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>
---
target/loongarch/cpu.c | 9 +++++++++
target/loongarch/cpu.h | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 3788f895c1..df76ab66d5 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 9dc71fa7f1..677100bd42 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;
--
2.43.5