From: Chao Gao <chao.gao@intel.com>
To: Kiryl Shutsemau <kas@kernel.org>
Cc: Dave Hansen <dave.hansen@intel.com>, <linux-coco@lists.linux.dev>,
<linux-kernel@vger.kernel.org>, <x86@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>, Kai Huang <kai.huang@intel.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Dan Williams <dan.j.williams@intel.com>
Subject: Re: [PATCH 1/2] x86/virt/tdx: Retrieve TDX module version
Date: Fri, 24 Oct 2025 18:04:24 +0800 [thread overview]
Message-ID: <aPtPKP7d9dbgcL6w@intel.com> (raw)
In-Reply-To: <mvwzymoykhb6symwvwcc5liws4nb5cnxbyibh25gt67kufxhy2@vnqb3npptx5z>
>> >Hm. Isn't it buggy?
>> >
>> >Caller expects to see field_id == -1 to exit loop, but you never set it
>> >in case of an error. It will result in endless loop if error happens not on
>> >the first iteration.
>>
>> The caller checks the return value and bails out if there was an error.
>
>I misread it. Missed the break.
>
>> >
>> >Drop the branch and always return ret.
>>
>> Setting field_id to -1 on error appears unnecessary since callers must check
>> the return value anyway. And, even if args.r8 were copied to field_id
>> on error, this wouldn't guarantee that field_id would be set to -1, as
>> SEAMCALLs may encounter #GP/#UD exceptions where r8 remains unchanged.
>>
>> Given this, I prefer to leave field_id as an undefined value on error, and
>> callers should not read/use it when an error occurs.
>
>It is not undefined. TDX module sets R8 to -1 in case of error.
Yes, I saw it. That's TDX module ABI. It doesn't necessarily have to be the
semantics of this kernel API. So, we have two choices:
1. Follow the TDX module, i.e., set field_id to -1 on error. Then we should do:
if (ret)
*field_id = -1;
else
*field_id = args.r8;
to cover #GP/#UD cases.
2. Leave field_id undefined on error, as in this patch.
I don't see the value of setting field_id to -1 on error if callers are
expected to check the return value.
next prev parent reply other threads:[~2025-10-24 10:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-01 2:22 [PATCH 0/2] Expose TDX Module version Chao Gao
2025-10-01 2:22 ` [PATCH 1/2] x86/virt/tdx: Retrieve TDX module version Chao Gao
2025-10-01 15:15 ` Dave Hansen
2025-10-22 7:54 ` Chao Gao
2025-10-22 10:26 ` Kiryl Shutsemau
2025-10-24 6:33 ` Chao Gao
2025-10-24 9:35 ` Kiryl Shutsemau
2025-10-24 10:04 ` Chao Gao [this message]
2025-11-13 1:24 ` Chao Gao
2025-10-24 14:20 ` Vishal Annapurve
2025-10-01 2:22 ` [PATCH 2/2] coco/tdx-host: Expose " Chao Gao
2025-10-01 4:12 ` Huang, Kai
2025-10-01 11:27 ` Kiryl Shutsemau
2025-10-01 21:41 ` Huang, Kai
2025-10-01 11:30 ` Kiryl Shutsemau
-- strict thread matches above, loose matches on Subject: below --
2026-01-08 0:31 [PATCH 0/2] x86/virt/tdx: Print TDX module version to dmesg Vishal Verma
2026-01-08 0:31 ` [PATCH 1/2] x86/virt/tdx: Retrieve TDX module version Vishal Verma
2026-01-08 10:41 ` Kiryl Shutsemau
2026-01-08 20:18 ` Edgecombe, Rick P
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=aPtPKP7d9dbgcL6w@intel.com \
--to=chao.gao@intel.com \
--cc=bp@alien8.de \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kai.huang@intel.com \
--cc=kas@kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.