2 * Copyright 2015, Michael Neuling, IBM Corp.
3 * Licensed under GPLv2.
5 * Test the kernel's signal delievery code to ensure that we don't
6 * trelaim twice in the kernel signal delivery code. This can happen
7 * if we trigger a signal when in a transaction and the stack pointer
10 * This test case registers a SEGV handler, sets the stack pointer
11 * (r1) to NULL, starts a transaction and then generates a SEGV. The
12 * SEGV should be handled but we exit here as the stack pointer is
13 * invalid and hance we can't sigreturn. We only need to check that
14 * this flow doesn't crash the kernel.
18 #include <sys/types.h>
27 void signal_segv(int signum
)
29 /* This should never actually run since stack is foobar */
43 if (pid
) { /* Parent */
45 * It's likely the whole machine will crash here so if
46 * the child ever exits, we are good.
54 * 1) register a signal handler (so signal delievery occurs)
55 * 2) make stack pointer (r1) = NULL
56 * 3) start transaction
59 if (signal(SIGSEGV
, signal_segv
) == SIG_ERR
)
61 asm volatile("li 1, 0 ;" /* stack ptr == NULL */
64 "beq 1b ;" /* retry forever */
66 "ld 2, 0(1) ;" /* trigger segv" */
69 /* This should never get here due to above segv */
75 return test_harness(tm_signal_stack
, "tm_signal_stack");