Skip to contentSkip to conversation

kvm-unit-test: nSVM: Test CR0[63:32] on VMRUN of nested guests

PATCH New Krish Sadhukhan 2 participants 3 messages Apr 20, 2020 – Apr 21, 2020 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm-unit-test: nSVM: Test CR0[63:32] on VMRUN of nested guests

[PATCH] kvm-unit-tests: nSVM: Test that CR0[63:32] are not set on VMRUN of nested

 x86/svm_tests.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Krish Sadhukhan (1):
nSVM: Test that CR0[63:32] are not set on VMRUN of nested guests

#1 lore raw

PATCH 1/1 kvm-unit-tests: nSVM: Test that CR0[63:32] are not set on VMRUN of nested guests

According to section "Canonicalization and Consistency Checks" in APM vol. 2, the following guest state is illegal:

	"CR0[63:32] are not zero."
---
 x86/svm_tests.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
x86/svm_tests.c +14 -0
index 8bdefc5..3bfa484 100644
@@ -1387,6 +1387,20 @@ static void svm_guest_state_test(void)
 	vmcb->save.cr0 = cr0;
 	report (svm_vmrun() == SVM_EXIT_ERR, "CR0: %lx", cr0);
 	vmcb->save.cr0 = cr0_saved;
+
+	/*
+	 * CR0[63:32] are not zero
+	 */
+	int i;
+
+	cr0 = cr0_saved;
+	for (i = 32; i < 63; i = i + 4) {
+		cr0 = cr0_saved | (1ull << i);
+		vmcb->save.cr0 = cr0;
+		report (svm_vmrun() == SVM_EXIT_ERR, "CR0[63:32]: %lx",
+		    cr0 >> 32);
+	}
+	vmcb->save.cr0 = cr0_saved;
 }
 
 struct svm_test svm_tests[] = {
Signature · 1 line
1.8.3.1
maintainer Applied
#2 lore raw

Re: [PATCH] kvm-unit-tests: nSVM: Test that CR0[63:32] are not set on VMRUN of nested guests

Quoted 26 lines · Krish Sadhukhan

According to section "Canonicalization and Consistency Checks" in APM vol. 2, the following guest state is illegal:

	"CR0[63:32] are not zero."
---
 x86/svm_tests.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
x86/svm_tests.c +7 -0
index 8bdefc5..3bfa484 100644
@@ -1387,6 +1387,20 @@ static void svm_guest_state_test(void)
 	vmcb->save.cr0 = cr0;
 	report (svm_vmrun() == SVM_EXIT_ERR, "CR0: %lx", cr0);
 	vmcb->save.cr0 = cr0_saved;
+
+	/*
+	 * CR0[63:32] are not zero
+	 */
+	int i;
+
+	cr0 = cr0_saved;

x86/svm_tests.c static void svm_guest_state_test(void) · line 1406

Quoted 10 lines
x86/svm_tests.c +7 -0
+	for (i = 32; i < 63; i = i + 4) {
+		cr0 = cr0_saved | (1ull << i);
+		vmcb->save.cr0 = cr0;
+		report (svm_vmrun() == SVM_EXIT_ERR, "CR0[63:32]: %lx",
+		    cr0 >> 32);
+	}
+	vmcb->save.cr0 = cr0_saved;
 }
 
 struct svm_test svm_tests[] = {

Applied, thanks.

Paolo