From patchwork Tue Nov 16 08:24:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12692712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0831EC433EF for ; Tue, 16 Nov 2021 08:27:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C219961B49 for ; Tue, 16 Nov 2021 08:27:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C219961B49 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RZg8JdE32X5nYlHM+mQdZ489mOAw8LZtQIUoR3LzhJQ=; b=V6sf7aJaJauAJf cEUTy1+hFCH6eN1nHHM7IlNPDe0XvcGhwZE2HGjoqHPE/NlaezSaeu97Z2jJ0QVLgosF5zmpC0s2Z a4cjgu0H92JimJwfux6d+jpkIoTo15vZZqnKtJ+LvtDpUB6597PuVoLprfsI8MLvBI5MylhdUV78T uQQHJ6OUBBKDPagX0snNOinTPzcYPcTxqd+GsVvZAFkXW71pNdfUmo2/xGdAAxpwq5OpHeV3fQOZY H3WH7sXJBoe2DqpNtrFiqpzJrVrBFJTaXPgWir/dl9l/3sQ92OS977GK0Mr6F3FuQwv7w0gu1EFv+ 57WuR4lwq1KldpR9q7og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmtnG-000hTj-MU; Tue, 16 Nov 2021 08:26:19 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmtmW-000hGQ-Lj for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 08:25:34 +0000 Received: by mail-pj1-x102c.google.com with SMTP id iq11so15137520pjb.3 for ; Tue, 16 Nov 2021 00:25:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=//SVuRQZNeICMM4rTHo9U8V7XTbAQzXJNXUlaXcEOp8=; b=nesmj2WHSb3eH7fuMb6p0CAcsMNDE4wLALbctRqOAlUtjb5/q80zeF9v6MX8XCLhiR CZmm4TXu8QOXLYGj3KHW/rUPmu9foWHOfTy7+WU9VSMVqKAmRFWOQKsFuJooexa7ljLW eVxBzLPBhCGMEeIT5dZmEcVqPj2aP6R2JTafiBqaWMneqRU44ucCuqT5AvnDRZS75Mq2 FpYrODPSOLr2la4mOvGvR/NLzybziOy4+yQnDoID8zKelwmPVKEm/qPQjMBLg1+UdY8t tGEu4FGxyJplAolFRIpg+nSKMvooaFv+7BZVyaBnC7er44JCxSBtL6+AJM+lKw5vkCVG lX3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=//SVuRQZNeICMM4rTHo9U8V7XTbAQzXJNXUlaXcEOp8=; b=s0SvSBFNphoJrv+4sIxVdH6qp8bzOelernWYHtjEgGbR8WaIBfF+M6A2/eNbO679Vj t8a7bvKgvOyOz53VGlraLrbILHvHEFQqETRcwXsKd0kuzODG/HTBpfNNTttxXiYSVOTr FadlSCs1Q94ubONhDLdaBWJcMCoRHmCnqV3SC4n2xyiHVyBCWAFVOJ40ypfPRLsyS1HN guZrjw2ZWHVYxiol8zQD65G3horbNgiCoKN+9P+sUdAyfil35clTrX19+wB4YmgDsNUA hqf8bsz7tvvbQJUQYtK1LP6QwGUXGZ4VKs/NVopOM5alSg70KX3kujW1aGAdxHQnLnrK G4OQ== X-Gm-Message-State: AOAM533aqFd5sbQ33ICfW8e7srdY5xEB9g9T077Clrdvt5XxMM1eytgP ZG3DOXcxMa+KlY161J3efbhC+zwRiA== X-Google-Smtp-Source: ABdhPJxrh7wztctEh4f9+votntRIdsRQs/MJFo9pbLgf8IjPdGR+xL1sJ39r13+T8Q5bSBByYOPnog== X-Received: by 2002:a17:903:2305:b0:142:1bca:72eb with SMTP id d5-20020a170903230500b001421bca72ebmr42454407plh.67.1637051131392; Tue, 16 Nov 2021 00:25:31 -0800 (PST) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id 11sm17104011pfl.41.2021.11.16.00.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 00:25:31 -0800 (PST) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Cc: Pingfan Liu , Catalin Marinas , Will Deacon , Mark Rutland , Marc Zyngier , Joey Gouly , Sami Tolvanen , Julien Thierry , Yuichi Ito , rcu@vger.kernel.org Subject: [PATCHv3 3/4] irqchip: GICv3: expose pNMI discriminator Date: Tue, 16 Nov 2021 16:24:49 +0800 Message-Id: <20211116082450.10357-4-kernelfans@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211116082450.10357-1-kernelfans@gmail.com> References: <20211116082450.10357-1-kernelfans@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211116_002532_740602_5A876469 X-CRM114-Status: GOOD ( 12.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Arch level code is ready to take over the nmi_enter()/nmi_exit() housekeeping. GICv3 can expose the pNMI discriminator, then simply remove the housekeeping. Signed-off-by: Pingfan Liu Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: Marc Zyngier Cc: Joey Gouly Cc: Sami Tolvanen Cc: Julien Thierry Cc: Yuichi Ito Cc: rcu@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- drivers/irqchip/irq-gic-v3.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index daec3309b014..aa2bcb47b47e 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -646,12 +646,8 @@ static void gic_deactivate_unhandled(u32 irqnr) static inline void gic_handle_nmi(u32 irqnr, struct pt_regs *regs) { - bool irqs_enabled = interrupts_enabled(regs); int err; - if (irqs_enabled) - nmi_enter(); - if (static_branch_likely(&supports_deactivate_key)) gic_write_eoir(irqnr); /* @@ -664,8 +660,6 @@ static inline void gic_handle_nmi(u32 irqnr, struct pt_regs *regs) if (err) gic_deactivate_unhandled(irqnr); - if (irqs_enabled) - nmi_exit(); } static u32 do_read_iar(struct pt_regs *regs) @@ -702,6 +696,15 @@ static u32 do_read_iar(struct pt_regs *regs) return iar; } +static bool gic_is_in_nmi(void) +{ + if (gic_supports_nmi() && + unlikely(gic_read_rpr() == GICD_INT_RPR_PRI(GICD_INT_NMI_PRI))) + return true; + + return false; +} + static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) { u32 irqnr; @@ -1791,6 +1794,9 @@ static int __init gic_init_bases(void __iomem *dist_base, } set_handle_irq(gic_handle_irq); +#if IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI) + set_nmi_discriminator(gic_is_in_nmi); +#endif gic_update_rdist_properties();