All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/7] x86/vioapic: Add ioapic_check() to validate IO-APIC state before restore
@ 2026-03-09 12:31 Julian Vetter
  2026-03-09 12:31 ` [PATCH v3 4/7] x86/passthrough: Use extended destination ID in PT MSI bind/unbind Julian Vetter
                   ` (6 more replies)
  0 siblings, 7 replies; 23+ messages in thread
From: Julian Vetter @ 2026-03-09 12:31 UTC (permalink / raw)
  To: xen-devel
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné, Anthony PERARD,
	Michal Orzel, Stefano Stabellini, Juergen Gross, Julien Grall,
	Julian Vetter

Register a check callback for the IOAPIC HVM save/restore entry,
following the pattern established by vpic_check() for the virtual PIC.
The function first verifies the target domain actually has a virtual
IO-APIC, returning -ENODEV otherwise. It then iterates all redirection
table entries and rejects any saved state where reserved bit fields are
non-zero, ensuring the state being loaded, represents actually reachable
hardware state before the restore is committed.

Signed-off-by: Julian Vetter <julian.vetter@vates.tech>
---
Changes in V3:
- As suggested by Jan, added new patch that does a generic check of the
  vIOAPIC state before migration
---
 xen/arch/x86/hvm/vioapic.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c
index 7c725f9e47..b9acdd8af6 100644
--- a/xen/arch/x86/hvm/vioapic.c
+++ b/xen/arch/x86/hvm/vioapic.c
@@ -594,6 +594,35 @@ int vioapic_get_trigger_mode(const struct domain *d, unsigned int gsi)
     return vioapic->redirtbl[pin].fields.trig_mode;
 }
 
+static int cf_check ioapic_check(const struct domain *d, hvm_domain_context_t *h)
+{
+    const HVM_SAVE_TYPE(IOAPIC) *s;
+    unsigned int i;
+
+    if ( !has_vioapic(d) )
+        return -ENODEV;
+
+    s = hvm_get_entry(IOAPIC, h);
+    if ( !s )
+        return -ENODATA;
+
+    for ( i = 0; i < ARRAY_SIZE(s->redirtbl); i++ )
+    {
+        const union vioapic_redir_entry *e = &s->redirtbl[i];
+
+        /*
+         * Check to-be-loaded values are within valid range, for them to
+         * represent actually reachable state.
+         */
+        if ( e->fields.reserve ||
+             e->fields.reserved[0] || e->fields.reserved[1] ||
+             e->fields.reserved[2] || e->fields.reserved[3] )
+            return -EINVAL;
+    }
+
+    return 0;
+}
+
 static int cf_check ioapic_save(struct vcpu *v, hvm_domain_context_t *h)
 {
     const struct domain *d = v->domain;
-- 
2.51.0



--
 | Vates

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2026-03-25 10:59 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 12:31 [PATCH v3 1/7] x86/vioapic: Add ioapic_check() to validate IO-APIC state before restore Julian Vetter
2026-03-09 12:31 ` [PATCH v3 4/7] x86/passthrough: Use extended destination ID in PT MSI bind/unbind Julian Vetter
2026-03-11 15:30   ` Jan Beulich
2026-03-09 12:31 ` [PATCH v3 2/7] x86/msi: Define extended destination ID masks and IO-APIC RTE fields Julian Vetter
2026-03-10 17:09   ` Jan Beulich
2026-03-11 10:15   ` Roger Pau Monné
2026-03-09 12:31 ` [PATCH v3 3/7] x86/hvm: Support extended destination IDs in virtual MSI and IO-APIC Julian Vetter
2026-03-11 15:27   ` Jan Beulich
2026-03-12 11:15     ` Jan Beulich
2026-03-16 15:06       ` Julian Vetter
2026-03-19  9:02         ` Jan Beulich
2026-03-09 12:31 ` [PATCH v3 6/7] x86/dmop: Add XEN_DMOP_enable_ext_dest_id DM op Julian Vetter
2026-03-09 13:26   ` Roger Pau Monné
2026-03-17 10:22     ` Julian Vetter
2026-03-25 10:58       ` Roger Pau Monné
2026-03-12 11:18   ` Jan Beulich
2026-03-09 12:31 ` [PATCH v3 7/7] x86/cpuid: Advertise XEN_HVM_CPUID_EXT_DEST_ID when device model opts in Julian Vetter
2026-03-09 12:31 ` [PATCH v3 5/7] x86/dmop: Add XEN_DMOP_{bind,unbind}_pt_msi_irq DM ops Julian Vetter
2026-03-09 13:38   ` Roger Pau Monné
2026-03-11 16:04   ` Jan Beulich
2026-03-12 11:53     ` Jan Beulich
2026-03-12 11:30   ` Jan Beulich
2026-03-10 16:55 ` [PATCH v3 1/7] x86/vioapic: Add ioapic_check() to validate IO-APIC state before restore Jan Beulich

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.