Skip to content

Commit 730319a

Browse files
ehabkostbonzini
authored andcommitted
i386: Mask SVM features if nested SVM is disabled
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 <[email protected]> Signed-off-by: Eduardo Habkost <[email protected]> Message-Id: <[email protected]> [Fix testcase. - Paolo] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent c8d7fd0 commit 730319a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

target/i386/cpu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,10 @@ static FeatureDep feature_dependencies[] = {
14041404
.from = { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_ENABLE_VMFUNC },
14051405
.to = { FEAT_VMX_VMFUNC, ~0ull },
14061406
},
1407+
{
1408+
.from = { FEAT_8000_0001_ECX, CPUID_EXT3_SVM },
1409+
.to = { FEAT_SVM, ~0ull },
1410+
},
14071411
};
14081412

14091413
typedef struct X86RegisterInfo32 {

tests/qtest/test-x86-cpuid-compat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ int main(int argc, char **argv)
256256
"-cpu 486,+invtsc", "xlevel", 0x80000007);
257257
/* CPUID[8000_000A].EDX: */
258258
add_cpuid_test("x86/cpuid/auto-xlevel/486/npt",
259-
"-cpu 486,+npt", "xlevel", 0x8000000A);
259+
"-cpu 486,+svm,+npt", "xlevel", 0x8000000A);
260260
/* CPUID[C000_0001].EDX: */
261261
add_cpuid_test("x86/cpuid/auto-xlevel2/phenom/xstore",
262262
"-cpu phenom,+xstore", "xlevel2", 0xC0000001);
@@ -348,7 +348,7 @@ int main(int argc, char **argv)
348348
"-machine pc-i440fx-2.4 -cpu SandyBridge,",
349349
"xlevel", 0x80000008);
350350
add_cpuid_test("x86/cpuid/xlevel-compat/pc-i440fx-2.4/npt-on",
351-
"-machine pc-i440fx-2.4 -cpu SandyBridge,+npt",
351+
"-machine pc-i440fx-2.4 -cpu SandyBridge,+svm,+npt",
352352
"xlevel", 0x80000008);
353353

354354
/* Test feature parsing */

0 commit comments

Comments
 (0)