All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yan Zhao <yan.y.zhao@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	 xiaoyao.li@intel.com
Subject: Re: [PATCH] KVM: x86/mmu: Reject direct bits in gpa passed to KVM_PRE_FAULT_MEMORY
Date: Fri, 13 Jun 2025 13:16:38 -0700	[thread overview]
Message-ID: <aEyHJuxo4aPUlmgV@google.com> (raw)
In-Reply-To: <aEuURZ1sBmSYtX9P@yzhao56-desk.sh.intel.com>

On Fri, Jun 13, 2025, Yan Zhao wrote:
> On Thu, Jun 12, 2025 at 12:49:43AM -0400, Paolo Bonzini wrote:
> > 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>
> > ---
> >  arch/x86/kvm/mmu/mmu.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> > index a4040578b537..4e06e2e89a8f 100644
> > --- a/arch/x86/kvm/mmu/mmu.c
> > +++ b/arch/x86/kvm/mmu/mmu.c
> > @@ -4903,6 +4903,9 @@ long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu,
> >  	if (!vcpu->kvm->arch.pre_fault_allowed)
> >  		return -EOPNOTSUPP;
> >  
> > +	if (kvm_is_gfn_alias(vcpu->kvm, gpa_to_gfn(range->gpa)))
> > +		return -EINVAL;
> > +
> Do we need the same check in kvm_vm_ioctl_set_mem_attributes()?

Yeah, we probably should disallow aliases there.  It should be benign?  Because
memslots disallow aliases, and so the aliased gfn entries in the xarray will never
actually be consumed.

  reply	other threads:[~2025-06-13 20:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-12  4:49 [PATCH] KVM: x86/mmu: Reject direct bits in gpa passed to KVM_PRE_FAULT_MEMORY Paolo Bonzini
2025-06-12  5:29 ` Xiaoyao Li
2025-06-12  5:34   ` Paolo Bonzini
2025-06-12  5:41     ` Xiaoyao Li
2025-06-13  3:00 ` Yan Zhao
2025-06-13 20:16   ` Sean Christopherson [this message]
2025-06-16  2:04     ` Yan Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aEyHJuxo4aPUlmgV@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=xiaoyao.li@intel.com \
    --cc=yan.y.zhao@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.