mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: WeitaoWang-oc <weitaowang-oc@zhaoxin.com>
To: Thomas Gleixner <tglx@linutronix.de>, Koichiro Den <den@valinux.co.jp>
Cc: mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
	x86@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org,
	WeitaoWang@zhaoxin.com, wwt8723@163.com, CobeChen@zhaoxin.com,
	stable@vger.kernel.org
Subject: Re: [此为外部邮件 谨防风险] Re: [PATCH] x86/apic/msi: Fix MSI interrupt affinity configuration
Date: Fri, 16 Oct 2026 11:36:10 +0800	[thread overview]
Message-ID: <316900d3-2ce8-4391-ad8f-556bb5540c2a@zhaoxin.com> (raw)
In-Reply-To: <87jynid352.ffs@fw13>

On 10/16/26 06:12, Thomas Gleixner wrote:
> On Wed, Sep 30 2026 at 01:29, Koichiro Den wrote:
>> On Tue, Sep 29, 2026 at 12:48:39AM +0800, WeitaoWang-oc wrote:
>>> commit b56ebe7c896d ("x86/apic/msi: Fix misconfigured non-maskable MSI
>>> quirk") try to fix the issue of misconfigured non-maskable MSI quirk.
>>> For non-maskable MSI interrupts, use the slow path to fix the MSI affinity
>>> race. Maskable MSI interrupts use the direct path to update configuration
>>> info. However, the current code logic is the opposite as only maskable
>>> MSI interrupts will enable reservation mode.
> 
> Please read:
> 
>    https://docs.kernel.org/process/maintainer-tip.html#changelog
> 
> and restructure and reword the changelog accordingly. The above is
> incomprehensible word salad.

Hi Thomas,

Thank you for the suggestions. I realize the problem description in my
previous patch needed to be more precise. Before posting v3, I have
updated the change log as shown below. Could you please take a look?
If this looks good to you, I will send out the next version.

From: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
Subject: [PATCH v3] x86/apic/msi: Fix MSI interrupt affinity configuration

The two step update sequence in msi_set_affinity() is required for MSI
interrupts which cannot be migrated atomically, i.e. devices which do not
provide MSI masking. The MSI message update writes address and data
registers separately, so such a device can raise an interrupt in between,
which results in a message built from half updated state: A stray
interrupt on a stale vector and a possibly lost device interrupt.

The update sequence is selected by a per interrupt quirk flag, which is
set for interrupts which cannot use reservation mode. Reservation mode is
only enabled for maskable interrupts, i.e. devices which provide MSI-X or
mask support, so the quirk flag is the inverse of the reservation mode
bit.

The removal of the quirk flag replaced the flag check with a reservation
mode check, but dropped the negation of the removed condition:

       - if (!irqd_msi_nomask_quirk(irqd) || ...)
       + if (!irqd_can_reserve(irqd) || ...)

As the quirk flag is the inverse of the reservation mode bit, the
replacement inverted the condition and selects the wrong update path for
every interrupt: Non-maskable interrupts take the direct update path
again, which reopens the race, while maskable interrupts needlessly go
through the two step update.

Restore the original condition so that the direct update path is selected
when reservation mode is enabled, which also matches the comment above the
check: Direct update is possible when the MSI is maskable, which is the
case when the reservation mode bit is set.

Fixes: b56ebe7c896d ("x86/apic/msi: Fix misconfigured non-maskable MSI quirk")
Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
Reviewed-by: Koichiro Den <den@valinux.co.jp>
Cc: <stable@vger.kernel.org> # v6.1+
---
  Changes in v3:
   - Rework the changelog as requested by Thomas:
     https://lore.kernel.org/all/87jynid352.ffs@fw13/

  Changes in v2:
   - Change the Fixes tag to b56ebe7c896d ("x86/apic/msi: Fix misconfigured
     Dnon-maskable MSI quirk")
   - Update commit messages for clarity

   - Link to v1: https://lore.kernel.org/all/20260928164839.6381-1-WeitaoWang-oc@zhaoxin.com/
   - Link to v2: https://lore.kernel.org/all/20260930155213.4380-1-WeitaoWang-oc@zhaoxin.com/

    arch/x86/kernel/apic/msi.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

   diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c
   index 66bc5d3e79db..da5f44a80313 100644
   --- a/arch/x86/kernel/apic/msi.c
   +++ b/arch/x86/kernel/apic/msi.c
   @@ -62,7 +62,7 @@ msi_set_affinity(struct irq_data *irqd, const struct cpumask *mask, bool force)
          * - The interrupt is not yet started up
          * - The new destination CPU is the same as the old destination CPU
          */
   -     if (!irqd_can_reserve(irqd) ||
   +     if (irqd_can_reserve(irqd) ||
             cfg->vector == old_cfg.vector ||
             old_cfg.vector == MANAGED_IRQ_SHUTDOWN_VECTOR ||
             !irqd_is_started(irqd) ||
  --
  2.32.0

Thanks
weitao


  reply	other threads:[~2026-10-16  3:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 16:48 WeitaoWang-oc
2026-09-29 16:29 ` Koichiro Den
2026-09-30  7:33   ` WeitaoWang-oc
2026-10-15 22:12   ` Thomas Gleixner
2026-10-16  3:36     ` WeitaoWang-oc [this message]
2026-10-16  9:30       ` [此为外部邮件 谨防风险] " Thomas Gleixner
2026-10-16 11:58         ` [PATCH v3] " WeitaoWang-oc

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=316900d3-2ce8-4391-ad8f-556bb5540c2a@zhaoxin.com \
    --to=weitaowang-oc@zhaoxin.com \
    --cc=CobeChen@zhaoxin.com \
    --cc=WeitaoWang@zhaoxin.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=den@valinux.co.jp \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wwt8723@163.com \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®