1 | The following changes since commit fec105c2abda8567ec15230429c41429b5ee307c: | 1 | The following changes since commit 98c7362b1efe651327385a25874a73e008c6549e: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/kraxel/tags/audio-20190828-pull-request' into staging (2019-09-03 14:03:15 +0100) | 3 | Merge tag 'accel-cpus-20250306' of https://github.com/philmd/qemu into staging (2025-03-07 07:39:49 +0800) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/rth7680/qemu.git tags/pull-tcg-20190903 | 7 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20250308 |
8 | 8 | ||
9 | for you to fetch changes up to c25c283df0f08582df29f1d5d7be1516b851532d: | 9 | for you to fetch changes up to 9e2080766f037857fc366012aaefd6fead0a75f9: |
10 | 10 | ||
11 | tcg: Factor out probe_write() logic into probe_access() (2019-09-03 08:34:18 -0700) | 11 | accel/tcg: Build tcg-runtime-gvec.c once (2025-03-08 10:06:48 -0800) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Allow page table bit to swap endianness. | 14 | include/qemu: Tidy atomic128 headers. |
15 | Reorganize watchpoints out of i/o path. | 15 | include/exec: Split out cpu-interrupt.h |
16 | Return host address from probe_write / probe_access. | 16 | include/exec: Split many tlb_* declarations to cputlb.h |
17 | include/accel/tcg: Split out getpc.h | ||
18 | accel/tcg: system: Compile some files once | ||
19 | linux-user/main: Allow setting tb-size | ||
17 | 20 | ||
18 | ---------------------------------------------------------------- | 21 | ---------------------------------------------------------------- |
19 | David Hildenbrand (11): | 22 | Ilya Leoshkevich (1): |
20 | exec: Factor out core logic of check_watchpoint() | 23 | linux-user/main: Allow setting tb-size |
21 | tcg: Check for watchpoints in probe_write() | ||
22 | s390x/tcg: Use guest_addr_valid() instead of h2g_valid() in probe_write_access() | ||
23 | s390x/tcg: Fix length calculation in probe_write_access() | ||
24 | tcg: Factor out CONFIG_USER_ONLY probe_write() from s390x code | ||
25 | tcg: Enforce single page access in probe_write() | ||
26 | mips/tcg: Call probe_write() for CONFIG_USER_ONLY as well | ||
27 | hppa/tcg: Call probe_write() also for CONFIG_USER_ONLY | ||
28 | s390x/tcg: Pass a size to probe_write() in do_csst() | ||
29 | tcg: Make probe_write() return a pointer to the host page | ||
30 | tcg: Factor out probe_write() logic into probe_access() | ||
31 | 24 | ||
32 | Richard Henderson (6): | 25 | Philippe Mathieu-Daudé (11): |
33 | exec: Move user-only watchpoint stubs inline | 26 | accel/tcg: Restrict CPU_TLB_DYN_*_BITS definitions to accel/tcg/ |
34 | cputlb: Fold TLB_RECHECK into TLB_INVALID_MASK | 27 | exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h' |
35 | exec: Factor out cpu_watchpoint_address_matches | 28 | exec: Declare tlb_set_page_full() in 'exec/cputlb.h' |
36 | cputlb: Fix size operand for tlb_fill on unaligned store | 29 | exec: Declare tlb_set_page_with_attrs() in 'exec/cputlb.h' |
37 | cputlb: Remove double-alignment in store_helper | 30 | exec: Declare tlb_set_page() in 'exec/cputlb.h' |
38 | cputlb: Handle watchpoints via TLB_WATCHPOINT | 31 | exec: Declare tlb_hit*() in 'exec/cputlb.h' |
32 | exec: Declare tlb_flush*() in 'exec/cputlb.h' | ||
33 | accel/tcg: Restrict GETPC_ADJ to 'tb-internal.h' | ||
34 | qemu/atomic: Rename atomic128-cas.h headers using .h.inc suffix | ||
35 | qemu/atomic: Rename atomic128-ldst.h headers using .h.inc suffix | ||
36 | qemu/atomic128: Include missing 'qemu/atomic.h' header | ||
39 | 37 | ||
40 | Tony Nguyen (19): | 38 | Richard Henderson (11): |
41 | tcg: TCGMemOp is now accelerator independent MemOp | 39 | include/exec: Move TARGET_PAGE_{SIZE,MASK,BITS} to target_page.h |
42 | memory: Introduce size_memop | 40 | include/exec: Split out exec/cpu-interrupt.h |
43 | target/mips: Access MemoryRegion with MemOp | 41 | accel/tcg: Compile watchpoint.c once |
44 | hw/s390x: Access MemoryRegion with MemOp | 42 | system: Build watchpoint.c once |
45 | hw/intc/armv7m_nic: Access MemoryRegion with MemOp | 43 | accel/tcg: Build tcg-accel-ops.c once |
46 | hw/virtio: Access MemoryRegion with MemOp | 44 | accel/tcg: Build tcg-accel-ops-icount.c once |
47 | hw/vfio: Access MemoryRegion with MemOp | 45 | accel/tcg: Build tcg-accel-ops-rr.c once |
48 | exec: Access MemoryRegion with MemOp | 46 | accel/tcg: Build tcg-accel-ops-mttcg.c once |
49 | cputlb: Access MemoryRegion with MemOp | 47 | accel/tcg: Split out getpc.h |
50 | memory: Access MemoryRegion with MemOp | 48 | accel/tcg: Build tcg-runtime.c once |
51 | hw/s390x: Hard code size with MO_{8|16|32|64} | 49 | accel/tcg: Build tcg-runtime-gvec.c once |
52 | target/mips: Hard code size with MO_{8|16|32|64} | ||
53 | exec: Hard code size with MO_{8|16|32|64} | ||
54 | memory: Access MemoryRegion with endianness | ||
55 | cputlb: Replace size and endian operands for MemOp | ||
56 | memory: Single byte swap along the I/O path | ||
57 | cputlb: Byte swap memory transaction attribute | ||
58 | target/sparc: Add TLB entry with attributes | ||
59 | target/sparc: sun4u Invert Endian TTE bit | ||
60 | 50 | ||
61 | include/exec/cpu-all.h | 8 +- | 51 | accel/tcg/internal-common.h | 2 + |
62 | include/exec/exec-all.h | 10 +- | 52 | accel/tcg/tb-internal.h | 40 +++- |
63 | include/exec/memattrs.h | 2 + | 53 | host/include/aarch64/host/atomic128-cas.h | 2 +- |
64 | include/exec/memop.h | 134 +++++++++++ | 54 | include/accel/tcg/getpc.h | 24 ++ |
65 | include/exec/memory.h | 12 +- | 55 | include/exec/cpu-all.h | 97 +------- |
66 | include/hw/core/cpu.h | 37 +++ | 56 | include/exec/cpu-defs.h | 26 -- |
67 | target/arm/translate-a64.h | 2 +- | 57 | include/exec/cpu-interrupt.h | 70 ++++++ |
68 | target/arm/translate.h | 2 +- | 58 | include/exec/cputlb.h | 263 ++++++++++++++++++++- |
69 | target/sparc/cpu.h | 2 + | 59 | include/exec/exec-all.h | 262 +------------------- |
70 | tcg/tcg-op.h | 80 +++--- | 60 | include/exec/poison.h | 17 -- |
71 | tcg/tcg.h | 101 +------- | 61 | include/exec/ram_addr.h | 1 + |
72 | trace/mem-internal.h | 4 +- | 62 | include/exec/target_page.h | 58 ++++- |
73 | trace/mem.h | 4 +- | 63 | include/qemu/atomic128.h | 5 +- |
74 | accel/tcg/cputlb.c | 414 ++++++++++++++++++-------------- | 64 | accel/tcg/cputlb.c | 23 ++ |
75 | accel/tcg/user-exec.c | 32 +++ | 65 | accel/tcg/tcg-accel-ops-icount.c | 2 +- |
76 | exec.c | 177 +++----------- | 66 | accel/tcg/tcg-accel-ops-mttcg.c | 1 - |
77 | hw/intc/armv7m_nvic.c | 13 +- | 67 | accel/tcg/tcg-accel-ops-rr.c | 2 +- |
78 | hw/s390x/s390-pci-inst.c | 11 +- | 68 | accel/tcg/tcg-accel-ops.c | 2 +- |
79 | hw/vfio/pci-quirks.c | 7 +- | 69 | accel/tcg/tcg-runtime-gvec.c | 1 - |
80 | hw/virtio/virtio-pci.c | 15 +- | 70 | accel/tcg/tcg-runtime.c | 8 +- |
81 | memory.c | 58 +++-- | 71 | accel/tcg/watchpoint.c | 5 +- |
82 | memory_ldst.inc.c | 81 ++----- | 72 | cpu-target.c | 1 + |
83 | target/alpha/translate.c | 2 +- | 73 | hw/intc/armv7m_nvic.c | 2 +- |
84 | target/arm/translate-a64.c | 48 ++-- | 74 | hw/ppc/spapr_nested.c | 1 + |
85 | target/arm/translate-sve.c | 2 +- | 75 | hw/sh4/sh7750.c | 1 + |
86 | target/arm/translate.c | 32 +-- | 76 | linux-user/main.c | 12 + |
87 | target/hppa/op_helper.c | 2 - | 77 | page-target.c | 18 -- |
88 | target/hppa/translate.c | 14 +- | 78 | page-vary-target.c | 2 - |
89 | target/i386/translate.c | 132 +++++----- | 79 | system/physmem.c | 1 + |
90 | target/m68k/translate.c | 2 +- | 80 | system/watchpoint.c | 3 +- |
91 | target/microblaze/translate.c | 4 +- | 81 | target/alpha/helper.c | 2 +- |
92 | target/mips/op_helper.c | 13 +- | 82 | target/alpha/sys_helper.c | 2 +- |
93 | target/mips/translate.c | 8 +- | 83 | target/arm/helper.c | 1 + |
94 | target/openrisc/translate.c | 4 +- | 84 | target/arm/tcg/tlb-insns.c | 2 +- |
95 | target/ppc/translate.c | 12 +- | 85 | target/avr/helper.c | 2 +- |
96 | target/riscv/insn_trans/trans_rva.inc.c | 8 +- | 86 | target/hppa/mem_helper.c | 1 + |
97 | target/riscv/insn_trans/trans_rvi.inc.c | 4 +- | 87 | target/i386/helper.c | 2 +- |
98 | target/s390x/mem_helper.c | 13 +- | 88 | target/i386/machine.c | 2 +- |
99 | target/s390x/translate.c | 6 +- | 89 | target/i386/tcg/fpu_helper.c | 2 +- |
100 | target/s390x/translate_vx.inc.c | 10 +- | 90 | target/i386/tcg/misc_helper.c | 2 +- |
101 | target/sparc/mmu_helper.c | 40 +-- | 91 | target/i386/tcg/system/excp_helper.c | 2 +- |
102 | target/sparc/translate.c | 14 +- | 92 | target/i386/tcg/system/misc_helper.c | 2 +- |
103 | target/tilegx/translate.c | 10 +- | 93 | target/i386/tcg/system/svm_helper.c | 2 +- |
104 | target/tricore/translate.c | 8 +- | 94 | target/loongarch/tcg/csr_helper.c | 2 +- |
105 | tcg/aarch64/tcg-target.inc.c | 26 +- | 95 | target/loongarch/tcg/tlb_helper.c | 1 + |
106 | tcg/arm/tcg-target.inc.c | 26 +- | 96 | target/m68k/helper.c | 1 + |
107 | tcg/i386/tcg-target.inc.c | 24 +- | 97 | target/microblaze/helper.c | 2 +- |
108 | tcg/mips/tcg-target.inc.c | 16 +- | 98 | target/microblaze/mmu.c | 2 +- |
109 | tcg/optimize.c | 2 +- | 99 | target/mips/system/cp0.c | 2 +- |
110 | tcg/ppc/tcg-target.inc.c | 12 +- | 100 | target/mips/tcg/system/cp0_helper.c | 2 +- |
111 | tcg/riscv/tcg-target.inc.c | 20 +- | 101 | target/mips/tcg/system/tlb_helper.c | 1 + |
112 | tcg/s390/tcg-target.inc.c | 14 +- | 102 | target/openrisc/mmu.c | 2 +- |
113 | tcg/sparc/tcg-target.inc.c | 6 +- | 103 | target/openrisc/sys_helper.c | 1 + |
114 | tcg/tcg-op.c | 38 +-- | 104 | target/ppc/helper_regs.c | 2 +- |
115 | tcg/tcg.c | 2 +- | 105 | target/ppc/misc_helper.c | 1 + |
116 | MAINTAINERS | 1 + | 106 | target/ppc/mmu_helper.c | 1 + |
117 | tcg/README | 2 +- | 107 | target/riscv/cpu_helper.c | 1 + |
118 | 57 files changed, 918 insertions(+), 865 deletions(-) | 108 | target/riscv/csr.c | 1 + |
119 | create mode 100644 include/exec/memop.h | 109 | target/riscv/op_helper.c | 1 + |
110 | target/riscv/pmp.c | 2 +- | ||
111 | target/rx/cpu.c | 2 +- | ||
112 | target/s390x/gdbstub.c | 2 +- | ||
113 | target/s390x/sigp.c | 1 + | ||
114 | target/s390x/tcg/excp_helper.c | 1 + | ||
115 | target/s390x/tcg/mem_helper.c | 1 + | ||
116 | target/s390x/tcg/misc_helper.c | 1 + | ||
117 | target/sh4/helper.c | 1 + | ||
118 | target/sparc/ldst_helper.c | 1 + | ||
119 | target/sparc/mmu_helper.c | 2 +- | ||
120 | target/tricore/helper.c | 2 +- | ||
121 | target/xtensa/helper.c | 2 +- | ||
122 | target/xtensa/mmu_helper.c | 1 + | ||
123 | accel/tcg/meson.build | 14 +- | ||
124 | .../{atomic128-ldst.h => atomic128-ldst.h.inc} | 0 | ||
125 | .../host/{atomic128-cas.h => atomic128-cas.h.inc} | 0 | ||
126 | .../{atomic128-ldst.h => atomic128-ldst.h.inc} | 0 | ||
127 | .../{atomic128-ldst.h => atomic128-ldst.h.inc} | 0 | ||
128 | .../{atomic128-ldst.h => atomic128-ldst.h.inc} | 2 +- | ||
129 | .../x86_64/host/load-extract-al16-al8.h.inc | 2 +- | ||
130 | system/meson.build | 2 +- | ||
131 | 80 files changed, 552 insertions(+), 486 deletions(-) | ||
132 | create mode 100644 include/accel/tcg/getpc.h | ||
133 | create mode 100644 include/exec/cpu-interrupt.h | ||
134 | rename host/include/aarch64/host/{atomic128-ldst.h => atomic128-ldst.h.inc} (100%) | ||
135 | rename host/include/generic/host/{atomic128-cas.h => atomic128-cas.h.inc} (100%) | ||
136 | rename host/include/generic/host/{atomic128-ldst.h => atomic128-ldst.h.inc} (100%) | ||
137 | rename host/include/loongarch64/host/{atomic128-ldst.h => atomic128-ldst.h.inc} (100%) | ||
138 | rename host/include/x86_64/host/{atomic128-ldst.h => atomic128-ldst.h.inc} (96%) | ||
120 | 139 | diff view generated by jsdifflib |
1 | From: Tony Nguyen <tony.nguyen@bt.com> | 1 | From: Ilya Leoshkevich <iii@linux.ibm.com> |
---|---|---|---|
2 | 2 | ||
3 | Now that MemOp has been pushed down into the memory API, and | 3 | While qemu-system can set tb-size using -accel tcg,tb-size=n, there |
4 | callers are encoding endianness, we can collapse byte swaps | 4 | is no similar knob for qemu-user. Add one in a way similar to how |
5 | along the I/O path into the accelerator and target independent | 5 | one-insn-per-tb is already handled. |
6 | adjust_endianness. | ||
7 | 6 | ||
8 | Collapsing byte swaps along the I/O path enables additional endian | 7 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> |
9 | inversion logic, e.g. SPARC64 Invert Endian TTE bit, with redundant | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | byte swaps cancelling out. | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-ID: <20240730215532.1442-1-iii@linux.ibm.com> | ||
11 | --- | ||
12 | linux-user/main.c | 12 ++++++++++++ | ||
13 | 1 file changed, 12 insertions(+) | ||
11 | 14 | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 15 | diff --git a/linux-user/main.c b/linux-user/main.c |
13 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
15 | Message-Id: <911ff31af11922a9afba9b7ce128af8b8b80f316.1566466906.git.tony.nguyen@bt.com> | ||
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | --- | ||
18 | accel/tcg/cputlb.c | 42 ++-------------------------- | ||
19 | exec.c | 17 +++--------- | ||
20 | hw/virtio/virtio-pci.c | 10 +++---- | ||
21 | memory.c | 33 ++++++++-------------- | ||
22 | memory_ldst.inc.c | 63 ------------------------------------------ | ||
23 | 5 files changed, 23 insertions(+), 142 deletions(-) | ||
24 | |||
25 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/accel/tcg/cputlb.c | 17 | --- a/linux-user/main.c |
28 | +++ b/accel/tcg/cputlb.c | 18 | +++ b/linux-user/main.c |
29 | @@ -XXX,XX +XXX,XX @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, | 19 | @@ -XXX,XX +XXX,XX @@ char *exec_path; |
30 | cpu_loop_exit_atomic(env_cpu(env), retaddr); | 20 | char real_exec_path[PATH_MAX]; |
21 | |||
22 | static bool opt_one_insn_per_tb; | ||
23 | +static unsigned long opt_tb_size; | ||
24 | static const char *argv0; | ||
25 | static const char *gdbstub; | ||
26 | static envlist_t *envlist; | ||
27 | @@ -XXX,XX +XXX,XX @@ static void handle_arg_one_insn_per_tb(const char *arg) | ||
28 | opt_one_insn_per_tb = true; | ||
31 | } | 29 | } |
32 | 30 | ||
33 | -#ifdef TARGET_WORDS_BIGENDIAN | 31 | +static void handle_arg_tb_size(const char *arg) |
34 | -#define NEED_BE_BSWAP 0 | 32 | +{ |
35 | -#define NEED_LE_BSWAP 1 | 33 | + if (qemu_strtoul(arg, NULL, 0, &opt_tb_size)) { |
36 | -#else | 34 | + usage(EXIT_FAILURE); |
37 | -#define NEED_BE_BSWAP 1 | 35 | + } |
38 | -#define NEED_LE_BSWAP 0 | 36 | +} |
39 | -#endif | 37 | + |
40 | - | 38 | static void handle_arg_strace(const char *arg) |
41 | -/* | 39 | { |
42 | - * Byte Swap Helper | 40 | enable_strace = true; |
43 | - * | 41 | @@ -XXX,XX +XXX,XX @@ static const struct qemu_argument arg_table[] = { |
44 | - * This should all dead code away depending on the build host and | 42 | {"one-insn-per-tb", |
45 | - * access type. | 43 | "QEMU_ONE_INSN_PER_TB", false, handle_arg_one_insn_per_tb, |
46 | - */ | 44 | "", "run with one guest instruction per emulated TB"}, |
47 | - | 45 | + {"tb-size", "QEMU_TB_SIZE", true, handle_arg_tb_size, |
48 | -static inline uint64_t handle_bswap(uint64_t val, MemOp op) | 46 | + "size", "TCG translation block cache size"}, |
49 | -{ | 47 | {"strace", "QEMU_STRACE", false, handle_arg_strace, |
50 | - if ((memop_big_endian(op) && NEED_BE_BSWAP) || | 48 | "", "log system calls"}, |
51 | - (!memop_big_endian(op) && NEED_LE_BSWAP)) { | 49 | {"seed", "QEMU_RAND_SEED", true, handle_arg_seed, |
52 | - switch (op & MO_SIZE) { | 50 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp) |
53 | - case MO_8: return val; | 51 | accel_init_interfaces(ac); |
54 | - case MO_16: return bswap16(val); | 52 | object_property_set_bool(OBJECT(accel), "one-insn-per-tb", |
55 | - case MO_32: return bswap32(val); | 53 | opt_one_insn_per_tb, &error_abort); |
56 | - case MO_64: return bswap64(val); | 54 | + object_property_set_int(OBJECT(accel), "tb-size", |
57 | - default: | 55 | + opt_tb_size, &error_abort); |
58 | - g_assert_not_reached(); | 56 | ac->init_machine(NULL); |
59 | - } | ||
60 | - } else { | ||
61 | - return val; | ||
62 | - } | ||
63 | -} | ||
64 | - | ||
65 | /* | ||
66 | * Load Helpers | ||
67 | * | ||
68 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
69 | } | ||
70 | } | ||
71 | |||
72 | - /* TODO: Merge bswap into io_readx -> memory_region_dispatch_read. */ | ||
73 | - res = io_readx(env, &env_tlb(env)->d[mmu_idx].iotlb[index], | ||
74 | - mmu_idx, addr, retaddr, access_type, op); | ||
75 | - return handle_bswap(res, op); | ||
76 | + return io_readx(env, &env_tlb(env)->d[mmu_idx].iotlb[index], | ||
77 | + mmu_idx, addr, retaddr, access_type, op); | ||
78 | } | 57 | } |
79 | 58 | ||
80 | /* Handle slow unaligned access (it spans two pages or IO). */ | ||
81 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
82 | } | ||
83 | } | ||
84 | |||
85 | - /* TODO: Merge bswap into io_writex -> memory_region_dispatch_write. */ | ||
86 | io_writex(env, &env_tlb(env)->d[mmu_idx].iotlb[index], mmu_idx, | ||
87 | - handle_bswap(val, op), | ||
88 | - addr, retaddr, op); | ||
89 | + val, addr, retaddr, op); | ||
90 | return; | ||
91 | } | ||
92 | |||
93 | diff --git a/exec.c b/exec.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/exec.c | ||
96 | +++ b/exec.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, | ||
98 | l = memory_access_size(mr, l, addr1); | ||
99 | /* XXX: could force current_cpu to NULL to avoid | ||
100 | potential bugs */ | ||
101 | - val = ldn_p(buf, l); | ||
102 | - /* | ||
103 | - * TODO: Merge bswap from ldn_p into memory_region_dispatch_write | ||
104 | - * by using ldn_he_p and dropping MO_TE to get a host-endian value. | ||
105 | - */ | ||
106 | + val = ldn_he_p(buf, l); | ||
107 | result |= memory_region_dispatch_write(mr, addr1, val, | ||
108 | - size_memop(l) | MO_TE, | ||
109 | - attrs); | ||
110 | + size_memop(l), attrs); | ||
111 | } else { | ||
112 | /* RAM case */ | ||
113 | ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l, false); | ||
114 | @@ -XXX,XX +XXX,XX @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, | ||
115 | /* I/O case */ | ||
116 | release_lock |= prepare_mmio_access(mr); | ||
117 | l = memory_access_size(mr, l, addr1); | ||
118 | - /* | ||
119 | - * TODO: Merge bswap from stn_p into memory_region_dispatch_read | ||
120 | - * by using stn_he_p and dropping MO_TE to get a host-endian value. | ||
121 | - */ | ||
122 | result |= memory_region_dispatch_read(mr, addr1, &val, | ||
123 | - size_memop(l) | MO_TE, attrs); | ||
124 | - stn_p(buf, l, val); | ||
125 | + size_memop(l), attrs); | ||
126 | + stn_he_p(buf, l, val); | ||
127 | } else { | ||
128 | /* RAM case */ | ||
129 | ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l, false); | ||
130 | diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c | ||
131 | index XXXXXXX..XXXXXXX 100644 | ||
132 | --- a/hw/virtio/virtio-pci.c | ||
133 | +++ b/hw/virtio/virtio-pci.c | ||
134 | @@ -XXX,XX +XXX,XX @@ void virtio_address_space_write(VirtIOPCIProxy *proxy, hwaddr addr, | ||
135 | val = pci_get_byte(buf); | ||
136 | break; | ||
137 | case 2: | ||
138 | - val = cpu_to_le16(pci_get_word(buf)); | ||
139 | + val = pci_get_word(buf); | ||
140 | break; | ||
141 | case 4: | ||
142 | - val = cpu_to_le32(pci_get_long(buf)); | ||
143 | + val = pci_get_long(buf); | ||
144 | break; | ||
145 | default: | ||
146 | /* As length is under guest control, handle illegal values. */ | ||
147 | return; | ||
148 | } | ||
149 | - /* TODO: Merge bswap from cpu_to_leXX into memory_region_dispatch_write. */ | ||
150 | memory_region_dispatch_write(mr, addr, val, size_memop(len) | MO_LE, | ||
151 | MEMTXATTRS_UNSPECIFIED); | ||
152 | } | ||
153 | @@ -XXX,XX +XXX,XX @@ virtio_address_space_read(VirtIOPCIProxy *proxy, hwaddr addr, | ||
154 | /* Make sure caller aligned buf properly */ | ||
155 | assert(!(((uintptr_t)buf) & (len - 1))); | ||
156 | |||
157 | - /* TODO: Merge bswap from leXX_to_cpu into memory_region_dispatch_read. */ | ||
158 | memory_region_dispatch_read(mr, addr, &val, size_memop(len) | MO_LE, | ||
159 | MEMTXATTRS_UNSPECIFIED); | ||
160 | switch (len) { | ||
161 | @@ -XXX,XX +XXX,XX @@ virtio_address_space_read(VirtIOPCIProxy *proxy, hwaddr addr, | ||
162 | pci_set_byte(buf, val); | ||
163 | break; | ||
164 | case 2: | ||
165 | - pci_set_word(buf, le16_to_cpu(val)); | ||
166 | + pci_set_word(buf, val); | ||
167 | break; | ||
168 | case 4: | ||
169 | - pci_set_long(buf, le32_to_cpu(val)); | ||
170 | + pci_set_long(buf, val); | ||
171 | break; | ||
172 | default: | ||
173 | /* As length is under guest control, handle illegal values. */ | ||
174 | diff --git a/memory.c b/memory.c | ||
175 | index XXXXXXX..XXXXXXX 100644 | ||
176 | --- a/memory.c | ||
177 | +++ b/memory.c | ||
178 | @@ -XXX,XX +XXX,XX @@ static bool memory_region_big_endian(MemoryRegion *mr) | ||
179 | #endif | ||
180 | } | ||
181 | |||
182 | -static bool memory_region_wrong_endianness(MemoryRegion *mr) | ||
183 | +static void adjust_endianness(MemoryRegion *mr, uint64_t *data, MemOp op) | ||
184 | { | ||
185 | -#ifdef TARGET_WORDS_BIGENDIAN | ||
186 | - return mr->ops->endianness == DEVICE_LITTLE_ENDIAN; | ||
187 | -#else | ||
188 | - return mr->ops->endianness == DEVICE_BIG_ENDIAN; | ||
189 | -#endif | ||
190 | -} | ||
191 | - | ||
192 | -static void adjust_endianness(MemoryRegion *mr, uint64_t *data, unsigned size) | ||
193 | -{ | ||
194 | - if (memory_region_wrong_endianness(mr)) { | ||
195 | - switch (size) { | ||
196 | - case 1: | ||
197 | + if ((op & MO_BSWAP) != devend_memop(mr->ops->endianness)) { | ||
198 | + switch (op & MO_SIZE) { | ||
199 | + case MO_8: | ||
200 | break; | ||
201 | - case 2: | ||
202 | + case MO_16: | ||
203 | *data = bswap16(*data); | ||
204 | break; | ||
205 | - case 4: | ||
206 | + case MO_32: | ||
207 | *data = bswap32(*data); | ||
208 | break; | ||
209 | - case 8: | ||
210 | + case MO_64: | ||
211 | *data = bswap64(*data); | ||
212 | break; | ||
213 | default: | ||
214 | - abort(); | ||
215 | + g_assert_not_reached(); | ||
216 | } | ||
217 | } | ||
218 | } | ||
219 | @@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_read(MemoryRegion *mr, | ||
220 | } | ||
221 | |||
222 | r = memory_region_dispatch_read1(mr, addr, pval, size, attrs); | ||
223 | - adjust_endianness(mr, pval, size); | ||
224 | + adjust_endianness(mr, pval, op); | ||
225 | return r; | ||
226 | } | ||
227 | |||
228 | @@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr, | ||
229 | return MEMTX_DECODE_ERROR; | ||
230 | } | ||
231 | |||
232 | - adjust_endianness(mr, &data, size); | ||
233 | + adjust_endianness(mr, &data, op); | ||
234 | |||
235 | if ((!kvm_eventfds_enabled()) && | ||
236 | memory_region_dispatch_write_eventfds(mr, addr, data, size, attrs)) { | ||
237 | @@ -XXX,XX +XXX,XX @@ void memory_region_add_eventfd(MemoryRegion *mr, | ||
238 | } | ||
239 | |||
240 | if (size) { | ||
241 | - adjust_endianness(mr, &mrfd.data, size); | ||
242 | + adjust_endianness(mr, &mrfd.data, size_memop(size) | MO_TE); | ||
243 | } | ||
244 | memory_region_transaction_begin(); | ||
245 | for (i = 0; i < mr->ioeventfd_nb; ++i) { | ||
246 | @@ -XXX,XX +XXX,XX @@ void memory_region_del_eventfd(MemoryRegion *mr, | ||
247 | unsigned i; | ||
248 | |||
249 | if (size) { | ||
250 | - adjust_endianness(mr, &mrfd.data, size); | ||
251 | + adjust_endianness(mr, &mrfd.data, size_memop(size) | MO_TE); | ||
252 | } | ||
253 | memory_region_transaction_begin(); | ||
254 | for (i = 0; i < mr->ioeventfd_nb; ++i) { | ||
255 | diff --git a/memory_ldst.inc.c b/memory_ldst.inc.c | ||
256 | index XXXXXXX..XXXXXXX 100644 | ||
257 | --- a/memory_ldst.inc.c | ||
258 | +++ b/memory_ldst.inc.c | ||
259 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL, | ||
260 | release_lock |= prepare_mmio_access(mr); | ||
261 | |||
262 | /* I/O case */ | ||
263 | - /* TODO: Merge bswap32 into memory_region_dispatch_read. */ | ||
264 | r = memory_region_dispatch_read(mr, addr1, &val, | ||
265 | MO_32 | devend_memop(endian), attrs); | ||
266 | -#if defined(TARGET_WORDS_BIGENDIAN) | ||
267 | - if (endian == DEVICE_LITTLE_ENDIAN) { | ||
268 | - val = bswap32(val); | ||
269 | - } | ||
270 | -#else | ||
271 | - if (endian == DEVICE_BIG_ENDIAN) { | ||
272 | - val = bswap32(val); | ||
273 | - } | ||
274 | -#endif | ||
275 | } else { | ||
276 | /* RAM case */ | ||
277 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
278 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL, | ||
279 | release_lock |= prepare_mmio_access(mr); | ||
280 | |||
281 | /* I/O case */ | ||
282 | - /* TODO: Merge bswap64 into memory_region_dispatch_read. */ | ||
283 | r = memory_region_dispatch_read(mr, addr1, &val, | ||
284 | MO_64 | devend_memop(endian), attrs); | ||
285 | -#if defined(TARGET_WORDS_BIGENDIAN) | ||
286 | - if (endian == DEVICE_LITTLE_ENDIAN) { | ||
287 | - val = bswap64(val); | ||
288 | - } | ||
289 | -#else | ||
290 | - if (endian == DEVICE_BIG_ENDIAN) { | ||
291 | - val = bswap64(val); | ||
292 | - } | ||
293 | -#endif | ||
294 | } else { | ||
295 | /* RAM case */ | ||
296 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
297 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL, | ||
298 | release_lock |= prepare_mmio_access(mr); | ||
299 | |||
300 | /* I/O case */ | ||
301 | - /* TODO: Merge bswap16 into memory_region_dispatch_read. */ | ||
302 | r = memory_region_dispatch_read(mr, addr1, &val, | ||
303 | MO_16 | devend_memop(endian), attrs); | ||
304 | -#if defined(TARGET_WORDS_BIGENDIAN) | ||
305 | - if (endian == DEVICE_LITTLE_ENDIAN) { | ||
306 | - val = bswap16(val); | ||
307 | - } | ||
308 | -#else | ||
309 | - if (endian == DEVICE_BIG_ENDIAN) { | ||
310 | - val = bswap16(val); | ||
311 | - } | ||
312 | -#endif | ||
313 | } else { | ||
314 | /* RAM case */ | ||
315 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
316 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stl_internal, SUFFIX)(ARG1_DECL, | ||
317 | mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
318 | if (l < 4 || !memory_access_is_direct(mr, true)) { | ||
319 | release_lock |= prepare_mmio_access(mr); | ||
320 | - | ||
321 | -#if defined(TARGET_WORDS_BIGENDIAN) | ||
322 | - if (endian == DEVICE_LITTLE_ENDIAN) { | ||
323 | - val = bswap32(val); | ||
324 | - } | ||
325 | -#else | ||
326 | - if (endian == DEVICE_BIG_ENDIAN) { | ||
327 | - val = bswap32(val); | ||
328 | - } | ||
329 | -#endif | ||
330 | - /* TODO: Merge bswap32 into memory_region_dispatch_write. */ | ||
331 | r = memory_region_dispatch_write(mr, addr1, val, | ||
332 | MO_32 | devend_memop(endian), attrs); | ||
333 | } else { | ||
334 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stw_internal, SUFFIX)(ARG1_DECL, | ||
335 | mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
336 | if (l < 2 || !memory_access_is_direct(mr, true)) { | ||
337 | release_lock |= prepare_mmio_access(mr); | ||
338 | - | ||
339 | -#if defined(TARGET_WORDS_BIGENDIAN) | ||
340 | - if (endian == DEVICE_LITTLE_ENDIAN) { | ||
341 | - val = bswap16(val); | ||
342 | - } | ||
343 | -#else | ||
344 | - if (endian == DEVICE_BIG_ENDIAN) { | ||
345 | - val = bswap16(val); | ||
346 | - } | ||
347 | -#endif | ||
348 | - /* TODO: Merge bswap16 into memory_region_dispatch_write. */ | ||
349 | r = memory_region_dispatch_write(mr, addr1, val, | ||
350 | MO_16 | devend_memop(endian), attrs); | ||
351 | } else { | ||
352 | @@ -XXX,XX +XXX,XX @@ static void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL, | ||
353 | mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
354 | if (l < 8 || !memory_access_is_direct(mr, true)) { | ||
355 | release_lock |= prepare_mmio_access(mr); | ||
356 | - | ||
357 | -#if defined(TARGET_WORDS_BIGENDIAN) | ||
358 | - if (endian == DEVICE_LITTLE_ENDIAN) { | ||
359 | - val = bswap64(val); | ||
360 | - } | ||
361 | -#else | ||
362 | - if (endian == DEVICE_BIG_ENDIAN) { | ||
363 | - val = bswap64(val); | ||
364 | - } | ||
365 | -#endif | ||
366 | - /* TODO: Merge bswap64 into memory_region_dispatch_write. */ | ||
367 | r = memory_region_dispatch_write(mr, addr1, val, | ||
368 | MO_64 | devend_memop(endian), attrs); | ||
369 | } else { | ||
370 | -- | 59 | -- |
371 | 2.17.1 | 60 | 2.43.0 |
372 | 61 | ||
373 | 62 | diff view generated by jsdifflib |
1 | From: Tony Nguyen <tony.nguyen@bt.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The memory_region_dispatch_{read|write} operand "unsigned size" is | 3 | CPU_TLB_DYN_*_BITS definitions are only used by accel/tcg/cputlb.c |
4 | being converted into a "MemOp op". | 4 | and accel/tcg/translate-all.c. Move them to accel/tcg/tb-internal.h. |
5 | 5 | ||
6 | Introduce no-op size_memop to aid preparatory conversion of | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | interfaces. | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-ID: <20250305191859.71608-1-philmd@linaro.org> | ||
10 | --- | ||
11 | accel/tcg/tb-internal.h | 27 +++++++++++++++++++++++++++ | ||
12 | include/exec/cpu-defs.h | 26 -------------------------- | ||
13 | 2 files changed, 27 insertions(+), 26 deletions(-) | ||
8 | 14 | ||
9 | Once interfaces are converted, size_memop will be implemented to | 15 | diff --git a/accel/tcg/tb-internal.h b/accel/tcg/tb-internal.h |
10 | return a MemOp from size in bytes. | ||
11 | |||
12 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-Id: <35b8ee74020f67cf40848fb7d5f127cf96c851d6.1566466906.git.tony.nguyen@bt.com> | ||
15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | ||
17 | include/exec/memop.h | 10 ++++++++++ | ||
18 | 1 file changed, 10 insertions(+) | ||
19 | |||
20 | diff --git a/include/exec/memop.h b/include/exec/memop.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/exec/memop.h | 17 | --- a/accel/tcg/tb-internal.h |
23 | +++ b/include/exec/memop.h | 18 | +++ b/accel/tcg/tb-internal.h |
24 | @@ -XXX,XX +XXX,XX @@ typedef enum MemOp { | 19 | @@ -XXX,XX +XXX,XX @@ |
25 | MO_SSIZE = MO_SIZE | MO_SIGN, | 20 | #include "exec/exec-all.h" |
26 | } MemOp; | 21 | #include "exec/translation-block.h" |
27 | 22 | ||
28 | +/* Size in bytes to MemOp. */ | 23 | +#ifdef CONFIG_SOFTMMU |
29 | +static inline unsigned size_memop(unsigned size) | ||
30 | +{ | ||
31 | + /* | ||
32 | + * FIXME: No-op to aid conversion of memory_region_dispatch_{read|write} | ||
33 | + * "unsigned size" operand into a "MemOp op". | ||
34 | + */ | ||
35 | + return size; | ||
36 | +} | ||
37 | + | 24 | + |
25 | +#define CPU_TLB_DYN_MIN_BITS 6 | ||
26 | +#define CPU_TLB_DYN_DEFAULT_BITS 8 | ||
27 | + | ||
28 | +# if HOST_LONG_BITS == 32 | ||
29 | +/* Make sure we do not require a double-word shift for the TLB load */ | ||
30 | +# define CPU_TLB_DYN_MAX_BITS (32 - TARGET_PAGE_BITS) | ||
31 | +# else /* HOST_LONG_BITS == 64 */ | ||
32 | +/* | ||
33 | + * Assuming TARGET_PAGE_BITS==12, with 2**22 entries we can cover 2**(22+12) == | ||
34 | + * 2**34 == 16G of address space. This is roughly what one would expect a | ||
35 | + * TLB to cover in a modern (as of 2018) x86_64 CPU. For instance, Intel | ||
36 | + * Skylake's Level-2 STLB has 16 1G entries. | ||
37 | + * Also, make sure we do not size the TLB past the guest's address space. | ||
38 | + */ | ||
39 | +# ifdef TARGET_PAGE_BITS_VARY | ||
40 | +# define CPU_TLB_DYN_MAX_BITS \ | ||
41 | + MIN(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS) | ||
42 | +# else | ||
43 | +# define CPU_TLB_DYN_MAX_BITS \ | ||
44 | + MIN_CONST(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS) | ||
45 | +# endif | ||
46 | +# endif | ||
47 | + | ||
48 | +#endif /* CONFIG_SOFTMMU */ | ||
49 | + | ||
50 | #ifdef CONFIG_USER_ONLY | ||
51 | #include "user/page-protection.h" | ||
52 | /* | ||
53 | diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/include/exec/cpu-defs.h | ||
56 | +++ b/include/exec/cpu-defs.h | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | |||
59 | #include "exec/target_long.h" | ||
60 | |||
61 | -#if defined(CONFIG_SOFTMMU) && defined(CONFIG_TCG) | ||
62 | -#define CPU_TLB_DYN_MIN_BITS 6 | ||
63 | -#define CPU_TLB_DYN_DEFAULT_BITS 8 | ||
64 | - | ||
65 | -# if HOST_LONG_BITS == 32 | ||
66 | -/* Make sure we do not require a double-word shift for the TLB load */ | ||
67 | -# define CPU_TLB_DYN_MAX_BITS (32 - TARGET_PAGE_BITS) | ||
68 | -# else /* HOST_LONG_BITS == 64 */ | ||
69 | -/* | ||
70 | - * Assuming TARGET_PAGE_BITS==12, with 2**22 entries we can cover 2**(22+12) == | ||
71 | - * 2**34 == 16G of address space. This is roughly what one would expect a | ||
72 | - * TLB to cover in a modern (as of 2018) x86_64 CPU. For instance, Intel | ||
73 | - * Skylake's Level-2 STLB has 16 1G entries. | ||
74 | - * Also, make sure we do not size the TLB past the guest's address space. | ||
75 | - */ | ||
76 | -# ifdef TARGET_PAGE_BITS_VARY | ||
77 | -# define CPU_TLB_DYN_MAX_BITS \ | ||
78 | - MIN(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS) | ||
79 | -# else | ||
80 | -# define CPU_TLB_DYN_MAX_BITS \ | ||
81 | - MIN_CONST(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS) | ||
82 | -# endif | ||
83 | -# endif | ||
84 | - | ||
85 | -#endif /* CONFIG_SOFTMMU && CONFIG_TCG */ | ||
86 | - | ||
38 | #endif | 87 | #endif |
39 | -- | 88 | -- |
40 | 2.17.1 | 89 | 2.43.0 |
41 | 90 | ||
42 | 91 | diff view generated by jsdifflib |
1 | Let the user-only watchpoint stubs resolve to empty inline functions. | 1 | Re-use the TARGET_PAGE_BITS_VARY mechanism to define |
---|---|---|---|
2 | TARGET_PAGE_SIZE and friends when not compiling per-target. | ||
3 | Inline qemu_target_page_{size,mask,bits} as they are now trivial. | ||
2 | 4 | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 5 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
4 | Reviewed-by: David Hildenbrand <david@redhat.com> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | --- | 7 | --- |
7 | include/hw/core/cpu.h | 23 +++++++++++++++++++++++ | 8 | include/exec/cpu-all.h | 21 +------------- |
8 | exec.c | 26 ++------------------------ | 9 | include/exec/poison.h | 4 --- |
9 | 2 files changed, 25 insertions(+), 24 deletions(-) | 10 | include/exec/target_page.h | 58 ++++++++++++++++++++++++++++++++++---- |
11 | page-target.c | 18 ------------ | ||
12 | page-vary-target.c | 2 -- | ||
13 | 5 files changed, 53 insertions(+), 50 deletions(-) | ||
10 | 14 | ||
11 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h | 15 | diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/include/hw/core/cpu.h | 17 | --- a/include/exec/cpu-all.h |
14 | +++ b/include/hw/core/cpu.h | 18 | +++ b/include/exec/cpu-all.h |
15 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_breakpoint_test(CPUState *cpu, vaddr pc, int mask) | 19 | @@ -XXX,XX +XXX,XX @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val |
16 | return false; | 20 | |
17 | } | 21 | /* page related stuff */ |
18 | 22 | #include "exec/cpu-defs.h" | |
19 | +#ifdef CONFIG_USER_ONLY | 23 | -#ifdef TARGET_PAGE_BITS_VARY |
20 | +static inline int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, | 24 | -# include "exec/page-vary.h" |
21 | + int flags, CPUWatchpoint **watchpoint) | 25 | -extern const TargetPageBits target_page; |
26 | -# ifdef CONFIG_DEBUG_TCG | ||
27 | -# define TARGET_PAGE_BITS ({ assert(target_page.decided); \ | ||
28 | - target_page.bits; }) | ||
29 | -# define TARGET_PAGE_MASK ({ assert(target_page.decided); \ | ||
30 | - (target_long)target_page.mask; }) | ||
31 | -# else | ||
32 | -# define TARGET_PAGE_BITS target_page.bits | ||
33 | -# define TARGET_PAGE_MASK ((target_long)target_page.mask) | ||
34 | -# endif | ||
35 | -# define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK) | ||
36 | -#else | ||
37 | -# define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS | ||
38 | -# define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) | ||
39 | -# define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) | ||
40 | -#endif | ||
41 | - | ||
42 | -#define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE) | ||
43 | +#include "exec/target_page.h" | ||
44 | |||
45 | CPUArchState *cpu_copy(CPUArchState *env); | ||
46 | |||
47 | diff --git a/include/exec/poison.h b/include/exec/poison.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/include/exec/poison.h | ||
50 | +++ b/include/exec/poison.h | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | #pragma GCC poison TARGET_FMT_ld | ||
53 | #pragma GCC poison TARGET_FMT_lu | ||
54 | |||
55 | -#pragma GCC poison TARGET_PAGE_SIZE | ||
56 | -#pragma GCC poison TARGET_PAGE_MASK | ||
57 | -#pragma GCC poison TARGET_PAGE_BITS | ||
58 | -#pragma GCC poison TARGET_PAGE_ALIGN | ||
59 | #pragma GCC poison TARGET_PHYS_ADDR_SPACE_BITS | ||
60 | |||
61 | #pragma GCC poison CPU_INTERRUPT_HARD | ||
62 | diff --git a/include/exec/target_page.h b/include/exec/target_page.h | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/include/exec/target_page.h | ||
65 | +++ b/include/exec/target_page.h | ||
66 | @@ -XXX,XX +XXX,XX @@ | ||
67 | #ifndef EXEC_TARGET_PAGE_H | ||
68 | #define EXEC_TARGET_PAGE_H | ||
69 | |||
70 | -size_t qemu_target_page_size(void); | ||
71 | -int qemu_target_page_mask(void); | ||
72 | -int qemu_target_page_bits(void); | ||
73 | -int qemu_target_page_bits_min(void); | ||
74 | - | ||
75 | -size_t qemu_target_pages_to_MiB(size_t pages); | ||
76 | +/* | ||
77 | + * If compiling per-target, get the real values. | ||
78 | + * For generic code, reuse the mechanism for variable page size. | ||
79 | + */ | ||
80 | +#ifdef COMPILING_PER_TARGET | ||
81 | +#include "cpu-param.h" | ||
82 | +#include "exec/target_long.h" | ||
83 | +#define TARGET_PAGE_TYPE target_long | ||
84 | +#else | ||
85 | +#define TARGET_PAGE_BITS_VARY | ||
86 | +#define TARGET_PAGE_TYPE int | ||
87 | +#endif | ||
88 | + | ||
89 | +#ifdef TARGET_PAGE_BITS_VARY | ||
90 | +# include "exec/page-vary.h" | ||
91 | +extern const TargetPageBits target_page; | ||
92 | +# ifdef CONFIG_DEBUG_TCG | ||
93 | +# define TARGET_PAGE_BITS ({ assert(target_page.decided); \ | ||
94 | + target_page.bits; }) | ||
95 | +# define TARGET_PAGE_MASK ({ assert(target_page.decided); \ | ||
96 | + (TARGET_PAGE_TYPE)target_page.mask; }) | ||
97 | +# else | ||
98 | +# define TARGET_PAGE_BITS target_page.bits | ||
99 | +# define TARGET_PAGE_MASK ((TARGET_PAGE_TYPE)target_page.mask) | ||
100 | +# endif | ||
101 | +# define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK) | ||
102 | +#else | ||
103 | +# define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS | ||
104 | +# define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) | ||
105 | +# define TARGET_PAGE_MASK ((TARGET_PAGE_TYPE)-1 << TARGET_PAGE_BITS) | ||
106 | +#endif | ||
107 | + | ||
108 | +#define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE) | ||
109 | + | ||
110 | +static inline size_t qemu_target_page_size(void) | ||
22 | +{ | 111 | +{ |
23 | + return -ENOSYS; | 112 | + return TARGET_PAGE_SIZE; |
24 | +} | 113 | +} |
25 | + | 114 | + |
26 | +static inline int cpu_watchpoint_remove(CPUState *cpu, vaddr addr, | 115 | +static inline int qemu_target_page_mask(void) |
27 | + vaddr len, int flags) | ||
28 | +{ | 116 | +{ |
29 | + return -ENOSYS; | 117 | + return TARGET_PAGE_MASK; |
30 | +} | 118 | +} |
31 | + | 119 | + |
32 | +static inline void cpu_watchpoint_remove_by_ref(CPUState *cpu, | 120 | +static inline int qemu_target_page_bits(void) |
33 | + CPUWatchpoint *wp) | ||
34 | +{ | 121 | +{ |
122 | + return TARGET_PAGE_BITS; | ||
35 | +} | 123 | +} |
36 | + | 124 | + |
37 | +static inline void cpu_watchpoint_remove_all(CPUState *cpu, int mask) | 125 | +int qemu_target_page_bits_min(void); |
38 | +{ | 126 | +size_t qemu_target_pages_to_MiB(size_t pages); |
39 | +} | 127 | + |
40 | +#else | 128 | #endif |
41 | int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, | 129 | diff --git a/page-target.c b/page-target.c |
42 | int flags, CPUWatchpoint **watchpoint); | ||
43 | int cpu_watchpoint_remove(CPUState *cpu, vaddr addr, | ||
44 | vaddr len, int flags); | ||
45 | void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint); | ||
46 | void cpu_watchpoint_remove_all(CPUState *cpu, int mask); | ||
47 | +#endif | ||
48 | |||
49 | /** | ||
50 | * cpu_get_address_space: | ||
51 | diff --git a/exec.c b/exec.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | 130 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/exec.c | 131 | --- a/page-target.c |
54 | +++ b/exec.c | 132 | +++ b/page-target.c |
55 | @@ -XXX,XX +XXX,XX @@ static void breakpoint_invalidate(CPUState *cpu, target_ulong pc) | 133 | @@ -XXX,XX +XXX,XX @@ |
56 | } | 134 | |
57 | #endif | 135 | #include "qemu/osdep.h" |
58 | 136 | #include "exec/target_page.h" | |
59 | -#if defined(CONFIG_USER_ONLY) | 137 | -#include "exec/cpu-defs.h" |
60 | -void cpu_watchpoint_remove_all(CPUState *cpu, int mask) | 138 | -#include "cpu.h" |
139 | -#include "exec/cpu-all.h" | ||
61 | - | 140 | - |
141 | -size_t qemu_target_page_size(void) | ||
62 | -{ | 142 | -{ |
143 | - return TARGET_PAGE_SIZE; | ||
63 | -} | 144 | -} |
64 | - | 145 | - |
65 | -int cpu_watchpoint_remove(CPUState *cpu, vaddr addr, vaddr len, | 146 | -int qemu_target_page_mask(void) |
66 | - int flags) | ||
67 | -{ | 147 | -{ |
68 | - return -ENOSYS; | 148 | - return TARGET_PAGE_MASK; |
69 | -} | 149 | -} |
70 | - | 150 | - |
71 | -void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint) | 151 | -int qemu_target_page_bits(void) |
72 | -{ | 152 | -{ |
153 | - return TARGET_PAGE_BITS; | ||
73 | -} | 154 | -} |
74 | - | 155 | |
75 | -int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, | 156 | int qemu_target_page_bits_min(void) |
76 | - int flags, CPUWatchpoint **watchpoint) | 157 | { |
77 | -{ | 158 | diff --git a/page-vary-target.c b/page-vary-target.c |
78 | - return -ENOSYS; | 159 | index XXXXXXX..XXXXXXX 100644 |
79 | -} | 160 | --- a/page-vary-target.c |
80 | -#else | 161 | +++ b/page-vary-target.c |
81 | +#ifndef CONFIG_USER_ONLY | 162 | @@ -XXX,XX +XXX,XX @@ bool set_preferred_target_page_bits(int bits) |
82 | /* Add a watchpoint. */ | 163 | |
83 | int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, | 164 | void finalize_target_page_bits(void) |
84 | int flags, CPUWatchpoint **watchpoint) | 165 | { |
85 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_watchpoint_address_matches(CPUWatchpoint *wp, | 166 | -#ifdef TARGET_PAGE_BITS_VARY |
86 | 167 | finalize_target_page_bits_common(TARGET_PAGE_BITS_MIN); | |
87 | return !(addr > wpend || wp->vaddr > addrend); | 168 | -#endif |
88 | } | 169 | } |
89 | - | ||
90 | -#endif | ||
91 | +#endif /* !CONFIG_USER_ONLY */ | ||
92 | |||
93 | /* Add a breakpoint. */ | ||
94 | int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags, | ||
95 | -- | 170 | -- |
96 | 2.17.1 | 171 | 2.43.0 |
97 | |||
98 | diff view generated by jsdifflib |
1 | The raising of exceptions from check_watchpoint, buried inside | 1 | Some of these bits are actually common to all cpus; while the |
---|---|---|---|
2 | of the I/O subsystem, is fundamentally broken. We do not have | 2 | reset have common reservations for target-specific usage. |
3 | the helper return address with which we can unwind guest state. | 3 | While generic code cannot know what the target-specific usage is, |
4 | common code can know what to do with the bits, e.g. single-step. | ||
4 | 5 | ||
5 | Replace PHYS_SECTION_WATCH and io_mem_watch with TLB_WATCHPOINT. | 6 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Move the call to cpu_check_watchpoint into the cputlb helpers | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | where we do have the helper return address. | 8 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
8 | |||
9 | This allows watchpoints on RAM to bypass the full i/o access path. | ||
10 | |||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Reviewed-by: David Hildenbrand <david@redhat.com> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
14 | --- | 10 | --- |
15 | include/exec/cpu-all.h | 5 +- | 11 | include/exec/cpu-all.h | 53 +-------------------------- |
16 | accel/tcg/cputlb.c | 89 ++++++++++++++++++++++++++++---- | 12 | include/exec/cpu-interrupt.h | 70 ++++++++++++++++++++++++++++++++++++ |
17 | exec.c | 114 +++-------------------------------------- | 13 | include/exec/poison.h | 13 ------- |
18 | 3 files changed, 90 insertions(+), 118 deletions(-) | 14 | 3 files changed, 71 insertions(+), 65 deletions(-) |
15 | create mode 100644 include/exec/cpu-interrupt.h | ||
19 | 16 | ||
20 | diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h | 17 | diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h |
21 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/exec/cpu-all.h | 19 | --- a/include/exec/cpu-all.h |
23 | +++ b/include/exec/cpu-all.h | 20 | +++ b/include/exec/cpu-all.h |
24 | @@ -XXX,XX +XXX,XX @@ CPUArchState *cpu_copy(CPUArchState *env); | 21 | @@ -XXX,XX +XXX,XX @@ |
25 | #define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS - 2)) | 22 | |
26 | /* Set if TLB entry is an IO callback. */ | 23 | #include "exec/page-protection.h" |
27 | #define TLB_MMIO (1 << (TARGET_PAGE_BITS - 3)) | 24 | #include "exec/cpu-common.h" |
28 | +/* Set if TLB entry contains a watchpoint. */ | 25 | +#include "exec/cpu-interrupt.h" |
29 | +#define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS - 4)) | 26 | #include "exec/memory.h" |
30 | 27 | #include "exec/tswap.h" | |
31 | /* Use this mask to check interception with an alignment mask | 28 | #include "hw/core/cpu.h" |
32 | * in a TCG backend. | 29 | @@ -XXX,XX +XXX,XX @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val |
33 | */ | 30 | |
34 | -#define TLB_FLAGS_MASK (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO) | 31 | CPUArchState *cpu_copy(CPUArchState *env); |
35 | +#define TLB_FLAGS_MASK \ | 32 | |
36 | + (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO | TLB_WATCHPOINT) | 33 | -/* Flags for use in ENV->INTERRUPT_PENDING. |
37 | 34 | - | |
38 | /** | 35 | - The numbers assigned here are non-sequential in order to preserve |
39 | * tlb_hit_page: return true if page aligned @addr is a hit against the | 36 | - binary compatibility with the vmstate dump. Bit 0 (0x0001) was |
40 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | 37 | - previously used for CPU_INTERRUPT_EXIT, and is cleared when loading |
38 | - the vmstate dump. */ | ||
39 | - | ||
40 | -/* External hardware interrupt pending. This is typically used for | ||
41 | - interrupts from devices. */ | ||
42 | -#define CPU_INTERRUPT_HARD 0x0002 | ||
43 | - | ||
44 | -/* Exit the current TB. This is typically used when some system-level device | ||
45 | - makes some change to the memory mapping. E.g. the a20 line change. */ | ||
46 | -#define CPU_INTERRUPT_EXITTB 0x0004 | ||
47 | - | ||
48 | -/* Halt the CPU. */ | ||
49 | -#define CPU_INTERRUPT_HALT 0x0020 | ||
50 | - | ||
51 | -/* Debug event pending. */ | ||
52 | -#define CPU_INTERRUPT_DEBUG 0x0080 | ||
53 | - | ||
54 | -/* Reset signal. */ | ||
55 | -#define CPU_INTERRUPT_RESET 0x0400 | ||
56 | - | ||
57 | -/* Several target-specific external hardware interrupts. Each target/cpu.h | ||
58 | - should define proper names based on these defines. */ | ||
59 | -#define CPU_INTERRUPT_TGT_EXT_0 0x0008 | ||
60 | -#define CPU_INTERRUPT_TGT_EXT_1 0x0010 | ||
61 | -#define CPU_INTERRUPT_TGT_EXT_2 0x0040 | ||
62 | -#define CPU_INTERRUPT_TGT_EXT_3 0x0200 | ||
63 | -#define CPU_INTERRUPT_TGT_EXT_4 0x1000 | ||
64 | - | ||
65 | -/* Several target-specific internal interrupts. These differ from the | ||
66 | - preceding target-specific interrupts in that they are intended to | ||
67 | - originate from within the cpu itself, typically in response to some | ||
68 | - instruction being executed. These, therefore, are not masked while | ||
69 | - single-stepping within the debugger. */ | ||
70 | -#define CPU_INTERRUPT_TGT_INT_0 0x0100 | ||
71 | -#define CPU_INTERRUPT_TGT_INT_1 0x0800 | ||
72 | -#define CPU_INTERRUPT_TGT_INT_2 0x2000 | ||
73 | - | ||
74 | -/* First unused bit: 0x4000. */ | ||
75 | - | ||
76 | -/* The set of all bits that should be masked when single-stepping. */ | ||
77 | -#define CPU_INTERRUPT_SSTEP_MASK \ | ||
78 | - (CPU_INTERRUPT_HARD \ | ||
79 | - | CPU_INTERRUPT_TGT_EXT_0 \ | ||
80 | - | CPU_INTERRUPT_TGT_EXT_1 \ | ||
81 | - | CPU_INTERRUPT_TGT_EXT_2 \ | ||
82 | - | CPU_INTERRUPT_TGT_EXT_3 \ | ||
83 | - | CPU_INTERRUPT_TGT_EXT_4) | ||
84 | - | ||
85 | #include "cpu.h" | ||
86 | |||
87 | #ifdef CONFIG_USER_ONLY | ||
88 | diff --git a/include/exec/cpu-interrupt.h b/include/exec/cpu-interrupt.h | ||
89 | new file mode 100644 | ||
90 | index XXXXXXX..XXXXXXX | ||
91 | --- /dev/null | ||
92 | +++ b/include/exec/cpu-interrupt.h | ||
93 | @@ -XXX,XX +XXX,XX @@ | ||
94 | +/* | ||
95 | + * Flags for use with cpu_interrupt() | ||
96 | + * | ||
97 | + * Copyright (c) 2003 Fabrice Bellard | ||
98 | + * SPDX-License-Identifier: LGPL-2.1-or-later | ||
99 | + */ | ||
100 | + | ||
101 | +#ifndef CPU_INTERRUPT_H | ||
102 | +#define CPU_INTERRUPT_H | ||
103 | + | ||
104 | +/* | ||
105 | + * The numbers assigned here are non-sequential in order to preserve binary | ||
106 | + * compatibility with the vmstate dump. Bit 0 (0x0001) was previously used | ||
107 | + * for CPU_INTERRUPT_EXIT, and is cleared when loading the vmstate dump. | ||
108 | + */ | ||
109 | + | ||
110 | +/* | ||
111 | + * External hardware interrupt pending. | ||
112 | + * This is typically used for interrupts from devices. | ||
113 | + */ | ||
114 | +#define CPU_INTERRUPT_HARD 0x0002 | ||
115 | + | ||
116 | +/* | ||
117 | + * Exit the current TB. This is typically used when some system-level device | ||
118 | + * makes some change to the memory mapping. E.g. the a20 line change. | ||
119 | + */ | ||
120 | +#define CPU_INTERRUPT_EXITTB 0x0004 | ||
121 | + | ||
122 | +/* Halt the CPU. */ | ||
123 | +#define CPU_INTERRUPT_HALT 0x0020 | ||
124 | + | ||
125 | +/* Debug event pending. */ | ||
126 | +#define CPU_INTERRUPT_DEBUG 0x0080 | ||
127 | + | ||
128 | +/* Reset signal. */ | ||
129 | +#define CPU_INTERRUPT_RESET 0x0400 | ||
130 | + | ||
131 | +/* | ||
132 | + * Several target-specific external hardware interrupts. Each target/cpu.h | ||
133 | + * should define proper names based on these defines. | ||
134 | + */ | ||
135 | +#define CPU_INTERRUPT_TGT_EXT_0 0x0008 | ||
136 | +#define CPU_INTERRUPT_TGT_EXT_1 0x0010 | ||
137 | +#define CPU_INTERRUPT_TGT_EXT_2 0x0040 | ||
138 | +#define CPU_INTERRUPT_TGT_EXT_3 0x0200 | ||
139 | +#define CPU_INTERRUPT_TGT_EXT_4 0x1000 | ||
140 | + | ||
141 | +/* | ||
142 | + * Several target-specific internal interrupts. These differ from the | ||
143 | + * preceding target-specific interrupts in that they are intended to | ||
144 | + * originate from within the cpu itself, typically in response to some | ||
145 | + * instruction being executed. These, therefore, are not masked while | ||
146 | + * single-stepping within the debugger. | ||
147 | + */ | ||
148 | +#define CPU_INTERRUPT_TGT_INT_0 0x0100 | ||
149 | +#define CPU_INTERRUPT_TGT_INT_1 0x0800 | ||
150 | +#define CPU_INTERRUPT_TGT_INT_2 0x2000 | ||
151 | + | ||
152 | +/* First unused bit: 0x4000. */ | ||
153 | + | ||
154 | +/* The set of all bits that should be masked when single-stepping. */ | ||
155 | +#define CPU_INTERRUPT_SSTEP_MASK \ | ||
156 | + (CPU_INTERRUPT_HARD \ | ||
157 | + | CPU_INTERRUPT_TGT_EXT_0 \ | ||
158 | + | CPU_INTERRUPT_TGT_EXT_1 \ | ||
159 | + | CPU_INTERRUPT_TGT_EXT_2 \ | ||
160 | + | CPU_INTERRUPT_TGT_EXT_3 \ | ||
161 | + | CPU_INTERRUPT_TGT_EXT_4) | ||
162 | + | ||
163 | +#endif /* CPU_INTERRUPT_H */ | ||
164 | diff --git a/include/exec/poison.h b/include/exec/poison.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | 165 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/accel/tcg/cputlb.c | 166 | --- a/include/exec/poison.h |
43 | +++ b/accel/tcg/cputlb.c | 167 | +++ b/include/exec/poison.h |
44 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | 168 | @@ -XXX,XX +XXX,XX @@ |
45 | hwaddr iotlb, xlat, sz, paddr_page; | 169 | |
46 | target_ulong vaddr_page; | 170 | #pragma GCC poison TARGET_PHYS_ADDR_SPACE_BITS |
47 | int asidx = cpu_asidx_from_attrs(cpu, attrs); | 171 | |
48 | + int wp_flags; | 172 | -#pragma GCC poison CPU_INTERRUPT_HARD |
49 | 173 | -#pragma GCC poison CPU_INTERRUPT_EXITTB | |
50 | assert_cpu_is_self(cpu); | 174 | -#pragma GCC poison CPU_INTERRUPT_HALT |
51 | 175 | -#pragma GCC poison CPU_INTERRUPT_DEBUG | |
52 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | 176 | -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_0 |
53 | code_address = address; | 177 | -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_1 |
54 | iotlb = memory_region_section_get_iotlb(cpu, section, vaddr_page, | 178 | -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_2 |
55 | paddr_page, xlat, prot, &address); | 179 | -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_3 |
56 | + wp_flags = cpu_watchpoint_address_matches(cpu, vaddr_page, | 180 | -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_4 |
57 | + TARGET_PAGE_SIZE); | 181 | -#pragma GCC poison CPU_INTERRUPT_TGT_INT_0 |
58 | 182 | -#pragma GCC poison CPU_INTERRUPT_TGT_INT_1 | |
59 | index = tlb_index(env, mmu_idx, vaddr_page); | 183 | -#pragma GCC poison CPU_INTERRUPT_TGT_INT_2 |
60 | te = tlb_entry(env, mmu_idx, vaddr_page); | ||
61 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | ||
62 | tn.addend = addend - vaddr_page; | ||
63 | if (prot & PAGE_READ) { | ||
64 | tn.addr_read = address; | ||
65 | + if (wp_flags & BP_MEM_READ) { | ||
66 | + tn.addr_read |= TLB_WATCHPOINT; | ||
67 | + } | ||
68 | } else { | ||
69 | tn.addr_read = -1; | ||
70 | } | ||
71 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | ||
72 | if (prot & PAGE_WRITE_INV) { | ||
73 | tn.addr_write |= TLB_INVALID_MASK; | ||
74 | } | ||
75 | + if (wp_flags & BP_MEM_WRITE) { | ||
76 | + tn.addr_write |= TLB_WATCHPOINT; | ||
77 | + } | ||
78 | } | ||
79 | |||
80 | copy_tlb_helper_locked(te, &tn); | ||
81 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
82 | tlb_addr &= ~TLB_INVALID_MASK; | ||
83 | } | ||
84 | |||
85 | - /* Handle an IO access. */ | ||
86 | + /* Handle anything that isn't just a straight memory access. */ | ||
87 | if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { | ||
88 | + CPUIOTLBEntry *iotlbentry; | ||
89 | + | ||
90 | + /* For anything that is unaligned, recurse through full_load. */ | ||
91 | if ((addr & (size - 1)) != 0) { | ||
92 | goto do_unaligned_access; | ||
93 | } | ||
94 | - return io_readx(env, &env_tlb(env)->d[mmu_idx].iotlb[index], | ||
95 | - mmu_idx, addr, retaddr, access_type, op); | ||
96 | + | ||
97 | + iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
98 | + | ||
99 | + /* Handle watchpoints. */ | ||
100 | + if (unlikely(tlb_addr & TLB_WATCHPOINT)) { | ||
101 | + /* On watchpoint hit, this will longjmp out. */ | ||
102 | + cpu_check_watchpoint(env_cpu(env), addr, size, | ||
103 | + iotlbentry->attrs, BP_MEM_READ, retaddr); | ||
104 | + | ||
105 | + /* The backing page may or may not require I/O. */ | ||
106 | + tlb_addr &= ~TLB_WATCHPOINT; | ||
107 | + if ((tlb_addr & ~TARGET_PAGE_MASK) == 0) { | ||
108 | + goto do_aligned_access; | ||
109 | + } | ||
110 | + } | ||
111 | + | ||
112 | + /* Handle I/O access. */ | ||
113 | + return io_readx(env, iotlbentry, mmu_idx, addr, | ||
114 | + retaddr, access_type, op); | ||
115 | } | ||
116 | |||
117 | /* Handle slow unaligned access (it spans two pages or IO). */ | ||
118 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
119 | return res & MAKE_64BIT_MASK(0, size * 8); | ||
120 | } | ||
121 | |||
122 | + do_aligned_access: | ||
123 | haddr = (void *)((uintptr_t)addr + entry->addend); | ||
124 | switch (op) { | ||
125 | case MO_UB: | ||
126 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
127 | tlb_addr = tlb_addr_write(entry) & ~TLB_INVALID_MASK; | ||
128 | } | ||
129 | |||
130 | - /* Handle an IO access. */ | ||
131 | + /* Handle anything that isn't just a straight memory access. */ | ||
132 | if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { | ||
133 | + CPUIOTLBEntry *iotlbentry; | ||
134 | + | ||
135 | + /* For anything that is unaligned, recurse through byte stores. */ | ||
136 | if ((addr & (size - 1)) != 0) { | ||
137 | goto do_unaligned_access; | ||
138 | } | ||
139 | - io_writex(env, &env_tlb(env)->d[mmu_idx].iotlb[index], mmu_idx, | ||
140 | - val, addr, retaddr, op); | ||
141 | + | ||
142 | + iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
143 | + | ||
144 | + /* Handle watchpoints. */ | ||
145 | + if (unlikely(tlb_addr & TLB_WATCHPOINT)) { | ||
146 | + /* On watchpoint hit, this will longjmp out. */ | ||
147 | + cpu_check_watchpoint(env_cpu(env), addr, size, | ||
148 | + iotlbentry->attrs, BP_MEM_WRITE, retaddr); | ||
149 | + | ||
150 | + /* The backing page may or may not require I/O. */ | ||
151 | + tlb_addr &= ~TLB_WATCHPOINT; | ||
152 | + if ((tlb_addr & ~TARGET_PAGE_MASK) == 0) { | ||
153 | + goto do_aligned_access; | ||
154 | + } | ||
155 | + } | ||
156 | + | ||
157 | + /* Handle I/O access. */ | ||
158 | + io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, op); | ||
159 | return; | ||
160 | } | ||
161 | |||
162 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
163 | index2 = tlb_index(env, mmu_idx, page2); | ||
164 | entry2 = tlb_entry(env, mmu_idx, page2); | ||
165 | tlb_addr2 = tlb_addr_write(entry2); | ||
166 | - if (!tlb_hit_page(tlb_addr2, page2) | ||
167 | - && !victim_tlb_hit(env, mmu_idx, index2, tlb_off, page2)) { | ||
168 | - tlb_fill(env_cpu(env), page2, size2, MMU_DATA_STORE, | ||
169 | - mmu_idx, retaddr); | ||
170 | + if (!tlb_hit_page(tlb_addr2, page2)) { | ||
171 | + if (!victim_tlb_hit(env, mmu_idx, index2, tlb_off, page2)) { | ||
172 | + tlb_fill(env_cpu(env), page2, size2, MMU_DATA_STORE, | ||
173 | + mmu_idx, retaddr); | ||
174 | + index2 = tlb_index(env, mmu_idx, page2); | ||
175 | + entry2 = tlb_entry(env, mmu_idx, page2); | ||
176 | + } | ||
177 | + tlb_addr2 = tlb_addr_write(entry2); | ||
178 | + } | ||
179 | + | ||
180 | + /* | ||
181 | + * Handle watchpoints. Since this may trap, all checks | ||
182 | + * must happen before any store. | ||
183 | + */ | ||
184 | + if (unlikely(tlb_addr & TLB_WATCHPOINT)) { | ||
185 | + cpu_check_watchpoint(env_cpu(env), addr, size - size2, | ||
186 | + env_tlb(env)->d[mmu_idx].iotlb[index].attrs, | ||
187 | + BP_MEM_WRITE, retaddr); | ||
188 | + } | ||
189 | + if (unlikely(tlb_addr2 & TLB_WATCHPOINT)) { | ||
190 | + cpu_check_watchpoint(env_cpu(env), page2, size2, | ||
191 | + env_tlb(env)->d[mmu_idx].iotlb[index2].attrs, | ||
192 | + BP_MEM_WRITE, retaddr); | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
197 | return; | ||
198 | } | ||
199 | |||
200 | + do_aligned_access: | ||
201 | haddr = (void *)((uintptr_t)addr + entry->addend); | ||
202 | switch (op) { | ||
203 | case MO_UB: | ||
204 | diff --git a/exec.c b/exec.c | ||
205 | index XXXXXXX..XXXXXXX 100644 | ||
206 | --- a/exec.c | ||
207 | +++ b/exec.c | ||
208 | @@ -XXX,XX +XXX,XX @@ typedef struct subpage_t { | ||
209 | #define PHYS_SECTION_UNASSIGNED 0 | ||
210 | #define PHYS_SECTION_NOTDIRTY 1 | ||
211 | #define PHYS_SECTION_ROM 2 | ||
212 | -#define PHYS_SECTION_WATCH 3 | ||
213 | |||
214 | static void io_mem_init(void); | ||
215 | static void memory_map_init(void); | ||
216 | static void tcg_log_global_after_sync(MemoryListener *listener); | ||
217 | static void tcg_commit(MemoryListener *listener); | ||
218 | |||
219 | -static MemoryRegion io_mem_watch; | ||
220 | - | 184 | - |
221 | /** | 185 | #pragma GCC poison CONFIG_ALPHA_DIS |
222 | * CPUAddressSpace: all the information a CPU needs about an AddressSpace | 186 | #pragma GCC poison CONFIG_HPPA_DIS |
223 | * @cpu: the CPU whose AddressSpace this is | 187 | #pragma GCC poison CONFIG_I386_DIS |
224 | @@ -XXX,XX +XXX,XX @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, | ||
225 | target_ulong *address) | ||
226 | { | ||
227 | hwaddr iotlb; | ||
228 | - int flags, match; | ||
229 | |||
230 | if (memory_region_is_ram(section->mr)) { | ||
231 | /* Normal RAM. */ | ||
232 | @@ -XXX,XX +XXX,XX @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, | ||
233 | iotlb += xlat; | ||
234 | } | ||
235 | |||
236 | - /* Avoid trapping reads of pages with a write breakpoint. */ | ||
237 | - match = (prot & PAGE_READ ? BP_MEM_READ : 0) | ||
238 | - | (prot & PAGE_WRITE ? BP_MEM_WRITE : 0); | ||
239 | - flags = cpu_watchpoint_address_matches(cpu, vaddr, TARGET_PAGE_SIZE); | ||
240 | - if (flags & match) { | ||
241 | - /* | ||
242 | - * Make accesses to pages with watchpoints go via the | ||
243 | - * watchpoint trap routines. | ||
244 | - */ | ||
245 | - iotlb = PHYS_SECTION_WATCH + paddr; | ||
246 | - *address |= TLB_MMIO; | ||
247 | - } | ||
248 | - | ||
249 | return iotlb; | ||
250 | } | ||
251 | #endif /* defined(CONFIG_USER_ONLY) */ | ||
252 | @@ -XXX,XX +XXX,XX @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, | ||
253 | |||
254 | assert(tcg_enabled()); | ||
255 | if (cpu->watchpoint_hit) { | ||
256 | - /* We re-entered the check after replacing the TB. Now raise | ||
257 | - * the debug interrupt so that is will trigger after the | ||
258 | - * current instruction. */ | ||
259 | + /* | ||
260 | + * We re-entered the check after replacing the TB. | ||
261 | + * Now raise the debug interrupt so that it will | ||
262 | + * trigger after the current instruction. | ||
263 | + */ | ||
264 | + qemu_mutex_lock_iothread(); | ||
265 | cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); | ||
266 | + qemu_mutex_unlock_iothread(); | ||
267 | return; | ||
268 | } | ||
269 | |||
270 | @@ -XXX,XX +XXX,XX @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, | ||
271 | } | ||
272 | } | ||
273 | |||
274 | -static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) | ||
275 | -{ | ||
276 | - CPUState *cpu = current_cpu; | ||
277 | - vaddr addr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset; | ||
278 | - | ||
279 | - cpu_check_watchpoint(cpu, addr, len, attrs, flags, 0); | ||
280 | -} | ||
281 | - | ||
282 | -/* Watchpoint access routines. Watchpoints are inserted using TLB tricks, | ||
283 | - so these check for a hit then pass through to the normal out-of-line | ||
284 | - phys routines. */ | ||
285 | -static MemTxResult watch_mem_read(void *opaque, hwaddr addr, uint64_t *pdata, | ||
286 | - unsigned size, MemTxAttrs attrs) | ||
287 | -{ | ||
288 | - MemTxResult res; | ||
289 | - uint64_t data; | ||
290 | - int asidx = cpu_asidx_from_attrs(current_cpu, attrs); | ||
291 | - AddressSpace *as = current_cpu->cpu_ases[asidx].as; | ||
292 | - | ||
293 | - check_watchpoint(addr & ~TARGET_PAGE_MASK, size, attrs, BP_MEM_READ); | ||
294 | - switch (size) { | ||
295 | - case 1: | ||
296 | - data = address_space_ldub(as, addr, attrs, &res); | ||
297 | - break; | ||
298 | - case 2: | ||
299 | - data = address_space_lduw(as, addr, attrs, &res); | ||
300 | - break; | ||
301 | - case 4: | ||
302 | - data = address_space_ldl(as, addr, attrs, &res); | ||
303 | - break; | ||
304 | - case 8: | ||
305 | - data = address_space_ldq(as, addr, attrs, &res); | ||
306 | - break; | ||
307 | - default: abort(); | ||
308 | - } | ||
309 | - *pdata = data; | ||
310 | - return res; | ||
311 | -} | ||
312 | - | ||
313 | -static MemTxResult watch_mem_write(void *opaque, hwaddr addr, | ||
314 | - uint64_t val, unsigned size, | ||
315 | - MemTxAttrs attrs) | ||
316 | -{ | ||
317 | - MemTxResult res; | ||
318 | - int asidx = cpu_asidx_from_attrs(current_cpu, attrs); | ||
319 | - AddressSpace *as = current_cpu->cpu_ases[asidx].as; | ||
320 | - | ||
321 | - check_watchpoint(addr & ~TARGET_PAGE_MASK, size, attrs, BP_MEM_WRITE); | ||
322 | - switch (size) { | ||
323 | - case 1: | ||
324 | - address_space_stb(as, addr, val, attrs, &res); | ||
325 | - break; | ||
326 | - case 2: | ||
327 | - address_space_stw(as, addr, val, attrs, &res); | ||
328 | - break; | ||
329 | - case 4: | ||
330 | - address_space_stl(as, addr, val, attrs, &res); | ||
331 | - break; | ||
332 | - case 8: | ||
333 | - address_space_stq(as, addr, val, attrs, &res); | ||
334 | - break; | ||
335 | - default: abort(); | ||
336 | - } | ||
337 | - return res; | ||
338 | -} | ||
339 | - | ||
340 | -static const MemoryRegionOps watch_mem_ops = { | ||
341 | - .read_with_attrs = watch_mem_read, | ||
342 | - .write_with_attrs = watch_mem_write, | ||
343 | - .endianness = DEVICE_NATIVE_ENDIAN, | ||
344 | - .valid = { | ||
345 | - .min_access_size = 1, | ||
346 | - .max_access_size = 8, | ||
347 | - .unaligned = false, | ||
348 | - }, | ||
349 | - .impl = { | ||
350 | - .min_access_size = 1, | ||
351 | - .max_access_size = 8, | ||
352 | - .unaligned = false, | ||
353 | - }, | ||
354 | -}; | ||
355 | - | ||
356 | static MemTxResult flatview_read(FlatView *fv, hwaddr addr, | ||
357 | MemTxAttrs attrs, uint8_t *buf, hwaddr len); | ||
358 | static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, | ||
359 | @@ -XXX,XX +XXX,XX @@ static void io_mem_init(void) | ||
360 | memory_region_init_io(&io_mem_notdirty, NULL, ¬dirty_mem_ops, NULL, | ||
361 | NULL, UINT64_MAX); | ||
362 | memory_region_clear_global_locking(&io_mem_notdirty); | ||
363 | - | ||
364 | - memory_region_init_io(&io_mem_watch, NULL, &watch_mem_ops, NULL, | ||
365 | - NULL, UINT64_MAX); | ||
366 | } | ||
367 | |||
368 | AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv) | ||
369 | @@ -XXX,XX +XXX,XX @@ AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv) | ||
370 | assert(n == PHYS_SECTION_NOTDIRTY); | ||
371 | n = dummy_section(&d->map, fv, &io_mem_rom); | ||
372 | assert(n == PHYS_SECTION_ROM); | ||
373 | - n = dummy_section(&d->map, fv, &io_mem_watch); | ||
374 | - assert(n == PHYS_SECTION_WATCH); | ||
375 | |||
376 | d->phys_map = (PhysPageEntry) { .ptr = PHYS_MAP_NODE_NIL, .skip = 1 }; | ||
377 | |||
378 | -- | 188 | -- |
379 | 2.17.1 | 189 | 2.43.0 |
380 | 190 | ||
381 | 191 | diff view generated by jsdifflib |
1 | From: Tony Nguyen <tony.nguyen@bt.com> | 1 | Move tb_check_watchpoint declaration from tb-internal.h, which is |
---|---|---|---|
2 | still target-specific, to internal-common.h, which isn't. | ||
3 | Otherwise, all that is required to build watchpoint.c once is | ||
4 | to include the new exec/cpu-interrupt.h instead of exec/exec-all.h. | ||
2 | 5 | ||
3 | Preparation for collapsing the two byte swaps adjust_endianness and | 6 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | handle_bswap into the former. | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | 8 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> | |
6 | Call memory_region_dispatch_{read|write} with endianness encoded into | ||
7 | the "MemOp op" operand. | ||
8 | |||
9 | This patch does not change any behaviour as | ||
10 | memory_region_dispatch_{read|write} is yet to handle the endianness. | ||
11 | |||
12 | Once it does handle endianness, callers with byte swaps can collapse | ||
13 | them into adjust_endianness. | ||
14 | |||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
17 | Message-Id: <8066ab3eb037c0388dfadfe53c5118429dd1de3a.1566466906.git.tony.nguyen@bt.com> | ||
18 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
19 | --- | 10 | --- |
20 | include/exec/memory.h | 3 +++ | 11 | accel/tcg/internal-common.h | 2 ++ |
21 | accel/tcg/cputlb.c | 8 ++++++-- | 12 | accel/tcg/tb-internal.h | 2 -- |
22 | exec.c | 13 +++++++++++-- | 13 | accel/tcg/watchpoint.c | 5 ++--- |
23 | hw/intc/armv7m_nvic.c | 15 ++++++++------- | 14 | accel/tcg/meson.build | 2 +- |
24 | hw/s390x/s390-pci-inst.c | 6 ++++-- | 15 | 4 files changed, 5 insertions(+), 6 deletions(-) |
25 | hw/vfio/pci-quirks.c | 5 +++-- | ||
26 | hw/virtio/virtio-pci.c | 6 ++++-- | ||
27 | memory.c | 18 ++++++++++++++++++ | ||
28 | memory_ldst.inc.c | 24 ++++++++++++++++++------ | ||
29 | 9 files changed, 75 insertions(+), 23 deletions(-) | ||
30 | 16 | ||
31 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 17 | diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h |
32 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/include/exec/memory.h | 19 | --- a/accel/tcg/internal-common.h |
34 | +++ b/include/exec/memory.h | 20 | +++ b/accel/tcg/internal-common.h |
35 | @@ -XXX,XX +XXX,XX @@ address_space_write_cached(MemoryRegionCache *cache, hwaddr addr, | 21 | @@ -XXX,XX +XXX,XX @@ void tcg_exec_unrealizefn(CPUState *cpu); |
36 | } | 22 | /* current cflags for hashing/comparison */ |
37 | } | 23 | uint32_t curr_cflags(CPUState *cpu); |
38 | 24 | ||
39 | +/* enum device_endian to MemOp. */ | 25 | +void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr); |
40 | +MemOp devend_memop(enum device_endian end); | ||
41 | + | 26 | + |
42 | #endif | 27 | #endif |
43 | 28 | diff --git a/accel/tcg/tb-internal.h b/accel/tcg/tb-internal.h | |
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/accel/tcg/tb-internal.h | ||
31 | +++ b/accel/tcg/tb-internal.h | ||
32 | @@ -XXX,XX +XXX,XX @@ void tb_invalidate_phys_range_fast(ram_addr_t ram_addr, | ||
33 | |||
34 | bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc); | ||
35 | |||
36 | -void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr); | ||
37 | - | ||
44 | #endif | 38 | #endif |
45 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | 39 | diff --git a/accel/tcg/watchpoint.c b/accel/tcg/watchpoint.c |
46 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/accel/tcg/cputlb.c | 41 | --- a/accel/tcg/watchpoint.c |
48 | +++ b/accel/tcg/cputlb.c | 42 | +++ b/accel/tcg/watchpoint.c |
49 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | 43 | @@ -XXX,XX +XXX,XX @@ |
50 | qemu_mutex_lock_iothread(); | 44 | |
51 | locked = true; | 45 | #include "qemu/osdep.h" |
52 | } | 46 | #include "qemu/main-loop.h" |
53 | - r = memory_region_dispatch_read(mr, mr_offset, &val, size_memop(size), | 47 | -#include "qemu/error-report.h" |
54 | + r = memory_region_dispatch_read(mr, mr_offset, &val, | 48 | -#include "exec/exec-all.h" |
55 | + size_memop(size) | MO_TE, | 49 | +#include "exec/breakpoint.h" |
56 | iotlbentry->attrs); | 50 | +#include "exec/cpu-interrupt.h" |
57 | if (r != MEMTX_OK) { | 51 | #include "exec/page-protection.h" |
58 | hwaddr physaddr = mr_offset + | 52 | #include "exec/translation-block.h" |
59 | @@ -XXX,XX +XXX,XX @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | 53 | -#include "tb-internal.h" |
60 | qemu_mutex_lock_iothread(); | 54 | #include "system/tcg.h" |
61 | locked = true; | 55 | #include "system/replay.h" |
62 | } | 56 | #include "accel/tcg/cpu-ops.h" |
63 | - r = memory_region_dispatch_write(mr, mr_offset, val, size_memop(size), | 57 | diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build |
64 | + r = memory_region_dispatch_write(mr, mr_offset, val, | ||
65 | + size_memop(size) | MO_TE, | ||
66 | iotlbentry->attrs); | ||
67 | if (r != MEMTX_OK) { | ||
68 | hwaddr physaddr = mr_offset + | ||
69 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
70 | } | ||
71 | } | ||
72 | |||
73 | + /* TODO: Merge bswap into io_readx -> memory_region_dispatch_read. */ | ||
74 | res = io_readx(env, &env_tlb(env)->d[mmu_idx].iotlb[index], | ||
75 | mmu_idx, addr, retaddr, access_type, size); | ||
76 | return handle_bswap(res, size, big_endian); | ||
77 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
78 | } | ||
79 | } | ||
80 | |||
81 | + /* TODO: Merge bswap into io_writex -> memory_region_dispatch_write. */ | ||
82 | io_writex(env, &env_tlb(env)->d[mmu_idx].iotlb[index], mmu_idx, | ||
83 | handle_bswap(val, size, big_endian), | ||
84 | addr, retaddr, size); | ||
85 | diff --git a/exec.c b/exec.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | 58 | index XXXXXXX..XXXXXXX 100644 |
87 | --- a/exec.c | 59 | --- a/accel/tcg/meson.build |
88 | +++ b/exec.c | 60 | +++ b/accel/tcg/meson.build |
89 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, | 61 | @@ -XXX,XX +XXX,XX @@ specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss) |
90 | /* XXX: could force current_cpu to NULL to avoid | 62 | |
91 | potential bugs */ | 63 | specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files( |
92 | val = ldn_p(buf, l); | 64 | 'cputlb.c', |
93 | + /* | 65 | - 'watchpoint.c', |
94 | + * TODO: Merge bswap from ldn_p into memory_region_dispatch_write | 66 | 'tcg-accel-ops.c', |
95 | + * by using ldn_he_p and dropping MO_TE to get a host-endian value. | 67 | 'tcg-accel-ops-mttcg.c', |
96 | + */ | 68 | 'tcg-accel-ops-icount.c', |
97 | result |= memory_region_dispatch_write(mr, addr1, val, | 69 | @@ -XXX,XX +XXX,XX @@ specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files( |
98 | - size_memop(l), attrs); | 70 | system_ss.add(when: ['CONFIG_TCG'], if_true: files( |
99 | + size_memop(l) | MO_TE, | 71 | 'icount-common.c', |
100 | + attrs); | 72 | 'monitor.c', |
101 | } else { | 73 | + 'watchpoint.c', |
102 | /* RAM case */ | 74 | )) |
103 | ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l, false); | ||
104 | @@ -XXX,XX +XXX,XX @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, | ||
105 | /* I/O case */ | ||
106 | release_lock |= prepare_mmio_access(mr); | ||
107 | l = memory_access_size(mr, l, addr1); | ||
108 | + /* | ||
109 | + * TODO: Merge bswap from stn_p into memory_region_dispatch_read | ||
110 | + * by using stn_he_p and dropping MO_TE to get a host-endian value. | ||
111 | + */ | ||
112 | result |= memory_region_dispatch_read(mr, addr1, &val, | ||
113 | - size_memop(l), attrs); | ||
114 | + size_memop(l) | MO_TE, attrs); | ||
115 | stn_p(buf, l, val); | ||
116 | } else { | ||
117 | /* RAM case */ | ||
118 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
119 | index XXXXXXX..XXXXXXX 100644 | ||
120 | --- a/hw/intc/armv7m_nvic.c | ||
121 | +++ b/hw/intc/armv7m_nvic.c | ||
122 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_ns_write(void *opaque, hwaddr addr, | ||
123 | if (attrs.secure) { | ||
124 | /* S accesses to the alias act like NS accesses to the real region */ | ||
125 | attrs.secure = 0; | ||
126 | - return memory_region_dispatch_write(mr, addr, value, size_memop(size), | ||
127 | - attrs); | ||
128 | + return memory_region_dispatch_write(mr, addr, value, | ||
129 | + size_memop(size) | MO_TE, attrs); | ||
130 | } else { | ||
131 | /* NS attrs are RAZ/WI for privileged, and BusFault for user */ | ||
132 | if (attrs.user) { | ||
133 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_ns_read(void *opaque, hwaddr addr, | ||
134 | if (attrs.secure) { | ||
135 | /* S accesses to the alias act like NS accesses to the real region */ | ||
136 | attrs.secure = 0; | ||
137 | - return memory_region_dispatch_read(mr, addr, data, size_memop(size), | ||
138 | - attrs); | ||
139 | + return memory_region_dispatch_read(mr, addr, data, | ||
140 | + size_memop(size) | MO_TE, attrs); | ||
141 | } else { | ||
142 | /* NS attrs are RAZ/WI for privileged, and BusFault for user */ | ||
143 | if (attrs.user) { | ||
144 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_systick_write(void *opaque, hwaddr addr, | ||
145 | |||
146 | /* Direct the access to the correct systick */ | ||
147 | mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systick[attrs.secure]), 0); | ||
148 | - return memory_region_dispatch_write(mr, addr, value, size_memop(size), | ||
149 | - attrs); | ||
150 | + return memory_region_dispatch_write(mr, addr, value, | ||
151 | + size_memop(size) | MO_TE, attrs); | ||
152 | } | ||
153 | |||
154 | static MemTxResult nvic_systick_read(void *opaque, hwaddr addr, | ||
155 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_systick_read(void *opaque, hwaddr addr, | ||
156 | |||
157 | /* Direct the access to the correct systick */ | ||
158 | mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systick[attrs.secure]), 0); | ||
159 | - return memory_region_dispatch_read(mr, addr, data, size_memop(size), attrs); | ||
160 | + return memory_region_dispatch_read(mr, addr, data, size_memop(size) | MO_TE, | ||
161 | + attrs); | ||
162 | } | ||
163 | |||
164 | static const MemoryRegionOps nvic_systick_ops = { | ||
165 | diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c | ||
166 | index XXXXXXX..XXXXXXX 100644 | ||
167 | --- a/hw/s390x/s390-pci-inst.c | ||
168 | +++ b/hw/s390x/s390-pci-inst.c | ||
169 | @@ -XXX,XX +XXX,XX @@ static MemTxResult zpci_read_bar(S390PCIBusDevice *pbdev, uint8_t pcias, | ||
170 | mr = pbdev->pdev->io_regions[pcias].memory; | ||
171 | mr = s390_get_subregion(mr, offset, len); | ||
172 | offset -= mr->addr; | ||
173 | - return memory_region_dispatch_read(mr, offset, data, size_memop(len), | ||
174 | + return memory_region_dispatch_read(mr, offset, data, | ||
175 | + size_memop(len) | MO_BE, | ||
176 | MEMTXATTRS_UNSPECIFIED); | ||
177 | } | ||
178 | |||
179 | @@ -XXX,XX +XXX,XX @@ static MemTxResult zpci_write_bar(S390PCIBusDevice *pbdev, uint8_t pcias, | ||
180 | mr = pbdev->pdev->io_regions[pcias].memory; | ||
181 | mr = s390_get_subregion(mr, offset, len); | ||
182 | offset -= mr->addr; | ||
183 | - return memory_region_dispatch_write(mr, offset, data, size_memop(len), | ||
184 | + return memory_region_dispatch_write(mr, offset, data, | ||
185 | + size_memop(len) | MO_BE, | ||
186 | MEMTXATTRS_UNSPECIFIED); | ||
187 | } | ||
188 | |||
189 | diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c | ||
190 | index XXXXXXX..XXXXXXX 100644 | ||
191 | --- a/hw/vfio/pci-quirks.c | ||
192 | +++ b/hw/vfio/pci-quirks.c | ||
193 | @@ -XXX,XX +XXX,XX @@ static void vfio_rtl8168_quirk_address_write(void *opaque, hwaddr addr, | ||
194 | |||
195 | /* Write to the proper guest MSI-X table instead */ | ||
196 | memory_region_dispatch_write(&vdev->pdev.msix_table_mmio, | ||
197 | - offset, val, size_memop(size), | ||
198 | + offset, val, | ||
199 | + size_memop(size) | MO_LE, | ||
200 | MEMTXATTRS_UNSPECIFIED); | ||
201 | } | ||
202 | return; /* Do not write guest MSI-X data to hardware */ | ||
203 | @@ -XXX,XX +XXX,XX @@ static uint64_t vfio_rtl8168_quirk_data_read(void *opaque, | ||
204 | if (rtl->enabled && (vdev->pdev.cap_present & QEMU_PCI_CAP_MSIX)) { | ||
205 | hwaddr offset = rtl->addr & 0xfff; | ||
206 | memory_region_dispatch_read(&vdev->pdev.msix_table_mmio, offset, | ||
207 | - &data, size_memop(size), | ||
208 | + &data, size_memop(size) | MO_LE, | ||
209 | MEMTXATTRS_UNSPECIFIED); | ||
210 | trace_vfio_quirk_rtl8168_msix_read(vdev->vbasedev.name, offset, data); | ||
211 | } | ||
212 | diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c | ||
213 | index XXXXXXX..XXXXXXX 100644 | ||
214 | --- a/hw/virtio/virtio-pci.c | ||
215 | +++ b/hw/virtio/virtio-pci.c | ||
216 | @@ -XXX,XX +XXX,XX @@ void virtio_address_space_write(VirtIOPCIProxy *proxy, hwaddr addr, | ||
217 | /* As length is under guest control, handle illegal values. */ | ||
218 | return; | ||
219 | } | ||
220 | - memory_region_dispatch_write(mr, addr, val, size_memop(len), | ||
221 | + /* TODO: Merge bswap from cpu_to_leXX into memory_region_dispatch_write. */ | ||
222 | + memory_region_dispatch_write(mr, addr, val, size_memop(len) | MO_LE, | ||
223 | MEMTXATTRS_UNSPECIFIED); | ||
224 | } | ||
225 | |||
226 | @@ -XXX,XX +XXX,XX @@ virtio_address_space_read(VirtIOPCIProxy *proxy, hwaddr addr, | ||
227 | /* Make sure caller aligned buf properly */ | ||
228 | assert(!(((uintptr_t)buf) & (len - 1))); | ||
229 | |||
230 | - memory_region_dispatch_read(mr, addr, &val, size_memop(len), | ||
231 | + /* TODO: Merge bswap from leXX_to_cpu into memory_region_dispatch_read. */ | ||
232 | + memory_region_dispatch_read(mr, addr, &val, size_memop(len) | MO_LE, | ||
233 | MEMTXATTRS_UNSPECIFIED); | ||
234 | switch (len) { | ||
235 | case 1: | ||
236 | diff --git a/memory.c b/memory.c | ||
237 | index XXXXXXX..XXXXXXX 100644 | ||
238 | --- a/memory.c | ||
239 | +++ b/memory.c | ||
240 | @@ -XXX,XX +XXX,XX @@ static void memory_register_types(void) | ||
241 | } | ||
242 | |||
243 | type_init(memory_register_types) | ||
244 | + | ||
245 | +MemOp devend_memop(enum device_endian end) | ||
246 | +{ | ||
247 | + static MemOp conv[] = { | ||
248 | + [DEVICE_LITTLE_ENDIAN] = MO_LE, | ||
249 | + [DEVICE_BIG_ENDIAN] = MO_BE, | ||
250 | + [DEVICE_NATIVE_ENDIAN] = MO_TE, | ||
251 | + [DEVICE_HOST_ENDIAN] = 0, | ||
252 | + }; | ||
253 | + switch (end) { | ||
254 | + case DEVICE_LITTLE_ENDIAN: | ||
255 | + case DEVICE_BIG_ENDIAN: | ||
256 | + case DEVICE_NATIVE_ENDIAN: | ||
257 | + return conv[end]; | ||
258 | + default: | ||
259 | + g_assert_not_reached(); | ||
260 | + } | ||
261 | +} | ||
262 | diff --git a/memory_ldst.inc.c b/memory_ldst.inc.c | ||
263 | index XXXXXXX..XXXXXXX 100644 | ||
264 | --- a/memory_ldst.inc.c | ||
265 | +++ b/memory_ldst.inc.c | ||
266 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL, | ||
267 | release_lock |= prepare_mmio_access(mr); | ||
268 | |||
269 | /* I/O case */ | ||
270 | - r = memory_region_dispatch_read(mr, addr1, &val, MO_32, attrs); | ||
271 | + /* TODO: Merge bswap32 into memory_region_dispatch_read. */ | ||
272 | + r = memory_region_dispatch_read(mr, addr1, &val, | ||
273 | + MO_32 | devend_memop(endian), attrs); | ||
274 | #if defined(TARGET_WORDS_BIGENDIAN) | ||
275 | if (endian == DEVICE_LITTLE_ENDIAN) { | ||
276 | val = bswap32(val); | ||
277 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL, | ||
278 | release_lock |= prepare_mmio_access(mr); | ||
279 | |||
280 | /* I/O case */ | ||
281 | - r = memory_region_dispatch_read(mr, addr1, &val, MO_64, attrs); | ||
282 | + /* TODO: Merge bswap64 into memory_region_dispatch_read. */ | ||
283 | + r = memory_region_dispatch_read(mr, addr1, &val, | ||
284 | + MO_64 | devend_memop(endian), attrs); | ||
285 | #if defined(TARGET_WORDS_BIGENDIAN) | ||
286 | if (endian == DEVICE_LITTLE_ENDIAN) { | ||
287 | val = bswap64(val); | ||
288 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL, | ||
289 | release_lock |= prepare_mmio_access(mr); | ||
290 | |||
291 | /* I/O case */ | ||
292 | - r = memory_region_dispatch_read(mr, addr1, &val, MO_16, attrs); | ||
293 | + /* TODO: Merge bswap16 into memory_region_dispatch_read. */ | ||
294 | + r = memory_region_dispatch_read(mr, addr1, &val, | ||
295 | + MO_16 | devend_memop(endian), attrs); | ||
296 | #if defined(TARGET_WORDS_BIGENDIAN) | ||
297 | if (endian == DEVICE_LITTLE_ENDIAN) { | ||
298 | val = bswap16(val); | ||
299 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stl_internal, SUFFIX)(ARG1_DECL, | ||
300 | val = bswap32(val); | ||
301 | } | ||
302 | #endif | ||
303 | - r = memory_region_dispatch_write(mr, addr1, val, MO_32, attrs); | ||
304 | + /* TODO: Merge bswap32 into memory_region_dispatch_write. */ | ||
305 | + r = memory_region_dispatch_write(mr, addr1, val, | ||
306 | + MO_32 | devend_memop(endian), attrs); | ||
307 | } else { | ||
308 | /* RAM case */ | ||
309 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
310 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stw_internal, SUFFIX)(ARG1_DECL, | ||
311 | val = bswap16(val); | ||
312 | } | ||
313 | #endif | ||
314 | - r = memory_region_dispatch_write(mr, addr1, val, MO_16, attrs); | ||
315 | + /* TODO: Merge bswap16 into memory_region_dispatch_write. */ | ||
316 | + r = memory_region_dispatch_write(mr, addr1, val, | ||
317 | + MO_16 | devend_memop(endian), attrs); | ||
318 | } else { | ||
319 | /* RAM case */ | ||
320 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
321 | @@ -XXX,XX +XXX,XX @@ static void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL, | ||
322 | val = bswap64(val); | ||
323 | } | ||
324 | #endif | ||
325 | - r = memory_region_dispatch_write(mr, addr1, val, MO_64, attrs); | ||
326 | + /* TODO: Merge bswap64 into memory_region_dispatch_write. */ | ||
327 | + r = memory_region_dispatch_write(mr, addr1, val, | ||
328 | + MO_64 | devend_memop(endian), attrs); | ||
329 | } else { | ||
330 | /* RAM case */ | ||
331 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
332 | -- | 75 | -- |
333 | 2.17.1 | 76 | 2.43.0 |
334 | 77 | ||
335 | 78 | diff view generated by jsdifflib |
1 | From: David Hildenbrand <david@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Let's also allow to probe other access types. | 3 | Move CPU TLB related methods to "exec/cputlb.h". |
4 | 4 | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Signed-off-by: David Hildenbrand <david@redhat.com> | 6 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
7 | Message-Id: <20190830100959.26615-3-david@redhat.com> | 7 | Message-ID: <20241114011310.3615-14-philmd@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | --- | 9 | --- |
10 | include/exec/exec-all.h | 10 ++++++++-- | 10 | include/exec/cputlb.h | 7 +++++++ |
11 | accel/tcg/cputlb.c | 43 ++++++++++++++++++++++++++++++----------- | 11 | include/exec/exec-all.h | 3 --- |
12 | accel/tcg/user-exec.c | 26 +++++++++++++++++++------ | 12 | include/exec/ram_addr.h | 1 + |
13 | 3 files changed, 60 insertions(+), 19 deletions(-) | 13 | system/physmem.c | 1 + |
14 | 4 files changed, 9 insertions(+), 3 deletions(-) | ||
14 | 15 | ||
16 | diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/exec/cputlb.h | ||
19 | +++ b/include/exec/cputlb.h | ||
20 | @@ -XXX,XX +XXX,XX @@ void tlb_unprotect_code(ram_addr_t ram_addr); | ||
21 | |||
22 | #endif /* CONFIG_TCG */ | ||
23 | |||
24 | +#ifndef CONFIG_USER_ONLY | ||
25 | + | ||
26 | +void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length); | ||
27 | +void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length); | ||
28 | + | ||
29 | +#endif | ||
30 | + | ||
31 | #endif | ||
15 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | 32 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h |
16 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/exec/exec-all.h | 34 | --- a/include/exec/exec-all.h |
18 | +++ b/include/exec/exec-all.h | 35 | +++ b/include/exec/exec-all.h |
19 | @@ -XXX,XX +XXX,XX @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, | 36 | @@ -XXX,XX +XXX,XX @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env, |
20 | { | 37 | |
21 | } | 38 | #if !defined(CONFIG_USER_ONLY) |
22 | #endif | 39 | |
23 | -void *probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 40 | -void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length); |
24 | - uintptr_t retaddr); | 41 | -void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length); |
25 | +void *probe_access(CPUArchState *env, target_ulong addr, int size, | 42 | - |
26 | + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); | 43 | MemoryRegionSection * |
27 | + | 44 | address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr, |
28 | +static inline void *probe_write(CPUArchState *env, target_ulong addr, int size, | 45 | hwaddr *xlat, hwaddr *plen, |
29 | + int mmu_idx, uintptr_t retaddr) | 46 | diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h |
30 | +{ | ||
31 | + return probe_access(env, addr, size, MMU_DATA_STORE, mmu_idx, retaddr); | ||
32 | +} | ||
33 | |||
34 | #define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ | ||
35 | |||
36 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/accel/tcg/cputlb.c | 48 | --- a/include/exec/ram_addr.h |
39 | +++ b/accel/tcg/cputlb.c | 49 | +++ b/include/exec/ram_addr.h |
40 | @@ -XXX,XX +XXX,XX @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) | 50 | @@ -XXX,XX +XXX,XX @@ |
41 | return qemu_ram_addr_from_host_nofail(p); | 51 | #include "cpu.h" |
42 | } | 52 | #include "system/xen.h" |
43 | 53 | #include "system/tcg.h" | |
44 | -/* Probe for whether the specified guest write access is permitted. | 54 | +#include "exec/cputlb.h" |
45 | - * If it is not permitted then an exception will be taken in the same | 55 | #include "exec/ramlist.h" |
46 | - * way as if this were a real write access (and we will not return). | 56 | #include "exec/ramblock.h" |
47 | +/* | 57 | #include "exec/exec-all.h" |
48 | + * Probe for whether the specified guest access is permitted. If it is not | 58 | diff --git a/system/physmem.c b/system/physmem.c |
49 | + * permitted then an exception will be taken in the same way as if this | ||
50 | + * were a real access (and we will not return). | ||
51 | * If the size is 0 or the page requires I/O access, returns NULL; otherwise, | ||
52 | * returns the address of the host page similar to tlb_vaddr_to_host(). | ||
53 | */ | ||
54 | -void *probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | ||
55 | - uintptr_t retaddr) | ||
56 | +void *probe_access(CPUArchState *env, target_ulong addr, int size, | ||
57 | + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) | ||
58 | { | ||
59 | uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
60 | CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); | ||
61 | - target_ulong tlb_addr = tlb_addr_write(entry); | ||
62 | + target_ulong tlb_addr; | ||
63 | + size_t elt_ofs; | ||
64 | + int wp_access; | ||
65 | |||
66 | g_assert(-(addr | TARGET_PAGE_MASK) >= size); | ||
67 | |||
68 | + switch (access_type) { | ||
69 | + case MMU_DATA_LOAD: | ||
70 | + elt_ofs = offsetof(CPUTLBEntry, addr_read); | ||
71 | + wp_access = BP_MEM_READ; | ||
72 | + break; | ||
73 | + case MMU_DATA_STORE: | ||
74 | + elt_ofs = offsetof(CPUTLBEntry, addr_write); | ||
75 | + wp_access = BP_MEM_WRITE; | ||
76 | + break; | ||
77 | + case MMU_INST_FETCH: | ||
78 | + elt_ofs = offsetof(CPUTLBEntry, addr_code); | ||
79 | + wp_access = BP_MEM_READ; | ||
80 | + break; | ||
81 | + default: | ||
82 | + g_assert_not_reached(); | ||
83 | + } | ||
84 | + tlb_addr = tlb_read_ofs(entry, elt_ofs); | ||
85 | + | ||
86 | if (unlikely(!tlb_hit(tlb_addr, addr))) { | ||
87 | - if (!VICTIM_TLB_HIT(addr_write, addr)) { | ||
88 | - tlb_fill(env_cpu(env), addr, size, MMU_DATA_STORE, | ||
89 | - mmu_idx, retaddr); | ||
90 | + if (!victim_tlb_hit(env, mmu_idx, index, elt_ofs, | ||
91 | + addr & TARGET_PAGE_MASK)) { | ||
92 | + tlb_fill(env_cpu(env), addr, size, access_type, mmu_idx, retaddr); | ||
93 | /* TLB resize via tlb_fill may have moved the entry. */ | ||
94 | index = tlb_index(env, mmu_idx, addr); | ||
95 | entry = tlb_entry(env, mmu_idx, addr); | ||
96 | } | ||
97 | - tlb_addr = tlb_addr_write(entry); | ||
98 | + tlb_addr = tlb_read_ofs(entry, elt_ofs); | ||
99 | } | ||
100 | |||
101 | if (!size) { | ||
102 | @@ -XXX,XX +XXX,XX @@ void *probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | ||
103 | if (tlb_addr & TLB_WATCHPOINT) { | ||
104 | cpu_check_watchpoint(env_cpu(env), addr, size, | ||
105 | env_tlb(env)->d[mmu_idx].iotlb[index].attrs, | ||
106 | - BP_MEM_WRITE, retaddr); | ||
107 | + wp_access, retaddr); | ||
108 | } | ||
109 | |||
110 | if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO)) { | ||
111 | diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
113 | --- a/accel/tcg/user-exec.c | 60 | --- a/system/physmem.c |
114 | +++ b/accel/tcg/user-exec.c | 61 | +++ b/system/physmem.c |
115 | @@ -XXX,XX +XXX,XX @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, | 62 | @@ -XXX,XX +XXX,XX @@ |
116 | g_assert_not_reached(); | 63 | #endif /* CONFIG_TCG */ |
117 | } | 64 | |
118 | 65 | #include "exec/exec-all.h" | |
119 | -void *probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 66 | +#include "exec/cputlb.h" |
120 | - uintptr_t retaddr) | 67 | #include "exec/page-protection.h" |
121 | +void *probe_access(CPUArchState *env, target_ulong addr, int size, | 68 | #include "exec/target_page.h" |
122 | + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) | 69 | #include "exec/translation-block.h" |
123 | { | ||
124 | + int flags; | ||
125 | + | ||
126 | g_assert(-(addr | TARGET_PAGE_MASK) >= size); | ||
127 | |||
128 | - if (!guest_addr_valid(addr) || | ||
129 | - page_check_range(addr, size, PAGE_WRITE) < 0) { | ||
130 | + switch (access_type) { | ||
131 | + case MMU_DATA_STORE: | ||
132 | + flags = PAGE_WRITE; | ||
133 | + break; | ||
134 | + case MMU_DATA_LOAD: | ||
135 | + flags = PAGE_READ; | ||
136 | + break; | ||
137 | + case MMU_INST_FETCH: | ||
138 | + flags = PAGE_EXEC; | ||
139 | + break; | ||
140 | + default: | ||
141 | + g_assert_not_reached(); | ||
142 | + } | ||
143 | + | ||
144 | + if (!guest_addr_valid(addr) || page_check_range(addr, size, flags) < 0) { | ||
145 | CPUState *cpu = env_cpu(env); | ||
146 | CPUClass *cc = CPU_GET_CLASS(cpu); | ||
147 | - | ||
148 | - cc->tlb_fill(cpu, addr, size, MMU_DATA_STORE, MMU_USER_IDX, false, | ||
149 | + cc->tlb_fill(cpu, addr, size, access_type, MMU_USER_IDX, false, | ||
150 | retaddr); | ||
151 | g_assert_not_reached(); | ||
152 | } | ||
153 | -- | 70 | -- |
154 | 2.17.1 | 71 | 2.43.0 |
155 | 72 | ||
156 | 73 | diff view generated by jsdifflib |
1 | From: Tony Nguyen <tony.nguyen@bt.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This bit configures endianness of PCI MMIO devices. It is used by | 3 | Move CPU TLB related methods to "exec/cputlb.h". |
4 | Solaris and OpenBSD sunhme drivers. | ||
5 | 4 | ||
6 | Tested working on OpenBSD. | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-ID: <20241114011310.3615-16-philmd@linaro.org> | ||
9 | --- | ||
10 | include/exec/cputlb.h | 23 +++++++++++++++++++++++ | ||
11 | include/exec/exec-all.h | 22 ---------------------- | ||
12 | target/sparc/mmu_helper.c | 2 +- | ||
13 | 3 files changed, 24 insertions(+), 23 deletions(-) | ||
7 | 14 | ||
8 | Unfortunately Solaris 10 had a unrelated keyboard issue blocking | 15 | diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h |
9 | testing... another inch towards Solaris 10 on SPARC64 =) | ||
10 | |||
11 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | ||
14 | Message-Id: <3c8d5181a584f1b3712d3d8d66801b13cecb4b88.1566466906.git.tony.nguyen@bt.com> | ||
15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | ||
17 | target/sparc/cpu.h | 2 ++ | ||
18 | target/sparc/mmu_helper.c | 8 +++++++- | ||
19 | 2 files changed, 9 insertions(+), 1 deletion(-) | ||
20 | |||
21 | diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/sparc/cpu.h | 17 | --- a/include/exec/cputlb.h |
24 | +++ b/target/sparc/cpu.h | 18 | +++ b/include/exec/cputlb.h |
25 | @@ -XXX,XX +XXX,XX @@ enum { | 19 | @@ -XXX,XX +XXX,XX @@ |
26 | 20 | #define CPUTLB_H | |
27 | #define TTE_VALID_BIT (1ULL << 63) | 21 | |
28 | #define TTE_NFO_BIT (1ULL << 60) | 22 | #include "exec/cpu-common.h" |
29 | +#define TTE_IE_BIT (1ULL << 59) | 23 | +#include "exec/vaddr.h" |
30 | #define TTE_USED_BIT (1ULL << 41) | 24 | |
31 | #define TTE_LOCKED_BIT (1ULL << 6) | 25 | #ifdef CONFIG_TCG |
32 | #define TTE_SIDEEFFECT_BIT (1ULL << 3) | 26 | |
33 | @@ -XXX,XX +XXX,XX @@ enum { | 27 | @@ -XXX,XX +XXX,XX @@ void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length); |
34 | 28 | ||
35 | #define TTE_IS_VALID(tte) ((tte) & TTE_VALID_BIT) | 29 | #endif |
36 | #define TTE_IS_NFO(tte) ((tte) & TTE_NFO_BIT) | 30 | |
37 | +#define TTE_IS_IE(tte) ((tte) & TTE_IE_BIT) | 31 | +/** |
38 | #define TTE_IS_USED(tte) ((tte) & TTE_USED_BIT) | 32 | + * tlb_set_page_full: |
39 | #define TTE_IS_LOCKED(tte) ((tte) & TTE_LOCKED_BIT) | 33 | + * @cpu: CPU context |
40 | #define TTE_IS_SIDEEFFECT(tte) ((tte) & TTE_SIDEEFFECT_BIT) | 34 | + * @mmu_idx: mmu index of the tlb to modify |
35 | + * @addr: virtual address of the entry to add | ||
36 | + * @full: the details of the tlb entry | ||
37 | + * | ||
38 | + * Add an entry to @cpu tlb index @mmu_idx. All of the fields of | ||
39 | + * @full must be filled, except for xlat_section, and constitute | ||
40 | + * the complete description of the translated page. | ||
41 | + * | ||
42 | + * This is generally called by the target tlb_fill function after | ||
43 | + * having performed a successful page table walk to find the physical | ||
44 | + * address and attributes for the translation. | ||
45 | + * | ||
46 | + * At most one entry for a given virtual address is permitted. Only a | ||
47 | + * single TARGET_PAGE_SIZE region is mapped; @full->lg_page_size is only | ||
48 | + * used by tlb_flush_page. | ||
49 | + */ | ||
50 | +void tlb_set_page_full(CPUState *cpu, int mmu_idx, vaddr addr, | ||
51 | + CPUTLBEntryFull *full); | ||
52 | + | ||
53 | #endif | ||
54 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/include/exec/exec-all.h | ||
57 | +++ b/include/exec/exec-all.h | ||
58 | @@ -XXX,XX +XXX,XX @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
59 | uint16_t idxmap, | ||
60 | unsigned bits); | ||
61 | |||
62 | -/** | ||
63 | - * tlb_set_page_full: | ||
64 | - * @cpu: CPU context | ||
65 | - * @mmu_idx: mmu index of the tlb to modify | ||
66 | - * @addr: virtual address of the entry to add | ||
67 | - * @full: the details of the tlb entry | ||
68 | - * | ||
69 | - * Add an entry to @cpu tlb index @mmu_idx. All of the fields of | ||
70 | - * @full must be filled, except for xlat_section, and constitute | ||
71 | - * the complete description of the translated page. | ||
72 | - * | ||
73 | - * This is generally called by the target tlb_fill function after | ||
74 | - * having performed a successful page table walk to find the physical | ||
75 | - * address and attributes for the translation. | ||
76 | - * | ||
77 | - * At most one entry for a given virtual address is permitted. Only a | ||
78 | - * single TARGET_PAGE_SIZE region is mapped; @full->lg_page_size is only | ||
79 | - * used by tlb_flush_page. | ||
80 | - */ | ||
81 | -void tlb_set_page_full(CPUState *cpu, int mmu_idx, vaddr addr, | ||
82 | - CPUTLBEntryFull *full); | ||
83 | - | ||
84 | /** | ||
85 | * tlb_set_page_with_attrs: | ||
86 | * @cpu: CPU to add this TLB entry for | ||
41 | diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c | 87 | diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c |
42 | index XXXXXXX..XXXXXXX 100644 | 88 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/target/sparc/mmu_helper.c | 89 | --- a/target/sparc/mmu_helper.c |
44 | +++ b/target/sparc/mmu_helper.c | 90 | +++ b/target/sparc/mmu_helper.c |
45 | @@ -XXX,XX +XXX,XX @@ static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical, | 91 | @@ -XXX,XX +XXX,XX @@ |
46 | if (ultrasparc_tag_match(&env->dtlb[i], address, context, physical)) { | 92 | #include "qemu/osdep.h" |
47 | int do_fault = 0; | 93 | #include "qemu/log.h" |
48 | 94 | #include "cpu.h" | |
49 | + if (TTE_IS_IE(env->dtlb[i].tte)) { | 95 | -#include "exec/exec-all.h" |
50 | + attrs->byte_swap = true; | 96 | +#include "exec/cputlb.h" |
51 | + } | 97 | #include "exec/page-protection.h" |
52 | + | 98 | #include "qemu/qemu-print.h" |
53 | /* access ok? */ | 99 | #include "trace.h" |
54 | /* multiple bits in SFSR.FT may be set on TT_DFAULT */ | ||
55 | if (TTE_IS_PRIV(env->dtlb[i].tte) && is_user) { | ||
56 | @@ -XXX,XX +XXX,XX @@ void dump_mmu(CPUSPARCState *env) | ||
57 | } | ||
58 | if (TTE_IS_VALID(env->dtlb[i].tte)) { | ||
59 | qemu_printf("[%02u] VA: %" PRIx64 ", PA: %llx" | ||
60 | - ", %s, %s, %s, %s, ctx %" PRId64 " %s\n", | ||
61 | + ", %s, %s, %s, %s, ie %s, ctx %" PRId64 " %s\n", | ||
62 | i, | ||
63 | env->dtlb[i].tag & (uint64_t)~0x1fffULL, | ||
64 | TTE_PA(env->dtlb[i].tte), | ||
65 | @@ -XXX,XX +XXX,XX @@ void dump_mmu(CPUSPARCState *env) | ||
66 | TTE_IS_W_OK(env->dtlb[i].tte) ? "RW" : "RO", | ||
67 | TTE_IS_LOCKED(env->dtlb[i].tte) ? | ||
68 | "locked" : "unlocked", | ||
69 | + TTE_IS_IE(env->dtlb[i].tte) ? | ||
70 | + "yes" : "no", | ||
71 | env->dtlb[i].tag & (uint64_t)0x1fffULL, | ||
72 | TTE_IS_GLOBAL(env->dtlb[i].tte) ? | ||
73 | "global" : "local"); | ||
74 | -- | 100 | -- |
75 | 2.17.1 | 101 | 2.43.0 |
76 | 102 | ||
77 | 103 | diff view generated by jsdifflib |
1 | From: David Hildenbrand <david@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | ... similar to tlb_vaddr_to_host(); however, allow access to the host | 3 | Move CPU TLB related methods to "exec/cputlb.h". |
4 | page except when TLB_NOTDIRTY or TLB_MMIO is set. | ||
5 | 4 | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Signed-off-by: David Hildenbrand <david@redhat.com> | 6 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
8 | Message-Id: <20190830100959.26615-2-david@redhat.com> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-ID: <20241114011310.3615-17-philmd@linaro.org> | ||
10 | --- | 9 | --- |
11 | include/exec/exec-all.h | 4 ++-- | 10 | include/exec/cputlb.h | 28 ++++++++++++++++++++++++++++ |
12 | accel/tcg/cputlb.c | 21 ++++++++++++++++----- | 11 | include/exec/exec-all.h | 25 ------------------------- |
13 | accel/tcg/user-exec.c | 6 ++++-- | 12 | target/i386/tcg/system/excp_helper.c | 2 +- |
14 | 3 files changed, 22 insertions(+), 9 deletions(-) | 13 | target/microblaze/helper.c | 2 +- |
14 | 4 files changed, 30 insertions(+), 27 deletions(-) | ||
15 | 15 | ||
16 | diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/exec/cputlb.h | ||
19 | +++ b/include/exec/cputlb.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #define CPUTLB_H | ||
22 | |||
23 | #include "exec/cpu-common.h" | ||
24 | +#include "exec/hwaddr.h" | ||
25 | +#include "exec/memattrs.h" | ||
26 | #include "exec/vaddr.h" | ||
27 | |||
28 | #ifdef CONFIG_TCG | ||
29 | @@ -XXX,XX +XXX,XX @@ void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length); | ||
30 | void tlb_set_page_full(CPUState *cpu, int mmu_idx, vaddr addr, | ||
31 | CPUTLBEntryFull *full); | ||
32 | |||
33 | +/** | ||
34 | + * tlb_set_page_with_attrs: | ||
35 | + * @cpu: CPU to add this TLB entry for | ||
36 | + * @addr: virtual address of page to add entry for | ||
37 | + * @paddr: physical address of the page | ||
38 | + * @attrs: memory transaction attributes | ||
39 | + * @prot: access permissions (PAGE_READ/PAGE_WRITE/PAGE_EXEC bits) | ||
40 | + * @mmu_idx: MMU index to insert TLB entry for | ||
41 | + * @size: size of the page in bytes | ||
42 | + * | ||
43 | + * Add an entry to this CPU's TLB (a mapping from virtual address | ||
44 | + * @addr to physical address @paddr) with the specified memory | ||
45 | + * transaction attributes. This is generally called by the target CPU | ||
46 | + * specific code after it has been called through the tlb_fill() | ||
47 | + * entry point and performed a successful page table walk to find | ||
48 | + * the physical address and attributes for the virtual address | ||
49 | + * which provoked the TLB miss. | ||
50 | + * | ||
51 | + * At most one entry for a given virtual address is permitted. Only a | ||
52 | + * single TARGET_PAGE_SIZE region is mapped; the supplied @size is only | ||
53 | + * used by tlb_flush_page. | ||
54 | + */ | ||
55 | +void tlb_set_page_with_attrs(CPUState *cpu, vaddr addr, | ||
56 | + hwaddr paddr, MemTxAttrs attrs, | ||
57 | + int prot, int mmu_idx, vaddr size); | ||
58 | + | ||
59 | #endif | ||
16 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | 60 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h |
17 | index XXXXXXX..XXXXXXX 100644 | 61 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/exec/exec-all.h | 62 | --- a/include/exec/exec-all.h |
19 | +++ b/include/exec/exec-all.h | 63 | +++ b/include/exec/exec-all.h |
20 | @@ -XXX,XX +XXX,XX @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, | 64 | @@ -XXX,XX +XXX,XX @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, |
21 | { | 65 | uint16_t idxmap, |
22 | } | 66 | unsigned bits); |
23 | #endif | 67 | |
24 | -void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 68 | -/** |
25 | - uintptr_t retaddr); | 69 | - * tlb_set_page_with_attrs: |
26 | +void *probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 70 | - * @cpu: CPU to add this TLB entry for |
27 | + uintptr_t retaddr); | 71 | - * @addr: virtual address of page to add entry for |
28 | 72 | - * @paddr: physical address of the page | |
29 | #define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ | 73 | - * @attrs: memory transaction attributes |
30 | 74 | - * @prot: access permissions (PAGE_READ/PAGE_WRITE/PAGE_EXEC bits) | |
31 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | 75 | - * @mmu_idx: MMU index to insert TLB entry for |
76 | - * @size: size of the page in bytes | ||
77 | - * | ||
78 | - * Add an entry to this CPU's TLB (a mapping from virtual address | ||
79 | - * @addr to physical address @paddr) with the specified memory | ||
80 | - * transaction attributes. This is generally called by the target CPU | ||
81 | - * specific code after it has been called through the tlb_fill() | ||
82 | - * entry point and performed a successful page table walk to find | ||
83 | - * the physical address and attributes for the virtual address | ||
84 | - * which provoked the TLB miss. | ||
85 | - * | ||
86 | - * At most one entry for a given virtual address is permitted. Only a | ||
87 | - * single TARGET_PAGE_SIZE region is mapped; the supplied @size is only | ||
88 | - * used by tlb_flush_page. | ||
89 | - */ | ||
90 | -void tlb_set_page_with_attrs(CPUState *cpu, vaddr addr, | ||
91 | - hwaddr paddr, MemTxAttrs attrs, | ||
92 | - int prot, int mmu_idx, vaddr size); | ||
93 | /* tlb_set_page: | ||
94 | * | ||
95 | * This function is equivalent to calling tlb_set_page_with_attrs() | ||
96 | diff --git a/target/i386/tcg/system/excp_helper.c b/target/i386/tcg/system/excp_helper.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | 97 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/accel/tcg/cputlb.c | 98 | --- a/target/i386/tcg/system/excp_helper.c |
34 | +++ b/accel/tcg/cputlb.c | 99 | +++ b/target/i386/tcg/system/excp_helper.c |
35 | @@ -XXX,XX +XXX,XX @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) | 100 | @@ -XXX,XX +XXX,XX @@ |
36 | /* Probe for whether the specified guest write access is permitted. | 101 | #include "qemu/osdep.h" |
37 | * If it is not permitted then an exception will be taken in the same | 102 | #include "cpu.h" |
38 | * way as if this were a real write access (and we will not return). | 103 | #include "exec/cpu_ldst.h" |
39 | - * Otherwise the function will return, and there will be a valid | 104 | -#include "exec/exec-all.h" |
40 | - * entry in the TLB for this access. | 105 | +#include "exec/cputlb.h" |
41 | + * If the size is 0 or the page requires I/O access, returns NULL; otherwise, | 106 | #include "exec/page-protection.h" |
42 | + * returns the address of the host page similar to tlb_vaddr_to_host(). | 107 | #include "tcg/helper-tcg.h" |
43 | */ | 108 | |
44 | -void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 109 | diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c |
45 | - uintptr_t retaddr) | ||
46 | +void *probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | ||
47 | + uintptr_t retaddr) | ||
48 | { | ||
49 | uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
50 | CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); | ||
51 | @@ -XXX,XX +XXX,XX @@ void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | ||
52 | tlb_addr = tlb_addr_write(entry); | ||
53 | } | ||
54 | |||
55 | + if (!size) { | ||
56 | + return NULL; | ||
57 | + } | ||
58 | + | ||
59 | /* Handle watchpoints. */ | ||
60 | - if ((tlb_addr & TLB_WATCHPOINT) && size > 0) { | ||
61 | + if (tlb_addr & TLB_WATCHPOINT) { | ||
62 | cpu_check_watchpoint(env_cpu(env), addr, size, | ||
63 | env_tlb(env)->d[mmu_idx].iotlb[index].attrs, | ||
64 | BP_MEM_WRITE, retaddr); | ||
65 | } | ||
66 | + | ||
67 | + if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO)) { | ||
68 | + /* I/O access */ | ||
69 | + return NULL; | ||
70 | + } | ||
71 | + | ||
72 | + return (void *)((uintptr_t)addr + entry->addend); | ||
73 | } | ||
74 | |||
75 | void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, | ||
76 | diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | 110 | index XXXXXXX..XXXXXXX 100644 |
78 | --- a/accel/tcg/user-exec.c | 111 | --- a/target/microblaze/helper.c |
79 | +++ b/accel/tcg/user-exec.c | 112 | +++ b/target/microblaze/helper.c |
80 | @@ -XXX,XX +XXX,XX @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, | 113 | @@ -XXX,XX +XXX,XX @@ |
81 | g_assert_not_reached(); | 114 | |
82 | } | 115 | #include "qemu/osdep.h" |
83 | 116 | #include "cpu.h" | |
84 | -void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 117 | -#include "exec/exec-all.h" |
85 | - uintptr_t retaddr) | 118 | +#include "exec/cputlb.h" |
86 | +void *probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 119 | #include "exec/page-protection.h" |
87 | + uintptr_t retaddr) | 120 | #include "qemu/host-utils.h" |
88 | { | 121 | #include "exec/log.h" |
89 | g_assert(-(addr | TARGET_PAGE_MASK) >= size); | ||
90 | |||
91 | @@ -XXX,XX +XXX,XX @@ void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | ||
92 | retaddr); | ||
93 | g_assert_not_reached(); | ||
94 | } | ||
95 | + | ||
96 | + return size ? g2h(addr) : NULL; | ||
97 | } | ||
98 | |||
99 | #if defined(__i386__) | ||
100 | -- | 122 | -- |
101 | 2.17.1 | 123 | 2.43.0 |
102 | 124 | ||
103 | 125 | diff view generated by jsdifflib |
1 | From: David Hildenbrand <david@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Factor it out into common code. Similar to the !CONFIG_USER_ONLY variant, | 3 | Move CPU TLB related methods to "exec/cputlb.h". |
4 | let's not allow to cross page boundaries. | 4 | |
5 | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
6 | Signed-off-by: David Hildenbrand <david@redhat.com> | 6 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-Id: <20190826075112.25637-4-david@redhat.com> | ||
9 | [rth: Move cpu & cc variables inside if block.] | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-ID: <20241114011310.3615-18-philmd@linaro.org> | ||
11 | --- | 9 | --- |
12 | include/exec/exec-all.h | 4 ++-- | 10 | include/exec/cputlb.h | 11 +++++++++++ |
13 | accel/tcg/user-exec.c | 14 ++++++++++++++ | 11 | include/exec/exec-all.h | 9 --------- |
14 | target/s390x/mem_helper.c | 7 ------- | 12 | target/alpha/helper.c | 2 +- |
15 | 3 files changed, 16 insertions(+), 9 deletions(-) | 13 | target/avr/helper.c | 2 +- |
16 | 14 | target/loongarch/tcg/tlb_helper.c | 1 + | |
15 | target/m68k/helper.c | 1 + | ||
16 | target/mips/tcg/system/tlb_helper.c | 1 + | ||
17 | target/openrisc/mmu.c | 2 +- | ||
18 | target/ppc/mmu_helper.c | 1 + | ||
19 | target/riscv/cpu_helper.c | 1 + | ||
20 | target/rx/cpu.c | 2 +- | ||
21 | target/s390x/tcg/excp_helper.c | 1 + | ||
22 | target/sh4/helper.c | 1 + | ||
23 | target/tricore/helper.c | 2 +- | ||
24 | target/xtensa/helper.c | 2 +- | ||
25 | 15 files changed, 24 insertions(+), 15 deletions(-) | ||
26 | |||
27 | diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/include/exec/cputlb.h | ||
30 | +++ b/include/exec/cputlb.h | ||
31 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, vaddr addr, | ||
32 | hwaddr paddr, MemTxAttrs attrs, | ||
33 | int prot, int mmu_idx, vaddr size); | ||
34 | |||
35 | +/** | ||
36 | + * tlb_set_page: | ||
37 | + * | ||
38 | + * This function is equivalent to calling tlb_set_page_with_attrs() | ||
39 | + * with an @attrs argument of MEMTXATTRS_UNSPECIFIED. It's provided | ||
40 | + * as a convenience for CPUs which don't use memory transaction attributes. | ||
41 | + */ | ||
42 | +void tlb_set_page(CPUState *cpu, vaddr addr, | ||
43 | + hwaddr paddr, int prot, | ||
44 | + int mmu_idx, vaddr size); | ||
45 | + | ||
46 | #endif | ||
17 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | 47 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h |
18 | index XXXXXXX..XXXXXXX 100644 | 48 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/exec/exec-all.h | 49 | --- a/include/exec/exec-all.h |
20 | +++ b/include/exec/exec-all.h | 50 | +++ b/include/exec/exec-all.h |
21 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | 51 | @@ -XXX,XX +XXX,XX @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, |
22 | void tlb_set_page(CPUState *cpu, target_ulong vaddr, | 52 | uint16_t idxmap, |
23 | hwaddr paddr, int prot, | 53 | unsigned bits); |
24 | int mmu_idx, target_ulong size); | 54 | |
25 | -void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 55 | -/* tlb_set_page: |
26 | - uintptr_t retaddr); | 56 | - * |
57 | - * This function is equivalent to calling tlb_set_page_with_attrs() | ||
58 | - * with an @attrs argument of MEMTXATTRS_UNSPECIFIED. It's provided | ||
59 | - * as a convenience for CPUs which don't use memory transaction attributes. | ||
60 | - */ | ||
61 | -void tlb_set_page(CPUState *cpu, vaddr addr, | ||
62 | - hwaddr paddr, int prot, | ||
63 | - int mmu_idx, vaddr size); | ||
27 | #else | 64 | #else |
28 | static inline void tlb_init(CPUState *cpu) | 65 | static inline void tlb_flush_page(CPUState *cpu, vaddr addr) |
29 | { | 66 | { |
30 | @@ -XXX,XX +XXX,XX @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, | 67 | diff --git a/target/alpha/helper.c b/target/alpha/helper.c |
31 | { | 68 | index XXXXXXX..XXXXXXX 100644 |
32 | } | 69 | --- a/target/alpha/helper.c |
33 | #endif | 70 | +++ b/target/alpha/helper.c |
34 | +void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 71 | @@ -XXX,XX +XXX,XX @@ |
35 | + uintptr_t retaddr); | 72 | #include "qemu/osdep.h" |
36 | 73 | #include "qemu/log.h" | |
37 | #define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ | 74 | #include "cpu.h" |
38 | 75 | -#include "exec/exec-all.h" | |
39 | diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c | 76 | +#include "exec/cputlb.h" |
40 | index XXXXXXX..XXXXXXX 100644 | 77 | #include "exec/page-protection.h" |
41 | --- a/accel/tcg/user-exec.c | 78 | #include "fpu/softfloat-types.h" |
42 | +++ b/accel/tcg/user-exec.c | 79 | #include "exec/helper-proto.h" |
43 | @@ -XXX,XX +XXX,XX @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, | 80 | diff --git a/target/avr/helper.c b/target/avr/helper.c |
44 | g_assert_not_reached(); | 81 | index XXXXXXX..XXXXXXX 100644 |
45 | } | 82 | --- a/target/avr/helper.c |
46 | 83 | +++ b/target/avr/helper.c | |
47 | +void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 84 | @@ -XXX,XX +XXX,XX @@ |
48 | + uintptr_t retaddr) | 85 | #include "qemu/error-report.h" |
49 | +{ | 86 | #include "cpu.h" |
50 | + if (!guest_addr_valid(addr) || | 87 | #include "accel/tcg/cpu-ops.h" |
51 | + page_check_range(addr, size, PAGE_WRITE) < 0) { | 88 | -#include "exec/exec-all.h" |
52 | + CPUState *cpu = env_cpu(env); | 89 | +#include "exec/cputlb.h" |
53 | + CPUClass *cc = CPU_GET_CLASS(cpu); | 90 | #include "exec/page-protection.h" |
54 | + | 91 | #include "exec/cpu_ldst.h" |
55 | + cc->tlb_fill(cpu, addr, size, MMU_DATA_STORE, MMU_USER_IDX, false, | 92 | #include "exec/address-spaces.h" |
56 | + retaddr); | 93 | diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c |
57 | + g_assert_not_reached(); | 94 | index XXXXXXX..XXXXXXX 100644 |
58 | + } | 95 | --- a/target/loongarch/tcg/tlb_helper.c |
59 | +} | 96 | +++ b/target/loongarch/tcg/tlb_helper.c |
60 | + | 97 | @@ -XXX,XX +XXX,XX @@ |
61 | #if defined(__i386__) | 98 | #include "cpu.h" |
62 | 99 | #include "internals.h" | |
63 | #if defined(__NetBSD__) | 100 | #include "exec/helper-proto.h" |
64 | diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c | 101 | +#include "exec/cputlb.h" |
65 | index XXXXXXX..XXXXXXX 100644 | 102 | #include "exec/exec-all.h" |
66 | --- a/target/s390x/mem_helper.c | 103 | #include "exec/page-protection.h" |
67 | +++ b/target/s390x/mem_helper.c | 104 | #include "exec/cpu_ldst.h" |
68 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(cu42)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t m3) | 105 | diff --git a/target/m68k/helper.c b/target/m68k/helper.c |
69 | void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len, | 106 | index XXXXXXX..XXXXXXX 100644 |
70 | uintptr_t ra) | 107 | --- a/target/m68k/helper.c |
71 | { | 108 | +++ b/target/m68k/helper.c |
72 | -#ifdef CONFIG_USER_ONLY | 109 | @@ -XXX,XX +XXX,XX @@ |
73 | - if (!guest_addr_valid(addr) || !guest_addr_valid(addr + len - 1) || | 110 | |
74 | - page_check_range(addr, len, PAGE_WRITE) < 0) { | 111 | #include "qemu/osdep.h" |
75 | - s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); | 112 | #include "cpu.h" |
76 | - } | 113 | +#include "exec/cputlb.h" |
77 | -#else | 114 | #include "exec/exec-all.h" |
78 | /* test the actual access, not just any access to the page due to LAP */ | 115 | #include "exec/page-protection.h" |
79 | while (len) { | 116 | #include "exec/gdbstub.h" |
80 | const uint64_t pagelen = -(addr | TARGET_PAGE_MASK); | 117 | diff --git a/target/mips/tcg/system/tlb_helper.c b/target/mips/tcg/system/tlb_helper.c |
81 | @@ -XXX,XX +XXX,XX @@ void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len, | 118 | index XXXXXXX..XXXXXXX 100644 |
82 | addr = wrap_address(env, addr + curlen); | 119 | --- a/target/mips/tcg/system/tlb_helper.c |
83 | len -= curlen; | 120 | +++ b/target/mips/tcg/system/tlb_helper.c |
84 | } | 121 | @@ -XXX,XX +XXX,XX @@ |
85 | -#endif | 122 | |
86 | } | 123 | #include "cpu.h" |
87 | 124 | #include "internal.h" | |
88 | void HELPER(probe_write_access)(CPUS390XState *env, uint64_t addr, uint64_t len) | 125 | +#include "exec/cputlb.h" |
126 | #include "exec/exec-all.h" | ||
127 | #include "exec/page-protection.h" | ||
128 | #include "exec/cpu_ldst.h" | ||
129 | diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/target/openrisc/mmu.c | ||
132 | +++ b/target/openrisc/mmu.c | ||
133 | @@ -XXX,XX +XXX,XX @@ | ||
134 | #include "qemu/osdep.h" | ||
135 | #include "qemu/log.h" | ||
136 | #include "cpu.h" | ||
137 | -#include "exec/exec-all.h" | ||
138 | +#include "exec/cputlb.h" | ||
139 | #include "exec/page-protection.h" | ||
140 | #include "gdbstub/helpers.h" | ||
141 | #include "qemu/host-utils.h" | ||
142 | diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c | ||
143 | index XXXXXXX..XXXXXXX 100644 | ||
144 | --- a/target/ppc/mmu_helper.c | ||
145 | +++ b/target/ppc/mmu_helper.c | ||
146 | @@ -XXX,XX +XXX,XX @@ | ||
147 | #include "kvm_ppc.h" | ||
148 | #include "mmu-hash64.h" | ||
149 | #include "mmu-hash32.h" | ||
150 | +#include "exec/cputlb.h" | ||
151 | #include "exec/exec-all.h" | ||
152 | #include "exec/page-protection.h" | ||
153 | #include "exec/log.h" | ||
154 | diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c | ||
155 | index XXXXXXX..XXXXXXX 100644 | ||
156 | --- a/target/riscv/cpu_helper.c | ||
157 | +++ b/target/riscv/cpu_helper.c | ||
158 | @@ -XXX,XX +XXX,XX @@ | ||
159 | #include "cpu.h" | ||
160 | #include "internals.h" | ||
161 | #include "pmu.h" | ||
162 | +#include "exec/cputlb.h" | ||
163 | #include "exec/exec-all.h" | ||
164 | #include "exec/page-protection.h" | ||
165 | #include "instmap.h" | ||
166 | diff --git a/target/rx/cpu.c b/target/rx/cpu.c | ||
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/target/rx/cpu.c | ||
169 | +++ b/target/rx/cpu.c | ||
170 | @@ -XXX,XX +XXX,XX @@ | ||
171 | #include "qapi/error.h" | ||
172 | #include "cpu.h" | ||
173 | #include "migration/vmstate.h" | ||
174 | -#include "exec/exec-all.h" | ||
175 | +#include "exec/cputlb.h" | ||
176 | #include "exec/page-protection.h" | ||
177 | #include "exec/translation-block.h" | ||
178 | #include "hw/loader.h" | ||
179 | diff --git a/target/s390x/tcg/excp_helper.c b/target/s390x/tcg/excp_helper.c | ||
180 | index XXXXXXX..XXXXXXX 100644 | ||
181 | --- a/target/s390x/tcg/excp_helper.c | ||
182 | +++ b/target/s390x/tcg/excp_helper.c | ||
183 | @@ -XXX,XX +XXX,XX @@ | ||
184 | #include "qemu/log.h" | ||
185 | #include "cpu.h" | ||
186 | #include "exec/helper-proto.h" | ||
187 | +#include "exec/cputlb.h" | ||
188 | #include "exec/exec-all.h" | ||
189 | #include "s390x-internal.h" | ||
190 | #include "tcg_s390x.h" | ||
191 | diff --git a/target/sh4/helper.c b/target/sh4/helper.c | ||
192 | index XXXXXXX..XXXXXXX 100644 | ||
193 | --- a/target/sh4/helper.c | ||
194 | +++ b/target/sh4/helper.c | ||
195 | @@ -XXX,XX +XXX,XX @@ | ||
196 | #include "qemu/osdep.h" | ||
197 | |||
198 | #include "cpu.h" | ||
199 | +#include "exec/cputlb.h" | ||
200 | #include "exec/exec-all.h" | ||
201 | #include "exec/page-protection.h" | ||
202 | #include "exec/log.h" | ||
203 | diff --git a/target/tricore/helper.c b/target/tricore/helper.c | ||
204 | index XXXXXXX..XXXXXXX 100644 | ||
205 | --- a/target/tricore/helper.c | ||
206 | +++ b/target/tricore/helper.c | ||
207 | @@ -XXX,XX +XXX,XX @@ | ||
208 | #include "qemu/log.h" | ||
209 | #include "hw/registerfields.h" | ||
210 | #include "cpu.h" | ||
211 | -#include "exec/exec-all.h" | ||
212 | +#include "exec/cputlb.h" | ||
213 | #include "exec/page-protection.h" | ||
214 | #include "fpu/softfloat-helpers.h" | ||
215 | #include "qemu/qemu-print.h" | ||
216 | diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c | ||
217 | index XXXXXXX..XXXXXXX 100644 | ||
218 | --- a/target/xtensa/helper.c | ||
219 | +++ b/target/xtensa/helper.c | ||
220 | @@ -XXX,XX +XXX,XX @@ | ||
221 | #include "qemu/osdep.h" | ||
222 | #include "qemu/log.h" | ||
223 | #include "cpu.h" | ||
224 | -#include "exec/exec-all.h" | ||
225 | +#include "exec/cputlb.h" | ||
226 | #include "gdbstub/helpers.h" | ||
227 | #include "exec/helper-proto.h" | ||
228 | #include "qemu/error-report.h" | ||
89 | -- | 229 | -- |
90 | 2.17.1 | 230 | 2.43.0 |
91 | 231 | ||
92 | 232 | diff view generated by jsdifflib |
1 | We had two different mechanisms to force a recheck of the tlb. | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Before TLB_RECHECK was introduced, we had a PAGE_WRITE_INV bit | 3 | Move CPU TLB related methods to "exec/cputlb.h". |
4 | that would immediate set TLB_INVALID_MASK, which automatically | ||
5 | means that a second check of the tlb entry fails. | ||
6 | 4 | ||
7 | We can use the same mechanism to handle small pages. | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Conserve TLB_* bits by removing TLB_RECHECK. | 6 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
9 | |||
10 | Reviewed-by: David Hildenbrand <david@redhat.com> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-ID: <20241114011310.3615-20-philmd@linaro.org> | ||
12 | --- | 9 | --- |
13 | include/exec/cpu-all.h | 5 +-- | 10 | include/exec/cpu-all.h | 23 ----------------------- |
14 | accel/tcg/cputlb.c | 86 +++++++++++------------------------------- | 11 | accel/tcg/cputlb.c | 23 +++++++++++++++++++++++ |
15 | 2 files changed, 24 insertions(+), 67 deletions(-) | 12 | 2 files changed, 23 insertions(+), 23 deletions(-) |
16 | 13 | ||
17 | diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h | 14 | diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/exec/cpu-all.h | 16 | --- a/include/exec/cpu-all.h |
20 | +++ b/include/exec/cpu-all.h | 17 | +++ b/include/exec/cpu-all.h |
21 | @@ -XXX,XX +XXX,XX @@ CPUArchState *cpu_copy(CPUArchState *env); | 18 | @@ -XXX,XX +XXX,XX @@ static inline int cpu_mmu_index(CPUState *cs, bool ifetch) |
22 | #define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS - 2)) | 19 | /* The two sets of flags must not overlap. */ |
23 | /* Set if TLB entry is an IO callback. */ | 20 | QEMU_BUILD_BUG_ON(TLB_FLAGS_MASK & TLB_SLOW_FLAGS_MASK); |
24 | #define TLB_MMIO (1 << (TARGET_PAGE_BITS - 3)) | 21 | |
25 | -/* Set if TLB entry must have MMU lookup repeated for every access */ | 22 | -/** |
26 | -#define TLB_RECHECK (1 << (TARGET_PAGE_BITS - 4)) | 23 | - * tlb_hit_page: return true if page aligned @addr is a hit against the |
27 | 24 | - * TLB entry @tlb_addr | |
28 | /* Use this mask to check interception with an alignment mask | 25 | - * |
29 | * in a TCG backend. | 26 | - * @addr: virtual address to test (must be page aligned) |
30 | */ | 27 | - * @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) |
31 | -#define TLB_FLAGS_MASK (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO \ | 28 | - */ |
32 | - | TLB_RECHECK) | 29 | -static inline bool tlb_hit_page(uint64_t tlb_addr, vaddr addr) |
33 | +#define TLB_FLAGS_MASK (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO) | 30 | -{ |
34 | 31 | - return addr == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK)); | |
35 | /** | 32 | -} |
36 | * tlb_hit_page: return true if page aligned @addr is a hit against the | 33 | - |
34 | -/** | ||
35 | - * tlb_hit: return true if @addr is a hit against the TLB entry @tlb_addr | ||
36 | - * | ||
37 | - * @addr: virtual address to test (need not be page aligned) | ||
38 | - * @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) | ||
39 | - */ | ||
40 | -static inline bool tlb_hit(uint64_t tlb_addr, vaddr addr) | ||
41 | -{ | ||
42 | - return tlb_hit_page(tlb_addr, addr & TARGET_PAGE_MASK); | ||
43 | -} | ||
44 | - | ||
45 | #endif /* !CONFIG_USER_ONLY */ | ||
46 | |||
47 | /* Validate correct placement of CPUArchState. */ | ||
37 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | 48 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c |
38 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/accel/tcg/cputlb.c | 50 | --- a/accel/tcg/cputlb.c |
40 | +++ b/accel/tcg/cputlb.c | 51 | +++ b/accel/tcg/cputlb.c |
41 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | 52 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page(CPUState *cpu, vaddr addr, |
42 | 53 | prot, mmu_idx, size); | |
43 | address = vaddr_page; | 54 | } |
44 | if (size < TARGET_PAGE_SIZE) { | 55 | |
45 | - /* | 56 | +/** |
46 | - * Slow-path the TLB entries; we will repeat the MMU check and TLB | 57 | + * tlb_hit_page: return true if page aligned @addr is a hit against the |
47 | - * fill on every access. | 58 | + * TLB entry @tlb_addr |
48 | - */ | ||
49 | - address |= TLB_RECHECK; | ||
50 | + /* Repeat the MMU check and TLB fill on every access. */ | ||
51 | + address |= TLB_INVALID_MASK; | ||
52 | } | ||
53 | if (attrs.byte_swap) { | ||
54 | /* Force the access through the I/O slow path. */ | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, | ||
56 | victim_tlb_hit(env, mmu_idx, index, offsetof(CPUTLBEntry, TY), \ | ||
57 | (ADDR) & TARGET_PAGE_MASK) | ||
58 | |||
59 | -/* NOTE: this function can trigger an exception */ | ||
60 | -/* NOTE2: the returned address is not exactly the physical address: it | ||
61 | - * is actually a ram_addr_t (in system mode; the user mode emulation | ||
62 | - * version of this function returns a guest virtual address). | ||
63 | +/* | ||
64 | + * Return a ram_addr_t for the virtual address for execution. | ||
65 | + * | 59 | + * |
66 | + * Return -1 if we can't translate and execute from an entire page | 60 | + * @addr: virtual address to test (must be page aligned) |
67 | + * of RAM. This will force us to execute by loading and translating | 61 | + * @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) |
68 | + * one insn at a time, without caching. | 62 | + */ |
63 | +static inline bool tlb_hit_page(uint64_t tlb_addr, vaddr addr) | ||
64 | +{ | ||
65 | + return addr == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK)); | ||
66 | +} | ||
67 | + | ||
68 | +/** | ||
69 | + * tlb_hit: return true if @addr is a hit against the TLB entry @tlb_addr | ||
69 | + * | 70 | + * |
70 | + * NOTE: This function will trigger an exception if the page is | 71 | + * @addr: virtual address to test (need not be page aligned) |
71 | + * not executable. | 72 | + * @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) |
72 | */ | 73 | + */ |
73 | tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) | 74 | +static inline bool tlb_hit(uint64_t tlb_addr, vaddr addr) |
74 | { | 75 | +{ |
75 | @@ -XXX,XX +XXX,XX @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) | 76 | + return tlb_hit_page(tlb_addr, addr & TARGET_PAGE_MASK); |
76 | tlb_fill(env_cpu(env), addr, 0, MMU_INST_FETCH, mmu_idx, 0); | 77 | +} |
77 | index = tlb_index(env, mmu_idx, addr); | ||
78 | entry = tlb_entry(env, mmu_idx, addr); | ||
79 | + | 78 | + |
80 | + if (unlikely(entry->addr_code & TLB_INVALID_MASK)) { | 79 | /* |
81 | + /* | 80 | * Note: tlb_fill_align() can trigger a resize of the TLB. |
82 | + * The MMU protection covers a smaller range than a target | 81 | * This means that all of the caller's prior references to the TLB table |
83 | + * page, so we must redo the MMU check for every insn. | ||
84 | + */ | ||
85 | + return -1; | ||
86 | + } | ||
87 | } | ||
88 | assert(tlb_hit(entry->addr_code, addr)); | ||
89 | } | ||
90 | |||
91 | - if (unlikely(entry->addr_code & (TLB_RECHECK | TLB_MMIO))) { | ||
92 | - /* | ||
93 | - * Return -1 if we can't translate and execute from an entire | ||
94 | - * page of RAM here, which will cause us to execute by loading | ||
95 | - * and translating one insn at a time, without caching: | ||
96 | - * - TLB_RECHECK: means the MMU protection covers a smaller range | ||
97 | - * than a target page, so we must redo the MMU check every insn | ||
98 | - * - TLB_MMIO: region is not backed by RAM | ||
99 | - */ | ||
100 | + if (unlikely(entry->addr_code & TLB_MMIO)) { | ||
101 | + /* The region is not backed by RAM. */ | ||
102 | return -1; | ||
103 | } | ||
104 | |||
105 | @@ -XXX,XX +XXX,XX @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, | ||
106 | } | ||
107 | |||
108 | /* Notice an IO access or a needs-MMU-lookup access */ | ||
109 | - if (unlikely(tlb_addr & (TLB_MMIO | TLB_RECHECK))) { | ||
110 | + if (unlikely(tlb_addr & TLB_MMIO)) { | ||
111 | /* There's really nothing that can be done to | ||
112 | support this apart from stop-the-world. */ | ||
113 | goto stop_the_world; | ||
114 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
115 | entry = tlb_entry(env, mmu_idx, addr); | ||
116 | } | ||
117 | tlb_addr = code_read ? entry->addr_code : entry->addr_read; | ||
118 | + tlb_addr &= ~TLB_INVALID_MASK; | ||
119 | } | ||
120 | |||
121 | /* Handle an IO access. */ | ||
122 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
123 | if ((addr & (size - 1)) != 0) { | ||
124 | goto do_unaligned_access; | ||
125 | } | ||
126 | - | ||
127 | - if (tlb_addr & TLB_RECHECK) { | ||
128 | - /* | ||
129 | - * This is a TLB_RECHECK access, where the MMU protection | ||
130 | - * covers a smaller range than a target page, and we must | ||
131 | - * repeat the MMU check here. This tlb_fill() call might | ||
132 | - * longjump out if this access should cause a guest exception. | ||
133 | - */ | ||
134 | - tlb_fill(env_cpu(env), addr, size, | ||
135 | - access_type, mmu_idx, retaddr); | ||
136 | - index = tlb_index(env, mmu_idx, addr); | ||
137 | - entry = tlb_entry(env, mmu_idx, addr); | ||
138 | - | ||
139 | - tlb_addr = code_read ? entry->addr_code : entry->addr_read; | ||
140 | - tlb_addr &= ~TLB_RECHECK; | ||
141 | - if (!(tlb_addr & ~TARGET_PAGE_MASK)) { | ||
142 | - /* RAM access */ | ||
143 | - goto do_aligned_access; | ||
144 | - } | ||
145 | - } | ||
146 | - | ||
147 | return io_readx(env, &env_tlb(env)->d[mmu_idx].iotlb[index], | ||
148 | mmu_idx, addr, retaddr, access_type, op); | ||
149 | } | ||
150 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
151 | return res & MAKE_64BIT_MASK(0, size * 8); | ||
152 | } | ||
153 | |||
154 | - do_aligned_access: | ||
155 | haddr = (void *)((uintptr_t)addr + entry->addend); | ||
156 | switch (op) { | ||
157 | case MO_UB: | ||
158 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
159 | if ((addr & (size - 1)) != 0) { | ||
160 | goto do_unaligned_access; | ||
161 | } | ||
162 | - | ||
163 | - if (tlb_addr & TLB_RECHECK) { | ||
164 | - /* | ||
165 | - * This is a TLB_RECHECK access, where the MMU protection | ||
166 | - * covers a smaller range than a target page, and we must | ||
167 | - * repeat the MMU check here. This tlb_fill() call might | ||
168 | - * longjump out if this access should cause a guest exception. | ||
169 | - */ | ||
170 | - tlb_fill(env_cpu(env), addr, size, MMU_DATA_STORE, | ||
171 | - mmu_idx, retaddr); | ||
172 | - index = tlb_index(env, mmu_idx, addr); | ||
173 | - entry = tlb_entry(env, mmu_idx, addr); | ||
174 | - | ||
175 | - tlb_addr = tlb_addr_write(entry); | ||
176 | - tlb_addr &= ~TLB_RECHECK; | ||
177 | - if (!(tlb_addr & ~TARGET_PAGE_MASK)) { | ||
178 | - /* RAM access */ | ||
179 | - goto do_aligned_access; | ||
180 | - } | ||
181 | - } | ||
182 | - | ||
183 | io_writex(env, &env_tlb(env)->d[mmu_idx].iotlb[index], mmu_idx, | ||
184 | val, addr, retaddr, op); | ||
185 | return; | ||
186 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
187 | return; | ||
188 | } | ||
189 | |||
190 | - do_aligned_access: | ||
191 | haddr = (void *)((uintptr_t)addr + entry->addend); | ||
192 | switch (op) { | ||
193 | case MO_UB: | ||
194 | -- | 82 | -- |
195 | 2.17.1 | 83 | 2.43.0 |
196 | 84 | ||
197 | 85 | diff view generated by jsdifflib |
1 | From: Tony Nguyen <tony.nguyen@bt.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The memory_region_dispatch_{read|write} operand "unsigned size" is | 3 | Move CPU TLB related methods to "exec/cputlb.h". |
4 | being converted into a "MemOp op". | ||
5 | 4 | ||
6 | Convert interfaces by using no-op size_memop. | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | |||
8 | After all interfaces are converted, size_memop will be implemented | ||
9 | and the memory_region_dispatch_{read|write} operand "unsigned size" | ||
10 | will be converted into a "MemOp op". | ||
11 | |||
12 | As size_memop is a no-op, this patch does not change any behaviour. | ||
13 | |||
14 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-Id: <21113bae2f54b45176701e0bf595937031368ae6.1566466906.git.tony.nguyen@bt.com> | 7 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
8 | Message-ID: <20241114011310.3615-19-philmd@linaro.org> | ||
18 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
19 | --- | 10 | --- |
20 | hw/intc/armv7m_nvic.c | 12 ++++++++---- | 11 | include/exec/cputlb.h | 200 +++++++++++++++++++++++++-- |
21 | 1 file changed, 8 insertions(+), 4 deletions(-) | 12 | include/exec/exec-all.h | 184 ------------------------ |
13 | accel/tcg/tcg-accel-ops.c | 2 +- | ||
14 | cpu-target.c | 1 + | ||
15 | hw/intc/armv7m_nvic.c | 2 +- | ||
16 | hw/ppc/spapr_nested.c | 1 + | ||
17 | hw/sh4/sh7750.c | 1 + | ||
18 | system/watchpoint.c | 3 +- | ||
19 | target/alpha/sys_helper.c | 2 +- | ||
20 | target/arm/helper.c | 1 + | ||
21 | target/arm/tcg/tlb-insns.c | 2 +- | ||
22 | target/hppa/mem_helper.c | 1 + | ||
23 | target/i386/helper.c | 2 +- | ||
24 | target/i386/machine.c | 2 +- | ||
25 | target/i386/tcg/fpu_helper.c | 2 +- | ||
26 | target/i386/tcg/misc_helper.c | 2 +- | ||
27 | target/i386/tcg/system/misc_helper.c | 2 +- | ||
28 | target/i386/tcg/system/svm_helper.c | 2 +- | ||
29 | target/loongarch/tcg/csr_helper.c | 2 +- | ||
30 | target/microblaze/mmu.c | 2 +- | ||
31 | target/mips/system/cp0.c | 2 +- | ||
32 | target/mips/tcg/system/cp0_helper.c | 2 +- | ||
33 | target/openrisc/sys_helper.c | 1 + | ||
34 | target/ppc/helper_regs.c | 2 +- | ||
35 | target/ppc/misc_helper.c | 1 + | ||
36 | target/riscv/csr.c | 1 + | ||
37 | target/riscv/op_helper.c | 1 + | ||
38 | target/riscv/pmp.c | 2 +- | ||
39 | target/s390x/gdbstub.c | 2 +- | ||
40 | target/s390x/sigp.c | 1 + | ||
41 | target/s390x/tcg/mem_helper.c | 1 + | ||
42 | target/s390x/tcg/misc_helper.c | 1 + | ||
43 | target/sparc/ldst_helper.c | 1 + | ||
44 | target/xtensa/mmu_helper.c | 1 + | ||
45 | 34 files changed, 224 insertions(+), 211 deletions(-) | ||
22 | 46 | ||
47 | diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/include/exec/cputlb.h | ||
50 | +++ b/include/exec/cputlb.h | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | #include "exec/memattrs.h" | ||
53 | #include "exec/vaddr.h" | ||
54 | |||
55 | -#ifdef CONFIG_TCG | ||
56 | - | ||
57 | -#if !defined(CONFIG_USER_ONLY) | ||
58 | -/* cputlb.c */ | ||
59 | +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) | ||
60 | void tlb_protect_code(ram_addr_t ram_addr); | ||
61 | void tlb_unprotect_code(ram_addr_t ram_addr); | ||
62 | #endif | ||
63 | |||
64 | -#endif /* CONFIG_TCG */ | ||
65 | - | ||
66 | #ifndef CONFIG_USER_ONLY | ||
67 | - | ||
68 | void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length); | ||
69 | void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length); | ||
70 | - | ||
71 | #endif | ||
72 | |||
73 | /** | ||
74 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page(CPUState *cpu, vaddr addr, | ||
75 | hwaddr paddr, int prot, | ||
76 | int mmu_idx, vaddr size); | ||
77 | |||
78 | -#endif | ||
79 | +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) | ||
80 | +/** | ||
81 | + * tlb_flush_page: | ||
82 | + * @cpu: CPU whose TLB should be flushed | ||
83 | + * @addr: virtual address of page to be flushed | ||
84 | + * | ||
85 | + * Flush one page from the TLB of the specified CPU, for all | ||
86 | + * MMU indexes. | ||
87 | + */ | ||
88 | +void tlb_flush_page(CPUState *cpu, vaddr addr); | ||
89 | + | ||
90 | +/** | ||
91 | + * tlb_flush_page_all_cpus_synced: | ||
92 | + * @cpu: src CPU of the flush | ||
93 | + * @addr: virtual address of page to be flushed | ||
94 | + * | ||
95 | + * Flush one page from the TLB of all CPUs, for all | ||
96 | + * MMU indexes. | ||
97 | + * | ||
98 | + * When this function returns, no CPUs will subsequently perform | ||
99 | + * translations using the flushed TLBs. | ||
100 | + */ | ||
101 | +void tlb_flush_page_all_cpus_synced(CPUState *src, vaddr addr); | ||
102 | + | ||
103 | +/** | ||
104 | + * tlb_flush: | ||
105 | + * @cpu: CPU whose TLB should be flushed | ||
106 | + * | ||
107 | + * Flush the entire TLB for the specified CPU. Most CPU architectures | ||
108 | + * allow the implementation to drop entries from the TLB at any time | ||
109 | + * so this is generally safe. If more selective flushing is required | ||
110 | + * use one of the other functions for efficiency. | ||
111 | + */ | ||
112 | +void tlb_flush(CPUState *cpu); | ||
113 | + | ||
114 | +/** | ||
115 | + * tlb_flush_all_cpus_synced: | ||
116 | + * @cpu: src CPU of the flush | ||
117 | + * | ||
118 | + * Flush the entire TLB for all CPUs, for all MMU indexes. | ||
119 | + * | ||
120 | + * When this function returns, no CPUs will subsequently perform | ||
121 | + * translations using the flushed TLBs. | ||
122 | + */ | ||
123 | +void tlb_flush_all_cpus_synced(CPUState *src_cpu); | ||
124 | + | ||
125 | +/** | ||
126 | + * tlb_flush_page_by_mmuidx: | ||
127 | + * @cpu: CPU whose TLB should be flushed | ||
128 | + * @addr: virtual address of page to be flushed | ||
129 | + * @idxmap: bitmap of MMU indexes to flush | ||
130 | + * | ||
131 | + * Flush one page from the TLB of the specified CPU, for the specified | ||
132 | + * MMU indexes. | ||
133 | + */ | ||
134 | +void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, | ||
135 | + uint16_t idxmap); | ||
136 | + | ||
137 | +/** | ||
138 | + * tlb_flush_page_by_mmuidx_all_cpus_synced: | ||
139 | + * @cpu: Originating CPU of the flush | ||
140 | + * @addr: virtual address of page to be flushed | ||
141 | + * @idxmap: bitmap of MMU indexes to flush | ||
142 | + * | ||
143 | + * Flush one page from the TLB of all CPUs, for the specified | ||
144 | + * MMU indexes. | ||
145 | + * | ||
146 | + * When this function returns, no CPUs will subsequently perform | ||
147 | + * translations using the flushed TLBs. | ||
148 | + */ | ||
149 | +void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, | ||
150 | + uint16_t idxmap); | ||
151 | + | ||
152 | +/** | ||
153 | + * tlb_flush_by_mmuidx: | ||
154 | + * @cpu: CPU whose TLB should be flushed | ||
155 | + * @wait: If true ensure synchronisation by exiting the cpu_loop | ||
156 | + * @idxmap: bitmap of MMU indexes to flush | ||
157 | + * | ||
158 | + * Flush all entries from the TLB of the specified CPU, for the specified | ||
159 | + * MMU indexes. | ||
160 | + */ | ||
161 | +void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap); | ||
162 | + | ||
163 | +/** | ||
164 | + * tlb_flush_by_mmuidx_all_cpus_synced: | ||
165 | + * @cpu: Originating CPU of the flush | ||
166 | + * @idxmap: bitmap of MMU indexes to flush | ||
167 | + * | ||
168 | + * Flush all entries from the TLB of all CPUs, for the specified | ||
169 | + * MMU indexes. | ||
170 | + * | ||
171 | + * When this function returns, no CPUs will subsequently perform | ||
172 | + * translations using the flushed TLBs. | ||
173 | + */ | ||
174 | +void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap); | ||
175 | + | ||
176 | +/** | ||
177 | + * tlb_flush_page_bits_by_mmuidx | ||
178 | + * @cpu: CPU whose TLB should be flushed | ||
179 | + * @addr: virtual address of page to be flushed | ||
180 | + * @idxmap: bitmap of mmu indexes to flush | ||
181 | + * @bits: number of significant bits in address | ||
182 | + * | ||
183 | + * Similar to tlb_flush_page_mask, but with a bitmap of indexes. | ||
184 | + */ | ||
185 | +void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr addr, | ||
186 | + uint16_t idxmap, unsigned bits); | ||
187 | + | ||
188 | +/* Similarly, with broadcast and syncing. */ | ||
189 | +void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, | ||
190 | + uint16_t idxmap, | ||
191 | + unsigned bits); | ||
192 | + | ||
193 | +/** | ||
194 | + * tlb_flush_range_by_mmuidx | ||
195 | + * @cpu: CPU whose TLB should be flushed | ||
196 | + * @addr: virtual address of the start of the range to be flushed | ||
197 | + * @len: length of range to be flushed | ||
198 | + * @idxmap: bitmap of mmu indexes to flush | ||
199 | + * @bits: number of significant bits in address | ||
200 | + * | ||
201 | + * For each mmuidx in @idxmap, flush all pages within [@addr,@addr+@len), | ||
202 | + * comparing only the low @bits worth of each virtual page. | ||
203 | + */ | ||
204 | +void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, | ||
205 | + vaddr len, uint16_t idxmap, | ||
206 | + unsigned bits); | ||
207 | + | ||
208 | +/* Similarly, with broadcast and syncing. */ | ||
209 | +void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
210 | + vaddr addr, | ||
211 | + vaddr len, | ||
212 | + uint16_t idxmap, | ||
213 | + unsigned bits); | ||
214 | +#else | ||
215 | +static inline void tlb_flush_page(CPUState *cpu, vaddr addr) | ||
216 | +{ | ||
217 | +} | ||
218 | +static inline void tlb_flush_page_all_cpus_synced(CPUState *src, vaddr addr) | ||
219 | +{ | ||
220 | +} | ||
221 | +static inline void tlb_flush(CPUState *cpu) | ||
222 | +{ | ||
223 | +} | ||
224 | +static inline void tlb_flush_all_cpus_synced(CPUState *src_cpu) | ||
225 | +{ | ||
226 | +} | ||
227 | +static inline void tlb_flush_page_by_mmuidx(CPUState *cpu, | ||
228 | + vaddr addr, uint16_t idxmap) | ||
229 | +{ | ||
230 | +} | ||
231 | + | ||
232 | +static inline void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap) | ||
233 | +{ | ||
234 | +} | ||
235 | +static inline void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
236 | + vaddr addr, | ||
237 | + uint16_t idxmap) | ||
238 | +{ | ||
239 | +} | ||
240 | +static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
241 | + uint16_t idxmap) | ||
242 | +{ | ||
243 | +} | ||
244 | +static inline void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, | ||
245 | + vaddr addr, | ||
246 | + uint16_t idxmap, | ||
247 | + unsigned bits) | ||
248 | +{ | ||
249 | +} | ||
250 | +static inline void | ||
251 | +tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, | ||
252 | + uint16_t idxmap, unsigned bits) | ||
253 | +{ | ||
254 | +} | ||
255 | +static inline void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, | ||
256 | + vaddr len, uint16_t idxmap, | ||
257 | + unsigned bits) | ||
258 | +{ | ||
259 | +} | ||
260 | +static inline void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
261 | + vaddr addr, | ||
262 | + vaddr len, | ||
263 | + uint16_t idxmap, | ||
264 | + unsigned bits) | ||
265 | +{ | ||
266 | +} | ||
267 | +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ | ||
268 | +#endif /* CPUTLB_H */ | ||
269 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | ||
270 | index XXXXXXX..XXXXXXX 100644 | ||
271 | --- a/include/exec/exec-all.h | ||
272 | +++ b/include/exec/exec-all.h | ||
273 | @@ -XXX,XX +XXX,XX @@ | ||
274 | #include "exec/mmu-access-type.h" | ||
275 | #include "exec/translation-block.h" | ||
276 | |||
277 | -#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) | ||
278 | -/* cputlb.c */ | ||
279 | -/** | ||
280 | - * tlb_flush_page: | ||
281 | - * @cpu: CPU whose TLB should be flushed | ||
282 | - * @addr: virtual address of page to be flushed | ||
283 | - * | ||
284 | - * Flush one page from the TLB of the specified CPU, for all | ||
285 | - * MMU indexes. | ||
286 | - */ | ||
287 | -void tlb_flush_page(CPUState *cpu, vaddr addr); | ||
288 | -/** | ||
289 | - * tlb_flush_page_all_cpus_synced: | ||
290 | - * @cpu: src CPU of the flush | ||
291 | - * @addr: virtual address of page to be flushed | ||
292 | - * | ||
293 | - * Flush one page from the TLB of all CPUs, for all | ||
294 | - * MMU indexes. | ||
295 | - * | ||
296 | - * When this function returns, no CPUs will subsequently perform | ||
297 | - * translations using the flushed TLBs. | ||
298 | - */ | ||
299 | -void tlb_flush_page_all_cpus_synced(CPUState *src, vaddr addr); | ||
300 | -/** | ||
301 | - * tlb_flush: | ||
302 | - * @cpu: CPU whose TLB should be flushed | ||
303 | - * | ||
304 | - * Flush the entire TLB for the specified CPU. Most CPU architectures | ||
305 | - * allow the implementation to drop entries from the TLB at any time | ||
306 | - * so this is generally safe. If more selective flushing is required | ||
307 | - * use one of the other functions for efficiency. | ||
308 | - */ | ||
309 | -void tlb_flush(CPUState *cpu); | ||
310 | -/** | ||
311 | - * tlb_flush_all_cpus_synced: | ||
312 | - * @cpu: src CPU of the flush | ||
313 | - * | ||
314 | - * Flush the entire TLB for all CPUs, for all MMU indexes. | ||
315 | - * | ||
316 | - * When this function returns, no CPUs will subsequently perform | ||
317 | - * translations using the flushed TLBs. | ||
318 | - */ | ||
319 | -void tlb_flush_all_cpus_synced(CPUState *src_cpu); | ||
320 | -/** | ||
321 | - * tlb_flush_page_by_mmuidx: | ||
322 | - * @cpu: CPU whose TLB should be flushed | ||
323 | - * @addr: virtual address of page to be flushed | ||
324 | - * @idxmap: bitmap of MMU indexes to flush | ||
325 | - * | ||
326 | - * Flush one page from the TLB of the specified CPU, for the specified | ||
327 | - * MMU indexes. | ||
328 | - */ | ||
329 | -void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, | ||
330 | - uint16_t idxmap); | ||
331 | -/** | ||
332 | - * tlb_flush_page_by_mmuidx_all_cpus_synced: | ||
333 | - * @cpu: Originating CPU of the flush | ||
334 | - * @addr: virtual address of page to be flushed | ||
335 | - * @idxmap: bitmap of MMU indexes to flush | ||
336 | - * | ||
337 | - * Flush one page from the TLB of all CPUs, for the specified | ||
338 | - * MMU indexes. | ||
339 | - * | ||
340 | - * When this function returns, no CPUs will subsequently perform | ||
341 | - * translations using the flushed TLBs. | ||
342 | - */ | ||
343 | -void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, | ||
344 | - uint16_t idxmap); | ||
345 | -/** | ||
346 | - * tlb_flush_by_mmuidx: | ||
347 | - * @cpu: CPU whose TLB should be flushed | ||
348 | - * @wait: If true ensure synchronisation by exiting the cpu_loop | ||
349 | - * @idxmap: bitmap of MMU indexes to flush | ||
350 | - * | ||
351 | - * Flush all entries from the TLB of the specified CPU, for the specified | ||
352 | - * MMU indexes. | ||
353 | - */ | ||
354 | -void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap); | ||
355 | -/** | ||
356 | - * tlb_flush_by_mmuidx_all_cpus_synced: | ||
357 | - * @cpu: Originating CPU of the flush | ||
358 | - * @idxmap: bitmap of MMU indexes to flush | ||
359 | - * | ||
360 | - * Flush all entries from the TLB of all CPUs, for the specified | ||
361 | - * MMU indexes. | ||
362 | - * | ||
363 | - * When this function returns, no CPUs will subsequently perform | ||
364 | - * translations using the flushed TLBs. | ||
365 | - */ | ||
366 | -void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap); | ||
367 | - | ||
368 | -/** | ||
369 | - * tlb_flush_page_bits_by_mmuidx | ||
370 | - * @cpu: CPU whose TLB should be flushed | ||
371 | - * @addr: virtual address of page to be flushed | ||
372 | - * @idxmap: bitmap of mmu indexes to flush | ||
373 | - * @bits: number of significant bits in address | ||
374 | - * | ||
375 | - * Similar to tlb_flush_page_mask, but with a bitmap of indexes. | ||
376 | - */ | ||
377 | -void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr addr, | ||
378 | - uint16_t idxmap, unsigned bits); | ||
379 | - | ||
380 | -/* Similarly, with broadcast and syncing. */ | ||
381 | -void tlb_flush_page_bits_by_mmuidx_all_cpus_synced | ||
382 | - (CPUState *cpu, vaddr addr, uint16_t idxmap, unsigned bits); | ||
383 | - | ||
384 | -/** | ||
385 | - * tlb_flush_range_by_mmuidx | ||
386 | - * @cpu: CPU whose TLB should be flushed | ||
387 | - * @addr: virtual address of the start of the range to be flushed | ||
388 | - * @len: length of range to be flushed | ||
389 | - * @idxmap: bitmap of mmu indexes to flush | ||
390 | - * @bits: number of significant bits in address | ||
391 | - * | ||
392 | - * For each mmuidx in @idxmap, flush all pages within [@addr,@addr+@len), | ||
393 | - * comparing only the low @bits worth of each virtual page. | ||
394 | - */ | ||
395 | -void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, | ||
396 | - vaddr len, uint16_t idxmap, | ||
397 | - unsigned bits); | ||
398 | - | ||
399 | -/* Similarly, with broadcast and syncing. */ | ||
400 | -void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
401 | - vaddr addr, | ||
402 | - vaddr len, | ||
403 | - uint16_t idxmap, | ||
404 | - unsigned bits); | ||
405 | - | ||
406 | -#else | ||
407 | -static inline void tlb_flush_page(CPUState *cpu, vaddr addr) | ||
408 | -{ | ||
409 | -} | ||
410 | -static inline void tlb_flush_page_all_cpus_synced(CPUState *src, vaddr addr) | ||
411 | -{ | ||
412 | -} | ||
413 | -static inline void tlb_flush(CPUState *cpu) | ||
414 | -{ | ||
415 | -} | ||
416 | -static inline void tlb_flush_all_cpus_synced(CPUState *src_cpu) | ||
417 | -{ | ||
418 | -} | ||
419 | -static inline void tlb_flush_page_by_mmuidx(CPUState *cpu, | ||
420 | - vaddr addr, uint16_t idxmap) | ||
421 | -{ | ||
422 | -} | ||
423 | - | ||
424 | -static inline void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap) | ||
425 | -{ | ||
426 | -} | ||
427 | -static inline void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
428 | - vaddr addr, | ||
429 | - uint16_t idxmap) | ||
430 | -{ | ||
431 | -} | ||
432 | -static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
433 | - uint16_t idxmap) | ||
434 | -{ | ||
435 | -} | ||
436 | -static inline void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, | ||
437 | - vaddr addr, | ||
438 | - uint16_t idxmap, | ||
439 | - unsigned bits) | ||
440 | -{ | ||
441 | -} | ||
442 | -static inline void | ||
443 | -tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, | ||
444 | - uint16_t idxmap, unsigned bits) | ||
445 | -{ | ||
446 | -} | ||
447 | -static inline void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, | ||
448 | - vaddr len, uint16_t idxmap, | ||
449 | - unsigned bits) | ||
450 | -{ | ||
451 | -} | ||
452 | -static inline void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
453 | - vaddr addr, | ||
454 | - vaddr len, | ||
455 | - uint16_t idxmap, | ||
456 | - unsigned bits) | ||
457 | -{ | ||
458 | -} | ||
459 | -#endif | ||
460 | - | ||
461 | #if defined(CONFIG_TCG) | ||
462 | |||
463 | /** | ||
464 | diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c | ||
465 | index XXXXXXX..XXXXXXX 100644 | ||
466 | --- a/accel/tcg/tcg-accel-ops.c | ||
467 | +++ b/accel/tcg/tcg-accel-ops.c | ||
468 | @@ -XXX,XX +XXX,XX @@ | ||
469 | #include "qemu/main-loop.h" | ||
470 | #include "qemu/guest-random.h" | ||
471 | #include "qemu/timer.h" | ||
472 | -#include "exec/exec-all.h" | ||
473 | +#include "exec/cputlb.h" | ||
474 | #include "exec/hwaddr.h" | ||
475 | #include "exec/tb-flush.h" | ||
476 | #include "exec/translation-block.h" | ||
477 | diff --git a/cpu-target.c b/cpu-target.c | ||
478 | index XXXXXXX..XXXXXXX 100644 | ||
479 | --- a/cpu-target.c | ||
480 | +++ b/cpu-target.c | ||
481 | @@ -XXX,XX +XXX,XX @@ | ||
482 | #include "exec/tswap.h" | ||
483 | #include "exec/replay-core.h" | ||
484 | #include "exec/cpu-common.h" | ||
485 | +#include "exec/cputlb.h" | ||
486 | #include "exec/exec-all.h" | ||
487 | #include "exec/tb-flush.h" | ||
488 | #include "exec/log.h" | ||
23 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 489 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
24 | index XXXXXXX..XXXXXXX 100644 | 490 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/intc/armv7m_nvic.c | 491 | --- a/hw/intc/armv7m_nvic.c |
26 | +++ b/hw/intc/armv7m_nvic.c | 492 | +++ b/hw/intc/armv7m_nvic.c |
27 | @@ -XXX,XX +XXX,XX @@ | 493 | @@ -XXX,XX +XXX,XX @@ |
28 | #include "hw/qdev-properties.h" | 494 | #include "system/runstate.h" |
29 | #include "target/arm/cpu.h" | 495 | #include "target/arm/cpu.h" |
30 | #include "exec/exec-all.h" | 496 | #include "target/arm/cpu-features.h" |
31 | +#include "exec/memop.h" | 497 | -#include "exec/exec-all.h" |
498 | +#include "exec/cputlb.h" | ||
499 | #include "exec/memop.h" | ||
32 | #include "qemu/log.h" | 500 | #include "qemu/log.h" |
33 | #include "qemu/module.h" | 501 | #include "qemu/module.h" |
502 | diff --git a/hw/ppc/spapr_nested.c b/hw/ppc/spapr_nested.c | ||
503 | index XXXXXXX..XXXXXXX 100644 | ||
504 | --- a/hw/ppc/spapr_nested.c | ||
505 | +++ b/hw/ppc/spapr_nested.c | ||
506 | @@ -XXX,XX +XXX,XX @@ | ||
507 | #include "qemu/osdep.h" | ||
508 | #include "qemu/cutils.h" | ||
509 | #include "exec/exec-all.h" | ||
510 | +#include "exec/cputlb.h" | ||
511 | #include "helper_regs.h" | ||
512 | #include "hw/ppc/ppc.h" | ||
513 | #include "hw/ppc/spapr.h" | ||
514 | diff --git a/hw/sh4/sh7750.c b/hw/sh4/sh7750.c | ||
515 | index XXXXXXX..XXXXXXX 100644 | ||
516 | --- a/hw/sh4/sh7750.c | ||
517 | +++ b/hw/sh4/sh7750.c | ||
518 | @@ -XXX,XX +XXX,XX @@ | ||
519 | #include "hw/sh4/sh_intc.h" | ||
520 | #include "hw/timer/tmu012.h" | ||
521 | #include "exec/exec-all.h" | ||
522 | +#include "exec/cputlb.h" | ||
34 | #include "trace.h" | 523 | #include "trace.h" |
35 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_ns_write(void *opaque, hwaddr addr, | 524 | |
36 | if (attrs.secure) { | 525 | typedef struct SH7750State { |
37 | /* S accesses to the alias act like NS accesses to the real region */ | 526 | diff --git a/system/watchpoint.c b/system/watchpoint.c |
38 | attrs.secure = 0; | 527 | index XXXXXXX..XXXXXXX 100644 |
39 | - return memory_region_dispatch_write(mr, addr, value, size, attrs); | 528 | --- a/system/watchpoint.c |
40 | + return memory_region_dispatch_write(mr, addr, value, size_memop(size), | 529 | +++ b/system/watchpoint.c |
41 | + attrs); | 530 | @@ -XXX,XX +XXX,XX @@ |
42 | } else { | 531 | |
43 | /* NS attrs are RAZ/WI for privileged, and BusFault for user */ | 532 | #include "qemu/osdep.h" |
44 | if (attrs.user) { | 533 | #include "qemu/error-report.h" |
45 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_ns_read(void *opaque, hwaddr addr, | 534 | -#include "exec/exec-all.h" |
46 | if (attrs.secure) { | 535 | +#include "exec/cputlb.h" |
47 | /* S accesses to the alias act like NS accesses to the real region */ | 536 | +#include "exec/target_page.h" |
48 | attrs.secure = 0; | 537 | #include "hw/core/cpu.h" |
49 | - return memory_region_dispatch_read(mr, addr, data, size, attrs); | 538 | |
50 | + return memory_region_dispatch_read(mr, addr, data, size_memop(size), | 539 | /* Add a watchpoint. */ |
51 | + attrs); | 540 | diff --git a/target/alpha/sys_helper.c b/target/alpha/sys_helper.c |
52 | } else { | 541 | index XXXXXXX..XXXXXXX 100644 |
53 | /* NS attrs are RAZ/WI for privileged, and BusFault for user */ | 542 | --- a/target/alpha/sys_helper.c |
54 | if (attrs.user) { | 543 | +++ b/target/alpha/sys_helper.c |
55 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_systick_write(void *opaque, hwaddr addr, | 544 | @@ -XXX,XX +XXX,XX @@ |
56 | 545 | ||
57 | /* Direct the access to the correct systick */ | 546 | #include "qemu/osdep.h" |
58 | mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systick[attrs.secure]), 0); | 547 | #include "cpu.h" |
59 | - return memory_region_dispatch_write(mr, addr, value, size, attrs); | 548 | -#include "exec/exec-all.h" |
60 | + return memory_region_dispatch_write(mr, addr, value, size_memop(size), | 549 | +#include "exec/cputlb.h" |
61 | + attrs); | 550 | #include "exec/tb-flush.h" |
62 | } | 551 | #include "exec/helper-proto.h" |
63 | 552 | #include "system/runstate.h" | |
64 | static MemTxResult nvic_systick_read(void *opaque, hwaddr addr, | 553 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
65 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_systick_read(void *opaque, hwaddr addr, | 554 | index XXXXXXX..XXXXXXX 100644 |
66 | 555 | --- a/target/arm/helper.c | |
67 | /* Direct the access to the correct systick */ | 556 | +++ b/target/arm/helper.c |
68 | mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systick[attrs.secure]), 0); | 557 | @@ -XXX,XX +XXX,XX @@ |
69 | - return memory_region_dispatch_read(mr, addr, data, size, attrs); | 558 | #include "qemu/timer.h" |
70 | + return memory_region_dispatch_read(mr, addr, data, size_memop(size), attrs); | 559 | #include "qemu/bitops.h" |
71 | } | 560 | #include "qemu/qemu-print.h" |
72 | 561 | +#include "exec/cputlb.h" | |
73 | static const MemoryRegionOps nvic_systick_ops = { | 562 | #include "exec/exec-all.h" |
563 | #include "exec/translation-block.h" | ||
564 | #include "hw/irq.h" | ||
565 | diff --git a/target/arm/tcg/tlb-insns.c b/target/arm/tcg/tlb-insns.c | ||
566 | index XXXXXXX..XXXXXXX 100644 | ||
567 | --- a/target/arm/tcg/tlb-insns.c | ||
568 | +++ b/target/arm/tcg/tlb-insns.c | ||
569 | @@ -XXX,XX +XXX,XX @@ | ||
570 | */ | ||
571 | #include "qemu/osdep.h" | ||
572 | #include "qemu/log.h" | ||
573 | -#include "exec/exec-all.h" | ||
574 | +#include "exec/cputlb.h" | ||
575 | #include "cpu.h" | ||
576 | #include "internals.h" | ||
577 | #include "cpu-features.h" | ||
578 | diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c | ||
579 | index XXXXXXX..XXXXXXX 100644 | ||
580 | --- a/target/hppa/mem_helper.c | ||
581 | +++ b/target/hppa/mem_helper.c | ||
582 | @@ -XXX,XX +XXX,XX @@ | ||
583 | #include "qemu/log.h" | ||
584 | #include "cpu.h" | ||
585 | #include "exec/exec-all.h" | ||
586 | +#include "exec/cputlb.h" | ||
587 | #include "exec/page-protection.h" | ||
588 | #include "exec/helper-proto.h" | ||
589 | #include "hw/core/cpu.h" | ||
590 | diff --git a/target/i386/helper.c b/target/i386/helper.c | ||
591 | index XXXXXXX..XXXXXXX 100644 | ||
592 | --- a/target/i386/helper.c | ||
593 | +++ b/target/i386/helper.c | ||
594 | @@ -XXX,XX +XXX,XX @@ | ||
595 | #include "qemu/osdep.h" | ||
596 | #include "qapi/qapi-events-run-state.h" | ||
597 | #include "cpu.h" | ||
598 | -#include "exec/exec-all.h" | ||
599 | +#include "exec/cputlb.h" | ||
600 | #include "exec/translation-block.h" | ||
601 | #include "system/runstate.h" | ||
602 | #ifndef CONFIG_USER_ONLY | ||
603 | diff --git a/target/i386/machine.c b/target/i386/machine.c | ||
604 | index XXXXXXX..XXXXXXX 100644 | ||
605 | --- a/target/i386/machine.c | ||
606 | +++ b/target/i386/machine.c | ||
607 | @@ -XXX,XX +XXX,XX @@ | ||
608 | #include "qemu/osdep.h" | ||
609 | #include "cpu.h" | ||
610 | -#include "exec/exec-all.h" | ||
611 | +#include "exec/cputlb.h" | ||
612 | #include "hw/isa/isa.h" | ||
613 | #include "migration/cpu.h" | ||
614 | #include "kvm/hyperv.h" | ||
615 | diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c | ||
616 | index XXXXXXX..XXXXXXX 100644 | ||
617 | --- a/target/i386/tcg/fpu_helper.c | ||
618 | +++ b/target/i386/tcg/fpu_helper.c | ||
619 | @@ -XXX,XX +XXX,XX @@ | ||
620 | #include <math.h> | ||
621 | #include "cpu.h" | ||
622 | #include "tcg-cpu.h" | ||
623 | -#include "exec/exec-all.h" | ||
624 | +#include "exec/cputlb.h" | ||
625 | #include "exec/cpu_ldst.h" | ||
626 | #include "exec/helper-proto.h" | ||
627 | #include "fpu/softfloat.h" | ||
628 | diff --git a/target/i386/tcg/misc_helper.c b/target/i386/tcg/misc_helper.c | ||
629 | index XXXXXXX..XXXXXXX 100644 | ||
630 | --- a/target/i386/tcg/misc_helper.c | ||
631 | +++ b/target/i386/tcg/misc_helper.c | ||
632 | @@ -XXX,XX +XXX,XX @@ | ||
633 | #include "qemu/log.h" | ||
634 | #include "cpu.h" | ||
635 | #include "exec/helper-proto.h" | ||
636 | -#include "exec/exec-all.h" | ||
637 | +#include "exec/cputlb.h" | ||
638 | #include "helper-tcg.h" | ||
639 | |||
640 | /* | ||
641 | diff --git a/target/i386/tcg/system/misc_helper.c b/target/i386/tcg/system/misc_helper.c | ||
642 | index XXXXXXX..XXXXXXX 100644 | ||
643 | --- a/target/i386/tcg/system/misc_helper.c | ||
644 | +++ b/target/i386/tcg/system/misc_helper.c | ||
645 | @@ -XXX,XX +XXX,XX @@ | ||
646 | #include "exec/helper-proto.h" | ||
647 | #include "exec/cpu_ldst.h" | ||
648 | #include "exec/address-spaces.h" | ||
649 | -#include "exec/exec-all.h" | ||
650 | +#include "exec/cputlb.h" | ||
651 | #include "tcg/helper-tcg.h" | ||
652 | #include "hw/i386/apic.h" | ||
653 | |||
654 | diff --git a/target/i386/tcg/system/svm_helper.c b/target/i386/tcg/system/svm_helper.c | ||
655 | index XXXXXXX..XXXXXXX 100644 | ||
656 | --- a/target/i386/tcg/system/svm_helper.c | ||
657 | +++ b/target/i386/tcg/system/svm_helper.c | ||
658 | @@ -XXX,XX +XXX,XX @@ | ||
659 | #include "qemu/log.h" | ||
660 | #include "cpu.h" | ||
661 | #include "exec/helper-proto.h" | ||
662 | -#include "exec/exec-all.h" | ||
663 | +#include "exec/cputlb.h" | ||
664 | #include "exec/cpu_ldst.h" | ||
665 | #include "tcg/helper-tcg.h" | ||
666 | |||
667 | diff --git a/target/loongarch/tcg/csr_helper.c b/target/loongarch/tcg/csr_helper.c | ||
668 | index XXXXXXX..XXXXXXX 100644 | ||
669 | --- a/target/loongarch/tcg/csr_helper.c | ||
670 | +++ b/target/loongarch/tcg/csr_helper.c | ||
671 | @@ -XXX,XX +XXX,XX @@ | ||
672 | #include "internals.h" | ||
673 | #include "qemu/host-utils.h" | ||
674 | #include "exec/helper-proto.h" | ||
675 | -#include "exec/exec-all.h" | ||
676 | +#include "exec/cputlb.h" | ||
677 | #include "exec/cpu_ldst.h" | ||
678 | #include "hw/irq.h" | ||
679 | #include "cpu-csr.h" | ||
680 | diff --git a/target/microblaze/mmu.c b/target/microblaze/mmu.c | ||
681 | index XXXXXXX..XXXXXXX 100644 | ||
682 | --- a/target/microblaze/mmu.c | ||
683 | +++ b/target/microblaze/mmu.c | ||
684 | @@ -XXX,XX +XXX,XX @@ | ||
685 | #include "qemu/osdep.h" | ||
686 | #include "qemu/log.h" | ||
687 | #include "cpu.h" | ||
688 | -#include "exec/exec-all.h" | ||
689 | +#include "exec/cputlb.h" | ||
690 | #include "exec/page-protection.h" | ||
691 | |||
692 | static unsigned int tlb_decode_size(unsigned int f) | ||
693 | diff --git a/target/mips/system/cp0.c b/target/mips/system/cp0.c | ||
694 | index XXXXXXX..XXXXXXX 100644 | ||
695 | --- a/target/mips/system/cp0.c | ||
696 | +++ b/target/mips/system/cp0.c | ||
697 | @@ -XXX,XX +XXX,XX @@ | ||
698 | #include "qemu/osdep.h" | ||
699 | #include "cpu.h" | ||
700 | #include "internal.h" | ||
701 | -#include "exec/exec-all.h" | ||
702 | +#include "exec/cputlb.h" | ||
703 | |||
704 | /* Called for updates to CP0_Status. */ | ||
705 | void sync_c0_status(CPUMIPSState *env, CPUMIPSState *cpu, int tc) | ||
706 | diff --git a/target/mips/tcg/system/cp0_helper.c b/target/mips/tcg/system/cp0_helper.c | ||
707 | index XXXXXXX..XXXXXXX 100644 | ||
708 | --- a/target/mips/tcg/system/cp0_helper.c | ||
709 | +++ b/target/mips/tcg/system/cp0_helper.c | ||
710 | @@ -XXX,XX +XXX,XX @@ | ||
711 | #include "internal.h" | ||
712 | #include "qemu/host-utils.h" | ||
713 | #include "exec/helper-proto.h" | ||
714 | -#include "exec/exec-all.h" | ||
715 | +#include "exec/cputlb.h" | ||
716 | |||
717 | |||
718 | /* SMP helpers. */ | ||
719 | diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c | ||
720 | index XXXXXXX..XXXXXXX 100644 | ||
721 | --- a/target/openrisc/sys_helper.c | ||
722 | +++ b/target/openrisc/sys_helper.c | ||
723 | @@ -XXX,XX +XXX,XX @@ | ||
724 | #include "qemu/osdep.h" | ||
725 | #include "cpu.h" | ||
726 | #include "exec/exec-all.h" | ||
727 | +#include "exec/cputlb.h" | ||
728 | #include "exec/helper-proto.h" | ||
729 | #include "exception.h" | ||
730 | #ifndef CONFIG_USER_ONLY | ||
731 | diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c | ||
732 | index XXXXXXX..XXXXXXX 100644 | ||
733 | --- a/target/ppc/helper_regs.c | ||
734 | +++ b/target/ppc/helper_regs.c | ||
735 | @@ -XXX,XX +XXX,XX @@ | ||
736 | #include "qemu/osdep.h" | ||
737 | #include "cpu.h" | ||
738 | #include "qemu/main-loop.h" | ||
739 | -#include "exec/exec-all.h" | ||
740 | +#include "exec/cputlb.h" | ||
741 | #include "system/kvm.h" | ||
742 | #include "system/tcg.h" | ||
743 | #include "helper_regs.h" | ||
744 | diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c | ||
745 | index XXXXXXX..XXXXXXX 100644 | ||
746 | --- a/target/ppc/misc_helper.c | ||
747 | +++ b/target/ppc/misc_helper.c | ||
748 | @@ -XXX,XX +XXX,XX @@ | ||
749 | #include "qemu/log.h" | ||
750 | #include "cpu.h" | ||
751 | #include "exec/exec-all.h" | ||
752 | +#include "exec/cputlb.h" | ||
753 | #include "exec/helper-proto.h" | ||
754 | #include "qemu/error-report.h" | ||
755 | #include "qemu/main-loop.h" | ||
756 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
757 | index XXXXXXX..XXXXXXX 100644 | ||
758 | --- a/target/riscv/csr.c | ||
759 | +++ b/target/riscv/csr.c | ||
760 | @@ -XXX,XX +XXX,XX @@ | ||
761 | #include "pmu.h" | ||
762 | #include "time_helper.h" | ||
763 | #include "exec/exec-all.h" | ||
764 | +#include "exec/cputlb.h" | ||
765 | #include "exec/tb-flush.h" | ||
766 | #include "system/cpu-timers.h" | ||
767 | #include "qemu/guest-random.h" | ||
768 | diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c | ||
769 | index XXXXXXX..XXXXXXX 100644 | ||
770 | --- a/target/riscv/op_helper.c | ||
771 | +++ b/target/riscv/op_helper.c | ||
772 | @@ -XXX,XX +XXX,XX @@ | ||
773 | #include "cpu.h" | ||
774 | #include "internals.h" | ||
775 | #include "exec/exec-all.h" | ||
776 | +#include "exec/cputlb.h" | ||
777 | #include "exec/cpu_ldst.h" | ||
778 | #include "exec/helper-proto.h" | ||
779 | #include "trace.h" | ||
780 | diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c | ||
781 | index XXXXXXX..XXXXXXX 100644 | ||
782 | --- a/target/riscv/pmp.c | ||
783 | +++ b/target/riscv/pmp.c | ||
784 | @@ -XXX,XX +XXX,XX @@ | ||
785 | #include "qapi/error.h" | ||
786 | #include "cpu.h" | ||
787 | #include "trace.h" | ||
788 | -#include "exec/exec-all.h" | ||
789 | +#include "exec/cputlb.h" | ||
790 | #include "exec/page-protection.h" | ||
791 | |||
792 | static bool pmp_write_cfg(CPURISCVState *env, uint32_t addr_index, | ||
793 | diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c | ||
794 | index XXXXXXX..XXXXXXX 100644 | ||
795 | --- a/target/s390x/gdbstub.c | ||
796 | +++ b/target/s390x/gdbstub.c | ||
797 | @@ -XXX,XX +XXX,XX @@ | ||
798 | #include "qemu/osdep.h" | ||
799 | #include "cpu.h" | ||
800 | #include "s390x-internal.h" | ||
801 | -#include "exec/exec-all.h" | ||
802 | +#include "exec/cputlb.h" | ||
803 | #include "exec/gdbstub.h" | ||
804 | #include "gdbstub/helpers.h" | ||
805 | #include "qemu/bitops.h" | ||
806 | diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c | ||
807 | index XXXXXXX..XXXXXXX 100644 | ||
808 | --- a/target/s390x/sigp.c | ||
809 | +++ b/target/s390x/sigp.c | ||
810 | @@ -XXX,XX +XXX,XX @@ | ||
811 | #include "system/hw_accel.h" | ||
812 | #include "system/runstate.h" | ||
813 | #include "exec/address-spaces.h" | ||
814 | +#include "exec/cputlb.h" | ||
815 | #include "exec/exec-all.h" | ||
816 | #include "system/tcg.h" | ||
817 | #include "trace.h" | ||
818 | diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c | ||
819 | index XXXXXXX..XXXXXXX 100644 | ||
820 | --- a/target/s390x/tcg/mem_helper.c | ||
821 | +++ b/target/s390x/tcg/mem_helper.c | ||
822 | @@ -XXX,XX +XXX,XX @@ | ||
823 | #include "exec/helper-proto.h" | ||
824 | #include "exec/cpu-common.h" | ||
825 | #include "exec/exec-all.h" | ||
826 | +#include "exec/cputlb.h" | ||
827 | #include "exec/page-protection.h" | ||
828 | #include "exec/cpu_ldst.h" | ||
829 | #include "accel/tcg/cpu-ops.h" | ||
830 | diff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c | ||
831 | index XXXXXXX..XXXXXXX 100644 | ||
832 | --- a/target/s390x/tcg/misc_helper.c | ||
833 | +++ b/target/s390x/tcg/misc_helper.c | ||
834 | @@ -XXX,XX +XXX,XX @@ | ||
835 | #include "exec/helper-proto.h" | ||
836 | #include "qemu/timer.h" | ||
837 | #include "exec/exec-all.h" | ||
838 | +#include "exec/cputlb.h" | ||
839 | #include "exec/cpu_ldst.h" | ||
840 | #include "qapi/error.h" | ||
841 | #include "tcg_s390x.h" | ||
842 | diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c | ||
843 | index XXXXXXX..XXXXXXX 100644 | ||
844 | --- a/target/sparc/ldst_helper.c | ||
845 | +++ b/target/sparc/ldst_helper.c | ||
846 | @@ -XXX,XX +XXX,XX @@ | ||
847 | #include "tcg/tcg.h" | ||
848 | #include "exec/helper-proto.h" | ||
849 | #include "exec/exec-all.h" | ||
850 | +#include "exec/cputlb.h" | ||
851 | #include "exec/page-protection.h" | ||
852 | #include "exec/cpu_ldst.h" | ||
853 | #ifdef CONFIG_USER_ONLY | ||
854 | diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c | ||
855 | index XXXXXXX..XXXXXXX 100644 | ||
856 | --- a/target/xtensa/mmu_helper.c | ||
857 | +++ b/target/xtensa/mmu_helper.c | ||
858 | @@ -XXX,XX +XXX,XX @@ | ||
859 | #include "cpu.h" | ||
860 | #include "exec/helper-proto.h" | ||
861 | #include "qemu/host-utils.h" | ||
862 | +#include "exec/cputlb.h" | ||
863 | #include "exec/exec-all.h" | ||
864 | #include "exec/page-protection.h" | ||
865 | |||
74 | -- | 866 | -- |
75 | 2.17.1 | 867 | 2.43.0 |
76 | 868 | ||
77 | 869 | diff view generated by jsdifflib |
1 | From: David Hildenbrand <david@redhat.com> | 1 | Now that watchpoint.c uses cputlb.h instead of exec-all.h, |
---|---|---|---|
2 | it can be built once. | ||
2 | 3 | ||
3 | Hm... how did that "-" slip in (-TAGRET_PAGE_SIZE would be correct). This | 4 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | currently makes us exceed one page in a single probe_write() call, | 5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | essentially leaving some memory unchecked. | 6 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
6 | |||
7 | Fixes: c5a7392cfb96 ("s390x/tcg: Provide probe_write_access helper") | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: David Hildenbrand <david@redhat.com> | ||
10 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
11 | Message-Id: <20190826075112.25637-3-david@redhat.com> | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
13 | --- | 8 | --- |
14 | target/s390x/mem_helper.c | 2 +- | 9 | system/meson.build | 2 +- |
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | 10 | 1 file changed, 1 insertion(+), 1 deletion(-) |
16 | 11 | ||
17 | diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c | 12 | diff --git a/system/meson.build b/system/meson.build |
18 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/s390x/mem_helper.c | 14 | --- a/system/meson.build |
20 | +++ b/target/s390x/mem_helper.c | 15 | +++ b/system/meson.build |
21 | @@ -XXX,XX +XXX,XX @@ void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len, | 16 | @@ -XXX,XX +XXX,XX @@ specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: [files( |
22 | #else | 17 | 'ioport.c', |
23 | /* test the actual access, not just any access to the page due to LAP */ | 18 | 'memory.c', |
24 | while (len) { | 19 | 'physmem.c', |
25 | - const uint64_t pagelen = -(addr | -TARGET_PAGE_MASK); | 20 | - 'watchpoint.c', |
26 | + const uint64_t pagelen = -(addr | TARGET_PAGE_MASK); | 21 | )]) |
27 | const uint64_t curlen = MIN(pagelen, len); | 22 | |
28 | 23 | system_ss.add(files( | |
29 | probe_write(env, addr, curlen, cpu_mmu_index(env, false), ra); | 24 | @@ -XXX,XX +XXX,XX @@ system_ss.add(files( |
25 | 'runstate.c', | ||
26 | 'tpm-hmp-cmds.c', | ||
27 | 'vl.c', | ||
28 | + 'watchpoint.c', | ||
29 | ), sdl, libpmem, libdaxctl) | ||
30 | |||
31 | if have_tpm | ||
30 | -- | 32 | -- |
31 | 2.17.1 | 33 | 2.43.0 |
32 | 34 | ||
33 | 35 | diff view generated by jsdifflib |
1 | From: David Hildenbrand <david@redhat.com> | 1 | Now that tcg-accel-ops.c uses cputlb.h instead of exec-all.h, |
---|---|---|---|
2 | it can be built once. | ||
2 | 3 | ||
3 | If I'm not completely wrong, we are dealing with guest addresses here | 4 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
4 | and not with host addresses. Use the right check. | ||
5 | |||
6 | Fixes: c5a7392cfb96 ("s390x/tcg: Provide probe_write_access helper") | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: David Hildenbrand <david@redhat.com> | ||
9 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
10 | Message-Id: <20190826075112.25637-2-david@redhat.com> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
12 | --- | 6 | --- |
13 | target/s390x/mem_helper.c | 2 +- | 7 | accel/tcg/meson.build | 2 +- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 8 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 9 | ||
16 | diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c | 10 | diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build |
17 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/s390x/mem_helper.c | 12 | --- a/accel/tcg/meson.build |
19 | +++ b/target/s390x/mem_helper.c | 13 | +++ b/accel/tcg/meson.build |
20 | @@ -XXX,XX +XXX,XX @@ void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len, | 14 | @@ -XXX,XX +XXX,XX @@ specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss) |
21 | uintptr_t ra) | 15 | |
22 | { | 16 | specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files( |
23 | #ifdef CONFIG_USER_ONLY | 17 | 'cputlb.c', |
24 | - if (!h2g_valid(addr) || !h2g_valid(addr + len - 1) || | 18 | - 'tcg-accel-ops.c', |
25 | + if (!guest_addr_valid(addr) || !guest_addr_valid(addr + len - 1) || | 19 | 'tcg-accel-ops-mttcg.c', |
26 | page_check_range(addr, len, PAGE_WRITE) < 0) { | 20 | 'tcg-accel-ops-icount.c', |
27 | s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); | 21 | 'tcg-accel-ops-rr.c', |
28 | } | 22 | @@ -XXX,XX +XXX,XX @@ specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files( |
23 | system_ss.add(when: ['CONFIG_TCG'], if_true: files( | ||
24 | 'icount-common.c', | ||
25 | 'monitor.c', | ||
26 | + 'tcg-accel-ops.c', | ||
27 | 'watchpoint.c', | ||
28 | )) | ||
29 | -- | 29 | -- |
30 | 2.17.1 | 30 | 2.43.0 |
31 | |||
32 | diff view generated by jsdifflib |
1 | From: David Hildenbrand <david@redhat.com> | 1 | All that is required is to avoid including exec-all.h. |
---|---|---|---|
2 | 2 | ||
3 | ... and also call it for CONFIG_USER_ONLY. This function probably will | 3 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
4 | also need some refactoring in regards to probing, however, we'll have to | ||
5 | come back to that later, once cleaning up the other mem helpers. | ||
6 | |||
7 | The alignment check always makes sure that the write access falls into a | ||
8 | single page. | ||
9 | |||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Signed-off-by: David Hildenbrand <david@redhat.com> | ||
12 | Message-Id: <20190826075112.25637-8-david@redhat.com> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
14 | --- | 5 | --- |
15 | target/s390x/mem_helper.c | 4 +--- | 6 | accel/tcg/tcg-accel-ops-icount.c | 2 +- |
16 | 1 file changed, 1 insertion(+), 3 deletions(-) | 7 | accel/tcg/meson.build | 2 +- |
8 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
17 | 9 | ||
18 | diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c | 10 | diff --git a/accel/tcg/tcg-accel-ops-icount.c b/accel/tcg/tcg-accel-ops-icount.c |
19 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/s390x/mem_helper.c | 12 | --- a/accel/tcg/tcg-accel-ops-icount.c |
21 | +++ b/target/s390x/mem_helper.c | 13 | +++ b/accel/tcg/tcg-accel-ops-icount.c |
22 | @@ -XXX,XX +XXX,XX @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, | 14 | @@ -XXX,XX +XXX,XX @@ |
23 | } | 15 | #include "system/cpu-timers.h" |
24 | 16 | #include "qemu/main-loop.h" | |
25 | /* Sanity check writability of the store address. */ | 17 | #include "qemu/guest-random.h" |
26 | -#ifndef CONFIG_USER_ONLY | 18 | -#include "exec/exec-all.h" |
27 | - probe_write(env, a2, 0, mem_idx, ra); | 19 | +#include "hw/core/cpu.h" |
28 | -#endif | 20 | |
29 | + probe_write(env, a2, 1 << sc, mem_idx, ra); | 21 | #include "tcg-accel-ops.h" |
30 | 22 | #include "tcg-accel-ops-icount.h" | |
31 | /* | 23 | diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build |
32 | * Note that the compare-and-swap is atomic, and the store is atomic, | 24 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/accel/tcg/meson.build | ||
26 | +++ b/accel/tcg/meson.build | ||
27 | @@ -XXX,XX +XXX,XX @@ specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss) | ||
28 | specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files( | ||
29 | 'cputlb.c', | ||
30 | 'tcg-accel-ops-mttcg.c', | ||
31 | - 'tcg-accel-ops-icount.c', | ||
32 | 'tcg-accel-ops-rr.c', | ||
33 | )) | ||
34 | |||
35 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: ['CONFIG_TCG'], if_true: files( | ||
36 | 'icount-common.c', | ||
37 | 'monitor.c', | ||
38 | 'tcg-accel-ops.c', | ||
39 | + 'tcg-accel-ops-icount.c', | ||
40 | 'watchpoint.c', | ||
41 | )) | ||
33 | -- | 42 | -- |
34 | 2.17.1 | 43 | 2.43.0 |
35 | |||
36 | diff view generated by jsdifflib |
1 | From: David Hildenbrand <david@redhat.com> | 1 | All that is required is to use cpu-common.h instead of exec-all.h. |
---|---|---|---|
2 | 2 | ||
3 | We now have a variant for CONFIG_USER_ONLY as well. | 3 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
4 | |||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Signed-off-by: David Hildenbrand <david@redhat.com> | ||
7 | Message-Id: <20190826075112.25637-7-david@redhat.com> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | --- | 5 | --- |
10 | target/hppa/op_helper.c | 2 -- | 6 | accel/tcg/tcg-accel-ops-rr.c | 2 +- |
11 | 1 file changed, 2 deletions(-) | 7 | accel/tcg/meson.build | 2 +- |
8 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
12 | 9 | ||
13 | diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c | 10 | diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c |
14 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/hppa/op_helper.c | 12 | --- a/accel/tcg/tcg-accel-ops-rr.c |
16 | +++ b/target/hppa/op_helper.c | 13 | +++ b/accel/tcg/tcg-accel-ops-rr.c |
17 | @@ -XXX,XX +XXX,XX @@ static void do_stby_e(CPUHPPAState *env, target_ulong addr, target_ureg val, | 14 | @@ -XXX,XX +XXX,XX @@ |
18 | default: | 15 | #include "qemu/main-loop.h" |
19 | /* Nothing is stored, but protection is checked and the | 16 | #include "qemu/notify.h" |
20 | cacheline is marked dirty. */ | 17 | #include "qemu/guest-random.h" |
21 | -#ifndef CONFIG_USER_ONLY | 18 | -#include "exec/exec-all.h" |
22 | probe_write(env, addr, 0, cpu_mmu_index(env, 0), ra); | 19 | +#include "exec/cpu-common.h" |
23 | -#endif | 20 | #include "tcg/startup.h" |
24 | break; | 21 | #include "tcg-accel-ops.h" |
25 | } | 22 | #include "tcg-accel-ops-rr.h" |
26 | } | 23 | diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build |
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/accel/tcg/meson.build | ||
26 | +++ b/accel/tcg/meson.build | ||
27 | @@ -XXX,XX +XXX,XX @@ specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss) | ||
28 | specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files( | ||
29 | 'cputlb.c', | ||
30 | 'tcg-accel-ops-mttcg.c', | ||
31 | - 'tcg-accel-ops-rr.c', | ||
32 | )) | ||
33 | |||
34 | system_ss.add(when: ['CONFIG_TCG'], if_true: files( | ||
35 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: ['CONFIG_TCG'], if_true: files( | ||
36 | 'monitor.c', | ||
37 | 'tcg-accel-ops.c', | ||
38 | 'tcg-accel-ops-icount.c', | ||
39 | + 'tcg-accel-ops-rr.c', | ||
40 | 'watchpoint.c', | ||
41 | )) | ||
27 | -- | 42 | -- |
28 | 2.17.1 | 43 | 2.43.0 |
29 | |||
30 | diff view generated by jsdifflib |
1 | From: David Hildenbrand <david@redhat.com> | 1 | All that is required is to avoid including exec-all.h. |
---|---|---|---|
2 | 2 | ||
3 | Let's call it also for CONFIG_USER_ONLY. While at it, add a FIXME and get | 3 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
4 | rid of one local variable. | ||
5 | |||
6 | MIPS code probably needs a bigger refactoring in regards of | ||
7 | ensure_writable_pages(), similar to s390x, so for example, watchpoints | ||
8 | can be handled reliably later. The actually accessed addresses should | ||
9 | be probed only, not full pages. | ||
10 | |||
11 | Signed-off-by: David Hildenbrand <david@redhat.com> | ||
12 | Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com> | ||
13 | Message-Id: <20190826075112.25637-6-david@redhat.com> | ||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
15 | --- | 5 | --- |
16 | target/mips/op_helper.c | 8 +++----- | 6 | accel/tcg/tcg-accel-ops-mttcg.c | 1 - |
17 | 1 file changed, 3 insertions(+), 5 deletions(-) | 7 | accel/tcg/meson.build | 2 +- |
8 | 2 files changed, 1 insertion(+), 2 deletions(-) | ||
18 | 9 | ||
19 | diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c | 10 | diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c |
20 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/mips/op_helper.c | 12 | --- a/accel/tcg/tcg-accel-ops-mttcg.c |
22 | +++ b/target/mips/op_helper.c | 13 | +++ b/accel/tcg/tcg-accel-ops-mttcg.c |
23 | @@ -XXX,XX +XXX,XX @@ static inline void ensure_writable_pages(CPUMIPSState *env, | 14 | @@ -XXX,XX +XXX,XX @@ |
24 | int mmu_idx, | 15 | #include "qemu/main-loop.h" |
25 | uintptr_t retaddr) | 16 | #include "qemu/notify.h" |
26 | { | 17 | #include "qemu/guest-random.h" |
27 | -#if !defined(CONFIG_USER_ONLY) | 18 | -#include "exec/exec-all.h" |
28 | - target_ulong page_addr; | 19 | #include "hw/boards.h" |
29 | + /* FIXME: Probe the actual accesses (pass and use a size) */ | 20 | #include "tcg/startup.h" |
30 | if (unlikely(MSA_PAGESPAN(addr))) { | 21 | #include "tcg-accel-ops.h" |
31 | /* first page */ | 22 | diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build |
32 | probe_write(env, addr, 0, mmu_idx, retaddr); | 23 | index XXXXXXX..XXXXXXX 100644 |
33 | /* second page */ | 24 | --- a/accel/tcg/meson.build |
34 | - page_addr = (addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; | 25 | +++ b/accel/tcg/meson.build |
35 | - probe_write(env, page_addr, 0, mmu_idx, retaddr); | 26 | @@ -XXX,XX +XXX,XX @@ specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss) |
36 | + addr = (addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; | 27 | |
37 | + probe_write(env, addr, 0, mmu_idx, retaddr); | 28 | specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files( |
38 | } | 29 | 'cputlb.c', |
39 | -#endif | 30 | - 'tcg-accel-ops-mttcg.c', |
40 | } | 31 | )) |
41 | 32 | ||
42 | void helper_msa_st_b(CPUMIPSState *env, uint32_t wd, | 33 | system_ss.add(when: ['CONFIG_TCG'], if_true: files( |
34 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: ['CONFIG_TCG'], if_true: files( | ||
35 | 'monitor.c', | ||
36 | 'tcg-accel-ops.c', | ||
37 | 'tcg-accel-ops-icount.c', | ||
38 | + 'tcg-accel-ops-mttcg.c', | ||
39 | 'tcg-accel-ops-rr.c', | ||
40 | 'watchpoint.c', | ||
41 | )) | ||
43 | -- | 42 | -- |
44 | 2.17.1 | 43 | 2.43.0 |
45 | |||
46 | diff view generated by jsdifflib |
1 | We want to move the check for watchpoints from | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | memory_region_section_get_iotlb to tlb_set_page_with_attrs. | ||
3 | Isolate the loop over watchpoints to an exported function. | ||
4 | 2 | ||
5 | Rename the existing cpu_watchpoint_address_matches to | 3 | GETPC_ADJ is only used within accel/tcg/, no need to |
6 | watchpoint_address_matches, since it doesn't actually | 4 | expose it to all the code base. |
7 | have a cpu argument. | ||
8 | 5 | ||
9 | Reviewed-by: David Hildenbrand <david@redhat.com> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Message-ID: <20250308072348.65723-2-philmd@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | --- | 9 | --- |
12 | include/hw/core/cpu.h | 7 +++++++ | 10 | accel/tcg/tb-internal.h | 11 +++++++++++ |
13 | exec.c | 45 ++++++++++++++++++++++++++++--------------- | 11 | include/exec/exec-all.h | 9 --------- |
14 | 2 files changed, 36 insertions(+), 16 deletions(-) | 12 | 2 files changed, 11 insertions(+), 9 deletions(-) |
15 | 13 | ||
16 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h | 14 | diff --git a/accel/tcg/tb-internal.h b/accel/tcg/tb-internal.h |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/core/cpu.h | 16 | --- a/accel/tcg/tb-internal.h |
19 | +++ b/include/hw/core/cpu.h | 17 | +++ b/accel/tcg/tb-internal.h |
20 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, | 18 | @@ -XXX,XX +XXX,XX @@ |
21 | MemTxAttrs atr, int fl, uintptr_t ra) | 19 | #include "exec/exec-all.h" |
22 | { | 20 | #include "exec/translation-block.h" |
23 | } | 21 | |
22 | +/* | ||
23 | + * The true return address will often point to a host insn that is part of | ||
24 | + * the next translated guest insn. Adjust the address backward to point to | ||
25 | + * the middle of the call insn. Subtracting one would do the job except for | ||
26 | + * several compressed mode architectures (arm, mips) which set the low bit | ||
27 | + * to indicate the compressed mode; subtracting two works around that. It | ||
28 | + * is also the case that there are no host isas that contain a call insn | ||
29 | + * smaller than 4 bytes, so we don't worry about special-casing this. | ||
30 | + */ | ||
31 | +#define GETPC_ADJ 2 | ||
24 | + | 32 | + |
25 | +static inline int cpu_watchpoint_address_matches(CPUState *cpu, | 33 | #ifdef CONFIG_SOFTMMU |
26 | + vaddr addr, vaddr len) | 34 | |
27 | +{ | 35 | #define CPU_TLB_DYN_MIN_BITS 6 |
28 | + return 0; | 36 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h |
29 | +} | 37 | index XXXXXXX..XXXXXXX 100644 |
30 | #else | 38 | --- a/include/exec/exec-all.h |
31 | int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, | 39 | +++ b/include/exec/exec-all.h |
32 | int flags, CPUWatchpoint **watchpoint); | 40 | @@ -XXX,XX +XXX,XX @@ extern __thread uintptr_t tci_tb_ptr; |
33 | @@ -XXX,XX +XXX,XX @@ void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint); | 41 | ((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0))) |
34 | void cpu_watchpoint_remove_all(CPUState *cpu, int mask); | ||
35 | void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, | ||
36 | MemTxAttrs attrs, int flags, uintptr_t ra); | ||
37 | +int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len); | ||
38 | #endif | 42 | #endif |
39 | 43 | ||
44 | -/* The true return address will often point to a host insn that is part of | ||
45 | - the next translated guest insn. Adjust the address backward to point to | ||
46 | - the middle of the call insn. Subtracting one would do the job except for | ||
47 | - several compressed mode architectures (arm, mips) which set the low bit | ||
48 | - to indicate the compressed mode; subtracting two works around that. It | ||
49 | - is also the case that there are no host isas that contain a call insn | ||
50 | - smaller than 4 bytes, so we don't worry about special-casing this. */ | ||
51 | -#define GETPC_ADJ 2 | ||
52 | - | ||
53 | #if !defined(CONFIG_USER_ONLY) | ||
54 | |||
40 | /** | 55 | /** |
41 | diff --git a/exec.c b/exec.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/exec.c | ||
44 | +++ b/exec.c | ||
45 | @@ -XXX,XX +XXX,XX @@ void cpu_watchpoint_remove_all(CPUState *cpu, int mask) | ||
46 | * partially or completely with the address range covered by the | ||
47 | * access). | ||
48 | */ | ||
49 | -static inline bool cpu_watchpoint_address_matches(CPUWatchpoint *wp, | ||
50 | - vaddr addr, | ||
51 | - vaddr len) | ||
52 | +static inline bool watchpoint_address_matches(CPUWatchpoint *wp, | ||
53 | + vaddr addr, vaddr len) | ||
54 | { | ||
55 | /* We know the lengths are non-zero, but a little caution is | ||
56 | * required to avoid errors in the case where the range ends | ||
57 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_watchpoint_address_matches(CPUWatchpoint *wp, | ||
58 | |||
59 | return !(addr > wpend || wp->vaddr > addrend); | ||
60 | } | ||
61 | + | ||
62 | +/* Return flags for watchpoints that match addr + prot. */ | ||
63 | +int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len) | ||
64 | +{ | ||
65 | + CPUWatchpoint *wp; | ||
66 | + int ret = 0; | ||
67 | + | ||
68 | + QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { | ||
69 | + if (watchpoint_address_matches(wp, addr, TARGET_PAGE_SIZE)) { | ||
70 | + ret |= wp->flags; | ||
71 | + } | ||
72 | + } | ||
73 | + return ret; | ||
74 | +} | ||
75 | #endif /* !CONFIG_USER_ONLY */ | ||
76 | |||
77 | /* Add a breakpoint. */ | ||
78 | @@ -XXX,XX +XXX,XX @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, | ||
79 | target_ulong *address) | ||
80 | { | ||
81 | hwaddr iotlb; | ||
82 | - CPUWatchpoint *wp; | ||
83 | + int flags, match; | ||
84 | |||
85 | if (memory_region_is_ram(section->mr)) { | ||
86 | /* Normal RAM. */ | ||
87 | @@ -XXX,XX +XXX,XX @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, | ||
88 | iotlb += xlat; | ||
89 | } | ||
90 | |||
91 | - /* Make accesses to pages with watchpoints go via the | ||
92 | - watchpoint trap routines. */ | ||
93 | - QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { | ||
94 | - if (cpu_watchpoint_address_matches(wp, vaddr, TARGET_PAGE_SIZE)) { | ||
95 | - /* Avoid trapping reads of pages with a write breakpoint. */ | ||
96 | - if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) { | ||
97 | - iotlb = PHYS_SECTION_WATCH + paddr; | ||
98 | - *address |= TLB_MMIO; | ||
99 | - break; | ||
100 | - } | ||
101 | - } | ||
102 | + /* Avoid trapping reads of pages with a write breakpoint. */ | ||
103 | + match = (prot & PAGE_READ ? BP_MEM_READ : 0) | ||
104 | + | (prot & PAGE_WRITE ? BP_MEM_WRITE : 0); | ||
105 | + flags = cpu_watchpoint_address_matches(cpu, vaddr, TARGET_PAGE_SIZE); | ||
106 | + if (flags & match) { | ||
107 | + /* | ||
108 | + * Make accesses to pages with watchpoints go via the | ||
109 | + * watchpoint trap routines. | ||
110 | + */ | ||
111 | + iotlb = PHYS_SECTION_WATCH + paddr; | ||
112 | + *address |= TLB_MMIO; | ||
113 | } | ||
114 | |||
115 | return iotlb; | ||
116 | @@ -XXX,XX +XXX,XX @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, | ||
117 | |||
118 | addr = cc->adjust_watchpoint_address(cpu, addr, len); | ||
119 | QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { | ||
120 | - if (cpu_watchpoint_address_matches(wp, addr, len) | ||
121 | + if (watchpoint_address_matches(wp, addr, len) | ||
122 | && (wp->flags & flags)) { | ||
123 | if (flags == BP_MEM_READ) { | ||
124 | wp->flags |= BP_WATCHPOINT_HIT_READ; | ||
125 | -- | 56 | -- |
126 | 2.17.1 | 57 | 2.43.0 |
127 | 58 | ||
128 | 59 | diff view generated by jsdifflib |
1 | From: Tony Nguyen <tony.nguyen@bt.com> | 1 | Split out GETPC to a target-independent header. |
---|---|---|---|
2 | 2 | ||
3 | Preparation for collapsing the two byte swaps, adjust_endianness and | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | handle_bswap, along the I/O path. | 4 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
5 | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
6 | Target dependant attributes are conditionalized upon NEED_CPU_H. | 6 | Message-ID: <20250308072348.65723-3-philmd@linaro.org> |
7 | |||
8 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
9 | Acked-by: David Gibson <david@gibson.dropbear.id.au> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Acked-by: Cornelia Huck <cohuck@redhat.com> | ||
12 | Message-Id: <81d9cd7d7f5aaadfa772d6c48ecee834e9cf7882.1566466906.git.tony.nguyen@bt.com> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
14 | --- | 8 | --- |
15 | include/exec/memop.h | 110 ++++++++++++++++++++ | 9 | include/accel/tcg/getpc.h | 24 ++++++++++++++++++++++++ |
16 | target/arm/translate-a64.h | 2 +- | 10 | include/exec/exec-all.h | 10 +--------- |
17 | target/arm/translate.h | 2 +- | 11 | 2 files changed, 25 insertions(+), 9 deletions(-) |
18 | tcg/tcg-op.h | 80 +++++++------- | 12 | create mode 100644 include/accel/tcg/getpc.h |
19 | tcg/tcg.h | 101 ++---------------- | ||
20 | trace/mem-internal.h | 4 +- | ||
21 | trace/mem.h | 4 +- | ||
22 | accel/tcg/cputlb.c | 2 +- | ||
23 | target/alpha/translate.c | 2 +- | ||
24 | target/arm/translate-a64.c | 48 ++++----- | ||
25 | target/arm/translate-sve.c | 2 +- | ||
26 | target/arm/translate.c | 32 +++--- | ||
27 | target/hppa/translate.c | 14 +-- | ||
28 | target/i386/translate.c | 132 ++++++++++++------------ | ||
29 | target/m68k/translate.c | 2 +- | ||
30 | target/microblaze/translate.c | 4 +- | ||
31 | target/mips/translate.c | 8 +- | ||
32 | target/openrisc/translate.c | 4 +- | ||
33 | target/ppc/translate.c | 12 +-- | ||
34 | target/riscv/insn_trans/trans_rva.inc.c | 8 +- | ||
35 | target/riscv/insn_trans/trans_rvi.inc.c | 4 +- | ||
36 | target/s390x/translate.c | 6 +- | ||
37 | target/s390x/translate_vx.inc.c | 10 +- | ||
38 | target/sparc/translate.c | 14 +-- | ||
39 | target/tilegx/translate.c | 10 +- | ||
40 | target/tricore/translate.c | 8 +- | ||
41 | tcg/aarch64/tcg-target.inc.c | 26 ++--- | ||
42 | tcg/arm/tcg-target.inc.c | 26 ++--- | ||
43 | tcg/i386/tcg-target.inc.c | 24 ++--- | ||
44 | tcg/mips/tcg-target.inc.c | 16 +-- | ||
45 | tcg/optimize.c | 2 +- | ||
46 | tcg/ppc/tcg-target.inc.c | 12 +-- | ||
47 | tcg/riscv/tcg-target.inc.c | 20 ++-- | ||
48 | tcg/s390/tcg-target.inc.c | 14 +-- | ||
49 | tcg/sparc/tcg-target.inc.c | 6 +- | ||
50 | tcg/tcg-op.c | 38 +++---- | ||
51 | tcg/tcg.c | 2 +- | ||
52 | MAINTAINERS | 1 + | ||
53 | tcg/README | 2 +- | ||
54 | 39 files changed, 418 insertions(+), 396 deletions(-) | ||
55 | create mode 100644 include/exec/memop.h | ||
56 | 13 | ||
57 | diff --git a/include/exec/memop.h b/include/exec/memop.h | 14 | diff --git a/include/accel/tcg/getpc.h b/include/accel/tcg/getpc.h |
58 | new file mode 100644 | 15 | new file mode 100644 |
59 | index XXXXXXX..XXXXXXX | 16 | index XXXXXXX..XXXXXXX |
60 | --- /dev/null | 17 | --- /dev/null |
61 | +++ b/include/exec/memop.h | 18 | +++ b/include/accel/tcg/getpc.h |
62 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
63 | +/* | 20 | +/* |
64 | + * Constants for memory operations | 21 | + * Get host pc for helper unwinding. |
65 | + * | 22 | + * |
66 | + * Authors: | 23 | + * Copyright (c) 2003 Fabrice Bellard |
67 | + * Richard Henderson <rth@twiddle.net> | 24 | + * SPDX-License-Identifier: LGPL-2.1-or-later |
68 | + * | ||
69 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
70 | + * See the COPYING file in the top-level directory. | ||
71 | + * | ||
72 | + */ | 25 | + */ |
73 | + | 26 | + |
74 | +#ifndef MEMOP_H | 27 | +#ifndef ACCEL_TCG_GETPC_H |
75 | +#define MEMOP_H | 28 | +#define ACCEL_TCG_GETPC_H |
76 | + | 29 | + |
77 | +typedef enum MemOp { | 30 | +#ifndef CONFIG_TCG |
78 | + MO_8 = 0, | 31 | +#error Can only include this header with TCG |
79 | + MO_16 = 1, | ||
80 | + MO_32 = 2, | ||
81 | + MO_64 = 3, | ||
82 | + MO_SIZE = 3, /* Mask for the above. */ | ||
83 | + | ||
84 | + MO_SIGN = 4, /* Sign-extended, otherwise zero-extended. */ | ||
85 | + | ||
86 | + MO_BSWAP = 8, /* Host reverse endian. */ | ||
87 | +#ifdef HOST_WORDS_BIGENDIAN | ||
88 | + MO_LE = MO_BSWAP, | ||
89 | + MO_BE = 0, | ||
90 | +#else | ||
91 | + MO_LE = 0, | ||
92 | + MO_BE = MO_BSWAP, | ||
93 | +#endif | ||
94 | +#ifdef NEED_CPU_H | ||
95 | +#ifdef TARGET_WORDS_BIGENDIAN | ||
96 | + MO_TE = MO_BE, | ||
97 | +#else | ||
98 | + MO_TE = MO_LE, | ||
99 | +#endif | ||
100 | +#endif | 32 | +#endif |
101 | + | 33 | + |
102 | + /* | 34 | +/* GETPC is the true target of the return instruction that we'll execute. */ |
103 | + * MO_UNALN accesses are never checked for alignment. | 35 | +#ifdef CONFIG_TCG_INTERPRETER |
104 | + * MO_ALIGN accesses will result in a call to the CPU's | 36 | +extern __thread uintptr_t tci_tb_ptr; |
105 | + * do_unaligned_access hook if the guest address is not aligned. | 37 | +# define GETPC() tci_tb_ptr |
106 | + * The default depends on whether the target CPU defines | ||
107 | + * TARGET_ALIGNED_ONLY. | ||
108 | + * | ||
109 | + * Some architectures (e.g. ARMv8) need the address which is aligned | ||
110 | + * to a size more than the size of the memory access. | ||
111 | + * Some architectures (e.g. SPARCv9) need an address which is aligned, | ||
112 | + * but less strictly than the natural alignment. | ||
113 | + * | ||
114 | + * MO_ALIGN supposes the alignment size is the size of a memory access. | ||
115 | + * | ||
116 | + * There are three options: | ||
117 | + * - unaligned access permitted (MO_UNALN). | ||
118 | + * - an alignment to the size of an access (MO_ALIGN); | ||
119 | + * - an alignment to a specified size, which may be more or less than | ||
120 | + * the access size (MO_ALIGN_x where 'x' is a size in bytes); | ||
121 | + */ | ||
122 | + MO_ASHIFT = 4, | ||
123 | + MO_AMASK = 7 << MO_ASHIFT, | ||
124 | +#ifdef NEED_CPU_H | ||
125 | +#ifdef TARGET_ALIGNED_ONLY | ||
126 | + MO_ALIGN = 0, | ||
127 | + MO_UNALN = MO_AMASK, | ||
128 | +#else | 38 | +#else |
129 | + MO_ALIGN = MO_AMASK, | 39 | +# define GETPC() \ |
130 | + MO_UNALN = 0, | 40 | + ((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0))) |
131 | +#endif | ||
132 | +#endif | ||
133 | + MO_ALIGN_2 = 1 << MO_ASHIFT, | ||
134 | + MO_ALIGN_4 = 2 << MO_ASHIFT, | ||
135 | + MO_ALIGN_8 = 3 << MO_ASHIFT, | ||
136 | + MO_ALIGN_16 = 4 << MO_ASHIFT, | ||
137 | + MO_ALIGN_32 = 5 << MO_ASHIFT, | ||
138 | + MO_ALIGN_64 = 6 << MO_ASHIFT, | ||
139 | + | ||
140 | + /* Combinations of the above, for ease of use. */ | ||
141 | + MO_UB = MO_8, | ||
142 | + MO_UW = MO_16, | ||
143 | + MO_UL = MO_32, | ||
144 | + MO_SB = MO_SIGN | MO_8, | ||
145 | + MO_SW = MO_SIGN | MO_16, | ||
146 | + MO_SL = MO_SIGN | MO_32, | ||
147 | + MO_Q = MO_64, | ||
148 | + | ||
149 | + MO_LEUW = MO_LE | MO_UW, | ||
150 | + MO_LEUL = MO_LE | MO_UL, | ||
151 | + MO_LESW = MO_LE | MO_SW, | ||
152 | + MO_LESL = MO_LE | MO_SL, | ||
153 | + MO_LEQ = MO_LE | MO_Q, | ||
154 | + | ||
155 | + MO_BEUW = MO_BE | MO_UW, | ||
156 | + MO_BEUL = MO_BE | MO_UL, | ||
157 | + MO_BESW = MO_BE | MO_SW, | ||
158 | + MO_BESL = MO_BE | MO_SL, | ||
159 | + MO_BEQ = MO_BE | MO_Q, | ||
160 | + | ||
161 | +#ifdef NEED_CPU_H | ||
162 | + MO_TEUW = MO_TE | MO_UW, | ||
163 | + MO_TEUL = MO_TE | MO_UL, | ||
164 | + MO_TESW = MO_TE | MO_SW, | ||
165 | + MO_TESL = MO_TE | MO_SL, | ||
166 | + MO_TEQ = MO_TE | MO_Q, | ||
167 | +#endif | 41 | +#endif |
168 | + | 42 | + |
169 | + MO_SSIZE = MO_SIZE | MO_SIGN, | 43 | +#endif /* ACCEL_TCG_GETPC_H */ |
170 | +} MemOp; | 44 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h |
171 | + | ||
172 | +#endif | ||
173 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
174 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
175 | --- a/target/arm/translate-a64.h | 46 | --- a/include/exec/exec-all.h |
176 | +++ b/target/arm/translate-a64.h | 47 | +++ b/include/exec/exec-all.h |
177 | @@ -XXX,XX +XXX,XX @@ static inline void assert_fp_access_checked(DisasContext *s) | ||
178 | * the FP/vector register Qn. | ||
179 | */ | ||
180 | static inline int vec_reg_offset(DisasContext *s, int regno, | ||
181 | - int element, TCGMemOp size) | ||
182 | + int element, MemOp size) | ||
183 | { | ||
184 | int element_size = 1 << size; | ||
185 | int offs = element * element_size; | ||
186 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
187 | index XXXXXXX..XXXXXXX 100644 | ||
188 | --- a/target/arm/translate.h | ||
189 | +++ b/target/arm/translate.h | ||
190 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
191 | int condexec_cond; | ||
192 | int thumb; | ||
193 | int sctlr_b; | ||
194 | - TCGMemOp be_data; | ||
195 | + MemOp be_data; | ||
196 | #if !defined(CONFIG_USER_ONLY) | ||
197 | int user; | ||
198 | #endif | ||
199 | diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h | ||
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/tcg/tcg-op.h | ||
202 | +++ b/tcg/tcg-op.h | ||
203 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_lookup_and_goto_ptr(void); | ||
204 | #define tcg_gen_qemu_st_tl tcg_gen_qemu_st_i64 | ||
205 | #endif | ||
206 | |||
207 | -void tcg_gen_qemu_ld_i32(TCGv_i32, TCGv, TCGArg, TCGMemOp); | ||
208 | -void tcg_gen_qemu_st_i32(TCGv_i32, TCGv, TCGArg, TCGMemOp); | ||
209 | -void tcg_gen_qemu_ld_i64(TCGv_i64, TCGv, TCGArg, TCGMemOp); | ||
210 | -void tcg_gen_qemu_st_i64(TCGv_i64, TCGv, TCGArg, TCGMemOp); | ||
211 | +void tcg_gen_qemu_ld_i32(TCGv_i32, TCGv, TCGArg, MemOp); | ||
212 | +void tcg_gen_qemu_st_i32(TCGv_i32, TCGv, TCGArg, MemOp); | ||
213 | +void tcg_gen_qemu_ld_i64(TCGv_i64, TCGv, TCGArg, MemOp); | ||
214 | +void tcg_gen_qemu_st_i64(TCGv_i64, TCGv, TCGArg, MemOp); | ||
215 | |||
216 | static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index) | ||
217 | { | ||
218 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index) | ||
219 | } | ||
220 | |||
221 | void tcg_gen_atomic_cmpxchg_i32(TCGv_i32, TCGv, TCGv_i32, TCGv_i32, | ||
222 | - TCGArg, TCGMemOp); | ||
223 | + TCGArg, MemOp); | ||
224 | void tcg_gen_atomic_cmpxchg_i64(TCGv_i64, TCGv, TCGv_i64, TCGv_i64, | ||
225 | - TCGArg, TCGMemOp); | ||
226 | + TCGArg, MemOp); | ||
227 | |||
228 | -void tcg_gen_atomic_xchg_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
229 | -void tcg_gen_atomic_xchg_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
230 | +void tcg_gen_atomic_xchg_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
231 | +void tcg_gen_atomic_xchg_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
232 | |||
233 | -void tcg_gen_atomic_fetch_add_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
234 | -void tcg_gen_atomic_fetch_add_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
235 | -void tcg_gen_atomic_fetch_and_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
236 | -void tcg_gen_atomic_fetch_and_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
237 | -void tcg_gen_atomic_fetch_or_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
238 | -void tcg_gen_atomic_fetch_or_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
239 | -void tcg_gen_atomic_fetch_xor_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
240 | -void tcg_gen_atomic_fetch_xor_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
241 | -void tcg_gen_atomic_fetch_smin_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
242 | -void tcg_gen_atomic_fetch_smin_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
243 | -void tcg_gen_atomic_fetch_umin_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
244 | -void tcg_gen_atomic_fetch_umin_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
245 | -void tcg_gen_atomic_fetch_smax_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
246 | -void tcg_gen_atomic_fetch_smax_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
247 | -void tcg_gen_atomic_fetch_umax_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
248 | -void tcg_gen_atomic_fetch_umax_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
249 | +void tcg_gen_atomic_fetch_add_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
250 | +void tcg_gen_atomic_fetch_add_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
251 | +void tcg_gen_atomic_fetch_and_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
252 | +void tcg_gen_atomic_fetch_and_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
253 | +void tcg_gen_atomic_fetch_or_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
254 | +void tcg_gen_atomic_fetch_or_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
255 | +void tcg_gen_atomic_fetch_xor_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
256 | +void tcg_gen_atomic_fetch_xor_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
257 | +void tcg_gen_atomic_fetch_smin_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
258 | +void tcg_gen_atomic_fetch_smin_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
259 | +void tcg_gen_atomic_fetch_umin_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
260 | +void tcg_gen_atomic_fetch_umin_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
261 | +void tcg_gen_atomic_fetch_smax_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
262 | +void tcg_gen_atomic_fetch_smax_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
263 | +void tcg_gen_atomic_fetch_umax_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
264 | +void tcg_gen_atomic_fetch_umax_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
265 | |||
266 | -void tcg_gen_atomic_add_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
267 | -void tcg_gen_atomic_add_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
268 | -void tcg_gen_atomic_and_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
269 | -void tcg_gen_atomic_and_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
270 | -void tcg_gen_atomic_or_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
271 | -void tcg_gen_atomic_or_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
272 | -void tcg_gen_atomic_xor_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
273 | -void tcg_gen_atomic_xor_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
274 | -void tcg_gen_atomic_smin_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
275 | -void tcg_gen_atomic_smin_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
276 | -void tcg_gen_atomic_umin_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
277 | -void tcg_gen_atomic_umin_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
278 | -void tcg_gen_atomic_smax_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
279 | -void tcg_gen_atomic_smax_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
280 | -void tcg_gen_atomic_umax_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); | ||
281 | -void tcg_gen_atomic_umax_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); | ||
282 | +void tcg_gen_atomic_add_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
283 | +void tcg_gen_atomic_add_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
284 | +void tcg_gen_atomic_and_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
285 | +void tcg_gen_atomic_and_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
286 | +void tcg_gen_atomic_or_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
287 | +void tcg_gen_atomic_or_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
288 | +void tcg_gen_atomic_xor_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
289 | +void tcg_gen_atomic_xor_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
290 | +void tcg_gen_atomic_smin_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
291 | +void tcg_gen_atomic_smin_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
292 | +void tcg_gen_atomic_umin_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
293 | +void tcg_gen_atomic_umin_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
294 | +void tcg_gen_atomic_smax_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
295 | +void tcg_gen_atomic_smax_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
296 | +void tcg_gen_atomic_umax_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); | ||
297 | +void tcg_gen_atomic_umax_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); | ||
298 | |||
299 | void tcg_gen_mov_vec(TCGv_vec, TCGv_vec); | ||
300 | void tcg_gen_dup_i32_vec(unsigned vece, TCGv_vec, TCGv_i32); | ||
301 | diff --git a/tcg/tcg.h b/tcg/tcg.h | ||
302 | index XXXXXXX..XXXXXXX 100644 | ||
303 | --- a/tcg/tcg.h | ||
304 | +++ b/tcg/tcg.h | ||
305 | @@ -XXX,XX +XXX,XX @@ | 48 | @@ -XXX,XX +XXX,XX @@ |
306 | #define TCG_H | 49 | #include "exec/translation-block.h" |
307 | 50 | ||
308 | #include "cpu.h" | 51 | #if defined(CONFIG_TCG) |
309 | +#include "exec/memop.h" | 52 | +#include "accel/tcg/getpc.h" |
310 | #include "exec/tb-context.h" | 53 | |
311 | #include "qemu/bitops.h" | 54 | /** |
312 | #include "qemu/queue.h" | 55 | * probe_access: |
313 | @@ -XXX,XX +XXX,XX @@ typedef enum TCGType { | 56 | @@ -XXX,XX +XXX,XX @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); |
314 | #endif | 57 | void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t last); |
315 | } TCGType; | 58 | void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr); |
316 | 59 | ||
317 | -/* Constants for qemu_ld and qemu_st for the Memory Operation field. */ | 60 | -/* GETPC is the true target of the return instruction that we'll execute. */ |
318 | -typedef enum TCGMemOp { | 61 | -#if defined(CONFIG_TCG_INTERPRETER) |
319 | - MO_8 = 0, | 62 | -extern __thread uintptr_t tci_tb_ptr; |
320 | - MO_16 = 1, | 63 | -# define GETPC() tci_tb_ptr |
321 | - MO_32 = 2, | ||
322 | - MO_64 = 3, | ||
323 | - MO_SIZE = 3, /* Mask for the above. */ | ||
324 | - | ||
325 | - MO_SIGN = 4, /* Sign-extended, otherwise zero-extended. */ | ||
326 | - | ||
327 | - MO_BSWAP = 8, /* Host reverse endian. */ | ||
328 | -#ifdef HOST_WORDS_BIGENDIAN | ||
329 | - MO_LE = MO_BSWAP, | ||
330 | - MO_BE = 0, | ||
331 | -#else | 64 | -#else |
332 | - MO_LE = 0, | 65 | -# define GETPC() \ |
333 | - MO_BE = MO_BSWAP, | 66 | - ((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0))) |
334 | -#endif | ||
335 | -#ifdef TARGET_WORDS_BIGENDIAN | ||
336 | - MO_TE = MO_BE, | ||
337 | -#else | ||
338 | - MO_TE = MO_LE, | ||
339 | -#endif | 67 | -#endif |
340 | - | 68 | - |
341 | - /* | 69 | #if !defined(CONFIG_USER_ONLY) |
342 | - * MO_UNALN accesses are never checked for alignment. | 70 | |
343 | - * MO_ALIGN accesses will result in a call to the CPU's | ||
344 | - * do_unaligned_access hook if the guest address is not aligned. | ||
345 | - * The default depends on whether the target CPU defines | ||
346 | - * TARGET_ALIGNED_ONLY. | ||
347 | - * | ||
348 | - * Some architectures (e.g. ARMv8) need the address which is aligned | ||
349 | - * to a size more than the size of the memory access. | ||
350 | - * Some architectures (e.g. SPARCv9) need an address which is aligned, | ||
351 | - * but less strictly than the natural alignment. | ||
352 | - * | ||
353 | - * MO_ALIGN supposes the alignment size is the size of a memory access. | ||
354 | - * | ||
355 | - * There are three options: | ||
356 | - * - unaligned access permitted (MO_UNALN). | ||
357 | - * - an alignment to the size of an access (MO_ALIGN); | ||
358 | - * - an alignment to a specified size, which may be more or less than | ||
359 | - * the access size (MO_ALIGN_x where 'x' is a size in bytes); | ||
360 | - */ | ||
361 | - MO_ASHIFT = 4, | ||
362 | - MO_AMASK = 7 << MO_ASHIFT, | ||
363 | -#ifdef TARGET_ALIGNED_ONLY | ||
364 | - MO_ALIGN = 0, | ||
365 | - MO_UNALN = MO_AMASK, | ||
366 | -#else | ||
367 | - MO_ALIGN = MO_AMASK, | ||
368 | - MO_UNALN = 0, | ||
369 | -#endif | ||
370 | - MO_ALIGN_2 = 1 << MO_ASHIFT, | ||
371 | - MO_ALIGN_4 = 2 << MO_ASHIFT, | ||
372 | - MO_ALIGN_8 = 3 << MO_ASHIFT, | ||
373 | - MO_ALIGN_16 = 4 << MO_ASHIFT, | ||
374 | - MO_ALIGN_32 = 5 << MO_ASHIFT, | ||
375 | - MO_ALIGN_64 = 6 << MO_ASHIFT, | ||
376 | - | ||
377 | - /* Combinations of the above, for ease of use. */ | ||
378 | - MO_UB = MO_8, | ||
379 | - MO_UW = MO_16, | ||
380 | - MO_UL = MO_32, | ||
381 | - MO_SB = MO_SIGN | MO_8, | ||
382 | - MO_SW = MO_SIGN | MO_16, | ||
383 | - MO_SL = MO_SIGN | MO_32, | ||
384 | - MO_Q = MO_64, | ||
385 | - | ||
386 | - MO_LEUW = MO_LE | MO_UW, | ||
387 | - MO_LEUL = MO_LE | MO_UL, | ||
388 | - MO_LESW = MO_LE | MO_SW, | ||
389 | - MO_LESL = MO_LE | MO_SL, | ||
390 | - MO_LEQ = MO_LE | MO_Q, | ||
391 | - | ||
392 | - MO_BEUW = MO_BE | MO_UW, | ||
393 | - MO_BEUL = MO_BE | MO_UL, | ||
394 | - MO_BESW = MO_BE | MO_SW, | ||
395 | - MO_BESL = MO_BE | MO_SL, | ||
396 | - MO_BEQ = MO_BE | MO_Q, | ||
397 | - | ||
398 | - MO_TEUW = MO_TE | MO_UW, | ||
399 | - MO_TEUL = MO_TE | MO_UL, | ||
400 | - MO_TESW = MO_TE | MO_SW, | ||
401 | - MO_TESL = MO_TE | MO_SL, | ||
402 | - MO_TEQ = MO_TE | MO_Q, | ||
403 | - | ||
404 | - MO_SSIZE = MO_SIZE | MO_SIGN, | ||
405 | -} TCGMemOp; | ||
406 | - | ||
407 | /** | 71 | /** |
408 | * get_alignment_bits | ||
409 | - * @memop: TCGMemOp value | ||
410 | + * @memop: MemOp value | ||
411 | * | ||
412 | * Extract the alignment size from the memop. | ||
413 | */ | ||
414 | -static inline unsigned get_alignment_bits(TCGMemOp memop) | ||
415 | +static inline unsigned get_alignment_bits(MemOp memop) | ||
416 | { | ||
417 | unsigned a = memop & MO_AMASK; | ||
418 | |||
419 | @@ -XXX,XX +XXX,XX @@ static inline size_t tcg_current_code_size(TCGContext *s) | ||
420 | return tcg_ptr_byte_diff(s->code_ptr, s->code_buf); | ||
421 | } | ||
422 | |||
423 | -/* Combine the TCGMemOp and mmu_idx parameters into a single value. */ | ||
424 | +/* Combine the MemOp and mmu_idx parameters into a single value. */ | ||
425 | typedef uint32_t TCGMemOpIdx; | ||
426 | |||
427 | /** | ||
428 | @@ -XXX,XX +XXX,XX @@ typedef uint32_t TCGMemOpIdx; | ||
429 | * | ||
430 | * Encode these values into a single parameter. | ||
431 | */ | ||
432 | -static inline TCGMemOpIdx make_memop_idx(TCGMemOp op, unsigned idx) | ||
433 | +static inline TCGMemOpIdx make_memop_idx(MemOp op, unsigned idx) | ||
434 | { | ||
435 | tcg_debug_assert(idx <= 15); | ||
436 | return (op << 4) | idx; | ||
437 | @@ -XXX,XX +XXX,XX @@ static inline TCGMemOpIdx make_memop_idx(TCGMemOp op, unsigned idx) | ||
438 | * | ||
439 | * Extract the memory operation from the combined value. | ||
440 | */ | ||
441 | -static inline TCGMemOp get_memop(TCGMemOpIdx oi) | ||
442 | +static inline MemOp get_memop(TCGMemOpIdx oi) | ||
443 | { | ||
444 | return oi >> 4; | ||
445 | } | ||
446 | diff --git a/trace/mem-internal.h b/trace/mem-internal.h | ||
447 | index XXXXXXX..XXXXXXX 100644 | ||
448 | --- a/trace/mem-internal.h | ||
449 | +++ b/trace/mem-internal.h | ||
450 | @@ -XXX,XX +XXX,XX @@ | ||
451 | #define TRACE_MEM_ST (1ULL << 5) /* store (y/n) */ | ||
452 | |||
453 | static inline uint8_t trace_mem_build_info( | ||
454 | - int size_shift, bool sign_extend, TCGMemOp endianness, bool store) | ||
455 | + int size_shift, bool sign_extend, MemOp endianness, bool store) | ||
456 | { | ||
457 | uint8_t res; | ||
458 | |||
459 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t trace_mem_build_info( | ||
460 | return res; | ||
461 | } | ||
462 | |||
463 | -static inline uint8_t trace_mem_get_info(TCGMemOp op, bool store) | ||
464 | +static inline uint8_t trace_mem_get_info(MemOp op, bool store) | ||
465 | { | ||
466 | return trace_mem_build_info(op & MO_SIZE, !!(op & MO_SIGN), | ||
467 | op & MO_BSWAP, store); | ||
468 | diff --git a/trace/mem.h b/trace/mem.h | ||
469 | index XXXXXXX..XXXXXXX 100644 | ||
470 | --- a/trace/mem.h | ||
471 | +++ b/trace/mem.h | ||
472 | @@ -XXX,XX +XXX,XX @@ | ||
473 | * | ||
474 | * Return a value for the 'info' argument in guest memory access traces. | ||
475 | */ | ||
476 | -static uint8_t trace_mem_get_info(TCGMemOp op, bool store); | ||
477 | +static uint8_t trace_mem_get_info(MemOp op, bool store); | ||
478 | |||
479 | /** | ||
480 | * trace_mem_build_info: | ||
481 | @@ -XXX,XX +XXX,XX @@ static uint8_t trace_mem_get_info(TCGMemOp op, bool store); | ||
482 | * Return a value for the 'info' argument in guest memory access traces. | ||
483 | */ | ||
484 | static uint8_t trace_mem_build_info(int size_shift, bool sign_extend, | ||
485 | - TCGMemOp endianness, bool store); | ||
486 | + MemOp endianness, bool store); | ||
487 | |||
488 | |||
489 | #include "trace/mem-internal.h" | ||
490 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
491 | index XXXXXXX..XXXXXXX 100644 | ||
492 | --- a/accel/tcg/cputlb.c | ||
493 | +++ b/accel/tcg/cputlb.c | ||
494 | @@ -XXX,XX +XXX,XX @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, | ||
495 | uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
496 | CPUTLBEntry *tlbe = tlb_entry(env, mmu_idx, addr); | ||
497 | target_ulong tlb_addr = tlb_addr_write(tlbe); | ||
498 | - TCGMemOp mop = get_memop(oi); | ||
499 | + MemOp mop = get_memop(oi); | ||
500 | int a_bits = get_alignment_bits(mop); | ||
501 | int s_bits = mop & MO_SIZE; | ||
502 | void *hostaddr; | ||
503 | diff --git a/target/alpha/translate.c b/target/alpha/translate.c | ||
504 | index XXXXXXX..XXXXXXX 100644 | ||
505 | --- a/target/alpha/translate.c | ||
506 | +++ b/target/alpha/translate.c | ||
507 | @@ -XXX,XX +XXX,XX @@ static inline void gen_store_mem(DisasContext *ctx, | ||
508 | |||
509 | static DisasJumpType gen_store_conditional(DisasContext *ctx, int ra, int rb, | ||
510 | int32_t disp16, int mem_idx, | ||
511 | - TCGMemOp op) | ||
512 | + MemOp op) | ||
513 | { | ||
514 | TCGLabel *lab_fail, *lab_done; | ||
515 | TCGv addr, val; | ||
516 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
517 | index XXXXXXX..XXXXXXX 100644 | ||
518 | --- a/target/arm/translate-a64.c | ||
519 | +++ b/target/arm/translate-a64.c | ||
520 | @@ -XXX,XX +XXX,XX @@ typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64); | ||
521 | typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); | ||
522 | typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
523 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
524 | -typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, TCGMemOp); | ||
525 | +typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
526 | |||
527 | /* initialize TCG globals. */ | ||
528 | void a64_translate_init(void) | ||
529 | @@ -XXX,XX +XXX,XX @@ TCGv_i64 read_cpu_reg_sp(DisasContext *s, int reg, int sf) | ||
530 | * Dn, Sn, Hn or Bn). | ||
531 | * (Note that this is not the same mapping as for A32; see cpu.h) | ||
532 | */ | ||
533 | -static inline int fp_reg_offset(DisasContext *s, int regno, TCGMemOp size) | ||
534 | +static inline int fp_reg_offset(DisasContext *s, int regno, MemOp size) | ||
535 | { | ||
536 | return vec_reg_offset(s, regno, 0, size); | ||
537 | } | ||
538 | @@ -XXX,XX +XXX,XX @@ static void do_gpr_ld_memidx(DisasContext *s, | ||
539 | bool iss_valid, unsigned int iss_srt, | ||
540 | bool iss_sf, bool iss_ar) | ||
541 | { | ||
542 | - TCGMemOp memop = s->be_data + size; | ||
543 | + MemOp memop = s->be_data + size; | ||
544 | |||
545 | g_assert(size <= 3); | ||
546 | |||
547 | @@ -XXX,XX +XXX,XX @@ static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size) | ||
548 | TCGv_i64 tmphi; | ||
549 | |||
550 | if (size < 4) { | ||
551 | - TCGMemOp memop = s->be_data + size; | ||
552 | + MemOp memop = s->be_data + size; | ||
553 | tmphi = tcg_const_i64(0); | ||
554 | tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), memop); | ||
555 | } else { | ||
556 | @@ -XXX,XX +XXX,XX @@ static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size) | ||
557 | |||
558 | /* Get value of an element within a vector register */ | ||
559 | static void read_vec_element(DisasContext *s, TCGv_i64 tcg_dest, int srcidx, | ||
560 | - int element, TCGMemOp memop) | ||
561 | + int element, MemOp memop) | ||
562 | { | ||
563 | int vect_off = vec_reg_offset(s, srcidx, element, memop & MO_SIZE); | ||
564 | switch (memop) { | ||
565 | @@ -XXX,XX +XXX,XX @@ static void read_vec_element(DisasContext *s, TCGv_i64 tcg_dest, int srcidx, | ||
566 | } | ||
567 | |||
568 | static void read_vec_element_i32(DisasContext *s, TCGv_i32 tcg_dest, int srcidx, | ||
569 | - int element, TCGMemOp memop) | ||
570 | + int element, MemOp memop) | ||
571 | { | ||
572 | int vect_off = vec_reg_offset(s, srcidx, element, memop & MO_SIZE); | ||
573 | switch (memop) { | ||
574 | @@ -XXX,XX +XXX,XX @@ static void read_vec_element_i32(DisasContext *s, TCGv_i32 tcg_dest, int srcidx, | ||
575 | |||
576 | /* Set value of an element within a vector register */ | ||
577 | static void write_vec_element(DisasContext *s, TCGv_i64 tcg_src, int destidx, | ||
578 | - int element, TCGMemOp memop) | ||
579 | + int element, MemOp memop) | ||
580 | { | ||
581 | int vect_off = vec_reg_offset(s, destidx, element, memop & MO_SIZE); | ||
582 | switch (memop) { | ||
583 | @@ -XXX,XX +XXX,XX @@ static void write_vec_element(DisasContext *s, TCGv_i64 tcg_src, int destidx, | ||
584 | } | ||
585 | |||
586 | static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src, | ||
587 | - int destidx, int element, TCGMemOp memop) | ||
588 | + int destidx, int element, MemOp memop) | ||
589 | { | ||
590 | int vect_off = vec_reg_offset(s, destidx, element, memop & MO_SIZE); | ||
591 | switch (memop) { | ||
592 | @@ -XXX,XX +XXX,XX @@ static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src, | ||
593 | |||
594 | /* Store from vector register to memory */ | ||
595 | static void do_vec_st(DisasContext *s, int srcidx, int element, | ||
596 | - TCGv_i64 tcg_addr, int size, TCGMemOp endian) | ||
597 | + TCGv_i64 tcg_addr, int size, MemOp endian) | ||
598 | { | ||
599 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | ||
600 | |||
601 | @@ -XXX,XX +XXX,XX @@ static void do_vec_st(DisasContext *s, int srcidx, int element, | ||
602 | |||
603 | /* Load from memory to vector register */ | ||
604 | static void do_vec_ld(DisasContext *s, int destidx, int element, | ||
605 | - TCGv_i64 tcg_addr, int size, TCGMemOp endian) | ||
606 | + TCGv_i64 tcg_addr, int size, MemOp endian) | ||
607 | { | ||
608 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | ||
609 | |||
610 | @@ -XXX,XX +XXX,XX @@ static void gen_load_exclusive(DisasContext *s, int rt, int rt2, | ||
611 | TCGv_i64 addr, int size, bool is_pair) | ||
612 | { | ||
613 | int idx = get_mem_index(s); | ||
614 | - TCGMemOp memop = s->be_data; | ||
615 | + MemOp memop = s->be_data; | ||
616 | |||
617 | g_assert(size <= 3); | ||
618 | if (is_pair) { | ||
619 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
620 | bool is_postidx = extract32(insn, 23, 1); | ||
621 | bool is_q = extract32(insn, 30, 1); | ||
622 | TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; | ||
623 | - TCGMemOp endian = s->be_data; | ||
624 | + MemOp endian = s->be_data; | ||
625 | |||
626 | int ebytes; /* bytes per element */ | ||
627 | int elements; /* elements per vector */ | ||
628 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | ||
629 | unsigned int mos, type, rm, cond, rn, rd; | ||
630 | TCGv_i64 t_true, t_false, t_zero; | ||
631 | DisasCompare64 c; | ||
632 | - TCGMemOp sz; | ||
633 | + MemOp sz; | ||
634 | |||
635 | mos = extract32(insn, 29, 3); | ||
636 | type = extract32(insn, 22, 2); | ||
637 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) | ||
638 | int mos = extract32(insn, 29, 3); | ||
639 | uint64_t imm; | ||
640 | TCGv_i64 tcg_res; | ||
641 | - TCGMemOp sz; | ||
642 | + MemOp sz; | ||
643 | |||
644 | if (mos || imm5) { | ||
645 | unallocated_encoding(s); | ||
646 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 do_reduction_op(DisasContext *s, int fpopcode, int rn, | ||
647 | { | ||
648 | if (esize == size) { | ||
649 | int element; | ||
650 | - TCGMemOp msize = esize == 16 ? MO_16 : MO_32; | ||
651 | + MemOp msize = esize == 16 ? MO_16 : MO_32; | ||
652 | TCGv_i32 tcg_elem; | ||
653 | |||
654 | /* We should have one register left here */ | ||
655 | @@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_sqshrn(DisasContext *s, bool is_scalar, bool is_q, | ||
656 | int shift = (2 * esize) - immhb; | ||
657 | int elements = is_scalar ? 1 : (64 / esize); | ||
658 | bool round = extract32(opcode, 0, 1); | ||
659 | - TCGMemOp ldop = (size + 1) | (is_u_shift ? 0 : MO_SIGN); | ||
660 | + MemOp ldop = (size + 1) | (is_u_shift ? 0 : MO_SIGN); | ||
661 | TCGv_i64 tcg_rn, tcg_rd, tcg_round; | ||
662 | TCGv_i32 tcg_rd_narrowed; | ||
663 | TCGv_i64 tcg_final; | ||
664 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_qshl(DisasContext *s, bool scalar, bool is_q, | ||
665 | } | ||
666 | }; | ||
667 | NeonGenTwoOpEnvFn *genfn = fns[src_unsigned][dst_unsigned][size]; | ||
668 | - TCGMemOp memop = scalar ? size : MO_32; | ||
669 | + MemOp memop = scalar ? size : MO_32; | ||
670 | int maxpass = scalar ? 1 : is_q ? 4 : 2; | ||
671 | |||
672 | for (pass = 0; pass < maxpass; pass++) { | ||
673 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn, | ||
674 | TCGv_ptr tcg_fpst = get_fpstatus_ptr(size == MO_16); | ||
675 | TCGv_i32 tcg_shift = NULL; | ||
676 | |||
677 | - TCGMemOp mop = size | (is_signed ? MO_SIGN : 0); | ||
678 | + MemOp mop = size | (is_signed ? MO_SIGN : 0); | ||
679 | int pass; | ||
680 | |||
681 | if (fracbits || size == MO_64) { | ||
682 | @@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_shri(DisasContext *s, bool is_q, bool is_u, | ||
683 | int dsize = is_q ? 128 : 64; | ||
684 | int esize = 8 << size; | ||
685 | int elements = dsize/esize; | ||
686 | - TCGMemOp memop = size | (is_u ? 0 : MO_SIGN); | ||
687 | + MemOp memop = size | (is_u ? 0 : MO_SIGN); | ||
688 | TCGv_i64 tcg_rn = new_tmp_a64(s); | ||
689 | TCGv_i64 tcg_rd = new_tmp_a64(s); | ||
690 | TCGv_i64 tcg_round; | ||
691 | @@ -XXX,XX +XXX,XX @@ static void handle_3rd_widening(DisasContext *s, int is_q, int is_u, int size, | ||
692 | TCGv_i64 tcg_op1 = tcg_temp_new_i64(); | ||
693 | TCGv_i64 tcg_op2 = tcg_temp_new_i64(); | ||
694 | TCGv_i64 tcg_passres; | ||
695 | - TCGMemOp memop = MO_32 | (is_u ? 0 : MO_SIGN); | ||
696 | + MemOp memop = MO_32 | (is_u ? 0 : MO_SIGN); | ||
697 | |||
698 | int elt = pass + is_q * 2; | ||
699 | |||
700 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_pairwise(DisasContext *s, int opcode, bool u, | ||
701 | |||
702 | if (size == 2) { | ||
703 | /* 32 + 32 -> 64 op */ | ||
704 | - TCGMemOp memop = size + (u ? 0 : MO_SIGN); | ||
705 | + MemOp memop = size + (u ? 0 : MO_SIGN); | ||
706 | |||
707 | for (pass = 0; pass < maxpass; pass++) { | ||
708 | TCGv_i64 tcg_op1 = tcg_temp_new_i64(); | ||
709 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
710 | |||
711 | switch (is_fp) { | ||
712 | case 1: /* normal fp */ | ||
713 | - /* convert insn encoded size to TCGMemOp size */ | ||
714 | + /* convert insn encoded size to MemOp size */ | ||
715 | switch (size) { | ||
716 | case 0: /* half-precision */ | ||
717 | size = MO_16; | ||
718 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
719 | return; | ||
720 | } | ||
721 | |||
722 | - /* Given TCGMemOp size, adjust register and indexing. */ | ||
723 | + /* Given MemOp size, adjust register and indexing. */ | ||
724 | switch (size) { | ||
725 | case MO_16: | ||
726 | index = h << 2 | l << 1 | m; | ||
727 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
728 | TCGv_i64 tcg_res[2]; | ||
729 | int pass; | ||
730 | bool satop = extract32(opcode, 0, 1); | ||
731 | - TCGMemOp memop = MO_32; | ||
732 | + MemOp memop = MO_32; | ||
733 | |||
734 | if (satop || !u) { | ||
735 | memop |= MO_SIGN; | ||
736 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
737 | index XXXXXXX..XXXXXXX 100644 | ||
738 | --- a/target/arm/translate-sve.c | ||
739 | +++ b/target/arm/translate-sve.c | ||
740 | @@ -XXX,XX +XXX,XX @@ static bool trans_STR_pri(DisasContext *s, arg_rri *a) | ||
741 | */ | ||
742 | |||
743 | /* The memory mode of the dtype. */ | ||
744 | -static const TCGMemOp dtype_mop[16] = { | ||
745 | +static const MemOp dtype_mop[16] = { | ||
746 | MO_UB, MO_UB, MO_UB, MO_UB, | ||
747 | MO_SL, MO_UW, MO_UW, MO_UW, | ||
748 | MO_SW, MO_SW, MO_UL, MO_UL, | ||
749 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
750 | index XXXXXXX..XXXXXXX 100644 | ||
751 | --- a/target/arm/translate.c | ||
752 | +++ b/target/arm/translate.c | ||
753 | @@ -XXX,XX +XXX,XX @@ typedef enum ISSInfo { | ||
754 | } ISSInfo; | ||
755 | |||
756 | /* Save the syndrome information for a Data Abort */ | ||
757 | -static void disas_set_da_iss(DisasContext *s, TCGMemOp memop, ISSInfo issinfo) | ||
758 | +static void disas_set_da_iss(DisasContext *s, MemOp memop, ISSInfo issinfo) | ||
759 | { | ||
760 | uint32_t syn; | ||
761 | int sas = memop & MO_SIZE; | ||
762 | @@ -XXX,XX +XXX,XX @@ static inline void store_reg_from_load(DisasContext *s, int reg, TCGv_i32 var) | ||
763 | * that the address argument is TCGv_i32 rather than TCGv. | ||
764 | */ | ||
765 | |||
766 | -static inline TCGv gen_aa32_addr(DisasContext *s, TCGv_i32 a32, TCGMemOp op) | ||
767 | +static inline TCGv gen_aa32_addr(DisasContext *s, TCGv_i32 a32, MemOp op) | ||
768 | { | ||
769 | TCGv addr = tcg_temp_new(); | ||
770 | tcg_gen_extu_i32_tl(addr, a32); | ||
771 | @@ -XXX,XX +XXX,XX @@ static inline TCGv gen_aa32_addr(DisasContext *s, TCGv_i32 a32, TCGMemOp op) | ||
772 | } | ||
773 | |||
774 | static void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
775 | - int index, TCGMemOp opc) | ||
776 | + int index, MemOp opc) | ||
777 | { | ||
778 | TCGv addr; | ||
779 | |||
780 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
781 | } | ||
782 | |||
783 | static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
784 | - int index, TCGMemOp opc) | ||
785 | + int index, MemOp opc) | ||
786 | { | ||
787 | TCGv addr; | ||
788 | |||
789 | @@ -XXX,XX +XXX,XX @@ static inline void gen_aa32_frob64(DisasContext *s, TCGv_i64 val) | ||
790 | } | ||
791 | |||
792 | static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
793 | - int index, TCGMemOp opc) | ||
794 | + int index, MemOp opc) | ||
795 | { | ||
796 | TCGv addr = gen_aa32_addr(s, a32, opc); | ||
797 | tcg_gen_qemu_ld_i64(val, addr, index, opc); | ||
798 | @@ -XXX,XX +XXX,XX @@ static inline void gen_aa32_ld64(DisasContext *s, TCGv_i64 val, | ||
799 | } | ||
800 | |||
801 | static void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
802 | - int index, TCGMemOp opc) | ||
803 | + int index, MemOp opc) | ||
804 | { | ||
805 | TCGv addr = gen_aa32_addr(s, a32, opc); | ||
806 | |||
807 | @@ -XXX,XX +XXX,XX @@ neon_reg_offset (int reg, int n) | ||
808 | * where 0 is the least significant end of the register. | ||
809 | */ | ||
810 | static inline long | ||
811 | -neon_element_offset(int reg, int element, TCGMemOp size) | ||
812 | +neon_element_offset(int reg, int element, MemOp size) | ||
813 | { | ||
814 | int element_size = 1 << size; | ||
815 | int ofs = element * element_size; | ||
816 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 neon_load_reg(int reg, int pass) | ||
817 | return tmp; | ||
818 | } | ||
819 | |||
820 | -static void neon_load_element(TCGv_i32 var, int reg, int ele, TCGMemOp mop) | ||
821 | +static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop) | ||
822 | { | ||
823 | long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | ||
824 | |||
825 | @@ -XXX,XX +XXX,XX @@ static void neon_load_element(TCGv_i32 var, int reg, int ele, TCGMemOp mop) | ||
826 | } | ||
827 | } | ||
828 | |||
829 | -static void neon_load_element64(TCGv_i64 var, int reg, int ele, TCGMemOp mop) | ||
830 | +static void neon_load_element64(TCGv_i64 var, int reg, int ele, MemOp mop) | ||
831 | { | ||
832 | long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | ||
833 | |||
834 | @@ -XXX,XX +XXX,XX @@ static void neon_store_reg(int reg, int pass, TCGv_i32 var) | ||
835 | tcg_temp_free_i32(var); | ||
836 | } | ||
837 | |||
838 | -static void neon_store_element(int reg, int ele, TCGMemOp size, TCGv_i32 var) | ||
839 | +static void neon_store_element(int reg, int ele, MemOp size, TCGv_i32 var) | ||
840 | { | ||
841 | long offset = neon_element_offset(reg, ele, size); | ||
842 | |||
843 | @@ -XXX,XX +XXX,XX @@ static void neon_store_element(int reg, int ele, TCGMemOp size, TCGv_i32 var) | ||
844 | } | ||
845 | } | ||
846 | |||
847 | -static void neon_store_element64(int reg, int ele, TCGMemOp size, TCGv_i64 var) | ||
848 | +static void neon_store_element64(int reg, int ele, MemOp size, TCGv_i64 var) | ||
849 | { | ||
850 | long offset = neon_element_offset(reg, ele, size); | ||
851 | |||
852 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
853 | int n; | ||
854 | int vec_size; | ||
855 | int mmu_idx; | ||
856 | - TCGMemOp endian; | ||
857 | + MemOp endian; | ||
858 | TCGv_i32 addr; | ||
859 | TCGv_i32 tmp; | ||
860 | TCGv_i32 tmp2; | ||
861 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
862 | } else if ((insn & 0x380) == 0) { | ||
863 | /* VDUP */ | ||
864 | int element; | ||
865 | - TCGMemOp size; | ||
866 | + MemOp size; | ||
867 | |||
868 | if ((insn & (7 << 16)) == 0 || (q && (rd & 1))) { | ||
869 | return 1; | ||
870 | @@ -XXX,XX +XXX,XX @@ static void gen_load_exclusive(DisasContext *s, int rt, int rt2, | ||
871 | TCGv_i32 addr, int size) | ||
872 | { | ||
873 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
874 | - TCGMemOp opc = size | MO_ALIGN | s->be_data; | ||
875 | + MemOp opc = size | MO_ALIGN | s->be_data; | ||
876 | |||
877 | s->is_ldex = true; | ||
878 | |||
879 | @@ -XXX,XX +XXX,XX @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2, | ||
880 | TCGv taddr; | ||
881 | TCGLabel *done_label; | ||
882 | TCGLabel *fail_label; | ||
883 | - TCGMemOp opc = size | MO_ALIGN | s->be_data; | ||
884 | + MemOp opc = size | MO_ALIGN | s->be_data; | ||
885 | |||
886 | /* if (env->exclusive_addr == addr && env->exclusive_val == [addr]) { | ||
887 | [addr] = {Rt}; | ||
888 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
889 | */ | ||
890 | |||
891 | TCGv taddr; | ||
892 | - TCGMemOp opc = s->be_data; | ||
893 | + MemOp opc = s->be_data; | ||
894 | |||
895 | rm = (insn) & 0xf; | ||
896 | |||
897 | diff --git a/target/hppa/translate.c b/target/hppa/translate.c | ||
898 | index XXXXXXX..XXXXXXX 100644 | ||
899 | --- a/target/hppa/translate.c | ||
900 | +++ b/target/hppa/translate.c | ||
901 | @@ -XXX,XX +XXX,XX @@ static void form_gva(DisasContext *ctx, TCGv_tl *pgva, TCGv_reg *pofs, | ||
902 | */ | ||
903 | static void do_load_32(DisasContext *ctx, TCGv_i32 dest, unsigned rb, | ||
904 | unsigned rx, int scale, target_sreg disp, | ||
905 | - unsigned sp, int modify, TCGMemOp mop) | ||
906 | + unsigned sp, int modify, MemOp mop) | ||
907 | { | ||
908 | TCGv_reg ofs; | ||
909 | TCGv_tl addr; | ||
910 | @@ -XXX,XX +XXX,XX @@ static void do_load_32(DisasContext *ctx, TCGv_i32 dest, unsigned rb, | ||
911 | |||
912 | static void do_load_64(DisasContext *ctx, TCGv_i64 dest, unsigned rb, | ||
913 | unsigned rx, int scale, target_sreg disp, | ||
914 | - unsigned sp, int modify, TCGMemOp mop) | ||
915 | + unsigned sp, int modify, MemOp mop) | ||
916 | { | ||
917 | TCGv_reg ofs; | ||
918 | TCGv_tl addr; | ||
919 | @@ -XXX,XX +XXX,XX @@ static void do_load_64(DisasContext *ctx, TCGv_i64 dest, unsigned rb, | ||
920 | |||
921 | static void do_store_32(DisasContext *ctx, TCGv_i32 src, unsigned rb, | ||
922 | unsigned rx, int scale, target_sreg disp, | ||
923 | - unsigned sp, int modify, TCGMemOp mop) | ||
924 | + unsigned sp, int modify, MemOp mop) | ||
925 | { | ||
926 | TCGv_reg ofs; | ||
927 | TCGv_tl addr; | ||
928 | @@ -XXX,XX +XXX,XX @@ static void do_store_32(DisasContext *ctx, TCGv_i32 src, unsigned rb, | ||
929 | |||
930 | static void do_store_64(DisasContext *ctx, TCGv_i64 src, unsigned rb, | ||
931 | unsigned rx, int scale, target_sreg disp, | ||
932 | - unsigned sp, int modify, TCGMemOp mop) | ||
933 | + unsigned sp, int modify, MemOp mop) | ||
934 | { | ||
935 | TCGv_reg ofs; | ||
936 | TCGv_tl addr; | ||
937 | @@ -XXX,XX +XXX,XX @@ static void do_store_64(DisasContext *ctx, TCGv_i64 src, unsigned rb, | ||
938 | |||
939 | static bool do_load(DisasContext *ctx, unsigned rt, unsigned rb, | ||
940 | unsigned rx, int scale, target_sreg disp, | ||
941 | - unsigned sp, int modify, TCGMemOp mop) | ||
942 | + unsigned sp, int modify, MemOp mop) | ||
943 | { | ||
944 | TCGv_reg dest; | ||
945 | |||
946 | @@ -XXX,XX +XXX,XX @@ static bool trans_fldd(DisasContext *ctx, arg_ldst *a) | ||
947 | |||
948 | static bool do_store(DisasContext *ctx, unsigned rt, unsigned rb, | ||
949 | target_sreg disp, unsigned sp, | ||
950 | - int modify, TCGMemOp mop) | ||
951 | + int modify, MemOp mop) | ||
952 | { | ||
953 | nullify_over(ctx); | ||
954 | do_store_reg(ctx, load_gpr(ctx, rt), rb, 0, 0, disp, sp, modify, mop); | ||
955 | @@ -XXX,XX +XXX,XX @@ static bool trans_st(DisasContext *ctx, arg_ldst *a) | ||
956 | |||
957 | static bool trans_ldc(DisasContext *ctx, arg_ldst *a) | ||
958 | { | ||
959 | - TCGMemOp mop = MO_TEUL | MO_ALIGN_16 | a->size; | ||
960 | + MemOp mop = MO_TEUL | MO_ALIGN_16 | a->size; | ||
961 | TCGv_reg zero, dest, ofs; | ||
962 | TCGv_tl addr; | ||
963 | |||
964 | diff --git a/target/i386/translate.c b/target/i386/translate.c | ||
965 | index XXXXXXX..XXXXXXX 100644 | ||
966 | --- a/target/i386/translate.c | ||
967 | +++ b/target/i386/translate.c | ||
968 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
969 | /* current insn context */ | ||
970 | int override; /* -1 if no override */ | ||
971 | int prefix; | ||
972 | - TCGMemOp aflag; | ||
973 | - TCGMemOp dflag; | ||
974 | + MemOp aflag; | ||
975 | + MemOp dflag; | ||
976 | target_ulong pc_start; | ||
977 | target_ulong pc; /* pc = eip + cs_base */ | ||
978 | /* current block context */ | ||
979 | @@ -XXX,XX +XXX,XX @@ static void gen_eob(DisasContext *s); | ||
980 | static void gen_jr(DisasContext *s, TCGv dest); | ||
981 | static void gen_jmp(DisasContext *s, target_ulong eip); | ||
982 | static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num); | ||
983 | -static void gen_op(DisasContext *s1, int op, TCGMemOp ot, int d); | ||
984 | +static void gen_op(DisasContext *s1, int op, MemOp ot, int d); | ||
985 | |||
986 | /* i386 arith/logic operations */ | ||
987 | enum { | ||
988 | @@ -XXX,XX +XXX,XX @@ static inline bool byte_reg_is_xH(DisasContext *s, int reg) | ||
989 | } | ||
990 | |||
991 | /* Select the size of a push/pop operation. */ | ||
992 | -static inline TCGMemOp mo_pushpop(DisasContext *s, TCGMemOp ot) | ||
993 | +static inline MemOp mo_pushpop(DisasContext *s, MemOp ot) | ||
994 | { | ||
995 | if (CODE64(s)) { | ||
996 | return ot == MO_16 ? MO_16 : MO_64; | ||
997 | @@ -XXX,XX +XXX,XX @@ static inline TCGMemOp mo_pushpop(DisasContext *s, TCGMemOp ot) | ||
998 | } | ||
999 | |||
1000 | /* Select the size of the stack pointer. */ | ||
1001 | -static inline TCGMemOp mo_stacksize(DisasContext *s) | ||
1002 | +static inline MemOp mo_stacksize(DisasContext *s) | ||
1003 | { | ||
1004 | return CODE64(s) ? MO_64 : s->ss32 ? MO_32 : MO_16; | ||
1005 | } | ||
1006 | |||
1007 | /* Select only size 64 else 32. Used for SSE operand sizes. */ | ||
1008 | -static inline TCGMemOp mo_64_32(TCGMemOp ot) | ||
1009 | +static inline MemOp mo_64_32(MemOp ot) | ||
1010 | { | ||
1011 | #ifdef TARGET_X86_64 | ||
1012 | return ot == MO_64 ? MO_64 : MO_32; | ||
1013 | @@ -XXX,XX +XXX,XX @@ static inline TCGMemOp mo_64_32(TCGMemOp ot) | ||
1014 | |||
1015 | /* Select size 8 if lsb of B is clear, else OT. Used for decoding | ||
1016 | byte vs word opcodes. */ | ||
1017 | -static inline TCGMemOp mo_b_d(int b, TCGMemOp ot) | ||
1018 | +static inline MemOp mo_b_d(int b, MemOp ot) | ||
1019 | { | ||
1020 | return b & 1 ? ot : MO_8; | ||
1021 | } | ||
1022 | |||
1023 | /* Select size 8 if lsb of B is clear, else OT capped at 32. | ||
1024 | Used for decoding operand size of port opcodes. */ | ||
1025 | -static inline TCGMemOp mo_b_d32(int b, TCGMemOp ot) | ||
1026 | +static inline MemOp mo_b_d32(int b, MemOp ot) | ||
1027 | { | ||
1028 | return b & 1 ? (ot == MO_16 ? MO_16 : MO_32) : MO_8; | ||
1029 | } | ||
1030 | |||
1031 | -static void gen_op_mov_reg_v(DisasContext *s, TCGMemOp ot, int reg, TCGv t0) | ||
1032 | +static void gen_op_mov_reg_v(DisasContext *s, MemOp ot, int reg, TCGv t0) | ||
1033 | { | ||
1034 | switch(ot) { | ||
1035 | case MO_8: | ||
1036 | @@ -XXX,XX +XXX,XX @@ static void gen_op_mov_reg_v(DisasContext *s, TCGMemOp ot, int reg, TCGv t0) | ||
1037 | } | ||
1038 | |||
1039 | static inline | ||
1040 | -void gen_op_mov_v_reg(DisasContext *s, TCGMemOp ot, TCGv t0, int reg) | ||
1041 | +void gen_op_mov_v_reg(DisasContext *s, MemOp ot, TCGv t0, int reg) | ||
1042 | { | ||
1043 | if (ot == MO_8 && byte_reg_is_xH(s, reg)) { | ||
1044 | tcg_gen_extract_tl(t0, cpu_regs[reg - 4], 8, 8); | ||
1045 | @@ -XXX,XX +XXX,XX @@ static inline void gen_op_jmp_v(TCGv dest) | ||
1046 | } | ||
1047 | |||
1048 | static inline | ||
1049 | -void gen_op_add_reg_im(DisasContext *s, TCGMemOp size, int reg, int32_t val) | ||
1050 | +void gen_op_add_reg_im(DisasContext *s, MemOp size, int reg, int32_t val) | ||
1051 | { | ||
1052 | tcg_gen_addi_tl(s->tmp0, cpu_regs[reg], val); | ||
1053 | gen_op_mov_reg_v(s, size, reg, s->tmp0); | ||
1054 | } | ||
1055 | |||
1056 | -static inline void gen_op_add_reg_T0(DisasContext *s, TCGMemOp size, int reg) | ||
1057 | +static inline void gen_op_add_reg_T0(DisasContext *s, MemOp size, int reg) | ||
1058 | { | ||
1059 | tcg_gen_add_tl(s->tmp0, cpu_regs[reg], s->T0); | ||
1060 | gen_op_mov_reg_v(s, size, reg, s->tmp0); | ||
1061 | @@ -XXX,XX +XXX,XX @@ static inline void gen_jmp_im(DisasContext *s, target_ulong pc) | ||
1062 | /* Compute SEG:REG into A0. SEG is selected from the override segment | ||
1063 | (OVR_SEG) and the default segment (DEF_SEG). OVR_SEG may be -1 to | ||
1064 | indicate no override. */ | ||
1065 | -static void gen_lea_v_seg(DisasContext *s, TCGMemOp aflag, TCGv a0, | ||
1066 | +static void gen_lea_v_seg(DisasContext *s, MemOp aflag, TCGv a0, | ||
1067 | int def_seg, int ovr_seg) | ||
1068 | { | ||
1069 | switch (aflag) { | ||
1070 | @@ -XXX,XX +XXX,XX @@ static inline void gen_string_movl_A0_EDI(DisasContext *s) | ||
1071 | gen_lea_v_seg(s, s->aflag, cpu_regs[R_EDI], R_ES, -1); | ||
1072 | } | ||
1073 | |||
1074 | -static inline void gen_op_movl_T0_Dshift(DisasContext *s, TCGMemOp ot) | ||
1075 | +static inline void gen_op_movl_T0_Dshift(DisasContext *s, MemOp ot) | ||
1076 | { | ||
1077 | tcg_gen_ld32s_tl(s->T0, cpu_env, offsetof(CPUX86State, df)); | ||
1078 | tcg_gen_shli_tl(s->T0, s->T0, ot); | ||
1079 | }; | ||
1080 | |||
1081 | -static TCGv gen_ext_tl(TCGv dst, TCGv src, TCGMemOp size, bool sign) | ||
1082 | +static TCGv gen_ext_tl(TCGv dst, TCGv src, MemOp size, bool sign) | ||
1083 | { | ||
1084 | switch (size) { | ||
1085 | case MO_8: | ||
1086 | @@ -XXX,XX +XXX,XX @@ static TCGv gen_ext_tl(TCGv dst, TCGv src, TCGMemOp size, bool sign) | ||
1087 | } | ||
1088 | } | ||
1089 | |||
1090 | -static void gen_extu(TCGMemOp ot, TCGv reg) | ||
1091 | +static void gen_extu(MemOp ot, TCGv reg) | ||
1092 | { | ||
1093 | gen_ext_tl(reg, reg, ot, false); | ||
1094 | } | ||
1095 | |||
1096 | -static void gen_exts(TCGMemOp ot, TCGv reg) | ||
1097 | +static void gen_exts(MemOp ot, TCGv reg) | ||
1098 | { | ||
1099 | gen_ext_tl(reg, reg, ot, true); | ||
1100 | } | ||
1101 | |||
1102 | static inline | ||
1103 | -void gen_op_jnz_ecx(DisasContext *s, TCGMemOp size, TCGLabel *label1) | ||
1104 | +void gen_op_jnz_ecx(DisasContext *s, MemOp size, TCGLabel *label1) | ||
1105 | { | ||
1106 | tcg_gen_mov_tl(s->tmp0, cpu_regs[R_ECX]); | ||
1107 | gen_extu(size, s->tmp0); | ||
1108 | @@ -XXX,XX +XXX,XX @@ void gen_op_jnz_ecx(DisasContext *s, TCGMemOp size, TCGLabel *label1) | ||
1109 | } | ||
1110 | |||
1111 | static inline | ||
1112 | -void gen_op_jz_ecx(DisasContext *s, TCGMemOp size, TCGLabel *label1) | ||
1113 | +void gen_op_jz_ecx(DisasContext *s, MemOp size, TCGLabel *label1) | ||
1114 | { | ||
1115 | tcg_gen_mov_tl(s->tmp0, cpu_regs[R_ECX]); | ||
1116 | gen_extu(size, s->tmp0); | ||
1117 | tcg_gen_brcondi_tl(TCG_COND_EQ, s->tmp0, 0, label1); | ||
1118 | } | ||
1119 | |||
1120 | -static void gen_helper_in_func(TCGMemOp ot, TCGv v, TCGv_i32 n) | ||
1121 | +static void gen_helper_in_func(MemOp ot, TCGv v, TCGv_i32 n) | ||
1122 | { | ||
1123 | switch (ot) { | ||
1124 | case MO_8: | ||
1125 | @@ -XXX,XX +XXX,XX @@ static void gen_helper_in_func(TCGMemOp ot, TCGv v, TCGv_i32 n) | ||
1126 | } | ||
1127 | } | ||
1128 | |||
1129 | -static void gen_helper_out_func(TCGMemOp ot, TCGv_i32 v, TCGv_i32 n) | ||
1130 | +static void gen_helper_out_func(MemOp ot, TCGv_i32 v, TCGv_i32 n) | ||
1131 | { | ||
1132 | switch (ot) { | ||
1133 | case MO_8: | ||
1134 | @@ -XXX,XX +XXX,XX @@ static void gen_helper_out_func(TCGMemOp ot, TCGv_i32 v, TCGv_i32 n) | ||
1135 | } | ||
1136 | } | ||
1137 | |||
1138 | -static void gen_check_io(DisasContext *s, TCGMemOp ot, target_ulong cur_eip, | ||
1139 | +static void gen_check_io(DisasContext *s, MemOp ot, target_ulong cur_eip, | ||
1140 | uint32_t svm_flags) | ||
1141 | { | ||
1142 | target_ulong next_eip; | ||
1143 | @@ -XXX,XX +XXX,XX @@ static void gen_check_io(DisasContext *s, TCGMemOp ot, target_ulong cur_eip, | ||
1144 | } | ||
1145 | } | ||
1146 | |||
1147 | -static inline void gen_movs(DisasContext *s, TCGMemOp ot) | ||
1148 | +static inline void gen_movs(DisasContext *s, MemOp ot) | ||
1149 | { | ||
1150 | gen_string_movl_A0_ESI(s); | ||
1151 | gen_op_ld_v(s, ot, s->T0, s->A0); | ||
1152 | @@ -XXX,XX +XXX,XX @@ static CCPrepare gen_prepare_eflags_s(DisasContext *s, TCGv reg) | ||
1153 | return (CCPrepare) { .cond = TCG_COND_NEVER, .mask = -1 }; | ||
1154 | default: | ||
1155 | { | ||
1156 | - TCGMemOp size = (s->cc_op - CC_OP_ADDB) & 3; | ||
1157 | + MemOp size = (s->cc_op - CC_OP_ADDB) & 3; | ||
1158 | TCGv t0 = gen_ext_tl(reg, cpu_cc_dst, size, true); | ||
1159 | return (CCPrepare) { .cond = TCG_COND_LT, .reg = t0, .mask = -1 }; | ||
1160 | } | ||
1161 | @@ -XXX,XX +XXX,XX @@ static CCPrepare gen_prepare_eflags_z(DisasContext *s, TCGv reg) | ||
1162 | .mask = -1 }; | ||
1163 | default: | ||
1164 | { | ||
1165 | - TCGMemOp size = (s->cc_op - CC_OP_ADDB) & 3; | ||
1166 | + MemOp size = (s->cc_op - CC_OP_ADDB) & 3; | ||
1167 | TCGv t0 = gen_ext_tl(reg, cpu_cc_dst, size, false); | ||
1168 | return (CCPrepare) { .cond = TCG_COND_EQ, .reg = t0, .mask = -1 }; | ||
1169 | } | ||
1170 | @@ -XXX,XX +XXX,XX @@ static CCPrepare gen_prepare_eflags_z(DisasContext *s, TCGv reg) | ||
1171 | static CCPrepare gen_prepare_cc(DisasContext *s, int b, TCGv reg) | ||
1172 | { | ||
1173 | int inv, jcc_op, cond; | ||
1174 | - TCGMemOp size; | ||
1175 | + MemOp size; | ||
1176 | CCPrepare cc; | ||
1177 | TCGv t0; | ||
1178 | |||
1179 | @@ -XXX,XX +XXX,XX @@ static TCGLabel *gen_jz_ecx_string(DisasContext *s, target_ulong next_eip) | ||
1180 | return l2; | ||
1181 | } | ||
1182 | |||
1183 | -static inline void gen_stos(DisasContext *s, TCGMemOp ot) | ||
1184 | +static inline void gen_stos(DisasContext *s, MemOp ot) | ||
1185 | { | ||
1186 | gen_op_mov_v_reg(s, MO_32, s->T0, R_EAX); | ||
1187 | gen_string_movl_A0_EDI(s); | ||
1188 | @@ -XXX,XX +XXX,XX @@ static inline void gen_stos(DisasContext *s, TCGMemOp ot) | ||
1189 | gen_op_add_reg_T0(s, s->aflag, R_EDI); | ||
1190 | } | ||
1191 | |||
1192 | -static inline void gen_lods(DisasContext *s, TCGMemOp ot) | ||
1193 | +static inline void gen_lods(DisasContext *s, MemOp ot) | ||
1194 | { | ||
1195 | gen_string_movl_A0_ESI(s); | ||
1196 | gen_op_ld_v(s, ot, s->T0, s->A0); | ||
1197 | @@ -XXX,XX +XXX,XX @@ static inline void gen_lods(DisasContext *s, TCGMemOp ot) | ||
1198 | gen_op_add_reg_T0(s, s->aflag, R_ESI); | ||
1199 | } | ||
1200 | |||
1201 | -static inline void gen_scas(DisasContext *s, TCGMemOp ot) | ||
1202 | +static inline void gen_scas(DisasContext *s, MemOp ot) | ||
1203 | { | ||
1204 | gen_string_movl_A0_EDI(s); | ||
1205 | gen_op_ld_v(s, ot, s->T1, s->A0); | ||
1206 | @@ -XXX,XX +XXX,XX @@ static inline void gen_scas(DisasContext *s, TCGMemOp ot) | ||
1207 | gen_op_add_reg_T0(s, s->aflag, R_EDI); | ||
1208 | } | ||
1209 | |||
1210 | -static inline void gen_cmps(DisasContext *s, TCGMemOp ot) | ||
1211 | +static inline void gen_cmps(DisasContext *s, MemOp ot) | ||
1212 | { | ||
1213 | gen_string_movl_A0_EDI(s); | ||
1214 | gen_op_ld_v(s, ot, s->T1, s->A0); | ||
1215 | @@ -XXX,XX +XXX,XX @@ static void gen_bpt_io(DisasContext *s, TCGv_i32 t_port, int ot) | ||
1216 | } | ||
1217 | |||
1218 | |||
1219 | -static inline void gen_ins(DisasContext *s, TCGMemOp ot) | ||
1220 | +static inline void gen_ins(DisasContext *s, MemOp ot) | ||
1221 | { | ||
1222 | if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
1223 | gen_io_start(); | ||
1224 | @@ -XXX,XX +XXX,XX @@ static inline void gen_ins(DisasContext *s, TCGMemOp ot) | ||
1225 | } | ||
1226 | } | ||
1227 | |||
1228 | -static inline void gen_outs(DisasContext *s, TCGMemOp ot) | ||
1229 | +static inline void gen_outs(DisasContext *s, MemOp ot) | ||
1230 | { | ||
1231 | if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
1232 | gen_io_start(); | ||
1233 | @@ -XXX,XX +XXX,XX @@ static inline void gen_outs(DisasContext *s, TCGMemOp ot) | ||
1234 | /* same method as Valgrind : we generate jumps to current or next | ||
1235 | instruction */ | ||
1236 | #define GEN_REPZ(op) \ | ||
1237 | -static inline void gen_repz_ ## op(DisasContext *s, TCGMemOp ot, \ | ||
1238 | +static inline void gen_repz_ ## op(DisasContext *s, MemOp ot, \ | ||
1239 | target_ulong cur_eip, target_ulong next_eip) \ | ||
1240 | { \ | ||
1241 | TCGLabel *l2; \ | ||
1242 | @@ -XXX,XX +XXX,XX @@ static inline void gen_repz_ ## op(DisasContext *s, TCGMemOp ot, \ | ||
1243 | } | ||
1244 | |||
1245 | #define GEN_REPZ2(op) \ | ||
1246 | -static inline void gen_repz_ ## op(DisasContext *s, TCGMemOp ot, \ | ||
1247 | +static inline void gen_repz_ ## op(DisasContext *s, MemOp ot, \ | ||
1248 | target_ulong cur_eip, \ | ||
1249 | target_ulong next_eip, \ | ||
1250 | int nz) \ | ||
1251 | @@ -XXX,XX +XXX,XX @@ static void gen_illegal_opcode(DisasContext *s) | ||
1252 | } | ||
1253 | |||
1254 | /* if d == OR_TMP0, it means memory operand (address in A0) */ | ||
1255 | -static void gen_op(DisasContext *s1, int op, TCGMemOp ot, int d) | ||
1256 | +static void gen_op(DisasContext *s1, int op, MemOp ot, int d) | ||
1257 | { | ||
1258 | if (d != OR_TMP0) { | ||
1259 | if (s1->prefix & PREFIX_LOCK) { | ||
1260 | @@ -XXX,XX +XXX,XX @@ static void gen_op(DisasContext *s1, int op, TCGMemOp ot, int d) | ||
1261 | } | ||
1262 | |||
1263 | /* if d == OR_TMP0, it means memory operand (address in A0) */ | ||
1264 | -static void gen_inc(DisasContext *s1, TCGMemOp ot, int d, int c) | ||
1265 | +static void gen_inc(DisasContext *s1, MemOp ot, int d, int c) | ||
1266 | { | ||
1267 | if (s1->prefix & PREFIX_LOCK) { | ||
1268 | if (d != OR_TMP0) { | ||
1269 | @@ -XXX,XX +XXX,XX @@ static void gen_inc(DisasContext *s1, TCGMemOp ot, int d, int c) | ||
1270 | set_cc_op(s1, (c > 0 ? CC_OP_INCB : CC_OP_DECB) + ot); | ||
1271 | } | ||
1272 | |||
1273 | -static void gen_shift_flags(DisasContext *s, TCGMemOp ot, TCGv result, | ||
1274 | +static void gen_shift_flags(DisasContext *s, MemOp ot, TCGv result, | ||
1275 | TCGv shm1, TCGv count, bool is_right) | ||
1276 | { | ||
1277 | TCGv_i32 z32, s32, oldop; | ||
1278 | @@ -XXX,XX +XXX,XX @@ static void gen_shift_flags(DisasContext *s, TCGMemOp ot, TCGv result, | ||
1279 | set_cc_op(s, CC_OP_DYNAMIC); | ||
1280 | } | ||
1281 | |||
1282 | -static void gen_shift_rm_T1(DisasContext *s, TCGMemOp ot, int op1, | ||
1283 | +static void gen_shift_rm_T1(DisasContext *s, MemOp ot, int op1, | ||
1284 | int is_right, int is_arith) | ||
1285 | { | ||
1286 | target_ulong mask = (ot == MO_64 ? 0x3f : 0x1f); | ||
1287 | @@ -XXX,XX +XXX,XX @@ static void gen_shift_rm_T1(DisasContext *s, TCGMemOp ot, int op1, | ||
1288 | gen_shift_flags(s, ot, s->T0, s->tmp0, s->T1, is_right); | ||
1289 | } | ||
1290 | |||
1291 | -static void gen_shift_rm_im(DisasContext *s, TCGMemOp ot, int op1, int op2, | ||
1292 | +static void gen_shift_rm_im(DisasContext *s, MemOp ot, int op1, int op2, | ||
1293 | int is_right, int is_arith) | ||
1294 | { | ||
1295 | int mask = (ot == MO_64 ? 0x3f : 0x1f); | ||
1296 | @@ -XXX,XX +XXX,XX @@ static void gen_shift_rm_im(DisasContext *s, TCGMemOp ot, int op1, int op2, | ||
1297 | } | ||
1298 | } | ||
1299 | |||
1300 | -static void gen_rot_rm_T1(DisasContext *s, TCGMemOp ot, int op1, int is_right) | ||
1301 | +static void gen_rot_rm_T1(DisasContext *s, MemOp ot, int op1, int is_right) | ||
1302 | { | ||
1303 | target_ulong mask = (ot == MO_64 ? 0x3f : 0x1f); | ||
1304 | TCGv_i32 t0, t1; | ||
1305 | @@ -XXX,XX +XXX,XX @@ static void gen_rot_rm_T1(DisasContext *s, TCGMemOp ot, int op1, int is_right) | ||
1306 | set_cc_op(s, CC_OP_DYNAMIC); | ||
1307 | } | ||
1308 | |||
1309 | -static void gen_rot_rm_im(DisasContext *s, TCGMemOp ot, int op1, int op2, | ||
1310 | +static void gen_rot_rm_im(DisasContext *s, MemOp ot, int op1, int op2, | ||
1311 | int is_right) | ||
1312 | { | ||
1313 | int mask = (ot == MO_64 ? 0x3f : 0x1f); | ||
1314 | @@ -XXX,XX +XXX,XX @@ static void gen_rot_rm_im(DisasContext *s, TCGMemOp ot, int op1, int op2, | ||
1315 | } | ||
1316 | |||
1317 | /* XXX: add faster immediate = 1 case */ | ||
1318 | -static void gen_rotc_rm_T1(DisasContext *s, TCGMemOp ot, int op1, | ||
1319 | +static void gen_rotc_rm_T1(DisasContext *s, MemOp ot, int op1, | ||
1320 | int is_right) | ||
1321 | { | ||
1322 | gen_compute_eflags(s); | ||
1323 | @@ -XXX,XX +XXX,XX @@ static void gen_rotc_rm_T1(DisasContext *s, TCGMemOp ot, int op1, | ||
1324 | } | ||
1325 | |||
1326 | /* XXX: add faster immediate case */ | ||
1327 | -static void gen_shiftd_rm_T1(DisasContext *s, TCGMemOp ot, int op1, | ||
1328 | +static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1, | ||
1329 | bool is_right, TCGv count_in) | ||
1330 | { | ||
1331 | target_ulong mask = (ot == MO_64 ? 63 : 31); | ||
1332 | @@ -XXX,XX +XXX,XX @@ static void gen_shiftd_rm_T1(DisasContext *s, TCGMemOp ot, int op1, | ||
1333 | tcg_temp_free(count); | ||
1334 | } | ||
1335 | |||
1336 | -static void gen_shift(DisasContext *s1, int op, TCGMemOp ot, int d, int s) | ||
1337 | +static void gen_shift(DisasContext *s1, int op, MemOp ot, int d, int s) | ||
1338 | { | ||
1339 | if (s != OR_TMP1) | ||
1340 | gen_op_mov_v_reg(s1, ot, s1->T1, s); | ||
1341 | @@ -XXX,XX +XXX,XX @@ static void gen_shift(DisasContext *s1, int op, TCGMemOp ot, int d, int s) | ||
1342 | } | ||
1343 | } | ||
1344 | |||
1345 | -static void gen_shifti(DisasContext *s1, int op, TCGMemOp ot, int d, int c) | ||
1346 | +static void gen_shifti(DisasContext *s1, int op, MemOp ot, int d, int c) | ||
1347 | { | ||
1348 | switch(op) { | ||
1349 | case OP_ROL: | ||
1350 | @@ -XXX,XX +XXX,XX @@ static void gen_add_A0_ds_seg(DisasContext *s) | ||
1351 | /* generate modrm memory load or store of 'reg'. TMP0 is used if reg == | ||
1352 | OR_TMP0 */ | ||
1353 | static void gen_ldst_modrm(CPUX86State *env, DisasContext *s, int modrm, | ||
1354 | - TCGMemOp ot, int reg, int is_store) | ||
1355 | + MemOp ot, int reg, int is_store) | ||
1356 | { | ||
1357 | int mod, rm; | ||
1358 | |||
1359 | @@ -XXX,XX +XXX,XX @@ static void gen_ldst_modrm(CPUX86State *env, DisasContext *s, int modrm, | ||
1360 | } | ||
1361 | } | ||
1362 | |||
1363 | -static inline uint32_t insn_get(CPUX86State *env, DisasContext *s, TCGMemOp ot) | ||
1364 | +static inline uint32_t insn_get(CPUX86State *env, DisasContext *s, MemOp ot) | ||
1365 | { | ||
1366 | uint32_t ret; | ||
1367 | |||
1368 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t insn_get(CPUX86State *env, DisasContext *s, TCGMemOp ot) | ||
1369 | return ret; | ||
1370 | } | ||
1371 | |||
1372 | -static inline int insn_const_size(TCGMemOp ot) | ||
1373 | +static inline int insn_const_size(MemOp ot) | ||
1374 | { | ||
1375 | if (ot <= MO_32) { | ||
1376 | return 1 << ot; | ||
1377 | @@ -XXX,XX +XXX,XX @@ static inline void gen_jcc(DisasContext *s, int b, | ||
1378 | } | ||
1379 | } | ||
1380 | |||
1381 | -static void gen_cmovcc1(CPUX86State *env, DisasContext *s, TCGMemOp ot, int b, | ||
1382 | +static void gen_cmovcc1(CPUX86State *env, DisasContext *s, MemOp ot, int b, | ||
1383 | int modrm, int reg) | ||
1384 | { | ||
1385 | CCPrepare cc; | ||
1386 | @@ -XXX,XX +XXX,XX @@ static inline void gen_stack_update(DisasContext *s, int addend) | ||
1387 | /* Generate a push. It depends on ss32, addseg and dflag. */ | ||
1388 | static void gen_push_v(DisasContext *s, TCGv val) | ||
1389 | { | ||
1390 | - TCGMemOp d_ot = mo_pushpop(s, s->dflag); | ||
1391 | - TCGMemOp a_ot = mo_stacksize(s); | ||
1392 | + MemOp d_ot = mo_pushpop(s, s->dflag); | ||
1393 | + MemOp a_ot = mo_stacksize(s); | ||
1394 | int size = 1 << d_ot; | ||
1395 | TCGv new_esp = s->A0; | ||
1396 | |||
1397 | @@ -XXX,XX +XXX,XX @@ static void gen_push_v(DisasContext *s, TCGv val) | ||
1398 | } | ||
1399 | |||
1400 | /* two step pop is necessary for precise exceptions */ | ||
1401 | -static TCGMemOp gen_pop_T0(DisasContext *s) | ||
1402 | +static MemOp gen_pop_T0(DisasContext *s) | ||
1403 | { | ||
1404 | - TCGMemOp d_ot = mo_pushpop(s, s->dflag); | ||
1405 | + MemOp d_ot = mo_pushpop(s, s->dflag); | ||
1406 | |||
1407 | gen_lea_v_seg(s, mo_stacksize(s), cpu_regs[R_ESP], R_SS, -1); | ||
1408 | gen_op_ld_v(s, d_ot, s->T0, s->A0); | ||
1409 | @@ -XXX,XX +XXX,XX @@ static TCGMemOp gen_pop_T0(DisasContext *s) | ||
1410 | return d_ot; | ||
1411 | } | ||
1412 | |||
1413 | -static inline void gen_pop_update(DisasContext *s, TCGMemOp ot) | ||
1414 | +static inline void gen_pop_update(DisasContext *s, MemOp ot) | ||
1415 | { | ||
1416 | gen_stack_update(s, 1 << ot); | ||
1417 | } | ||
1418 | @@ -XXX,XX +XXX,XX @@ static inline void gen_stack_A0(DisasContext *s) | ||
1419 | |||
1420 | static void gen_pusha(DisasContext *s) | ||
1421 | { | ||
1422 | - TCGMemOp s_ot = s->ss32 ? MO_32 : MO_16; | ||
1423 | - TCGMemOp d_ot = s->dflag; | ||
1424 | + MemOp s_ot = s->ss32 ? MO_32 : MO_16; | ||
1425 | + MemOp d_ot = s->dflag; | ||
1426 | int size = 1 << d_ot; | ||
1427 | int i; | ||
1428 | |||
1429 | @@ -XXX,XX +XXX,XX @@ static void gen_pusha(DisasContext *s) | ||
1430 | |||
1431 | static void gen_popa(DisasContext *s) | ||
1432 | { | ||
1433 | - TCGMemOp s_ot = s->ss32 ? MO_32 : MO_16; | ||
1434 | - TCGMemOp d_ot = s->dflag; | ||
1435 | + MemOp s_ot = s->ss32 ? MO_32 : MO_16; | ||
1436 | + MemOp d_ot = s->dflag; | ||
1437 | int size = 1 << d_ot; | ||
1438 | int i; | ||
1439 | |||
1440 | @@ -XXX,XX +XXX,XX @@ static void gen_popa(DisasContext *s) | ||
1441 | |||
1442 | static void gen_enter(DisasContext *s, int esp_addend, int level) | ||
1443 | { | ||
1444 | - TCGMemOp d_ot = mo_pushpop(s, s->dflag); | ||
1445 | - TCGMemOp a_ot = CODE64(s) ? MO_64 : s->ss32 ? MO_32 : MO_16; | ||
1446 | + MemOp d_ot = mo_pushpop(s, s->dflag); | ||
1447 | + MemOp a_ot = CODE64(s) ? MO_64 : s->ss32 ? MO_32 : MO_16; | ||
1448 | int size = 1 << d_ot; | ||
1449 | |||
1450 | /* Push BP; compute FrameTemp into T1. */ | ||
1451 | @@ -XXX,XX +XXX,XX @@ static void gen_enter(DisasContext *s, int esp_addend, int level) | ||
1452 | |||
1453 | static void gen_leave(DisasContext *s) | ||
1454 | { | ||
1455 | - TCGMemOp d_ot = mo_pushpop(s, s->dflag); | ||
1456 | - TCGMemOp a_ot = mo_stacksize(s); | ||
1457 | + MemOp d_ot = mo_pushpop(s, s->dflag); | ||
1458 | + MemOp a_ot = mo_stacksize(s); | ||
1459 | |||
1460 | gen_lea_v_seg(s, a_ot, cpu_regs[R_EBP], R_SS, -1); | ||
1461 | gen_op_ld_v(s, d_ot, s->T0, s->A0); | ||
1462 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, | ||
1463 | SSEFunc_0_eppi sse_fn_eppi; | ||
1464 | SSEFunc_0_ppi sse_fn_ppi; | ||
1465 | SSEFunc_0_eppt sse_fn_eppt; | ||
1466 | - TCGMemOp ot; | ||
1467 | + MemOp ot; | ||
1468 | |||
1469 | b &= 0xff; | ||
1470 | if (s->prefix & PREFIX_DATA) | ||
1471 | @@ -XXX,XX +XXX,XX @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) | ||
1472 | CPUX86State *env = cpu->env_ptr; | ||
1473 | int b, prefixes; | ||
1474 | int shift; | ||
1475 | - TCGMemOp ot, aflag, dflag; | ||
1476 | + MemOp ot, aflag, dflag; | ||
1477 | int modrm, reg, rm, mod, op, opreg, val; | ||
1478 | target_ulong next_eip, tval; | ||
1479 | int rex_w, rex_r; | ||
1480 | @@ -XXX,XX +XXX,XX @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) | ||
1481 | case 0x1be: /* movsbS Gv, Eb */ | ||
1482 | case 0x1bf: /* movswS Gv, Eb */ | ||
1483 | { | ||
1484 | - TCGMemOp d_ot; | ||
1485 | - TCGMemOp s_ot; | ||
1486 | + MemOp d_ot; | ||
1487 | + MemOp s_ot; | ||
1488 | |||
1489 | /* d_ot is the size of destination */ | ||
1490 | d_ot = dflag; | ||
1491 | diff --git a/target/m68k/translate.c b/target/m68k/translate.c | ||
1492 | index XXXXXXX..XXXXXXX 100644 | ||
1493 | --- a/target/m68k/translate.c | ||
1494 | +++ b/target/m68k/translate.c | ||
1495 | @@ -XXX,XX +XXX,XX @@ DISAS_INSN(cas) | ||
1496 | uint16_t ext; | ||
1497 | TCGv load; | ||
1498 | TCGv cmp; | ||
1499 | - TCGMemOp opc; | ||
1500 | + MemOp opc; | ||
1501 | |||
1502 | switch ((insn >> 9) & 3) { | ||
1503 | case 1: | ||
1504 | diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c | ||
1505 | index XXXXXXX..XXXXXXX 100644 | ||
1506 | --- a/target/microblaze/translate.c | ||
1507 | +++ b/target/microblaze/translate.c | ||
1508 | @@ -XXX,XX +XXX,XX @@ static void dec_load(DisasContext *dc) | ||
1509 | unsigned int size; | ||
1510 | bool rev = false, ex = false, ea = false; | ||
1511 | int mem_index = cpu_mmu_index(&dc->cpu->env, false); | ||
1512 | - TCGMemOp mop; | ||
1513 | + MemOp mop; | ||
1514 | |||
1515 | mop = dc->opcode & 3; | ||
1516 | size = 1 << mop; | ||
1517 | @@ -XXX,XX +XXX,XX @@ static void dec_store(DisasContext *dc) | ||
1518 | unsigned int size; | ||
1519 | bool rev = false, ex = false, ea = false; | ||
1520 | int mem_index = cpu_mmu_index(&dc->cpu->env, false); | ||
1521 | - TCGMemOp mop; | ||
1522 | + MemOp mop; | ||
1523 | |||
1524 | mop = dc->opcode & 3; | ||
1525 | size = 1 << mop; | ||
1526 | diff --git a/target/mips/translate.c b/target/mips/translate.c | ||
1527 | index XXXXXXX..XXXXXXX 100644 | ||
1528 | --- a/target/mips/translate.c | ||
1529 | +++ b/target/mips/translate.c | ||
1530 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
1531 | int32_t CP0_Config5; | ||
1532 | /* Routine used to access memory */ | ||
1533 | int mem_idx; | ||
1534 | - TCGMemOp default_tcg_memop_mask; | ||
1535 | + MemOp default_tcg_memop_mask; | ||
1536 | uint32_t hflags, saved_hflags; | ||
1537 | target_ulong btarget; | ||
1538 | bool ulri; | ||
1539 | @@ -XXX,XX +XXX,XX @@ static void gen_st(DisasContext *ctx, uint32_t opc, int rt, | ||
1540 | |||
1541 | /* Store conditional */ | ||
1542 | static void gen_st_cond(DisasContext *ctx, int rt, int base, int offset, | ||
1543 | - TCGMemOp tcg_mo, bool eva) | ||
1544 | + MemOp tcg_mo, bool eva) | ||
1545 | { | ||
1546 | TCGv addr, t0, val; | ||
1547 | TCGLabel *l1 = gen_new_label(); | ||
1548 | @@ -XXX,XX +XXX,XX @@ static void gen_HILO(DisasContext *ctx, uint32_t opc, int acc, int reg) | ||
1549 | } | ||
1550 | |||
1551 | static inline void gen_r6_ld(target_long addr, int reg, int memidx, | ||
1552 | - TCGMemOp memop) | ||
1553 | + MemOp memop) | ||
1554 | { | ||
1555 | TCGv t0 = tcg_const_tl(addr); | ||
1556 | tcg_gen_qemu_ld_tl(t0, t0, memidx, memop); | ||
1557 | @@ -XXX,XX +XXX,XX @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) | ||
1558 | extract32(ctx->opcode, 0, 8); | ||
1559 | TCGv va = tcg_temp_new(); | ||
1560 | TCGv t1 = tcg_temp_new(); | ||
1561 | - TCGMemOp memop = (extract32(ctx->opcode, 8, 3)) == | ||
1562 | + MemOp memop = (extract32(ctx->opcode, 8, 3)) == | ||
1563 | NM_P_LS_UAWM ? MO_UNALN : 0; | ||
1564 | |||
1565 | count = (count == 0) ? 8 : count; | ||
1566 | diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c | ||
1567 | index XXXXXXX..XXXXXXX 100644 | ||
1568 | --- a/target/openrisc/translate.c | ||
1569 | +++ b/target/openrisc/translate.c | ||
1570 | @@ -XXX,XX +XXX,XX @@ static bool trans_l_lwa(DisasContext *dc, arg_load *a) | ||
1571 | return true; | ||
1572 | } | ||
1573 | |||
1574 | -static void do_load(DisasContext *dc, arg_load *a, TCGMemOp mop) | ||
1575 | +static void do_load(DisasContext *dc, arg_load *a, MemOp mop) | ||
1576 | { | ||
1577 | TCGv ea; | ||
1578 | |||
1579 | @@ -XXX,XX +XXX,XX @@ static bool trans_l_swa(DisasContext *dc, arg_store *a) | ||
1580 | return true; | ||
1581 | } | ||
1582 | |||
1583 | -static void do_store(DisasContext *dc, arg_store *a, TCGMemOp mop) | ||
1584 | +static void do_store(DisasContext *dc, arg_store *a, MemOp mop) | ||
1585 | { | ||
1586 | TCGv t0 = tcg_temp_new(); | ||
1587 | tcg_gen_addi_tl(t0, cpu_R[a->a], a->i); | ||
1588 | diff --git a/target/ppc/translate.c b/target/ppc/translate.c | ||
1589 | index XXXXXXX..XXXXXXX 100644 | ||
1590 | --- a/target/ppc/translate.c | ||
1591 | +++ b/target/ppc/translate.c | ||
1592 | @@ -XXX,XX +XXX,XX @@ struct DisasContext { | ||
1593 | int mem_idx; | ||
1594 | int access_type; | ||
1595 | /* Translation flags */ | ||
1596 | - TCGMemOp default_tcg_memop_mask; | ||
1597 | + MemOp default_tcg_memop_mask; | ||
1598 | #if defined(TARGET_PPC64) | ||
1599 | bool sf_mode; | ||
1600 | bool has_cfar; | ||
1601 | @@ -XXX,XX +XXX,XX @@ static void gen_isync(DisasContext *ctx) | ||
1602 | |||
1603 | #define MEMOP_GET_SIZE(x) (1 << ((x) & MO_SIZE)) | ||
1604 | |||
1605 | -static void gen_load_locked(DisasContext *ctx, TCGMemOp memop) | ||
1606 | +static void gen_load_locked(DisasContext *ctx, MemOp memop) | ||
1607 | { | ||
1608 | TCGv gpr = cpu_gpr[rD(ctx->opcode)]; | ||
1609 | TCGv t0 = tcg_temp_new(); | ||
1610 | @@ -XXX,XX +XXX,XX @@ LARX(lbarx, DEF_MEMOP(MO_UB)) | ||
1611 | LARX(lharx, DEF_MEMOP(MO_UW)) | ||
1612 | LARX(lwarx, DEF_MEMOP(MO_UL)) | ||
1613 | |||
1614 | -static void gen_fetch_inc_conditional(DisasContext *ctx, TCGMemOp memop, | ||
1615 | +static void gen_fetch_inc_conditional(DisasContext *ctx, MemOp memop, | ||
1616 | TCGv EA, TCGCond cond, int addend) | ||
1617 | { | ||
1618 | TCGv t = tcg_temp_new(); | ||
1619 | @@ -XXX,XX +XXX,XX @@ static void gen_fetch_inc_conditional(DisasContext *ctx, TCGMemOp memop, | ||
1620 | tcg_temp_free(u); | ||
1621 | } | ||
1622 | |||
1623 | -static void gen_ld_atomic(DisasContext *ctx, TCGMemOp memop) | ||
1624 | +static void gen_ld_atomic(DisasContext *ctx, MemOp memop) | ||
1625 | { | ||
1626 | uint32_t gpr_FC = FC(ctx->opcode); | ||
1627 | TCGv EA = tcg_temp_new(); | ||
1628 | @@ -XXX,XX +XXX,XX @@ static void gen_ldat(DisasContext *ctx) | ||
1629 | } | ||
1630 | #endif | ||
1631 | |||
1632 | -static void gen_st_atomic(DisasContext *ctx, TCGMemOp memop) | ||
1633 | +static void gen_st_atomic(DisasContext *ctx, MemOp memop) | ||
1634 | { | ||
1635 | uint32_t gpr_FC = FC(ctx->opcode); | ||
1636 | TCGv EA = tcg_temp_new(); | ||
1637 | @@ -XXX,XX +XXX,XX @@ static void gen_stdat(DisasContext *ctx) | ||
1638 | } | ||
1639 | #endif | ||
1640 | |||
1641 | -static void gen_conditional_store(DisasContext *ctx, TCGMemOp memop) | ||
1642 | +static void gen_conditional_store(DisasContext *ctx, MemOp memop) | ||
1643 | { | ||
1644 | TCGLabel *l1 = gen_new_label(); | ||
1645 | TCGLabel *l2 = gen_new_label(); | ||
1646 | diff --git a/target/riscv/insn_trans/trans_rva.inc.c b/target/riscv/insn_trans/trans_rva.inc.c | ||
1647 | index XXXXXXX..XXXXXXX 100644 | ||
1648 | --- a/target/riscv/insn_trans/trans_rva.inc.c | ||
1649 | +++ b/target/riscv/insn_trans/trans_rva.inc.c | ||
1650 | @@ -XXX,XX +XXX,XX @@ | ||
1651 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
1652 | */ | ||
1653 | |||
1654 | -static inline bool gen_lr(DisasContext *ctx, arg_atomic *a, TCGMemOp mop) | ||
1655 | +static inline bool gen_lr(DisasContext *ctx, arg_atomic *a, MemOp mop) | ||
1656 | { | ||
1657 | TCGv src1 = tcg_temp_new(); | ||
1658 | /* Put addr in load_res, data in load_val. */ | ||
1659 | @@ -XXX,XX +XXX,XX @@ static inline bool gen_lr(DisasContext *ctx, arg_atomic *a, TCGMemOp mop) | ||
1660 | return true; | ||
1661 | } | ||
1662 | |||
1663 | -static inline bool gen_sc(DisasContext *ctx, arg_atomic *a, TCGMemOp mop) | ||
1664 | +static inline bool gen_sc(DisasContext *ctx, arg_atomic *a, MemOp mop) | ||
1665 | { | ||
1666 | TCGv src1 = tcg_temp_new(); | ||
1667 | TCGv src2 = tcg_temp_new(); | ||
1668 | @@ -XXX,XX +XXX,XX @@ static inline bool gen_sc(DisasContext *ctx, arg_atomic *a, TCGMemOp mop) | ||
1669 | } | ||
1670 | |||
1671 | static bool gen_amo(DisasContext *ctx, arg_atomic *a, | ||
1672 | - void(*func)(TCGv, TCGv, TCGv, TCGArg, TCGMemOp), | ||
1673 | - TCGMemOp mop) | ||
1674 | + void(*func)(TCGv, TCGv, TCGv, TCGArg, MemOp), | ||
1675 | + MemOp mop) | ||
1676 | { | ||
1677 | TCGv src1 = tcg_temp_new(); | ||
1678 | TCGv src2 = tcg_temp_new(); | ||
1679 | diff --git a/target/riscv/insn_trans/trans_rvi.inc.c b/target/riscv/insn_trans/trans_rvi.inc.c | ||
1680 | index XXXXXXX..XXXXXXX 100644 | ||
1681 | --- a/target/riscv/insn_trans/trans_rvi.inc.c | ||
1682 | +++ b/target/riscv/insn_trans/trans_rvi.inc.c | ||
1683 | @@ -XXX,XX +XXX,XX @@ static bool trans_bgeu(DisasContext *ctx, arg_bgeu *a) | ||
1684 | return gen_branch(ctx, a, TCG_COND_GEU); | ||
1685 | } | ||
1686 | |||
1687 | -static bool gen_load(DisasContext *ctx, arg_lb *a, TCGMemOp memop) | ||
1688 | +static bool gen_load(DisasContext *ctx, arg_lb *a, MemOp memop) | ||
1689 | { | ||
1690 | TCGv t0 = tcg_temp_new(); | ||
1691 | TCGv t1 = tcg_temp_new(); | ||
1692 | @@ -XXX,XX +XXX,XX @@ static bool trans_lhu(DisasContext *ctx, arg_lhu *a) | ||
1693 | return gen_load(ctx, a, MO_TEUW); | ||
1694 | } | ||
1695 | |||
1696 | -static bool gen_store(DisasContext *ctx, arg_sb *a, TCGMemOp memop) | ||
1697 | +static bool gen_store(DisasContext *ctx, arg_sb *a, MemOp memop) | ||
1698 | { | ||
1699 | TCGv t0 = tcg_temp_new(); | ||
1700 | TCGv dat = tcg_temp_new(); | ||
1701 | diff --git a/target/s390x/translate.c b/target/s390x/translate.c | ||
1702 | index XXXXXXX..XXXXXXX 100644 | ||
1703 | --- a/target/s390x/translate.c | ||
1704 | +++ b/target/s390x/translate.c | ||
1705 | @@ -XXX,XX +XXX,XX @@ static inline int vec_full_reg_offset(uint8_t reg) | ||
1706 | return offsetof(CPUS390XState, vregs[reg][0]); | ||
1707 | } | ||
1708 | |||
1709 | -static inline int vec_reg_offset(uint8_t reg, uint8_t enr, TCGMemOp es) | ||
1710 | +static inline int vec_reg_offset(uint8_t reg, uint8_t enr, MemOp es) | ||
1711 | { | ||
1712 | /* Convert element size (es) - e.g. MO_8 - to bytes */ | ||
1713 | const uint8_t bytes = 1 << es; | ||
1714 | @@ -XXX,XX +XXX,XX @@ static DisasJumpType op_csst(DisasContext *s, DisasOps *o) | ||
1715 | #ifndef CONFIG_USER_ONLY | ||
1716 | static DisasJumpType op_csp(DisasContext *s, DisasOps *o) | ||
1717 | { | ||
1718 | - TCGMemOp mop = s->insn->data; | ||
1719 | + MemOp mop = s->insn->data; | ||
1720 | TCGv_i64 addr, old, cc; | ||
1721 | TCGLabel *lab = gen_new_label(); | ||
1722 | |||
1723 | @@ -XXX,XX +XXX,XX @@ static DisasJumpType op_lm64(DisasContext *s, DisasOps *o) | ||
1724 | static DisasJumpType op_lpd(DisasContext *s, DisasOps *o) | ||
1725 | { | ||
1726 | TCGv_i64 a1, a2; | ||
1727 | - TCGMemOp mop = s->insn->data; | ||
1728 | + MemOp mop = s->insn->data; | ||
1729 | |||
1730 | /* In a parallel context, stop the world and single step. */ | ||
1731 | if (tb_cflags(s->base.tb) & CF_PARALLEL) { | ||
1732 | diff --git a/target/s390x/translate_vx.inc.c b/target/s390x/translate_vx.inc.c | ||
1733 | index XXXXXXX..XXXXXXX 100644 | ||
1734 | --- a/target/s390x/translate_vx.inc.c | ||
1735 | +++ b/target/s390x/translate_vx.inc.c | ||
1736 | @@ -XXX,XX +XXX,XX @@ | ||
1737 | #define FPF_LONG 3 | ||
1738 | #define FPF_EXT 4 | ||
1739 | |||
1740 | -static inline bool valid_vec_element(uint8_t enr, TCGMemOp es) | ||
1741 | +static inline bool valid_vec_element(uint8_t enr, MemOp es) | ||
1742 | { | ||
1743 | return !(enr & ~(NUM_VEC_ELEMENTS(es) - 1)); | ||
1744 | } | ||
1745 | |||
1746 | static void read_vec_element_i64(TCGv_i64 dst, uint8_t reg, uint8_t enr, | ||
1747 | - TCGMemOp memop) | ||
1748 | + MemOp memop) | ||
1749 | { | ||
1750 | const int offs = vec_reg_offset(reg, enr, memop & MO_SIZE); | ||
1751 | |||
1752 | @@ -XXX,XX +XXX,XX @@ static void read_vec_element_i64(TCGv_i64 dst, uint8_t reg, uint8_t enr, | ||
1753 | } | ||
1754 | |||
1755 | static void read_vec_element_i32(TCGv_i32 dst, uint8_t reg, uint8_t enr, | ||
1756 | - TCGMemOp memop) | ||
1757 | + MemOp memop) | ||
1758 | { | ||
1759 | const int offs = vec_reg_offset(reg, enr, memop & MO_SIZE); | ||
1760 | |||
1761 | @@ -XXX,XX +XXX,XX @@ static void read_vec_element_i32(TCGv_i32 dst, uint8_t reg, uint8_t enr, | ||
1762 | } | ||
1763 | |||
1764 | static void write_vec_element_i64(TCGv_i64 src, int reg, uint8_t enr, | ||
1765 | - TCGMemOp memop) | ||
1766 | + MemOp memop) | ||
1767 | { | ||
1768 | const int offs = vec_reg_offset(reg, enr, memop & MO_SIZE); | ||
1769 | |||
1770 | @@ -XXX,XX +XXX,XX @@ static void write_vec_element_i64(TCGv_i64 src, int reg, uint8_t enr, | ||
1771 | } | ||
1772 | |||
1773 | static void write_vec_element_i32(TCGv_i32 src, int reg, uint8_t enr, | ||
1774 | - TCGMemOp memop) | ||
1775 | + MemOp memop) | ||
1776 | { | ||
1777 | const int offs = vec_reg_offset(reg, enr, memop & MO_SIZE); | ||
1778 | |||
1779 | diff --git a/target/sparc/translate.c b/target/sparc/translate.c | ||
1780 | index XXXXXXX..XXXXXXX 100644 | ||
1781 | --- a/target/sparc/translate.c | ||
1782 | +++ b/target/sparc/translate.c | ||
1783 | @@ -XXX,XX +XXX,XX @@ static inline void gen_ne_fop_QD(DisasContext *dc, int rd, int rs, | ||
1784 | } | ||
1785 | |||
1786 | static void gen_swap(DisasContext *dc, TCGv dst, TCGv src, | ||
1787 | - TCGv addr, int mmu_idx, TCGMemOp memop) | ||
1788 | + TCGv addr, int mmu_idx, MemOp memop) | ||
1789 | { | ||
1790 | gen_address_mask(dc, addr); | ||
1791 | tcg_gen_atomic_xchg_tl(dst, addr, src, mmu_idx, memop); | ||
1792 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
1793 | ASIType type; | ||
1794 | int asi; | ||
1795 | int mem_idx; | ||
1796 | - TCGMemOp memop; | ||
1797 | + MemOp memop; | ||
1798 | } DisasASI; | ||
1799 | |||
1800 | -static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop) | ||
1801 | +static DisasASI get_asi(DisasContext *dc, int insn, MemOp memop) | ||
1802 | { | ||
1803 | int asi = GET_FIELD(insn, 19, 26); | ||
1804 | ASIType type = GET_ASI_HELPER; | ||
1805 | @@ -XXX,XX +XXX,XX @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop) | ||
1806 | } | ||
1807 | |||
1808 | static void gen_ld_asi(DisasContext *dc, TCGv dst, TCGv addr, | ||
1809 | - int insn, TCGMemOp memop) | ||
1810 | + int insn, MemOp memop) | ||
1811 | { | ||
1812 | DisasASI da = get_asi(dc, insn, memop); | ||
1813 | |||
1814 | @@ -XXX,XX +XXX,XX @@ static void gen_ld_asi(DisasContext *dc, TCGv dst, TCGv addr, | ||
1815 | } | ||
1816 | |||
1817 | static void gen_st_asi(DisasContext *dc, TCGv src, TCGv addr, | ||
1818 | - int insn, TCGMemOp memop) | ||
1819 | + int insn, MemOp memop) | ||
1820 | { | ||
1821 | DisasASI da = get_asi(dc, insn, memop); | ||
1822 | |||
1823 | @@ -XXX,XX +XXX,XX @@ static void gen_ldf_asi(DisasContext *dc, TCGv addr, | ||
1824 | case GET_ASI_BLOCK: | ||
1825 | /* Valid for lddfa on aligned registers only. */ | ||
1826 | if (size == 8 && (rd & 7) == 0) { | ||
1827 | - TCGMemOp memop; | ||
1828 | + MemOp memop; | ||
1829 | TCGv eight; | ||
1830 | int i; | ||
1831 | |||
1832 | @@ -XXX,XX +XXX,XX @@ static void gen_stf_asi(DisasContext *dc, TCGv addr, | ||
1833 | case GET_ASI_BLOCK: | ||
1834 | /* Valid for stdfa on aligned registers only. */ | ||
1835 | if (size == 8 && (rd & 7) == 0) { | ||
1836 | - TCGMemOp memop; | ||
1837 | + MemOp memop; | ||
1838 | TCGv eight; | ||
1839 | int i; | ||
1840 | |||
1841 | diff --git a/target/tilegx/translate.c b/target/tilegx/translate.c | ||
1842 | index XXXXXXX..XXXXXXX 100644 | ||
1843 | --- a/target/tilegx/translate.c | ||
1844 | +++ b/target/tilegx/translate.c | ||
1845 | @@ -XXX,XX +XXX,XX @@ static void gen_cmul2(TCGv tdest, TCGv tsrca, TCGv tsrcb, int sh, int rd) | ||
1846 | } | ||
1847 | |||
1848 | static TileExcp gen_st_opcode(DisasContext *dc, unsigned dest, unsigned srca, | ||
1849 | - unsigned srcb, TCGMemOp memop, const char *name) | ||
1850 | + unsigned srcb, MemOp memop, const char *name) | ||
1851 | { | ||
1852 | if (dest) { | ||
1853 | return TILEGX_EXCP_OPCODE_UNKNOWN; | ||
1854 | @@ -XXX,XX +XXX,XX @@ static TileExcp gen_st_opcode(DisasContext *dc, unsigned dest, unsigned srca, | ||
1855 | } | ||
1856 | |||
1857 | static TileExcp gen_st_add_opcode(DisasContext *dc, unsigned srca, unsigned srcb, | ||
1858 | - int imm, TCGMemOp memop, const char *name) | ||
1859 | + int imm, MemOp memop, const char *name) | ||
1860 | { | ||
1861 | TCGv tsrca = load_gr(dc, srca); | ||
1862 | TCGv tsrcb = load_gr(dc, srcb); | ||
1863 | @@ -XXX,XX +XXX,XX @@ static TileExcp gen_rr_opcode(DisasContext *dc, unsigned opext, | ||
1864 | { | ||
1865 | TCGv tdest, tsrca; | ||
1866 | const char *mnemonic; | ||
1867 | - TCGMemOp memop; | ||
1868 | + MemOp memop; | ||
1869 | TileExcp ret = TILEGX_EXCP_NONE; | ||
1870 | bool prefetch_nofault = false; | ||
1871 | |||
1872 | @@ -XXX,XX +XXX,XX @@ static TileExcp gen_rri_opcode(DisasContext *dc, unsigned opext, | ||
1873 | TCGv tsrca = load_gr(dc, srca); | ||
1874 | bool prefetch_nofault = false; | ||
1875 | const char *mnemonic; | ||
1876 | - TCGMemOp memop; | ||
1877 | + MemOp memop; | ||
1878 | int i2, i3; | ||
1879 | TCGv t0; | ||
1880 | |||
1881 | @@ -XXX,XX +XXX,XX @@ static TileExcp decode_y2(DisasContext *dc, tilegx_bundle_bits bundle) | ||
1882 | unsigned srca = get_SrcA_Y2(bundle); | ||
1883 | unsigned srcbdest = get_SrcBDest_Y2(bundle); | ||
1884 | const char *mnemonic; | ||
1885 | - TCGMemOp memop; | ||
1886 | + MemOp memop; | ||
1887 | bool prefetch_nofault = false; | ||
1888 | |||
1889 | switch (OEY2(opc, mode)) { | ||
1890 | diff --git a/target/tricore/translate.c b/target/tricore/translate.c | ||
1891 | index XXXXXXX..XXXXXXX 100644 | ||
1892 | --- a/target/tricore/translate.c | ||
1893 | +++ b/target/tricore/translate.c | ||
1894 | @@ -XXX,XX +XXX,XX @@ static inline void generate_trap(DisasContext *ctx, int class, int tin); | ||
1895 | /* Functions for load/save to/from memory */ | ||
1896 | |||
1897 | static inline void gen_offset_ld(DisasContext *ctx, TCGv r1, TCGv r2, | ||
1898 | - int16_t con, TCGMemOp mop) | ||
1899 | + int16_t con, MemOp mop) | ||
1900 | { | ||
1901 | TCGv temp = tcg_temp_new(); | ||
1902 | tcg_gen_addi_tl(temp, r2, con); | ||
1903 | @@ -XXX,XX +XXX,XX @@ static inline void gen_offset_ld(DisasContext *ctx, TCGv r1, TCGv r2, | ||
1904 | } | ||
1905 | |||
1906 | static inline void gen_offset_st(DisasContext *ctx, TCGv r1, TCGv r2, | ||
1907 | - int16_t con, TCGMemOp mop) | ||
1908 | + int16_t con, MemOp mop) | ||
1909 | { | ||
1910 | TCGv temp = tcg_temp_new(); | ||
1911 | tcg_gen_addi_tl(temp, r2, con); | ||
1912 | @@ -XXX,XX +XXX,XX @@ static void gen_offset_ld_2regs(TCGv rh, TCGv rl, TCGv base, int16_t con, | ||
1913 | } | ||
1914 | |||
1915 | static void gen_st_preincr(DisasContext *ctx, TCGv r1, TCGv r2, int16_t off, | ||
1916 | - TCGMemOp mop) | ||
1917 | + MemOp mop) | ||
1918 | { | ||
1919 | TCGv temp = tcg_temp_new(); | ||
1920 | tcg_gen_addi_tl(temp, r2, off); | ||
1921 | @@ -XXX,XX +XXX,XX @@ static void gen_st_preincr(DisasContext *ctx, TCGv r1, TCGv r2, int16_t off, | ||
1922 | } | ||
1923 | |||
1924 | static void gen_ld_preincr(DisasContext *ctx, TCGv r1, TCGv r2, int16_t off, | ||
1925 | - TCGMemOp mop) | ||
1926 | + MemOp mop) | ||
1927 | { | ||
1928 | TCGv temp = tcg_temp_new(); | ||
1929 | tcg_gen_addi_tl(temp, r2, off); | ||
1930 | diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c | ||
1931 | index XXXXXXX..XXXXXXX 100644 | ||
1932 | --- a/tcg/aarch64/tcg-target.inc.c | ||
1933 | +++ b/tcg/aarch64/tcg-target.inc.c | ||
1934 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_rev16(TCGContext *s, TCGReg rd, TCGReg rn) | ||
1935 | tcg_out_insn(s, 3507, REV16, TCG_TYPE_I32, rd, rn); | ||
1936 | } | ||
1937 | |||
1938 | -static inline void tcg_out_sxt(TCGContext *s, TCGType ext, TCGMemOp s_bits, | ||
1939 | +static inline void tcg_out_sxt(TCGContext *s, TCGType ext, MemOp s_bits, | ||
1940 | TCGReg rd, TCGReg rn) | ||
1941 | { | ||
1942 | /* Using ALIASes SXTB, SXTH, SXTW, of SBFM Xd, Xn, #0, #7|15|31 */ | ||
1943 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_sxt(TCGContext *s, TCGType ext, TCGMemOp s_bits, | ||
1944 | tcg_out_sbfm(s, ext, rd, rn, 0, bits); | ||
1945 | } | ||
1946 | |||
1947 | -static inline void tcg_out_uxt(TCGContext *s, TCGMemOp s_bits, | ||
1948 | +static inline void tcg_out_uxt(TCGContext *s, MemOp s_bits, | ||
1949 | TCGReg rd, TCGReg rn) | ||
1950 | { | ||
1951 | /* Using ALIASes UXTB, UXTH of UBFM Wd, Wn, #0, #7|15 */ | ||
1952 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_adr(TCGContext *s, TCGReg rd, void *target) | ||
1953 | static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
1954 | { | ||
1955 | TCGMemOpIdx oi = lb->oi; | ||
1956 | - TCGMemOp opc = get_memop(oi); | ||
1957 | - TCGMemOp size = opc & MO_SIZE; | ||
1958 | + MemOp opc = get_memop(oi); | ||
1959 | + MemOp size = opc & MO_SIZE; | ||
1960 | |||
1961 | if (!reloc_pc19(lb->label_ptr[0], s->code_ptr)) { | ||
1962 | return false; | ||
1963 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
1964 | static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
1965 | { | ||
1966 | TCGMemOpIdx oi = lb->oi; | ||
1967 | - TCGMemOp opc = get_memop(oi); | ||
1968 | - TCGMemOp size = opc & MO_SIZE; | ||
1969 | + MemOp opc = get_memop(oi); | ||
1970 | + MemOp size = opc & MO_SIZE; | ||
1971 | |||
1972 | if (!reloc_pc19(lb->label_ptr[0], s->code_ptr)) { | ||
1973 | return false; | ||
1974 | @@ -XXX,XX +XXX,XX @@ QEMU_BUILD_BUG_ON(offsetof(CPUTLBDescFast, table) != 8); | ||
1975 | slow path for the failure case, which will be patched later when finalizing | ||
1976 | the slow path. Generated code returns the host addend in X1, | ||
1977 | clobbers X0,X2,X3,TMP. */ | ||
1978 | -static void tcg_out_tlb_read(TCGContext *s, TCGReg addr_reg, TCGMemOp opc, | ||
1979 | +static void tcg_out_tlb_read(TCGContext *s, TCGReg addr_reg, MemOp opc, | ||
1980 | tcg_insn_unit **label_ptr, int mem_index, | ||
1981 | bool is_read) | ||
1982 | { | ||
1983 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_tlb_read(TCGContext *s, TCGReg addr_reg, TCGMemOp opc, | ||
1984 | |||
1985 | #endif /* CONFIG_SOFTMMU */ | ||
1986 | |||
1987 | -static void tcg_out_qemu_ld_direct(TCGContext *s, TCGMemOp memop, TCGType ext, | ||
1988 | +static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp memop, TCGType ext, | ||
1989 | TCGReg data_r, TCGReg addr_r, | ||
1990 | TCGType otype, TCGReg off_r) | ||
1991 | { | ||
1992 | - const TCGMemOp bswap = memop & MO_BSWAP; | ||
1993 | + const MemOp bswap = memop & MO_BSWAP; | ||
1994 | |||
1995 | switch (memop & MO_SSIZE) { | ||
1996 | case MO_UB: | ||
1997 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGMemOp memop, TCGType ext, | ||
1998 | } | ||
1999 | } | ||
2000 | |||
2001 | -static void tcg_out_qemu_st_direct(TCGContext *s, TCGMemOp memop, | ||
2002 | +static void tcg_out_qemu_st_direct(TCGContext *s, MemOp memop, | ||
2003 | TCGReg data_r, TCGReg addr_r, | ||
2004 | TCGType otype, TCGReg off_r) | ||
2005 | { | ||
2006 | - const TCGMemOp bswap = memop & MO_BSWAP; | ||
2007 | + const MemOp bswap = memop & MO_BSWAP; | ||
2008 | |||
2009 | switch (memop & MO_SIZE) { | ||
2010 | case MO_8: | ||
2011 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGMemOp memop, | ||
2012 | static void tcg_out_qemu_ld(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, | ||
2013 | TCGMemOpIdx oi, TCGType ext) | ||
2014 | { | ||
2015 | - TCGMemOp memop = get_memop(oi); | ||
2016 | + MemOp memop = get_memop(oi); | ||
2017 | const TCGType otype = TARGET_LONG_BITS == 64 ? TCG_TYPE_I64 : TCG_TYPE_I32; | ||
2018 | #ifdef CONFIG_SOFTMMU | ||
2019 | unsigned mem_index = get_mmuidx(oi); | ||
2020 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, | ||
2021 | static void tcg_out_qemu_st(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, | ||
2022 | TCGMemOpIdx oi) | ||
2023 | { | ||
2024 | - TCGMemOp memop = get_memop(oi); | ||
2025 | + MemOp memop = get_memop(oi); | ||
2026 | const TCGType otype = TARGET_LONG_BITS == 64 ? TCG_TYPE_I64 : TCG_TYPE_I32; | ||
2027 | #ifdef CONFIG_SOFTMMU | ||
2028 | unsigned mem_index = get_mmuidx(oi); | ||
2029 | diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c | ||
2030 | index XXXXXXX..XXXXXXX 100644 | ||
2031 | --- a/tcg/arm/tcg-target.inc.c | ||
2032 | +++ b/tcg/arm/tcg-target.inc.c | ||
2033 | @@ -XXX,XX +XXX,XX @@ QEMU_BUILD_BUG_ON(offsetof(CPUTLBDescFast, table) != 4); | ||
2034 | containing the addend of the tlb entry. Clobbers R0, R1, R2, TMP. */ | ||
2035 | |||
2036 | static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi, | ||
2037 | - TCGMemOp opc, int mem_index, bool is_load) | ||
2038 | + MemOp opc, int mem_index, bool is_load) | ||
2039 | { | ||
2040 | int cmp_off = (is_load ? offsetof(CPUTLBEntry, addr_read) | ||
2041 | : offsetof(CPUTLBEntry, addr_write)); | ||
2042 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
2043 | { | ||
2044 | TCGReg argreg, datalo, datahi; | ||
2045 | TCGMemOpIdx oi = lb->oi; | ||
2046 | - TCGMemOp opc = get_memop(oi); | ||
2047 | + MemOp opc = get_memop(oi); | ||
2048 | void *func; | ||
2049 | |||
2050 | if (!reloc_pc24(lb->label_ptr[0], s->code_ptr)) { | ||
2051 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
2052 | { | ||
2053 | TCGReg argreg, datalo, datahi; | ||
2054 | TCGMemOpIdx oi = lb->oi; | ||
2055 | - TCGMemOp opc = get_memop(oi); | ||
2056 | + MemOp opc = get_memop(oi); | ||
2057 | |||
2058 | if (!reloc_pc24(lb->label_ptr[0], s->code_ptr)) { | ||
2059 | return false; | ||
2060 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
2061 | } | ||
2062 | #endif /* SOFTMMU */ | ||
2063 | |||
2064 | -static inline void tcg_out_qemu_ld_index(TCGContext *s, TCGMemOp opc, | ||
2065 | +static inline void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, | ||
2066 | TCGReg datalo, TCGReg datahi, | ||
2067 | TCGReg addrlo, TCGReg addend) | ||
2068 | { | ||
2069 | - TCGMemOp bswap = opc & MO_BSWAP; | ||
2070 | + MemOp bswap = opc & MO_BSWAP; | ||
2071 | |||
2072 | switch (opc & MO_SSIZE) { | ||
2073 | case MO_UB: | ||
2074 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_qemu_ld_index(TCGContext *s, TCGMemOp opc, | ||
2075 | } | ||
2076 | } | ||
2077 | |||
2078 | -static inline void tcg_out_qemu_ld_direct(TCGContext *s, TCGMemOp opc, | ||
2079 | +static inline void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, | ||
2080 | TCGReg datalo, TCGReg datahi, | ||
2081 | TCGReg addrlo) | ||
2082 | { | ||
2083 | - TCGMemOp bswap = opc & MO_BSWAP; | ||
2084 | + MemOp bswap = opc & MO_BSWAP; | ||
2085 | |||
2086 | switch (opc & MO_SSIZE) { | ||
2087 | case MO_UB: | ||
2088 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
2089 | { | ||
2090 | TCGReg addrlo, datalo, datahi, addrhi __attribute__((unused)); | ||
2091 | TCGMemOpIdx oi; | ||
2092 | - TCGMemOp opc; | ||
2093 | + MemOp opc; | ||
2094 | #ifdef CONFIG_SOFTMMU | ||
2095 | int mem_index; | ||
2096 | TCGReg addend; | ||
2097 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
2098 | #endif | ||
2099 | } | ||
2100 | |||
2101 | -static inline void tcg_out_qemu_st_index(TCGContext *s, int cond, TCGMemOp opc, | ||
2102 | +static inline void tcg_out_qemu_st_index(TCGContext *s, int cond, MemOp opc, | ||
2103 | TCGReg datalo, TCGReg datahi, | ||
2104 | TCGReg addrlo, TCGReg addend) | ||
2105 | { | ||
2106 | - TCGMemOp bswap = opc & MO_BSWAP; | ||
2107 | + MemOp bswap = opc & MO_BSWAP; | ||
2108 | |||
2109 | switch (opc & MO_SIZE) { | ||
2110 | case MO_8: | ||
2111 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_qemu_st_index(TCGContext *s, int cond, TCGMemOp opc, | ||
2112 | } | ||
2113 | } | ||
2114 | |||
2115 | -static inline void tcg_out_qemu_st_direct(TCGContext *s, TCGMemOp opc, | ||
2116 | +static inline void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, | ||
2117 | TCGReg datalo, TCGReg datahi, | ||
2118 | TCGReg addrlo) | ||
2119 | { | ||
2120 | - TCGMemOp bswap = opc & MO_BSWAP; | ||
2121 | + MemOp bswap = opc & MO_BSWAP; | ||
2122 | |||
2123 | switch (opc & MO_SIZE) { | ||
2124 | case MO_8: | ||
2125 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
2126 | { | ||
2127 | TCGReg addrlo, datalo, datahi, addrhi __attribute__((unused)); | ||
2128 | TCGMemOpIdx oi; | ||
2129 | - TCGMemOp opc; | ||
2130 | + MemOp opc; | ||
2131 | #ifdef CONFIG_SOFTMMU | ||
2132 | int mem_index; | ||
2133 | TCGReg addend; | ||
2134 | diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c | ||
2135 | index XXXXXXX..XXXXXXX 100644 | ||
2136 | --- a/tcg/i386/tcg-target.inc.c | ||
2137 | +++ b/tcg/i386/tcg-target.inc.c | ||
2138 | @@ -XXX,XX +XXX,XX @@ static void * const qemu_st_helpers[16] = { | ||
2139 | First argument register is clobbered. */ | ||
2140 | |||
2141 | static inline void tcg_out_tlb_load(TCGContext *s, TCGReg addrlo, TCGReg addrhi, | ||
2142 | - int mem_index, TCGMemOp opc, | ||
2143 | + int mem_index, MemOp opc, | ||
2144 | tcg_insn_unit **label_ptr, int which) | ||
2145 | { | ||
2146 | const TCGReg r0 = TCG_REG_L0; | ||
2147 | @@ -XXX,XX +XXX,XX @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, bool is_64, | ||
2148 | static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
2149 | { | ||
2150 | TCGMemOpIdx oi = l->oi; | ||
2151 | - TCGMemOp opc = get_memop(oi); | ||
2152 | + MemOp opc = get_memop(oi); | ||
2153 | TCGReg data_reg; | ||
2154 | tcg_insn_unit **label_ptr = &l->label_ptr[0]; | ||
2155 | int rexw = (l->type == TCG_TYPE_I64 ? P_REXW : 0); | ||
2156 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
2157 | static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
2158 | { | ||
2159 | TCGMemOpIdx oi = l->oi; | ||
2160 | - TCGMemOp opc = get_memop(oi); | ||
2161 | - TCGMemOp s_bits = opc & MO_SIZE; | ||
2162 | + MemOp opc = get_memop(oi); | ||
2163 | + MemOp s_bits = opc & MO_SIZE; | ||
2164 | tcg_insn_unit **label_ptr = &l->label_ptr[0]; | ||
2165 | TCGReg retaddr; | ||
2166 | |||
2167 | @@ -XXX,XX +XXX,XX @@ static inline int setup_guest_base_seg(void) | ||
2168 | |||
2169 | static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
2170 | TCGReg base, int index, intptr_t ofs, | ||
2171 | - int seg, bool is64, TCGMemOp memop) | ||
2172 | + int seg, bool is64, MemOp memop) | ||
2173 | { | ||
2174 | - const TCGMemOp real_bswap = memop & MO_BSWAP; | ||
2175 | - TCGMemOp bswap = real_bswap; | ||
2176 | + const MemOp real_bswap = memop & MO_BSWAP; | ||
2177 | + MemOp bswap = real_bswap; | ||
2178 | int rexw = is64 * P_REXW; | ||
2179 | int movop = OPC_MOVL_GvEv; | ||
2180 | |||
2181 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
2182 | TCGReg datalo, datahi, addrlo; | ||
2183 | TCGReg addrhi __attribute__((unused)); | ||
2184 | TCGMemOpIdx oi; | ||
2185 | - TCGMemOp opc; | ||
2186 | + MemOp opc; | ||
2187 | #if defined(CONFIG_SOFTMMU) | ||
2188 | int mem_index; | ||
2189 | tcg_insn_unit *label_ptr[2]; | ||
2190 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
2191 | |||
2192 | static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
2193 | TCGReg base, int index, intptr_t ofs, | ||
2194 | - int seg, TCGMemOp memop) | ||
2195 | + int seg, MemOp memop) | ||
2196 | { | ||
2197 | /* ??? Ideally we wouldn't need a scratch register. For user-only, | ||
2198 | we could perform the bswap twice to restore the original value | ||
2199 | instead of moving to the scratch. But as it is, the L constraint | ||
2200 | means that TCG_REG_L0 is definitely free here. */ | ||
2201 | const TCGReg scratch = TCG_REG_L0; | ||
2202 | - const TCGMemOp real_bswap = memop & MO_BSWAP; | ||
2203 | - TCGMemOp bswap = real_bswap; | ||
2204 | + const MemOp real_bswap = memop & MO_BSWAP; | ||
2205 | + MemOp bswap = real_bswap; | ||
2206 | int movop = OPC_MOVL_EvGv; | ||
2207 | |||
2208 | if (have_movbe && real_bswap) { | ||
2209 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
2210 | TCGReg datalo, datahi, addrlo; | ||
2211 | TCGReg addrhi __attribute__((unused)); | ||
2212 | TCGMemOpIdx oi; | ||
2213 | - TCGMemOp opc; | ||
2214 | + MemOp opc; | ||
2215 | #if defined(CONFIG_SOFTMMU) | ||
2216 | int mem_index; | ||
2217 | tcg_insn_unit *label_ptr[2]; | ||
2218 | diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c | ||
2219 | index XXXXXXX..XXXXXXX 100644 | ||
2220 | --- a/tcg/mips/tcg-target.inc.c | ||
2221 | +++ b/tcg/mips/tcg-target.inc.c | ||
2222 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg base, TCGReg addrl, | ||
2223 | TCGReg addrh, TCGMemOpIdx oi, | ||
2224 | tcg_insn_unit *label_ptr[2], bool is_load) | ||
2225 | { | ||
2226 | - TCGMemOp opc = get_memop(oi); | ||
2227 | + MemOp opc = get_memop(oi); | ||
2228 | unsigned s_bits = opc & MO_SIZE; | ||
2229 | unsigned a_bits = get_alignment_bits(opc); | ||
2230 | int mem_index = get_mmuidx(oi); | ||
2231 | @@ -XXX,XX +XXX,XX @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, | ||
2232 | static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
2233 | { | ||
2234 | TCGMemOpIdx oi = l->oi; | ||
2235 | - TCGMemOp opc = get_memop(oi); | ||
2236 | + MemOp opc = get_memop(oi); | ||
2237 | TCGReg v0; | ||
2238 | int i; | ||
2239 | |||
2240 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
2241 | static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
2242 | { | ||
2243 | TCGMemOpIdx oi = l->oi; | ||
2244 | - TCGMemOp opc = get_memop(oi); | ||
2245 | - TCGMemOp s_bits = opc & MO_SIZE; | ||
2246 | + MemOp opc = get_memop(oi); | ||
2247 | + MemOp s_bits = opc & MO_SIZE; | ||
2248 | int i; | ||
2249 | |||
2250 | /* resolve label address */ | ||
2251 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
2252 | #endif | ||
2253 | |||
2254 | static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, | ||
2255 | - TCGReg base, TCGMemOp opc, bool is_64) | ||
2256 | + TCGReg base, MemOp opc, bool is_64) | ||
2257 | { | ||
2258 | switch (opc & (MO_SSIZE | MO_BSWAP)) { | ||
2259 | case MO_UB: | ||
2260 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
2261 | TCGReg addr_regl, addr_regh __attribute__((unused)); | ||
2262 | TCGReg data_regl, data_regh; | ||
2263 | TCGMemOpIdx oi; | ||
2264 | - TCGMemOp opc; | ||
2265 | + MemOp opc; | ||
2266 | #if defined(CONFIG_SOFTMMU) | ||
2267 | tcg_insn_unit *label_ptr[2]; | ||
2268 | #endif | ||
2269 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
2270 | } | ||
2271 | |||
2272 | static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, | ||
2273 | - TCGReg base, TCGMemOp opc) | ||
2274 | + TCGReg base, MemOp opc) | ||
2275 | { | ||
2276 | /* Don't clutter the code below with checks to avoid bswapping ZERO. */ | ||
2277 | if ((lo | hi) == 0) { | ||
2278 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
2279 | TCGReg addr_regl, addr_regh __attribute__((unused)); | ||
2280 | TCGReg data_regl, data_regh; | ||
2281 | TCGMemOpIdx oi; | ||
2282 | - TCGMemOp opc; | ||
2283 | + MemOp opc; | ||
2284 | #if defined(CONFIG_SOFTMMU) | ||
2285 | tcg_insn_unit *label_ptr[2]; | ||
2286 | #endif | ||
2287 | diff --git a/tcg/optimize.c b/tcg/optimize.c | ||
2288 | index XXXXXXX..XXXXXXX 100644 | ||
2289 | --- a/tcg/optimize.c | ||
2290 | +++ b/tcg/optimize.c | ||
2291 | @@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s) | ||
2292 | CASE_OP_32_64(qemu_ld): | ||
2293 | { | ||
2294 | TCGMemOpIdx oi = op->args[nb_oargs + nb_iargs]; | ||
2295 | - TCGMemOp mop = get_memop(oi); | ||
2296 | + MemOp mop = get_memop(oi); | ||
2297 | if (!(mop & MO_SIGN)) { | ||
2298 | mask = (2ULL << ((8 << (mop & MO_SIZE)) - 1)) - 1; | ||
2299 | } | ||
2300 | diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c | ||
2301 | index XXXXXXX..XXXXXXX 100644 | ||
2302 | --- a/tcg/ppc/tcg-target.inc.c | ||
2303 | +++ b/tcg/ppc/tcg-target.inc.c | ||
2304 | @@ -XXX,XX +XXX,XX @@ QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -32768); | ||
2305 | in CR7, loads the addend of the TLB into R3, and returns the register | ||
2306 | containing the guest address (zero-extended into R4). Clobbers R0 and R2. */ | ||
2307 | |||
2308 | -static TCGReg tcg_out_tlb_read(TCGContext *s, TCGMemOp opc, | ||
2309 | +static TCGReg tcg_out_tlb_read(TCGContext *s, MemOp opc, | ||
2310 | TCGReg addrlo, TCGReg addrhi, | ||
2311 | int mem_index, bool is_read) | ||
2312 | { | ||
2313 | @@ -XXX,XX +XXX,XX @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, | ||
2314 | static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
2315 | { | ||
2316 | TCGMemOpIdx oi = lb->oi; | ||
2317 | - TCGMemOp opc = get_memop(oi); | ||
2318 | + MemOp opc = get_memop(oi); | ||
2319 | TCGReg hi, lo, arg = TCG_REG_R3; | ||
2320 | |||
2321 | if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) { | ||
2322 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
2323 | static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
2324 | { | ||
2325 | TCGMemOpIdx oi = lb->oi; | ||
2326 | - TCGMemOp opc = get_memop(oi); | ||
2327 | - TCGMemOp s_bits = opc & MO_SIZE; | ||
2328 | + MemOp opc = get_memop(oi); | ||
2329 | + MemOp s_bits = opc & MO_SIZE; | ||
2330 | TCGReg hi, lo, arg = TCG_REG_R3; | ||
2331 | |||
2332 | if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) { | ||
2333 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
2334 | TCGReg datalo, datahi, addrlo, rbase; | ||
2335 | TCGReg addrhi __attribute__((unused)); | ||
2336 | TCGMemOpIdx oi; | ||
2337 | - TCGMemOp opc, s_bits; | ||
2338 | + MemOp opc, s_bits; | ||
2339 | #ifdef CONFIG_SOFTMMU | ||
2340 | int mem_index; | ||
2341 | tcg_insn_unit *label_ptr; | ||
2342 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
2343 | TCGReg datalo, datahi, addrlo, rbase; | ||
2344 | TCGReg addrhi __attribute__((unused)); | ||
2345 | TCGMemOpIdx oi; | ||
2346 | - TCGMemOp opc, s_bits; | ||
2347 | + MemOp opc, s_bits; | ||
2348 | #ifdef CONFIG_SOFTMMU | ||
2349 | int mem_index; | ||
2350 | tcg_insn_unit *label_ptr; | ||
2351 | diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c | ||
2352 | index XXXXXXX..XXXXXXX 100644 | ||
2353 | --- a/tcg/riscv/tcg-target.inc.c | ||
2354 | +++ b/tcg/riscv/tcg-target.inc.c | ||
2355 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, | ||
2356 | TCGReg addrh, TCGMemOpIdx oi, | ||
2357 | tcg_insn_unit **label_ptr, bool is_load) | ||
2358 | { | ||
2359 | - TCGMemOp opc = get_memop(oi); | ||
2360 | + MemOp opc = get_memop(oi); | ||
2361 | unsigned s_bits = opc & MO_SIZE; | ||
2362 | unsigned a_bits = get_alignment_bits(opc); | ||
2363 | tcg_target_long compare_mask; | ||
2364 | @@ -XXX,XX +XXX,XX @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, | ||
2365 | static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
2366 | { | ||
2367 | TCGMemOpIdx oi = l->oi; | ||
2368 | - TCGMemOp opc = get_memop(oi); | ||
2369 | + MemOp opc = get_memop(oi); | ||
2370 | TCGReg a0 = tcg_target_call_iarg_regs[0]; | ||
2371 | TCGReg a1 = tcg_target_call_iarg_regs[1]; | ||
2372 | TCGReg a2 = tcg_target_call_iarg_regs[2]; | ||
2373 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
2374 | static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
2375 | { | ||
2376 | TCGMemOpIdx oi = l->oi; | ||
2377 | - TCGMemOp opc = get_memop(oi); | ||
2378 | - TCGMemOp s_bits = opc & MO_SIZE; | ||
2379 | + MemOp opc = get_memop(oi); | ||
2380 | + MemOp s_bits = opc & MO_SIZE; | ||
2381 | TCGReg a0 = tcg_target_call_iarg_regs[0]; | ||
2382 | TCGReg a1 = tcg_target_call_iarg_regs[1]; | ||
2383 | TCGReg a2 = tcg_target_call_iarg_regs[2]; | ||
2384 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
2385 | #endif /* CONFIG_SOFTMMU */ | ||
2386 | |||
2387 | static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, | ||
2388 | - TCGReg base, TCGMemOp opc, bool is_64) | ||
2389 | + TCGReg base, MemOp opc, bool is_64) | ||
2390 | { | ||
2391 | - const TCGMemOp bswap = opc & MO_BSWAP; | ||
2392 | + const MemOp bswap = opc & MO_BSWAP; | ||
2393 | |||
2394 | /* We don't yet handle byteswapping, assert */ | ||
2395 | g_assert(!bswap); | ||
2396 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
2397 | TCGReg addr_regl, addr_regh __attribute__((unused)); | ||
2398 | TCGReg data_regl, data_regh; | ||
2399 | TCGMemOpIdx oi; | ||
2400 | - TCGMemOp opc; | ||
2401 | + MemOp opc; | ||
2402 | #if defined(CONFIG_SOFTMMU) | ||
2403 | tcg_insn_unit *label_ptr[1]; | ||
2404 | #endif | ||
2405 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
2406 | } | ||
2407 | |||
2408 | static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, | ||
2409 | - TCGReg base, TCGMemOp opc) | ||
2410 | + TCGReg base, MemOp opc) | ||
2411 | { | ||
2412 | - const TCGMemOp bswap = opc & MO_BSWAP; | ||
2413 | + const MemOp bswap = opc & MO_BSWAP; | ||
2414 | |||
2415 | /* We don't yet handle byteswapping, assert */ | ||
2416 | g_assert(!bswap); | ||
2417 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
2418 | TCGReg addr_regl, addr_regh __attribute__((unused)); | ||
2419 | TCGReg data_regl, data_regh; | ||
2420 | TCGMemOpIdx oi; | ||
2421 | - TCGMemOp opc; | ||
2422 | + MemOp opc; | ||
2423 | #if defined(CONFIG_SOFTMMU) | ||
2424 | tcg_insn_unit *label_ptr[1]; | ||
2425 | #endif | ||
2426 | diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c | ||
2427 | index XXXXXXX..XXXXXXX 100644 | ||
2428 | --- a/tcg/s390/tcg-target.inc.c | ||
2429 | +++ b/tcg/s390/tcg-target.inc.c | ||
2430 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_call(TCGContext *s, tcg_insn_unit *dest) | ||
2431 | } | ||
2432 | } | ||
2433 | |||
2434 | -static void tcg_out_qemu_ld_direct(TCGContext *s, TCGMemOp opc, TCGReg data, | ||
2435 | +static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, TCGReg data, | ||
2436 | TCGReg base, TCGReg index, int disp) | ||
2437 | { | ||
2438 | switch (opc & (MO_SSIZE | MO_BSWAP)) { | ||
2439 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGMemOp opc, TCGReg data, | ||
2440 | } | ||
2441 | } | ||
2442 | |||
2443 | -static void tcg_out_qemu_st_direct(TCGContext *s, TCGMemOp opc, TCGReg data, | ||
2444 | +static void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg data, | ||
2445 | TCGReg base, TCGReg index, int disp) | ||
2446 | { | ||
2447 | switch (opc & (MO_SIZE | MO_BSWAP)) { | ||
2448 | @@ -XXX,XX +XXX,XX @@ QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -(1 << 19)); | ||
2449 | |||
2450 | /* Load and compare a TLB entry, leaving the flags set. Loads the TLB | ||
2451 | addend into R2. Returns a register with the santitized guest address. */ | ||
2452 | -static TCGReg tcg_out_tlb_read(TCGContext* s, TCGReg addr_reg, TCGMemOp opc, | ||
2453 | +static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addr_reg, MemOp opc, | ||
2454 | int mem_index, bool is_ld) | ||
2455 | { | ||
2456 | unsigned s_bits = opc & MO_SIZE; | ||
2457 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
2458 | TCGReg addr_reg = lb->addrlo_reg; | ||
2459 | TCGReg data_reg = lb->datalo_reg; | ||
2460 | TCGMemOpIdx oi = lb->oi; | ||
2461 | - TCGMemOp opc = get_memop(oi); | ||
2462 | + MemOp opc = get_memop(oi); | ||
2463 | |||
2464 | if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL, | ||
2465 | (intptr_t)s->code_ptr, 2)) { | ||
2466 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
2467 | TCGReg addr_reg = lb->addrlo_reg; | ||
2468 | TCGReg data_reg = lb->datalo_reg; | ||
2469 | TCGMemOpIdx oi = lb->oi; | ||
2470 | - TCGMemOp opc = get_memop(oi); | ||
2471 | + MemOp opc = get_memop(oi); | ||
2472 | |||
2473 | if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL, | ||
2474 | (intptr_t)s->code_ptr, 2)) { | ||
2475 | @@ -XXX,XX +XXX,XX @@ static void tcg_prepare_user_ldst(TCGContext *s, TCGReg *addr_reg, | ||
2476 | static void tcg_out_qemu_ld(TCGContext* s, TCGReg data_reg, TCGReg addr_reg, | ||
2477 | TCGMemOpIdx oi) | ||
2478 | { | ||
2479 | - TCGMemOp opc = get_memop(oi); | ||
2480 | + MemOp opc = get_memop(oi); | ||
2481 | #ifdef CONFIG_SOFTMMU | ||
2482 | unsigned mem_index = get_mmuidx(oi); | ||
2483 | tcg_insn_unit *label_ptr; | ||
2484 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext* s, TCGReg data_reg, TCGReg addr_reg, | ||
2485 | static void tcg_out_qemu_st(TCGContext* s, TCGReg data_reg, TCGReg addr_reg, | ||
2486 | TCGMemOpIdx oi) | ||
2487 | { | ||
2488 | - TCGMemOp opc = get_memop(oi); | ||
2489 | + MemOp opc = get_memop(oi); | ||
2490 | #ifdef CONFIG_SOFTMMU | ||
2491 | unsigned mem_index = get_mmuidx(oi); | ||
2492 | tcg_insn_unit *label_ptr; | ||
2493 | diff --git a/tcg/sparc/tcg-target.inc.c b/tcg/sparc/tcg-target.inc.c | ||
2494 | index XXXXXXX..XXXXXXX 100644 | ||
2495 | --- a/tcg/sparc/tcg-target.inc.c | ||
2496 | +++ b/tcg/sparc/tcg-target.inc.c | ||
2497 | @@ -XXX,XX +XXX,XX @@ QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -(1 << 12)); | ||
2498 | is in the returned register, maybe %o0. The TLB addend is in %o1. */ | ||
2499 | |||
2500 | static TCGReg tcg_out_tlb_load(TCGContext *s, TCGReg addr, int mem_index, | ||
2501 | - TCGMemOp opc, int which) | ||
2502 | + MemOp opc, int which) | ||
2503 | { | ||
2504 | int fast_off = TLB_MASK_TABLE_OFS(mem_index); | ||
2505 | int mask_off = fast_off + offsetof(CPUTLBDescFast, mask); | ||
2506 | @@ -XXX,XX +XXX,XX @@ static const int qemu_st_opc[16] = { | ||
2507 | static void tcg_out_qemu_ld(TCGContext *s, TCGReg data, TCGReg addr, | ||
2508 | TCGMemOpIdx oi, bool is_64) | ||
2509 | { | ||
2510 | - TCGMemOp memop = get_memop(oi); | ||
2511 | + MemOp memop = get_memop(oi); | ||
2512 | #ifdef CONFIG_SOFTMMU | ||
2513 | unsigned memi = get_mmuidx(oi); | ||
2514 | TCGReg addrz, param; | ||
2515 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data, TCGReg addr, | ||
2516 | static void tcg_out_qemu_st(TCGContext *s, TCGReg data, TCGReg addr, | ||
2517 | TCGMemOpIdx oi) | ||
2518 | { | ||
2519 | - TCGMemOp memop = get_memop(oi); | ||
2520 | + MemOp memop = get_memop(oi); | ||
2521 | #ifdef CONFIG_SOFTMMU | ||
2522 | unsigned memi = get_mmuidx(oi); | ||
2523 | TCGReg addrz, param; | ||
2524 | diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c | ||
2525 | index XXXXXXX..XXXXXXX 100644 | ||
2526 | --- a/tcg/tcg-op.c | ||
2527 | +++ b/tcg/tcg-op.c | ||
2528 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_lookup_and_goto_ptr(void) | ||
2529 | } | ||
2530 | } | ||
2531 | |||
2532 | -static inline TCGMemOp tcg_canonicalize_memop(TCGMemOp op, bool is64, bool st) | ||
2533 | +static inline MemOp tcg_canonicalize_memop(MemOp op, bool is64, bool st) | ||
2534 | { | ||
2535 | /* Trigger the asserts within as early as possible. */ | ||
2536 | (void)get_alignment_bits(op); | ||
2537 | @@ -XXX,XX +XXX,XX @@ static inline TCGMemOp tcg_canonicalize_memop(TCGMemOp op, bool is64, bool st) | ||
2538 | } | ||
2539 | |||
2540 | static void gen_ldst_i32(TCGOpcode opc, TCGv_i32 val, TCGv addr, | ||
2541 | - TCGMemOp memop, TCGArg idx) | ||
2542 | + MemOp memop, TCGArg idx) | ||
2543 | { | ||
2544 | TCGMemOpIdx oi = make_memop_idx(memop, idx); | ||
2545 | #if TARGET_LONG_BITS == 32 | ||
2546 | @@ -XXX,XX +XXX,XX @@ static void gen_ldst_i32(TCGOpcode opc, TCGv_i32 val, TCGv addr, | ||
2547 | } | ||
2548 | |||
2549 | static void gen_ldst_i64(TCGOpcode opc, TCGv_i64 val, TCGv addr, | ||
2550 | - TCGMemOp memop, TCGArg idx) | ||
2551 | + MemOp memop, TCGArg idx) | ||
2552 | { | ||
2553 | TCGMemOpIdx oi = make_memop_idx(memop, idx); | ||
2554 | #if TARGET_LONG_BITS == 32 | ||
2555 | @@ -XXX,XX +XXX,XX @@ static void tcg_gen_req_mo(TCGBar type) | ||
2556 | } | ||
2557 | } | ||
2558 | |||
2559 | -void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
2560 | +void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) | ||
2561 | { | ||
2562 | - TCGMemOp orig_memop; | ||
2563 | + MemOp orig_memop; | ||
2564 | |||
2565 | tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); | ||
2566 | memop = tcg_canonicalize_memop(memop, 0, 0); | ||
2567 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
2568 | } | ||
2569 | } | ||
2570 | |||
2571 | -void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
2572 | +void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) | ||
2573 | { | ||
2574 | TCGv_i32 swap = NULL; | ||
2575 | |||
2576 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
2577 | } | ||
2578 | } | ||
2579 | |||
2580 | -void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
2581 | +void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) | ||
2582 | { | ||
2583 | - TCGMemOp orig_memop; | ||
2584 | + MemOp orig_memop; | ||
2585 | |||
2586 | if (TCG_TARGET_REG_BITS == 32 && (memop & MO_SIZE) < MO_64) { | ||
2587 | tcg_gen_qemu_ld_i32(TCGV_LOW(val), addr, idx, memop); | ||
2588 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
2589 | } | ||
2590 | } | ||
2591 | |||
2592 | -void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
2593 | +void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) | ||
2594 | { | ||
2595 | TCGv_i64 swap = NULL; | ||
2596 | |||
2597 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
2598 | } | ||
2599 | } | ||
2600 | |||
2601 | -static void tcg_gen_ext_i32(TCGv_i32 ret, TCGv_i32 val, TCGMemOp opc) | ||
2602 | +static void tcg_gen_ext_i32(TCGv_i32 ret, TCGv_i32 val, MemOp opc) | ||
2603 | { | ||
2604 | switch (opc & MO_SSIZE) { | ||
2605 | case MO_SB: | ||
2606 | @@ -XXX,XX +XXX,XX @@ static void tcg_gen_ext_i32(TCGv_i32 ret, TCGv_i32 val, TCGMemOp opc) | ||
2607 | } | ||
2608 | } | ||
2609 | |||
2610 | -static void tcg_gen_ext_i64(TCGv_i64 ret, TCGv_i64 val, TCGMemOp opc) | ||
2611 | +static void tcg_gen_ext_i64(TCGv_i64 ret, TCGv_i64 val, MemOp opc) | ||
2612 | { | ||
2613 | switch (opc & MO_SSIZE) { | ||
2614 | case MO_SB: | ||
2615 | @@ -XXX,XX +XXX,XX @@ static void * const table_cmpxchg[16] = { | ||
2616 | }; | ||
2617 | |||
2618 | void tcg_gen_atomic_cmpxchg_i32(TCGv_i32 retv, TCGv addr, TCGv_i32 cmpv, | ||
2619 | - TCGv_i32 newv, TCGArg idx, TCGMemOp memop) | ||
2620 | + TCGv_i32 newv, TCGArg idx, MemOp memop) | ||
2621 | { | ||
2622 | memop = tcg_canonicalize_memop(memop, 0, 0); | ||
2623 | |||
2624 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_atomic_cmpxchg_i32(TCGv_i32 retv, TCGv addr, TCGv_i32 cmpv, | ||
2625 | } | ||
2626 | |||
2627 | void tcg_gen_atomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv, | ||
2628 | - TCGv_i64 newv, TCGArg idx, TCGMemOp memop) | ||
2629 | + TCGv_i64 newv, TCGArg idx, MemOp memop) | ||
2630 | { | ||
2631 | memop = tcg_canonicalize_memop(memop, 1, 0); | ||
2632 | |||
2633 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_atomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv, | ||
2634 | } | ||
2635 | |||
2636 | static void do_nonatomic_op_i32(TCGv_i32 ret, TCGv addr, TCGv_i32 val, | ||
2637 | - TCGArg idx, TCGMemOp memop, bool new_val, | ||
2638 | + TCGArg idx, MemOp memop, bool new_val, | ||
2639 | void (*gen)(TCGv_i32, TCGv_i32, TCGv_i32)) | ||
2640 | { | ||
2641 | TCGv_i32 t1 = tcg_temp_new_i32(); | ||
2642 | @@ -XXX,XX +XXX,XX @@ static void do_nonatomic_op_i32(TCGv_i32 ret, TCGv addr, TCGv_i32 val, | ||
2643 | } | ||
2644 | |||
2645 | static void do_atomic_op_i32(TCGv_i32 ret, TCGv addr, TCGv_i32 val, | ||
2646 | - TCGArg idx, TCGMemOp memop, void * const table[]) | ||
2647 | + TCGArg idx, MemOp memop, void * const table[]) | ||
2648 | { | ||
2649 | gen_atomic_op_i32 gen; | ||
2650 | |||
2651 | @@ -XXX,XX +XXX,XX @@ static void do_atomic_op_i32(TCGv_i32 ret, TCGv addr, TCGv_i32 val, | ||
2652 | } | ||
2653 | |||
2654 | static void do_nonatomic_op_i64(TCGv_i64 ret, TCGv addr, TCGv_i64 val, | ||
2655 | - TCGArg idx, TCGMemOp memop, bool new_val, | ||
2656 | + TCGArg idx, MemOp memop, bool new_val, | ||
2657 | void (*gen)(TCGv_i64, TCGv_i64, TCGv_i64)) | ||
2658 | { | ||
2659 | TCGv_i64 t1 = tcg_temp_new_i64(); | ||
2660 | @@ -XXX,XX +XXX,XX @@ static void do_nonatomic_op_i64(TCGv_i64 ret, TCGv addr, TCGv_i64 val, | ||
2661 | } | ||
2662 | |||
2663 | static void do_atomic_op_i64(TCGv_i64 ret, TCGv addr, TCGv_i64 val, | ||
2664 | - TCGArg idx, TCGMemOp memop, void * const table[]) | ||
2665 | + TCGArg idx, MemOp memop, void * const table[]) | ||
2666 | { | ||
2667 | memop = tcg_canonicalize_memop(memop, 1, 0); | ||
2668 | |||
2669 | @@ -XXX,XX +XXX,XX @@ static void * const table_##NAME[16] = { \ | ||
2670 | WITH_ATOMIC64([MO_64 | MO_BE] = gen_helper_atomic_##NAME##q_be) \ | ||
2671 | }; \ | ||
2672 | void tcg_gen_atomic_##NAME##_i32 \ | ||
2673 | - (TCGv_i32 ret, TCGv addr, TCGv_i32 val, TCGArg idx, TCGMemOp memop) \ | ||
2674 | + (TCGv_i32 ret, TCGv addr, TCGv_i32 val, TCGArg idx, MemOp memop) \ | ||
2675 | { \ | ||
2676 | if (tcg_ctx->tb_cflags & CF_PARALLEL) { \ | ||
2677 | do_atomic_op_i32(ret, addr, val, idx, memop, table_##NAME); \ | ||
2678 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_atomic_##NAME##_i32 \ | ||
2679 | } \ | ||
2680 | } \ | ||
2681 | void tcg_gen_atomic_##NAME##_i64 \ | ||
2682 | - (TCGv_i64 ret, TCGv addr, TCGv_i64 val, TCGArg idx, TCGMemOp memop) \ | ||
2683 | + (TCGv_i64 ret, TCGv addr, TCGv_i64 val, TCGArg idx, MemOp memop) \ | ||
2684 | { \ | ||
2685 | if (tcg_ctx->tb_cflags & CF_PARALLEL) { \ | ||
2686 | do_atomic_op_i64(ret, addr, val, idx, memop, table_##NAME); \ | ||
2687 | diff --git a/tcg/tcg.c b/tcg/tcg.c | ||
2688 | index XXXXXXX..XXXXXXX 100644 | ||
2689 | --- a/tcg/tcg.c | ||
2690 | +++ b/tcg/tcg.c | ||
2691 | @@ -XXX,XX +XXX,XX @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) | ||
2692 | case INDEX_op_qemu_st_i64: | ||
2693 | { | ||
2694 | TCGMemOpIdx oi = op->args[k++]; | ||
2695 | - TCGMemOp op = get_memop(oi); | ||
2696 | + MemOp op = get_memop(oi); | ||
2697 | unsigned ix = get_mmuidx(oi); | ||
2698 | |||
2699 | if (op & ~(MO_AMASK | MO_BSWAP | MO_SSIZE)) { | ||
2700 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
2701 | index XXXXXXX..XXXXXXX 100644 | ||
2702 | --- a/MAINTAINERS | ||
2703 | +++ b/MAINTAINERS | ||
2704 | @@ -XXX,XX +XXX,XX @@ M: Paolo Bonzini <pbonzini@redhat.com> | ||
2705 | S: Supported | ||
2706 | F: include/exec/ioport.h | ||
2707 | F: ioport.c | ||
2708 | +F: include/exec/memop.h | ||
2709 | F: include/exec/memory.h | ||
2710 | F: include/exec/ram_addr.h | ||
2711 | F: memory.c | ||
2712 | diff --git a/tcg/README b/tcg/README | ||
2713 | index XXXXXXX..XXXXXXX 100644 | ||
2714 | --- a/tcg/README | ||
2715 | +++ b/tcg/README | ||
2716 | @@ -XXX,XX +XXX,XX @@ Both t0 and t1 may be split into little-endian ordered pairs of registers | ||
2717 | if dealing with 64-bit quantities on a 32-bit host. | ||
2718 | |||
2719 | The memidx selects the qemu tlb index to use (e.g. user or kernel access). | ||
2720 | -The flags are the TCGMemOp bits, selecting the sign, width, and endianness | ||
2721 | +The flags are the MemOp bits, selecting the sign, width, and endianness | ||
2722 | of the memory access. | ||
2723 | |||
2724 | For a 32-bit host, qemu_ld/st_i64 is guaranteed to only be used with a | ||
2725 | -- | 72 | -- |
2726 | 2.17.1 | 73 | 2.43.0 |
2727 | 74 | ||
2728 | 75 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Tony Nguyen <tony.nguyen@bt.com> | ||
2 | 1 | ||
3 | The memory_region_dispatch_{read|write} operand "unsigned size" is | ||
4 | being converted into a "MemOp op". | ||
5 | |||
6 | Convert interfaces by using no-op size_memop. | ||
7 | |||
8 | After all interfaces are converted, size_memop will be implemented | ||
9 | and the memory_region_dispatch_{read|write} operand "unsigned size" | ||
10 | will be converted into a "MemOp op". | ||
11 | |||
12 | As size_memop is a no-op, this patch does not change any behaviour. | ||
13 | |||
14 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com> | ||
18 | Message-Id: <af407f0a34dc95ef5aaf2c00dffda7c65df23c3a.1566466906.git.tony.nguyen@bt.com> | ||
19 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
20 | --- | ||
21 | target/mips/op_helper.c | 5 +++-- | ||
22 | 1 file changed, 3 insertions(+), 2 deletions(-) | ||
23 | |||
24 | diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/mips/op_helper.c | ||
27 | +++ b/target/mips/op_helper.c | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | #include "exec/helper-proto.h" | ||
30 | #include "exec/exec-all.h" | ||
31 | #include "exec/cpu_ldst.h" | ||
32 | +#include "exec/memop.h" | ||
33 | #include "sysemu/kvm.h" | ||
34 | #include "fpu/softfloat.h" | ||
35 | |||
36 | @@ -XXX,XX +XXX,XX @@ void helper_cache(CPUMIPSState *env, target_ulong addr, uint32_t op) | ||
37 | if (op == 9) { | ||
38 | /* Index Store Tag */ | ||
39 | memory_region_dispatch_write(env->itc_tag, index, env->CP0_TagLo, | ||
40 | - 8, MEMTXATTRS_UNSPECIFIED); | ||
41 | + size_memop(8), MEMTXATTRS_UNSPECIFIED); | ||
42 | } else if (op == 5) { | ||
43 | /* Index Load Tag */ | ||
44 | memory_region_dispatch_read(env->itc_tag, index, &env->CP0_TagLo, | ||
45 | - 8, MEMTXATTRS_UNSPECIFIED); | ||
46 | + size_memop(8), MEMTXATTRS_UNSPECIFIED); | ||
47 | } | ||
48 | #endif | ||
49 | } | ||
50 | -- | ||
51 | 2.17.1 | ||
52 | |||
53 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Tony Nguyen <tony.nguyen@bt.com> | ||
2 | 1 | ||
3 | The memory_region_dispatch_{read|write} operand "unsigned size" is | ||
4 | being converted into a "MemOp op". | ||
5 | |||
6 | Convert interfaces by using no-op size_memop. | ||
7 | |||
8 | After all interfaces are converted, size_memop will be implemented | ||
9 | and the memory_region_dispatch_{read|write} operand "unsigned size" | ||
10 | will be converted into a "MemOp op". | ||
11 | |||
12 | As size_memop is a no-op, this patch does not change any behaviour. | ||
13 | |||
14 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
17 | Message-Id: <2f41da26201fb9b0339c2b7fde34df864f7f9ea8.1566466906.git.tony.nguyen@bt.com> | ||
18 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | --- | ||
20 | hw/s390x/s390-pci-inst.c | 8 +++++--- | ||
21 | 1 file changed, 5 insertions(+), 3 deletions(-) | ||
22 | |||
23 | diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/hw/s390x/s390-pci-inst.c | ||
26 | +++ b/hw/s390x/s390-pci-inst.c | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | #include "cpu.h" | ||
29 | #include "s390-pci-inst.h" | ||
30 | #include "s390-pci-bus.h" | ||
31 | +#include "exec/memop.h" | ||
32 | #include "exec/memory-internal.h" | ||
33 | #include "qemu/error-report.h" | ||
34 | #include "sysemu/hw_accel.h" | ||
35 | @@ -XXX,XX +XXX,XX @@ static MemTxResult zpci_read_bar(S390PCIBusDevice *pbdev, uint8_t pcias, | ||
36 | mr = pbdev->pdev->io_regions[pcias].memory; | ||
37 | mr = s390_get_subregion(mr, offset, len); | ||
38 | offset -= mr->addr; | ||
39 | - return memory_region_dispatch_read(mr, offset, data, len, | ||
40 | + return memory_region_dispatch_read(mr, offset, data, size_memop(len), | ||
41 | MEMTXATTRS_UNSPECIFIED); | ||
42 | } | ||
43 | |||
44 | @@ -XXX,XX +XXX,XX @@ static MemTxResult zpci_write_bar(S390PCIBusDevice *pbdev, uint8_t pcias, | ||
45 | mr = pbdev->pdev->io_regions[pcias].memory; | ||
46 | mr = s390_get_subregion(mr, offset, len); | ||
47 | offset -= mr->addr; | ||
48 | - return memory_region_dispatch_write(mr, offset, data, len, | ||
49 | + return memory_region_dispatch_write(mr, offset, data, size_memop(len), | ||
50 | MEMTXATTRS_UNSPECIFIED); | ||
51 | } | ||
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr, | ||
54 | |||
55 | for (i = 0; i < len / 8; i++) { | ||
56 | result = memory_region_dispatch_write(mr, offset + i * 8, | ||
57 | - ldq_p(buffer + i * 8), 8, | ||
58 | + ldq_p(buffer + i * 8), | ||
59 | + size_memop(8), | ||
60 | MEMTXATTRS_UNSPECIFIED); | ||
61 | if (result != MEMTX_OK) { | ||
62 | s390_program_interrupt(env, PGM_OPERAND, 6, ra); | ||
63 | -- | ||
64 | 2.17.1 | ||
65 | |||
66 | diff view generated by jsdifflib |
1 | From: Tony Nguyen <tony.nguyen@bt.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Preparation for collapsing the two byte swaps adjust_endianness and | 3 | Since commit 139c1837db ("meson: rename included C source files |
4 | handle_bswap into the former. | 4 | to .c.inc"), QEMU standard procedure for included C files is to |
5 | use *.c.inc. | ||
5 | 6 | ||
6 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | 7 | Besides, since commit 6a0057aa22 ("docs/devel: make a statement |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | about includes") this is documented in the Coding Style: |
8 | Message-Id: <755b7104410956b743e1f1e9c34ab87db113360f.1566466906.git.tony.nguyen@bt.com> | 9 | |
10 | If you do use template header files they should be named with | ||
11 | the ``.c.inc`` or ``.h.inc`` suffix to make it clear they are | ||
12 | being included for expansion. | ||
13 | |||
14 | Therefore rename 'atomic128-cas.h' as 'atomic128-cas.h.inc'. | ||
15 | |||
16 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 17 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
18 | Message-ID: <20241212141018.59428-2-philmd@linaro.org> | ||
10 | --- | 19 | --- |
11 | include/exec/memop.h | 6 ++ | 20 | host/include/aarch64/host/atomic128-cas.h | 2 +- |
12 | accel/tcg/cputlb.c | 170 +++++++++++++++++++++---------------------- | 21 | include/qemu/atomic128.h | 2 +- |
13 | 2 files changed, 87 insertions(+), 89 deletions(-) | 22 | .../generic/host/{atomic128-cas.h => atomic128-cas.h.inc} | 0 |
23 | 3 files changed, 2 insertions(+), 2 deletions(-) | ||
24 | rename host/include/generic/host/{atomic128-cas.h => atomic128-cas.h.inc} (100%) | ||
14 | 25 | ||
15 | diff --git a/include/exec/memop.h b/include/exec/memop.h | 26 | diff --git a/host/include/aarch64/host/atomic128-cas.h b/host/include/aarch64/host/atomic128-cas.h |
16 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/exec/memop.h | 28 | --- a/host/include/aarch64/host/atomic128-cas.h |
18 | +++ b/include/exec/memop.h | 29 | +++ b/host/include/aarch64/host/atomic128-cas.h |
19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp size_memop(unsigned size) | 30 | @@ -XXX,XX +XXX,XX @@ |
20 | return ctz32(size); | 31 | |
21 | } | 32 | /* Through gcc 10, aarch64 has no support for 128-bit atomics. */ |
22 | 33 | #if defined(CONFIG_ATOMIC128) || defined(CONFIG_CMPXCHG128) | |
23 | +/* Big endianness from MemOp. */ | 34 | -#include "host/include/generic/host/atomic128-cas.h" |
24 | +static inline bool memop_big_endian(MemOp op) | 35 | +#include "host/include/generic/host/atomic128-cas.h.inc" |
25 | +{ | 36 | #else |
26 | + return (op & MO_BSWAP) == MO_BE; | 37 | static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) |
27 | +} | 38 | { |
28 | + | 39 | diff --git a/include/qemu/atomic128.h b/include/qemu/atomic128.h |
29 | #endif | ||
30 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/accel/tcg/cputlb.c | 41 | --- a/include/qemu/atomic128.h |
33 | +++ b/accel/tcg/cputlb.c | 42 | +++ b/include/qemu/atomic128.h |
34 | @@ -XXX,XX +XXX,XX @@ static void tlb_fill(CPUState *cpu, target_ulong addr, int size, | 43 | @@ -XXX,XX +XXX,XX @@ |
35 | 44 | * Therefore, special case each platform. | |
36 | static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
37 | int mmu_idx, target_ulong addr, uintptr_t retaddr, | ||
38 | - MMUAccessType access_type, int size) | ||
39 | + MMUAccessType access_type, MemOp op) | ||
40 | { | ||
41 | CPUState *cpu = env_cpu(env); | ||
42 | hwaddr mr_offset; | ||
43 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
44 | qemu_mutex_lock_iothread(); | ||
45 | locked = true; | ||
46 | } | ||
47 | - r = memory_region_dispatch_read(mr, mr_offset, &val, | ||
48 | - size_memop(size) | MO_TE, | ||
49 | - iotlbentry->attrs); | ||
50 | + r = memory_region_dispatch_read(mr, mr_offset, &val, op, iotlbentry->attrs); | ||
51 | if (r != MEMTX_OK) { | ||
52 | hwaddr physaddr = mr_offset + | ||
53 | section->offset_within_address_space - | ||
54 | section->offset_within_region; | ||
55 | |||
56 | - cpu_transaction_failed(cpu, physaddr, addr, size, access_type, | ||
57 | + cpu_transaction_failed(cpu, physaddr, addr, memop_size(op), access_type, | ||
58 | mmu_idx, iotlbentry->attrs, r, retaddr); | ||
59 | } | ||
60 | if (locked) { | ||
61 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
62 | |||
63 | static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
64 | int mmu_idx, uint64_t val, target_ulong addr, | ||
65 | - uintptr_t retaddr, int size) | ||
66 | + uintptr_t retaddr, MemOp op) | ||
67 | { | ||
68 | CPUState *cpu = env_cpu(env); | ||
69 | hwaddr mr_offset; | ||
70 | @@ -XXX,XX +XXX,XX @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
71 | qemu_mutex_lock_iothread(); | ||
72 | locked = true; | ||
73 | } | ||
74 | - r = memory_region_dispatch_write(mr, mr_offset, val, | ||
75 | - size_memop(size) | MO_TE, | ||
76 | - iotlbentry->attrs); | ||
77 | + r = memory_region_dispatch_write(mr, mr_offset, val, op, iotlbentry->attrs); | ||
78 | if (r != MEMTX_OK) { | ||
79 | hwaddr physaddr = mr_offset + | ||
80 | section->offset_within_address_space - | ||
81 | section->offset_within_region; | ||
82 | |||
83 | - cpu_transaction_failed(cpu, physaddr, addr, size, MMU_DATA_STORE, | ||
84 | - mmu_idx, iotlbentry->attrs, r, retaddr); | ||
85 | + cpu_transaction_failed(cpu, physaddr, addr, memop_size(op), | ||
86 | + MMU_DATA_STORE, mmu_idx, iotlbentry->attrs, r, | ||
87 | + retaddr); | ||
88 | } | ||
89 | if (locked) { | ||
90 | qemu_mutex_unlock_iothread(); | ||
91 | @@ -XXX,XX +XXX,XX @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, | ||
92 | * access type. | ||
93 | */ | 45 | */ |
94 | 46 | ||
95 | -static inline uint64_t handle_bswap(uint64_t val, int size, bool big_endian) | 47 | -#include "host/atomic128-cas.h" |
96 | +static inline uint64_t handle_bswap(uint64_t val, MemOp op) | 48 | +#include "host/atomic128-cas.h.inc" |
97 | { | 49 | #include "host/atomic128-ldst.h" |
98 | - if ((big_endian && NEED_BE_BSWAP) || (!big_endian && NEED_LE_BSWAP)) { | 50 | |
99 | - switch (size) { | 51 | #endif /* QEMU_ATOMIC128_H */ |
100 | - case 1: return val; | 52 | diff --git a/host/include/generic/host/atomic128-cas.h b/host/include/generic/host/atomic128-cas.h.inc |
101 | - case 2: return bswap16(val); | 53 | similarity index 100% |
102 | - case 4: return bswap32(val); | 54 | rename from host/include/generic/host/atomic128-cas.h |
103 | - case 8: return bswap64(val); | 55 | rename to host/include/generic/host/atomic128-cas.h.inc |
104 | + if ((memop_big_endian(op) && NEED_BE_BSWAP) || | ||
105 | + (!memop_big_endian(op) && NEED_LE_BSWAP)) { | ||
106 | + switch (op & MO_SIZE) { | ||
107 | + case MO_8: return val; | ||
108 | + case MO_16: return bswap16(val); | ||
109 | + case MO_32: return bswap32(val); | ||
110 | + case MO_64: return bswap64(val); | ||
111 | default: | ||
112 | g_assert_not_reached(); | ||
113 | } | ||
114 | @@ -XXX,XX +XXX,XX @@ typedef uint64_t FullLoadHelper(CPUArchState *env, target_ulong addr, | ||
115 | |||
116 | static inline uint64_t __attribute__((always_inline)) | ||
117 | load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
118 | - uintptr_t retaddr, size_t size, bool big_endian, bool code_read, | ||
119 | + uintptr_t retaddr, MemOp op, bool code_read, | ||
120 | FullLoadHelper *full_load) | ||
121 | { | ||
122 | uintptr_t mmu_idx = get_mmuidx(oi); | ||
123 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
124 | unsigned a_bits = get_alignment_bits(get_memop(oi)); | ||
125 | void *haddr; | ||
126 | uint64_t res; | ||
127 | + size_t size = memop_size(op); | ||
128 | |||
129 | /* Handle CPU specific unaligned behaviour */ | ||
130 | if (addr & ((1 << a_bits) - 1)) { | ||
131 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
132 | |||
133 | /* TODO: Merge bswap into io_readx -> memory_region_dispatch_read. */ | ||
134 | res = io_readx(env, &env_tlb(env)->d[mmu_idx].iotlb[index], | ||
135 | - mmu_idx, addr, retaddr, access_type, size); | ||
136 | - return handle_bswap(res, size, big_endian); | ||
137 | + mmu_idx, addr, retaddr, access_type, op); | ||
138 | + return handle_bswap(res, op); | ||
139 | } | ||
140 | |||
141 | /* Handle slow unaligned access (it spans two pages or IO). */ | ||
142 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
143 | r2 = full_load(env, addr2, oi, retaddr); | ||
144 | shift = (addr & (size - 1)) * 8; | ||
145 | |||
146 | - if (big_endian) { | ||
147 | + if (memop_big_endian(op)) { | ||
148 | /* Big-endian combine. */ | ||
149 | res = (r1 << shift) | (r2 >> ((size * 8) - shift)); | ||
150 | } else { | ||
151 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
152 | |||
153 | do_aligned_access: | ||
154 | haddr = (void *)((uintptr_t)addr + entry->addend); | ||
155 | - switch (size) { | ||
156 | - case 1: | ||
157 | + switch (op) { | ||
158 | + case MO_UB: | ||
159 | res = ldub_p(haddr); | ||
160 | break; | ||
161 | - case 2: | ||
162 | - if (big_endian) { | ||
163 | - res = lduw_be_p(haddr); | ||
164 | - } else { | ||
165 | - res = lduw_le_p(haddr); | ||
166 | - } | ||
167 | + case MO_BEUW: | ||
168 | + res = lduw_be_p(haddr); | ||
169 | break; | ||
170 | - case 4: | ||
171 | - if (big_endian) { | ||
172 | - res = (uint32_t)ldl_be_p(haddr); | ||
173 | - } else { | ||
174 | - res = (uint32_t)ldl_le_p(haddr); | ||
175 | - } | ||
176 | + case MO_LEUW: | ||
177 | + res = lduw_le_p(haddr); | ||
178 | break; | ||
179 | - case 8: | ||
180 | - if (big_endian) { | ||
181 | - res = ldq_be_p(haddr); | ||
182 | - } else { | ||
183 | - res = ldq_le_p(haddr); | ||
184 | - } | ||
185 | + case MO_BEUL: | ||
186 | + res = (uint32_t)ldl_be_p(haddr); | ||
187 | + break; | ||
188 | + case MO_LEUL: | ||
189 | + res = (uint32_t)ldl_le_p(haddr); | ||
190 | + break; | ||
191 | + case MO_BEQ: | ||
192 | + res = ldq_be_p(haddr); | ||
193 | + break; | ||
194 | + case MO_LEQ: | ||
195 | + res = ldq_le_p(haddr); | ||
196 | break; | ||
197 | default: | ||
198 | g_assert_not_reached(); | ||
199 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, | ||
200 | static uint64_t full_ldub_mmu(CPUArchState *env, target_ulong addr, | ||
201 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
202 | { | ||
203 | - return load_helper(env, addr, oi, retaddr, 1, false, false, | ||
204 | - full_ldub_mmu); | ||
205 | + return load_helper(env, addr, oi, retaddr, MO_UB, false, full_ldub_mmu); | ||
206 | } | ||
207 | |||
208 | tcg_target_ulong helper_ret_ldub_mmu(CPUArchState *env, target_ulong addr, | ||
209 | @@ -XXX,XX +XXX,XX @@ tcg_target_ulong helper_ret_ldub_mmu(CPUArchState *env, target_ulong addr, | ||
210 | static uint64_t full_le_lduw_mmu(CPUArchState *env, target_ulong addr, | ||
211 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
212 | { | ||
213 | - return load_helper(env, addr, oi, retaddr, 2, false, false, | ||
214 | + return load_helper(env, addr, oi, retaddr, MO_LEUW, false, | ||
215 | full_le_lduw_mmu); | ||
216 | } | ||
217 | |||
218 | @@ -XXX,XX +XXX,XX @@ tcg_target_ulong helper_le_lduw_mmu(CPUArchState *env, target_ulong addr, | ||
219 | static uint64_t full_be_lduw_mmu(CPUArchState *env, target_ulong addr, | ||
220 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
221 | { | ||
222 | - return load_helper(env, addr, oi, retaddr, 2, true, false, | ||
223 | + return load_helper(env, addr, oi, retaddr, MO_BEUW, false, | ||
224 | full_be_lduw_mmu); | ||
225 | } | ||
226 | |||
227 | @@ -XXX,XX +XXX,XX @@ tcg_target_ulong helper_be_lduw_mmu(CPUArchState *env, target_ulong addr, | ||
228 | static uint64_t full_le_ldul_mmu(CPUArchState *env, target_ulong addr, | ||
229 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
230 | { | ||
231 | - return load_helper(env, addr, oi, retaddr, 4, false, false, | ||
232 | + return load_helper(env, addr, oi, retaddr, MO_LEUL, false, | ||
233 | full_le_ldul_mmu); | ||
234 | } | ||
235 | |||
236 | @@ -XXX,XX +XXX,XX @@ tcg_target_ulong helper_le_ldul_mmu(CPUArchState *env, target_ulong addr, | ||
237 | static uint64_t full_be_ldul_mmu(CPUArchState *env, target_ulong addr, | ||
238 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
239 | { | ||
240 | - return load_helper(env, addr, oi, retaddr, 4, true, false, | ||
241 | + return load_helper(env, addr, oi, retaddr, MO_BEUL, false, | ||
242 | full_be_ldul_mmu); | ||
243 | } | ||
244 | |||
245 | @@ -XXX,XX +XXX,XX @@ tcg_target_ulong helper_be_ldul_mmu(CPUArchState *env, target_ulong addr, | ||
246 | uint64_t helper_le_ldq_mmu(CPUArchState *env, target_ulong addr, | ||
247 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
248 | { | ||
249 | - return load_helper(env, addr, oi, retaddr, 8, false, false, | ||
250 | + return load_helper(env, addr, oi, retaddr, MO_LEQ, false, | ||
251 | helper_le_ldq_mmu); | ||
252 | } | ||
253 | |||
254 | uint64_t helper_be_ldq_mmu(CPUArchState *env, target_ulong addr, | ||
255 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
256 | { | ||
257 | - return load_helper(env, addr, oi, retaddr, 8, true, false, | ||
258 | + return load_helper(env, addr, oi, retaddr, MO_BEQ, false, | ||
259 | helper_be_ldq_mmu); | ||
260 | } | ||
261 | |||
262 | @@ -XXX,XX +XXX,XX @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env, target_ulong addr, | ||
263 | |||
264 | static inline void __attribute__((always_inline)) | ||
265 | store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
266 | - TCGMemOpIdx oi, uintptr_t retaddr, size_t size, bool big_endian) | ||
267 | + TCGMemOpIdx oi, uintptr_t retaddr, MemOp op) | ||
268 | { | ||
269 | uintptr_t mmu_idx = get_mmuidx(oi); | ||
270 | uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
271 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
272 | const size_t tlb_off = offsetof(CPUTLBEntry, addr_write); | ||
273 | unsigned a_bits = get_alignment_bits(get_memop(oi)); | ||
274 | void *haddr; | ||
275 | + size_t size = memop_size(op); | ||
276 | |||
277 | /* Handle CPU specific unaligned behaviour */ | ||
278 | if (addr & ((1 << a_bits) - 1)) { | ||
279 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
280 | |||
281 | /* TODO: Merge bswap into io_writex -> memory_region_dispatch_write. */ | ||
282 | io_writex(env, &env_tlb(env)->d[mmu_idx].iotlb[index], mmu_idx, | ||
283 | - handle_bswap(val, size, big_endian), | ||
284 | - addr, retaddr, size); | ||
285 | + handle_bswap(val, op), | ||
286 | + addr, retaddr, op); | ||
287 | return; | ||
288 | } | ||
289 | |||
290 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
291 | */ | ||
292 | for (i = 0; i < size; ++i) { | ||
293 | uint8_t val8; | ||
294 | - if (big_endian) { | ||
295 | + if (memop_big_endian(op)) { | ||
296 | /* Big-endian extract. */ | ||
297 | val8 = val >> (((size - 1) * 8) - (i * 8)); | ||
298 | } else { | ||
299 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
300 | |||
301 | do_aligned_access: | ||
302 | haddr = (void *)((uintptr_t)addr + entry->addend); | ||
303 | - switch (size) { | ||
304 | - case 1: | ||
305 | + switch (op) { | ||
306 | + case MO_UB: | ||
307 | stb_p(haddr, val); | ||
308 | break; | ||
309 | - case 2: | ||
310 | - if (big_endian) { | ||
311 | - stw_be_p(haddr, val); | ||
312 | - } else { | ||
313 | - stw_le_p(haddr, val); | ||
314 | - } | ||
315 | + case MO_BEUW: | ||
316 | + stw_be_p(haddr, val); | ||
317 | break; | ||
318 | - case 4: | ||
319 | - if (big_endian) { | ||
320 | - stl_be_p(haddr, val); | ||
321 | - } else { | ||
322 | - stl_le_p(haddr, val); | ||
323 | - } | ||
324 | + case MO_LEUW: | ||
325 | + stw_le_p(haddr, val); | ||
326 | break; | ||
327 | - case 8: | ||
328 | - if (big_endian) { | ||
329 | - stq_be_p(haddr, val); | ||
330 | - } else { | ||
331 | - stq_le_p(haddr, val); | ||
332 | - } | ||
333 | + case MO_BEUL: | ||
334 | + stl_be_p(haddr, val); | ||
335 | + break; | ||
336 | + case MO_LEUL: | ||
337 | + stl_le_p(haddr, val); | ||
338 | + break; | ||
339 | + case MO_BEQ: | ||
340 | + stq_be_p(haddr, val); | ||
341 | + break; | ||
342 | + case MO_LEQ: | ||
343 | + stq_le_p(haddr, val); | ||
344 | break; | ||
345 | default: | ||
346 | g_assert_not_reached(); | ||
347 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
348 | void helper_ret_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val, | ||
349 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
350 | { | ||
351 | - store_helper(env, addr, val, oi, retaddr, 1, false); | ||
352 | + store_helper(env, addr, val, oi, retaddr, MO_UB); | ||
353 | } | ||
354 | |||
355 | void helper_le_stw_mmu(CPUArchState *env, target_ulong addr, uint16_t val, | ||
356 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
357 | { | ||
358 | - store_helper(env, addr, val, oi, retaddr, 2, false); | ||
359 | + store_helper(env, addr, val, oi, retaddr, MO_LEUW); | ||
360 | } | ||
361 | |||
362 | void helper_be_stw_mmu(CPUArchState *env, target_ulong addr, uint16_t val, | ||
363 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
364 | { | ||
365 | - store_helper(env, addr, val, oi, retaddr, 2, true); | ||
366 | + store_helper(env, addr, val, oi, retaddr, MO_BEUW); | ||
367 | } | ||
368 | |||
369 | void helper_le_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val, | ||
370 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
371 | { | ||
372 | - store_helper(env, addr, val, oi, retaddr, 4, false); | ||
373 | + store_helper(env, addr, val, oi, retaddr, MO_LEUL); | ||
374 | } | ||
375 | |||
376 | void helper_be_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val, | ||
377 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
378 | { | ||
379 | - store_helper(env, addr, val, oi, retaddr, 4, true); | ||
380 | + store_helper(env, addr, val, oi, retaddr, MO_BEUL); | ||
381 | } | ||
382 | |||
383 | void helper_le_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, | ||
384 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
385 | { | ||
386 | - store_helper(env, addr, val, oi, retaddr, 8, false); | ||
387 | + store_helper(env, addr, val, oi, retaddr, MO_LEQ); | ||
388 | } | ||
389 | |||
390 | void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, | ||
391 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
392 | { | ||
393 | - store_helper(env, addr, val, oi, retaddr, 8, true); | ||
394 | + store_helper(env, addr, val, oi, retaddr, MO_BEQ); | ||
395 | } | ||
396 | |||
397 | /* First set of helpers allows passing in of OI and RETADDR. This makes | ||
398 | @@ -XXX,XX +XXX,XX @@ void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, | ||
399 | static uint64_t full_ldub_cmmu(CPUArchState *env, target_ulong addr, | ||
400 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
401 | { | ||
402 | - return load_helper(env, addr, oi, retaddr, 1, false, true, | ||
403 | - full_ldub_cmmu); | ||
404 | + return load_helper(env, addr, oi, retaddr, MO_8, true, full_ldub_cmmu); | ||
405 | } | ||
406 | |||
407 | uint8_t helper_ret_ldb_cmmu(CPUArchState *env, target_ulong addr, | ||
408 | @@ -XXX,XX +XXX,XX @@ uint8_t helper_ret_ldb_cmmu(CPUArchState *env, target_ulong addr, | ||
409 | static uint64_t full_le_lduw_cmmu(CPUArchState *env, target_ulong addr, | ||
410 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
411 | { | ||
412 | - return load_helper(env, addr, oi, retaddr, 2, false, true, | ||
413 | + return load_helper(env, addr, oi, retaddr, MO_LEUW, true, | ||
414 | full_le_lduw_cmmu); | ||
415 | } | ||
416 | |||
417 | @@ -XXX,XX +XXX,XX @@ uint16_t helper_le_ldw_cmmu(CPUArchState *env, target_ulong addr, | ||
418 | static uint64_t full_be_lduw_cmmu(CPUArchState *env, target_ulong addr, | ||
419 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
420 | { | ||
421 | - return load_helper(env, addr, oi, retaddr, 2, true, true, | ||
422 | + return load_helper(env, addr, oi, retaddr, MO_BEUW, true, | ||
423 | full_be_lduw_cmmu); | ||
424 | } | ||
425 | |||
426 | @@ -XXX,XX +XXX,XX @@ uint16_t helper_be_ldw_cmmu(CPUArchState *env, target_ulong addr, | ||
427 | static uint64_t full_le_ldul_cmmu(CPUArchState *env, target_ulong addr, | ||
428 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
429 | { | ||
430 | - return load_helper(env, addr, oi, retaddr, 4, false, true, | ||
431 | + return load_helper(env, addr, oi, retaddr, MO_LEUL, true, | ||
432 | full_le_ldul_cmmu); | ||
433 | } | ||
434 | |||
435 | @@ -XXX,XX +XXX,XX @@ uint32_t helper_le_ldl_cmmu(CPUArchState *env, target_ulong addr, | ||
436 | static uint64_t full_be_ldul_cmmu(CPUArchState *env, target_ulong addr, | ||
437 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
438 | { | ||
439 | - return load_helper(env, addr, oi, retaddr, 4, true, true, | ||
440 | + return load_helper(env, addr, oi, retaddr, MO_BEUL, true, | ||
441 | full_be_ldul_cmmu); | ||
442 | } | ||
443 | |||
444 | @@ -XXX,XX +XXX,XX @@ uint32_t helper_be_ldl_cmmu(CPUArchState *env, target_ulong addr, | ||
445 | uint64_t helper_le_ldq_cmmu(CPUArchState *env, target_ulong addr, | ||
446 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
447 | { | ||
448 | - return load_helper(env, addr, oi, retaddr, 8, false, true, | ||
449 | + return load_helper(env, addr, oi, retaddr, MO_LEQ, true, | ||
450 | helper_le_ldq_cmmu); | ||
451 | } | ||
452 | |||
453 | uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr, | ||
454 | TCGMemOpIdx oi, uintptr_t retaddr) | ||
455 | { | ||
456 | - return load_helper(env, addr, oi, retaddr, 8, true, true, | ||
457 | + return load_helper(env, addr, oi, retaddr, MO_BEQ, true, | ||
458 | helper_be_ldq_cmmu); | ||
459 | } | ||
460 | -- | 56 | -- |
461 | 2.17.1 | 57 | 2.43.0 |
462 | 58 | ||
463 | 59 | diff view generated by jsdifflib |
1 | From: Tony Nguyen <tony.nguyen@bt.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The memory_region_dispatch_{read|write} operand "unsigned size" is | 3 | Since commit 139c1837db ("meson: rename included C source files |
4 | being converted into a "MemOp op". | 4 | to .c.inc"), QEMU standard procedure for included C files is to |
5 | use *.c.inc. | ||
5 | 6 | ||
6 | Convert interfaces by using no-op size_memop. | 7 | Besides, since commit 6a0057aa22 ("docs/devel: make a statement |
8 | about includes") this is documented in the Coding Style: | ||
7 | 9 | ||
8 | After all interfaces are converted, size_memop will be implemented | 10 | If you do use template header files they should be named with |
9 | and the memory_region_dispatch_{read|write} operand "unsigned size" | 11 | the ``.c.inc`` or ``.h.inc`` suffix to make it clear they are |
10 | will be converted into a "MemOp op". | 12 | being included for expansion. |
11 | 13 | ||
12 | As size_memop is a no-op, this patch does not change any behaviour. | 14 | Therefore rename 'atomic128-ldst.h' as 'atomic128-ldst.h.inc'. |
13 | 15 | ||
14 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | 16 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
17 | Message-Id: <e70ff5814ac3656974180db6375397c43b0bc8b8.1566466906.git.tony.nguyen@bt.com> | ||
18 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 17 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
18 | Message-ID: <20241212141018.59428-3-philmd@linaro.org> | ||
19 | --- | 19 | --- |
20 | hw/vfio/pci-quirks.c | 6 ++++-- | 20 | include/qemu/atomic128.h | 2 +- |
21 | 1 file changed, 4 insertions(+), 2 deletions(-) | 21 | .../aarch64/host/{atomic128-ldst.h => atomic128-ldst.h.inc} | 0 |
22 | .../generic/host/{atomic128-ldst.h => atomic128-ldst.h.inc} | 0 | ||
23 | .../loongarch64/host/{atomic128-ldst.h => atomic128-ldst.h.inc} | 0 | ||
24 | .../x86_64/host/{atomic128-ldst.h => atomic128-ldst.h.inc} | 2 +- | ||
25 | host/include/x86_64/host/load-extract-al16-al8.h.inc | 2 +- | ||
26 | 6 files changed, 3 insertions(+), 3 deletions(-) | ||
27 | rename host/include/aarch64/host/{atomic128-ldst.h => atomic128-ldst.h.inc} (100%) | ||
28 | rename host/include/generic/host/{atomic128-ldst.h => atomic128-ldst.h.inc} (100%) | ||
29 | rename host/include/loongarch64/host/{atomic128-ldst.h => atomic128-ldst.h.inc} (100%) | ||
30 | rename host/include/x86_64/host/{atomic128-ldst.h => atomic128-ldst.h.inc} (96%) | ||
22 | 31 | ||
23 | diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c | 32 | diff --git a/include/qemu/atomic128.h b/include/qemu/atomic128.h |
24 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/vfio/pci-quirks.c | 34 | --- a/include/qemu/atomic128.h |
26 | +++ b/hw/vfio/pci-quirks.c | 35 | +++ b/include/qemu/atomic128.h |
27 | @@ -XXX,XX +XXX,XX @@ | 36 | @@ -XXX,XX +XXX,XX @@ |
28 | */ | 37 | */ |
29 | 38 | ||
30 | #include "qemu/osdep.h" | 39 | #include "host/atomic128-cas.h.inc" |
31 | +#include "exec/memop.h" | 40 | -#include "host/atomic128-ldst.h" |
32 | #include "qemu/units.h" | 41 | +#include "host/atomic128-ldst.h.inc" |
33 | #include "qemu/error-report.h" | 42 | |
34 | #include "qemu/main-loop.h" | 43 | #endif /* QEMU_ATOMIC128_H */ |
35 | @@ -XXX,XX +XXX,XX @@ static void vfio_rtl8168_quirk_address_write(void *opaque, hwaddr addr, | 44 | diff --git a/host/include/aarch64/host/atomic128-ldst.h b/host/include/aarch64/host/atomic128-ldst.h.inc |
36 | 45 | similarity index 100% | |
37 | /* Write to the proper guest MSI-X table instead */ | 46 | rename from host/include/aarch64/host/atomic128-ldst.h |
38 | memory_region_dispatch_write(&vdev->pdev.msix_table_mmio, | 47 | rename to host/include/aarch64/host/atomic128-ldst.h.inc |
39 | - offset, val, size, | 48 | diff --git a/host/include/generic/host/atomic128-ldst.h b/host/include/generic/host/atomic128-ldst.h.inc |
40 | + offset, val, size_memop(size), | 49 | similarity index 100% |
41 | MEMTXATTRS_UNSPECIFIED); | 50 | rename from host/include/generic/host/atomic128-ldst.h |
42 | } | 51 | rename to host/include/generic/host/atomic128-ldst.h.inc |
43 | return; /* Do not write guest MSI-X data to hardware */ | 52 | diff --git a/host/include/loongarch64/host/atomic128-ldst.h b/host/include/loongarch64/host/atomic128-ldst.h.inc |
44 | @@ -XXX,XX +XXX,XX @@ static uint64_t vfio_rtl8168_quirk_data_read(void *opaque, | 53 | similarity index 100% |
45 | if (rtl->enabled && (vdev->pdev.cap_present & QEMU_PCI_CAP_MSIX)) { | 54 | rename from host/include/loongarch64/host/atomic128-ldst.h |
46 | hwaddr offset = rtl->addr & 0xfff; | 55 | rename to host/include/loongarch64/host/atomic128-ldst.h.inc |
47 | memory_region_dispatch_read(&vdev->pdev.msix_table_mmio, offset, | 56 | diff --git a/host/include/x86_64/host/atomic128-ldst.h b/host/include/x86_64/host/atomic128-ldst.h.inc |
48 | - &data, size, MEMTXATTRS_UNSPECIFIED); | 57 | similarity index 96% |
49 | + &data, size_memop(size), | 58 | rename from host/include/x86_64/host/atomic128-ldst.h |
50 | + MEMTXATTRS_UNSPECIFIED); | 59 | rename to host/include/x86_64/host/atomic128-ldst.h.inc |
51 | trace_vfio_quirk_rtl8168_msix_read(vdev->vbasedev.name, offset, data); | 60 | index XXXXXXX..XXXXXXX 100644 |
52 | } | 61 | --- a/host/include/x86_64/host/atomic128-ldst.h |
53 | 62 | +++ b/host/include/x86_64/host/atomic128-ldst.h.inc | |
63 | @@ -XXX,XX +XXX,XX @@ static inline void atomic16_set(Int128 *ptr, Int128 val) | ||
64 | } | ||
65 | #else | ||
66 | /* Provide QEMU_ERROR stubs. */ | ||
67 | -#include "host/include/generic/host/atomic128-ldst.h" | ||
68 | +#include "host/include/generic/host/atomic128-ldst.h.inc" | ||
69 | #endif | ||
70 | |||
71 | #endif /* X86_64_ATOMIC128_LDST_H */ | ||
72 | diff --git a/host/include/x86_64/host/load-extract-al16-al8.h.inc b/host/include/x86_64/host/load-extract-al16-al8.h.inc | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/host/include/x86_64/host/load-extract-al16-al8.h.inc | ||
75 | +++ b/host/include/x86_64/host/load-extract-al16-al8.h.inc | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | #define X86_64_LOAD_EXTRACT_AL16_AL8_H | ||
78 | |||
79 | #ifdef CONFIG_INT128_TYPE | ||
80 | -#include "host/atomic128-ldst.h" | ||
81 | +#include "host/atomic128-ldst.h.inc" | ||
82 | |||
83 | /** | ||
84 | * load_atom_extract_al16_or_al8: | ||
54 | -- | 85 | -- |
55 | 2.17.1 | 86 | 2.43.0 |
56 | 87 | ||
57 | 88 | diff view generated by jsdifflib |
1 | From: David Hildenbrand <david@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Let's enforce the interface restriction. | 3 | qatomic_cmpxchg__nocheck() is declared in "qemu/atomic.h". |
4 | Include it in order to avoid when refactoring unrelated headers: | ||
4 | 5 | ||
5 | Signed-off-by: David Hildenbrand <david@redhat.com> | 6 | In file included from ../../accel/tcg/tcg-runtime-gvec.c:22: |
7 | In file included from include/exec/helper-proto-common.h:10: | ||
8 | In file included from include/qemu/atomic128.h:61: | ||
9 | host/include/generic/host/atomic128-cas.h.inc:23:11: error: call to undeclared function 'qatomic_cmpxchg__nocheck'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] | ||
10 | 23 | r.i = qatomic_cmpxchg__nocheck(ptr_align, c.i, n.i); | ||
11 | | ^ | ||
12 | 1 error generated. | ||
13 | |||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-Id: <20190826075112.25637-5-david@redhat.com> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-ID: <20241212141018.59428-4-philmd@linaro.org> | ||
9 | --- | 18 | --- |
10 | accel/tcg/cputlb.c | 2 ++ | 19 | include/qemu/atomic128.h | 1 + |
11 | accel/tcg/user-exec.c | 2 ++ | 20 | 1 file changed, 1 insertion(+) |
12 | 2 files changed, 4 insertions(+) | ||
13 | 21 | ||
14 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | 22 | diff --git a/include/qemu/atomic128.h b/include/qemu/atomic128.h |
15 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/accel/tcg/cputlb.c | 24 | --- a/include/qemu/atomic128.h |
17 | +++ b/accel/tcg/cputlb.c | 25 | +++ b/include/qemu/atomic128.h |
18 | @@ -XXX,XX +XXX,XX @@ void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 26 | @@ -XXX,XX +XXX,XX @@ |
19 | CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); | 27 | #ifndef QEMU_ATOMIC128_H |
20 | target_ulong tlb_addr = tlb_addr_write(entry); | 28 | #define QEMU_ATOMIC128_H |
21 | 29 | ||
22 | + g_assert(-(addr | TARGET_PAGE_MASK) >= size); | 30 | +#include "qemu/atomic.h" |
23 | + | 31 | #include "qemu/int128.h" |
24 | if (unlikely(!tlb_hit(tlb_addr, addr))) { | 32 | |
25 | if (!VICTIM_TLB_HIT(addr_write, addr)) { | 33 | /* |
26 | tlb_fill(env_cpu(env), addr, size, MMU_DATA_STORE, | ||
27 | diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/accel/tcg/user-exec.c | ||
30 | +++ b/accel/tcg/user-exec.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, | ||
32 | void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | ||
33 | uintptr_t retaddr) | ||
34 | { | ||
35 | + g_assert(-(addr | TARGET_PAGE_MASK) >= size); | ||
36 | + | ||
37 | if (!guest_addr_valid(addr) || | ||
38 | page_check_range(addr, size, PAGE_WRITE) < 0) { | ||
39 | CPUState *cpu = env_cpu(env); | ||
40 | -- | 34 | -- |
41 | 2.17.1 | 35 | 2.43.0 |
42 | 36 | ||
43 | 37 | diff view generated by jsdifflib |
1 | From: David Hildenbrand <david@redhat.com> | 1 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
---|---|---|---|
2 | |||
3 | Let size > 0 indicate a promise to write to those bytes. | ||
4 | Check for write watchpoints in the probed range. | ||
5 | |||
6 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: David Hildenbrand <david@redhat.com> | ||
9 | Message-Id: <20190823100741.9621-10-david@redhat.com> | ||
10 | [rth: Recompute index after tlb_fill; check TLB_WATCHPOINT.] | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
12 | --- | 3 | --- |
13 | accel/tcg/cputlb.c | 15 +++++++++++++-- | 4 | accel/tcg/tcg-runtime.c | 8 ++------ |
14 | 1 file changed, 13 insertions(+), 2 deletions(-) | 5 | accel/tcg/meson.build | 2 +- |
6 | 2 files changed, 3 insertions(+), 7 deletions(-) | ||
15 | 7 | ||
16 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | 8 | diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c |
17 | index XXXXXXX..XXXXXXX 100644 | 9 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/accel/tcg/cputlb.c | 10 | --- a/accel/tcg/tcg-runtime.c |
19 | +++ b/accel/tcg/cputlb.c | 11 | +++ b/accel/tcg/tcg-runtime.c |
20 | @@ -XXX,XX +XXX,XX @@ void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 12 | @@ -XXX,XX +XXX,XX @@ |
21 | { | 13 | */ |
22 | uintptr_t index = tlb_index(env, mmu_idx, addr); | 14 | #include "qemu/osdep.h" |
23 | CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); | 15 | #include "qemu/host-utils.h" |
24 | + target_ulong tlb_addr = tlb_addr_write(entry); | 16 | -#include "cpu.h" |
25 | 17 | +#include "exec/cpu-common.h" | |
26 | - if (!tlb_hit(tlb_addr_write(entry), addr)) { | 18 | #include "exec/helper-proto-common.h" |
27 | - /* TLB entry is for a different page */ | 19 | -#include "exec/cpu_ldst.h" |
28 | + if (unlikely(!tlb_hit(tlb_addr, addr))) { | 20 | -#include "exec/exec-all.h" |
29 | if (!VICTIM_TLB_HIT(addr_write, addr)) { | 21 | -#include "disas/disas.h" |
30 | tlb_fill(env_cpu(env), addr, size, MMU_DATA_STORE, | 22 | -#include "exec/log.h" |
31 | mmu_idx, retaddr); | 23 | -#include "tcg/tcg.h" |
32 | + /* TLB resize via tlb_fill may have moved the entry. */ | 24 | +#include "accel/tcg/getpc.h" |
33 | + index = tlb_index(env, mmu_idx, addr); | 25 | |
34 | + entry = tlb_entry(env, mmu_idx, addr); | 26 | #define HELPER_H "accel/tcg/tcg-runtime.h" |
35 | } | 27 | #include "exec/helper-info.c.inc" |
36 | + tlb_addr = tlb_addr_write(entry); | 28 | diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build |
37 | + } | 29 | index XXXXXXX..XXXXXXX 100644 |
38 | + | 30 | --- a/accel/tcg/meson.build |
39 | + /* Handle watchpoints. */ | 31 | +++ b/accel/tcg/meson.build |
40 | + if ((tlb_addr & TLB_WATCHPOINT) && size > 0) { | 32 | @@ -XXX,XX +XXX,XX @@ |
41 | + cpu_check_watchpoint(env_cpu(env), addr, size, | 33 | common_ss.add(when: 'CONFIG_TCG', if_true: files( |
42 | + env_tlb(env)->d[mmu_idx].iotlb[index].attrs, | 34 | 'cpu-exec-common.c', |
43 | + BP_MEM_WRITE, retaddr); | 35 | + 'tcg-runtime.c', |
44 | } | 36 | )) |
45 | } | 37 | tcg_specific_ss = ss.source_set() |
46 | 38 | tcg_specific_ss.add(files( | |
39 | @@ -XXX,XX +XXX,XX @@ tcg_specific_ss.add(files( | ||
40 | 'cpu-exec.c', | ||
41 | 'tb-maint.c', | ||
42 | 'tcg-runtime-gvec.c', | ||
43 | - 'tcg-runtime.c', | ||
44 | 'translate-all.c', | ||
45 | 'translator.c', | ||
46 | )) | ||
47 | -- | 47 | -- |
48 | 2.17.1 | 48 | 2.43.0 |
49 | |||
50 | diff view generated by jsdifflib |
1 | From: Tony Nguyen <tony.nguyen@bt.com> | 1 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
3 | The memory_region_dispatch_{read|write} operand "unsigned size" is | 3 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
4 | being converted into a "MemOp op". | ||
5 | |||
6 | Convert interfaces by using no-op size_memop. | ||
7 | |||
8 | After all interfaces are converted, size_memop will be implemented | ||
9 | and the memory_region_dispatch_{read|write} operand "unsigned size" | ||
10 | will be converted into a "MemOp op". | ||
11 | |||
12 | As size_memop is a no-op, this patch does not change any behaviour. | ||
13 | |||
14 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
17 | Message-Id: <ebf1f78029d5ac1de1739a11d679740a87a1f02f.1566466906.git.tony.nguyen@bt.com> | ||
18 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
19 | --- | 5 | --- |
20 | hw/virtio/virtio-pci.c | 7 +++++-- | 6 | accel/tcg/tcg-runtime-gvec.c | 1 - |
21 | 1 file changed, 5 insertions(+), 2 deletions(-) | 7 | accel/tcg/meson.build | 2 +- |
8 | 2 files changed, 1 insertion(+), 2 deletions(-) | ||
22 | 9 | ||
23 | diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c | 10 | diff --git a/accel/tcg/tcg-runtime-gvec.c b/accel/tcg/tcg-runtime-gvec.c |
24 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/virtio/virtio-pci.c | 12 | --- a/accel/tcg/tcg-runtime-gvec.c |
26 | +++ b/hw/virtio/virtio-pci.c | 13 | +++ b/accel/tcg/tcg-runtime-gvec.c |
27 | @@ -XXX,XX +XXX,XX @@ | 14 | @@ -XXX,XX +XXX,XX @@ |
28 | 15 | ||
29 | #include "qemu/osdep.h" | 16 | #include "qemu/osdep.h" |
30 | 17 | #include "qemu/host-utils.h" | |
31 | +#include "exec/memop.h" | 18 | -#include "cpu.h" |
32 | #include "standard-headers/linux/virtio_pci.h" | 19 | #include "exec/helper-proto-common.h" |
33 | #include "hw/virtio/virtio.h" | 20 | #include "tcg/tcg-gvec-desc.h" |
34 | #include "migration/qemu-file-types.h" | 21 | |
35 | @@ -XXX,XX +XXX,XX @@ void virtio_address_space_write(VirtIOPCIProxy *proxy, hwaddr addr, | 22 | diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build |
36 | /* As length is under guest control, handle illegal values. */ | 23 | index XXXXXXX..XXXXXXX 100644 |
37 | return; | 24 | --- a/accel/tcg/meson.build |
38 | } | 25 | +++ b/accel/tcg/meson.build |
39 | - memory_region_dispatch_write(mr, addr, val, len, MEMTXATTRS_UNSPECIFIED); | 26 | @@ -XXX,XX +XXX,XX @@ |
40 | + memory_region_dispatch_write(mr, addr, val, size_memop(len), | 27 | common_ss.add(when: 'CONFIG_TCG', if_true: files( |
41 | + MEMTXATTRS_UNSPECIFIED); | 28 | 'cpu-exec-common.c', |
42 | } | 29 | 'tcg-runtime.c', |
43 | 30 | + 'tcg-runtime-gvec.c', | |
44 | static void | 31 | )) |
45 | @@ -XXX,XX +XXX,XX @@ virtio_address_space_read(VirtIOPCIProxy *proxy, hwaddr addr, | 32 | tcg_specific_ss = ss.source_set() |
46 | /* Make sure caller aligned buf properly */ | 33 | tcg_specific_ss.add(files( |
47 | assert(!(((uintptr_t)buf) & (len - 1))); | 34 | 'tcg-all.c', |
48 | 35 | 'cpu-exec.c', | |
49 | - memory_region_dispatch_read(mr, addr, &val, len, MEMTXATTRS_UNSPECIFIED); | 36 | 'tb-maint.c', |
50 | + memory_region_dispatch_read(mr, addr, &val, size_memop(len), | 37 | - 'tcg-runtime-gvec.c', |
51 | + MEMTXATTRS_UNSPECIFIED); | 38 | 'translate-all.c', |
52 | switch (len) { | 39 | 'translator.c', |
53 | case 1: | 40 | )) |
54 | pci_set_byte(buf, val); | ||
55 | -- | 41 | -- |
56 | 2.17.1 | 42 | 2.43.0 |
57 | 43 | ||
58 | 44 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Tony Nguyen <tony.nguyen@bt.com> | ||
2 | 1 | ||
3 | The memory_region_dispatch_{read|write} operand "unsigned size" is | ||
4 | being converted into a "MemOp op". | ||
5 | |||
6 | Convert interfaces by using no-op size_memop. | ||
7 | |||
8 | After all interfaces are converted, size_memop will be implemented | ||
9 | and the memory_region_dispatch_{read|write} operand "unsigned size" | ||
10 | will be converted into a "MemOp op". | ||
11 | |||
12 | As size_memop is a no-op, this patch does not change any behaviour. | ||
13 | |||
14 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-Id: <3b042deef0a60dd49ae2320ece92120ba6027f2b.1566466906.git.tony.nguyen@bt.com> | ||
18 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | --- | ||
20 | exec.c | 6 ++++-- | ||
21 | memory_ldst.inc.c | 18 +++++++++--------- | ||
22 | 2 files changed, 13 insertions(+), 11 deletions(-) | ||
23 | |||
24 | diff --git a/exec.c b/exec.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/exec.c | ||
27 | +++ b/exec.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, | ||
29 | /* XXX: could force current_cpu to NULL to avoid | ||
30 | potential bugs */ | ||
31 | val = ldn_p(buf, l); | ||
32 | - result |= memory_region_dispatch_write(mr, addr1, val, l, attrs); | ||
33 | + result |= memory_region_dispatch_write(mr, addr1, val, | ||
34 | + size_memop(l), attrs); | ||
35 | } else { | ||
36 | /* RAM case */ | ||
37 | ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l, false); | ||
38 | @@ -XXX,XX +XXX,XX @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, | ||
39 | /* I/O case */ | ||
40 | release_lock |= prepare_mmio_access(mr); | ||
41 | l = memory_access_size(mr, l, addr1); | ||
42 | - result |= memory_region_dispatch_read(mr, addr1, &val, l, attrs); | ||
43 | + result |= memory_region_dispatch_read(mr, addr1, &val, | ||
44 | + size_memop(l), attrs); | ||
45 | stn_p(buf, l, val); | ||
46 | } else { | ||
47 | /* RAM case */ | ||
48 | diff --git a/memory_ldst.inc.c b/memory_ldst.inc.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/memory_ldst.inc.c | ||
51 | +++ b/memory_ldst.inc.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL, | ||
53 | release_lock |= prepare_mmio_access(mr); | ||
54 | |||
55 | /* I/O case */ | ||
56 | - r = memory_region_dispatch_read(mr, addr1, &val, 4, attrs); | ||
57 | + r = memory_region_dispatch_read(mr, addr1, &val, size_memop(4), attrs); | ||
58 | #if defined(TARGET_WORDS_BIGENDIAN) | ||
59 | if (endian == DEVICE_LITTLE_ENDIAN) { | ||
60 | val = bswap32(val); | ||
61 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL, | ||
62 | release_lock |= prepare_mmio_access(mr); | ||
63 | |||
64 | /* I/O case */ | ||
65 | - r = memory_region_dispatch_read(mr, addr1, &val, 8, attrs); | ||
66 | + r = memory_region_dispatch_read(mr, addr1, &val, size_memop(8), attrs); | ||
67 | #if defined(TARGET_WORDS_BIGENDIAN) | ||
68 | if (endian == DEVICE_LITTLE_ENDIAN) { | ||
69 | val = bswap64(val); | ||
70 | @@ -XXX,XX +XXX,XX @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL, | ||
71 | release_lock |= prepare_mmio_access(mr); | ||
72 | |||
73 | /* I/O case */ | ||
74 | - r = memory_region_dispatch_read(mr, addr1, &val, 1, attrs); | ||
75 | + r = memory_region_dispatch_read(mr, addr1, &val, size_memop(1), attrs); | ||
76 | } else { | ||
77 | /* RAM case */ | ||
78 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
79 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL, | ||
80 | release_lock |= prepare_mmio_access(mr); | ||
81 | |||
82 | /* I/O case */ | ||
83 | - r = memory_region_dispatch_read(mr, addr1, &val, 2, attrs); | ||
84 | + r = memory_region_dispatch_read(mr, addr1, &val, size_memop(2), attrs); | ||
85 | #if defined(TARGET_WORDS_BIGENDIAN) | ||
86 | if (endian == DEVICE_LITTLE_ENDIAN) { | ||
87 | val = bswap16(val); | ||
88 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stl_notdirty, SUFFIX)(ARG1_DECL, | ||
89 | if (l < 4 || !memory_access_is_direct(mr, true)) { | ||
90 | release_lock |= prepare_mmio_access(mr); | ||
91 | |||
92 | - r = memory_region_dispatch_write(mr, addr1, val, 4, attrs); | ||
93 | + r = memory_region_dispatch_write(mr, addr1, val, size_memop(4), attrs); | ||
94 | } else { | ||
95 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
96 | stl_p(ptr, val); | ||
97 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stl_internal, SUFFIX)(ARG1_DECL, | ||
98 | val = bswap32(val); | ||
99 | } | ||
100 | #endif | ||
101 | - r = memory_region_dispatch_write(mr, addr1, val, 4, attrs); | ||
102 | + r = memory_region_dispatch_write(mr, addr1, val, size_memop(4), attrs); | ||
103 | } else { | ||
104 | /* RAM case */ | ||
105 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
106 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stb, SUFFIX)(ARG1_DECL, | ||
107 | mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
108 | if (!memory_access_is_direct(mr, true)) { | ||
109 | release_lock |= prepare_mmio_access(mr); | ||
110 | - r = memory_region_dispatch_write(mr, addr1, val, 1, attrs); | ||
111 | + r = memory_region_dispatch_write(mr, addr1, val, size_memop(1), attrs); | ||
112 | } else { | ||
113 | /* RAM case */ | ||
114 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
115 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stw_internal, SUFFIX)(ARG1_DECL, | ||
116 | val = bswap16(val); | ||
117 | } | ||
118 | #endif | ||
119 | - r = memory_region_dispatch_write(mr, addr1, val, 2, attrs); | ||
120 | + r = memory_region_dispatch_write(mr, addr1, val, size_memop(2), attrs); | ||
121 | } else { | ||
122 | /* RAM case */ | ||
123 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
124 | @@ -XXX,XX +XXX,XX @@ static void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL, | ||
125 | val = bswap64(val); | ||
126 | } | ||
127 | #endif | ||
128 | - r = memory_region_dispatch_write(mr, addr1, val, 8, attrs); | ||
129 | + r = memory_region_dispatch_write(mr, addr1, val, size_memop(8), attrs); | ||
130 | } else { | ||
131 | /* RAM case */ | ||
132 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
133 | -- | ||
134 | 2.17.1 | ||
135 | |||
136 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Tony Nguyen <tony.nguyen@bt.com> | ||
2 | 1 | ||
3 | The memory_region_dispatch_{read|write} operand "unsigned size" is | ||
4 | being converted into a "MemOp op". | ||
5 | |||
6 | Convert interfaces by using no-op size_memop. | ||
7 | |||
8 | After all interfaces are converted, size_memop will be implemented | ||
9 | and the memory_region_dispatch_{read|write} operand "unsigned size" | ||
10 | will be converted into a "MemOp op". | ||
11 | |||
12 | As size_memop is a no-op, this patch does not change any behaviour. | ||
13 | |||
14 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-Id: <c4571c76467ade83660970f7ef9d7292297f1908.1566466906.git.tony.nguyen@bt.com> | ||
18 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | --- | ||
20 | accel/tcg/cputlb.c | 8 ++++---- | ||
21 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
22 | |||
23 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/accel/tcg/cputlb.c | ||
26 | +++ b/accel/tcg/cputlb.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
28 | qemu_mutex_lock_iothread(); | ||
29 | locked = true; | ||
30 | } | ||
31 | - r = memory_region_dispatch_read(mr, mr_offset, | ||
32 | - &val, size, iotlbentry->attrs); | ||
33 | + r = memory_region_dispatch_read(mr, mr_offset, &val, size_memop(size), | ||
34 | + iotlbentry->attrs); | ||
35 | if (r != MEMTX_OK) { | ||
36 | hwaddr physaddr = mr_offset + | ||
37 | section->offset_within_address_space - | ||
38 | @@ -XXX,XX +XXX,XX @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
39 | qemu_mutex_lock_iothread(); | ||
40 | locked = true; | ||
41 | } | ||
42 | - r = memory_region_dispatch_write(mr, mr_offset, | ||
43 | - val, size, iotlbentry->attrs); | ||
44 | + r = memory_region_dispatch_write(mr, mr_offset, val, size_memop(size), | ||
45 | + iotlbentry->attrs); | ||
46 | if (r != MEMTX_OK) { | ||
47 | hwaddr physaddr = mr_offset + | ||
48 | section->offset_within_address_space - | ||
49 | -- | ||
50 | 2.17.1 | ||
51 | |||
52 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Tony Nguyen <tony.nguyen@bt.com> | ||
2 | 1 | ||
3 | Convert memory_region_dispatch_{read|write} operand "unsigned size" | ||
4 | into a "MemOp op". | ||
5 | |||
6 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-Id: <1dd82df5801866743f838f1d046475115a1d32da.1566466906.git.tony.nguyen@bt.com> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | include/exec/memop.h | 22 +++++++++++++++------- | ||
12 | include/exec/memory.h | 9 +++++---- | ||
13 | memory.c | 7 +++++-- | ||
14 | 3 files changed, 25 insertions(+), 13 deletions(-) | ||
15 | |||
16 | diff --git a/include/exec/memop.h b/include/exec/memop.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/exec/memop.h | ||
19 | +++ b/include/exec/memop.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #ifndef MEMOP_H | ||
22 | #define MEMOP_H | ||
23 | |||
24 | +#include "qemu/host-utils.h" | ||
25 | + | ||
26 | typedef enum MemOp { | ||
27 | MO_8 = 0, | ||
28 | MO_16 = 1, | ||
29 | @@ -XXX,XX +XXX,XX @@ typedef enum MemOp { | ||
30 | MO_SSIZE = MO_SIZE | MO_SIGN, | ||
31 | } MemOp; | ||
32 | |||
33 | -/* Size in bytes to MemOp. */ | ||
34 | -static inline unsigned size_memop(unsigned size) | ||
35 | +/* MemOp to size in bytes. */ | ||
36 | +static inline unsigned memop_size(MemOp op) | ||
37 | { | ||
38 | - /* | ||
39 | - * FIXME: No-op to aid conversion of memory_region_dispatch_{read|write} | ||
40 | - * "unsigned size" operand into a "MemOp op". | ||
41 | - */ | ||
42 | - return size; | ||
43 | + return 1 << (op & MO_SIZE); | ||
44 | +} | ||
45 | + | ||
46 | +/* Size in bytes to MemOp. */ | ||
47 | +static inline MemOp size_memop(unsigned size) | ||
48 | +{ | ||
49 | +#ifdef CONFIG_DEBUG_TCG | ||
50 | + /* Power of 2 up to 8. */ | ||
51 | + assert((size & (size - 1)) == 0 && size >= 1 && size <= 8); | ||
52 | +#endif | ||
53 | + return ctz32(size); | ||
54 | } | ||
55 | |||
56 | #endif | ||
57 | diff --git a/include/exec/memory.h b/include/exec/memory.h | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/include/exec/memory.h | ||
60 | +++ b/include/exec/memory.h | ||
61 | @@ -XXX,XX +XXX,XX @@ | ||
62 | #include "exec/cpu-common.h" | ||
63 | #include "exec/hwaddr.h" | ||
64 | #include "exec/memattrs.h" | ||
65 | +#include "exec/memop.h" | ||
66 | #include "exec/ramlist.h" | ||
67 | #include "qemu/bswap.h" | ||
68 | #include "qemu/queue.h" | ||
69 | @@ -XXX,XX +XXX,XX @@ void mtree_info(bool flatview, bool dispatch_tree, bool owner); | ||
70 | * @mr: #MemoryRegion to access | ||
71 | * @addr: address within that region | ||
72 | * @pval: pointer to uint64_t which the data is written to | ||
73 | - * @size: size of the access in bytes | ||
74 | + * @op: size, sign, and endianness of the memory operation | ||
75 | * @attrs: memory transaction attributes to use for the access | ||
76 | */ | ||
77 | MemTxResult memory_region_dispatch_read(MemoryRegion *mr, | ||
78 | hwaddr addr, | ||
79 | uint64_t *pval, | ||
80 | - unsigned size, | ||
81 | + MemOp op, | ||
82 | MemTxAttrs attrs); | ||
83 | /** | ||
84 | * memory_region_dispatch_write: perform a write directly to the specified | ||
85 | @@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_read(MemoryRegion *mr, | ||
86 | * @mr: #MemoryRegion to access | ||
87 | * @addr: address within that region | ||
88 | * @data: data to write | ||
89 | - * @size: size of the access in bytes | ||
90 | + * @op: size, sign, and endianness of the memory operation | ||
91 | * @attrs: memory transaction attributes to use for the access | ||
92 | */ | ||
93 | MemTxResult memory_region_dispatch_write(MemoryRegion *mr, | ||
94 | hwaddr addr, | ||
95 | uint64_t data, | ||
96 | - unsigned size, | ||
97 | + MemOp op, | ||
98 | MemTxAttrs attrs); | ||
99 | |||
100 | /** | ||
101 | diff --git a/memory.c b/memory.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/memory.c | ||
104 | +++ b/memory.c | ||
105 | @@ -XXX,XX +XXX,XX @@ static MemTxResult memory_region_dispatch_read1(MemoryRegion *mr, | ||
106 | MemTxResult memory_region_dispatch_read(MemoryRegion *mr, | ||
107 | hwaddr addr, | ||
108 | uint64_t *pval, | ||
109 | - unsigned size, | ||
110 | + MemOp op, | ||
111 | MemTxAttrs attrs) | ||
112 | { | ||
113 | + unsigned size = memop_size(op); | ||
114 | MemTxResult r; | ||
115 | |||
116 | if (!memory_region_access_valid(mr, addr, size, false, attrs)) { | ||
117 | @@ -XXX,XX +XXX,XX @@ static bool memory_region_dispatch_write_eventfds(MemoryRegion *mr, | ||
118 | MemTxResult memory_region_dispatch_write(MemoryRegion *mr, | ||
119 | hwaddr addr, | ||
120 | uint64_t data, | ||
121 | - unsigned size, | ||
122 | + MemOp op, | ||
123 | MemTxAttrs attrs) | ||
124 | { | ||
125 | + unsigned size = memop_size(op); | ||
126 | + | ||
127 | if (!memory_region_access_valid(mr, addr, size, true, attrs)) { | ||
128 | unassigned_mem_write(mr, addr, data, size); | ||
129 | return MEMTX_DECODE_ERROR; | ||
130 | -- | ||
131 | 2.17.1 | ||
132 | |||
133 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Tony Nguyen <tony.nguyen@bt.com> | ||
2 | 1 | ||
3 | Temporarily no-op size_memop was introduced to aid the conversion of | ||
4 | memory_region_dispatch_{read|write} operand "unsigned size" into | ||
5 | "MemOp op". | ||
6 | |||
7 | Now size_memop is implemented, again hard coded size but with | ||
8 | MO_{8|16|32|64}. This is more expressive and avoids size_memop calls. | ||
9 | |||
10 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
13 | Message-Id: <76dc97273a8eb5e10170ffc16526863df808f487.1566466906.git.tony.nguyen@bt.com> | ||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | --- | ||
16 | hw/s390x/s390-pci-inst.c | 3 +-- | ||
17 | 1 file changed, 1 insertion(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/s390x/s390-pci-inst.c | ||
22 | +++ b/hw/s390x/s390-pci-inst.c | ||
23 | @@ -XXX,XX +XXX,XX @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr, | ||
24 | for (i = 0; i < len / 8; i++) { | ||
25 | result = memory_region_dispatch_write(mr, offset + i * 8, | ||
26 | ldq_p(buffer + i * 8), | ||
27 | - size_memop(8), | ||
28 | - MEMTXATTRS_UNSPECIFIED); | ||
29 | + MO_64, MEMTXATTRS_UNSPECIFIED); | ||
30 | if (result != MEMTX_OK) { | ||
31 | s390_program_interrupt(env, PGM_OPERAND, 6, ra); | ||
32 | return 0; | ||
33 | -- | ||
34 | 2.17.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Tony Nguyen <tony.nguyen@bt.com> | ||
2 | 1 | ||
3 | Temporarily no-op size_memop was introduced to aid the conversion of | ||
4 | memory_region_dispatch_{read|write} operand "unsigned size" into | ||
5 | "MemOp op". | ||
6 | |||
7 | Now size_memop is implemented, again hard coded size but with | ||
8 | MO_{8|16|32|64}. This is more expressive and avoids size_memop calls. | ||
9 | |||
10 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com> | ||
13 | Message-Id: <99c4459d5c1dc9013820be3dbda9798165c15b99.1566466906.git.tony.nguyen@bt.com> | ||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | --- | ||
16 | target/mips/op_helper.c | 4 ++-- | ||
17 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/mips/op_helper.c | ||
22 | +++ b/target/mips/op_helper.c | ||
23 | @@ -XXX,XX +XXX,XX @@ void helper_cache(CPUMIPSState *env, target_ulong addr, uint32_t op) | ||
24 | if (op == 9) { | ||
25 | /* Index Store Tag */ | ||
26 | memory_region_dispatch_write(env->itc_tag, index, env->CP0_TagLo, | ||
27 | - size_memop(8), MEMTXATTRS_UNSPECIFIED); | ||
28 | + MO_64, MEMTXATTRS_UNSPECIFIED); | ||
29 | } else if (op == 5) { | ||
30 | /* Index Load Tag */ | ||
31 | memory_region_dispatch_read(env->itc_tag, index, &env->CP0_TagLo, | ||
32 | - size_memop(8), MEMTXATTRS_UNSPECIFIED); | ||
33 | + MO_64, MEMTXATTRS_UNSPECIFIED); | ||
34 | } | ||
35 | #endif | ||
36 | } | ||
37 | -- | ||
38 | 2.17.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Tony Nguyen <tony.nguyen@bt.com> | ||
2 | 1 | ||
3 | Temporarily no-op size_memop was introduced to aid the conversion of | ||
4 | memory_region_dispatch_{read|write} operand "unsigned size" into | ||
5 | "MemOp op". | ||
6 | |||
7 | Now size_memop is implemented, again hard coded size but with | ||
8 | MO_{8|16|32|64}. This is more expressive and avoids size_memop calls. | ||
9 | |||
10 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-Id: <99f69701cad294db638f84abebc58115e1b9de9a.1566466906.git.tony.nguyen@bt.com> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | --- | ||
15 | memory_ldst.inc.c | 18 +++++++++--------- | ||
16 | 1 file changed, 9 insertions(+), 9 deletions(-) | ||
17 | |||
18 | diff --git a/memory_ldst.inc.c b/memory_ldst.inc.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/memory_ldst.inc.c | ||
21 | +++ b/memory_ldst.inc.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL, | ||
23 | release_lock |= prepare_mmio_access(mr); | ||
24 | |||
25 | /* I/O case */ | ||
26 | - r = memory_region_dispatch_read(mr, addr1, &val, size_memop(4), attrs); | ||
27 | + r = memory_region_dispatch_read(mr, addr1, &val, MO_32, attrs); | ||
28 | #if defined(TARGET_WORDS_BIGENDIAN) | ||
29 | if (endian == DEVICE_LITTLE_ENDIAN) { | ||
30 | val = bswap32(val); | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL, | ||
32 | release_lock |= prepare_mmio_access(mr); | ||
33 | |||
34 | /* I/O case */ | ||
35 | - r = memory_region_dispatch_read(mr, addr1, &val, size_memop(8), attrs); | ||
36 | + r = memory_region_dispatch_read(mr, addr1, &val, MO_64, attrs); | ||
37 | #if defined(TARGET_WORDS_BIGENDIAN) | ||
38 | if (endian == DEVICE_LITTLE_ENDIAN) { | ||
39 | val = bswap64(val); | ||
40 | @@ -XXX,XX +XXX,XX @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL, | ||
41 | release_lock |= prepare_mmio_access(mr); | ||
42 | |||
43 | /* I/O case */ | ||
44 | - r = memory_region_dispatch_read(mr, addr1, &val, size_memop(1), attrs); | ||
45 | + r = memory_region_dispatch_read(mr, addr1, &val, MO_8, attrs); | ||
46 | } else { | ||
47 | /* RAM case */ | ||
48 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
49 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL, | ||
50 | release_lock |= prepare_mmio_access(mr); | ||
51 | |||
52 | /* I/O case */ | ||
53 | - r = memory_region_dispatch_read(mr, addr1, &val, size_memop(2), attrs); | ||
54 | + r = memory_region_dispatch_read(mr, addr1, &val, MO_16, attrs); | ||
55 | #if defined(TARGET_WORDS_BIGENDIAN) | ||
56 | if (endian == DEVICE_LITTLE_ENDIAN) { | ||
57 | val = bswap16(val); | ||
58 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stl_notdirty, SUFFIX)(ARG1_DECL, | ||
59 | if (l < 4 || !memory_access_is_direct(mr, true)) { | ||
60 | release_lock |= prepare_mmio_access(mr); | ||
61 | |||
62 | - r = memory_region_dispatch_write(mr, addr1, val, size_memop(4), attrs); | ||
63 | + r = memory_region_dispatch_write(mr, addr1, val, MO_32, attrs); | ||
64 | } else { | ||
65 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
66 | stl_p(ptr, val); | ||
67 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stl_internal, SUFFIX)(ARG1_DECL, | ||
68 | val = bswap32(val); | ||
69 | } | ||
70 | #endif | ||
71 | - r = memory_region_dispatch_write(mr, addr1, val, size_memop(4), attrs); | ||
72 | + r = memory_region_dispatch_write(mr, addr1, val, MO_32, attrs); | ||
73 | } else { | ||
74 | /* RAM case */ | ||
75 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
76 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stb, SUFFIX)(ARG1_DECL, | ||
77 | mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
78 | if (!memory_access_is_direct(mr, true)) { | ||
79 | release_lock |= prepare_mmio_access(mr); | ||
80 | - r = memory_region_dispatch_write(mr, addr1, val, size_memop(1), attrs); | ||
81 | + r = memory_region_dispatch_write(mr, addr1, val, MO_8, attrs); | ||
82 | } else { | ||
83 | /* RAM case */ | ||
84 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
85 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stw_internal, SUFFIX)(ARG1_DECL, | ||
86 | val = bswap16(val); | ||
87 | } | ||
88 | #endif | ||
89 | - r = memory_region_dispatch_write(mr, addr1, val, size_memop(2), attrs); | ||
90 | + r = memory_region_dispatch_write(mr, addr1, val, MO_16, attrs); | ||
91 | } else { | ||
92 | /* RAM case */ | ||
93 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
94 | @@ -XXX,XX +XXX,XX @@ static void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL, | ||
95 | val = bswap64(val); | ||
96 | } | ||
97 | #endif | ||
98 | - r = memory_region_dispatch_write(mr, addr1, val, size_memop(8), attrs); | ||
99 | + r = memory_region_dispatch_write(mr, addr1, val, MO_64, attrs); | ||
100 | } else { | ||
101 | /* RAM case */ | ||
102 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
103 | -- | ||
104 | 2.17.1 | ||
105 | |||
106 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Tony Nguyen <tony.nguyen@bt.com> | ||
2 | 1 | ||
3 | Notice new attribute, byte swap, and force the transaction through the | ||
4 | memory slow path. | ||
5 | |||
6 | Required by architectures that can invert endianness of memory | ||
7 | transaction, e.g. SPARC64 has the Invert Endian TTE bit. | ||
8 | |||
9 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-Id: <2a10a1f1c00a894af1212c8f68ef09c2966023c1.1566466906.git.tony.nguyen@bt.com> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | --- | ||
15 | include/exec/memattrs.h | 2 ++ | ||
16 | accel/tcg/cputlb.c | 12 ++++++++++++ | ||
17 | 2 files changed, 14 insertions(+) | ||
18 | |||
19 | diff --git a/include/exec/memattrs.h b/include/exec/memattrs.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/include/exec/memattrs.h | ||
22 | +++ b/include/exec/memattrs.h | ||
23 | @@ -XXX,XX +XXX,XX @@ typedef struct MemTxAttrs { | ||
24 | unsigned int user:1; | ||
25 | /* Requester ID (for MSI for example) */ | ||
26 | unsigned int requester_id:16; | ||
27 | + /* Invert endianness for this page */ | ||
28 | + unsigned int byte_swap:1; | ||
29 | /* | ||
30 | * The following are target-specific page-table bits. These are not | ||
31 | * related to actual memory transactions at all. However, this structure | ||
32 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/accel/tcg/cputlb.c | ||
35 | +++ b/accel/tcg/cputlb.c | ||
36 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | ||
37 | */ | ||
38 | address |= TLB_RECHECK; | ||
39 | } | ||
40 | + if (attrs.byte_swap) { | ||
41 | + /* Force the access through the I/O slow path. */ | ||
42 | + address |= TLB_MMIO; | ||
43 | + } | ||
44 | if (!memory_region_is_ram(section->mr) && | ||
45 | !memory_region_is_romd(section->mr)) { | ||
46 | /* IO memory case */ | ||
47 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
48 | bool locked = false; | ||
49 | MemTxResult r; | ||
50 | |||
51 | + if (iotlbentry->attrs.byte_swap) { | ||
52 | + op ^= MO_BSWAP; | ||
53 | + } | ||
54 | + | ||
55 | section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); | ||
56 | mr = section->mr; | ||
57 | mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; | ||
58 | @@ -XXX,XX +XXX,XX @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
59 | bool locked = false; | ||
60 | MemTxResult r; | ||
61 | |||
62 | + if (iotlbentry->attrs.byte_swap) { | ||
63 | + op ^= MO_BSWAP; | ||
64 | + } | ||
65 | + | ||
66 | section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); | ||
67 | mr = section->mr; | ||
68 | mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; | ||
69 | -- | ||
70 | 2.17.1 | ||
71 | |||
72 | diff view generated by jsdifflib |
1 | From: Tony Nguyen <tony.nguyen@bt.com> | 1 | The third argument of the syscall contains the size of the |
---|---|---|---|
2 | cpu mask in bytes, not bits. Nor is the size rounded up to | ||
3 | a multiple of sizeof(abi_ulong). | ||
2 | 4 | ||
3 | Append MemTxAttrs to interfaces so we can pass along up coming Invert | 5 | Cc: qemu-stable@nongnu.org |
4 | Endian TTE bit on SPARC64. | 6 | Reported-by: Andreas Schwab <schwab@suse.de> |
5 | 7 | Fixes: 9e1c7d982d7 ("linux-user/riscv: Add syscall riscv_hwprobe") | |
6 | Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-Id: <f8fcc3138570c460ef289a6b34ba7715ba36f99e.1566466906.git.tony.nguyen@bt.com> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | --- | 9 | --- |
11 | target/sparc/mmu_helper.c | 32 ++++++++++++++++++-------------- | 10 | linux-user/syscall.c | 55 +++++++++++++++++++++++--------------------- |
12 | 1 file changed, 18 insertions(+), 14 deletions(-) | 11 | 1 file changed, 29 insertions(+), 26 deletions(-) |
13 | 12 | ||
14 | diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c | 13 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/sparc/mmu_helper.c | 15 | --- a/linux-user/syscall.c |
17 | +++ b/target/sparc/mmu_helper.c | 16 | +++ b/linux-user/syscall.c |
18 | @@ -XXX,XX +XXX,XX @@ static const int perm_table[2][8] = { | 17 | @@ -XXX,XX +XXX,XX @@ static void risc_hwprobe_fill_pairs(CPURISCVState *env, |
19 | }; | ||
20 | |||
21 | static int get_physical_address(CPUSPARCState *env, hwaddr *physical, | ||
22 | - int *prot, int *access_index, | ||
23 | + int *prot, int *access_index, MemTxAttrs *attrs, | ||
24 | target_ulong address, int rw, int mmu_idx, | ||
25 | target_ulong *page_size) | ||
26 | { | ||
27 | @@ -XXX,XX +XXX,XX @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
28 | target_ulong vaddr; | ||
29 | target_ulong page_size; | ||
30 | int error_code = 0, prot, access_index; | ||
31 | + MemTxAttrs attrs = {}; | ||
32 | |||
33 | /* | ||
34 | * TODO: If we ever need tlb_vaddr_to_host for this target, | ||
35 | @@ -XXX,XX +XXX,XX @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
36 | assert(!probe); | ||
37 | |||
38 | address &= TARGET_PAGE_MASK; | ||
39 | - error_code = get_physical_address(env, &paddr, &prot, &access_index, | ||
40 | + error_code = get_physical_address(env, &paddr, &prot, &access_index, &attrs, | ||
41 | address, access_type, | ||
42 | mmu_idx, &page_size); | ||
43 | vaddr = address; | ||
44 | @@ -XXX,XX +XXX,XX @@ static inline int ultrasparc_tag_match(SparcTLBEntry *tlb, | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | -static int get_physical_address_data(CPUSPARCState *env, | ||
49 | - hwaddr *physical, int *prot, | ||
50 | +static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical, | ||
51 | + int *prot, MemTxAttrs *attrs, | ||
52 | target_ulong address, int rw, int mmu_idx) | ||
53 | { | ||
54 | CPUState *cs = env_cpu(env); | ||
55 | @@ -XXX,XX +XXX,XX @@ static int get_physical_address_data(CPUSPARCState *env, | ||
56 | return 1; | ||
57 | } | ||
58 | |||
59 | -static int get_physical_address_code(CPUSPARCState *env, | ||
60 | - hwaddr *physical, int *prot, | ||
61 | +static int get_physical_address_code(CPUSPARCState *env, hwaddr *physical, | ||
62 | + int *prot, MemTxAttrs *attrs, | ||
63 | target_ulong address, int mmu_idx) | ||
64 | { | ||
65 | CPUState *cs = env_cpu(env); | ||
66 | @@ -XXX,XX +XXX,XX @@ static int get_physical_address_code(CPUSPARCState *env, | ||
67 | } | ||
68 | |||
69 | static int get_physical_address(CPUSPARCState *env, hwaddr *physical, | ||
70 | - int *prot, int *access_index, | ||
71 | + int *prot, int *access_index, MemTxAttrs *attrs, | ||
72 | target_ulong address, int rw, int mmu_idx, | ||
73 | target_ulong *page_size) | ||
74 | { | ||
75 | @@ -XXX,XX +XXX,XX @@ static int get_physical_address(CPUSPARCState *env, hwaddr *physical, | ||
76 | } | ||
77 | |||
78 | if (rw == 2) { | ||
79 | - return get_physical_address_code(env, physical, prot, address, | ||
80 | + return get_physical_address_code(env, physical, prot, attrs, address, | ||
81 | mmu_idx); | ||
82 | } else { | ||
83 | - return get_physical_address_data(env, physical, prot, address, rw, | ||
84 | - mmu_idx); | ||
85 | + return get_physical_address_data(env, physical, prot, attrs, address, | ||
86 | + rw, mmu_idx); | ||
87 | } | 18 | } |
88 | } | 19 | } |
89 | 20 | ||
90 | @@ -XXX,XX +XXX,XX @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | 21 | -static int cpu_set_valid(abi_long arg3, abi_long arg4) |
91 | target_ulong vaddr; | 22 | +/* |
92 | hwaddr paddr; | 23 | + * If the cpumask_t of (target_cpus, cpusetsize) cannot be read: -EFAULT. |
93 | target_ulong page_size; | 24 | + * If the cpumast_t has no bits set: -EINVAL. |
94 | + MemTxAttrs attrs = {}; | 25 | + * Otherwise the cpumask_t contains some bit set: 0. |
95 | int error_code = 0, prot, access_index; | 26 | + * Unlike the kernel, we do not mask cpumask_t by the set of online cpus, |
96 | 27 | + * nor bound the search by cpumask_size(). | |
97 | address &= TARGET_PAGE_MASK; | 28 | + */ |
98 | - error_code = get_physical_address(env, &paddr, &prot, &access_index, | 29 | +static int nonempty_cpu_set(abi_ulong cpusetsize, abi_ptr target_cpus) |
99 | + error_code = get_physical_address(env, &paddr, &prot, &access_index, &attrs, | 30 | { |
100 | address, access_type, | 31 | - int ret, i, tmp; |
101 | mmu_idx, &page_size); | 32 | - size_t host_mask_size, target_mask_size; |
102 | if (likely(error_code == 0)) { | 33 | - unsigned long *host_mask; |
103 | @@ -XXX,XX +XXX,XX @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | 34 | + unsigned char *p = lock_user(VERIFY_READ, target_cpus, cpusetsize, 1); |
104 | env->dmmu.mmu_primary_context, | 35 | + int ret = -TARGET_EFAULT; |
105 | env->dmmu.mmu_secondary_context); | 36 | |
106 | 37 | - /* | |
107 | - tlb_set_page(cs, vaddr, paddr, prot, mmu_idx, page_size); | 38 | - * cpu_set_t represent CPU masks as bit masks of type unsigned long *. |
108 | + tlb_set_page_with_attrs(cs, vaddr, paddr, attrs, prot, mmu_idx, | 39 | - * arg3 contains the cpu count. |
109 | + page_size); | 40 | - */ |
110 | return true; | 41 | - tmp = (8 * sizeof(abi_ulong)); |
42 | - target_mask_size = ((arg3 + tmp - 1) / tmp) * sizeof(abi_ulong); | ||
43 | - host_mask_size = (target_mask_size + (sizeof(*host_mask) - 1)) & | ||
44 | - ~(sizeof(*host_mask) - 1); | ||
45 | - | ||
46 | - host_mask = alloca(host_mask_size); | ||
47 | - | ||
48 | - ret = target_to_host_cpu_mask(host_mask, host_mask_size, | ||
49 | - arg4, target_mask_size); | ||
50 | - if (ret != 0) { | ||
51 | - return ret; | ||
52 | - } | ||
53 | - | ||
54 | - for (i = 0 ; i < host_mask_size / sizeof(*host_mask); i++) { | ||
55 | - if (host_mask[i] != 0) { | ||
56 | - return 0; | ||
57 | + if (p) { | ||
58 | + ret = -TARGET_EINVAL; | ||
59 | + /* | ||
60 | + * Since we only care about the empty/non-empty state of the cpumask_t | ||
61 | + * not the individual bits, we do not need to repartition the bits | ||
62 | + * from target abi_ulong to host unsigned long. | ||
63 | + * | ||
64 | + * Note that the kernel does not round up cpusetsize to a multiple of | ||
65 | + * sizeof(abi_ulong). After bounding cpusetsize by cpumask_size(), | ||
66 | + * it copies exactly cpusetsize bytes into a zeroed buffer. | ||
67 | + */ | ||
68 | + for (abi_ulong i = 0; i < cpusetsize; ++i) { | ||
69 | + if (p[i]) { | ||
70 | + ret = 0; | ||
71 | + break; | ||
72 | + } | ||
73 | } | ||
74 | + unlock_user(p, target_cpus, 0); | ||
111 | } | 75 | } |
112 | if (probe) { | 76 | - return -TARGET_EINVAL; |
113 | @@ -XXX,XX +XXX,XX @@ static int cpu_sparc_get_phys_page(CPUSPARCState *env, hwaddr *phys, | 77 | + return ret; |
114 | { | ||
115 | target_ulong page_size; | ||
116 | int prot, access_index; | ||
117 | + MemTxAttrs attrs = {}; | ||
118 | |||
119 | - return get_physical_address(env, phys, &prot, &access_index, addr, rw, | ||
120 | - mmu_idx, &page_size); | ||
121 | + return get_physical_address(env, phys, &prot, &access_index, &attrs, addr, | ||
122 | + rw, mmu_idx, &page_size); | ||
123 | } | 78 | } |
124 | 79 | ||
125 | #if defined(TARGET_SPARC64) | 80 | static abi_long do_riscv_hwprobe(CPUArchState *cpu_env, abi_long arg1, |
81 | @@ -XXX,XX +XXX,XX @@ static abi_long do_riscv_hwprobe(CPUArchState *cpu_env, abi_long arg1, | ||
82 | |||
83 | /* check cpu_set */ | ||
84 | if (arg3 != 0) { | ||
85 | - ret = cpu_set_valid(arg3, arg4); | ||
86 | + ret = nonempty_cpu_set(arg3, arg4); | ||
87 | if (ret != 0) { | ||
88 | return ret; | ||
89 | } | ||
126 | -- | 90 | -- |
127 | 2.17.1 | 91 | 2.43.0 |
128 | |||
129 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: David Hildenbrand <david@redhat.com> | ||
2 | 1 | ||
3 | We want to perform the same checks in probe_write() to trigger a cpu | ||
4 | exit before doing any modifications. We'll have to pass a PC. | ||
5 | |||
6 | Signed-off-by: David Hildenbrand <david@redhat.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-Id: <20190823100741.9621-9-david@redhat.com> | ||
9 | [rth: Use vaddr for len, like other watchpoint functions; | ||
10 | Move user-only stub to static inline.] | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | include/hw/core/cpu.h | 7 +++++++ | ||
14 | exec.c | 26 ++++++++++++++++++-------- | ||
15 | 2 files changed, 25 insertions(+), 8 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/core/cpu.h | ||
20 | +++ b/include/hw/core/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_watchpoint_remove_by_ref(CPUState *cpu, | ||
22 | static inline void cpu_watchpoint_remove_all(CPUState *cpu, int mask) | ||
23 | { | ||
24 | } | ||
25 | + | ||
26 | +static inline void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, | ||
27 | + MemTxAttrs atr, int fl, uintptr_t ra) | ||
28 | +{ | ||
29 | +} | ||
30 | #else | ||
31 | int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, | ||
32 | int flags, CPUWatchpoint **watchpoint); | ||
33 | @@ -XXX,XX +XXX,XX @@ int cpu_watchpoint_remove(CPUState *cpu, vaddr addr, | ||
34 | vaddr len, int flags); | ||
35 | void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint); | ||
36 | void cpu_watchpoint_remove_all(CPUState *cpu, int mask); | ||
37 | +void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, | ||
38 | + MemTxAttrs attrs, int flags, uintptr_t ra); | ||
39 | #endif | ||
40 | |||
41 | /** | ||
42 | diff --git a/exec.c b/exec.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/exec.c | ||
45 | +++ b/exec.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps notdirty_mem_ops = { | ||
47 | }; | ||
48 | |||
49 | /* Generate a debug exception if a watchpoint has been hit. */ | ||
50 | -static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) | ||
51 | +void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, | ||
52 | + MemTxAttrs attrs, int flags, uintptr_t ra) | ||
53 | { | ||
54 | - CPUState *cpu = current_cpu; | ||
55 | CPUClass *cc = CPU_GET_CLASS(cpu); | ||
56 | - target_ulong vaddr; | ||
57 | CPUWatchpoint *wp; | ||
58 | |||
59 | assert(tcg_enabled()); | ||
60 | @@ -XXX,XX +XXX,XX @@ static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) | ||
61 | cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); | ||
62 | return; | ||
63 | } | ||
64 | - vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset; | ||
65 | - vaddr = cc->adjust_watchpoint_address(cpu, vaddr, len); | ||
66 | + | ||
67 | + addr = cc->adjust_watchpoint_address(cpu, addr, len); | ||
68 | QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { | ||
69 | - if (cpu_watchpoint_address_matches(wp, vaddr, len) | ||
70 | + if (cpu_watchpoint_address_matches(wp, addr, len) | ||
71 | && (wp->flags & flags)) { | ||
72 | if (flags == BP_MEM_READ) { | ||
73 | wp->flags |= BP_WATCHPOINT_HIT_READ; | ||
74 | } else { | ||
75 | wp->flags |= BP_WATCHPOINT_HIT_WRITE; | ||
76 | } | ||
77 | - wp->hitaddr = vaddr; | ||
78 | + wp->hitaddr = MAX(addr, wp->vaddr); | ||
79 | wp->hitattrs = attrs; | ||
80 | if (!cpu->watchpoint_hit) { | ||
81 | if (wp->flags & BP_CPU && | ||
82 | @@ -XXX,XX +XXX,XX @@ static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) | ||
83 | if (wp->flags & BP_STOP_BEFORE_ACCESS) { | ||
84 | cpu->exception_index = EXCP_DEBUG; | ||
85 | mmap_unlock(); | ||
86 | - cpu_loop_exit(cpu); | ||
87 | + cpu_loop_exit_restore(cpu, ra); | ||
88 | } else { | ||
89 | /* Force execution of one insn next time. */ | ||
90 | cpu->cflags_next_tb = 1 | curr_cflags(); | ||
91 | mmap_unlock(); | ||
92 | + if (ra) { | ||
93 | + cpu_restore_state(cpu, ra, true); | ||
94 | + } | ||
95 | cpu_loop_exit_noexc(cpu); | ||
96 | } | ||
97 | } | ||
98 | @@ -XXX,XX +XXX,XX @@ static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) | ||
99 | } | ||
100 | } | ||
101 | |||
102 | +static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) | ||
103 | +{ | ||
104 | + CPUState *cpu = current_cpu; | ||
105 | + vaddr addr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset; | ||
106 | + | ||
107 | + cpu_check_watchpoint(cpu, addr, len, attrs, flags, 0); | ||
108 | +} | ||
109 | + | ||
110 | /* Watchpoint access routines. Watchpoints are inserted using TLB tricks, | ||
111 | so these check for a hit then pass through to the normal out-of-line | ||
112 | phys routines. */ | ||
113 | -- | ||
114 | 2.17.1 | ||
115 | |||
116 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We are currently passing the size of the full write to | ||
2 | the tlb_fill for the second page. Instead pass the real | ||
3 | size of the write to that page. | ||
4 | 1 | ||
5 | This argument is unused within all tlb_fill, except to be | ||
6 | logged via tracing, so in practice this makes no difference. | ||
7 | |||
8 | But in a moment we'll need the value of size2 for watchpoints, | ||
9 | and if we've computed the value we might as well use it. | ||
10 | |||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Reviewed-by: David Hildenbrand <david@redhat.com> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | --- | ||
15 | accel/tcg/cputlb.c | 5 ++++- | ||
16 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
17 | |||
18 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/accel/tcg/cputlb.c | ||
21 | +++ b/accel/tcg/cputlb.c | ||
22 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
23 | uintptr_t index2; | ||
24 | CPUTLBEntry *entry2; | ||
25 | target_ulong page2, tlb_addr2; | ||
26 | + size_t size2; | ||
27 | + | ||
28 | do_unaligned_access: | ||
29 | /* | ||
30 | * Ensure the second page is in the TLB. Note that the first page | ||
31 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
32 | * cannot evict the first. | ||
33 | */ | ||
34 | page2 = (addr + size) & TARGET_PAGE_MASK; | ||
35 | + size2 = (addr + size) & ~TARGET_PAGE_MASK; | ||
36 | index2 = tlb_index(env, mmu_idx, page2); | ||
37 | entry2 = tlb_entry(env, mmu_idx, page2); | ||
38 | tlb_addr2 = tlb_addr_write(entry2); | ||
39 | if (!tlb_hit_page(tlb_addr2, page2) | ||
40 | && !victim_tlb_hit(env, mmu_idx, index2, tlb_off, | ||
41 | page2 & TARGET_PAGE_MASK)) { | ||
42 | - tlb_fill(env_cpu(env), page2, size, MMU_DATA_STORE, | ||
43 | + tlb_fill(env_cpu(env), page2, size2, MMU_DATA_STORE, | ||
44 | mmu_idx, retaddr); | ||
45 | } | ||
46 | |||
47 | -- | ||
48 | 2.17.1 | ||
49 | |||
50 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We have already aligned page2 to the start of the next page. | ||
2 | There is no reason to do that a second time. | ||
3 | 1 | ||
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
5 | Reviewed-by: David Hildenbrand <david@redhat.com> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | accel/tcg/cputlb.c | 3 +-- | ||
9 | 1 file changed, 1 insertion(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/accel/tcg/cputlb.c | ||
14 | +++ b/accel/tcg/cputlb.c | ||
15 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
16 | entry2 = tlb_entry(env, mmu_idx, page2); | ||
17 | tlb_addr2 = tlb_addr_write(entry2); | ||
18 | if (!tlb_hit_page(tlb_addr2, page2) | ||
19 | - && !victim_tlb_hit(env, mmu_idx, index2, tlb_off, | ||
20 | - page2 & TARGET_PAGE_MASK)) { | ||
21 | + && !victim_tlb_hit(env, mmu_idx, index2, tlb_off, page2)) { | ||
22 | tlb_fill(env_cpu(env), page2, size2, MMU_DATA_STORE, | ||
23 | mmu_idx, retaddr); | ||
24 | } | ||
25 | -- | ||
26 | 2.17.1 | ||
27 | |||
28 | diff view generated by jsdifflib |