diff options
author | Shuai Xue <xueshuai@linux.alibaba.com> | 2023-05-06 14:13:52 +0800 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2023-06-01 09:59:25 -0700 |
commit | 9d11fc3e05eae7b454efeb5941beded56f80445b (patch) | |
tree | 4939b18fd848429d2b85f6ca4e32e84f200e1db1 | |
parent | 025014dedca39d2b8a57a82e52286e72e157d73a (diff) | |
download | mce-test-9d11fc3e05eae7b454efeb5941beded56f80445b.tar.gz |
The current sighandler only restores the environment saved before, we
can not tell the SIGBUS reason. Therefore, explictly print si_code like
we do in tsimpleinj, 4 for BUS_MCEERR_AR, and 5 for BUS_MCEERR_AO.
Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r-- | cases/function/hwpoison/tprctl.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cases/function/hwpoison/tprctl.c b/cases/function/hwpoison/tprctl.c index d07e9d2..41a992b 100644 --- a/cases/function/hwpoison/tprctl.c +++ b/cases/function/hwpoison/tprctl.c @@ -39,8 +39,10 @@ static int madvise_poison(void *addr, size_t length, int advice) sigjmp_buf recover_ctx; volatile int seq; -void handler(int sig) +void sighandler(int sig, siginfo_t *si, void *arg) { + printf("signal %d code %d addr %p\n", sig, si->si_code, si->si_addr); + siglongjmp(recover_ctx, 1); } @@ -51,7 +53,11 @@ void test(int early) MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, 0,0); if (ptr == (char *)-1L) err("mmap"); - signal(SIGBUS, handler); + struct sigaction sa = { + .sa_sigaction = sighandler, + .sa_flags = SA_SIGINFO + }; + sigaction(SIGBUS, &sa, NULL); printf("ptr = %p\n", ptr); if (sigsetjmp(recover_ctx, 1) == 0) { seq = 0; |