All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jinjie Ruan" <ruanjinjie@huawei.com>
Cc: kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH 17/17] irqchip/gic-v3: Implement FEAT_GICv3_NMI support
Date: Fri, 03 Jul 2026 10:25:13 +0000	[thread overview]
Message-ID: <20260703102513.85AF91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260703100135.2512312-18-ruanjinjie@huawei.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing mapping for GICD_INMIR to GICD_INMIRnE in convert_offset_index() for ESPIs
- [Low] Comment typo contradicts the implementation regarding expected interrupt state
--

commit d7c99cd0a83704d2374d8fa536ff561f0b757f91
Author: Lorenzo Pieralisi <lpieralisi@kernel.org>

irqchip/gic-v3: Implement FEAT_GICv3_NMI support

The FEAT_GICv3_NMI GIC feature coupled with the CPU FEAT_NMI enables
handling NMI interrupts in HW on aarch64, by adding a superpriority
interrupt to the existing GIC priority scheme.

Link: https://lore.kernel.org/r/20221112151708.175147-15-broonie@kernel.org

> diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
> index 111cd882c7a95..6e48dd9990219 100644
> --- a/drivers/irqchip/irq-gic-v3.c
> +++ b/drivers/irqchip/irq-gic-v3.c

[ ... ]

> @@ -467,6 +482,42 @@ static int gic_peek_irq(struct irq_data *d, u32 offset)
>  	return !!(readl_relaxed(base + offset + (index / 32) * 4) & mask);
>  }
>  
> +static DEFINE_RAW_SPINLOCK(irq_controller_lock);
> +
> +static void gic_irq_configure_nmi(struct irq_data *d, bool enable)
> +{
> +	void __iomem *base, *addr;
> +	u32 offset, index, mask, val;
> +
> +	offset = convert_offset_index(d, GICD_INMIR, &index);

[Severity: High]
Does this miss the ESPI mapping for GICD_INMIR?

When configuring an NMI for an Extended SPI (ESPI), convert_offset_index()
is called with GICD_INMIR. However, the ESPI_RANGE switch block in
convert_offset_index() currently lacks a case for GICD_INMIR:

	case ESPI_RANGE:
		*index = d->hwirq - ESPI_BASE_INTID;
		switch (offset) {
		case GICD_ISENABLER:
			return GICD_ISENABLERnE;
		...
		default:
			break;
		}

This will cause the switch to fall through to the default handler, trigger
a WARN_ON(1), reset the index to the raw hardware IRQ number (>= 4096),
and return the baseline GICD_INMIR offset.

Could this result in an out-of-bounds MMIO read-modify-write on an
incorrect register address when calculating addr below?

> +	mask = 1 << (index % 32);
> +
> +	if (gic_irq_in_rdist(d))
> +		base = gic_data_rdist_sgi_base();
> +	else
> +		base = gic_data.dist_base;
> +
> +	addr = base + offset + (index / 32) * 4;

[ ... ]

> @@ -857,6 +915,28 @@ static void __gic_handle_irq_from_irqson(struct pt_regs *regs)
>  	bool is_nmi;
>  	u32 irqnr;
>  
> +	/*
> +	 * We should enter here with interrupts disabled, otherwise we may met
> +	 * a race here with FEAT_NMI/FEAT_GICv3_NMI:
> +	 *
> +	 * [interrupt disabled]
> +	 *                   <- normal interrupt pending, for example timer interrupt
> +	 *                   <- NMI occurs, ISR_EL1.nmi = 1
> +	 * do_el1_interrupt()
> +	 *                   <- NMI withdraw, ISR_EL1.nmi = 0
> +	 *   ISR_EL1.nmi = 0, not an NMI interrupt
> +	 *   gic_handle_irq()
> +	 *     __gic_handle_irq_from_irqson()
> +	 *       irqnr = gic_read_iar() <- Oops, ack and handle an normal interrupt
> +	 *                                 in interrupt disabled context!
> +	 *
> +	 * So if we met this case here, just return from the interrupt context.
> +	 * Since the interrupt is still pending, we can handle it once the
> +	 * interrupt re-enabled and it'll not be missing.
> +	 */
> +	if (!interrupts_enabled(regs))
> +		return;

[Severity: Low]
This isn't a bug, but does this comment contradict the code immediately
below it?

The comment states "We should enter here with interrupts disabled", but the
code immediately returns if interrupts are disabled. Should the comment say
"enabled" instead, or "we could enter here with interrupts disabled"?

> +
>  	irqnr = gic_read_iar();

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260703100135.2512312-1-ruanjinjie@huawei.com?part=17

  reply	other threads:[~2026-07-03 10:25 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 10:01 [PATCH 00/17] arm64: Support FEAT_NMI and Rework Exception Masking Jinjie Ruan
2026-07-03 10:01 ` [PATCH 01/17] arm64: Move DAIF macros to ptrace.h and use them centrally Jinjie Ruan
2026-07-03 16:44   ` Breno Leitao
2026-07-06 12:57     ` Jinjie Ruan
2026-07-03 10:01 ` [PATCH 02/17] arm64: Rework exception masking into abstract logical mask Jinjie Ruan
2026-07-03 10:15   ` sashiko-bot
2026-07-03 13:38   ` Leonardo Bras
2026-07-06 13:00     ` Jinjie Ruan
2026-07-06 13:02       ` Leonardo Bras
2026-07-03 13:48   ` Leonardo Bras
2026-07-06 13:15     ` Jinjie Ruan
2026-07-06 13:43       ` Leonardo Bras
2026-07-07  8:39         ` Jinjie Ruan
2026-07-03 10:01 ` [PATCH 03/17] arm64: entry: arm64: entry: Move DAIF masking for EL1 exit to C code Jinjie Ruan
2026-07-03 10:01 ` [PATCH 04/17] arm64: entry: Add entry-specific helpers Jinjie Ruan
2026-07-03 10:17   ` sashiko-bot
2026-07-03 10:01 ` [PATCH 05/17] arm64: Introduce helpers for restoring standard exception masks Jinjie Ruan
2026-07-03 10:01 ` [PATCH 06/17] arm64/booting: Document boot requirements for FEAT_NMI Jinjie Ruan
2026-07-03 10:15   ` sashiko-bot
2026-07-03 10:01 ` [PATCH 07/17] arm64/sysreg: Add definitions for immediate versions of MSR ALLINT Jinjie Ruan
2026-07-03 10:18   ` sashiko-bot
2026-07-03 10:01 ` [PATCH 08/17] arm64/hyp-stub: Enable access to ALLINT Jinjie Ruan
2026-07-03 10:16   ` sashiko-bot
2026-07-03 10:01 ` [PATCH 09/17] arm64/idreg: Add an override for FEAT_NMI Jinjie Ruan
2026-07-03 10:20   ` sashiko-bot
2026-07-03 10:01 ` [PATCH 10/17] arm64/cpufeature: Detect PE support " Jinjie Ruan
2026-07-03 10:01 ` [PATCH 11/17] KVM: arm64: Hide FEAT_NMI from guests Jinjie Ruan
2026-07-03 10:13   ` sashiko-bot
2026-07-03 10:01 ` [PATCH 12/17] arm64/nmi: Manage masking for superpriority interrupts along with DAIF Jinjie Ruan
2026-07-03 10:27   ` sashiko-bot
2026-07-03 10:01 ` [PATCH 13/17] arm64/entry: Don't call preempt_schedule_irq() with NMIs masked Jinjie Ruan
2026-07-03 10:01 ` [PATCH 14/17] arm64/irq: Document handling of FEAT_NMI in irqflags.h Jinjie Ruan
2026-07-03 10:01 ` [PATCH 15/17] arm64/nmi: Add handling of superpriority interrupts as NMIs Jinjie Ruan
2026-07-03 10:19   ` sashiko-bot
2026-07-03 10:01 ` [PATCH 16/17] arm64/nmi: Add Kconfig for NMI Jinjie Ruan
2026-07-03 10:28   ` sashiko-bot
2026-07-03 10:01 ` [PATCH 17/17] irqchip/gic-v3: Implement FEAT_GICv3_NMI support Jinjie Ruan
2026-07-03 10:25   ` sashiko-bot [this message]
2026-07-03 14:15 ` [PATCH 00/17] arm64: Support FEAT_NMI and Rework Exception Masking Mark Rutland
2026-07-06  1:10   ` Jinjie Ruan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260703102513.85AF91F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=ruanjinjie@huawei.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.