public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Daniel Gomez <da.gomez@kernel.org>
Cc: "Jürgen Groß" <jgross@suse.com>,
	"Bjorn Helgaas" <helgaas@kernel.org>,
	linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org,
	linux-pci@vger.kernel.org, "Thomas Gleixner" <tglx@linutronix.de>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v3 3/3] PCI/MSI: Convert pci_msi_ignore_mask to per MSI domain flag
Date: Mon, 24 Mar 2025 18:51:54 +0100	[thread overview]
Message-ID: <Z-GbuiIYEdqVRsHj@macbook.local> (raw)
In-Reply-To: <qn7fzggcj6qe6r6gdbwcz23pzdz2jx64aldccmsuheabhmjgrt@tawf5nfwuvw7>

On Mon, Mar 24, 2025 at 03:29:46PM +0100, Daniel Gomez wrote:
> 
> Hi,
> 
> On Fri, Mar 21, 2025 at 09:00:09AM +0100, Jürgen Groß wrote:
> > On 20.03.25 22:07, Bjorn Helgaas wrote:
> > > On Wed, Feb 19, 2025 at 10:20:57AM +0100, Roger Pau Monne wrote:
> > > > Setting pci_msi_ignore_mask inhibits the toggling of the mask bit for both
> > > > MSI and MSI-X entries globally, regardless of the IRQ chip they are using.
> > > > Only Xen sets the pci_msi_ignore_mask when routing physical interrupts over
> > > > event channels, to prevent PCI code from attempting to toggle the maskbit,
> > > > as it's Xen that controls the bit.
> > > > 
> > > > However, the pci_msi_ignore_mask being global will affect devices that use
> > > > MSI interrupts but are not routing those interrupts over event channels
> > > > (not using the Xen pIRQ chip).  One example is devices behind a VMD PCI
> > > > bridge.  In that scenario the VMD bridge configures MSI(-X) using the
> > > > normal IRQ chip (the pIRQ one in the Xen case), and devices behind the
> > > > bridge configure the MSI entries using indexes into the VMD bridge MSI
> > > > table.  The VMD bridge then demultiplexes such interrupts and delivers to
> > > > the destination device(s).  Having pci_msi_ignore_mask set in that scenario
> > > > prevents (un)masking of MSI entries for devices behind the VMD bridge.
> > > > 
> > > > Move the signaling of no entry masking into the MSI domain flags, as that
> > > > allows setting it on a per-domain basis.  Set it for the Xen MSI domain
> > > > that uses the pIRQ chip, while leaving it unset for the rest of the
> > > > cases.
> > > > 
> > > > Remove pci_msi_ignore_mask at once, since it was only used by Xen code, and
> > > > with Xen dropping usage the variable is unneeded.
> > > > 
> > > > This fixes using devices behind a VMD bridge on Xen PV hardware domains.
> > > > 
> > > > Albeit Devices behind a VMD bridge are not known to Xen, that doesn't mean
> > > > Linux cannot use them.  By inhibiting the usage of
> > > > VMD_FEAT_CAN_BYPASS_MSI_REMAP and the removal of the pci_msi_ignore_mask
> > > > bodge devices behind a VMD bridge do work fine when use from a Linux Xen
> > > > hardware domain.  That's the whole point of the series.
> > > > 
> > > > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > > > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> > > > Acked-by: Juergen Gross <jgross@suse.com>
> > > 
> > > Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> > > 
> > > I assume you'll merge this series via the Xen tree.  Let me know if
> > > otherwise.
> > 
> > I've pushed the series to the linux-next branch of the Xen tree.
> > 
> > 
> > Juergen
> 
> This patch landed in latest next-20250324 tag causing this crash:
> 
> [    0.753426] BUG: kernel NULL pointer dereference, address: 0000000000000002
> [    0.753921] #PF: supervisor read access in kernel mode
> [    0.754286] #PF: error_code(0x0000) - not-present page
> [    0.754656] PGD 0 P4D 0
> [    0.754842] Oops: Oops: 0000 [#1]
> [    0.755080] CPU: 0 UID: 0 PID: 1 Comm: swapper Not tainted 6.14.0-rc7-next-20250324 #1 NONE
> [    0.755691] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
> [    0.756349] RIP: 0010:msix_prepare_msi_desc+0x39/0x80
> [    0.756390] Code: 20 c7 46 04 01 00 00 00 8b 56 4c 89 d0 0d 01 01 00 00 66 89 46 4c 8b 8f 64 02 00 00 89 4e 50 48 8b 8f 70 06 00 00 48 89 4e 58 <41> f6 40 02 40 75 2a c1 ea 02 bf 80 00 00 00 21 fa 25 7f ff ff ff
> [    0.756390] RSP: 0000:ffff8881002a76e0 EFLAGS: 00010202
> [    0.756390] RAX: 0000000000000101 RBX: ffff88810074d000 RCX: ffffc9000002e000
> [    0.756390] RDX: 0000000000000000 RSI: ffff8881002a7710 RDI: ffff88810074d000
> [    0.756390] RBP: ffff8881002a7710 R08: 0000000000000000 R09: ffff8881002a76b4
> [    0.756390] R10: 000000701000c001 R11: ffffffff82a3dc01 R12: 0000000000000000
> [    0.756390] R13: 0000000000000005 R14: 0000000000000000 R15: 0000000000000002
> [    0.756390] FS:  0000000000000000(0000) GS:0000000000000000(0000) knlGS:0000000000000000
> [    0.756390] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [    0.756390] CR2: 0000000000000002 CR3: 0000000002a3d001 CR4: 00000000003706b0
> [    0.756390] Call Trace:
> [    0.756390]  <TASK>
> [    0.756390]  ? __die_body+0x1b/0x60
> [    0.756390]  ? page_fault_oops+0x2d0/0x310
> [    0.756390]  ? exc_page_fault+0x59/0xc0
> [    0.756390]  ? asm_exc_page_fault+0x22/0x30
> [    0.756390]  ? msix_prepare_msi_desc+0x39/0x80
> [    0.756390]  ? msix_capability_init+0x172/0x2c0
> [    0.756390]  ? __pci_enable_msix_range+0x1a8/0x1d0
> [    0.756390]  ? pci_alloc_irq_vectors_affinity+0x7c/0xf0
> [    0.756390]  ? vp_find_vqs_msix+0x187/0x400
> [    0.756390]  ? vp_find_vqs+0x2f/0x250
> [    0.756390]  ? snprintf+0x3e/0x50
> [    0.756390]  ? vp_modern_find_vqs+0x13/0x60
> [    0.756390]  ? init_vq+0x184/0x1e0
> [    0.756390]  ? vp_get_status+0x20/0x20
> [    0.756390]  ? virtblk_probe+0xeb/0x8d0
> [    0.756390]  ? __kernfs_new_node+0x122/0x160
> [    0.756390]  ? vp_get_status+0x20/0x20
> [    0.756390]  ? virtio_dev_probe+0x171/0x1c0
> [    0.756390]  ? really_probe+0xc2/0x240
> [    0.756390]  ? driver_probe_device+0x1d/0x70
> [    0.756390]  ? __driver_attach+0x96/0xe0
> [    0.756390]  ? driver_attach+0x20/0x20
> [    0.756390]  ? bus_for_each_dev+0x7b/0xb0
> [    0.756390]  ? bus_add_driver+0xe6/0x200
> [    0.756390]  ? driver_register+0x5e/0xf0
> [    0.756390]  ? virtio_blk_init+0x4d/0x90
> [    0.756390]  ? add_boot_memory_block+0x90/0x90
> [    0.756390]  ? do_one_initcall+0xe2/0x250
> [    0.756390]  ? xas_store+0x4b/0x4b0
> [    0.756390]  ? number+0x13b/0x260
> [    0.756390]  ? ida_alloc_range+0x36a/0x3b0
> [    0.756390]  ? parameq+0x13/0x90
> [    0.756390]  ? parse_args+0x10f/0x2a0
> [    0.756390]  ? do_initcall_level+0x83/0xb0
> [    0.756390]  ? do_initcalls+0x43/0x70
> [    0.756390]  ? rest_init+0x80/0x80
> [    0.756390]  ? kernel_init_freeable+0x70/0xb0
> [    0.756390]  ? kernel_init+0x16/0x110
> [    0.756390]  ? ret_from_fork+0x30/0x40
> [    0.756390]  ? rest_init+0x80/0x80
> [    0.756390]  ? ret_from_fork_asm+0x11/0x20
> [    0.756390]  </TASK>
> [    0.756390] Modules linked in:
> [    0.756390] CR2: 0000000000000002
> [    0.756390] ---[ end trace 0000000000000000 ]---
> [    0.756390] RIP: 0010:msix_prepare_msi_desc+0x39/0x80
> [    0.756390] Code: 20 c7 46 04 01 00 00 00 8b 56 4c 89 d0 0d 01 01 00 00 66 89 46 4c 8b 8f 64 02 00 00 89 4e 50 48 8b 8f 70 06 00 00 48 89 4e 58 <41> f6 40 02 40 75 2a c1 ea 02 bf 80 00 00 00 21 fa 25 7f ff ff ff
> [    0.756390] RSP: 0000:ffff8881002a76e0 EFLAGS: 00010202
> [    0.756390] RAX: 0000000000000101 RBX: ffff88810074d000 RCX: ffffc9000002e000
> [    0.756390] RDX: 0000000000000000 RSI: ffff8881002a7710 RDI: ffff88810074d000
> [    0.756390] RBP: ffff8881002a7710 R08: 0000000000000000 R09: ffff8881002a76b4
> [    0.756390] R10: 000000701000c001 R11: ffffffff82a3dc01 R12: 0000000000000000
> [    0.756390] R13: 0000000000000005 R14: 0000000000000000 R15: 0000000000000002
> [    0.756390] FS:  0000000000000000(0000) GS:0000000000000000(0000) knlGS:0000000000000000
> [    0.756390] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [    0.756390] CR2: 0000000000000002 CR3: 0000000002a3d001 CR4: 00000000003706b0
> [    0.756390] note: swapper[1] exited with irqs disabled
> [    0.782774] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009
> [    0.783560] Kernel Offset: disabled
> [    0.783909] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009 ]---
> 
> 
> msix_prepare_msi_desc+0x39/0x80:
> msix_prepare_msi_desc at drivers/pci/msi/msi.c:616
>  611            desc->nvec_used                         = 1;
>  612            desc->pci.msi_attrib.is_msix            = 1;
>  613            desc->pci.msi_attrib.is_64              = 1;
>  614            desc->pci.msi_attrib.default_irq        = dev->irq;
>  615            desc->pci.mask_base                     = dev->msix_base;
> >616<           desc->pci.msi_attrib.can_mask           = !(info->flags & MSI_FLAG_NO_MASK) &&
>  617                                                      !desc->pci.msi_attrib.is_virtual;
>  618
>  619            if (desc->pci.msi_attrib.can_mask) {
>  620                    void __iomem *addr = pci_msix_desc_addr(desc);
>  621
> 
> Reverting patch 3 fixes the issue.

Thanks for the report and sorry for the breakage.  Do you have a QEMU
command line I can use to try to reproduce this locally?

Will work on a patch ASAP.

Regards, Roger.

  reply	other threads:[~2025-03-24 17:52 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19  9:20 [PATCH v3 0/3] xen: Fix usage of devices behind a VMD bridge Roger Pau Monne
2025-02-19  9:20 ` [PATCH v3 1/3] xen/pci: Do not register devices with segments >= 0x10000 Roger Pau Monne
2025-02-19  9:20 ` [PATCH v3 2/3] PCI: vmd: Disable MSI remapping bypass under Xen Roger Pau Monne
2025-03-03 14:16   ` Roger Pau Monné
2025-03-20 21:06   ` Bjorn Helgaas
2025-02-19  9:20 ` [PATCH v3 3/3] PCI/MSI: Convert pci_msi_ignore_mask to per MSI domain flag Roger Pau Monne
2025-03-20 21:07   ` Bjorn Helgaas
2025-03-21  8:00     ` Jürgen Groß
2025-03-24 14:29       ` Daniel Gomez
2025-03-24 17:51         ` Roger Pau Monné [this message]
2025-03-24 18:58           ` Daniel Gomez
2025-03-24 19:18             ` Roger Pau Monné
2025-03-24 20:45               ` Daniel Gomez
2025-03-25  8:11               ` Thomas Gleixner
2025-03-25  9:20                 ` Thomas Gleixner
2025-03-25  9:47                   ` Daniel Gomez
2025-03-25 10:22                   ` Roger Pau Monné
2025-03-25 10:27                     ` Thomas Gleixner
2025-03-25 10:55                       ` Roger Pau Monné
2025-03-26  8:14                         ` Thomas Gleixner
2025-03-26  8:10                   ` Roger Pau Monné
2025-03-26 11:26                   ` Marek Szyprowski
2025-03-26 12:05                   ` [PATCH] PCI/MSI: Handle the NOMASK flag correctly for all PCI/MSI backends Thomas Gleixner
2025-03-26 12:09                     ` Jürgen Groß
2025-03-26 12:46                       ` Thomas Gleixner
2025-03-26 12:16                     ` Juergen Gross
2025-03-26 14:39                     ` [tip: timers/urgent] " tip-bot2 for Thomas Gleixner
2025-03-30 14:57                   ` [PATCH] " Bert Karwatzki
2025-03-26 11:04   ` [PATCH v3 3/3] PCI/MSI: Convert pci_msi_ignore_mask to per MSI domain flag Borislav Petkov
2025-03-26 11:14     ` Roger Pau Monné
2025-03-26 11:21       ` Borislav Petkov
2025-03-06  8:48 ` [PATCH v3 0/3] xen: Fix usage of devices behind a VMD bridge Roger Pau Monné
2025-03-20 16:21   ` Roger Pau Monné

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=Z-GbuiIYEdqVRsHj@macbook.local \
    --to=roger.pau@citrix.com \
    --cc=bhelgaas@google.com \
    --cc=bp@alien8.de \
    --cc=da.gomez@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=helgaas@kernel.org \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.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