Re: [PATCH v11 42/45] virt: Add SEV-SNP guest driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux