Re: [PATCH] kvm-unit-tests: VMX: Fix some nested EPT related bugs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Il 09/09/2013 17:55, Arthur Chunqi Li ha scritto:
> This patch fix 3 bugs in VMX framework and EPT framework
> 1. Fix bug of setting default value of CPU_SECONDARY
> 2. Fix bug of reading MSR_IA32_VMX_PROCBASED_CTLS2 and
> MSR_IA32_VMX_EPT_VPID_CAP
> 3. For EPT violation and misconfiguration reduced vmexit, vmcs field
> "VM-exit instruction length" is not used and will return unexpected
> value when read.
> 
> Signed-off-by: Arthur Chunqi Li <yzt356@xxxxxxxxx>
> ---
>  x86/vmx.c       |   13 ++++++++++---
>  x86/vmx_tests.c |    2 --
>  2 files changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/x86/vmx.c b/x86/vmx.c
> index 87d1d55..9db4ef4 100644
> --- a/x86/vmx.c
> +++ b/x86/vmx.c
> @@ -304,7 +304,8 @@ static void init_vmcs_ctrl(void)
>  	/* Disable VMEXIT of IO instruction */
>  	vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu[0]);
>  	if (ctrl_cpu_rev[0].set & CPU_SECONDARY) {
> -		ctrl_cpu[1] |= ctrl_cpu_rev[1].set & ctrl_cpu_rev[1].clr;
> +		ctrl_cpu[1] = (ctrl_cpu[1] | ctrl_cpu_rev[1].set) &
> +			ctrl_cpu_rev[1].clr;
>  		vmcs_write(CPU_EXEC_CTRL1, ctrl_cpu[1]);
>  	}
>  	vmcs_write(CR3_TARGET_COUNT, 0);
> @@ -489,8 +490,14 @@ static void init_vmx(void)
>  			: MSR_IA32_VMX_ENTRY_CTLS);
>  	ctrl_cpu_rev[0].val = rdmsr(basic.ctrl ? MSR_IA32_VMX_TRUE_PROC
>  			: MSR_IA32_VMX_PROCBASED_CTLS);
> -	ctrl_cpu_rev[1].val = rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2);
> -	ept_vpid.val = rdmsr(MSR_IA32_VMX_EPT_VPID_CAP);
> +	if ((ctrl_cpu_rev[0].clr & CPU_SECONDARY) != 0)
> +		ctrl_cpu_rev[1].val = rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2);
> +	else
> +		ctrl_cpu_rev[1].val = 0;
> +	if ((ctrl_cpu_rev[1].clr & (CPU_EPT | CPU_VPID)) != 0)
> +		ept_vpid.val = rdmsr(MSR_IA32_VMX_EPT_VPID_CAP);
> +	else
> +		ept_vpid.val = 0;
>  
>  	write_cr0((read_cr0() & fix_cr0_clr) | fix_cr0_set);
>  	write_cr4((read_cr4() & fix_cr4_clr) | fix_cr4_set | X86_CR4_VMXE);
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index 6d972c0..e891a9f 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -1075,7 +1075,6 @@ static int ept_exit_handler()
>  			print_vmexit_info();
>  			return VMX_TEST_VMEXIT;
>  		}
> -		vmcs_write(GUEST_RIP, guest_rip + insn_len);
>  		return VMX_TEST_RESUME;
>  	case VMX_EPT_VIOLATION:
>  		switch(get_stage()) {
> @@ -1100,7 +1099,6 @@ static int ept_exit_handler()
>  			print_vmexit_info();
>  			return VMX_TEST_VMEXIT;
>  		}
> -		vmcs_write(GUEST_RIP, guest_rip + insn_len);
>  		return VMX_TEST_RESUME;
>  	default:
>  		printf("Unknown exit reason, %d\n", reason);
> 

Looks good, thanks!

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux