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.
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCAAxFiEEAM520YNJYN/OiG3470yhUCzLq0EFAlvrYtYTHHBhbG1lckBk
 YWJiZWx0LmNvbQAKCRDvTKFQLMurQdF+EACA9fVWBbXmJfsOeWq1887zGXt+Txdf
 KKxWc9JNf6Zo/QLziGinSDAt8UNTtHzckVePdlSAJIiNuvDLf4AtQT8wSjPGeVzS
 IMauZnXe/gz15iqPGLOUmaz9B/UrkV4T5wmFwnNv7T00dBFWIKESez7QJgjPih/e
 zmDgUw+FG6A/SGHBkL60xxhv2+2ZkXhtwaB9tzqeKmqebaJDOgEGT6roQDffbW0C
 jKiRXmBQVFWfmmi1HXfs8NFGmMDgV1vBAr/3dd7F2tZU7lZBhFp/KUkY5VhMC+2y
 CNU7Ug1OyIE6haoPgui2FqlQV95CL7zkqkwEZqdaqzgXAQAxtWsJjMwZl4vCuumu
 DmTEhunvt7/aMqsB2iQgVAXDgKX79qI5xLzc04en0I/BppT1991BWJfyQSyucQyb
 vBF5iLBudsxzAWAB6TSWu7lsBECTYci+QJ/z7ZvvOpTaT8mm0Rc0aEfm0PVpVLIk
 hxZAMdbbPKl3q2e69//w/nw5jHfWk2cAPWcfpFvGWyweD3xLiy60S+++nzWjwJy3
 9mXW7MjW6iFGYTGDUWOQ5207NJ/tISxBsmck81+aPHfb6bPxpIJicZnchfzoWdop
 ahw9XbOsnBZdY18csgeNBQh5UVKZcVGvxeCfjtO/XlIw+kUB3wPbu+bQ+3vUSeV+
 Ubfw/T0n/GerUg==
 =Y5YG
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/riscv/tags/riscv-for-master-3.1-rc2' into staging

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.

# gpg: Signature made Tue 13 Nov 2018 23:48:38 GMT
# gpg:                using RSA key EF4CA1502CCBAB41
# gpg: Good signature from "Palmer Dabbelt <palmer@dabbelt.com>"
# gpg:                 aka "Palmer Dabbelt <palmer@sifive.com>"
# 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

* remotes/riscv/tags/riscv-for-master-3.1-rc2:
  RISC-V: Respect fences for user-only emulators
  target/riscv: Fix sfence.vm/a both available in any priv version
  target/riscv: Fix FCLASS_D being treated as RV64 only
  hw/riscv/virt: Free the test device tree node name

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-11-19 09:35:27 +00:00
commit d06491098b
2 changed files with 17 additions and 8 deletions

View File

@ -240,6 +240,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
qemu_fdt_setprop_cells(fdt, nodename, "reg", qemu_fdt_setprop_cells(fdt, nodename, "reg",
0x0, memmap[VIRT_TEST].base, 0x0, memmap[VIRT_TEST].base,
0x0, memmap[VIRT_TEST].size); 0x0, memmap[VIRT_TEST].size);
g_free(nodename);
nodename = g_strdup_printf("/uart@%lx", nodename = g_strdup_printf("/uart@%lx",
(long)memmap[VIRT_UART0].base); (long)memmap[VIRT_UART0].base);

View File

@ -1237,13 +1237,14 @@ static void gen_fp_arith(DisasContext *ctx, uint32_t opc, int rd,
tcg_temp_free(t0); tcg_temp_free(t0);
break; break;
#if defined(TARGET_RISCV64)
case OPC_RISC_FMV_X_D: case OPC_RISC_FMV_X_D:
/* also OPC_RISC_FCLASS_D */ /* also OPC_RISC_FCLASS_D */
switch (rm) { switch (rm) {
#if defined(TARGET_RISCV64)
case 0: /* FMV */ case 0: /* FMV */
gen_set_gpr(rd, cpu_fpr[rs1]); gen_set_gpr(rd, cpu_fpr[rs1]);
break; break;
#endif
case 1: case 1:
t0 = tcg_temp_new(); t0 = tcg_temp_new();
gen_helper_fclass_d(t0, cpu_fpr[rs1]); 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; break;
#if defined(TARGET_RISCV64)
case OPC_RISC_FMV_D_X: case OPC_RISC_FMV_D_X:
t0 = tcg_temp_new(); t0 = tcg_temp_new();
gen_get_gpr(t0, rs1); gen_get_gpr(t0, rs1);
@ -1290,10 +1292,14 @@ static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc,
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY
/* Extract funct7 value and check whether it matches SFENCE.VMA */ /* Extract funct7 value and check whether it matches SFENCE.VMA */
if ((opc == OPC_RISC_ECALL) && ((csr >> 5) == 9)) { if ((opc == OPC_RISC_ECALL) && ((csr >> 5) == 9)) {
/* sfence.vma */ if (env->priv_ver == PRIV_VERSION_1_10_0) {
/* TODO: handle ASID specific fences */ /* sfence.vma */
gen_helper_tlb_flush(cpu_env); /* TODO: handle ASID specific fences */
return; gen_helper_tlb_flush(cpu_env);
return;
} else {
gen_exception_illegal(ctx);
}
} }
#endif #endif
@ -1340,7 +1346,11 @@ static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc,
gen_helper_wfi(cpu_env); gen_helper_wfi(cpu_env);
break; break;
case 0x104: /* SFENCE.VM */ 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; break;
#endif #endif
default: default:
@ -1766,7 +1776,6 @@ static void decode_RV32_64G(CPURISCVState *env, DisasContext *ctx)
GET_RM(ctx->opcode)); GET_RM(ctx->opcode));
break; break;
case OPC_RISC_FENCE: case OPC_RISC_FENCE:
#ifndef CONFIG_USER_ONLY
if (ctx->opcode & 0x1000) { if (ctx->opcode & 0x1000) {
/* FENCE_I is a no-op in QEMU, /* FENCE_I is a no-op in QEMU,
* however we need to end the translation block */ * however we need to end the translation block */
@ -1777,7 +1786,6 @@ static void decode_RV32_64G(CPURISCVState *env, DisasContext *ctx)
/* FENCE is a full memory barrier. */ /* FENCE is a full memory barrier. */
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
} }
#endif
break; break;
case OPC_RISC_SYSTEM: case OPC_RISC_SYSTEM:
gen_system(env, ctx, MASK_OP_SYSTEM(ctx->opcode), rd, rs1, gen_system(env, ctx, MASK_OP_SYSTEM(ctx->opcode), rd, rs1,