From patchwork Thu Oct 10 11:34:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13830026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B19CCF11DA for ; Thu, 10 Oct 2024 12:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/aytaH1oLbxE7oXL5Lh1BICkPib3Ft7vQWy4tTKokWI=; b=gZBJiQJTW6N5tPui4hJz9bGs7N 2EPhZ/mkg0zxjQca9LS8/ZI82pcQztUrLFi0YwkYAbtEFpS0ywv37vHqZkKduGhsEXs//SHGXLDHw mEU1Ed3x3seI7rwtiSuS1zdVRHcdzo10dJvgRIPR+jLnLpdtQ7hkBKXDEa1814mLMnPrwp5VqyPXk 5vnr5gSI2TS2tQbtnkJillfgiQ7+GkwxCwsJncIBKA8nv7yCM1E+gMFm+YAGeG1pbBeWZkcUgtCa2 DOjT8ajiK1SFYpAEFutucYRADvlFU+EnHCy6ZQyc28iTiX63ADq25RYKSeJmAE1p9+iXxYM9MMypa zs02VkaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sys3I-0000000CfTX-43Nv; Thu, 10 Oct 2024 12:13:57 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syrR7-0000000CYSC-0Esd for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 11:34:35 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a995ec65c35so137467566b.1 for ; Thu, 10 Oct 2024 04:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728560067; x=1729164867; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=/aytaH1oLbxE7oXL5Lh1BICkPib3Ft7vQWy4tTKokWI=; b=GIbTy5ikZq3Ka4m710Sm5ZoNEN2gAxM5rzWVMM5SCVDEK0lugxSCsklJHkL9yxpjr0 EoUHcfi4SWZI3sdZRqf9A5V42NoNhLAP+/KuFTVnfgUXfskpIZWMtcb3fppn/L/rIGnX cOwaU0UuKZREt1xW02za7ZzeLDZ+aCg64XaJe/2N6UZMNJcee4kfxO1bxP9/28JP80IY UdtWkoyoDWOwZptho01vYD2eRr0f8aKkpaknOwxR+BCYCOPE260YAzawMgDGLAL82NKh WU589acssaYlWFX1eMdseqlcSZ8ss1P742yEaBNnRDqc2yDBGhBOoaCGQX4ACBVY7WPd NcXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728560067; x=1729164867; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/aytaH1oLbxE7oXL5Lh1BICkPib3Ft7vQWy4tTKokWI=; b=FUPyfmhA1e5Y4LVMe4YSGigviGXrg1yExmwIAJsB5hFxKmwJx3hCYLwNO4QSvcgJje 28IHNqN8pbOWkWDonF7Dhr1Pdy9k1x6TzVkMfkLaeZl+se6muoLVpLM9kvRP+qpKtPAh yfBcBo050juvPj0Q/R1+lWe7c0Tdj38Qhc/Nxc28c0xMOBYLSLli8A93l3vjXk1VGkJl VFMTQ9tZFX8U5LV+6w8pzpsyI2iPgte9X8gxltbqLBN3G8ACkPMd+PaXv6JtK2jCRzkJ 09n6aVFylL3rf3CPFIzTu35QIwj0DOm5oREBoLaJ86ZW8JPEK0xDYi7h6M0bY+Sh6VR7 BS2A== X-Gm-Message-State: AOJu0Yy/eYNax8zbpkcIjcjDPfLBaEZpL6vXDcohf+EcvfGSHrE7T2k+ xy+RODiF9HeRSMdMMOx9iYtiWxZTT/r+ycqLYWFRqtvogg//YjI5OPA3HYBi8y8= X-Google-Smtp-Source: AGHT+IHJCZC9ttmjEV4fugv9O8uxWYQ1Bo3ztMHrIb7V/zI60wobNn2BdMO/fiOPIzAK9oQNZ6UZoA== X-Received: by 2002:a17:907:940a:b0:a99:55ca:3758 with SMTP id a640c23a62f3a-a99a10e840emr242802266b.8.1728560067473; Thu, 10 Oct 2024 04:34:27 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a7f25406sm77619066b.69.2024.10.10.04.34.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 04:34:26 -0700 (PDT) From: Linus Walleij Date: Thu, 10 Oct 2024 13:34:05 +0200 Subject: [PATCH RFC 27/28] ARM: entry: Add FIQ/NMI C callbacks MIME-Version: 1.0 Message-Id: <20241010-arm-generic-entry-v1-27-b94f451d087b@linaro.org> References: <20241010-arm-generic-entry-v1-0-b94f451d087b@linaro.org> In-Reply-To: <20241010-arm-generic-entry-v1-0-b94f451d087b@linaro.org> To: Oleg Nesterov , Russell King , Kees Cook , Andy Lutomirski , Will Drewry , Frederic Weisbecker , "Paul E. McKenney" , Jinjie Ruan , Arnd Bergmann , Ard Biesheuvel , Al Viro Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_043429_227714_C25C7A24 X-CRM114-Status: GOOD ( 13.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org These NMI (FIQ) callbacks are added to complete the calls expected by the generic entry. They are perfectly fine to add code to but are left empty for now. Signed-off-by: Linus Walleij --- arch/arm/include/asm/entry.h | 4 ++++ arch/arm/kernel/entry-armv.S | 14 +++++++++++--- arch/arm/kernel/entry-header.S | 2 ++ arch/arm/kernel/entry.c | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/entry.h b/arch/arm/include/asm/entry.h index a78bc5054b09..2e7ccd87f0eb 100644 --- a/arch/arm/include/asm/entry.h +++ b/arch/arm/include/asm/entry.h @@ -14,5 +14,9 @@ void irqentry_enter_from_user_mode(struct pt_regs *regs); void irqentry_exit_to_user_mode(struct pt_regs *regs); void irqentry_enter_from_kernel_mode(struct pt_regs *regs); void irqentry_exit_to_kernel_mode(struct pt_regs *regs); +void irqentry_nmi_enter_from_user_mode(struct pt_regs *regs); +void irqentry_nmi_exit_to_user_mode(struct pt_regs *regs); +void irqentry_nmi_enter_from_kernel_mode(struct pt_regs *regs); +void irqentry_nmi_exit_to_kernel_mode(struct pt_regs *regs); #endif /* __ASM_ENTRY_H__ */ diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 600375f6f5d8..839f3ebe7228 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -157,7 +157,7 @@ ENDPROC(__und_invalid) #define SPFIX(code...) #endif - .macro svc_entry, stack_hole=0 uaccess=1, overflow_check=1 + .macro svc_entry, stack_hole=0 uaccess=1, overflow_check=1, nmi=0 UNWIND(.fnstart ) sub sp, sp, #(SVC_REGS_SIZE + \stack_hole) THUMB( add sp, r1 ) @ get SP in a GPR without @@ -205,7 +205,11 @@ ENDPROC(__und_invalid) uaccess_entry tsk, r0, r1, r2, \uaccess mov r0, sp @ 'regs' + .if \nmi + bl irqentry_nmi_enter_from_kernel_mode + .else bl irqentry_enter_from_kernel_mode + .endif .endm @@ -297,7 +301,7 @@ ENDPROC(__pabt_svc) .align 5 __fiq_svc: - svc_entry + svc_entry nmi=1 mov r0, sp @ struct pt_regs *regs bl handle_fiq_as_nmi svc_exit_via_fiq @@ -315,7 +319,7 @@ ENDPROC(__fiq_svc) @ .align 5 __fiq_abt: - svc_entry + svc_entry nmi=1 ARM( msr cpsr_c, #ABT_MODE | PSR_I_BIT | PSR_F_BIT ) THUMB( mov r0, #ABT_MODE | PSR_I_BIT | PSR_F_BIT ) @@ -490,9 +494,13 @@ ENDPROC(ret_from_exception) .align 5 __fiq_usr: usr_entry + mov r0, sp + bl irqentry_nmi_enter_from_user_mode kuser_cmpxchg_check mov r0, sp @ struct pt_regs *regs bl handle_fiq_as_nmi + mov r0, sp + bl irqentry_nmi_exit_to_user_mode get_thread_info tsk restore_user_regs UNWIND(.fnend ) diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S index cfaf14d71378..ec8a6e193802 100644 --- a/arch/arm/kernel/entry-header.S +++ b/arch/arm/kernel/entry-header.S @@ -252,6 +252,8 @@ @ .macro svc_exit_via_fiq uaccess_exit tsk, r0, r1 + mov r0, sp + bl irqentry_nmi_exit_to_kernel_mode #ifndef CONFIG_THUMB2_KERNEL @ ARM mode restore mov r0, sp diff --git a/arch/arm/kernel/entry.c b/arch/arm/kernel/entry.c index 1e1284cc4cae..09109215dfdf 100644 --- a/arch/arm/kernel/entry.c +++ b/arch/arm/kernel/entry.c @@ -69,3 +69,19 @@ noinstr void irqentry_exit_to_kernel_mode(struct pt_regs *regs) else trace_hardirqs_off(); } + +noinstr void irqentry_nmi_enter_from_user_mode(struct pt_regs *regs) +{ +} + +noinstr void irqentry_nmi_exit_to_user_mode(struct pt_regs *regs) +{ +} + +noinstr void irqentry_nmi_enter_from_kernel_mode(struct pt_regs *regs) +{ +} + +noinstr void irqentry_nmi_exit_to_kernel_mode(struct pt_regs *regs) +{ +}