Tarun Sahu <[email protected]> writes: > > [...snip...] > > +static bool kvm_gmem_luo_can_preserve(struct liveupdate_file_handler > *handler, struct file *file) > +{ > + struct inode *inode = file_inode(file); > + struct gmem_file *gmem_file; > + struct kvm *kvm; > + > + if (inode->i_sb->s_magic != GUEST_MEMFD_MAGIC) > + return false; > + > + gmem_file = file->private_data; > + if (!gmem_file) > + return false; > + > + /* > + * Only Fully-shared guest_memfd preservation is supported > + */ > + if (!(GMEM_I(inode)->flags & GUEST_MEMFD_FLAG_INIT_SHARED)) > + return false; > +
The above check can probably be removed. I think the core thing about this series is "we can preserve any memory that doesn't have any encryption state that goes along with it", and so the check for kvm_arch_has_private_mem() below would be sufficient to gate that. > + /* > + * It makes sure that no memory can be converted to private > + * even if it was initially fully shared (in-place conversions are > + * prevented). > + */ > + kvm = gmem_file->kvm; > + if (kvm_arch_has_private_mem(kvm)) > + return false; > + For now, has_private_mem == has some encryption state that we can't preserve yet. This also gates off KVM_X86_SW_PROTECTED_VM, but I guess that is intended, since when work is done for preserving encryption state, we can then test using KVM_X86_SW_PROTECTED_VM, and only then, remove this check? > + if (mapping_large_folio_support(inode->i_mapping)) > + return false; > + > + return true; > +} > + > > [...snip...] >

