All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Serge Hallyn (AMD)" <sergeh@kernel.org>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: "Mathias Brossard" <Mathias.Brossard@arm.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Tony Lindgren" <tony.lindgren@linux.intel.com>,
	"Kishen Maloor" <kishen.maloor@intel.com>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Sean Christopherson" <seanjc@google.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>,
	"Kai Huang" <kai.huang@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" <kvm@vger.kernel.org>,
	"David.Kaplan@amd.com" <David.Kaplan@amd.com>,
	"tycho@kernel.org" <tycho@kernel.org>,
	"Adam, Mahmoud" <Mahmoud.Adam@amd.com>,
	"Daniil Egranov" <Daniil.Egranov@arm.com>
Subject: Re: Negotiation Model
Date: Thu, 3 Dec 2026 10:55:24 -0600	[thread overview]
Message-ID: <axGe_H1hn8hzPAGW@shallyn-amd> (raw)
In-Reply-To: <a51133c7f35e3b4a9f838678919f763b1fadee7e.camel@gmail.com>

On Wed, Dec 02, 2026 at 03:31:52PM +0200, Artem Bityutskiy wrote:
> Hi,
> 
> let me reply only about CoCo negotiation model.
> 
> On Thu, 2026-11-19 at 22:35 +0000, Mathias Brossard wrote:
> > 
> > On Thu, Nov 19, 2026 at 11:27, Peter Xu wrote:
> > > Hopefully it shouldn't be anything complex. My current expectation is the
> > > migration thread should own the main iochannel (for bi-directional IOs) for
> > > a short while because the handshake needs talks back and forth, and it
> > > should forward the return path channel only until handshake done, then
> > > it'll become almost outgoing traffic like before (unless there's a postcopy
> > > afterwards).
> > 
> > 
> > We are looking to see how we can define for the CCA migration session
> > establishment to be routed over the NEGOTIATE command. So hopefully this
> > should be something that could be leveraged on Arm too.
> 
> # Terminology
> 
> First, let's agree on terminology. Serge suggested the word
> "negotiate" earlier, so let's try building the terminology around it.
> I used the TDX terms before ("setup session", "migration setup"), but
> I am fine with "negotiate" if folks like it. Let me know.

Right, I wasn't really thinking about it, I've just been calling it
negotiation bc the two sides have to vet each other and agree on a
key.

> This would be the generic Linux terminology. Each vendor can keep its
> own terms in its specs.
> 
> - Negotiation phase: the migration phase that establishes trust
>   between the source and destination, checks the migration policy, and
>   sets up the migration keys. It ends when both sides have the keys.
>   TDX calls it the "setup session", the AMD ARG (AMD Root Guest) spec
>   calls it "Pre-Migration", and Arm calls it "session establishment"
>   (per Mathias).
> 
> - Negotiation agent: a separate trusted entity that negotiates on
>   behalf of the migrated guest. Examples are TDX MigTD and AMD MA,
>   which are special TDX and SNP guests. As I understand from Mathias,
>   Arm CCA may have a similar agent too. The point is that negotiation
>   agents are not part of the kernel. From QEMU's point of view, they
>   are separate processes, and may or may not be VMs. The interface
>   between QEMU and negotiation agents is a separate topic.
> 
> - Agent binding: attaching a negotiation agent to the migrated guest.
>   The VMM does it when the guest is created, on both the source and
>   the destination. The binding is reflected in the guest attestation,
>   and only the bound agent can install the guest's migration keys.
>   TDX does it with TDH.SERVTD.BIND (optionally preceded by
>   TDH.SERVTD.PREBIND), AMD with SNP_LAUNCH_START_EX. Agent binding
>   needs a KVM interface, but it is part of guest creation, not of the
>   migration uAPI.
> 
> - Direct negotiation: the platform security component (e.g. the TDX
>   module) negotiates with its peer itself. QEMU drives it with
>   KVM_MIGRATE_NEGOTIATE, relays opaque blobs between the source and
>   destination, and provides an attestation quote when asked.
> 
> - Agent negotiation: negotiation agents on the source and destination
>   negotiate with each other, then install the migration keys into the
>   platform security component. QEMU of the migrated guest does not
>   take part and does not call KVM_MIGRATE_NEGOTIATE.

Oh.  FWIW I had assumed that for agent negotiation, qemu would still drive
the negotiation over its migration buffer using KVM_MIGRATE_NEGOTIATE
steps, and the hypervisor through the platform would communicate with
the agent.  Guess that's kind of silly.  But it was a simple way to
allow the qemu buffer to be used for it, so the MAs dont' have to
initiate their own connection.

> - KVM_MIGRATE_NEGOTIATE: the KVM ioctl command that drives direct
>   negotiation. QEMU calls it repeatedly until it returns "done". It is
>   not used with agent negotiation.
> 
> - KVM_MIGRATE_BEGIN: the KVM ioctl command that begins the migration
>   session after the negotiation phase, in both models. It transfers
>   the initial VM state, such as the VM identity and configuration,
>   which the destination uses to create the VM. TDX calls it the
>   "immutable state", and AMD ARG calls it the "guest context". It
>   requires the migration keys, so it fails if the negotiation phase is
>   not done yet.
> 
> - QEMU handshake: the early phase Peter mentioned, where the source and
>   destination QEMUs talk in both directions before migration starts.
>   It is a QEMU-level transport phase, also used for non-CoCo needs, and
>   not specific to the negotiation phase. With direct negotiation, the
>   KVM_MIGRATE_NEGOTIATE blobs are carried over the QEMU handshake. With
>   agent negotiation, the agents have their own transport.
> 
> Whether a guest uses direct or agent negotiation is decided by
> userspace when the guest is created: agent negotiation requires agent
> binding. So KVM does not need to decide or report it.
> 
> Notes:
> 
> - MigTD is mentioned here only as an example of agent negotiation. We
>   do not plan to work on MigTD support upstream for now. Our focus is
>   direct negotiation via the TDX module. This is also why I did not go
>   into agent binding details, but it looks like AMD will need it.
> 
> - AMD also has a variant where the negotiation logic runs inside the
>   migrated guest itself, in its SVSM. If KVM is the channel between
>   QEMU and the SVSM, I think this is direct negotiation: QEMU drives it
>   via KVM_MIGRATE_NEGOTIATE, and the SVSM installs the migration key
>   itself. Serge, is this how you see it?

Yes, that's exactly how I see it.

Mind you, agent negotiation would also be an option for us.  It's just
not the path we started down.

> # The negotiation phase model
> 
> ## Direct negotiation
> 
> QEMU calls KVM_MIGRATE_NEGOTIATE in a loop on both the source and the
> destination. Each call returns what QEMU should do next:
> 
> - send this blob to the peer
> - provide an attestation quote
> - done.

And "cancel/reject" ?

> 1. QEMU calls KVM_MIGRATE_NEGOTIATE. The first call may carry a
>    migration policy, which defines the rules for the migration, e.g.
>    which destinations are acceptable. Later calls carry the blobs
>    received from the peer. The policy is opaque to KVM, and its format
>    is vendor specific. For TDX, it is a JSON document provided by the
>    TD owner and, optionally, the platform owner.
> 2. KVM passes the input to the platform security component and returns
>    the next action: "send this blob to the peer" or "provide a quote".
> 3. QEMU does that, using the QEMU handshake for the peer messages, and
>    calls KVM_MIGRATE_NEGOTIATE again.
> 4. This repeats until KVM_MIGRATE_NEGOTIATE returns "done" on both
>    sides.
> 5. QEMU then calls KVM_MIGRATE_BEGIN.
> 
> The blobs are opaque to QEMU and KVM.
> 
> ## Agent negotiation
> 
> 1. When creating the guest,QEMU binds it to a negotiation agent,
>    on both the source and the destination.
> 2. QEMU asks the negotiation agents to start the negotiation, using
>    a QEMU<->agent API, which is not defined yet.
> 3. The negotiation agents negotiate with each other, using their own
>    transport, and install the migration keys into the platform
>    security component.
> 4. QEMU learns from the negotiation agent that the negotiation phase
>    is done, again via the QEMU<->agent API, and calls
>    KVM_MIGRATE_BEGIN.
> 
> The QEMU<->agent API is not part of the KVM uAPI.

So, if every platform is going to have such an API, do we want to
have a separate conversation on qemu-devel about a platform agnostic
API for that?

> The migration policy is the business of the negotiation agent, and
> QEMU and KVM do not see it.
> 
> So in both models, KVM_MIGRATE_BEGIN starts the migration. If it is
> called before the negotiation phase is done, it fails.
> 
> 
> > In theory, the session establishment could happen orthogonally (another
> > VMM), would we use a vendor error code to signal that
> 
> 
> I think the ioctl should return both:
> 
> - A generic errno, e.g. -ENOKEY, so QEMU can handle "negotiation not
>   done" the same way on all platforms.
> - The platform-specific status, in a field of the ioctl structure, for
>   details and debugging. For example, TDX returns
>   TDX_MIGRATION_DECRYPTION_KEY_NOT_SET, and AMD ARG returns
>   INVALID_GUEST. For Arm, it could be your UNFINISHED_NEGOTIATION.
> 
> Artem.

thanks,
-serge

  reply	other threads:[~2026-12-03 16:55 UTC|newest]

Thread overview: 113+ 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)
2026-12-04 12:31           ` Artem Bityutskiy
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) [this message]
2026-12-04  8:35                                     ` Artem Bityutskiy
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=axGe_H1hn8hzPAGW@shallyn-amd \
    --to=sergeh@kernel.org \
    --cc=Daniil.Egranov@arm.com \
    --cc=David.Kaplan@amd.com \
    --cc=Jon.Grimm@amd.com \
    --cc=Mahmoud.Adam@amd.com \
    --cc=Mathias.Brossard@arm.com \
    --cc=Steven.Price@arm.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=kai.huang@intel.com \
    --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=serge@hallyn.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.