[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200916163243.3zkhff57gpoug6x4@liuwe-devbox-debian-v2>
Date: Wed, 16 Sep 2020 16:32:43 +0000
From: Wei Liu <wei.liu@...nel.org>
To: Vitaly Kuznetsov <vkuznets@...hat.com>
Cc: Wei Liu <wei.liu@...nel.org>,
Linux on Hyper-V List <linux-hyperv@...r.kernel.org>,
virtualization@...ts.linux-foundation.org,
Linux Kernel List <linux-kernel@...r.kernel.org>,
Michael Kelley <mikelley@...rosoft.com>,
Vineeth Pillai <viremana@...ux.microsoft.com>,
Sunil Muthuswamy <sunilmut@...rosoft.com>,
Nuno Das Neves <nudasnev@...rosoft.com>,
Lillian Grassin-Drake <ligrassi@...rosoft.com>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>, Arnd Bergmann <arnd@...db.de>,
"open list:GENERIC INCLUDE/ASM HEADER FILES"
<linux-arch@...r.kernel.org>
Subject: Re: [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@...nel.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.
Powered by blists - more mailing lists