Subject: Re: [PATCH v9 05/23] coco/tdx-host: Expose TDX module version
From: Dave Hansen <[email-masked]>
To: [email-masked]

[Draft review generated by x86-maintainer-agent applying Dave_Hansen.txt
 rules to the v9 series.  Strip this banner before sending.]

> +static ssize_t version_show(struct device *dev, struct device_attribute *attr,
> +			    char *buf)
> +{
> +	const struct tdx_sys_info *tdx_sysinfo = tdx_get_sysinfo();
> +	const struct tdx_sys_info_version *ver;
> +
> +	if (!tdx_sysinfo)
> +		return -ENXIO;

-ENXIO here is a one-shot value that patch 22 documents as "the TDX
module is dead".  Worth a one-line code comment that explicitly ties
the errno to that meaning -- the next person to touch this file will
not have patch 22's ABI documentation open.  RULE 2.

  /*
   * tdx_get_sysinfo() returns NULL once the TDX module has
   * been torn down (e.g. after a failed runtime update).  See
   * Documentation/ABI/testing/sysfs-devices-faux-tdx-host for the
   * userspace-visible meaning of this -ENXIO.
   */

The TDX_VERSION_FMT macro plus its zero-pad comment is the right call
-- thanks for spelling out the convention next to the definition
(RULE 16, "use existing helpers / make a helper if you'll need it
twice").

ABI documentation is present (RULE 13).  Good.

Reviewed-by: Dave Hansen <[email-masked]>  [with the
                                                        comment added]