From: Max Filippov <jcmvbkbc@gmail.com>
To: qemu-devel@nongnu.org
Cc: Max Filippov <jcmvbkbc@gmail.com>, "Emilio G . Cota" <cota@braap.org>
Subject: [Qemu-devel] [PATCH v2 04/11] target/xtensa: support MTTCG
Date: Wed, 28 Feb 2018 14:16:02 -0800 [thread overview]
Message-ID: <20180228221609.11265-5-jcmvbkbc@gmail.com> (raw)
In-Reply-To: <20180228221609.11265-1-jcmvbkbc@gmail.com>
- emit TCG barriers for MEMW, EXTW, S32RI and L32AI;
- do atomic_cmpxchg_i32 for S32C1I.
Cc: Emilio G. Cota <cota@braap.org>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
configure | 1 +
target/xtensa/cpu.h | 3 +++
target/xtensa/translate.c | 46 +++++++++++++++++++++++++++++++---------------
3 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/configure b/configure
index 39f3a4300163..f83bdeb2a550 100755
--- a/configure
+++ b/configure
@@ -6813,6 +6813,7 @@ case "$target_name" in
;;
xtensa|xtensaeb)
TARGET_ARCH=xtensa
+ mttcg="yes"
;;
*)
error_exit "Unsupported target CPU"
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 255cc9e08ed9..d9d3b33a7052 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -31,6 +31,9 @@
#define ALIGNED_ONLY
#define TARGET_LONG_BITS 32
+/* Xtensa processors have a weak memory model */
+#define TCG_GUEST_DEFAULT_MO (0)
+
#define CPUArchState struct CPUXtensaState
#include "qemu-common.h"
diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
index 5969d7c3cd96..c06d30d17960 100644
--- a/target/xtensa/translate.c
+++ b/target/xtensa/translate.c
@@ -1664,9 +1664,15 @@ static void translate_ldst(DisasContext *dc, const uint32_t arg[],
gen_load_store_alignment(dc, par[0] & MO_SIZE, addr, par[1]);
}
if (par[2]) {
+ if (par[1]) {
+ tcg_gen_mb(TCG_BAR_STRL | TCG_MO_ALL);
+ }
tcg_gen_qemu_st_tl(cpu_R[arg[0]], addr, dc->cring, par[0]);
} else {
tcg_gen_qemu_ld_tl(cpu_R[arg[0]], addr, dc->cring, par[0]);
+ if (par[1]) {
+ tcg_gen_mb(TCG_BAR_LDAQ | TCG_MO_ALL);
+ }
}
tcg_temp_free(addr);
}
@@ -1823,6 +1829,12 @@ static void translate_mac16(DisasContext *dc, const uint32_t arg[],
}
}
+static void translate_memw(DisasContext *dc, const uint32_t arg[],
+ const uint32_t par[])
+{
+ tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL);
+}
+
static void translate_minmax(DisasContext *dc, const uint32_t arg[],
const uint32_t par[])
{
@@ -2193,29 +2205,33 @@ static void translate_setb_expstate(DisasContext *dc, const uint32_t arg[],
tcg_gen_ori_i32(cpu_UR[EXPSTATE], cpu_UR[EXPSTATE], 1u << arg[0]);
}
+#ifdef CONFIG_USER_ONLY
+static void gen_check_atomctl(DisasContext *dc, TCGv_i32 addr)
+{
+}
+#else
+static void gen_check_atomctl(DisasContext *dc, TCGv_i32 addr)
+{
+ TCGv_i32 tpc = tcg_const_i32(dc->pc);
+
+ gen_helper_check_atomctl(cpu_env, tpc, addr);
+ tcg_temp_free(tpc);
+}
+#endif
+
static void translate_s32c1i(DisasContext *dc, const uint32_t arg[],
const uint32_t par[])
{
if (gen_window_check2(dc, arg[0], arg[1])) {
- TCGLabel *label = gen_new_label();
TCGv_i32 tmp = tcg_temp_local_new_i32();
TCGv_i32 addr = tcg_temp_local_new_i32();
- TCGv_i32 tpc;
tcg_gen_mov_i32(tmp, cpu_R[arg[0]]);
tcg_gen_addi_i32(addr, cpu_R[arg[1]], arg[2]);
gen_load_store_alignment(dc, 2, addr, true);
-
- tpc = tcg_const_i32(dc->pc);
- gen_helper_check_atomctl(cpu_env, tpc, addr);
- tcg_gen_qemu_ld32u(cpu_R[arg[0]], addr, dc->cring);
- tcg_gen_brcond_i32(TCG_COND_NE, cpu_R[arg[0]],
- cpu_SR[SCOMPARE1], label);
-
- tcg_gen_qemu_st32(tmp, addr, dc->cring);
-
- gen_set_label(label);
- tcg_temp_free(tpc);
+ gen_check_atomctl(dc, addr);
+ tcg_gen_atomic_cmpxchg_i32(cpu_R[arg[0]], addr, cpu_SR[SCOMPARE1],
+ tmp, dc->cring, MO_32);
tcg_temp_free(addr);
tcg_temp_free(tmp);
}
@@ -2828,7 +2844,7 @@ static const XtensaOpcodeOps core_ops[] = {
.translate = translate_extui,
}, {
.name = "extw",
- .translate = translate_nop,
+ .translate = translate_memw,
}, {
.name = "hwwdtlba",
.translate = translate_ill,
@@ -2945,7 +2961,7 @@ static const XtensaOpcodeOps core_ops[] = {
.par = (const uint32_t[]){TCG_COND_GEU},
}, {
.name = "memw",
- .translate = translate_nop,
+ .translate = translate_memw,
}, {
.name = "min",
.translate = translate_minmax,
--
2.11.0
next prev parent reply other threads:[~2018-02-28 22:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-28 22:15 [Qemu-devel] [PATCH v2 00/11] linux-user support for target/xtensa Max Filippov
2018-02-28 22:15 ` [Qemu-devel] [PATCH v2 01/11] target/xtensa: dump correct physical registers Max Filippov
2018-02-28 22:16 ` [Qemu-devel] [PATCH v2 02/11] target/xtensa: mark register windows in the dump Max Filippov
2018-02-28 22:16 ` [Qemu-devel] [PATCH v2 03/11] target/xtensa: use correct number of registers in gdbstub Max Filippov
2018-02-28 22:16 ` Max Filippov [this message]
2018-02-28 22:16 ` [Qemu-devel] [PATCH v2 05/11] linux-user: fix mmap/munmap/mprotect/mremap/shmat Max Filippov
2018-02-28 22:16 ` [Qemu-devel] [PATCH v2 06/11] linux-user: fix assertion in shmdt Max Filippov
2018-03-01 10:14 ` Laurent Vivier
2018-03-09 19:57 ` Laurent Vivier
2018-02-28 22:16 ` [Qemu-devel] [PATCH v2 07/11] linux-user: fix target_mprotect/target_munmap error return values Max Filippov
2018-03-01 9:42 ` Laurent Vivier
2018-03-09 19:57 ` Laurent Vivier
2018-02-28 22:16 ` [Qemu-devel] [PATCH v2 08/11] linux-user: drop unused target_msync function Max Filippov
2018-03-01 9:28 ` Laurent Vivier
2018-03-09 19:58 ` Laurent Vivier
2018-02-28 22:16 ` [Qemu-devel] [PATCH v2 09/11] target/xtensa: add linux-user support Max Filippov
2018-02-28 22:16 ` [Qemu-devel] [PATCH v2 10/11] qemu-binfmt-conf.sh: add qemu-xtensa Max Filippov
2018-03-01 14:13 ` Laurent Vivier
2018-03-09 19:58 ` Laurent Vivier
2018-03-09 20:55 ` Max Filippov
2018-02-28 22:16 ` [Qemu-devel] [PATCH v2 11/11] MAINTAINERS: fix W: address for xtensa Max Filippov
2018-02-28 22:29 ` [Qemu-devel] [PATCH v2 00/11] linux-user support for target/xtensa no-reply
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=20180228221609.11265-5-jcmvbkbc@gmail.com \
--to=jcmvbkbc@gmail.com \
--cc=cota@braap.org \
--cc=qemu-devel@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).