* [PATCH v2 02/23] linux-user/aarch64: Implement setup_sigtramp
[not found] <20210618192951.125651-1-richard.henderson@linaro.org>
@ 2021-06-18 19:29 ` Richard Henderson
2021-06-29 13:36 ` Peter Maydell
2021-06-18 19:29 ` [PATCH v2 03/23] linux-user/arm: Split out v2_frame Richard Henderson
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Richard Henderson @ 2021-06-18 19:29 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, alex.bennee, qemu-arm, Philippe Mathieu-Daudé
Create and record the rt signal trampoline.
Use it when the guest does not use SA_RESTORER.
Cc: qemu-arm@nongnu.org
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/aarch64/target_signal.h | 2 ++
linux-user/aarch64/signal.c | 28 ++++++++++++++++++----------
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/linux-user/aarch64/target_signal.h b/linux-user/aarch64/target_signal.h
index 18013e1b23..7580d99403 100644
--- a/linux-user/aarch64/target_signal.h
+++ b/linux-user/aarch64/target_signal.h
@@ -25,4 +25,6 @@ typedef struct target_sigaltstack {
#define TARGET_SEGV_MTESERR 9 /* Synchronous ARM MTE exception */
#define TARGET_ARCH_HAS_SETUP_FRAME
+#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
+
#endif /* AARCH64_TARGET_SIGNAL_H */
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
index 662bcd1c4e..65b84eb04e 100644
--- a/linux-user/aarch64/signal.c
+++ b/linux-user/aarch64/signal.c
@@ -108,7 +108,6 @@ struct target_rt_sigframe {
struct target_rt_frame_record {
uint64_t fp;
uint64_t lr;
- uint32_t tramp[2];
};
static void target_setup_general_frame(struct target_rt_sigframe *sf,
@@ -495,15 +494,7 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
if (ka->sa_flags & TARGET_SA_RESTORER) {
return_addr = ka->sa_restorer;
} else {
- /*
- * mov x8,#__NR_rt_sigreturn; svc #0
- * Since these are instructions they need to be put as little-endian
- * regardless of target default or current CPU endianness.
- */
- __put_user_e(0xd2801168, &fr->tramp[0], le);
- __put_user_e(0xd4000001, &fr->tramp[1], le);
- return_addr = frame_addr + fr_ofs
- + offsetof(struct target_rt_frame_record, tramp);
+ return_addr = default_rt_sigreturn;
}
env->xregs[0] = usig;
env->xregs[29] = frame_addr + fr_ofs;
@@ -576,3 +567,20 @@ long do_sigreturn(CPUARMState *env)
{
return do_rt_sigreturn(env);
}
+
+void setup_sigtramp(abi_ulong sigtramp_page)
+{
+ uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0);
+ assert(tramp != NULL);
+
+ /*
+ * mov x8,#__NR_rt_sigreturn; svc #0
+ * Since these are instructions they need to be put as little-endian
+ * regardless of target default or current CPU endianness.
+ */
+ __put_user_e(0xd2801168, &tramp[0], le);
+ __put_user_e(0xd4000001, &tramp[1], le);
+
+ default_rt_sigreturn = sigtramp_page;
+ unlock_user(tramp, sigtramp_page, 8);
+}
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 03/23] linux-user/arm: Split out v2_frame
[not found] <20210618192951.125651-1-richard.henderson@linaro.org>
2021-06-18 19:29 ` [PATCH v2 02/23] linux-user/aarch64: Implement setup_sigtramp Richard Henderson
@ 2021-06-18 19:29 ` Richard Henderson
2021-06-29 13:53 ` Peter Maydell
2021-06-18 19:29 ` [PATCH v2 04/23] linux-user/arm: Force v2 frames for fdpic Richard Henderson
2021-06-18 19:29 ` [PATCH v2 05/23] linux-user/arm: Implement setup_sigtramp Richard Henderson
3 siblings, 1 reply; 11+ messages in thread
From: Richard Henderson @ 2021-06-18 19:29 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, alex.bennee, qemu-arm
Split out a helper function to test for a v2 signal frame.
Cc: qemu-arm@nongnu.org
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/arm/signal.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c
index 32b68ee302..cb65623965 100644
--- a/linux-user/arm/signal.c
+++ b/linux-user/arm/signal.c
@@ -165,6 +165,11 @@ static inline int valid_user_regs(CPUARMState *regs)
return 1;
}
+static bool v2_frame(void)
+{
+ return get_osversion() >= 0x020612;
+}
+
static void
setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/
CPUARMState *env, abi_ulong mask)
@@ -422,7 +427,7 @@ sigsegv:
void setup_frame(int usig, struct target_sigaction *ka,
target_sigset_t *set, CPUARMState *regs)
{
- if (get_osversion() >= 0x020612) {
+ if (v2_frame()) {
setup_frame_v2(usig, ka, set, regs);
} else {
setup_frame_v1(usig, ka, set, regs);
@@ -516,7 +521,7 @@ void setup_rt_frame(int usig, struct target_sigaction *ka,
target_siginfo_t *info,
target_sigset_t *set, CPUARMState *env)
{
- if (get_osversion() >= 0x020612) {
+ if (v2_frame()) {
setup_rt_frame_v2(usig, ka, info, set, env);
} else {
setup_rt_frame_v1(usig, ka, info, set, env);
@@ -734,7 +739,7 @@ badframe:
long do_sigreturn(CPUARMState *env)
{
- if (get_osversion() >= 0x020612) {
+ if (v2_frame()) {
return do_sigreturn_v2(env);
} else {
return do_sigreturn_v1(env);
@@ -823,7 +828,7 @@ badframe:
long do_rt_sigreturn(CPUARMState *env)
{
- if (get_osversion() >= 0x020612) {
+ if (v2_frame()) {
return do_rt_sigreturn_v2(env);
} else {
return do_rt_sigreturn_v1(env);
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 04/23] linux-user/arm: Force v2 frames for fdpic
[not found] <20210618192951.125651-1-richard.henderson@linaro.org>
2021-06-18 19:29 ` [PATCH v2 02/23] linux-user/aarch64: Implement setup_sigtramp Richard Henderson
2021-06-18 19:29 ` [PATCH v2 03/23] linux-user/arm: Split out v2_frame Richard Henderson
@ 2021-06-18 19:29 ` Richard Henderson
2021-06-29 13:54 ` Peter Maydell
2021-06-18 19:29 ` [PATCH v2 05/23] linux-user/arm: Implement setup_sigtramp Richard Henderson
3 siblings, 1 reply; 11+ messages in thread
From: Richard Henderson @ 2021-06-18 19:29 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, alex.bennee, qemu-arm
The value of get_os_release may be controlled by a command
line option. Since fdpic was added in v4.14, and v2 frame
were added in v2.6.12, this makes no change under normal conditions.
Cc: qemu-arm@nongnu.org
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/arm/signal.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c
index cb65623965..2d30345fc2 100644
--- a/linux-user/arm/signal.c
+++ b/linux-user/arm/signal.c
@@ -167,7 +167,14 @@ static inline int valid_user_regs(CPUARMState *regs)
static bool v2_frame(void)
{
- return get_osversion() >= 0x020612;
+ /*
+ * We do not create fdpic trampolines for v1 frames.
+ * Thus we force v2 frames, regardless of what uname says.
+ * Support for fdpic dates from Linux 4.14, so this is not
+ * really a behaviour change.
+ */
+ int is_fdpic = info_is_fdpic(((TaskState *)thread_cpu->opaque)->info);
+ return is_fdpic || get_osversion() >= 0x020612;
}
static void
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 05/23] linux-user/arm: Implement setup_sigtramp
[not found] <20210618192951.125651-1-richard.henderson@linaro.org>
` (2 preceding siblings ...)
2021-06-18 19:29 ` [PATCH v2 04/23] linux-user/arm: Force v2 frames for fdpic Richard Henderson
@ 2021-06-18 19:29 ` Richard Henderson
2021-06-29 14:09 ` Peter Maydell
3 siblings, 1 reply; 11+ messages in thread
From: Richard Henderson @ 2021-06-18 19:29 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, alex.bennee, qemu-arm
ARM is more complicated than the others, in that we also
have trampolines for using SA_RESTORER with FDPIC, and
we need to create trampolines for both ARM and Thumb modes.
Cc: qemu-arm@nongnu.org
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/arm/target_signal.h | 2 +
linux-user/arm/signal.c | 170 +++++++++++++++++++--------------
2 files changed, 100 insertions(+), 72 deletions(-)
diff --git a/linux-user/arm/target_signal.h b/linux-user/arm/target_signal.h
index 0998dd6dfa..1e7fb0cecb 100644
--- a/linux-user/arm/target_signal.h
+++ b/linux-user/arm/target_signal.h
@@ -22,4 +22,6 @@ typedef struct target_sigaltstack {
#include "../generic/signal.h"
#define TARGET_ARCH_HAS_SETUP_FRAME
+#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
+
#endif /* ARM_TARGET_SIGNAL_H */
diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c
index 2d30345fc2..63bdd59ab9 100644
--- a/linux-user/arm/signal.c
+++ b/linux-user/arm/signal.c
@@ -101,13 +101,12 @@ struct sigframe_v1
{
struct target_sigcontext sc;
abi_ulong extramask[TARGET_NSIG_WORDS-1];
- abi_ulong retcode[4];
};
struct sigframe_v2
{
struct target_ucontext_v2 uc;
- abi_ulong retcode[4];
+ abi_ulong fdpic_ret;
};
struct rt_sigframe_v1
@@ -116,49 +115,20 @@ struct rt_sigframe_v1
abi_ulong puc;
struct target_siginfo info;
struct target_ucontext_v1 uc;
- abi_ulong retcode[4];
};
struct rt_sigframe_v2
{
struct target_siginfo info;
struct target_ucontext_v2 uc;
- abi_ulong retcode[4];
+ abi_ulong fdpic_ret;
};
/*
- * For ARM syscalls, we encode the syscall number into the instruction.
+ * Stubs needed to make sure the FD register (r9) contains the right value.
+ * There are 4 of them, each consuming 8 bytes.
*/
-#define SWI_SYS_SIGRETURN (0xef000000|(TARGET_NR_sigreturn + ARM_SYSCALL_BASE))
-#define SWI_SYS_RT_SIGRETURN (0xef000000|(TARGET_NR_rt_sigreturn + ARM_SYSCALL_BASE))
-
-/*
- * For Thumb syscalls, we pass the syscall number via r7. We therefore
- * need two 16-bit instructions.
- */
-#define SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_sigreturn))
-#define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_rt_sigreturn))
-
-static const abi_ulong retcodes[4] = {
- SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN,
- SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN
-};
-
-/*
- * Stub needed to make sure the FD register (r9) contains the right
- * value.
- */
-static const unsigned long sigreturn_fdpic_codes[3] = {
- 0xe59fc004, /* ldr r12, [pc, #4] to read function descriptor */
- 0xe59c9004, /* ldr r9, [r12, #4] to setup GOT */
- 0xe59cf000 /* ldr pc, [r12] to jump into restorer */
-};
-
-static const unsigned long sigreturn_fdpic_thumb_codes[3] = {
- 0xc008f8df, /* ldr r12, [pc, #8] to read function descriptor */
- 0x9004f8dc, /* ldr r9, [r12, #4] to setup GOT */
- 0xf000f8dc /* ldr pc, [r12] to jump into restorer */
-};
+static abi_ulong sigreturn_fdpic_tramp;
static inline int valid_user_regs(CPUARMState *regs)
{
@@ -219,13 +189,12 @@ get_sigframe(struct target_sigaction *ka, CPUARMState *regs, int framesize)
static int
setup_return(CPUARMState *env, struct target_sigaction *ka,
- abi_ulong *rc, abi_ulong frame_addr, int usig, abi_ulong rc_addr)
+ abi_ulong frame_addr, int usig)
{
abi_ulong handler = 0;
abi_ulong handler_fdpic_GOT = 0;
abi_ulong retcode;
-
- int thumb;
+ int thumb, retcode_idx;
int is_fdpic = info_is_fdpic(((TaskState *)thread_cpu->opaque)->info);
if (is_fdpic) {
@@ -243,6 +212,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka,
}
thumb = handler & 1;
+ retcode_idx = thumb + (ka->sa_flags & TARGET_SA_SIGINFO ? 2 : 0);
uint32_t cpsr = cpsr_read(env);
@@ -260,37 +230,24 @@ setup_return(CPUARMState *env, struct target_sigaction *ka,
if (ka->sa_flags & TARGET_SA_RESTORER) {
if (is_fdpic) {
- /* For FDPIC we ensure that the restorer is called with a
- * correct r9 value. For that we need to write code on
- * the stack that sets r9 and jumps back to restorer
- * value.
+ /*
+ * For FDPIC we ensure that the restorer is called with a
+ * correct r9 value. For that we use a special trampoline
+ * that reads the function descriptor from the frame,
+ * sets r9 and jumps back to restorer value.
*/
- if (thumb) {
- __put_user(sigreturn_fdpic_thumb_codes[0], rc);
- __put_user(sigreturn_fdpic_thumb_codes[1], rc + 1);
- __put_user(sigreturn_fdpic_thumb_codes[2], rc + 2);
- __put_user((abi_ulong)ka->sa_restorer, rc + 3);
- } else {
- __put_user(sigreturn_fdpic_codes[0], rc);
- __put_user(sigreturn_fdpic_codes[1], rc + 1);
- __put_user(sigreturn_fdpic_codes[2], rc + 2);
- __put_user((abi_ulong)ka->sa_restorer, rc + 3);
- }
-
- retcode = rc_addr + thumb;
+ abi_ulong fd_ofs = (retcode_idx & 2
+ ? offsetof(struct rt_sigframe_v2, fdpic_ret)
+ : offsetof(struct sigframe_v2, fdpic_ret));
+ put_user_ual(ka->sa_restorer, frame_addr + fd_ofs);
+ /* Each trampoline variant consumes 8-byte slot. */
+ retcode = sigreturn_fdpic_tramp + retcode_idx * 8 + thumb;
} else {
retcode = ka->sa_restorer;
}
} else {
- unsigned int idx = thumb;
-
- if (ka->sa_flags & TARGET_SA_SIGINFO) {
- idx += 2;
- }
-
- __put_user(retcodes[idx], rc);
-
- retcode = rc_addr + thumb;
+ /* Each trampoline variant consumes one 4-byte slot. */
+ retcode = default_sigreturn + retcode_idx * 4 + thumb;
}
env->regs[0] = usig;
@@ -394,8 +351,7 @@ static void setup_frame_v1(int usig, struct target_sigaction *ka,
__put_user(set->sig[i], &frame->extramask[i - 1]);
}
- if (setup_return(regs, ka, frame->retcode, frame_addr, usig,
- frame_addr + offsetof(struct sigframe_v1, retcode))) {
+ if (setup_return(regs, ka, frame_addr, usig)) {
goto sigsegv;
}
@@ -419,8 +375,7 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka,
setup_sigframe_v2(&frame->uc, set, regs);
- if (setup_return(regs, ka, frame->retcode, frame_addr, usig,
- frame_addr + offsetof(struct sigframe_v2, retcode))) {
+ if (setup_return(regs, ka, frame_addr, usig)) {
goto sigsegv;
}
@@ -475,8 +430,7 @@ static void setup_rt_frame_v1(int usig, struct target_sigaction *ka,
__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]);
}
- if (setup_return(env, ka, frame->retcode, frame_addr, usig,
- frame_addr + offsetof(struct rt_sigframe_v1, retcode))) {
+ if (setup_return(env, ka, frame_addr, usig)) {
goto sigsegv;
}
@@ -509,8 +463,7 @@ static void setup_rt_frame_v2(int usig, struct target_sigaction *ka,
setup_sigframe_v2(&frame->uc, set, env);
- if (setup_return(env, ka, frame->retcode, frame_addr, usig,
- frame_addr + offsetof(struct rt_sigframe_v2, retcode))) {
+ if (setup_return(env, ka, frame_addr, usig)) {
goto sigsegv;
}
@@ -841,3 +794,76 @@ long do_rt_sigreturn(CPUARMState *env)
return do_rt_sigreturn_v1(env);
}
}
+
+void setup_sigtramp(abi_ulong sigtramp_page)
+{
+ enum {
+ /* For ARM, we encode the syscall number into the instruction. */
+ SWI_SYS_SIGRETURN =
+ 0xef000000 | (TARGET_NR_sigreturn + ARM_SYSCALL_BASE),
+ SWI_SYS_RT_SIGRETURN =
+ 0xef000000 | (TARGET_NR_rt_sigreturn + ARM_SYSCALL_BASE),
+
+ /*
+ * For Thumb , we pass the syscall number via r7.
+ * We therefore need two 16-bit instructions.
+ */
+ SWI_THUMB_SIGRETURN =
+ 0xdf00 << 16 | 0x2700 | TARGET_NR_sigreturn,
+ SWI_THUMB_RT_SIGRETURN =
+ 0xdf00 << 16 | 0x2700 | TARGET_NR_rt_sigreturn,
+
+ SIGFRAME_FDPIC_OFS = offsetof(struct sigframe_v2, fdpic_ret),
+ RT_SIGFRAME_FDPIC_OFS = offsetof(struct rt_sigframe_v2, fdpic_ret),
+ };
+
+ uint32_t total_size = 4 * 4 + 2 * 8;
+ uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, total_size, 0);
+ uint32_t i = 0;
+
+ assert(tramp != NULL);
+
+ default_sigreturn = sigtramp_page;
+ __put_user(SWI_SYS_SIGRETURN, &tramp[i++]);
+ __put_user(SWI_THUMB_SIGRETURN, &tramp[i++]);
+ __put_user(SWI_SYS_RT_SIGRETURN, &tramp[i++]);
+ __put_user(SWI_THUMB_RT_SIGRETURN, &tramp[i++]);
+
+ /*
+ * FDPIC require trampolines to call sa_restorer.
+ *
+ * ARM versions use:
+ * ldr r9, [sp, #ofs]
+ * ldmia r9, {r9, pc}
+ *
+ * Thumb versions use:
+ * ldrd r9, r10, [sp, #ofs]
+ * bx r10
+ * nop
+ */
+ sigreturn_fdpic_tramp = sigtramp_page + i * 4;
+
+ /* ARM sigframe */
+ QEMU_BUILD_BUG_ON(SIGFRAME_FDPIC_OFS > 0xfff);
+ __put_user(0xe59d9000 | SIGFRAME_FDPIC_OFS, &tramp[i++]);
+ __put_user(0xe8998200, &tramp[i++]);
+
+ /* Thumb sigframe */
+ QEMU_BUILD_BUG_ON(SIGFRAME_FDPIC_OFS > 0xff << 2);
+ QEMU_BUILD_BUG_ON(SIGFRAME_FDPIC_OFS & 3);
+ __put_user(0x9a00e9dd | (SIGFRAME_FDPIC_OFS << 14), &tramp[i++]);
+ __put_user(0x46c04750, &tramp[i++]);
+
+ /* ARM rt_sigframe */
+ QEMU_BUILD_BUG_ON(RT_SIGFRAME_FDPIC_OFS > 0xfff);
+ __put_user(0xe59d9000 | RT_SIGFRAME_FDPIC_OFS, &tramp[i++]);
+ __put_user(0xe8998200, &tramp[i++]);
+
+ /* Thumb rt_sigframe */
+ QEMU_BUILD_BUG_ON(RT_SIGFRAME_FDPIC_OFS > 0xff << 2);
+ QEMU_BUILD_BUG_ON(RT_SIGFRAME_FDPIC_OFS & 3);
+ __put_user(0x9a00e9dd | (RT_SIGFRAME_FDPIC_OFS << 14), &tramp[i++]);
+ __put_user(0x46c04750, &tramp[i++]);
+
+ unlock_user(tramp, sigtramp_page, total_size);
+}
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 02/23] linux-user/aarch64: Implement setup_sigtramp
2021-06-18 19:29 ` [PATCH v2 02/23] linux-user/aarch64: Implement setup_sigtramp Richard Henderson
@ 2021-06-29 13:36 ` Peter Maydell
2021-07-01 19:27 ` Richard Henderson
0 siblings, 1 reply; 11+ messages in thread
From: Peter Maydell @ 2021-06-29 13:36 UTC (permalink / raw)
To: Richard Henderson
Cc: Philippe Mathieu-Daudé, qemu-arm, QEMU Developers,
Laurent Vivier
On Fri, 18 Jun 2021 at 20:33, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Create and record the rt signal trampoline.
> Use it when the guest does not use SA_RESTORER.
>
> Cc: qemu-arm@nongnu.org
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> linux-user/aarch64/target_signal.h | 2 ++
> linux-user/aarch64/signal.c | 28 ++++++++++++++++++----------
> 2 files changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/linux-user/aarch64/target_signal.h b/linux-user/aarch64/target_signal.h
> index 18013e1b23..7580d99403 100644
> --- a/linux-user/aarch64/target_signal.h
> +++ b/linux-user/aarch64/target_signal.h
> @@ -25,4 +25,6 @@ typedef struct target_sigaltstack {
> #define TARGET_SEGV_MTESERR 9 /* Synchronous ARM MTE exception */
>
> #define TARGET_ARCH_HAS_SETUP_FRAME
> +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
> +
> #endif /* AARCH64_TARGET_SIGNAL_H */
> diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
> index 662bcd1c4e..65b84eb04e 100644
> --- a/linux-user/aarch64/signal.c
> +++ b/linux-user/aarch64/signal.c
> @@ -108,7 +108,6 @@ struct target_rt_sigframe {
> struct target_rt_frame_record {
> uint64_t fp;
> uint64_t lr;
> - uint32_t tramp[2];
> };
>
> static void target_setup_general_frame(struct target_rt_sigframe *sf,
> @@ -495,15 +494,7 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
A little way up from here there's a comment:
/* Reserve space for the return code. On a real system this would
* be within the VDSO. So, despite the name this is not a "real"
* record within the frame.
*/
fr_ofs = layout.total_size;
layout.total_size += sizeof(struct target_rt_frame_record);
That now needs updating, because we're no longer putting the return
code in that target_rt_frame_record.
I think the 'struct target_rt_frame_record' now does correspond
to the kernel's 'struct frame_record', right?
Otherwise
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 03/23] linux-user/arm: Split out v2_frame
2021-06-18 19:29 ` [PATCH v2 03/23] linux-user/arm: Split out v2_frame Richard Henderson
@ 2021-06-29 13:53 ` Peter Maydell
2021-06-29 14:30 ` Richard Henderson
0 siblings, 1 reply; 11+ messages in thread
From: Peter Maydell @ 2021-06-29 13:53 UTC (permalink / raw)
To: Richard Henderson
Cc: QEMU Developers, qemu-arm, Alex Bennée, Laurent Vivier
On Fri, 18 Jun 2021 at 20:32, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Split out a helper function to test for a v2 signal frame.
>
> Cc: qemu-arm@nongnu.org
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> linux-user/arm/signal.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c
> index 32b68ee302..cb65623965 100644
> --- a/linux-user/arm/signal.c
> +++ b/linux-user/arm/signal.c
> @@ -165,6 +165,11 @@ static inline int valid_user_regs(CPUARMState *regs)
> return 1;
> }
>
> +static bool v2_frame(void)
> +{
> + return get_osversion() >= 0x020612;
> +}
Not sure how much we care about supporting claiming to be a 15-year-old
kernel any more (especially since we set UNAME_MINIMUM_RELEASE to 2.6.32...)
so it's awfully tempting to just blow away the v1 frame support instead...
Anyway
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 04/23] linux-user/arm: Force v2 frames for fdpic
2021-06-18 19:29 ` [PATCH v2 04/23] linux-user/arm: Force v2 frames for fdpic Richard Henderson
@ 2021-06-29 13:54 ` Peter Maydell
0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2021-06-29 13:54 UTC (permalink / raw)
To: Richard Henderson
Cc: QEMU Developers, qemu-arm, Alex Bennée, Laurent Vivier
On Fri, 18 Jun 2021 at 20:32, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> The value of get_os_release may be controlled by a command
> line option. Since fdpic was added in v4.14, and v2 frame
> were added in v2.6.12, this makes no change under normal conditions.
>
> Cc: qemu-arm@nongnu.org
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 05/23] linux-user/arm: Implement setup_sigtramp
2021-06-18 19:29 ` [PATCH v2 05/23] linux-user/arm: Implement setup_sigtramp Richard Henderson
@ 2021-06-29 14:09 ` Peter Maydell
2021-06-29 18:32 ` Richard Henderson
0 siblings, 1 reply; 11+ messages in thread
From: Peter Maydell @ 2021-06-29 14:09 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-arm, QEMU Developers, Laurent Vivier
On Fri, 18 Jun 2021 at 20:33, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> ARM is more complicated than the others, in that we also
> have trampolines for using SA_RESTORER with FDPIC, and
> we need to create trampolines for both ARM and Thumb modes.
>
> Cc: qemu-arm@nongnu.org
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> linux-user/arm/target_signal.h | 2 +
> linux-user/arm/signal.c | 170 +++++++++++++++++++--------------
> 2 files changed, 100 insertions(+), 72 deletions(-)
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
though I'm not 100% confident I checked all the details. Do you have
test programs that checked all the different trampolines ?
thanks
-- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 03/23] linux-user/arm: Split out v2_frame
2021-06-29 13:53 ` Peter Maydell
@ 2021-06-29 14:30 ` Richard Henderson
0 siblings, 0 replies; 11+ messages in thread
From: Richard Henderson @ 2021-06-29 14:30 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers, qemu-arm, Alex Bennée, Laurent Vivier
On 6/29/21 6:53 AM, Peter Maydell wrote:
> On Fri, 18 Jun 2021 at 20:32, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> Split out a helper function to test for a v2 signal frame.
>>
>> Cc: qemu-arm@nongnu.org
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> linux-user/arm/signal.c | 13 +++++++++----
>> 1 file changed, 9 insertions(+), 4 deletions(-)
>>
>> diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c
>> index 32b68ee302..cb65623965 100644
>> --- a/linux-user/arm/signal.c
>> +++ b/linux-user/arm/signal.c
>> @@ -165,6 +165,11 @@ static inline int valid_user_regs(CPUARMState *regs)
>> return 1;
>> }
>>
>> +static bool v2_frame(void)
>> +{
>> + return get_osversion() >= 0x020612;
>> +}
>
> Not sure how much we care about supporting claiming to be a 15-year-old
> kernel any more (especially since we set UNAME_MINIMUM_RELEASE to 2.6.32...)
> so it's awfully tempting to just blow away the v1 frame support instead...
>
> Anyway
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
I hadn't noticed the minimum release setting. Yes, I think it would be better to remove
the v1 support instead of bodging around it like this.
r~
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 05/23] linux-user/arm: Implement setup_sigtramp
2021-06-29 14:09 ` Peter Maydell
@ 2021-06-29 18:32 ` Richard Henderson
0 siblings, 0 replies; 11+ messages in thread
From: Richard Henderson @ 2021-06-29 18:32 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-arm, QEMU Developers, Laurent Vivier
On 6/29/21 7:09 AM, Peter Maydell wrote:
> On Fri, 18 Jun 2021 at 20:33, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> ARM is more complicated than the others, in that we also
>> have trampolines for using SA_RESTORER with FDPIC, and
>> we need to create trampolines for both ARM and Thumb modes.
>>
>> Cc: qemu-arm@nongnu.org
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> linux-user/arm/target_signal.h | 2 +
>> linux-user/arm/signal.c | 170 +++++++++++++++++++--------------
>> 2 files changed, 100 insertions(+), 72 deletions(-)
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> though I'm not 100% confident I checked all the details. Do you have
> test programs that checked all the different trampolines ?
No, I have no fdpic testcases, and wasn't keen to spend an afternoon building the toolchain.
r~
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 02/23] linux-user/aarch64: Implement setup_sigtramp
2021-06-29 13:36 ` Peter Maydell
@ 2021-07-01 19:27 ` Richard Henderson
0 siblings, 0 replies; 11+ messages in thread
From: Richard Henderson @ 2021-07-01 19:27 UTC (permalink / raw)
To: Peter Maydell
Cc: Philippe Mathieu-Daudé, qemu-arm, QEMU Developers,
Laurent Vivier
On 6/29/21 6:36 AM, Peter Maydell wrote:
> A little way up from here there's a comment:
>
> /* Reserve space for the return code. On a real system this would
> * be within the VDSO. So, despite the name this is not a "real"
> * record within the frame.
> */
> fr_ofs = layout.total_size;
> layout.total_size += sizeof(struct target_rt_frame_record);
>
> That now needs updating, because we're no longer putting the return
> code in that target_rt_frame_record.
Updated to
/*
* Reserve space for the standard frame unwind pair: fp, lr.
* Despite the name this is not a "real" record within the frame.
*/
> I think the 'struct target_rt_frame_record' now does correspond
> to the kernel's 'struct frame_record', right?
Yes.
r~
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-07-01 19:27 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20210618192951.125651-1-richard.henderson@linaro.org>
2021-06-18 19:29 ` [PATCH v2 02/23] linux-user/aarch64: Implement setup_sigtramp Richard Henderson
2021-06-29 13:36 ` Peter Maydell
2021-07-01 19:27 ` Richard Henderson
2021-06-18 19:29 ` [PATCH v2 03/23] linux-user/arm: Split out v2_frame Richard Henderson
2021-06-29 13:53 ` Peter Maydell
2021-06-29 14:30 ` Richard Henderson
2021-06-18 19:29 ` [PATCH v2 04/23] linux-user/arm: Force v2 frames for fdpic Richard Henderson
2021-06-29 13:54 ` Peter Maydell
2021-06-18 19:29 ` [PATCH v2 05/23] linux-user/arm: Implement setup_sigtramp Richard Henderson
2021-06-29 14:09 ` Peter Maydell
2021-06-29 18:32 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).