public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Fix the condition of #PF interception caused by MKTME
@ 2024-03-19  3:11 Tao Su
  2024-04-09  2:01 ` Sean Christopherson
  2024-04-09 19:05 ` Sean Christopherson
  0 siblings, 2 replies; 5+ messages in thread
From: Tao Su @ 2024-03-19  3:11 UTC (permalink / raw)
  To: kvm; +Cc: seanjc, pbonzini, chao.gao, xiaoyao.li, tao1.su

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@linux.intel.com>
---
 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();
 }
 
 static inline bool is_unrestricted_guest(struct kvm_vcpu *vcpu)

base-commit: b3603fcb79b1036acae10602bffc4855a4b9af80
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-10  1:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-19  3:11 [PATCH] KVM: x86: Fix the condition of #PF interception caused by MKTME Tao Su
2024-04-09  2:01 ` Sean Christopherson
2024-04-09  3:54   ` Xiaoyao Li
2024-04-09 19:05 ` Sean Christopherson
2024-04-10  1:20   ` Tao Su

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox