diff options
author | Krish Sadhukhan <krish.sadhukhan@oracle.com> | 2020-04-09 16:50:35 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-04-16 09:59:25 -0400 |
commit | e8d7a8f62087526da656849d693a850afc8a0d6e (patch) | |
tree | 804097303e097840ab223e2f80d54e35e4c36d94 | |
parent | 33a6576c6e1bfd98fd35402c9f64dfd7537dd2ff (diff) | |
download | kvm-unit-tests-e8d7a8f62087526da656849d693a850afc8a0d6e.tar.gz |
kvm-unit-tests: nSVM: Test CR0.CD and CR0.NW combination on VMRUN of nested guests
According to section "Canonicalization and Consistency Checks" in APM vol. 2,
the following guest state combination is illegal:
"CR0.CD is zero and CR0.NW is set"
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Message-Id: <20200409205035.16830-4-krish.sadhukhan@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | x86/svm_tests.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/x86/svm_tests.c b/x86/svm_tests.c index b4ba999..3f18d37 100644 --- a/x86/svm_tests.c +++ b/x86/svm_tests.c @@ -1598,15 +1598,41 @@ static void basic_guest_main(struct svm_test *test) static void svm_guest_state_test(void) { + test_set_guest(basic_guest_main); + + /* + * Un-setting EFER.SVME is illegal + */ 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; + + /* + * Un-setting CR0.CD and setting CR0.NW is illegal combination + */ + u64 cr0_saved = vmcb->save.cr0; + u64 cr0 = cr0_saved; + + cr0 |= X86_CR0_CD; + cr0 &= ~X86_CR0_NW; + vmcb->save.cr0 = cr0; + report (svm_vmrun() == SVM_EXIT_VMMCALL, "CR0: %lx", cr0); + cr0 |= X86_CR0_NW; + vmcb->save.cr0 = cr0; + report (svm_vmrun() == SVM_EXIT_VMMCALL, "CR0: %lx", cr0); + cr0 &= ~X86_CR0_NW; + cr0 &= ~X86_CR0_CD; + vmcb->save.cr0 = cr0; + report (svm_vmrun() == SVM_EXIT_VMMCALL, "CR0: %lx", cr0); + cr0 |= X86_CR0_NW; + vmcb->save.cr0 = cr0; + report (svm_vmrun() == SVM_EXIT_ERR, "CR0: %lx", cr0); + vmcb->save.cr0 = cr0_saved; } struct svm_test svm_tests[] = { |