1
The following changes since commit 035eed4c0d257c905a556fa0f4865a0c077b4e7f:
1
The following changes since commit e93ded1bf6c94ab95015b33e188bc8b0b0c32670:
2
2
3
Merge remote-tracking branch 'remotes/vivier/tags/q800-for-5.0-pull-request' into staging (2020-01-07 17:08:21 +0000)
3
Merge tag 'testing-pull-request-2022-08-30' of https://gitlab.com/thuth/qemu into staging (2022-08-31 18:19:03 -0400)
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-20200108
7
https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20220901
8
8
9
for you to fetch changes up to 5e7ef51cbe47e726f76bfbc208e167085cf398c4:
9
for you to fetch changes up to 20011be2e30b8aa8ef1fc258485f00c688703deb:
10
10
11
MAINTAINERS: Replace Claudio Fontana for tcg/aarch64 (2020-01-08 11:54:12 +1100)
11
target/riscv: Make translator stop before the end of a page (2022-09-01 07:43:08 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Improve -static and -pie linking
14
Respect PROT_EXEC in user-only mode.
15
Add cpu_{ld,st}*_mmuidx_ra
15
Fix s390x, i386 and riscv for translations crossing a page.
16
Remove MMU_MODE*_SUFFIX
17
Move tcg headers under include/
18
16
19
----------------------------------------------------------------
17
----------------------------------------------------------------
20
Philippe Mathieu-Daudé (4):
18
Ilya Leoshkevich (4):
21
tcg: Search includes from the project root source directory
19
linux-user: Clear translations on mprotect()
22
tcg: Search includes in the parent source directory
20
accel/tcg: Introduce is_same_page()
23
tcg: Move TCG headers to include/tcg/
21
target/s390x: Make translator stop before the end of a page
24
configure: Remove tcg/ from the preprocessor include search list
22
target/i386: Make translator stop before the end of a page
25
23
26
Richard Henderson (37):
24
Richard Henderson (16):
27
configure: Drop adjustment of textseg
25
linux-user/arm: Mark the commpage executable
28
tcg: Remove softmmu code_gen_buffer fixed address
26
linux-user/hppa: Allocate page zero as a commpage
29
configure: Do not force pie=no for non-x86
27
linux-user/x86_64: Allocate vsyscall page as a commpage
30
configure: Always detect -no-pie toolchain support
28
linux-user: Honor PT_GNU_STACK
31
configure: Unnest detection of -z,relro and -z,now
29
tests/tcg/i386: Move smc_code2 to an executable section
32
configure: Override the os default with --disable-pie
30
accel/tcg: Properly implement get_page_addr_code for user-only
33
configure: Support -static-pie if requested
31
accel/tcg: Unlock mmap_lock after longjmp
34
target/xtensa: Use probe_access for itlb_hit_test
32
accel/tcg: Make tb_htable_lookup static
35
cputlb: Use trace_mem_get_info instead of trace_mem_build_info
33
accel/tcg: Move qemu_ram_addr_from_host_nofail to physmem.c
36
trace: Remove trace_mem_build_info_no_se_[bl]e
34
accel/tcg: Use probe_access_internal for softmmu get_page_addr_code_hostp
37
target/s390x: Include tcg.h in mem_helper.c
35
accel/tcg: Document the faulting lookup in tb_lookup_cmp
38
target/arm: Include tcg.h in sve_helper.c
36
accel/tcg: Remove translator_ldsw
39
accel/tcg: Include tcg.h in tcg-runtime.c
37
accel/tcg: Add pc and host_pc params to gen_intermediate_code
40
linux-user: Include tcg.h in syscall.c
38
accel/tcg: Add fast path for translator_ld*
41
linux-user: Include trace-root.h in syscall-trace.h
39
target/riscv: Add MAX_INSN_LEN and insn_len
42
plugins: Include trace/mem.h in api.c
40
target/riscv: Make translator stop before the end of a page
43
cputlb: Move body of cpu_ldst_template.h out of line
44
translator: Use cpu_ld*_code instead of open-coding
45
cputlb: Rename helper_ret_ld*_cmmu to cpu_ld*_code
46
cputlb: Provide cpu_(ld,st}*_mmuidx_ra for user-only
47
target/i386: Use cpu_*_mmuidx_ra instead of templates
48
cputlb: Expand cpu_ldst_useronly_template.h in user-exec.c
49
target/nios2: Remove MMU_MODE{0,1}_SUFFIX
50
target/alpha: Remove MMU_MODE{0,1}_SUFFIX
51
target/cris: Remove MMU_MODE{0,1}_SUFFIX
52
target/i386: Remove MMU_MODE{0,1,2}_SUFFIX
53
target/microblaze: Remove MMU_MODE{0,1,2}_SUFFIX
54
target/sh4: Remove MMU_MODE{0,1}_SUFFIX
55
target/unicore32: Remove MMU_MODE{0,1}_SUFFIX
56
target/xtensa: Remove MMU_MODE{0,1,2,3}_SUFFIX
57
target/m68k: Use cpu_*_mmuidx_ra instead of MMU_MODE{0,1}_SUFFIX
58
target/mips: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
59
target/s390x: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
60
target/ppc: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
61
cputlb: Remove support for MMU_MODE*_SUFFIX
62
cputlb: Expand cpu_ldst_template.h in cputlb.c
63
MAINTAINERS: Replace Claudio Fontana for tcg/aarch64
64
41
65
Makefile | 2 +-
42
include/elf.h | 1 +
66
accel/tcg/atomic_template.h | 67 ++---
43
include/exec/cpu-common.h | 1 +
67
include/exec/cpu_ldst.h | 446 +++++++++---------------------
44
include/exec/exec-all.h | 89 ++++++++----------------
68
include/exec/cpu_ldst_template.h | 211 --------------
45
include/exec/translator.h | 96 ++++++++++++++++---------
69
include/exec/cpu_ldst_useronly_template.h | 159 -----------
46
linux-user/arm/target_cpu.h | 4 +-
70
include/exec/translator.h | 48 +---
47
linux-user/qemu.h | 1 +
71
{tcg => include/tcg}/tcg-gvec-desc.h | 0
48
accel/tcg/cpu-exec.c | 143 ++++++++++++++++++++------------------
72
{tcg => include/tcg}/tcg-mo.h | 0
49
accel/tcg/cputlb.c | 93 +++++++------------------
73
{tcg => include/tcg}/tcg-op-gvec.h | 0
50
accel/tcg/translate-all.c | 29 ++++----
74
{tcg => include/tcg}/tcg-op.h | 2 +-
51
accel/tcg/translator.c | 135 ++++++++++++++++++++++++++---------
75
{tcg => include/tcg}/tcg-opc.h | 0
52
accel/tcg/user-exec.c | 17 ++++-
76
{tcg => include/tcg}/tcg.h | 33 +--
53
linux-user/elfload.c | 82 ++++++++++++++++++++--
77
include/user/syscall-trace.h | 2 +
54
linux-user/mmap.c | 6 +-
78
target/alpha/cpu.h | 2 -
55
softmmu/physmem.c | 12 ++++
79
target/cris/cpu.h | 2 -
56
target/alpha/translate.c | 5 +-
80
target/i386/cpu.h | 3 -
57
target/arm/translate.c | 5 +-
81
target/m68k/cpu.h | 2 -
58
target/avr/translate.c | 5 +-
82
target/microblaze/cpu.h | 3 -
59
target/cris/translate.c | 5 +-
83
target/mips/cpu.h | 4 -
60
target/hexagon/translate.c | 6 +-
84
target/nios2/cpu.h | 2 -
61
target/hppa/translate.c | 5 +-
85
target/ppc/cpu.h | 2 -
62
target/i386/tcg/translate.c | 71 +++++++++++--------
86
target/s390x/cpu.h | 5 -
63
target/loongarch/translate.c | 6 +-
87
target/sh4/cpu.h | 2 -
64
target/m68k/translate.c | 5 +-
88
target/unicore32/cpu.h | 2 -
65
target/microblaze/translate.c | 5 +-
89
target/xtensa/cpu.h | 4 -
66
target/mips/tcg/translate.c | 5 +-
90
tcg/i386/tcg-target.h | 2 +-
67
target/nios2/translate.c | 5 +-
91
trace/mem-internal.h | 17 --
68
target/openrisc/translate.c | 6 +-
92
accel/tcg/cpu-exec.c | 2 +-
69
target/ppc/translate.c | 5 +-
93
accel/tcg/cputlb.c | 315 ++++++++++++++++-----
70
target/riscv/translate.c | 32 +++++++--
94
accel/tcg/tcg-runtime-gvec.c | 2 +-
71
target/rx/translate.c | 5 +-
95
accel/tcg/tcg-runtime.c | 1 +
72
target/s390x/tcg/translate.c | 20 ++++--
96
accel/tcg/translate-all.c | 39 +--
73
target/sh4/translate.c | 5 +-
97
accel/tcg/user-exec.c | 238 +++++++++++++++-
74
target/sparc/translate.c | 5 +-
98
bsd-user/main.c | 2 +-
75
target/tricore/translate.c | 6 +-
99
cpus.c | 2 +-
76
target/xtensa/translate.c | 6 +-
100
exec.c | 2 +-
77
tests/tcg/i386/test-i386.c | 2 +-
101
linux-user/main.c | 2 +-
78
tests/tcg/riscv64/noexec.c | 79 +++++++++++++++++++++
102
linux-user/syscall.c | 1 +
79
tests/tcg/s390x/noexec.c | 106 ++++++++++++++++++++++++++++
103
plugins/api.c | 1 +
80
tests/tcg/x86_64/noexec.c | 75 ++++++++++++++++++++
104
target/alpha/translate.c | 2 +-
81
tests/tcg/multiarch/noexec.c.inc | 139 ++++++++++++++++++++++++++++++++++++
105
target/arm/helper-a64.c | 2 +-
82
tests/tcg/riscv64/Makefile.target | 1 +
106
target/arm/sve_helper.c | 1 +
83
tests/tcg/s390x/Makefile.target | 1 +
107
target/arm/translate-a64.c | 4 +-
84
tests/tcg/x86_64/Makefile.target | 3 +-
108
target/arm/translate-sve.c | 6 +-
85
43 files changed, 966 insertions(+), 367 deletions(-)
109
target/arm/translate.c | 4 +-
86
create mode 100644 tests/tcg/riscv64/noexec.c
110
target/cris/translate.c | 2 +-
87
create mode 100644 tests/tcg/s390x/noexec.c
111
target/hppa/translate.c | 2 +-
88
create mode 100644 tests/tcg/x86_64/noexec.c
112
target/i386/mem_helper.c | 2 +-
89
create mode 100644 tests/tcg/multiarch/noexec.c.inc
113
target/i386/seg_helper.c | 56 ++--
114
target/i386/translate.c | 2 +-
115
target/lm32/translate.c | 2 +-
116
target/m68k/op_helper.c | 77 ++++--
117
target/m68k/translate.c | 2 +-
118
target/microblaze/translate.c | 2 +-
119
target/mips/op_helper.c | 182 ++++--------
120
target/mips/translate.c | 2 +-
121
target/moxie/translate.c | 2 +-
122
target/nios2/translate.c | 2 +-
123
target/openrisc/translate.c | 2 +-
124
target/ppc/mem_helper.c | 13 +-
125
target/ppc/translate.c | 4 +-
126
target/riscv/cpu_helper.c | 2 +-
127
target/riscv/translate.c | 2 +-
128
target/s390x/mem_helper.c | 11 +-
129
target/s390x/translate.c | 4 +-
130
target/sh4/translate.c | 2 +-
131
target/sparc/ldst_helper.c | 2 +-
132
target/sparc/translate.c | 2 +-
133
target/tilegx/translate.c | 2 +-
134
target/tricore/translate.c | 2 +-
135
target/unicore32/translate.c | 2 +-
136
target/xtensa/mmu_helper.c | 5 +-
137
target/xtensa/translate.c | 2 +-
138
tcg/aarch64/tcg-target.inc.c | 4 +-
139
tcg/arm/tcg-target.inc.c | 4 +-
140
tcg/i386/tcg-target.inc.c | 4 +-
141
tcg/mips/tcg-target.inc.c | 2 +-
142
tcg/optimize.c | 2 +-
143
tcg/ppc/tcg-target.inc.c | 4 +-
144
tcg/riscv/tcg-target.inc.c | 4 +-
145
tcg/s390/tcg-target.inc.c | 4 +-
146
tcg/sparc/tcg-target.inc.c | 2 +-
147
tcg/tcg-common.c | 2 +-
148
tcg/tcg-op-gvec.c | 8 +-
149
tcg/tcg-op-vec.c | 6 +-
150
tcg/tcg-op.c | 6 +-
151
tcg/tcg.c | 2 +-
152
tcg/tci.c | 2 +-
153
MAINTAINERS | 4 +-
154
configure | 117 +++-----
155
docs/devel/loads-stores.rst | 215 ++++++++++----
156
91 files changed, 1075 insertions(+), 1357 deletions(-)
157
delete mode 100644 include/exec/cpu_ldst_template.h
158
delete mode 100644 include/exec/cpu_ldst_useronly_template.h
159
rename {tcg => include/tcg}/tcg-gvec-desc.h (100%)
160
rename {tcg => include/tcg}/tcg-mo.h (100%)
161
rename {tcg => include/tcg}/tcg-op-gvec.h (100%)
162
rename {tcg => include/tcg}/tcg-op.h (99%)
163
rename {tcg => include/tcg}/tcg-opc.h (100%)
164
rename {tcg => include/tcg}/tcg.h (96%)
165
diff view generated by jsdifflib
Deleted patch
1
This adjustment was random and unnecessary. The user mode
2
startup code in probe_guest_base() will choose a value for
3
guest_base that allows the host qemu binary to not conflict
4
with the guest binary.
5
1
6
With modern distributions, this isn't even used, as the default
7
is PIE, which does the same job in a more portable way.
8
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Thomas Huth <thuth@redhat.com>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
---
13
v2: Remove mention of config-host.ld from make distclean
14
---
15
Makefile | 2 +-
16
configure | 47 -----------------------------------------------
17
2 files changed, 1 insertion(+), 48 deletions(-)
18
19
diff --git a/Makefile b/Makefile
20
index XXXXXXX..XXXXXXX 100644
21
--- a/Makefile
22
+++ b/Makefile
23
@@ -XXX,XX +XXX,XX @@ rm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(M
24
endef
25
26
distclean: clean
27
-    rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
28
+    rm -f config-host.mak config-host.h* $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
29
    rm -f tests/tcg/config-*.mak
30
    rm -f config-all-devices.mak config-all-disas.mak config.status
31
    rm -f $(SUBDIR_DEVICES_MAK)
32
diff --git a/configure b/configure
33
index XXXXXXX..XXXXXXX 100755
34
--- a/configure
35
+++ b/configure
36
@@ -XXX,XX +XXX,XX @@ if test "$cpu" = "s390x" ; then
37
fi
38
fi
39
40
-# Probe for the need for relocating the user-only binary.
41
-if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
42
- textseg_addr=
43
- case "$cpu" in
44
- arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
45
- # ??? Rationale for choosing this address
46
- textseg_addr=0x60000000
47
- ;;
48
- mips)
49
- # A 256M aligned address, high in the address space, with enough
50
- # room for the code_gen_buffer above it before the stack.
51
- textseg_addr=0x60000000
52
- ;;
53
- esac
54
- if [ -n "$textseg_addr" ]; then
55
- cat > $TMPC <<EOF
56
- int main(void) { return 0; }
57
-EOF
58
- textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
59
- if ! compile_prog "" "$textseg_ldflags"; then
60
- # In case ld does not support -Ttext-segment, edit the default linker
61
- # script via sed to set the .text start addr. This is needed on FreeBSD
62
- # at least.
63
- if ! $ld --verbose >/dev/null 2>&1; then
64
- error_exit \
65
- "We need to link the QEMU user mode binaries at a" \
66
- "specific text address. Unfortunately your linker" \
67
- "doesn't support either the -Ttext-segment option or" \
68
- "printing the default linker script with --verbose." \
69
- "If you don't want the user mode binaries, pass the" \
70
- "--disable-user option to configure."
71
- fi
72
-
73
- $ld --verbose | sed \
74
- -e '1,/==================================================/d' \
75
- -e '/==================================================/,$d' \
76
- -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
77
- -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
78
- textseg_ldflags="-Wl,-T../config-host.ld"
79
- fi
80
- fi
81
-fi
82
-
83
# Check that the C++ compiler exists and works with the C compiler.
84
# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
85
if has $cxx; then
86
@@ -XXX,XX +XXX,XX @@ if test "$gprof" = "yes" ; then
87
fi
88
fi
89
90
-if test "$target_linux_user" = "yes" || test "$target_bsd_user" = "yes" ; then
91
- ldflags="$ldflags $textseg_ldflags"
92
-fi
93
-
94
# Newer kernels on s390 check for an S390_PGSTE program header and
95
# enable the pgste page table extensions in that case. This makes
96
# the vm.allocate_pgste sysctl unnecessary. We enable this program
97
--
98
2.20.1
99
100
diff view generated by jsdifflib
1
There are only two uses. Within dcbz_common, the local variable
1
We're about to start validating PAGE_EXEC, which means
2
mmu_idx already contains the epid computation, and we can avoid
2
that we've got to mark the commpage executable. We had
3
repeating it for the store. Within helper_icbiep, the usage is
3
been placing the commpage outside of reserved_va, which
4
trivially expanded using PPC_TLB_EPID_LOAD.
4
was incorrect and lead to an abort.
5
5
6
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
7
Acked-by: David Gibson <david@gibson.dropbear.id.au>
7
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
8
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
---
9
---
11
target/ppc/cpu.h | 2 --
10
linux-user/arm/target_cpu.h | 4 ++--
12
target/ppc/mem_helper.c | 11 ++---------
11
linux-user/elfload.c | 6 +++++-
13
2 files changed, 2 insertions(+), 11 deletions(-)
12
2 files changed, 7 insertions(+), 3 deletions(-)
14
13
15
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
14
diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/target/ppc/cpu.h
16
--- a/linux-user/arm/target_cpu.h
18
+++ b/target/ppc/cpu.h
17
+++ b/linux-user/arm/target_cpu.h
19
@@ -XXX,XX +XXX,XX @@ struct ppc_radix_page_info {
18
@@ -XXX,XX +XXX,XX @@ static inline unsigned long arm_max_reserved_va(CPUState *cs)
20
* + real/paged mode combinations. The other two modes are for
21
* external PID load/store.
22
*/
23
-#define MMU_MODE8_SUFFIX _epl
24
-#define MMU_MODE9_SUFFIX _eps
25
#define PPC_TLB_EPID_LOAD 8
26
#define PPC_TLB_EPID_STORE 9
27
28
diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/ppc/mem_helper.c
31
+++ b/target/ppc/mem_helper.c
32
@@ -XXX,XX +XXX,XX @@ static void dcbz_common(CPUPPCState *env, target_ulong addr,
33
} else {
19
} else {
34
/* Slow path */
20
/*
35
for (i = 0; i < dcbz_size; i += 8) {
21
* We need to be able to map the commpage.
36
- if (epid) {
22
- * See validate_guest_space in linux-user/elfload.c.
37
-#if !defined(CONFIG_USER_ONLY)
23
+ * See init_guest_commpage in linux-user/elfload.c.
38
- /* Does not make sense on USER_ONLY config */
24
*/
39
- cpu_stq_eps_ra(env, addr + i, 0, retaddr);
25
- return 0xffff0000ul;
40
-#endif
26
+ return 0xfffffffful;
41
- } else {
42
- cpu_stq_data_ra(env, addr + i, 0, retaddr);
43
- }
44
+ cpu_stq_mmuidx_ra(env, addr + i, 0, mmu_idx, retaddr);
45
}
46
}
27
}
47
}
28
}
48
@@ -XXX,XX +XXX,XX @@ void helper_icbiep(CPUPPCState *env, target_ulong addr)
29
#define MAX_RESERVED_VA arm_max_reserved_va
49
#if !defined(CONFIG_USER_ONLY)
30
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
50
/* See comments above */
31
index XXXXXXX..XXXXXXX 100644
51
addr &= ~(env->dcache_line_size - 1);
32
--- a/linux-user/elfload.c
52
- cpu_ldl_epl_ra(env, addr, GETPC());
33
+++ b/linux-user/elfload.c
53
+ cpu_ldl_mmuidx_ra(env, addr, PPC_TLB_EPID_LOAD, GETPC());
34
@@ -XXX,XX +XXX,XX @@ enum {
54
#endif
35
36
static bool init_guest_commpage(void)
37
{
38
- void *want = g2h_untagged(HI_COMMPAGE & -qemu_host_page_size);
39
+ abi_ptr commpage = HI_COMMPAGE & -qemu_host_page_size;
40
+ void *want = g2h_untagged(commpage);
41
void *addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE,
42
MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
43
44
@@ -XXX,XX +XXX,XX @@ static bool init_guest_commpage(void)
45
perror("Protecting guest commpage");
46
exit(EXIT_FAILURE);
47
}
48
+
49
+ page_set_flags(commpage, commpage + qemu_host_page_size,
50
+ PAGE_READ | PAGE_EXEC | PAGE_VALID);
51
return true;
55
}
52
}
56
53
57
--
54
--
58
2.20.1
55
2.34.1
59
60
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
While there are no target-specific nonfaulting probes,
2
generic code may grow some uses at some point.
2
3
3
Cc: Chris Wulff <crwulff@gmail.com>
4
Note that the attrs argument was incorrect -- it should have
4
Cc: Marek Vasut <marex@denx.de>
5
been MEMTXATTRS_UNSPECIFIED. Just use the simpler interface.
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
---
9
target/nios2/cpu.h | 2 --
10
target/avr/helper.c | 46 ++++++++++++++++++++++++++++-----------------
10
1 file changed, 2 deletions(-)
11
1 file changed, 29 insertions(+), 17 deletions(-)
11
12
12
diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
13
diff --git a/target/avr/helper.c b/target/avr/helper.c
13
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
14
--- a/target/nios2/cpu.h
15
--- a/target/avr/helper.c
15
+++ b/target/nios2/cpu.h
16
+++ b/target/avr/helper.c
16
@@ -XXX,XX +XXX,XX @@ void do_nios2_semihosting(CPUNios2State *env);
17
@@ -XXX,XX +XXX,XX @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
17
#define CPU_SAVE_VERSION 1
18
MMUAccessType access_type, int mmu_idx,
18
19
bool probe, uintptr_t retaddr)
19
/* MMU modes definitions */
20
{
20
-#define MMU_MODE0_SUFFIX _kernel
21
- int prot = 0;
21
-#define MMU_MODE1_SUFFIX _user
22
- MemTxAttrs attrs = {};
22
#define MMU_SUPERVISOR_IDX 0
23
+ int prot, page_size = TARGET_PAGE_SIZE;
23
#define MMU_USER_IDX 1
24
uint32_t paddr;
25
26
address &= TARGET_PAGE_MASK;
27
28
if (mmu_idx == MMU_CODE_IDX) {
29
- /* access to code in flash */
30
+ /* Access to code in flash. */
31
paddr = OFFSET_CODE + address;
32
prot = PAGE_READ | PAGE_EXEC;
33
- if (paddr + TARGET_PAGE_SIZE > OFFSET_DATA) {
34
+ if (paddr >= OFFSET_DATA) {
35
+ /*
36
+ * This should not be possible via any architectural operations.
37
+ * There is certainly not an exception that we can deliver.
38
+ * Accept probing that might come from generic code.
39
+ */
40
+ if (probe) {
41
+ return false;
42
+ }
43
error_report("execution left flash memory");
44
abort();
45
}
46
- } else if (address < NUMBER_OF_CPU_REGISTERS + NUMBER_OF_IO_REGISTERS) {
47
- /*
48
- * access to CPU registers, exit and rebuilt this TB to use full access
49
- * incase it touches specially handled registers like SREG or SP
50
- */
51
- AVRCPU *cpu = AVR_CPU(cs);
52
- CPUAVRState *env = &cpu->env;
53
- env->fullacc = 1;
54
- cpu_loop_exit_restore(cs, retaddr);
55
} else {
56
- /* access to memory. nothing special */
57
+ /* Access to memory. */
58
paddr = OFFSET_DATA + address;
59
prot = PAGE_READ | PAGE_WRITE;
60
+ if (address < NUMBER_OF_CPU_REGISTERS + NUMBER_OF_IO_REGISTERS) {
61
+ /*
62
+ * Access to CPU registers, exit and rebuilt this TB to use
63
+ * full access in case it touches specially handled registers
64
+ * like SREG or SP. For probing, set page_size = 1, in order
65
+ * to force tlb_fill to be called for the next access.
66
+ */
67
+ if (probe) {
68
+ page_size = 1;
69
+ } else {
70
+ AVRCPU *cpu = AVR_CPU(cs);
71
+ CPUAVRState *env = &cpu->env;
72
+ env->fullacc = 1;
73
+ cpu_loop_exit_restore(cs, retaddr);
74
+ }
75
+ }
76
}
77
78
- tlb_set_page_with_attrs(cs, address, paddr, attrs, prot,
79
- mmu_idx, TARGET_PAGE_SIZE);
80
-
81
+ tlb_set_page(cs, address, paddr, prot, mmu_idx, page_size);
82
return true;
83
}
24
84
25
--
85
--
26
2.20.1
86
2.34.1
27
87
28
88
diff view generated by jsdifflib
1
Claudio's Huawei address has been defunct for quite a while. In
1
There is no need to go through cc->tcg_ops when
2
we know what value that must have.
2
3
3
https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg06872.html
4
Reviewed-by: Michael Rolnik <mrolnik@gmail.com>
4
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
he asked for his personal address to be removed as well.
6
7
I will take over officially.
8
9
Cc: Claudio Fontana <claudio.fontana@gmail.com>
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
---
7
---
14
MAINTAINERS | 3 +--
8
target/avr/helper.c | 5 ++---
15
1 file changed, 1 insertion(+), 2 deletions(-)
9
1 file changed, 2 insertions(+), 3 deletions(-)
16
10
17
diff --git a/MAINTAINERS b/MAINTAINERS
11
diff --git a/target/avr/helper.c b/target/avr/helper.c
18
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
19
--- a/MAINTAINERS
13
--- a/target/avr/helper.c
20
+++ b/MAINTAINERS
14
+++ b/target/avr/helper.c
21
@@ -XXX,XX +XXX,XX @@ F: plugins/
15
@@ -XXX,XX +XXX,XX @@
22
F: tests/plugin
16
bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
23
17
{
24
AArch64 TCG target
18
bool ret = false;
25
-M: Claudio Fontana <claudio.fontana@huawei.com>
19
- CPUClass *cc = CPU_GET_CLASS(cs);
26
-M: Claudio Fontana <claudio.fontana@gmail.com>
20
AVRCPU *cpu = AVR_CPU(cs);
27
+M: Richard Henderson <richard.henderson@linaro.org>
21
CPUAVRState *env = &cpu->env;
28
S: Maintained
22
29
L: qemu-arm@nongnu.org
23
if (interrupt_request & CPU_INTERRUPT_RESET) {
30
F: tcg/aarch64/
24
if (cpu_interrupts_enabled(env)) {
25
cs->exception_index = EXCP_RESET;
26
- cc->tcg_ops->do_interrupt(cs);
27
+ avr_cpu_do_interrupt(cs);
28
29
cs->interrupt_request &= ~CPU_INTERRUPT_RESET;
30
31
@@ -XXX,XX +XXX,XX @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
32
if (cpu_interrupts_enabled(env) && env->intsrc != 0) {
33
int index = ctz32(env->intsrc);
34
cs->exception_index = EXCP_INT(index);
35
- cc->tcg_ops->do_interrupt(cs);
36
+ avr_cpu_do_interrupt(cs);
37
38
env->intsrc &= env->intsrc - 1; /* clear the interrupt */
39
if (!env->intsrc) {
31
--
40
--
32
2.20.1
41
2.34.1
33
42
34
43
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
We're about to start validating PAGE_EXEC, which means that we've
2
got to mark page zero executable. We had been special casing this
3
entirely within translate.
2
4
3
All the *.inc.c files included by tcg/$TARGET/tcg-target.inc.c
5
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
4
are in tcg/, their parent directory. To simplify the preprocessor
6
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
5
search path, include the relative parent path: '..'.
6
7
Patch created mechanically by running:
8
9
$ for x in tcg-pool.inc.c tcg-ldst.inc.c; do \
10
sed -i "s,#include \"$x\",#include \"../$x\"," \
11
$(git grep -l "#include \"$x\""); \
12
done
13
14
Acked-by: David Gibson <david@gibson.dropbear.id.au> (ppc parts)
15
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
16
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
17
Reviewed-by: Stefan Weil <sw@weilnetz.de>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
20
Message-Id: <20200101112303.20724-3-philmd@redhat.com>
21
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
22
---
8
---
23
tcg/aarch64/tcg-target.inc.c | 4 ++--
9
linux-user/elfload.c | 34 +++++++++++++++++++++++++++++++---
24
tcg/arm/tcg-target.inc.c | 4 ++--
10
1 file changed, 31 insertions(+), 3 deletions(-)
25
tcg/i386/tcg-target.inc.c | 4 ++--
26
tcg/mips/tcg-target.inc.c | 2 +-
27
tcg/ppc/tcg-target.inc.c | 4 ++--
28
tcg/riscv/tcg-target.inc.c | 4 ++--
29
tcg/s390/tcg-target.inc.c | 4 ++--
30
tcg/sparc/tcg-target.inc.c | 2 +-
31
8 files changed, 14 insertions(+), 14 deletions(-)
32
11
33
diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c
12
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
34
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
35
--- a/tcg/aarch64/tcg-target.inc.c
14
--- a/linux-user/elfload.c
36
+++ b/tcg/aarch64/tcg-target.inc.c
15
+++ b/linux-user/elfload.c
37
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@ static inline void init_thread(struct target_pt_regs *regs,
38
* See the COPYING file in the top-level directory for details.
17
regs->gr[31] = infop->entry;
39
*/
40
41
-#include "tcg-pool.inc.c"
42
+#include "../tcg-pool.inc.c"
43
#include "qemu/bitops.h"
44
45
/* We're going to re-use TCGType in setting of the SF bit, which controls
46
@@ -XXX,XX +XXX,XX @@ static void tcg_out_cltz(TCGContext *s, TCGType ext, TCGReg d,
47
}
18
}
48
19
49
#ifdef CONFIG_SOFTMMU
20
+#define LO_COMMPAGE 0
50
-#include "tcg-ldst.inc.c"
21
+
51
+#include "../tcg-ldst.inc.c"
22
+static bool init_guest_commpage(void)
52
23
+{
53
/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr,
24
+ void *want = g2h_untagged(LO_COMMPAGE);
54
* TCGMemOpIdx oi, uintptr_t ra)
25
+ void *addr = mmap(want, qemu_host_page_size, PROT_NONE,
55
diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c
26
+ MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
56
index XXXXXXX..XXXXXXX 100644
27
+
57
--- a/tcg/arm/tcg-target.inc.c
28
+ if (addr == MAP_FAILED) {
58
+++ b/tcg/arm/tcg-target.inc.c
29
+ perror("Allocating guest commpage");
59
@@ -XXX,XX +XXX,XX @@
30
+ exit(EXIT_FAILURE);
60
*/
31
+ }
61
32
+ if (addr != want) {
62
#include "elf.h"
33
+ return false;
63
-#include "tcg-pool.inc.c"
34
+ }
64
+#include "../tcg-pool.inc.c"
35
+
65
36
+ /*
66
int arm_arch = __ARM_ARCH;
37
+ * On Linux, page zero is normally marked execute only + gateway.
67
38
+ * Normal read or write is supposed to fail (thus PROT_NONE above),
68
@@ -XXX,XX +XXX,XX @@ static TCGCond tcg_out_cmp2(TCGContext *s, const TCGArg *args,
39
+ * but specific offsets have kernel code mapped to raise permissions
40
+ * and implement syscalls. Here, simply mark the page executable.
41
+ * Special case the entry points during translation (see do_page_zero).
42
+ */
43
+ page_set_flags(LO_COMMPAGE, LO_COMMPAGE + TARGET_PAGE_SIZE,
44
+ PAGE_EXEC | PAGE_VALID);
45
+ return true;
46
+}
47
+
48
#endif /* TARGET_HPPA */
49
50
#ifdef TARGET_XTENSA
51
@@ -XXX,XX +XXX,XX @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
69
}
52
}
70
53
71
#ifdef CONFIG_SOFTMMU
54
#if defined(HI_COMMPAGE)
72
-#include "tcg-ldst.inc.c"
55
-#define LO_COMMPAGE 0
73
+#include "../tcg-ldst.inc.c"
56
+#define LO_COMMPAGE -1
74
57
#elif defined(LO_COMMPAGE)
75
/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr,
58
#define HI_COMMPAGE 0
76
* int mmu_idx, uintptr_t ra)
59
#else
77
diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c
60
#define HI_COMMPAGE 0
78
index XXXXXXX..XXXXXXX 100644
61
-#define LO_COMMPAGE 0
79
--- a/tcg/i386/tcg-target.inc.c
62
+#define LO_COMMPAGE -1
80
+++ b/tcg/i386/tcg-target.inc.c
63
#define init_guest_commpage() true
81
@@ -XXX,XX +XXX,XX @@
82
* THE SOFTWARE.
83
*/
84
85
-#include "tcg-pool.inc.c"
86
+#include "../tcg-pool.inc.c"
87
88
#ifdef CONFIG_DEBUG_TCG
89
static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
90
@@ -XXX,XX +XXX,XX @@ static void tcg_out_nopn(TCGContext *s, int n)
91
}
92
93
#if defined(CONFIG_SOFTMMU)
94
-#include "tcg-ldst.inc.c"
95
+#include "../tcg-ldst.inc.c"
96
97
/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr,
98
* int mmu_idx, uintptr_t ra)
99
diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c
100
index XXXXXXX..XXXXXXX 100644
101
--- a/tcg/mips/tcg-target.inc.c
102
+++ b/tcg/mips/tcg-target.inc.c
103
@@ -XXX,XX +XXX,XX @@ static void tcg_out_call(TCGContext *s, tcg_insn_unit *arg)
104
}
105
106
#if defined(CONFIG_SOFTMMU)
107
-#include "tcg-ldst.inc.c"
108
+#include "../tcg-ldst.inc.c"
109
110
static void * const qemu_ld_helpers[16] = {
111
[MO_UB] = helper_ret_ldub_mmu,
112
diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c
113
index XXXXXXX..XXXXXXX 100644
114
--- a/tcg/ppc/tcg-target.inc.c
115
+++ b/tcg/ppc/tcg-target.inc.c
116
@@ -XXX,XX +XXX,XX @@
117
*/
118
119
#include "elf.h"
120
-#include "tcg-pool.inc.c"
121
+#include "../tcg-pool.inc.c"
122
123
#if defined _CALL_DARWIN || defined __APPLE__
124
#define TCG_TARGET_CALL_DARWIN
125
@@ -XXX,XX +XXX,XX @@ static const uint32_t qemu_exts_opc[4] = {
126
};
127
128
#if defined (CONFIG_SOFTMMU)
129
-#include "tcg-ldst.inc.c"
130
+#include "../tcg-ldst.inc.c"
131
132
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
133
* int mmu_idx, uintptr_t ra)
134
diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c
135
index XXXXXXX..XXXXXXX 100644
136
--- a/tcg/riscv/tcg-target.inc.c
137
+++ b/tcg/riscv/tcg-target.inc.c
138
@@ -XXX,XX +XXX,XX @@
139
* THE SOFTWARE.
140
*/
141
142
-#include "tcg-pool.inc.c"
143
+#include "../tcg-pool.inc.c"
144
145
#ifdef CONFIG_DEBUG_TCG
146
static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
147
@@ -XXX,XX +XXX,XX @@ static void tcg_out_mb(TCGContext *s, TCGArg a0)
148
*/
149
150
#if defined(CONFIG_SOFTMMU)
151
-#include "tcg-ldst.inc.c"
152
+#include "../tcg-ldst.inc.c"
153
154
/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr,
155
* TCGMemOpIdx oi, uintptr_t ra)
156
diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c
157
index XXXXXXX..XXXXXXX 100644
158
--- a/tcg/s390/tcg-target.inc.c
159
+++ b/tcg/s390/tcg-target.inc.c
160
@@ -XXX,XX +XXX,XX @@
161
#error "unsupported code generation mode"
162
#endif
64
#endif
163
65
164
-#include "tcg-pool.inc.c"
66
@@ -XXX,XX +XXX,XX @@ static void pgb_static(const char *image_name, abi_ulong orig_loaddr,
165
+#include "../tcg-pool.inc.c"
67
} else {
166
#include "elf.h"
68
offset = -(HI_COMMPAGE & -align);
167
69
}
168
/* ??? The translation blocks produced by TCG are generally small enough to
70
- } else if (LO_COMMPAGE != 0) {
169
@@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg data,
71
+ } else if (LO_COMMPAGE != -1) {
170
}
72
loaddr = MIN(loaddr, LO_COMMPAGE & -align);
171
73
}
172
#if defined(CONFIG_SOFTMMU)
74
173
-#include "tcg-ldst.inc.c"
174
+#include "../tcg-ldst.inc.c"
175
176
/* We're expecting to use a 20-bit negative offset on the tlb memory ops. */
177
QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) > 0);
178
diff --git a/tcg/sparc/tcg-target.inc.c b/tcg/sparc/tcg-target.inc.c
179
index XXXXXXX..XXXXXXX 100644
180
--- a/tcg/sparc/tcg-target.inc.c
181
+++ b/tcg/sparc/tcg-target.inc.c
182
@@ -XXX,XX +XXX,XX @@
183
* THE SOFTWARE.
184
*/
185
186
-#include "tcg-pool.inc.c"
187
+#include "../tcg-pool.inc.c"
188
189
#ifdef CONFIG_DEBUG_TCG
190
static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
191
--
75
--
192
2.20.1
76
2.34.1
193
194
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
We're about to start validating PAGE_EXEC, which means that we've
2
got to mark the vsyscall page executable. We had been special
3
casing this entirely within translate.
2
4
3
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
5
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
8
---
8
target/unicore32/cpu.h | 2 --
9
linux-user/elfload.c | 23 +++++++++++++++++++++++
9
1 file changed, 2 deletions(-)
10
1 file changed, 23 insertions(+)
10
11
11
diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
12
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
12
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
13
--- a/target/unicore32/cpu.h
14
--- a/linux-user/elfload.c
14
+++ b/target/unicore32/cpu.h
15
+++ b/linux-user/elfload.c
15
@@ -XXX,XX +XXX,XX @@ void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)
16
@@ -XXX,XX +XXX,XX @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en
16
int uc32_cpu_signal_handler(int host_signum, void *pinfo, void *puc);
17
(*regs)[26] = tswapreg(env->segs[R_GS].selector & 0xffff);
17
18
}
18
/* MMU modes definitions */
19
19
-#define MMU_MODE0_SUFFIX _kernel
20
+#if ULONG_MAX >= TARGET_VSYSCALL_PAGE
20
-#define MMU_MODE1_SUFFIX _user
21
+#define INIT_GUEST_COMMPAGE
21
#define MMU_USER_IDX 1
22
+static bool init_guest_commpage(void)
22
static inline int cpu_mmu_index(CPUUniCore32State *env, bool ifetch)
23
+{
24
+ /*
25
+ * The vsyscall page is at a high negative address aka kernel space,
26
+ * which means that we cannot actually allocate it with target_mmap.
27
+ * We still should be able to use page_set_flags, unless the user
28
+ * has specified -R reserved_va, which would trigger an assert().
29
+ */
30
+ if (reserved_va != 0 &&
31
+ TARGET_VSYSCALL_PAGE + TARGET_PAGE_SIZE >= reserved_va) {
32
+ error_report("Cannot allocate vsyscall page");
33
+ exit(EXIT_FAILURE);
34
+ }
35
+ page_set_flags(TARGET_VSYSCALL_PAGE,
36
+ TARGET_VSYSCALL_PAGE + TARGET_PAGE_SIZE,
37
+ PAGE_EXEC | PAGE_VALID);
38
+ return true;
39
+}
40
+#endif
41
#else
42
43
#define ELF_START_MMAP 0x80000000
44
@@ -XXX,XX +XXX,XX @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
45
#else
46
#define HI_COMMPAGE 0
47
#define LO_COMMPAGE -1
48
+#ifndef INIT_GUEST_COMMPAGE
49
#define init_guest_commpage() true
50
#endif
51
+#endif
52
53
static void pgb_fail_in_use(const char *image_name)
23
{
54
{
24
--
55
--
25
2.20.1
56
2.34.1
26
27
diff view generated by jsdifflib
1
The generated functions aside from *_real are unused.
1
We cannot deliver two interrupts simultaneously;
2
The *_real functions have a couple of users in mem_helper.c;
2
the first interrupt handler must execute first.
3
use *_mmuidx_ra instead, with MMU_REAL_IDX.
4
3
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Reviewed-by: Michael Rolnik <mrolnik@gmail.com>
6
Reviewed-by: David Hildenbrand <david@redhat.com>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
7
---
10
v2: Use *_mmuidx_ra directly, without intermediate macros.
8
target/avr/helper.c | 9 +++------
11
---
9
1 file changed, 3 insertions(+), 6 deletions(-)
12
target/s390x/cpu.h | 5 -----
13
target/s390x/mem_helper.c | 10 +++++-----
14
2 files changed, 5 insertions(+), 10 deletions(-)
15
10
16
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
11
diff --git a/target/avr/helper.c b/target/avr/helper.c
17
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
18
--- a/target/s390x/cpu.h
13
--- a/target/avr/helper.c
19
+++ b/target/s390x/cpu.h
14
+++ b/target/avr/helper.c
20
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@
21
16
22
#define TARGET_INSN_START_EXTRA_WORDS 2
17
bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
23
18
{
24
-#define MMU_MODE0_SUFFIX _primary
19
- bool ret = false;
25
-#define MMU_MODE1_SUFFIX _secondary
20
AVRCPU *cpu = AVR_CPU(cs);
26
-#define MMU_MODE2_SUFFIX _home
21
CPUAVRState *env = &cpu->env;
27
-#define MMU_MODE3_SUFFIX _real
22
23
@@ -XXX,XX +XXX,XX @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
24
avr_cpu_do_interrupt(cs);
25
26
cs->interrupt_request &= ~CPU_INTERRUPT_RESET;
28
-
27
-
29
#define MMU_USER_IDX 0
28
- ret = true;
30
29
+ return true;
31
#define S390_MAX_CPUS 248
32
diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/s390x/mem_helper.c
35
+++ b/target/s390x/mem_helper.c
36
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(testblock)(CPUS390XState *env, uint64_t real_addr)
37
real_addr = wrap_address(env, real_addr) & TARGET_PAGE_MASK;
38
39
for (i = 0; i < TARGET_PAGE_SIZE; i += 8) {
40
- cpu_stq_real_ra(env, real_addr + i, 0, ra);
41
+ cpu_stq_mmuidx_ra(env, real_addr + i, 0, MMU_REAL_IDX, ra);
42
}
43
44
return 0;
45
@@ -XXX,XX +XXX,XX @@ void HELPER(idte)(CPUS390XState *env, uint64_t r1, uint64_t r2, uint32_t m4)
46
for (i = 0; i < entries; i++) {
47
/* addresses are not wrapped in 24/31bit mode but table index is */
48
raddr = table + ((index + i) & 0x7ff) * sizeof(entry);
49
- entry = cpu_ldq_real_ra(env, raddr, ra);
50
+ entry = cpu_ldq_mmuidx_ra(env, raddr, MMU_REAL_IDX, ra);
51
if (!(entry & REGION_ENTRY_I)) {
52
/* we are allowed to not store if already invalid */
53
entry |= REGION_ENTRY_I;
54
- cpu_stq_real_ra(env, raddr, entry, ra);
55
+ cpu_stq_mmuidx_ra(env, raddr, entry, MMU_REAL_IDX, ra);
56
}
57
}
30
}
58
}
31
}
59
@@ -XXX,XX +XXX,XX @@ void HELPER(ipte)(CPUS390XState *env, uint64_t pto, uint64_t vaddr,
32
if (interrupt_request & CPU_INTERRUPT_HARD) {
60
pte_addr += VADDR_PAGE_TX(vaddr) * 8;
33
@@ -XXX,XX +XXX,XX @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
61
34
if (!env->intsrc) {
62
/* Mark the page table entry as invalid */
35
cs->interrupt_request &= ~CPU_INTERRUPT_HARD;
63
- pte = cpu_ldq_real_ra(env, pte_addr, ra);
36
}
64
+ pte = cpu_ldq_mmuidx_ra(env, pte_addr, MMU_REAL_IDX, ra);
37
-
65
pte |= PAGE_ENTRY_I;
38
- ret = true;
66
- cpu_stq_real_ra(env, pte_addr, pte, ra);
39
+ return true;
67
+ cpu_stq_mmuidx_ra(env, pte_addr, pte, MMU_REAL_IDX, ra);
40
}
68
41
}
69
/* XXX we exploit the fact that Linux passes the exact virtual
42
- return ret;
70
address here - it's not obliged to! */
43
+ return false;
44
}
45
46
void avr_cpu_do_interrupt(CPUState *cs)
71
--
47
--
72
2.20.1
48
2.34.1
73
49
74
50
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
This bit is not saved across interrupts, so we must
2
delay delivering the interrupt until the skip has
3
been processed.
2
4
3
All tcg includes are relative to the repository root directory,
5
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1118
4
we can safely remove the tcg/ directory from the include search
6
Reviewed-by: Michael Rolnik <mrolnik@gmail.com>
5
path list.
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
7
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Stefan Weil <sw@weilnetz.de>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Message-Id: <20200101112303.20724-5-philmd@redhat.com>
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
---
9
---
15
configure | 1 -
10
target/avr/helper.c | 9 +++++++++
16
1 file changed, 1 deletion(-)
11
target/avr/translate.c | 26 ++++++++++++++++++++++----
12
2 files changed, 31 insertions(+), 4 deletions(-)
17
13
18
diff --git a/configure b/configure
14
diff --git a/target/avr/helper.c b/target/avr/helper.c
19
index XXXXXXX..XXXXXXX 100755
15
index XXXXXXX..XXXXXXX 100644
20
--- a/configure
16
--- a/target/avr/helper.c
21
+++ b/configure
17
+++ b/target/avr/helper.c
22
@@ -XXX,XX +XXX,XX @@ elif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
18
@@ -XXX,XX +XXX,XX @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
23
else
19
AVRCPU *cpu = AVR_CPU(cs);
24
QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
20
CPUAVRState *env = &cpu->env;
25
fi
21
26
-QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
22
+ /*
27
23
+ * We cannot separate a skip from the next instruction,
28
echo "TOOLS=$tools" >> $config_host_mak
24
+ * as the skip would not be preserved across the interrupt.
29
echo "ROMS=$roms" >> $config_host_mak
25
+ * Separating the two insn normally only happens at page boundaries.
26
+ */
27
+ if (env->skip) {
28
+ return false;
29
+ }
30
+
31
if (interrupt_request & CPU_INTERRUPT_RESET) {
32
if (cpu_interrupts_enabled(env)) {
33
cs->exception_index = EXCP_RESET;
34
diff --git a/target/avr/translate.c b/target/avr/translate.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/target/avr/translate.c
37
+++ b/target/avr/translate.c
38
@@ -XXX,XX +XXX,XX @@ static void avr_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
39
if (skip_label) {
40
canonicalize_skip(ctx);
41
gen_set_label(skip_label);
42
- if (ctx->base.is_jmp == DISAS_NORETURN) {
43
+
44
+ switch (ctx->base.is_jmp) {
45
+ case DISAS_NORETURN:
46
ctx->base.is_jmp = DISAS_CHAIN;
47
+ break;
48
+ case DISAS_NEXT:
49
+ if (ctx->base.tb->flags & TB_FLAGS_SKIP) {
50
+ ctx->base.is_jmp = DISAS_TOO_MANY;
51
+ }
52
+ break;
53
+ default:
54
+ break;
55
}
56
}
57
58
@@ -XXX,XX +XXX,XX @@ static void avr_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
59
{
60
DisasContext *ctx = container_of(dcbase, DisasContext, base);
61
bool nonconst_skip = canonicalize_skip(ctx);
62
+ /*
63
+ * Because we disable interrupts while env->skip is set,
64
+ * we must return to the main loop to re-evaluate afterward.
65
+ */
66
+ bool force_exit = ctx->base.tb->flags & TB_FLAGS_SKIP;
67
68
switch (ctx->base.is_jmp) {
69
case DISAS_NORETURN:
70
@@ -XXX,XX +XXX,XX @@ static void avr_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
71
case DISAS_NEXT:
72
case DISAS_TOO_MANY:
73
case DISAS_CHAIN:
74
- if (!nonconst_skip) {
75
+ if (!nonconst_skip && !force_exit) {
76
/* Note gen_goto_tb checks singlestep. */
77
gen_goto_tb(ctx, 1, ctx->npc);
78
break;
79
@@ -XXX,XX +XXX,XX @@ static void avr_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
80
tcg_gen_movi_tl(cpu_pc, ctx->npc);
81
/* fall through */
82
case DISAS_LOOKUP:
83
- tcg_gen_lookup_and_goto_ptr();
84
- break;
85
+ if (!force_exit) {
86
+ tcg_gen_lookup_and_goto_ptr();
87
+ break;
88
+ }
89
+ /* fall through */
90
case DISAS_EXIT:
91
tcg_gen_exit_tb(NULL, 0);
92
break;
30
--
93
--
31
2.20.1
94
2.34.1
32
95
33
96
diff view generated by jsdifflib
1
The separate suffixed functions were used to construct
1
Map the stack executable if required by default or on demand.
2
some do_##insn function switched on mmu_idx. The interface
3
is exactly identical to the *_mmuidx_ra functions. Replace
4
them directly and remove the constructions.
5
2
6
Cc: Aurelien Jarno <aurelien@aurel32.net>
3
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
7
Cc: Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>
4
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
8
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
---
6
---
13
target/mips/cpu.h | 4 -
7
include/elf.h | 1 +
14
target/mips/op_helper.c | 182 +++++++++++++---------------------------
8
linux-user/qemu.h | 1 +
15
2 files changed, 60 insertions(+), 126 deletions(-)
9
linux-user/elfload.c | 19 ++++++++++++++++++-
10
3 files changed, 20 insertions(+), 1 deletion(-)
16
11
17
diff --git a/target/mips/cpu.h b/target/mips/cpu.h
12
diff --git a/include/elf.h b/include/elf.h
18
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
19
--- a/target/mips/cpu.h
14
--- a/include/elf.h
20
+++ b/target/mips/cpu.h
15
+++ b/include/elf.h
21
@@ -XXX,XX +XXX,XX @@ extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env);
16
@@ -XXX,XX +XXX,XX @@ typedef int64_t Elf64_Sxword;
22
* MMU modes definitions. We carefully match the indices with our
17
#define PT_LOPROC 0x70000000
23
* hflags layout.
18
#define PT_HIPROC 0x7fffffff
24
*/
19
25
-#define MMU_MODE0_SUFFIX _kernel
20
+#define PT_GNU_STACK (PT_LOOS + 0x474e551)
26
-#define MMU_MODE1_SUFFIX _super
21
#define PT_GNU_PROPERTY (PT_LOOS + 0x474e553)
27
-#define MMU_MODE2_SUFFIX _user
22
28
-#define MMU_MODE3_SUFFIX _error
23
#define PT_MIPS_REGINFO 0x70000000
29
#define MMU_USER_IDX 2
24
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
30
31
static inline int hflags_mmu_index(uint32_t hflags)
32
diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c
33
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
34
--- a/target/mips/op_helper.c
26
--- a/linux-user/qemu.h
35
+++ b/target/mips/op_helper.c
27
+++ b/linux-user/qemu.h
36
@@ -XXX,XX +XXX,XX @@ static void raise_exception(CPUMIPSState *env, uint32_t exception)
28
@@ -XXX,XX +XXX,XX @@ struct image_info {
37
do_raise_exception(env, exception, 0);
29
uint32_t elf_flags;
38
}
30
int personality;
39
31
abi_ulong alignment;
40
-#if defined(CONFIG_USER_ONLY)
32
+ bool exec_stack;
41
-#define HELPER_LD(name, insn, type) \
33
42
-static inline type do_##name(CPUMIPSState *env, target_ulong addr, \
34
/* Generic semihosting knows about these pointers. */
43
- int mem_idx, uintptr_t retaddr) \
35
abi_ulong arg_strings; /* strings for argv */
44
-{ \
36
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
45
- return (type) cpu_##insn##_data_ra(env, addr, retaddr); \
37
index XXXXXXX..XXXXXXX 100644
46
-}
38
--- a/linux-user/elfload.c
47
-#else
39
+++ b/linux-user/elfload.c
48
-#define HELPER_LD(name, insn, type) \
40
@@ -XXX,XX +XXX,XX @@ static bool init_guest_commpage(void)
49
-static inline type do_##name(CPUMIPSState *env, target_ulong addr, \
41
#define ELF_ARCH EM_386
50
- int mem_idx, uintptr_t retaddr) \
42
51
-{ \
43
#define ELF_PLATFORM get_elf_platform()
52
- switch (mem_idx) { \
44
+#define EXSTACK_DEFAULT true
53
- case 0: return (type) cpu_##insn##_kernel_ra(env, addr, retaddr); \
45
54
- case 1: return (type) cpu_##insn##_super_ra(env, addr, retaddr); \
46
static const char *get_elf_platform(void)
55
- default: \
56
- case 2: return (type) cpu_##insn##_user_ra(env, addr, retaddr); \
57
- case 3: return (type) cpu_##insn##_error_ra(env, addr, retaddr); \
58
- } \
59
-}
60
-#endif
61
-HELPER_LD(lw, ldl, int32_t)
62
-#if defined(TARGET_MIPS64)
63
-HELPER_LD(ld, ldq, int64_t)
64
-#endif
65
-#undef HELPER_LD
66
-
67
-#if defined(CONFIG_USER_ONLY)
68
-#define HELPER_ST(name, insn, type) \
69
-static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
70
- type val, int mem_idx, uintptr_t retaddr) \
71
-{ \
72
- cpu_##insn##_data_ra(env, addr, val, retaddr); \
73
-}
74
-#else
75
-#define HELPER_ST(name, insn, type) \
76
-static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
77
- type val, int mem_idx, uintptr_t retaddr) \
78
-{ \
79
- switch (mem_idx) { \
80
- case 0: \
81
- cpu_##insn##_kernel_ra(env, addr, val, retaddr); \
82
- break; \
83
- case 1: \
84
- cpu_##insn##_super_ra(env, addr, val, retaddr); \
85
- break; \
86
- default: \
87
- case 2: \
88
- cpu_##insn##_user_ra(env, addr, val, retaddr); \
89
- break; \
90
- case 3: \
91
- cpu_##insn##_error_ra(env, addr, val, retaddr); \
92
- break; \
93
- } \
94
-}
95
-#endif
96
-HELPER_ST(sb, stb, uint8_t)
97
-HELPER_ST(sw, stl, uint32_t)
98
-#if defined(TARGET_MIPS64)
99
-HELPER_ST(sd, stq, uint64_t)
100
-#endif
101
-#undef HELPER_ST
102
-
103
/* 64 bits arithmetic for 32 bits hosts */
104
static inline uint64_t get_HILO(CPUMIPSState *env)
105
{
47
{
106
@@ -XXX,XX +XXX,XX @@ target_ulong helper_##name(CPUMIPSState *env, target_ulong arg, int mem_idx) \
48
@@ -XXX,XX +XXX,XX @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en
107
} \
49
108
env->CP0_LLAddr = do_translate_address(env, arg, 0, GETPC()); \
50
#define ELF_ARCH EM_ARM
109
env->lladdr = arg; \
51
#define ELF_CLASS ELFCLASS32
110
- env->llval = do_##insn(env, arg, mem_idx, GETPC()); \
52
+#define EXSTACK_DEFAULT true
111
+ env->llval = cpu_##insn##_mmuidx_ra(env, arg, mem_idx, GETPC()); \
53
112
return env->llval; \
54
static inline void init_thread(struct target_pt_regs *regs,
113
}
55
struct image_info *infop)
114
-HELPER_LD_ATOMIC(ll, lw, 0x3)
56
@@ -XXX,XX +XXX,XX @@ static inline void init_thread(struct target_pt_regs *regs,
115
+HELPER_LD_ATOMIC(ll, ldl, 0x3)
57
#else
116
#ifdef TARGET_MIPS64
58
117
-HELPER_LD_ATOMIC(lld, ld, 0x7)
59
#define ELF_CLASS ELFCLASS32
118
+HELPER_LD_ATOMIC(lld, ldq, 0x7)
60
+#define EXSTACK_DEFAULT true
61
119
#endif
62
#endif
120
#undef HELPER_LD_ATOMIC
63
64
@@ -XXX,XX +XXX,XX @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en
65
66
#define ELF_CLASS ELFCLASS64
67
#define ELF_ARCH EM_LOONGARCH
68
+#define EXSTACK_DEFAULT true
69
70
#define elf_check_arch(x) ((x) == EM_LOONGARCH)
71
72
@@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void)
73
#define ELF_CLASS ELFCLASS32
121
#endif
74
#endif
122
@@ -XXX,XX +XXX,XX @@ HELPER_LD_ATOMIC(lld, ld, 0x7)
75
#define ELF_ARCH EM_MIPS
123
void helper_swl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
76
+#define EXSTACK_DEFAULT true
124
int mem_idx)
77
78
#ifdef TARGET_ABI_MIPSN32
79
#define elf_check_abi(x) ((x) & EF_MIPS_ABI2)
80
@@ -XXX,XX +XXX,XX @@ static inline void init_thread(struct target_pt_regs *regs,
81
#define bswaptls(ptr) bswap32s(ptr)
82
#endif
83
84
+#ifndef EXSTACK_DEFAULT
85
+#define EXSTACK_DEFAULT false
86
+#endif
87
+
88
#include "elf.h"
89
90
/* We must delay the following stanzas until after "elf.h". */
91
@@ -XXX,XX +XXX,XX @@ static abi_ulong setup_arg_pages(struct linux_binprm *bprm,
92
struct image_info *info)
125
{
93
{
126
- do_sb(env, arg2, (uint8_t)(arg1 >> 24), mem_idx, GETPC());
94
abi_ulong size, error, guard;
127
+ cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 24), mem_idx, GETPC());
95
+ int prot;
128
96
129
if (GET_LMASK(arg2) <= 2) {
97
size = guest_stack_size;
130
- do_sb(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 16), mem_idx,
98
if (size < STACK_LOWER_LIMIT) {
131
- GETPC());
99
@@ -XXX,XX +XXX,XX @@ static abi_ulong setup_arg_pages(struct linux_binprm *bprm,
132
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 16),
100
guard = qemu_real_host_page_size();
133
+ mem_idx, GETPC());
134
}
101
}
135
102
136
if (GET_LMASK(arg2) <= 1) {
103
- error = target_mmap(0, size + guard, PROT_READ | PROT_WRITE,
137
- do_sb(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 8), mem_idx,
104
+ prot = PROT_READ | PROT_WRITE;
138
- GETPC());
105
+ if (info->exec_stack) {
139
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 8),
106
+ prot |= PROT_EXEC;
140
+ mem_idx, GETPC());
107
+ }
141
}
108
+ error = target_mmap(0, size + guard, prot,
142
109
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
143
if (GET_LMASK(arg2) == 0) {
110
if (error == -1) {
144
- do_sb(env, GET_OFFSET(arg2, 3), (uint8_t)arg1, mem_idx,
111
perror("mmap stack");
145
- GETPC());
112
@@ -XXX,XX +XXX,XX @@ static void load_elf_image(const char *image_name, int image_fd,
146
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)arg1,
113
*/
147
+ mem_idx, GETPC());
114
loaddr = -1, hiaddr = 0;
148
}
115
info->alignment = 0;
149
}
116
+ info->exec_stack = EXSTACK_DEFAULT;
150
117
for (i = 0; i < ehdr->e_phnum; ++i) {
151
void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
118
struct elf_phdr *eppnt = phdr + i;
152
int mem_idx)
119
if (eppnt->p_type == PT_LOAD) {
153
{
120
@@ -XXX,XX +XXX,XX @@ static void load_elf_image(const char *image_name, int image_fd,
154
- do_sb(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
121
if (!parse_elf_properties(image_fd, info, eppnt, bprm_buf, &err)) {
155
+ cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
122
goto exit_errmsg;
156
123
}
157
if (GET_LMASK(arg2) >= 1) {
124
+ } else if (eppnt->p_type == PT_GNU_STACK) {
158
- do_sb(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8), mem_idx,
125
+ info->exec_stack = eppnt->p_flags & PF_X;
159
- GETPC());
160
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
161
+ mem_idx, GETPC());
162
}
163
164
if (GET_LMASK(arg2) >= 2) {
165
- do_sb(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16), mem_idx,
166
- GETPC());
167
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
168
+ mem_idx, GETPC());
169
}
170
171
if (GET_LMASK(arg2) == 3) {
172
- do_sb(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24), mem_idx,
173
- GETPC());
174
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
175
+ mem_idx, GETPC());
176
}
177
}
178
179
@@ -XXX,XX +XXX,XX @@ void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
180
void helper_sdl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
181
int mem_idx)
182
{
183
- do_sb(env, arg2, (uint8_t)(arg1 >> 56), mem_idx, GETPC());
184
+ cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 56), mem_idx, GETPC());
185
186
if (GET_LMASK64(arg2) <= 6) {
187
- do_sb(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 48), mem_idx,
188
- GETPC());
189
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 48),
190
+ mem_idx, GETPC());
191
}
192
193
if (GET_LMASK64(arg2) <= 5) {
194
- do_sb(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 40), mem_idx,
195
- GETPC());
196
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 40),
197
+ mem_idx, GETPC());
198
}
199
200
if (GET_LMASK64(arg2) <= 4) {
201
- do_sb(env, GET_OFFSET(arg2, 3), (uint8_t)(arg1 >> 32), mem_idx,
202
- GETPC());
203
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)(arg1 >> 32),
204
+ mem_idx, GETPC());
205
}
206
207
if (GET_LMASK64(arg2) <= 3) {
208
- do_sb(env, GET_OFFSET(arg2, 4), (uint8_t)(arg1 >> 24), mem_idx,
209
- GETPC());
210
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 4), (uint8_t)(arg1 >> 24),
211
+ mem_idx, GETPC());
212
}
213
214
if (GET_LMASK64(arg2) <= 2) {
215
- do_sb(env, GET_OFFSET(arg2, 5), (uint8_t)(arg1 >> 16), mem_idx,
216
- GETPC());
217
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 5), (uint8_t)(arg1 >> 16),
218
+ mem_idx, GETPC());
219
}
220
221
if (GET_LMASK64(arg2) <= 1) {
222
- do_sb(env, GET_OFFSET(arg2, 6), (uint8_t)(arg1 >> 8), mem_idx,
223
- GETPC());
224
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 6), (uint8_t)(arg1 >> 8),
225
+ mem_idx, GETPC());
226
}
227
228
if (GET_LMASK64(arg2) <= 0) {
229
- do_sb(env, GET_OFFSET(arg2, 7), (uint8_t)arg1, mem_idx,
230
- GETPC());
231
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 7), (uint8_t)arg1,
232
+ mem_idx, GETPC());
233
}
234
}
235
236
void helper_sdr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
237
int mem_idx)
238
{
239
- do_sb(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
240
+ cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
241
242
if (GET_LMASK64(arg2) >= 1) {
243
- do_sb(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8), mem_idx,
244
- GETPC());
245
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
246
+ mem_idx, GETPC());
247
}
248
249
if (GET_LMASK64(arg2) >= 2) {
250
- do_sb(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16), mem_idx,
251
- GETPC());
252
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
253
+ mem_idx, GETPC());
254
}
255
256
if (GET_LMASK64(arg2) >= 3) {
257
- do_sb(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24), mem_idx,
258
- GETPC());
259
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
260
+ mem_idx, GETPC());
261
}
262
263
if (GET_LMASK64(arg2) >= 4) {
264
- do_sb(env, GET_OFFSET(arg2, -4), (uint8_t)(arg1 >> 32), mem_idx,
265
- GETPC());
266
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -4), (uint8_t)(arg1 >> 32),
267
+ mem_idx, GETPC());
268
}
269
270
if (GET_LMASK64(arg2) >= 5) {
271
- do_sb(env, GET_OFFSET(arg2, -5), (uint8_t)(arg1 >> 40), mem_idx,
272
- GETPC());
273
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -5), (uint8_t)(arg1 >> 40),
274
+ mem_idx, GETPC());
275
}
276
277
if (GET_LMASK64(arg2) >= 6) {
278
- do_sb(env, GET_OFFSET(arg2, -6), (uint8_t)(arg1 >> 48), mem_idx,
279
- GETPC());
280
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -6), (uint8_t)(arg1 >> 48),
281
+ mem_idx, GETPC());
282
}
283
284
if (GET_LMASK64(arg2) == 7) {
285
- do_sb(env, GET_OFFSET(arg2, -7), (uint8_t)(arg1 >> 56), mem_idx,
286
- GETPC());
287
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -7), (uint8_t)(arg1 >> 56),
288
+ mem_idx, GETPC());
289
}
290
}
291
#endif /* TARGET_MIPS64 */
292
@@ -XXX,XX +XXX,XX @@ void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
293
294
for (i = 0; i < base_reglist; i++) {
295
env->active_tc.gpr[multiple_regs[i]] =
296
- (target_long)do_lw(env, addr, mem_idx, GETPC());
297
+ (target_long)cpu_ldl_mmuidx_ra(env, addr, mem_idx, GETPC());
298
addr += 4;
299
}
126
}
300
}
127
}
301
128
302
if (do_r31) {
303
- env->active_tc.gpr[31] = (target_long)do_lw(env, addr, mem_idx,
304
- GETPC());
305
+ env->active_tc.gpr[31] =
306
+ (target_long)cpu_ldl_mmuidx_ra(env, addr, mem_idx, GETPC());
307
}
308
}
309
310
@@ -XXX,XX +XXX,XX @@ void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
311
target_ulong i;
312
313
for (i = 0; i < base_reglist; i++) {
314
- do_sw(env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx,
315
- GETPC());
316
+ cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
317
+ mem_idx, GETPC());
318
addr += 4;
319
}
320
}
321
322
if (do_r31) {
323
- do_sw(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
324
+ cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
325
}
326
}
327
328
@@ -XXX,XX +XXX,XX @@ void helper_ldm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
329
target_ulong i;
330
331
for (i = 0; i < base_reglist; i++) {
332
- env->active_tc.gpr[multiple_regs[i]] = do_ld(env, addr, mem_idx,
333
- GETPC());
334
+ env->active_tc.gpr[multiple_regs[i]] =
335
+ cpu_ldq_mmuidx_ra(env, addr, mem_idx, GETPC());
336
addr += 8;
337
}
338
}
339
340
if (do_r31) {
341
- env->active_tc.gpr[31] = do_ld(env, addr, mem_idx, GETPC());
342
+ env->active_tc.gpr[31] =
343
+ cpu_ldq_mmuidx_ra(env, addr, mem_idx, GETPC());
344
}
345
}
346
347
@@ -XXX,XX +XXX,XX @@ void helper_sdm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
348
target_ulong i;
349
350
for (i = 0; i < base_reglist; i++) {
351
- do_sd(env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx,
352
- GETPC());
353
+ cpu_stq_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
354
+ mem_idx, GETPC());
355
addr += 8;
356
}
357
}
358
359
if (do_r31) {
360
- do_sd(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
361
+ cpu_stq_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
362
}
363
}
364
#endif
365
--
129
--
366
2.20.1
130
2.34.1
367
368
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Ilya Leoshkevich <iii@linux.ibm.com>
2
2
3
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
3
Currently it's possible to execute pages that do not have PAGE_EXEC
4
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
4
if there is an existing translation block. Fix by invalidating TBs
5
Reviewed-by: Stefan Weil <sw@weilnetz.de>
5
that touch the affected pages.
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
8
Message-Id: <20200101112303.20724-4-philmd@redhat.com>
8
Message-Id: <20220817150506.592862-2-iii@linux.ibm.com>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
---
10
---
11
{tcg => include/tcg}/tcg-gvec-desc.h | 0
11
linux-user/mmap.c | 6 ++++--
12
{tcg => include/tcg}/tcg-mo.h | 0
12
1 file changed, 4 insertions(+), 2 deletions(-)
13
{tcg => include/tcg}/tcg-op-gvec.h | 0
14
{tcg => include/tcg}/tcg-op.h | 0
15
{tcg => include/tcg}/tcg-opc.h | 0
16
{tcg => include/tcg}/tcg.h | 0
17
MAINTAINERS | 1 +
18
7 files changed, 1 insertion(+)
19
rename {tcg => include/tcg}/tcg-gvec-desc.h (100%)
20
rename {tcg => include/tcg}/tcg-mo.h (100%)
21
rename {tcg => include/tcg}/tcg-op-gvec.h (100%)
22
rename {tcg => include/tcg}/tcg-op.h (100%)
23
rename {tcg => include/tcg}/tcg-opc.h (100%)
24
rename {tcg => include/tcg}/tcg.h (100%)
25
13
26
diff --git a/tcg/tcg-gvec-desc.h b/include/tcg/tcg-gvec-desc.h
14
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
27
similarity index 100%
28
rename from tcg/tcg-gvec-desc.h
29
rename to include/tcg/tcg-gvec-desc.h
30
diff --git a/tcg/tcg-mo.h b/include/tcg/tcg-mo.h
31
similarity index 100%
32
rename from tcg/tcg-mo.h
33
rename to include/tcg/tcg-mo.h
34
diff --git a/tcg/tcg-op-gvec.h b/include/tcg/tcg-op-gvec.h
35
similarity index 100%
36
rename from tcg/tcg-op-gvec.h
37
rename to include/tcg/tcg-op-gvec.h
38
diff --git a/tcg/tcg-op.h b/include/tcg/tcg-op.h
39
similarity index 100%
40
rename from tcg/tcg-op.h
41
rename to include/tcg/tcg-op.h
42
diff --git a/tcg/tcg-opc.h b/include/tcg/tcg-opc.h
43
similarity index 100%
44
rename from tcg/tcg-opc.h
45
rename to include/tcg/tcg-opc.h
46
diff --git a/tcg/tcg.h b/include/tcg/tcg.h
47
similarity index 100%
48
rename from tcg/tcg.h
49
rename to include/tcg/tcg.h
50
diff --git a/MAINTAINERS b/MAINTAINERS
51
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
52
--- a/MAINTAINERS
16
--- a/linux-user/mmap.c
53
+++ b/MAINTAINERS
17
+++ b/linux-user/mmap.c
54
@@ -XXX,XX +XXX,XX @@ Common TCG code
18
@@ -XXX,XX +XXX,XX @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot)
55
M: Richard Henderson <rth@twiddle.net>
19
goto error;
56
S: Maintained
20
}
57
F: tcg/
21
}
58
+F: include/tcg/
22
+
59
23
page_set_flags(start, start + len, page_flags);
60
TCG Plugins
24
- mmap_unlock();
61
M: Alex Bennée <alex.bennee@linaro.org>
25
- return 0;
26
+ tb_invalidate_phys_range(start, start + len);
27
+ ret = 0;
28
+
29
error:
30
mmap_unlock();
31
return ret;
62
--
32
--
63
2.20.1
33
2.34.1
64
65
diff view generated by jsdifflib
1
All users have now been converted to cpu_*_mmuidx_ra.
1
We're about to start validating PAGE_EXEC, which means
2
that we've got to put this code into a section that is
3
both writable and executable.
2
4
3
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Note that this test did not run on hardware beforehand either.
4
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
7
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
8
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
10
---
7
include/exec/cpu_ldst.h | 230 ----------------------------------------
11
tests/tcg/i386/test-i386.c | 2 +-
8
1 file changed, 230 deletions(-)
12
1 file changed, 1 insertion(+), 1 deletion(-)
9
13
10
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
14
diff --git a/tests/tcg/i386/test-i386.c b/tests/tcg/i386/test-i386.c
11
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
12
--- a/include/exec/cpu_ldst.h
16
--- a/tests/tcg/i386/test-i386.c
13
+++ b/include/exec/cpu_ldst.h
17
+++ b/tests/tcg/i386/test-i386.c
14
@@ -XXX,XX +XXX,XX @@ void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
18
@@ -XXX,XX +XXX,XX @@ uint8_t code[] = {
15
void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
19
0xc3, /* ret */
16
int mmu_idx, uintptr_t retaddr);
20
};
17
21
18
-#ifdef MMU_MODE0_SUFFIX
22
-asm(".section \".data\"\n"
19
-#define CPU_MMU_INDEX 0
23
+asm(".section \".data_x\",\"awx\"\n"
20
-#define MEMSUFFIX MMU_MODE0_SUFFIX
24
"smc_code2:\n"
21
-#define DATA_SIZE 1
25
"movl 4(%esp), %eax\n"
22
-#include "exec/cpu_ldst_template.h"
26
"movl %eax, smc_patch_addr2 + 1\n"
23
-
24
-#define DATA_SIZE 2
25
-#include "exec/cpu_ldst_template.h"
26
-
27
-#define DATA_SIZE 4
28
-#include "exec/cpu_ldst_template.h"
29
-
30
-#define DATA_SIZE 8
31
-#include "exec/cpu_ldst_template.h"
32
-#undef CPU_MMU_INDEX
33
-#undef MEMSUFFIX
34
-#endif
35
-
36
-#if (NB_MMU_MODES >= 2) && defined(MMU_MODE1_SUFFIX)
37
-#define CPU_MMU_INDEX 1
38
-#define MEMSUFFIX MMU_MODE1_SUFFIX
39
-#define DATA_SIZE 1
40
-#include "exec/cpu_ldst_template.h"
41
-
42
-#define DATA_SIZE 2
43
-#include "exec/cpu_ldst_template.h"
44
-
45
-#define DATA_SIZE 4
46
-#include "exec/cpu_ldst_template.h"
47
-
48
-#define DATA_SIZE 8
49
-#include "exec/cpu_ldst_template.h"
50
-#undef CPU_MMU_INDEX
51
-#undef MEMSUFFIX
52
-#endif
53
-
54
-#if (NB_MMU_MODES >= 3) && defined(MMU_MODE2_SUFFIX)
55
-
56
-#define CPU_MMU_INDEX 2
57
-#define MEMSUFFIX MMU_MODE2_SUFFIX
58
-#define DATA_SIZE 1
59
-#include "exec/cpu_ldst_template.h"
60
-
61
-#define DATA_SIZE 2
62
-#include "exec/cpu_ldst_template.h"
63
-
64
-#define DATA_SIZE 4
65
-#include "exec/cpu_ldst_template.h"
66
-
67
-#define DATA_SIZE 8
68
-#include "exec/cpu_ldst_template.h"
69
-#undef CPU_MMU_INDEX
70
-#undef MEMSUFFIX
71
-#endif /* (NB_MMU_MODES >= 3) */
72
-
73
-#if (NB_MMU_MODES >= 4) && defined(MMU_MODE3_SUFFIX)
74
-
75
-#define CPU_MMU_INDEX 3
76
-#define MEMSUFFIX MMU_MODE3_SUFFIX
77
-#define DATA_SIZE 1
78
-#include "exec/cpu_ldst_template.h"
79
-
80
-#define DATA_SIZE 2
81
-#include "exec/cpu_ldst_template.h"
82
-
83
-#define DATA_SIZE 4
84
-#include "exec/cpu_ldst_template.h"
85
-
86
-#define DATA_SIZE 8
87
-#include "exec/cpu_ldst_template.h"
88
-#undef CPU_MMU_INDEX
89
-#undef MEMSUFFIX
90
-#endif /* (NB_MMU_MODES >= 4) */
91
-
92
-#if (NB_MMU_MODES >= 5) && defined(MMU_MODE4_SUFFIX)
93
-
94
-#define CPU_MMU_INDEX 4
95
-#define MEMSUFFIX MMU_MODE4_SUFFIX
96
-#define DATA_SIZE 1
97
-#include "exec/cpu_ldst_template.h"
98
-
99
-#define DATA_SIZE 2
100
-#include "exec/cpu_ldst_template.h"
101
-
102
-#define DATA_SIZE 4
103
-#include "exec/cpu_ldst_template.h"
104
-
105
-#define DATA_SIZE 8
106
-#include "exec/cpu_ldst_template.h"
107
-#undef CPU_MMU_INDEX
108
-#undef MEMSUFFIX
109
-#endif /* (NB_MMU_MODES >= 5) */
110
-
111
-#if (NB_MMU_MODES >= 6) && defined(MMU_MODE5_SUFFIX)
112
-
113
-#define CPU_MMU_INDEX 5
114
-#define MEMSUFFIX MMU_MODE5_SUFFIX
115
-#define DATA_SIZE 1
116
-#include "exec/cpu_ldst_template.h"
117
-
118
-#define DATA_SIZE 2
119
-#include "exec/cpu_ldst_template.h"
120
-
121
-#define DATA_SIZE 4
122
-#include "exec/cpu_ldst_template.h"
123
-
124
-#define DATA_SIZE 8
125
-#include "exec/cpu_ldst_template.h"
126
-#undef CPU_MMU_INDEX
127
-#undef MEMSUFFIX
128
-#endif /* (NB_MMU_MODES >= 6) */
129
-
130
-#if (NB_MMU_MODES >= 7) && defined(MMU_MODE6_SUFFIX)
131
-
132
-#define CPU_MMU_INDEX 6
133
-#define MEMSUFFIX MMU_MODE6_SUFFIX
134
-#define DATA_SIZE 1
135
-#include "exec/cpu_ldst_template.h"
136
-
137
-#define DATA_SIZE 2
138
-#include "exec/cpu_ldst_template.h"
139
-
140
-#define DATA_SIZE 4
141
-#include "exec/cpu_ldst_template.h"
142
-
143
-#define DATA_SIZE 8
144
-#include "exec/cpu_ldst_template.h"
145
-#undef CPU_MMU_INDEX
146
-#undef MEMSUFFIX
147
-#endif /* (NB_MMU_MODES >= 7) */
148
-
149
-#if (NB_MMU_MODES >= 8) && defined(MMU_MODE7_SUFFIX)
150
-
151
-#define CPU_MMU_INDEX 7
152
-#define MEMSUFFIX MMU_MODE7_SUFFIX
153
-#define DATA_SIZE 1
154
-#include "exec/cpu_ldst_template.h"
155
-
156
-#define DATA_SIZE 2
157
-#include "exec/cpu_ldst_template.h"
158
-
159
-#define DATA_SIZE 4
160
-#include "exec/cpu_ldst_template.h"
161
-
162
-#define DATA_SIZE 8
163
-#include "exec/cpu_ldst_template.h"
164
-#undef CPU_MMU_INDEX
165
-#undef MEMSUFFIX
166
-#endif /* (NB_MMU_MODES >= 8) */
167
-
168
-#if (NB_MMU_MODES >= 9) && defined(MMU_MODE8_SUFFIX)
169
-
170
-#define CPU_MMU_INDEX 8
171
-#define MEMSUFFIX MMU_MODE8_SUFFIX
172
-#define DATA_SIZE 1
173
-#include "exec/cpu_ldst_template.h"
174
-
175
-#define DATA_SIZE 2
176
-#include "exec/cpu_ldst_template.h"
177
-
178
-#define DATA_SIZE 4
179
-#include "exec/cpu_ldst_template.h"
180
-
181
-#define DATA_SIZE 8
182
-#include "exec/cpu_ldst_template.h"
183
-#undef CPU_MMU_INDEX
184
-#undef MEMSUFFIX
185
-#endif /* (NB_MMU_MODES >= 9) */
186
-
187
-#if (NB_MMU_MODES >= 10) && defined(MMU_MODE9_SUFFIX)
188
-
189
-#define CPU_MMU_INDEX 9
190
-#define MEMSUFFIX MMU_MODE9_SUFFIX
191
-#define DATA_SIZE 1
192
-#include "exec/cpu_ldst_template.h"
193
-
194
-#define DATA_SIZE 2
195
-#include "exec/cpu_ldst_template.h"
196
-
197
-#define DATA_SIZE 4
198
-#include "exec/cpu_ldst_template.h"
199
-
200
-#define DATA_SIZE 8
201
-#include "exec/cpu_ldst_template.h"
202
-#undef CPU_MMU_INDEX
203
-#undef MEMSUFFIX
204
-#endif /* (NB_MMU_MODES >= 10) */
205
-
206
-#if (NB_MMU_MODES >= 11) && defined(MMU_MODE10_SUFFIX)
207
-
208
-#define CPU_MMU_INDEX 10
209
-#define MEMSUFFIX MMU_MODE10_SUFFIX
210
-#define DATA_SIZE 1
211
-#include "exec/cpu_ldst_template.h"
212
-
213
-#define DATA_SIZE 2
214
-#include "exec/cpu_ldst_template.h"
215
-
216
-#define DATA_SIZE 4
217
-#include "exec/cpu_ldst_template.h"
218
-
219
-#define DATA_SIZE 8
220
-#include "exec/cpu_ldst_template.h"
221
-#undef CPU_MMU_INDEX
222
-#undef MEMSUFFIX
223
-#endif /* (NB_MMU_MODES >= 11) */
224
-
225
-#if (NB_MMU_MODES >= 12) && defined(MMU_MODE11_SUFFIX)
226
-
227
-#define CPU_MMU_INDEX 11
228
-#define MEMSUFFIX MMU_MODE11_SUFFIX
229
-#define DATA_SIZE 1
230
-#include "exec/cpu_ldst_template.h"
231
-
232
-#define DATA_SIZE 2
233
-#include "exec/cpu_ldst_template.h"
234
-
235
-#define DATA_SIZE 4
236
-#include "exec/cpu_ldst_template.h"
237
-
238
-#define DATA_SIZE 8
239
-#include "exec/cpu_ldst_template.h"
240
-#undef CPU_MMU_INDEX
241
-#undef MEMSUFFIX
242
-#endif /* (NB_MMU_MODES >= 12) */
243
-
244
-#if (NB_MMU_MODES > 12)
245
-#error "NB_MMU_MODES > 12 is not supported for now"
246
-#endif /* (NB_MMU_MODES > 12) */
247
-
248
/* these access are slower, they must be as rare as possible */
249
#define CPU_MMU_INDEX (cpu_mmu_index(env, false))
250
#define MEMSUFFIX _data
251
--
27
--
252
2.20.1
28
2.34.1
253
254
diff view generated by jsdifflib
1
The DO_LOAD macros replicate the distinction already performed
1
From: Ilya Leoshkevich <iii@linux.ibm.com>
2
by the cpu_ldst.h functions. Use them.
3
2
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
3
Introduce a function that checks whether a given address is on the same
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
page as where disassembly started. Having it improves readability of
5
the following patches.
6
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
9
Message-Id: <20220811095534.241224-3-iii@linux.ibm.com>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
[rth: Make the DisasContextBase parameter const.]
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
13
---
8
include/exec/cpu_ldst.h | 11 ---------
14
include/exec/translator.h | 10 ++++++++++
9
include/exec/translator.h | 48 +++++++++++----------------------------
15
1 file changed, 10 insertions(+)
10
2 files changed, 13 insertions(+), 46 deletions(-)
11
16
12
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/include/exec/cpu_ldst.h
15
+++ b/include/exec/cpu_ldst.h
16
@@ -XXX,XX +XXX,XX @@ static inline void clear_helper_retaddr(void)
17
#include "exec/cpu_ldst_useronly_template.h"
18
#undef MEMSUFFIX
19
20
-/*
21
- * Code access is deprecated in favour of translator_ld* functions
22
- * (see translator.h). However there are still users that need to
23
- * converted so for now these stay.
24
- */
25
#define MEMSUFFIX _code
26
#define CODE_ACCESS
27
#define DATA_SIZE 1
28
@@ -XXX,XX +XXX,XX @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
29
#undef CPU_MMU_INDEX
30
#undef MEMSUFFIX
31
32
-/*
33
- * Code access is deprecated in favour of translator_ld* functions
34
- * (see translator.h). However there are still users that need to
35
- * converted so for now these stay.
36
- */
37
-
38
#define CPU_MMU_INDEX (cpu_mmu_index(env, true))
39
#define MEMSUFFIX _code
40
#define SOFTMMU_CODE_ACCESS
41
diff --git a/include/exec/translator.h b/include/exec/translator.h
17
diff --git a/include/exec/translator.h b/include/exec/translator.h
42
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
43
--- a/include/exec/translator.h
19
--- a/include/exec/translator.h
44
+++ b/include/exec/translator.h
20
+++ b/include/exec/translator.h
45
@@ -XXX,XX +XXX,XX @@ void translator_loop_temp_check(DisasContextBase *db);
21
@@ -XXX,XX +XXX,XX @@ FOR_EACH_TRANSLATOR_LD(GEN_TRANSLATOR_LD)
46
/*
22
47
* Translator Load Functions
48
*
49
- * These are intended to replace the old cpu_ld*_code functions and
50
- * are mandatory for front-ends that have been migrated to the common
51
- * translator_loop. These functions are only intended to be called
52
- * from the translation stage and should not be called from helper
53
- * functions. Those functions should be converted to encode the
54
- * relevant information at translation time.
55
+ * These are intended to replace the direct usage of the cpu_ld*_code
56
+ * functions and are mandatory for front-ends that have been migrated
57
+ * to the common translator_loop. These functions are only intended
58
+ * to be called from the translation stage and should not be called
59
+ * from helper functions. Those functions should be converted to encode
60
+ * the relevant information at translation time.
61
*/
62
63
-#ifdef CONFIG_USER_ONLY
64
-
65
-#define DO_LOAD(type, name, shift) \
66
- do { \
67
- set_helper_retaddr(1); \
68
- ret = name ## _p(g2h(pc)); \
69
- clear_helper_retaddr(); \
70
- } while (0)
71
-
72
-#else
73
-
74
-#define DO_LOAD(type, name, shift) \
75
- do { \
76
- int mmu_idx = cpu_mmu_index(env, true); \
77
- TCGMemOpIdx oi = make_memop_idx(shift, mmu_idx); \
78
- ret = helper_ret_ ## name ## _cmmu(env, pc, oi, 0); \
79
- } while (0)
80
-
81
-#endif
82
-
83
-#define GEN_TRANSLATOR_LD(fullname, name, type, shift, swap_fn) \
84
+#define GEN_TRANSLATOR_LD(fullname, type, load_fn, swap_fn) \
85
static inline type \
86
fullname ## _swap(CPUArchState *env, abi_ptr pc, bool do_swap) \
87
{ \
88
- type ret; \
89
- DO_LOAD(type, name, shift); \
90
- \
91
+ type ret = load_fn(env, pc); \
92
if (do_swap) { \
93
ret = swap_fn(ret); \
94
} \
95
@@ -XXX,XX +XXX,XX @@ void translator_loop_temp_check(DisasContextBase *db);
96
return fullname ## _swap(env, pc, false); \
97
}
98
99
-GEN_TRANSLATOR_LD(translator_ldub, ldub, uint8_t, 0, /* no swap */ )
100
-GEN_TRANSLATOR_LD(translator_ldsw, ldsw, int16_t, 1, bswap16)
101
-GEN_TRANSLATOR_LD(translator_lduw, lduw, uint16_t, 1, bswap16)
102
-GEN_TRANSLATOR_LD(translator_ldl, ldl, uint32_t, 2, bswap32)
103
-GEN_TRANSLATOR_LD(translator_ldq, ldq, uint64_t, 3, bswap64)
104
+GEN_TRANSLATOR_LD(translator_ldub, uint8_t, cpu_ldub_code, /* no swap */)
105
+GEN_TRANSLATOR_LD(translator_ldsw, int16_t, cpu_ldsw_code, bswap16)
106
+GEN_TRANSLATOR_LD(translator_lduw, uint16_t, cpu_lduw_code, bswap16)
107
+GEN_TRANSLATOR_LD(translator_ldl, uint32_t, cpu_ldl_code, bswap32)
108
+GEN_TRANSLATOR_LD(translator_ldq, uint64_t, cpu_ldq_code, bswap64)
109
#undef GEN_TRANSLATOR_LD
23
#undef GEN_TRANSLATOR_LD
110
24
111
#endif /* EXEC__TRANSLATOR_H */
25
+/*
26
+ * Return whether addr is on the same page as where disassembly started.
27
+ * Translators can use this to enforce the rule that only single-insn
28
+ * translation blocks are allowed to cross page boundaries.
29
+ */
30
+static inline bool is_same_page(const DisasContextBase *db, target_ulong addr)
31
+{
32
+ return ((addr ^ db->pc_first) & TARGET_PAGE_MASK) == 0;
33
+}
34
+
35
#endif /* EXEC__TRANSLATOR_H */
112
--
36
--
113
2.20.1
37
2.34.1
114
115
diff view generated by jsdifflib
1
Reduce the amount of preprocessor obfuscation by expanding
1
The current implementation is a no-op, simply returning addr.
2
the text of each of the functions generated. The result is
2
This is incorrect, because we ought to be checking the page
3
only slightly smaller than the original.
3
permissions for execution.
4
4
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Make get_page_addr_code inline for both implementations.
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
7
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
7
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
8
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
9
Acked-by: Alistair Francis <alistair.francis@wdc.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
11
---
10
include/exec/cpu_ldst.h | 67 +++++++-----------
12
include/exec/exec-all.h | 85 ++++++++++++++---------------------------
11
include/exec/cpu_ldst_template.h | 117 -------------------------------
13
accel/tcg/cputlb.c | 5 ---
12
accel/tcg/cputlb.c | 107 +++++++++++++++++++++++++++-
14
accel/tcg/user-exec.c | 14 +++++++
13
3 files changed, 130 insertions(+), 161 deletions(-)
15
3 files changed, 42 insertions(+), 62 deletions(-)
14
delete mode 100644 include/exec/cpu_ldst_template.h
15
16
16
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
17
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/include/exec/cpu_ldst.h
19
--- a/include/exec/exec-all.h
19
+++ b/include/exec/cpu_ldst.h
20
+++ b/include/exec/exec-all.h
20
@@ -XXX,XX +XXX,XX @@ typedef target_ulong abi_ptr;
21
@@ -XXX,XX +XXX,XX @@ struct MemoryRegionSection *iotlb_to_section(CPUState *cpu,
21
#define TARGET_ABI_FMT_ptr TARGET_ABI_FMT_lx
22
hwaddr index, MemTxAttrs attrs);
22
#endif
23
#endif
23
24
24
-#if defined(CONFIG_USER_ONLY)
25
-#if defined(CONFIG_USER_ONLY)
26
-void mmap_lock(void);
27
-void mmap_unlock(void);
28
-bool have_mmap_lock(void);
25
-
29
-
26
-extern __thread uintptr_t helper_retaddr;
30
/**
31
- * get_page_addr_code() - user-mode version
32
+ * get_page_addr_code_hostp()
33
* @env: CPUArchState
34
* @addr: guest virtual address of guest code
35
*
36
- * Returns @addr.
37
+ * See get_page_addr_code() (full-system version) for documentation on the
38
+ * return value.
39
+ *
40
+ * Sets *@hostp (when @hostp is non-NULL) as follows.
41
+ * If the return value is -1, sets *@hostp to NULL. Otherwise, sets *@hostp
42
+ * to the host address where @addr's content is kept.
43
+ *
44
+ * Note: this function can trigger an exception.
45
+ */
46
+tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr,
47
+ void **hostp);
48
+
49
+/**
50
+ * get_page_addr_code()
51
+ * @env: CPUArchState
52
+ * @addr: guest virtual address of guest code
53
+ *
54
+ * If we cannot translate and execute from the entire RAM page, or if
55
+ * the region is not backed by RAM, returns -1. Otherwise, returns the
56
+ * ram_addr_t corresponding to the guest code at @addr.
57
+ *
58
+ * Note: this function can trigger an exception.
59
*/
60
static inline tb_page_addr_t get_page_addr_code(CPUArchState *env,
61
target_ulong addr)
62
{
63
- return addr;
64
+ return get_page_addr_code_hostp(env, addr, NULL);
65
}
66
67
-/**
68
- * get_page_addr_code_hostp() - user-mode version
69
- * @env: CPUArchState
70
- * @addr: guest virtual address of guest code
71
- *
72
- * Returns @addr.
73
- *
74
- * If @hostp is non-NULL, sets *@hostp to the host address where @addr's content
75
- * is kept.
76
- */
77
-static inline tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env,
78
- target_ulong addr,
79
- void **hostp)
80
-{
81
- if (hostp) {
82
- *hostp = g2h_untagged(addr);
83
- }
84
- return addr;
85
-}
86
+#if defined(CONFIG_USER_ONLY)
87
+void mmap_lock(void);
88
+void mmap_unlock(void);
89
+bool have_mmap_lock(void);
90
91
/**
92
* adjust_signal_pc:
93
@@ -XXX,XX +XXX,XX @@ G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
94
static inline void mmap_lock(void) {}
95
static inline void mmap_unlock(void) {}
96
97
-/**
98
- * get_page_addr_code() - full-system version
99
- * @env: CPUArchState
100
- * @addr: guest virtual address of guest code
101
- *
102
- * If we cannot translate and execute from the entire RAM page, or if
103
- * the region is not backed by RAM, returns -1. Otherwise, returns the
104
- * ram_addr_t corresponding to the guest code at @addr.
105
- *
106
- * Note: this function can trigger an exception.
107
- */
108
-tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr);
27
-
109
-
28
-static inline void set_helper_retaddr(uintptr_t ra)
110
-/**
29
-{
111
- * get_page_addr_code_hostp() - full-system version
30
- helper_retaddr = ra;
112
- * @env: CPUArchState
31
- /*
113
- * @addr: guest virtual address of guest code
32
- * Ensure that this write is visible to the SIGSEGV handler that
114
- *
33
- * may be invoked due to a subsequent invalid memory operation.
115
- * See get_page_addr_code() (full-system version) for documentation on the
34
- */
116
- * return value.
35
- signal_barrier();
117
- *
36
-}
118
- * Sets *@hostp (when @hostp is non-NULL) as follows.
119
- * If the return value is -1, sets *@hostp to NULL. Otherwise, sets *@hostp
120
- * to the host address where @addr's content is kept.
121
- *
122
- * Note: this function can trigger an exception.
123
- */
124
-tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr,
125
- void **hostp);
37
-
126
-
38
-static inline void clear_helper_retaddr(void)
127
void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
39
-{
128
void tlb_set_dirty(CPUState *cpu, target_ulong vaddr);
40
- /*
129
41
- * Ensure that previous memory operations have succeeded before
42
- * removing the data visible to the signal handler.
43
- */
44
- signal_barrier();
45
- helper_retaddr = 0;
46
-}
47
-
48
-/* In user-only mode we provide only the _code and _data accessors. */
49
-
50
uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr);
51
uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr);
52
uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr);
53
@@ -XXX,XX +XXX,XX @@ void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
54
void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
55
uint64_t val, uintptr_t retaddr);
56
57
+#if defined(CONFIG_USER_ONLY)
58
+
59
+extern __thread uintptr_t helper_retaddr;
60
+
61
+static inline void set_helper_retaddr(uintptr_t ra)
62
+{
63
+ helper_retaddr = ra;
64
+ /*
65
+ * Ensure that this write is visible to the SIGSEGV handler that
66
+ * may be invoked due to a subsequent invalid memory operation.
67
+ */
68
+ signal_barrier();
69
+}
70
+
71
+static inline void clear_helper_retaddr(void)
72
+{
73
+ /*
74
+ * Ensure that previous memory operations have succeeded before
75
+ * removing the data visible to the signal handler.
76
+ */
77
+ signal_barrier();
78
+ helper_retaddr = 0;
79
+}
80
+
81
/*
82
* Provide the same *_mmuidx_ra interface as for softmmu.
83
* The mmu_idx argument is ignored.
84
@@ -XXX,XX +XXX,XX @@ void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
85
void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
86
int mmu_idx, uintptr_t retaddr);
87
88
-/* these access are slower, they must be as rare as possible */
89
-#define CPU_MMU_INDEX (cpu_mmu_index(env, false))
90
-#define MEMSUFFIX _data
91
-#define DATA_SIZE 1
92
-#include "exec/cpu_ldst_template.h"
93
-
94
-#define DATA_SIZE 2
95
-#include "exec/cpu_ldst_template.h"
96
-
97
-#define DATA_SIZE 4
98
-#include "exec/cpu_ldst_template.h"
99
-
100
-#define DATA_SIZE 8
101
-#include "exec/cpu_ldst_template.h"
102
-#undef CPU_MMU_INDEX
103
-#undef MEMSUFFIX
104
-
105
#endif /* defined(CONFIG_USER_ONLY) */
106
107
uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
108
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
109
deleted file mode 100644
110
index XXXXXXX..XXXXXXX
111
--- a/include/exec/cpu_ldst_template.h
112
+++ /dev/null
113
@@ -XXX,XX +XXX,XX @@
114
-/*
115
- * Software MMU support
116
- *
117
- * Generate inline load/store functions for one MMU mode and data
118
- * size.
119
- *
120
- * Generate a store function as well as signed and unsigned loads.
121
- *
122
- * Not used directly but included from cpu_ldst.h.
123
- *
124
- * Copyright (c) 2003 Fabrice Bellard
125
- *
126
- * This library is free software; you can redistribute it and/or
127
- * modify it under the terms of the GNU Lesser General Public
128
- * License as published by the Free Software Foundation; either
129
- * version 2 of the License, or (at your option) any later version.
130
- *
131
- * This library is distributed in the hope that it will be useful,
132
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
133
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
134
- * Lesser General Public License for more details.
135
- *
136
- * You should have received a copy of the GNU Lesser General Public
137
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
138
- */
139
-
140
-#if DATA_SIZE == 8
141
-#define SUFFIX q
142
-#define USUFFIX q
143
-#define DATA_TYPE uint64_t
144
-#define SHIFT 3
145
-#elif DATA_SIZE == 4
146
-#define SUFFIX l
147
-#define USUFFIX l
148
-#define DATA_TYPE uint32_t
149
-#define SHIFT 2
150
-#elif DATA_SIZE == 2
151
-#define SUFFIX w
152
-#define USUFFIX uw
153
-#define DATA_TYPE uint16_t
154
-#define DATA_STYPE int16_t
155
-#define SHIFT 1
156
-#elif DATA_SIZE == 1
157
-#define SUFFIX b
158
-#define USUFFIX ub
159
-#define DATA_TYPE uint8_t
160
-#define DATA_STYPE int8_t
161
-#define SHIFT 0
162
-#else
163
-#error unsupported data size
164
-#endif
165
-
166
-#if DATA_SIZE == 8
167
-#define RES_TYPE uint64_t
168
-#else
169
-#define RES_TYPE uint32_t
170
-#endif
171
-
172
-/* generic load/store macros */
173
-
174
-static inline RES_TYPE
175
-glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
176
- target_ulong ptr,
177
- uintptr_t retaddr)
178
-{
179
- return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
180
- retaddr);
181
-}
182
-
183
-static inline RES_TYPE
184
-glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
185
-{
186
- return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
187
-}
188
-
189
-#if DATA_SIZE <= 2
190
-static inline int
191
-glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
192
- target_ulong ptr,
193
- uintptr_t retaddr)
194
-{
195
- return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
196
- retaddr);
197
-}
198
-
199
-static inline int
200
-glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
201
-{
202
- return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
203
-}
204
-#endif
205
-
206
-/* generic store macro */
207
-
208
-static inline void
209
-glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
210
- target_ulong ptr,
211
- RES_TYPE v, uintptr_t retaddr)
212
-{
213
- glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX,
214
- retaddr);
215
-}
216
-
217
-static inline void
218
-glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
219
- RES_TYPE v)
220
-{
221
- glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
222
-}
223
-
224
-#undef RES_TYPE
225
-#undef DATA_TYPE
226
-#undef DATA_STYPE
227
-#undef SUFFIX
228
-#undef USUFFIX
229
-#undef DATA_SIZE
230
-#undef SHIFT
231
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
130
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
232
index XXXXXXX..XXXXXXX 100644
131
index XXXXXXX..XXXXXXX 100644
233
--- a/accel/tcg/cputlb.c
132
--- a/accel/tcg/cputlb.c
234
+++ b/accel/tcg/cputlb.c
133
+++ b/accel/tcg/cputlb.c
235
@@ -XXX,XX +XXX,XX @@
134
@@ -XXX,XX +XXX,XX @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr,
236
#include "qemu/atomic128.h"
135
return qemu_ram_addr_from_host_nofail(p);
237
#include "translate-all.h"
238
#include "trace-root.h"
239
-#include "qemu/plugin.h"
240
#include "trace/mem.h"
241
#ifdef CONFIG_PLUGIN
242
#include "qemu/plugin-memory.h"
243
@@ -XXX,XX +XXX,XX @@ uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
244
? helper_le_ldq_mmu : helper_be_ldq_mmu);
245
}
136
}
246
137
247
+uint32_t cpu_ldub_data_ra(CPUArchState *env, target_ulong ptr,
138
-tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr)
248
+ uintptr_t retaddr)
139
-{
140
- return get_page_addr_code_hostp(env, addr, NULL);
141
-}
142
-
143
static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size,
144
CPUIOTLBEntry *iotlbentry, uintptr_t retaddr)
145
{
146
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
147
index XXXXXXX..XXXXXXX 100644
148
--- a/accel/tcg/user-exec.c
149
+++ b/accel/tcg/user-exec.c
150
@@ -XXX,XX +XXX,XX @@ void *probe_access(CPUArchState *env, target_ulong addr, int size,
151
return size ? g2h(env_cpu(env), addr) : NULL;
152
}
153
154
+tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr,
155
+ void **hostp)
249
+{
156
+{
250
+ return cpu_ldub_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
157
+ int flags;
158
+
159
+ flags = probe_access_internal(env, addr, 1, MMU_INST_FETCH, false, 0);
160
+ g_assert(flags == 0);
161
+
162
+ if (hostp) {
163
+ *hostp = g2h_untagged(addr);
164
+ }
165
+ return addr;
251
+}
166
+}
252
+
167
+
253
+int cpu_ldsb_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
168
/* The softmmu versions of these helpers are in cputlb.c. */
254
+{
169
255
+ return cpu_ldsb_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
256
+}
257
+
258
+uint32_t cpu_lduw_data_ra(CPUArchState *env, target_ulong ptr,
259
+ uintptr_t retaddr)
260
+{
261
+ return cpu_lduw_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
262
+}
263
+
264
+int cpu_ldsw_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
265
+{
266
+ return cpu_ldsw_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
267
+}
268
+
269
+uint32_t cpu_ldl_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
270
+{
271
+ return cpu_ldl_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
272
+}
273
+
274
+uint64_t cpu_ldq_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
275
+{
276
+ return cpu_ldq_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
277
+}
278
+
279
+uint32_t cpu_ldub_data(CPUArchState *env, target_ulong ptr)
280
+{
281
+ return cpu_ldub_data_ra(env, ptr, 0);
282
+}
283
+
284
+int cpu_ldsb_data(CPUArchState *env, target_ulong ptr)
285
+{
286
+ return cpu_ldsb_data_ra(env, ptr, 0);
287
+}
288
+
289
+uint32_t cpu_lduw_data(CPUArchState *env, target_ulong ptr)
290
+{
291
+ return cpu_lduw_data_ra(env, ptr, 0);
292
+}
293
+
294
+int cpu_ldsw_data(CPUArchState *env, target_ulong ptr)
295
+{
296
+ return cpu_ldsw_data_ra(env, ptr, 0);
297
+}
298
+
299
+uint32_t cpu_ldl_data(CPUArchState *env, target_ulong ptr)
300
+{
301
+ return cpu_ldl_data_ra(env, ptr, 0);
302
+}
303
+
304
+uint64_t cpu_ldq_data(CPUArchState *env, target_ulong ptr)
305
+{
306
+ return cpu_ldq_data_ra(env, ptr, 0);
307
+}
308
+
309
/*
170
/*
310
* Store Helpers
311
*/
312
@@ -XXX,XX +XXX,XX @@ void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
313
cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEQ);
314
}
315
316
+void cpu_stb_data_ra(CPUArchState *env, target_ulong ptr,
317
+ uint32_t val, uintptr_t retaddr)
318
+{
319
+ cpu_stb_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
320
+}
321
+
322
+void cpu_stw_data_ra(CPUArchState *env, target_ulong ptr,
323
+ uint32_t val, uintptr_t retaddr)
324
+{
325
+ cpu_stw_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
326
+}
327
+
328
+void cpu_stl_data_ra(CPUArchState *env, target_ulong ptr,
329
+ uint32_t val, uintptr_t retaddr)
330
+{
331
+ cpu_stl_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
332
+}
333
+
334
+void cpu_stq_data_ra(CPUArchState *env, target_ulong ptr,
335
+ uint64_t val, uintptr_t retaddr)
336
+{
337
+ cpu_stq_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
338
+}
339
+
340
+void cpu_stb_data(CPUArchState *env, target_ulong ptr, uint32_t val)
341
+{
342
+ cpu_stb_data_ra(env, ptr, val, 0);
343
+}
344
+
345
+void cpu_stw_data(CPUArchState *env, target_ulong ptr, uint32_t val)
346
+{
347
+ cpu_stw_data_ra(env, ptr, val, 0);
348
+}
349
+
350
+void cpu_stl_data(CPUArchState *env, target_ulong ptr, uint32_t val)
351
+{
352
+ cpu_stl_data_ra(env, ptr, val, 0);
353
+}
354
+
355
+void cpu_stq_data(CPUArchState *env, target_ulong ptr, uint64_t val)
356
+{
357
+ cpu_stq_data_ra(env, ptr, val, 0);
358
+}
359
+
360
/* First set of helpers allows passing in of OI and RETADDR. This makes
361
them callable from other helpers. */
362
363
--
171
--
364
2.20.1
172
2.34.1
365
366
diff view generated by jsdifflib
1
With the tracing hooks, the inline functions are no longer
1
The mmap_lock is held around tb_gen_code. While the comment
2
so simple. Reduce the amount of preprocessor obfuscation
2
is correct that the lock is dropped when tb_gen_code runs out
3
by expanding the text of each of the functions generated.
3
of memory, the lock is *not* dropped when an exception is
4
raised reading code for translation.
4
5
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Acked-by: Alistair Francis <alistair.francis@wdc.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
8
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
10
---
9
include/exec/cpu_ldst.h | 54 +++--
11
accel/tcg/cpu-exec.c | 12 ++++++------
10
include/exec/cpu_ldst_useronly_template.h | 159 ---------------
12
accel/tcg/user-exec.c | 3 ---
11
accel/tcg/user-exec.c | 236 ++++++++++++++++++++++
13
2 files changed, 6 insertions(+), 9 deletions(-)
12
3 files changed, 262 insertions(+), 187 deletions(-)
13
delete mode 100644 include/exec/cpu_ldst_useronly_template.h
14
14
15
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
15
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/exec/cpu_ldst.h
17
--- a/accel/tcg/cpu-exec.c
18
+++ b/include/exec/cpu_ldst.h
18
+++ b/accel/tcg/cpu-exec.c
19
@@ -XXX,XX +XXX,XX @@ static inline void clear_helper_retaddr(void)
19
@@ -XXX,XX +XXX,XX @@ void cpu_exec_step_atomic(CPUState *cpu)
20
20
cpu_tb_exec(cpu, tb, &tb_exit);
21
/* In user-only mode we provide only the _code and _data accessors. */
21
cpu_exec_exit(cpu);
22
22
} else {
23
-#define MEMSUFFIX _data
23
- /*
24
-#define DATA_SIZE 1
24
- * The mmap_lock is dropped by tb_gen_code if it runs out of
25
-#include "exec/cpu_ldst_useronly_template.h"
25
- * memory.
26
+uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr);
26
- */
27
+uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr);
27
#ifndef CONFIG_SOFTMMU
28
+uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr);
28
clear_helper_retaddr();
29
+uint64_t cpu_ldq_data(CPUArchState *env, abi_ptr ptr);
29
- tcg_debug_assert(!have_mmap_lock());
30
+int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr);
30
+ if (have_mmap_lock()) {
31
+int cpu_ldsw_data(CPUArchState *env, abi_ptr ptr);
31
+ mmap_unlock();
32
32
+ }
33
-#define DATA_SIZE 2
33
#endif
34
-#include "exec/cpu_ldst_useronly_template.h"
34
if (qemu_mutex_iothread_locked()) {
35
+uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
35
qemu_mutex_unlock_iothread();
36
+uint32_t cpu_lduw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
36
@@ -XXX,XX +XXX,XX @@ int cpu_exec(CPUState *cpu)
37
+uint32_t cpu_ldl_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
37
38
+uint64_t cpu_ldq_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
38
#ifndef CONFIG_SOFTMMU
39
+int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
39
clear_helper_retaddr();
40
+int cpu_ldsw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
40
- tcg_debug_assert(!have_mmap_lock());
41
41
+ if (have_mmap_lock()) {
42
-#define DATA_SIZE 4
42
+ mmap_unlock();
43
-#include "exec/cpu_ldst_useronly_template.h"
43
+ }
44
+void cpu_stb_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
44
#endif
45
+void cpu_stw_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
45
if (qemu_mutex_iothread_locked()) {
46
+void cpu_stl_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
46
qemu_mutex_unlock_iothread();
47
+void cpu_stq_data(CPUArchState *env, abi_ptr ptr, uint64_t val);
48
49
-#define DATA_SIZE 8
50
-#include "exec/cpu_ldst_useronly_template.h"
51
-#undef MEMSUFFIX
52
-
53
-#define MEMSUFFIX _code
54
-#define CODE_ACCESS
55
-#define DATA_SIZE 1
56
-#include "exec/cpu_ldst_useronly_template.h"
57
-
58
-#define DATA_SIZE 2
59
-#include "exec/cpu_ldst_useronly_template.h"
60
-
61
-#define DATA_SIZE 4
62
-#include "exec/cpu_ldst_useronly_template.h"
63
-
64
-#define DATA_SIZE 8
65
-#include "exec/cpu_ldst_useronly_template.h"
66
-#undef MEMSUFFIX
67
-#undef CODE_ACCESS
68
+void cpu_stb_data_ra(CPUArchState *env, abi_ptr ptr,
69
+ uint32_t val, uintptr_t retaddr);
70
+void cpu_stw_data_ra(CPUArchState *env, abi_ptr ptr,
71
+ uint32_t val, uintptr_t retaddr);
72
+void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
73
+ uint32_t val, uintptr_t retaddr);
74
+void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
75
+ uint64_t val, uintptr_t retaddr);
76
77
/*
78
* Provide the same *_mmuidx_ra interface as for softmmu.
79
@@ -XXX,XX +XXX,XX @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
80
#undef CPU_MMU_INDEX
81
#undef MEMSUFFIX
82
83
+#endif /* defined(CONFIG_USER_ONLY) */
84
+
85
uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
86
uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr);
87
uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr);
88
@@ -XXX,XX +XXX,XX @@ static inline int cpu_ldsw_code(CPUArchState *env, abi_ptr addr)
89
return (int16_t)cpu_lduw_code(env, addr);
90
}
91
92
-#endif /* defined(CONFIG_USER_ONLY) */
93
-
94
/**
95
* tlb_vaddr_to_host:
96
* @env: CPUArchState
97
diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h
98
deleted file mode 100644
99
index XXXXXXX..XXXXXXX
100
--- a/include/exec/cpu_ldst_useronly_template.h
101
+++ /dev/null
102
@@ -XXX,XX +XXX,XX @@
103
-/*
104
- * User-only accessor function support
105
- *
106
- * Generate inline load/store functions for one data size.
107
- *
108
- * Generate a store function as well as signed and unsigned loads.
109
- *
110
- * Not used directly but included from cpu_ldst.h.
111
- *
112
- * Copyright (c) 2015 Linaro Limited
113
- *
114
- * This library is free software; you can redistribute it and/or
115
- * modify it under the terms of the GNU Lesser General Public
116
- * License as published by the Free Software Foundation; either
117
- * version 2 of the License, or (at your option) any later version.
118
- *
119
- * This library is distributed in the hope that it will be useful,
120
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
121
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
122
- * Lesser General Public License for more details.
123
- *
124
- * You should have received a copy of the GNU Lesser General Public
125
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
126
- */
127
-
128
-#if !defined(CODE_ACCESS)
129
-#include "trace-root.h"
130
-#endif
131
-
132
-#include "trace/mem.h"
133
-
134
-#if DATA_SIZE == 8
135
-#define SUFFIX q
136
-#define USUFFIX q
137
-#define DATA_TYPE uint64_t
138
-#define SHIFT 3
139
-#elif DATA_SIZE == 4
140
-#define SUFFIX l
141
-#define USUFFIX l
142
-#define DATA_TYPE uint32_t
143
-#define SHIFT 2
144
-#elif DATA_SIZE == 2
145
-#define SUFFIX w
146
-#define USUFFIX uw
147
-#define DATA_TYPE uint16_t
148
-#define DATA_STYPE int16_t
149
-#define SHIFT 1
150
-#elif DATA_SIZE == 1
151
-#define SUFFIX b
152
-#define USUFFIX ub
153
-#define DATA_TYPE uint8_t
154
-#define DATA_STYPE int8_t
155
-#define SHIFT 0
156
-#else
157
-#error unsupported data size
158
-#endif
159
-
160
-#if DATA_SIZE == 8
161
-#define RES_TYPE uint64_t
162
-#else
163
-#define RES_TYPE uint32_t
164
-#endif
165
-
166
-static inline RES_TYPE
167
-glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
168
-{
169
- RES_TYPE ret;
170
-#ifdef CODE_ACCESS
171
- set_helper_retaddr(1);
172
- ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
173
- clear_helper_retaddr();
174
-#else
175
- MemOp op = MO_TE | SHIFT;
176
- uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
177
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
178
- ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
179
-#endif
180
- return ret;
181
-}
182
-
183
-#ifndef CODE_ACCESS
184
-static inline RES_TYPE
185
-glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
186
- abi_ptr ptr,
187
- uintptr_t retaddr)
188
-{
189
- RES_TYPE ret;
190
- set_helper_retaddr(retaddr);
191
- ret = glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(env, ptr);
192
- clear_helper_retaddr();
193
- return ret;
194
-}
195
-#endif
196
-
197
-#if DATA_SIZE <= 2
198
-static inline int
199
-glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
200
-{
201
- int ret;
202
-#ifdef CODE_ACCESS
203
- set_helper_retaddr(1);
204
- ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
205
- clear_helper_retaddr();
206
-#else
207
- MemOp op = MO_TE | MO_SIGN | SHIFT;
208
- uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
209
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
210
- ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
211
- qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
212
-#endif
213
- return ret;
214
-}
215
-
216
-#ifndef CODE_ACCESS
217
-static inline int
218
-glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
219
- abi_ptr ptr,
220
- uintptr_t retaddr)
221
-{
222
- int ret;
223
- set_helper_retaddr(retaddr);
224
- ret = glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(env, ptr);
225
- clear_helper_retaddr();
226
- return ret;
227
-}
228
-#endif /* CODE_ACCESS */
229
-#endif /* DATA_SIZE <= 2 */
230
-
231
-#ifndef CODE_ACCESS
232
-static inline void
233
-glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
234
- RES_TYPE v)
235
-{
236
- MemOp op = MO_TE | SHIFT;
237
- uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, true);
238
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
239
- glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
240
- qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
241
-}
242
-
243
-static inline void
244
-glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
245
- abi_ptr ptr,
246
- RES_TYPE v,
247
- uintptr_t retaddr)
248
-{
249
- set_helper_retaddr(retaddr);
250
- glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(env, ptr, v);
251
- clear_helper_retaddr();
252
-}
253
-#endif
254
-
255
-#undef RES_TYPE
256
-#undef DATA_TYPE
257
-#undef DATA_STYPE
258
-#undef SUFFIX
259
-#undef USUFFIX
260
-#undef DATA_SIZE
261
-#undef SHIFT
262
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
47
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
263
index XXXXXXX..XXXXXXX 100644
48
index XXXXXXX..XXXXXXX 100644
264
--- a/accel/tcg/user-exec.c
49
--- a/accel/tcg/user-exec.c
265
+++ b/accel/tcg/user-exec.c
50
+++ b/accel/tcg/user-exec.c
266
@@ -XXX,XX +XXX,XX @@
51
@@ -XXX,XX +XXX,XX @@ MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write)
267
#include "translate-all.h"
52
* (and if the translator doesn't handle page boundaries correctly
268
#include "exec/helper-proto.h"
53
* there's little we can do about that here). Therefore, do not
269
#include "qemu/atomic128.h"
54
* trigger the unwinder.
270
+#include "trace-root.h"
55
- *
271
+#include "trace/mem.h"
56
- * Like tb_gen_code, release the memory lock before cpu_loop_exit.
272
57
*/
273
#undef EAX
58
- mmap_unlock();
274
#undef ECX
59
*pc = 0;
275
@@ -XXX,XX +XXX,XX @@ int cpu_signal_handler(int host_signum, void *pinfo,
60
return MMU_INST_FETCH;
276
61
}
277
/* The softmmu versions of these helpers are in cputlb.c. */
278
279
+uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr)
280
+{
281
+ uint32_t ret;
282
+ uint16_t meminfo = trace_mem_get_info(MO_UB, MMU_USER_IDX, false);
283
+
284
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
285
+ ret = ldub_p(g2h(ptr));
286
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
287
+ return ret;
288
+}
289
+
290
+int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr)
291
+{
292
+ int ret;
293
+ uint16_t meminfo = trace_mem_get_info(MO_SB, MMU_USER_IDX, false);
294
+
295
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
296
+ ret = ldsb_p(g2h(ptr));
297
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
298
+ return ret;
299
+}
300
+
301
+uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr)
302
+{
303
+ uint32_t ret;
304
+ uint16_t meminfo = trace_mem_get_info(MO_TEUW, MMU_USER_IDX, false);
305
+
306
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
307
+ ret = lduw_p(g2h(ptr));
308
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
309
+ return ret;
310
+}
311
+
312
+int cpu_ldsw_data(CPUArchState *env, abi_ptr ptr)
313
+{
314
+ int ret;
315
+ uint16_t meminfo = trace_mem_get_info(MO_TESW, MMU_USER_IDX, false);
316
+
317
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
318
+ ret = ldsw_p(g2h(ptr));
319
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
320
+ return ret;
321
+}
322
+
323
+uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr)
324
+{
325
+ uint32_t ret;
326
+ uint16_t meminfo = trace_mem_get_info(MO_TEUL, MMU_USER_IDX, false);
327
+
328
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
329
+ ret = ldl_p(g2h(ptr));
330
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
331
+ return ret;
332
+}
333
+
334
+uint64_t cpu_ldq_data(CPUArchState *env, abi_ptr ptr)
335
+{
336
+ uint64_t ret;
337
+ uint16_t meminfo = trace_mem_get_info(MO_TEQ, MMU_USER_IDX, false);
338
+
339
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
340
+ ret = ldq_p(g2h(ptr));
341
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
342
+ return ret;
343
+}
344
+
345
+uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
346
+{
347
+ uint32_t ret;
348
+
349
+ set_helper_retaddr(retaddr);
350
+ ret = cpu_ldub_data(env, ptr);
351
+ clear_helper_retaddr();
352
+ return ret;
353
+}
354
+
355
+int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
356
+{
357
+ int ret;
358
+
359
+ set_helper_retaddr(retaddr);
360
+ ret = cpu_ldsb_data(env, ptr);
361
+ clear_helper_retaddr();
362
+ return ret;
363
+}
364
+
365
+uint32_t cpu_lduw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
366
+{
367
+ uint32_t ret;
368
+
369
+ set_helper_retaddr(retaddr);
370
+ ret = cpu_lduw_data(env, ptr);
371
+ clear_helper_retaddr();
372
+ return ret;
373
+}
374
+
375
+int cpu_ldsw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
376
+{
377
+ int ret;
378
+
379
+ set_helper_retaddr(retaddr);
380
+ ret = cpu_ldsw_data(env, ptr);
381
+ clear_helper_retaddr();
382
+ return ret;
383
+}
384
+
385
+uint32_t cpu_ldl_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
386
+{
387
+ uint32_t ret;
388
+
389
+ set_helper_retaddr(retaddr);
390
+ ret = cpu_ldl_data(env, ptr);
391
+ clear_helper_retaddr();
392
+ return ret;
393
+}
394
+
395
+uint64_t cpu_ldq_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
396
+{
397
+ uint64_t ret;
398
+
399
+ set_helper_retaddr(retaddr);
400
+ ret = cpu_ldq_data(env, ptr);
401
+ clear_helper_retaddr();
402
+ return ret;
403
+}
404
+
405
+void cpu_stb_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
406
+{
407
+ uint16_t meminfo = trace_mem_get_info(MO_UB, MMU_USER_IDX, true);
408
+
409
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
410
+ stb_p(g2h(ptr), val);
411
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
412
+}
413
+
414
+void cpu_stw_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
415
+{
416
+ uint16_t meminfo = trace_mem_get_info(MO_TEUW, MMU_USER_IDX, true);
417
+
418
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
419
+ stw_p(g2h(ptr), val);
420
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
421
+}
422
+
423
+void cpu_stl_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
424
+{
425
+ uint16_t meminfo = trace_mem_get_info(MO_TEUL, MMU_USER_IDX, true);
426
+
427
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
428
+ stl_p(g2h(ptr), val);
429
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
430
+}
431
+
432
+void cpu_stq_data(CPUArchState *env, abi_ptr ptr, uint64_t val)
433
+{
434
+ uint16_t meminfo = trace_mem_get_info(MO_TEQ, MMU_USER_IDX, true);
435
+
436
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
437
+ stq_p(g2h(ptr), val);
438
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
439
+}
440
+
441
+void cpu_stb_data_ra(CPUArchState *env, abi_ptr ptr,
442
+ uint32_t val, uintptr_t retaddr)
443
+{
444
+ set_helper_retaddr(retaddr);
445
+ cpu_stb_data(env, ptr, val);
446
+ clear_helper_retaddr();
447
+}
448
+
449
+void cpu_stw_data_ra(CPUArchState *env, abi_ptr ptr,
450
+ uint32_t val, uintptr_t retaddr)
451
+{
452
+ set_helper_retaddr(retaddr);
453
+ cpu_stw_data(env, ptr, val);
454
+ clear_helper_retaddr();
455
+}
456
+
457
+void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
458
+ uint32_t val, uintptr_t retaddr)
459
+{
460
+ set_helper_retaddr(retaddr);
461
+ cpu_stl_data(env, ptr, val);
462
+ clear_helper_retaddr();
463
+}
464
+
465
+void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
466
+ uint64_t val, uintptr_t retaddr)
467
+{
468
+ set_helper_retaddr(retaddr);
469
+ cpu_stq_data(env, ptr, val);
470
+ clear_helper_retaddr();
471
+}
472
+
473
+uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr ptr)
474
+{
475
+ uint32_t ret;
476
+
477
+ set_helper_retaddr(1);
478
+ ret = ldub_p(g2h(ptr));
479
+ clear_helper_retaddr();
480
+ return ret;
481
+}
482
+
483
+uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr ptr)
484
+{
485
+ uint32_t ret;
486
+
487
+ set_helper_retaddr(1);
488
+ ret = lduw_p(g2h(ptr));
489
+ clear_helper_retaddr();
490
+ return ret;
491
+}
492
+
493
+uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr ptr)
494
+{
495
+ uint32_t ret;
496
+
497
+ set_helper_retaddr(1);
498
+ ret = ldl_p(g2h(ptr));
499
+ clear_helper_retaddr();
500
+ return ret;
501
+}
502
+
503
+uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr ptr)
504
+{
505
+ uint64_t ret;
506
+
507
+ set_helper_retaddr(1);
508
+ ret = ldq_p(g2h(ptr));
509
+ clear_helper_retaddr();
510
+ return ret;
511
+}
512
+
513
/* Do not allow unaligned operations to proceed. Return the host address. */
514
static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
515
int size, uintptr_t retaddr)
516
--
62
--
517
2.20.1
63
2.34.1
518
519
diff view generated by jsdifflib
1
It is easy for the atomic helpers to use trace_mem_build_info
1
The function is not used outside of cpu-exec.c. Move it and
2
directly, without resorting to symbol pasting. For this usage,
2
its subroutines up in the file, before the first use.
3
we cannot use trace_mem_get_info, because the MemOp does not
4
support 16-byte accesses.
5
3
6
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
6
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
8
---
10
accel/tcg/atomic_template.h | 67 +++++++++++++------------------------
9
include/exec/exec-all.h | 3 -
11
trace/mem-internal.h | 17 ----------
10
accel/tcg/cpu-exec.c | 122 ++++++++++++++++++++--------------------
12
2 files changed, 24 insertions(+), 60 deletions(-)
11
2 files changed, 61 insertions(+), 64 deletions(-)
13
12
14
diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h
13
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/accel/tcg/atomic_template.h
15
--- a/include/exec/exec-all.h
17
+++ b/accel/tcg/atomic_template.h
16
+++ b/include/exec/exec-all.h
18
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs);
19
the ATOMIC_NAME macro, and redefined below. */
20
#if DATA_SIZE == 1
21
# define END
22
-# define MEND _be /* either le or be would be fine */
23
#elif defined(HOST_WORDS_BIGENDIAN)
24
# define END _be
25
-# define MEND _be
26
#else
27
# define END _le
28
-# define MEND _le
29
#endif
18
#endif
30
19
void tb_flush(CPUState *cpu);
31
ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
20
void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr);
32
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
21
-TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc,
33
ATOMIC_MMU_DECLS;
22
- target_ulong cs_base, uint32_t flags,
34
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
23
- uint32_t cflags);
35
DATA_TYPE ret;
24
void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr);
36
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
25
37
- ATOMIC_MMU_IDX);
26
/* GETPC is the true target of the return instruction that we'll execute. */
38
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
27
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
39
+ ATOMIC_MMU_IDX);
40
41
atomic_trace_rmw_pre(env, addr, info);
42
#if DATA_SIZE == 16
43
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS)
44
{
45
ATOMIC_MMU_DECLS;
46
DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP;
47
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
48
- ATOMIC_MMU_IDX);
49
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
50
+ ATOMIC_MMU_IDX);
51
52
atomic_trace_ld_pre(env, addr, info);
53
val = atomic16_read(haddr);
54
@@ -XXX,XX +XXX,XX @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr,
55
{
56
ATOMIC_MMU_DECLS;
57
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
58
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, true,
59
- ATOMIC_MMU_IDX);
60
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, true,
61
+ ATOMIC_MMU_IDX);
62
63
atomic_trace_st_pre(env, addr, info);
64
atomic16_set(haddr, val);
65
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr,
66
ATOMIC_MMU_DECLS;
67
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
68
DATA_TYPE ret;
69
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
70
- ATOMIC_MMU_IDX);
71
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
72
+ ATOMIC_MMU_IDX);
73
74
atomic_trace_rmw_pre(env, addr, info);
75
ret = atomic_xchg__nocheck(haddr, val);
76
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \
77
ATOMIC_MMU_DECLS; \
78
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \
79
DATA_TYPE ret; \
80
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \
81
- false, \
82
- ATOMIC_MMU_IDX); \
83
- \
84
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, false, \
85
+ ATOMIC_MMU_IDX); \
86
atomic_trace_rmw_pre(env, addr, info); \
87
ret = atomic_##X(haddr, val); \
88
ATOMIC_MMU_CLEANUP; \
89
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \
90
ATOMIC_MMU_DECLS; \
91
XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \
92
XDATA_TYPE cmp, old, new, val = xval; \
93
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \
94
- false, \
95
- ATOMIC_MMU_IDX); \
96
- \
97
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, false, \
98
+ ATOMIC_MMU_IDX); \
99
atomic_trace_rmw_pre(env, addr, info); \
100
smp_mb(); \
101
cmp = atomic_read__nocheck(haddr); \
102
@@ -XXX,XX +XXX,XX @@ GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new)
103
#endif /* DATA SIZE >= 16 */
104
105
#undef END
106
-#undef MEND
107
108
#if DATA_SIZE > 1
109
110
@@ -XXX,XX +XXX,XX @@ GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new)
111
within the ATOMIC_NAME macro. */
112
#ifdef HOST_WORDS_BIGENDIAN
113
# define END _le
114
-# define MEND _le
115
#else
116
# define END _be
117
-# define MEND _be
118
#endif
119
120
ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
121
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
122
ATOMIC_MMU_DECLS;
123
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
124
DATA_TYPE ret;
125
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
126
- false,
127
- ATOMIC_MMU_IDX);
128
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, false,
129
+ ATOMIC_MMU_IDX);
130
131
atomic_trace_rmw_pre(env, addr, info);
132
#if DATA_SIZE == 16
133
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS)
134
{
135
ATOMIC_MMU_DECLS;
136
DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP;
137
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
138
- false,
139
- ATOMIC_MMU_IDX);
140
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, false,
141
+ ATOMIC_MMU_IDX);
142
143
atomic_trace_ld_pre(env, addr, info);
144
val = atomic16_read(haddr);
145
@@ -XXX,XX +XXX,XX @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr,
146
{
147
ATOMIC_MMU_DECLS;
148
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
149
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
150
- true,
151
- ATOMIC_MMU_IDX);
152
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, true,
153
+ ATOMIC_MMU_IDX);
154
155
val = BSWAP(val);
156
atomic_trace_st_pre(env, addr, info);
157
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr,
158
ATOMIC_MMU_DECLS;
159
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
160
ABI_TYPE ret;
161
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
162
- false,
163
- ATOMIC_MMU_IDX);
164
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, false,
165
+ ATOMIC_MMU_IDX);
166
167
atomic_trace_rmw_pre(env, addr, info);
168
ret = atomic_xchg__nocheck(haddr, BSWAP(val));
169
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \
170
ATOMIC_MMU_DECLS; \
171
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \
172
DATA_TYPE ret; \
173
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \
174
- false, \
175
- ATOMIC_MMU_IDX); \
176
- \
177
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, \
178
+ false, ATOMIC_MMU_IDX); \
179
atomic_trace_rmw_pre(env, addr, info); \
180
ret = atomic_##X(haddr, BSWAP(val)); \
181
ATOMIC_MMU_CLEANUP; \
182
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \
183
ATOMIC_MMU_DECLS; \
184
XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \
185
XDATA_TYPE ldo, ldn, old, new, val = xval; \
186
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \
187
- false, \
188
- ATOMIC_MMU_IDX); \
189
- \
190
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, \
191
+ false, ATOMIC_MMU_IDX); \
192
atomic_trace_rmw_pre(env, addr, info); \
193
smp_mb(); \
194
ldn = atomic_read__nocheck(haddr); \
195
@@ -XXX,XX +XXX,XX @@ GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new)
196
#endif /* DATA_SIZE >= 16 */
197
198
#undef END
199
-#undef MEND
200
#endif /* DATA_SIZE > 1 */
201
202
#undef BSWAP
203
diff --git a/trace/mem-internal.h b/trace/mem-internal.h
204
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
205
--- a/trace/mem-internal.h
29
--- a/accel/tcg/cpu-exec.c
206
+++ b/trace/mem-internal.h
30
+++ b/accel/tcg/cpu-exec.c
207
@@ -XXX,XX +XXX,XX @@ static inline uint16_t trace_mem_get_info(MemOp op,
31
@@ -XXX,XX +XXX,XX @@ uint32_t curr_cflags(CPUState *cpu)
208
mmu_idx);
32
return cflags;
209
}
33
}
210
34
211
-/* Used by the atomic helpers */
35
+struct tb_desc {
212
-static inline
36
+ target_ulong pc;
213
-uint16_t trace_mem_build_info_no_se_be(int size_shift, bool store,
37
+ target_ulong cs_base;
214
- TCGMemOpIdx oi)
38
+ CPUArchState *env;
39
+ tb_page_addr_t phys_page1;
40
+ uint32_t flags;
41
+ uint32_t cflags;
42
+ uint32_t trace_vcpu_dstate;
43
+};
44
+
45
+static bool tb_lookup_cmp(const void *p, const void *d)
46
+{
47
+ const TranslationBlock *tb = p;
48
+ const struct tb_desc *desc = d;
49
+
50
+ if (tb->pc == desc->pc &&
51
+ tb->page_addr[0] == desc->phys_page1 &&
52
+ tb->cs_base == desc->cs_base &&
53
+ tb->flags == desc->flags &&
54
+ tb->trace_vcpu_dstate == desc->trace_vcpu_dstate &&
55
+ tb_cflags(tb) == desc->cflags) {
56
+ /* check next page if needed */
57
+ if (tb->page_addr[1] == -1) {
58
+ return true;
59
+ } else {
60
+ tb_page_addr_t phys_page2;
61
+ target_ulong virt_page2;
62
+
63
+ virt_page2 = (desc->pc & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
64
+ phys_page2 = get_page_addr_code(desc->env, virt_page2);
65
+ if (tb->page_addr[1] == phys_page2) {
66
+ return true;
67
+ }
68
+ }
69
+ }
70
+ return false;
71
+}
72
+
73
+static TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc,
74
+ target_ulong cs_base, uint32_t flags,
75
+ uint32_t cflags)
76
+{
77
+ tb_page_addr_t phys_pc;
78
+ struct tb_desc desc;
79
+ uint32_t h;
80
+
81
+ desc.env = cpu->env_ptr;
82
+ desc.cs_base = cs_base;
83
+ desc.flags = flags;
84
+ desc.cflags = cflags;
85
+ desc.trace_vcpu_dstate = *cpu->trace_dstate;
86
+ desc.pc = pc;
87
+ phys_pc = get_page_addr_code(desc.env, pc);
88
+ if (phys_pc == -1) {
89
+ return NULL;
90
+ }
91
+ desc.phys_page1 = phys_pc & TARGET_PAGE_MASK;
92
+ h = tb_hash_func(phys_pc, pc, flags, cflags, *cpu->trace_dstate);
93
+ return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp);
94
+}
95
+
96
/* Might cause an exception, so have a longjmp destination ready */
97
static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc,
98
target_ulong cs_base,
99
@@ -XXX,XX +XXX,XX @@ void cpu_exec_step_atomic(CPUState *cpu)
100
end_exclusive();
101
}
102
103
-struct tb_desc {
104
- target_ulong pc;
105
- target_ulong cs_base;
106
- CPUArchState *env;
107
- tb_page_addr_t phys_page1;
108
- uint32_t flags;
109
- uint32_t cflags;
110
- uint32_t trace_vcpu_dstate;
111
-};
112
-
113
-static bool tb_lookup_cmp(const void *p, const void *d)
215
-{
114
-{
216
- return trace_mem_build_info(size_shift, false, MO_BE, store,
115
- const TranslationBlock *tb = p;
217
- get_mmuidx(oi));
116
- const struct tb_desc *desc = d;
117
-
118
- if (tb->pc == desc->pc &&
119
- tb->page_addr[0] == desc->phys_page1 &&
120
- tb->cs_base == desc->cs_base &&
121
- tb->flags == desc->flags &&
122
- tb->trace_vcpu_dstate == desc->trace_vcpu_dstate &&
123
- tb_cflags(tb) == desc->cflags) {
124
- /* check next page if needed */
125
- if (tb->page_addr[1] == -1) {
126
- return true;
127
- } else {
128
- tb_page_addr_t phys_page2;
129
- target_ulong virt_page2;
130
-
131
- virt_page2 = (desc->pc & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
132
- phys_page2 = get_page_addr_code(desc->env, virt_page2);
133
- if (tb->page_addr[1] == phys_page2) {
134
- return true;
135
- }
136
- }
137
- }
138
- return false;
218
-}
139
-}
219
-
140
-
220
-static inline
141
-TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc,
221
-uint16_t trace_mem_build_info_no_se_le(int size_shift, bool store,
142
- target_ulong cs_base, uint32_t flags,
222
- TCGMemOpIdx oi)
143
- uint32_t cflags)
223
-{
144
-{
224
- return trace_mem_build_info(size_shift, false, MO_LE, store,
145
- tb_page_addr_t phys_pc;
225
- get_mmuidx(oi));
146
- struct tb_desc desc;
147
- uint32_t h;
148
-
149
- desc.env = cpu->env_ptr;
150
- desc.cs_base = cs_base;
151
- desc.flags = flags;
152
- desc.cflags = cflags;
153
- desc.trace_vcpu_dstate = *cpu->trace_dstate;
154
- desc.pc = pc;
155
- phys_pc = get_page_addr_code(desc.env, pc);
156
- if (phys_pc == -1) {
157
- return NULL;
158
- }
159
- desc.phys_page1 = phys_pc & TARGET_PAGE_MASK;
160
- h = tb_hash_func(phys_pc, pc, flags, cflags, *cpu->trace_dstate);
161
- return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp);
226
-}
162
-}
227
-
163
-
228
#endif /* TRACE__MEM_INTERNAL_H */
164
void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr)
165
{
166
if (TCG_TARGET_HAS_direct_jump) {
229
--
167
--
230
2.20.1
168
2.34.1
231
232
diff view generated by jsdifflib
1
There are no uses of the *_cmmu names other than the bare wrapping
1
The base qemu_ram_addr_from_host function is already in
2
within the *_code inlines. Therefore rename the functions so we
2
softmmu/physmem.c; move the nofail version to be adjacent.
3
can drop the inlines.
4
3
5
Use abi_ptr instead of target_ulong in preparation for user-only;
4
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
the two types are identical for softmmu.
5
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
7
6
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
8
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
---
8
---
12
include/exec/cpu_ldst.h | 29 ++++------
9
include/exec/cpu-common.h | 1 +
13
include/exec/cpu_ldst_template.h | 21 -------
10
accel/tcg/cputlb.c | 12 ------------
14
tcg/tcg.h | 29 ----------
11
softmmu/physmem.c | 12 ++++++++++++
15
accel/tcg/cputlb.c | 94 ++++++++------------------------
12
3 files changed, 13 insertions(+), 12 deletions(-)
16
docs/devel/loads-stores.rst | 4 +-
17
5 files changed, 36 insertions(+), 141 deletions(-)
18
13
19
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
14
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
20
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
21
--- a/include/exec/cpu_ldst.h
16
--- a/include/exec/cpu-common.h
22
+++ b/include/exec/cpu_ldst.h
17
+++ b/include/exec/cpu-common.h
23
@@ -XXX,XX +XXX,XX @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
18
@@ -XXX,XX +XXX,XX @@ typedef uintptr_t ram_addr_t;
24
#undef CPU_MMU_INDEX
19
void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
25
#undef MEMSUFFIX
20
/* This should not be used by devices. */
26
21
ram_addr_t qemu_ram_addr_from_host(void *ptr);
27
-#define CPU_MMU_INDEX (cpu_mmu_index(env, true))
22
+ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr);
28
-#define MEMSUFFIX _code
23
RAMBlock *qemu_ram_block_by_name(const char *name);
29
-#define SOFTMMU_CODE_ACCESS
24
RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
30
+uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
25
ram_addr_t *offset);
31
+uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr);
32
+uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr);
33
+uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr);
34
35
-#define DATA_SIZE 1
36
-#include "exec/cpu_ldst_template.h"
37
+static inline int cpu_ldsb_code(CPUArchState *env, abi_ptr addr)
38
+{
39
+ return (int8_t)cpu_ldub_code(env, addr);
40
+}
41
42
-#define DATA_SIZE 2
43
-#include "exec/cpu_ldst_template.h"
44
-
45
-#define DATA_SIZE 4
46
-#include "exec/cpu_ldst_template.h"
47
-
48
-#define DATA_SIZE 8
49
-#include "exec/cpu_ldst_template.h"
50
-
51
-#undef CPU_MMU_INDEX
52
-#undef MEMSUFFIX
53
-#undef SOFTMMU_CODE_ACCESS
54
+static inline int cpu_ldsw_code(CPUArchState *env, abi_ptr addr)
55
+{
56
+ return (int16_t)cpu_lduw_code(env, addr);
57
+}
58
59
#endif /* defined(CONFIG_USER_ONLY) */
60
61
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
62
index XXXXXXX..XXXXXXX 100644
63
--- a/include/exec/cpu_ldst_template.h
64
+++ b/include/exec/cpu_ldst_template.h
65
@@ -XXX,XX +XXX,XX @@
66
67
/* generic load/store macros */
68
69
-#ifdef SOFTMMU_CODE_ACCESS
70
-
71
-static inline RES_TYPE
72
-glue(glue(cpu_ld, USUFFIX), _code)(CPUArchState *env, target_ulong ptr)
73
-{
74
- TCGMemOpIdx oi = make_memop_idx(MO_TE | SHIFT, CPU_MMU_INDEX);
75
- return glue(glue(helper_ret_ld, USUFFIX), _cmmu)(env, ptr, oi, 0);
76
-}
77
-
78
-#if DATA_SIZE <= 2
79
-static inline int
80
-glue(glue(cpu_lds, SUFFIX), _code)(CPUArchState *env, target_ulong ptr)
81
-{
82
- return (DATA_STYPE)glue(glue(cpu_ld, USUFFIX), _code)(env, ptr);
83
-}
84
-#endif
85
-
86
-#else
87
-
88
static inline RES_TYPE
89
glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
90
target_ulong ptr,
91
@@ -XXX,XX +XXX,XX @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
92
glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
93
}
94
95
-#endif /* !SOFTMMU_CODE_ACCESS */
96
-
97
#undef RES_TYPE
98
#undef DATA_TYPE
99
#undef DATA_STYPE
100
diff --git a/tcg/tcg.h b/tcg/tcg.h
101
index XXXXXXX..XXXXXXX 100644
102
--- a/tcg/tcg.h
103
+++ b/tcg/tcg.h
104
@@ -XXX,XX +XXX,XX @@ void helper_be_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val,
105
void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,
106
TCGMemOpIdx oi, uintptr_t retaddr);
107
108
-uint8_t helper_ret_ldub_cmmu(CPUArchState *env, target_ulong addr,
109
- TCGMemOpIdx oi, uintptr_t retaddr);
110
-int8_t helper_ret_ldsb_cmmu(CPUArchState *env, target_ulong addr,
111
- TCGMemOpIdx oi, uintptr_t retaddr);
112
-uint16_t helper_le_lduw_cmmu(CPUArchState *env, target_ulong addr,
113
- TCGMemOpIdx oi, uintptr_t retaddr);
114
-int16_t helper_le_ldsw_cmmu(CPUArchState *env, target_ulong addr,
115
- TCGMemOpIdx oi, uintptr_t retaddr);
116
-uint32_t helper_le_ldl_cmmu(CPUArchState *env, target_ulong addr,
117
- TCGMemOpIdx oi, uintptr_t retaddr);
118
-uint64_t helper_le_ldq_cmmu(CPUArchState *env, target_ulong addr,
119
- TCGMemOpIdx oi, uintptr_t retaddr);
120
-uint16_t helper_be_lduw_cmmu(CPUArchState *env, target_ulong addr,
121
- TCGMemOpIdx oi, uintptr_t retaddr);
122
-int16_t helper_be_ldsw_cmmu(CPUArchState *env, target_ulong addr,
123
- TCGMemOpIdx oi, uintptr_t retaddr);
124
-uint32_t helper_be_ldl_cmmu(CPUArchState *env, target_ulong addr,
125
- TCGMemOpIdx oi, uintptr_t retaddr);
126
-uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
127
- TCGMemOpIdx oi, uintptr_t retaddr);
128
-
129
/* Temporary aliases until backends are converted. */
130
#ifdef TARGET_WORDS_BIGENDIAN
131
# define helper_ret_ldsw_mmu helper_be_ldsw_mmu
132
@@ -XXX,XX +XXX,XX @@ uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
133
# define helper_ret_stw_mmu helper_be_stw_mmu
134
# define helper_ret_stl_mmu helper_be_stl_mmu
135
# define helper_ret_stq_mmu helper_be_stq_mmu
136
-# define helper_ret_lduw_cmmu helper_be_lduw_cmmu
137
-# define helper_ret_ldsw_cmmu helper_be_ldsw_cmmu
138
-# define helper_ret_ldl_cmmu helper_be_ldl_cmmu
139
-# define helper_ret_ldq_cmmu helper_be_ldq_cmmu
140
#else
141
# define helper_ret_ldsw_mmu helper_le_ldsw_mmu
142
# define helper_ret_lduw_mmu helper_le_lduw_mmu
143
@@ -XXX,XX +XXX,XX @@ uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
144
# define helper_ret_stw_mmu helper_le_stw_mmu
145
# define helper_ret_stl_mmu helper_le_stl_mmu
146
# define helper_ret_stq_mmu helper_le_stq_mmu
147
-# define helper_ret_lduw_cmmu helper_le_lduw_cmmu
148
-# define helper_ret_ldsw_cmmu helper_le_ldsw_cmmu
149
-# define helper_ret_ldl_cmmu helper_le_ldl_cmmu
150
-# define helper_ret_ldq_cmmu helper_le_ldq_cmmu
151
#endif
152
153
uint32_t helper_atomic_cmpxchgb_mmu(CPUArchState *env, target_ulong addr,
154
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
26
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
155
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
156
--- a/accel/tcg/cputlb.c
28
--- a/accel/tcg/cputlb.c
157
+++ b/accel/tcg/cputlb.c
29
+++ b/accel/tcg/cputlb.c
158
@@ -XXX,XX +XXX,XX @@ void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
30
@@ -XXX,XX +XXX,XX @@ void tlb_set_page(CPUState *cpu, target_ulong vaddr,
159
31
prot, mmu_idx, size);
160
/* Code access functions. */
161
162
-static uint64_t full_ldub_cmmu(CPUArchState *env, target_ulong addr,
163
+static uint64_t full_ldub_code(CPUArchState *env, target_ulong addr,
164
TCGMemOpIdx oi, uintptr_t retaddr)
165
{
166
- return load_helper(env, addr, oi, retaddr, MO_8, true, full_ldub_cmmu);
167
+ return load_helper(env, addr, oi, retaddr, MO_8, true, full_ldub_code);
168
}
32
}
169
33
170
-uint8_t helper_ret_ldub_cmmu(CPUArchState *env, target_ulong addr,
34
-static inline ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr)
171
- TCGMemOpIdx oi, uintptr_t retaddr)
35
-{
172
+uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr)
36
- ram_addr_t ram_addr;
173
{
37
-
174
- return full_ldub_cmmu(env, addr, oi, retaddr);
38
- ram_addr = qemu_ram_addr_from_host(ptr);
175
+ TCGMemOpIdx oi = make_memop_idx(MO_UB, cpu_mmu_index(env, true));
39
- if (ram_addr == RAM_ADDR_INVALID) {
176
+ return full_ldub_code(env, addr, oi, 0);
40
- error_report("Bad ram pointer %p", ptr);
177
}
41
- abort();
178
42
- }
179
-int8_t helper_ret_ldsb_cmmu(CPUArchState *env, target_ulong addr,
43
- return ram_addr;
180
- TCGMemOpIdx oi, uintptr_t retaddr)
181
+static uint64_t full_lduw_code(CPUArchState *env, target_ulong addr,
182
+ TCGMemOpIdx oi, uintptr_t retaddr)
183
{
184
- return (int8_t) full_ldub_cmmu(env, addr, oi, retaddr);
185
+ return load_helper(env, addr, oi, retaddr, MO_TEUW, true, full_lduw_code);
186
}
187
188
-static uint64_t full_le_lduw_cmmu(CPUArchState *env, target_ulong addr,
189
- TCGMemOpIdx oi, uintptr_t retaddr)
190
+uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr)
191
{
192
- return load_helper(env, addr, oi, retaddr, MO_LEUW, true,
193
- full_le_lduw_cmmu);
194
+ TCGMemOpIdx oi = make_memop_idx(MO_TEUW, cpu_mmu_index(env, true));
195
+ return full_lduw_code(env, addr, oi, 0);
196
}
197
198
-uint16_t helper_le_lduw_cmmu(CPUArchState *env, target_ulong addr,
199
- TCGMemOpIdx oi, uintptr_t retaddr)
200
+static uint64_t full_ldl_code(CPUArchState *env, target_ulong addr,
201
+ TCGMemOpIdx oi, uintptr_t retaddr)
202
{
203
- return full_le_lduw_cmmu(env, addr, oi, retaddr);
204
+ return load_helper(env, addr, oi, retaddr, MO_TEUL, true, full_ldl_code);
205
}
206
207
-int16_t helper_le_ldsw_cmmu(CPUArchState *env, target_ulong addr,
208
- TCGMemOpIdx oi, uintptr_t retaddr)
209
+uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr)
210
{
211
- return (int16_t) full_le_lduw_cmmu(env, addr, oi, retaddr);
212
+ TCGMemOpIdx oi = make_memop_idx(MO_TEUL, cpu_mmu_index(env, true));
213
+ return full_ldl_code(env, addr, oi, 0);
214
}
215
216
-static uint64_t full_be_lduw_cmmu(CPUArchState *env, target_ulong addr,
217
- TCGMemOpIdx oi, uintptr_t retaddr)
218
+static uint64_t full_ldq_code(CPUArchState *env, target_ulong addr,
219
+ TCGMemOpIdx oi, uintptr_t retaddr)
220
{
221
- return load_helper(env, addr, oi, retaddr, MO_BEUW, true,
222
- full_be_lduw_cmmu);
223
+ return load_helper(env, addr, oi, retaddr, MO_TEQ, true, full_ldq_code);
224
}
225
226
-uint16_t helper_be_lduw_cmmu(CPUArchState *env, target_ulong addr,
227
- TCGMemOpIdx oi, uintptr_t retaddr)
228
+uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr)
229
{
230
- return full_be_lduw_cmmu(env, addr, oi, retaddr);
231
-}
44
-}
232
-
45
-
233
-int16_t helper_be_ldsw_cmmu(CPUArchState *env, target_ulong addr,
46
/*
234
- TCGMemOpIdx oi, uintptr_t retaddr)
47
* Note: tlb_fill() can trigger a resize of the TLB. This means that all of the
235
-{
48
* caller's prior references to the TLB table (e.g. CPUTLBEntry pointers) must
236
- return (int16_t) full_be_lduw_cmmu(env, addr, oi, retaddr);
49
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
237
-}
50
index XXXXXXX..XXXXXXX 100644
238
-
51
--- a/softmmu/physmem.c
239
-static uint64_t full_le_ldul_cmmu(CPUArchState *env, target_ulong addr,
52
+++ b/softmmu/physmem.c
240
- TCGMemOpIdx oi, uintptr_t retaddr)
53
@@ -XXX,XX +XXX,XX @@ ram_addr_t qemu_ram_addr_from_host(void *ptr)
241
-{
54
return block->offset + offset;
242
- return load_helper(env, addr, oi, retaddr, MO_LEUL, true,
243
- full_le_ldul_cmmu);
244
-}
245
-
246
-uint32_t helper_le_ldl_cmmu(CPUArchState *env, target_ulong addr,
247
- TCGMemOpIdx oi, uintptr_t retaddr)
248
-{
249
- return full_le_ldul_cmmu(env, addr, oi, retaddr);
250
-}
251
-
252
-static uint64_t full_be_ldul_cmmu(CPUArchState *env, target_ulong addr,
253
- TCGMemOpIdx oi, uintptr_t retaddr)
254
-{
255
- return load_helper(env, addr, oi, retaddr, MO_BEUL, true,
256
- full_be_ldul_cmmu);
257
-}
258
-
259
-uint32_t helper_be_ldl_cmmu(CPUArchState *env, target_ulong addr,
260
- TCGMemOpIdx oi, uintptr_t retaddr)
261
-{
262
- return full_be_ldul_cmmu(env, addr, oi, retaddr);
263
-}
264
-
265
-uint64_t helper_le_ldq_cmmu(CPUArchState *env, target_ulong addr,
266
- TCGMemOpIdx oi, uintptr_t retaddr)
267
-{
268
- return load_helper(env, addr, oi, retaddr, MO_LEQ, true,
269
- helper_le_ldq_cmmu);
270
-}
271
-
272
-uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
273
- TCGMemOpIdx oi, uintptr_t retaddr)
274
-{
275
- return load_helper(env, addr, oi, retaddr, MO_BEQ, true,
276
- helper_be_ldq_cmmu);
277
+ TCGMemOpIdx oi = make_memop_idx(MO_TEQ, cpu_mmu_index(env, true));
278
+ return full_ldq_code(env, addr, oi, 0);
279
}
55
}
280
diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst
56
281
index XXXXXXX..XXXXXXX 100644
57
+ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr)
282
--- a/docs/devel/loads-stores.rst
58
+{
283
+++ b/docs/devel/loads-stores.rst
59
+ ram_addr_t ram_addr;
284
@@ -XXX,XX +XXX,XX @@ more in line with the other memory access functions.
60
+
285
61
+ ram_addr = qemu_ram_addr_from_host(ptr);
286
load: ``helper_{endian}_ld{sign}{size}_mmu(env, addr, opindex, retaddr)``
62
+ if (ram_addr == RAM_ADDR_INVALID) {
287
63
+ error_report("Bad ram pointer %p", ptr);
288
-load (code): ``helper_{endian}_ld{sign}{size}_cmmu(env, addr, opindex, retaddr)``
64
+ abort();
289
-
65
+ }
290
store: ``helper_{endian}_st{size}_mmu(env, addr, val, opindex, retaddr)``
66
+ return ram_addr;
291
67
+}
292
``sign``
68
+
293
@@ -XXX,XX +XXX,XX @@ store: ``helper_{endian}_st{size}_mmu(env, addr, val, opindex, retaddr)``
69
static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
294
- ``ret`` : target endianness
70
MemTxAttrs attrs, void *buf, hwaddr len);
295
71
static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
296
Regexes for git grep
297
- - ``\<helper_\(le\|be\|ret\)_ld[us]\?[bwlq]_c\?mmu\>``
298
+ - ``\<helper_\(le\|be\|ret\)_ld[us]\?[bwlq]_mmu\>``
299
- ``\<helper_\(le\|be\|ret\)_st[bwlq]_mmu\>``
300
301
``address_space_*``
302
--
72
--
303
2.20.1
73
2.34.1
304
305
diff view generated by jsdifflib
1
With the tracing hooks, the inline functions are no longer
1
Simplify the implementation of get_page_addr_code_hostp
2
so simple. Once out-of-line, the current tlb_entry lookup
2
by reusing the existing probe_access infrastructure.
3
is redundant with the one in the main load/store_helper.
4
3
5
This also begins the introduction of a new target facing
4
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
6
interface, with suffix *_mmuidx_ra. This is not yet
5
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
7
official because the interface is not done for user-only.
8
9
Use abi_ptr instead of target_ulong in preparation for
10
user-only; the two types are identical for softmmu.
11
12
What remains in cpu_ldst_template.h are the expansions
13
for _code, _data, and MMU_MODE<N>_SUFFIX.
14
15
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
16
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
17
---
7
---
18
include/exec/cpu_ldst.h | 25 ++++++-
8
accel/tcg/cputlb.c | 76 ++++++++++++++++------------------------------
19
include/exec/cpu_ldst_template.h | 125 +++++++------------------------
9
1 file changed, 26 insertions(+), 50 deletions(-)
20
accel/tcg/cputlb.c | 116 ++++++++++++++++++++++++++++
21
3 files changed, 166 insertions(+), 100 deletions(-)
22
10
23
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
24
index XXXXXXX..XXXXXXX 100644
25
--- a/include/exec/cpu_ldst.h
26
+++ b/include/exec/cpu_ldst.h
27
@@ -XXX,XX +XXX,XX @@ static inline void clear_helper_retaddr(void)
28
29
#else
30
31
-/* The memory helpers for tcg-generated code need tcg_target_long etc. */
32
+/* Needed for TCG_OVERSIZED_GUEST */
33
#include "tcg.h"
34
35
static inline target_ulong tlb_addr_write(const CPUTLBEntry *entry)
36
@@ -XXX,XX +XXX,XX @@ static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx,
37
return &env_tlb(env)->f[mmu_idx].table[tlb_index(env, mmu_idx, addr)];
38
}
39
40
+uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
41
+ int mmu_idx, uintptr_t ra);
42
+uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
43
+ int mmu_idx, uintptr_t ra);
44
+uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
45
+ int mmu_idx, uintptr_t ra);
46
+uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
47
+ int mmu_idx, uintptr_t ra);
48
+
49
+int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
50
+ int mmu_idx, uintptr_t ra);
51
+int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
52
+ int mmu_idx, uintptr_t ra);
53
+
54
+void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
55
+ int mmu_idx, uintptr_t retaddr);
56
+void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
57
+ int mmu_idx, uintptr_t retaddr);
58
+void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
59
+ int mmu_idx, uintptr_t retaddr);
60
+void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
61
+ int mmu_idx, uintptr_t retaddr);
62
+
63
#ifdef MMU_MODE0_SUFFIX
64
#define CPU_MMU_INDEX 0
65
#define MEMSUFFIX MMU_MODE0_SUFFIX
66
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
67
index XXXXXXX..XXXXXXX 100644
68
--- a/include/exec/cpu_ldst_template.h
69
+++ b/include/exec/cpu_ldst_template.h
70
@@ -XXX,XX +XXX,XX @@
71
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
72
*/
73
74
-#if !defined(SOFTMMU_CODE_ACCESS)
75
-#include "trace-root.h"
76
-#endif
77
-
78
-#include "qemu/plugin.h"
79
-#include "trace/mem.h"
80
-
81
#if DATA_SIZE == 8
82
#define SUFFIX q
83
#define USUFFIX q
84
@@ -XXX,XX +XXX,XX @@
85
#define RES_TYPE uint32_t
86
#endif
87
88
+/* generic load/store macros */
89
+
90
#ifdef SOFTMMU_CODE_ACCESS
91
-#define ADDR_READ addr_code
92
-#define MMUSUFFIX _cmmu
93
-#define URETSUFFIX USUFFIX
94
-#define SRETSUFFIX glue(s, SUFFIX)
95
-#else
96
-#define ADDR_READ addr_read
97
-#define MMUSUFFIX _mmu
98
-#define URETSUFFIX USUFFIX
99
-#define SRETSUFFIX glue(s, SUFFIX)
100
+
101
+static inline RES_TYPE
102
+glue(glue(cpu_ld, USUFFIX), _code)(CPUArchState *env, target_ulong ptr)
103
+{
104
+ TCGMemOpIdx oi = make_memop_idx(MO_TE | SHIFT, CPU_MMU_INDEX);
105
+ return glue(glue(helper_ret_ld, USUFFIX), _cmmu)(env, ptr, oi, 0);
106
+}
107
+
108
+#if DATA_SIZE <= 2
109
+static inline int
110
+glue(glue(cpu_lds, SUFFIX), _code)(CPUArchState *env, target_ulong ptr)
111
+{
112
+ return (DATA_STYPE)glue(glue(cpu_ld, USUFFIX), _code)(env, ptr);
113
+}
114
#endif
115
116
-/* generic load/store macros */
117
+#else
118
119
static inline RES_TYPE
120
glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
121
target_ulong ptr,
122
uintptr_t retaddr)
123
{
124
- CPUTLBEntry *entry;
125
- RES_TYPE res;
126
- target_ulong addr;
127
- int mmu_idx = CPU_MMU_INDEX;
128
- MemOp op = MO_TE | SHIFT;
129
-#if !defined(SOFTMMU_CODE_ACCESS)
130
- uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
131
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
132
-#endif
133
-
134
- addr = ptr;
135
- entry = tlb_entry(env, mmu_idx, addr);
136
- if (unlikely(entry->ADDR_READ !=
137
- (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
138
- TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
139
- res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr,
140
- oi, retaddr);
141
- } else {
142
- uintptr_t hostaddr = addr + entry->addend;
143
- res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr);
144
- }
145
-#ifndef SOFTMMU_CODE_ACCESS
146
- qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
147
-#endif
148
- return res;
149
+ return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
150
+ retaddr);
151
}
152
153
static inline RES_TYPE
154
glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
155
{
156
- return glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(env, ptr, 0);
157
+ return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
158
}
159
160
#if DATA_SIZE <= 2
161
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
162
target_ulong ptr,
163
uintptr_t retaddr)
164
{
165
- CPUTLBEntry *entry;
166
- int res;
167
- target_ulong addr;
168
- int mmu_idx = CPU_MMU_INDEX;
169
- MemOp op = MO_TE | MO_SIGN | SHIFT;
170
-#ifndef SOFTMMU_CODE_ACCESS
171
- uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
172
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
173
-#endif
174
-
175
- addr = ptr;
176
- entry = tlb_entry(env, mmu_idx, addr);
177
- if (unlikely(entry->ADDR_READ !=
178
- (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
179
- TCGMemOpIdx oi = make_memop_idx(op & ~MO_SIGN, mmu_idx);
180
- res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX),
181
- MMUSUFFIX)(env, addr, oi, retaddr);
182
- } else {
183
- uintptr_t hostaddr = addr + entry->addend;
184
- res = glue(glue(lds, SUFFIX), _p)((uint8_t *)hostaddr);
185
- }
186
-#ifndef SOFTMMU_CODE_ACCESS
187
- qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
188
-#endif
189
- return res;
190
+ return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
191
+ retaddr);
192
}
193
194
static inline int
195
glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
196
{
197
- return glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(env, ptr, 0);
198
+ return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
199
}
200
#endif
201
202
-#ifndef SOFTMMU_CODE_ACCESS
203
-
204
/* generic store macro */
205
206
static inline void
207
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
208
target_ulong ptr,
209
RES_TYPE v, uintptr_t retaddr)
210
{
211
- CPUTLBEntry *entry;
212
- target_ulong addr;
213
- int mmu_idx = CPU_MMU_INDEX;
214
- MemOp op = MO_TE | SHIFT;
215
-#if !defined(SOFTMMU_CODE_ACCESS)
216
- uint16_t meminfo = trace_mem_get_info(op, mmu_idx, true);
217
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
218
-#endif
219
-
220
- addr = ptr;
221
- entry = tlb_entry(env, mmu_idx, addr);
222
- if (unlikely(tlb_addr_write(entry) !=
223
- (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
224
- TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
225
- glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi,
226
- retaddr);
227
- } else {
228
- uintptr_t hostaddr = addr + entry->addend;
229
- glue(glue(st, SUFFIX), _p)((uint8_t *)hostaddr, v);
230
- }
231
-#ifndef SOFTMMU_CODE_ACCESS
232
- qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
233
-#endif
234
+ glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX,
235
+ retaddr);
236
}
237
238
static inline void
239
glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
240
RES_TYPE v)
241
{
242
- glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(env, ptr, v, 0);
243
+ glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
244
}
245
246
#endif /* !SOFTMMU_CODE_ACCESS */
247
@@ -XXX,XX +XXX,XX @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
248
#undef SUFFIX
249
#undef USUFFIX
250
#undef DATA_SIZE
251
-#undef MMUSUFFIX
252
-#undef ADDR_READ
253
-#undef URETSUFFIX
254
-#undef SRETSUFFIX
255
#undef SHIFT
256
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
11
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
257
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
258
--- a/accel/tcg/cputlb.c
13
--- a/accel/tcg/cputlb.c
259
+++ b/accel/tcg/cputlb.c
14
+++ b/accel/tcg/cputlb.c
260
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index,
261
#include "qemu/atomic.h"
16
victim_tlb_hit(env, mmu_idx, index, offsetof(CPUTLBEntry, TY), \
262
#include "qemu/atomic128.h"
17
(ADDR) & TARGET_PAGE_MASK)
263
#include "translate-all.h"
18
264
+#include "trace-root.h"
19
-/*
265
+#include "qemu/plugin.h"
20
- * Return a ram_addr_t for the virtual address for execution.
266
+#include "trace/mem.h"
21
- *
267
#ifdef CONFIG_PLUGIN
22
- * Return -1 if we can't translate and execute from an entire page
268
#include "qemu/plugin-memory.h"
23
- * of RAM. This will force us to execute by loading and translating
269
#endif
24
- * one insn at a time, without caching.
270
@@ -XXX,XX +XXX,XX @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env, target_ulong addr,
25
- *
271
return (int32_t)helper_be_ldul_mmu(env, addr, oi, retaddr);
26
- * NOTE: This function will trigger an exception if the page is
27
- * not executable.
28
- */
29
-tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr,
30
- void **hostp)
31
-{
32
- uintptr_t mmu_idx = cpu_mmu_index(env, true);
33
- uintptr_t index = tlb_index(env, mmu_idx, addr);
34
- CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr);
35
- void *p;
36
-
37
- if (unlikely(!tlb_hit(entry->addr_code, addr))) {
38
- if (!VICTIM_TLB_HIT(addr_code, addr)) {
39
- tlb_fill(env_cpu(env), addr, 0, MMU_INST_FETCH, mmu_idx, 0);
40
- index = tlb_index(env, mmu_idx, addr);
41
- entry = tlb_entry(env, mmu_idx, addr);
42
-
43
- if (unlikely(entry->addr_code & TLB_INVALID_MASK)) {
44
- /*
45
- * The MMU protection covers a smaller range than a target
46
- * page, so we must redo the MMU check for every insn.
47
- */
48
- return -1;
49
- }
50
- }
51
- assert(tlb_hit(entry->addr_code, addr));
52
- }
53
-
54
- if (unlikely(entry->addr_code & TLB_MMIO)) {
55
- /* The region is not backed by RAM. */
56
- if (hostp) {
57
- *hostp = NULL;
58
- }
59
- return -1;
60
- }
61
-
62
- p = (void *)((uintptr_t)addr + entry->addend);
63
- if (hostp) {
64
- *hostp = p;
65
- }
66
- return qemu_ram_addr_from_host_nofail(p);
67
-}
68
-
69
static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size,
70
CPUIOTLBEntry *iotlbentry, uintptr_t retaddr)
71
{
72
@@ -XXX,XX +XXX,XX @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr,
73
return flags ? NULL : host;
272
}
74
}
273
75
274
+/*
76
+/*
275
+ * Load helpers for cpu_ldst.h.
77
+ * Return a ram_addr_t for the virtual address for execution.
78
+ *
79
+ * Return -1 if we can't translate and execute from an entire page
80
+ * of RAM. This will force us to execute by loading and translating
81
+ * one insn at a time, without caching.
82
+ *
83
+ * NOTE: This function will trigger an exception if the page is
84
+ * not executable.
276
+ */
85
+ */
86
+tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr,
87
+ void **hostp)
88
+{
89
+ void *p;
277
+
90
+
278
+static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr,
91
+ (void)probe_access_internal(env, addr, 1, MMU_INST_FETCH,
279
+ int mmu_idx, uintptr_t retaddr,
92
+ cpu_mmu_index(env, true), false, &p, 0);
280
+ MemOp op, FullLoadHelper *full_load)
93
+ if (p == NULL) {
281
+{
94
+ return -1;
282
+ uint16_t meminfo;
95
+ }
283
+ TCGMemOpIdx oi;
96
+ if (hostp) {
284
+ uint64_t ret;
97
+ *hostp = p;
285
+
98
+ }
286
+ meminfo = trace_mem_get_info(op, mmu_idx, false);
99
+ return qemu_ram_addr_from_host_nofail(p);
287
+ trace_guest_mem_before_exec(env_cpu(env), addr, meminfo);
288
+
289
+ op &= ~MO_SIGN;
290
+ oi = make_memop_idx(op, mmu_idx);
291
+ ret = full_load(env, addr, oi, retaddr);
292
+
293
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, meminfo);
294
+
295
+ return ret;
296
+}
100
+}
297
+
101
+
298
+uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
102
#ifdef CONFIG_PLUGIN
299
+ int mmu_idx, uintptr_t ra)
300
+{
301
+ return cpu_load_helper(env, addr, mmu_idx, ra, MO_UB, full_ldub_mmu);
302
+}
303
+
304
+int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
305
+ int mmu_idx, uintptr_t ra)
306
+{
307
+ return (int8_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_SB,
308
+ full_ldub_mmu);
309
+}
310
+
311
+uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
312
+ int mmu_idx, uintptr_t ra)
313
+{
314
+ return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUW,
315
+ MO_TE == MO_LE
316
+ ? full_le_lduw_mmu : full_be_lduw_mmu);
317
+}
318
+
319
+int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
320
+ int mmu_idx, uintptr_t ra)
321
+{
322
+ return (int16_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_TESW,
323
+ MO_TE == MO_LE
324
+ ? full_le_lduw_mmu : full_be_lduw_mmu);
325
+}
326
+
327
+uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
328
+ int mmu_idx, uintptr_t ra)
329
+{
330
+ return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUL,
331
+ MO_TE == MO_LE
332
+ ? full_le_ldul_mmu : full_be_ldul_mmu);
333
+}
334
+
335
+uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
336
+ int mmu_idx, uintptr_t ra)
337
+{
338
+ return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEQ,
339
+ MO_TE == MO_LE
340
+ ? helper_le_ldq_mmu : helper_be_ldq_mmu);
341
+}
342
+
343
/*
103
/*
344
* Store Helpers
104
* Perform a TLB lookup and populate the qemu_plugin_hwaddr structure.
345
*/
346
@@ -XXX,XX +XXX,XX @@ void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,
347
store_helper(env, addr, val, oi, retaddr, MO_BEQ);
348
}
349
350
+/*
351
+ * Store Helpers for cpu_ldst.h
352
+ */
353
+
354
+static inline void QEMU_ALWAYS_INLINE
355
+cpu_store_helper(CPUArchState *env, target_ulong addr, uint64_t val,
356
+ int mmu_idx, uintptr_t retaddr, MemOp op)
357
+{
358
+ TCGMemOpIdx oi;
359
+ uint16_t meminfo;
360
+
361
+ meminfo = trace_mem_get_info(op, mmu_idx, true);
362
+ trace_guest_mem_before_exec(env_cpu(env), addr, meminfo);
363
+
364
+ oi = make_memop_idx(op, mmu_idx);
365
+ store_helper(env, addr, val, oi, retaddr, op);
366
+
367
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, meminfo);
368
+}
369
+
370
+void cpu_stb_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
371
+ int mmu_idx, uintptr_t retaddr)
372
+{
373
+ cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_UB);
374
+}
375
+
376
+void cpu_stw_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
377
+ int mmu_idx, uintptr_t retaddr)
378
+{
379
+ cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUW);
380
+}
381
+
382
+void cpu_stl_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
383
+ int mmu_idx, uintptr_t retaddr)
384
+{
385
+ cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUL);
386
+}
387
+
388
+void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
389
+ int mmu_idx, uintptr_t retaddr)
390
+{
391
+ cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEQ);
392
+}
393
+
394
/* First set of helpers allows passing in of OI and RETADDR. This makes
395
them callable from other helpers. */
396
397
--
105
--
398
2.20.1
106
2.34.1
399
400
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
It was non-obvious to me why we can raise an exception in
2
the middle of a comparison function, but it works.
3
While nearby, use TARGET_PAGE_ALIGN instead of open-coding.
2
4
3
Cc: Aurelien Jarno <aurelien@aurel32.net>
5
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
7
---
8
target/sh4/cpu.h | 2 --
8
accel/tcg/cpu-exec.c | 11 ++++++++++-
9
1 file changed, 2 deletions(-)
9
1 file changed, 10 insertions(+), 1 deletion(-)
10
10
11
diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
11
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
12
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/sh4/cpu.h
13
--- a/accel/tcg/cpu-exec.c
14
+++ b/target/sh4/cpu.h
14
+++ b/accel/tcg/cpu-exec.c
15
@@ -XXX,XX +XXX,XX @@ void cpu_load_tlb(CPUSH4State * env);
15
@@ -XXX,XX +XXX,XX @@ static bool tb_lookup_cmp(const void *p, const void *d)
16
#define cpu_list sh4_cpu_list
16
tb_page_addr_t phys_page2;
17
17
target_ulong virt_page2;
18
/* MMU modes definitions */
18
19
-#define MMU_MODE0_SUFFIX _kernel
19
- virt_page2 = (desc->pc & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
20
-#define MMU_MODE1_SUFFIX _user
20
+ /*
21
#define MMU_USER_IDX 1
21
+ * We know that the first page matched, and an otherwise valid TB
22
static inline int cpu_mmu_index (CPUSH4State *env, bool ifetch)
22
+ * encountered an incomplete instruction at the end of that page,
23
{
23
+ * therefore we know that generating a new TB from the current PC
24
+ * must also require reading from the next page -- even if the
25
+ * second pages do not match, and therefore the resulting insn
26
+ * is different for the new TB. Therefore any exception raised
27
+ * here by the faulting lookup is not premature.
28
+ */
29
+ virt_page2 = TARGET_PAGE_ALIGN(desc->pc);
30
phys_page2 = get_page_addr_code(desc->env, virt_page2);
31
if (tb->page_addr[1] == phys_page2) {
32
return true;
24
--
33
--
25
2.20.1
34
2.34.1
26
27
diff view generated by jsdifflib
1
The generated *_user functions are unused. The *_kernel functions
1
The only user can easily use translator_lduw and
2
have a couple of users in op_helper.c; use *_mmuidx_ra instead,
2
adjust the type to signed during the return.
3
with MMU_KERNEL_IDX.
4
3
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
5
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
8
---
10
v2: Use *_mmuidx_ra directly, without intermediate macros.
9
include/exec/translator.h | 1 -
11
---
10
target/i386/tcg/translate.c | 2 +-
12
target/m68k/cpu.h | 2 --
11
2 files changed, 1 insertion(+), 2 deletions(-)
13
target/m68k/op_helper.c | 77 +++++++++++++++++++++++++----------------
14
2 files changed, 47 insertions(+), 32 deletions(-)
15
12
16
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
13
diff --git a/include/exec/translator.h b/include/exec/translator.h
17
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
18
--- a/target/m68k/cpu.h
15
--- a/include/exec/translator.h
19
+++ b/target/m68k/cpu.h
16
+++ b/include/exec/translator.h
20
@@ -XXX,XX +XXX,XX @@ enum {
17
@@ -XXX,XX +XXX,XX @@ bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest);
21
#define cpu_list m68k_cpu_list
18
22
19
#define FOR_EACH_TRANSLATOR_LD(F) \
23
/* MMU modes definitions */
20
F(translator_ldub, uint8_t, cpu_ldub_code, /* no swap */) \
24
-#define MMU_MODE0_SUFFIX _kernel
21
- F(translator_ldsw, int16_t, cpu_ldsw_code, bswap16) \
25
-#define MMU_MODE1_SUFFIX _user
22
F(translator_lduw, uint16_t, cpu_lduw_code, bswap16) \
26
#define MMU_KERNEL_IDX 0
23
F(translator_ldl, uint32_t, cpu_ldl_code, bswap32) \
27
#define MMU_USER_IDX 1
24
F(translator_ldq, uint64_t, cpu_ldq_code, bswap64)
28
static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch)
25
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
29
diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c
30
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
31
--- a/target/m68k/op_helper.c
27
--- a/target/i386/tcg/translate.c
32
+++ b/target/m68k/op_helper.c
28
+++ b/target/i386/tcg/translate.c
33
@@ -XXX,XX +XXX,XX @@ static void cf_rte(CPUM68KState *env)
29
@@ -XXX,XX +XXX,XX @@ static inline uint8_t x86_ldub_code(CPUX86State *env, DisasContext *s)
34
uint32_t fmt;
30
35
31
static inline int16_t x86_ldsw_code(CPUX86State *env, DisasContext *s)
36
sp = env->aregs[7];
32
{
37
- fmt = cpu_ldl_kernel(env, sp);
33
- return translator_ldsw(env, &s->base, advance_pc(env, s, 2));
38
- env->pc = cpu_ldl_kernel(env, sp + 4);
34
+ return translator_lduw(env, &s->base, advance_pc(env, s, 2));
39
+ fmt = cpu_ldl_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
40
+ env->pc = cpu_ldl_mmuidx_ra(env, sp + 4, MMU_KERNEL_IDX, 0);
41
sp |= (fmt >> 28) & 3;
42
env->aregs[7] = sp + 8;
43
44
@@ -XXX,XX +XXX,XX @@ static void m68k_rte(CPUM68KState *env)
45
46
sp = env->aregs[7];
47
throwaway:
48
- sr = cpu_lduw_kernel(env, sp);
49
+ sr = cpu_lduw_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
50
sp += 2;
51
- env->pc = cpu_ldl_kernel(env, sp);
52
+ env->pc = cpu_ldl_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
53
sp += 4;
54
if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) {
55
/* all except 68000 */
56
- fmt = cpu_lduw_kernel(env, sp);
57
+ fmt = cpu_lduw_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
58
sp += 2;
59
switch (fmt >> 12) {
60
case 0:
61
@@ -XXX,XX +XXX,XX @@ static void cf_interrupt_all(CPUM68KState *env, int is_hw)
62
/* ??? This could cause MMU faults. */
63
sp &= ~3;
64
sp -= 4;
65
- cpu_stl_kernel(env, sp, retaddr);
66
+ cpu_stl_mmuidx_ra(env, sp, retaddr, MMU_KERNEL_IDX, 0);
67
sp -= 4;
68
- cpu_stl_kernel(env, sp, fmt);
69
+ cpu_stl_mmuidx_ra(env, sp, fmt, MMU_KERNEL_IDX, 0);
70
env->aregs[7] = sp;
71
/* Jump to vector. */
72
- env->pc = cpu_ldl_kernel(env, env->vbr + vector);
73
+ env->pc = cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, 0);
74
}
35
}
75
36
76
static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
37
static inline uint16_t x86_lduw_code(CPUX86State *env, DisasContext *s)
77
@@ -XXX,XX +XXX,XX @@ static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
78
switch (format) {
79
case 4:
80
*sp -= 4;
81
- cpu_stl_kernel(env, *sp, env->pc);
82
+ cpu_stl_mmuidx_ra(env, *sp, env->pc, MMU_KERNEL_IDX, 0);
83
*sp -= 4;
84
- cpu_stl_kernel(env, *sp, addr);
85
+ cpu_stl_mmuidx_ra(env, *sp, addr, MMU_KERNEL_IDX, 0);
86
break;
87
case 3:
88
case 2:
89
*sp -= 4;
90
- cpu_stl_kernel(env, *sp, addr);
91
+ cpu_stl_mmuidx_ra(env, *sp, addr, MMU_KERNEL_IDX, 0);
92
break;
93
}
94
*sp -= 2;
95
- cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2));
96
+ cpu_stw_mmuidx_ra(env, *sp, (format << 12) + (cs->exception_index << 2),
97
+ MMU_KERNEL_IDX, 0);
98
}
99
*sp -= 4;
100
- cpu_stl_kernel(env, *sp, retaddr);
101
+ cpu_stl_mmuidx_ra(env, *sp, retaddr, MMU_KERNEL_IDX, 0);
102
*sp -= 2;
103
- cpu_stw_kernel(env, *sp, sr);
104
+ cpu_stw_mmuidx_ra(env, *sp, sr, MMU_KERNEL_IDX, 0);
105
}
106
107
static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
108
@@ -XXX,XX +XXX,XX @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
109
cpu_abort(cs, "DOUBLE MMU FAULT\n");
110
}
111
env->mmu.fault = true;
112
+ /* push data 3 */
113
sp -= 4;
114
- cpu_stl_kernel(env, sp, 0); /* push data 3 */
115
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
116
+ /* push data 2 */
117
sp -= 4;
118
- cpu_stl_kernel(env, sp, 0); /* push data 2 */
119
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
120
+ /* push data 1 */
121
sp -= 4;
122
- cpu_stl_kernel(env, sp, 0); /* push data 1 */
123
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
124
+ /* write back 1 / push data 0 */
125
sp -= 4;
126
- cpu_stl_kernel(env, sp, 0); /* write back 1 / push data 0 */
127
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
128
+ /* write back 1 address */
129
sp -= 4;
130
- cpu_stl_kernel(env, sp, 0); /* write back 1 address */
131
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
132
+ /* write back 2 data */
133
sp -= 4;
134
- cpu_stl_kernel(env, sp, 0); /* write back 2 data */
135
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
136
+ /* write back 2 address */
137
sp -= 4;
138
- cpu_stl_kernel(env, sp, 0); /* write back 2 address */
139
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
140
+ /* write back 3 data */
141
sp -= 4;
142
- cpu_stl_kernel(env, sp, 0); /* write back 3 data */
143
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
144
+ /* write back 3 address */
145
sp -= 4;
146
- cpu_stl_kernel(env, sp, env->mmu.ar); /* write back 3 address */
147
+ cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
148
+ /* fault address */
149
sp -= 4;
150
- cpu_stl_kernel(env, sp, env->mmu.ar); /* fault address */
151
+ cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
152
+ /* write back 1 status */
153
sp -= 2;
154
- cpu_stw_kernel(env, sp, 0); /* write back 1 status */
155
+ cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
156
+ /* write back 2 status */
157
sp -= 2;
158
- cpu_stw_kernel(env, sp, 0); /* write back 2 status */
159
+ cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
160
+ /* write back 3 status */
161
sp -= 2;
162
- cpu_stw_kernel(env, sp, 0); /* write back 3 status */
163
+ cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
164
+ /* special status word */
165
sp -= 2;
166
- cpu_stw_kernel(env, sp, env->mmu.ssw); /* special status word */
167
+ cpu_stw_mmuidx_ra(env, sp, env->mmu.ssw, MMU_KERNEL_IDX, 0);
168
+ /* effective address */
169
sp -= 4;
170
- cpu_stl_kernel(env, sp, env->mmu.ar); /* effective address */
171
+ cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
172
+
173
do_stack_frame(env, &sp, 7, oldsr, 0, retaddr);
174
env->mmu.fault = false;
175
if (qemu_loglevel_mask(CPU_LOG_INT)) {
176
@@ -XXX,XX +XXX,XX @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
177
178
env->aregs[7] = sp;
179
/* Jump to vector. */
180
- env->pc = cpu_ldl_kernel(env, env->vbr + vector);
181
+ env->pc = cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, 0);
182
}
183
184
static void do_interrupt_all(CPUM68KState *env, int is_hw)
185
--
38
--
186
2.20.1
39
2.34.1
187
188
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Pass these along to translator_loop -- pc may be used instead
2
of tb->pc, and host_pc is currently unused. Adjust all targets
3
at one time.
2
4
3
We currently search both the root and the tcg/ directories for tcg
5
Acked-by: Alistair Francis <alistair.francis@wdc.com>
4
files:
6
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
5
7
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
6
$ git grep '#include "tcg/' | wc -l
7
28
8
9
$ git grep '#include "tcg[^/]' | wc -l
10
94
11
12
To simplify the preprocessor search path, unify by expliciting the
13
tcg/ directory.
14
15
Patch created mechanically by running:
16
17
$ for x in \
18
tcg.h tcg-mo.h tcg-op.h tcg-opc.h \
19
tcg-op-gvec.h tcg-gvec-desc.h; do \
20
sed -i "s,#include \"$x\",#include \"tcg/$x\"," \
21
$(git grep -l "#include \"$x\""); \
22
done
23
24
Acked-by: David Gibson <david@gibson.dropbear.id.au> (ppc parts)
25
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
26
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
27
Reviewed-by: Stefan Weil <sw@weilnetz.de>
28
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
29
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
30
Message-Id: <20200101112303.20724-2-philmd@redhat.com>
31
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
32
---
9
---
33
include/exec/cpu_ldst.h | 2 +-
10
include/exec/exec-all.h | 1 -
34
tcg/i386/tcg-target.h | 2 +-
11
include/exec/translator.h | 24 ++++++++++++++++++++----
35
tcg/tcg-op.h | 2 +-
12
accel/tcg/translate-all.c | 6 ++++--
36
tcg/tcg.h | 4 ++--
13
accel/tcg/translator.c | 9 +++++----
37
accel/tcg/cpu-exec.c | 2 +-
14
target/alpha/translate.c | 5 +++--
38
accel/tcg/tcg-runtime-gvec.c | 2 +-
15
target/arm/translate.c | 5 +++--
39
accel/tcg/tcg-runtime.c | 2 +-
16
target/avr/translate.c | 5 +++--
40
accel/tcg/translate-all.c | 2 +-
17
target/cris/translate.c | 5 +++--
41
accel/tcg/user-exec.c | 2 +-
18
target/hexagon/translate.c | 6 ++++--
42
bsd-user/main.c | 2 +-
19
target/hppa/translate.c | 5 +++--
43
cpus.c | 2 +-
20
target/i386/tcg/translate.c | 5 +++--
44
exec.c | 2 +-
21
target/loongarch/translate.c | 6 ++++--
45
linux-user/main.c | 2 +-
22
target/m68k/translate.c | 5 +++--
46
linux-user/syscall.c | 2 +-
23
target/microblaze/translate.c | 5 +++--
47
target/alpha/translate.c | 2 +-
24
target/mips/tcg/translate.c | 5 +++--
48
target/arm/helper-a64.c | 2 +-
25
target/nios2/translate.c | 5 +++--
49
target/arm/sve_helper.c | 2 +-
26
target/openrisc/translate.c | 6 ++++--
50
target/arm/translate-a64.c | 4 ++--
27
target/ppc/translate.c | 5 +++--
51
target/arm/translate-sve.c | 6 +++---
28
target/riscv/translate.c | 5 +++--
52
target/arm/translate.c | 4 ++--
29
target/rx/translate.c | 5 +++--
53
target/cris/translate.c | 2 +-
30
target/s390x/tcg/translate.c | 5 +++--
54
target/hppa/translate.c | 2 +-
31
target/sh4/translate.c | 5 +++--
55
target/i386/mem_helper.c | 2 +-
32
target/sparc/translate.c | 5 +++--
56
target/i386/translate.c | 2 +-
33
target/tricore/translate.c | 6 ++++--
57
target/lm32/translate.c | 2 +-
34
target/xtensa/translate.c | 6 ++++--
58
target/m68k/translate.c | 2 +-
35
25 files changed, 97 insertions(+), 53 deletions(-)
59
target/microblaze/translate.c | 2 +-
60
target/mips/translate.c | 2 +-
61
target/moxie/translate.c | 2 +-
62
target/nios2/translate.c | 2 +-
63
target/openrisc/translate.c | 2 +-
64
target/ppc/mem_helper.c | 2 +-
65
target/ppc/translate.c | 4 ++--
66
target/riscv/cpu_helper.c | 2 +-
67
target/riscv/translate.c | 2 +-
68
target/s390x/mem_helper.c | 2 +-
69
target/s390x/translate.c | 4 ++--
70
target/sh4/translate.c | 2 +-
71
target/sparc/ldst_helper.c | 2 +-
72
target/sparc/translate.c | 2 +-
73
target/tilegx/translate.c | 2 +-
74
target/tricore/translate.c | 2 +-
75
target/unicore32/translate.c | 2 +-
76
target/xtensa/translate.c | 2 +-
77
tcg/optimize.c | 2 +-
78
tcg/tcg-common.c | 2 +-
79
tcg/tcg-op-gvec.c | 8 ++++----
80
tcg/tcg-op-vec.c | 6 +++---
81
tcg/tcg-op.c | 6 +++---
82
tcg/tcg.c | 2 +-
83
tcg/tci.c | 2 +-
84
51 files changed, 65 insertions(+), 65 deletions(-)
85
36
86
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
37
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
87
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
88
--- a/include/exec/cpu_ldst.h
39
--- a/include/exec/exec-all.h
89
+++ b/include/exec/cpu_ldst.h
40
+++ b/include/exec/exec-all.h
90
@@ -XXX,XX +XXX,XX @@ static inline void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
41
@@ -XXX,XX +XXX,XX @@ typedef ram_addr_t tb_page_addr_t;
91
#else
42
#define TB_PAGE_ADDR_FMT RAM_ADDR_FMT
92
43
#endif
93
/* Needed for TCG_OVERSIZED_GUEST */
44
94
-#include "tcg.h"
45
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns);
95
+#include "tcg/tcg.h"
46
void restore_state_to_opc(CPUArchState *env, TranslationBlock *tb,
96
47
target_ulong *data);
97
static inline target_ulong tlb_addr_write(const CPUTLBEntry *entry)
48
98
{
49
diff --git a/include/exec/translator.h b/include/exec/translator.h
99
diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h
50
index XXXXXXX..XXXXXXX 100644
100
index XXXXXXX..XXXXXXX 100644
51
--- a/include/exec/translator.h
101
--- a/tcg/i386/tcg-target.h
52
+++ b/include/exec/translator.h
102
+++ b/tcg/i386/tcg-target.h
53
@@ -XXX,XX +XXX,XX @@
103
@@ -XXX,XX +XXX,XX @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr,
54
#include "exec/translate-all.h"
104
* The x86 has a pretty strong memory ordering which only really
55
#include "tcg/tcg.h"
105
* allows for some stores to be re-ordered after loads.
56
57
+/**
58
+ * gen_intermediate_code
59
+ * @cpu: cpu context
60
+ * @tb: translation block
61
+ * @max_insns: max number of instructions to translate
62
+ * @pc: guest virtual program counter address
63
+ * @host_pc: host physical program counter address
64
+ *
65
+ * This function must be provided by the target, which should create
66
+ * the target-specific DisasContext, and then invoke translator_loop.
67
+ */
68
+void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns,
69
+ target_ulong pc, void *host_pc);
70
71
/**
72
* DisasJumpType:
73
@@ -XXX,XX +XXX,XX @@ typedef struct TranslatorOps {
74
75
/**
76
* translator_loop:
77
- * @ops: Target-specific operations.
78
- * @db: Disassembly context.
79
* @cpu: Target vCPU.
80
* @tb: Translation block.
81
* @max_insns: Maximum number of insns to translate.
82
+ * @pc: guest virtual program counter address
83
+ * @host_pc: host physical program counter address
84
+ * @ops: Target-specific operations.
85
+ * @db: Disassembly context.
86
*
87
* Generic translator loop.
88
*
89
@@ -XXX,XX +XXX,XX @@ typedef struct TranslatorOps {
90
* - When single-stepping is enabled (system-wide or on the current vCPU).
91
* - When too many instructions have been translated.
106
*/
92
*/
107
-#include "tcg-mo.h"
93
-void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
108
+#include "tcg/tcg-mo.h"
94
- CPUState *cpu, TranslationBlock *tb, int max_insns);
109
95
+void translator_loop(CPUState *cpu, TranslationBlock *tb, int max_insns,
110
#define TCG_TARGET_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD)
96
+ target_ulong pc, void *host_pc,
111
97
+ const TranslatorOps *ops, DisasContextBase *db);
112
diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h
98
113
index XXXXXXX..XXXXXXX 100644
99
void translator_loop_temp_check(DisasContextBase *db);
114
--- a/tcg/tcg-op.h
115
+++ b/tcg/tcg-op.h
116
@@ -XXX,XX +XXX,XX @@
117
#ifndef TCG_TCG_OP_H
118
#define TCG_TCG_OP_H
119
120
-#include "tcg.h"
121
+#include "tcg/tcg.h"
122
#include "exec/helper-proto.h"
123
#include "exec/helper-gen.h"
124
125
diff --git a/tcg/tcg.h b/tcg/tcg.h
126
index XXXXXXX..XXXXXXX 100644
127
--- a/tcg/tcg.h
128
+++ b/tcg/tcg.h
129
@@ -XXX,XX +XXX,XX @@
130
#include "qemu/bitops.h"
131
#include "qemu/plugin.h"
132
#include "qemu/queue.h"
133
-#include "tcg-mo.h"
134
+#include "tcg/tcg-mo.h"
135
#include "tcg-target.h"
136
#include "qemu/int128.h"
137
138
@@ -XXX,XX +XXX,XX @@ typedef uint64_t TCGRegSet;
139
140
typedef enum TCGOpcode {
141
#define DEF(name, oargs, iargs, cargs, flags) INDEX_op_ ## name,
142
-#include "tcg-opc.h"
143
+#include "tcg/tcg-opc.h"
144
#undef DEF
145
NB_OPS,
146
} TCGOpcode;
147
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
148
index XXXXXXX..XXXXXXX 100644
149
--- a/accel/tcg/cpu-exec.c
150
+++ b/accel/tcg/cpu-exec.c
151
@@ -XXX,XX +XXX,XX @@
152
#include "trace.h"
153
#include "disas/disas.h"
154
#include "exec/exec-all.h"
155
-#include "tcg.h"
156
+#include "tcg/tcg.h"
157
#include "qemu/atomic.h"
158
#include "sysemu/qtest.h"
159
#include "qemu/timer.h"
160
diff --git a/accel/tcg/tcg-runtime-gvec.c b/accel/tcg/tcg-runtime-gvec.c
161
index XXXXXXX..XXXXXXX 100644
162
--- a/accel/tcg/tcg-runtime-gvec.c
163
+++ b/accel/tcg/tcg-runtime-gvec.c
164
@@ -XXX,XX +XXX,XX @@
165
#include "qemu/host-utils.h"
166
#include "cpu.h"
167
#include "exec/helper-proto.h"
168
-#include "tcg-gvec-desc.h"
169
+#include "tcg/tcg-gvec-desc.h"
170
171
172
/* Virtually all hosts support 16-byte vectors. Those that don't can emulate
173
diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c
174
index XXXXXXX..XXXXXXX 100644
175
--- a/accel/tcg/tcg-runtime.c
176
+++ b/accel/tcg/tcg-runtime.c
177
@@ -XXX,XX +XXX,XX @@
178
#include "exec/tb-lookup.h"
179
#include "disas/disas.h"
180
#include "exec/log.h"
181
-#include "tcg.h"
182
+#include "tcg/tcg.h"
183
184
/* 32-bit helpers */
185
100
186
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
101
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
187
index XXXXXXX..XXXXXXX 100644
102
index XXXXXXX..XXXXXXX 100644
188
--- a/accel/tcg/translate-all.c
103
--- a/accel/tcg/translate-all.c
189
+++ b/accel/tcg/translate-all.c
104
+++ b/accel/tcg/translate-all.c
190
@@ -XXX,XX +XXX,XX @@
105
@@ -XXX,XX +XXX,XX @@
191
#include "trace.h"
106
192
#include "disas/disas.h"
107
#include "exec/cputlb.h"
193
#include "exec/exec-all.h"
108
#include "exec/translate-all.h"
194
-#include "tcg.h"
109
+#include "exec/translator.h"
195
+#include "tcg/tcg.h"
110
#include "qemu/bitmap.h"
196
#if defined(CONFIG_USER_ONLY)
111
#include "qemu/qemu-print.h"
197
#include "qemu.h"
198
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
199
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
200
index XXXXXXX..XXXXXXX 100644
201
--- a/accel/tcg/user-exec.c
202
+++ b/accel/tcg/user-exec.c
203
@@ -XXX,XX +XXX,XX @@
204
#include "cpu.h"
205
#include "disas/disas.h"
206
#include "exec/exec-all.h"
207
-#include "tcg.h"
208
+#include "tcg/tcg.h"
209
#include "qemu/bitops.h"
210
#include "exec/cpu_ldst.h"
211
#include "translate-all.h"
212
diff --git a/bsd-user/main.c b/bsd-user/main.c
213
index XXXXXXX..XXXXXXX 100644
214
--- a/bsd-user/main.c
215
+++ b/bsd-user/main.c
216
@@ -XXX,XX +XXX,XX @@
217
#include "qemu/module.h"
218
#include "cpu.h"
219
#include "exec/exec-all.h"
220
-#include "tcg.h"
221
+#include "tcg/tcg.h"
222
#include "qemu/timer.h"
112
#include "qemu/timer.h"
223
#include "qemu/envlist.h"
113
@@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu,
224
#include "exec/log.h"
114
TCGProfile *prof = &tcg_ctx->prof;
225
diff --git a/cpus.c b/cpus.c
115
int64_t ti;
226
index XXXXXXX..XXXXXXX 100644
116
#endif
227
--- a/cpus.c
117
+ void *host_pc;
228
+++ b/cpus.c
118
229
@@ -XXX,XX +XXX,XX @@
119
assert_memory_lock();
230
#include "qemu/bitmap.h"
120
qemu_thread_jit_write();
231
#include "qemu/seqlock.h"
121
232
#include "qemu/guest-random.h"
122
- phys_pc = get_page_addr_code(env, pc);
233
-#include "tcg.h"
123
+ phys_pc = get_page_addr_code_hostp(env, pc, &host_pc);
234
+#include "tcg/tcg.h"
124
235
#include "hw/nmi.h"
125
if (phys_pc == -1) {
236
#include "sysemu/replay.h"
126
/* Generate a one-shot TB with 1 insn in it */
237
#include "sysemu/runstate.h"
127
@@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu,
238
diff --git a/exec.c b/exec.c
128
tcg_func_start(tcg_ctx);
239
index XXXXXXX..XXXXXXX 100644
129
240
--- a/exec.c
130
tcg_ctx->cpu = env_cpu(env);
241
+++ b/exec.c
131
- gen_intermediate_code(cpu, tb, max_insns);
242
@@ -XXX,XX +XXX,XX @@
132
+ gen_intermediate_code(cpu, tb, max_insns, pc, host_pc);
243
#include "cpu.h"
133
assert(tb->size != 0);
244
#include "exec/exec-all.h"
134
tcg_ctx->cpu = NULL;
245
#include "exec/target_page.h"
135
max_insns = tb->icount;
246
-#include "tcg.h"
136
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
247
+#include "tcg/tcg.h"
137
index XXXXXXX..XXXXXXX 100644
248
#include "hw/qdev-core.h"
138
--- a/accel/tcg/translator.c
249
#include "hw/qdev-properties.h"
139
+++ b/accel/tcg/translator.c
250
#if !defined(CONFIG_USER_ONLY)
140
@@ -XXX,XX +XXX,XX @@ static inline void translator_page_protect(DisasContextBase *dcbase,
251
diff --git a/linux-user/main.c b/linux-user/main.c
141
#endif
252
index XXXXXXX..XXXXXXX 100644
142
}
253
--- a/linux-user/main.c
143
254
+++ b/linux-user/main.c
144
-void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
255
@@ -XXX,XX +XXX,XX @@
145
- CPUState *cpu, TranslationBlock *tb, int max_insns)
256
#include "qemu/plugin.h"
146
+void translator_loop(CPUState *cpu, TranslationBlock *tb, int max_insns,
257
#include "cpu.h"
147
+ target_ulong pc, void *host_pc,
258
#include "exec/exec-all.h"
148
+ const TranslatorOps *ops, DisasContextBase *db)
259
-#include "tcg.h"
149
{
260
+#include "tcg/tcg.h"
150
uint32_t cflags = tb_cflags(tb);
261
#include "qemu/timer.h"
151
bool plugin_enabled;
262
#include "qemu/envlist.h"
152
263
#include "qemu/guest-random.h"
153
/* Initialize DisasContext */
264
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
154
db->tb = tb;
265
index XXXXXXX..XXXXXXX 100644
155
- db->pc_first = tb->pc;
266
--- a/linux-user/syscall.c
156
- db->pc_next = db->pc_first;
267
+++ b/linux-user/syscall.c
157
+ db->pc_first = pc;
268
@@ -XXX,XX +XXX,XX @@
158
+ db->pc_next = pc;
269
#include "user/syscall-trace.h"
159
db->is_jmp = DISAS_NEXT;
270
#include "qapi/error.h"
160
db->num_insns = 0;
271
#include "fd-trans.h"
161
db->max_insns = max_insns;
272
-#include "tcg.h"
273
+#include "tcg/tcg.h"
274
275
#ifndef CLONE_IO
276
#define CLONE_IO 0x80000000 /* Clone io context */
277
diff --git a/target/alpha/translate.c b/target/alpha/translate.c
162
diff --git a/target/alpha/translate.c b/target/alpha/translate.c
278
index XXXXXXX..XXXXXXX 100644
163
index XXXXXXX..XXXXXXX 100644
279
--- a/target/alpha/translate.c
164
--- a/target/alpha/translate.c
280
+++ b/target/alpha/translate.c
165
+++ b/target/alpha/translate.c
281
@@ -XXX,XX +XXX,XX @@
166
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps alpha_tr_ops = {
282
#include "disas/disas.h"
167
.disas_log = alpha_tr_disas_log,
283
#include "qemu/host-utils.h"
168
};
284
#include "exec/exec-all.h"
169
285
-#include "tcg-op.h"
170
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns)
286
+#include "tcg/tcg-op.h"
171
+void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns,
287
#include "exec/cpu_ldst.h"
172
+ target_ulong pc, void *host_pc)
288
#include "exec/helper-proto.h"
173
{
289
#include "exec/helper-gen.h"
174
DisasContext dc;
290
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
175
- translator_loop(&alpha_tr_ops, &dc.base, cpu, tb, max_insns);
291
index XXXXXXX..XXXXXXX 100644
176
+ translator_loop(cpu, tb, max_insns, pc, host_pc, &alpha_tr_ops, &dc.base);
292
--- a/target/arm/helper-a64.c
177
}
293
+++ b/target/arm/helper-a64.c
178
294
@@ -XXX,XX +XXX,XX @@
179
void restore_state_to_opc(CPUAlphaState *env, TranslationBlock *tb,
295
#include "exec/cpu_ldst.h"
296
#include "qemu/int128.h"
297
#include "qemu/atomic128.h"
298
-#include "tcg.h"
299
+#include "tcg/tcg.h"
300
#include "fpu/softfloat.h"
301
#include <zlib.h> /* For crc32 */
302
303
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
304
index XXXXXXX..XXXXXXX 100644
305
--- a/target/arm/sve_helper.c
306
+++ b/target/arm/sve_helper.c
307
@@ -XXX,XX +XXX,XX @@
308
#include "exec/helper-proto.h"
309
#include "tcg/tcg-gvec-desc.h"
310
#include "fpu/softfloat.h"
311
-#include "tcg.h"
312
+#include "tcg/tcg.h"
313
314
315
/* Note that vector data is stored in host-endian 64-bit chunks,
316
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
317
index XXXXXXX..XXXXXXX 100644
318
--- a/target/arm/translate-a64.c
319
+++ b/target/arm/translate-a64.c
320
@@ -XXX,XX +XXX,XX @@
321
322
#include "cpu.h"
323
#include "exec/exec-all.h"
324
-#include "tcg-op.h"
325
-#include "tcg-op-gvec.h"
326
+#include "tcg/tcg-op.h"
327
+#include "tcg/tcg-op-gvec.h"
328
#include "qemu/log.h"
329
#include "arm_ldst.h"
330
#include "translate.h"
331
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
332
index XXXXXXX..XXXXXXX 100644
333
--- a/target/arm/translate-sve.c
334
+++ b/target/arm/translate-sve.c
335
@@ -XXX,XX +XXX,XX @@
336
#include "qemu/osdep.h"
337
#include "cpu.h"
338
#include "exec/exec-all.h"
339
-#include "tcg-op.h"
340
-#include "tcg-op-gvec.h"
341
-#include "tcg-gvec-desc.h"
342
+#include "tcg/tcg-op.h"
343
+#include "tcg/tcg-op-gvec.h"
344
+#include "tcg/tcg-gvec-desc.h"
345
#include "qemu/log.h"
346
#include "arm_ldst.h"
347
#include "translate.h"
348
diff --git a/target/arm/translate.c b/target/arm/translate.c
180
diff --git a/target/arm/translate.c b/target/arm/translate.c
349
index XXXXXXX..XXXXXXX 100644
181
index XXXXXXX..XXXXXXX 100644
350
--- a/target/arm/translate.c
182
--- a/target/arm/translate.c
351
+++ b/target/arm/translate.c
183
+++ b/target/arm/translate.c
352
@@ -XXX,XX +XXX,XX @@
184
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps thumb_translator_ops = {
353
#include "internals.h"
185
};
354
#include "disas/disas.h"
186
355
#include "exec/exec-all.h"
187
/* generate intermediate code for basic block 'tb'. */
356
-#include "tcg-op.h"
188
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns)
357
-#include "tcg-op-gvec.h"
189
+void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns,
358
+#include "tcg/tcg-op.h"
190
+ target_ulong pc, void *host_pc)
359
+#include "tcg/tcg-op-gvec.h"
191
{
360
#include "qemu/log.h"
192
DisasContext dc = { };
361
#include "qemu/bitops.h"
193
const TranslatorOps *ops = &arm_translator_ops;
362
#include "arm_ldst.h"
194
@@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns)
195
}
196
#endif
197
198
- translator_loop(ops, &dc.base, cpu, tb, max_insns);
199
+ translator_loop(cpu, tb, max_insns, pc, host_pc, ops, &dc.base);
200
}
201
202
void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb,
203
diff --git a/target/avr/translate.c b/target/avr/translate.c
204
index XXXXXXX..XXXXXXX 100644
205
--- a/target/avr/translate.c
206
+++ b/target/avr/translate.c
207
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps avr_tr_ops = {
208
.disas_log = avr_tr_disas_log,
209
};
210
211
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
212
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
213
+ target_ulong pc, void *host_pc)
214
{
215
DisasContext dc = { };
216
- translator_loop(&avr_tr_ops, &dc.base, cs, tb, max_insns);
217
+ translator_loop(cs, tb, max_insns, pc, host_pc, &avr_tr_ops, &dc.base);
218
}
219
220
void restore_state_to_opc(CPUAVRState *env, TranslationBlock *tb,
363
diff --git a/target/cris/translate.c b/target/cris/translate.c
221
diff --git a/target/cris/translate.c b/target/cris/translate.c
364
index XXXXXXX..XXXXXXX 100644
222
index XXXXXXX..XXXXXXX 100644
365
--- a/target/cris/translate.c
223
--- a/target/cris/translate.c
366
+++ b/target/cris/translate.c
224
+++ b/target/cris/translate.c
367
@@ -XXX,XX +XXX,XX @@
225
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps cris_tr_ops = {
368
#include "cpu.h"
226
.disas_log = cris_tr_disas_log,
369
#include "disas/disas.h"
227
};
370
#include "exec/exec-all.h"
228
371
-#include "tcg-op.h"
229
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
372
+#include "tcg/tcg-op.h"
230
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
373
#include "exec/helper-proto.h"
231
+ target_ulong pc, void *host_pc)
374
#include "mmu.h"
232
{
375
#include "exec/cpu_ldst.h"
233
DisasContext dc;
234
- translator_loop(&cris_tr_ops, &dc.base, cs, tb, max_insns);
235
+ translator_loop(cs, tb, max_insns, pc, host_pc, &cris_tr_ops, &dc.base);
236
}
237
238
void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags)
239
diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
240
index XXXXXXX..XXXXXXX 100644
241
--- a/target/hexagon/translate.c
242
+++ b/target/hexagon/translate.c
243
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps hexagon_tr_ops = {
244
.disas_log = hexagon_tr_disas_log,
245
};
246
247
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
248
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
249
+ target_ulong pc, void *host_pc)
250
{
251
DisasContext ctx;
252
253
- translator_loop(&hexagon_tr_ops, &ctx.base, cs, tb, max_insns);
254
+ translator_loop(cs, tb, max_insns, pc, host_pc,
255
+ &hexagon_tr_ops, &ctx.base);
256
}
257
258
#define NAME_LEN 64
376
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
259
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
377
index XXXXXXX..XXXXXXX 100644
260
index XXXXXXX..XXXXXXX 100644
378
--- a/target/hppa/translate.c
261
--- a/target/hppa/translate.c
379
+++ b/target/hppa/translate.c
262
+++ b/target/hppa/translate.c
380
@@ -XXX,XX +XXX,XX @@
263
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps hppa_tr_ops = {
381
#include "disas/disas.h"
264
.disas_log = hppa_tr_disas_log,
382
#include "qemu/host-utils.h"
265
};
383
#include "exec/exec-all.h"
266
384
-#include "tcg-op.h"
267
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
385
+#include "tcg/tcg-op.h"
268
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
386
#include "exec/cpu_ldst.h"
269
+ target_ulong pc, void *host_pc)
387
#include "exec/helper-proto.h"
270
{
388
#include "exec/helper-gen.h"
271
DisasContext ctx;
389
diff --git a/target/i386/mem_helper.c b/target/i386/mem_helper.c
272
- translator_loop(&hppa_tr_ops, &ctx.base, cs, tb, max_insns);
390
index XXXXXXX..XXXXXXX 100644
273
+ translator_loop(cs, tb, max_insns, pc, host_pc, &hppa_tr_ops, &ctx.base);
391
--- a/target/i386/mem_helper.c
274
}
392
+++ b/target/i386/mem_helper.c
275
393
@@ -XXX,XX +XXX,XX @@
276
void restore_state_to_opc(CPUHPPAState *env, TranslationBlock *tb,
394
#include "exec/cpu_ldst.h"
277
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
395
#include "qemu/int128.h"
278
index XXXXXXX..XXXXXXX 100644
396
#include "qemu/atomic128.h"
279
--- a/target/i386/tcg/translate.c
397
-#include "tcg.h"
280
+++ b/target/i386/tcg/translate.c
398
+#include "tcg/tcg.h"
281
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps i386_tr_ops = {
399
282
};
400
void helper_cmpxchg8b_unlocked(CPUX86State *env, target_ulong a0)
283
401
{
284
/* generate intermediate code for basic block 'tb'. */
402
diff --git a/target/i386/translate.c b/target/i386/translate.c
285
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns)
403
index XXXXXXX..XXXXXXX 100644
286
+void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns,
404
--- a/target/i386/translate.c
287
+ target_ulong pc, void *host_pc)
405
+++ b/target/i386/translate.c
288
{
406
@@ -XXX,XX +XXX,XX @@
289
DisasContext dc;
407
#include "cpu.h"
290
408
#include "disas/disas.h"
291
- translator_loop(&i386_tr_ops, &dc.base, cpu, tb, max_insns);
409
#include "exec/exec-all.h"
292
+ translator_loop(cpu, tb, max_insns, pc, host_pc, &i386_tr_ops, &dc.base);
410
-#include "tcg-op.h"
293
}
411
+#include "tcg/tcg-op.h"
294
412
#include "exec/cpu_ldst.h"
295
void restore_state_to_opc(CPUX86State *env, TranslationBlock *tb,
413
#include "exec/translator.h"
296
diff --git a/target/loongarch/translate.c b/target/loongarch/translate.c
414
297
index XXXXXXX..XXXXXXX 100644
415
diff --git a/target/lm32/translate.c b/target/lm32/translate.c
298
--- a/target/loongarch/translate.c
416
index XXXXXXX..XXXXXXX 100644
299
+++ b/target/loongarch/translate.c
417
--- a/target/lm32/translate.c
300
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps loongarch_tr_ops = {
418
+++ b/target/lm32/translate.c
301
.disas_log = loongarch_tr_disas_log,
419
@@ -XXX,XX +XXX,XX @@
302
};
420
#include "exec/helper-proto.h"
303
421
#include "exec/exec-all.h"
304
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
422
#include "exec/translator.h"
305
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
423
-#include "tcg-op.h"
306
+ target_ulong pc, void *host_pc)
424
+#include "tcg/tcg-op.h"
307
{
425
#include "qemu/qemu-print.h"
308
DisasContext ctx;
426
309
427
#include "exec/cpu_ldst.h"
310
- translator_loop(&loongarch_tr_ops, &ctx.base, cs, tb, max_insns);
311
+ translator_loop(cs, tb, max_insns, pc, host_pc,
312
+ &loongarch_tr_ops, &ctx.base);
313
}
314
315
void loongarch_translate_init(void)
428
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
316
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
429
index XXXXXXX..XXXXXXX 100644
317
index XXXXXXX..XXXXXXX 100644
430
--- a/target/m68k/translate.c
318
--- a/target/m68k/translate.c
431
+++ b/target/m68k/translate.c
319
+++ b/target/m68k/translate.c
432
@@ -XXX,XX +XXX,XX @@
320
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps m68k_tr_ops = {
433
#include "cpu.h"
321
.disas_log = m68k_tr_disas_log,
434
#include "disas/disas.h"
322
};
435
#include "exec/exec-all.h"
323
436
-#include "tcg-op.h"
324
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns)
437
+#include "tcg/tcg-op.h"
325
+void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns,
438
#include "qemu/log.h"
326
+ target_ulong pc, void *host_pc)
439
#include "qemu/qemu-print.h"
327
{
440
#include "exec/cpu_ldst.h"
328
DisasContext dc;
329
- translator_loop(&m68k_tr_ops, &dc.base, cpu, tb, max_insns);
330
+ translator_loop(cpu, tb, max_insns, pc, host_pc, &m68k_tr_ops, &dc.base);
331
}
332
333
static double floatx80_to_double(CPUM68KState *env, uint16_t high, uint64_t low)
441
diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
334
diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
442
index XXXXXXX..XXXXXXX 100644
335
index XXXXXXX..XXXXXXX 100644
443
--- a/target/microblaze/translate.c
336
--- a/target/microblaze/translate.c
444
+++ b/target/microblaze/translate.c
337
+++ b/target/microblaze/translate.c
445
@@ -XXX,XX +XXX,XX @@
338
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps mb_tr_ops = {
446
#include "cpu.h"
339
.disas_log = mb_tr_disas_log,
447
#include "disas/disas.h"
340
};
448
#include "exec/exec-all.h"
341
449
-#include "tcg-op.h"
342
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns)
450
+#include "tcg/tcg-op.h"
343
+void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns,
451
#include "exec/helper-proto.h"
344
+ target_ulong pc, void *host_pc)
452
#include "microblaze-decode.h"
345
{
453
#include "exec/cpu_ldst.h"
346
DisasContext dc;
454
diff --git a/target/mips/translate.c b/target/mips/translate.c
347
- translator_loop(&mb_tr_ops, &dc.base, cpu, tb, max_insns);
455
index XXXXXXX..XXXXXXX 100644
348
+ translator_loop(cpu, tb, max_insns, pc, host_pc, &mb_tr_ops, &dc.base);
456
--- a/target/mips/translate.c
349
}
457
+++ b/target/mips/translate.c
350
458
@@ -XXX,XX +XXX,XX @@
351
void mb_cpu_dump_state(CPUState *cs, FILE *f, int flags)
459
#include "internal.h"
352
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
460
#include "disas/disas.h"
353
index XXXXXXX..XXXXXXX 100644
461
#include "exec/exec-all.h"
354
--- a/target/mips/tcg/translate.c
462
-#include "tcg-op.h"
355
+++ b/target/mips/tcg/translate.c
463
+#include "tcg/tcg-op.h"
356
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps mips_tr_ops = {
464
#include "exec/cpu_ldst.h"
357
.disas_log = mips_tr_disas_log,
465
#include "hw/mips/cpudevs.h"
358
};
466
359
467
diff --git a/target/moxie/translate.c b/target/moxie/translate.c
360
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
468
index XXXXXXX..XXXXXXX 100644
361
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
469
--- a/target/moxie/translate.c
362
+ target_ulong pc, void *host_pc)
470
+++ b/target/moxie/translate.c
363
{
471
@@ -XXX,XX +XXX,XX @@
364
DisasContext ctx;
472
#include "cpu.h"
365
473
#include "exec/exec-all.h"
366
- translator_loop(&mips_tr_ops, &ctx.base, cs, tb, max_insns);
474
#include "disas/disas.h"
367
+ translator_loop(cs, tb, max_insns, pc, host_pc, &mips_tr_ops, &ctx.base);
475
-#include "tcg-op.h"
368
}
476
+#include "tcg/tcg-op.h"
369
477
#include "exec/cpu_ldst.h"
370
void mips_tcg_init(void)
478
#include "qemu/qemu-print.h"
479
480
diff --git a/target/nios2/translate.c b/target/nios2/translate.c
371
diff --git a/target/nios2/translate.c b/target/nios2/translate.c
481
index XXXXXXX..XXXXXXX 100644
372
index XXXXXXX..XXXXXXX 100644
482
--- a/target/nios2/translate.c
373
--- a/target/nios2/translate.c
483
+++ b/target/nios2/translate.c
374
+++ b/target/nios2/translate.c
484
@@ -XXX,XX +XXX,XX @@
375
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps nios2_tr_ops = {
485
376
.disas_log = nios2_tr_disas_log,
486
#include "qemu/osdep.h"
377
};
487
#include "cpu.h"
378
488
-#include "tcg-op.h"
379
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
489
+#include "tcg/tcg-op.h"
380
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
490
#include "exec/exec-all.h"
381
+ target_ulong pc, void *host_pc)
491
#include "disas/disas.h"
382
{
492
#include "exec/helper-proto.h"
383
DisasContext dc;
384
- translator_loop(&nios2_tr_ops, &dc.base, cs, tb, max_insns);
385
+ translator_loop(cs, tb, max_insns, pc, host_pc, &nios2_tr_ops, &dc.base);
386
}
387
388
void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags)
493
diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c
389
diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c
494
index XXXXXXX..XXXXXXX 100644
390
index XXXXXXX..XXXXXXX 100644
495
--- a/target/openrisc/translate.c
391
--- a/target/openrisc/translate.c
496
+++ b/target/openrisc/translate.c
392
+++ b/target/openrisc/translate.c
497
@@ -XXX,XX +XXX,XX @@
393
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps openrisc_tr_ops = {
498
#include "cpu.h"
394
.disas_log = openrisc_tr_disas_log,
499
#include "exec/exec-all.h"
395
};
500
#include "disas/disas.h"
396
501
-#include "tcg-op.h"
397
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
502
+#include "tcg/tcg-op.h"
398
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
503
#include "qemu/log.h"
399
+ target_ulong pc, void *host_pc)
504
#include "qemu/bitops.h"
400
{
505
#include "qemu/qemu-print.h"
401
DisasContext ctx;
506
diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
402
507
index XXXXXXX..XXXXXXX 100644
403
- translator_loop(&openrisc_tr_ops, &ctx.base, cs, tb, max_insns);
508
--- a/target/ppc/mem_helper.c
404
+ translator_loop(cs, tb, max_insns, pc, host_pc,
509
+++ b/target/ppc/mem_helper.c
405
+ &openrisc_tr_ops, &ctx.base);
510
@@ -XXX,XX +XXX,XX @@
406
}
511
#include "exec/helper-proto.h"
407
512
#include "helper_regs.h"
408
void openrisc_cpu_dump_state(CPUState *cs, FILE *f, int flags)
513
#include "exec/cpu_ldst.h"
514
-#include "tcg.h"
515
+#include "tcg/tcg.h"
516
#include "internal.h"
517
#include "qemu/atomic128.h"
518
519
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
409
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
520
index XXXXXXX..XXXXXXX 100644
410
index XXXXXXX..XXXXXXX 100644
521
--- a/target/ppc/translate.c
411
--- a/target/ppc/translate.c
522
+++ b/target/ppc/translate.c
412
+++ b/target/ppc/translate.c
523
@@ -XXX,XX +XXX,XX @@
413
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps ppc_tr_ops = {
524
#include "internal.h"
414
.disas_log = ppc_tr_disas_log,
525
#include "disas/disas.h"
415
};
526
#include "exec/exec-all.h"
416
527
-#include "tcg-op.h"
417
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
528
-#include "tcg-op-gvec.h"
418
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
529
+#include "tcg/tcg-op.h"
419
+ target_ulong pc, void *host_pc)
530
+#include "tcg/tcg-op-gvec.h"
420
{
531
#include "qemu/host-utils.h"
421
DisasContext ctx;
532
#include "qemu/main-loop.h"
422
533
#include "exec/cpu_ldst.h"
423
- translator_loop(&ppc_tr_ops, &ctx.base, cs, tb, max_insns);
534
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
424
+ translator_loop(cs, tb, max_insns, pc, host_pc, &ppc_tr_ops, &ctx.base);
535
index XXXXXXX..XXXXXXX 100644
425
}
536
--- a/target/riscv/cpu_helper.c
426
537
+++ b/target/riscv/cpu_helper.c
427
void restore_state_to_opc(CPUPPCState *env, TranslationBlock *tb,
538
@@ -XXX,XX +XXX,XX @@
539
#include "qemu/main-loop.h"
540
#include "cpu.h"
541
#include "exec/exec-all.h"
542
-#include "tcg-op.h"
543
+#include "tcg/tcg-op.h"
544
#include "trace.h"
545
546
int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)
547
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
428
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
548
index XXXXXXX..XXXXXXX 100644
429
index XXXXXXX..XXXXXXX 100644
549
--- a/target/riscv/translate.c
430
--- a/target/riscv/translate.c
550
+++ b/target/riscv/translate.c
431
+++ b/target/riscv/translate.c
551
@@ -XXX,XX +XXX,XX @@
432
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps riscv_tr_ops = {
552
#include "qemu/osdep.h"
433
.disas_log = riscv_tr_disas_log,
553
#include "qemu/log.h"
434
};
554
#include "cpu.h"
435
555
-#include "tcg-op.h"
436
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
556
+#include "tcg/tcg-op.h"
437
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
557
#include "disas/disas.h"
438
+ target_ulong pc, void *host_pc)
558
#include "exec/cpu_ldst.h"
439
{
559
#include "exec/exec-all.h"
440
DisasContext ctx;
560
diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
441
561
index XXXXXXX..XXXXXXX 100644
442
- translator_loop(&riscv_tr_ops, &ctx.base, cs, tb, max_insns);
562
--- a/target/s390x/mem_helper.c
443
+ translator_loop(cs, tb, max_insns, pc, host_pc, &riscv_tr_ops, &ctx.base);
563
+++ b/target/s390x/mem_helper.c
444
}
564
@@ -XXX,XX +XXX,XX @@
445
565
#include "exec/cpu_ldst.h"
446
void riscv_translate_init(void)
566
#include "qemu/int128.h"
447
diff --git a/target/rx/translate.c b/target/rx/translate.c
567
#include "qemu/atomic128.h"
448
index XXXXXXX..XXXXXXX 100644
568
-#include "tcg.h"
449
--- a/target/rx/translate.c
569
+#include "tcg/tcg.h"
450
+++ b/target/rx/translate.c
570
451
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps rx_tr_ops = {
571
#if !defined(CONFIG_USER_ONLY)
452
.disas_log = rx_tr_disas_log,
572
#include "hw/s390x/storage-keys.h"
453
};
573
diff --git a/target/s390x/translate.c b/target/s390x/translate.c
454
574
index XXXXXXX..XXXXXXX 100644
455
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
575
--- a/target/s390x/translate.c
456
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
576
+++ b/target/s390x/translate.c
457
+ target_ulong pc, void *host_pc)
577
@@ -XXX,XX +XXX,XX @@
458
{
578
#include "internal.h"
459
DisasContext dc;
579
#include "disas/disas.h"
460
580
#include "exec/exec-all.h"
461
- translator_loop(&rx_tr_ops, &dc.base, cs, tb, max_insns);
581
-#include "tcg-op.h"
462
+ translator_loop(cs, tb, max_insns, pc, host_pc, &rx_tr_ops, &dc.base);
582
-#include "tcg-op-gvec.h"
463
}
583
+#include "tcg/tcg-op.h"
464
584
+#include "tcg/tcg-op-gvec.h"
465
void restore_state_to_opc(CPURXState *env, TranslationBlock *tb,
585
#include "qemu/log.h"
466
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
586
#include "qemu/host-utils.h"
467
index XXXXXXX..XXXXXXX 100644
587
#include "exec/cpu_ldst.h"
468
--- a/target/s390x/tcg/translate.c
469
+++ b/target/s390x/tcg/translate.c
470
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps s390x_tr_ops = {
471
.disas_log = s390x_tr_disas_log,
472
};
473
474
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
475
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
476
+ target_ulong pc, void *host_pc)
477
{
478
DisasContext dc;
479
480
- translator_loop(&s390x_tr_ops, &dc.base, cs, tb, max_insns);
481
+ translator_loop(cs, tb, max_insns, pc, host_pc, &s390x_tr_ops, &dc.base);
482
}
483
484
void restore_state_to_opc(CPUS390XState *env, TranslationBlock *tb,
588
diff --git a/target/sh4/translate.c b/target/sh4/translate.c
485
diff --git a/target/sh4/translate.c b/target/sh4/translate.c
589
index XXXXXXX..XXXXXXX 100644
486
index XXXXXXX..XXXXXXX 100644
590
--- a/target/sh4/translate.c
487
--- a/target/sh4/translate.c
591
+++ b/target/sh4/translate.c
488
+++ b/target/sh4/translate.c
592
@@ -XXX,XX +XXX,XX @@
489
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps sh4_tr_ops = {
593
#include "cpu.h"
490
.disas_log = sh4_tr_disas_log,
594
#include "disas/disas.h"
491
};
595
#include "exec/exec-all.h"
492
596
-#include "tcg-op.h"
493
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
597
+#include "tcg/tcg-op.h"
494
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
598
#include "exec/cpu_ldst.h"
495
+ target_ulong pc, void *host_pc)
599
#include "exec/helper-proto.h"
496
{
600
#include "exec/helper-gen.h"
497
DisasContext ctx;
601
diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
498
602
index XXXXXXX..XXXXXXX 100644
499
- translator_loop(&sh4_tr_ops, &ctx.base, cs, tb, max_insns);
603
--- a/target/sparc/ldst_helper.c
500
+ translator_loop(cs, tb, max_insns, pc, host_pc, &sh4_tr_ops, &ctx.base);
604
+++ b/target/sparc/ldst_helper.c
501
}
605
@@ -XXX,XX +XXX,XX @@
502
606
503
void restore_state_to_opc(CPUSH4State *env, TranslationBlock *tb,
607
#include "qemu/osdep.h"
608
#include "cpu.h"
609
-#include "tcg.h"
610
+#include "tcg/tcg.h"
611
#include "exec/helper-proto.h"
612
#include "exec/exec-all.h"
613
#include "exec/cpu_ldst.h"
614
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
504
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
615
index XXXXXXX..XXXXXXX 100644
505
index XXXXXXX..XXXXXXX 100644
616
--- a/target/sparc/translate.c
506
--- a/target/sparc/translate.c
617
+++ b/target/sparc/translate.c
507
+++ b/target/sparc/translate.c
618
@@ -XXX,XX +XXX,XX @@
508
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps sparc_tr_ops = {
619
#include "disas/disas.h"
509
.disas_log = sparc_tr_disas_log,
620
#include "exec/helper-proto.h"
510
};
621
#include "exec/exec-all.h"
511
622
-#include "tcg-op.h"
512
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
623
+#include "tcg/tcg-op.h"
513
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
624
#include "exec/cpu_ldst.h"
514
+ target_ulong pc, void *host_pc)
625
515
{
626
#include "exec/helper-gen.h"
516
DisasContext dc = {};
627
diff --git a/target/tilegx/translate.c b/target/tilegx/translate.c
517
628
index XXXXXXX..XXXXXXX 100644
518
- translator_loop(&sparc_tr_ops, &dc.base, cs, tb, max_insns);
629
--- a/target/tilegx/translate.c
519
+ translator_loop(cs, tb, max_insns, pc, host_pc, &sparc_tr_ops, &dc.base);
630
+++ b/target/tilegx/translate.c
520
}
631
@@ -XXX,XX +XXX,XX @@
521
632
#include "exec/log.h"
522
void sparc_tcg_init(void)
633
#include "disas/disas.h"
634
#include "exec/exec-all.h"
635
-#include "tcg-op.h"
636
+#include "tcg/tcg-op.h"
637
#include "exec/cpu_ldst.h"
638
#include "linux-user/syscall_defs.h"
639
640
diff --git a/target/tricore/translate.c b/target/tricore/translate.c
523
diff --git a/target/tricore/translate.c b/target/tricore/translate.c
641
index XXXXXXX..XXXXXXX 100644
524
index XXXXXXX..XXXXXXX 100644
642
--- a/target/tricore/translate.c
525
--- a/target/tricore/translate.c
643
+++ b/target/tricore/translate.c
526
+++ b/target/tricore/translate.c
644
@@ -XXX,XX +XXX,XX @@
527
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps tricore_tr_ops = {
645
#include "cpu.h"
528
};
646
#include "disas/disas.h"
529
647
#include "exec/exec-all.h"
530
648
-#include "tcg-op.h"
531
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
649
+#include "tcg/tcg-op.h"
532
+void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns,
650
#include "exec/cpu_ldst.h"
533
+ target_ulong pc, void *host_pc)
651
#include "qemu/qemu-print.h"
534
{
652
535
DisasContext ctx;
653
diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c
536
- translator_loop(&tricore_tr_ops, &ctx.base, cs, tb, max_insns);
654
index XXXXXXX..XXXXXXX 100644
537
+ translator_loop(cs, tb, max_insns, pc, host_pc,
655
--- a/target/unicore32/translate.c
538
+ &tricore_tr_ops, &ctx.base);
656
+++ b/target/unicore32/translate.c
539
}
657
@@ -XXX,XX +XXX,XX @@
540
658
#include "cpu.h"
541
void
659
#include "disas/disas.h"
660
#include "exec/exec-all.h"
661
-#include "tcg-op.h"
662
+#include "tcg/tcg-op.h"
663
#include "qemu/log.h"
664
#include "exec/cpu_ldst.h"
665
#include "exec/translator.h"
666
diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
542
diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
667
index XXXXXXX..XXXXXXX 100644
543
index XXXXXXX..XXXXXXX 100644
668
--- a/target/xtensa/translate.c
544
--- a/target/xtensa/translate.c
669
+++ b/target/xtensa/translate.c
545
+++ b/target/xtensa/translate.c
670
@@ -XXX,XX +XXX,XX @@
546
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps xtensa_translator_ops = {
671
#include "cpu.h"
547
.disas_log = xtensa_tr_disas_log,
672
#include "exec/exec-all.h"
548
};
673
#include "disas/disas.h"
549
674
-#include "tcg-op.h"
550
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns)
675
+#include "tcg/tcg-op.h"
551
+void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns,
676
#include "qemu/log.h"
552
+ target_ulong pc, void *host_pc)
677
#include "qemu/qemu-print.h"
553
{
678
#include "exec/cpu_ldst.h"
554
DisasContext dc = {};
679
diff --git a/tcg/optimize.c b/tcg/optimize.c
555
- translator_loop(&xtensa_translator_ops, &dc.base, cpu, tb, max_insns);
680
index XXXXXXX..XXXXXXX 100644
556
+ translator_loop(cpu, tb, max_insns, pc, host_pc,
681
--- a/tcg/optimize.c
557
+ &xtensa_translator_ops, &dc.base);
682
+++ b/tcg/optimize.c
558
}
683
@@ -XXX,XX +XXX,XX @@
559
684
*/
560
void xtensa_cpu_dump_state(CPUState *cs, FILE *f, int flags)
685
686
#include "qemu/osdep.h"
687
-#include "tcg-op.h"
688
+#include "tcg/tcg-op.h"
689
690
#define CASE_OP_32_64(x) \
691
glue(glue(case INDEX_op_, x), _i32): \
692
diff --git a/tcg/tcg-common.c b/tcg/tcg-common.c
693
index XXXXXXX..XXXXXXX 100644
694
--- a/tcg/tcg-common.c
695
+++ b/tcg/tcg-common.c
696
@@ -XXX,XX +XXX,XX @@ uintptr_t tci_tb_ptr;
697
TCGOpDef tcg_op_defs[] = {
698
#define DEF(s, oargs, iargs, cargs, flags) \
699
{ #s, oargs, iargs, cargs, iargs + oargs + cargs, flags },
700
-#include "tcg-opc.h"
701
+#include "tcg/tcg-opc.h"
702
#undef DEF
703
};
704
const size_t tcg_op_defs_max = ARRAY_SIZE(tcg_op_defs);
705
diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c
706
index XXXXXXX..XXXXXXX 100644
707
--- a/tcg/tcg-op-gvec.c
708
+++ b/tcg/tcg-op-gvec.c
709
@@ -XXX,XX +XXX,XX @@
710
*/
711
712
#include "qemu/osdep.h"
713
-#include "tcg.h"
714
-#include "tcg-op.h"
715
-#include "tcg-op-gvec.h"
716
+#include "tcg/tcg.h"
717
+#include "tcg/tcg-op.h"
718
+#include "tcg/tcg-op-gvec.h"
719
#include "qemu/main-loop.h"
720
-#include "tcg-gvec-desc.h"
721
+#include "tcg/tcg-gvec-desc.h"
722
723
#define MAX_UNROLL 4
724
725
diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c
726
index XXXXXXX..XXXXXXX 100644
727
--- a/tcg/tcg-op-vec.c
728
+++ b/tcg/tcg-op-vec.c
729
@@ -XXX,XX +XXX,XX @@
730
731
#include "qemu/osdep.h"
732
#include "cpu.h"
733
-#include "tcg.h"
734
-#include "tcg-op.h"
735
-#include "tcg-mo.h"
736
+#include "tcg/tcg.h"
737
+#include "tcg/tcg-op.h"
738
+#include "tcg/tcg-mo.h"
739
740
/* Reduce the number of ifdefs below. This assumes that all uses of
741
TCGV_HIGH and TCGV_LOW are properly protected by a conditional that
742
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
743
index XXXXXXX..XXXXXXX 100644
744
--- a/tcg/tcg-op.c
745
+++ b/tcg/tcg-op.c
746
@@ -XXX,XX +XXX,XX @@
747
#include "qemu/osdep.h"
748
#include "cpu.h"
749
#include "exec/exec-all.h"
750
-#include "tcg.h"
751
-#include "tcg-op.h"
752
-#include "tcg-mo.h"
753
+#include "tcg/tcg.h"
754
+#include "tcg/tcg-op.h"
755
+#include "tcg/tcg-mo.h"
756
#include "trace-tcg.h"
757
#include "trace/mem.h"
758
#include "exec/plugin-gen.h"
759
diff --git a/tcg/tcg.c b/tcg/tcg.c
760
index XXXXXXX..XXXXXXX 100644
761
--- a/tcg/tcg.c
762
+++ b/tcg/tcg.c
763
@@ -XXX,XX +XXX,XX @@
764
#include "hw/boards.h"
765
#endif
766
767
-#include "tcg-op.h"
768
+#include "tcg/tcg-op.h"
769
770
#if UINTPTR_MAX == UINT32_MAX
771
# define ELF_CLASS ELFCLASS32
772
diff --git a/tcg/tci.c b/tcg/tci.c
773
index XXXXXXX..XXXXXXX 100644
774
--- a/tcg/tci.c
775
+++ b/tcg/tci.c
776
@@ -XXX,XX +XXX,XX @@
777
#include "qemu-common.h"
778
#include "tcg/tcg.h" /* MAX_OPC_PARAM_IARGS */
779
#include "exec/cpu_ldst.h"
780
-#include "tcg-op.h"
781
+#include "tcg/tcg-op.h"
782
783
/* Marker for missing code. */
784
#define TODO() \
785
--
561
--
786
2.20.1
562
2.34.1
787
788
diff view generated by jsdifflib
1
The commentary talks about "in concert with the addresses
1
Cache the translation from guest to host address, so we may
2
assigned in the relevant linker script", except there is no
2
use direct loads when we hit on the primary translation page.
3
linker script for softmmu, nor has there been for some time.
4
3
5
(Do not confuse the user-only linker script editing that was
4
Look up the second translation page only once, during translation.
6
removed in the previous patch, because user-only does not
5
This obviates another lookup of the second page within tb_gen_code
7
use this code_gen_buffer allocation method.)
6
after translation.
8
7
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Fixes a bug in that plugin_insn_append should be passed the bytes
10
Reviewed-by: Thomas Huth <thuth@redhat.com>
9
in the original memory order, not bswapped by pieces.
10
11
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
12
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
---
14
---
13
accel/tcg/translate-all.c | 37 +++++--------------------------------
15
include/exec/translator.h | 63 +++++++++++--------
14
1 file changed, 5 insertions(+), 32 deletions(-)
16
accel/tcg/translate-all.c | 23 +++----
17
accel/tcg/translator.c | 126 +++++++++++++++++++++++++++++---------
18
3 files changed, 141 insertions(+), 71 deletions(-)
15
19
20
diff --git a/include/exec/translator.h b/include/exec/translator.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/include/exec/translator.h
23
+++ b/include/exec/translator.h
24
@@ -XXX,XX +XXX,XX @@ typedef enum DisasJumpType {
25
* Architecture-agnostic disassembly context.
26
*/
27
typedef struct DisasContextBase {
28
- const TranslationBlock *tb;
29
+ TranslationBlock *tb;
30
target_ulong pc_first;
31
target_ulong pc_next;
32
DisasJumpType is_jmp;
33
int num_insns;
34
int max_insns;
35
bool singlestep_enabled;
36
-#ifdef CONFIG_USER_ONLY
37
- /*
38
- * Guest address of the last byte of the last protected page.
39
- *
40
- * Pages containing the translated instructions are made non-writable in
41
- * order to achieve consistency in case another thread is modifying the
42
- * code while translate_insn() fetches the instruction bytes piecemeal.
43
- * Such writer threads are blocked on mmap_lock() in page_unprotect().
44
- */
45
- target_ulong page_protect_end;
46
-#endif
47
+ void *host_addr[2];
48
} DisasContextBase;
49
50
/**
51
@@ -XXX,XX +XXX,XX @@ bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest);
52
* the relevant information at translation time.
53
*/
54
55
-#define GEN_TRANSLATOR_LD(fullname, type, load_fn, swap_fn) \
56
- type fullname ## _swap(CPUArchState *env, DisasContextBase *dcbase, \
57
- abi_ptr pc, bool do_swap); \
58
- static inline type fullname(CPUArchState *env, \
59
- DisasContextBase *dcbase, abi_ptr pc) \
60
- { \
61
- return fullname ## _swap(env, dcbase, pc, false); \
62
+uint8_t translator_ldub(CPUArchState *env, DisasContextBase *db, abi_ptr pc);
63
+uint16_t translator_lduw(CPUArchState *env, DisasContextBase *db, abi_ptr pc);
64
+uint32_t translator_ldl(CPUArchState *env, DisasContextBase *db, abi_ptr pc);
65
+uint64_t translator_ldq(CPUArchState *env, DisasContextBase *db, abi_ptr pc);
66
+
67
+static inline uint16_t
68
+translator_lduw_swap(CPUArchState *env, DisasContextBase *db,
69
+ abi_ptr pc, bool do_swap)
70
+{
71
+ uint16_t ret = translator_lduw(env, db, pc);
72
+ if (do_swap) {
73
+ ret = bswap16(ret);
74
}
75
+ return ret;
76
+}
77
78
-#define FOR_EACH_TRANSLATOR_LD(F) \
79
- F(translator_ldub, uint8_t, cpu_ldub_code, /* no swap */) \
80
- F(translator_lduw, uint16_t, cpu_lduw_code, bswap16) \
81
- F(translator_ldl, uint32_t, cpu_ldl_code, bswap32) \
82
- F(translator_ldq, uint64_t, cpu_ldq_code, bswap64)
83
+static inline uint32_t
84
+translator_ldl_swap(CPUArchState *env, DisasContextBase *db,
85
+ abi_ptr pc, bool do_swap)
86
+{
87
+ uint32_t ret = translator_ldl(env, db, pc);
88
+ if (do_swap) {
89
+ ret = bswap32(ret);
90
+ }
91
+ return ret;
92
+}
93
94
-FOR_EACH_TRANSLATOR_LD(GEN_TRANSLATOR_LD)
95
-
96
-#undef GEN_TRANSLATOR_LD
97
+static inline uint64_t
98
+translator_ldq_swap(CPUArchState *env, DisasContextBase *db,
99
+ abi_ptr pc, bool do_swap)
100
+{
101
+ uint64_t ret = translator_ldq_swap(env, db, pc, false);
102
+ if (do_swap) {
103
+ ret = bswap64(ret);
104
+ }
105
+ return ret;
106
+}
107
108
/*
109
* Return whether addr is on the same page as where disassembly started.
16
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
110
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
17
index XXXXXXX..XXXXXXX 100644
111
index XXXXXXX..XXXXXXX 100644
18
--- a/accel/tcg/translate-all.c
112
--- a/accel/tcg/translate-all.c
19
+++ b/accel/tcg/translate-all.c
113
+++ b/accel/tcg/translate-all.c
20
@@ -XXX,XX +XXX,XX @@ static inline void *alloc_code_gen_buffer(void)
114
@@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu,
21
{
115
{
22
int prot = PROT_WRITE | PROT_READ | PROT_EXEC;
116
CPUArchState *env = cpu->env_ptr;
23
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
117
TranslationBlock *tb, *existing_tb;
24
- uintptr_t start = 0;
118
- tb_page_addr_t phys_pc, phys_page2;
25
size_t size = tcg_ctx->code_gen_buffer_size;
119
- target_ulong virt_page2;
26
void *buf;
120
+ tb_page_addr_t phys_pc;
27
121
tcg_insn_unit *gen_code_buf;
28
- /* Constrain the position of the buffer based on the host cpu.
122
int gen_code_size, search_size, max_insns;
29
- Note that these addresses are chosen in concert with the
123
#ifdef CONFIG_PROFILER
30
- addresses assigned in the relevant linker script file. */
124
@@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu,
31
-# if defined(__PIE__) || defined(__PIC__)
125
tb->flags = flags;
32
- /* Don't bother setting a preferred location if we're building
126
tb->cflags = cflags;
33
- a position-independent executable. We're more likely to get
127
tb->trace_vcpu_dstate = *cpu->trace_dstate;
34
- an address near the main executable if we let the kernel
128
+ tb->page_addr[0] = phys_pc;
35
- choose the address. */
129
+ tb->page_addr[1] = -1;
36
-# elif defined(__x86_64__) && defined(MAP_32BIT)
130
tcg_ctx->tb_cflags = cflags;
37
- /* Force the memory down into low memory with the executable.
131
tb_overflow:
38
- Leave the choice of exact location with the kernel. */
132
39
- flags |= MAP_32BIT;
133
@@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu,
40
- /* Cannot expect to map more than 800MB in low memory. */
134
}
41
- if (size > 800u * 1024 * 1024) {
135
42
- tcg_ctx->code_gen_buffer_size = size = 800u * 1024 * 1024;
136
/*
137
- * If the TB is not associated with a physical RAM page then
138
- * it must be a temporary one-insn TB, and we have nothing to do
139
- * except fill in the page_addr[] fields. Return early before
140
- * attempting to link to other TBs or add to the lookup table.
141
+ * If the TB is not associated with a physical RAM page then it must be
142
+ * a temporary one-insn TB, and we have nothing left to do. Return early
143
+ * before attempting to link to other TBs or add to the lookup table.
144
*/
145
- if (phys_pc == -1) {
146
- tb->page_addr[0] = tb->page_addr[1] = -1;
147
+ if (tb->page_addr[0] == -1) {
148
return tb;
149
}
150
151
@@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu,
152
*/
153
tcg_tb_insert(tb);
154
155
- /* check next page if needed */
156
- virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
157
- phys_page2 = -1;
158
- if ((pc & TARGET_PAGE_MASK) != virt_page2) {
159
- phys_page2 = get_page_addr_code(env, virt_page2);
43
- }
160
- }
44
-# elif defined(__sparc__)
161
/*
45
- start = 0x40000000ul;
162
* No explicit memory barrier is required -- tb_link_page() makes the
46
-# elif defined(__s390x__)
163
* TB visible in a consistent state.
47
- start = 0x90000000ul;
164
*/
48
-# elif defined(__mips__)
165
- existing_tb = tb_link_page(tb, phys_pc, phys_page2);
49
-# if _MIPS_SIM == _ABI64
166
+ existing_tb = tb_link_page(tb, tb->page_addr[0], tb->page_addr[1]);
50
- start = 0x128000000ul;
167
/* if the TB already exists, discard what we just translated */
51
-# else
168
if (unlikely(existing_tb != tb)) {
52
- start = 0x08000000ul;
169
uintptr_t orig_aligned = (uintptr_t)gen_code_buf;
53
-# endif
170
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
54
-# endif
171
index XXXXXXX..XXXXXXX 100644
172
--- a/accel/tcg/translator.c
173
+++ b/accel/tcg/translator.c
174
@@ -XXX,XX +XXX,XX @@ bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest)
175
return ((db->pc_first ^ dest) & TARGET_PAGE_MASK) == 0;
176
}
177
178
-static inline void translator_page_protect(DisasContextBase *dcbase,
179
- target_ulong pc)
180
-{
181
-#ifdef CONFIG_USER_ONLY
182
- dcbase->page_protect_end = pc | ~TARGET_PAGE_MASK;
183
- page_protect(pc);
184
-#endif
185
-}
55
-
186
-
56
- buf = mmap((void *)start, size, prot, flags, -1, 0);
187
void translator_loop(CPUState *cpu, TranslationBlock *tb, int max_insns,
57
+ buf = mmap(NULL, size, prot, flags, -1, 0);
188
target_ulong pc, void *host_pc,
58
if (buf == MAP_FAILED) {
189
const TranslatorOps *ops, DisasContextBase *db)
59
return NULL;
190
@@ -XXX,XX +XXX,XX @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int max_insns,
60
}
191
db->num_insns = 0;
61
192
db->max_insns = max_insns;
62
#ifdef __mips__
193
db->singlestep_enabled = cflags & CF_SINGLE_STEP;
63
if (cross_256mb(buf, size)) {
194
- translator_page_protect(db, db->pc_next);
64
- /* Try again, with the original still mapped, to avoid re-acquiring
195
+ db->host_addr[0] = host_pc;
65
- that 256mb crossing. This time don't specify an address. */
196
+ db->host_addr[1] = NULL;
66
+ /*
197
+
67
+ * Try again, with the original still mapped, to avoid re-acquiring
198
+#ifdef CONFIG_USER_ONLY
68
+ * the same 256mb crossing.
199
+ page_protect(pc);
69
+ */
200
+#endif
70
size_t size2;
201
71
void *buf2 = mmap(NULL, size, prot, flags, -1, 0);
202
ops->init_disas_context(db, cpu);
72
switch ((int)(buf2 != MAP_FAILED)) {
203
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
204
@@ -XXX,XX +XXX,XX @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int max_insns,
205
#endif
206
}
207
208
-static inline void translator_maybe_page_protect(DisasContextBase *dcbase,
209
- target_ulong pc, size_t len)
210
+static void *translator_access(CPUArchState *env, DisasContextBase *db,
211
+ target_ulong pc, size_t len)
212
{
213
-#ifdef CONFIG_USER_ONLY
214
- target_ulong end = pc + len - 1;
215
+ void *host;
216
+ target_ulong base, end;
217
+ TranslationBlock *tb;
218
219
- if (end > dcbase->page_protect_end) {
220
- translator_page_protect(dcbase, end);
221
+ tb = db->tb;
222
+
223
+ /* Use slow path if first page is MMIO. */
224
+ if (unlikely(tb->page_addr[0] == -1)) {
225
+ return NULL;
226
}
227
+
228
+ end = pc + len - 1;
229
+ if (likely(is_same_page(db, end))) {
230
+ host = db->host_addr[0];
231
+ base = db->pc_first;
232
+ } else {
233
+ host = db->host_addr[1];
234
+ base = TARGET_PAGE_ALIGN(db->pc_first);
235
+ if (host == NULL) {
236
+ tb->page_addr[1] =
237
+ get_page_addr_code_hostp(env, base, &db->host_addr[1]);
238
+#ifdef CONFIG_USER_ONLY
239
+ page_protect(end);
240
#endif
241
+ /* We cannot handle MMIO as second page. */
242
+ assert(tb->page_addr[1] != -1);
243
+ host = db->host_addr[1];
244
+ }
245
+
246
+ /* Use slow path when crossing pages. */
247
+ if (is_same_page(db, pc)) {
248
+ return NULL;
249
+ }
250
+ }
251
+
252
+ tcg_debug_assert(pc >= base);
253
+ return host + (pc - base);
254
}
255
256
-#define GEN_TRANSLATOR_LD(fullname, type, load_fn, swap_fn) \
257
- type fullname ## _swap(CPUArchState *env, DisasContextBase *dcbase, \
258
- abi_ptr pc, bool do_swap) \
259
- { \
260
- translator_maybe_page_protect(dcbase, pc, sizeof(type)); \
261
- type ret = load_fn(env, pc); \
262
- if (do_swap) { \
263
- ret = swap_fn(ret); \
264
- } \
265
- plugin_insn_append(pc, &ret, sizeof(ret)); \
266
- return ret; \
267
+uint8_t translator_ldub(CPUArchState *env, DisasContextBase *db, abi_ptr pc)
268
+{
269
+ uint8_t ret;
270
+ void *p = translator_access(env, db, pc, sizeof(ret));
271
+
272
+ if (p) {
273
+ plugin_insn_append(pc, p, sizeof(ret));
274
+ return ldub_p(p);
275
}
276
+ ret = cpu_ldub_code(env, pc);
277
+ plugin_insn_append(pc, &ret, sizeof(ret));
278
+ return ret;
279
+}
280
281
-FOR_EACH_TRANSLATOR_LD(GEN_TRANSLATOR_LD)
282
+uint16_t translator_lduw(CPUArchState *env, DisasContextBase *db, abi_ptr pc)
283
+{
284
+ uint16_t ret, plug;
285
+ void *p = translator_access(env, db, pc, sizeof(ret));
286
287
-#undef GEN_TRANSLATOR_LD
288
+ if (p) {
289
+ plugin_insn_append(pc, p, sizeof(ret));
290
+ return lduw_p(p);
291
+ }
292
+ ret = cpu_lduw_code(env, pc);
293
+ plug = tswap16(ret);
294
+ plugin_insn_append(pc, &plug, sizeof(ret));
295
+ return ret;
296
+}
297
+
298
+uint32_t translator_ldl(CPUArchState *env, DisasContextBase *db, abi_ptr pc)
299
+{
300
+ uint32_t ret, plug;
301
+ void *p = translator_access(env, db, pc, sizeof(ret));
302
+
303
+ if (p) {
304
+ plugin_insn_append(pc, p, sizeof(ret));
305
+ return ldl_p(p);
306
+ }
307
+ ret = cpu_ldl_code(env, pc);
308
+ plug = tswap32(ret);
309
+ plugin_insn_append(pc, &plug, sizeof(ret));
310
+ return ret;
311
+}
312
+
313
+uint64_t translator_ldq(CPUArchState *env, DisasContextBase *db, abi_ptr pc)
314
+{
315
+ uint64_t ret, plug;
316
+ void *p = translator_access(env, db, pc, sizeof(ret));
317
+
318
+ if (p) {
319
+ plugin_insn_append(pc, p, sizeof(ret));
320
+ return ldq_p(p);
321
+ }
322
+ ret = cpu_ldq_code(env, pc);
323
+ plug = tswap64(ret);
324
+ plugin_insn_append(pc, &plug, sizeof(ret));
325
+ return ret;
326
+}
73
--
327
--
74
2.20.1
328
2.34.1
75
76
diff view generated by jsdifflib
Deleted patch
1
PIE is supported on many other hosts besides x86.
2
1
3
The default for non-x86 is now the same as x86: pie is used
4
if supported, and may be forced via --enable/--disable-pie.
5
6
The original commit (40d6444e91c) said:
7
8
"Non-x86 are not changed, as they require TCG changes"
9
10
but I think that's wrong -- there's nothing about PIE that
11
affects TCG one way or another.
12
13
Tested on aarch64 (bionic) and ppc64le (centos 7) hosts.
14
15
Tested-by: Alex Bennée <alex.bennee@linaro.org>
16
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
17
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
18
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
19
---
20
configure | 10 ----------
21
1 file changed, 10 deletions(-)
22
23
diff --git a/configure b/configure
24
index XXXXXXX..XXXXXXX 100755
25
--- a/configure
26
+++ b/configure
27
@@ -XXX,XX +XXX,XX @@ if ! compile_prog "-Werror" "" ; then
28
    "Thread-Local Storage (TLS). Please upgrade to a version that does."
29
fi
30
31
-if test "$pie" = ""; then
32
- case "$cpu-$targetos" in
33
- i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
34
- ;;
35
- *)
36
- pie="no"
37
- ;;
38
- esac
39
-fi
40
-
41
if test "$pie" != "no" ; then
42
cat > $TMPC << EOF
43
44
--
45
2.20.1
46
47
diff view generated by jsdifflib
Deleted patch
1
The CFLAGS_NOPIE and LDFLAGS_NOPIE variables are used
2
in pc-bios/optionrom/Makefile, which has nothing to do
3
with the PIE setting of the main qemu executables.
4
1
5
This overrides any operating system default to build
6
all executables as PIE, which is important for ROMs.
7
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Thomas Huth <thuth@redhat.com>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
---
12
configure | 18 ++++++++----------
13
1 file changed, 8 insertions(+), 10 deletions(-)
14
15
diff --git a/configure b/configure
16
index XXXXXXX..XXXXXXX 100755
17
--- a/configure
18
+++ b/configure
19
@@ -XXX,XX +XXX,XX @@ if ! compile_prog "-Werror" "" ; then
20
    "Thread-Local Storage (TLS). Please upgrade to a version that does."
21
fi
22
23
-if test "$pie" != "no" ; then
24
- cat > $TMPC << EOF
25
+cat > $TMPC << EOF
26
27
#ifdef __linux__
28
# define THREAD __thread
29
#else
30
# define THREAD
31
#endif
32
-
33
static THREAD int tls_var;
34
-
35
int main(void) { return tls_var; }
36
-
37
EOF
38
- # check we support --no-pie first...
39
- if compile_prog "-Werror -fno-pie" "-no-pie"; then
40
- CFLAGS_NOPIE="-fno-pie"
41
- LDFLAGS_NOPIE="-nopie"
42
- fi
43
44
+# Check we support --no-pie first; we will need this for building ROMs.
45
+if compile_prog "-Werror -fno-pie" "-no-pie"; then
46
+ CFLAGS_NOPIE="-fno-pie"
47
+ LDFLAGS_NOPIE="-no-pie"
48
+fi
49
+
50
+if test "$pie" != "no" ; then
51
if compile_prog "-fPIE -DPIE" "-pie"; then
52
QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
53
LDFLAGS="-pie $LDFLAGS"
54
--
55
2.20.1
56
57
diff view generated by jsdifflib
Deleted patch
1
There is nothing about these options that is related to PIE.
2
Use them unconditionally.
3
1
4
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Reviewed-by: Fangrui Song <i@maskray.me>
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
v2: Do not split into two tests.
10
---
11
configure | 9 ++++++---
12
1 file changed, 6 insertions(+), 3 deletions(-)
13
14
diff --git a/configure b/configure
15
index XXXXXXX..XXXXXXX 100755
16
--- a/configure
17
+++ b/configure
18
@@ -XXX,XX +XXX,XX @@ if test "$pie" != "no" ; then
19
QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
20
LDFLAGS="-pie $LDFLAGS"
21
pie="yes"
22
- if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
23
- LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
24
- fi
25
else
26
if test "$pie" = "yes"; then
27
error_exit "PIE not available due to missing toolchain support"
28
@@ -XXX,XX +XXX,XX @@ if test "$pie" != "no" ; then
29
fi
30
fi
31
32
+# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
33
+# The combination is known as "full relro", because .got.plt is read-only too.
34
+if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
35
+ LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
36
+fi
37
+
38
##########################################
39
# __sync_fetch_and_and requires at least -march=i486. Many toolchains
40
# use i686 as default anyway, but for those that don't, an explicit
41
--
42
2.20.1
43
44
diff view generated by jsdifflib
Deleted patch
1
Some distributions, e.g. Ubuntu 19.10, enable PIE by default.
2
If for some reason one wishes to build a non-pie binary, we
3
must provide additional options to override.
4
1
5
At the same time, reorg the code to an elif chain.
6
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Thomas Huth <thuth@redhat.com>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
---
12
configure | 25 ++++++++++++-------------
13
1 file changed, 12 insertions(+), 13 deletions(-)
14
15
diff --git a/configure b/configure
16
index XXXXXXX..XXXXXXX 100755
17
--- a/configure
18
+++ b/configure
19
@@ -XXX,XX +XXX,XX @@ if compile_prog "-Werror -fno-pie" "-no-pie"; then
20
LDFLAGS_NOPIE="-no-pie"
21
fi
22
23
-if test "$pie" != "no" ; then
24
- if compile_prog "-fPIE -DPIE" "-pie"; then
25
- QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
26
- LDFLAGS="-pie $LDFLAGS"
27
- pie="yes"
28
- else
29
- if test "$pie" = "yes"; then
30
- error_exit "PIE not available due to missing toolchain support"
31
- else
32
- echo "Disabling PIE due to missing toolchain support"
33
- pie="no"
34
- fi
35
- fi
36
+if test "$pie" = "no"; then
37
+ QEMU_CFLAGS="$CFLAGS_NOPIE $QEMU_CFLAGS"
38
+ LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
39
+elif compile_prog "-fPIE -DPIE" "-pie"; then
40
+ QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
41
+ LDFLAGS="-pie $LDFLAGS"
42
+ pie="yes"
43
+elif test "$pie" = "yes"; then
44
+ error_exit "PIE not available due to missing toolchain support"
45
+else
46
+ echo "Disabling PIE due to missing toolchain support"
47
+ pie="no"
48
fi
49
50
# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
51
--
52
2.20.1
53
54
diff view generated by jsdifflib
Deleted patch
1
Recent toolchains support static and pie at the same time.
2
1
3
As with normal dynamic builds, allow --static to default to PIE
4
if supported by the toolchain. Allow --enable/--disable-pie to
5
override the default.
6
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
10
v2: Fix --disable-pie --static
11
---
12
configure | 19 ++++++++++++-------
13
1 file changed, 12 insertions(+), 7 deletions(-)
14
15
diff --git a/configure b/configure
16
index XXXXXXX..XXXXXXX 100755
17
--- a/configure
18
+++ b/configure
19
@@ -XXX,XX +XXX,XX @@ for opt do
20
;;
21
--static)
22
static="yes"
23
- LDFLAGS="-static $LDFLAGS"
24
QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
25
;;
26
--mandir=*) mandir="$optarg"
27
@@ -XXX,XX +XXX,XX @@ if test "$static" = "yes" ; then
28
if test "$modules" = "yes" ; then
29
error_exit "static and modules are mutually incompatible"
30
fi
31
- if test "$pie" = "yes" ; then
32
- error_exit "static and pie are mutually incompatible"
33
- else
34
- pie="no"
35
- fi
36
fi
37
38
# Unconditional check for compiler __thread support
39
@@ -XXX,XX +XXX,XX @@ if compile_prog "-Werror -fno-pie" "-no-pie"; then
40
LDFLAGS_NOPIE="-no-pie"
41
fi
42
43
-if test "$pie" = "no"; then
44
+if test "$static" = "yes"; then
45
+ if test "$pie" != "no" && compile_prog "-fPIE -DPIE" "-static-pie"; then
46
+ QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
47
+ LDFLAGS="-static-pie $LDFLAGS"
48
+ pie="yes"
49
+ elif test "$pie" = "yes"; then
50
+ error_exit "-static-pie not available due to missing toolchain support"
51
+ else
52
+ LDFLAGS="-static $LDFLAGS"
53
+ pie="no"
54
+ fi
55
+elif test "$pie" = "no"; then
56
QEMU_CFLAGS="$CFLAGS_NOPIE $QEMU_CFLAGS"
57
LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
58
elif compile_prog "-fPIE -DPIE" "-pie"; then
59
--
60
2.20.1
61
62
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
From: Ilya Leoshkevich <iii@linux.ibm.com>
2
2
3
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
3
Right now translator stops right *after* the end of a page, which
4
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
4
breaks reporting of fault locations when the last instruction of a
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
multi-insn translation block crosses a page boundary.
6
7
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-Id: <20220817150506.592862-3-iii@linux.ibm.com>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
11
---
8
target/xtensa/cpu.h | 4 ----
12
target/s390x/tcg/translate.c | 15 +++-
9
1 file changed, 4 deletions(-)
13
tests/tcg/s390x/noexec.c | 106 +++++++++++++++++++++++
14
tests/tcg/multiarch/noexec.c.inc | 139 +++++++++++++++++++++++++++++++
15
tests/tcg/s390x/Makefile.target | 1 +
16
4 files changed, 257 insertions(+), 4 deletions(-)
17
create mode 100644 tests/tcg/s390x/noexec.c
18
create mode 100644 tests/tcg/multiarch/noexec.c.inc
10
19
11
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
20
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
12
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
13
--- a/target/xtensa/cpu.h
22
--- a/target/s390x/tcg/translate.c
14
+++ b/target/xtensa/cpu.h
23
+++ b/target/s390x/tcg/translate.c
15
@@ -XXX,XX +XXX,XX @@ static inline uint32_t xtensa_replicate_windowstart(CPUXtensaState *env)
24
@@ -XXX,XX +XXX,XX @@ static void s390x_tr_insn_start(DisasContextBase *dcbase, CPUState *cs)
25
dc->insn_start = tcg_last_op();
16
}
26
}
17
27
18
/* MMU modes definitions */
28
+static target_ulong get_next_pc(CPUS390XState *env, DisasContext *s,
19
-#define MMU_MODE0_SUFFIX _ring0
29
+ uint64_t pc)
20
-#define MMU_MODE1_SUFFIX _ring1
30
+{
21
-#define MMU_MODE2_SUFFIX _ring2
31
+ uint64_t insn = ld_code2(env, s, pc);
22
-#define MMU_MODE3_SUFFIX _ring3
32
+
23
#define MMU_USER_IDX 3
33
+ return pc + get_ilen((insn >> 8) & 0xff);
24
34
+}
25
static inline int cpu_mmu_index(CPUXtensaState *env, bool ifetch)
35
+
36
static void s390x_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
37
{
38
CPUS390XState *env = cs->env_ptr;
39
@@ -XXX,XX +XXX,XX @@ static void s390x_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
40
41
dc->base.is_jmp = translate_one(env, dc);
42
if (dc->base.is_jmp == DISAS_NEXT) {
43
- uint64_t page_start;
44
-
45
- page_start = dc->base.pc_first & TARGET_PAGE_MASK;
46
- if (dc->base.pc_next - page_start >= TARGET_PAGE_SIZE || dc->ex_value) {
47
+ if (!is_same_page(dcbase, dc->base.pc_next) ||
48
+ !is_same_page(dcbase, get_next_pc(env, dc, dc->base.pc_next)) ||
49
+ dc->ex_value) {
50
dc->base.is_jmp = DISAS_TOO_MANY;
51
}
52
}
53
diff --git a/tests/tcg/s390x/noexec.c b/tests/tcg/s390x/noexec.c
54
new file mode 100644
55
index XXXXXXX..XXXXXXX
56
--- /dev/null
57
+++ b/tests/tcg/s390x/noexec.c
58
@@ -XXX,XX +XXX,XX @@
59
+#include "../multiarch/noexec.c.inc"
60
+
61
+static void *arch_mcontext_pc(const mcontext_t *ctx)
62
+{
63
+ return (void *)ctx->psw.addr;
64
+}
65
+
66
+static int arch_mcontext_arg(const mcontext_t *ctx)
67
+{
68
+ return ctx->gregs[2];
69
+}
70
+
71
+static void arch_flush(void *p, int len)
72
+{
73
+}
74
+
75
+extern char noexec_1[];
76
+extern char noexec_2[];
77
+extern char noexec_end[];
78
+
79
+asm("noexec_1:\n"
80
+ " lgfi %r2,1\n" /* %r2 is 0 on entry, set 1. */
81
+ "noexec_2:\n"
82
+ " lgfi %r2,2\n" /* %r2 is 0/1; set 2. */
83
+ " br %r14\n" /* return */
84
+ "noexec_end:");
85
+
86
+extern char exrl_1[];
87
+extern char exrl_2[];
88
+extern char exrl_end[];
89
+
90
+asm("exrl_1:\n"
91
+ " exrl %r0, exrl_2\n"
92
+ " br %r14\n"
93
+ "exrl_2:\n"
94
+ " lgfi %r2,2\n"
95
+ "exrl_end:");
96
+
97
+int main(void)
98
+{
99
+ struct noexec_test noexec_tests[] = {
100
+ {
101
+ .name = "fallthrough",
102
+ .test_code = noexec_1,
103
+ .test_len = noexec_end - noexec_1,
104
+ .page_ofs = noexec_1 - noexec_2,
105
+ .entry_ofs = noexec_1 - noexec_2,
106
+ .expected_si_ofs = 0,
107
+ .expected_pc_ofs = 0,
108
+ .expected_arg = 1,
109
+ },
110
+ {
111
+ .name = "jump",
112
+ .test_code = noexec_1,
113
+ .test_len = noexec_end - noexec_1,
114
+ .page_ofs = noexec_1 - noexec_2,
115
+ .entry_ofs = 0,
116
+ .expected_si_ofs = 0,
117
+ .expected_pc_ofs = 0,
118
+ .expected_arg = 0,
119
+ },
120
+ {
121
+ .name = "exrl",
122
+ .test_code = exrl_1,
123
+ .test_len = exrl_end - exrl_1,
124
+ .page_ofs = exrl_1 - exrl_2,
125
+ .entry_ofs = exrl_1 - exrl_2,
126
+ .expected_si_ofs = 0,
127
+ .expected_pc_ofs = exrl_1 - exrl_2,
128
+ .expected_arg = 0,
129
+ },
130
+ {
131
+ .name = "fallthrough [cross]",
132
+ .test_code = noexec_1,
133
+ .test_len = noexec_end - noexec_1,
134
+ .page_ofs = noexec_1 - noexec_2 - 2,
135
+ .entry_ofs = noexec_1 - noexec_2 - 2,
136
+ .expected_si_ofs = 0,
137
+ .expected_pc_ofs = -2,
138
+ .expected_arg = 1,
139
+ },
140
+ {
141
+ .name = "jump [cross]",
142
+ .test_code = noexec_1,
143
+ .test_len = noexec_end - noexec_1,
144
+ .page_ofs = noexec_1 - noexec_2 - 2,
145
+ .entry_ofs = -2,
146
+ .expected_si_ofs = 0,
147
+ .expected_pc_ofs = -2,
148
+ .expected_arg = 0,
149
+ },
150
+ {
151
+ .name = "exrl [cross]",
152
+ .test_code = exrl_1,
153
+ .test_len = exrl_end - exrl_1,
154
+ .page_ofs = exrl_1 - exrl_2 - 2,
155
+ .entry_ofs = exrl_1 - exrl_2 - 2,
156
+ .expected_si_ofs = 0,
157
+ .expected_pc_ofs = exrl_1 - exrl_2 - 2,
158
+ .expected_arg = 0,
159
+ },
160
+ };
161
+
162
+ return test_noexec(noexec_tests,
163
+ sizeof(noexec_tests) / sizeof(noexec_tests[0]));
164
+}
165
diff --git a/tests/tcg/multiarch/noexec.c.inc b/tests/tcg/multiarch/noexec.c.inc
166
new file mode 100644
167
index XXXXXXX..XXXXXXX
168
--- /dev/null
169
+++ b/tests/tcg/multiarch/noexec.c.inc
170
@@ -XXX,XX +XXX,XX @@
171
+/*
172
+ * Common code for arch-specific MMU_INST_FETCH fault testing.
173
+ */
174
+
175
+#define _GNU_SOURCE
176
+
177
+#include <assert.h>
178
+#include <signal.h>
179
+#include <stdio.h>
180
+#include <stdlib.h>
181
+#include <string.h>
182
+#include <errno.h>
183
+#include <unistd.h>
184
+#include <sys/mman.h>
185
+#include <sys/ucontext.h>
186
+
187
+/* Forward declarations. */
188
+
189
+static void *arch_mcontext_pc(const mcontext_t *ctx);
190
+static int arch_mcontext_arg(const mcontext_t *ctx);
191
+static void arch_flush(void *p, int len);
192
+
193
+/* Testing infrastructure. */
194
+
195
+struct noexec_test {
196
+ const char *name;
197
+ const char *test_code;
198
+ int test_len;
199
+ int page_ofs;
200
+ int entry_ofs;
201
+ int expected_si_ofs;
202
+ int expected_pc_ofs;
203
+ int expected_arg;
204
+};
205
+
206
+static void *page_base;
207
+static int page_size;
208
+static const struct noexec_test *current_noexec_test;
209
+
210
+static void handle_err(const char *syscall)
211
+{
212
+ printf("[ FAILED ] %s: %s\n", syscall, strerror(errno));
213
+ exit(EXIT_FAILURE);
214
+}
215
+
216
+static void handle_segv(int sig, siginfo_t *info, void *ucontext)
217
+{
218
+ const struct noexec_test *test = current_noexec_test;
219
+ const mcontext_t *mc = &((ucontext_t *)ucontext)->uc_mcontext;
220
+ void *expected_si;
221
+ void *expected_pc;
222
+ void *pc;
223
+ int arg;
224
+
225
+ if (test == NULL) {
226
+ printf("[ FAILED ] unexpected SEGV\n");
227
+ exit(EXIT_FAILURE);
228
+ }
229
+ current_noexec_test = NULL;
230
+
231
+ expected_si = page_base + test->expected_si_ofs;
232
+ if (info->si_addr != expected_si) {
233
+ printf("[ FAILED ] wrong si_addr (%p != %p)\n",
234
+ info->si_addr, expected_si);
235
+ exit(EXIT_FAILURE);
236
+ }
237
+
238
+ pc = arch_mcontext_pc(mc);
239
+ expected_pc = page_base + test->expected_pc_ofs;
240
+ if (pc != expected_pc) {
241
+ printf("[ FAILED ] wrong pc (%p != %p)\n", pc, expected_pc);
242
+ exit(EXIT_FAILURE);
243
+ }
244
+
245
+ arg = arch_mcontext_arg(mc);
246
+ if (arg != test->expected_arg) {
247
+ printf("[ FAILED ] wrong arg (%d != %d)\n", arg, test->expected_arg);
248
+ exit(EXIT_FAILURE);
249
+ }
250
+
251
+ if (mprotect(page_base, page_size,
252
+ PROT_READ | PROT_WRITE | PROT_EXEC) < 0) {
253
+ handle_err("mprotect");
254
+ }
255
+}
256
+
257
+static void test_noexec_1(const struct noexec_test *test)
258
+{
259
+ void *start = page_base + test->page_ofs;
260
+ void (*fn)(int arg) = page_base + test->entry_ofs;
261
+
262
+ memcpy(start, test->test_code, test->test_len);
263
+ arch_flush(start, test->test_len);
264
+
265
+ /* Trigger TB creation in order to test invalidation. */
266
+ fn(0);
267
+
268
+ if (mprotect(page_base, page_size, PROT_NONE) < 0) {
269
+ handle_err("mprotect");
270
+ }
271
+
272
+ /* Trigger SEGV and check that handle_segv() ran. */
273
+ current_noexec_test = test;
274
+ fn(0);
275
+ assert(current_noexec_test == NULL);
276
+}
277
+
278
+static int test_noexec(struct noexec_test *tests, size_t n_tests)
279
+{
280
+ struct sigaction act;
281
+ size_t i;
282
+
283
+ memset(&act, 0, sizeof(act));
284
+ act.sa_sigaction = handle_segv;
285
+ act.sa_flags = SA_SIGINFO;
286
+ if (sigaction(SIGSEGV, &act, NULL) < 0) {
287
+ handle_err("sigaction");
288
+ }
289
+
290
+ page_size = getpagesize();
291
+ page_base = mmap(NULL, 2 * page_size,
292
+ PROT_READ | PROT_WRITE | PROT_EXEC,
293
+ MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
294
+ if (page_base == MAP_FAILED) {
295
+ handle_err("mmap");
296
+ }
297
+ page_base += page_size;
298
+
299
+ for (i = 0; i < n_tests; i++) {
300
+ struct noexec_test *test = &tests[i];
301
+
302
+ printf("[ RUN ] %s\n", test->name);
303
+ test_noexec_1(test);
304
+ printf("[ OK ]\n");
305
+ }
306
+
307
+ printf("[ PASSED ]\n");
308
+ return EXIT_SUCCESS;
309
+}
310
diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
311
index XXXXXXX..XXXXXXX 100644
312
--- a/tests/tcg/s390x/Makefile.target
313
+++ b/tests/tcg/s390x/Makefile.target
314
@@ -XXX,XX +XXX,XX @@ TESTS+=shift
315
TESTS+=trap
316
TESTS+=signals-s390x
317
TESTS+=branch-relative-long
318
+TESTS+=noexec
319
320
Z14_TESTS=vfminmax
321
vfminmax: LDFLAGS+=-lm
26
--
322
--
27
2.20.1
323
2.34.1
28
29
diff view generated by jsdifflib
1
In the cpu_ldst templates, we already require a MemOp, and it
1
From: Ilya Leoshkevich <iii@linux.ibm.com>
2
is cleaner and clearer to pass that instead of 3 separate
2
3
arguments describing the memory operation.
3
Right now translator stops right *after* the end of a page, which
4
4
breaks reporting of fault locations when the last instruction of a
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
multi-insn translation block crosses a page boundary.
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
An implementation, like the one arm and s390x have, would require an
8
i386 length disassembler, which is burdensome to maintain. Another
9
alternative would be to single-step at the end of a guest page, but
10
this may come with a performance impact.
11
12
Fix by snapshotting disassembly state and restoring it after we figure
13
out we crossed a page boundary. This includes rolling back cc_op
14
updates and emitted ops.
15
16
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1143
19
Message-Id: <20220817150506.592862-4-iii@linux.ibm.com>
20
[rth: Simplify end-of-insn cross-page checks.]
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
21
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
22
---
10
include/exec/cpu_ldst_template.h | 22 +++++++++++-----------
23
target/i386/tcg/translate.c | 64 ++++++++++++++++-----------
11
include/exec/cpu_ldst_useronly_template.h | 12 ++++++------
24
tests/tcg/x86_64/noexec.c | 75 ++++++++++++++++++++++++++++++++
12
2 files changed, 17 insertions(+), 17 deletions(-)
25
tests/tcg/x86_64/Makefile.target | 3 +-
13
26
3 files changed, 116 insertions(+), 26 deletions(-)
14
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
27
create mode 100644 tests/tcg/x86_64/noexec.c
28
29
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
15
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
16
--- a/include/exec/cpu_ldst_template.h
31
--- a/target/i386/tcg/translate.c
17
+++ b/include/exec/cpu_ldst_template.h
32
+++ b/target/i386/tcg/translate.c
18
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
33
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
19
RES_TYPE res;
34
TCGv_i64 tmp1_i64;
20
target_ulong addr;
35
21
int mmu_idx = CPU_MMU_INDEX;
36
sigjmp_buf jmpbuf;
22
- TCGMemOpIdx oi;
37
+ TCGOp *prev_insn_end;
23
+ MemOp op = MO_TE | SHIFT;
38
} DisasContext;
24
#if !defined(SOFTMMU_CODE_ACCESS)
39
25
- uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false, mmu_idx);
40
/* The environment in which user-only runs is constrained. */
26
+ uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
41
@@ -XXX,XX +XXX,XX @@ static uint64_t advance_pc(CPUX86State *env, DisasContext *s, int num_bytes)
27
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
42
{
43
uint64_t pc = s->pc;
44
45
+ /* This is a subsequent insn that crosses a page boundary. */
46
+ if (s->base.num_insns > 1 &&
47
+ !is_same_page(&s->base, s->pc + num_bytes - 1)) {
48
+ siglongjmp(s->jmpbuf, 2);
49
+ }
50
+
51
s->pc += num_bytes;
52
if (unlikely(s->pc - s->pc_start > X86_MAX_INSN_LENGTH)) {
53
/* If the instruction's 16th byte is on a different page than the 1st, a
54
@@ -XXX,XX +XXX,XX @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
55
int modrm, reg, rm, mod, op, opreg, val;
56
target_ulong next_eip, tval;
57
target_ulong pc_start = s->base.pc_next;
58
+ bool orig_cc_op_dirty = s->cc_op_dirty;
59
+ CCOp orig_cc_op = s->cc_op;
60
61
s->pc_start = s->pc = pc_start;
62
s->override = -1;
63
@@ -XXX,XX +XXX,XX @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
64
s->rip_offset = 0; /* for relative ip address */
65
s->vex_l = 0;
66
s->vex_v = 0;
67
- if (sigsetjmp(s->jmpbuf, 0) != 0) {
68
+ switch (sigsetjmp(s->jmpbuf, 0)) {
69
+ case 0:
70
+ break;
71
+ case 1:
72
gen_exception_gpf(s);
73
return s->pc;
74
+ case 2:
75
+ /* Restore state that may affect the next instruction. */
76
+ s->cc_op_dirty = orig_cc_op_dirty;
77
+ s->cc_op = orig_cc_op;
78
+ s->base.num_insns--;
79
+ tcg_remove_ops_after(s->prev_insn_end);
80
+ s->base.is_jmp = DISAS_TOO_MANY;
81
+ return pc_start;
82
+ default:
83
+ g_assert_not_reached();
84
}
85
86
prefixes = 0;
87
@@ -XXX,XX +XXX,XX @@ static void i386_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu)
88
{
89
DisasContext *dc = container_of(dcbase, DisasContext, base);
90
91
+ dc->prev_insn_end = tcg_last_op();
92
tcg_gen_insn_start(dc->base.pc_next, dc->cc_op);
93
}
94
95
@@ -XXX,XX +XXX,XX @@ static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
28
#endif
96
#endif
29
97
30
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
98
pc_next = disas_insn(dc, cpu);
31
entry = tlb_entry(env, mmu_idx, addr);
99
-
32
if (unlikely(entry->ADDR_READ !=
100
- if (dc->flags & (HF_TF_MASK | HF_INHIBIT_IRQ_MASK)) {
33
(addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
101
- /* if single step mode, we generate only one instruction and
34
- oi = make_memop_idx(SHIFT, mmu_idx);
102
- generate an exception */
35
+ TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
103
- /* if irq were inhibited with HF_INHIBIT_IRQ_MASK, we clear
36
res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr,
104
- the flag and abort the translation to give the irqs a
37
- oi, retaddr);
105
- chance to happen */
38
+ oi, retaddr);
106
- dc->base.is_jmp = DISAS_TOO_MANY;
39
} else {
107
- } else if ((tb_cflags(dc->base.tb) & CF_USE_ICOUNT)
40
uintptr_t hostaddr = addr + entry->addend;
108
- && ((pc_next & TARGET_PAGE_MASK)
41
res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr);
109
- != ((pc_next + TARGET_MAX_INSN_SIZE - 1)
42
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
110
- & TARGET_PAGE_MASK)
43
int res;
111
- || (pc_next & ~TARGET_PAGE_MASK) == 0)) {
44
target_ulong addr;
112
- /* Do not cross the boundary of the pages in icount mode,
45
int mmu_idx = CPU_MMU_INDEX;
113
- it can cause an exception. Do it only when boundary is
46
- TCGMemOpIdx oi;
114
- crossed by the first instruction in the block.
47
-#if !defined(SOFTMMU_CODE_ACCESS)
115
- If current instruction already crossed the bound - it's ok,
48
- uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false, mmu_idx);
116
- because an exception hasn't stopped this code.
49
+ MemOp op = MO_TE | MO_SIGN | SHIFT;
117
- */
50
+#ifndef SOFTMMU_CODE_ACCESS
118
- dc->base.is_jmp = DISAS_TOO_MANY;
51
+ uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
119
- } else if ((pc_next - dc->base.pc_first) >= (TARGET_PAGE_SIZE - 32)) {
52
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
120
- dc->base.is_jmp = DISAS_TOO_MANY;
53
#endif
121
- }
54
122
-
55
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
123
dc->base.pc_next = pc_next;
56
entry = tlb_entry(env, mmu_idx, addr);
124
+
57
if (unlikely(entry->ADDR_READ !=
125
+ if (dc->base.is_jmp == DISAS_NEXT) {
58
(addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
126
+ if (dc->flags & (HF_TF_MASK | HF_INHIBIT_IRQ_MASK)) {
59
- oi = make_memop_idx(SHIFT, mmu_idx);
127
+ /*
60
+ TCGMemOpIdx oi = make_memop_idx(op & ~MO_SIGN, mmu_idx);
128
+ * If single step mode, we generate only one instruction and
61
res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX),
129
+ * generate an exception.
62
MMUSUFFIX)(env, addr, oi, retaddr);
130
+ * If irq were inhibited with HF_INHIBIT_IRQ_MASK, we clear
63
} else {
131
+ * the flag and abort the translation to give the irqs a
64
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
132
+ * chance to happen.
65
CPUTLBEntry *entry;
133
+ */
66
target_ulong addr;
134
+ dc->base.is_jmp = DISAS_TOO_MANY;
67
int mmu_idx = CPU_MMU_INDEX;
135
+ } else if (!is_same_page(&dc->base, pc_next)) {
68
- TCGMemOpIdx oi;
136
+ dc->base.is_jmp = DISAS_TOO_MANY;
69
+ MemOp op = MO_TE | SHIFT;
137
+ }
70
#if !defined(SOFTMMU_CODE_ACCESS)
138
+ }
71
- uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true, mmu_idx);
139
}
72
+ uint16_t meminfo = trace_mem_get_info(op, mmu_idx, true);
140
73
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
141
static void i386_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
74
#endif
142
diff --git a/tests/tcg/x86_64/noexec.c b/tests/tcg/x86_64/noexec.c
75
143
new file mode 100644
76
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
144
index XXXXXXX..XXXXXXX
77
entry = tlb_entry(env, mmu_idx, addr);
145
--- /dev/null
78
if (unlikely(tlb_addr_write(entry) !=
146
+++ b/tests/tcg/x86_64/noexec.c
79
(addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
147
@@ -XXX,XX +XXX,XX @@
80
- oi = make_memop_idx(SHIFT, mmu_idx);
148
+#include "../multiarch/noexec.c.inc"
81
+ TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
149
+
82
glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi,
150
+static void *arch_mcontext_pc(const mcontext_t *ctx)
83
retaddr);
151
+{
84
} else {
152
+ return (void *)ctx->gregs[REG_RIP];
85
diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h
153
+}
154
+
155
+int arch_mcontext_arg(const mcontext_t *ctx)
156
+{
157
+ return ctx->gregs[REG_RDI];
158
+}
159
+
160
+static void arch_flush(void *p, int len)
161
+{
162
+}
163
+
164
+extern char noexec_1[];
165
+extern char noexec_2[];
166
+extern char noexec_end[];
167
+
168
+asm("noexec_1:\n"
169
+ " movq $1,%rdi\n" /* %rdi is 0 on entry, set 1. */
170
+ "noexec_2:\n"
171
+ " movq $2,%rdi\n" /* %rdi is 0/1; set 2. */
172
+ " ret\n"
173
+ "noexec_end:");
174
+
175
+int main(void)
176
+{
177
+ struct noexec_test noexec_tests[] = {
178
+ {
179
+ .name = "fallthrough",
180
+ .test_code = noexec_1,
181
+ .test_len = noexec_end - noexec_1,
182
+ .page_ofs = noexec_1 - noexec_2,
183
+ .entry_ofs = noexec_1 - noexec_2,
184
+ .expected_si_ofs = 0,
185
+ .expected_pc_ofs = 0,
186
+ .expected_arg = 1,
187
+ },
188
+ {
189
+ .name = "jump",
190
+ .test_code = noexec_1,
191
+ .test_len = noexec_end - noexec_1,
192
+ .page_ofs = noexec_1 - noexec_2,
193
+ .entry_ofs = 0,
194
+ .expected_si_ofs = 0,
195
+ .expected_pc_ofs = 0,
196
+ .expected_arg = 0,
197
+ },
198
+ {
199
+ .name = "fallthrough [cross]",
200
+ .test_code = noexec_1,
201
+ .test_len = noexec_end - noexec_1,
202
+ .page_ofs = noexec_1 - noexec_2 - 2,
203
+ .entry_ofs = noexec_1 - noexec_2 - 2,
204
+ .expected_si_ofs = 0,
205
+ .expected_pc_ofs = -2,
206
+ .expected_arg = 1,
207
+ },
208
+ {
209
+ .name = "jump [cross]",
210
+ .test_code = noexec_1,
211
+ .test_len = noexec_end - noexec_1,
212
+ .page_ofs = noexec_1 - noexec_2 - 2,
213
+ .entry_ofs = -2,
214
+ .expected_si_ofs = 0,
215
+ .expected_pc_ofs = -2,
216
+ .expected_arg = 0,
217
+ },
218
+ };
219
+
220
+ return test_noexec(noexec_tests,
221
+ sizeof(noexec_tests) / sizeof(noexec_tests[0]));
222
+}
223
diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target
86
index XXXXXXX..XXXXXXX 100644
224
index XXXXXXX..XXXXXXX 100644
87
--- a/include/exec/cpu_ldst_useronly_template.h
225
--- a/tests/tcg/x86_64/Makefile.target
88
+++ b/include/exec/cpu_ldst_useronly_template.h
226
+++ b/tests/tcg/x86_64/Makefile.target
89
@@ -XXX,XX +XXX,XX @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
227
@@ -XXX,XX +XXX,XX @@ include $(SRC_PATH)/tests/tcg/i386/Makefile.target
90
ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
228
91
clear_helper_retaddr();
229
ifeq ($(filter %-linux-user, $(TARGET)),$(TARGET))
92
#else
230
X86_64_TESTS += vsyscall
93
- uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false,
231
+X86_64_TESTS += noexec
94
- MMU_USER_IDX);
232
TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64
95
+ MemOp op = MO_TE | SHIFT;
233
else
96
+ uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
234
TESTS=$(MULTIARCH_TESTS)
97
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
235
@@ -XXX,XX +XXX,XX @@ test-x86_64: LDFLAGS+=-lm -lc
98
ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
236
test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h
99
#endif
237
    $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
100
@@ -XXX,XX +XXX,XX @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
238
101
ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
239
-vsyscall: $(SRC_PATH)/tests/tcg/x86_64/vsyscall.c
102
clear_helper_retaddr();
240
+%: $(SRC_PATH)/tests/tcg/x86_64/%.c
103
#else
241
    $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
104
- uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false,
105
- MMU_USER_IDX);
106
+ MemOp op = MO_TE | MO_SIGN | SHIFT;
107
+ uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
108
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
109
ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
110
qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
111
@@ -XXX,XX +XXX,XX @@ static inline void
112
glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
113
RES_TYPE v)
114
{
115
- uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true,
116
- MMU_USER_IDX);
117
+ MemOp op = MO_TE | SHIFT;
118
+ uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, true);
119
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
120
glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
121
qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
122
--
242
--
123
2.20.1
243
2.34.1
124
125
diff view generated by jsdifflib
1
We don't actually need the result of the read, only to probe that the
1
These will be useful in properly ending the TB.
2
memory mapping exists. This is exactly what probe_access does.
3
2
4
This is also the only user of any cpu_ld*_code_ra function.
3
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
5
Removing this allows the interface to be removed shortly.
4
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
6
5
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
7
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
---
7
---
13
target/xtensa/mmu_helper.c | 5 +++--
8
target/riscv/translate.c | 10 +++++++++-
14
1 file changed, 3 insertions(+), 2 deletions(-)
9
1 file changed, 9 insertions(+), 1 deletion(-)
15
10
16
diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c
11
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
17
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
18
--- a/target/xtensa/mmu_helper.c
13
--- a/target/riscv/translate.c
19
+++ b/target/xtensa/mmu_helper.c
14
+++ b/target/riscv/translate.c
20
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)
21
void HELPER(itlb_hit_test)(CPUXtensaState *env, uint32_t vaddr)
16
/* Include decoders for factored-out extensions */
17
#include "decode-XVentanaCondOps.c.inc"
18
19
+/* The specification allows for longer insns, but not supported by qemu. */
20
+#define MAX_INSN_LEN 4
21
+
22
+static inline int insn_len(uint16_t first_word)
23
+{
24
+ return (first_word & 3) == 3 ? 4 : 2;
25
+}
26
+
27
static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode)
22
{
28
{
23
/*
29
/*
24
- * Attempt the memory load; we don't care about the result but
30
@@ -XXX,XX +XXX,XX @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode)
25
+ * Probe the memory; we don't care about the result but
31
};
26
* only the side-effects (ie any MMU or other exception)
32
27
*/
33
/* Check for compressed insn */
28
- cpu_ldub_code_ra(env, vaddr, GETPC());
34
- if (extract16(opcode, 0, 2) != 3) {
29
+ probe_access(env, vaddr, 1, MMU_INST_FETCH,
35
+ if (insn_len(opcode) == 2) {
30
+ cpu_mmu_index(env, true), GETPC());
36
if (!has_ext(ctx, RVC)) {
31
}
37
gen_exception_illegal(ctx);
32
38
} else {
33
void HELPER(wsr_rasid)(CPUXtensaState *env, uint32_t v)
34
--
39
--
35
2.20.1
40
2.34.1
36
37
diff view generated by jsdifflib
Deleted patch
1
Code movement in an upcoming patch will show that this file
2
was implicitly depending on tcg.h being included indirectly.
3
1
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: David Hildenbrand <david@redhat.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
target/s390x/mem_helper.c | 1 +
10
1 file changed, 1 insertion(+)
11
12
diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/s390x/mem_helper.c
15
+++ b/target/s390x/mem_helper.c
16
@@ -XXX,XX +XXX,XX @@
17
#include "exec/cpu_ldst.h"
18
#include "qemu/int128.h"
19
#include "qemu/atomic128.h"
20
+#include "tcg.h"
21
22
#if !defined(CONFIG_USER_ONLY)
23
#include "hw/s390x/storage-keys.h"
24
--
25
2.20.1
26
27
diff view generated by jsdifflib
Deleted patch
1
Code movement in an upcoming patch will show that this file
2
was implicitly depending on tcg.h being included indirectly.
3
1
4
Cc: Peter Maydell <peter.maydell@linaro.org>
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
target/arm/sve_helper.c | 1 +
10
1 file changed, 1 insertion(+)
11
12
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/sve_helper.c
15
+++ b/target/arm/sve_helper.c
16
@@ -XXX,XX +XXX,XX @@
17
#include "exec/helper-proto.h"
18
#include "tcg/tcg-gvec-desc.h"
19
#include "fpu/softfloat.h"
20
+#include "tcg.h"
21
22
23
/* Note that vector data is stored in host-endian 64-bit chunks,
24
--
25
2.20.1
26
27
diff view generated by jsdifflib
Deleted patch
1
Code movement in an upcoming patch will show that this file
2
was implicitly depending on tcg.h being included indirectly.
3
1
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
8
accel/tcg/tcg-runtime.c | 1 +
9
1 file changed, 1 insertion(+)
10
11
diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/accel/tcg/tcg-runtime.c
14
+++ b/accel/tcg/tcg-runtime.c
15
@@ -XXX,XX +XXX,XX @@
16
#include "exec/tb-lookup.h"
17
#include "disas/disas.h"
18
#include "exec/log.h"
19
+#include "tcg.h"
20
21
/* 32-bit helpers */
22
23
--
24
2.20.1
25
26
diff view generated by jsdifflib
Deleted patch
1
Code movement in an upcoming patch will show that this file
2
was implicitly depending on tcg.h being included indirectly.
3
1
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
linux-user/syscall.c | 1 +
10
1 file changed, 1 insertion(+)
11
12
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/linux-user/syscall.c
15
+++ b/linux-user/syscall.c
16
@@ -XXX,XX +XXX,XX @@
17
#include "user/syscall-trace.h"
18
#include "qapi/error.h"
19
#include "fd-trans.h"
20
+#include "tcg.h"
21
22
#ifndef CLONE_IO
23
#define CLONE_IO 0x80000000 /* Clone io context */
24
--
25
2.20.1
26
27
diff view generated by jsdifflib
Deleted patch
1
Code movement in an upcoming patch will show that this file
2
was implicitly depending on trace-root.h being included beforehand.
3
1
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
include/user/syscall-trace.h | 2 ++
10
1 file changed, 2 insertions(+)
11
12
diff --git a/include/user/syscall-trace.h b/include/user/syscall-trace.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/include/user/syscall-trace.h
15
+++ b/include/user/syscall-trace.h
16
@@ -XXX,XX +XXX,XX @@
17
#ifndef _SYSCALL_TRACE_H_
18
#define _SYSCALL_TRACE_H_
19
20
+#include "trace-root.h"
21
+
22
/*
23
* These helpers just provide a common place for the various
24
* subsystems that want to track syscalls to put their hooks in. We
25
--
26
2.20.1
27
28
diff view generated by jsdifflib
Deleted patch
1
Code movement in an upcoming patch will show that this file
2
was implicitly depending on trace/mem.h being included beforehand.
3
1
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reported-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
plugins/api.c | 1 +
10
1 file changed, 1 insertion(+)
11
12
diff --git a/plugins/api.c b/plugins/api.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/plugins/api.c
15
+++ b/plugins/api.c
16
@@ -XXX,XX +XXX,XX @@
17
#include "qemu/plugin-memory.h"
18
#include "hw/boards.h"
19
#endif
20
+#include "trace/mem.h"
21
22
/* Uninstall and Reset handlers */
23
24
--
25
2.20.1
26
27
diff view generated by jsdifflib
1
This finishes the new interface began with the previous patch.
1
Right now the translator stops right *after* the end of a page, which
2
Document the interface and deprecate MMU_MODE<N>_SUFFIX.
2
breaks reporting of fault locations when the last instruction of a
3
multi-insn translation block crosses a page boundary.
3
4
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1155
5
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
8
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
10
---
9
include/exec/cpu_ldst.h | 80 +++++++++++++-
11
target/riscv/translate.c | 17 +++++--
10
docs/devel/loads-stores.rst | 211 ++++++++++++++++++++++++++----------
12
tests/tcg/riscv64/noexec.c | 79 +++++++++++++++++++++++++++++++
11
2 files changed, 230 insertions(+), 61 deletions(-)
13
tests/tcg/riscv64/Makefile.target | 1 +
14
3 files changed, 93 insertions(+), 4 deletions(-)
15
create mode 100644 tests/tcg/riscv64/noexec.c
12
16
13
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
17
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
14
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
15
--- a/include/exec/cpu_ldst.h
19
--- a/target/riscv/translate.c
16
+++ b/include/exec/cpu_ldst.h
20
+++ b/target/riscv/translate.c
21
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
22
}
23
ctx->nftemp = 0;
24
25
+ /* Only the first insn within a TB is allowed to cross a page boundary. */
26
if (ctx->base.is_jmp == DISAS_NEXT) {
27
- target_ulong page_start;
28
-
29
- page_start = ctx->base.pc_first & TARGET_PAGE_MASK;
30
- if (ctx->base.pc_next - page_start >= TARGET_PAGE_SIZE) {
31
+ if (!is_same_page(&ctx->base, ctx->base.pc_next)) {
32
ctx->base.is_jmp = DISAS_TOO_MANY;
33
+ } else {
34
+ unsigned page_ofs = ctx->base.pc_next & ~TARGET_PAGE_MASK;
35
+
36
+ if (page_ofs > TARGET_PAGE_SIZE - MAX_INSN_LEN) {
37
+ uint16_t next_insn = cpu_lduw_code(env, ctx->base.pc_next);
38
+ int len = insn_len(next_insn);
39
+
40
+ if (!is_same_page(&ctx->base, ctx->base.pc_next + len)) {
41
+ ctx->base.is_jmp = DISAS_TOO_MANY;
42
+ }
43
+ }
44
}
45
}
46
}
47
diff --git a/tests/tcg/riscv64/noexec.c b/tests/tcg/riscv64/noexec.c
48
new file mode 100644
49
index XXXXXXX..XXXXXXX
50
--- /dev/null
51
+++ b/tests/tcg/riscv64/noexec.c
17
@@ -XXX,XX +XXX,XX @@
52
@@ -XXX,XX +XXX,XX @@
18
*
53
+#include "../multiarch/noexec.c.inc"
19
* The syntax for the accessors is:
20
*
21
- * load: cpu_ld{sign}{size}_{mmusuffix}(env, ptr)
22
+ * load: cpu_ld{sign}{size}_{mmusuffix}(env, ptr)
23
+ * cpu_ld{sign}{size}_{mmusuffix}_ra(env, ptr, retaddr)
24
+ * cpu_ld{sign}{size}_mmuidx_ra(env, ptr, mmu_idx, retaddr)
25
*
26
- * store: cpu_st{sign}{size}_{mmusuffix}(env, ptr, val)
27
+ * store: cpu_st{size}_{mmusuffix}(env, ptr, val)
28
+ * cpu_st{size}_{mmusuffix}_ra(env, ptr, val, retaddr)
29
+ * cpu_st{size}_mmuidx_ra(env, ptr, val, mmu_idx, retaddr)
30
*
31
* sign is:
32
* (empty): for 32 and 64 bit sizes
33
@@ -XXX,XX +XXX,XX @@
34
* l: 32 bits
35
* q: 64 bits
36
*
37
- * mmusuffix is one of the generic suffixes "data" or "code", or
38
- * (for softmmu configs) a target-specific MMU mode suffix as defined
39
- * in target cpu.h.
40
+ * mmusuffix is one of the generic suffixes "data" or "code", or "mmuidx".
41
+ * The "mmuidx" suffix carries an extra mmu_idx argument that specifies
42
+ * the index to use; the "data" and "code" suffixes take the index from
43
+ * cpu_mmu_index().
44
*/
45
#ifndef CPU_LDST_H
46
#define CPU_LDST_H
47
@@ -XXX,XX +XXX,XX @@ static inline void clear_helper_retaddr(void)
48
#undef MEMSUFFIX
49
#undef CODE_ACCESS
50
51
+/*
52
+ * Provide the same *_mmuidx_ra interface as for softmmu.
53
+ * The mmu_idx argument is ignored.
54
+ */
55
+
54
+
56
+static inline uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
55
+static void *arch_mcontext_pc(const mcontext_t *ctx)
57
+ int mmu_idx, uintptr_t ra)
58
+{
56
+{
59
+ return cpu_ldub_data_ra(env, addr, ra);
57
+ return (void *)ctx->__gregs[REG_PC];
60
+}
58
+}
61
+
59
+
62
+static inline uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
60
+static int arch_mcontext_arg(const mcontext_t *ctx)
63
+ int mmu_idx, uintptr_t ra)
64
+{
61
+{
65
+ return cpu_lduw_data_ra(env, addr, ra);
62
+ return ctx->__gregs[REG_A0];
66
+}
63
+}
67
+
64
+
68
+static inline uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
65
+static void arch_flush(void *p, int len)
69
+ int mmu_idx, uintptr_t ra)
70
+{
66
+{
71
+ return cpu_ldl_data_ra(env, addr, ra);
67
+ __builtin___clear_cache(p, p + len);
72
+}
68
+}
73
+
69
+
74
+static inline uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
70
+extern char noexec_1[];
75
+ int mmu_idx, uintptr_t ra)
71
+extern char noexec_2[];
72
+extern char noexec_end[];
73
+
74
+asm(".option push\n"
75
+ ".option norvc\n"
76
+ "noexec_1:\n"
77
+ " li a0,1\n" /* a0 is 0 on entry, set 1. */
78
+ "noexec_2:\n"
79
+ " li a0,2\n" /* a0 is 0/1; set 2. */
80
+ " ret\n"
81
+ "noexec_end:\n"
82
+ ".option pop");
83
+
84
+int main(void)
76
+{
85
+{
77
+ return cpu_ldq_data_ra(env, addr, ra);
86
+ struct noexec_test noexec_tests[] = {
87
+ {
88
+ .name = "fallthrough",
89
+ .test_code = noexec_1,
90
+ .test_len = noexec_end - noexec_1,
91
+ .page_ofs = noexec_1 - noexec_2,
92
+ .entry_ofs = noexec_1 - noexec_2,
93
+ .expected_si_ofs = 0,
94
+ .expected_pc_ofs = 0,
95
+ .expected_arg = 1,
96
+ },
97
+ {
98
+ .name = "jump",
99
+ .test_code = noexec_1,
100
+ .test_len = noexec_end - noexec_1,
101
+ .page_ofs = noexec_1 - noexec_2,
102
+ .entry_ofs = 0,
103
+ .expected_si_ofs = 0,
104
+ .expected_pc_ofs = 0,
105
+ .expected_arg = 0,
106
+ },
107
+ {
108
+ .name = "fallthrough [cross]",
109
+ .test_code = noexec_1,
110
+ .test_len = noexec_end - noexec_1,
111
+ .page_ofs = noexec_1 - noexec_2 - 2,
112
+ .entry_ofs = noexec_1 - noexec_2 - 2,
113
+ .expected_si_ofs = 0,
114
+ .expected_pc_ofs = -2,
115
+ .expected_arg = 1,
116
+ },
117
+ {
118
+ .name = "jump [cross]",
119
+ .test_code = noexec_1,
120
+ .test_len = noexec_end - noexec_1,
121
+ .page_ofs = noexec_1 - noexec_2 - 2,
122
+ .entry_ofs = -2,
123
+ .expected_si_ofs = 0,
124
+ .expected_pc_ofs = -2,
125
+ .expected_arg = 0,
126
+ },
127
+ };
128
+
129
+ return test_noexec(noexec_tests,
130
+ sizeof(noexec_tests) / sizeof(noexec_tests[0]));
78
+}
131
+}
79
+
132
diff --git a/tests/tcg/riscv64/Makefile.target b/tests/tcg/riscv64/Makefile.target
80
+static inline int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
81
+ int mmu_idx, uintptr_t ra)
82
+{
83
+ return cpu_ldsb_data_ra(env, addr, ra);
84
+}
85
+
86
+static inline int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
87
+ int mmu_idx, uintptr_t ra)
88
+{
89
+ return cpu_ldsw_data_ra(env, addr, ra);
90
+}
91
+
92
+static inline void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
93
+ uint32_t val, int mmu_idx, uintptr_t ra)
94
+{
95
+ cpu_stb_data_ra(env, addr, val, ra);
96
+}
97
+
98
+static inline void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
99
+ uint32_t val, int mmu_idx, uintptr_t ra)
100
+{
101
+ cpu_stw_data_ra(env, addr, val, ra);
102
+}
103
+
104
+static inline void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
105
+ uint32_t val, int mmu_idx, uintptr_t ra)
106
+{
107
+ cpu_stl_data_ra(env, addr, val, ra);
108
+}
109
+
110
+static inline void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
111
+ uint64_t val, int mmu_idx, uintptr_t ra)
112
+{
113
+ cpu_stq_data_ra(env, addr, val, ra);
114
+}
115
+
116
#else
117
118
/* Needed for TCG_OVERSIZED_GUEST */
119
diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst
120
index XXXXXXX..XXXXXXX 100644
133
index XXXXXXX..XXXXXXX 100644
121
--- a/docs/devel/loads-stores.rst
134
--- a/tests/tcg/riscv64/Makefile.target
122
+++ b/docs/devel/loads-stores.rst
135
+++ b/tests/tcg/riscv64/Makefile.target
123
@@ -XXX,XX +XXX,XX @@ Regexes for git grep
136
@@ -XXX,XX +XXX,XX @@
124
- ``\<ldn_\([hbl]e\)?_p\>``
137
125
- ``\<stn_\([hbl]e\)?_p\>``
138
VPATH += $(SRC_PATH)/tests/tcg/riscv64
126
139
TESTS += test-div
127
-``cpu_{ld,st}_*``
140
+TESTS += noexec
128
-~~~~~~~~~~~~~~~~~
129
+``cpu_{ld,st}*_mmuidx_ra``
130
+~~~~~~~~~~~~~~~~~~~~~~~~~~
131
132
-These functions operate on a guest virtual address. Be aware
133
-that these functions may cause a guest CPU exception to be
134
-taken (e.g. for an alignment fault or MMU fault) which will
135
-result in guest CPU state being updated and control longjumping
136
-out of the function call. They should therefore only be used
137
-in code that is implementing emulation of the target CPU.
138
+These functions operate on a guest virtual address plus a context,
139
+known as a "mmu index" or ``mmuidx``, which controls how that virtual
140
+address is translated. The meaning of the indexes are target specific,
141
+but specifying a particular index might be necessary if, for instance,
142
+the helper requires an "always as non-privileged" access rather that
143
+the default access for the current state of the guest CPU.
144
145
-These functions may throw an exception (longjmp() back out
146
-to the top level TCG loop). This means they must only be used
147
-from helper functions where the translator has saved all
148
-necessary CPU state before generating the helper function call.
149
-It's usually better to use the ``_ra`` variants described below
150
-from helper functions, but these functions are the right choice
151
-for calls made from hooks like the CPU do_interrupt hook or
152
-when you know for certain that the translator had to save all
153
-the CPU state that ``cpu_restore_state()`` would restore anyway.
154
+These functions may cause a guest CPU exception to be taken
155
+(e.g. for an alignment fault or MMU fault) which will result in
156
+guest CPU state being updated and control longjmp'ing out of the
157
+function call. They should therefore only be used in code that is
158
+implementing emulation of the guest CPU.
159
+
160
+The ``retaddr`` parameter is used to control unwinding of the
161
+guest CPU state in case of a guest CPU exception. This is passed
162
+to ``cpu_restore_state()``. Therefore the value should either be 0,
163
+to indicate that the guest CPU state is already synchronized, or
164
+the result of ``GETPC()`` from the top level ``HELPER(foo)``
165
+function, which is a return address into the generated code.
166
167
Function names follow the pattern:
168
169
-load: ``cpu_ld{sign}{size}_{mmusuffix}(env, ptr)``
170
+load: ``cpu_ld{sign}{size}_mmuidx_ra(env, ptr, mmuidx, retaddr)``
171
172
-store: ``cpu_st{size}_{mmusuffix}(env, ptr, val)``
173
+store: ``cpu_st{size}_mmuidx_ra(env, ptr, val, mmuidx, retaddr)``
174
175
``sign``
176
- (empty) : for 32 or 64 bit sizes
177
@@ -XXX,XX +XXX,XX @@ store: ``cpu_st{size}_{mmusuffix}(env, ptr, val)``
178
- ``l`` : 32 bits
179
- ``q`` : 64 bits
180
181
-``mmusuffix`` is one of the generic suffixes ``data`` or ``code``, or
182
-(for softmmu configs) a target-specific MMU mode suffix as defined
183
-in the target's ``cpu.h``.
184
+Regexes for git grep:
185
+ - ``\<cpu_ld[us]\?[bwlq]_mmuidx_ra\>``
186
+ - ``\<cpu_st[bwlq]_mmuidx_ra\>``
187
188
-Regexes for git grep
189
- - ``\<cpu_ld[us]\?[bwlq]_[a-zA-Z0-9]\+\>``
190
- - ``\<cpu_st[bwlq]_[a-zA-Z0-9]\+\>``
191
+``cpu_{ld,st}*_data_ra``
192
+~~~~~~~~~~~~~~~~~~~~~~~~
193
194
-``cpu_{ld,st}_*_ra``
195
-~~~~~~~~~~~~~~~~~~~~
196
-
197
-These functions work like the ``cpu_{ld,st}_*`` functions except
198
-that they also take a ``retaddr`` argument. This extra argument
199
-allows for correct unwinding of any exception that is taken,
200
-and should generally be the result of GETPC() called directly
201
-from the top level HELPER(foo) function (i.e. the return address
202
-in the generated code).
203
+These functions work like the ``cpu_{ld,st}_mmuidx_ra`` functions
204
+except that the ``mmuidx`` parameter is taken from the current mode
205
+of the guest CPU, as determined by ``cpu_mmu_index(env, false)``.
206
207
These are generally the preferred way to do accesses by guest
208
-virtual address from helper functions; see the documentation
209
-of the non-``_ra`` variants for when those would be better.
210
-
211
-Calling these functions with a ``retaddr`` argument of 0 is
212
-equivalent to calling the non-``_ra`` version of the function.
213
+virtual address from helper functions, unless the access should
214
+be performed with a context other than the default.
215
216
Function names follow the pattern:
217
218
-load: ``cpu_ld{sign}{size}_{mmusuffix}_ra(env, ptr, retaddr)``
219
+load: ``cpu_ld{sign}{size}_data_ra(env, ptr, ra)``
220
221
-store: ``cpu_st{sign}{size}_{mmusuffix}_ra(env, ptr, val, retaddr)``
222
+store: ``cpu_st{size}_data_ra(env, ptr, val, ra)``
223
+
224
+``sign``
225
+ - (empty) : for 32 or 64 bit sizes
226
+ - ``u`` : unsigned
227
+ - ``s`` : signed
228
+
229
+``size``
230
+ - ``b`` : 8 bits
231
+ - ``w`` : 16 bits
232
+ - ``l`` : 32 bits
233
+ - ``q`` : 64 bits
234
+
235
+Regexes for git grep:
236
+ - ``\<cpu_ld[us]\?[bwlq]_data_ra\>``
237
+ - ``\<cpu_st[bwlq]_data_ra\>``
238
+
239
+``cpu_{ld,st}*_data``
240
+~~~~~~~~~~~~~~~~~~~~~
241
+
242
+These functions work like the ``cpu_{ld,st}_data_ra`` functions
243
+except that the ``retaddr`` parameter is 0, and thus does not
244
+unwind guest CPU state.
245
+
246
+This means they must only be used from helper functions where the
247
+translator has saved all necessary CPU state. These functions are
248
+the right choice for calls made from hooks like the CPU ``do_interrupt``
249
+hook or when you know for certain that the translator had to save all
250
+the CPU state anyway.
251
+
252
+Function names follow the pattern:
253
+
254
+load: ``cpu_ld{sign}{size}_data(env, ptr)``
255
+
256
+store: ``cpu_st{size}_data(env, ptr, val)``
257
+
258
+``sign``
259
+ - (empty) : for 32 or 64 bit sizes
260
+ - ``u`` : unsigned
261
+ - ``s`` : signed
262
+
263
+``size``
264
+ - ``b`` : 8 bits
265
+ - ``w`` : 16 bits
266
+ - ``l`` : 32 bits
267
+ - ``q`` : 64 bits
268
269
Regexes for git grep
270
- - ``\<cpu_ld[us]\?[bwlq]_[a-zA-Z0-9]\+_ra\>``
271
- - ``\<cpu_st[bwlq]_[a-zA-Z0-9]\+_ra\>``
272
+ - ``\<cpu_ld[us]\?[bwlq]_data\>``
273
+ - ``\<cpu_st[bwlq]_data\+\>``
274
275
-``helper_*_{ld,st}*mmu``
276
-~~~~~~~~~~~~~~~~~~~~~~~~
277
+``cpu_ld*_code``
278
+~~~~~~~~~~~~~~~~
279
+
280
+These functions perform a read for instruction execution. The ``mmuidx``
281
+parameter is taken from the current mode of the guest CPU, as determined
282
+by ``cpu_mmu_index(env, true)``. The ``retaddr`` parameter is 0, and
283
+thus does not unwind guest CPU state, because CPU state is always
284
+synchronized while translating instructions. Any guest CPU exception
285
+that is raised will indicate an instruction execution fault rather than
286
+a data read fault.
287
+
288
+In general these functions should not be used directly during translation.
289
+There are wrapper functions that are to be used which also take care of
290
+plugins for tracing.
291
+
292
+Function names follow the pattern:
293
+
294
+load: ``cpu_ld{sign}{size}_code(env, ptr)``
295
+
296
+``sign``
297
+ - (empty) : for 32 or 64 bit sizes
298
+ - ``u`` : unsigned
299
+ - ``s`` : signed
300
+
301
+``size``
302
+ - ``b`` : 8 bits
303
+ - ``w`` : 16 bits
304
+ - ``l`` : 32 bits
305
+ - ``q`` : 64 bits
306
+
307
+Regexes for git grep:
308
+ - ``\<cpu_ld[us]\?[bwlq]_code\>``
309
+
310
+``translator_ld*``
311
+~~~~~~~~~~~~~~~~~~
312
+
313
+These functions are a wrapper for ``cpu_ld*_code`` which also perform
314
+any actions required by any tracing plugins. They are only to be
315
+called during the translator callback ``translate_insn``.
316
+
317
+There is a set of functions ending in ``_swap`` which, if the parameter
318
+is true, returns the value in the endianness that is the reverse of
319
+the guest native endianness, as determined by ``TARGET_WORDS_BIGENDIAN``.
320
+
321
+Function names follow the pattern:
322
+
323
+load: ``translator_ld{sign}{size}(env, ptr)``
324
+
325
+swap: ``translator_ld{sign}{size}_swap(env, ptr, swap)``
326
+
327
+``sign``
328
+ - (empty) : for 32 or 64 bit sizes
329
+ - ``u`` : unsigned
330
+ - ``s`` : signed
331
+
332
+``size``
333
+ - ``b`` : 8 bits
334
+ - ``w`` : 16 bits
335
+ - ``l`` : 32 bits
336
+ - ``q`` : 64 bits
337
+
338
+Regexes for git grep
339
+ - ``\<translator_ld[us]\?[bwlq]\(_swap\)\?\>``
340
+
341
+``helper_*_{ld,st}*_mmu``
342
+~~~~~~~~~~~~~~~~~~~~~~~~~
343
344
These functions are intended primarily to be called by the code
345
generated by the TCG backend. They may also be called by target
346
-CPU helper function code. Like the ``cpu_{ld,st}_*_ra`` functions
347
-they perform accesses by guest virtual address; the difference is
348
-that these functions allow you to specify an ``opindex`` parameter
349
-which encodes (among other things) the mmu index to use for the
350
-access. This is necessary if your helper needs to make an access
351
-via a specific mmu index (for instance, an "always as non-privileged"
352
-access) rather than using the default mmu index for the current state
353
-of the guest CPU.
354
+CPU helper function code. Like the ``cpu_{ld,st}_mmuidx_ra`` functions
355
+they perform accesses by guest virtual address, with a given ``mmuidx``.
356
357
-The ``opindex`` parameter should be created by calling ``make_memop_idx()``.
358
+These functions specify an ``opindex`` parameter which encodes
359
+(among other things) the mmu index to use for the access. This parameter
360
+should be created by calling ``make_memop_idx()``.
361
362
The ``retaddr`` parameter should be the result of GETPC() called directly
363
from the top level HELPER(foo) function (or 0 if no guest CPU state
364
@@ -XXX,XX +XXX,XX @@ unwinding is required).
365
366
**TODO** The names of these functions are a bit odd for historical
367
reasons because they were originally expected to be called only from
368
-within generated code. We should rename them to bring them
369
-more in line with the other memory access functions.
370
+within generated code. We should rename them to bring them more in
371
+line with the other memory access functions. The explicit endianness
372
+is the only feature they have beyond ``*_mmuidx_ra``.
373
374
load: ``helper_{endian}_ld{sign}{size}_mmu(env, addr, opindex, retaddr)``
375
376
--
141
--
377
2.20.1
142
2.34.1
378
379
diff view generated by jsdifflib
Deleted patch
1
Do not use exec/cpu_ldst_{,useronly_}template.h directly,
2
but instead use the functional interface.
3
1
4
Cc: Eduardo Habkost <ehabkost@redhat.com>
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
10
target/i386/seg_helper.c | 56 ++++++++++++++++++++--------------------
11
1 file changed, 28 insertions(+), 28 deletions(-)
12
13
diff --git a/target/i386/seg_helper.c b/target/i386/seg_helper.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/i386/seg_helper.c
16
+++ b/target/i386/seg_helper.c
17
@@ -XXX,XX +XXX,XX @@
18
# define LOG_PCALL_STATE(cpu) do { } while (0)
19
#endif
20
21
-#ifdef CONFIG_USER_ONLY
22
-#define MEMSUFFIX _kernel
23
-#define DATA_SIZE 1
24
-#include "exec/cpu_ldst_useronly_template.h"
25
+/*
26
+ * TODO: Convert callers to compute cpu_mmu_index_kernel once
27
+ * and use *_mmuidx_ra directly.
28
+ */
29
+#define cpu_ldub_kernel_ra(e, p, r) \
30
+ cpu_ldub_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
31
+#define cpu_lduw_kernel_ra(e, p, r) \
32
+ cpu_lduw_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
33
+#define cpu_ldl_kernel_ra(e, p, r) \
34
+ cpu_ldl_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
35
+#define cpu_ldq_kernel_ra(e, p, r) \
36
+ cpu_ldq_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
37
38
-#define DATA_SIZE 2
39
-#include "exec/cpu_ldst_useronly_template.h"
40
+#define cpu_stb_kernel_ra(e, p, v, r) \
41
+ cpu_stb_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
42
+#define cpu_stw_kernel_ra(e, p, v, r) \
43
+ cpu_stw_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
44
+#define cpu_stl_kernel_ra(e, p, v, r) \
45
+ cpu_stl_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
46
+#define cpu_stq_kernel_ra(e, p, v, r) \
47
+ cpu_stq_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
48
49
-#define DATA_SIZE 4
50
-#include "exec/cpu_ldst_useronly_template.h"
51
+#define cpu_ldub_kernel(e, p) cpu_ldub_kernel_ra(e, p, 0)
52
+#define cpu_lduw_kernel(e, p) cpu_lduw_kernel_ra(e, p, 0)
53
+#define cpu_ldl_kernel(e, p) cpu_ldl_kernel_ra(e, p, 0)
54
+#define cpu_ldq_kernel(e, p) cpu_ldq_kernel_ra(e, p, 0)
55
56
-#define DATA_SIZE 8
57
-#include "exec/cpu_ldst_useronly_template.h"
58
-#undef MEMSUFFIX
59
-#else
60
-#define CPU_MMU_INDEX (cpu_mmu_index_kernel(env))
61
-#define MEMSUFFIX _kernel
62
-#define DATA_SIZE 1
63
-#include "exec/cpu_ldst_template.h"
64
-
65
-#define DATA_SIZE 2
66
-#include "exec/cpu_ldst_template.h"
67
-
68
-#define DATA_SIZE 4
69
-#include "exec/cpu_ldst_template.h"
70
-
71
-#define DATA_SIZE 8
72
-#include "exec/cpu_ldst_template.h"
73
-#undef CPU_MMU_INDEX
74
-#undef MEMSUFFIX
75
-#endif
76
+#define cpu_stb_kernel(e, p, v) cpu_stb_kernel_ra(e, p, v, 0)
77
+#define cpu_stw_kernel(e, p, v) cpu_stw_kernel_ra(e, p, v, 0)
78
+#define cpu_stl_kernel(e, p, v) cpu_stl_kernel_ra(e, p, v, 0)
79
+#define cpu_stq_kernel(e, p, v) cpu_stq_kernel_ra(e, p, v, 0)
80
81
/* return non zero if error */
82
static inline int load_segment_ra(CPUX86State *env, uint32_t *e1_ptr,
83
--
84
2.20.1
85
86
diff view generated by jsdifflib
Deleted patch
1
The functions generated by these macros are unused.
2
1
3
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
target/alpha/cpu.h | 2 --
8
1 file changed, 2 deletions(-)
9
10
diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/alpha/cpu.h
13
+++ b/target/alpha/cpu.h
14
@@ -XXX,XX +XXX,XX @@ enum {
15
PALcode cheats and usees the KSEG mapping for its code+data rather than
16
physical addresses. */
17
18
-#define MMU_MODE0_SUFFIX _kernel
19
-#define MMU_MODE1_SUFFIX _user
20
#define MMU_KERNEL_IDX 0
21
#define MMU_USER_IDX 1
22
#define MMU_PHYS_IDX 2
23
--
24
2.20.1
25
26
diff view generated by jsdifflib
Deleted patch
1
The functions generated by these macros are unused.
2
1
3
Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
8
target/cris/cpu.h | 2 --
9
1 file changed, 2 deletions(-)
10
11
diff --git a/target/cris/cpu.h b/target/cris/cpu.h
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/cris/cpu.h
14
+++ b/target/cris/cpu.h
15
@@ -XXX,XX +XXX,XX @@ enum {
16
#define cpu_signal_handler cpu_cris_signal_handler
17
18
/* MMU modes definitions */
19
-#define MMU_MODE0_SUFFIX _kernel
20
-#define MMU_MODE1_SUFFIX _user
21
#define MMU_USER_IDX 1
22
static inline int cpu_mmu_index (CPUCRISState *env, bool ifetch)
23
{
24
--
25
2.20.1
26
27
diff view generated by jsdifflib
Deleted patch
1
The functions generated by these macros are unused.
2
1
3
Cc: Eduardo Habkost <ehabkost@redhat.com>
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
target/i386/cpu.h | 3 ---
10
1 file changed, 3 deletions(-)
11
12
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/i386/cpu.h
15
+++ b/target/i386/cpu.h
16
@@ -XXX,XX +XXX,XX @@ uint64_t cpu_get_tsc(CPUX86State *env);
17
#define cpu_list x86_cpu_list
18
19
/* MMU modes definitions */
20
-#define MMU_MODE0_SUFFIX _ksmap
21
-#define MMU_MODE1_SUFFIX _user
22
-#define MMU_MODE2_SUFFIX _knosmap /* SMAP disabled or CPL<3 && AC=1 */
23
#define MMU_KSMAP_IDX 0
24
#define MMU_USER_IDX 1
25
#define MMU_KNOSMAP_IDX 2
26
--
27
2.20.1
28
29
diff view generated by jsdifflib
Deleted patch
1
The functions generated by these macros are unused.
2
1
3
Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
8
target/microblaze/cpu.h | 3 ---
9
1 file changed, 3 deletions(-)
10
11
diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/microblaze/cpu.h
14
+++ b/target/microblaze/cpu.h
15
@@ -XXX,XX +XXX,XX @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
16
#define cpu_signal_handler cpu_mb_signal_handler
17
18
/* MMU modes definitions */
19
-#define MMU_MODE0_SUFFIX _nommu
20
-#define MMU_MODE1_SUFFIX _kernel
21
-#define MMU_MODE2_SUFFIX _user
22
#define MMU_NOMMU_IDX 0
23
#define MMU_KERNEL_IDX 1
24
#define MMU_USER_IDX 2
25
--
26
2.20.1
27
28
diff view generated by jsdifflib