bsd-user: arm (32-bit) support
v4 cover bsd-user: arm (32-bit) support
This series of patches brings in 32-bit arm support for bsd-user. It implements all the bits needed to do image activation, signal handling, stack management and threading. This allows us to get to the "Hello World" level. The arm and x86 code are now the same as in the bsd-user fork. For full context, the fork is at
https://github.com/qemu-bsd-user/qemu-bsd-user/tree/blitz (though the the recent sig{bus,segv} needed updates are incomplete).
v4 changes the following:
* Remove mips* -- the bsd-user fork has removed it, so clean up the clutter.
* Move target_os_ucontext.h patch earlier in the series and add check of ucontext_t and mcontext_t sizes to match native sizes.
* Move x86 patches earlier in the patch series and Fill in the i386 and x86_64 mcontext contents to match FreeBSD and define TARGET_[UM]CONTEXT_SIZE to enable size checking.
* generally: Move inlines from target_arch_signal.h to signal.c
* Collapse arm's definition mcontext and trapframe into one commit and add size with TARGET_[MU]CONTEXT_SIZE.
* Fix the saving of vfp context to use proper locking and fetching of target address to get/save it.
* Filter out low-order bits of pc in arm set_mcontext()
Where code just moved (maybe with trivial changes), I retained reviewed-by tagging. When the changes were more substantial due to issues discovered by getting the size right, I droppped prior review. The following thus lack review:
bsd-user/mips*: Remove
bsd-user/freebsd: Create common target_os_ucontext.h file
bsd-user: create a per-arch signal.c file bsd-user/i386/target_arch_signal.h: Update mcontext_t to match FreeBSD bsd-user/i386: Move the inlines into signal.c bsd-user/x86_64/target_arch_signal.h: Fill in mcontext_t bsd-user/x86_64: Move functions into signal.c bsd-user/arm/target_arch_signal.h: arm machine context and trapframe for signals bsd-user/arm/target_arch_signal.h: Define size of *context_t bsd-user/arm/target_arch_signal.c: arm get_mcontext bsd-user/arm/target_arch_signal.c: arm set_mcontext bsd-user/freebsd/target_os_ucontext.h: Require TARGET_*CONTEXT_SIZE
Warnings that should be ignored:
o make checkpatch has a couple of complaints about the comments for the signal trampoline, since it's a false positive IMHO.
WARNING: Block comments use a leading /* on a separate line
+ /* 8 */ sys_sigreturn,
WARNING: Block comments use a leading /* on a separate line
+ /* 9 */ sys_exit
Warner Losh (36):
bsd-user/mips*: Remove
bsd-user/freebsd: Create common target_os_ucontext.h file
bsd-user: create a per-arch signal.c file bsd-user/i386/target_arch_signal.h: Remove target_sigcontext bsd-user/i386/target_arch_signal.h: use new target_os_ucontext.h bsd-user/i386/target_arch_signal.h: Update mcontext_t to match FreeBSD bsd-user/i386: Move the inlines into signal.c bsd-user/x86_64/target_arch_signal.h: Remove target_sigcontext bsd-user/x86_64/target_arch_signal.h: use new target_os_ucontext.h bsd-user/x86_64/target_arch_signal.h: Fill in mcontext_t bsd-user/x86_64: Move functions into signal.c bsd-user/arm/target_arch_sysarch.h: Use consistent include guards bsd-user/arm/target_syscall.h: Add copyright and update name bsd-user/arm/target_arch_cpu.c: Target specific TLS routines bsd-user/arm/target_arch_cpu.h: CPU Loop definitions bsd-user/arm/target_arch_cpu.h: Implement target_cpu_clone_regs bsd-user/arm/target_arch_cpu.h: Dummy target_cpu_loop implementation bsd-user/arm/target_arch_cpu.h: Implement trivial EXCP exceptions bsd-user/arm/target_arch_cpu.h: Implement data abort exceptions bsd-user/arm/target_arch_cpu.h: Implement system call dispatch bsd-user/arm/target_arch_reg.h: Implement core dump register copying bsd-user/arm/target_arch_vmparam.h: Parameters for arm address space bsd-user/arm/target_arch_sigtramp.h: Signal Trampoline for arm bsd-user/arm/target_arch_thread.h: Routines to create and switch to a
thread
bsd-user/arm/target_arch_elf.h: arm defines for ELF bsd-user/arm/target_arch_elf.h: arm get hwcap bsd-user/arm/target_arch_elf.h: arm get_hwcap2 impl bsd-user/arm/target_arch_signal.h: arm specific signal registers and
stack
bsd-user/arm/target_arch_signal.h: arm machine context and trapframe
for signals
bsd-user/arm/target_arch_signal.h: Define size of *context_t bsd-user/arm/target_arch_signal.c: arm set_sigtramp_args bsd-user/arm/target_arch_signal.c: arm get_mcontext bsd-user/arm/target_arch_signal.c: arm set_mcontext bsd-user/arm/target_arch_signal.c: arm get_ucontext_sigreturn bsd-user/freebsd/target_os_ucontext.h: Require TARGET_*CONTEXT_SIZE
bsd-user: add arm target build
bsd-user/arm/signal.c | 199 ++++++++++++++++++++++++ bsd-user/arm/target_arch.h | 28 ++++ bsd-user/arm/target_arch_cpu.c | 39 +++++ bsd-user/arm/target_arch_cpu.h | 211 ++++++++++++++++++++++++++ bsd-user/arm/target_arch_elf.h | 128 ++++++++++++++++ bsd-user/arm/target_arch_reg.h | 60 ++++++++ bsd-user/arm/target_arch_signal.h | 97 ++++++++++++ bsd-user/arm/target_arch_sigtramp.h | 49 ++++++ bsd-user/arm/target_arch_sysarch.h | 6 +- bsd-user/arm/target_arch_thread.h | 82 ++++++++++ bsd-user/arm/target_arch_vmparam.h | 48 ++++++ bsd-user/arm/target_syscall.h | 27 +++- bsd-user/freebsd/target_os_signal.h | 3 - bsd-user/freebsd/target_os_ucontext.h | 33 ++++ bsd-user/i386/signal.c | 55 +++++++ bsd-user/i386/target_arch_signal.h | 102 +++++++------ bsd-user/mips/target_arch_sysarch.h | 69 --------- bsd-user/mips/target_syscall.h | 52 ------- bsd-user/mips64/target_arch_sysarch.h | 69 --------- bsd-user/mips64/target_syscall.h | 53 ------- bsd-user/x86_64/signal.c | 55 +++++++ bsd-user/x86_64/target_arch_signal.h | 110 ++++++++------ configs/targets/arm-bsd-user.mak | 2 + meson.build | 2 +- 24 files changed, 1231 insertions(+), 348 deletions(-) create mode 100644 bsd-user/arm/signal.c create mode 100644 bsd-user/arm/target_arch.h create mode 100644 bsd-user/arm/target_arch_cpu.c create mode 100644 bsd-user/arm/target_arch_cpu.h create mode 100644 bsd-user/arm/target_arch_elf.h create mode 100644 bsd-user/arm/target_arch_reg.h create mode 100644 bsd-user/arm/target_arch_signal.h create mode 100644 bsd-user/arm/target_arch_sigtramp.h create mode 100644 bsd-user/arm/target_arch_thread.h create mode 100644 bsd-user/arm/target_arch_vmparam.h create mode 100644 bsd-user/freebsd/target_os_ucontext.h create mode 100644 bsd-user/i386/signal.c delete mode 100644 bsd-user/mips/target_arch_sysarch.h delete mode 100644 bsd-user/mips/target_syscall.h delete mode 100644 bsd-user/mips64/target_arch_sysarch.h delete mode 100644 bsd-user/mips64/target_syscall.h create mode 100644 bsd-user/x86_64/signal.c create mode 100644 configs/targets/arm-bsd-user.mak
Signature · 1 line
2.33.0
PATCH v4 1/36 bsd-user/mips*: Remove
FreeBSD has dropped support for mips starting with FreeBSD 14. mips support has been removed from the bsd-user fork because updating it for new signal requirements. Remove it here since it is a distraction.
--- bsd-user/mips/target_arch_sysarch.h | 69 --------------------------- bsd-user/mips/target_syscall.h | 52 -------------------- bsd-user/mips64/target_arch_sysarch.h | 69 --------------------------- bsd-user/mips64/target_syscall.h | 53 -------------------- 4 files changed, 243 deletions(-) delete mode 100644 bsd-user/mips/target_arch_sysarch.h delete mode 100644 bsd-user/mips/target_syscall.h delete mode 100644 bsd-user/mips64/target_arch_sysarch.h delete mode 100644 bsd-user/mips64/target_syscall.h
bsd-user/mips/target_arch_sysarch.h deleted +0 -69
@@ -1,69 +0,0 @@ -/* -* mips sysarch() system call emulation -* -* Copyright (c) 2013 Stacey D. Son -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program 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 General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef BSD_USER_ARCH_SYSARCH_H_ -#define BSD_USER_ARCH_SYSARCH_H_ - -#include "target_syscall.h" -#include "target_arch.h" - -static inline abi_long do_freebsd_arch_sysarch (CPUMIPSState *env,int op, -abi_ulong parms) -{ -int ret =0 ; - -switch (op) { -case TARGET_MIPS_SET_TLS : -target_cpu_set_tls (env, parms); -break ; - -case TARGET_MIPS_GET_TLS : -if (put_user (target_cpu_get_tls (env), parms, abi_ulong)) { - ret = -TARGET_EFAULT ; - } -break ; - -default : - ret = -TARGET_EINVAL ; -break ; - } - -return ret; -} - -static inline void do_freebsd_arch_print_sysarch ( -const struct syscallname *name,abi_long arg1,abi_long arg2, -abi_long arg3,abi_long arg4,abi_long arg5,abi_long arg6) -{ - -switch (arg1) { -case TARGET_MIPS_SET_TLS : -gemu_log ("%s(SET_TLS, 0x" TARGET_ABI_FMT_lx")" , name->name, arg2); -break ; - -case TARGET_MIPS_GET_TLS : -gemu_log ("%s(GET_TLS, 0x" TARGET_ABI_FMT_lx")" , name->name, arg2); -break ; - -default : -gemu_log ("UNKNOWN OP: %d, " TARGET_ABI_FMT_lx")" , (int )arg1, arg2); - } -} - -#endif /*!BSD_USER_ARCH_SYSARCH_H_ */
bsd-user/mips/target_syscall.h deleted +0 -52
52 lines not on this page · raw message
bsd-user/mips64/target_arch_sysarch.h deleted +0 -69
69 lines not on this page · raw message
bsd-user/mips64/target_syscall.h deleted +0 -53
53 lines not on this page · raw message
Signature · 1 line
2.33.0
Re: [PATCH v4 01/36] bsd-user/mips*: Remove
Quoted 11 lines · Warner Losh
FreeBSD has dropped support for mips starting with FreeBSD 14. mips support has been removed from the bsd-user fork because updating it for new signal requirements. Remove it here since it is a distraction.
Signed-off-by Warner Losh<[email protected]>--- bsd-user/mips/target_arch_sysarch.h | 69 --------------------------- bsd-user/mips/target_syscall.h | 52 -------------------- bsd-user/mips64/target_arch_sysarch.h | 69 --------------------------- bsd-user/mips64/target_syscall.h | 53 -------------------- 4 files changed, 243 deletions(-)
Quoted 4 lines
delete mode 100644
bsd-user/mips/target_arch_sysarch.hdelete mode 100644bsd-user/mips/target_syscall.hdelete mode 100644bsd-user/mips64/target_arch_sysarch.hdelete mode 100644bsd-user/mips64/target_syscall.h
I'm somewhat surprised that sys/mips/mips still exists on the main branch? But anyway,
r~
Re: [PATCH v4 01/36] bsd-user/mips*: Remove
Quoted 17 lines · Richard Henderson
Quoted 11 lines · Warner Losh
FreeBSD has dropped support for mips starting with FreeBSD 14. mips support has been removed from the bsd-user fork because updating it for new signal requirements. Remove it here since it is a distraction.
Signed-off-by Warner Losh<[email protected]>--- bsd-user/mips/target_arch_sysarch.h | 69 --------------------------- bsd-user/mips/target_syscall.h | 52 -------------------- bsd-user/mips64/target_arch_sysarch.h | 69 --------------------------- bsd-user/mips64/target_syscall.h | 53 -------------------- 4 files changed, 243 deletions(-)Quoted 4 lines
delete mode 100644
bsd-user/mips/target_arch_sysarch.hdelete mode 100644bsd-user/mips/target_syscall.hdelete mode 100644bsd-user/mips64/target_arch_sysarch.hdelete mode 100644bsd-user/mips64/target_syscall.h
Quoted 3 lines
I'm somewhat surprised that sys/mips/mips still exists on the main branch? But anyway,
It's slated for removal here within the coming month or two-
Warner Losh
Acked-by Richard HendersonRe: [PATCH v4 01/36] bsd-user/mips*: Remove
In reply to Richard HendersonQuoted 16 lines · Richard Henderson
Quoted 11 lines · Warner Losh
FreeBSD has dropped support for mips starting with FreeBSD 14. mips support has been removed from the bsd-user fork because updating it for new signal requirements. Remove it here since it is a distraction.
Signed-off-by Warner Losh<[email protected]>--- bsd-user/mips/target_arch_sysarch.h | 69 --------------------------- bsd-user/mips/target_syscall.h | 52 -------------------- bsd-user/mips64/target_arch_sysarch.h | 69 --------------------------- bsd-user/mips64/target_syscall.h | 53 -------------------- 4 files changed, 243 deletions(-)Quoted 4 lines
delete mode 100644
bsd-user/mips/target_arch_sysarch.hdelete mode 100644bsd-user/mips/target_syscall.hdelete mode 100644bsd-user/mips64/target_arch_sysarch.hdelete mode 100644bsd-user/mips64/target_syscall.h
Quoted 3 lines
I'm somewhat surprised that sys/mips/mips still exists on the main branch? But anyway,
It's a long story, but it's been talked about for several years now. It was retained
in the tree 18 months ago when it was last discussed to allow a large customer
to migrate to from doing their research on MIPS to arm and riscv. I have a branch
in my repo locally to remove it and hope to post the review in the coming days.
If things go well, it will be gone by the end of the month. I'd planned on keeping
mips on in the bsd-user fork until we hit a point when it was too much work to
keep it going, but that time came much sooner than I expected.
Quoted 1 line
Thanks!
Warner
Quoted 3 lines
r~
PATCH v4 2/36 bsd-user/freebsd: Create common target_os_ucontext.h file
In reply to Warner LoshFreeBSD has a MI ucontext structure that contains the MD mcontext machine state and other things that are machine independent. Create an include file for all the ucontext stuff. It needs to be included in the arch specific files after target_mcontext is defined. This is largely copied from sys/_ucontext.h with the comments about layout removed because we don't support ancient FreeBSD binaries.
--- bsd-user/freebsd/target_os_signal.h | 3 --- bsd-user/freebsd/target_os_ucontext.h | 35 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 bsd-user/freebsd/target_os_ucontext.h
bsd-user/freebsd/target_os_signal.h +0 -3
@@ -1,9 +1,6 @@#ifndef _TARGET_OS_SIGNAL_H_#define _TARGET_OS_SIGNAL_H_ -/* FreeBSD's sys/ucontext.h defines this */ -#define TARGET_MC_GET_CLEAR_RET 0x0001 -#include "target_os_siginfo.h" #include "target_arch_signal.h"
bsd-user/freebsd/target_os_ucontext.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* FreeBSD has a common ucontext definition for all architectures. +* +* Copyright 2021 Warner Losh <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause +*/ +#ifndef TARGET_OS_UCONTEXT_H +#define TARGET_OS_UCONTEXT_H + +/* +* Defines the common bits for all of FreeBSD's architectures. Has to be +* included AFTER the MD target_mcontext_t is defined, however, so can't +* be in the grab-bag that is target_os_signal.h. +*/ + +/* See FreeBSD's sys/ucontext.h */ +#define TARGET_MC_GET_CLEAR_RET 0x0001 + +/* FreeBSD's sys/_ucontext.h structures */ +typedef struct target_ucontext { +target_sigset_t uc_sigmask; +target_mcontext_t uc_mcontext; +abi_ulong uc_link; +target_stack_t uc_stack; +int32_t uc_flags; +int32_t __spare__[4 ]; +}target_ucontext_t ; + +#ifdef TARGET_MCONTEXT_SIZE +G_STATIC_ASSERT (TARGET_MCONTEXT_SIZE ==sizeof (target_mcontext_t)); +G_STATIC_ASSERT (TARGET_UCONTEXT_SIZE ==sizeof (target_ucontext_t)); +#endif /* TARGET_MCONTEXT_SIZE */ + +#endif /* TARGET_OS_UCONTEXT_H */
Signature · 1 line
2.33.0
Re: [PATCH v4 02/36] bsd-user/freebsd: Create common target_os_ucontext.h file
Quoted 7 lines · Warner Losh
FreeBSD has a MI ucontext structure that contains the MD mcontext machine state and other things that are machine independent. Create an include file for all the ucontext stuff. It needs to be included in the arch specific files after
target_mcontextis defined. This is largely copied fromsys/_ucontext.hwith the comments about layout removed because we don't support ancient FreeBSD binaries.
Quoted 6 lines
Signed-off-by Warner Losh <[email protected]>--- bsd-user/freebsd/target_os_signal.h | 3 --- bsd-user/freebsd/target_os_ucontext.h | 35 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-)create mode 100644
bsd-user/freebsd/target_os_ucontext.h
r~
PATCH v4 3/36 bsd-user: create a per-arch signal.c file
In reply to Warner LoshCreate a place-holder signal.c file for each of the architectures that are currently built. In the future, some code that's currently inlined in target_arch_signal.h will live here.
--- bsd-user/i386/signal.c | 1 + bsd-user/x86_64/signal.c | 1 + meson.build | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 bsd-user/i386/signal.c create mode 100644 bsd-user/x86_64/signal.c
bsd-user/i386/signal.c new file +1 -0
@@ -0,0 +1 @@ +/* Placeholder for signal.c */
bsd-user/x86_64/signal.c new file +1 -0
@@ -0,0 +1 @@ +/* Placeholder for signal.c */
meson.build +1 -1
@@ -2888,7 +2888,7 @@ foreach target : target_dirs base_dir = 'bsd-user' target_inc += include_directories('bsd-user/' / targetos) dir = base_dir / abi - arch_srcs += files(dir / 'target_arch_cpu.c') + arch_srcs += files(dir / 'signal.c', dir / 'target_arch_cpu.c') endif target_inc += include_directories( base_dir,
Signature · 1 line
2.33.0
Re: [PATCH v4 03/36] bsd-user: create a per-arch signal.c file
Quoted 4 lines · Warner Losh
Create a place-holder
signal.cfile for each of the architectures that are currently built. In the future, some code that's currently inlined intarget_arch_signal.hwill live here.
Quoted 8 lines
Signed-off-by Warner Losh <[email protected]>--- bsd-user/i386/signal.c | 1 + bsd-user/x86_64/signal.c | 1 + meson.build | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-)create mode 100644
bsd-user/i386/signal.c
create mode 100644bsd-user/x86_64/signal.c
r~
PATCH v4 4/36 bsd-user/i386/target_arch_signal.h: Remove target_sigcontext
In reply to Warner LoshIn FreeBSD, sigcontext was retired in favor of ucontext/mcontext. Remove vestigial target_sigcontext.
--- bsd-user/i386/target_arch_signal.h | 4 ---- 1 file changed, 4 deletions(-)
bsd-user/i386/target_arch_signal.h +0 -4
@@ -27,10 +27,6 @@#define TARGET_MINSIGSTKSZ (512 * 4)/* min sig stack size */ #define TARGET_SIGSTKSZ (MINSIGSTKSZ + 32768)/* recommended size */ -struct target_sigcontext { -/* to be added */ -}; -typedef struct target_mcontext { }target_mcontext_t ;
Signature · 1 line
2.33.0
PATCH v4 5/36 bsd-user/i386/target_arch_signal.h: use new target_os_ucontext.h
In reply to Warner Losh--- bsd-user/i386/target_arch_signal.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
bsd-user/i386/target_arch_signal.h +1 -8
@@ -30,14 +30,7 @@typedef struct target_mcontext { }target_mcontext_t ; -typedef struct target_ucontext { -target_sigset_t uc_sigmask; -target_mcontext_t uc_mcontext; -abi_ulong uc_link; -target_stack_t uc_stack; -int32_t uc_flags; -int32_t __spare__[4 ]; -}target_ucontext_t ; +#include "target_os_ucontext.h" struct target_sigframe {abi_ulong sf_signum;
Signature · 1 line
2.33.0
PATCH v4 6/36 bsd-user/i386/target_arch_signal.h: Update mcontext_t to match FreeBSD
In reply to Warner LoshFill in target_mcontext_t to match the FreeBSD mcontex_t. Also tag the current size of mcontext and ucontext to enable size checking for i386.
--- bsd-user/i386/target_arch_signal.h | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
bsd-user/i386/target_arch_signal.h +46 -0
@@ -28,8 +28,54 @@#define TARGET_SIGSTKSZ (MINSIGSTKSZ + 32768)/* recommended size */ typedef struct target_mcontext { +abi_ulong mc_onstack;/* XXX - sigcontext compat. */ +abi_ulong mc_gs;/* machine state (struct trapframe) */ +abi_ulong mc_fs; +abi_ulong mc_es; +abi_ulong mc_ds; +abi_ulong mc_edi; +abi_ulong mc_esi; +abi_ulong mc_ebp; +abi_ulong mc_isp; +abi_ulong mc_ebx; +abi_ulong mc_edx; +abi_ulong mc_ecx; +abi_ulong mc_eax; +abi_ulong mc_trapno; +abi_ulong mc_err; +abi_ulong mc_eip; +abi_ulong mc_cs; +abi_ulong mc_eflags; +abi_ulong mc_esp; +abi_ulong mc_ss; + +int32_t mc_len;/* sizeof(mcontext_t) */ +#define _MC_FPFMT_NODEV 0x10000/* device not present or configured */ +#define _MC_FPFMT_387 0x10001 +#define _MC_FPFMT_XMM 0x10002 +int32_t mc_fpformat; +#define _MC_FPOWNED_NONE 0x20000/* FP state not used */ +#define _MC_FPOWNED_FPU 0x20001/* FP state came from FPU */ +#define _MC_FPOWNED_PCB 0x20002/* FP state came from PCB */ +int32_t mc_ownedfp; +abi_ulong mc_flags; +/* +* See <machine/npx.h> for the internals of mc_fpstate[]. +*/ +int32_t mc_fpstate[128 ]__aligned(16) ; + +abi_ulong mc_fsbase; +abi_ulong mc_gsbase; + +abi_ulong mc_xfpustate; +abi_ulong mc_xfpustate_len; + +int32_t mc_spare2[4 ]; }target_mcontext_t ; +#define TARGET_MCONTEXT_SIZE 640 +#define TARGET_UCONTEXT_SIZE 704 +#include "target_os_ucontext.h" struct target_sigframe {
Signature · 1 line
2.33.0
Re: [PATCH v4 06/36] bsd-user/i386/target_arch_signal.h: Update mcontext_t to match FreeBSD
Quoted 7 lines · Warner Losh
Fill in
target_mcontext_tto match the FreeBSDmcontex_t. Also tag the current size of mcontext and ucontext to enable size checking for i386.Signed-off-by Warner Losh<[email protected]>--- bsd-user/i386/target_arch_signal.h | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
r~
PATCH v4 7/36 bsd-user/i386: Move the inlines into signal.c
In reply to Warner LoshMove the (now stubbed out) inlines into bsd-user/i386/signal.c.
--- bsd-user/i386/signal.c | 56 +++++++++++++++++++++++++++++- bsd-user/i386/target_arch_signal.h | 43 +++++------------------ 2 files changed, 63 insertions(+), 36 deletions(-)
bsd-user/i386/signal.c +55 -1
@@ -1 +1,55 @@ -/* Placeholder for signal.c */ +/* +* i386 dependent signal definitions +* +* Copyright (c) 2013 Stacey D. Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu.h" + +/* +* Compare to i386/i386/machdep.c sendsig() +* Assumes that target stack frame memory is locked. +*/ +abi_long set_sigtramp_args (CPUX86State *env,int sig, +struct target_sigframe *frame, +abi_ulong frame_addr, +struct target_sigaction *ka) +{ +/* XXX return -TARGET_EOPNOTSUPP; */ +return 0 ; +} + +/* Compare to i386/i386/machdep.c get_mcontext() */ +abi_long get_mcontext (CPUX86State *regs,target_mcontext_t *mcp,int flags) +{ +/* XXX */ +return -TARGET_EOPNOTSUPP ; +} + +/* Compare to i386/i386/machdep.c set_mcontext() */ +abi_long set_mcontext (CPUX86State *regs,target_mcontext_t *mcp,int srflag) +{ +/* XXX */ +return -TARGET_EOPNOTSUPP ; +} + +abi_long get_ucontext_sigreturn (CPUX86State *regs,abi_ulong target_sf, +abi_ulong *target_uc) +{ +/* XXX */ + *target_uc =0 ; +return -TARGET_EOPNOTSUPP ; +}
bsd-user/i386/target_arch_signal.h +8 -35
48 lines not on this page · raw message
Signature · 1 line
2.33.0
Re: [PATCH v4 07/36] bsd-user/i386: Move the inlines into signal.c
bsd-user/i386/target_arch_signal.h struct target_sigframe { · line 100
Quoted 10 lines · Warner Losh
bsd-user/i386/target_arch_signal.h +8
-0+abi_long set_sigtramp_args (CPUX86State *env,int sig, +struct target_sigframe *frame, +abi_ulong frame_addr, +struct target_sigaction *ka); +abi_long get_mcontext (CPUX86State *regs,target_mcontext_t *mcp,int flags); +abi_long set_mcontext (CPUX86State *regs,target_mcontext_t *mcp,int srflag); +abi_long get_ucontext_sigreturn (CPUX86State *regs,abi_ulong target_sf, +abi_ulong *target_uc);#endif /* TARGET_ARCH_SIGNAL_H */
You should use the CPUArchState typedef, instead of CPUX86State directly, and place these declarations in a shared header.
Otherwise,
r~
Re: [PATCH v4 07/36] bsd-user/i386: Move the inlines into signal.c
Quoted 9 lines · Richard Henderson
bsd-user/i386/target_arch_signal.h struct target_sigframe {
Quoted 5 lines · Warner Losh
bsd-user/i386/target_arch_signal.h +5
-0+abi_long set_sigtramp_args (CPUX86State *env,int sig, +struct target_sigframe *frame, +abi_ulong frame_addr, +struct target_sigaction *ka); +abi_long get_mcontext(CPUX86State *regs, target_mcontext_t *mcp, intflags);
Quoted 1 line
+abi_long set_mcontext(CPUX86State *regs,
target_mcontext_t*mcp, intsrflag);
Quoted 9 lines
bsd-user/i386/target_arch_signal.h struct target_sigframe { · line 100
Quoted 4 lines
bsd-user/i386/target_arch_signal.h +2
-0+abi_long get_ucontext_sigreturn (CPUX86State *regs,abi_ulong target_sf, +abi_ulong *target_uc);#endif /* TARGET_ARCH_SIGNAL_H */ You should use the CPUArchState typedef, instead of CPUX86State directly, and place these
declarations in a shared header.
Will do! Thanks!
Quoted 3 lines
Otherwise,
Reviewed-by Richard Henderson <[email protected]>
Re: [PATCH v4 07/36] bsd-user/i386: Move the inlines into signal.c
Quoted 17 lines · Warner Losh
Quoted 12 lines · Richard Henderson
bsd-user/i386/target_arch_signal.h struct target_sigframe {
Quoted 5 lines · Warner Losh
bsd-user/i386/target_arch_signal.h +5
-0+abi_long set_sigtramp_args (CPUX86State *env,int sig, +struct target_sigframe *frame, +abi_ulong frame_addr, +struct target_sigaction *ka); +abi_long get_mcontext(CPUX86State *regs, target_mcontext_t *mcp, intflags);
Quoted 1 line
+abi_long set_mcontext(CPUX86State *regs,
target_mcontext_t*mcp, intsrflag);
Quoted 3 lines
bsd-user/i386/target_arch_signal.h +2
-0+abi_long get_ucontext_sigreturn (CPUX86State *regs,abi_ulong target_sf, +abi_ulong *target_uc);
Quoted 9 lines
Quoted 6 lines
Quoted 1 line
#endif /* TARGET_ARCH_SIGNAL_H */You should use the CPUArchState typedef, instead of CPUX86State directly, and place these
declarations in a shared header.Will do! Thanks!
FYI: I'm going to add a change that moves this to target_os_ucommon.h after I've
made i386 and x86_64 use the functions. That way all revisions will still compile
and I don't have to deal with the 'half-way' state. I'll then tweak the arm commits
later in the series to not add them arm specific prototypes to the target_arch_signal.h
file.
Warner
Quoted 6 lines
Quoted 5 lines
Otherwise,
Reviewed-by Richard Henderson <[email protected]>
PATCH v4 8/36 bsd-user/x86_64/target_arch_signal.h: Remove target_sigcontext
In reply to Warner LoshIn FreeBSD, sigcontext was retired in favor of ucontext/mcontext. Remove vestigial target_sigcontext.
--- bsd-user/x86_64/target_arch_signal.h | 4 ---- 1 file changed, 4 deletions(-)
bsd-user/x86_64/target_arch_signal.h +0 -4
@@ -27,10 +27,6 @@#define TARGET_MINSIGSTKSZ (512 * 4)/* min sig stack size */ #define TARGET_SIGSTKSZ (MINSIGSTKSZ + 32768)/* recommended size */ -struct target_sigcontext { -/* to be added */ -}; -typedef struct target_mcontext { }target_mcontext_t ;
Signature · 1 line
2.33.0
PATCH v4 9/36 bsd-user/x86_64/target_arch_signal.h: use new target_os_ucontext.h
In reply to Warner Losh--- bsd-user/x86_64/target_arch_signal.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
bsd-user/x86_64/target_arch_signal.h +1 -8
@@ -30,14 +30,7 @@typedef struct target_mcontext { }target_mcontext_t ; -typedef struct target_ucontext { -target_sigset_t uc_sigmask; -target_mcontext_t uc_mcontext; -abi_ulong uc_link; -target_stack_t uc_stack; -int32_t uc_flags; -int32_t __spare__[4 ]; -}target_ucontext_t ; +#include "target_os_ucontext.h" struct target_sigframe {abi_ulong sf_signum;
Signature · 1 line
2.33.0
PATCH v4 10/36 bsd-user/x86_64/target_arch_signal.h: Fill in mcontext_t
In reply to Warner LoshFill in target_mcontext match the FreeBSD mcontext_t structure. Also define the size correctly.
--- bsd-user/x86_64/target_arch_signal.h | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
bsd-user/x86_64/target_arch_signal.h +54 -0
@@ -28,8 +28,62 @@#define TARGET_SIGSTKSZ (MINSIGSTKSZ + 32768)/* recommended size */ typedef struct target_mcontext { +abi_ulong mc_onstack;/* XXX - sigcontext compat. */ +abi_ulong mc_rdi;/* machine state (struct trapframe) */ +abi_ulong mc_rsi; +abi_ulong mc_rdx; +abi_ulong mc_rcx; +abi_ulong mc_r8; +abi_ulong mc_r9; +abi_ulong mc_rax; +abi_ulong mc_rbx; +abi_ulong mc_rbp; +abi_ulong mc_r10; +abi_ulong mc_r11; +abi_ulong mc_r12; +abi_ulong mc_r13; +abi_ulong mc_r14; +abi_ulong mc_r15; +uint32_t mc_trapno; +uint16_t mc_fs; +uint16_t mc_gs; +abi_ulong mc_addr; +uint32_t mc_flags; +uint16_t mc_es; +uint16_t mc_ds; +abi_ulong mc_err; +abi_ulong mc_rip; +abi_ulong mc_cs; +abi_ulong mc_rflags; +abi_ulong mc_rsp; +abi_ulong mc_ss; + +abi_long mc_len;/* sizeof(mcontext_t) */ + +#define _MC_FPFMT_NODEV 0x10000/* device not present or configured */ +#define _MC_FPFMT_XMM 0x10002 +abi_long mc_fpformat; +#define _MC_FPOWNED_NONE 0x20000/* FP state not used */ +#define _MC_FPOWNED_FPU 0x20001/* FP state came from FPU */ +#define _MC_FPOWNED_PCB 0x20002/* FP state came from PCB */ +abi_long mc_ownedfp; +/* +* See <machine/fpu.h> for the internals of mc_fpstate[]. +*/ +abi_long mc_fpstate[64 ]__aligned(16) ; + +abi_ulong mc_fsbase; +abi_ulong mc_gsbase; + +abi_ulong mc_xfpustate; +abi_ulong mc_xfpustate_len; + +abi_long mc_spare[4 ]; }target_mcontext_t ; +#define TARGET_MCONTEXT_SIZE 800 +#define TARGET_UCONTEXT_SIZE 880 +#include "target_os_ucontext.h" struct target_sigframe {
Signature · 1 line
2.33.0
Re: [PATCH v4 10/36] bsd-user/x86_64/target_arch_signal.h: Fill in mcontext_t
Quoted 7 lines · Warner Losh
Fill in
target_mcontextmatch the FreeBSDmcontext_tstructure. Also define the size correctly.Signed-off-by Warner Losh<[email protected]>--- bsd-user/x86_64/target_arch_signal.h | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
r~
PATCH v4 11/36 bsd-user/x86_64: Move functions into signal.c
In reply to Warner LoshMove the current inline functions into sigal.c. This will increate the flexibility of implementation in the future.
--- bsd-user/x86_64/signal.c | 56 +++++++++++++++++++++++++++- bsd-user/x86_64/target_arch_signal.h | 43 ++++----------------- 2 files changed, 63 insertions(+), 36 deletions(-)
bsd-user/x86_64/signal.c +55 -1
@@ -1 +1,55 @@ -/* Placeholder for signal.c */ +/* +* x86_64 signal definitions +* +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu.h" + +/* +* Compare to amd64/amd64/machdep.c sendsig() +* Assumes that target stack frame memory is locked. +*/ +abi_long set_sigtramp_args (CPUX86State *regs, +int sig,struct target_sigframe *frame,abi_ulong frame_addr, +struct target_sigaction *ka) +{ +/* XXX return -TARGET_EOPNOTSUPP; */ +return 0 ; +} + +/* Compare to amd64/amd64/machdep.c get_mcontext() */ +abi_long get_mcontext (CPUX86State *regs, +target_mcontext_t *mcp,int flags) +{ +/* XXX */ +return -TARGET_EOPNOTSUPP ; +} + +/* Compare to amd64/amd64/machdep.c set_mcontext() */ +abi_long set_mcontext (CPUX86State *regs, +target_mcontext_t *mcp,int srflag) +{ +/* XXX */ +return -TARGET_EOPNOTSUPP ; +} + +abi_long get_ucontext_sigreturn (CPUX86State *regs, +abi_ulong target_sf,abi_ulong *target_uc) +{ +/* XXX */ + *target_uc =0 ; +return -TARGET_EOPNOTSUPP ; +}
bsd-user/x86_64/target_arch_signal.h +8 -35
48 lines not on this page · raw message
Signature · 1 line
2.33.0
Re: [PATCH v4 11/36] bsd-user/x86_64: Move functions into signal.c
Quoted 8 lines · Warner Losh
Move the current inline functions into
sigal.c. This will increate the flexibility of implementation in the future.Signed-off-by Warner Losh<[email protected]>--- bsd-user/x86_64/signal.c | 56 +++++++++++++++++++++++++++- bsd-user/x86_64/target_arch_signal.h | 43 ++++----------------- 2 files changed, 63 insertions(+), 36 deletions(-)
bsd-user/x86_64/target_arch_signal.h struct target_sigframe { · line 106
Quoted 8 lines
bsd-user/x86_64/target_arch_signal.h +8
-0+abi_long set_sigtramp_args (CPUX86State *env,int sig, +struct target_sigframe *frame, +abi_ulong frame_addr, +struct target_sigaction *ka); +abi_long get_mcontext (CPUX86State *regs,target_mcontext_t *mcp,int flags); +abi_long set_mcontext (CPUX86State *regs,target_mcontext_t *mcp,int srflag); +abi_long get_ucontext_sigreturn (CPUX86State *regs,abi_ulong target_sf, +abi_ulong *target_uc);
with of course the same comment as for i386.
r~
Re: [PATCH v4 11/36] bsd-user/x86_64: Move functions into signal.c
Quoted 19 lines · Richard Henderson
Quoted 8 lines · Warner Losh
Move the current inline functions into
sigal.c. This will increate the flexibility of implementation in the future.Signed-off-by Warner Losh<[email protected]>--- bsd-user/x86_64/signal.c | 56 +++++++++++++++++++++++++++- bsd-user/x86_64/target_arch_signal.h | 43 ++++----------------- 2 files changed, 63 insertions(+), 36 deletions(-)Reviewed-by Richard Henderson <[email protected]>bsd-user/x86_64/target_arch_signal.h struct target_sigframe {
Quoted 5 lines
bsd-user/x86_64/target_arch_signal.h +5
-0+abi_long set_sigtramp_args (CPUX86State *env,int sig, +struct target_sigframe *frame, +abi_ulong frame_addr, +struct target_sigaction *ka); +abi_long get_mcontext(CPUX86State *regs, target_mcontext_t *mcp, intflags);
Quoted 7 lines
Quoted 1 line
+abi_long set_mcontext(CPUX86State *regs,
target_mcontext_t*mcp, intsrflag);
bsd-user/x86_64/target_arch_signal.h struct target_sigframe { · line 106
Quoted 2 lines
bsd-user/x86_64/target_arch_signal.h +2
-0+abi_long get_ucontext_sigreturn (CPUX86State *regs,abi_ulong target_sf, +abi_ulong *target_uc);with of course the same comment as for i386.
of course... :)
Warner
PATCH v4 12/36 bsd-user/arm/target_arch_sysarch.h: Use consistent include guards
In reply to Warner LoshAs part of upstreaming, the include guards have been made more consistent. Update this file to use the new guards.
--- bsd-user/arm/target_arch_sysarch.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
bsd-user/arm/target_arch_sysarch.h +3 -3
@@ -17,8 +17,8 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef BSD_USER_ARCH_SYSARCH_H_ -#define BSD_USER_ARCH_SYSARCH_H_ +#ifndef _TARGET_ARCH_SYSARCH_H_ +#define _TARGET_ARCH_SYSARCH_H_#include "target_syscall.h" #include "target_arch.h"
@@ -75,4 +75,4 @@ static inline void do_freebsd_arch_print_sysarch( } } -#endif /*!BSD_USER_ARCH_SYSARCH_H_ */ +#endif /*!_TARGET_ARCH_SYSARCH_H_ */
Signature · 1 line
2.33.0
PATCH v4 13/36 bsd-user/arm/target_syscall.h: Add copyright and update name
In reply to Warner LoshThe preferred name for the 32-bit arm is now armv7. Update the name to reflect that. In addition, add Stacey's copyright to this file and update the include guards to the new convention.
--- bsd-user/arm/target_syscall.h | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
bsd-user/arm/target_syscall.h +23 -4
@@ -1,5 +1,24 @@ -#ifndef BSD_USER_ARCH_SYSCALL_H_ -#define BSD_USER_ARCH_SYSCALL_H_ +/* +* arm cpu system call stubs +* +* Copyright (c) 2013 Stacey D. Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _TARGET_ARCH_SYSCALL_H_ +#define _TARGET_ARCH_SYSCALL_H_ struct target_pt_regs { abi_long uregs[17];
@@ -31,6 +50,6 @@ struct target_pt_regs {#define TARGET_FREEBSD_ARM_GET_TP 3#define TARGET_HW_MACHINE "arm" -#define TARGET_HW_MACHINE_ARCH "armv6" +#define TARGET_HW_MACHINE_ARCH "armv7" -#endif /* !BSD_USER_ARCH_SYSCALL_H_ */ +#endif /* !_TARGET_ARCH_SYSCALL_H_ */
Signature · 1 line
2.33.0
PATCH v4 14/36 bsd-user/arm/target_arch_cpu.c: Target specific TLS routines
In reply to Warner LoshTarget specific TLS routines to get and set the TLS values.
--- bsd-user/arm/target_arch.h | 28 ++++++++++++++++++++++++ bsd-user/arm/target_arch_cpu.c | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 bsd-user/arm/target_arch.h create mode 100644 bsd-user/arm/target_arch_cpu.c
bsd-user/arm/target_arch.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* ARM 32-bit specific prototypes for bsd-user +* +* Copyright (c) 2013 Stacey D. Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _TARGET_ARCH_H_ +#define _TARGET_ARCH_H_ + +#include "qemu.h" + +void target_cpu_set_tls (CPUARMState *env,target_ulong newtls); +target_ulong target_cpu_get_tls (CPUARMState *env); + +#endif /* !_TARGET_ARCH_H_ */
bsd-user/arm/target_arch_cpu.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* arm cpu related code +* +* Copyright (c) 2013 Stacey D. Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ +#include "target_arch.h" + +void target_cpu_set_tls (CPUARMState *env,target_ulong newtls) +{ +if (access_secure_reg (env)) { + env->cp15.tpidrurw_s = newtls; + env->cp15.tpidruro_s = newtls; +return ; + } + + env->cp15.tpidr_el[0 ] = newtls; + env->cp15.tpidrro_el[0 ] = newtls; +} + +target_ulong target_cpu_get_tls (CPUARMState *env) +{ +if (access_secure_reg (env)) { +return env->cp15.tpidruro_s; + } +return env->cp15.tpidrro_el[0 ]; +}
Signature · 1 line
2.33.0
PATCH v4 15/36 bsd-user/arm/target_arch_cpu.h: CPU Loop definitions
In reply to Warner Loshtarget_arch_cpu.h is for CPU loop definitions. Create the file and define target_cpu_init and target_cpu_reset for arm.
--- bsd-user/arm/target_arch_cpu.h | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 bsd-user/arm/target_arch_cpu.h
bsd-user/arm/target_arch_cpu.h new file +43 -0
@@ -0,0 +1,43 @@ +/* +* arm cpu init and loop +* +* Copyright (c) 2013 Stacey D. Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _TARGET_ARCH_CPU_H_ +#define _TARGET_ARCH_CPU_H_ + +#include "target_arch.h" + +#define TARGET_DEFAULT_CPU_MODEL "any" + +static inline void target_cpu_init (CPUARMState *env, +struct target_pt_regs *regs) +{ +int i; + +cpsr_write (env, regs->uregs[16 ],CPSR_USER |CPSR_EXEC , + CPSRWriteByInstr); +for (i =0 ; i <16 ; i++) { + env->regs[i] = regs->uregs[i]; + } +} + +static inline void target_cpu_reset (CPUArchState *cpu) +{ +} + +#endif /* !_TARGET_ARCH_CPU_H */
Signature · 1 line
2.33.0
PATCH v4 16/36 bsd-user/arm/target_arch_cpu.h: Implement target_cpu_clone_regs
In reply to Warner LoshImplement target_cpu_clone_regs to clone the resister state on a fork.
--- bsd-user/arm/target_arch_cpu.h | 8 ++++++++ 1 file changed, 8 insertions(+)
bsd-user/arm/target_arch_cpu.h +8 -0
@@ -36,6 +36,14 @@ static inline void target_cpu_init(CPUARMState *env, } } +static inline void target_cpu_clone_regs (CPUARMState *env,target_ulong newsp) +{ +if (newsp) { + env->regs[13 ] = newsp; + } + env->regs[0 ] =0 ; +} +static inline void target_cpu_reset (CPUArchState *cpu) { }
Signature · 1 line
2.33.0
PATCH v4 17/36 bsd-user/arm/target_arch_cpu.h: Dummy target_cpu_loop implementation
In reply to Warner LoshAdd a boiler plate CPU loop that does nothing except return an error for all traps.
--- bsd-user/arm/target_arch_cpu.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
bsd-user/arm/target_arch_cpu.h +22 -0
@@ -36,6 +36,28 @@ static inline void target_cpu_init(CPUARMState *env, } } +static inline void target_cpu_loop (CPUARMState *env) +{ +int trapnr; +target_siginfo_t info; +CPUState *cs =env_cpu (env); + +for (;;) { +cpu_exec_start (cs); + trapnr =cpu_exec (cs); +cpu_exec_end (cs); +process_queued_cpu_work (cs); +switch (trapnr) { +default : +fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , + trapnr); +cpu_dump_state (cs, stderr,0 ); +abort (); + }/* switch() */ +process_pending_signals (env); + }/* for (;;) */ +} +static inline void target_cpu_clone_regs (CPUARMState *env,target_ulong newsp) {if (newsp) {
Signature · 1 line
2.33.0
PATCH v4 18/36 bsd-user/arm/target_arch_cpu.h: Implement trivial EXCP exceptions
In reply to Warner LoshImplement EXCP_UDEF, EXCP_DEBUG, EXCP_INTERRUPT, EXCP_ATOMIC and EXCP_YIELD. The first two generate a signal to the emulated binary. EXCP_ATOMIC handles atomic operations. The remainder are fancy nops.
--- bsd-user/arm/target_arch_cpu.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
bsd-user/arm/target_arch_cpu.h +33 -0
@@ -48,6 +48,39 @@ static inline void target_cpu_loop(CPUARMState *env)cpu_exec_end (cs);process_queued_cpu_work (cs);switch (trapnr) { +case EXCP_UDEF : + { +/* See arm/arm/undefined.c undefinedinstruction(); */ + info.si_addr = env->regs[15 ]; + +/* illegal instruction */ + info.si_signo =TARGET_SIGILL ; + info.si_errno =0 ; + info.si_code =TARGET_ILL_ILLOPC ; +queue_signal (env, info.si_signo, &info); + +/* TODO: What about instruction emulation? */ + } +break ; +case EXCP_INTERRUPT : +/* just indicate that signals should be handled asap */ +break ; +case EXCP_DEBUG : + { + + info.si_signo =TARGET_SIGTRAP ; + info.si_errno =0 ; + info.si_code =TARGET_TRAP_BRKPT ; + info.si_addr = env->exception.vaddress; +queue_signal (env, info.si_signo, &info); + } +break ; +case EXCP_ATOMIC : +cpu_exec_step_atomic (cs); +break ; +case EXCP_YIELD : +/* nothing to do here for user-mode, just resume guest code */ +break ;default :fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);
Signature · 1 line
2.33.0
PATCH v4 19/36 bsd-user/arm/target_arch_cpu.h: Implement data abort exceptions
In reply to Warner LoshImplement EXCP_PREFETCH_ABORT AND EXCP_DATA_ABORT. Both of these data exceptions cause a SIGSEGV.
--- bsd-user/arm/target_arch_cpu.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
bsd-user/arm/target_arch_cpu.h +11 -0
@@ -65,6 +65,17 @@ static inline void target_cpu_loop(CPUARMState *env)case EXCP_INTERRUPT :/* just indicate that signals should be handled asap */ break ; +case EXCP_PREFETCH_ABORT : +/* See arm/arm/trap.c prefetch_abort_handler() */ +case EXCP_DATA_ABORT : +/* See arm/arm/trap.c data_abort_handler() */ + info.si_signo =TARGET_SIGSEGV ; + info.si_errno =0 ; +/* XXX: check env->error_code */ + info.si_code =0 ; + info.si_addr = env->exception.vaddress; +queue_signal (env, info.si_signo, &info); +break ;case EXCP_DEBUG : {
Signature · 1 line
2.33.0
PATCH v4 20/36 bsd-user/arm/target_arch_cpu.h: Implement system call dispatch
In reply to Warner LoshImplement the system call dispatch. This implements all three kinds of system call: direct and the two indirect variants. It handles all the special cases for thumb as well.
--- bsd-user/arm/target_arch_cpu.h | 94 ++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+)
bsd-user/arm/target_arch_cpu.h +94 -0
@@ -40,6 +40,7 @@ static inline void target_cpu_loop(CPUARMState *env) {int trapnr;target_siginfo_t info; +unsigned int n;CPUState *cs =env_cpu (env);for (;;) {
@@ -62,6 +63,99 @@ static inline void target_cpu_loop(CPUARMState *env)/* TODO: What about instruction emulation? */ }break ; +case EXCP_SWI : +case EXCP_BKPT : + { +/* +* system call +* See arm/arm/trap.c cpu_fetch_syscall_args() +*/ +if (trapnr ==EXCP_BKPT ) { +if (env->thumb) { + env->regs[15 ] +=2 ; + }else { + env->regs[15 ] +=4 ; + } + } + n = env->regs[7 ]; +if (bsd_type == target_freebsd) { +int ret; +abi_ulong params =get_sp_from_cpustate (env); +int32_t syscall_nr = n; +int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; + +/* See arm/arm/trap.c cpu_fetch_syscall_args() */ +if (syscall_nr == TARGET_FREEBSD_NR_syscall) { + syscall_nr = env->regs[0 ]; + arg1 = env->regs[1 ]; + arg2 = env->regs[2 ]; + arg3 = env->regs[3 ]; +get_user_s32 (arg4, params); + params +=sizeof (int32_t ); +get_user_s32 (arg5, params); + params +=sizeof (int32_t ); +get_user_s32 (arg6, params); + params +=sizeof (int32_t ); +get_user_s32 (arg7, params); + arg8 =0 ; + }else if (syscall_nr == TARGET_FREEBSD_NR___syscall) { + syscall_nr = env->regs[0 ]; + arg1 = env->regs[2 ]; + arg2 = env->regs[3 ]; +get_user_s32 (arg3, params); + params +=sizeof (int32_t ); +get_user_s32 (arg4, params); + params +=sizeof (int32_t ); +get_user_s32 (arg5, params); + params +=sizeof (int32_t ); +get_user_s32 (arg6, params); + arg7 =0 ; + arg8 =0 ; + }else { + arg1 = env->regs[0 ]; + arg2 = env->regs[1 ]; + arg3 = env->regs[2 ]; + arg4 = env->regs[3 ]; +get_user_s32 (arg5, params); + params +=sizeof (int32_t ); +get_user_s32 (arg6, params); + params +=sizeof (int32_t ); +get_user_s32 (arg7, params); + params +=sizeof (int32_t ); +get_user_s32 (arg8, params); + } + ret =do_freebsd_syscall (env, syscall_nr, arg1, arg2, arg3, + arg4, arg5, arg6, arg7, arg8); +/* +* Compare to arm/arm/vm_machdep.c +* cpu_set_syscall_retval() +*/ +if (-TARGET_EJUSTRETURN == ret) { +/* +* Returning from a successful sigreturn syscall. +* Avoid clobbering register state. +*/ +break ; + } +if (-TARGET_ERESTART == ret) { + env->regs[15 ] -= env->thumb ?2 :4 ; +break ; + } +if ((unsigned int )ret >= (unsigned int )(-515 )) { + ret = -ret; +cpsr_write (env,CPSR_C ,CPSR_C , CPSRWriteByInstr); + env->regs[0 ] = ret; + }else { +cpsr_write (env,0 ,CPSR_C , CPSRWriteByInstr); + env->regs[0 ] = ret;/* XXX need to handle lseek()? */ +/* env->regs[1] = 0; */ + } + }else { +fprintf (stderr,"qemu: bsd_type (= %d) syscall " +"not supported\n" , bsd_type); + } + } +break ;case EXCP_INTERRUPT :/* just indicate that signals should be handled asap */ break ;
Signature · 1 line
2.33.0
PATCH v4 21/36 bsd-user/arm/target_arch_reg.h: Implement core dump register copying
In reply to Warner LoshImplement the register copying routines to extract registers from the cpu for core dump generation.
--- bsd-user/arm/target_arch_reg.h | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 bsd-user/arm/target_arch_reg.h
bsd-user/arm/target_arch_reg.h new file +60 -0
@@ -0,0 +1,60 @@ +/* +* FreeBSD arm register structures +* +* Copyright (c) 2015 Stacey Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _TARGET_ARCH_REG_H_ +#define _TARGET_ARCH_REG_H_ + +/* See sys/arm/include/reg.h */ +typedef struct target_reg { +uint32_t r[13 ]; +uint32_t r_sp; +uint32_t r_lr; +uint32_t r_pc; +uint32_t r_cpsr; +}target_reg_t ; + +typedef struct target_fp_reg { +uint32_t fp_exponent; +uint32_t fp_mantissa_hi; +u_int32_t fp_mantissa_lo; +}target_fp_reg_t ; + +typedef struct target_fpreg { +uint32_t fpr_fpsr; +target_fp_reg_t fpr[8 ]; +}target_fpreg_t ; + +#define tswapreg (ptr) tswapal(ptr) + +static inline void target_copy_regs (target_reg_t *regs,const CPUARMState *env) +{ +int i; + +for (i =0 ; i <13 ; i++) { + regs->r[i] =tswapreg (env->regs[i +1 ]); + } + regs->r_sp =tswapreg (env->regs[13 ]); + regs->r_lr =tswapreg (env->regs[14 ]); + regs->r_pc =tswapreg (env->regs[15 ]); + regs->r_cpsr =tswapreg (cpsr_read ((CPUARMState *)env)); +} + +#undef tswapreg + +#endif /* !_TARGET_ARCH_REG_H_ */
Signature · 1 line
2.33.0
PATCH v4 22/36 bsd-user/arm/target_arch_vmparam.h: Parameters for arm address space
In reply to Warner LoshVarious parameters describing the layout of the ARM address space. In addition, define routines to get the stack pointer and to set the second return value.
--- bsd-user/arm/target_arch_vmparam.h | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 bsd-user/arm/target_arch_vmparam.h
bsd-user/arm/target_arch_vmparam.h new file +48 -0
@@ -0,0 +1,48 @@ +/* +* arm VM parameters definitions +* +* Copyright (c) 2013 Stacey D. Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef _TARGET_ARCH_VMPARAM_H_ +#define _TARGET_ARCH_VMPARAM_H_ + +#include "cpu.h" + +/* compare to sys/arm/include/vmparam.h */ +#define TARGET_MAXTSIZ (64 * MiB)/* max text size */ +#define TARGET_DFLDSIZ (128 * MiB)/* initial data size limit */ +#define TARGET_MAXDSIZ (512 * MiB)/* max data size */ +#define TARGET_DFLSSIZ (4 * MiB)/* initial stack size limit */ +#define TARGET_MAXSSIZ (64 * MiB)/* max stack size */ +#define TARGET_SGROWSIZ (128 * KiB)/* amount to grow stack */ + +#define TARGET_RESERVED_VA 0xf7000000 + +/* KERNBASE - 512 MB */ +#define TARGET_VM_MAXUSER_ADDRESS (0xc0000000 - (512 * MiB)) +#define TARGET_USRSTACK TARGET_VM_MAXUSER_ADDRESS + +static inline abi_ulong get_sp_from_cpustate (CPUARMState *state) +{ +return state->regs[13 ];/* sp */ +} + +static inline void set_second_rval (CPUARMState *state,abi_ulong retval2) +{ + state->regs[1 ] = retval2; +} + +#endif /* ! _TARGET_ARCH_VMPARAM_H_ */
Signature · 1 line
2.33.0
PATCH v4 23/36 bsd-user/arm/target_arch_sigtramp.h: Signal Trampoline for arm
In reply to Warner LoshCopy of the signal trampoline code for arm, as well as setup_sigtramp to write it to the stack.
--- bsd-user/arm/target_arch_sigtramp.h | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 bsd-user/arm/target_arch_sigtramp.h
bsd-user/arm/target_arch_sigtramp.h new file +49 -0
@@ -0,0 +1,49 @@ +/* +* arm sysarch() system call emulation +* +* Copyright (c) 2013 Stacey D. Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _TARGET_ARCH_SIGTRAMP_H_ +#define _TARGET_ARCH_SIGTRAMP_H_ + +/* Compare to arm/arm/locore.S ENTRY_NP(sigcode) */ +static inline abi_long setup_sigtramp (abi_ulong offset,unsigned sigf_uc, +unsigned sys_sigreturn) +{ +int i; +uint32_t sys_exit = TARGET_FREEBSD_NR_exit; +uint32_t sigtramp_code[] = { +/* 1 */ 0xE1A0000D ,/* mov r0, sp */ +/* 2 */ 0xE2800000 + sigf_uc,/* add r0, r0, #SIGF_UC */ +/* 3 */ 0xE59F700C ,/* ldr r7, [pc, #12] */ +/* 4 */ 0xEF000000 + sys_sigreturn,/* swi (SYS_sigreturn) */ +/* 5 */ 0xE59F7008 ,/* ldr r7, [pc, #8] */ +/* 6 */ 0xEF000000 + sys_exit,/* swi (SYS_exit)*/ +/* 7 */ 0xEAFFFFFA ,/* b . -16 */ +/* 8 */ sys_sigreturn, +/* 9 */ sys_exit + }; + +G_STATIC_ASSERT (sizeof (sigtramp_code) ==TARGET_SZSIGCODE ); + +for (i =0 ; i <9 ; i++) { +tswap32s (&sigtramp_code[i]); + } + +return memcpy_to_target (offset, sigtramp_code,TARGET_SZSIGCODE ); +} +#endif /* _TARGET_ARCH_SIGTRAMP_H_ */
Signature · 1 line
2.33.0
PATCH v4 24/36 bsd-user/arm/target_arch_thread.h: Routines to create and switch to a thread
In reply to Warner LoshImplement target_thread_init (to create a thread) and target_set_upcall (to switch to a thread) for arm.
--- bsd-user/arm/target_arch_thread.h | 82 +++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 bsd-user/arm/target_arch_thread.h
bsd-user/arm/target_arch_thread.h new file +82 -0
@@ -0,0 +1,82 @@ +/* +* arm thread support +* +* Copyright (c) 2013 Stacey D. Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef _TARGET_ARCH_THREAD_H_ +#define _TARGET_ARCH_THREAD_H_ + +/* Compare to arm/arm/vm_machdep.c cpu_set_upcall_kse() */ +static inline void target_thread_set_upcall (CPUARMState *env,abi_ulong entry, +abi_ulong arg,abi_ulong stack_base,abi_ulong stack_size) +{ +abi_ulong sp; + +/* +* Make sure the stack is properly aligned. +* arm/include/param.h (STACKLIGN() macro) +*/ + sp = (u_int)(stack_base + stack_size) & ~0x7 ; + +/* sp = stack base */ + env->regs[13 ] = sp; +/* pc = start function entry */ + env->regs[15 ] = entry &0xfffffffe ; +/* r0 = arg */ + env->regs[0 ] = arg; + env->spsr =ARM_CPU_MODE_USR ; +/* +* Thumb mode is encoded by the low bit in the entry point (since ARM can't +* execute at odd addresses). When it's set, set the Thumb bit (T) in the +* CPSR. +*/ +cpsr_write (env, (entry &1 ) *CPSR_T ,CPSR_T , CPSRWriteByInstr); +} + +static inline void target_thread_init (struct target_pt_regs *regs, +struct image_info *infop) +{ +abi_long stack = infop->start_stack; +memset (regs,0 ,sizeof (*regs)); + regs->ARM_cpsr =ARM_CPU_MODE_USR ; +/* +* Thumb mode is encoded by the low bit in the entry point (since ARM can't +* execute at odd addresses). When it's set, set the Thumb bit (T) in the +* CPSR. +*/ +if (infop->entry &1 ) { + regs->ARM_cpsr |=CPSR_T ; + } + regs->ARM_pc = infop->entry &0xfffffffe ; + regs->ARM_sp = stack; +if (bsd_type == target_freebsd) { + regs->ARM_lr = infop->entry &0xfffffffe ; + } +/* +* FreeBSD kernel passes the ps_strings pointer in r0. This is used by some +* programs to set status messages that we see in ps. bsd-user doesn't +* support that functionality, so it's ignored. When set to 0, FreeBSD's csu +* code ignores it. For the static case, r1 and r2 are effectively ignored +* by the csu __startup() routine. For the dynamic case, rtld saves r0 but +* generates r1 and r2 and passes them into the csu _startup. +* +* r0 ps_strings 0 passed since ps arg setting not supported +* r1 obj_main ignored by _start(), so 0 passed +* r2 cleanup generated by rtld or ignored by _start(), so 0 passed +*/ +} + +#endif /* !_TARGET_ARCH_THREAD_H_ */
Signature · 1 line
2.33.0
PATCH v4 25/36 bsd-user/arm/target_arch_elf.h: arm defines for ELF
In reply to Warner LoshBasic set of defines needed for arm ELF file activation.
--- bsd-user/arm/target_arch_elf.h | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 bsd-user/arm/target_arch_elf.h
bsd-user/arm/target_arch_elf.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* arm ELF definitions +* +* Copyright (c) 2013 Stacey D. Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef _TARGET_ARCH_ELF_H_ +#define _TARGET_ARCH_ELF_H_ + +#define ELF_START_MMAP 0x80000000 +#define ELF_ET_DYN_LOAD_ADDR 0x500000 + +#define elf_check_arch (x) ((x) == EM_ARM) + +#define ELF_CLASS ELFCLASS32 +#define ELF_DATA ELFDATA2LSB +#define ELF_ARCH EM_ARM + +#define USE_ELF_CORE_DUMP +#define ELF_EXEC_PAGESIZE 4096 + +#define ELF_HWCAP 0 + +#endif /* _TARGET_ARCH_ELF_H_ */
Signature · 1 line
2.33.0
PATCH v4 26/36 bsd-user/arm/target_arch_elf.h: arm get hwcap
In reply to Warner LoshImplement get_elf_hwcap to get the first word of hardware capabilities.
--- bsd-user/arm/target_arch_elf.h | 72 +++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-)
bsd-user/arm/target_arch_elf.h +71 -1
@@ -31,6 +31,76 @@#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 -#define ELF_HWCAP 0 +#define ELF_HWCAP get_elf_hwcap() + +#define GET_FEATURE (feat, hwcap) \ + do { if (arm_feature(&cpu->env, feat)) { hwcaps |= hwcap; } } while (0) + +#define GET_FEATURE_ID (feat, hwcap) \ + do { if (cpu_isar_feature(feat, cpu)) { hwcaps |= hwcap; } } while (0) + +enum { +ARM_HWCAP_ARM_SWP =1 <<0 , +ARM_HWCAP_ARM_HALF =1 <<1 , +ARM_HWCAP_ARM_THUMB =1 <<2 , +ARM_HWCAP_ARM_26BIT =1 <<3 , +ARM_HWCAP_ARM_FAST_MULT =1 <<4 , +ARM_HWCAP_ARM_FPA =1 <<5 , +ARM_HWCAP_ARM_VFP =1 <<6 , +ARM_HWCAP_ARM_EDSP =1 <<7 , +ARM_HWCAP_ARM_JAVA =1 <<8 , +ARM_HWCAP_ARM_IWMMXT =1 <<9 , +ARM_HWCAP_ARM_CRUNCH =1 <<10 , +ARM_HWCAP_ARM_THUMBEE =1 <<11 , +ARM_HWCAP_ARM_NEON =1 <<12 , + ARM_HWCAP_ARM_VFPv3 =1 <<13 , + ARM_HWCAP_ARM_VFPv3D16 =1 <<14 , +ARM_HWCAP_ARM_TLS =1 <<15 , + ARM_HWCAP_ARM_VFPv4 =1 <<16 , +ARM_HWCAP_ARM_IDIVA =1 <<17 , +ARM_HWCAP_ARM_IDIVT =1 <<18 , +ARM_HWCAP_ARM_VFPD32 =1 <<19 , +ARM_HWCAP_ARM_LPAE =1 <<20 , +ARM_HWCAP_ARM_EVTSTRM =1 <<21 , +}; + +static uint32_t get_elf_hwcap (void ) +{ +ARMCPU *cpu =ARM_CPU (thread_cpu); +uint32_t hwcaps =0 ; + + hwcaps |=ARM_HWCAP_ARM_SWP ; + hwcaps |=ARM_HWCAP_ARM_HALF ; + hwcaps |=ARM_HWCAP_ARM_THUMB ; + hwcaps |=ARM_HWCAP_ARM_FAST_MULT ; + +/* probe for the extra features */ +/* EDSP is in v5TE and above */ +GET_FEATURE (ARM_FEATURE_V5 ,ARM_HWCAP_ARM_EDSP ); +GET_FEATURE (ARM_FEATURE_IWMMXT ,ARM_HWCAP_ARM_IWMMXT ); +GET_FEATURE (ARM_FEATURE_THUMB2EE ,ARM_HWCAP_ARM_THUMBEE ); +GET_FEATURE (ARM_FEATURE_NEON ,ARM_HWCAP_ARM_NEON ); +GET_FEATURE (ARM_FEATURE_V6K ,ARM_HWCAP_ARM_TLS ); +GET_FEATURE (ARM_FEATURE_LPAE ,ARM_HWCAP_ARM_LPAE ); +GET_FEATURE_ID (aa32_arm_div,ARM_HWCAP_ARM_IDIVA ); +GET_FEATURE_ID (aa32_thumb_div,ARM_HWCAP_ARM_IDIVT ); +GET_FEATURE_ID (aa32_vfp,ARM_HWCAP_ARM_VFP ); + +if (cpu_isar_feature (aa32_fpsp_v3, cpu) || +cpu_isar_feature (aa32_fpdp_v3, cpu)) { + hwcaps |= ARM_HWCAP_ARM_VFPv3; +if (cpu_isar_feature (aa32_simd_r32, cpu)) { + hwcaps |=ARM_HWCAP_ARM_VFPD32 ; + }else { + hwcaps |= ARM_HWCAP_ARM_VFPv3D16; + } + } +GET_FEATURE_ID (aa32_simdfmac, ARM_HWCAP_ARM_VFPv4); + +return hwcaps; +} + +#undef GET_FEATURE +#undef GET_FEATURE_ID#endif /* _TARGET_ARCH_ELF_H_ */
Signature · 1 line
2.33.0
PATCH v4 27/36 bsd-user/arm/target_arch_elf.h: arm get_hwcap2 impl
In reply to Warner LoshImplement the extended HW capabilities for HWCAP2.
--- bsd-user/arm/target_arch_elf.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
bsd-user/arm/target_arch_elf.h +22 -0
@@ -32,6 +32,7 @@#define ELF_EXEC_PAGESIZE 4096#define ELF_HWCAP get_elf_hwcap() +#define ELF_HWCAP2 get_elf_hwcap2()#define GET_FEATURE (feat, hwcap) \ do { if (arm_feature(&cpu->env, feat)) { hwcaps |= hwcap; } } while (0)
@@ -64,6 +65,14 @@ enum { ARM_HWCAP_ARM_EVTSTRM = 1 << 21, }; +enum { +ARM_HWCAP2_ARM_AES =1 <<0 , +ARM_HWCAP2_ARM_PMULL =1 <<1 , +ARM_HWCAP2_ARM_SHA1 =1 <<2 , +ARM_HWCAP2_ARM_SHA2 =1 <<3 , +ARM_HWCAP2_ARM_CRC32 =1 <<4 , +}; +static uint32_t get_elf_hwcap (void ) {ARMCPU *cpu =ARM_CPU (thread_cpu);
@@ -100,6 +109,19 @@ static uint32_t get_elf_hwcap(void)return hwcaps; } +static uint32_t get_elf_hwcap2 (void ) +{ +ARMCPU *cpu =ARM_CPU (thread_cpu); +uint32_t hwcaps =0 ; + +GET_FEATURE_ID (aa32_aes,ARM_HWCAP2_ARM_AES ); +GET_FEATURE_ID (aa32_pmull,ARM_HWCAP2_ARM_PMULL ); +GET_FEATURE_ID (aa32_sha1,ARM_HWCAP2_ARM_SHA1 ); +GET_FEATURE_ID (aa32_sha2,ARM_HWCAP2_ARM_SHA2 ); +GET_FEATURE_ID (aa32_crc32,ARM_HWCAP2_ARM_CRC32 ); +return hwcaps; +} +#undef GET_FEATURE#undef GET_FEATURE_ID
Signature · 1 line
2.33.0
PATCH v4 28/36 bsd-user/arm/target_arch_signal.h: arm specific signal registers and stack
In reply to Warner LoshDefines for registers and stack layout related to signals.
--- bsd-user/arm/target_arch_signal.h | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 bsd-user/arm/target_arch_signal.h
bsd-user/arm/target_arch_signal.h new file +57 -0
@@ -0,0 +1,57 @@ +/* +* arm signal definitions +* +* Copyright (c) 2013 Stacey D. Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef _TARGET_ARCH_SIGNAL_H_ +#define _TARGET_ARCH_SIGNAL_H_ + +#include "cpu.h" + +#define TARGET_REG_R0 0 +#define TARGET_REG_R1 1 +#define TARGET_REG_R2 2 +#define TARGET_REG_R3 3 +#define TARGET_REG_R4 4 +#define TARGET_REG_R5 5 +#define TARGET_REG_R6 6 +#define TARGET_REG_R7 7 +#define TARGET_REG_R8 8 +#define TARGET_REG_R9 9 +#define TARGET_REG_R10 10 +#define TARGET_REG_R11 11 +#define TARGET_REG_R12 12 +#define TARGET_REG_R13 13 +#define TARGET_REG_R14 14 +#define TARGET_REG_R15 15 +#define TARGET_REG_CPSR 16 +#define TARGET__NGREG 17 +/* Convenience synonyms */ +#define TARGET_REG_FP TARGET_REG_R11 +#define TARGET_REG_SP TARGET_REG_R13 +#define TARGET_REG_LR TARGET_REG_R14 +#define TARGET_REG_PC TARGET_REG_R15 + +#define TARGET_INSN_SIZE 4/* arm instruction size */ + +/* Size of the signal trampolin code. See _sigtramp(). */ +#define TARGET_SZSIGCODE ((abi_ulong)(9 * TARGET_INSN_SIZE)) + +/* compare to arm/include/_limits.h */ +#define TARGET_MINSIGSTKSZ (1024 * 4)/* min sig stack size */ +#define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768)/* recommended size */ + +#endif /* !_TARGET_ARCH_SIGNAL_H_ */
Signature · 1 line
2.33.0
PATCH v4 29/36 bsd-user/arm/target_arch_signal.h: arm machine context and trapframe for signals
In reply to Warner Losh--- bsd-user/arm/target_arch_signal.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
bsd-user/arm/target_arch_signal.h +28 -0
@@ -54,4 +54,32 @@#define TARGET_MINSIGSTKSZ (1024 * 4)/* min sig stack size */ #define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768)/* recommended size */ +/* +* Floating point register state +*/ +typedef struct target_mcontext_vfp { +abi_ullong mcv_reg[32 ]; +abi_ulong mcv_fpscr; +}target_mcontext_vfp_t ; + +typedef struct target_mcontext { +abi_uint __gregs[TARGET__NGREG ]; + +/* +* Originally, rest of this structure was named __fpu, 35 * 4 bytes +* long, never accessed from kernel. +*/ +abi_ulong mc_vfp_size; +abi_ptr mc_vfp_ptr; +abi_int mc_spare[33 ]; +}target_mcontext_t ; + +#include "target_os_ucontext.h" + +struct target_sigframe { +target_siginfo_t sf_si;/* saved siginfo */ +target_ucontext_t sf_uc;/* saved ucontext */ +target_mcontext_vfp_t sf_vfp;/* actual saved VFP context */ +}; +#endif /* !_TARGET_ARCH_SIGNAL_H_ */
Signature · 1 line
2.33.0
Re: [PATCH v4 29/36] bsd-user/arm/target_arch_signal.h: arm machine context and trapframe for signals
Quoted 6 lines · Warner Losh
Signed-off-by Stacey Son<[email protected]>Signed-off-by Kyle Evans<[email protected]>Signed-off-by Warner Losh<[email protected]>--- bsd-user/arm/target_arch_signal.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
r~
PATCH v4 30/36 bsd-user/arm/target_arch_signal.h: Define size of *context_t
In reply to Warner LoshDefine the native sizes of mcontext_t and ucontext_t so that the tests in target_os_ucontext.h ensure the size of arm's version of these structures is correct.
--- bsd-user/arm/target_arch_signal.h | 3 +++ 1 file changed, 3 insertions(+)
bsd-user/arm/target_arch_signal.h +3 -0
@@ -74,6 +74,9 @@ typedef struct target_mcontext {abi_int mc_spare[33 ]; } target_mcontext_t; +#define TARGET_MCONTEXT_SIZE 208 +#define TARGET_UCONTEXT_SIZE 260 +#include "target_os_ucontext.h" struct target_sigframe {
Signature · 1 line
2.33.0
Re: [PATCH v4 30/36] bsd-user/arm/target_arch_signal.h: Define size of *context_t
Quoted 8 lines · Warner Losh
Define the native sizes of
mcontext_tanducontext_tso that the tests intarget_os_ucontext.hensure the size of arm's version of these structures is correct.Signed-off-by Warner Losh<[email protected]>--- bsd-user/arm/target_arch_signal.h | 3 +++ 1 file changed, 3 insertions(+)
r~
PATCH v4 31/36 bsd-user/arm/target_arch_signal.c: arm set_sigtramp_args
In reply to Warner LoshImplement set_sigtramp_args to setup the arguments to the sigtramp calls.
--- bsd-user/arm/signal.c | 60 +++++++++++++++++++++++++++++++ bsd-user/arm/target_arch_signal.h | 5 +++ 2 files changed, 65 insertions(+) create mode 100644 bsd-user/arm/signal.c
bsd-user/arm/signal.c new file +60 -0
@@ -0,0 +1,60 @@ +/* +* arm signal functions +* +* Copyright (c) 2013 Stacey D. Son +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu.h" + +/* +* Compare to arm/arm/machdep.c sendsig() +* Assumes that target stack frame memory is locked. +*/ +abi_long set_sigtramp_args (CPUARMState *env,int sig, +struct target_sigframe *frame, +abi_ulong frame_addr, +struct target_sigaction *ka) +{ +/* +* Arguments to signal handler: +* r0 = signal number +* r1 = siginfo pointer +* r2 = ucontext pointer +* r5 = ucontext pointer +* pc = signal handler pointer +* sp = sigframe struct pointer +* lr = sigtramp at base of user stack +*/ + + env->regs[0 ] = sig; + env->regs[1 ] = frame_addr + + offsetof(struct target_sigframe , sf_si); + env->regs[2 ] = frame_addr + + offsetof(struct target_sigframe , sf_uc); + +/* the trampoline uses r5 as the uc address */ + env->regs[5 ] = frame_addr + + offsetof(struct target_sigframe , sf_uc); + env->regs[TARGET_REG_PC ] = ka->_sa_handler & ~1 ; + env->regs[TARGET_REG_SP ] = frame_addr; + env->regs[TARGET_REG_LR ] =TARGET_PS_STRINGS -TARGET_SZSIGCODE ; +/* +* Low bit indicates whether or not we're entering thumb mode. +*/ +cpsr_write (env, (ka->_sa_handler &1 ) *CPSR_T ,CPSR_T , CPSRWriteByInstr); + +return 0 ; +}
bsd-user/arm/target_arch_signal.h +5 -0
@@ -85,4 +85,9 @@ struct target_sigframe { target_mcontext_vfp_t sf_vfp; /* actual saved VFP context */ }; +abi_long set_sigtramp_args (CPUARMState *regs,int sig, +struct target_sigframe *frame, +abi_ulong frame_addr, +struct target_sigaction *ka); +#endif /* !_TARGET_ARCH_SIGNAL_H_ */
Signature · 1 line
2.33.0
PATCH v4 32/36 bsd-user/arm/target_arch_signal.c: arm get_mcontext
In reply to Warner LoshGet the machine context from the CPU state.
--- bsd-user/arm/signal.c | 51 +++++++++++++++++++++++++++++++ bsd-user/arm/target_arch_signal.h | 1 + 2 files changed, 52 insertions(+)
bsd-user/arm/signal.c +51 -0
@@ -58,3 +58,54 @@ abi_long set_sigtramp_args(CPUARMState *env, int sig,return 0 ; } + +/* +* Compare to arm/arm/machdep.c get_mcontext() +* Assumes that the memory is locked if mcp points to user memory. +*/ +abi_long get_mcontext (CPUARMState *env,target_mcontext_t *mcp,int flags) +{ +int err =0 ; +uint32_t *gr = mcp->__gregs; + +if (mcp->mc_vfp_size !=0 && mcp->mc_vfp_size !=sizeof (target_mcontext_vfp_t)) { +return -TARGET_EINVAL ; + } + + gr[TARGET_REG_CPSR ] =tswap32 (cpsr_read (env)); +if (flags &TARGET_MC_GET_CLEAR_RET ) { + gr[TARGET_REG_R0 ] =0 ; + gr[TARGET_REG_CPSR ] &= ~CPSR_C ; + }else { + gr[TARGET_REG_R0 ] =tswap32 (env->regs[0 ]); + } + + gr[TARGET_REG_R1 ] =tswap32 (env->regs[1 ]); + gr[TARGET_REG_R2 ] =tswap32 (env->regs[2 ]); + gr[TARGET_REG_R3 ] =tswap32 (env->regs[3 ]); + gr[TARGET_REG_R4 ] =tswap32 (env->regs[4 ]); + gr[TARGET_REG_R5 ] =tswap32 (env->regs[5 ]); + gr[TARGET_REG_R6 ] =tswap32 (env->regs[6 ]); + gr[TARGET_REG_R7 ] =tswap32 (env->regs[7 ]); + gr[TARGET_REG_R8 ] =tswap32 (env->regs[8 ]); + gr[TARGET_REG_R9 ] =tswap32 (env->regs[9 ]); + gr[TARGET_REG_R10 ] =tswap32 (env->regs[10 ]); + gr[TARGET_REG_R11 ] =tswap32 (env->regs[11 ]); + gr[TARGET_REG_R12 ] =tswap32 (env->regs[12 ]); + + gr[TARGET_REG_SP ] =tswap32 (env->regs[13 ]); + gr[TARGET_REG_LR ] =tswap32 (env->regs[14 ]); + gr[TARGET_REG_PC ] =tswap32 (env->regs[15 ]); + +if (mcp->mc_vfp_size !=0 && mcp->mc_vfp_ptr !=0 ) { +/* see get_vfpcontext in sys/arm/arm/exec_machdep.c */ +target_mcontext_vfp_t *vfp; + vfp =lock_user (VERIFY_WRITE , mcp->mc_vfp_ptr,sizeof (*vfp),0 ); +for (int i =0 ; i <32 ; i++) { + vfp->mcv_reg[i] =tswap64 (*aa32_vfp_dreg (env, i)); + } + vfp->mcv_fpscr =tswap32 (vfp_get_fpscr (env)); +unlock_user (vfp, mcp->mc_vfp_ptr,sizeof (*vfp)); + } +return err; +}
bsd-user/arm/target_arch_signal.h +1 -0
@@ -89,5 +89,6 @@ abi_long set_sigtramp_args(CPUARMState *regs, int sig,struct target_sigframe *frame, abi_ulong frame_addr, struct target_sigaction *ka); +abi_long get_mcontext (CPUARMState *regs,target_mcontext_t *mcp,int flags);#endif /* !_TARGET_ARCH_SIGNAL_H_ */
Signature · 1 line
2.33.0
Re: [PATCH v4 32/36] bsd-user/arm/target_arch_signal.c: arm get_mcontext
Quoted 9 lines · Warner Losh
Get the machine context from the CPU state.
Signed-off-by Stacey Son<[email protected]>Signed-off-by Kyle Evans<[email protected]>Signed-off-by Warner Losh<[email protected]>--- bsd-user/arm/signal.c | 51 +++++++++++++++++++++++++++++++ bsd-user/arm/target_arch_signal.h | 1 + 2 files changed, 52 insertions(+)
r~
PATCH v4 33/36 bsd-user/arm/target_arch_signal.c: arm set_mcontext
In reply to Warner LoshMove the machine context to the CPU state.
--- bsd-user/arm/signal.c | 79 +++++++++++++++++++++++++++++++ bsd-user/arm/target_arch_signal.h | 1 + 2 files changed, 80 insertions(+)
bsd-user/arm/signal.c +79 -0
@@ -109,3 +109,82 @@ abi_long get_mcontext(CPUARMState *env, target_mcontext_t *mcp, int flags) }return err; } + +/* Compare to arm/arm/exec_machdep.c set_mcontext() */ +abi_long set_mcontext (CPUARMState *env,target_mcontext_t *mcp,int srflag) +{ +int err =0 ; +const uint32_t *gr = mcp->__gregs; +uint32_t cpsr, ccpsr =cpsr_read (env); +uint32_t fpscr, mask; + + cpsr =tswap32 (gr[TARGET_REG_CPSR ]); +/* +* Only allow certain bits to change, reject attempted changes to non-user +* bits. In addition, make sure we're headed for user mode and none of the +* interrupt bits are set. +*/ +if ((ccpsr & ~CPSR_USER ) != (cpsr & ~CPSR_USER )) { +return -TARGET_EINVAL ; + } +if ((cpsr &CPSR_M ) !=ARM_CPU_MODE_USR || + (cpsr & (CPSR_I |CPSR_F )) !=0 ) { +return -TARGET_EINVAL ; + } + mask = cpsr &CPSR_T ?0x1 :0x3 ; + +/* +* Make sure that we either have no vfp, or it's the correct size. +* FreeBSD just ignores it, though, so maybe we'll need to adjust +* things below instead. +*/ +if (mcp->mc_vfp_size !=0 && mcp->mc_vfp_size !=sizeof (target_mcontext_vfp_t)) { +return -TARGET_EINVAL ; + } +/* +* Make sure T mode matches the PC's notion of thumb mode, although +* FreeBSD lets the processor sort this out, so we may need remove +* this check, or generate a signal... +*/ +if (!!(tswap32 (gr[TARGET_REG_PC ]) &1 ) != !!(cpsr &CPSR_T )) { +return -TARGET_EINVAL ; + } + + env->regs[0 ] =tswap32 (gr[TARGET_REG_R0 ]); + env->regs[1 ] =tswap32 (gr[TARGET_REG_R1 ]); + env->regs[2 ] =tswap32 (gr[TARGET_REG_R2 ]); + env->regs[3 ] =tswap32 (gr[TARGET_REG_R3 ]); + env->regs[4 ] =tswap32 (gr[TARGET_REG_R4 ]); + env->regs[5 ] =tswap32 (gr[TARGET_REG_R5 ]); + env->regs[6 ] =tswap32 (gr[TARGET_REG_R6 ]); + env->regs[7 ] =tswap32 (gr[TARGET_REG_R7 ]); + env->regs[8 ] =tswap32 (gr[TARGET_REG_R8 ]); + env->regs[9 ] =tswap32 (gr[TARGET_REG_R9 ]); + env->regs[10 ] =tswap32 (gr[TARGET_REG_R10 ]); + env->regs[11 ] =tswap32 (gr[TARGET_REG_R11 ]); + env->regs[12 ] =tswap32 (gr[TARGET_REG_R12 ]); + + env->regs[13 ] =tswap32 (gr[TARGET_REG_SP ]); + env->regs[14 ] =tswap32 (gr[TARGET_REG_LR ]); + env->regs[15 ] =tswap32 (gr[TARGET_REG_PC ] & mask); +if (mcp->mc_vfp_size !=0 && mcp->mc_vfp_ptr !=0 ) { +/* see set_vfpcontext in sys/arm/arm/exec_machdep.c */ +target_mcontext_vfp_t *vfp; + + vfp =lock_user (VERIFY_READ , mcp->mc_vfp_ptr,sizeof (*vfp),1 ); +for (int i =0 ; i <32 ; i++) { +__get_user (*aa32_vfp_dreg (env, i), &vfp->mcv_reg[i]); + } +__get_user (fpscr, &vfp->mcv_fpscr); +vfp_set_fpscr (env, fpscr); +unlock_user (vfp, mcp->mc_vfp_ptr,sizeof (target_ucontext_t)); + +/* +* linux-user sets fpexc, fpinst and fpinst2, but these aren't in +* FreeBSD's mcontext, what to do? +*/ + } +cpsr_write (env, cpsr,CPSR_USER |CPSR_EXEC , CPSRWriteByInstr); + +return err; +}
bsd-user/arm/target_arch_signal.h +1 -0
@@ -90,5 +90,6 @@ abi_long set_sigtramp_args(CPUARMState *regs, int sig,abi_ulong frame_addr, struct target_sigaction *ka);abi_long get_mcontext (CPUARMState *regs,target_mcontext_t *mcp,int flags); +abi_long set_mcontext (CPUARMState *regs,target_mcontext_t *mcp,int srflag);#endif /* !_TARGET_ARCH_SIGNAL_H_ */
Signature · 1 line
2.33.0
Re: [PATCH v4 33/36] bsd-user/arm/target_arch_signal.c: arm set_mcontext
Quoted 12 lines · Warner Losh
bsd-user/arm/signal.c +12
-0+/* Compare to arm/arm/exec_machdep.c set_mcontext() */ +abi_long set_mcontext (CPUARMState *env,target_mcontext_t *mcp,int srflag) +{ +int err =0 ; +const uint32_t *gr = mcp->__gregs; +uint32_t cpsr, ccpsr =cpsr_read (env); +uint32_t fpscr, mask; + + cpsr =tswap32 (gr[TARGET_REG_CPSR ]); +/* +* Only allow certain bits to change, reject attempted changes to non-user +* bits. In addition, make sure we're headed for user mode and none of the
bsd-user/arm/signal.c abi_long get_mcontext(CPUARMState *env, target_mcontext_t *mcp, int flags) · line 134
Quoted 10 lines
bsd-user/arm/signal.c +10
-0+* interrupt bits are set. +*/ +if ((ccpsr & ~CPSR_USER ) != (cpsr & ~CPSR_USER )) { +return -TARGET_EINVAL ; + } +if ((cpsr &CPSR_M ) !=ARM_CPU_MODE_USR || + (cpsr & (CPSR_I |CPSR_F )) !=0 ) { +return -TARGET_EINVAL ; + } + mask = cpsr &CPSR_T ?0x1 :0x3 ;
Should add a sentence or so here, pointing to the exception return instruction used by the freebsd kernel, which does this masking.
bsd-user/arm/signal.c abi_long get_mcontext(CPUARMState *env, target_mcontext_t *mcp, int flags) · line 151
Quoted 8 lines
bsd-user/arm/signal.c +8
-0+/* +* Make sure T mode matches the PC's notion of thumb mode, although +* FreeBSD lets the processor sort this out, so we may need remove +* this check, or generate a signal... +*/ +if (!!(tswap32 (gr[TARGET_REG_PC ]) &1 ) != !!(cpsr &CPSR_T )) { +return -TARGET_EINVAL ; + }
Remove this.
Quoted 1 line
+ env->regs[15] =
tswap32(gr[TARGET_REG_PC] & mask);
You wanted ~mask.
r~
Re: [PATCH v4 33/36] bsd-user/arm/target_arch_signal.c: arm set_mcontext
Quoted 27 lines · Richard Henderson
Review
Quoted 2 lines · Warner Losh
(quoted diff) +2
-0+/* Compare to arm/arm/exec_machdep.c set_mcontext() */ +abi_long set_mcontext(CPUARMState *env, target_mcontext_t *mcp, intsrflag)
bsd-user/arm/signal.c abi_long get_mcontext(CPUARMState *env, target_mcontext_t *mcp, int flags)
Quoted 9 lines
bsd-user/arm/signal.c +9
-0+{ +int err =0 ; +const uint32_t *gr = mcp->__gregs; +uint32_t cpsr, ccpsr =cpsr_read (env); +uint32_t fpscr, mask; + + cpsr =tswap32 (gr[TARGET_REG_CPSR ]); +/* +* Only allow certain bits to change, reject attempted changes to non-user
Quoted 1 line
+ * bits. In addition, make sure we're headed for user mode and none
of the
bsd-user/arm/signal.c abi_long get_mcontext(CPUARMState *env, target_mcontext_t *mcp, int flags) · line 134
Quoted 10 lines
bsd-user/arm/signal.c +10
-0+* interrupt bits are set. +*/ +if ((ccpsr & ~CPSR_USER ) != (cpsr & ~CPSR_USER )) { +return -TARGET_EINVAL ; + } +if ((cpsr &CPSR_M ) !=ARM_CPU_MODE_USR || + (cpsr & (CPSR_I |CPSR_F )) !=0 ) { +return -TARGET_EINVAL ; + } + mask = cpsr &CPSR_T ?0x1 :0x3 ;
Quoted 4 lines
Should add a sentence or so here, pointing to the exception return instruction used by the
freebsd kernel, which does this masking.
Will do.
Quoted 11 lines
bsd-user/arm/signal.c abi_long get_mcontext(CPUARMState *env, target_mcontext_t *mcp, int flags) · line 151
Quoted 8 lines
bsd-user/arm/signal.c +8
-0+/* +* Make sure T mode matches the PC's notion of thumb mode, although +* FreeBSD lets the processor sort this out, so we may need remove +* this check, or generate a signal... +*/ +if (!!(tswap32 (gr[TARGET_REG_PC ]) &1 ) != !!(cpsr &CPSR_T )) { +return -TARGET_EINVAL ; + }Remove this.
Gone.
Quoted 4 lines
Quoted 1 line
+ env->regs[15] =
tswap32(gr[TARGET_REG_PC] & mask);You wanted ~mask.
Doh! Fixed.
Warner
Quoted 3 lines
r~
PATCH v4 34/36 bsd-user/arm/target_arch_signal.c: arm get_ucontext_sigreturn
In reply to Warner LoshUpdate ucontext to implement sigreturn.
--- bsd-user/arm/signal.c | 9 +++++++++ bsd-user/arm/target_arch_signal.h | 2 ++ 2 files changed, 11 insertions(+)
bsd-user/arm/signal.c +9 -0
@@ -188,3 +188,12 @@ abi_long set_mcontext(CPUARMState *env, target_mcontext_t *mcp, int srflag)return err; } + +/* Compare to arm/arm/machdep.c sys_sigreturn() */ +abi_long get_ucontext_sigreturn (CPUARMState *env,abi_ulong target_sf, +abi_ulong *target_uc) +{ + *target_uc = target_sf; + +return 0 ; +}
bsd-user/arm/target_arch_signal.h +2 -0
@@ -91,5 +91,7 @@ abi_long set_sigtramp_args(CPUARMState *regs, int sig, struct target_sigaction *ka);abi_long get_mcontext (CPUARMState *regs,target_mcontext_t *mcp,int flags);abi_long set_mcontext (CPUARMState *regs,target_mcontext_t *mcp,int srflag); +abi_long get_ucontext_sigreturn (CPUARMState *regs,abi_ulong target_sf, +abi_ulong *target_uc);#endif /* !_TARGET_ARCH_SIGNAL_H_ */
Signature · 1 line
2.33.0
PATCH v4 35/36 bsd-user/freebsd/target_os_ucontext.h: Require TARGET_*CONTEXT_SIZE
In reply to Warner LoshNow that all architecutres define TARGET_[MU]CONTEXT_SIZE, enforce requiring them and always check the sizeof target_{u,m}context_t sizes.
--- bsd-user/freebsd/target_os_ucontext.h | 2 -- 1 file changed, 2 deletions(-)
bsd-user/freebsd/target_os_ucontext.h +0 -2
@@ -27,9 +27,7 @@ typedef struct target_ucontext { int32_t __spare__[4]; } target_ucontext_t; -#ifdef TARGET_MCONTEXT_SIZE G_STATIC_ASSERT (TARGET_MCONTEXT_SIZE ==sizeof (target_mcontext_t));G_STATIC_ASSERT (TARGET_UCONTEXT_SIZE ==sizeof (target_ucontext_t)); -#endif /* TARGET_MCONTEXT_SIZE */ #endif /* TARGET_OS_UCONTEXT_H */
Signature · 1 line
2.33.0
Re: [PATCH v4 35/36] bsd-user/freebsd/target_os_ucontext.h: Require TARGET_*CONTEXT_SIZE
Quoted 8 lines · Warner Losh
Now that all architecutres define TARGET_[MU]CONTEXT_SIZE, enforce requiring them and always check the sizeof target_{u,m}context_t sizes.
Signed-off-by Warner Losh<[email protected]>--- bsd-user/freebsd/target_os_ucontext.h | 2 -- 1 file changed, 2 deletions(-)
r~
PATCH v4 36/36 bsd-user: add arm target build
In reply to Warner Losh--- configs/targets/arm-bsd-user.mak | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 configs/targets/arm-bsd-user.mak
configs/targets/arm-bsd-user.mak new file +2 -0
@@ -0,0 +1,2 @@ +TARGET_ARCH=arm +TARGET_XML_FILES= gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml gdb-xml/arm-vfp-sysregs.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml gdb-xml/arm-m-profile-mve.xml
Signature · 1 line
2.33.0