1
Mini PR, aimed at fixing the mips and ovmf regressions.
1
v2: Fix bsd-user signal.c Werror.
2
I've conformed that it merges well with Warner's bsd-user pull.
2
3
3
4
4
r~
5
r~
5
6
6
The following changes since commit 36e9aab3c569d4c9ad780473596e18479838d1aa:
7
7
8
The following changes since commit da1034094d375afe9e3d8ec8980550ea0f06f7e0:
8
migration: Move return path cleanup to main migration thread (2023-09-27 13:58:02 -0400)
9
10
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-10-03 07:43:44 -0400)
9
11
10
are available in the Git repository at:
12
are available in the Git repository at:
11
13
12
https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20230928
14
https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20231004
13
15
14
for you to fetch changes up to 18a536f1f8d6222e562f59179e837fdfd8b92718:
16
for you to fetch changes up to 79de3960ae1e322835112755d99187ee9b63a270:
15
17
16
accel/tcg: Always require can_do_io (2023-09-28 10:08:13 -0700)
18
tcg/loongarch64: Fix buid error (2023-10-04 11:03:54 -0700)
17
19
18
----------------------------------------------------------------
20
----------------------------------------------------------------
19
accel/tcg: Always require can_do_io, for #1866
21
accel: Introduce AccelClass::cpu_common_[un]realize
22
accel: Target agnostic code movement
23
accel/tcg: Cleanups to use CPUState instead of CPUArchState
24
accel/tcg: Move CPUNegativeOffsetState into CPUState
25
tcg: Split out tcg init functions to tcg/startup.h
26
linux-user/hppa: Fix struct target_sigcontext layout
27
build: Remove --enable-gprof
20
28
21
----------------------------------------------------------------
29
----------------------------------------------------------------
22
Richard Henderson (6):
30
Anton Johansson (9):
23
accel/tcg: Avoid load of icount_decr if unused
31
target/arm: Replace TARGET_PAGE_ENTRY_EXTRA
24
accel/tcg: Hoist CF_MEMI_ONLY check outside translation loop
32
accel/tcg: Modify tlb_*() to use CPUState
25
accel/tcg: Track current value of can_do_io in the TB
33
accel/tcg: Modify probe_access_internal() to use CPUState
26
accel/tcg: Improve setting of can_do_io at start of TB
34
accel/tcg: Modify memory access functions to use CPUState
27
accel/tcg: Always set CF_LAST_IO with CF_NOIRQ
35
accel/tcg: Modify atomic_mmu_lookup() to use CPUState
28
accel/tcg: Always require can_do_io
36
accel/tcg: Use CPUState in atomicity helpers
29
37
accel/tcg: Remove env_tlb()
30
include/exec/translator.h | 2 ++
38
accel/tcg: Unify user and softmmu do_[st|ld]*_mmu()
31
accel/tcg/cpu-exec.c | 2 +-
39
accel/tcg: move ld/st helpers to ldst_common.c.inc
32
accel/tcg/tb-maint.c | 6 ++--
40
33
accel/tcg/translator.c | 72 +++++++++++++++++++++------------------------
41
Philippe Mathieu-Daudé (19):
34
target/mips/tcg/translate.c | 1 -
42
accel: Rename accel_cpu_realizefn() -> accel_cpu_realize()
35
5 files changed, 41 insertions(+), 42 deletions(-)
43
accel: Rename AccelCPUClass::cpu_realizefn() -> cpu_target_realize()
44
accel: Rename accel_cpu_realize() -> accel_cpu_common_realize()
45
accel: Introduce accel_cpu_common_unrealize() stub
46
accel: Declare AccelClass::cpu_common_[un]realize() handlers
47
accel/tcg: Have tcg_exec_realizefn() return a boolean
48
accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG
49
exec: Make EXCP_FOO definitions target agnostic
50
exec: Move cpu_loop_foo() target agnostic functions to 'cpu-common.h'
51
accel/tcg: Restrict dump_exec_info() declaration
52
accel: Make accel-blocker.o target agnostic
53
accel: Rename accel-common.c -> accel-target.c
54
exec: Rename cpu.c -> cpu-target.c
55
exec: Rename target specific page-vary.c -> page-vary-target.c
56
accel/tcg: Rename target-specific 'internal.h' -> 'internal-target.h'
57
accel/tcg: Make monitor.c a target-agnostic unit
58
accel/tcg: Make icount.o a target agnostic unit
59
accel/tcg: Make cpu-exec-common.c a target agnostic unit
60
tests/avocado: Re-enable MIPS Malta tests (GitLab issue #1884 fixed)
61
62
Richard Henderson (18):
63
accel/tcg: Move CPUTLB definitions from cpu-defs.h
64
qom: Propagate alignment through type system
65
target/arm: Remove size and alignment for cpu subclasses
66
target/*: Add instance_align to all cpu base classes
67
accel/tcg: Validate placement of CPUNegativeOffsetState
68
accel/tcg: Move CPUNegativeOffsetState into CPUState
69
accel/tcg: Remove CPUState.icount_decr_ptr
70
accel/tcg: Move can_do_io to CPUNegativeOffsetState
71
accel/tcg: Remove cpu_neg()
72
tcg: Rename cpu_env to tcg_env
73
accel/tcg: Replace CPUState.env_ptr with cpu_env()
74
accel/tcg: Remove cpu_set_cpustate_pointers
75
accel/tcg: Remove env_neg()
76
tcg: Remove TCGContext.tlb_fast_offset
77
tcg: Remove argument to tcg_prologue_init
78
tcg: Split out tcg init functions to tcg/startup.h
79
linux-user/hppa: Fix struct target_sigcontext layout
80
build: Remove --enable-gprof
81
82
gaosong (1):
83
tcg/loongarch64: Fix buid error
84
85
MAINTAINERS | 7 +-
86
docs/about/deprecated.rst | 14 -
87
meson.build | 18 +-
88
accel/tcg/atomic_template.h | 20 +-
89
accel/tcg/internal-common.h | 28 +
90
accel/tcg/{internal.h => internal-target.h} | 21 +-
91
bsd-user/bsd-proc.h | 3 -
92
include/exec/cpu-all.h | 67 +-
93
include/exec/cpu-common.h | 39 +
94
include/exec/cpu-defs.h | 138 ---
95
include/exec/cpu_ldst.h | 8 +-
96
include/exec/exec-all.h | 32 +-
97
include/hw/core/accel-cpu.h | 2 +-
98
include/hw/core/cpu.h | 171 ++-
99
include/qemu/accel.h | 12 +-
100
include/tcg/startup.h | 58 +
101
include/tcg/tcg.h | 6 +-
102
target/alpha/cpu.h | 1 -
103
target/arm/common-semi-target.h | 2 +-
104
target/arm/cpu-param.h | 12 -
105
target/arm/cpu.h | 1 -
106
target/arm/tcg/translate-a32.h | 2 +-
107
target/arm/tcg/translate-a64.h | 4 +-
108
target/arm/tcg/translate.h | 16 +-
109
target/avr/cpu.h | 1 -
110
target/cris/cpu.h | 1 -
111
target/hexagon/cpu.h | 2 +-
112
target/hexagon/gen_tcg.h | 120 +-
113
target/hexagon/gen_tcg_hvx.h | 20 +-
114
target/hexagon/macros.h | 8 +-
115
target/hppa/cpu.h | 1 -
116
target/i386/cpu.h | 1 -
117
target/loongarch/cpu.h | 1 -
118
target/m68k/cpu.h | 1 -
119
target/microblaze/cpu.h | 6 +-
120
target/mips/cpu.h | 4 +-
121
target/mips/tcg/translate.h | 6 +-
122
target/nios2/cpu.h | 1 -
123
target/openrisc/cpu.h | 1 -
124
target/ppc/cpu.h | 1 -
125
target/riscv/cpu.h | 2 +-
126
target/rx/cpu.h | 1 -
127
target/s390x/cpu.h | 1 -
128
target/sh4/cpu.h | 1 -
129
target/sparc/cpu.h | 1 -
130
target/tricore/cpu.h | 1 -
131
target/xtensa/cpu.h | 3 +-
132
accel/{accel-common.c => accel-target.c} | 27 +-
133
accel/dummy-cpus.c | 2 +-
134
accel/hvf/hvf-accel-ops.c | 2 +-
135
accel/kvm/kvm-accel-ops.c | 2 +-
136
accel/tcg/cpu-exec-common.c | 5 +-
137
accel/tcg/cpu-exec.c | 31 +-
138
accel/tcg/cputlb.c | 787 +++++-------
139
softmmu/icount.c => accel/tcg/icount-common.c | 7 +-
140
accel/tcg/monitor.c | 2 +-
141
accel/tcg/plugin-gen.c | 10 +-
142
accel/tcg/tb-maint.c | 3 +-
143
accel/tcg/tcg-accel-ops-icount.c | 8 +-
144
accel/tcg/tcg-accel-ops-mttcg.c | 4 +-
145
accel/tcg/tcg-accel-ops-rr.c | 6 +-
146
accel/tcg/tcg-accel-ops.c | 2 +-
147
accel/tcg/tcg-all.c | 8 +-
148
accel/tcg/translate-all.c | 15 +-
149
accel/tcg/translator.c | 24 +-
150
accel/tcg/user-exec.c | 279 +----
151
bsd-user/main.c | 6 +-
152
bsd-user/signal.c | 14 +-
153
cpus-common.c => cpu-common.c | 0
154
cpu.c => cpu-target.c | 13 +-
155
gdbstub/gdbstub.c | 4 +-
156
gdbstub/user-target.c | 2 +-
157
hw/core/cpu-common.c | 6 +-
158
hw/i386/kvm/clock.c | 2 +-
159
hw/intc/mips_gic.c | 2 +-
160
hw/intc/riscv_aclint.c | 12 +-
161
hw/intc/riscv_imsic.c | 2 +-
162
hw/ppc/e500.c | 4 +-
163
hw/ppc/spapr.c | 2 +-
164
linux-user/elfload.c | 4 +-
165
linux-user/exit.c | 6 -
166
linux-user/hppa/signal.c | 2 +-
167
linux-user/i386/cpu_loop.c | 2 +-
168
linux-user/main.c | 8 +-
169
linux-user/signal.c | 20 +-
170
linux-user/syscall.c | 2 +-
171
monitor/hmp-cmds-target.c | 2 +-
172
page-vary.c => page-vary-target.c | 0
173
qom/object.c | 14 +
174
semihosting/arm-compat-semi.c | 6 +-
175
semihosting/syscalls.c | 28 +-
176
softmmu/watchpoint.c | 2 +-
177
target/alpha/cpu.c | 3 +-
178
target/alpha/translate.c | 146 +--
179
target/arm/cpu.c | 12 +-
180
target/arm/cpu64.c | 4 -
181
target/arm/helper.c | 2 +-
182
target/arm/ptw.c | 4 +-
183
target/arm/tcg/mte_helper.c | 2 +-
184
target/arm/tcg/sve_helper.c | 2 +-
185
target/arm/tcg/tlb_helper.c | 4 +-
186
target/arm/tcg/translate-a64.c | 384 +++---
187
target/arm/tcg/translate-m-nocp.c | 24 +-
188
target/arm/tcg/translate-mve.c | 52 +-
189
target/arm/tcg/translate-neon.c | 78 +-
190
target/arm/tcg/translate-sme.c | 8 +-
191
target/arm/tcg/translate-sve.c | 172 +--
192
target/arm/tcg/translate-vfp.c | 56 +-
193
target/arm/tcg/translate.c | 234 ++--
194
target/avr/cpu.c | 3 +-
195
target/avr/translate.c | 66 +-
196
target/cris/cpu.c | 3 +-
197
target/cris/translate.c | 72 +-
198
target/hexagon/cpu.c | 4 +-
199
target/hexagon/genptr.c | 36 +-
200
target/hexagon/idef-parser/parser-helpers.c | 2 +-
201
target/hexagon/translate.c | 52 +-
202
target/hppa/cpu.c | 2 +-
203
target/hppa/mem_helper.c | 2 +-
204
target/hppa/translate.c | 161 ++-
205
target/i386/cpu.c | 2 +-
206
target/i386/hvf/hvf-cpu.c | 2 +-
207
target/i386/kvm/kvm-cpu.c | 4 +-
208
target/i386/nvmm/nvmm-all.c | 14 +-
209
target/i386/tcg/sysemu/excp_helper.c | 2 +-
210
target/i386/tcg/tcg-cpu.c | 4 +-
211
target/i386/tcg/translate.c | 584 ++++-----
212
target/i386/whpx/whpx-all.c | 26 +-
213
target/loongarch/cpu.c | 9 +-
214
target/loongarch/translate.c | 22 +-
215
target/m68k/cpu.c | 9 +-
216
target/m68k/translate.c | 306 ++---
217
target/microblaze/cpu.c | 2 +-
218
target/microblaze/translate.c | 52 +-
219
target/mips/cpu.c | 2 +-
220
target/mips/tcg/lcsr_translate.c | 6 +-
221
target/mips/tcg/msa_translate.c | 34 +-
222
target/mips/tcg/mxu_translate.c | 4 +-
223
target/mips/tcg/sysemu/mips-semi.c | 4 +-
224
target/mips/tcg/translate.c | 1288 ++++++++++----------
225
target/mips/tcg/vr54xx_translate.c | 2 +-
226
target/nios2/cpu.c | 5 +-
227
target/nios2/translate.c | 52 +-
228
target/openrisc/cpu.c | 7 +-
229
target/openrisc/translate.c | 86 +-
230
target/ppc/cpu_init.c | 1 -
231
target/ppc/excp_helper.c | 10 +-
232
target/ppc/translate.c | 366 +++---
233
target/riscv/cpu.c | 8 +-
234
target/riscv/translate.c | 56 +-
235
target/rx/cpu.c | 5 +-
236
target/rx/translate.c | 58 +-
237
target/s390x/cpu.c | 2 -
238
target/s390x/tcg/translate.c | 426 +++----
239
target/sh4/cpu.c | 3 +-
240
target/sh4/op_helper.c | 2 +-
241
target/sh4/translate.c | 128 +-
242
target/sparc/cpu.c | 3 +-
243
target/sparc/translate.c | 332 ++---
244
target/tricore/cpu.c | 10 +-
245
target/tricore/translate.c | 230 ++--
246
target/xtensa/cpu.c | 2 +-
247
target/xtensa/translate.c | 192 +--
248
tcg/tcg-op-gvec.c | 300 ++---
249
tcg/tcg-op-ldst.c | 22 +-
250
tcg/tcg-op.c | 2 +-
251
tcg/tcg.c | 23 +-
252
accel/tcg/ldst_atomicity.c.inc | 88 +-
253
accel/tcg/ldst_common.c.inc | 225 ++++
254
target/cris/translate_v10.c.inc | 28 +-
255
target/i386/tcg/decode-new.c.inc | 4 +-
256
target/i386/tcg/emit.c.inc | 262 ++--
257
target/loongarch/insn_trans/trans_atomic.c.inc | 4 +-
258
target/loongarch/insn_trans/trans_branch.c.inc | 2 +-
259
target/loongarch/insn_trans/trans_extra.c.inc | 10 +-
260
target/loongarch/insn_trans/trans_farith.c.inc | 6 +-
261
target/loongarch/insn_trans/trans_fcmp.c.inc | 8 +-
262
target/loongarch/insn_trans/trans_fmemory.c.inc | 8 +-
263
target/loongarch/insn_trans/trans_fmov.c.inc | 20 +-
264
target/loongarch/insn_trans/trans_memory.c.inc | 8 +-
265
target/loongarch/insn_trans/trans_privileged.c.inc | 52 +-
266
target/loongarch/insn_trans/trans_vec.c.inc | 24 +-
267
target/mips/tcg/micromips_translate.c.inc | 12 +-
268
target/mips/tcg/nanomips_translate.c.inc | 200 +--
269
target/ppc/power8-pmu-regs.c.inc | 8 +-
270
target/ppc/translate/branch-impl.c.inc | 2 +-
271
target/ppc/translate/dfp-impl.c.inc | 22 +-
272
target/ppc/translate/fixedpoint-impl.c.inc | 2 +-
273
target/ppc/translate/fp-impl.c.inc | 50 +-
274
target/ppc/translate/processor-ctrl-impl.c.inc | 8 +-
275
target/ppc/translate/spe-impl.c.inc | 30 +-
276
target/ppc/translate/storage-ctrl-impl.c.inc | 26 +-
277
target/ppc/translate/vmx-impl.c.inc | 34 +-
278
target/ppc/translate/vsx-impl.c.inc | 54 +-
279
target/riscv/insn_trans/trans_privileged.c.inc | 8 +-
280
target/riscv/insn_trans/trans_rvbf16.c.inc | 10 +-
281
target/riscv/insn_trans/trans_rvd.c.inc | 48 +-
282
target/riscv/insn_trans/trans_rvf.c.inc | 46 +-
283
target/riscv/insn_trans/trans_rvh.c.inc | 8 +-
284
target/riscv/insn_trans/trans_rvi.c.inc | 16 +-
285
target/riscv/insn_trans/trans_rvm.c.inc | 16 +-
286
target/riscv/insn_trans/trans_rvv.c.inc | 130 +-
287
target/riscv/insn_trans/trans_rvvk.c.inc | 30 +-
288
target/riscv/insn_trans/trans_rvzce.c.inc | 2 +-
289
target/riscv/insn_trans/trans_rvzfa.c.inc | 38 +-
290
target/riscv/insn_trans/trans_rvzfh.c.inc | 54 +-
291
target/riscv/insn_trans/trans_rvzicbo.c.inc | 8 +-
292
target/riscv/insn_trans/trans_svinval.c.inc | 6 +-
293
target/riscv/insn_trans/trans_xthead.c.inc | 2 +-
294
target/s390x/tcg/translate_vx.c.inc | 104 +-
295
tcg/aarch64/tcg-target.c.inc | 2 +-
296
tcg/arm/tcg-target.c.inc | 2 +-
297
tcg/loongarch64/tcg-target.c.inc | 68 +-
298
accel/meson.build | 4 +-
299
accel/tcg/meson.build | 8 +-
300
meson_options.txt | 3 -
301
scripts/meson-buildoptions.sh | 3 -
302
softmmu/meson.build | 4 -
303
target/hexagon/README | 10 +-
304
target/hexagon/gen_tcg_funcs.py | 16 +-
305
tests/avocado/boot_linux_console.py | 7 -
306
tests/avocado/machine_mips_malta.py | 6 -
307
tests/avocado/replay_kernel.py | 7 -
308
tests/avocado/tuxrun_baselines.py | 4 -
309
tests/qemu-iotests/meson.build | 2 +-
310
225 files changed, 5101 insertions(+), 5323 deletions(-)
311
create mode 100644 accel/tcg/internal-common.h
312
rename accel/tcg/{internal.h => internal-target.h} (89%)
313
create mode 100644 include/tcg/startup.h
314
rename accel/{accel-common.c => accel-target.c} (86%)
315
rename softmmu/icount.c => accel/tcg/icount-common.c (99%)
316
rename cpus-common.c => cpu-common.c (100%)
317
rename cpu.c => cpu-target.c (97%)
318
rename page-vary.c => page-vary-target.c (100%)
319
diff view generated by jsdifflib
Deleted patch
1
With CF_NOIRQ and without !CF_USE_ICOUNT, the load isn't used.
2
Avoid emitting it.
3
1
4
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
accel/tcg/translator.c | 11 +++++++----
8
1 file changed, 7 insertions(+), 4 deletions(-)
9
10
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/accel/tcg/translator.c
13
+++ b/accel/tcg/translator.c
14
@@ -XXX,XX +XXX,XX @@ bool translator_io_start(DisasContextBase *db)
15
16
static TCGOp *gen_tb_start(uint32_t cflags)
17
{
18
- TCGv_i32 count = tcg_temp_new_i32();
19
+ TCGv_i32 count = NULL;
20
TCGOp *icount_start_insn = NULL;
21
22
- tcg_gen_ld_i32(count, cpu_env,
23
- offsetof(ArchCPU, neg.icount_decr.u32) -
24
- offsetof(ArchCPU, env));
25
+ if ((cflags & CF_USE_ICOUNT) || !(cflags & CF_NOIRQ)) {
26
+ count = tcg_temp_new_i32();
27
+ tcg_gen_ld_i32(count, cpu_env,
28
+ offsetof(ArchCPU, neg.icount_decr.u32) -
29
+ offsetof(ArchCPU, env));
30
+ }
31
32
if (cflags & CF_USE_ICOUNT) {
33
/*
34
--
35
2.34.1
36
37
diff view generated by jsdifflib
Deleted patch
1
The condition checked is loop invariant; check it only once.
2
1
3
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
accel/tcg/translator.c | 14 ++++++++------
7
1 file changed, 8 insertions(+), 6 deletions(-)
8
9
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/accel/tcg/translator.c
12
+++ b/accel/tcg/translator.c
13
@@ -XXX,XX +XXX,XX @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
14
ops->tb_start(db, cpu);
15
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
16
17
- plugin_enabled = plugin_gen_tb_start(cpu, db, cflags & CF_MEMI_ONLY);
18
+ if (cflags & CF_MEMI_ONLY) {
19
+ /* We should only see CF_MEMI_ONLY for io_recompile. */
20
+ assert(cflags & CF_LAST_IO);
21
+ plugin_enabled = plugin_gen_tb_start(cpu, db, true);
22
+ } else {
23
+ plugin_enabled = plugin_gen_tb_start(cpu, db, false);
24
+ }
25
26
while (true) {
27
*max_insns = ++db->num_insns;
28
@@ -XXX,XX +XXX,XX @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
29
if (db->num_insns == db->max_insns && (cflags & CF_LAST_IO)) {
30
/* Accept I/O on the last instruction. */
31
gen_io_start();
32
- ops->translate_insn(db, cpu);
33
- } else {
34
- /* we should only see CF_MEMI_ONLY for io_recompile */
35
- tcg_debug_assert(!(cflags & CF_MEMI_ONLY));
36
- ops->translate_insn(db, cpu);
37
}
38
+ ops->translate_insn(db, cpu);
39
40
/*
41
* We can't instrument after instructions that change control
42
--
43
2.34.1
44
45
diff view generated by jsdifflib
Deleted patch
1
Simplify translator_io_start by recording the current
2
known value of can_do_io within DisasContextBase.
3
1
4
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
include/exec/translator.h | 2 ++
8
accel/tcg/translator.c | 31 ++++++++++++++-----------------
9
2 files changed, 16 insertions(+), 17 deletions(-)
10
11
diff --git a/include/exec/translator.h b/include/exec/translator.h
12
index XXXXXXX..XXXXXXX 100644
13
--- a/include/exec/translator.h
14
+++ b/include/exec/translator.h
15
@@ -XXX,XX +XXX,XX @@ typedef enum DisasJumpType {
16
* @num_insns: Number of translated instructions (including current).
17
* @max_insns: Maximum number of instructions to be translated in this TB.
18
* @singlestep_enabled: "Hardware" single stepping enabled.
19
+ * @saved_can_do_io: Known value of cpu->neg.can_do_io, or -1 for unknown.
20
*
21
* Architecture-agnostic disassembly context.
22
*/
23
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContextBase {
24
int num_insns;
25
int max_insns;
26
bool singlestep_enabled;
27
+ int8_t saved_can_do_io;
28
void *host_addr[2];
29
} DisasContextBase;
30
31
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/accel/tcg/translator.c
34
+++ b/accel/tcg/translator.c
35
@@ -XXX,XX +XXX,XX @@
36
#include "tcg/tcg-op-common.h"
37
#include "internal.h"
38
39
-static void gen_io_start(void)
40
+static void set_can_do_io(DisasContextBase *db, bool val)
41
{
42
- tcg_gen_st_i32(tcg_constant_i32(1), cpu_env,
43
- offsetof(ArchCPU, parent_obj.can_do_io) -
44
- offsetof(ArchCPU, env));
45
+ if (db->saved_can_do_io != val) {
46
+ db->saved_can_do_io = val;
47
+ tcg_gen_st_i32(tcg_constant_i32(val), cpu_env,
48
+ offsetof(ArchCPU, parent_obj.can_do_io) -
49
+ offsetof(ArchCPU, env));
50
+ }
51
}
52
53
bool translator_io_start(DisasContextBase *db)
54
@@ -XXX,XX +XXX,XX @@ bool translator_io_start(DisasContextBase *db)
55
if (!(cflags & CF_USE_ICOUNT)) {
56
return false;
57
}
58
- if (db->num_insns == db->max_insns && (cflags & CF_LAST_IO)) {
59
- /* Already started in translator_loop. */
60
- return true;
61
- }
62
63
- gen_io_start();
64
+ set_can_do_io(db, true);
65
66
/*
67
* Ensure that this instruction will be the last in the TB.
68
@@ -XXX,XX +XXX,XX @@ bool translator_io_start(DisasContextBase *db)
69
return true;
70
}
71
72
-static TCGOp *gen_tb_start(uint32_t cflags)
73
+static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags)
74
{
75
TCGv_i32 count = NULL;
76
TCGOp *icount_start_insn = NULL;
77
@@ -XXX,XX +XXX,XX @@ static TCGOp *gen_tb_start(uint32_t cflags)
78
* cpu->can_do_io is cleared automatically here at the beginning of
79
* each translation block. The cost is minimal and only paid for
80
* -icount, plus it would be very easy to forget doing it in the
81
- * translator. Doing it here means we don't need a gen_io_end() to
82
- * go with gen_io_start().
83
+ * translator.
84
*/
85
- tcg_gen_st_i32(tcg_constant_i32(0), cpu_env,
86
- offsetof(ArchCPU, parent_obj.can_do_io) -
87
- offsetof(ArchCPU, env));
88
+ set_can_do_io(db, false);
89
}
90
91
return icount_start_insn;
92
@@ -XXX,XX +XXX,XX @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
93
db->num_insns = 0;
94
db->max_insns = *max_insns;
95
db->singlestep_enabled = cflags & CF_SINGLE_STEP;
96
+ db->saved_can_do_io = -1;
97
db->host_addr[0] = host_pc;
98
db->host_addr[1] = NULL;
99
100
@@ -XXX,XX +XXX,XX @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
101
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
102
103
/* Start translating. */
104
- icount_start_insn = gen_tb_start(cflags);
105
+ icount_start_insn = gen_tb_start(db, cflags);
106
ops->tb_start(db, cpu);
107
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
108
109
@@ -XXX,XX +XXX,XX @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
110
the next instruction. */
111
if (db->num_insns == db->max_insns && (cflags & CF_LAST_IO)) {
112
/* Accept I/O on the last instruction. */
113
- gen_io_start();
114
+ set_can_do_io(db, true);
115
}
116
ops->translate_insn(db, cpu);
117
118
--
119
2.34.1
120
121
diff view generated by jsdifflib
Deleted patch
1
Initialize can_do_io to true if this the TB has CF_LAST_IO
2
and will consist of a single instruction. This avoids a
3
set to 0 followed immediately by a set to 1.
4
1
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
8
accel/tcg/translator.c | 4 ++--
9
1 file changed, 2 insertions(+), 2 deletions(-)
10
11
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/accel/tcg/translator.c
14
+++ b/accel/tcg/translator.c
15
@@ -XXX,XX +XXX,XX @@ static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags)
16
offsetof(ArchCPU, neg.icount_decr.u16.low) -
17
offsetof(ArchCPU, env));
18
/*
19
- * cpu->can_do_io is cleared automatically here at the beginning of
20
+ * cpu->can_do_io is set automatically here at the beginning of
21
* each translation block. The cost is minimal and only paid for
22
* -icount, plus it would be very easy to forget doing it in the
23
* translator.
24
*/
25
- set_can_do_io(db, false);
26
+ set_can_do_io(db, db->max_insns == 1 && (cflags & CF_LAST_IO));
27
}
28
29
return icount_start_insn;
30
--
31
2.34.1
32
33
diff view generated by jsdifflib
Deleted patch
1
Without this we can get see loops through cpu_io_recompile,
2
in which the cpu makes no progress.
3
1
4
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
accel/tcg/cpu-exec.c | 2 +-
8
accel/tcg/tb-maint.c | 6 ++++--
9
2 files changed, 5 insertions(+), 3 deletions(-)
10
11
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/accel/tcg/cpu-exec.c
14
+++ b/accel/tcg/cpu-exec.c
15
@@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
16
&& cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra == 0) {
17
/* Execute just one insn to trigger exception pending in the log */
18
cpu->cflags_next_tb = (curr_cflags(cpu) & ~CF_USE_ICOUNT)
19
- | CF_NOIRQ | 1;
20
+ | CF_LAST_IO | CF_NOIRQ | 1;
21
}
22
#endif
23
return false;
24
diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/accel/tcg/tb-maint.c
27
+++ b/accel/tcg/tb-maint.c
28
@@ -XXX,XX +XXX,XX @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc)
29
if (current_tb_modified) {
30
/* Force execution of one insn next time. */
31
CPUState *cpu = current_cpu;
32
- cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu);
33
+ cpu->cflags_next_tb =
34
+ 1 | CF_LAST_IO | CF_NOIRQ | curr_cflags(current_cpu);
35
return true;
36
}
37
return false;
38
@@ -XXX,XX +XXX,XX @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,
39
if (current_tb_modified) {
40
page_collection_unlock(pages);
41
/* Force execution of one insn next time. */
42
- current_cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu);
43
+ current_cpu->cflags_next_tb =
44
+ 1 | CF_LAST_IO | CF_NOIRQ | curr_cflags(current_cpu);
45
mmap_unlock();
46
cpu_loop_exit_noexc(current_cpu);
47
}
48
--
49
2.34.1
50
51
diff view generated by jsdifflib
Deleted patch
1
Require i/o as the last insn of a TranslationBlock always,
2
not only with icount. This is required for i/o that alters
3
the address space, such as a pci config space write.
4
1
5
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1866
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
accel/tcg/translator.c | 20 +++++++-------------
10
target/mips/tcg/translate.c | 1 -
11
2 files changed, 7 insertions(+), 14 deletions(-)
12
13
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/accel/tcg/translator.c
16
+++ b/accel/tcg/translator.c
17
@@ -XXX,XX +XXX,XX @@ static void set_can_do_io(DisasContextBase *db, bool val)
18
19
bool translator_io_start(DisasContextBase *db)
20
{
21
- uint32_t cflags = tb_cflags(db->tb);
22
-
23
- if (!(cflags & CF_USE_ICOUNT)) {
24
- return false;
25
- }
26
-
27
set_can_do_io(db, true);
28
29
/*
30
@@ -XXX,XX +XXX,XX @@ static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags)
31
tcg_gen_st16_i32(count, cpu_env,
32
offsetof(ArchCPU, neg.icount_decr.u16.low) -
33
offsetof(ArchCPU, env));
34
- /*
35
- * cpu->can_do_io is set automatically here at the beginning of
36
- * each translation block. The cost is minimal and only paid for
37
- * -icount, plus it would be very easy to forget doing it in the
38
- * translator.
39
- */
40
- set_can_do_io(db, db->max_insns == 1 && (cflags & CF_LAST_IO));
41
}
42
43
+ /*
44
+ * cpu->can_do_io is set automatically here at the beginning of
45
+ * each translation block. The cost is minimal, plus it would be
46
+ * very easy to forget doing it in the translator.
47
+ */
48
+ set_can_do_io(db, db->max_insns == 1 && (cflags & CF_LAST_IO));
49
+
50
return icount_start_insn;
51
}
52
53
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
54
index XXXXXXX..XXXXXXX 100644
55
--- a/target/mips/tcg/translate.c
56
+++ b/target/mips/tcg/translate.c
57
@@ -XXX,XX +XXX,XX @@ static void gen_branch(DisasContext *ctx, int insn_bytes)
58
/* Branches completion */
59
clear_branch_hflags(ctx);
60
ctx->base.is_jmp = DISAS_NORETURN;
61
- /* FIXME: Need to clear can_do_io. */
62
switch (proc_hflags & MIPS_HFLAG_BMASK_BASE) {
63
case MIPS_HFLAG_FBNSLOT:
64
gen_goto_tb(ctx, 0, ctx->base.pc_next + insn_bytes);
65
--
66
2.34.1
67
68
diff view generated by jsdifflib