Skip to content

Commit 7f2817e

Browse files
taosu-linuxsean-jc
authored andcommitted
KVM: VMX: Ignore MKTME KeyID bits when intercepting #PF for allow_smaller_maxphyaddr
Use the raw/true host.MAXPHYADDR when deciding whether or not KVM must intercept #PFs when allow_smaller_maxphyaddr is enabled, as any adjustments the kernel makes to boot_cpu_data.x86_phys_bits to account for MKTME KeyID bits do not apply to the guest physical address space. I.e. the KeyID are off-limits for host physical addresses, but are not reserved for GPAs as far as hardware is concerned. Signed-off-by: Tao Su <[email protected]> Link: https://lore.kernel.org/r/[email protected] [sean: massage changelog] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 449c081 commit 7f2817e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/x86/kvm/vmx/vmx.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "vmx_ops.h"
1616
#include "../cpuid.h"
1717
#include "run_flags.h"
18+
#include "../mmu.h"
1819

1920
#define MSR_TYPE_R 1
2021
#define MSR_TYPE_W 2
@@ -719,7 +720,8 @@ static inline bool vmx_need_pf_intercept(struct kvm_vcpu *vcpu)
719720
if (!enable_ept)
720721
return true;
721722

722-
return allow_smaller_maxphyaddr && cpuid_maxphyaddr(vcpu) < boot_cpu_data.x86_phys_bits;
723+
return allow_smaller_maxphyaddr &&
724+
cpuid_maxphyaddr(vcpu) < kvm_get_shadow_phys_bits();
723725
}
724726

725727
static inline bool is_unrestricted_guest(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)