aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhenzhong Duan <zhenzhong.duan@oracle.com>2019-07-11 08:02:09 -0400
committerJuergen Gross <jgross@suse.com>2019-07-17 02:09:58 -0400
commit30978346372e5c43a652cfbd4533c6bd5427c33b (patch)
tree0fb7e6a976d391af1469f7c4e210bef06e7ef5cb
parent1b37683cda0217305837fd1b79e7c57104d4f983 (diff)
x86: Add "nopv" parameter to disable PV extensions
In virtualization environment, PV extensions (drivers, interrupts, timers, etc) are enabled in the majority of use cases which is the best option. However, in some cases (kexec not fully working, benchmarking) we want to disable PV extensions. We have "xen_nopv" for that purpose but only for XEN. For a consistent admin experience a common command line parameter "nopv" set across all PV guest implementations is a better choice. There are guest types which just won't work without PV extensions, like Xen PV, Xen PVH and jailhouse. add a "ignore_nopv" member to struct hypervisor_x86 set to true for those guest types and call the detect functions only if nopv is false or ignore_nopv is true. Suggested-by: Juergen Gross <jgross@suse.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com> Reviewed-by: Juergen Gross <jgross@suse.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Jan Kiszka <jan.kiszka@siemens.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Stefano Stabellini <sstabellini@kernel.org> Signed-off-by: Juergen Gross <jgross@suse.com>
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt5
-rw-r--r--arch/x86/include/asm/hypervisor.h4
-rw-r--r--arch/x86/kernel/cpu/hypervisor.c11
-rw-r--r--arch/x86/kernel/jailhouse.c1
-rw-r--r--arch/x86/xen/enlighten_pv.c1
5 files changed, 22 insertions, 0 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 99db4975e6b5..936e8e7e6474 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5257,6 +5257,11 @@
5257 improve timer resolution at the expense of processing 5257 improve timer resolution at the expense of processing
5258 more timer interrupts. 5258 more timer interrupts.
5259 5259
5260 nopv= [X86,XEN,KVM,HYPER_V,VMWARE]
5261 Disables the PV optimizations forcing the guest to run
5262 as generic guest with no PV drivers. Currently support
5263 XEN HVM, KVM, HYPER_V and VMWARE guest.
5264
5260 xirc2ps_cs= [NET,PCMCIA] 5265 xirc2ps_cs= [NET,PCMCIA]
5261 Format: 5266 Format:
5262 <irq>,<irq_mask>,<io>,<full_duplex>,<do_sound>,<lockup_hack>[,<irq2>[,<irq3>[,<irq4>]]] 5267 <irq>,<irq_mask>,<io>,<full_duplex>,<do_sound>,<lockup_hack>[,<irq2>[,<irq3>[,<irq4>]]]
diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
index 50a30f6c668b..f7b4c5338428 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -53,8 +53,12 @@ struct hypervisor_x86 {
53 53
54 /* runtime callbacks */ 54 /* runtime callbacks */
55 struct x86_hyper_runtime runtime; 55 struct x86_hyper_runtime runtime;
56
57 /* ignore nopv parameter */
58 bool ignore_nopv;
56}; 59};
57 60
61extern bool nopv;
58extern enum x86_hypervisor_type x86_hyper_type; 62extern enum x86_hypervisor_type x86_hyper_type;
59extern void init_hypervisor_platform(void); 63extern void init_hypervisor_platform(void);
60static inline bool hypervisor_is_type(enum x86_hypervisor_type type) 64static inline bool hypervisor_is_type(enum x86_hypervisor_type type)
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index 87e39ad8d873..7eaad41c68f4 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -58,6 +58,14 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
58enum x86_hypervisor_type x86_hyper_type; 58enum x86_hypervisor_type x86_hyper_type;
59EXPORT_SYMBOL(x86_hyper_type); 59EXPORT_SYMBOL(x86_hyper_type);
60 60
61bool __initdata nopv;
62static __init int parse_nopv(char *arg)
63{
64 nopv = true;
65 return 0;
66}
67early_param("nopv", parse_nopv);
68
61static inline const struct hypervisor_x86 * __init 69static inline const struct hypervisor_x86 * __init
62detect_hypervisor_vendor(void) 70detect_hypervisor_vendor(void)
63{ 71{
@@ -65,6 +73,9 @@ detect_hypervisor_vendor(void)
65 uint32_t pri, max_pri = 0; 73 uint32_t pri, max_pri = 0;
66 74
67 for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) { 75 for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
76 if (unlikely(nopv) && !(*p)->ignore_nopv)
77 continue;
78
68 pri = (*p)->detect(); 79 pri = (*p)->detect();
69 if (pri > max_pri) { 80 if (pri > max_pri) {
70 max_pri = pri; 81 max_pri = pri;
diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c
index 6857b4577f17..3ad34f01de2a 100644
--- a/arch/x86/kernel/jailhouse.c
+++ b/arch/x86/kernel/jailhouse.c
@@ -217,4 +217,5 @@ const struct hypervisor_x86 x86_hyper_jailhouse __refconst = {
217 .detect = jailhouse_detect, 217 .detect = jailhouse_detect,
218 .init.init_platform = jailhouse_init_platform, 218 .init.init_platform = jailhouse_init_platform,
219 .init.x2apic_available = jailhouse_x2apic_available, 219 .init.x2apic_available = jailhouse_x2apic_available,
220 .ignore_nopv = true,
220}; 221};
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 4722ba2966ac..5d16824e4dca 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -1463,4 +1463,5 @@ const __initconst struct hypervisor_x86 x86_hyper_xen_pv = {
1463 .detect = xen_platform_pv, 1463 .detect = xen_platform_pv,
1464 .type = X86_HYPER_XEN_PV, 1464 .type = X86_HYPER_XEN_PV,
1465 .runtime.pin_vcpu = xen_pin_vcpu, 1465 .runtime.pin_vcpu = xen_pin_vcpu,
1466 .ignore_nopv = true,
1466}; 1467};