From: Richard Henderson <richard.henderson@linaro.org>
To: Song Gao <gaosong@loongson.cn>, qemu-devel@nongnu.org
Cc: philmd@redhat.com, laurent@vivier.e, maobibo@loongson.cn,
yangxiaojuan@loongson.cn, laurent@vivier.eu
Subject: Re: [PATCH v1 5/6] linux-user/loongarch64: Add LSX sigcontext save/restore
Date: Sat, 28 Oct 2023 14:35:23 -0700 [thread overview]
Message-ID: <b2335b60-b2f5-4ece-ab75-079fac4f7f9b@linaro.org> (raw)
In-Reply-To: <20231010033701.385725-6-gaosong@loongson.cn>
On 10/9/23 20:37, Song Gao wrote:
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> ---
> linux-user/loongarch64/signal.c | 107 ++++++++++++++++++++++++++------
> 1 file changed, 87 insertions(+), 20 deletions(-)
>
> diff --git a/linux-user/loongarch64/signal.c b/linux-user/loongarch64/signal.c
> index 277e9f5757..4b09e50a5f 100644
> --- a/linux-user/loongarch64/signal.c
> +++ b/linux-user/loongarch64/signal.c
> @@ -33,6 +33,14 @@ struct target_fpu_context {
> uint32_t fcsr;
> } QEMU_ALIGNED(FPU_CTX_ALIGN);
>
> +#define LSX_CTX_MAGIC 0x53580001
> +#define LSX_CTX_ALIGN 16
> +struct target_lsx_context {
> + uint64_t regs[2 * 32];
> + uint64_t fcc;
> + uint32_t fcsr;
> +} QEMU_ALIGNED(LSX_CTX_ALIGN);
It probably doesn't matter here because fo the alignment, but all types within target
structures should be using abi_{ullong,uint} etc.
> @@ -99,8 +109,15 @@ static abi_ptr setup_extcontext(struct extctx_layout *extctx, abi_ptr sp)
>
> /* For qemu, there is no lazy fp context switch, so fp always present. */
> extctx->flags = SC_USED_FP;
> - sp = extframe_alloc(extctx, &extctx->fpu,
> +
> + if (env->extctx_flags & EXTCTX_FLAGS_LSX) {
> + sp = extframe_alloc(extctx, &extctx->lsx,
> + sizeof(struct target_lsx_context), LSX_CTX_ALIGN, sp);
> +
> + } else if (env->extctx_flags & EXTCTX_FLAGS_FPU) {
> + sp = extframe_alloc(extctx, &extctx->fpu,
> sizeof(struct target_fpu_context), FPU_CTX_ALIGN, sp);
> + }
I think this is overly complicated. (1) The fpu is always present, and (2) you don't need
a special flag on env, you can check the same CSR bits as for system mode.
I'll note that while this layout matches the kernel, it is an unfortunate set of data
structures. Any program has to look for all of {FPU,LSX,LASX}_CTX_MAGIC in order to find
the basic fp registers.
r~
next prev parent reply other threads:[~2023-10-28 21:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 3:36 [PATCH v1 0/6] linux-user/loongarch64: Add LSX/LASX sigcontext Song Gao
2023-10-10 3:36 ` [PATCH v1 1/6] target/loongarch: Add env->extctx_flags for user-mode setup extcontext Song Gao
2023-10-10 3:36 ` [PATCH v1 2/6] target/loongarch: Add set_vec_extctx to set LSX/LASX instructions extctx_flags Song Gao
2023-10-28 21:40 ` Richard Henderson
2023-10-30 3:28 ` gaosong
2023-10-30 15:30 ` Richard Henderson
2023-10-31 6:16 ` gaosong
2023-10-31 14:50 ` Richard Henderson
2023-11-01 1:49 ` gaosong
2023-10-10 3:36 ` [PATCH v1 3/6] linux-user/loongarch64: Fix setup_extcontext alloc wrong fpu_context size Song Gao
2023-10-28 21:18 ` Richard Henderson
2023-10-10 3:36 ` [PATCH v1 4/6] linux-user/loongarch64: setup_sigframe() set 'end' context size 0 Song Gao
2023-10-28 21:20 ` Richard Henderson
2023-10-10 3:37 ` [PATCH v1 5/6] linux-user/loongarch64: Add LSX sigcontext save/restore Song Gao
2023-10-28 21:35 ` Richard Henderson [this message]
2023-10-30 3:28 ` gaosong
2023-10-10 3:37 ` [PATCH v1 6/6] linux-user/loongarch64: Add LASX " Song Gao
2023-10-23 2:47 ` [PATCH v1 0/6] linux-user/loongarch64: Add LSX/LASX sigcontext gaosong
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=b2335b60-b2f5-4ece-ab75-079fac4f7f9b@linaro.org \
--to=richard.henderson@linaro.org \
--cc=gaosong@loongson.cn \
--cc=laurent@vivier.e \
--cc=laurent@vivier.eu \
--cc=maobibo@loongson.cn \
--cc=philmd@redhat.com \
--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).