From: Chao Gao <chao.gao@intel.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: <linux-coco@lists.linux.dev>, <x86@kernel.org>,
<kvm@vger.kernel.org>, <seanjc@google.com>, <pbonzini@redhat.com>,
<eddie.dong@intel.com>, <kirill.shutemov@intel.com>,
<dave.hansen@intel.com>, <dan.j.williams@intel.com>,
<kai.huang@intel.com>, <isaku.yamahata@intel.com>,
<elena.reshetova@intel.com>, <rick.p.edgecombe@intel.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
<linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [RFC PATCH 00/20] TD-Preserving updates
Date: Wed, 16 Jul 2025 15:30:33 +0800 [thread overview]
Message-ID: <aHdVGYxCP8s6ItTZ@intel.com> (raw)
In-Reply-To: <a7affba9-0cea-4493-b868-392158b59d83@paulmck-laptop>
On Mon, Jul 14, 2025 at 05:21:47PM -0700, Paul E. McKenney wrote:
>On Fri, Jul 11, 2025 at 04:04:48PM +0800, Chao Gao wrote:
>> On Fri, May 23, 2025 at 02:52:23AM -0700, Chao Gao wrote:
>> >Hi Reviewers,
>> >
>> >This series adds support for runtime TDX module updates that preserve
>> >running TDX guests (a.k.a, TD-Preserving updates). The goal is to gather
>> >feedback on the feature design. Please pay attention to the following items:
>> >
>> >1. TD-Preserving updates are done in stop_machine() context. it copy-pastes
>> > part of multi_cpu_stop() to guarantee step-locked progress on all CPUs.
>> > But, there are a few differences between them. I am wondering whether
>> > these differences have reached a point where abstracting a common
>> > function might do more harm than good. See more details in patch 10.
>
>Please note that multi_cpu_stop() is used by a number of functions,
>so it is a good example of common code. But you are within your rights
>to create your own function to pass to stop_machine(), and quite a
>few call sites do just that. Most of them expect this function to be
>executed on only one CPU, but these run on multiple CPUs:
>
>o __apply_alternatives_multi_stop(), which has CPU 0 do the
> work and the rest wati on it.
>
>o cpu_enable_non_boot_scope_capabilities(), which works on
> a per-CPU basis.
>
>o do_join(), which is similar to your do_seamldr_install_module().
> Somewhat similar, anyway.
>
>o __ftrace_modify_code(), of which there are several, some of
> which have some vague resemblance to your code.
>
>o cache_rendezvous_handler(), which works on a per-CPU basis.
>
>o panic_stop_irqoff_fn(), which is a simple barrier-wait, with
> the last CPU to arrive doing the work.
>
>I strongly recommend looking at these functions. They might
>suggest an improved way to do what you are trying to accomplish with
>do_seamldr_install_module().
Hi Paul,
Thanks for your feedback.
Let me clarify what do_seamldr_install_module() does. Patch 10 just adds the
skeleton (sorry for only directing you to patch 10). More functions are added by
subsequent patches. Specifically:
* TDP_SHUTDOWN (Patch 12)
Shut down the running TDX module on any CPU while other CPUs must be idle
* TDP_CPU_INSTALL (Patch 14)
Load a new TDX module on all CPUs serially
* TDP_CPU_INIT (patch 16)
Initialize the new module on all CPUs in parallel
* TDP_RUN_UPDATE (Patch 17)
Import metadata from the old module on any CPU while other CPUs must be idle
And there are two requirements:
1. These steps must be executed in a lock-stepped manner, meaning all CPUs must
complete step X before any CPU proceeds to step X+1.
2. If any CPU encounters an error, all CPUs should bail out rather than proceed
to the next step.
>
>> >2. P-SEAMLDR seamcalls (specificially SEAMRET from P-SEAMLDR) clear current
>> > VMCS pointers, which may disrupt KVM. To prevent VMX instructions in IRQ
>> > context from encountering NULL current-VMCS pointers, P-SEAMLDR
>> > seamcalls are called with IRQ disabled. I'm uncertain if NMIs could
>> > cause a problem, but I believe they won't. See more information in patch 3.
>> >
>> >3. Two helpers, cpu_vmcs_load() and cpu_vmcs_store(), are added in patch 3
>> > to save and restore the current VMCS. KVM has a variant of cpu_vmcs_load(),
>> > i.e., vmcs_load(). Extracting KVM's version would cause a lot of code
>> > churn, and I don't think that can be justified for reducing ~16 LoC
>> > duplication. Please let me know if you disagree.
>>
>> Gentle ping!
>
>I do not believe that I was CCed on the original. Just in case you
>were wondering why I did not respond. ;-)
My bad :(. I forgot to CC you when posting the series.
Btw, it seems that stop_machine.c isn't listed under any entry in MAINTAINERS.
I found your name by checking who submitted pull requests related to
stop_machine.c to Linus.
>
>> There are three open issues: one regarding stop_machine() and two related to
>> interactions with KVM.
>>
>> Sean and Paul, do you have any preferences or insights on these matters?
>
>Again, you are within your rights to create a new function and pass
>it to stop_machine(). But it seems quite likely that there is a much
>simpler way to get your job done.
>
>Either way, please add a header comment stating what your function
>is trying to do,
Sure. Will do.
>which appears to be to wait for all CPUs to enter
>do_seamldr_install_module() and then just leave?
Emm, do_seamldr_install_module() does more than just a simple barrier-wait at
the end of the series.
>Sort of like
>multi_cpu_stop(), except leaving interrupts enabled and not executing a
>"msdata->fn(msdata->data);", correct?
>
>If so, something like panic_stop_irqoff_fn() might be a simpler model,
>perhaps with the touch_nmi_watchdog() and rcu_momentary_eqs() added.
As said above, lockstep is a key requirement. panic_stop_irqoff_fn()-like
simple model cannot meet our needs here.
>
>Oh, and one bug: You must have interrupts disabled when you call
>rcu_momentary_eqs(). Please fix this.
Actually, interrupts are disabled in multi_cpu_stop() before it calls
msdata->fn (i.e., do_seamldr_install_module())
In this context, there are two state machines involved. The MULTI_STOP_RUN
state, part of the outer state machine, includes an inner state machine with
the following stages:
* TDP_START
* TDP_SHUTDOWN
* TDP_CPU_INSTALL
* TDP_CPU_INIT
* TDP_RUN_UPDATE
* TDP_DONE
I am concerned about the code duplication between do_seamldr_install_module()
and multi_cpu_stop(). But, I don't see a good way to eliminate the duplication
without adding more complexity. It seems you can also live with the duplication
if do_seamldr_install_module() truly requires another state machine, right?
prev parent reply other threads:[~2025-07-16 7:31 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 9:52 [RFC PATCH 00/20] TD-Preserving updates Chao Gao
2025-05-23 9:52 ` [RFC PATCH 01/20] x86/virt/tdx: Print SEAMCALL leaf numbers in decimal Chao Gao
2025-06-02 23:44 ` Huang, Kai
2025-05-23 9:52 ` [RFC PATCH 02/20] x86/virt/tdx: Prepare to support P-SEAMLDR SEAMCALLs Chao Gao
2025-06-04 12:22 ` Huang, Kai
2025-06-04 13:14 ` Chao Gao
2025-06-05 0:14 ` Huang, Kai
2025-05-23 9:52 ` [RFC PATCH 03/20] x86/virt/seamldr: Introduce a wrapper for " Chao Gao
2025-06-03 11:22 ` Nikolay Borisov
2025-06-09 7:53 ` Chao Gao
2025-06-09 8:02 ` Nikolay Borisov
2025-06-10 1:03 ` Chao Gao
2025-06-10 6:52 ` Nikolay Borisov
2025-06-10 15:02 ` Dave Hansen
2025-07-11 13:59 ` Sean Christopherson
2025-07-14 9:21 ` Chao Gao
2025-05-23 9:52 ` [RFC PATCH 04/20] x86/virt/tdx: Introduce a "tdx" subsystem and "tsm" device Chao Gao
2025-06-02 23:44 ` Huang, Kai
2025-06-05 8:34 ` Chao Gao
2025-07-31 20:17 ` dan.j.williams
2025-05-23 9:52 ` [RFC PATCH 05/20] x86/virt/tdx: Export tdx module attributes via sysfs Chao Gao
2025-06-02 23:49 ` Huang, Kai
2025-06-10 1:37 ` Chao Gao
2025-06-11 2:09 ` Huang, Kai
2025-06-11 7:45 ` Chao Gao
2025-05-23 9:52 ` [RFC PATCH 06/20] x86/virt/seamldr: Add a helper to read P-SEAMLDR information Chao Gao
2025-05-23 9:52 ` [RFC PATCH 07/20] x86/virt/tdx: Expose SEAMLDR information via sysfs Chao Gao
2025-07-29 4:55 ` Xu Yilun
2025-07-29 10:00 ` Chao Gao
2025-07-31 21:01 ` dan.j.williams
2025-08-01 2:07 ` Xu Yilun
2025-08-01 15:24 ` dan.j.williams
2025-08-04 7:00 ` Xu Yilun
2025-08-05 0:17 ` dan.j.williams
2025-08-05 0:47 ` Sean Christopherson
2025-08-05 4:02 ` dan.j.williams
2025-08-05 13:49 ` Sean Christopherson
2025-08-06 16:33 ` dan.j.williams
2025-08-06 3:03 ` Xu Yilun
2025-05-23 9:52 ` [RFC PATCH 08/20] x86/virt/seamldr: Implement FW_UPLOAD sysfs ABI for TD-Preserving Updates Chao Gao
2025-06-16 22:55 ` Sagi Shahar
2025-06-17 7:55 ` Chao Gao
2025-05-23 9:52 ` [RFC PATCH 09/20] x86/virt/seamldr: Allocate and populate a module update request Chao Gao
2025-05-23 9:52 ` [RFC PATCH 10/20] x86/virt/seamldr: Introduce skeleton for TD-Preserving updates Chao Gao
2025-05-23 9:52 ` [RFC PATCH 11/20] x86/virt/seamldr: Abort updates if errors occurred midway Chao Gao
2025-06-03 12:04 ` Nikolay Borisov
2025-06-09 2:37 ` Chao Gao
2025-05-23 9:52 ` [RFC PATCH 12/20] x86/virt/seamldr: Shut down the current TDX module Chao Gao
2025-06-03 12:36 ` Nikolay Borisov
2025-06-09 2:10 ` Chao Gao
2025-05-23 9:52 ` [RFC PATCH 13/20] x86/virt/tdx: Reset software states after TDX module shutdown Chao Gao
2025-05-23 9:52 ` [RFC PATCH 14/20] x86/virt/seamldr: Install a new TDX module Chao Gao
2025-05-23 9:52 ` [RFC PATCH 15/20] x86/virt/seamldr: Handle TD-Preserving update failures Chao Gao
2025-05-23 9:52 ` [RFC PATCH 16/20] x86/virt/seamldr: Do TDX cpu init after updates Chao Gao
2025-05-23 9:52 ` [RFC PATCH 17/20] x86/virt/tdx: Establish contexts for the new module Chao Gao
2025-05-23 9:52 ` [RFC PATCH 18/20] x86/virt/tdx: Update tdx_sysinfo and check features post-update Chao Gao
2025-05-23 9:52 ` [RFC PATCH 19/20] x86/virt/seamldr: Verify availability of slots for TD-Preserving updates Chao Gao
2025-05-23 9:52 ` [RFC PATCH 20/20] x86/virt/seamldr: Enable TD-Preserving Updates Chao Gao
2025-06-11 19:56 ` [RFC PATCH 00/20] TD-Preserving updates Sagi Shahar
2025-07-11 8:04 ` Chao Gao
2025-07-11 14:06 ` Sean Christopherson
2025-07-14 10:26 ` Chao Gao
2025-07-15 0:21 ` Paul E. McKenney
2025-07-16 7:30 ` Chao Gao [this message]
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=aHdVGYxCP8s6ItTZ@intel.com \
--to=chao.gao@intel.com \
--cc=bp@alien8.de \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=eddie.dong@intel.com \
--cc=elena.reshetova@intel.com \
--cc=hpa@zytor.com \
--cc=isaku.yamahata@intel.com \
--cc=kai.huang@intel.com \
--cc=kirill.shutemov@intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@kernel.org \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).