Add function pointer apic_id_from_topo_ids in PCMachineState. Initialize with correct handler based on the mode selected. Also rename the handler apicid_from_topo_ids to x86_apicid_from_topo_ids for consistency. x86_apicid_from_topo_ids will be the default handler.
Signed-off-by: Babu Moger <babu.mo...@amd.com --- hw/i386/pc.c | 3 ++- include/hw/i386/pc.h | 2 ++ include/hw/i386/topology.h | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index b0d58515dd..e6c8a458e7 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2305,7 +2305,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, topo_ids.llc_id = cpu->llc_id; topo_ids.core_id = cpu->core_id; topo_ids.smt_id = cpu->thread_id; - cpu->apic_id = apicid_from_topo_ids(&topo_info, &topo_ids); + cpu->apic_id = pcms->apicid_from_topo_ids(&topo_info, &topo_ids); } cpu_slot = pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); @@ -2682,6 +2682,7 @@ static void pc_machine_initfn(Object *obj) /* Initialize the apic id related handlers */ pcms->apicid_from_cpu_idx = x86_apicid_from_cpu_idx; pcms->topo_ids_from_apicid = x86_topo_ids_from_apicid; + pcms->apicid_from_topo_ids = x86_apicid_from_topo_ids; pc_system_flash_create(pcms); } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index ffc5c78164..0789f8b5ea 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -73,6 +73,8 @@ struct PCMachineState { unsigned cpu_index); void (*topo_ids_from_apicid)(apic_id_t apicid, X86CPUTopoInfo *topo_info, X86CPUTopoIDs *topo_ids); + apic_id_t (*apicid_from_topo_ids)(X86CPUTopoInfo *topo_info, + const X86CPUTopoIDs *topo_ids); /* Address space used by IOAPIC device. All IOAPIC interrupts * will be translated to MSI messages in the address space. */ diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index adb92fe9ce..b2b9e93a06 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -206,7 +206,7 @@ static inline apic_id_t x86_apicid_from_cpu_idx_epyc(X86CPUTopoInfo *topo_info, * * The caller must make sure core_id < nr_cores and smt_id < nr_threads. */ -static inline apic_id_t apicid_from_topo_ids(X86CPUTopoInfo *topo_info, +static inline apic_id_t x86_apicid_from_topo_ids(X86CPUTopoInfo *topo_info, const X86CPUTopoIDs *topo_ids) { return (topo_ids->pkg_id << apicid_pkg_offset(topo_info)) | @@ -259,7 +259,7 @@ static inline apic_id_t x86_apicid_from_cpu_idx(X86CPUTopoInfo *topo_info, { X86CPUTopoIDs topo_ids; x86_topo_ids_from_idx(topo_info, cpu_index, &topo_ids); - return apicid_from_topo_ids(topo_info, &topo_ids); + return x86_apicid_from_topo_ids(topo_info, &topo_ids); } #endif /* HW_I386_TOPOLOGY_H */