]> xenbits.xensource.com Git - xen.git/commitdiff
x86/prot-key: Enumeration for Protection Key Supervisor
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 14 Dec 2021 16:51:28 +0000 (16:51 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 20 Jan 2023 19:39:33 +0000 (19:39 +0000)
Protection Key Supervisor works in a very similar way to Protection Key User,
except that instead of a PKRU register used by the {RD,WR}PKRU instructions,
the supervisor protection settings live in MSR_PKRS and is accessed using
normal {RD,WR}MSR instructions.

PKS has the same problematic interactions with PV guests as PKU (more infact,
given the guest kernel's CPL), so we'll only support this for HVM guests for
now.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
tools/libs/light/libxl_cpuid.c
tools/misc/xen-cpuid.c
xen/arch/x86/include/asm/cpufeature.h
xen/arch/x86/include/asm/msr-index.h
xen/arch/x86/include/asm/x86-defns.h
xen/include/public/arch-x86/cpufeatureset.h

index 2aa23225f42c69b1bb5b7889162cad5aa3b3654d..cbd4e511e8ab21c5cb9562f7c94c232c91975885 100644 (file)
@@ -211,6 +211,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
         {"avx512-vpopcntdq",0x00000007,0,CPUID_REG_ECX, 14,  1},
         {"rdpid",        0x00000007,  0, CPUID_REG_ECX, 22,  1},
         {"cldemote",     0x00000007,  0, CPUID_REG_ECX, 25,  1},
+        {"pks",          0x00000007,  0, CPUID_REG_ECX, 31,  1},
 
         {"avx512-4vnniw",0x00000007,  0, CPUID_REG_EDX,  2,  1},
         {"avx512-4fmaps",0x00000007,  0, CPUID_REG_EDX,  3,  1},
index d5833e9ce8792d14eceb66eeb38d8523efc557aa..ea7ff320e0e4ebd6f7404a3e6de38ea06a85e47f 100644 (file)
@@ -134,7 +134,7 @@ static const char *const str_7c0[32] =
     /* 24 */                   [25] = "cldemote",
     /* 26 */                   [27] = "movdiri",
     [28] = "movdir64b",        [29] = "enqcmd",
-    [30] = "sgx-lc",
+    [30] = "sgx-lc",           [31] = "pks",
 };
 
 static const char *const str_e7d[32] =
index 044cfd9f882d6c328d451341b2e5e1a55f744738..0a301013c3d957a23b189e53763cf2f673fddd40 100644 (file)
 #define cpu_has_movdiri         boot_cpu_has(X86_FEATURE_MOVDIRI)
 #define cpu_has_movdir64b       boot_cpu_has(X86_FEATURE_MOVDIR64B)
 #define cpu_has_enqcmd          boot_cpu_has(X86_FEATURE_ENQCMD)
+#define cpu_has_pks             boot_cpu_has(X86_FEATURE_PKS)
 
 /* CPUID level 0x80000007.edx */
 #define cpu_has_hw_pstate       boot_cpu_has(X86_FEATURE_HW_PSTATE)
index 0a8852f3c2461145e2a7ac44bf680709a60c0bb4..7615d8087f46db89de02599300600252bf7f5874 100644 (file)
 #define MSR_PL3_SSP                         0x000006a7
 #define MSR_INTERRUPT_SSP_TABLE             0x000006a8
 
+#define MSR_PKRS                            0x000006e1
+
 #define MSR_X2APIC_FIRST                    0x00000800
 #define MSR_X2APIC_LAST                     0x000008ff
 
index 42b5f382d438d21ac97b6438e8c810c7b964cf6d..fe1caba6f819a3776d5d6db70826ba9c98c323ea 100644 (file)
@@ -74,6 +74,7 @@
 #define X86_CR4_SMAP       0x00200000 /* enable SMAP */
 #define X86_CR4_PKE        0x00400000 /* enable PKE */
 #define X86_CR4_CET        0x00800000 /* Control-flow Enforcement Technology */
+#define X86_CR4_PKS        0x01000000 /* Protection Key Supervisor */
 
 /*
  * XSTATE component flags in XCR0
index 7915f5826f57cc11a358cd7f080c8697cffaa60b..ad7e89dd4c407660d82c2a6bb3d09ad870ea0546 100644 (file)
@@ -227,6 +227,7 @@ XEN_CPUFEATURE(CLDEMOTE,      6*32+25) /*A  CLDEMOTE instruction */
 XEN_CPUFEATURE(MOVDIRI,       6*32+27) /*a  MOVDIRI instruction */
 XEN_CPUFEATURE(MOVDIR64B,     6*32+28) /*a  MOVDIR64B instruction */
 XEN_CPUFEATURE(ENQCMD,        6*32+29) /*   ENQCMD{,S} instructions */
+XEN_CPUFEATURE(PKS,           6*32+31) /*   Protection Key for Supervisor */
 
 /* AMD-defined CPU features, CPUID level 0x80000007.edx, word 7 */
 XEN_CPUFEATURE(HW_PSTATE,     7*32+ 7) /*   Hardware Pstates */