All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX
@ 2019-12-16 22:11 Richard Henderson
  2019-12-16 22:11 ` [PATCH v2 01/28] target/xtensa: Use probe_access for itlb_hit_test Richard Henderson
                   ` (27 more replies)
  0 siblings, 28 replies; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marek Vasut, Peter Maydell, Eduardo Habkost, David Hildenbrand,
	Chris Wulff, Laurent Vivier, Max Filippov, Aleksandar Markovic,
	Paolo Bonzini, Edgar E . Iglesias, Aleksandar Rikalo,
	Guan Xuetao, Aurelien Jarno, David Gibson

This is part of a project to raise the limit on NB_MMU_MODES.

One of those is in cpu_ldst.h, in support of MMU_MODE*_SUFFIX.
While this could be extended, it's not the best interface for
such things.  Better is a single interface that allows a variable
mmu_idx.  The best exemplars of that is the usage in target/mips
and target/ppc.

In the process, I tried to clean up the implementation of these
functions for softmmu and user-only.

Aleksander asked about code size changes.  They vary between
a minor size increase (e.g. for qemu-system-alpha, where there
are in fact no uses of the functions, which are now present as
out-of-line functions rather than eliminated inline functions),
to a minor size decrease (e.g. -79k/-1.6% for qemu-system-i386).
See below for details.

Changes for v2:
  * Significantly revised docs/devel/loads-stores.rst.
  * m68k and s390x dropped #defines and use *_mmuidx_ra directly.


r~


Cc: Aleksandar Markovic <amarkovic@wavecomp.com>
Cc: Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Chris Wulff <crwulff@gmail.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: David Hildenbrand <david@redhat.com>
Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: Marek Vasut <marex@denx.de>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>


Richard Henderson (28):
  target/xtensa: Use probe_access for itlb_hit_test
  cputlb: Use trace_mem_get_info instead of trace_mem_build_info
  trace: Remove trace_mem_build_info_no_se_[bl]e
  cputlb: Move body of cpu_ldst_template.h out of line
  translator: Use cpu_ld*_code instead of open-coding
  cputlb: Rename helper_ret_ld*_cmmu to cpu_ld*_code
  cputlb: Provide cpu_(ld,st}*_mmuidx_ra for user-only
  target/i386: Use cpu_*_mmuidx_ra instead of templates
  target/s390x: Include tcg.h in mem_helper.c
  target/arm: Include tcg.h in sve_helper.c
  accel/tcg: Include tcg.h in tcg-runtime.c
  linux-user: Include tcg.h in syscall.c
  linux-user: Include trace-root.h in syscall-trace.h
  cputlb: Expand cpu_ldst_useronly_template.h in user-exec.c
  target/nios2: Remove MMU_MODE{0,1}_SUFFIX
  target/alpha: Remove MMU_MODE{0,1}_SUFFIX
  target/cris: Remove MMU_MODE{0,1}_SUFFIX
  target/i386: Remove MMU_MODE{0,1,2}_SUFFIX
  target/microblaze: Remove MMU_MODE{0,1,2}_SUFFIX
  target/sh4: Remove MMU_MODE{0,1}_SUFFIX
  target/unicore32: Remove MMU_MODE{0,1}_SUFFIX
  target/xtensa: Remove MMU_MODE{0,1,2,3}_SUFFIX
  target/m68k: Use cpu_*_mmuidx_ra instead of MMU_MODE{0,1}_SUFFIX
  target/mips: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
  target/s390x: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
  target/ppc: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
  cputlb: Remove support for MMU_MODE*_SUFFIX
  cputlb: Expand cpu_ldst_template.h in cputlb.c

 accel/tcg/atomic_template.h               |  67 ++--
 include/exec/cpu_ldst.h                   | 444 +++++++---------------
 include/exec/cpu_ldst_template.h          | 211 ----------
 include/exec/cpu_ldst_useronly_template.h | 159 --------
 include/exec/translator.h                 |  48 +--
 include/user/syscall-trace.h              |   2 +
 target/alpha/cpu.h                        |   2 -
 target/cris/cpu.h                         |   2 -
 target/i386/cpu.h                         |   3 -
 target/m68k/cpu.h                         |   2 -
 target/microblaze/cpu.h                   |   3 -
 target/mips/cpu.h                         |   4 -
 target/nios2/cpu.h                        |   2 -
 target/ppc/cpu.h                          |   2 -
 target/s390x/cpu.h                        |   5 -
 target/sh4/cpu.h                          |   2 -
 target/unicore32/cpu.h                    |   2 -
 target/xtensa/cpu.h                       |   4 -
 tcg/tcg.h                                 |  29 --
 trace/mem-internal.h                      |  17 -
 accel/tcg/cputlb.c                        | 315 +++++++++++----
 accel/tcg/tcg-runtime.c                   |   1 +
 accel/tcg/user-exec.c                     | 236 ++++++++++++
 linux-user/syscall.c                      |   1 +
 target/arm/sve_helper.c                   |   1 +
 target/i386/seg_helper.c                  |  56 +--
 target/m68k/op_helper.c                   |  77 ++--
 target/mips/op_helper.c                   | 182 +++------
 target/ppc/mem_helper.c                   |  11 +-
 target/s390x/mem_helper.c                 |  22 +-
 target/xtensa/mmu_helper.c                |   5 +-
 docs/devel/loads-stores.rst               | 215 ++++++++---
 32 files changed, 966 insertions(+), 1166 deletions(-)
 delete mode 100644 include/exec/cpu_ldst_template.h
 delete mode 100644 include/exec/cpu_ldst_useronly_template.h

-- 
2.20.1


orig    new
text    text
size    size    change  %change binary
------- ------- ------- ------- -----------------
2097672	2101864	4192	0.20%	qemu-aarch64
2102760	2107304	4544	0.22%	qemu-aarch64_be
961464	965960	4496	0.47%	qemu-alpha
1463736	1468200	4464	0.30%	qemu-arm
1470072	1474632	4560	0.31%	qemu-armeb
990584	995224	4640	0.47%	qemu-cris
1009656	1012792	3136	0.31%	qemu-hppa
1295728	1250064	-45664	-3.52%	qemu-i386
1091560	1091928	368	0.03%	qemu-m68k
965720	970232	4512	0.47%	qemu-microblaze
961000	965496	4496	0.47%	qemu-microblazeel
1959864	1957224	-2640	-0.13%	qemu-mips
2001688	2003768	2080	0.10%	qemu-mips64
1996184	1998232	2048	0.10%	qemu-mips64el
1954648	1951928	-2720	-0.14%	qemu-mipsel
2004936	2006888	1952	0.10%	qemu-mipsn32
1999272	1999320	48	0.00%	qemu-mipsn32el
933400	937896	4496	0.48%	qemu-nios2
964024	969176	5152	0.53%	qemu-or1k
1643400	1643272	-128	-0.01%	qemu-ppc
1670168	1669192	-976	-0.06%	qemu-ppc64
1693048	1691784	-1264	-0.07%	qemu-ppc64abi32
1667880	1667080	-800	-0.05%	qemu-ppc64le
973416	978024	4608	0.47%	qemu-riscv32
970664	975112	4448	0.46%	qemu-riscv64
1176952	1159928	-17024	-1.45%	qemu-s390x
970600	974808	4208	0.43%	qemu-sh4
975368	979656	4288	0.44%	qemu-sh4eb
981992	986424	4432	0.45%	qemu-sparc
1020168	1024008	3840	0.38%	qemu-sparc32plus
1022264	1026072	3808	0.37%	qemu-sparc64
926616	930872	4256	0.46%	qemu-tilegx
1300464	1249504	-50960	-3.92%	qemu-x86_64
1236648	1240952	4304	0.35%	qemu-xtensa
1241896	1246360	4464	0.36%	qemu-xtensaeb

orig    new
text    text
size    size    change  %change binary
------- ------- ------- ------- -----------------
6324680	6327256	2576	0.04%	qemu-system-aarch64
3961000	3966200	5200	0.13%	qemu-system-alpha
5580408	5583768	3360	0.06%	qemu-system-arm
2816936	2822072	5136	0.18%	qemu-system-cris
3969576	3971624	2048	0.05%	qemu-system-hppa
4856824	4777432	-79392	-1.63%	qemu-system-i386
2936584	2940984	4400	0.15%	qemu-system-lm32
3010216	3002088	-8128	-0.27%	qemu-system-m68k
2817400	2822264	4864	0.17%	qemu-system-microblaze
2817160	2821912	4752	0.17%	qemu-system-microblazeel
5098264	5101288	3024	0.06%	qemu-system-mips
5205096	5206408	1312	0.03%	qemu-system-mips64
5222424	5223704	1280	0.02%	qemu-system-mips64el
5094216	5097048	2832	0.06%	qemu-system-mipsel
2729320	2733448	4128	0.15%	qemu-system-moxie
2750200	2755048	4848	0.18%	qemu-system-nios2
2777656	2782840	5184	0.19%	qemu-system-or1k
5020408	5018312	-2096	-0.04%	qemu-system-ppc
5401848	5396936	-4912	-0.09%	qemu-system-ppc64
4029464	4034520	5056	0.13%	qemu-system-riscv32
4030632	4035320	4688	0.12%	qemu-system-riscv64
3576984	3523992	-52992	-1.48%	qemu-system-s390x
3952872	3958376	5504	0.14%	qemu-system-sh4
3957032	3962680	5648	0.14%	qemu-system-sh4eb
3003368	3009048	5680	0.19%	qemu-system-sparc
4013240	4018040	4800	0.12%	qemu-system-sparc64
2936472	2923080	-13392	-0.46%	qemu-system-tricore
2824456	2829560	5104	0.18%	qemu-system-unicore32
4886520	4816088	-70432	-1.44%	qemu-system-x86_64
4160168	4165400	5232	0.13%	qemu-system-xtensa
4164232	4169528	5296	0.13%	qemu-system-xtensaeb



^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 01/28] target/xtensa: Use probe_access for itlb_hit_test
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-17  3:51   ` Philippe Mathieu-Daudé
  2019-12-20 14:15   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 02/28] cputlb: Use trace_mem_get_info instead of trace_mem_build_info Richard Henderson
                   ` (26 subsequent siblings)
  27 siblings, 2 replies; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov

We don't actually need the result of the read, only to probe that the
memory mapping exists.  This is exactly what probe_access does.

This is also the only user of any cpu_ld*_code_ra function.
Removing this allows the interface to be removed shortly.

Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/xtensa/mmu_helper.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c
index f15bff306f..b01ff9399a 100644
--- a/target/xtensa/mmu_helper.c
+++ b/target/xtensa/mmu_helper.c
@@ -63,10 +63,11 @@
 void HELPER(itlb_hit_test)(CPUXtensaState *env, uint32_t vaddr)
 {
     /*
-     * Attempt the memory load; we don't care about the result but
+     * Probe the memory; we don't care about the result but
      * only the side-effects (ie any MMU or other exception)
      */
-    cpu_ldub_code_ra(env, vaddr, GETPC());
+    probe_access(env, vaddr, 1, MMU_INST_FETCH,
+                 cpu_mmu_index(env, true), GETPC());
 }
 
 void HELPER(wsr_rasid)(CPUXtensaState *env, uint32_t v)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 02/28] cputlb: Use trace_mem_get_info instead of trace_mem_build_info
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
  2019-12-16 22:11 ` [PATCH v2 01/28] target/xtensa: Use probe_access for itlb_hit_test Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-17  3:59   ` Philippe Mathieu-Daudé
  2019-12-20 15:04   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 03/28] trace: Remove trace_mem_build_info_no_se_[bl]e Richard Henderson
                   ` (25 subsequent siblings)
  27 siblings, 2 replies; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel

In the cpu_ldst templates, we already require a MemOp, and it
is cleaner and clearer to pass that instead of 3 separate
arguments describing the memory operation.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu_ldst_template.h          | 22 +++++++++++-----------
 include/exec/cpu_ldst_useronly_template.h | 12 ++++++------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
index 54b5e858ce..0ad5de3ef9 100644
--- a/include/exec/cpu_ldst_template.h
+++ b/include/exec/cpu_ldst_template.h
@@ -86,9 +86,9 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
     RES_TYPE res;
     target_ulong addr;
     int mmu_idx = CPU_MMU_INDEX;
-    TCGMemOpIdx oi;
+    MemOp op = MO_TE | SHIFT;
 #if !defined(SOFTMMU_CODE_ACCESS)
-    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false, mmu_idx);
+    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
     trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
 #endif
 
@@ -96,9 +96,9 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
     entry = tlb_entry(env, mmu_idx, addr);
     if (unlikely(entry->ADDR_READ !=
                  (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
-        oi = make_memop_idx(SHIFT, mmu_idx);
+        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
         res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr,
-                                                            oi, retaddr);
+                                                               oi, retaddr);
     } else {
         uintptr_t hostaddr = addr + entry->addend;
         res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr);
@@ -125,9 +125,9 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
     int res;
     target_ulong addr;
     int mmu_idx = CPU_MMU_INDEX;
-    TCGMemOpIdx oi;
-#if !defined(SOFTMMU_CODE_ACCESS)
-    uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false, mmu_idx);
+    MemOp op = MO_TE | MO_SIGN | SHIFT;
+#ifndef SOFTMMU_CODE_ACCESS
+    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
     trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
 #endif
 
@@ -135,7 +135,7 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
     entry = tlb_entry(env, mmu_idx, addr);
     if (unlikely(entry->ADDR_READ !=
                  (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
-        oi = make_memop_idx(SHIFT, mmu_idx);
+        TCGMemOpIdx oi = make_memop_idx(op & ~MO_SIGN, mmu_idx);
         res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX),
                                MMUSUFFIX)(env, addr, oi, retaddr);
     } else {
@@ -167,9 +167,9 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
     CPUTLBEntry *entry;
     target_ulong addr;
     int mmu_idx = CPU_MMU_INDEX;
-    TCGMemOpIdx oi;
+    MemOp op = MO_TE | SHIFT;
 #if !defined(SOFTMMU_CODE_ACCESS)
-    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true, mmu_idx);
+    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, true);
     trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
 #endif
 
@@ -177,7 +177,7 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
     entry = tlb_entry(env, mmu_idx, addr);
     if (unlikely(tlb_addr_write(entry) !=
                  (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
-        oi = make_memop_idx(SHIFT, mmu_idx);
+        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
         glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi,
                                                      retaddr);
     } else {
diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h
index dbdc7a845d..e5a3d1983a 100644
--- a/include/exec/cpu_ldst_useronly_template.h
+++ b/include/exec/cpu_ldst_useronly_template.h
@@ -70,8 +70,8 @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
     ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
     clear_helper_retaddr();
 #else
-    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false,
-                                            MMU_USER_IDX);
+    MemOp op = MO_TE | SHIFT;
+    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
     trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
     ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
 #endif
@@ -102,8 +102,8 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
     ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
     clear_helper_retaddr();
 #else
-    uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false,
-                                            MMU_USER_IDX);
+    MemOp op = MO_TE | MO_SIGN | SHIFT;
+    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
     trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
     ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
     qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
@@ -131,8 +131,8 @@ static inline void
 glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
                                       RES_TYPE v)
 {
-    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true,
-                                            MMU_USER_IDX);
+    MemOp op = MO_TE | SHIFT;
+    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, true);
     trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
     glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
     qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 03/28] trace: Remove trace_mem_build_info_no_se_[bl]e
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
  2019-12-16 22:11 ` [PATCH v2 01/28] target/xtensa: Use probe_access for itlb_hit_test Richard Henderson
  2019-12-16 22:11 ` [PATCH v2 02/28] cputlb: Use trace_mem_get_info instead of trace_mem_build_info Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 16:38   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 04/28] cputlb: Move body of cpu_ldst_template.h out of line Richard Henderson
                   ` (24 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel

It is easy for the atomic helpers to use trace_mem_build_info
directly, without resorting to symbol pasting.  For this usage,
we cannot use trace_mem_get_info, because the MemOp does not
support 16-byte accesses.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 accel/tcg/atomic_template.h | 67 +++++++++++++------------------------
 trace/mem-internal.h        | 17 ----------
 2 files changed, 24 insertions(+), 60 deletions(-)

diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h
index 837676231f..26969487d6 100644
--- a/accel/tcg/atomic_template.h
+++ b/accel/tcg/atomic_template.h
@@ -64,13 +64,10 @@
    the ATOMIC_NAME macro, and redefined below.  */
 #if DATA_SIZE == 1
 # define END
-# define MEND _be /* either le or be would be fine */
 #elif defined(HOST_WORDS_BIGENDIAN)
 # define END  _be
-# define MEND _be
 #else
 # define END  _le
-# define MEND _le
 #endif
 
 ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
@@ -79,8 +76,8 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
     ATOMIC_MMU_DECLS;
     DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
     DATA_TYPE ret;
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
-                                                           ATOMIC_MMU_IDX);
+    uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
+                                         ATOMIC_MMU_IDX);
 
     atomic_trace_rmw_pre(env, addr, info);
 #if DATA_SIZE == 16
@@ -99,8 +96,8 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS)
 {
     ATOMIC_MMU_DECLS;
     DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP;
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
-                                                           ATOMIC_MMU_IDX);
+    uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
+                                         ATOMIC_MMU_IDX);
 
     atomic_trace_ld_pre(env, addr, info);
     val = atomic16_read(haddr);
@@ -114,8 +111,8 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr,
 {
     ATOMIC_MMU_DECLS;
     DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, true,
-                                                          ATOMIC_MMU_IDX);
+    uint16_t info = trace_mem_build_info(SHIFT, false, 0, true,
+                                         ATOMIC_MMU_IDX);
 
     atomic_trace_st_pre(env, addr, info);
     atomic16_set(haddr, val);
@@ -130,8 +127,8 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr,
     ATOMIC_MMU_DECLS;
     DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
     DATA_TYPE ret;
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
-                                                          ATOMIC_MMU_IDX);
+    uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
+                                         ATOMIC_MMU_IDX);
 
     atomic_trace_rmw_pre(env, addr, info);
     ret = atomic_xchg__nocheck(haddr, val);
@@ -147,10 +144,8 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,       \
     ATOMIC_MMU_DECLS;                                               \
     DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;                           \
     DATA_TYPE ret;                                                  \
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,   \
-                                                           false,   \
-                                                           ATOMIC_MMU_IDX); \
-                                                                    \
+    uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,    \
+                                         ATOMIC_MMU_IDX);           \
     atomic_trace_rmw_pre(env, addr, info);                          \
     ret = atomic_##X(haddr, val);                                   \
     ATOMIC_MMU_CLEANUP;                                             \
@@ -183,10 +178,8 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,       \
     ATOMIC_MMU_DECLS;                                               \
     XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;                          \
     XDATA_TYPE cmp, old, new, val = xval;                           \
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,   \
-                                                           false,   \
-                                                           ATOMIC_MMU_IDX); \
-                                                                    \
+    uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,    \
+                                         ATOMIC_MMU_IDX);           \
     atomic_trace_rmw_pre(env, addr, info);                          \
     smp_mb();                                                       \
     cmp = atomic_read__nocheck(haddr);                              \
@@ -213,7 +206,6 @@ GEN_ATOMIC_HELPER_FN(umax_fetch, MAX,  DATA_TYPE, new)
 #endif /* DATA SIZE >= 16 */
 
 #undef END
-#undef MEND
 
 #if DATA_SIZE > 1
 
@@ -221,10 +213,8 @@ GEN_ATOMIC_HELPER_FN(umax_fetch, MAX,  DATA_TYPE, new)
    within the ATOMIC_NAME macro.  */
 #ifdef HOST_WORDS_BIGENDIAN
 # define END  _le
-# define MEND _le
 #else
 # define END  _be
-# define MEND _be
 #endif
 
 ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
@@ -233,9 +223,8 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
     ATOMIC_MMU_DECLS;
     DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
     DATA_TYPE ret;
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
-                                                           false,
-                                                           ATOMIC_MMU_IDX);
+    uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, false,
+                                         ATOMIC_MMU_IDX);
 
     atomic_trace_rmw_pre(env, addr, info);
 #if DATA_SIZE == 16
@@ -254,9 +243,8 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS)
 {
     ATOMIC_MMU_DECLS;
     DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP;
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
-                                                           false,
-                                                           ATOMIC_MMU_IDX);
+    uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, false,
+                                         ATOMIC_MMU_IDX);
 
     atomic_trace_ld_pre(env, addr, info);
     val = atomic16_read(haddr);
@@ -270,9 +258,8 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr,
 {
     ATOMIC_MMU_DECLS;
     DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
-                                                           true,
-                                                           ATOMIC_MMU_IDX);
+    uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, true,
+                                         ATOMIC_MMU_IDX);
 
     val = BSWAP(val);
     atomic_trace_st_pre(env, addr, info);
@@ -289,9 +276,8 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr,
     ATOMIC_MMU_DECLS;
     DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
     ABI_TYPE ret;
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
-                                                           false,
-                                                           ATOMIC_MMU_IDX);
+    uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, false,
+                                         ATOMIC_MMU_IDX);
 
     atomic_trace_rmw_pre(env, addr, info);
     ret = atomic_xchg__nocheck(haddr, BSWAP(val));
@@ -307,10 +293,8 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,       \
     ATOMIC_MMU_DECLS;                                               \
     DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;                           \
     DATA_TYPE ret;                                                  \
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,   \
-                                                           false,   \
-                                                           ATOMIC_MMU_IDX); \
-                                                                    \
+    uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP,    \
+                                         false, ATOMIC_MMU_IDX);    \
     atomic_trace_rmw_pre(env, addr, info);                          \
     ret = atomic_##X(haddr, BSWAP(val));                            \
     ATOMIC_MMU_CLEANUP;                                             \
@@ -341,10 +325,8 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,       \
     ATOMIC_MMU_DECLS;                                               \
     XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;                          \
     XDATA_TYPE ldo, ldn, old, new, val = xval;                      \
-    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,   \
-                                                           false,   \
-                                                           ATOMIC_MMU_IDX); \
-                                                                    \
+    uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP,    \
+                                         false, ATOMIC_MMU_IDX);    \
     atomic_trace_rmw_pre(env, addr, info);                          \
     smp_mb();                                                       \
     ldn = atomic_read__nocheck(haddr);                              \
@@ -378,7 +360,6 @@ GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new)
 #endif /* DATA_SIZE >= 16 */
 
 #undef END
-#undef MEND
 #endif /* DATA_SIZE > 1 */
 
 #undef BSWAP
diff --git a/trace/mem-internal.h b/trace/mem-internal.h
index 0a32aa22ca..8b72b678fa 100644
--- a/trace/mem-internal.h
+++ b/trace/mem-internal.h
@@ -47,21 +47,4 @@ static inline uint16_t trace_mem_get_info(MemOp op,
                                 mmu_idx);
 }
 
-/* Used by the atomic helpers */
-static inline
-uint16_t trace_mem_build_info_no_se_be(int size_shift, bool store,
-                                       TCGMemOpIdx oi)
-{
-    return trace_mem_build_info(size_shift, false, MO_BE, store,
-                                get_mmuidx(oi));
-}
-
-static inline
-uint16_t trace_mem_build_info_no_se_le(int size_shift, bool store,
-                                       TCGMemOpIdx oi)
-{
-    return trace_mem_build_info(size_shift, false, MO_LE, store,
-                                get_mmuidx(oi));
-}
-
 #endif /* TRACE__MEM_INTERNAL_H */
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 04/28] cputlb: Move body of cpu_ldst_template.h out of line
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (2 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 03/28] trace: Remove trace_mem_build_info_no_se_[bl]e Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 17:07   ` Alex Bennée
  2019-12-20 18:36   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 05/28] translator: Use cpu_ld*_code instead of open-coding Richard Henderson
                   ` (23 subsequent siblings)
  27 siblings, 2 replies; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel

With the tracing hooks, the inline functions are no longer
so simple.  Once out-of-line, the current tlb_entry lookup
is redundant with the one in the main load/store_helper.

This also begins the introduction of a new target facing
interface, with suffix *_mmuidx_ra.  This is not yet
official because the interface is not done for user-only.

Use abi_ptr instead of target_ulong in preparation for
user-only; the two types are identical for softmmu.

What remains in cpu_ldst_template.h are the expansions
for _code, _data, and MMU_MODE<N>_SUFFIX.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu_ldst.h          |  25 ++++++-
 include/exec/cpu_ldst_template.h | 125 +++++++------------------------
 accel/tcg/cputlb.c               | 116 ++++++++++++++++++++++++++++
 3 files changed, 166 insertions(+), 100 deletions(-)

diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index fd499f7e2f..cf8af36dbc 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -152,7 +152,7 @@ static inline void clear_helper_retaddr(void)
 
 #else
 
-/* The memory helpers for tcg-generated code need tcg_target_long etc.  */
+/* Needed for TCG_OVERSIZED_GUEST */
 #include "tcg.h"
 
 static inline target_ulong tlb_addr_write(const CPUTLBEntry *entry)
@@ -185,6 +185,29 @@ static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx,
     return &env_tlb(env)->f[mmu_idx].table[tlb_index(env, mmu_idx, addr)];
 }
 
+uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                            int mmu_idx, uintptr_t ra);
+uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                            int mmu_idx, uintptr_t ra);
+uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                           int mmu_idx, uintptr_t ra);
+uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                           int mmu_idx, uintptr_t ra);
+
+int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                       int mmu_idx, uintptr_t ra);
+int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                       int mmu_idx, uintptr_t ra);
+
+void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
+                       int mmu_idx, uintptr_t retaddr);
+void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
+                       int mmu_idx, uintptr_t retaddr);
+void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
+                       int mmu_idx, uintptr_t retaddr);
+void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
+                       int mmu_idx, uintptr_t retaddr);
+
 #ifdef MMU_MODE0_SUFFIX
 #define CPU_MMU_INDEX 0
 #define MEMSUFFIX MMU_MODE0_SUFFIX
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
index 0ad5de3ef9..ea39e29c19 100644
--- a/include/exec/cpu_ldst_template.h
+++ b/include/exec/cpu_ldst_template.h
@@ -24,13 +24,6 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#if !defined(SOFTMMU_CODE_ACCESS)
-#include "trace-root.h"
-#endif
-
-#include "qemu/plugin.h"
-#include "trace/mem.h"
-
 #if DATA_SIZE == 8
 #define SUFFIX q
 #define USUFFIX q
@@ -63,56 +56,40 @@
 #define RES_TYPE uint32_t
 #endif
 
+/* generic load/store macros */
+
 #ifdef SOFTMMU_CODE_ACCESS
-#define ADDR_READ addr_code
-#define MMUSUFFIX _cmmu
-#define URETSUFFIX USUFFIX
-#define SRETSUFFIX glue(s, SUFFIX)
-#else
-#define ADDR_READ addr_read
-#define MMUSUFFIX _mmu
-#define URETSUFFIX USUFFIX
-#define SRETSUFFIX glue(s, SUFFIX)
+
+static inline RES_TYPE
+glue(glue(cpu_ld, USUFFIX), _code)(CPUArchState *env, target_ulong ptr)
+{
+    TCGMemOpIdx oi = make_memop_idx(MO_TE | SHIFT, CPU_MMU_INDEX);
+    return glue(glue(helper_ret_ld, USUFFIX), _cmmu)(env, ptr, oi, 0);
+}
+
+#if DATA_SIZE <= 2
+static inline int
+glue(glue(cpu_lds, SUFFIX), _code)(CPUArchState *env, target_ulong ptr)
+{
+    return (DATA_STYPE)glue(glue(cpu_ld, USUFFIX), _code)(env, ptr);
+}
 #endif
 
-/* generic load/store macros */
+#else
 
 static inline RES_TYPE
 glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
                                                   target_ulong ptr,
                                                   uintptr_t retaddr)
 {
-    CPUTLBEntry *entry;
-    RES_TYPE res;
-    target_ulong addr;
-    int mmu_idx = CPU_MMU_INDEX;
-    MemOp op = MO_TE | SHIFT;
-#if !defined(SOFTMMU_CODE_ACCESS)
-    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
-    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
-#endif
-
-    addr = ptr;
-    entry = tlb_entry(env, mmu_idx, addr);
-    if (unlikely(entry->ADDR_READ !=
-                 (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
-        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
-        res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr,
-                                                               oi, retaddr);
-    } else {
-        uintptr_t hostaddr = addr + entry->addend;
-        res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr);
-    }
-#ifndef SOFTMMU_CODE_ACCESS
-    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
-#endif
-    return res;
+    return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
+                                                   retaddr);
 }
 
 static inline RES_TYPE
 glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
 {
-    return glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(env, ptr, 0);
+    return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
 }
 
 #if DATA_SIZE <= 2
@@ -121,42 +98,17 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
                                                   target_ulong ptr,
                                                   uintptr_t retaddr)
 {
-    CPUTLBEntry *entry;
-    int res;
-    target_ulong addr;
-    int mmu_idx = CPU_MMU_INDEX;
-    MemOp op = MO_TE | MO_SIGN | SHIFT;
-#ifndef SOFTMMU_CODE_ACCESS
-    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
-    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
-#endif
-
-    addr = ptr;
-    entry = tlb_entry(env, mmu_idx, addr);
-    if (unlikely(entry->ADDR_READ !=
-                 (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
-        TCGMemOpIdx oi = make_memop_idx(op & ~MO_SIGN, mmu_idx);
-        res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX),
-                               MMUSUFFIX)(env, addr, oi, retaddr);
-    } else {
-        uintptr_t hostaddr = addr + entry->addend;
-        res = glue(glue(lds, SUFFIX), _p)((uint8_t *)hostaddr);
-    }
-#ifndef SOFTMMU_CODE_ACCESS
-    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
-#endif
-    return res;
+    return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
+                                                   retaddr);
 }
 
 static inline int
 glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
 {
-    return glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(env, ptr, 0);
+    return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
 }
 #endif
 
-#ifndef SOFTMMU_CODE_ACCESS
-
 /* generic store macro */
 
 static inline void
@@ -164,36 +116,15 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
                                                  target_ulong ptr,
                                                  RES_TYPE v, uintptr_t retaddr)
 {
-    CPUTLBEntry *entry;
-    target_ulong addr;
-    int mmu_idx = CPU_MMU_INDEX;
-    MemOp op = MO_TE | SHIFT;
-#if !defined(SOFTMMU_CODE_ACCESS)
-    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, true);
-    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
-#endif
-
-    addr = ptr;
-    entry = tlb_entry(env, mmu_idx, addr);
-    if (unlikely(tlb_addr_write(entry) !=
-                 (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
-        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
-        glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi,
-                                                     retaddr);
-    } else {
-        uintptr_t hostaddr = addr + entry->addend;
-        glue(glue(st, SUFFIX), _p)((uint8_t *)hostaddr, v);
-    }
-#ifndef SOFTMMU_CODE_ACCESS
-    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
-#endif
+    glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX,
+                                           retaddr);
 }
 
 static inline void
 glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
                                       RES_TYPE v)
 {
-    glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(env, ptr, v, 0);
+    glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
 }
 
 #endif /* !SOFTMMU_CODE_ACCESS */
@@ -204,8 +135,4 @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
 #undef SUFFIX
 #undef USUFFIX
 #undef DATA_SIZE
-#undef MMUSUFFIX
-#undef ADDR_READ
-#undef URETSUFFIX
-#undef SRETSUFFIX
 #undef SHIFT
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 98221948d6..ddd19718bf 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -34,6 +34,9 @@
 #include "qemu/atomic.h"
 #include "qemu/atomic128.h"
 #include "translate-all.h"
+#include "trace-root.h"
+#include "qemu/plugin.h"
+#include "trace/mem.h"
 #ifdef CONFIG_PLUGIN
 #include "qemu/plugin-memory.h"
 #endif
@@ -1625,6 +1628,75 @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env, target_ulong addr,
     return (int32_t)helper_be_ldul_mmu(env, addr, oi, retaddr);
 }
 
+/*
+ * Load helpers for cpu_ldst.h.
+ */
+
+static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr,
+                                       int mmu_idx, uintptr_t retaddr,
+                                       MemOp op, FullLoadHelper *full_load)
+{
+    uint16_t meminfo;
+    TCGMemOpIdx oi;
+    uint64_t ret;
+
+    meminfo = trace_mem_get_info(op, mmu_idx, false);
+    trace_guest_mem_before_exec(env_cpu(env), addr, meminfo);
+
+    op &= ~MO_SIGN;
+    oi = make_memop_idx(op, mmu_idx);
+    ret = full_load(env, addr, oi, retaddr);
+
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, meminfo);
+
+    return ret;
+}
+
+uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                            int mmu_idx, uintptr_t ra)
+{
+    return cpu_load_helper(env, addr, mmu_idx, ra, MO_UB, full_ldub_mmu);
+}
+
+int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                       int mmu_idx, uintptr_t ra)
+{
+    return (int8_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_SB,
+                                   full_ldub_mmu);
+}
+
+uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                            int mmu_idx, uintptr_t ra)
+{
+    return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUW,
+                           MO_TE == MO_LE
+                           ? full_le_lduw_mmu : full_be_lduw_mmu);
+}
+
+int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                       int mmu_idx, uintptr_t ra)
+{
+    return (int16_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_TESW,
+                                    MO_TE == MO_LE
+                                    ? full_le_lduw_mmu : full_be_lduw_mmu);
+}
+
+uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                           int mmu_idx, uintptr_t ra)
+{
+    return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUL,
+                           MO_TE == MO_LE
+                           ? full_le_ldul_mmu : full_be_ldul_mmu);
+}
+
+uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                           int mmu_idx, uintptr_t ra)
+{
+    return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEQ,
+                           MO_TE == MO_LE
+                           ? helper_le_ldq_mmu : helper_be_ldq_mmu);
+}
+
 /*
  * Store Helpers
  */
@@ -1854,6 +1926,50 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,
     store_helper(env, addr, val, oi, retaddr, MO_BEQ);
 }
 
+/*
+ * Store Helpers for cpu_ldst.h
+ */
+
+static inline void QEMU_ALWAYS_INLINE
+cpu_store_helper(CPUArchState *env, target_ulong addr, uint64_t val,
+                 int mmu_idx, uintptr_t retaddr, MemOp op)
+{
+    TCGMemOpIdx oi;
+    uint16_t meminfo;
+
+    meminfo = trace_mem_get_info(op, mmu_idx, true);
+    trace_guest_mem_before_exec(env_cpu(env), addr, meminfo);
+
+    oi = make_memop_idx(op, mmu_idx);
+    store_helper(env, addr, val, oi, retaddr, op);
+
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, meminfo);
+}
+
+void cpu_stb_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
+                       int mmu_idx, uintptr_t retaddr)
+{
+    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_UB);
+}
+
+void cpu_stw_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
+                       int mmu_idx, uintptr_t retaddr)
+{
+    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUW);
+}
+
+void cpu_stl_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
+                       int mmu_idx, uintptr_t retaddr)
+{
+    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUL);
+}
+
+void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
+                       int mmu_idx, uintptr_t retaddr)
+{
+    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEQ);
+}
+
 /* First set of helpers allows passing in of OI and RETADDR.  This makes
    them callable from other helpers.  */
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 05/28] translator: Use cpu_ld*_code instead of open-coding
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (3 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 04/28] cputlb: Move body of cpu_ldst_template.h out of line Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 17:12   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 06/28] cputlb: Rename helper_ret_ld*_cmmu to cpu_ld*_code Richard Henderson
                   ` (22 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel

The DO_LOAD macros replicate the distinction already performed
by the cpu_ldst.h functions.  Use them.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu_ldst.h   | 11 ---------
 include/exec/translator.h | 48 +++++++++++----------------------------
 2 files changed, 13 insertions(+), 46 deletions(-)

diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index cf8af36dbc..399ff6c3da 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -129,11 +129,6 @@ static inline void clear_helper_retaddr(void)
 #include "exec/cpu_ldst_useronly_template.h"
 #undef MEMSUFFIX
 
-/*
- * Code access is deprecated in favour of translator_ld* functions
- * (see translator.h). However there are still users that need to
- * converted so for now these stay.
- */
 #define MEMSUFFIX _code
 #define CODE_ACCESS
 #define DATA_SIZE 1
@@ -455,12 +450,6 @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
 #undef CPU_MMU_INDEX
 #undef MEMSUFFIX
 
-/*
- * Code access is deprecated in favour of translator_ld* functions
- * (see translator.h). However there are still users that need to
- * converted so for now these stay.
- */
-
 #define CPU_MMU_INDEX (cpu_mmu_index(env, true))
 #define MEMSUFFIX _code
 #define SOFTMMU_CODE_ACCESS
diff --git a/include/exec/translator.h b/include/exec/translator.h
index 459dd72aab..638e1529c5 100644
--- a/include/exec/translator.h
+++ b/include/exec/translator.h
@@ -148,41 +148,19 @@ void translator_loop_temp_check(DisasContextBase *db);
 /*
  * Translator Load Functions
  *
- * These are intended to replace the old cpu_ld*_code functions and
- * are mandatory for front-ends that have been migrated to the common
- * translator_loop. These functions are only intended to be called
- * from the translation stage and should not be called from helper
- * functions. Those functions should be converted to encode the
- * relevant information at translation time.
+ * These are intended to replace the direct usage of the cpu_ld*_code
+ * functions and are mandatory for front-ends that have been migrated
+ * to the common translator_loop. These functions are only intended
+ * to be called from the translation stage and should not be called
+ * from helper functions. Those functions should be converted to encode
+ * the relevant information at translation time.
  */
 
-#ifdef CONFIG_USER_ONLY
-
-#define DO_LOAD(type, name, shift)               \
-    do {                                         \
-        set_helper_retaddr(1);                   \
-        ret = name ## _p(g2h(pc));               \
-        clear_helper_retaddr();                  \
-    } while (0)
-
-#else
-
-#define DO_LOAD(type, name, shift)                          \
-    do {                                                    \
-        int mmu_idx = cpu_mmu_index(env, true);             \
-        TCGMemOpIdx oi = make_memop_idx(shift, mmu_idx);    \
-        ret = helper_ret_ ## name ## _cmmu(env, pc, oi, 0); \
-    } while (0)
-
-#endif
-
-#define GEN_TRANSLATOR_LD(fullname, name, type, shift, swap_fn)         \
+#define GEN_TRANSLATOR_LD(fullname, type, load_fn, swap_fn)             \
     static inline type                                                  \
     fullname ## _swap(CPUArchState *env, abi_ptr pc, bool do_swap)      \
     {                                                                   \
-        type ret;                                                       \
-        DO_LOAD(type, name, shift);                                     \
-                                                                        \
+        type ret = load_fn(env, pc);                                    \
         if (do_swap) {                                                  \
             ret = swap_fn(ret);                                         \
         }                                                               \
@@ -195,11 +173,11 @@ void translator_loop_temp_check(DisasContextBase *db);
         return fullname ## _swap(env, pc, false);                       \
     }
 
-GEN_TRANSLATOR_LD(translator_ldub, ldub, uint8_t, 0, /* no swap */ )
-GEN_TRANSLATOR_LD(translator_ldsw, ldsw, int16_t, 1, bswap16)
-GEN_TRANSLATOR_LD(translator_lduw, lduw, uint16_t, 1, bswap16)
-GEN_TRANSLATOR_LD(translator_ldl, ldl, uint32_t, 2, bswap32)
-GEN_TRANSLATOR_LD(translator_ldq, ldq, uint64_t, 3, bswap64)
+GEN_TRANSLATOR_LD(translator_ldub, uint8_t, cpu_ldub_code, /* no swap */)
+GEN_TRANSLATOR_LD(translator_ldsw, int16_t, cpu_ldsw_code, bswap16)
+GEN_TRANSLATOR_LD(translator_lduw, uint16_t, cpu_lduw_code, bswap16)
+GEN_TRANSLATOR_LD(translator_ldl, uint32_t, cpu_ldl_code, bswap32)
+GEN_TRANSLATOR_LD(translator_ldq, uint64_t, cpu_ldq_code, bswap64)
 #undef GEN_TRANSLATOR_LD
 
 #endif  /* EXEC__TRANSLATOR_H */
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 06/28] cputlb: Rename helper_ret_ld*_cmmu to cpu_ld*_code
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (4 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 05/28] translator: Use cpu_ld*_code instead of open-coding Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 17:25   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 07/28] cputlb: Provide cpu_(ld, st}*_mmuidx_ra for user-only Richard Henderson
                   ` (21 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aleksandar Markovic

There are no uses of the *_cmmu names other than the bare wrapping
within the *_code inlines.  Therefore rename the functions so we
can drop the inlines.

Use abi_ptr instead of target_ulong in preparation for user-only;
the two types are identical for softmmu.

Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu_ldst.h          | 29 ++++------
 include/exec/cpu_ldst_template.h | 21 -------
 tcg/tcg.h                        | 29 ----------
 accel/tcg/cputlb.c               | 94 ++++++++------------------------
 docs/devel/loads-stores.rst      |  4 +-
 5 files changed, 36 insertions(+), 141 deletions(-)

diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index 399ff6c3da..ef59ed61e4 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -450,25 +450,20 @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
 #undef CPU_MMU_INDEX
 #undef MEMSUFFIX
 
-#define CPU_MMU_INDEX (cpu_mmu_index(env, true))
-#define MEMSUFFIX _code
-#define SOFTMMU_CODE_ACCESS
+uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
+uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr);
+uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr);
+uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr);
 
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
+static inline int cpu_ldsb_code(CPUArchState *env, abi_ptr addr)
+{
+    return (int8_t)cpu_ldub_code(env, addr);
+}
 
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#undef SOFTMMU_CODE_ACCESS
+static inline int cpu_ldsw_code(CPUArchState *env, abi_ptr addr)
+{
+    return (int16_t)cpu_lduw_code(env, addr);
+}
 
 #endif /* defined(CONFIG_USER_ONLY) */
 
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
index ea39e29c19..e400979f23 100644
--- a/include/exec/cpu_ldst_template.h
+++ b/include/exec/cpu_ldst_template.h
@@ -58,25 +58,6 @@
 
 /* generic load/store macros */
 
-#ifdef SOFTMMU_CODE_ACCESS
-
-static inline RES_TYPE
-glue(glue(cpu_ld, USUFFIX), _code)(CPUArchState *env, target_ulong ptr)
-{
-    TCGMemOpIdx oi = make_memop_idx(MO_TE | SHIFT, CPU_MMU_INDEX);
-    return glue(glue(helper_ret_ld, USUFFIX), _cmmu)(env, ptr, oi, 0);
-}
-
-#if DATA_SIZE <= 2
-static inline int
-glue(glue(cpu_lds, SUFFIX), _code)(CPUArchState *env, target_ulong ptr)
-{
-    return (DATA_STYPE)glue(glue(cpu_ld, USUFFIX), _code)(env, ptr);
-}
-#endif
-
-#else
-
 static inline RES_TYPE
 glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
                                                   target_ulong ptr,
@@ -127,8 +108,6 @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
     glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
 }
 
-#endif /* !SOFTMMU_CODE_ACCESS */
-
 #undef RES_TYPE
 #undef DATA_TYPE
 #undef DATA_STYPE
diff --git a/tcg/tcg.h b/tcg/tcg.h
index 92ca10dffc..3b4f79301c 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -1290,27 +1290,6 @@ void helper_be_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val,
 void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,
                        TCGMemOpIdx oi, uintptr_t retaddr);
 
-uint8_t helper_ret_ldub_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr);
-int8_t helper_ret_ldsb_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr);
-uint16_t helper_le_lduw_cmmu(CPUArchState *env, target_ulong addr,
-                             TCGMemOpIdx oi, uintptr_t retaddr);
-int16_t helper_le_ldsw_cmmu(CPUArchState *env, target_ulong addr,
-                             TCGMemOpIdx oi, uintptr_t retaddr);
-uint32_t helper_le_ldl_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr);
-uint64_t helper_le_ldq_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr);
-uint16_t helper_be_lduw_cmmu(CPUArchState *env, target_ulong addr,
-                             TCGMemOpIdx oi, uintptr_t retaddr);
-int16_t helper_be_ldsw_cmmu(CPUArchState *env, target_ulong addr,
-                             TCGMemOpIdx oi, uintptr_t retaddr);
-uint32_t helper_be_ldl_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr);
-uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr);
-
 /* Temporary aliases until backends are converted.  */
 #ifdef TARGET_WORDS_BIGENDIAN
 # define helper_ret_ldsw_mmu  helper_be_ldsw_mmu
@@ -1322,10 +1301,6 @@ uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
 # define helper_ret_stw_mmu   helper_be_stw_mmu
 # define helper_ret_stl_mmu   helper_be_stl_mmu
 # define helper_ret_stq_mmu   helper_be_stq_mmu
-# define helper_ret_lduw_cmmu  helper_be_lduw_cmmu
-# define helper_ret_ldsw_cmmu  helper_be_ldsw_cmmu
-# define helper_ret_ldl_cmmu  helper_be_ldl_cmmu
-# define helper_ret_ldq_cmmu  helper_be_ldq_cmmu
 #else
 # define helper_ret_ldsw_mmu  helper_le_ldsw_mmu
 # define helper_ret_lduw_mmu  helper_le_lduw_mmu
@@ -1336,10 +1311,6 @@ uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
 # define helper_ret_stw_mmu   helper_le_stw_mmu
 # define helper_ret_stl_mmu   helper_le_stl_mmu
 # define helper_ret_stq_mmu   helper_le_stq_mmu
-# define helper_ret_lduw_cmmu  helper_le_lduw_cmmu
-# define helper_ret_ldsw_cmmu  helper_le_ldsw_cmmu
-# define helper_ret_ldl_cmmu  helper_le_ldl_cmmu
-# define helper_ret_ldq_cmmu  helper_le_ldq_cmmu
 #endif
 
 uint32_t helper_atomic_cmpxchgb_mmu(CPUArchState *env, target_ulong addr,
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index ddd19718bf..f0e4b0aee4 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -2028,98 +2028,50 @@ void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
 
 /* Code access functions.  */
 
-static uint64_t full_ldub_cmmu(CPUArchState *env, target_ulong addr,
+static uint64_t full_ldub_code(CPUArchState *env, target_ulong addr,
                                TCGMemOpIdx oi, uintptr_t retaddr)
 {
-    return load_helper(env, addr, oi, retaddr, MO_8, true, full_ldub_cmmu);
+    return load_helper(env, addr, oi, retaddr, MO_8, true, full_ldub_code);
 }
 
-uint8_t helper_ret_ldub_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr)
+uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr)
 {
-    return full_ldub_cmmu(env, addr, oi, retaddr);
+    TCGMemOpIdx oi = make_memop_idx(MO_UB, cpu_mmu_index(env, true));
+    return full_ldub_code(env, addr, oi, 0);
 }
 
-int8_t helper_ret_ldsb_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr)
+static uint64_t full_lduw_code(CPUArchState *env, target_ulong addr,
+                               TCGMemOpIdx oi, uintptr_t retaddr)
 {
-    return (int8_t) full_ldub_cmmu(env, addr, oi, retaddr);
+    return load_helper(env, addr, oi, retaddr, MO_TEUW, true, full_lduw_code);
 }
 
-static uint64_t full_le_lduw_cmmu(CPUArchState *env, target_ulong addr,
-                                  TCGMemOpIdx oi, uintptr_t retaddr)
+uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr)
 {
-    return load_helper(env, addr, oi, retaddr, MO_LEUW, true,
-                       full_le_lduw_cmmu);
+    TCGMemOpIdx oi = make_memop_idx(MO_TEUW, cpu_mmu_index(env, true));
+    return full_lduw_code(env, addr, oi, 0);
 }
 
-uint16_t helper_le_lduw_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr)
+static uint64_t full_ldl_code(CPUArchState *env, target_ulong addr,
+                              TCGMemOpIdx oi, uintptr_t retaddr)
 {
-    return full_le_lduw_cmmu(env, addr, oi, retaddr);
+    return load_helper(env, addr, oi, retaddr, MO_TEUL, true, full_ldl_code);
 }
 
-int16_t helper_le_ldsw_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr)
+uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr)
 {
-    return (int16_t) full_le_lduw_cmmu(env, addr, oi, retaddr);
+    TCGMemOpIdx oi = make_memop_idx(MO_TEUL, cpu_mmu_index(env, true));
+    return full_ldl_code(env, addr, oi, 0);
 }
 
-static uint64_t full_be_lduw_cmmu(CPUArchState *env, target_ulong addr,
-                                  TCGMemOpIdx oi, uintptr_t retaddr)
+static uint64_t full_ldq_code(CPUArchState *env, target_ulong addr,
+                              TCGMemOpIdx oi, uintptr_t retaddr)
 {
-    return load_helper(env, addr, oi, retaddr, MO_BEUW, true,
-                       full_be_lduw_cmmu);
+    return load_helper(env, addr, oi, retaddr, MO_TEQ, true, full_ldq_code);
 }
 
-uint16_t helper_be_lduw_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr)
+uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr)
 {
-    return full_be_lduw_cmmu(env, addr, oi, retaddr);
-}
-
-int16_t helper_be_ldsw_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr)
-{
-    return (int16_t) full_be_lduw_cmmu(env, addr, oi, retaddr);
-}
-
-static uint64_t full_le_ldul_cmmu(CPUArchState *env, target_ulong addr,
-                                  TCGMemOpIdx oi, uintptr_t retaddr)
-{
-    return load_helper(env, addr, oi, retaddr, MO_LEUL, true,
-                       full_le_ldul_cmmu);
-}
-
-uint32_t helper_le_ldl_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr)
-{
-    return full_le_ldul_cmmu(env, addr, oi, retaddr);
-}
-
-static uint64_t full_be_ldul_cmmu(CPUArchState *env, target_ulong addr,
-                                  TCGMemOpIdx oi, uintptr_t retaddr)
-{
-    return load_helper(env, addr, oi, retaddr, MO_BEUL, true,
-                       full_be_ldul_cmmu);
-}
-
-uint32_t helper_be_ldl_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr)
-{
-    return full_be_ldul_cmmu(env, addr, oi, retaddr);
-}
-
-uint64_t helper_le_ldq_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr)
-{
-    return load_helper(env, addr, oi, retaddr, MO_LEQ, true,
-                       helper_le_ldq_cmmu);
-}
-
-uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
-                            TCGMemOpIdx oi, uintptr_t retaddr)
-{
-    return load_helper(env, addr, oi, retaddr, MO_BEQ, true,
-                       helper_be_ldq_cmmu);
+    TCGMemOpIdx oi = make_memop_idx(MO_TEQ, cpu_mmu_index(env, true));
+    return full_ldq_code(env, addr, oi, 0);
 }
diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst
index c74cd090e6..8a5bc912a5 100644
--- a/docs/devel/loads-stores.rst
+++ b/docs/devel/loads-stores.rst
@@ -171,8 +171,6 @@ more in line with the other memory access functions.
 
 load: ``helper_{endian}_ld{sign}{size}_mmu(env, addr, opindex, retaddr)``
 
-load (code): ``helper_{endian}_ld{sign}{size}_cmmu(env, addr, opindex, retaddr)``
-
 store: ``helper_{endian}_st{size}_mmu(env, addr, val, opindex, retaddr)``
 
 ``sign``
@@ -192,7 +190,7 @@ store: ``helper_{endian}_st{size}_mmu(env, addr, val, opindex, retaddr)``
  - ``ret`` : target endianness
 
 Regexes for git grep
- - ``\<helper_\(le\|be\|ret\)_ld[us]\?[bwlq]_c\?mmu\>``
+ - ``\<helper_\(le\|be\|ret\)_ld[us]\?[bwlq]_mmu\>``
  - ``\<helper_\(le\|be\|ret\)_st[bwlq]_mmu\>``
 
 ``address_space_*``
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 07/28] cputlb: Provide cpu_(ld, st}*_mmuidx_ra for user-only
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (5 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 06/28] cputlb: Rename helper_ret_ld*_cmmu to cpu_ld*_code Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 17:36   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 08/28] target/i386: Use cpu_*_mmuidx_ra instead of templates Richard Henderson
                   ` (20 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel

This finishes the new interface began with the previous patch.
Document the interface and deprecate MMU_MODE<N>_SUFFIX.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu_ldst.h     |  80 +++++++++++++-
 docs/devel/loads-stores.rst | 211 ++++++++++++++++++++++++++----------
 2 files changed, 230 insertions(+), 61 deletions(-)

diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index ef59ed61e4..41b98ba801 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -25,9 +25,13 @@
  *
  * The syntax for the accessors is:
  *
- * load: cpu_ld{sign}{size}_{mmusuffix}(env, ptr)
+ * load:  cpu_ld{sign}{size}_{mmusuffix}(env, ptr)
+ *        cpu_ld{sign}{size}_{mmusuffix}_ra(env, ptr, retaddr)
+ *        cpu_ld{sign}{size}_mmuidx_ra(env, ptr, mmu_idx, retaddr)
  *
- * store: cpu_st{sign}{size}_{mmusuffix}(env, ptr, val)
+ * store: cpu_st{size}_{mmusuffix}(env, ptr, val)
+ *        cpu_st{size}_{mmusuffix}_ra(env, ptr, val, retaddr)
+ *        cpu_st{size}_mmuidx_ra(env, ptr, val, mmu_idx, retaddr)
  *
  * sign is:
  * (empty): for 32 and 64 bit sizes
@@ -40,9 +44,10 @@
  *   l: 32 bits
  *   q: 64 bits
  *
- * mmusuffix is one of the generic suffixes "data" or "code", or
- * (for softmmu configs)  a target-specific MMU mode suffix as defined
- * in target cpu.h.
+ * mmusuffix is one of the generic suffixes "data" or "code", or "mmuidx".
+ * The "mmuidx" suffix carries an extra mmu_idx argument that specifies
+ * the index to use; the "data" and "code" suffixes take the index from
+ * cpu_mmu_index().
  */
 #ifndef CPU_LDST_H
 #define CPU_LDST_H
@@ -145,6 +150,71 @@ static inline void clear_helper_retaddr(void)
 #undef MEMSUFFIX
 #undef CODE_ACCESS
 
+/*
+ * Provide the same *_mmuidx_ra interface as for softmmu.
+ * The mmu_idx argument is ignored.
+ */
+
+static inline uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                                          int mmu_idx, uintptr_t ra)
+{
+    return cpu_ldub_data_ra(env, addr, ra);
+}
+
+static inline uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                                          int mmu_idx, uintptr_t ra)
+{
+    return cpu_lduw_data_ra(env, addr, ra);
+}
+
+static inline uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                                         int mmu_idx, uintptr_t ra)
+{
+    return cpu_ldl_data_ra(env, addr, ra);
+}
+
+static inline uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                                         int mmu_idx, uintptr_t ra)
+{
+    return cpu_ldq_data_ra(env, addr, ra);
+}
+
+static inline int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                                     int mmu_idx, uintptr_t ra)
+{
+    return cpu_ldsb_data_ra(env, addr, ra);
+}
+
+static inline int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                                     int mmu_idx, uintptr_t ra)
+{
+    return cpu_ldsw_data_ra(env, addr, ra);
+}
+
+static inline void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                                     uint32_t val, int mmu_idx, uintptr_t ra)
+{
+    cpu_stb_data_ra(env, addr, val, ra);
+}
+
+static inline void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                                     uint32_t val, int mmu_idx, uintptr_t ra)
+{
+    cpu_stw_data_ra(env, addr, val, ra);
+}
+
+static inline void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                                     uint32_t val, int mmu_idx, uintptr_t ra)
+{
+    cpu_stl_data_ra(env, addr, val, ra);
+}
+
+static inline void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
+                                     uint64_t val, int mmu_idx, uintptr_t ra)
+{
+    cpu_stq_data_ra(env, addr, val, ra);
+}
+
 #else
 
 /* Needed for TCG_OVERSIZED_GUEST */
diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst
index 8a5bc912a5..03aa9e7ff8 100644
--- a/docs/devel/loads-stores.rst
+++ b/docs/devel/loads-stores.rst
@@ -72,31 +72,34 @@ Regexes for git grep
  - ``\<ldn_\([hbl]e\)?_p\>``
  - ``\<stn_\([hbl]e\)?_p\>``
 
-``cpu_{ld,st}_*``
-~~~~~~~~~~~~~~~~~
+``cpu_{ld,st}*_mmuidx_ra``
+~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-These functions operate on a guest virtual address. Be aware
-that these functions may cause a guest CPU exception to be
-taken (e.g. for an alignment fault or MMU fault) which will
-result in guest CPU state being updated and control longjumping
-out of the function call. They should therefore only be used
-in code that is implementing emulation of the target CPU.
+These functions operate on a guest virtual address plus a context,
+known as a "mmu index" or ``mmuidx``, which controls how that virtual
+address is translated.  The meaning of the indexes are target specific,
+but specifying a particular index might be necessary if, for instance,
+the helper requires an "always as non-privileged" access rather that
+the default access for the current state of the guest CPU.
 
-These functions may throw an exception (longjmp() back out
-to the top level TCG loop). This means they must only be used
-from helper functions where the translator has saved all
-necessary CPU state before generating the helper function call.
-It's usually better to use the ``_ra`` variants described below
-from helper functions, but these functions are the right choice
-for calls made from hooks like the CPU do_interrupt hook or
-when you know for certain that the translator had to save all
-the CPU state that ``cpu_restore_state()`` would restore anyway.
+These functions may cause a guest CPU exception to be taken
+(e.g. for an alignment fault or MMU fault) which will result in
+guest CPU state being updated and control longjmp'ing out of the
+function call.  They should therefore only be used in code that is
+implementing emulation of the guest CPU.
+
+The ``retaddr`` parameter is used to control unwinding of the
+guest CPU state in case of a guest CPU exception.  This is passed
+to ``cpu_restore_state()``.  Therefore the value should either be 0,
+to indicate that the guest CPU state is already synchronized, or
+the result of ``GETPC()`` from the top level ``HELPER(foo)``
+function, which is a return address into the generated code.
 
 Function names follow the pattern:
 
-load: ``cpu_ld{sign}{size}_{mmusuffix}(env, ptr)``
+load: ``cpu_ld{sign}{size}_mmuidx_ra(env, ptr, mmuidx, retaddr)``
 
-store: ``cpu_st{size}_{mmusuffix}(env, ptr, val)``
+store: ``cpu_st{size}_mmuidx_ra(env, ptr, val, mmuidx, retaddr)``
 
 ``sign``
  - (empty) : for 32 or 64 bit sizes
@@ -109,56 +112,151 @@ store: ``cpu_st{size}_{mmusuffix}(env, ptr, val)``
  - ``l`` : 32 bits
  - ``q`` : 64 bits
 
-``mmusuffix`` is one of the generic suffixes ``data`` or ``code``, or
-(for softmmu configs) a target-specific MMU mode suffix as defined
-in the target's ``cpu.h``.
+Regexes for git grep:
+ - ``\<cpu_ld[us]\?[bwlq]_mmuidx_ra\>``
+ - ``\<cpu_st[bwlq]_mmuidx_ra\>``
 
-Regexes for git grep
- - ``\<cpu_ld[us]\?[bwlq]_[a-zA-Z0-9]\+\>``
- - ``\<cpu_st[bwlq]_[a-zA-Z0-9]\+\>``
+``cpu_{ld,st}*_data_ra``
+~~~~~~~~~~~~~~~~~~~~~~~~
 
-``cpu_{ld,st}_*_ra``
-~~~~~~~~~~~~~~~~~~~~
-
-These functions work like the ``cpu_{ld,st}_*`` functions except
-that they also take a ``retaddr`` argument. This extra argument
-allows for correct unwinding of any exception that is taken,
-and should generally be the result of GETPC() called directly
-from the top level HELPER(foo) function (i.e. the return address
-in the generated code).
+These functions work like the ``cpu_{ld,st}_mmuidx_ra`` functions
+except that the ``mmuidx`` parameter is taken from the current mode
+of the guest CPU, as determined by ``cpu_mmu_index(env, false)``.
 
 These are generally the preferred way to do accesses by guest
-virtual address from helper functions; see the documentation
-of the non-``_ra`` variants for when those would be better.
-
-Calling these functions with a ``retaddr`` argument of 0 is
-equivalent to calling the non-``_ra`` version of the function.
+virtual address from helper functions, unless the access should
+be performed with a context other than the default.
 
 Function names follow the pattern:
 
-load: ``cpu_ld{sign}{size}_{mmusuffix}_ra(env, ptr, retaddr)``
+load: ``cpu_ld{sign}{size}_data_ra(env, ptr, ra)``
 
-store: ``cpu_st{sign}{size}_{mmusuffix}_ra(env, ptr, val, retaddr)``
+store: ``cpu_st{size}_data_ra(env, ptr, val, ra)``
+
+``sign``
+ - (empty) : for 32 or 64 bit sizes
+ - ``u`` : unsigned
+ - ``s`` : signed
+
+``size``
+ - ``b`` : 8 bits
+ - ``w`` : 16 bits
+ - ``l`` : 32 bits
+ - ``q`` : 64 bits
+
+Regexes for git grep:
+ - ``\<cpu_ld[us]\?[bwlq]_data_ra\>``
+ - ``\<cpu_st[bwlq]_data_ra\>``
+
+``cpu_{ld,st}*_data``
+~~~~~~~~~~~~~~~~~~~~~
+
+These functions work like the ``cpu_{ld,st}_data_ra`` functions
+except that the ``retaddr`` parameter is 0, and thus does not
+unwind guest CPU state.
+
+This means they must only be used from helper functions where the
+translator has saved all necessary CPU state.  These functions are
+the right choice for calls made from hooks like the CPU ``do_interrupt``
+hook or when you know for certain that the translator had to save all
+the CPU state anyway.
+
+Function names follow the pattern:
+
+load: ``cpu_ld{sign}{size}_data(env, ptr)``
+
+store: ``cpu_st{size}_data(env, ptr, val)``
+
+``sign``
+ - (empty) : for 32 or 64 bit sizes
+ - ``u`` : unsigned
+ - ``s`` : signed
+
+``size``
+ - ``b`` : 8 bits
+ - ``w`` : 16 bits
+ - ``l`` : 32 bits
+ - ``q`` : 64 bits
 
 Regexes for git grep
- - ``\<cpu_ld[us]\?[bwlq]_[a-zA-Z0-9]\+_ra\>``
- - ``\<cpu_st[bwlq]_[a-zA-Z0-9]\+_ra\>``
+ - ``\<cpu_ld[us]\?[bwlq]_data\>``
+ - ``\<cpu_st[bwlq]_data\+\>``
 
-``helper_*_{ld,st}*mmu``
-~~~~~~~~~~~~~~~~~~~~~~~~
+``cpu_ld*_code``
+~~~~~~~~~~~~~~~~
+
+These functions perform a read for instruction execution.  The ``mmuidx``
+parameter is taken from the current mode of the guest CPU, as determined
+by ``cpu_mmu_index(env, true)``.  The ``retaddr`` parameter is 0, and
+thus does not unwind guest CPU state, because CPU state is always
+synchronized while translating instructions.  Any guest CPU exception
+that is raised will indicate an instruction execution fault rather than
+a data read fault.
+
+In general these functions should not be used directly during translation.
+There are wrapper functions that are to be used which also take care of
+plugins for tracing.
+
+Function names follow the pattern:
+
+load: ``cpu_ld{sign}{size}_code(env, ptr)``
+
+``sign``
+ - (empty) : for 32 or 64 bit sizes
+ - ``u`` : unsigned
+ - ``s`` : signed
+
+``size``
+ - ``b`` : 8 bits
+ - ``w`` : 16 bits
+ - ``l`` : 32 bits
+ - ``q`` : 64 bits
+
+Regexes for git grep:
+ - ``\<cpu_ld[us]\?[bwlq]_code\>``
+
+``translator_ld*``
+~~~~~~~~~~~~~~~~~~
+
+These functions are a wrapper for ``cpu_ld*_code`` which also perform
+any actions required by any tracing plugins.  They are only to be
+called during the translator callback ``translate_insn``.
+
+There is a set of functions ending in ``_swap`` which, if the parameter
+is true, returns the value in the endianness that is the reverse of
+the guest native endianness, as determined by ``TARGET_WORDS_BIGENDIAN``.
+
+Function names follow the pattern:
+
+load: ``translator_ld{sign}{size}(env, ptr)``
+
+swap: ``translator_ld{sign}{size}_swap(env, ptr, swap)``
+
+``sign``
+ - (empty) : for 32 or 64 bit sizes
+ - ``u`` : unsigned
+ - ``s`` : signed
+
+``size``
+ - ``b`` : 8 bits
+ - ``w`` : 16 bits
+ - ``l`` : 32 bits
+ - ``q`` : 64 bits
+
+Regexes for git grep
+ - ``\<translator_ld[us]\?[bwlq]\(_swap\)\?\>``
+
+``helper_*_{ld,st}*_mmu``
+~~~~~~~~~~~~~~~~~~~~~~~~~
 
 These functions are intended primarily to be called by the code
 generated by the TCG backend. They may also be called by target
-CPU helper function code. Like the ``cpu_{ld,st}_*_ra`` functions
-they perform accesses by guest virtual address; the difference is
-that these functions allow you to specify an ``opindex`` parameter
-which encodes (among other things) the mmu index to use for the
-access. This is necessary if your helper needs to make an access
-via a specific mmu index (for instance, an "always as non-privileged"
-access) rather than using the default mmu index for the current state
-of the guest CPU.
+CPU helper function code. Like the ``cpu_{ld,st}_mmuidx_ra`` functions
+they perform accesses by guest virtual address, with a given ``mmuidx``.
 
-The ``opindex`` parameter should be created by calling ``make_memop_idx()``.
+These functions specify an ``opindex`` parameter which encodes
+(among other things) the mmu index to use for the access.  This parameter
+should be created by calling ``make_memop_idx()``.
 
 The ``retaddr`` parameter should be the result of GETPC() called directly
 from the top level HELPER(foo) function (or 0 if no guest CPU state
@@ -166,8 +264,9 @@ unwinding is required).
 
 **TODO** The names of these functions are a bit odd for historical
 reasons because they were originally expected to be called only from
-within generated code. We should rename them to bring them
-more in line with the other memory access functions.
+within generated code. We should rename them to bring them more in
+line with the other memory access functions. The explicit endianness
+is the only feature they have beyond ``*_mmuidx_ra``.
 
 load: ``helper_{endian}_ld{sign}{size}_mmu(env, addr, opindex, retaddr)``
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 08/28] target/i386: Use cpu_*_mmuidx_ra instead of templates
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (6 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 07/28] cputlb: Provide cpu_(ld, st}*_mmuidx_ra for user-only Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 17:42   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 09/28] target/s390x: Include tcg.h in mem_helper.c Richard Henderson
                   ` (19 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Eduardo Habkost

Do not use exec/cpu_ldst_{,useronly_}template.h directly,
but instead use the functional interface.

Cc: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/i386/seg_helper.c | 56 ++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/target/i386/seg_helper.c b/target/i386/seg_helper.c
index 87a627f9dc..b96de068ca 100644
--- a/target/i386/seg_helper.c
+++ b/target/i386/seg_helper.c
@@ -37,37 +37,37 @@
 # define LOG_PCALL_STATE(cpu) do { } while (0)
 #endif
 
-#ifdef CONFIG_USER_ONLY
-#define MEMSUFFIX _kernel
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_useronly_template.h"
+/*
+ * TODO: Convert callers to compute cpu_mmu_index_kernel once
+ * and use *_mmuidx_ra directly.
+ */
+#define cpu_ldub_kernel_ra(e, p, r) \
+    cpu_ldub_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
+#define cpu_lduw_kernel_ra(e, p, r) \
+    cpu_lduw_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
+#define cpu_ldl_kernel_ra(e, p, r) \
+    cpu_ldl_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
+#define cpu_ldq_kernel_ra(e, p, r) \
+    cpu_ldq_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
 
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_useronly_template.h"
+#define cpu_stb_kernel_ra(e, p, v, r) \
+    cpu_stb_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
+#define cpu_stw_kernel_ra(e, p, v, r) \
+    cpu_stw_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
+#define cpu_stl_kernel_ra(e, p, v, r) \
+    cpu_stl_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
+#define cpu_stq_kernel_ra(e, p, v, r) \
+    cpu_stq_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
 
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_useronly_template.h"
+#define cpu_ldub_kernel(e, p)    cpu_ldub_kernel_ra(e, p, 0)
+#define cpu_lduw_kernel(e, p)    cpu_lduw_kernel_ra(e, p, 0)
+#define cpu_ldl_kernel(e, p)     cpu_ldl_kernel_ra(e, p, 0)
+#define cpu_ldq_kernel(e, p)     cpu_ldq_kernel_ra(e, p, 0)
 
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_useronly_template.h"
-#undef MEMSUFFIX
-#else
-#define CPU_MMU_INDEX (cpu_mmu_index_kernel(env))
-#define MEMSUFFIX _kernel
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif
+#define cpu_stb_kernel(e, p, v)  cpu_stb_kernel_ra(e, p, v, 0)
+#define cpu_stw_kernel(e, p, v)  cpu_stw_kernel_ra(e, p, v, 0)
+#define cpu_stl_kernel(e, p, v)  cpu_stl_kernel_ra(e, p, v, 0)
+#define cpu_stq_kernel(e, p, v)  cpu_stq_kernel_ra(e, p, v, 0)
 
 /* return non zero if error */
 static inline int load_segment_ra(CPUX86State *env, uint32_t *e1_ptr,
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 09/28] target/s390x: Include tcg.h in mem_helper.c
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (7 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 08/28] target/i386: Use cpu_*_mmuidx_ra instead of templates Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 17:43   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 10/28] target/arm: Include tcg.h in sve_helper.c Richard Henderson
                   ` (18 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Hildenbrand

Code movement in an upcoming patch will show that this file
was implicitly depending on tcg.h being included indirectly.

Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/s390x/mem_helper.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
index 2325767f17..57ce17c252 100644
--- a/target/s390x/mem_helper.c
+++ b/target/s390x/mem_helper.c
@@ -27,6 +27,7 @@
 #include "exec/cpu_ldst.h"
 #include "qemu/int128.h"
 #include "qemu/atomic128.h"
+#include "tcg.h"
 
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/s390x/storage-keys.h"
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 10/28] target/arm: Include tcg.h in sve_helper.c
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (8 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 09/28] target/s390x: Include tcg.h in mem_helper.c Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 17:43   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 11/28] accel/tcg: Include tcg.h in tcg-runtime.c Richard Henderson
                   ` (17 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

Code movement in an upcoming patch will show that this file
was implicitly depending on tcg.h being included indirectly.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/sve_helper.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
index fc0c1755d2..83cc7f5bb5 100644
--- a/target/arm/sve_helper.c
+++ b/target/arm/sve_helper.c
@@ -25,6 +25,7 @@
 #include "exec/helper-proto.h"
 #include "tcg/tcg-gvec-desc.h"
 #include "fpu/softfloat.h"
+#include "tcg.h"
 
 
 /* Note that vector data is stored in host-endian 64-bit chunks,
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 11/28] accel/tcg: Include tcg.h in tcg-runtime.c
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (9 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 10/28] target/arm: Include tcg.h in sve_helper.c Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-16 22:11 ` [PATCH v2 12/28] linux-user: Include tcg.h in syscall.c Richard Henderson
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée

Code movement in an upcoming patch will show that this file
was implicitly depending on tcg.h being included indirectly.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 accel/tcg/tcg-runtime.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c
index 8a1e408e31..4ab2cf7f75 100644
--- a/accel/tcg/tcg-runtime.c
+++ b/accel/tcg/tcg-runtime.c
@@ -30,6 +30,7 @@
 #include "exec/tb-lookup.h"
 #include "disas/disas.h"
 #include "exec/log.h"
+#include "tcg.h"
 
 /* 32-bit helpers */
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 12/28] linux-user: Include tcg.h in syscall.c
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (10 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 11/28] accel/tcg: Include tcg.h in tcg-runtime.c Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 17:43   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 13/28] linux-user: Include trace-root.h in syscall-trace.h Richard Henderson
                   ` (15 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel

Code movement in an upcoming patch will show that this file
was implicitly depending on tcg.h being included indirectly.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 171c0caef3..34825f15bf 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -115,6 +115,7 @@
 #include "user/syscall-trace.h"
 #include "qapi/error.h"
 #include "fd-trans.h"
+#include "tcg.h"
 
 #ifndef CLONE_IO
 #define CLONE_IO                0x80000000      /* Clone io context */
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 13/28] linux-user: Include trace-root.h in syscall-trace.h
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (11 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 12/28] linux-user: Include tcg.h in syscall.c Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 17:49   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 14/28] cputlb: Expand cpu_ldst_useronly_template.h in user-exec.c Richard Henderson
                   ` (14 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel

Code movement in an upcoming patch will show that this file
was implicitly depending on trace-root.h being included beforehand.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/user/syscall-trace.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/user/syscall-trace.h b/include/user/syscall-trace.h
index 9e60473643..79fd3e5aa9 100644
--- a/include/user/syscall-trace.h
+++ b/include/user/syscall-trace.h
@@ -10,6 +10,8 @@
 #ifndef _SYSCALL_TRACE_H_
 #define _SYSCALL_TRACE_H_
 
+#include "trace-root.h"
+
 /*
  * These helpers just provide a common place for the various
  * subsystems that want to track syscalls to put their hooks in. We
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 14/28] cputlb: Expand cpu_ldst_useronly_template.h in user-exec.c
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (12 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 13/28] linux-user: Include trace-root.h in syscall-trace.h Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 17:59   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 15/28] target/nios2: Remove MMU_MODE{0,1}_SUFFIX Richard Henderson
                   ` (13 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel

With the tracing hooks, the inline functions are no longer
so simple.  Reduce the amount of preprocessor obfuscation
by expanding the text of each of the functions generated.
The result is only slightly larger than the original.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu_ldst.h                   |  54 +++--
 include/exec/cpu_ldst_useronly_template.h | 159 ---------------
 accel/tcg/user-exec.c                     | 236 ++++++++++++++++++++++
 3 files changed, 262 insertions(+), 187 deletions(-)
 delete mode 100644 include/exec/cpu_ldst_useronly_template.h

diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index 41b98ba801..0f3c49a005 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -120,35 +120,33 @@ static inline void clear_helper_retaddr(void)
 
 /* In user-only mode we provide only the _code and _data accessors. */
 
-#define MEMSUFFIX _data
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_useronly_template.h"
+uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr);
+uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr);
+uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr);
+uint64_t cpu_ldq_data(CPUArchState *env, abi_ptr ptr);
+int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr);
+int cpu_ldsw_data(CPUArchState *env, abi_ptr ptr);
 
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_useronly_template.h"
+uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
+uint32_t cpu_lduw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
+uint32_t cpu_ldl_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
+uint64_t cpu_ldq_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
+int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
+int cpu_ldsw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
 
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_useronly_template.h"
+void cpu_stb_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
+void cpu_stw_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
+void cpu_stl_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
+void cpu_stq_data(CPUArchState *env, abi_ptr ptr, uint64_t val);
 
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_useronly_template.h"
-#undef MEMSUFFIX
-
-#define MEMSUFFIX _code
-#define CODE_ACCESS
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_useronly_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_useronly_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_useronly_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_useronly_template.h"
-#undef MEMSUFFIX
-#undef CODE_ACCESS
+void cpu_stb_data_ra(CPUArchState *env, abi_ptr ptr,
+                     uint32_t val, uintptr_t retaddr);
+void cpu_stw_data_ra(CPUArchState *env, abi_ptr ptr,
+                     uint32_t val, uintptr_t retaddr);
+void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
+                     uint32_t val, uintptr_t retaddr);
+void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
+                     uint64_t val, uintptr_t retaddr);
 
 /*
  * Provide the same *_mmuidx_ra interface as for softmmu.
@@ -520,6 +518,8 @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
 #undef CPU_MMU_INDEX
 #undef MEMSUFFIX
 
+#endif /* defined(CONFIG_USER_ONLY) */
+
 uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
 uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr);
 uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr);
@@ -535,8 +535,6 @@ static inline int cpu_ldsw_code(CPUArchState *env, abi_ptr addr)
     return (int16_t)cpu_lduw_code(env, addr);
 }
 
-#endif /* defined(CONFIG_USER_ONLY) */
-
 /**
  * tlb_vaddr_to_host:
  * @env: CPUArchState
diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h
deleted file mode 100644
index e5a3d1983a..0000000000
--- a/include/exec/cpu_ldst_useronly_template.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- *  User-only accessor function support
- *
- * Generate inline load/store functions for one data size.
- *
- * Generate a store function as well as signed and unsigned loads.
- *
- * Not used directly but included from cpu_ldst.h.
- *
- *  Copyright (c) 2015 Linaro Limited
- *
- * 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/>.
- */
-
-#if !defined(CODE_ACCESS)
-#include "trace-root.h"
-#endif
-
-#include "trace/mem.h"
-
-#if DATA_SIZE == 8
-#define SUFFIX q
-#define USUFFIX q
-#define DATA_TYPE uint64_t
-#define SHIFT 3
-#elif DATA_SIZE == 4
-#define SUFFIX l
-#define USUFFIX l
-#define DATA_TYPE uint32_t
-#define SHIFT 2
-#elif DATA_SIZE == 2
-#define SUFFIX w
-#define USUFFIX uw
-#define DATA_TYPE uint16_t
-#define DATA_STYPE int16_t
-#define SHIFT 1
-#elif DATA_SIZE == 1
-#define SUFFIX b
-#define USUFFIX ub
-#define DATA_TYPE uint8_t
-#define DATA_STYPE int8_t
-#define SHIFT 0
-#else
-#error unsupported data size
-#endif
-
-#if DATA_SIZE == 8
-#define RES_TYPE uint64_t
-#else
-#define RES_TYPE uint32_t
-#endif
-
-static inline RES_TYPE
-glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
-{
-    RES_TYPE ret;
-#ifdef CODE_ACCESS
-    set_helper_retaddr(1);
-    ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
-    clear_helper_retaddr();
-#else
-    MemOp op = MO_TE | SHIFT;
-    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
-    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
-    ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
-#endif
-    return ret;
-}
-
-#ifndef CODE_ACCESS
-static inline RES_TYPE
-glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
-                                                  abi_ptr ptr,
-                                                  uintptr_t retaddr)
-{
-    RES_TYPE ret;
-    set_helper_retaddr(retaddr);
-    ret = glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(env, ptr);
-    clear_helper_retaddr();
-    return ret;
-}
-#endif
-
-#if DATA_SIZE <= 2
-static inline int
-glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
-{
-    int ret;
-#ifdef CODE_ACCESS
-    set_helper_retaddr(1);
-    ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
-    clear_helper_retaddr();
-#else
-    MemOp op = MO_TE | MO_SIGN | SHIFT;
-    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
-    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
-    ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
-    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
-#endif
-    return ret;
-}
-
-#ifndef CODE_ACCESS
-static inline int
-glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
-                                                  abi_ptr ptr,
-                                                  uintptr_t retaddr)
-{
-    int ret;
-    set_helper_retaddr(retaddr);
-    ret = glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(env, ptr);
-    clear_helper_retaddr();
-    return ret;
-}
-#endif /* CODE_ACCESS */
-#endif /* DATA_SIZE <= 2 */
-
-#ifndef CODE_ACCESS
-static inline void
-glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
-                                      RES_TYPE v)
-{
-    MemOp op = MO_TE | SHIFT;
-    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, true);
-    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
-    glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
-    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
-}
-
-static inline void
-glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
-                                                  abi_ptr ptr,
-                                                  RES_TYPE v,
-                                                  uintptr_t retaddr)
-{
-    set_helper_retaddr(retaddr);
-    glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(env, ptr, v);
-    clear_helper_retaddr();
-}
-#endif
-
-#undef RES_TYPE
-#undef DATA_TYPE
-#undef DATA_STYPE
-#undef SUFFIX
-#undef USUFFIX
-#undef DATA_SIZE
-#undef SHIFT
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index b09f7a1577..79da4219bb 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -26,6 +26,8 @@
 #include "translate-all.h"
 #include "exec/helper-proto.h"
 #include "qemu/atomic128.h"
+#include "trace-root.h"
+#include "trace/mem.h"
 
 #undef EAX
 #undef ECX
@@ -734,6 +736,240 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 
 /* The softmmu versions of these helpers are in cputlb.c.  */
 
+uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr)
+{
+    uint32_t ret;
+    uint16_t meminfo = trace_mem_get_info(MO_UB, MMU_USER_IDX, false);
+
+    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
+    ret = ldub_p(g2h(ptr));
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
+    return ret;
+}
+
+int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr)
+{
+    int ret;
+    uint16_t meminfo = trace_mem_get_info(MO_SB, MMU_USER_IDX, false);
+
+    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
+    ret = ldsb_p(g2h(ptr));
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
+    return ret;
+}
+
+uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr)
+{
+    uint32_t ret;
+    uint16_t meminfo = trace_mem_get_info(MO_TEUW, MMU_USER_IDX, false);
+
+    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
+    ret = lduw_p(g2h(ptr));
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
+    return ret;
+}
+
+int cpu_ldsw_data(CPUArchState *env, abi_ptr ptr)
+{
+    int ret;
+    uint16_t meminfo = trace_mem_get_info(MO_TESW, MMU_USER_IDX, false);
+
+    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
+    ret = ldsw_p(g2h(ptr));
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
+    return ret;
+}
+
+uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr)
+{
+    uint32_t ret;
+    uint16_t meminfo = trace_mem_get_info(MO_TEUL, MMU_USER_IDX, false);
+
+    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
+    ret = ldl_p(g2h(ptr));
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
+    return ret;
+}
+
+uint64_t cpu_ldq_data(CPUArchState *env, abi_ptr ptr)
+{
+    uint64_t ret;
+    uint16_t meminfo = trace_mem_get_info(MO_TEQ, MMU_USER_IDX, false);
+
+    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
+    ret = ldq_p(g2h(ptr));
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
+    return ret;
+}
+
+uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
+{
+    uint32_t ret;
+
+    set_helper_retaddr(retaddr);
+    ret = cpu_ldub_data(env, ptr);
+    clear_helper_retaddr();
+    return ret;
+}
+
+int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
+{
+    int ret;
+
+    set_helper_retaddr(retaddr);
+    ret = cpu_ldsb_data(env, ptr);
+    clear_helper_retaddr();
+    return ret;
+}
+
+uint32_t cpu_lduw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
+{
+    uint32_t ret;
+
+    set_helper_retaddr(retaddr);
+    ret = cpu_lduw_data(env, ptr);
+    clear_helper_retaddr();
+    return ret;
+}
+
+int cpu_ldsw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
+{
+    int ret;
+
+    set_helper_retaddr(retaddr);
+    ret = cpu_ldsw_data(env, ptr);
+    clear_helper_retaddr();
+    return ret;
+}
+
+uint32_t cpu_ldl_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
+{
+    uint32_t ret;
+
+    set_helper_retaddr(retaddr);
+    ret = cpu_ldl_data(env, ptr);
+    clear_helper_retaddr();
+    return ret;
+}
+
+uint64_t cpu_ldq_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
+{
+    uint64_t ret;
+
+    set_helper_retaddr(retaddr);
+    ret = cpu_ldq_data(env, ptr);
+    clear_helper_retaddr();
+    return ret;
+}
+
+void cpu_stb_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
+{
+    uint16_t meminfo = trace_mem_get_info(MO_UB, MMU_USER_IDX, true);
+
+    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
+    stb_p(g2h(ptr), val);
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
+}
+
+void cpu_stw_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
+{
+    uint16_t meminfo = trace_mem_get_info(MO_TEUW, MMU_USER_IDX, true);
+
+    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
+    stw_p(g2h(ptr), val);
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
+}
+
+void cpu_stl_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
+{
+    uint16_t meminfo = trace_mem_get_info(MO_TEUL, MMU_USER_IDX, true);
+
+    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
+    stl_p(g2h(ptr), val);
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
+}
+
+void cpu_stq_data(CPUArchState *env, abi_ptr ptr, uint64_t val)
+{
+    uint16_t meminfo = trace_mem_get_info(MO_TEQ, MMU_USER_IDX, true);
+
+    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
+    stq_p(g2h(ptr), val);
+    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
+}
+
+void cpu_stb_data_ra(CPUArchState *env, abi_ptr ptr,
+                     uint32_t val, uintptr_t retaddr)
+{
+    set_helper_retaddr(retaddr);
+    cpu_stb_data(env, ptr, val);
+    clear_helper_retaddr();
+}
+
+void cpu_stw_data_ra(CPUArchState *env, abi_ptr ptr,
+                     uint32_t val, uintptr_t retaddr)
+{
+    set_helper_retaddr(retaddr);
+    cpu_stw_data(env, ptr, val);
+    clear_helper_retaddr();
+}
+
+void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
+                     uint32_t val, uintptr_t retaddr)
+{
+    set_helper_retaddr(retaddr);
+    cpu_stl_data(env, ptr, val);
+    clear_helper_retaddr();
+}
+
+void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
+                     uint64_t val, uintptr_t retaddr)
+{
+    set_helper_retaddr(retaddr);
+    cpu_stq_data(env, ptr, val);
+    clear_helper_retaddr();
+}
+
+uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr ptr)
+{
+    uint32_t ret;
+
+    set_helper_retaddr(1);
+    ret = ldub_p(g2h(ptr));
+    clear_helper_retaddr();
+    return ret;
+}
+
+uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr ptr)
+{
+    uint32_t ret;
+
+    set_helper_retaddr(1);
+    ret = lduw_p(g2h(ptr));
+    clear_helper_retaddr();
+    return ret;
+}
+
+uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr ptr)
+{
+    uint32_t ret;
+
+    set_helper_retaddr(1);
+    ret = ldl_p(g2h(ptr));
+    clear_helper_retaddr();
+    return ret;
+}
+
+uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr ptr)
+{
+    uint64_t ret;
+
+    set_helper_retaddr(1);
+    ret = ldq_p(g2h(ptr));
+    clear_helper_retaddr();
+    return ret;
+}
+
 /* Do not allow unaligned operations to proceed.  Return the host address.  */
 static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
                                int size, uintptr_t retaddr)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 15/28] target/nios2: Remove MMU_MODE{0,1}_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (13 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 14/28] cputlb: Expand cpu_ldst_useronly_template.h in user-exec.c Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 18:02   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 16/28] target/alpha: " Richard Henderson
                   ` (12 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marek Vasut, Chris Wulff

The functions generated by these macros are unused.

Cc: Chris Wulff <crwulff@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/nios2/cpu.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index 361b06ffeb..78f633f970 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -217,8 +217,6 @@ void do_nios2_semihosting(CPUNios2State *env);
 #define CPU_SAVE_VERSION 1
 
 /* MMU modes definitions */
-#define MMU_MODE0_SUFFIX _kernel
-#define MMU_MODE1_SUFFIX _user
 #define MMU_SUPERVISOR_IDX  0
 #define MMU_USER_IDX        1
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 16/28] target/alpha: Remove MMU_MODE{0,1}_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (14 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 15/28] target/nios2: Remove MMU_MODE{0,1}_SUFFIX Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 18:02   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 17/28] target/cris: " Richard Henderson
                   ` (11 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel

The functions generated by these macros are unused.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/alpha/cpu.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index a530249a5b..3f782c0efe 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -193,8 +193,6 @@ enum {
    PALcode cheats and usees the KSEG mapping for its code+data rather than
    physical addresses.  */
 
-#define MMU_MODE0_SUFFIX _kernel
-#define MMU_MODE1_SUFFIX _user
 #define MMU_KERNEL_IDX   0
 #define MMU_USER_IDX     1
 #define MMU_PHYS_IDX     2
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 17/28] target/cris: Remove MMU_MODE{0,1}_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (15 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 16/28] target/alpha: " Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 18:02   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 18/28] target/i386: Remove MMU_MODE{0,1,2}_SUFFIX Richard Henderson
                   ` (10 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Edgar E . Iglesias

The functions generated by these macros are unused.

Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/cris/cpu.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/target/cris/cpu.h b/target/cris/cpu.h
index aba0a66474..bc43bc23a1 100644
--- a/target/cris/cpu.h
+++ b/target/cris/cpu.h
@@ -252,8 +252,6 @@ enum {
 #define cpu_signal_handler cpu_cris_signal_handler
 
 /* MMU modes definitions */
-#define MMU_MODE0_SUFFIX _kernel
-#define MMU_MODE1_SUFFIX _user
 #define MMU_USER_IDX 1
 static inline int cpu_mmu_index (CPUCRISState *env, bool ifetch)
 {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 18/28] target/i386: Remove MMU_MODE{0,1,2}_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (16 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 17/28] target/cris: " Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 18:02   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 19/28] target/microblaze: " Richard Henderson
                   ` (9 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Eduardo Habkost

The functions generated by these macros are unused.

Cc: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/i386/cpu.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index cde2a16b94..6a8228df4f 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1949,9 +1949,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 #define cpu_list x86_cpu_list
 
 /* MMU modes definitions */
-#define MMU_MODE0_SUFFIX _ksmap
-#define MMU_MODE1_SUFFIX _user
-#define MMU_MODE2_SUFFIX _knosmap /* SMAP disabled or CPL<3 && AC=1 */
 #define MMU_KSMAP_IDX   0
 #define MMU_USER_IDX    1
 #define MMU_KNOSMAP_IDX 2
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 19/28] target/microblaze: Remove MMU_MODE{0,1,2}_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (17 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 18/28] target/i386: Remove MMU_MODE{0,1,2}_SUFFIX Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 18:03   ` [PATCH v2 19/28] target/microblaze: Remove MMU_MODE{0, 1, 2}_SUFFIX Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 20/28] target/sh4: Remove MMU_MODE{0,1}_SUFFIX Richard Henderson
                   ` (8 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Edgar E . Iglesias

The functions generated by these macros are unused.

Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/microblaze/cpu.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
index 95773089aa..32522f606b 100644
--- a/target/microblaze/cpu.h
+++ b/target/microblaze/cpu.h
@@ -328,9 +328,6 @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
 #define cpu_signal_handler cpu_mb_signal_handler
 
 /* MMU modes definitions */
-#define MMU_MODE0_SUFFIX _nommu
-#define MMU_MODE1_SUFFIX _kernel
-#define MMU_MODE2_SUFFIX _user
 #define MMU_NOMMU_IDX   0
 #define MMU_KERNEL_IDX  1
 #define MMU_USER_IDX    2
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 20/28] target/sh4: Remove MMU_MODE{0,1}_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (18 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 19/28] target/microblaze: " Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 18:03   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 21/28] target/unicore32: " Richard Henderson
                   ` (7 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aurelien Jarno

The functions generated by these macros are unused.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/sh4/cpu.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
index ecaa7a18a9..452a596e67 100644
--- a/target/sh4/cpu.h
+++ b/target/sh4/cpu.h
@@ -254,8 +254,6 @@ void cpu_load_tlb(CPUSH4State * env);
 #define cpu_list sh4_cpu_list
 
 /* MMU modes definitions */
-#define MMU_MODE0_SUFFIX _kernel
-#define MMU_MODE1_SUFFIX _user
 #define MMU_USER_IDX 1
 static inline int cpu_mmu_index (CPUSH4State *env, bool ifetch)
 {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 21/28] target/unicore32: Remove MMU_MODE{0,1}_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (19 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 20/28] target/sh4: Remove MMU_MODE{0,1}_SUFFIX Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 18:03   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 22/28] target/xtensa: Remove MMU_MODE{0,1,2,3}_SUFFIX Richard Henderson
                   ` (6 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Guan Xuetao

The functions generated by these macros are unused.

Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/unicore32/cpu.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
index 50ed9dd99c..7a32e086ed 100644
--- a/target/unicore32/cpu.h
+++ b/target/unicore32/cpu.h
@@ -133,8 +133,6 @@ void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)
 int uc32_cpu_signal_handler(int host_signum, void *pinfo, void *puc);
 
 /* MMU modes definitions */
-#define MMU_MODE0_SUFFIX _kernel
-#define MMU_MODE1_SUFFIX _user
 #define MMU_USER_IDX 1
 static inline int cpu_mmu_index(CPUUniCore32State *env, bool ifetch)
 {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 22/28] target/xtensa: Remove MMU_MODE{0,1,2,3}_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (20 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 21/28] target/unicore32: " Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 19:30   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 23/28] target/m68k: Use cpu_*_mmuidx_ra instead of MMU_MODE{0, 1}_SUFFIX Richard Henderson
                   ` (5 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov

The functions generated by these macros are unused.

Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/xtensa/cpu.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index b363ffcf10..f5a7ea48bb 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -685,10 +685,6 @@ static inline uint32_t xtensa_replicate_windowstart(CPUXtensaState *env)
 }
 
 /* MMU modes definitions */
-#define MMU_MODE0_SUFFIX _ring0
-#define MMU_MODE1_SUFFIX _ring1
-#define MMU_MODE2_SUFFIX _ring2
-#define MMU_MODE3_SUFFIX _ring3
 #define MMU_USER_IDX 3
 
 static inline int cpu_mmu_index(CPUXtensaState *env, bool ifetch)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 23/28] target/m68k: Use cpu_*_mmuidx_ra instead of MMU_MODE{0, 1}_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (21 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 22/28] target/xtensa: Remove MMU_MODE{0,1,2,3}_SUFFIX Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 19:34   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 24/28] target/mips: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX Richard Henderson
                   ` (4 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier

The generated *_user functions are unused.  The *_kernel functions
have a couple of users in op_helper.c; use *_mmuidx_ra instead,
with MMU_KERNEL_IDX.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
v2: Use *_mmuidx_ra directly, without intermediate macros.
---
 target/m68k/cpu.h       |  2 --
 target/m68k/op_helper.c | 77 +++++++++++++++++++++++++----------------
 2 files changed, 47 insertions(+), 32 deletions(-)

diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 20de3c379a..89af14e899 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -516,8 +516,6 @@ enum {
 #define cpu_list m68k_cpu_list
 
 /* MMU modes definitions */
-#define MMU_MODE0_SUFFIX _kernel
-#define MMU_MODE1_SUFFIX _user
 #define MMU_KERNEL_IDX 0
 #define MMU_USER_IDX 1
 static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch)
diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c
index bc4f845e3f..202498deb5 100644
--- a/target/m68k/op_helper.c
+++ b/target/m68k/op_helper.c
@@ -42,8 +42,8 @@ static void cf_rte(CPUM68KState *env)
     uint32_t fmt;
 
     sp = env->aregs[7];
-    fmt = cpu_ldl_kernel(env, sp);
-    env->pc = cpu_ldl_kernel(env, sp + 4);
+    fmt = cpu_ldl_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
+    env->pc = cpu_ldl_mmuidx_ra(env, sp + 4, MMU_KERNEL_IDX, 0);
     sp |= (fmt >> 28) & 3;
     env->aregs[7] = sp + 8;
 
@@ -58,13 +58,13 @@ static void m68k_rte(CPUM68KState *env)
 
     sp = env->aregs[7];
 throwaway:
-    sr = cpu_lduw_kernel(env, sp);
+    sr = cpu_lduw_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
     sp += 2;
-    env->pc = cpu_ldl_kernel(env, sp);
+    env->pc = cpu_ldl_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
     sp += 4;
     if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) {
         /*  all except 68000 */
-        fmt = cpu_lduw_kernel(env, sp);
+        fmt = cpu_lduw_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
         sp += 2;
         switch (fmt >> 12) {
         case 0:
@@ -260,12 +260,12 @@ static void cf_interrupt_all(CPUM68KState *env, int is_hw)
     /* ??? This could cause MMU faults.  */
     sp &= ~3;
     sp -= 4;
-    cpu_stl_kernel(env, sp, retaddr);
+    cpu_stl_mmuidx_ra(env, sp, retaddr, MMU_KERNEL_IDX, 0);
     sp -= 4;
-    cpu_stl_kernel(env, sp, fmt);
+    cpu_stl_mmuidx_ra(env, sp, fmt, MMU_KERNEL_IDX, 0);
     env->aregs[7] = sp;
     /* Jump to vector.  */
-    env->pc = cpu_ldl_kernel(env, env->vbr + vector);
+    env->pc = cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, 0);
 }
 
 static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
@@ -278,23 +278,24 @@ static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
         switch (format) {
         case 4:
             *sp -= 4;
-            cpu_stl_kernel(env, *sp, env->pc);
+            cpu_stl_mmuidx_ra(env, *sp, env->pc, MMU_KERNEL_IDX, 0);
             *sp -= 4;
-            cpu_stl_kernel(env, *sp, addr);
+            cpu_stl_mmuidx_ra(env, *sp, addr, MMU_KERNEL_IDX, 0);
             break;
         case 3:
         case 2:
             *sp -= 4;
-            cpu_stl_kernel(env, *sp, addr);
+            cpu_stl_mmuidx_ra(env, *sp, addr, MMU_KERNEL_IDX, 0);
             break;
         }
         *sp -= 2;
-        cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2));
+        cpu_stw_mmuidx_ra(env, *sp, (format << 12) + (cs->exception_index << 2),
+                          MMU_KERNEL_IDX, 0);
     }
     *sp -= 4;
-    cpu_stl_kernel(env, *sp, retaddr);
+    cpu_stl_mmuidx_ra(env, *sp, retaddr, MMU_KERNEL_IDX, 0);
     *sp -= 2;
-    cpu_stw_kernel(env, *sp, sr);
+    cpu_stw_mmuidx_ra(env, *sp, sr, MMU_KERNEL_IDX, 0);
 }
 
 static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
@@ -353,36 +354,52 @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
             cpu_abort(cs, "DOUBLE MMU FAULT\n");
         }
         env->mmu.fault = true;
+        /* push data 3 */
         sp -= 4;
-        cpu_stl_kernel(env, sp, 0); /* push data 3 */
+        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
+        /* push data 2 */
         sp -= 4;
-        cpu_stl_kernel(env, sp, 0); /* push data 2 */
+        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
+        /* push data 1 */
         sp -= 4;
-        cpu_stl_kernel(env, sp, 0); /* push data 1 */
+        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
+        /* write back 1 / push data 0 */
         sp -= 4;
-        cpu_stl_kernel(env, sp, 0); /* write back 1 / push data 0 */
+        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
+        /* write back 1 address */
         sp -= 4;
-        cpu_stl_kernel(env, sp, 0); /* write back 1 address */
+        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
+        /* write back 2 data */
         sp -= 4;
-        cpu_stl_kernel(env, sp, 0); /* write back 2 data */
+        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
+        /* write back 2 address */
         sp -= 4;
-        cpu_stl_kernel(env, sp, 0); /* write back 2 address */
+        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
+        /* write back 3 data */
         sp -= 4;
-        cpu_stl_kernel(env, sp, 0); /* write back 3 data */
+        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
+        /* write back 3 address */
         sp -= 4;
-        cpu_stl_kernel(env, sp, env->mmu.ar); /* write back 3 address */
+        cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
+        /* fault address */
         sp -= 4;
-        cpu_stl_kernel(env, sp, env->mmu.ar); /* fault address */
+        cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
+        /* write back 1 status */
         sp -= 2;
-        cpu_stw_kernel(env, sp, 0); /* write back 1 status */
+        cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
+        /* write back 2 status */
         sp -= 2;
-        cpu_stw_kernel(env, sp, 0); /* write back 2 status */
+        cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
+        /* write back 3 status */
         sp -= 2;
-        cpu_stw_kernel(env, sp, 0); /* write back 3 status */
+        cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
+        /* special status word */
         sp -= 2;
-        cpu_stw_kernel(env, sp, env->mmu.ssw); /* special status word */
+        cpu_stw_mmuidx_ra(env, sp, env->mmu.ssw, MMU_KERNEL_IDX, 0);
+        /* effective address */
         sp -= 4;
-        cpu_stl_kernel(env, sp, env->mmu.ar); /* effective address */
+        cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
+
         do_stack_frame(env, &sp, 7, oldsr, 0, retaddr);
         env->mmu.fault = false;
         if (qemu_loglevel_mask(CPU_LOG_INT)) {
@@ -414,7 +431,7 @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
 
     env->aregs[7] = sp;
     /* Jump to vector.  */
-    env->pc = cpu_ldl_kernel(env, env->vbr + vector);
+    env->pc = cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, 0);
 }
 
 static void do_interrupt_all(CPUM68KState *env, int is_hw)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 24/28] target/mips: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (22 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 23/28] target/m68k: Use cpu_*_mmuidx_ra instead of MMU_MODE{0, 1}_SUFFIX Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 19:37   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 25/28] target/s390x: " Richard Henderson
                   ` (3 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aleksandar Rikalo, Aleksandar Markovic, Aurelien Jarno

The separate suffixed functions were used to construct
some do_##insn function switched on mmu_idx.  The interface
is exactly identical to the *_mmuidx_ra functions.  Replace
them directly and remove the constructions.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/mips/cpu.h       |   4 -
 target/mips/op_helper.c | 182 +++++++++++++---------------------------
 2 files changed, 60 insertions(+), 126 deletions(-)

diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index ca00f41daf..c218ccc4a8 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -1147,10 +1147,6 @@ extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env);
  * MMU modes definitions. We carefully match the indices with our
  * hflags layout.
  */
-#define MMU_MODE0_SUFFIX _kernel
-#define MMU_MODE1_SUFFIX _super
-#define MMU_MODE2_SUFFIX _user
-#define MMU_MODE3_SUFFIX _error
 #define MMU_USER_IDX 2
 
 static inline int hflags_mmu_index(uint32_t hflags)
diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c
index 18fcee4a78..79d44da6fa 100644
--- a/target/mips/op_helper.c
+++ b/target/mips/op_helper.c
@@ -52,69 +52,6 @@ static void raise_exception(CPUMIPSState *env, uint32_t exception)
     do_raise_exception(env, exception, 0);
 }
 
-#if defined(CONFIG_USER_ONLY)
-#define HELPER_LD(name, insn, type)                                     \
-static inline type do_##name(CPUMIPSState *env, target_ulong addr,      \
-                             int mem_idx, uintptr_t retaddr)            \
-{                                                                       \
-    return (type) cpu_##insn##_data_ra(env, addr, retaddr);             \
-}
-#else
-#define HELPER_LD(name, insn, type)                                     \
-static inline type do_##name(CPUMIPSState *env, target_ulong addr,      \
-                             int mem_idx, uintptr_t retaddr)            \
-{                                                                       \
-    switch (mem_idx) {                                                  \
-    case 0: return (type) cpu_##insn##_kernel_ra(env, addr, retaddr);   \
-    case 1: return (type) cpu_##insn##_super_ra(env, addr, retaddr);    \
-    default:                                                            \
-    case 2: return (type) cpu_##insn##_user_ra(env, addr, retaddr);     \
-    case 3: return (type) cpu_##insn##_error_ra(env, addr, retaddr);    \
-    }                                                                   \
-}
-#endif
-HELPER_LD(lw, ldl, int32_t)
-#if defined(TARGET_MIPS64)
-HELPER_LD(ld, ldq, int64_t)
-#endif
-#undef HELPER_LD
-
-#if defined(CONFIG_USER_ONLY)
-#define HELPER_ST(name, insn, type)                                     \
-static inline void do_##name(CPUMIPSState *env, target_ulong addr,      \
-                             type val, int mem_idx, uintptr_t retaddr)  \
-{                                                                       \
-    cpu_##insn##_data_ra(env, addr, val, retaddr);                      \
-}
-#else
-#define HELPER_ST(name, insn, type)                                     \
-static inline void do_##name(CPUMIPSState *env, target_ulong addr,      \
-                             type val, int mem_idx, uintptr_t retaddr)  \
-{                                                                       \
-    switch (mem_idx) {                                                  \
-    case 0:                                                             \
-        cpu_##insn##_kernel_ra(env, addr, val, retaddr);                \
-        break;                                                          \
-    case 1:                                                             \
-        cpu_##insn##_super_ra(env, addr, val, retaddr);                 \
-        break;                                                          \
-    default:                                                            \
-    case 2:                                                             \
-        cpu_##insn##_user_ra(env, addr, val, retaddr);                  \
-        break;                                                          \
-    case 3:                                                             \
-        cpu_##insn##_error_ra(env, addr, val, retaddr);                 \
-        break;                                                          \
-    }                                                                   \
-}
-#endif
-HELPER_ST(sb, stb, uint8_t)
-HELPER_ST(sw, stl, uint32_t)
-#if defined(TARGET_MIPS64)
-HELPER_ST(sd, stq, uint64_t)
-#endif
-#undef HELPER_ST
-
 /* 64 bits arithmetic for 32 bits hosts */
 static inline uint64_t get_HILO(CPUMIPSState *env)
 {
@@ -379,12 +316,12 @@ target_ulong helper_##name(CPUMIPSState *env, target_ulong arg, int mem_idx)  \
     }                                                                         \
     env->CP0_LLAddr = do_translate_address(env, arg, 0, GETPC());             \
     env->lladdr = arg;                                                        \
-    env->llval = do_##insn(env, arg, mem_idx, GETPC());                       \
+    env->llval = cpu_##insn##_mmuidx_ra(env, arg, mem_idx, GETPC());          \
     return env->llval;                                                        \
 }
-HELPER_LD_ATOMIC(ll, lw, 0x3)
+HELPER_LD_ATOMIC(ll, ldl, 0x3)
 #ifdef TARGET_MIPS64
-HELPER_LD_ATOMIC(lld, ld, 0x7)
+HELPER_LD_ATOMIC(lld, ldq, 0x7)
 #endif
 #undef HELPER_LD_ATOMIC
 #endif
@@ -400,42 +337,42 @@ HELPER_LD_ATOMIC(lld, ld, 0x7)
 void helper_swl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
                 int mem_idx)
 {
-    do_sb(env, arg2, (uint8_t)(arg1 >> 24), mem_idx, GETPC());
+    cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 24), mem_idx, GETPC());
 
     if (GET_LMASK(arg2) <= 2) {
-        do_sb(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 16), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 16),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK(arg2) <= 1) {
-        do_sb(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 8), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 8),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK(arg2) == 0) {
-        do_sb(env, GET_OFFSET(arg2, 3), (uint8_t)arg1, mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)arg1,
+                          mem_idx, GETPC());
     }
 }
 
 void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
                 int mem_idx)
 {
-    do_sb(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
+    cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
 
     if (GET_LMASK(arg2) >= 1) {
-        do_sb(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK(arg2) >= 2) {
-        do_sb(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK(arg2) == 3) {
-        do_sb(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
+                          mem_idx, GETPC());
     }
 }
 
@@ -453,82 +390,82 @@ void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
 void helper_sdl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
                 int mem_idx)
 {
-    do_sb(env, arg2, (uint8_t)(arg1 >> 56), mem_idx, GETPC());
+    cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 56), mem_idx, GETPC());
 
     if (GET_LMASK64(arg2) <= 6) {
-        do_sb(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 48), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 48),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) <= 5) {
-        do_sb(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 40), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 40),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) <= 4) {
-        do_sb(env, GET_OFFSET(arg2, 3), (uint8_t)(arg1 >> 32), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)(arg1 >> 32),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) <= 3) {
-        do_sb(env, GET_OFFSET(arg2, 4), (uint8_t)(arg1 >> 24), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 4), (uint8_t)(arg1 >> 24),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) <= 2) {
-        do_sb(env, GET_OFFSET(arg2, 5), (uint8_t)(arg1 >> 16), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 5), (uint8_t)(arg1 >> 16),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) <= 1) {
-        do_sb(env, GET_OFFSET(arg2, 6), (uint8_t)(arg1 >> 8), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 6), (uint8_t)(arg1 >> 8),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) <= 0) {
-        do_sb(env, GET_OFFSET(arg2, 7), (uint8_t)arg1, mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 7), (uint8_t)arg1,
+                          mem_idx, GETPC());
     }
 }
 
 void helper_sdr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
                 int mem_idx)
 {
-    do_sb(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
+    cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
 
     if (GET_LMASK64(arg2) >= 1) {
-        do_sb(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) >= 2) {
-        do_sb(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) >= 3) {
-        do_sb(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) >= 4) {
-        do_sb(env, GET_OFFSET(arg2, -4), (uint8_t)(arg1 >> 32), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -4), (uint8_t)(arg1 >> 32),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) >= 5) {
-        do_sb(env, GET_OFFSET(arg2, -5), (uint8_t)(arg1 >> 40), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -5), (uint8_t)(arg1 >> 40),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) >= 6) {
-        do_sb(env, GET_OFFSET(arg2, -6), (uint8_t)(arg1 >> 48), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -6), (uint8_t)(arg1 >> 48),
+                          mem_idx, GETPC());
     }
 
     if (GET_LMASK64(arg2) == 7) {
-        do_sb(env, GET_OFFSET(arg2, -7), (uint8_t)(arg1 >> 56), mem_idx,
-              GETPC());
+        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -7), (uint8_t)(arg1 >> 56),
+                          mem_idx, GETPC());
     }
 }
 #endif /* TARGET_MIPS64 */
@@ -546,14 +483,14 @@ void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
 
         for (i = 0; i < base_reglist; i++) {
             env->active_tc.gpr[multiple_regs[i]] =
-                (target_long)do_lw(env, addr, mem_idx, GETPC());
+                (target_long)cpu_ldl_mmuidx_ra(env, addr, mem_idx, GETPC());
             addr += 4;
         }
     }
 
     if (do_r31) {
-        env->active_tc.gpr[31] = (target_long)do_lw(env, addr, mem_idx,
-                                                    GETPC());
+        env->active_tc.gpr[31] =
+            (target_long)cpu_ldl_mmuidx_ra(env, addr, mem_idx, GETPC());
     }
 }
 
@@ -567,14 +504,14 @@ void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
         target_ulong i;
 
         for (i = 0; i < base_reglist; i++) {
-            do_sw(env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx,
-                  GETPC());
+            cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
+                              mem_idx, GETPC());
             addr += 4;
         }
     }
 
     if (do_r31) {
-        do_sw(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
+        cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
     }
 }
 
@@ -589,14 +526,15 @@ void helper_ldm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
         target_ulong i;
 
         for (i = 0; i < base_reglist; i++) {
-            env->active_tc.gpr[multiple_regs[i]] = do_ld(env, addr, mem_idx,
-                                                         GETPC());
+            env->active_tc.gpr[multiple_regs[i]] =
+                cpu_ldq_mmuidx_ra(env, addr, mem_idx, GETPC());
             addr += 8;
         }
     }
 
     if (do_r31) {
-        env->active_tc.gpr[31] = do_ld(env, addr, mem_idx, GETPC());
+        env->active_tc.gpr[31] =
+            cpu_ldq_mmuidx_ra(env, addr, mem_idx, GETPC());
     }
 }
 
@@ -610,14 +548,14 @@ void helper_sdm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
         target_ulong i;
 
         for (i = 0; i < base_reglist; i++) {
-            do_sd(env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx,
-                  GETPC());
+            cpu_stq_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
+                              mem_idx, GETPC());
             addr += 8;
         }
     }
 
     if (do_r31) {
-        do_sd(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
+        cpu_stq_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
     }
 }
 #endif
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 25/28] target/s390x: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (23 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 24/28] target/mips: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 19:39   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 26/28] target/ppc: " Richard Henderson
                   ` (2 subsequent siblings)
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Hildenbrand

The generated functions aside from *_real are unused.
The *_real functions have a couple of users in mem_helper.c;
use *_mmuidx_ra instead, with MMU_REAL_IDX.

Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
v2: Use *_mmuidx_ra directly, without intermediate macros.
---
 target/s390x/cpu.h        |  5 -----
 target/s390x/mem_helper.c | 21 ++++++++++++---------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index aa829e954c..cfa8a81265 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -36,11 +36,6 @@
 
 #define TARGET_INSN_START_EXTRA_WORDS 2
 
-#define MMU_MODE0_SUFFIX _primary
-#define MMU_MODE1_SUFFIX _secondary
-#define MMU_MODE2_SUFFIX _home
-#define MMU_MODE3_SUFFIX _real
-
 #define MMU_USER_IDX 0
 
 #define S390_MAX_CPUS 248
diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
index 57ce17c252..6f4a16b9b2 100644
--- a/target/s390x/mem_helper.c
+++ b/target/s390x/mem_helper.c
@@ -2026,7 +2026,7 @@ uint32_t HELPER(testblock)(CPUS390XState *env, uint64_t real_addr)
     real_addr = wrap_address(env, real_addr) & TARGET_PAGE_MASK;
 
     for (i = 0; i < TARGET_PAGE_SIZE; i += 8) {
-        cpu_stq_real_ra(env, real_addr + i, 0, ra);
+        cpu_stq_mmuidx_ra(env, real_addr + i, 0, MMU_REAL_IDX, ra);
     }
 
     return 0;
@@ -2260,11 +2260,11 @@ void HELPER(idte)(CPUS390XState *env, uint64_t r1, uint64_t r2, uint32_t m4)
         for (i = 0; i < entries; i++) {
             /* addresses are not wrapped in 24/31bit mode but table index is */
             raddr = table + ((index + i) & 0x7ff) * sizeof(entry);
-            entry = cpu_ldq_real_ra(env, raddr, ra);
+            entry = cpu_ldq_mmuidx_ra(env, raddr, MMU_REAL_IDX, ra);
             if (!(entry & REGION_ENTRY_I)) {
                 /* we are allowed to not store if already invalid */
                 entry |= REGION_ENTRY_I;
-                cpu_stq_real_ra(env, raddr, entry, ra);
+                cpu_stq_mmuidx_ra(env, raddr, entry, MMU_REAL_IDX, ra);
             }
         }
     }
@@ -2291,9 +2291,9 @@ void HELPER(ipte)(CPUS390XState *env, uint64_t pto, uint64_t vaddr,
     pte_addr += VADDR_PAGE_TX(vaddr) * 8;
 
     /* Mark the page table entry as invalid */
-    pte = cpu_ldq_real_ra(env, pte_addr, ra);
+    pte = cpu_ldq_mmuidx_ra(env, pte_addr, MMU_REAL_IDX, ra);
     pte |= PAGE_ENTRY_I;
-    cpu_stq_real_ra(env, pte_addr, pte, ra);
+    cpu_stq_mmuidx_ra(env, pte_addr, pte, MMU_REAL_IDX, ra);
 
     /* XXX we exploit the fact that Linux passes the exact virtual
        address here - it's not obliged to! */
@@ -2333,18 +2333,21 @@ void HELPER(purge)(CPUS390XState *env)
 /* load using real address */
 uint64_t HELPER(lura)(CPUS390XState *env, uint64_t addr)
 {
-    return cpu_ldl_real_ra(env, wrap_address(env, addr), GETPC());
+    return cpu_ldl_mmuidx_ra(env, wrap_address(env, addr),
+                             MMU_REAL_IDX, GETPC());
 }
 
 uint64_t HELPER(lurag)(CPUS390XState *env, uint64_t addr)
 {
-    return cpu_ldq_real_ra(env, wrap_address(env, addr), GETPC());
+    return cpu_ldq_mmuidx_ra(env, wrap_address(env, addr),
+                             MMU_REAL_IDX, GETPC());
 }
 
 /* store using real address */
 void HELPER(stura)(CPUS390XState *env, uint64_t addr, uint64_t v1)
 {
-    cpu_stl_real_ra(env, wrap_address(env, addr), (uint32_t)v1, GETPC());
+    cpu_stl_mmuidx_ra(env, wrap_address(env, addr), (uint32_t)v1,
+                      MMU_REAL_IDX, GETPC());
 
     if ((env->psw.mask & PSW_MASK_PER) &&
         (env->cregs[9] & PER_CR9_EVENT_STORE) &&
@@ -2357,7 +2360,7 @@ void HELPER(stura)(CPUS390XState *env, uint64_t addr, uint64_t v1)
 
 void HELPER(sturg)(CPUS390XState *env, uint64_t addr, uint64_t v1)
 {
-    cpu_stq_real_ra(env, wrap_address(env, addr), v1, GETPC());
+    cpu_stq_mmuidx_ra(env, wrap_address(env, addr), v1, MMU_REAL_IDX, GETPC());
 
     if ((env->psw.mask & PSW_MASK_PER) &&
         (env->cregs[9] & PER_CR9_EVENT_STORE) &&
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 26/28] target/ppc: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (24 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 25/28] target/s390x: " Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 19:51   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 27/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
  2019-12-16 22:11 ` [PATCH v2 28/28] cputlb: Expand cpu_ldst_template.h in cputlb.c Richard Henderson
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson

There are only two uses.  Within dcbz_common, the local variable
mmu_idx already contains the epid computation, and we can avoid
repeating it for the store.  Within helper_icbiep, the usage is
trivially expanded using PPC_TLB_EPID_LOAD.

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/ppc/cpu.h        |  2 --
 target/ppc/mem_helper.c | 11 ++---------
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index e3e82327b7..3bd983adaa 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -951,8 +951,6 @@ struct ppc_radix_page_info {
  * + real/paged mode combinations. The other two modes are for
  * external PID load/store.
  */
-#define MMU_MODE8_SUFFIX _epl
-#define MMU_MODE9_SUFFIX _eps
 #define PPC_TLB_EPID_LOAD 8
 #define PPC_TLB_EPID_STORE 9
 
diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
index 1351b53f28..56855f2381 100644
--- a/target/ppc/mem_helper.c
+++ b/target/ppc/mem_helper.c
@@ -177,14 +177,7 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr,
     } else {
         /* Slow path */
         for (i = 0; i < dcbz_size; i += 8) {
-            if (epid) {
-#if !defined(CONFIG_USER_ONLY)
-                /* Does not make sense on USER_ONLY config */
-                cpu_stq_eps_ra(env, addr + i, 0, retaddr);
-#endif
-            } else {
-                cpu_stq_data_ra(env, addr + i, 0, retaddr);
-            }
+            cpu_stq_mmuidx_ra(env, addr + i, 0, mmu_idx, retaddr);
         }
     }
 }
@@ -216,7 +209,7 @@ void helper_icbiep(CPUPPCState *env, target_ulong addr)
 #if !defined(CONFIG_USER_ONLY)
     /* See comments above */
     addr &= ~(env->dcache_line_size - 1);
-    cpu_ldl_epl_ra(env, addr, GETPC());
+    cpu_ldl_mmuidx_ra(env, addr, PPC_TLB_EPID_LOAD, GETPC());
 #endif
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 27/28] cputlb: Remove support for MMU_MODE*_SUFFIX
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (25 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 26/28] target/ppc: " Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 19:52   ` Alex Bennée
  2019-12-16 22:11 ` [PATCH v2 28/28] cputlb: Expand cpu_ldst_template.h in cputlb.c Richard Henderson
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel

All users have now been converted to cpu_*_mmuidx_ra.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu_ldst.h | 230 ----------------------------------------
 1 file changed, 230 deletions(-)

diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index 0f3c49a005..cf4652bf48 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -271,236 +271,6 @@ void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
 void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
                        int mmu_idx, uintptr_t retaddr);
 
-#ifdef MMU_MODE0_SUFFIX
-#define CPU_MMU_INDEX 0
-#define MEMSUFFIX MMU_MODE0_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif
-
-#if (NB_MMU_MODES >= 2) && defined(MMU_MODE1_SUFFIX)
-#define CPU_MMU_INDEX 1
-#define MEMSUFFIX MMU_MODE1_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif
-
-#if (NB_MMU_MODES >= 3) && defined(MMU_MODE2_SUFFIX)
-
-#define CPU_MMU_INDEX 2
-#define MEMSUFFIX MMU_MODE2_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif /* (NB_MMU_MODES >= 3) */
-
-#if (NB_MMU_MODES >= 4) && defined(MMU_MODE3_SUFFIX)
-
-#define CPU_MMU_INDEX 3
-#define MEMSUFFIX MMU_MODE3_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif /* (NB_MMU_MODES >= 4) */
-
-#if (NB_MMU_MODES >= 5) && defined(MMU_MODE4_SUFFIX)
-
-#define CPU_MMU_INDEX 4
-#define MEMSUFFIX MMU_MODE4_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif /* (NB_MMU_MODES >= 5) */
-
-#if (NB_MMU_MODES >= 6) && defined(MMU_MODE5_SUFFIX)
-
-#define CPU_MMU_INDEX 5
-#define MEMSUFFIX MMU_MODE5_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif /* (NB_MMU_MODES >= 6) */
-
-#if (NB_MMU_MODES >= 7) && defined(MMU_MODE6_SUFFIX)
-
-#define CPU_MMU_INDEX 6
-#define MEMSUFFIX MMU_MODE6_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif /* (NB_MMU_MODES >= 7) */
-
-#if (NB_MMU_MODES >= 8) && defined(MMU_MODE7_SUFFIX)
-
-#define CPU_MMU_INDEX 7
-#define MEMSUFFIX MMU_MODE7_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif /* (NB_MMU_MODES >= 8) */
-
-#if (NB_MMU_MODES >= 9) && defined(MMU_MODE8_SUFFIX)
-
-#define CPU_MMU_INDEX 8
-#define MEMSUFFIX MMU_MODE8_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif /* (NB_MMU_MODES >= 9) */
-
-#if (NB_MMU_MODES >= 10) && defined(MMU_MODE9_SUFFIX)
-
-#define CPU_MMU_INDEX 9
-#define MEMSUFFIX MMU_MODE9_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif /* (NB_MMU_MODES >= 10) */
-
-#if (NB_MMU_MODES >= 11) && defined(MMU_MODE10_SUFFIX)
-
-#define CPU_MMU_INDEX 10
-#define MEMSUFFIX MMU_MODE10_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif /* (NB_MMU_MODES >= 11) */
-
-#if (NB_MMU_MODES >= 12) && defined(MMU_MODE11_SUFFIX)
-
-#define CPU_MMU_INDEX 11
-#define MEMSUFFIX MMU_MODE11_SUFFIX
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-#endif /* (NB_MMU_MODES >= 12) */
-
-#if (NB_MMU_MODES > 12)
-#error "NB_MMU_MODES > 12 is not supported for now"
-#endif /* (NB_MMU_MODES > 12) */
-
 /* these access are slower, they must be as rare as possible */
 #define CPU_MMU_INDEX (cpu_mmu_index(env, false))
 #define MEMSUFFIX _data
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 28/28] cputlb: Expand cpu_ldst_template.h in cputlb.c
  2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
                   ` (26 preceding siblings ...)
  2019-12-16 22:11 ` [PATCH v2 27/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
@ 2019-12-16 22:11 ` Richard Henderson
  2019-12-20 19:53   ` Alex Bennée
  27 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-16 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aleksandar Markovic

Reduce the amount of preprocessor obfuscation by expanding
the text of each of the functions generated.  The result is
only slightly smaller than the original.

Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu_ldst.h          |  67 +++++++-----------
 include/exec/cpu_ldst_template.h | 117 -------------------------------
 accel/tcg/cputlb.c               | 107 +++++++++++++++++++++++++++-
 3 files changed, 130 insertions(+), 161 deletions(-)
 delete mode 100644 include/exec/cpu_ldst_template.h

diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index cf4652bf48..62f38d5a22 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -94,32 +94,6 @@ typedef target_ulong abi_ptr;
 #define TARGET_ABI_FMT_ptr TARGET_ABI_FMT_lx
 #endif
 
-#if defined(CONFIG_USER_ONLY)
-
-extern __thread uintptr_t helper_retaddr;
-
-static inline void set_helper_retaddr(uintptr_t ra)
-{
-    helper_retaddr = ra;
-    /*
-     * Ensure that this write is visible to the SIGSEGV handler that
-     * may be invoked due to a subsequent invalid memory operation.
-     */
-    signal_barrier();
-}
-
-static inline void clear_helper_retaddr(void)
-{
-    /*
-     * Ensure that previous memory operations have succeeded before
-     * removing the data visible to the signal handler.
-     */
-    signal_barrier();
-    helper_retaddr = 0;
-}
-
-/* In user-only mode we provide only the _code and _data accessors. */
-
 uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr);
 uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr);
 uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr);
@@ -148,6 +122,30 @@ void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
 void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
                      uint64_t val, uintptr_t retaddr);
 
+#if defined(CONFIG_USER_ONLY)
+
+extern __thread uintptr_t helper_retaddr;
+
+static inline void set_helper_retaddr(uintptr_t ra)
+{
+    helper_retaddr = ra;
+    /*
+     * Ensure that this write is visible to the SIGSEGV handler that
+     * may be invoked due to a subsequent invalid memory operation.
+     */
+    signal_barrier();
+}
+
+static inline void clear_helper_retaddr(void)
+{
+    /*
+     * Ensure that previous memory operations have succeeded before
+     * removing the data visible to the signal handler.
+     */
+    signal_barrier();
+    helper_retaddr = 0;
+}
+
 /*
  * Provide the same *_mmuidx_ra interface as for softmmu.
  * The mmu_idx argument is ignored.
@@ -271,23 +269,6 @@ void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
 void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
                        int mmu_idx, uintptr_t retaddr);
 
-/* these access are slower, they must be as rare as possible */
-#define CPU_MMU_INDEX (cpu_mmu_index(env, false))
-#define MEMSUFFIX _data
-#define DATA_SIZE 1
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 2
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 4
-#include "exec/cpu_ldst_template.h"
-
-#define DATA_SIZE 8
-#include "exec/cpu_ldst_template.h"
-#undef CPU_MMU_INDEX
-#undef MEMSUFFIX
-
 #endif /* defined(CONFIG_USER_ONLY) */
 
 uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
deleted file mode 100644
index e400979f23..0000000000
--- a/include/exec/cpu_ldst_template.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- *  Software MMU support
- *
- * Generate inline load/store functions for one MMU mode and data
- * size.
- *
- * Generate a store function as well as signed and unsigned loads.
- *
- * Not used directly but included from cpu_ldst.h.
- *
- *  Copyright (c) 2003 Fabrice Bellard
- *
- * 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/>.
- */
-
-#if DATA_SIZE == 8
-#define SUFFIX q
-#define USUFFIX q
-#define DATA_TYPE uint64_t
-#define SHIFT 3
-#elif DATA_SIZE == 4
-#define SUFFIX l
-#define USUFFIX l
-#define DATA_TYPE uint32_t
-#define SHIFT 2
-#elif DATA_SIZE == 2
-#define SUFFIX w
-#define USUFFIX uw
-#define DATA_TYPE uint16_t
-#define DATA_STYPE int16_t
-#define SHIFT 1
-#elif DATA_SIZE == 1
-#define SUFFIX b
-#define USUFFIX ub
-#define DATA_TYPE uint8_t
-#define DATA_STYPE int8_t
-#define SHIFT 0
-#else
-#error unsupported data size
-#endif
-
-#if DATA_SIZE == 8
-#define RES_TYPE uint64_t
-#else
-#define RES_TYPE uint32_t
-#endif
-
-/* generic load/store macros */
-
-static inline RES_TYPE
-glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
-                                                  target_ulong ptr,
-                                                  uintptr_t retaddr)
-{
-    return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
-                                                   retaddr);
-}
-
-static inline RES_TYPE
-glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
-{
-    return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
-}
-
-#if DATA_SIZE <= 2
-static inline int
-glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
-                                                  target_ulong ptr,
-                                                  uintptr_t retaddr)
-{
-    return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
-                                                   retaddr);
-}
-
-static inline int
-glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
-{
-    return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
-}
-#endif
-
-/* generic store macro */
-
-static inline void
-glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
-                                                 target_ulong ptr,
-                                                 RES_TYPE v, uintptr_t retaddr)
-{
-    glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX,
-                                           retaddr);
-}
-
-static inline void
-glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
-                                      RES_TYPE v)
-{
-    glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
-}
-
-#undef RES_TYPE
-#undef DATA_TYPE
-#undef DATA_STYPE
-#undef SUFFIX
-#undef USUFFIX
-#undef DATA_SIZE
-#undef SHIFT
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index f0e4b0aee4..a991ea2964 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -35,7 +35,6 @@
 #include "qemu/atomic128.h"
 #include "translate-all.h"
 #include "trace-root.h"
-#include "qemu/plugin.h"
 #include "trace/mem.h"
 #ifdef CONFIG_PLUGIN
 #include "qemu/plugin-memory.h"
@@ -1697,6 +1696,68 @@ uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
                            ? helper_le_ldq_mmu : helper_be_ldq_mmu);
 }
 
+uint32_t cpu_ldub_data_ra(CPUArchState *env, target_ulong ptr,
+                          uintptr_t retaddr)
+{
+    return cpu_ldub_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
+}
+
+int cpu_ldsb_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
+{
+    return cpu_ldsb_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
+}
+
+uint32_t cpu_lduw_data_ra(CPUArchState *env, target_ulong ptr,
+                          uintptr_t retaddr)
+{
+    return cpu_lduw_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
+}
+
+int cpu_ldsw_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
+{
+    return cpu_ldsw_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
+}
+
+uint32_t cpu_ldl_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
+{
+    return cpu_ldl_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
+}
+
+uint64_t cpu_ldq_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
+{
+    return cpu_ldq_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
+}
+
+uint32_t cpu_ldub_data(CPUArchState *env, target_ulong ptr)
+{
+    return cpu_ldub_data_ra(env, ptr, 0);
+}
+
+int cpu_ldsb_data(CPUArchState *env, target_ulong ptr)
+{
+    return cpu_ldsb_data_ra(env, ptr, 0);
+}
+
+uint32_t cpu_lduw_data(CPUArchState *env, target_ulong ptr)
+{
+    return cpu_lduw_data_ra(env, ptr, 0);
+}
+
+int cpu_ldsw_data(CPUArchState *env, target_ulong ptr)
+{
+    return cpu_ldsw_data_ra(env, ptr, 0);
+}
+
+uint32_t cpu_ldl_data(CPUArchState *env, target_ulong ptr)
+{
+    return cpu_ldl_data_ra(env, ptr, 0);
+}
+
+uint64_t cpu_ldq_data(CPUArchState *env, target_ulong ptr)
+{
+    return cpu_ldq_data_ra(env, ptr, 0);
+}
+
 /*
  * Store Helpers
  */
@@ -1970,6 +2031,50 @@ void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
     cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEQ);
 }
 
+void cpu_stb_data_ra(CPUArchState *env, target_ulong ptr,
+                     uint32_t val, uintptr_t retaddr)
+{
+    cpu_stb_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
+}
+
+void cpu_stw_data_ra(CPUArchState *env, target_ulong ptr,
+                     uint32_t val, uintptr_t retaddr)
+{
+    cpu_stw_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
+}
+
+void cpu_stl_data_ra(CPUArchState *env, target_ulong ptr,
+                     uint32_t val, uintptr_t retaddr)
+{
+    cpu_stl_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
+}
+
+void cpu_stq_data_ra(CPUArchState *env, target_ulong ptr,
+                     uint64_t val, uintptr_t retaddr)
+{
+    cpu_stq_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
+}
+
+void cpu_stb_data(CPUArchState *env, target_ulong ptr, uint32_t val)
+{
+    cpu_stb_data_ra(env, ptr, val, 0);
+}
+
+void cpu_stw_data(CPUArchState *env, target_ulong ptr, uint32_t val)
+{
+    cpu_stw_data_ra(env, ptr, val, 0);
+}
+
+void cpu_stl_data(CPUArchState *env, target_ulong ptr, uint32_t val)
+{
+    cpu_stl_data_ra(env, ptr, val, 0);
+}
+
+void cpu_stq_data(CPUArchState *env, target_ulong ptr, uint64_t val)
+{
+    cpu_stq_data_ra(env, ptr, val, 0);
+}
+
 /* First set of helpers allows passing in of OI and RETADDR.  This makes
    them callable from other helpers.  */
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 01/28] target/xtensa: Use probe_access for itlb_hit_test
  2019-12-16 22:11 ` [PATCH v2 01/28] target/xtensa: Use probe_access for itlb_hit_test Richard Henderson
@ 2019-12-17  3:51   ` Philippe Mathieu-Daudé
  2019-12-20 14:15   ` Alex Bennée
  1 sibling, 0 replies; 66+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-12-17  3:51 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: Max Filippov

On 12/16/19 11:11 PM, Richard Henderson wrote:
> We don't actually need the result of the read, only to probe that the
> memory mapping exists.  This is exactly what probe_access does.
> 
> This is also the only user of any cpu_ld*_code_ra function.
> Removing this allows the interface to be removed shortly.
> 
> Acked-by: Max Filippov <jcmvbkbc@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/xtensa/mmu_helper.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c
> index f15bff306f..b01ff9399a 100644
> --- a/target/xtensa/mmu_helper.c
> +++ b/target/xtensa/mmu_helper.c
> @@ -63,10 +63,11 @@
>   void HELPER(itlb_hit_test)(CPUXtensaState *env, uint32_t vaddr)
>   {
>       /*
> -     * Attempt the memory load; we don't care about the result but
> +     * Probe the memory; we don't care about the result but
>        * only the side-effects (ie any MMU or other exception)
>        */
> -    cpu_ldub_code_ra(env, vaddr, GETPC());
> +    probe_access(env, vaddr, 1, MMU_INST_FETCH,
> +                 cpu_mmu_index(env, true), GETPC());

TIL probe_access

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>   }
>   
>   void HELPER(wsr_rasid)(CPUXtensaState *env, uint32_t v)
> 



^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 02/28] cputlb: Use trace_mem_get_info instead of trace_mem_build_info
  2019-12-16 22:11 ` [PATCH v2 02/28] cputlb: Use trace_mem_get_info instead of trace_mem_build_info Richard Henderson
@ 2019-12-17  3:59   ` Philippe Mathieu-Daudé
  2019-12-20 15:04   ` Alex Bennée
  1 sibling, 0 replies; 66+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-12-17  3:59 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

On 12/16/19 11:11 PM, Richard Henderson wrote:
> In the cpu_ldst templates, we already require a MemOp, and it
> is cleaner and clearer to pass that instead of 3 separate
> arguments describing the memory operation.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   include/exec/cpu_ldst_template.h          | 22 +++++++++++-----------
>   include/exec/cpu_ldst_useronly_template.h | 12 ++++++------
>   2 files changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
> index 54b5e858ce..0ad5de3ef9 100644
> --- a/include/exec/cpu_ldst_template.h
> +++ b/include/exec/cpu_ldst_template.h
> @@ -86,9 +86,9 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>       RES_TYPE res;
>       target_ulong addr;
>       int mmu_idx = CPU_MMU_INDEX;
> -    TCGMemOpIdx oi;
> +    MemOp op = MO_TE | SHIFT;
>   #if !defined(SOFTMMU_CODE_ACCESS)
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false, mmu_idx);
> +    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
>       trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>   #endif
>   
> @@ -96,9 +96,9 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>       entry = tlb_entry(env, mmu_idx, addr);
>       if (unlikely(entry->ADDR_READ !=
>                    (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
> -        oi = make_memop_idx(SHIFT, mmu_idx);
> +        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
>           res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr,
> -                                                            oi, retaddr);
> +                                                               oi, retaddr);
>       } else {
>           uintptr_t hostaddr = addr + entry->addend;
>           res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr);
> @@ -125,9 +125,9 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>       int res;
>       target_ulong addr;
>       int mmu_idx = CPU_MMU_INDEX;
> -    TCGMemOpIdx oi;
> -#if !defined(SOFTMMU_CODE_ACCESS)
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false, mmu_idx);
> +    MemOp op = MO_TE | MO_SIGN | SHIFT;

Good, the sign-extend is easier to review this way (than 'true').

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> +#ifndef SOFTMMU_CODE_ACCESS
> +    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
>       trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>   #endif
>   
> @@ -135,7 +135,7 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>       entry = tlb_entry(env, mmu_idx, addr);
>       if (unlikely(entry->ADDR_READ !=
>                    (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
> -        oi = make_memop_idx(SHIFT, mmu_idx);
> +        TCGMemOpIdx oi = make_memop_idx(op & ~MO_SIGN, mmu_idx);
>           res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX),
>                                  MMUSUFFIX)(env, addr, oi, retaddr);
>       } else {
> @@ -167,9 +167,9 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>       CPUTLBEntry *entry;
>       target_ulong addr;
>       int mmu_idx = CPU_MMU_INDEX;
> -    TCGMemOpIdx oi;
> +    MemOp op = MO_TE | SHIFT;
>   #if !defined(SOFTMMU_CODE_ACCESS)
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true, mmu_idx);
> +    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, true);
>       trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>   #endif
>   
> @@ -177,7 +177,7 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>       entry = tlb_entry(env, mmu_idx, addr);
>       if (unlikely(tlb_addr_write(entry) !=
>                    (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
> -        oi = make_memop_idx(SHIFT, mmu_idx);
> +        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
>           glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi,
>                                                        retaddr);
>       } else {
> diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h
> index dbdc7a845d..e5a3d1983a 100644
> --- a/include/exec/cpu_ldst_useronly_template.h
> +++ b/include/exec/cpu_ldst_useronly_template.h
> @@ -70,8 +70,8 @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
>       ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
>       clear_helper_retaddr();
>   #else
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false,
> -                                            MMU_USER_IDX);
> +    MemOp op = MO_TE | SHIFT;
> +    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
>       trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>       ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
>   #endif
> @@ -102,8 +102,8 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
>       ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
>       clear_helper_retaddr();
>   #else
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false,
> -                                            MMU_USER_IDX);
> +    MemOp op = MO_TE | MO_SIGN | SHIFT;
> +    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
>       trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>       ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
>       qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> @@ -131,8 +131,8 @@ static inline void
>   glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
>                                         RES_TYPE v)
>   {
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true,
> -                                            MMU_USER_IDX);
> +    MemOp op = MO_TE | SHIFT;
> +    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, true);
>       trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>       glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
>       qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> 



^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 01/28] target/xtensa: Use probe_access for itlb_hit_test
  2019-12-16 22:11 ` [PATCH v2 01/28] target/xtensa: Use probe_access for itlb_hit_test Richard Henderson
  2019-12-17  3:51   ` Philippe Mathieu-Daudé
@ 2019-12-20 14:15   ` Alex Bennée
  1 sibling, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov


Richard Henderson <richard.henderson@linaro.org> writes:

> We don't actually need the result of the read, only to probe that the
> memory mapping exists.  This is exactly what probe_access does.
>
> This is also the only user of any cpu_ld*_code_ra function.
> Removing this allows the interface to be removed shortly.
>
> Acked-by: Max Filippov <jcmvbkbc@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/xtensa/mmu_helper.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c
> index f15bff306f..b01ff9399a 100644
> --- a/target/xtensa/mmu_helper.c
> +++ b/target/xtensa/mmu_helper.c
> @@ -63,10 +63,11 @@
>  void HELPER(itlb_hit_test)(CPUXtensaState *env, uint32_t vaddr)
>  {
>      /*
> -     * Attempt the memory load; we don't care about the result but
> +     * Probe the memory; we don't care about the result but
>       * only the side-effects (ie any MMU or other exception)
>       */
> -    cpu_ldub_code_ra(env, vaddr, GETPC());
> +    probe_access(env, vaddr, 1, MMU_INST_FETCH,
> +                 cpu_mmu_index(env, true), GETPC());
>  }
>  
>  void HELPER(wsr_rasid)(CPUXtensaState *env, uint32_t v)


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 02/28] cputlb: Use trace_mem_get_info instead of trace_mem_build_info
  2019-12-16 22:11 ` [PATCH v2 02/28] cputlb: Use trace_mem_get_info instead of trace_mem_build_info Richard Henderson
  2019-12-17  3:59   ` Philippe Mathieu-Daudé
@ 2019-12-20 15:04   ` Alex Bennée
  1 sibling, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 15:04 UTC (permalink / raw)
  To: qemu-devel


Richard Henderson <richard.henderson@linaro.org> writes:

> In the cpu_ldst templates, we already require a MemOp, and it
> is cleaner and clearer to pass that instead of 3 separate
> arguments describing the memory operation.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  include/exec/cpu_ldst_template.h          | 22 +++++++++++-----------
>  include/exec/cpu_ldst_useronly_template.h | 12 ++++++------
>  2 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
> index 54b5e858ce..0ad5de3ef9 100644
> --- a/include/exec/cpu_ldst_template.h
> +++ b/include/exec/cpu_ldst_template.h
> @@ -86,9 +86,9 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>      RES_TYPE res;
>      target_ulong addr;
>      int mmu_idx = CPU_MMU_INDEX;
> -    TCGMemOpIdx oi;
> +    MemOp op = MO_TE | SHIFT;
>  #if !defined(SOFTMMU_CODE_ACCESS)
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false, mmu_idx);
> +    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
>      trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>  #endif
>  
> @@ -96,9 +96,9 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>      entry = tlb_entry(env, mmu_idx, addr);
>      if (unlikely(entry->ADDR_READ !=
>                   (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
> -        oi = make_memop_idx(SHIFT, mmu_idx);
> +        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
>          res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr,
> -                                                            oi, retaddr);
> +                                                               oi, retaddr);
>      } else {
>          uintptr_t hostaddr = addr + entry->addend;
>          res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr);
> @@ -125,9 +125,9 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>      int res;
>      target_ulong addr;
>      int mmu_idx = CPU_MMU_INDEX;
> -    TCGMemOpIdx oi;
> -#if !defined(SOFTMMU_CODE_ACCESS)
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false, mmu_idx);
> +    MemOp op = MO_TE | MO_SIGN | SHIFT;
> +#ifndef SOFTMMU_CODE_ACCESS
> +    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
>      trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>  #endif
>  
> @@ -135,7 +135,7 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>      entry = tlb_entry(env, mmu_idx, addr);
>      if (unlikely(entry->ADDR_READ !=
>                   (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
> -        oi = make_memop_idx(SHIFT, mmu_idx);
> +        TCGMemOpIdx oi = make_memop_idx(op & ~MO_SIGN, mmu_idx);
>          res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX),
>                                 MMUSUFFIX)(env, addr, oi, retaddr);
>      } else {
> @@ -167,9 +167,9 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>      CPUTLBEntry *entry;
>      target_ulong addr;
>      int mmu_idx = CPU_MMU_INDEX;
> -    TCGMemOpIdx oi;
> +    MemOp op = MO_TE | SHIFT;
>  #if !defined(SOFTMMU_CODE_ACCESS)
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true, mmu_idx);
> +    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, true);
>      trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>  #endif
>  
> @@ -177,7 +177,7 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>      entry = tlb_entry(env, mmu_idx, addr);
>      if (unlikely(tlb_addr_write(entry) !=
>                   (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
> -        oi = make_memop_idx(SHIFT, mmu_idx);
> +        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
>          glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi,
>                                                       retaddr);
>      } else {
> diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h
> index dbdc7a845d..e5a3d1983a 100644
> --- a/include/exec/cpu_ldst_useronly_template.h
> +++ b/include/exec/cpu_ldst_useronly_template.h
> @@ -70,8 +70,8 @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
>      ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
>      clear_helper_retaddr();
>  #else
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false,
> -                                            MMU_USER_IDX);
> +    MemOp op = MO_TE | SHIFT;
> +    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
>      trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>      ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
>  #endif
> @@ -102,8 +102,8 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
>      ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
>      clear_helper_retaddr();
>  #else
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false,
> -                                            MMU_USER_IDX);
> +    MemOp op = MO_TE | MO_SIGN | SHIFT;
> +    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
>      trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>      ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
>      qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> @@ -131,8 +131,8 @@ static inline void
>  glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
>                                        RES_TYPE v)
>  {
> -    uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true,
> -                                            MMU_USER_IDX);
> +    MemOp op = MO_TE | SHIFT;
> +    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, true);
>      trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>      glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
>      qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 03/28] trace: Remove trace_mem_build_info_no_se_[bl]e
  2019-12-16 22:11 ` [PATCH v2 03/28] trace: Remove trace_mem_build_info_no_se_[bl]e Richard Henderson
@ 2019-12-20 16:38   ` Alex Bennée
  2019-12-28 20:48     ` Richard Henderson
  0 siblings, 1 reply; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 16:38 UTC (permalink / raw)
  To: qemu-devel


Richard Henderson <richard.henderson@linaro.org> writes:

> It is easy for the atomic helpers to use trace_mem_build_info
> directly, without resorting to symbol pasting.  For this usage,
> we cannot use trace_mem_get_info, because the MemOp does not
> support 16-byte accesses.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  accel/tcg/atomic_template.h | 67 +++++++++++++------------------------
>  trace/mem-internal.h        | 17 ----------
>  2 files changed, 24 insertions(+), 60 deletions(-)
>
> diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h
> index 837676231f..26969487d6 100644
> --- a/accel/tcg/atomic_template.h
> +++ b/accel/tcg/atomic_template.h
> @@ -64,13 +64,10 @@
>     the ATOMIC_NAME macro, and redefined below.  */
>  #if DATA_SIZE == 1
>  # define END
> -# define MEND _be /* either le or be would be fine */
>  #elif defined(HOST_WORDS_BIGENDIAN)
>  # define END  _be
> -# define MEND _be
>  #else
>  # define END  _le
> -# define MEND _le
>  #endif
>  
>  ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
> @@ -79,8 +76,8 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
>      ATOMIC_MMU_DECLS;
>      DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
>      DATA_TYPE ret;
> -    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
> -                                                           ATOMIC_MMU_IDX);
> +    uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,

What is MEND meant to be? Shouldn't we use the appropriate MO_TE instead
of 0 for these helpers?

> +                                         ATOMIC_MMU_IDX);
>  
>      atomic_trace_rmw_pre(env, addr, info);
>  #if DATA_SIZE == 16
> @@ -99,8 +96,8 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS)
>  {
>      ATOMIC_MMU_DECLS;
>      DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP;
> -    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
> -                                                           ATOMIC_MMU_IDX);
> +    uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
> +                                         ATOMIC_MMU_IDX);
>  
>      atomic_trace_ld_pre(env, addr, info);
>      val = atomic16_read(haddr);
> @@ -114,8 +111,8 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr,
>  {
>      ATOMIC_MMU_DECLS;
>      DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
> -    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, true,
> -                                                          ATOMIC_MMU_IDX);
> +    uint16_t info = trace_mem_build_info(SHIFT, false, 0, true,
> +                                         ATOMIC_MMU_IDX);
>  
>      atomic_trace_st_pre(env, addr, info);
>      atomic16_set(haddr, val);
> @@ -130,8 +127,8 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr,
>      ATOMIC_MMU_DECLS;
>      DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
>      DATA_TYPE ret;
> -    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
> -                                                          ATOMIC_MMU_IDX);
> +    uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
> +                                         ATOMIC_MMU_IDX);
>  
>      atomic_trace_rmw_pre(env, addr, info);
>      ret = atomic_xchg__nocheck(haddr, val);
> @@ -147,10 +144,8 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,       \
>      ATOMIC_MMU_DECLS;                                               \
>      DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;                           \
>      DATA_TYPE ret;                                                  \
> -    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,   \
> -                                                           false,   \
> -                                                           ATOMIC_MMU_IDX); \
> -                                                                    \
> +    uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,    \
> +                                         ATOMIC_MMU_IDX);           \
>      atomic_trace_rmw_pre(env, addr, info);                          \
>      ret = atomic_##X(haddr, val);                                   \
>      ATOMIC_MMU_CLEANUP;                                             \
> @@ -183,10 +178,8 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,       \
>      ATOMIC_MMU_DECLS;                                               \
>      XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;                          \
>      XDATA_TYPE cmp, old, new, val = xval;                           \
> -    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,   \
> -                                                           false,   \
> -                                                           ATOMIC_MMU_IDX); \
> -                                                                    \
> +    uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,    \
> +                                         ATOMIC_MMU_IDX);           \
>      atomic_trace_rmw_pre(env, addr, info);                          \
>      smp_mb();                                                       \
>      cmp = atomic_read__nocheck(haddr);                              \
> @@ -213,7 +206,6 @@ GEN_ATOMIC_HELPER_FN(umax_fetch, MAX,  DATA_TYPE, new)
>  #endif /* DATA SIZE >= 16 */
>  
>  #undef END
> -#undef MEND
>  
>  #if DATA_SIZE > 1
>  
> @@ -221,10 +213,8 @@ GEN_ATOMIC_HELPER_FN(umax_fetch, MAX,  DATA_TYPE, new)
>     within the ATOMIC_NAME macro.  */
>  #ifdef HOST_WORDS_BIGENDIAN
>  # define END  _le
> -# define MEND _le
>  #else
>  # define END  _be
> -# define MEND _be
>  #endif
>  
>  ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
> @@ -233,9 +223,8 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
>      ATOMIC_MMU_DECLS;
>      DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
>      DATA_TYPE ret;
> -    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
> -                                                           false,
> -                                                           ATOMIC_MMU_IDX);
> +    uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, false,
> +                                         ATOMIC_MMU_IDX);

These are fine with MO_BSWAP. So otherwise:

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 04/28] cputlb: Move body of cpu_ldst_template.h out of line
  2019-12-16 22:11 ` [PATCH v2 04/28] cputlb: Move body of cpu_ldst_template.h out of line Richard Henderson
@ 2019-12-20 17:07   ` Alex Bennée
  2019-12-20 18:33     ` Alex Bennée
  2019-12-20 18:36   ` Alex Bennée
  1 sibling, 1 reply; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 17:07 UTC (permalink / raw)
  To: qemu-devel


Richard Henderson <richard.henderson@linaro.org> writes:

> With the tracing hooks, the inline functions are no longer
> so simple.  Once out-of-line, the current tlb_entry lookup
> is redundant with the one in the main load/store_helper.
>
> This also begins the introduction of a new target facing
> interface, with suffix *_mmuidx_ra.  This is not yet
> official because the interface is not done for user-only.
>
> Use abi_ptr instead of target_ulong in preparation for
> user-only; the two types are identical for softmmu.
>
> What remains in cpu_ldst_template.h are the expansions
> for _code, _data, and MMU_MODE<N>_SUFFIX.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  include/exec/cpu_ldst.h          |  25 ++++++-
>  include/exec/cpu_ldst_template.h | 125 +++++++------------------------
>  accel/tcg/cputlb.c               | 116 ++++++++++++++++++++++++++++
>  3 files changed, 166 insertions(+), 100 deletions(-)
>
> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
> index fd499f7e2f..cf8af36dbc 100644
> --- a/include/exec/cpu_ldst.h
> +++ b/include/exec/cpu_ldst.h
> @@ -152,7 +152,7 @@ static inline void clear_helper_retaddr(void)
>  
>  #else
>  
> -/* The memory helpers for tcg-generated code need tcg_target_long etc.  */
> +/* Needed for TCG_OVERSIZED_GUEST */
>  #include "tcg.h"
>  
>  static inline target_ulong tlb_addr_write(const CPUTLBEntry *entry)
> @@ -185,6 +185,29 @@ static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx,
>      return &env_tlb(env)->f[mmu_idx].table[tlb_index(env, mmu_idx, addr)];
>  }
>  
> +uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                            int mmu_idx, uintptr_t ra);
> +uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                            int mmu_idx, uintptr_t ra);
> +uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                           int mmu_idx, uintptr_t ra);
> +uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                           int mmu_idx, uintptr_t ra);
> +
> +int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                       int mmu_idx, uintptr_t ra);
> +int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                       int mmu_idx, uintptr_t ra);
> +
> +void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
> +                       int mmu_idx, uintptr_t retaddr);
> +void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
> +                       int mmu_idx, uintptr_t retaddr);
> +void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
> +                       int mmu_idx, uintptr_t retaddr);
> +void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
> +                       int mmu_idx, uintptr_t retaddr);
> +
>  #ifdef MMU_MODE0_SUFFIX
>  #define CPU_MMU_INDEX 0
>  #define MEMSUFFIX MMU_MODE0_SUFFIX
> diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
> index 0ad5de3ef9..ea39e29c19 100644
> --- a/include/exec/cpu_ldst_template.h
> +++ b/include/exec/cpu_ldst_template.h
> @@ -24,13 +24,6 @@
>   * License along with this library; if not, see <http://www.gnu.org/licenses/>.
>   */
>  
> -#if !defined(SOFTMMU_CODE_ACCESS)
> -#include "trace-root.h"
> -#endif
> -
> -#include "qemu/plugin.h"
> -#include "trace/mem.h"
> -
>  #if DATA_SIZE == 8
>  #define SUFFIX q
>  #define USUFFIX q
> @@ -63,56 +56,40 @@
>  #define RES_TYPE uint32_t
>  #endif
>  
> +/* generic load/store macros */
> +
>  #ifdef SOFTMMU_CODE_ACCESS
> -#define ADDR_READ addr_code
> -#define MMUSUFFIX _cmmu
> -#define URETSUFFIX USUFFIX
> -#define SRETSUFFIX glue(s, SUFFIX)
> -#else
> -#define ADDR_READ addr_read
> -#define MMUSUFFIX _mmu
> -#define URETSUFFIX USUFFIX
> -#define SRETSUFFIX glue(s, SUFFIX)
> +
> +static inline RES_TYPE
> +glue(glue(cpu_ld, USUFFIX), _code)(CPUArchState *env, target_ulong ptr)
> +{
> +    TCGMemOpIdx oi = make_memop_idx(MO_TE | SHIFT, CPU_MMU_INDEX);
> +    return glue(glue(helper_ret_ld, USUFFIX), _cmmu)(env, ptr, oi, 0);
> +}
> +
> +#if DATA_SIZE <= 2
> +static inline int
> +glue(glue(cpu_lds, SUFFIX), _code)(CPUArchState *env, target_ulong ptr)
> +{
> +    return (DATA_STYPE)glue(glue(cpu_ld, USUFFIX), _code)(env, ptr);
> +}
>  #endif
>  
> -/* generic load/store macros */
> +#else
>  
>  static inline RES_TYPE
>  glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>                                                    target_ulong ptr,
>                                                    uintptr_t retaddr)
>  {
> -    CPUTLBEntry *entry;
> -    RES_TYPE res;
> -    target_ulong addr;
> -    int mmu_idx = CPU_MMU_INDEX;
> -    MemOp op = MO_TE | SHIFT;
> -#if !defined(SOFTMMU_CODE_ACCESS)
> -    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
> -    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> -#endif
> -
> -    addr = ptr;
> -    entry = tlb_entry(env, mmu_idx, addr);
> -    if (unlikely(entry->ADDR_READ !=
> -                 (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
> -        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
> -        res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr,
> -                                                               oi, retaddr);
> -    } else {
> -        uintptr_t hostaddr = addr + entry->addend;
> -        res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr);
> -    }
> -#ifndef SOFTMMU_CODE_ACCESS
> -    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> -#endif
> -    return res;
> +    return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
> +                                                   retaddr);
>  }
>  
>  static inline RES_TYPE
>  glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
>  {
> -    return glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(env, ptr, 0);
> +    return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
>  }
>  
>  #if DATA_SIZE <= 2
> @@ -121,42 +98,17 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>                                                    target_ulong ptr,
>                                                    uintptr_t retaddr)
>  {
> -    CPUTLBEntry *entry;
> -    int res;
> -    target_ulong addr;
> -    int mmu_idx = CPU_MMU_INDEX;
> -    MemOp op = MO_TE | MO_SIGN | SHIFT;
> -#ifndef SOFTMMU_CODE_ACCESS
> -    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
> -    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> -#endif
> -
> -    addr = ptr;
> -    entry = tlb_entry(env, mmu_idx, addr);
> -    if (unlikely(entry->ADDR_READ !=
> -                 (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
> -        TCGMemOpIdx oi = make_memop_idx(op & ~MO_SIGN, mmu_idx);
> -        res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX),
> -                               MMUSUFFIX)(env, addr, oi, retaddr);
> -    } else {
> -        uintptr_t hostaddr = addr + entry->addend;
> -        res = glue(glue(lds, SUFFIX), _p)((uint8_t *)hostaddr);
> -    }
> -#ifndef SOFTMMU_CODE_ACCESS
> -    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> -#endif
> -    return res;
> +    return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
> +                                                   retaddr);
>  }
>  
>  static inline int
>  glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
>  {
> -    return glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(env, ptr, 0);
> +    return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
>  }
>  #endif
>  
> -#ifndef SOFTMMU_CODE_ACCESS
> -
>  /* generic store macro */
>  
>  static inline void
> @@ -164,36 +116,15 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>                                                   target_ulong ptr,
>                                                   RES_TYPE v, uintptr_t retaddr)
>  {
> -    CPUTLBEntry *entry;
> -    target_ulong addr;
> -    int mmu_idx = CPU_MMU_INDEX;
> -    MemOp op = MO_TE | SHIFT;
> -#if !defined(SOFTMMU_CODE_ACCESS)
> -    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, true);
> -    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> -#endif
> -
> -    addr = ptr;
> -    entry = tlb_entry(env, mmu_idx, addr);
> -    if (unlikely(tlb_addr_write(entry) !=
> -                 (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
> -        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
> -        glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi,
> -                                                     retaddr);
> -    } else {
> -        uintptr_t hostaddr = addr + entry->addend;
> -        glue(glue(st, SUFFIX), _p)((uint8_t *)hostaddr, v);
> -    }
> -#ifndef SOFTMMU_CODE_ACCESS
> -    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> -#endif
> +    glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX,
> +                                           retaddr);
>  }
>  
>  static inline void
>  glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
>                                        RES_TYPE v)
>  {
> -    glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(env, ptr, v, 0);
> +    glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
>  }
>  
>  #endif /* !SOFTMMU_CODE_ACCESS */
> @@ -204,8 +135,4 @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
>  #undef SUFFIX
>  #undef USUFFIX
>  #undef DATA_SIZE
> -#undef MMUSUFFIX
> -#undef ADDR_READ
> -#undef URETSUFFIX
> -#undef SRETSUFFIX
>  #undef SHIFT
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index 98221948d6..ddd19718bf 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -34,6 +34,9 @@
>  #include "qemu/atomic.h"
>  #include "qemu/atomic128.h"
>  #include "translate-all.h"
> +#include "trace-root.h"
> +#include "qemu/plugin.h"
> +#include "trace/mem.h"
>  #ifdef CONFIG_PLUGIN
>  #include "qemu/plugin-memory.h"
>  #endif
> @@ -1625,6 +1628,75 @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env, target_ulong addr,
>      return (int32_t)helper_be_ldul_mmu(env, addr, oi, retaddr);
>  }
>  
> +/*
> + * Load helpers for cpu_ldst.h.
> + */
> +
> +static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr,
> +                                       int mmu_idx, uintptr_t retaddr,
> +                                       MemOp op, FullLoadHelper *full_load)
> +{
> +    uint16_t meminfo;
> +    TCGMemOpIdx oi;
> +    uint64_t ret;
> +
> +    meminfo = trace_mem_get_info(op, mmu_idx, false);
> +    trace_guest_mem_before_exec(env_cpu(env), addr, meminfo);
> +
> +    op &= ~MO_SIGN;
> +    oi = make_memop_idx(op, mmu_idx);
> +    ret = full_load(env, addr, oi, retaddr);
> +
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, meminfo);
> +
> +    return ret;
> +}
> +
> +uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                            int mmu_idx, uintptr_t ra)
> +{
> +    return cpu_load_helper(env, addr, mmu_idx, ra, MO_UB, full_ldub_mmu);
> +}
> +
> +int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                       int mmu_idx, uintptr_t ra)
> +{
> +    return (int8_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_SB,
> +                                   full_ldub_mmu);
> +}
> +
> +uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                            int mmu_idx, uintptr_t ra)
> +{
> +    return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUW,
> +                           MO_TE == MO_LE
> +                           ? full_le_lduw_mmu : full_be_lduw_mmu);
> +}
> +
> +int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                       int mmu_idx, uintptr_t ra)
> +{
> +    return (int16_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_TESW,
> +                                    MO_TE == MO_LE
> +                                    ? full_le_lduw_mmu : full_be_lduw_mmu);
> +}
> +
> +uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                           int mmu_idx, uintptr_t ra)
> +{
> +    return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUL,
> +                           MO_TE == MO_LE
> +                           ? full_le_ldul_mmu : full_be_ldul_mmu);
> +}
> +
> +uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                           int mmu_idx, uintptr_t ra)
> +{
> +    return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEQ,
> +                           MO_TE == MO_LE
> +                           ? helper_le_ldq_mmu : helper_be_ldq_mmu);
> +}
> +
>  /*
>   * Store Helpers
>   */
> @@ -1854,6 +1926,50 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,
>      store_helper(env, addr, val, oi, retaddr, MO_BEQ);
>  }
>  
> +/*
> + * Store Helpers for cpu_ldst.h
> + */
> +
> +static inline void QEMU_ALWAYS_INLINE
> +cpu_store_helper(CPUArchState *env, target_ulong addr, uint64_t val,
> +                 int mmu_idx, uintptr_t retaddr, MemOp op)
> +{
> +    TCGMemOpIdx oi;
> +    uint16_t meminfo;
> +
> +    meminfo = trace_mem_get_info(op, mmu_idx, true);
> +    trace_guest_mem_before_exec(env_cpu(env), addr, meminfo);
> +
> +    oi = make_memop_idx(op, mmu_idx);
> +    store_helper(env, addr, val, oi, retaddr, op);
> +
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, meminfo);
> +}
> +
> +void cpu_stb_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
> +                       int mmu_idx, uintptr_t retaddr)
> +{
> +    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_UB);
> +}
> +
> +void cpu_stw_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
> +                       int mmu_idx, uintptr_t retaddr)
> +{
> +    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUW);
> +}
> +
> +void cpu_stl_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
> +                       int mmu_idx, uintptr_t retaddr)
> +{
> +    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUL);
> +}
> +
> +void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
> +                       int mmu_idx, uintptr_t retaddr)
> +{
> +    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEQ);
> +}
> +
>  /* First set of helpers allows passing in of OI and RETADDR.  This makes
>     them callable from other helpers.  */


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 05/28] translator: Use cpu_ld*_code instead of open-coding
  2019-12-16 22:11 ` [PATCH v2 05/28] translator: Use cpu_ld*_code instead of open-coding Richard Henderson
@ 2019-12-20 17:12   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 17:12 UTC (permalink / raw)
  To: qemu-devel


Richard Henderson <richard.henderson@linaro.org> writes:

> The DO_LOAD macros replicate the distinction already performed
> by the cpu_ldst.h functions.  Use them.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  include/exec/cpu_ldst.h   | 11 ---------
>  include/exec/translator.h | 48 +++++++++++----------------------------
>  2 files changed, 13 insertions(+), 46 deletions(-)
>
> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
> index cf8af36dbc..399ff6c3da 100644
> --- a/include/exec/cpu_ldst.h
> +++ b/include/exec/cpu_ldst.h
> @@ -129,11 +129,6 @@ static inline void clear_helper_retaddr(void)
>  #include "exec/cpu_ldst_useronly_template.h"
>  #undef MEMSUFFIX
>  
> -/*
> - * Code access is deprecated in favour of translator_ld* functions
> - * (see translator.h). However there are still users that need to
> - * converted so for now these stay.
> - */
>  #define MEMSUFFIX _code
>  #define CODE_ACCESS
>  #define DATA_SIZE 1
> @@ -455,12 +450,6 @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
>  #undef CPU_MMU_INDEX
>  #undef MEMSUFFIX
>  
> -/*
> - * Code access is deprecated in favour of translator_ld* functions
> - * (see translator.h). However there are still users that need to
> - * converted so for now these stay.
> - */
> -
>  #define CPU_MMU_INDEX (cpu_mmu_index(env, true))
>  #define MEMSUFFIX _code
>  #define SOFTMMU_CODE_ACCESS
> diff --git a/include/exec/translator.h b/include/exec/translator.h
> index 459dd72aab..638e1529c5 100644
> --- a/include/exec/translator.h
> +++ b/include/exec/translator.h
> @@ -148,41 +148,19 @@ void translator_loop_temp_check(DisasContextBase *db);
>  /*
>   * Translator Load Functions
>   *
> - * These are intended to replace the old cpu_ld*_code functions and
> - * are mandatory for front-ends that have been migrated to the common
> - * translator_loop. These functions are only intended to be called
> - * from the translation stage and should not be called from helper
> - * functions. Those functions should be converted to encode the
> - * relevant information at translation time.
> + * These are intended to replace the direct usage of the cpu_ld*_code
> + * functions and are mandatory for front-ends that have been migrated
> + * to the common translator_loop. These functions are only intended
> + * to be called from the translation stage and should not be called
> + * from helper functions. Those functions should be converted to encode
> + * the relevant information at translation time.
>   */
>  
> -#ifdef CONFIG_USER_ONLY
> -
> -#define DO_LOAD(type, name, shift)               \
> -    do {                                         \
> -        set_helper_retaddr(1);                   \
> -        ret = name ## _p(g2h(pc));               \
> -        clear_helper_retaddr();                  \
> -    } while (0)
> -
> -#else
> -
> -#define DO_LOAD(type, name, shift)                          \
> -    do {                                                    \
> -        int mmu_idx = cpu_mmu_index(env, true);             \
> -        TCGMemOpIdx oi = make_memop_idx(shift, mmu_idx);    \
> -        ret = helper_ret_ ## name ## _cmmu(env, pc, oi, 0); \
> -    } while (0)
> -
> -#endif
> -
> -#define GEN_TRANSLATOR_LD(fullname, name, type, shift, swap_fn)         \
> +#define GEN_TRANSLATOR_LD(fullname, type, load_fn, swap_fn)             \
>      static inline type                                                  \
>      fullname ## _swap(CPUArchState *env, abi_ptr pc, bool do_swap)      \
>      {                                                                   \
> -        type ret;                                                       \
> -        DO_LOAD(type, name, shift);                                     \
> -                                                                        \
> +        type ret = load_fn(env, pc);                                    \
>          if (do_swap) {                                                  \
>              ret = swap_fn(ret);                                         \
>          }                                                               \
> @@ -195,11 +173,11 @@ void translator_loop_temp_check(DisasContextBase *db);
>          return fullname ## _swap(env, pc, false);                       \
>      }
>  
> -GEN_TRANSLATOR_LD(translator_ldub, ldub, uint8_t, 0, /* no swap */ )
> -GEN_TRANSLATOR_LD(translator_ldsw, ldsw, int16_t, 1, bswap16)
> -GEN_TRANSLATOR_LD(translator_lduw, lduw, uint16_t, 1, bswap16)
> -GEN_TRANSLATOR_LD(translator_ldl, ldl, uint32_t, 2, bswap32)
> -GEN_TRANSLATOR_LD(translator_ldq, ldq, uint64_t, 3, bswap64)
> +GEN_TRANSLATOR_LD(translator_ldub, uint8_t, cpu_ldub_code, /* no swap */)
> +GEN_TRANSLATOR_LD(translator_ldsw, int16_t, cpu_ldsw_code, bswap16)
> +GEN_TRANSLATOR_LD(translator_lduw, uint16_t, cpu_lduw_code, bswap16)
> +GEN_TRANSLATOR_LD(translator_ldl, uint32_t, cpu_ldl_code, bswap32)
> +GEN_TRANSLATOR_LD(translator_ldq, uint64_t, cpu_ldq_code, bswap64)
>  #undef GEN_TRANSLATOR_LD
>  
>  #endif  /* EXEC__TRANSLATOR_H */


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 06/28] cputlb: Rename helper_ret_ld*_cmmu to cpu_ld*_code
  2019-12-16 22:11 ` [PATCH v2 06/28] cputlb: Rename helper_ret_ld*_cmmu to cpu_ld*_code Richard Henderson
@ 2019-12-20 17:25   ` Alex Bennée
  2019-12-28 20:58     ` Richard Henderson
  0 siblings, 1 reply; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 17:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aleksandar Markovic


Richard Henderson <richard.henderson@linaro.org> writes:

> There are no uses of the *_cmmu names other than the bare wrapping
> within the *_code inlines.  Therefore rename the functions so we
> can drop the inlines.
>
> Use abi_ptr instead of target_ulong in preparation for user-only;
> the two types are identical for softmmu.
>
> Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  include/exec/cpu_ldst.h          | 29 ++++------
>  include/exec/cpu_ldst_template.h | 21 -------
>  tcg/tcg.h                        | 29 ----------
>  accel/tcg/cputlb.c               | 94 ++++++++------------------------
>  docs/devel/loads-stores.rst      |  4 +-
>  5 files changed, 36 insertions(+), 141 deletions(-)
>
> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
> index 399ff6c3da..ef59ed61e4 100644
> --- a/include/exec/cpu_ldst.h
> +++ b/include/exec/cpu_ldst.h
> @@ -450,25 +450,20 @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
>  #undef CPU_MMU_INDEX
>  #undef MEMSUFFIX
>
> -#define CPU_MMU_INDEX (cpu_mmu_index(env, true))
> -#define MEMSUFFIX _code
> -#define SOFTMMU_CODE_ACCESS
> +uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
> +uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr);
> +uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr);
> +uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr);
>
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> +static inline int cpu_ldsb_code(CPUArchState *env, abi_ptr addr)
> +{
> +    return (int8_t)cpu_ldub_code(env, addr);
> +}
<snip>
> --- a/tcg/tcg.h
> +++ b/tcg/tcg.h
> @@ -1290,27 +1290,6 @@ void helper_be_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val,
>  void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,
>                         TCGMemOpIdx oi, uintptr_t retaddr);
>
> -uint8_t helper_ret_ldub_cmmu(CPUArchState *env, target_ulong addr,
> -                            TCGMemOpIdx oi, uintptr_t retaddr);
> -int8_t helper_ret_ldsb_cmmu(CPUArchState *env, target_ulong addr,
> -                            TCGMemOpIdx oi, uintptr_t retaddr);
> -uint16_t helper_le_lduw_cmmu(CPUArchState *env, target_ulong addr,
> -                             TCGMemOpIdx oi, uintptr_t retaddr);
> -int16_t helper_le_ldsw_cmmu(CPUArchState *env, target_ulong addr,
> -                             TCGMemOpIdx oi, uintptr_t retaddr);
> -uint32_t helper_le_ldl_cmmu(CPUArchState *env, target_ulong addr,
> -                            TCGMemOpIdx oi, uintptr_t retaddr);
> -uint64_t helper_le_ldq_cmmu(CPUArchState *env, target_ulong addr,
> -                            TCGMemOpIdx oi, uintptr_t retaddr);
> -uint16_t helper_be_lduw_cmmu(CPUArchState *env, target_ulong addr,
> -                             TCGMemOpIdx oi, uintptr_t retaddr);
> -int16_t helper_be_ldsw_cmmu(CPUArchState *env, target_ulong addr,
> -                             TCGMemOpIdx oi, uintptr_t retaddr);
> -uint32_t helper_be_ldl_cmmu(CPUArchState *env, target_ulong addr,
> -                            TCGMemOpIdx oi, uintptr_t retaddr);
> -uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
> -                            TCGMemOpIdx oi, uintptr_t retaddr);
> -
<snip>

Why have we dropped the final type and stuck to uint32/64? Do we rely on
the caller truncating any data by casting the result of their eventual
cpu_ldFoo?

--
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 07/28] cputlb: Provide cpu_(ld, st}*_mmuidx_ra for user-only
  2019-12-16 22:11 ` [PATCH v2 07/28] cputlb: Provide cpu_(ld, st}*_mmuidx_ra for user-only Richard Henderson
@ 2019-12-20 17:36   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 17:36 UTC (permalink / raw)
  To: qemu-devel


Richard Henderson <richard.henderson@linaro.org> writes:

> This finishes the new interface began with the previous patch.
> Document the interface and deprecate MMU_MODE<N>_SUFFIX.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  include/exec/cpu_ldst.h     |  80 +++++++++++++-
>  docs/devel/loads-stores.rst | 211 ++++++++++++++++++++++++++----------
>  2 files changed, 230 insertions(+), 61 deletions(-)
>
> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
> index ef59ed61e4..41b98ba801 100644
> --- a/include/exec/cpu_ldst.h
> +++ b/include/exec/cpu_ldst.h
> @@ -25,9 +25,13 @@
>   *
>   * The syntax for the accessors is:
>   *
> - * load: cpu_ld{sign}{size}_{mmusuffix}(env, ptr)
> + * load:  cpu_ld{sign}{size}_{mmusuffix}(env, ptr)
> + *        cpu_ld{sign}{size}_{mmusuffix}_ra(env, ptr, retaddr)
> + *        cpu_ld{sign}{size}_mmuidx_ra(env, ptr, mmu_idx, retaddr)
>   *
> - * store: cpu_st{sign}{size}_{mmusuffix}(env, ptr, val)
> + * store: cpu_st{size}_{mmusuffix}(env, ptr, val)
> + *        cpu_st{size}_{mmusuffix}_ra(env, ptr, val, retaddr)
> + *        cpu_st{size}_mmuidx_ra(env, ptr, val, mmu_idx, retaddr)
>   *
>   * sign is:
>   * (empty): for 32 and 64 bit sizes
> @@ -40,9 +44,10 @@
>   *   l: 32 bits
>   *   q: 64 bits
>   *
> - * mmusuffix is one of the generic suffixes "data" or "code", or
> - * (for softmmu configs)  a target-specific MMU mode suffix as defined
> - * in target cpu.h.
> + * mmusuffix is one of the generic suffixes "data" or "code", or "mmuidx".
> + * The "mmuidx" suffix carries an extra mmu_idx argument that specifies
> + * the index to use; the "data" and "code" suffixes take the index from
> + * cpu_mmu_index().
>   */
>  #ifndef CPU_LDST_H
>  #define CPU_LDST_H
> @@ -145,6 +150,71 @@ static inline void clear_helper_retaddr(void)
>  #undef MEMSUFFIX
>  #undef CODE_ACCESS
>  
> +/*
> + * Provide the same *_mmuidx_ra interface as for softmmu.
> + * The mmu_idx argument is ignored.
> + */
> +
> +static inline uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                                          int mmu_idx, uintptr_t ra)
> +{
> +    return cpu_ldub_data_ra(env, addr, ra);
> +}
> +
> +static inline uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                                          int mmu_idx, uintptr_t ra)
> +{
> +    return cpu_lduw_data_ra(env, addr, ra);
> +}
> +
> +static inline uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                                         int mmu_idx, uintptr_t ra)
> +{
> +    return cpu_ldl_data_ra(env, addr, ra);
> +}
> +
> +static inline uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                                         int mmu_idx, uintptr_t ra)
> +{
> +    return cpu_ldq_data_ra(env, addr, ra);
> +}
> +
> +static inline int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                                     int mmu_idx, uintptr_t ra)
> +{
> +    return cpu_ldsb_data_ra(env, addr, ra);
> +}
> +
> +static inline int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                                     int mmu_idx, uintptr_t ra)
> +{
> +    return cpu_ldsw_data_ra(env, addr, ra);
> +}
> +
> +static inline void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                                     uint32_t val, int mmu_idx, uintptr_t ra)
> +{
> +    cpu_stb_data_ra(env, addr, val, ra);
> +}
> +
> +static inline void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                                     uint32_t val, int mmu_idx, uintptr_t ra)
> +{
> +    cpu_stw_data_ra(env, addr, val, ra);
> +}
> +
> +static inline void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                                     uint32_t val, int mmu_idx, uintptr_t ra)
> +{
> +    cpu_stl_data_ra(env, addr, val, ra);
> +}
> +
> +static inline void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                                     uint64_t val, int mmu_idx, uintptr_t ra)
> +{
> +    cpu_stq_data_ra(env, addr, val, ra);
> +}
> +
>  #else
>  
>  /* Needed for TCG_OVERSIZED_GUEST */
> diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst
> index 8a5bc912a5..03aa9e7ff8 100644
> --- a/docs/devel/loads-stores.rst
> +++ b/docs/devel/loads-stores.rst
> @@ -72,31 +72,34 @@ Regexes for git grep
>   - ``\<ldn_\([hbl]e\)?_p\>``
>   - ``\<stn_\([hbl]e\)?_p\>``
>  
> -``cpu_{ld,st}_*``
> -~~~~~~~~~~~~~~~~~
> +``cpu_{ld,st}*_mmuidx_ra``
> +~~~~~~~~~~~~~~~~~~~~~~~~~~
>  
> -These functions operate on a guest virtual address. Be aware
> -that these functions may cause a guest CPU exception to be
> -taken (e.g. for an alignment fault or MMU fault) which will
> -result in guest CPU state being updated and control longjumping
> -out of the function call. They should therefore only be used
> -in code that is implementing emulation of the target CPU.
> +These functions operate on a guest virtual address plus a context,
> +known as a "mmu index" or ``mmuidx``, which controls how that virtual
> +address is translated.  The meaning of the indexes are target specific,
> +but specifying a particular index might be necessary if, for instance,
> +the helper requires an "always as non-privileged" access rather that
> +the default access for the current state of the guest CPU.
>  
> -These functions may throw an exception (longjmp() back out
> -to the top level TCG loop). This means they must only be used
> -from helper functions where the translator has saved all
> -necessary CPU state before generating the helper function call.
> -It's usually better to use the ``_ra`` variants described below
> -from helper functions, but these functions are the right choice
> -for calls made from hooks like the CPU do_interrupt hook or
> -when you know for certain that the translator had to save all
> -the CPU state that ``cpu_restore_state()`` would restore anyway.
> +These functions may cause a guest CPU exception to be taken
> +(e.g. for an alignment fault or MMU fault) which will result in
> +guest CPU state being updated and control longjmp'ing out of the
> +function call.  They should therefore only be used in code that is
> +implementing emulation of the guest CPU.
> +
> +The ``retaddr`` parameter is used to control unwinding of the
> +guest CPU state in case of a guest CPU exception.  This is passed
> +to ``cpu_restore_state()``.  Therefore the value should either be 0,
> +to indicate that the guest CPU state is already synchronized, or
> +the result of ``GETPC()`` from the top level ``HELPER(foo)``
> +function, which is a return address into the generated code.
>  
>  Function names follow the pattern:
>  
> -load: ``cpu_ld{sign}{size}_{mmusuffix}(env, ptr)``
> +load: ``cpu_ld{sign}{size}_mmuidx_ra(env, ptr, mmuidx, retaddr)``
>  
> -store: ``cpu_st{size}_{mmusuffix}(env, ptr, val)``
> +store: ``cpu_st{size}_mmuidx_ra(env, ptr, val, mmuidx, retaddr)``
>  
>  ``sign``
>   - (empty) : for 32 or 64 bit sizes
> @@ -109,56 +112,151 @@ store: ``cpu_st{size}_{mmusuffix}(env, ptr, val)``
>   - ``l`` : 32 bits
>   - ``q`` : 64 bits
>  
> -``mmusuffix`` is one of the generic suffixes ``data`` or ``code``, or
> -(for softmmu configs) a target-specific MMU mode suffix as defined
> -in the target's ``cpu.h``.
> +Regexes for git grep:
> + - ``\<cpu_ld[us]\?[bwlq]_mmuidx_ra\>``
> + - ``\<cpu_st[bwlq]_mmuidx_ra\>``
>  
> -Regexes for git grep
> - - ``\<cpu_ld[us]\?[bwlq]_[a-zA-Z0-9]\+\>``
> - - ``\<cpu_st[bwlq]_[a-zA-Z0-9]\+\>``
> +``cpu_{ld,st}*_data_ra``
> +~~~~~~~~~~~~~~~~~~~~~~~~
>  
> -``cpu_{ld,st}_*_ra``
> -~~~~~~~~~~~~~~~~~~~~
> -
> -These functions work like the ``cpu_{ld,st}_*`` functions except
> -that they also take a ``retaddr`` argument. This extra argument
> -allows for correct unwinding of any exception that is taken,
> -and should generally be the result of GETPC() called directly
> -from the top level HELPER(foo) function (i.e. the return address
> -in the generated code).
> +These functions work like the ``cpu_{ld,st}_mmuidx_ra`` functions
> +except that the ``mmuidx`` parameter is taken from the current mode
> +of the guest CPU, as determined by ``cpu_mmu_index(env, false)``.
>  
>  These are generally the preferred way to do accesses by guest
> -virtual address from helper functions; see the documentation
> -of the non-``_ra`` variants for when those would be better.
> -
> -Calling these functions with a ``retaddr`` argument of 0 is
> -equivalent to calling the non-``_ra`` version of the function.
> +virtual address from helper functions, unless the access should
> +be performed with a context other than the default.
>  
>  Function names follow the pattern:
>  
> -load: ``cpu_ld{sign}{size}_{mmusuffix}_ra(env, ptr, retaddr)``
> +load: ``cpu_ld{sign}{size}_data_ra(env, ptr, ra)``
>  
> -store: ``cpu_st{sign}{size}_{mmusuffix}_ra(env, ptr, val, retaddr)``
> +store: ``cpu_st{size}_data_ra(env, ptr, val, ra)``
> +
> +``sign``
> + - (empty) : for 32 or 64 bit sizes
> + - ``u`` : unsigned
> + - ``s`` : signed
> +
> +``size``
> + - ``b`` : 8 bits
> + - ``w`` : 16 bits
> + - ``l`` : 32 bits
> + - ``q`` : 64 bits
> +
> +Regexes for git grep:
> + - ``\<cpu_ld[us]\?[bwlq]_data_ra\>``
> + - ``\<cpu_st[bwlq]_data_ra\>``
> +
> +``cpu_{ld,st}*_data``
> +~~~~~~~~~~~~~~~~~~~~~
> +
> +These functions work like the ``cpu_{ld,st}_data_ra`` functions
> +except that the ``retaddr`` parameter is 0, and thus does not
> +unwind guest CPU state.
> +
> +This means they must only be used from helper functions where the
> +translator has saved all necessary CPU state.  These functions are
> +the right choice for calls made from hooks like the CPU ``do_interrupt``
> +hook or when you know for certain that the translator had to save all
> +the CPU state anyway.
> +
> +Function names follow the pattern:
> +
> +load: ``cpu_ld{sign}{size}_data(env, ptr)``
> +
> +store: ``cpu_st{size}_data(env, ptr, val)``
> +
> +``sign``
> + - (empty) : for 32 or 64 bit sizes
> + - ``u`` : unsigned
> + - ``s`` : signed
> +
> +``size``
> + - ``b`` : 8 bits
> + - ``w`` : 16 bits
> + - ``l`` : 32 bits
> + - ``q`` : 64 bits
>  
>  Regexes for git grep
> - - ``\<cpu_ld[us]\?[bwlq]_[a-zA-Z0-9]\+_ra\>``
> - - ``\<cpu_st[bwlq]_[a-zA-Z0-9]\+_ra\>``
> + - ``\<cpu_ld[us]\?[bwlq]_data\>``
> + - ``\<cpu_st[bwlq]_data\+\>``
>  
> -``helper_*_{ld,st}*mmu``
> -~~~~~~~~~~~~~~~~~~~~~~~~
> +``cpu_ld*_code``
> +~~~~~~~~~~~~~~~~
> +
> +These functions perform a read for instruction execution.  The ``mmuidx``
> +parameter is taken from the current mode of the guest CPU, as determined
> +by ``cpu_mmu_index(env, true)``.  The ``retaddr`` parameter is 0, and
> +thus does not unwind guest CPU state, because CPU state is always
> +synchronized while translating instructions.  Any guest CPU exception
> +that is raised will indicate an instruction execution fault rather than
> +a data read fault.
> +
> +In general these functions should not be used directly during translation.
> +There are wrapper functions that are to be used which also take care of
> +plugins for tracing.
> +
> +Function names follow the pattern:
> +
> +load: ``cpu_ld{sign}{size}_code(env, ptr)``
> +
> +``sign``
> + - (empty) : for 32 or 64 bit sizes
> + - ``u`` : unsigned
> + - ``s`` : signed
> +
> +``size``
> + - ``b`` : 8 bits
> + - ``w`` : 16 bits
> + - ``l`` : 32 bits
> + - ``q`` : 64 bits
> +
> +Regexes for git grep:
> + - ``\<cpu_ld[us]\?[bwlq]_code\>``
> +
> +``translator_ld*``
> +~~~~~~~~~~~~~~~~~~
> +
> +These functions are a wrapper for ``cpu_ld*_code`` which also perform
> +any actions required by any tracing plugins.  They are only to be
> +called during the translator callback ``translate_insn``.
> +
> +There is a set of functions ending in ``_swap`` which, if the parameter
> +is true, returns the value in the endianness that is the reverse of
> +the guest native endianness, as determined by ``TARGET_WORDS_BIGENDIAN``.
> +
> +Function names follow the pattern:
> +
> +load: ``translator_ld{sign}{size}(env, ptr)``
> +
> +swap: ``translator_ld{sign}{size}_swap(env, ptr, swap)``
> +
> +``sign``
> + - (empty) : for 32 or 64 bit sizes
> + - ``u`` : unsigned
> + - ``s`` : signed
> +
> +``size``
> + - ``b`` : 8 bits
> + - ``w`` : 16 bits
> + - ``l`` : 32 bits
> + - ``q`` : 64 bits
> +
> +Regexes for git grep
> + - ``\<translator_ld[us]\?[bwlq]\(_swap\)\?\>``
> +
> +``helper_*_{ld,st}*_mmu``
> +~~~~~~~~~~~~~~~~~~~~~~~~~
>  
>  These functions are intended primarily to be called by the code
>  generated by the TCG backend. They may also be called by target
> -CPU helper function code. Like the ``cpu_{ld,st}_*_ra`` functions
> -they perform accesses by guest virtual address; the difference is
> -that these functions allow you to specify an ``opindex`` parameter
> -which encodes (among other things) the mmu index to use for the
> -access. This is necessary if your helper needs to make an access
> -via a specific mmu index (for instance, an "always as non-privileged"
> -access) rather than using the default mmu index for the current state
> -of the guest CPU.
> +CPU helper function code. Like the ``cpu_{ld,st}_mmuidx_ra`` functions
> +they perform accesses by guest virtual address, with a given ``mmuidx``.
>  
> -The ``opindex`` parameter should be created by calling ``make_memop_idx()``.
> +These functions specify an ``opindex`` parameter which encodes
> +(among other things) the mmu index to use for the access.  This parameter
> +should be created by calling ``make_memop_idx()``.
>  
>  The ``retaddr`` parameter should be the result of GETPC() called directly
>  from the top level HELPER(foo) function (or 0 if no guest CPU state
> @@ -166,8 +264,9 @@ unwinding is required).
>  
>  **TODO** The names of these functions are a bit odd for historical
>  reasons because they were originally expected to be called only from
> -within generated code. We should rename them to bring them
> -more in line with the other memory access functions.
> +within generated code. We should rename them to bring them more in
> +line with the other memory access functions. The explicit endianness
> +is the only feature they have beyond ``*_mmuidx_ra``.
>  
>  load: ``helper_{endian}_ld{sign}{size}_mmu(env, addr, opindex, retaddr)``


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 08/28] target/i386: Use cpu_*_mmuidx_ra instead of templates
  2019-12-16 22:11 ` [PATCH v2 08/28] target/i386: Use cpu_*_mmuidx_ra instead of templates Richard Henderson
@ 2019-12-20 17:42   ` Alex Bennée
  2019-12-28 21:02     ` Richard Henderson
  0 siblings, 1 reply; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Eduardo Habkost


Richard Henderson <richard.henderson@linaro.org> writes:

> Do not use exec/cpu_ldst_{,useronly_}template.h directly,
> but instead use the functional interface.
>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  target/i386/seg_helper.c | 56 ++++++++++++++++++++--------------------
>  1 file changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/target/i386/seg_helper.c b/target/i386/seg_helper.c
> index 87a627f9dc..b96de068ca 100644
> --- a/target/i386/seg_helper.c
> +++ b/target/i386/seg_helper.c
> @@ -37,37 +37,37 @@
>  # define LOG_PCALL_STATE(cpu) do { } while (0)
>  #endif
>  
> -#ifdef CONFIG_USER_ONLY
> -#define MEMSUFFIX _kernel
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_useronly_template.h"
> +/*
> + * TODO: Convert callers to compute cpu_mmu_index_kernel once
> + * and use *_mmuidx_ra directly.
> + */

I guess this would only be if it was a significant performance impact?
They seem to be mainly called for (I assume) infrequently called
helpers.

Anyway lgtm:

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>


> +#define cpu_ldub_kernel_ra(e, p, r) \
> +    cpu_ldub_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
> +#define cpu_lduw_kernel_ra(e, p, r) \
> +    cpu_lduw_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
> +#define cpu_ldl_kernel_ra(e, p, r) \
> +    cpu_ldl_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
> +#define cpu_ldq_kernel_ra(e, p, r) \
> +    cpu_ldq_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
>  
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_useronly_template.h"
> +#define cpu_stb_kernel_ra(e, p, v, r) \
> +    cpu_stb_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
> +#define cpu_stw_kernel_ra(e, p, v, r) \
> +    cpu_stw_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
> +#define cpu_stl_kernel_ra(e, p, v, r) \
> +    cpu_stl_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
> +#define cpu_stq_kernel_ra(e, p, v, r) \
> +    cpu_stq_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
>  
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_useronly_template.h"
> +#define cpu_ldub_kernel(e, p)    cpu_ldub_kernel_ra(e, p, 0)
> +#define cpu_lduw_kernel(e, p)    cpu_lduw_kernel_ra(e, p, 0)
> +#define cpu_ldl_kernel(e, p)     cpu_ldl_kernel_ra(e, p, 0)
> +#define cpu_ldq_kernel(e, p)     cpu_ldq_kernel_ra(e, p, 0)
>  
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_useronly_template.h"
> -#undef MEMSUFFIX
> -#else
> -#define CPU_MMU_INDEX (cpu_mmu_index_kernel(env))
> -#define MEMSUFFIX _kernel
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif
> +#define cpu_stb_kernel(e, p, v)  cpu_stb_kernel_ra(e, p, v, 0)
> +#define cpu_stw_kernel(e, p, v)  cpu_stw_kernel_ra(e, p, v, 0)
> +#define cpu_stl_kernel(e, p, v)  cpu_stl_kernel_ra(e, p, v, 0)
> +#define cpu_stq_kernel(e, p, v)  cpu_stq_kernel_ra(e, p, v, 0)
>  
>  /* return non zero if error */
>  static inline int load_segment_ra(CPUX86State *env, uint32_t *e1_ptr,


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 09/28] target/s390x: Include tcg.h in mem_helper.c
  2019-12-16 22:11 ` [PATCH v2 09/28] target/s390x: Include tcg.h in mem_helper.c Richard Henderson
@ 2019-12-20 17:43   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Hildenbrand


Richard Henderson <richard.henderson@linaro.org> writes:

> Code movement in an upcoming patch will show that this file
> was implicitly depending on tcg.h being included indirectly.
>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/s390x/mem_helper.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
> index 2325767f17..57ce17c252 100644
> --- a/target/s390x/mem_helper.c
> +++ b/target/s390x/mem_helper.c
> @@ -27,6 +27,7 @@
>  #include "exec/cpu_ldst.h"
>  #include "qemu/int128.h"
>  #include "qemu/atomic128.h"
> +#include "tcg.h"
>  
>  #if !defined(CONFIG_USER_ONLY)
>  #include "hw/s390x/storage-keys.h"


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 10/28] target/arm: Include tcg.h in sve_helper.c
  2019-12-16 22:11 ` [PATCH v2 10/28] target/arm: Include tcg.h in sve_helper.c Richard Henderson
@ 2019-12-20 17:43   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell


Richard Henderson <richard.henderson@linaro.org> writes:

> Code movement in an upcoming patch will show that this file
> was implicitly depending on tcg.h being included indirectly.
>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/arm/sve_helper.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
> index fc0c1755d2..83cc7f5bb5 100644
> --- a/target/arm/sve_helper.c
> +++ b/target/arm/sve_helper.c
> @@ -25,6 +25,7 @@
>  #include "exec/helper-proto.h"
>  #include "tcg/tcg-gvec-desc.h"
>  #include "fpu/softfloat.h"
> +#include "tcg.h"
>  
>  
>  /* Note that vector data is stored in host-endian 64-bit chunks,


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 12/28] linux-user: Include tcg.h in syscall.c
  2019-12-16 22:11 ` [PATCH v2 12/28] linux-user: Include tcg.h in syscall.c Richard Henderson
@ 2019-12-20 17:43   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel


Richard Henderson <richard.henderson@linaro.org> writes:

> Code movement in an upcoming patch will show that this file
> was implicitly depending on tcg.h being included indirectly.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  linux-user/syscall.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 171c0caef3..34825f15bf 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -115,6 +115,7 @@
>  #include "user/syscall-trace.h"
>  #include "qapi/error.h"
>  #include "fd-trans.h"
> +#include "tcg.h"
>  
>  #ifndef CLONE_IO
>  #define CLONE_IO                0x80000000      /* Clone io context */


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 13/28] linux-user: Include trace-root.h in syscall-trace.h
  2019-12-16 22:11 ` [PATCH v2 13/28] linux-user: Include trace-root.h in syscall-trace.h Richard Henderson
@ 2019-12-20 17:49   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 17:49 UTC (permalink / raw)
  To: qemu-devel


Richard Henderson <richard.henderson@linaro.org> writes:

> Code movement in an upcoming patch will show that this file
> was implicitly depending on trace-root.h being included beforehand.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  include/user/syscall-trace.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/include/user/syscall-trace.h b/include/user/syscall-trace.h
> index 9e60473643..79fd3e5aa9 100644
> --- a/include/user/syscall-trace.h
> +++ b/include/user/syscall-trace.h
> @@ -10,6 +10,8 @@
>  #ifndef _SYSCALL_TRACE_H_
>  #define _SYSCALL_TRACE_H_
>  
> +#include "trace-root.h"
> +
>  /*
>   * These helpers just provide a common place for the various
>   * subsystems that want to track syscalls to put their hooks in. We


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 14/28] cputlb: Expand cpu_ldst_useronly_template.h in user-exec.c
  2019-12-16 22:11 ` [PATCH v2 14/28] cputlb: Expand cpu_ldst_useronly_template.h in user-exec.c Richard Henderson
@ 2019-12-20 17:59   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 17:59 UTC (permalink / raw)
  To: qemu-devel


Richard Henderson <richard.henderson@linaro.org> writes:

> With the tracing hooks, the inline functions are no longer
> so simple.  Reduce the amount of preprocessor obfuscation
> by expanding the text of each of the functions generated.
> The result is only slightly larger than the original.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  include/exec/cpu_ldst.h                   |  54 +++--
>  include/exec/cpu_ldst_useronly_template.h | 159 ---------------
>  accel/tcg/user-exec.c                     | 236 ++++++++++++++++++++++
>  3 files changed, 262 insertions(+), 187 deletions(-)
>  delete mode 100644 include/exec/cpu_ldst_useronly_template.h
>
> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
> index 41b98ba801..0f3c49a005 100644
> --- a/include/exec/cpu_ldst.h
> +++ b/include/exec/cpu_ldst.h
> @@ -120,35 +120,33 @@ static inline void clear_helper_retaddr(void)
>  
>  /* In user-only mode we provide only the _code and _data accessors. */
>  
> -#define MEMSUFFIX _data
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_useronly_template.h"
> +uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr);
> +uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr);
> +uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr);
> +uint64_t cpu_ldq_data(CPUArchState *env, abi_ptr ptr);
> +int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr);
> +int cpu_ldsw_data(CPUArchState *env, abi_ptr ptr);
>  
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_useronly_template.h"
> +uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
> +uint32_t cpu_lduw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
> +uint32_t cpu_ldl_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
> +uint64_t cpu_ldq_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
> +int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
> +int cpu_ldsw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
>  
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_useronly_template.h"
> +void cpu_stb_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
> +void cpu_stw_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
> +void cpu_stl_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
> +void cpu_stq_data(CPUArchState *env, abi_ptr ptr, uint64_t val);
>  
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_useronly_template.h"
> -#undef MEMSUFFIX
> -
> -#define MEMSUFFIX _code
> -#define CODE_ACCESS
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_useronly_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_useronly_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_useronly_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_useronly_template.h"
> -#undef MEMSUFFIX
> -#undef CODE_ACCESS
> +void cpu_stb_data_ra(CPUArchState *env, abi_ptr ptr,
> +                     uint32_t val, uintptr_t retaddr);
> +void cpu_stw_data_ra(CPUArchState *env, abi_ptr ptr,
> +                     uint32_t val, uintptr_t retaddr);
> +void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
> +                     uint32_t val, uintptr_t retaddr);
> +void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
> +                     uint64_t val, uintptr_t retaddr);
>  
>  /*
>   * Provide the same *_mmuidx_ra interface as for softmmu.
> @@ -520,6 +518,8 @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
>  #undef CPU_MMU_INDEX
>  #undef MEMSUFFIX
>  
> +#endif /* defined(CONFIG_USER_ONLY) */
> +
>  uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
>  uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr);
>  uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr);
> @@ -535,8 +535,6 @@ static inline int cpu_ldsw_code(CPUArchState *env, abi_ptr addr)
>      return (int16_t)cpu_lduw_code(env, addr);
>  }
>  
> -#endif /* defined(CONFIG_USER_ONLY) */
> -
>  /**
>   * tlb_vaddr_to_host:
>   * @env: CPUArchState
> diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h
> deleted file mode 100644
> index e5a3d1983a..0000000000
> --- a/include/exec/cpu_ldst_useronly_template.h
> +++ /dev/null
> @@ -1,159 +0,0 @@
> -/*
> - *  User-only accessor function support
> - *
> - * Generate inline load/store functions for one data size.
> - *
> - * Generate a store function as well as signed and unsigned loads.
> - *
> - * Not used directly but included from cpu_ldst.h.
> - *
> - *  Copyright (c) 2015 Linaro Limited
> - *
> - * 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/>.
> - */
> -
> -#if !defined(CODE_ACCESS)
> -#include "trace-root.h"
> -#endif
> -
> -#include "trace/mem.h"
> -
> -#if DATA_SIZE == 8
> -#define SUFFIX q
> -#define USUFFIX q
> -#define DATA_TYPE uint64_t
> -#define SHIFT 3
> -#elif DATA_SIZE == 4
> -#define SUFFIX l
> -#define USUFFIX l
> -#define DATA_TYPE uint32_t
> -#define SHIFT 2
> -#elif DATA_SIZE == 2
> -#define SUFFIX w
> -#define USUFFIX uw
> -#define DATA_TYPE uint16_t
> -#define DATA_STYPE int16_t
> -#define SHIFT 1
> -#elif DATA_SIZE == 1
> -#define SUFFIX b
> -#define USUFFIX ub
> -#define DATA_TYPE uint8_t
> -#define DATA_STYPE int8_t
> -#define SHIFT 0
> -#else
> -#error unsupported data size
> -#endif
> -
> -#if DATA_SIZE == 8
> -#define RES_TYPE uint64_t
> -#else
> -#define RES_TYPE uint32_t
> -#endif
> -
> -static inline RES_TYPE
> -glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
> -{
> -    RES_TYPE ret;
> -#ifdef CODE_ACCESS
> -    set_helper_retaddr(1);
> -    ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
> -    clear_helper_retaddr();
> -#else
> -    MemOp op = MO_TE | SHIFT;
> -    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
> -    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> -    ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
> -#endif
> -    return ret;
> -}
> -
> -#ifndef CODE_ACCESS
> -static inline RES_TYPE
> -glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
> -                                                  abi_ptr ptr,
> -                                                  uintptr_t retaddr)
> -{
> -    RES_TYPE ret;
> -    set_helper_retaddr(retaddr);
> -    ret = glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(env, ptr);
> -    clear_helper_retaddr();
> -    return ret;
> -}
> -#endif
> -
> -#if DATA_SIZE <= 2
> -static inline int
> -glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
> -{
> -    int ret;
> -#ifdef CODE_ACCESS
> -    set_helper_retaddr(1);
> -    ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
> -    clear_helper_retaddr();
> -#else
> -    MemOp op = MO_TE | MO_SIGN | SHIFT;
> -    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
> -    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> -    ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
> -    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> -#endif
> -    return ret;
> -}
> -
> -#ifndef CODE_ACCESS
> -static inline int
> -glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
> -                                                  abi_ptr ptr,
> -                                                  uintptr_t retaddr)
> -{
> -    int ret;
> -    set_helper_retaddr(retaddr);
> -    ret = glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(env, ptr);
> -    clear_helper_retaddr();
> -    return ret;
> -}
> -#endif /* CODE_ACCESS */
> -#endif /* DATA_SIZE <= 2 */
> -
> -#ifndef CODE_ACCESS
> -static inline void
> -glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
> -                                      RES_TYPE v)
> -{
> -    MemOp op = MO_TE | SHIFT;
> -    uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, true);
> -    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> -    glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
> -    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> -}
> -
> -static inline void
> -glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
> -                                                  abi_ptr ptr,
> -                                                  RES_TYPE v,
> -                                                  uintptr_t retaddr)
> -{
> -    set_helper_retaddr(retaddr);
> -    glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(env, ptr, v);
> -    clear_helper_retaddr();
> -}
> -#endif
> -
> -#undef RES_TYPE
> -#undef DATA_TYPE
> -#undef DATA_STYPE
> -#undef SUFFIX
> -#undef USUFFIX
> -#undef DATA_SIZE
> -#undef SHIFT
> diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
> index b09f7a1577..79da4219bb 100644
> --- a/accel/tcg/user-exec.c
> +++ b/accel/tcg/user-exec.c
> @@ -26,6 +26,8 @@
>  #include "translate-all.h"
>  #include "exec/helper-proto.h"
>  #include "qemu/atomic128.h"
> +#include "trace-root.h"
> +#include "trace/mem.h"
>  
>  #undef EAX
>  #undef ECX
> @@ -734,6 +736,240 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>  
>  /* The softmmu versions of these helpers are in cputlb.c.  */
>  
> +uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr)
> +{
> +    uint32_t ret;
> +    uint16_t meminfo = trace_mem_get_info(MO_UB, MMU_USER_IDX, false);
> +
> +    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> +    ret = ldub_p(g2h(ptr));
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> +    return ret;
> +}
> +
> +int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr)
> +{
> +    int ret;
> +    uint16_t meminfo = trace_mem_get_info(MO_SB, MMU_USER_IDX, false);
> +
> +    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> +    ret = ldsb_p(g2h(ptr));
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> +    return ret;
> +}
> +
> +uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr)
> +{
> +    uint32_t ret;
> +    uint16_t meminfo = trace_mem_get_info(MO_TEUW, MMU_USER_IDX, false);
> +
> +    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> +    ret = lduw_p(g2h(ptr));
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> +    return ret;
> +}
> +
> +int cpu_ldsw_data(CPUArchState *env, abi_ptr ptr)
> +{
> +    int ret;
> +    uint16_t meminfo = trace_mem_get_info(MO_TESW, MMU_USER_IDX, false);
> +
> +    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> +    ret = ldsw_p(g2h(ptr));
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> +    return ret;
> +}
> +
> +uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr)
> +{
> +    uint32_t ret;
> +    uint16_t meminfo = trace_mem_get_info(MO_TEUL, MMU_USER_IDX, false);
> +
> +    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> +    ret = ldl_p(g2h(ptr));
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> +    return ret;
> +}
> +
> +uint64_t cpu_ldq_data(CPUArchState *env, abi_ptr ptr)
> +{
> +    uint64_t ret;
> +    uint16_t meminfo = trace_mem_get_info(MO_TEQ, MMU_USER_IDX, false);
> +
> +    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> +    ret = ldq_p(g2h(ptr));
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> +    return ret;
> +}
> +
> +uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
> +{
> +    uint32_t ret;
> +
> +    set_helper_retaddr(retaddr);
> +    ret = cpu_ldub_data(env, ptr);
> +    clear_helper_retaddr();
> +    return ret;
> +}
> +
> +int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
> +{
> +    int ret;
> +
> +    set_helper_retaddr(retaddr);
> +    ret = cpu_ldsb_data(env, ptr);
> +    clear_helper_retaddr();
> +    return ret;
> +}
> +
> +uint32_t cpu_lduw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
> +{
> +    uint32_t ret;
> +
> +    set_helper_retaddr(retaddr);
> +    ret = cpu_lduw_data(env, ptr);
> +    clear_helper_retaddr();
> +    return ret;
> +}
> +
> +int cpu_ldsw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
> +{
> +    int ret;
> +
> +    set_helper_retaddr(retaddr);
> +    ret = cpu_ldsw_data(env, ptr);
> +    clear_helper_retaddr();
> +    return ret;
> +}
> +
> +uint32_t cpu_ldl_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
> +{
> +    uint32_t ret;
> +
> +    set_helper_retaddr(retaddr);
> +    ret = cpu_ldl_data(env, ptr);
> +    clear_helper_retaddr();
> +    return ret;
> +}
> +
> +uint64_t cpu_ldq_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
> +{
> +    uint64_t ret;
> +
> +    set_helper_retaddr(retaddr);
> +    ret = cpu_ldq_data(env, ptr);
> +    clear_helper_retaddr();
> +    return ret;
> +}
> +
> +void cpu_stb_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
> +{
> +    uint16_t meminfo = trace_mem_get_info(MO_UB, MMU_USER_IDX, true);
> +
> +    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> +    stb_p(g2h(ptr), val);
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> +}
> +
> +void cpu_stw_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
> +{
> +    uint16_t meminfo = trace_mem_get_info(MO_TEUW, MMU_USER_IDX, true);
> +
> +    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> +    stw_p(g2h(ptr), val);
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> +}
> +
> +void cpu_stl_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
> +{
> +    uint16_t meminfo = trace_mem_get_info(MO_TEUL, MMU_USER_IDX, true);
> +
> +    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> +    stl_p(g2h(ptr), val);
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> +}
> +
> +void cpu_stq_data(CPUArchState *env, abi_ptr ptr, uint64_t val)
> +{
> +    uint16_t meminfo = trace_mem_get_info(MO_TEQ, MMU_USER_IDX, true);
> +
> +    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
> +    stq_p(g2h(ptr), val);
> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
> +}
> +
> +void cpu_stb_data_ra(CPUArchState *env, abi_ptr ptr,
> +                     uint32_t val, uintptr_t retaddr)
> +{
> +    set_helper_retaddr(retaddr);
> +    cpu_stb_data(env, ptr, val);
> +    clear_helper_retaddr();
> +}
> +
> +void cpu_stw_data_ra(CPUArchState *env, abi_ptr ptr,
> +                     uint32_t val, uintptr_t retaddr)
> +{
> +    set_helper_retaddr(retaddr);
> +    cpu_stw_data(env, ptr, val);
> +    clear_helper_retaddr();
> +}
> +
> +void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
> +                     uint32_t val, uintptr_t retaddr)
> +{
> +    set_helper_retaddr(retaddr);
> +    cpu_stl_data(env, ptr, val);
> +    clear_helper_retaddr();
> +}
> +
> +void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
> +                     uint64_t val, uintptr_t retaddr)
> +{
> +    set_helper_retaddr(retaddr);
> +    cpu_stq_data(env, ptr, val);
> +    clear_helper_retaddr();
> +}
> +
> +uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr ptr)
> +{
> +    uint32_t ret;
> +
> +    set_helper_retaddr(1);
> +    ret = ldub_p(g2h(ptr));
> +    clear_helper_retaddr();
> +    return ret;
> +}
> +
> +uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr ptr)
> +{
> +    uint32_t ret;
> +
> +    set_helper_retaddr(1);
> +    ret = lduw_p(g2h(ptr));
> +    clear_helper_retaddr();
> +    return ret;
> +}
> +
> +uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr ptr)
> +{
> +    uint32_t ret;
> +
> +    set_helper_retaddr(1);
> +    ret = ldl_p(g2h(ptr));
> +    clear_helper_retaddr();
> +    return ret;
> +}
> +
> +uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr ptr)
> +{
> +    uint64_t ret;
> +
> +    set_helper_retaddr(1);
> +    ret = ldq_p(g2h(ptr));
> +    clear_helper_retaddr();
> +    return ret;
> +}
> +
>  /* Do not allow unaligned operations to proceed.  Return the host address.  */
>  static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
>                                 int size, uintptr_t retaddr)


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 15/28] target/nios2: Remove MMU_MODE{0,1}_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 15/28] target/nios2: Remove MMU_MODE{0,1}_SUFFIX Richard Henderson
@ 2019-12-20 18:02   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 18:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marek Vasut, Chris Wulff


Richard Henderson <richard.henderson@linaro.org> writes:

> The functions generated by these macros are unused.
>
> Cc: Chris Wulff <crwulff@gmail.com>
> Cc: Marek Vasut <marex@denx.de>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/nios2/cpu.h | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
> index 361b06ffeb..78f633f970 100644
> --- a/target/nios2/cpu.h
> +++ b/target/nios2/cpu.h
> @@ -217,8 +217,6 @@ void do_nios2_semihosting(CPUNios2State *env);
>  #define CPU_SAVE_VERSION 1
>  
>  /* MMU modes definitions */
> -#define MMU_MODE0_SUFFIX _kernel
> -#define MMU_MODE1_SUFFIX _user
>  #define MMU_SUPERVISOR_IDX  0
>  #define MMU_USER_IDX        1


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 16/28] target/alpha: Remove MMU_MODE{0,1}_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 16/28] target/alpha: " Richard Henderson
@ 2019-12-20 18:02   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 18:02 UTC (permalink / raw)
  To: qemu-devel


Richard Henderson <richard.henderson@linaro.org> writes:

> The functions generated by these macros are unused.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/alpha/cpu.h | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
> index a530249a5b..3f782c0efe 100644
> --- a/target/alpha/cpu.h
> +++ b/target/alpha/cpu.h
> @@ -193,8 +193,6 @@ enum {
>     PALcode cheats and usees the KSEG mapping for its code+data rather than
>     physical addresses.  */
>  
> -#define MMU_MODE0_SUFFIX _kernel
> -#define MMU_MODE1_SUFFIX _user
>  #define MMU_KERNEL_IDX   0
>  #define MMU_USER_IDX     1
>  #define MMU_PHYS_IDX     2


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 17/28] target/cris: Remove MMU_MODE{0,1}_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 17/28] target/cris: " Richard Henderson
@ 2019-12-20 18:02   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 18:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Edgar E . Iglesias


Richard Henderson <richard.henderson@linaro.org> writes:

> The functions generated by these macros are unused.
>
> Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/cris/cpu.h | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/target/cris/cpu.h b/target/cris/cpu.h
> index aba0a66474..bc43bc23a1 100644
> --- a/target/cris/cpu.h
> +++ b/target/cris/cpu.h
> @@ -252,8 +252,6 @@ enum {
>  #define cpu_signal_handler cpu_cris_signal_handler
>  
>  /* MMU modes definitions */
> -#define MMU_MODE0_SUFFIX _kernel
> -#define MMU_MODE1_SUFFIX _user
>  #define MMU_USER_IDX 1
>  static inline int cpu_mmu_index (CPUCRISState *env, bool ifetch)
>  {


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 18/28] target/i386: Remove MMU_MODE{0,1,2}_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 18/28] target/i386: Remove MMU_MODE{0,1,2}_SUFFIX Richard Henderson
@ 2019-12-20 18:02   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 18:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Eduardo Habkost


Richard Henderson <richard.henderson@linaro.org> writes:

> The functions generated by these macros are unused.
>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/i386/cpu.h | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index cde2a16b94..6a8228df4f 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -1949,9 +1949,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);
>  #define cpu_list x86_cpu_list
>  
>  /* MMU modes definitions */
> -#define MMU_MODE0_SUFFIX _ksmap
> -#define MMU_MODE1_SUFFIX _user
> -#define MMU_MODE2_SUFFIX _knosmap /* SMAP disabled or CPL<3 && AC=1 */
>  #define MMU_KSMAP_IDX   0
>  #define MMU_USER_IDX    1
>  #define MMU_KNOSMAP_IDX 2


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 19/28] target/microblaze: Remove MMU_MODE{0, 1, 2}_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 19/28] target/microblaze: " Richard Henderson
@ 2019-12-20 18:03   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Edgar E . Iglesias


Richard Henderson <richard.henderson@linaro.org> writes:

> The functions generated by these macros are unused.
>
> Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/microblaze/cpu.h | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
> index 95773089aa..32522f606b 100644
> --- a/target/microblaze/cpu.h
> +++ b/target/microblaze/cpu.h
> @@ -328,9 +328,6 @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
>  #define cpu_signal_handler cpu_mb_signal_handler
>  
>  /* MMU modes definitions */
> -#define MMU_MODE0_SUFFIX _nommu
> -#define MMU_MODE1_SUFFIX _kernel
> -#define MMU_MODE2_SUFFIX _user
>  #define MMU_NOMMU_IDX   0
>  #define MMU_KERNEL_IDX  1
>  #define MMU_USER_IDX    2


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 20/28] target/sh4: Remove MMU_MODE{0,1}_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 20/28] target/sh4: Remove MMU_MODE{0,1}_SUFFIX Richard Henderson
@ 2019-12-20 18:03   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aurelien Jarno


Richard Henderson <richard.henderson@linaro.org> writes:

> The functions generated by these macros are unused.
>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/sh4/cpu.h | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
> index ecaa7a18a9..452a596e67 100644
> --- a/target/sh4/cpu.h
> +++ b/target/sh4/cpu.h
> @@ -254,8 +254,6 @@ void cpu_load_tlb(CPUSH4State * env);
>  #define cpu_list sh4_cpu_list
>  
>  /* MMU modes definitions */
> -#define MMU_MODE0_SUFFIX _kernel
> -#define MMU_MODE1_SUFFIX _user
>  #define MMU_USER_IDX 1
>  static inline int cpu_mmu_index (CPUSH4State *env, bool ifetch)
>  {


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 21/28] target/unicore32: Remove MMU_MODE{0,1}_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 21/28] target/unicore32: " Richard Henderson
@ 2019-12-20 18:03   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Guan Xuetao


Richard Henderson <richard.henderson@linaro.org> writes:

> The functions generated by these macros are unused.
>
> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/unicore32/cpu.h | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
> index 50ed9dd99c..7a32e086ed 100644
> --- a/target/unicore32/cpu.h
> +++ b/target/unicore32/cpu.h
> @@ -133,8 +133,6 @@ void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)
>  int uc32_cpu_signal_handler(int host_signum, void *pinfo, void *puc);
>  
>  /* MMU modes definitions */
> -#define MMU_MODE0_SUFFIX _kernel
> -#define MMU_MODE1_SUFFIX _user
>  #define MMU_USER_IDX 1
>  static inline int cpu_mmu_index(CPUUniCore32State *env, bool ifetch)
>  {


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 04/28] cputlb: Move body of cpu_ldst_template.h out of line
  2019-12-20 17:07   ` Alex Bennée
@ 2019-12-20 18:33     ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 18:33 UTC (permalink / raw)
  To: qemu-devel


Alex Bennée <alex.bennee@linaro.org> writes:

> Richard Henderson <richard.henderson@linaro.org> writes:
>
>> With the tracing hooks, the inline functions are no longer
>> so simple.  Once out-of-line, the current tlb_entry lookup
>> is redundant with the one in the main load/store_helper.
>>
>> This also begins the introduction of a new target facing
>> interface, with suffix *_mmuidx_ra.  This is not yet
>> official because the interface is not done for user-only.
>>
>> Use abi_ptr instead of target_ulong in preparation for
>> user-only; the two types are identical for softmmu.
>>
>> What remains in cpu_ldst_template.h are the expansions
>> for _code, _data, and MMU_MODE<N>_SUFFIX.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

Although this seems to have broken --enable-plugins builds:

    CC      aarch64-softmmu/plugins/api.o
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c: In function ‘qemu_plugin_mem_size_shift’:
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c:229:19: error: ‘TRACE_MEM_SZ_SHIFT_MASK’ undeclared (first use in this function)
       return info & TRACE_MEM_SZ_SHIFT_MASK;
                     ^~~~~~~~~~~~~~~~~~~~~~~
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c:229:19: note: each undeclared identifier is reported only once for each function it appears in
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c: In function ‘qemu_plugin_mem_is_sign_extended’:
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c:234:22: error: ‘TRACE_MEM_SE’ undeclared (first use in this function)
       return !!(info & TRACE_MEM_SE);
                        ^~~~~~~~~~~~
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c: In function ‘qemu_plugin_mem_is_big_endian’:
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c:239:22: error: ‘TRACE_MEM_BE’ undeclared (first use in this function)
       return !!(info & TRACE_MEM_BE);
                        ^~~~~~~~~~~~
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c: In function ‘qemu_plugin_mem_is_store’:
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c:244:22: error: ‘TRACE_MEM_ST’ undeclared (first use in this function)
       return !!(info & TRACE_MEM_ST);
                        ^~~~~~~~~~~~
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c: In function ‘qemu_plugin_get_hwaddr’:
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c:258:36: error: ‘TRACE_MEM_MMU_SHIFT’ undeclared (first use in this function); did you mean ‘TCP_MAX_WINSHIFT’?
       unsigned int mmu_idx = info >> TRACE_MEM_MMU_SHIFT;
                                      ^~~~~~~~~~~~~~~~~~~
                                      TCP_MAX_WINSHIFT
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c:259:35: error: ‘TRACE_MEM_ST’ undeclared (first use in this function); did you mean ‘TRACE_MEM_MMU_SHIFT’?
       hwaddr_info.is_store = info & TRACE_MEM_ST;
                                     ^~~~~~~~~~~~
                                     TRACE_MEM_MMU_SHIFT
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c: In function ‘qemu_plugin_mem_size_shift’:
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c:230:1: error: control reaches end of non-void function [-Werror=return-type]
   }
   ^
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c: In function ‘qemu_plugin_mem_is_sign_extended’:
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c:235:1: error: control reaches end of non-void function [-Werror=return-type]
   }
   ^
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c: In function ‘qemu_plugin_mem_is_big_endian’:
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c:240:1: error: control reaches end of non-void function [-Werror=return-type]
   }
   ^
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c: In function ‘qemu_plugin_mem_is_store’:
  /home/alex.bennee/lsrc/qemu.git/plugins/api.c:245:1: error: control reaches end of non-void function [-Werror=return-type]
   }
   ^
  cc1: all warnings being treated as errors
  /home/alex.bennee/lsrc/qemu.git/rules.mak:69: recipe for target 'plugins/api.o' failed
  make[1]: *** [plugins/api.o] Error 1
  Makefile:491: recipe for target 'aarch64-softmmu/all' failed
  make: *** [aarch64-softmmu/all] Error 2


>
>> ---
>>  include/exec/cpu_ldst.h          |  25 ++++++-
>>  include/exec/cpu_ldst_template.h | 125 +++++++------------------------
>>  accel/tcg/cputlb.c               | 116 ++++++++++++++++++++++++++++
>>  3 files changed, 166 insertions(+), 100 deletions(-)
>>
>> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
>> index fd499f7e2f..cf8af36dbc 100644
>> --- a/include/exec/cpu_ldst.h
>> +++ b/include/exec/cpu_ldst.h
>> @@ -152,7 +152,7 @@ static inline void clear_helper_retaddr(void)
>>  
>>  #else
>>  
>> -/* The memory helpers for tcg-generated code need tcg_target_long etc.  */
>> +/* Needed for TCG_OVERSIZED_GUEST */
>>  #include "tcg.h"
>>  
>>  static inline target_ulong tlb_addr_write(const CPUTLBEntry *entry)
>> @@ -185,6 +185,29 @@ static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx,
>>      return &env_tlb(env)->f[mmu_idx].table[tlb_index(env, mmu_idx, addr)];
>>  }
>>  
>> +uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                            int mmu_idx, uintptr_t ra);
>> +uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                            int mmu_idx, uintptr_t ra);
>> +uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                           int mmu_idx, uintptr_t ra);
>> +uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                           int mmu_idx, uintptr_t ra);
>> +
>> +int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                       int mmu_idx, uintptr_t ra);
>> +int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                       int mmu_idx, uintptr_t ra);
>> +
>> +void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
>> +                       int mmu_idx, uintptr_t retaddr);
>> +void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
>> +                       int mmu_idx, uintptr_t retaddr);
>> +void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
>> +                       int mmu_idx, uintptr_t retaddr);
>> +void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
>> +                       int mmu_idx, uintptr_t retaddr);
>> +
>>  #ifdef MMU_MODE0_SUFFIX
>>  #define CPU_MMU_INDEX 0
>>  #define MEMSUFFIX MMU_MODE0_SUFFIX
>> diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
>> index 0ad5de3ef9..ea39e29c19 100644
>> --- a/include/exec/cpu_ldst_template.h
>> +++ b/include/exec/cpu_ldst_template.h
>> @@ -24,13 +24,6 @@
>>   * License along with this library; if not, see <http://www.gnu.org/licenses/>.
>>   */
>>  
>> -#if !defined(SOFTMMU_CODE_ACCESS)
>> -#include "trace-root.h"
>> -#endif
>> -
>> -#include "qemu/plugin.h"
>> -#include "trace/mem.h"
>> -
>>  #if DATA_SIZE == 8
>>  #define SUFFIX q
>>  #define USUFFIX q
>> @@ -63,56 +56,40 @@
>>  #define RES_TYPE uint32_t
>>  #endif
>>  
>> +/* generic load/store macros */
>> +
>>  #ifdef SOFTMMU_CODE_ACCESS
>> -#define ADDR_READ addr_code
>> -#define MMUSUFFIX _cmmu
>> -#define URETSUFFIX USUFFIX
>> -#define SRETSUFFIX glue(s, SUFFIX)
>> -#else
>> -#define ADDR_READ addr_read
>> -#define MMUSUFFIX _mmu
>> -#define URETSUFFIX USUFFIX
>> -#define SRETSUFFIX glue(s, SUFFIX)
>> +
>> +static inline RES_TYPE
>> +glue(glue(cpu_ld, USUFFIX), _code)(CPUArchState *env, target_ulong ptr)
>> +{
>> +    TCGMemOpIdx oi = make_memop_idx(MO_TE | SHIFT, CPU_MMU_INDEX);
>> +    return glue(glue(helper_ret_ld, USUFFIX), _cmmu)(env, ptr, oi, 0);
>> +}
>> +
>> +#if DATA_SIZE <= 2
>> +static inline int
>> +glue(glue(cpu_lds, SUFFIX), _code)(CPUArchState *env, target_ulong ptr)
>> +{
>> +    return (DATA_STYPE)glue(glue(cpu_ld, USUFFIX), _code)(env, ptr);
>> +}
>>  #endif
>>  
>> -/* generic load/store macros */
>> +#else
>>  
>>  static inline RES_TYPE
>>  glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>>                                                    target_ulong ptr,
>>                                                    uintptr_t retaddr)
>>  {
>> -    CPUTLBEntry *entry;
>> -    RES_TYPE res;
>> -    target_ulong addr;
>> -    int mmu_idx = CPU_MMU_INDEX;
>> -    MemOp op = MO_TE | SHIFT;
>> -#if !defined(SOFTMMU_CODE_ACCESS)
>> -    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
>> -    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>> -#endif
>> -
>> -    addr = ptr;
>> -    entry = tlb_entry(env, mmu_idx, addr);
>> -    if (unlikely(entry->ADDR_READ !=
>> -                 (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
>> -        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
>> -        res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr,
>> -                                                               oi, retaddr);
>> -    } else {
>> -        uintptr_t hostaddr = addr + entry->addend;
>> -        res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr);
>> -    }
>> -#ifndef SOFTMMU_CODE_ACCESS
>> -    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
>> -#endif
>> -    return res;
>> +    return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
>> +                                                   retaddr);
>>  }
>>  
>>  static inline RES_TYPE
>>  glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
>>  {
>> -    return glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(env, ptr, 0);
>> +    return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
>>  }
>>  
>>  #if DATA_SIZE <= 2
>> @@ -121,42 +98,17 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>>                                                    target_ulong ptr,
>>                                                    uintptr_t retaddr)
>>  {
>> -    CPUTLBEntry *entry;
>> -    int res;
>> -    target_ulong addr;
>> -    int mmu_idx = CPU_MMU_INDEX;
>> -    MemOp op = MO_TE | MO_SIGN | SHIFT;
>> -#ifndef SOFTMMU_CODE_ACCESS
>> -    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
>> -    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>> -#endif
>> -
>> -    addr = ptr;
>> -    entry = tlb_entry(env, mmu_idx, addr);
>> -    if (unlikely(entry->ADDR_READ !=
>> -                 (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
>> -        TCGMemOpIdx oi = make_memop_idx(op & ~MO_SIGN, mmu_idx);
>> -        res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX),
>> -                               MMUSUFFIX)(env, addr, oi, retaddr);
>> -    } else {
>> -        uintptr_t hostaddr = addr + entry->addend;
>> -        res = glue(glue(lds, SUFFIX), _p)((uint8_t *)hostaddr);
>> -    }
>> -#ifndef SOFTMMU_CODE_ACCESS
>> -    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
>> -#endif
>> -    return res;
>> +    return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
>> +                                                   retaddr);
>>  }
>>  
>>  static inline int
>>  glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
>>  {
>> -    return glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(env, ptr, 0);
>> +    return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
>>  }
>>  #endif
>>  
>> -#ifndef SOFTMMU_CODE_ACCESS
>> -
>>  /* generic store macro */
>>  
>>  static inline void
>> @@ -164,36 +116,15 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
>>                                                   target_ulong ptr,
>>                                                   RES_TYPE v, uintptr_t retaddr)
>>  {
>> -    CPUTLBEntry *entry;
>> -    target_ulong addr;
>> -    int mmu_idx = CPU_MMU_INDEX;
>> -    MemOp op = MO_TE | SHIFT;
>> -#if !defined(SOFTMMU_CODE_ACCESS)
>> -    uint16_t meminfo = trace_mem_get_info(op, mmu_idx, true);
>> -    trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
>> -#endif
>> -
>> -    addr = ptr;
>> -    entry = tlb_entry(env, mmu_idx, addr);
>> -    if (unlikely(tlb_addr_write(entry) !=
>> -                 (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
>> -        TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
>> -        glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi,
>> -                                                     retaddr);
>> -    } else {
>> -        uintptr_t hostaddr = addr + entry->addend;
>> -        glue(glue(st, SUFFIX), _p)((uint8_t *)hostaddr, v);
>> -    }
>> -#ifndef SOFTMMU_CODE_ACCESS
>> -    qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
>> -#endif
>> +    glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX,
>> +                                           retaddr);
>>  }
>>  
>>  static inline void
>>  glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
>>                                        RES_TYPE v)
>>  {
>> -    glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(env, ptr, v, 0);
>> +    glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
>>  }
>>  
>>  #endif /* !SOFTMMU_CODE_ACCESS */
>> @@ -204,8 +135,4 @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
>>  #undef SUFFIX
>>  #undef USUFFIX
>>  #undef DATA_SIZE
>> -#undef MMUSUFFIX
>> -#undef ADDR_READ
>> -#undef URETSUFFIX
>> -#undef SRETSUFFIX
>>  #undef SHIFT
>> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
>> index 98221948d6..ddd19718bf 100644
>> --- a/accel/tcg/cputlb.c
>> +++ b/accel/tcg/cputlb.c
>> @@ -34,6 +34,9 @@
>>  #include "qemu/atomic.h"
>>  #include "qemu/atomic128.h"
>>  #include "translate-all.h"
>> +#include "trace-root.h"
>> +#include "qemu/plugin.h"
>> +#include "trace/mem.h"
>>  #ifdef CONFIG_PLUGIN
>>  #include "qemu/plugin-memory.h"
>>  #endif
>> @@ -1625,6 +1628,75 @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env, target_ulong addr,
>>      return (int32_t)helper_be_ldul_mmu(env, addr, oi, retaddr);
>>  }
>>  
>> +/*
>> + * Load helpers for cpu_ldst.h.
>> + */
>> +
>> +static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr,
>> +                                       int mmu_idx, uintptr_t retaddr,
>> +                                       MemOp op, FullLoadHelper *full_load)
>> +{
>> +    uint16_t meminfo;
>> +    TCGMemOpIdx oi;
>> +    uint64_t ret;
>> +
>> +    meminfo = trace_mem_get_info(op, mmu_idx, false);
>> +    trace_guest_mem_before_exec(env_cpu(env), addr, meminfo);
>> +
>> +    op &= ~MO_SIGN;
>> +    oi = make_memop_idx(op, mmu_idx);
>> +    ret = full_load(env, addr, oi, retaddr);
>> +
>> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, meminfo);
>> +
>> +    return ret;
>> +}
>> +
>> +uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                            int mmu_idx, uintptr_t ra)
>> +{
>> +    return cpu_load_helper(env, addr, mmu_idx, ra, MO_UB, full_ldub_mmu);
>> +}
>> +
>> +int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                       int mmu_idx, uintptr_t ra)
>> +{
>> +    return (int8_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_SB,
>> +                                   full_ldub_mmu);
>> +}
>> +
>> +uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                            int mmu_idx, uintptr_t ra)
>> +{
>> +    return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUW,
>> +                           MO_TE == MO_LE
>> +                           ? full_le_lduw_mmu : full_be_lduw_mmu);
>> +}
>> +
>> +int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                       int mmu_idx, uintptr_t ra)
>> +{
>> +    return (int16_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_TESW,
>> +                                    MO_TE == MO_LE
>> +                                    ? full_le_lduw_mmu : full_be_lduw_mmu);
>> +}
>> +
>> +uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                           int mmu_idx, uintptr_t ra)
>> +{
>> +    return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUL,
>> +                           MO_TE == MO_LE
>> +                           ? full_le_ldul_mmu : full_be_ldul_mmu);
>> +}
>> +
>> +uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>> +                           int mmu_idx, uintptr_t ra)
>> +{
>> +    return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEQ,
>> +                           MO_TE == MO_LE
>> +                           ? helper_le_ldq_mmu : helper_be_ldq_mmu);
>> +}
>> +
>>  /*
>>   * Store Helpers
>>   */
>> @@ -1854,6 +1926,50 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,
>>      store_helper(env, addr, val, oi, retaddr, MO_BEQ);
>>  }
>>  
>> +/*
>> + * Store Helpers for cpu_ldst.h
>> + */
>> +
>> +static inline void QEMU_ALWAYS_INLINE
>> +cpu_store_helper(CPUArchState *env, target_ulong addr, uint64_t val,
>> +                 int mmu_idx, uintptr_t retaddr, MemOp op)
>> +{
>> +    TCGMemOpIdx oi;
>> +    uint16_t meminfo;
>> +
>> +    meminfo = trace_mem_get_info(op, mmu_idx, true);
>> +    trace_guest_mem_before_exec(env_cpu(env), addr, meminfo);
>> +
>> +    oi = make_memop_idx(op, mmu_idx);
>> +    store_helper(env, addr, val, oi, retaddr, op);
>> +
>> +    qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, meminfo);
>> +}
>> +
>> +void cpu_stb_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
>> +                       int mmu_idx, uintptr_t retaddr)
>> +{
>> +    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_UB);
>> +}
>> +
>> +void cpu_stw_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
>> +                       int mmu_idx, uintptr_t retaddr)
>> +{
>> +    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUW);
>> +}
>> +
>> +void cpu_stl_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
>> +                       int mmu_idx, uintptr_t retaddr)
>> +{
>> +    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUL);
>> +}
>> +
>> +void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
>> +                       int mmu_idx, uintptr_t retaddr)
>> +{
>> +    cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEQ);
>> +}
>> +
>>  /* First set of helpers allows passing in of OI and RETADDR.  This makes
>>     them callable from other helpers.  */


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 04/28] cputlb: Move body of cpu_ldst_template.h out of line
  2019-12-16 22:11 ` [PATCH v2 04/28] cputlb: Move body of cpu_ldst_template.h out of line Richard Henderson
  2019-12-20 17:07   ` Alex Bennée
@ 2019-12-20 18:36   ` Alex Bennée
  2019-12-28 20:50     ` Richard Henderson
  1 sibling, 1 reply; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 18:36 UTC (permalink / raw)
  To: qemu-devel


Richard Henderson <richard.henderson@linaro.org> writes:

> With the tracing hooks, the inline functions are no longer
> so simple.  Once out-of-line, the current tlb_entry lookup
> is redundant with the one in the main load/store_helper.
>
> This also begins the introduction of a new target facing
> interface, with suffix *_mmuidx_ra.  This is not yet
> official because the interface is not done for user-only.
>
> Use abi_ptr instead of target_ulong in preparation for
> user-only; the two types are identical for softmmu.
>
> What remains in cpu_ldst_template.h are the expansions
> for _code, _data, and MMU_MODE<N>_SUFFIX.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  include/exec/cpu_ldst.h          |  25 ++++++-
>  include/exec/cpu_ldst_template.h | 125 +++++++------------------------
>  accel/tcg/cputlb.c               | 116 ++++++++++++++++++++++++++++
>  3 files changed, 166 insertions(+), 100 deletions(-)
>
> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
> index fd499f7e2f..cf8af36dbc 100644
> --- a/include/exec/cpu_ldst.h
> +++ b/include/exec/cpu_ldst.h
> @@ -152,7 +152,7 @@ static inline void clear_helper_retaddr(void)
>  
>  #else
>  
> -/* The memory helpers for tcg-generated code need tcg_target_long etc.  */
> +/* Needed for TCG_OVERSIZED_GUEST */
>  #include "tcg.h"
>  
>  static inline target_ulong tlb_addr_write(const CPUTLBEntry *entry)
> @@ -185,6 +185,29 @@ static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx,
>      return &env_tlb(env)->f[mmu_idx].table[tlb_index(env, mmu_idx, addr)];
>  }
>  
> +uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                            int mmu_idx, uintptr_t ra);
> +uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                            int mmu_idx, uintptr_t ra);
> +uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                           int mmu_idx, uintptr_t ra);
> +uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                           int mmu_idx, uintptr_t ra);
> +
> +int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                       int mmu_idx, uintptr_t ra);
> +int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
> +                       int mmu_idx, uintptr_t ra);
> +
> +void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
> +                       int mmu_idx, uintptr_t retaddr);
> +void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
> +                       int mmu_idx, uintptr_t retaddr);
> +void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
> +                       int mmu_idx, uintptr_t retaddr);
> +void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
> +                       int mmu_idx, uintptr_t retaddr);
> +
>  #ifdef MMU_MODE0_SUFFIX
>  #define CPU_MMU_INDEX 0
>  #define MEMSUFFIX MMU_MODE0_SUFFIX
> diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
> index 0ad5de3ef9..ea39e29c19 100644
> --- a/include/exec/cpu_ldst_template.h
> +++ b/include/exec/cpu_ldst_template.h
> @@ -24,13 +24,6 @@
>   * License along with this library; if not, see <http://www.gnu.org/licenses/>.
>   */
>  
> -#if !defined(SOFTMMU_CODE_ACCESS)
> -#include "trace-root.h"
> -#endif
> -
> -#include "qemu/plugin.h"
> -#include "trace/mem.h"

I think api.c needs to include trace/mem.h

-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 22/28] target/xtensa: Remove MMU_MODE{0,1,2,3}_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 22/28] target/xtensa: Remove MMU_MODE{0,1,2,3}_SUFFIX Richard Henderson
@ 2019-12-20 19:30   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 19:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov


Richard Henderson <richard.henderson@linaro.org> writes:

> The functions generated by these macros are unused.
>
> Acked-by: Max Filippov <jcmvbkbc@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/xtensa/cpu.h | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
> index b363ffcf10..f5a7ea48bb 100644
> --- a/target/xtensa/cpu.h
> +++ b/target/xtensa/cpu.h
> @@ -685,10 +685,6 @@ static inline uint32_t xtensa_replicate_windowstart(CPUXtensaState *env)
>  }
>  
>  /* MMU modes definitions */
> -#define MMU_MODE0_SUFFIX _ring0
> -#define MMU_MODE1_SUFFIX _ring1
> -#define MMU_MODE2_SUFFIX _ring2
> -#define MMU_MODE3_SUFFIX _ring3
>  #define MMU_USER_IDX 3
>  
>  static inline int cpu_mmu_index(CPUXtensaState *env, bool ifetch)


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 23/28] target/m68k: Use cpu_*_mmuidx_ra instead of MMU_MODE{0, 1}_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 23/28] target/m68k: Use cpu_*_mmuidx_ra instead of MMU_MODE{0, 1}_SUFFIX Richard Henderson
@ 2019-12-20 19:34   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 19:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier


Richard Henderson <richard.henderson@linaro.org> writes:

> The generated *_user functions are unused.  The *_kernel functions
> have a couple of users in op_helper.c; use *_mmuidx_ra instead,
> with MMU_KERNEL_IDX.
>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>


> ---
> v2: Use *_mmuidx_ra directly, without intermediate macros.
> ---
>  target/m68k/cpu.h       |  2 --
>  target/m68k/op_helper.c | 77 +++++++++++++++++++++++++----------------
>  2 files changed, 47 insertions(+), 32 deletions(-)
>
> diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
> index 20de3c379a..89af14e899 100644
> --- a/target/m68k/cpu.h
> +++ b/target/m68k/cpu.h
> @@ -516,8 +516,6 @@ enum {
>  #define cpu_list m68k_cpu_list
>  
>  /* MMU modes definitions */
> -#define MMU_MODE0_SUFFIX _kernel
> -#define MMU_MODE1_SUFFIX _user
>  #define MMU_KERNEL_IDX 0
>  #define MMU_USER_IDX 1
>  static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch)
> diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c
> index bc4f845e3f..202498deb5 100644
> --- a/target/m68k/op_helper.c
> +++ b/target/m68k/op_helper.c
> @@ -42,8 +42,8 @@ static void cf_rte(CPUM68KState *env)
>      uint32_t fmt;
>  
>      sp = env->aregs[7];
> -    fmt = cpu_ldl_kernel(env, sp);
> -    env->pc = cpu_ldl_kernel(env, sp + 4);
> +    fmt = cpu_ldl_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
> +    env->pc = cpu_ldl_mmuidx_ra(env, sp + 4, MMU_KERNEL_IDX, 0);
>      sp |= (fmt >> 28) & 3;
>      env->aregs[7] = sp + 8;
>  
> @@ -58,13 +58,13 @@ static void m68k_rte(CPUM68KState *env)
>  
>      sp = env->aregs[7];
>  throwaway:
> -    sr = cpu_lduw_kernel(env, sp);
> +    sr = cpu_lduw_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
>      sp += 2;
> -    env->pc = cpu_ldl_kernel(env, sp);
> +    env->pc = cpu_ldl_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
>      sp += 4;
>      if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) {
>          /*  all except 68000 */
> -        fmt = cpu_lduw_kernel(env, sp);
> +        fmt = cpu_lduw_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
>          sp += 2;
>          switch (fmt >> 12) {
>          case 0:
> @@ -260,12 +260,12 @@ static void cf_interrupt_all(CPUM68KState *env, int is_hw)
>      /* ??? This could cause MMU faults.  */
>      sp &= ~3;
>      sp -= 4;
> -    cpu_stl_kernel(env, sp, retaddr);
> +    cpu_stl_mmuidx_ra(env, sp, retaddr, MMU_KERNEL_IDX, 0);
>      sp -= 4;
> -    cpu_stl_kernel(env, sp, fmt);
> +    cpu_stl_mmuidx_ra(env, sp, fmt, MMU_KERNEL_IDX, 0);
>      env->aregs[7] = sp;
>      /* Jump to vector.  */
> -    env->pc = cpu_ldl_kernel(env, env->vbr + vector);
> +    env->pc = cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, 0);
>  }
>  
>  static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
> @@ -278,23 +278,24 @@ static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
>          switch (format) {
>          case 4:
>              *sp -= 4;
> -            cpu_stl_kernel(env, *sp, env->pc);
> +            cpu_stl_mmuidx_ra(env, *sp, env->pc, MMU_KERNEL_IDX, 0);
>              *sp -= 4;
> -            cpu_stl_kernel(env, *sp, addr);
> +            cpu_stl_mmuidx_ra(env, *sp, addr, MMU_KERNEL_IDX, 0);
>              break;
>          case 3:
>          case 2:
>              *sp -= 4;
> -            cpu_stl_kernel(env, *sp, addr);
> +            cpu_stl_mmuidx_ra(env, *sp, addr, MMU_KERNEL_IDX, 0);
>              break;
>          }
>          *sp -= 2;
> -        cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2));
> +        cpu_stw_mmuidx_ra(env, *sp, (format << 12) + (cs->exception_index << 2),
> +                          MMU_KERNEL_IDX, 0);
>      }
>      *sp -= 4;
> -    cpu_stl_kernel(env, *sp, retaddr);
> +    cpu_stl_mmuidx_ra(env, *sp, retaddr, MMU_KERNEL_IDX, 0);
>      *sp -= 2;
> -    cpu_stw_kernel(env, *sp, sr);
> +    cpu_stw_mmuidx_ra(env, *sp, sr, MMU_KERNEL_IDX, 0);
>  }
>  
>  static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
> @@ -353,36 +354,52 @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
>              cpu_abort(cs, "DOUBLE MMU FAULT\n");
>          }
>          env->mmu.fault = true;
> +        /* push data 3 */
>          sp -= 4;
> -        cpu_stl_kernel(env, sp, 0); /* push data 3 */
> +        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
> +        /* push data 2 */
>          sp -= 4;
> -        cpu_stl_kernel(env, sp, 0); /* push data 2 */
> +        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
> +        /* push data 1 */
>          sp -= 4;
> -        cpu_stl_kernel(env, sp, 0); /* push data 1 */
> +        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
> +        /* write back 1 / push data 0 */
>          sp -= 4;
> -        cpu_stl_kernel(env, sp, 0); /* write back 1 / push data 0 */
> +        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
> +        /* write back 1 address */
>          sp -= 4;
> -        cpu_stl_kernel(env, sp, 0); /* write back 1 address */
> +        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
> +        /* write back 2 data */
>          sp -= 4;
> -        cpu_stl_kernel(env, sp, 0); /* write back 2 data */
> +        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
> +        /* write back 2 address */
>          sp -= 4;
> -        cpu_stl_kernel(env, sp, 0); /* write back 2 address */
> +        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
> +        /* write back 3 data */
>          sp -= 4;
> -        cpu_stl_kernel(env, sp, 0); /* write back 3 data */
> +        cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
> +        /* write back 3 address */
>          sp -= 4;
> -        cpu_stl_kernel(env, sp, env->mmu.ar); /* write back 3 address */
> +        cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
> +        /* fault address */
>          sp -= 4;
> -        cpu_stl_kernel(env, sp, env->mmu.ar); /* fault address */
> +        cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
> +        /* write back 1 status */
>          sp -= 2;
> -        cpu_stw_kernel(env, sp, 0); /* write back 1 status */
> +        cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
> +        /* write back 2 status */
>          sp -= 2;
> -        cpu_stw_kernel(env, sp, 0); /* write back 2 status */
> +        cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
> +        /* write back 3 status */
>          sp -= 2;
> -        cpu_stw_kernel(env, sp, 0); /* write back 3 status */
> +        cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
> +        /* special status word */
>          sp -= 2;
> -        cpu_stw_kernel(env, sp, env->mmu.ssw); /* special status word */
> +        cpu_stw_mmuidx_ra(env, sp, env->mmu.ssw, MMU_KERNEL_IDX, 0);
> +        /* effective address */
>          sp -= 4;
> -        cpu_stl_kernel(env, sp, env->mmu.ar); /* effective address */
> +        cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
> +
>          do_stack_frame(env, &sp, 7, oldsr, 0, retaddr);
>          env->mmu.fault = false;
>          if (qemu_loglevel_mask(CPU_LOG_INT)) {
> @@ -414,7 +431,7 @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
>  
>      env->aregs[7] = sp;
>      /* Jump to vector.  */
> -    env->pc = cpu_ldl_kernel(env, env->vbr + vector);
> +    env->pc = cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, 0);
>  }
>  
>  static void do_interrupt_all(CPUM68KState *env, int is_hw)


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 24/28] target/mips: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 24/28] target/mips: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX Richard Henderson
@ 2019-12-20 19:37   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 19:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aleksandar Rikalo, Aurelien Jarno, Aleksandar Markovic


Richard Henderson <richard.henderson@linaro.org> writes:

> The separate suffixed functions were used to construct
> some do_##insn function switched on mmu_idx.  The interface
> is exactly identical to the *_mmuidx_ra functions.  Replace
> them directly and remove the constructions.
>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>
> Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  target/mips/cpu.h       |   4 -
>  target/mips/op_helper.c | 182 +++++++++++++---------------------------
>  2 files changed, 60 insertions(+), 126 deletions(-)
>
> diff --git a/target/mips/cpu.h b/target/mips/cpu.h
> index ca00f41daf..c218ccc4a8 100644
> --- a/target/mips/cpu.h
> +++ b/target/mips/cpu.h
> @@ -1147,10 +1147,6 @@ extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env);
>   * MMU modes definitions. We carefully match the indices with our
>   * hflags layout.
>   */
> -#define MMU_MODE0_SUFFIX _kernel
> -#define MMU_MODE1_SUFFIX _super
> -#define MMU_MODE2_SUFFIX _user
> -#define MMU_MODE3_SUFFIX _error
>  #define MMU_USER_IDX 2
>  
>  static inline int hflags_mmu_index(uint32_t hflags)
> diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c
> index 18fcee4a78..79d44da6fa 100644
> --- a/target/mips/op_helper.c
> +++ b/target/mips/op_helper.c
> @@ -52,69 +52,6 @@ static void raise_exception(CPUMIPSState *env, uint32_t exception)
>      do_raise_exception(env, exception, 0);
>  }
>  
> -#if defined(CONFIG_USER_ONLY)
> -#define HELPER_LD(name, insn, type)                                     \
> -static inline type do_##name(CPUMIPSState *env, target_ulong addr,      \
> -                             int mem_idx, uintptr_t retaddr)            \
> -{                                                                       \
> -    return (type) cpu_##insn##_data_ra(env, addr, retaddr);             \
> -}
> -#else
> -#define HELPER_LD(name, insn, type)                                     \
> -static inline type do_##name(CPUMIPSState *env, target_ulong addr,      \
> -                             int mem_idx, uintptr_t retaddr)            \
> -{                                                                       \
> -    switch (mem_idx) {                                                  \
> -    case 0: return (type) cpu_##insn##_kernel_ra(env, addr, retaddr);   \
> -    case 1: return (type) cpu_##insn##_super_ra(env, addr, retaddr);    \
> -    default:                                                            \
> -    case 2: return (type) cpu_##insn##_user_ra(env, addr, retaddr);     \
> -    case 3: return (type) cpu_##insn##_error_ra(env, addr, retaddr);    \
> -    }                                                                   \
> -}
> -#endif
> -HELPER_LD(lw, ldl, int32_t)
> -#if defined(TARGET_MIPS64)
> -HELPER_LD(ld, ldq, int64_t)
> -#endif
> -#undef HELPER_LD
> -
> -#if defined(CONFIG_USER_ONLY)
> -#define HELPER_ST(name, insn, type)                                     \
> -static inline void do_##name(CPUMIPSState *env, target_ulong addr,      \
> -                             type val, int mem_idx, uintptr_t retaddr)  \
> -{                                                                       \
> -    cpu_##insn##_data_ra(env, addr, val, retaddr);                      \
> -}
> -#else
> -#define HELPER_ST(name, insn, type)                                     \
> -static inline void do_##name(CPUMIPSState *env, target_ulong addr,      \
> -                             type val, int mem_idx, uintptr_t retaddr)  \
> -{                                                                       \
> -    switch (mem_idx) {                                                  \
> -    case 0:                                                             \
> -        cpu_##insn##_kernel_ra(env, addr, val, retaddr);                \
> -        break;                                                          \
> -    case 1:                                                             \
> -        cpu_##insn##_super_ra(env, addr, val, retaddr);                 \
> -        break;                                                          \
> -    default:                                                            \
> -    case 2:                                                             \
> -        cpu_##insn##_user_ra(env, addr, val, retaddr);                  \
> -        break;                                                          \
> -    case 3:                                                             \
> -        cpu_##insn##_error_ra(env, addr, val, retaddr);                 \
> -        break;                                                          \
> -    }                                                                   \
> -}
> -#endif
> -HELPER_ST(sb, stb, uint8_t)
> -HELPER_ST(sw, stl, uint32_t)
> -#if defined(TARGET_MIPS64)
> -HELPER_ST(sd, stq, uint64_t)
> -#endif
> -#undef HELPER_ST
> -
>  /* 64 bits arithmetic for 32 bits hosts */
>  static inline uint64_t get_HILO(CPUMIPSState *env)
>  {
> @@ -379,12 +316,12 @@ target_ulong helper_##name(CPUMIPSState *env, target_ulong arg, int mem_idx)  \
>      }                                                                         \
>      env->CP0_LLAddr = do_translate_address(env, arg, 0, GETPC());             \
>      env->lladdr = arg;                                                        \
> -    env->llval = do_##insn(env, arg, mem_idx, GETPC());                       \
> +    env->llval = cpu_##insn##_mmuidx_ra(env, arg, mem_idx, GETPC());          \
>      return env->llval;                                                        \
>  }
> -HELPER_LD_ATOMIC(ll, lw, 0x3)
> +HELPER_LD_ATOMIC(ll, ldl, 0x3)
>  #ifdef TARGET_MIPS64
> -HELPER_LD_ATOMIC(lld, ld, 0x7)
> +HELPER_LD_ATOMIC(lld, ldq, 0x7)
>  #endif
>  #undef HELPER_LD_ATOMIC
>  #endif
> @@ -400,42 +337,42 @@ HELPER_LD_ATOMIC(lld, ld, 0x7)
>  void helper_swl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
>                  int mem_idx)
>  {
> -    do_sb(env, arg2, (uint8_t)(arg1 >> 24), mem_idx, GETPC());
> +    cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 24), mem_idx, GETPC());
>  
>      if (GET_LMASK(arg2) <= 2) {
> -        do_sb(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 16), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 16),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK(arg2) <= 1) {
> -        do_sb(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 8), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 8),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK(arg2) == 0) {
> -        do_sb(env, GET_OFFSET(arg2, 3), (uint8_t)arg1, mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)arg1,
> +                          mem_idx, GETPC());
>      }
>  }
>  
>  void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
>                  int mem_idx)
>  {
> -    do_sb(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
> +    cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
>  
>      if (GET_LMASK(arg2) >= 1) {
> -        do_sb(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK(arg2) >= 2) {
> -        do_sb(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK(arg2) == 3) {
> -        do_sb(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
> +                          mem_idx, GETPC());
>      }
>  }
>  
> @@ -453,82 +390,82 @@ void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
>  void helper_sdl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
>                  int mem_idx)
>  {
> -    do_sb(env, arg2, (uint8_t)(arg1 >> 56), mem_idx, GETPC());
> +    cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 56), mem_idx, GETPC());
>  
>      if (GET_LMASK64(arg2) <= 6) {
> -        do_sb(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 48), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 48),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) <= 5) {
> -        do_sb(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 40), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 40),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) <= 4) {
> -        do_sb(env, GET_OFFSET(arg2, 3), (uint8_t)(arg1 >> 32), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)(arg1 >> 32),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) <= 3) {
> -        do_sb(env, GET_OFFSET(arg2, 4), (uint8_t)(arg1 >> 24), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 4), (uint8_t)(arg1 >> 24),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) <= 2) {
> -        do_sb(env, GET_OFFSET(arg2, 5), (uint8_t)(arg1 >> 16), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 5), (uint8_t)(arg1 >> 16),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) <= 1) {
> -        do_sb(env, GET_OFFSET(arg2, 6), (uint8_t)(arg1 >> 8), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 6), (uint8_t)(arg1 >> 8),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) <= 0) {
> -        do_sb(env, GET_OFFSET(arg2, 7), (uint8_t)arg1, mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 7), (uint8_t)arg1,
> +                          mem_idx, GETPC());
>      }
>  }
>  
>  void helper_sdr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
>                  int mem_idx)
>  {
> -    do_sb(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
> +    cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
>  
>      if (GET_LMASK64(arg2) >= 1) {
> -        do_sb(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) >= 2) {
> -        do_sb(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) >= 3) {
> -        do_sb(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) >= 4) {
> -        do_sb(env, GET_OFFSET(arg2, -4), (uint8_t)(arg1 >> 32), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -4), (uint8_t)(arg1 >> 32),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) >= 5) {
> -        do_sb(env, GET_OFFSET(arg2, -5), (uint8_t)(arg1 >> 40), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -5), (uint8_t)(arg1 >> 40),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) >= 6) {
> -        do_sb(env, GET_OFFSET(arg2, -6), (uint8_t)(arg1 >> 48), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -6), (uint8_t)(arg1 >> 48),
> +                          mem_idx, GETPC());
>      }
>  
>      if (GET_LMASK64(arg2) == 7) {
> -        do_sb(env, GET_OFFSET(arg2, -7), (uint8_t)(arg1 >> 56), mem_idx,
> -              GETPC());
> +        cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -7), (uint8_t)(arg1 >> 56),
> +                          mem_idx, GETPC());
>      }
>  }
>  #endif /* TARGET_MIPS64 */
> @@ -546,14 +483,14 @@ void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
>  
>          for (i = 0; i < base_reglist; i++) {
>              env->active_tc.gpr[multiple_regs[i]] =
> -                (target_long)do_lw(env, addr, mem_idx, GETPC());
> +                (target_long)cpu_ldl_mmuidx_ra(env, addr, mem_idx, GETPC());
>              addr += 4;
>          }
>      }
>  
>      if (do_r31) {
> -        env->active_tc.gpr[31] = (target_long)do_lw(env, addr, mem_idx,
> -                                                    GETPC());
> +        env->active_tc.gpr[31] =
> +            (target_long)cpu_ldl_mmuidx_ra(env, addr, mem_idx, GETPC());
>      }
>  }
>  
> @@ -567,14 +504,14 @@ void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
>          target_ulong i;
>  
>          for (i = 0; i < base_reglist; i++) {
> -            do_sw(env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx,
> -                  GETPC());
> +            cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
> +                              mem_idx, GETPC());
>              addr += 4;
>          }
>      }
>  
>      if (do_r31) {
> -        do_sw(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
> +        cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
>      }
>  }
>  
> @@ -589,14 +526,15 @@ void helper_ldm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
>          target_ulong i;
>  
>          for (i = 0; i < base_reglist; i++) {
> -            env->active_tc.gpr[multiple_regs[i]] = do_ld(env, addr, mem_idx,
> -                                                         GETPC());
> +            env->active_tc.gpr[multiple_regs[i]] =
> +                cpu_ldq_mmuidx_ra(env, addr, mem_idx, GETPC());
>              addr += 8;
>          }
>      }
>  
>      if (do_r31) {
> -        env->active_tc.gpr[31] = do_ld(env, addr, mem_idx, GETPC());
> +        env->active_tc.gpr[31] =
> +            cpu_ldq_mmuidx_ra(env, addr, mem_idx, GETPC());
>      }
>  }
>  
> @@ -610,14 +548,14 @@ void helper_sdm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
>          target_ulong i;
>  
>          for (i = 0; i < base_reglist; i++) {
> -            do_sd(env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx,
> -                  GETPC());
> +            cpu_stq_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
> +                              mem_idx, GETPC());
>              addr += 8;
>          }
>      }
>  
>      if (do_r31) {
> -        do_sd(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
> +        cpu_stq_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
>      }
>  }
>  #endif


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 25/28] target/s390x: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 25/28] target/s390x: " Richard Henderson
@ 2019-12-20 19:39   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Hildenbrand


Richard Henderson <richard.henderson@linaro.org> writes:

> The generated functions aside from *_real are unused.
> The *_real functions have a couple of users in mem_helper.c;
> use *_mmuidx_ra instead, with MMU_REAL_IDX.
>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

FYI there is a merge conflict with master as some of the helpers have
been replaced with inline code (by you ;-).

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
> v2: Use *_mmuidx_ra directly, without intermediate macros.
> ---
>  target/s390x/cpu.h        |  5 -----
>  target/s390x/mem_helper.c | 21 ++++++++++++---------
>  2 files changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index aa829e954c..cfa8a81265 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
> @@ -36,11 +36,6 @@
>  
>  #define TARGET_INSN_START_EXTRA_WORDS 2
>  
> -#define MMU_MODE0_SUFFIX _primary
> -#define MMU_MODE1_SUFFIX _secondary
> -#define MMU_MODE2_SUFFIX _home
> -#define MMU_MODE3_SUFFIX _real
> -
>  #define MMU_USER_IDX 0
>  
>  #define S390_MAX_CPUS 248
> diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
> index 57ce17c252..6f4a16b9b2 100644
> --- a/target/s390x/mem_helper.c
> +++ b/target/s390x/mem_helper.c
> @@ -2026,7 +2026,7 @@ uint32_t HELPER(testblock)(CPUS390XState *env, uint64_t real_addr)
>      real_addr = wrap_address(env, real_addr) & TARGET_PAGE_MASK;
>  
>      for (i = 0; i < TARGET_PAGE_SIZE; i += 8) {
> -        cpu_stq_real_ra(env, real_addr + i, 0, ra);
> +        cpu_stq_mmuidx_ra(env, real_addr + i, 0, MMU_REAL_IDX, ra);
>      }
>  
>      return 0;
> @@ -2260,11 +2260,11 @@ void HELPER(idte)(CPUS390XState *env, uint64_t r1, uint64_t r2, uint32_t m4)
>          for (i = 0; i < entries; i++) {
>              /* addresses are not wrapped in 24/31bit mode but table index is */
>              raddr = table + ((index + i) & 0x7ff) * sizeof(entry);
> -            entry = cpu_ldq_real_ra(env, raddr, ra);
> +            entry = cpu_ldq_mmuidx_ra(env, raddr, MMU_REAL_IDX, ra);
>              if (!(entry & REGION_ENTRY_I)) {
>                  /* we are allowed to not store if already invalid */
>                  entry |= REGION_ENTRY_I;
> -                cpu_stq_real_ra(env, raddr, entry, ra);
> +                cpu_stq_mmuidx_ra(env, raddr, entry, MMU_REAL_IDX, ra);
>              }
>          }
>      }
> @@ -2291,9 +2291,9 @@ void HELPER(ipte)(CPUS390XState *env, uint64_t pto, uint64_t vaddr,
>      pte_addr += VADDR_PAGE_TX(vaddr) * 8;
>  
>      /* Mark the page table entry as invalid */
> -    pte = cpu_ldq_real_ra(env, pte_addr, ra);
> +    pte = cpu_ldq_mmuidx_ra(env, pte_addr, MMU_REAL_IDX, ra);
>      pte |= PAGE_ENTRY_I;
> -    cpu_stq_real_ra(env, pte_addr, pte, ra);
> +    cpu_stq_mmuidx_ra(env, pte_addr, pte, MMU_REAL_IDX, ra);
>  
>      /* XXX we exploit the fact that Linux passes the exact virtual
>         address here - it's not obliged to! */
> @@ -2333,18 +2333,21 @@ void HELPER(purge)(CPUS390XState *env)
>  /* load using real address */
>  uint64_t HELPER(lura)(CPUS390XState *env, uint64_t addr)
>  {
> -    return cpu_ldl_real_ra(env, wrap_address(env, addr), GETPC());
> +    return cpu_ldl_mmuidx_ra(env, wrap_address(env, addr),
> +                             MMU_REAL_IDX, GETPC());
>  }
>  
>  uint64_t HELPER(lurag)(CPUS390XState *env, uint64_t addr)
>  {
> -    return cpu_ldq_real_ra(env, wrap_address(env, addr), GETPC());
> +    return cpu_ldq_mmuidx_ra(env, wrap_address(env, addr),
> +                             MMU_REAL_IDX, GETPC());
>  }
>  
>  /* store using real address */
>  void HELPER(stura)(CPUS390XState *env, uint64_t addr, uint64_t v1)
>  {
> -    cpu_stl_real_ra(env, wrap_address(env, addr), (uint32_t)v1, GETPC());
> +    cpu_stl_mmuidx_ra(env, wrap_address(env, addr), (uint32_t)v1,
> +                      MMU_REAL_IDX, GETPC());
>  
>      if ((env->psw.mask & PSW_MASK_PER) &&
>          (env->cregs[9] & PER_CR9_EVENT_STORE) &&
> @@ -2357,7 +2360,7 @@ void HELPER(stura)(CPUS390XState *env, uint64_t addr, uint64_t v1)
>  
>  void HELPER(sturg)(CPUS390XState *env, uint64_t addr, uint64_t v1)
>  {
> -    cpu_stq_real_ra(env, wrap_address(env, addr), v1, GETPC());
> +    cpu_stq_mmuidx_ra(env, wrap_address(env, addr), v1, MMU_REAL_IDX, GETPC());
>  
>      if ((env->psw.mask & PSW_MASK_PER) &&
>          (env->cregs[9] & PER_CR9_EVENT_STORE) &&


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 26/28] target/ppc: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 26/28] target/ppc: " Richard Henderson
@ 2019-12-20 19:51   ` Alex Bennée
  2019-12-28 21:18     ` Richard Henderson
  0 siblings, 1 reply; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 19:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson


Richard Henderson <richard.henderson@linaro.org> writes:

> There are only two uses.  Within dcbz_common, the local variable
> mmu_idx already contains the epid computation, and we can avoid
> repeating it for the store.  Within helper_icbiep, the usage is
> trivially expanded using PPC_TLB_EPID_LOAD.
>
> Acked-by: David Gibson <david@gibson.dropbear.id.au>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  target/ppc/cpu.h        |  2 --
>  target/ppc/mem_helper.c | 11 ++---------
>  2 files changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index e3e82327b7..3bd983adaa 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -951,8 +951,6 @@ struct ppc_radix_page_info {
>   * + real/paged mode combinations. The other two modes are for
>   * external PID load/store.
>   */
> -#define MMU_MODE8_SUFFIX _epl
> -#define MMU_MODE9_SUFFIX _eps
>  #define PPC_TLB_EPID_LOAD 8
>  #define PPC_TLB_EPID_STORE 9
>  
> diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
> index 1351b53f28..56855f2381 100644
> --- a/target/ppc/mem_helper.c
> +++ b/target/ppc/mem_helper.c
> @@ -177,14 +177,7 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr,
>      } else {
>          /* Slow path */
>          for (i = 0; i < dcbz_size; i += 8) {
> -            if (epid) {
> -#if !defined(CONFIG_USER_ONLY)
> -                /* Does not make sense on USER_ONLY config */
> -                cpu_stq_eps_ra(env, addr + i, 0, retaddr);
> -#endif
> -            } else {
> -                cpu_stq_data_ra(env, addr + i, 0, retaddr);
> -            }
> +            cpu_stq_mmuidx_ra(env, addr + i, 0, mmu_idx, retaddr);

I assume the possibility of a user-mode with epid is elided in the
translation phase by avoiding gen_dcbzep although I can't quite see
where they get called from. Anyway:

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

>          }
>      }
>  }
> @@ -216,7 +209,7 @@ void helper_icbiep(CPUPPCState *env, target_ulong addr)
>  #if !defined(CONFIG_USER_ONLY)
>      /* See comments above */
>      addr &= ~(env->dcache_line_size - 1);
> -    cpu_ldl_epl_ra(env, addr, GETPC());
> +    cpu_ldl_mmuidx_ra(env, addr, PPC_TLB_EPID_LOAD, GETPC());
>  #endif
>  }


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 27/28] cputlb: Remove support for MMU_MODE*_SUFFIX
  2019-12-16 22:11 ` [PATCH v2 27/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
@ 2019-12-20 19:52   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 19:52 UTC (permalink / raw)
  To: qemu-devel


Richard Henderson <richard.henderson@linaro.org> writes:

> All users have now been converted to cpu_*_mmuidx_ra.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  include/exec/cpu_ldst.h | 230 ----------------------------------------
>  1 file changed, 230 deletions(-)
>
> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
> index 0f3c49a005..cf4652bf48 100644
> --- a/include/exec/cpu_ldst.h
> +++ b/include/exec/cpu_ldst.h
> @@ -271,236 +271,6 @@ void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
>  void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
>                         int mmu_idx, uintptr_t retaddr);
>  
> -#ifdef MMU_MODE0_SUFFIX
> -#define CPU_MMU_INDEX 0
> -#define MEMSUFFIX MMU_MODE0_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif
> -
> -#if (NB_MMU_MODES >= 2) && defined(MMU_MODE1_SUFFIX)
> -#define CPU_MMU_INDEX 1
> -#define MEMSUFFIX MMU_MODE1_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif
> -
> -#if (NB_MMU_MODES >= 3) && defined(MMU_MODE2_SUFFIX)
> -
> -#define CPU_MMU_INDEX 2
> -#define MEMSUFFIX MMU_MODE2_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif /* (NB_MMU_MODES >= 3) */
> -
> -#if (NB_MMU_MODES >= 4) && defined(MMU_MODE3_SUFFIX)
> -
> -#define CPU_MMU_INDEX 3
> -#define MEMSUFFIX MMU_MODE3_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif /* (NB_MMU_MODES >= 4) */
> -
> -#if (NB_MMU_MODES >= 5) && defined(MMU_MODE4_SUFFIX)
> -
> -#define CPU_MMU_INDEX 4
> -#define MEMSUFFIX MMU_MODE4_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif /* (NB_MMU_MODES >= 5) */
> -
> -#if (NB_MMU_MODES >= 6) && defined(MMU_MODE5_SUFFIX)
> -
> -#define CPU_MMU_INDEX 5
> -#define MEMSUFFIX MMU_MODE5_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif /* (NB_MMU_MODES >= 6) */
> -
> -#if (NB_MMU_MODES >= 7) && defined(MMU_MODE6_SUFFIX)
> -
> -#define CPU_MMU_INDEX 6
> -#define MEMSUFFIX MMU_MODE6_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif /* (NB_MMU_MODES >= 7) */
> -
> -#if (NB_MMU_MODES >= 8) && defined(MMU_MODE7_SUFFIX)
> -
> -#define CPU_MMU_INDEX 7
> -#define MEMSUFFIX MMU_MODE7_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif /* (NB_MMU_MODES >= 8) */
> -
> -#if (NB_MMU_MODES >= 9) && defined(MMU_MODE8_SUFFIX)
> -
> -#define CPU_MMU_INDEX 8
> -#define MEMSUFFIX MMU_MODE8_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif /* (NB_MMU_MODES >= 9) */
> -
> -#if (NB_MMU_MODES >= 10) && defined(MMU_MODE9_SUFFIX)
> -
> -#define CPU_MMU_INDEX 9
> -#define MEMSUFFIX MMU_MODE9_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif /* (NB_MMU_MODES >= 10) */
> -
> -#if (NB_MMU_MODES >= 11) && defined(MMU_MODE10_SUFFIX)
> -
> -#define CPU_MMU_INDEX 10
> -#define MEMSUFFIX MMU_MODE10_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif /* (NB_MMU_MODES >= 11) */
> -
> -#if (NB_MMU_MODES >= 12) && defined(MMU_MODE11_SUFFIX)
> -
> -#define CPU_MMU_INDEX 11
> -#define MEMSUFFIX MMU_MODE11_SUFFIX
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -#endif /* (NB_MMU_MODES >= 12) */
> -
> -#if (NB_MMU_MODES > 12)
> -#error "NB_MMU_MODES > 12 is not supported for now"
> -#endif /* (NB_MMU_MODES > 12) */
> -
>  /* these access are slower, they must be as rare as possible */
>  #define CPU_MMU_INDEX (cpu_mmu_index(env, false))
>  #define MEMSUFFIX _data


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 28/28] cputlb: Expand cpu_ldst_template.h in cputlb.c
  2019-12-16 22:11 ` [PATCH v2 28/28] cputlb: Expand cpu_ldst_template.h in cputlb.c Richard Henderson
@ 2019-12-20 19:53   ` Alex Bennée
  0 siblings, 0 replies; 66+ messages in thread
From: Alex Bennée @ 2019-12-20 19:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aleksandar Markovic


Richard Henderson <richard.henderson@linaro.org> writes:

> Reduce the amount of preprocessor obfuscation by expanding
> the text of each of the functions generated.  The result is
> only slightly smaller than the original.
>
> Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

\o/

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  include/exec/cpu_ldst.h          |  67 +++++++-----------
>  include/exec/cpu_ldst_template.h | 117 -------------------------------
>  accel/tcg/cputlb.c               | 107 +++++++++++++++++++++++++++-
>  3 files changed, 130 insertions(+), 161 deletions(-)
>  delete mode 100644 include/exec/cpu_ldst_template.h
>
> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
> index cf4652bf48..62f38d5a22 100644
> --- a/include/exec/cpu_ldst.h
> +++ b/include/exec/cpu_ldst.h
> @@ -94,32 +94,6 @@ typedef target_ulong abi_ptr;
>  #define TARGET_ABI_FMT_ptr TARGET_ABI_FMT_lx
>  #endif
>  
> -#if defined(CONFIG_USER_ONLY)
> -
> -extern __thread uintptr_t helper_retaddr;
> -
> -static inline void set_helper_retaddr(uintptr_t ra)
> -{
> -    helper_retaddr = ra;
> -    /*
> -     * Ensure that this write is visible to the SIGSEGV handler that
> -     * may be invoked due to a subsequent invalid memory operation.
> -     */
> -    signal_barrier();
> -}
> -
> -static inline void clear_helper_retaddr(void)
> -{
> -    /*
> -     * Ensure that previous memory operations have succeeded before
> -     * removing the data visible to the signal handler.
> -     */
> -    signal_barrier();
> -    helper_retaddr = 0;
> -}
> -
> -/* In user-only mode we provide only the _code and _data accessors. */
> -
>  uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr);
>  uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr);
>  uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr);
> @@ -148,6 +122,30 @@ void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
>  void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
>                       uint64_t val, uintptr_t retaddr);
>  
> +#if defined(CONFIG_USER_ONLY)
> +
> +extern __thread uintptr_t helper_retaddr;
> +
> +static inline void set_helper_retaddr(uintptr_t ra)
> +{
> +    helper_retaddr = ra;
> +    /*
> +     * Ensure that this write is visible to the SIGSEGV handler that
> +     * may be invoked due to a subsequent invalid memory operation.
> +     */
> +    signal_barrier();
> +}
> +
> +static inline void clear_helper_retaddr(void)
> +{
> +    /*
> +     * Ensure that previous memory operations have succeeded before
> +     * removing the data visible to the signal handler.
> +     */
> +    signal_barrier();
> +    helper_retaddr = 0;
> +}
> +
>  /*
>   * Provide the same *_mmuidx_ra interface as for softmmu.
>   * The mmu_idx argument is ignored.
> @@ -271,23 +269,6 @@ void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
>  void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
>                         int mmu_idx, uintptr_t retaddr);
>  
> -/* these access are slower, they must be as rare as possible */
> -#define CPU_MMU_INDEX (cpu_mmu_index(env, false))
> -#define MEMSUFFIX _data
> -#define DATA_SIZE 1
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 2
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 4
> -#include "exec/cpu_ldst_template.h"
> -
> -#define DATA_SIZE 8
> -#include "exec/cpu_ldst_template.h"
> -#undef CPU_MMU_INDEX
> -#undef MEMSUFFIX
> -
>  #endif /* defined(CONFIG_USER_ONLY) */
>  
>  uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
> diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
> deleted file mode 100644
> index e400979f23..0000000000
> --- a/include/exec/cpu_ldst_template.h
> +++ /dev/null
> @@ -1,117 +0,0 @@
> -/*
> - *  Software MMU support
> - *
> - * Generate inline load/store functions for one MMU mode and data
> - * size.
> - *
> - * Generate a store function as well as signed and unsigned loads.
> - *
> - * Not used directly but included from cpu_ldst.h.
> - *
> - *  Copyright (c) 2003 Fabrice Bellard
> - *
> - * 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/>.
> - */
> -
> -#if DATA_SIZE == 8
> -#define SUFFIX q
> -#define USUFFIX q
> -#define DATA_TYPE uint64_t
> -#define SHIFT 3
> -#elif DATA_SIZE == 4
> -#define SUFFIX l
> -#define USUFFIX l
> -#define DATA_TYPE uint32_t
> -#define SHIFT 2
> -#elif DATA_SIZE == 2
> -#define SUFFIX w
> -#define USUFFIX uw
> -#define DATA_TYPE uint16_t
> -#define DATA_STYPE int16_t
> -#define SHIFT 1
> -#elif DATA_SIZE == 1
> -#define SUFFIX b
> -#define USUFFIX ub
> -#define DATA_TYPE uint8_t
> -#define DATA_STYPE int8_t
> -#define SHIFT 0
> -#else
> -#error unsupported data size
> -#endif
> -
> -#if DATA_SIZE == 8
> -#define RES_TYPE uint64_t
> -#else
> -#define RES_TYPE uint32_t
> -#endif
> -
> -/* generic load/store macros */
> -
> -static inline RES_TYPE
> -glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
> -                                                  target_ulong ptr,
> -                                                  uintptr_t retaddr)
> -{
> -    return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
> -                                                   retaddr);
> -}
> -
> -static inline RES_TYPE
> -glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
> -{
> -    return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
> -}
> -
> -#if DATA_SIZE <= 2
> -static inline int
> -glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
> -                                                  target_ulong ptr,
> -                                                  uintptr_t retaddr)
> -{
> -    return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
> -                                                   retaddr);
> -}
> -
> -static inline int
> -glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
> -{
> -    return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
> -}
> -#endif
> -
> -/* generic store macro */
> -
> -static inline void
> -glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
> -                                                 target_ulong ptr,
> -                                                 RES_TYPE v, uintptr_t retaddr)
> -{
> -    glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX,
> -                                           retaddr);
> -}
> -
> -static inline void
> -glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
> -                                      RES_TYPE v)
> -{
> -    glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
> -}
> -
> -#undef RES_TYPE
> -#undef DATA_TYPE
> -#undef DATA_STYPE
> -#undef SUFFIX
> -#undef USUFFIX
> -#undef DATA_SIZE
> -#undef SHIFT
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index f0e4b0aee4..a991ea2964 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -35,7 +35,6 @@
>  #include "qemu/atomic128.h"
>  #include "translate-all.h"
>  #include "trace-root.h"
> -#include "qemu/plugin.h"
>  #include "trace/mem.h"
>  #ifdef CONFIG_PLUGIN
>  #include "qemu/plugin-memory.h"
> @@ -1697,6 +1696,68 @@ uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
>                             ? helper_le_ldq_mmu : helper_be_ldq_mmu);
>  }
>  
> +uint32_t cpu_ldub_data_ra(CPUArchState *env, target_ulong ptr,
> +                          uintptr_t retaddr)
> +{
> +    return cpu_ldub_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
> +}
> +
> +int cpu_ldsb_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
> +{
> +    return cpu_ldsb_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
> +}
> +
> +uint32_t cpu_lduw_data_ra(CPUArchState *env, target_ulong ptr,
> +                          uintptr_t retaddr)
> +{
> +    return cpu_lduw_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
> +}
> +
> +int cpu_ldsw_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
> +{
> +    return cpu_ldsw_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
> +}
> +
> +uint32_t cpu_ldl_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
> +{
> +    return cpu_ldl_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
> +}
> +
> +uint64_t cpu_ldq_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
> +{
> +    return cpu_ldq_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
> +}
> +
> +uint32_t cpu_ldub_data(CPUArchState *env, target_ulong ptr)
> +{
> +    return cpu_ldub_data_ra(env, ptr, 0);
> +}
> +
> +int cpu_ldsb_data(CPUArchState *env, target_ulong ptr)
> +{
> +    return cpu_ldsb_data_ra(env, ptr, 0);
> +}
> +
> +uint32_t cpu_lduw_data(CPUArchState *env, target_ulong ptr)
> +{
> +    return cpu_lduw_data_ra(env, ptr, 0);
> +}
> +
> +int cpu_ldsw_data(CPUArchState *env, target_ulong ptr)
> +{
> +    return cpu_ldsw_data_ra(env, ptr, 0);
> +}
> +
> +uint32_t cpu_ldl_data(CPUArchState *env, target_ulong ptr)
> +{
> +    return cpu_ldl_data_ra(env, ptr, 0);
> +}
> +
> +uint64_t cpu_ldq_data(CPUArchState *env, target_ulong ptr)
> +{
> +    return cpu_ldq_data_ra(env, ptr, 0);
> +}
> +
>  /*
>   * Store Helpers
>   */
> @@ -1970,6 +2031,50 @@ void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
>      cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEQ);
>  }
>  
> +void cpu_stb_data_ra(CPUArchState *env, target_ulong ptr,
> +                     uint32_t val, uintptr_t retaddr)
> +{
> +    cpu_stb_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
> +}
> +
> +void cpu_stw_data_ra(CPUArchState *env, target_ulong ptr,
> +                     uint32_t val, uintptr_t retaddr)
> +{
> +    cpu_stw_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
> +}
> +
> +void cpu_stl_data_ra(CPUArchState *env, target_ulong ptr,
> +                     uint32_t val, uintptr_t retaddr)
> +{
> +    cpu_stl_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
> +}
> +
> +void cpu_stq_data_ra(CPUArchState *env, target_ulong ptr,
> +                     uint64_t val, uintptr_t retaddr)
> +{
> +    cpu_stq_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
> +}
> +
> +void cpu_stb_data(CPUArchState *env, target_ulong ptr, uint32_t val)
> +{
> +    cpu_stb_data_ra(env, ptr, val, 0);
> +}
> +
> +void cpu_stw_data(CPUArchState *env, target_ulong ptr, uint32_t val)
> +{
> +    cpu_stw_data_ra(env, ptr, val, 0);
> +}
> +
> +void cpu_stl_data(CPUArchState *env, target_ulong ptr, uint32_t val)
> +{
> +    cpu_stl_data_ra(env, ptr, val, 0);
> +}
> +
> +void cpu_stq_data(CPUArchState *env, target_ulong ptr, uint64_t val)
> +{
> +    cpu_stq_data_ra(env, ptr, val, 0);
> +}
> +
>  /* First set of helpers allows passing in of OI and RETADDR.  This makes
>     them callable from other helpers.  */


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 03/28] trace: Remove trace_mem_build_info_no_se_[bl]e
  2019-12-20 16:38   ` Alex Bennée
@ 2019-12-28 20:48     ` Richard Henderson
  0 siblings, 0 replies; 66+ messages in thread
From: Richard Henderson @ 2019-12-28 20:48 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel

On 12/21/19 3:38 AM, Alex Bennée wrote:
> 
> Richard Henderson <richard.henderson@linaro.org> writes:
> 
>> It is easy for the atomic helpers to use trace_mem_build_info
>> directly, without resorting to symbol pasting.  For this usage,
>> we cannot use trace_mem_get_info, because the MemOp does not
>> support 16-byte accesses.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>  accel/tcg/atomic_template.h | 67 +++++++++++++------------------------
>>  trace/mem-internal.h        | 17 ----------
>>  2 files changed, 24 insertions(+), 60 deletions(-)
>>
>> diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h
>> index 837676231f..26969487d6 100644
>> --- a/accel/tcg/atomic_template.h
>> +++ b/accel/tcg/atomic_template.h
>> @@ -64,13 +64,10 @@
>>     the ATOMIC_NAME macro, and redefined below.  */
>>  #if DATA_SIZE == 1
>>  # define END
>> -# define MEND _be /* either le or be would be fine */
>>  #elif defined(HOST_WORDS_BIGENDIAN)
>>  # define END  _be
>> -# define MEND _be
>>  #else
>>  # define END  _le
>> -# define MEND _le
>>  #endif
>>  
>>  ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
>> @@ -79,8 +76,8 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
>>      ATOMIC_MMU_DECLS;
>>      DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
>>      DATA_TYPE ret;
>> -    uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
>> -                                                           ATOMIC_MMU_IDX);
>> +    uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
> 
> What is MEND meant to be? Shouldn't we use the appropriate MO_TE instead
> of 0 for these helpers?

See the first hunk, where MEND is removed.  It's based on HOST_WORDS_BIGENDIAN,
so no we don't use MO_TE.


r~


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 04/28] cputlb: Move body of cpu_ldst_template.h out of line
  2019-12-20 18:36   ` Alex Bennée
@ 2019-12-28 20:50     ` Richard Henderson
  0 siblings, 0 replies; 66+ messages in thread
From: Richard Henderson @ 2019-12-28 20:50 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel

On 12/21/19 5:36 AM, Alex Bennée wrote:
>> -#if !defined(SOFTMMU_CODE_ACCESS)
>> -#include "trace-root.h"
>> -#endif
>> -
>> -#include "qemu/plugin.h"
>> -#include "trace/mem.h"
> 
> I think api.c needs to include trace/mem.h

Yep, thanks.  I'll enable travis for my local branches for next time, which I
believe would have caught this.


r~


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 06/28] cputlb: Rename helper_ret_ld*_cmmu to cpu_ld*_code
  2019-12-20 17:25   ` Alex Bennée
@ 2019-12-28 20:58     ` Richard Henderson
  0 siblings, 0 replies; 66+ messages in thread
From: Richard Henderson @ 2019-12-28 20:58 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: Aleksandar Markovic

On 12/21/19 4:25 AM, Alex Bennée wrote:
>> -#define CPU_MMU_INDEX (cpu_mmu_index(env, true))
>> -#define MEMSUFFIX _code
>> -#define SOFTMMU_CODE_ACCESS
>> +uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
>> +uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr);
>> +uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr);
>> +uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr);
>>
>> -#define DATA_SIZE 1
>> -#include "exec/cpu_ldst_template.h"
>> +static inline int cpu_ldsb_code(CPUArchState *env, abi_ptr addr)
>> +{
>> +    return (int8_t)cpu_ldub_code(env, addr);
>> +}
...
>> -uint8_t helper_ret_ldub_cmmu(CPUArchState *env, target_ulong addr,
>> -                            TCGMemOpIdx oi, uintptr_t retaddr);
>> -int8_t helper_ret_ldsb_cmmu(CPUArchState *env, target_ulong addr,
>> -                            TCGMemOpIdx oi, uintptr_t retaddr);
>> -uint16_t helper_le_lduw_cmmu(CPUArchState *env, target_ulong addr,
>> -                             TCGMemOpIdx oi, uintptr_t retaddr);
>> -int16_t helper_le_ldsw_cmmu(CPUArchState *env, target_ulong addr,
>> -                             TCGMemOpIdx oi, uintptr_t retaddr);
>> -uint32_t helper_le_ldl_cmmu(CPUArchState *env, target_ulong addr,
>> -                            TCGMemOpIdx oi, uintptr_t retaddr);
>> -uint64_t helper_le_ldq_cmmu(CPUArchState *env, target_ulong addr,
>> -                            TCGMemOpIdx oi, uintptr_t retaddr);
>> -uint16_t helper_be_lduw_cmmu(CPUArchState *env, target_ulong addr,
>> -                             TCGMemOpIdx oi, uintptr_t retaddr);
>> -int16_t helper_be_ldsw_cmmu(CPUArchState *env, target_ulong addr,
>> -                             TCGMemOpIdx oi, uintptr_t retaddr);
>> -uint32_t helper_be_ldl_cmmu(CPUArchState *env, target_ulong addr,
>> -                            TCGMemOpIdx oi, uintptr_t retaddr);
>> -uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
>> -                            TCGMemOpIdx oi, uintptr_t retaddr);
>> -
> <snip>
> 
> Why have we dropped the final type and stuck to uint32/64? Do we rely on
> the caller truncating any data by casting the result of their eventual
> cpu_ldFoo?

I have *preserved* the existing type of cpu_ld*_code(), the actual interface
that is being used.

Cleaning up the load return and store value types is another project.  I would
not limit that to *_code, though.  And I'd want to think of some way to prove
that all callers are getting the promotion that they expected.


r~


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 08/28] target/i386: Use cpu_*_mmuidx_ra instead of templates
  2019-12-20 17:42   ` Alex Bennée
@ 2019-12-28 21:02     ` Richard Henderson
  0 siblings, 0 replies; 66+ messages in thread
From: Richard Henderson @ 2019-12-28 21:02 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: Paolo Bonzini, Eduardo Habkost

On 12/21/19 4:42 AM, Alex Bennée wrote:
>> +/*
>> + * TODO: Convert callers to compute cpu_mmu_index_kernel once
>> + * and use *_mmuidx_ra directly.
>> + */
> 
> I guess this would only be if it was a significant performance impact?
> They seem to be mainly called for (I assume) infrequently called
> helpers.

Yes, they are infrequent.

But if you expose all of the hidden cpu_mmu_index_kernel() invocations, one
should immediately ask why we're not caching the result in a local variable.
If for nothing else, readability.


r~


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 26/28] target/ppc: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
  2019-12-20 19:51   ` Alex Bennée
@ 2019-12-28 21:18     ` Richard Henderson
  2019-12-29  8:40       ` David Gibson
  0 siblings, 1 reply; 66+ messages in thread
From: Richard Henderson @ 2019-12-28 21:18 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: David Gibson

On 12/21/19 6:51 AM, Alex Bennée wrote:
>> --- a/target/ppc/mem_helper.c
>> +++ b/target/ppc/mem_helper.c
>> @@ -177,14 +177,7 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr,
>>      } else {
>>          /* Slow path */
>>          for (i = 0; i < dcbz_size; i += 8) {
>> -            if (epid) {
>> -#if !defined(CONFIG_USER_ONLY)
>> -                /* Does not make sense on USER_ONLY config */
>> -                cpu_stq_eps_ra(env, addr + i, 0, retaddr);
>> -#endif
>> -            } else {
>> -                cpu_stq_data_ra(env, addr + i, 0, retaddr);
>> -            }
>> +            cpu_stq_mmuidx_ra(env, addr + i, 0, mmu_idx, retaddr);
> 
> I assume the possibility of a user-mode with epid is elided in the
> translation phase by avoiding gen_dcbzep although I can't quite see
> where they get called from. Anyway:

I suspect that dcbzep (vs dcbze) is supposed to be privileged, but I can't see
that enforced anywhere.  Certainly one can't write to the EPSC register from
userspace...


r~


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 26/28] target/ppc: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
  2019-12-28 21:18     ` Richard Henderson
@ 2019-12-29  8:40       ` David Gibson
  0 siblings, 0 replies; 66+ messages in thread
From: David Gibson @ 2019-12-29  8:40 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Alex Bennée, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]

On Sun, Dec 29, 2019 at 08:18:35AM +1100, Richard Henderson wrote:
> On 12/21/19 6:51 AM, Alex Bennée wrote:
> >> --- a/target/ppc/mem_helper.c
> >> +++ b/target/ppc/mem_helper.c
> >> @@ -177,14 +177,7 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr,
> >>      } else {
> >>          /* Slow path */
> >>          for (i = 0; i < dcbz_size; i += 8) {
> >> -            if (epid) {
> >> -#if !defined(CONFIG_USER_ONLY)
> >> -                /* Does not make sense on USER_ONLY config */
> >> -                cpu_stq_eps_ra(env, addr + i, 0, retaddr);
> >> -#endif
> >> -            } else {
> >> -                cpu_stq_data_ra(env, addr + i, 0, retaddr);
> >> -            }
> >> +            cpu_stq_mmuidx_ra(env, addr + i, 0, mmu_idx, retaddr);
> > 
> > I assume the possibility of a user-mode with epid is elided in the
> > translation phase by avoiding gen_dcbzep although I can't quite see
> > where they get called from. Anyway:
> 
> I suspect that dcbzep (vs dcbze) is supposed to be privileged, but I can't see
> that enforced anywhere.  Certainly one can't write to the EPSC register from
> userspace...

So... it's true that dcbzep is privileged (as are all the external PID
instructions, I believe).  I'm not certain if the reasoning you used
to guess that was correct, though.  In this case the suffix is "ep"
for "External PID" not "p" for "Privileged".  There is no "dcbze"
instruction, only "dcbz" which happens not to be privileged.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 66+ messages in thread

end of thread, other threads:[~2019-12-29  8:41 UTC | newest]

Thread overview: 66+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-16 22:11 [PATCH v2 00/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
2019-12-16 22:11 ` [PATCH v2 01/28] target/xtensa: Use probe_access for itlb_hit_test Richard Henderson
2019-12-17  3:51   ` Philippe Mathieu-Daudé
2019-12-20 14:15   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 02/28] cputlb: Use trace_mem_get_info instead of trace_mem_build_info Richard Henderson
2019-12-17  3:59   ` Philippe Mathieu-Daudé
2019-12-20 15:04   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 03/28] trace: Remove trace_mem_build_info_no_se_[bl]e Richard Henderson
2019-12-20 16:38   ` Alex Bennée
2019-12-28 20:48     ` Richard Henderson
2019-12-16 22:11 ` [PATCH v2 04/28] cputlb: Move body of cpu_ldst_template.h out of line Richard Henderson
2019-12-20 17:07   ` Alex Bennée
2019-12-20 18:33     ` Alex Bennée
2019-12-20 18:36   ` Alex Bennée
2019-12-28 20:50     ` Richard Henderson
2019-12-16 22:11 ` [PATCH v2 05/28] translator: Use cpu_ld*_code instead of open-coding Richard Henderson
2019-12-20 17:12   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 06/28] cputlb: Rename helper_ret_ld*_cmmu to cpu_ld*_code Richard Henderson
2019-12-20 17:25   ` Alex Bennée
2019-12-28 20:58     ` Richard Henderson
2019-12-16 22:11 ` [PATCH v2 07/28] cputlb: Provide cpu_(ld, st}*_mmuidx_ra for user-only Richard Henderson
2019-12-20 17:36   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 08/28] target/i386: Use cpu_*_mmuidx_ra instead of templates Richard Henderson
2019-12-20 17:42   ` Alex Bennée
2019-12-28 21:02     ` Richard Henderson
2019-12-16 22:11 ` [PATCH v2 09/28] target/s390x: Include tcg.h in mem_helper.c Richard Henderson
2019-12-20 17:43   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 10/28] target/arm: Include tcg.h in sve_helper.c Richard Henderson
2019-12-20 17:43   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 11/28] accel/tcg: Include tcg.h in tcg-runtime.c Richard Henderson
2019-12-16 22:11 ` [PATCH v2 12/28] linux-user: Include tcg.h in syscall.c Richard Henderson
2019-12-20 17:43   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 13/28] linux-user: Include trace-root.h in syscall-trace.h Richard Henderson
2019-12-20 17:49   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 14/28] cputlb: Expand cpu_ldst_useronly_template.h in user-exec.c Richard Henderson
2019-12-20 17:59   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 15/28] target/nios2: Remove MMU_MODE{0,1}_SUFFIX Richard Henderson
2019-12-20 18:02   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 16/28] target/alpha: " Richard Henderson
2019-12-20 18:02   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 17/28] target/cris: " Richard Henderson
2019-12-20 18:02   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 18/28] target/i386: Remove MMU_MODE{0,1,2}_SUFFIX Richard Henderson
2019-12-20 18:02   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 19/28] target/microblaze: " Richard Henderson
2019-12-20 18:03   ` [PATCH v2 19/28] target/microblaze: Remove MMU_MODE{0, 1, 2}_SUFFIX Alex Bennée
2019-12-16 22:11 ` [PATCH v2 20/28] target/sh4: Remove MMU_MODE{0,1}_SUFFIX Richard Henderson
2019-12-20 18:03   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 21/28] target/unicore32: " Richard Henderson
2019-12-20 18:03   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 22/28] target/xtensa: Remove MMU_MODE{0,1,2,3}_SUFFIX Richard Henderson
2019-12-20 19:30   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 23/28] target/m68k: Use cpu_*_mmuidx_ra instead of MMU_MODE{0, 1}_SUFFIX Richard Henderson
2019-12-20 19:34   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 24/28] target/mips: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX Richard Henderson
2019-12-20 19:37   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 25/28] target/s390x: " Richard Henderson
2019-12-20 19:39   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 26/28] target/ppc: " Richard Henderson
2019-12-20 19:51   ` Alex Bennée
2019-12-28 21:18     ` Richard Henderson
2019-12-29  8:40       ` David Gibson
2019-12-16 22:11 ` [PATCH v2 27/28] cputlb: Remove support for MMU_MODE*_SUFFIX Richard Henderson
2019-12-20 19:52   ` Alex Bennée
2019-12-16 22:11 ` [PATCH v2 28/28] cputlb: Expand cpu_ldst_template.h in cputlb.c Richard Henderson
2019-12-20 19:53   ` Alex Bennée

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.