Skip to contentSkip to conversation

x86/cpu: Enable a few new cpu features

PATCH In review Jingqi Liu 3 participants 10 messages Jul 10, 2018 – Aug 20, 2018

lore
Share & tools
lore

Jingqi Liu

author
#0 lore raw

cover x86/cpu: Enable a few new cpu features

Enable a few new cpu features including UMONITOR, UMWAIT, TPAUSE, MOVDIRI and MOVDIR64B.

UMONITOR, UMWAIT, and TPAUSE are a set of user wait instructions. MOVDIRI moves doubleword or quadword from register to memory through direct store.
MOVDIR64B moves 64-bytes as direct-store with 64-bytes write atomicity.

The bits definition:
CPUID.(EAX=7,ECX=0):ECX[bit 05] WAITPKG
CPUID.(EAX=7,ECX=0):ECX[bit 27] MOVDIRI
CPUID.(EAX=7,ECX=0):ECX[bit 28] MOVDIR64B

The release document ref below link:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

Jingqi Liu (3):
x86/cpu: Enable UMONITOR/UMWAIT/TPAUSE cpu features x86/cpu: Enable MOVDIRI cpu feature x86/cpu: Enable MOVDIR64B cpu feature

 target/i386/cpu.c | 6 +++---
 target/i386/cpu.h | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/3 x86/cpu: Enable UMONITOR/UMWAIT/TPAUSE cpu features

UMONITOR, UMWAIT, and TPAUSE are a set of user wait instructions.

UMONITOR arms address monitoring hardware using an address. A store to an address within the specified address range triggers the monitoring hardware to wake up the processor waiting in umwait.

UMWAIT instructs the processor to enter an implementation-dependent optimized state while monitoring a range of addresses. The optimized state may be either a light-weight power/performance optimized state or an improved power/performance optimized state.

TPAUSE instructs the processor to enter an implementation-dependent optimized state c0.1 or c0.2 state and wake up when time-stamp counter reaches specified timeout.

The bit definition:
CPUID.(EAX=7,ECX=0):ECX[bit 05] WAITPKG

The release document ref below link:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

---
 target/i386/cpu.c | 2 +-
 target/i386/cpu.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
target/i386/cpu.c +1 -1
index e0e2f2e..e0d151f 100644
@@ -978,7 +978,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
     [FEAT_7_0_ECX] = {
         .feat_names = {
             NULL, "avx512vbmi", "umip", "pku",
-            NULL /* ospke */, NULL, "avx512vbmi2", NULL,
+            NULL /* ospke */, "waitpkg", "avx512vbmi2", NULL,
             "gfni", "vaes", "vpclmulqdq", "avx512vnni",
             "avx512bitalg", NULL, "avx512-vpopcntdq", NULL,
             "la57", NULL, NULL, NULL,
target/i386/cpu.h +1 -0
index 2c5a0d9..f651105 100644
@@ -674,6 +674,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
 #define CPUID_7_0_ECX_UMIP     (1U << 2)
 #define CPUID_7_0_ECX_PKU      (1U << 3)
 #define CPUID_7_0_ECX_OSPKE    (1U << 4)
+#define CPUID_7_0_ECX_WAITPKG  (1U << 5) /* UMONITOR/UMWAIT/TPAUSE Instructions */
 #define CPUID_7_0_ECX_VBMI2    (1U << 6) /* Additional VBMI Instrs */
 #define CPUID_7_0_ECX_GFNI     (1U << 8)
 #define CPUID_7_0_ECX_VAES     (1U << 9)
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] x86/cpu: Enable UMONITOR/UMWAIT/TPAUSE cpu features

Quoted 15 lines · Jingqi Liu

UMONITOR, UMWAIT, and TPAUSE are a set of user wait instructions.

UMONITOR arms address monitoring hardware using an address. A store to an address within the specified address range triggers the monitoring hardware to wake up the processor waiting in umwait.

UMWAIT instructs the processor to enter an implementation-dependent optimized state while monitoring a range of addresses. The optimized state may be either a light-weight power/performance optimized state or an improved power/performance optimized state.

TPAUSE instructs the processor to enter an implementation-dependent optimized state c0.1 or c0.2 state and wake up when time-stamp counter reaches specified timeout.

Quoted 8 lines

The bit definition:
CPUID.(EAX=7,ECX=0):ECX[bit 05] WAITPKG

The release document ref below link:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

Is it really OK to expose these features to the guest without "-overcommit cpu-pm=on"?

Don't we need code to migrate IA32_UMWAIT_CONTROL?

(I don't see code to handle writes to IA32_UMWAIT_CONTROL on the KVM patches, either.)

Signature · 1 line
Eduardo
#3 lore raw

Re: [Qemu-devel] [PATCH 1/3] x86/cpu: Enable UMONITOR/UMWAIT/TPAUSE cpu features

Quoted 38 lines

-----Original Message-----
From: Eduardo Habkost [mailto:[email protected]]
Sent: Tuesday, August 7, 2018 6:03 AM
To: Liu, Jingqi <[email protected]>
Cc: [email protected]; [email protected]; Wang, Wei W <[email protected]>; [email protected]; Michael S. Tsirkin <[email protected]>
Subject: Re: [Qemu-devel] [PATCH 1/3] x86/cpu: Enable UMONITOR/UMWAIT/TPAUSE cpu features

Quoted 15 lines · Jingqi Liu

UMONITOR, UMWAIT, and TPAUSE are a set of user wait instructions.

UMONITOR arms address monitoring hardware using an address. A store to an address within the specified address range triggers the monitoring hardware to wake up the processor waiting in umwait.

UMWAIT instructs the processor to enter an implementation-dependent optimized state while monitoring a range of addresses. The optimized state may be either a light-weight power/performance optimized state or an improved power/performance optimized state.

TPAUSE instructs the processor to enter an implementation-dependent optimized state c0.1 or c0.2 state and wake up when time-stamp counter reaches specified timeout.

Quoted 8 lines

The bit definition:
CPUID.(EAX=7,ECX=0):ECX[bit 05] WAITPKG

The release document ref below link:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

Is it really OK to expose these features to the guest without "-overcommit cpu- pm=on"?

Quoted 6 lines

Don't we need code to migrate IA32_UMWAIT_CONTROL?

(I don't see code to handle writes to IA32_UMWAIT_CONTROL on the KVM patches, either.)

--

Hi Eduardo,

Yes, I'll handle IA32_UMWAIT_CONTROL in the second version. Thanks for your review.

Quoted 1 line

Eduardo

author
#4 lore raw

PATCH 2/3 x86/cpu: Enable MOVDIRI cpu feature

In reply to Jingqi Liu

MOVDIRI moves doubleword or quadword from register to memory through direct store which is implemented by using write combining (WC) for writing data directly into memory without caching the data.

The bit definition:
CPUID.(EAX=7,ECX=0):ECX[bit 27] MOVDIRI

The release document ref below link:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

---
 target/i386/cpu.c | 2 +-
 target/i386/cpu.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
target/i386/cpu.c +1 -1
index e0d151f..775cfcb 100644
@@ -983,7 +983,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
             "avx512bitalg", NULL, "avx512-vpopcntdq", NULL,
             "la57", NULL, NULL, NULL,
             NULL, NULL, "rdpid", NULL,
-            NULL, "cldemote", NULL, NULL,
+            NULL, "cldemote", NULL, "movdiri",
             NULL, NULL, NULL, NULL,
         },
         .cpuid_eax = 7,
target/i386/cpu.h +1 -0
index f651105..d94bf2d 100644
@@ -685,6 +685,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
 #define CPUID_7_0_ECX_LA57     (1U << 16)
 #define CPUID_7_0_ECX_RDPID    (1U << 22)
 #define CPUID_7_0_ECX_CLDEMOTE (1U << 25)  /* CLDEMOTE Instruction */
+#define CPUID_7_0_ECX_MOVDIRI  (1U << 27)  /* MOVDIRI Instruction */
 
 #define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2) /* AVX512 Neural Network Instructions */
 #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) /* AVX512 Multiply Accumulation Single Precision */
Signature · 1 line
1.8.3.1
author
#5 lore raw

PATCH 3/3 x86/cpu: Enable MOVDIR64B cpu feature

In reply to Jingqi Liu

MOVDIR64B moves 64-bytes as direct-store with 64-bytes write atomicity. Direct store is implemented by using write combining (WC) for writing data directly into memory without caching the data.

The bit definition:
CPUID.(EAX=7,ECX=0):ECX[bit 28] MOVDIR64B

The release document ref below link:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

---
 target/i386/cpu.c | 2 +-
 target/i386/cpu.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
target/i386/cpu.c +1 -1
index 775cfcb..fc0b678 100644
@@ -984,7 +984,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
             "la57", NULL, NULL, NULL,
             NULL, NULL, "rdpid", NULL,
             NULL, "cldemote", NULL, "movdiri",
-            NULL, NULL, NULL, NULL,
+            "movdir64b", NULL, NULL, NULL,
         },
         .cpuid_eax = 7,
         .cpuid_needs_ecx = true, .cpuid_ecx = 0,
target/i386/cpu.h +1 -0
index d94bf2d..8014c1c 100644
@@ -686,6 +686,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
 #define CPUID_7_0_ECX_RDPID    (1U << 22)
 #define CPUID_7_0_ECX_CLDEMOTE (1U << 25)  /* CLDEMOTE Instruction */
 #define CPUID_7_0_ECX_MOVDIRI  (1U << 27)  /* MOVDIRI Instruction */
+#define CPUID_7_0_ECX_MOVDIR64B (1U << 28) /* MOVDIR64B Instruction */
 
 #define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2) /* AVX512 Neural Network Instructions */
 #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) /* AVX512 Multiply Accumulation Single Precision */
Signature · 1 line
1.8.3.1
#6 lore raw
In reply to Jingqi Liu
Quoted 7 lines · Jingqi Liu

Enable a few new cpu features including UMONITOR, UMWAIT, TPAUSE, MOVDIRI and MOVDIR64B.

UMONITOR, UMWAIT, and TPAUSE are a set of user wait instructions. MOVDIRI moves doubleword or quadword from register to memory through direct store.
MOVDIR64B moves 64-bytes as direct-store with 64-bytes write atomicity.

Do you have corresponding KVM changes?

Paolo

Quoted 18 lines

The bits definition:
CPUID.(EAX=7,ECX=0):ECX[bit 05] WAITPKG
CPUID.(EAX=7,ECX=0):ECX[bit 27] MOVDIRI
CPUID.(EAX=7,ECX=0):ECX[bit 28] MOVDIR64B

The release document ref below link:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

Jingqi Liu (3):
x86/cpu: Enable UMONITOR/UMWAIT/TPAUSE cpu features x86/cpu: Enable MOVDIRI cpu feature x86/cpu: Enable MOVDIR64B cpu feature

 target/i386/cpu.c | 6 +++---
 target/i386/cpu.h | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)
#7 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 7 lines · Jingqi Liu

Enable a few new cpu features including UMONITOR, UMWAIT, TPAUSE, MOVDIRI and MOVDIR64B.

UMONITOR, UMWAIT, and TPAUSE are a set of user wait instructions. MOVDIRI moves doubleword or quadword from register to memory through direct store.
MOVDIR64B moves 64-bytes as direct-store with 64-bytes write atomicity.

Do you have corresponding KVM changes?

Yes, the corresponding links are listed as below.
https://www.spinics.net/lists/kvm/msg171563.html
https://www.spinics.net/lists/kernel/msg2850965.html
The patches had been sent for your review also.
Thanks
Jingqi Liu

Quoted 21 lines

Paolo

Quoted 18 lines

The bits definition:
CPUID.(EAX=7,ECX=0):ECX[bit 05] WAITPKG
CPUID.(EAX=7,ECX=0):ECX[bit 27] MOVDIRI
CPUID.(EAX=7,ECX=0):ECX[bit 28] MOVDIR64B

The release document ref below link:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

Jingqi Liu (3):
x86/cpu: Enable UMONITOR/UMWAIT/TPAUSE cpu features x86/cpu: Enable MOVDIRI cpu feature x86/cpu: Enable MOVDIR64B cpu feature

  target/i386/cpu.c | 6 +++---
  target/i386/cpu.h | 3 +++
  2 files changed, 6 insertions(+), 3 deletions(-)
#8 lore raw
In reply to Paolo Bonzini

Hi Paolo & Eduardo,

Do you have any comments for the series ?
Thanks

Quoted 30 lines · Paolo Bonzini
Quoted 7 lines · Jingqi Liu

Enable a few new cpu features including UMONITOR, UMWAIT, TPAUSE, MOVDIRI and MOVDIR64B.

UMONITOR, UMWAIT, and TPAUSE are a set of user wait instructions. MOVDIRI moves doubleword or quadword from register to memory through direct store.
MOVDIR64B moves 64-bytes as direct-store with 64-bytes write atomicity.

Do you have corresponding KVM changes?

Paolo

Quoted 18 lines

The bits definition:
CPUID.(EAX=7,ECX=0):ECX[bit 05] WAITPKG
CPUID.(EAX=7,ECX=0):ECX[bit 27] MOVDIRI
CPUID.(EAX=7,ECX=0):ECX[bit 28] MOVDIR64B

The release document ref below link:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

Jingqi Liu (3):
x86/cpu: Enable UMONITOR/UMWAIT/TPAUSE cpu features x86/cpu: Enable MOVDIRI cpu feature x86/cpu: Enable MOVDIR64B cpu feature

  target/i386/cpu.c | 6 +++---
  target/i386/cpu.h | 3 +++
  2 files changed, 6 insertions(+), 3 deletions(-)
#9 lore raw
Quoted 5 lines · Jingqi

Hi Paolo & Eduardo,

Do you have any comments for the series ?
Thanks

Hi,

QEMU is currently in feature freeze. We will look at the series soon after QEMU 3.0 is released.

Paolo