From: Tony Lindgren <tony.lindgren@linux.intel.com>
To: Kishen Maloor <kishen.maloor@intel.com>
Cc: "Artem Bityutskiy" <dedekind1@gmail.com>,
"Jörg Rödel" <joro@8bytes.org>,
"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>,
"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
Subject: Re: [RFC PATCH v2 2/4] KVM: x86: Add optional KVM_CAP_LIVE_MIGRATION and KVM_MIGRATE_CMD
Date: Wed, 23 Sep 2026 09:04:07 +0300 [thread overview]
Message-ID: <arNr18dSS5P6Kf4e@tlindgre-MOBL1> (raw)
In-Reply-To: <1f481f4a-716d-47fd-97b1-8fa872d39797@intel.com>
On Tue, Sep 22, 2026 at 05:38:43PM -0700, Kishen Maloor wrote:
> On 9/21/26 10:25 PM, Tony Lindgren wrote:
> > On Mon, Sep 21, 2026 at 08:57:45PM -0700, Kishen Maloor wrote:
> >> On 9/20/26 11:52 PM, Tony Lindgren wrote:
> >>> Then for KVM tracking the role, I don't think we need it with the two
> >>> above. The role tracking can always be added if really needed. Any other
> >>> opinions on this one?
> >>
> >> I do think it's useful for generic KVM to track this role (1 byte).
> >> - It lets _TRANSFER_ style calls dispatch directly to import or export
> >> callbacks based on the role.
> >> - Even if we don't adopt the _TRANSFER_ style, it enables generic KVM to
> >> reject mismatched calls, e.g., KVM_EXPORT_MEMORY on a destination.
> >
> > Having KVM do generic checks on the calls is a good idea. There might be
> > a simpler way of handling it though. Rather than having KVM track the
> > migration state, how about we add a function to check for the migration
> > session state from the vendor code?
> >
> > So something like this for the states you suggested earlier:
> >
> > enum kvm_lmstate {
> > KVM_LM_NONE,
> > KVM_LM_SOURCE,
> > KVM_LM_DESTINATION,
> > };
> >
> > With something like this to get the state from the vendor code:
> >
> > enum kmv_lmstate kvm_arch_get_lmstate(struct kvm *);
> >
> > For x86 it would end up calling kvm_x86_call(get_lmstate)(kvm) and for
> > the TDX specific case tdx_get_lmstate().
>
> How is this simpler? It trades one byte in a KVM struct for a new generic
> enum, a new kvm_arch_get_lmstate(), a new kvm_x86_ops entry, and a vendor
> implementation per vendor, plus a cross-layer call on every command just
> to learn the role.
> Directly checking a stored byte (0=unset/1=src/2=dst) seems simplest, no?
It would avoid dragging KVM into the "track the migration state" business
at least for now.
I guess the question in general is: What does KVM need to do with the
migration role beyond generic checks on the migration related calls?
> > It would allow KVM to do the generic checks for the migration related
> > calls you're describing. And having KVM start tracking the state can be
> > still added later on too if it is needed.
>
> I think we'd need to pick one way or the other before the UAPI settles
> if we want generic KVM to reject mismatched calls. OTOH if we want to
> defer this generic KVM validation, then yeah, it could be settled later.
>
> >
> >>> The transfer direction is there with the EXPORT/IMPORT naming. Maybe
> >>> just let's keep that naming for easier readability rather than try to
> >>> switch to TRANSFER style naming. No transfer direction flag needed.
> >>
> >> I can't say I have a clear preference between EXPORT/IMPORT vs _TRANSFER_.
> >> If we keep the EXPORT/IMPORT naming, then consistency would arguably call for
> >> splitting MIGRATE_CMD too, which makes it 6 vs 3 (or 5 vs 3 against the RFC
> >> as posted):
> >>
> >> EXPORT/IMPORT style _TRANSFER_ style
> >> KVM_EXPORT_CMD KVM_MIGRATE_CMD
> >> KVM_IMPORT_CMD
> >> KVM_EXPORT_MEMORY KVM_TRANSFER_MEMORY
> >> KVM_IMPORT_MEMORY
> >> KVM_EXPORT_VCPU KVM_TRANSFER_VCPU
> >> KVM_IMPORT_VCPU
> >
> > Agreed we should split the MIGRATE_CMD too. Probably the number of ioctls
> > is not and issue compared to following the KVM style and better
> > readability. So my vote is now on EXPORT/IMPORT style naming.
> >
> >> I guess the main benefit of the _TRANSFER_ style is reduced duplication.
> >> Each EXPORT/IMPORT pair takes the same struct and differs only by the role
> >> that the session already knows. Merging them gives one entry point per call
> >> type and lets userspace drive both ends from the same call site which could
> >> be considered a win. It doesn't reduce kernel code though as the top-level
> >> handler still branches internally on the role.
> >
> > Yup not much of a win for the TRANSFER style naming.
>
> Yeah, my goal was just to enumerate alternatives for consideration.
>
> One other benefit of KVM_EXPORT_CMD/KVM_IMPORT_CMD is that the per-session
> role is implicitly conveyed - in other words, a successful KVM_EXPORT_CMD/SETUP
> (for e.g.) would indicate that this is a 'source'. So, we wouldn't require a 'role'
> field in struct kvm_migrate_cmd to explicitly assert one during SETUP.
Yes good point with the KVM_EXPORT/IMPORT_CMD, that sounds good to me.
> > Trying to summarize again after we sorted out the direction flag issue in
> > the transfer:
> >
> > role per migration session (cannot change during the migration)
> > direction per command, EXPORT/IMPORT
> > hardware state set and tracked by vendor specific code
>
> The 'role' and 'direction' as you define it above are essentially saying the
> same thing - a source only invokes the vendor's EXPORT call, a destination only
> invokes the vendor's IMPORT call, and the role doesn't change over the session.
> If a destination needs to send data to be consumed by the source, then that
> still invokes the vendor's EXPORT call.
Yup.
> > And checking again against the dmaengine analogy:
> >
> > Compared to dmaengine, the migration role is modeled similar to the dma
> > channel configuration.
> >
> > The migration direction with EXPORT/IMPORT is modeled similar to
> > dmaengine_prep_slave_sg().
> I'll leave the dmaengine comparison to you, I don't know that API well enough
> to map it properly :)
Heh just a sanity check for trying to relate this to something existing.
next prev parent reply other threads:[~2026-09-23 6:04 UTC|newest]
Thread overview: 85+ 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-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 [this message]
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-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-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-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=arNr18dSS5P6Kf4e@tlindgre-MOBL1 \
--to=tony.lindgren@linux.intel.com \
--cc=Jon.Grimm@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=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=steven.price@arm.com \
--cc=thomas.lendacky@amd.com \
--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