From: LIU Zhiwei <zhiwei_liu@c-sky.com>
To: Richard Henderson <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: palmer@dabbelt.com, bin.meng@windriver.com, Alistair.Francis@wdc.com
Subject: Re: [RFC PATCH 01/13] target/riscv: Add UXL to tb flags
Date: Fri, 6 Aug 2021 10:49:21 +0800 [thread overview]
Message-ID: <1030e7cf-63d3-27e7-a7ed-448b134763cb@c-sky.com> (raw)
In-Reply-To: <94c93e5e-3469-e81c-33b8-9a6ba7f4922a@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 3772 bytes --]
On 2021/8/6 上午3:01, Richard Henderson wrote:
> On 8/4/21 4:53 PM, LIU Zhiwei wrote:
>> For 32-bit applications run on 64-bit cpu, it may share some code
>> with other 64-bit applictions. Thus we should distinguish the translated
>> cache of the share code with a tb flag.
>>
>> Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
>> ---
>> target/riscv/cpu.h | 15 +++++++++++++++
>> target/riscv/translate.c | 3 +++
>> 2 files changed, 18 insertions(+)
>>
>> diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
>> index bf1c899c00..2b3ba21a78 100644
>> --- a/target/riscv/cpu.h
>> +++ b/target/riscv/cpu.h
>> @@ -394,9 +394,20 @@ FIELD(TB_FLAGS, SEW, 5, 3)
>> FIELD(TB_FLAGS, VILL, 8, 1)
>> /* Is a Hypervisor instruction load/store allowed? */
>> FIELD(TB_FLAGS, HLSX, 9, 1)
>> +FIELD(TB_FLAGS, UXL, 10, 2)
>
> Are you intending to reserve space for RV128 here?
> Otherwise this could be a single bit.
>
Yes.
> Also, you probably don't want to name it "UXL", since it should
> indicate the current operating XLEN, taking MXL, SXL and UXL into
> account.
>
Hi Richard,
I don't have the ambitious to define a XLEN32 at least for this patch
set. I think it is much more difficult.
The only purpose of this patch set is that we can run 32-bit application
on a 64 bit Linux from qemu-system-riscv64.
So I didn't change the default behavior of every instruction except when
1. Current CPU is 64 bit CPU, i.s. TARGET_LONG_BITS is 64.
2. Current privileged is U-mode.
3. UXL is 1.
I know that Alistair has done a lot to support 32-bit CPU on
qemu-system-riscv64. But We are doing different things,
and it maybe a little confusing.
I still do not find a good to combine them. In my opinion, some code in
this patch set can be reused for SXL32.
If you have any advice, please let me know.
Best Regards,
Zhiwei
> Perhaps just name the field XLEN32, and make it a single bit?
>
>> +static inline bool riscv_cpu_is_uxl32(CPURISCVState *env)
>> +{
>> +#ifndef CONFIG_USER_ONLY
>> + return (get_field(env->mstatus, MSTATUS64_UXL) == 1) &&
>> + !riscv_cpu_is_32bit(env) &&
>> + (env->priv == PRV_U);
>> +#endif
>> + return false;
>> +}
>
> Again, naming could be better?
> It seems trivial to handle all of the fields here. Perhaps
>
>
> static inline bool riscv_cpu_is_xlen32(env)
> {
> #if defined(TARGET_RISCV32)
> return true;
> #elif defined(CONFIG_USER_ONLY)
> return false;
> #else
> /* When emulating a 32-bit-only cpu, use RV32. */
> if (riscv_cpu_is_32bit(env)) {
> return true;
> }
> /*
> * If MXL has been reduced to RV32, MSTATUSH doesn't have UXL/SXL,
> * therefore, XLEN cannot be widened back to RV64 for lower privs.
> */
> if (get_field(env->misa, MISA64_MXL) == 1) {
> return true;
> }
> switch (env->priv) {
> case PRV_M:
> return false;
> case PRV_U:
> return get_field(env->mstatus, MSTATUS64_UXL) == 1;
> default: /* PRV_S & PRV_H */
> return get_field(env->mstatus, MSTATUS64_SXL) == 1;
> }
> #endif
> }
>
>
>> @@ -451,6 +462,10 @@ static inline void
>> cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
>> flags = FIELD_DP32(flags, TB_FLAGS, HLSX, 1);
>> }
>> }
>> + if (riscv_cpu_is_uxl32(env)) {
>> + flags = FIELD_DP32(flags, TB_FLAGS, UXL,
>> + get_field(env->mstatus, MSTATUS64_UXL));
>
> flags = FIELD_DP32(flags, TB_FLAGS, XLEN32,
> riscv_cpu_is_xlen32(env));
>
>
> r~
[-- Attachment #2: Type: text/html, Size: 6122 bytes --]
next prev parent reply other threads:[~2021-08-06 2:52 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-05 2:52 [RFC PATCH 00/13] Support UXL field in mstatus LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 01/13] target/riscv: Add UXL to tb flags LIU Zhiwei
2021-08-05 6:00 ` Alistair Francis
2021-08-05 19:01 ` Richard Henderson
2021-08-06 2:49 ` LIU Zhiwei [this message]
2021-08-05 2:53 ` [RFC PATCH 02/13] target/riscv: Support UXL32 for branch instructions LIU Zhiwei
2021-08-05 19:06 ` Richard Henderson
2021-08-09 1:45 ` LIU Zhiwei
2021-08-09 19:34 ` Richard Henderson
2021-08-11 14:57 ` LIU Zhiwei
2021-08-11 17:56 ` Richard Henderson
2021-08-11 22:40 ` LIU Zhiwei
2021-08-12 4:42 ` Richard Henderson
2021-08-12 5:03 ` LIU Zhiwei
2021-08-12 6:12 ` Richard Henderson
2021-08-12 7:20 ` LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 03/13] target/riscv: Support UXL32 on 64-bit cpu for load/store LIU Zhiwei
2021-08-05 19:08 ` Richard Henderson
2021-08-09 1:50 ` LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 04/13] target/riscv: Support UXL32 for slit/sltiu LIU Zhiwei
2021-08-05 19:09 ` Richard Henderson
2021-08-09 7:28 ` LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 05/13] target/riscv: Support UXL32 for shift instruction LIU Zhiwei
2021-08-05 22:17 ` Richard Henderson
2021-08-09 7:51 ` LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 06/13] target/riscv: Fix div instructions LIU Zhiwei
2021-08-05 22:18 ` Richard Henderson
2021-08-09 7:53 ` LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 07/13] target/riscv: Support UXL32 for RVM LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 08/13] target/riscv: Support UXL32 for vector instructions LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 09/13] target/riscv: Support UXL32 for atomic instructions LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 10/13] target/riscv: Support UXL32 for float instructions LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 11/13] target/riscv: Fix srow LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 12/13] target/riscv: Support UXL32 for RVB LIU Zhiwei
2021-08-05 2:53 ` [RFC PATCH 13/13] target/riscv: Changing the width of U-mode CSR LIU Zhiwei
2021-08-05 6:01 ` [RFC PATCH 00/13] Support UXL field in mstatus Alistair Francis
2021-08-05 7:14 ` LIU Zhiwei
2021-08-05 7:20 ` Bin Meng
2021-08-05 8:10 ` LIU Zhiwei
2021-08-06 10:05 ` Alistair Francis
2021-08-09 1:25 ` LIU Zhiwei
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=1030e7cf-63d3-27e7-a7ed-448b134763cb@c-sky.com \
--to=zhiwei_liu@c-sky.com \
--cc=Alistair.Francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=richard.henderson@linaro.org \
/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).