* [PATCH] selftests/powerpc: Fix wild_bctr test to work on BE
@ 2018-11-07 10:17 Michael Ellerman
2018-11-07 17:48 ` Segher Boessenkool
0 siblings, 1 reply; 2+ messages in thread
From: Michael Ellerman @ 2018-11-07 10:17 UTC (permalink / raw)
To: linuxppc-dev
The selftest I recently added to test branching to an out-of-bounds
NIP doesn't work on 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>
---
tools/testing/selftests/powerpc/mm/wild_bctr.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/powerpc/mm/wild_bctr.c b/tools/testing/selftests/powerpc/mm/wild_bctr.c
index 1b0e9e9a2ddc..dda314bb59dd 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)
}
}
+#ifdef __BIG_ENDIAN__
+struct opd {
+ unsigned long ip;
+ unsigned long toc;
+ unsigned long env;
+};
+static struct opd bad_opd = {
+ .ip = BAD_NIP,
+};
+#define BAD_FUNC (&bad_opd)
+#else
+#define BAD_FUNC BAD_NIP
+#endif
+
int test_wild_bctr(void)
{
int (*func_ptr)(void);
@@ -133,7 +147,7 @@ int test_wild_bctr(void)
poison_regs();
- func_ptr = (int (*)(void))BAD_NIP;
+ func_ptr = (int (*)(void))BAD_FUNC;
func_ptr();
FAIL_IF(1); /* we didn't segv? */
--
2.17.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests/powerpc: Fix wild_bctr test to work on BE
2018-11-07 10:17 [PATCH] selftests/powerpc: Fix wild_bctr test to work on BE Michael Ellerman
@ 2018-11-07 17:48 ` Segher Boessenkool
0 siblings, 0 replies; 2+ messages in thread
From: Segher Boessenkool @ 2018-11-07 17:48 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
Hi!
On Wed, Nov 07, 2018 at 09:17:23PM +1100, Michael Ellerman wrote:
> The selftest I recently added to test branching to an out-of-bounds
> NIP doesn't work on 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.
> +#ifdef __BIG_ENDIAN__
Maybe you should test for _CALL_AIXDESC instead? It is more directly
what you want to know, and it even works correctly in all cases ;-)
Segher
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-07 17:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07 10:17 [PATCH] selftests/powerpc: Fix wild_bctr test to work on BE Michael Ellerman
2018-11-07 17:48 ` Segher Boessenkool
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.