[PATCH v3 19/29] bsd-user/arm/target_arch_signal.h: arm machine context for signals

Warner Losh posted 29 patches 4 years, 3 months ago
Maintainers: Laurent Vivier <laurent@vivier.eu>, Michael Tokarev <mjt@tls.msk.ru>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>
There is a newer version of this series
[PATCH v3 19/29] bsd-user/arm/target_arch_signal.h: arm machine context for signals
Posted by Warner Losh 4 years, 3 months ago
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/arm/target_arch_signal.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/bsd-user/arm/target_arch_signal.h b/bsd-user/arm/target_arch_signal.h
index 973183d99c..3aaced474b 100644
--- a/bsd-user/arm/target_arch_signal.h
+++ b/bsd-user/arm/target_arch_signal.h
@@ -54,4 +54,24 @@
 #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 {
+    uint32_t    __gregs[32];
+
+    /*
+     * Originally, rest of this structure was named __fpu, 35 * 4 bytes
+     * long, never accessed from kernel.
+     */
+    abi_long    mc_vfp_size;
+    abi_ptr     *mc_vfp_ptr;
+    abi_int     mc_spare[33];
+} target_mcontext_t;
+
 #endif /* !_TARGET_ARCH_SIGNAL_H_ */
-- 
2.33.0


Re: [PATCH v3 19/29] bsd-user/arm/target_arch_signal.h: arm machine context for signals
Posted by Richard Henderson 4 years, 3 months ago
On 11/4/21 10:05 AM, Warner Losh wrote:
> +typedef struct target_mcontext {
> +    uint32_t    __gregs[32];

sys/arm/include/ucontext.h has

#define _NGREG          17
typedef __greg_t        __gregset_t[_NGREG];

With s/32/17/ here,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

Re: [PATCH v3 19/29] bsd-user/arm/target_arch_signal.h: arm machine context for signals
Posted by Warner Losh 4 years, 3 months ago
On Thu, Nov 4, 2021 at 11:49 AM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 11/4/21 10:05 AM, Warner Losh wrote:
> > +typedef struct target_mcontext {
> > +    uint32_t    __gregs[32];
>
> sys/arm/include/ucontext.h has
>
> #define _NGREG          17
> typedef __greg_t        __gregset_t[_NGREG];
>
> With s/32/17/ here,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>

Will do.

And I'm going to add compile time asserts for the size of mcontext and
ucontext in a future
patch series. It won't test for layout, but will keep things like this from
happening again by accident.

Warner
Re: [PATCH v3 19/29] bsd-user/arm/target_arch_signal.h: arm machine context for signals
Posted by Warner Losh 4 years, 3 months ago
On Thu, Nov 4, 2021, 11:58 AM Warner Losh <imp@bsdimp.com> wrote:

>
>
> On Thu, Nov 4, 2021 at 11:49 AM Richard Henderson <
> richard.henderson@linaro.org> wrote:
>
>> On 11/4/21 10:05 AM, Warner Losh wrote:
>> > +typedef struct target_mcontext {
>> > +    uint32_t    __gregs[32];
>>
>> sys/arm/include/ucontext.h has
>>
>> #define _NGREG          17
>> typedef __greg_t        __gregset_t[_NGREG];
>>
>
There is already a TARGET__NGREG so I'll use that.

With s/32/17/ here,
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>
>
> Will do.
>
> And I'm going to add compile time asserts for the size of mcontext and
> ucontext in a future
> patch series. It won't test for layout, but will keep things like this
> from happening again by accident.
>
> Warner
>
Re: [PATCH v3 19/29] bsd-user/arm/target_arch_signal.h: arm machine context for signals
Posted by Warner Losh 4 years, 3 months ago
On Thu, Nov 4, 2021 at 11:58 AM Warner Losh <imp@bsdimp.com> wrote:

>
>
> On Thu, Nov 4, 2021 at 11:49 AM Richard Henderson <
> richard.henderson@linaro.org> wrote:
>
>> On 11/4/21 10:05 AM, Warner Losh wrote:
>> > +typedef struct target_mcontext {
>> > +    uint32_t    __gregs[32];
>>
>> sys/arm/include/ucontext.h has
>>
>> #define _NGREG          17
>> typedef __greg_t        __gregset_t[_NGREG];
>>
>> With s/32/17/ here,
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>
>
> Will do.
>
> And I'm going to add compile time asserts for the size of mcontext and
> ucontext in a future
> patch series. It won't test for layout, but will keep things like this
> from happening again by accident.
>

So I added a G_STATIC_ASSERT and found I used a host's pointer instead of
the target's pointer for the vfp stuff.
Easy enough to  fix... But it means using functions that aren't yet defined
when this is included, which means I'll
have to restructure things... shuffling the includes is likely out of the
question, so I'll have to create an arch/signal.c
to hold the now-inlined functions.

All because I wanted to catch errors like this before I made them again in
public... :)  So thanks for inspiring me
to do something that detected the error, but a good natured harumph at the
work I have to do now...

Warner