diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-19 14:31:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-19 14:31:38 -0400 |
commit | e5a489abcfd216d07ad6b33ea0d191e61d0f25ea (patch) | |
tree | 2d56b24cfc559c8138a72d4ef52b45c2f2d536d4 /tools | |
parent | 8b4822de59d5d9919b9b045183a36c673ce20b73 (diff) | |
parent | e41e53cd4fe331d0d1f06f8e4ed7e2cc63ee2c34 (diff) |
Merge tag 'powerpc-4.12-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman:
"The headliner is a fix for FP/VMX register corruption when using
transactional memory, and a new selftest to go with it.
Then there's the virt_addr_valid() fix, currently HARDENDED_USERCOPY
is tripping on that causing some machines to crash.
A few other fairly minor fixes for long tail things, and a couple of
fixes for code we just merged.
Thanks to: Breno Leitao, Gautham Shenoy, Michael Neuling, Naveen Rao.
Nicholas Piggin, Paul Mackerras"
* tag 'powerpc-4.12-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
powerpc/mm: Fix virt_addr_valid() etc. on 64-bit hash
powerpc/mm: Fix crash in page table dump with huge pages
powerpc/kprobes: Fix handling of instruction emulation on probe re-entry
powerpc/powernv: Set NAPSTATELOST after recovering paca on P9 DD1
selftests/powerpc: Test TM and VMX register state
powerpc/tm: Fix FP and VMX register corruption
powerpc/modules: If mprofile-kernel is enabled add it to vermagic
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/powerpc/tm/.gitignore | 1 | ||||
-rw-r--r-- | tools/testing/selftests/powerpc/tm/Makefile | 4 | ||||
-rw-r--r-- | tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c | 118 |
3 files changed, 122 insertions, 1 deletions
diff --git a/tools/testing/selftests/powerpc/tm/.gitignore b/tools/testing/selftests/powerpc/tm/.gitignore index 427621792229..2f1f7b013293 100644 --- a/tools/testing/selftests/powerpc/tm/.gitignore +++ b/tools/testing/selftests/powerpc/tm/.gitignore | |||
@@ -11,3 +11,4 @@ tm-signal-context-chk-fpu | |||
11 | tm-signal-context-chk-gpr | 11 | tm-signal-context-chk-gpr |
12 | tm-signal-context-chk-vmx | 12 | tm-signal-context-chk-vmx |
13 | tm-signal-context-chk-vsx | 13 | tm-signal-context-chk-vsx |
14 | tm-vmx-unavail | ||
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile index 5576ee6a51f2..958c11c14acd 100644 --- a/tools/testing/selftests/powerpc/tm/Makefile +++ b/tools/testing/selftests/powerpc/tm/Makefile | |||
@@ -2,7 +2,8 @@ SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu | |||
2 | tm-signal-context-chk-vmx tm-signal-context-chk-vsx | 2 | tm-signal-context-chk-vmx tm-signal-context-chk-vsx |
3 | 3 | ||
4 | TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \ | 4 | TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \ |
5 | tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS) | 5 | tm-vmxcopy tm-fork tm-tar tm-tmspr tm-vmx-unavail \ |
6 | $(SIGNAL_CONTEXT_CHK_TESTS) | ||
6 | 7 | ||
7 | include ../../lib.mk | 8 | include ../../lib.mk |
8 | 9 | ||
@@ -13,6 +14,7 @@ CFLAGS += -mhtm | |||
13 | $(OUTPUT)/tm-syscall: tm-syscall-asm.S | 14 | $(OUTPUT)/tm-syscall: tm-syscall-asm.S |
14 | $(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include | 15 | $(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include |
15 | $(OUTPUT)/tm-tmspr: CFLAGS += -pthread | 16 | $(OUTPUT)/tm-tmspr: CFLAGS += -pthread |
17 | $(OUTPUT)/tm-vmx-unavail: CFLAGS += -pthread -m64 | ||
16 | 18 | ||
17 | SIGNAL_CONTEXT_CHK_TESTS := $(patsubst %,$(OUTPUT)/%,$(SIGNAL_CONTEXT_CHK_TESTS)) | 19 | SIGNAL_CONTEXT_CHK_TESTS := $(patsubst %,$(OUTPUT)/%,$(SIGNAL_CONTEXT_CHK_TESTS)) |
18 | $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S | 20 | $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S |
diff --git a/tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c b/tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c new file mode 100644 index 000000000000..137185ba4937 --- /dev/null +++ b/tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * Copyright 2017, Michael Neuling, IBM Corp. | ||
3 | * Licensed under GPLv2. | ||
4 | * Original: Breno Leitao <brenohl@br.ibm.com> & | ||
5 | * Gustavo Bueno Romero <gromero@br.ibm.com> | ||
6 | * Edited: Michael Neuling | ||
7 | * | ||
8 | * Force VMX unavailable during a transaction and see if it corrupts | ||
9 | * the checkpointed VMX register state after the abort. | ||
10 | */ | ||
11 | |||
12 | #include <inttypes.h> | ||
13 | #include <htmintrin.h> | ||
14 | #include <string.h> | ||
15 | #include <stdlib.h> | ||
16 | #include <stdio.h> | ||
17 | #include <pthread.h> | ||
18 | #include <sys/mman.h> | ||
19 | #include <unistd.h> | ||
20 | #include <pthread.h> | ||
21 | |||
22 | #include "tm.h" | ||
23 | #include "utils.h" | ||
24 | |||
25 | int passed; | ||
26 | |||
27 | void *worker(void *unused) | ||
28 | { | ||
29 | __int128 vmx0; | ||
30 | uint64_t texasr; | ||
31 | |||
32 | asm goto ( | ||
33 | "li 3, 1;" /* Stick non-zero value in VMX0 */ | ||
34 | "std 3, 0(%[vmx0_ptr]);" | ||
35 | "lvx 0, 0, %[vmx0_ptr];" | ||
36 | |||
37 | /* Wait here a bit so we get scheduled out 255 times */ | ||
38 | "lis 3, 0x3fff;" | ||
39 | "1: ;" | ||
40 | "addi 3, 3, -1;" | ||
41 | "cmpdi 3, 0;" | ||
42 | "bne 1b;" | ||
43 | |||
44 | /* Kernel will hopefully turn VMX off now */ | ||
45 | |||
46 | "tbegin. ;" | ||
47 | "beq failure;" | ||
48 | |||
49 | /* Cause VMX unavail. Any VMX instruction */ | ||
50 | "vaddcuw 0,0,0;" | ||
51 | |||
52 | "tend. ;" | ||
53 | "b %l[success];" | ||
54 | |||
55 | /* Check VMX0 sanity after abort */ | ||
56 | "failure: ;" | ||
57 | "lvx 1, 0, %[vmx0_ptr];" | ||
58 | "vcmpequb. 2, 0, 1;" | ||
59 | "bc 4, 24, %l[value_mismatch];" | ||
60 | "b %l[value_match];" | ||
61 | : | ||
62 | : [vmx0_ptr] "r"(&vmx0) | ||
63 | : "r3" | ||
64 | : success, value_match, value_mismatch | ||
65 | ); | ||
66 | |||
67 | /* HTM aborted and VMX0 is corrupted */ | ||
68 | value_mismatch: | ||
69 | texasr = __builtin_get_texasr(); | ||
70 | |||
71 | printf("\n\n==============\n\n"); | ||
72 | printf("Failure with error: %lx\n", _TEXASR_FAILURE_CODE(texasr)); | ||
73 | printf("Summary error : %lx\n", _TEXASR_FAILURE_SUMMARY(texasr)); | ||
74 | printf("TFIAR exact : %lx\n\n", _TEXASR_TFIAR_EXACT(texasr)); | ||
75 | |||
76 | passed = 0; | ||
77 | return NULL; | ||
78 | |||
79 | /* HTM aborted but VMX0 is correct */ | ||
80 | value_match: | ||
81 | // printf("!"); | ||
82 | return NULL; | ||
83 | |||
84 | success: | ||
85 | // printf("."); | ||
86 | return NULL; | ||
87 | } | ||
88 | |||
89 | int tm_vmx_unavail_test() | ||
90 | { | ||
91 | int threads; | ||
92 | pthread_t *thread; | ||
93 | |||
94 | SKIP_IF(!have_htm()); | ||
95 | |||
96 | passed = 1; | ||
97 | |||
98 | threads = sysconf(_SC_NPROCESSORS_ONLN) * 4; | ||
99 | thread = malloc(sizeof(pthread_t)*threads); | ||
100 | if (!thread) | ||
101 | return EXIT_FAILURE; | ||
102 | |||
103 | for (uint64_t i = 0; i < threads; i++) | ||
104 | pthread_create(&thread[i], NULL, &worker, NULL); | ||
105 | |||
106 | for (uint64_t i = 0; i < threads; i++) | ||
107 | pthread_join(thread[i], NULL); | ||
108 | |||
109 | free(thread); | ||
110 | |||
111 | return passed ? EXIT_SUCCESS : EXIT_FAILURE; | ||
112 | } | ||
113 | |||
114 | |||
115 | int main(int argc, char **argv) | ||
116 | { | ||
117 | return test_harness(tm_vmx_unavail_test, "tm_vmx_unavail_test"); | ||
118 | } | ||