Skip to content

Commit 6dc77fa

Browse files
kelleymhliuw
authored andcommitted
Drivers: hv: Move Hyper-V misc functionality to arch-neutral code
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]>
1 parent 9d7cf2c commit 6dc77fa

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

arch/x86/hyperv/hv_init.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
* Author : K. Y. Srinivasan <[email protected]>
88
*/
99

10-
#include <linux/acpi.h>
1110
#include <linux/efi.h>
1211
#include <linux/types.h>
1312
#include <linux/bitfield.h>
13+
#include <linux/io.h>
1414
#include <asm/apic.h>
1515
#include <asm/desc.h>
1616
#include <asm/hypervisor.h>
@@ -523,12 +523,6 @@ bool hv_is_hyperv_initialized(void)
523523
}
524524
EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized);
525525

526-
bool hv_is_hibernation_supported(void)
527-
{
528-
return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
529-
}
530-
EXPORT_SYMBOL_GPL(hv_is_hibernation_supported);
531-
532526
enum hv_isolation_type hv_get_isolation_type(void)
533527
{
534528
if (!(ms_hyperv.priv_high & HV_ISOLATION))

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <linux/irq.h>
1818
#include <linux/kexec.h>
1919
#include <linux/i8253.h>
20-
#include <linux/panic_notifier.h>
2120
#include <linux/random.h>
2221
#include <asm/processor.h>
2322
#include <asm/hypervisor.h>
@@ -326,16 +325,6 @@ static void __init ms_hyperv_init_platform(void)
326325
ms_hyperv.nested_features);
327326
}
328327

329-
/*
330-
* Hyper-V expects to get crash register data or kmsg when
331-
* crash enlightment is available and system crashes. Set
332-
* crash_kexec_post_notifiers to be true to make sure that
333-
* calling crash enlightment interface before running kdump
334-
* kernel.
335-
*/
336-
if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE)
337-
crash_kexec_post_notifiers = true;
338-
339328
#ifdef CONFIG_X86_LOCAL_APIC
340329
if (ms_hyperv.features & HV_ACCESS_FREQUENCY_MSRS &&
341330
ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {

drivers/hv/hv_common.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
*/
1414

1515
#include <linux/types.h>
16+
#include <linux/acpi.h>
1617
#include <linux/export.h>
1718
#include <linux/bitfield.h>
1819
#include <linux/cpumask.h>
20+
#include <linux/panic_notifier.h>
1921
#include <linux/ptrace.h>
2022
#include <linux/slab.h>
2123
#include <asm/hyperv-tlfs.h>
@@ -70,6 +72,16 @@ int __init hv_common_init(void)
7072
{
7173
int i;
7274

75+
/*
76+
* Hyper-V expects to get crash register data or kmsg when
77+
* crash enlightment is available and system crashes. Set
78+
* crash_kexec_post_notifiers to be true to make sure that
79+
* calling crash enlightment interface before running kdump
80+
* kernel.
81+
*/
82+
if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE)
83+
crash_kexec_post_notifiers = true;
84+
7385
/*
7486
* Allocate the per-CPU state for the hypercall input arg.
7587
* If this allocation fails, we will not be able to setup
@@ -204,6 +216,12 @@ bool hv_query_ext_cap(u64 cap_query)
204216
}
205217
EXPORT_SYMBOL_GPL(hv_query_ext_cap);
206218

219+
bool hv_is_hibernation_supported(void)
220+
{
221+
return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
222+
}
223+
EXPORT_SYMBOL_GPL(hv_is_hibernation_supported);
224+
207225
/* These __weak functions provide default "no-op" behavior and
208226
* may be overridden by architecture specific versions. Architectures
209227
* for which the default "no-op" behavior is sufficient can leave

0 commit comments

Comments
 (0)