Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796218321; b=cB0HbueJ7ekeZvZTuYUOxgHha0vK5AJXs4XqucApFS0V0KXcyqbsM983ATq9mT35dYMz P/NA25LFjgE4tqccDQtB6m1JhA9aEwn5POo5/SqpX8BoyCp3D+ggoMUqik6YtXxWOx6mW T/YmeqhU838BvsTCIIpz4hsfZxFMoYHyd6rPmBSAoHMwkHQjumNqPjpU+azKq6sEvK0j1 Is7GTDg382UOX/C0o5muxWEH1+iV4HJTDXmcvwUEtCJ/eDoAqBV6dOfpIyhzHnf+HCNMl PoB0KAIi9rKgRd4JI504NxhssbgmyYiiB64bqab2m+XmQM139qROsHKO1cPJ7dNvp5A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796218321; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:Content-Transfer-Encoding:User-Agent:MIME-Version; bh=XE1PPw29xOVcaKmrIcmIuFkECs9hDUQ2HZ7rfoO6i/0=; b=4eZ6PMBqQsNetCimshYAB+2ALMePj+Rs2BGRuwue1S1d+lL6yMKaycTvZ/gnmQEEWsKV +tXUSVxZvUWktO7EUpprDafpKV+3G616HW2LzbUkJh8X1Jt1MdPmYVgIWgdG44XMc4iFJ PSH/wjKzlS5qDeL//jqQqo8B1rfkSJTUVvYdXDPNLF++1CADWQl5JX9wgt/OcW/ZZwgeZ SZzIaMyGFufMmdgYGKmlh57N8zFo1SRcjVqcJbSA9GJjgDeaDCFsl0v+S5HUexGDGe2UF nDLIj8k4UHlGq/w85Pu6c+mYF8G9FsFXgMW/ptPPGv3lNiA7DuEykdNWRPKuVdnqi9Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=x+F7EVRQ; arc=none smtp.remote-ip=209.85.208.50 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAD73606A31A for ; Wed, 2 Dec 2026 13:32:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AAD73606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=x+F7EVRQ Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-6baa6f27904so14459140a12.0 for ; Wed, 02 Dec 2026 05:32:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796218319; x=1796823119; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to:content-type; bh=XE1PPw29xOVcaKmrIcmIuFkECs9hDUQ2HZ7rfoO6i/0=; b=x+F7EVRQzeI4Vo4l6DRAgJ6CM5bHQ/Yh5Olfy2gPiRGFT22fxVqwmsJ32lNFucId/z Mbmzzyh7AUdz6GN21KRWvw9GmuTOs09mhWv4+Ul7uaOviVZQh7CNEMcTLLBzU58J53sf U7ZStYSBiIWmrPMfqYoah3GDkm3q69LJ84jl3tes3VQCPie5RkhHdjTMfhlGV5Y3B5VY 8dkIyGTb+hHvniO+3F9Jsr/OCV67F8vm1ffhLnEQkiCX3RYdxHfW/R+N2dieruHmAnJg d76z7RoLbmFvuoM4ZJ7jEQoVshBByFRlsIaDZEvQkOodFz1KgxZYadeLvGF5i9DwWbg4 qJUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796218319; x=1796823119; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=XE1PPw29xOVcaKmrIcmIuFkECs9hDUQ2HZ7rfoO6i/0=; b=sr0XrAeGryck9KgH4QropHp4N05qsCiwramvFStiRPCl3rPRnEKM3AQZLAO9lovVHg GndJMWYW6YxpHnV9214bIqeRGNU2UXeBuHpuggBzneCUtudg5oG8pFYmK6ww/xuFIGu8 +xTCDGHde3NSDpOiePQqMMF+MUrWLmp7hZLNsoBISZLk2uHzVukBerXjDDuxbxEob+EQ IVzPUuHCXJ5lyiJoC2R1Y+FZccEACbpxeONPBg1wmhzPsK+ZyLySbWADPsHztnXPvZKk +PUo92B6cIpRLpLzqUiyx7i07RmQmcvU47sbWaZlQNvyZXUO8frh83YcIuTqJXkvcHG7 6psA== X-Forwarded-Encrypted: i=1; AL+hErFO47iWRbsp1Z7JyC6UIyRriPPa/aFpPbf1+8aHnvIEM1NGZjxTZzcnKMBiY1ih4SUYItE=@vger.kernel.org X-Gm-Message-State: APuU4Z9/yPLXJaeM6vGex51LApgZxFqTcE9U+iIeBvb7YfdKkefJyTlb z/sGfI5JFelM/h0ZrturEIXSfrRiGK3g+2vRoSAG00hrWVhqSY0auvzN X-Gm-Gg: AZFdTZe6C1BNiiOJjw+4/844YgUOEtVihZQY/BMf0jkwahsPImfHC7DZa6bpf/VCPWw 2HsGBSFuFNr6svz/OPQa45LmjvZWrawfhkBo4NOkuZ2SO7TMOxtBXMsJeL/XXdb0Xe21igbZIKq yavkH/J6IjSvP+YAX0nKK+6XKtahquMG3dL9jnpZL7Scg9i4PULmRdQcX6BL5idKTILq5ybln8o 7XNsaoDtNdHMnnPk1jGI0LPFiKUEmvVZ6dQWZYPI76aVlEo+8JdIO5wt4BTr1jkLDpoky3yUit/ YOeIahO7TrWHoPmYsCKMsmZ5GM3NxBC2SEEsdlHqdidMZ/pQl86oZFIk5FGYRIrIyEuOQVJsrUF /qXgtwp9UU4NRy0vEymYile6NHrtAco++ZwnncVHZAh1M22Ba7B4Dv0EPfQNY9xg5kbRmN4Bbxz jOyWV5QJ92F7OiUXE/rXPQwrCs2akORk8tapzexbZVVaZyV7+tFLzdfoJ5FDluneyw2uN/pX5F5 ejdApafDauoPXqmVofF8Fw5DUyLi947K0uxy1NLNQPrRfZO7Ir5V7zGqdiTfAT3x4IiY+EB9Jcq I39oeL1FEstIKY+3VaYAn8XqT+0/WGqY X-Received: by 2002:a05:6402:2046:b0:6b7:e902:5dfd with SMTP id 4fb4d7f45d1cf-6ba37ed33cdmr24539505a12.41.1796218318592; Wed, 02 Dec 2026 05:31:58 -0800 (PST) Received: from [10.245.245.124] ([192.198.151.45]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6bc6192392fsm730361a12.15.2026.12.02.05.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 05:31:58 -0800 (PST) Message-ID: Subject: Re: Negotiation Model From: Artem Bityutskiy To: Mathias Brossard , Peter Xu , "Serge Hallyn (AMD)" Cc: Tony Lindgren , Kishen Maloor , "Serge E. Hallyn" , Paolo Bonzini , Sean Christopherson , Fabiano Rosas , Jon Grimm , Pankaj Gupta , Tom Lendacky , Marc Zyngier , Oliver Upton , Steven Price , Anup Patel , Samuel Ortiz , Jakub =?UTF-8?Q?R=C5=AF=C5=BEi=C4=8Dka?= , =?ISO-8859-1?Q?J=F6rg_R=F6del?= , Vishal Annapurve , Elena Reshetova , Kai Huang , Mika Westerberg , Peter Fang , Rick Edgecombe , Xiaoyao Li , Xu Yilun , "kvm@vger.kernel.org" , "David.Kaplan@amd.com" , "tycho@kernel.org" , "Adam, Mahmoud" , Daniil Egranov Date: Wed, 02 Dec 2026 15:31:52 +0200 In-Reply-To: References: <85f899cd277b2188cd4b33f8f21b206fa2ff6f6f.camel@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-3.fc44) 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 Hi, let me reply only about CoCo negotiation model. On Thu, 2026-11-19 at 22:35 +0000, Mathias Brossard wrote: >=20 > On Thu, Nov 19, 2026 at 11:27, Peter Xu wrote: > > Hopefully it shouldn't be anything complex. My current expectation is t= he > > 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 post= copy > > afterwards). >=20 >=20 > 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. 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. - 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? # 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. 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. 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.