Skip to content

Commit a870980

Browse files
author
Maxim Levitsky
committed
KVM: x86/mmu: Reject direct bits in gpa passed to KVM_PRE_FAULT_MEMORY
JIRA: https://issues.redhat.com/browse/RHEL-47242 commit 8046d29 Author: Paolo Bonzini <pbonzini@redhat.com> Date: Thu Jun 12 00:47:44 2025 -0400 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 <seanjc@google.com>. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
1 parent b362c9c commit a870980

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
@@ -4902,6 +4902,9 @@ long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu,
49024902
if (!vcpu->kvm->arch.pre_fault_allowed)
49034903
return -EOPNOTSUPP;
49044904

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

0 commit comments

Comments
 (0)