Skip to content

Commit 9d7cf2c

Browse files
kelleymhliuw
authored andcommitted
Drivers: hv: Add arch independent default functions for some Hyper-V handlers
Architecture independent Hyper-V code calls various arch-specific handlers when needed. To aid in supporting multiple architectures, provide weak defaults that can be overridden by arch-specific implementations where appropriate. But when arch-specific overrides aren't needed or haven't been implemented yet for a particular architecture, these stubs reduce the amount of clutter under arch/. No functional change. Signed-off-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/1626287687-2045-3-git-send-email-mikelley@microsoft.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent afca4d9 commit 9d7cf2c

3 files changed

Lines changed: 49 additions & 8 deletions

File tree

arch/x86/hyperv/hv_init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ void hyperv_cleanup(void)
468468
hypercall_msr.as_uint64 = 0;
469469
wrmsrl(HV_X64_MSR_REFERENCE_TSC, hypercall_msr.as_uint64);
470470
}
471-
EXPORT_SYMBOL_GPL(hyperv_cleanup);
472471

473472
void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die)
474473
{
@@ -542,4 +541,3 @@ bool hv_is_isolation_supported(void)
542541
{
543542
return hv_get_isolation_type() != HV_ISOLATION_TYPE_NONE;
544543
}
545-
EXPORT_SYMBOL_GPL(hv_is_isolation_supported);

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,12 @@ void hv_setup_vmbus_handler(void (*handler)(void))
6262
{
6363
vmbus_handler = handler;
6464
}
65-
EXPORT_SYMBOL_GPL(hv_setup_vmbus_handler);
6665

6766
void hv_remove_vmbus_handler(void)
6867
{
6968
/* We have no way to deallocate the interrupt gate */
7069
vmbus_handler = NULL;
7170
}
72-
EXPORT_SYMBOL_GPL(hv_remove_vmbus_handler);
7371

7472
/*
7573
* Routines to do per-architecture handling of stimer0
@@ -104,25 +102,21 @@ void hv_setup_kexec_handler(void (*handler)(void))
104102
{
105103
hv_kexec_handler = handler;
106104
}
107-
EXPORT_SYMBOL_GPL(hv_setup_kexec_handler);
108105

109106
void hv_remove_kexec_handler(void)
110107
{
111108
hv_kexec_handler = NULL;
112109
}
113-
EXPORT_SYMBOL_GPL(hv_remove_kexec_handler);
114110

115111
void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs))
116112
{
117113
hv_crash_handler = handler;
118114
}
119-
EXPORT_SYMBOL_GPL(hv_setup_crash_handler);
120115

121116
void hv_remove_crash_handler(void)
122117
{
123118
hv_crash_handler = NULL;
124119
}
125-
EXPORT_SYMBOL_GPL(hv_remove_crash_handler);
126120

127121
#ifdef CONFIG_KEXEC_CORE
128122
static void hv_machine_shutdown(void)

drivers/hv/hv_common.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/export.h>
1717
#include <linux/bitfield.h>
1818
#include <linux/cpumask.h>
19+
#include <linux/ptrace.h>
1920
#include <linux/slab.h>
2021
#include <asm/hyperv-tlfs.h>
2122
#include <asm/mshyperv.h>
@@ -202,3 +203,51 @@ bool hv_query_ext_cap(u64 cap_query)
202203
return hv_extended_cap & cap_query;
203204
}
204205
EXPORT_SYMBOL_GPL(hv_query_ext_cap);
206+
207+
/* These __weak functions provide default "no-op" behavior and
208+
* may be overridden by architecture specific versions. Architectures
209+
* for which the default "no-op" behavior is sufficient can leave
210+
* them unimplemented and not be cluttered with a bunch of stub
211+
* functions in arch-specific code.
212+
*/
213+
214+
bool __weak hv_is_isolation_supported(void)
215+
{
216+
return false;
217+
}
218+
EXPORT_SYMBOL_GPL(hv_is_isolation_supported);
219+
220+
void __weak hv_setup_vmbus_handler(void (*handler)(void))
221+
{
222+
}
223+
EXPORT_SYMBOL_GPL(hv_setup_vmbus_handler);
224+
225+
void __weak hv_remove_vmbus_handler(void)
226+
{
227+
}
228+
EXPORT_SYMBOL_GPL(hv_remove_vmbus_handler);
229+
230+
void __weak hv_setup_kexec_handler(void (*handler)(void))
231+
{
232+
}
233+
EXPORT_SYMBOL_GPL(hv_setup_kexec_handler);
234+
235+
void __weak hv_remove_kexec_handler(void)
236+
{
237+
}
238+
EXPORT_SYMBOL_GPL(hv_remove_kexec_handler);
239+
240+
void __weak hv_setup_crash_handler(void (*handler)(struct pt_regs *regs))
241+
{
242+
}
243+
EXPORT_SYMBOL_GPL(hv_setup_crash_handler);
244+
245+
void __weak hv_remove_crash_handler(void)
246+
{
247+
}
248+
EXPORT_SYMBOL_GPL(hv_remove_crash_handler);
249+
250+
void __weak hyperv_cleanup(void)
251+
{
252+
}
253+
EXPORT_SYMBOL_GPL(hyperv_cleanup);

0 commit comments

Comments
 (0)