aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBibo Mao <maobibo@loongson.cn>2025-03-05 09:27:59 +0800
committerBibo Mao <maobibo@loongson.cn>2025-03-05 09:39:17 +0800
commitd32fde20bd334a9fa4efab95583bc596d01a39ea (patch)
treed48967f2cda025e112d572e2dcf529410a0a0556
parent8ccf28c2f6cf54c82485de099b4566b260893445 (diff)
downloadqemu-d32fde20bd334a9fa4efab95583bc596d01a39ea.zip
qemu-d32fde20bd334a9fa4efab95583bc596d01a39ea.tar.gz
qemu-d32fde20bd334a9fa4efab95583bc596d01a39ea.tar.bz2
hw/loongarch/virt: Add topo properties on CPU object
Add some properties such as socket_id, core_id, thread_id and node_id on LoongArch CPU object. Co-developed-by: Xianglai Li <lixianglai@loongson.cn> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
-rw-r--r--target/loongarch/cpu.c9
-rw-r--r--target/loongarch/cpu.h4
2 files changed, 13 insertions, 0 deletions
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 3788f89..df76ab6 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -14,6 +14,7 @@
#include "system/tcg.h"
#include "system/kvm.h"
#include "kvm/kvm_loongarch.h"
+#include "hw/qdev-properties.h"
#include "exec/exec-all.h"
#include "exec/translation-block.h"
#include "cpu.h"
@@ -879,6 +880,13 @@ static int64_t loongarch_cpu_get_arch_id(CPUState *cs)
}
#endif
+static const Property loongarch_cpu_properties[] = {
+ DEFINE_PROP_INT32("socket-id", LoongArchCPU, socket_id, 0),
+ DEFINE_PROP_INT32("core-id", LoongArchCPU, core_id, 0),
+ DEFINE_PROP_INT32("thread-id", LoongArchCPU, thread_id, 0),
+ DEFINE_PROP_INT32("node-id", LoongArchCPU, node_id, CPU_UNSET_NUMA_NODE_ID),
+};
+
static void loongarch_cpu_class_init(ObjectClass *c, void *data)
{
LoongArchCPUClass *lacc = LOONGARCH_CPU_CLASS(c);
@@ -886,6 +894,7 @@ static void loongarch_cpu_class_init(ObjectClass *c, void *data)
DeviceClass *dc = DEVICE_CLASS(c);
ResettableClass *rc = RESETTABLE_CLASS(c);
+ device_class_set_props(dc, loongarch_cpu_properties);
device_class_set_parent_realize(dc, loongarch_cpu_realizefn,
&lacc->parent_realize);
resettable_class_set_parent_phases(rc, NULL, loongarch_cpu_reset_hold, NULL,
diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index 9dc71fa..677100b 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -417,6 +417,10 @@ struct ArchCPU {
OnOffAuto lasx;
OnOffAuto kvm_pv_ipi;
OnOffAuto kvm_steal_time;
+ int32_t socket_id; /* socket-id of this CPU */
+ int32_t core_id; /* core-id of this CPU */
+ int32_t thread_id; /* thread-id of this CPU */
+ int32_t node_id; /* NUMA node of this CPU */
/* 'compatible' string for this CPU for Linux device trees */
const char *dtb_compatible;