qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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: Mon, 30 Oct 2023 08:30:27 -0700	[thread overview]
Message-ID: <c43b9404-fd99-4f8a-9e35-62f5a4e50b5b@linaro.org> (raw)
In-Reply-To: <24981f5e-3397-427e-a552-635887d581cd@loongson.cn>

On 10/29/23 20:28, gaosong wrote:
> 在 2023/10/29 上午5:40, Richard Henderson 写道:
>> On 10/9/23 20:36, Song Gao wrote:
>>> Signed-off-by: Song Gao <gaosong@loongson.cn>
>>> ---
>>>   target/loongarch/insn_trans/trans_vec.c.inc | 12 ++++++++++++
>>>   target/loongarch/internals.h                |  2 ++
>>>   2 files changed, 14 insertions(+)
>>>
>>> diff --git a/target/loongarch/insn_trans/trans_vec.c.inc 
>>> b/target/loongarch/insn_trans/trans_vec.c.inc
>>> index 98f856bb29..aef16ef44a 100644
>>> --- a/target/loongarch/insn_trans/trans_vec.c.inc
>>> +++ b/target/loongarch/insn_trans/trans_vec.c.inc
>>> @@ -23,8 +23,20 @@ static bool check_vec(DisasContext *ctx, uint32_t oprsz)
>>>     #else
>>>   +static void set_vec_extctx(DisasContext *ctx, uint32_t oprsz)
>>> +{
>>> +    if (oprsz == 16) {
>>> +        ctx->extctx_flags |= EXTCTX_FLAGS_LSX;
>>> +    }
>>> +
>>> +    if (oprsz == 32) {
>>> +        ctx->extctx_flags |= EXTCTX_FLAGS_LASX;
>>> +    }
>>> +}
>>> +
>>>   static bool check_vec(DisasContext *ctx, uint32_t oprsz)
>>>   {
>>> +    set_vec_extctx(ctx, oprsz);
>>>       return true;
>>>   }
>>
>> This doesn't do anything.  Nothing copies the changed value back to env.
>> Anyway, I think this is the wrong way to go about it.
>>
> Oh, It is on patch1.
> 
> @@ -294,6 +296,7 @@ static void loongarch_tr_translate_insn(DisasContextBase *dcbase, 
> CPUState *cs)
>           generate_exception(ctx, EXCCODE_INE);
>       }
> 
> +    env->extctx_flags |= ctx->extctx_flags;

Ah, well, this is also incorrect.

This copy only happens at translation time, not at execution time.

Anyway, I think my previous suggestion is better:

>> 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 exactly which 
>> units have been used by the program.


r~



  reply	other threads:[~2023-10-30 15:30 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 [this message]
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
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=c43b9404-fd99-4f8a-9e35-62f5a4e50b5b@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).