Re: git: 9729f076e4d9 - main - arm64: Hyper-V: enablement for ARM64 in Hyper-V (Part 3, final)

From: Andrew Turner <andrew_at_fubar.geek.nz>
Date: Thu, 27 Oct 2022 14:55:56 UTC
I was planning on testing this as I now have appropriate hardware to run arm64 Hyper-V. I have left some comments below.

I am seeing FreeBSD/arm64 hang at the following point under Hyper-V on a Microsoft Dev Kit 2023 box:

vmbus0: decoding 3 range 0xe0000000-0xfed3ffff
vmbus0: fb: fb_addr: 0xe0000000, size: 0x800000, actual size needed: 0xc0000
vmbus0: allocated type 3 (0xe0000000-0xe07fffff) for rid 0 of vmbus0
vmbus0: successfully reserved memory for framebuffer starting at 0xe0000000, size 0x800000
vmbus0: irq 0x2, vector 0 end 0x2
vmbus0: the irq 18
vmbus0: smp_started = 0

> On 27 Oct 2022, at 14:54, Wei Hu <whu@FreeBSD.org> wrote:
> 
> The branch main has been updated by whu:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=9729f076e4d93c5a37e78d427bfe0f1ab99bbcc6
> 
> commit 9729f076e4d93c5a37e78d427bfe0f1ab99bbcc6
> Author:     Souradeep Chakrabarti <schakrabarti@microsoft.com>
> AuthorDate: 2022-10-27 13:46:08 +0000
> Commit:     Wei Hu <whu@FreeBSD.org>
> CommitDate: 2022-10-27 13:53:22 +0000
> 
>    arm64: Hyper-V: enablement for ARM64 in Hyper-V (Part 3, final)
> 
>    This is the last part for ARM64 Hyper-V enablement. This includes
>    commone files and make file changes to enable the ARM64 FreeBSD
>    guest on Hyper-V. With this patch, it should be able to build
>    the ARM64 image and install it on Hyper-V.
> 
>    Reviewed by:    emaste, andrew, whu
>    Tested by:      Souradeep Chakrabarti <schakrabarti@microsoft.com>
>    Sponsored by:   Microsoft
>    Differential Revision:  https://reviews.freebsd.org/D36744
> ---
> share/mk/src.opts.mk                        |   3 +-
> sys/arm64/conf/GENERIC                      |   1 +
> sys/arm64/conf/std.dev                      |   3 +
> sys/arm64/conf/std.hyperv                   |   6 +
> sys/conf/files.arm64                        |  22 ++++
> sys/conf/files.x86                          |   2 +
> sys/dev/hyperv/include/hyperv.h             |   5 +
> sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c |   5 +-
> sys/dev/hyperv/vmbus/hyperv.c               | 194 +++------------------------
> sys/dev/hyperv/vmbus/hyperv_machdep.h       |  37 ------
> sys/dev/hyperv/vmbus/hyperv_reg.h           | 193 ---------------------------
> sys/dev/hyperv/vmbus/hyperv_var.h           |   4 +
> sys/dev/hyperv/vmbus/i386/hyperv_machdep.c  |   2 +-
> sys/dev/hyperv/vmbus/vmbus.c                | 197 +++++++++-------------------
> sys/dev/hyperv/vmbus/vmbus_et.c             |   7 +-
> sys/dev/hyperv/vmbus/vmbus_reg.h            |   7 +-
> sys/dev/hyperv/vmbus/vmbus_var.h            |  15 +++
> sys/modules/Makefile                        |   1 +
> sys/modules/hyperv/utilities/Makefile       |   1 -
> sys/modules/hyperv/vmbus/Makefile           |  11 +-
> 20 files changed, 164 insertions(+), 552 deletions(-)
> 
> diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
> index a03b8147ecbb..4c0913474ef7 100644
> --- a/share/mk/src.opts.mk
> +++ b/share/mk/src.opts.mk
> @@ -332,8 +332,7 @@ BROKEN_OPTIONS+=CXGBETOOL
> BROKEN_OPTIONS+=MLX5TOOL
> .endif
> 
> -# HyperV is currently x86-only
> -.if ${__T} != "amd64" && ${__T} != "i386"
> +.if ${__T} != "amd64" && ${__T} != "i386" && ${__T} != "aarch64"
> BROKEN_OPTIONS+=HYPERV
> .endif
> 
> diff --git a/sys/arm64/conf/GENERIC b/sys/arm64/conf/GENERIC
> index c716183aae61..60772893cdbb 100644
> --- a/sys/arm64/conf/GENERIC
> +++ b/sys/arm64/conf/GENERIC
> @@ -31,6 +31,7 @@ include		"std.amd"
> include		"std.arm"
> include		"std.broadcom"
> include		"std.cavium"
> +include		"std.hyperv"
> include		"std.hisilicon"
> include		"std.imx"
> include		"std.marvell"
> diff --git a/sys/arm64/conf/std.dev b/sys/arm64/conf/std.dev
> index 6ef7358e5e85..8cdd35e2fd21 100644
> --- a/sys/arm64/conf/std.dev
> +++ b/sys/arm64/conf/std.dev
> @@ -107,3 +107,6 @@ device		mmcsd			# mmc/sd flash cards
> # HID support
> options 	HID_DEBUG		# enable debug msgs
> device		hid			# Generic HID support
> +
> +#hyper-v support
> +device		hyperv
This should only be in std.hyperv

> diff --git a/sys/arm64/conf/std.hyperv b/sys/arm64/conf/std.hyperv
> new file mode 100644
> index 000000000000..f87082f15c96
> --- /dev/null
> +++ b/sys/arm64/conf/std.hyperv
> @@ -0,0 +1,6 @@
> +#
> +# Hyper-V support (Hyper-v Gen 2)
> +#
> +
> +#hyper-v support
> +device      hyperv

This file is missing a few devices needed by hyper-v, e.g. the uart and acpi. It should be complete enough so the following kernel config will boot:

cpu ARM64
ident HYPERV
include "std.arm64"
include “std.dev"
include “std.hyperv"

> diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64
> index 5178048cb0af..8b6ba43d2a3d 100644
> --- a/sys/conf/files.arm64
> +++ b/sys/conf/files.arm64
> @@ -624,3 +624,25 @@ arm64/rockchip/clk/rk3399_pmucru.c		optional fdt soc_rockchip_rk3399
> 
> # Xilinx
> arm/xilinx/uart_dev_cdnc.c			optional uart soc_xilinx_zynq
> +
> +# Microsoft Hyper-V

This should probably be in the Device driver section, and be in alphabetical order.

> +dev/hyperv/vmbus/hyperv.c		optional	hyperv
> +dev/hyperv/vmbus/aarch64/hyperv_aarch64.c		optional    hyperv
> +dev/hyperv/vmbus/vmbus.c				optional	hyperv pci
> +dev/hyperv/vmbus/aarch64/vmbus_aarch64.c		optional    hyperv
> +dev/hyperv/vmbus/vmbus_if.m				optional	hyperv
> +dev/hyperv/vmbus/vmbus_res.c				optional	hyperv
> +dev/hyperv/vmbus/vmbus_xact.c				optional	hyperv
> +dev/hyperv/vmbus/aarch64/hyperv_machdep.c				optional    hyperv
> +dev/hyperv/vmbus/vmbus_chan.c				optional 		hyperv
> +dev/hyperv/vmbus/hyperv_busdma.c				optional hyperv
> +dev/hyperv/vmbus/vmbus_br.c				optional 	hyperv
> +dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c				optional hyperv
> +dev/hyperv/utilities/vmbus_timesync.c				optional        hyperv
> +dev/hyperv/utilities/vmbus_heartbeat.c				optional    hyperv
> +dev/hyperv/utilities/vmbus_ic.c				optional    hyperv
> +dev/hyperv/utilities/vmbus_shutdown.c				optional    hyperv
> +dev/hyperv/utilities/hv_kvp.c			optional   hyperv
> +dev/hyperv/netvsc/hn_nvs.c				optional	hyperv
> +dev/hyperv/netvsc/hn_rndis.c			optional	hyperv
> +dev/hyperv/netvsc/if_hn.c				optional	hyperv

The indentation for all the above should be cleaned up.

Andrew