mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Huang, Kai" <kai.huang@intel.com>
To: "tglx@linutronix.de" <tglx@linutronix.de>,
	"Sun, Yi" <yi.sun@intel.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"x86@kernel.org" <x86@kernel.org>, "bp@alien8.de" <bp@alien8.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
Cc: "kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"sathyanarayanan.kuppuswamy@linux.intel.com" 
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	"Yan, Dongcheng" <dongcheng.yan@intel.com>,
	"nik.borisov@suse.com" <nik.borisov@suse.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"yi.sun@linux.intel.com" <yi.sun@linux.intel.com>,
	"Su, Heng" <heng.su@intel.com>
Subject: Re: [PATCH v7] x86/tdx: Dump TDX Version During TD Bootup
Date: Fri, 27 Oct 2023 08:56:54 +0000	[thread overview]
Message-ID: <03ceb0cf8f0fd5e7f4e9dba996da09a02305a04b.camel@intel.com> (raw)
In-Reply-To: <20231027045234.1371846-1-yi.sun@intel.com>


> +/*
> + * Detect TDX Module version info from TDG.SYS.RD TDCALL
> + */
> +static void detect_tdx_version(void)
> +{
> +	struct tdx_module_args args = {};
> +	u16 major_version, minor_version;
> +	u32 vendor_id;
> +	u64 ret;
> +
> +	args.rdx = TDX_SYS_VENDOR_ID_FID;
> +	ret = __tdcall_ret(TDG_SYS_RD, &args);
> +	if (ret)
> +		goto err_out;

I am not sure we need to detect vendor ID?  I believe TDX must be from Intel?

Also, I think either "err" or "out" is sufficient?

> +
> +	vendor_id = args.r8;
> +
> +	memset(&args, 0, sizeof(args));
> +	args.rdx = TDX_SYS_MAJOR_FID;
> +	ret = __tdcall_ret(TDG_SYS_RD, &args);
> +	if (ret)
> +		goto err_out;
> +
> +	major_version = args.r8;
> +
> +	memset(&args, 0, sizeof(args));
> +	args.rdx = TDX_SYS_MINOR_FID;
> +	ret = __tdcall_ret(TDG_SYS_RD, &args);
> +	if (ret)
> +		goto err_out;
> +
> +	minor_version = args.r8;
> +
> +	pr_info("Guest detected. version:%u.%u VendorID:%x\n",
> +		major_version, minor_version, vendor_id);
> +
> +	return;
> +
> +err_out:
> +	if (TDCALL_RETURN_CODE(ret) == TDCALL_INVALID_OPERAND)
> +		pr_info("TDG.SYS.RD not available\n");
> +	else
> +		pr_info("TDG.SYS.RD unknown error (%llu), reading field %llu\n",
> +			ret, args.rdx);
> +
> +	pr_info("Assuming TDX version:1.x (x<5) VendorID:%x\n",
> +		TDX_VENDOR_INTEL);

You removed "Guest detected" in tdx_early_init(), but didn't add it here, so
unfortunately the "Guest detected" will get lost here.

Also, I suppose for the case TDG.SYS.RD isn't supported there's still some value
to print "Assume module version: 1.x (x<5)", but when TDG.SYS.RD failed
unexpectedly I don't think we can make that assumption, and printing "assuming
..." could give user misinformation which is worse than not printing IMHO.

So, I think you can keep the printing of "Guest detected" in tdx_early_init(),
and somehow refine the code to print something like below:

For module that does TDG.SYS.RD successfully:

  tdx: Guest detected
  tdx: Module version: %u.%u

For module that doesn't support TDG.SYS.RD:

  tdx: Guest detected
  tdx: Failed to get module version: TDG.SYS.RD unsupported. Assume module
version: 1.x (x < 5).

For module that TDG.SYS.RD failed unexpectedly:

  tdx: Guest detected
  tdx: Failed to get module version: TDG.SYS.RD failed to read 0x%llu: 0x%llu  

      reply	other threads:[~2023-10-27  8:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-27  4:52 Yi Sun
2023-10-27  8:56 ` Huang, Kai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03ceb0cf8f0fd5e7f4e9dba996da09a02305a04b.camel@intel.com \
    --to=kai.huang@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dongcheng.yan@intel.com \
    --cc=heng.su@intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nik.borisov@suse.com \
    --cc=peterz@infradead.org \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yi.sun@intel.com \
    --cc=yi.sun@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®