From patchwork Thu Jan 31 14:59:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 10790789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79AF0746 for ; Thu, 31 Jan 2019 15:18:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6846C31399 for ; Thu, 31 Jan 2019 15:18:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5795B313A4; Thu, 31 Jan 2019 15:18:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DD94731399 for ; Thu, 31 Jan 2019 15:18:21 +0000 (UTC) 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=Xm/KQY7N95ePvFpNRxaGMRSSVrRoOVOi4yMWSBxGhB4=; b=p+evOHGt88PeCY+pEk9UD+KiOj BZQkDXB2Sva2WcTn0nwPbWA3IfDY/5zd3BSma5AIFkDtBzoyIMN7cmJEnsYYsSU25J3vtr50j+7Ya EBCC248qIGX9HyI8nBzBh0dm75jCe4D9l6wvVKv8wrSX11a71SmqwgR6tYFEaQSuSPVR/XUZceCrb Ft691+naK9dYdoQIvt6Ly3bMZxOMgOTP+PvS+81ozpSSCvDnJ1sfPOFT/KWSYDOEKFhYYjgz5X+AO B4JKN53wj4erQJwT7vyyxvE0hinhlfkQe+M24V/q2cRHX1zp+6sqJ01V7ExTGXUV9DltTQxJ6yFHz gwdpYJtQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpE6c-0002xV-9g; Thu, 31 Jan 2019 15:18:18 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpE4x-0001CY-TH for linux-arm-kernel@bombadil.infradead.org; Thu, 31 Jan 2019 15:16:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=lwCT6AJySXy1/0+AeTL0z3O2pPPJwDO3cbM5kqHzsOg=; b=CGAxArSD45aZrrd+egkgoFDlA np+mYOmOv6tHzJOfy/dg1VbogdvJQQgKzzW9tusNoOG0PMP8QhnN88yvJG4wzyEMemAPm425MBJxE 80pyVoKdLiS1LvMEzhdkSznJmdMbJ7Y6qqwUqayK4RD8kRayv2yTbMVOO3ycz2t7T1o6pgrjL7tj9 2QsRk9sQExOSAfwID6wFcqZAAqNSxKX0qKkoKG+AlkA3umIwuY+A8AJW9xdsm7u2FLjkG2SMYpQmh pqS8cVLd/akLyLRgfhnLVD1nQUlUyS+pXsC8SI3WLkMojYrtxR1UN63Q/yxoO3mU/z86XpYe21dKY hKKirSw1g==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpDp5-0008Gm-Jq for linux-arm-kernel@lists.infradead.org; Thu, 31 Jan 2019 15:00:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C66E91684; Thu, 31 Jan 2019 07:00:10 -0800 (PST) Received: from e112298-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CDE0A3F59C; Thu, 31 Jan 2019 07:00:08 -0800 (PST) From: Julien Thierry To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v10 23/25] arm64: Skip preemption when exiting an NMI Date: Thu, 31 Jan 2019 14:59:01 +0000 Message-Id: <1548946743-38979-24-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1548946743-38979-1-git-send-email-julien.thierry@arm.com> References: <1548946743-38979-1-git-send-email-julien.thierry@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190131_150011_894659_CE49F86D X-CRM114-Status: UNSURE ( 9.70 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, daniel.thompson@linaro.org, Julien Thierry , marc.zyngier@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, christoffer.dall@arm.com, james.morse@arm.com, joel@joelfernandes.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Handling of an NMI should not set any TIF flags. For NMIs received from EL0 the current exit path is safe to use. However, an NMI received at EL1 could have interrupted some task context that has set the TIF_NEED_RESCHED flag. Preempting a task should not happen as a result of an NMI. Skip preemption after handling an NMI from EL1. Signed-off-by: Julien Thierry Acked-by: Marc Zyngier Cc: Catalin Marinas Cc: Will Deacon Cc: Marc Zyngier --- arch/arm64/kernel/entry.S | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 35a47f6..acf1250 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -624,7 +624,15 @@ el1_irq: #ifdef CONFIG_PREEMPT ldr x24, [tsk, #TSK_TI_PREEMPT] // get preempt count - cbnz x24, 1f // preempt count != 0 +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 el1_preempt 1: #endif