qemu-riscv
[Top][All Lists]
Advanced

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

Re: [RFC PATCH v1 2/2] Enable custom instruction suport for Andes A25 an


From: Richard Henderson
Subject: Re: [RFC PATCH v1 2/2] Enable custom instruction suport for Andes A25 and AX25 CPU model
Date: Fri, 22 Oct 2021 10:24:06 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

On 10/22/21 4:52 AM, Alex Bennée wrote:

Ruinland ChuanTzu Tsai <ruinland@andestech.com> writes:

On Thu, Oct 21, 2021 at 12:17:47PM -0700, Richard Henderson wrote:
On 10/21/21 8:11 AM, Ruinland Chuan-Tzu Tsai wrote:
In this patch, we demonstrate how Andes Performance Extension(c) insn :
bfos and bfoz could be used with Andes CoDense : exec.it.

<snip>
+static int andes_v5_gen_codense_exec_it(CPURISCVState *env, DisasContext *ctx, 
arg_execit *a)
+{
+    uint32_t insn;
+    uint32_t imm_ex10 = a->imm_codense;
+    target_ulong uitb_val = 0;
+    riscv_csrrw(env, 0x800, &uitb_val, 0, 0);

This won't work -- you can't access env during translation.  So all this
faff around passing env through HartState is for naught.

Sorry, please elaborate me a little bit more.

When dealing with translation you need to separate the translation phase
from the execution phase. CPUEnv is the current run time state of the
vCPU so the value that might be stored in it when you do translation
could very well be different when the translation runs (or runs again).

The correct way to deal with this is by the use of translation flags...

Yes translation flags will be important for this, but first, the cpu state which you are reading here at translation time, which you are baking into this TranslationBlock forevermore, is (1) the uitb csr value and (2) the contents of the memory at the final address.

Both of these things might vary in between translation of the exec_it instruction and execution of the TranslationBlock. At which point the translation you did earlier is wrong.

Avoiding these kinds of mistakes is exactly why we have *not* provided env to you at this point in translation. Which is why all of the changes you did to recover env are also wrong.


r~



reply via email to

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