Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Preserving TDX module during kexec with live update
@ 2026-07-15 23:28 Sagi Shahar
  2026-07-16 14:55 ` Pasha Tatashin
  0 siblings, 1 reply; 2+ messages in thread
From: Sagi Shahar @ 2026-07-15 23:28 UTC (permalink / raw)
  To: Pasha Tatashin, Alexander Graf, Andersen, Tycho, Anthony Yznaga,
	Baolu Lu, David Hildenbrand, David Matlack, Heyne, Maximillian,
	James Gowans, Jason Gunthorpe, Mike Rapoport, Pankaj Gupta,
	Pratyush Yadav, Praveen Kumar, Vipin Sharma, Vishal Annapurve,
	Woodhouse, David, Luca Boccassi, Samiullah Khawaja, Jork Loeser,
	Chenghao Duan, Zhu Yanjun, Sean Christopherson, Verma, Vishal L
  Cc: linux-mm, kexec, linux-kernel

Hi,

I started looking into preserving the TDX module across live updates
and I'm not sure what the best approach is. I tried looking into using
flb as David M suggested but I don't think this approach works for the
TDX module.

Right now the way that TDX supports kexec is by disabling the TDX
module on kexec and then reinitilizing it on the next boot [1]. This
approach clears the TDX module state so any TDX VM from the source
kernel won't be able to resume running on the destination kernel.

In order to support live update while keeping the VMs alive we need to
skip the TDH_SYS_DISABLE call and instead preserve pages used by the
TDX module such as the TDMR pages from the source kernel.

From what I understand, using flb will tie the TDX module save/restore
to the lifecycle of the VMs depending on it. This means the module
will be restored too late during kernel boot, after the VMs are
restored using the live update IOCTLs.

I'm thinking we should preserve the TDX module during the shutdown
stage of the source kernel. Perhaps we can preserve the pages used by
the TDX module as we allocate them on the source kernel and pass
pointers and additional metadata during KHO. Then on the destination
we need to pipe this information to where the TDX module gets
initialized during the KVM module initialization.

I haven't found a device that acts in a similar way so I'm not sure
how complicated this will be or if there's a better approach.

I would love to hear your thoughts and if you have any pointers on
where this code can be implemented.

Thanks,
Sagi

[1] https://lore.kernel.org/all/20260323-fuller_tdx_kexec_support-v2-0-87a36409e051@intel.com/


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Preserving TDX module during kexec with live update
  2026-07-15 23:28 Preserving TDX module during kexec with live update Sagi Shahar
@ 2026-07-16 14:55 ` Pasha Tatashin
  0 siblings, 0 replies; 2+ messages in thread
From: Pasha Tatashin @ 2026-07-16 14:55 UTC (permalink / raw)
  To: Sagi Shahar
  Cc: Pasha Tatashin, Alexander Graf, Andersen, Tycho, Anthony Yznaga,
	Baolu Lu, David Hildenbrand, David Matlack, Heyne, Maximillian,
	James Gowans, Jason Gunthorpe, Mike Rapoport, Pankaj Gupta,
	Pratyush Yadav, Praveen Kumar, Vipin Sharma, Vishal Annapurve,
	Woodhouse, David, Luca Boccassi, Samiullah Khawaja, Jork Loeser,
	Chenghao Duan, Zhu Yanjun, Sean Christopherson, Verma, Vishal L,
	linux-mm, kexec, linux-kernel

On 07-15 18:28, Sagi Shahar wrote:
> Hi,
> 
> I started looking into preserving the TDX module across live updates
> and I'm not sure what the best approach is. I tried looking into using
> flb as David M suggested but I don't think this approach works for the
> TDX module.
> 
> Right now the way that TDX supports kexec is by disabling the TDX
> module on kexec and then reinitilizing it on the next boot [1]. This
> approach clears the TDX module state so any TDX VM from the source
> kernel won't be able to resume running on the destination kernel.
> 
> In order to support live update while keeping the VMs alive we need to
> skip the TDH_SYS_DISABLE call and instead preserve pages used by the
> TDX module such as the TDMR pages from the source kernel.

Agreed.

> 
> From what I understand, using flb will tie the TDX module save/restore
> to the lifecycle of the VMs depending on it. This means the module
> will be restored too late during kernel boot, after the VMs are
> restored using the live update IOCTLs.

That is not correct. FLBs specifically can be restored very early in 
boot. We do that for HugeTLB preservation, for example.

liveupdate_flb_get_incoming() does not require userspace to resume or 
restore VMs. You can call it super early in boot to see if there is FLB 
data present and, if so, change the way the module is initialized during 
boot.

> 
> I'm thinking we should preserve the TDX module during the shutdown
> stage of the source kernel. Perhaps we can preserve the pages used by
> the TDX module as we allocate them on the source kernel and pass
> pointers and additional metadata during KHO. Then on the destination
> we need to pipe this information to where the TDX module gets
> initialized during the KVM module initialization.

Please don't invent another state machine; instead, use the existing 
one.

Pasha

> 
> I haven't found a device that acts in a similar way so I'm not sure
> how complicated this will be or if there's a better approach.
> 
> I would love to hear your thoughts and if you have any pointers on
> where this code can be implemented.
> 
> Thanks,
> Sagi
> 
> [1] https://lore.kernel.org/all/20260323-fuller_tdx_kexec_support-v2-0-87a36409e051@intel.com/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-16 14:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15 23:28 Preserving TDX module during kexec with live update Sagi Shahar
2026-07-16 14:55 ` Pasha Tatashin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox