Re: [PATCH 2/2] KVM: x86: remove duplicate cr0 set in vmx_vcpu_reset()

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

 



On Sat, 2018-09-22 at 09:56 +0800, kvm-owner@xxxxxxxxxxxxxxx wrote:
> vmx->vcpu.arch.cr0 will be set in vmx_set_cr0().
> 
> This patch removes duplicate cr0 set in vmx_vcpu_reset().
> 
> Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx>
> ---
>  arch/x86/kvm/vmx.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 1519f030fd73..b1e1d63a4970 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -6734,7 +6734,6 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
>  		vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid);
>  
>  	cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET;
> -	vmx->vcpu.arch.cr0 = cr0;

Initializing arch.cr0 prior to vmx_set_cr0() is necessary because it
might be queried by vmx_set_cr0(), e.g. via is_paging().  A stale cr0
could trigger side effects in vmx_set_cr0() related to toggling cr0
bits, which we don't want.

>  	vmx_set_cr0(vcpu, cr0); /* enter rmode */
>  	vmx_set_cr4(vcpu, 0);
>  	vmx_set_efer(vcpu, 0);



[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