[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/7] target/i386: x86_cpu_expand_feature() helper
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH 2/7] target/i386: x86_cpu_expand_feature() helper |
Date: |
Fri, 6 Oct 2017 18:52:39 -0300 |
x86_cpu_expand_features() needs to ensure it won't touch
user-configured features when changing cpu->features. Make a
helper for that, and use it when handling cpu->max_features.
Signed-off-by: Eduardo Habkost <address@hidden>
---
target/i386/cpu.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 98732cd65f..90c969363e 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -3486,6 +3486,25 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)
* any CPUID data based on host capabilities.
*/
+/**
+ * x86_cpu_expand_feature:
+ *
+ * Change cpu->features, being careful to not override features explicitly
+ * configured bv the user.
+ *
+ * @w: the feature word to be changed
+ * @mask: the bits to be changed in cpu->features[w]
+ * @value: the new value for the bits in (cpu->features[w] & @mask)
+ */
+static void x86_cpu_expand_feature(X86CPU *cpu, FeatureWord w,
+ uint32_t mask, uint32_t value)
+{
+ assert((value & mask) == value);
+ mask &= ~cpu->env.user_features[w];
+ cpu->env.features[w] &= ~mask;
+ cpu->env.features[w] |= value & mask;
+}
+
/* Expand CPU configuration data, based on configured features
* and host/accelerator capabilities when appropriate.
*/
@@ -3503,12 +3522,8 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error
**errp)
*/
if (cpu->max_features) {
for (w = 0; w < FEATURE_WORDS; w++) {
- /* Override only features that weren't set explicitly
- * by the user.
- */
- env->features[w] |=
- x86_cpu_get_supported_feature_word(w, cpu->migratable) &
- ~env->user_features[w];
+ uint32_t f = x86_cpu_get_supported_feature_word(w,
cpu->migratable);
+ x86_cpu_expand_feature(cpu, w, ~0, f);
}
}
--
2.13.6
- [Qemu-devel] [PATCH 0/7] x86: Rework KVM-defaults compat code, enable kvm_pv_unhalt by default, Eduardo Habkost, 2017/10/06
- [Qemu-devel] [PATCH 1/7] qemu-doc: Document minimum kernel version for KVM in x86_64, Eduardo Habkost, 2017/10/06
- [Qemu-devel] [PATCH 2/7] target/i386: x86_cpu_expand_feature() helper,
Eduardo Habkost <=
- [Qemu-devel] [PATCH 3/7] target/i386: Use global variables to control KVM defaults, Eduardo Habkost, 2017/10/06
- [Qemu-devel] [PATCH 4/7] kvm: Define KVM_FEAT_* even if CONFIG_KVM is not defined, Eduardo Habkost, 2017/10/06
- [Qemu-devel] [PATCH 5/7] target/i386: Handle kvm_auto_* compat in x86_cpu_expand_features(), Eduardo Habkost, 2017/10/06
- [Qemu-devel] [PATCH 6/7] pc: Use compat_props to control KVM defaults compatibility, Eduardo Habkost, 2017/10/06
- [Qemu-devel] [PATCH 7/7] target/i386: Enable kvm_pv_unhalt by default, Eduardo Habkost, 2017/10/06
- Re: [Qemu-devel] [PATCH 0/7] x86: Rework KVM-defaults compat code, enable kvm_pv_unhalt by default, Paolo Bonzini, 2017/10/09