qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC 52/52] i386: Support cpu_index_to_core_type() for x86


From: Zhao Liu
Subject: [RFC 52/52] i386: Support cpu_index_to_core_type() for x86
Date: Mon, 13 Feb 2023 17:50:35 +0800

From: Zhao Liu <zhao1.liu@intel.com>

The cpu_index_to_core_type() of MachineClass is implemented in x86 to
obtain the string name of core type, so that users can get the basic
topology information (topology type and core type) of x86 machine
(currently, only PC machine) in query_cpus_fast.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 hw/i386/x86.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index f58a90359170..67318a527c6c 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -1583,6 +1583,38 @@ static int x86_parse_hybrid_core_type(MachineState *ms, 
const char *coretype)
     return type;
 }
 
+static const char *x86_cpu_index_to_hybrid_core_type(MachineState *machine,
+                                                     unsigned cpu_index)
+{
+    CPUState *cs;
+
+    if (machine_topo_is_smp(machine)) {
+        return NULL;
+    }
+
+    CPU_FOREACH(cs) {
+        X86CPU *cpu = X86_CPU(cs);
+        CPUX86State *env = &cpu->env;
+
+        if (cs->cpu_index == cpu_index) {
+            const char *core_type;
+
+            switch (env->hybrid_core_type) {
+            case INTEL_ATOM_TYPE:
+                core_type = "atom";
+                break;
+            case INTEL_CORE_TYPE:
+                core_type = "core";
+                break;
+            default:
+                abort();
+            }
+            return core_type;
+        }
+    }
+    return NULL;
+}
+
 static void x86_machine_initfn(Object *obj)
 {
     X86MachineState *x86ms = X86_MACHINE(obj);
@@ -1611,6 +1643,7 @@ static void x86_machine_class_init(ObjectClass *oc, void 
*data)
     x86mc->fwcfg_dma_enabled = true;
     nc->nmi_monitor_handler = x86_nmi;
     mc->core_type = x86_parse_hybrid_core_type;
+    mc->cpu_index_to_core_type = x86_cpu_index_to_hybrid_core_type;
 
     object_class_property_add(oc, X86_MACHINE_SMM, "OnOffAuto",
         x86_machine_get_smm, x86_machine_set_smm,
-- 
2.34.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]