1 | Pulling together some cleanups, fixes, and prepatory tci stuff. | 1 | TCG patch queue, plus one target/sh4 patch that |
---|---|---|---|
2 | Most of this has been reviewed, but not all. | 2 | Yoshinori Sato asked me to process. |
3 | |||
4 | Those lacking review: | ||
5 | |||
6 | 01-tcg-aarch64-Fix-constant-subtraction-in-tcg_out_adds.patch | ||
7 | 02-tcg-aarch64-Fix-I3617_CMLE0.patch | ||
8 | 03-tcg-aarch64-Fix-generation-of-scalar-vector-operatio.patch | ||
9 | 04-tcg-tci-Use-exec-cpu_ldst.h-interfaces.patch | ||
10 | 06-tcg-Manage-splitwx-in-tc_ptr_to_region_tree-by-hand.patch | ||
11 | 23-accel-tcg-rename-tb_lookup__cpu_state-and-hoist-stat.patch | ||
12 | 24-accel-tcg-move-CF_CLUSTER-calculation-to-curr_cflags.patch | ||
13 | 25-accel-tcg-drop-the-use-of-CF_HASH_MASK-and-rename-pa.patch | ||
14 | 26-include-exec-lightly-re-arrange-TranslationBlock.patch | ||
15 | 27-accel-tcg-Precompute-curr_cflags-into-cpu-tcg_cflags.patch | ||
16 | |||
17 | Alex, the last patch is a re-write and extension of one that | ||
18 | you did review. | ||
19 | 3 | ||
20 | 4 | ||
21 | r~ | 5 | r~ |
22 | 6 | ||
23 | 7 | ||
24 | Alex Bennée (4): | 8 | The following changes since commit efbf38d73e5dcc4d5f8b98c6e7a12be1f3b91745: |
25 | accel/tcg: rename tb_lookup__cpu_state and hoist state extraction | ||
26 | accel/tcg: move CF_CLUSTER calculation to curr_cflags | ||
27 | accel/tcg: drop the use of CF_HASH_MASK and rename params | ||
28 | include/exec: lightly re-arrange TranslationBlock | ||
29 | 9 | ||
30 | Richard Henderson (23): | 10 | Merge tag 'for-upstream' of git://repo.or.cz/qemu/kevin into staging (2022-10-03 15:06:07 -0400) |
31 | tcg/aarch64: Fix constant subtraction in tcg_out_addsub2 | ||
32 | tcg/aarch64: Fix I3617_CMLE0 | ||
33 | tcg/aarch64: Fix generation of "scalar" vector operations | ||
34 | tcg/tci: Use exec/cpu_ldst.h interfaces | ||
35 | tcg: Split out tcg_raise_tb_overflow | ||
36 | tcg: Manage splitwx in tc_ptr_to_region_tree by hand | ||
37 | tcg/tci: Merge identical cases in generation (arithmetic opcodes) | ||
38 | tcg/tci: Merge identical cases in generation (exchange opcodes) | ||
39 | tcg/tci: Merge identical cases in generation (deposit opcode) | ||
40 | tcg/tci: Merge identical cases in generation (conditional opcodes) | ||
41 | tcg/tci: Merge identical cases in generation (load/store opcodes) | ||
42 | tcg/tci: Remove tci_read_r8 | ||
43 | tcg/tci: Remove tci_read_r8s | ||
44 | tcg/tci: Remove tci_read_r16 | ||
45 | tcg/tci: Remove tci_read_r16s | ||
46 | tcg/tci: Remove tci_read_r32 | ||
47 | tcg/tci: Remove tci_read_r32s | ||
48 | tcg/tci: Reduce use of tci_read_r64 | ||
49 | tcg/tci: Merge basic arithmetic operations | ||
50 | tcg/tci: Merge extension operations | ||
51 | tcg/tci: Merge bswap operations | ||
52 | tcg/tci: Merge mov, not and neg operations | ||
53 | accel/tcg: Precompute curr_cflags into cpu->tcg_cflags | ||
54 | 11 | ||
55 | accel/tcg/tcg-accel-ops.h | 1 + | 12 | are available in the Git repository at: |
56 | include/exec/exec-all.h | 19 +- | ||
57 | include/exec/tb-lookup.h | 26 +- | ||
58 | include/hw/core/cpu.h | 2 + | ||
59 | accel/tcg/cpu-exec.c | 34 ++- | ||
60 | accel/tcg/tcg-accel-ops-mttcg.c | 3 +- | ||
61 | accel/tcg/tcg-accel-ops-rr.c | 2 +- | ||
62 | accel/tcg/tcg-accel-ops.c | 8 + | ||
63 | accel/tcg/tcg-runtime.c | 6 +- | ||
64 | accel/tcg/translate-all.c | 18 +- | ||
65 | linux-user/main.c | 1 + | ||
66 | linux-user/sh4/signal.c | 8 +- | ||
67 | linux-user/syscall.c | 18 +- | ||
68 | softmmu/physmem.c | 2 +- | ||
69 | tcg/tcg.c | 29 +- | ||
70 | tcg/tci.c | 526 ++++++++++---------------------- | ||
71 | tcg/aarch64/tcg-target.c.inc | 229 +++++++++++--- | ||
72 | tcg/tci/tcg-target.c.inc | 204 +++++-------- | ||
73 | 18 files changed, 526 insertions(+), 610 deletions(-) | ||
74 | 13 | ||
75 | -- | 14 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20221004 |
76 | 2.25.1 | ||
77 | 15 | ||
16 | for you to fetch changes up to ab419fd8a035a65942de4e63effcd55ccbf1a9fe: | ||
78 | 17 | ||
18 | target/sh4: Fix TB_FLAG_UNALIGN (2022-10-04 12:33:05 -0700) | ||
19 | |||
20 | ---------------------------------------------------------------- | ||
21 | Cache CPUClass for use in hot code paths. | ||
22 | Add CPUTLBEntryFull, probe_access_full, tlb_set_page_full. | ||
23 | Add generic support for TARGET_TB_PCREL. | ||
24 | tcg/ppc: Optimize 26-bit jumps using STQ for POWER 2.07 | ||
25 | target/sh4: Fix TB_FLAG_UNALIGN | ||
26 | |||
27 | ---------------------------------------------------------------- | ||
28 | Alex Bennée (3): | ||
29 | cpu: cache CPUClass in CPUState for hot code paths | ||
30 | hw/core/cpu-sysemu: used cached class in cpu_asidx_from_attrs | ||
31 | cputlb: used cached CPUClass in our hot-paths | ||
32 | |||
33 | Leandro Lupori (1): | ||
34 | tcg/ppc: Optimize 26-bit jumps | ||
35 | |||
36 | Richard Henderson (16): | ||
37 | accel/tcg: Rename CPUIOTLBEntry to CPUTLBEntryFull | ||
38 | accel/tcg: Drop addr member from SavedIOTLB | ||
39 | accel/tcg: Suppress auto-invalidate in probe_access_internal | ||
40 | accel/tcg: Introduce probe_access_full | ||
41 | accel/tcg: Introduce tlb_set_page_full | ||
42 | include/exec: Introduce TARGET_PAGE_ENTRY_EXTRA | ||
43 | accel/tcg: Remove PageDesc code_bitmap | ||
44 | accel/tcg: Use bool for page_find_alloc | ||
45 | accel/tcg: Use DisasContextBase in plugin_gen_tb_start | ||
46 | accel/tcg: Do not align tb->page_addr[0] | ||
47 | accel/tcg: Inline tb_flush_jmp_cache | ||
48 | include/hw/core: Create struct CPUJumpCache | ||
49 | hw/core: Add CPUClass.get_pc | ||
50 | accel/tcg: Introduce tb_pc and log_pc | ||
51 | accel/tcg: Introduce TARGET_TB_PCREL | ||
52 | target/sh4: Fix TB_FLAG_UNALIGN | ||
53 | |||
54 | accel/tcg/internal.h | 10 ++ | ||
55 | accel/tcg/tb-hash.h | 1 + | ||
56 | accel/tcg/tb-jmp-cache.h | 65 ++++++++ | ||
57 | include/exec/cpu-common.h | 1 + | ||
58 | include/exec/cpu-defs.h | 48 ++++-- | ||
59 | include/exec/exec-all.h | 75 ++++++++- | ||
60 | include/exec/plugin-gen.h | 7 +- | ||
61 | include/hw/core/cpu.h | 28 ++-- | ||
62 | include/qemu/typedefs.h | 2 + | ||
63 | include/tcg/tcg.h | 2 +- | ||
64 | target/sh4/cpu.h | 56 ++++--- | ||
65 | accel/stubs/tcg-stub.c | 4 + | ||
66 | accel/tcg/cpu-exec.c | 80 +++++----- | ||
67 | accel/tcg/cputlb.c | 259 ++++++++++++++++++-------------- | ||
68 | accel/tcg/plugin-gen.c | 22 +-- | ||
69 | accel/tcg/translate-all.c | 214 ++++++++++++-------------- | ||
70 | accel/tcg/translator.c | 2 +- | ||
71 | cpu.c | 9 +- | ||
72 | hw/core/cpu-common.c | 3 +- | ||
73 | hw/core/cpu-sysemu.c | 5 +- | ||
74 | linux-user/sh4/signal.c | 6 +- | ||
75 | plugins/core.c | 2 +- | ||
76 | target/alpha/cpu.c | 9 ++ | ||
77 | target/arm/cpu.c | 17 ++- | ||
78 | target/arm/mte_helper.c | 14 +- | ||
79 | target/arm/sve_helper.c | 4 +- | ||
80 | target/arm/translate-a64.c | 2 +- | ||
81 | target/avr/cpu.c | 10 +- | ||
82 | target/cris/cpu.c | 8 + | ||
83 | target/hexagon/cpu.c | 10 +- | ||
84 | target/hppa/cpu.c | 12 +- | ||
85 | target/i386/cpu.c | 9 ++ | ||
86 | target/i386/tcg/tcg-cpu.c | 2 +- | ||
87 | target/loongarch/cpu.c | 11 +- | ||
88 | target/m68k/cpu.c | 8 + | ||
89 | target/microblaze/cpu.c | 10 +- | ||
90 | target/mips/cpu.c | 8 + | ||
91 | target/mips/tcg/exception.c | 2 +- | ||
92 | target/mips/tcg/sysemu/special_helper.c | 2 +- | ||
93 | target/nios2/cpu.c | 9 ++ | ||
94 | target/openrisc/cpu.c | 10 +- | ||
95 | target/ppc/cpu_init.c | 8 + | ||
96 | target/riscv/cpu.c | 17 ++- | ||
97 | target/rx/cpu.c | 10 +- | ||
98 | target/s390x/cpu.c | 8 + | ||
99 | target/s390x/tcg/mem_helper.c | 4 - | ||
100 | target/sh4/cpu.c | 18 ++- | ||
101 | target/sh4/helper.c | 6 +- | ||
102 | target/sh4/translate.c | 90 +++++------ | ||
103 | target/sparc/cpu.c | 10 +- | ||
104 | target/tricore/cpu.c | 11 +- | ||
105 | target/xtensa/cpu.c | 8 + | ||
106 | tcg/tcg.c | 8 +- | ||
107 | trace/control-target.c | 2 +- | ||
108 | tcg/ppc/tcg-target.c.inc | 119 +++++++++++---- | ||
109 | 55 files changed, 915 insertions(+), 462 deletions(-) | ||
110 | create mode 100644 accel/tcg/tb-jmp-cache.h | ||
111 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Lets make sure all the flags we compare when looking up blocks are | 3 | The class cast checkers are quite expensive and always on (unlike the |
4 | together in the same place. | 4 | dynamic case who's checks are gated by CONFIG_QOM_CAST_DEBUG). To |
5 | avoid the overhead of repeatedly checking something which should never | ||
6 | change we cache the CPUClass reference for use in the hot code paths. | ||
5 | 7 | ||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
7 | Message-Id: <20210224165811.11567-5-alex.bennee@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-Id: <20220811151413.3350684-3-alex.bennee@linaro.org> | ||
11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
12 | Message-Id: <20220923084803.498337-3-clg@kaod.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | --- | 14 | --- |
10 | include/exec/exec-all.h | 8 +++++--- | 15 | include/hw/core/cpu.h | 9 +++++++++ |
11 | 1 file changed, 5 insertions(+), 3 deletions(-) | 16 | cpu.c | 9 ++++----- |
17 | 2 files changed, 13 insertions(+), 5 deletions(-) | ||
12 | 18 | ||
13 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | 19 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/exec/exec-all.h | 21 | --- a/include/hw/core/cpu.h |
16 | +++ b/include/exec/exec-all.h | 22 | +++ b/include/hw/core/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ struct TranslationBlock { | 23 | @@ -XXX,XX +XXX,XX @@ typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size, |
18 | target_ulong pc; /* simulated PC corresponding to this block (EIP + CS base) */ | 24 | */ |
19 | target_ulong cs_base; /* CS base for this block */ | 25 | #define CPU(obj) ((CPUState *)(obj)) |
20 | uint32_t flags; /* flags defining in which context the code was generated */ | 26 | |
21 | - uint16_t size; /* size of target code for this block (1 <= | 27 | +/* |
22 | - size <= TARGET_PAGE_SIZE) */ | 28 | + * The class checkers bring in CPU_GET_CLASS() which is potentially |
23 | - uint16_t icount; | 29 | + * expensive given the eventual call to |
24 | uint32_t cflags; /* compile flags */ | 30 | + * object_class_dynamic_cast_assert(). Because of this the CPUState |
25 | #define CF_COUNT_MASK 0x00007fff | 31 | + * has a cached value for the class in cs->cc which is set up in |
26 | #define CF_LAST_IO 0x00008000 /* Last insn may be an IO access. */ | 32 | + * cpu_exec_realizefn() for use in hot code paths. |
27 | @@ -XXX,XX +XXX,XX @@ struct TranslationBlock { | 33 | + */ |
28 | /* Per-vCPU dynamic tracing state used to generate this TB */ | 34 | typedef struct CPUClass CPUClass; |
29 | uint32_t trace_vcpu_dstate; | 35 | DECLARE_CLASS_CHECKERS(CPUClass, CPU, |
30 | 36 | TYPE_CPU) | |
31 | + /* Above fields used for comparing */ | 37 | @@ -XXX,XX +XXX,XX @@ struct qemu_work_item; |
32 | + uint16_t size; /* size of target code for this block (1 <= | 38 | struct CPUState { |
33 | + size <= TARGET_PAGE_SIZE) */ | 39 | /*< private >*/ |
34 | + uint16_t icount; | 40 | DeviceState parent_obj; |
35 | + | 41 | + /* cache to avoid expensive CPU_GET_CLASS */ |
36 | struct tb_tc tc; | 42 | + CPUClass *cc; |
37 | 43 | /*< public >*/ | |
38 | /* first and second physical page containing code. The lower bit | 44 | |
45 | int nr_cores; | ||
46 | diff --git a/cpu.c b/cpu.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/cpu.c | ||
49 | +++ b/cpu.c | ||
50 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_cpu_common = { | ||
51 | |||
52 | void cpu_exec_realizefn(CPUState *cpu, Error **errp) | ||
53 | { | ||
54 | -#ifndef CONFIG_USER_ONLY | ||
55 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
56 | -#endif | ||
57 | + /* cache the cpu class for the hotpath */ | ||
58 | + cpu->cc = CPU_GET_CLASS(cpu); | ||
59 | |||
60 | cpu_list_add(cpu); | ||
61 | if (!accel_cpu_realizefn(cpu, errp)) { | ||
62 | @@ -XXX,XX +XXX,XX @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) | ||
63 | if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { | ||
64 | vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); | ||
65 | } | ||
66 | - if (cc->sysemu_ops->legacy_vmsd != NULL) { | ||
67 | - vmstate_register(NULL, cpu->cpu_index, cc->sysemu_ops->legacy_vmsd, cpu); | ||
68 | + if (cpu->cc->sysemu_ops->legacy_vmsd != NULL) { | ||
69 | + vmstate_register(NULL, cpu->cpu_index, cpu->cc->sysemu_ops->legacy_vmsd, cpu); | ||
70 | } | ||
71 | #endif /* CONFIG_USER_ONLY */ | ||
72 | } | ||
39 | -- | 73 | -- |
40 | 2.25.1 | 74 | 2.34.1 |
41 | 75 | ||
42 | 76 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Having a function return either and valid TB and some system state | 3 | This is a heavily used function so lets avoid the cost of |
4 | seems excessive. It will make the subsequent re-factoring easier if we | 4 | CPU_GET_CLASS. On the romulus-bmc run it has a modest effect: |
5 | lookup the current state where we are. | 5 | |
6 | Before: 36.812 s ± 0.506 s | ||
7 | After: 35.912 s ± 0.168 s | ||
6 | 8 | ||
7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 9 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
8 | Message-Id: <20210224165811.11567-2-alex.bennee@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-Id: <20220811151413.3350684-4-alex.bennee@linaro.org> | ||
12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
13 | Message-Id: <20220923084803.498337-4-clg@kaod.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | --- | 15 | --- |
11 | include/exec/tb-lookup.h | 18 ++++++++---------- | 16 | hw/core/cpu-sysemu.c | 5 ++--- |
12 | accel/tcg/cpu-exec.c | 10 ++++++++-- | 17 | 1 file changed, 2 insertions(+), 3 deletions(-) |
13 | accel/tcg/tcg-runtime.c | 4 +++- | ||
14 | 3 files changed, 19 insertions(+), 13 deletions(-) | ||
15 | 18 | ||
16 | diff --git a/include/exec/tb-lookup.h b/include/exec/tb-lookup.h | 19 | diff --git a/hw/core/cpu-sysemu.c b/hw/core/cpu-sysemu.c |
17 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/exec/tb-lookup.h | 21 | --- a/hw/core/cpu-sysemu.c |
19 | +++ b/include/exec/tb-lookup.h | 22 | +++ b/hw/core/cpu-sysemu.c |
20 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr) |
21 | #include "exec/tb-hash.h" | 24 | |
22 | 25 | int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs) | |
23 | /* Might cause an exception, so have a longjmp destination ready */ | ||
24 | -static inline TranslationBlock * | ||
25 | -tb_lookup__cpu_state(CPUState *cpu, target_ulong *pc, target_ulong *cs_base, | ||
26 | - uint32_t *flags, uint32_t cf_mask) | ||
27 | +static inline TranslationBlock * tb_lookup(CPUState *cpu, | ||
28 | + target_ulong pc, target_ulong cs_base, | ||
29 | + uint32_t flags, uint32_t cf_mask) | ||
30 | { | 26 | { |
31 | - CPUArchState *env = (CPUArchState *)cpu->env_ptr; | 27 | - CPUClass *cc = CPU_GET_CLASS(cpu); |
32 | TranslationBlock *tb; | 28 | int ret = 0; |
33 | uint32_t hash; | 29 | |
34 | 30 | - if (cc->sysemu_ops->asidx_from_attrs) { | |
35 | - cpu_get_tb_cpu_state(env, pc, cs_base, flags); | 31 | - ret = cc->sysemu_ops->asidx_from_attrs(cpu, attrs); |
36 | - hash = tb_jmp_cache_hash_func(*pc); | 32 | + if (cpu->cc->sysemu_ops->asidx_from_attrs) { |
37 | + hash = tb_jmp_cache_hash_func(pc); | 33 | + ret = cpu->cc->sysemu_ops->asidx_from_attrs(cpu, attrs); |
38 | tb = qatomic_rcu_read(&cpu->tb_jmp_cache[hash]); | 34 | assert(ret < cpu->num_ases && ret >= 0); |
39 | |||
40 | cf_mask &= ~CF_CLUSTER_MASK; | ||
41 | cf_mask |= cpu->cluster_index << CF_CLUSTER_SHIFT; | ||
42 | |||
43 | if (likely(tb && | ||
44 | - tb->pc == *pc && | ||
45 | - tb->cs_base == *cs_base && | ||
46 | - tb->flags == *flags && | ||
47 | + tb->pc == pc && | ||
48 | + tb->cs_base == cs_base && | ||
49 | + tb->flags == flags && | ||
50 | tb->trace_vcpu_dstate == *cpu->trace_dstate && | ||
51 | (tb_cflags(tb) & (CF_HASH_MASK | CF_INVALID)) == cf_mask)) { | ||
52 | return tb; | ||
53 | } | 35 | } |
54 | - tb = tb_htable_lookup(cpu, *pc, *cs_base, *flags, cf_mask); | 36 | return ret; |
55 | + tb = tb_htable_lookup(cpu, pc, cs_base, flags, cf_mask); | ||
56 | if (tb == NULL) { | ||
57 | return NULL; | ||
58 | } | ||
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 void cpu_exec_exit(CPUState *cpu) | ||
64 | |||
65 | void cpu_exec_step_atomic(CPUState *cpu) | ||
66 | { | ||
67 | + CPUArchState *env = (CPUArchState *)cpu->env_ptr; | ||
68 | TranslationBlock *tb; | ||
69 | target_ulong cs_base, pc; | ||
70 | uint32_t flags; | ||
71 | @@ -XXX,XX +XXX,XX @@ void cpu_exec_step_atomic(CPUState *cpu) | ||
72 | g_assert(!cpu->running); | ||
73 | cpu->running = true; | ||
74 | |||
75 | - tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); | ||
76 | + cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); | ||
77 | + tb = tb_lookup(cpu, pc, cs_base, flags, cf_mask); | ||
78 | + | ||
79 | if (tb == NULL) { | ||
80 | mmap_lock(); | ||
81 | tb = tb_gen_code(cpu, pc, cs_base, flags, cflags); | ||
82 | @@ -XXX,XX +XXX,XX @@ static inline TranslationBlock *tb_find(CPUState *cpu, | ||
83 | TranslationBlock *last_tb, | ||
84 | int tb_exit, uint32_t cf_mask) | ||
85 | { | ||
86 | + CPUArchState *env = (CPUArchState *)cpu->env_ptr; | ||
87 | TranslationBlock *tb; | ||
88 | target_ulong cs_base, pc; | ||
89 | uint32_t flags; | ||
90 | |||
91 | - tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); | ||
92 | + cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); | ||
93 | + | ||
94 | + tb = tb_lookup(cpu, pc, cs_base, flags, cf_mask); | ||
95 | if (tb == NULL) { | ||
96 | mmap_lock(); | ||
97 | tb = tb_gen_code(cpu, pc, cs_base, flags, cf_mask); | ||
98 | diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/accel/tcg/tcg-runtime.c | ||
101 | +++ b/accel/tcg/tcg-runtime.c | ||
102 | @@ -XXX,XX +XXX,XX @@ const void *HELPER(lookup_tb_ptr)(CPUArchState *env) | ||
103 | target_ulong cs_base, pc; | ||
104 | uint32_t flags; | ||
105 | |||
106 | - tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, curr_cflags()); | ||
107 | + cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); | ||
108 | + | ||
109 | + tb = tb_lookup(cpu, pc, cs_base, flags, curr_cflags()); | ||
110 | if (tb == NULL) { | ||
111 | return tcg_code_gen_epilogue; | ||
112 | } | ||
113 | -- | 37 | -- |
114 | 2.25.1 | 38 | 2.34.1 |
115 | 39 | ||
116 | 40 | diff view generated by jsdifflib |
1 | In all cases restricted to 64-bit hosts, tcg_read_r is | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | identical. We retain the 64-bit symbol for the single | ||
3 | case of INDEX_op_qemu_st_i64. | ||
4 | 2 | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Before: 35.912 s ± 0.168 s |
4 | After: 35.565 s ± 0.087 s | ||
5 | |||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-Id: <20220811151413.3350684-5-alex.bennee@linaro.org> | ||
9 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
10 | Message-Id: <20220923084803.498337-5-clg@kaod.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | --- | 12 | --- |
8 | tcg/tci.c | 93 +++++++++++++++++++++++++------------------------------ | 13 | accel/tcg/cputlb.c | 15 ++++++--------- |
9 | 1 file changed, 42 insertions(+), 51 deletions(-) | 14 | 1 file changed, 6 insertions(+), 9 deletions(-) |
10 | 15 | ||
11 | diff --git a/tcg/tci.c b/tcg/tci.c | 16 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c |
12 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/tcg/tci.c | 18 | --- a/accel/tcg/cputlb.c |
14 | +++ b/tcg/tci.c | 19 | +++ b/accel/tcg/cputlb.c |
15 | @@ -XXX,XX +XXX,XX @@ static tcg_target_ulong tci_read_reg(const tcg_target_ulong *regs, TCGReg index) | 20 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page(CPUState *cpu, target_ulong vaddr, |
16 | return regs[index]; | 21 | static void tlb_fill(CPUState *cpu, target_ulong addr, int size, |
22 | MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) | ||
23 | { | ||
24 | - CPUClass *cc = CPU_GET_CLASS(cpu); | ||
25 | bool ok; | ||
26 | |||
27 | /* | ||
28 | * This is not a probe, so only valid return is success; failure | ||
29 | * should result in exception + longjmp to the cpu loop. | ||
30 | */ | ||
31 | - ok = cc->tcg_ops->tlb_fill(cpu, addr, size, | ||
32 | - access_type, mmu_idx, false, retaddr); | ||
33 | + ok = cpu->cc->tcg_ops->tlb_fill(cpu, addr, size, | ||
34 | + access_type, mmu_idx, false, retaddr); | ||
35 | assert(ok); | ||
17 | } | 36 | } |
18 | 37 | ||
19 | -#if TCG_TARGET_REG_BITS == 64 | 38 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, |
20 | -static uint64_t tci_read_reg64(const tcg_target_ulong *regs, TCGReg index) | 39 | MMUAccessType access_type, |
21 | -{ | 40 | int mmu_idx, uintptr_t retaddr) |
22 | - return tci_read_reg(regs, index); | 41 | { |
23 | -} | 42 | - CPUClass *cc = CPU_GET_CLASS(cpu); |
24 | -#endif | ||
25 | - | 43 | - |
26 | static void | 44 | - cc->tcg_ops->do_unaligned_access(cpu, addr, access_type, mmu_idx, retaddr); |
27 | tci_write_reg(tcg_target_ulong *regs, TCGReg index, tcg_target_ulong value) | 45 | + cpu->cc->tcg_ops->do_unaligned_access(cpu, addr, access_type, |
28 | { | 46 | + mmu_idx, retaddr); |
29 | @@ -XXX,XX +XXX,XX @@ static uint64_t tci_read_r64(const tcg_target_ulong *regs, | ||
30 | static uint64_t tci_read_r64(const tcg_target_ulong *regs, | ||
31 | const uint8_t **tb_ptr) | ||
32 | { | ||
33 | - uint64_t value = tci_read_reg64(regs, **tb_ptr); | ||
34 | - *tb_ptr += 1; | ||
35 | - return value; | ||
36 | + return tci_read_r(regs, tb_ptr); | ||
37 | } | 47 | } |
38 | #endif | 48 | |
39 | 49 | static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, | |
40 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 50 | @@ -XXX,XX +XXX,XX @@ static int probe_access_internal(CPUArchState *env, target_ulong addr, |
41 | #elif TCG_TARGET_REG_BITS == 64 | 51 | if (!tlb_hit_page(tlb_addr, page_addr)) { |
42 | case INDEX_op_setcond_i64: | 52 | if (!victim_tlb_hit(env, mmu_idx, index, elt_ofs, page_addr)) { |
43 | t0 = *tb_ptr++; | 53 | CPUState *cs = env_cpu(env); |
44 | - t1 = tci_read_r64(regs, &tb_ptr); | 54 | - CPUClass *cc = CPU_GET_CLASS(cs); |
45 | - t2 = tci_read_r64(regs, &tb_ptr); | 55 | |
46 | + t1 = tci_read_r(regs, &tb_ptr); | 56 | - if (!cc->tcg_ops->tlb_fill(cs, addr, fault_size, access_type, |
47 | + t2 = tci_read_r(regs, &tb_ptr); | 57 | - mmu_idx, nonfault, retaddr)) { |
48 | condition = *tb_ptr++; | 58 | + if (!cs->cc->tcg_ops->tlb_fill(cs, addr, fault_size, access_type, |
49 | tci_write_reg(regs, t0, tci_compare64(t1, t2, condition)); | 59 | + mmu_idx, nonfault, retaddr)) { |
50 | break; | 60 | /* Non-faulting page table read failed. */ |
51 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 61 | *phost = NULL; |
52 | #if TCG_TARGET_REG_BITS == 64 | 62 | return TLB_INVALID_MASK; |
53 | case INDEX_op_mov_i64: | ||
54 | t0 = *tb_ptr++; | ||
55 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
56 | + t1 = tci_read_r(regs, &tb_ptr); | ||
57 | tci_write_reg(regs, t0, t1); | ||
58 | break; | ||
59 | case INDEX_op_tci_movi_i64: | ||
60 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
61 | tci_write_reg(regs, t0, *(uint64_t *)(t1 + t2)); | ||
62 | break; | ||
63 | case INDEX_op_st_i64: | ||
64 | - t0 = tci_read_r64(regs, &tb_ptr); | ||
65 | + t0 = tci_read_r(regs, &tb_ptr); | ||
66 | t1 = tci_read_r(regs, &tb_ptr); | ||
67 | t2 = tci_read_s32(&tb_ptr); | ||
68 | *(uint64_t *)(t1 + t2) = t0; | ||
69 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
70 | |||
71 | case INDEX_op_add_i64: | ||
72 | t0 = *tb_ptr++; | ||
73 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
74 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
75 | + t1 = tci_read_r(regs, &tb_ptr); | ||
76 | + t2 = tci_read_r(regs, &tb_ptr); | ||
77 | tci_write_reg(regs, t0, t1 + t2); | ||
78 | break; | ||
79 | case INDEX_op_sub_i64: | ||
80 | t0 = *tb_ptr++; | ||
81 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
82 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
83 | + t1 = tci_read_r(regs, &tb_ptr); | ||
84 | + t2 = tci_read_r(regs, &tb_ptr); | ||
85 | tci_write_reg(regs, t0, t1 - t2); | ||
86 | break; | ||
87 | case INDEX_op_mul_i64: | ||
88 | t0 = *tb_ptr++; | ||
89 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
90 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
91 | + t1 = tci_read_r(regs, &tb_ptr); | ||
92 | + t2 = tci_read_r(regs, &tb_ptr); | ||
93 | tci_write_reg(regs, t0, t1 * t2); | ||
94 | break; | ||
95 | case INDEX_op_div_i64: | ||
96 | t0 = *tb_ptr++; | ||
97 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
98 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
99 | + t1 = tci_read_r(regs, &tb_ptr); | ||
100 | + t2 = tci_read_r(regs, &tb_ptr); | ||
101 | tci_write_reg(regs, t0, (int64_t)t1 / (int64_t)t2); | ||
102 | break; | ||
103 | case INDEX_op_divu_i64: | ||
104 | t0 = *tb_ptr++; | ||
105 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
106 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
107 | + t1 = tci_read_r(regs, &tb_ptr); | ||
108 | + t2 = tci_read_r(regs, &tb_ptr); | ||
109 | tci_write_reg(regs, t0, (uint64_t)t1 / (uint64_t)t2); | ||
110 | break; | ||
111 | case INDEX_op_rem_i64: | ||
112 | t0 = *tb_ptr++; | ||
113 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
114 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
115 | + t1 = tci_read_r(regs, &tb_ptr); | ||
116 | + t2 = tci_read_r(regs, &tb_ptr); | ||
117 | tci_write_reg(regs, t0, (int64_t)t1 % (int64_t)t2); | ||
118 | break; | ||
119 | case INDEX_op_remu_i64: | ||
120 | t0 = *tb_ptr++; | ||
121 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
122 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
123 | + t1 = tci_read_r(regs, &tb_ptr); | ||
124 | + t2 = tci_read_r(regs, &tb_ptr); | ||
125 | tci_write_reg(regs, t0, (uint64_t)t1 % (uint64_t)t2); | ||
126 | break; | ||
127 | case INDEX_op_and_i64: | ||
128 | t0 = *tb_ptr++; | ||
129 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
130 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
131 | + t1 = tci_read_r(regs, &tb_ptr); | ||
132 | + t2 = tci_read_r(regs, &tb_ptr); | ||
133 | tci_write_reg(regs, t0, t1 & t2); | ||
134 | break; | ||
135 | case INDEX_op_or_i64: | ||
136 | t0 = *tb_ptr++; | ||
137 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
138 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
139 | + t1 = tci_read_r(regs, &tb_ptr); | ||
140 | + t2 = tci_read_r(regs, &tb_ptr); | ||
141 | tci_write_reg(regs, t0, t1 | t2); | ||
142 | break; | ||
143 | case INDEX_op_xor_i64: | ||
144 | t0 = *tb_ptr++; | ||
145 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
146 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
147 | + t1 = tci_read_r(regs, &tb_ptr); | ||
148 | + t2 = tci_read_r(regs, &tb_ptr); | ||
149 | tci_write_reg(regs, t0, t1 ^ t2); | ||
150 | break; | ||
151 | |||
152 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
153 | |||
154 | case INDEX_op_shl_i64: | ||
155 | t0 = *tb_ptr++; | ||
156 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
157 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
158 | + t1 = tci_read_r(regs, &tb_ptr); | ||
159 | + t2 = tci_read_r(regs, &tb_ptr); | ||
160 | tci_write_reg(regs, t0, t1 << (t2 & 63)); | ||
161 | break; | ||
162 | case INDEX_op_shr_i64: | ||
163 | t0 = *tb_ptr++; | ||
164 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
165 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
166 | + t1 = tci_read_r(regs, &tb_ptr); | ||
167 | + t2 = tci_read_r(regs, &tb_ptr); | ||
168 | tci_write_reg(regs, t0, t1 >> (t2 & 63)); | ||
169 | break; | ||
170 | case INDEX_op_sar_i64: | ||
171 | t0 = *tb_ptr++; | ||
172 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
173 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
174 | + t1 = tci_read_r(regs, &tb_ptr); | ||
175 | + t2 = tci_read_r(regs, &tb_ptr); | ||
176 | tci_write_reg(regs, t0, ((int64_t)t1 >> (t2 & 63))); | ||
177 | break; | ||
178 | #if TCG_TARGET_HAS_rot_i64 | ||
179 | case INDEX_op_rotl_i64: | ||
180 | t0 = *tb_ptr++; | ||
181 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
182 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
183 | + t1 = tci_read_r(regs, &tb_ptr); | ||
184 | + t2 = tci_read_r(regs, &tb_ptr); | ||
185 | tci_write_reg(regs, t0, rol64(t1, t2 & 63)); | ||
186 | break; | ||
187 | case INDEX_op_rotr_i64: | ||
188 | t0 = *tb_ptr++; | ||
189 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
190 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
191 | + t1 = tci_read_r(regs, &tb_ptr); | ||
192 | + t2 = tci_read_r(regs, &tb_ptr); | ||
193 | tci_write_reg(regs, t0, ror64(t1, t2 & 63)); | ||
194 | break; | ||
195 | #endif | ||
196 | #if TCG_TARGET_HAS_deposit_i64 | ||
197 | case INDEX_op_deposit_i64: | ||
198 | t0 = *tb_ptr++; | ||
199 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
200 | - t2 = tci_read_r64(regs, &tb_ptr); | ||
201 | + t1 = tci_read_r(regs, &tb_ptr); | ||
202 | + t2 = tci_read_r(regs, &tb_ptr); | ||
203 | tmp16 = *tb_ptr++; | ||
204 | tmp8 = *tb_ptr++; | ||
205 | tmp64 = (((1ULL << tmp8) - 1) << tmp16); | ||
206 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
207 | break; | ||
208 | #endif | ||
209 | case INDEX_op_brcond_i64: | ||
210 | - t0 = tci_read_r64(regs, &tb_ptr); | ||
211 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
212 | + t0 = tci_read_r(regs, &tb_ptr); | ||
213 | + t1 = tci_read_r(regs, &tb_ptr); | ||
214 | condition = *tb_ptr++; | ||
215 | label = tci_read_label(&tb_ptr); | ||
216 | if (tci_compare64(t0, t1, condition)) { | ||
217 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
218 | #if TCG_TARGET_HAS_bswap64_i64 | ||
219 | case INDEX_op_bswap64_i64: | ||
220 | t0 = *tb_ptr++; | ||
221 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
222 | + t1 = tci_read_r(regs, &tb_ptr); | ||
223 | tci_write_reg(regs, t0, bswap64(t1)); | ||
224 | break; | ||
225 | #endif | ||
226 | #if TCG_TARGET_HAS_not_i64 | ||
227 | case INDEX_op_not_i64: | ||
228 | t0 = *tb_ptr++; | ||
229 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
230 | + t1 = tci_read_r(regs, &tb_ptr); | ||
231 | tci_write_reg(regs, t0, ~t1); | ||
232 | break; | ||
233 | #endif | ||
234 | #if TCG_TARGET_HAS_neg_i64 | ||
235 | case INDEX_op_neg_i64: | ||
236 | t0 = *tb_ptr++; | ||
237 | - t1 = tci_read_r64(regs, &tb_ptr); | ||
238 | + t1 = tci_read_r(regs, &tb_ptr); | ||
239 | tci_write_reg(regs, t0, -t1); | ||
240 | break; | ||
241 | #endif | ||
242 | -- | 63 | -- |
243 | 2.25.1 | 64 | 2.34.1 |
244 | 65 | ||
245 | 66 | diff view generated by jsdifflib |
1 | This includes add, sub, mul, and, or, xor. | 1 | This structure will shortly contain more than just |
---|---|---|---|
2 | data for accessing MMIO. Rename the 'addr' member | ||
3 | to 'xlat_section' to more clearly indicate its purpose. | ||
2 | 4 | ||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | --- | 9 | --- |
6 | tcg/tci.c | 83 +++++++++++++++++-------------------------------------- | 10 | include/exec/cpu-defs.h | 22 ++++---- |
7 | 1 file changed, 25 insertions(+), 58 deletions(-) | 11 | accel/tcg/cputlb.c | 102 +++++++++++++++++++------------------ |
12 | target/arm/mte_helper.c | 14 ++--- | ||
13 | target/arm/sve_helper.c | 4 +- | ||
14 | target/arm/translate-a64.c | 2 +- | ||
15 | 5 files changed, 73 insertions(+), 71 deletions(-) | ||
8 | 16 | ||
9 | diff --git a/tcg/tci.c b/tcg/tci.c | 17 | diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h |
10 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/tcg/tci.c | 19 | --- a/include/exec/cpu-defs.h |
12 | +++ b/tcg/tci.c | 20 | +++ b/include/exec/cpu-defs.h |
13 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 21 | @@ -XXX,XX +XXX,XX @@ typedef uint64_t target_ulong; |
14 | *(uint32_t *)(t1 + t2) = t0; | 22 | # endif |
15 | break; | 23 | # endif |
16 | 24 | ||
17 | - /* Arithmetic operations (32 bit). */ | 25 | +/* Minimalized TLB entry for use by TCG fast path. */ |
18 | + /* Arithmetic operations (mixed 32/64 bit). */ | 26 | typedef struct CPUTLBEntry { |
19 | 27 | /* bit TARGET_LONG_BITS to TARGET_PAGE_BITS : virtual address | |
20 | - case INDEX_op_add_i32: | 28 | bit TARGET_PAGE_BITS-1..4 : Nonzero for accesses that should not |
21 | + CASE_32_64(add) | 29 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUTLBEntry { |
22 | t0 = *tb_ptr++; | 30 | |
23 | t1 = tci_read_r(regs, &tb_ptr); | 31 | QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS)); |
24 | t2 = tci_read_r(regs, &tb_ptr); | 32 | |
25 | tci_write_reg(regs, t0, t1 + t2); | 33 | -/* The IOTLB is not accessed directly inline by generated TCG code, |
26 | break; | 34 | - * so the CPUIOTLBEntry layout is not as critical as that of the |
27 | - case INDEX_op_sub_i32: | 35 | - * CPUTLBEntry. (This is also why we don't want to combine the two |
28 | + CASE_32_64(sub) | 36 | - * structs into one.) |
29 | t0 = *tb_ptr++; | 37 | +/* |
30 | t1 = tci_read_r(regs, &tb_ptr); | 38 | + * The full TLB entry, which is not accessed by generated TCG code, |
31 | t2 = tci_read_r(regs, &tb_ptr); | 39 | + * so the layout is not as critical as that of CPUTLBEntry. This is |
32 | tci_write_reg(regs, t0, t1 - t2); | 40 | + * also why we don't want to combine the two structs. |
33 | break; | 41 | */ |
34 | - case INDEX_op_mul_i32: | 42 | -typedef struct CPUIOTLBEntry { |
35 | + CASE_32_64(mul) | 43 | +typedef struct CPUTLBEntryFull { |
36 | t0 = *tb_ptr++; | 44 | /* |
37 | t1 = tci_read_r(regs, &tb_ptr); | 45 | - * @addr contains: |
38 | t2 = tci_read_r(regs, &tb_ptr); | 46 | + * @xlat_section contains: |
39 | tci_write_reg(regs, t0, t1 * t2); | 47 | * - in the lower TARGET_PAGE_BITS, a physical section number |
40 | break; | 48 | * - with the lower TARGET_PAGE_BITS masked off, an offset which |
41 | + CASE_32_64(and) | 49 | * must be added to the virtual address to obtain: |
42 | + t0 = *tb_ptr++; | 50 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUIOTLBEntry { |
43 | + t1 = tci_read_r(regs, &tb_ptr); | 51 | * number is PHYS_SECTION_NOTDIRTY or PHYS_SECTION_ROM) |
44 | + t2 = tci_read_r(regs, &tb_ptr); | 52 | * + the offset within the target MemoryRegion (otherwise) |
45 | + tci_write_reg(regs, t0, t1 & t2); | 53 | */ |
46 | + break; | 54 | - hwaddr addr; |
47 | + CASE_32_64(or) | 55 | + hwaddr xlat_section; |
48 | + t0 = *tb_ptr++; | 56 | MemTxAttrs attrs; |
49 | + t1 = tci_read_r(regs, &tb_ptr); | 57 | -} CPUIOTLBEntry; |
50 | + t2 = tci_read_r(regs, &tb_ptr); | 58 | +} CPUTLBEntryFull; |
51 | + tci_write_reg(regs, t0, t1 | t2); | 59 | |
52 | + break; | 60 | /* |
53 | + CASE_32_64(xor) | 61 | * Data elements that are per MMU mode, minus the bits accessed by |
54 | + t0 = *tb_ptr++; | 62 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUTLBDesc { |
55 | + t1 = tci_read_r(regs, &tb_ptr); | 63 | size_t vindex; |
56 | + t2 = tci_read_r(regs, &tb_ptr); | 64 | /* The tlb victim table, in two parts. */ |
57 | + tci_write_reg(regs, t0, t1 ^ t2); | 65 | CPUTLBEntry vtable[CPU_VTLB_SIZE]; |
58 | + break; | 66 | - CPUIOTLBEntry viotlb[CPU_VTLB_SIZE]; |
59 | + | 67 | - /* The iotlb. */ |
60 | + /* Arithmetic operations (32 bit). */ | 68 | - CPUIOTLBEntry *iotlb; |
61 | + | 69 | + CPUTLBEntryFull vfulltlb[CPU_VTLB_SIZE]; |
62 | case INDEX_op_div_i32: | 70 | + CPUTLBEntryFull *fulltlb; |
63 | t0 = *tb_ptr++; | 71 | } CPUTLBDesc; |
64 | t1 = tci_read_r(regs, &tb_ptr); | 72 | |
65 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 73 | /* |
66 | t2 = tci_read_r(regs, &tb_ptr); | 74 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c |
67 | tci_write_reg(regs, t0, (uint32_t)t1 % (uint32_t)t2); | 75 | index XXXXXXX..XXXXXXX 100644 |
68 | break; | 76 | --- a/accel/tcg/cputlb.c |
69 | - case INDEX_op_and_i32: | 77 | +++ b/accel/tcg/cputlb.c |
70 | - t0 = *tb_ptr++; | 78 | @@ -XXX,XX +XXX,XX @@ static void tlb_mmu_resize_locked(CPUTLBDesc *desc, CPUTLBDescFast *fast, |
71 | - t1 = tci_read_r(regs, &tb_ptr); | 79 | } |
72 | - t2 = tci_read_r(regs, &tb_ptr); | 80 | |
73 | - tci_write_reg(regs, t0, t1 & t2); | 81 | g_free(fast->table); |
74 | - break; | 82 | - g_free(desc->iotlb); |
75 | - case INDEX_op_or_i32: | 83 | + g_free(desc->fulltlb); |
76 | - t0 = *tb_ptr++; | 84 | |
77 | - t1 = tci_read_r(regs, &tb_ptr); | 85 | tlb_window_reset(desc, now, 0); |
78 | - t2 = tci_read_r(regs, &tb_ptr); | 86 | /* desc->n_used_entries is cleared by the caller */ |
79 | - tci_write_reg(regs, t0, t1 | t2); | 87 | fast->mask = (new_size - 1) << CPU_TLB_ENTRY_BITS; |
80 | - break; | 88 | fast->table = g_try_new(CPUTLBEntry, new_size); |
81 | - case INDEX_op_xor_i32: | 89 | - desc->iotlb = g_try_new(CPUIOTLBEntry, new_size); |
82 | - t0 = *tb_ptr++; | 90 | + desc->fulltlb = g_try_new(CPUTLBEntryFull, new_size); |
83 | - t1 = tci_read_r(regs, &tb_ptr); | 91 | |
84 | - t2 = tci_read_r(regs, &tb_ptr); | 92 | /* |
85 | - tci_write_reg(regs, t0, t1 ^ t2); | 93 | * If the allocations fail, try smaller sizes. We just freed some |
86 | - break; | 94 | @@ -XXX,XX +XXX,XX @@ static void tlb_mmu_resize_locked(CPUTLBDesc *desc, CPUTLBDescFast *fast, |
87 | 95 | * allocations to fail though, so we progressively reduce the allocation | |
88 | /* Shift/rotate operations (32 bit). */ | 96 | * size, aborting if we cannot even allocate the smallest TLB we support. |
89 | 97 | */ | |
90 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 98 | - while (fast->table == NULL || desc->iotlb == NULL) { |
91 | 99 | + while (fast->table == NULL || desc->fulltlb == NULL) { | |
92 | /* Arithmetic operations (64 bit). */ | 100 | if (new_size == (1 << CPU_TLB_DYN_MIN_BITS)) { |
93 | 101 | error_report("%s: %s", __func__, strerror(errno)); | |
94 | - case INDEX_op_add_i64: | 102 | abort(); |
95 | - t0 = *tb_ptr++; | 103 | @@ -XXX,XX +XXX,XX @@ static void tlb_mmu_resize_locked(CPUTLBDesc *desc, CPUTLBDescFast *fast, |
96 | - t1 = tci_read_r(regs, &tb_ptr); | 104 | fast->mask = (new_size - 1) << CPU_TLB_ENTRY_BITS; |
97 | - t2 = tci_read_r(regs, &tb_ptr); | 105 | |
98 | - tci_write_reg(regs, t0, t1 + t2); | 106 | g_free(fast->table); |
99 | - break; | 107 | - g_free(desc->iotlb); |
100 | - case INDEX_op_sub_i64: | 108 | + g_free(desc->fulltlb); |
101 | - t0 = *tb_ptr++; | 109 | fast->table = g_try_new(CPUTLBEntry, new_size); |
102 | - t1 = tci_read_r(regs, &tb_ptr); | 110 | - desc->iotlb = g_try_new(CPUIOTLBEntry, new_size); |
103 | - t2 = tci_read_r(regs, &tb_ptr); | 111 | + desc->fulltlb = g_try_new(CPUTLBEntryFull, new_size); |
104 | - tci_write_reg(regs, t0, t1 - t2); | 112 | } |
105 | - break; | 113 | } |
106 | - case INDEX_op_mul_i64: | 114 | |
107 | - t0 = *tb_ptr++; | 115 | @@ -XXX,XX +XXX,XX @@ static void tlb_mmu_init(CPUTLBDesc *desc, CPUTLBDescFast *fast, int64_t now) |
108 | - t1 = tci_read_r(regs, &tb_ptr); | 116 | desc->n_used_entries = 0; |
109 | - t2 = tci_read_r(regs, &tb_ptr); | 117 | fast->mask = (n_entries - 1) << CPU_TLB_ENTRY_BITS; |
110 | - tci_write_reg(regs, t0, t1 * t2); | 118 | fast->table = g_new(CPUTLBEntry, n_entries); |
111 | - break; | 119 | - desc->iotlb = g_new(CPUIOTLBEntry, n_entries); |
112 | case INDEX_op_div_i64: | 120 | + desc->fulltlb = g_new(CPUTLBEntryFull, n_entries); |
113 | t0 = *tb_ptr++; | 121 | tlb_mmu_flush_locked(desc, fast); |
114 | t1 = tci_read_r(regs, &tb_ptr); | 122 | } |
115 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 123 | |
116 | t2 = tci_read_r(regs, &tb_ptr); | 124 | @@ -XXX,XX +XXX,XX @@ void tlb_destroy(CPUState *cpu) |
117 | tci_write_reg(regs, t0, (uint64_t)t1 % (uint64_t)t2); | 125 | CPUTLBDescFast *fast = &env_tlb(env)->f[i]; |
118 | break; | 126 | |
119 | - case INDEX_op_and_i64: | 127 | g_free(fast->table); |
120 | - t0 = *tb_ptr++; | 128 | - g_free(desc->iotlb); |
121 | - t1 = tci_read_r(regs, &tb_ptr); | 129 | + g_free(desc->fulltlb); |
122 | - t2 = tci_read_r(regs, &tb_ptr); | 130 | } |
123 | - tci_write_reg(regs, t0, t1 & t2); | 131 | } |
124 | - break; | 132 | |
125 | - case INDEX_op_or_i64: | 133 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, |
126 | - t0 = *tb_ptr++; | 134 | |
127 | - t1 = tci_read_r(regs, &tb_ptr); | 135 | /* Evict the old entry into the victim tlb. */ |
128 | - t2 = tci_read_r(regs, &tb_ptr); | 136 | copy_tlb_helper_locked(tv, te); |
129 | - tci_write_reg(regs, t0, t1 | t2); | 137 | - desc->viotlb[vidx] = desc->iotlb[index]; |
130 | - break; | 138 | + desc->vfulltlb[vidx] = desc->fulltlb[index]; |
131 | - case INDEX_op_xor_i64: | 139 | tlb_n_used_entries_dec(env, mmu_idx); |
132 | - t0 = *tb_ptr++; | 140 | } |
133 | - t1 = tci_read_r(regs, &tb_ptr); | 141 | |
134 | - t2 = tci_read_r(regs, &tb_ptr); | 142 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, |
135 | - tci_write_reg(regs, t0, t1 ^ t2); | 143 | * subtract here is that of the page base, and not the same as the |
136 | - break; | 144 | * vaddr we add back in io_readx()/io_writex()/get_page_addr_code(). |
137 | 145 | */ | |
138 | /* Shift/rotate operations (64 bit). */ | 146 | - desc->iotlb[index].addr = iotlb - vaddr_page; |
147 | - desc->iotlb[index].attrs = attrs; | ||
148 | + desc->fulltlb[index].xlat_section = iotlb - vaddr_page; | ||
149 | + desc->fulltlb[index].attrs = attrs; | ||
150 | |||
151 | /* Now calculate the new entry */ | ||
152 | tn.addend = addend - vaddr_page; | ||
153 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, | ||
154 | } | ||
155 | } | ||
156 | |||
157 | -static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
158 | +static uint64_t io_readx(CPUArchState *env, CPUTLBEntryFull *full, | ||
159 | int mmu_idx, target_ulong addr, uintptr_t retaddr, | ||
160 | MMUAccessType access_type, MemOp op) | ||
161 | { | ||
162 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
163 | bool locked = false; | ||
164 | MemTxResult r; | ||
165 | |||
166 | - section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); | ||
167 | + section = iotlb_to_section(cpu, full->xlat_section, full->attrs); | ||
168 | mr = section->mr; | ||
169 | - mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; | ||
170 | + mr_offset = (full->xlat_section & TARGET_PAGE_MASK) + addr; | ||
171 | cpu->mem_io_pc = retaddr; | ||
172 | if (!cpu->can_do_io) { | ||
173 | cpu_io_recompile(cpu, retaddr); | ||
174 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
175 | qemu_mutex_lock_iothread(); | ||
176 | locked = true; | ||
177 | } | ||
178 | - r = memory_region_dispatch_read(mr, mr_offset, &val, op, iotlbentry->attrs); | ||
179 | + r = memory_region_dispatch_read(mr, mr_offset, &val, op, full->attrs); | ||
180 | if (r != MEMTX_OK) { | ||
181 | hwaddr physaddr = mr_offset + | ||
182 | section->offset_within_address_space - | ||
183 | section->offset_within_region; | ||
184 | |||
185 | cpu_transaction_failed(cpu, physaddr, addr, memop_size(op), access_type, | ||
186 | - mmu_idx, iotlbentry->attrs, r, retaddr); | ||
187 | + mmu_idx, full->attrs, r, retaddr); | ||
188 | } | ||
189 | if (locked) { | ||
190 | qemu_mutex_unlock_iothread(); | ||
191 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
192 | } | ||
193 | |||
194 | /* | ||
195 | - * Save a potentially trashed IOTLB entry for later lookup by plugin. | ||
196 | - * This is read by tlb_plugin_lookup if the iotlb entry doesn't match | ||
197 | + * Save a potentially trashed CPUTLBEntryFull for later lookup by plugin. | ||
198 | + * This is read by tlb_plugin_lookup if the fulltlb entry doesn't match | ||
199 | * because of the side effect of io_writex changing memory layout. | ||
200 | */ | ||
201 | static void save_iotlb_data(CPUState *cs, hwaddr addr, | ||
202 | @@ -XXX,XX +XXX,XX @@ static void save_iotlb_data(CPUState *cs, hwaddr addr, | ||
203 | #endif | ||
204 | } | ||
205 | |||
206 | -static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
207 | +static void io_writex(CPUArchState *env, CPUTLBEntryFull *full, | ||
208 | int mmu_idx, uint64_t val, target_ulong addr, | ||
209 | uintptr_t retaddr, MemOp op) | ||
210 | { | ||
211 | @@ -XXX,XX +XXX,XX @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
212 | bool locked = false; | ||
213 | MemTxResult r; | ||
214 | |||
215 | - section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); | ||
216 | + section = iotlb_to_section(cpu, full->xlat_section, full->attrs); | ||
217 | mr = section->mr; | ||
218 | - mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; | ||
219 | + mr_offset = (full->xlat_section & TARGET_PAGE_MASK) + addr; | ||
220 | if (!cpu->can_do_io) { | ||
221 | cpu_io_recompile(cpu, retaddr); | ||
222 | } | ||
223 | @@ -XXX,XX +XXX,XX @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | ||
224 | * The memory_region_dispatch may trigger a flush/resize | ||
225 | * so for plugins we save the iotlb_data just in case. | ||
226 | */ | ||
227 | - save_iotlb_data(cpu, iotlbentry->addr, section, mr_offset); | ||
228 | + save_iotlb_data(cpu, full->xlat_section, section, mr_offset); | ||
229 | |||
230 | if (!qemu_mutex_iothread_locked()) { | ||
231 | qemu_mutex_lock_iothread(); | ||
232 | locked = true; | ||
233 | } | ||
234 | - r = memory_region_dispatch_write(mr, mr_offset, val, op, iotlbentry->attrs); | ||
235 | + r = memory_region_dispatch_write(mr, mr_offset, val, op, full->attrs); | ||
236 | if (r != MEMTX_OK) { | ||
237 | hwaddr physaddr = mr_offset + | ||
238 | section->offset_within_address_space - | ||
239 | section->offset_within_region; | ||
240 | |||
241 | cpu_transaction_failed(cpu, physaddr, addr, memop_size(op), | ||
242 | - MMU_DATA_STORE, mmu_idx, iotlbentry->attrs, r, | ||
243 | + MMU_DATA_STORE, mmu_idx, full->attrs, r, | ||
244 | retaddr); | ||
245 | } | ||
246 | if (locked) { | ||
247 | @@ -XXX,XX +XXX,XX @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, | ||
248 | copy_tlb_helper_locked(vtlb, &tmptlb); | ||
249 | qemu_spin_unlock(&env_tlb(env)->c.lock); | ||
250 | |||
251 | - CPUIOTLBEntry tmpio, *io = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
252 | - CPUIOTLBEntry *vio = &env_tlb(env)->d[mmu_idx].viotlb[vidx]; | ||
253 | - tmpio = *io; *io = *vio; *vio = tmpio; | ||
254 | + CPUTLBEntryFull *f1 = &env_tlb(env)->d[mmu_idx].fulltlb[index]; | ||
255 | + CPUTLBEntryFull *f2 = &env_tlb(env)->d[mmu_idx].vfulltlb[vidx]; | ||
256 | + CPUTLBEntryFull tmpf; | ||
257 | + tmpf = *f1; *f1 = *f2; *f2 = tmpf; | ||
258 | return true; | ||
259 | } | ||
260 | } | ||
261 | @@ -XXX,XX +XXX,XX @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, | ||
262 | (ADDR) & TARGET_PAGE_MASK) | ||
263 | |||
264 | static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size, | ||
265 | - CPUIOTLBEntry *iotlbentry, uintptr_t retaddr) | ||
266 | + CPUTLBEntryFull *full, uintptr_t retaddr) | ||
267 | { | ||
268 | - ram_addr_t ram_addr = mem_vaddr + iotlbentry->addr; | ||
269 | + ram_addr_t ram_addr = mem_vaddr + full->xlat_section; | ||
270 | |||
271 | trace_memory_notdirty_write_access(mem_vaddr, ram_addr, size); | ||
272 | |||
273 | @@ -XXX,XX +XXX,XX @@ int probe_access_flags(CPUArchState *env, target_ulong addr, | ||
274 | /* Handle clean RAM pages. */ | ||
275 | if (unlikely(flags & TLB_NOTDIRTY)) { | ||
276 | uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
277 | - CPUIOTLBEntry *iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
278 | + CPUTLBEntryFull *full = &env_tlb(env)->d[mmu_idx].fulltlb[index]; | ||
279 | |||
280 | - notdirty_write(env_cpu(env), addr, 1, iotlbentry, retaddr); | ||
281 | + notdirty_write(env_cpu(env), addr, 1, full, retaddr); | ||
282 | flags &= ~TLB_NOTDIRTY; | ||
283 | } | ||
284 | |||
285 | @@ -XXX,XX +XXX,XX @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, | ||
286 | |||
287 | if (unlikely(flags & (TLB_NOTDIRTY | TLB_WATCHPOINT))) { | ||
288 | uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
289 | - CPUIOTLBEntry *iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
290 | + CPUTLBEntryFull *full = &env_tlb(env)->d[mmu_idx].fulltlb[index]; | ||
291 | |||
292 | /* Handle watchpoints. */ | ||
293 | if (flags & TLB_WATCHPOINT) { | ||
294 | int wp_access = (access_type == MMU_DATA_STORE | ||
295 | ? BP_MEM_WRITE : BP_MEM_READ); | ||
296 | cpu_check_watchpoint(env_cpu(env), addr, size, | ||
297 | - iotlbentry->attrs, wp_access, retaddr); | ||
298 | + full->attrs, wp_access, retaddr); | ||
299 | } | ||
300 | |||
301 | /* Handle clean RAM pages. */ | ||
302 | if (flags & TLB_NOTDIRTY) { | ||
303 | - notdirty_write(env_cpu(env), addr, 1, iotlbentry, retaddr); | ||
304 | + notdirty_write(env_cpu(env), addr, 1, full, retaddr); | ||
305 | } | ||
306 | } | ||
307 | |||
308 | @@ -XXX,XX +XXX,XX @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr, | ||
309 | * should have just filled the TLB. The one corner case is io_writex | ||
310 | * which can cause TLB flushes and potential resizing of the TLBs | ||
311 | * losing the information we need. In those cases we need to recover | ||
312 | - * data from a copy of the iotlbentry. As long as this always occurs | ||
313 | + * data from a copy of the CPUTLBEntryFull. As long as this always occurs | ||
314 | * from the same thread (which a mem callback will be) this is safe. | ||
315 | */ | ||
316 | |||
317 | @@ -XXX,XX +XXX,XX @@ bool tlb_plugin_lookup(CPUState *cpu, target_ulong addr, int mmu_idx, | ||
318 | if (likely(tlb_hit(tlb_addr, addr))) { | ||
319 | /* We must have an iotlb entry for MMIO */ | ||
320 | if (tlb_addr & TLB_MMIO) { | ||
321 | - CPUIOTLBEntry *iotlbentry; | ||
322 | - iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
323 | + CPUTLBEntryFull *full; | ||
324 | + full = &env_tlb(env)->d[mmu_idx].fulltlb[index]; | ||
325 | data->is_io = true; | ||
326 | - data->v.io.section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); | ||
327 | - data->v.io.offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; | ||
328 | + data->v.io.section = | ||
329 | + iotlb_to_section(cpu, full->xlat_section, full->attrs); | ||
330 | + data->v.io.offset = (full->xlat_section & TARGET_PAGE_MASK) + addr; | ||
331 | } else { | ||
332 | data->is_io = false; | ||
333 | data->v.ram.hostaddr = (void *)((uintptr_t)addr + tlbe->addend); | ||
334 | @@ -XXX,XX +XXX,XX @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, | ||
335 | |||
336 | if (unlikely(tlb_addr & TLB_NOTDIRTY)) { | ||
337 | notdirty_write(env_cpu(env), addr, size, | ||
338 | - &env_tlb(env)->d[mmu_idx].iotlb[index], retaddr); | ||
339 | + &env_tlb(env)->d[mmu_idx].fulltlb[index], retaddr); | ||
340 | } | ||
341 | |||
342 | return hostaddr; | ||
343 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, MemOpIdx oi, | ||
344 | |||
345 | /* Handle anything that isn't just a straight memory access. */ | ||
346 | if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { | ||
347 | - CPUIOTLBEntry *iotlbentry; | ||
348 | + CPUTLBEntryFull *full; | ||
349 | bool need_swap; | ||
350 | |||
351 | /* For anything that is unaligned, recurse through full_load. */ | ||
352 | @@ -XXX,XX +XXX,XX @@ load_helper(CPUArchState *env, target_ulong addr, MemOpIdx oi, | ||
353 | goto do_unaligned_access; | ||
354 | } | ||
355 | |||
356 | - iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
357 | + full = &env_tlb(env)->d[mmu_idx].fulltlb[index]; | ||
358 | |||
359 | /* Handle watchpoints. */ | ||
360 | if (unlikely(tlb_addr & TLB_WATCHPOINT)) { | ||
361 | /* On watchpoint hit, this will longjmp out. */ | ||
362 | cpu_check_watchpoint(env_cpu(env), addr, size, | ||
363 | - iotlbentry->attrs, BP_MEM_READ, retaddr); | ||
364 | + full->attrs, BP_MEM_READ, retaddr); | ||
365 | } | ||
366 | |||
367 | need_swap = size > 1 && (tlb_addr & TLB_BSWAP); | ||
368 | |||
369 | /* Handle I/O access. */ | ||
370 | if (likely(tlb_addr & TLB_MMIO)) { | ||
371 | - return io_readx(env, iotlbentry, mmu_idx, addr, retaddr, | ||
372 | + return io_readx(env, full, mmu_idx, addr, retaddr, | ||
373 | access_type, op ^ (need_swap * MO_BSWAP)); | ||
374 | } | ||
375 | |||
376 | @@ -XXX,XX +XXX,XX @@ store_helper_unaligned(CPUArchState *env, target_ulong addr, uint64_t val, | ||
377 | */ | ||
378 | if (unlikely(tlb_addr & TLB_WATCHPOINT)) { | ||
379 | cpu_check_watchpoint(env_cpu(env), addr, size - size2, | ||
380 | - env_tlb(env)->d[mmu_idx].iotlb[index].attrs, | ||
381 | + env_tlb(env)->d[mmu_idx].fulltlb[index].attrs, | ||
382 | BP_MEM_WRITE, retaddr); | ||
383 | } | ||
384 | if (unlikely(tlb_addr2 & TLB_WATCHPOINT)) { | ||
385 | cpu_check_watchpoint(env_cpu(env), page2, size2, | ||
386 | - env_tlb(env)->d[mmu_idx].iotlb[index2].attrs, | ||
387 | + env_tlb(env)->d[mmu_idx].fulltlb[index2].attrs, | ||
388 | BP_MEM_WRITE, retaddr); | ||
389 | } | ||
390 | |||
391 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
392 | |||
393 | /* Handle anything that isn't just a straight memory access. */ | ||
394 | if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { | ||
395 | - CPUIOTLBEntry *iotlbentry; | ||
396 | + CPUTLBEntryFull *full; | ||
397 | bool need_swap; | ||
398 | |||
399 | /* For anything that is unaligned, recurse through byte stores. */ | ||
400 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
401 | goto do_unaligned_access; | ||
402 | } | ||
403 | |||
404 | - iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
405 | + full = &env_tlb(env)->d[mmu_idx].fulltlb[index]; | ||
406 | |||
407 | /* Handle watchpoints. */ | ||
408 | if (unlikely(tlb_addr & TLB_WATCHPOINT)) { | ||
409 | /* On watchpoint hit, this will longjmp out. */ | ||
410 | cpu_check_watchpoint(env_cpu(env), addr, size, | ||
411 | - iotlbentry->attrs, BP_MEM_WRITE, retaddr); | ||
412 | + full->attrs, BP_MEM_WRITE, retaddr); | ||
413 | } | ||
414 | |||
415 | need_swap = size > 1 && (tlb_addr & TLB_BSWAP); | ||
416 | |||
417 | /* Handle I/O access. */ | ||
418 | if (tlb_addr & TLB_MMIO) { | ||
419 | - io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, | ||
420 | + io_writex(env, full, mmu_idx, val, addr, retaddr, | ||
421 | op ^ (need_swap * MO_BSWAP)); | ||
422 | return; | ||
423 | } | ||
424 | @@ -XXX,XX +XXX,XX @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, | ||
425 | |||
426 | /* Handle clean RAM pages. */ | ||
427 | if (tlb_addr & TLB_NOTDIRTY) { | ||
428 | - notdirty_write(env_cpu(env), addr, size, iotlbentry, retaddr); | ||
429 | + notdirty_write(env_cpu(env), addr, size, full, retaddr); | ||
430 | } | ||
431 | |||
432 | haddr = (void *)((uintptr_t)addr + entry->addend); | ||
433 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | ||
434 | index XXXXXXX..XXXXXXX 100644 | ||
435 | --- a/target/arm/mte_helper.c | ||
436 | +++ b/target/arm/mte_helper.c | ||
437 | @@ -XXX,XX +XXX,XX @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, | ||
438 | return tags + index; | ||
439 | #else | ||
440 | uintptr_t index; | ||
441 | - CPUIOTLBEntry *iotlbentry; | ||
442 | + CPUTLBEntryFull *full; | ||
443 | int in_page, flags; | ||
444 | ram_addr_t ptr_ra; | ||
445 | hwaddr ptr_paddr, tag_paddr, xlat; | ||
446 | @@ -XXX,XX +XXX,XX @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, | ||
447 | assert(!(flags & TLB_INVALID_MASK)); | ||
448 | |||
449 | /* | ||
450 | - * Find the iotlbentry for ptr. This *must* be present in the TLB | ||
451 | + * Find the CPUTLBEntryFull for ptr. This *must* be present in the TLB | ||
452 | * because we just found the mapping. | ||
453 | * TODO: Perhaps there should be a cputlb helper that returns a | ||
454 | * matching tlb entry + iotlb entry. | ||
455 | @@ -XXX,XX +XXX,XX @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, | ||
456 | g_assert(tlb_hit(comparator, ptr)); | ||
457 | } | ||
458 | # endif | ||
459 | - iotlbentry = &env_tlb(env)->d[ptr_mmu_idx].iotlb[index]; | ||
460 | + full = &env_tlb(env)->d[ptr_mmu_idx].fulltlb[index]; | ||
461 | |||
462 | /* If the virtual page MemAttr != Tagged, access unchecked. */ | ||
463 | - if (!arm_tlb_mte_tagged(&iotlbentry->attrs)) { | ||
464 | + if (!arm_tlb_mte_tagged(&full->attrs)) { | ||
465 | return NULL; | ||
466 | } | ||
467 | |||
468 | @@ -XXX,XX +XXX,XX @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, | ||
469 | int wp = ptr_access == MMU_DATA_LOAD ? BP_MEM_READ : BP_MEM_WRITE; | ||
470 | assert(ra != 0); | ||
471 | cpu_check_watchpoint(env_cpu(env), ptr, ptr_size, | ||
472 | - iotlbentry->attrs, wp, ra); | ||
473 | + full->attrs, wp, ra); | ||
474 | } | ||
475 | |||
476 | /* | ||
477 | @@ -XXX,XX +XXX,XX @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, | ||
478 | tag_paddr = ptr_paddr >> (LOG2_TAG_GRANULE + 1); | ||
479 | |||
480 | /* Look up the address in tag space. */ | ||
481 | - tag_asi = iotlbentry->attrs.secure ? ARMASIdx_TagS : ARMASIdx_TagNS; | ||
482 | + tag_asi = full->attrs.secure ? ARMASIdx_TagS : ARMASIdx_TagNS; | ||
483 | tag_as = cpu_get_address_space(env_cpu(env), tag_asi); | ||
484 | mr = address_space_translate(tag_as, tag_paddr, &xlat, NULL, | ||
485 | tag_access == MMU_DATA_STORE, | ||
486 | - iotlbentry->attrs); | ||
487 | + full->attrs); | ||
488 | |||
489 | /* | ||
490 | * Note that @mr will never be NULL. If there is nothing in the address | ||
491 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
492 | index XXXXXXX..XXXXXXX 100644 | ||
493 | --- a/target/arm/sve_helper.c | ||
494 | +++ b/target/arm/sve_helper.c | ||
495 | @@ -XXX,XX +XXX,XX @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env, | ||
496 | g_assert(tlb_hit(comparator, addr)); | ||
497 | # endif | ||
498 | |||
499 | - CPUIOTLBEntry *iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; | ||
500 | - info->attrs = iotlbentry->attrs; | ||
501 | + CPUTLBEntryFull *full = &env_tlb(env)->d[mmu_idx].fulltlb[index]; | ||
502 | + info->attrs = full->attrs; | ||
503 | } | ||
504 | #endif | ||
505 | |||
506 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
507 | index XXXXXXX..XXXXXXX 100644 | ||
508 | --- a/target/arm/translate-a64.c | ||
509 | +++ b/target/arm/translate-a64.c | ||
510 | @@ -XXX,XX +XXX,XX @@ static bool is_guarded_page(CPUARMState *env, DisasContext *s) | ||
511 | * table entry even for that case. | ||
512 | */ | ||
513 | return (tlb_hit(entry->addr_code, addr) && | ||
514 | - arm_tlb_bti_gp(&env_tlb(env)->d[mmu_idx].iotlb[index].attrs)); | ||
515 | + arm_tlb_bti_gp(&env_tlb(env)->d[mmu_idx].fulltlb[index].attrs)); | ||
516 | #endif | ||
517 | } | ||
139 | 518 | ||
140 | -- | 519 | -- |
141 | 2.25.1 | 520 | 2.34.1 |
142 | 521 | ||
143 | 522 | diff view generated by jsdifflib |
1 | This field is only written, not read; remove it. | ||
---|---|---|---|
2 | |||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
1 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
3 | --- | 7 | --- |
4 | tcg/tci.c | 29 +++++------------------------ | 8 | include/hw/core/cpu.h | 1 - |
5 | 1 file changed, 5 insertions(+), 24 deletions(-) | 9 | accel/tcg/cputlb.c | 7 +++---- |
10 | 2 files changed, 3 insertions(+), 5 deletions(-) | ||
6 | 11 | ||
7 | diff --git a/tcg/tci.c b/tcg/tci.c | 12 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h |
8 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
9 | --- a/tcg/tci.c | 14 | --- a/include/hw/core/cpu.h |
10 | +++ b/tcg/tci.c | 15 | +++ b/include/hw/core/cpu.h |
11 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 16 | @@ -XXX,XX +XXX,XX @@ struct CPUWatchpoint { |
12 | tci_write_reg(regs, t0, tci_compare64(t1, t2, condition)); | 17 | * the memory regions get moved around by io_writex. |
13 | break; | 18 | */ |
19 | typedef struct SavedIOTLB { | ||
20 | - hwaddr addr; | ||
21 | MemoryRegionSection *section; | ||
22 | hwaddr mr_offset; | ||
23 | } SavedIOTLB; | ||
24 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/accel/tcg/cputlb.c | ||
27 | +++ b/accel/tcg/cputlb.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUTLBEntryFull *full, | ||
29 | * This is read by tlb_plugin_lookup if the fulltlb entry doesn't match | ||
30 | * because of the side effect of io_writex changing memory layout. | ||
31 | */ | ||
32 | -static void save_iotlb_data(CPUState *cs, hwaddr addr, | ||
33 | - MemoryRegionSection *section, hwaddr mr_offset) | ||
34 | +static void save_iotlb_data(CPUState *cs, MemoryRegionSection *section, | ||
35 | + hwaddr mr_offset) | ||
36 | { | ||
37 | #ifdef CONFIG_PLUGIN | ||
38 | SavedIOTLB *saved = &cs->saved_iotlb; | ||
39 | - saved->addr = addr; | ||
40 | saved->section = section; | ||
41 | saved->mr_offset = mr_offset; | ||
14 | #endif | 42 | #endif |
15 | - case INDEX_op_mov_i32: | 43 | @@ -XXX,XX +XXX,XX @@ static void io_writex(CPUArchState *env, CPUTLBEntryFull *full, |
16 | + CASE_32_64(mov) | 44 | * The memory_region_dispatch may trigger a flush/resize |
17 | t0 = *tb_ptr++; | 45 | * so for plugins we save the iotlb_data just in case. |
18 | t1 = tci_read_r(regs, &tb_ptr); | 46 | */ |
19 | tci_write_reg(regs, t0, t1); | 47 | - save_iotlb_data(cpu, full->xlat_section, section, mr_offset); |
20 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 48 | + save_iotlb_data(cpu, section, mr_offset); |
21 | tci_write_reg(regs, t0, bswap32(t1)); | 49 | |
22 | break; | 50 | if (!qemu_mutex_iothread_locked()) { |
23 | #endif | 51 | qemu_mutex_lock_iothread(); |
24 | -#if TCG_TARGET_HAS_not_i32 | ||
25 | - case INDEX_op_not_i32: | ||
26 | +#if TCG_TARGET_HAS_not_i32 || TCG_TARGET_HAS_not_i64 | ||
27 | + CASE_32_64(not) | ||
28 | t0 = *tb_ptr++; | ||
29 | t1 = tci_read_r(regs, &tb_ptr); | ||
30 | tci_write_reg(regs, t0, ~t1); | ||
31 | break; | ||
32 | #endif | ||
33 | -#if TCG_TARGET_HAS_neg_i32 | ||
34 | - case INDEX_op_neg_i32: | ||
35 | +#if TCG_TARGET_HAS_neg_i32 || TCG_TARGET_HAS_neg_i64 | ||
36 | + CASE_32_64(neg) | ||
37 | t0 = *tb_ptr++; | ||
38 | t1 = tci_read_r(regs, &tb_ptr); | ||
39 | tci_write_reg(regs, t0, -t1); | ||
40 | break; | ||
41 | #endif | ||
42 | #if TCG_TARGET_REG_BITS == 64 | ||
43 | - case INDEX_op_mov_i64: | ||
44 | - t0 = *tb_ptr++; | ||
45 | - t1 = tci_read_r(regs, &tb_ptr); | ||
46 | - tci_write_reg(regs, t0, t1); | ||
47 | - break; | ||
48 | case INDEX_op_tci_movi_i64: | ||
49 | t0 = *tb_ptr++; | ||
50 | t1 = tci_read_i64(&tb_ptr); | ||
51 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
52 | tci_write_reg(regs, t0, bswap64(t1)); | ||
53 | break; | ||
54 | #endif | ||
55 | -#if TCG_TARGET_HAS_not_i64 | ||
56 | - case INDEX_op_not_i64: | ||
57 | - t0 = *tb_ptr++; | ||
58 | - t1 = tci_read_r(regs, &tb_ptr); | ||
59 | - tci_write_reg(regs, t0, ~t1); | ||
60 | - break; | ||
61 | -#endif | ||
62 | -#if TCG_TARGET_HAS_neg_i64 | ||
63 | - case INDEX_op_neg_i64: | ||
64 | - t0 = *tb_ptr++; | ||
65 | - t1 = tci_read_r(regs, &tb_ptr); | ||
66 | - tci_write_reg(regs, t0, -t1); | ||
67 | - break; | ||
68 | -#endif | ||
69 | #endif /* TCG_TARGET_REG_BITS == 64 */ | ||
70 | |||
71 | /* QEMU specific operations. */ | ||
72 | -- | 52 | -- |
73 | 2.25.1 | 53 | 2.34.1 |
74 | 54 | ||
75 | 55 | diff view generated by jsdifflib |
1 | This includes bswap16 and bswap32. | 1 | When PAGE_WRITE_INV is set when calling tlb_set_page, |
---|---|---|---|
2 | we immediately set TLB_INVALID_MASK in order to force | ||
3 | tlb_fill to be called on the next lookup. Here in | ||
4 | probe_access_internal, we have just called tlb_fill | ||
5 | and eliminated true misses, thus the lookup must be valid. | ||
2 | 6 | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | This allows us to remove a warning comment from s390x. |
8 | There doesn't seem to be a reason to change the code though. | ||
9 | |||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Reviewed-by: David Hildenbrand <david@redhat.com> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | --- | 14 | --- |
6 | tcg/tci.c | 22 ++++------------------ | 15 | accel/tcg/cputlb.c | 10 +++++++++- |
7 | 1 file changed, 4 insertions(+), 18 deletions(-) | 16 | target/s390x/tcg/mem_helper.c | 4 ---- |
17 | 2 files changed, 9 insertions(+), 5 deletions(-) | ||
8 | 18 | ||
9 | diff --git a/tcg/tci.c b/tcg/tci.c | 19 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c |
10 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/tcg/tci.c | 21 | --- a/accel/tcg/cputlb.c |
12 | +++ b/tcg/tci.c | 22 | +++ b/accel/tcg/cputlb.c |
13 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 23 | @@ -XXX,XX +XXX,XX @@ static int probe_access_internal(CPUArchState *env, target_ulong addr, |
14 | tci_write_reg(regs, t0, (uint16_t)t1); | 24 | } |
15 | break; | 25 | tlb_addr = tlb_read_ofs(entry, elt_ofs); |
16 | #endif | 26 | |
17 | -#if TCG_TARGET_HAS_bswap16_i32 | 27 | + flags = TLB_FLAGS_MASK; |
18 | - case INDEX_op_bswap16_i32: | 28 | page_addr = addr & TARGET_PAGE_MASK; |
19 | +#if TCG_TARGET_HAS_bswap16_i32 || TCG_TARGET_HAS_bswap16_i64 | 29 | if (!tlb_hit_page(tlb_addr, page_addr)) { |
20 | + CASE_32_64(bswap16) | 30 | if (!victim_tlb_hit(env, mmu_idx, index, elt_ofs, page_addr)) { |
21 | t0 = *tb_ptr++; | 31 | @@ -XXX,XX +XXX,XX @@ static int probe_access_internal(CPUArchState *env, target_ulong addr, |
22 | t1 = tci_read_r(regs, &tb_ptr); | 32 | |
23 | tci_write_reg(regs, t0, bswap16(t1)); | 33 | /* TLB resize via tlb_fill may have moved the entry. */ |
24 | break; | 34 | entry = tlb_entry(env, mmu_idx, addr); |
25 | #endif | 35 | + |
26 | -#if TCG_TARGET_HAS_bswap32_i32 | 36 | + /* |
27 | - case INDEX_op_bswap32_i32: | 37 | + * With PAGE_WRITE_INV, we set TLB_INVALID_MASK immediately, |
28 | +#if TCG_TARGET_HAS_bswap32_i32 || TCG_TARGET_HAS_bswap32_i64 | 38 | + * to force the next access through tlb_fill. We've just |
29 | + CASE_32_64(bswap32) | 39 | + * called tlb_fill, so we know that this entry *is* valid. |
30 | t0 = *tb_ptr++; | 40 | + */ |
31 | t1 = tci_read_r(regs, &tb_ptr); | 41 | + flags &= ~TLB_INVALID_MASK; |
32 | tci_write_reg(regs, t0, bswap32(t1)); | 42 | } |
33 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 43 | tlb_addr = tlb_read_ofs(entry, elt_ofs); |
34 | t1 = tci_read_r(regs, &tb_ptr); | 44 | } |
35 | tci_write_reg(regs, t0, (uint32_t)t1); | 45 | - flags = tlb_addr & TLB_FLAGS_MASK; |
36 | break; | 46 | + flags &= tlb_addr; |
37 | -#if TCG_TARGET_HAS_bswap16_i64 | 47 | |
38 | - case INDEX_op_bswap16_i64: | 48 | /* Fold all "mmio-like" bits into TLB_MMIO. This is not RAM. */ |
39 | - t0 = *tb_ptr++; | 49 | if (unlikely(flags & ~(TLB_WATCHPOINT | TLB_NOTDIRTY))) { |
40 | - t1 = tci_read_r(regs, &tb_ptr); | 50 | diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c |
41 | - tci_write_reg(regs, t0, bswap16(t1)); | 51 | index XXXXXXX..XXXXXXX 100644 |
42 | - break; | 52 | --- a/target/s390x/tcg/mem_helper.c |
43 | -#endif | 53 | +++ b/target/s390x/tcg/mem_helper.c |
44 | -#if TCG_TARGET_HAS_bswap32_i64 | 54 | @@ -XXX,XX +XXX,XX @@ static int s390_probe_access(CPUArchState *env, target_ulong addr, int size, |
45 | - case INDEX_op_bswap32_i64: | 55 | #else |
46 | - t0 = *tb_ptr++; | 56 | int flags; |
47 | - t1 = tci_read_r(regs, &tb_ptr); | 57 | |
48 | - tci_write_reg(regs, t0, bswap32(t1)); | 58 | - /* |
49 | - break; | 59 | - * For !CONFIG_USER_ONLY, we cannot rely on TLB_INVALID_MASK or haddr==NULL |
50 | -#endif | 60 | - * to detect if there was an exception during tlb_fill(). |
51 | #if TCG_TARGET_HAS_bswap64_i64 | 61 | - */ |
52 | case INDEX_op_bswap64_i64: | 62 | env->tlb_fill_exc = 0; |
53 | t0 = *tb_ptr++; | 63 | flags = probe_access_flags(env, addr, access_type, mmu_idx, nonfault, phost, |
64 | ra); | ||
54 | -- | 65 | -- |
55 | 2.25.1 | 66 | 2.34.1 |
56 | 67 | ||
57 | 68 | diff view generated by jsdifflib |
1 | Allow other places in tcg to restart with a smaller tb. | 1 | Add an interface to return the CPUTLBEntryFull struct |
---|---|---|---|
2 | that goes with the lookup. The result is not intended | ||
3 | to be valid across multiple lookups, so the user must | ||
4 | use the results immediately. | ||
2 | 5 | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | --- | 10 | --- |
6 | tcg/tcg.c | 9 +++++++-- | 11 | include/exec/exec-all.h | 15 +++++++++++++ |
7 | 1 file changed, 7 insertions(+), 2 deletions(-) | 12 | include/qemu/typedefs.h | 1 + |
13 | accel/tcg/cputlb.c | 47 +++++++++++++++++++++++++---------------- | ||
14 | 3 files changed, 45 insertions(+), 18 deletions(-) | ||
8 | 15 | ||
9 | diff --git a/tcg/tcg.c b/tcg/tcg.c | 16 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h |
10 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/tcg/tcg.c | 18 | --- a/include/exec/exec-all.h |
12 | +++ b/tcg/tcg.c | 19 | +++ b/include/exec/exec-all.h |
13 | @@ -XXX,XX +XXX,XX @@ static void set_jmp_reset_offset(TCGContext *s, int which) | 20 | @@ -XXX,XX +XXX,XX @@ int probe_access_flags(CPUArchState *env, target_ulong addr, |
14 | s->tb_jmp_reset_offset[which] = tcg_current_code_size(s); | 21 | MMUAccessType access_type, int mmu_idx, |
22 | bool nonfault, void **phost, uintptr_t retaddr); | ||
23 | |||
24 | +#ifndef CONFIG_USER_ONLY | ||
25 | +/** | ||
26 | + * probe_access_full: | ||
27 | + * Like probe_access_flags, except also return into @pfull. | ||
28 | + * | ||
29 | + * The CPUTLBEntryFull structure returned via @pfull is transient | ||
30 | + * and must be consumed or copied immediately, before any further | ||
31 | + * access or changes to TLB @mmu_idx. | ||
32 | + */ | ||
33 | +int probe_access_full(CPUArchState *env, target_ulong addr, | ||
34 | + MMUAccessType access_type, int mmu_idx, | ||
35 | + bool nonfault, void **phost, | ||
36 | + CPUTLBEntryFull **pfull, uintptr_t retaddr); | ||
37 | +#endif | ||
38 | + | ||
39 | #define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ | ||
40 | |||
41 | /* Estimated block size for TB allocation. */ | ||
42 | diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/include/qemu/typedefs.h | ||
45 | +++ b/include/qemu/typedefs.h | ||
46 | @@ -XXX,XX +XXX,XX @@ typedef struct ConfidentialGuestSupport ConfidentialGuestSupport; | ||
47 | typedef struct CPUAddressSpace CPUAddressSpace; | ||
48 | typedef struct CPUArchState CPUArchState; | ||
49 | typedef struct CPUState CPUState; | ||
50 | +typedef struct CPUTLBEntryFull CPUTLBEntryFull; | ||
51 | typedef struct DeviceListener DeviceListener; | ||
52 | typedef struct DeviceState DeviceState; | ||
53 | typedef struct DirtyBitmapSnapshot DirtyBitmapSnapshot; | ||
54 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/accel/tcg/cputlb.c | ||
57 | +++ b/accel/tcg/cputlb.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size, | ||
59 | static int probe_access_internal(CPUArchState *env, target_ulong addr, | ||
60 | int fault_size, MMUAccessType access_type, | ||
61 | int mmu_idx, bool nonfault, | ||
62 | - void **phost, uintptr_t retaddr) | ||
63 | + void **phost, CPUTLBEntryFull **pfull, | ||
64 | + uintptr_t retaddr) | ||
65 | { | ||
66 | uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
67 | CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); | ||
68 | @@ -XXX,XX +XXX,XX @@ static int probe_access_internal(CPUArchState *env, target_ulong addr, | ||
69 | mmu_idx, nonfault, retaddr)) { | ||
70 | /* Non-faulting page table read failed. */ | ||
71 | *phost = NULL; | ||
72 | + *pfull = NULL; | ||
73 | return TLB_INVALID_MASK; | ||
74 | } | ||
75 | |||
76 | /* TLB resize via tlb_fill may have moved the entry. */ | ||
77 | + index = tlb_index(env, mmu_idx, addr); | ||
78 | entry = tlb_entry(env, mmu_idx, addr); | ||
79 | |||
80 | /* | ||
81 | @@ -XXX,XX +XXX,XX @@ static int probe_access_internal(CPUArchState *env, target_ulong addr, | ||
82 | } | ||
83 | flags &= tlb_addr; | ||
84 | |||
85 | + *pfull = &env_tlb(env)->d[mmu_idx].fulltlb[index]; | ||
86 | + | ||
87 | /* Fold all "mmio-like" bits into TLB_MMIO. This is not RAM. */ | ||
88 | if (unlikely(flags & ~(TLB_WATCHPOINT | TLB_NOTDIRTY))) { | ||
89 | *phost = NULL; | ||
90 | @@ -XXX,XX +XXX,XX @@ static int probe_access_internal(CPUArchState *env, target_ulong addr, | ||
91 | return flags; | ||
15 | } | 92 | } |
16 | 93 | ||
17 | +/* Signal overflow, starting over with fewer guest insns. */ | 94 | -int probe_access_flags(CPUArchState *env, target_ulong addr, |
18 | +static void QEMU_NORETURN tcg_raise_tb_overflow(TCGContext *s) | 95 | - MMUAccessType access_type, int mmu_idx, |
96 | - bool nonfault, void **phost, uintptr_t retaddr) | ||
97 | +int probe_access_full(CPUArchState *env, target_ulong addr, | ||
98 | + MMUAccessType access_type, int mmu_idx, | ||
99 | + bool nonfault, void **phost, CPUTLBEntryFull **pfull, | ||
100 | + uintptr_t retaddr) | ||
101 | { | ||
102 | - int flags; | ||
103 | - | ||
104 | - flags = probe_access_internal(env, addr, 0, access_type, mmu_idx, | ||
105 | - nonfault, phost, retaddr); | ||
106 | + int flags = probe_access_internal(env, addr, 0, access_type, mmu_idx, | ||
107 | + nonfault, phost, pfull, retaddr); | ||
108 | |||
109 | /* Handle clean RAM pages. */ | ||
110 | if (unlikely(flags & TLB_NOTDIRTY)) { | ||
111 | - uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
112 | - CPUTLBEntryFull *full = &env_tlb(env)->d[mmu_idx].fulltlb[index]; | ||
113 | - | ||
114 | - notdirty_write(env_cpu(env), addr, 1, full, retaddr); | ||
115 | + notdirty_write(env_cpu(env), addr, 1, *pfull, retaddr); | ||
116 | flags &= ~TLB_NOTDIRTY; | ||
117 | } | ||
118 | |||
119 | return flags; | ||
120 | } | ||
121 | |||
122 | +int probe_access_flags(CPUArchState *env, target_ulong addr, | ||
123 | + MMUAccessType access_type, int mmu_idx, | ||
124 | + bool nonfault, void **phost, uintptr_t retaddr) | ||
19 | +{ | 125 | +{ |
20 | + siglongjmp(s->jmp_trans, -2); | 126 | + CPUTLBEntryFull *full; |
127 | + | ||
128 | + return probe_access_full(env, addr, access_type, mmu_idx, | ||
129 | + nonfault, phost, &full, retaddr); | ||
21 | +} | 130 | +} |
22 | + | 131 | + |
23 | #define C_PFX1(P, A) P##A | 132 | void *probe_access(CPUArchState *env, target_ulong addr, int size, |
24 | #define C_PFX2(P, A, B) P##A##_##B | 133 | MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) |
25 | #define C_PFX3(P, A, B, C) P##A##_##B##_##C | 134 | { |
26 | @@ -XXX,XX +XXX,XX @@ static TCGTemp *tcg_temp_alloc(TCGContext *s) | 135 | + CPUTLBEntryFull *full; |
27 | int n = s->nb_temps++; | 136 | void *host; |
28 | 137 | int flags; | |
29 | if (n >= TCG_MAX_TEMPS) { | 138 | |
30 | - /* Signal overflow, starting over with fewer guest insns. */ | 139 | g_assert(-(addr | TARGET_PAGE_MASK) >= size); |
31 | - siglongjmp(s->jmp_trans, -2); | 140 | |
32 | + tcg_raise_tb_overflow(s); | 141 | flags = probe_access_internal(env, addr, size, access_type, mmu_idx, |
142 | - false, &host, retaddr); | ||
143 | + false, &host, &full, retaddr); | ||
144 | |||
145 | /* Per the interface, size == 0 merely faults the access. */ | ||
146 | if (size == 0) { | ||
147 | @@ -XXX,XX +XXX,XX @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, | ||
33 | } | 148 | } |
34 | return memset(&s->temps[n], 0, sizeof(TCGTemp)); | 149 | |
35 | } | 150 | if (unlikely(flags & (TLB_NOTDIRTY | TLB_WATCHPOINT))) { |
151 | - uintptr_t index = tlb_index(env, mmu_idx, addr); | ||
152 | - CPUTLBEntryFull *full = &env_tlb(env)->d[mmu_idx].fulltlb[index]; | ||
153 | - | ||
154 | /* Handle watchpoints. */ | ||
155 | if (flags & TLB_WATCHPOINT) { | ||
156 | int wp_access = (access_type == MMU_DATA_STORE | ||
157 | @@ -XXX,XX +XXX,XX @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, | ||
158 | void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, | ||
159 | MMUAccessType access_type, int mmu_idx) | ||
160 | { | ||
161 | + CPUTLBEntryFull *full; | ||
162 | void *host; | ||
163 | int flags; | ||
164 | |||
165 | flags = probe_access_internal(env, addr, 0, access_type, | ||
166 | - mmu_idx, true, &host, 0); | ||
167 | + mmu_idx, true, &host, &full, 0); | ||
168 | |||
169 | /* No combination of flags are expected by the caller. */ | ||
170 | return flags ? NULL : host; | ||
171 | @@ -XXX,XX +XXX,XX @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, | ||
172 | tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr, | ||
173 | void **hostp) | ||
174 | { | ||
175 | + CPUTLBEntryFull *full; | ||
176 | void *p; | ||
177 | |||
178 | (void)probe_access_internal(env, addr, 1, MMU_INST_FETCH, | ||
179 | - cpu_mmu_index(env, true), false, &p, 0); | ||
180 | + cpu_mmu_index(env, true), false, &p, &full, 0); | ||
181 | if (p == NULL) { | ||
182 | return -1; | ||
183 | } | ||
36 | -- | 184 | -- |
37 | 2.25.1 | 185 | 2.34.1 |
38 | 186 | ||
39 | 187 | diff view generated by jsdifflib |
1 | Use explicit casts for ext32u opcodes, and allow truncation | 1 | Now that we have collected all of the page data into |
---|---|---|---|
2 | to happen for other users. | 2 | CPUTLBEntryFull, provide an interface to record that |
3 | all in one go, instead of using 4 arguments. This interface | ||
4 | allows CPUTLBEntryFull to be extended without having to | ||
5 | change the number of arguments. | ||
3 | 6 | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | --- | 11 | --- |
7 | tcg/tci.c | 122 ++++++++++++++++++++++++------------------------------ | 12 | include/exec/cpu-defs.h | 14 +++++++++++ |
8 | 1 file changed, 54 insertions(+), 68 deletions(-) | 13 | include/exec/exec-all.h | 22 ++++++++++++++++++ |
14 | accel/tcg/cputlb.c | 51 ++++++++++++++++++++++++++--------------- | ||
15 | 3 files changed, 69 insertions(+), 18 deletions(-) | ||
9 | 16 | ||
10 | diff --git a/tcg/tci.c b/tcg/tci.c | 17 | diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h |
11 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/tcg/tci.c | 19 | --- a/include/exec/cpu-defs.h |
13 | +++ b/tcg/tci.c | 20 | +++ b/include/exec/cpu-defs.h |
14 | @@ -XXX,XX +XXX,XX @@ static int32_t tci_read_reg32s(const tcg_target_ulong *regs, TCGReg index) | 21 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUTLBEntryFull { |
22 | * + the offset within the target MemoryRegion (otherwise) | ||
23 | */ | ||
24 | hwaddr xlat_section; | ||
25 | + | ||
26 | + /* | ||
27 | + * @phys_addr contains the physical address in the address space | ||
28 | + * given by cpu_asidx_from_attrs(cpu, @attrs). | ||
29 | + */ | ||
30 | + hwaddr phys_addr; | ||
31 | + | ||
32 | + /* @attrs contains the memory transaction attributes for the page. */ | ||
33 | MemTxAttrs attrs; | ||
34 | + | ||
35 | + /* @prot contains the complete protections for the page. */ | ||
36 | + uint8_t prot; | ||
37 | + | ||
38 | + /* @lg_page_size contains the log2 of the page size. */ | ||
39 | + uint8_t lg_page_size; | ||
40 | } CPUTLBEntryFull; | ||
41 | |||
42 | /* | ||
43 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/include/exec/exec-all.h | ||
46 | +++ b/include/exec/exec-all.h | ||
47 | @@ -XXX,XX +XXX,XX @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, | ||
48 | uint16_t idxmap, | ||
49 | unsigned bits); | ||
50 | |||
51 | +/** | ||
52 | + * tlb_set_page_full: | ||
53 | + * @cpu: CPU context | ||
54 | + * @mmu_idx: mmu index of the tlb to modify | ||
55 | + * @vaddr: virtual address of the entry to add | ||
56 | + * @full: the details of the tlb entry | ||
57 | + * | ||
58 | + * Add an entry to @cpu tlb index @mmu_idx. All of the fields of | ||
59 | + * @full must be filled, except for xlat_section, and constitute | ||
60 | + * the complete description of the translated page. | ||
61 | + * | ||
62 | + * This is generally called by the target tlb_fill function after | ||
63 | + * having performed a successful page table walk to find the physical | ||
64 | + * address and attributes for the translation. | ||
65 | + * | ||
66 | + * At most one entry for a given virtual address is permitted. Only a | ||
67 | + * single TARGET_PAGE_SIZE region is mapped; @full->lg_page_size is only | ||
68 | + * used by tlb_flush_page. | ||
69 | + */ | ||
70 | +void tlb_set_page_full(CPUState *cpu, int mmu_idx, target_ulong vaddr, | ||
71 | + CPUTLBEntryFull *full); | ||
72 | + | ||
73 | /** | ||
74 | * tlb_set_page_with_attrs: | ||
75 | * @cpu: CPU to add this TLB entry for | ||
76 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/accel/tcg/cputlb.c | ||
79 | +++ b/accel/tcg/cputlb.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static void tlb_add_large_page(CPUArchState *env, int mmu_idx, | ||
81 | env_tlb(env)->d[mmu_idx].large_page_mask = lp_mask; | ||
15 | } | 82 | } |
16 | #endif | 83 | |
17 | 84 | -/* Add a new TLB entry. At most one entry for a given virtual address | |
18 | -static uint32_t tci_read_reg32(const tcg_target_ulong *regs, TCGReg index) | 85 | +/* |
19 | -{ | 86 | + * Add a new TLB entry. At most one entry for a given virtual address |
20 | - return (uint32_t)tci_read_reg(regs, index); | 87 | * is permitted. Only a single TARGET_PAGE_SIZE region is mapped, the |
21 | -} | 88 | * supplied size is only used by tlb_flush_page. |
22 | - | 89 | * |
23 | #if TCG_TARGET_REG_BITS == 64 | 90 | * Called from TCG-generated code, which is under an RCU read-side |
24 | static uint64_t tci_read_reg64(const tcg_target_ulong *regs, TCGReg index) | 91 | * critical section. |
92 | */ | ||
93 | -void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | ||
94 | - hwaddr paddr, MemTxAttrs attrs, int prot, | ||
95 | - int mmu_idx, target_ulong size) | ||
96 | +void tlb_set_page_full(CPUState *cpu, int mmu_idx, | ||
97 | + target_ulong vaddr, CPUTLBEntryFull *full) | ||
25 | { | 98 | { |
26 | @@ -XXX,XX +XXX,XX @@ tci_read_r(const tcg_target_ulong *regs, const uint8_t **tb_ptr) | 99 | CPUArchState *env = cpu->env_ptr; |
27 | return value; | 100 | CPUTLB *tlb = env_tlb(env); |
101 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | ||
102 | CPUTLBEntry *te, tn; | ||
103 | hwaddr iotlb, xlat, sz, paddr_page; | ||
104 | target_ulong vaddr_page; | ||
105 | - int asidx = cpu_asidx_from_attrs(cpu, attrs); | ||
106 | - int wp_flags; | ||
107 | + int asidx, wp_flags, prot; | ||
108 | bool is_ram, is_romd; | ||
109 | |||
110 | assert_cpu_is_self(cpu); | ||
111 | |||
112 | - if (size <= TARGET_PAGE_SIZE) { | ||
113 | + if (full->lg_page_size <= TARGET_PAGE_BITS) { | ||
114 | sz = TARGET_PAGE_SIZE; | ||
115 | } else { | ||
116 | - tlb_add_large_page(env, mmu_idx, vaddr, size); | ||
117 | - sz = size; | ||
118 | + sz = (hwaddr)1 << full->lg_page_size; | ||
119 | + tlb_add_large_page(env, mmu_idx, vaddr, sz); | ||
120 | } | ||
121 | vaddr_page = vaddr & TARGET_PAGE_MASK; | ||
122 | - paddr_page = paddr & TARGET_PAGE_MASK; | ||
123 | + paddr_page = full->phys_addr & TARGET_PAGE_MASK; | ||
124 | |||
125 | + prot = full->prot; | ||
126 | + asidx = cpu_asidx_from_attrs(cpu, full->attrs); | ||
127 | section = address_space_translate_for_iotlb(cpu, asidx, paddr_page, | ||
128 | - &xlat, &sz, attrs, &prot); | ||
129 | + &xlat, &sz, full->attrs, &prot); | ||
130 | assert(sz >= TARGET_PAGE_SIZE); | ||
131 | |||
132 | tlb_debug("vaddr=" TARGET_FMT_lx " paddr=0x" TARGET_FMT_plx | ||
133 | " prot=%x idx=%d\n", | ||
134 | - vaddr, paddr, prot, mmu_idx); | ||
135 | + vaddr, full->phys_addr, prot, mmu_idx); | ||
136 | |||
137 | address = vaddr_page; | ||
138 | - if (size < TARGET_PAGE_SIZE) { | ||
139 | + if (full->lg_page_size < TARGET_PAGE_BITS) { | ||
140 | /* Repeat the MMU check and TLB fill on every access. */ | ||
141 | address |= TLB_INVALID_MASK; | ||
142 | } | ||
143 | - if (attrs.byte_swap) { | ||
144 | + if (full->attrs.byte_swap) { | ||
145 | address |= TLB_BSWAP; | ||
146 | } | ||
147 | |||
148 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | ||
149 | * subtract here is that of the page base, and not the same as the | ||
150 | * vaddr we add back in io_readx()/io_writex()/get_page_addr_code(). | ||
151 | */ | ||
152 | + desc->fulltlb[index] = *full; | ||
153 | desc->fulltlb[index].xlat_section = iotlb - vaddr_page; | ||
154 | - desc->fulltlb[index].attrs = attrs; | ||
155 | + desc->fulltlb[index].phys_addr = paddr_page; | ||
156 | + desc->fulltlb[index].prot = prot; | ||
157 | |||
158 | /* Now calculate the new entry */ | ||
159 | tn.addend = addend - vaddr_page; | ||
160 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | ||
161 | qemu_spin_unlock(&tlb->c.lock); | ||
28 | } | 162 | } |
29 | 163 | ||
30 | -/* Read indexed register (32 bit) from bytecode. */ | 164 | -/* Add a new TLB entry, but without specifying the memory |
31 | -static uint32_t tci_read_r32(const tcg_target_ulong *regs, | 165 | - * transaction attributes to be used. |
32 | - const uint8_t **tb_ptr) | 166 | - */ |
33 | -{ | 167 | +void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, |
34 | - uint32_t value = tci_read_reg32(regs, **tb_ptr); | 168 | + hwaddr paddr, MemTxAttrs attrs, int prot, |
35 | - *tb_ptr += 1; | 169 | + int mmu_idx, target_ulong size) |
36 | - return value; | 170 | +{ |
37 | -} | 171 | + CPUTLBEntryFull full = { |
38 | - | 172 | + .phys_addr = paddr, |
39 | #if TCG_TARGET_REG_BITS == 32 | 173 | + .attrs = attrs, |
40 | /* Read two indexed registers (2 * 32 bit) from bytecode. */ | 174 | + .prot = prot, |
41 | static uint64_t tci_read_r64(const tcg_target_ulong *regs, | 175 | + .lg_page_size = ctz64(size) |
42 | const uint8_t **tb_ptr) | 176 | + }; |
43 | { | 177 | + |
44 | - uint32_t low = tci_read_r32(regs, tb_ptr); | 178 | + assert(is_power_of_2(size)); |
45 | - return tci_uint64(tci_read_r32(regs, tb_ptr), low); | 179 | + tlb_set_page_full(cpu, mmu_idx, vaddr, &full); |
46 | + uint32_t low = tci_read_r(regs, tb_ptr); | 180 | +} |
47 | + return tci_uint64(tci_read_r(regs, tb_ptr), low); | 181 | + |
48 | } | 182 | void tlb_set_page(CPUState *cpu, target_ulong vaddr, |
49 | #elif TCG_TARGET_REG_BITS == 64 | 183 | hwaddr paddr, int prot, |
50 | /* Read indexed register (32 bit signed) from bytecode. */ | 184 | int mmu_idx, target_ulong size) |
51 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
52 | continue; | ||
53 | case INDEX_op_setcond_i32: | ||
54 | t0 = *tb_ptr++; | ||
55 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
56 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
57 | + t1 = tci_read_r(regs, &tb_ptr); | ||
58 | + t2 = tci_read_r(regs, &tb_ptr); | ||
59 | condition = *tb_ptr++; | ||
60 | tci_write_reg(regs, t0, tci_compare32(t1, t2, condition)); | ||
61 | break; | ||
62 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
63 | #endif | ||
64 | case INDEX_op_mov_i32: | ||
65 | t0 = *tb_ptr++; | ||
66 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
67 | + t1 = tci_read_r(regs, &tb_ptr); | ||
68 | tci_write_reg(regs, t0, t1); | ||
69 | break; | ||
70 | case INDEX_op_tci_movi_i32: | ||
71 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
72 | break; | ||
73 | case INDEX_op_st_i32: | ||
74 | CASE_64(st32) | ||
75 | - t0 = tci_read_r32(regs, &tb_ptr); | ||
76 | + t0 = tci_read_r(regs, &tb_ptr); | ||
77 | t1 = tci_read_r(regs, &tb_ptr); | ||
78 | t2 = tci_read_s32(&tb_ptr); | ||
79 | *(uint32_t *)(t1 + t2) = t0; | ||
80 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
81 | |||
82 | case INDEX_op_add_i32: | ||
83 | t0 = *tb_ptr++; | ||
84 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
85 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
86 | + t1 = tci_read_r(regs, &tb_ptr); | ||
87 | + t2 = tci_read_r(regs, &tb_ptr); | ||
88 | tci_write_reg(regs, t0, t1 + t2); | ||
89 | break; | ||
90 | case INDEX_op_sub_i32: | ||
91 | t0 = *tb_ptr++; | ||
92 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
93 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
94 | + t1 = tci_read_r(regs, &tb_ptr); | ||
95 | + t2 = tci_read_r(regs, &tb_ptr); | ||
96 | tci_write_reg(regs, t0, t1 - t2); | ||
97 | break; | ||
98 | case INDEX_op_mul_i32: | ||
99 | t0 = *tb_ptr++; | ||
100 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
101 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
102 | + t1 = tci_read_r(regs, &tb_ptr); | ||
103 | + t2 = tci_read_r(regs, &tb_ptr); | ||
104 | tci_write_reg(regs, t0, t1 * t2); | ||
105 | break; | ||
106 | case INDEX_op_div_i32: | ||
107 | t0 = *tb_ptr++; | ||
108 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
109 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
110 | + t1 = tci_read_r(regs, &tb_ptr); | ||
111 | + t2 = tci_read_r(regs, &tb_ptr); | ||
112 | tci_write_reg(regs, t0, (int32_t)t1 / (int32_t)t2); | ||
113 | break; | ||
114 | case INDEX_op_divu_i32: | ||
115 | t0 = *tb_ptr++; | ||
116 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
117 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
118 | - tci_write_reg(regs, t0, t1 / t2); | ||
119 | + t1 = tci_read_r(regs, &tb_ptr); | ||
120 | + t2 = tci_read_r(regs, &tb_ptr); | ||
121 | + tci_write_reg(regs, t0, (uint32_t)t1 / (uint32_t)t2); | ||
122 | break; | ||
123 | case INDEX_op_rem_i32: | ||
124 | t0 = *tb_ptr++; | ||
125 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
126 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
127 | + t1 = tci_read_r(regs, &tb_ptr); | ||
128 | + t2 = tci_read_r(regs, &tb_ptr); | ||
129 | tci_write_reg(regs, t0, (int32_t)t1 % (int32_t)t2); | ||
130 | break; | ||
131 | case INDEX_op_remu_i32: | ||
132 | t0 = *tb_ptr++; | ||
133 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
134 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
135 | - tci_write_reg(regs, t0, t1 % t2); | ||
136 | + t1 = tci_read_r(regs, &tb_ptr); | ||
137 | + t2 = tci_read_r(regs, &tb_ptr); | ||
138 | + tci_write_reg(regs, t0, (uint32_t)t1 % (uint32_t)t2); | ||
139 | break; | ||
140 | case INDEX_op_and_i32: | ||
141 | t0 = *tb_ptr++; | ||
142 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
143 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
144 | + t1 = tci_read_r(regs, &tb_ptr); | ||
145 | + t2 = tci_read_r(regs, &tb_ptr); | ||
146 | tci_write_reg(regs, t0, t1 & t2); | ||
147 | break; | ||
148 | case INDEX_op_or_i32: | ||
149 | t0 = *tb_ptr++; | ||
150 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
151 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
152 | + t1 = tci_read_r(regs, &tb_ptr); | ||
153 | + t2 = tci_read_r(regs, &tb_ptr); | ||
154 | tci_write_reg(regs, t0, t1 | t2); | ||
155 | break; | ||
156 | case INDEX_op_xor_i32: | ||
157 | t0 = *tb_ptr++; | ||
158 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
159 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
160 | + t1 = tci_read_r(regs, &tb_ptr); | ||
161 | + t2 = tci_read_r(regs, &tb_ptr); | ||
162 | tci_write_reg(regs, t0, t1 ^ t2); | ||
163 | break; | ||
164 | |||
165 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
166 | |||
167 | case INDEX_op_shl_i32: | ||
168 | t0 = *tb_ptr++; | ||
169 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
170 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
171 | - tci_write_reg(regs, t0, t1 << (t2 & 31)); | ||
172 | + t1 = tci_read_r(regs, &tb_ptr); | ||
173 | + t2 = tci_read_r(regs, &tb_ptr); | ||
174 | + tci_write_reg(regs, t0, (uint32_t)t1 << (t2 & 31)); | ||
175 | break; | ||
176 | case INDEX_op_shr_i32: | ||
177 | t0 = *tb_ptr++; | ||
178 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
179 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
180 | - tci_write_reg(regs, t0, t1 >> (t2 & 31)); | ||
181 | + t1 = tci_read_r(regs, &tb_ptr); | ||
182 | + t2 = tci_read_r(regs, &tb_ptr); | ||
183 | + tci_write_reg(regs, t0, (uint32_t)t1 >> (t2 & 31)); | ||
184 | break; | ||
185 | case INDEX_op_sar_i32: | ||
186 | t0 = *tb_ptr++; | ||
187 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
188 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
189 | - tci_write_reg(regs, t0, ((int32_t)t1 >> (t2 & 31))); | ||
190 | + t1 = tci_read_r(regs, &tb_ptr); | ||
191 | + t2 = tci_read_r(regs, &tb_ptr); | ||
192 | + tci_write_reg(regs, t0, (int32_t)t1 >> (t2 & 31)); | ||
193 | break; | ||
194 | #if TCG_TARGET_HAS_rot_i32 | ||
195 | case INDEX_op_rotl_i32: | ||
196 | t0 = *tb_ptr++; | ||
197 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
198 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
199 | + t1 = tci_read_r(regs, &tb_ptr); | ||
200 | + t2 = tci_read_r(regs, &tb_ptr); | ||
201 | tci_write_reg(regs, t0, rol32(t1, t2 & 31)); | ||
202 | break; | ||
203 | case INDEX_op_rotr_i32: | ||
204 | t0 = *tb_ptr++; | ||
205 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
206 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
207 | + t1 = tci_read_r(regs, &tb_ptr); | ||
208 | + t2 = tci_read_r(regs, &tb_ptr); | ||
209 | tci_write_reg(regs, t0, ror32(t1, t2 & 31)); | ||
210 | break; | ||
211 | #endif | ||
212 | #if TCG_TARGET_HAS_deposit_i32 | ||
213 | case INDEX_op_deposit_i32: | ||
214 | t0 = *tb_ptr++; | ||
215 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
216 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
217 | + t1 = tci_read_r(regs, &tb_ptr); | ||
218 | + t2 = tci_read_r(regs, &tb_ptr); | ||
219 | tmp16 = *tb_ptr++; | ||
220 | tmp8 = *tb_ptr++; | ||
221 | tmp32 = (((1 << tmp8) - 1) << tmp16); | ||
222 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
223 | break; | ||
224 | #endif | ||
225 | case INDEX_op_brcond_i32: | ||
226 | - t0 = tci_read_r32(regs, &tb_ptr); | ||
227 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
228 | + t0 = tci_read_r(regs, &tb_ptr); | ||
229 | + t1 = tci_read_r(regs, &tb_ptr); | ||
230 | condition = *tb_ptr++; | ||
231 | label = tci_read_label(&tb_ptr); | ||
232 | if (tci_compare32(t0, t1, condition)) { | ||
233 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
234 | case INDEX_op_mulu2_i32: | ||
235 | t0 = *tb_ptr++; | ||
236 | t1 = *tb_ptr++; | ||
237 | - t2 = tci_read_r32(regs, &tb_ptr); | ||
238 | - tmp64 = tci_read_r32(regs, &tb_ptr); | ||
239 | - tci_write_reg64(regs, t1, t0, t2 * tmp64); | ||
240 | + t2 = tci_read_r(regs, &tb_ptr); | ||
241 | + tmp64 = (uint32_t)tci_read_r(regs, &tb_ptr); | ||
242 | + tci_write_reg64(regs, t1, t0, (uint32_t)t2 * tmp64); | ||
243 | break; | ||
244 | #endif /* TCG_TARGET_REG_BITS == 32 */ | ||
245 | #if TCG_TARGET_HAS_ext8s_i32 | ||
246 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
247 | #if TCG_TARGET_HAS_bswap32_i32 | ||
248 | case INDEX_op_bswap32_i32: | ||
249 | t0 = *tb_ptr++; | ||
250 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
251 | + t1 = tci_read_r(regs, &tb_ptr); | ||
252 | tci_write_reg(regs, t0, bswap32(t1)); | ||
253 | break; | ||
254 | #endif | ||
255 | #if TCG_TARGET_HAS_not_i32 | ||
256 | case INDEX_op_not_i32: | ||
257 | t0 = *tb_ptr++; | ||
258 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
259 | + t1 = tci_read_r(regs, &tb_ptr); | ||
260 | tci_write_reg(regs, t0, ~t1); | ||
261 | break; | ||
262 | #endif | ||
263 | #if TCG_TARGET_HAS_neg_i32 | ||
264 | case INDEX_op_neg_i32: | ||
265 | t0 = *tb_ptr++; | ||
266 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
267 | + t1 = tci_read_r(regs, &tb_ptr); | ||
268 | tci_write_reg(regs, t0, -t1); | ||
269 | break; | ||
270 | #endif | ||
271 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
272 | #endif | ||
273 | case INDEX_op_extu_i32_i64: | ||
274 | t0 = *tb_ptr++; | ||
275 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
276 | - tci_write_reg(regs, t0, t1); | ||
277 | + t1 = tci_read_r(regs, &tb_ptr); | ||
278 | + tci_write_reg(regs, t0, (uint32_t)t1); | ||
279 | break; | ||
280 | #if TCG_TARGET_HAS_bswap16_i64 | ||
281 | case INDEX_op_bswap16_i64: | ||
282 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
283 | #if TCG_TARGET_HAS_bswap32_i64 | ||
284 | case INDEX_op_bswap32_i64: | ||
285 | t0 = *tb_ptr++; | ||
286 | - t1 = tci_read_r32(regs, &tb_ptr); | ||
287 | + t1 = tci_read_r(regs, &tb_ptr); | ||
288 | tci_write_reg(regs, t0, bswap32(t1)); | ||
289 | break; | ||
290 | #endif | ||
291 | -- | 185 | -- |
292 | 2.25.1 | 186 | 2.34.1 |
293 | 187 | ||
294 | 188 | diff view generated by jsdifflib |
1 | This includes ext8s, ext8u, ext16s, ext16u. | 1 | Allow the target to cache items from the guest page tables. |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | --- | 7 | --- |
6 | tcg/tci.c | 44 ++++++++------------------------------------ | 8 | include/exec/cpu-defs.h | 9 +++++++++ |
7 | 1 file changed, 8 insertions(+), 36 deletions(-) | 9 | 1 file changed, 9 insertions(+) |
8 | 10 | ||
9 | diff --git a/tcg/tci.c b/tcg/tci.c | 11 | diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h |
10 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/tcg/tci.c | 13 | --- a/include/exec/cpu-defs.h |
12 | +++ b/tcg/tci.c | 14 | +++ b/include/exec/cpu-defs.h |
13 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUTLBEntryFull { |
14 | tci_write_reg64(regs, t1, t0, (uint32_t)t2 * tmp64); | 16 | |
15 | break; | 17 | /* @lg_page_size contains the log2 of the page size. */ |
16 | #endif /* TCG_TARGET_REG_BITS == 32 */ | 18 | uint8_t lg_page_size; |
17 | -#if TCG_TARGET_HAS_ext8s_i32 | 19 | + |
18 | - case INDEX_op_ext8s_i32: | 20 | + /* |
19 | +#if TCG_TARGET_HAS_ext8s_i32 || TCG_TARGET_HAS_ext8s_i64 | 21 | + * Allow target-specific additions to this structure. |
20 | + CASE_32_64(ext8s) | 22 | + * This may be used to cache items from the guest cpu |
21 | t0 = *tb_ptr++; | 23 | + * page tables for later use by the implementation. |
22 | t1 = tci_read_r(regs, &tb_ptr); | 24 | + */ |
23 | tci_write_reg(regs, t0, (int8_t)t1); | 25 | +#ifdef TARGET_PAGE_ENTRY_EXTRA |
24 | break; | 26 | + TARGET_PAGE_ENTRY_EXTRA |
25 | #endif | 27 | +#endif |
26 | -#if TCG_TARGET_HAS_ext16s_i32 | 28 | } CPUTLBEntryFull; |
27 | - case INDEX_op_ext16s_i32: | 29 | |
28 | +#if TCG_TARGET_HAS_ext16s_i32 || TCG_TARGET_HAS_ext16s_i64 | 30 | /* |
29 | + CASE_32_64(ext16s) | ||
30 | t0 = *tb_ptr++; | ||
31 | t1 = tci_read_r(regs, &tb_ptr); | ||
32 | tci_write_reg(regs, t0, (int16_t)t1); | ||
33 | break; | ||
34 | #endif | ||
35 | -#if TCG_TARGET_HAS_ext8u_i32 | ||
36 | - case INDEX_op_ext8u_i32: | ||
37 | +#if TCG_TARGET_HAS_ext8u_i32 || TCG_TARGET_HAS_ext8u_i64 | ||
38 | + CASE_32_64(ext8u) | ||
39 | t0 = *tb_ptr++; | ||
40 | t1 = tci_read_r(regs, &tb_ptr); | ||
41 | tci_write_reg(regs, t0, (uint8_t)t1); | ||
42 | break; | ||
43 | #endif | ||
44 | -#if TCG_TARGET_HAS_ext16u_i32 | ||
45 | - case INDEX_op_ext16u_i32: | ||
46 | +#if TCG_TARGET_HAS_ext16u_i32 || TCG_TARGET_HAS_ext16u_i64 | ||
47 | + CASE_32_64(ext16u) | ||
48 | t0 = *tb_ptr++; | ||
49 | t1 = tci_read_r(regs, &tb_ptr); | ||
50 | tci_write_reg(regs, t0, (uint16_t)t1); | ||
51 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
52 | continue; | ||
53 | } | ||
54 | break; | ||
55 | -#if TCG_TARGET_HAS_ext8u_i64 | ||
56 | - case INDEX_op_ext8u_i64: | ||
57 | - t0 = *tb_ptr++; | ||
58 | - t1 = tci_read_r(regs, &tb_ptr); | ||
59 | - tci_write_reg(regs, t0, (uint8_t)t1); | ||
60 | - break; | ||
61 | -#endif | ||
62 | -#if TCG_TARGET_HAS_ext8s_i64 | ||
63 | - case INDEX_op_ext8s_i64: | ||
64 | - t0 = *tb_ptr++; | ||
65 | - t1 = tci_read_r(regs, &tb_ptr); | ||
66 | - tci_write_reg(regs, t0, (int8_t)t1); | ||
67 | - break; | ||
68 | -#endif | ||
69 | -#if TCG_TARGET_HAS_ext16s_i64 | ||
70 | - case INDEX_op_ext16s_i64: | ||
71 | - t0 = *tb_ptr++; | ||
72 | - t1 = tci_read_r(regs, &tb_ptr); | ||
73 | - tci_write_reg(regs, t0, (int16_t)t1); | ||
74 | - break; | ||
75 | -#endif | ||
76 | -#if TCG_TARGET_HAS_ext16u_i64 | ||
77 | - case INDEX_op_ext16u_i64: | ||
78 | - t0 = *tb_ptr++; | ||
79 | - t1 = tci_read_r(regs, &tb_ptr); | ||
80 | - tci_write_reg(regs, t0, (uint16_t)t1); | ||
81 | - break; | ||
82 | -#endif | ||
83 | #if TCG_TARGET_HAS_ext32s_i64 | ||
84 | case INDEX_op_ext32s_i64: | ||
85 | #endif | ||
86 | -- | 31 | -- |
87 | 2.25.1 | 32 | 2.34.1 |
88 | 33 | ||
89 | 34 | diff view generated by jsdifflib |
1 | Use explicit casts for ext32s opcodes. | 1 | This bitmap is created and discarded immediately. |
---|---|---|---|
2 | We gain nothing by its existence. | ||
2 | 3 | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-Id: <20220822232338.1727934-2-richard.henderson@linaro.org> | ||
5 | --- | 7 | --- |
6 | tcg/tci.c | 20 ++------------------ | 8 | accel/tcg/translate-all.c | 78 ++------------------------------------- |
7 | 1 file changed, 2 insertions(+), 18 deletions(-) | 9 | 1 file changed, 4 insertions(+), 74 deletions(-) |
8 | 10 | ||
9 | diff --git a/tcg/tci.c b/tcg/tci.c | 11 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c |
10 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/tcg/tci.c | 13 | --- a/accel/tcg/translate-all.c |
12 | +++ b/tcg/tci.c | 14 | +++ b/accel/tcg/translate-all.c |
13 | @@ -XXX,XX +XXX,XX @@ static tcg_target_ulong tci_read_reg(const tcg_target_ulong *regs, TCGReg index) | 15 | @@ -XXX,XX +XXX,XX @@ |
14 | return regs[index]; | 16 | #define assert_memory_lock() tcg_debug_assert(have_mmap_lock()) |
17 | #endif | ||
18 | |||
19 | -#define SMC_BITMAP_USE_THRESHOLD 10 | ||
20 | - | ||
21 | typedef struct PageDesc { | ||
22 | /* list of TBs intersecting this ram page */ | ||
23 | uintptr_t first_tb; | ||
24 | -#ifdef CONFIG_SOFTMMU | ||
25 | - /* in order to optimize self modifying code, we count the number | ||
26 | - of lookups we do to a given page to use a bitmap */ | ||
27 | - unsigned long *code_bitmap; | ||
28 | - unsigned int code_write_count; | ||
29 | -#else | ||
30 | +#ifdef CONFIG_USER_ONLY | ||
31 | unsigned long flags; | ||
32 | void *target_data; | ||
33 | #endif | ||
34 | -#ifndef CONFIG_USER_ONLY | ||
35 | +#ifdef CONFIG_SOFTMMU | ||
36 | QemuSpin lock; | ||
37 | #endif | ||
38 | } PageDesc; | ||
39 | @@ -XXX,XX +XXX,XX @@ void tb_htable_init(void) | ||
40 | qht_init(&tb_ctx.htable, tb_cmp, CODE_GEN_HTABLE_SIZE, mode); | ||
15 | } | 41 | } |
16 | 42 | ||
17 | -#if TCG_TARGET_REG_BITS == 64 | 43 | -/* call with @p->lock held */ |
18 | -static int32_t tci_read_reg32s(const tcg_target_ulong *regs, TCGReg index) | 44 | -static inline void invalidate_page_bitmap(PageDesc *p) |
19 | -{ | 45 | -{ |
20 | - return (int32_t)tci_read_reg(regs, index); | 46 | - assert_page_locked(p); |
47 | -#ifdef CONFIG_SOFTMMU | ||
48 | - g_free(p->code_bitmap); | ||
49 | - p->code_bitmap = NULL; | ||
50 | - p->code_write_count = 0; | ||
51 | -#endif | ||
52 | -} | ||
53 | - | ||
54 | /* Set to NULL all the 'first_tb' fields in all PageDescs. */ | ||
55 | static void page_flush_tb_1(int level, void **lp) | ||
56 | { | ||
57 | @@ -XXX,XX +XXX,XX @@ static void page_flush_tb_1(int level, void **lp) | ||
58 | for (i = 0; i < V_L2_SIZE; ++i) { | ||
59 | page_lock(&pd[i]); | ||
60 | pd[i].first_tb = (uintptr_t)NULL; | ||
61 | - invalidate_page_bitmap(pd + i); | ||
62 | page_unlock(&pd[i]); | ||
63 | } | ||
64 | } else { | ||
65 | @@ -XXX,XX +XXX,XX @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) | ||
66 | if (rm_from_page_list) { | ||
67 | p = page_find(tb->page_addr[0] >> TARGET_PAGE_BITS); | ||
68 | tb_page_remove(p, tb); | ||
69 | - invalidate_page_bitmap(p); | ||
70 | if (tb->page_addr[1] != -1) { | ||
71 | p = page_find(tb->page_addr[1] >> TARGET_PAGE_BITS); | ||
72 | tb_page_remove(p, tb); | ||
73 | - invalidate_page_bitmap(p); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | @@ -XXX,XX +XXX,XX @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) | ||
78 | } | ||
79 | } | ||
80 | |||
81 | -#ifdef CONFIG_SOFTMMU | ||
82 | -/* call with @p->lock held */ | ||
83 | -static void build_page_bitmap(PageDesc *p) | ||
84 | -{ | ||
85 | - int n, tb_start, tb_end; | ||
86 | - TranslationBlock *tb; | ||
87 | - | ||
88 | - assert_page_locked(p); | ||
89 | - p->code_bitmap = bitmap_new(TARGET_PAGE_SIZE); | ||
90 | - | ||
91 | - PAGE_FOR_EACH_TB(p, tb, n) { | ||
92 | - /* NOTE: this is subtle as a TB may span two physical pages */ | ||
93 | - if (n == 0) { | ||
94 | - /* NOTE: tb_end may be after the end of the page, but | ||
95 | - it is not a problem */ | ||
96 | - tb_start = tb->pc & ~TARGET_PAGE_MASK; | ||
97 | - tb_end = tb_start + tb->size; | ||
98 | - if (tb_end > TARGET_PAGE_SIZE) { | ||
99 | - tb_end = TARGET_PAGE_SIZE; | ||
100 | - } | ||
101 | - } else { | ||
102 | - tb_start = 0; | ||
103 | - tb_end = ((tb->pc + tb->size) & ~TARGET_PAGE_MASK); | ||
104 | - } | ||
105 | - bitmap_set(p->code_bitmap, tb_start, tb_end - tb_start); | ||
106 | - } | ||
21 | -} | 107 | -} |
22 | -#endif | 108 | -#endif |
23 | - | 109 | - |
24 | #if TCG_TARGET_REG_BITS == 64 | 110 | /* add the tb in the target page and protect it if necessary |
25 | static uint64_t tci_read_reg64(const tcg_target_ulong *regs, TCGReg index) | 111 | * |
26 | { | 112 | * Called with mmap_lock held for user-mode emulation. |
27 | @@ -XXX,XX +XXX,XX @@ static uint64_t tci_read_r64(const tcg_target_ulong *regs, | 113 | @@ -XXX,XX +XXX,XX @@ static inline void tb_page_add(PageDesc *p, TranslationBlock *tb, |
28 | return tci_uint64(tci_read_r(regs, tb_ptr), low); | 114 | page_already_protected = p->first_tb != (uintptr_t)NULL; |
115 | #endif | ||
116 | p->first_tb = (uintptr_t)tb | n; | ||
117 | - invalidate_page_bitmap(p); | ||
118 | |||
119 | #if defined(CONFIG_USER_ONLY) | ||
120 | /* translator_loop() must have made all TB pages non-writable */ | ||
121 | @@ -XXX,XX +XXX,XX @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, | ||
122 | /* remove TB from the page(s) if we couldn't insert it */ | ||
123 | if (unlikely(existing_tb)) { | ||
124 | tb_page_remove(p, tb); | ||
125 | - invalidate_page_bitmap(p); | ||
126 | if (p2) { | ||
127 | tb_page_remove(p2, tb); | ||
128 | - invalidate_page_bitmap(p2); | ||
129 | } | ||
130 | tb = existing_tb; | ||
131 | } | ||
132 | @@ -XXX,XX +XXX,XX @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, | ||
133 | #if !defined(CONFIG_USER_ONLY) | ||
134 | /* if no code remaining, no need to continue to use slow writes */ | ||
135 | if (!p->first_tb) { | ||
136 | - invalidate_page_bitmap(p); | ||
137 | tlb_unprotect_code(start); | ||
138 | } | ||
139 | #endif | ||
140 | @@ -XXX,XX +XXX,XX @@ void tb_invalidate_phys_page_fast(struct page_collection *pages, | ||
141 | } | ||
142 | |||
143 | assert_page_locked(p); | ||
144 | - if (!p->code_bitmap && | ||
145 | - ++p->code_write_count >= SMC_BITMAP_USE_THRESHOLD) { | ||
146 | - build_page_bitmap(p); | ||
147 | - } | ||
148 | - if (p->code_bitmap) { | ||
149 | - unsigned int nr; | ||
150 | - unsigned long b; | ||
151 | - | ||
152 | - nr = start & ~TARGET_PAGE_MASK; | ||
153 | - b = p->code_bitmap[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG - 1)); | ||
154 | - if (b & ((1 << len) - 1)) { | ||
155 | - goto do_invalidate; | ||
156 | - } | ||
157 | - } else { | ||
158 | - do_invalidate: | ||
159 | - tb_invalidate_phys_page_range__locked(pages, p, start, start + len, | ||
160 | - retaddr); | ||
161 | - } | ||
162 | + tb_invalidate_phys_page_range__locked(pages, p, start, start + len, | ||
163 | + retaddr); | ||
29 | } | 164 | } |
30 | #elif TCG_TARGET_REG_BITS == 64 | 165 | #else |
31 | -/* Read indexed register (32 bit signed) from bytecode. */ | 166 | /* Called with mmap_lock held. If pc is not 0 then it indicates the |
32 | -static int32_t tci_read_r32s(const tcg_target_ulong *regs, | ||
33 | - const uint8_t **tb_ptr) | ||
34 | -{ | ||
35 | - int32_t value = tci_read_reg32s(regs, **tb_ptr); | ||
36 | - *tb_ptr += 1; | ||
37 | - return value; | ||
38 | -} | ||
39 | - | ||
40 | /* Read indexed register (64 bit) from bytecode. */ | ||
41 | static uint64_t tci_read_r64(const tcg_target_ulong *regs, | ||
42 | const uint8_t **tb_ptr) | ||
43 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
44 | #endif | ||
45 | case INDEX_op_ext_i32_i64: | ||
46 | t0 = *tb_ptr++; | ||
47 | - t1 = tci_read_r32s(regs, &tb_ptr); | ||
48 | - tci_write_reg(regs, t0, t1); | ||
49 | + t1 = tci_read_r(regs, &tb_ptr); | ||
50 | + tci_write_reg(regs, t0, (int32_t)t1); | ||
51 | break; | ||
52 | #if TCG_TARGET_HAS_ext32u_i64 | ||
53 | case INDEX_op_ext32u_i64: | ||
54 | -- | 167 | -- |
55 | 2.25.1 | 168 | 2.34.1 |
56 | 169 | ||
57 | 170 | diff view generated by jsdifflib |
1 | Use explicit casts for ext16s opcodes. | 1 | Bool is more appropriate type for the alloc parameter. |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | --- | 6 | --- |
6 | tcg/tci.c | 26 ++++---------------------- | 7 | accel/tcg/translate-all.c | 14 +++++++------- |
7 | 1 file changed, 4 insertions(+), 22 deletions(-) | 8 | 1 file changed, 7 insertions(+), 7 deletions(-) |
8 | 9 | ||
9 | diff --git a/tcg/tci.c b/tcg/tci.c | 10 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c |
10 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/tcg/tci.c | 12 | --- a/accel/tcg/translate-all.c |
12 | +++ b/tcg/tci.c | 13 | +++ b/accel/tcg/translate-all.c |
13 | @@ -XXX,XX +XXX,XX @@ static tcg_target_ulong tci_read_reg(const tcg_target_ulong *regs, TCGReg index) | 14 | @@ -XXX,XX +XXX,XX @@ void page_init(void) |
14 | return regs[index]; | 15 | #endif |
15 | } | 16 | } |
16 | 17 | ||
17 | -#if TCG_TARGET_HAS_ext16s_i32 || TCG_TARGET_HAS_ext16s_i64 | 18 | -static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc) |
18 | -static int16_t tci_read_reg16s(const tcg_target_ulong *regs, TCGReg index) | 19 | +static PageDesc *page_find_alloc(tb_page_addr_t index, bool alloc) |
19 | -{ | ||
20 | - return (int16_t)tci_read_reg(regs, index); | ||
21 | -} | ||
22 | -#endif | ||
23 | - | ||
24 | #if TCG_TARGET_REG_BITS == 64 | ||
25 | static int32_t tci_read_reg32s(const tcg_target_ulong *regs, TCGReg index) | ||
26 | { | 20 | { |
27 | @@ -XXX,XX +XXX,XX @@ tci_read_r(const tcg_target_ulong *regs, const uint8_t **tb_ptr) | 21 | PageDesc *pd; |
28 | return value; | 22 | void **lp; |
23 | @@ -XXX,XX +XXX,XX @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc) | ||
24 | |||
25 | static inline PageDesc *page_find(tb_page_addr_t index) | ||
26 | { | ||
27 | - return page_find_alloc(index, 0); | ||
28 | + return page_find_alloc(index, false); | ||
29 | } | 29 | } |
30 | 30 | ||
31 | -#if TCG_TARGET_HAS_ext16s_i32 || TCG_TARGET_HAS_ext16s_i64 | 31 | static void page_lock_pair(PageDesc **ret_p1, tb_page_addr_t phys1, |
32 | -/* Read indexed register (16 bit signed) from bytecode. */ | 32 | - PageDesc **ret_p2, tb_page_addr_t phys2, int alloc); |
33 | -static int16_t tci_read_r16s(const tcg_target_ulong *regs, | 33 | + PageDesc **ret_p2, tb_page_addr_t phys2, bool alloc); |
34 | - const uint8_t **tb_ptr) | 34 | |
35 | -{ | 35 | /* In user-mode page locks aren't used; mmap_lock is enough */ |
36 | - int16_t value = tci_read_reg16s(regs, **tb_ptr); | 36 | #ifdef CONFIG_USER_ONLY |
37 | - *tb_ptr += 1; | 37 | @@ -XXX,XX +XXX,XX @@ static inline void page_unlock(PageDesc *pd) |
38 | - return value; | 38 | /* lock the page(s) of a TB in the correct acquisition order */ |
39 | -} | 39 | static inline void page_lock_tb(const TranslationBlock *tb) |
40 | -#endif | 40 | { |
41 | - | 41 | - page_lock_pair(NULL, tb->page_addr[0], NULL, tb->page_addr[1], 0); |
42 | /* Read indexed register (32 bit) from bytecode. */ | 42 | + page_lock_pair(NULL, tb->page_addr[0], NULL, tb->page_addr[1], false); |
43 | static uint32_t tci_read_r32(const tcg_target_ulong *regs, | 43 | } |
44 | const uint8_t **tb_ptr) | 44 | |
45 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 45 | static inline void page_unlock_tb(const TranslationBlock *tb) |
46 | #if TCG_TARGET_HAS_ext16s_i32 | 46 | @@ -XXX,XX +XXX,XX @@ void page_collection_unlock(struct page_collection *set) |
47 | case INDEX_op_ext16s_i32: | 47 | #endif /* !CONFIG_USER_ONLY */ |
48 | t0 = *tb_ptr++; | 48 | |
49 | - t1 = tci_read_r16s(regs, &tb_ptr); | 49 | static void page_lock_pair(PageDesc **ret_p1, tb_page_addr_t phys1, |
50 | - tci_write_reg(regs, t0, t1); | 50 | - PageDesc **ret_p2, tb_page_addr_t phys2, int alloc) |
51 | + t1 = tci_read_r(regs, &tb_ptr); | 51 | + PageDesc **ret_p2, tb_page_addr_t phys2, bool alloc) |
52 | + tci_write_reg(regs, t0, (int16_t)t1); | 52 | { |
53 | break; | 53 | PageDesc *p1, *p2; |
54 | #endif | 54 | tb_page_addr_t page1; |
55 | #if TCG_TARGET_HAS_ext8u_i32 | 55 | @@ -XXX,XX +XXX,XX @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, |
56 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 56 | * Note that inserting into the hash table first isn't an option, since |
57 | #if TCG_TARGET_HAS_ext16s_i64 | 57 | * we can only insert TBs that are fully initialized. |
58 | case INDEX_op_ext16s_i64: | 58 | */ |
59 | t0 = *tb_ptr++; | 59 | - page_lock_pair(&p, phys_pc, &p2, phys_page2, 1); |
60 | - t1 = tci_read_r16s(regs, &tb_ptr); | 60 | + page_lock_pair(&p, phys_pc, &p2, phys_page2, true); |
61 | - tci_write_reg(regs, t0, t1); | 61 | tb_page_add(p, tb, 0, phys_pc & TARGET_PAGE_MASK); |
62 | + t1 = tci_read_r(regs, &tb_ptr); | 62 | if (p2) { |
63 | + tci_write_reg(regs, t0, (int16_t)t1); | 63 | tb_page_add(p2, tb, 1, phys_page2); |
64 | break; | 64 | @@ -XXX,XX +XXX,XX @@ void page_set_flags(target_ulong start, target_ulong end, int flags) |
65 | #endif | 65 | for (addr = start, len = end - start; |
66 | #if TCG_TARGET_HAS_ext16u_i64 | 66 | len != 0; |
67 | len -= TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) { | ||
68 | - PageDesc *p = page_find_alloc(addr >> TARGET_PAGE_BITS, 1); | ||
69 | + PageDesc *p = page_find_alloc(addr >> TARGET_PAGE_BITS, true); | ||
70 | |||
71 | /* If the write protection bit is set, then we invalidate | ||
72 | the code inside. */ | ||
67 | -- | 73 | -- |
68 | 2.25.1 | 74 | 2.34.1 |
69 | 75 | ||
70 | 76 | diff view generated by jsdifflib |
1 | The use in tcg_tb_lookup is given a random pc that comes from the pc | 1 | Use the pc coming from db->pc_first rather than the TB. |
---|---|---|---|
2 | of a signal handler. Do not assert that the pointer is already within | ||
3 | the code gen buffer at all, much less the writable mirror of it. | ||
4 | 2 | ||
5 | Fixes: db0c51a3803 | 3 | Use the cached host_addr rather than re-computing for the |
4 | first page. We still need a separate lookup for the second | ||
5 | page because it won't be computed for DisasContextBase until | ||
6 | the translator actually performs a read from the page. | ||
7 | |||
8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | --- | 10 | --- |
8 | tcg/tcg.c | 20 ++++++++++++++++++-- | 11 | include/exec/plugin-gen.h | 7 ++++--- |
9 | 1 file changed, 18 insertions(+), 2 deletions(-) | 12 | accel/tcg/plugin-gen.c | 22 +++++++++++----------- |
13 | accel/tcg/translator.c | 2 +- | ||
14 | 3 files changed, 16 insertions(+), 15 deletions(-) | ||
10 | 15 | ||
11 | diff --git a/tcg/tcg.c b/tcg/tcg.c | 16 | diff --git a/include/exec/plugin-gen.h b/include/exec/plugin-gen.h |
12 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/tcg/tcg.c | 18 | --- a/include/exec/plugin-gen.h |
14 | +++ b/tcg/tcg.c | 19 | +++ b/include/exec/plugin-gen.h |
15 | @@ -XXX,XX +XXX,XX @@ static void tcg_region_trees_init(void) | 20 | @@ -XXX,XX +XXX,XX @@ struct DisasContextBase; |
21 | |||
22 | #ifdef CONFIG_PLUGIN | ||
23 | |||
24 | -bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb, bool supress); | ||
25 | +bool plugin_gen_tb_start(CPUState *cpu, const struct DisasContextBase *db, | ||
26 | + bool supress); | ||
27 | void plugin_gen_tb_end(CPUState *cpu); | ||
28 | void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db); | ||
29 | void plugin_gen_insn_end(void); | ||
30 | @@ -XXX,XX +XXX,XX @@ static inline void plugin_insn_append(abi_ptr pc, const void *from, size_t size) | ||
31 | |||
32 | #else /* !CONFIG_PLUGIN */ | ||
33 | |||
34 | -static inline | ||
35 | -bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb, bool supress) | ||
36 | +static inline bool | ||
37 | +plugin_gen_tb_start(CPUState *cpu, const struct DisasContextBase *db, bool sup) | ||
38 | { | ||
39 | return false; | ||
40 | } | ||
41 | diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/accel/tcg/plugin-gen.c | ||
44 | +++ b/accel/tcg/plugin-gen.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void plugin_gen_inject(const struct qemu_plugin_tb *plugin_tb) | ||
46 | pr_ops(); | ||
47 | } | ||
48 | |||
49 | -bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb, bool mem_only) | ||
50 | +bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db, | ||
51 | + bool mem_only) | ||
52 | { | ||
53 | bool ret = false; | ||
54 | |||
55 | @@ -XXX,XX +XXX,XX @@ bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb, bool mem_onl | ||
56 | |||
57 | ret = true; | ||
58 | |||
59 | - ptb->vaddr = tb->pc; | ||
60 | + ptb->vaddr = db->pc_first; | ||
61 | ptb->vaddr2 = -1; | ||
62 | - get_page_addr_code_hostp(cpu->env_ptr, tb->pc, &ptb->haddr1); | ||
63 | + ptb->haddr1 = db->host_addr[0]; | ||
64 | ptb->haddr2 = NULL; | ||
65 | ptb->mem_only = mem_only; | ||
66 | |||
67 | @@ -XXX,XX +XXX,XX @@ void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db) | ||
68 | * Note that we skip this when haddr1 == NULL, e.g. when we're | ||
69 | * fetching instructions from a region not backed by RAM. | ||
70 | */ | ||
71 | - if (likely(ptb->haddr1 != NULL && ptb->vaddr2 == -1) && | ||
72 | - unlikely((db->pc_next & TARGET_PAGE_MASK) != | ||
73 | - (db->pc_first & TARGET_PAGE_MASK))) { | ||
74 | - get_page_addr_code_hostp(cpu->env_ptr, db->pc_next, | ||
75 | - &ptb->haddr2); | ||
76 | - ptb->vaddr2 = db->pc_next; | ||
77 | - } | ||
78 | - if (likely(ptb->vaddr2 == -1)) { | ||
79 | + if (ptb->haddr1 == NULL) { | ||
80 | + pinsn->haddr = NULL; | ||
81 | + } else if (is_same_page(db, db->pc_next)) { | ||
82 | pinsn->haddr = ptb->haddr1 + pinsn->vaddr - ptb->vaddr; | ||
83 | } else { | ||
84 | + if (ptb->vaddr2 == -1) { | ||
85 | + ptb->vaddr2 = TARGET_PAGE_ALIGN(db->pc_first); | ||
86 | + get_page_addr_code_hostp(cpu->env_ptr, ptb->vaddr2, &ptb->haddr2); | ||
87 | + } | ||
88 | pinsn->haddr = ptb->haddr2 + pinsn->vaddr - ptb->vaddr2; | ||
16 | } | 89 | } |
17 | } | 90 | } |
18 | 91 | diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c | |
19 | -static struct tcg_region_tree *tc_ptr_to_region_tree(const void *cp) | 92 | index XXXXXXX..XXXXXXX 100644 |
20 | +static struct tcg_region_tree *tc_ptr_to_region_tree(const void *p) | 93 | --- a/accel/tcg/translator.c |
21 | { | 94 | +++ b/accel/tcg/translator.c |
22 | - void *p = tcg_splitwx_to_rw(cp); | 95 | @@ -XXX,XX +XXX,XX @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int max_insns, |
23 | size_t region_idx; | 96 | ops->tb_start(db, cpu); |
24 | 97 | tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */ | |
25 | + /* | 98 | |
26 | + * Like tcg_splitwx_to_rw, with no assert. The pc may come from | 99 | - plugin_enabled = plugin_gen_tb_start(cpu, tb, cflags & CF_MEMI_ONLY); |
27 | + * a signal handler over which the caller has no control. | 100 | + plugin_enabled = plugin_gen_tb_start(cpu, db, cflags & CF_MEMI_ONLY); |
28 | + */ | 101 | |
29 | + if (!in_code_gen_buffer(p)) { | 102 | while (true) { |
30 | + p -= tcg_splitwx_diff; | 103 | db->num_insns++; |
31 | + if (!in_code_gen_buffer(p)) { | ||
32 | + return NULL; | ||
33 | + } | ||
34 | + } | ||
35 | + | ||
36 | if (p < region.start_aligned) { | ||
37 | region_idx = 0; | ||
38 | } else { | ||
39 | @@ -XXX,XX +XXX,XX @@ void tcg_tb_insert(TranslationBlock *tb) | ||
40 | { | ||
41 | struct tcg_region_tree *rt = tc_ptr_to_region_tree(tb->tc.ptr); | ||
42 | |||
43 | + g_assert(rt != NULL); | ||
44 | qemu_mutex_lock(&rt->lock); | ||
45 | g_tree_insert(rt->tree, &tb->tc, tb); | ||
46 | qemu_mutex_unlock(&rt->lock); | ||
47 | @@ -XXX,XX +XXX,XX @@ void tcg_tb_remove(TranslationBlock *tb) | ||
48 | { | ||
49 | struct tcg_region_tree *rt = tc_ptr_to_region_tree(tb->tc.ptr); | ||
50 | |||
51 | + g_assert(rt != NULL); | ||
52 | qemu_mutex_lock(&rt->lock); | ||
53 | g_tree_remove(rt->tree, &tb->tc); | ||
54 | qemu_mutex_unlock(&rt->lock); | ||
55 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tcg_tb_lookup(uintptr_t tc_ptr) | ||
56 | TranslationBlock *tb; | ||
57 | struct tb_tc s = { .ptr = (void *)tc_ptr }; | ||
58 | |||
59 | + if (rt == NULL) { | ||
60 | + return NULL; | ||
61 | + } | ||
62 | + | ||
63 | qemu_mutex_lock(&rt->lock); | ||
64 | tb = g_tree_lookup(rt->tree, &s); | ||
65 | qemu_mutex_unlock(&rt->lock); | ||
66 | -- | 104 | -- |
67 | 2.25.1 | 105 | 2.34.1 |
68 | 106 | ||
69 | 107 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | Let tb->page_addr[0] contain the address of the first byte of the |
---|---|---|---|
2 | translated block, rather than the address of the page containing the | ||
3 | start of the translated block. We need to recover this value anyway | ||
4 | at various points, and it is easier to discard a page offset when it | ||
5 | is not needed, which happens naturally via the existing find_page shift. | ||
2 | 6 | ||
3 | There is nothing special about this compile flag that doesn't mean we | 7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
4 | can't just compute it with curr_cflags() which we should be using when | ||
5 | building a new set. | ||
6 | |||
7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Message-Id: <20210224165811.11567-3-alex.bennee@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | --- | 9 | --- |
11 | include/exec/exec-all.h | 8 +++++--- | 10 | accel/tcg/cpu-exec.c | 16 ++++++++-------- |
12 | include/exec/tb-lookup.h | 3 --- | 11 | accel/tcg/cputlb.c | 3 ++- |
13 | accel/tcg/cpu-exec.c | 9 ++++----- | 12 | accel/tcg/translate-all.c | 9 +++++---- |
14 | accel/tcg/tcg-runtime.c | 2 +- | 13 | 3 files changed, 15 insertions(+), 13 deletions(-) |
15 | accel/tcg/translate-all.c | 6 +++--- | ||
16 | softmmu/physmem.c | 2 +- | ||
17 | 6 files changed, 14 insertions(+), 16 deletions(-) | ||
18 | 14 | ||
19 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/include/exec/exec-all.h | ||
22 | +++ b/include/exec/exec-all.h | ||
23 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t tb_cflags(const TranslationBlock *tb) | ||
24 | } | ||
25 | |||
26 | /* current cflags for hashing/comparison */ | ||
27 | -static inline uint32_t curr_cflags(void) | ||
28 | +static inline uint32_t curr_cflags(CPUState *cpu) | ||
29 | { | ||
30 | - return (parallel_cpus ? CF_PARALLEL : 0) | ||
31 | - | (icount_enabled() ? CF_USE_ICOUNT : 0); | ||
32 | + uint32_t cflags = deposit32(0, CF_CLUSTER_SHIFT, 8, cpu->cluster_index); | ||
33 | + cflags |= parallel_cpus ? CF_PARALLEL : 0; | ||
34 | + cflags |= icount_enabled() ? CF_USE_ICOUNT : 0; | ||
35 | + return cflags; | ||
36 | } | ||
37 | |||
38 | /* TranslationBlock invalidate API */ | ||
39 | diff --git a/include/exec/tb-lookup.h b/include/exec/tb-lookup.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/include/exec/tb-lookup.h | ||
42 | +++ b/include/exec/tb-lookup.h | ||
43 | @@ -XXX,XX +XXX,XX @@ static inline TranslationBlock * tb_lookup(CPUState *cpu, | ||
44 | hash = tb_jmp_cache_hash_func(pc); | ||
45 | tb = qatomic_rcu_read(&cpu->tb_jmp_cache[hash]); | ||
46 | |||
47 | - cf_mask &= ~CF_CLUSTER_MASK; | ||
48 | - cf_mask |= cpu->cluster_index << CF_CLUSTER_SHIFT; | ||
49 | - | ||
50 | if (likely(tb && | ||
51 | tb->pc == pc && | ||
52 | tb->cs_base == cs_base && | ||
53 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | 15 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c |
54 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/accel/tcg/cpu-exec.c | 17 | --- a/accel/tcg/cpu-exec.c |
56 | +++ b/accel/tcg/cpu-exec.c | 18 | +++ b/accel/tcg/cpu-exec.c |
57 | @@ -XXX,XX +XXX,XX @@ void cpu_exec_step_atomic(CPUState *cpu) | 19 | @@ -XXX,XX +XXX,XX @@ struct tb_desc { |
58 | TranslationBlock *tb; | 20 | target_ulong pc; |
59 | target_ulong cs_base, pc; | 21 | target_ulong cs_base; |
22 | CPUArchState *env; | ||
23 | - tb_page_addr_t phys_page1; | ||
24 | + tb_page_addr_t page_addr0; | ||
60 | uint32_t flags; | 25 | uint32_t flags; |
61 | - uint32_t cflags = 1; | 26 | uint32_t cflags; |
62 | - uint32_t cf_mask = cflags & CF_HASH_MASK; | 27 | uint32_t trace_vcpu_dstate; |
63 | + uint32_t cflags = (curr_cflags(cpu) & ~CF_PARALLEL) | 1; | 28 | @@ -XXX,XX +XXX,XX @@ static bool tb_lookup_cmp(const void *p, const void *d) |
64 | int tb_exit; | 29 | const struct tb_desc *desc = d; |
65 | 30 | ||
66 | if (sigsetjmp(cpu->jmp_env, 0) == 0) { | 31 | if (tb->pc == desc->pc && |
67 | @@ -XXX,XX +XXX,XX @@ void cpu_exec_step_atomic(CPUState *cpu) | 32 | - tb->page_addr[0] == desc->phys_page1 && |
68 | cpu->running = true; | 33 | + tb->page_addr[0] == desc->page_addr0 && |
69 | 34 | tb->cs_base == desc->cs_base && | |
70 | cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); | 35 | tb->flags == desc->flags && |
71 | - tb = tb_lookup(cpu, pc, cs_base, flags, cf_mask); | 36 | tb->trace_vcpu_dstate == desc->trace_vcpu_dstate && |
72 | + tb = tb_lookup(cpu, pc, cs_base, flags, cflags); | 37 | @@ -XXX,XX +XXX,XX @@ static bool tb_lookup_cmp(const void *p, const void *d) |
73 | 38 | if (tb->page_addr[1] == -1) { | |
74 | if (tb == NULL) { | 39 | return true; |
75 | mmap_lock(); | 40 | } else { |
76 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) | 41 | - tb_page_addr_t phys_page2; |
77 | if (replay_has_exception() | 42 | - target_ulong virt_page2; |
78 | && cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra == 0) { | 43 | + tb_page_addr_t phys_page1; |
79 | /* Execute just one insn to trigger exception pending in the log */ | 44 | + target_ulong virt_page1; |
80 | - cpu->cflags_next_tb = (curr_cflags() & ~CF_USE_ICOUNT) | 1; | 45 | |
81 | + cpu->cflags_next_tb = (curr_cflags(cpu) & ~CF_USE_ICOUNT) | 1; | 46 | /* |
47 | * We know that the first page matched, and an otherwise valid TB | ||
48 | @@ -XXX,XX +XXX,XX @@ static bool tb_lookup_cmp(const void *p, const void *d) | ||
49 | * is different for the new TB. Therefore any exception raised | ||
50 | * here by the faulting lookup is not premature. | ||
51 | */ | ||
52 | - virt_page2 = TARGET_PAGE_ALIGN(desc->pc); | ||
53 | - phys_page2 = get_page_addr_code(desc->env, virt_page2); | ||
54 | - if (tb->page_addr[1] == phys_page2) { | ||
55 | + virt_page1 = TARGET_PAGE_ALIGN(desc->pc); | ||
56 | + phys_page1 = get_page_addr_code(desc->env, virt_page1); | ||
57 | + if (tb->page_addr[1] == phys_page1) { | ||
58 | return true; | ||
59 | } | ||
82 | } | 60 | } |
83 | #endif | 61 | @@ -XXX,XX +XXX,XX @@ static TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, |
84 | return false; | 62 | if (phys_pc == -1) { |
85 | @@ -XXX,XX +XXX,XX @@ int cpu_exec(CPUState *cpu) | 63 | return NULL; |
86 | have CF_INVALID set, -1 is a convenient invalid value that | 64 | } |
87 | does not require tcg headers for cpu_common_reset. */ | 65 | - desc.phys_page1 = phys_pc & TARGET_PAGE_MASK; |
88 | if (cflags == -1) { | 66 | + desc.page_addr0 = phys_pc; |
89 | - cflags = curr_cflags(); | 67 | h = tb_hash_func(phys_pc, pc, flags, cflags, *cpu->trace_dstate); |
90 | + cflags = curr_cflags(cpu); | 68 | return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp); |
91 | } else { | 69 | } |
92 | cpu->cflags_next_tb = -1; | 70 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c |
93 | } | ||
94 | diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c | ||
95 | index XXXXXXX..XXXXXXX 100644 | 71 | index XXXXXXX..XXXXXXX 100644 |
96 | --- a/accel/tcg/tcg-runtime.c | 72 | --- a/accel/tcg/cputlb.c |
97 | +++ b/accel/tcg/tcg-runtime.c | 73 | +++ b/accel/tcg/cputlb.c |
98 | @@ -XXX,XX +XXX,XX @@ const void *HELPER(lookup_tb_ptr)(CPUArchState *env) | 74 | @@ -XXX,XX +XXX,XX @@ void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu, |
99 | 75 | can be detected */ | |
100 | cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); | 76 | void tlb_protect_code(ram_addr_t ram_addr) |
101 | 77 | { | |
102 | - tb = tb_lookup(cpu, pc, cs_base, flags, curr_cflags()); | 78 | - cpu_physical_memory_test_and_clear_dirty(ram_addr, TARGET_PAGE_SIZE, |
103 | + tb = tb_lookup(cpu, pc, cs_base, flags, curr_cflags(cpu)); | 79 | + cpu_physical_memory_test_and_clear_dirty(ram_addr & TARGET_PAGE_MASK, |
104 | if (tb == NULL) { | 80 | + TARGET_PAGE_SIZE, |
105 | return tcg_code_gen_epilogue; | 81 | DIRTY_MEMORY_CODE); |
106 | } | 82 | } |
83 | |||
107 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | 84 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c |
108 | index XXXXXXX..XXXXXXX 100644 | 85 | index XXXXXXX..XXXXXXX 100644 |
109 | --- a/accel/tcg/translate-all.c | 86 | --- a/accel/tcg/translate-all.c |
110 | +++ b/accel/tcg/translate-all.c | 87 | +++ b/accel/tcg/translate-all.c |
88 | @@ -XXX,XX +XXX,XX @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) | ||
89 | qemu_spin_unlock(&tb->jmp_lock); | ||
90 | |||
91 | /* remove the TB from the hash list */ | ||
92 | - phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); | ||
93 | + phys_pc = tb->page_addr[0]; | ||
94 | h = tb_hash_func(phys_pc, tb->pc, tb->flags, orig_cflags, | ||
95 | tb->trace_vcpu_dstate); | ||
96 | if (!qht_remove(&tb_ctx.htable, tb, h)) { | ||
97 | @@ -XXX,XX +XXX,XX @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, | ||
98 | * we can only insert TBs that are fully initialized. | ||
99 | */ | ||
100 | page_lock_pair(&p, phys_pc, &p2, phys_page2, true); | ||
101 | - tb_page_add(p, tb, 0, phys_pc & TARGET_PAGE_MASK); | ||
102 | + tb_page_add(p, tb, 0, phys_pc); | ||
103 | if (p2) { | ||
104 | tb_page_add(p2, tb, 1, phys_page2); | ||
105 | } else { | ||
111 | @@ -XXX,XX +XXX,XX @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, | 106 | @@ -XXX,XX +XXX,XX @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, |
112 | if (current_tb_modified) { | 107 | if (n == 0) { |
113 | page_collection_unlock(pages); | 108 | /* NOTE: tb_end may be after the end of the page, but |
114 | /* Force execution of one insn next time. */ | 109 | it is not a problem */ |
115 | - cpu->cflags_next_tb = 1 | curr_cflags(); | 110 | - tb_start = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); |
116 | + cpu->cflags_next_tb = 1 | curr_cflags(cpu); | 111 | + tb_start = tb->page_addr[0]; |
117 | mmap_unlock(); | 112 | tb_end = tb_start + tb->size; |
118 | cpu_loop_exit_noexc(cpu); | 113 | } else { |
119 | } | 114 | tb_start = tb->page_addr[1]; |
120 | @@ -XXX,XX +XXX,XX @@ static bool tb_invalidate_phys_page(tb_page_addr_t addr, uintptr_t pc) | 115 | - tb_end = tb_start + ((tb->pc + tb->size) & ~TARGET_PAGE_MASK); |
116 | + tb_end = tb_start + ((tb->page_addr[0] + tb->size) | ||
117 | + & ~TARGET_PAGE_MASK); | ||
118 | } | ||
119 | if (!(tb_end <= start || tb_start >= end)) { | ||
121 | #ifdef TARGET_HAS_PRECISE_SMC | 120 | #ifdef TARGET_HAS_PRECISE_SMC |
122 | if (current_tb_modified) { | ||
123 | /* Force execution of one insn next time. */ | ||
124 | - cpu->cflags_next_tb = 1 | curr_cflags(); | ||
125 | + cpu->cflags_next_tb = 1 | curr_cflags(cpu); | ||
126 | return true; | ||
127 | } | ||
128 | #endif | ||
129 | @@ -XXX,XX +XXX,XX @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) | ||
130 | * operations only (which execute after completion) so we don't | ||
131 | * double instrument the instruction. | ||
132 | */ | ||
133 | - cpu->cflags_next_tb = curr_cflags() | CF_MEMI_ONLY | CF_LAST_IO | n; | ||
134 | + cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | CF_LAST_IO | n; | ||
135 | |||
136 | qemu_log_mask_and_addr(CPU_LOG_EXEC, tb->pc, | ||
137 | "cpu_io_recompile: rewound execution of TB to " | ||
138 | diff --git a/softmmu/physmem.c b/softmmu/physmem.c | ||
139 | index XXXXXXX..XXXXXXX 100644 | ||
140 | --- a/softmmu/physmem.c | ||
141 | +++ b/softmmu/physmem.c | ||
142 | @@ -XXX,XX +XXX,XX @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, | ||
143 | cpu_loop_exit_restore(cpu, ra); | ||
144 | } else { | ||
145 | /* Force execution of one insn next time. */ | ||
146 | - cpu->cflags_next_tb = 1 | curr_cflags(); | ||
147 | + cpu->cflags_next_tb = 1 | curr_cflags(cpu); | ||
148 | mmap_unlock(); | ||
149 | if (ra) { | ||
150 | cpu_restore_state(cpu, ra, true); | ||
151 | -- | 121 | -- |
152 | 2.25.1 | 122 | 2.34.1 |
153 | 123 | ||
154 | 124 | diff view generated by jsdifflib |
1 | Use explicit casts for ext16u opcodes, and allow truncation | 1 | This function has two users, who use it incompatibly. |
---|---|---|---|
2 | to happen with the store for st16 opcodes, and with the call | 2 | In tlb_flush_page_by_mmuidx_async_0, when flushing a |
3 | for bswap16 opcodes. | 3 | single page, we need to flush exactly two pages. |
4 | In tlb_flush_range_by_mmuidx_async_0, when flushing a | ||
5 | range of pages, we need to flush N+1 pages. | ||
4 | 6 | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | This avoids double-flushing of jmp cache pages in a range. |
8 | |||
9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | --- | 11 | --- |
8 | tcg/tci.c | 28 +++++++--------------------- | 12 | accel/tcg/cputlb.c | 25 ++++++++++++++----------- |
9 | 1 file changed, 7 insertions(+), 21 deletions(-) | 13 | 1 file changed, 14 insertions(+), 11 deletions(-) |
10 | 14 | ||
11 | diff --git a/tcg/tci.c b/tcg/tci.c | 15 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/tcg/tci.c | 17 | --- a/accel/tcg/cputlb.c |
14 | +++ b/tcg/tci.c | 18 | +++ b/accel/tcg/cputlb.c |
15 | @@ -XXX,XX +XXX,XX @@ static int32_t tci_read_reg32s(const tcg_target_ulong *regs, TCGReg index) | 19 | @@ -XXX,XX +XXX,XX @@ static void tb_jmp_cache_clear_page(CPUState *cpu, target_ulong page_addr) |
20 | } | ||
16 | } | 21 | } |
17 | #endif | 22 | |
18 | 23 | -static void tb_flush_jmp_cache(CPUState *cpu, target_ulong addr) | |
19 | -static uint16_t tci_read_reg16(const tcg_target_ulong *regs, TCGReg index) | ||
20 | -{ | 24 | -{ |
21 | - return (uint16_t)tci_read_reg(regs, index); | 25 | - /* Discard jump cache entries for any tb which might potentially |
26 | - overlap the flushed page. */ | ||
27 | - tb_jmp_cache_clear_page(cpu, addr - TARGET_PAGE_SIZE); | ||
28 | - tb_jmp_cache_clear_page(cpu, addr); | ||
22 | -} | 29 | -} |
23 | - | 30 | - |
24 | static uint32_t tci_read_reg32(const tcg_target_ulong *regs, TCGReg index) | 31 | /** |
25 | { | 32 | * tlb_mmu_resize_locked() - perform TLB resize bookkeeping; resize if necessary |
26 | return (uint32_t)tci_read_reg(regs, index); | 33 | * @desc: The CPUTLBDesc portion of the TLB |
27 | @@ -XXX,XX +XXX,XX @@ tci_read_r(const tcg_target_ulong *regs, const uint8_t **tb_ptr) | 34 | @@ -XXX,XX +XXX,XX @@ static void tlb_flush_page_by_mmuidx_async_0(CPUState *cpu, |
28 | return value; | 35 | } |
36 | qemu_spin_unlock(&env_tlb(env)->c.lock); | ||
37 | |||
38 | - tb_flush_jmp_cache(cpu, addr); | ||
39 | + /* | ||
40 | + * Discard jump cache entries for any tb which might potentially | ||
41 | + * overlap the flushed page, which includes the previous. | ||
42 | + */ | ||
43 | + tb_jmp_cache_clear_page(cpu, addr - TARGET_PAGE_SIZE); | ||
44 | + tb_jmp_cache_clear_page(cpu, addr); | ||
29 | } | 45 | } |
30 | 46 | ||
31 | -/* Read indexed register (16 bit) from bytecode. */ | 47 | /** |
32 | -static uint16_t tci_read_r16(const tcg_target_ulong *regs, | 48 | @@ -XXX,XX +XXX,XX @@ static void tlb_flush_range_by_mmuidx_async_0(CPUState *cpu, |
33 | - const uint8_t **tb_ptr) | 49 | return; |
34 | -{ | 50 | } |
35 | - uint16_t value = tci_read_reg16(regs, **tb_ptr); | 51 | |
36 | - *tb_ptr += 1; | 52 | - for (target_ulong i = 0; i < d.len; i += TARGET_PAGE_SIZE) { |
37 | - return value; | 53 | - tb_flush_jmp_cache(cpu, d.addr + i); |
38 | -} | 54 | + /* |
39 | - | 55 | + * Discard jump cache entries for any tb which might potentially |
40 | #if TCG_TARGET_HAS_ext16s_i32 || TCG_TARGET_HAS_ext16s_i64 | 56 | + * overlap the flushed pages, which includes the previous. |
41 | /* Read indexed register (16 bit signed) from bytecode. */ | 57 | + */ |
42 | static int16_t tci_read_r16s(const tcg_target_ulong *regs, | 58 | + d.addr -= TARGET_PAGE_SIZE; |
43 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 59 | + for (target_ulong i = 0, n = d.len / TARGET_PAGE_SIZE + 1; i < n; i++) { |
44 | *(uint8_t *)(t1 + t2) = t0; | 60 | + tb_jmp_cache_clear_page(cpu, d.addr); |
45 | break; | 61 | + d.addr += TARGET_PAGE_SIZE; |
46 | CASE_32_64(st16) | 62 | } |
47 | - t0 = tci_read_r16(regs, &tb_ptr); | 63 | } |
48 | + t0 = tci_read_r(regs, &tb_ptr); | 64 | |
49 | t1 = tci_read_r(regs, &tb_ptr); | ||
50 | t2 = tci_read_s32(&tb_ptr); | ||
51 | *(uint16_t *)(t1 + t2) = t0; | ||
52 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
53 | #if TCG_TARGET_HAS_ext16u_i32 | ||
54 | case INDEX_op_ext16u_i32: | ||
55 | t0 = *tb_ptr++; | ||
56 | - t1 = tci_read_r16(regs, &tb_ptr); | ||
57 | - tci_write_reg(regs, t0, t1); | ||
58 | + t1 = tci_read_r(regs, &tb_ptr); | ||
59 | + tci_write_reg(regs, t0, (uint16_t)t1); | ||
60 | break; | ||
61 | #endif | ||
62 | #if TCG_TARGET_HAS_bswap16_i32 | ||
63 | case INDEX_op_bswap16_i32: | ||
64 | t0 = *tb_ptr++; | ||
65 | - t1 = tci_read_r16(regs, &tb_ptr); | ||
66 | + t1 = tci_read_r(regs, &tb_ptr); | ||
67 | tci_write_reg(regs, t0, bswap16(t1)); | ||
68 | break; | ||
69 | #endif | ||
70 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
71 | #if TCG_TARGET_HAS_ext16u_i64 | ||
72 | case INDEX_op_ext16u_i64: | ||
73 | t0 = *tb_ptr++; | ||
74 | - t1 = tci_read_r16(regs, &tb_ptr); | ||
75 | - tci_write_reg(regs, t0, t1); | ||
76 | + t1 = tci_read_r(regs, &tb_ptr); | ||
77 | + tci_write_reg(regs, t0, (uint16_t)t1); | ||
78 | break; | ||
79 | #endif | ||
80 | #if TCG_TARGET_HAS_ext32s_i64 | ||
81 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | ||
82 | #if TCG_TARGET_HAS_bswap16_i64 | ||
83 | case INDEX_op_bswap16_i64: | ||
84 | t0 = *tb_ptr++; | ||
85 | - t1 = tci_read_r16(regs, &tb_ptr); | ||
86 | + t1 = tci_read_r(regs, &tb_ptr); | ||
87 | tci_write_reg(regs, t0, bswap16(t1)); | ||
88 | break; | ||
89 | #endif | ||
90 | -- | 65 | -- |
91 | 2.25.1 | 66 | 2.34.1 |
92 | 67 | ||
93 | 68 | diff view generated by jsdifflib |
1 | Use explicit casts for ext8u opcodes, and allow truncation | 1 | Wrap the bare TranslationBlock pointer into a structure. |
---|---|---|---|
2 | to happen with the store for st8 opcodes. | ||
3 | 2 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | --- | 6 | --- |
7 | tcg/tci.c | 23 +++++------------------ | 7 | accel/tcg/tb-hash.h | 1 + |
8 | 1 file changed, 5 insertions(+), 18 deletions(-) | 8 | accel/tcg/tb-jmp-cache.h | 24 ++++++++++++++++++++++++ |
9 | include/exec/cpu-common.h | 1 + | ||
10 | include/hw/core/cpu.h | 15 +-------------- | ||
11 | include/qemu/typedefs.h | 1 + | ||
12 | accel/stubs/tcg-stub.c | 4 ++++ | ||
13 | accel/tcg/cpu-exec.c | 10 +++++++--- | ||
14 | accel/tcg/cputlb.c | 9 +++++---- | ||
15 | accel/tcg/translate-all.c | 28 +++++++++++++++++++++++++--- | ||
16 | hw/core/cpu-common.c | 3 +-- | ||
17 | plugins/core.c | 2 +- | ||
18 | trace/control-target.c | 2 +- | ||
19 | 12 files changed, 72 insertions(+), 28 deletions(-) | ||
20 | create mode 100644 accel/tcg/tb-jmp-cache.h | ||
9 | 21 | ||
10 | diff --git a/tcg/tci.c b/tcg/tci.c | 22 | diff --git a/accel/tcg/tb-hash.h b/accel/tcg/tb-hash.h |
11 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/tcg/tci.c | 24 | --- a/accel/tcg/tb-hash.h |
13 | +++ b/tcg/tci.c | 25 | +++ b/accel/tcg/tb-hash.h |
14 | @@ -XXX,XX +XXX,XX @@ static int32_t tci_read_reg32s(const tcg_target_ulong *regs, TCGReg index) | 26 | @@ -XXX,XX +XXX,XX @@ |
15 | } | 27 | #include "exec/cpu-defs.h" |
16 | #endif | 28 | #include "exec/exec-all.h" |
17 | 29 | #include "qemu/xxhash.h" | |
18 | -static uint8_t tci_read_reg8(const tcg_target_ulong *regs, TCGReg index) | 30 | +#include "tb-jmp-cache.h" |
31 | |||
32 | #ifdef CONFIG_SOFTMMU | ||
33 | |||
34 | diff --git a/accel/tcg/tb-jmp-cache.h b/accel/tcg/tb-jmp-cache.h | ||
35 | new file mode 100644 | ||
36 | index XXXXXXX..XXXXXXX | ||
37 | --- /dev/null | ||
38 | +++ b/accel/tcg/tb-jmp-cache.h | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | +/* | ||
41 | + * The per-CPU TranslationBlock jump cache. | ||
42 | + * | ||
43 | + * Copyright (c) 2003 Fabrice Bellard | ||
44 | + * | ||
45 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
46 | + */ | ||
47 | + | ||
48 | +#ifndef ACCEL_TCG_TB_JMP_CACHE_H | ||
49 | +#define ACCEL_TCG_TB_JMP_CACHE_H | ||
50 | + | ||
51 | +#define TB_JMP_CACHE_BITS 12 | ||
52 | +#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) | ||
53 | + | ||
54 | +/* | ||
55 | + * Accessed in parallel; all accesses to 'tb' must be atomic. | ||
56 | + */ | ||
57 | +struct CPUJumpCache { | ||
58 | + struct { | ||
59 | + TranslationBlock *tb; | ||
60 | + } array[TB_JMP_CACHE_SIZE]; | ||
61 | +}; | ||
62 | + | ||
63 | +#endif /* ACCEL_TCG_TB_JMP_CACHE_H */ | ||
64 | diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/include/exec/cpu-common.h | ||
67 | +++ b/include/exec/cpu-common.h | ||
68 | @@ -XXX,XX +XXX,XX @@ void cpu_list_unlock(void); | ||
69 | unsigned int cpu_list_generation_id_get(void); | ||
70 | |||
71 | void tcg_flush_softmmu_tlb(CPUState *cs); | ||
72 | +void tcg_flush_jmp_cache(CPUState *cs); | ||
73 | |||
74 | void tcg_iommu_init_notifier_list(CPUState *cpu); | ||
75 | void tcg_iommu_free_notifier_list(CPUState *cpu); | ||
76 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/include/hw/core/cpu.h | ||
79 | +++ b/include/hw/core/cpu.h | ||
80 | @@ -XXX,XX +XXX,XX @@ struct kvm_run; | ||
81 | struct hax_vcpu_state; | ||
82 | struct hvf_vcpu_state; | ||
83 | |||
84 | -#define TB_JMP_CACHE_BITS 12 | ||
85 | -#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) | ||
86 | - | ||
87 | /* work queue */ | ||
88 | |||
89 | /* The union type allows passing of 64 bit target pointers on 32 bit | ||
90 | @@ -XXX,XX +XXX,XX @@ struct CPUState { | ||
91 | CPUArchState *env_ptr; | ||
92 | IcountDecr *icount_decr_ptr; | ||
93 | |||
94 | - /* Accessed in parallel; all accesses must be atomic */ | ||
95 | - TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; | ||
96 | + CPUJumpCache *tb_jmp_cache; | ||
97 | |||
98 | struct GDBRegisterState *gdb_regs; | ||
99 | int gdb_num_regs; | ||
100 | @@ -XXX,XX +XXX,XX @@ extern CPUTailQ cpus; | ||
101 | |||
102 | extern __thread CPUState *current_cpu; | ||
103 | |||
104 | -static inline void cpu_tb_jmp_cache_clear(CPUState *cpu) | ||
19 | -{ | 105 | -{ |
20 | - return (uint8_t)tci_read_reg(regs, index); | 106 | - unsigned int i; |
107 | - | ||
108 | - for (i = 0; i < TB_JMP_CACHE_SIZE; i++) { | ||
109 | - qatomic_set(&cpu->tb_jmp_cache[i], NULL); | ||
110 | - } | ||
21 | -} | 111 | -} |
22 | - | 112 | - |
23 | static uint16_t tci_read_reg16(const tcg_target_ulong *regs, TCGReg index) | 113 | /** |
24 | { | 114 | * qemu_tcg_mttcg_enabled: |
25 | return (uint16_t)tci_read_reg(regs, index); | 115 | * Check whether we are running MultiThread TCG or not. |
26 | @@ -XXX,XX +XXX,XX @@ tci_read_r(const tcg_target_ulong *regs, const uint8_t **tb_ptr) | 116 | diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h |
27 | return value; | 117 | index XXXXXXX..XXXXXXX 100644 |
28 | } | 118 | --- a/include/qemu/typedefs.h |
29 | 119 | +++ b/include/qemu/typedefs.h | |
30 | -/* Read indexed register (8 bit) from bytecode. */ | 120 | @@ -XXX,XX +XXX,XX @@ typedef struct CoMutex CoMutex; |
31 | -static uint8_t tci_read_r8(const tcg_target_ulong *regs, const uint8_t **tb_ptr) | 121 | typedef struct ConfidentialGuestSupport ConfidentialGuestSupport; |
32 | -{ | 122 | typedef struct CPUAddressSpace CPUAddressSpace; |
33 | - uint8_t value = tci_read_reg8(regs, **tb_ptr); | 123 | typedef struct CPUArchState CPUArchState; |
34 | - *tb_ptr += 1; | 124 | +typedef struct CPUJumpCache CPUJumpCache; |
35 | - return value; | 125 | typedef struct CPUState CPUState; |
36 | -} | 126 | typedef struct CPUTLBEntryFull CPUTLBEntryFull; |
127 | typedef struct DeviceListener DeviceListener; | ||
128 | diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/accel/stubs/tcg-stub.c | ||
131 | +++ b/accel/stubs/tcg-stub.c | ||
132 | @@ -XXX,XX +XXX,XX @@ void tlb_set_dirty(CPUState *cpu, target_ulong vaddr) | ||
133 | { | ||
134 | } | ||
135 | |||
136 | +void tcg_flush_jmp_cache(CPUState *cpu) | ||
137 | +{ | ||
138 | +} | ||
139 | + | ||
140 | int probe_access_flags(CPUArchState *env, target_ulong addr, | ||
141 | MMUAccessType access_type, int mmu_idx, | ||
142 | bool nonfault, void **phost, uintptr_t retaddr) | ||
143 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | ||
144 | index XXXXXXX..XXXXXXX 100644 | ||
145 | --- a/accel/tcg/cpu-exec.c | ||
146 | +++ b/accel/tcg/cpu-exec.c | ||
147 | @@ -XXX,XX +XXX,XX @@ | ||
148 | #include "sysemu/replay.h" | ||
149 | #include "sysemu/tcg.h" | ||
150 | #include "exec/helper-proto.h" | ||
151 | +#include "tb-jmp-cache.h" | ||
152 | #include "tb-hash.h" | ||
153 | #include "tb-context.h" | ||
154 | #include "internal.h" | ||
155 | @@ -XXX,XX +XXX,XX @@ static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc, | ||
156 | tcg_debug_assert(!(cflags & CF_INVALID)); | ||
157 | |||
158 | hash = tb_jmp_cache_hash_func(pc); | ||
159 | - tb = qatomic_rcu_read(&cpu->tb_jmp_cache[hash]); | ||
160 | + tb = qatomic_rcu_read(&cpu->tb_jmp_cache->array[hash].tb); | ||
161 | |||
162 | if (likely(tb && | ||
163 | tb->pc == pc && | ||
164 | @@ -XXX,XX +XXX,XX @@ static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc, | ||
165 | if (tb == NULL) { | ||
166 | return NULL; | ||
167 | } | ||
168 | - qatomic_set(&cpu->tb_jmp_cache[hash], tb); | ||
169 | + qatomic_set(&cpu->tb_jmp_cache->array[hash].tb, tb); | ||
170 | return tb; | ||
171 | } | ||
172 | |||
173 | @@ -XXX,XX +XXX,XX @@ int cpu_exec(CPUState *cpu) | ||
174 | |||
175 | tb = tb_lookup(cpu, pc, cs_base, flags, cflags); | ||
176 | if (tb == NULL) { | ||
177 | + uint32_t h; | ||
178 | + | ||
179 | mmap_lock(); | ||
180 | tb = tb_gen_code(cpu, pc, cs_base, flags, cflags); | ||
181 | mmap_unlock(); | ||
182 | @@ -XXX,XX +XXX,XX @@ int cpu_exec(CPUState *cpu) | ||
183 | * We add the TB in the virtual pc hash table | ||
184 | * for the fast lookup | ||
185 | */ | ||
186 | - qatomic_set(&cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)], tb); | ||
187 | + h = tb_jmp_cache_hash_func(pc); | ||
188 | + qatomic_set(&cpu->tb_jmp_cache->array[h].tb, tb); | ||
189 | } | ||
190 | |||
191 | #ifndef CONFIG_USER_ONLY | ||
192 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
193 | index XXXXXXX..XXXXXXX 100644 | ||
194 | --- a/accel/tcg/cputlb.c | ||
195 | +++ b/accel/tcg/cputlb.c | ||
196 | @@ -XXX,XX +XXX,XX @@ static void tlb_window_reset(CPUTLBDesc *desc, int64_t ns, | ||
197 | |||
198 | static void tb_jmp_cache_clear_page(CPUState *cpu, target_ulong page_addr) | ||
199 | { | ||
200 | - unsigned int i, i0 = tb_jmp_cache_hash_page(page_addr); | ||
201 | + int i, i0 = tb_jmp_cache_hash_page(page_addr); | ||
202 | + CPUJumpCache *jc = cpu->tb_jmp_cache; | ||
203 | |||
204 | for (i = 0; i < TB_JMP_PAGE_SIZE; i++) { | ||
205 | - qatomic_set(&cpu->tb_jmp_cache[i0 + i], NULL); | ||
206 | + qatomic_set(&jc->array[i0 + i].tb, NULL); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | @@ -XXX,XX +XXX,XX @@ static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, run_on_cpu_data data) | ||
211 | |||
212 | qemu_spin_unlock(&env_tlb(env)->c.lock); | ||
213 | |||
214 | - cpu_tb_jmp_cache_clear(cpu); | ||
215 | + tcg_flush_jmp_cache(cpu); | ||
216 | |||
217 | if (to_clean == ALL_MMUIDX_BITS) { | ||
218 | qatomic_set(&env_tlb(env)->c.full_flush_count, | ||
219 | @@ -XXX,XX +XXX,XX @@ static void tlb_flush_range_by_mmuidx_async_0(CPUState *cpu, | ||
220 | * longer to clear each entry individually than it will to clear it all. | ||
221 | */ | ||
222 | if (d.len >= (TARGET_PAGE_SIZE * TB_JMP_CACHE_SIZE)) { | ||
223 | - cpu_tb_jmp_cache_clear(cpu); | ||
224 | + tcg_flush_jmp_cache(cpu); | ||
225 | return; | ||
226 | } | ||
227 | |||
228 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | ||
229 | index XXXXXXX..XXXXXXX 100644 | ||
230 | --- a/accel/tcg/translate-all.c | ||
231 | +++ b/accel/tcg/translate-all.c | ||
232 | @@ -XXX,XX +XXX,XX @@ | ||
233 | #include "sysemu/tcg.h" | ||
234 | #include "qapi/error.h" | ||
235 | #include "hw/core/tcg-cpu-ops.h" | ||
236 | +#include "tb-jmp-cache.h" | ||
237 | #include "tb-hash.h" | ||
238 | #include "tb-context.h" | ||
239 | #include "internal.h" | ||
240 | @@ -XXX,XX +XXX,XX @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) | ||
241 | } | ||
242 | |||
243 | CPU_FOREACH(cpu) { | ||
244 | - cpu_tb_jmp_cache_clear(cpu); | ||
245 | + tcg_flush_jmp_cache(cpu); | ||
246 | } | ||
247 | |||
248 | qht_reset_size(&tb_ctx.htable, CODE_GEN_HTABLE_SIZE); | ||
249 | @@ -XXX,XX +XXX,XX @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) | ||
250 | /* remove the TB from the hash list */ | ||
251 | h = tb_jmp_cache_hash_func(tb->pc); | ||
252 | CPU_FOREACH(cpu) { | ||
253 | - if (qatomic_read(&cpu->tb_jmp_cache[h]) == tb) { | ||
254 | - qatomic_set(&cpu->tb_jmp_cache[h], NULL); | ||
255 | + CPUJumpCache *jc = cpu->tb_jmp_cache; | ||
256 | + if (qatomic_read(&jc->array[h].tb) == tb) { | ||
257 | + qatomic_set(&jc->array[h].tb, NULL); | ||
258 | } | ||
259 | } | ||
260 | |||
261 | @@ -XXX,XX +XXX,XX @@ int page_unprotect(target_ulong address, uintptr_t pc) | ||
262 | } | ||
263 | #endif /* CONFIG_USER_ONLY */ | ||
264 | |||
265 | +/* | ||
266 | + * Called by generic code at e.g. cpu reset after cpu creation, | ||
267 | + * therefore we must be prepared to allocate the jump cache. | ||
268 | + */ | ||
269 | +void tcg_flush_jmp_cache(CPUState *cpu) | ||
270 | +{ | ||
271 | + CPUJumpCache *jc = cpu->tb_jmp_cache; | ||
272 | + | ||
273 | + if (likely(jc)) { | ||
274 | + for (int i = 0; i < TB_JMP_CACHE_SIZE; i++) { | ||
275 | + qatomic_set(&jc->array[i].tb, NULL); | ||
276 | + } | ||
277 | + } else { | ||
278 | + /* This should happen once during realize, and thus never race. */ | ||
279 | + jc = g_new0(CPUJumpCache, 1); | ||
280 | + jc = qatomic_xchg(&cpu->tb_jmp_cache, jc); | ||
281 | + assert(jc == NULL); | ||
282 | + } | ||
283 | +} | ||
284 | + | ||
285 | /* This is a wrapper for common code that can not use CONFIG_SOFTMMU */ | ||
286 | void tcg_flush_softmmu_tlb(CPUState *cs) | ||
287 | { | ||
288 | diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c | ||
289 | index XXXXXXX..XXXXXXX 100644 | ||
290 | --- a/hw/core/cpu-common.c | ||
291 | +++ b/hw/core/cpu-common.c | ||
292 | @@ -XXX,XX +XXX,XX @@ static void cpu_common_reset(DeviceState *dev) | ||
293 | cpu->cflags_next_tb = -1; | ||
294 | |||
295 | if (tcg_enabled()) { | ||
296 | - cpu_tb_jmp_cache_clear(cpu); | ||
37 | - | 297 | - |
38 | #if TCG_TARGET_HAS_ext8s_i32 || TCG_TARGET_HAS_ext8s_i64 | 298 | + tcg_flush_jmp_cache(cpu); |
39 | /* Read indexed register (8 bit signed) from bytecode. */ | 299 | tcg_flush_softmmu_tlb(cpu); |
40 | static int8_t tci_read_r8s(const tcg_target_ulong *regs, const uint8_t **tb_ptr) | 300 | } |
41 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 301 | } |
42 | tci_write_reg(regs, t0, *(uint32_t *)(t1 + t2)); | 302 | diff --git a/plugins/core.c b/plugins/core.c |
43 | break; | 303 | index XXXXXXX..XXXXXXX 100644 |
44 | CASE_32_64(st8) | 304 | --- a/plugins/core.c |
45 | - t0 = tci_read_r8(regs, &tb_ptr); | 305 | +++ b/plugins/core.c |
46 | + t0 = tci_read_r(regs, &tb_ptr); | 306 | @@ -XXX,XX +XXX,XX @@ struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id) |
47 | t1 = tci_read_r(regs, &tb_ptr); | 307 | static void plugin_cpu_update__async(CPUState *cpu, run_on_cpu_data data) |
48 | t2 = tci_read_s32(&tb_ptr); | 308 | { |
49 | *(uint8_t *)(t1 + t2) = t0; | 309 | bitmap_copy(cpu->plugin_mask, &data.host_ulong, QEMU_PLUGIN_EV_MAX); |
50 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 310 | - cpu_tb_jmp_cache_clear(cpu); |
51 | #if TCG_TARGET_HAS_ext8u_i32 | 311 | + tcg_flush_jmp_cache(cpu); |
52 | case INDEX_op_ext8u_i32: | 312 | } |
53 | t0 = *tb_ptr++; | 313 | |
54 | - t1 = tci_read_r8(regs, &tb_ptr); | 314 | static void plugin_cpu_update__locked(gpointer k, gpointer v, gpointer udata) |
55 | - tci_write_reg(regs, t0, t1); | 315 | diff --git a/trace/control-target.c b/trace/control-target.c |
56 | + t1 = tci_read_r(regs, &tb_ptr); | 316 | index XXXXXXX..XXXXXXX 100644 |
57 | + tci_write_reg(regs, t0, (uint8_t)t1); | 317 | --- a/trace/control-target.c |
58 | break; | 318 | +++ b/trace/control-target.c |
59 | #endif | 319 | @@ -XXX,XX +XXX,XX @@ static void trace_event_synchronize_vcpu_state_dynamic( |
60 | #if TCG_TARGET_HAS_ext16u_i32 | 320 | { |
61 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 321 | bitmap_copy(vcpu->trace_dstate, vcpu->trace_dstate_delayed, |
62 | #if TCG_TARGET_HAS_ext8u_i64 | 322 | CPU_TRACE_DSTATE_MAX_EVENTS); |
63 | case INDEX_op_ext8u_i64: | 323 | - cpu_tb_jmp_cache_clear(vcpu); |
64 | t0 = *tb_ptr++; | 324 | + tcg_flush_jmp_cache(vcpu); |
65 | - t1 = tci_read_r8(regs, &tb_ptr); | 325 | } |
66 | - tci_write_reg(regs, t0, t1); | 326 | |
67 | + t1 = tci_read_r(regs, &tb_ptr); | 327 | void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, |
68 | + tci_write_reg(regs, t0, (uint8_t)t1); | ||
69 | break; | ||
70 | #endif | ||
71 | #if TCG_TARGET_HAS_ext8s_i64 | ||
72 | -- | 328 | -- |
73 | 2.25.1 | 329 | 2.34.1 |
74 | 330 | ||
75 | 331 | diff view generated by jsdifflib |
1 | An hppa guest executing | 1 | Populate this new method for all targets. Always match |
---|---|---|---|
2 | the result that would be given by cpu_get_tb_cpu_state, | ||
3 | as we will want these values to correspond in the logs. | ||
2 | 4 | ||
3 | 0x000000000000e05c: ldil L%10000,r4 | 5 | Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> |
4 | 0x000000000000e060: ldo 0(r4),r4 | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
5 | 0x000000000000e064: sub r3,r4,sp | 7 | Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> (target/sparc) |
6 | |||
7 | produces | ||
8 | |||
9 | ---- 000000000000e064 000000000000e068 | ||
10 | sub2_i32 tmp0,tmp4,r3,$0x1,$0x10000,$0x0 | ||
11 | |||
12 | after folding and constant propagation. Then we hit | ||
13 | |||
14 | tcg-target.c.inc:640: tcg_out_insn_3401: Assertion `aimm <= 0xfff' failed. | ||
15 | |||
16 | because aimm is in fact -16, but unsigned. | ||
17 | |||
18 | The ((bl < 0) ^ sub) condition which negates bl is incorrect and will | ||
19 | always lead to this abort. If the constant is positive, sub will make | ||
20 | it negative; if the constant is negative, sub will keep it negative. | ||
21 | |||
22 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
23 | --- | 9 | --- |
24 | tcg/aarch64/tcg-target.c.inc | 16 +++++++++------- | 10 | Cc: Eduardo Habkost <eduardo@habkost.net> (supporter:Machine core) |
25 | 1 file changed, 9 insertions(+), 7 deletions(-) | 11 | Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> (supporter:Machine core) |
12 | Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org> (reviewer:Machine core) | ||
13 | Cc: Yanan Wang <wangyanan55@huawei.com> (reviewer:Machine core) | ||
14 | Cc: Michael Rolnik <mrolnik@gmail.com> (maintainer:AVR TCG CPUs) | ||
15 | Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com> (maintainer:CRIS TCG CPUs) | ||
16 | Cc: Taylor Simpson <tsimpson@quicinc.com> (supporter:Hexagon TCG CPUs) | ||
17 | Cc: Song Gao <gaosong@loongson.cn> (maintainer:LoongArch TCG CPUs) | ||
18 | Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn> (maintainer:LoongArch TCG CPUs) | ||
19 | Cc: Laurent Vivier <laurent@vivier.eu> (maintainer:M68K TCG CPUs) | ||
20 | Cc: Jiaxun Yang <jiaxun.yang@flygoat.com> (reviewer:MIPS TCG CPUs) | ||
21 | Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com> (reviewer:MIPS TCG CPUs) | ||
22 | Cc: Chris Wulff <crwulff@gmail.com> (maintainer:NiosII TCG CPUs) | ||
23 | Cc: Marek Vasut <marex@denx.de> (maintainer:NiosII TCG CPUs) | ||
24 | Cc: Stafford Horne <shorne@gmail.com> (odd fixer:OpenRISC TCG CPUs) | ||
25 | Cc: Yoshinori Sato <ysato@users.sourceforge.jp> (reviewer:RENESAS RX CPUs) | ||
26 | Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> (maintainer:SPARC TCG CPUs) | ||
27 | Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de> (maintainer:TriCore TCG CPUs) | ||
28 | Cc: Max Filippov <jcmvbkbc@gmail.com> (maintainer:Xtensa TCG CPUs) | ||
29 | Cc: qemu-arm@nongnu.org (open list:ARM TCG CPUs) | ||
30 | Cc: qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs) | ||
31 | Cc: qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) | ||
32 | Cc: qemu-s390x@nongnu.org (open list:S390 TCG CPUs) | ||
33 | --- | ||
34 | include/hw/core/cpu.h | 3 +++ | ||
35 | target/alpha/cpu.c | 9 +++++++++ | ||
36 | target/arm/cpu.c | 13 +++++++++++++ | ||
37 | target/avr/cpu.c | 8 ++++++++ | ||
38 | target/cris/cpu.c | 8 ++++++++ | ||
39 | target/hexagon/cpu.c | 8 ++++++++ | ||
40 | target/hppa/cpu.c | 8 ++++++++ | ||
41 | target/i386/cpu.c | 9 +++++++++ | ||
42 | target/loongarch/cpu.c | 9 +++++++++ | ||
43 | target/m68k/cpu.c | 8 ++++++++ | ||
44 | target/microblaze/cpu.c | 8 ++++++++ | ||
45 | target/mips/cpu.c | 8 ++++++++ | ||
46 | target/nios2/cpu.c | 9 +++++++++ | ||
47 | target/openrisc/cpu.c | 8 ++++++++ | ||
48 | target/ppc/cpu_init.c | 8 ++++++++ | ||
49 | target/riscv/cpu.c | 13 +++++++++++++ | ||
50 | target/rx/cpu.c | 8 ++++++++ | ||
51 | target/s390x/cpu.c | 8 ++++++++ | ||
52 | target/sh4/cpu.c | 8 ++++++++ | ||
53 | target/sparc/cpu.c | 8 ++++++++ | ||
54 | target/tricore/cpu.c | 9 +++++++++ | ||
55 | target/xtensa/cpu.c | 8 ++++++++ | ||
56 | 22 files changed, 186 insertions(+) | ||
26 | 57 | ||
27 | diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc | 58 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h |
28 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/tcg/aarch64/tcg-target.c.inc | 60 | --- a/include/hw/core/cpu.h |
30 | +++ b/tcg/aarch64/tcg-target.c.inc | 61 | +++ b/include/hw/core/cpu.h |
31 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_addsubi(TCGContext *s, int ext, TCGReg rd, | 62 | @@ -XXX,XX +XXX,XX @@ struct SysemuCPUOps; |
63 | * If the target behaviour here is anything other than "set | ||
64 | * the PC register to the value passed in" then the target must | ||
65 | * also implement the synchronize_from_tb hook. | ||
66 | + * @get_pc: Callback for getting the Program Counter register. | ||
67 | + * As above, with the semantics of the target architecture. | ||
68 | * @gdb_read_register: Callback for letting GDB read a register. | ||
69 | * @gdb_write_register: Callback for letting GDB write a register. | ||
70 | * @gdb_adjust_breakpoint: Callback for adjusting the address of a | ||
71 | @@ -XXX,XX +XXX,XX @@ struct CPUClass { | ||
72 | void (*dump_state)(CPUState *cpu, FILE *, int flags); | ||
73 | int64_t (*get_arch_id)(CPUState *cpu); | ||
74 | void (*set_pc)(CPUState *cpu, vaddr value); | ||
75 | + vaddr (*get_pc)(CPUState *cpu); | ||
76 | int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); | ||
77 | int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg); | ||
78 | vaddr (*gdb_adjust_breakpoint)(CPUState *cpu, vaddr addr); | ||
79 | diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/target/alpha/cpu.c | ||
82 | +++ b/target/alpha/cpu.c | ||
83 | @@ -XXX,XX +XXX,XX @@ static void alpha_cpu_set_pc(CPUState *cs, vaddr value) | ||
84 | cpu->env.pc = value; | ||
85 | } | ||
86 | |||
87 | +static vaddr alpha_cpu_get_pc(CPUState *cs) | ||
88 | +{ | ||
89 | + AlphaCPU *cpu = ALPHA_CPU(cs); | ||
90 | + | ||
91 | + return cpu->env.pc; | ||
92 | +} | ||
93 | + | ||
94 | + | ||
95 | static bool alpha_cpu_has_work(CPUState *cs) | ||
96 | { | ||
97 | /* Here we are checking to see if the CPU should wake up from HALT. | ||
98 | @@ -XXX,XX +XXX,XX @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) | ||
99 | cc->has_work = alpha_cpu_has_work; | ||
100 | cc->dump_state = alpha_cpu_dump_state; | ||
101 | cc->set_pc = alpha_cpu_set_pc; | ||
102 | + cc->get_pc = alpha_cpu_get_pc; | ||
103 | cc->gdb_read_register = alpha_cpu_gdb_read_register; | ||
104 | cc->gdb_write_register = alpha_cpu_gdb_write_register; | ||
105 | #ifndef CONFIG_USER_ONLY | ||
106 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/cpu.c | ||
109 | +++ b/target/arm/cpu.c | ||
110 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) | ||
32 | } | 111 | } |
33 | } | 112 | } |
34 | 113 | ||
35 | -static inline void tcg_out_addsub2(TCGContext *s, TCGType ext, TCGReg rl, | 114 | +static vaddr arm_cpu_get_pc(CPUState *cs) |
36 | - TCGReg rh, TCGReg al, TCGReg ah, | 115 | +{ |
37 | - tcg_target_long bl, tcg_target_long bh, | 116 | + ARMCPU *cpu = ARM_CPU(cs); |
38 | - bool const_bl, bool const_bh, bool sub) | 117 | + CPUARMState *env = &cpu->env; |
39 | +static void tcg_out_addsub2(TCGContext *s, TCGType ext, TCGReg rl, | 118 | + |
40 | + TCGReg rh, TCGReg al, TCGReg ah, | 119 | + if (is_a64(env)) { |
41 | + tcg_target_long bl, tcg_target_long bh, | 120 | + return env->pc; |
42 | + bool const_bl, bool const_bh, bool sub) | 121 | + } else { |
43 | { | 122 | + return env->regs[15]; |
44 | TCGReg orig_rl = rl; | 123 | + } |
45 | AArch64Insn insn; | 124 | +} |
46 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_addsub2(TCGContext *s, TCGType ext, TCGReg rl, | 125 | + |
126 | #ifdef CONFIG_TCG | ||
127 | void arm_cpu_synchronize_from_tb(CPUState *cs, | ||
128 | const TranslationBlock *tb) | ||
129 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) | ||
130 | cc->has_work = arm_cpu_has_work; | ||
131 | cc->dump_state = arm_cpu_dump_state; | ||
132 | cc->set_pc = arm_cpu_set_pc; | ||
133 | + cc->get_pc = arm_cpu_get_pc; | ||
134 | cc->gdb_read_register = arm_cpu_gdb_read_register; | ||
135 | cc->gdb_write_register = arm_cpu_gdb_write_register; | ||
136 | #ifndef CONFIG_USER_ONLY | ||
137 | diff --git a/target/avr/cpu.c b/target/avr/cpu.c | ||
138 | index XXXXXXX..XXXXXXX 100644 | ||
139 | --- a/target/avr/cpu.c | ||
140 | +++ b/target/avr/cpu.c | ||
141 | @@ -XXX,XX +XXX,XX @@ static void avr_cpu_set_pc(CPUState *cs, vaddr value) | ||
142 | cpu->env.pc_w = value / 2; /* internally PC points to words */ | ||
143 | } | ||
144 | |||
145 | +static vaddr avr_cpu_get_pc(CPUState *cs) | ||
146 | +{ | ||
147 | + AVRCPU *cpu = AVR_CPU(cs); | ||
148 | + | ||
149 | + return cpu->env.pc_w * 2; | ||
150 | +} | ||
151 | + | ||
152 | static bool avr_cpu_has_work(CPUState *cs) | ||
153 | { | ||
154 | AVRCPU *cpu = AVR_CPU(cs); | ||
155 | @@ -XXX,XX +XXX,XX @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) | ||
156 | cc->has_work = avr_cpu_has_work; | ||
157 | cc->dump_state = avr_cpu_dump_state; | ||
158 | cc->set_pc = avr_cpu_set_pc; | ||
159 | + cc->get_pc = avr_cpu_get_pc; | ||
160 | dc->vmsd = &vms_avr_cpu; | ||
161 | cc->sysemu_ops = &avr_sysemu_ops; | ||
162 | cc->disas_set_info = avr_cpu_disas_set_info; | ||
163 | diff --git a/target/cris/cpu.c b/target/cris/cpu.c | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/target/cris/cpu.c | ||
166 | +++ b/target/cris/cpu.c | ||
167 | @@ -XXX,XX +XXX,XX @@ static void cris_cpu_set_pc(CPUState *cs, vaddr value) | ||
168 | cpu->env.pc = value; | ||
169 | } | ||
170 | |||
171 | +static vaddr cris_cpu_get_pc(CPUState *cs) | ||
172 | +{ | ||
173 | + CRISCPU *cpu = CRIS_CPU(cs); | ||
174 | + | ||
175 | + return cpu->env.pc; | ||
176 | +} | ||
177 | + | ||
178 | static bool cris_cpu_has_work(CPUState *cs) | ||
179 | { | ||
180 | return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI); | ||
181 | @@ -XXX,XX +XXX,XX @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) | ||
182 | cc->has_work = cris_cpu_has_work; | ||
183 | cc->dump_state = cris_cpu_dump_state; | ||
184 | cc->set_pc = cris_cpu_set_pc; | ||
185 | + cc->get_pc = cris_cpu_get_pc; | ||
186 | cc->gdb_read_register = cris_cpu_gdb_read_register; | ||
187 | cc->gdb_write_register = cris_cpu_gdb_write_register; | ||
188 | #ifndef CONFIG_USER_ONLY | ||
189 | diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c | ||
190 | index XXXXXXX..XXXXXXX 100644 | ||
191 | --- a/target/hexagon/cpu.c | ||
192 | +++ b/target/hexagon/cpu.c | ||
193 | @@ -XXX,XX +XXX,XX @@ static void hexagon_cpu_set_pc(CPUState *cs, vaddr value) | ||
194 | env->gpr[HEX_REG_PC] = value; | ||
195 | } | ||
196 | |||
197 | +static vaddr hexagon_cpu_get_pc(CPUState *cs) | ||
198 | +{ | ||
199 | + HexagonCPU *cpu = HEXAGON_CPU(cs); | ||
200 | + CPUHexagonState *env = &cpu->env; | ||
201 | + return env->gpr[HEX_REG_PC]; | ||
202 | +} | ||
203 | + | ||
204 | static void hexagon_cpu_synchronize_from_tb(CPUState *cs, | ||
205 | const TranslationBlock *tb) | ||
206 | { | ||
207 | @@ -XXX,XX +XXX,XX @@ static void hexagon_cpu_class_init(ObjectClass *c, void *data) | ||
208 | cc->has_work = hexagon_cpu_has_work; | ||
209 | cc->dump_state = hexagon_dump_state; | ||
210 | cc->set_pc = hexagon_cpu_set_pc; | ||
211 | + cc->get_pc = hexagon_cpu_get_pc; | ||
212 | cc->gdb_read_register = hexagon_gdb_read_register; | ||
213 | cc->gdb_write_register = hexagon_gdb_write_register; | ||
214 | cc->gdb_num_core_regs = TOTAL_PER_THREAD_REGS + NUM_VREGS + NUM_QREGS; | ||
215 | diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c | ||
216 | index XXXXXXX..XXXXXXX 100644 | ||
217 | --- a/target/hppa/cpu.c | ||
218 | +++ b/target/hppa/cpu.c | ||
219 | @@ -XXX,XX +XXX,XX @@ static void hppa_cpu_set_pc(CPUState *cs, vaddr value) | ||
220 | cpu->env.iaoq_b = value + 4; | ||
221 | } | ||
222 | |||
223 | +static vaddr hppa_cpu_get_pc(CPUState *cs) | ||
224 | +{ | ||
225 | + HPPACPU *cpu = HPPA_CPU(cs); | ||
226 | + | ||
227 | + return cpu->env.iaoq_f; | ||
228 | +} | ||
229 | + | ||
230 | static void hppa_cpu_synchronize_from_tb(CPUState *cs, | ||
231 | const TranslationBlock *tb) | ||
232 | { | ||
233 | @@ -XXX,XX +XXX,XX @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) | ||
234 | cc->has_work = hppa_cpu_has_work; | ||
235 | cc->dump_state = hppa_cpu_dump_state; | ||
236 | cc->set_pc = hppa_cpu_set_pc; | ||
237 | + cc->get_pc = hppa_cpu_get_pc; | ||
238 | cc->gdb_read_register = hppa_cpu_gdb_read_register; | ||
239 | cc->gdb_write_register = hppa_cpu_gdb_write_register; | ||
240 | #ifndef CONFIG_USER_ONLY | ||
241 | diff --git a/target/i386/cpu.c b/target/i386/cpu.c | ||
242 | index XXXXXXX..XXXXXXX 100644 | ||
243 | --- a/target/i386/cpu.c | ||
244 | +++ b/target/i386/cpu.c | ||
245 | @@ -XXX,XX +XXX,XX @@ static void x86_cpu_set_pc(CPUState *cs, vaddr value) | ||
246 | cpu->env.eip = value; | ||
247 | } | ||
248 | |||
249 | +static vaddr x86_cpu_get_pc(CPUState *cs) | ||
250 | +{ | ||
251 | + X86CPU *cpu = X86_CPU(cs); | ||
252 | + | ||
253 | + /* Match cpu_get_tb_cpu_state. */ | ||
254 | + return cpu->env.eip + cpu->env.segs[R_CS].base; | ||
255 | +} | ||
256 | + | ||
257 | int x86_cpu_pending_interrupt(CPUState *cs, int interrupt_request) | ||
258 | { | ||
259 | X86CPU *cpu = X86_CPU(cs); | ||
260 | @@ -XXX,XX +XXX,XX @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) | ||
261 | cc->has_work = x86_cpu_has_work; | ||
262 | cc->dump_state = x86_cpu_dump_state; | ||
263 | cc->set_pc = x86_cpu_set_pc; | ||
264 | + cc->get_pc = x86_cpu_get_pc; | ||
265 | cc->gdb_read_register = x86_cpu_gdb_read_register; | ||
266 | cc->gdb_write_register = x86_cpu_gdb_write_register; | ||
267 | cc->get_arch_id = x86_cpu_get_arch_id; | ||
268 | diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c | ||
269 | index XXXXXXX..XXXXXXX 100644 | ||
270 | --- a/target/loongarch/cpu.c | ||
271 | +++ b/target/loongarch/cpu.c | ||
272 | @@ -XXX,XX +XXX,XX @@ static void loongarch_cpu_set_pc(CPUState *cs, vaddr value) | ||
273 | env->pc = value; | ||
274 | } | ||
275 | |||
276 | +static vaddr loongarch_cpu_get_pc(CPUState *cs) | ||
277 | +{ | ||
278 | + LoongArchCPU *cpu = LOONGARCH_CPU(cs); | ||
279 | + CPULoongArchState *env = &cpu->env; | ||
280 | + | ||
281 | + return env->pc; | ||
282 | +} | ||
283 | + | ||
284 | #ifndef CONFIG_USER_ONLY | ||
285 | #include "hw/loongarch/virt.h" | ||
286 | |||
287 | @@ -XXX,XX +XXX,XX @@ static void loongarch_cpu_class_init(ObjectClass *c, void *data) | ||
288 | cc->has_work = loongarch_cpu_has_work; | ||
289 | cc->dump_state = loongarch_cpu_dump_state; | ||
290 | cc->set_pc = loongarch_cpu_set_pc; | ||
291 | + cc->get_pc = loongarch_cpu_get_pc; | ||
292 | #ifndef CONFIG_USER_ONLY | ||
293 | dc->vmsd = &vmstate_loongarch_cpu; | ||
294 | cc->sysemu_ops = &loongarch_sysemu_ops; | ||
295 | diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c | ||
296 | index XXXXXXX..XXXXXXX 100644 | ||
297 | --- a/target/m68k/cpu.c | ||
298 | +++ b/target/m68k/cpu.c | ||
299 | @@ -XXX,XX +XXX,XX @@ static void m68k_cpu_set_pc(CPUState *cs, vaddr value) | ||
300 | cpu->env.pc = value; | ||
301 | } | ||
302 | |||
303 | +static vaddr m68k_cpu_get_pc(CPUState *cs) | ||
304 | +{ | ||
305 | + M68kCPU *cpu = M68K_CPU(cs); | ||
306 | + | ||
307 | + return cpu->env.pc; | ||
308 | +} | ||
309 | + | ||
310 | static bool m68k_cpu_has_work(CPUState *cs) | ||
311 | { | ||
312 | return cs->interrupt_request & CPU_INTERRUPT_HARD; | ||
313 | @@ -XXX,XX +XXX,XX @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) | ||
314 | cc->has_work = m68k_cpu_has_work; | ||
315 | cc->dump_state = m68k_cpu_dump_state; | ||
316 | cc->set_pc = m68k_cpu_set_pc; | ||
317 | + cc->get_pc = m68k_cpu_get_pc; | ||
318 | cc->gdb_read_register = m68k_cpu_gdb_read_register; | ||
319 | cc->gdb_write_register = m68k_cpu_gdb_write_register; | ||
320 | #if defined(CONFIG_SOFTMMU) | ||
321 | diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c | ||
322 | index XXXXXXX..XXXXXXX 100644 | ||
323 | --- a/target/microblaze/cpu.c | ||
324 | +++ b/target/microblaze/cpu.c | ||
325 | @@ -XXX,XX +XXX,XX @@ static void mb_cpu_set_pc(CPUState *cs, vaddr value) | ||
326 | cpu->env.iflags = 0; | ||
327 | } | ||
328 | |||
329 | +static vaddr mb_cpu_get_pc(CPUState *cs) | ||
330 | +{ | ||
331 | + MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); | ||
332 | + | ||
333 | + return cpu->env.pc; | ||
334 | +} | ||
335 | + | ||
336 | static void mb_cpu_synchronize_from_tb(CPUState *cs, | ||
337 | const TranslationBlock *tb) | ||
338 | { | ||
339 | @@ -XXX,XX +XXX,XX @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) | ||
340 | |||
341 | cc->dump_state = mb_cpu_dump_state; | ||
342 | cc->set_pc = mb_cpu_set_pc; | ||
343 | + cc->get_pc = mb_cpu_get_pc; | ||
344 | cc->gdb_read_register = mb_cpu_gdb_read_register; | ||
345 | cc->gdb_write_register = mb_cpu_gdb_write_register; | ||
346 | |||
347 | diff --git a/target/mips/cpu.c b/target/mips/cpu.c | ||
348 | index XXXXXXX..XXXXXXX 100644 | ||
349 | --- a/target/mips/cpu.c | ||
350 | +++ b/target/mips/cpu.c | ||
351 | @@ -XXX,XX +XXX,XX @@ static void mips_cpu_set_pc(CPUState *cs, vaddr value) | ||
352 | mips_env_set_pc(&cpu->env, value); | ||
353 | } | ||
354 | |||
355 | +static vaddr mips_cpu_get_pc(CPUState *cs) | ||
356 | +{ | ||
357 | + MIPSCPU *cpu = MIPS_CPU(cs); | ||
358 | + | ||
359 | + return cpu->env.active_tc.PC; | ||
360 | +} | ||
361 | + | ||
362 | static bool mips_cpu_has_work(CPUState *cs) | ||
363 | { | ||
364 | MIPSCPU *cpu = MIPS_CPU(cs); | ||
365 | @@ -XXX,XX +XXX,XX @@ static void mips_cpu_class_init(ObjectClass *c, void *data) | ||
366 | cc->has_work = mips_cpu_has_work; | ||
367 | cc->dump_state = mips_cpu_dump_state; | ||
368 | cc->set_pc = mips_cpu_set_pc; | ||
369 | + cc->get_pc = mips_cpu_get_pc; | ||
370 | cc->gdb_read_register = mips_cpu_gdb_read_register; | ||
371 | cc->gdb_write_register = mips_cpu_gdb_write_register; | ||
372 | #ifndef CONFIG_USER_ONLY | ||
373 | diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c | ||
374 | index XXXXXXX..XXXXXXX 100644 | ||
375 | --- a/target/nios2/cpu.c | ||
376 | +++ b/target/nios2/cpu.c | ||
377 | @@ -XXX,XX +XXX,XX @@ static void nios2_cpu_set_pc(CPUState *cs, vaddr value) | ||
378 | env->pc = value; | ||
379 | } | ||
380 | |||
381 | +static vaddr nios2_cpu_get_pc(CPUState *cs) | ||
382 | +{ | ||
383 | + Nios2CPU *cpu = NIOS2_CPU(cs); | ||
384 | + CPUNios2State *env = &cpu->env; | ||
385 | + | ||
386 | + return env->pc; | ||
387 | +} | ||
388 | + | ||
389 | static bool nios2_cpu_has_work(CPUState *cs) | ||
390 | { | ||
391 | return cs->interrupt_request & CPU_INTERRUPT_HARD; | ||
392 | @@ -XXX,XX +XXX,XX @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data) | ||
393 | cc->has_work = nios2_cpu_has_work; | ||
394 | cc->dump_state = nios2_cpu_dump_state; | ||
395 | cc->set_pc = nios2_cpu_set_pc; | ||
396 | + cc->get_pc = nios2_cpu_get_pc; | ||
397 | cc->disas_set_info = nios2_cpu_disas_set_info; | ||
398 | #ifndef CONFIG_USER_ONLY | ||
399 | cc->sysemu_ops = &nios2_sysemu_ops; | ||
400 | diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c | ||
401 | index XXXXXXX..XXXXXXX 100644 | ||
402 | --- a/target/openrisc/cpu.c | ||
403 | +++ b/target/openrisc/cpu.c | ||
404 | @@ -XXX,XX +XXX,XX @@ static void openrisc_cpu_set_pc(CPUState *cs, vaddr value) | ||
405 | cpu->env.dflag = 0; | ||
406 | } | ||
407 | |||
408 | +static vaddr openrisc_cpu_get_pc(CPUState *cs) | ||
409 | +{ | ||
410 | + OpenRISCCPU *cpu = OPENRISC_CPU(cs); | ||
411 | + | ||
412 | + return cpu->env.pc; | ||
413 | +} | ||
414 | + | ||
415 | static void openrisc_cpu_synchronize_from_tb(CPUState *cs, | ||
416 | const TranslationBlock *tb) | ||
417 | { | ||
418 | @@ -XXX,XX +XXX,XX @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) | ||
419 | cc->has_work = openrisc_cpu_has_work; | ||
420 | cc->dump_state = openrisc_cpu_dump_state; | ||
421 | cc->set_pc = openrisc_cpu_set_pc; | ||
422 | + cc->get_pc = openrisc_cpu_get_pc; | ||
423 | cc->gdb_read_register = openrisc_cpu_gdb_read_register; | ||
424 | cc->gdb_write_register = openrisc_cpu_gdb_write_register; | ||
425 | #ifndef CONFIG_USER_ONLY | ||
426 | diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c | ||
427 | index XXXXXXX..XXXXXXX 100644 | ||
428 | --- a/target/ppc/cpu_init.c | ||
429 | +++ b/target/ppc/cpu_init.c | ||
430 | @@ -XXX,XX +XXX,XX @@ static void ppc_cpu_set_pc(CPUState *cs, vaddr value) | ||
431 | cpu->env.nip = value; | ||
432 | } | ||
433 | |||
434 | +static vaddr ppc_cpu_get_pc(CPUState *cs) | ||
435 | +{ | ||
436 | + PowerPCCPU *cpu = POWERPC_CPU(cs); | ||
437 | + | ||
438 | + return cpu->env.nip; | ||
439 | +} | ||
440 | + | ||
441 | static bool ppc_cpu_has_work(CPUState *cs) | ||
442 | { | ||
443 | PowerPCCPU *cpu = POWERPC_CPU(cs); | ||
444 | @@ -XXX,XX +XXX,XX @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) | ||
445 | cc->has_work = ppc_cpu_has_work; | ||
446 | cc->dump_state = ppc_cpu_dump_state; | ||
447 | cc->set_pc = ppc_cpu_set_pc; | ||
448 | + cc->get_pc = ppc_cpu_get_pc; | ||
449 | cc->gdb_read_register = ppc_cpu_gdb_read_register; | ||
450 | cc->gdb_write_register = ppc_cpu_gdb_write_register; | ||
451 | #ifndef CONFIG_USER_ONLY | ||
452 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
453 | index XXXXXXX..XXXXXXX 100644 | ||
454 | --- a/target/riscv/cpu.c | ||
455 | +++ b/target/riscv/cpu.c | ||
456 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_set_pc(CPUState *cs, vaddr value) | ||
47 | } | 457 | } |
48 | 458 | } | |
49 | if (const_bl) { | 459 | |
50 | - insn = I3401_ADDSI; | 460 | +static vaddr riscv_cpu_get_pc(CPUState *cs) |
51 | - if ((bl < 0) ^ sub) { | 461 | +{ |
52 | - insn = I3401_SUBSI; | 462 | + RISCVCPU *cpu = RISCV_CPU(cs); |
53 | + if (bl < 0) { | 463 | + CPURISCVState *env = &cpu->env; |
54 | bl = -bl; | 464 | + |
55 | + insn = sub ? I3401_ADDSI : I3401_SUBSI; | 465 | + /* Match cpu_get_tb_cpu_state. */ |
56 | + } else { | 466 | + if (env->xl == MXL_RV32) { |
57 | + insn = sub ? I3401_SUBSI : I3401_ADDSI; | 467 | + return env->pc & UINT32_MAX; |
58 | } | 468 | + } |
59 | + | 469 | + return env->pc; |
60 | if (unlikely(al == TCG_REG_XZR)) { | 470 | +} |
61 | /* ??? We want to allow al to be zero for the benefit of | 471 | + |
62 | negation via subtraction. However, that leaves open the | 472 | static void riscv_cpu_synchronize_from_tb(CPUState *cs, |
473 | const TranslationBlock *tb) | ||
474 | { | ||
475 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) | ||
476 | cc->has_work = riscv_cpu_has_work; | ||
477 | cc->dump_state = riscv_cpu_dump_state; | ||
478 | cc->set_pc = riscv_cpu_set_pc; | ||
479 | + cc->get_pc = riscv_cpu_get_pc; | ||
480 | cc->gdb_read_register = riscv_cpu_gdb_read_register; | ||
481 | cc->gdb_write_register = riscv_cpu_gdb_write_register; | ||
482 | cc->gdb_num_core_regs = 33; | ||
483 | diff --git a/target/rx/cpu.c b/target/rx/cpu.c | ||
484 | index XXXXXXX..XXXXXXX 100644 | ||
485 | --- a/target/rx/cpu.c | ||
486 | +++ b/target/rx/cpu.c | ||
487 | @@ -XXX,XX +XXX,XX @@ static void rx_cpu_set_pc(CPUState *cs, vaddr value) | ||
488 | cpu->env.pc = value; | ||
489 | } | ||
490 | |||
491 | +static vaddr rx_cpu_get_pc(CPUState *cs) | ||
492 | +{ | ||
493 | + RXCPU *cpu = RX_CPU(cs); | ||
494 | + | ||
495 | + return cpu->env.pc; | ||
496 | +} | ||
497 | + | ||
498 | static void rx_cpu_synchronize_from_tb(CPUState *cs, | ||
499 | const TranslationBlock *tb) | ||
500 | { | ||
501 | @@ -XXX,XX +XXX,XX @@ static void rx_cpu_class_init(ObjectClass *klass, void *data) | ||
502 | cc->has_work = rx_cpu_has_work; | ||
503 | cc->dump_state = rx_cpu_dump_state; | ||
504 | cc->set_pc = rx_cpu_set_pc; | ||
505 | + cc->get_pc = rx_cpu_get_pc; | ||
506 | |||
507 | #ifndef CONFIG_USER_ONLY | ||
508 | cc->sysemu_ops = &rx_sysemu_ops; | ||
509 | diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c | ||
510 | index XXXXXXX..XXXXXXX 100644 | ||
511 | --- a/target/s390x/cpu.c | ||
512 | +++ b/target/s390x/cpu.c | ||
513 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value) | ||
514 | cpu->env.psw.addr = value; | ||
515 | } | ||
516 | |||
517 | +static vaddr s390_cpu_get_pc(CPUState *cs) | ||
518 | +{ | ||
519 | + S390CPU *cpu = S390_CPU(cs); | ||
520 | + | ||
521 | + return cpu->env.psw.addr; | ||
522 | +} | ||
523 | + | ||
524 | static bool s390_cpu_has_work(CPUState *cs) | ||
525 | { | ||
526 | S390CPU *cpu = S390_CPU(cs); | ||
527 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) | ||
528 | cc->has_work = s390_cpu_has_work; | ||
529 | cc->dump_state = s390_cpu_dump_state; | ||
530 | cc->set_pc = s390_cpu_set_pc; | ||
531 | + cc->get_pc = s390_cpu_get_pc; | ||
532 | cc->gdb_read_register = s390_cpu_gdb_read_register; | ||
533 | cc->gdb_write_register = s390_cpu_gdb_write_register; | ||
534 | #ifndef CONFIG_USER_ONLY | ||
535 | diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c | ||
536 | index XXXXXXX..XXXXXXX 100644 | ||
537 | --- a/target/sh4/cpu.c | ||
538 | +++ b/target/sh4/cpu.c | ||
539 | @@ -XXX,XX +XXX,XX @@ static void superh_cpu_set_pc(CPUState *cs, vaddr value) | ||
540 | cpu->env.pc = value; | ||
541 | } | ||
542 | |||
543 | +static vaddr superh_cpu_get_pc(CPUState *cs) | ||
544 | +{ | ||
545 | + SuperHCPU *cpu = SUPERH_CPU(cs); | ||
546 | + | ||
547 | + return cpu->env.pc; | ||
548 | +} | ||
549 | + | ||
550 | static void superh_cpu_synchronize_from_tb(CPUState *cs, | ||
551 | const TranslationBlock *tb) | ||
552 | { | ||
553 | @@ -XXX,XX +XXX,XX @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) | ||
554 | cc->has_work = superh_cpu_has_work; | ||
555 | cc->dump_state = superh_cpu_dump_state; | ||
556 | cc->set_pc = superh_cpu_set_pc; | ||
557 | + cc->get_pc = superh_cpu_get_pc; | ||
558 | cc->gdb_read_register = superh_cpu_gdb_read_register; | ||
559 | cc->gdb_write_register = superh_cpu_gdb_write_register; | ||
560 | #ifndef CONFIG_USER_ONLY | ||
561 | diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c | ||
562 | index XXXXXXX..XXXXXXX 100644 | ||
563 | --- a/target/sparc/cpu.c | ||
564 | +++ b/target/sparc/cpu.c | ||
565 | @@ -XXX,XX +XXX,XX @@ static void sparc_cpu_set_pc(CPUState *cs, vaddr value) | ||
566 | cpu->env.npc = value + 4; | ||
567 | } | ||
568 | |||
569 | +static vaddr sparc_cpu_get_pc(CPUState *cs) | ||
570 | +{ | ||
571 | + SPARCCPU *cpu = SPARC_CPU(cs); | ||
572 | + | ||
573 | + return cpu->env.pc; | ||
574 | +} | ||
575 | + | ||
576 | static void sparc_cpu_synchronize_from_tb(CPUState *cs, | ||
577 | const TranslationBlock *tb) | ||
578 | { | ||
579 | @@ -XXX,XX +XXX,XX @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) | ||
580 | cc->memory_rw_debug = sparc_cpu_memory_rw_debug; | ||
581 | #endif | ||
582 | cc->set_pc = sparc_cpu_set_pc; | ||
583 | + cc->get_pc = sparc_cpu_get_pc; | ||
584 | cc->gdb_read_register = sparc_cpu_gdb_read_register; | ||
585 | cc->gdb_write_register = sparc_cpu_gdb_write_register; | ||
586 | #ifndef CONFIG_USER_ONLY | ||
587 | diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c | ||
588 | index XXXXXXX..XXXXXXX 100644 | ||
589 | --- a/target/tricore/cpu.c | ||
590 | +++ b/target/tricore/cpu.c | ||
591 | @@ -XXX,XX +XXX,XX @@ static void tricore_cpu_set_pc(CPUState *cs, vaddr value) | ||
592 | env->PC = value & ~(target_ulong)1; | ||
593 | } | ||
594 | |||
595 | +static vaddr tricore_cpu_get_pc(CPUState *cs) | ||
596 | +{ | ||
597 | + TriCoreCPU *cpu = TRICORE_CPU(cs); | ||
598 | + CPUTriCoreState *env = &cpu->env; | ||
599 | + | ||
600 | + return env->PC; | ||
601 | +} | ||
602 | + | ||
603 | static void tricore_cpu_synchronize_from_tb(CPUState *cs, | ||
604 | const TranslationBlock *tb) | ||
605 | { | ||
606 | @@ -XXX,XX +XXX,XX @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) | ||
607 | |||
608 | cc->dump_state = tricore_cpu_dump_state; | ||
609 | cc->set_pc = tricore_cpu_set_pc; | ||
610 | + cc->get_pc = tricore_cpu_get_pc; | ||
611 | cc->sysemu_ops = &tricore_sysemu_ops; | ||
612 | cc->tcg_ops = &tricore_tcg_ops; | ||
613 | } | ||
614 | diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c | ||
615 | index XXXXXXX..XXXXXXX 100644 | ||
616 | --- a/target/xtensa/cpu.c | ||
617 | +++ b/target/xtensa/cpu.c | ||
618 | @@ -XXX,XX +XXX,XX @@ static void xtensa_cpu_set_pc(CPUState *cs, vaddr value) | ||
619 | cpu->env.pc = value; | ||
620 | } | ||
621 | |||
622 | +static vaddr xtensa_cpu_get_pc(CPUState *cs) | ||
623 | +{ | ||
624 | + XtensaCPU *cpu = XTENSA_CPU(cs); | ||
625 | + | ||
626 | + return cpu->env.pc; | ||
627 | +} | ||
628 | + | ||
629 | static bool xtensa_cpu_has_work(CPUState *cs) | ||
630 | { | ||
631 | #ifndef CONFIG_USER_ONLY | ||
632 | @@ -XXX,XX +XXX,XX @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) | ||
633 | cc->has_work = xtensa_cpu_has_work; | ||
634 | cc->dump_state = xtensa_cpu_dump_state; | ||
635 | cc->set_pc = xtensa_cpu_set_pc; | ||
636 | + cc->get_pc = xtensa_cpu_get_pc; | ||
637 | cc->gdb_read_register = xtensa_cpu_gdb_read_register; | ||
638 | cc->gdb_write_register = xtensa_cpu_gdb_write_register; | ||
639 | cc->gdb_stop_before_watchpoint = true; | ||
63 | -- | 640 | -- |
64 | 2.25.1 | 641 | 2.34.1 |
65 | 642 | ||
66 | 643 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Fix a typo in the encodeing of the cmle (zero) instruction. | ||
2 | 1 | ||
3 | Fixes: 14e4c1e2355 ("tcg/aarch64: Add vector operations") | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tcg/aarch64/tcg-target.c.inc | 2 +- | ||
7 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
8 | |||
9 | diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/tcg/aarch64/tcg-target.c.inc | ||
12 | +++ b/tcg/aarch64/tcg-target.c.inc | ||
13 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
14 | I3617_CMEQ0 = 0x0e209800, | ||
15 | I3617_CMLT0 = 0x0e20a800, | ||
16 | I3617_CMGE0 = 0x2e208800, | ||
17 | - I3617_CMLE0 = 0x2e20a800, | ||
18 | + I3617_CMLE0 = 0x2e209800, | ||
19 | I3617_NOT = 0x2e205800, | ||
20 | I3617_ABS = 0x0e20b800, | ||
21 | I3617_NEG = 0x2e20b800, | ||
22 | -- | ||
23 | 2.25.1 | ||
24 | |||
25 | diff view generated by jsdifflib |
1 | The primary motivation is to remove a dozen insns along | 1 | The availability of tb->pc will shortly be conditional. |
---|---|---|---|
2 | the fast-path in tb_lookup. As a byproduct, this allows | 2 | Introduce accessor functions to minimize ifdefs. |
3 | us to completely remove parallel_cpus. | ||
4 | 3 | ||
4 | Pass around a known pc to places like tcg_gen_code, | ||
5 | where the caller must already have the value. | ||
6 | |||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | --- | 9 | --- |
7 | accel/tcg/tcg-accel-ops.h | 1 + | 10 | accel/tcg/internal.h | 6 ++++ |
8 | include/exec/exec-all.h | 7 +------ | 11 | include/exec/exec-all.h | 6 ++++ |
9 | include/hw/core/cpu.h | 2 ++ | 12 | include/tcg/tcg.h | 2 +- |
10 | accel/tcg/cpu-exec.c | 3 --- | 13 | accel/tcg/cpu-exec.c | 46 ++++++++++++++----------- |
11 | accel/tcg/tcg-accel-ops-mttcg.c | 3 +-- | 14 | accel/tcg/translate-all.c | 37 +++++++++++--------- |
12 | accel/tcg/tcg-accel-ops-rr.c | 2 +- | 15 | target/arm/cpu.c | 4 +-- |
13 | accel/tcg/tcg-accel-ops.c | 8 ++++++++ | 16 | target/avr/cpu.c | 2 +- |
14 | accel/tcg/translate-all.c | 4 ---- | 17 | target/hexagon/cpu.c | 2 +- |
15 | linux-user/main.c | 1 + | 18 | target/hppa/cpu.c | 4 +-- |
16 | linux-user/sh4/signal.c | 8 +++++--- | 19 | target/i386/tcg/tcg-cpu.c | 2 +- |
17 | linux-user/syscall.c | 18 ++++++++++-------- | 20 | target/loongarch/cpu.c | 2 +- |
18 | 11 files changed, 30 insertions(+), 27 deletions(-) | 21 | target/microblaze/cpu.c | 2 +- |
22 | target/mips/tcg/exception.c | 2 +- | ||
23 | target/mips/tcg/sysemu/special_helper.c | 2 +- | ||
24 | target/openrisc/cpu.c | 2 +- | ||
25 | target/riscv/cpu.c | 4 +-- | ||
26 | target/rx/cpu.c | 2 +- | ||
27 | target/sh4/cpu.c | 4 +-- | ||
28 | target/sparc/cpu.c | 2 +- | ||
29 | target/tricore/cpu.c | 2 +- | ||
30 | tcg/tcg.c | 8 ++--- | ||
31 | 21 files changed, 82 insertions(+), 61 deletions(-) | ||
19 | 32 | ||
20 | diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h | 33 | diff --git a/accel/tcg/internal.h b/accel/tcg/internal.h |
21 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/accel/tcg/tcg-accel-ops.h | 35 | --- a/accel/tcg/internal.h |
23 | +++ b/accel/tcg/tcg-accel-ops.h | 36 | +++ b/accel/tcg/internal.h |
24 | @@ -XXX,XX +XXX,XX @@ | 37 | @@ -XXX,XX +XXX,XX @@ G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr); |
25 | void tcg_cpus_destroy(CPUState *cpu); | 38 | void page_init(void); |
26 | int tcg_cpus_exec(CPUState *cpu); | 39 | void tb_htable_init(void); |
27 | void tcg_handle_interrupt(CPUState *cpu, int mask); | 40 | |
28 | +void tcg_cpu_init_cflags(CPUState *cpu, bool parallel); | 41 | +/* Return the current PC from CPU, which may be cached in TB. */ |
29 | 42 | +static inline target_ulong log_pc(CPUState *cpu, const TranslationBlock *tb) | |
30 | #endif /* TCG_CPUS_H */ | 43 | +{ |
44 | + return tb_pc(tb); | ||
45 | +} | ||
46 | + | ||
47 | #endif /* ACCEL_TCG_INTERNAL_H */ | ||
31 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | 48 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h |
32 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/include/exec/exec-all.h | 50 | --- a/include/exec/exec-all.h |
34 | +++ b/include/exec/exec-all.h | 51 | +++ b/include/exec/exec-all.h |
35 | @@ -XXX,XX +XXX,XX @@ struct TranslationBlock { | 52 | @@ -XXX,XX +XXX,XX @@ struct TranslationBlock { |
36 | uintptr_t jmp_dest[2]; | 53 | uintptr_t jmp_dest[2]; |
37 | }; | 54 | }; |
38 | 55 | ||
39 | -extern bool parallel_cpus; | 56 | +/* Hide the read to avoid ifdefs for TARGET_TB_PCREL. */ |
40 | - | 57 | +static inline target_ulong tb_pc(const TranslationBlock *tb) |
58 | +{ | ||
59 | + return tb->pc; | ||
60 | +} | ||
61 | + | ||
41 | /* Hide the qatomic_read to make code a little easier on the eyes */ | 62 | /* Hide the qatomic_read to make code a little easier on the eyes */ |
42 | static inline uint32_t tb_cflags(const TranslationBlock *tb) | 63 | static inline uint32_t tb_cflags(const TranslationBlock *tb) |
43 | { | 64 | { |
44 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t tb_cflags(const TranslationBlock *tb) | 65 | diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h |
45 | /* current cflags for hashing/comparison */ | 66 | index XXXXXXX..XXXXXXX 100644 |
46 | static inline uint32_t curr_cflags(CPUState *cpu) | 67 | --- a/include/tcg/tcg.h |
47 | { | 68 | +++ b/include/tcg/tcg.h |
48 | - uint32_t cflags = deposit32(0, CF_CLUSTER_SHIFT, 8, cpu->cluster_index); | 69 | @@ -XXX,XX +XXX,XX @@ void tcg_register_thread(void); |
49 | - cflags |= parallel_cpus ? CF_PARALLEL : 0; | 70 | void tcg_prologue_init(TCGContext *s); |
50 | - cflags |= icount_enabled() ? CF_USE_ICOUNT : 0; | 71 | void tcg_func_start(TCGContext *s); |
51 | - return cflags; | 72 | |
52 | + return cpu->tcg_cflags; | 73 | -int tcg_gen_code(TCGContext *s, TranslationBlock *tb); |
53 | } | 74 | +int tcg_gen_code(TCGContext *s, TranslationBlock *tb, target_ulong pc_start); |
54 | 75 | ||
55 | /* TranslationBlock invalidate API */ | 76 | void tcg_set_frame(TCGContext *s, TCGReg reg, intptr_t start, intptr_t size); |
56 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h | 77 | |
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/include/hw/core/cpu.h | ||
59 | +++ b/include/hw/core/cpu.h | ||
60 | @@ -XXX,XX +XXX,XX @@ struct qemu_work_item; | ||
61 | * to a cluster this will be UNASSIGNED_CLUSTER_INDEX; otherwise it will | ||
62 | * be the same as the cluster-id property of the CPU object's TYPE_CPU_CLUSTER | ||
63 | * QOM parent. | ||
64 | + * @tcg_cflags: Pre-computed cflags for this cpu. | ||
65 | * @nr_cores: Number of cores within this CPU package. | ||
66 | * @nr_threads: Number of threads within this CPU. | ||
67 | * @running: #true if CPU is currently running (lockless). | ||
68 | @@ -XXX,XX +XXX,XX @@ struct CPUState { | ||
69 | /* TODO Move common fields from CPUArchState here. */ | ||
70 | int cpu_index; | ||
71 | int cluster_index; | ||
72 | + uint32_t tcg_cflags; | ||
73 | uint32_t halted; | ||
74 | uint32_t can_do_io; | ||
75 | int32_t exception_index; | ||
76 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | 78 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c |
77 | index XXXXXXX..XXXXXXX 100644 | 79 | index XXXXXXX..XXXXXXX 100644 |
78 | --- a/accel/tcg/cpu-exec.c | 80 | --- a/accel/tcg/cpu-exec.c |
79 | +++ b/accel/tcg/cpu-exec.c | 81 | +++ b/accel/tcg/cpu-exec.c |
80 | @@ -XXX,XX +XXX,XX @@ void cpu_exec_step_atomic(CPUState *cpu) | 82 | @@ -XXX,XX +XXX,XX @@ static bool tb_lookup_cmp(const void *p, const void *d) |
81 | mmap_unlock(); | 83 | const TranslationBlock *tb = p; |
84 | const struct tb_desc *desc = d; | ||
85 | |||
86 | - if (tb->pc == desc->pc && | ||
87 | + if (tb_pc(tb) == desc->pc && | ||
88 | tb->page_addr[0] == desc->page_addr0 && | ||
89 | tb->cs_base == desc->cs_base && | ||
90 | tb->flags == desc->flags && | ||
91 | @@ -XXX,XX +XXX,XX @@ static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc, | ||
92 | return tb; | ||
93 | } | ||
94 | |||
95 | -static inline void log_cpu_exec(target_ulong pc, CPUState *cpu, | ||
96 | - const TranslationBlock *tb) | ||
97 | +static void log_cpu_exec(target_ulong pc, CPUState *cpu, | ||
98 | + const TranslationBlock *tb) | ||
99 | { | ||
100 | - if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_CPU | CPU_LOG_EXEC)) | ||
101 | - && qemu_log_in_addr_range(pc)) { | ||
102 | - | ||
103 | + if (qemu_log_in_addr_range(pc)) { | ||
104 | qemu_log_mask(CPU_LOG_EXEC, | ||
105 | "Trace %d: %p [" TARGET_FMT_lx | ||
106 | "/" TARGET_FMT_lx "/%08x/%08x] %s\n", | ||
107 | @@ -XXX,XX +XXX,XX @@ const void *HELPER(lookup_tb_ptr)(CPUArchState *env) | ||
108 | return tcg_code_gen_epilogue; | ||
109 | } | ||
110 | |||
111 | - log_cpu_exec(pc, cpu, tb); | ||
112 | + if (qemu_loglevel_mask(CPU_LOG_TB_CPU | CPU_LOG_EXEC)) { | ||
113 | + log_cpu_exec(pc, cpu, tb); | ||
114 | + } | ||
115 | |||
116 | return tb->tc.ptr; | ||
117 | } | ||
118 | @@ -XXX,XX +XXX,XX @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit) | ||
119 | TranslationBlock *last_tb; | ||
120 | const void *tb_ptr = itb->tc.ptr; | ||
121 | |||
122 | - log_cpu_exec(itb->pc, cpu, itb); | ||
123 | + if (qemu_loglevel_mask(CPU_LOG_TB_CPU | CPU_LOG_EXEC)) { | ||
124 | + log_cpu_exec(log_pc(cpu, itb), cpu, itb); | ||
125 | + } | ||
126 | |||
127 | qemu_thread_jit_execute(); | ||
128 | ret = tcg_qemu_tb_exec(env, tb_ptr); | ||
129 | @@ -XXX,XX +XXX,XX @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit) | ||
130 | * of the start of the TB. | ||
131 | */ | ||
132 | CPUClass *cc = CPU_GET_CLASS(cpu); | ||
133 | - qemu_log_mask_and_addr(CPU_LOG_EXEC, last_tb->pc, | ||
134 | - "Stopped execution of TB chain before %p [" | ||
135 | - TARGET_FMT_lx "] %s\n", | ||
136 | - last_tb->tc.ptr, last_tb->pc, | ||
137 | - lookup_symbol(last_tb->pc)); | ||
138 | + | ||
139 | if (cc->tcg_ops->synchronize_from_tb) { | ||
140 | cc->tcg_ops->synchronize_from_tb(cpu, last_tb); | ||
141 | } else { | ||
142 | assert(cc->set_pc); | ||
143 | - cc->set_pc(cpu, last_tb->pc); | ||
144 | + cc->set_pc(cpu, tb_pc(last_tb)); | ||
145 | + } | ||
146 | + if (qemu_loglevel_mask(CPU_LOG_EXEC)) { | ||
147 | + target_ulong pc = log_pc(cpu, last_tb); | ||
148 | + if (qemu_log_in_addr_range(pc)) { | ||
149 | + qemu_log("Stopped execution of TB chain before %p [" | ||
150 | + TARGET_FMT_lx "] %s\n", | ||
151 | + last_tb->tc.ptr, pc, lookup_symbol(pc)); | ||
152 | + } | ||
82 | } | 153 | } |
83 | 154 | } | |
84 | - /* Since we got here, we know that parallel_cpus must be true. */ | 155 | |
85 | - parallel_cpus = false; | 156 | @@ -XXX,XX +XXX,XX @@ static inline void tb_add_jump(TranslationBlock *tb, int n, |
86 | cpu_exec_enter(cpu); | 157 | |
87 | /* execute the generated code */ | 158 | qemu_spin_unlock(&tb_next->jmp_lock); |
88 | trace_exec_tb(tb, pc); | 159 | |
89 | @@ -XXX,XX +XXX,XX @@ void cpu_exec_step_atomic(CPUState *cpu) | 160 | - qemu_log_mask_and_addr(CPU_LOG_EXEC, tb->pc, |
90 | * the execution. | 161 | - "Linking TBs %p [" TARGET_FMT_lx |
91 | */ | 162 | - "] index %d -> %p [" TARGET_FMT_lx "]\n", |
92 | g_assert(cpu_in_exclusive_context(cpu)); | 163 | - tb->tc.ptr, tb->pc, n, |
93 | - parallel_cpus = true; | 164 | - tb_next->tc.ptr, tb_next->pc); |
94 | cpu->running = false; | 165 | + qemu_log_mask(CPU_LOG_EXEC, "Linking TBs %p index %d -> %p\n", |
95 | end_exclusive(); | 166 | + tb->tc.ptr, n, tb_next->tc.ptr); |
96 | } | 167 | return; |
97 | diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c | 168 | |
98 | index XXXXXXX..XXXXXXX 100644 | 169 | out_unlock_next: |
99 | --- a/accel/tcg/tcg-accel-ops-mttcg.c | 170 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_interrupt(CPUState *cpu, |
100 | +++ b/accel/tcg/tcg-accel-ops-mttcg.c | 171 | } |
101 | @@ -XXX,XX +XXX,XX @@ void mttcg_start_vcpu_thread(CPUState *cpu) | 172 | |
102 | char thread_name[VCPU_THREAD_NAME_SIZE]; | 173 | static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, |
103 | 174 | + target_ulong pc, | |
104 | g_assert(tcg_enabled()); | 175 | TranslationBlock **last_tb, int *tb_exit) |
105 | - | 176 | { |
106 | - parallel_cpus = (current_machine->smp.max_cpus > 1); | 177 | int32_t insns_left; |
107 | + tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1); | 178 | |
108 | 179 | - trace_exec_tb(tb, tb->pc); | |
109 | cpu->thread = g_malloc0(sizeof(QemuThread)); | 180 | + trace_exec_tb(tb, pc); |
110 | cpu->halt_cond = g_malloc0(sizeof(QemuCond)); | 181 | tb = cpu_tb_exec(cpu, tb, tb_exit); |
111 | diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c | 182 | if (*tb_exit != TB_EXIT_REQUESTED) { |
112 | index XXXXXXX..XXXXXXX 100644 | 183 | *last_tb = tb; |
113 | --- a/accel/tcg/tcg-accel-ops-rr.c | 184 | @@ -XXX,XX +XXX,XX @@ int cpu_exec(CPUState *cpu) |
114 | +++ b/accel/tcg/tcg-accel-ops-rr.c | 185 | tb_add_jump(last_tb, tb_exit, tb); |
115 | @@ -XXX,XX +XXX,XX @@ void rr_start_vcpu_thread(CPUState *cpu) | 186 | } |
116 | static QemuThread *single_tcg_cpu_thread; | 187 | |
117 | 188 | - cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit); | |
118 | g_assert(tcg_enabled()); | 189 | + cpu_loop_exec_tb(cpu, tb, pc, &last_tb, &tb_exit); |
119 | - parallel_cpus = false; | 190 | |
120 | + tcg_cpu_init_cflags(cpu, false); | 191 | /* Try to align the host and virtual clocks |
121 | 192 | if the guest is in advance */ | |
122 | if (!single_tcg_cpu_thread) { | ||
123 | cpu->thread = g_malloc0(sizeof(QemuThread)); | ||
124 | diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c | ||
125 | index XXXXXXX..XXXXXXX 100644 | ||
126 | --- a/accel/tcg/tcg-accel-ops.c | ||
127 | +++ b/accel/tcg/tcg-accel-ops.c | ||
128 | @@ -XXX,XX +XXX,XX @@ | ||
129 | |||
130 | /* common functionality among all TCG variants */ | ||
131 | |||
132 | +void tcg_cpu_init_cflags(CPUState *cpu, bool parallel) | ||
133 | +{ | ||
134 | + uint32_t cflags = cpu->cluster_index << CF_CLUSTER_SHIFT; | ||
135 | + cflags |= parallel ? CF_PARALLEL : 0; | ||
136 | + cflags |= icount_enabled() ? CF_USE_ICOUNT : 0; | ||
137 | + cpu->tcg_cflags = cflags; | ||
138 | +} | ||
139 | + | ||
140 | void tcg_cpus_destroy(CPUState *cpu) | ||
141 | { | ||
142 | cpu_thread_signal_destroyed(cpu); | ||
143 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | 193 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c |
144 | index XXXXXXX..XXXXXXX 100644 | 194 | index XXXXXXX..XXXXXXX 100644 |
145 | --- a/accel/tcg/translate-all.c | 195 | --- a/accel/tcg/translate-all.c |
146 | +++ b/accel/tcg/translate-all.c | 196 | +++ b/accel/tcg/translate-all.c |
147 | @@ -XXX,XX +XXX,XX @@ static void *l1_map[V_L1_MAX_SIZE]; | 197 | @@ -XXX,XX +XXX,XX @@ static int encode_search(TranslationBlock *tb, uint8_t *block) |
148 | TCGContext tcg_init_ctx; | 198 | |
149 | __thread TCGContext *tcg_ctx; | 199 | for (j = 0; j < TARGET_INSN_START_WORDS; ++j) { |
150 | TBContext tb_ctx; | 200 | if (i == 0) { |
151 | -bool parallel_cpus; | 201 | - prev = (j == 0 ? tb->pc : 0); |
152 | 202 | + prev = (j == 0 ? tb_pc(tb) : 0); | |
153 | static void page_table_config_init(void) | 203 | } else { |
154 | { | 204 | prev = tcg_ctx->gen_insn_data[i - 1][j]; |
205 | } | ||
206 | @@ -XXX,XX +XXX,XX @@ static int encode_search(TranslationBlock *tb, uint8_t *block) | ||
207 | static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, | ||
208 | uintptr_t searched_pc, bool reset_icount) | ||
209 | { | ||
210 | - target_ulong data[TARGET_INSN_START_WORDS] = { tb->pc }; | ||
211 | + target_ulong data[TARGET_INSN_START_WORDS] = { tb_pc(tb) }; | ||
212 | uintptr_t host_pc = (uintptr_t)tb->tc.ptr; | ||
213 | CPUArchState *env = cpu->env_ptr; | ||
214 | const uint8_t *p = tb->tc.ptr + tb->tc.size; | ||
215 | @@ -XXX,XX +XXX,XX @@ static bool tb_cmp(const void *ap, const void *bp) | ||
216 | const TranslationBlock *a = ap; | ||
217 | const TranslationBlock *b = bp; | ||
218 | |||
219 | - return a->pc == b->pc && | ||
220 | + return tb_pc(a) == tb_pc(b) && | ||
221 | a->cs_base == b->cs_base && | ||
222 | a->flags == b->flags && | ||
223 | (tb_cflags(a) & ~CF_INVALID) == (tb_cflags(b) & ~CF_INVALID) && | ||
224 | @@ -XXX,XX +XXX,XX @@ static void do_tb_invalidate_check(void *p, uint32_t hash, void *userp) | ||
225 | TranslationBlock *tb = p; | ||
226 | target_ulong addr = *(target_ulong *)userp; | ||
227 | |||
228 | - if (!(addr + TARGET_PAGE_SIZE <= tb->pc || addr >= tb->pc + tb->size)) { | ||
229 | + if (!(addr + TARGET_PAGE_SIZE <= tb_pc(tb) || | ||
230 | + addr >= tb_pc(tb) + tb->size)) { | ||
231 | printf("ERROR invalidate: address=" TARGET_FMT_lx | ||
232 | - " PC=%08lx size=%04x\n", addr, (long)tb->pc, tb->size); | ||
233 | + " PC=%08lx size=%04x\n", addr, (long)tb_pc(tb), tb->size); | ||
234 | } | ||
235 | } | ||
236 | |||
237 | @@ -XXX,XX +XXX,XX @@ static void do_tb_page_check(void *p, uint32_t hash, void *userp) | ||
238 | TranslationBlock *tb = p; | ||
239 | int flags1, flags2; | ||
240 | |||
241 | - flags1 = page_get_flags(tb->pc); | ||
242 | - flags2 = page_get_flags(tb->pc + tb->size - 1); | ||
243 | + flags1 = page_get_flags(tb_pc(tb)); | ||
244 | + flags2 = page_get_flags(tb_pc(tb) + tb->size - 1); | ||
245 | if ((flags1 & PAGE_WRITE) || (flags2 & PAGE_WRITE)) { | ||
246 | printf("ERROR page flags: PC=%08lx size=%04x f1=%x f2=%x\n", | ||
247 | - (long)tb->pc, tb->size, flags1, flags2); | ||
248 | + (long)tb_pc(tb), tb->size, flags1, flags2); | ||
249 | } | ||
250 | } | ||
251 | |||
252 | @@ -XXX,XX +XXX,XX @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) | ||
253 | |||
254 | /* remove the TB from the hash list */ | ||
255 | phys_pc = tb->page_addr[0]; | ||
256 | - h = tb_hash_func(phys_pc, tb->pc, tb->flags, orig_cflags, | ||
257 | + h = tb_hash_func(phys_pc, tb_pc(tb), tb->flags, orig_cflags, | ||
258 | tb->trace_vcpu_dstate); | ||
259 | if (!qht_remove(&tb_ctx.htable, tb, h)) { | ||
260 | return; | ||
261 | @@ -XXX,XX +XXX,XX @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, | ||
262 | } | ||
263 | |||
264 | /* add in the hash table */ | ||
265 | - h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags, | ||
266 | + h = tb_hash_func(phys_pc, tb_pc(tb), tb->flags, tb->cflags, | ||
267 | tb->trace_vcpu_dstate); | ||
268 | qht_insert(&tb_ctx.htable, tb, h, &existing_tb); | ||
269 | |||
155 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, | 270 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, |
156 | cflags = (cflags & ~CF_COUNT_MASK) | 1; | 271 | tcg_ctx->cpu = NULL; |
157 | } | 272 | max_insns = tb->icount; |
158 | 273 | ||
159 | - cflags &= ~CF_CLUSTER_MASK; | 274 | - trace_translate_block(tb, tb->pc, tb->tc.ptr); |
160 | - cflags |= cpu->cluster_index << CF_CLUSTER_SHIFT; | 275 | + trace_translate_block(tb, pc, tb->tc.ptr); |
161 | - | 276 | |
162 | max_insns = cflags & CF_COUNT_MASK; | 277 | /* generate machine code */ |
163 | if (max_insns == 0) { | 278 | tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID; |
164 | max_insns = CF_COUNT_MASK; | 279 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, |
165 | diff --git a/linux-user/main.c b/linux-user/main.c | 280 | ti = profile_getclock(); |
166 | index XXXXXXX..XXXXXXX 100644 | 281 | #endif |
167 | --- a/linux-user/main.c | 282 | |
168 | +++ b/linux-user/main.c | 283 | - gen_code_size = tcg_gen_code(tcg_ctx, tb); |
169 | @@ -XXX,XX +XXX,XX @@ CPUArchState *cpu_copy(CPUArchState *env) | 284 | + gen_code_size = tcg_gen_code(tcg_ctx, tb, pc); |
170 | /* Reset non arch specific state */ | 285 | if (unlikely(gen_code_size < 0)) { |
171 | cpu_reset(new_cpu); | 286 | error_return: |
172 | 287 | switch (gen_code_size) { | |
173 | + new_cpu->tcg_cflags = cpu->tcg_cflags; | 288 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, |
174 | memcpy(new_env, env, sizeof(CPUArchState)); | 289 | |
175 | 290 | #ifdef DEBUG_DISAS | |
176 | /* Clone all break/watchpoints. | 291 | if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) && |
177 | diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c | 292 | - qemu_log_in_addr_range(tb->pc)) { |
178 | index XXXXXXX..XXXXXXX 100644 | 293 | + qemu_log_in_addr_range(pc)) { |
179 | --- a/linux-user/sh4/signal.c | 294 | FILE *logfile = qemu_log_trylock(); |
180 | +++ b/linux-user/sh4/signal.c | 295 | if (logfile) { |
181 | @@ -XXX,XX +XXX,XX @@ static abi_ulong get_sigframe(struct target_sigaction *ka, | 296 | int code_size, data_size; |
182 | return (sp - frame_size) & -8ul; | 297 | @@ -XXX,XX +XXX,XX @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) |
183 | } | 298 | */ |
184 | 299 | cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | CF_LAST_IO | n; | |
185 | -/* Notice when we're in the middle of a gUSA region and reset. | 300 | |
186 | - Note that this will only occur for !parallel_cpus, as we will | 301 | - qemu_log_mask_and_addr(CPU_LOG_EXEC, tb->pc, |
187 | - translate such sequences differently in a parallel context. */ | 302 | - "cpu_io_recompile: rewound execution of TB to " |
188 | +/* | 303 | - TARGET_FMT_lx "\n", tb->pc); |
189 | + * Notice when we're in the middle of a gUSA region and reset. | 304 | + if (qemu_loglevel_mask(CPU_LOG_EXEC)) { |
190 | + * Note that this will only occur when #CF_PARALLEL is unset, as we | 305 | + target_ulong pc = log_pc(cpu, tb); |
191 | + * will translate such sequences differently in a parallel context. | 306 | + if (qemu_log_in_addr_range(pc)) { |
192 | + */ | 307 | + qemu_log("cpu_io_recompile: rewound execution of TB to " |
193 | static void unwind_gusa(CPUSH4State *regs) | 308 | + TARGET_FMT_lx "\n", pc); |
194 | { | ||
195 | /* If the stack pointer is sufficiently negative, and we haven't | ||
196 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c | ||
197 | index XXXXXXX..XXXXXXX 100644 | ||
198 | --- a/linux-user/syscall.c | ||
199 | +++ b/linux-user/syscall.c | ||
200 | @@ -XXX,XX +XXX,XX @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, | ||
201 | /* Grab a mutex so that thread setup appears atomic. */ | ||
202 | pthread_mutex_lock(&clone_lock); | ||
203 | |||
204 | + /* | ||
205 | + * If this is our first additional thread, we need to ensure we | ||
206 | + * generate code for parallel execution and flush old translations. | ||
207 | + * Do this now so that the copy gets CF_PARALLEL too. | ||
208 | + */ | ||
209 | + if (!(cpu->tcg_cflags & CF_PARALLEL)) { | ||
210 | + cpu->tcg_cflags |= CF_PARALLEL; | ||
211 | + tb_flush(cpu); | ||
212 | + } | 309 | + } |
213 | + | 310 | + } |
214 | /* we create a new CPU instance. */ | 311 | |
215 | new_env = cpu_copy(env); | 312 | cpu_loop_exit_noexc(cpu); |
216 | /* Init regs that differ from the parent. */ | 313 | } |
217 | @@ -XXX,XX +XXX,XX @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, | 314 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
218 | sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask); | 315 | index XXXXXXX..XXXXXXX 100644 |
219 | cpu->random_seed = qemu_guest_random_seed_thread_part1(); | 316 | --- a/target/arm/cpu.c |
220 | 317 | +++ b/target/arm/cpu.c | |
221 | - /* If this is our first additional thread, we need to ensure we | 318 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_synchronize_from_tb(CPUState *cs, |
222 | - * generate code for parallel execution and flush old translations. | 319 | * never possible for an AArch64 TB to chain to an AArch32 TB. |
223 | - */ | 320 | */ |
224 | - if (!parallel_cpus) { | 321 | if (is_a64(env)) { |
225 | - parallel_cpus = true; | 322 | - env->pc = tb->pc; |
226 | - tb_flush(cpu); | 323 | + env->pc = tb_pc(tb); |
227 | - } | 324 | } else { |
228 | - | 325 | - env->regs[15] = tb->pc; |
229 | ret = pthread_create(&info.thread, &attr, clone_func, &info); | 326 | + env->regs[15] = tb_pc(tb); |
230 | /* TODO: Free new CPU state if thread creation failed. */ | 327 | } |
231 | 328 | } | |
329 | #endif /* CONFIG_TCG */ | ||
330 | diff --git a/target/avr/cpu.c b/target/avr/cpu.c | ||
331 | index XXXXXXX..XXXXXXX 100644 | ||
332 | --- a/target/avr/cpu.c | ||
333 | +++ b/target/avr/cpu.c | ||
334 | @@ -XXX,XX +XXX,XX @@ static void avr_cpu_synchronize_from_tb(CPUState *cs, | ||
335 | AVRCPU *cpu = AVR_CPU(cs); | ||
336 | CPUAVRState *env = &cpu->env; | ||
337 | |||
338 | - env->pc_w = tb->pc / 2; /* internally PC points to words */ | ||
339 | + env->pc_w = tb_pc(tb) / 2; /* internally PC points to words */ | ||
340 | } | ||
341 | |||
342 | static void avr_cpu_reset(DeviceState *ds) | ||
343 | diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c | ||
344 | index XXXXXXX..XXXXXXX 100644 | ||
345 | --- a/target/hexagon/cpu.c | ||
346 | +++ b/target/hexagon/cpu.c | ||
347 | @@ -XXX,XX +XXX,XX @@ static void hexagon_cpu_synchronize_from_tb(CPUState *cs, | ||
348 | { | ||
349 | HexagonCPU *cpu = HEXAGON_CPU(cs); | ||
350 | CPUHexagonState *env = &cpu->env; | ||
351 | - env->gpr[HEX_REG_PC] = tb->pc; | ||
352 | + env->gpr[HEX_REG_PC] = tb_pc(tb); | ||
353 | } | ||
354 | |||
355 | static bool hexagon_cpu_has_work(CPUState *cs) | ||
356 | diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c | ||
357 | index XXXXXXX..XXXXXXX 100644 | ||
358 | --- a/target/hppa/cpu.c | ||
359 | +++ b/target/hppa/cpu.c | ||
360 | @@ -XXX,XX +XXX,XX @@ static void hppa_cpu_synchronize_from_tb(CPUState *cs, | ||
361 | HPPACPU *cpu = HPPA_CPU(cs); | ||
362 | |||
363 | #ifdef CONFIG_USER_ONLY | ||
364 | - cpu->env.iaoq_f = tb->pc; | ||
365 | + cpu->env.iaoq_f = tb_pc(tb); | ||
366 | cpu->env.iaoq_b = tb->cs_base; | ||
367 | #else | ||
368 | /* Recover the IAOQ values from the GVA + PRIV. */ | ||
369 | @@ -XXX,XX +XXX,XX @@ static void hppa_cpu_synchronize_from_tb(CPUState *cs, | ||
370 | int32_t diff = cs_base; | ||
371 | |||
372 | cpu->env.iasq_f = iasq_f; | ||
373 | - cpu->env.iaoq_f = (tb->pc & ~iasq_f) + priv; | ||
374 | + cpu->env.iaoq_f = (tb_pc(tb) & ~iasq_f) + priv; | ||
375 | if (diff) { | ||
376 | cpu->env.iaoq_b = cpu->env.iaoq_f + diff; | ||
377 | } | ||
378 | diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c | ||
379 | index XXXXXXX..XXXXXXX 100644 | ||
380 | --- a/target/i386/tcg/tcg-cpu.c | ||
381 | +++ b/target/i386/tcg/tcg-cpu.c | ||
382 | @@ -XXX,XX +XXX,XX @@ static void x86_cpu_synchronize_from_tb(CPUState *cs, | ||
383 | { | ||
384 | X86CPU *cpu = X86_CPU(cs); | ||
385 | |||
386 | - cpu->env.eip = tb->pc - tb->cs_base; | ||
387 | + cpu->env.eip = tb_pc(tb) - tb->cs_base; | ||
388 | } | ||
389 | |||
390 | #ifndef CONFIG_USER_ONLY | ||
391 | diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c | ||
392 | index XXXXXXX..XXXXXXX 100644 | ||
393 | --- a/target/loongarch/cpu.c | ||
394 | +++ b/target/loongarch/cpu.c | ||
395 | @@ -XXX,XX +XXX,XX @@ static void loongarch_cpu_synchronize_from_tb(CPUState *cs, | ||
396 | LoongArchCPU *cpu = LOONGARCH_CPU(cs); | ||
397 | CPULoongArchState *env = &cpu->env; | ||
398 | |||
399 | - env->pc = tb->pc; | ||
400 | + env->pc = tb_pc(tb); | ||
401 | } | ||
402 | #endif /* CONFIG_TCG */ | ||
403 | |||
404 | diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c | ||
405 | index XXXXXXX..XXXXXXX 100644 | ||
406 | --- a/target/microblaze/cpu.c | ||
407 | +++ b/target/microblaze/cpu.c | ||
408 | @@ -XXX,XX +XXX,XX @@ static void mb_cpu_synchronize_from_tb(CPUState *cs, | ||
409 | { | ||
410 | MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); | ||
411 | |||
412 | - cpu->env.pc = tb->pc; | ||
413 | + cpu->env.pc = tb_pc(tb); | ||
414 | cpu->env.iflags = tb->flags & IFLAGS_TB_MASK; | ||
415 | } | ||
416 | |||
417 | diff --git a/target/mips/tcg/exception.c b/target/mips/tcg/exception.c | ||
418 | index XXXXXXX..XXXXXXX 100644 | ||
419 | --- a/target/mips/tcg/exception.c | ||
420 | +++ b/target/mips/tcg/exception.c | ||
421 | @@ -XXX,XX +XXX,XX @@ void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) | ||
422 | MIPSCPU *cpu = MIPS_CPU(cs); | ||
423 | CPUMIPSState *env = &cpu->env; | ||
424 | |||
425 | - env->active_tc.PC = tb->pc; | ||
426 | + env->active_tc.PC = tb_pc(tb); | ||
427 | env->hflags &= ~MIPS_HFLAG_BMASK; | ||
428 | env->hflags |= tb->flags & MIPS_HFLAG_BMASK; | ||
429 | } | ||
430 | diff --git a/target/mips/tcg/sysemu/special_helper.c b/target/mips/tcg/sysemu/special_helper.c | ||
431 | index XXXXXXX..XXXXXXX 100644 | ||
432 | --- a/target/mips/tcg/sysemu/special_helper.c | ||
433 | +++ b/target/mips/tcg/sysemu/special_helper.c | ||
434 | @@ -XXX,XX +XXX,XX @@ bool mips_io_recompile_replay_branch(CPUState *cs, const TranslationBlock *tb) | ||
435 | CPUMIPSState *env = &cpu->env; | ||
436 | |||
437 | if ((env->hflags & MIPS_HFLAG_BMASK) != 0 | ||
438 | - && env->active_tc.PC != tb->pc) { | ||
439 | + && env->active_tc.PC != tb_pc(tb)) { | ||
440 | env->active_tc.PC -= (env->hflags & MIPS_HFLAG_B16 ? 2 : 4); | ||
441 | env->hflags &= ~MIPS_HFLAG_BMASK; | ||
442 | return true; | ||
443 | diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c | ||
444 | index XXXXXXX..XXXXXXX 100644 | ||
445 | --- a/target/openrisc/cpu.c | ||
446 | +++ b/target/openrisc/cpu.c | ||
447 | @@ -XXX,XX +XXX,XX @@ static void openrisc_cpu_synchronize_from_tb(CPUState *cs, | ||
448 | { | ||
449 | OpenRISCCPU *cpu = OPENRISC_CPU(cs); | ||
450 | |||
451 | - cpu->env.pc = tb->pc; | ||
452 | + cpu->env.pc = tb_pc(tb); | ||
453 | } | ||
454 | |||
455 | |||
456 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
457 | index XXXXXXX..XXXXXXX 100644 | ||
458 | --- a/target/riscv/cpu.c | ||
459 | +++ b/target/riscv/cpu.c | ||
460 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_synchronize_from_tb(CPUState *cs, | ||
461 | RISCVMXL xl = FIELD_EX32(tb->flags, TB_FLAGS, XL); | ||
462 | |||
463 | if (xl == MXL_RV32) { | ||
464 | - env->pc = (int32_t)tb->pc; | ||
465 | + env->pc = (int32_t)tb_pc(tb); | ||
466 | } else { | ||
467 | - env->pc = tb->pc; | ||
468 | + env->pc = tb_pc(tb); | ||
469 | } | ||
470 | } | ||
471 | |||
472 | diff --git a/target/rx/cpu.c b/target/rx/cpu.c | ||
473 | index XXXXXXX..XXXXXXX 100644 | ||
474 | --- a/target/rx/cpu.c | ||
475 | +++ b/target/rx/cpu.c | ||
476 | @@ -XXX,XX +XXX,XX @@ static void rx_cpu_synchronize_from_tb(CPUState *cs, | ||
477 | { | ||
478 | RXCPU *cpu = RX_CPU(cs); | ||
479 | |||
480 | - cpu->env.pc = tb->pc; | ||
481 | + cpu->env.pc = tb_pc(tb); | ||
482 | } | ||
483 | |||
484 | static bool rx_cpu_has_work(CPUState *cs) | ||
485 | diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c | ||
486 | index XXXXXXX..XXXXXXX 100644 | ||
487 | --- a/target/sh4/cpu.c | ||
488 | +++ b/target/sh4/cpu.c | ||
489 | @@ -XXX,XX +XXX,XX @@ static void superh_cpu_synchronize_from_tb(CPUState *cs, | ||
490 | { | ||
491 | SuperHCPU *cpu = SUPERH_CPU(cs); | ||
492 | |||
493 | - cpu->env.pc = tb->pc; | ||
494 | + cpu->env.pc = tb_pc(tb); | ||
495 | cpu->env.flags = tb->flags & TB_FLAG_ENVFLAGS_MASK; | ||
496 | } | ||
497 | |||
498 | @@ -XXX,XX +XXX,XX @@ static bool superh_io_recompile_replay_branch(CPUState *cs, | ||
499 | CPUSH4State *env = &cpu->env; | ||
500 | |||
501 | if ((env->flags & ((DELAY_SLOT | DELAY_SLOT_CONDITIONAL))) != 0 | ||
502 | - && env->pc != tb->pc) { | ||
503 | + && env->pc != tb_pc(tb)) { | ||
504 | env->pc -= 2; | ||
505 | env->flags &= ~(DELAY_SLOT | DELAY_SLOT_CONDITIONAL); | ||
506 | return true; | ||
507 | diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c | ||
508 | index XXXXXXX..XXXXXXX 100644 | ||
509 | --- a/target/sparc/cpu.c | ||
510 | +++ b/target/sparc/cpu.c | ||
511 | @@ -XXX,XX +XXX,XX @@ static void sparc_cpu_synchronize_from_tb(CPUState *cs, | ||
512 | { | ||
513 | SPARCCPU *cpu = SPARC_CPU(cs); | ||
514 | |||
515 | - cpu->env.pc = tb->pc; | ||
516 | + cpu->env.pc = tb_pc(tb); | ||
517 | cpu->env.npc = tb->cs_base; | ||
518 | } | ||
519 | |||
520 | diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c | ||
521 | index XXXXXXX..XXXXXXX 100644 | ||
522 | --- a/target/tricore/cpu.c | ||
523 | +++ b/target/tricore/cpu.c | ||
524 | @@ -XXX,XX +XXX,XX @@ static void tricore_cpu_synchronize_from_tb(CPUState *cs, | ||
525 | TriCoreCPU *cpu = TRICORE_CPU(cs); | ||
526 | CPUTriCoreState *env = &cpu->env; | ||
527 | |||
528 | - env->PC = tb->pc; | ||
529 | + env->PC = tb_pc(tb); | ||
530 | } | ||
531 | |||
532 | static void tricore_cpu_reset(DeviceState *dev) | ||
533 | diff --git a/tcg/tcg.c b/tcg/tcg.c | ||
534 | index XXXXXXX..XXXXXXX 100644 | ||
535 | --- a/tcg/tcg.c | ||
536 | +++ b/tcg/tcg.c | ||
537 | @@ -XXX,XX +XXX,XX @@ int64_t tcg_cpu_exec_time(void) | ||
538 | #endif | ||
539 | |||
540 | |||
541 | -int tcg_gen_code(TCGContext *s, TranslationBlock *tb) | ||
542 | +int tcg_gen_code(TCGContext *s, TranslationBlock *tb, target_ulong pc_start) | ||
543 | { | ||
544 | #ifdef CONFIG_PROFILER | ||
545 | TCGProfile *prof = &s->prof; | ||
546 | @@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) | ||
547 | |||
548 | #ifdef DEBUG_DISAS | ||
549 | if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP) | ||
550 | - && qemu_log_in_addr_range(tb->pc))) { | ||
551 | + && qemu_log_in_addr_range(pc_start))) { | ||
552 | FILE *logfile = qemu_log_trylock(); | ||
553 | if (logfile) { | ||
554 | fprintf(logfile, "OP:\n"); | ||
555 | @@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) | ||
556 | if (s->nb_indirects > 0) { | ||
557 | #ifdef DEBUG_DISAS | ||
558 | if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND) | ||
559 | - && qemu_log_in_addr_range(tb->pc))) { | ||
560 | + && qemu_log_in_addr_range(pc_start))) { | ||
561 | FILE *logfile = qemu_log_trylock(); | ||
562 | if (logfile) { | ||
563 | fprintf(logfile, "OP before indirect lowering:\n"); | ||
564 | @@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) | ||
565 | |||
566 | #ifdef DEBUG_DISAS | ||
567 | if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT) | ||
568 | - && qemu_log_in_addr_range(tb->pc))) { | ||
569 | + && qemu_log_in_addr_range(pc_start))) { | ||
570 | FILE *logfile = qemu_log_trylock(); | ||
571 | if (logfile) { | ||
572 | fprintf(logfile, "OP after optimization and liveness analysis:\n"); | ||
232 | -- | 573 | -- |
233 | 2.25.1 | 574 | 2.34.1 |
234 | 575 | ||
235 | 576 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | Prepare for targets to be able to produce TBs that can |
---|---|---|---|
2 | run in more than one virtual context. | ||
2 | 3 | ||
3 | We don't really deal in cf_mask most of the time. The one time it's | 4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
4 | relevant is when we want to remove an invalidated TB from the QHT | ||
5 | lookup. Everywhere else we should be looking up things without | ||
6 | CF_INVALID set. | ||
7 | |||
8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Message-Id: <20210224165811.11567-4-alex.bennee@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | --- | 6 | --- |
12 | include/exec/exec-all.h | 4 +--- | 7 | accel/tcg/internal.h | 4 +++ |
13 | include/exec/tb-lookup.h | 9 ++++++--- | 8 | accel/tcg/tb-jmp-cache.h | 41 +++++++++++++++++++++++++ |
14 | accel/tcg/cpu-exec.c | 16 ++++++++-------- | 9 | include/exec/cpu-defs.h | 3 ++ |
15 | accel/tcg/tcg-runtime.c | 2 +- | 10 | include/exec/exec-all.h | 32 ++++++++++++++++++-- |
16 | accel/tcg/translate-all.c | 8 +++++--- | 11 | accel/tcg/cpu-exec.c | 16 ++++++---- |
17 | 5 files changed, 21 insertions(+), 18 deletions(-) | 12 | accel/tcg/translate-all.c | 64 ++++++++++++++++++++++++++------------- |
13 | 6 files changed, 131 insertions(+), 29 deletions(-) | ||
18 | 14 | ||
15 | diff --git a/accel/tcg/internal.h b/accel/tcg/internal.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/accel/tcg/internal.h | ||
18 | +++ b/accel/tcg/internal.h | ||
19 | @@ -XXX,XX +XXX,XX @@ void tb_htable_init(void); | ||
20 | /* Return the current PC from CPU, which may be cached in TB. */ | ||
21 | static inline target_ulong log_pc(CPUState *cpu, const TranslationBlock *tb) | ||
22 | { | ||
23 | +#if TARGET_TB_PCREL | ||
24 | + return cpu->cc->get_pc(cpu); | ||
25 | +#else | ||
26 | return tb_pc(tb); | ||
27 | +#endif | ||
28 | } | ||
29 | |||
30 | #endif /* ACCEL_TCG_INTERNAL_H */ | ||
31 | diff --git a/accel/tcg/tb-jmp-cache.h b/accel/tcg/tb-jmp-cache.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/accel/tcg/tb-jmp-cache.h | ||
34 | +++ b/accel/tcg/tb-jmp-cache.h | ||
35 | @@ -XXX,XX +XXX,XX @@ | ||
36 | |||
37 | /* | ||
38 | * Accessed in parallel; all accesses to 'tb' must be atomic. | ||
39 | + * For TARGET_TB_PCREL, accesses to 'pc' must be protected by | ||
40 | + * a load_acquire/store_release to 'tb'. | ||
41 | */ | ||
42 | struct CPUJumpCache { | ||
43 | struct { | ||
44 | TranslationBlock *tb; | ||
45 | +#if TARGET_TB_PCREL | ||
46 | + target_ulong pc; | ||
47 | +#endif | ||
48 | } array[TB_JMP_CACHE_SIZE]; | ||
49 | }; | ||
50 | |||
51 | +static inline TranslationBlock * | ||
52 | +tb_jmp_cache_get_tb(CPUJumpCache *jc, uint32_t hash) | ||
53 | +{ | ||
54 | +#if TARGET_TB_PCREL | ||
55 | + /* Use acquire to ensure current load of pc from jc. */ | ||
56 | + return qatomic_load_acquire(&jc->array[hash].tb); | ||
57 | +#else | ||
58 | + /* Use rcu_read to ensure current load of pc from *tb. */ | ||
59 | + return qatomic_rcu_read(&jc->array[hash].tb); | ||
60 | +#endif | ||
61 | +} | ||
62 | + | ||
63 | +static inline target_ulong | ||
64 | +tb_jmp_cache_get_pc(CPUJumpCache *jc, uint32_t hash, TranslationBlock *tb) | ||
65 | +{ | ||
66 | +#if TARGET_TB_PCREL | ||
67 | + return jc->array[hash].pc; | ||
68 | +#else | ||
69 | + return tb_pc(tb); | ||
70 | +#endif | ||
71 | +} | ||
72 | + | ||
73 | +static inline void | ||
74 | +tb_jmp_cache_set(CPUJumpCache *jc, uint32_t hash, | ||
75 | + TranslationBlock *tb, target_ulong pc) | ||
76 | +{ | ||
77 | +#if TARGET_TB_PCREL | ||
78 | + jc->array[hash].pc = pc; | ||
79 | + /* Use store_release on tb to ensure pc is written first. */ | ||
80 | + qatomic_store_release(&jc->array[hash].tb, tb); | ||
81 | +#else | ||
82 | + /* Use the pc value already stored in tb->pc. */ | ||
83 | + qatomic_set(&jc->array[hash].tb, tb); | ||
84 | +#endif | ||
85 | +} | ||
86 | + | ||
87 | #endif /* ACCEL_TCG_TB_JMP_CACHE_H */ | ||
88 | diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/include/exec/cpu-defs.h | ||
91 | +++ b/include/exec/cpu-defs.h | ||
92 | @@ -XXX,XX +XXX,XX @@ | ||
93 | # error TARGET_PAGE_BITS must be defined in cpu-param.h | ||
94 | # endif | ||
95 | #endif | ||
96 | +#ifndef TARGET_TB_PCREL | ||
97 | +# define TARGET_TB_PCREL 0 | ||
98 | +#endif | ||
99 | |||
100 | #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) | ||
101 | |||
19 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | 102 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h |
20 | index XXXXXXX..XXXXXXX 100644 | 103 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/exec/exec-all.h | 104 | --- a/include/exec/exec-all.h |
22 | +++ b/include/exec/exec-all.h | 105 | +++ b/include/exec/exec-all.h |
106 | @@ -XXX,XX +XXX,XX @@ struct tb_tc { | ||
107 | }; | ||
108 | |||
109 | struct TranslationBlock { | ||
110 | - target_ulong pc; /* simulated PC corresponding to this block (EIP + CS base) */ | ||
111 | - target_ulong cs_base; /* CS base for this block */ | ||
112 | +#if !TARGET_TB_PCREL | ||
113 | + /* | ||
114 | + * Guest PC corresponding to this block. This must be the true | ||
115 | + * virtual address. Therefore e.g. x86 stores EIP + CS_BASE, and | ||
116 | + * targets like Arm, MIPS, HP-PA, which reuse low bits for ISA or | ||
117 | + * privilege, must store those bits elsewhere. | ||
118 | + * | ||
119 | + * If TARGET_TB_PCREL, the opcodes for the TranslationBlock are | ||
120 | + * written such that the TB is associated only with the physical | ||
121 | + * page and may be run in any virtual address context. In this case, | ||
122 | + * PC must always be taken from ENV in a target-specific manner. | ||
123 | + * Unwind information is taken as offsets from the page, to be | ||
124 | + * deposited into the "current" PC. | ||
125 | + */ | ||
126 | + target_ulong pc; | ||
127 | +#endif | ||
128 | + | ||
129 | + /* | ||
130 | + * Target-specific data associated with the TranslationBlock, e.g.: | ||
131 | + * x86: the original user, the Code Segment virtual base, | ||
132 | + * arm: an extension of tb->flags, | ||
133 | + * s390x: instruction data for EXECUTE, | ||
134 | + * sparc: the next pc of the instruction queue (for delay slots). | ||
135 | + */ | ||
136 | + target_ulong cs_base; | ||
137 | + | ||
138 | uint32_t flags; /* flags defining in which context the code was generated */ | ||
139 | uint32_t cflags; /* compile flags */ | ||
140 | |||
23 | @@ -XXX,XX +XXX,XX @@ struct TranslationBlock { | 141 | @@ -XXX,XX +XXX,XX @@ struct TranslationBlock { |
24 | #define CF_PARALLEL 0x00080000 /* Generate code for a parallel context */ | 142 | /* Hide the read to avoid ifdefs for TARGET_TB_PCREL. */ |
25 | #define CF_CLUSTER_MASK 0xff000000 /* Top 8 bits are cluster ID */ | 143 | static inline target_ulong tb_pc(const TranslationBlock *tb) |
26 | #define CF_CLUSTER_SHIFT 24 | 144 | { |
27 | -/* cflags' mask for hashing/comparison, basically ignore CF_INVALID */ | 145 | +#if TARGET_TB_PCREL |
28 | -#define CF_HASH_MASK (~CF_INVALID) | 146 | + qemu_build_not_reached(); |
29 | 147 | +#else | |
30 | /* Per-vCPU dynamic tracing state used to generate this TB */ | 148 | return tb->pc; |
31 | uint32_t trace_vcpu_dstate; | 149 | +#endif |
32 | @@ -XXX,XX +XXX,XX @@ void tb_flush(CPUState *cpu); | 150 | } |
33 | void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); | 151 | |
34 | TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, | 152 | /* Hide the qatomic_read to make code a little easier on the eyes */ |
35 | target_ulong cs_base, uint32_t flags, | 153 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c |
36 | - uint32_t cf_mask); | 154 | index XXXXXXX..XXXXXXX 100644 |
37 | + uint32_t cflags); | 155 | --- a/accel/tcg/cpu-exec.c |
38 | void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr); | 156 | +++ b/accel/tcg/cpu-exec.c |
39 | 157 | @@ -XXX,XX +XXX,XX @@ static bool tb_lookup_cmp(const void *p, const void *d) | |
40 | /* GETPC is the true target of the return instruction that we'll execute. */ | 158 | const TranslationBlock *tb = p; |
41 | diff --git a/include/exec/tb-lookup.h b/include/exec/tb-lookup.h | 159 | const struct tb_desc *desc = d; |
42 | index XXXXXXX..XXXXXXX 100644 | 160 | |
43 | --- a/include/exec/tb-lookup.h | 161 | - if (tb_pc(tb) == desc->pc && |
44 | +++ b/include/exec/tb-lookup.h | 162 | + if ((TARGET_TB_PCREL || tb_pc(tb) == desc->pc) && |
45 | @@ -XXX,XX +XXX,XX @@ | 163 | tb->page_addr[0] == desc->page_addr0 && |
46 | /* Might cause an exception, so have a longjmp destination ready */ | 164 | tb->cs_base == desc->cs_base && |
47 | static inline TranslationBlock * tb_lookup(CPUState *cpu, | 165 | tb->flags == desc->flags && |
48 | target_ulong pc, target_ulong cs_base, | 166 | @@ -XXX,XX +XXX,XX @@ static TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, |
49 | - uint32_t flags, uint32_t cf_mask) | 167 | return NULL; |
50 | + uint32_t flags, uint32_t cflags) | 168 | } |
169 | desc.page_addr0 = phys_pc; | ||
170 | - h = tb_hash_func(phys_pc, pc, flags, cflags, *cpu->trace_dstate); | ||
171 | + h = tb_hash_func(phys_pc, (TARGET_TB_PCREL ? 0 : pc), | ||
172 | + flags, cflags, *cpu->trace_dstate); | ||
173 | return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp); | ||
174 | } | ||
175 | |||
176 | @@ -XXX,XX +XXX,XX @@ static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc, | ||
177 | uint32_t flags, uint32_t cflags) | ||
51 | { | 178 | { |
52 | TranslationBlock *tb; | 179 | TranslationBlock *tb; |
180 | + CPUJumpCache *jc; | ||
53 | uint32_t hash; | 181 | uint32_t hash; |
54 | 182 | ||
55 | + /* we should never be trying to look up an INVALID tb */ | 183 | /* we should never be trying to look up an INVALID tb */ |
56 | + tcg_debug_assert(!(cflags & CF_INVALID)); | 184 | tcg_debug_assert(!(cflags & CF_INVALID)); |
57 | + | 185 | |
58 | hash = tb_jmp_cache_hash_func(pc); | 186 | hash = tb_jmp_cache_hash_func(pc); |
59 | tb = qatomic_rcu_read(&cpu->tb_jmp_cache[hash]); | 187 | - tb = qatomic_rcu_read(&cpu->tb_jmp_cache->array[hash].tb); |
60 | 188 | + jc = cpu->tb_jmp_cache; | |
61 | @@ -XXX,XX +XXX,XX @@ static inline TranslationBlock * tb_lookup(CPUState *cpu, | 189 | + tb = tb_jmp_cache_get_tb(jc, hash); |
190 | |||
191 | if (likely(tb && | ||
192 | - tb->pc == pc && | ||
193 | + tb_jmp_cache_get_pc(jc, hash, tb) == pc && | ||
62 | tb->cs_base == cs_base && | 194 | tb->cs_base == cs_base && |
63 | tb->flags == flags && | 195 | tb->flags == flags && |
64 | tb->trace_vcpu_dstate == *cpu->trace_dstate && | 196 | tb->trace_vcpu_dstate == *cpu->trace_dstate && |
65 | - (tb_cflags(tb) & (CF_HASH_MASK | CF_INVALID)) == cf_mask)) { | 197 | @@ -XXX,XX +XXX,XX @@ static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc, |
66 | + tb_cflags(tb) == cflags)) { | ||
67 | return tb; | ||
68 | } | ||
69 | - tb = tb_htable_lookup(cpu, pc, cs_base, flags, cf_mask); | ||
70 | + tb = tb_htable_lookup(cpu, pc, cs_base, flags, cflags); | ||
71 | if (tb == NULL) { | 198 | if (tb == NULL) { |
72 | return NULL; | 199 | return NULL; |
73 | } | 200 | } |
74 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | 201 | - qatomic_set(&cpu->tb_jmp_cache->array[hash].tb, tb); |
75 | index XXXXXXX..XXXXXXX 100644 | 202 | + tb_jmp_cache_set(jc, hash, tb, pc); |
76 | --- a/accel/tcg/cpu-exec.c | 203 | return tb; |
77 | +++ b/accel/tcg/cpu-exec.c | 204 | } |
78 | @@ -XXX,XX +XXX,XX @@ struct tb_desc { | 205 | |
79 | CPUArchState *env; | 206 | @@ -XXX,XX +XXX,XX @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit) |
80 | tb_page_addr_t phys_page1; | 207 | if (cc->tcg_ops->synchronize_from_tb) { |
81 | uint32_t flags; | 208 | cc->tcg_ops->synchronize_from_tb(cpu, last_tb); |
82 | - uint32_t cf_mask; | 209 | } else { |
83 | + uint32_t cflags; | 210 | + assert(!TARGET_TB_PCREL); |
84 | uint32_t trace_vcpu_dstate; | 211 | assert(cc->set_pc); |
85 | }; | 212 | cc->set_pc(cpu, tb_pc(last_tb)); |
86 | 213 | } | |
87 | @@ -XXX,XX +XXX,XX @@ static bool tb_lookup_cmp(const void *p, const void *d) | 214 | @@ -XXX,XX +XXX,XX @@ int cpu_exec(CPUState *cpu) |
88 | tb->cs_base == desc->cs_base && | 215 | * for the fast lookup |
89 | tb->flags == desc->flags && | 216 | */ |
90 | tb->trace_vcpu_dstate == desc->trace_vcpu_dstate && | 217 | h = tb_jmp_cache_hash_func(pc); |
91 | - (tb_cflags(tb) & (CF_HASH_MASK | CF_INVALID)) == desc->cf_mask) { | 218 | - qatomic_set(&cpu->tb_jmp_cache->array[h].tb, tb); |
92 | + tb_cflags(tb) == desc->cflags) { | 219 | + tb_jmp_cache_set(cpu->tb_jmp_cache, h, tb, pc); |
93 | /* check next page if needed */ | 220 | } |
94 | if (tb->page_addr[1] == -1) { | 221 | |
95 | return true; | 222 | #ifndef CONFIG_USER_ONLY |
96 | @@ -XXX,XX +XXX,XX @@ static bool tb_lookup_cmp(const void *p, const void *d) | ||
97 | |||
98 | TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, | ||
99 | target_ulong cs_base, uint32_t flags, | ||
100 | - uint32_t cf_mask) | ||
101 | + uint32_t cflags) | ||
102 | { | ||
103 | tb_page_addr_t phys_pc; | ||
104 | struct tb_desc desc; | ||
105 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, | ||
106 | desc.env = (CPUArchState *)cpu->env_ptr; | ||
107 | desc.cs_base = cs_base; | ||
108 | desc.flags = flags; | ||
109 | - desc.cf_mask = cf_mask; | ||
110 | + desc.cflags = cflags; | ||
111 | desc.trace_vcpu_dstate = *cpu->trace_dstate; | ||
112 | desc.pc = pc; | ||
113 | phys_pc = get_page_addr_code(desc.env, pc); | ||
114 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, | ||
115 | return NULL; | ||
116 | } | ||
117 | desc.phys_page1 = phys_pc & TARGET_PAGE_MASK; | ||
118 | - h = tb_hash_func(phys_pc, pc, flags, cf_mask, *cpu->trace_dstate); | ||
119 | + h = tb_hash_func(phys_pc, pc, flags, cflags, *cpu->trace_dstate); | ||
120 | return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp); | ||
121 | } | ||
122 | |||
123 | @@ -XXX,XX +XXX,XX @@ static inline void tb_add_jump(TranslationBlock *tb, int n, | ||
124 | |||
125 | static inline TranslationBlock *tb_find(CPUState *cpu, | ||
126 | TranslationBlock *last_tb, | ||
127 | - int tb_exit, uint32_t cf_mask) | ||
128 | + int tb_exit, uint32_t cflags) | ||
129 | { | ||
130 | CPUArchState *env = (CPUArchState *)cpu->env_ptr; | ||
131 | TranslationBlock *tb; | ||
132 | @@ -XXX,XX +XXX,XX @@ static inline TranslationBlock *tb_find(CPUState *cpu, | ||
133 | |||
134 | cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); | ||
135 | |||
136 | - tb = tb_lookup(cpu, pc, cs_base, flags, cf_mask); | ||
137 | + tb = tb_lookup(cpu, pc, cs_base, flags, cflags); | ||
138 | if (tb == NULL) { | ||
139 | mmap_lock(); | ||
140 | - tb = tb_gen_code(cpu, pc, cs_base, flags, cf_mask); | ||
141 | + tb = tb_gen_code(cpu, pc, cs_base, flags, cflags); | ||
142 | mmap_unlock(); | ||
143 | /* We add the TB in the virtual pc hash table for the fast lookup */ | ||
144 | qatomic_set(&cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)], tb); | ||
145 | diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c | ||
146 | index XXXXXXX..XXXXXXX 100644 | ||
147 | --- a/accel/tcg/tcg-runtime.c | ||
148 | +++ b/accel/tcg/tcg-runtime.c | ||
149 | @@ -XXX,XX +XXX,XX @@ | ||
150 | #include "exec/helper-proto.h" | ||
151 | #include "exec/cpu_ldst.h" | ||
152 | #include "exec/exec-all.h" | ||
153 | -#include "exec/tb-lookup.h" | ||
154 | #include "disas/disas.h" | ||
155 | #include "exec/log.h" | ||
156 | #include "tcg/tcg.h" | ||
157 | +#include "exec/tb-lookup.h" | ||
158 | |||
159 | /* 32-bit helpers */ | ||
160 | |||
161 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | 223 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c |
162 | index XXXXXXX..XXXXXXX 100644 | 224 | index XXXXXXX..XXXXXXX 100644 |
163 | --- a/accel/tcg/translate-all.c | 225 | --- a/accel/tcg/translate-all.c |
164 | +++ b/accel/tcg/translate-all.c | 226 | +++ b/accel/tcg/translate-all.c |
227 | @@ -XXX,XX +XXX,XX @@ static int encode_search(TranslationBlock *tb, uint8_t *block) | ||
228 | |||
229 | for (j = 0; j < TARGET_INSN_START_WORDS; ++j) { | ||
230 | if (i == 0) { | ||
231 | - prev = (j == 0 ? tb_pc(tb) : 0); | ||
232 | + prev = (!TARGET_TB_PCREL && j == 0 ? tb_pc(tb) : 0); | ||
233 | } else { | ||
234 | prev = tcg_ctx->gen_insn_data[i - 1][j]; | ||
235 | } | ||
236 | @@ -XXX,XX +XXX,XX @@ static int encode_search(TranslationBlock *tb, uint8_t *block) | ||
237 | static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, | ||
238 | uintptr_t searched_pc, bool reset_icount) | ||
239 | { | ||
240 | - target_ulong data[TARGET_INSN_START_WORDS] = { tb_pc(tb) }; | ||
241 | + target_ulong data[TARGET_INSN_START_WORDS]; | ||
242 | uintptr_t host_pc = (uintptr_t)tb->tc.ptr; | ||
243 | CPUArchState *env = cpu->env_ptr; | ||
244 | const uint8_t *p = tb->tc.ptr + tb->tc.size; | ||
245 | @@ -XXX,XX +XXX,XX @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, | ||
246 | return -1; | ||
247 | } | ||
248 | |||
249 | + memset(data, 0, sizeof(data)); | ||
250 | + if (!TARGET_TB_PCREL) { | ||
251 | + data[0] = tb_pc(tb); | ||
252 | + } | ||
253 | + | ||
254 | /* Reconstruct the stored insn data while looking for the point at | ||
255 | which the end of the insn exceeds the searched_pc. */ | ||
256 | for (i = 0; i < num_insns; ++i) { | ||
165 | @@ -XXX,XX +XXX,XX @@ static bool tb_cmp(const void *ap, const void *bp) | 257 | @@ -XXX,XX +XXX,XX @@ static bool tb_cmp(const void *ap, const void *bp) |
166 | return a->pc == b->pc && | 258 | const TranslationBlock *a = ap; |
167 | a->cs_base == b->cs_base && | 259 | const TranslationBlock *b = bp; |
168 | a->flags == b->flags && | 260 | |
169 | - (tb_cflags(a) & CF_HASH_MASK) == (tb_cflags(b) & CF_HASH_MASK) && | 261 | - return tb_pc(a) == tb_pc(b) && |
170 | + (tb_cflags(a) & ~CF_INVALID) == (tb_cflags(b) & ~CF_INVALID) && | 262 | - a->cs_base == b->cs_base && |
171 | a->trace_vcpu_dstate == b->trace_vcpu_dstate && | 263 | - a->flags == b->flags && |
172 | a->page_addr[0] == b->page_addr[0] && | 264 | - (tb_cflags(a) & ~CF_INVALID) == (tb_cflags(b) & ~CF_INVALID) && |
173 | a->page_addr[1] == b->page_addr[1]; | 265 | - a->trace_vcpu_dstate == b->trace_vcpu_dstate && |
174 | @@ -XXX,XX +XXX,XX @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) | 266 | - a->page_addr[0] == b->page_addr[0] && |
267 | - a->page_addr[1] == b->page_addr[1]; | ||
268 | + return ((TARGET_TB_PCREL || tb_pc(a) == tb_pc(b)) && | ||
269 | + a->cs_base == b->cs_base && | ||
270 | + a->flags == b->flags && | ||
271 | + (tb_cflags(a) & ~CF_INVALID) == (tb_cflags(b) & ~CF_INVALID) && | ||
272 | + a->trace_vcpu_dstate == b->trace_vcpu_dstate && | ||
273 | + a->page_addr[0] == b->page_addr[0] && | ||
274 | + a->page_addr[1] == b->page_addr[1]); | ||
275 | } | ||
276 | |||
277 | void tb_htable_init(void) | ||
278 | @@ -XXX,XX +XXX,XX @@ static inline void tb_jmp_unlink(TranslationBlock *dest) | ||
279 | qemu_spin_unlock(&dest->jmp_lock); | ||
280 | } | ||
281 | |||
282 | +static void tb_jmp_cache_inval_tb(TranslationBlock *tb) | ||
283 | +{ | ||
284 | + CPUState *cpu; | ||
285 | + | ||
286 | + if (TARGET_TB_PCREL) { | ||
287 | + /* A TB may be at any virtual address */ | ||
288 | + CPU_FOREACH(cpu) { | ||
289 | + tcg_flush_jmp_cache(cpu); | ||
290 | + } | ||
291 | + } else { | ||
292 | + uint32_t h = tb_jmp_cache_hash_func(tb_pc(tb)); | ||
293 | + | ||
294 | + CPU_FOREACH(cpu) { | ||
295 | + CPUJumpCache *jc = cpu->tb_jmp_cache; | ||
296 | + | ||
297 | + if (qatomic_read(&jc->array[h].tb) == tb) { | ||
298 | + qatomic_set(&jc->array[h].tb, NULL); | ||
299 | + } | ||
300 | + } | ||
301 | + } | ||
302 | +} | ||
303 | + | ||
304 | /* | ||
305 | * In user-mode, call with mmap_lock held. | ||
306 | * In !user-mode, if @rm_from_page_list is set, call with the TB's pages' | ||
307 | @@ -XXX,XX +XXX,XX @@ static inline void tb_jmp_unlink(TranslationBlock *dest) | ||
308 | */ | ||
309 | static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) | ||
310 | { | ||
311 | - CPUState *cpu; | ||
175 | PageDesc *p; | 312 | PageDesc *p; |
176 | uint32_t h; | 313 | uint32_t h; |
177 | tb_page_addr_t phys_pc; | 314 | tb_page_addr_t phys_pc; |
178 | + uint32_t orig_cflags = tb_cflags(tb); | ||
179 | |||
180 | assert_memory_lock(); | ||
181 | |||
182 | @@ -XXX,XX +XXX,XX @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) | 315 | @@ -XXX,XX +XXX,XX @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) |
183 | 316 | ||
184 | /* remove the TB from the hash list */ | 317 | /* remove the TB from the hash list */ |
185 | phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); | 318 | phys_pc = tb->page_addr[0]; |
186 | - h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb_cflags(tb) & CF_HASH_MASK, | 319 | - h = tb_hash_func(phys_pc, tb_pc(tb), tb->flags, orig_cflags, |
187 | + h = tb_hash_func(phys_pc, tb->pc, tb->flags, orig_cflags, | 320 | - tb->trace_vcpu_dstate); |
188 | tb->trace_vcpu_dstate); | 321 | + h = tb_hash_func(phys_pc, (TARGET_TB_PCREL ? 0 : tb_pc(tb)), |
322 | + tb->flags, orig_cflags, tb->trace_vcpu_dstate); | ||
189 | if (!qht_remove(&tb_ctx.htable, tb, h)) { | 323 | if (!qht_remove(&tb_ctx.htable, tb, h)) { |
190 | return; | 324 | return; |
325 | } | ||
326 | @@ -XXX,XX +XXX,XX @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) | ||
327 | } | ||
328 | |||
329 | /* remove the TB from the hash list */ | ||
330 | - h = tb_jmp_cache_hash_func(tb->pc); | ||
331 | - CPU_FOREACH(cpu) { | ||
332 | - CPUJumpCache *jc = cpu->tb_jmp_cache; | ||
333 | - if (qatomic_read(&jc->array[h].tb) == tb) { | ||
334 | - qatomic_set(&jc->array[h].tb, NULL); | ||
335 | - } | ||
336 | - } | ||
337 | + tb_jmp_cache_inval_tb(tb); | ||
338 | |||
339 | /* suppress this TB from the two jump lists */ | ||
340 | tb_remove_from_jmp_list(tb, 0); | ||
191 | @@ -XXX,XX +XXX,XX @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, | 341 | @@ -XXX,XX +XXX,XX @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, |
192 | uint32_t h; | 342 | } |
193 | |||
194 | assert_memory_lock(); | ||
195 | + tcg_debug_assert(!(tb->cflags & CF_INVALID)); | ||
196 | |||
197 | /* | ||
198 | * Add the TB to the page list, acquiring first the pages's locks. | ||
199 | @@ -XXX,XX +XXX,XX @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, | ||
200 | } | ||
201 | 343 | ||
202 | /* add in the hash table */ | 344 | /* add in the hash table */ |
203 | - h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MASK, | 345 | - h = tb_hash_func(phys_pc, tb_pc(tb), tb->flags, tb->cflags, |
204 | + h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags, | 346 | - tb->trace_vcpu_dstate); |
205 | tb->trace_vcpu_dstate); | 347 | + h = tb_hash_func(phys_pc, (TARGET_TB_PCREL ? 0 : tb_pc(tb)), |
348 | + tb->flags, tb->cflags, tb->trace_vcpu_dstate); | ||
206 | qht_insert(&tb_ctx.htable, tb, h, &existing_tb); | 349 | qht_insert(&tb_ctx.htable, tb, h, &existing_tb); |
207 | 350 | ||
351 | /* remove TB from the page(s) if we couldn't insert it */ | ||
352 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, | ||
353 | |||
354 | gen_code_buf = tcg_ctx->code_gen_ptr; | ||
355 | tb->tc.ptr = tcg_splitwx_to_rx(gen_code_buf); | ||
356 | +#if !TARGET_TB_PCREL | ||
357 | tb->pc = pc; | ||
358 | +#endif | ||
359 | tb->cs_base = cs_base; | ||
360 | tb->flags = flags; | ||
361 | tb->cflags = cflags; | ||
208 | -- | 362 | -- |
209 | 2.25.1 | 363 | 2.34.1 |
210 | 364 | ||
211 | 365 | diff view generated by jsdifflib |
1 | For some vector operations, "1D" is not a valid type, and there | 1 | From: Leandro Lupori <leandro.lupori@eldorado.org.br> |
---|---|---|---|
2 | are separate instructions for the 64-bit scalar operation. | ||
3 | 2 | ||
4 | Tested-by: Stefan Weil <sw@weilnetz.de> | 3 | PowerPC64 processors handle direct branches better than indirect |
5 | Buglink: https://bugs.launchpad.net/qemu/+bug/1916112 | 4 | ones, resulting in less stalled cycles and branch misses. |
6 | Fixes: 14e4c1e2355 ("tcg/aarch64: Add vector operations") | 5 | |
6 | However, PPC's tb_target_set_jmp_target() was only using direct | ||
7 | branches for 16-bit jumps, while PowerPC64's unconditional branch | ||
8 | instructions are able to handle displacements of up to 26 bits. | ||
9 | To take advantage of this, now jumps whose displacements fit in | ||
10 | between 17 and 26 bits are also converted to direct branches. | ||
11 | |||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Signed-off-by: Leandro Lupori <leandro.lupori@eldorado.org.br> | ||
14 | [rth: Expanded some commentary.] | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | --- | 16 | --- |
9 | tcg/aarch64/tcg-target.c.inc | 211 ++++++++++++++++++++++++++++++----- | 17 | tcg/ppc/tcg-target.c.inc | 119 +++++++++++++++++++++++++++++---------- |
10 | 1 file changed, 181 insertions(+), 30 deletions(-) | 18 | 1 file changed, 88 insertions(+), 31 deletions(-) |
11 | 19 | ||
12 | diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc | 20 | diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc |
13 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/tcg/aarch64/tcg-target.c.inc | 22 | --- a/tcg/ppc/tcg-target.c.inc |
15 | +++ b/tcg/aarch64/tcg-target.c.inc | 23 | +++ b/tcg/ppc/tcg-target.c.inc |
16 | @@ -XXX,XX +XXX,XX @@ typedef enum { | 24 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) |
17 | I3606_BIC = 0x2f001400, | 25 | tcg_out32(s, insn); |
18 | I3606_ORR = 0x0f001400, | ||
19 | |||
20 | + /* AdvSIMD scalar shift by immediate */ | ||
21 | + I3609_SSHR = 0x5f000400, | ||
22 | + I3609_SSRA = 0x5f001400, | ||
23 | + I3609_SHL = 0x5f005400, | ||
24 | + I3609_USHR = 0x7f000400, | ||
25 | + I3609_USRA = 0x7f001400, | ||
26 | + I3609_SLI = 0x7f005400, | ||
27 | + | ||
28 | + /* AdvSIMD scalar three same */ | ||
29 | + I3611_SQADD = 0x5e200c00, | ||
30 | + I3611_SQSUB = 0x5e202c00, | ||
31 | + I3611_CMGT = 0x5e203400, | ||
32 | + I3611_CMGE = 0x5e203c00, | ||
33 | + I3611_SSHL = 0x5e204400, | ||
34 | + I3611_ADD = 0x5e208400, | ||
35 | + I3611_CMTST = 0x5e208c00, | ||
36 | + I3611_UQADD = 0x7e200c00, | ||
37 | + I3611_UQSUB = 0x7e202c00, | ||
38 | + I3611_CMHI = 0x7e203400, | ||
39 | + I3611_CMHS = 0x7e203c00, | ||
40 | + I3611_USHL = 0x7e204400, | ||
41 | + I3611_SUB = 0x7e208400, | ||
42 | + I3611_CMEQ = 0x7e208c00, | ||
43 | + | ||
44 | + /* AdvSIMD scalar two-reg misc */ | ||
45 | + I3612_CMGT0 = 0x5e208800, | ||
46 | + I3612_CMEQ0 = 0x5e209800, | ||
47 | + I3612_CMLT0 = 0x5e20a800, | ||
48 | + I3612_ABS = 0x5e20b800, | ||
49 | + I3612_CMGE0 = 0x7e208800, | ||
50 | + I3612_CMLE0 = 0x7e209800, | ||
51 | + I3612_NEG = 0x7e20b800, | ||
52 | + | ||
53 | /* AdvSIMD shift by immediate */ | ||
54 | I3614_SSHR = 0x0f000400, | ||
55 | I3614_SSRA = 0x0f001400, | ||
56 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_insn_3606(TCGContext *s, AArch64Insn insn, bool q, | ||
57 | | (imm8 & 0xe0) << (16 - 5) | (imm8 & 0x1f) << 5); | ||
58 | } | 26 | } |
59 | 27 | ||
60 | +static void tcg_out_insn_3609(TCGContext *s, AArch64Insn insn, | 28 | +static inline uint64_t make_pair(tcg_insn_unit i1, tcg_insn_unit i2) |
61 | + TCGReg rd, TCGReg rn, unsigned immhb) | ||
62 | +{ | 29 | +{ |
63 | + tcg_out32(s, insn | immhb << 16 | (rn & 0x1f) << 5 | (rd & 0x1f)); | 30 | + if (HOST_BIG_ENDIAN) { |
31 | + return (uint64_t)i1 << 32 | i2; | ||
32 | + } | ||
33 | + return (uint64_t)i2 << 32 | i1; | ||
64 | +} | 34 | +} |
65 | + | 35 | + |
66 | +static void tcg_out_insn_3611(TCGContext *s, AArch64Insn insn, | 36 | +static inline void ppc64_replace2(uintptr_t rx, uintptr_t rw, |
67 | + unsigned size, TCGReg rd, TCGReg rn, TCGReg rm) | 37 | + tcg_insn_unit i0, tcg_insn_unit i1) |
68 | +{ | 38 | +{ |
69 | + tcg_out32(s, insn | (size << 22) | (rm & 0x1f) << 16 | 39 | +#if TCG_TARGET_REG_BITS == 64 |
70 | + | (rn & 0x1f) << 5 | (rd & 0x1f)); | 40 | + qatomic_set((uint64_t *)rw, make_pair(i0, i1)); |
41 | + flush_idcache_range(rx, rw, 8); | ||
42 | +#else | ||
43 | + qemu_build_not_reached(); | ||
44 | +#endif | ||
71 | +} | 45 | +} |
72 | + | 46 | + |
73 | +static void tcg_out_insn_3612(TCGContext *s, AArch64Insn insn, | 47 | +static inline void ppc64_replace4(uintptr_t rx, uintptr_t rw, |
74 | + unsigned size, TCGReg rd, TCGReg rn) | 48 | + tcg_insn_unit i0, tcg_insn_unit i1, |
49 | + tcg_insn_unit i2, tcg_insn_unit i3) | ||
75 | +{ | 50 | +{ |
76 | + tcg_out32(s, insn | (size << 22) | (rn & 0x1f) << 5 | (rd & 0x1f)); | 51 | + uint64_t p[2]; |
52 | + | ||
53 | + p[!HOST_BIG_ENDIAN] = make_pair(i0, i1); | ||
54 | + p[HOST_BIG_ENDIAN] = make_pair(i2, i3); | ||
55 | + | ||
56 | + /* | ||
57 | + * There's no convenient way to get the compiler to allocate a pair | ||
58 | + * of registers at an even index, so copy into r6/r7 and clobber. | ||
59 | + */ | ||
60 | + asm("mr %%r6, %1\n\t" | ||
61 | + "mr %%r7, %2\n\t" | ||
62 | + "stq %%r6, %0" | ||
63 | + : "=Q"(*(__int128 *)rw) : "r"(p[0]), "r"(p[1]) : "r6", "r7"); | ||
64 | + flush_idcache_range(rx, rw, 16); | ||
77 | +} | 65 | +} |
78 | + | 66 | + |
79 | static void tcg_out_insn_3614(TCGContext *s, AArch64Insn insn, bool q, | 67 | void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, |
80 | TCGReg rd, TCGReg rn, unsigned immhb) | 68 | uintptr_t jmp_rw, uintptr_t addr) |
81 | { | 69 | { |
82 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | 70 | - if (TCG_TARGET_REG_BITS == 64) { |
83 | unsigned vecl, unsigned vece, | 71 | - tcg_insn_unit i1, i2; |
84 | const TCGArg *args, const int *const_args) | 72 | - intptr_t tb_diff = addr - tc_ptr; |
85 | { | 73 | - intptr_t br_diff = addr - (jmp_rx + 4); |
86 | - static const AArch64Insn cmp_insn[16] = { | 74 | - uint64_t pair; |
87 | + static const AArch64Insn cmp_vec_insn[16] = { | 75 | + tcg_insn_unit i0, i1, i2, i3; |
88 | [TCG_COND_EQ] = I3616_CMEQ, | 76 | + intptr_t tb_diff = addr - tc_ptr; |
89 | [TCG_COND_GT] = I3616_CMGT, | 77 | + intptr_t br_diff = addr - (jmp_rx + 4); |
90 | [TCG_COND_GE] = I3616_CMGE, | 78 | + intptr_t lo, hi; |
91 | [TCG_COND_GTU] = I3616_CMHI, | 79 | |
92 | [TCG_COND_GEU] = I3616_CMHS, | 80 | - /* This does not exercise the range of the branch, but we do |
93 | }; | 81 | - still need to be able to load the new value of TCG_REG_TB. |
94 | - static const AArch64Insn cmp0_insn[16] = { | 82 | - But this does still happen quite often. */ |
95 | + static const AArch64Insn cmp_scalar_insn[16] = { | 83 | - if (tb_diff == (int16_t)tb_diff) { |
96 | + [TCG_COND_EQ] = I3611_CMEQ, | 84 | - i1 = ADDI | TAI(TCG_REG_TB, TCG_REG_TB, tb_diff); |
97 | + [TCG_COND_GT] = I3611_CMGT, | 85 | - i2 = B | (br_diff & 0x3fffffc); |
98 | + [TCG_COND_GE] = I3611_CMGE, | 86 | - } else { |
99 | + [TCG_COND_GTU] = I3611_CMHI, | 87 | - intptr_t lo = (int16_t)tb_diff; |
100 | + [TCG_COND_GEU] = I3611_CMHS, | 88 | - intptr_t hi = (int32_t)(tb_diff - lo); |
101 | + }; | 89 | - assert(tb_diff == hi + lo); |
102 | + static const AArch64Insn cmp0_vec_insn[16] = { | 90 | - i1 = ADDIS | TAI(TCG_REG_TB, TCG_REG_TB, hi >> 16); |
103 | [TCG_COND_EQ] = I3617_CMEQ0, | 91 | - i2 = ADDI | TAI(TCG_REG_TB, TCG_REG_TB, lo); |
104 | [TCG_COND_GT] = I3617_CMGT0, | 92 | - } |
105 | [TCG_COND_GE] = I3617_CMGE0, | 93 | -#if HOST_BIG_ENDIAN |
106 | [TCG_COND_LT] = I3617_CMLT0, | 94 | - pair = (uint64_t)i1 << 32 | i2; |
107 | [TCG_COND_LE] = I3617_CMLE0, | 95 | -#else |
108 | }; | 96 | - pair = (uint64_t)i2 << 32 | i1; |
109 | + static const AArch64Insn cmp0_scalar_insn[16] = { | 97 | -#endif |
110 | + [TCG_COND_EQ] = I3612_CMEQ0, | 98 | - |
111 | + [TCG_COND_GT] = I3612_CMGT0, | 99 | - /* As per the enclosing if, this is ppc64. Avoid the _Static_assert |
112 | + [TCG_COND_GE] = I3612_CMGE0, | 100 | - within qatomic_set that would fail to build a ppc32 host. */ |
113 | + [TCG_COND_LT] = I3612_CMLT0, | 101 | - qatomic_set__nocheck((uint64_t *)jmp_rw, pair); |
114 | + [TCG_COND_LE] = I3612_CMLE0, | 102 | - flush_idcache_range(jmp_rx, jmp_rw, 8); |
115 | + }; | 103 | - } else { |
116 | 104 | + if (TCG_TARGET_REG_BITS == 32) { | |
117 | TCGType type = vecl + TCG_TYPE_V64; | 105 | intptr_t diff = addr - jmp_rx; |
118 | unsigned is_q = vecl; | 106 | tcg_debug_assert(in_range_b(diff)); |
119 | + bool is_scalar = !is_q && vece == MO_64; | 107 | qatomic_set((uint32_t *)jmp_rw, B | (diff & 0x3fffffc)); |
120 | TCGArg a0, a1, a2, a3; | 108 | flush_idcache_range(jmp_rx, jmp_rw, 4); |
121 | int cmode, imm8; | 109 | + return; |
122 | 110 | } | |
123 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | 111 | + |
124 | tcg_out_dupm_vec(s, type, vece, a0, a1, a2); | 112 | + /* |
125 | break; | 113 | + * For 16-bit displacements, we can use a single add + branch. |
126 | case INDEX_op_add_vec: | 114 | + * This happens quite often. |
127 | - tcg_out_insn(s, 3616, ADD, is_q, vece, a0, a1, a2); | 115 | + */ |
128 | + if (is_scalar) { | 116 | + if (tb_diff == (int16_t)tb_diff) { |
129 | + tcg_out_insn(s, 3611, ADD, vece, a0, a1, a2); | 117 | + i0 = ADDI | TAI(TCG_REG_TB, TCG_REG_TB, tb_diff); |
130 | + } else { | 118 | + i1 = B | (br_diff & 0x3fffffc); |
131 | + tcg_out_insn(s, 3616, ADD, is_q, vece, a0, a1, a2); | 119 | + ppc64_replace2(jmp_rx, jmp_rw, i0, i1); |
132 | + } | 120 | + return; |
133 | break; | 121 | + } |
134 | case INDEX_op_sub_vec: | 122 | + |
135 | - tcg_out_insn(s, 3616, SUB, is_q, vece, a0, a1, a2); | 123 | + lo = (int16_t)tb_diff; |
136 | + if (is_scalar) { | 124 | + hi = (int32_t)(tb_diff - lo); |
137 | + tcg_out_insn(s, 3611, SUB, vece, a0, a1, a2); | 125 | + assert(tb_diff == hi + lo); |
138 | + } else { | 126 | + i0 = ADDIS | TAI(TCG_REG_TB, TCG_REG_TB, hi >> 16); |
139 | + tcg_out_insn(s, 3616, SUB, is_q, vece, a0, a1, a2); | 127 | + i1 = ADDI | TAI(TCG_REG_TB, TCG_REG_TB, lo); |
140 | + } | 128 | + |
141 | break; | 129 | + /* |
142 | case INDEX_op_mul_vec: | 130 | + * Without stq from 2.07, we can only update two insns, |
143 | tcg_out_insn(s, 3616, MUL, is_q, vece, a0, a1, a2); | 131 | + * and those must be the ones that load the target address. |
144 | break; | 132 | + */ |
145 | case INDEX_op_neg_vec: | 133 | + if (!have_isa_2_07) { |
146 | - tcg_out_insn(s, 3617, NEG, is_q, vece, a0, a1); | 134 | + ppc64_replace2(jmp_rx, jmp_rw, i0, i1); |
147 | + if (is_scalar) { | 135 | + return; |
148 | + tcg_out_insn(s, 3612, NEG, vece, a0, a1); | 136 | + } |
149 | + } else { | 137 | + |
150 | + tcg_out_insn(s, 3617, NEG, is_q, vece, a0, a1); | 138 | + /* |
151 | + } | 139 | + * For 26-bit displacements, we can use a direct branch. |
152 | break; | 140 | + * Otherwise we still need the indirect branch, which we |
153 | case INDEX_op_abs_vec: | 141 | + * must restore after a potential direct branch write. |
154 | - tcg_out_insn(s, 3617, ABS, is_q, vece, a0, a1); | 142 | + */ |
155 | + if (is_scalar) { | 143 | + br_diff -= 4; |
156 | + tcg_out_insn(s, 3612, ABS, vece, a0, a1); | 144 | + if (in_range_b(br_diff)) { |
157 | + } else { | 145 | + i2 = B | (br_diff & 0x3fffffc); |
158 | + tcg_out_insn(s, 3617, ABS, is_q, vece, a0, a1); | 146 | + i3 = NOP; |
159 | + } | 147 | + } else { |
160 | break; | 148 | + i2 = MTSPR | RS(TCG_REG_TB) | CTR; |
161 | case INDEX_op_and_vec: | 149 | + i3 = BCCTR | BO_ALWAYS; |
162 | if (const_args[2]) { | 150 | + } |
163 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | 151 | + ppc64_replace4(jmp_rx, jmp_rw, i0, i1, i2, i3); |
164 | tcg_out_insn(s, 3616, EOR, is_q, 0, a0, a1, a2); | 152 | } |
165 | break; | 153 | |
166 | case INDEX_op_ssadd_vec: | 154 | static void tcg_out_call_int(TCGContext *s, int lk, |
167 | - tcg_out_insn(s, 3616, SQADD, is_q, vece, a0, a1, a2); | 155 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, |
168 | + if (is_scalar) { | 156 | if (s->tb_jmp_insn_offset) { |
169 | + tcg_out_insn(s, 3611, SQADD, vece, a0, a1, a2); | 157 | /* Direct jump. */ |
170 | + } else { | 158 | if (TCG_TARGET_REG_BITS == 64) { |
171 | + tcg_out_insn(s, 3616, SQADD, is_q, vece, a0, a1, a2); | 159 | - /* Ensure the next insns are 8-byte aligned. */ |
172 | + } | 160 | - if ((uintptr_t)s->code_ptr & 7) { |
173 | break; | 161 | + /* Ensure the next insns are 8 or 16-byte aligned. */ |
174 | case INDEX_op_sssub_vec: | 162 | + while ((uintptr_t)s->code_ptr & (have_isa_2_07 ? 15 : 7)) { |
175 | - tcg_out_insn(s, 3616, SQSUB, is_q, vece, a0, a1, a2); | 163 | tcg_out32(s, NOP); |
176 | + if (is_scalar) { | ||
177 | + tcg_out_insn(s, 3611, SQSUB, vece, a0, a1, a2); | ||
178 | + } else { | ||
179 | + tcg_out_insn(s, 3616, SQSUB, is_q, vece, a0, a1, a2); | ||
180 | + } | ||
181 | break; | ||
182 | case INDEX_op_usadd_vec: | ||
183 | - tcg_out_insn(s, 3616, UQADD, is_q, vece, a0, a1, a2); | ||
184 | + if (is_scalar) { | ||
185 | + tcg_out_insn(s, 3611, UQADD, vece, a0, a1, a2); | ||
186 | + } else { | ||
187 | + tcg_out_insn(s, 3616, UQADD, is_q, vece, a0, a1, a2); | ||
188 | + } | ||
189 | break; | ||
190 | case INDEX_op_ussub_vec: | ||
191 | - tcg_out_insn(s, 3616, UQSUB, is_q, vece, a0, a1, a2); | ||
192 | + if (is_scalar) { | ||
193 | + tcg_out_insn(s, 3611, UQSUB, vece, a0, a1, a2); | ||
194 | + } else { | ||
195 | + tcg_out_insn(s, 3616, UQSUB, is_q, vece, a0, a1, a2); | ||
196 | + } | ||
197 | break; | ||
198 | case INDEX_op_smax_vec: | ||
199 | tcg_out_insn(s, 3616, SMAX, is_q, vece, a0, a1, a2); | ||
200 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
201 | tcg_out_insn(s, 3617, NOT, is_q, 0, a0, a1); | ||
202 | break; | ||
203 | case INDEX_op_shli_vec: | ||
204 | - tcg_out_insn(s, 3614, SHL, is_q, a0, a1, a2 + (8 << vece)); | ||
205 | + if (is_scalar) { | ||
206 | + tcg_out_insn(s, 3609, SHL, a0, a1, a2 + (8 << vece)); | ||
207 | + } else { | ||
208 | + tcg_out_insn(s, 3614, SHL, is_q, a0, a1, a2 + (8 << vece)); | ||
209 | + } | ||
210 | break; | ||
211 | case INDEX_op_shri_vec: | ||
212 | - tcg_out_insn(s, 3614, USHR, is_q, a0, a1, (16 << vece) - a2); | ||
213 | + if (is_scalar) { | ||
214 | + tcg_out_insn(s, 3609, USHR, a0, a1, (16 << vece) - a2); | ||
215 | + } else { | ||
216 | + tcg_out_insn(s, 3614, USHR, is_q, a0, a1, (16 << vece) - a2); | ||
217 | + } | ||
218 | break; | ||
219 | case INDEX_op_sari_vec: | ||
220 | - tcg_out_insn(s, 3614, SSHR, is_q, a0, a1, (16 << vece) - a2); | ||
221 | + if (is_scalar) { | ||
222 | + tcg_out_insn(s, 3609, SSHR, a0, a1, (16 << vece) - a2); | ||
223 | + } else { | ||
224 | + tcg_out_insn(s, 3614, SSHR, is_q, a0, a1, (16 << vece) - a2); | ||
225 | + } | ||
226 | break; | ||
227 | case INDEX_op_aa64_sli_vec: | ||
228 | - tcg_out_insn(s, 3614, SLI, is_q, a0, a2, args[3] + (8 << vece)); | ||
229 | + if (is_scalar) { | ||
230 | + tcg_out_insn(s, 3609, SLI, a0, a2, args[3] + (8 << vece)); | ||
231 | + } else { | ||
232 | + tcg_out_insn(s, 3614, SLI, is_q, a0, a2, args[3] + (8 << vece)); | ||
233 | + } | ||
234 | break; | ||
235 | case INDEX_op_shlv_vec: | ||
236 | - tcg_out_insn(s, 3616, USHL, is_q, vece, a0, a1, a2); | ||
237 | + if (is_scalar) { | ||
238 | + tcg_out_insn(s, 3611, USHL, vece, a0, a1, a2); | ||
239 | + } else { | ||
240 | + tcg_out_insn(s, 3616, USHL, is_q, vece, a0, a1, a2); | ||
241 | + } | ||
242 | break; | ||
243 | case INDEX_op_aa64_sshl_vec: | ||
244 | - tcg_out_insn(s, 3616, SSHL, is_q, vece, a0, a1, a2); | ||
245 | + if (is_scalar) { | ||
246 | + tcg_out_insn(s, 3611, SSHL, vece, a0, a1, a2); | ||
247 | + } else { | ||
248 | + tcg_out_insn(s, 3616, SSHL, is_q, vece, a0, a1, a2); | ||
249 | + } | ||
250 | break; | ||
251 | case INDEX_op_cmp_vec: | ||
252 | { | ||
253 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
254 | |||
255 | if (cond == TCG_COND_NE) { | ||
256 | if (const_args[2]) { | ||
257 | - tcg_out_insn(s, 3616, CMTST, is_q, vece, a0, a1, a1); | ||
258 | + if (is_scalar) { | ||
259 | + tcg_out_insn(s, 3611, CMTST, vece, a0, a1, a1); | ||
260 | + } else { | ||
261 | + tcg_out_insn(s, 3616, CMTST, is_q, vece, a0, a1, a1); | ||
262 | + } | ||
263 | } else { | ||
264 | - tcg_out_insn(s, 3616, CMEQ, is_q, vece, a0, a1, a2); | ||
265 | + if (is_scalar) { | ||
266 | + tcg_out_insn(s, 3611, CMEQ, vece, a0, a1, a2); | ||
267 | + } else { | ||
268 | + tcg_out_insn(s, 3616, CMEQ, is_q, vece, a0, a1, a2); | ||
269 | + } | ||
270 | tcg_out_insn(s, 3617, NOT, is_q, 0, a0, a0); | ||
271 | } | 164 | } |
272 | } else { | 165 | s->tb_jmp_insn_offset[args[0]] = tcg_current_code_size(s); |
273 | if (const_args[2]) { | ||
274 | - insn = cmp0_insn[cond]; | ||
275 | - if (insn) { | ||
276 | - tcg_out_insn_3617(s, insn, is_q, vece, a0, a1); | ||
277 | - break; | ||
278 | + if (is_scalar) { | ||
279 | + insn = cmp0_scalar_insn[cond]; | ||
280 | + if (insn) { | ||
281 | + tcg_out_insn_3612(s, insn, vece, a0, a1); | ||
282 | + break; | ||
283 | + } | ||
284 | + } else { | ||
285 | + insn = cmp0_vec_insn[cond]; | ||
286 | + if (insn) { | ||
287 | + tcg_out_insn_3617(s, insn, is_q, vece, a0, a1); | ||
288 | + break; | ||
289 | + } | ||
290 | } | ||
291 | tcg_out_dupi_vec(s, type, MO_8, TCG_VEC_TMP, 0); | ||
292 | a2 = TCG_VEC_TMP; | ||
293 | } | ||
294 | - insn = cmp_insn[cond]; | ||
295 | - if (insn == 0) { | ||
296 | - TCGArg t; | ||
297 | - t = a1, a1 = a2, a2 = t; | ||
298 | - cond = tcg_swap_cond(cond); | ||
299 | - insn = cmp_insn[cond]; | ||
300 | - tcg_debug_assert(insn != 0); | ||
301 | + if (is_scalar) { | ||
302 | + insn = cmp_scalar_insn[cond]; | ||
303 | + if (insn == 0) { | ||
304 | + TCGArg t; | ||
305 | + t = a1, a1 = a2, a2 = t; | ||
306 | + cond = tcg_swap_cond(cond); | ||
307 | + insn = cmp_scalar_insn[cond]; | ||
308 | + tcg_debug_assert(insn != 0); | ||
309 | + } | ||
310 | + tcg_out_insn_3611(s, insn, vece, a0, a1, a2); | ||
311 | + } else { | ||
312 | + insn = cmp_vec_insn[cond]; | ||
313 | + if (insn == 0) { | ||
314 | + TCGArg t; | ||
315 | + t = a1, a1 = a2, a2 = t; | ||
316 | + cond = tcg_swap_cond(cond); | ||
317 | + insn = cmp_vec_insn[cond]; | ||
318 | + tcg_debug_assert(insn != 0); | ||
319 | + } | ||
320 | + tcg_out_insn_3616(s, insn, is_q, vece, a0, a1, a2); | ||
321 | } | ||
322 | - tcg_out_insn_3616(s, insn, is_q, vece, a0, a1, a2); | ||
323 | } | ||
324 | } | ||
325 | break; | ||
326 | -- | 166 | -- |
327 | 2.25.1 | 167 | 2.34.1 |
328 | |||
329 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Use the provided cpu_ldst.h interfaces. This fixes the build vs | ||
2 | the unconverted uses of g2h(), adds missed memory trace events, | ||
3 | and correctly recognizes when a SIGSEGV belongs to the guest via | ||
4 | set_helper_retaddr(). | ||
5 | 1 | ||
6 | Fixes: 3e8f1628e864 | ||
7 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | tcg/tci.c | 73 +++++++++++++++++++++---------------------------------- | ||
11 | 1 file changed, 28 insertions(+), 45 deletions(-) | ||
12 | |||
13 | diff --git a/tcg/tci.c b/tcg/tci.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tcg/tci.c | ||
16 | +++ b/tcg/tci.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) | ||
18 | return result; | ||
19 | } | ||
20 | |||
21 | -#ifdef CONFIG_SOFTMMU | ||
22 | -# define qemu_ld_ub \ | ||
23 | - helper_ret_ldub_mmu(env, taddr, oi, (uintptr_t)tb_ptr) | ||
24 | -# define qemu_ld_leuw \ | ||
25 | - helper_le_lduw_mmu(env, taddr, oi, (uintptr_t)tb_ptr) | ||
26 | -# define qemu_ld_leul \ | ||
27 | - helper_le_ldul_mmu(env, taddr, oi, (uintptr_t)tb_ptr) | ||
28 | -# define qemu_ld_leq \ | ||
29 | - helper_le_ldq_mmu(env, taddr, oi, (uintptr_t)tb_ptr) | ||
30 | -# define qemu_ld_beuw \ | ||
31 | - helper_be_lduw_mmu(env, taddr, oi, (uintptr_t)tb_ptr) | ||
32 | -# define qemu_ld_beul \ | ||
33 | - helper_be_ldul_mmu(env, taddr, oi, (uintptr_t)tb_ptr) | ||
34 | -# define qemu_ld_beq \ | ||
35 | - helper_be_ldq_mmu(env, taddr, oi, (uintptr_t)tb_ptr) | ||
36 | -# define qemu_st_b(X) \ | ||
37 | - helper_ret_stb_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) | ||
38 | -# define qemu_st_lew(X) \ | ||
39 | - helper_le_stw_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) | ||
40 | -# define qemu_st_lel(X) \ | ||
41 | - helper_le_stl_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) | ||
42 | -# define qemu_st_leq(X) \ | ||
43 | - helper_le_stq_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) | ||
44 | -# define qemu_st_bew(X) \ | ||
45 | - helper_be_stw_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) | ||
46 | -# define qemu_st_bel(X) \ | ||
47 | - helper_be_stl_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) | ||
48 | -# define qemu_st_beq(X) \ | ||
49 | - helper_be_stq_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) | ||
50 | -#else | ||
51 | -# define qemu_ld_ub ldub_p(g2h(taddr)) | ||
52 | -# define qemu_ld_leuw lduw_le_p(g2h(taddr)) | ||
53 | -# define qemu_ld_leul (uint32_t)ldl_le_p(g2h(taddr)) | ||
54 | -# define qemu_ld_leq ldq_le_p(g2h(taddr)) | ||
55 | -# define qemu_ld_beuw lduw_be_p(g2h(taddr)) | ||
56 | -# define qemu_ld_beul (uint32_t)ldl_be_p(g2h(taddr)) | ||
57 | -# define qemu_ld_beq ldq_be_p(g2h(taddr)) | ||
58 | -# define qemu_st_b(X) stb_p(g2h(taddr), X) | ||
59 | -# define qemu_st_lew(X) stw_le_p(g2h(taddr), X) | ||
60 | -# define qemu_st_lel(X) stl_le_p(g2h(taddr), X) | ||
61 | -# define qemu_st_leq(X) stq_le_p(g2h(taddr), X) | ||
62 | -# define qemu_st_bew(X) stw_be_p(g2h(taddr), X) | ||
63 | -# define qemu_st_bel(X) stl_be_p(g2h(taddr), X) | ||
64 | -# define qemu_st_beq(X) stq_be_p(g2h(taddr), X) | ||
65 | -#endif | ||
66 | +#define qemu_ld_ub \ | ||
67 | + cpu_ldub_mmuidx_ra(env, taddr, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
68 | +#define qemu_ld_leuw \ | ||
69 | + cpu_lduw_le_mmuidx_ra(env, taddr, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
70 | +#define qemu_ld_leul \ | ||
71 | + cpu_ldl_le_mmuidx_ra(env, taddr, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
72 | +#define qemu_ld_leq \ | ||
73 | + cpu_ldq_le_mmuidx_ra(env, taddr, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
74 | +#define qemu_ld_beuw \ | ||
75 | + cpu_lduw_be_mmuidx_ra(env, taddr, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
76 | +#define qemu_ld_beul \ | ||
77 | + cpu_ldl_be_mmuidx_ra(env, taddr, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
78 | +#define qemu_ld_beq \ | ||
79 | + cpu_ldq_be_mmuidx_ra(env, taddr, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
80 | +#define qemu_st_b(X) \ | ||
81 | + cpu_stb_mmuidx_ra(env, taddr, X, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
82 | +#define qemu_st_lew(X) \ | ||
83 | + cpu_stw_le_mmuidx_ra(env, taddr, X, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
84 | +#define qemu_st_lel(X) \ | ||
85 | + cpu_stl_le_mmuidx_ra(env, taddr, X, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
86 | +#define qemu_st_leq(X) \ | ||
87 | + cpu_stq_le_mmuidx_ra(env, taddr, X, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
88 | +#define qemu_st_bew(X) \ | ||
89 | + cpu_stw_be_mmuidx_ra(env, taddr, X, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
90 | +#define qemu_st_bel(X) \ | ||
91 | + cpu_stl_be_mmuidx_ra(env, taddr, X, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
92 | +#define qemu_st_beq(X) \ | ||
93 | + cpu_stq_be_mmuidx_ra(env, taddr, X, get_mmuidx(oi), (uintptr_t)tb_ptr) | ||
94 | |||
95 | #if TCG_TARGET_REG_BITS == 64 | ||
96 | # define CASE_32_64(x) \ | ||
97 | -- | ||
98 | 2.25.1 | ||
99 | |||
100 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Use CASE_32_64 and CASE_64 to reduce ifdefs and merge | ||
2 | cases that are identical between 32-bit and 64-bit hosts. | ||
3 | 1 | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-Id: <20210217202036.1724901-5-richard.henderson@linaro.org> | ||
7 | [PMD: Split patch as 1/5] | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-Id: <20210218232840.1760806-2-f4bug@amsat.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | tcg/tci/tcg-target.c.inc | 85 +++++++++++++++++----------------------- | ||
13 | 1 file changed, 37 insertions(+), 48 deletions(-) | ||
14 | |||
15 | diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tcg/tci/tcg-target.c.inc | ||
18 | +++ b/tcg/tci/tcg-target.c.inc | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) | ||
20 | old_code_ptr[1] = s->code_ptr - old_code_ptr; | ||
21 | } | ||
22 | |||
23 | +#if TCG_TARGET_REG_BITS == 64 | ||
24 | +# define CASE_32_64(x) \ | ||
25 | + case glue(glue(INDEX_op_, x), _i64): \ | ||
26 | + case glue(glue(INDEX_op_, x), _i32): | ||
27 | +# define CASE_64(x) \ | ||
28 | + case glue(glue(INDEX_op_, x), _i64): | ||
29 | +#else | ||
30 | +# define CASE_32_64(x) \ | ||
31 | + case glue(glue(INDEX_op_, x), _i32): | ||
32 | +# define CASE_64(x) | ||
33 | +#endif | ||
34 | + | ||
35 | static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
36 | const int *const_args) | ||
37 | { | ||
38 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
39 | case INDEX_op_exit_tb: | ||
40 | tcg_out64(s, args[0]); | ||
41 | break; | ||
42 | + | ||
43 | case INDEX_op_goto_tb: | ||
44 | if (s->tb_jmp_insn_offset) { | ||
45 | /* Direct jump method. */ | ||
46 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
47 | tcg_debug_assert(args[2] == (int32_t)args[2]); | ||
48 | tcg_out32(s, args[2]); | ||
49 | break; | ||
50 | - case INDEX_op_add_i32: | ||
51 | - case INDEX_op_sub_i32: | ||
52 | - case INDEX_op_mul_i32: | ||
53 | - case INDEX_op_and_i32: | ||
54 | - case INDEX_op_andc_i32: /* Optional (TCG_TARGET_HAS_andc_i32). */ | ||
55 | - case INDEX_op_eqv_i32: /* Optional (TCG_TARGET_HAS_eqv_i32). */ | ||
56 | - case INDEX_op_nand_i32: /* Optional (TCG_TARGET_HAS_nand_i32). */ | ||
57 | - case INDEX_op_nor_i32: /* Optional (TCG_TARGET_HAS_nor_i32). */ | ||
58 | - case INDEX_op_or_i32: | ||
59 | - case INDEX_op_orc_i32: /* Optional (TCG_TARGET_HAS_orc_i32). */ | ||
60 | - case INDEX_op_xor_i32: | ||
61 | - case INDEX_op_shl_i32: | ||
62 | - case INDEX_op_shr_i32: | ||
63 | - case INDEX_op_sar_i32: | ||
64 | - case INDEX_op_rotl_i32: /* Optional (TCG_TARGET_HAS_rot_i32). */ | ||
65 | - case INDEX_op_rotr_i32: /* Optional (TCG_TARGET_HAS_rot_i32). */ | ||
66 | + | ||
67 | + CASE_32_64(add) | ||
68 | + CASE_32_64(sub) | ||
69 | + CASE_32_64(mul) | ||
70 | + CASE_32_64(and) | ||
71 | + CASE_32_64(or) | ||
72 | + CASE_32_64(xor) | ||
73 | + CASE_32_64(andc) /* Optional (TCG_TARGET_HAS_andc_*). */ | ||
74 | + CASE_32_64(orc) /* Optional (TCG_TARGET_HAS_orc_*). */ | ||
75 | + CASE_32_64(eqv) /* Optional (TCG_TARGET_HAS_eqv_*). */ | ||
76 | + CASE_32_64(nand) /* Optional (TCG_TARGET_HAS_nand_*). */ | ||
77 | + CASE_32_64(nor) /* Optional (TCG_TARGET_HAS_nor_*). */ | ||
78 | + CASE_32_64(shl) | ||
79 | + CASE_32_64(shr) | ||
80 | + CASE_32_64(sar) | ||
81 | + CASE_32_64(rotl) /* Optional (TCG_TARGET_HAS_rot_*). */ | ||
82 | + CASE_32_64(rotr) /* Optional (TCG_TARGET_HAS_rot_*). */ | ||
83 | + CASE_32_64(div) /* Optional (TCG_TARGET_HAS_div_*). */ | ||
84 | + CASE_32_64(divu) /* Optional (TCG_TARGET_HAS_div_*). */ | ||
85 | + CASE_32_64(rem) /* Optional (TCG_TARGET_HAS_div_*). */ | ||
86 | + CASE_32_64(remu) /* Optional (TCG_TARGET_HAS_div_*). */ | ||
87 | tcg_out_r(s, args[0]); | ||
88 | tcg_out_r(s, args[1]); | ||
89 | tcg_out_r(s, args[2]); | ||
90 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
91 | break; | ||
92 | |||
93 | #if TCG_TARGET_REG_BITS == 64 | ||
94 | - case INDEX_op_add_i64: | ||
95 | - case INDEX_op_sub_i64: | ||
96 | - case INDEX_op_mul_i64: | ||
97 | - case INDEX_op_and_i64: | ||
98 | - case INDEX_op_andc_i64: /* Optional (TCG_TARGET_HAS_andc_i64). */ | ||
99 | - case INDEX_op_eqv_i64: /* Optional (TCG_TARGET_HAS_eqv_i64). */ | ||
100 | - case INDEX_op_nand_i64: /* Optional (TCG_TARGET_HAS_nand_i64). */ | ||
101 | - case INDEX_op_nor_i64: /* Optional (TCG_TARGET_HAS_nor_i64). */ | ||
102 | - case INDEX_op_or_i64: | ||
103 | - case INDEX_op_orc_i64: /* Optional (TCG_TARGET_HAS_orc_i64). */ | ||
104 | - case INDEX_op_xor_i64: | ||
105 | - case INDEX_op_shl_i64: | ||
106 | - case INDEX_op_shr_i64: | ||
107 | - case INDEX_op_sar_i64: | ||
108 | - case INDEX_op_rotl_i64: /* Optional (TCG_TARGET_HAS_rot_i64). */ | ||
109 | - case INDEX_op_rotr_i64: /* Optional (TCG_TARGET_HAS_rot_i64). */ | ||
110 | - case INDEX_op_div_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ | ||
111 | - case INDEX_op_divu_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ | ||
112 | - case INDEX_op_rem_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ | ||
113 | - case INDEX_op_remu_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ | ||
114 | - tcg_out_r(s, args[0]); | ||
115 | - tcg_out_r(s, args[1]); | ||
116 | - tcg_out_r(s, args[2]); | ||
117 | - break; | ||
118 | case INDEX_op_deposit_i64: /* Optional (TCG_TARGET_HAS_deposit_i64). */ | ||
119 | tcg_out_r(s, args[0]); | ||
120 | tcg_out_r(s, args[1]); | ||
121 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
122 | tcg_out_r(s, args[0]); | ||
123 | tcg_out_r(s, args[1]); | ||
124 | break; | ||
125 | - case INDEX_op_div_i32: /* Optional (TCG_TARGET_HAS_div_i32). */ | ||
126 | - case INDEX_op_divu_i32: /* Optional (TCG_TARGET_HAS_div_i32). */ | ||
127 | - case INDEX_op_rem_i32: /* Optional (TCG_TARGET_HAS_div_i32). */ | ||
128 | - case INDEX_op_remu_i32: /* Optional (TCG_TARGET_HAS_div_i32). */ | ||
129 | - tcg_out_r(s, args[0]); | ||
130 | - tcg_out_r(s, args[1]); | ||
131 | - tcg_out_r(s, args[2]); | ||
132 | - break; | ||
133 | + | ||
134 | #if TCG_TARGET_REG_BITS == 32 | ||
135 | case INDEX_op_add2_i32: | ||
136 | case INDEX_op_sub2_i32: | ||
137 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
138 | } | ||
139 | tcg_out_i(s, *args++); | ||
140 | break; | ||
141 | + | ||
142 | case INDEX_op_mb: | ||
143 | break; | ||
144 | + | ||
145 | case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ | ||
146 | case INDEX_op_mov_i64: | ||
147 | case INDEX_op_call: /* Always emitted via tcg_out_call. */ | ||
148 | -- | ||
149 | 2.25.1 | ||
150 | |||
151 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Use CASE_32_64 and CASE_64 to reduce ifdefs and merge | ||
2 | cases that are identical between 32-bit and 64-bit hosts. | ||
3 | 1 | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-Id: <20210217202036.1724901-5-richard.henderson@linaro.org> | ||
7 | [PMD: Split patch as 2/5] | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-Id: <20210218232840.1760806-3-f4bug@amsat.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | tcg/tci/tcg-target.c.inc | 35 ++++++++++++++--------------------- | ||
13 | 1 file changed, 14 insertions(+), 21 deletions(-) | ||
14 | |||
15 | diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tcg/tci/tcg-target.c.inc | ||
18 | +++ b/tcg/tci/tcg-target.c.inc | ||
19 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
20 | tcg_out8(s, args[2]); /* condition */ | ||
21 | tci_out_label(s, arg_label(args[3])); | ||
22 | break; | ||
23 | - case INDEX_op_bswap16_i64: /* Optional (TCG_TARGET_HAS_bswap16_i64). */ | ||
24 | - case INDEX_op_bswap32_i64: /* Optional (TCG_TARGET_HAS_bswap32_i64). */ | ||
25 | - case INDEX_op_bswap64_i64: /* Optional (TCG_TARGET_HAS_bswap64_i64). */ | ||
26 | - case INDEX_op_not_i64: /* Optional (TCG_TARGET_HAS_not_i64). */ | ||
27 | - case INDEX_op_neg_i64: /* Optional (TCG_TARGET_HAS_neg_i64). */ | ||
28 | - case INDEX_op_ext8s_i64: /* Optional (TCG_TARGET_HAS_ext8s_i64). */ | ||
29 | - case INDEX_op_ext8u_i64: /* Optional (TCG_TARGET_HAS_ext8u_i64). */ | ||
30 | - case INDEX_op_ext16s_i64: /* Optional (TCG_TARGET_HAS_ext16s_i64). */ | ||
31 | - case INDEX_op_ext16u_i64: /* Optional (TCG_TARGET_HAS_ext16u_i64). */ | ||
32 | - case INDEX_op_ext32s_i64: /* Optional (TCG_TARGET_HAS_ext32s_i64). */ | ||
33 | - case INDEX_op_ext32u_i64: /* Optional (TCG_TARGET_HAS_ext32u_i64). */ | ||
34 | - case INDEX_op_ext_i32_i64: | ||
35 | - case INDEX_op_extu_i32_i64: | ||
36 | #endif /* TCG_TARGET_REG_BITS == 64 */ | ||
37 | - case INDEX_op_neg_i32: /* Optional (TCG_TARGET_HAS_neg_i32). */ | ||
38 | - case INDEX_op_not_i32: /* Optional (TCG_TARGET_HAS_not_i32). */ | ||
39 | - case INDEX_op_ext8s_i32: /* Optional (TCG_TARGET_HAS_ext8s_i32). */ | ||
40 | - case INDEX_op_ext16s_i32: /* Optional (TCG_TARGET_HAS_ext16s_i32). */ | ||
41 | - case INDEX_op_ext8u_i32: /* Optional (TCG_TARGET_HAS_ext8u_i32). */ | ||
42 | - case INDEX_op_ext16u_i32: /* Optional (TCG_TARGET_HAS_ext16u_i32). */ | ||
43 | - case INDEX_op_bswap16_i32: /* Optional (TCG_TARGET_HAS_bswap16_i32). */ | ||
44 | - case INDEX_op_bswap32_i32: /* Optional (TCG_TARGET_HAS_bswap32_i32). */ | ||
45 | + | ||
46 | + CASE_32_64(neg) /* Optional (TCG_TARGET_HAS_neg_*). */ | ||
47 | + CASE_32_64(not) /* Optional (TCG_TARGET_HAS_not_*). */ | ||
48 | + CASE_32_64(ext8s) /* Optional (TCG_TARGET_HAS_ext8s_*). */ | ||
49 | + CASE_32_64(ext8u) /* Optional (TCG_TARGET_HAS_ext8u_*). */ | ||
50 | + CASE_32_64(ext16s) /* Optional (TCG_TARGET_HAS_ext16s_*). */ | ||
51 | + CASE_32_64(ext16u) /* Optional (TCG_TARGET_HAS_ext16u_*). */ | ||
52 | + CASE_64(ext32s) /* Optional (TCG_TARGET_HAS_ext32s_i64). */ | ||
53 | + CASE_64(ext32u) /* Optional (TCG_TARGET_HAS_ext32u_i64). */ | ||
54 | + CASE_64(ext_i32) | ||
55 | + CASE_64(extu_i32) | ||
56 | + CASE_32_64(bswap16) /* Optional (TCG_TARGET_HAS_bswap16_*). */ | ||
57 | + CASE_32_64(bswap32) /* Optional (TCG_TARGET_HAS_bswap32_*). */ | ||
58 | + CASE_64(bswap64) /* Optional (TCG_TARGET_HAS_bswap64_i64). */ | ||
59 | tcg_out_r(s, args[0]); | ||
60 | tcg_out_r(s, args[1]); | ||
61 | break; | ||
62 | -- | ||
63 | 2.25.1 | ||
64 | |||
65 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Use CASE_32_64 and CASE_64 to reduce ifdefs and merge | ||
2 | cases that are identical between 32-bit and 64-bit hosts. | ||
3 | 1 | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-Id: <20210217202036.1724901-5-richard.henderson@linaro.org> | ||
7 | [PMD: Split patch as 3/5] | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-Id: <20210218232840.1760806-4-f4bug@amsat.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | tcg/tci/tcg-target.c.inc | 12 ++---------- | ||
13 | 1 file changed, 2 insertions(+), 10 deletions(-) | ||
14 | |||
15 | diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tcg/tci/tcg-target.c.inc | ||
18 | +++ b/tcg/tci/tcg-target.c.inc | ||
19 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
20 | tcg_out_r(s, args[1]); | ||
21 | tcg_out_r(s, args[2]); | ||
22 | break; | ||
23 | - case INDEX_op_deposit_i32: /* Optional (TCG_TARGET_HAS_deposit_i32). */ | ||
24 | + | ||
25 | + CASE_32_64(deposit) /* Optional (TCG_TARGET_HAS_deposit_*). */ | ||
26 | tcg_out_r(s, args[0]); | ||
27 | tcg_out_r(s, args[1]); | ||
28 | tcg_out_r(s, args[2]); | ||
29 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
30 | break; | ||
31 | |||
32 | #if TCG_TARGET_REG_BITS == 64 | ||
33 | - case INDEX_op_deposit_i64: /* Optional (TCG_TARGET_HAS_deposit_i64). */ | ||
34 | - tcg_out_r(s, args[0]); | ||
35 | - tcg_out_r(s, args[1]); | ||
36 | - tcg_out_r(s, args[2]); | ||
37 | - tcg_debug_assert(args[3] <= UINT8_MAX); | ||
38 | - tcg_out8(s, args[3]); | ||
39 | - tcg_debug_assert(args[4] <= UINT8_MAX); | ||
40 | - tcg_out8(s, args[4]); | ||
41 | - break; | ||
42 | case INDEX_op_brcond_i64: | ||
43 | tcg_out_r(s, args[0]); | ||
44 | tcg_out_r(s, args[1]); | ||
45 | -- | ||
46 | 2.25.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Use CASE_32_64 and CASE_64 to reduce ifdefs and merge | ||
2 | cases that are identical between 32-bit and 64-bit hosts. | ||
3 | 1 | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-Id: <20210217202036.1724901-5-richard.henderson@linaro.org> | ||
7 | [PMD: Split patch as 4/5] | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-Id: <20210218232840.1760806-5-f4bug@amsat.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | tcg/tci/tcg-target.c.inc | 23 ++++++----------------- | ||
13 | 1 file changed, 6 insertions(+), 17 deletions(-) | ||
14 | |||
15 | diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tcg/tci/tcg-target.c.inc | ||
18 | +++ b/tcg/tci/tcg-target.c.inc | ||
19 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
20 | } | ||
21 | set_jmp_reset_offset(s, args[0]); | ||
22 | break; | ||
23 | + | ||
24 | case INDEX_op_br: | ||
25 | tci_out_label(s, arg_label(args[0])); | ||
26 | break; | ||
27 | - case INDEX_op_setcond_i32: | ||
28 | + | ||
29 | + CASE_32_64(setcond) | ||
30 | tcg_out_r(s, args[0]); | ||
31 | tcg_out_r(s, args[1]); | ||
32 | tcg_out_r(s, args[2]); | ||
33 | tcg_out8(s, args[3]); /* condition */ | ||
34 | break; | ||
35 | + | ||
36 | #if TCG_TARGET_REG_BITS == 32 | ||
37 | case INDEX_op_setcond2_i32: | ||
38 | /* setcond2_i32 cond, t0, t1_low, t1_high, t2_low, t2_high */ | ||
39 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
40 | tcg_out_r(s, args[4]); | ||
41 | tcg_out8(s, args[5]); /* condition */ | ||
42 | break; | ||
43 | -#elif TCG_TARGET_REG_BITS == 64 | ||
44 | - case INDEX_op_setcond_i64: | ||
45 | - tcg_out_r(s, args[0]); | ||
46 | - tcg_out_r(s, args[1]); | ||
47 | - tcg_out_r(s, args[2]); | ||
48 | - tcg_out8(s, args[3]); /* condition */ | ||
49 | - break; | ||
50 | #endif | ||
51 | case INDEX_op_ld8u_i32: | ||
52 | case INDEX_op_ld8s_i32: | ||
53 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
54 | tcg_out8(s, args[4]); | ||
55 | break; | ||
56 | |||
57 | -#if TCG_TARGET_REG_BITS == 64 | ||
58 | - case INDEX_op_brcond_i64: | ||
59 | + CASE_32_64(brcond) | ||
60 | tcg_out_r(s, args[0]); | ||
61 | tcg_out_r(s, args[1]); | ||
62 | tcg_out8(s, args[2]); /* condition */ | ||
63 | tci_out_label(s, arg_label(args[3])); | ||
64 | break; | ||
65 | -#endif /* TCG_TARGET_REG_BITS == 64 */ | ||
66 | |||
67 | CASE_32_64(neg) /* Optional (TCG_TARGET_HAS_neg_*). */ | ||
68 | CASE_32_64(not) /* Optional (TCG_TARGET_HAS_not_*). */ | ||
69 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
70 | tcg_out_r(s, args[3]); | ||
71 | break; | ||
72 | #endif | ||
73 | - case INDEX_op_brcond_i32: | ||
74 | - tcg_out_r(s, args[0]); | ||
75 | - tcg_out_r(s, args[1]); | ||
76 | - tcg_out8(s, args[2]); /* condition */ | ||
77 | - tci_out_label(s, arg_label(args[3])); | ||
78 | - break; | ||
79 | + | ||
80 | case INDEX_op_qemu_ld_i32: | ||
81 | tcg_out_r(s, *args++); | ||
82 | tcg_out_r(s, *args++); | ||
83 | -- | ||
84 | 2.25.1 | ||
85 | |||
86 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Use CASE_32_64 and CASE_64 to reduce ifdefs and merge | ||
2 | cases that are identical between 32-bit and 64-bit hosts. | ||
3 | 1 | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-Id: <20210217202036.1724901-5-richard.henderson@linaro.org> | ||
7 | [PMD: Split patch as 5/5] | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-Id: <20210218232840.1760806-6-f4bug@amsat.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | tcg/tci/tcg-target.c.inc | 49 ++++++++++++---------------------------- | ||
13 | 1 file changed, 14 insertions(+), 35 deletions(-) | ||
14 | |||
15 | diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tcg/tci/tcg-target.c.inc | ||
18 | +++ b/tcg/tci/tcg-target.c.inc | ||
19 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
20 | tcg_out8(s, args[5]); /* condition */ | ||
21 | break; | ||
22 | #endif | ||
23 | - case INDEX_op_ld8u_i32: | ||
24 | - case INDEX_op_ld8s_i32: | ||
25 | - case INDEX_op_ld16u_i32: | ||
26 | - case INDEX_op_ld16s_i32: | ||
27 | + | ||
28 | + CASE_32_64(ld8u) | ||
29 | + CASE_32_64(ld8s) | ||
30 | + CASE_32_64(ld16u) | ||
31 | + CASE_32_64(ld16s) | ||
32 | case INDEX_op_ld_i32: | ||
33 | - case INDEX_op_st8_i32: | ||
34 | - case INDEX_op_st16_i32: | ||
35 | + CASE_64(ld32u) | ||
36 | + CASE_64(ld32s) | ||
37 | + CASE_64(ld) | ||
38 | + CASE_32_64(st8) | ||
39 | + CASE_32_64(st16) | ||
40 | case INDEX_op_st_i32: | ||
41 | - case INDEX_op_ld8u_i64: | ||
42 | - case INDEX_op_ld8s_i64: | ||
43 | - case INDEX_op_ld16u_i64: | ||
44 | - case INDEX_op_ld16s_i64: | ||
45 | - case INDEX_op_ld32u_i64: | ||
46 | - case INDEX_op_ld32s_i64: | ||
47 | - case INDEX_op_ld_i64: | ||
48 | - case INDEX_op_st8_i64: | ||
49 | - case INDEX_op_st16_i64: | ||
50 | - case INDEX_op_st32_i64: | ||
51 | - case INDEX_op_st_i64: | ||
52 | + CASE_64(st32) | ||
53 | + CASE_64(st) | ||
54 | stack_bounds_check(args[1], args[2]); | ||
55 | tcg_out_r(s, args[0]); | ||
56 | tcg_out_r(s, args[1]); | ||
57 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
58 | #endif | ||
59 | |||
60 | case INDEX_op_qemu_ld_i32: | ||
61 | - tcg_out_r(s, *args++); | ||
62 | - tcg_out_r(s, *args++); | ||
63 | - if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) { | ||
64 | - tcg_out_r(s, *args++); | ||
65 | - } | ||
66 | - tcg_out_i(s, *args++); | ||
67 | - break; | ||
68 | - case INDEX_op_qemu_ld_i64: | ||
69 | - tcg_out_r(s, *args++); | ||
70 | - if (TCG_TARGET_REG_BITS == 32) { | ||
71 | - tcg_out_r(s, *args++); | ||
72 | - } | ||
73 | - tcg_out_r(s, *args++); | ||
74 | - if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) { | ||
75 | - tcg_out_r(s, *args++); | ||
76 | - } | ||
77 | - tcg_out_i(s, *args++); | ||
78 | - break; | ||
79 | case INDEX_op_qemu_st_i32: | ||
80 | tcg_out_r(s, *args++); | ||
81 | tcg_out_r(s, *args++); | ||
82 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
83 | } | ||
84 | tcg_out_i(s, *args++); | ||
85 | break; | ||
86 | + | ||
87 | + case INDEX_op_qemu_ld_i64: | ||
88 | case INDEX_op_qemu_st_i64: | ||
89 | tcg_out_r(s, *args++); | ||
90 | if (TCG_TARGET_REG_BITS == 32) { | ||
91 | -- | ||
92 | 2.25.1 | ||
93 | |||
94 | diff view generated by jsdifflib |
1 | Use explicit casts for ext8s opcodes. | 1 | The value previously chosen overlaps GUSA_MASK. |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Rename all DELAY_SLOT_* and GUSA_* defines to emphasize |
4 | that they are included in TB_FLAGs. Add aliases for the | ||
5 | FPSCR and SR bits that are included in TB_FLAGS, so that | ||
6 | we don't accidentally reassign those bits. | ||
7 | |||
8 | Fixes: 4da06fb3062 ("target/sh4: Implement prctl_unalign_sigbus") | ||
9 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/856 | ||
10 | Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | --- | 12 | --- |
6 | tcg/tci.c | 25 ++++--------------------- | 13 | target/sh4/cpu.h | 56 +++++++++++++------------ |
7 | 1 file changed, 4 insertions(+), 21 deletions(-) | 14 | linux-user/sh4/signal.c | 6 +-- |
15 | target/sh4/cpu.c | 6 +-- | ||
16 | target/sh4/helper.c | 6 +-- | ||
17 | target/sh4/translate.c | 90 ++++++++++++++++++++++------------------- | ||
18 | 5 files changed, 88 insertions(+), 76 deletions(-) | ||
8 | 19 | ||
9 | diff --git a/tcg/tci.c b/tcg/tci.c | 20 | diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h |
10 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/tcg/tci.c | 22 | --- a/target/sh4/cpu.h |
12 | +++ b/tcg/tci.c | 23 | +++ b/target/sh4/cpu.h |
13 | @@ -XXX,XX +XXX,XX @@ static tcg_target_ulong tci_read_reg(const tcg_target_ulong *regs, TCGReg index) | 24 | @@ -XXX,XX +XXX,XX @@ |
14 | return regs[index]; | 25 | #define FPSCR_RM_NEAREST (0 << 0) |
15 | } | 26 | #define FPSCR_RM_ZERO (1 << 0) |
16 | 27 | ||
17 | -#if TCG_TARGET_HAS_ext8s_i32 || TCG_TARGET_HAS_ext8s_i64 | 28 | -#define DELAY_SLOT_MASK 0x7 |
18 | -static int8_t tci_read_reg8s(const tcg_target_ulong *regs, TCGReg index) | 29 | -#define DELAY_SLOT (1 << 0) |
19 | -{ | 30 | -#define DELAY_SLOT_CONDITIONAL (1 << 1) |
20 | - return (int8_t)tci_read_reg(regs, index); | 31 | -#define DELAY_SLOT_RTE (1 << 2) |
21 | -} | 32 | +#define TB_FLAG_DELAY_SLOT (1 << 0) |
33 | +#define TB_FLAG_DELAY_SLOT_COND (1 << 1) | ||
34 | +#define TB_FLAG_DELAY_SLOT_RTE (1 << 2) | ||
35 | +#define TB_FLAG_PENDING_MOVCA (1 << 3) | ||
36 | +#define TB_FLAG_GUSA_SHIFT 4 /* [11:4] */ | ||
37 | +#define TB_FLAG_GUSA_EXCLUSIVE (1 << 12) | ||
38 | +#define TB_FLAG_UNALIGN (1 << 13) | ||
39 | +#define TB_FLAG_SR_FD (1 << SR_FD) /* 15 */ | ||
40 | +#define TB_FLAG_FPSCR_PR FPSCR_PR /* 19 */ | ||
41 | +#define TB_FLAG_FPSCR_SZ FPSCR_SZ /* 20 */ | ||
42 | +#define TB_FLAG_FPSCR_FR FPSCR_FR /* 21 */ | ||
43 | +#define TB_FLAG_SR_RB (1 << SR_RB) /* 29 */ | ||
44 | +#define TB_FLAG_SR_MD (1 << SR_MD) /* 30 */ | ||
45 | |||
46 | -#define TB_FLAG_PENDING_MOVCA (1 << 3) | ||
47 | -#define TB_FLAG_UNALIGN (1 << 4) | ||
48 | - | ||
49 | -#define GUSA_SHIFT 4 | ||
50 | -#ifdef CONFIG_USER_ONLY | ||
51 | -#define GUSA_EXCLUSIVE (1 << 12) | ||
52 | -#define GUSA_MASK ((0xff << GUSA_SHIFT) | GUSA_EXCLUSIVE) | ||
53 | -#else | ||
54 | -/* Provide dummy versions of the above to allow tests against tbflags | ||
55 | - to be elided while avoiding ifdefs. */ | ||
56 | -#define GUSA_EXCLUSIVE 0 | ||
57 | -#define GUSA_MASK 0 | ||
22 | -#endif | 58 | -#endif |
23 | - | 59 | - |
24 | #if TCG_TARGET_HAS_ext16s_i32 || TCG_TARGET_HAS_ext16s_i64 | 60 | -#define TB_FLAG_ENVFLAGS_MASK (DELAY_SLOT_MASK | GUSA_MASK) |
25 | static int16_t tci_read_reg16s(const tcg_target_ulong *regs, TCGReg index) | 61 | +#define TB_FLAG_DELAY_SLOT_MASK (TB_FLAG_DELAY_SLOT | \ |
62 | + TB_FLAG_DELAY_SLOT_COND | \ | ||
63 | + TB_FLAG_DELAY_SLOT_RTE) | ||
64 | +#define TB_FLAG_GUSA_MASK ((0xff << TB_FLAG_GUSA_SHIFT) | \ | ||
65 | + TB_FLAG_GUSA_EXCLUSIVE) | ||
66 | +#define TB_FLAG_FPSCR_MASK (TB_FLAG_FPSCR_PR | \ | ||
67 | + TB_FLAG_FPSCR_SZ | \ | ||
68 | + TB_FLAG_FPSCR_FR) | ||
69 | +#define TB_FLAG_SR_MASK (TB_FLAG_SR_FD | \ | ||
70 | + TB_FLAG_SR_RB | \ | ||
71 | + TB_FLAG_SR_MD) | ||
72 | +#define TB_FLAG_ENVFLAGS_MASK (TB_FLAG_DELAY_SLOT_MASK | \ | ||
73 | + TB_FLAG_GUSA_MASK) | ||
74 | |||
75 | typedef struct tlb_t { | ||
76 | uint32_t vpn; /* virtual page number */ | ||
77 | @@ -XXX,XX +XXX,XX @@ static inline int cpu_mmu_index (CPUSH4State *env, bool ifetch) | ||
26 | { | 78 | { |
27 | @@ -XXX,XX +XXX,XX @@ tci_read_r(const tcg_target_ulong *regs, const uint8_t **tb_ptr) | 79 | /* The instruction in a RTE delay slot is fetched in privileged |
28 | return value; | 80 | mode, but executed in user mode. */ |
81 | - if (ifetch && (env->flags & DELAY_SLOT_RTE)) { | ||
82 | + if (ifetch && (env->flags & TB_FLAG_DELAY_SLOT_RTE)) { | ||
83 | return 0; | ||
84 | } else { | ||
85 | return (env->sr & (1u << SR_MD)) == 0 ? 1 : 0; | ||
86 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_get_tb_cpu_state(CPUSH4State *env, target_ulong *pc, | ||
87 | { | ||
88 | *pc = env->pc; | ||
89 | /* For a gUSA region, notice the end of the region. */ | ||
90 | - *cs_base = env->flags & GUSA_MASK ? env->gregs[0] : 0; | ||
91 | - *flags = env->flags /* TB_FLAG_ENVFLAGS_MASK: bits 0-2, 4-12 */ | ||
92 | - | (env->fpscr & (FPSCR_FR | FPSCR_SZ | FPSCR_PR)) /* Bits 19-21 */ | ||
93 | - | (env->sr & ((1u << SR_MD) | (1u << SR_RB))) /* Bits 29-30 */ | ||
94 | - | (env->sr & (1u << SR_FD)) /* Bit 15 */ | ||
95 | + *cs_base = env->flags & TB_FLAG_GUSA_MASK ? env->gregs[0] : 0; | ||
96 | + *flags = env->flags | ||
97 | + | (env->fpscr & TB_FLAG_FPSCR_MASK) | ||
98 | + | (env->sr & TB_FLAG_SR_MASK) | ||
99 | | (env->movcal_backup ? TB_FLAG_PENDING_MOVCA : 0); /* Bit 3 */ | ||
100 | #ifdef CONFIG_USER_ONLY | ||
101 | *flags |= TB_FLAG_UNALIGN * !env_cpu(env)->prctl_unalign_sigbus; | ||
102 | diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/linux-user/sh4/signal.c | ||
105 | +++ b/linux-user/sh4/signal.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static void restore_sigcontext(CPUSH4State *regs, struct target_sigcontext *sc) | ||
107 | __get_user(regs->fpul, &sc->sc_fpul); | ||
108 | |||
109 | regs->tra = -1; /* disable syscall checks */ | ||
110 | - regs->flags &= ~(DELAY_SLOT_MASK | GUSA_MASK); | ||
111 | + regs->flags = 0; | ||
29 | } | 112 | } |
30 | 113 | ||
31 | -#if TCG_TARGET_HAS_ext8s_i32 || TCG_TARGET_HAS_ext8s_i64 | 114 | void setup_frame(int sig, struct target_sigaction *ka, |
32 | -/* Read indexed register (8 bit signed) from bytecode. */ | 115 | @@ -XXX,XX +XXX,XX @@ void setup_frame(int sig, struct target_sigaction *ka, |
33 | -static int8_t tci_read_r8s(const tcg_target_ulong *regs, const uint8_t **tb_ptr) | 116 | regs->gregs[5] = 0; |
34 | -{ | 117 | regs->gregs[6] = frame_addr += offsetof(typeof(*frame), sc); |
35 | - int8_t value = tci_read_reg8s(regs, **tb_ptr); | 118 | regs->pc = (unsigned long) ka->_sa_handler; |
36 | - *tb_ptr += 1; | 119 | - regs->flags &= ~(DELAY_SLOT_MASK | GUSA_MASK); |
37 | - return value; | 120 | + regs->flags &= ~(TB_FLAG_DELAY_SLOT_MASK | TB_FLAG_GUSA_MASK); |
38 | -} | 121 | |
39 | -#endif | 122 | unlock_user_struct(frame, frame_addr, 1); |
40 | - | 123 | return; |
41 | /* Read indexed register (16 bit) from bytecode. */ | 124 | @@ -XXX,XX +XXX,XX @@ void setup_rt_frame(int sig, struct target_sigaction *ka, |
42 | static uint16_t tci_read_r16(const tcg_target_ulong *regs, | 125 | regs->gregs[5] = frame_addr + offsetof(typeof(*frame), info); |
43 | const uint8_t **tb_ptr) | 126 | regs->gregs[6] = frame_addr + offsetof(typeof(*frame), uc); |
44 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 127 | regs->pc = (unsigned long) ka->_sa_handler; |
45 | #if TCG_TARGET_HAS_ext8s_i32 | 128 | - regs->flags &= ~(DELAY_SLOT_MASK | GUSA_MASK); |
46 | case INDEX_op_ext8s_i32: | 129 | + regs->flags &= ~(TB_FLAG_DELAY_SLOT_MASK | TB_FLAG_GUSA_MASK); |
47 | t0 = *tb_ptr++; | 130 | |
48 | - t1 = tci_read_r8s(regs, &tb_ptr); | 131 | unlock_user_struct(frame, frame_addr, 1); |
49 | - tci_write_reg(regs, t0, t1); | 132 | return; |
50 | + t1 = tci_read_r(regs, &tb_ptr); | 133 | diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c |
51 | + tci_write_reg(regs, t0, (int8_t)t1); | 134 | index XXXXXXX..XXXXXXX 100644 |
52 | break; | 135 | --- a/target/sh4/cpu.c |
136 | +++ b/target/sh4/cpu.c | ||
137 | @@ -XXX,XX +XXX,XX @@ static void superh_cpu_synchronize_from_tb(CPUState *cs, | ||
138 | SuperHCPU *cpu = SUPERH_CPU(cs); | ||
139 | |||
140 | cpu->env.pc = tb_pc(tb); | ||
141 | - cpu->env.flags = tb->flags & TB_FLAG_ENVFLAGS_MASK; | ||
142 | + cpu->env.flags = tb->flags; | ||
143 | } | ||
144 | |||
145 | #ifndef CONFIG_USER_ONLY | ||
146 | @@ -XXX,XX +XXX,XX @@ static bool superh_io_recompile_replay_branch(CPUState *cs, | ||
147 | SuperHCPU *cpu = SUPERH_CPU(cs); | ||
148 | CPUSH4State *env = &cpu->env; | ||
149 | |||
150 | - if ((env->flags & ((DELAY_SLOT | DELAY_SLOT_CONDITIONAL))) != 0 | ||
151 | + if ((env->flags & (TB_FLAG_DELAY_SLOT | TB_FLAG_DELAY_SLOT_COND)) | ||
152 | && env->pc != tb_pc(tb)) { | ||
153 | env->pc -= 2; | ||
154 | - env->flags &= ~(DELAY_SLOT | DELAY_SLOT_CONDITIONAL); | ||
155 | + env->flags &= ~(TB_FLAG_DELAY_SLOT | TB_FLAG_DELAY_SLOT_COND); | ||
156 | return true; | ||
157 | } | ||
158 | return false; | ||
159 | diff --git a/target/sh4/helper.c b/target/sh4/helper.c | ||
160 | index XXXXXXX..XXXXXXX 100644 | ||
161 | --- a/target/sh4/helper.c | ||
162 | +++ b/target/sh4/helper.c | ||
163 | @@ -XXX,XX +XXX,XX @@ void superh_cpu_do_interrupt(CPUState *cs) | ||
164 | env->sr |= (1u << SR_BL) | (1u << SR_MD) | (1u << SR_RB); | ||
165 | env->lock_addr = -1; | ||
166 | |||
167 | - if (env->flags & DELAY_SLOT_MASK) { | ||
168 | + if (env->flags & TB_FLAG_DELAY_SLOT_MASK) { | ||
169 | /* Branch instruction should be executed again before delay slot. */ | ||
170 | env->spc -= 2; | ||
171 | /* Clear flags for exception/interrupt routine. */ | ||
172 | - env->flags &= ~DELAY_SLOT_MASK; | ||
173 | + env->flags &= ~TB_FLAG_DELAY_SLOT_MASK; | ||
174 | } | ||
175 | |||
176 | if (do_exp) { | ||
177 | @@ -XXX,XX +XXX,XX @@ bool superh_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
178 | CPUSH4State *env = &cpu->env; | ||
179 | |||
180 | /* Delay slots are indivisible, ignore interrupts */ | ||
181 | - if (env->flags & DELAY_SLOT_MASK) { | ||
182 | + if (env->flags & TB_FLAG_DELAY_SLOT_MASK) { | ||
183 | return false; | ||
184 | } else { | ||
185 | superh_cpu_do_interrupt(cs); | ||
186 | diff --git a/target/sh4/translate.c b/target/sh4/translate.c | ||
187 | index XXXXXXX..XXXXXXX 100644 | ||
188 | --- a/target/sh4/translate.c | ||
189 | +++ b/target/sh4/translate.c | ||
190 | @@ -XXX,XX +XXX,XX @@ void superh_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
191 | i, env->gregs[i], i + 1, env->gregs[i + 1], | ||
192 | i + 2, env->gregs[i + 2], i + 3, env->gregs[i + 3]); | ||
193 | } | ||
194 | - if (env->flags & DELAY_SLOT) { | ||
195 | + if (env->flags & TB_FLAG_DELAY_SLOT) { | ||
196 | qemu_printf("in delay slot (delayed_pc=0x%08x)\n", | ||
197 | env->delayed_pc); | ||
198 | - } else if (env->flags & DELAY_SLOT_CONDITIONAL) { | ||
199 | + } else if (env->flags & TB_FLAG_DELAY_SLOT_COND) { | ||
200 | qemu_printf("in conditional delay slot (delayed_pc=0x%08x)\n", | ||
201 | env->delayed_pc); | ||
202 | - } else if (env->flags & DELAY_SLOT_RTE) { | ||
203 | + } else if (env->flags & TB_FLAG_DELAY_SLOT_RTE) { | ||
204 | qemu_fprintf(f, "in rte delay slot (delayed_pc=0x%08x)\n", | ||
205 | env->delayed_pc); | ||
206 | } | ||
207 | @@ -XXX,XX +XXX,XX @@ static inline void gen_save_cpu_state(DisasContext *ctx, bool save_pc) | ||
208 | |||
209 | static inline bool use_exit_tb(DisasContext *ctx) | ||
210 | { | ||
211 | - return (ctx->tbflags & GUSA_EXCLUSIVE) != 0; | ||
212 | + return (ctx->tbflags & TB_FLAG_GUSA_EXCLUSIVE) != 0; | ||
213 | } | ||
214 | |||
215 | static bool use_goto_tb(DisasContext *ctx, target_ulong dest) | ||
216 | @@ -XXX,XX +XXX,XX @@ static void gen_conditional_jump(DisasContext *ctx, target_ulong dest, | ||
217 | TCGLabel *l1 = gen_new_label(); | ||
218 | TCGCond cond_not_taken = jump_if_true ? TCG_COND_EQ : TCG_COND_NE; | ||
219 | |||
220 | - if (ctx->tbflags & GUSA_EXCLUSIVE) { | ||
221 | + if (ctx->tbflags & TB_FLAG_GUSA_EXCLUSIVE) { | ||
222 | /* When in an exclusive region, we must continue to the end. | ||
223 | Therefore, exit the region on a taken branch, but otherwise | ||
224 | fall through to the next instruction. */ | ||
225 | tcg_gen_brcondi_i32(cond_not_taken, cpu_sr_t, 0, l1); | ||
226 | - tcg_gen_movi_i32(cpu_flags, ctx->envflags & ~GUSA_MASK); | ||
227 | + tcg_gen_movi_i32(cpu_flags, ctx->envflags & ~TB_FLAG_GUSA_MASK); | ||
228 | /* Note that this won't actually use a goto_tb opcode because we | ||
229 | disallow it in use_goto_tb, but it handles exit + singlestep. */ | ||
230 | gen_goto_tb(ctx, 0, dest); | ||
231 | @@ -XXX,XX +XXX,XX @@ static void gen_delayed_conditional_jump(DisasContext * ctx) | ||
232 | tcg_gen_mov_i32(ds, cpu_delayed_cond); | ||
233 | tcg_gen_discard_i32(cpu_delayed_cond); | ||
234 | |||
235 | - if (ctx->tbflags & GUSA_EXCLUSIVE) { | ||
236 | + if (ctx->tbflags & TB_FLAG_GUSA_EXCLUSIVE) { | ||
237 | /* When in an exclusive region, we must continue to the end. | ||
238 | Therefore, exit the region on a taken branch, but otherwise | ||
239 | fall through to the next instruction. */ | ||
240 | tcg_gen_brcondi_i32(TCG_COND_EQ, ds, 0, l1); | ||
241 | |||
242 | /* Leave the gUSA region. */ | ||
243 | - tcg_gen_movi_i32(cpu_flags, ctx->envflags & ~GUSA_MASK); | ||
244 | + tcg_gen_movi_i32(cpu_flags, ctx->envflags & ~TB_FLAG_GUSA_MASK); | ||
245 | gen_jump(ctx); | ||
246 | |||
247 | gen_set_label(l1); | ||
248 | @@ -XXX,XX +XXX,XX @@ static inline void gen_store_fpr64(DisasContext *ctx, TCGv_i64 t, int reg) | ||
249 | #define XHACK(x) ((((x) & 1 ) << 4) | ((x) & 0xe)) | ||
250 | |||
251 | #define CHECK_NOT_DELAY_SLOT \ | ||
252 | - if (ctx->envflags & DELAY_SLOT_MASK) { \ | ||
253 | - goto do_illegal_slot; \ | ||
254 | + if (ctx->envflags & TB_FLAG_DELAY_SLOT_MASK) { \ | ||
255 | + goto do_illegal_slot; \ | ||
256 | } | ||
257 | |||
258 | #define CHECK_PRIVILEGED \ | ||
259 | @@ -XXX,XX +XXX,XX @@ static void _decode_opc(DisasContext * ctx) | ||
260 | case 0x000b: /* rts */ | ||
261 | CHECK_NOT_DELAY_SLOT | ||
262 | tcg_gen_mov_i32(cpu_delayed_pc, cpu_pr); | ||
263 | - ctx->envflags |= DELAY_SLOT; | ||
264 | + ctx->envflags |= TB_FLAG_DELAY_SLOT; | ||
265 | ctx->delayed_pc = (uint32_t) - 1; | ||
266 | return; | ||
267 | case 0x0028: /* clrmac */ | ||
268 | @@ -XXX,XX +XXX,XX @@ static void _decode_opc(DisasContext * ctx) | ||
269 | CHECK_NOT_DELAY_SLOT | ||
270 | gen_write_sr(cpu_ssr); | ||
271 | tcg_gen_mov_i32(cpu_delayed_pc, cpu_spc); | ||
272 | - ctx->envflags |= DELAY_SLOT_RTE; | ||
273 | + ctx->envflags |= TB_FLAG_DELAY_SLOT_RTE; | ||
274 | ctx->delayed_pc = (uint32_t) - 1; | ||
275 | ctx->base.is_jmp = DISAS_STOP; | ||
276 | return; | ||
277 | @@ -XXX,XX +XXX,XX @@ static void _decode_opc(DisasContext * ctx) | ||
278 | return; | ||
279 | case 0xe000: /* mov #imm,Rn */ | ||
280 | #ifdef CONFIG_USER_ONLY | ||
281 | - /* Detect the start of a gUSA region. If so, update envflags | ||
282 | - and end the TB. This will allow us to see the end of the | ||
283 | - region (stored in R0) in the next TB. */ | ||
284 | + /* | ||
285 | + * Detect the start of a gUSA region (mov #-n, r15). | ||
286 | + * If so, update envflags and end the TB. This will allow us | ||
287 | + * to see the end of the region (stored in R0) in the next TB. | ||
288 | + */ | ||
289 | if (B11_8 == 15 && B7_0s < 0 && | ||
290 | (tb_cflags(ctx->base.tb) & CF_PARALLEL)) { | ||
291 | - ctx->envflags = deposit32(ctx->envflags, GUSA_SHIFT, 8, B7_0s); | ||
292 | + ctx->envflags = | ||
293 | + deposit32(ctx->envflags, TB_FLAG_GUSA_SHIFT, 8, B7_0s); | ||
294 | ctx->base.is_jmp = DISAS_STOP; | ||
295 | } | ||
53 | #endif | 296 | #endif |
54 | #if TCG_TARGET_HAS_ext16s_i32 | 297 | @@ -XXX,XX +XXX,XX @@ static void _decode_opc(DisasContext * ctx) |
55 | @@ -XXX,XX +XXX,XX @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, | 298 | case 0xa000: /* bra disp */ |
56 | #if TCG_TARGET_HAS_ext8s_i64 | 299 | CHECK_NOT_DELAY_SLOT |
57 | case INDEX_op_ext8s_i64: | 300 | ctx->delayed_pc = ctx->base.pc_next + 4 + B11_0s * 2; |
58 | t0 = *tb_ptr++; | 301 | - ctx->envflags |= DELAY_SLOT; |
59 | - t1 = tci_read_r8s(regs, &tb_ptr); | 302 | + ctx->envflags |= TB_FLAG_DELAY_SLOT; |
60 | - tci_write_reg(regs, t0, t1); | 303 | return; |
61 | + t1 = tci_read_r(regs, &tb_ptr); | 304 | case 0xb000: /* bsr disp */ |
62 | + tci_write_reg(regs, t0, (int8_t)t1); | 305 | CHECK_NOT_DELAY_SLOT |
63 | break; | 306 | tcg_gen_movi_i32(cpu_pr, ctx->base.pc_next + 4); |
307 | ctx->delayed_pc = ctx->base.pc_next + 4 + B11_0s * 2; | ||
308 | - ctx->envflags |= DELAY_SLOT; | ||
309 | + ctx->envflags |= TB_FLAG_DELAY_SLOT; | ||
310 | return; | ||
311 | } | ||
312 | |||
313 | @@ -XXX,XX +XXX,XX @@ static void _decode_opc(DisasContext * ctx) | ||
314 | CHECK_NOT_DELAY_SLOT | ||
315 | tcg_gen_xori_i32(cpu_delayed_cond, cpu_sr_t, 1); | ||
316 | ctx->delayed_pc = ctx->base.pc_next + 4 + B7_0s * 2; | ||
317 | - ctx->envflags |= DELAY_SLOT_CONDITIONAL; | ||
318 | + ctx->envflags |= TB_FLAG_DELAY_SLOT_COND; | ||
319 | return; | ||
320 | case 0x8900: /* bt label */ | ||
321 | CHECK_NOT_DELAY_SLOT | ||
322 | @@ -XXX,XX +XXX,XX @@ static void _decode_opc(DisasContext * ctx) | ||
323 | CHECK_NOT_DELAY_SLOT | ||
324 | tcg_gen_mov_i32(cpu_delayed_cond, cpu_sr_t); | ||
325 | ctx->delayed_pc = ctx->base.pc_next + 4 + B7_0s * 2; | ||
326 | - ctx->envflags |= DELAY_SLOT_CONDITIONAL; | ||
327 | + ctx->envflags |= TB_FLAG_DELAY_SLOT_COND; | ||
328 | return; | ||
329 | case 0x8800: /* cmp/eq #imm,R0 */ | ||
330 | tcg_gen_setcondi_i32(TCG_COND_EQ, cpu_sr_t, REG(0), B7_0s); | ||
331 | @@ -XXX,XX +XXX,XX @@ static void _decode_opc(DisasContext * ctx) | ||
332 | case 0x0023: /* braf Rn */ | ||
333 | CHECK_NOT_DELAY_SLOT | ||
334 | tcg_gen_addi_i32(cpu_delayed_pc, REG(B11_8), ctx->base.pc_next + 4); | ||
335 | - ctx->envflags |= DELAY_SLOT; | ||
336 | + ctx->envflags |= TB_FLAG_DELAY_SLOT; | ||
337 | ctx->delayed_pc = (uint32_t) - 1; | ||
338 | return; | ||
339 | case 0x0003: /* bsrf Rn */ | ||
340 | CHECK_NOT_DELAY_SLOT | ||
341 | tcg_gen_movi_i32(cpu_pr, ctx->base.pc_next + 4); | ||
342 | tcg_gen_add_i32(cpu_delayed_pc, REG(B11_8), cpu_pr); | ||
343 | - ctx->envflags |= DELAY_SLOT; | ||
344 | + ctx->envflags |= TB_FLAG_DELAY_SLOT; | ||
345 | ctx->delayed_pc = (uint32_t) - 1; | ||
346 | return; | ||
347 | case 0x4015: /* cmp/pl Rn */ | ||
348 | @@ -XXX,XX +XXX,XX @@ static void _decode_opc(DisasContext * ctx) | ||
349 | case 0x402b: /* jmp @Rn */ | ||
350 | CHECK_NOT_DELAY_SLOT | ||
351 | tcg_gen_mov_i32(cpu_delayed_pc, REG(B11_8)); | ||
352 | - ctx->envflags |= DELAY_SLOT; | ||
353 | + ctx->envflags |= TB_FLAG_DELAY_SLOT; | ||
354 | ctx->delayed_pc = (uint32_t) - 1; | ||
355 | return; | ||
356 | case 0x400b: /* jsr @Rn */ | ||
357 | CHECK_NOT_DELAY_SLOT | ||
358 | tcg_gen_movi_i32(cpu_pr, ctx->base.pc_next + 4); | ||
359 | tcg_gen_mov_i32(cpu_delayed_pc, REG(B11_8)); | ||
360 | - ctx->envflags |= DELAY_SLOT; | ||
361 | + ctx->envflags |= TB_FLAG_DELAY_SLOT; | ||
362 | ctx->delayed_pc = (uint32_t) - 1; | ||
363 | return; | ||
364 | case 0x400e: /* ldc Rm,SR */ | ||
365 | @@ -XXX,XX +XXX,XX @@ static void _decode_opc(DisasContext * ctx) | ||
366 | fflush(stderr); | ||
64 | #endif | 367 | #endif |
65 | #if TCG_TARGET_HAS_ext16s_i64 | 368 | do_illegal: |
369 | - if (ctx->envflags & DELAY_SLOT_MASK) { | ||
370 | + if (ctx->envflags & TB_FLAG_DELAY_SLOT_MASK) { | ||
371 | do_illegal_slot: | ||
372 | gen_save_cpu_state(ctx, true); | ||
373 | gen_helper_raise_slot_illegal_instruction(cpu_env); | ||
374 | @@ -XXX,XX +XXX,XX @@ static void _decode_opc(DisasContext * ctx) | ||
375 | |||
376 | do_fpu_disabled: | ||
377 | gen_save_cpu_state(ctx, true); | ||
378 | - if (ctx->envflags & DELAY_SLOT_MASK) { | ||
379 | + if (ctx->envflags & TB_FLAG_DELAY_SLOT_MASK) { | ||
380 | gen_helper_raise_slot_fpu_disable(cpu_env); | ||
381 | } else { | ||
382 | gen_helper_raise_fpu_disable(cpu_env); | ||
383 | @@ -XXX,XX +XXX,XX @@ static void decode_opc(DisasContext * ctx) | ||
384 | |||
385 | _decode_opc(ctx); | ||
386 | |||
387 | - if (old_flags & DELAY_SLOT_MASK) { | ||
388 | + if (old_flags & TB_FLAG_DELAY_SLOT_MASK) { | ||
389 | /* go out of the delay slot */ | ||
390 | - ctx->envflags &= ~DELAY_SLOT_MASK; | ||
391 | + ctx->envflags &= ~TB_FLAG_DELAY_SLOT_MASK; | ||
392 | |||
393 | /* When in an exclusive region, we must continue to the end | ||
394 | for conditional branches. */ | ||
395 | - if (ctx->tbflags & GUSA_EXCLUSIVE | ||
396 | - && old_flags & DELAY_SLOT_CONDITIONAL) { | ||
397 | + if (ctx->tbflags & TB_FLAG_GUSA_EXCLUSIVE | ||
398 | + && old_flags & TB_FLAG_DELAY_SLOT_COND) { | ||
399 | gen_delayed_conditional_jump(ctx); | ||
400 | return; | ||
401 | } | ||
402 | /* Otherwise this is probably an invalid gUSA region. | ||
403 | Drop the GUSA bits so the next TB doesn't see them. */ | ||
404 | - ctx->envflags &= ~GUSA_MASK; | ||
405 | + ctx->envflags &= ~TB_FLAG_GUSA_MASK; | ||
406 | |||
407 | tcg_gen_movi_i32(cpu_flags, ctx->envflags); | ||
408 | - if (old_flags & DELAY_SLOT_CONDITIONAL) { | ||
409 | + if (old_flags & TB_FLAG_DELAY_SLOT_COND) { | ||
410 | gen_delayed_conditional_jump(ctx); | ||
411 | } else { | ||
412 | gen_jump(ctx); | ||
413 | @@ -XXX,XX +XXX,XX @@ static void decode_gusa(DisasContext *ctx, CPUSH4State *env) | ||
414 | } | ||
415 | |||
416 | /* The entire region has been translated. */ | ||
417 | - ctx->envflags &= ~GUSA_MASK; | ||
418 | + ctx->envflags &= ~TB_FLAG_GUSA_MASK; | ||
419 | ctx->base.pc_next = pc_end; | ||
420 | ctx->base.num_insns += max_insns - 1; | ||
421 | return; | ||
422 | @@ -XXX,XX +XXX,XX @@ static void decode_gusa(DisasContext *ctx, CPUSH4State *env) | ||
423 | |||
424 | /* Restart with the EXCLUSIVE bit set, within a TB run via | ||
425 | cpu_exec_step_atomic holding the exclusive lock. */ | ||
426 | - ctx->envflags |= GUSA_EXCLUSIVE; | ||
427 | + ctx->envflags |= TB_FLAG_GUSA_EXCLUSIVE; | ||
428 | gen_save_cpu_state(ctx, false); | ||
429 | gen_helper_exclusive(cpu_env); | ||
430 | ctx->base.is_jmp = DISAS_NORETURN; | ||
431 | @@ -XXX,XX +XXX,XX @@ static void sh4_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
432 | (tbflags & (1 << SR_RB))) * 0x10; | ||
433 | ctx->fbank = tbflags & FPSCR_FR ? 0x10 : 0; | ||
434 | |||
435 | - if (tbflags & GUSA_MASK) { | ||
436 | +#ifdef CONFIG_USER_ONLY | ||
437 | + if (tbflags & TB_FLAG_GUSA_MASK) { | ||
438 | + /* In gUSA exclusive region. */ | ||
439 | uint32_t pc = ctx->base.pc_next; | ||
440 | uint32_t pc_end = ctx->base.tb->cs_base; | ||
441 | - int backup = sextract32(ctx->tbflags, GUSA_SHIFT, 8); | ||
442 | + int backup = sextract32(ctx->tbflags, TB_FLAG_GUSA_SHIFT, 8); | ||
443 | int max_insns = (pc_end - pc) / 2; | ||
444 | |||
445 | if (pc != pc_end + backup || max_insns < 2) { | ||
446 | /* This is a malformed gUSA region. Don't do anything special, | ||
447 | since the interpreter is likely to get confused. */ | ||
448 | - ctx->envflags &= ~GUSA_MASK; | ||
449 | - } else if (tbflags & GUSA_EXCLUSIVE) { | ||
450 | + ctx->envflags &= ~TB_FLAG_GUSA_MASK; | ||
451 | + } else if (tbflags & TB_FLAG_GUSA_EXCLUSIVE) { | ||
452 | /* Regardless of single-stepping or the end of the page, | ||
453 | we must complete execution of the gUSA region while | ||
454 | holding the exclusive lock. */ | ||
455 | @@ -XXX,XX +XXX,XX @@ static void sh4_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
456 | return; | ||
457 | } | ||
458 | } | ||
459 | +#endif | ||
460 | |||
461 | /* Since the ISA is fixed-width, we can bound by the number | ||
462 | of instructions remaining on the page. */ | ||
463 | @@ -XXX,XX +XXX,XX @@ static void sh4_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) | ||
464 | DisasContext *ctx = container_of(dcbase, DisasContext, base); | ||
465 | |||
466 | #ifdef CONFIG_USER_ONLY | ||
467 | - if (unlikely(ctx->envflags & GUSA_MASK) | ||
468 | - && !(ctx->envflags & GUSA_EXCLUSIVE)) { | ||
469 | + if (unlikely(ctx->envflags & TB_FLAG_GUSA_MASK) | ||
470 | + && !(ctx->envflags & TB_FLAG_GUSA_EXCLUSIVE)) { | ||
471 | /* We're in an gUSA region, and we have not already fallen | ||
472 | back on using an exclusive region. Attempt to parse the | ||
473 | region into a single supported atomic operation. Failure | ||
474 | @@ -XXX,XX +XXX,XX @@ static void sh4_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) | ||
475 | { | ||
476 | DisasContext *ctx = container_of(dcbase, DisasContext, base); | ||
477 | |||
478 | - if (ctx->tbflags & GUSA_EXCLUSIVE) { | ||
479 | + if (ctx->tbflags & TB_FLAG_GUSA_EXCLUSIVE) { | ||
480 | /* Ending the region of exclusivity. Clear the bits. */ | ||
481 | - ctx->envflags &= ~GUSA_MASK; | ||
482 | + ctx->envflags &= ~TB_FLAG_GUSA_MASK; | ||
483 | } | ||
484 | |||
485 | switch (ctx->base.is_jmp) { | ||
66 | -- | 486 | -- |
67 | 2.25.1 | 487 | 2.34.1 |
68 | |||
69 | diff view generated by jsdifflib |