* [Qemu-devel] [PATCH for 3.1] RISC-V: Respect fences for user-only emulators
@ 2018-11-09 19:19 Palmer Dabbelt
2018-11-09 19:19 ` Palmer Dabbelt
0 siblings, 1 reply; 4+ messages in thread
From: Palmer Dabbelt @ 2018-11-09 19:19 UTC (permalink / raw)
To: qemu-riscv, richard.henderson; +Cc: qemu-devel
I'd like to target this for 3.1: while it's a pretty esoteric bug the
risk of breaking anything is low and tracking down a manifestation of
the bug would be a nightmare.
I don't think the performance improvement alluded to will be a 3.1
candidiate, and as a result I probably won't get around to it until
later.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH for 3.1] RISC-V: Respect fences for user-only emulators
2018-11-09 19:19 [Qemu-devel] [PATCH for 3.1] RISC-V: Respect fences for user-only emulators Palmer Dabbelt
@ 2018-11-09 19:19 ` Palmer Dabbelt
2018-11-09 22:02 ` Alistair Francis
2018-11-10 8:37 ` Richard Henderson
0 siblings, 2 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2018-11-09 19:19 UTC (permalink / raw)
To: qemu-riscv, richard.henderson; +Cc: qemu-devel, Palmer Dabbelt
Our 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.
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
---
target/riscv/translate.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index 18d7b6d1471d..624d1c679a84 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -1766,7 +1766,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 */
@@ -1777,7 +1776,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,
--
2.18.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH for 3.1] RISC-V: Respect fences for user-only emulators
2018-11-09 19:19 ` Palmer Dabbelt
@ 2018-11-09 22:02 ` Alistair Francis
2018-11-10 8:37 ` Richard Henderson
1 sibling, 0 replies; 4+ messages in thread
From: Alistair Francis @ 2018-11-09 22:02 UTC (permalink / raw)
To: Palmer Dabbelt
Cc: qemu-riscv, Richard Henderson, qemu-devel@nongnu.org Developers
On Fri, Nov 9, 2018 at 11:21 AM Palmer Dabbelt <palmer@sifive.com> wrote:
>
> Our 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
s/though/thought/g
> 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.
>
> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> target/riscv/translate.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/target/riscv/translate.c b/target/riscv/translate.c
> index 18d7b6d1471d..624d1c679a84 100644
> --- a/target/riscv/translate.c
> +++ b/target/riscv/translate.c
> @@ -1766,7 +1766,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 */
> @@ -1777,7 +1776,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,
> --
> 2.18.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH for 3.1] RISC-V: Respect fences for user-only emulators
2018-11-09 19:19 ` Palmer Dabbelt
2018-11-09 22:02 ` Alistair Francis
@ 2018-11-10 8:37 ` Richard Henderson
1 sibling, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2018-11-10 8:37 UTC (permalink / raw)
To: Palmer Dabbelt, qemu-riscv; +Cc: qemu-devel
On 11/9/18 8:19 PM, Palmer Dabbelt wrote:
> Our 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.
>
> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
> ---
> target/riscv/translate.c | 2 --
> 1 file changed, 2 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-11-10 8:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-09 19:19 [Qemu-devel] [PATCH for 3.1] RISC-V: Respect fences for user-only emulators Palmer Dabbelt
2018-11-09 19:19 ` Palmer Dabbelt
2018-11-09 22:02 ` Alistair Francis
2018-11-10 8:37 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).