[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <41cdd3d5-c45b-4991-ace9-bef7cf9ed197@linux.intel.com>
Date: Mon, 24 Nov 2025 15:49:34 +0800
From: Binbin Wu <binbin.wu@...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, yilun.xu@...ux.intel.com, sagis@...gle.com,
vannapurve@...gle.com, paulmck@...nel.org, nik.borisov@...e.com,
Farrah Chen <farrah.chen@...el.com>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, "H. Peter Anvin" <hpa@...or.com>,
"Kirill A. Shutemov" <kas@...nel.org>
Subject: Re: [PATCH v2 08/21] coco/tdx-host: Implement FW_UPLOAD sysfs ABI for
TDX Module updates
On 10/1/2025 10:52 AM, Chao Gao wrote:
[...]
>
> +static enum fw_upload_err tdx_fw_prepare(struct fw_upload *fwl,
> + const u8 *data, u32 size)
> +{
> + struct tdx_fw_upload_status *status = fwl->dd_handle;
> +
> + if (status->cancel_request) {
> + status->cancel_request = false;
> + return FW_UPLOAD_ERR_CANCELED;
> + }
> +
> + return FW_UPLOAD_ERR_NONE;
> +}
> +
> +static enum fw_upload_err tdx_fw_write(struct fw_upload *fwl, const u8 *data,
> + u32 offset, u32 size, u32 *written)
> +{
> + struct tdx_fw_upload_status *status = fwl->dd_handle;
> +
> + if (status->cancel_request) {
> + status->cancel_request = false;
> + return FW_UPLOAD_ERR_CANCELED;
> + }
Since the execution of the work is not protected by the mutex, if userspace
requests cancellation after this point, after the TDX module update finished,
it seems that the cancel value is left over and it could impact the next update?
> +
> + /*
> + * tdx_fw_write() always processes all data on the first call with
> + * offset == 0. Since it never returns partial success (it either
> + * succeeds completely or fails), there is no subsequent call with
> + * non-zero offsets.
> + */
> + WARN_ON_ONCE(offset);
> + if (seamldr_install_module(data, size))
> + return FW_UPLOAD_ERR_FW_INVALID;
> +
> + *written = size;
> + return FW_UPLOAD_ERR_NONE;
> +}
> +
> +static enum fw_upload_err tdx_fw_poll_complete(struct fw_upload *fwl)
> +{
> + /*
> + * TDX Module updates are completed in the previous phase
> + * (tdx_fw_write()). If any error occurred, the previous phase
> + * would return an error code to abort the update process. In
> + * other words, reaching this point means the update succeeded.
> + */
> + return FW_UPLOAD_ERR_NONE;
> +}
> +
> +static void tdx_fw_cancel(struct fw_upload *fwl)
> +{
> + struct tdx_fw_upload_status *status = fwl->dd_handle;
> +
> + status->cancel_request = true;
> +}
> +
>
[...]
Powered by blists - more mailing lists