If the system is numa configured the pkg_offset needs to be adjusted for EPYC cpu models. Fix it calling the model specific handler.
Signed-off-by: Babu Moger <babu.mo...@amd.com> --- hw/i386/pc.c | 1 + hw/i386/x86.c | 4 ++++ target/i386/cpu.c | 4 ++-- target/i386/cpu.h | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 93063af6a8..e56780b1f0 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1754,6 +1754,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, env->nr_dies = x86ms->smp_dies; env->nr_nodes = ms->numa_state->num_nodes / ms->smp.sockets; + env->pkg_offset = x86ms->apicid_pkg_offset(&topo_info); /* * If APIC ID is not set, diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 472dc3eb77..99f2a67d69 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -106,12 +106,16 @@ void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp) Error *local_err = NULL; CPUX86State *env = NULL; MachineState *ms = MACHINE(x86ms); + X86CPUTopoInfo topo_info; + + init_topo_info(&topo_info, x86ms); cpu = object_new(MACHINE(x86ms)->cpu_type); env = &X86_CPU(cpu)->env; env->nr_dies = x86ms->smp_dies; env->nr_nodes = ms->numa_state->num_nodes / ms->smp.sockets; + env->pkg_offset = x86ms->apicid_pkg_offset(&topo_info); object_property_set_uint(cpu, apic_id, "apic-id", &local_err); object_property_set_bool(cpu, true, "realized", &local_err); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 082865d72b..b793da7c6e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5454,7 +5454,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx |= CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: - *eax = apicid_pkg_offset(&topo_info); + *eax = env->pkg_offset; *ebx = cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_CORE; break; @@ -5488,7 +5488,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx |= CPUID_TOPOLOGY_LEVEL_CORE; break; case 2: - *eax = apicid_pkg_offset(&topo_info); + *eax = env->pkg_offset; *ebx = env->nr_dies * cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_DIE; break; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 64a1cca690..641e1cacdf 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1604,6 +1604,7 @@ typedef struct CPUX86State { unsigned nr_dies; unsigned nr_nodes; + unsigned pkg_offset; } CPUX86State; struct kvm_msrs;