From: tarunsahu@google.com
To: Ackerley Tng <ackerleytng@google.com>,
Sean Christopherson <seanjc@google.com>
Cc: axelrasmussen@google.com, mark.rutland@arm.com,
skhawaja@google.com, Mike Rapoport <rppt@kernel.org>,
sagis@google.com, Jason Gunthorpe <jgg@ziepe.ca>,
Shuah Khan <shuah@kernel.org>,
corbet@lwn.net, dmatlack@google.com,
Paolo Bonzini <pbonzini@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
vannapurve@google.com, Pratyush Yadav <pratyush@kernel.org>,
david@redhat.com, aneesh.kumar@kernel.org, vipinsh@google.com,
Alexander Graf <graf@amazon.com>,
David Hildenbrand <david@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
kexec@lists.infradead.org, linux-kselftest@vger.kernel.org,
kvm@vger.kernel.org
Subject: Re: [RFC PATCH v1 0/8] liveupdate: kvm: Guest_memfd preservation
Date: Fri, 05 Jun 2026 19:12:22 +0000 [thread overview]
Message-ID: <9huz33z06bu1.fsf@tarunix.c.googlers.com> (raw)
In-Reply-To: <CAEvNRgHsJbGz8k8vgCn_HSxeeQ8agEm4oBYQQ0+b3gFb-aVokg@mail.gmail.com>
Hi,
Ackerley Tng <ackerleytng@google.com> writes:
> Sean Christopherson <seanjc@google.com> writes:
>
>>>
>>> [...snip...]
>>>
>>> we have one open Question left:
>>> 1. How to check guest_memfd is fully shared.
>>>
>>> [...snip...]
>>>
>>
>> Given that lack of support isn't going to be limited to _just_ guest_memfd,
>> simply disallow preservation if the VM supports private memory:
>>
>> if (kvm_arch_has_private_mem(kvm))
>> return -EOPNOTSUPP;
>
This is a good idea, I have implemented it in V2 (sent it recently).
Below, I have mentioned a detailed analysis. Please let me know your thoughts.
> Makes sense. Tarun this was the other option that I was suggesting when
> we discussed offline.
>
> I think (?) it is possible to create a fully-private guest_memfd for a
> non-Confidential VM, and even after conversion lands, for both
> vm_memory_attributes=true and vm_memory_attributes=false.
>
> In that case, your preservation series can still preserve memory tracked
> as private by guest_memfd but not used as private, right?
>
> I don't think anyone will use this combination before guest_memfd
> write() support lands, we just need to make sure there's no kernel crash
> or corruption in this case.
IIUC, currently, private memory definition is where cocovm with HW based
private memory is supported. Which is directly checked by
kvm_arch_has_private_mem and this return false incase ARCH does not
support it in HW (SEV/SNP, TDX).
So about the combination where a guest_memfd is tracked as private but
not actually private. (Created without the INIT_SHARED flags). Even
though kvm_arch_has_private_mem is false.
In this case the luo will preserve the guest_memfd. But it will not
preserve any attributes, because
1. during creation, we dont populate any attributes, so by default
guest_memfd memory always considered to be shared. (Even though no
INIT_SHARED is passed). Conversion to private IOCTL will fail as
kvm_arch_has_private_mem check will fail for non-COCOVM. for COCOVM,
presevation will not be supported and conversion to private memory will
be succeded. (No corruption and kernel crash in this case)
==== WHAT IF CONVERSION SERIES LANDS =========
In this case, we have two scenerio
1. kvm->attributes
In this case, Every logic remains same as above.
2. gmem->attributes
if INIT_SHARED: memory is initially shared and no entry in maple tree, and if
kvm_arch_has_private_mem returns false (non-COCOVM), this will just
fails any conversion request. hence preserving the guest_memfd wont
have any problem (fully shared case).
if INIT_SHARED not set: memory is initially private, and there is an
entry in maple tree, marked the memory as private. During conversion:
A. To private: it fails as kvm_arch_has_private_mem return false.
Preservation is safe and there will be no problem. as in preservation
we dont preserve any attributes, but on retrieval, when a new gmem
file is created, identical entry to attributes will also be assigned
as INIT_SHARED flag is not set. So we wont have any issues in this case.
B. TO shared: it passes, and update the maple tree. preservation will
not be preserving the attributes with current patches, and it will
also allow the preservation as kvm_arch_has_private_mem is false. So
in this case, on retrieval, we will lose the data regarding the
private vs shared (non-cocovm). So if host want to access the shared
memory, it will try MMAP and which will fail in new kernel (which was
successful in old kernel as conversion happened). But I dont see any
kernel crash or corruption.
This is an issue with only non-cocoVM support with conversion series
having the gmem attribute enabled without INIT_SHARED flag. I am not
sure, if there will be any user for this very soon (is it SW_PROTECTED_VM ?? ).
Let me know, If my understanding is correct. Should we add INIT_SHARED
along with kvm_arch_has_private_mem check to make Above case 2.B.
impossible in future for the current support of guest_memfd.
next prev parent reply other threads:[~2026-06-05 19:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 9:36 Tarun Sahu
2026-05-18 9:36 ` [RFC PATCH v1 1/9] liveupdate: luo_file: Add internal APIs for file preservation Tarun Sahu
2026-05-18 9:36 ` [RFC PATCH v1 2/9] liveupdate: Add LIVEUPDATE_GUEST_MEMFD config option Tarun Sahu
2026-05-18 9:36 ` [RFC PATCH v1 3/9] kvm: Prepare core VM structs and helpers for LUO support Tarun Sahu
2026-05-18 9:36 ` [RFC PATCH v1 4/9] kvm: kvm_luo: Allow kvm preservation with LUO Tarun Sahu
2026-05-18 9:36 ` [RFC PATCH v1 5/9] kvm: guest_memfd: Move internal definitions and helper to new header Tarun Sahu
2026-05-18 9:36 ` [RFC PATCH v1 6/9] kvm: guest_memfd: Add support for freezing and unfreezing mappings Tarun Sahu
2026-05-18 9:36 ` [RFC PATCH v1 7/9] kvm: guest_memfd_luo: add support for guest_memfd preservation Tarun Sahu
2026-05-18 9:36 ` [RFC PATCH v1 8/9] selftests: kvm: Split ____vm_create() to expose init helpers Tarun Sahu
2026-05-18 9:36 ` [RFC PATCH v1 9/9] selftests: kvm: Add guest_memfd_preservation_test Tarun Sahu
2026-05-28 17:20 ` [RFC PATCH v1 0/8] liveupdate: kvm: Guest_memfd preservation tarunsahu
2026-05-29 13:57 ` Sean Christopherson
2026-06-03 22:17 ` Ackerley Tng
2026-06-05 19:12 ` tarunsahu [this message]
2026-06-05 20:05 ` Ackerley Tng
2026-06-07 0:30 ` tarunsahu
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=9huz33z06bu1.fsf@tarunix.c.googlers.com \
--to=tarunsahu@google.com \
--cc=ackerleytng@google.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@kernel.org \
--cc=axelrasmussen@google.com \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=david@redhat.com \
--cc=dmatlack@google.com \
--cc=graf@amazon.com \
--cc=jgg@ziepe.ca \
--cc=kexec@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=pasha.tatashin@soleen.com \
--cc=pbonzini@redhat.com \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.org \
--cc=sagis@google.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
--cc=skhawaja@google.com \
--cc=vannapurve@google.com \
--cc=vipinsh@google.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
all inboxes | Powered by JetHome®