diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2018-11-11 21:46:06 -0500 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-11-11 22:47:54 -0500 |
commit | 2c7645b0f7d1014f2636393de7906c6bfd25939f (patch) | |
tree | 4ac37971e808e324b428551a9836bf5934bbad29 /tools/testing | |
parent | 43c6494fa1499912c8177e71450c0279041152a6 (diff) |
selftests/powerpc: Fix wild_bctr test to work on ppc64
The selftest I recently added to test branching to an out-of-bounds
NIP doesn't work on 64-bit big endian. It does fail but not in the
right way. That is it SEGVs trying to load from the opd at BAD_NIP,
but it never gets as far as branching to BAD_NIP.
To fix it we need to create an opd which is reachable but which holds
the bad address.
Fixes: b7683fc66eba ("selftests/powerpc: Add a test of wild bctr")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'tools/testing')
-rw-r--r-- | tools/testing/selftests/powerpc/mm/wild_bctr.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/testing/selftests/powerpc/mm/wild_bctr.c b/tools/testing/selftests/powerpc/mm/wild_bctr.c index 1b0e9e9a2ddc..90469a9e49d4 100644 --- a/tools/testing/selftests/powerpc/mm/wild_bctr.c +++ b/tools/testing/selftests/powerpc/mm/wild_bctr.c | |||
@@ -105,6 +105,20 @@ static void dump_regs(void) | |||
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | #ifdef _CALL_AIXDESC | ||
109 | struct opd { | ||
110 | unsigned long ip; | ||
111 | unsigned long toc; | ||
112 | unsigned long env; | ||
113 | }; | ||
114 | static struct opd bad_opd = { | ||
115 | .ip = BAD_NIP, | ||
116 | }; | ||
117 | #define BAD_FUNC (&bad_opd) | ||
118 | #else | ||
119 | #define BAD_FUNC BAD_NIP | ||
120 | #endif | ||
121 | |||
108 | int test_wild_bctr(void) | 122 | int test_wild_bctr(void) |
109 | { | 123 | { |
110 | int (*func_ptr)(void); | 124 | int (*func_ptr)(void); |
@@ -133,7 +147,7 @@ int test_wild_bctr(void) | |||
133 | 147 | ||
134 | poison_regs(); | 148 | poison_regs(); |
135 | 149 | ||
136 | func_ptr = (int (*)(void))BAD_NIP; | 150 | func_ptr = (int (*)(void))BAD_FUNC; |
137 | func_ptr(); | 151 | func_ptr(); |
138 | 152 | ||
139 | FAIL_IF(1); /* we didn't segv? */ | 153 | FAIL_IF(1); /* we didn't segv? */ |