Skip to contentSkip to conversation

Enable Linux guests on Hyper-V on ARM64

PATCH Applied Michael Kelley 3 participants 14 messages Aug 4, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v12 cover Enable Linux guests on Hyper-V on ARM64

This series enables Linux guests running on Hyper-V on ARM64 hardware. New ARM64-specific code in arch/arm64/hyperv initializes Hyper-V and its hypercall mechanism. Existing architecture independent drivers for Hyper-V's VMbus and synthetic devices just work when built for ARM64. Hyper-V code is built and included in the image and modules only if CONFIG_HYPERV is enabled.

The five patches are organized as follows:

1) Add definitions and functions for making Hyper-V hypercalls and getting/setting virtual processor registers provided by Hyper-V

2) Add the function needed by the arch independent VMbus driver for reporting a panic to Hyper-V.

3) Add Hyper-V initialization code and utility functions that report Hyper-v status.

4) Export screen_info so it may be used by the Hyper-V frame buffer driver built as a module. It is already exported for x86, powerpc, and alpha architectures.

5) Make CONFIG_HYPERV selectable on ARM64 in addition to x86/x64.

Hyper-V on ARM64 runs with a 4 Kbyte page size, but allows guests with 4K/16K/64K page size. Linux guests with this patch series work with all three supported ARM64 page sizes.

The Hyper-V vPCI driver at drivers/pci/host/pci-hyperv.c has x86/x64-specific code and is not being built for ARM64. Enabling Hyper-V vPCI devices on ARM64 is in progress via a separate set of patches.

This patch set is based on the linux-next20210720 code tree.

Changes in v12:
* Updated hyperv_init() in Patch 3 to allow a kernel built with CONFIG_HYPERV to run in other environments. [Marc Zyngier, Mark Rutland]

Changes in v11:
* Drop the previous Patch 1 as the fixes have already been separately accepted upstream.
* Drop the previous Patch 3 for enabling Hyper-V enlightened clocks/timers. Hyper-V is now offering the full ARM64 architectural Generic Timer in guest VMs, so the existing arch_arch_timer.c driver just works. [Mark Rutland, Marc Zyngier]
* Simplified the previous Patch 4 and Patch 5 (now Patch 2 and 3) by sharing more code between the x86 and ARM64 architectures.
* Combined hyperv_early_init() and hyperv_init() into a single initialization function that runs as an early_initcall. This is possible because the Hyper-V enlightened clocks/timers no longer need to be initialized early in the boot sequence.

Changes in v10:
* Drop previous Patch 1 for SMCCC v1.2 HVC calls in favor of Sudeep Holla's patch [Mark Rutland]
* Use new helper functions in 5.13 for checking Hyper-V hypercall return status
* Set up per-CPU hypercall argument page that is now used by the Hyper-V balloon driver
* Rebase on 5.13-RC1

Changes in v9:
* Added Patch 1 to enable making an SMCCC compliant hypercall that returns results in other than registers X0 thru X3, per version 1.2 and later of the SMCCC spec.
* Using the ability to return results in registers X6 and X7, converted hv_get_vpreg_128() to use a "fast" hypercall that passes inputs and outputs in registers, and in doing so eliminated a lot of memory allocation complexity.
* Cleaned up some extra blank lines and use of spaces in aligning local variables. [Sunil Muthuswamy]
* Based on discussion about future directions, reverted the population of hv_vp_index array to use a cpuhp state instead of a hypercall, which is like it was in v7 and earlier.

Changes in v8:
* Removed a lot of code based on refactoring the boundary between arch independent and arch dependent code for Hyper-V, per comments from Arnd Bergmann. The removed code was either duplicated on the x86 side, or has been folded into architecture independent code as not really being architecture dependent.
* Added config dependency on !CONFIG_CPU_BIG_ENDIAN [Arnd Bergmann]
* Reworked the approach to Hyper-V initialization. The functionality is the same, but is now structured like the Xen code with an early init function called in setup_arch() and an early initcall to finish the initialization. [Arnd Bergmann]

Changes in v7:
* Separately upstreamed split of hyperv-tlfs.h into arch dependent and independent versions. In this patch set, update the ARM64 hyperv-tlfs.h to include architecture independent definitions. This approach eliminates a lot of lines of otherwise duplicated code on the ARM64 side.
* Break ARM64 mshyperv.h into smaller pieces. Have an initial baseline, and add code along with patches for a particular functional area. [Marc Zyngier]
* In mshyperv.h, use static inline functions instead of #defines where possible. [Arnd Bergmann]
* Use VMbus INTID obtained from ACPI DSDT instead of hardcoding. The STIMER INTID is still hardcoded because it is needed before Linux has initialized the ACPI subsystem, so it can't be obtained from the DSDT. Wedging it into the GTDT seems dubious, so was not done. [Marc Zyngier]
* Update Hyper-V page size allocation functions to use alloc_page() if PAGE_SIZE == HV_HYP_PAGE_SIZE [Arnd Bergmann]
* Various other minor changes based on feedback and to rebase to latest linux-next [Marc Zyngier and Arnd Bergmann]

Changes in v6:
* Use SMCCC hypercall interface instead of direct invocation of HVC instruction and the Hyper-V hypercall interface [Marc Zyngier]
* Reimplemented functions to alloc/free Hyper-V size pages using kmalloc/kfree since kmalloc now guarantees alignment of power of 2 size allocations [Marc Zyngier]
* Export screen_info in arm64 architecture so it can be used by the Hyper-V buffer driver built as a module
* Renamed source file arch/arm64/hyperv/hv_init.c to hv_core.c to better reflect its content
* Fixed the bit position of certain feature flags presented by Hyper-V to the guest. The bit positions on ARM64 don't match the position on x86 like originally thought.
* Minor fixups to rebase to 5.6-rc5 linux-next

Changes in v5:
* Minor fixups to rebase to 5.4-rc1 linux-next

Changes in v4:
* Moved clock-related code into an architecture independent Hyper-V clocksource driver that is already upstream. Clock related code is removed from this patch set except for the ARM64 specific interrupt handler. [Marc Zyngier]
* Separately upstreamed the split of mshyperv.h into arch independent and arch dependent portions. The arch independent portion has been removed from this patch set.
* Divided patch #2 of the series into multiple smaller patches [Marc Zyngier]
* Changed a dozen or so smaller things based on feedback [Marc Zyngier, Will Deacon]
* Added functions to alloc/free Hyper-V size pages for use by drivers for Hyper-V synthetic devices when updated to not assume guest page size and Hyper-v page size are the same

Changes in v3:
* Added initialization of hv_vp_index array like was recently added on x86 branch [KY Srinivasan]
* Changed Hyper-V ARM64 register symbols to be all uppercase instead of mixed case [KY Srinivasan]
* Separated mshyperv.h into two files, one architecture independent and one architecture dependent. After this code is upstream, will make changes to the x86 code to use the architecture independent file and remove duplication. And once we have a multi-architecture Hyper-V TLFS, will do a separate patch to split hyperv-tlfs.h in the same way. [KY Srinivasan]
* Minor tweaks to rebase to latest linux-next code

Changes in v2:
* Removed patch to implement slow_virt_to_phys() on ARM64. Use of slow_virt_to_phys() in arch independent Hyper-V drivers has been eliminated by commit 6ba34171bcbd ("Drivers: hv: vmbus: Remove use of slow_virt_to_phys()")
* Minor tweaks to rebase to latest linux-next code

Michael Kelley (5):
arm64: hyperv: Add Hyper-V hypercall and register access utilities
arm64: hyperv: Add panic handler
arm64: hyperv: Initialize hypervisor on boot
arm64: efi: Export screen_info
Drivers: hv: Enable Hyper-V code to be built on ARM64

 MAINTAINERS                          |   3 +
 arch/arm64/Kbuild                    |   1 +
 arch/arm64/hyperv/Makefile           |   2 +
 arch/arm64/hyperv/hv_core.c          | 181 +++++++++++++++++++++++++++++++++++
 arch/arm64/hyperv/mshyperv.c         |  87 +++++++++++++++++
 arch/arm64/include/asm/hyperv-tlfs.h |  69 +++++++++++++
 arch/arm64/include/asm/mshyperv.h    |  54 +++++++++++
 arch/arm64/kernel/efi.c              |   1 +
 drivers/hv/Kconfig                   |   5 +-
 9 files changed, 401 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm64/hyperv/Makefile
 create mode 100644 arch/arm64/hyperv/hv_core.c
 create mode 100644 arch/arm64/hyperv/mshyperv.c
 create mode 100644 arch/arm64/include/asm/hyperv-tlfs.h
 create mode 100644 arch/arm64/include/asm/mshyperv.h
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v12 1/5 arm64: hyperv: Add Hyper-V hypercall and register access utilities

hyperv-tlfs.h defines Hyper-V interfaces from the Hyper-V Top Level Functional Spec (TLFS), and #includes the architecture-independent part of hyperv-tlfs.h in include/asm-generic. The published TLFS is distinctly oriented to x86/x64, so the ARM64-specific hyperv-tlfs.h includes information for ARM64 that is not yet formally published. The TLFS is available here:

docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs

mshyperv.h defines Linux-specific structures and routines for interacting with Hyper-V on ARM64, and #includes the architecture- independent part of mshyperv.h in include/asm-generic.

Use these definitions to provide utility functions to make Hyper-V hypercalls and to get and set Hyper-V provided registers associated with a virtual processor.

---
 MAINTAINERS                          |   3 +
 arch/arm64/Kbuild                    |   1 +
 arch/arm64/hyperv/Makefile           |   2 +
 arch/arm64/hyperv/hv_core.c          | 129 +++++++++++++++++++++++++++++++++++
 arch/arm64/include/asm/hyperv-tlfs.h |  69 +++++++++++++++++++
 arch/arm64/include/asm/mshyperv.h    |  54 +++++++++++++++
 6 files changed, 258 insertions(+)
 create mode 100644 arch/arm64/hyperv/Makefile
 create mode 100644 arch/arm64/hyperv/hv_core.c
 create mode 100644 arch/arm64/include/asm/hyperv-tlfs.h
 create mode 100644 arch/arm64/include/asm/mshyperv.h
MAINTAINERS +3 -0
index 6993219..8f6f429 100644
@@ -8608,6 +8608,9 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
 F:	Documentation/ABI/stable/sysfs-bus-vmbus
 F:	Documentation/ABI/testing/debugfs-hyperv
 F:	Documentation/networking/device_drivers/ethernet/microsoft/netvsc.rst
+F:	arch/arm64/hyperv
+F:	arch/arm64/include/asm/hyperv-tlfs.h
+F:	arch/arm64/include/asm/mshyperv.h
 F:	arch/x86/hyperv
 F:	arch/x86/include/asm/hyperv-tlfs.h
 F:	arch/x86/include/asm/mshyperv.h
arch/arm64/Kbuild +1 -0
index 7b393cf..ea7ab4c 100644
@@ -2,4 +2,5 @@
 obj-y			+= kernel/ mm/ net/
 obj-$(CONFIG_KVM)	+= kvm/
 obj-$(CONFIG_XEN)	+= xen/
+obj-$(subst m,y,$(CONFIG_HYPERV))	+= hyperv/
 obj-$(CONFIG_CRYPTO)	+= crypto/
arch/arm64/hyperv/Makefile new file +2 -0
new file mode 100644
index 0000000..1697d30
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-y		:= hv_core.o
arch/arm64/hyperv/hv_core.c new file +129 -0

129 lines not on this page · raw message

arch/arm64/include/asm/hyperv-tlfs.h new file +69 -0

69 lines not on this page · raw message

arch/arm64/include/asm/mshyperv.h new file +54 -0

54 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v12 2/5 arm64: hyperv: Add panic handler

In reply to Michael Kelley

Add a function to inform Hyper-V about a guest panic.

This code is built only when CONFIG_HYPERV is enabled.

---
 arch/arm64/hyperv/hv_core.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
arch/arm64/hyperv/hv_core.c +52 -0
index 4c5dc0f..b54c347 100644
@@ -127,3 +127,55 @@ u64 hv_get_vpreg(u32 msr)
 	return output.as64.low;
 }
 EXPORT_SYMBOL_GPL(hv_get_vpreg);
+
+/*
+ * hyperv_report_panic - report a panic to Hyper-V.  This function uses
+ * the older version of the Hyper-V interface that admittedly doesn't
+ * pass enough information to be useful beyond just recording the
+ * occurrence of a panic. The parallel hv_kmsg_dump() uses the
+ * new interface that allows reporting 4 Kbytes of data, which is much
+ * more useful. Hyper-V on ARM64 always supports the newer interface, but
+ * we retain support for the older version because the sysadmin is allowed
+ * to disable the newer version via sysctl in case of information security
+ * concerns about the more verbose version.
+ */
+void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die)
+{
+	static bool	panic_reported;
+	u64		guest_id;
+
+	/* Don't report a panic to Hyper-V if we're not going to panic */
+	if (in_die && !panic_on_oops)
+		return;
+
+	/*
+	 * We prefer to report panic on 'die' chain as we have proper
+	 * registers to report, but if we miss it (e.g. on BUG()) we need
+	 * to report it on 'panic'.
+	 *
+	 * Calling code in the 'die' and 'panic' paths ensures that only
+	 * one CPU is running this code, so no atomicity is needed.
+	 */
+	if (panic_reported)
+		return;
+	panic_reported = true;
+
+	guest_id = hv_get_vpreg(HV_REGISTER_GUEST_OSID);
+
+	/*
+	 * Hyper-V provides the ability to store only 5 values.
+	 * Pick the passed in error value, the guest_id, the PC,
+	 * and the SP.
+	 */
+	hv_set_vpreg(HV_REGISTER_CRASH_P0, err);
+	hv_set_vpreg(HV_REGISTER_CRASH_P1, guest_id);
+	hv_set_vpreg(HV_REGISTER_CRASH_P2, regs->pc);
+	hv_set_vpreg(HV_REGISTER_CRASH_P3, regs->sp);
+	hv_set_vpreg(HV_REGISTER_CRASH_P4, 0);
+
+	/*
+	 * Let Hyper-V know there is crash data available
+	 */
+	hv_set_vpreg(HV_REGISTER_CRASH_CTL, HV_CRASH_CTL_CRASH_NOTIFY);
+}
+EXPORT_SYMBOL_GPL(hyperv_report_panic);
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH v12 3/5 arm64: hyperv: Initialize hypervisor on boot

In reply to Michael Kelley

Add ARM64-specific code to initialize the Hyper-V
hypervisor when booting as a guest VM.

This code is built only when CONFIG_HYPERV is enabled.

---
 arch/arm64/hyperv/Makefile   |  2 +-
 arch/arm64/hyperv/mshyperv.c | 87 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/hyperv/mshyperv.c
arch/arm64/hyperv/Makefile +1 -1
index 1697d30..87c31c0 100644
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-y		:= hv_core.o
+obj-y		:= hv_core.o mshyperv.o
arch/arm64/hyperv/mshyperv.c new file +87 -0

87 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v12 4/5 arm64: efi: Export screen_info

In reply to Michael Kelley

The Hyper-V frame buffer driver may be built as a module, and it needs access to screen_info. So export screen_info.

---
 arch/arm64/kernel/efi.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kernel/efi.c +1 -0
index fa02efb..e1be6c4 100644
@@ -55,6 +55,7 @@ static __init pteval_t create_mapping_protection(efi_memory_desc_t *md)
 
 /* we will fill this structure from the stub, so don't put it in .bss */
 struct screen_info screen_info __section(".data");
+EXPORT_SYMBOL(screen_info);
 
 int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md)
 {
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v12 5/5 Drivers: hv: Enable Hyper-V code to be built on ARM64

In reply to Michael Kelley

Update drivers/hv/Kconfig so CONFIG_HYPERV can be selected on ARM64, causing the Hyper-V specific code to be built. Exclude the Hyper-V enlightened clocks/timers code from being built for ARM64.

---
 drivers/hv/Kconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hv/Kconfig +3 -2
index 66c794d..e509d5d 100644
@@ -4,7 +4,8 @@ menu "Microsoft Hyper-V guest support"
 
 config HYPERV
 	tristate "Microsoft Hyper-V client drivers"
-	depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST
+	depends on ACPI && ((X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \
+		|| (ARM64 && !CPU_BIG_ENDIAN))
 	select PARAVIRT
 	select X86_HV_CALLBACK_VECTOR
 	help
@@ -12,7 +13,7 @@ config HYPERV
 	  system.
 
 config HYPERV_TIMER
-	def_bool HYPERV
+	def_bool HYPERV && X86
 
 config HYPERV_UTILS
 	tristate "Microsoft Hyper-V Utilities driver"
Signature · 1 line
1.8.3.1
maintainer
#6 lore raw

Re: [PATCH v12 5/5] Drivers: hv: Enable Hyper-V code to be built on ARM64

Quoted 18 lines · Michael Kelley

Update drivers/hv/Kconfig so CONFIG_HYPERV can be selected on ARM64, causing the Hyper-V specific code to be built. Exclude the Hyper-V enlightened clocks/timers code from being built for ARM64.

---
 drivers/hv/Kconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hv/Kconfig +0 -0
index 66c794d..e509d5d 100644

drivers/hv/Kconfig menu "Microsoft Hyper-V guest support" · line 10

Quoted 8 lines
drivers/hv/Kconfig +2 -1
@@ -4,7 +4,8 @@ menu "Microsoft Hyper-V guest support"
 
 config HYPERV
 	tristate "Microsoft Hyper-V client drivers"
-	depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST
+	depends on ACPI && ((X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \
+		|| (ARM64 && !CPU_BIG_ENDIAN))
 	select PARAVIRT
 	select X86_HV_CALLBACK_VECTOR

Does this need to be:

select X86_HV_CALLBACK_VECTOR if X86

I haven't checked whether it gives a warning on arm64 but that symbol doesn't exist.

Anyway, I can fix it up locally.

As an additional patch (it can be done later, once this goes upstream) I think we should replace the depends on with a single ARCH_HAS_HYPERV.

Signature · 6 lines
Catalin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#7 lore raw

Re: [PATCH v12 5/5] Drivers: hv: Enable Hyper-V code to be built on ARM64

Quoted 30 lines · Catalin Marinas
Quoted 18 lines · Michael Kelley

Update drivers/hv/Kconfig so CONFIG_HYPERV can be selected on ARM64, causing the Hyper-V specific code to be built. Exclude the Hyper-V enlightened clocks/timers code from being built for ARM64.

---
 drivers/hv/Kconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hv/Kconfig +0 -0
index 66c794d..e509d5d 100644

drivers/hv/Kconfig menu "Microsoft Hyper-V guest support" · line 10

Quoted 8 lines
drivers/hv/Kconfig +2 -1
@@ -4,7 +4,8 @@ menu "Microsoft Hyper-V guest support"
 
 config HYPERV
 	tristate "Microsoft Hyper-V client drivers"
-	depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST
+	depends on ACPI && ((X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \
+		|| (ARM64 && !CPU_BIG_ENDIAN))
 	select PARAVIRT
 	select X86_HV_CALLBACK_VECTOR

Does this need to be:

Quoted 6 lines

select X86_HV_CALLBACK_VECTOR if X86

I haven't checked whether it gives a warning on arm64 but that symbol doesn't exist.

Anyway, I can fix it up locally.

I can fix it up while I queue these patches.

Wei.

#8 lore raw

RE: [PATCH v12 5/5] Drivers: hv: Enable Hyper-V code to be built on ARM64

From: Wei Liu <[email protected]> Sent: Wednesday, August 4, 2021 9:40 AM

Quoted 32 lines · Catalin Marinas
Quoted 30 lines · Michael Kelley
Quoted 18 lines

Update drivers/hv/Kconfig so CONFIG_HYPERV can be selected on ARM64, causing the Hyper-V specific code to be built. Exclude the Hyper-V enlightened clocks/timers code from being built for ARM64.

---
 drivers/hv/Kconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hv/Kconfig +0 -0
index 66c794d..e509d5d 100644

drivers/hv/Kconfig menu "Microsoft Hyper-V guest support" · line 10

Quoted 8 lines
drivers/hv/Kconfig +2 -1
@@ -4,7 +4,8 @@ menu "Microsoft Hyper-V guest support"
 
 config HYPERV
 	tristate "Microsoft Hyper-V client drivers"
-	depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST
+	depends on ACPI && ((X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \
+		|| (ARM64 && !CPU_BIG_ENDIAN))
 	select PARAVIRT
 	select X86_HV_CALLBACK_VECTOR

Does this need to be:

Quoted 4 lines
Quoted 4 lines

select X86_HV_CALLBACK_VECTOR if X86

I haven't checked whether it gives a warning on arm64 but that symbol doesn't exist.

The symbol is only referenced in code under arch/x86, so there's no warning when building for arm64. But yes, it would be good hygiene to add the "if X86".

Michael

Quoted 6 lines
Quoted 2 lines

Anyway, I can fix it up locally.

I can fix it up while I queue these patches.

Wei.

maintainer
#9 lore raw
In reply to Michael Kelley
Quoted 6 lines · Michael Kelley

This series enables Linux guests running on Hyper-V on ARM64 hardware. New ARM64-specific code in arch/arm64/hyperv initializes Hyper-V and its hypercall mechanism. Existing architecture independent drivers for Hyper-V's VMbus and synthetic devices just work when built for ARM64. Hyper-V code is built and included in the image and modules only if CONFIG_HYPERV is enabled.

[...]

Quoted 10 lines

Hyper-V on ARM64 runs with a 4 Kbyte page size, but allows guests with 4K/16K/64K page size. Linux guests with this patch series work with all three supported ARM64 page sizes.

The Hyper-V vPCI driver at drivers/pci/host/pci-hyperv.c has x86/x64-specific code and is not being built for ARM64. Enabling Hyper-V vPCI devices on ARM64 is in progress via a separate set of patches.

This patch set is based on the linux-next20210720 code tree.

Is it possible to rebase this on top of -rc3? Are there any dependencies or do you plan to upstream this via a different tree?

It applies cleanly but it doesn't build for me:

In file included from arch/arm64/include/asm/mshyperv.h:52,

                 from arch/arm64/hyperv/hv_core.c:19:
include/asm-generic/mshyperv.h: In function 'hv_do_rep_hypercall':
include/asm-generic/mshyperv.h:86:3: error: implicit declaration of function 'touch_nmi_watchdog' [-Werror=implicit-function-declaration]
   86 |   touch_nmi_watchdog();
      |   ^~~~~~~~~~~~~~~~~~

A quick fix for the above was to include nmi.h in mshyperv.h.

However, the below I can't fix since there's no trace of hv_common_init() on top of 5.14-rc3:

arch/arm64/hyperv/mshyperv.c: In function 'hyperv_init':
arch/arm64/hyperv/mshyperv.c:66:8: error: implicit declaration of function 'hv_common_init' [-Werror=implicit-function-declaration]

   66 |  ret = hv_common_init();
      |        ^~~~~~~~~~~~~~
arch/arm64/hyperv/mshyperv.c:71:5: error: 'hv_common_cpu_init' undeclared (first use in this function)
   71 |     hv_common_cpu_init, hv_common_cpu_die);
      |     ^~~~~~~~~~~~~~~~~~
arch/arm64/hyperv/mshyperv.c:71:5: note: each undeclared identifier is reported only once for each function it appears in
arch/arm64/hyperv/mshyperv.c:71:25: error: 'hv_common_cpu_die' undeclared (first use in this function)
   71 |     hv_common_cpu_init, hv_common_cpu_die);
      |                         ^~~~~~~~~~~~~~~~~
arch/arm64/hyperv/mshyperv.c:73:3: error: implicit declaration of function 'hv_common_free' [-Werror=implicit-function-declaration]
   73 |   hv_common_free();
      |   ^~~~~~~~~~~~~~
Signature · 1 line
Catalin
maintainer
#10 lore raw
Quoted 17 lines · Catalin Marinas
Quoted 6 lines · Michael Kelley

This series enables Linux guests running on Hyper-V on ARM64 hardware. New ARM64-specific code in arch/arm64/hyperv initializes Hyper-V and its hypercall mechanism. Existing architecture independent drivers for Hyper-V's VMbus and synthetic devices just work when built for ARM64. Hyper-V code is built and included in the image and modules only if CONFIG_HYPERV is enabled.

[...]

Quoted 9 lines

Hyper-V on ARM64 runs with a 4 Kbyte page size, but allows guests with 4K/16K/64K page size. Linux guests with this patch series work with all three supported ARM64 page sizes.

The Hyper-V vPCI driver at drivers/pci/host/pci-hyperv.c has x86/x64-specific code and is not being built for ARM64. Enabling Hyper-V vPCI devices on ARM64 is in progress via a separate set of patches.

Quoted 4 lines
Quoted 1 line

This patch set is based on the linux-next20210720 code tree.

Is it possible to rebase this on top of -rc3? Are there any dependencies or do you plan to upstream this via a different tree?

Some prerequisite patches are in hyperv-next.

https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/log/?h=hyperv-next

Wei.

#11 lore raw
In reply to Catalin Marinas

From: Catalin Marinas <[email protected]> Sent: Wednesday, August 4, 2021 9:26 AM

Quoted 18 lines · Michael Kelley
Quoted 6 lines

This series enables Linux guests running on Hyper-V on ARM64 hardware. New ARM64-specific code in arch/arm64/hyperv initializes Hyper-V and its hypercall mechanism. Existing architecture independent drivers for Hyper-V's VMbus and synthetic devices just work when built for ARM64. Hyper-V code is built and included in the image and modules only if CONFIG_HYPERV is enabled.

[...]

Quoted 9 lines

Hyper-V on ARM64 runs with a 4 Kbyte page size, but allows guests with 4K/16K/64K page size. Linux guests with this patch series work with all three supported ARM64 page sizes.

The Hyper-V vPCI driver at drivers/pci/host/pci-hyperv.c has x86/x64-specific code and is not being built for ARM64. Enabling Hyper-V vPCI devices on ARM64 is in progress via a separate set of patches.

Quoted 5 lines
Quoted 1 line

This patch set is based on the linux-next20210720 code tree.

Is it possible to rebase this on top of -rc3? Are there any dependencies or do you plan to upstream this via a different tree?

There are dependencies on changes in the hyperv-next tree
(https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/)
which is why you are getting the build errors. The changes common-ized some code between the x86 side and previous versions of this patch set (and fixed the #include nmi.h problem). So the code would most naturally go upstream through that tree.

Michael

Quoted 34 lines

It applies cleanly but it doesn't build for me:

In file included from arch/arm64/include/asm/mshyperv.h:52,

                 from arch/arm64/hyperv/hv_core.c:19:
include/asm-generic/mshyperv.h: In function 'hv_do_rep_hypercall':
include/asm-generic/mshyperv.h:86:3: error: implicit declaration of function 'touch_nmi_watchdog' [-Werror=implicit-
function-declaration]
   86 |   touch_nmi_watchdog();
      |   ^~~~~~~~~~~~~~~~~~

A quick fix for the above was to include nmi.h in mshyperv.h.

However, the below I can't fix since there's no trace of hv_common_init() on top of 5.14-rc3:

arch/arm64/hyperv/mshyperv.c: In function 'hyperv_init':
arch/arm64/hyperv/mshyperv.c:66:8: error: implicit declaration of function 'hv_common_init' [-Werror=implicit-function- declaration]

   66 |  ret = hv_common_init();
      |        ^~~~~~~~~~~~~~
arch/arm64/hyperv/mshyperv.c:71:5: error: 'hv_common_cpu_init' undeclared (first use in this function)
   71 |     hv_common_cpu_init, hv_common_cpu_die);
      |     ^~~~~~~~~~~~~~~~~~
arch/arm64/hyperv/mshyperv.c:71:5: note: each undeclared identifier is reported only once for each function it appears in
arch/arm64/hyperv/mshyperv.c:71:25: error: 'hv_common_cpu_die' undeclared (first use in this function)
   71 |     hv_common_cpu_init, hv_common_cpu_die);
      |                         ^~~~~~~~~~~~~~~~~
arch/arm64/hyperv/mshyperv.c:73:3: error: implicit declaration of function 'hv_common_free' [-Werror=implicit-function-
declaration]
   73 |   hv_common_free();
      |   ^~~~~~~~~~~~~~

--
Catalin

maintainer Acked-by
#12 lore raw
Quoted 24 lines · Michael Kelley

From: Catalin Marinas <[email protected]> Sent: Wednesday, August 4, 2021 9:26 AM

Quoted 18 lines · Michael Kelley
Quoted 6 lines

This series enables Linux guests running on Hyper-V on ARM64 hardware. New ARM64-specific code in arch/arm64/hyperv initializes Hyper-V and its hypercall mechanism. Existing architecture independent drivers for Hyper-V's VMbus and synthetic devices just work when built for ARM64. Hyper-V code is built and included in the image and modules only if CONFIG_HYPERV is enabled.

[...]

Quoted 9 lines

Hyper-V on ARM64 runs with a 4 Kbyte page size, but allows guests with 4K/16K/64K page size. Linux guests with this patch series work with all three supported ARM64 page sizes.

The Hyper-V vPCI driver at drivers/pci/host/pci-hyperv.c has x86/x64-specific code and is not being built for ARM64. Enabling Hyper-V vPCI devices on ARM64 is in progress via a separate set of patches.

Quoted 4 lines
Quoted 1 line

This patch set is based on the linux-next20210720 code tree.

Is it possible to rebase this on top of -rc3? Are there any dependencies or do you plan to upstream this via a different tree?

Quoted 6 lines

There are dependencies on changes in the hyperv-next tree
(https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/)
which is why you are getting the build errors. The changes common-ized some code between the x86 side and previous versions of this patch set (and fixed the #include nmi.h problem). So the code would most naturally go upstream through that tree.

In that case, for this series:

I don't think there'd be conflicts with the arm64 changes but we can spot them early in -next.

Signature · 1 line
Catalin
maintainer Applied
#13 lore raw
In reply to Michael Kelley
Quoted 7 lines · Michael Kelley

Michael Kelley (5):
arm64: hyperv: Add Hyper-V hypercall and register access utilities
arm64: hyperv: Add panic handler
arm64: hyperv: Initialize hypervisor on boot
arm64: efi: Export screen_info
Drivers: hv: Enable Hyper-V code to be built on ARM64

Applied to hyperv-next. Thanks.

Wei.