[PATCH 4/6] drivers/hv: arch-neutral implementation of get_vtl()
From: Roman Kisel This change generalizes the x86-specific implementation of get_vtl() so that it can be used on arm64. Signed-off-by: Roman Kisel --- arch/x86/hyperv/hv_init.c | 34 --- arch/x86/include/asm/hyperv-tlfs.h | 7 - drivers/hv/hv_common.c | 43 ++ include/asm-generic/hyperv-tlfs.h | 7 + include/asm-generic/mshyperv.h | 6 + 5 files changed, 56 insertions(+), 41 deletions(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index 17a71e92a343..c350fa05ee59 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -413,40 +413,6 @@ static void __init hv_get_partition_id(void) local_irq_restore(flags); } -#if IS_ENABLED(CONFIG_HYPERV_VTL_MODE) -static u8 __init get_vtl(void) -{ - u64 control = HV_HYPERCALL_REP_COMP_1 | HVCALL_GET_VP_REGISTERS; - struct hv_get_vp_registers_input *input; - struct hv_get_vp_registers_output *output; - unsigned long flags; - u64 ret; - - local_irq_save(flags); - input = *this_cpu_ptr(hyperv_pcpu_input_arg); - output = (struct hv_get_vp_registers_output *)input; - - memset(input, 0, struct_size(input, element, 1)); - input->header.partitionid = HV_PARTITION_ID_SELF; - input->header.vpindex = HV_VP_INDEX_SELF; - input->header.inputvtl = 0; - input->element[0].name0 = HV_X64_REGISTER_VSM_VP_STATUS; - - ret = hv_do_hypercall(control, input, output); - if (hv_result_success(ret)) { - ret = output->as64.low & HV_X64_VTL_MASK; - } else { - pr_err("Failed to get VTL(error: %lld) exiting...\n", ret); - BUG(); - } - - local_irq_restore(flags); - return ret; -} -#else -static inline u8 get_vtl(void) { return 0; } -#endif - /* * This function is to be invoked early in the boot sequence after the * hypervisor has been detected. diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index 3787d26810c1..9ee68eb8e6ff 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -309,13 +309,6 @@ enum hv_isolation_type { #define HV_MSR_STIMER0_CONFIG (HV_X64_MSR_STIMER0_CONFIG) #define HV_MSR_STIMER0_COUNT (HV_X64_MSR_STIMER0_COUNT) -/* - * Registers are only accessible via HVCALL_GET_VP_REGISTERS hvcall and - * there is not associated MSR address. - */ -#defineHV_X64_REGISTER_VSM_VP_STATUS 0x000D0003 -#defineHV_X64_VTL_MASK GENMASK(3, 0) - /* Hyper-V memory host visibility */ enum hv_mem_host_visibility { VMBUS_PAGE_NOT_VISIBLE = 0, diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index dde3f9b6871a..d4cf477a4d0c 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -660,3 +660,46 @@ u64 __weak hv_tdx_hypercall(u64 control, u64 param1, u64 param2) return HV_STATUS_INVALID_PARAMETER; } EXPORT_SYMBOL_GPL(hv_tdx_hypercall); + +#if IS_ENABLED(CONFIG_HYPERV_VTL_MODE) +u8 __init get_vtl(void) +{ + u64 control = HV_HYPERCALL_REP_COMP_1 | HVCALL_GET_VP_REGISTERS; + struct hv_get_vp_registers_input *input; + struct hv_get_vp_registers_output *output; + unsigned long flags; + u64 ret; + + local_irq_save(flags); + input = *this_cpu_ptr(hyperv_pcpu_input_arg); + output = (struct hv_get_vp_registers_output *)input; + + memset(input, 0, struct_size(input, element, 1)); + input->header.partitionid = HV_PARTITION_ID_SELF; + input->header.vpindex = HV_VP_INDEX_SELF; + input->header.inputvtl = 0; + input->element[0].name0 = HV_REGISTER_VSM_VP_STATUS; + + ret = hv_do_hypercall(control, input, output); + if (hv_result_success(ret)) { + ret = output->as64.low & HV_VTL_MASK; + } else { + pr_err("Failed to get VTL(error: %lld) exiting...\n", ret); + + /* +* This is a dead end, something fundamental is broken. +* +* There is no sensible way of continuing as the Hyper-V drivers +* transitively depend via the vmbus driver on knowing which VTL +* they run in to establish communication with the host. The kernel +* is going to be worse off if continued booting than a panicked one, +* just hung and stuck, producing second-order failures, with neither +* a way to recover nor to provide expected services. +*/ + BUG(); + } + + local_irq_restore(flags); + return ret; +} +#endif diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h index 87e3d49a4e29..682bcda3124f 100644 --- a/include/asm-generic/hyperv-tlfs.h +++ b/include/asm-generic/hyperv-tlfs.h @@ -75,6 +75,13 @@ /* AccessTscInvariantControls privilege */ #define HV_ACC
[PATCH 0/6] arm64/hyperv: Support Virtual Trust Level boot
From: Roman Kisel This set of patches enables the Hyper-V code to boot on ARM64 inside a Virtual Trust Level. These levels are a part of the Virtual Secure Mode documented in the Top-Level Functional Specification available at https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/vsm Roman Kisel (6): arm64/hyperv: Support DeviceTree drivers/hv: Enable VTL mode for arm64 arm64/hyperv: Boot in a Virtual Trust Level drivers/hv: arch-neutral implementation of get_vtl() drivers/hv/vmbus: Get the irq number from DeviceTree drivers/pci/hyperv/arm64: vPCI MSI IRQ domain from DT arch/arm64/hyperv/Makefile | 1 + arch/arm64/hyperv/hv_vtl.c | 19 + arch/arm64/hyperv/mshyperv.c| 40 +++ arch/arm64/include/asm/mshyperv.h | 8 ++ arch/x86/hyperv/hv_init.c | 34 --- arch/x86/hyperv/hv_vtl.c| 2 +- arch/x86/include/asm/hyperv-tlfs.h | 7 - drivers/hv/Kconfig | 6 ++-- drivers/hv/hv_common.c | 43 + drivers/hv/vmbus_drv.c | 37 + drivers/pci/controller/pci-hyperv.c | 13 +++-- include/asm-generic/hyperv-tlfs.h | 7 + include/asm-generic/mshyperv.h | 6 include/linux/acpi.h| 10 +++ 14 files changed, 180 insertions(+), 53 deletions(-) create mode 100644 arch/arm64/hyperv/hv_vtl.c -- 2.45.0
[PATCH 3/6] arm64/hyperv: Boot in a Virtual Trust Level
From: Roman Kisel This change builds upon the previous ones to boot in a Virtual Trust Level and provide configuration for the drivers. Also print the VTL the code runs in the new and the existing code. Signed-off-by: Roman Kisel --- arch/arm64/hyperv/Makefile| 1 + arch/arm64/hyperv/hv_vtl.c| 19 +++ arch/arm64/hyperv/mshyperv.c | 6 ++ arch/arm64/include/asm/mshyperv.h | 8 arch/x86/hyperv/hv_vtl.c | 2 +- 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/hyperv/hv_vtl.c diff --git a/arch/arm64/hyperv/Makefile b/arch/arm64/hyperv/Makefile index 87c31c001da9..9701a837a6e1 100644 --- a/arch/arm64/hyperv/Makefile +++ b/arch/arm64/hyperv/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 obj-y := hv_core.o mshyperv.o +obj-$(CONFIG_HYPERV_VTL_MODE) += hv_vtl.o diff --git a/arch/arm64/hyperv/hv_vtl.c b/arch/arm64/hyperv/hv_vtl.c new file mode 100644 index ..9b44cc49594c --- /dev/null +++ b/arch/arm64/hyperv/hv_vtl.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023, Microsoft, Inc. + * + * Author : Roman Kisel + */ + +#include + +void __init hv_vtl_init_platform(void) +{ + pr_info("Linux runs in Hyper-V Virtual Trust Level %d\n", ms_hyperv.vtl); +} + +int __init hv_vtl_early_init(void) +{ + return 0; +} +early_initcall(hv_vtl_early_init); diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c index 208a3bcb9686..cbde483b167a 100644 --- a/arch/arm64/hyperv/mshyperv.c +++ b/arch/arm64/hyperv/mshyperv.c @@ -96,6 +96,12 @@ static int __init hyperv_init(void) return ret; } + /* Find the VTL */ + ms_hyperv.vtl = get_vtl(); + if (ms_hyperv.vtl > 0) /* non default VTL */ + hv_vtl_early_init(); + + hv_vtl_init_platform(); ms_hyperv_late_init(); hyperv_initialized = true; diff --git a/arch/arm64/include/asm/mshyperv.h b/arch/arm64/include/asm/mshyperv.h index a975e1a689dd..4a8ff6be389c 100644 --- a/arch/arm64/include/asm/mshyperv.h +++ b/arch/arm64/include/asm/mshyperv.h @@ -49,6 +49,14 @@ static inline u64 hv_get_msr(unsigned int reg) ARM_SMCCC_OWNER_VENDOR_HYP, \ HV_SMCCC_FUNC_NUMBER) +#ifdef CONFIG_HYPERV_VTL_MODE +void __init hv_vtl_init_platform(void); +int __init hv_vtl_early_init(void); +#else +static inline void __init hv_vtl_init_platform(void) {} +static inline int __init hv_vtl_early_init(void) { return 0; } +#endif + #include #endif diff --git a/arch/x86/hyperv/hv_vtl.c b/arch/x86/hyperv/hv_vtl.c index 92bd5a55f093..ae3105375a12 100644 --- a/arch/x86/hyperv/hv_vtl.c +++ b/arch/x86/hyperv/hv_vtl.c @@ -19,7 +19,7 @@ static struct real_mode_header hv_vtl_real_mode_header; void __init hv_vtl_init_platform(void) { - pr_info("Linux runs in Hyper-V Virtual Trust Level\n"); + pr_info("Linux runs in Hyper-V Virtual Trust Level %d\n", ms_hyperv.vtl); x86_platform.realmode_reserve = x86_init_noop; x86_platform.realmode_init = x86_init_noop; -- 2.45.0
[PATCH 2/6] drivers/hv: Enable VTL mode for arm64
From: Roman Kisel This change removes dependency on ACPI when buidling the hv drivers to allow Virtual Trust Level boot with DeviceTree. Signed-off-by: Roman Kisel --- drivers/hv/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig index 862c47b191af..a5cd1365e248 100644 --- a/drivers/hv/Kconfig +++ b/drivers/hv/Kconfig @@ -5,7 +5,7 @@ menu "Microsoft Hyper-V guest support" config HYPERV tristate "Microsoft Hyper-V client drivers" depends on (X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \ - || (ACPI && ARM64 && !CPU_BIG_ENDIAN) + || (ARM64 && !CPU_BIG_ENDIAN) select PARAVIRT select X86_HV_CALLBACK_VECTOR if X86 select OF_EARLY_FLATTREE if OF @@ -15,7 +15,7 @@ config HYPERV config HYPERV_VTL_MODE bool "Enable Linux to boot in VTL context" - depends on X86_64 && HYPERV + depends on HYPERV depends on SMP default n help @@ -31,7 +31,7 @@ config HYPERV_VTL_MODE Select this option to build a Linux kernel to run at a VTL other than the normal VTL0, which currently is only VTL2. This option - initializes the x86 platform for VTL2, and adds the ability to boot + initializes the kernel to run in VTL2, and adds the ability to boot secondary CPUs directly into 64-bit context as required for VTLs other than 0. A kernel built with this option must run at VTL2, and will not run as a normal guest. -- 2.45.0
[PATCH 5/6] drivers/hv/vmbus: Get the irq number from DeviceTree
From: Roman Kisel When booting on arm64, one has to configure the irq using the data from the system configuration. There has already been support for ACPI, support DeviceTree as booting in a Virtual Trust Level relies on DT. Signed-off-by: Roman Kisel --- drivers/hv/vmbus_drv.c | 37 + 1 file changed, 37 insertions(+) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index e25223cee3ab..52f01bd1c947 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include "hyperv_vmbus.h" @@ -2316,6 +2317,34 @@ static int vmbus_acpi_add(struct platform_device *pdev) } #endif +static int __maybe_unused vmbus_of_set_irq(struct device_node *np) +{ + struct irq_desc *desc; + int irq; + + irq = of_irq_get(np, 0); + if (irq == 0) { + pr_err("VMBus interrupt mapping failure\n"); + return -EINVAL; + } + if (irq < 0) { + pr_err("VMBus interrupt data can't be read from DeviceTree, error %d\n", irq); + return irq; + } + + desc = irq_to_desc(irq); + if (!desc) { + pr_err("VMBus interrupt description can't be found for virq %d\n", irq); + return -ENODEV; + } + + vmbus_irq = irq; + vmbus_interrupt = desc->irq_data.hwirq; + pr_debug("VMBus virq %d, hwirq %d\n", vmbus_irq, vmbus_interrupt); + + return 0; +} + static int vmbus_device_add(struct platform_device *pdev) { struct resource **cur_res = &hyperv_mmio; @@ -2324,12 +2353,20 @@ static int vmbus_device_add(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; int ret; + pr_debug("VMBus is present in DeviceTree\n"); + hv_dev = &pdev->dev; ret = of_range_parser_init(&parser, np); if (ret) return ret; +#ifndef HYPERVISOR_CALLBACK_VECTOR + ret = vmbus_of_set_irq(np); + if (ret) + return ret; +#endif + for_each_of_range(&parser, &range) { struct resource *res; -- 2.45.0
[PATCH 6/6] drivers/pci/hyperv/arm64: vPCI MSI IRQ domain from DT
From: Roman Kisel This change allows Hyper-V PCI to be enabled on arm64 via DT when booting in a Virtual Trust Level. Signed-off-by: Roman Kisel --- drivers/pci/controller/pci-hyperv.c | 13 ++--- include/linux/acpi.h| 10 ++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 1ea40b8d..ccc2b54206f4 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -906,9 +906,16 @@ static int hv_pci_irqchip_init(void) * way to ensure that all the corresponding devices are also gone and * no interrupts will be generated. */ - hv_msi_gic_irq_domain = acpi_irq_create_hierarchy(0, HV_PCI_MSI_SPI_NR, - fn, &hv_pci_domain_ops, - chip_data); + if (acpi_disabled) + hv_msi_gic_irq_domain = irq_domain_create_hierarchy( + irq_find_matching_fwnode(fn, DOMAIN_BUS_ANY), + 0, HV_PCI_MSI_SPI_NR, + fn, &hv_pci_domain_ops, + chip_data); + else + hv_msi_gic_irq_domain = acpi_irq_create_hierarchy(0, HV_PCI_MSI_SPI_NR, + fn, &hv_pci_domain_ops, + chip_data); if (!hv_msi_gic_irq_domain) { pr_err("Failed to create Hyper-V arm64 vPCI MSI IRQ domain\n"); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index b7165e52b3c6..eb93d355bb6d 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1077,6 +1077,16 @@ static inline bool acpi_sleep_state_supported(u8 sleep_state) return false; } + +static inline struct irq_domain *acpi_irq_create_hierarchy(unsigned int flags, +unsigned int size, +struct fwnode_handle *fwnode, +const struct irq_domain_ops *ops, +void *host_data) +{ + return NULL; +} + #endif /* !CONFIG_ACPI */ extern void arch_post_acpi_subsys_init(void); -- 2.45.0
[PATCH 1/6] arm64/hyperv: Support DeviceTree
From: Roman Kisel Update the driver to support DeviceTree boot as well along with ACPI. This enables the Virtual Trust Level platforms boot up on ARM64. Signed-off-by: Roman Kisel --- arch/arm64/hyperv/mshyperv.c | 34 +- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c index b1a4de4eee29..208a3bcb9686 100644 --- a/arch/arm64/hyperv/mshyperv.c +++ b/arch/arm64/hyperv/mshyperv.c @@ -15,6 +15,9 @@ #include #include #include +#include +#include +#include #include static bool hyperv_initialized; @@ -27,6 +30,29 @@ int hv_get_hypervisor_version(union hv_hypervisor_version_info *info) return 0; } +static bool hyperv_detect_fdt(void) +{ +#ifdef CONFIG_OF + const unsigned long hyp_node = of_get_flat_dt_subnode_by_name( + of_get_flat_dt_root(), "hypervisor"); + + return (hyp_node != -FDT_ERR_NOTFOUND) && + of_flat_dt_is_compatible(hyp_node, "microsoft,hyperv"); +#else + return false; +#endif +} + +static bool hyperv_detect_acpi(void) +{ +#ifdef CONFIG_ACPI + return !acpi_disabled && + !strncmp((char *)&acpi_gbl_FADT.hypervisor_id, "MsHyperV", 8); +#else + return false; +#endif +} + static int __init hyperv_init(void) { struct hv_get_vp_registers_output result; @@ -35,13 +61,11 @@ static int __init hyperv_init(void) /* * Allow for a kernel built with CONFIG_HYPERV to be running in -* a non-Hyper-V environment, including on DT instead of ACPI. +* a non-Hyper-V environment. +* * In such cases, do nothing and return success. */ - if (acpi_disabled) - return 0; - - if (strncmp((char *)&acpi_gbl_FADT.hypervisor_id, "MsHyperV", 8)) + if (!hyperv_detect_fdt() && !hyperv_detect_acpi()) return 0; /* Setup the guest ID */ -- 2.45.0
Re: [PATCH 1/6] arm64/hyperv: Support DeviceTree
On 5/10/2024 9:05 AM, rom...@linux.microsoft.com wrote: > From: Roman Kisel > > Update the driver to support DeviceTree boot as well along with ACPI. > This enables the Virtual Trust Level platforms boot up on ARM64. > > Signed-off-by: Roman Kisel > --- > arch/arm64/hyperv/mshyperv.c | 34 +- > 1 file changed, 29 insertions(+), 5 deletions(-) > > diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c > index b1a4de4eee29..208a3bcb9686 100644 > --- a/arch/arm64/hyperv/mshyperv.c > +++ b/arch/arm64/hyperv/mshyperv.c > @@ -15,6 +15,9 @@ > #include > #include > #include > +#include > +#include > +#include > #include > > static bool hyperv_initialized; > @@ -27,6 +30,29 @@ int hv_get_hypervisor_version(union > hv_hypervisor_version_info *info) > return 0; > } > > +static bool hyperv_detect_fdt(void) > +{ > +#ifdef CONFIG_OF > + const unsigned long hyp_node = of_get_flat_dt_subnode_by_name( > + of_get_flat_dt_root(), "hypervisor"); > + > + return (hyp_node != -FDT_ERR_NOTFOUND) && > + of_flat_dt_is_compatible(hyp_node, "microsoft,hyperv"); > +#else > + return false; > +#endif > +} > + > +static bool hyperv_detect_acpi(void) > +{ > +#ifdef CONFIG_ACPI > + return !acpi_disabled && > + !strncmp((char *)&acpi_gbl_FADT.hypervisor_id, > "MsHyperV", 8); > +#else > + return false; > +#endif > +} > + Could using IS_ENABLED() allow collapsing these two functions into one hyperv_detect_fw()? I am wondering if #ifdef was explicitly chosen to allow for the code to be compiled in if CONFIG* is defined v/s IS_ENABLED() only being true if the CONFIG value is true. > static int __init hyperv_init(void) > { > struct hv_get_vp_registers_output result; > @@ -35,13 +61,11 @@ static int __init hyperv_init(void) > > /* >* Allow for a kernel built with CONFIG_HYPERV to be running in > - * a non-Hyper-V environment, including on DT instead of ACPI. > + * a non-Hyper-V environment. > + * >* In such cases, do nothing and return success. >*/ > - if (acpi_disabled) > - return 0; > - > - if (strncmp((char *)&acpi_gbl_FADT.hypervisor_id, "MsHyperV", 8)) > + if (!hyperv_detect_fdt() && !hyperv_detect_acpi()) > return 0; > > /* Setup the guest ID */
Re: [PATCH 1/6] arm64/hyperv: Support DeviceTree
On 5/10/2024 10:04 AM, Easwar Hariharan wrote: On 5/10/2024 9:05 AM, rom...@linux.microsoft.com wrote: From: Roman Kisel Update the driver to support DeviceTree boot as well along with ACPI. This enables the Virtual Trust Level platforms boot up on ARM64. Signed-off-by: Roman Kisel --- arch/arm64/hyperv/mshyperv.c | 34 +- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c index b1a4de4eee29..208a3bcb9686 100644 --- a/arch/arm64/hyperv/mshyperv.c +++ b/arch/arm64/hyperv/mshyperv.c @@ -15,6 +15,9 @@ #include #include #include +#include +#include +#include #include static bool hyperv_initialized; @@ -27,6 +30,29 @@ int hv_get_hypervisor_version(union hv_hypervisor_version_info *info) return 0; } +static bool hyperv_detect_fdt(void) +{ +#ifdef CONFIG_OF + const unsigned long hyp_node = of_get_flat_dt_subnode_by_name( + of_get_flat_dt_root(), "hypervisor"); + + return (hyp_node != -FDT_ERR_NOTFOUND) && + of_flat_dt_is_compatible(hyp_node, "microsoft,hyperv"); +#else + return false; +#endif +} + +static bool hyperv_detect_acpi(void) +{ +#ifdef CONFIG_ACPI + return !acpi_disabled && + !strncmp((char *)&acpi_gbl_FADT.hypervisor_id, "MsHyperV", 8); +#else + return false; +#endif +} + Could using IS_ENABLED() allow collapsing these two functions into one hyperv_detect_fw()? I am wondering if #ifdef was explicitly chosen to allow for the code to be compiled in if CONFIG* is defined v/s IS_ENABLED() only being true if the CONFIG value is true. In the hyperv_detect_fdt function, the #ifdef has been chosen due to the functions being declared only when the macro is defined, hence I could not rely on `if IS_ENABLED()` and the run-time detection. For the compile-time option, `#if IS_ENABLED()` would convey the intent better, could update with that. In the hyperv_detect_acpi function, using of the #ifdef appears to be not needed, will remove that in the next version of the patch set. Appreciate your help! As for combining the functions into one, the result looks less readable due to more if statements and is mixing the concerns to an extent. That said, unless you feel strongly about having just one function here, perhaps could keep the both functions. static int __init hyperv_init(void) { struct hv_get_vp_registers_output result; @@ -35,13 +61,11 @@ static int __init hyperv_init(void) /* * Allow for a kernel built with CONFIG_HYPERV to be running in -* a non-Hyper-V environment, including on DT instead of ACPI. +* a non-Hyper-V environment. +* * In such cases, do nothing and return success. */ - if (acpi_disabled) - return 0; - - if (strncmp((char *)&acpi_gbl_FADT.hypervisor_id, "MsHyperV", 8)) + if (!hyperv_detect_fdt() && !hyperv_detect_acpi()) return 0; /* Setup the guest ID */ -- Thank you, Roman