git: 654749832b89 - main - arm64: Hyper-V: fixing hung issue during Hyper-V initialization
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 01 Nov 2022 14:15:06 UTC
The branch main has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=654749832b8900656b40d317a3ad9beab2413a8d commit 654749832b8900656b40d317a3ad9beab2413a8d Author: Souradeep Chakrabarti <schakrabarti@microsoft.com> AuthorDate: 2022-11-01 14:06:01 +0000 Commit: Wei Hu <whu@FreeBSD.org> CommitDate: 2022-11-01 14:13:50 +0000 arm64: Hyper-V: fixing hung issue during Hyper-V initialization In non-Hyper-V systems during Hyper-V initialization, system initialization was getting hung, as hyperv_identify(), was returning successful irrespective of the type of the platform. Reviewed by: andrew, whu Fixes: 9729f076e4d Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D37219 --- sys/dev/hyperv/vmbus/aarch64/hyperv_aarch64.c | 42 ++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/sys/dev/hyperv/vmbus/aarch64/hyperv_aarch64.c b/sys/dev/hyperv/vmbus/aarch64/hyperv_aarch64.c index eb915131fb6f..47390ad35c0f 100644 --- a/sys/dev/hyperv/vmbus/aarch64/hyperv_aarch64.c +++ b/sys/dev/hyperv/vmbus/aarch64/hyperv_aarch64.c @@ -50,12 +50,15 @@ __FBSDID("$FreeBSD$"); #include <dev/hyperv/vmbus/aarch64/hyperv_reg.h> #include <dev/hyperv/vmbus/hyperv_var.h> #include <dev/hyperv/vmbus/hyperv_common_reg.h> +#include <contrib/dev/acpica/include/acpi.h> void hyperv_init_tc(void); int hypercall_page_setup(vm_paddr_t); void hypercall_disable(void); bool hyperv_identify_features(void); +static bool is_hyperv(void); + u_int hyperv_ver_major; u_int hyperv_features; u_int hyperv_recommends; @@ -80,12 +83,49 @@ hypercall_disable(void) return; } +/* + * This function verifies if the platform is Hyper-V or not. + * To do that we are using ACPI FADT and for that, acpi + * fadt is mapped first. + */ +static bool +is_hyperv(void) +{ + ACPI_TABLE_FADT *fadt; + vm_paddr_t physaddr; + uint64_t hypervid; + bool ret; + + physaddr = acpi_find_table(ACPI_SIG_FADT); + if (physaddr == 0) + return (false); + + fadt = acpi_map_table(physaddr, ACPI_SIG_FADT); + if (fadt == NULL) { + printf("hyperv: Unable to map the FADT\n"); + return (false); + } + + hypervid = fadt->HypervisorId; + acpi_unmap_table(fadt); + ret = strncmp((char *)&hypervid, "MsHyperV", 8) == 0 ? true : false; + return (ret); +} + bool hyperv_identify_features(void) { struct hv_get_vp_registers_output result; - vm_guest = VM_GUEST_HV; + if (resource_disabled("acpi", 0)) + return (false); + if (!is_hyperv()) + return (false); + + vm_guest = VM_GUEST_HV; + /* use MSRs to get the hyperv specific + * attributes. + */ hv_get_vpreg_128(CPUID_LEAF_HV_FEATURES, &result); hyperv_features = result.as32.a; hv_get_vpreg_128(CPUID_LEAF_HV_IDENTITY, &result);