Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3982450imu; Mon, 12 Nov 2018 03:59:02 -0800 (PST) X-Google-Smtp-Source: AJdET5dDWhnnh102MUcyVOcaijrvk5TFtoW0kUuZfghItxrEhMMjZohCDpcMsRL0eOaRnGxqaLIA X-Received: by 2002:a17:902:b83:: with SMTP id 3-v6mr690162plr.202.1542023942815; Mon, 12 Nov 2018 03:59:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542023942; cv=none; d=google.com; s=arc-20160816; b=Mp5vuq5Ord4ibeJTZEgKCvP5PiQ2d3PI+EOK3zypKrfYqD0Jy+Pqd43onOdkOM9ga5 X0wopvmtF6X68msQ+2zu66qc1QuKDNxHhAy6bd9iRsAVP9Q3e9Ahem7RIpEdskm32kgb mwgBuqkF8iKoPcKfG2p/tG2fkdbGfmnhN/szRLKX1ZbUUwMaunUArkmlXHGVrho4Yd12 +o1dCrHRlFJDG3XWFHX8CzJpAEZB8sepxQz0g33wIGC5d4wKhKYlZYbaz1Jx93dFCWhC zoI9VxnGFyt2biOpZnSSM0UjXQDlw41/1VAJUpW6lUVBRfnKh0fFLF+VY9POt3B0Qe9z 9h3w== 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=9FGfVYyA1bYLmCl2zlv3XIFxwsH8Xln+NM7zEa1tC9w=; b=kC/hvZKGgZ4RSGv9KvC4twygoS8R3o8dGPrwruRKm6GKaHwqmyblUMdVxrXJ8xL7tz Jvwx7HU4hZZ035EX+jy/sfV9dOsX00Rua5SMEzDbcLmOP/y9P7SeRQUCvXA6uATERou/ t0PfHAhFeMSPjA5OiIqe8j38Aoq+Q12T22vrz7FbCm88ZntQ+PKw7JXs/GY6TL60nSb8 kzr2OklUzITuCB+RpFETLwRn0VQUFWDmLg3SBhF/fXuRdCfhxhWKz+k/ok8I+Bruhotp cotGg6yCS7c7nkQ/MU52FOsjd3VOq4Y6SNMy0E1kP2+1sb13E/yuhEAXhdXi2nY81dAg r2XQ== 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 s38-v6si14198185pga.473.2018.11.12.03.58.47; Mon, 12 Nov 2018 03:59:02 -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 S1729372AbeKLVvE (ORCPT + 99 others); Mon, 12 Nov 2018 16:51:04 -0500 Received: from foss.arm.com ([217.140.101.70]:34738 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729293AbeKLVvD (ORCPT ); Mon, 12 Nov 2018 16:51:03 -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 E9AD61684; Mon, 12 Nov 2018 03:58:06 -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 D71FB3F5A0; Mon, 12 Nov 2018 03:58:04 -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 , Thomas Gleixner , Jason Cooper Subject: [PATCH v6 18/24] irqchip/gic-v3: Handle pseudo-NMIs Date: Mon, 12 Nov 2018 11:57:09 +0000 Message-Id: <1542023835-21446-19-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 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 | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 5245791..c763f1a 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 0xa0 + struct redist_region { void __iomem *redist_base; phys_addr_t phys_base; @@ -375,6 +377,16 @@ 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 asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) { u32 irqnr; @@ -384,6 +396,22 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs if (likely(irqnr > 15 && irqnr < 1020) || irqnr >= 8192) { int err; + if (gic_supports_nmi() && + unlikely(gic_read_rpr() == GICD_INT_NMI_PRI)) { + 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); + return; + } + if (gic_prio_masking_enabled()) { gic_pmr_mask_irqs(); gic_arch_enable_irqs(); @@ -397,12 +425,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