[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aWdymkCJrSG+zMfz@yilunxu-OptiPlex-7050>
Date: Wed, 14 Jan 2026 18:40:26 +0800
From: Xu Yilun <yilun.xu@...ux.intel.com>
To: Chao Gao <chao.gao@...el.com>
Cc: linux-coco@...ts.linux.dev, linux-kernel@...r.kernel.org,
x86@...nel.org, reinette.chatre@...el.com, ira.weiny@...el.com,
kai.huang@...el.com, dan.j.williams@...el.com, sagis@...gle.com,
vannapurve@...gle.com, paulmck@...nel.org, nik.borisov@...e.com,
Farrah Chen <farrah.chen@...el.com>,
"Kirill A. Shutemov" <kas@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH v2 13/21] x86/virt/seamldr: Abort updates if errors
occurred midway
On Tue, Sep 30, 2025 at 07:52:57PM -0700, Chao Gao wrote:
> The TDX Module update process has multiple stages, each of which may
> encounter failures.
>
> The current state machine of updates proceeds to the next stage
> regardless of errors. But continuing updates when errors occur midway
> is pointless.
>
> Add support of transitioning directly to the final stage on errors,
> effectively aborting the update and skipping all remaining stages.
>
> Signed-off-by: Chao Gao <chao.gao@...el.com>
> Tested-by: Farrah Chen <farrah.chen@...el.com>
> ---
> arch/x86/virt/vmx/tdx/seamldr.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/virt/vmx/tdx/seamldr.c b/arch/x86/virt/vmx/tdx/seamldr.c
> index b074630d42e3..fca558b90f72 100644
> --- a/arch/x86/virt/vmx/tdx/seamldr.c
> +++ b/arch/x86/virt/vmx/tdx/seamldr.c
> @@ -235,6 +235,7 @@ enum tdp_state {
> static struct {
> enum tdp_state state;
> atomic_t thread_ack;
> + atomic_t failed;
> } tdp_data;
>
> static void set_target_state(enum tdp_state state)
> @@ -249,8 +250,16 @@ static void set_target_state(enum tdp_state state)
> /* Last one to ack a state moves to the next state. */
> static void ack_state(void)
> {
> - if (atomic_dec_and_test(&tdp_data.thread_ack))
> - set_target_state(tdp_data.state + 1);
> + if (atomic_dec_and_test(&tdp_data.thread_ack)) {
> + /*
> + * If an error occurred, abort the update by skipping to
> + * the final state
> + */
> + if (atomic_read(&tdp_data.failed))
> + set_target_state(TDP_DONE);
Could we immediately move to TDP_DONE once the error happens, i.e. no
need to get all ack for current state?
> + else
> + set_target_state(tdp_data.state + 1);
> + }
> }
----8<-----
static void ack_state(void)
{
if (atomic_read(&tdp_data.failed)) {
set_target_state(TDP_DONE);
return;
}
if (atomic_dec_and_test(&tdp_data.thread_ack))
set_target_state(tdp_data.state + 1);
}
Powered by blists - more mailing lists