* [PATCH 1/2] x86/vlapic: size the all-ones broadcast by the sender's mode
@ 2026-11-19 22:00 Stefano Stabellini
2026-11-19 22:00 ` [PATCH 2/2] x86/passthrough: skip disabled vLAPICs in vector_hashing_dest() Stefano Stabellini
2026-11-20 8:58 ` [PATCH 1/2] x86/vlapic: size the all-ones broadcast by the sender's mode Jan Beulich
0 siblings, 2 replies; 5+ messages in thread
From: Stefano Stabellini @ 2026-11-19 22:00 UTC (permalink / raw)
To: xen-devel
Cc: stefano.stabellini, Andrew Cooper, Jan Beulich,
Roger Pau Monné, Teddy Astie
vlapic_match_dest() detects a broadcast by comparing the destination
with all ones in the target's mode, but an IPI's destination has the
width of the sender's mode.
Use the sender's mode when there is one, as is_multicast_dest() does:
whether a destination is a broadcast is decided by the sender. vIO-APIC
and MSI destinations have no sender and are still compared in the
target's mode.
Fixes: 82d29b97d013 ("x86/vlapic: accept a logical destination of all ones as a broadcast")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Link: https://lore.kernel.org/xen-devel/95e0e0fb-2978-4c87-b723-fb7c30f36883@citrix.com/
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
---
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Roger Pau Monné <roger@xenproject.org>
CC: Teddy Astie <teddy.astie@vates.tech>
xen/arch/x86/hvm/vlapic.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
index 50b515d254..b7861bd2ba 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -247,8 +247,12 @@ bool vlapic_match_dest(
switch ( short_hand )
{
case APIC_DEST_NOSHORT:
- /* All ones is a broadcast in either destination mode. */
- if ( dest == _VLAPIC_ID(target, 0xffffffffU) )
+ /*
+ * All ones is a broadcast in either destination mode. An IPI's
+ * destination has the width of its sender's mode; IO-APIC and MSI
+ * destinations are compared in the target's.
+ */
+ if ( dest == _VLAPIC_ID(source ?: target, 0xffffffffU) )
return true;
if ( dest_mode )
return vlapic_match_logical_addr(target, dest);
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] x86/passthrough: skip disabled vLAPICs in vector_hashing_dest()
2026-11-19 22:00 [PATCH 1/2] x86/vlapic: size the all-ones broadcast by the sender's mode Stefano Stabellini
@ 2026-11-19 22:00 ` Stefano Stabellini
2026-11-20 8:24 ` Jan Beulich
2026-11-20 8:58 ` [PATCH 1/2] x86/vlapic: size the all-ones broadcast by the sender's mode Jan Beulich
1 sibling, 1 reply; 5+ messages in thread
From: Stefano Stabellini @ 2026-11-19 22:00 UTC (permalink / raw)
To: xen-devel
Cc: stefano.stabellini, Jan Beulich, Andrew Cooper,
Roger Pau Monné, Teddy Astie
Unlike vlapic_lowest_prio(), vector_hashing_dest() does not check
vlapic_enabled(), so a lowest-priority MSI can be posted to a vCPU
whose LAPIC is disabled, e.g. an AP not yet started, and the interrupt
is left pending in that vCPU's PIR instead of being delivered.
Skip such vCPUs, as vlapic_lowest_prio() does, and as vioapic_deliver()
already mimics where it uses vlapic_match_dest() on its own.
Fixes: 35a1caf8b6b5 ("pass-through: update IRTE according to guest interrupt config changes")
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
---
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Roger Pau Monné <roger@xenproject.org>
CC: Teddy Astie <teddy.astie@vates.tech>
xen/drivers/passthrough/x86/hvm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/xen/drivers/passthrough/x86/hvm.c b/xen/drivers/passthrough/x86/hvm.c
index 9f8e6c8cd5..7971acadbc 100644
--- a/xen/drivers/passthrough/x86/hvm.c
+++ b/xen/drivers/passthrough/x86/hvm.c
@@ -191,7 +191,8 @@ static struct vcpu *vector_hashing_dest(const struct domain *d,
for_each_vcpu ( d, v )
{
if ( !vlapic_match_dest(vcpu_vlapic(v), NULL, APIC_DEST_NOSHORT,
- dest_id, dest_mode) )
+ dest_id, dest_mode) ||
+ !vlapic_enabled(vcpu_vlapic(v)) )
continue;
__set_bit(v->vcpu_id, dest_vcpu_bitmap);
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] x86/passthrough: skip disabled vLAPICs in vector_hashing_dest()
2026-11-19 22:00 ` [PATCH 2/2] x86/passthrough: skip disabled vLAPICs in vector_hashing_dest() Stefano Stabellini
@ 2026-11-20 8:24 ` Jan Beulich
0 siblings, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2026-11-20 8:24 UTC (permalink / raw)
To: Stefano Stabellini
Cc: Andrew Cooper, Roger Pau Monné, Teddy Astie, xen-devel
On 19.11.2026 23:00, Stefano Stabellini wrote:
> Unlike vlapic_lowest_prio(), vector_hashing_dest() does not check
> vlapic_enabled(), so a lowest-priority MSI can be posted to a vCPU
> whose LAPIC is disabled, e.g. an AP not yet started, and the interrupt
> is left pending in that vCPU's PIR instead of being delivered.
>
> Skip such vCPUs, as vlapic_lowest_prio() does, and as vioapic_deliver()
> already mimics where it uses vlapic_match_dest() on its own.
>
> Fixes: 35a1caf8b6b5 ("pass-through: update IRTE according to guest interrupt config changes")
> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Please see https://lists.xen.org/archives/html/xen-devel/2026-11/msg01815.html
for a more extensive fix.
Jan
> --- a/xen/drivers/passthrough/x86/hvm.c
> +++ b/xen/drivers/passthrough/x86/hvm.c
> @@ -191,7 +191,8 @@ static struct vcpu *vector_hashing_dest(const struct domain *d,
> for_each_vcpu ( d, v )
> {
> if ( !vlapic_match_dest(vcpu_vlapic(v), NULL, APIC_DEST_NOSHORT,
> - dest_id, dest_mode) )
> + dest_id, dest_mode) ||
> + !vlapic_enabled(vcpu_vlapic(v)) )
> continue;
>
> __set_bit(v->vcpu_id, dest_vcpu_bitmap);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] x86/vlapic: size the all-ones broadcast by the sender's mode
2026-11-19 22:00 [PATCH 1/2] x86/vlapic: size the all-ones broadcast by the sender's mode Stefano Stabellini
2026-11-19 22:00 ` [PATCH 2/2] x86/passthrough: skip disabled vLAPICs in vector_hashing_dest() Stefano Stabellini
@ 2026-11-20 8:58 ` Jan Beulich
2026-11-20 21:55 ` Stefano Stabellini
1 sibling, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2026-11-20 8:58 UTC (permalink / raw)
To: Stefano Stabellini
Cc: Andrew Cooper, Roger Pau Monné, Teddy Astie, xen-devel
On 19.11.2026 23:00, Stefano Stabellini wrote:
> vlapic_match_dest() detects a broadcast by comparing the destination
> with all ones in the target's mode, but an IPI's destination has the
> width of the sender's mode.
>
> Use the sender's mode when there is one, as is_multicast_dest() does:
> whether a destination is a broadcast is decided by the sender. vIO-APIC
> and MSI destinations have no sender and are still compared in the
> target's mode.
But that isn't right: Those simply cannot express wide target IDs. Aiui
0xff is uniformly "broadcast" there. (Or alternatively 0xff cannot
validly be used in x2APIC mode, or even at all. I fear different sources
say different things as to the validity of this.)
The situation is perhaps yet more fuzzy there with the 15-bit ID extension,
for which patches are floating around. All we've got in the tree so far is
XEN_HVM_CPUID_EXT_DEST_ID afaics.
Overall with no sender it may be best to simply skip the broadcast check.
Jan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] x86/vlapic: size the all-ones broadcast by the sender's mode
2026-11-20 8:58 ` [PATCH 1/2] x86/vlapic: size the all-ones broadcast by the sender's mode Jan Beulich
@ 2026-11-20 21:55 ` Stefano Stabellini
0 siblings, 0 replies; 5+ messages in thread
From: Stefano Stabellini @ 2026-11-20 21:55 UTC (permalink / raw)
To: Jan Beulich
Cc: Stefano Stabellini, Andrew Cooper, Roger Pau Monné,
Teddy Astie, xen-devel
On Fri, 20 Nov 2026, Jan Beulich wrote:
> On 19.11.2026 23:00, Stefano Stabellini wrote:
> > vlapic_match_dest() detects a broadcast by comparing the destination
> > with all ones in the target's mode, but an IPI's destination has the
> > width of the sender's mode.
> >
> > Use the sender's mode when there is one, as is_multicast_dest() does:
> > whether a destination is a broadcast is decided by the sender. vIO-APIC
> > and MSI destinations have no sender and are still compared in the
> > target's mode.
>
> But that isn't right: Those simply cannot express wide target IDs. Aiui
> 0xff is uniformly "broadcast" there. (Or alternatively 0xff cannot
> validly be used in x2APIC mode, or even at all. I fear different sources
> say different things as to the validity of this.)
>
> The situation is perhaps yet more fuzzy there with the 15-bit ID extension,
> for which patches are floating around. All we've got in the tree so far is
> XEN_HVM_CPUID_EXT_DEST_ID afaics.
>
> Overall with no sender it may be best to simply skip the broadcast check.
Is this what you are thinking?
if ( source && dest == _VLAPIC_ID(source, 0xffffffffU) )
return true;
Note that this also drops the physical 0xff broadcast from IO-APIC/MSI
to xAPIC-mode vLAPICs.
If 0xff is uniformly a broadcast for IO-APIC/MSI, the alternative is to
accept a physical 0xff from them for every vLAPIC, independent of the
target's mode:
case APIC_DEST_NOSHORT:
if ( source ? dest == _VLAPIC_ID(source, 0xffffffffU)
: !dest_mode && dest == 0xff )
return true;
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-20 21:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 22:00 [PATCH 1/2] x86/vlapic: size the all-ones broadcast by the sender's mode Stefano Stabellini
2026-11-19 22:00 ` [PATCH 2/2] x86/passthrough: skip disabled vLAPICs in vector_hashing_dest() Stefano Stabellini
2026-11-20 8:24 ` Jan Beulich
2026-11-20 8:58 ` [PATCH 1/2] x86/vlapic: size the all-ones broadcast by the sender's mode Jan Beulich
2026-11-20 21:55 ` Stefano Stabellini
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.