Blob Blame History Raw
From a310512e2d77a739c20335db711441680cc69cbd Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Mon, 24 Feb 2020 14:39:53 +0100
Subject: [PATCH] kvm: Reintroduce nopvspin kernel parameter
Patch-mainline: Never, Suse specific
References: bsc#1056427

THis is a port of Davidlohr's work. The core of the parameter has gone
in from upstream in two earlier patches. This merely enables the
parameter with the same name as in SP1

Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 Documentation/admin-guide/kernel-parameters.txt |    4 ++++
 arch/x86/kernel/kvm.c                           |   21 +++++++++++++++++++++
 2 files changed, 25 insertions(+)

--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -2435,6 +2435,10 @@
 			feature (tagged TLBs) on capable Intel chips.
 			Default is 1 (enabled)
 
+	kvm_nopvspin	[X86,KVM]
+			Disables the paravirtualized spinlock slowpath
+			optimizations for KVM.
+
 	l1tf=           [X86] Control mitigation of the L1TF vulnerability on
 			      affected CPUs
 
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -44,6 +44,22 @@
 #include <asm/svm.h>
 #include <asm/e820/api.h>
 
+/*
+ * SLE-specific.
+ *
+ * Allow disabling of PV spinlock in kernel command line (kernel param).
+ * Similar idea to what Xen does. Upstream, however, uses a different
+ * approach such that hypervisor admins can pass the VM_HINTS_DEDICATED
+ * via qemu.
+ */
+static bool kvm_pvspin = true;
+static __init int kvm_parse_nopvspin(char *arg)
+{
+	kvm_pvspin = false;
+	return 0;
+}
+early_param("kvm_nopvspin", kvm_parse_nopvspin);
+
 DEFINE_STATIC_KEY_FALSE(kvm_async_pf_enabled);
 
 static int kvmapf = 1;
@@ -1036,6 +1052,11 @@ void __init kvm_spinlock_init(void)
 		goto out;
 	}
 
+	if (!kvm_pvspin) {
+		pr_info("KVM: disabled paravirtual spinlock by kernel parameter\n");
+		goto out;
+	}
+
 	if (nopvspin) {
 		pr_info("PV spinlocks disabled, forced by \"nopvspin\" parameter\n");
 		goto out;