Commit a87730cc authored by Chang S. Bae's avatar Chang S. Bae Committed by Thomas Gleixner

selftests/x86/fsgsbase: Test ptracer-induced GSBASE write with FSGSBASE

This validates that GS and GSBASE are independently preserved in
ptracer commands.
Suggested-by: default avatarAndy Lutomirski <luto@kernel.org>
Signed-off-by: default avatarChang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ravi Shankar <ravi.v.shankar@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Link: https://lkml.kernel.org/r/1557309753-24073-16-git-send-email-chang.seok.bae@intel.com
parent 9ad75a09
...@@ -470,7 +470,7 @@ static void test_ptrace_write_gsbase(void) ...@@ -470,7 +470,7 @@ static void test_ptrace_write_gsbase(void)
wait(&status); wait(&status);
if (WSTOPSIG(status) == SIGTRAP) { if (WSTOPSIG(status) == SIGTRAP) {
unsigned long gs; unsigned long gs, base;
unsigned long gs_offset = USER_REGS_OFFSET(gs); unsigned long gs_offset = USER_REGS_OFFSET(gs);
unsigned long base_offset = USER_REGS_OFFSET(gs_base); unsigned long base_offset = USER_REGS_OFFSET(gs_base);
...@@ -486,6 +486,7 @@ static void test_ptrace_write_gsbase(void) ...@@ -486,6 +486,7 @@ static void test_ptrace_write_gsbase(void)
err(1, "PTRACE_POKEUSER"); err(1, "PTRACE_POKEUSER");
gs = ptrace(PTRACE_PEEKUSER, child, gs_offset, NULL); gs = ptrace(PTRACE_PEEKUSER, child, gs_offset, NULL);
base = ptrace(PTRACE_PEEKUSER, child, base_offset, NULL);
/* /*
* In a non-FSGSBASE system, the nonzero selector will load * In a non-FSGSBASE system, the nonzero selector will load
...@@ -496,8 +497,14 @@ static void test_ptrace_write_gsbase(void) ...@@ -496,8 +497,14 @@ static void test_ptrace_write_gsbase(void)
if (gs != 0x7) { if (gs != 0x7) {
nerrs++; nerrs++;
printf("[FAIL]\tGS changed to %lx\n", gs); printf("[FAIL]\tGS changed to %lx\n", gs);
} else if (have_fsgsbase && (base != 0xFF)) {
nerrs++;
printf("[FAIL]\tGSBASE changed to %lx\n", base);
} else { } else {
printf("[OK]\tGS remained 0x7\n"); printf("[OK]\tGS remained 0x7 %s");
if (have_fsgsbase)
printf("and GSBASE changed to 0xFF");
printf("\n");
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment