Re: [PATCH] KVM: x86: Fix the condition of #PF interception caused by MKTME

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

 



On Tue, Mar 19, 2024, Tao Su wrote:
> Intel MKTME repurposes several high bits of physical address as 'keyID',
> so boot_cpu_data.x86_phys_bits doesn't hold physical address bits reported
> by CPUID anymore.
> 
> If guest.MAXPHYADDR < host.MAXPHYADDR, the bit field of ‘keyID’ belongs
> to reserved bits in guest’s view, so intercepting #PF to fix error code
> is necessary, just replace boot_cpu_data.x86_phys_bits with
> kvm_get_shadow_phys_bits() to fix.
> 
> Signed-off-by: Tao Su <tao1.su@xxxxxxxxxxxxxxx>
> ---
>  arch/x86/kvm/vmx/vmx.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h
> index 65786dbe7d60..79b1757df74a 100644
> --- a/arch/x86/kvm/vmx/vmx.h
> +++ b/arch/x86/kvm/vmx/vmx.h
> @@ -15,6 +15,7 @@
>  #include "vmx_ops.h"
>  #include "../cpuid.h"
>  #include "run_flags.h"
> +#include "../mmu.h"
>  
>  #define MSR_TYPE_R	1
>  #define MSR_TYPE_W	2
> @@ -719,7 +720,8 @@ static inline bool vmx_need_pf_intercept(struct kvm_vcpu *vcpu)
>  	if (!enable_ept)
>  		return true;
>  
> -	return allow_smaller_maxphyaddr && cpuid_maxphyaddr(vcpu) < boot_cpu_data.x86_phys_bits;
> +	return allow_smaller_maxphyaddr &&
> +		cpuid_maxphyaddr(vcpu) < kvm_get_shadow_phys_bits();

For posterity, because I had a brief moment where I thought we done messed up:

No change is needed in the reporting of MAXPHYADDR in KVM_GET_SUPPORTED_CPUID,
as reporting boot_cpu_data.x86_phys_bits as MAXPHYADDR when TDP is disabled is ok
because KVM always intercepts #PF when TDP is disabled, and KVM already reports
the full/raw MAXPHYADDR when TDP is enabled.





[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