From: Palmer Dabbelt <palmer@sifive.com>
To: qemu-riscv@nongnu.org
Cc: qemu-devel@nongnu.org, Palmer Dabbelt <palmer@sifive.com>
Subject: [Qemu-devel] [PULL 4/4] RISC-V: Respect fences for user-only emulators
Date: Tue, 13 Nov 2018 15:50:45 -0800 [thread overview]
Message-ID: <20181113235045.14155-5-palmer@sifive.com> (raw)
In-Reply-To: <20181113235045.14155-1-palmer@sifive.com>
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>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/riscv/translate.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index f44eb9c41b48..312bf298b3c2 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -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,
--
2.18.1
next prev parent reply other threads:[~2018-11-13 23:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-13 23:50 [Qemu-devel] [PR RFC] RISC-V Patches for 3.1-rc2 Palmer Dabbelt
2018-11-13 23:50 ` [Qemu-devel] [PULL 1/4] hw/riscv/virt: Free the test device tree node name Palmer Dabbelt
2018-11-13 23:50 ` [Qemu-devel] [PULL 2/4] target/riscv: Fix FCLASS_D being treated as RV64 only Palmer Dabbelt
2018-11-13 23:50 ` [Qemu-devel] [PULL 3/4] target/riscv: Fix sfence.vm/a both available in any priv version Palmer Dabbelt
2018-11-13 23:50 ` Palmer Dabbelt [this message]
2018-11-14 2:32 ` [Qemu-devel] [PULL 4/4] RISC-V: Respect fences for user-only emulators Michael Clark
2018-11-14 3:06 ` [Qemu-devel] [PR RFC] RISC-V Patches for 3.1-rc2 Michael Clark
-- strict thread matches above, loose matches on Subject: below --
2018-11-16 21:30 [Qemu-devel] [PULL] " Palmer Dabbelt
2018-11-16 21:30 ` [Qemu-devel] [PULL 4/4] RISC-V: Respect fences for user-only emulators Palmer Dabbelt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181113235045.14155-5-palmer@sifive.com \
--to=palmer@sifive.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).