Skip to contentSkip to conversation

x86/vioapic: allow holes in the GSI range for PVH Dom0

PATCH Superseded Roger Pau Monne 2 participants 2 messages Apr 18, 2017

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/vioapic: allow holes in the GSI range for PVH Dom0

The current vIO APIC for PVH Dom0 doesn't allow non-contiguous GSIs, which means that all GSIs must belong to an IO APIC. This doesn't match reality, where there are systems with non-contiguous GSIs.

In order to fix this add a base_gsi field to each hvm_vioapic struct, in order to store the base GSI for each emulated IO APIC. For PVH Dom0 those values are populated based on the hardware ones.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Chao Gao <[email protected]>
---
Changes since v1:
- Calculate the maximum GSI in vioapic_init taking into account the base GSI of each IO APIC.
- Use the vioapic base_gsi field in the PVH Dom0 build in order to populate the MADT IO APIC entries.

I think this is a good canditate to be included in 4.9, it's a bugfix, and it's only used by PVH Dom0, so the risk is low IMHO.

---
 xen/arch/x86/hvm/dom0_build.c     |  2 +-
 xen/arch/x86/hvm/vioapic.c        | 45 +++++++++++++++++----------------------
 xen/include/asm-x86/hvm/vioapic.h |  1 +
 3 files changed, 21 insertions(+), 27 deletions(-)
xen/arch/x86/hvm/dom0_build.c +1 -1
index db9be87612..020c355faf 100644
@@ -719,7 +719,7 @@ static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr)
         io_apic->header.length = sizeof(*io_apic);
         io_apic->id = domain_vioapic(d, i)->id;
         io_apic->address = domain_vioapic(d, i)->base_address;
-        io_apic->global_irq_base = io_apic_gsi_base(i);
+        io_apic->global_irq_base = domain_vioapic(d, i)->base_gsi;
         io_apic++;
     }
 
xen/arch/x86/hvm/vioapic.c +19 -26

118 lines not on this page · raw message

xen/include/asm-x86/hvm/vioapic.h +1 -0
index 8ec91d2bd1..2ceb60eaef 100644
@@ -50,6 +50,7 @@
 struct hvm_vioapic {
     struct domain *domain;
     uint32_t nr_pins;
+    unsigned int base_gsi;
     union {
         XEN_HVM_VIOAPIC(,);
         struct hvm_hw_vioapic domU;
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

xen/arch/x86/hvm/vioapic.c void vioapic_reset(struct domain *d) · line 542

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 18.04.17 at 11:14, <[email protected]> wrote:
xen/arch/x86/hvm/vioapic.c +1 -0
@@ -554,6 +539,7 @@ void vioapic_reset(struct domain *d)
         {
             vioapic->base_address = mp_ioapics[i].mpc_apicaddr;
             vioapic->id = mp_ioapics[i].mpc_apicid;
+            vioapic->base_gsi = io_apic_gsi_base(i);

The value doesn't change over the lifetime of the vIO-APIC, so I'd prefer this initialization to be done ...

xen/arch/x86/hvm/vioapic.c int vioapic_init(struct domain *d) · line 580

Quoted 6 lines
xen/arch/x86/hvm/vioapic.c +2 -0
@@ -590,6 +576,8 @@ int vioapic_init(struct domain *d)
     {
         unsigned int nr_pins = is_hardware_domain(d) ? nr_ioapic_entries[i] :
             ARRAY_SIZE(domain_vioapic(d, 0)->domU.redirtbl);
+        unsigned int base_gsi = is_hardware_domain(d) ? io_apic_gsi_base(i)
+                                                      : 0;

... somewhere below here, also avoiding to have the same logic (Dom0 vs DomU) in two places. Perhaps the nr_pins calculation could then be moved into that new if() (and its else) as well.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel