Skip to contentSkip to conversation

x86: pkeys: add test for memory protection-key

PATCH Superseded Huaitong Han 1 participant 1 message Nov 18, 2015 KVM

v2 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86: pkeys: add test for memory protection-key

Changes in v2:
* Move pku.flat from config-x86-common.mak to config-x86_64.mak.

The protection-key feature provides an additional mechanism by which IA-32e paging controls access to usermode addresses.

The specification of Protection Keys can be found at SDM (4.6.2, volume 3)
http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-manual-325462.pdf.

config/config-x86-common.mak +2 -0
index c2f9908..a72055c 100644
@@ -104,6 +104,8 @@ $(TEST_DIR)/pcid.elf: $(cstart.o) $(TEST_DIR)/pcid.o
 
 $(TEST_DIR)/smap.elf: $(cstart.o) $(TEST_DIR)/smap.o
 
+$(TEST_DIR)/pku.elf: $(cstart.o) $(TEST_DIR)/pku.o
+
 $(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o
 
 $(TEST_DIR)/debug.elf: $(cstart.o) $(TEST_DIR)/debug.o
config/config-x86_64.mak +1 -0
index 7d4eb34..fcf4486 100644
@@ -11,5 +11,6 @@ tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
 tests += $(TEST_DIR)/svm.flat
 tests += $(TEST_DIR)/vmx.flat
 tests += $(TEST_DIR)/tscdeadline_latency.flat
+tests += $(TEST_DIR)/pku.flat
 
 include config/config-x86-common.mak
lib/x86/processor.h +1 -0
index f6eb187..1816807 100644
@@ -28,6 +28,7 @@
 #define X86_CR4_PAE    0x00000020
 #define X86_CR4_PCIDE  0x00020000
 #define X86_CR4_SMAP   0x00200000
+#define X86_CR4_PKE    0x00400000
 
 #define X86_EFLAGS_CF  0x00000001
 #define X86_EFLAGS_ZF  0x00000040
x86/pku.c new file +162 -0

162 lines not on this page · raw message

x86/unittests.cfg +5 -0
index 8bb0e6a..2e89a6a 100644
@@ -76,6 +76,11 @@ arch = x86_64
 file = smap.flat
 extra_params = -cpu host
 
+[pku]
+file = pku.flat
+arch = x86_64
+extra_params = -cpu host
+
 #[asyncpf]
 #file = asyncpf.flat
 
Signature · 1 line
2.4.3