lkml.org 
[lkml]   [2022]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v11 42/45] virt: Add SEV-SNP guest driver
From

On 3/3/22 11:33 AM, Dave Hansen wrote:

...


>> + */
>> + if (count >= UINT_MAX) {
>> + pr_err_ratelimited("request message sequence counter overflow\n");
>> + return 0;
>> + }
>> +
>> + return count;
>> +}
> I didn't see a pr_fmt defined anywhere. But, for a "driver", should
> this be a dev_err()?


Okay, I can switch to dev_err() and will define pr_fmt.

> ...
>> +static void free_shared_pages(void *buf, size_t sz)
>> +{
>> + unsigned int npages = PAGE_ALIGN(sz) >> PAGE_SHIFT;
>> +
>> + if (!buf)
>> + return;
>> +
>> + if (WARN_ONCE(set_memory_encrypted((unsigned long)buf, npages),
>> + "failed to restore encryption mask (leak it)\n"))
>> + return;
>> +
>> + __free_pages(virt_to_page(buf), get_order(sz));
>> +}
> Nit: It's a bad practice to do important things inside a WARN_ON() _or_
> and if(). This should be:
>
> int ret;
>
> ...
>
> ret = set_memory_encrypted((unsigned long)buf, npages));
>
> if (ret) {
> WARN_ONCE(...);
> return;
> }
>
> BTW, this look like a generic allocator thingy. But it's only ever used
> to allocate a 'struct snp_guest_msg'. Why all the trouble to allocate
> and free one fixed-size structure? The changelog and comments don't
> shed any light.

The GHCB specification says that a guest must use shared memory for
request, response, and certificate blob. In this patch, you are seeing
that {alloc,free}_shared_pages() used only to alloc/free the request and
response page. In the last patch, we used the same generic function to
allocate the certificate blob with a different size (~16K) than 'struct
snp_guest_msg.'


thanks

\
 
 \ /
  Last update: 2022-03-04 14:18    [W:0.188 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site