1 | The following changes since commit 0a301624c2f4ced3331ffd5bce85b4274fe132af: | 1 | The following changes since commit 813bac3d8d70d85cb7835f7945eb9eed84c2d8d0: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20220208' into staging (2022-02-08 11:40:08 +0000) | 3 | Merge tag '2023q3-bsd-user-pull-request' of https://gitlab.com/bsdimp/qemu into staging (2023-08-29 08:58:00 -0400) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20220211 | 7 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20230829 |
8 | 8 | ||
9 | for you to fetch changes up to 5c1a101ef6b85537a4ade93c39ea81cadd5c246e: | 9 | for you to fetch changes up to dad2f2f5afbaf58d6056f31dfd4b9edd0854b8ab: |
10 | 10 | ||
11 | tests/tcg/multiarch: Add sigbus.c (2022-02-09 09:00:01 +1100) | 11 | tcg/sparc64: Disable TCG_TARGET_HAS_extr_i64_i32 (2023-08-29 09:57:39 -0700) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Fix safe_syscall_base for sparc64. | 14 | softmmu: Use async_run_on_cpu in tcg_commit |
15 | Fix host signal handling for sparc64-linux. | 15 | tcg: Remove vecop_list check from tcg_gen_not_vec |
16 | Speedups for jump cache and work list probing. | 16 | tcg/sparc64: Disable TCG_TARGET_HAS_extr_i64_i32 |
17 | Fix for exception replays. | ||
18 | Raise guest SIGBUS for user-only misaligned accesses. | ||
19 | 17 | ||
20 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
21 | Idan Horowitz (2): | 19 | Richard Henderson (4): |
22 | accel/tcg: Optimize jump cache flush during tlb range flush | 20 | softmmu: Assert data in bounds in iotlb_to_section |
23 | softmmu/cpus: Check if the cpu work list is empty atomically | 21 | softmmu: Use async_run_on_cpu in tcg_commit |
22 | tcg: Remove vecop_list check from tcg_gen_not_vec | ||
23 | tcg/sparc64: Disable TCG_TARGET_HAS_extr_i64_i32 | ||
24 | 24 | ||
25 | Pavel Dovgalyuk (1): | 25 | include/exec/cpu-common.h | 1 - |
26 | replay: use CF_NOIRQ for special exception-replaying TB | 26 | tcg/sparc64/tcg-target.h | 2 +- |
27 | 27 | accel/tcg/cpu-exec-common.c | 30 -------------------------- | |
28 | Richard Henderson (29): | 28 | softmmu/physmem.c | 50 ++++++++++++++++++++++++++++++++------------ |
29 | common-user/host/sparc64: Fix safe_syscall_base | 29 | tcg/tcg-op-vec.c | 7 +++---- |
30 | linux-user: Introduce host_signal_mask | 30 | tcg/sparc64/tcg-target.c.inc | 11 ---------- |
31 | linux-user: Introduce host_sigcontext | 31 | 6 files changed, 41 insertions(+), 60 deletions(-) |
32 | linux-user: Move sparc/host-signal.h to sparc64/host-signal.h | ||
33 | linux-user/include/host/sparc64: Fix host_sigcontext | ||
34 | tcg/i386: Support raising sigbus for user-only | ||
35 | tcg/aarch64: Support raising sigbus for user-only | ||
36 | tcg/ppc: Support raising sigbus for user-only | ||
37 | tcg/riscv: Support raising sigbus for user-only | ||
38 | tcg/s390x: Support raising sigbus for user-only | ||
39 | tcg/tci: Support raising sigbus for user-only | ||
40 | tcg/arm: Drop support for armv4 and armv5 hosts | ||
41 | tcg/arm: Remove use_armv5t_instructions | ||
42 | tcg/arm: Remove use_armv6_instructions | ||
43 | tcg/arm: Check alignment for ldrd and strd | ||
44 | tcg/arm: Support unaligned access for softmmu | ||
45 | tcg/arm: Reserve a register for guest_base | ||
46 | tcg/arm: Support raising sigbus for user-only | ||
47 | tcg/mips: Support unaligned access for user-only | ||
48 | tcg/mips: Support unaligned access for softmmu | ||
49 | tcg/sparc: Use tcg_out_movi_imm13 in tcg_out_addsub2_i64 | ||
50 | tcg/sparc: Split out tcg_out_movi_imm32 | ||
51 | tcg/sparc: Add scratch argument to tcg_out_movi_int | ||
52 | tcg/sparc: Improve code gen for shifted 32-bit constants | ||
53 | tcg/sparc: Convert patch_reloc to return bool | ||
54 | tcg/sparc: Use the constant pool for 64-bit constants | ||
55 | tcg/sparc: Add tcg_out_jmpl_const for better tail calls | ||
56 | tcg/sparc: Support unaligned access for user-only | ||
57 | tests/tcg/multiarch: Add sigbus.c | ||
58 | |||
59 | WANG Xuerui (2): | ||
60 | tcg/loongarch64: Fix fallout from recent MO_Q renaming | ||
61 | tcg/loongarch64: Support raising sigbus for user-only | ||
62 | |||
63 | linux-user/include/host/aarch64/host-signal.h | 16 +- | ||
64 | linux-user/include/host/alpha/host-signal.h | 14 +- | ||
65 | linux-user/include/host/arm/host-signal.h | 14 +- | ||
66 | linux-user/include/host/i386/host-signal.h | 14 +- | ||
67 | linux-user/include/host/loongarch64/host-signal.h | 14 +- | ||
68 | linux-user/include/host/mips/host-signal.h | 14 +- | ||
69 | linux-user/include/host/ppc/host-signal.h | 14 +- | ||
70 | linux-user/include/host/riscv/host-signal.h | 14 +- | ||
71 | linux-user/include/host/s390/host-signal.h | 14 +- | ||
72 | linux-user/include/host/sparc/host-signal.h | 63 ---- | ||
73 | linux-user/include/host/sparc64/host-signal.h | 65 +++- | ||
74 | linux-user/include/host/x86_64/host-signal.h | 14 +- | ||
75 | tcg/aarch64/tcg-target.h | 2 - | ||
76 | tcg/arm/tcg-target.h | 6 +- | ||
77 | tcg/i386/tcg-target.h | 2 - | ||
78 | tcg/loongarch64/tcg-target.h | 2 - | ||
79 | tcg/mips/tcg-target.h | 2 - | ||
80 | tcg/ppc/tcg-target.h | 2 - | ||
81 | tcg/riscv/tcg-target.h | 2 - | ||
82 | tcg/s390x/tcg-target.h | 2 - | ||
83 | accel/tcg/cpu-exec.c | 3 +- | ||
84 | accel/tcg/cputlb.c | 9 + | ||
85 | linux-user/signal.c | 22 +- | ||
86 | softmmu/cpus.c | 7 +- | ||
87 | tcg/tci.c | 20 +- | ||
88 | tests/tcg/multiarch/sigbus.c | 68 ++++ | ||
89 | tcg/aarch64/tcg-target.c.inc | 91 ++++- | ||
90 | tcg/arm/tcg-target.c.inc | 410 +++++++++------------- | ||
91 | tcg/i386/tcg-target.c.inc | 103 +++++- | ||
92 | tcg/loongarch64/tcg-target.c.inc | 73 +++- | ||
93 | tcg/mips/tcg-target.c.inc | 387 ++++++++++++++++++-- | ||
94 | tcg/ppc/tcg-target.c.inc | 98 +++++- | ||
95 | tcg/riscv/tcg-target.c.inc | 63 +++- | ||
96 | tcg/s390x/tcg-target.c.inc | 59 +++- | ||
97 | tcg/sparc/tcg-target.c.inc | 348 +++++++++++++++--- | ||
98 | common-user/host/sparc64/safe-syscall.inc.S | 5 +- | ||
99 | 36 files changed, 1561 insertions(+), 495 deletions(-) | ||
100 | delete mode 100644 linux-user/include/host/sparc/host-signal.h | ||
101 | create mode 100644 tests/tcg/multiarch/sigbus.c | ||
102 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Use the "retl" instead of "ret" instruction alias, since we | ||
2 | do not allocate a register window in this function. | ||
3 | 1 | ||
4 | Fix the offset to the first stacked parameter, which lies | ||
5 | beyond the register window save area. | ||
6 | |||
7 | Fixes: 95c021dac835 ("linux-user/host/sparc64: Add safe-syscall.inc.S") | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | common-user/host/sparc64/safe-syscall.inc.S | 5 +++-- | ||
11 | 1 file changed, 3 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/common-user/host/sparc64/safe-syscall.inc.S b/common-user/host/sparc64/safe-syscall.inc.S | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/common-user/host/sparc64/safe-syscall.inc.S | ||
16 | +++ b/common-user/host/sparc64/safe-syscall.inc.S | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | .type safe_syscall_end, @function | ||
19 | |||
20 | #define STACK_BIAS 2047 | ||
21 | -#define PARAM(N) STACK_BIAS + N*8 | ||
22 | +#define WINDOW_SIZE 16 * 8 | ||
23 | +#define PARAM(N) STACK_BIAS + WINDOW_SIZE + N * 8 | ||
24 | |||
25 | /* | ||
26 | * This is the entry point for making a system call. The calling | ||
27 | @@ -XXX,XX +XXX,XX @@ safe_syscall_end: | ||
28 | /* code path for having successfully executed the syscall */ | ||
29 | bcs,pn %xcc, 1f | ||
30 | nop | ||
31 | - ret | ||
32 | + retl | ||
33 | nop | ||
34 | |||
35 | /* code path when we didn't execute the syscall */ | ||
36 | -- | ||
37 | 2.25.1 | ||
38 | |||
39 | diff view generated by jsdifflib |
1 | Due to mapping changes, we now rarely place the code_gen_buffer | 1 | Acked-by: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | near the main executable. Which means that direct calls will | 2 | Suggested-by: Alex Bennée <alex.bennee@linaro.org> |
3 | now rarely be in range. | ||
4 | |||
5 | So, always use indirect calls for tail calls, which allows us to | ||
6 | avoid clobbering %o7, and therefore we need not save and restore it. | ||
7 | |||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | --- | 4 | --- |
11 | tcg/sparc/tcg-target.c.inc | 37 +++++++++++++++++++++++-------------- | 5 | softmmu/physmem.c | 10 ++++++++-- |
12 | 1 file changed, 23 insertions(+), 14 deletions(-) | 6 | 1 file changed, 8 insertions(+), 2 deletions(-) |
13 | 7 | ||
14 | diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc | 8 | diff --git a/softmmu/physmem.c b/softmmu/physmem.c |
15 | index XXXXXXX..XXXXXXX 100644 | 9 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tcg/sparc/tcg-target.c.inc | 10 | --- a/softmmu/physmem.c |
17 | +++ b/tcg/sparc/tcg-target.c.inc | 11 | +++ b/softmmu/physmem.c |
18 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_addsub2_i64(TCGContext *s, TCGReg rl, TCGReg rh, | 12 | @@ -XXX,XX +XXX,XX @@ MemoryRegionSection *iotlb_to_section(CPUState *cpu, |
19 | tcg_out_mov(s, TCG_TYPE_I64, rl, tmp); | 13 | int asidx = cpu_asidx_from_attrs(cpu, attrs); |
14 | CPUAddressSpace *cpuas = &cpu->cpu_ases[asidx]; | ||
15 | AddressSpaceDispatch *d = qatomic_rcu_read(&cpuas->memory_dispatch); | ||
16 | - MemoryRegionSection *sections = d->map.sections; | ||
17 | + int section_index = index & ~TARGET_PAGE_MASK; | ||
18 | + MemoryRegionSection *ret; | ||
19 | |||
20 | - return §ions[index & ~TARGET_PAGE_MASK]; | ||
21 | + assert(section_index < d->map.sections_nb); | ||
22 | + ret = d->map.sections + section_index; | ||
23 | + assert(ret->mr); | ||
24 | + assert(ret->mr->ops); | ||
25 | + | ||
26 | + return ret; | ||
20 | } | 27 | } |
21 | 28 | ||
22 | +static void tcg_out_jmpl_const(TCGContext *s, const tcg_insn_unit *dest, | 29 | static void io_mem_init(void) |
23 | + bool in_prologue, bool tail_call) | ||
24 | +{ | ||
25 | + uintptr_t desti = (uintptr_t)dest; | ||
26 | + | ||
27 | + /* Be careful not to clobber %o7 for a tail call. */ | ||
28 | + tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_REG_T1, | ||
29 | + desti & ~0xfff, in_prologue, | ||
30 | + tail_call ? TCG_REG_G2 : TCG_REG_O7); | ||
31 | + tcg_out_arithi(s, tail_call ? TCG_REG_G0 : TCG_REG_O7, | ||
32 | + TCG_REG_T1, desti & 0xfff, JMPL); | ||
33 | +} | ||
34 | + | ||
35 | static void tcg_out_call_nodelay(TCGContext *s, const tcg_insn_unit *dest, | ||
36 | bool in_prologue) | ||
37 | { | ||
38 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_call_nodelay(TCGContext *s, const tcg_insn_unit *dest, | ||
39 | if (disp == (int32_t)disp) { | ||
40 | tcg_out32(s, CALL | (uint32_t)disp >> 2); | ||
41 | } else { | ||
42 | - uintptr_t desti = (uintptr_t)dest; | ||
43 | - tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_REG_T1, | ||
44 | - desti & ~0xfff, in_prologue, TCG_REG_O7); | ||
45 | - tcg_out_arithi(s, TCG_REG_O7, TCG_REG_T1, desti & 0xfff, JMPL); | ||
46 | + tcg_out_jmpl_const(s, dest, in_prologue, false); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | @@ -XXX,XX +XXX,XX @@ static void build_trampolines(TCGContext *s) | ||
51 | |||
52 | /* Set the retaddr operand. */ | ||
53 | tcg_out_mov(s, TCG_TYPE_PTR, ra, TCG_REG_O7); | ||
54 | - /* Set the env operand. */ | ||
55 | - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O0, TCG_AREG0); | ||
56 | /* Tail call. */ | ||
57 | - tcg_out_call_nodelay(s, qemu_ld_helpers[i], true); | ||
58 | - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O7, ra); | ||
59 | + tcg_out_jmpl_const(s, qemu_ld_helpers[i], true, true); | ||
60 | + /* delay slot -- set the env argument */ | ||
61 | + tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); | ||
62 | } | ||
63 | |||
64 | for (i = 0; i < ARRAY_SIZE(qemu_st_helpers); ++i) { | ||
65 | @@ -XXX,XX +XXX,XX @@ static void build_trampolines(TCGContext *s) | ||
66 | if (ra >= TCG_REG_O6) { | ||
67 | tcg_out_st(s, TCG_TYPE_PTR, TCG_REG_O7, TCG_REG_CALL_STACK, | ||
68 | TCG_TARGET_CALL_STACK_OFFSET); | ||
69 | - ra = TCG_REG_G1; | ||
70 | + } else { | ||
71 | + tcg_out_mov(s, TCG_TYPE_PTR, ra, TCG_REG_O7); | ||
72 | } | ||
73 | - tcg_out_mov(s, TCG_TYPE_PTR, ra, TCG_REG_O7); | ||
74 | - /* Set the env operand. */ | ||
75 | - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O0, TCG_AREG0); | ||
76 | + | ||
77 | /* Tail call. */ | ||
78 | - tcg_out_call_nodelay(s, qemu_st_helpers[i], true); | ||
79 | - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O7, ra); | ||
80 | + tcg_out_jmpl_const(s, qemu_st_helpers[i], true, true); | ||
81 | + /* delay slot -- set the env argument */ | ||
82 | + tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); | ||
83 | } | ||
84 | } | ||
85 | #endif | ||
86 | -- | 30 | -- |
87 | 2.25.1 | 31 | 2.34.1 |
88 | 32 | ||
89 | 33 | diff view generated by jsdifflib |
1 | This is kinda sorta the opposite of the other tcg hosts, where | 1 | After system startup, run the update to memory_dispatch |
---|---|---|---|
2 | we get (normal) alignment checks for free with host SIGBUS and | 2 | and the tlb_flush on the cpu. This eliminates a race, |
3 | need to add code to support unaligned accesses. | 3 | wherein a running cpu sees the memory_dispatch change |
4 | but has not yet seen the tlb_flush. | ||
4 | 5 | ||
5 | This inline code expansion is somewhat large, but it takes quite | 6 | Since the update now happens on the cpu, we need not use |
6 | a few instructions to make a function call to a helper anyway. | 7 | qatomic_rcu_read to protect the read of memory_dispatch. |
7 | 8 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1826 |
10 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1834 | ||
11 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1846 | ||
12 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
13 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | --- | 15 | --- |
11 | tcg/sparc/tcg-target.c.inc | 219 +++++++++++++++++++++++++++++++++++-- | 16 | include/exec/cpu-common.h | 1 - |
12 | 1 file changed, 211 insertions(+), 8 deletions(-) | 17 | accel/tcg/cpu-exec-common.c | 30 ---------------------------- |
18 | softmmu/physmem.c | 40 +++++++++++++++++++++++++++---------- | ||
19 | 3 files changed, 29 insertions(+), 42 deletions(-) | ||
13 | 20 | ||
14 | diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc | 21 | diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h |
15 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tcg/sparc/tcg-target.c.inc | 23 | --- a/include/exec/cpu-common.h |
17 | +++ b/tcg/sparc/tcg-target.c.inc | 24 | +++ b/include/exec/cpu-common.h |
18 | @@ -XXX,XX +XXX,XX @@ static const int tcg_target_call_oarg_regs[] = { | 25 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_physical_memory_write(hwaddr addr, |
19 | #define ARITH_ADD (INSN_OP(2) | INSN_OP3(0x00)) | 26 | { |
20 | #define ARITH_ADDCC (INSN_OP(2) | INSN_OP3(0x10)) | 27 | cpu_physical_memory_rw(addr, (void *)buf, len, true); |
21 | #define ARITH_AND (INSN_OP(2) | INSN_OP3(0x01)) | 28 | } |
22 | +#define ARITH_ANDCC (INSN_OP(2) | INSN_OP3(0x11)) | 29 | -void cpu_reloading_memory_map(void); |
23 | #define ARITH_ANDN (INSN_OP(2) | INSN_OP3(0x05)) | 30 | void *cpu_physical_memory_map(hwaddr addr, |
24 | #define ARITH_OR (INSN_OP(2) | INSN_OP3(0x02)) | 31 | hwaddr *plen, |
25 | #define ARITH_ORCC (INSN_OP(2) | INSN_OP3(0x12)) | 32 | bool is_write); |
26 | @@ -XXX,XX +XXX,XX @@ static void build_trampolines(TCGContext *s) | 33 | diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c |
27 | tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); | 34 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/accel/tcg/cpu-exec-common.c | ||
36 | +++ b/accel/tcg/cpu-exec-common.c | ||
37 | @@ -XXX,XX +XXX,XX @@ void cpu_loop_exit_noexc(CPUState *cpu) | ||
38 | cpu_loop_exit(cpu); | ||
39 | } | ||
40 | |||
41 | -#if defined(CONFIG_SOFTMMU) | ||
42 | -void cpu_reloading_memory_map(void) | ||
43 | -{ | ||
44 | - if (qemu_in_vcpu_thread() && current_cpu->running) { | ||
45 | - /* The guest can in theory prolong the RCU critical section as long | ||
46 | - * as it feels like. The major problem with this is that because it | ||
47 | - * can do multiple reconfigurations of the memory map within the | ||
48 | - * critical section, we could potentially accumulate an unbounded | ||
49 | - * collection of memory data structures awaiting reclamation. | ||
50 | - * | ||
51 | - * Because the only thing we're currently protecting with RCU is the | ||
52 | - * memory data structures, it's sufficient to break the critical section | ||
53 | - * in this callback, which we know will get called every time the | ||
54 | - * memory map is rearranged. | ||
55 | - * | ||
56 | - * (If we add anything else in the system that uses RCU to protect | ||
57 | - * its data structures, we will need to implement some other mechanism | ||
58 | - * to force TCG CPUs to exit the critical section, at which point this | ||
59 | - * part of this callback might become unnecessary.) | ||
60 | - * | ||
61 | - * This pair matches cpu_exec's rcu_read_lock()/rcu_read_unlock(), which | ||
62 | - * only protects cpu->as->dispatch. Since we know our caller is about | ||
63 | - * to reload it, it's safe to split the critical section. | ||
64 | - */ | ||
65 | - rcu_read_unlock(); | ||
66 | - rcu_read_lock(); | ||
67 | - } | ||
68 | -} | ||
69 | -#endif | ||
70 | - | ||
71 | void cpu_loop_exit(CPUState *cpu) | ||
72 | { | ||
73 | /* Undo the setting in cpu_tb_exec. */ | ||
74 | diff --git a/softmmu/physmem.c b/softmmu/physmem.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/softmmu/physmem.c | ||
77 | +++ b/softmmu/physmem.c | ||
78 | @@ -XXX,XX +XXX,XX @@ address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr orig_addr, | ||
79 | IOMMUTLBEntry iotlb; | ||
80 | int iommu_idx; | ||
81 | hwaddr addr = orig_addr; | ||
82 | - AddressSpaceDispatch *d = | ||
83 | - qatomic_rcu_read(&cpu->cpu_ases[asidx].memory_dispatch); | ||
84 | + AddressSpaceDispatch *d = cpu->cpu_ases[asidx].memory_dispatch; | ||
85 | |||
86 | for (;;) { | ||
87 | section = address_space_translate_internal(d, addr, &addr, plen, false); | ||
88 | @@ -XXX,XX +XXX,XX @@ MemoryRegionSection *iotlb_to_section(CPUState *cpu, | ||
89 | { | ||
90 | int asidx = cpu_asidx_from_attrs(cpu, attrs); | ||
91 | CPUAddressSpace *cpuas = &cpu->cpu_ases[asidx]; | ||
92 | - AddressSpaceDispatch *d = qatomic_rcu_read(&cpuas->memory_dispatch); | ||
93 | + AddressSpaceDispatch *d = cpuas->memory_dispatch; | ||
94 | int section_index = index & ~TARGET_PAGE_MASK; | ||
95 | MemoryRegionSection *ret; | ||
96 | |||
97 | @@ -XXX,XX +XXX,XX @@ static void tcg_log_global_after_sync(MemoryListener *listener) | ||
28 | } | 98 | } |
29 | } | 99 | } |
30 | +#else | 100 | |
31 | +static const tcg_insn_unit *qemu_unalign_ld_trampoline; | 101 | +static void tcg_commit_cpu(CPUState *cpu, run_on_cpu_data data) |
32 | +static const tcg_insn_unit *qemu_unalign_st_trampoline; | 102 | +{ |
103 | + CPUAddressSpace *cpuas = data.host_ptr; | ||
33 | + | 104 | + |
34 | +static void build_trampolines(TCGContext *s) | 105 | + cpuas->memory_dispatch = address_space_to_dispatch(cpuas->as); |
35 | +{ | 106 | + tlb_flush(cpu); |
36 | + for (int ld = 0; ld < 2; ++ld) { | 107 | +} |
37 | + void *helper; | ||
38 | + | 108 | + |
39 | + while ((uintptr_t)s->code_ptr & 15) { | 109 | static void tcg_commit(MemoryListener *listener) |
40 | + tcg_out_nop(s); | ||
41 | + } | ||
42 | + | ||
43 | + if (ld) { | ||
44 | + helper = helper_unaligned_ld; | ||
45 | + qemu_unalign_ld_trampoline = tcg_splitwx_to_rx(s->code_ptr); | ||
46 | + } else { | ||
47 | + helper = helper_unaligned_st; | ||
48 | + qemu_unalign_st_trampoline = tcg_splitwx_to_rx(s->code_ptr); | ||
49 | + } | ||
50 | + | ||
51 | + if (!SPARC64 && TARGET_LONG_BITS == 64) { | ||
52 | + /* Install the high part of the address. */ | ||
53 | + tcg_out_arithi(s, TCG_REG_O1, TCG_REG_O2, 32, SHIFT_SRLX); | ||
54 | + } | ||
55 | + | ||
56 | + /* Tail call. */ | ||
57 | + tcg_out_jmpl_const(s, helper, true, true); | ||
58 | + /* delay slot -- set the env argument */ | ||
59 | + tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); | ||
60 | + } | ||
61 | +} | ||
62 | #endif | ||
63 | |||
64 | /* Generate global QEMU prologue and epilogue code */ | ||
65 | @@ -XXX,XX +XXX,XX @@ static void tcg_target_qemu_prologue(TCGContext *s) | ||
66 | /* delay slot */ | ||
67 | tcg_out_movi_imm13(s, TCG_REG_O0, 0); | ||
68 | |||
69 | -#ifdef CONFIG_SOFTMMU | ||
70 | build_trampolines(s); | ||
71 | -#endif | ||
72 | } | ||
73 | |||
74 | static void tcg_out_nop_fill(tcg_insn_unit *p, int count) | ||
75 | @@ -XXX,XX +XXX,XX @@ static TCGReg tcg_out_tlb_load(TCGContext *s, TCGReg addr, int mem_index, | ||
76 | static const int qemu_ld_opc[(MO_SSIZE | MO_BSWAP) + 1] = { | ||
77 | [MO_UB] = LDUB, | ||
78 | [MO_SB] = LDSB, | ||
79 | + [MO_UB | MO_LE] = LDUB, | ||
80 | + [MO_SB | MO_LE] = LDSB, | ||
81 | |||
82 | [MO_BEUW] = LDUH, | ||
83 | [MO_BESW] = LDSH, | ||
84 | [MO_BEUL] = LDUW, | ||
85 | [MO_BESL] = LDSW, | ||
86 | [MO_BEUQ] = LDX, | ||
87 | + [MO_BESQ] = LDX, | ||
88 | |||
89 | [MO_LEUW] = LDUH_LE, | ||
90 | [MO_LESW] = LDSH_LE, | ||
91 | [MO_LEUL] = LDUW_LE, | ||
92 | [MO_LESL] = LDSW_LE, | ||
93 | [MO_LEUQ] = LDX_LE, | ||
94 | + [MO_LESQ] = LDX_LE, | ||
95 | }; | ||
96 | |||
97 | static const int qemu_st_opc[(MO_SIZE | MO_BSWAP) + 1] = { | ||
98 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data, TCGReg addr, | ||
99 | MemOpIdx oi, bool is_64) | ||
100 | { | 110 | { |
101 | MemOp memop = get_memop(oi); | 111 | CPUAddressSpace *cpuas; |
102 | + tcg_insn_unit *label_ptr; | 112 | - AddressSpaceDispatch *d; |
103 | + | 113 | + CPUState *cpu; |
104 | #ifdef CONFIG_SOFTMMU | 114 | |
105 | unsigned memi = get_mmuidx(oi); | 115 | assert(tcg_enabled()); |
106 | TCGReg addrz, param; | 116 | /* since each CPU stores ram addresses in its TLB cache, we must |
107 | const tcg_insn_unit *func; | 117 | reset the modified entries */ |
108 | - tcg_insn_unit *label_ptr; | 118 | cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener); |
109 | 119 | - cpu_reloading_memory_map(); | |
110 | addrz = tcg_out_tlb_load(s, addr, memi, memop, | 120 | - /* The CPU and TLB are protected by the iothread lock. |
111 | offsetof(CPUTLBEntry, addr_read)); | 121 | - * We reload the dispatch pointer now because cpu_reloading_memory_map() |
112 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data, TCGReg addr, | 122 | - * may have split the RCU critical section. |
113 | 123 | + cpu = cpuas->cpu; | |
114 | *label_ptr |= INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); | ||
115 | #else | ||
116 | + TCGReg index = (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0); | ||
117 | + unsigned a_bits = get_alignment_bits(memop); | ||
118 | + unsigned s_bits = memop & MO_SIZE; | ||
119 | + unsigned t_bits; | ||
120 | + | ||
121 | if (SPARC64 && TARGET_LONG_BITS == 32) { | ||
122 | tcg_out_arithi(s, TCG_REG_T1, addr, 0, SHIFT_SRL); | ||
123 | addr = TCG_REG_T1; | ||
124 | } | ||
125 | - tcg_out_ldst_rr(s, data, addr, | ||
126 | - (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0), | ||
127 | + | 124 | + |
128 | + /* | 125 | + /* |
129 | + * Normal case: alignment equal to access size. | 126 | + * Defer changes to as->memory_dispatch until the cpu is quiescent. |
130 | + */ | 127 | + * Otherwise we race between (1) other cpu threads and (2) ongoing |
131 | + if (a_bits == s_bits) { | 128 | + * i/o for the current cpu thread, with data cached by mmu_lookup(). |
132 | + tcg_out_ldst_rr(s, data, addr, index, | 129 | + * |
133 | + qemu_ld_opc[memop & (MO_BSWAP | MO_SSIZE)]); | 130 | + * In addition, queueing the work function will kick the cpu back to |
134 | + return; | 131 | + * the main loop, which will end the RCU critical section and reclaim |
132 | + * the memory data structures. | ||
133 | + * | ||
134 | + * That said, the listener is also called during realize, before | ||
135 | + * all of the tcg machinery for run-on is initialized: thus halt_cond. | ||
136 | */ | ||
137 | - d = address_space_to_dispatch(cpuas->as); | ||
138 | - qatomic_rcu_set(&cpuas->memory_dispatch, d); | ||
139 | - tlb_flush(cpuas->cpu); | ||
140 | + if (cpu->halt_cond) { | ||
141 | + async_run_on_cpu(cpu, tcg_commit_cpu, RUN_ON_CPU_HOST_PTR(cpuas)); | ||
142 | + } else { | ||
143 | + tcg_commit_cpu(cpu, RUN_ON_CPU_HOST_PTR(cpuas)); | ||
135 | + } | 144 | + } |
136 | + | ||
137 | + /* | ||
138 | + * Test for at least natural alignment, and assume most accesses | ||
139 | + * will be aligned -- perform a straight load in the delay slot. | ||
140 | + * This is required to preserve atomicity for aligned accesses. | ||
141 | + */ | ||
142 | + t_bits = MAX(a_bits, s_bits); | ||
143 | + tcg_debug_assert(t_bits < 13); | ||
144 | + tcg_out_arithi(s, TCG_REG_G0, addr, (1u << t_bits) - 1, ARITH_ANDCC); | ||
145 | + | ||
146 | + /* beq,a,pt %icc, label */ | ||
147 | + label_ptr = s->code_ptr; | ||
148 | + tcg_out_bpcc0(s, COND_E, BPCC_A | BPCC_PT | BPCC_ICC, 0); | ||
149 | + /* delay slot */ | ||
150 | + tcg_out_ldst_rr(s, data, addr, index, | ||
151 | qemu_ld_opc[memop & (MO_BSWAP | MO_SSIZE)]); | ||
152 | + | ||
153 | + if (a_bits >= s_bits) { | ||
154 | + /* | ||
155 | + * Overalignment: A successful alignment test will perform the memory | ||
156 | + * operation in the delay slot, and failure need only invoke the | ||
157 | + * handler for SIGBUS. | ||
158 | + */ | ||
159 | + TCGReg arg_low = TCG_REG_O1 + (!SPARC64 && TARGET_LONG_BITS == 64); | ||
160 | + tcg_out_call_nodelay(s, qemu_unalign_ld_trampoline, false); | ||
161 | + /* delay slot -- move to low part of argument reg */ | ||
162 | + tcg_out_mov_delay(s, arg_low, addr); | ||
163 | + } else { | ||
164 | + /* Underalignment: load by pieces of minimum alignment. */ | ||
165 | + int ld_opc, a_size, s_size, i; | ||
166 | + | ||
167 | + /* | ||
168 | + * Force full address into T1 early; avoids problems with | ||
169 | + * overlap between @addr and @data. | ||
170 | + */ | ||
171 | + tcg_out_arith(s, TCG_REG_T1, addr, index, ARITH_ADD); | ||
172 | + | ||
173 | + a_size = 1 << a_bits; | ||
174 | + s_size = 1 << s_bits; | ||
175 | + if ((memop & MO_BSWAP) == MO_BE) { | ||
176 | + ld_opc = qemu_ld_opc[a_bits | MO_BE | (memop & MO_SIGN)]; | ||
177 | + tcg_out_ldst(s, data, TCG_REG_T1, 0, ld_opc); | ||
178 | + ld_opc = qemu_ld_opc[a_bits | MO_BE]; | ||
179 | + for (i = a_size; i < s_size; i += a_size) { | ||
180 | + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, i, ld_opc); | ||
181 | + tcg_out_arithi(s, data, data, a_size, SHIFT_SLLX); | ||
182 | + tcg_out_arith(s, data, data, TCG_REG_T2, ARITH_OR); | ||
183 | + } | ||
184 | + } else if (a_bits == 0) { | ||
185 | + ld_opc = LDUB; | ||
186 | + tcg_out_ldst(s, data, TCG_REG_T1, 0, ld_opc); | ||
187 | + for (i = a_size; i < s_size; i += a_size) { | ||
188 | + if ((memop & MO_SIGN) && i == s_size - a_size) { | ||
189 | + ld_opc = LDSB; | ||
190 | + } | ||
191 | + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, i, ld_opc); | ||
192 | + tcg_out_arithi(s, TCG_REG_T2, TCG_REG_T2, i * 8, SHIFT_SLLX); | ||
193 | + tcg_out_arith(s, data, data, TCG_REG_T2, ARITH_OR); | ||
194 | + } | ||
195 | + } else { | ||
196 | + ld_opc = qemu_ld_opc[a_bits | MO_LE]; | ||
197 | + tcg_out_ldst_rr(s, data, TCG_REG_T1, TCG_REG_G0, ld_opc); | ||
198 | + for (i = a_size; i < s_size; i += a_size) { | ||
199 | + tcg_out_arithi(s, TCG_REG_T1, TCG_REG_T1, a_size, ARITH_ADD); | ||
200 | + if ((memop & MO_SIGN) && i == s_size - a_size) { | ||
201 | + ld_opc = qemu_ld_opc[a_bits | MO_LE | MO_SIGN]; | ||
202 | + } | ||
203 | + tcg_out_ldst_rr(s, TCG_REG_T2, TCG_REG_T1, TCG_REG_G0, ld_opc); | ||
204 | + tcg_out_arithi(s, TCG_REG_T2, TCG_REG_T2, i * 8, SHIFT_SLLX); | ||
205 | + tcg_out_arith(s, data, data, TCG_REG_T2, ARITH_OR); | ||
206 | + } | ||
207 | + } | ||
208 | + } | ||
209 | + | ||
210 | + *label_ptr |= INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); | ||
211 | #endif /* CONFIG_SOFTMMU */ | ||
212 | } | 145 | } |
213 | 146 | ||
214 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data, TCGReg addr, | 147 | static void memory_map_init(void) |
215 | MemOpIdx oi) | ||
216 | { | ||
217 | MemOp memop = get_memop(oi); | ||
218 | + tcg_insn_unit *label_ptr; | ||
219 | + | ||
220 | #ifdef CONFIG_SOFTMMU | ||
221 | unsigned memi = get_mmuidx(oi); | ||
222 | TCGReg addrz, param; | ||
223 | const tcg_insn_unit *func; | ||
224 | - tcg_insn_unit *label_ptr; | ||
225 | |||
226 | addrz = tcg_out_tlb_load(s, addr, memi, memop, | ||
227 | offsetof(CPUTLBEntry, addr_write)); | ||
228 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data, TCGReg addr, | ||
229 | |||
230 | *label_ptr |= INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); | ||
231 | #else | ||
232 | + TCGReg index = (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0); | ||
233 | + unsigned a_bits = get_alignment_bits(memop); | ||
234 | + unsigned s_bits = memop & MO_SIZE; | ||
235 | + unsigned t_bits; | ||
236 | + | ||
237 | if (SPARC64 && TARGET_LONG_BITS == 32) { | ||
238 | tcg_out_arithi(s, TCG_REG_T1, addr, 0, SHIFT_SRL); | ||
239 | addr = TCG_REG_T1; | ||
240 | } | ||
241 | - tcg_out_ldst_rr(s, data, addr, | ||
242 | - (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0), | ||
243 | + | ||
244 | + /* | ||
245 | + * Normal case: alignment equal to access size. | ||
246 | + */ | ||
247 | + if (a_bits == s_bits) { | ||
248 | + tcg_out_ldst_rr(s, data, addr, index, | ||
249 | + qemu_st_opc[memop & (MO_BSWAP | MO_SIZE)]); | ||
250 | + return; | ||
251 | + } | ||
252 | + | ||
253 | + /* | ||
254 | + * Test for at least natural alignment, and assume most accesses | ||
255 | + * will be aligned -- perform a straight store in the delay slot. | ||
256 | + * This is required to preserve atomicity for aligned accesses. | ||
257 | + */ | ||
258 | + t_bits = MAX(a_bits, s_bits); | ||
259 | + tcg_debug_assert(t_bits < 13); | ||
260 | + tcg_out_arithi(s, TCG_REG_G0, addr, (1u << t_bits) - 1, ARITH_ANDCC); | ||
261 | + | ||
262 | + /* beq,a,pt %icc, label */ | ||
263 | + label_ptr = s->code_ptr; | ||
264 | + tcg_out_bpcc0(s, COND_E, BPCC_A | BPCC_PT | BPCC_ICC, 0); | ||
265 | + /* delay slot */ | ||
266 | + tcg_out_ldst_rr(s, data, addr, index, | ||
267 | qemu_st_opc[memop & (MO_BSWAP | MO_SIZE)]); | ||
268 | + | ||
269 | + if (a_bits >= s_bits) { | ||
270 | + /* | ||
271 | + * Overalignment: A successful alignment test will perform the memory | ||
272 | + * operation in the delay slot, and failure need only invoke the | ||
273 | + * handler for SIGBUS. | ||
274 | + */ | ||
275 | + TCGReg arg_low = TCG_REG_O1 + (!SPARC64 && TARGET_LONG_BITS == 64); | ||
276 | + tcg_out_call_nodelay(s, qemu_unalign_st_trampoline, false); | ||
277 | + /* delay slot -- move to low part of argument reg */ | ||
278 | + tcg_out_mov_delay(s, arg_low, addr); | ||
279 | + } else { | ||
280 | + /* Underalignment: store by pieces of minimum alignment. */ | ||
281 | + int st_opc, a_size, s_size, i; | ||
282 | + | ||
283 | + /* | ||
284 | + * Force full address into T1 early; avoids problems with | ||
285 | + * overlap between @addr and @data. | ||
286 | + */ | ||
287 | + tcg_out_arith(s, TCG_REG_T1, addr, index, ARITH_ADD); | ||
288 | + | ||
289 | + a_size = 1 << a_bits; | ||
290 | + s_size = 1 << s_bits; | ||
291 | + if ((memop & MO_BSWAP) == MO_BE) { | ||
292 | + st_opc = qemu_st_opc[a_bits | MO_BE]; | ||
293 | + for (i = 0; i < s_size; i += a_size) { | ||
294 | + TCGReg d = data; | ||
295 | + int shift = (s_size - a_size - i) * 8; | ||
296 | + if (shift) { | ||
297 | + d = TCG_REG_T2; | ||
298 | + tcg_out_arithi(s, d, data, shift, SHIFT_SRLX); | ||
299 | + } | ||
300 | + tcg_out_ldst(s, d, TCG_REG_T1, i, st_opc); | ||
301 | + } | ||
302 | + } else if (a_bits == 0) { | ||
303 | + tcg_out_ldst(s, data, TCG_REG_T1, 0, STB); | ||
304 | + for (i = 1; i < s_size; i++) { | ||
305 | + tcg_out_arithi(s, TCG_REG_T2, data, i * 8, SHIFT_SRLX); | ||
306 | + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, i, STB); | ||
307 | + } | ||
308 | + } else { | ||
309 | + /* Note that ST*A with immediate asi must use indexed address. */ | ||
310 | + st_opc = qemu_st_opc[a_bits + MO_LE]; | ||
311 | + tcg_out_ldst_rr(s, data, TCG_REG_T1, TCG_REG_G0, st_opc); | ||
312 | + for (i = a_size; i < s_size; i += a_size) { | ||
313 | + tcg_out_arithi(s, TCG_REG_T2, data, i * 8, SHIFT_SRLX); | ||
314 | + tcg_out_arithi(s, TCG_REG_T1, TCG_REG_T1, a_size, ARITH_ADD); | ||
315 | + tcg_out_ldst_rr(s, TCG_REG_T2, TCG_REG_T1, TCG_REG_G0, st_opc); | ||
316 | + } | ||
317 | + } | ||
318 | + } | ||
319 | + | ||
320 | + *label_ptr |= INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); | ||
321 | #endif /* CONFIG_SOFTMMU */ | ||
322 | } | ||
323 | |||
324 | -- | 148 | -- |
325 | 2.25.1 | 149 | 2.34.1 |
326 | 150 | ||
327 | 151 | diff view generated by jsdifflib |
1 | Do not directly access the uc_sigmask member. | 1 | The not pattern is always available via generic expansion. |
---|---|---|---|
2 | This is preparation for a sparc64 fix. | 2 | See debug block in tcg_can_emit_vecop_list. |
3 | 3 | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Fixes: 11978f6f58 ("tcg: Fix expansion of INDEX_op_not_vec") |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | --- | 7 | --- |
8 | linux-user/include/host/aarch64/host-signal.h | 5 +++++ | 8 | tcg/tcg-op-vec.c | 7 +++---- |
9 | linux-user/include/host/alpha/host-signal.h | 5 +++++ | 9 | 1 file changed, 3 insertions(+), 4 deletions(-) |
10 | linux-user/include/host/arm/host-signal.h | 5 +++++ | ||
11 | linux-user/include/host/i386/host-signal.h | 5 +++++ | ||
12 | .../include/host/loongarch64/host-signal.h | 5 +++++ | ||
13 | linux-user/include/host/mips/host-signal.h | 5 +++++ | ||
14 | linux-user/include/host/ppc/host-signal.h | 5 +++++ | ||
15 | linux-user/include/host/riscv/host-signal.h | 5 +++++ | ||
16 | linux-user/include/host/s390/host-signal.h | 5 +++++ | ||
17 | linux-user/include/host/sparc/host-signal.h | 5 +++++ | ||
18 | linux-user/include/host/x86_64/host-signal.h | 5 +++++ | ||
19 | linux-user/signal.c | 18 ++++++++---------- | ||
20 | 12 files changed, 63 insertions(+), 10 deletions(-) | ||
21 | 10 | ||
22 | diff --git a/linux-user/include/host/aarch64/host-signal.h b/linux-user/include/host/aarch64/host-signal.h | 11 | diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c |
23 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/linux-user/include/host/aarch64/host-signal.h | 13 | --- a/tcg/tcg-op-vec.c |
25 | +++ b/linux-user/include/host/aarch64/host-signal.h | 14 | +++ b/tcg/tcg-op-vec.c |
26 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | 15 | @@ -XXX,XX +XXX,XX @@ static bool do_op2(unsigned vece, TCGv_vec r, TCGv_vec a, TCGOpcode opc) |
27 | uc->uc_mcontext.pc = pc; | 16 | |
17 | void tcg_gen_not_vec(unsigned vece, TCGv_vec r, TCGv_vec a) | ||
18 | { | ||
19 | - const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL); | ||
20 | - | ||
21 | - if (!TCG_TARGET_HAS_not_vec || !do_op2(vece, r, a, INDEX_op_not_vec)) { | ||
22 | + if (TCG_TARGET_HAS_not_vec) { | ||
23 | + vec_gen_op2(INDEX_op_not_vec, 0, r, a); | ||
24 | + } else { | ||
25 | tcg_gen_xor_vec(0, r, a, tcg_constant_vec_matching(r, 0, -1)); | ||
26 | } | ||
27 | - tcg_swap_vecop_list(hold_list); | ||
28 | } | 28 | } |
29 | 29 | ||
30 | +static inline void *host_signal_mask(ucontext_t *uc) | 30 | void tcg_gen_neg_vec(unsigned vece, TCGv_vec r, TCGv_vec a) |
31 | +{ | ||
32 | + return &uc->uc_sigmask; | ||
33 | +} | ||
34 | + | ||
35 | static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
36 | { | ||
37 | struct _aarch64_ctx *hdr; | ||
38 | diff --git a/linux-user/include/host/alpha/host-signal.h b/linux-user/include/host/alpha/host-signal.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/linux-user/include/host/alpha/host-signal.h | ||
41 | +++ b/linux-user/include/host/alpha/host-signal.h | ||
42 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
43 | uc->uc_mcontext.sc_pc = pc; | ||
44 | } | ||
45 | |||
46 | +static inline void *host_signal_mask(ucontext_t *uc) | ||
47 | +{ | ||
48 | + return &uc->uc_sigmask; | ||
49 | +} | ||
50 | + | ||
51 | static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
52 | { | ||
53 | uint32_t *pc = (uint32_t *)host_signal_pc(uc); | ||
54 | diff --git a/linux-user/include/host/arm/host-signal.h b/linux-user/include/host/arm/host-signal.h | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/linux-user/include/host/arm/host-signal.h | ||
57 | +++ b/linux-user/include/host/arm/host-signal.h | ||
58 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
59 | uc->uc_mcontext.arm_pc = pc; | ||
60 | } | ||
61 | |||
62 | +static inline void *host_signal_mask(ucontext_t *uc) | ||
63 | +{ | ||
64 | + return &uc->uc_sigmask; | ||
65 | +} | ||
66 | + | ||
67 | static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
68 | { | ||
69 | /* | ||
70 | diff --git a/linux-user/include/host/i386/host-signal.h b/linux-user/include/host/i386/host-signal.h | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/linux-user/include/host/i386/host-signal.h | ||
73 | +++ b/linux-user/include/host/i386/host-signal.h | ||
74 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
75 | uc->uc_mcontext.gregs[REG_EIP] = pc; | ||
76 | } | ||
77 | |||
78 | +static inline void *host_signal_mask(ucontext_t *uc) | ||
79 | +{ | ||
80 | + return &uc->uc_sigmask; | ||
81 | +} | ||
82 | + | ||
83 | static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
84 | { | ||
85 | return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe | ||
86 | diff --git a/linux-user/include/host/loongarch64/host-signal.h b/linux-user/include/host/loongarch64/host-signal.h | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/linux-user/include/host/loongarch64/host-signal.h | ||
89 | +++ b/linux-user/include/host/loongarch64/host-signal.h | ||
90 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
91 | uc->uc_mcontext.__pc = pc; | ||
92 | } | ||
93 | |||
94 | +static inline void *host_signal_mask(ucontext_t *uc) | ||
95 | +{ | ||
96 | + return &uc->uc_sigmask; | ||
97 | +} | ||
98 | + | ||
99 | static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
100 | { | ||
101 | const uint32_t *pinsn = (const uint32_t *)host_signal_pc(uc); | ||
102 | diff --git a/linux-user/include/host/mips/host-signal.h b/linux-user/include/host/mips/host-signal.h | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/linux-user/include/host/mips/host-signal.h | ||
105 | +++ b/linux-user/include/host/mips/host-signal.h | ||
106 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
107 | uc->uc_mcontext.pc = pc; | ||
108 | } | ||
109 | |||
110 | +static inline void *host_signal_mask(ucontext_t *uc) | ||
111 | +{ | ||
112 | + return &uc->uc_sigmask; | ||
113 | +} | ||
114 | + | ||
115 | #if defined(__misp16) || defined(__mips_micromips) | ||
116 | #error "Unsupported encoding" | ||
117 | #endif | ||
118 | diff --git a/linux-user/include/host/ppc/host-signal.h b/linux-user/include/host/ppc/host-signal.h | ||
119 | index XXXXXXX..XXXXXXX 100644 | ||
120 | --- a/linux-user/include/host/ppc/host-signal.h | ||
121 | +++ b/linux-user/include/host/ppc/host-signal.h | ||
122 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
123 | uc->uc_mcontext.regs->nip = pc; | ||
124 | } | ||
125 | |||
126 | +static inline void *host_signal_mask(ucontext_t *uc) | ||
127 | +{ | ||
128 | + return &uc->uc_sigmask; | ||
129 | +} | ||
130 | + | ||
131 | static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
132 | { | ||
133 | return uc->uc_mcontext.regs->trap != 0x400 | ||
134 | diff --git a/linux-user/include/host/riscv/host-signal.h b/linux-user/include/host/riscv/host-signal.h | ||
135 | index XXXXXXX..XXXXXXX 100644 | ||
136 | --- a/linux-user/include/host/riscv/host-signal.h | ||
137 | +++ b/linux-user/include/host/riscv/host-signal.h | ||
138 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
139 | uc->uc_mcontext.__gregs[REG_PC] = pc; | ||
140 | } | ||
141 | |||
142 | +static inline void *host_signal_mask(ucontext_t *uc) | ||
143 | +{ | ||
144 | + return &uc->uc_sigmask; | ||
145 | +} | ||
146 | + | ||
147 | static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
148 | { | ||
149 | /* | ||
150 | diff --git a/linux-user/include/host/s390/host-signal.h b/linux-user/include/host/s390/host-signal.h | ||
151 | index XXXXXXX..XXXXXXX 100644 | ||
152 | --- a/linux-user/include/host/s390/host-signal.h | ||
153 | +++ b/linux-user/include/host/s390/host-signal.h | ||
154 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
155 | uc->uc_mcontext.psw.addr = pc; | ||
156 | } | ||
157 | |||
158 | +static inline void *host_signal_mask(ucontext_t *uc) | ||
159 | +{ | ||
160 | + return &uc->uc_sigmask; | ||
161 | +} | ||
162 | + | ||
163 | static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
164 | { | ||
165 | uint16_t *pinsn = (uint16_t *)host_signal_pc(uc); | ||
166 | diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/include/host/sparc/host-signal.h | ||
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/linux-user/include/host/sparc/host-signal.h | ||
169 | +++ b/linux-user/include/host/sparc/host-signal.h | ||
170 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
171 | #endif | ||
172 | } | ||
173 | |||
174 | +static inline void *host_signal_mask(ucontext_t *uc) | ||
175 | +{ | ||
176 | + return &uc->uc_sigmask; | ||
177 | +} | ||
178 | + | ||
179 | static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
180 | { | ||
181 | uint32_t insn = *(uint32_t *)host_signal_pc(uc); | ||
182 | diff --git a/linux-user/include/host/x86_64/host-signal.h b/linux-user/include/host/x86_64/host-signal.h | ||
183 | index XXXXXXX..XXXXXXX 100644 | ||
184 | --- a/linux-user/include/host/x86_64/host-signal.h | ||
185 | +++ b/linux-user/include/host/x86_64/host-signal.h | ||
186 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
187 | uc->uc_mcontext.gregs[REG_RIP] = pc; | ||
188 | } | ||
189 | |||
190 | +static inline void *host_signal_mask(ucontext_t *uc) | ||
191 | +{ | ||
192 | + return &uc->uc_sigmask; | ||
193 | +} | ||
194 | + | ||
195 | static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
196 | { | ||
197 | return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe | ||
198 | diff --git a/linux-user/signal.c b/linux-user/signal.c | ||
199 | index XXXXXXX..XXXXXXX 100644 | ||
200 | --- a/linux-user/signal.c | ||
201 | +++ b/linux-user/signal.c | ||
202 | @@ -XXX,XX +XXX,XX @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) | ||
203 | int guest_sig; | ||
204 | uintptr_t pc = 0; | ||
205 | bool sync_sig = false; | ||
206 | + void *sigmask = host_signal_mask(uc); | ||
207 | |||
208 | /* | ||
209 | * Non-spoofed SIGSEGV and SIGBUS are synchronous, and need special | ||
210 | @@ -XXX,XX +XXX,XX @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) | ||
211 | if (info->si_code == SEGV_ACCERR && h2g_valid(host_addr)) { | ||
212 | /* If this was a write to a TB protected page, restart. */ | ||
213 | if (is_write && | ||
214 | - handle_sigsegv_accerr_write(cpu, &uc->uc_sigmask, | ||
215 | - pc, guest_addr)) { | ||
216 | + handle_sigsegv_accerr_write(cpu, sigmask, pc, guest_addr)) { | ||
217 | return; | ||
218 | } | ||
219 | |||
220 | @@ -XXX,XX +XXX,XX @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) | ||
221 | } | ||
222 | } | ||
223 | |||
224 | - sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); | ||
225 | + sigprocmask(SIG_SETMASK, sigmask, NULL); | ||
226 | cpu_loop_exit_sigsegv(cpu, guest_addr, access_type, maperr, pc); | ||
227 | } else { | ||
228 | - sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); | ||
229 | + sigprocmask(SIG_SETMASK, sigmask, NULL); | ||
230 | if (info->si_code == BUS_ADRALN) { | ||
231 | cpu_loop_exit_sigbus(cpu, guest_addr, access_type, pc); | ||
232 | } | ||
233 | @@ -XXX,XX +XXX,XX @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) | ||
234 | * now and it getting out to the main loop. Signals will be | ||
235 | * unblocked again in process_pending_signals(). | ||
236 | * | ||
237 | - * WARNING: we cannot use sigfillset() here because the uc_sigmask | ||
238 | + * WARNING: we cannot use sigfillset() here because the sigmask | ||
239 | * field is a kernel sigset_t, which is much smaller than the | ||
240 | * libc sigset_t which sigfillset() operates on. Using sigfillset() | ||
241 | * would write 0xff bytes off the end of the structure and trash | ||
242 | * data on the struct. | ||
243 | - * We can't use sizeof(uc->uc_sigmask) either, because the libc | ||
244 | - * headers define the struct field with the wrong (too large) type. | ||
245 | */ | ||
246 | - memset(&uc->uc_sigmask, 0xff, SIGSET_T_SIZE); | ||
247 | - sigdelset(&uc->uc_sigmask, SIGSEGV); | ||
248 | - sigdelset(&uc->uc_sigmask, SIGBUS); | ||
249 | + memset(sigmask, 0xff, SIGSET_T_SIZE); | ||
250 | + sigdelset(sigmask, SIGSEGV); | ||
251 | + sigdelset(sigmask, SIGBUS); | ||
252 | |||
253 | /* interrupt the virtual CPU as soon as possible */ | ||
254 | cpu_exit(thread_cpu); | ||
255 | -- | 31 | -- |
256 | 2.25.1 | 32 | 2.34.1 |
257 | 33 | ||
258 | 34 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Do not directly access ucontext_t as the third signal parameter. | ||
2 | This is preparation for a sparc64 fix. | ||
3 | 1 | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | linux-user/include/host/aarch64/host-signal.h | 13 ++++++++----- | ||
9 | linux-user/include/host/alpha/host-signal.h | 11 +++++++---- | ||
10 | linux-user/include/host/arm/host-signal.h | 11 +++++++---- | ||
11 | linux-user/include/host/i386/host-signal.h | 11 +++++++---- | ||
12 | linux-user/include/host/loongarch64/host-signal.h | 11 +++++++---- | ||
13 | linux-user/include/host/mips/host-signal.h | 11 +++++++---- | ||
14 | linux-user/include/host/ppc/host-signal.h | 11 +++++++---- | ||
15 | linux-user/include/host/riscv/host-signal.h | 11 +++++++---- | ||
16 | linux-user/include/host/s390/host-signal.h | 11 +++++++---- | ||
17 | linux-user/include/host/sparc/host-signal.h | 11 +++++++---- | ||
18 | linux-user/include/host/x86_64/host-signal.h | 11 +++++++---- | ||
19 | linux-user/signal.c | 4 ++-- | ||
20 | 12 files changed, 80 insertions(+), 47 deletions(-) | ||
21 | |||
22 | diff --git a/linux-user/include/host/aarch64/host-signal.h b/linux-user/include/host/aarch64/host-signal.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/linux-user/include/host/aarch64/host-signal.h | ||
25 | +++ b/linux-user/include/host/aarch64/host-signal.h | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | #ifndef AARCH64_HOST_SIGNAL_H | ||
28 | #define AARCH64_HOST_SIGNAL_H | ||
29 | |||
30 | +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ | ||
31 | +typedef ucontext_t host_sigcontext; | ||
32 | + | ||
33 | /* Pre-3.16 kernel headers don't have these, so provide fallback definitions */ | ||
34 | #ifndef ESR_MAGIC | ||
35 | #define ESR_MAGIC 0x45535201 | ||
36 | @@ -XXX,XX +XXX,XX @@ struct esr_context { | ||
37 | }; | ||
38 | #endif | ||
39 | |||
40 | -static inline struct _aarch64_ctx *first_ctx(ucontext_t *uc) | ||
41 | +static inline struct _aarch64_ctx *first_ctx(host_sigcontext *uc) | ||
42 | { | ||
43 | return (struct _aarch64_ctx *)&uc->uc_mcontext.__reserved; | ||
44 | } | ||
45 | @@ -XXX,XX +XXX,XX @@ static inline struct _aarch64_ctx *next_ctx(struct _aarch64_ctx *hdr) | ||
46 | return (struct _aarch64_ctx *)((char *)hdr + hdr->size); | ||
47 | } | ||
48 | |||
49 | -static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
50 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
51 | { | ||
52 | return uc->uc_mcontext.pc; | ||
53 | } | ||
54 | |||
55 | -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
56 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
57 | { | ||
58 | uc->uc_mcontext.pc = pc; | ||
59 | } | ||
60 | |||
61 | -static inline void *host_signal_mask(ucontext_t *uc) | ||
62 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
63 | { | ||
64 | return &uc->uc_sigmask; | ||
65 | } | ||
66 | |||
67 | -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
68 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
69 | { | ||
70 | struct _aarch64_ctx *hdr; | ||
71 | uint32_t insn; | ||
72 | diff --git a/linux-user/include/host/alpha/host-signal.h b/linux-user/include/host/alpha/host-signal.h | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/linux-user/include/host/alpha/host-signal.h | ||
75 | +++ b/linux-user/include/host/alpha/host-signal.h | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | #ifndef ALPHA_HOST_SIGNAL_H | ||
78 | #define ALPHA_HOST_SIGNAL_H | ||
79 | |||
80 | -static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
81 | +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ | ||
82 | +typedef ucontext_t host_sigcontext; | ||
83 | + | ||
84 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
85 | { | ||
86 | return uc->uc_mcontext.sc_pc; | ||
87 | } | ||
88 | |||
89 | -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
90 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
91 | { | ||
92 | uc->uc_mcontext.sc_pc = pc; | ||
93 | } | ||
94 | |||
95 | -static inline void *host_signal_mask(ucontext_t *uc) | ||
96 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
97 | { | ||
98 | return &uc->uc_sigmask; | ||
99 | } | ||
100 | |||
101 | -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
102 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
103 | { | ||
104 | uint32_t *pc = (uint32_t *)host_signal_pc(uc); | ||
105 | uint32_t insn = *pc; | ||
106 | diff --git a/linux-user/include/host/arm/host-signal.h b/linux-user/include/host/arm/host-signal.h | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/linux-user/include/host/arm/host-signal.h | ||
109 | +++ b/linux-user/include/host/arm/host-signal.h | ||
110 | @@ -XXX,XX +XXX,XX @@ | ||
111 | #ifndef ARM_HOST_SIGNAL_H | ||
112 | #define ARM_HOST_SIGNAL_H | ||
113 | |||
114 | -static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
115 | +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ | ||
116 | +typedef ucontext_t host_sigcontext; | ||
117 | + | ||
118 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
119 | { | ||
120 | return uc->uc_mcontext.arm_pc; | ||
121 | } | ||
122 | |||
123 | -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
124 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
125 | { | ||
126 | uc->uc_mcontext.arm_pc = pc; | ||
127 | } | ||
128 | |||
129 | -static inline void *host_signal_mask(ucontext_t *uc) | ||
130 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
131 | { | ||
132 | return &uc->uc_sigmask; | ||
133 | } | ||
134 | |||
135 | -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
136 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
137 | { | ||
138 | /* | ||
139 | * In the FSR, bit 11 is WnR, assuming a v6 or | ||
140 | diff --git a/linux-user/include/host/i386/host-signal.h b/linux-user/include/host/i386/host-signal.h | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/linux-user/include/host/i386/host-signal.h | ||
143 | +++ b/linux-user/include/host/i386/host-signal.h | ||
144 | @@ -XXX,XX +XXX,XX @@ | ||
145 | #ifndef I386_HOST_SIGNAL_H | ||
146 | #define I386_HOST_SIGNAL_H | ||
147 | |||
148 | -static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
149 | +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ | ||
150 | +typedef ucontext_t host_sigcontext; | ||
151 | + | ||
152 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
153 | { | ||
154 | return uc->uc_mcontext.gregs[REG_EIP]; | ||
155 | } | ||
156 | |||
157 | -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
158 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
159 | { | ||
160 | uc->uc_mcontext.gregs[REG_EIP] = pc; | ||
161 | } | ||
162 | |||
163 | -static inline void *host_signal_mask(ucontext_t *uc) | ||
164 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
165 | { | ||
166 | return &uc->uc_sigmask; | ||
167 | } | ||
168 | |||
169 | -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
170 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
171 | { | ||
172 | return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe | ||
173 | && (uc->uc_mcontext.gregs[REG_ERR] & 0x2); | ||
174 | diff --git a/linux-user/include/host/loongarch64/host-signal.h b/linux-user/include/host/loongarch64/host-signal.h | ||
175 | index XXXXXXX..XXXXXXX 100644 | ||
176 | --- a/linux-user/include/host/loongarch64/host-signal.h | ||
177 | +++ b/linux-user/include/host/loongarch64/host-signal.h | ||
178 | @@ -XXX,XX +XXX,XX @@ | ||
179 | #ifndef LOONGARCH64_HOST_SIGNAL_H | ||
180 | #define LOONGARCH64_HOST_SIGNAL_H | ||
181 | |||
182 | -static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
183 | +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ | ||
184 | +typedef ucontext_t host_sigcontext; | ||
185 | + | ||
186 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
187 | { | ||
188 | return uc->uc_mcontext.__pc; | ||
189 | } | ||
190 | |||
191 | -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
192 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
193 | { | ||
194 | uc->uc_mcontext.__pc = pc; | ||
195 | } | ||
196 | |||
197 | -static inline void *host_signal_mask(ucontext_t *uc) | ||
198 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
199 | { | ||
200 | return &uc->uc_sigmask; | ||
201 | } | ||
202 | |||
203 | -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
204 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
205 | { | ||
206 | const uint32_t *pinsn = (const uint32_t *)host_signal_pc(uc); | ||
207 | uint32_t insn = pinsn[0]; | ||
208 | diff --git a/linux-user/include/host/mips/host-signal.h b/linux-user/include/host/mips/host-signal.h | ||
209 | index XXXXXXX..XXXXXXX 100644 | ||
210 | --- a/linux-user/include/host/mips/host-signal.h | ||
211 | +++ b/linux-user/include/host/mips/host-signal.h | ||
212 | @@ -XXX,XX +XXX,XX @@ | ||
213 | #ifndef MIPS_HOST_SIGNAL_H | ||
214 | #define MIPS_HOST_SIGNAL_H | ||
215 | |||
216 | -static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
217 | +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ | ||
218 | +typedef ucontext_t host_sigcontext; | ||
219 | + | ||
220 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
221 | { | ||
222 | return uc->uc_mcontext.pc; | ||
223 | } | ||
224 | |||
225 | -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
226 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
227 | { | ||
228 | uc->uc_mcontext.pc = pc; | ||
229 | } | ||
230 | |||
231 | -static inline void *host_signal_mask(ucontext_t *uc) | ||
232 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
233 | { | ||
234 | return &uc->uc_sigmask; | ||
235 | } | ||
236 | @@ -XXX,XX +XXX,XX @@ static inline void *host_signal_mask(ucontext_t *uc) | ||
237 | #error "Unsupported encoding" | ||
238 | #endif | ||
239 | |||
240 | -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
241 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
242 | { | ||
243 | uint32_t insn = *(uint32_t *)host_signal_pc(uc); | ||
244 | |||
245 | diff --git a/linux-user/include/host/ppc/host-signal.h b/linux-user/include/host/ppc/host-signal.h | ||
246 | index XXXXXXX..XXXXXXX 100644 | ||
247 | --- a/linux-user/include/host/ppc/host-signal.h | ||
248 | +++ b/linux-user/include/host/ppc/host-signal.h | ||
249 | @@ -XXX,XX +XXX,XX @@ | ||
250 | #ifndef PPC_HOST_SIGNAL_H | ||
251 | #define PPC_HOST_SIGNAL_H | ||
252 | |||
253 | -static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
254 | +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ | ||
255 | +typedef ucontext_t host_sigcontext; | ||
256 | + | ||
257 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
258 | { | ||
259 | return uc->uc_mcontext.regs->nip; | ||
260 | } | ||
261 | |||
262 | -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
263 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
264 | { | ||
265 | uc->uc_mcontext.regs->nip = pc; | ||
266 | } | ||
267 | |||
268 | -static inline void *host_signal_mask(ucontext_t *uc) | ||
269 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
270 | { | ||
271 | return &uc->uc_sigmask; | ||
272 | } | ||
273 | |||
274 | -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
275 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
276 | { | ||
277 | return uc->uc_mcontext.regs->trap != 0x400 | ||
278 | && (uc->uc_mcontext.regs->dsisr & 0x02000000); | ||
279 | diff --git a/linux-user/include/host/riscv/host-signal.h b/linux-user/include/host/riscv/host-signal.h | ||
280 | index XXXXXXX..XXXXXXX 100644 | ||
281 | --- a/linux-user/include/host/riscv/host-signal.h | ||
282 | +++ b/linux-user/include/host/riscv/host-signal.h | ||
283 | @@ -XXX,XX +XXX,XX @@ | ||
284 | #ifndef RISCV_HOST_SIGNAL_H | ||
285 | #define RISCV_HOST_SIGNAL_H | ||
286 | |||
287 | -static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
288 | +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ | ||
289 | +typedef ucontext_t host_sigcontext; | ||
290 | + | ||
291 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
292 | { | ||
293 | return uc->uc_mcontext.__gregs[REG_PC]; | ||
294 | } | ||
295 | |||
296 | -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
297 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
298 | { | ||
299 | uc->uc_mcontext.__gregs[REG_PC] = pc; | ||
300 | } | ||
301 | |||
302 | -static inline void *host_signal_mask(ucontext_t *uc) | ||
303 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
304 | { | ||
305 | return &uc->uc_sigmask; | ||
306 | } | ||
307 | |||
308 | -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
309 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
310 | { | ||
311 | /* | ||
312 | * Detect store by reading the instruction at the program counter. | ||
313 | diff --git a/linux-user/include/host/s390/host-signal.h b/linux-user/include/host/s390/host-signal.h | ||
314 | index XXXXXXX..XXXXXXX 100644 | ||
315 | --- a/linux-user/include/host/s390/host-signal.h | ||
316 | +++ b/linux-user/include/host/s390/host-signal.h | ||
317 | @@ -XXX,XX +XXX,XX @@ | ||
318 | #ifndef S390_HOST_SIGNAL_H | ||
319 | #define S390_HOST_SIGNAL_H | ||
320 | |||
321 | -static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
322 | +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ | ||
323 | +typedef ucontext_t host_sigcontext; | ||
324 | + | ||
325 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
326 | { | ||
327 | return uc->uc_mcontext.psw.addr; | ||
328 | } | ||
329 | |||
330 | -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
331 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
332 | { | ||
333 | uc->uc_mcontext.psw.addr = pc; | ||
334 | } | ||
335 | |||
336 | -static inline void *host_signal_mask(ucontext_t *uc) | ||
337 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
338 | { | ||
339 | return &uc->uc_sigmask; | ||
340 | } | ||
341 | |||
342 | -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
343 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
344 | { | ||
345 | uint16_t *pinsn = (uint16_t *)host_signal_pc(uc); | ||
346 | |||
347 | diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/include/host/sparc/host-signal.h | ||
348 | index XXXXXXX..XXXXXXX 100644 | ||
349 | --- a/linux-user/include/host/sparc/host-signal.h | ||
350 | +++ b/linux-user/include/host/sparc/host-signal.h | ||
351 | @@ -XXX,XX +XXX,XX @@ | ||
352 | #ifndef SPARC_HOST_SIGNAL_H | ||
353 | #define SPARC_HOST_SIGNAL_H | ||
354 | |||
355 | -static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
356 | +/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */ | ||
357 | +typedef ucontext_t host_sigcontext; | ||
358 | + | ||
359 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
360 | { | ||
361 | #ifdef __arch64__ | ||
362 | return uc->uc_mcontext.mc_gregs[MC_PC]; | ||
363 | @@ -XXX,XX +XXX,XX @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
364 | #endif | ||
365 | } | ||
366 | |||
367 | -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
368 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
369 | { | ||
370 | #ifdef __arch64__ | ||
371 | uc->uc_mcontext.mc_gregs[MC_PC] = pc; | ||
372 | @@ -XXX,XX +XXX,XX @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
373 | #endif | ||
374 | } | ||
375 | |||
376 | -static inline void *host_signal_mask(ucontext_t *uc) | ||
377 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
378 | { | ||
379 | return &uc->uc_sigmask; | ||
380 | } | ||
381 | |||
382 | -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
383 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
384 | { | ||
385 | uint32_t insn = *(uint32_t *)host_signal_pc(uc); | ||
386 | |||
387 | diff --git a/linux-user/include/host/x86_64/host-signal.h b/linux-user/include/host/x86_64/host-signal.h | ||
388 | index XXXXXXX..XXXXXXX 100644 | ||
389 | --- a/linux-user/include/host/x86_64/host-signal.h | ||
390 | +++ b/linux-user/include/host/x86_64/host-signal.h | ||
391 | @@ -XXX,XX +XXX,XX @@ | ||
392 | #ifndef X86_64_HOST_SIGNAL_H | ||
393 | #define X86_64_HOST_SIGNAL_H | ||
394 | |||
395 | -static inline uintptr_t host_signal_pc(ucontext_t *uc) | ||
396 | +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ | ||
397 | +typedef ucontext_t host_sigcontext; | ||
398 | + | ||
399 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
400 | { | ||
401 | return uc->uc_mcontext.gregs[REG_RIP]; | ||
402 | } | ||
403 | |||
404 | -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) | ||
405 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
406 | { | ||
407 | uc->uc_mcontext.gregs[REG_RIP] = pc; | ||
408 | } | ||
409 | |||
410 | -static inline void *host_signal_mask(ucontext_t *uc) | ||
411 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
412 | { | ||
413 | return &uc->uc_sigmask; | ||
414 | } | ||
415 | |||
416 | -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | ||
417 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
418 | { | ||
419 | return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe | ||
420 | && (uc->uc_mcontext.gregs[REG_ERR] & 0x2); | ||
421 | diff --git a/linux-user/signal.c b/linux-user/signal.c | ||
422 | index XXXXXXX..XXXXXXX 100644 | ||
423 | --- a/linux-user/signal.c | ||
424 | +++ b/linux-user/signal.c | ||
425 | @@ -XXX,XX +XXX,XX @@ void queue_signal(CPUArchState *env, int sig, int si_type, | ||
426 | /* Adjust the signal context to rewind out of safe-syscall if we're in it */ | ||
427 | static inline void rewind_if_in_safe_syscall(void *puc) | ||
428 | { | ||
429 | - ucontext_t *uc = (ucontext_t *)puc; | ||
430 | + host_sigcontext *uc = (host_sigcontext *)puc; | ||
431 | uintptr_t pcreg = host_signal_pc(uc); | ||
432 | |||
433 | if (pcreg > (uintptr_t)safe_syscall_start | ||
434 | @@ -XXX,XX +XXX,XX @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) | ||
435 | CPUState *cpu = env_cpu(env); | ||
436 | TaskState *ts = cpu->opaque; | ||
437 | target_siginfo_t tinfo; | ||
438 | - ucontext_t *uc = puc; | ||
439 | + host_sigcontext *uc = puc; | ||
440 | struct emulated_sigtable *k; | ||
441 | int guest_sig; | ||
442 | uintptr_t pc = 0; | ||
443 | -- | ||
444 | 2.25.1 | ||
445 | |||
446 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We do not support sparc32 as a host, so there's no point in | ||
2 | sparc64 redirecting to sparc. | ||
3 | 1 | ||
4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | linux-user/include/host/sparc/host-signal.h | 71 ------------------- | ||
8 | linux-user/include/host/sparc64/host-signal.h | 64 ++++++++++++++++- | ||
9 | 2 files changed, 63 insertions(+), 72 deletions(-) | ||
10 | delete mode 100644 linux-user/include/host/sparc/host-signal.h | ||
11 | |||
12 | diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/include/host/sparc/host-signal.h | ||
13 | deleted file mode 100644 | ||
14 | index XXXXXXX..XXXXXXX | ||
15 | --- a/linux-user/include/host/sparc/host-signal.h | ||
16 | +++ /dev/null | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | -/* | ||
19 | - * host-signal.h: signal info dependent on the host architecture | ||
20 | - * | ||
21 | - * Copyright (c) 2003-2005 Fabrice Bellard | ||
22 | - * Copyright (c) 2021 Linaro Limited | ||
23 | - * | ||
24 | - * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. | ||
25 | - * See the COPYING file in the top-level directory. | ||
26 | - */ | ||
27 | - | ||
28 | -#ifndef SPARC_HOST_SIGNAL_H | ||
29 | -#define SPARC_HOST_SIGNAL_H | ||
30 | - | ||
31 | -/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */ | ||
32 | -typedef ucontext_t host_sigcontext; | ||
33 | - | ||
34 | -static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
35 | -{ | ||
36 | -#ifdef __arch64__ | ||
37 | - return uc->uc_mcontext.mc_gregs[MC_PC]; | ||
38 | -#else | ||
39 | - return uc->uc_mcontext.gregs[REG_PC]; | ||
40 | -#endif | ||
41 | -} | ||
42 | - | ||
43 | -static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
44 | -{ | ||
45 | -#ifdef __arch64__ | ||
46 | - uc->uc_mcontext.mc_gregs[MC_PC] = pc; | ||
47 | -#else | ||
48 | - uc->uc_mcontext.gregs[REG_PC] = pc; | ||
49 | -#endif | ||
50 | -} | ||
51 | - | ||
52 | -static inline void *host_signal_mask(host_sigcontext *uc) | ||
53 | -{ | ||
54 | - return &uc->uc_sigmask; | ||
55 | -} | ||
56 | - | ||
57 | -static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
58 | -{ | ||
59 | - uint32_t insn = *(uint32_t *)host_signal_pc(uc); | ||
60 | - | ||
61 | - if ((insn >> 30) == 3) { | ||
62 | - switch ((insn >> 19) & 0x3f) { | ||
63 | - case 0x05: /* stb */ | ||
64 | - case 0x15: /* stba */ | ||
65 | - case 0x06: /* sth */ | ||
66 | - case 0x16: /* stha */ | ||
67 | - case 0x04: /* st */ | ||
68 | - case 0x14: /* sta */ | ||
69 | - case 0x07: /* std */ | ||
70 | - case 0x17: /* stda */ | ||
71 | - case 0x0e: /* stx */ | ||
72 | - case 0x1e: /* stxa */ | ||
73 | - case 0x24: /* stf */ | ||
74 | - case 0x34: /* stfa */ | ||
75 | - case 0x27: /* stdf */ | ||
76 | - case 0x37: /* stdfa */ | ||
77 | - case 0x26: /* stqf */ | ||
78 | - case 0x36: /* stqfa */ | ||
79 | - case 0x25: /* stfsr */ | ||
80 | - case 0x3c: /* casa */ | ||
81 | - case 0x3e: /* casxa */ | ||
82 | - return true; | ||
83 | - } | ||
84 | - } | ||
85 | - return false; | ||
86 | -} | ||
87 | - | ||
88 | -#endif | ||
89 | diff --git a/linux-user/include/host/sparc64/host-signal.h b/linux-user/include/host/sparc64/host-signal.h | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/linux-user/include/host/sparc64/host-signal.h | ||
92 | +++ b/linux-user/include/host/sparc64/host-signal.h | ||
93 | @@ -1 +1,63 @@ | ||
94 | -#include "../sparc/host-signal.h" | ||
95 | +/* | ||
96 | + * host-signal.h: signal info dependent on the host architecture | ||
97 | + * | ||
98 | + * Copyright (c) 2003-2005 Fabrice Bellard | ||
99 | + * Copyright (c) 2021 Linaro Limited | ||
100 | + * | ||
101 | + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. | ||
102 | + * See the COPYING file in the top-level directory. | ||
103 | + */ | ||
104 | + | ||
105 | +#ifndef SPARC64_HOST_SIGNAL_H | ||
106 | +#define SPARC64_HOST_SIGNAL_H | ||
107 | + | ||
108 | +/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */ | ||
109 | +typedef ucontext_t host_sigcontext; | ||
110 | + | ||
111 | +static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
112 | +{ | ||
113 | + return uc->uc_mcontext.mc_gregs[MC_PC]; | ||
114 | +} | ||
115 | + | ||
116 | +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
117 | +{ | ||
118 | + uc->uc_mcontext.mc_gregs[MC_PC] = pc; | ||
119 | +} | ||
120 | + | ||
121 | +static inline void *host_signal_mask(host_sigcontext *uc) | ||
122 | +{ | ||
123 | + return &uc->uc_sigmask; | ||
124 | +} | ||
125 | + | ||
126 | +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
127 | +{ | ||
128 | + uint32_t insn = *(uint32_t *)host_signal_pc(uc); | ||
129 | + | ||
130 | + if ((insn >> 30) == 3) { | ||
131 | + switch ((insn >> 19) & 0x3f) { | ||
132 | + case 0x05: /* stb */ | ||
133 | + case 0x15: /* stba */ | ||
134 | + case 0x06: /* sth */ | ||
135 | + case 0x16: /* stha */ | ||
136 | + case 0x04: /* st */ | ||
137 | + case 0x14: /* sta */ | ||
138 | + case 0x07: /* std */ | ||
139 | + case 0x17: /* stda */ | ||
140 | + case 0x0e: /* stx */ | ||
141 | + case 0x1e: /* stxa */ | ||
142 | + case 0x24: /* stf */ | ||
143 | + case 0x34: /* stfa */ | ||
144 | + case 0x27: /* stdf */ | ||
145 | + case 0x37: /* stdfa */ | ||
146 | + case 0x26: /* stqf */ | ||
147 | + case 0x36: /* stqfa */ | ||
148 | + case 0x25: /* stfsr */ | ||
149 | + case 0x3c: /* casa */ | ||
150 | + case 0x3e: /* casxa */ | ||
151 | + return true; | ||
152 | + } | ||
153 | + } | ||
154 | + return false; | ||
155 | +} | ||
156 | + | ||
157 | +#endif | ||
158 | -- | ||
159 | 2.25.1 | ||
160 | |||
161 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Sparc64 is unique on linux in *not* passing ucontext_t as | ||
2 | the third argument to a SA_SIGINFO handler. It passes the | ||
3 | old struct sigcontext instead. | ||
4 | 1 | ||
5 | Set both pc and npc in host_signal_set_pc. | ||
6 | |||
7 | Fixes: 8b5bd461935b ("linux-user/host/sparc: Populate host_signal.h") | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | linux-user/include/host/sparc64/host-signal.h | 17 +++++++++-------- | ||
12 | 1 file changed, 9 insertions(+), 8 deletions(-) | ||
13 | |||
14 | diff --git a/linux-user/include/host/sparc64/host-signal.h b/linux-user/include/host/sparc64/host-signal.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/linux-user/include/host/sparc64/host-signal.h | ||
17 | +++ b/linux-user/include/host/sparc64/host-signal.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | #ifndef SPARC64_HOST_SIGNAL_H | ||
20 | #define SPARC64_HOST_SIGNAL_H | ||
21 | |||
22 | -/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */ | ||
23 | -typedef ucontext_t host_sigcontext; | ||
24 | +/* The third argument to a SA_SIGINFO handler is struct sigcontext. */ | ||
25 | +typedef struct sigcontext host_sigcontext; | ||
26 | |||
27 | -static inline uintptr_t host_signal_pc(host_sigcontext *uc) | ||
28 | +static inline uintptr_t host_signal_pc(host_sigcontext *sc) | ||
29 | { | ||
30 | - return uc->uc_mcontext.mc_gregs[MC_PC]; | ||
31 | + return sc->sigc_regs.tpc; | ||
32 | } | ||
33 | |||
34 | -static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) | ||
35 | +static inline void host_signal_set_pc(host_sigcontext *sc, uintptr_t pc) | ||
36 | { | ||
37 | - uc->uc_mcontext.mc_gregs[MC_PC] = pc; | ||
38 | + sc->sigc_regs.tpc = pc; | ||
39 | + sc->sigc_regs.tnpc = pc + 4; | ||
40 | } | ||
41 | |||
42 | -static inline void *host_signal_mask(host_sigcontext *uc) | ||
43 | +static inline void *host_signal_mask(host_sigcontext *sc) | ||
44 | { | ||
45 | - return &uc->uc_sigmask; | ||
46 | + return &sc->sigc_mask; | ||
47 | } | ||
48 | |||
49 | static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) | ||
50 | -- | ||
51 | 2.25.1 | ||
52 | |||
53 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Idan Horowitz <idan.horowitz@gmail.com> | ||
2 | 1 | ||
3 | When the length of the range is large enough, clearing the whole cache is | ||
4 | faster than iterating over the (possibly extremely large) set of pages | ||
5 | contained in the range. | ||
6 | |||
7 | This mimics the pre-existing similar optimization done on the flush of the | ||
8 | tlb itself. | ||
9 | |||
10 | Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com> | ||
11 | Message-Id: <20220110164754.1066025-1-idan.horowitz@gmail.com> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | --- | ||
15 | accel/tcg/cputlb.c | 9 +++++++++ | ||
16 | 1 file changed, 9 insertions(+) | ||
17 | |||
18 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/accel/tcg/cputlb.c | ||
21 | +++ b/accel/tcg/cputlb.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static void tlb_flush_range_by_mmuidx_async_0(CPUState *cpu, | ||
23 | } | ||
24 | qemu_spin_unlock(&env_tlb(env)->c.lock); | ||
25 | |||
26 | + /* | ||
27 | + * If the length is larger than the jump cache size, then it will take | ||
28 | + * longer to clear each entry individually than it will to clear it all. | ||
29 | + */ | ||
30 | + if (d.len >= (TARGET_PAGE_SIZE * TB_JMP_CACHE_SIZE)) { | ||
31 | + cpu_tb_jmp_cache_clear(cpu); | ||
32 | + return; | ||
33 | + } | ||
34 | + | ||
35 | for (target_ulong i = 0; i < d.len; i += TARGET_PAGE_SIZE) { | ||
36 | tb_flush_jmp_cache(cpu, d.addr + i); | ||
37 | } | ||
38 | -- | ||
39 | 2.25.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Idan Horowitz <idan.horowitz@gmail.com> | ||
2 | 1 | ||
3 | Instead of taking the lock of the cpu work list in order to check if it's | ||
4 | empty, we can just read the head pointer atomically. This decreases | ||
5 | cpu_work_list_empty's share from 5% to 1.3% in a profile of icount-enabled | ||
6 | aarch64-softmmu. | ||
7 | |||
8 | Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com> | ||
9 | Message-Id: <20220114004358.299534-1-idan.horowitz@gmail.com> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | softmmu/cpus.c | 7 +------ | ||
14 | 1 file changed, 1 insertion(+), 6 deletions(-) | ||
15 | |||
16 | diff --git a/softmmu/cpus.c b/softmmu/cpus.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/softmmu/cpus.c | ||
19 | +++ b/softmmu/cpus.c | ||
20 | @@ -XXX,XX +XXX,XX @@ bool cpu_is_stopped(CPUState *cpu) | ||
21 | |||
22 | bool cpu_work_list_empty(CPUState *cpu) | ||
23 | { | ||
24 | - bool ret; | ||
25 | - | ||
26 | - qemu_mutex_lock(&cpu->work_mutex); | ||
27 | - ret = QSIMPLEQ_EMPTY(&cpu->work_list); | ||
28 | - qemu_mutex_unlock(&cpu->work_mutex); | ||
29 | - return ret; | ||
30 | + return QSIMPLEQ_EMPTY_ATOMIC(&cpu->work_list); | ||
31 | } | ||
32 | |||
33 | bool cpu_thread_is_idle(CPUState *cpu) | ||
34 | -- | ||
35 | 2.25.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru> | ||
2 | 1 | ||
3 | Commit aff0e204cb1f1c036a496c94c15f5dfafcd9b4b4 introduced CF_NOIRQ usage, | ||
4 | but one case was forgotten. Record/replay uses one special TB which is not | ||
5 | really executed, but used to cause a correct exception in replay mode. | ||
6 | This patch adds CF_NOIRQ flag for such block. | ||
7 | |||
8 | Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-Id: <164362834054.1754532.7678416881159817273.stgit@pasha-ThinkPad-X280> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | accel/tcg/cpu-exec.c | 3 ++- | ||
14 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/accel/tcg/cpu-exec.c | ||
19 | +++ b/accel/tcg/cpu-exec.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) | ||
21 | if (replay_has_exception() | ||
22 | && cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra == 0) { | ||
23 | /* Execute just one insn to trigger exception pending in the log */ | ||
24 | - cpu->cflags_next_tb = (curr_cflags(cpu) & ~CF_USE_ICOUNT) | 1; | ||
25 | + cpu->cflags_next_tb = (curr_cflags(cpu) & ~CF_USE_ICOUNT) | ||
26 | + | CF_NOIRQ | 1; | ||
27 | } | ||
28 | #endif | ||
29 | return false; | ||
30 | -- | ||
31 | 2.25.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: WANG Xuerui <git@xen0n.name> | ||
2 | 1 | ||
3 | Apparently we were left behind; just renaming MO_Q to MO_UQ is enough. | ||
4 | |||
5 | Fixes: fc313c64345453c7 ("exec/memop: Adding signedness to quad definitions") | ||
6 | Signed-off-by: WANG Xuerui <git@xen0n.name> | ||
7 | Message-Id: <20220206162106.1092364-1-i.qemu@xen0n.name> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | tcg/loongarch64/tcg-target.c.inc | 2 +- | ||
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tcg/loongarch64/tcg-target.c.inc | ||
16 | +++ b/tcg/loongarch64/tcg-target.c.inc | ||
17 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_indexed(TCGContext *s, TCGReg rd, TCGReg rj, | ||
18 | case MO_SL: | ||
19 | tcg_out_opc_ldx_w(s, rd, rj, rk); | ||
20 | break; | ||
21 | - case MO_Q: | ||
22 | + case MO_UQ: | ||
23 | tcg_out_opc_ldx_d(s, rd, rj, rk); | ||
24 | break; | ||
25 | default: | ||
26 | -- | ||
27 | 2.25.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/i386/tcg-target.h | 2 - | ||
5 | tcg/i386/tcg-target.c.inc | 103 ++++++++++++++++++++++++++++++++++++-- | ||
6 | 2 files changed, 98 insertions(+), 7 deletions(-) | ||
7 | 1 | ||
8 | diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h | ||
9 | index XXXXXXX..XXXXXXX 100644 | ||
10 | --- a/tcg/i386/tcg-target.h | ||
11 | +++ b/tcg/i386/tcg-target.h | ||
12 | @@ -XXX,XX +XXX,XX @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, | ||
13 | |||
14 | #define TCG_TARGET_HAS_MEMORY_BSWAP have_movbe | ||
15 | |||
16 | -#ifdef CONFIG_SOFTMMU | ||
17 | #define TCG_TARGET_NEED_LDST_LABELS | ||
18 | -#endif | ||
19 | #define TCG_TARGET_NEED_POOL_LABELS | ||
20 | |||
21 | #endif | ||
22 | diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/tcg/i386/tcg-target.c.inc | ||
25 | +++ b/tcg/i386/tcg-target.c.inc | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | * THE SOFTWARE. | ||
28 | */ | ||
29 | |||
30 | +#include "../tcg-ldst.c.inc" | ||
31 | #include "../tcg-pool.c.inc" | ||
32 | |||
33 | #ifdef CONFIG_DEBUG_TCG | ||
34 | @@ -XXX,XX +XXX,XX @@ static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
35 | #define OPC_VZEROUPPER (0x77 | P_EXT) | ||
36 | #define OPC_XCHG_ax_r32 (0x90) | ||
37 | |||
38 | -#define OPC_GRP3_Ev (0xf7) | ||
39 | -#define OPC_GRP5 (0xff) | ||
40 | +#define OPC_GRP3_Eb (0xf6) | ||
41 | +#define OPC_GRP3_Ev (0xf7) | ||
42 | +#define OPC_GRP5 (0xff) | ||
43 | #define OPC_GRP14 (0x73 | P_EXT | P_DATA16) | ||
44 | |||
45 | /* Group 1 opcode extensions for 0x80-0x83. | ||
46 | @@ -XXX,XX +XXX,XX @@ static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
47 | #define SHIFT_SAR 7 | ||
48 | |||
49 | /* Group 3 opcode extensions for 0xf6, 0xf7. To be used with OPC_GRP3. */ | ||
50 | +#define EXT3_TESTi 0 | ||
51 | #define EXT3_NOT 2 | ||
52 | #define EXT3_NEG 3 | ||
53 | #define EXT3_MUL 4 | ||
54 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_nopn(TCGContext *s, int n) | ||
55 | } | ||
56 | |||
57 | #if defined(CONFIG_SOFTMMU) | ||
58 | -#include "../tcg-ldst.c.inc" | ||
59 | - | ||
60 | /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, | ||
61 | * int mmu_idx, uintptr_t ra) | ||
62 | */ | ||
63 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
64 | tcg_out_jmp(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); | ||
65 | return true; | ||
66 | } | ||
67 | -#elif TCG_TARGET_REG_BITS == 32 | ||
68 | +#else | ||
69 | + | ||
70 | +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addrlo, | ||
71 | + TCGReg addrhi, unsigned a_bits) | ||
72 | +{ | ||
73 | + unsigned a_mask = (1 << a_bits) - 1; | ||
74 | + TCGLabelQemuLdst *label; | ||
75 | + | ||
76 | + /* | ||
77 | + * We are expecting a_bits to max out at 7, so we can usually use testb. | ||
78 | + * For i686, we have to use testl for %esi/%edi. | ||
79 | + */ | ||
80 | + if (a_mask <= 0xff && (TCG_TARGET_REG_BITS == 64 || addrlo < 4)) { | ||
81 | + tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, addrlo); | ||
82 | + tcg_out8(s, a_mask); | ||
83 | + } else { | ||
84 | + tcg_out_modrm(s, OPC_GRP3_Ev, EXT3_TESTi, addrlo); | ||
85 | + tcg_out32(s, a_mask); | ||
86 | + } | ||
87 | + | ||
88 | + /* jne slow_path */ | ||
89 | + tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0); | ||
90 | + | ||
91 | + label = new_ldst_label(s); | ||
92 | + label->is_ld = is_ld; | ||
93 | + label->addrlo_reg = addrlo; | ||
94 | + label->addrhi_reg = addrhi; | ||
95 | + label->raddr = tcg_splitwx_to_rx(s->code_ptr + 4); | ||
96 | + label->label_ptr[0] = s->code_ptr; | ||
97 | + | ||
98 | + s->code_ptr += 4; | ||
99 | +} | ||
100 | + | ||
101 | +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) | ||
102 | +{ | ||
103 | + /* resolve label address */ | ||
104 | + tcg_patch32(l->label_ptr[0], s->code_ptr - l->label_ptr[0] - 4); | ||
105 | + | ||
106 | + if (TCG_TARGET_REG_BITS == 32) { | ||
107 | + int ofs = 0; | ||
108 | + | ||
109 | + tcg_out_st(s, TCG_TYPE_PTR, TCG_AREG0, TCG_REG_ESP, ofs); | ||
110 | + ofs += 4; | ||
111 | + | ||
112 | + tcg_out_st(s, TCG_TYPE_I32, l->addrlo_reg, TCG_REG_ESP, ofs); | ||
113 | + ofs += 4; | ||
114 | + if (TARGET_LONG_BITS == 64) { | ||
115 | + tcg_out_st(s, TCG_TYPE_I32, l->addrhi_reg, TCG_REG_ESP, ofs); | ||
116 | + ofs += 4; | ||
117 | + } | ||
118 | + | ||
119 | + tcg_out_pushi(s, (uintptr_t)l->raddr); | ||
120 | + } else { | ||
121 | + tcg_out_mov(s, TCG_TYPE_TL, tcg_target_call_iarg_regs[1], | ||
122 | + l->addrlo_reg); | ||
123 | + tcg_out_mov(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0); | ||
124 | + | ||
125 | + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_RAX, (uintptr_t)l->raddr); | ||
126 | + tcg_out_push(s, TCG_REG_RAX); | ||
127 | + } | ||
128 | + | ||
129 | + /* "Tail call" to the helper, with the return address back inline. */ | ||
130 | + tcg_out_jmp(s, (const void *)(l->is_ld ? helper_unaligned_ld | ||
131 | + : helper_unaligned_st)); | ||
132 | + return true; | ||
133 | +} | ||
134 | + | ||
135 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
136 | +{ | ||
137 | + return tcg_out_fail_alignment(s, l); | ||
138 | +} | ||
139 | + | ||
140 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
141 | +{ | ||
142 | + return tcg_out_fail_alignment(s, l); | ||
143 | +} | ||
144 | + | ||
145 | +#if TCG_TARGET_REG_BITS == 32 | ||
146 | # define x86_guest_base_seg 0 | ||
147 | # define x86_guest_base_index -1 | ||
148 | # define x86_guest_base_offset guest_base | ||
149 | @@ -XXX,XX +XXX,XX @@ static inline int setup_guest_base_seg(void) | ||
150 | return 0; | ||
151 | } | ||
152 | # endif | ||
153 | +#endif | ||
154 | #endif /* SOFTMMU */ | ||
155 | |||
156 | static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
157 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
158 | #if defined(CONFIG_SOFTMMU) | ||
159 | int mem_index; | ||
160 | tcg_insn_unit *label_ptr[2]; | ||
161 | +#else | ||
162 | + unsigned a_bits; | ||
163 | #endif | ||
164 | |||
165 | datalo = *args++; | ||
166 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
167 | add_qemu_ldst_label(s, true, is64, oi, datalo, datahi, addrlo, addrhi, | ||
168 | s->code_ptr, label_ptr); | ||
169 | #else | ||
170 | + a_bits = get_alignment_bits(opc); | ||
171 | + if (a_bits) { | ||
172 | + tcg_out_test_alignment(s, true, addrlo, addrhi, a_bits); | ||
173 | + } | ||
174 | + | ||
175 | tcg_out_qemu_ld_direct(s, datalo, datahi, addrlo, x86_guest_base_index, | ||
176 | x86_guest_base_offset, x86_guest_base_seg, | ||
177 | is64, opc); | ||
178 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
179 | #if defined(CONFIG_SOFTMMU) | ||
180 | int mem_index; | ||
181 | tcg_insn_unit *label_ptr[2]; | ||
182 | +#else | ||
183 | + unsigned a_bits; | ||
184 | #endif | ||
185 | |||
186 | datalo = *args++; | ||
187 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
188 | add_qemu_ldst_label(s, false, is64, oi, datalo, datahi, addrlo, addrhi, | ||
189 | s->code_ptr, label_ptr); | ||
190 | #else | ||
191 | + a_bits = get_alignment_bits(opc); | ||
192 | + if (a_bits) { | ||
193 | + tcg_out_test_alignment(s, false, addrlo, addrhi, a_bits); | ||
194 | + } | ||
195 | + | ||
196 | tcg_out_qemu_st_direct(s, datalo, datahi, addrlo, x86_guest_base_index, | ||
197 | x86_guest_base_offset, x86_guest_base_seg, opc); | ||
198 | #endif | ||
199 | -- | ||
200 | 2.25.1 | ||
201 | |||
202 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/aarch64/tcg-target.h | 2 - | ||
5 | tcg/aarch64/tcg-target.c.inc | 91 +++++++++++++++++++++++++++++------- | ||
6 | 2 files changed, 74 insertions(+), 19 deletions(-) | ||
7 | 1 | ||
8 | diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h | ||
9 | index XXXXXXX..XXXXXXX 100644 | ||
10 | --- a/tcg/aarch64/tcg-target.h | ||
11 | +++ b/tcg/aarch64/tcg-target.h | ||
12 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
13 | |||
14 | void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); | ||
15 | |||
16 | -#ifdef CONFIG_SOFTMMU | ||
17 | #define TCG_TARGET_NEED_LDST_LABELS | ||
18 | -#endif | ||
19 | #define TCG_TARGET_NEED_POOL_LABELS | ||
20 | |||
21 | #endif /* AARCH64_TCG_TARGET_H */ | ||
22 | diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/tcg/aarch64/tcg-target.c.inc | ||
25 | +++ b/tcg/aarch64/tcg-target.c.inc | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | * See the COPYING file in the top-level directory for details. | ||
28 | */ | ||
29 | |||
30 | +#include "../tcg-ldst.c.inc" | ||
31 | #include "../tcg-pool.c.inc" | ||
32 | #include "qemu/bitops.h" | ||
33 | |||
34 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
35 | I3404_ANDI = 0x12000000, | ||
36 | I3404_ORRI = 0x32000000, | ||
37 | I3404_EORI = 0x52000000, | ||
38 | + I3404_ANDSI = 0x72000000, | ||
39 | |||
40 | /* Move wide immediate instructions. */ | ||
41 | I3405_MOVN = 0x12800000, | ||
42 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_goto_long(TCGContext *s, const tcg_insn_unit *target) | ||
43 | if (offset == sextract64(offset, 0, 26)) { | ||
44 | tcg_out_insn(s, 3206, B, offset); | ||
45 | } else { | ||
46 | - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, (intptr_t)target); | ||
47 | - tcg_out_insn(s, 3207, BR, TCG_REG_TMP); | ||
48 | + /* Choose X9 as a call-clobbered non-LR temporary. */ | ||
49 | + tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_X9, (intptr_t)target); | ||
50 | + tcg_out_insn(s, 3207, BR, TCG_REG_X9); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_cltz(TCGContext *s, TCGType ext, TCGReg d, | ||
55 | } | ||
56 | } | ||
57 | |||
58 | -#ifdef CONFIG_SOFTMMU | ||
59 | -#include "../tcg-ldst.c.inc" | ||
60 | +static void tcg_out_adr(TCGContext *s, TCGReg rd, const void *target) | ||
61 | +{ | ||
62 | + ptrdiff_t offset = tcg_pcrel_diff(s, target); | ||
63 | + tcg_debug_assert(offset == sextract64(offset, 0, 21)); | ||
64 | + tcg_out_insn(s, 3406, ADR, rd, offset); | ||
65 | +} | ||
66 | |||
67 | +#ifdef CONFIG_SOFTMMU | ||
68 | /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, | ||
69 | * MemOpIdx oi, uintptr_t ra) | ||
70 | */ | ||
71 | @@ -XXX,XX +XXX,XX @@ static void * const qemu_st_helpers[MO_SIZE + 1] = { | ||
72 | #endif | ||
73 | }; | ||
74 | |||
75 | -static inline void tcg_out_adr(TCGContext *s, TCGReg rd, const void *target) | ||
76 | -{ | ||
77 | - ptrdiff_t offset = tcg_pcrel_diff(s, target); | ||
78 | - tcg_debug_assert(offset == sextract64(offset, 0, 21)); | ||
79 | - tcg_out_insn(s, 3406, ADR, rd, offset); | ||
80 | -} | ||
81 | - | ||
82 | static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
83 | { | ||
84 | MemOpIdx oi = lb->oi; | ||
85 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_tlb_read(TCGContext *s, TCGReg addr_reg, MemOp opc, | ||
86 | tcg_out_insn(s, 3202, B_C, TCG_COND_NE, 0); | ||
87 | } | ||
88 | |||
89 | +#else | ||
90 | +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addr_reg, | ||
91 | + unsigned a_bits) | ||
92 | +{ | ||
93 | + unsigned a_mask = (1 << a_bits) - 1; | ||
94 | + TCGLabelQemuLdst *label = new_ldst_label(s); | ||
95 | + | ||
96 | + label->is_ld = is_ld; | ||
97 | + label->addrlo_reg = addr_reg; | ||
98 | + | ||
99 | + /* tst addr, #mask */ | ||
100 | + tcg_out_logicali(s, I3404_ANDSI, 0, TCG_REG_XZR, addr_reg, a_mask); | ||
101 | + | ||
102 | + label->label_ptr[0] = s->code_ptr; | ||
103 | + | ||
104 | + /* b.ne slow_path */ | ||
105 | + tcg_out_insn(s, 3202, B_C, TCG_COND_NE, 0); | ||
106 | + | ||
107 | + label->raddr = tcg_splitwx_to_rx(s->code_ptr); | ||
108 | +} | ||
109 | + | ||
110 | +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) | ||
111 | +{ | ||
112 | + if (!reloc_pc19(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { | ||
113 | + return false; | ||
114 | + } | ||
115 | + | ||
116 | + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_X1, l->addrlo_reg); | ||
117 | + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_X0, TCG_AREG0); | ||
118 | + | ||
119 | + /* "Tail call" to the helper, with the return address back inline. */ | ||
120 | + tcg_out_adr(s, TCG_REG_LR, l->raddr); | ||
121 | + tcg_out_goto_long(s, (const void *)(l->is_ld ? helper_unaligned_ld | ||
122 | + : helper_unaligned_st)); | ||
123 | + return true; | ||
124 | +} | ||
125 | + | ||
126 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
127 | +{ | ||
128 | + return tcg_out_fail_alignment(s, l); | ||
129 | +} | ||
130 | + | ||
131 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
132 | +{ | ||
133 | + return tcg_out_fail_alignment(s, l); | ||
134 | +} | ||
135 | #endif /* CONFIG_SOFTMMU */ | ||
136 | |||
137 | static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp memop, TCGType ext, | ||
138 | TCGReg data_r, TCGReg addr_r, | ||
139 | TCGType otype, TCGReg off_r) | ||
140 | { | ||
141 | - /* Byte swapping is left to middle-end expansion. */ | ||
142 | - tcg_debug_assert((memop & MO_BSWAP) == 0); | ||
143 | - | ||
144 | switch (memop & MO_SSIZE) { | ||
145 | case MO_UB: | ||
146 | tcg_out_ldst_r(s, I3312_LDRB, data_r, addr_r, otype, off_r); | ||
147 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp memop, | ||
148 | TCGReg data_r, TCGReg addr_r, | ||
149 | TCGType otype, TCGReg off_r) | ||
150 | { | ||
151 | - /* Byte swapping is left to middle-end expansion. */ | ||
152 | - tcg_debug_assert((memop & MO_BSWAP) == 0); | ||
153 | - | ||
154 | switch (memop & MO_SIZE) { | ||
155 | case MO_8: | ||
156 | tcg_out_ldst_r(s, I3312_STRB, data_r, addr_r, otype, off_r); | ||
157 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, | ||
158 | { | ||
159 | MemOp memop = get_memop(oi); | ||
160 | const TCGType otype = TARGET_LONG_BITS == 64 ? TCG_TYPE_I64 : TCG_TYPE_I32; | ||
161 | + | ||
162 | + /* Byte swapping is left to middle-end expansion. */ | ||
163 | + tcg_debug_assert((memop & MO_BSWAP) == 0); | ||
164 | + | ||
165 | #ifdef CONFIG_SOFTMMU | ||
166 | unsigned mem_index = get_mmuidx(oi); | ||
167 | tcg_insn_unit *label_ptr; | ||
168 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, | ||
169 | add_qemu_ldst_label(s, true, oi, ext, data_reg, addr_reg, | ||
170 | s->code_ptr, label_ptr); | ||
171 | #else /* !CONFIG_SOFTMMU */ | ||
172 | + unsigned a_bits = get_alignment_bits(memop); | ||
173 | + if (a_bits) { | ||
174 | + tcg_out_test_alignment(s, true, addr_reg, a_bits); | ||
175 | + } | ||
176 | if (USE_GUEST_BASE) { | ||
177 | tcg_out_qemu_ld_direct(s, memop, ext, data_reg, | ||
178 | TCG_REG_GUEST_BASE, otype, addr_reg); | ||
179 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, | ||
180 | { | ||
181 | MemOp memop = get_memop(oi); | ||
182 | const TCGType otype = TARGET_LONG_BITS == 64 ? TCG_TYPE_I64 : TCG_TYPE_I32; | ||
183 | + | ||
184 | + /* Byte swapping is left to middle-end expansion. */ | ||
185 | + tcg_debug_assert((memop & MO_BSWAP) == 0); | ||
186 | + | ||
187 | #ifdef CONFIG_SOFTMMU | ||
188 | unsigned mem_index = get_mmuidx(oi); | ||
189 | tcg_insn_unit *label_ptr; | ||
190 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, | ||
191 | add_qemu_ldst_label(s, false, oi, (memop & MO_SIZE)== MO_64, | ||
192 | data_reg, addr_reg, s->code_ptr, label_ptr); | ||
193 | #else /* !CONFIG_SOFTMMU */ | ||
194 | + unsigned a_bits = get_alignment_bits(memop); | ||
195 | + if (a_bits) { | ||
196 | + tcg_out_test_alignment(s, false, addr_reg, a_bits); | ||
197 | + } | ||
198 | if (USE_GUEST_BASE) { | ||
199 | tcg_out_qemu_st_direct(s, memop, data_reg, | ||
200 | TCG_REG_GUEST_BASE, otype, addr_reg); | ||
201 | -- | ||
202 | 2.25.1 | ||
203 | |||
204 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/ppc/tcg-target.h | 2 - | ||
5 | tcg/ppc/tcg-target.c.inc | 98 ++++++++++++++++++++++++++++++++++++---- | ||
6 | 2 files changed, 90 insertions(+), 10 deletions(-) | ||
7 | 1 | ||
8 | diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h | ||
9 | index XXXXXXX..XXXXXXX 100644 | ||
10 | --- a/tcg/ppc/tcg-target.h | ||
11 | +++ b/tcg/ppc/tcg-target.h | ||
12 | @@ -XXX,XX +XXX,XX @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); | ||
13 | #define TCG_TARGET_DEFAULT_MO (0) | ||
14 | #define TCG_TARGET_HAS_MEMORY_BSWAP 1 | ||
15 | |||
16 | -#ifdef CONFIG_SOFTMMU | ||
17 | #define TCG_TARGET_NEED_LDST_LABELS | ||
18 | -#endif | ||
19 | #define TCG_TARGET_NEED_POOL_LABELS | ||
20 | |||
21 | #endif | ||
22 | diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/tcg/ppc/tcg-target.c.inc | ||
25 | +++ b/tcg/ppc/tcg-target.c.inc | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | |||
28 | #include "elf.h" | ||
29 | #include "../tcg-pool.c.inc" | ||
30 | +#include "../tcg-ldst.c.inc" | ||
31 | |||
32 | /* | ||
33 | * Standardize on the _CALL_FOO symbols used by GCC: | ||
34 | @@ -XXX,XX +XXX,XX @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, | ||
35 | } | ||
36 | } | ||
37 | |||
38 | -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) | ||
39 | +static void tcg_out_call_int(TCGContext *s, int lk, | ||
40 | + const tcg_insn_unit *target) | ||
41 | { | ||
42 | #ifdef _CALL_AIX | ||
43 | /* Look through the descriptor. If the branch is in range, and we | ||
44 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) | ||
45 | |||
46 | if (in_range_b(diff) && toc == (uint32_t)toc) { | ||
47 | tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP1, toc); | ||
48 | - tcg_out_b(s, LK, tgt); | ||
49 | + tcg_out_b(s, lk, tgt); | ||
50 | } else { | ||
51 | /* Fold the low bits of the constant into the addresses below. */ | ||
52 | intptr_t arg = (intptr_t)target; | ||
53 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) | ||
54 | tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_TMP1, ofs); | ||
55 | tcg_out32(s, MTSPR | RA(TCG_REG_R0) | CTR); | ||
56 | tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R2, TCG_REG_TMP1, ofs + SZP); | ||
57 | - tcg_out32(s, BCCTR | BO_ALWAYS | LK); | ||
58 | + tcg_out32(s, BCCTR | BO_ALWAYS | lk); | ||
59 | } | ||
60 | #elif defined(_CALL_ELF) && _CALL_ELF == 2 | ||
61 | intptr_t diff; | ||
62 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) | ||
63 | |||
64 | diff = tcg_pcrel_diff(s, target); | ||
65 | if (in_range_b(diff)) { | ||
66 | - tcg_out_b(s, LK, target); | ||
67 | + tcg_out_b(s, lk, target); | ||
68 | } else { | ||
69 | tcg_out32(s, MTSPR | RS(TCG_REG_R12) | CTR); | ||
70 | - tcg_out32(s, BCCTR | BO_ALWAYS | LK); | ||
71 | + tcg_out32(s, BCCTR | BO_ALWAYS | lk); | ||
72 | } | ||
73 | #else | ||
74 | - tcg_out_b(s, LK, target); | ||
75 | + tcg_out_b(s, lk, target); | ||
76 | #endif | ||
77 | } | ||
78 | |||
79 | +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) | ||
80 | +{ | ||
81 | + tcg_out_call_int(s, LK, target); | ||
82 | +} | ||
83 | + | ||
84 | static const uint32_t qemu_ldx_opc[(MO_SSIZE + MO_BSWAP) + 1] = { | ||
85 | [MO_UB] = LBZX, | ||
86 | [MO_UW] = LHZX, | ||
87 | @@ -XXX,XX +XXX,XX @@ static const uint32_t qemu_exts_opc[4] = { | ||
88 | }; | ||
89 | |||
90 | #if defined (CONFIG_SOFTMMU) | ||
91 | -#include "../tcg-ldst.c.inc" | ||
92 | - | ||
93 | /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, | ||
94 | * int mmu_idx, uintptr_t ra) | ||
95 | */ | ||
96 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
97 | tcg_out_b(s, 0, lb->raddr); | ||
98 | return true; | ||
99 | } | ||
100 | +#else | ||
101 | + | ||
102 | +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addrlo, | ||
103 | + TCGReg addrhi, unsigned a_bits) | ||
104 | +{ | ||
105 | + unsigned a_mask = (1 << a_bits) - 1; | ||
106 | + TCGLabelQemuLdst *label = new_ldst_label(s); | ||
107 | + | ||
108 | + label->is_ld = is_ld; | ||
109 | + label->addrlo_reg = addrlo; | ||
110 | + label->addrhi_reg = addrhi; | ||
111 | + | ||
112 | + /* We are expecting a_bits to max out at 7, much lower than ANDI. */ | ||
113 | + tcg_debug_assert(a_bits < 16); | ||
114 | + tcg_out32(s, ANDI | SAI(addrlo, TCG_REG_R0, a_mask)); | ||
115 | + | ||
116 | + label->label_ptr[0] = s->code_ptr; | ||
117 | + tcg_out32(s, BC | BI(0, CR_EQ) | BO_COND_FALSE | LK); | ||
118 | + | ||
119 | + label->raddr = tcg_splitwx_to_rx(s->code_ptr); | ||
120 | +} | ||
121 | + | ||
122 | +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) | ||
123 | +{ | ||
124 | + if (!reloc_pc14(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { | ||
125 | + return false; | ||
126 | + } | ||
127 | + | ||
128 | + if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { | ||
129 | + TCGReg arg = TCG_REG_R4; | ||
130 | +#ifdef TCG_TARGET_CALL_ALIGN_ARGS | ||
131 | + arg |= 1; | ||
132 | +#endif | ||
133 | + if (l->addrlo_reg != arg) { | ||
134 | + tcg_out_mov(s, TCG_TYPE_I32, arg, l->addrhi_reg); | ||
135 | + tcg_out_mov(s, TCG_TYPE_I32, arg + 1, l->addrlo_reg); | ||
136 | + } else if (l->addrhi_reg != arg + 1) { | ||
137 | + tcg_out_mov(s, TCG_TYPE_I32, arg + 1, l->addrlo_reg); | ||
138 | + tcg_out_mov(s, TCG_TYPE_I32, arg, l->addrhi_reg); | ||
139 | + } else { | ||
140 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R0, arg); | ||
141 | + tcg_out_mov(s, TCG_TYPE_I32, arg, arg + 1); | ||
142 | + tcg_out_mov(s, TCG_TYPE_I32, arg + 1, TCG_REG_R0); | ||
143 | + } | ||
144 | + } else { | ||
145 | + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_R4, l->addrlo_reg); | ||
146 | + } | ||
147 | + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_R3, TCG_AREG0); | ||
148 | + | ||
149 | + /* "Tail call" to the helper, with the return address back inline. */ | ||
150 | + tcg_out_call_int(s, 0, (const void *)(l->is_ld ? helper_unaligned_ld | ||
151 | + : helper_unaligned_st)); | ||
152 | + return true; | ||
153 | +} | ||
154 | + | ||
155 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
156 | +{ | ||
157 | + return tcg_out_fail_alignment(s, l); | ||
158 | +} | ||
159 | + | ||
160 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
161 | +{ | ||
162 | + return tcg_out_fail_alignment(s, l); | ||
163 | +} | ||
164 | + | ||
165 | #endif /* SOFTMMU */ | ||
166 | |||
167 | static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
168 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
169 | #ifdef CONFIG_SOFTMMU | ||
170 | int mem_index; | ||
171 | tcg_insn_unit *label_ptr; | ||
172 | +#else | ||
173 | + unsigned a_bits; | ||
174 | #endif | ||
175 | |||
176 | datalo = *args++; | ||
177 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
178 | |||
179 | rbase = TCG_REG_R3; | ||
180 | #else /* !CONFIG_SOFTMMU */ | ||
181 | + a_bits = get_alignment_bits(opc); | ||
182 | + if (a_bits) { | ||
183 | + tcg_out_test_alignment(s, true, addrlo, addrhi, a_bits); | ||
184 | + } | ||
185 | rbase = guest_base ? TCG_GUEST_BASE_REG : 0; | ||
186 | if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { | ||
187 | tcg_out_ext32u(s, TCG_REG_TMP1, addrlo); | ||
188 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
189 | #ifdef CONFIG_SOFTMMU | ||
190 | int mem_index; | ||
191 | tcg_insn_unit *label_ptr; | ||
192 | +#else | ||
193 | + unsigned a_bits; | ||
194 | #endif | ||
195 | |||
196 | datalo = *args++; | ||
197 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
198 | |||
199 | rbase = TCG_REG_R3; | ||
200 | #else /* !CONFIG_SOFTMMU */ | ||
201 | + a_bits = get_alignment_bits(opc); | ||
202 | + if (a_bits) { | ||
203 | + tcg_out_test_alignment(s, false, addrlo, addrhi, a_bits); | ||
204 | + } | ||
205 | rbase = guest_base ? TCG_GUEST_BASE_REG : 0; | ||
206 | if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { | ||
207 | tcg_out_ext32u(s, TCG_REG_TMP1, addrlo); | ||
208 | -- | ||
209 | 2.25.1 | ||
210 | |||
211 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
2 | --- | ||
3 | tcg/riscv/tcg-target.h | 2 -- | ||
4 | tcg/riscv/tcg-target.c.inc | 63 ++++++++++++++++++++++++++++++++++++-- | ||
5 | 2 files changed, 61 insertions(+), 4 deletions(-) | ||
6 | 1 | ||
7 | diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h | ||
8 | index XXXXXXX..XXXXXXX 100644 | ||
9 | --- a/tcg/riscv/tcg-target.h | ||
10 | +++ b/tcg/riscv/tcg-target.h | ||
11 | @@ -XXX,XX +XXX,XX @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); | ||
12 | |||
13 | #define TCG_TARGET_DEFAULT_MO (0) | ||
14 | |||
15 | -#ifdef CONFIG_SOFTMMU | ||
16 | #define TCG_TARGET_NEED_LDST_LABELS | ||
17 | -#endif | ||
18 | #define TCG_TARGET_NEED_POOL_LABELS | ||
19 | |||
20 | #define TCG_TARGET_HAS_MEMORY_BSWAP 0 | ||
21 | diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/tcg/riscv/tcg-target.c.inc | ||
24 | +++ b/tcg/riscv/tcg-target.c.inc | ||
25 | @@ -XXX,XX +XXX,XX @@ | ||
26 | * THE SOFTWARE. | ||
27 | */ | ||
28 | |||
29 | +#include "../tcg-ldst.c.inc" | ||
30 | #include "../tcg-pool.c.inc" | ||
31 | |||
32 | #ifdef CONFIG_DEBUG_TCG | ||
33 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) | ||
34 | */ | ||
35 | |||
36 | #if defined(CONFIG_SOFTMMU) | ||
37 | -#include "../tcg-ldst.c.inc" | ||
38 | - | ||
39 | /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, | ||
40 | * MemOpIdx oi, uintptr_t ra) | ||
41 | */ | ||
42 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
43 | tcg_out_goto(s, l->raddr); | ||
44 | return true; | ||
45 | } | ||
46 | +#else | ||
47 | + | ||
48 | +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addr_reg, | ||
49 | + unsigned a_bits) | ||
50 | +{ | ||
51 | + unsigned a_mask = (1 << a_bits) - 1; | ||
52 | + TCGLabelQemuLdst *l = new_ldst_label(s); | ||
53 | + | ||
54 | + l->is_ld = is_ld; | ||
55 | + l->addrlo_reg = addr_reg; | ||
56 | + | ||
57 | + /* We are expecting a_bits to max out at 7, so we can always use andi. */ | ||
58 | + tcg_debug_assert(a_bits < 12); | ||
59 | + tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_TMP1, addr_reg, a_mask); | ||
60 | + | ||
61 | + l->label_ptr[0] = s->code_ptr; | ||
62 | + tcg_out_opc_branch(s, OPC_BNE, TCG_REG_TMP1, TCG_REG_ZERO, 0); | ||
63 | + | ||
64 | + l->raddr = tcg_splitwx_to_rx(s->code_ptr); | ||
65 | +} | ||
66 | + | ||
67 | +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) | ||
68 | +{ | ||
69 | + /* resolve label address */ | ||
70 | + if (!reloc_sbimm12(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { | ||
71 | + return false; | ||
72 | + } | ||
73 | + | ||
74 | + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_A1, l->addrlo_reg); | ||
75 | + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_A0, TCG_AREG0); | ||
76 | + | ||
77 | + /* tail call, with the return address back inline. */ | ||
78 | + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_RA, (uintptr_t)l->raddr); | ||
79 | + tcg_out_call_int(s, (const void *)(l->is_ld ? helper_unaligned_ld | ||
80 | + : helper_unaligned_st), true); | ||
81 | + return true; | ||
82 | +} | ||
83 | + | ||
84 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
85 | +{ | ||
86 | + return tcg_out_fail_alignment(s, l); | ||
87 | +} | ||
88 | + | ||
89 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
90 | +{ | ||
91 | + return tcg_out_fail_alignment(s, l); | ||
92 | +} | ||
93 | + | ||
94 | #endif /* CONFIG_SOFTMMU */ | ||
95 | |||
96 | static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, | ||
97 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
98 | MemOp opc; | ||
99 | #if defined(CONFIG_SOFTMMU) | ||
100 | tcg_insn_unit *label_ptr[1]; | ||
101 | +#else | ||
102 | + unsigned a_bits; | ||
103 | #endif | ||
104 | TCGReg base = TCG_REG_TMP0; | ||
105 | |||
106 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
107 | tcg_out_ext32u(s, base, addr_regl); | ||
108 | addr_regl = base; | ||
109 | } | ||
110 | + a_bits = get_alignment_bits(opc); | ||
111 | + if (a_bits) { | ||
112 | + tcg_out_test_alignment(s, true, addr_regl, a_bits); | ||
113 | + } | ||
114 | if (guest_base != 0) { | ||
115 | tcg_out_opc_reg(s, OPC_ADD, base, TCG_GUEST_BASE_REG, addr_regl); | ||
116 | } | ||
117 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
118 | MemOp opc; | ||
119 | #if defined(CONFIG_SOFTMMU) | ||
120 | tcg_insn_unit *label_ptr[1]; | ||
121 | +#else | ||
122 | + unsigned a_bits; | ||
123 | #endif | ||
124 | TCGReg base = TCG_REG_TMP0; | ||
125 | |||
126 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
127 | tcg_out_ext32u(s, base, addr_regl); | ||
128 | addr_regl = base; | ||
129 | } | ||
130 | + a_bits = get_alignment_bits(opc); | ||
131 | + if (a_bits) { | ||
132 | + tcg_out_test_alignment(s, false, addr_regl, a_bits); | ||
133 | + } | ||
134 | if (guest_base != 0) { | ||
135 | tcg_out_opc_reg(s, OPC_ADD, base, TCG_GUEST_BASE_REG, addr_regl); | ||
136 | } | ||
137 | -- | ||
138 | 2.25.1 | ||
139 | |||
140 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/s390x/tcg-target.h | 2 -- | ||
5 | tcg/s390x/tcg-target.c.inc | 59 ++++++++++++++++++++++++++++++++++++-- | ||
6 | 2 files changed, 57 insertions(+), 4 deletions(-) | ||
7 | 1 | ||
8 | diff --git a/tcg/s390x/tcg-target.h b/tcg/s390x/tcg-target.h | ||
9 | index XXXXXXX..XXXXXXX 100644 | ||
10 | --- a/tcg/s390x/tcg-target.h | ||
11 | +++ b/tcg/s390x/tcg-target.h | ||
12 | @@ -XXX,XX +XXX,XX @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, | ||
13 | /* no need to flush icache explicitly */ | ||
14 | } | ||
15 | |||
16 | -#ifdef CONFIG_SOFTMMU | ||
17 | #define TCG_TARGET_NEED_LDST_LABELS | ||
18 | -#endif | ||
19 | #define TCG_TARGET_NEED_POOL_LABELS | ||
20 | |||
21 | #endif | ||
22 | diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/tcg/s390x/tcg-target.c.inc | ||
25 | +++ b/tcg/s390x/tcg-target.c.inc | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | #error "unsupported code generation mode" | ||
28 | #endif | ||
29 | |||
30 | +#include "../tcg-ldst.c.inc" | ||
31 | #include "../tcg-pool.c.inc" | ||
32 | #include "elf.h" | ||
33 | |||
34 | @@ -XXX,XX +XXX,XX @@ typedef enum S390Opcode { | ||
35 | RI_OIHL = 0xa509, | ||
36 | RI_OILH = 0xa50a, | ||
37 | RI_OILL = 0xa50b, | ||
38 | + RI_TMLL = 0xa701, | ||
39 | |||
40 | RIE_CGIJ = 0xec7c, | ||
41 | RIE_CGRJ = 0xec64, | ||
42 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg data, | ||
43 | } | ||
44 | |||
45 | #if defined(CONFIG_SOFTMMU) | ||
46 | -#include "../tcg-ldst.c.inc" | ||
47 | - | ||
48 | /* We're expecting to use a 20-bit negative offset on the tlb memory ops. */ | ||
49 | QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) > 0); | ||
50 | QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -(1 << 19)); | ||
51 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
52 | return true; | ||
53 | } | ||
54 | #else | ||
55 | +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, | ||
56 | + TCGReg addrlo, unsigned a_bits) | ||
57 | +{ | ||
58 | + unsigned a_mask = (1 << a_bits) - 1; | ||
59 | + TCGLabelQemuLdst *l = new_ldst_label(s); | ||
60 | + | ||
61 | + l->is_ld = is_ld; | ||
62 | + l->addrlo_reg = addrlo; | ||
63 | + | ||
64 | + /* We are expecting a_bits to max out at 7, much lower than TMLL. */ | ||
65 | + tcg_debug_assert(a_bits < 16); | ||
66 | + tcg_out_insn(s, RI, TMLL, addrlo, a_mask); | ||
67 | + | ||
68 | + tcg_out16(s, RI_BRC | (7 << 4)); /* CC in {1,2,3} */ | ||
69 | + l->label_ptr[0] = s->code_ptr; | ||
70 | + s->code_ptr += 1; | ||
71 | + | ||
72 | + l->raddr = tcg_splitwx_to_rx(s->code_ptr); | ||
73 | +} | ||
74 | + | ||
75 | +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) | ||
76 | +{ | ||
77 | + if (!patch_reloc(l->label_ptr[0], R_390_PC16DBL, | ||
78 | + (intptr_t)tcg_splitwx_to_rx(s->code_ptr), 2)) { | ||
79 | + return false; | ||
80 | + } | ||
81 | + | ||
82 | + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_R3, l->addrlo_reg); | ||
83 | + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_R2, TCG_AREG0); | ||
84 | + | ||
85 | + /* "Tail call" to the helper, with the return address back inline. */ | ||
86 | + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R14, (uintptr_t)l->raddr); | ||
87 | + tgen_gotoi(s, S390_CC_ALWAYS, (const void *)(l->is_ld ? helper_unaligned_ld | ||
88 | + : helper_unaligned_st)); | ||
89 | + return true; | ||
90 | +} | ||
91 | + | ||
92 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
93 | +{ | ||
94 | + return tcg_out_fail_alignment(s, l); | ||
95 | +} | ||
96 | + | ||
97 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
98 | +{ | ||
99 | + return tcg_out_fail_alignment(s, l); | ||
100 | +} | ||
101 | + | ||
102 | static void tcg_prepare_user_ldst(TCGContext *s, TCGReg *addr_reg, | ||
103 | TCGReg *index_reg, tcg_target_long *disp) | ||
104 | { | ||
105 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext* s, TCGReg data_reg, TCGReg addr_reg, | ||
106 | #else | ||
107 | TCGReg index_reg; | ||
108 | tcg_target_long disp; | ||
109 | + unsigned a_bits = get_alignment_bits(opc); | ||
110 | |||
111 | + if (a_bits) { | ||
112 | + tcg_out_test_alignment(s, true, addr_reg, a_bits); | ||
113 | + } | ||
114 | tcg_prepare_user_ldst(s, &addr_reg, &index_reg, &disp); | ||
115 | tcg_out_qemu_ld_direct(s, opc, data_reg, addr_reg, index_reg, disp); | ||
116 | #endif | ||
117 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext* s, TCGReg data_reg, TCGReg addr_reg, | ||
118 | #else | ||
119 | TCGReg index_reg; | ||
120 | tcg_target_long disp; | ||
121 | + unsigned a_bits = get_alignment_bits(opc); | ||
122 | |||
123 | + if (a_bits) { | ||
124 | + tcg_out_test_alignment(s, false, addr_reg, a_bits); | ||
125 | + } | ||
126 | tcg_prepare_user_ldst(s, &addr_reg, &index_reg, &disp); | ||
127 | tcg_out_qemu_st_direct(s, opc, data_reg, addr_reg, index_reg, disp); | ||
128 | #endif | ||
129 | -- | ||
130 | 2.25.1 | ||
131 | |||
132 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/tci.c | 20 ++++++++++++++------ | ||
5 | 1 file changed, 14 insertions(+), 6 deletions(-) | ||
6 | 1 | ||
7 | diff --git a/tcg/tci.c b/tcg/tci.c | ||
8 | index XXXXXXX..XXXXXXX 100644 | ||
9 | --- a/tcg/tci.c | ||
10 | +++ b/tcg/tci.c | ||
11 | @@ -XXX,XX +XXX,XX @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) | ||
12 | static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, | ||
13 | MemOpIdx oi, const void *tb_ptr) | ||
14 | { | ||
15 | - MemOp mop = get_memop(oi) & (MO_BSWAP | MO_SSIZE); | ||
16 | + MemOp mop = get_memop(oi); | ||
17 | uintptr_t ra = (uintptr_t)tb_ptr; | ||
18 | |||
19 | #ifdef CONFIG_SOFTMMU | ||
20 | - switch (mop) { | ||
21 | + switch (mop & (MO_BSWAP | MO_SSIZE)) { | ||
22 | case MO_UB: | ||
23 | return helper_ret_ldub_mmu(env, taddr, oi, ra); | ||
24 | case MO_SB: | ||
25 | @@ -XXX,XX +XXX,XX @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, | ||
26 | } | ||
27 | #else | ||
28 | void *haddr = g2h(env_cpu(env), taddr); | ||
29 | + unsigned a_mask = (1u << get_alignment_bits(mop)) - 1; | ||
30 | uint64_t ret; | ||
31 | |||
32 | set_helper_retaddr(ra); | ||
33 | - switch (mop) { | ||
34 | + if (taddr & a_mask) { | ||
35 | + helper_unaligned_ld(env, taddr); | ||
36 | + } | ||
37 | + switch (mop & (MO_BSWAP | MO_SSIZE)) { | ||
38 | case MO_UB: | ||
39 | ret = ldub_p(haddr); | ||
40 | break; | ||
41 | @@ -XXX,XX +XXX,XX @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, | ||
42 | static void tci_qemu_st(CPUArchState *env, target_ulong taddr, uint64_t val, | ||
43 | MemOpIdx oi, const void *tb_ptr) | ||
44 | { | ||
45 | - MemOp mop = get_memop(oi) & (MO_BSWAP | MO_SSIZE); | ||
46 | + MemOp mop = get_memop(oi); | ||
47 | uintptr_t ra = (uintptr_t)tb_ptr; | ||
48 | |||
49 | #ifdef CONFIG_SOFTMMU | ||
50 | - switch (mop) { | ||
51 | + switch (mop & (MO_BSWAP | MO_SIZE)) { | ||
52 | case MO_UB: | ||
53 | helper_ret_stb_mmu(env, taddr, val, oi, ra); | ||
54 | break; | ||
55 | @@ -XXX,XX +XXX,XX @@ static void tci_qemu_st(CPUArchState *env, target_ulong taddr, uint64_t val, | ||
56 | } | ||
57 | #else | ||
58 | void *haddr = g2h(env_cpu(env), taddr); | ||
59 | + unsigned a_mask = (1u << get_alignment_bits(mop)) - 1; | ||
60 | |||
61 | set_helper_retaddr(ra); | ||
62 | - switch (mop) { | ||
63 | + if (taddr & a_mask) { | ||
64 | + helper_unaligned_st(env, taddr); | ||
65 | + } | ||
66 | + switch (mop & (MO_BSWAP | MO_SIZE)) { | ||
67 | case MO_UB: | ||
68 | stb_p(haddr, val); | ||
69 | break; | ||
70 | -- | ||
71 | 2.25.1 | ||
72 | |||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: WANG Xuerui <git@xen0n.name> | ||
2 | 1 | ||
3 | Signed-off-by: WANG Xuerui <git@xen0n.name> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-Id: <20220106134238.3936163-1-git@xen0n.name> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | tcg/loongarch64/tcg-target.h | 2 - | ||
9 | tcg/loongarch64/tcg-target.c.inc | 71 +++++++++++++++++++++++++++++++- | ||
10 | 2 files changed, 69 insertions(+), 4 deletions(-) | ||
11 | |||
12 | diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/loongarch64/tcg-target.h | ||
15 | +++ b/tcg/loongarch64/tcg-target.h | ||
16 | @@ -XXX,XX +XXX,XX @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); | ||
17 | |||
18 | #define TCG_TARGET_DEFAULT_MO (0) | ||
19 | |||
20 | -#ifdef CONFIG_SOFTMMU | ||
21 | #define TCG_TARGET_NEED_LDST_LABELS | ||
22 | -#endif | ||
23 | |||
24 | #define TCG_TARGET_HAS_MEMORY_BSWAP 0 | ||
25 | |||
26 | diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/tcg/loongarch64/tcg-target.c.inc | ||
29 | +++ b/tcg/loongarch64/tcg-target.c.inc | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | * THE SOFTWARE. | ||
32 | */ | ||
33 | |||
34 | +#include "../tcg-ldst.c.inc" | ||
35 | + | ||
36 | #ifdef CONFIG_DEBUG_TCG | ||
37 | static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { | ||
38 | "zero", | ||
39 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, | ||
40 | */ | ||
41 | |||
42 | #if defined(CONFIG_SOFTMMU) | ||
43 | -#include "../tcg-ldst.c.inc" | ||
44 | - | ||
45 | /* | ||
46 | * helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, | ||
47 | * MemOpIdx oi, uintptr_t ra) | ||
48 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
49 | |||
50 | return tcg_out_goto(s, l->raddr); | ||
51 | } | ||
52 | +#else | ||
53 | + | ||
54 | +/* | ||
55 | + * Alignment helpers for user-mode emulation | ||
56 | + */ | ||
57 | + | ||
58 | +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addr_reg, | ||
59 | + unsigned a_bits) | ||
60 | +{ | ||
61 | + TCGLabelQemuLdst *l = new_ldst_label(s); | ||
62 | + | ||
63 | + l->is_ld = is_ld; | ||
64 | + l->addrlo_reg = addr_reg; | ||
65 | + | ||
66 | + /* | ||
67 | + * Without micro-architecture details, we don't know which of bstrpick or | ||
68 | + * andi is faster, so use bstrpick as it's not constrained by imm field | ||
69 | + * width. (Not to say alignments >= 2^12 are going to happen any time | ||
70 | + * soon, though) | ||
71 | + */ | ||
72 | + tcg_out_opc_bstrpick_d(s, TCG_REG_TMP1, addr_reg, 0, a_bits - 1); | ||
73 | + | ||
74 | + l->label_ptr[0] = s->code_ptr; | ||
75 | + tcg_out_opc_bne(s, TCG_REG_TMP1, TCG_REG_ZERO, 0); | ||
76 | + | ||
77 | + l->raddr = tcg_splitwx_to_rx(s->code_ptr); | ||
78 | +} | ||
79 | + | ||
80 | +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) | ||
81 | +{ | ||
82 | + /* resolve label address */ | ||
83 | + if (!reloc_br_sk16(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { | ||
84 | + return false; | ||
85 | + } | ||
86 | + | ||
87 | + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_A1, l->addrlo_reg); | ||
88 | + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_A0, TCG_AREG0); | ||
89 | + | ||
90 | + /* tail call, with the return address back inline. */ | ||
91 | + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_RA, (uintptr_t)l->raddr); | ||
92 | + tcg_out_call_int(s, (const void *)(l->is_ld ? helper_unaligned_ld | ||
93 | + : helper_unaligned_st), true); | ||
94 | + return true; | ||
95 | +} | ||
96 | + | ||
97 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
98 | +{ | ||
99 | + return tcg_out_fail_alignment(s, l); | ||
100 | +} | ||
101 | + | ||
102 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
103 | +{ | ||
104 | + return tcg_out_fail_alignment(s, l); | ||
105 | +} | ||
106 | + | ||
107 | #endif /* CONFIG_SOFTMMU */ | ||
108 | |||
109 | /* | ||
110 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, TCGType type) | ||
111 | MemOp opc; | ||
112 | #if defined(CONFIG_SOFTMMU) | ||
113 | tcg_insn_unit *label_ptr[1]; | ||
114 | +#else | ||
115 | + unsigned a_bits; | ||
116 | #endif | ||
117 | TCGReg base; | ||
118 | |||
119 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, TCGType type) | ||
120 | data_regl, addr_regl, | ||
121 | s->code_ptr, label_ptr); | ||
122 | #else | ||
123 | + a_bits = get_alignment_bits(opc); | ||
124 | + if (a_bits) { | ||
125 | + tcg_out_test_alignment(s, true, addr_regl, a_bits); | ||
126 | + } | ||
127 | base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); | ||
128 | TCGReg guest_base_reg = USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_REG_ZERO; | ||
129 | tcg_out_qemu_ld_indexed(s, data_regl, base, guest_base_reg, opc, type); | ||
130 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args) | ||
131 | MemOp opc; | ||
132 | #if defined(CONFIG_SOFTMMU) | ||
133 | tcg_insn_unit *label_ptr[1]; | ||
134 | +#else | ||
135 | + unsigned a_bits; | ||
136 | #endif | ||
137 | TCGReg base; | ||
138 | |||
139 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args) | ||
140 | data_regl, addr_regl, | ||
141 | s->code_ptr, label_ptr); | ||
142 | #else | ||
143 | + a_bits = get_alignment_bits(opc); | ||
144 | + if (a_bits) { | ||
145 | + tcg_out_test_alignment(s, false, addr_regl, a_bits); | ||
146 | + } | ||
147 | base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); | ||
148 | TCGReg guest_base_reg = USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_REG_ZERO; | ||
149 | tcg_out_qemu_st_indexed(s, data_regl, base, guest_base_reg, opc); | ||
150 | -- | ||
151 | 2.25.1 | ||
152 | |||
153 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Support for unaligned accesses is difficult for pre-v6 hosts. | ||
2 | While debian still builds for armv4, we cannot use a compile | ||
3 | time test, so test the architecture at runtime and error out. | ||
4 | 1 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | tcg/arm/tcg-target.c.inc | 5 +++++ | ||
9 | 1 file changed, 5 insertions(+) | ||
10 | |||
11 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/tcg/arm/tcg-target.c.inc | ||
14 | +++ b/tcg/arm/tcg-target.c.inc | ||
15 | @@ -XXX,XX +XXX,XX @@ static void tcg_target_init(TCGContext *s) | ||
16 | if (pl != NULL && pl[0] == 'v' && pl[1] >= '4' && pl[1] <= '9') { | ||
17 | arm_arch = pl[1] - '0'; | ||
18 | } | ||
19 | + | ||
20 | + if (arm_arch < 6) { | ||
21 | + error_report("TCG: ARMv%d is unsupported; exiting", arm_arch); | ||
22 | + exit(EXIT_FAILURE); | ||
23 | + } | ||
24 | } | ||
25 | |||
26 | tcg_target_available_regs[TCG_TYPE_I32] = ALL_GENERAL_REGS; | ||
27 | -- | ||
28 | 2.25.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This is now always true, since we require armv6. | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tcg/arm/tcg-target.h | 3 +-- | ||
7 | tcg/arm/tcg-target.c.inc | 35 ++++++----------------------------- | ||
8 | 2 files changed, 7 insertions(+), 31 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/arm/tcg-target.h | ||
13 | +++ b/tcg/arm/tcg-target.h | ||
14 | @@ -XXX,XX +XXX,XX @@ | ||
15 | |||
16 | extern int arm_arch; | ||
17 | |||
18 | -#define use_armv5t_instructions (__ARM_ARCH >= 5 || arm_arch >= 5) | ||
19 | #define use_armv6_instructions (__ARM_ARCH >= 6 || arm_arch >= 6) | ||
20 | #define use_armv7_instructions (__ARM_ARCH >= 7 || arm_arch >= 7) | ||
21 | |||
22 | @@ -XXX,XX +XXX,XX @@ extern bool use_neon_instructions; | ||
23 | #define TCG_TARGET_HAS_eqv_i32 0 | ||
24 | #define TCG_TARGET_HAS_nand_i32 0 | ||
25 | #define TCG_TARGET_HAS_nor_i32 0 | ||
26 | -#define TCG_TARGET_HAS_clz_i32 use_armv5t_instructions | ||
27 | +#define TCG_TARGET_HAS_clz_i32 1 | ||
28 | #define TCG_TARGET_HAS_ctz_i32 use_armv7_instructions | ||
29 | #define TCG_TARGET_HAS_ctpop_i32 0 | ||
30 | #define TCG_TARGET_HAS_deposit_i32 use_armv7_instructions | ||
31 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/tcg/arm/tcg-target.c.inc | ||
34 | +++ b/tcg/arm/tcg-target.c.inc | ||
35 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_b_reg(TCGContext *s, ARMCond cond, TCGReg rn) | ||
36 | * Unless the C portion of QEMU is compiled as thumb, we don't need | ||
37 | * true BX semantics; merely a branch to an address held in a register. | ||
38 | */ | ||
39 | - if (use_armv5t_instructions) { | ||
40 | - tcg_out_bx_reg(s, cond, rn); | ||
41 | - } else { | ||
42 | - tcg_out_mov_reg(s, cond, TCG_REG_PC, rn); | ||
43 | - } | ||
44 | + tcg_out_bx_reg(s, cond, rn); | ||
45 | } | ||
46 | |||
47 | static void tcg_out_dat_imm(TCGContext *s, ARMCond cond, ARMInsn opc, | ||
48 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_goto(TCGContext *s, ARMCond cond, const tcg_insn_unit *addr) | ||
49 | } | ||
50 | |||
51 | /* LDR is interworking from v5t. */ | ||
52 | - if (arm_mode || use_armv5t_instructions) { | ||
53 | - tcg_out_movi_pool(s, cond, TCG_REG_PC, addri); | ||
54 | - return; | ||
55 | - } | ||
56 | - | ||
57 | - /* else v4t */ | ||
58 | - tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); | ||
59 | - tcg_out_bx_reg(s, COND_AL, TCG_REG_TMP); | ||
60 | + tcg_out_movi_pool(s, cond, TCG_REG_PC, addri); | ||
61 | } | ||
62 | |||
63 | /* | ||
64 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *addr) | ||
65 | if (disp - 8 < 0x02000000 && disp - 8 >= -0x02000000) { | ||
66 | if (arm_mode) { | ||
67 | tcg_out_bl_imm(s, COND_AL, disp); | ||
68 | - return; | ||
69 | - } | ||
70 | - if (use_armv5t_instructions) { | ||
71 | + } else { | ||
72 | tcg_out_blx_imm(s, disp); | ||
73 | - return; | ||
74 | } | ||
75 | + return; | ||
76 | } | ||
77 | |||
78 | - if (use_armv5t_instructions) { | ||
79 | - tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); | ||
80 | - tcg_out_blx_reg(s, COND_AL, TCG_REG_TMP); | ||
81 | - } else if (arm_mode) { | ||
82 | - /* ??? Know that movi_pool emits exactly 1 insn. */ | ||
83 | - tcg_out_mov_reg(s, COND_AL, TCG_REG_R14, TCG_REG_PC); | ||
84 | - tcg_out_movi_pool(s, COND_AL, TCG_REG_PC, addri); | ||
85 | - } else { | ||
86 | - tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); | ||
87 | - tcg_out_mov_reg(s, COND_AL, TCG_REG_R14, TCG_REG_PC); | ||
88 | - tcg_out_bx_reg(s, COND_AL, TCG_REG_TMP); | ||
89 | - } | ||
90 | + tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); | ||
91 | + tcg_out_blx_reg(s, COND_AL, TCG_REG_TMP); | ||
92 | } | ||
93 | |||
94 | static void tcg_out_goto_label(TCGContext *s, ARMCond cond, TCGLabel *l) | ||
95 | -- | ||
96 | 2.25.1 | ||
97 | |||
98 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This is now always true, since we require armv6. | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tcg/arm/tcg-target.h | 1 - | ||
7 | tcg/arm/tcg-target.c.inc | 192 ++++++--------------------------------- | ||
8 | 2 files changed, 27 insertions(+), 166 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/arm/tcg-target.h | ||
13 | +++ b/tcg/arm/tcg-target.h | ||
14 | @@ -XXX,XX +XXX,XX @@ | ||
15 | |||
16 | extern int arm_arch; | ||
17 | |||
18 | -#define use_armv6_instructions (__ARM_ARCH >= 6 || arm_arch >= 6) | ||
19 | #define use_armv7_instructions (__ARM_ARCH >= 7 || arm_arch >= 7) | ||
20 | |||
21 | #undef TCG_TARGET_STACK_GROWSUP | ||
22 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/tcg/arm/tcg-target.c.inc | ||
25 | +++ b/tcg/arm/tcg-target.c.inc | ||
26 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_dat_rIN(TCGContext *s, ARMCond cond, ARMInsn opc, | ||
27 | static void tcg_out_mul32(TCGContext *s, ARMCond cond, TCGReg rd, | ||
28 | TCGReg rn, TCGReg rm) | ||
29 | { | ||
30 | - /* if ArchVersion() < 6 && d == n then UNPREDICTABLE; */ | ||
31 | - if (!use_armv6_instructions && rd == rn) { | ||
32 | - if (rd == rm) { | ||
33 | - /* rd == rn == rm; copy an input to tmp first. */ | ||
34 | - tcg_out_mov_reg(s, cond, TCG_REG_TMP, rn); | ||
35 | - rm = rn = TCG_REG_TMP; | ||
36 | - } else { | ||
37 | - rn = rm; | ||
38 | - rm = rd; | ||
39 | - } | ||
40 | - } | ||
41 | /* mul */ | ||
42 | tcg_out32(s, (cond << 28) | 0x90 | (rd << 16) | (rm << 8) | rn); | ||
43 | } | ||
44 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_mul32(TCGContext *s, ARMCond cond, TCGReg rd, | ||
45 | static void tcg_out_umull32(TCGContext *s, ARMCond cond, TCGReg rd0, | ||
46 | TCGReg rd1, TCGReg rn, TCGReg rm) | ||
47 | { | ||
48 | - /* if ArchVersion() < 6 && (dHi == n || dLo == n) then UNPREDICTABLE; */ | ||
49 | - if (!use_armv6_instructions && (rd0 == rn || rd1 == rn)) { | ||
50 | - if (rd0 == rm || rd1 == rm) { | ||
51 | - tcg_out_mov_reg(s, cond, TCG_REG_TMP, rn); | ||
52 | - rn = TCG_REG_TMP; | ||
53 | - } else { | ||
54 | - TCGReg t = rn; | ||
55 | - rn = rm; | ||
56 | - rm = t; | ||
57 | - } | ||
58 | - } | ||
59 | /* umull */ | ||
60 | tcg_out32(s, (cond << 28) | 0x00800090 | | ||
61 | (rd1 << 16) | (rd0 << 12) | (rm << 8) | rn); | ||
62 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_umull32(TCGContext *s, ARMCond cond, TCGReg rd0, | ||
63 | static void tcg_out_smull32(TCGContext *s, ARMCond cond, TCGReg rd0, | ||
64 | TCGReg rd1, TCGReg rn, TCGReg rm) | ||
65 | { | ||
66 | - /* if ArchVersion() < 6 && (dHi == n || dLo == n) then UNPREDICTABLE; */ | ||
67 | - if (!use_armv6_instructions && (rd0 == rn || rd1 == rn)) { | ||
68 | - if (rd0 == rm || rd1 == rm) { | ||
69 | - tcg_out_mov_reg(s, cond, TCG_REG_TMP, rn); | ||
70 | - rn = TCG_REG_TMP; | ||
71 | - } else { | ||
72 | - TCGReg t = rn; | ||
73 | - rn = rm; | ||
74 | - rm = t; | ||
75 | - } | ||
76 | - } | ||
77 | /* smull */ | ||
78 | tcg_out32(s, (cond << 28) | 0x00c00090 | | ||
79 | (rd1 << 16) | (rd0 << 12) | (rm << 8) | rn); | ||
80 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_udiv(TCGContext *s, ARMCond cond, | ||
81 | |||
82 | static void tcg_out_ext8s(TCGContext *s, ARMCond cond, TCGReg rd, TCGReg rn) | ||
83 | { | ||
84 | - if (use_armv6_instructions) { | ||
85 | - /* sxtb */ | ||
86 | - tcg_out32(s, 0x06af0070 | (cond << 28) | (rd << 12) | rn); | ||
87 | - } else { | ||
88 | - tcg_out_dat_reg(s, cond, ARITH_MOV, | ||
89 | - rd, 0, rn, SHIFT_IMM_LSL(24)); | ||
90 | - tcg_out_dat_reg(s, cond, ARITH_MOV, | ||
91 | - rd, 0, rd, SHIFT_IMM_ASR(24)); | ||
92 | - } | ||
93 | + /* sxtb */ | ||
94 | + tcg_out32(s, 0x06af0070 | (cond << 28) | (rd << 12) | rn); | ||
95 | } | ||
96 | |||
97 | static void __attribute__((unused)) | ||
98 | @@ -XXX,XX +XXX,XX @@ tcg_out_ext8u(TCGContext *s, ARMCond cond, TCGReg rd, TCGReg rn) | ||
99 | |||
100 | static void tcg_out_ext16s(TCGContext *s, ARMCond cond, TCGReg rd, TCGReg rn) | ||
101 | { | ||
102 | - if (use_armv6_instructions) { | ||
103 | - /* sxth */ | ||
104 | - tcg_out32(s, 0x06bf0070 | (cond << 28) | (rd << 12) | rn); | ||
105 | - } else { | ||
106 | - tcg_out_dat_reg(s, cond, ARITH_MOV, | ||
107 | - rd, 0, rn, SHIFT_IMM_LSL(16)); | ||
108 | - tcg_out_dat_reg(s, cond, ARITH_MOV, | ||
109 | - rd, 0, rd, SHIFT_IMM_ASR(16)); | ||
110 | - } | ||
111 | + /* sxth */ | ||
112 | + tcg_out32(s, 0x06bf0070 | (cond << 28) | (rd << 12) | rn); | ||
113 | } | ||
114 | |||
115 | static void tcg_out_ext16u(TCGContext *s, ARMCond cond, TCGReg rd, TCGReg rn) | ||
116 | { | ||
117 | - if (use_armv6_instructions) { | ||
118 | - /* uxth */ | ||
119 | - tcg_out32(s, 0x06ff0070 | (cond << 28) | (rd << 12) | rn); | ||
120 | - } else { | ||
121 | - tcg_out_dat_reg(s, cond, ARITH_MOV, | ||
122 | - rd, 0, rn, SHIFT_IMM_LSL(16)); | ||
123 | - tcg_out_dat_reg(s, cond, ARITH_MOV, | ||
124 | - rd, 0, rd, SHIFT_IMM_LSR(16)); | ||
125 | - } | ||
126 | + /* uxth */ | ||
127 | + tcg_out32(s, 0x06ff0070 | (cond << 28) | (rd << 12) | rn); | ||
128 | } | ||
129 | |||
130 | static void tcg_out_bswap16(TCGContext *s, ARMCond cond, | ||
131 | TCGReg rd, TCGReg rn, int flags) | ||
132 | { | ||
133 | - if (use_armv6_instructions) { | ||
134 | - if (flags & TCG_BSWAP_OS) { | ||
135 | - /* revsh */ | ||
136 | - tcg_out32(s, 0x06ff0fb0 | (cond << 28) | (rd << 12) | rn); | ||
137 | - return; | ||
138 | - } | ||
139 | - | ||
140 | - /* rev16 */ | ||
141 | - tcg_out32(s, 0x06bf0fb0 | (cond << 28) | (rd << 12) | rn); | ||
142 | - if ((flags & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { | ||
143 | - /* uxth */ | ||
144 | - tcg_out32(s, 0x06ff0070 | (cond << 28) | (rd << 12) | rd); | ||
145 | - } | ||
146 | + if (flags & TCG_BSWAP_OS) { | ||
147 | + /* revsh */ | ||
148 | + tcg_out32(s, 0x06ff0fb0 | (cond << 28) | (rd << 12) | rn); | ||
149 | return; | ||
150 | } | ||
151 | |||
152 | - if (flags == 0) { | ||
153 | - /* | ||
154 | - * For stores, no input or output extension: | ||
155 | - * rn = xxAB | ||
156 | - * lsr tmp, rn, #8 tmp = 0xxA | ||
157 | - * and tmp, tmp, #0xff tmp = 000A | ||
158 | - * orr rd, tmp, rn, lsl #8 rd = xABA | ||
159 | - */ | ||
160 | - tcg_out_dat_reg(s, cond, ARITH_MOV, | ||
161 | - TCG_REG_TMP, 0, rn, SHIFT_IMM_LSR(8)); | ||
162 | - tcg_out_dat_imm(s, cond, ARITH_AND, TCG_REG_TMP, TCG_REG_TMP, 0xff); | ||
163 | - tcg_out_dat_reg(s, cond, ARITH_ORR, | ||
164 | - rd, TCG_REG_TMP, rn, SHIFT_IMM_LSL(8)); | ||
165 | - return; | ||
166 | + /* rev16 */ | ||
167 | + tcg_out32(s, 0x06bf0fb0 | (cond << 28) | (rd << 12) | rn); | ||
168 | + if ((flags & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { | ||
169 | + /* uxth */ | ||
170 | + tcg_out32(s, 0x06ff0070 | (cond << 28) | (rd << 12) | rd); | ||
171 | } | ||
172 | - | ||
173 | - /* | ||
174 | - * Byte swap, leaving the result at the top of the register. | ||
175 | - * We will then shift down, zero or sign-extending. | ||
176 | - */ | ||
177 | - if (flags & TCG_BSWAP_IZ) { | ||
178 | - /* | ||
179 | - * rn = 00AB | ||
180 | - * ror tmp, rn, #8 tmp = B00A | ||
181 | - * orr tmp, tmp, tmp, lsl #16 tmp = BA00 | ||
182 | - */ | ||
183 | - tcg_out_dat_reg(s, cond, ARITH_MOV, | ||
184 | - TCG_REG_TMP, 0, rn, SHIFT_IMM_ROR(8)); | ||
185 | - tcg_out_dat_reg(s, cond, ARITH_ORR, | ||
186 | - TCG_REG_TMP, TCG_REG_TMP, TCG_REG_TMP, | ||
187 | - SHIFT_IMM_LSL(16)); | ||
188 | - } else { | ||
189 | - /* | ||
190 | - * rn = xxAB | ||
191 | - * and tmp, rn, #0xff00 tmp = 00A0 | ||
192 | - * lsl tmp, tmp, #8 tmp = 0A00 | ||
193 | - * orr tmp, tmp, rn, lsl #24 tmp = BA00 | ||
194 | - */ | ||
195 | - tcg_out_dat_rI(s, cond, ARITH_AND, TCG_REG_TMP, rn, 0xff00, 1); | ||
196 | - tcg_out_dat_reg(s, cond, ARITH_MOV, | ||
197 | - TCG_REG_TMP, 0, TCG_REG_TMP, SHIFT_IMM_LSL(8)); | ||
198 | - tcg_out_dat_reg(s, cond, ARITH_ORR, | ||
199 | - TCG_REG_TMP, TCG_REG_TMP, rn, SHIFT_IMM_LSL(24)); | ||
200 | - } | ||
201 | - tcg_out_dat_reg(s, cond, ARITH_MOV, rd, 0, TCG_REG_TMP, | ||
202 | - (flags & TCG_BSWAP_OS | ||
203 | - ? SHIFT_IMM_ASR(8) : SHIFT_IMM_LSR(8))); | ||
204 | } | ||
205 | |||
206 | static void tcg_out_bswap32(TCGContext *s, ARMCond cond, TCGReg rd, TCGReg rn) | ||
207 | { | ||
208 | - if (use_armv6_instructions) { | ||
209 | - /* rev */ | ||
210 | - tcg_out32(s, 0x06bf0f30 | (cond << 28) | (rd << 12) | rn); | ||
211 | - } else { | ||
212 | - tcg_out_dat_reg(s, cond, ARITH_EOR, | ||
213 | - TCG_REG_TMP, rn, rn, SHIFT_IMM_ROR(16)); | ||
214 | - tcg_out_dat_imm(s, cond, ARITH_BIC, | ||
215 | - TCG_REG_TMP, TCG_REG_TMP, 0xff | 0x800); | ||
216 | - tcg_out_dat_reg(s, cond, ARITH_MOV, | ||
217 | - rd, 0, rn, SHIFT_IMM_ROR(8)); | ||
218 | - tcg_out_dat_reg(s, cond, ARITH_EOR, | ||
219 | - rd, rd, TCG_REG_TMP, SHIFT_IMM_LSR(8)); | ||
220 | - } | ||
221 | + /* rev */ | ||
222 | + tcg_out32(s, 0x06bf0f30 | (cond << 28) | (rd << 12) | rn); | ||
223 | } | ||
224 | |||
225 | static void tcg_out_deposit(TCGContext *s, ARMCond cond, TCGReg rd, | ||
226 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) | ||
227 | { | ||
228 | if (use_armv7_instructions) { | ||
229 | tcg_out32(s, INSN_DMB_ISH); | ||
230 | - } else if (use_armv6_instructions) { | ||
231 | + } else { | ||
232 | tcg_out32(s, INSN_DMB_MCR); | ||
233 | } | ||
234 | } | ||
235 | @@ -XXX,XX +XXX,XX @@ static TCGReg tcg_out_arg_reg64(TCGContext *s, TCGReg argreg, | ||
236 | if (argreg & 1) { | ||
237 | argreg++; | ||
238 | } | ||
239 | - if (use_armv6_instructions && argreg >= 4 | ||
240 | - && (arglo & 1) == 0 && arghi == arglo + 1) { | ||
241 | + if (argreg >= 4 && (arglo & 1) == 0 && arghi == arglo + 1) { | ||
242 | tcg_out_strd_8(s, COND_AL, arglo, | ||
243 | TCG_REG_CALL_STACK, (argreg - 4) * 4); | ||
244 | return argreg + 2; | ||
245 | @@ -XXX,XX +XXX,XX @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi, | ||
246 | int cmp_off = (is_load ? offsetof(CPUTLBEntry, addr_read) | ||
247 | : offsetof(CPUTLBEntry, addr_write)); | ||
248 | int fast_off = TLB_MASK_TABLE_OFS(mem_index); | ||
249 | - int mask_off = fast_off + offsetof(CPUTLBDescFast, mask); | ||
250 | - int table_off = fast_off + offsetof(CPUTLBDescFast, table); | ||
251 | unsigned s_bits = opc & MO_SIZE; | ||
252 | unsigned a_bits = get_alignment_bits(opc); | ||
253 | |||
254 | @@ -XXX,XX +XXX,XX @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi, | ||
255 | } | ||
256 | |||
257 | /* Load env_tlb(env)->f[mmu_idx].{mask,table} into {r0,r1}. */ | ||
258 | - if (use_armv6_instructions) { | ||
259 | - tcg_out_ldrd_8(s, COND_AL, TCG_REG_R0, TCG_AREG0, fast_off); | ||
260 | - } else { | ||
261 | - tcg_out_ld(s, TCG_TYPE_I32, TCG_REG_R0, TCG_AREG0, mask_off); | ||
262 | - tcg_out_ld(s, TCG_TYPE_I32, TCG_REG_R1, TCG_AREG0, table_off); | ||
263 | - } | ||
264 | + tcg_out_ldrd_8(s, COND_AL, TCG_REG_R0, TCG_AREG0, fast_off); | ||
265 | |||
266 | /* Extract the tlb index from the address into R0. */ | ||
267 | tcg_out_dat_reg(s, COND_AL, ARITH_AND, TCG_REG_R0, TCG_REG_R0, addrlo, | ||
268 | @@ -XXX,XX +XXX,XX @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi, | ||
269 | * Load the tlb comparator into R2/R3 and the fast path addend into R1. | ||
270 | */ | ||
271 | if (cmp_off == 0) { | ||
272 | - if (use_armv6_instructions && TARGET_LONG_BITS == 64) { | ||
273 | + if (TARGET_LONG_BITS == 64) { | ||
274 | tcg_out_ldrd_rwb(s, COND_AL, TCG_REG_R2, TCG_REG_R1, TCG_REG_R0); | ||
275 | } else { | ||
276 | tcg_out_ld32_rwb(s, COND_AL, TCG_REG_R2, TCG_REG_R1, TCG_REG_R0); | ||
277 | @@ -XXX,XX +XXX,XX @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi, | ||
278 | } else { | ||
279 | tcg_out_dat_reg(s, COND_AL, ARITH_ADD, | ||
280 | TCG_REG_R1, TCG_REG_R1, TCG_REG_R0, 0); | ||
281 | - if (use_armv6_instructions && TARGET_LONG_BITS == 64) { | ||
282 | + if (TARGET_LONG_BITS == 64) { | ||
283 | tcg_out_ldrd_8(s, COND_AL, TCG_REG_R2, TCG_REG_R1, cmp_off); | ||
284 | } else { | ||
285 | tcg_out_ld32_12(s, COND_AL, TCG_REG_R2, TCG_REG_R1, cmp_off); | ||
286 | } | ||
287 | } | ||
288 | - if (!use_armv6_instructions && TARGET_LONG_BITS == 64) { | ||
289 | - tcg_out_ld32_12(s, COND_AL, TCG_REG_R3, TCG_REG_R1, cmp_off + 4); | ||
290 | - } | ||
291 | |||
292 | /* Load the tlb addend. */ | ||
293 | tcg_out_ld32_12(s, COND_AL, TCG_REG_R1, TCG_REG_R1, | ||
294 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
295 | TCGReg argreg, datalo, datahi; | ||
296 | MemOpIdx oi = lb->oi; | ||
297 | MemOp opc = get_memop(oi); | ||
298 | - void *func; | ||
299 | |||
300 | if (!reloc_pc24(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { | ||
301 | return false; | ||
302 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
303 | argreg = tcg_out_arg_imm32(s, argreg, oi); | ||
304 | argreg = tcg_out_arg_reg32(s, argreg, TCG_REG_R14); | ||
305 | |||
306 | - /* For armv6 we can use the canonical unsigned helpers and minimize | ||
307 | - icache usage. For pre-armv6, use the signed helpers since we do | ||
308 | - not have a single insn sign-extend. */ | ||
309 | - if (use_armv6_instructions) { | ||
310 | - func = qemu_ld_helpers[opc & MO_SIZE]; | ||
311 | - } else { | ||
312 | - func = qemu_ld_helpers[opc & MO_SSIZE]; | ||
313 | - if (opc & MO_SIGN) { | ||
314 | - opc = MO_UL; | ||
315 | - } | ||
316 | - } | ||
317 | - tcg_out_call(s, func); | ||
318 | + /* Use the canonical unsigned helpers and minimize icache usage. */ | ||
319 | + tcg_out_call(s, qemu_ld_helpers[opc & MO_SIZE]); | ||
320 | |||
321 | datalo = lb->datalo_reg; | ||
322 | datahi = lb->datahi_reg; | ||
323 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, | ||
324 | break; | ||
325 | case MO_UQ: | ||
326 | /* Avoid ldrd for user-only emulation, to handle unaligned. */ | ||
327 | - if (USING_SOFTMMU && use_armv6_instructions | ||
328 | + if (USING_SOFTMMU | ||
329 | && (datalo & 1) == 0 && datahi == datalo + 1) { | ||
330 | tcg_out_ldrd_r(s, COND_AL, datalo, addrlo, addend); | ||
331 | } else if (datalo != addend) { | ||
332 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, TCGReg datalo, | ||
333 | break; | ||
334 | case MO_UQ: | ||
335 | /* Avoid ldrd for user-only emulation, to handle unaligned. */ | ||
336 | - if (USING_SOFTMMU && use_armv6_instructions | ||
337 | + if (USING_SOFTMMU | ||
338 | && (datalo & 1) == 0 && datahi == datalo + 1) { | ||
339 | tcg_out_ldrd_8(s, COND_AL, datalo, addrlo, 0); | ||
340 | } else if (datalo == addrlo) { | ||
341 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_index(TCGContext *s, ARMCond cond, MemOp opc, | ||
342 | break; | ||
343 | case MO_64: | ||
344 | /* Avoid strd for user-only emulation, to handle unaligned. */ | ||
345 | - if (USING_SOFTMMU && use_armv6_instructions | ||
346 | + if (USING_SOFTMMU | ||
347 | && (datalo & 1) == 0 && datahi == datalo + 1) { | ||
348 | tcg_out_strd_r(s, cond, datalo, addrlo, addend); | ||
349 | } else { | ||
350 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg datalo, | ||
351 | break; | ||
352 | case MO_64: | ||
353 | /* Avoid strd for user-only emulation, to handle unaligned. */ | ||
354 | - if (USING_SOFTMMU && use_armv6_instructions | ||
355 | + if (USING_SOFTMMU | ||
356 | && (datalo & 1) == 0 && datahi == datalo + 1) { | ||
357 | tcg_out_strd_8(s, COND_AL, datalo, addrlo, 0); | ||
358 | } else { | ||
359 | -- | ||
360 | 2.25.1 | ||
361 | |||
362 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We will shortly allow the use of unaligned memory accesses, | ||
2 | and these require proper alignment. Use get_alignment_bits | ||
3 | to verify and remove USING_SOFTMMU. | ||
4 | 1 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | tcg/arm/tcg-target.c.inc | 23 ++++++++--------------- | ||
9 | 1 file changed, 8 insertions(+), 15 deletions(-) | ||
10 | |||
11 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/tcg/arm/tcg-target.c.inc | ||
14 | +++ b/tcg/arm/tcg-target.c.inc | ||
15 | @@ -XXX,XX +XXX,XX @@ bool use_idiv_instructions; | ||
16 | bool use_neon_instructions; | ||
17 | #endif | ||
18 | |||
19 | -/* ??? Ought to think about changing CONFIG_SOFTMMU to always defined. */ | ||
20 | -#ifdef CONFIG_SOFTMMU | ||
21 | -# define USING_SOFTMMU 1 | ||
22 | -#else | ||
23 | -# define USING_SOFTMMU 0 | ||
24 | -#endif | ||
25 | - | ||
26 | #ifdef CONFIG_DEBUG_TCG | ||
27 | static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { | ||
28 | "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", | ||
29 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, | ||
30 | tcg_out_ld32_r(s, COND_AL, datalo, addrlo, addend); | ||
31 | break; | ||
32 | case MO_UQ: | ||
33 | - /* Avoid ldrd for user-only emulation, to handle unaligned. */ | ||
34 | - if (USING_SOFTMMU | ||
35 | + /* LDRD requires alignment; double-check that. */ | ||
36 | + if (get_alignment_bits(opc) >= MO_64 | ||
37 | && (datalo & 1) == 0 && datahi == datalo + 1) { | ||
38 | tcg_out_ldrd_r(s, COND_AL, datalo, addrlo, addend); | ||
39 | } else if (datalo != addend) { | ||
40 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, TCGReg datalo, | ||
41 | tcg_out_ld32_12(s, COND_AL, datalo, addrlo, 0); | ||
42 | break; | ||
43 | case MO_UQ: | ||
44 | - /* Avoid ldrd for user-only emulation, to handle unaligned. */ | ||
45 | - if (USING_SOFTMMU | ||
46 | + /* LDRD requires alignment; double-check that. */ | ||
47 | + if (get_alignment_bits(opc) >= MO_64 | ||
48 | && (datalo & 1) == 0 && datahi == datalo + 1) { | ||
49 | tcg_out_ldrd_8(s, COND_AL, datalo, addrlo, 0); | ||
50 | } else if (datalo == addrlo) { | ||
51 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_index(TCGContext *s, ARMCond cond, MemOp opc, | ||
52 | tcg_out_st32_r(s, cond, datalo, addrlo, addend); | ||
53 | break; | ||
54 | case MO_64: | ||
55 | - /* Avoid strd for user-only emulation, to handle unaligned. */ | ||
56 | - if (USING_SOFTMMU | ||
57 | + /* STRD requires alignment; double-check that. */ | ||
58 | + if (get_alignment_bits(opc) >= MO_64 | ||
59 | && (datalo & 1) == 0 && datahi == datalo + 1) { | ||
60 | tcg_out_strd_r(s, cond, datalo, addrlo, addend); | ||
61 | } else { | ||
62 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg datalo, | ||
63 | tcg_out_st32_12(s, COND_AL, datalo, addrlo, 0); | ||
64 | break; | ||
65 | case MO_64: | ||
66 | - /* Avoid strd for user-only emulation, to handle unaligned. */ | ||
67 | - if (USING_SOFTMMU | ||
68 | + /* STRD requires alignment; double-check that. */ | ||
69 | + if (get_alignment_bits(opc) >= MO_64 | ||
70 | && (datalo & 1) == 0 && datahi == datalo + 1) { | ||
71 | tcg_out_strd_8(s, COND_AL, datalo, addrlo, 0); | ||
72 | } else { | ||
73 | -- | ||
74 | 2.25.1 | ||
75 | |||
76 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From armv6, the architecture supports unaligned accesses. | ||
2 | All we need to do is perform the correct alignment check | ||
3 | in tcg_out_tlb_read. | ||
4 | 1 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | tcg/arm/tcg-target.c.inc | 41 ++++++++++++++++++++-------------------- | ||
9 | 1 file changed, 21 insertions(+), 20 deletions(-) | ||
10 | |||
11 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/tcg/arm/tcg-target.c.inc | ||
14 | +++ b/tcg/arm/tcg-target.c.inc | ||
15 | @@ -XXX,XX +XXX,XX @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi, | ||
16 | int cmp_off = (is_load ? offsetof(CPUTLBEntry, addr_read) | ||
17 | : offsetof(CPUTLBEntry, addr_write)); | ||
18 | int fast_off = TLB_MASK_TABLE_OFS(mem_index); | ||
19 | - unsigned s_bits = opc & MO_SIZE; | ||
20 | - unsigned a_bits = get_alignment_bits(opc); | ||
21 | - | ||
22 | - /* | ||
23 | - * We don't support inline unaligned acceses, but we can easily | ||
24 | - * support overalignment checks. | ||
25 | - */ | ||
26 | - if (a_bits < s_bits) { | ||
27 | - a_bits = s_bits; | ||
28 | - } | ||
29 | + unsigned s_mask = (1 << (opc & MO_SIZE)) - 1; | ||
30 | + unsigned a_mask = (1 << get_alignment_bits(opc)) - 1; | ||
31 | + TCGReg t_addr; | ||
32 | |||
33 | /* Load env_tlb(env)->f[mmu_idx].{mask,table} into {r0,r1}. */ | ||
34 | tcg_out_ldrd_8(s, COND_AL, TCG_REG_R0, TCG_AREG0, fast_off); | ||
35 | @@ -XXX,XX +XXX,XX @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi, | ||
36 | |||
37 | /* | ||
38 | * Check alignment, check comparators. | ||
39 | - * Do this in no more than 3 insns. Use MOVW for v7, if possible, | ||
40 | + * Do this in 2-4 insns. Use MOVW for v7, if possible, | ||
41 | * to reduce the number of sequential conditional instructions. | ||
42 | * Almost all guests have at least 4k pages, which means that we need | ||
43 | * to clear at least 9 bits even for an 8-byte memory, which means it | ||
44 | * isn't worth checking for an immediate operand for BIC. | ||
45 | + * | ||
46 | + * For unaligned accesses, test the page of the last unit of alignment. | ||
47 | + * This leaves the least significant alignment bits unchanged, and of | ||
48 | + * course must be zero. | ||
49 | */ | ||
50 | + t_addr = addrlo; | ||
51 | + if (a_mask < s_mask) { | ||
52 | + t_addr = TCG_REG_R0; | ||
53 | + tcg_out_dat_imm(s, COND_AL, ARITH_ADD, t_addr, | ||
54 | + addrlo, s_mask - a_mask); | ||
55 | + } | ||
56 | if (use_armv7_instructions && TARGET_PAGE_BITS <= 16) { | ||
57 | - tcg_target_ulong mask = ~(TARGET_PAGE_MASK | ((1 << a_bits) - 1)); | ||
58 | - | ||
59 | - tcg_out_movi32(s, COND_AL, TCG_REG_TMP, mask); | ||
60 | + tcg_out_movi32(s, COND_AL, TCG_REG_TMP, ~(TARGET_PAGE_MASK | a_mask)); | ||
61 | tcg_out_dat_reg(s, COND_AL, ARITH_BIC, TCG_REG_TMP, | ||
62 | - addrlo, TCG_REG_TMP, 0); | ||
63 | + t_addr, TCG_REG_TMP, 0); | ||
64 | tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, TCG_REG_R2, TCG_REG_TMP, 0); | ||
65 | } else { | ||
66 | - if (a_bits) { | ||
67 | - tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, addrlo, | ||
68 | - (1 << a_bits) - 1); | ||
69 | + if (a_mask) { | ||
70 | + tcg_debug_assert(a_mask <= 0xff); | ||
71 | + tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, addrlo, a_mask); | ||
72 | } | ||
73 | - tcg_out_dat_reg(s, COND_AL, ARITH_MOV, TCG_REG_TMP, 0, addrlo, | ||
74 | + tcg_out_dat_reg(s, COND_AL, ARITH_MOV, TCG_REG_TMP, 0, t_addr, | ||
75 | SHIFT_IMM_LSR(TARGET_PAGE_BITS)); | ||
76 | - tcg_out_dat_reg(s, (a_bits ? COND_EQ : COND_AL), ARITH_CMP, | ||
77 | + tcg_out_dat_reg(s, (a_mask ? COND_EQ : COND_AL), ARITH_CMP, | ||
78 | 0, TCG_REG_R2, TCG_REG_TMP, | ||
79 | SHIFT_IMM_LSL(TARGET_PAGE_BITS)); | ||
80 | } | ||
81 | -- | ||
82 | 2.25.1 | ||
83 | |||
84 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reserve a register for the guest_base using aarch64 for reference. | ||
2 | By doing so, we do not have to recompute it for every memory load. | ||
3 | 1 | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/arm/tcg-target.c.inc | 39 ++++++++++++++++++++++++++++----------- | ||
8 | 1 file changed, 28 insertions(+), 11 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/arm/tcg-target.c.inc | ||
13 | +++ b/tcg/arm/tcg-target.c.inc | ||
14 | @@ -XXX,XX +XXX,XX @@ static const int tcg_target_call_oarg_regs[2] = { | ||
15 | |||
16 | #define TCG_REG_TMP TCG_REG_R12 | ||
17 | #define TCG_VEC_TMP TCG_REG_Q15 | ||
18 | +#ifndef CONFIG_SOFTMMU | ||
19 | +#define TCG_REG_GUEST_BASE TCG_REG_R11 | ||
20 | +#endif | ||
21 | |||
22 | typedef enum { | ||
23 | COND_EQ = 0x0, | ||
24 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
25 | |||
26 | static void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, | ||
27 | TCGReg datalo, TCGReg datahi, | ||
28 | - TCGReg addrlo, TCGReg addend) | ||
29 | + TCGReg addrlo, TCGReg addend, | ||
30 | + bool scratch_addend) | ||
31 | { | ||
32 | /* Byte swapping is left to middle-end expansion. */ | ||
33 | tcg_debug_assert((opc & MO_BSWAP) == 0); | ||
34 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, | ||
35 | if (get_alignment_bits(opc) >= MO_64 | ||
36 | && (datalo & 1) == 0 && datahi == datalo + 1) { | ||
37 | tcg_out_ldrd_r(s, COND_AL, datalo, addrlo, addend); | ||
38 | - } else if (datalo != addend) { | ||
39 | + } else if (scratch_addend) { | ||
40 | tcg_out_ld32_rwb(s, COND_AL, datalo, addend, addrlo); | ||
41 | tcg_out_ld32_12(s, COND_AL, datahi, addend, 4); | ||
42 | } else { | ||
43 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
44 | label_ptr = s->code_ptr; | ||
45 | tcg_out_bl_imm(s, COND_NE, 0); | ||
46 | |||
47 | - tcg_out_qemu_ld_index(s, opc, datalo, datahi, addrlo, addend); | ||
48 | + tcg_out_qemu_ld_index(s, opc, datalo, datahi, addrlo, addend, true); | ||
49 | |||
50 | add_qemu_ldst_label(s, true, oi, datalo, datahi, addrlo, addrhi, | ||
51 | s->code_ptr, label_ptr); | ||
52 | #else /* !CONFIG_SOFTMMU */ | ||
53 | if (guest_base) { | ||
54 | - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP, guest_base); | ||
55 | - tcg_out_qemu_ld_index(s, opc, datalo, datahi, addrlo, TCG_REG_TMP); | ||
56 | + tcg_out_qemu_ld_index(s, opc, datalo, datahi, | ||
57 | + addrlo, TCG_REG_GUEST_BASE, false); | ||
58 | } else { | ||
59 | tcg_out_qemu_ld_direct(s, opc, datalo, datahi, addrlo); | ||
60 | } | ||
61 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
62 | |||
63 | static void tcg_out_qemu_st_index(TCGContext *s, ARMCond cond, MemOp opc, | ||
64 | TCGReg datalo, TCGReg datahi, | ||
65 | - TCGReg addrlo, TCGReg addend) | ||
66 | + TCGReg addrlo, TCGReg addend, | ||
67 | + bool scratch_addend) | ||
68 | { | ||
69 | /* Byte swapping is left to middle-end expansion. */ | ||
70 | tcg_debug_assert((opc & MO_BSWAP) == 0); | ||
71 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_index(TCGContext *s, ARMCond cond, MemOp opc, | ||
72 | if (get_alignment_bits(opc) >= MO_64 | ||
73 | && (datalo & 1) == 0 && datahi == datalo + 1) { | ||
74 | tcg_out_strd_r(s, cond, datalo, addrlo, addend); | ||
75 | - } else { | ||
76 | + } else if (scratch_addend) { | ||
77 | tcg_out_st32_rwb(s, cond, datalo, addend, addrlo); | ||
78 | tcg_out_st32_12(s, cond, datahi, addend, 4); | ||
79 | + } else { | ||
80 | + tcg_out_dat_reg(s, cond, ARITH_ADD, TCG_REG_TMP, | ||
81 | + addend, addrlo, SHIFT_IMM_LSL(0)); | ||
82 | + tcg_out_st32_12(s, cond, datalo, TCG_REG_TMP, 0); | ||
83 | + tcg_out_st32_12(s, cond, datahi, TCG_REG_TMP, 4); | ||
84 | } | ||
85 | break; | ||
86 | default: | ||
87 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
88 | mem_index = get_mmuidx(oi); | ||
89 | addend = tcg_out_tlb_read(s, addrlo, addrhi, opc, mem_index, 0); | ||
90 | |||
91 | - tcg_out_qemu_st_index(s, COND_EQ, opc, datalo, datahi, addrlo, addend); | ||
92 | + tcg_out_qemu_st_index(s, COND_EQ, opc, datalo, datahi, | ||
93 | + addrlo, addend, true); | ||
94 | |||
95 | /* The conditional call must come last, as we're going to return here. */ | ||
96 | label_ptr = s->code_ptr; | ||
97 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
98 | s->code_ptr, label_ptr); | ||
99 | #else /* !CONFIG_SOFTMMU */ | ||
100 | if (guest_base) { | ||
101 | - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP, guest_base); | ||
102 | - tcg_out_qemu_st_index(s, COND_AL, opc, datalo, | ||
103 | - datahi, addrlo, TCG_REG_TMP); | ||
104 | + tcg_out_qemu_st_index(s, COND_AL, opc, datalo, datahi, | ||
105 | + addrlo, TCG_REG_GUEST_BASE, false); | ||
106 | } else { | ||
107 | tcg_out_qemu_st_direct(s, opc, datalo, datahi, addrlo); | ||
108 | } | ||
109 | @@ -XXX,XX +XXX,XX @@ static void tcg_target_qemu_prologue(TCGContext *s) | ||
110 | |||
111 | tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]); | ||
112 | |||
113 | +#ifndef CONFIG_SOFTMMU | ||
114 | + if (guest_base) { | ||
115 | + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_GUEST_BASE, guest_base); | ||
116 | + tcg_regset_set_reg(s->reserved_regs, TCG_REG_GUEST_BASE); | ||
117 | + } | ||
118 | +#endif | ||
119 | + | ||
120 | tcg_out_b_reg(s, COND_AL, tcg_target_call_iarg_regs[1]); | ||
121 | |||
122 | /* | ||
123 | -- | ||
124 | 2.25.1 | ||
125 | |||
126 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/arm/tcg-target.h | 2 - | ||
5 | tcg/arm/tcg-target.c.inc | 83 +++++++++++++++++++++++++++++++++++++++- | ||
6 | 2 files changed, 81 insertions(+), 4 deletions(-) | ||
7 | 1 | ||
8 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
9 | index XXXXXXX..XXXXXXX 100644 | ||
10 | --- a/tcg/arm/tcg-target.h | ||
11 | +++ b/tcg/arm/tcg-target.h | ||
12 | @@ -XXX,XX +XXX,XX @@ extern bool use_neon_instructions; | ||
13 | /* not defined -- call should be eliminated at compile time */ | ||
14 | void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); | ||
15 | |||
16 | -#ifdef CONFIG_SOFTMMU | ||
17 | #define TCG_TARGET_NEED_LDST_LABELS | ||
18 | -#endif | ||
19 | #define TCG_TARGET_NEED_POOL_LABELS | ||
20 | |||
21 | #endif | ||
22 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/tcg/arm/tcg-target.c.inc | ||
25 | +++ b/tcg/arm/tcg-target.c.inc | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | */ | ||
28 | |||
29 | #include "elf.h" | ||
30 | +#include "../tcg-ldst.c.inc" | ||
31 | #include "../tcg-pool.c.inc" | ||
32 | |||
33 | int arm_arch = __ARM_ARCH; | ||
34 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vldst(TCGContext *s, ARMInsn insn, | ||
35 | } | ||
36 | |||
37 | #ifdef CONFIG_SOFTMMU | ||
38 | -#include "../tcg-ldst.c.inc" | ||
39 | - | ||
40 | /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, | ||
41 | * int mmu_idx, uintptr_t ra) | ||
42 | */ | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
44 | tcg_out_goto(s, COND_AL, qemu_st_helpers[opc & MO_SIZE]); | ||
45 | return true; | ||
46 | } | ||
47 | +#else | ||
48 | + | ||
49 | +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addrlo, | ||
50 | + TCGReg addrhi, unsigned a_bits) | ||
51 | +{ | ||
52 | + unsigned a_mask = (1 << a_bits) - 1; | ||
53 | + TCGLabelQemuLdst *label = new_ldst_label(s); | ||
54 | + | ||
55 | + label->is_ld = is_ld; | ||
56 | + label->addrlo_reg = addrlo; | ||
57 | + label->addrhi_reg = addrhi; | ||
58 | + | ||
59 | + /* We are expecting a_bits to max out at 7, and can easily support 8. */ | ||
60 | + tcg_debug_assert(a_mask <= 0xff); | ||
61 | + /* tst addr, #mask */ | ||
62 | + tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, addrlo, a_mask); | ||
63 | + | ||
64 | + /* blne slow_path */ | ||
65 | + label->label_ptr[0] = s->code_ptr; | ||
66 | + tcg_out_bl_imm(s, COND_NE, 0); | ||
67 | + | ||
68 | + label->raddr = tcg_splitwx_to_rx(s->code_ptr); | ||
69 | +} | ||
70 | + | ||
71 | +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) | ||
72 | +{ | ||
73 | + if (!reloc_pc24(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { | ||
74 | + return false; | ||
75 | + } | ||
76 | + | ||
77 | + if (TARGET_LONG_BITS == 64) { | ||
78 | + /* 64-bit target address is aligned into R2:R3. */ | ||
79 | + if (l->addrhi_reg != TCG_REG_R2) { | ||
80 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R2, l->addrlo_reg); | ||
81 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R3, l->addrhi_reg); | ||
82 | + } else if (l->addrlo_reg != TCG_REG_R3) { | ||
83 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R3, l->addrhi_reg); | ||
84 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R2, l->addrlo_reg); | ||
85 | + } else { | ||
86 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R1, TCG_REG_R2); | ||
87 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R2, TCG_REG_R3); | ||
88 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R3, TCG_REG_R1); | ||
89 | + } | ||
90 | + } else { | ||
91 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R1, l->addrlo_reg); | ||
92 | + } | ||
93 | + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_AREG0); | ||
94 | + | ||
95 | + /* | ||
96 | + * Tail call to the helper, with the return address back inline, | ||
97 | + * just for the clarity of the debugging traceback -- the helper | ||
98 | + * cannot return. We have used BLNE to arrive here, so LR is | ||
99 | + * already set. | ||
100 | + */ | ||
101 | + tcg_out_goto(s, COND_AL, (const void *) | ||
102 | + (l->is_ld ? helper_unaligned_ld : helper_unaligned_st)); | ||
103 | + return true; | ||
104 | +} | ||
105 | + | ||
106 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
107 | +{ | ||
108 | + return tcg_out_fail_alignment(s, l); | ||
109 | +} | ||
110 | + | ||
111 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
112 | +{ | ||
113 | + return tcg_out_fail_alignment(s, l); | ||
114 | +} | ||
115 | #endif /* SOFTMMU */ | ||
116 | |||
117 | static void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, | ||
118 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
119 | int mem_index; | ||
120 | TCGReg addend; | ||
121 | tcg_insn_unit *label_ptr; | ||
122 | +#else | ||
123 | + unsigned a_bits; | ||
124 | #endif | ||
125 | |||
126 | datalo = *args++; | ||
127 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
128 | add_qemu_ldst_label(s, true, oi, datalo, datahi, addrlo, addrhi, | ||
129 | s->code_ptr, label_ptr); | ||
130 | #else /* !CONFIG_SOFTMMU */ | ||
131 | + a_bits = get_alignment_bits(opc); | ||
132 | + if (a_bits) { | ||
133 | + tcg_out_test_alignment(s, true, addrlo, addrhi, a_bits); | ||
134 | + } | ||
135 | if (guest_base) { | ||
136 | tcg_out_qemu_ld_index(s, opc, datalo, datahi, | ||
137 | addrlo, TCG_REG_GUEST_BASE, false); | ||
138 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
139 | int mem_index; | ||
140 | TCGReg addend; | ||
141 | tcg_insn_unit *label_ptr; | ||
142 | +#else | ||
143 | + unsigned a_bits; | ||
144 | #endif | ||
145 | |||
146 | datalo = *args++; | ||
147 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
148 | add_qemu_ldst_label(s, false, oi, datalo, datahi, addrlo, addrhi, | ||
149 | s->code_ptr, label_ptr); | ||
150 | #else /* !CONFIG_SOFTMMU */ | ||
151 | + a_bits = get_alignment_bits(opc); | ||
152 | + if (a_bits) { | ||
153 | + tcg_out_test_alignment(s, false, addrlo, addrhi, a_bits); | ||
154 | + } | ||
155 | if (guest_base) { | ||
156 | tcg_out_qemu_st_index(s, COND_AL, opc, datalo, datahi, | ||
157 | addrlo, TCG_REG_GUEST_BASE, false); | ||
158 | -- | ||
159 | 2.25.1 | ||
160 | |||
161 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This is kinda sorta the opposite of the other tcg hosts, where | ||
2 | we get (normal) alignment checks for free with host SIGBUS and | ||
3 | need to add code to support unaligned accesses. | ||
4 | 1 | ||
5 | Fortunately, the ISA contains pairs of instructions that are | ||
6 | used to implement unaligned memory accesses. Use them. | ||
7 | |||
8 | Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com> | ||
9 | Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | tcg/mips/tcg-target.h | 2 - | ||
14 | tcg/mips/tcg-target.c.inc | 334 +++++++++++++++++++++++++++++++++++++- | ||
15 | 2 files changed, 328 insertions(+), 8 deletions(-) | ||
16 | |||
17 | diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/tcg/mips/tcg-target.h | ||
20 | +++ b/tcg/mips/tcg-target.h | ||
21 | @@ -XXX,XX +XXX,XX @@ extern bool use_mips32r2_instructions; | ||
22 | void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t) | ||
23 | QEMU_ERROR("code path is reachable"); | ||
24 | |||
25 | -#ifdef CONFIG_SOFTMMU | ||
26 | #define TCG_TARGET_NEED_LDST_LABELS | ||
27 | -#endif | ||
28 | |||
29 | #endif | ||
30 | diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/tcg/mips/tcg-target.c.inc | ||
33 | +++ b/tcg/mips/tcg-target.c.inc | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | * THE SOFTWARE. | ||
36 | */ | ||
37 | |||
38 | +#include "../tcg-ldst.c.inc" | ||
39 | + | ||
40 | #ifdef HOST_WORDS_BIGENDIAN | ||
41 | # define MIPS_BE 1 | ||
42 | #else | ||
43 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
44 | OPC_ORI = 015 << 26, | ||
45 | OPC_XORI = 016 << 26, | ||
46 | OPC_LUI = 017 << 26, | ||
47 | + OPC_BNEL = 025 << 26, | ||
48 | + OPC_BNEZALC_R6 = 030 << 26, | ||
49 | OPC_DADDIU = 031 << 26, | ||
50 | + OPC_LDL = 032 << 26, | ||
51 | + OPC_LDR = 033 << 26, | ||
52 | OPC_LB = 040 << 26, | ||
53 | OPC_LH = 041 << 26, | ||
54 | + OPC_LWL = 042 << 26, | ||
55 | OPC_LW = 043 << 26, | ||
56 | OPC_LBU = 044 << 26, | ||
57 | OPC_LHU = 045 << 26, | ||
58 | + OPC_LWR = 046 << 26, | ||
59 | OPC_LWU = 047 << 26, | ||
60 | OPC_SB = 050 << 26, | ||
61 | OPC_SH = 051 << 26, | ||
62 | + OPC_SWL = 052 << 26, | ||
63 | OPC_SW = 053 << 26, | ||
64 | + OPC_SDL = 054 << 26, | ||
65 | + OPC_SDR = 055 << 26, | ||
66 | + OPC_SWR = 056 << 26, | ||
67 | OPC_LD = 067 << 26, | ||
68 | OPC_SD = 077 << 26, | ||
69 | |||
70 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) | ||
71 | } | ||
72 | |||
73 | #if defined(CONFIG_SOFTMMU) | ||
74 | -#include "../tcg-ldst.c.inc" | ||
75 | - | ||
76 | static void * const qemu_ld_helpers[(MO_SSIZE | MO_BSWAP) + 1] = { | ||
77 | [MO_UB] = helper_ret_ldub_mmu, | ||
78 | [MO_SB] = helper_ret_ldsb_mmu, | ||
79 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
80 | tcg_out_mov(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0); | ||
81 | return true; | ||
82 | } | ||
83 | -#endif | ||
84 | + | ||
85 | +#else | ||
86 | + | ||
87 | +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addrlo, | ||
88 | + TCGReg addrhi, unsigned a_bits) | ||
89 | +{ | ||
90 | + unsigned a_mask = (1 << a_bits) - 1; | ||
91 | + TCGLabelQemuLdst *l = new_ldst_label(s); | ||
92 | + | ||
93 | + l->is_ld = is_ld; | ||
94 | + l->addrlo_reg = addrlo; | ||
95 | + l->addrhi_reg = addrhi; | ||
96 | + | ||
97 | + /* We are expecting a_bits to max out at 7, much lower than ANDI. */ | ||
98 | + tcg_debug_assert(a_bits < 16); | ||
99 | + tcg_out_opc_imm(s, OPC_ANDI, TCG_TMP0, addrlo, a_mask); | ||
100 | + | ||
101 | + l->label_ptr[0] = s->code_ptr; | ||
102 | + if (use_mips32r6_instructions) { | ||
103 | + tcg_out_opc_br(s, OPC_BNEZALC_R6, TCG_REG_ZERO, TCG_TMP0); | ||
104 | + } else { | ||
105 | + tcg_out_opc_br(s, OPC_BNEL, TCG_TMP0, TCG_REG_ZERO); | ||
106 | + tcg_out_nop(s); | ||
107 | + } | ||
108 | + | ||
109 | + l->raddr = tcg_splitwx_to_rx(s->code_ptr); | ||
110 | +} | ||
111 | + | ||
112 | +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) | ||
113 | +{ | ||
114 | + void *target; | ||
115 | + | ||
116 | + if (!reloc_pc16(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { | ||
117 | + return false; | ||
118 | + } | ||
119 | + | ||
120 | + if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { | ||
121 | + /* A0 is env, A1 is skipped, A2:A3 is the uint64_t address. */ | ||
122 | + TCGReg a2 = MIPS_BE ? l->addrhi_reg : l->addrlo_reg; | ||
123 | + TCGReg a3 = MIPS_BE ? l->addrlo_reg : l->addrhi_reg; | ||
124 | + | ||
125 | + if (a3 != TCG_REG_A2) { | ||
126 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A2, a2); | ||
127 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A3, a3); | ||
128 | + } else if (a2 != TCG_REG_A3) { | ||
129 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A3, a3); | ||
130 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A2, a2); | ||
131 | + } else { | ||
132 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_TMP0, TCG_REG_A2); | ||
133 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A2, TCG_REG_A3); | ||
134 | + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A3, TCG_TMP0); | ||
135 | + } | ||
136 | + } else { | ||
137 | + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_A1, l->addrlo_reg); | ||
138 | + } | ||
139 | + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_A0, TCG_AREG0); | ||
140 | + | ||
141 | + /* | ||
142 | + * Tail call to the helper, with the return address back inline. | ||
143 | + * We have arrived here via BNEL, so $31 is already set. | ||
144 | + */ | ||
145 | + target = (l->is_ld ? helper_unaligned_ld : helper_unaligned_st); | ||
146 | + tcg_out_call_int(s, target, true); | ||
147 | + return true; | ||
148 | +} | ||
149 | + | ||
150 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
151 | +{ | ||
152 | + return tcg_out_fail_alignment(s, l); | ||
153 | +} | ||
154 | + | ||
155 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
156 | +{ | ||
157 | + return tcg_out_fail_alignment(s, l); | ||
158 | +} | ||
159 | +#endif /* SOFTMMU */ | ||
160 | |||
161 | static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, | ||
162 | TCGReg base, MemOp opc, bool is_64) | ||
163 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, | ||
164 | } | ||
165 | } | ||
166 | |||
167 | +static void __attribute__((unused)) | ||
168 | +tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, | ||
169 | + TCGReg base, MemOp opc, bool is_64) | ||
170 | +{ | ||
171 | + const MIPSInsn lw1 = MIPS_BE ? OPC_LWL : OPC_LWR; | ||
172 | + const MIPSInsn lw2 = MIPS_BE ? OPC_LWR : OPC_LWL; | ||
173 | + const MIPSInsn ld1 = MIPS_BE ? OPC_LDL : OPC_LDR; | ||
174 | + const MIPSInsn ld2 = MIPS_BE ? OPC_LDR : OPC_LDL; | ||
175 | + | ||
176 | + bool sgn = (opc & MO_SIGN); | ||
177 | + | ||
178 | + switch (opc & (MO_SSIZE | MO_BSWAP)) { | ||
179 | + case MO_SW | MO_BE: | ||
180 | + case MO_UW | MO_BE: | ||
181 | + tcg_out_opc_imm(s, sgn ? OPC_LB : OPC_LBU, TCG_TMP0, base, 0); | ||
182 | + tcg_out_opc_imm(s, OPC_LBU, lo, base, 1); | ||
183 | + if (use_mips32r2_instructions) { | ||
184 | + tcg_out_opc_bf(s, OPC_INS, lo, TCG_TMP0, 31, 8); | ||
185 | + } else { | ||
186 | + tcg_out_opc_sa(s, OPC_SLL, TCG_TMP0, TCG_TMP0, 8); | ||
187 | + tcg_out_opc_reg(s, OPC_OR, lo, TCG_TMP0, TCG_TMP1); | ||
188 | + } | ||
189 | + break; | ||
190 | + | ||
191 | + case MO_SW | MO_LE: | ||
192 | + case MO_UW | MO_LE: | ||
193 | + if (use_mips32r2_instructions && lo != base) { | ||
194 | + tcg_out_opc_imm(s, OPC_LBU, lo, base, 0); | ||
195 | + tcg_out_opc_imm(s, sgn ? OPC_LB : OPC_LBU, TCG_TMP0, base, 1); | ||
196 | + tcg_out_opc_bf(s, OPC_INS, lo, TCG_TMP0, 31, 8); | ||
197 | + } else { | ||
198 | + tcg_out_opc_imm(s, OPC_LBU, TCG_TMP0, base, 0); | ||
199 | + tcg_out_opc_imm(s, sgn ? OPC_LB : OPC_LBU, TCG_TMP1, base, 1); | ||
200 | + tcg_out_opc_sa(s, OPC_SLL, TCG_TMP1, TCG_TMP1, 8); | ||
201 | + tcg_out_opc_reg(s, OPC_OR, lo, TCG_TMP0, TCG_TMP1); | ||
202 | + } | ||
203 | + break; | ||
204 | + | ||
205 | + case MO_SL: | ||
206 | + case MO_UL: | ||
207 | + tcg_out_opc_imm(s, lw1, lo, base, 0); | ||
208 | + tcg_out_opc_imm(s, lw2, lo, base, 3); | ||
209 | + if (TCG_TARGET_REG_BITS == 64 && is_64 && !sgn) { | ||
210 | + tcg_out_ext32u(s, lo, lo); | ||
211 | + } | ||
212 | + break; | ||
213 | + | ||
214 | + case MO_UL | MO_BSWAP: | ||
215 | + case MO_SL | MO_BSWAP: | ||
216 | + if (use_mips32r2_instructions) { | ||
217 | + tcg_out_opc_imm(s, lw1, lo, base, 0); | ||
218 | + tcg_out_opc_imm(s, lw2, lo, base, 3); | ||
219 | + tcg_out_bswap32(s, lo, lo, | ||
220 | + TCG_TARGET_REG_BITS == 64 && is_64 | ||
221 | + ? (sgn ? TCG_BSWAP_OS : TCG_BSWAP_OZ) : 0); | ||
222 | + } else { | ||
223 | + const tcg_insn_unit *subr = | ||
224 | + (TCG_TARGET_REG_BITS == 64 && is_64 && !sgn | ||
225 | + ? bswap32u_addr : bswap32_addr); | ||
226 | + | ||
227 | + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 0); | ||
228 | + tcg_out_bswap_subr(s, subr); | ||
229 | + /* delay slot */ | ||
230 | + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 3); | ||
231 | + tcg_out_mov(s, is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32, lo, TCG_TMP3); | ||
232 | + } | ||
233 | + break; | ||
234 | + | ||
235 | + case MO_UQ: | ||
236 | + if (TCG_TARGET_REG_BITS == 64) { | ||
237 | + tcg_out_opc_imm(s, ld1, lo, base, 0); | ||
238 | + tcg_out_opc_imm(s, ld2, lo, base, 7); | ||
239 | + } else { | ||
240 | + tcg_out_opc_imm(s, lw1, MIPS_BE ? hi : lo, base, 0 + 0); | ||
241 | + tcg_out_opc_imm(s, lw2, MIPS_BE ? hi : lo, base, 0 + 3); | ||
242 | + tcg_out_opc_imm(s, lw1, MIPS_BE ? lo : hi, base, 4 + 0); | ||
243 | + tcg_out_opc_imm(s, lw2, MIPS_BE ? lo : hi, base, 4 + 3); | ||
244 | + } | ||
245 | + break; | ||
246 | + | ||
247 | + case MO_UQ | MO_BSWAP: | ||
248 | + if (TCG_TARGET_REG_BITS == 64) { | ||
249 | + if (use_mips32r2_instructions) { | ||
250 | + tcg_out_opc_imm(s, ld1, lo, base, 0); | ||
251 | + tcg_out_opc_imm(s, ld2, lo, base, 7); | ||
252 | + tcg_out_bswap64(s, lo, lo); | ||
253 | + } else { | ||
254 | + tcg_out_opc_imm(s, ld1, TCG_TMP0, base, 0); | ||
255 | + tcg_out_bswap_subr(s, bswap64_addr); | ||
256 | + /* delay slot */ | ||
257 | + tcg_out_opc_imm(s, ld2, TCG_TMP0, base, 7); | ||
258 | + tcg_out_mov(s, TCG_TYPE_I64, lo, TCG_TMP3); | ||
259 | + } | ||
260 | + } else if (use_mips32r2_instructions) { | ||
261 | + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 0 + 0); | ||
262 | + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 0 + 3); | ||
263 | + tcg_out_opc_imm(s, lw1, TCG_TMP1, base, 4 + 0); | ||
264 | + tcg_out_opc_imm(s, lw2, TCG_TMP1, base, 4 + 3); | ||
265 | + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, TCG_TMP0); | ||
266 | + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, TCG_TMP1); | ||
267 | + tcg_out_opc_sa(s, OPC_ROTR, MIPS_BE ? lo : hi, TCG_TMP0, 16); | ||
268 | + tcg_out_opc_sa(s, OPC_ROTR, MIPS_BE ? hi : lo, TCG_TMP1, 16); | ||
269 | + } else { | ||
270 | + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 0 + 0); | ||
271 | + tcg_out_bswap_subr(s, bswap32_addr); | ||
272 | + /* delay slot */ | ||
273 | + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 0 + 3); | ||
274 | + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 4 + 0); | ||
275 | + tcg_out_mov(s, TCG_TYPE_I32, MIPS_BE ? lo : hi, TCG_TMP3); | ||
276 | + tcg_out_bswap_subr(s, bswap32_addr); | ||
277 | + /* delay slot */ | ||
278 | + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 4 + 3); | ||
279 | + tcg_out_mov(s, TCG_TYPE_I32, MIPS_BE ? hi : lo, TCG_TMP3); | ||
280 | + } | ||
281 | + break; | ||
282 | + | ||
283 | + default: | ||
284 | + g_assert_not_reached(); | ||
285 | + } | ||
286 | +} | ||
287 | + | ||
288 | static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
289 | { | ||
290 | TCGReg addr_regl, addr_regh __attribute__((unused)); | ||
291 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
292 | MemOp opc; | ||
293 | #if defined(CONFIG_SOFTMMU) | ||
294 | tcg_insn_unit *label_ptr[2]; | ||
295 | +#else | ||
296 | + unsigned a_bits, s_bits; | ||
297 | #endif | ||
298 | TCGReg base = TCG_REG_A0; | ||
299 | |||
300 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
301 | } else { | ||
302 | tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl); | ||
303 | } | ||
304 | - tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); | ||
305 | + a_bits = get_alignment_bits(opc); | ||
306 | + s_bits = opc & MO_SIZE; | ||
307 | + /* | ||
308 | + * R6 removes the left/right instructions but requires the | ||
309 | + * system to support misaligned memory accesses. | ||
310 | + */ | ||
311 | + if (use_mips32r6_instructions) { | ||
312 | + if (a_bits) { | ||
313 | + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); | ||
314 | + } | ||
315 | + tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); | ||
316 | + } else { | ||
317 | + if (a_bits && a_bits != s_bits) { | ||
318 | + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); | ||
319 | + } | ||
320 | + if (a_bits >= s_bits) { | ||
321 | + tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); | ||
322 | + } else { | ||
323 | + tcg_out_qemu_ld_unalign(s, data_regl, data_regh, base, opc, is_64); | ||
324 | + } | ||
325 | + } | ||
326 | #endif | ||
327 | } | ||
328 | |||
329 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, | ||
330 | } | ||
331 | } | ||
332 | |||
333 | +static void __attribute__((unused)) | ||
334 | +tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, | ||
335 | + TCGReg base, MemOp opc) | ||
336 | +{ | ||
337 | + const MIPSInsn sw1 = MIPS_BE ? OPC_SWL : OPC_SWR; | ||
338 | + const MIPSInsn sw2 = MIPS_BE ? OPC_SWR : OPC_SWL; | ||
339 | + const MIPSInsn sd1 = MIPS_BE ? OPC_SDL : OPC_SDR; | ||
340 | + const MIPSInsn sd2 = MIPS_BE ? OPC_SDR : OPC_SDL; | ||
341 | + | ||
342 | + /* Don't clutter the code below with checks to avoid bswapping ZERO. */ | ||
343 | + if ((lo | hi) == 0) { | ||
344 | + opc &= ~MO_BSWAP; | ||
345 | + } | ||
346 | + | ||
347 | + switch (opc & (MO_SIZE | MO_BSWAP)) { | ||
348 | + case MO_16 | MO_BE: | ||
349 | + tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, lo, 8); | ||
350 | + tcg_out_opc_imm(s, OPC_SB, TCG_TMP0, base, 0); | ||
351 | + tcg_out_opc_imm(s, OPC_SB, lo, base, 1); | ||
352 | + break; | ||
353 | + | ||
354 | + case MO_16 | MO_LE: | ||
355 | + tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, lo, 8); | ||
356 | + tcg_out_opc_imm(s, OPC_SB, lo, base, 0); | ||
357 | + tcg_out_opc_imm(s, OPC_SB, TCG_TMP0, base, 1); | ||
358 | + break; | ||
359 | + | ||
360 | + case MO_32 | MO_BSWAP: | ||
361 | + tcg_out_bswap32(s, TCG_TMP3, lo, 0); | ||
362 | + lo = TCG_TMP3; | ||
363 | + /* fall through */ | ||
364 | + case MO_32: | ||
365 | + tcg_out_opc_imm(s, sw1, lo, base, 0); | ||
366 | + tcg_out_opc_imm(s, sw2, lo, base, 3); | ||
367 | + break; | ||
368 | + | ||
369 | + case MO_64 | MO_BSWAP: | ||
370 | + if (TCG_TARGET_REG_BITS == 64) { | ||
371 | + tcg_out_bswap64(s, TCG_TMP3, lo); | ||
372 | + lo = TCG_TMP3; | ||
373 | + } else if (use_mips32r2_instructions) { | ||
374 | + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, MIPS_BE ? hi : lo); | ||
375 | + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, MIPS_BE ? lo : hi); | ||
376 | + tcg_out_opc_sa(s, OPC_ROTR, TCG_TMP0, TCG_TMP0, 16); | ||
377 | + tcg_out_opc_sa(s, OPC_ROTR, TCG_TMP1, TCG_TMP1, 16); | ||
378 | + hi = MIPS_BE ? TCG_TMP0 : TCG_TMP1; | ||
379 | + lo = MIPS_BE ? TCG_TMP1 : TCG_TMP0; | ||
380 | + } else { | ||
381 | + tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? lo : hi, 0); | ||
382 | + tcg_out_opc_imm(s, sw1, TCG_TMP3, base, 0 + 0); | ||
383 | + tcg_out_opc_imm(s, sw2, TCG_TMP3, base, 0 + 3); | ||
384 | + tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? hi : lo, 0); | ||
385 | + tcg_out_opc_imm(s, sw1, TCG_TMP3, base, 4 + 0); | ||
386 | + tcg_out_opc_imm(s, sw2, TCG_TMP3, base, 4 + 3); | ||
387 | + break; | ||
388 | + } | ||
389 | + /* fall through */ | ||
390 | + case MO_64: | ||
391 | + if (TCG_TARGET_REG_BITS == 64) { | ||
392 | + tcg_out_opc_imm(s, sd1, lo, base, 0); | ||
393 | + tcg_out_opc_imm(s, sd2, lo, base, 7); | ||
394 | + } else { | ||
395 | + tcg_out_opc_imm(s, sw1, MIPS_BE ? hi : lo, base, 0 + 0); | ||
396 | + tcg_out_opc_imm(s, sw2, MIPS_BE ? hi : lo, base, 0 + 3); | ||
397 | + tcg_out_opc_imm(s, sw1, MIPS_BE ? lo : hi, base, 4 + 0); | ||
398 | + tcg_out_opc_imm(s, sw2, MIPS_BE ? lo : hi, base, 4 + 3); | ||
399 | + } | ||
400 | + break; | ||
401 | + | ||
402 | + default: | ||
403 | + tcg_abort(); | ||
404 | + } | ||
405 | +} | ||
406 | static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
407 | { | ||
408 | TCGReg addr_regl, addr_regh __attribute__((unused)); | ||
409 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
410 | MemOp opc; | ||
411 | #if defined(CONFIG_SOFTMMU) | ||
412 | tcg_insn_unit *label_ptr[2]; | ||
413 | +#else | ||
414 | + unsigned a_bits, s_bits; | ||
415 | #endif | ||
416 | TCGReg base = TCG_REG_A0; | ||
417 | |||
418 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
419 | data_regl, data_regh, addr_regl, addr_regh, | ||
420 | s->code_ptr, label_ptr); | ||
421 | #else | ||
422 | - base = TCG_REG_A0; | ||
423 | if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { | ||
424 | tcg_out_ext32u(s, base, addr_regl); | ||
425 | addr_regl = base; | ||
426 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
427 | } else { | ||
428 | tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl); | ||
429 | } | ||
430 | - tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); | ||
431 | + a_bits = get_alignment_bits(opc); | ||
432 | + s_bits = opc & MO_SIZE; | ||
433 | + /* | ||
434 | + * R6 removes the left/right instructions but requires the | ||
435 | + * system to support misaligned memory accesses. | ||
436 | + */ | ||
437 | + if (use_mips32r6_instructions) { | ||
438 | + if (a_bits) { | ||
439 | + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); | ||
440 | + } | ||
441 | + tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); | ||
442 | + } else { | ||
443 | + if (a_bits && a_bits != s_bits) { | ||
444 | + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); | ||
445 | + } | ||
446 | + if (a_bits >= s_bits) { | ||
447 | + tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); | ||
448 | + } else { | ||
449 | + tcg_out_qemu_st_unalign(s, data_regl, data_regh, base, opc); | ||
450 | + } | ||
451 | + } | ||
452 | #endif | ||
453 | } | ||
454 | |||
455 | -- | ||
456 | 2.25.1 | ||
457 | |||
458 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We can use the routines just added for user-only to emit | ||
2 | unaligned accesses in softmmu mode too. | ||
3 | 1 | ||
4 | Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com> | ||
5 | Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | tcg/mips/tcg-target.c.inc | 91 ++++++++++++++++++++++----------------- | ||
10 | 1 file changed, 51 insertions(+), 40 deletions(-) | ||
11 | |||
12 | diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/mips/tcg-target.c.inc | ||
15 | +++ b/tcg/mips/tcg-target.c.inc | ||
16 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg base, TCGReg addrl, | ||
17 | tcg_insn_unit *label_ptr[2], bool is_load) | ||
18 | { | ||
19 | MemOp opc = get_memop(oi); | ||
20 | - unsigned s_bits = opc & MO_SIZE; | ||
21 | unsigned a_bits = get_alignment_bits(opc); | ||
22 | + unsigned s_bits = opc & MO_SIZE; | ||
23 | + unsigned a_mask = (1 << a_bits) - 1; | ||
24 | + unsigned s_mask = (1 << s_bits) - 1; | ||
25 | int mem_index = get_mmuidx(oi); | ||
26 | int fast_off = TLB_MASK_TABLE_OFS(mem_index); | ||
27 | int mask_off = fast_off + offsetof(CPUTLBDescFast, mask); | ||
28 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg base, TCGReg addrl, | ||
29 | int add_off = offsetof(CPUTLBEntry, addend); | ||
30 | int cmp_off = (is_load ? offsetof(CPUTLBEntry, addr_read) | ||
31 | : offsetof(CPUTLBEntry, addr_write)); | ||
32 | - target_ulong mask; | ||
33 | + target_ulong tlb_mask; | ||
34 | |||
35 | /* Load tlb_mask[mmu_idx] and tlb_table[mmu_idx]. */ | ||
36 | tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP0, TCG_AREG0, mask_off); | ||
37 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg base, TCGReg addrl, | ||
38 | /* Add the tlb_table pointer, creating the CPUTLBEntry address in TMP3. */ | ||
39 | tcg_out_opc_reg(s, ALIAS_PADD, TCG_TMP3, TCG_TMP3, TCG_TMP1); | ||
40 | |||
41 | - /* We don't currently support unaligned accesses. | ||
42 | - We could do so with mips32r6. */ | ||
43 | - if (a_bits < s_bits) { | ||
44 | - a_bits = s_bits; | ||
45 | - } | ||
46 | - | ||
47 | - /* Mask the page bits, keeping the alignment bits to compare against. */ | ||
48 | - mask = (target_ulong)TARGET_PAGE_MASK | ((1 << a_bits) - 1); | ||
49 | - | ||
50 | /* Load the (low-half) tlb comparator. */ | ||
51 | if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { | ||
52 | - tcg_out_ld(s, TCG_TYPE_I32, TCG_TMP0, TCG_TMP3, cmp_off + LO_OFF); | ||
53 | - tcg_out_movi(s, TCG_TYPE_I32, TCG_TMP1, mask); | ||
54 | + tcg_out_ldst(s, OPC_LW, TCG_TMP0, TCG_TMP3, cmp_off + LO_OFF); | ||
55 | } else { | ||
56 | tcg_out_ldst(s, (TARGET_LONG_BITS == 64 ? OPC_LD | ||
57 | : TCG_TARGET_REG_BITS == 64 ? OPC_LWU : OPC_LW), | ||
58 | TCG_TMP0, TCG_TMP3, cmp_off); | ||
59 | - tcg_out_movi(s, TCG_TYPE_TL, TCG_TMP1, mask); | ||
60 | - /* No second compare is required here; | ||
61 | - load the tlb addend for the fast path. */ | ||
62 | - tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP2, TCG_TMP3, add_off); | ||
63 | } | ||
64 | |||
65 | /* Zero extend a 32-bit guest address for a 64-bit host. */ | ||
66 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg base, TCGReg addrl, | ||
67 | tcg_out_ext32u(s, base, addrl); | ||
68 | addrl = base; | ||
69 | } | ||
70 | - tcg_out_opc_reg(s, OPC_AND, TCG_TMP1, TCG_TMP1, addrl); | ||
71 | + | ||
72 | + /* | ||
73 | + * Mask the page bits, keeping the alignment bits to compare against. | ||
74 | + * For unaligned accesses, compare against the end of the access to | ||
75 | + * verify that it does not cross a page boundary. | ||
76 | + */ | ||
77 | + tlb_mask = (target_ulong)TARGET_PAGE_MASK | a_mask; | ||
78 | + tcg_out_movi(s, TCG_TYPE_I32, TCG_TMP1, tlb_mask); | ||
79 | + if (a_mask >= s_mask) { | ||
80 | + tcg_out_opc_reg(s, OPC_AND, TCG_TMP1, TCG_TMP1, addrl); | ||
81 | + } else { | ||
82 | + tcg_out_opc_imm(s, ALIAS_PADDI, TCG_TMP2, addrl, s_mask - a_mask); | ||
83 | + tcg_out_opc_reg(s, OPC_AND, TCG_TMP1, TCG_TMP1, TCG_TMP2); | ||
84 | + } | ||
85 | + | ||
86 | + if (TCG_TARGET_REG_BITS >= TARGET_LONG_BITS) { | ||
87 | + /* Load the tlb addend for the fast path. */ | ||
88 | + tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP2, TCG_TMP3, add_off); | ||
89 | + } | ||
90 | |||
91 | label_ptr[0] = s->code_ptr; | ||
92 | tcg_out_opc_br(s, OPC_BNE, TCG_TMP1, TCG_TMP0); | ||
93 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg base, TCGReg addrl, | ||
94 | /* Load and test the high half tlb comparator. */ | ||
95 | if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { | ||
96 | /* delay slot */ | ||
97 | - tcg_out_ld(s, TCG_TYPE_I32, TCG_TMP0, TCG_TMP3, cmp_off + HI_OFF); | ||
98 | + tcg_out_ldst(s, OPC_LW, TCG_TMP0, TCG_TMP3, cmp_off + HI_OFF); | ||
99 | |||
100 | /* Load the tlb addend for the fast path. */ | ||
101 | tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP2, TCG_TMP3, add_off); | ||
102 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, | ||
103 | } | ||
104 | } | ||
105 | |||
106 | -static void __attribute__((unused)) | ||
107 | -tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, | ||
108 | +static void tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, | ||
109 | TCGReg base, MemOp opc, bool is_64) | ||
110 | { | ||
111 | const MIPSInsn lw1 = MIPS_BE ? OPC_LWL : OPC_LWR; | ||
112 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
113 | #if defined(CONFIG_SOFTMMU) | ||
114 | tcg_insn_unit *label_ptr[2]; | ||
115 | #else | ||
116 | - unsigned a_bits, s_bits; | ||
117 | #endif | ||
118 | + unsigned a_bits, s_bits; | ||
119 | TCGReg base = TCG_REG_A0; | ||
120 | |||
121 | data_regl = *args++; | ||
122 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
123 | addr_regh = (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *args++ : 0); | ||
124 | oi = *args++; | ||
125 | opc = get_memop(oi); | ||
126 | + a_bits = get_alignment_bits(opc); | ||
127 | + s_bits = opc & MO_SIZE; | ||
128 | |||
129 | + /* | ||
130 | + * R6 removes the left/right instructions but requires the | ||
131 | + * system to support misaligned memory accesses. | ||
132 | + */ | ||
133 | #if defined(CONFIG_SOFTMMU) | ||
134 | tcg_out_tlb_load(s, base, addr_regl, addr_regh, oi, label_ptr, 1); | ||
135 | - tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); | ||
136 | + if (use_mips32r6_instructions || a_bits >= s_bits) { | ||
137 | + tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); | ||
138 | + } else { | ||
139 | + tcg_out_qemu_ld_unalign(s, data_regl, data_regh, base, opc, is_64); | ||
140 | + } | ||
141 | add_qemu_ldst_label(s, 1, oi, | ||
142 | (is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32), | ||
143 | data_regl, data_regh, addr_regl, addr_regh, | ||
144 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
145 | } else { | ||
146 | tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl); | ||
147 | } | ||
148 | - a_bits = get_alignment_bits(opc); | ||
149 | - s_bits = opc & MO_SIZE; | ||
150 | - /* | ||
151 | - * R6 removes the left/right instructions but requires the | ||
152 | - * system to support misaligned memory accesses. | ||
153 | - */ | ||
154 | if (use_mips32r6_instructions) { | ||
155 | if (a_bits) { | ||
156 | tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); | ||
157 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, | ||
158 | } | ||
159 | } | ||
160 | |||
161 | -static void __attribute__((unused)) | ||
162 | -tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, | ||
163 | +static void tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, | ||
164 | TCGReg base, MemOp opc) | ||
165 | { | ||
166 | const MIPSInsn sw1 = MIPS_BE ? OPC_SWL : OPC_SWR; | ||
167 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
168 | MemOp opc; | ||
169 | #if defined(CONFIG_SOFTMMU) | ||
170 | tcg_insn_unit *label_ptr[2]; | ||
171 | -#else | ||
172 | - unsigned a_bits, s_bits; | ||
173 | #endif | ||
174 | + unsigned a_bits, s_bits; | ||
175 | TCGReg base = TCG_REG_A0; | ||
176 | |||
177 | data_regl = *args++; | ||
178 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
179 | addr_regh = (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *args++ : 0); | ||
180 | oi = *args++; | ||
181 | opc = get_memop(oi); | ||
182 | + a_bits = get_alignment_bits(opc); | ||
183 | + s_bits = opc & MO_SIZE; | ||
184 | |||
185 | + /* | ||
186 | + * R6 removes the left/right instructions but requires the | ||
187 | + * system to support misaligned memory accesses. | ||
188 | + */ | ||
189 | #if defined(CONFIG_SOFTMMU) | ||
190 | tcg_out_tlb_load(s, base, addr_regl, addr_regh, oi, label_ptr, 0); | ||
191 | - tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); | ||
192 | + if (use_mips32r6_instructions || a_bits >= s_bits) { | ||
193 | + tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); | ||
194 | + } else { | ||
195 | + tcg_out_qemu_st_unalign(s, data_regl, data_regh, base, opc); | ||
196 | + } | ||
197 | add_qemu_ldst_label(s, 0, oi, | ||
198 | (is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32), | ||
199 | data_regl, data_regh, addr_regl, addr_regh, | ||
200 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
201 | } else { | ||
202 | tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl); | ||
203 | } | ||
204 | - a_bits = get_alignment_bits(opc); | ||
205 | - s_bits = opc & MO_SIZE; | ||
206 | - /* | ||
207 | - * R6 removes the left/right instructions but requires the | ||
208 | - * system to support misaligned memory accesses. | ||
209 | - */ | ||
210 | if (use_mips32r6_instructions) { | ||
211 | if (a_bits) { | ||
212 | tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); | ||
213 | -- | ||
214 | 2.25.1 | ||
215 | |||
216 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | When BH is constant, it is constrained to 11 bits for use in MOVCC. | ||
2 | For the cases in which we must load the constant BH into a register, | ||
3 | we do not need the full logic of tcg_out_movi; we can use the simpler | ||
4 | function for emitting a 13 bit constant. | ||
5 | 1 | ||
6 | This eliminates the only case in which TCG_REG_T2 was passed to | ||
7 | tcg_out_movi, which will shortly become invalid. | ||
8 | |||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | tcg/sparc/tcg-target.c.inc | 10 +++++++--- | ||
13 | 1 file changed, 7 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tcg/sparc/tcg-target.c.inc | ||
18 | +++ b/tcg/sparc/tcg-target.c.inc | ||
19 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_addsub2_i64(TCGContext *s, TCGReg rl, TCGReg rh, | ||
20 | if (use_vis3_instructions && !is_sub) { | ||
21 | /* Note that ADDXC doesn't accept immediates. */ | ||
22 | if (bhconst && bh != 0) { | ||
23 | - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_T2, bh); | ||
24 | + tcg_out_movi_imm13(s, TCG_REG_T2, bh); | ||
25 | bh = TCG_REG_T2; | ||
26 | } | ||
27 | tcg_out_arith(s, rh, ah, bh, ARITH_ADDXC); | ||
28 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_addsub2_i64(TCGContext *s, TCGReg rl, TCGReg rh, | ||
29 | tcg_out_movcc(s, TCG_COND_GEU, MOVCC_XCC, rh, ah, 0); | ||
30 | } | ||
31 | } else { | ||
32 | - /* Otherwise adjust BH as if there is carry into T2 ... */ | ||
33 | + /* | ||
34 | + * Otherwise adjust BH as if there is carry into T2. | ||
35 | + * Note that constant BH is constrained to 11 bits for the MOVCC, | ||
36 | + * so the adjustment fits 12 bits. | ||
37 | + */ | ||
38 | if (bhconst) { | ||
39 | - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_T2, bh + (is_sub ? -1 : 1)); | ||
40 | + tcg_out_movi_imm13(s, TCG_REG_T2, bh + (is_sub ? -1 : 1)); | ||
41 | } else { | ||
42 | tcg_out_arithi(s, TCG_REG_T2, bh, 1, | ||
43 | is_sub ? ARITH_SUB : ARITH_ADD); | ||
44 | -- | ||
45 | 2.25.1 | ||
46 | |||
47 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Handle 32-bit constants with a separate function, so that | ||
2 | tcg_out_movi_int does not need to recurse. This slightly | ||
3 | rearranges the order of tests for small constants, but | ||
4 | produces the same output. | ||
5 | 1 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | tcg/sparc/tcg-target.c.inc | 36 +++++++++++++++++++++--------------- | ||
10 | 1 file changed, 21 insertions(+), 15 deletions(-) | ||
11 | |||
12 | diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/sparc/tcg-target.c.inc | ||
15 | +++ b/tcg/sparc/tcg-target.c.inc | ||
16 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_movi_imm13(TCGContext *s, TCGReg ret, int32_t arg) | ||
17 | tcg_out_arithi(s, ret, TCG_REG_G0, arg, ARITH_OR); | ||
18 | } | ||
19 | |||
20 | +static void tcg_out_movi_imm32(TCGContext *s, TCGReg ret, int32_t arg) | ||
21 | +{ | ||
22 | + if (check_fit_i32(arg, 13)) { | ||
23 | + /* A 13-bit constant sign-extended to 64-bits. */ | ||
24 | + tcg_out_movi_imm13(s, ret, arg); | ||
25 | + } else { | ||
26 | + /* A 32-bit constant zero-extended to 64 bits. */ | ||
27 | + tcg_out_sethi(s, ret, arg); | ||
28 | + if (arg & 0x3ff) { | ||
29 | + tcg_out_arithi(s, ret, ret, arg & 0x3ff, ARITH_OR); | ||
30 | + } | ||
31 | + } | ||
32 | +} | ||
33 | + | ||
34 | static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, | ||
35 | tcg_target_long arg, bool in_prologue) | ||
36 | { | ||
37 | tcg_target_long hi, lo = (int32_t)arg; | ||
38 | tcg_target_long test, lsb; | ||
39 | |||
40 | - /* Make sure we test 32-bit constants for imm13 properly. */ | ||
41 | - if (type == TCG_TYPE_I32) { | ||
42 | - arg = lo; | ||
43 | + /* A 32-bit constant, or 32-bit zero-extended to 64-bits. */ | ||
44 | + if (type == TCG_TYPE_I32 || arg == (uint32_t)arg) { | ||
45 | + tcg_out_movi_imm32(s, ret, arg); | ||
46 | + return; | ||
47 | } | ||
48 | |||
49 | /* A 13-bit constant sign-extended to 64-bits. */ | ||
50 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, | ||
51 | } | ||
52 | } | ||
53 | |||
54 | - /* A 32-bit constant, or 32-bit zero-extended to 64-bits. */ | ||
55 | - if (type == TCG_TYPE_I32 || arg == (uint32_t)arg) { | ||
56 | - tcg_out_sethi(s, ret, arg); | ||
57 | - if (arg & 0x3ff) { | ||
58 | - tcg_out_arithi(s, ret, ret, arg & 0x3ff, ARITH_OR); | ||
59 | - } | ||
60 | - return; | ||
61 | - } | ||
62 | - | ||
63 | /* A 32-bit constant sign-extended to 64-bits. */ | ||
64 | if (arg == lo) { | ||
65 | tcg_out_sethi(s, ret, ~arg); | ||
66 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, | ||
67 | /* A 64-bit constant decomposed into 2 32-bit pieces. */ | ||
68 | if (check_fit_i32(lo, 13)) { | ||
69 | hi = (arg - lo) >> 32; | ||
70 | - tcg_out_movi(s, TCG_TYPE_I32, ret, hi); | ||
71 | + tcg_out_movi_imm32(s, ret, hi); | ||
72 | tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX); | ||
73 | tcg_out_arithi(s, ret, ret, lo, ARITH_ADD); | ||
74 | } else { | ||
75 | hi = arg >> 32; | ||
76 | - tcg_out_movi(s, TCG_TYPE_I32, ret, hi); | ||
77 | - tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T2, lo); | ||
78 | + tcg_out_movi_imm32(s, ret, hi); | ||
79 | + tcg_out_movi_imm32(s, TCG_REG_T2, lo); | ||
80 | tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX); | ||
81 | tcg_out_arith(s, ret, ret, TCG_REG_T2, ARITH_OR); | ||
82 | } | ||
83 | -- | ||
84 | 2.25.1 | ||
85 | |||
86 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This will allow us to control exactly what scratch register is | ||
2 | used for loading the constant. | ||
3 | 1 | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/sparc/tcg-target.c.inc | 15 +++++++++------ | ||
8 | 1 file changed, 9 insertions(+), 6 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/sparc/tcg-target.c.inc | ||
13 | +++ b/tcg/sparc/tcg-target.c.inc | ||
14 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_movi_imm32(TCGContext *s, TCGReg ret, int32_t arg) | ||
15 | } | ||
16 | |||
17 | static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, | ||
18 | - tcg_target_long arg, bool in_prologue) | ||
19 | + tcg_target_long arg, bool in_prologue, | ||
20 | + TCGReg scratch) | ||
21 | { | ||
22 | tcg_target_long hi, lo = (int32_t)arg; | ||
23 | tcg_target_long test, lsb; | ||
24 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, | ||
25 | } else { | ||
26 | hi = arg >> 32; | ||
27 | tcg_out_movi_imm32(s, ret, hi); | ||
28 | - tcg_out_movi_imm32(s, TCG_REG_T2, lo); | ||
29 | + tcg_out_movi_imm32(s, scratch, lo); | ||
30 | tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX); | ||
31 | - tcg_out_arith(s, ret, ret, TCG_REG_T2, ARITH_OR); | ||
32 | + tcg_out_arith(s, ret, ret, scratch, ARITH_OR); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | static void tcg_out_movi(TCGContext *s, TCGType type, | ||
37 | TCGReg ret, tcg_target_long arg) | ||
38 | { | ||
39 | - tcg_out_movi_int(s, type, ret, arg, false); | ||
40 | + tcg_debug_assert(ret != TCG_REG_T2); | ||
41 | + tcg_out_movi_int(s, type, ret, arg, false, TCG_REG_T2); | ||
42 | } | ||
43 | |||
44 | static void tcg_out_ldst_rr(TCGContext *s, TCGReg data, TCGReg a1, | ||
45 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_call_nodelay(TCGContext *s, const tcg_insn_unit *dest, | ||
46 | } else { | ||
47 | uintptr_t desti = (uintptr_t)dest; | ||
48 | tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_REG_T1, | ||
49 | - desti & ~0xfff, in_prologue); | ||
50 | + desti & ~0xfff, in_prologue, TCG_REG_O7); | ||
51 | tcg_out_arithi(s, TCG_REG_O7, TCG_REG_T1, desti & 0xfff, JMPL); | ||
52 | } | ||
53 | } | ||
54 | @@ -XXX,XX +XXX,XX @@ static void tcg_target_qemu_prologue(TCGContext *s) | ||
55 | |||
56 | #ifndef CONFIG_SOFTMMU | ||
57 | if (guest_base != 0) { | ||
58 | - tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base, true); | ||
59 | + tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, | ||
60 | + guest_base, true, TCG_REG_T1); | ||
61 | tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); | ||
62 | } | ||
63 | #endif | ||
64 | -- | ||
65 | 2.25.1 | ||
66 | |||
67 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We had code for checking for 13 and 21-bit shifted constants, | ||
2 | but we can do better and allow 32-bit shifted constants. | ||
3 | This is still 2 insns shorter than the full 64-bit sequence. | ||
4 | 1 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | tcg/sparc/tcg-target.c.inc | 12 ++++++------ | ||
10 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/sparc/tcg-target.c.inc | ||
15 | +++ b/tcg/sparc/tcg-target.c.inc | ||
16 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, | ||
17 | return; | ||
18 | } | ||
19 | |||
20 | - /* A 21-bit constant, shifted. */ | ||
21 | + /* A 32-bit constant, shifted. */ | ||
22 | lsb = ctz64(arg); | ||
23 | test = (tcg_target_long)arg >> lsb; | ||
24 | - if (check_fit_tl(test, 13)) { | ||
25 | - tcg_out_movi_imm13(s, ret, test); | ||
26 | - tcg_out_arithi(s, ret, ret, lsb, SHIFT_SLLX); | ||
27 | - return; | ||
28 | - } else if (lsb > 10 && test == extract64(test, 0, 21)) { | ||
29 | + if (lsb > 10 && test == extract64(test, 0, 21)) { | ||
30 | tcg_out_sethi(s, ret, test << 10); | ||
31 | tcg_out_arithi(s, ret, ret, lsb - 10, SHIFT_SLLX); | ||
32 | return; | ||
33 | + } else if (test == (uint32_t)test || test == (int32_t)test) { | ||
34 | + tcg_out_movi_int(s, TCG_TYPE_I64, ret, test, in_prologue, scratch); | ||
35 | + tcg_out_arithi(s, ret, ret, lsb, SHIFT_SLLX); | ||
36 | + return; | ||
37 | } | ||
38 | |||
39 | /* A 64-bit constant decomposed into 2 32-bit pieces. */ | ||
40 | -- | ||
41 | 2.25.1 | ||
42 | |||
43 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Since 7ecd02a06f8, if patch_reloc fails we restart translation | ||
2 | with a smaller TB. SPARC had its function signature changed, | ||
3 | but not the logic. Replace assert with return false. | ||
4 | 1 | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | tcg/sparc/tcg-target.c.inc | 8 ++++++-- | ||
10 | 1 file changed, 6 insertions(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/sparc/tcg-target.c.inc | ||
15 | +++ b/tcg/sparc/tcg-target.c.inc | ||
16 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *src_rw, int type, | ||
17 | |||
18 | switch (type) { | ||
19 | case R_SPARC_WDISP16: | ||
20 | - assert(check_fit_ptr(pcrel >> 2, 16)); | ||
21 | + if (!check_fit_ptr(pcrel >> 2, 16)) { | ||
22 | + return false; | ||
23 | + } | ||
24 | insn &= ~INSN_OFF16(-1); | ||
25 | insn |= INSN_OFF16(pcrel); | ||
26 | break; | ||
27 | case R_SPARC_WDISP19: | ||
28 | - assert(check_fit_ptr(pcrel >> 2, 19)); | ||
29 | + if (!check_fit_ptr(pcrel >> 2, 19)) { | ||
30 | + return false; | ||
31 | + } | ||
32 | insn &= ~INSN_OFF19(-1); | ||
33 | insn |= INSN_OFF19(pcrel); | ||
34 | break; | ||
35 | -- | ||
36 | 2.25.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
1 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 1 | Since a59a29312660 ("tcg/sparc64: Remove sparc32plus constraints") |
---|---|---|---|
2 | we no longer distinguish registers with 32 vs 64 bits. | ||
3 | Therefore we can remove support for the backend-specific | ||
4 | type change opcodes. | ||
5 | |||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
3 | --- | 7 | --- |
4 | tcg/sparc/tcg-target.c.inc | 15 +++++++++++++++ | 8 | tcg/sparc64/tcg-target.h | 2 +- |
5 | 1 file changed, 15 insertions(+) | 9 | tcg/sparc64/tcg-target.c.inc | 11 ----------- |
10 | 2 files changed, 1 insertion(+), 12 deletions(-) | ||
6 | 11 | ||
7 | diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc | 12 | diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h |
8 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
9 | --- a/tcg/sparc/tcg-target.c.inc | 14 | --- a/tcg/sparc64/tcg-target.h |
10 | +++ b/tcg/sparc/tcg-target.c.inc | 15 | +++ b/tcg/sparc64/tcg-target.h |
11 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *src_rw, int type, | 16 | @@ -XXX,XX +XXX,XX @@ extern bool use_vis3_instructions; |
12 | insn &= ~INSN_OFF19(-1); | 17 | #define TCG_TARGET_HAS_mulsh_i32 0 |
13 | insn |= INSN_OFF19(pcrel); | 18 | #define TCG_TARGET_HAS_qemu_st8_i32 0 |
14 | break; | 19 | |
15 | + case R_SPARC_13: | 20 | -#define TCG_TARGET_HAS_extr_i64_i32 1 |
16 | + if (!check_fit_ptr(value, 13)) { | 21 | +#define TCG_TARGET_HAS_extr_i64_i32 0 |
17 | + return false; | 22 | #define TCG_TARGET_HAS_div_i64 1 |
18 | + } | 23 | #define TCG_TARGET_HAS_rem_i64 0 |
19 | + insn &= ~INSN_IMM13(-1); | 24 | #define TCG_TARGET_HAS_rot_i64 0 |
20 | + insn |= INSN_IMM13(value); | 25 | diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc |
21 | + break; | 26 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/tcg/sparc64/tcg-target.c.inc | ||
28 | +++ b/tcg/sparc64/tcg-target.c.inc | ||
29 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_extu_i32_i64(TCGContext *s, TCGReg rd, TCGReg rs) | ||
30 | tcg_out_ext32u(s, rd, rs); | ||
31 | } | ||
32 | |||
33 | -static void tcg_out_extrl_i64_i32(TCGContext *s, TCGReg rd, TCGReg rs) | ||
34 | -{ | ||
35 | - tcg_out_mov(s, TCG_TYPE_I32, rd, rs); | ||
36 | -} | ||
37 | - | ||
38 | static bool tcg_out_xchg(TCGContext *s, TCGType type, TCGReg r1, TCGReg r2) | ||
39 | { | ||
40 | return false; | ||
41 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, | ||
42 | case INDEX_op_divu_i64: | ||
43 | c = ARITH_UDIVX; | ||
44 | goto gen_arith; | ||
45 | - case INDEX_op_extrh_i64_i32: | ||
46 | - tcg_out_arithi(s, a0, a1, 32, SHIFT_SRLX); | ||
47 | - break; | ||
48 | |||
49 | case INDEX_op_brcond_i64: | ||
50 | tcg_out_brcond_i64(s, a2, a0, a1, const_args[1], arg_label(args[3])); | ||
51 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, | ||
52 | case INDEX_op_ext32u_i64: | ||
53 | case INDEX_op_ext_i32_i64: | ||
54 | case INDEX_op_extu_i32_i64: | ||
55 | - case INDEX_op_extrl_i64_i32: | ||
22 | default: | 56 | default: |
23 | g_assert_not_reached(); | 57 | g_assert_not_reached(); |
24 | } | 58 | } |
25 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, | 59 | @@ -XXX,XX +XXX,XX @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) |
26 | return; | 60 | case INDEX_op_ext32u_i64: |
27 | } | 61 | case INDEX_op_ext_i32_i64: |
28 | 62 | case INDEX_op_extu_i32_i64: | |
29 | + /* Use the constant pool, if possible. */ | 63 | - case INDEX_op_extrl_i64_i32: |
30 | + if (!in_prologue && USE_REG_TB) { | 64 | - case INDEX_op_extrh_i64_i32: |
31 | + new_pool_label(s, arg, R_SPARC_13, s->code_ptr, | 65 | case INDEX_op_qemu_ld_a32_i32: |
32 | + tcg_tbrel_diff(s, NULL)); | 66 | case INDEX_op_qemu_ld_a64_i32: |
33 | + tcg_out32(s, LDX | INSN_RD(ret) | INSN_RS1(TCG_REG_TB)); | 67 | case INDEX_op_qemu_ld_a32_i64: |
34 | + return; | ||
35 | + } | ||
36 | + | ||
37 | /* A 64-bit constant decomposed into 2 32-bit pieces. */ | ||
38 | if (check_fit_i32(lo, 13)) { | ||
39 | hi = (arg - lo) >> 32; | ||
40 | -- | 68 | -- |
41 | 2.25.1 | 69 | 2.34.1 |
42 | |||
43 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | A mostly generic test for unaligned access raising SIGBUS. | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tests/tcg/multiarch/sigbus.c | 68 ++++++++++++++++++++++++++++++++++++ | ||
7 | 1 file changed, 68 insertions(+) | ||
8 | create mode 100644 tests/tcg/multiarch/sigbus.c | ||
9 | |||
10 | diff --git a/tests/tcg/multiarch/sigbus.c b/tests/tcg/multiarch/sigbus.c | ||
11 | new file mode 100644 | ||
12 | index XXXXXXX..XXXXXXX | ||
13 | --- /dev/null | ||
14 | +++ b/tests/tcg/multiarch/sigbus.c | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | +#define _GNU_SOURCE 1 | ||
17 | + | ||
18 | +#include <assert.h> | ||
19 | +#include <stdlib.h> | ||
20 | +#include <signal.h> | ||
21 | +#include <endian.h> | ||
22 | + | ||
23 | + | ||
24 | +unsigned long long x = 0x8877665544332211ull; | ||
25 | +void * volatile p = (void *)&x + 1; | ||
26 | + | ||
27 | +void sigbus(int sig, siginfo_t *info, void *uc) | ||
28 | +{ | ||
29 | + assert(sig == SIGBUS); | ||
30 | + assert(info->si_signo == SIGBUS); | ||
31 | +#ifdef BUS_ADRALN | ||
32 | + assert(info->si_code == BUS_ADRALN); | ||
33 | +#endif | ||
34 | + assert(info->si_addr == p); | ||
35 | + exit(EXIT_SUCCESS); | ||
36 | +} | ||
37 | + | ||
38 | +int main() | ||
39 | +{ | ||
40 | + struct sigaction sa = { | ||
41 | + .sa_sigaction = sigbus, | ||
42 | + .sa_flags = SA_SIGINFO | ||
43 | + }; | ||
44 | + int allow_fail = 0; | ||
45 | + int tmp; | ||
46 | + | ||
47 | + tmp = sigaction(SIGBUS, &sa, NULL); | ||
48 | + assert(tmp == 0); | ||
49 | + | ||
50 | + /* | ||
51 | + * Select an operation that's likely to enforce alignment. | ||
52 | + * On many guests that support unaligned accesses by default, | ||
53 | + * this is often an atomic operation. | ||
54 | + */ | ||
55 | +#if defined(__aarch64__) | ||
56 | + asm volatile("ldxr %w0,[%1]" : "=r"(tmp) : "r"(p) : "memory"); | ||
57 | +#elif defined(__alpha__) | ||
58 | + asm volatile("ldl_l %0,0(%1)" : "=r"(tmp) : "r"(p) : "memory"); | ||
59 | +#elif defined(__arm__) | ||
60 | + asm volatile("ldrex %0,[%1]" : "=r"(tmp) : "r"(p) : "memory"); | ||
61 | +#elif defined(__powerpc__) | ||
62 | + asm volatile("lwarx %0,0,%1" : "=r"(tmp) : "r"(p) : "memory"); | ||
63 | +#elif defined(__riscv_atomic) | ||
64 | + asm volatile("lr.w %0,(%1)" : "=r"(tmp) : "r"(p) : "memory"); | ||
65 | +#else | ||
66 | + /* No insn known to fault unaligned -- try for a straight load. */ | ||
67 | + allow_fail = 1; | ||
68 | + tmp = *(volatile int *)p; | ||
69 | +#endif | ||
70 | + | ||
71 | + assert(allow_fail); | ||
72 | + | ||
73 | + /* | ||
74 | + * We didn't see a signal. | ||
75 | + * We might as well validate the unaligned load worked. | ||
76 | + */ | ||
77 | + if (BYTE_ORDER == LITTLE_ENDIAN) { | ||
78 | + assert(tmp == 0x55443322); | ||
79 | + } else { | ||
80 | + assert(tmp == 0x77665544); | ||
81 | + } | ||
82 | + return EXIT_SUCCESS; | ||
83 | +} | ||
84 | -- | ||
85 | 2.25.1 | ||
86 | |||
87 | diff view generated by jsdifflib |