lkml.org 
[lkml]   [2020]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH RFC v1 07/18] x86/hyperv: extract partition ID from Microsoft Hypervisor if necessary
On Tue, Sep 15, 2020 at 12:27:16PM +0200, Vitaly Kuznetsov wrote:
> Wei Liu <wei.liu@kernel.org> writes:
[...]
> >
> > +void __init hv_get_partition_id(void)
> > +{
> > + struct hv_get_partition_id *output_page;
> > + int status;
> > + unsigned long flags;
> > +
> > + local_irq_save(flags);
> > + output_page = *this_cpu_ptr(hyperv_pcpu_output_arg);
> > + status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, output_page) &
> > + HV_HYPERCALL_RESULT_MASK;
>
> Nit: in this case status is 'u16', we can define it as such (instead of
> signed int).

Fixed.

>
> > + if (status != HV_STATUS_SUCCESS)
> > + pr_err("Failed to get partition ID: %d\n", status);
> > + else
> > + hv_current_partition_id = output_page->partition_id;
> > + local_irq_restore(flags);
> > +
> > + /* No point in proceeding if this failed */
> > + BUG_ON(status != HV_STATUS_SUCCESS);
> > +}
> > +
> > /*
> > * This function is to be invoked early in the boot sequence after the
> > * hypervisor has been detected.
> > @@ -440,6 +463,9 @@ void __init hyperv_init(void)
> >
> > register_syscore_ops(&hv_syscore_ops);
> >
> > + if (hv_root_partition)
> > + hv_get_partition_id();
>
> According to TLFS, partition ID is available when AccessPartitionId
> privilege is granted. I'd suggest we check that instead of
> hv_root_partition (and we can set hv_current_partition_id to something
> like U64_MAX so we know it wasn't acuired). So the BUG_ON condition will
> move here:
>
> hv_get_partition_id();
> BUG_ON(hv_root_partition && hv_current_partition_id == U64_MAX);
>

Good point. I will reorganize this a bit.

Wei.

\
 
 \ /
  Last update: 2020-09-16 22:12    [W:0.186 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site