All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kishen Maloor <kishen.maloor@intel.com>
To: Tony Lindgren <tony.lindgren@linux.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, 16 Sep 2026 20:31:32 -0700	[thread overview]
Message-ID: <3ee06a84-2c4b-4b2f-9899-68fc92b6daf7@intel.com> (raw)
In-Reply-To: <aqoknAli8A0Mc4HR@tlindgre-MOBL1>

On 9/15/26 10:09 PM, Tony Lindgren wrote:
> On Tue, Sep 15, 2026 at 08:53:18AM -0700, Kishen Maloor wrote:
>> On 9/14/26 9:44 PM, Tony Lindgren wrote:
>>> On Mon, Sep 14, 2026 at 05:14:32PM -0700, Kishen Maloor wrote:
>>>> On 9/10/26 9:23 PM, Tony Lindgren wrote:
>>>>> On Thu, Sep 10, 2026 at 06:40:04PM -0700, Kishen Maloor wrote:
>>>>>> On 9/9/26 11:33 PM, Tony Lindgren wrote:
>>>>>>> On Wed, Sep 09, 2026 at 06:11:11PM -0700, Kishen Maloor wrote:
>>>>>>> ...
>>>>>>>>
>>>>>>>> As mentioned above, that is a destination launch time directive that we needn't
>>>>>>>> conflate with a migration/transfer session role.
>>>>>>>
>>>>>>> It's still the same role though. Yes we can set it on init, but would
>>>>>>> be nice to have some generic way to do it for qemu -incoming.
>>>>>>
>>>>>> I'd separate these.
>>>>>>
>>>>>> On the role: it seems we agree on recording roles per-session. My only point
>>>>>> then is that a VM created through the delayed_init flow doesn't additionally
>>>>>> need a destination role recorded for it if SETUP will assert one when the
>>>>>> migration is kicked off.
>>>>>>
>>>>>> On generic plumbing for -incoming: is this about KVM_TDX_INIT_VM_F_DELAY_INIT?
>>>>>> A generic mechanism would make sense to me if the flag were consumed by generic
>>>>>> KVM code, but that isn't the case here. Userspace has to make a
>>>>>> vendor-specific VM-init call like KVM_TDX_INIT_VM anyway, with the flag passed
>>>>>> on that call. So I'm not sure what a generic version would add, unless you have
>>>>>> something else in mind.
>>>>>
>>>>> So we could add a SETUP subcommand SET_ROLE or SET_INCOMING.
>>>> It might be better to pass the role as a parameter of the SETUP call
>>>> rather than a separate SET_ROLE call.
>>>> A separate SET_ROLE would bring its own ordering rules relative to the
>>>> other SETUP sub-commands. 
>>>
>>> OK a flag for SETUP sounds good to me. SETUP is needed anyways for each
>>> migration session.
>>
>> To be clear, I was suggesting a field in kvm_migrate_cmd and not a flag to pass
>> the role as an argument to SETUP. As I mentioned in my last comments (right 
>> below), 'flags' in the current proposal carry the vendor-defined sub-command values,
>> so a generic role argument wouldn't belong there.
> 
> I was thinking 8 bits for common flags and 8 bits for vendor flags but
> yeah that can be a bit tight. Sorry if the SETUP above caused extra
> confusion.
> 
> So trying to summarize the common flags for the role and separate vendor
> flags:
> 
> struct kvm_migrate_cmd {
> 	__u16 command;
> 	__u16 flags;
> 	__u16 vflags;
> 	__u16 reserved;
> 	__u32 reserved;
> 	struct kvm_transfer_buffer buf;
> };
> 
> Is the above along the lines what you were thinking?

No, I was suggesting a 'role' field carved out of the 'reserved' space,
like this:

struct kvm_migrate_cmd {
      __u16 command;
      __u16 flags;
      __u8  role;     /* 0 = unset, 1 = source, 2 = destination */
      __u8  reserved[3];
      struct kvm_transfer_buffer buf;
};

We haven't defined any generic flags. Thus far in this proposal 'flags'
contains only vendor-defined sub-command values.

>   
>>>> The specific role (src or dst) still needs someplace to go, and flags is
>>>> already the sub-command selector. An option is to carve out room in
>>>> the __u32 reserved field to carry a role argument, something
>>>> like 0=unset, 1=src, 2=dest so KVM can verify that a role was indeed set.
>>>
>>> To me it seems that 0=src can be the natural default starting point, I
>>> don't think we need 0=unset.
>>
>> With 0=src, the field would only carry information when it's a destination,
>> thereby making it an is_dest boolean rather than a role. It would also mean any 
>> VM that never established a session still reads as a source, so a 
>> KVM_TRANSFER_MEMORY aimed at the wrong VM by buggy or rogue userspace would get 
>> dispatched to the export path instead of rejected outright. The generic 
>> dispatcher shouldn't have to rely on the vendor layer to catch that. Reserving 0 
>> for 'unset' costs nothing and lets KVM reject a session that never stated a 
>> role.
> 
> Ah OK, yes that would also tell "the hardware has been initialized to a
> certain migration role". That seems like a usable common feature.

Not quite. It tells us that userspace asserted a role for this VM's migration
session. Whether a TD was created for import is a separate, vendor-level detail.
The generic layer only needs the role to reject a session that never stated one,
and to pick the export or import callback. That callback then knows which side
it's on and can reject an incorrect role (e.g., if SETUP asserted dst for a src TD).

>  
>>>> It could further be written into a generic KVM struct (kvm_arch or kvm) which
>>>> could be queried on KVM_TRANSFER_MEMORY, etc. to identify the relevant
>>>> callback.
>>>
>>> Yeah eventually some generic place for it would be nice. But that's easy
>>> to add later on too.
>>
>> Sure, we don't have to decide now as we're still discussing the UAPI.
>> But we'd want this detail also settled sometime before we call the UAPI
>> complete as it determines whether the dispatch is generic.
> 
> Yes a shared place for the role would make some generic sanity checks
> easier.

Agreed. The field above is just an argument to SETUP. Where that role gets stored
for KVM's top-level dispatcher to check is the detail we can settle later.

  reply	other threads:[~2026-09-17  3:31 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 [this message]
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-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=3ee06a84-2c4b-4b2f-9899-68fc92b6daf7@intel.com \
    --to=kishen.maloor@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=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=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.