Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: "Serge Hallyn (AMD)" <sergeh@kernel.org>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: "Tony Lindgren" <tony.lindgren@linux.intel.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Sean Christopherson" <seanjc@google.com>,
	"Peter Xu" <peterx@redhat.com>, "Fabiano Rosas" <farosas@suse.de>,
	"Jon Grimm" <Jon.Grimm@amd.com>,
	"Pankaj Gupta" <pankaj.gupta@amd.com>,
	"Tom Lendacky" <thomas.lendacky@amd.com>,
	"Marc Zyngier" <maz@kernel.org>,
	"Oliver Upton" <oliver.upton@linux.dev>,
	"Steven Price" <steven.price@arm.com>,
	"Anup Patel" <anup@brainfault.org>,
	"Samuel Ortiz" <sameo@rivosinc.com>,
	"Jakub Růžička" <jakub.ruzicka@matfyz.cz>,
	"Jörg Rödel" <joro@8bytes.org>,
	"Vishal Annapurve" <vannapurve@google.com>,
	"Elena Reshetova" <elena.reshetova@intel.com>,
	"Kishen Maloor" <kishen.maloor@intel.com>,
	"Mika Westerberg" <mika.westerberg@linux.intel.com>,
	"Peter Fang" <peter.fang@intel.com>,
	"Rick Edgecombe" <rick.p.edgecombe@intel.com>,
	"Xiaoyao Li" <xiaoyao.li@intel.com>,
	"Xu Yilun" <yilun.xu@linux.intel.com>,
	kvm@vger.kernel.org, "Tycho Andersen" <tycho@kernel.org>,
	"Mahmoud Adam" <Mahmoud.Adam@amd.com>
Subject: Re: [RFC PATCH v2 2/4] KVM: x86: Add optional KVM_CAP_LIVE_MIGRATION and KVM_MIGRATE_CMD
Date: Thu, 3 Dec 2026 11:07:36 -0600	[thread overview]
Message-ID: <axGh2CPBrJmyVaiy@shallyn-amd> (raw)
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

  reply	other threads:[~2026-12-03 17:07 UTC|newest]

Thread overview: 111+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31  7:13 [RFC PATCH v2 0/4] Add KVM API for confidential guest live migration Tony Lindgren
2026-08-31  7:13 ` [RFC PATCH v2 1/4] Documentation: KVM: Add live migration API for confidential guests Tony Lindgren
2026-08-31  7:20   ` sashiko-bot
2026-09-18 11:35   ` Peter Xu
2026-09-21  4:20     ` Tony Lindgren
2026-09-24  1:50     ` Wei Wang
2026-09-24  4:51       ` Tony Lindgren
2026-11-10 12:42   ` Artem Bityutskiy
2026-08-31  7:13 ` [RFC PATCH v2 2/4] KVM: x86: Add optional KVM_CAP_LIVE_MIGRATION and KVM_MIGRATE_CMD Tony Lindgren
2026-08-31  7:23   ` sashiko-bot
2026-09-01  6:03     ` Tony Lindgren
2026-09-07 11:53   ` Tony Lindgren
2026-09-07 13:15     ` Jörg Rödel
2026-09-07 13:32       ` Artem Bityutskiy
2026-09-08  4:15         ` Tony Lindgren
2026-09-08  4:43         ` Tony Lindgren
2026-09-09  0:22           ` Kishen Maloor
2026-09-09  6:57             ` Tony Lindgren
2026-09-10  1:11               ` Kishen Maloor
2026-09-10  6:33                 ` Tony Lindgren
2026-09-11  1:40                   ` Kishen Maloor
2026-09-11  4:23                     ` Tony Lindgren
2026-09-15  0:14                       ` Kishen Maloor
2026-09-15  4:44                         ` Tony Lindgren
2026-09-15 15:53                           ` Kishen Maloor
2026-09-16  5:09                             ` Tony Lindgren
2026-09-17  3:31                               ` Kishen Maloor
2026-09-17  6:42                                 ` Tony Lindgren
2026-09-18  4:32                                   ` Kishen Maloor
2026-09-18  5:58                                     ` Tony Lindgren
2026-09-21  0:13                                       ` Kishen Maloor
2026-09-21  6:52                                         ` Tony Lindgren
2026-09-21  9:24                                           ` Tony Lindgren
2026-09-21 10:58                                             ` Tony Lindgren
2026-09-22  3:57                                           ` Kishen Maloor
2026-09-22  5:25                                             ` Tony Lindgren
2026-09-23  0:38                                               ` Kishen Maloor
2026-09-23  6:04                                                 ` Tony Lindgren
2026-09-24  5:53                                                   ` Kishen Maloor
2026-09-24  6:59                                                     ` Tony Lindgren
2026-09-18  4:33   ` Kishen Maloor
2026-09-21  5:58     ` Tony Lindgren
2026-09-21  6:56       ` Tony Lindgren
2026-09-22  3:56         ` Kishen Maloor
2026-09-22  6:27           ` Tony Lindgren
2026-09-23  0:37             ` Kishen Maloor
2026-09-23  6:50               ` Tony Lindgren
2026-09-24  5:34                 ` Kishen Maloor
2026-09-24  7:15                   ` Tony Lindgren
2026-10-08  9:22                     ` Tony Lindgren
2026-10-16  4:00                       ` Kishen Maloor
2026-11-27  8:25   ` Artem Bityutskiy
2026-11-27  8:33   ` Artem Bityutskiy
2026-11-27  8:37     ` Tony Lindgren
2026-11-30 18:16     ` Serge Hallyn (AMD)
2026-12-02 10:31       ` Artem Bityutskiy
2026-12-03 17:07         ` Serge Hallyn (AMD) [this message]
2026-08-31  7:13 ` [RFC PATCH v2 3/4] KVM: x86: Add optional KVM_EXPORT_MEMORY and KVM_IMPORT_MEMORY Tony Lindgren
2026-08-31  7:23   ` sashiko-bot
2026-09-01  6:10     ` Tony Lindgren
2026-08-31  7:13 ` [RFC PATCH v2 4/4] KVM: x86: Add optional KVM_EXPORT_VCPU and KVM_IMPORT_VCPU Tony Lindgren
2026-08-31  7:23   ` sashiko-bot
2026-09-01  6:12     ` Tony Lindgren
2026-09-04 18:24 ` [RFC PATCH v2 0/4] Add KVM API for confidential guest live migration Artem Bityutskiy
2026-09-17 21:27   ` Peter Xu
2026-09-18 12:46     ` Artem Bityutskiy
2026-09-18 15:53       ` Peter Xu
2026-09-22  8:09         ` Artem Bityutskiy
2026-09-22  9:42           ` Tony Lindgren
2026-09-22 11:54             ` Artem Bityutskiy
2026-09-23  4:20               ` Tony Lindgren
2026-09-22 21:18           ` Peter Xu
2026-09-23 12:05             ` Artem Bityutskiy
2026-09-24 21:19               ` Peter Xu
2026-09-28 14:15                 ` Artem Bityutskiy
2026-09-29 21:05                   ` Peter Xu
2026-10-02 19:57                     ` Artem Bityutskiy
2026-10-07 20:00                       ` Peter Xu
2026-09-23 15:28           ` Serge Hallyn (AMD)
2026-11-04 13:51         ` TDX migration model Artem Bityutskiy
2026-11-05 14:58           ` Serge Hallyn (AMD)
2026-11-05 15:59             ` Artem Bityutskiy
2026-11-05 16:42               ` Serge E. Hallyn
2026-11-06  2:00                 ` Kishen Maloor
2026-11-09  7:45                   ` Tony Lindgren
2026-11-09 22:15                     ` Serge Hallyn (AMD)
2026-11-10  5:16                       ` Tony Lindgren
2026-11-19 14:21                         ` Peter Xu
2026-11-19 17:09                           ` Serge Hallyn (AMD)
2026-11-19 17:27                             ` Peter Xu
     [not found]                               ` <DU2PR08MB725581B0CF281FA12E2DFE0686792@DU2PR08MB7255.eurprd08.prod.outlook.com>
2026-12-02 13:31                                 ` Negotiation Model Artem Bityutskiy
2026-12-03 16:55                                   ` Serge Hallyn (AMD)
2026-10-09  6:11       ` [RFC PATCH v2 0/4] Add KVM API for confidential guest live migration Tony Lindgren
2026-10-16  3:56         ` Kishen Maloor
2026-10-19  7:34           ` Tony Lindgren
2026-09-20 23:56     ` Kishen Maloor
2026-09-23 21:36       ` Peter Xu
2026-09-24  4:27         ` Kishen Maloor
2026-09-25 14:18           ` Peter Xu
2026-09-29  1:28             ` Kishen Maloor
2026-09-30 20:42               ` Peter Xu
2026-10-07  4:27                 ` Kishen Maloor
2026-10-07 20:13                   ` Peter Xu
2026-10-08  6:23                     ` Tony Lindgren
2026-10-08 14:31                       ` Peter Xu
2026-10-09  4:29                         ` Tony Lindgren
2026-10-16  4:02                     ` Kishen Maloor
2026-09-18 18:36 ` Ionut Mihalcea
2026-09-21  4:35   ` Tony Lindgren
2026-09-25 16:03 ` Serge Hallyn (AMD)
2026-09-28  3:24   ` Kishen Maloor

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=axGh2CPBrJmyVaiy@shallyn-amd \
    --to=sergeh@kernel.org \
    --cc=Jon.Grimm@amd.com \
    --cc=Mahmoud.Adam@amd.com \
    --cc=anup@brainfault.org \
    --cc=dedekind1@gmail.com \
    --cc=elena.reshetova@intel.com \
    --cc=farosas@suse.de \
    --cc=jakub.ruzicka@matfyz.cz \
    --cc=joro@8bytes.org \
    --cc=kishen.maloor@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=oliver.upton@linux.dev \
    --cc=pankaj.gupta@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.fang@intel.com \
    --cc=peterx@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=sameo@rivosinc.com \
    --cc=seanjc@google.com \
    --cc=steven.price@arm.com \
    --cc=thomas.lendacky@amd.com \
    --cc=tony.lindgren@linux.intel.com \
    --cc=tycho@kernel.org \
    --cc=vannapurve@google.com \
    --cc=xiaoyao.li@intel.com \
    --cc=yilun.xu@linux.intel.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