[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/20] target-i386: Don't try to enable PT State xsav
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PULL 09/20] target-i386: Don't try to enable PT State xsave component |
Date: |
Tue, 27 Sep 2016 17:12:19 -0300 |
The code that calculates the set of supported XSAVE components on
CPUID looks at ext_save_areas to find out which components should
be enabled. However, if there are zeroed entries in the
ext_save_areas array, the
((env->features[esa->feature] & esa->bits) == esa->bits)
check will always succeed and QEMU will unconditionally try to
enable the component.
Luckily this never caused any problems because the only missing
entry in ext_save_areas is the PT State component (bit 8), and
KVM currently doesn't support it (so it was cleared on ena_mask).
But the code was still incorrect and would break if KVM starts
returning CPUID[EAX=0xD,ECX=0].EAX[bit 8] as supported on
GET_SUPPORTED_CPUID.
Fix the problem by changing the code to not enable a XSAVE
component if ExtSaveArea::bits is zero.
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
target-i386/cpu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index cc07fdb..25ab4f8 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2514,7 +2514,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
uint32_t count,
*ecx = 0x240;
for (i = 2; i < ARRAY_SIZE(x86_ext_save_areas); i++) {
const ExtSaveArea *esa = &x86_ext_save_areas[i];
- if ((env->features[esa->feature] & esa->bits) == esa->bits
+ if ((env->features[esa->feature] & esa->bits)
&& ((ena_mask >> i) & 1) != 0) {
if (i < 32) {
*eax |= 1u << i;
@@ -2530,7 +2530,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
uint32_t count,
*eax = env->features[FEAT_XSAVE];
} else if (count < ARRAY_SIZE(x86_ext_save_areas)) {
const ExtSaveArea *esa = &x86_ext_save_areas[count];
- if ((env->features[esa->feature] & esa->bits) == esa->bits
+ if ((env->features[esa->feature] & esa->bits)
&& ((ena_mask >> count) & 1) != 0) {
*eax = esa->size;
*ebx = esa->offset;
@@ -2766,7 +2766,7 @@ static void x86_cpu_reset(CPUState *s)
}
for (i = 2; i < ARRAY_SIZE(x86_ext_save_areas); i++) {
const ExtSaveArea *esa = &x86_ext_save_areas[i];
- if ((env->features[esa->feature] & esa->bits) == esa->bits) {
+ if (env->features[esa->feature] & esa->bits) {
xcr0 |= 1ull << i;
}
}
--
2.7.4
- [Qemu-devel] [PULL 02/20] target-i386: Add a marker to end of the region zeroed on reset, (continued)
- [Qemu-devel] [PULL 02/20] target-i386: Add a marker to end of the region zeroed on reset, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 01/20] target-i386: Remove unused X86CPUDefinition::xlevel2 field, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 05/20] target-i386: Automatically set level/xlevel/xlevel2 when needed, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 03/20] tests: Add test code for CPUID level/xlevel handling, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 04/20] tests: Test CPUID level handling for old machines, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 06/20] target-i386: Enable CPUID[0x8000000A] if SVM is enabled, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 07/20] linux-user: remove #define smp_{cores, threads}, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 11/20] target-i386: xsave: Simplify CPUID[0xD, 0].{EAX, EDX} calculation, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 08/20] target-i386: Move feature name arrays inside FeatureWordInfo, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 10/20] target-i386: xsave: Calculate enabled components only once, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 09/20] target-i386: Don't try to enable PT State xsave component,
Eduardo Habkost <=
- [Qemu-devel] [PULL 13/20] target-i386: xsave: Calculate set of xsave components on realize, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 14/20] target-i386: Move xsave component mask to features array, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 12/20] target-i386: xsave: Helper function to calculate xsave area size, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 16/20] target-i386: Remove has_msr_hv_apic global variable, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 17/20] target-i386: Remove has_msr_hv_tsc global variable, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 18/20] target-i386: Clear KVM CPUID features if KVM is disabled, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 15/20] target-i386: Remove has_msr_mtrr global variable, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 19/20] target-i386: Remove has_msr_* global vars for KVM features, Eduardo Habkost, 2016/09/27
- [Qemu-devel] [PULL 20/20] sysbus: Remove ignored return value of FindSysbusDeviceFunc, Eduardo Habkost, 2016/09/27
- Re: [Qemu-devel] [PULL 00/20] x86 and machine queue, 2016-09-27, Peter Maydell, 2016/09/27