Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6361532imu; Mon, 21 Jan 2019 07:37:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN5SSKMAdROgx0e8XBEgWwvKtll++ML2ZaT8gSihB6rCCo/mMSKdWJzRdM/zAyHoenEwfPNZ X-Received: by 2002:a17:902:584:: with SMTP id f4mr31468772plf.28.1548085051641; Mon, 21 Jan 2019 07:37:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548085051; cv=none; d=google.com; s=arc-20160816; b=Nk/UpFkPMKfzPHtGIKZ/hnGAnHvGSZajbDkwQgtxzW7OC3IQ5dCw5Tu860hZXveiqJ hijGoylXUzjx26OVFtc3gSsDBL9A4VjnEkDsmoXnVrHlm5YqJXSA0JqLrm3Qtf3P8l7a hOCaRptpEE9c0xEAEm3LekdriFWJriU+c3gWWzIDe25ENA1Xcf8KpktAvITCEBK1/RST 6xcxUFW0fNbztd+uaZFWAjZleXXPtLCyOvBrCugpy8WiIpYyumJQbmLQWOBxwB4zzMic G4tEDH2qnPQcT+lPfS3oNuOQchWDTLs9qL9fl6PvKgHWaSP1xE4qYlgRqZkLSfLEcwWj cDxQ== 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=H+hOS5KBiMF8RR6fk7pyhSQtB6OoPqn0Ej0GCn73ySY=; b=SxXTiL+TxQvixZG+YvKUNf8QtQdgrIrvK8wezO8QEZMPz7RVNAJy5w+HxkDuri7BYM zpHms2AZLCYDGPeliZLi6qYYyTtQveF7g/+amqLWaFeyYh6TTrkjagwhfZNjIcf9o4H7 NzPjZyln9Im7eVpJYcmGn+81KB0gR0Vxm+fyPGrQInf6YFK5rg/goCyYIuweaGMsS6cp GmMnlBVb8FzgD/WkHFM91m8mGAm365mIaa+ybAsmhKXbXEntDaSbGvgBLJy1Mf/+tqfA MT1w/0uUWYcfXBoREkETryK0k70Oyy2Af6R0hlYdkV1iwHfEWCRBIdZ4Vn7Afc7GlibE vxGA== 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 x61si13180418plb.303.2019.01.21.07.37.16; Mon, 21 Jan 2019 07:37:31 -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 S1730462AbfAUPeu (ORCPT + 99 others); Mon, 21 Jan 2019 10:34:50 -0500 Received: from foss.arm.com ([217.140.101.70]:36626 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730394AbfAUPes (ORCPT ); Mon, 21 Jan 2019 10:34:48 -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 3B74315BE; Mon, 21 Jan 2019 07:34:48 -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 EF89A3F5C1; Mon, 21 Jan 2019 07:34:45 -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 , Thomas Gleixner , Jason Cooper Subject: [PATCH v9 20/26] irqchip/gic-v3: Handle pseudo-NMIs Date: Mon, 21 Jan 2019 15:33:39 +0000 Message-Id: <1548084825-8803-21-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 Provide a higher priority to be used for pseudo-NMIs. When such an interrupt is received, keep interrupts fully disabled at CPU level to prevent receiving other pseudo-NMIs while handling the current one. Signed-off-by: Julien Thierry Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier --- drivers/irqchip/irq-gic-v3.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 5374b43..4df1e94 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -41,6 +41,8 @@ #include "irq-gic-common.h" +#define GICD_INT_NMI_PRI (GICD_INT_DEF_PRI & ~0x80) + #define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0) struct redist_region { @@ -381,12 +383,45 @@ static u64 gic_mpidr_to_affinity(unsigned long mpidr) return aff; } +static inline void gic_deactivate_unexpected_irq(u32 irqnr) +{ + if (static_branch_likely(&supports_deactivate_key)) { + if (irqnr < 8192) + gic_write_dir(irqnr); + } else { + gic_write_eoir(irqnr); + } +} + +static inline void gic_handle_nmi(u32 irqnr, struct pt_regs *regs) +{ + int err; + + if (static_branch_likely(&supports_deactivate_key)) + gic_write_eoir(irqnr); + /* + * Leave the PSR.I bit set to prevent other NMIs to be + * received while handling this one. + * PSR.I will be restored when we ERET to the + * interrupted context. + */ + err = handle_domain_nmi(gic_data.domain, irqnr, regs); + if (err) + gic_deactivate_unexpected_irq(irqnr); +} + static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) { u32 irqnr; irqnr = gic_read_iar(); + if (gic_supports_nmi() && + unlikely(gic_read_rpr() == GICD_INT_NMI_PRI)) { + gic_handle_nmi(irqnr, regs); + return; + } + if (gic_prio_masking_enabled()) { gic_pmr_mask_irqs(); gic_arch_enable_irqs(); @@ -403,12 +438,7 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs err = handle_domain_irq(gic_data.domain, irqnr, regs); if (err) { WARN_ONCE(true, "Unexpected interrupt received!\n"); - if (static_branch_likely(&supports_deactivate_key)) { - if (irqnr < 8192) - gic_write_dir(irqnr); - } else { - gic_write_eoir(irqnr); - } + gic_deactivate_unexpected_irq(irqnr); } return; } -- 1.9.1