forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests/powerpc: Add a test of sigreturning to an unaligned address
Add a test of sigreturning to an unaligned address (low two bits set). This should have no effect because the hardware will mask those bits. However it previously falsely triggered a warning when CONFIG_PPC_RFI_SRR_DEBUG=y. Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ sigfuz | |
sigreturn_vdso | ||
sig_sc_double_restart | ||
sigreturn_kernel | ||
sigreturn_unaligned |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
tools/testing/selftests/powerpc/signal/sigreturn_unaligned.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Test sigreturn to an unaligned address, ie. low 2 bits set. | ||
* Nothing bad should happen. | ||
* This was able to trigger warnings with CONFIG_PPC_RFI_SRR_DEBUG=y. | ||
*/ | ||
|
||
#include <signal.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <ucontext.h> | ||
#include <unistd.h> | ||
|
||
#include "utils.h" | ||
|
||
|
||
static void sigusr1_handler(int signo, siginfo_t *info, void *ptr) | ||
{ | ||
ucontext_t *uc = ptr; | ||
|
||
UCONTEXT_NIA(uc) |= 3; | ||
} | ||
|
||
static int test_sigreturn_unaligned(void) | ||
{ | ||
struct sigaction action; | ||
|
||
memset(&action, 0, sizeof(action)); | ||
action.sa_sigaction = sigusr1_handler; | ||
action.sa_flags = SA_SIGINFO; | ||
|
||
FAIL_IF(sigaction(SIGUSR1, &action, NULL) == -1); | ||
|
||
raise(SIGUSR1); | ||
|
||
return 0; | ||
} | ||
|
||
int main(void) | ||
{ | ||
return test_harness(test_sigreturn_unaligned, "sigreturn_unaligned"); | ||
} |