nSVM tests are "incompatible" with usermode due to __setup_vm() call in main function. If __setup_vm() is replaced with setup_vm() in main function, KUT will build the test with PT_USER_MASK set on all PTEs. nNPT tests will be moved to their own file so that the tests don't need to fiddle with page tables midway through. The quick and dirty approach would be to turn the current main() into a small helper, minus its call to __setup_vm() and call the helper function run_svm_tests() from main() function. No functional change intended. Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx> Signed-off-by: Manali Shukla <manali.shukla@xxxxxxx> --- x86/svm.c | 14 +++++++++----- x86/svm.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/x86/svm.c b/x86/svm.c index 3f94b2a..e93e780 100644 --- a/x86/svm.c +++ b/x86/svm.c @@ -406,17 +406,13 @@ test_wanted(const char *name, char *filters[], int filter_count) } } -int main(int ac, char **av) +int run_svm_tests(int ac, char **av) { - /* Omit PT_USER_MASK to allow tested host.CR4.SMEP=1. */ - pteval_t opt_mask = 0; int i = 0; ac--; av++; - __setup_vm(&opt_mask); - if (!this_cpu_has(X86_FEATURE_SVM)) { printf("SVM not availble\n"); return report_summary(); @@ -453,3 +449,11 @@ int main(int ac, char **av) return report_summary(); } + +int main(int ac, char **av) +{ + pteval_t opt_mask = 0; + + __setup_vm(&opt_mask); + return run_svm_tests(ac, av); +} diff --git a/x86/svm.h b/x86/svm.h index f74b13a..9ab3aa5 100644 --- a/x86/svm.h +++ b/x86/svm.h @@ -398,6 +398,7 @@ struct regs { typedef void (*test_guest_func)(struct svm_test *); +int run_svm_tests(int ac, char **av); u64 *npt_get_pte(u64 address); u64 *npt_get_pde(u64 address); u64 *npt_get_pdpe(void); -- 2.30.2