* [PATCH 0/4] x86: yet more PCI locking adjustments
@ 2026-10-29 14:22 Jan Beulich
2026-10-29 14:23 ` [PATCH 1/4] x86/physdev: use less heavy locking in physdev_unmap_pirq() Jan Beulich
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Jan Beulich @ 2026-10-29 14:22 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
Continuing from 13efde94f4af ("x86/vPCI: tighten locking assertions").
1: physdev: use less heavy locking in physdev_unmap_pirq()
2: IRQ: use less heavy locking in free_domain_pirqs()
3: MSI: drop redundant checking
4: tighten PCI-related locking assertions
Jan
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/4] x86/physdev: use less heavy locking in physdev_unmap_pirq()
2026-10-29 14:22 [PATCH 0/4] x86: yet more PCI locking adjustments Jan Beulich
@ 2026-10-29 14:23 ` Jan Beulich
2026-11-17 10:29 ` Roger Pau Monné
2026-10-29 14:24 ` [PATCH 2/4] x86/IRQ: use less heavy locking in free_domain_pirqs() Jan Beulich
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: Jan Beulich @ 2026-10-29 14:23 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
Like its mapping counterpart, in the GSI case no (PCI-related) lock would
be needed at all, while in the MSI cases the domain's PCI lock is
sufficient to hold.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/physdev.c
+++ b/xen/arch/x86/physdev.c
@@ -156,11 +156,11 @@ int physdev_unmap_pirq(struct domain *d,
return ret;
}
- pcidevs_lock();
+ read_lock(&d->pci_lock);
write_lock(&d->event_lock);
ret = unmap_domain_pirq(d, pirq);
write_unlock(&d->event_lock);
- pcidevs_unlock();
+ read_unlock(&d->pci_lock);
return ret;
}
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/4] x86/IRQ: use less heavy locking in free_domain_pirqs()
2026-10-29 14:22 [PATCH 0/4] x86: yet more PCI locking adjustments Jan Beulich
2026-10-29 14:23 ` [PATCH 1/4] x86/physdev: use less heavy locking in physdev_unmap_pirq() Jan Beulich
@ 2026-10-29 14:24 ` Jan Beulich
2026-11-17 10:31 ` Roger Pau Monné
2026-10-29 14:24 ` [PATCH 3/4] x86/MSI: drop redundant checking Jan Beulich
2026-10-29 14:25 ` [PATCH 4/4] x86: tighten PCI-related locking assertions Jan Beulich
3 siblings, 1 reply; 13+ messages in thread
From: Jan Beulich @ 2026-10-29 14:24 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
Holding the domain's PCI lock (alongside its event lock) is sufficient
around unmap_domain_pirq().
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -2516,7 +2516,7 @@ void free_domain_pirqs(struct domain *d)
{
int i;
- pcidevs_lock();
+ read_lock(&d->pci_lock);
write_lock(&d->event_lock);
for ( i = 0; i < d->nr_pirqs; i++ )
@@ -2524,7 +2524,7 @@ void free_domain_pirqs(struct domain *d)
unmap_domain_pirq(d, i);
write_unlock(&d->event_lock);
- pcidevs_unlock();
+ read_unlock(&d->pci_lock);
}
static void cf_check dump_irqs(unsigned char key)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/4] x86/MSI: drop redundant checking
2026-10-29 14:22 [PATCH 0/4] x86: yet more PCI locking adjustments Jan Beulich
2026-10-29 14:23 ` [PATCH 1/4] x86/physdev: use less heavy locking in physdev_unmap_pirq() Jan Beulich
2026-10-29 14:24 ` [PATCH 2/4] x86/IRQ: use less heavy locking in free_domain_pirqs() Jan Beulich
@ 2026-10-29 14:24 ` Jan Beulich
2026-11-17 10:34 ` Roger Pau Monné
2026-10-29 14:25 ` [PATCH 4/4] x86: tighten PCI-related locking assertions Jan Beulich
3 siblings, 1 reply; 13+ messages in thread
From: Jan Beulich @ 2026-10-29 14:24 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
__pci_enable_msi{,x}() are local helpers of pci_enable_msi(). That one
already checks for pdev to be non-NULL, and it also asserts the necessary
locking state. msi_capability_init() in turn is a local helper of
__pci_enable_msi().
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/msi.c
+++ b/xen/arch/x86/msi.c
@@ -600,7 +600,6 @@ static int msi_capability_init(struct pc
unsigned int i, mpos;
uint16_t control;
- ASSERT_PDEV_LIST_IS_READ_LOCKED(dev->domain);
pos = dev->msi_pos;
if ( !pos )
return -ENODEV;
@@ -1004,11 +1003,6 @@ static int __pci_enable_msi(struct pci_d
{
struct msi_desc *old_desc;
- if ( !pdev )
- return -ENODEV;
-
- ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
-
old_desc = find_msi_entry(pdev, msi->irq, PCI_CAP_ID_MSI);
if ( old_desc )
{
@@ -1059,11 +1053,6 @@ static int __pci_enable_msix(struct pci_
{
struct msi_desc *old_desc;
- if ( !pdev )
- return -ENODEV;
-
- ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
-
if ( !pdev->msix )
return -ENODEV;
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/4] x86: tighten PCI-related locking assertions
2026-10-29 14:22 [PATCH 0/4] x86: yet more PCI locking adjustments Jan Beulich
` (2 preceding siblings ...)
2026-10-29 14:24 ` [PATCH 3/4] x86/MSI: drop redundant checking Jan Beulich
@ 2026-10-29 14:25 ` Jan Beulich
2026-11-17 10:41 ` Roger Pau Monné
3 siblings, 1 reply; 13+ messages in thread
From: Jan Beulich @ 2026-10-29 14:25 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné, Teddy Astie
With recent changes the .pi_update_irte() hook as well as
{,un}map_domain_pirq() and allocate_and_map_msi_pirq() won't be called
anymore with the global PCI lock held. Convert the assertions to check for
just the domain's PCI lock.
With that the somewhat ugly ASSERT_PDEV_LIST_IS_READ_LOCKED() isn't used
outside of msi.c anymore, so move the #define there.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
It being just two use sites which remain, we may want to do away with
ASSERT_PDEV_LIST_IS_READ_LOCKED() altogether. Thoughts? (It also isn't
qite clear to me why its #define(s) sit inside an #ifdef: The expression
used ought to be fine to use also in release builds, as it looks.)
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -419,7 +419,7 @@ static int cf_check vmx_pi_update_irte(c
spin_unlock_irq(&desc->lock);
- ASSERT_PDEV_LIST_IS_READ_LOCKED(msi_desc->dev->domain);
+ ASSERT(rw_is_locked(&msi_desc->dev->domain->pci_lock));
rc = iommu_update_ire_from_msi(msi_desc, &msg);
if ( rc > 0 )
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -2250,7 +2250,7 @@ int map_domain_pirq(
struct pci_dev *pdev;
unsigned int nr = 0;
- ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
+ ASSERT(rw_is_locked(&d->pci_lock));
ret = -ENODEV;
if ( !cpu_has_apic )
@@ -2410,7 +2410,7 @@ int unmap_domain_pirq(struct domain *d,
if ( (pirq < 0) || (pirq >= d->nr_pirqs) )
return -EINVAL;
- ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
+ ASSERT(rw_is_locked(&d->pci_lock));
ASSERT(rw_is_write_locked(&d->event_lock));
info = pirq_info(d, pirq);
@@ -3021,7 +3021,7 @@ int allocate_and_map_msi_pirq(struct dom
{
int irq = -1, pirq, ret;
- ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
+ ASSERT(rw_is_locked(&d->pci_lock));
switch ( type )
{
--- a/xen/arch/x86/msi.c
+++ b/xen/arch/x86/msi.c
@@ -737,6 +737,19 @@ static uint64_t read_pci_mem_bar(const s
return (addr & PCI_BASE_ADDRESS_MEM_MASK) + disp;
}
+#ifndef NDEBUG
+/*
+ * Check to ensure there will be no changes to the entries in d->pdev_list (but
+ * not the contents of each entry).
+ * This check is not suitable for protecting other state or critical regions.
+ */
+#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) \
+ /* NB: d may be evaluated multiple times, or not at all */ \
+ ASSERT(pcidevs_locked() || ((d) && rw_is_locked(&(d)->pci_lock)))
+#else
+#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) ((void)(d))
+#endif
+
/**
* msix_capability_init - configure device's MSI-X capability
* @dev: pointer to the pci_dev data structure of MSI-X device function
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -204,19 +204,6 @@ static always_inline bool pcidevs_tryloc
return lock_evaluate_nospec(pcidevs_trylock_unsafe());
}
-#ifndef NDEBUG
-/*
- * Check to ensure there will be no changes to the entries in d->pdev_list (but
- * not the contents of each entry).
- * This check is not suitable for protecting other state or critical regions.
- */
-#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) \
- /* NB: d may be evaluated multiple times, or not at all */ \
- ASSERT(pcidevs_locked() || ((d) && rw_is_locked(&(d)->pci_lock)))
-#else
-#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) ((void)(d))
-#endif
-
bool pci_known_segment(u16 seg);
bool pci_device_detect(pci_sbdf_t sbdf);
int scan_pci_devices(void);
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/4] x86/physdev: use less heavy locking in physdev_unmap_pirq()
2026-10-29 14:23 ` [PATCH 1/4] x86/physdev: use less heavy locking in physdev_unmap_pirq() Jan Beulich
@ 2026-11-17 10:29 ` Roger Pau Monné
0 siblings, 0 replies; 13+ messages in thread
From: Roger Pau Monné @ 2026-11-17 10:29 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel@lists.xenproject.org, Andrew Cooper, Teddy Astie
On Thu, Oct 29, 2026 at 03:23:56PM +0100, Jan Beulich wrote:
> Like its mapping counterpart, in the GSI case no (PCI-related) lock would
> be needed at all, while in the MSI cases the domain's PCI lock is
> sufficient to hold.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/arch/x86/physdev.c
> +++ b/xen/arch/x86/physdev.c
> @@ -156,11 +156,11 @@ int physdev_unmap_pirq(struct domain *d,
> return ret;
> }
>
> - pcidevs_lock();
> + read_lock(&d->pci_lock);
> write_lock(&d->event_lock);
> ret = unmap_domain_pirq(d, pirq);
> write_unlock(&d->event_lock);
> - pcidevs_unlock();
> + read_unlock(&d->pci_lock);
I think there's possibly one pre-patch that would be needed before
making this change. Callers of pci_restore_msi_state() only hold the
pcidevs lock, dropping pcidevs lock here we would be allowing changes
to the list while there's possibly a concurrent access by
pci_restore_msi_state().
I think pci_restore_msi_state() (or its callers) need to hold the
d->event_lock, and this likely wants to be a pre-patch. Not holding
d->event_lock while iterating over pdev->msi_list in
pci_restore_msi_state() seems like a pre-existing issue that would be
uncovered by this patch, albeit it's not clear what d->event_lock is
supposed to protect exactly.
Thanks, Roger.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/4] x86/IRQ: use less heavy locking in free_domain_pirqs()
2026-10-29 14:24 ` [PATCH 2/4] x86/IRQ: use less heavy locking in free_domain_pirqs() Jan Beulich
@ 2026-11-17 10:31 ` Roger Pau Monné
2026-11-17 10:38 ` Jan Beulich
0 siblings, 1 reply; 13+ messages in thread
From: Roger Pau Monné @ 2026-11-17 10:31 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel@lists.xenproject.org, Andrew Cooper, Teddy Astie
On Thu, Oct 29, 2026 at 03:24:13PM +0100, Jan Beulich wrote:
> Holding the domain's PCI lock (alongside its event lock) is sufficient
> around unmap_domain_pirq().
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger@xenproject.org>
Thanks, Roger.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/4] x86/MSI: drop redundant checking
2026-10-29 14:24 ` [PATCH 3/4] x86/MSI: drop redundant checking Jan Beulich
@ 2026-11-17 10:34 ` Roger Pau Monné
0 siblings, 0 replies; 13+ messages in thread
From: Roger Pau Monné @ 2026-11-17 10:34 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel@lists.xenproject.org, Andrew Cooper, Teddy Astie
On Thu, Oct 29, 2026 at 03:24:32PM +0100, Jan Beulich wrote:
> __pci_enable_msi{,x}() are local helpers of pci_enable_msi(). That one
> already checks for pdev to be non-NULL, and it also asserts the necessary
> locking state. msi_capability_init() in turn is a local helper of
> __pci_enable_msi().
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monne <roger@xenproject.org>
Thanks, Roger.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/4] x86/IRQ: use less heavy locking in free_domain_pirqs()
2026-11-17 10:31 ` Roger Pau Monné
@ 2026-11-17 10:38 ` Jan Beulich
2026-11-17 11:35 ` Roger Pau Monné
0 siblings, 1 reply; 13+ messages in thread
From: Jan Beulich @ 2026-11-17 10:38 UTC (permalink / raw)
To: Roger Pau Monné
Cc: xen-devel@lists.xenproject.org, Andrew Cooper, Teddy Astie
On 17.11.2026 11:31, Roger Pau Monné wrote:
> On Thu, Oct 29, 2026 at 03:24:13PM +0100, Jan Beulich wrote:
>> Holding the domain's PCI lock (alongside its event lock) is sufficient
>> around unmap_domain_pirq().
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> Acked-by: Roger Pau Monné <roger@xenproject.org>
Thanks, but: Considering your reply to patch 1, did you forget to make this
conditional upon the same prereq change that you outline there?
Jan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/4] x86: tighten PCI-related locking assertions
2026-10-29 14:25 ` [PATCH 4/4] x86: tighten PCI-related locking assertions Jan Beulich
@ 2026-11-17 10:41 ` Roger Pau Monné
2026-11-17 11:11 ` Jan Beulich
0 siblings, 1 reply; 13+ messages in thread
From: Roger Pau Monné @ 2026-11-17 10:41 UTC (permalink / raw)
To: Jan Beulich
Cc: xen-devel@lists.xenproject.org, Andrew Cooper, Julien Grall,
Stefano Stabellini, Anthony PERARD, Michal Orzel, Teddy Astie
On Thu, Oct 29, 2026 at 03:25:04PM +0100, Jan Beulich wrote:
> With recent changes the .pi_update_irte() hook as well as
> {,un}map_domain_pirq() and allocate_and_map_msi_pirq() won't be called
> anymore with the global PCI lock held. Convert the assertions to check for
> just the domain's PCI lock.
>
> With that the somewhat ugly ASSERT_PDEV_LIST_IS_READ_LOCKED() isn't used
> outside of msi.c anymore, so move the #define there.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger@xenproject.org>
I agree about keeping a single ASSERT_PDEV_LIST_IS_READ_LOCKED()
definitions and dropping the unneeded NDEBUG preprocessor conditional.
> ---
> It being just two use sites which remain, we may want to do away with
> ASSERT_PDEV_LIST_IS_READ_LOCKED() altogether. Thoughts?
IIRC the reason for having this expression was so it could be used
everywhere to ensure the domain pdev list was somehow locked (either
by pcidevs lock or the per-domain rwlock).
If we now have fine grained control over the locking it possibly makes
no sense to keep it.
> (It also isn't
> qite clear to me why its #define(s) sit inside an #ifdef: The expression
> used ought to be fine to use also in release builds, as it looks.)
Hm, I'm not sure. It looks like the debug expression could be used in
non-debug builds.
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -419,7 +419,7 @@ static int cf_check vmx_pi_update_irte(c
>
> spin_unlock_irq(&desc->lock);
>
> - ASSERT_PDEV_LIST_IS_READ_LOCKED(msi_desc->dev->domain);
> + ASSERT(rw_is_locked(&msi_desc->dev->domain->pci_lock));
>
> rc = iommu_update_ire_from_msi(msi_desc, &msg);
> if ( rc > 0 )
> --- a/xen/arch/x86/irq.c
> +++ b/xen/arch/x86/irq.c
> @@ -2250,7 +2250,7 @@ int map_domain_pirq(
> struct pci_dev *pdev;
> unsigned int nr = 0;
>
> - ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
> + ASSERT(rw_is_locked(&d->pci_lock));
>
> ret = -ENODEV;
> if ( !cpu_has_apic )
> @@ -2410,7 +2410,7 @@ int unmap_domain_pirq(struct domain *d,
> if ( (pirq < 0) || (pirq >= d->nr_pirqs) )
> return -EINVAL;
>
> - ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
> + ASSERT(rw_is_locked(&d->pci_lock));
> ASSERT(rw_is_write_locked(&d->event_lock));
>
> info = pirq_info(d, pirq);
> @@ -3021,7 +3021,7 @@ int allocate_and_map_msi_pirq(struct dom
> {
> int irq = -1, pirq, ret;
>
> - ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
> + ASSERT(rw_is_locked(&d->pci_lock));
>
> switch ( type )
> {
> --- a/xen/arch/x86/msi.c
> +++ b/xen/arch/x86/msi.c
> @@ -737,6 +737,19 @@ static uint64_t read_pci_mem_bar(const s
> return (addr & PCI_BASE_ADDRESS_MEM_MASK) + disp;
> }
>
> +#ifndef NDEBUG
> +/*
> + * Check to ensure there will be no changes to the entries in d->pdev_list (but
> + * not the contents of each entry).
> + * This check is not suitable for protecting other state or critical regions.
> + */
> +#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) \
> + /* NB: d may be evaluated multiple times, or not at all */ \
> + ASSERT(pcidevs_locked() || ((d) && rw_is_locked(&(d)->pci_lock)))
> +#else
> +#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) ((void)(d))
> +#endif
Maybe while moving it you can leave just the !NDEBUG variant?Q
Thanks, Roger.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/4] x86: tighten PCI-related locking assertions
2026-11-17 10:41 ` Roger Pau Monné
@ 2026-11-17 11:11 ` Jan Beulich
2026-11-17 11:27 ` Roger Pau Monné
0 siblings, 1 reply; 13+ messages in thread
From: Jan Beulich @ 2026-11-17 11:11 UTC (permalink / raw)
To: Roger Pau Monné
Cc: xen-devel@lists.xenproject.org, Andrew Cooper, Julien Grall,
Stefano Stabellini, Anthony PERARD, Michal Orzel, Teddy Astie
On 17.11.2026 11:41, Roger Pau Monné wrote:
> On Thu, Oct 29, 2026 at 03:25:04PM +0100, Jan Beulich wrote:
>> With recent changes the .pi_update_irte() hook as well as
>> {,un}map_domain_pirq() and allocate_and_map_msi_pirq() won't be called
>> anymore with the global PCI lock held. Convert the assertions to check for
>> just the domain's PCI lock.
>>
>> With that the somewhat ugly ASSERT_PDEV_LIST_IS_READ_LOCKED() isn't used
>> outside of msi.c anymore, so move the #define there.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> Acked-by: Roger Pau Monné <roger@xenproject.org>
Thanks. I'm a bit puzzled about your further remarks, though.
> I agree about keeping a single ASSERT_PDEV_LIST_IS_READ_LOCKED()
> definitions and dropping the unneeded NDEBUG preprocessor conditional.
Here you look to agree with ...
>> ---
>> It being just two use sites which remain, we may want to do away with
>> ASSERT_PDEV_LIST_IS_READ_LOCKED() altogether. Thoughts?
>
> IIRC the reason for having this expression was so it could be used
> everywhere to ensure the domain pdev list was somehow locked (either
> by pcidevs lock or the per-domain rwlock).
>
> If we now have fine grained control over the locking it possibly makes
> no sense to keep it.
>
>> (It also isn't
>> qite clear to me why its #define(s) sit inside an #ifdef: The expression
>> used ought to be fine to use also in release builds, as it looks.)
... this observation, just to ...
> Hm, I'm not sure. It looks like the debug expression could be used in
> non-debug builds.
... voice uncertainty here. And then ...
>> --- a/xen/arch/x86/msi.c
>> +++ b/xen/arch/x86/msi.c
>> @@ -737,6 +737,19 @@ static uint64_t read_pci_mem_bar(const s
>> return (addr & PCI_BASE_ADDRESS_MEM_MASK) + disp;
>> }
>>
>> +#ifndef NDEBUG
>> +/*
>> + * Check to ensure there will be no changes to the entries in d->pdev_list (but
>> + * not the contents of each entry).
>> + * This check is not suitable for protecting other state or critical regions.
>> + */
>> +#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) \
>> + /* NB: d may be evaluated multiple times, or not at all */ \
>> + ASSERT(pcidevs_locked() || ((d) && rw_is_locked(&(d)->pci_lock)))
>> +#else
>> +#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) ((void)(d))
>> +#endif
>
> Maybe while moving it you can leave just the !NDEBUG variant?Q
... you again suggest doing what my remark was effectively suggesting as
well.
Jan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/4] x86: tighten PCI-related locking assertions
2026-11-17 11:11 ` Jan Beulich
@ 2026-11-17 11:27 ` Roger Pau Monné
0 siblings, 0 replies; 13+ messages in thread
From: Roger Pau Monné @ 2026-11-17 11:27 UTC (permalink / raw)
To: Jan Beulich
Cc: xen-devel@lists.xenproject.org, Andrew Cooper, Julien Grall,
Stefano Stabellini, Anthony PERARD, Michal Orzel, Teddy Astie
On Tue, Nov 17, 2026 at 12:11:42PM +0100, Jan Beulich wrote:
> On 17.11.2026 11:41, Roger Pau Monné wrote:
> > On Thu, Oct 29, 2026 at 03:25:04PM +0100, Jan Beulich wrote:
> >> With recent changes the .pi_update_irte() hook as well as
> >> {,un}map_domain_pirq() and allocate_and_map_msi_pirq() won't be called
> >> anymore with the global PCI lock held. Convert the assertions to check for
> >> just the domain's PCI lock.
> >>
> >> With that the somewhat ugly ASSERT_PDEV_LIST_IS_READ_LOCKED() isn't used
> >> outside of msi.c anymore, so move the #define there.
> >>
> >> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> >
> > Acked-by: Roger Pau Monné <roger@xenproject.org>
>
> Thanks. I'm a bit puzzled about your further remarks, though.
>
> > I agree about keeping a single ASSERT_PDEV_LIST_IS_READ_LOCKED()
> > definitions and dropping the unneeded NDEBUG preprocessor conditional.
>
> Here you look to agree with ...
>
> >> ---
> >> It being just two use sites which remain, we may want to do away with
> >> ASSERT_PDEV_LIST_IS_READ_LOCKED() altogether. Thoughts?
> >
> > IIRC the reason for having this expression was so it could be used
> > everywhere to ensure the domain pdev list was somehow locked (either
> > by pcidevs lock or the per-domain rwlock).
> >
> > If we now have fine grained control over the locking it possibly makes
> > no sense to keep it.
> >
> >> (It also isn't
> >> qite clear to me why its #define(s) sit inside an #ifdef: The expression
> >> used ought to be fine to use also in release builds, as it looks.)
>
> ... this observation, just to ...
>
> > Hm, I'm not sure. It looks like the debug expression could be used in
> > non-debug builds.
>
> ... voice uncertainty here. And then ...
Uncertainty about why debug vs non-debug variants of the expression
were added in the first place :). I agree with you and see no need
for them.
Thanks, Roger
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/4] x86/IRQ: use less heavy locking in free_domain_pirqs()
2026-11-17 10:38 ` Jan Beulich
@ 2026-11-17 11:35 ` Roger Pau Monné
0 siblings, 0 replies; 13+ messages in thread
From: Roger Pau Monné @ 2026-11-17 11:35 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel@lists.xenproject.org, Andrew Cooper, Teddy Astie
On Tue, Nov 17, 2026 at 11:38:29AM +0100, Jan Beulich wrote:
> On 17.11.2026 11:31, Roger Pau Monné wrote:
> > On Thu, Oct 29, 2026 at 03:24:13PM +0100, Jan Beulich wrote:
> >> Holding the domain's PCI lock (alongside its event lock) is sufficient
> >> around unmap_domain_pirq().
> >>
> >> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> >
> > Acked-by: Roger Pau Monné <roger@xenproject.org>
>
> Thanks, but: Considering your reply to patch 1, did you forget to make this
> conditional upon the same prereq change that you outline there?
Strictly speaking this function is only called from
arch_domain_destroy(), which is done after PCI devices are deassigned
and MSIs are torn down. In this context unmap_domain_pirq() is only
caled against GSIs. But yes, for correctness (and to avoid confusion)
I should have tied it to the same request as patch 1.
Thanks, Roger.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-11-17 11:35 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-29 14:22 [PATCH 0/4] x86: yet more PCI locking adjustments Jan Beulich
2026-10-29 14:23 ` [PATCH 1/4] x86/physdev: use less heavy locking in physdev_unmap_pirq() Jan Beulich
2026-11-17 10:29 ` Roger Pau Monné
2026-10-29 14:24 ` [PATCH 2/4] x86/IRQ: use less heavy locking in free_domain_pirqs() Jan Beulich
2026-11-17 10:31 ` Roger Pau Monné
2026-11-17 10:38 ` Jan Beulich
2026-11-17 11:35 ` Roger Pau Monné
2026-10-29 14:24 ` [PATCH 3/4] x86/MSI: drop redundant checking Jan Beulich
2026-11-17 10:34 ` Roger Pau Monné
2026-10-29 14:25 ` [PATCH 4/4] x86: tighten PCI-related locking assertions Jan Beulich
2026-11-17 10:41 ` Roger Pau Monné
2026-11-17 11:11 ` Jan Beulich
2026-11-17 11:27 ` Roger Pau Monné
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.