@@ -77,11 +77,18 @@ static void setup_npt(void)
__setup_mmu_range(pml4e, 0, size, X86_MMU_MAP_USER);
}
-void setup_svm(void)
+bool setup_svm(void)
{
- void *hsave = alloc_page();
+ void *hsave;
int i;
+ if (!npt_supported()) {
+ printf("NPT not detected - skipping SVM initialization\n");
+ return false;
+ }
+
+ hsave = alloc_page();
+
wrmsr(MSR_VM_HSAVE_PA, virt_to_phys(hsave));
wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_SVME);
@@ -89,14 +96,10 @@ void setup_svm(void)
msr_bitmap = (void *) ALIGN((ulong)msr_bitmap_area, PAGE_SIZE);
- if (!npt_supported())
- return;
for (i = 1; i < cpu_count(); i++)
on_cpu(i, (void *)set_additional_vcpu_msr, (void *)rdmsr(MSR_EFER));
- printf("NPT detected - running all tests with NPT enabled\n");
-
/*
* Nested paging supported - Build a nested page table
* Build the page-table bottom-up and map everything with 4k
@@ -104,4 +107,5 @@ void setup_svm(void)
*/
setup_npt();
+ return true;
}
@@ -49,7 +49,7 @@ static inline void clgi(void)
asm volatile ("clgi");
}
-void setup_svm(void);
+bool setup_svm(void);
u64 *npt_get_pte(u64 address);
u64 *npt_get_pde(u64 address);
@@ -264,7 +264,8 @@ int run_svm_tests(int ac, char **av, struct svm_test *svm_tests)
return report_summary();
}
- setup_svm();
+ if (!setup_svm())
+ return 0;
vmcb = alloc_page();
Fail SVM setup when NPT is not supported Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> --- lib/x86/svm_lib.c | 16 ++++++++++------ lib/x86/svm_lib.h | 2 +- x86/svm.c | 3 ++- 3 files changed, 13 insertions(+), 8 deletions(-)