[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 31/31] i386: Mask SVM features if nested SVM is disabled
From: |
Paolo Bonzini |
Subject: |
[PULL 31/31] i386: Mask SVM features if nested SVM is disabled |
Date: |
Wed, 24 Jun 2020 06:50:48 -0400 |
From: Eduardo Habkost <ehabkost@redhat.com>
QEMU incorrectly validates FEAT_SVM feature flags against
GET_SUPPORTED_CPUID even if SVM features are being masked out by
cpu_x86_cpuid(). This can make QEMU print warnings on most AMD
CPU models, even when SVM nesting is disabled (which is the
default).
This bug was never detected before because of a Linux KVM bug:
until Linux v5.6, KVM was not filtering out SVM features in
GET_SUPPORTED_CPUID when nested was disabled. This KVM bug was
fixed in Linux v5.7-rc1, on Linux commit a50718cc3f43 ("KVM:
nSVM: Expose SVM features to L1 iff nested is enabled").
Fix the problem by adding a CPUID_EXT3_SVM dependency to all
FEAT_SVM feature flags in the feature_dependencies table.
Reported-by: Yanan Fu <yfu@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20200623230116.277409-1-ehabkost@redhat.com>
[Fix testcase. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/cpu.c | 4 ++++
tests/qtest/test-x86-cpuid-compat.c | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 06dc013d88..36cbd3d027 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -1404,6 +1404,10 @@ static FeatureDep feature_dependencies[] = {
.from = { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_ENABLE_VMFUNC },
.to = { FEAT_VMX_VMFUNC, ~0ull },
},
+ {
+ .from = { FEAT_8000_0001_ECX, CPUID_EXT3_SVM },
+ .to = { FEAT_SVM, ~0ull },
+ },
};
typedef struct X86RegisterInfo32 {
diff --git a/tests/qtest/test-x86-cpuid-compat.c
b/tests/qtest/test-x86-cpuid-compat.c
index 772287bdb4..7ca1883a29 100644
--- a/tests/qtest/test-x86-cpuid-compat.c
+++ b/tests/qtest/test-x86-cpuid-compat.c
@@ -256,7 +256,7 @@ int main(int argc, char **argv)
"-cpu 486,+invtsc", "xlevel", 0x80000007);
/* CPUID[8000_000A].EDX: */
add_cpuid_test("x86/cpuid/auto-xlevel/486/npt",
- "-cpu 486,+npt", "xlevel", 0x8000000A);
+ "-cpu 486,+svm,+npt", "xlevel", 0x8000000A);
/* CPUID[C000_0001].EDX: */
add_cpuid_test("x86/cpuid/auto-xlevel2/phenom/xstore",
"-cpu phenom,+xstore", "xlevel2", 0xC0000001);
@@ -348,7 +348,7 @@ int main(int argc, char **argv)
"-machine pc-i440fx-2.4 -cpu SandyBridge,",
"xlevel", 0x80000008);
add_cpuid_test("x86/cpuid/xlevel-compat/pc-i440fx-2.4/npt-on",
- "-machine pc-i440fx-2.4 -cpu SandyBridge,+npt",
+ "-machine pc-i440fx-2.4 -cpu SandyBridge,+svm,+npt",
"xlevel", 0x80000008);
/* Test feature parsing */
--
2.26.2
- [PULL 27/31] kvm: i386: allow TSC to differ by NTP correction bounds without TSC scaling, (continued)
- [PULL 27/31] kvm: i386: allow TSC to differ by NTP correction bounds without TSC scaling, Paolo Bonzini, 2020/06/24
- [PULL 21/31] target/i386: reimplement fyl2xp1 using floatx80 operations, Paolo Bonzini, 2020/06/24
- [PULL 25/31] osdep: Make MIN/MAX evaluate arguments only once, Paolo Bonzini, 2020/06/24
- [PULL 22/31] target/i386: reimplement fyl2x using floatx80 operations, Paolo Bonzini, 2020/06/24
- [PULL 30/31] ibex_uart: fix XOR-as-pow, Paolo Bonzini, 2020/06/24
- [PULL 28/31] hyperv: vmbus: Remove the 2nd IRQ, Paolo Bonzini, 2020/06/24
- [PULL 29/31] vmport: move compat properties to hw_compat_5_0, Paolo Bonzini, 2020/06/24
- [PULL 31/31] i386: Mask SVM features if nested SVM is disabled,
Paolo Bonzini <=
- [PULL 26/31] numa: forbid '-numa node, mem' for 5.1 and newer machine types, Paolo Bonzini, 2020/06/24
- [PULL 07/31] replay: synchronize on every virtual timer callback, Paolo Bonzini, 2020/06/24
- Re: [PULL 00/31] Misc patches for 2020-06-24, no-reply, 2020/06/24
- Re: [PULL 00/31] Misc patches for 2020-06-24, Peter Maydell, 2020/06/25