Before initiating TD-Preserving updates, ensure that the limit on successive TD-Preserving updates has not been exceeded. This is a cheap check to prevent update failure. Refresh SEAMLDR info after each update so that userspace can read the correct value of remaining updates. Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx> Tested-by: Farrah Chen <farrah.chen@xxxxxxxxx> --- arch/x86/virt/vmx/tdx/seamldr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/virt/vmx/tdx/seamldr.c b/arch/x86/virt/vmx/tdx/seamldr.c index 93385db56281..fe8f98701429 100644 --- a/arch/x86/virt/vmx/tdx/seamldr.c +++ b/arch/x86/virt/vmx/tdx/seamldr.c @@ -371,6 +371,9 @@ static int seamldr_install_module(const u8 *data, u32 size) if (!info) return -ENOMEM; + if (!seamldr_info.num_remaining_updates) + return -ENOSPC; + struct seamldr_params *params __free(free_seamldr_params) = init_seamldr_params(data, size); if (IS_ERR(params)) @@ -382,6 +385,8 @@ static int seamldr_install_module(const u8 *data, u32 size) if (ret) return ret; + WARN_ON_ONCE(get_seamldr_info()); + return tdx_module_post_update(info); } -- 2.47.1