[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 1/4] target/i386/cpu: Introduce get_register_enum_32() helper
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v5 1/4] target/i386/cpu: Introduce get_register_enum_32() helper |
Date: |
Wed, 24 Feb 2021 23:46:40 +0100 |
Introduce get_register_enum_32(), similar to get_register_name_32().
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
target/i386/cpu-internal.h | 4 ++++
target/i386/cpu.c | 7 ++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/target/i386/cpu-internal.h b/target/i386/cpu-internal.h
index be688cb393e..9df24c482ea 100644
--- a/target/i386/cpu-internal.h
+++ b/target/i386/cpu-internal.h
@@ -20,6 +20,8 @@
#ifndef I386_CPU_INTERNAL_H
#define I386_CPU_INTERNAL_H
+#include "qapi/qapi-types-machine.h"
+
typedef enum FeatureWordType {
CPUID_FEATURE_WORD,
MSR_FEATURE_WORD,
@@ -55,6 +57,8 @@ typedef struct FeatureWordInfo {
extern FeatureWordInfo feature_word_info[];
+X86CPURegister32 get_register_enum_32(FeatureWord w);
+
void x86_cpu_expand_features(X86CPU *cpu, Error **errp);
#ifndef CONFIG_USER_ONLY
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 219d7652524..ffa342171ba 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -1476,6 +1476,11 @@ static const char *get_register_name_32(unsigned int reg)
return x86_reg_info_32[reg].name;
}
+X86CPURegister32 get_register_enum_32(FeatureWord w)
+{
+ return x86_reg_info_32[feature_word_info[w].cpuid.reg].qapi_enum;
+}
+
/*
* Returns the set of feature flags that are supported and migratable by
* QEMU, for a given FeatureWord.
@@ -4548,7 +4553,7 @@ static void x86_cpu_get_feature_words(Object *obj,
Visitor *v,
qwi->cpuid_input_eax = wi->cpuid.eax;
qwi->has_cpuid_input_ecx = wi->cpuid.needs_ecx;
qwi->cpuid_input_ecx = wi->cpuid.ecx;
- qwi->cpuid_register = x86_reg_info_32[wi->cpuid.reg].qapi_enum;
+ qwi->cpuid_register = get_register_enum_32(w);
qwi->features = array[w];
/* List will be in reverse order, but order shouldn't matter */
--
2.26.2