From: Kishen Maloor <kishen.maloor@intel.com>
To: Alexandru Elisei <alexandru.elisei@arm.com>,
Sean Christopherson <seanjc@google.com>
Cc: <pbonzini@redhat.com>, <kvm@vger.kernel.org>,
<david.hildenbrand@arm.com>, <maz@kernel.org>,
<oupton@kernel.org>, <joey.gouly@arm.com>, <seiden@linux.ibm.com>,
<suzuki.poulose@arm.com>, <yuzenghui@huawei.com>,
<linux-arm-kernel@lists.infradead.org>, <kvmarm@lists.linux.dev>,
<fuad.tabba@linux.dev>, <mark.rutland@arm.com>
Subject: Re: [RFC PATCH 2/3] KVM: Implement dirty page logging for guest_memfd-only memslots
Date: Mon, 13 Jul 2026 22:39:01 -0700 [thread overview]
Message-ID: <7295903c-14f9-4427-9c83-039e70e64cd3@intel.com> (raw)
In-Reply-To: <ak0zdNr1LvuF7gvm@raptor>
On 7/7/26 10:12 AM, Alexandru Elisei wrote:
> Hi Sean,
>
> On Mon, Jul 06, 2026 at 06:29:11PM -0700, Sean Christopherson wrote:
>> On Thu, Jul 02, 2026, Alexandru Elisei wrote:
>>> The entire memory represented by guest_memfd-only memslot is shared and
>>> accessible by userspace.
>>
>> ...
>>
>>> +8.48 KVM_CAP_GUEST_MEMFD_MMAP_LOG_DIRTY_PAGES
>>> +---------------------------------------------
>>> +
>>> +:Architectures: all
>>> +
>>> +The presence of this capability indicates that memslots backed by a guest_memfd
>>> +file descriptor created with the GUEST_MEMFD_FLAG_MMAP flag can have dirty
>>> +page logging enabled.
>>
>> What does mmap() have to do with anything? Supporting mmap() doesn't guarantee
>> the memory is shared, and I can't think of any dependency on memory actually
>> being mapped into userspace.
>
> My bad, it should have been GUEST_MEMFD_FLAG_MMAP +
> GUEST_MEMFD_FLAG_INIT_SHARED. I'm not sure what you mean by "dependency on
> memory actually being mapped into userspace".
>
> From my point of view, it only makes sense to enable dirty page logging if
> the contents of the memory is accessible to userspace, hence I made dirty
> page logging depend on userspace having the option to access the memory.
> This can only happen if the guest_memfd file is mmap'able and accessible by
> userspace. But it doesn't force userspace to actually have the memory
> mapped to allow the log dirty pages flag to be set for a guest_memfd backed
> memslot. Hm.. now that I think about it, maybe I should have made depend on
> guest_memfd also having been created as shared?
TDX live migration also needs to toggle KVM_MEM_LOG_DIRTY_PAGES on guest_memfd
memslots to use KVM's dirty logging infrastructure (the actual dirty
tracking for private pages is done out-of-band via SEAMCALLs). So this enabling
is needed, but it would be better to keep any logging eligibility decision in
an arch hook — e.g. gating on mmap/shared wouldn't work for TDX.
> Though I think that can be changed with KVM_SET_MEMORY_ATTRIBUTES on x86.
>
> Does that answer your question?
>
>> ...
>>> + r = kvm_gmem_bind(kvm, new, mem->guest_memfd, mem->guest_memfd_offset);
>>> + } else if (change == KVM_MR_FLAGS_ONLY) {
>>> + r = kvm_gmem_change_flags(kvm, old, new, mem->guest_memfd,
>>> + mem->guest_memfd_offset);
>>> + }
>>> if (r)
>>> goto out;
>>> }
>>> @@ -2117,7 +2117,7 @@ static int kvm_set_memory_region(struct kvm *kvm,
>>> return 0;
>>>
>>> out_unbind:
>>> - if (mem->flags & KVM_MEM_GUEST_MEMFD)
>>> + if ((mem->flags & KVM_MEM_GUEST_MEMFD) && change == KVM_MR_CREATE)
>>> kvm_gmem_unbind(new);
>>
>> This is wrong. If kvm_set_memslot() failed, the old memslot needs to be bound
>> back to the guest_memfd instance. Hmm, but KVM can't guarantee success. So
>
> The old memslot is still bound to guest_memfd in the sense that f->bindings
> still has the same memslot id+as_id assigned to the memslot's gpa range.
Whichever way it's handled, TDX will need this flags-only gmem update too.
A solution on the generic code path would be helpful.
> There's no rebinding happening when flags are changed because the memslot's
> id + as_id are not changed.
next prev parent reply other threads:[~2026-07-14 5:39 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 14:29 [RFC PATCH 0/3] KVM: Dirty page logging for guest_memfd-only memslots Alexandru Elisei
2026-07-02 14:29 ` [RFC PATCH 1/3] KVM: guest_memfd: Use memslot id to keep track of associated memslots Alexandru Elisei
2026-07-06 7:14 ` David Hildenbrand
2026-07-06 13:45 ` Alexandru Elisei
2026-07-06 21:46 ` Sean Christopherson
2026-07-07 17:05 ` Alexandru Elisei
2026-07-06 21:43 ` Sean Christopherson
2026-07-07 17:05 ` Alexandru Elisei
2026-07-13 14:03 ` David Hildenbrand
2026-07-13 16:13 ` Sean Christopherson
2026-07-13 13:42 ` David Hildenbrand
2026-07-02 14:29 ` [RFC PATCH 2/3] KVM: Implement dirty page logging for guest_memfd-only memslots Alexandru Elisei
2026-07-07 1:29 ` Sean Christopherson
2026-07-07 17:12 ` Alexandru Elisei
2026-07-14 5:39 ` Kishen Maloor [this message]
2026-07-02 14:29 ` [RFC PATCH 3/3] KVM: arm64: Allow " Alexandru Elisei
2026-07-07 0:56 ` [RFC PATCH 0/3] KVM: Dirty " Sean Christopherson
2026-07-07 16:58 ` Alexandru Elisei
2026-07-07 17:12 ` Sean Christopherson
2026-07-09 11:21 ` Mark Rutland
2026-07-09 19:01 ` Sean Christopherson
2026-07-10 10:26 ` Mark Rutland
2026-07-13 14:11 ` David Hildenbrand
2026-07-09 20:33 ` Oliver Upton
2026-07-10 10:44 ` Alexandru Elisei
2026-07-10 18:18 ` Oliver Upton
2026-07-13 13:48 ` Alexandru Elisei
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=7295903c-14f9-4427-9c83-039e70e64cd3@intel.com \
--to=kishen.maloor@intel.com \
--cc=alexandru.elisei@arm.com \
--cc=david.hildenbrand@arm.com \
--cc=fuad.tabba@linux.dev \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=yuzenghui@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox