Re: [PATCH 04/11] kvm: x86: Suppress CR3_PCID_INVD bit only when PCIDs are enabled

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

 



On 04/05/2018 20:37, Junaid Shahid wrote:
> If the PCIDE bit is not set in CR4, then the MSb of CR3 is a reserved
> bit. If the guest tries to set it, that should cause a #GP fault. So
> mask out the bit only when the PCIDE bit is set.
> 
> Signed-off-by: Junaid Shahid <junaids@xxxxxxxxxx>
> ---
>  arch/x86/kvm/x86.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 847ce7f0a2c8..5a19d220a9c3 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -845,7 +845,10 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
>  	unsigned long old_cr3 = kvm_read_cr3(vcpu);
>  
>  #ifdef CONFIG_X86_64
> -	cr3 &= ~CR3_PCID_INVD;
> +	bool pcid_enabled = kvm_read_cr4_bits(vcpu, X86_CR4_PCIDE);
> +
> +	if (pcid_enabled)
> +		cr3 &= ~CR3_PCID_INVD;
>  #endif
>  
>  	if (cr3 == old_cr3 && !pdptrs_changed(vcpu)) {
> 

Queued, thanks.

Paolo



[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