mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
bsd-user:Add ARM AArch64 signal handling support
Added sigcode setup function for signal trampoline which initializes a sequence of instructions to handle signal returns and exits, copying this code to the target offset. Defined ARM AArch64 specific signal definitions including register indices and sizes, and introduced structures to represent general purpose registers, floating point registers, and machine context. Added function to set up signal handler arguments, populating register values in `CPUARMState` based on the provided signal, signal frame, signal action, and frame address. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Ajeet Singh <itachis@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Co-authored-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20240707191128.10509-5-itachis@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
This commit is contained in:
parent
1541d87db2
commit
7dba5e10a6
3 changed files with 181 additions and 0 deletions
53
bsd-user/aarch64/signal.c
Normal file
53
bsd-user/aarch64/signal.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* ARM AArch64 specific signal definitions for bsd-user
|
||||
*
|
||||
* Copyright (c) 2015 Stacey D. Son <sson at FreeBSD>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "qemu/osdep.h"
|
||||
|
||||
#include "qemu.h"
|
||||
|
||||
/*
|
||||
* Compare to sendsig() in sys/arm64/arm64/machdep.c
|
||||
* Assumes that target stack frame memory is locked.
|
||||
*/
|
||||
abi_long set_sigtramp_args(CPUARMState *regs, int sig,
|
||||
struct target_sigframe *frame,
|
||||
abi_ulong frame_addr,
|
||||
struct target_sigaction *ka)
|
||||
{
|
||||
/*
|
||||
* Arguments to signal handler:
|
||||
* x0 = signal number
|
||||
* x1 = siginfo pointer
|
||||
* x2 = ucontext pointer
|
||||
* pc/elr = signal handler pointer
|
||||
* sp = sigframe struct pointer
|
||||
* lr = sigtramp at base of user stack
|
||||
*/
|
||||
|
||||
regs->xregs[0] = sig;
|
||||
regs->xregs[1] = frame_addr +
|
||||
offsetof(struct target_sigframe, sf_si);
|
||||
regs->xregs[2] = frame_addr +
|
||||
offsetof(struct target_sigframe, sf_uc);
|
||||
|
||||
regs->pc = ka->_sa_handler;
|
||||
regs->xregs[TARGET_REG_SP] = frame_addr;
|
||||
regs->xregs[TARGET_REG_LR] = TARGET_PS_STRINGS - TARGET_SZSIGCODE;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue