qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Song Gao <gaosong@loongson.cn>, qemu-devel@nongnu.org
Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>, laurent@vivier.eu
Subject: Re: [PATCH v11 19/26] linux-user: Add LoongArch signal support
Date: Sat, 20 Nov 2021 11:33:41 +0100	[thread overview]
Message-ID: <9195824d-31d2-f2e8-610b-f8f86d687707@linaro.org> (raw)
In-Reply-To: <1637302410-24632-20-git-send-email-gaosong@loongson.cn>

On 11/19/21 7:13 AM, Song Gao wrote:
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
> ---
>   linux-user/loongarch64/signal.c        | 162 +++++++++++++++++++++++++++++++++
>   linux-user/loongarch64/target_signal.h |  29 ++++++
>   2 files changed, 191 insertions(+)
>   create mode 100644 linux-user/loongarch64/signal.c
>   create mode 100644 linux-user/loongarch64/target_signal.h
> 
> diff --git a/linux-user/loongarch64/signal.c b/linux-user/loongarch64/signal.c
> new file mode 100644
> index 0000000..8fbc827
> --- /dev/null
> +++ b/linux-user/loongarch64/signal.c
> @@ -0,0 +1,162 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * LoongArch emulation of Linux signals
> + *
> + * Copyright (c) 2021 Loongson Technology Corporation Limited
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu.h"
> +#include "signal-common.h"
> +#include "user-internals.h"
> +#include "linux-user/trace.h"
> +
> +struct target_sigcontext {
> +    uint64_t   sc_pc;
> +    uint64_t   sc_gpr[32];
> +    uint64_t   sc_fpr[32];
> +    uint64_t   sc_fcc;
> +    uint32_t   sc_fcsr;
> +    uint32_t   sc_flags;
> +};

Does not match
https://github.com/loongson/linux/blob/loongarch-next/arch/loongarch/include/uapi/asm/sigcontext.h

> +
> +struct target_ucontext {
> +    target_ulong tuc_flags;
> +    target_ulong tuc_link;
> +    target_stack_t tuc_stack;
> +    target_ulong pad0;
> +    struct target_sigcontext tuc_mcontext;
> +    target_sigset_t tuc_sigmask;
> +};

Does not match
https://github.com/loongson/linux/blob/loongarch-next/arch/loongarch/include/uapi/asm/ucontext.h

> +static inline void setup_sigcontext(CPULoongArchState *env,
> +                                    struct target_sigcontext *sc)

Drop all of the the inline markers.

> +{
> +    int i;
> +
> +    __put_user(env->pc, &sc->sc_pc);
> +
> +    __put_user(0, &sc->sc_gpr[0]);
> +    for (i = 1; i < 32; ++i) {
> +        __put_user(env->gpr[i], &sc->sc_gpr[i]);
> +    }
> +
> +    for (i = 0; i < 32; ++i) {
> +        __put_user(env->fpr[i], &sc->sc_fpr[i]);
> +    }
> +}

Missing fcsr and fcc.

I'll note that the kernel is missing sets of vscr and scr[0-3].  IMO they should at least 
be zeroed in advance of supporting the vector extension.

> +static inline void
> +restore_sigcontext(CPULoongArchState *env, struct target_sigcontext *sc)
> +{
> +    int i;
> +
> +    __get_user(env->pc, &sc->sc_pc);
> +
> +    for (i = 1; i < 32; ++i) {
> +        __get_user(env->gpr[i], &sc->sc_gpr[i]);
> +    }
> +
> +    for (i = 0; i < 32; ++i) {
> +        __get_user(env->fpr[i], &sc->sc_fpr[i]);
> +    }
> +}

Similarly.

> +    return (sp - frame_size) & ~7;

include/asm/asm.h:#define ALMASK        ~15
kernel/signal.c:        return (void __user *)((sp - frame_size) & ALMASK);

> +    env->pc = env->gpr[20] = ka->_sa_handler;

There is no set of gpr[20].

> +void setup_sigtramp(abi_ulong sigtramp_page)
> +{
> +    uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0);
> +    assert(tramp != NULL);
> +
> +    __put_user(0x03822c0b, tramp + 0);  /* ori     a7, a7, 0x8b */

The comment is incorrect: "ori a7, zero, 0x8b", but the hex is right.

> +/* this struct defines a stack used during syscall handling */
> +typedef struct target_sigaltstack {
> +        abi_long ss_sp;
> +        abi_int ss_flags;
> +        abi_ulong ss_size;
> +} target_stack_t;
> +
> +/*
> + * sigaltstack controls
> + */
> +#define TARGET_SS_ONSTACK     1
> +#define TARGET_SS_DISABLE     2
> +
> +#define TARGET_MINSIGSTKSZ    2048
> +#define TARGET_SIGSTKSZ       8192

We should move these to generic/signal.h.


r~


  reply	other threads:[~2021-11-20 10:34 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19  6:13 [PATCH v11 00/26] Add LoongArch linux-user emulation support Song Gao
2021-11-19  6:13 ` [PATCH v11 01/26] target/loongarch: Add README Song Gao
2021-11-19  6:13 ` [PATCH v11 02/26] target/loongarch: Add core definition Song Gao
2021-11-19  6:13 ` [PATCH v11 03/26] target/loongarch: Add main translation routines Song Gao
2021-11-19  6:13 ` [PATCH v11 04/26] target/loongarch: Add fixed point arithmetic instruction translation Song Gao
2021-11-20  7:10   ` Richard Henderson
2021-11-20  7:17   ` Richard Henderson
2021-11-20  8:52     ` gaosong
2021-11-20  8:56       ` Richard Henderson
2021-11-22  8:23         ` gaosong
2021-11-22  8:28           ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 05/26] target/loongarch: Add fixed point shift " Song Gao
2021-11-20  7:42   ` Richard Henderson
2021-11-20  9:03     ` gaosong
2021-11-19  6:13 ` [PATCH v11 06/26] target/loongarch: Add fixed point bit " Song Gao
2021-11-20  8:05   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 07/26] target/loongarch: Add fixed point load/store " Song Gao
2021-11-20  8:20   ` Richard Henderson
2021-11-20  9:39     ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 08/26] target/loongarch: Add fixed point atomic " Song Gao
2021-11-20  8:30   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 09/26] target/loongarch: Add fixed point extra " Song Gao
2021-11-20  8:52   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 10/26] target/loongarch: Add floating point arithmetic " Song Gao
2021-11-20  8:54   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 11/26] target/loongarch: Add floating point comparison " Song Gao
2021-11-20  9:02   ` Richard Henderson
2021-11-30  8:22     ` gaosong
2021-11-30  8:37       ` Richard Henderson
2021-11-30  8:50         ` gaosong
2021-11-19  6:13 ` [PATCH v11 12/26] target/loongarch: Add floating point conversion " Song Gao
2021-11-19  6:13 ` [PATCH v11 13/26] target/loongarch: Add floating point move " Song Gao
2021-11-19  6:13 ` [PATCH v11 14/26] target/loongarch: Add floating point load/store " Song Gao
2021-11-20  9:36   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 15/26] target/loongarch: Add branch " Song Gao
2021-11-20  9:46   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 16/26] target/loongarch: Add disassembler Song Gao
2021-11-20  9:53   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 17/26] linux-user: Add LoongArch generic header files Song Gao
2021-11-20  9:54   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 18/26] linux-user: Add LoongArch specific structures Song Gao
2021-11-20 10:06   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 19/26] linux-user: Add LoongArch signal support Song Gao
2021-11-20 10:33   ` Richard Henderson [this message]
2021-11-22 11:41     ` gaosong
2021-11-22 11:44       ` chen huacai
2021-11-22 12:31       ` Richard Henderson
2021-11-24  2:46     ` gaosong
2021-11-24  7:27       ` Richard Henderson
2021-11-24  7:50         ` gaosong
2021-11-24  9:40           ` Richard Henderson
2021-11-24 10:22     ` gaosong
2021-11-24 10:44       ` Richard Henderson
2021-11-25  3:03     ` gaosong
2021-11-25 10:11       ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 20/26] linux-user: Add LoongArch elf support Song Gao
2021-11-20 10:35   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 21/26] linux-user: Add LoongArch syscall support Song Gao
2021-11-20 10:47   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 22/26] linux-user: Add LoongArch cpu_loop support Song Gao
2021-11-20 10:53   ` Richard Henderson
2021-11-19  6:13 ` [PATCH v11 23/26] default-configs: Add loongarch linux-user support Song Gao
2021-11-19  6:13 ` [PATCH v11 24/26] target/loongarch: Add target build suport Song Gao
2021-11-19  6:13 ` [PATCH v11 25/26] target/loongarch: 'make check-tcg' support Song Gao
2021-11-19  6:13 ` [PATCH v11 26/26] scripts: add loongarch64 binfmt config Song Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9195824d-31d2-f2e8-610b-f8f86d687707@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=gaosong@loongson.cn \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=yangxiaojuan@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).