Re: [PATCH 6/6] x86/virt/tdx: Re-initialize the extensions on runtime TDX module update
Tony Lindgren <[email protected]>
| Newsgroups | org.kernel.vger.kvm,dev.linux.lists.linux-coco,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <ao1T61FjnTQwa6qN@tlindgre-MOBL1> |
On Fri, Aug 21, 2026 at 11:29:20AM +0800, Xu Yilun wrote:
> --- a/arch/x86/virt/vmx/tdx/tdx.c
> +++ b/arch/x86/virt/vmx/tdx/tdx.c
> @@ -1289,7 +1289,7 @@ static __init int tdx_ext_mem_setup(void)
> return ret;
> }
>
> -static __init int tdx_ext_init(void)
> +static int tdx_ext_init(void)
> {
> struct tdx_module_args args = {};
> u64 ret;
> @@ -1332,6 +1332,19 @@ static __init int init_tdx_module_extensions(void)
> return tdx_ext_init();
> }
>
> +/*
> + * Don't update the extensions metadata, just follow the requirement originated
> + * during TDX module initialization. Let the extensions re-initialization fail
> + * if more memory is needed, or if ext_required is dropped after updates.
> + */
> +static int update_tdx_module_extensions(void)
> +{
> + if (!tdx_sysinfo.ext.ext_required)
> + return 0;
> +
> + return tdx_ext_init();
> +}
> +
> static __init int init_tdx_module(void)
> {
> int ret;
> @@ -1532,6 +1545,10 @@ int tdx_module_run_update(void)
> */
> WARN_ON_ONCE(ret);
>
> + ret = update_tdx_module_extensions();
> + if (ret)
> + return ret;
> +
> tdx_module_state.initialized = true;
> return 0;
> }
How about use naming to follow the comments and patch $subject, maybe
use reinit_tdx_module_extensions() naming instead?
But now I'm wondering how come we need separate functions for init and
reinit of the extensions, would a bool flag for init be enough to signal
the reinit?