Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1710692

Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

From Paolo Bonzini <pbonzini@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.
Date 2017-08-14 09:40 +0200
Message-ID <uei8F-1hl-3@gated-at.bofh.it> (permalink)
References <udF7k-1tj-11@gated-at.bofh.it> <udF7j-1tj-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 12/08/2017 15:35, Yu Zhang wrote:
> +			ctxt->ops->get_cpuid(ctxt, &eax, NULL, NULL, NULL);
> +			maxphyaddr = eax * 0xff;

This is "&", not "*".  You can also use rsvd_bits here.

> +			rsvd = (~((1UL << maxphyaddr) - 1)) &
> +				~CR3_PCID_INVD;
> +		}
>  
>  		if (new_val & rsvd)
>  			return emulate_gp(ctxt, 0);
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index e40a779..d9100c4 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -813,10 +813,10 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
>  		return 0;
>  	}
>  
> -	if (is_long_mode(vcpu)) {
> -		if (cr3 & CR3_L_MODE_RESERVED_BITS)
> -			return 1;
> -	} else if (is_pae(vcpu) && is_paging(vcpu) &&
> +	if (is_long_mode(vcpu) &&
> +	    (cr3 & rsvd_bits(cpuid_maxphyaddr(vcpu), 63)))
> +		return 1;

62 is a little better, since 63 is the PCID invalidate bit.

Paolo

> +	else if (is_pae(vcpu) && is_paging(vcpu) &&
>  		   !load_pdptrs(vcpu, vcpu->arch.walk_mmu, cr3))
>  		return 1;
>  

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width. Yu Zhang <yu.c.zhang@linux.intel.com> - 2017-08-12 16:00 +0200
  Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on  its physical address width. Paolo Bonzini <pbonzini@redhat.com> - 2017-08-14 09:40 +0200
    Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on  its physical address width. Yu Zhang <yu.c.zhang@linux.intel.com> - 2017-08-14 14:10 +0200
  Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on  its physical address width. Jim Mattson <jmattson@google.com> - 2017-08-14 18:20 +0200
    Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on  its physical address width. Paolo Bonzini <pbonzini@redhat.com> - 2017-08-14 18:50 +0200
      Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on  its physical address width. Yu Zhang <yu.c.zhang@linux.intel.com> - 2017-08-15 10:20 +0200

csiph-web