Misc fixups/cleanups for nested tests
cover Misc fixups/cleanups for nested tests
A group of misc cleanups and fixups for SVM and VMX tests.
Disclaimer for patch 3: I have no idea why #UD was used to convey failure from the guest when report() is usable, so I might have missed something there.
Disclaimer for patch 4: I did not look too closely into why the flake is happening. It seemed like there was an adhoc approach to stabilize the test (shift duration by 24 bits), so I just made the necessary adjustment to make the test stable on Turin.
This series is based on a different SVM series to avoid conflicts:
https://lore.kernel.org/kvm/[email protected]/
Yosry Ahmed (4):
x86/vmx: Skip vmx_pf_exception_test_fep early if FEP is not available x86/svm: Print SVM test names before running tests x86/svm: Replace #UD on failure in LBRV tests with proper report()s x86/svm: Deflake svm_tsc_scale_test
x86/svm.c | 1 + x86/svm_tests.c | 19 ++++++++++--------- x86/vmx_tests.c | 5 ++++- 3 files changed, 15 insertions(+), 10 deletions(-)
Signature · 1 line
2.51.2.1026.g39e6a42477-goog
PATCH 1/4 x86/vmx: Skip vmx_pf_exception_test_fep early if FEP is not available
The check to skip the test is currently performed in the guest code. There a few TEST_ASSERTs that happen before the guest is run, which internally call report_passed(). The latter increases the number of passed tests.
Hence, when vmx_pf_exception_test_fep is run, report_summary() does not return a "skip" error code because the total number of tests is larger than the number of skipped tests.
Skip early if FEP is not available, before any assertions, such that report_summary() finds exactly 1 skipped test and returns the appropriate error code.
--- x86/vmx_tests.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
x86/vmx_tests.c +4 -1
@@ -10644,7 +10644,10 @@ static void vmx_pf_exception_test(void)static void vmx_pf_exception_forced_emulation_test (void ) { -__vmx_pf_exception_test (NULL ,NULL , vmx_pf_exception_forced_emulation_test_guest); +if (is_fep_available) +__vmx_pf_exception_test (NULL ,NULL , vmx_pf_exception_forced_emulation_test_guest); +else +report_skip ("Forced emulation prefix (FEP) not available\n" ); }static void invalidate_tlb_no_vpid (void *data)
Signature · 1 line
2.51.2.1026.g39e6a42477-goog
PATCH 2/4 x86/svm: Print SVM test names before running tests
In reply to Yosry AhmedWhen SVM tests are run, the log is a see of PASS/FAIL/SKIPs that are not clearly separated by test. Sometimes it's hard to attribute a failure to a specific test (e.g. if the same helper is reused by multiple tests).
Print the test name before running each test.
--- x86/svm.c | 1 + 1 file changed, 1 insertion(+)
x86/svm.c +1 -0
@@ -407,6 +407,7 @@ int run_svm_tests(int ac, char **av, struct svm_test *svm_tests)report_skip ("%s (not supported)" , svm_tests[i].name);continue ; } +printf ("SVM test: %s\n" , svm_tests[i].name);if (svm_tests[i].v2 ==NULL ) {if (svm_tests[i].on_vcpu) {if (cpu_count () <= svm_tests[i].on_vcpu)
Signature · 1 line
2.51.2.1026.g39e6a42477-goog
PATCH 3/4 x86/svm: Replace #UD on failure in LBRV tests with proper report()s
In reply to Yosry AhmedIn LBRV tests, failures in the guest trigger a #UD and does not convey useful debugging info (i.e. expected and actual values of MSRs). Replace them with proper report() calls.
Admittedly, it is unclear why the choice of #UD was made given that report() works fine in the guest.
--- x86/svm_tests.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
x86/svm_tests.c +9 -8
@@ -3017,16 +3017,17 @@ do { \TEST_EXPECT_EQ ((u64 )to_expected,amd_get_lbr_rip (MSR_IA32_LASTBRANCHTOIP )); \ } while (0) -/* -* FIXME: Do something other than generate an exception to communicate failure. -* Debugging without expected vs. actual is an absolute nightmare. - */#define GUEST_CHECK_LBR (from_expected, to_expected) \ do { \ - if ((u64)(from_expected) != amd_get_lbr_rip(MSR_IA32_LASTBRANCHFROMIP)) \ - asm volatile("ud2"); \ - if ((u64)(to_expected) != amd_get_lbr_rip(MSR_IA32_LASTBRANCHTOIP)) \ - asm volatile("ud2"); \ + u64 from_ip = amd_get_lbr_rip(MSR_IA32_LASTBRANCHFROMIP); \ + u64 to_ip = amd_get_lbr_rip(MSR_IA32_LASTBRANCHTOIP); \ + \ + report((u64)(from_expected) == from_ip, \ + "Expected MSR_IA32_LASTBRANCHFROMIP: 0x%lx, found: 0x%lx", \ + (u64)from_expected, from_ip); \ + report((u64)(to_expected) == to_ip, \ + "Expected MSR_IA32_LASTBRANCHTOIP: 0x%lx, found: 0x%lx", \ + (u64)to_expected, to_ip); \ } while (0)#define REPORT_GUEST_LBR_ERROR (vmcb) \
Signature · 1 line
2.51.2.1026.g39e6a42477-goog
PATCH 4/4 x86/svm: Deflake svm_tsc_scale_test
In reply to Yosry AhmedOn an AMT Turin (EPYC Zen 5), svm_tsc_scale_test flakes on the last test case with 0.0001 TSC scaling ratio, even with the 24-bit shift for stability. On failure, the actual value is 49 instead of the expected 50.
Use a higher scaling ratio, 0.001, which makes the test pass consistently.
--- x86/svm_tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
x86/svm_tests.c +1 -1
@@ -1002,7 +1002,7 @@ static void svm_tsc_scale_test(void) }svm_tsc_scale_run_testcase (50 ,255 ,rdrand ()); -svm_tsc_scale_run_testcase (50 ,0.0001 ,rdrand ()); +svm_tsc_scale_run_testcase (50 ,0.001 ,rdrand ()); }static void latency_prepare (struct svm_test *test)
Signature · 1 line
2.51.2.1026.g39e6a42477-goog