RISC-V Patches for 3.1-rc2
The following changes since commit cb968d275c145467c8b385a3618a207ec111eab1:
Update version for v3.1.0-rc1 release (2018-11-13 18:16:14 +0000)
are available in the Git repository at:
git://github.com/riscv/riscv-qemu.git tags/riscv-for-master-3.1-rc2
for you to fetch changes up to 3502dc824a7b0218abb49f4350e80a49829748cf:
RISC-V: Respect fences for user-only emulators (2018-11-13 15:12:15 -0800)
----------------------------------------------------------------
RISC-V Patches for 3.1-rc2
This pull request contains four patches that aren't really related to each other aside from all being bug fixes that I think should go in for 3.1.0:
* The second half of Alistair's memory leak patch set that I missed last week.
* A fix to make fclass.d availiable only on RV64IFD systems (without this it's availiable on RV32IFD systems, truncating the result).
* A fix to make sfence.vm availiable only in priv-1.9.1, and sfence.vma only availiable in priv-1.10.
* A change to respect fences in user-mode emulators, which were previously treated as NOPs.
As usual, this builds and boot Linux for me. I don't think I have anything else planned for 3.1.0, but I may be wrong as things are a bit hectic this week.
----------------------------------------------------------------
Alistair Francis (1):
hw/riscv/virt: Free the test device tree node name
Bastian Koppelmann (2):
target/riscv: Fix FCLASS_D being treated as RV64 only target/riscv: Fix sfence.vm/a both available in any priv version
Palmer Dabbelt (1):
RISC-V: Respect fences for user-only emulators
hw/riscv/virt.c | 1 + target/riscv/translate.c | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-)
[Qemu-devel] [PULL 1/4] hw/riscv/virt: Free the test device tree node name
From: Alistair Francis <[email protected]>
--- hw/riscv/virt.c | 1 + 1 file changed, 1 insertion(+)
hw/riscv/virt.c +1 -0
@@ -240,6 +240,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,qemu_fdt_setprop_cells (fdt, nodename,"reg" ,0x0 , memmap[VIRT_TEST ].base,0x0 , memmap[VIRT_TEST ].size); +g_free (nodename); nodename =g_strdup_printf ("/uart@%lx" , (long )memmap[VIRT_UART0 ].base);
Signature · 1 line
2.18.1
[Qemu-devel] [PULL 2/4] target/riscv: Fix FCLASS_D being treated as RV64 only
In reply to Palmer DabbeltFrom: Bastian Koppelmann <[email protected]>
--- target/riscv/translate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target/riscv/translate.c +3 -1
@@ -1237,13 +1237,14 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t opc, int rd,tcg_temp_free (t0);break ; -#if defined(TARGET_RISCV64 )case OPC_RISC_FMV_X_D :/* also OPC_RISC_FCLASS_D */ switch (rm) { +#if defined(TARGET_RISCV64 )case 0 :/* FMV */ gen_set_gpr (rd, cpu_fpr[rs1]);break ; +#endif case 1 : t0 =tcg_temp_new ();gen_helper_fclass_d (t0, cpu_fpr[rs1]);
@@ -1255,6 +1256,7 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t opc, int rd, }break ; +#if defined(TARGET_RISCV64 )case OPC_RISC_FMV_D_X : t0 =tcg_temp_new ();gen_get_gpr (t0, rs1);
Signature · 1 line
2.18.1
[Qemu-devel] [PULL 3/4] target/riscv: Fix sfence.vm/a both available in any priv version
In reply to Palmer DabbeltFrom: Bastian Koppelmann <[email protected]>
sfence.vm has been replaced in priv v1.10 spec by sfence.vma.
--- target/riscv/translate.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
target/riscv/translate.c +13 -5
@@ -1292,10 +1292,14 @@ static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc,#ifndef CONFIG_USER_ONLY /* Extract funct7 value and check whether it matches SFENCE.VMA */ if ((opc ==OPC_RISC_ECALL ) && ((csr >>5 ) ==9 )) { -/* sfence.vma */ -/* TODO: handle ASID specific fences */ -gen_helper_tlb_flush (cpu_env); -return ; +if (env->priv_ver ==PRIV_VERSION_1_10_0 ) { +/* sfence.vma */ +/* TODO: handle ASID specific fences */ +gen_helper_tlb_flush (cpu_env); +return ; + }else { +gen_exception_illegal (ctx); + } }#endif
@@ -1342,7 +1346,11 @@ static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc,gen_helper_wfi (cpu_env);break ;case 0x104 :/* SFENCE.VM */ -gen_helper_tlb_flush (cpu_env); +if (env->priv_ver <=PRIV_VERSION_1_09_1 ) { +gen_helper_tlb_flush (cpu_env); + }else { +gen_exception_illegal (ctx); + }break ;#endif default :
Signature · 1 line
2.18.1
[Qemu-devel] [PULL 4/4] RISC-V: Respect fences for user-only emulators
In reply to Palmer DabbeltOur current fence implementation ignores fences for the user-only configurations. This is incorrect but unlikely to manifest: it requires multi-threaded user-only code that takes advantage of the weakness in the host's memory model and can be inlined by TCG.
This patch simply treats fences the same way for all our emulators. I've given it to testing as I don't want to construct a test that would actually trigger the failure.
Our fence implementation has an additional deficiency where we map all RISC-V fences to full fences. Now that we have a formal memory model for RISC-V we can start to take advantage of the strength bits on our fence instructions. This requires a bit more though, so I'm going to split it out because the implementation is still correct without taking advantage of these weaker fences.
Thanks to Richard Henderson for pointing out both of the issues.
--- target/riscv/translate.c | 2 -- 1 file changed, 2 deletions(-)
target/riscv/translate.c +0 -2
@@ -1776,7 +1776,6 @@ static void decode_RV32_64G(CPURISCVState *env, DisasContext *ctx) GET_RM(ctx->opcode));break ;case OPC_RISC_FENCE : -#ifndef CONFIG_USER_ONLY if (ctx->opcode &0x1000 ) {/* FENCE_I is a no-op in QEMU, * however we need to end the translation block */
@@ -1787,7 +1786,6 @@ static void decode_RV32_64G(CPURISCVState *env, DisasContext *ctx)/* FENCE is a full memory barrier. */ tcg_gen_mb (TCG_MO_ALL |TCG_BAR_SC ); } -#endif break ;case OPC_RISC_SYSTEM : gen_system(env, ctx, MASK_OP_SYSTEM(ctx->opcode), rd, rs1,
Signature · 1 line
2.18.1
Peter Maydell
AppliedQuoted 28 lines · Palmer Dabbelt
The following changes since commit
cb968d275c145467c8b385a3618a207ec111eab1:Update version for v3.1.0-rc1 release (2018-11-13 18:16:14 +0000)
are available in the Git repository at:
git://github.com/riscv/riscv-qemu.gittags/riscv-for-master-3.1-rc2for you to fetch changes up to
3502dc824a7b0218abb49f4350e80a49829748cf:RISC-V: Respect fences for user-only emulators (2018-11-13 15:12:15 -0800)
----------------------------------------------------------------
RISC-V Patches for 3.1-rc2This pull request contains four patches that aren't really related to each other aside from all being bug fixes that I think should go in for 3.1.0:
* The second half of Alistair's memory leak patch set that I missed last week.
* A fix to make fclass.d availiable only on RV64IFD systems (without this it's availiable on RV32IFD systems, truncating the result).
* A fix to make sfence.vm availiable only in priv-1.9.1, and sfence.vma only availiable in priv-1.10.
* A change to respect fences in user-mode emulators, which were previously treated as NOPs.
Quoted 4 lines
As usual, this builds and boot Linux for me. I don't think I have anything else planned for 3.1.0, but I may be wrong as things are a bit hectic this week.
Applied, thanks.
-- PMM