> -----Original Message----- > From: mikelley@xxxxxxxxxxxxxxxxxxxxxx > [mailto:mikelley@xxxxxxxxxxxxxxxxxxxxxx] > Sent: Wednesday, October 25, 2017 3:31 PM > To: gregkh@xxxxxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; > devel@xxxxxxxxxxxxxxxxxxxxxx; olaf@xxxxxxxxx; apw@xxxxxxxxxxxxx; > vkuznets@xxxxxxxxxx; jasowang@xxxxxxxxxx; > leann.ogasawara@xxxxxxxxxxxxx; marcelo.cerri@xxxxxxxxxxxxx; Stephen > Hemminger <sthemmin@xxxxxxxxxxxxx>; KY Srinivasan > <kys@xxxxxxxxxxxxx> > Cc: Michael Kelley (EOSG) <Michael.H.Kelley@xxxxxxxxxxxxx> > Subject: [PATCH char-misc 1/1] Hyper-V: Remove x86-isms from architecture > independent Hyper-V drivers > > [This sender failed our fraud detection checks and may not be who they > appear to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing] > > From: Michael Kelley <mikelley@xxxxxxxxxxxxx> > > hv_is_hypercall_page_setup() is used to check if Hyper-V is > initialized, but a 'hypercall page' is an x86 implementation detail > that isn't necessarily present on other architectures. Rename to the > architecture independent hv_is_hyperv_initialized(). Use this function > instead of direct references to x86-specific data structures in > vmbus_drv.c, and remove 'x86' from the string name passed to > cpuhp_setup_state(). > > Signed-off-by: Michael Kelley <mikelley@xxxxxxxxxxxxx> > --- > arch/x86/hyperv/hv_init.c | 4 ++-- > arch/x86/include/asm/mshyperv.h | 4 ++-- > drivers/hv/hv.c | 2 +- > drivers/hv/vmbus_drv.c | 5 ++--- > 4 files changed, 7 insertions(+), 8 deletions(-) > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > index a5db63f728a2..38310bd091c2 100644 > --- a/arch/x86/hyperv/hv_init.c > +++ b/arch/x86/hyperv/hv_init.c > @@ -236,7 +236,7 @@ void hyperv_report_panic(struct pt_regs *regs) > } > EXPORT_SYMBOL_GPL(hyperv_report_panic); > > -bool hv_is_hypercall_page_setup(void) > +bool hv_is_hyperv_initialized(void) > { > union hv_x64_msr_hypercall_contents hypercall_msr; > > @@ -249,4 +249,4 @@ bool hv_is_hypercall_page_setup(void) > > return true; > } > -EXPORT_SYMBOL_GPL(hv_is_hypercall_page_setup); > +EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized); > diff --git a/arch/x86/include/asm/mshyperv.h > b/arch/x86/include/asm/mshyperv.h > index 530f448fddaf..b001f898ccf3 100644 > --- a/arch/x86/include/asm/mshyperv.h > +++ b/arch/x86/include/asm/mshyperv.h > @@ -311,11 +311,11 @@ void hyperv_init(void); > void hyperv_setup_mmu_ops(void); > void hyper_alloc_mmu(void); > void hyperv_report_panic(struct pt_regs *regs); > -bool hv_is_hypercall_page_setup(void); > +bool hv_is_hyperv_initialized(void); > void hyperv_cleanup(void); > #else /* CONFIG_HYPERV */ > static inline void hyperv_init(void) {} > -static inline bool hv_is_hypercall_page_setup(void) { return false; } > +static inline bool hv_is_hyperv_initialized(void) { return false; } > static inline void hyperv_cleanup(void) {} > static inline void hyperv_setup_mmu_ops(void) {} > #endif /* CONFIG_HYPERV */ > diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c > index 8267439dd1ee..ebad26053362 100644 > --- a/drivers/hv/hv.c > +++ b/drivers/hv/hv.c > @@ -49,7 +49,7 @@ struct hv_context hv_context = { > */ > int hv_init(void) > { > - if (!hv_is_hypercall_page_setup()) > + if (!hv_is_hyperv_initialized()) > return -ENOTSUPP; > > hv_context.cpu_context = alloc_percpu(struct hv_per_cpu_context); > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c > index 1da8e818f4de..12c51dc6bb7b 100644 > --- a/drivers/hv/vmbus_drv.c > +++ b/drivers/hv/vmbus_drv.c > @@ -37,7 +37,6 @@ > #include <linux/sched/task_stack.h> > > #include <asm/hyperv.h> > -#include <asm/hypervisor.h> > #include <asm/mshyperv.h> > #include <linux/notifier.h> > #include <linux/ptrace.h> > @@ -1047,7 +1046,7 @@ static int vmbus_bus_init(void) > * Initialize the per-cpu interrupt state and > * connect to the host. > */ > - ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, > "x86/hyperv:online", > + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, > "hyperv/vmbus:online", > hv_synic_init, hv_synic_cleanup); > if (ret < 0) > goto err_alloc; > @@ -1695,7 +1694,7 @@ static int __init hv_acpi_init(void) > { > int ret, t; > > - if (x86_hyper != &x86_hyper_ms_hyperv) > + if (!hv_is_hyperv_initialized()) We are checking to see if we are running on MSFT Hyper-V. This check was added to deal with situations where Xen/KVM were emulating Hyper-V. It may not be safe to replace this check with the call to hv_is_hyperv_initialized(). Perhaps we can add a new architecture independent function to check the hypervisor - something like running_on_mshyperv() that can be used here. Regards, K. Y > return -ENODEV; > > init_completion(&probe_event); > -- > 2.14.1 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel