Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6361101imu; Mon, 21 Jan 2019 07:37:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN6SF8btBwHGHB7ts7UpIoakzhe6datx+tbQeSBAnygbo6f2Kzo5x1SNHQgpPDIPd4aNPRFJ X-Received: by 2002:a63:3e05:: with SMTP id l5mr26838862pga.96.1548085025821; Mon, 21 Jan 2019 07:37:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548085025; cv=none; d=google.com; s=arc-20160816; b=Yl9KI+P/j9zvJ1zd5hjPGH2rCig9I/SvdHfSAzEcAtjTkeyauk4ffmWBCYETpKqTRN VjzR4jH3vad0JjTm1X/ia+JLyoTi6hqVl7cneAAc5pKFEl8zFEKIbh+sibff5JFZLZec qFnlpCMKml0ao2y2LWNwtXrr8Nc0IKiZWMqmeoCA05x4rwP6z4MDCjwnPeX0vMZww1ya VJDCG24ltMwexLdRupi8ZciBcpnwWuJD8enTxxUiWRHZwSvCzgVrgxhxKVpnbPGZYjvZ TLIxF2bURdrJR8VN5GZNgvG/VtElNw35o17g7kAubEGLxxomiEf5mEyiN+YwDy63C8t+ esOA== 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=rYVMC4CzJ8OhyRgo61CT5F30zwqlbo6KlTBm6X1QXHE=; b=nvhMLZIBMZ/W/KnGPoZ14XEVutQHBwC1rakEh2e9NIaYhTHhZ6cZdumWSDwJTSFp1k 8sM2wgfMPEMUhYJYuSovqlbposEyvXCMyYmPtd+YmQq6WG9ypP5cJ2ecjM8/NqLDoW29 WJSoo1TqW0jvxb3R/WxcDGb0CicguLgb3wTn4Bhn4uG899kn3SGawASfxu9wE2iFk4S6 oQxp/XI/NmZaU4J/Ck/npCRjBI8+akVkP7v63WYKVUlA/qnaLok/spDs30zlcqkRYvE4 el8BETODIvjdUKQm2sEIWBAFtjXT/bgp2vixh8W/2AYdVZnSrh32n06oCLBVPh12gDi1 FaYw== 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 bc3si12459409plb.130.2019.01.21.07.36.50; Mon, 21 Jan 2019 07:37:05 -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 S1730265AbfAUPee (ORCPT + 99 others); Mon, 21 Jan 2019 10:34:34 -0500 Received: from foss.arm.com ([217.140.101.70]:36528 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730135AbfAUPeb (ORCPT ); Mon, 21 Jan 2019 10:34:31 -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 683F71684; Mon, 21 Jan 2019 07:34:31 -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 9BB143F5C1; Mon, 21 Jan 2019 07:34:29 -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, mark.rutland@arm.com, Julien Thierry Subject: [PATCH v9 13/26] arm64: daifflags: Include PMR in daifflags restore operations Date: Mon, 21 Jan 2019 15:33:32 +0000 Message-Id: <1548084825-8803-14-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1548084825-8803-1-git-send-email-julien.thierry@arm.com> References: <1548084825-8803-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 The addition of PMR should not bypass the semantics of daifflags. When DA_F are set, I bit is also set as no interrupts (even of higher priority) is allowed. When DA_F are cleared, I bit is cleared and interrupt enabling/disabling goes through ICC_PMR_EL1. Signed-off-by: Julien Thierry Reviewed-by: Catalin Marinas Cc: Catalin Marinas Cc: Will Deacon Cc: James Morse --- arch/arm64/include/asm/daifflags.h | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/daifflags.h b/arch/arm64/include/asm/daifflags.h index 546bc39..1fd390e 100644 --- a/arch/arm64/include/asm/daifflags.h +++ b/arch/arm64/include/asm/daifflags.h @@ -18,6 +18,8 @@ #include +#include + #define DAIF_PROCCTX 0 #define DAIF_PROCCTX_NOIRQ PSR_I_BIT @@ -36,7 +38,13 @@ static inline unsigned long local_daif_save(void) { unsigned long flags; - flags = arch_local_save_flags(); + flags = read_sysreg(daif); + + if (system_uses_irq_prio_masking()) { + /* If IRQs are masked with PMR, reflect it in the flags */ + if (read_sysreg_s(SYS_ICC_PMR_EL1) <= GIC_PRIO_IRQOFF) + flags |= PSR_I_BIT; + } local_daif_mask(); @@ -45,12 +53,27 @@ static inline unsigned long local_daif_save(void) static inline void local_daif_restore(unsigned long flags) { - if (!arch_irqs_disabled_flags(flags)) + bool irq_disabled = flags & PSR_I_BIT; + + if (!irq_disabled) { trace_hardirqs_on(); - arch_local_irq_restore(flags); + if (system_uses_irq_prio_masking()) + arch_local_irq_enable(); + } else if (!(flags & PSR_A_BIT)) { + /* + * If interrupts are disabled but we can take + * asynchronous errors, we can take NMIs + */ + if (system_uses_irq_prio_masking()) { + flags &= ~PSR_I_BIT; + arch_local_irq_disable(); + } + } + + write_sysreg(flags, daif); - if (arch_irqs_disabled_flags(flags)) + if (irq_disabled) trace_hardirqs_off(); } -- 1.9.1