]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
tools/hvmloader: Replace LAPIC_ID() with cpu_to_apicid[]
authorAlejandro Vallejo <alejandro.vallejo@cloud.com>
Mon, 10 Mar 2025 08:52:39 +0000 (09:52 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 10 Mar 2025 08:52:39 +0000 (09:52 +0100)
Replace uses of the LAPIC_ID() macro with accesses to the
cpu_to_apicid[] lookup table. This table contains the APIC IDs of each
vCPU as probed at runtime rather than assuming a predefined relation.

Moved smp_initialise() ahead of apic_setup() in order to initialise
cpu_to_apicid ASAP and avoid using it uninitialised. Note that bringing
up the APs doesn't need the APIC in hvmloader becasue it always runs
virtualized and uses the PV interface.

Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
tools/firmware/hvmloader/config.h
tools/firmware/hvmloader/hvmloader.c
tools/firmware/hvmloader/mp_tables.c
tools/firmware/hvmloader/util.c

index b32bcbf4a1f2f54fefde39dbff6a9615d2090f4a..6e1da137d779669fcf2ab9ba8aae78f4fa850327 100644 (file)
@@ -51,7 +51,6 @@ extern uint8_t ioapic_version;
 extern uint32_t *cpu_to_apicid;
 
 #define LAPIC_BASE_ADDRESS  0xfee00000
-#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
 
 #define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
 #define PCI_ISA_IRQ_MASK    0x0c20U /* ISA IRQs 5,10,11 are PCI connected */
index f8af88fabf24dc8272cf6dd929540cd69253cdb9..4e330fc1e241392dd3e510af4c96d21e24626f13 100644 (file)
@@ -224,7 +224,7 @@ static void apic_setup(void)
 
     /* 8259A ExtInts are delivered through IOAPIC pin 0 (Virtual Wire Mode). */
     ioapic_write(0x10, APIC_DM_EXTINT);
-    ioapic_write(0x11, SET_APIC_ID(LAPIC_ID(0)));
+    ioapic_write(0x11, SET_APIC_ID(cpu_to_apicid[0]));
 }
 
 struct bios_info {
@@ -341,11 +341,11 @@ int main(void)
 
     printf("CPU speed is %u MHz\n", get_cpu_mhz());
 
+    smp_initialise();
+
     apic_setup();
     pci_setup();
 
-    smp_initialise();
-
     perform_tests();
 
     if ( bios->bios_info_setup )
index 77d3010406d0a95888cb73e65f4f7785736458a4..3c93a5c947d986e3a7168215bfbdd59fe70dace6 100644 (file)
@@ -199,7 +199,7 @@ static void fill_mp_config_table(struct mp_config_table *mpct, int length)
 static void fill_mp_proc_entry(struct mp_proc_entry *mppe, int vcpu_id)
 {
     mppe->type = ENTRY_TYPE_PROCESSOR;
-    mppe->lapic_id = LAPIC_ID(vcpu_id);
+    mppe->lapic_id = cpu_to_apicid[vcpu_id];
     mppe->lapic_version = 0x11;
     mppe->cpu_flags = CPU_FLAG_ENABLED;
     if ( vcpu_id == 0 )
index d3b3f9038e64c1b27005f1097656f99558ec8d1d..2d07ce1290132fa4e12415bee76d764b959b1a5d 100644 (file)
@@ -827,7 +827,7 @@ static void acpi_mem_free(struct acpi_ctxt *ctxt,
 
 static uint32_t acpi_lapic_id(unsigned cpu)
 {
-    return LAPIC_ID(cpu);
+    return cpu_to_apicid[cpu];
 }
 
 void hvmloader_acpi_build_tables(struct acpi_config *config,