On 6/16/22 05:16, Song Gao wrote:
+static void copy_fpu_to_sigcontext(CPULoongArchState *env, + struct extctx_layout *extctx) +{ + int i; + struct target_sctx_info *info = (struct target_sctx_info *)extctx->fpu.addr; + struct target_fpu_context *fpu_ctx = get_ctx(info); + + for (i = 1; i < 32; ++i) { + __put_user(env->fpr[i], &fpu_ctx->regs[i]); + } + + fpu_ctx->fcc = read_all_fcc(env); + __put_user(env->fcsr0, &fpu_ctx->fcsr); + __put_user(extctx->fpu.size, &info->size); +}
You've failed to set magic.
+ +static abi_ulong extframe_alloc(struct extctx_layout *extctx, + struct ctx_layout *layout, + size_t size, abi_ulong base) +{ + abi_ulong new_base = base - size; + + new_base -= sizeof(struct target_sctx_info);
Missing ROUND_DOWN.
+ layout->addr = new_base; + layout->size = (unsigned int)(base - new_base);
Cast not required.
+static int parse_extcontext(struct target_sigcontext *sc, + struct extctx_layout *extctx) +{ + unsigned int size; + struct target_sctx_info *info = (struct target_sctx_info *) + &sc->sc_extcontext; + + __get_user(size, &info->size); + + if (size < (sizeof(struct target_sctx_info) + + sizeof(struct target_fpu_context))) { + return -TARGET_EINVAL; + } + + extctx->fpu.addr = (abi_ulong)info; + info = (struct target_sctx_info *)((char *)info + size); + + return 0; +}
This does not even closely resemble the kernel's parse_extcontext. You *really* have to be more careful about this. r~