Subject: [PATCH 2/2] x86: make hyperv support optional

Make it possible to opt-out from hyperv support.

Signed-off-by: Enrico Weigelt, metux IT consult <[email protected]>
---
arch/x86/Kconfig | 7 +++++++
arch/x86/kernel/cpu/Makefile | 4 ++--
arch/x86/kernel/cpu/hypervisor.c | 2 ++
drivers/hv/Kconfig | 2 +-
4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c227c1fa0091..60aab344d6ab 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -808,6 +808,13 @@ config VMWARE_GUEST
This option enables several optimizations for running under the
VMware hypervisor.

+config HYPERV_GUEST
+ bool "HyperV Guest support"
+ default y
+ help
+ This option enables several optimizations for running under the
+ HyperV hypervisor.
+
config KVM_GUEST
bool "KVM Guest support (including kvmclock)"
depends on PARAVIRT
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index a615b0152bf0..5536b801cb44 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -51,9 +51,9 @@ obj-$(CONFIG_X86_CPU_RESCTRL) += resctrl/

obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o

-obj-$(CONFIG_HYPERVISOR_GUEST) += hypervisor.o mshyperv.o
+obj-$(CONFIG_HYPERVISOR_GUEST) += hypervisor.o
obj-$(CONFIG_VMWARE_GUEST) += vmware.o
-
+obj-$(CONFIG_HYPERV_GUEST) += mshyperv.o
obj-$(CONFIG_ACRN_GUEST) += acrn.o

ifdef CONFIG_X86_FEATURE_NAMES
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index c0e770a224aa..32d6b2084d05 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -37,7 +37,9 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
#ifdef CONFIG_VMWARE_GUEST
&x86_hyper_vmware,
#endif
+#ifdef CONFIG_HYPERV_GUEST
&x86_hyper_ms_hyperv,
+#endif
#ifdef CONFIG_KVM_GUEST
&x86_hyper_kvm,
#endif
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 79e5356a737a..7b3094c59a81 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -4,7 +4,7 @@ menu "Microsoft Hyper-V guest support"

config HYPERV
tristate "Microsoft Hyper-V client drivers"
- depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST
+ depends on X86 && ACPI && X86_LOCAL_APIC && HYPERV_GUEST
select PARAVIRT
select X86_HV_CALLBACK_VECTOR
help
--
2.11.0


2020-11-18 09:25:24

by Wei Liu

[permalink] [raw]
Subject: Re: [PATCH 2/2] x86: make hyperv support optional

On Tue, Nov 17, 2020 at 09:23:08PM +0100, Enrico Weigelt, metux IT consult wrote:
> Make it possible to opt-out from hyperv support.
>

"Hyper-V support".

Have you tested this patch? If so, how?

> Signed-off-by: Enrico Weigelt, metux IT consult <[email protected]>
> ---
> arch/x86/Kconfig | 7 +++++++
> arch/x86/kernel/cpu/Makefile | 4 ++--
> arch/x86/kernel/cpu/hypervisor.c | 2 ++
> drivers/hv/Kconfig | 2 +-
> 4 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index c227c1fa0091..60aab344d6ab 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -808,6 +808,13 @@ config VMWARE_GUEST
> This option enables several optimizations for running under the
> VMware hypervisor.
>
> +config HYPERV_GUEST
> + bool "HyperV Guest support"

Hyper-V here.

> + default y
> + help
> + This option enables several optimizations for running under the
> + HyperV hypervisor.
> +

"for running under Hyper-V".

> config KVM_GUEST
> bool "KVM Guest support (including kvmclock)"
> depends on PARAVIRT
> diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
> index a615b0152bf0..5536b801cb44 100644
> --- a/arch/x86/kernel/cpu/Makefile
> +++ b/arch/x86/kernel/cpu/Makefile
> @@ -51,9 +51,9 @@ obj-$(CONFIG_X86_CPU_RESCTRL) += resctrl/
>
> obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o
>
> -obj-$(CONFIG_HYPERVISOR_GUEST) += hypervisor.o mshyperv.o
> +obj-$(CONFIG_HYPERVISOR_GUEST) += hypervisor.o
> obj-$(CONFIG_VMWARE_GUEST) += vmware.o
> -
> +obj-$(CONFIG_HYPERV_GUEST) += mshyperv.o
> obj-$(CONFIG_ACRN_GUEST) += acrn.o
>
> ifdef CONFIG_X86_FEATURE_NAMES
> diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
> index c0e770a224aa..32d6b2084d05 100644
> --- a/arch/x86/kernel/cpu/hypervisor.c
> +++ b/arch/x86/kernel/cpu/hypervisor.c
> @@ -37,7 +37,9 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
> #ifdef CONFIG_VMWARE_GUEST
> &x86_hyper_vmware,
> #endif
> +#ifdef CONFIG_HYPERV_GUEST
> &x86_hyper_ms_hyperv,
> +#endif
> #ifdef CONFIG_KVM_GUEST
> &x86_hyper_kvm,
> #endif
> diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
> index 79e5356a737a..7b3094c59a81 100644
> --- a/drivers/hv/Kconfig
> +++ b/drivers/hv/Kconfig
> @@ -4,7 +4,7 @@ menu "Microsoft Hyper-V guest support"
>
> config HYPERV
> tristate "Microsoft Hyper-V client drivers"
> - depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST
> + depends on X86 && ACPI && X86_LOCAL_APIC && HYPERV_GUEST
> select PARAVIRT
> select X86_HV_CALLBACK_VECTOR
> help

Maybe that one should be moved to x86/Kconfig and used instead?

Wei.

> --
> 2.11.0
>