RISC-V Patches for the 5.0 Soft Freeze, Part 1
This patch set contains a handful of collected fixes that I'd like to target for the 5.0 soft freeze (I know that's a long way away, I just don't know what else to call these): * A fix for a memory leak initializing the sifive_u board. * Fixes to privilege mode emulation related to interrupts and fstatus. Notably absent is the H extension implementation. That's pretty much reviewed, but not quite ready to go yet and I didn't want to hold back these important fixes. This boots 32-bit and 64-bit Linux (buildroot this time, just for fun) and passes "make check". -----BEGIN PGP SIGNATURE----- iQJHBAABCgAxFiEEKzw3R0RoQ7JKlDp6LhMZ81+7GIkFAl4ngWATHHBhbG1lckBk YWJiZWx0LmNvbQAKCRAuExnzX7sYiT4eD/450dJ8tGRJKA7V/XEYFM4yYZ87cgsE HSF3E4lOTdjqp+wNwag2P1uIFJO1snqAa+6qwQFLsPRtGwn43hQzTbay86L7sPK8 YXL143OaQz0jUtcmEyTJ2EczOti4bVhX+gy9T4NckvsteSJHnHbMmdqfaafwVlmy Qrx2IMAwY8k7+Dfil2INZTp4jlJ6ibe0XwziiMM+5RwTL2a30vYAREkRU3wrF0UN 87BVp5jA5ytiOAtJoniD6Yh9zKgDhkQwv6orJUbIseAWhJUvVVoMg4IIdF11Hert FoqFZy6dUbIAeCTwEtHfvgJJrA/2Mn2Go1uLG22ToStp8Vq9VGzq29MN7Zx4fM8J 22j3SOwOzUVGl0bSsSktfQ+QqJEMXRfWGzq4/al0JCjEx68DMKkVW3V5P4H8FP5Z 7ZlBvf9NxaZeXLFOavZgW0fQBdVKMjb0Uk2QXWbe45TdMOPQ7BT8WGRogb0MhOyW t8iyKPCaYfF0NygOSCUaRdZ7Ng2NkAvppyUiAFccmttlPbaYSui306yMIJ9Ls2z1 3pny3gwdMTIy0/86yEWdi6gffVgUR/o9bhwRDjMQpJU21cAHn06zJjPM4hnPk83Z j0/5JTQFWJzMO7xML9btMUV/bdPp5nJmI2ljQgkgaT92Qi3e9x4je09Duky5R2Bl XbGrB9GzcDjAtw== =WooQ -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/palmer/tags/riscv-for-master-5.0-sf1' into staging RISC-V Patches for the 5.0 Soft Freeze, Part 1 This patch set contains a handful of collected fixes that I'd like to target for the 5.0 soft freeze (I know that's a long way away, I just don't know what else to call these): * A fix for a memory leak initializing the sifive_u board. * Fixes to privilege mode emulation related to interrupts and fstatus. Notably absent is the H extension implementation. That's pretty much reviewed, but not quite ready to go yet and I didn't want to hold back these important fixes. This boots 32-bit and 64-bit Linux (buildroot this time, just for fun) and passes "make check". # gpg: Signature made Tue 21 Jan 2020 22:55:28 GMT # gpg: using RSA key 2B3C3747446843B24A943A7A2E1319F35FBB1889 # gpg: issuer "palmer@dabbelt.com" # gpg: Good signature from "Palmer Dabbelt <palmer@dabbelt.com>" [unknown] # gpg: aka "Palmer Dabbelt <palmer@sifive.com>" [unknown] # gpg: aka "Palmer Dabbelt <palmerdabbelt@google.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 00CE 76D1 8349 60DF CE88 6DF8 EF4C A150 2CCB AB41 # Subkey fingerprint: 2B3C 3747 4468 43B2 4A94 3A7A 2E13 19F3 5FBB 1889 * remotes/palmer/tags/riscv-for-master-5.0-sf1: target/riscv: update mstatus.SD when FS is set dirty target/riscv: fsd/fsw doesn't dirty FP state target/riscv: Fix tb->flags FS status riscv: Set xPIE to 1 after xRET riscv/sifive_u: fix a memory leak in soc_realize() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
ba2ed84fe6
@ -542,6 +542,7 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)
|
||||
SIFIVE_U_PLIC_CONTEXT_BASE,
|
||||
SIFIVE_U_PLIC_CONTEXT_STRIDE,
|
||||
memmap[SIFIVE_U_PLIC].size);
|
||||
g_free(plic_hart_config);
|
||||
sifive_uart_create(system_memory, memmap[SIFIVE_U_UART0].base,
|
||||
serial_hd(0), qdev_get_gpio_in(DEVICE(s->plic), SIFIVE_U_UART0_IRQ));
|
||||
sifive_uart_create(system_memory, memmap[SIFIVE_U_UART1].base,
|
||||
|
@ -293,10 +293,7 @@ static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
*flags = TB_FLAGS_MSTATUS_FS;
|
||||
#else
|
||||
*flags = cpu_mmu_index(env, 0);
|
||||
if (riscv_cpu_fp_enabled(env)) {
|
||||
*flags |= TB_FLAGS_MSTATUS_FS;
|
||||
}
|
||||
*flags = cpu_mmu_index(env, 0) | (env->mstatus & MSTATUS_FS);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -341,8 +341,7 @@ static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val)
|
||||
|
||||
mstatus = (mstatus & ~mask) | (val & mask);
|
||||
|
||||
dirty = (riscv_cpu_fp_enabled(env) &&
|
||||
((mstatus & MSTATUS_FS) == MSTATUS_FS)) |
|
||||
dirty = ((mstatus & MSTATUS_FS) == MSTATUS_FS) |
|
||||
((mstatus & MSTATUS_XS) == MSTATUS_XS);
|
||||
mstatus = set_field(mstatus, MSTATUS_SD, dirty);
|
||||
env->mstatus = mstatus;
|
||||
|
@ -43,7 +43,6 @@ static bool trans_fsd(DisasContext *ctx, arg_fsd *a)
|
||||
|
||||
tcg_gen_qemu_st_i64(cpu_fpr[a->rs2], t0, ctx->mem_idx, MO_TEQ);
|
||||
|
||||
mark_fs_dirty(ctx);
|
||||
tcg_temp_free(t0);
|
||||
return true;
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ static bool trans_fsw(DisasContext *ctx, arg_fsw *a)
|
||||
tcg_gen_qemu_st_i64(cpu_fpr[a->rs2], t0, ctx->mem_idx, MO_TEUL);
|
||||
|
||||
tcg_temp_free(t0);
|
||||
mark_fs_dirty(ctx);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ target_ulong helper_sret(CPURISCVState *env, target_ulong cpu_pc_deb)
|
||||
env->priv_ver >= PRIV_VERSION_1_10_0 ?
|
||||
MSTATUS_SIE : MSTATUS_UIE << prev_priv,
|
||||
get_field(mstatus, MSTATUS_SPIE));
|
||||
mstatus = set_field(mstatus, MSTATUS_SPIE, 0);
|
||||
mstatus = set_field(mstatus, MSTATUS_SPIE, 1);
|
||||
mstatus = set_field(mstatus, MSTATUS_SPP, PRV_U);
|
||||
riscv_cpu_set_mode(env, prev_priv);
|
||||
env->mstatus = mstatus;
|
||||
@ -118,7 +118,7 @@ target_ulong helper_mret(CPURISCVState *env, target_ulong cpu_pc_deb)
|
||||
env->priv_ver >= PRIV_VERSION_1_10_0 ?
|
||||
MSTATUS_MIE : MSTATUS_UIE << prev_priv,
|
||||
get_field(mstatus, MSTATUS_MPIE));
|
||||
mstatus = set_field(mstatus, MSTATUS_MPIE, 0);
|
||||
mstatus = set_field(mstatus, MSTATUS_MPIE, 1);
|
||||
mstatus = set_field(mstatus, MSTATUS_MPP, PRV_U);
|
||||
riscv_cpu_set_mode(env, prev_priv);
|
||||
env->mstatus = mstatus;
|
||||
|
@ -394,7 +394,7 @@ static void mark_fs_dirty(DisasContext *ctx)
|
||||
|
||||
tmp = tcg_temp_new();
|
||||
tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus));
|
||||
tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS);
|
||||
tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | MSTATUS_SD);
|
||||
tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus));
|
||||
tcg_temp_free(tmp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user