From mboxrd@z Thu Jan 1 00:00:00 1970 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 35188C4332F for ; Fri, 4 Nov 2022 23:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Eoe+keuKl2KcXsuzF35bQpZGkavhijgTUqRuiyRI6/0=; b=ksH9ZmExj3oTiM ATKQ2Nrp50LKbftRGCOebr/9P7Jn1/05oLZYLuYtStmPuh7Qafq6TWOany+6DSwXudVMPcwk7JC/8 F3W18wiNJfBMkX8hVU4U0xUEjYUFEijv+T3CziRjDV1YEAgIjINzcj9JauScdyW57tZV4zTi5ILw2 7vaFBNw8YcWb2j/+EziX6NnV7I5/hDKz6iOFYdxyYRR+8vOGXohSCasDUGN3L4+h8V3+Io6oLla/d VoyDcWANzR1piiVQaiz01qEHOqIlDyUU8JxGRdE9xH7rjyxhUW0cXtWvl+tFeuNpXG/I4ed3lPo2q RJFOp7551UwSEsujHFFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1or6Yc-005XWZ-E3; Fri, 04 Nov 2022 23:57:06 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1or6Wz-005Wh7-5T for linux-arm-kernel@lists.infradead.org; Fri, 04 Nov 2022 23:55:27 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C5800B83012; Fri, 4 Nov 2022 23:55:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91F5CC43140; Fri, 4 Nov 2022 23:55:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667606122; bh=ghgTTUKPLmbZpgJ9baB6YeZLj5+YNBBYVvSLTJAni7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EjTVPovqbSQVsZwVMjcqn+/UTiIEXiQtRF2HBxorxYssPSnIV7JbPNlB9zqas3v3o gfDi+sA8rtssRBGHtQ8+kpv7pExpiQqpxFdhCeeIh0TTHGe+ZtqLveqoV7M65oUpsy 2m5JehN6P1Z8Icr5h7MyeV/CjCVxT/r98esZwf9CylObvI4QloxXaqOHFus41CLIg7 zxnphEFDKDrGomLiFcPq/4HfKmwYF1FmHUqCXwjAOjkxI4nYpdQBnEJfqi5/h1qwdq 6RpkZ+7pxWNy1ys8RNKhw55pP/D8djAySGA9MLmsXkaHOTm49tNenGoyUOwXYx6zgJ TIgvck+3f+V0w== From: Mark Brown To: Catalin Marinas , Will Deacon , Marc Zyngier Cc: Lorenzo Pieralisi , Mark Rutland , Sami Mujawar , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v1 09/18] arm64/entry: Manage ALLINT.ALLINT when FEAT_NMI is active Date: Fri, 4 Nov 2022 23:54:44 +0000 Message-Id: <20221104235453.870573-10-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221104235453.870573-1-broonie@kernel.org> References: <20221104235453.870573-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3629; i=broonie@kernel.org; h=from:subject; bh=ghgTTUKPLmbZpgJ9baB6YeZLj5+YNBBYVvSLTJAni7E=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjZaZDebaUqNTSOLYoFhhbtxTgouq+uiivwVY+pRH8 MYOejEKJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY2WmQwAKCRAk1otyXVSH0NcbB/ wIbt8kLwCbFyeW/u4WfADbgpYmB+I7GZERNtwBjT6e4UM0DyqLoJOcLa3Ope5MEHz8RkXEUdthW/lN 0h/3X35IgYZOecr2hQSfe0c0+mEOy01FOFYjjgXEFvhTMiHuRXQGNk2pvBLNJOek6LH4KZ7vp/sT5u 6LzI8ruUMSobLCp/ImvzCFVjNE4RPBmsEGH9y2h5zf9nrg6Fuoq9ehCkkeEgBobKgs0WQMi3VBMZiR WDr7JBpFYuXl3BN03oQ+scxC8TMubN+ThsliLxozxP3PUnGtaC2xq60IDLdaS22WQptpnn3vs5tmjo njM4cZHAPQJA2PxnyJbFcgBlQi59po X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221104_165525_521103_DDF287E7 X-CRM114-Status: GOOD ( 17.24 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As might not be expected given the name the superpriority interrupts provided by FEAT_NMI can in fact be masked which must be managed by EL1 code to ensure that the time spent with superpriority interrupts masked is minimised without causing reentrancy issues. We configure FEAT_NMI with SCTLR_EL1.SPINTMASK clear since we do not use PSTATE.SP to manage a kernel stack pointer. This means that on entry to EL1 ALLINT.ALLINT will be set and it is the responsibility of EL1 to clear it to ensure that both normal and superpriority interrupts are not masked. Add appropriate code in each EL1 entry path, with no special handling for superpriority interrupts introduced yet. Since we need to handle unmasking differently in the case of superpriority interrupts this code is not factored out into the assembly code. Due to the number of special cases in the various entry paths and in order to ensure that superpriority interrupts are masked for as little time as possible explicit handling in each of the entry points seemed the simplest and most robust approach. Signed-off-by: Mark Brown --- arch/arm64/kernel/entry-common.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c index 9173fad279af..32547723fcc8 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -294,6 +295,8 @@ static void noinstr __panic_unhandled(struct pt_regs *regs, const char *vector, __show_regs(regs); panic("Unhandled exception"); + + nmi_unmask(); } #define UNHANDLED(el, regsize, vector) \ @@ -420,6 +423,8 @@ asmlinkage void noinstr el1h_64_sync_handler(struct pt_regs *regs) { unsigned long esr = read_sysreg(esr_el1); + nmi_unmask(); + switch (ESR_ELx_EC(esr)) { case ESR_ELx_EC_DABT_CUR: case ESR_ELx_EC_IABT_CUR: @@ -477,6 +482,7 @@ static __always_inline void __el1_irq(struct pt_regs *regs, static void noinstr el1_interrupt(struct pt_regs *regs, void (*handler)(struct pt_regs *)) { + nmi_unmask(); write_sysreg(DAIF_PROCCTX_NOIRQ, daif); if (IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI) && !interrupts_enabled(regs)) @@ -499,6 +505,7 @@ asmlinkage void noinstr el1h_64_error_handler(struct pt_regs *regs) { unsigned long esr = read_sysreg(esr_el1); + nmi_unmask(); local_daif_restore(DAIF_ERRCTX); arm64_enter_nmi(regs); do_serror(regs, esr); @@ -649,6 +656,8 @@ asmlinkage void noinstr el0t_64_sync_handler(struct pt_regs *regs) { unsigned long esr = read_sysreg(esr_el1); + nmi_unmask(); + switch (ESR_ELx_EC(esr)) { case ESR_ELx_EC_SVC64: el0_svc(regs); @@ -706,6 +715,7 @@ static void noinstr el0_interrupt(struct pt_regs *regs, { enter_from_user_mode(regs); + nmi_unmask(); write_sysreg(DAIF_PROCCTX_NOIRQ, daif); if (regs->pc & BIT(55)) @@ -742,6 +752,7 @@ static void noinstr __el0_error_handler_common(struct pt_regs *regs) { unsigned long esr = read_sysreg(esr_el1); + nmi_unmask(); enter_from_user_mode(regs); local_daif_restore(DAIF_ERRCTX); arm64_enter_nmi(regs); @@ -777,6 +788,8 @@ asmlinkage void noinstr el0t_32_sync_handler(struct pt_regs *regs) { unsigned long esr = read_sysreg(esr_el1); + nmi_unmask(); + switch (ESR_ELx_EC(esr)) { case ESR_ELx_EC_SVC32: el0_svc_compat(regs); -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel