According to the section "Canonicalization and Consistency Checks" in 15.5.1 in APM vol 2, setting EFER.SVME to zero is an illegal guest state and will cause the nested guest to VMEXIT to the guest with an exit code of VMEXIT_INVALID. Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx> --- x86/svm_tests.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/x86/svm_tests.c b/x86/svm_tests.c index 580bce6..8de4b8e 100644 --- a/x86/svm_tests.c +++ b/x86/svm_tests.c @@ -1197,6 +1197,28 @@ static bool pending_event_check_vmask(struct svm_test *test) #define TEST(name) { #name, .v2 = name } +/* + * v2 tests + */ + +static void basic_guest_main(struct svm_test *test) +{ +} + +static void svm_guest_state_test(void) +{ + size_t offset = offsetof(struct vmcb_save_area, efer); + u64 efer_saved = vmcb_save_read64(offset); + u64 efer = efer_saved; + + test_set_guest(basic_guest_main); + report (svm_vmrun() == SVM_EXIT_VMMCALL, "EFER.SVME: %lx", efer); + efer &= ~EFER_SVME; + vmcb_save_write64(offset, efer); + report (svm_vmrun() == SVM_EXIT_ERR, "EFER.SVME: %lx", efer); + vmcb_save_write64(offset, efer_saved); +} + struct svm_test svm_tests[] = { { "null", default_supported, default_prepare, default_prepare_gif_clear, null_test, @@ -1277,5 +1299,6 @@ struct svm_test svm_tests[] = { pending_event_prepare_gif_clear_vmask, pending_event_test_vmask, pending_event_finished_vmask, pending_event_check_vmask }, + TEST(svm_guest_state_test), { NULL, NULL, NULL, NULL, NULL, NULL, NULL } }; -- 1.8.3.1