On Tue, May 31, 2022 at 12:15:00PM -0700, Vishal Annapurve wrote: > On Thu, May 19, 2022 at 8:41 AM Chao Peng <chao.p.peng@xxxxxxxxxxxxxxx> wrote: > > > > Introduce a new memfd_create() flag indicating the content of the > > created memfd is inaccessible from userspace through ordinary MMU > > access (e.g., read/write/mmap). However, the file content can be > > accessed via a different mechanism (e.g. KVM MMU) indirectly. > > > > SEV, TDX, pkvm and software-only VMs seem to have usecases to set up > initial guest boot memory with the needed blobs. > TDX already supports a KVM IOCTL to transfer contents to private > memory using the TDX module but rest of the implementations will need > to invent > a way to do this. There are some discussions in https://lkml.org/lkml/2022/5/9/1292 already. I somehow agree with Sean. TDX is using an dedicated ioctl to copy guest boot memory to private fd so the rest can do that similarly. The concern is the performance (extra memcpy) but it's trivial since the initial guest payload is usually optimized in size. > > Is there a plan to support a common implementation for either allowing > initial write access from userspace to private fd or adding a KVM > IOCTL to transfer contents to such a file, > as part of this series through future revisions? Indeed, adding pre-boot private memory populating on current design isn't impossible, but there are still some opens, e.g. how to expose private fd to userspace for access, pKVM and CC usages may have different requirements. Before that's well-studied I would tend to not add that and instead use an ioctl to copy. Whether we need a generic ioctl or feature-specific ioctl, I don't have strong opinion here. Current TDX uses a feature-specific ioctl so it's not covered in this series. Chao > > Regards, > Vishal