From patchwork Fri Sep 24 13:28:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12515513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F82AC433EF for ; Fri, 24 Sep 2021 13:32:54 +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 E6E3F60F4C for ; Fri, 24 Sep 2021 13:32:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E6E3F60F4C 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=oha2Hsc5FUz65T6dJs/rAedURySAKNET5Aa1jQtr60w=; b=FinV1WxVPEVqtX 4ik8oy5zPk9n2b2KsqPoEcz9ONCJURbqLbn6iiEN7gHSqYJkO8ikmwE5DUroZfn3wiLMy45n94nIh EaUCAL0wOvg9SGKgUDZyQWlBVFY2MFE7WbcEFq0uLD3eHkyXsVwc1khBo/DVCjkValwtUm3WuriFL 3zrZUXBA76TjNJxec8biTT4LOqbuY9SsXmu6fWNzIkz4hRNXW0jnTY2zEHqJbuKjoF8osEnaTAF/J Cyz7D8QxsNsYs0QY0dqn7I40fJMVOVLL0Ncyh0rv+eVEryA3F5L0MCdnYlMsy/3DFsMhKPlI5xy/S EwVEqAukaUQn1ckaAbbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTlI0-00EbLZ-Rp; Fri, 24 Sep 2021 13:30:57 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTlGG-00Eaeu-0z for linux-arm-kernel@lists.infradead.org; Fri, 24 Sep 2021 13:29:09 +0000 Received: by mail-pf1-x42e.google.com with SMTP id 145so8868641pfz.11 for ; Fri, 24 Sep 2021 06:29:07 -0700 (PDT) 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=E2re79r/KMQm8fC1r1C1DX1MnLIusIxSofGmOWtOLv8=; b=pu20CDJ63FPAZYqTMiqLBsWmahvQuNVWq+rjQjOyUIBcwGDWU1xS6o7oUh56yY0iFi xhgEyY4QuwLAfHjCCLCp8GBGg2+LKvg6R2tsyDOBY3eA4tjgPP3KQerr6HIKfD2VBWJg OlJIKFhMDIUXEJQKOyAqnhsj4PdEQ2FtQY193GAu9BP6wgkJkJ3VI9+7RkjLmFIoqi2M J93vY5xWBxYgSl8YLQTL/pzpbFR1Qu7XYy9q/NQzPIeDAv+oF/IQGpk/ZvTJWAKy69a1 mcaPPZFQcwwrX2x1hbaWRLFUmGPWH1/Oid+oy6m1yMhGMoOkFB0okrWaNcrTdW9c/S8p k08w== 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=E2re79r/KMQm8fC1r1C1DX1MnLIusIxSofGmOWtOLv8=; b=mdUHtUThPyqFEqIMj2hST7ZnFigyAp2bDnAKKoUIHYUF+5CU1B6A27gaxibpzJmg5+ 9GM7sqbwFX80Qk/AKhn1X+BdSD/tjTD8qQGELovHtx7g9SLQq6Z8qfLEw7UN2FhQ9ZmE 2ipd+Egqh/EzHFwr/nbP7qr7i9cdmfmrv1ssvUJ3Ak8uzlmyv9Gzew3+GfPtFrYotivw B3C8xe0CfB9qEaRnoNkPeR8wUPaksQCaMOMT27sYTCK+VAvPDc9pu+xShsNV0wFFuKOt r1r+OVprGE5GC3uxVSDf1nKVRaWmrM59fAacy2ruaOiUOwbEMrBu4Nq59dEid2C++uV9 uc/w== X-Gm-Message-State: AOAM530JhlMgWkeLeRQydrj7EJ1C+mJ+fqN5xIm1ifHinQJXtVpTpxot t+eFi7byApOTOBdsLk3nYAAlC+lenA== X-Google-Smtp-Source: ABdhPJyVLf2VBROoVBckvGi5mCtdHnpZ3wBEsV++tAn/ln2TpuxIAOv5tUd/N6zOk8DqvUq47PzLdQ== X-Received: by 2002:a63:ef01:: with SMTP id u1mr3784992pgh.336.1632490146668; Fri, 24 Sep 2021 06:29:06 -0700 (PDT) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id 26sm11756573pgx.72.2021.09.24.06.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 06:29:06 -0700 (PDT) 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 , Thomas Gleixner , Yuichi Ito , linux-kernel@vger.kernel.org Subject: [PATCHv2 2/5] irqchip/GICv3: expose handle_nmi() directly Date: Fri, 24 Sep 2021 21:28:34 +0800 Message-Id: <20210924132837.45994-3-kernelfans@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210924132837.45994-1-kernelfans@gmail.com> References: <20210924132837.45994-1-kernelfans@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210924_062908_144206_AF59B731 X-CRM114-Status: GOOD ( 18.12 ) 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 With the previous patch, the NMI should be dispatched at irqentry level. Accordingly adjust GICv3 to utilize the hooks, so NMI handler can be dispatched. 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: Thomas Gleixner Cc: Yuichi Ito Cc: linux-kernel@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- arch/arm64/include/asm/irq.h | 2 ++ drivers/irqchip/irq-gic-v3.c | 53 +++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h index a59b1745f458..c39627290a60 100644 --- a/arch/arm64/include/asm/irq.h +++ b/arch/arm64/include/asm/irq.h @@ -11,6 +11,8 @@ struct pt_regs; int set_handle_irq(void (*handle_irq)(struct pt_regs *)); #define set_handle_irq set_handle_irq int set_handle_fiq(void (*handle_fiq)(struct pt_regs *)); +int set_handle_nmi(void (*handle_nmi)(struct pt_regs *)); +int set_nmi_discriminator(bool (*discriminator)(void)); extern void (*handle_arch_irq)(struct pt_regs *regs); extern void (*handle_arch_fiq)(struct pt_regs *regs); diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index fd4e9a37fea6..89dcec902a82 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -644,28 +644,12 @@ static void gic_deactivate_unhandled(u32 irqnr) } } -static inline void gic_handle_nmi(u32 irqnr, struct pt_regs *regs) +static bool gic_is_in_nmi(void) { - bool irqs_enabled = interrupts_enabled(regs); - int err; - - if (irqs_enabled) - nmi_enter(); - - 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_unhandled(irqnr); + if (gic_supports_nmi() && unlikely(gic_read_rpr() == GICD_INT_NMI_PRI)) + return true; - if (irqs_enabled) - nmi_exit(); + return false; } static u32 do_read_iar(struct pt_regs *regs) @@ -702,21 +686,38 @@ static u32 do_read_iar(struct pt_regs *regs) return iar; } -static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) +static void gic_handle_nmi(struct pt_regs *regs) { u32 irqnr; + int err; irqnr = do_read_iar(regs); /* Check for special IDs first */ if ((irqnr >= 1020 && irqnr <= 1023)) return; + 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_unhandled(irqnr); +} - if (gic_supports_nmi() && - unlikely(gic_read_rpr() == GICD_INT_RPR_PRI(GICD_INT_NMI_PRI))) { - gic_handle_nmi(irqnr, regs); +static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) +{ + u32 irqnr; + + irqnr = do_read_iar(regs); + + /* Check for special IDs first */ + if ((irqnr >= 1020 && irqnr <= 1023)) return; - } if (gic_prio_masking_enabled()) { gic_pmr_mask_irqs(); @@ -1791,6 +1792,8 @@ static int __init gic_init_bases(void __iomem *dist_base, } set_handle_irq(gic_handle_irq); + set_handle_nmi(gic_handle_nmi); + set_nmi_discriminator(gic_is_in_nmi); gic_update_rdist_properties();