All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: ZongYao.Chen@linux.alibaba.com
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, Shuah Khan <shuah@kernel.org>,
	 "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Chao Peng <chao.p.peng@linux.intel.com>,
	 Xiaoyao Li <xiaoyao.li@intel.com>,
	Ackerley Tng <ackerleytng@google.com>,
	 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>,
	linux-kselftest@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] KVM: guest_memfd: Return -EEXIST for overlapping bindings
Date: Mon, 18 May 2026 11:32:21 -0700	[thread overview]
Message-ID: <agtbNc2uPA7esShy@google.com> (raw)
In-Reply-To: <20260518070943.2091287-2-ZongYao.Chen@linux.alibaba.com>

On Mon, May 18, 2026, ZongYao.Chen@linux.alibaba.com wrote:
> From: Zongyao Chen <ZongYao.Chen@linux.alibaba.com>
> 
> KVM_SET_USER_MEMORY_REGION2 rejects guest_memfd ranges that overlap an
> existing binding, but kvm_gmem_bind() currently reports the failure through
> its generic -EINVAL path.  That makes binding conflicts indistinguishable
> from malformed guest_memfd parameters.
> 
> Return -EEXIST when the target guest_memfd range is already bound, matching
> the errno used for overlapping GPA memslots and making the two types of
> range conflicts report the same class of error to userspace.

The other key piece of information is that we quite clearly intended to return
-EEXIST in this case, given the testcase, but simply failed on multiple fronts.

No need for a v2, I'll add a blurb when applying.

> Fixes: a7800aa80ea4 ("KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory")
> Signed-off-by: Zongyao Chen <ZongYao.Chen@linux.alibaba.com>
> ---
>  virt/kvm/guest_memfd.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> index 69c9d6d546b2..46727539d08a 100644
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
> @@ -675,6 +675,7 @@ int kvm_gmem_bind(struct kvm *kvm, struct kvm_memory_slot *slot,
>  
>  	if (!xa_empty(&f->bindings) &&
>  	    xa_find(&f->bindings, &start, end - 1, XA_PRESENT)) {
> +		r = -EEXIST;
>  		filemap_invalidate_unlock(inode->i_mapping);
>  		goto err;
>  	}
> -- 
> 2.47.3
> 

  reply	other threads:[~2026-05-18 18:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18  7:09 [PATCH 0/2] KVM: Fix guest_memfd binding overlap errno and selftest ZongYao.Chen
2026-05-18  7:09 ` [PATCH 1/2] KVM: guest_memfd: Return -EEXIST for overlapping bindings ZongYao.Chen
2026-05-18 18:32   ` Sean Christopherson [this message]
2026-05-18 20:11   ` Ackerley Tng
2026-05-18  7:09 ` [PATCH 2/2] KVM: selftests: Test guest_memfd binding overlap without GPA overlap ZongYao.Chen
2026-05-18 20:05   ` Ackerley Tng
2026-05-18 20:39     ` Sean Christopherson
2026-05-19 18:35       ` Ackerley Tng
2026-05-19 19:54         ` Sean Christopherson

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=agtbNc2uPA7esShy@google.com \
    --to=seanjc@google.com \
    --cc=ZongYao.Chen@linux.alibaba.com \
    --cc=ackerleytng@google.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    --cc=tianjia.zhang@linux.alibaba.com \
    --cc=xiaoyao.li@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.