From: Richard Henderson <richard.henderson@linaro.org>
To: gaosong <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 2/6] target/loongarch: Add set_vec_extctx to set LSX/LASX instructions extctx_flags
Date: Tue, 31 Oct 2023 07:50:46 -0700 [thread overview]
Message-ID: <0d60c6d4-a785-4abd-a16a-279b50abf09d@linaro.org> (raw)
In-Reply-To: <4f952bcc-61c9-b3b6-d858-00c64167c292@loongson.cn>
[-- Attachment #1: Type: text/plain, Size: 472 bytes --]
On 10/30/23 23:16, gaosong wrote:
>> Anyway, I think my previous suggestion is better:
>>
> Oh, Could you show more details? I think I didn't get you point.
>
>>>> If you want to track what the program is using, you should do it exactly like the real
>>>> kernel: disable the execution unit, have the program trap, and the enable the
>>>> execution unit when the trap occurs. At this point, CSR_EUEN enable bits contain
Untested, but something like this.
r~
[-- Attachment #2: 0001-linux-user-loongarch64-Use-traps-to-track-LSX-LASX-u.patch --]
[-- Type: text/x-patch, Size: 2226 bytes --]
From 2a5b55a33bc6133cd318856b95b844162779beaf Mon Sep 17 00:00:00 2001
From: Richard Henderson <richard.henderson@linaro.org>
Date: Tue, 31 Oct 2023 07:46:54 -0700
Subject: [PATCH] linux-user/loongarch64: Use traps to track LSX/LASX usage
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/loongarch64/cpu_loop.c | 13 +++++++++++++
target/loongarch/insn_trans/trans_vec.c.inc | 11 -----------
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/linux-user/loongarch64/cpu_loop.c b/linux-user/loongarch64/cpu_loop.c
index 894fdd111a..73d7b6796a 100644
--- a/linux-user/loongarch64/cpu_loop.c
+++ b/linux-user/loongarch64/cpu_loop.c
@@ -72,6 +72,19 @@ void cpu_loop(CPULoongArchState *env)
case EXCCODE_BCE:
force_sig_fault(TARGET_SIGSYS, TARGET_SI_KERNEL, env->pc);
break;
+
+ /*
+ * Begin with LSX and LASX disabled, then enable on the first trap.
+ * In this way we can tell if the unit is in use. This is used to
+ * choose the layout of any signal frame.
+ */
+ case EXCCODE_SXD:
+ env->CSR_EUEN |= R_CSR_EUEN_SXE_MASK;
+ break;
+ case EXCCODE_ASXD:
+ env->CSR_EUEN |= R_CSR_EUEN_ASXE_MASK;
+ break;
+
case EXCP_ATOMIC:
cpu_exec_step_atomic(cs);
break;
diff --git a/target/loongarch/insn_trans/trans_vec.c.inc b/target/loongarch/insn_trans/trans_vec.c.inc
index 98f856bb29..92b1d22e28 100644
--- a/target/loongarch/insn_trans/trans_vec.c.inc
+++ b/target/loongarch/insn_trans/trans_vec.c.inc
@@ -4,8 +4,6 @@
* Copyright (c) 2022-2023 Loongson Technology Corporation Limited
*/
-#ifndef CONFIG_USER_ONLY
-
static bool check_vec(DisasContext *ctx, uint32_t oprsz)
{
if ((oprsz == 16) && ((ctx->base.tb->flags & HW_FLAGS_EUEN_SXE) == 0)) {
@@ -21,15 +19,6 @@ static bool check_vec(DisasContext *ctx, uint32_t oprsz)
return true;
}
-#else
-
-static bool check_vec(DisasContext *ctx, uint32_t oprsz)
-{
- return true;
-}
-
-#endif
-
static bool gen_vvvv_ptr_vl(DisasContext *ctx, arg_vvvv *a, uint32_t oprsz,
gen_helper_gvec_4_ptr *fn)
{
--
2.34.1
next prev parent reply other threads:[~2023-10-31 14:51 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 [this message]
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
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=0d60c6d4-a785-4abd-a16a-279b50abf09d@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).