lkml.org 
[lkml]   [2022]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v4 1/3] x86/tdx: Add TDX Guest attestation interface driver
From
On 4/28/22 10:56, Sathyanarayanan Kuppuswamy wrote:
> On 4/28/22 10:45 AM, Wander Lairson Costa wrote:
>> On Fri, Apr 22, 2022 at 04:34:16PM -0700, Kuppuswamy Sathyanarayanan
>> wrote:
>>> +static long tdx_get_tdreport(void __user *argp)
>>> +{
>>> +    void *report_buf = NULL, *tdreport_buf = NULL;
>>> +    long ret = 0, err;
>>> +
>>> +    /* Allocate space for report data */
>>> +    report_buf = kmalloc(TDX_REPORT_DATA_LEN, GFP_KERNEL);
>>> +    if (!report_buf)
>>> +        return -ENOMEM;
>>> +
>>> +    /*
>>> +     * Allocate space for TDREPORT buffer (1024-byte aligned).
>>> +     * Full page alignment is more than enough.
>>> +     */
>>> +    tdreport_buf = (void *)get_zeroed_page(GFP_KERNEL);
>>
>> Maybe we should add BUILD_BUG_ON(TDX_TDREPORT_LEN > PAGE_SIZE)
>
> Currently, it is a constant value < PAGE_SIZE. But I can add the
> BUILD_BUG_ON check for it.

That's kinda silly. If it might ever be bigger than a page, you just do:

tdreport_buf = alloc_pages();

But, seriously, TDX_TDREPORT_LEN is part of the ABI and can't change.
kmalloc() would work too since TDX_TDREPORT_LEN is a power of 2.

\
 
 \ /
  Last update: 2022-04-28 20:06    [W:0.058 / U:1.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site