diff mbox series

[v3,08/18] hw/i386: Update structures for nodes_per_pkg

Message ID 157541987113.46157.12421621035195290598.stgit@naples-babu.amd.com (mailing list archive)
State New, archived
Headers show
Series APIC ID fixes for AMD EPYC CPU models | expand

Commit Message

Babu Moger Dec. 4, 2019, 12:37 a.m. UTC
Update structures X86CPUTopoIDs and CPUX86State to hold the nodes_per_pkg. This
is required to build EPYC mode topology.

Signed-off-by: Babu Moger <babu.moger@amd.com>
---
 hw/i386/pc.c               |    4 ++++
 include/hw/i386/topology.h |    1 +
 target/i386/cpu.c          |    1 +
 target/i386/cpu.h          |    1 +
 4 files changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index df5339c102..5dc11df922 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -870,6 +870,7 @@  static inline void initialize_topo_info(X86CPUTopoInfo *topo_info,
                                         PCMachineState *pcms,
                                         const MachineState *ms)
 {
+    topo_info->nodes_per_pkg = ms->numa_state->num_nodes / ms->smp.sockets;
     topo_info->dies_per_pkg = pcms->smp_dies;
     topo_info->cores_per_die = ms->smp.cores;
     topo_info->threads_per_core = ms->smp.threads;
@@ -1390,11 +1391,13 @@  static void pc_new_cpu(PCMachineState *pcms, int64_t apic_id, Error **errp)
     Object *cpu = NULL;
     Error *local_err = NULL;
     CPUX86State *env = NULL;
+    MachineState *ms = MACHINE(pcms);
 
     cpu = object_new(MACHINE(pcms)->cpu_type);
 
     env = &X86_CPU(cpu)->env;
     env->nr_dies = pcms->smp_dies;
+    env->nr_nodes = ms->numa_state->num_nodes / ms->smp.sockets;
 
     object_property_set_uint(cpu, apic_id, "apic-id", &local_err);
     object_property_set_bool(cpu, true, "realized", &local_err);
@@ -2242,6 +2245,7 @@  static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
     initialize_topo_info(&topo_info, pcms, ms);
 
     env->nr_dies = pcms->smp_dies;
+    env->nr_nodes = ms->numa_state->num_nodes / ms->smp.sockets;
 
     /*
      * If APIC ID is not set,
diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h
index 1238006208..cfb09312fe 100644
--- a/include/hw/i386/topology.h
+++ b/include/hw/i386/topology.h
@@ -54,6 +54,7 @@  typedef struct X86CPUTopoIDs {
 } X86CPUTopoIDs;
 
 typedef struct X86CPUTopoInfo {
+    unsigned nodes_per_pkg;
     unsigned dies_per_pkg;
     unsigned cores_per_die;
     unsigned threads_per_core;
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 3c81aa3ecd..9b2608a4c8 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -5996,6 +5996,7 @@  static void x86_cpu_initfn(Object *obj)
     FeatureWord w;
 
     env->nr_dies = 1;
+    env->nr_nodes = 1;
     cpu_set_cpustate_pointers(cpu);
 
     object_property_add(obj, "family", "int",
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index a56d44e405..0ef4fdb55f 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1591,6 +1591,7 @@  typedef struct CPUX86State {
     TPRAccess tpr_access_type;
 
     unsigned nr_dies;
+    unsigned nr_nodes;
 } CPUX86State;
 
 struct kvm_msrs;