lkml.org 
[lkml]   [2018]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v8 2/2] x86/kvm: use __bss_decrypted attribute in shared variables
On Thu, 13 Sep 2018, Brijesh Singh wrote:
>
> +static void __init kvmclock_init_mem(void)
> +{
> + unsigned int ncpus = num_possible_cpus() - HVC_BOOT_ARRAY_SIZE;
> + unsigned int order = get_order(ncpus * sizeof(*hvclock_mem));
> + struct page *p;
> + int r;
> +
> + p = alloc_pages(GFP_KERNEL, order);
> + if (p) {

If you make this:

if (!p) {
pr_warn();
return;
}

then you spare one indentation level and give useful information.

> + hvclock_mem = page_address(p);
> +
> + /*
> + * hvclock is shared between the guest and the hypervisor, must
> + * be mapped decrypted.
> + */
> + if (sev_active()) {
> + r = set_memory_decrypted((unsigned long) hvclock_mem,
> + 1UL << order);
> + if (r) {
> + __free_pages(p, order);
> + hvclock_mem = NULL;

This wants a pr_warn() as well, please.

> + return;
> + }
> + }
> +
> + memset(hvclock_mem, 0, PAGE_SIZE << order);
> + }
> +}

Other than that, this looks really reasonable and way more palatable in the
rc stage.

Thanks,

tglx

\
 
 \ /
  Last update: 2018-09-14 01:33    [W:0.142 / U:2.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site