Message ID | 22761a83664e100f962532cfa82b25d1a0a89ba3.1607467819.git.alistair.francis@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | RISC-V: Start to remove xlen preprocess | expand |
On 12/8/20 4:56 PM, Alistair Francis wrote: > +bool riscv_cpu_is_32bit(CPURISCVState *env) > +{ > + if (env->misa & RV64) { > + return false; > + } > + > + return true; Is this ever going to more than return !(env->misa & RV64); ? r~
On Wed, Dec 9, 2020 at 7:59 AM Richard Henderson <richard.henderson@linaro.org> wrote: > > On 12/8/20 4:56 PM, Alistair Francis wrote: > > +bool riscv_cpu_is_32bit(CPURISCVState *env) > > +{ > > + if (env->misa & RV64) { > > + return false; > > + } > > + > > + return true; > > Is this ever going to more than > > return !(env->misa & RV64); Eventually this could also depend on mstatus, to allow a 32-bit kernel to run on a 64-bit firmware. It will also hopefully one day be configurable by hypervisors. Alistair > > ? > > > r~
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 9c064f3094..6339e84819 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -384,6 +384,8 @@ FIELD(TB_FLAGS, VILL, 8, 1) /* Is a Hypervisor instruction load/store allowed? */ FIELD(TB_FLAGS, HLSX, 9, 1) +bool riscv_cpu_is_32bit(CPURISCVState *env); + /* * A simplification for VLMAX * = (1 << LMUL) * VLEN / (8 * (1 << SEW)) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6a0264fc6b..32a6916b8a 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -108,6 +108,15 @@ const char *riscv_cpu_get_trap_name(target_ulong cause, bool async) } } +bool riscv_cpu_is_32bit(CPURISCVState *env) +{ + if (env->misa & RV64) { + return false; + } + + return true; +} + static void set_misa(CPURISCVState *env, target_ulong misa) { env->misa_mask = env->misa = misa;