From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796317662; b=WIvkE66uP5m5lDPPMbm3w3cfiWbxoHd3eptoUNcXHZNrUnewIjuobWRE7ELru4R4iuci Mta2Th1E1AIbwwUQCJRtXwC6ce6B99VoHVhhvFLXgp85WSCbow6e8It9Sz7QBL/QcPjbd bLGINGGwrYVIBpVpd2u6LDggNNW408YAecVYV7pyydIoZ7caXn72tvxq3E08q5OaEkBrH gXs90L3HZadTxMLBkK/THp6vz+5dHt39CkReehSpH/aEVRCQGWQlBv1GIuKIh/CLBxQez vayrCJ8le1+X1jdE73t6BdBmrGn0h5K8ek9OJ6iBqPkq79B85qIVqIFc4W9h+j9027w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796317662; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=P5fhoS53FUg+kWYtyjmV8GGqBcZi7V4qVG3EhNYQbTY=; b=zPl5fV/c3VCdb91h3gBud3xOfzEqWiggTU1AwjEwUJ0tGS45XBjNDtybqOMdfKgbD56T eIofq/JLh++emUW6xv0BGsX8WjyDX3rDKG0V1tQuY+ceMBMSw4kJhR+Krvtpj8um2RPKT Bv98WksqDU0zCHERVXYRo+aqiCS7T2k4ZwJVhgqV6WHqCP7GHmF6rkRByTav9Ujb7ej0f lNyCToK9SDmo5sJOTWqHIGEaL5WtSUMSZ7rWYc0RgdsogHzRkuhcvVYVGQ5Z/UgmY3lGq q4WZvkkwisg7G7373g9WL012MvpDsEMUyRq6BD418B3pM4osdYQeucDPFoS7cX91tOw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jBj2Aodk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AED91606A337 for ; Thu, 3 Dec 2026 17:07:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jBj2Aodk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43B081F00924; Thu, 3 Dec 2026 17:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796317662; bh=P5fhoS53FUg+kWYtyjmV8GGqBcZi7V4qVG3EhNYQbTY=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=jBj2AodkU2IA4FrQas+vQZW9/ufvnaHM1oAldzjR9fx6kLrv6J9q29wVIyrGxZnCD jOEsl7yCpXIF6l9SEHIki4oJIQ1WLOtfy0s822+tuYbhpYGM/0psNOfSaejUUyj5it hstJPgT3KNxe+KjWgkDTRimQPS/SjdKXqfm64UnWeSgzLw/7eemHPhfVsRcuAnM/TD 0L7g3VF+dQCEDXg0pHAhpyiATlKuvxuzTd81+OZLGfnRDbg/8Uccj8xAK1U2BAWZMI ViXc8fxzyVucNpGRnGDzWEcezXeeEJ/7gdRj7wm6ol42mJs6JGO1b94VvuTzkMV1R+ wkwa+qAY0fP9Q== Date: Thu, 3 Dec 2026 11:07:36 -0600 From: "Serge Hallyn (AMD)" To: Artem Bityutskiy Cc: Tony Lindgren , Paolo Bonzini , Sean Christopherson , Peter Xu , Fabiano Rosas , Jon Grimm , Pankaj Gupta , Tom Lendacky , Marc Zyngier , Oliver Upton , Steven Price , Anup Patel , Samuel Ortiz , Jakub =?utf-8?B?UsWvxb5pxI1rYQ==?= , =?iso-8859-1?Q?J=F6rg_R=F6del?= , Vishal Annapurve , Elena Reshetova , Kishen Maloor , Mika Westerberg , Peter Fang , Rick Edgecombe , Xiaoyao Li , Xu Yilun , kvm@vger.kernel.org, Tycho Andersen , Mahmoud Adam Subject: Re: [RFC PATCH v2 2/4] KVM: x86: Add optional KVM_CAP_LIVE_MIGRATION and KVM_MIGRATE_CMD Message-ID: References: <20260831071304.762939-1-tony.lindgren@linux.intel.com> <20260831071304.762939-3-tony.lindgren@linux.intel.com> <74c6eec32fec9b7db75a8b4cd7f8e00d581eab5f.camel@gmail.com> <4aba17135640e38f41b714b36d3db4807194c843.camel@gmail.com> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4aba17135640e38f41b714b36d3db4807194c843.camel@gmail.com> On Wed, Dec 02, 2026 at 12:31:19PM +0200, Artem Bityutskiy wrote: > On Mon, 2026-11-30 at 12:16 -0600, Serge Hallyn (AMD) wrote: > > On Fri, Nov 27, 2026 at 10:33:40AM +0200, Artem Bityutskiy wrote: > > > On Mon, 2026-08-31 at 10:13 +0300, Tony Lindgren wrote: > > > > +struct kvm_migrate_cmd { > > > > + __u16 command; > > > > + __u16 flags; > > > > + __u32 reserved; > > > > + struct kvm_transfer_buffer buf; > > > > +}; > > > > > > In addition to dropping 'struct kvm_transfer_buffer', we need separate > > > input and output buffers. Reasons: > > > > > >   - TDX requires them to be separate: using one buffer for both does not work > > >     in corner cases such as update-while-setup. > > >   - We can't assume other CoCo implementations can use the input buffer as > > >     the output buffer either. > > > > Indeed.  I figured that at least for AMD the sev driver would take care > > of that opaquely behind the KVM_MIGRATE_CMD API, but separate buffers > > is good for us, too. > > To clarify, my comment was about the setup ioctl. It is used at the > initial stage, when the platform security agents (the TDX module in > our case) establish trust, migration keys, etc. > > > > In September, you had mentioned Intel requiring output space for both > > output and metadata.  The same is of course true for AMD (you can see > > the details for SNP_ARG_EXPORT_PAGE in chapter 6 at > > https://docs.amd.com/api/khub/documents/Gzue7GL~KH3204rrtW369g/content ) > > and I would imagine every implementation would export some metadata. > > So, do we actually want three buffers?  If not, of course, userspace > > can just pass in a larger contiguous buffer for both, but perhaps it > > keeps things simpler and cleaner to separate them. > > This one is about the memory export ioctl, which is a different story. > > The current TDX module exports private memory into a "memory bundle" > that consists of 4 buffers: > > +------------+ +---------------+ > | MBMD | | GPA list page | > | | | GPA entries | > +------------+ +---------------+ > > +-------------+ +-----------------------+ > | MAC page 0 | | MAC page 1 (optional) | > | MAC entries | | MAC entries | > +-------------+ +-----------------------+ > > +----------------------+ +----------+ > | Encrypted memory | | ... | > | data page | | | > +----------------------+ +----------+ > > Details: > https://github.com/dedekind/dedekind-share/blob/master/misc/intel-cpu/tdx-migration-structs.md#memory-bundle > > Partitioned TDs need a 5th buffer. Upstream does not support them > today, but that may change some day. > > So there are many buffers, not just two as in the AMD case. As far as > I know, ARM CCA may need about as many buffers as TDX. > > Of the TDX buffers, only the GPA list is interesting to the VMM. It > says which GPAs were exported, and which were not and why. The rest is > opaque to the VMM and only matters to the destination TDX module. > > Maybe some data from the MBMD (and also from the AMD metadata) can be > interesting for debugging or research, but not in general. > > I suggest this uAPI model: > > - One opaque output buffer (blob). The VMM transfers it to the > destination as is and feeds it to the import ioctl. > - Everything the VMM needs to know goes into explicit fields of the > ioctl structure: the blob size, which GPAs were exported, how many, > per-GPA status, etc. This data is for the source VMM only and is not > transferred. > > If a platform produces multiple buffers, either the platform ABI > must be improved, or the kernel must pack them into a single blob. > Either way, userspace sees one opaque buffer. > > For AMD, I guess the kernel could simply prepend or append the 40-byte > metadata to the exported data. Yes, there may be challenges of "wasted > space" or "gaps" in the blob, which are transferred over the wire. But > I'd say each platform should deal with them somehow, or just accept > the small wastage. Yup, that's what I had originally been planning to do. My thought here was that if every coco platform will output a separate stream of metadata, everything might be easier to follow if we just make that explicit in the api. But since the number of extra buffers varies, then I agree, sticking with one buffer is good. > To me this is the cleanest and most platform-agnostic approach. > > An alternative is to return some sort of scatter-gather list of > buffers. But that is more complex, and it would likely slow down > upstreaming, which already has many moving pieces. I guess the only reason the scatter-gather list would be preferable is if some platform might not be able to predict the size of the expected output buffers. That's not the case for AMD, nor apparently for Intel. I wouldn't expect it to be the case for arm. > Thoughts? I think we should stick with what you suggest. thanks, -serge