|
|
4ec855 |
From 7e7c5dab29ed99bda0fb5d810db6f12ae4aa2608 Mon Sep 17 00:00:00 2001
|
|
|
4ec855 |
From: "plai@redhat.com" <plai@redhat.com>
|
|
|
4ec855 |
Date: Tue, 26 Nov 2019 18:36:54 +0000
|
|
|
4ec855 |
Subject: [PATCH 10/11] x86/cpu: Add support for UMONITOR/UMWAIT/TPAUSE
|
|
|
4ec855 |
MIME-Version: 1.0
|
|
|
4ec855 |
Content-Type: text/plain; charset=UTF-8
|
|
|
4ec855 |
Content-Transfer-Encoding: 8bit
|
|
|
4ec855 |
|
|
|
4ec855 |
x86/cpu: Add support for UMONITOR/UMWAIT/TPAUSE
|
|
|
4ec855 |
|
|
|
4ec855 |
RH-Author: plai@redhat.com
|
|
|
4ec855 |
Message-id: <1574797015-32564-7-git-send-email-plai@redhat.com>
|
|
|
4ec855 |
Patchwork-id: 92695
|
|
|
4ec855 |
O-Subject: [RHEL8.2 qemu-kvm PATCH 6/7] x86/cpu: Add support for UMONITOR/UMWAIT/TPAUSE
|
|
|
4ec855 |
Bugzilla: 1634827
|
|
|
4ec855 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
4ec855 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
4ec855 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
4ec855 |
|
|
|
4ec855 |
From: Tao Xu <tao3.xu@intel.com>
|
|
|
4ec855 |
|
|
|
4ec855 |
UMONITOR, UMWAIT and TPAUSE are a set of user wait instructions.
|
|
|
4ec855 |
This patch adds support for user wait instructions in KVM. Availability
|
|
|
4ec855 |
of the user wait instructions is indicated by the presence of the CPUID
|
|
|
4ec855 |
feature flag WAITPKG CPUID.0x07.0x0:ECX[5]. User wait instructions may
|
|
|
4ec855 |
be executed at any privilege level, and use IA32_UMWAIT_CONTROL MSR to
|
|
|
4ec855 |
set the maximum time.
|
|
|
4ec855 |
|
|
|
4ec855 |
The patch enable the umonitor, umwait and tpause features in KVM.
|
|
|
4ec855 |
Because umwait and tpause can put a (psysical) CPU into a power saving
|
|
|
4ec855 |
state, by default we dont't expose it to kvm and enable it only when
|
|
|
4ec855 |
guest CPUID has it. And use QEMU command-line "-overcommit cpu-pm=on"
|
|
|
4ec855 |
(enable_cpu_pm is enabled), a VM can use UMONITOR, UMWAIT and TPAUSE
|
|
|
4ec855 |
instructions. If the instruction causes a delay, the amount of time
|
|
|
4ec855 |
delayed is called here the physical delay. The physical delay is first
|
|
|
4ec855 |
computed by determining the virtual delay (the time to delay relative to
|
|
|
4ec855 |
the VM’s timestamp counter). Otherwise, UMONITOR, UMWAIT and TPAUSE cause
|
|
|
4ec855 |
an invalid-opcode exception(#UD).
|
|
|
4ec855 |
|
|
|
4ec855 |
The release document ref below link:
|
|
|
4ec855 |
https://software.intel.com/sites/default/files/\
|
|
|
4ec855 |
managed/39/c5/325462-sdm-vol-1-2abcd-3abcd.pdf
|
|
|
4ec855 |
|
|
|
4ec855 |
Co-developed-by: Jingqi Liu <jingqi.liu@intel.com>
|
|
|
4ec855 |
Signed-off-by: Jingqi Liu <jingqi.liu@intel.com>
|
|
|
4ec855 |
Signed-off-by: Tao Xu <tao3.xu@intel.com>
|
|
|
4ec855 |
Message-Id: <20191011074103.30393-2-tao3.xu@intel.com>
|
|
|
4ec855 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4ec855 |
(cherry picked from commit 67192a298f5bf98f96e5516c3b6474c49e4853cd)
|
|
|
4ec855 |
Signed-off-by: Paul Lai <plai@redhat.com>
|
|
|
4ec855 |
|
|
|
4ec855 |
Resolved Conflicts:
|
|
|
4ec855 |
target/i386/cpu.c
|
|
|
4ec855 |
target/i386/cpu.h
|
|
|
4ec855 |
|
|
|
4ec855 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
4ec855 |
---
|
|
|
4ec855 |
target/i386/cpu.c | 2 +-
|
|
|
4ec855 |
target/i386/cpu.h | 2 ++
|
|
|
4ec855 |
target/i386/kvm.c | 6 ++++++
|
|
|
4ec855 |
3 files changed, 9 insertions(+), 1 deletion(-)
|
|
|
4ec855 |
|
|
|
4ec855 |
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
|
|
4ec855 |
index 87b0502..7d2afc7 100644
|
|
|
4ec855 |
--- a/target/i386/cpu.c
|
|
|
4ec855 |
+++ b/target/i386/cpu.c
|
|
|
4ec855 |
@@ -1016,7 +1016,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
|
|
|
4ec855 |
.type = CPUID_FEATURE_WORD,
|
|
|
4ec855 |
.feat_names = {
|
|
|
4ec855 |
NULL, "avx512vbmi", "umip", "pku",
|
|
|
4ec855 |
- "ospke", NULL, "avx512vbmi2", NULL,
|
|
|
4ec855 |
+ "ospke", "waitpkg", "avx512vbmi2", NULL,
|
|
|
4ec855 |
"gfni", "vaes", "vpclmulqdq", "avx512vnni",
|
|
|
4ec855 |
"avx512bitalg", NULL, "avx512-vpopcntdq", NULL,
|
|
|
4ec855 |
"la57", NULL, NULL, NULL,
|
|
|
4ec855 |
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
|
|
|
4ec855 |
index 7ab8ee9..fac98aa 100644
|
|
|
4ec855 |
--- a/target/i386/cpu.h
|
|
|
4ec855 |
+++ b/target/i386/cpu.h
|
|
|
4ec855 |
@@ -708,6 +708,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];
|
|
|
4ec855 |
#define CPUID_7_0_ECX_UMIP (1U << 2)
|
|
|
4ec855 |
#define CPUID_7_0_ECX_PKU (1U << 3)
|
|
|
4ec855 |
#define CPUID_7_0_ECX_OSPKE (1U << 4)
|
|
|
4ec855 |
+/* UMONITOR/UMWAIT/TPAUSE Instructions */
|
|
|
4ec855 |
+#define CPUID_7_0_ECX_WAITPKG (1U << 5)
|
|
|
4ec855 |
#define CPUID_7_0_ECX_VBMI2 (1U << 6) /* Additional VBMI Instrs */
|
|
|
4ec855 |
#define CPUID_7_0_ECX_GFNI (1U << 8)
|
|
|
4ec855 |
#define CPUID_7_0_ECX_VAES (1U << 9)
|
|
|
4ec855 |
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
|
|
|
4ec855 |
index ffd01f0..0fd5650 100644
|
|
|
4ec855 |
--- a/target/i386/kvm.c
|
|
|
4ec855 |
+++ b/target/i386/kvm.c
|
|
|
4ec855 |
@@ -392,6 +392,12 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
|
|
|
4ec855 |
if (host_tsx_blacklisted()) {
|
|
|
4ec855 |
ret &= ~(CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_HLE);
|
|
|
4ec855 |
}
|
|
|
4ec855 |
+ } else if (function == 7 && index == 0 && reg == R_ECX) {
|
|
|
4ec855 |
+ if (enable_cpu_pm) {
|
|
|
4ec855 |
+ ret |= CPUID_7_0_ECX_WAITPKG;
|
|
|
4ec855 |
+ } else {
|
|
|
4ec855 |
+ ret &= ~CPUID_7_0_ECX_WAITPKG;
|
|
|
4ec855 |
+ }
|
|
|
4ec855 |
} else if (function == 7 && index == 0 && reg == R_EDX) {
|
|
|
4ec855 |
/*
|
|
|
4ec855 |
* Linux v4.17-v4.20 incorrectly return ARCH_CAPABILITIES on SVM hosts.
|
|
|
4ec855 |
--
|
|
|
4ec855 |
1.8.3.1
|
|
|
4ec855 |
|