From: "Roger Pau Monné" <roger@xenproject.org>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Teddy Astie <teddy.astie@vates.tech>,
Julian Vetter <julian.vetter@vates.tech>
Subject: Re: [PATCH v2 1/5] x86/pass-through: alter locking around pt_irq_{create,destroy}_bind()
Date: Wed, 28 Oct 2026 15:33:13 +0100 [thread overview]
Message-ID: <auIHqfrpdFnmgoMq@Mac.lan> (raw)
In-Reply-To: <e3f82d25-42b1-467b-93b7-902bf6c1bf15@suse.com>
On Wed, Sep 30, 2026 at 01:42:29PM +0200, Jan Beulich wrote:
> The questionable use of pcidevs_lock() there was discussed more than once.
> It really is pointless: The functions synchronize primarily via the per-
> domain event lock. They also may already be called with the global PCI
> devices lock not held: See hvm/vmsi.c:vpci_msi_update(),
> hvm/vmsi.c:vpci_msi_arch_update(), and hvm/vmsi.c:vpci_msi_disable().
>
> It's merely msixtbl_pt_{,un}register() which require the global or per-
> domain PCI lock held. Switch to using the latter, which is also sufficient
> to acquire in read mode. While strictly speaking this is needed only for
> PT_IRQ_TYPE_MSI, keep it being unconditional. In vioapic_hwdom_map_gsi()
> also unlock earlier.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> v2: Replace locking rather than dropping it altogether.
>
> --- a/xen/arch/x86/domctl.c
> +++ b/xen/arch/x86/domctl.c
> @@ -636,9 +636,9 @@ long arch_do_domctl(
> ret = -EPERM;
> else if ( is_iommu_enabled(d) )
> {
> - pcidevs_lock();
> + read_lock(&d->pci_lock);
> ret = pt_irq_create_bind(d, bind);
> - pcidevs_unlock();
> + read_unlock(&d->pci_lock);
>
> if ( ret < 0 )
> printk(XENLOG_G_ERR "pt_irq_create_bind failed (%ld) for %pd\n",
> @@ -670,9 +670,9 @@ long arch_do_domctl(
> ret = -EPERM;
> else if ( is_iommu_enabled(d) )
> {
> - pcidevs_lock();
> + read_lock(&d->pci_lock);
> ret = pt_irq_destroy_bind(d, bind);
> - pcidevs_unlock();
> + read_unlock(&d->pci_lock);
>
> if ( ret < 0 )
> printk(XENLOG_G_ERR "pt_irq_destroy_bind failed (%ld) for %pd\n",
> --- a/xen/arch/x86/hvm/vioapic.c
> +++ b/xen/arch/x86/hvm/vioapic.c
> @@ -197,8 +197,9 @@ static int vioapic_hwdom_map_gsi(unsigne
> return ret;
> }
>
> - pcidevs_lock();
> + read_lock(&currd->pci_lock);
> ret = pt_irq_create_bind(currd, &pt_irq_bind);
> + read_unlock(&currd->pci_lock);
I think you need to extend the ->pci_lock'ed region so it also covers
unmap_domain_pirq(), otherwise the ASSERT_PDEV_LIST_IS_READ_LOCKED()
in there will trigger? IE: the read_unlock() needs to be where the
pcidevs_unlock() is?
Thanks, Roger.
next prev parent reply other threads:[~2026-10-28 14:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 11:40 [PATCH v2 0/5] x86: pass-through / {,v}PCI locking Jan Beulich
2026-09-30 11:42 ` [PATCH v2 1/5] x86/pass-through: alter locking around pt_irq_{create,destroy}_bind() Jan Beulich
2026-10-28 14:33 ` Roger Pau Monné [this message]
2026-10-28 15:21 ` Jan Beulich
2026-10-28 15:36 ` Roger Pau Monné
2026-09-30 11:42 ` [PATCH v2 2/5] x86/vPCI: tighten locking assertions Jan Beulich
2026-09-30 11:43 ` [PATCH v2 3/5] x86/pass-through: use simpler locking primitives in pt_irq_{create,destroy}_bind() Jan Beulich
2026-09-30 11:43 ` [PATCH v2 4/5] x86/vPCI: make better use of "pdev" in vpci_msix_arch_print() Jan Beulich
2026-10-28 14:38 ` Roger Pau Monné
2026-09-30 11:43 ` [PATCH v2 5/5] x86/vMSI: avoid "goto" in msixtbl_pt_unregister() Jan Beulich
2026-10-28 14:51 ` 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=auIHqfrpdFnmgoMq@Mac.lan \
--to=roger@xenproject.org \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=julian.vetter@vates.tech \
--cc=teddy.astie@vates.tech \
--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 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.