Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3982615imu; Mon, 12 Nov 2018 03:59:15 -0800 (PST) X-Google-Smtp-Source: AJdET5dhhoGY58EtwTuBXbyviNZx+O2aLyqYafTTI8V4IkPz44K6ucvfJMGF4W77cIq9WhycHv2y X-Received: by 2002:a17:902:b18c:: with SMTP id s12-v6mr673970plr.16.1542023955340; Mon, 12 Nov 2018 03:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542023955; cv=none; d=google.com; s=arc-20160816; b=zM/quDuPl9DuhFB067Y8qDLoK1C3/yEPqAa1vtFwaKpLClod3PWXjt0qIkp0Efs65P bwvd+kFMoTgdHsR8LxTsYu3WaL8UJ3dejaojRCizdOBqwR38GQVxnlQFkdVk1TWIcjYX C7pN/9bP86NmMgushGhwT06JBkz29G+CyMgZgZiJk1RL7oOyq+oYkKWTe3hbjAOtHDZB NpaIg8S+S9kdldYBEk4JU5iotVTETfNoB7p7ddu7ynXLWByeq3E2Lhw31mmdOpjYEa+N SM4OyJhyB3wu/auSI0kontLrMjSC0zhBSozOWcGcaXbjhd1B3DLDmaRt8AMTNfuvRg7Y U73Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=fVPpcgyWnXP69qJMQnEmahgKA6Hyr+ekOGnWYJKHvhQ=; b=qRT93uI02M9FhH1W/LdyEgjEbIiySdPkZ4bekMC079uEKGDtEKGBt6XDPUF7voWgIG 86nslX0rxjvKEYLLmK7grd3sWX5R5/+fZu36D3M2b+PhvDhqprvGa2FrFj8AMZDPESl4 kkY7TH5TvD9sberDS48DnQJpRLA+l6O0jaLtOpuPBp0IERZTzs67kDs31/+U7HX/7+oF UYfpCZsxuxcIHz26FET9VNBBk+dsUx/jVhmKStxtpjX9hGpnbjTLRK9Xl5PCM9KqaTV9 gJfVovbeyeexVPVRNwZ2dhoMu9arJ75w9OZwyzGqyk+RW2y19oFJQHhFzTSMYMBqZH9C dS4w== 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 e7si110464pgv.499.2018.11.12.03.59.00; Mon, 12 Nov 2018 03:59:15 -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 S1730119AbeKLVvN (ORCPT + 99 others); Mon, 12 Nov 2018 16:51:13 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34806 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729293AbeKLVvM (ORCPT ); Mon, 12 Nov 2018 16:51:12 -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 0205015BF; Mon, 12 Nov 2018 03:58:16 -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 363A83F5A0; Mon, 12 Nov 2018 03:58:14 -0800 (PST) From: Julien Thierry To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, daniel.thompson@linaro.org, joel@joelfernandes.org, marc.zyngier@arm.com, christoffer.dall@arm.com, james.morse@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Julien Thierry Subject: [PATCH v6 22/24] arm64: Skip preemption when exiting an NMI Date: Mon, 12 Nov 2018 11:57:13 +0000 Message-Id: <1542023835-21446-23-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1542023835-21446-1-git-send-email-julien.thierry@arm.com> References: <1542023835-21446-1-git-send-email-julien.thierry@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 eb8120e..e02ee55 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -636,6 +636,14 @@ el1_irq: #ifdef CONFIG_PREEMPT ldr w24, [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 w24, w24, w0 +alternative_else_nop_endif cbnz w24, 1f // preempt count != 0 ldr x0, [tsk, #TSK_TI_FLAGS] // get flags tbz x0, #TIF_NEED_RESCHED, 1f // needs rescheduling? -- 1.9.1