1 | The following changes since commit 7a1dc45af581d2b643cdbf33c01fd96271616fbd: | 1 | Pretty small still, but there are two patches that ought |
---|---|---|---|
2 | to get backported to stable, so no point in delaying. | ||
2 | 3 | ||
3 | Merge tag 'pull-target-arm-20240126' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2024-01-26 18:16:35 +0000) | 4 | r~ |
5 | |||
6 | The following changes since commit a5ba0a7e4e150d1350a041f0d0ef9ca6c8d7c307: | ||
7 | |||
8 | Merge tag 'pull-aspeed-20241211' of https://github.com/legoater/qemu into staging (2024-12-11 15:16:47 +0000) | ||
4 | 9 | ||
5 | are available in the Git repository at: | 10 | are available in the Git repository at: |
6 | 11 | ||
7 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20240130 | 12 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20241212 |
8 | 13 | ||
9 | for you to fetch changes up to ec1d32af123e7f13d98754a72bcaa7aa8c8e9d27: | 14 | for you to fetch changes up to 7ac87b14a92234b6a89b701b4043ad6cf8bdcccf: |
10 | 15 | ||
11 | target/i386: Extract x86_cpu_exec_halt() from accel/tcg/ (2024-01-29 21:04:10 +1000) | 16 | target/sparc: Use memcpy() and remove memcpy32() (2024-12-12 14:28:38 -0600) |
12 | 17 | ||
13 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
14 | linux-user: Allow gdbstub to ignore page protection | 19 | tcg: Reset free_temps before tcg_optimize |
15 | cpu-exec: simplify jump cache management | 20 | tcg/riscv: Fix StoreStore barrier generation |
16 | include/exec: Cleanups toward building accel/tcg once | 21 | include/exec: Introduce fpst alias in helper-head.h.inc |
22 | target/sparc: Use memcpy() and remove memcpy32() | ||
17 | 23 | ||
18 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
19 | Anton Johansson (9): | 25 | Philippe Mathieu-Daudé (1): |
20 | include/exec: Move vaddr defines to separate file | 26 | target/sparc: Use memcpy() and remove memcpy32() |
21 | hw/core: Include vaddr.h from cpu.h | ||
22 | target: Use vaddr in gen_intermediate_code | ||
23 | include/exec: Use vaddr in DisasContextBase for virtual addresses | ||
24 | include/exec: typedef abi_ptr to vaddr | ||
25 | include/exec: Move PAGE_* macros to common header | ||
26 | include/exec: Move cpu_*()/cpu_env() to common header | ||
27 | include/hw/core: Move do_interrupt in TCGCPUOps | ||
28 | include/hw/core: Remove i386 conditional on fake_user_interrupt | ||
29 | 27 | ||
30 | Ilya Leoshkevich (8): | 28 | Richard Henderson (2): |
31 | linux-user: Allow gdbstub to ignore page protection | 29 | tcg: Reset free_temps before tcg_optimize |
32 | tests/tcg: Factor out gdbstub test functions | 30 | include/exec: Introduce fpst alias in helper-head.h.inc |
33 | tests/tcg: Add the PROT_NONE gdbstub test | ||
34 | target: Make qemu_target_page_mask() available for *-user | ||
35 | accel/tcg: Make use of qemu_target_page_mask() in perf.c | ||
36 | tcg: Make tb_cflags() usable from target-agnostic code | ||
37 | accel/tcg: Remove #ifdef TARGET_I386 from perf.c | ||
38 | accel/tcg: Move perf and debuginfo support to tcg/ | ||
39 | 31 | ||
40 | Paolo Bonzini (1): | 32 | Roman Artemev (1): |
41 | cpu-exec: simplify jump cache management | 33 | tcg/riscv: Fix StoreStore barrier generation |
42 | 34 | ||
43 | Philippe Mathieu-Daudé (9): | 35 | include/tcg/tcg-temp-internal.h | 6 ++++++ |
44 | accel/tcg/cpu-exec: Use RCU_READ_LOCK_GUARD | 36 | accel/tcg/plugin-gen.c | 2 +- |
45 | accel/tcg: Rename tcg_ss[] -> tcg_specific_ss[] in meson | 37 | target/sparc/win_helper.c | 26 ++++++++------------------ |
46 | accel/tcg: Rename tcg_cpus_destroy() -> tcg_cpu_destroy() | 38 | tcg/tcg.c | 5 ++++- |
47 | accel/tcg: Rename tcg_cpus_exec() -> tcg_cpu_exec() | 39 | include/exec/helper-head.h.inc | 3 +++ |
48 | accel/tcg: Un-inline icount_exit_request() for clarity | 40 | tcg/riscv/tcg-target.c.inc | 2 +- |
49 | accel/tcg: Introduce TCGCPUOps::need_replay_interrupt() handler | 41 | 6 files changed, 23 insertions(+), 21 deletions(-) |
50 | target/i386: Extract x86_need_replay_interrupt() from accel/tcg/ | ||
51 | accel/tcg: Introduce TCGCPUOps::cpu_exec_halt() handler | ||
52 | target/i386: Extract x86_cpu_exec_halt() from accel/tcg/ | ||
53 | 42 | ||
54 | Richard Henderson (4): | ||
55 | include/qemu: Add TCGCPUOps typedef to typedefs.h | ||
56 | target/loongarch: Constify loongarch_tcg_ops | ||
57 | accel/tcg: Use CPUState.cc instead of CPU_GET_CLASS in cpu-exec.c | ||
58 | accel/tcg: Inline need_replay_interrupt | ||
59 | |||
60 | accel/tcg/tb-jmp-cache.h | 8 +- | ||
61 | accel/tcg/tcg-accel-ops.h | 4 +- | ||
62 | include/exec/cpu-all.h | 49 ----- | ||
63 | include/exec/cpu-common.h | 69 +++++-- | ||
64 | include/exec/cpu_ldst.h | 4 +- | ||
65 | include/exec/exec-all.h | 6 - | ||
66 | include/exec/translation-block.h | 6 + | ||
67 | include/exec/translator.h | 8 +- | ||
68 | include/exec/vaddr.h | 18 ++ | ||
69 | include/hw/core/cpu.h | 7 +- | ||
70 | include/hw/core/tcg-cpu-ops.h | 19 +- | ||
71 | include/qemu/typedefs.h | 1 + | ||
72 | {accel => include}/tcg/debuginfo.h | 4 +- | ||
73 | {accel => include}/tcg/perf.h | 4 +- | ||
74 | target/i386/tcg/helper-tcg.h | 2 + | ||
75 | target/mips/tcg/translate.h | 3 +- | ||
76 | accel/tcg/cpu-exec.c | 223 +++++++++------------ | ||
77 | accel/tcg/tcg-accel-ops-mttcg.c | 4 +- | ||
78 | accel/tcg/tcg-accel-ops-rr.c | 4 +- | ||
79 | accel/tcg/tcg-accel-ops.c | 4 +- | ||
80 | accel/tcg/translate-all.c | 2 +- | ||
81 | bsd-user/signal.c | 4 +- | ||
82 | cpu-target.c | 78 +++++-- | ||
83 | hw/core/loader.c | 2 +- | ||
84 | linux-user/elfload.c | 2 +- | ||
85 | linux-user/exit.c | 2 +- | ||
86 | linux-user/main.c | 2 +- | ||
87 | linux-user/signal.c | 4 +- | ||
88 | system/physmem.c | 5 - | ||
89 | system/vl.c | 2 +- | ||
90 | target/alpha/cpu.c | 2 +- | ||
91 | target/alpha/translate.c | 2 +- | ||
92 | target/arm/cpu.c | 2 +- | ||
93 | target/arm/tcg/cpu32.c | 2 +- | ||
94 | target/arm/tcg/translate.c | 2 +- | ||
95 | target/avr/cpu.c | 2 +- | ||
96 | target/avr/translate.c | 2 +- | ||
97 | target/cris/cpu.c | 4 +- | ||
98 | target/cris/translate.c | 2 +- | ||
99 | target/hexagon/cpu.c | 2 +- | ||
100 | target/hexagon/translate.c | 5 +- | ||
101 | target/hppa/cpu.c | 2 +- | ||
102 | target/hppa/translate.c | 2 +- | ||
103 | target/i386/tcg/sysemu/seg_helper.c | 23 +++ | ||
104 | target/i386/tcg/tcg-cpu.c | 4 +- | ||
105 | target/i386/tcg/translate.c | 2 +- | ||
106 | target/loongarch/cpu.c | 2 +- | ||
107 | target/loongarch/tcg/translate.c | 2 +- | ||
108 | target/m68k/cpu.c | 2 +- | ||
109 | target/m68k/translate.c | 4 +- | ||
110 | target/microblaze/cpu.c | 2 +- | ||
111 | target/microblaze/translate.c | 2 +- | ||
112 | target/mips/cpu.c | 2 +- | ||
113 | target/mips/tcg/translate.c | 14 +- | ||
114 | target/nios2/cpu.c | 2 +- | ||
115 | target/nios2/translate.c | 2 +- | ||
116 | target/openrisc/cpu.c | 2 +- | ||
117 | target/openrisc/translate.c | 2 +- | ||
118 | target/ppc/cpu_init.c | 2 +- | ||
119 | target/ppc/translate.c | 2 +- | ||
120 | target/riscv/tcg/tcg-cpu.c | 2 +- | ||
121 | target/riscv/translate.c | 2 +- | ||
122 | target/rx/cpu.c | 2 +- | ||
123 | target/rx/translate.c | 2 +- | ||
124 | target/s390x/cpu.c | 2 +- | ||
125 | target/s390x/tcg/translate.c | 2 +- | ||
126 | target/sh4/cpu.c | 2 +- | ||
127 | target/sh4/translate.c | 2 +- | ||
128 | target/sparc/cpu.c | 2 +- | ||
129 | target/sparc/translate.c | 2 +- | ||
130 | target/target-common.c | 10 + | ||
131 | target/tricore/cpu.c | 2 +- | ||
132 | target/tricore/translate.c | 2 +- | ||
133 | target/xtensa/cpu.c | 2 +- | ||
134 | target/xtensa/translate.c | 2 +- | ||
135 | {accel/tcg => tcg}/debuginfo.c | 3 +- | ||
136 | {accel/tcg => tcg}/perf.c | 14 +- | ||
137 | tcg/tcg.c | 2 +- | ||
138 | tests/tcg/multiarch/prot-none.c | 40 ++++ | ||
139 | accel/tcg/meson.build | 16 +- | ||
140 | target/meson.build | 2 + | ||
141 | tcg/meson.build | 5 + | ||
142 | tests/guest-debug/run-test.py | 7 +- | ||
143 | tests/guest-debug/test_gdbstub.py | 60 ++++++ | ||
144 | tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 34 +--- | ||
145 | tests/tcg/aarch64/gdbstub/test-sve.py | 33 +-- | ||
146 | tests/tcg/multiarch/Makefile.target | 9 +- | ||
147 | tests/tcg/multiarch/gdbstub/interrupt.py | 47 +---- | ||
148 | tests/tcg/multiarch/gdbstub/memory.py | 39 +--- | ||
149 | tests/tcg/multiarch/gdbstub/prot-none.py | 36 ++++ | ||
150 | tests/tcg/multiarch/gdbstub/registers.py | 41 +--- | ||
151 | tests/tcg/multiarch/gdbstub/sha1.py | 38 +--- | ||
152 | tests/tcg/multiarch/gdbstub/test-proc-mappings.py | 39 +--- | ||
153 | .../tcg/multiarch/gdbstub/test-qxfer-auxv-read.py | 37 +--- | ||
154 | .../multiarch/gdbstub/test-thread-breakpoint.py | 37 +--- | ||
155 | tests/tcg/s390x/gdbstub/test-signals-s390x.py | 42 +--- | ||
156 | tests/tcg/s390x/gdbstub/test-svc.py | 39 +--- | ||
157 | 97 files changed, 580 insertions(+), 730 deletions(-) | ||
158 | create mode 100644 include/exec/vaddr.h | ||
159 | rename {accel => include}/tcg/debuginfo.h (96%) | ||
160 | rename {accel => include}/tcg/perf.h (95%) | ||
161 | create mode 100644 target/target-common.c | ||
162 | rename {accel/tcg => tcg}/debuginfo.c (98%) | ||
163 | rename {accel/tcg => tcg}/perf.c (97%) | ||
164 | create mode 100644 tests/tcg/multiarch/prot-none.c | ||
165 | create mode 100644 tests/guest-debug/test_gdbstub.py | ||
166 | create mode 100644 tests/tcg/multiarch/gdbstub/prot-none.py | ||
167 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Paolo Bonzini <pbonzini@redhat.com> | ||
2 | 1 | ||
3 | Unless I'm missing something egregious, the jmp cache is only every | ||
4 | populated with a valid entry by the same thread that reads the cache. | ||
5 | Therefore, the contents of any valid entry are always consistent and | ||
6 | there is no need for any acquire/release magic. | ||
7 | |||
8 | Indeed ->tb has to be accessed with atomics, because concurrent | ||
9 | invalidations would otherwise cause data races. But ->pc is only ever | ||
10 | accessed by one thread, and accesses to ->tb and ->pc within tb_lookup | ||
11 | can never race with another tb_lookup. While the TranslationBlock | ||
12 | (especially the flags) could be modified by a concurrent invalidation, | ||
13 | store-release and load-acquire operations on the cache entry would | ||
14 | not add any additional ordering beyond what you get from performing | ||
15 | the accesses within a single thread. | ||
16 | |||
17 | Because of this, there is really nothing to win in splitting the CF_PCREL | ||
18 | and !CF_PCREL paths. It is easier to just always use the ->pc field in | ||
19 | the jump cache. | ||
20 | |||
21 | I noticed this while working on splitting commit 8ed558ec0cb | ||
22 | ("accel/tcg: Introduce TARGET_TB_PCREL", 2022-10-04) into multiple | ||
23 | pieces, for the sake of finding a more fine-grained bisection | ||
24 | result for https://gitlab.com/qemu-project/qemu/-/issues/2092. | ||
25 | It does not (and does not intend to) fix that issue; therefore | ||
26 | it may make sense to not commit it until the root cause | ||
27 | of issue #2092 is found. | ||
28 | |||
29 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | ||
30 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
31 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
32 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
33 | Message-Id: <20240122153409.351959-1-pbonzini@redhat.com> | ||
34 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
35 | --- | ||
36 | accel/tcg/tb-jmp-cache.h | 8 +++-- | ||
37 | accel/tcg/cpu-exec.c | 66 ++++++++++++++-------------------------- | ||
38 | 2 files changed, 28 insertions(+), 46 deletions(-) | ||
39 | |||
40 | diff --git a/accel/tcg/tb-jmp-cache.h b/accel/tcg/tb-jmp-cache.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/accel/tcg/tb-jmp-cache.h | ||
43 | +++ b/accel/tcg/tb-jmp-cache.h | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | #define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) | ||
46 | |||
47 | /* | ||
48 | - * Accessed in parallel; all accesses to 'tb' must be atomic. | ||
49 | - * For CF_PCREL, accesses to 'pc' must be protected by a | ||
50 | - * load_acquire/store_release to 'tb'. | ||
51 | + * Invalidated in parallel; all accesses to 'tb' must be atomic. | ||
52 | + * A valid entry is read/written by a single CPU, therefore there is | ||
53 | + * no need for qatomic_rcu_read() and pc is always consistent with a | ||
54 | + * non-NULL value of 'tb'. Strictly speaking pc is only needed for | ||
55 | + * CF_PCREL, but it's used always for simplicity. | ||
56 | */ | ||
57 | struct CPUJumpCache { | ||
58 | struct rcu_head rcu; | ||
59 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/accel/tcg/cpu-exec.c | ||
62 | +++ b/accel/tcg/cpu-exec.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static inline TranslationBlock *tb_lookup(CPUState *cpu, vaddr pc, | ||
64 | hash = tb_jmp_cache_hash_func(pc); | ||
65 | jc = cpu->tb_jmp_cache; | ||
66 | |||
67 | - if (cflags & CF_PCREL) { | ||
68 | - /* Use acquire to ensure current load of pc from jc. */ | ||
69 | - tb = qatomic_load_acquire(&jc->array[hash].tb); | ||
70 | - | ||
71 | - if (likely(tb && | ||
72 | - jc->array[hash].pc == pc && | ||
73 | - tb->cs_base == cs_base && | ||
74 | - tb->flags == flags && | ||
75 | - tb_cflags(tb) == cflags)) { | ||
76 | - return tb; | ||
77 | - } | ||
78 | - tb = tb_htable_lookup(cpu, pc, cs_base, flags, cflags); | ||
79 | - if (tb == NULL) { | ||
80 | - return NULL; | ||
81 | - } | ||
82 | - jc->array[hash].pc = pc; | ||
83 | - /* Ensure pc is written first. */ | ||
84 | - qatomic_store_release(&jc->array[hash].tb, tb); | ||
85 | - } else { | ||
86 | - /* Use rcu_read to ensure current load of pc from *tb. */ | ||
87 | - tb = qatomic_rcu_read(&jc->array[hash].tb); | ||
88 | - | ||
89 | - if (likely(tb && | ||
90 | - tb->pc == pc && | ||
91 | - tb->cs_base == cs_base && | ||
92 | - tb->flags == flags && | ||
93 | - tb_cflags(tb) == cflags)) { | ||
94 | - return tb; | ||
95 | - } | ||
96 | - tb = tb_htable_lookup(cpu, pc, cs_base, flags, cflags); | ||
97 | - if (tb == NULL) { | ||
98 | - return NULL; | ||
99 | - } | ||
100 | - /* Use the pc value already stored in tb->pc. */ | ||
101 | - qatomic_set(&jc->array[hash].tb, tb); | ||
102 | + tb = qatomic_read(&jc->array[hash].tb); | ||
103 | + if (likely(tb && | ||
104 | + jc->array[hash].pc == pc && | ||
105 | + tb->cs_base == cs_base && | ||
106 | + tb->flags == flags && | ||
107 | + tb_cflags(tb) == cflags)) { | ||
108 | + goto hit; | ||
109 | } | ||
110 | |||
111 | + tb = tb_htable_lookup(cpu, pc, cs_base, flags, cflags); | ||
112 | + if (tb == NULL) { | ||
113 | + return NULL; | ||
114 | + } | ||
115 | + | ||
116 | + jc->array[hash].pc = pc; | ||
117 | + qatomic_set(&jc->array[hash].tb, tb); | ||
118 | + | ||
119 | +hit: | ||
120 | + /* | ||
121 | + * As long as tb is not NULL, the contents are consistent. Therefore, | ||
122 | + * the virtual PC has to match for non-CF_PCREL translations. | ||
123 | + */ | ||
124 | + assert((tb_cflags(tb) & CF_PCREL) || tb->pc == pc); | ||
125 | return tb; | ||
126 | } | ||
127 | |||
128 | @@ -XXX,XX +XXX,XX @@ cpu_exec_loop(CPUState *cpu, SyncClocks *sc) | ||
129 | */ | ||
130 | h = tb_jmp_cache_hash_func(pc); | ||
131 | jc = cpu->tb_jmp_cache; | ||
132 | - if (cflags & CF_PCREL) { | ||
133 | - jc->array[h].pc = pc; | ||
134 | - /* Ensure pc is written first. */ | ||
135 | - qatomic_store_release(&jc->array[h].tb, tb); | ||
136 | - } else { | ||
137 | - /* Use the pc value already stored in tb->pc. */ | ||
138 | - qatomic_set(&jc->array[h].tb, tb); | ||
139 | - } | ||
140 | + jc->array[h].pc = pc; | ||
141 | + qatomic_set(&jc->array[h].tb, tb); | ||
142 | } | ||
143 | |||
144 | #ifndef CONFIG_USER_ONLY | ||
145 | -- | ||
146 | 2.34.1 | ||
147 | |||
148 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Anton Johansson <anjo@rev.ng> | ||
2 | 1 | ||
3 | Needed to work around circular includes. vaddr is currently defined in | ||
4 | cpu-common.h and needed by hw/core/cpu.h, but cpu-common.h also need | ||
5 | cpu.h to know the size of the CPUState. | ||
6 | |||
7 | [Maybe we can instead move parts of cpu-common.h w. hw/core/cpu.h to | ||
8 | sort out the circular inclusion.] | ||
9 | |||
10 | Signed-off-by: Anton Johansson <anjo@rev.ng> | ||
11 | Message-Id: <20240119144024.14289-7-anjo@rev.ng> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | [rth: Add include of vaddr.h into cpu-common.h] | ||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | --- | ||
16 | include/exec/cpu-common.h | 13 +------------ | ||
17 | include/exec/vaddr.h | 18 ++++++++++++++++++ | ||
18 | 2 files changed, 19 insertions(+), 12 deletions(-) | ||
19 | create mode 100644 include/exec/vaddr.h | ||
20 | |||
21 | diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/include/exec/cpu-common.h | ||
24 | +++ b/include/exec/cpu-common.h | ||
25 | @@ -XXX,XX +XXX,XX @@ | ||
26 | |||
27 | /* CPU interfaces that are target independent. */ | ||
28 | |||
29 | +#include "exec/vaddr.h" | ||
30 | #ifndef CONFIG_USER_ONLY | ||
31 | #include "exec/hwaddr.h" | ||
32 | #endif | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | #define EXCP_YIELD 0x10004 /* cpu wants to yield timeslice to another */ | ||
35 | #define EXCP_ATOMIC 0x10005 /* stop-the-world and emulate atomic */ | ||
36 | |||
37 | -/** | ||
38 | - * vaddr: | ||
39 | - * Type wide enough to contain any #target_ulong virtual address. | ||
40 | - */ | ||
41 | -typedef uint64_t vaddr; | ||
42 | -#define VADDR_PRId PRId64 | ||
43 | -#define VADDR_PRIu PRIu64 | ||
44 | -#define VADDR_PRIo PRIo64 | ||
45 | -#define VADDR_PRIx PRIx64 | ||
46 | -#define VADDR_PRIX PRIX64 | ||
47 | -#define VADDR_MAX UINT64_MAX | ||
48 | - | ||
49 | void cpu_exec_init_all(void); | ||
50 | void cpu_exec_step_atomic(CPUState *cpu); | ||
51 | |||
52 | diff --git a/include/exec/vaddr.h b/include/exec/vaddr.h | ||
53 | new file mode 100644 | ||
54 | index XXXXXXX..XXXXXXX | ||
55 | --- /dev/null | ||
56 | +++ b/include/exec/vaddr.h | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | +/* Define vaddr. */ | ||
59 | + | ||
60 | +#ifndef VADDR_H | ||
61 | +#define VADDR_H | ||
62 | + | ||
63 | +/** | ||
64 | + * vaddr: | ||
65 | + * Type wide enough to contain any #target_ulong virtual address. | ||
66 | + */ | ||
67 | +typedef uint64_t vaddr; | ||
68 | +#define VADDR_PRId PRId64 | ||
69 | +#define VADDR_PRIu PRIu64 | ||
70 | +#define VADDR_PRIo PRIo64 | ||
71 | +#define VADDR_PRIx PRIx64 | ||
72 | +#define VADDR_PRIX PRIX64 | ||
73 | +#define VADDR_MAX UINT64_MAX | ||
74 | + | ||
75 | +#endif | ||
76 | -- | ||
77 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | 1 | When allocating new temps during tcg_optmize, do not re-use |
---|---|---|---|
2 | any EBB temps that were used within the TB. We do not have | ||
3 | any idea what span of the TB in which the temp was live. | ||
2 | 4 | ||
3 | tcg/ should not depend on accel/tcg/, but perf and debuginfo | 5 | Introduce tcg_temp_ebb_reset_freed and use before tcg_optimize, |
4 | support provided by the latter are being used by tcg/tcg.c. | 6 | as well as replacing the equivalent in plugin_gen_inject and |
7 | tcg_func_start. | ||
5 | 8 | ||
6 | Since that's the only user, move both to tcg/. | 9 | Cc: qemu-stable@nongnu.org |
10 | Fixes: fb04ab7ddd8 ("tcg/optimize: Lower TCG_COND_TST{EQ,NE} if unsupported") | ||
11 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2711 | ||
12 | Reported-by: wannacu <wannacu2049@gmail.com> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
16 | --- | ||
17 | include/tcg/tcg-temp-internal.h | 6 ++++++ | ||
18 | accel/tcg/plugin-gen.c | 2 +- | ||
19 | tcg/tcg.c | 5 ++++- | ||
20 | 3 files changed, 11 insertions(+), 2 deletions(-) | ||
7 | 21 | ||
8 | Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 22 | diff --git a/include/tcg/tcg-temp-internal.h b/include/tcg/tcg-temp-internal.h |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-ID: <20231212003837.64090-5-iii@linux.ibm.com> | ||
13 | Message-Id: <20240125054631.78867-5-philmd@linaro.org> | ||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | --- | ||
16 | {accel => include}/tcg/debuginfo.h | 4 ++-- | ||
17 | {accel => include}/tcg/perf.h | 4 ++-- | ||
18 | accel/tcg/translate-all.c | 2 +- | ||
19 | hw/core/loader.c | 2 +- | ||
20 | linux-user/elfload.c | 2 +- | ||
21 | linux-user/exit.c | 2 +- | ||
22 | linux-user/main.c | 2 +- | ||
23 | system/vl.c | 2 +- | ||
24 | {accel/tcg => tcg}/debuginfo.c | 3 +-- | ||
25 | {accel/tcg => tcg}/perf.c | 7 +++---- | ||
26 | tcg/tcg.c | 2 +- | ||
27 | accel/tcg/meson.build | 4 ---- | ||
28 | tcg/meson.build | 5 +++++ | ||
29 | 13 files changed, 20 insertions(+), 21 deletions(-) | ||
30 | rename {accel => include}/tcg/debuginfo.h (96%) | ||
31 | rename {accel => include}/tcg/perf.h (95%) | ||
32 | rename {accel/tcg => tcg}/debuginfo.c (98%) | ||
33 | rename {accel/tcg => tcg}/perf.c (99%) | ||
34 | |||
35 | diff --git a/accel/tcg/debuginfo.h b/include/tcg/debuginfo.h | ||
36 | similarity index 96% | ||
37 | rename from accel/tcg/debuginfo.h | ||
38 | rename to include/tcg/debuginfo.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/accel/tcg/debuginfo.h | 24 | --- a/include/tcg/tcg-temp-internal.h |
41 | +++ b/include/tcg/debuginfo.h | 25 | +++ b/include/tcg/tcg-temp-internal.h |
42 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ TCGv_i64 tcg_temp_ebb_new_i64(void); |
43 | * SPDX-License-Identifier: GPL-2.0-or-later | 27 | TCGv_ptr tcg_temp_ebb_new_ptr(void); |
44 | */ | 28 | TCGv_i128 tcg_temp_ebb_new_i128(void); |
45 | 29 | ||
46 | -#ifndef ACCEL_TCG_DEBUGINFO_H | 30 | +/* Forget all freed EBB temps, so that new allocations produce new temps. */ |
47 | -#define ACCEL_TCG_DEBUGINFO_H | 31 | +static inline void tcg_temp_ebb_reset_freed(TCGContext *s) |
48 | +#ifndef TCG_DEBUGINFO_H | 32 | +{ |
49 | +#define TCG_DEBUGINFO_H | 33 | + memset(s->free_temps, 0, sizeof(s->free_temps)); |
50 | 34 | +} | |
51 | #include "qemu/bitops.h" | 35 | + |
52 | 36 | #endif /* TCG_TEMP_FREE_H */ | |
53 | diff --git a/accel/tcg/perf.h b/include/tcg/perf.h | 37 | diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c |
54 | similarity index 95% | ||
55 | rename from accel/tcg/perf.h | ||
56 | rename to include/tcg/perf.h | ||
57 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
58 | --- a/accel/tcg/perf.h | 39 | --- a/accel/tcg/plugin-gen.c |
59 | +++ b/include/tcg/perf.h | 40 | +++ b/accel/tcg/plugin-gen.c |
60 | @@ -XXX,XX +XXX,XX @@ | 41 | @@ -XXX,XX +XXX,XX @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) |
61 | * SPDX-License-Identifier: GPL-2.0-or-later | 42 | * that might be live within the existing opcode stream. |
62 | */ | 43 | * The simplest solution is to release them all and create new. |
63 | 44 | */ | |
64 | -#ifndef ACCEL_TCG_PERF_H | 45 | - memset(tcg_ctx->free_temps, 0, sizeof(tcg_ctx->free_temps)); |
65 | -#define ACCEL_TCG_PERF_H | 46 | + tcg_temp_ebb_reset_freed(tcg_ctx); |
66 | +#ifndef TCG_PERF_H | 47 | |
67 | +#define TCG_PERF_H | 48 | QTAILQ_FOREACH_SAFE(op, &tcg_ctx->ops, link, next) { |
68 | 49 | switch (op->opc) { | |
69 | #if defined(CONFIG_TCG) && defined(CONFIG_LINUX) | ||
70 | /* Start writing perf-<pid>.map. */ | ||
71 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/accel/tcg/translate-all.c | ||
74 | +++ b/accel/tcg/translate-all.c | ||
75 | @@ -XXX,XX +XXX,XX @@ | ||
76 | #include "tb-context.h" | ||
77 | #include "internal-common.h" | ||
78 | #include "internal-target.h" | ||
79 | -#include "perf.h" | ||
80 | +#include "tcg/perf.h" | ||
81 | #include "tcg/insn-start-words.h" | ||
82 | |||
83 | TBContext tb_ctx; | ||
84 | diff --git a/hw/core/loader.c b/hw/core/loader.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/hw/core/loader.c | ||
87 | +++ b/hw/core/loader.c | ||
88 | @@ -XXX,XX +XXX,XX @@ | ||
89 | #include "hw/boards.h" | ||
90 | #include "qemu/cutils.h" | ||
91 | #include "sysemu/runstate.h" | ||
92 | -#include "accel/tcg/debuginfo.h" | ||
93 | +#include "tcg/debuginfo.h" | ||
94 | |||
95 | #include <zlib.h> | ||
96 | |||
97 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | ||
98 | index XXXXXXX..XXXXXXX 100644 | ||
99 | --- a/linux-user/elfload.c | ||
100 | +++ b/linux-user/elfload.c | ||
101 | @@ -XXX,XX +XXX,XX @@ | ||
102 | #include "qapi/error.h" | ||
103 | #include "qemu/error-report.h" | ||
104 | #include "target_signal.h" | ||
105 | -#include "accel/tcg/debuginfo.h" | ||
106 | +#include "tcg/debuginfo.h" | ||
107 | |||
108 | #ifdef TARGET_ARM | ||
109 | #include "target/arm/cpu-features.h" | ||
110 | diff --git a/linux-user/exit.c b/linux-user/exit.c | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/linux-user/exit.c | ||
113 | +++ b/linux-user/exit.c | ||
114 | @@ -XXX,XX +XXX,XX @@ | ||
115 | * along with this program; if not, see <http://www.gnu.org/licenses/>. | ||
116 | */ | ||
117 | #include "qemu/osdep.h" | ||
118 | -#include "accel/tcg/perf.h" | ||
119 | +#include "tcg/perf.h" | ||
120 | #include "gdbstub/syscalls.h" | ||
121 | #include "qemu.h" | ||
122 | #include "user-internals.h" | ||
123 | diff --git a/linux-user/main.c b/linux-user/main.c | ||
124 | index XXXXXXX..XXXXXXX 100644 | ||
125 | --- a/linux-user/main.c | ||
126 | +++ b/linux-user/main.c | ||
127 | @@ -XXX,XX +XXX,XX @@ | ||
128 | #include "signal-common.h" | ||
129 | #include "loader.h" | ||
130 | #include "user-mmap.h" | ||
131 | -#include "accel/tcg/perf.h" | ||
132 | +#include "tcg/perf.h" | ||
133 | |||
134 | #ifdef CONFIG_SEMIHOSTING | ||
135 | #include "semihosting/semihost.h" | ||
136 | diff --git a/system/vl.c b/system/vl.c | ||
137 | index XXXXXXX..XXXXXXX 100644 | ||
138 | --- a/system/vl.c | ||
139 | +++ b/system/vl.c | ||
140 | @@ -XXX,XX +XXX,XX @@ | ||
141 | #endif | ||
142 | #include "sysemu/qtest.h" | ||
143 | #ifdef CONFIG_TCG | ||
144 | -#include "accel/tcg/perf.h" | ||
145 | +#include "tcg/perf.h" | ||
146 | #endif | ||
147 | |||
148 | #include "disas/disas.h" | ||
149 | diff --git a/accel/tcg/debuginfo.c b/tcg/debuginfo.c | ||
150 | similarity index 98% | ||
151 | rename from accel/tcg/debuginfo.c | ||
152 | rename to tcg/debuginfo.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/accel/tcg/debuginfo.c | ||
155 | +++ b/tcg/debuginfo.c | ||
156 | @@ -XXX,XX +XXX,XX @@ | ||
157 | |||
158 | #include "qemu/osdep.h" | ||
159 | #include "qemu/lockable.h" | ||
160 | +#include "tcg/debuginfo.h" | ||
161 | |||
162 | #include <elfutils/libdwfl.h> | ||
163 | |||
164 | -#include "debuginfo.h" | ||
165 | - | ||
166 | static QemuMutex lock; | ||
167 | static Dwfl *dwfl; | ||
168 | static const Dwfl_Callbacks dwfl_callbacks = { | ||
169 | diff --git a/accel/tcg/perf.c b/tcg/perf.c | ||
170 | similarity index 99% | ||
171 | rename from accel/tcg/perf.c | ||
172 | rename to tcg/perf.c | ||
173 | index XXXXXXX..XXXXXXX 100644 | ||
174 | --- a/accel/tcg/perf.c | ||
175 | +++ b/tcg/perf.c | ||
176 | @@ -XXX,XX +XXX,XX @@ | ||
177 | #include "qemu/osdep.h" | ||
178 | #include "elf.h" | ||
179 | #include "exec/target_page.h" | ||
180 | -#include "exec/exec-all.h" | ||
181 | +#include "exec/translation-block.h" | ||
182 | #include "qemu/timer.h" | ||
183 | +#include "tcg/debuginfo.h" | ||
184 | +#include "tcg/perf.h" | ||
185 | #include "tcg/tcg.h" | ||
186 | |||
187 | -#include "debuginfo.h" | ||
188 | -#include "perf.h" | ||
189 | - | ||
190 | static FILE *safe_fopen_w(const char *path) | ||
191 | { | ||
192 | int saved_errno; | ||
193 | diff --git a/tcg/tcg.c b/tcg/tcg.c | 50 | diff --git a/tcg/tcg.c b/tcg/tcg.c |
194 | index XXXXXXX..XXXXXXX 100644 | 51 | index XXXXXXX..XXXXXXX 100644 |
195 | --- a/tcg/tcg.c | 52 | --- a/tcg/tcg.c |
196 | +++ b/tcg/tcg.c | 53 | +++ b/tcg/tcg.c |
197 | @@ -XXX,XX +XXX,XX @@ | 54 | @@ -XXX,XX +XXX,XX @@ void tcg_func_start(TCGContext *s) |
198 | #include "tcg/tcg-ldst.h" | 55 | s->nb_temps = s->nb_globals; |
199 | #include "tcg/tcg-temp-internal.h" | 56 | |
200 | #include "tcg-internal.h" | 57 | /* No temps have been previously allocated for size or locality. */ |
201 | -#include "accel/tcg/perf.h" | 58 | - memset(s->free_temps, 0, sizeof(s->free_temps)); |
202 | +#include "tcg/perf.h" | 59 | + tcg_temp_ebb_reset_freed(s); |
203 | #ifdef CONFIG_USER_ONLY | 60 | |
204 | #include "exec/user/guest-base.h" | 61 | /* No constant temps have been previously allocated. */ |
62 | for (int i = 0; i < TCG_TYPE_COUNT; ++i) { | ||
63 | @@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, uint64_t pc_start) | ||
64 | } | ||
205 | #endif | 65 | #endif |
206 | diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build | 66 | |
207 | index XXXXXXX..XXXXXXX 100644 | 67 | + /* Do not reuse any EBB that may be allocated within the TB. */ |
208 | --- a/accel/tcg/meson.build | 68 | + tcg_temp_ebb_reset_freed(s); |
209 | +++ b/accel/tcg/meson.build | ||
210 | @@ -XXX,XX +XXX,XX @@ tcg_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files('user-exec-stub.c')) | ||
211 | if get_option('plugins') | ||
212 | tcg_ss.add(files('plugin-gen.c')) | ||
213 | endif | ||
214 | -tcg_ss.add(when: libdw, if_true: files('debuginfo.c')) | ||
215 | -if host_os == 'linux' | ||
216 | - tcg_ss.add(files('perf.c')) | ||
217 | -endif | ||
218 | specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) | ||
219 | |||
220 | specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files( | ||
221 | diff --git a/tcg/meson.build b/tcg/meson.build | ||
222 | index XXXXXXX..XXXXXXX 100644 | ||
223 | --- a/tcg/meson.build | ||
224 | +++ b/tcg/meson.build | ||
225 | @@ -XXX,XX +XXX,XX @@ if get_option('tcg_interpreter') | ||
226 | tcg_ss.add(files('tci.c')) | ||
227 | endif | ||
228 | |||
229 | +tcg_ss.add(when: libdw, if_true: files('debuginfo.c')) | ||
230 | +if host_os == 'linux' | ||
231 | + tcg_ss.add(files('perf.c')) | ||
232 | +endif | ||
233 | + | 69 | + |
234 | tcg_ss = tcg_ss.apply({}) | 70 | tcg_optimize(s); |
235 | 71 | ||
236 | libtcg_user = static_library('tcg_user', | 72 | reachable_code_pass(s); |
237 | -- | 73 | -- |
238 | 2.34.1 | 74 | 2.43.0 |
239 | 75 | ||
240 | 76 | diff view generated by jsdifflib |
1 | From: Anton Johansson <anjo@rev.ng> | 1 | From: Roman Artemev <roman.artemev@syntacore.com> |
---|---|---|---|
2 | 2 | ||
3 | cpu-common.h is only needed for vaddr | 3 | On RISC-V to StoreStore barrier corresponds |
4 | `fence w, w` not `fence r, r` | ||
4 | 5 | ||
5 | Signed-off-by: Anton Johansson <anjo@rev.ng> | 6 | Cc: qemu-stable@nongnu.org |
6 | Message-Id: <20240119144024.14289-8-anjo@rev.ng> | 7 | Fixes: efbea94c76b ("tcg/riscv: Add slowpath load and store instructions") |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Signed-off-by: Denis Tomashev <denis.tomashev@syntacore.com> | ||
10 | Signed-off-by: Roman Artemev <roman.artemev@syntacore.com> | ||
11 | Message-ID: <e2f2131e294a49e79959d4fa9ec02cf4@syntacore.com> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | --- | 13 | --- |
10 | include/hw/core/cpu.h | 2 +- | 14 | tcg/riscv/tcg-target.c.inc | 2 +- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 15 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 16 | ||
13 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h | 17 | diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/hw/core/cpu.h | 19 | --- a/tcg/riscv/tcg-target.c.inc |
16 | +++ b/include/hw/core/cpu.h | 20 | +++ b/tcg/riscv/tcg-target.c.inc |
17 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) |
18 | 22 | insn |= 0x02100000; | |
19 | #include "hw/qdev-core.h" | 23 | } |
20 | #include "disas/dis-asm.h" | 24 | if (a0 & TCG_MO_ST_ST) { |
21 | -#include "exec/cpu-common.h" | 25 | - insn |= 0x02200000; |
22 | #include "exec/hwaddr.h" | 26 | + insn |= 0x01100000; |
23 | +#include "exec/vaddr.h" | 27 | } |
24 | #include "exec/memattrs.h" | 28 | tcg_out32(s, insn); |
25 | #include "exec/tlb-common.h" | 29 | } |
26 | #include "qapi/qapi-types-run-state.h" | ||
27 | -- | 30 | -- |
28 | 2.34.1 | 31 | 2.43.0 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Anton Johansson <anjo@rev.ng> | ||
2 | 1 | ||
3 | Makes gen_intermediate_code() signature target agnostic so the function | ||
4 | can be called from accel/tcg/translate-all.c without target specifics. | ||
5 | |||
6 | Signed-off-by: Anton Johansson <anjo@rev.ng> | ||
7 | Message-Id: <20240119144024.14289-9-anjo@rev.ng> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | include/exec/translator.h | 2 +- | ||
12 | target/alpha/translate.c | 2 +- | ||
13 | target/arm/tcg/translate.c | 2 +- | ||
14 | target/avr/translate.c | 2 +- | ||
15 | target/cris/translate.c | 2 +- | ||
16 | target/hexagon/translate.c | 2 +- | ||
17 | target/hppa/translate.c | 2 +- | ||
18 | target/i386/tcg/translate.c | 2 +- | ||
19 | target/loongarch/tcg/translate.c | 2 +- | ||
20 | target/m68k/translate.c | 2 +- | ||
21 | target/microblaze/translate.c | 2 +- | ||
22 | target/mips/tcg/translate.c | 2 +- | ||
23 | target/nios2/translate.c | 2 +- | ||
24 | target/openrisc/translate.c | 2 +- | ||
25 | target/ppc/translate.c | 2 +- | ||
26 | target/riscv/translate.c | 2 +- | ||
27 | target/rx/translate.c | 2 +- | ||
28 | target/s390x/tcg/translate.c | 2 +- | ||
29 | target/sh4/translate.c | 2 +- | ||
30 | target/sparc/translate.c | 2 +- | ||
31 | target/tricore/translate.c | 2 +- | ||
32 | target/xtensa/translate.c | 2 +- | ||
33 | 22 files changed, 22 insertions(+), 22 deletions(-) | ||
34 | |||
35 | diff --git a/include/exec/translator.h b/include/exec/translator.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/include/exec/translator.h | ||
38 | +++ b/include/exec/translator.h | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | * the target-specific DisasContext, and then invoke translator_loop. | ||
41 | */ | ||
42 | void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, | ||
43 | - target_ulong pc, void *host_pc); | ||
44 | + vaddr pc, void *host_pc); | ||
45 | |||
46 | /** | ||
47 | * DisasJumpType: | ||
48 | diff --git a/target/alpha/translate.c b/target/alpha/translate.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/alpha/translate.c | ||
51 | +++ b/target/alpha/translate.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps alpha_tr_ops = { | ||
53 | }; | ||
54 | |||
55 | void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, | ||
56 | - target_ulong pc, void *host_pc) | ||
57 | + vaddr pc, void *host_pc) | ||
58 | { | ||
59 | DisasContext dc; | ||
60 | translator_loop(cpu, tb, max_insns, pc, host_pc, &alpha_tr_ops, &dc.base); | ||
61 | diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/tcg/translate.c | ||
64 | +++ b/target/arm/tcg/translate.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps thumb_translator_ops = { | ||
66 | |||
67 | /* generate intermediate code for basic block 'tb'. */ | ||
68 | void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, | ||
69 | - target_ulong pc, void *host_pc) | ||
70 | + vaddr pc, void *host_pc) | ||
71 | { | ||
72 | DisasContext dc = { }; | ||
73 | const TranslatorOps *ops = &arm_translator_ops; | ||
74 | diff --git a/target/avr/translate.c b/target/avr/translate.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/target/avr/translate.c | ||
77 | +++ b/target/avr/translate.c | ||
78 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps avr_tr_ops = { | ||
79 | }; | ||
80 | |||
81 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
82 | - target_ulong pc, void *host_pc) | ||
83 | + vaddr pc, void *host_pc) | ||
84 | { | ||
85 | DisasContext dc = { }; | ||
86 | translator_loop(cs, tb, max_insns, pc, host_pc, &avr_tr_ops, &dc.base); | ||
87 | diff --git a/target/cris/translate.c b/target/cris/translate.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/target/cris/translate.c | ||
90 | +++ b/target/cris/translate.c | ||
91 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps cris_tr_ops = { | ||
92 | }; | ||
93 | |||
94 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
95 | - target_ulong pc, void *host_pc) | ||
96 | + vaddr pc, void *host_pc) | ||
97 | { | ||
98 | DisasContext dc; | ||
99 | translator_loop(cs, tb, max_insns, pc, host_pc, &cris_tr_ops, &dc.base); | ||
100 | diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/target/hexagon/translate.c | ||
103 | +++ b/target/hexagon/translate.c | ||
104 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps hexagon_tr_ops = { | ||
105 | }; | ||
106 | |||
107 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
108 | - target_ulong pc, void *host_pc) | ||
109 | + vaddr pc, void *host_pc) | ||
110 | { | ||
111 | DisasContext ctx; | ||
112 | |||
113 | diff --git a/target/hppa/translate.c b/target/hppa/translate.c | ||
114 | index XXXXXXX..XXXXXXX 100644 | ||
115 | --- a/target/hppa/translate.c | ||
116 | +++ b/target/hppa/translate.c | ||
117 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps hppa_tr_ops = { | ||
118 | }; | ||
119 | |||
120 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
121 | - target_ulong pc, void *host_pc) | ||
122 | + vaddr pc, void *host_pc) | ||
123 | { | ||
124 | DisasContext ctx; | ||
125 | translator_loop(cs, tb, max_insns, pc, host_pc, &hppa_tr_ops, &ctx.base); | ||
126 | diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c | ||
127 | index XXXXXXX..XXXXXXX 100644 | ||
128 | --- a/target/i386/tcg/translate.c | ||
129 | +++ b/target/i386/tcg/translate.c | ||
130 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps i386_tr_ops = { | ||
131 | |||
132 | /* generate intermediate code for basic block 'tb'. */ | ||
133 | void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, | ||
134 | - target_ulong pc, void *host_pc) | ||
135 | + vaddr pc, void *host_pc) | ||
136 | { | ||
137 | DisasContext dc; | ||
138 | |||
139 | diff --git a/target/loongarch/tcg/translate.c b/target/loongarch/tcg/translate.c | ||
140 | index XXXXXXX..XXXXXXX 100644 | ||
141 | --- a/target/loongarch/tcg/translate.c | ||
142 | +++ b/target/loongarch/tcg/translate.c | ||
143 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps loongarch_tr_ops = { | ||
144 | }; | ||
145 | |||
146 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
147 | - target_ulong pc, void *host_pc) | ||
148 | + vaddr pc, void *host_pc) | ||
149 | { | ||
150 | DisasContext ctx; | ||
151 | |||
152 | diff --git a/target/m68k/translate.c b/target/m68k/translate.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/m68k/translate.c | ||
155 | +++ b/target/m68k/translate.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps m68k_tr_ops = { | ||
157 | }; | ||
158 | |||
159 | void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, | ||
160 | - target_ulong pc, void *host_pc) | ||
161 | + vaddr pc, void *host_pc) | ||
162 | { | ||
163 | DisasContext dc; | ||
164 | translator_loop(cpu, tb, max_insns, pc, host_pc, &m68k_tr_ops, &dc.base); | ||
165 | diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c | ||
166 | index XXXXXXX..XXXXXXX 100644 | ||
167 | --- a/target/microblaze/translate.c | ||
168 | +++ b/target/microblaze/translate.c | ||
169 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps mb_tr_ops = { | ||
170 | }; | ||
171 | |||
172 | void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, | ||
173 | - target_ulong pc, void *host_pc) | ||
174 | + vaddr pc, void *host_pc) | ||
175 | { | ||
176 | DisasContext dc; | ||
177 | translator_loop(cpu, tb, max_insns, pc, host_pc, &mb_tr_ops, &dc.base); | ||
178 | diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c | ||
179 | index XXXXXXX..XXXXXXX 100644 | ||
180 | --- a/target/mips/tcg/translate.c | ||
181 | +++ b/target/mips/tcg/translate.c | ||
182 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps mips_tr_ops = { | ||
183 | }; | ||
184 | |||
185 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
186 | - target_ulong pc, void *host_pc) | ||
187 | + vaddr pc, void *host_pc) | ||
188 | { | ||
189 | DisasContext ctx; | ||
190 | |||
191 | diff --git a/target/nios2/translate.c b/target/nios2/translate.c | ||
192 | index XXXXXXX..XXXXXXX 100644 | ||
193 | --- a/target/nios2/translate.c | ||
194 | +++ b/target/nios2/translate.c | ||
195 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps nios2_tr_ops = { | ||
196 | }; | ||
197 | |||
198 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
199 | - target_ulong pc, void *host_pc) | ||
200 | + vaddr pc, void *host_pc) | ||
201 | { | ||
202 | DisasContext dc; | ||
203 | translator_loop(cs, tb, max_insns, pc, host_pc, &nios2_tr_ops, &dc.base); | ||
204 | diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c | ||
205 | index XXXXXXX..XXXXXXX 100644 | ||
206 | --- a/target/openrisc/translate.c | ||
207 | +++ b/target/openrisc/translate.c | ||
208 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps openrisc_tr_ops = { | ||
209 | }; | ||
210 | |||
211 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
212 | - target_ulong pc, void *host_pc) | ||
213 | + vaddr pc, void *host_pc) | ||
214 | { | ||
215 | DisasContext ctx; | ||
216 | |||
217 | diff --git a/target/ppc/translate.c b/target/ppc/translate.c | ||
218 | index XXXXXXX..XXXXXXX 100644 | ||
219 | --- a/target/ppc/translate.c | ||
220 | +++ b/target/ppc/translate.c | ||
221 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps ppc_tr_ops = { | ||
222 | }; | ||
223 | |||
224 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
225 | - target_ulong pc, void *host_pc) | ||
226 | + vaddr pc, void *host_pc) | ||
227 | { | ||
228 | DisasContext ctx; | ||
229 | |||
230 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c | ||
231 | index XXXXXXX..XXXXXXX 100644 | ||
232 | --- a/target/riscv/translate.c | ||
233 | +++ b/target/riscv/translate.c | ||
234 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps riscv_tr_ops = { | ||
235 | }; | ||
236 | |||
237 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
238 | - target_ulong pc, void *host_pc) | ||
239 | + vaddr pc, void *host_pc) | ||
240 | { | ||
241 | DisasContext ctx; | ||
242 | |||
243 | diff --git a/target/rx/translate.c b/target/rx/translate.c | ||
244 | index XXXXXXX..XXXXXXX 100644 | ||
245 | --- a/target/rx/translate.c | ||
246 | +++ b/target/rx/translate.c | ||
247 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps rx_tr_ops = { | ||
248 | }; | ||
249 | |||
250 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
251 | - target_ulong pc, void *host_pc) | ||
252 | + vaddr pc, void *host_pc) | ||
253 | { | ||
254 | DisasContext dc; | ||
255 | |||
256 | diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c | ||
257 | index XXXXXXX..XXXXXXX 100644 | ||
258 | --- a/target/s390x/tcg/translate.c | ||
259 | +++ b/target/s390x/tcg/translate.c | ||
260 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps s390x_tr_ops = { | ||
261 | }; | ||
262 | |||
263 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
264 | - target_ulong pc, void *host_pc) | ||
265 | + vaddr pc, void *host_pc) | ||
266 | { | ||
267 | DisasContext dc; | ||
268 | |||
269 | diff --git a/target/sh4/translate.c b/target/sh4/translate.c | ||
270 | index XXXXXXX..XXXXXXX 100644 | ||
271 | --- a/target/sh4/translate.c | ||
272 | +++ b/target/sh4/translate.c | ||
273 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps sh4_tr_ops = { | ||
274 | }; | ||
275 | |||
276 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
277 | - target_ulong pc, void *host_pc) | ||
278 | + vaddr pc, void *host_pc) | ||
279 | { | ||
280 | DisasContext ctx; | ||
281 | |||
282 | diff --git a/target/sparc/translate.c b/target/sparc/translate.c | ||
283 | index XXXXXXX..XXXXXXX 100644 | ||
284 | --- a/target/sparc/translate.c | ||
285 | +++ b/target/sparc/translate.c | ||
286 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps sparc_tr_ops = { | ||
287 | }; | ||
288 | |||
289 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
290 | - target_ulong pc, void *host_pc) | ||
291 | + vaddr pc, void *host_pc) | ||
292 | { | ||
293 | DisasContext dc = {}; | ||
294 | |||
295 | diff --git a/target/tricore/translate.c b/target/tricore/translate.c | ||
296 | index XXXXXXX..XXXXXXX 100644 | ||
297 | --- a/target/tricore/translate.c | ||
298 | +++ b/target/tricore/translate.c | ||
299 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps tricore_tr_ops = { | ||
300 | |||
301 | |||
302 | void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
303 | - target_ulong pc, void *host_pc) | ||
304 | + vaddr pc, void *host_pc) | ||
305 | { | ||
306 | DisasContext ctx; | ||
307 | translator_loop(cs, tb, max_insns, pc, host_pc, | ||
308 | diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c | ||
309 | index XXXXXXX..XXXXXXX 100644 | ||
310 | --- a/target/xtensa/translate.c | ||
311 | +++ b/target/xtensa/translate.c | ||
312 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps xtensa_translator_ops = { | ||
313 | }; | ||
314 | |||
315 | void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, | ||
316 | - target_ulong pc, void *host_pc) | ||
317 | + vaddr pc, void *host_pc) | ||
318 | { | ||
319 | DisasContext dc = {}; | ||
320 | translator_loop(cpu, tb, max_insns, pc, host_pc, | ||
321 | -- | ||
322 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Anton Johansson <anjo@rev.ng> | ||
2 | 1 | ||
3 | Updates target/ QEMU_LOG macros to use VADDR_PRIx for printing updated | ||
4 | DisasContextBase fields. | ||
5 | |||
6 | Signed-off-by: Anton Johansson <anjo@rev.ng> | ||
7 | Message-Id: <20240119144024.14289-10-anjo@rev.ng> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | include/exec/translator.h | 6 +++--- | ||
12 | target/mips/tcg/translate.h | 3 ++- | ||
13 | target/hexagon/translate.c | 3 ++- | ||
14 | target/m68k/translate.c | 2 +- | ||
15 | target/mips/tcg/translate.c | 12 ++++++------ | ||
16 | 5 files changed, 14 insertions(+), 12 deletions(-) | ||
17 | |||
18 | diff --git a/include/exec/translator.h b/include/exec/translator.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/exec/translator.h | ||
21 | +++ b/include/exec/translator.h | ||
22 | @@ -XXX,XX +XXX,XX @@ typedef enum DisasJumpType { | ||
23 | */ | ||
24 | typedef struct DisasContextBase { | ||
25 | TranslationBlock *tb; | ||
26 | - target_ulong pc_first; | ||
27 | - target_ulong pc_next; | ||
28 | + vaddr pc_first; | ||
29 | + vaddr pc_next; | ||
30 | DisasJumpType is_jmp; | ||
31 | int num_insns; | ||
32 | int max_insns; | ||
33 | @@ -XXX,XX +XXX,XX @@ void translator_fake_ldb(uint8_t insn8, abi_ptr pc); | ||
34 | * Translators can use this to enforce the rule that only single-insn | ||
35 | * translation blocks are allowed to cross page boundaries. | ||
36 | */ | ||
37 | -static inline bool is_same_page(const DisasContextBase *db, target_ulong addr) | ||
38 | +static inline bool is_same_page(const DisasContextBase *db, vaddr addr) | ||
39 | { | ||
40 | return ((addr ^ db->pc_first) & TARGET_PAGE_MASK) == 0; | ||
41 | } | ||
42 | diff --git a/target/mips/tcg/translate.h b/target/mips/tcg/translate.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/mips/tcg/translate.h | ||
45 | +++ b/target/mips/tcg/translate.h | ||
46 | @@ -XXX,XX +XXX,XX @@ extern TCGv bcond; | ||
47 | do { \ | ||
48 | if (MIPS_DEBUG_DISAS) { \ | ||
49 | qemu_log_mask(CPU_LOG_TB_IN_ASM, \ | ||
50 | - TARGET_FMT_lx ": %08x Invalid %s %03x %03x %03x\n", \ | ||
51 | + "%016" VADDR_PRIx \ | ||
52 | + ": %08x Invalid %s %03x %03x %03x\n", \ | ||
53 | ctx->base.pc_next, ctx->opcode, op, \ | ||
54 | ctx->opcode >> 26, ctx->opcode & 0x3F, \ | ||
55 | ((ctx->opcode >> 16) & 0x1F)); \ | ||
56 | diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/hexagon/translate.c | ||
59 | +++ b/target/hexagon/translate.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static int read_packet_words(CPUHexagonState *env, DisasContext *ctx, | ||
61 | g_assert(ctx->base.num_insns == 1); | ||
62 | } | ||
63 | |||
64 | - HEX_DEBUG_LOG("decode_packet: pc = 0x%x\n", ctx->base.pc_next); | ||
65 | + HEX_DEBUG_LOG("decode_packet: pc = 0x%" VADDR_PRIx "\n", | ||
66 | + ctx->base.pc_next); | ||
67 | HEX_DEBUG_LOG(" words = { "); | ||
68 | for (int i = 0; i < nwords; i++) { | ||
69 | HEX_DEBUG_LOG("0x%x, ", words[i]); | ||
70 | diff --git a/target/m68k/translate.c b/target/m68k/translate.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/target/m68k/translate.c | ||
73 | +++ b/target/m68k/translate.c | ||
74 | @@ -XXX,XX +XXX,XX @@ DISAS_INSN(undef) | ||
75 | * for the 680x0 series, as well as those that are implemented | ||
76 | * but actually illegal for CPU32 or pre-68020. | ||
77 | */ | ||
78 | - qemu_log_mask(LOG_UNIMP, "Illegal instruction: %04x @ %08x\n", | ||
79 | + qemu_log_mask(LOG_UNIMP, "Illegal instruction: %04x @ %" VADDR_PRIx "\n", | ||
80 | insn, s->base.pc_next); | ||
81 | gen_exception(s, s->base.pc_next, EXCP_ILLEGAL); | ||
82 | } | ||
83 | diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/target/mips/tcg/translate.c | ||
86 | +++ b/target/mips/tcg/translate.c | ||
87 | @@ -XXX,XX +XXX,XX @@ static void gen_compute_branch(DisasContext *ctx, uint32_t opc, | ||
88 | |||
89 | if (ctx->hflags & MIPS_HFLAG_BMASK) { | ||
90 | #ifdef MIPS_DEBUG_DISAS | ||
91 | - LOG_DISAS("Branch in delay / forbidden slot at PC 0x" | ||
92 | - TARGET_FMT_lx "\n", ctx->base.pc_next); | ||
93 | + LOG_DISAS("Branch in delay / forbidden slot at PC 0x%016" | ||
94 | + VADDR_PRIx "\n", ctx->base.pc_next); | ||
95 | #endif | ||
96 | gen_reserved_instruction(ctx); | ||
97 | goto out; | ||
98 | @@ -XXX,XX +XXX,XX @@ static void gen_compute_branch1_r6(DisasContext *ctx, uint32_t op, | ||
99 | |||
100 | if (ctx->hflags & MIPS_HFLAG_BMASK) { | ||
101 | #ifdef MIPS_DEBUG_DISAS | ||
102 | - LOG_DISAS("Branch in delay / forbidden slot at PC 0x" TARGET_FMT_lx | ||
103 | - "\n", ctx->base.pc_next); | ||
104 | + LOG_DISAS("Branch in delay / forbidden slot at PC 0x%016" | ||
105 | + VADDR_PRIx "\n", ctx->base.pc_next); | ||
106 | #endif | ||
107 | gen_reserved_instruction(ctx); | ||
108 | return; | ||
109 | @@ -XXX,XX +XXX,XX @@ static void gen_compute_compact_branch(DisasContext *ctx, uint32_t opc, | ||
110 | |||
111 | if (ctx->hflags & MIPS_HFLAG_BMASK) { | ||
112 | #ifdef MIPS_DEBUG_DISAS | ||
113 | - LOG_DISAS("Branch in delay / forbidden slot at PC 0x" TARGET_FMT_lx | ||
114 | - "\n", ctx->base.pc_next); | ||
115 | + LOG_DISAS("Branch in delay / forbidden slot at PC 0x%016" | ||
116 | + VADDR_PRIx "\n", ctx->base.pc_next); | ||
117 | #endif | ||
118 | gen_reserved_instruction(ctx); | ||
119 | return; | ||
120 | -- | ||
121 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Anton Johansson <anjo@rev.ng> | ||
2 | 1 | ||
3 | Signed-off-by: Anton Johansson <anjo@rev.ng> | ||
4 | Message-Id: <20240119144024.14289-11-anjo@rev.ng> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | include/exec/cpu_ldst.h | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/include/exec/cpu_ldst.h | ||
14 | +++ b/include/exec/cpu_ldst.h | ||
15 | @@ -XXX,XX +XXX,XX @@ static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len) | ||
16 | h2g_nocheck(x); \ | ||
17 | }) | ||
18 | #else | ||
19 | -typedef target_ulong abi_ptr; | ||
20 | -#define TARGET_ABI_FMT_ptr TARGET_FMT_lx | ||
21 | +typedef vaddr abi_ptr; | ||
22 | +#define TARGET_ABI_FMT_ptr VADDR_PRIx | ||
23 | #endif | ||
24 | |||
25 | uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr); | ||
26 | -- | ||
27 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Anton Johansson <anjo@rev.ng> | ||
2 | 1 | ||
3 | These don't vary across targets and are used in soon-to-be common code | ||
4 | (cputlb.c). | ||
5 | |||
6 | Signed-off-by: Anton Johansson <anjo@rev.ng> | ||
7 | Message-Id: <20240119144024.14289-15-anjo@rev.ng> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | include/exec/cpu-all.h | 24 ------------------------ | ||
12 | include/exec/cpu-common.h | 30 ++++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 30 insertions(+), 24 deletions(-) | ||
14 | |||
15 | diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/exec/cpu-all.h | ||
18 | +++ b/include/exec/cpu-all.h | ||
19 | @@ -XXX,XX +XXX,XX @@ extern const TargetPageBits target_page; | ||
20 | |||
21 | #define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE) | ||
22 | |||
23 | -/* same as PROT_xxx */ | ||
24 | -#define PAGE_READ 0x0001 | ||
25 | -#define PAGE_WRITE 0x0002 | ||
26 | -#define PAGE_EXEC 0x0004 | ||
27 | -#define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC) | ||
28 | -#define PAGE_VALID 0x0008 | ||
29 | -/* | ||
30 | - * Original state of the write flag (used when tracking self-modifying code) | ||
31 | - */ | ||
32 | -#define PAGE_WRITE_ORG 0x0010 | ||
33 | -/* | ||
34 | - * Invalidate the TLB entry immediately, helpful for s390x | ||
35 | - * Low-Address-Protection. Used with PAGE_WRITE in tlb_set_page_with_attrs() | ||
36 | - */ | ||
37 | -#define PAGE_WRITE_INV 0x0020 | ||
38 | -/* For use with page_set_flags: page is being replaced; target_data cleared. */ | ||
39 | -#define PAGE_RESET 0x0040 | ||
40 | -/* For linux-user, indicates that the page is MAP_ANON. */ | ||
41 | -#define PAGE_ANON 0x0080 | ||
42 | - | ||
43 | #if defined(CONFIG_BSD) && defined(CONFIG_USER_ONLY) | ||
44 | /* FIXME: Code that sets/uses this is broken and needs to go away. */ | ||
45 | #define PAGE_RESERVED 0x0100 | ||
46 | #endif | ||
47 | -/* Target-specific bits that will be used via page_get_flags(). */ | ||
48 | -#define PAGE_TARGET_1 0x0200 | ||
49 | -#define PAGE_TARGET_2 0x0400 | ||
50 | - | ||
51 | /* | ||
52 | * For linux-user, indicates that the page is mapped with the same semantics | ||
53 | * in both guest and host. | ||
54 | diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/include/exec/cpu-common.h | ||
57 | +++ b/include/exec/cpu-common.h | ||
58 | @@ -XXX,XX +XXX,XX @@ G_NORETURN void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc); | ||
59 | G_NORETURN void cpu_loop_exit(CPUState *cpu); | ||
60 | G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc); | ||
61 | |||
62 | +/* same as PROT_xxx */ | ||
63 | +#define PAGE_READ 0x0001 | ||
64 | +#define PAGE_WRITE 0x0002 | ||
65 | +#define PAGE_EXEC 0x0004 | ||
66 | +#define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC) | ||
67 | +#define PAGE_VALID 0x0008 | ||
68 | +/* | ||
69 | + * Original state of the write flag (used when tracking self-modifying code) | ||
70 | + */ | ||
71 | +#define PAGE_WRITE_ORG 0x0010 | ||
72 | +/* | ||
73 | + * Invalidate the TLB entry immediately, helpful for s390x | ||
74 | + * Low-Address-Protection. Used with PAGE_WRITE in tlb_set_page_with_attrs() | ||
75 | + */ | ||
76 | +#define PAGE_WRITE_INV 0x0020 | ||
77 | +/* For use with page_set_flags: page is being replaced; target_data cleared. */ | ||
78 | +#define PAGE_RESET 0x0040 | ||
79 | +/* For linux-user, indicates that the page is MAP_ANON. */ | ||
80 | +#define PAGE_ANON 0x0080 | ||
81 | + | ||
82 | +/* Target-specific bits that will be used via page_get_flags(). */ | ||
83 | +#define PAGE_TARGET_1 0x0200 | ||
84 | +#define PAGE_TARGET_2 0x0400 | ||
85 | + | ||
86 | +/* | ||
87 | + * For linux-user, indicates that the page is mapped with the same semantics | ||
88 | + * in both guest and host. | ||
89 | + */ | ||
90 | +#define PAGE_PASSTHROUGH 0x0800 | ||
91 | + | ||
92 | #endif /* CPU_COMMON_H */ | ||
93 | -- | ||
94 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Anton Johansson <anjo@rev.ng> | ||
2 | 1 | ||
3 | Functions are target independent. | ||
4 | |||
5 | Signed-off-by: Anton Johansson <anjo@rev.ng> | ||
6 | Message-Id: <20240119144024.14289-17-anjo@rev.ng> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | include/exec/cpu-all.h | 25 ------------------------- | ||
12 | include/exec/cpu-common.h | 26 ++++++++++++++++++++++++++ | ||
13 | 2 files changed, 26 insertions(+), 25 deletions(-) | ||
14 | |||
15 | diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/exec/cpu-all.h | ||
18 | +++ b/include/exec/cpu-all.h | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline bool tlb_hit(uint64_t tlb_addr, vaddr addr) | ||
20 | |||
21 | #endif /* !CONFIG_USER_ONLY */ | ||
22 | |||
23 | -/* accel/tcg/cpu-exec.c */ | ||
24 | -int cpu_exec(CPUState *cpu); | ||
25 | - | ||
26 | /* Validate correct placement of CPUArchState. */ | ||
27 | QEMU_BUILD_BUG_ON(offsetof(ArchCPU, parent_obj) != 0); | ||
28 | QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState)); | ||
29 | |||
30 | -/** | ||
31 | - * env_archcpu(env) | ||
32 | - * @env: The architecture environment | ||
33 | - * | ||
34 | - * Return the ArchCPU associated with the environment. | ||
35 | - */ | ||
36 | -static inline ArchCPU *env_archcpu(CPUArchState *env) | ||
37 | -{ | ||
38 | - return (void *)env - sizeof(CPUState); | ||
39 | -} | ||
40 | - | ||
41 | -/** | ||
42 | - * env_cpu(env) | ||
43 | - * @env: The architecture environment | ||
44 | - * | ||
45 | - * Return the CPUState associated with the environment. | ||
46 | - */ | ||
47 | -static inline CPUState *env_cpu(CPUArchState *env) | ||
48 | -{ | ||
49 | - return (void *)env - sizeof(CPUState); | ||
50 | -} | ||
51 | - | ||
52 | #endif /* CPU_ALL_H */ | ||
53 | diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/include/exec/cpu-common.h | ||
56 | +++ b/include/exec/cpu-common.h | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | #ifndef CONFIG_USER_ONLY | ||
59 | #include "exec/hwaddr.h" | ||
60 | #endif | ||
61 | +#include "hw/core/cpu.h" | ||
62 | |||
63 | #define EXCP_INTERRUPT 0x10000 /* async interruption */ | ||
64 | #define EXCP_HLT 0x10001 /* hlt instruction reached */ | ||
65 | @@ -XXX,XX +XXX,XX @@ G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc); | ||
66 | */ | ||
67 | #define PAGE_PASSTHROUGH 0x0800 | ||
68 | |||
69 | +/* accel/tcg/cpu-exec.c */ | ||
70 | +int cpu_exec(CPUState *cpu); | ||
71 | + | ||
72 | +/** | ||
73 | + * env_archcpu(env) | ||
74 | + * @env: The architecture environment | ||
75 | + * | ||
76 | + * Return the ArchCPU associated with the environment. | ||
77 | + */ | ||
78 | +static inline ArchCPU *env_archcpu(CPUArchState *env) | ||
79 | +{ | ||
80 | + return (void *)env - sizeof(CPUState); | ||
81 | +} | ||
82 | + | ||
83 | +/** | ||
84 | + * env_cpu(env) | ||
85 | + * @env: The architecture environment | ||
86 | + * | ||
87 | + * Return the CPUState associated with the environment. | ||
88 | + */ | ||
89 | +static inline CPUState *env_cpu(CPUArchState *env) | ||
90 | +{ | ||
91 | + return (void *)env - sizeof(CPUState); | ||
92 | +} | ||
93 | + | ||
94 | #endif /* CPU_COMMON_H */ | ||
95 | -- | ||
96 | 2.34.1 | ||
97 | |||
98 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Anton Johansson <anjo@rev.ng> | ||
2 | 1 | ||
3 | The ifdef out of which it is moved is not quite right: do_interrupt is | ||
4 | only needed for system mode. Move it to the top of a different ifdef | ||
5 | block, which preserves its position within the structure for that case. | ||
6 | |||
7 | Signed-off-by: Anton Johansson <anjo@rev.ng> | ||
8 | Message-Id: <20240119144024.14289-18-anjo@rev.ng> | ||
9 | [rth: Split from a larger patch and simplified.] | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | include/hw/core/tcg-cpu-ops.h | 7 ++----- | ||
13 | 1 file changed, 2 insertions(+), 5 deletions(-) | ||
14 | |||
15 | diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/core/tcg-cpu-ops.h | ||
18 | +++ b/include/hw/core/tcg-cpu-ops.h | ||
19 | @@ -XXX,XX +XXX,XX @@ struct TCGCPUOps { | ||
20 | * cpu execution loop (hack for x86 user mode). | ||
21 | */ | ||
22 | void (*fake_user_interrupt)(CPUState *cpu); | ||
23 | -#else | ||
24 | - /** | ||
25 | - * @do_interrupt: Callback for interrupt handling. | ||
26 | - */ | ||
27 | - void (*do_interrupt)(CPUState *cpu); | ||
28 | #endif /* !CONFIG_USER_ONLY || !TARGET_I386 */ | ||
29 | #ifdef CONFIG_USER_ONLY | ||
30 | /** | ||
31 | @@ -XXX,XX +XXX,XX @@ struct TCGCPUOps { | ||
32 | void (*record_sigbus)(CPUState *cpu, vaddr addr, | ||
33 | MMUAccessType access_type, uintptr_t ra); | ||
34 | #else | ||
35 | + /** @do_interrupt: Callback for interrupt handling. */ | ||
36 | + void (*do_interrupt)(CPUState *cpu); | ||
37 | /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ | ||
38 | bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); | ||
39 | /** | ||
40 | -- | ||
41 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Anton Johansson <anjo@rev.ng> | ||
2 | 1 | ||
3 | Always include fake_user_interrupt in user-only build, despite | ||
4 | only being used for i386. This will enable cpu-exec.c to be | ||
5 | compiled only once. | ||
6 | |||
7 | Signed-off-by: Anton Johansson <anjo@rev.ng> | ||
8 | Message-ID: <20240119144024.14289-18-anjo@rev.ng> | ||
9 | [rth: Split out of a larger patch; remove TARGET_I386 conditional.] | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | include/hw/core/tcg-cpu-ops.h | 5 ++--- | ||
13 | 1 file changed, 2 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/core/tcg-cpu-ops.h | ||
18 | +++ b/include/hw/core/tcg-cpu-ops.h | ||
19 | @@ -XXX,XX +XXX,XX @@ struct TCGCPUOps { | ||
20 | void (*debug_excp_handler)(CPUState *cpu); | ||
21 | |||
22 | #ifdef NEED_CPU_H | ||
23 | -#if defined(CONFIG_USER_ONLY) && defined(TARGET_I386) | ||
24 | +#ifdef CONFIG_USER_ONLY | ||
25 | /** | ||
26 | * @fake_user_interrupt: Callback for 'fake exception' handling. | ||
27 | * | ||
28 | @@ -XXX,XX +XXX,XX @@ struct TCGCPUOps { | ||
29 | * cpu execution loop (hack for x86 user mode). | ||
30 | */ | ||
31 | void (*fake_user_interrupt)(CPUState *cpu); | ||
32 | -#endif /* !CONFIG_USER_ONLY || !TARGET_I386 */ | ||
33 | -#ifdef CONFIG_USER_ONLY | ||
34 | + | ||
35 | /** | ||
36 | * record_sigsegv: | ||
37 | * @cpu: cpu context | ||
38 | -- | ||
39 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
2 | 1 | ||
3 | gdbserver ignores page protection by virtue of using /proc/$pid/mem. | ||
4 | Teach qemu gdbstub to do this too. This will not work if /proc is not | ||
5 | mounted; accept this limitation. | ||
6 | |||
7 | One alternative is to temporarily grant the missing PROT_* bit, but | ||
8 | this is inherently racy. Another alternative is self-debugging with | ||
9 | ptrace(POKE), which will break if QEMU itself is being debugged - a | ||
10 | much more severe limitation. | ||
11 | |||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
14 | Message-Id: <20240129093410.3151-2-iii@linux.ibm.com> | ||
15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | ||
17 | cpu-target.c | 78 ++++++++++++++++++++++++++++++++++++++++++---------- | ||
18 | 1 file changed, 63 insertions(+), 15 deletions(-) | ||
19 | |||
20 | diff --git a/cpu-target.c b/cpu-target.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/cpu-target.c | ||
23 | +++ b/cpu-target.c | ||
24 | @@ -XXX,XX +XXX,XX @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, | ||
25 | vaddr l, page; | ||
26 | void * p; | ||
27 | uint8_t *buf = ptr; | ||
28 | + ssize_t written; | ||
29 | + int ret = -1; | ||
30 | + int fd = -1; | ||
31 | |||
32 | while (len > 0) { | ||
33 | page = addr & TARGET_PAGE_MASK; | ||
34 | @@ -XXX,XX +XXX,XX @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, | ||
35 | if (l > len) | ||
36 | l = len; | ||
37 | flags = page_get_flags(page); | ||
38 | - if (!(flags & PAGE_VALID)) | ||
39 | - return -1; | ||
40 | + if (!(flags & PAGE_VALID)) { | ||
41 | + goto out_close; | ||
42 | + } | ||
43 | if (is_write) { | ||
44 | - if (!(flags & PAGE_WRITE)) | ||
45 | - return -1; | ||
46 | + if (flags & PAGE_WRITE) { | ||
47 | + /* XXX: this code should not depend on lock_user */ | ||
48 | + p = lock_user(VERIFY_WRITE, addr, l, 0); | ||
49 | + if (!p) { | ||
50 | + goto out_close; | ||
51 | + } | ||
52 | + memcpy(p, buf, l); | ||
53 | + unlock_user(p, addr, l); | ||
54 | + } else { | ||
55 | + /* Bypass the host page protection using ptrace. */ | ||
56 | + if (fd == -1) { | ||
57 | + fd = open("/proc/self/mem", O_WRONLY); | ||
58 | + if (fd == -1) { | ||
59 | + goto out; | ||
60 | + } | ||
61 | + } | ||
62 | + /* | ||
63 | + * If there is a TranslationBlock and we weren't bypassing the | ||
64 | + * host page protection, the memcpy() above would SEGV, | ||
65 | + * ultimately leading to page_unprotect(). So invalidate the | ||
66 | + * translations manually. Both invalidation and pwrite() must | ||
67 | + * be under mmap_lock() in order to prevent the creation of | ||
68 | + * another TranslationBlock in between. | ||
69 | + */ | ||
70 | + mmap_lock(); | ||
71 | + tb_invalidate_phys_range(addr, addr + l - 1); | ||
72 | + written = pwrite(fd, buf, l, | ||
73 | + (off_t)(uintptr_t)g2h_untagged(addr)); | ||
74 | + mmap_unlock(); | ||
75 | + if (written != l) { | ||
76 | + goto out_close; | ||
77 | + } | ||
78 | + } | ||
79 | + } else if (flags & PAGE_READ) { | ||
80 | /* XXX: this code should not depend on lock_user */ | ||
81 | - if (!(p = lock_user(VERIFY_WRITE, addr, l, 0))) | ||
82 | - return -1; | ||
83 | - memcpy(p, buf, l); | ||
84 | - unlock_user(p, addr, l); | ||
85 | - } else { | ||
86 | - if (!(flags & PAGE_READ)) | ||
87 | - return -1; | ||
88 | - /* XXX: this code should not depend on lock_user */ | ||
89 | - if (!(p = lock_user(VERIFY_READ, addr, l, 1))) | ||
90 | - return -1; | ||
91 | + p = lock_user(VERIFY_READ, addr, l, 1); | ||
92 | + if (!p) { | ||
93 | + goto out_close; | ||
94 | + } | ||
95 | memcpy(buf, p, l); | ||
96 | unlock_user(p, addr, 0); | ||
97 | + } else { | ||
98 | + /* Bypass the host page protection using ptrace. */ | ||
99 | + if (fd == -1) { | ||
100 | + fd = open("/proc/self/mem", O_RDONLY); | ||
101 | + if (fd == -1) { | ||
102 | + goto out; | ||
103 | + } | ||
104 | + } | ||
105 | + if (pread(fd, buf, l, | ||
106 | + (off_t)(uintptr_t)g2h_untagged(addr)) != l) { | ||
107 | + goto out_close; | ||
108 | + } | ||
109 | } | ||
110 | len -= l; | ||
111 | buf += l; | ||
112 | addr += l; | ||
113 | } | ||
114 | - return 0; | ||
115 | + ret = 0; | ||
116 | +out_close: | ||
117 | + if (fd != -1) { | ||
118 | + close(fd); | ||
119 | + } | ||
120 | +out: | ||
121 | + return ret; | ||
122 | } | ||
123 | #endif | ||
124 | |||
125 | -- | ||
126 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
2 | 1 | ||
3 | Both the report() function as well as the initial gdbstub test sequence | ||
4 | are copy-pasted into ~10 files with slight modifications. This | ||
5 | indicates that they are indeed generic, so factor them out. While | ||
6 | at it, add a few newlines to make the formatting closer to PEP-8. | ||
7 | |||
8 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
9 | Message-Id: <20240129093410.3151-3-iii@linux.ibm.com> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | tests/guest-debug/run-test.py | 7 ++- | ||
13 | tests/guest-debug/test_gdbstub.py | 60 +++++++++++++++++++ | ||
14 | tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 34 +---------- | ||
15 | tests/tcg/aarch64/gdbstub/test-sve.py | 33 +--------- | ||
16 | tests/tcg/multiarch/gdbstub/interrupt.py | 47 ++------------- | ||
17 | tests/tcg/multiarch/gdbstub/memory.py | 39 +----------- | ||
18 | tests/tcg/multiarch/gdbstub/registers.py | 41 ++----------- | ||
19 | tests/tcg/multiarch/gdbstub/sha1.py | 38 ++---------- | ||
20 | .../multiarch/gdbstub/test-proc-mappings.py | 39 +----------- | ||
21 | .../multiarch/gdbstub/test-qxfer-auxv-read.py | 37 +----------- | ||
22 | .../gdbstub/test-thread-breakpoint.py | 37 +----------- | ||
23 | tests/tcg/s390x/gdbstub/test-signals-s390x.py | 42 +------------ | ||
24 | tests/tcg/s390x/gdbstub/test-svc.py | 39 +----------- | ||
25 | 13 files changed, 98 insertions(+), 395 deletions(-) | ||
26 | create mode 100644 tests/guest-debug/test_gdbstub.py | ||
27 | |||
28 | diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py | ||
29 | index XXXXXXX..XXXXXXX 100755 | ||
30 | --- a/tests/guest-debug/run-test.py | ||
31 | +++ b/tests/guest-debug/run-test.py | ||
32 | @@ -XXX,XX +XXX,XX @@ def log(output, msg): | ||
33 | sleep(1) | ||
34 | log(output, "GDB CMD: %s" % (gdb_cmd)) | ||
35 | |||
36 | - result = subprocess.call(gdb_cmd, shell=True, stdout=output, stderr=stderr) | ||
37 | + gdb_env = dict(os.environ) | ||
38 | + gdb_pythonpath = gdb_env.get("PYTHONPATH", "").split(os.pathsep) | ||
39 | + gdb_pythonpath.append(os.path.dirname(os.path.realpath(__file__))) | ||
40 | + gdb_env["PYTHONPATH"] = os.pathsep.join(gdb_pythonpath) | ||
41 | + result = subprocess.call(gdb_cmd, shell=True, stdout=output, stderr=stderr, | ||
42 | + env=gdb_env) | ||
43 | |||
44 | # A result of greater than 128 indicates a fatal signal (likely a | ||
45 | # crash due to gdb internal failure). That's a problem for GDB and | ||
46 | diff --git a/tests/guest-debug/test_gdbstub.py b/tests/guest-debug/test_gdbstub.py | ||
47 | new file mode 100644 | ||
48 | index XXXXXXX..XXXXXXX | ||
49 | --- /dev/null | ||
50 | +++ b/tests/guest-debug/test_gdbstub.py | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | +"""Helper functions for gdbstub testing | ||
53 | + | ||
54 | +""" | ||
55 | +from __future__ import print_function | ||
56 | +import gdb | ||
57 | +import os | ||
58 | +import sys | ||
59 | +import traceback | ||
60 | + | ||
61 | +fail_count = 0 | ||
62 | + | ||
63 | + | ||
64 | +def report(cond, msg): | ||
65 | + """Report success/fail of a test""" | ||
66 | + if cond: | ||
67 | + print("PASS: {}".format(msg)) | ||
68 | + else: | ||
69 | + print("FAIL: {}".format(msg)) | ||
70 | + global fail_count | ||
71 | + fail_count += 1 | ||
72 | + | ||
73 | + | ||
74 | +def main(test, expected_arch=None): | ||
75 | + """Run a test function | ||
76 | + | ||
77 | + This runs as the script it sourced (via -x, via run-test.py).""" | ||
78 | + try: | ||
79 | + inferior = gdb.selected_inferior() | ||
80 | + arch = inferior.architecture() | ||
81 | + print("ATTACHED: {}".format(arch.name())) | ||
82 | + if expected_arch is not None: | ||
83 | + report(arch.name() == expected_arch, | ||
84 | + "connected to {}".format(expected_arch)) | ||
85 | + except (gdb.error, AttributeError): | ||
86 | + print("SKIP: not connected") | ||
87 | + exit(0) | ||
88 | + | ||
89 | + if gdb.parse_and_eval("$pc") == 0: | ||
90 | + print("SKIP: PC not set") | ||
91 | + exit(0) | ||
92 | + | ||
93 | + try: | ||
94 | + test() | ||
95 | + except: | ||
96 | + print("GDB Exception:") | ||
97 | + traceback.print_exc(file=sys.stdout) | ||
98 | + global fail_count | ||
99 | + fail_count += 1 | ||
100 | + if "QEMU_TEST_INTERACTIVE" in os.environ: | ||
101 | + import code | ||
102 | + code.InteractiveConsole(locals=globals()).interact() | ||
103 | + raise | ||
104 | + | ||
105 | + try: | ||
106 | + gdb.execute("kill") | ||
107 | + except gdb.error: | ||
108 | + pass | ||
109 | + | ||
110 | + print("All tests complete: {} failures".format(fail_count)) | ||
111 | + exit(fail_count) | ||
112 | diff --git a/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py b/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | ||
115 | +++ b/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | ||
116 | @@ -XXX,XX +XXX,XX @@ | ||
117 | # | ||
118 | |||
119 | import gdb | ||
120 | -import sys | ||
121 | +from test_gdbstub import main, report | ||
122 | |||
123 | initial_vlen = 0 | ||
124 | -failcount = 0 | ||
125 | |||
126 | -def report(cond, msg): | ||
127 | - "Report success/fail of test" | ||
128 | - if cond: | ||
129 | - print ("PASS: %s" % (msg)) | ||
130 | - else: | ||
131 | - print ("FAIL: %s" % (msg)) | ||
132 | - global failcount | ||
133 | - failcount += 1 | ||
134 | |||
135 | class TestBreakpoint(gdb.Breakpoint): | ||
136 | def __init__(self, sym_name="__sve_ld_done"): | ||
137 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
138 | |||
139 | gdb.execute("c") | ||
140 | |||
141 | -# | ||
142 | -# This runs as the script it sourced (via -x, via run-test.py) | ||
143 | -# | ||
144 | -try: | ||
145 | - inferior = gdb.selected_inferior() | ||
146 | - arch = inferior.architecture() | ||
147 | - report(arch.name() == "aarch64", "connected to aarch64") | ||
148 | -except (gdb.error, AttributeError): | ||
149 | - print("SKIPPING (not connected)", file=sys.stderr) | ||
150 | - exit(0) | ||
151 | |||
152 | -try: | ||
153 | - # Run the actual tests | ||
154 | - run_test() | ||
155 | -except: | ||
156 | - print ("GDB Exception: %s" % (sys.exc_info()[0])) | ||
157 | - failcount += 1 | ||
158 | - import code | ||
159 | - code.InteractiveConsole(locals=globals()).interact() | ||
160 | - raise | ||
161 | - | ||
162 | -print("All tests complete: %d failures" % failcount) | ||
163 | -exit(failcount) | ||
164 | +main(run_test, expected_arch="aarch64") | ||
165 | diff --git a/tests/tcg/aarch64/gdbstub/test-sve.py b/tests/tcg/aarch64/gdbstub/test-sve.py | ||
166 | index XXXXXXX..XXXXXXX 100644 | ||
167 | --- a/tests/tcg/aarch64/gdbstub/test-sve.py | ||
168 | +++ b/tests/tcg/aarch64/gdbstub/test-sve.py | ||
169 | @@ -XXX,XX +XXX,XX @@ | ||
170 | # | ||
171 | |||
172 | import gdb | ||
173 | -import sys | ||
174 | +from test_gdbstub import main, report | ||
175 | |||
176 | MAGIC = 0xDEADBEEF | ||
177 | |||
178 | -failcount = 0 | ||
179 | - | ||
180 | -def report(cond, msg): | ||
181 | - "Report success/fail of test" | ||
182 | - if cond: | ||
183 | - print ("PASS: %s" % (msg)) | ||
184 | - else: | ||
185 | - print ("FAIL: %s" % (msg)) | ||
186 | - global failcount | ||
187 | - failcount += 1 | ||
188 | |||
189 | def run_test(): | ||
190 | "Run through the tests one by one" | ||
191 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
192 | report(str(v.type) == "uint64_t", "size of %s" % (reg)) | ||
193 | report(int(v) == MAGIC, "%s is 0x%x" % (reg, MAGIC)) | ||
194 | |||
195 | -# | ||
196 | -# This runs as the script it sourced (via -x, via run-test.py) | ||
197 | -# | ||
198 | -try: | ||
199 | - inferior = gdb.selected_inferior() | ||
200 | - arch = inferior.architecture() | ||
201 | - report(arch.name() == "aarch64", "connected to aarch64") | ||
202 | -except (gdb.error, AttributeError): | ||
203 | - print("SKIPPING (not connected)", file=sys.stderr) | ||
204 | - exit(0) | ||
205 | |||
206 | -try: | ||
207 | - # Run the actual tests | ||
208 | - run_test() | ||
209 | -except: | ||
210 | - print ("GDB Exception: %s" % (sys.exc_info()[0])) | ||
211 | - failcount += 1 | ||
212 | - | ||
213 | -print("All tests complete: %d failures" % failcount) | ||
214 | - | ||
215 | -exit(failcount) | ||
216 | +main(run_test, expected_arch="aarch64") | ||
217 | diff --git a/tests/tcg/multiarch/gdbstub/interrupt.py b/tests/tcg/multiarch/gdbstub/interrupt.py | ||
218 | index XXXXXXX..XXXXXXX 100644 | ||
219 | --- a/tests/tcg/multiarch/gdbstub/interrupt.py | ||
220 | +++ b/tests/tcg/multiarch/gdbstub/interrupt.py | ||
221 | @@ -XXX,XX +XXX,XX @@ | ||
222 | # | ||
223 | |||
224 | import gdb | ||
225 | -import sys | ||
226 | - | ||
227 | -failcount = 0 | ||
228 | - | ||
229 | - | ||
230 | -def report(cond, msg): | ||
231 | - "Report success/fail of test" | ||
232 | - if cond: | ||
233 | - print("PASS: %s" % (msg)) | ||
234 | - else: | ||
235 | - print("FAIL: %s" % (msg)) | ||
236 | - global failcount | ||
237 | - failcount += 1 | ||
238 | +from test_gdbstub import main, report | ||
239 | |||
240 | |||
241 | def check_interrupt(thread): | ||
242 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
243 | Test if interrupting the code always lands us on the same thread when | ||
244 | running with scheduler-lock enabled. | ||
245 | """ | ||
246 | + if len(gdb.selected_inferior().threads()) == 1: | ||
247 | + print("SKIP: set to run on a single thread") | ||
248 | + exit(0) | ||
249 | |||
250 | gdb.execute("set scheduler-locking on") | ||
251 | for thread in gdb.selected_inferior().threads(): | ||
252 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
253 | "thread %d resumes correctly on interrupt" % thread.num) | ||
254 | |||
255 | |||
256 | -# | ||
257 | -# This runs as the script it sourced (via -x, via run-test.py) | ||
258 | -# | ||
259 | -try: | ||
260 | - inferior = gdb.selected_inferior() | ||
261 | - arch = inferior.architecture() | ||
262 | - print("ATTACHED: %s" % arch.name()) | ||
263 | -except (gdb.error, AttributeError): | ||
264 | - print("SKIPPING (not connected)", file=sys.stderr) | ||
265 | - exit(0) | ||
266 | - | ||
267 | -if gdb.parse_and_eval('$pc') == 0: | ||
268 | - print("SKIP: PC not set") | ||
269 | - exit(0) | ||
270 | -if len(gdb.selected_inferior().threads()) == 1: | ||
271 | - print("SKIP: set to run on a single thread") | ||
272 | - exit(0) | ||
273 | - | ||
274 | -try: | ||
275 | - # Run the actual tests | ||
276 | - run_test() | ||
277 | -except (gdb.error): | ||
278 | - print("GDB Exception: %s" % (sys.exc_info()[0])) | ||
279 | - failcount += 1 | ||
280 | - pass | ||
281 | - | ||
282 | -# Finally kill the inferior and exit gdb with a count of failures | ||
283 | -gdb.execute("kill") | ||
284 | -exit(failcount) | ||
285 | +main(run_test) | ||
286 | diff --git a/tests/tcg/multiarch/gdbstub/memory.py b/tests/tcg/multiarch/gdbstub/memory.py | ||
287 | index XXXXXXX..XXXXXXX 100644 | ||
288 | --- a/tests/tcg/multiarch/gdbstub/memory.py | ||
289 | +++ b/tests/tcg/multiarch/gdbstub/memory.py | ||
290 | @@ -XXX,XX +XXX,XX @@ | ||
291 | |||
292 | import gdb | ||
293 | import sys | ||
294 | - | ||
295 | -failcount = 0 | ||
296 | - | ||
297 | - | ||
298 | -def report(cond, msg): | ||
299 | - "Report success/fail of test" | ||
300 | - if cond: | ||
301 | - print("PASS: %s" % (msg)) | ||
302 | - else: | ||
303 | - print("FAIL: %s" % (msg)) | ||
304 | - global failcount | ||
305 | - failcount += 1 | ||
306 | +from test_gdbstub import main, report | ||
307 | |||
308 | |||
309 | def check_step(): | ||
310 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
311 | |||
312 | report(cbp.hit_count == 0, "didn't reach backstop") | ||
313 | |||
314 | -# | ||
315 | -# This runs as the script it sourced (via -x, via run-test.py) | ||
316 | -# | ||
317 | -try: | ||
318 | - inferior = gdb.selected_inferior() | ||
319 | - arch = inferior.architecture() | ||
320 | - print("ATTACHED: %s" % arch.name()) | ||
321 | -except (gdb.error, AttributeError): | ||
322 | - print("SKIPPING (not connected)", file=sys.stderr) | ||
323 | - exit(0) | ||
324 | |||
325 | -if gdb.parse_and_eval('$pc') == 0: | ||
326 | - print("SKIP: PC not set") | ||
327 | - exit(0) | ||
328 | - | ||
329 | -try: | ||
330 | - # Run the actual tests | ||
331 | - run_test() | ||
332 | -except (gdb.error): | ||
333 | - print("GDB Exception: %s" % (sys.exc_info()[0])) | ||
334 | - failcount += 1 | ||
335 | - pass | ||
336 | - | ||
337 | -# Finally kill the inferior and exit gdb with a count of failures | ||
338 | -gdb.execute("kill") | ||
339 | -exit(failcount) | ||
340 | +main(run_test) | ||
341 | diff --git a/tests/tcg/multiarch/gdbstub/registers.py b/tests/tcg/multiarch/gdbstub/registers.py | ||
342 | index XXXXXXX..XXXXXXX 100644 | ||
343 | --- a/tests/tcg/multiarch/gdbstub/registers.py | ||
344 | +++ b/tests/tcg/multiarch/gdbstub/registers.py | ||
345 | @@ -XXX,XX +XXX,XX @@ | ||
346 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
347 | |||
348 | import gdb | ||
349 | -import sys | ||
350 | import xml.etree.ElementTree as ET | ||
351 | +from test_gdbstub import main, report | ||
352 | + | ||
353 | |||
354 | initial_vlen = 0 | ||
355 | -failcount = 0 | ||
356 | - | ||
357 | -def report(cond, msg): | ||
358 | - "Report success/fail of test." | ||
359 | - if cond: | ||
360 | - print("PASS: %s" % (msg)) | ||
361 | - else: | ||
362 | - print("FAIL: %s" % (msg)) | ||
363 | - global failcount | ||
364 | - failcount += 1 | ||
365 | |||
366 | |||
367 | def fetch_xml_regmap(): | ||
368 | @@ -XXX,XX +XXX,XX @@ def fetch_xml_regmap(): | ||
369 | |||
370 | return reg_map | ||
371 | |||
372 | + | ||
373 | def get_register_by_regnum(reg_map, regnum): | ||
374 | """ | ||
375 | Helper to find a register from the map via its XML regnum | ||
376 | @@ -XXX,XX +XXX,XX @@ def get_register_by_regnum(reg_map, regnum): | ||
377 | return entry | ||
378 | return None | ||
379 | |||
380 | + | ||
381 | def crosscheck_remote_xml(reg_map): | ||
382 | """ | ||
383 | Cross-check the list of remote-registers with the XML info. | ||
384 | @@ -XXX,XX +XXX,XX @@ def crosscheck_remote_xml(reg_map): | ||
385 | elif "seen" not in x_reg: | ||
386 | print(f"{x_reg} wasn't seen in remote-registers") | ||
387 | |||
388 | + | ||
389 | def initial_register_read(reg_map): | ||
390 | """ | ||
391 | Do an initial read of all registers that we know gdb cares about | ||
392 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
393 | complete_and_diff(reg_map) | ||
394 | |||
395 | |||
396 | -# | ||
397 | -# This runs as the script it sourced (via -x, via run-test.py) | ||
398 | -# | ||
399 | -try: | ||
400 | - inferior = gdb.selected_inferior() | ||
401 | - arch = inferior.architecture() | ||
402 | - print("ATTACHED: %s" % arch.name()) | ||
403 | -except (gdb.error, AttributeError): | ||
404 | - print("SKIPPING (not connected)", file=sys.stderr) | ||
405 | - exit(0) | ||
406 | - | ||
407 | -if gdb.parse_and_eval('$pc') == 0: | ||
408 | - print("SKIP: PC not set") | ||
409 | - exit(0) | ||
410 | - | ||
411 | -try: | ||
412 | - run_test() | ||
413 | -except (gdb.error): | ||
414 | - print ("GDB Exception: %s" % (sys.exc_info()[0])) | ||
415 | - failcount += 1 | ||
416 | - pass | ||
417 | - | ||
418 | -print("All tests complete: %d failures" % failcount) | ||
419 | -exit(failcount) | ||
420 | +main(run_test) | ||
421 | diff --git a/tests/tcg/multiarch/gdbstub/sha1.py b/tests/tcg/multiarch/gdbstub/sha1.py | ||
422 | index XXXXXXX..XXXXXXX 100644 | ||
423 | --- a/tests/tcg/multiarch/gdbstub/sha1.py | ||
424 | +++ b/tests/tcg/multiarch/gdbstub/sha1.py | ||
425 | @@ -XXX,XX +XXX,XX @@ | ||
426 | # | ||
427 | |||
428 | import gdb | ||
429 | -import sys | ||
430 | +from test_gdbstub import main, report | ||
431 | + | ||
432 | |||
433 | initial_vlen = 0 | ||
434 | -failcount = 0 | ||
435 | |||
436 | -def report(cond, msg): | ||
437 | - "Report success/fail of test" | ||
438 | - if cond: | ||
439 | - print("PASS: %s" % (msg)) | ||
440 | - else: | ||
441 | - print("FAIL: %s" % (msg)) | ||
442 | - global failcount | ||
443 | - failcount += 1 | ||
444 | |||
445 | def check_break(sym_name): | ||
446 | "Setup breakpoint, continue and check we stopped." | ||
447 | @@ -XXX,XX +XXX,XX @@ def check_break(sym_name): | ||
448 | |||
449 | bp.delete() | ||
450 | |||
451 | + | ||
452 | def run_test(): | ||
453 | "Run through the tests one by one" | ||
454 | |||
455 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
456 | # finally check we don't barf inspecting registers | ||
457 | gdb.execute("info registers") | ||
458 | |||
459 | -# | ||
460 | -# This runs as the script it sourced (via -x, via run-test.py) | ||
461 | -# | ||
462 | -try: | ||
463 | - inferior = gdb.selected_inferior() | ||
464 | - arch = inferior.architecture() | ||
465 | - print("ATTACHED: %s" % arch.name()) | ||
466 | -except (gdb.error, AttributeError): | ||
467 | - print("SKIPPING (not connected)", file=sys.stderr) | ||
468 | - exit(0) | ||
469 | |||
470 | -if gdb.parse_and_eval('$pc') == 0: | ||
471 | - print("SKIP: PC not set") | ||
472 | - exit(0) | ||
473 | - | ||
474 | -try: | ||
475 | - # Run the actual tests | ||
476 | - run_test() | ||
477 | -except (gdb.error): | ||
478 | - print ("GDB Exception: %s" % (sys.exc_info()[0])) | ||
479 | - failcount += 1 | ||
480 | - pass | ||
481 | - | ||
482 | -print("All tests complete: %d failures" % failcount) | ||
483 | -exit(failcount) | ||
484 | +main(run_test) | ||
485 | diff --git a/tests/tcg/multiarch/gdbstub/test-proc-mappings.py b/tests/tcg/multiarch/gdbstub/test-proc-mappings.py | ||
486 | index XXXXXXX..XXXXXXX 100644 | ||
487 | --- a/tests/tcg/multiarch/gdbstub/test-proc-mappings.py | ||
488 | +++ b/tests/tcg/multiarch/gdbstub/test-proc-mappings.py | ||
489 | @@ -XXX,XX +XXX,XX @@ | ||
490 | This runs as a sourced script (via -x, via run-test.py).""" | ||
491 | from __future__ import print_function | ||
492 | import gdb | ||
493 | -import sys | ||
494 | - | ||
495 | - | ||
496 | -n_failures = 0 | ||
497 | - | ||
498 | - | ||
499 | -def report(cond, msg): | ||
500 | - """Report success/fail of a test""" | ||
501 | - if cond: | ||
502 | - print("PASS: {}".format(msg)) | ||
503 | - else: | ||
504 | - print("FAIL: {}".format(msg)) | ||
505 | - global n_failures | ||
506 | - n_failures += 1 | ||
507 | +from test_gdbstub import main, report | ||
508 | |||
509 | |||
510 | def run_test(): | ||
511 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
512 | # report("/sha1" in mappings, "Found the test binary name in the mappings") | ||
513 | |||
514 | |||
515 | -def main(): | ||
516 | - """Prepare the environment and run through the tests""" | ||
517 | - try: | ||
518 | - inferior = gdb.selected_inferior() | ||
519 | - print("ATTACHED: {}".format(inferior.architecture().name())) | ||
520 | - except (gdb.error, AttributeError): | ||
521 | - print("SKIPPING (not connected)") | ||
522 | - exit(0) | ||
523 | - | ||
524 | - if gdb.parse_and_eval('$pc') == 0: | ||
525 | - print("SKIP: PC not set") | ||
526 | - exit(0) | ||
527 | - | ||
528 | - try: | ||
529 | - # Run the actual tests | ||
530 | - run_test() | ||
531 | - except gdb.error: | ||
532 | - report(False, "GDB Exception: {}".format(sys.exc_info()[0])) | ||
533 | - print("All tests complete: %d failures" % n_failures) | ||
534 | - exit(n_failures) | ||
535 | - | ||
536 | - | ||
537 | -main() | ||
538 | +main(run_test) | ||
539 | diff --git a/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py b/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py | ||
540 | index XXXXXXX..XXXXXXX 100644 | ||
541 | --- a/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py | ||
542 | +++ b/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py | ||
543 | @@ -XXX,XX +XXX,XX @@ | ||
544 | # | ||
545 | |||
546 | import gdb | ||
547 | -import sys | ||
548 | +from test_gdbstub import main, report | ||
549 | |||
550 | -failcount = 0 | ||
551 | - | ||
552 | -def report(cond, msg): | ||
553 | - "Report success/fail of test" | ||
554 | - if cond: | ||
555 | - print ("PASS: %s" % (msg)) | ||
556 | - else: | ||
557 | - print ("FAIL: %s" % (msg)) | ||
558 | - global failcount | ||
559 | - failcount += 1 | ||
560 | |||
561 | def run_test(): | ||
562 | "Run through the tests one by one" | ||
563 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
564 | report(isinstance(auxv, str), "Fetched auxv from inferior") | ||
565 | report(auxv.find("sha1"), "Found test binary name in auxv") | ||
566 | |||
567 | -# | ||
568 | -# This runs as the script it sourced (via -x, via run-test.py) | ||
569 | -# | ||
570 | -try: | ||
571 | - inferior = gdb.selected_inferior() | ||
572 | - arch = inferior.architecture() | ||
573 | - print("ATTACHED: %s" % arch.name()) | ||
574 | -except (gdb.error, AttributeError): | ||
575 | - print("SKIPPING (not connected)", file=sys.stderr) | ||
576 | - exit(0) | ||
577 | |||
578 | -if gdb.parse_and_eval('$pc') == 0: | ||
579 | - print("SKIP: PC not set") | ||
580 | - exit(0) | ||
581 | - | ||
582 | -try: | ||
583 | - # Run the actual tests | ||
584 | - run_test() | ||
585 | -except (gdb.error): | ||
586 | - print ("GDB Exception: %s" % (sys.exc_info()[0])) | ||
587 | - failcount += 1 | ||
588 | - pass | ||
589 | - | ||
590 | -print("All tests complete: %d failures" % failcount) | ||
591 | -exit(failcount) | ||
592 | +main(run_test) | ||
593 | diff --git a/tests/tcg/multiarch/gdbstub/test-thread-breakpoint.py b/tests/tcg/multiarch/gdbstub/test-thread-breakpoint.py | ||
594 | index XXXXXXX..XXXXXXX 100644 | ||
595 | --- a/tests/tcg/multiarch/gdbstub/test-thread-breakpoint.py | ||
596 | +++ b/tests/tcg/multiarch/gdbstub/test-thread-breakpoint.py | ||
597 | @@ -XXX,XX +XXX,XX @@ | ||
598 | # | ||
599 | |||
600 | import gdb | ||
601 | -import sys | ||
602 | +from test_gdbstub import main, report | ||
603 | |||
604 | -failcount = 0 | ||
605 | - | ||
606 | -def report(cond, msg): | ||
607 | - "Report success/fail of test" | ||
608 | - if cond: | ||
609 | - print ("PASS: %s" % (msg)) | ||
610 | - else: | ||
611 | - print ("FAIL: %s" % (msg)) | ||
612 | - global failcount | ||
613 | - failcount += 1 | ||
614 | |||
615 | def run_test(): | ||
616 | "Run through the tests one by one" | ||
617 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
618 | frame = gdb.selected_frame() | ||
619 | report(str(frame.function()) == "thread1_func", "break @ %s"%frame) | ||
620 | |||
621 | -# | ||
622 | -# This runs as the script it sourced (via -x, via run-test.py) | ||
623 | -# | ||
624 | -try: | ||
625 | - inferior = gdb.selected_inferior() | ||
626 | - arch = inferior.architecture() | ||
627 | - print("ATTACHED: %s" % arch.name()) | ||
628 | -except (gdb.error, AttributeError): | ||
629 | - print("SKIPPING (not connected)", file=sys.stderr) | ||
630 | - exit(0) | ||
631 | |||
632 | -if gdb.parse_and_eval('$pc') == 0: | ||
633 | - print("SKIP: PC not set") | ||
634 | - exit(0) | ||
635 | - | ||
636 | -try: | ||
637 | - # Run the actual tests | ||
638 | - run_test() | ||
639 | -except (gdb.error): | ||
640 | - print ("GDB Exception: %s" % (sys.exc_info()[0])) | ||
641 | - failcount += 1 | ||
642 | - pass | ||
643 | - | ||
644 | -print("All tests complete: %d failures" % failcount) | ||
645 | -exit(failcount) | ||
646 | +main(run_test) | ||
647 | diff --git a/tests/tcg/s390x/gdbstub/test-signals-s390x.py b/tests/tcg/s390x/gdbstub/test-signals-s390x.py | ||
648 | index XXXXXXX..XXXXXXX 100644 | ||
649 | --- a/tests/tcg/s390x/gdbstub/test-signals-s390x.py | ||
650 | +++ b/tests/tcg/s390x/gdbstub/test-signals-s390x.py | ||
651 | @@ -XXX,XX +XXX,XX @@ | ||
652 | # | ||
653 | |||
654 | import gdb | ||
655 | -import sys | ||
656 | - | ||
657 | -failcount = 0 | ||
658 | - | ||
659 | - | ||
660 | -def report(cond, msg): | ||
661 | - """Report success/fail of test""" | ||
662 | - if cond: | ||
663 | - print("PASS: %s" % (msg)) | ||
664 | - else: | ||
665 | - print("FAIL: %s" % (msg)) | ||
666 | - global failcount | ||
667 | - failcount += 1 | ||
668 | +from test_gdbstub import main, report | ||
669 | |||
670 | |||
671 | def run_test(): | ||
672 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
673 | gdb.Breakpoint("_exit") | ||
674 | gdb.execute("c") | ||
675 | status = int(gdb.parse_and_eval("$r2")) | ||
676 | - report(status == 0, "status == 0"); | ||
677 | + report(status == 0, "status == 0") | ||
678 | |||
679 | |||
680 | -# | ||
681 | -# This runs as the script it sourced (via -x, via run-test.py) | ||
682 | -# | ||
683 | -try: | ||
684 | - inferior = gdb.selected_inferior() | ||
685 | - arch = inferior.architecture() | ||
686 | - print("ATTACHED: %s" % arch.name()) | ||
687 | -except (gdb.error, AttributeError): | ||
688 | - print("SKIPPING (not connected)", file=sys.stderr) | ||
689 | - exit(0) | ||
690 | - | ||
691 | -if gdb.parse_and_eval("$pc") == 0: | ||
692 | - print("SKIP: PC not set") | ||
693 | - exit(0) | ||
694 | - | ||
695 | -try: | ||
696 | - # Run the actual tests | ||
697 | - run_test() | ||
698 | -except (gdb.error): | ||
699 | - print("GDB Exception: %s" % (sys.exc_info()[0])) | ||
700 | - failcount += 1 | ||
701 | - pass | ||
702 | - | ||
703 | -print("All tests complete: %d failures" % failcount) | ||
704 | -exit(failcount) | ||
705 | +main(run_test) | ||
706 | diff --git a/tests/tcg/s390x/gdbstub/test-svc.py b/tests/tcg/s390x/gdbstub/test-svc.py | ||
707 | index XXXXXXX..XXXXXXX 100644 | ||
708 | --- a/tests/tcg/s390x/gdbstub/test-svc.py | ||
709 | +++ b/tests/tcg/s390x/gdbstub/test-svc.py | ||
710 | @@ -XXX,XX +XXX,XX @@ | ||
711 | This runs as a sourced script (via -x, via run-test.py).""" | ||
712 | from __future__ import print_function | ||
713 | import gdb | ||
714 | -import sys | ||
715 | - | ||
716 | - | ||
717 | -n_failures = 0 | ||
718 | - | ||
719 | - | ||
720 | -def report(cond, msg): | ||
721 | - """Report success/fail of a test""" | ||
722 | - if cond: | ||
723 | - print("PASS: {}".format(msg)) | ||
724 | - else: | ||
725 | - print("FAIL: {}".format(msg)) | ||
726 | - global n_failures | ||
727 | - n_failures += 1 | ||
728 | +from test_gdbstub import main, report | ||
729 | |||
730 | |||
731 | def run_test(): | ||
732 | @@ -XXX,XX +XXX,XX @@ def run_test(): | ||
733 | gdb.execute("si") | ||
734 | |||
735 | |||
736 | -def main(): | ||
737 | - """Prepare the environment and run through the tests""" | ||
738 | - try: | ||
739 | - inferior = gdb.selected_inferior() | ||
740 | - print("ATTACHED: {}".format(inferior.architecture().name())) | ||
741 | - except (gdb.error, AttributeError): | ||
742 | - print("SKIPPING (not connected)") | ||
743 | - exit(0) | ||
744 | - | ||
745 | - if gdb.parse_and_eval('$pc') == 0: | ||
746 | - print("SKIP: PC not set") | ||
747 | - exit(0) | ||
748 | - | ||
749 | - try: | ||
750 | - # Run the actual tests | ||
751 | - run_test() | ||
752 | - except gdb.error: | ||
753 | - report(False, "GDB Exception: {}".format(sys.exc_info()[0])) | ||
754 | - print("All tests complete: %d failures" % n_failures) | ||
755 | - exit(n_failures) | ||
756 | - | ||
757 | - | ||
758 | -main() | ||
759 | +main(run_test) | ||
760 | -- | ||
761 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
2 | 1 | ||
3 | Make sure that qemu gdbstub, like gdbserver, allows reading from and | ||
4 | writing to PROT_NONE pages. | ||
5 | |||
6 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
7 | Message-Id: <20240129093410.3151-4-iii@linux.ibm.com> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | tests/tcg/multiarch/prot-none.c | 40 ++++++++++++++++++++++++ | ||
11 | tests/tcg/multiarch/Makefile.target | 9 +++++- | ||
12 | tests/tcg/multiarch/gdbstub/prot-none.py | 36 +++++++++++++++++++++ | ||
13 | 3 files changed, 84 insertions(+), 1 deletion(-) | ||
14 | create mode 100644 tests/tcg/multiarch/prot-none.c | ||
15 | create mode 100644 tests/tcg/multiarch/gdbstub/prot-none.py | ||
16 | |||
17 | diff --git a/tests/tcg/multiarch/prot-none.c b/tests/tcg/multiarch/prot-none.c | ||
18 | new file mode 100644 | ||
19 | index XXXXXXX..XXXXXXX | ||
20 | --- /dev/null | ||
21 | +++ b/tests/tcg/multiarch/prot-none.c | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | +/* | ||
24 | + * Test that GDB can access PROT_NONE pages. | ||
25 | + * | ||
26 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
27 | + */ | ||
28 | +#include <assert.h> | ||
29 | +#include <stdlib.h> | ||
30 | +#include <string.h> | ||
31 | +#include <sys/mman.h> | ||
32 | +#include <unistd.h> | ||
33 | + | ||
34 | +void break_here(void *q) | ||
35 | +{ | ||
36 | +} | ||
37 | + | ||
38 | +int main(void) | ||
39 | +{ | ||
40 | + long pagesize = sysconf(_SC_PAGESIZE); | ||
41 | + void *p, *q; | ||
42 | + int err; | ||
43 | + | ||
44 | + p = mmap(NULL, pagesize * 2, PROT_READ | PROT_WRITE, | ||
45 | + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | ||
46 | + assert(p != MAP_FAILED); | ||
47 | + q = p + pagesize - 1; | ||
48 | + strcpy(q, "42"); | ||
49 | + | ||
50 | + err = mprotect(p, pagesize * 2, PROT_NONE); | ||
51 | + assert(err == 0); | ||
52 | + | ||
53 | + break_here(q); | ||
54 | + | ||
55 | + err = mprotect(p, pagesize * 2, PROT_READ); | ||
56 | + assert(err == 0); | ||
57 | + if (getenv("PROT_NONE_PY")) { | ||
58 | + assert(strcmp(q, "24") == 0); | ||
59 | + } | ||
60 | + | ||
61 | + return EXIT_SUCCESS; | ||
62 | +} | ||
63 | diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/tests/tcg/multiarch/Makefile.target | ||
66 | +++ b/tests/tcg/multiarch/Makefile.target | ||
67 | @@ -XXX,XX +XXX,XX @@ run-gdbstub-registers: sha512 | ||
68 | --bin $< --test $(MULTIARCH_SRC)/gdbstub/registers.py, \ | ||
69 | checking register enumeration) | ||
70 | |||
71 | +run-gdbstub-prot-none: prot-none | ||
72 | + $(call run-test, $@, env PROT_NONE_PY=1 $(GDB_SCRIPT) \ | ||
73 | + --gdb $(GDB) \ | ||
74 | + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ | ||
75 | + --bin $< --test $(MULTIARCH_SRC)/gdbstub/prot-none.py, \ | ||
76 | + accessing PROT_NONE memory) | ||
77 | + | ||
78 | else | ||
79 | run-gdbstub-%: | ||
80 | $(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%,,$(TARGET_NAME)) support") | ||
81 | endif | ||
82 | EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ | ||
83 | run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \ | ||
84 | - run-gdbstub-registers | ||
85 | + run-gdbstub-registers run-gdbstub-prot-none | ||
86 | |||
87 | # ARM Compatible Semi Hosting Tests | ||
88 | # | ||
89 | diff --git a/tests/tcg/multiarch/gdbstub/prot-none.py b/tests/tcg/multiarch/gdbstub/prot-none.py | ||
90 | new file mode 100644 | ||
91 | index XXXXXXX..XXXXXXX | ||
92 | --- /dev/null | ||
93 | +++ b/tests/tcg/multiarch/gdbstub/prot-none.py | ||
94 | @@ -XXX,XX +XXX,XX @@ | ||
95 | +"""Test that GDB can access PROT_NONE pages. | ||
96 | + | ||
97 | +This runs as a sourced script (via -x, via run-test.py). | ||
98 | + | ||
99 | +SPDX-License-Identifier: GPL-2.0-or-later | ||
100 | +""" | ||
101 | +import ctypes | ||
102 | +from test_gdbstub import main, report | ||
103 | + | ||
104 | + | ||
105 | +def probe_proc_self_mem(): | ||
106 | + buf = ctypes.create_string_buffer(b'aaa') | ||
107 | + try: | ||
108 | + with open("/proc/self/mem", "rb") as fp: | ||
109 | + fp.seek(ctypes.addressof(buf)) | ||
110 | + return fp.read(3) == b'aaa' | ||
111 | + except OSError: | ||
112 | + return False | ||
113 | + | ||
114 | + | ||
115 | +def run_test(): | ||
116 | + """Run through the tests one by one""" | ||
117 | + if not probe_proc_self_mem: | ||
118 | + print("SKIP: /proc/self/mem is not usable") | ||
119 | + exit(0) | ||
120 | + gdb.Breakpoint("break_here") | ||
121 | + gdb.execute("continue") | ||
122 | + val = gdb.parse_and_eval("*(char[2] *)q").string() | ||
123 | + report(val == "42", "{} == 42".format(val)) | ||
124 | + gdb.execute("set *(char[3] *)q = \"24\"") | ||
125 | + gdb.execute("continue") | ||
126 | + exitcode = int(gdb.parse_and_eval("$_exitcode")) | ||
127 | + report(exitcode == 0, "{} == 0".format(exitcode)) | ||
128 | + | ||
129 | + | ||
130 | +main(run_test) | ||
131 | -- | ||
132 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
2 | 1 | ||
3 | Replace the manual rcu_read_(un)lock calls in cpu_exec(). | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Message-Id: <20240124074201.8239-2-philmd@linaro.org> | ||
7 | [rth: Use RCU_READ_LOCK_GUARD not WITH_RCU_READ_LOCK_GUARD] | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | accel/tcg/cpu-exec.c | 4 +--- | ||
12 | 1 file changed, 1 insertion(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/accel/tcg/cpu-exec.c | ||
17 | +++ b/accel/tcg/cpu-exec.c | ||
18 | @@ -XXX,XX +XXX,XX @@ int cpu_exec(CPUState *cpu) | ||
19 | return EXCP_HALTED; | ||
20 | } | ||
21 | |||
22 | - rcu_read_lock(); | ||
23 | + RCU_READ_LOCK_GUARD(); | ||
24 | cpu_exec_enter(cpu); | ||
25 | |||
26 | /* | ||
27 | @@ -XXX,XX +XXX,XX @@ int cpu_exec(CPUState *cpu) | ||
28 | ret = cpu_exec_setjmp(cpu, &sc); | ||
29 | |||
30 | cpu_exec_exit(cpu); | ||
31 | - rcu_read_unlock(); | ||
32 | - | ||
33 | return ret; | ||
34 | } | ||
35 | |||
36 | -- | ||
37 | 2.34.1 | ||
38 | |||
39 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
2 | 1 | ||
3 | Currently qemu_target_page_mask() is usable only from the softmmu | ||
4 | code. Make it possible to use it from the *-user code as well. | ||
5 | |||
6 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
7 | Message-ID: <20231208003754.3688038-2-iii@linux.ibm.com> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Message-Id: <20240124075609.14756-2-philmd@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | [rth: Split out change to accel/tcg/perf.c] | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | --- | ||
14 | system/physmem.c | 5 ----- | ||
15 | target/target-common.c | 10 ++++++++++ | ||
16 | target/meson.build | 2 ++ | ||
17 | 3 files changed, 12 insertions(+), 5 deletions(-) | ||
18 | create mode 100644 target/target-common.c | ||
19 | |||
20 | diff --git a/system/physmem.c b/system/physmem.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/system/physmem.c | ||
23 | +++ b/system/physmem.c | ||
24 | @@ -XXX,XX +XXX,XX @@ size_t qemu_target_page_size(void) | ||
25 | return TARGET_PAGE_SIZE; | ||
26 | } | ||
27 | |||
28 | -int qemu_target_page_mask(void) | ||
29 | -{ | ||
30 | - return TARGET_PAGE_MASK; | ||
31 | -} | ||
32 | - | ||
33 | int qemu_target_page_bits(void) | ||
34 | { | ||
35 | return TARGET_PAGE_BITS; | ||
36 | diff --git a/target/target-common.c b/target/target-common.c | ||
37 | new file mode 100644 | ||
38 | index XXXXXXX..XXXXXXX | ||
39 | --- /dev/null | ||
40 | +++ b/target/target-common.c | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
43 | +#include "qemu/osdep.h" | ||
44 | + | ||
45 | +#include "cpu.h" | ||
46 | +#include "exec/target_page.h" | ||
47 | + | ||
48 | +int qemu_target_page_mask(void) | ||
49 | +{ | ||
50 | + return TARGET_PAGE_MASK; | ||
51 | +} | ||
52 | diff --git a/target/meson.build b/target/meson.build | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/meson.build | ||
55 | +++ b/target/meson.build | ||
56 | @@ -XXX,XX +XXX,XX @@ subdir('sh4') | ||
57 | subdir('sparc') | ||
58 | subdir('tricore') | ||
59 | subdir('xtensa') | ||
60 | + | ||
61 | +specific_ss.add(files('target-common.c')) | ||
62 | -- | ||
63 | 2.34.1 | ||
64 | |||
65 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
2 | 1 | ||
3 | Stop using TARGET_PAGE_MASK in order to make perf.c more | ||
4 | target-agnostic. | ||
5 | |||
6 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Message-ID: <20231212003837.64090-2-iii@linux.ibm.com> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-Id: <20240125054631.78867-2-philmd@linaro.org> | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | --- | ||
14 | accel/tcg/perf.c | 3 ++- | ||
15 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/accel/tcg/perf.c b/accel/tcg/perf.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/accel/tcg/perf.c | ||
20 | +++ b/accel/tcg/perf.c | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | |||
23 | #include "qemu/osdep.h" | ||
24 | #include "elf.h" | ||
25 | +#include "exec/target_page.h" | ||
26 | #include "exec/exec-all.h" | ||
27 | #include "qemu/timer.h" | ||
28 | #include "tcg/tcg.h" | ||
29 | @@ -XXX,XX +XXX,XX @@ void perf_report_code(uint64_t guest_pc, TranslationBlock *tb, | ||
30 | /* FIXME: This replicates the restore_state_to_opc() logic. */ | ||
31 | q[insn].address = gen_insn_data[insn * start_words + 0]; | ||
32 | if (tb_cflags(tb) & CF_PCREL) { | ||
33 | - q[insn].address |= (guest_pc & TARGET_PAGE_MASK); | ||
34 | + q[insn].address |= (guest_pc & qemu_target_page_mask()); | ||
35 | } else { | ||
36 | #if defined(TARGET_I386) | ||
37 | q[insn].address -= tb->cs_base; | ||
38 | -- | ||
39 | 2.34.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
2 | 1 | ||
3 | Currently tb_cflags() is defined in exec-all.h, which is not usable | ||
4 | from target-agnostic code. Move it to translation-block.h, which is. | ||
5 | |||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-ID: <20231212003837.64090-3-iii@linux.ibm.com> | ||
10 | Message-Id: <20240125054631.78867-3-philmd@linaro.org> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | include/exec/exec-all.h | 6 ------ | ||
14 | include/exec/translation-block.h | 6 ++++++ | ||
15 | 2 files changed, 6 insertions(+), 6 deletions(-) | ||
16 | |||
17 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/exec/exec-all.h | ||
20 | +++ b/include/exec/exec-all.h | ||
21 | @@ -XXX,XX +XXX,XX @@ int probe_access_full_mmu(CPUArchState *env, vaddr addr, int size, | ||
22 | |||
23 | #endif | ||
24 | |||
25 | -/* Hide the qatomic_read to make code a little easier on the eyes */ | ||
26 | -static inline uint32_t tb_cflags(const TranslationBlock *tb) | ||
27 | -{ | ||
28 | - return qatomic_read(&tb->cflags); | ||
29 | -} | ||
30 | - | ||
31 | static inline tb_page_addr_t tb_page_addr0(const TranslationBlock *tb) | ||
32 | { | ||
33 | #ifdef CONFIG_USER_ONLY | ||
34 | diff --git a/include/exec/translation-block.h b/include/exec/translation-block.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/include/exec/translation-block.h | ||
37 | +++ b/include/exec/translation-block.h | ||
38 | @@ -XXX,XX +XXX,XX @@ struct TranslationBlock { | ||
39 | /* The alignment given to TranslationBlock during allocation. */ | ||
40 | #define CODE_GEN_ALIGN 16 | ||
41 | |||
42 | +/* Hide the qatomic_read to make code a little easier on the eyes */ | ||
43 | +static inline uint32_t tb_cflags(const TranslationBlock *tb) | ||
44 | +{ | ||
45 | + return qatomic_read(&tb->cflags); | ||
46 | +} | ||
47 | + | ||
48 | #endif /* EXEC_TRANSLATION_BLOCK_H */ | ||
49 | -- | ||
50 | 2.34.1 | ||
51 | |||
52 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
2 | 1 | ||
3 | Preparation for moving perf.c to tcg/. | ||
4 | |||
5 | This affects only profiling guest code, which has code in a non-0 based | ||
6 | segment, e.g., 16-bit code, which is not particularly important. | ||
7 | |||
8 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-ID: <20231212003837.64090-4-iii@linux.ibm.com> | ||
13 | Message-Id: <20240125054631.78867-4-philmd@linaro.org> | ||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | --- | ||
16 | accel/tcg/perf.c | 4 ---- | ||
17 | 1 file changed, 4 deletions(-) | ||
18 | |||
19 | diff --git a/accel/tcg/perf.c b/accel/tcg/perf.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/accel/tcg/perf.c | ||
22 | +++ b/accel/tcg/perf.c | ||
23 | @@ -XXX,XX +XXX,XX @@ void perf_report_code(uint64_t guest_pc, TranslationBlock *tb, | ||
24 | q[insn].address = gen_insn_data[insn * start_words + 0]; | ||
25 | if (tb_cflags(tb) & CF_PCREL) { | ||
26 | q[insn].address |= (guest_pc & qemu_target_page_mask()); | ||
27 | - } else { | ||
28 | -#if defined(TARGET_I386) | ||
29 | - q[insn].address -= tb->cs_base; | ||
30 | -#endif | ||
31 | } | ||
32 | q[insn].flags = DEBUGINFO_SYMBOL | (jitdump ? DEBUGINFO_LINE : 0); | ||
33 | } | ||
34 | -- | ||
35 | 2.34.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
2 | 1 | ||
3 | tcg_ss[] source set contains target-specific units. | ||
4 | Rename it as 'tcg_specific_ss[]' for clarity. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Anton Johansson <anjo@rev.ng> | ||
9 | Message-Id: <20240124101639.30056-2-philmd@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | accel/tcg/meson.build | 12 ++++++------ | ||
13 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
14 | |||
15 | diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/accel/tcg/meson.build | ||
18 | +++ b/accel/tcg/meson.build | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | -tcg_ss = ss.source_set() | ||
21 | common_ss.add(when: 'CONFIG_TCG', if_true: files( | ||
22 | 'cpu-exec-common.c', | ||
23 | )) | ||
24 | -tcg_ss.add(files( | ||
25 | +tcg_specific_ss = ss.source_set() | ||
26 | +tcg_specific_ss.add(files( | ||
27 | 'tcg-all.c', | ||
28 | 'cpu-exec.c', | ||
29 | 'tb-maint.c', | ||
30 | @@ -XXX,XX +XXX,XX @@ tcg_ss.add(files( | ||
31 | 'translate-all.c', | ||
32 | 'translator.c', | ||
33 | )) | ||
34 | -tcg_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-exec.c')) | ||
35 | -tcg_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files('user-exec-stub.c')) | ||
36 | +tcg_specific_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-exec.c')) | ||
37 | +tcg_specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files('user-exec-stub.c')) | ||
38 | if get_option('plugins') | ||
39 | - tcg_ss.add(files('plugin-gen.c')) | ||
40 | + tcg_specific_ss.add(files('plugin-gen.c')) | ||
41 | endif | ||
42 | -specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) | ||
43 | +specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss) | ||
44 | |||
45 | specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files( | ||
46 | 'cputlb.c', | ||
47 | -- | ||
48 | 2.34.1 | ||
49 | |||
50 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
2 | 1 | ||
3 | tcg_cpus_destroy() operates on a single vCPU, rename it | ||
4 | as 'tcg_cpu_destroy'. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Anton Johansson <anjo@rev.ng> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-Id: <20240124101639.30056-3-philmd@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | accel/tcg/tcg-accel-ops.h | 2 +- | ||
13 | accel/tcg/tcg-accel-ops-mttcg.c | 2 +- | ||
14 | accel/tcg/tcg-accel-ops-rr.c | 2 +- | ||
15 | accel/tcg/tcg-accel-ops.c | 2 +- | ||
16 | 4 files changed, 4 insertions(+), 4 deletions(-) | ||
17 | |||
18 | diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/accel/tcg/tcg-accel-ops.h | ||
21 | +++ b/accel/tcg/tcg-accel-ops.h | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | |||
24 | #include "sysemu/cpus.h" | ||
25 | |||
26 | -void tcg_cpus_destroy(CPUState *cpu); | ||
27 | +void tcg_cpu_destroy(CPUState *cpu); | ||
28 | int tcg_cpus_exec(CPUState *cpu); | ||
29 | void tcg_handle_interrupt(CPUState *cpu, int mask); | ||
30 | void tcg_cpu_init_cflags(CPUState *cpu, bool parallel); | ||
31 | diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/accel/tcg/tcg-accel-ops-mttcg.c | ||
34 | +++ b/accel/tcg/tcg-accel-ops-mttcg.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void *mttcg_cpu_thread_fn(void *arg) | ||
36 | qemu_wait_io_event(cpu); | ||
37 | } while (!cpu->unplug || cpu_can_run(cpu)); | ||
38 | |||
39 | - tcg_cpus_destroy(cpu); | ||
40 | + tcg_cpu_destroy(cpu); | ||
41 | bql_unlock(); | ||
42 | rcu_remove_force_rcu_notifier(&force_rcu.notifier); | ||
43 | rcu_unregister_thread(); | ||
44 | diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/accel/tcg/tcg-accel-ops-rr.c | ||
47 | +++ b/accel/tcg/tcg-accel-ops-rr.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void rr_deal_with_unplugged_cpus(void) | ||
49 | |||
50 | CPU_FOREACH(cpu) { | ||
51 | if (cpu->unplug && !cpu_can_run(cpu)) { | ||
52 | - tcg_cpus_destroy(cpu); | ||
53 | + tcg_cpu_destroy(cpu); | ||
54 | break; | ||
55 | } | ||
56 | } | ||
57 | diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/accel/tcg/tcg-accel-ops.c | ||
60 | +++ b/accel/tcg/tcg-accel-ops.c | ||
61 | @@ -XXX,XX +XXX,XX @@ void tcg_cpu_init_cflags(CPUState *cpu, bool parallel) | ||
62 | cpu->tcg_cflags |= cflags; | ||
63 | } | ||
64 | |||
65 | -void tcg_cpus_destroy(CPUState *cpu) | ||
66 | +void tcg_cpu_destroy(CPUState *cpu) | ||
67 | { | ||
68 | cpu_thread_signal_destroyed(cpu); | ||
69 | } | ||
70 | -- | ||
71 | 2.34.1 | ||
72 | |||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
2 | 1 | ||
3 | tcg_cpus_exec() operates on a single vCPU, rename it | ||
4 | as 'tcg_cpu_exec'. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Anton Johansson <anjo@rev.ng> | ||
9 | Message-Id: <20240124101639.30056-4-philmd@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | accel/tcg/tcg-accel-ops.h | 2 +- | ||
13 | accel/tcg/tcg-accel-ops-mttcg.c | 2 +- | ||
14 | accel/tcg/tcg-accel-ops-rr.c | 2 +- | ||
15 | accel/tcg/tcg-accel-ops.c | 2 +- | ||
16 | 4 files changed, 4 insertions(+), 4 deletions(-) | ||
17 | |||
18 | diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/accel/tcg/tcg-accel-ops.h | ||
21 | +++ b/accel/tcg/tcg-accel-ops.h | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | #include "sysemu/cpus.h" | ||
24 | |||
25 | void tcg_cpu_destroy(CPUState *cpu); | ||
26 | -int tcg_cpus_exec(CPUState *cpu); | ||
27 | +int tcg_cpu_exec(CPUState *cpu); | ||
28 | void tcg_handle_interrupt(CPUState *cpu, int mask); | ||
29 | void tcg_cpu_init_cflags(CPUState *cpu, bool parallel); | ||
30 | |||
31 | diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/accel/tcg/tcg-accel-ops-mttcg.c | ||
34 | +++ b/accel/tcg/tcg-accel-ops-mttcg.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void *mttcg_cpu_thread_fn(void *arg) | ||
36 | if (cpu_can_run(cpu)) { | ||
37 | int r; | ||
38 | bql_unlock(); | ||
39 | - r = tcg_cpus_exec(cpu); | ||
40 | + r = tcg_cpu_exec(cpu); | ||
41 | bql_lock(); | ||
42 | switch (r) { | ||
43 | case EXCP_DEBUG: | ||
44 | diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/accel/tcg/tcg-accel-ops-rr.c | ||
47 | +++ b/accel/tcg/tcg-accel-ops-rr.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void *rr_cpu_thread_fn(void *arg) | ||
49 | if (icount_enabled()) { | ||
50 | icount_prepare_for_run(cpu, cpu_budget); | ||
51 | } | ||
52 | - r = tcg_cpus_exec(cpu); | ||
53 | + r = tcg_cpu_exec(cpu); | ||
54 | if (icount_enabled()) { | ||
55 | icount_process_data(cpu); | ||
56 | } | ||
57 | diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/accel/tcg/tcg-accel-ops.c | ||
60 | +++ b/accel/tcg/tcg-accel-ops.c | ||
61 | @@ -XXX,XX +XXX,XX @@ void tcg_cpu_destroy(CPUState *cpu) | ||
62 | cpu_thread_signal_destroyed(cpu); | ||
63 | } | ||
64 | |||
65 | -int tcg_cpus_exec(CPUState *cpu) | ||
66 | +int tcg_cpu_exec(CPUState *cpu) | ||
67 | { | ||
68 | int ret; | ||
69 | assert(tcg_enabled()); | ||
70 | -- | ||
71 | 2.34.1 | ||
72 | |||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
2 | 1 | ||
3 | Convert packed logic to dumb icount_exit_request() helper. | ||
4 | No functional change intended. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Anton Johansson <anjo@rev.ng> | ||
9 | Message-Id: <20240124101639.30056-5-philmd@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | accel/tcg/cpu-exec.c | 16 ++++++++++++---- | ||
13 | 1 file changed, 12 insertions(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/accel/tcg/cpu-exec.c | ||
18 | +++ b/accel/tcg/cpu-exec.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline bool need_replay_interrupt(int interrupt_request) | ||
20 | } | ||
21 | #endif /* !CONFIG_USER_ONLY */ | ||
22 | |||
23 | +static inline bool icount_exit_request(CPUState *cpu) | ||
24 | +{ | ||
25 | + if (!icount_enabled()) { | ||
26 | + return false; | ||
27 | + } | ||
28 | + if (cpu->cflags_next_tb != -1 && !(cpu->cflags_next_tb & CF_USE_ICOUNT)) { | ||
29 | + return false; | ||
30 | + } | ||
31 | + return cpu->neg.icount_decr.u16.low + cpu->icount_extra == 0; | ||
32 | +} | ||
33 | + | ||
34 | static inline bool cpu_handle_interrupt(CPUState *cpu, | ||
35 | TranslationBlock **last_tb) | ||
36 | { | ||
37 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_interrupt(CPUState *cpu, | ||
38 | } | ||
39 | |||
40 | /* Finally, check if we need to exit to the main loop. */ | ||
41 | - if (unlikely(qatomic_read(&cpu->exit_request)) | ||
42 | - || (icount_enabled() | ||
43 | - && (cpu->cflags_next_tb == -1 || cpu->cflags_next_tb & CF_USE_ICOUNT) | ||
44 | - && cpu->neg.icount_decr.u16.low + cpu->icount_extra == 0)) { | ||
45 | + if (unlikely(qatomic_read(&cpu->exit_request)) || icount_exit_request(cpu)) { | ||
46 | qatomic_set(&cpu->exit_request, 0); | ||
47 | if (cpu->exception_index == -1) { | ||
48 | cpu->exception_index = EXCP_INTERRUPT; | ||
49 | -- | ||
50 | 2.34.1 | ||
51 | |||
52 | diff view generated by jsdifflib |
1 | QEMU coding style recommends using structure typedefs. | 1 | This allows targets to declare that the helper requires a |
---|---|---|---|
2 | float_status pointer and instead of a generic void pointer. | ||
2 | 3 | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | --- | 6 | --- |
6 | include/hw/core/cpu.h | 5 +---- | 7 | include/exec/helper-head.h.inc | 3 +++ |
7 | include/qemu/typedefs.h | 1 + | 8 | 1 file changed, 3 insertions(+) |
8 | bsd-user/signal.c | 4 ++-- | ||
9 | linux-user/signal.c | 4 ++-- | ||
10 | target/alpha/cpu.c | 2 +- | ||
11 | target/arm/cpu.c | 2 +- | ||
12 | target/arm/tcg/cpu32.c | 2 +- | ||
13 | target/avr/cpu.c | 2 +- | ||
14 | target/cris/cpu.c | 4 ++-- | ||
15 | target/hexagon/cpu.c | 2 +- | ||
16 | target/hppa/cpu.c | 2 +- | ||
17 | target/i386/tcg/tcg-cpu.c | 2 +- | ||
18 | target/loongarch/cpu.c | 2 +- | ||
19 | target/m68k/cpu.c | 2 +- | ||
20 | target/microblaze/cpu.c | 2 +- | ||
21 | target/mips/cpu.c | 2 +- | ||
22 | target/nios2/cpu.c | 2 +- | ||
23 | target/openrisc/cpu.c | 2 +- | ||
24 | target/ppc/cpu_init.c | 2 +- | ||
25 | target/riscv/tcg/tcg-cpu.c | 2 +- | ||
26 | target/rx/cpu.c | 2 +- | ||
27 | target/s390x/cpu.c | 2 +- | ||
28 | target/sh4/cpu.c | 2 +- | ||
29 | target/sparc/cpu.c | 2 +- | ||
30 | target/tricore/cpu.c | 2 +- | ||
31 | target/xtensa/cpu.c | 2 +- | ||
32 | 26 files changed, 29 insertions(+), 31 deletions(-) | ||
33 | 9 | ||
34 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h | 10 | diff --git a/include/exec/helper-head.h.inc b/include/exec/helper-head.h.inc |
35 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/include/hw/core/cpu.h | 12 | --- a/include/exec/helper-head.h.inc |
37 | +++ b/include/hw/core/cpu.h | 13 | +++ b/include/exec/helper-head.h.inc |
38 | @@ -XXX,XX +XXX,XX @@ typedef enum MMUAccessType { | 14 | @@ -XXX,XX +XXX,XX @@ |
39 | 15 | #define dh_alias_ptr ptr | |
40 | typedef struct CPUWatchpoint CPUWatchpoint; | 16 | #define dh_alias_cptr ptr |
41 | 17 | #define dh_alias_env ptr | |
42 | -/* see tcg-cpu-ops.h */ | 18 | +#define dh_alias_fpst ptr |
43 | -struct TCGCPUOps; | 19 | #define dh_alias_void void |
44 | - | 20 | #define dh_alias_noreturn noreturn |
45 | /* see accel-cpu.h */ | 21 | #define dh_alias(t) glue(dh_alias_, t) |
46 | struct AccelCPUClass; | 22 | @@ -XXX,XX +XXX,XX @@ |
47 | 23 | #define dh_ctype_ptr void * | |
48 | @@ -XXX,XX +XXX,XX @@ struct CPUClass { | 24 | #define dh_ctype_cptr const void * |
49 | const struct SysemuCPUOps *sysemu_ops; | 25 | #define dh_ctype_env CPUArchState * |
50 | 26 | +#define dh_ctype_fpst float_status * | |
51 | /* when TCG is not available, this pointer is NULL */ | 27 | #define dh_ctype_void void |
52 | - const struct TCGCPUOps *tcg_ops; | 28 | #define dh_ctype_noreturn G_NORETURN void |
53 | + const TCGCPUOps *tcg_ops; | 29 | #define dh_ctype(t) dh_ctype_##t |
54 | 30 | @@ -XXX,XX +XXX,XX @@ | |
55 | /* | 31 | #define dh_typecode_f64 dh_typecode_i64 |
56 | * if not NULL, this is called in order for the CPUClass to initialize | 32 | #define dh_typecode_cptr dh_typecode_ptr |
57 | diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h | 33 | #define dh_typecode_env dh_typecode_ptr |
58 | index XXXXXXX..XXXXXXX 100644 | 34 | +#define dh_typecode_fpst dh_typecode_ptr |
59 | --- a/include/qemu/typedefs.h | 35 | #define dh_typecode(t) dh_typecode_##t |
60 | +++ b/include/qemu/typedefs.h | 36 | |
61 | @@ -XXX,XX +XXX,XX @@ typedef struct Range Range; | 37 | #define dh_callflag_i32 0 |
62 | typedef struct ReservedRegion ReservedRegion; | ||
63 | typedef struct SHPCDevice SHPCDevice; | ||
64 | typedef struct SSIBus SSIBus; | ||
65 | +typedef struct TCGCPUOps TCGCPUOps; | ||
66 | typedef struct TCGHelperInfo TCGHelperInfo; | ||
67 | typedef struct TranslationBlock TranslationBlock; | ||
68 | typedef struct VirtIODevice VirtIODevice; | ||
69 | diff --git a/bsd-user/signal.c b/bsd-user/signal.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/bsd-user/signal.c | ||
72 | +++ b/bsd-user/signal.c | ||
73 | @@ -XXX,XX +XXX,XX @@ void process_pending_signals(CPUArchState *env) | ||
74 | void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, | ||
75 | MMUAccessType access_type, bool maperr, uintptr_t ra) | ||
76 | { | ||
77 | - const struct TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; | ||
78 | + const TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; | ||
79 | |||
80 | if (tcg_ops->record_sigsegv) { | ||
81 | tcg_ops->record_sigsegv(cpu, addr, access_type, maperr, ra); | ||
82 | @@ -XXX,XX +XXX,XX @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, | ||
83 | void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, | ||
84 | MMUAccessType access_type, uintptr_t ra) | ||
85 | { | ||
86 | - const struct TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; | ||
87 | + const TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; | ||
88 | |||
89 | if (tcg_ops->record_sigbus) { | ||
90 | tcg_ops->record_sigbus(cpu, addr, access_type, ra); | ||
91 | diff --git a/linux-user/signal.c b/linux-user/signal.c | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/linux-user/signal.c | ||
94 | +++ b/linux-user/signal.c | ||
95 | @@ -XXX,XX +XXX,XX @@ void force_sigsegv(int oldsig) | ||
96 | void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, | ||
97 | MMUAccessType access_type, bool maperr, uintptr_t ra) | ||
98 | { | ||
99 | - const struct TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; | ||
100 | + const TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; | ||
101 | |||
102 | if (tcg_ops->record_sigsegv) { | ||
103 | tcg_ops->record_sigsegv(cpu, addr, access_type, maperr, ra); | ||
104 | @@ -XXX,XX +XXX,XX @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, | ||
105 | void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, | ||
106 | MMUAccessType access_type, uintptr_t ra) | ||
107 | { | ||
108 | - const struct TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; | ||
109 | + const TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; | ||
110 | |||
111 | if (tcg_ops->record_sigbus) { | ||
112 | tcg_ops->record_sigbus(cpu, addr, access_type, ra); | ||
113 | diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c | ||
114 | index XXXXXXX..XXXXXXX 100644 | ||
115 | --- a/target/alpha/cpu.c | ||
116 | +++ b/target/alpha/cpu.c | ||
117 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps alpha_sysemu_ops = { | ||
118 | |||
119 | #include "hw/core/tcg-cpu-ops.h" | ||
120 | |||
121 | -static const struct TCGCPUOps alpha_tcg_ops = { | ||
122 | +static const TCGCPUOps alpha_tcg_ops = { | ||
123 | .initialize = alpha_translate_init, | ||
124 | .restore_state_to_opc = alpha_restore_state_to_opc, | ||
125 | |||
126 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
127 | index XXXXXXX..XXXXXXX 100644 | ||
128 | --- a/target/arm/cpu.c | ||
129 | +++ b/target/arm/cpu.c | ||
130 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps arm_sysemu_ops = { | ||
131 | #endif | ||
132 | |||
133 | #ifdef CONFIG_TCG | ||
134 | -static const struct TCGCPUOps arm_tcg_ops = { | ||
135 | +static const TCGCPUOps arm_tcg_ops = { | ||
136 | .initialize = arm_translate_init, | ||
137 | .synchronize_from_tb = arm_cpu_synchronize_from_tb, | ||
138 | .debug_excp_handler = arm_debug_excp_handler, | ||
139 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | ||
140 | index XXXXXXX..XXXXXXX 100644 | ||
141 | --- a/target/arm/tcg/cpu32.c | ||
142 | +++ b/target/arm/tcg/cpu32.c | ||
143 | @@ -XXX,XX +XXX,XX @@ static void pxa270c5_initfn(Object *obj) | ||
144 | cpu->reset_sctlr = 0x00000078; | ||
145 | } | ||
146 | |||
147 | -static const struct TCGCPUOps arm_v7m_tcg_ops = { | ||
148 | +static const TCGCPUOps arm_v7m_tcg_ops = { | ||
149 | .initialize = arm_translate_init, | ||
150 | .synchronize_from_tb = arm_cpu_synchronize_from_tb, | ||
151 | .debug_excp_handler = arm_debug_excp_handler, | ||
152 | diff --git a/target/avr/cpu.c b/target/avr/cpu.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/avr/cpu.c | ||
155 | +++ b/target/avr/cpu.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps avr_sysemu_ops = { | ||
157 | |||
158 | #include "hw/core/tcg-cpu-ops.h" | ||
159 | |||
160 | -static const struct TCGCPUOps avr_tcg_ops = { | ||
161 | +static const TCGCPUOps avr_tcg_ops = { | ||
162 | .initialize = avr_cpu_tcg_init, | ||
163 | .synchronize_from_tb = avr_cpu_synchronize_from_tb, | ||
164 | .restore_state_to_opc = avr_restore_state_to_opc, | ||
165 | diff --git a/target/cris/cpu.c b/target/cris/cpu.c | ||
166 | index XXXXXXX..XXXXXXX 100644 | ||
167 | --- a/target/cris/cpu.c | ||
168 | +++ b/target/cris/cpu.c | ||
169 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps cris_sysemu_ops = { | ||
170 | |||
171 | #include "hw/core/tcg-cpu-ops.h" | ||
172 | |||
173 | -static const struct TCGCPUOps crisv10_tcg_ops = { | ||
174 | +static const TCGCPUOps crisv10_tcg_ops = { | ||
175 | .initialize = cris_initialize_crisv10_tcg, | ||
176 | .restore_state_to_opc = cris_restore_state_to_opc, | ||
177 | |||
178 | @@ -XXX,XX +XXX,XX @@ static const struct TCGCPUOps crisv10_tcg_ops = { | ||
179 | #endif /* !CONFIG_USER_ONLY */ | ||
180 | }; | ||
181 | |||
182 | -static const struct TCGCPUOps crisv32_tcg_ops = { | ||
183 | +static const TCGCPUOps crisv32_tcg_ops = { | ||
184 | .initialize = cris_initialize_tcg, | ||
185 | .restore_state_to_opc = cris_restore_state_to_opc, | ||
186 | |||
187 | diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c | ||
188 | index XXXXXXX..XXXXXXX 100644 | ||
189 | --- a/target/hexagon/cpu.c | ||
190 | +++ b/target/hexagon/cpu.c | ||
191 | @@ -XXX,XX +XXX,XX @@ static void hexagon_cpu_init(Object *obj) | ||
192 | |||
193 | #include "hw/core/tcg-cpu-ops.h" | ||
194 | |||
195 | -static const struct TCGCPUOps hexagon_tcg_ops = { | ||
196 | +static const TCGCPUOps hexagon_tcg_ops = { | ||
197 | .initialize = hexagon_translate_init, | ||
198 | .synchronize_from_tb = hexagon_cpu_synchronize_from_tb, | ||
199 | .restore_state_to_opc = hexagon_restore_state_to_opc, | ||
200 | diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c | ||
201 | index XXXXXXX..XXXXXXX 100644 | ||
202 | --- a/target/hppa/cpu.c | ||
203 | +++ b/target/hppa/cpu.c | ||
204 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps hppa_sysemu_ops = { | ||
205 | |||
206 | #include "hw/core/tcg-cpu-ops.h" | ||
207 | |||
208 | -static const struct TCGCPUOps hppa_tcg_ops = { | ||
209 | +static const TCGCPUOps hppa_tcg_ops = { | ||
210 | .initialize = hppa_translate_init, | ||
211 | .synchronize_from_tb = hppa_cpu_synchronize_from_tb, | ||
212 | .restore_state_to_opc = hppa_restore_state_to_opc, | ||
213 | diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c | ||
214 | index XXXXXXX..XXXXXXX 100644 | ||
215 | --- a/target/i386/tcg/tcg-cpu.c | ||
216 | +++ b/target/i386/tcg/tcg-cpu.c | ||
217 | @@ -XXX,XX +XXX,XX @@ static bool x86_debug_check_breakpoint(CPUState *cs) | ||
218 | |||
219 | #include "hw/core/tcg-cpu-ops.h" | ||
220 | |||
221 | -static const struct TCGCPUOps x86_tcg_ops = { | ||
222 | +static const TCGCPUOps x86_tcg_ops = { | ||
223 | .initialize = tcg_x86_init, | ||
224 | .synchronize_from_tb = x86_cpu_synchronize_from_tb, | ||
225 | .restore_state_to_opc = x86_restore_state_to_opc, | ||
226 | diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c | ||
227 | index XXXXXXX..XXXXXXX 100644 | ||
228 | --- a/target/loongarch/cpu.c | ||
229 | +++ b/target/loongarch/cpu.c | ||
230 | @@ -XXX,XX +XXX,XX @@ void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
231 | #ifdef CONFIG_TCG | ||
232 | #include "hw/core/tcg-cpu-ops.h" | ||
233 | |||
234 | -static struct TCGCPUOps loongarch_tcg_ops = { | ||
235 | +static TCGCPUOps loongarch_tcg_ops = { | ||
236 | .initialize = loongarch_translate_init, | ||
237 | .synchronize_from_tb = loongarch_cpu_synchronize_from_tb, | ||
238 | .restore_state_to_opc = loongarch_restore_state_to_opc, | ||
239 | diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c | ||
240 | index XXXXXXX..XXXXXXX 100644 | ||
241 | --- a/target/m68k/cpu.c | ||
242 | +++ b/target/m68k/cpu.c | ||
243 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps m68k_sysemu_ops = { | ||
244 | |||
245 | #include "hw/core/tcg-cpu-ops.h" | ||
246 | |||
247 | -static const struct TCGCPUOps m68k_tcg_ops = { | ||
248 | +static const TCGCPUOps m68k_tcg_ops = { | ||
249 | .initialize = m68k_tcg_init, | ||
250 | .restore_state_to_opc = m68k_restore_state_to_opc, | ||
251 | |||
252 | diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c | ||
253 | index XXXXXXX..XXXXXXX 100644 | ||
254 | --- a/target/microblaze/cpu.c | ||
255 | +++ b/target/microblaze/cpu.c | ||
256 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps mb_sysemu_ops = { | ||
257 | |||
258 | #include "hw/core/tcg-cpu-ops.h" | ||
259 | |||
260 | -static const struct TCGCPUOps mb_tcg_ops = { | ||
261 | +static const TCGCPUOps mb_tcg_ops = { | ||
262 | .initialize = mb_tcg_init, | ||
263 | .synchronize_from_tb = mb_cpu_synchronize_from_tb, | ||
264 | .restore_state_to_opc = mb_restore_state_to_opc, | ||
265 | diff --git a/target/mips/cpu.c b/target/mips/cpu.c | ||
266 | index XXXXXXX..XXXXXXX 100644 | ||
267 | --- a/target/mips/cpu.c | ||
268 | +++ b/target/mips/cpu.c | ||
269 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps mips_sysemu_ops = { | ||
270 | * NB: cannot be const, as some elements are changed for specific | ||
271 | * mips hardware (see hw/mips/jazz.c). | ||
272 | */ | ||
273 | -static const struct TCGCPUOps mips_tcg_ops = { | ||
274 | +static const TCGCPUOps mips_tcg_ops = { | ||
275 | .initialize = mips_tcg_init, | ||
276 | .synchronize_from_tb = mips_cpu_synchronize_from_tb, | ||
277 | .restore_state_to_opc = mips_restore_state_to_opc, | ||
278 | diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c | ||
279 | index XXXXXXX..XXXXXXX 100644 | ||
280 | --- a/target/nios2/cpu.c | ||
281 | +++ b/target/nios2/cpu.c | ||
282 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps nios2_sysemu_ops = { | ||
283 | |||
284 | #include "hw/core/tcg-cpu-ops.h" | ||
285 | |||
286 | -static const struct TCGCPUOps nios2_tcg_ops = { | ||
287 | +static const TCGCPUOps nios2_tcg_ops = { | ||
288 | .initialize = nios2_tcg_init, | ||
289 | .restore_state_to_opc = nios2_restore_state_to_opc, | ||
290 | |||
291 | diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c | ||
292 | index XXXXXXX..XXXXXXX 100644 | ||
293 | --- a/target/openrisc/cpu.c | ||
294 | +++ b/target/openrisc/cpu.c | ||
295 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps openrisc_sysemu_ops = { | ||
296 | |||
297 | #include "hw/core/tcg-cpu-ops.h" | ||
298 | |||
299 | -static const struct TCGCPUOps openrisc_tcg_ops = { | ||
300 | +static const TCGCPUOps openrisc_tcg_ops = { | ||
301 | .initialize = openrisc_translate_init, | ||
302 | .synchronize_from_tb = openrisc_cpu_synchronize_from_tb, | ||
303 | .restore_state_to_opc = openrisc_restore_state_to_opc, | ||
304 | diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c | ||
305 | index XXXXXXX..XXXXXXX 100644 | ||
306 | --- a/target/ppc/cpu_init.c | ||
307 | +++ b/target/ppc/cpu_init.c | ||
308 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps ppc_sysemu_ops = { | ||
309 | #ifdef CONFIG_TCG | ||
310 | #include "hw/core/tcg-cpu-ops.h" | ||
311 | |||
312 | -static const struct TCGCPUOps ppc_tcg_ops = { | ||
313 | +static const TCGCPUOps ppc_tcg_ops = { | ||
314 | .initialize = ppc_translate_init, | ||
315 | .restore_state_to_opc = ppc_restore_state_to_opc, | ||
316 | |||
317 | diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c | ||
318 | index XXXXXXX..XXXXXXX 100644 | ||
319 | --- a/target/riscv/tcg/tcg-cpu.c | ||
320 | +++ b/target/riscv/tcg/tcg-cpu.c | ||
321 | @@ -XXX,XX +XXX,XX @@ static void riscv_restore_state_to_opc(CPUState *cs, | ||
322 | env->bins = data[1]; | ||
323 | } | ||
324 | |||
325 | -static const struct TCGCPUOps riscv_tcg_ops = { | ||
326 | +static const TCGCPUOps riscv_tcg_ops = { | ||
327 | .initialize = riscv_translate_init, | ||
328 | .synchronize_from_tb = riscv_cpu_synchronize_from_tb, | ||
329 | .restore_state_to_opc = riscv_restore_state_to_opc, | ||
330 | diff --git a/target/rx/cpu.c b/target/rx/cpu.c | ||
331 | index XXXXXXX..XXXXXXX 100644 | ||
332 | --- a/target/rx/cpu.c | ||
333 | +++ b/target/rx/cpu.c | ||
334 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps rx_sysemu_ops = { | ||
335 | |||
336 | #include "hw/core/tcg-cpu-ops.h" | ||
337 | |||
338 | -static const struct TCGCPUOps rx_tcg_ops = { | ||
339 | +static const TCGCPUOps rx_tcg_ops = { | ||
340 | .initialize = rx_translate_init, | ||
341 | .synchronize_from_tb = rx_cpu_synchronize_from_tb, | ||
342 | .restore_state_to_opc = rx_restore_state_to_opc, | ||
343 | diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c | ||
344 | index XXXXXXX..XXXXXXX 100644 | ||
345 | --- a/target/s390x/cpu.c | ||
346 | +++ b/target/s390x/cpu.c | ||
347 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_reset_full(DeviceState *dev) | ||
348 | #ifdef CONFIG_TCG | ||
349 | #include "hw/core/tcg-cpu-ops.h" | ||
350 | |||
351 | -static const struct TCGCPUOps s390_tcg_ops = { | ||
352 | +static const TCGCPUOps s390_tcg_ops = { | ||
353 | .initialize = s390x_translate_init, | ||
354 | .restore_state_to_opc = s390x_restore_state_to_opc, | ||
355 | |||
356 | diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c | ||
357 | index XXXXXXX..XXXXXXX 100644 | ||
358 | --- a/target/sh4/cpu.c | ||
359 | +++ b/target/sh4/cpu.c | ||
360 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps sh4_sysemu_ops = { | ||
361 | |||
362 | #include "hw/core/tcg-cpu-ops.h" | ||
363 | |||
364 | -static const struct TCGCPUOps superh_tcg_ops = { | ||
365 | +static const TCGCPUOps superh_tcg_ops = { | ||
366 | .initialize = sh4_translate_init, | ||
367 | .synchronize_from_tb = superh_cpu_synchronize_from_tb, | ||
368 | .restore_state_to_opc = superh_restore_state_to_opc, | ||
369 | diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c | ||
370 | index XXXXXXX..XXXXXXX 100644 | ||
371 | --- a/target/sparc/cpu.c | ||
372 | +++ b/target/sparc/cpu.c | ||
373 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps sparc_sysemu_ops = { | ||
374 | #ifdef CONFIG_TCG | ||
375 | #include "hw/core/tcg-cpu-ops.h" | ||
376 | |||
377 | -static const struct TCGCPUOps sparc_tcg_ops = { | ||
378 | +static const TCGCPUOps sparc_tcg_ops = { | ||
379 | .initialize = sparc_tcg_init, | ||
380 | .synchronize_from_tb = sparc_cpu_synchronize_from_tb, | ||
381 | .restore_state_to_opc = sparc_restore_state_to_opc, | ||
382 | diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c | ||
383 | index XXXXXXX..XXXXXXX 100644 | ||
384 | --- a/target/tricore/cpu.c | ||
385 | +++ b/target/tricore/cpu.c | ||
386 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps tricore_sysemu_ops = { | ||
387 | |||
388 | #include "hw/core/tcg-cpu-ops.h" | ||
389 | |||
390 | -static const struct TCGCPUOps tricore_tcg_ops = { | ||
391 | +static const TCGCPUOps tricore_tcg_ops = { | ||
392 | .initialize = tricore_tcg_init, | ||
393 | .synchronize_from_tb = tricore_cpu_synchronize_from_tb, | ||
394 | .restore_state_to_opc = tricore_restore_state_to_opc, | ||
395 | diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c | ||
396 | index XXXXXXX..XXXXXXX 100644 | ||
397 | --- a/target/xtensa/cpu.c | ||
398 | +++ b/target/xtensa/cpu.c | ||
399 | @@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps xtensa_sysemu_ops = { | ||
400 | |||
401 | #include "hw/core/tcg-cpu-ops.h" | ||
402 | |||
403 | -static const struct TCGCPUOps xtensa_tcg_ops = { | ||
404 | +static const TCGCPUOps xtensa_tcg_ops = { | ||
405 | .initialize = xtensa_translate_init, | ||
406 | .debug_excp_handler = xtensa_breakpoint_handler, | ||
407 | .restore_state_to_opc = xtensa_restore_state_to_opc, | ||
408 | -- | 38 | -- |
409 | 2.34.1 | 39 | 2.43.0 |
410 | 40 | ||
411 | 41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
2 | --- | ||
3 | target/loongarch/cpu.c | 2 +- | ||
4 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
5 | 1 | ||
6 | diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c | ||
7 | index XXXXXXX..XXXXXXX 100644 | ||
8 | --- a/target/loongarch/cpu.c | ||
9 | +++ b/target/loongarch/cpu.c | ||
10 | @@ -XXX,XX +XXX,XX @@ void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
11 | #ifdef CONFIG_TCG | ||
12 | #include "hw/core/tcg-cpu-ops.h" | ||
13 | |||
14 | -static TCGCPUOps loongarch_tcg_ops = { | ||
15 | +static const TCGCPUOps loongarch_tcg_ops = { | ||
16 | .initialize = loongarch_translate_init, | ||
17 | .synchronize_from_tb = loongarch_cpu_synchronize_from_tb, | ||
18 | .restore_state_to_opc = loongarch_restore_state_to_opc, | ||
19 | -- | ||
20 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | CPU_GET_CLASS does runtime type checking; use the cached | ||
2 | copy of the class instead. | ||
3 | 1 | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | accel/tcg/cpu-exec.c | 109 ++++++++++++++++++++++--------------------- | ||
7 | 1 file changed, 56 insertions(+), 53 deletions(-) | ||
8 | |||
9 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/accel/tcg/cpu-exec.c | ||
12 | +++ b/accel/tcg/cpu-exec.c | ||
13 | @@ -XXX,XX +XXX,XX @@ static bool check_for_breakpoints_slow(CPUState *cpu, vaddr pc, | ||
14 | #ifdef CONFIG_USER_ONLY | ||
15 | g_assert_not_reached(); | ||
16 | #else | ||
17 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
18 | - assert(cc->tcg_ops->debug_check_breakpoint); | ||
19 | - match_bp = cc->tcg_ops->debug_check_breakpoint(cpu); | ||
20 | + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
21 | + assert(tcg_ops->debug_check_breakpoint); | ||
22 | + match_bp = tcg_ops->debug_check_breakpoint(cpu); | ||
23 | #endif | ||
24 | } | ||
25 | |||
26 | @@ -XXX,XX +XXX,XX @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit) | ||
27 | * counter hit zero); we must restore the guest PC to the address | ||
28 | * of the start of the TB. | ||
29 | */ | ||
30 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
31 | + CPUClass *cc = cpu->cc; | ||
32 | + const TCGCPUOps *tcg_ops = cc->tcg_ops; | ||
33 | |||
34 | - if (cc->tcg_ops->synchronize_from_tb) { | ||
35 | - cc->tcg_ops->synchronize_from_tb(cpu, last_tb); | ||
36 | + if (tcg_ops->synchronize_from_tb) { | ||
37 | + tcg_ops->synchronize_from_tb(cpu, last_tb); | ||
38 | } else { | ||
39 | tcg_debug_assert(!(tb_cflags(last_tb) & CF_PCREL)); | ||
40 | assert(cc->set_pc); | ||
41 | @@ -XXX,XX +XXX,XX @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit) | ||
42 | |||
43 | static void cpu_exec_enter(CPUState *cpu) | ||
44 | { | ||
45 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
46 | + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
47 | |||
48 | - if (cc->tcg_ops->cpu_exec_enter) { | ||
49 | - cc->tcg_ops->cpu_exec_enter(cpu); | ||
50 | + if (tcg_ops->cpu_exec_enter) { | ||
51 | + tcg_ops->cpu_exec_enter(cpu); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | static void cpu_exec_exit(CPUState *cpu) | ||
56 | { | ||
57 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
58 | + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
59 | |||
60 | - if (cc->tcg_ops->cpu_exec_exit) { | ||
61 | - cc->tcg_ops->cpu_exec_exit(cpu); | ||
62 | + if (tcg_ops->cpu_exec_exit) { | ||
63 | + tcg_ops->cpu_exec_exit(cpu); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_halt(CPUState *cpu) | ||
68 | |||
69 | static inline void cpu_handle_debug_exception(CPUState *cpu) | ||
70 | { | ||
71 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
72 | + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
73 | CPUWatchpoint *wp; | ||
74 | |||
75 | if (!cpu->watchpoint_hit) { | ||
76 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_handle_debug_exception(CPUState *cpu) | ||
77 | } | ||
78 | } | ||
79 | |||
80 | - if (cc->tcg_ops->debug_excp_handler) { | ||
81 | - cc->tcg_ops->debug_excp_handler(cpu); | ||
82 | + if (tcg_ops->debug_excp_handler) { | ||
83 | + tcg_ops->debug_excp_handler(cpu); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) | ||
88 | #endif | ||
89 | return false; | ||
90 | } | ||
91 | + | ||
92 | if (cpu->exception_index >= EXCP_INTERRUPT) { | ||
93 | /* exit request from the cpu execution loop */ | ||
94 | *ret = cpu->exception_index; | ||
95 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) | ||
96 | } | ||
97 | cpu->exception_index = -1; | ||
98 | return true; | ||
99 | - } else { | ||
100 | -#if defined(CONFIG_USER_ONLY) | ||
101 | - /* if user mode only, we simulate a fake exception | ||
102 | - which will be handled outside the cpu execution | ||
103 | - loop */ | ||
104 | -#if defined(TARGET_I386) | ||
105 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
106 | - cc->tcg_ops->fake_user_interrupt(cpu); | ||
107 | -#endif /* TARGET_I386 */ | ||
108 | - *ret = cpu->exception_index; | ||
109 | - cpu->exception_index = -1; | ||
110 | - return true; | ||
111 | -#else | ||
112 | - if (replay_exception()) { | ||
113 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
114 | - bql_lock(); | ||
115 | - cc->tcg_ops->do_interrupt(cpu); | ||
116 | - bql_unlock(); | ||
117 | - cpu->exception_index = -1; | ||
118 | + } | ||
119 | |||
120 | - if (unlikely(cpu->singlestep_enabled)) { | ||
121 | - /* | ||
122 | - * After processing the exception, ensure an EXCP_DEBUG is | ||
123 | - * raised when single-stepping so that GDB doesn't miss the | ||
124 | - * next instruction. | ||
125 | - */ | ||
126 | - *ret = EXCP_DEBUG; | ||
127 | - cpu_handle_debug_exception(cpu); | ||
128 | - return true; | ||
129 | - } | ||
130 | - } else if (!replay_has_interrupt()) { | ||
131 | - /* give a chance to iothread in replay mode */ | ||
132 | - *ret = EXCP_INTERRUPT; | ||
133 | +#if defined(CONFIG_USER_ONLY) | ||
134 | + /* | ||
135 | + * If user mode only, we simulate a fake exception which will be | ||
136 | + * handled outside the cpu execution loop. | ||
137 | + */ | ||
138 | +#if defined(TARGET_I386) | ||
139 | + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
140 | + tcg_ops->fake_user_interrupt(cpu); | ||
141 | +#endif /* TARGET_I386 */ | ||
142 | + *ret = cpu->exception_index; | ||
143 | + cpu->exception_index = -1; | ||
144 | + return true; | ||
145 | +#else | ||
146 | + if (replay_exception()) { | ||
147 | + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
148 | + | ||
149 | + bql_lock(); | ||
150 | + tcg_ops->do_interrupt(cpu); | ||
151 | + bql_unlock(); | ||
152 | + cpu->exception_index = -1; | ||
153 | + | ||
154 | + if (unlikely(cpu->singlestep_enabled)) { | ||
155 | + /* | ||
156 | + * After processing the exception, ensure an EXCP_DEBUG is | ||
157 | + * raised when single-stepping so that GDB doesn't miss the | ||
158 | + * next instruction. | ||
159 | + */ | ||
160 | + *ret = EXCP_DEBUG; | ||
161 | + cpu_handle_debug_exception(cpu); | ||
162 | return true; | ||
163 | } | ||
164 | -#endif | ||
165 | + } else if (!replay_has_interrupt()) { | ||
166 | + /* give a chance to iothread in replay mode */ | ||
167 | + *ret = EXCP_INTERRUPT; | ||
168 | + return true; | ||
169 | } | ||
170 | +#endif | ||
171 | |||
172 | return false; | ||
173 | } | ||
174 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_interrupt(CPUState *cpu, | ||
175 | True when it is, and we should restart on a new TB, | ||
176 | and via longjmp via cpu_loop_exit. */ | ||
177 | else { | ||
178 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
179 | + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
180 | |||
181 | - if (cc->tcg_ops->cpu_exec_interrupt && | ||
182 | - cc->tcg_ops->cpu_exec_interrupt(cpu, interrupt_request)) { | ||
183 | + if (tcg_ops->cpu_exec_interrupt && | ||
184 | + tcg_ops->cpu_exec_interrupt(cpu, interrupt_request)) { | ||
185 | if (need_replay_interrupt(interrupt_request)) { | ||
186 | replay_interrupt(); | ||
187 | } | ||
188 | @@ -XXX,XX +XXX,XX @@ int cpu_exec(CPUState *cpu) | ||
189 | bool tcg_exec_realizefn(CPUState *cpu, Error **errp) | ||
190 | { | ||
191 | static bool tcg_target_initialized; | ||
192 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
193 | |||
194 | if (!tcg_target_initialized) { | ||
195 | - cc->tcg_ops->initialize(); | ||
196 | + cpu->cc->tcg_ops->initialize(); | ||
197 | tcg_target_initialized = true; | ||
198 | } | ||
199 | |||
200 | -- | ||
201 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
2 | 1 | ||
3 | In order to make accel/tcg/ target agnostic, | ||
4 | introduce the need_replay_interrupt() handler. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Anton Johansson <anjo@rev.ng> | ||
9 | Reviewed-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru> | ||
10 | Message-Id: <20240124101639.30056-7-philmd@linaro.org> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | include/hw/core/tcg-cpu-ops.h | 5 +++++ | ||
14 | accel/tcg/cpu-exec.c | 8 +++++--- | ||
15 | 2 files changed, 10 insertions(+), 3 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/core/tcg-cpu-ops.h | ||
20 | +++ b/include/hw/core/tcg-cpu-ops.h | ||
21 | @@ -XXX,XX +XXX,XX @@ struct TCGCPUOps { | ||
22 | */ | ||
23 | bool (*io_recompile_replay_branch)(CPUState *cpu, | ||
24 | const TranslationBlock *tb); | ||
25 | + /** | ||
26 | + * @need_replay_interrupt: Return %true if @interrupt_request | ||
27 | + * needs to be recorded for replay purposes. | ||
28 | + */ | ||
29 | + bool (*need_replay_interrupt)(int interrupt_request); | ||
30 | #endif /* !CONFIG_USER_ONLY */ | ||
31 | #endif /* NEED_CPU_H */ | ||
32 | |||
33 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/accel/tcg/cpu-exec.c | ||
36 | +++ b/accel/tcg/cpu-exec.c | ||
37 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) | ||
38 | * "real" interrupt event later. It does not need to be recorded for | ||
39 | * replay purposes. | ||
40 | */ | ||
41 | -static inline bool need_replay_interrupt(int interrupt_request) | ||
42 | +static inline bool need_replay_interrupt(CPUState *cpu, int interrupt_request) | ||
43 | { | ||
44 | #if defined(TARGET_I386) | ||
45 | return !(interrupt_request & CPU_INTERRUPT_POLL); | ||
46 | #else | ||
47 | - return true; | ||
48 | + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
49 | + return !tcg_ops->need_replay_interrupt | ||
50 | + || tcg_ops->need_replay_interrupt(interrupt_request); | ||
51 | #endif | ||
52 | } | ||
53 | #endif /* !CONFIG_USER_ONLY */ | ||
54 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_interrupt(CPUState *cpu, | ||
55 | |||
56 | if (tcg_ops->cpu_exec_interrupt && | ||
57 | tcg_ops->cpu_exec_interrupt(cpu, interrupt_request)) { | ||
58 | - if (need_replay_interrupt(interrupt_request)) { | ||
59 | + if (need_replay_interrupt(cpu, interrupt_request)) { | ||
60 | replay_interrupt(); | ||
61 | } | ||
62 | /* | ||
63 | -- | ||
64 | 2.34.1 | ||
65 | |||
66 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
2 | 1 | ||
3 | Move this x86-specific code out of the generic accel/tcg/. | ||
4 | |||
5 | Reviewed-by: Anton Johansson <anjo@rev.ng> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Message-Id: <20240124101639.30056-8-philmd@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | target/i386/tcg/helper-tcg.h | 1 + | ||
13 | accel/tcg/cpu-exec.c | 4 ---- | ||
14 | target/i386/tcg/sysemu/seg_helper.c | 10 ++++++++++ | ||
15 | target/i386/tcg/tcg-cpu.c | 1 + | ||
16 | 4 files changed, 12 insertions(+), 4 deletions(-) | ||
17 | |||
18 | diff --git a/target/i386/tcg/helper-tcg.h b/target/i386/tcg/helper-tcg.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/i386/tcg/helper-tcg.h | ||
21 | +++ b/target/i386/tcg/helper-tcg.h | ||
22 | @@ -XXX,XX +XXX,XX @@ QEMU_BUILD_BUG_ON(TCG_PHYS_ADDR_BITS > TARGET_PHYS_ADDR_SPACE_BITS); | ||
23 | */ | ||
24 | void x86_cpu_do_interrupt(CPUState *cpu); | ||
25 | #ifndef CONFIG_USER_ONLY | ||
26 | +bool x86_need_replay_interrupt(int interrupt_request); | ||
27 | bool x86_cpu_exec_interrupt(CPUState *cpu, int int_req); | ||
28 | #endif | ||
29 | |||
30 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/accel/tcg/cpu-exec.c | ||
33 | +++ b/accel/tcg/cpu-exec.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) | ||
35 | */ | ||
36 | static inline bool need_replay_interrupt(CPUState *cpu, int interrupt_request) | ||
37 | { | ||
38 | -#if defined(TARGET_I386) | ||
39 | - return !(interrupt_request & CPU_INTERRUPT_POLL); | ||
40 | -#else | ||
41 | const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
42 | return !tcg_ops->need_replay_interrupt | ||
43 | || tcg_ops->need_replay_interrupt(interrupt_request); | ||
44 | -#endif | ||
45 | } | ||
46 | #endif /* !CONFIG_USER_ONLY */ | ||
47 | |||
48 | diff --git a/target/i386/tcg/sysemu/seg_helper.c b/target/i386/tcg/sysemu/seg_helper.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/i386/tcg/sysemu/seg_helper.c | ||
51 | +++ b/target/i386/tcg/sysemu/seg_helper.c | ||
52 | @@ -XXX,XX +XXX,XX @@ void x86_cpu_do_interrupt(CPUState *cs) | ||
53 | } | ||
54 | } | ||
55 | |||
56 | +bool x86_need_replay_interrupt(int interrupt_request) | ||
57 | +{ | ||
58 | + /* | ||
59 | + * CPU_INTERRUPT_POLL is a virtual event which gets converted into a | ||
60 | + * "real" interrupt event later. It does not need to be recorded for | ||
61 | + * replay purposes. | ||
62 | + */ | ||
63 | + return !(interrupt_request & CPU_INTERRUPT_POLL); | ||
64 | +} | ||
65 | + | ||
66 | bool x86_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
67 | { | ||
68 | X86CPU *cpu = X86_CPU(cs); | ||
69 | diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/i386/tcg/tcg-cpu.c | ||
72 | +++ b/target/i386/tcg/tcg-cpu.c | ||
73 | @@ -XXX,XX +XXX,XX @@ static const TCGCPUOps x86_tcg_ops = { | ||
74 | .do_unaligned_access = x86_cpu_do_unaligned_access, | ||
75 | .debug_excp_handler = breakpoint_handler, | ||
76 | .debug_check_breakpoint = x86_debug_check_breakpoint, | ||
77 | + .need_replay_interrupt = x86_need_replay_interrupt, | ||
78 | #endif /* !CONFIG_USER_ONLY */ | ||
79 | }; | ||
80 | |||
81 | -- | ||
82 | 2.34.1 | ||
83 | |||
84 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The function is now trivial, and with inlining we can | ||
2 | re-use the calling function's tcg_ops variable. | ||
3 | 1 | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | accel/tcg/cpu-exec.c | 17 ++--------------- | ||
7 | 1 file changed, 2 insertions(+), 15 deletions(-) | ||
8 | |||
9 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/accel/tcg/cpu-exec.c | ||
12 | +++ b/accel/tcg/cpu-exec.c | ||
13 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) | ||
14 | return false; | ||
15 | } | ||
16 | |||
17 | -#ifndef CONFIG_USER_ONLY | ||
18 | -/* | ||
19 | - * CPU_INTERRUPT_POLL is a virtual event which gets converted into a | ||
20 | - * "real" interrupt event later. It does not need to be recorded for | ||
21 | - * replay purposes. | ||
22 | - */ | ||
23 | -static inline bool need_replay_interrupt(CPUState *cpu, int interrupt_request) | ||
24 | -{ | ||
25 | - const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
26 | - return !tcg_ops->need_replay_interrupt | ||
27 | - || tcg_ops->need_replay_interrupt(interrupt_request); | ||
28 | -} | ||
29 | -#endif /* !CONFIG_USER_ONLY */ | ||
30 | - | ||
31 | static inline bool icount_exit_request(CPUState *cpu) | ||
32 | { | ||
33 | if (!icount_enabled()) { | ||
34 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_interrupt(CPUState *cpu, | ||
35 | |||
36 | if (tcg_ops->cpu_exec_interrupt && | ||
37 | tcg_ops->cpu_exec_interrupt(cpu, interrupt_request)) { | ||
38 | - if (need_replay_interrupt(cpu, interrupt_request)) { | ||
39 | + if (!tcg_ops->need_replay_interrupt || | ||
40 | + tcg_ops->need_replay_interrupt(interrupt_request)) { | ||
41 | replay_interrupt(); | ||
42 | } | ||
43 | /* | ||
44 | -- | ||
45 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
2 | 1 | ||
3 | In order to make accel/tcg/ target agnostic, | ||
4 | introduce the cpu_exec_halt() handler. | ||
5 | |||
6 | Reviewed-by: Anton Johansson <anjo@rev.ng> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Message-Id: <20240124101639.30056-9-philmd@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | include/hw/core/tcg-cpu-ops.h | 2 ++ | ||
13 | accel/tcg/cpu-exec.c | 5 +++++ | ||
14 | 2 files changed, 7 insertions(+) | ||
15 | |||
16 | diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/core/tcg-cpu-ops.h | ||
19 | +++ b/include/hw/core/tcg-cpu-ops.h | ||
20 | @@ -XXX,XX +XXX,XX @@ struct TCGCPUOps { | ||
21 | void (*do_interrupt)(CPUState *cpu); | ||
22 | /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */ | ||
23 | bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); | ||
24 | + /** @cpu_exec_halt: Callback for handling halt in cpu_exec */ | ||
25 | + void (*cpu_exec_halt)(CPUState *cpu); | ||
26 | /** | ||
27 | * @tlb_fill: Handle a softmmu tlb miss | ||
28 | * | ||
29 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/accel/tcg/cpu-exec.c | ||
32 | +++ b/accel/tcg/cpu-exec.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_halt(CPUState *cpu) | ||
34 | { | ||
35 | #ifndef CONFIG_USER_ONLY | ||
36 | if (cpu->halted) { | ||
37 | + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
38 | + | ||
39 | #if defined(TARGET_I386) | ||
40 | if (cpu->interrupt_request & CPU_INTERRUPT_POLL) { | ||
41 | X86CPU *x86_cpu = X86_CPU(cpu); | ||
42 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_halt(CPUState *cpu) | ||
43 | bql_unlock(); | ||
44 | } | ||
45 | #endif /* TARGET_I386 */ | ||
46 | + if (tcg_ops->cpu_exec_halt) { | ||
47 | + tcg_ops->cpu_exec_halt(cpu); | ||
48 | + } | ||
49 | if (!cpu_has_work(cpu)) { | ||
50 | return true; | ||
51 | } | ||
52 | -- | ||
53 | 2.34.1 | ||
54 | |||
55 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Move this x86-specific code out of the generic accel/tcg/. | 3 | Rather than manually copying each register, use |
4 | the libc memcpy(), which is well optimized nowadays. | ||
4 | 5 | ||
5 | Reported-by: Anton Johansson <anjo@rev.ng> | 6 | Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
6 | Reviewed-by: Anton Johansson <anjo@rev.ng> | 7 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Message-Id: <20240124101639.30056-10-philmd@linaro.org> | 10 | Message-ID: <20241205205418.67613-1-philmd@linaro.org> |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | --- | 12 | --- |
12 | target/i386/tcg/helper-tcg.h | 1 + | 13 | target/sparc/win_helper.c | 26 ++++++++------------------ |
13 | accel/tcg/cpu-exec.c | 12 ------------ | 14 | 1 file changed, 8 insertions(+), 18 deletions(-) |
14 | target/i386/tcg/sysemu/seg_helper.c | 13 +++++++++++++ | ||
15 | target/i386/tcg/tcg-cpu.c | 1 + | ||
16 | 4 files changed, 15 insertions(+), 12 deletions(-) | ||
17 | 15 | ||
18 | diff --git a/target/i386/tcg/helper-tcg.h b/target/i386/tcg/helper-tcg.h | 16 | diff --git a/target/sparc/win_helper.c b/target/sparc/win_helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/i386/tcg/helper-tcg.h | 18 | --- a/target/sparc/win_helper.c |
21 | +++ b/target/i386/tcg/helper-tcg.h | 19 | +++ b/target/sparc/win_helper.c |
22 | @@ -XXX,XX +XXX,XX @@ QEMU_BUILD_BUG_ON(TCG_PHYS_ADDR_BITS > TARGET_PHYS_ADDR_SPACE_BITS); | ||
23 | */ | ||
24 | void x86_cpu_do_interrupt(CPUState *cpu); | ||
25 | #ifndef CONFIG_USER_ONLY | ||
26 | +void x86_cpu_exec_halt(CPUState *cpu); | ||
27 | bool x86_need_replay_interrupt(int interrupt_request); | ||
28 | bool x86_cpu_exec_interrupt(CPUState *cpu, int int_req); | ||
29 | #endif | ||
30 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/accel/tcg/cpu-exec.c | ||
33 | +++ b/accel/tcg/cpu-exec.c | ||
34 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
35 | #include "qemu/rcu.h" | ||
36 | #include "exec/log.h" | ||
37 | #include "qemu/main-loop.h" | ||
38 | -#if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY) | ||
39 | -#include "hw/i386/apic.h" | ||
40 | -#endif | ||
41 | #include "sysemu/cpus.h" | ||
42 | #include "exec/cpu-all.h" | ||
43 | #include "sysemu/cpu-timers.h" | ||
44 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_halt(CPUState *cpu) | ||
45 | if (cpu->halted) { | ||
46 | const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; | ||
47 | |||
48 | -#if defined(TARGET_I386) | ||
49 | - if (cpu->interrupt_request & CPU_INTERRUPT_POLL) { | ||
50 | - X86CPU *x86_cpu = X86_CPU(cpu); | ||
51 | - bql_lock(); | ||
52 | - apic_poll_irq(x86_cpu->apic_state); | ||
53 | - cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); | ||
54 | - bql_unlock(); | ||
55 | - } | ||
56 | -#endif /* TARGET_I386 */ | ||
57 | if (tcg_ops->cpu_exec_halt) { | ||
58 | tcg_ops->cpu_exec_halt(cpu); | ||
59 | } | ||
60 | diff --git a/target/i386/tcg/sysemu/seg_helper.c b/target/i386/tcg/sysemu/seg_helper.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/i386/tcg/sysemu/seg_helper.c | ||
63 | +++ b/target/i386/tcg/sysemu/seg_helper.c | ||
64 | @@ -XXX,XX +XXX,XX @@ | ||
65 | |||
66 | #include "qemu/osdep.h" | ||
67 | #include "qemu/log.h" | ||
68 | +#include "qemu/main-loop.h" | ||
69 | #include "cpu.h" | ||
70 | #include "exec/helper-proto.h" | 21 | #include "exec/helper-proto.h" |
71 | #include "exec/cpu_ldst.h" | 22 | #include "trace.h" |
72 | @@ -XXX,XX +XXX,XX @@ void x86_cpu_do_interrupt(CPUState *cs) | 23 | |
24 | -static inline void memcpy32(target_ulong *dst, const target_ulong *src) | ||
25 | -{ | ||
26 | - dst[0] = src[0]; | ||
27 | - dst[1] = src[1]; | ||
28 | - dst[2] = src[2]; | ||
29 | - dst[3] = src[3]; | ||
30 | - dst[4] = src[4]; | ||
31 | - dst[5] = src[5]; | ||
32 | - dst[6] = src[6]; | ||
33 | - dst[7] = src[7]; | ||
34 | -} | ||
35 | - | ||
36 | void cpu_set_cwp(CPUSPARCState *env, int new_cwp) | ||
37 | { | ||
38 | /* put the modified wrap registers at their proper location */ | ||
39 | if (env->cwp == env->nwindows - 1) { | ||
40 | - memcpy32(env->regbase, env->regbase + env->nwindows * 16); | ||
41 | + memcpy(env->regbase, env->regbase + env->nwindows * 16, | ||
42 | + sizeof(env->gregs)); | ||
43 | } | ||
44 | env->cwp = new_cwp; | ||
45 | |||
46 | /* put the wrap registers at their temporary location */ | ||
47 | if (new_cwp == env->nwindows - 1) { | ||
48 | - memcpy32(env->regbase + env->nwindows * 16, env->regbase); | ||
49 | + memcpy(env->regbase + env->nwindows * 16, env->regbase, | ||
50 | + sizeof(env->gregs)); | ||
51 | } | ||
52 | env->regwptr = env->regbase + (new_cwp * 16); | ||
53 | } | ||
54 | @@ -XXX,XX +XXX,XX @@ void cpu_gl_switch_gregs(CPUSPARCState *env, uint32_t new_gl) | ||
55 | dst = get_gl_gregset(env, env->gl); | ||
56 | |||
57 | if (src != dst) { | ||
58 | - memcpy32(dst, env->gregs); | ||
59 | - memcpy32(env->gregs, src); | ||
60 | + memcpy(dst, env->gregs, sizeof(env->gregs)); | ||
61 | + memcpy(env->gregs, src, sizeof(env->gregs)); | ||
73 | } | 62 | } |
74 | } | 63 | } |
75 | 64 | ||
76 | +void x86_cpu_exec_halt(CPUState *cpu) | 65 | @@ -XXX,XX +XXX,XX @@ void cpu_change_pstate(CPUSPARCState *env, uint32_t new_pstate) |
77 | +{ | 66 | /* Switch global register bank */ |
78 | + if (cpu->interrupt_request & CPU_INTERRUPT_POLL) { | 67 | src = get_gregset(env, new_pstate_regs); |
79 | + X86CPU *x86_cpu = X86_CPU(cpu); | 68 | dst = get_gregset(env, pstate_regs); |
80 | + | 69 | - memcpy32(dst, env->gregs); |
81 | + bql_lock(); | 70 | - memcpy32(env->gregs, src); |
82 | + apic_poll_irq(x86_cpu->apic_state); | 71 | + memcpy(dst, env->gregs, sizeof(env->gregs)); |
83 | + cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); | 72 | + memcpy(env->gregs, src, sizeof(env->gregs)); |
84 | + bql_unlock(); | 73 | } else { |
85 | + } | 74 | trace_win_helper_no_switch_pstate(new_pstate_regs); |
86 | +} | 75 | } |
87 | + | ||
88 | bool x86_need_replay_interrupt(int interrupt_request) | ||
89 | { | ||
90 | /* | ||
91 | diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/target/i386/tcg/tcg-cpu.c | ||
94 | +++ b/target/i386/tcg/tcg-cpu.c | ||
95 | @@ -XXX,XX +XXX,XX @@ static const TCGCPUOps x86_tcg_ops = { | ||
96 | #else | ||
97 | .tlb_fill = x86_cpu_tlb_fill, | ||
98 | .do_interrupt = x86_cpu_do_interrupt, | ||
99 | + .cpu_exec_halt = x86_cpu_exec_halt, | ||
100 | .cpu_exec_interrupt = x86_cpu_exec_interrupt, | ||
101 | .do_unaligned_access = x86_cpu_do_unaligned_access, | ||
102 | .debug_excp_handler = breakpoint_handler, | ||
103 | -- | 76 | -- |
104 | 2.34.1 | 77 | 2.43.0 |
105 | 78 | ||
106 | 79 | diff view generated by jsdifflib |