mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-23 05:25:11 +00:00
target/riscv: Allow setting mstatus virtulisation bits
Backports commit 1f0419cb0475eebdbefea67483e85287f3af07a7 from qemu
This commit is contained in:
parent
c64f57c360
commit
47e4e047bc
|
@ -297,11 +297,10 @@ static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val)
|
|||
{
|
||||
target_ulong mstatus = env->mstatus;
|
||||
target_ulong mask = 0;
|
||||
target_ulong mpp = get_field(val, MSTATUS_MPP);
|
||||
|
||||
/* flush tlb on mstatus fields that affect VM */
|
||||
if (env->priv_ver <= PRIV_VERSION_1_09_1) {
|
||||
if ((val ^ mstatus) & (MSTATUS_MXR | MSTATUS_MPP |
|
||||
if ((val ^ mstatus) & (MSTATUS_MXR | MSTATUS_MPP | MSTATUS_MPV |
|
||||
MSTATUS_MPRV | MSTATUS_SUM | MSTATUS_VM)) {
|
||||
tlb_flush(CPU(riscv_env_get_cpu(env)));
|
||||
}
|
||||
|
@ -320,13 +319,14 @@ static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val)
|
|||
MSTATUS_SPP | MSTATUS_FS | MSTATUS_MPRV | MSTATUS_SUM |
|
||||
MSTATUS_MPP | MSTATUS_MXR | MSTATUS_TVM | MSTATUS_TSR |
|
||||
MSTATUS_TW;
|
||||
}
|
||||
|
||||
/* silenty discard mstatus.mpp writes for unsupported modes */
|
||||
if (mpp == PRV_H ||
|
||||
(!riscv_has_ext(env, RVS) && mpp == PRV_S) ||
|
||||
(!riscv_has_ext(env, RVU) && mpp == PRV_U)) {
|
||||
mask &= ~MSTATUS_MPP;
|
||||
#if defined(TARGET_RISCV64)
|
||||
/*
|
||||
* RV32: MPV and MTL are not in mstatus. The current plan is to
|
||||
* add them to mstatush. For now, we just don't support it.
|
||||
*/
|
||||
mask |= MSTATUS_MPP | MSTATUS_MPV;
|
||||
#endif
|
||||
}
|
||||
|
||||
mstatus = (mstatus & ~mask) | (val & mask);
|
||||
|
|
Loading…
Reference in a new issue