Re: [PATCH v17 2/3] virt: Add TDX guest driver

From: Sathyanarayanan Kuppuswamy
Date: Wed Nov 09 2022 - 10:42:22 EST




On 11/9/22 6:24 AM, Wander Lairson Costa wrote:
>> + reportdata = kmalloc(TDX_REPORTDATA_LEN, GFP_KERNEL);
>> + if (!reportdata)
>> + return -ENOMEM;
>> +
>> + tdreport = kzalloc(TDX_REPORT_LEN, GFP_KERNEL);
>> + if (!tdreport) {
>> + ret = -ENOMEM;
>> + goto out;
>> + }
> Isn't simpler just allocating a struct tdx_report_req? You would save
> one allocation and a few lines of code.
>

TDG.MR.TDCALL expects reportdata and tdreport buffers to be size aligned. So,
allocating them together with sizeof(struct tdx report req) will not work. We
can get around this by allocating a slightly larger buffer size. However, because
it is not a time-critical path, I believe that allocating two separate buffers
for input/output is simpler.

--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer