Skip to content

Commit 8046d29

Browse files
committed
KVM: x86/mmu: Reject direct bits in gpa passed to KVM_PRE_FAULT_MEMORY
Only let userspace pass the same addresses that were used in KVM_SET_USER_MEMORY_REGION (or KVM_SET_USER_MEMORY_REGION2); gpas in the the upper half of the address space are an implementation detail of TDX and KVM. Extracted from a patch by Sean Christopherson <[email protected]>. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent aa2024c commit 8046d29

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4903,6 +4903,9 @@ long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu,
49034903
if (!vcpu->kvm->arch.pre_fault_allowed)
49044904
return -EOPNOTSUPP;
49054905

4906+
if (kvm_is_gfn_alias(vcpu->kvm, gpa_to_gfn(range->gpa)))
4907+
return -EINVAL;
4908+
49064909
/*
49074910
* reload is efficient when called repeatedly, so we can do it on
49084911
* every iteration.

0 commit comments

Comments
 (0)