[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v18 02/13] linux-user: Add LoongArch signal support
From: |
Richard Henderson |
Subject: |
Re: [PATCH v18 02/13] linux-user: Add LoongArch signal support |
Date: |
Mon, 20 Jun 2022 09:23:32 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 |
On 6/20/22 02:33, Song Gao wrote:
+static int restore_sigcontext(CPULoongArchState *env,
+ struct target_sigcontext *sc)
+{
+ int i;
+ int ret = 0;
+ struct extctx_layout extctx;
+
+ memset(&extctx, 0, sizeof(struct extctx_layout));
+
+ __get_user(extctx.flags, &sc->sc_flags);
+
+ ret = parse_extcontext(sc, &extctx);
+ if (ret < 0) {
+ goto bad;
+ }
+
+ __get_user(env->pc, &sc->sc_pc);
+ for (i = 1; i < 32; ++i) {
+ __get_user(env->gpr[i], &sc->sc_regs[i]);
+ }
+
+ if (extctx.fpu.addr) {
+ copy_fpu_from_sigcontext(env, &extctx);
+ restore_fp_status(env);
+ }
+bad:
+ return ret;
+}
This is missing lock_user/unlock_user somewhere.
You can't use the double-underscore __get/__put_user without having done that.
You can use the non-underscore get_user in parse_extcontext, and separately lock the
target_fpu_context. Failures must goto invalid.
+void setup_rt_frame(int sig, struct target_sigaction *ka,
+ target_siginfo_t *info,
+ target_sigset_t *set, CPULoongArchState *env)
+{
+ struct target_rt_sigframe *frame;
+ struct extctx_layout extctx;
+ abi_ulong frame_addr;
+ int i;
+
+ frame_addr = get_sigframe(ka, env, sizeof(*frame), &extctx);
+ trace_user_setup_rt_frame(env, frame_addr);
+ if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
+ goto give_sigsegv;
+ }
Similarly, this lock...
+
+ tswap_siginfo(&frame->rs_info, info);
+
+ __put_user(0, &frame->rs_uc.tuc_flags);
+ __put_user(0, &frame->rs_uc.tuc_link);
+ target_save_altstack(&frame->rs_uc.tuc_stack, env);
+
+ setup_sigcontext(env, &frame->rs_uc.tuc_mcontext, &extctx);
... fails to cover the extra memory allocated for extctx.
This is why I suggested statically allocating the extra
pieces of the signal frame *on write*. You obviously
cannot rely on the signal frame being identical on
signal return -- the guest is allowed to create any valid
context to give to rt_sigreturn.
r~
- [PATCH v18 05/13] linux-user: Add LoongArch cpu_loop support, (continued)
- [PATCH v18 05/13] linux-user: Add LoongArch cpu_loop support, Song Gao, 2022/06/20
- [PATCH v18 06/13] scripts: add loongarch64 binfmt config, Song Gao, 2022/06/20
- [PATCH v18 01/13] linux-user: Add LoongArch generic header files, Song Gao, 2022/06/20
- [PATCH v18 09/13] target/loongarch: Fix helper_asrtle_d/asrtgt_d raise wrong exception, Song Gao, 2022/06/20
- [PATCH v18 07/13] target/loongarch: remove badaddr from CPULoongArch, Song Gao, 2022/06/20
- [PATCH v18 04/13] linux-user: Add LoongArch syscall support, Song Gao, 2022/06/20
- [PATCH v18 03/13] linux-user: Add LoongArch elf support, Song Gao, 2022/06/20
- [PATCH v18 13/13] target/loongarch: Update README, Song Gao, 2022/06/20
- [PATCH v18 11/13] target/loongarch: Adjust functions and structure to support user-mode, Song Gao, 2022/06/20
- [PATCH v18 02/13] linux-user: Add LoongArch signal support, Song Gao, 2022/06/20
- Re: [PATCH v18 02/13] linux-user: Add LoongArch signal support,
Richard Henderson <=
- [PATCH v18 08/13] target/loongarch: Fix missing update CSR_BADV, Song Gao, 2022/06/20
- [PATCH v18 10/13] target/loongarch: remove unused include hw/loader.h, Song Gao, 2022/06/20
- [PATCH v18 12/13] default-configs: Add loongarch linux-user support, Song Gao, 2022/06/20