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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B788C282DD for ; Wed, 8 Jan 2020 18:57:58 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6C0C720678 for ; Wed, 8 Jan 2020 18:57:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OGm9tv8e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C0C720678 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Tp+R7q4qDqR6QmmxVhzdR/ymgXX4hQxrOFivPuCDT+E=; b=OGm9tv8eaIDKhRrDh5bVEGVAuI +8WPE75rmdPRNXe0WAocpBJAfwRCVXLnfpyv3yd8/tvEAJ8RB2amyaij8BjnAsVLcNWIhq6S5ILvg 75nvCn0boqvjPf2keNpFiCjUm4cWFawIGYg1JUeGK4XWpY84/aewvsCxB7r2vVlzsdW3EHDoaOI/L gkxr/cWIWKEdG0PQrELslWcbmckMsIR9MlTHR/oKpCbap3pt9WfrDbwUxDkZTLW3XRqBqi2FgwWhW VnRaS+Dd2KUDCVL2G+WIzLKW1FzUZhFwCZsWELtK0uLWqgpbL84NxgsXopONU3Bns+u2hq99HZKtR TORhzHJQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipGWi-0008KE-R1; Wed, 08 Jan 2020 18:57:56 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipGVn-0007Pn-OU for linux-arm-kernel@lists.infradead.org; Wed, 08 Jan 2020 18:57:01 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1C8EEDA7; Wed, 8 Jan 2020 10:56:59 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8A5EC3F534; Wed, 8 Jan 2020 10:56:57 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, james.morse@arm.com Subject: [PATCH 04/17] arm64: entry: move preempt logic to C Date: Wed, 8 Jan 2020 18:56:21 +0000 Message-Id: <20200108185634.1163-5-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200108185634.1163-1-mark.rutland@arm.com> References: <20200108185634.1163-1-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200108_105659_912048_86657B51 X-CRM114-Status: GOOD ( 12.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, keescook@chromium.org, maz@kernel.org, broonie@kernel.org, labbott@redhat.com, robin.murphy@arm.com, julien.thierry.kdev@gmail.com, alex.popov@linux.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some of our preeemption logic is in C, while a portion of it is in assembly. Let's pull the remainder of it into C so that it lives in one place. At the same time, let's improve the comments regarding NMI preemption to make it clearer why we cannot preempt from NMIs. Subsequent patches will covert the caller of el1_preempt() to C. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: James Morse Cc: Julien Thierry Cc: Will Deacon --- arch/arm64/kernel/entry-common.c | 18 +++++++++++++++++- arch/arm64/kernel/entry.S | 13 +------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c index 4fa058453468..b93ca2148a20 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -334,8 +335,23 @@ asmlinkage void notrace el0_sync_compat_handler(struct pt_regs *regs) NOKPROBE_SYMBOL(el0_sync_compat_handler); #endif /* CONFIG_COMPAT */ -asmlinkage void __sched arm64_preempt_schedule_irq(void) +asmlinkage void __sched el1_preempt(void) { + if (!IS_ENABLED(CONFIG_PREEMPT) || preempt_count()) + return; + + /* + * To avoid nesting NMIs and overflowing the stack, we must leave NMIs + * masked until the exception return. We want to context-switch with + * IRQs masked but NMIs enabled, so cannot preempt an NMI. + * + * PSTATE.{D,A,F} are cleared for IRQ and NMI by el1_irq(). + * When gic_handle_irq() handles an NMI, it leaves PSTATE.I set. + * If anything is set in DAIF, this is an NMI. + */ + if (system_uses_irq_prio_masking() && read_sysreg(daif) != 0) + return; + lockdep_assert_irqs_disabled(); /* diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 7c6a0a41676f..53ce1877a4aa 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -606,18 +606,7 @@ el1_irq: irq_handler #ifdef CONFIG_PREEMPT - ldr x24, [tsk, #TSK_TI_PREEMPT] // get preempt count -alternative_if ARM64_HAS_IRQ_PRIO_MASKING - /* - * DA_F were cleared at start of handling. If anything is set in DAIF, - * we come back from an NMI, so skip preemption - */ - mrs x0, daif - orr x24, x24, x0 -alternative_else_nop_endif - cbnz x24, 1f // preempt count != 0 || NMI return path - bl arm64_preempt_schedule_irq // irq en/disable is done inside -1: + bl el1_preempt #endif #ifdef CONFIG_ARM64_PSEUDO_NMI -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel