Re: [PATCH v8 06/11] x86/traps: Add #VE support for TDX guest

From: Dave Hansen
Date: Sun Oct 17 2021 - 13:15:33 EST


On 10/7/21 10:06 AM, Borislav Petkov wrote:
> On Mon, Oct 04, 2021 at 07:52:00PM -0700, Kuppuswamy Sathyanarayanan wrote:
>> +unsigned long tdx_get_ve_info(struct ve_info *ve)
>> +{
>> + struct tdx_module_output out = {0};
>> + u64 ret;
>> +
>> + /*
>> + * NMIs and machine checks are suppressed. Before this point any
>> + * #VE is fatal. After this point (TDGETVEINFO call), NMIs and
>> + * additional #VEs are permitted (but it is expected not to
>> + * happen unless kernel panics).
>> + */
>> + ret = __tdx_module_call(TDGETVEINFO, 0, 0, 0, 0, &out);
> Same question as before - why do you need to clear this @out thing above
> when __tdx_module_call() will overwrite it?
>
> What you should do instead is check that @ve pointer which you get
> passed in - it might be NULL.

Hi Borislav,

That ve_info really is specific to handling a fault. There's only one
call site:

> +DEFINE_IDTENTRY(exc_virtualization_exception)
> +{
> + struct ve_info ve;
...
> + ret = tdx_get_ve_info(&ve);

I think it's equivalent to something like a 'pt_regs' or 'stack_info'
that we pass around in other exception handlers. It's always stack
allocated. It's never dynamically allocated and NULL is never passed
for some other semantic reason.