aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-11 20:34:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-11 20:34:00 -0400
commitfd9879b9bb3258ebc27a4cc6d2d29f528f71901f (patch)
tree48b68994f5e8083aafe116533e8143cb2bf30c85 /tools/testing
parent81ae31d78239318610d7c2acb3e2610d622a5aa4 (diff)
parentd53ba6b3bba33432cc37b7101a86f8f3392c46e7 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux
Pull powerpc updates from Michael Ellerman: "Here's a first pull request for powerpc updates for 3.18. The bulk of the additions are for the "cxl" driver, for IBM's Coherent Accelerator Processor Interface (CAPI). Most of it's in drivers/misc, which Greg & Arnd maintain, Greg said he was happy for us to take it through our tree. There's the usual minor cleanups and fixes, including a bit of noise in drivers from some of those. A bunch of updates to our EEH code, which has been getting more testing. Several nice speedups from Anton, including 20% in clear_page(). And a bunch of updates for freescale from Scott" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux: (130 commits) cxl: Fix afu_read() not doing finish_wait() on signal or non-blocking cxl: Add documentation for userspace APIs cxl: Add driver to Kbuild and Makefiles cxl: Add userspace header file cxl: Driver code for powernv PCIe based cards for userspace access cxl: Add base builtin support powerpc/mm: Add hooks for cxl powerpc/opal: Add PHB to cxl mode call powerpc/mm: Add new hash_page_mm() powerpc/powerpc: Add new PCIe functions for allocating cxl interrupts cxl: Add new header for call backs and structs powerpc/powernv: Split out set MSI IRQ chip code powerpc/mm: Export mmu_kernel_ssize and mmu_linear_psize powerpc/msi: Improve IRQ bitmap allocator powerpc/cell: Make spu_flush_all_slbs() generic powerpc/cell: Move data segment faulting code out of cell platform powerpc/cell: Move spu_handle_mm_fault() out of cell platform powerpc/pseries: Use new defines when calling H_SET_MODE powerpc: Update contact info in Documentation files powerpc/perf/hv-24x7: Simplify catalog_read() ...
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/powerpc/Makefile2
-rw-r--r--tools/testing/selftests/powerpc/primitives/Makefile17
l---------tools/testing/selftests/powerpc/primitives/asm/asm-compat.h1
-rw-r--r--tools/testing/selftests/powerpc/primitives/asm/ppc-opcode.h0
-rw-r--r--tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad.c147
l---------tools/testing/selftests/powerpc/primitives/word-at-a-time.h1
6 files changed, 167 insertions, 1 deletions
diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index 74a78cedce37..f6ff90a76bd7 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -13,7 +13,7 @@ CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CUR
13 13
14export CC CFLAGS 14export CC CFLAGS
15 15
16TARGETS = pmu copyloops mm tm 16TARGETS = pmu copyloops mm tm primitives
17 17
18endif 18endif
19 19
diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
new file mode 100644
index 000000000000..ea737ca01732
--- /dev/null
+++ b/tools/testing/selftests/powerpc/primitives/Makefile
@@ -0,0 +1,17 @@
1CFLAGS += -I$(CURDIR)
2
3PROGS := load_unaligned_zeropad
4
5all: $(PROGS)
6
7$(PROGS): ../harness.c
8
9run_tests: all
10 @-for PROG in $(PROGS); do \
11 ./$$PROG; \
12 done;
13
14clean:
15 rm -f $(PROGS) *.o
16
17.PHONY: all run_tests clean
diff --git a/tools/testing/selftests/powerpc/primitives/asm/asm-compat.h b/tools/testing/selftests/powerpc/primitives/asm/asm-compat.h
new file mode 120000
index 000000000000..b14255e15a25
--- /dev/null
+++ b/tools/testing/selftests/powerpc/primitives/asm/asm-compat.h
@@ -0,0 +1 @@
../.././../../../../arch/powerpc/include/asm/asm-compat.h \ No newline at end of file
diff --git a/tools/testing/selftests/powerpc/primitives/asm/ppc-opcode.h b/tools/testing/selftests/powerpc/primitives/asm/ppc-opcode.h
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/tools/testing/selftests/powerpc/primitives/asm/ppc-opcode.h
diff --git a/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad.c b/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad.c
new file mode 100644
index 000000000000..d1b647509596
--- /dev/null
+++ b/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad.c
@@ -0,0 +1,147 @@
1/*
2 * Userspace test harness for load_unaligned_zeropad. Creates two
3 * pages and uses mprotect to prevent access to the second page and
4 * a SEGV handler that walks the exception tables and runs the fixup
5 * routine.
6 *
7 * The results are compared against a normal load that is that is
8 * performed while access to the second page is enabled via mprotect.
9 *
10 * Copyright (C) 2014 Anton Blanchard <anton@au.ibm.com>, IBM
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17
18#include <stdlib.h>
19#include <string.h>
20#include <stdio.h>
21#include <stdbool.h>
22#include <signal.h>
23#include <unistd.h>
24#include <sys/mman.h>
25
26#define FIXUP_SECTION ".ex_fixup"
27
28#include "word-at-a-time.h"
29
30#include "utils.h"
31
32
33static int page_size;
34static char *mem_region;
35
36static int protect_region(void)
37{
38 if (mprotect(mem_region + page_size, page_size, PROT_NONE)) {
39 perror("mprotect");
40 return 1;
41 }
42
43 return 0;
44}
45
46static int unprotect_region(void)
47{
48 if (mprotect(mem_region + page_size, page_size, PROT_READ|PROT_WRITE)) {
49 perror("mprotect");
50 return 1;
51 }
52
53 return 0;
54}
55
56extern char __start___ex_table[];
57extern char __stop___ex_table[];
58
59#if defined(__powerpc64__)
60#define UCONTEXT_NIA(UC) (UC)->uc_mcontext.gp_regs[PT_NIP]
61#elif defined(__powerpc__)
62#define UCONTEXT_NIA(UC) (UC)->uc_mcontext.uc_regs->gregs[PT_NIP]
63#else
64#error implement UCONTEXT_NIA
65#endif
66
67static int segv_error;
68
69static void segv_handler(int signr, siginfo_t *info, void *ptr)
70{
71 ucontext_t *uc = (ucontext_t *)ptr;
72 unsigned long addr = (unsigned long)info->si_addr;
73 unsigned long *ip = &UCONTEXT_NIA(uc);
74 unsigned long *ex_p = (unsigned long *)__start___ex_table;
75
76 while (ex_p < (unsigned long *)__stop___ex_table) {
77 unsigned long insn, fixup;
78
79 insn = *ex_p++;
80 fixup = *ex_p++;
81
82 if (insn == *ip) {
83 *ip = fixup;
84 return;
85 }
86 }
87
88 printf("No exception table match for NIA %lx ADDR %lx\n", *ip, addr);
89 segv_error++;
90}
91
92static void setup_segv_handler(void)
93{
94 struct sigaction action;
95
96 memset(&action, 0, sizeof(action));
97 action.sa_sigaction = segv_handler;
98 action.sa_flags = SA_SIGINFO;
99 sigaction(SIGSEGV, &action, NULL);
100}
101
102static int do_one_test(char *p, int page_offset)
103{
104 unsigned long should;
105 unsigned long got;
106
107 FAIL_IF(unprotect_region());
108 should = *(unsigned long *)p;
109 FAIL_IF(protect_region());
110
111 got = load_unaligned_zeropad(p);
112
113 if (should != got)
114 printf("offset %u load_unaligned_zeropad returned 0x%lx, should be 0x%lx\n", page_offset, got, should);
115
116 return 0;
117}
118
119static int test_body(void)
120{
121 unsigned long i;
122
123 page_size = getpagesize();
124 mem_region = mmap(NULL, page_size * 2, PROT_READ|PROT_WRITE,
125 MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
126
127 FAIL_IF(mem_region == MAP_FAILED);
128
129 for (i = 0; i < page_size; i++)
130 mem_region[i] = i;
131
132 memset(mem_region+page_size, 0, page_size);
133
134 setup_segv_handler();
135
136 for (i = 0; i < page_size; i++)
137 FAIL_IF(do_one_test(mem_region+i, i));
138
139 FAIL_IF(segv_error);
140
141 return 0;
142}
143
144int main(void)
145{
146 return test_harness(test_body, "load_unaligned_zeropad");
147}
diff --git a/tools/testing/selftests/powerpc/primitives/word-at-a-time.h b/tools/testing/selftests/powerpc/primitives/word-at-a-time.h
new file mode 120000
index 000000000000..eb74401b591f
--- /dev/null
+++ b/tools/testing/selftests/powerpc/primitives/word-at-a-time.h
@@ -0,0 +1 @@
../../../../../arch/powerpc/include/asm/word-at-a-time.h \ No newline at end of file