Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3416776imu; Mon, 28 Jan 2019 04:35:23 -0800 (PST) X-Google-Smtp-Source: ALg8bN66bnFITlj+Wiq8BytbnUlhpeSdyfotuVAhMKzhcULNxghmrv/tCPG/AVhwu5Xq3e/oTaev X-Received: by 2002:a62:62c5:: with SMTP id w188mr21922939pfb.160.1548678923204; Mon, 28 Jan 2019 04:35:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548678923; cv=none; d=google.com; s=arc-20160816; b=zEKvQj58QyPSXKhSmkU+CXFE0vRejVmb+qnYi05ipDEbj8+PPPLAXpiLouUEGrLb3k ad6KVw4X7bFqTmciA9FeiVjXOZHJUxlUh5xOuxUlYS7SdwdG3PLmJCchdeB3FQWMLgLe dtJrx64aCsKXznwONYPl9nq7TfAHTvE234Ukz2KU47y7s4DIQFEOGPBKbcgOEDGzlzaa nrSEKeT1WdzaGC0xtxMb6Em+QhlwB8+Ivy0u3liTmpQXR0FuyyMVkUHMo1tZGproEXOa LGs+UQudNkoFdSBIvkBPYhnaBj5AyMrrKbtNkLDLIN5u9d4xT/TVbLHMQeT7pVUAHmWw wQ9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:user-agent :references:in-reply-to:subject:cc:to:from:message-id:date; bh=rfkv9db6UCuWBlPANJDrc57qx1mPxAA24p+OrMEtmjc=; b=pZ6JZh8ui1WsR+eGJz+tM8MSYoHunOeI+pIdGUWRL9YpIZyTNrqu6ZxjlBqXwNCMvi PqLmvuBWYNZ38ksTDEhr4F+ZnW1SNTQWw1CmWV58zpCOi2E9SAiYHJHvRGMKbCvEQsPp SHULkAMNanXdCx8PgwTQprnhJ3Yv+XfyTwt/hcuJzkjM0sofbLIbGWQQ14pP9f6hN/y3 yXti8lVmBU5CWESrWWdSJLcIvq7NaiFS9eVwi3Gf1KkqvLFJSweLnYPCeiDwGO5w9ae/ MbTLjMlmdIpdrADJObX1aCVW4TFK0Fgm9upfL+WU0N+Y2jBcbKIV2227vDVfTW6wr5io k/jg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 35si31970862pgn.278.2019.01.28.04.35.07; Mon, 28 Jan 2019 04:35:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbfA1MeN (ORCPT + 99 others); Mon, 28 Jan 2019 07:34:13 -0500 Received: from foss.arm.com ([217.140.101.70]:44752 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726611AbfA1MeN (ORCPT ); Mon, 28 Jan 2019 07:34:13 -0500 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 C37EB80D; Mon, 28 Jan 2019 04:34:12 -0800 (PST) Received: from big-swifty.misterjones.org (big-swifty.cambridge.arm.com [10.1.39.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 47C053F59C; Mon, 28 Jan 2019 04:34:10 -0800 (PST) Date: Mon, 28 Jan 2019 12:34:13 +0000 Message-ID: <86r2cxufju.wl-marc.zyngier@arm.com> From: Marc Zyngier To: Julien Thierry Cc: , , , , , , , , Subject: Re: [PATCH v9 24/26] arm64: Skip preemption when exiting an NMI In-Reply-To: <1548084825-8803-25-git-send-email-julien.thierry@arm.com> References: <1548084825-8803-1-git-send-email-julien.thierry@arm.com> <1548084825-8803-25-git-send-email-julien.thierry@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: ARM Ltd MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 21 Jan 2019 15:33:43 +0000, Julien Thierry wrote: > > 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 > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Marc Zyngier > --- > arch/arm64/kernel/entry.S | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S > index 35a47f6..a0b0a22 100644 > --- a/arch/arm64/kernel/entry.S > +++ b/arch/arm64/kernel/entry.S > @@ -624,6 +624,14 @@ el1_irq: > > #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 > bl el1_preempt > 1: I find this a bit ugly, as what we have in x24 is not the preempt count anymore. Maybe amend the comment above? The code being nonetheless correct: Acked-by: Marc Zyngier M. -- Jazz is not dead, it just smell funny.