aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/arch/x86/kvm/x86.h
diff options
context:
space:
mode:
authorBabu Moger <babu.moger@amd.com>2018-03-16 16:37:24 -0400
committerRadim Krčmář <rkrcmar@redhat.com>2018-03-28 22:47:06 +0200
commitc8e88717cfc6b36bedea22368d97667446318291 (patch)
treee5de741d9cf03b50bf5f25035347de39c6728b24 /arch/x86/kvm/x86.h
parentKVM: VMX: Remove ple_window_actual_max (diff)
downloadwireguard-linux-c8e88717cfc6b36bedea22368d97667446318291.tar.xz
wireguard-linux-c8e88717cfc6b36bedea22368d97667446318291.zip
KVM: VMX: Bring the common code to header file
This patch brings some of the code from vmx to x86.h header file. Now, we can share this code between vmx and svm. Modified couple functions to make it common. Signed-off-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Diffstat (limited to '')
-rw-r--r--arch/x86/kvm/x86.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 35efd567a676..0804722b809e 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -6,6 +6,42 @@
#include <asm/pvclock.h>
#include "kvm_cache_regs.h"
+#define KVM_DEFAULT_PLE_GAP 128
+#define KVM_VMX_DEFAULT_PLE_WINDOW 4096
+#define KVM_DEFAULT_PLE_WINDOW_GROW 2
+#define KVM_DEFAULT_PLE_WINDOW_SHRINK 0
+#define KVM_VMX_DEFAULT_PLE_WINDOW_MAX UINT_MAX
+
+static inline unsigned int __grow_ple_window(unsigned int val,
+ unsigned int base, unsigned int modifier, unsigned int max)
+{
+ u64 ret = val;
+
+ if (modifier < 1)
+ return base;
+
+ if (modifier < base)
+ ret *= modifier;
+ else
+ ret += modifier;
+
+ return min(ret, (u64)max);
+}
+
+static inline unsigned int __shrink_ple_window(unsigned int val,
+ unsigned int base, unsigned int modifier, unsigned int min)
+{
+ if (modifier < 1)
+ return base;
+
+ if (modifier < base)
+ val /= modifier;
+ else
+ val -= modifier;
+
+ return max(val, min);
+}
+
#define MSR_IA32_CR_PAT_DEFAULT 0x0007040600070406ULL
static inline void kvm_clear_exception_queue(struct kvm_vcpu *vcpu)