Re: [PATCH v2 08/21] coco/tdx-host: Implement FW_UPLOAD sysfs ABI for TDX Module updates

From: Chao Gao
Date: Tue Dec 02 2025 - 02:21:23 EST


On Mon, Nov 24, 2025 at 03:49:34PM +0800, Binbin Wu wrote:
>
>
>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?

Yes, I think this is a bug. A few other drivers just clear "cancel_request" in
the "prepare" phase, e.g., pd692x0_fw_prepare(), mpfs_auto_update_prepare(),
m10bmc_sec_prepare(). I will follow that approach.