diff options
author | Andy Lutomirski <luto@kernel.org> | 2017-11-04 07:19:49 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-11-07 05:13:42 -0500 |
commit | d60ad744c9741586010d4bea286f09a063a90fbd (patch) | |
tree | 151677d1e329c26a86024662a12c74387ea3bd2d | |
parent | 693cb5580fdb026922363aa103add64b3ecd572e (diff) |
selftests/x86/ldt_gdt: Robustify against set_thread_area() and LAR oddities
Bits 19:16 of LAR's result are undefined, and some upcoming
improvements to the test case seem to trigger this. Mask off those
bits to avoid spurious failures.
commit 5b781c7e317f ("x86/tls: Forcibly set the accessed bit in TLS
segments") adds a valid case in which LAR's output doesn't quite
agree with set_thread_area()'s input. This isn't triggered in the
test as is, but it will be if we start calling set_thread_area()
with the accessed bit clear. Work around this discrepency.
I've added a Fixes tag so that -stable can pick this up if neccesary.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bpetkov@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 5b781c7e317f ("x86/tls: Forcibly set the accessed bit in TLS segments")
Link: http://lkml.kernel.org/r/b82f3f89c034b53580970ac865139fd8863f44e2.1509794321.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | tools/testing/selftests/x86/ldt_gdt.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/testing/selftests/x86/ldt_gdt.c b/tools/testing/selftests/x86/ldt_gdt.c index 961e3ee26c27..b0334338a4b0 100644 --- a/tools/testing/selftests/x86/ldt_gdt.c +++ b/tools/testing/selftests/x86/ldt_gdt.c | |||
@@ -115,7 +115,15 @@ static void check_valid_segment(uint16_t index, int ldt, | |||
115 | return; | 115 | return; |
116 | } | 116 | } |
117 | 117 | ||
118 | if (ar != expected_ar) { | 118 | /* The SDM says "bits 19:16 are undefined". Thanks. */ |
119 | ar &= ~0xF0000; | ||
120 | |||
121 | /* | ||
122 | * NB: Different Linux versions do different things with the | ||
123 | * accessed bit in set_thread_area(). | ||
124 | */ | ||
125 | if (ar != expected_ar && | ||
126 | (ldt || ar != (expected_ar | AR_ACCESSED))) { | ||
119 | printf("[FAIL]\t%s entry %hu has AR 0x%08X but expected 0x%08X\n", | 127 | printf("[FAIL]\t%s entry %hu has AR 0x%08X but expected 0x%08X\n", |
120 | (ldt ? "LDT" : "GDT"), index, ar, expected_ar); | 128 | (ldt ? "LDT" : "GDT"), index, ar, expected_ar); |
121 | nerrs++; | 129 | nerrs++; |