Re: [PATCH v6 07/10] arm64: hyperv: Initialize hypervisor on boot

From: Arnd Bergmann
Date: Wed Mar 18 2020 - 05:44:39 EST


On Wed, Mar 18, 2020 at 1:18 AM Michael Kelley <mikelley@xxxxxxxxxxxxx> wrote:
>
> From: Arnd Bergmann <arnd@xxxxxxxx> Sent: Monday, March 16, 2020 1:30 AM
> >
> > As you are effectively adding a new clocksource driver here, please move the
> > code to drivers/clocksource and send the patch to the respective maintainers
> > (added to Cc here), splitting it out from the rest of the patch.
> >
> > You should also describe why your platform doesn't just use the normal
> > architected timer interface.
> >
> > > +TIMER_ACPI_DECLARE(hyperv, ACPI_SIG_GTDT, hyperv_init);
> >
> > This looks like it registers a driver for the same device as the normal
> > arch timer. Won't that clash?
>
> There is a Hyper-V clocksource driver in drivers/clocksource/hyperv_timer.c.
> It is architecture independent and works for both x86 and ARM64.
>
> The requirement here is really for a place to hang the general Hyper-V
> initialization code. On the x86 side, there's infrastructure already in place
> to do hypervisor initialization, but nothing corresponding on the ARM64 side.
> The TIMER_ACPI_DECLARE hook is admittedly a temporary approach, and I'm
> happy to hear if someone has a better way to handle this.
>
> FWIW, Hyper-V doesn't currently virtualize the ARM arch counter/timer for
> guest VMs. The Hyper-V synthetic counter/timer in the Hyper-V clocksource
> driver is used on both ARM64 and x86. But this Hyper-V init code doesn't actually
> touch the GTDT device, so it won't interfere with the ARM arch counter/timer
> when a future Hyper-V version does virtualize it.

I don't have a good idea to solve it, just a few more thoughts:

- if your platform does not actually provide the generic timer, then the
ACPI tables should not list one either. Instead, create a separate
description for your custom timer, and have that added to the ACPI
spec.

- To treat the timer more like a normal driver, better have the
TIMER_ACPI_DECLARE() function live only in the driver itself,
and use an early initcall (arch_initcall, subsys_initcall, etc)
it initialize the rest as late as you can.

- Some of the other code added to arch/arm64/ might be able to
live in drivers/virt/hyperv in order to be shared between x86 and
arm64. (No idea how much of it there is).

Arnd