/* * Copyright 2015, Michael Neuling, IBM Corp. * Licensed under GPLv2. * * Test the kernel's signal delievery code to ensure that we don't * trelaim twice in the kernel signal delivery code. This can happen * if we trigger a signal when in a transaction and the stack pointer * is bogus. * * This test case registers a SEGV handler, sets the stack pointer * (r1) to NULL, starts a transaction and then generates a SEGV. The * SEGV should be handled but we exit here as the stack pointer is * invalid and hance we can't sigreturn. We only need to check that * this flow doesn't crash the kernel. */ #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <stdlib.h> #include <stdio.h> #include <signal.h> #include "utils.h" #include "tm.h" void signal_segv(int signum) { /* This should never actually run since stack is foobar */ exit(1); } int tm_signal_stack() { int pid; SKIP_IF(!have_htm()); pid = fork(); if (pid < 0) exit(1); if (pid) { /* Parent */ /* * It's likely the whole machine will crash here so if * the child ever exits, we are good. */ wait(NULL); return 0; } /* * The flow here is: * 1) register a signal handler (so signal delievery occurs) * 2) make stack pointer (r1) = NULL * 3) start transaction * 4) cause segv */ if (signal(SIGSEGV, signal_segv) == SIG_ERR) exit(1); asm volatile("li 1, 0 ;" /* stack ptr == NULL */ "1:" "tbegin.;" "beq 1b ;" /* retry forever */ "tsuspend.;" "ld 2, 0(1) ;" /* trigger segv" */ : : : "memory"); /* This should never get here due to above segv */ return 1; } int main(void) { return test_harness(tm_signal_stack, "tm_signal_stack"); } t.git/tree/drivers/infiniband/core?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>tree</a><a class='active' href='/cgit.cgi/linux/net-next.git/commit/drivers/infiniband/core?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/drivers/infiniband/core?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/drivers/infiniband/core'> <input type='hidden' name='id' value='7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'/><select name='qt'> <option value='grep'>log msg</option> <option value='author'>author</option> <option value='committer'>committer</option> <option value='range'>range</option> </select> <input class='txt' type='search' size='10' name='q' value=''/> <input type='submit' value='search'/> </form> </td></tr></table> <div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/commit/?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>root</a>/<a href='/cgit.cgi/linux/net-next.git/commit/drivers?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>drivers</a>/<a href='/cgit.cgi/linux/net-next.git/commit/drivers/infiniband?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>infiniband</a>/<a href='/cgit.cgi/linux/net-next.git/commit/drivers/infiniband/core?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>core</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='id' value='7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><table summary='commit info' class='commit-info'> <tr><th>author</th><td>Linus Torvalds <torvalds@linux-foundation.org></td><td class='right'>2014-01-12 17:04:18 +0700</td></tr> <tr><th>committer</th><td>Linus Torvalds <torvalds@linux-foundation.org></td><td class='right'>2014-01-12 17:04:18 +0700</td></tr> <tr><th>commit</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/drivers/infiniband/core?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>7e22e91102c6b9df7c4ae2168910e19d2bb14cd6</a> (<a href='/cgit.cgi/linux/net-next.git/patch/drivers/infiniband/core?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>patch</a>)</td></tr> <tr><th>tree</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/tree/?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>a0b3677d442ed08ca16943fb471a90f5fd5bc367</a> /<a href='/cgit.cgi/linux/net-next.git/tree/drivers/infiniband/core?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>drivers/infiniband/core</a></td></tr> <tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/drivers/infiniband/core?id=3dc91d4338d698ce77832985f9cb183d8eeaf6be'>3dc91d4338d698ce77832985f9cb183d8eeaf6be</a> (<a href='/cgit.cgi/linux/net-next.git/diff/drivers/infiniband/core?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6&id2=3dc91d4338d698ce77832985f9cb183d8eeaf6be'>diff</a>)</td></tr></table> <div class='commit-subject'>Linux 3.13-rc8</div><div class='commit-msg'></div><div class='diffstat-header'><a href='/cgit.cgi/linux/net-next.git/diff/?id=7e22e91102c6b9df7c4ae2168910e19d2bb14cd6'>Diffstat</a> (limited to 'drivers/infiniband/core')</div><table summary='diffstat' class='diffstat'>