qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v17 02/13] linux-user: Add LoongArch signal support


From: Richard Henderson
Subject: Re: [PATCH v17 02/13] linux-user: Add LoongArch signal support
Date: Fri, 17 Jun 2022 19:47:03 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

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~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]