Drivers: hv: Move Hyper-V misc functionality to arch-neutral code
authorMichael Kelley <mikelley@microsoft.com>
Wed, 14 Jul 2021 18:34:47 +0000 (11:34 -0700)
committerWei Liu <wei.liu@kernel.org>
Thu, 15 Jul 2021 12:59:45 +0000 (12:59 +0000)
The check for whether hibernation is possible, and the enabling of
Hyper-V panic notification during kexec, are both architecture neutral.
Move the code from under arch/x86 and into drivers/hv/hv_common.c where
it can also be used for ARM64.

No functional change.

Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/1626287687-2045-4-git-send-email-mikelley@microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
arch/x86/hyperv/hv_init.c
arch/x86/kernel/cpu/mshyperv.c
drivers/hv/hv_common.c

index e87a0293b705d21c89d07d53ad25c5d196bab6f1..6f247e7e07eb516b0ed3540981a6b106ca47ed9d 100644 (file)
@@ -7,10 +7,10 @@
  * Author : K. Y. Srinivasan <kys@microsoft.com>
  */
 
-#include <linux/acpi.h>
 #include <linux/efi.h>
 #include <linux/types.h>
 #include <linux/bitfield.h>
+#include <linux/io.h>
 #include <asm/apic.h>
 #include <asm/desc.h>
 #include <asm/hypervisor.h>
@@ -523,12 +523,6 @@ bool hv_is_hyperv_initialized(void)
 }
 EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized);
 
-bool hv_is_hibernation_supported(void)
-{
-       return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
-}
-EXPORT_SYMBOL_GPL(hv_is_hibernation_supported);
-
 enum hv_isolation_type hv_get_isolation_type(void)
 {
        if (!(ms_hyperv.priv_high & HV_ISOLATION))
index 0b647965e0390e44e8455c13bae5ca96797323e9..30baae031481b9c3b0d2f8bca4824d3d1c48b593 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/irq.h>
 #include <linux/kexec.h>
 #include <linux/i8253.h>
-#include <linux/panic_notifier.h>
 #include <linux/random.h>
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
@@ -326,16 +325,6 @@ static void __init ms_hyperv_init_platform(void)
                        ms_hyperv.nested_features);
        }
 
-       /*
-        * Hyper-V expects to get crash register data or kmsg when
-        * crash enlightment is available and system crashes. Set
-        * crash_kexec_post_notifiers to be true to make sure that
-        * calling crash enlightment interface before running kdump
-        * kernel.
-        */
-       if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE)
-               crash_kexec_post_notifiers = true;
-
 #ifdef CONFIG_X86_LOCAL_APIC
        if (ms_hyperv.features & HV_ACCESS_FREQUENCY_MSRS &&
            ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {
index fe333f410d1d525d94c4bd7342464137edafe2f1..46658de78050e5140f38c1b5856023b65c8a36ae 100644 (file)
  */
 
 #include <linux/types.h>
+#include <linux/acpi.h>
 #include <linux/export.h>
 #include <linux/bitfield.h>
 #include <linux/cpumask.h>
+#include <linux/panic_notifier.h>
 #include <linux/ptrace.h>
 #include <linux/slab.h>
 #include <asm/hyperv-tlfs.h>
@@ -70,6 +72,16 @@ int __init hv_common_init(void)
 {
        int i;
 
+       /*
+        * Hyper-V expects to get crash register data or kmsg when
+        * crash enlightment is available and system crashes. Set
+        * crash_kexec_post_notifiers to be true to make sure that
+        * calling crash enlightment interface before running kdump
+        * kernel.
+        */
+       if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE)
+               crash_kexec_post_notifiers = true;
+
        /*
         * Allocate the per-CPU state for the hypercall input arg.
         * If this allocation fails, we will not be able to setup
@@ -204,6 +216,12 @@ bool hv_query_ext_cap(u64 cap_query)
 }
 EXPORT_SYMBOL_GPL(hv_query_ext_cap);
 
+bool hv_is_hibernation_supported(void)
+{
+       return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
+}
+EXPORT_SYMBOL_GPL(hv_is_hibernation_supported);
+
 /* These __weak functions provide default "no-op" behavior and
  * may be overridden by architecture specific versions. Architectures
  * for which the default "no-op" behavior is sufficient can leave