From: Nikita Kalyazin <kalyazin@amazon.com>
To: Paolo Bonzini <pbonzini@redhat.com>, <corbet@lwn.net>,
<kvm@vger.kernel.org>, <linux-doc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <jthoughton@google.com>, <brijesh.singh@amd.com>,
<michael.roth@amd.com>, <graf@amazon.de>, <jgowans@amazon.com>,
<roypat@amazon.co.uk>, <derekmn@amazon.com>, <nsaenz@amazon.es>,
<xmarcalx@amazon.com>
Subject: Re: [RFC PATCH 0/4] KVM: ioctl for populating guest_memfd
Date: Wed, 20 Nov 2024 17:41:31 +0000 [thread overview]
Message-ID: <acdfa273-5da0-48dd-b506-e1064eea2726@amazon.com> (raw)
In-Reply-To: <86811253-a310-4474-8d0a-dad453630a2d@redhat.com>
On 20/11/2024 13:55, Paolo Bonzini wrote:
>> Patch 4 allows to call the ioctl from a separate (non-VMM) process. It
>> has been prohibited by [3], but I have not been able to locate the exact
>> justification for the requirement.
>
> The justification is that the "struct kvm" has a long-lived tie to a
> host process's address space.
>
> Invoking ioctls like KVM_SET_USER_MEMORY_REGION and KVM_RUN from
> different processes would make things very messy, because it is not
> clear which mm you are working with: the MMU notifier is registered for
> kvm->mm, but some functions such as get_user_pages do not take an mm for
> example and always operate on current->mm.
That's fair, thanks for the explanation.
> In your case, it should be enough to add a ioctl on the guestmemfd
> instead?
That's right. That would be sufficient indeed. Is that something that
could be considered? Would that be some non-KVM API, with guest_memfd
moving to an mm library?
> But the real question is, what are you using
> KVM_X86_SW_PROTECTED_VM for?
The concrete use case is VM restoration from a snapshot in Firecracker
[1]. In the current setup, the VMM registers a UFFD against the guest
memory and sends the UFFD handle to an external process that knows how
to obtain the snapshotted memory. We would like to preserve the
semantics, but also remove the guest memory from the direct map [2].
Mimicing this with guest_memfd would be sending some form of a
guest_memfd handle to that process that would be using it to populate
guest_memfd.
[1]:
https://github.com/firecracker-microvm/firecracker/blob/main/docs/snapshotting/handling-page-faults-on-snapshot-resume.md#userfaultfd
[2]:
https://lore.kernel.org/kvm/20241030134912.515725-1-roypat@amazon.co.uk/T/
> Paolo
prev parent reply other threads:[~2024-11-20 17:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 9:54 [RFC PATCH 0/4] KVM: ioctl for populating guest_memfd Nikita Kalyazin
2024-10-24 9:54 ` [PATCH 1/4] KVM: guest_memfd: add generic post_populate callback Nikita Kalyazin
2024-11-22 18:40 ` Mike Day
2024-11-25 11:46 ` Nikita Kalyazin
2024-10-24 9:54 ` [PATCH 2/4] KVM: add KVM_GUEST_MEMFD_POPULATE ioctl for guest_memfd Nikita Kalyazin
2024-10-24 9:54 ` [PATCH 3/4] KVM: allow KVM_GUEST_MEMFD_POPULATE in another mm Nikita Kalyazin
2024-10-24 9:54 ` [PATCH 4/4] KVM: document KVM_GUEST_MEMFD_POPULATE ioctl Nikita Kalyazin
2024-11-20 12:09 ` [RFC PATCH 0/4] KVM: ioctl for populating guest_memfd Nikita Kalyazin
2024-11-20 13:46 ` David Hildenbrand
2024-11-20 15:13 ` David Hildenbrand
2024-11-20 15:58 ` Nikita Kalyazin
2024-11-20 16:20 ` David Hildenbrand
2024-11-20 16:44 ` David Hildenbrand
2024-11-20 17:21 ` Nikita Kalyazin
2024-11-20 18:29 ` David Hildenbrand
2024-11-21 16:46 ` Nikita Kalyazin
2024-11-26 16:04 ` Nikita Kalyazin
2024-11-28 12:11 ` David Hildenbrand
2024-11-20 13:55 ` Paolo Bonzini
2024-11-20 17:41 ` Nikita Kalyazin [this message]
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=acdfa273-5da0-48dd-b506-e1064eea2726@amazon.com \
--to=kalyazin@amazon.com \
--cc=brijesh.singh@amd.com \
--cc=corbet@lwn.net \
--cc=derekmn@amazon.com \
--cc=graf@amazon.de \
--cc=jgowans@amazon.com \
--cc=jthoughton@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=nsaenz@amazon.es \
--cc=pbonzini@redhat.com \
--cc=roypat@amazon.co.uk \
--cc=xmarcalx@amazon.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