All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alvise Rigo <a.rigo@virtualopensystems.com>
To: qemu-devel@nongnu.org, mttcg@listserver.greensocs.com
Cc: claudio.fontana@huawei.com, pbonzini@redhat.com,
	jani.kokkonen@huawei.com, tech@virtualopensystems.com,
	alex.bennee@linaro.org, rth@twiddle.net
Subject: [Qemu-devel] [RFC v6 05/14] tcg: Create new runtime helpers for excl accesses
Date: Mon, 14 Dec 2015 09:41:29 +0100	[thread overview]
Message-ID: <1450082498-27109-6-git-send-email-a.rigo@virtualopensystems.com> (raw)
In-Reply-To: <1450082498-27109-1-git-send-email-a.rigo@virtualopensystems.com>

Introduce a set of new runtime helpers do handle exclusive instructions.
This helpers are used as hooks to call the respective LL/SC helpers in
softmmu_llsc_template.h from TCG code.

Suggested-by: Jani Kokkonen <jani.kokkonen@huawei.com>
Suggested-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Alvise Rigo <a.rigo@virtualopensystems.com>
---
 Makefile.target             |   2 +-
 include/exec/helper-gen.h   |   1 +
 include/exec/helper-proto.h |   1 +
 include/exec/helper-tcg.h   |   1 +
 tcg-llsc-helper.c           | 109 ++++++++++++++++++++++++++++++++++++++++++++
 tcg-llsc-helper.h           |  35 ++++++++++++++
 tcg/tcg-llsc-gen-helper.h   |  32 +++++++++++++
 7 files changed, 180 insertions(+), 1 deletion(-)
 create mode 100644 tcg-llsc-helper.c
 create mode 100644 tcg-llsc-helper.h
 create mode 100644 tcg/tcg-llsc-gen-helper.h

diff --git a/Makefile.target b/Makefile.target
index 962d004..e9fbcdc 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -135,7 +135,7 @@ obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
 obj-y += qtest.o bootdevice.o
 obj-y += hw/
 obj-$(CONFIG_KVM) += kvm-all.o
-obj-y += memory.o cputlb.o
+obj-y += memory.o cputlb.o tcg-llsc-helper.o
 obj-y += memory_mapping.o
 obj-y += dump.o
 obj-y += migration/ram.o migration/savevm.o
diff --git a/include/exec/helper-gen.h b/include/exec/helper-gen.h
index 0d0da3a..d45cdad2 100644
--- a/include/exec/helper-gen.h
+++ b/include/exec/helper-gen.h
@@ -60,6 +60,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret)          \
 #include "trace/generated-helpers.h"
 #include "trace/generated-helpers-wrappers.h"
 #include "tcg-runtime.h"
+#include "tcg-llsc-gen-helper.h"
 
 #undef DEF_HELPER_FLAGS_0
 #undef DEF_HELPER_FLAGS_1
diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h
index effdd43..90be2fd 100644
--- a/include/exec/helper-proto.h
+++ b/include/exec/helper-proto.h
@@ -29,6 +29,7 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \
 #include "helper.h"
 #include "trace/generated-helpers.h"
 #include "tcg-runtime.h"
+#include "tcg/tcg-llsc-gen-helper.h"
 
 #undef DEF_HELPER_FLAGS_0
 #undef DEF_HELPER_FLAGS_1
diff --git a/include/exec/helper-tcg.h b/include/exec/helper-tcg.h
index 79fa3c8..0c0dc71 100644
--- a/include/exec/helper-tcg.h
+++ b/include/exec/helper-tcg.h
@@ -38,6 +38,7 @@
 #include "helper.h"
 #include "trace/generated-helpers.h"
 #include "tcg-runtime.h"
+#include "tcg-llsc-gen-helper.h"
 
 #undef DEF_HELPER_FLAGS_0
 #undef DEF_HELPER_FLAGS_1
diff --git a/tcg-llsc-helper.c b/tcg-llsc-helper.c
new file mode 100644
index 0000000..04cc8b1
--- /dev/null
+++ b/tcg-llsc-helper.c
@@ -0,0 +1,109 @@
+/*
+ * Runtime helpers for atomic istruction emulation
+ *
+ * Copyright (c) 2015 Virtual Open Systems
+ *
+ * Authors:
+ *  Alvise Rigo <a.rigo@virtualopensystems.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "exec/cpu_ldst.h"
+#include "exec/helper-head.h"
+#include "tcg-llsc-helper.h"
+
+#define LDEX_HELPER(SUFF, OPC, FUNC)                                    \
+uint32_t HELPER(ldlink_aa32_i##SUFF)(CPUArchState *env, uint32_t addr,  \
+                                                       uint32_t index)  \
+{                                                                       \
+    CPUArchState *state = env;                                          \
+    TCGMemOpIdx op;                                                     \
+                                                                        \
+    op = make_memop_idx(OPC, index);                                    \
+                                                                        \
+    return (uint32_t)FUNC(state, addr, op, GETRA());                    \
+}
+
+LDEX_HELPER(8, MO_UB, helper_ret_ldlinkub_mmu)
+
+LDEX_HELPER(16_be, MO_BEUW, helper_be_ldlinkuw_mmu)
+LDEX_HELPER(32_be, MO_BEUL, helper_be_ldlinkul_mmu)
+
+uint64_t HELPER(ldlink_aa32_i64_be)(CPUArchState *env, uint32_t addr,
+                                    uint32_t index)
+{
+    CPUArchState *state = env;
+    TCGMemOpIdx op;
+
+    op = make_memop_idx(MO_BEQ, index);
+
+    return helper_be_ldlinkq_mmu(state, addr, op, GETRA());
+}
+
+LDEX_HELPER(16_le, MO_LEUW, helper_le_ldlinkuw_mmu)
+LDEX_HELPER(32_le, MO_LEUL, helper_le_ldlinkq_mmu)
+
+uint64_t HELPER(ldlink_aa32_i64_le)(CPUArchState *env, uint32_t addr,
+                                    uint32_t index)
+{
+    CPUArchState *state = env;
+    TCGMemOpIdx op;
+
+    op = make_memop_idx(MO_LEQ, index);
+
+    return helper_le_ldlinkq_mmu(state, addr, op, GETRA());
+}
+
+#define STEX_HELPER(SUFF, DATA_TYPE, OPC, FUNC)                         \
+uint32_t HELPER(stcond_aa32_i##SUFF)(CPUArchState *env, uint32_t addr,  \
+                                     uint32_t val, uint32_t index)      \
+{                                                                       \
+    CPUArchState *state = env;                                          \
+    TCGMemOpIdx op;                                                     \
+                                                                        \
+    op = make_memop_idx(OPC, index);                                    \
+                                                                        \
+    return (uint32_t)FUNC(state, addr, val, op, GETRA());               \
+}
+
+STEX_HELPER(8, uint8_t, MO_UB, helper_ret_stcondb_mmu)
+
+STEX_HELPER(16_be, uint16_t, MO_BEUW, helper_be_stcondw_mmu)
+STEX_HELPER(32_be, uint32_t, MO_BEUL, helper_be_stcondl_mmu)
+
+uint32_t HELPER(stcond_aa32_i64_be)(CPUArchState *env, uint32_t addr,
+                                    uint64_t val, uint32_t index)
+{
+    CPUArchState *state = env;
+    TCGMemOpIdx op;
+
+    op = make_memop_idx(MO_BEQ, index);
+
+    return (uint32_t)helper_be_stcondq_mmu(state, addr, val, op, GETRA());
+}
+
+STEX_HELPER(16_le, uint16_t, MO_LEUW, helper_le_stcondw_mmu)
+STEX_HELPER(32_le, uint32_t, MO_LEUL, helper_le_stcondl_mmu)
+
+uint32_t HELPER(stcond_aa32_i64_le)(CPUArchState *env, uint32_t addr,
+                                    uint64_t val, uint32_t index)
+{
+    CPUArchState *state = env;
+    TCGMemOpIdx op;
+
+    op = make_memop_idx(MO_LEQ, index);
+
+    return (uint32_t)helper_le_stcondq_mmu(state, addr, val, op, GETRA());
+}
diff --git a/tcg-llsc-helper.h b/tcg-llsc-helper.h
new file mode 100644
index 0000000..bbe42c3
--- /dev/null
+++ b/tcg-llsc-helper.h
@@ -0,0 +1,35 @@
+#ifndef HELPER_LLSC_HEAD_H
+#define HELPER_LLSC_HEAD_H 1
+
+uint32_t HELPER(ldlink_aa32_i8)(CPUArchState *env, uint32_t addr,
+                                uint32_t index);
+uint32_t HELPER(ldlink_aa32_i16_be)(CPUArchState *env, uint32_t addr,
+                                    uint32_t index);
+uint32_t HELPER(ldlink_aa32_i32_be)(CPUArchState *env, uint32_t addr,
+                                    uint32_t index);
+uint64_t HELPER(ldlink_aa32_i64_be)(CPUArchState *env, uint32_t addr,
+                                    uint32_t index);
+uint32_t HELPER(ldlink_aa32_i16_le)(CPUArchState *env, uint32_t addr,
+                                    uint32_t index);
+uint32_t HELPER(ldlink_aa32_i32_le)(CPUArchState *env, uint32_t addr,
+                                    uint32_t index);
+uint64_t HELPER(ldlink_aa32_i64_le)(CPUArchState *env, uint32_t addr,
+                                    uint32_t index);
+
+
+uint32_t HELPER(stcond_aa32_i8)(CPUArchState *env, uint32_t addr,
+                                uint32_t val, uint32_t index);
+uint32_t HELPER(stcond_aa32_i16_be)(CPUArchState *env, uint32_t addr,
+                                    uint32_t val, uint32_t index);
+uint32_t HELPER(stcond_aa32_i32_be)(CPUArchState *env, uint32_t addr,
+                                    uint32_t val, uint32_t index);
+uint32_t HELPER(stcond_aa32_i64_be)(CPUArchState *env, uint32_t addr,
+                                    uint64_t val, uint32_t index);
+uint32_t HELPER(stcond_aa32_i16_le)(CPUArchState *env, uint32_t addr,
+                                    uint32_t val, uint32_t index);
+uint32_t HELPER(stcond_aa32_i32_le)(CPUArchState *env, uint32_t addr,
+                                    uint32_t val, uint32_t index);
+uint32_t HELPER(stcond_aa32_i64_le)(CPUArchState *env, uint32_t addr,
+                                    uint64_t val, uint32_t index);
+
+#endif
diff --git a/tcg/tcg-llsc-gen-helper.h b/tcg/tcg-llsc-gen-helper.h
new file mode 100644
index 0000000..2b647cd
--- /dev/null
+++ b/tcg/tcg-llsc-gen-helper.h
@@ -0,0 +1,32 @@
+DEF_HELPER_3(ldlink_aa32_i8, i32, env, i32, i32)
+DEF_HELPER_3(ldlink_aa32_i16_be, i32, env, i32, i32)
+DEF_HELPER_3(ldlink_aa32_i32_be, i32, env, i32, i32)
+DEF_HELPER_3(ldlink_aa32_i64_be, i64, env, i32, i32)
+DEF_HELPER_3(ldlink_aa32_i16_le, i32, env, i32, i32)
+DEF_HELPER_3(ldlink_aa32_i32_le, i32, env, i32, i32)
+DEF_HELPER_3(ldlink_aa32_i64_le, i64, env, i32, i32)
+
+DEF_HELPER_4(stcond_aa32_i8, i32, env, i32, i32, i32)
+DEF_HELPER_4(stcond_aa32_i16_be, i32, env, i32, i32, i32)
+DEF_HELPER_4(stcond_aa32_i32_be, i32, env, i32, i32, i32)
+DEF_HELPER_4(stcond_aa32_i64_be, i32, env, i32, i64, i32)
+DEF_HELPER_4(stcond_aa32_i16_le, i32, env, i32, i32, i32)
+DEF_HELPER_4(stcond_aa32_i32_le, i32, env, i32, i32, i32)
+DEF_HELPER_4(stcond_aa32_i64_le, i32, env, i32, i64, i32)
+
+/* Convenient aliases */
+#ifdef TARGET_WORDS_BIGENDIAN
+#define gen_helper_stcond_aa32_i16 gen_helper_stcond_aa32_i16_be
+#define gen_helper_stcond_aa32_i32 gen_helper_stcond_aa32_i32_be
+#define gen_helper_stcond_aa32_i64 gen_helper_stcond_aa32_i64_be
+#define gen_helper_ldlink_aa32_i16 gen_helper_ldlink_aa32_i16_be
+#define gen_helper_ldlink_aa32_i32 gen_helper_ldlink_aa32_i32_be
+#define gen_helper_ldlink_aa32_i64 gen_helper_ldlink_aa32_i64_be
+#else
+#define gen_helper_stcond_aa32_i16 gen_helper_stcond_aa32_i16_le
+#define gen_helper_stcond_aa32_i32 gen_helper_stcond_aa32_i32_le
+#define gen_helper_stcond_aa32_i64 gen_helper_stcond_aa32_i64_le
+#define gen_helper_ldlink_aa32_i16 gen_helper_ldlink_aa32_i16_le
+#define gen_helper_ldlink_aa32_i32 gen_helper_ldlink_aa32_i32_le
+#define gen_helper_ldlink_aa32_i64 gen_helper_ldlink_aa32_i64_le
+#endif
-- 
2.6.4

  parent reply	other threads:[~2015-12-14  8:41 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-14  8:41 [Qemu-devel] [RFC v6 00/14] Slow-path for atomic instruction translation Alvise Rigo
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 01/14] exec.c: Add new exclusive bitmap to ram_list Alvise Rigo
2015-12-18 13:18   ` Alex Bennée
2015-12-18 13:47     ` alvise rigo
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 02/14] softmmu: Add new TLB_EXCL flag Alvise Rigo
2016-01-05 16:10   ` Alex Bennée
2016-01-05 17:27     ` alvise rigo
2016-01-05 18:39       ` Alex Bennée
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 03/14] Add CPUClass hook to set exclusive range Alvise Rigo
2016-01-05 16:42   ` Alex Bennée
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 04/14] softmmu: Add helpers for a new slowpath Alvise Rigo
2016-01-06 15:16   ` Alex Bennée
2015-12-14  8:41 ` Alvise Rigo [this message]
2015-12-14  9:40   ` [Qemu-devel] [RFC v6 05/14] tcg: Create new runtime helpers for excl accesses Paolo Bonzini
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 06/14] configure: Use slow-path for atomic only when the softmmu is enabled Alvise Rigo
2015-12-14  9:38   ` Paolo Bonzini
2015-12-14  9:39     ` Paolo Bonzini
2015-12-14 10:14   ` Laurent Vivier
2015-12-15 14:23     ` alvise rigo
2015-12-15 14:31       ` Paolo Bonzini
2015-12-15 15:18         ` Laurent Vivier
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 07/14] target-arm: translate: Use ld/st excl for atomic insns Alvise Rigo
2016-01-06 17:11   ` Alex Bennée
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 08/14] target-arm: Add atomic_clear helper for CLREX insn Alvise Rigo
2016-01-06 17:13   ` Alex Bennée
2016-01-06 17:27     ` alvise rigo
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 09/14] softmmu: Add history of excl accesses Alvise Rigo
2015-12-14  9:35   ` Paolo Bonzini
2015-12-15 14:26     ` alvise rigo
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 10/14] softmmu: Simplify helper_*_st_name, wrap unaligned code Alvise Rigo
2016-01-07 14:46   ` Alex Bennée
2016-01-07 15:09     ` alvise rigo
2016-01-07 16:35       ` Alex Bennée
2016-01-07 16:54         ` alvise rigo
2016-01-07 17:36           ` Alex Bennée
2016-01-08 11:19   ` Alex Bennée
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 11/14] softmmu: Simplify helper_*_st_name, wrap MMIO code Alvise Rigo
2016-01-11  9:54   ` Alex Bennée
2016-01-11 10:19     ` alvise rigo
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 12/14] softmmu: Simplify helper_*_st_name, wrap RAM code Alvise Rigo
2015-12-17 16:52   ` Alex Bennée
2015-12-17 17:13     ` alvise rigo
2015-12-17 20:20       ` Alex Bennée
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 13/14] softmmu: Include MMIO/invalid exclusive accesses Alvise Rigo
2015-12-14  8:41 ` [Qemu-devel] [RFC v6 14/14] softmmu: Protect MMIO exclusive range Alvise Rigo
2015-12-14  9:33 ` [Qemu-devel] [RFC v6 00/14] Slow-path for atomic instruction translation Paolo Bonzini
2015-12-14 10:04   ` alvise rigo
2015-12-14 10:17     ` Paolo Bonzini
2015-12-15 13:59       ` alvise rigo
2015-12-15 14:18         ` Paolo Bonzini
2015-12-15 14:22           ` alvise rigo
2015-12-14 22:09 ` Andreas Tobler
2015-12-15  8:16   ` alvise rigo
2015-12-17 16:06 ` Alex Bennée
2015-12-17 16:16   ` alvise rigo
2016-01-06 18:00 ` Andrew Baumann
2016-01-07 10:21   ` alvise rigo
2016-01-07 10:22     ` Peter Maydell
2016-01-07 10:49       ` alvise rigo
2016-01-07 11:16         ` Peter Maydell

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=1450082498-27109-6-git-send-email-a.rigo@virtualopensystems.com \
    --to=a.rigo@virtualopensystems.com \
    --cc=alex.bennee@linaro.org \
    --cc=claudio.fontana@huawei.com \
    --cc=jani.kokkonen@huawei.com \
    --cc=mttcg@listserver.greensocs.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=tech@virtualopensystems.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.