Message ID | 20211019164447.16359-19-imp@bsdimp.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | bsd-user: arm (32-bit) support | expand |
On Tue, Oct 19, 2021 at 11:45 AM Warner Losh <imp@bsdimp.com> wrote: > > Signed-off-by: Stacey Son <sson@FreeBSD.org> > Signed-off-by: Klye Evans <kevans@FreeBSD.org> > Signed-off-by: Warner Losh <imp@bsdimp.com> > --- > bsd-user/arm/target_arch_signal.h | 36 +++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) > > diff --git a/bsd-user/arm/target_arch_signal.h b/bsd-user/arm/target_arch_signal.h > index 973183d99c..9fee58ca9c 100644 > --- a/bsd-user/arm/target_arch_signal.h > +++ b/bsd-user/arm/target_arch_signal.h > @@ -54,4 +54,40 @@ > #define TARGET_MINSIGSTKSZ (1024 * 4) /* min sig stack size */ > #define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768) /* recommended size */ > > +/* arm/arm/machdep.c */ > +struct target_sigcontext { > + target_sigset_t sc_mask; /* signal mask to retstore */ > + int32_t sc_onstack; /* sigstack state to restore */ > + abi_long sc_pc; /* pc at time of signal */ > + abi_long sc_reg[32]; /* processor regs 0 to 31 */ > + abi_long mullo, mulhi; /* mullo and mulhi registers */ > + int32_t sc_fpused; /* fp has been used */ > + abi_long sc_fpregs[33]; /* fp regs 0 to 31 & csr */ > + abi_long sc_fpc_eir; /* fp exception instr reg */ > + /* int32_t reserved[8]; */ > +}; > + > +typedef struct { > + uint32_t __fp_fpsr; > + struct { > + uint32_t __fp_exponent; > + uint32_t __fp_mantissa_hi; > + uint32_t __fp_mantissa_lo; > + } __fp_fr[8]; > +} target__fpregset_t; > + > +typedef struct { > + uint32_t __vfp_fpscr; > + uint32_t __vfp_fstmx[33]; > + uint32_t __vfp_fpsid; > +} target__vfpregset_t; > + > +typedef struct target_mcontext { > + uint32_t __gregs[TARGET__NGREG]; > + union { > + target__fpregset_t __fpregs; > + target__vfpregset_t __vfpregs; > + } __fpu; > +} target_mcontext_t; > + > #endif /* !_TARGET_ARCH_SIGNAL_H_ */ > -- > 2.32.0 > Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
On 10/19/21 9:44 AM, Warner Losh wrote: > +/* arm/arm/machdep.c */ > +struct target_sigcontext { > + target_sigset_t sc_mask; /* signal mask to retstore */ > + int32_t sc_onstack; /* sigstack state to restore */ > + abi_long sc_pc; /* pc at time of signal */ > + abi_long sc_reg[32]; /* processor regs 0 to 31 */ > + abi_long mullo, mulhi; /* mullo and mulhi registers */ > + int32_t sc_fpused; /* fp has been used */ > + abi_long sc_fpregs[33]; /* fp regs 0 to 31 & csr */ > + abi_long sc_fpc_eir; /* fp exception instr reg */ > + /* int32_t reserved[8]; */ > +}; From the set of registers, this seems to be copied from mips. The contents of sys/arm/include/signal.h are struct sigcontext { int _dummy; }; so I'm not sure what you're doing here. r~
On 10/19/21 9:44 AM, Warner Losh wrote: > +typedef struct { > + uint32_t __fp_fpsr; > + struct { > + uint32_t __fp_exponent; > + uint32_t __fp_mantissa_hi; > + uint32_t __fp_mantissa_lo; > + } __fp_fr[8]; > +} target__fpregset_t; > + > +typedef struct { > + uint32_t __vfp_fpscr; > + uint32_t __vfp_fstmx[33]; > + uint32_t __vfp_fpsid; > +} target__vfpregset_t; > + > +typedef struct target_mcontext { > + uint32_t __gregs[TARGET__NGREG]; > + union { > + target__fpregset_t __fpregs; > + target__vfpregset_t __vfpregs; > + } __fpu; > +} target_mcontext_t; This doesn't match what I see in sys/arm/include/ucontext.h at all. I don't even see the string "fstmx" anywhere in the source tree. r~
On Thu, Oct 28, 2021 at 11:18 AM Richard Henderson < richard.henderson@linaro.org> wrote: > On 10/19/21 9:44 AM, Warner Losh wrote: > > +typedef struct { > > + uint32_t __fp_fpsr; > > + struct { > > + uint32_t __fp_exponent; > > + uint32_t __fp_mantissa_hi; > > + uint32_t __fp_mantissa_lo; > > + } __fp_fr[8]; > > +} target__fpregset_t; > > + > > +typedef struct { > > + uint32_t __vfp_fpscr; > > + uint32_t __vfp_fstmx[33]; > > + uint32_t __vfp_fpsid; > > +} target__vfpregset_t; > > + > > +typedef struct target_mcontext { > > + uint32_t __gregs[TARGET__NGREG]; > > + union { > > + target__fpregset_t __fpregs; > > + target__vfpregset_t __vfpregs; > > + } __fpu; > > +} target_mcontext_t; > > This doesn't match what I see in sys/arm/include/ucontext.h at all. > I don't even see the string "fstmx" anywhere in the source tree. > Yea. This appears to be a copy mostly from mips and is totally wrong for ARM. However, despite that, it works by accident because the general registers all wind up in the right places and we don't actually write to the full context.... I'll respin with the correct headers and any code tweaks that are needed. As to 'how this happened' I'm at a loss: git blame shows that it came in when the sbruno repo was created which is the earliest history I have for the project. Warner
diff --git a/bsd-user/arm/target_arch_signal.h b/bsd-user/arm/target_arch_signal.h index 973183d99c..9fee58ca9c 100644 --- a/bsd-user/arm/target_arch_signal.h +++ b/bsd-user/arm/target_arch_signal.h @@ -54,4 +54,40 @@ #define TARGET_MINSIGSTKSZ (1024 * 4) /* min sig stack size */ #define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768) /* recommended size */ +/* arm/arm/machdep.c */ +struct target_sigcontext { + target_sigset_t sc_mask; /* signal mask to retstore */ + int32_t sc_onstack; /* sigstack state to restore */ + abi_long sc_pc; /* pc at time of signal */ + abi_long sc_reg[32]; /* processor regs 0 to 31 */ + abi_long mullo, mulhi; /* mullo and mulhi registers */ + int32_t sc_fpused; /* fp has been used */ + abi_long sc_fpregs[33]; /* fp regs 0 to 31 & csr */ + abi_long sc_fpc_eir; /* fp exception instr reg */ + /* int32_t reserved[8]; */ +}; + +typedef struct { + uint32_t __fp_fpsr; + struct { + uint32_t __fp_exponent; + uint32_t __fp_mantissa_hi; + uint32_t __fp_mantissa_lo; + } __fp_fr[8]; +} target__fpregset_t; + +typedef struct { + uint32_t __vfp_fpscr; + uint32_t __vfp_fstmx[33]; + uint32_t __vfp_fpsid; +} target__vfpregset_t; + +typedef struct target_mcontext { + uint32_t __gregs[TARGET__NGREG]; + union { + target__fpregset_t __fpregs; + target__vfpregset_t __vfpregs; + } __fpu; +} target_mcontext_t; + #endif /* !_TARGET_ARCH_SIGNAL_H_ */