On 4/14/2022 1:58 AM, Sean Christopherson wrote: > On Thu, Mar 24, 2022, Manali Shukla wrote: >> 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; > > Please use tabs, not spaces. Looks like this file is an unholy mess of tabs and > spaces. And since we're riping this file apart, let's take the opportunity to > clean it up. How about after moving code to svm_npt.c, go through and replace > all spaces with tabs and fixup indentation as appropriate in this file? Hey Sean, Thank you for reviewing the code. I will work on the comments and fixing up the indentation. -Manali > >> + >> + __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 >>