+Vipin Sharma On Wed, Jan 31, 2024 at 4:21 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote: > On Mon, Jan 22, 2024, isaku.yamahata@xxxxxxxxx wrote: > > The real reason for this drive-by pseudo-review is that I am hoping/wishing we > can turn this into a generic KVM ioctl() to allow userspace to pre-map guest > memory[*]. > > If we're going to carry non-trivial code, we might as well squeeze as much use > out of it as we can. > > Beyond wanting to shove this into KVM_MEMORY_ENCRYPT_OP, is there any reason why > this is a VM ioctl() and not a vCPU ioctl()? Very roughly, couldn't we use a > struct like this as input to a vCPU ioctl() that maps memory, and optionally > initializes memory from @source? > > struct kvm_memory_mapping { > __u64 base_gfn; > __u64 nr_pages; > __u64 flags; > __u64 source; > } > > TDX would need to do special things for copying the source, but beyond that most > of the code in this function is generic. > > [*] https://lore.kernel.org/all/65262e67-7885-971a-896d-ad9c0a760907@xxxxxxxxx We would also be interested in such an API to reduce the guest performance impact of intra-host migration.