Skip to contentSkip to conversation

Add PKU/OSPKE on Skylake-Server CPU model

PATCH Superseded Tao Xu 3 participants 7 messages Oct 17, 2018 – Oct 29, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Tao Xu

author
#0 lore raw

cover Add PKU/OSPKE on Skylake-Server CPU model

This patch adds PKU/OSPKE on Skylake-Server CPU model

Tao Xu (1):
i386: Add PKU/OSPKE on Skylake-Server CPU model

 target/i386/cpu.c | 4 ++++
 1 file changed, 4 insertions(+)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/1 i386: Add PKU/OSPKE on Skylake-Server CPU model

As the release document ref below link (page 13):
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

PKU is supported in Skylake Server (Only Server) and later, and on Intel(R) Xeon(R) Processor Scalable Family. OSPKE is to reads the value of PKRU (Instruction of PKU) into EAX and clears EDX. So PKU/OSPKE are supposed to be in Skylake-Server CPU model. And PKU/OSPKE 's CPUID has been exposed to QEMU. But PKU/OSPKE can't be find in Skylake-Server CPU model in the code. So this patch will fix PKU/OSPKE this issue in Skylake-Server CPU model.

---
 target/i386/cpu.c | 4 ++++
 1 file changed, 4 insertions(+)
target/i386/cpu.c +4 -0
index f24295e6e4..6ecd28c8a2 100644
@@ -2322,6 +2322,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_7_0_EBX_AVX512F | CPUID_7_0_EBX_AVX512DQ |
             CPUID_7_0_EBX_AVX512BW | CPUID_7_0_EBX_AVX512CD |
             CPUID_7_0_EBX_AVX512VL | CPUID_7_0_EBX_CLFLUSHOPT,
+        .features[FEAT_7_0_ECX] =
+            CPUID_7_0_ECX_PKU | CPUID_7_0_ECX_OSPKE,
         /* Missing: XSAVES (not supported by some Linux versions,
          * including v4.1 to v4.12).
          * KVM doesn't yet expose any XSAVES state save component,
@@ -2372,6 +2374,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_7_0_EBX_AVX512F | CPUID_7_0_EBX_AVX512DQ |
             CPUID_7_0_EBX_AVX512BW | CPUID_7_0_EBX_AVX512CD |
             CPUID_7_0_EBX_AVX512VL,
+        .features[FEAT_7_0_ECX] =
+            CPUID_7_0_ECX_PKU | CPUID_7_0_ECX_OSPKE,
         /* Missing: XSAVES (not supported by some Linux versions,
          * including v4.1 to v4.12).
          * KVM doesn't yet expose any XSAVES state save component,
Signature · 1 line
2.17.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/1] i386: Add PKU/OSPKE on Skylake-Server CPU model

Quoted 4 lines · Tao Xu

As the release document ref below link (page 13):
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

Quoted 8 lines

PKU is supported in Skylake Server (Only Server) and later, and on Intel(R) Xeon(R) Processor Scalable Family. OSPKE is to reads the value of PKRU (Instruction of PKU) into EAX and clears EDX. So PKU/OSPKE are supposed to be in Skylake-Server CPU model. And PKU/OSPKE 's CPUID has been exposed to QEMU. But PKU/OSPKE can't be find in Skylake-Server CPU model in the code. So this patch will fix PKU/OSPKE this issue in Skylake-Server CPU model.

OSPKE is not needed, since it is added automatically based on CR4 (and is not set on boot).

Also, the guru of CPU model compatibility is Eduardo, so I'll wait for him to chime in anyway.

Paolo

#3 lore raw

Re: [Qemu-devel] [PATCH 1/1] i386: Add PKU/OSPKE on Skylake-Server CPU model

Quoted 14 lines · Paolo Bonzini
Quoted 4 lines · Tao Xu

As the release document ref below link (page 13):
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

Quoted 8 lines

PKU is supported in Skylake Server (Only Server) and later, and on Intel(R) Xeon(R) Processor Scalable Family. OSPKE is to reads the value of PKRU (Instruction of PKU) into EAX and clears EDX. So PKU/OSPKE are supposed to be in Skylake-Server CPU model. And PKU/OSPKE 's CPUID has been exposed to QEMU. But PKU/OSPKE can't be find in Skylake-Server CPU model in the code. So this patch will fix PKU/OSPKE this issue in Skylake-Server CPU model.

Quoted 2 lines

OSPKE is not needed, since it is added automatically based on CR4 (and is not set on boot).

Correct.

Quoted 3 lines

Also, the guru of CPU model compatibility is Eduardo, so I'll wait for him to chime in anyway.

Sorry for taking so long to reply. This can be safely done only if every host that is able to run Skylake-Server today is guaranteed to support PKU. Is that the case?

You'll also need Skylake-Server-*-cpu.pku=off entries on PC_COMPAT_3_0 to keep PKU disabled on pc-*-3.0 and older.

Signature · 1 line
Eduardo
author
#4 lore raw

Re: [Qemu-devel] [PATCH 1/1] i386: Add PKU/OSPKE on Skylake-Server CPU model

Quoted 18 lines · Eduardo Habkost
Quoted 13 lines · Paolo Bonzini
Quoted 4 lines · Tao Xu

As the release document ref below link (page 13):
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

Quoted 8 lines

PKU is supported in Skylake Server (Only Server) and later, and on Intel(R) Xeon(R) Processor Scalable Family. OSPKE is to reads the value of PKRU (Instruction of PKU) into EAX and clears EDX. So PKU/OSPKE are supposed to be in Skylake-Server CPU model. And PKU/OSPKE 's CPUID has been exposed to QEMU. But PKU/OSPKE can't be find in Skylake-Server CPU model in the code. So this patch will fix PKU/OSPKE this issue in Skylake-Server CPU model.

Quoted 2 lines

OSPKE is not needed, since it is added automatically based on CR4 (and is not set on boot).

Correct.

Quoted 9 lines
Quoted 2 lines

Also, the guru of CPU model compatibility is Eduardo, so I'll wait for him to chime in anyway.

Sorry for taking so long to reply. This can be safely done only if every host that is able to run Skylake-Server today is guaranteed to support PKU. Is that the case?

You'll also need Skylake-Server-*-cpu.pku=off entries on PC_COMPAT_3_0 to keep PKU disabled on pc-*-3.0 and older.

Thank you Eduardo,

But I can't find PC_COMPAT_3_0 in  include/hw/i386/pc.h. Will it exist on

QEMU 3.1 and will I add "pku=off" after QEMU 3.1  release?

Best Regard

Tao Xu

#5 lore raw

Re: [Qemu-devel] [PATCH 1/1] i386: Add PKU/OSPKE on Skylake-Server CPU model

Quoted 28 lines · Tao Xu
Quoted 18 lines · Eduardo Habkost
Quoted 13 lines · Paolo Bonzini
Quoted 4 lines · Tao Xu

As the release document ref below link (page 13):
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

Quoted 8 lines

PKU is supported in Skylake Server (Only Server) and later, and on Intel(R) Xeon(R) Processor Scalable Family. OSPKE is to reads the value of PKRU (Instruction of PKU) into EAX and clears EDX. So PKU/OSPKE are supposed to be in Skylake-Server CPU model. And PKU/OSPKE 's CPUID has been exposed to QEMU. But PKU/OSPKE can't be find in Skylake-Server CPU model in the code. So this patch will fix PKU/OSPKE this issue in Skylake-Server CPU model.

Quoted 2 lines

OSPKE is not needed, since it is added automatically based on CR4 (and is not set on boot).

Correct.

Quoted 9 lines
Quoted 2 lines

Also, the guru of CPU model compatibility is Eduardo, so I'll wait for him to chime in anyway.

Sorry for taking so long to reply. This can be safely done only if every host that is able to run Skylake-Server today is guaranteed to support PKU. Is that the case?

You'll also need Skylake-Server-*-cpu.pku=off entries on PC_COMPAT_3_0 to keep PKU disabled on pc-*-3.0 and older.

Quoted 6 lines

Thank you Eduardo,

But I can't find PC_COMPAT_3_0 in  include/hw/i386/pc.h. Will it exist on

QEMU 3.1 and will I add "pku=off" after QEMU 3.1  release?

PC_COMPAT_3_0 was added to qemu.git master a few weeks ago, by commit 9b4cf107b09d18ac30f46fd1c4de8585ccba030c.

Signature · 1 line
Eduardo
author
#6 lore raw

Re: [Qemu-devel] [PATCH 1/1] i386: Add PKU/OSPKE on Skylake-Server CPU model

Quoted 6 lines · Eduardo Habkost
Quoted 5 lines · Tao Xu
Quoted 3 lines · Eduardo Habkost

Sorry for taking so long to reply. This can be safely done only if every host that is able to run Skylake-Server today is guaranteed to support PKU. Is that the case?

Yes, as the release document ref below link (page 13):
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf

PKU is supported in Skylake Server (Only Server) and later. So, every host that is able to run Skylake-Server today is to to support PKU.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

You'll also need Skylake-Server-*-cpu.pku=off entries on PC_COMPAT_3_0 to keep PKU disabled on pc-*-3.0 and older.

Quoted 9 lines
Quoted 6 lines

Thank you Eduardo,

But I can't find PC_COMPAT_3_0 in  include/hw/i386/pc.h. Will it exist on

QEMU 3.1 and will I add "pku=off" after QEMU 3.1  release?

PC_COMPAT_3_0 was added to qemu.git master a few weeks ago, by commit 9b4cf107b09d18ac30f46fd1c4de8585ccba030c.

Thank you. I'll add this on the next version of this patch.