Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796207486; b=FW0WOREJIcEOynZrteU677WVAWNAtlBfOQQevPvVbO1bd4FTIYnQdpEvtTfhtx0i02tJ 066pX1Ji9XIN1enHdxUwx4Fab9HMIDvRGwrl2vpqLtc6FNcleIwQu2Nj6gok32vUsjDep v1FA/3+ZV5U1f3lpnkq+98ukJ3V8zu8YiUH09KIW15BxmOq6uxlIEZ9sgBVmQ27L+xC8I 89ONDedWVG9rtd0hcnS8k9aMu1TnSWNE5HCnhnY5J8vkYJNr9TBe6n+HkF2jpHV17lK7Z O74HAVMHCoFIX6wPK90GxkD+obBK2l8CDEeRmA7FEGl3p9nz/NYGVFSrCZzJlxkwAQw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796207486; 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=+bISUPV9vqFffoWMWzzpOZc8ncUMv0VOb8odWMakG2U=; b=xaw9CQtJzl/8Z2i01uVz6cXeIrVLFFNml4qt72fKYHAQ74YWt9oehcrhV1ESVM2/JEvT B08Aksqtpxm2VHIG8aH2USEs+h7ZJ5tdClTFE9AQvEr81WesDjJQjBmF+zXI4Q1ch+JTo 1xm7ZSuW/HaEMQewB+buslNgL7tJmNRt5kI0Q/sIg0PwOC5ly8eJhS3GtAp79ZF2/YGDd /a469DHEU7Jai3nkpiPLw4hivPvHQwmPofuj0lhGTawZHSsYSXhdLUj3i0Ss6lD37d6ko 0ulV4gxKLxFKN1WXiYohKA1o0ApcpCODFfQ9GyiHCpy/e1HJIE19KCwgPWs4OmciEmA== 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=memvA1Ba; arc=none smtp.remote-ip=209.85.128.43 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 88104606A31A for ; Wed, 2 Dec 2026 10:31:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 88104606A31A 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=memvA1Ba Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4bb6ba3b244so132411465e9.3 for ; Wed, 02 Dec 2026 02:31:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796207484; x=1796812284; 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=+bISUPV9vqFffoWMWzzpOZc8ncUMv0VOb8odWMakG2U=; b=memvA1BaXTPdDpIsUG+sriGq4QL3tBJchxaxf89orozhsWSZO7TVude0O9mV+VANEe yFlMC9Yb2qY5CbbOSEBZZqj1+EW2sw/6SbQjOr2ENmLblB4WBzTptgZVfoDGoH6IlR0d x5W+/+naYIU2SGI3M4WkDCfLoJnYzPAT0xH3zt1Yhiugxzvuxt2uir/Yp5aOpBQDgxIC 0Ce2HFGwO9Kn1X5Y4Zh6QN8x2Id8hvXyAsw8aIsrCFVLBYc1FM5Cq0IXskwoDz2xSSly 5mq5TxXKJCWHXQR39n1s7FfyxP+yTeWueSfpqKlYM0qDhOXBW7++MTsCoNECZ2v5EBC8 SN/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796207484; x=1796812284; 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=+bISUPV9vqFffoWMWzzpOZc8ncUMv0VOb8odWMakG2U=; b=ln5T56+dEm4tnfe5S8sZXuMxUYL8Y1ElIKsHDswCGMmDELgjaMPqnALX7NDCFbQaof j08/+RXeBsiZiCNS9artE6epYw4anmtvryEJgZ5rc0UoGVVi02ebLR89VAy3pqHjEf8H ajWHkR/AraoSBVdTEas5X5icuCtHK7lH+q1Ytf9aCjJo21mm8FhhKegYl+b3npaLqf4M LztfxkR1dSkQahJz2Vt+cmwwHGEhqv2vzGVoN41NywwCSD0oviNxbkDtKFYCckApO4Df yAq/bwdHIKLNClcT7+m7904nYUyEB+O5TRP7sMEc7a7rkEz8T9lMHrZJ8YHKxfR87yMs G1Tg== X-Forwarded-Encrypted: i=1; AL+hErGXcQMI44bKh+bWzo7b/KlseaXcYGu06yZR3zmeryGZWXfIe5QLo7A2Gz/a4q5iYADU6dA=@vger.kernel.org X-Gm-Message-State: APuU4Z8C33r/04R95OR/wYDtUf/fKABTLmeP+UnZbnHcDEZMecEFK5vh ncrBIGLx/J1scKel1hhfQgak5Y4QlS1FDX3A1ECCtNguskGalYYnR7HQ X-Gm-Gg: AZFdTZfaV0fZUwsJrHhg/xhjWHc2p0OfgNX4Ujn+e4JNJPqry97N1E9aom3F4Hu+c17 2+Xm8Au4jO0UluFapsQnnHmQHu/eLu27jrLcjPzWVq2xu9ReQrHZpHzRzZ8JVLuSLJ4Kfs17Ys+ NNXJfP/w8hzJ8wcqGgapyf+XFil2sa9R3Tojxgzb5yX/S302WnLCfi0yREhrnfkVWon1a3nzf3W zqZkVzBQXgeJxBBHlyhACuYg7qeD+nipkFltZ2CVF0pbCA9h1CjL1IB5emjFZzuSaoKF9uX89lF 76gTAzS9g98q9KedZLwMVSG27xM+SrvNSTFG4HCfURjQGzJHizEi2bP39sxsEVvWUjBtuMAfuoT oEjmyykBFjO2SC0gjqh+PpCnWhfTC3+q6s1lw0RI9G+0OozU5uq1AMl3CXKKVqsWKx/LMY8eTal iJRomH8DlIjNFl8snEQ+z6zXqwbM5ns8ibVm1F0augjyVkJyw0i7C3B9t1JddJ97u/c87yHmCvP IskrHG/ngXUuSoZsubeMATY54BHCsesS2IE7Q0s/Wp8oZh8cA5HJHPSkbduFiYqSK9nYmWp31sW nGYhyesf9etNzf9mZSx5/2v13aiTCltU X-Received: by 2002:a05:600c:848d:b0:4a5:1cf1:b7bd with SMTP id 5b1f17b1804b1-4bb88810b2dmr768234325e9.16.1796207483754; Wed, 02 Dec 2026 02:31:23 -0800 (PST) Received: from [10.245.245.124] ([192.198.151.45]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884ab091sm1471134135e9.11.2026.12.02.02.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 02:31:23 -0800 (PST) Message-ID: <4aba17135640e38f41b714b36d3db4807194c843.camel@gmail.com> Subject: Re: [RFC PATCH v2 2/4] KVM: x86: Add optional KVM_CAP_LIVE_MIGRATION and KVM_MIGRATE_CMD From: Artem Bityutskiy To: "Serge Hallyn (AMD)" 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?Q?R=C5=AF=C5=BEi=C4=8Dka?= , =?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 Date: Wed, 02 Dec 2026 12:31:19 +0200 In-Reply-To: References: <20260831071304.762939-1-tony.lindgren@linux.intel.com> <20260831071304.762939-3-tony.lindgren@linux.intel.com> <74c6eec32fec9b7db75a8b4cd7f8e00d581eab5f.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 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; > > > +}; > >=20 > > In addition to dropping 'struct kvm_transfer_buffer', we need=C2=A0sepa= rate > > input=C2=A0and output buffers. Reasons: > >=20 > > =C2=A0 - TDX requires them to be separate: using one buffer for both do= es not work > > =C2=A0=C2=A0=C2=A0 in corner cases such as update-while-setup. > > =C2=A0 - We can't assume other CoCo implementations can use the input b= uffer as > > =C2=A0=C2=A0=C2=A0 the output buffer either. >=20 > Indeed.=C2=A0 I figured that at least for AMD the sev driver would take c= are > 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.=C2=A0 The same is of course true for AMD (you can se= e > the details for SNP_ARG_EXPORT_PAGE in chapter 6 at > https://docs.amd.com/api/khub/documents/Gzue7GL~KH3204rrtW369g/content=C2= =A0) > and I would imagine every implementation would export some metadata. > So, do we actually want three buffers?=C2=A0 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-m= igration-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. 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. Thoughts?