diff mbox

[kvm-unit-tests] vmx_tests: do not set unsupported PAT controls in the VMCS

Message ID 1411551780-15248-1-git-send-email-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Paolo Bonzini Sept. 24, 2014, 9:43 a.m. UTC
Otherwise, vmlaunch fails.  Also, skip PAT tests altogether if save/load
PAT is completely unsupported.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 x86/vmx_tests.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 2104fe9..184fafc 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -236,10 +236,19 @@  static int test_ctrl_pat_init()
 	u64 ctrl_exi;
 
 	msr_bmp_init();
+	if (!(ctrl_exit_rev.clr & EXI_SAVE_PAT) &&
+	    !(ctrl_exit_rev.clr & EXI_LOAD_PAT) &&
+	    !(ctrl_enter_rev.clr & ENT_LOAD_PAT)) {
+		printf("\tSave/load PAT is not supported\n");
+		return 1;
+	}
+
 	ctrl_ent = vmcs_read(ENT_CONTROLS);
 	ctrl_exi = vmcs_read(EXI_CONTROLS);
-	vmcs_write(ENT_CONTROLS, ctrl_ent | ENT_LOAD_PAT);
-	vmcs_write(EXI_CONTROLS, ctrl_exi | (EXI_SAVE_PAT | EXI_LOAD_PAT));
+	ctrl_ent |= ctrl_enter_rev.clr & ENT_LOAD_PAT;
+	ctrl_exi |= ctrl_exit_rev.clr & (EXI_SAVE_PAT | EXI_LOAD_PAT);
+	vmcs_write(ENT_CONTROLS, ctrl_ent);
+	vmcs_write(EXI_CONTROLS, ctrl_exi);
 	ia32_pat = rdmsr(MSR_IA32_CR_PAT);
 	vmcs_write(GUEST_PAT, 0x0);
 	vmcs_write(HOST_PAT, ia32_pat);