2 * Copyright 2016, Chris Smart, IBM Corporation.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Common code for copy, copy_first, paste and paste_last unaligned
18 #include "instructions.h"
19 #include "copy_paste_unaligned_common.h"
21 unsigned int expected_instruction;
22 unsigned int instruction_mask;
24 char cacheline_buf[128] __cacheline_aligned;
26 void signal_action_handler(int signal_num, siginfo_t *info, void *ptr)
28 ucontext_t *ctx = ptr;
29 #if defined(__powerpc64__)
30 unsigned int *pc = (unsigned int *)ctx->uc_mcontext.gp_regs[PT_NIP];
32 unsigned int *pc = (unsigned int *)ctx->uc_mcontext.uc_regs->gregs[PT_NIP];
36 * Check that the signal was on the correct instruction, using a
37 * mask because the compiler assigns the register at RB.
39 if ((*pc & instruction_mask) == expected_instruction)
40 _exit(0); /* We hit the right instruction */
45 void setup_signal_handler(void)
47 struct sigaction signal_action;
49 memset(&signal_action, 0, sizeof(signal_action));
50 signal_action.sa_sigaction = signal_action_handler;
51 signal_action.sa_flags = SA_SIGINFO;
52 sigaction(SIGBUS, &signal_action, NULL);