kvm-unit-test: nSVM: Test SVME.EFER on VMRUN of nested guests

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@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index f1945ee..16b9dfd 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -1342,6 +1342,27 @@
 
 #define TEST(name) { #name, .v2 = name }
 
+/*
+ * v2 tests
+ */
+
+static void basic_guest_main(struct svm_test *test)
+{
+}
+
+static void svm_guest_state_test(void)
+{
+	u64 efer_saved = vmcb->save.efer;
+	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.efer = efer;
+	report (svm_vmrun() == SVM_EXIT_ERR, "EFER.SVME: %lx", efer);
+	vmcb->save.efer = efer_saved;
+}
+
 struct svm_test svm_tests[] = {
     { "null", default_supported, default_prepare,
       default_prepare_gif_clear, null_test,
@@ -1425,5 +1446,6 @@
     { "interrupt", default_supported, interrupt_prepare,
       default_prepare_gif_clear, interrupt_test,
       interrupt_finished, interrupt_check },
+    TEST(svm_guest_state_test),
     { NULL, NULL, NULL, NULL, NULL, NULL, NULL }
 };