Re: [PATCH v2 10/17] kvm: x86: Map guest PCIDs to host PCIDs

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

 



On Tue, Jun 12, 2018 at 03:52:37PM -0700, Junaid Shahid wrote:
> When using shadow paging mode, map guest PCIDs 1:1 to host PCIDs instead
> of mapping them all to PCID 0.

Nit - what about changing the wording to something like:
  
  When using shadow paging mode, propagate the guest's PCID value to
  the shadow CR3 in the host instead of always using PCID 0.

My initial impression of the commit message is that the intent is to
actively track and map the guest's PCID values to PCIDs that are being
used by the host kernel.

> 
> Signed-off-by: Junaid Shahid <junaids@xxxxxxxxxx>
> ---
>  arch/x86/kvm/mmu.h | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
> index 9950c04e1239..398b8565badf 100644
> --- a/arch/x86/kvm/mmu.h
> +++ b/arch/x86/kvm/mmu.h
> @@ -97,10 +97,25 @@ static inline int kvm_mmu_reload(struct kvm_vcpu *vcpu)
>  	return kvm_mmu_load(vcpu);
>  }
>  
> +static inline unsigned long kvm_get_pcid(struct kvm_vcpu *vcpu, gpa_t cr3)
> +{
> +	BUILD_BUG_ON((X86_CR3_PCID_MASK & PAGE_MASK) != 0);
> +
> +	return kvm_read_cr4_bits(vcpu, X86_CR4_PCIDE)
> +	       ? cr3 & X86_CR3_PCID_MASK
> +	       : 0;
> +}
> +
> +static inline unsigned long kvm_get_active_pcid(struct kvm_vcpu *vcpu)
> +{
> +	return kvm_get_pcid(vcpu, kvm_read_cr3(vcpu));
> +}
> +
>  static inline void kvm_mmu_load_cr3(struct kvm_vcpu *vcpu)
>  {
>  	if (VALID_PAGE(vcpu->arch.mmu.root_hpa))
> -		vcpu->arch.mmu.set_cr3(vcpu, vcpu->arch.mmu.root_hpa);
> +		vcpu->arch.mmu.set_cr3(vcpu, vcpu->arch.mmu.root_hpa |
> +					     kvm_get_active_pcid(vcpu));
>  }
>  
>  /*
> -- 
> 2.18.0.rc1.242.g61856ae69a-goog
> 



[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