1 | Small pile of bug fixes for rc1. I've included my patches to get | 1 | Just flushing my target-arm queue since I won't be working next week :-) |
---|---|---|---|
2 | our docs building with Sphinx 3, just for convenience... | ||
3 | 2 | ||
4 | -- PMM | 3 | -- PMM |
5 | 4 | ||
6 | The following changes since commit b149dea55cce97cb226683d06af61984a1c11e96: | 5 | The following changes since commit b3cd3b5a66f0dddfe3d5ba2bef13cd4f5b89cde9: |
7 | 6 | ||
8 | Merge remote-tracking branch 'remotes/cschoenebeck/tags/pull-9p-20201102' into staging (2020-11-02 10:57:48 +0000) | 7 | Merge tag 'pull-riscv-to-apply-20220610' of github.com:alistair23/qemu into staging (2022-06-09 22:08:27 -0700) |
9 | 8 | ||
10 | are available in the Git repository at: | 9 | are available in the Git repository at: |
11 | 10 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201102 | 11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220610 |
13 | 12 | ||
14 | for you to fetch changes up to ffb4fbf90a2f63c9cb33e4bb9f854c79bf04ca4a: | 13 | for you to fetch changes up to 90c072e063737e9e8f431489bbd334452f89056e: |
15 | 14 | ||
16 | tests/qtest/npcm7xx_rng-test: Disable randomness tests (2020-11-02 16:52:18 +0000) | 15 | semihosting/config: Merge --semihosting-config option groups (2022-06-10 14:32:36 +0100) |
17 | 16 | ||
18 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
19 | target-arm queue: | 18 | * refactor exception routing code |
20 | * target/arm: Fix Neon emulation bugs on big-endian hosts | 19 | * fix SCR_EL3 RAO/RAZ bits |
21 | * target/arm: fix handling of HCR.FB | 20 | * gdbstub: Don't use GDB syscalls if no GDB is attached |
22 | * target/arm: fix LORID_EL1 access check | 21 | * semihosting/config: Merge --semihosting-config option groups |
23 | * disas/capstone: Fix monitor disassembly of >32 bytes | 22 | * tests/qtest: Reduce npcm7xx_sdhci test image size |
24 | * hw/arm/smmuv3: Fix potential integer overflow (CID 1432363) | ||
25 | * hw/arm/boot: fix SVE for EL3 direct kernel boot | ||
26 | * hw/display/omap_lcdc: Fix potential NULL pointer dereference | ||
27 | * hw/display/exynos4210_fimd: Fix potential NULL pointer dereference | ||
28 | * target/arm: Get correct MMU index for other-security-state | ||
29 | * configure: Test that gio libs from pkg-config work | ||
30 | * hw/intc/arm_gicv3_cpuif: Make GIC maintenance interrupts work | ||
31 | * docs: Fix building with Sphinx 3 | ||
32 | * tests/qtest/npcm7xx_rng-test: Disable randomness tests | ||
33 | 23 | ||
34 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
35 | AlexChen (2): | 25 | Hao Wu (1): |
36 | hw/display/omap_lcdc: Fix potential NULL pointer dereference | 26 | tests/qtest: Reduce npcm7xx_sdhci test image size |
37 | hw/display/exynos4210_fimd: Fix potential NULL pointer dereference | ||
38 | 27 | ||
39 | Peter Maydell (9): | 28 | Peter Maydell (2): |
40 | target/arm: Fix float16 pairwise Neon ops on big-endian hosts | 29 | gdbstub: Don't use GDB syscalls if no GDB is attached |
41 | target/arm: Fix VUDOT/VSDOT (scalar) on big-endian hosts | 30 | semihosting/config: Merge --semihosting-config option groups |
42 | disas/capstone: Fix monitor disassembly of >32 bytes | ||
43 | target/arm: Get correct MMU index for other-security-state | ||
44 | configure: Test that gio libs from pkg-config work | ||
45 | hw/intc/arm_gicv3_cpuif: Make GIC maintenance interrupts work | ||
46 | scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments | ||
47 | qemu-option-trace.rst.inc: Don't use option:: markup | ||
48 | tests/qtest/npcm7xx_rng-test: Disable randomness tests | ||
49 | 31 | ||
50 | Philippe Mathieu-Daudé (1): | 32 | Richard Henderson (25): |
51 | hw/arm/smmuv3: Fix potential integer overflow (CID 1432363) | 33 | target/arm: Mark exception helpers as noreturn |
34 | target/arm: Add coproc parameter to syn_fp_access_trap | ||
35 | target/arm: Move exception_target_el out of line | ||
36 | target/arm: Move arm_singlestep_active out of line | ||
37 | target/arm: Move arm_generate_debug_exceptions out of line | ||
38 | target/arm: Use is_a64 in arm_generate_debug_exceptions | ||
39 | target/arm: Move exception_bkpt_insn to debug_helper.c | ||
40 | target/arm: Move arm_debug_exception_fsr to debug_helper.c | ||
41 | target/arm: Rename helper_exception_with_syndrome | ||
42 | target/arm: Introduce gen_exception_insn_el_v | ||
43 | target/arm: Rename gen_exception_insn to gen_exception_insn_el | ||
44 | target/arm: Introduce gen_exception_insn | ||
45 | target/arm: Create helper_exception_swstep | ||
46 | target/arm: Remove TBFLAG_ANY.DEBUG_TARGET_EL | ||
47 | target/arm: Move gen_exception to translate.c | ||
48 | target/arm: Rename gen_exception to gen_exception_el | ||
49 | target/arm: Introduce gen_exception | ||
50 | target/arm: Introduce gen_exception_el_v | ||
51 | target/arm: Introduce helper_exception_with_syndrome | ||
52 | target/arm: Remove default_exception_el | ||
53 | target/arm: Create raise_exception_debug | ||
54 | target/arm: Move arm_debug_target_el to debug_helper.c | ||
55 | target/arm: Fix Secure PL1 tests in fp_exception_el | ||
56 | target/arm: Adjust format test in scr_write | ||
57 | target/arm: SCR_EL3.RW is RAO/WI without AArch32 EL[12] | ||
52 | 58 | ||
53 | Richard Henderson (11): | 59 | target/arm/cpu.h | 133 ++--------------------- |
54 | target/arm: Introduce neon_full_reg_offset | 60 | target/arm/helper.h | 8 +- |
55 | target/arm: Move neon_element_offset to translate.c | 61 | target/arm/internals.h | 43 +------- |
56 | target/arm: Use neon_element_offset in neon_load/store_reg | 62 | target/arm/syndrome.h | 7 +- |
57 | target/arm: Use neon_element_offset in vfp_reg_offset | 63 | target/arm/translate.h | 43 ++------ |
58 | target/arm: Add read/write_neon_element32 | 64 | gdbstub.c | 14 ++- |
59 | target/arm: Expand read/write_neon_element32 to all MemOp | 65 | semihosting/config.c | 1 + |
60 | target/arm: Rename neon_load_reg32 to vfp_load_reg32 | 66 | target/arm/debug_helper.c | 220 +++++++++++++++++++++++++++++++++++++-- |
61 | target/arm: Add read/write_neon_element64 | 67 | target/arm/helper.c | 53 ++++------ |
62 | target/arm: Rename neon_load_reg64 to vfp_load_reg64 | 68 | target/arm/op_helper.c | 52 +++++---- |
63 | target/arm: Simplify do_long_3d and do_2scalar_long | 69 | target/arm/translate-a64.c | 34 +++--- |
64 | target/arm: Improve do_prewiden_3d | 70 | target/arm/translate-m-nocp.c | 15 ++- |
65 | 71 | target/arm/translate-mve.c | 3 +- | |
66 | Rémi Denis-Courmont (3): | 72 | target/arm/translate-vfp.c | 18 +++- |
67 | target/arm: fix handling of HCR.FB | 73 | target/arm/translate.c | 106 ++++++++++--------- |
68 | target/arm: fix LORID_EL1 access check | 74 | tests/qtest/npcm7xx_sdhci-test.c | 2 +- |
69 | hw/arm/boot: fix SVE for EL3 direct kernel boot | 75 | 16 files changed, 390 insertions(+), 362 deletions(-) |
70 | |||
71 | docs/qemu-option-trace.rst.inc | 6 +- | ||
72 | configure | 10 +- | ||
73 | include/hw/intc/arm_gicv3_common.h | 1 - | ||
74 | disas/capstone.c | 2 +- | ||
75 | hw/arm/boot.c | 3 + | ||
76 | hw/arm/smmuv3.c | 3 +- | ||
77 | hw/display/exynos4210_fimd.c | 4 +- | ||
78 | hw/display/omap_lcdc.c | 10 +- | ||
79 | hw/intc/arm_gicv3_cpuif.c | 5 +- | ||
80 | target/arm/helper.c | 24 +- | ||
81 | target/arm/m_helper.c | 3 +- | ||
82 | target/arm/translate.c | 153 +++++++++--- | ||
83 | target/arm/vec_helper.c | 12 +- | ||
84 | tests/qtest/npcm7xx_rng-test.c | 14 +- | ||
85 | scripts/kernel-doc | 18 +- | ||
86 | target/arm/translate-neon.c.inc | 472 ++++++++++++++++++++----------------- | ||
87 | target/arm/translate-vfp.c.inc | 341 +++++++++++---------------- | ||
88 | 17 files changed, 588 insertions(+), 493 deletions(-) | ||
89 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20220609202901.1177572-2-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/helper.h | 6 +++--- | ||
9 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/helper.h | ||
14 | +++ b/target/arm/helper.h | ||
15 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(usad8, TCG_CALL_NO_RWG_SE, i32, i32, i32) | ||
16 | |||
17 | DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE, | ||
18 | i32, i32, i32, i32) | ||
19 | -DEF_HELPER_2(exception_internal, void, env, i32) | ||
20 | -DEF_HELPER_4(exception_with_syndrome, void, env, i32, i32, i32) | ||
21 | -DEF_HELPER_2(exception_bkpt_insn, void, env, i32) | ||
22 | +DEF_HELPER_2(exception_internal, noreturn, env, i32) | ||
23 | +DEF_HELPER_4(exception_with_syndrome, noreturn, env, i32, i32, i32) | ||
24 | +DEF_HELPER_2(exception_bkpt_insn, noreturn, env, i32) | ||
25 | DEF_HELPER_2(exception_pc_alignment, noreturn, env, tl) | ||
26 | DEF_HELPER_1(setend, void, env) | ||
27 | DEF_HELPER_2(wfi, void, env, i32) | ||
28 | -- | ||
29 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We can then use this to improve VMOV (scalar to gp) and | 3 | With ARMv8, this field is always RES0. |
4 | VMOV (gp to scalar) so that we simply perform the memory | 4 | With ARMv7, targeting EL2 and TA=0, it is always 0xA. |
5 | operation that we wanted, rather than inserting or | ||
6 | extracting from a 32-bit quantity. | ||
7 | 5 | ||
8 | These were the last uses of neon_load/store_reg, so remove them. | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | |||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20201030022618.785675-7-richard.henderson@linaro.org | 8 | Message-id: 20220609202901.1177572-3-richard.henderson@linaro.org |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 10 | --- |
15 | target/arm/translate.c | 50 +++++++++++++----------- | 11 | target/arm/syndrome.h | 7 ++++--- |
16 | target/arm/translate-vfp.c.inc | 71 +++++----------------------------- | 12 | target/arm/translate-a64.c | 3 ++- |
17 | 2 files changed, 37 insertions(+), 84 deletions(-) | 13 | target/arm/translate-vfp.c | 14 ++++++++++++-- |
14 | 3 files changed, 18 insertions(+), 6 deletions(-) | ||
18 | 15 | ||
19 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/translate.c | 18 | --- a/target/arm/syndrome.h |
22 | +++ b/target/arm/translate.c | 19 | +++ b/target/arm/syndrome.h |
23 | @@ -XXX,XX +XXX,XX @@ static long neon_full_reg_offset(unsigned reg) | 20 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_cp15_rrt_trap(int cv, int cond, int opc1, int crm, |
24 | * Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | 21 | | (rt2 << 10) | (rt << 5) | (crm << 1) | isread; |
25 | * where 0 is the least significant end of the register. | 22 | } |
26 | */ | 23 | |
27 | -static long neon_element_offset(int reg, int element, MemOp size) | 24 | -static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit) |
28 | +static long neon_element_offset(int reg, int element, MemOp memop) | 25 | +static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit, |
26 | + int coproc) | ||
29 | { | 27 | { |
30 | - int element_size = 1 << size; | 28 | - /* AArch32 FP trap or any AArch64 FP/SIMD trap: TA == 0 coproc == 0xa */ |
31 | + int element_size = 1 << (memop & MO_SIZE); | 29 | + /* AArch32 FP trap or any AArch64 FP/SIMD trap: TA == 0 */ |
32 | int ofs = element * element_size; | 30 | return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT) |
33 | #ifdef HOST_WORDS_BIGENDIAN | 31 | | (is_16bit ? 0 : ARM_EL_IL) |
34 | /* | 32 | - | (cv << 24) | (cond << 20) | 0xa; |
35 | @@ -XXX,XX +XXX,XX @@ static long vfp_reg_offset(bool dp, unsigned reg) | 33 | + | (cv << 24) | (cond << 20) | coproc; |
36 | } | ||
37 | } | 34 | } |
38 | 35 | ||
39 | -static TCGv_i32 neon_load_reg(int reg, int pass) | 36 | static inline uint32_t syn_simd_access_trap(int cv, int cond, bool is_16bit) |
40 | -{ | 37 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
41 | - TCGv_i32 tmp = tcg_temp_new_i32(); | ||
42 | - tcg_gen_ld_i32(tmp, cpu_env, neon_element_offset(reg, pass, MO_32)); | ||
43 | - return tmp; | ||
44 | -} | ||
45 | - | ||
46 | -static void neon_store_reg(int reg, int pass, TCGv_i32 var) | ||
47 | -{ | ||
48 | - tcg_gen_st_i32(var, cpu_env, neon_element_offset(reg, pass, MO_32)); | ||
49 | - tcg_temp_free_i32(var); | ||
50 | -} | ||
51 | - | ||
52 | static inline void neon_load_reg64(TCGv_i64 var, int reg) | ||
53 | { | ||
54 | tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg)); | ||
55 | @@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg32(TCGv_i32 var, int reg) | ||
56 | tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); | ||
57 | } | ||
58 | |||
59 | -static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size) | ||
60 | +static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop) | ||
61 | { | ||
62 | - long off = neon_element_offset(reg, ele, size); | ||
63 | + long off = neon_element_offset(reg, ele, memop); | ||
64 | |||
65 | - switch (size) { | ||
66 | - case MO_32: | ||
67 | + switch (memop) { | ||
68 | + case MO_SB: | ||
69 | + tcg_gen_ld8s_i32(dest, cpu_env, off); | ||
70 | + break; | ||
71 | + case MO_UB: | ||
72 | + tcg_gen_ld8u_i32(dest, cpu_env, off); | ||
73 | + break; | ||
74 | + case MO_SW: | ||
75 | + tcg_gen_ld16s_i32(dest, cpu_env, off); | ||
76 | + break; | ||
77 | + case MO_UW: | ||
78 | + tcg_gen_ld16u_i32(dest, cpu_env, off); | ||
79 | + break; | ||
80 | + case MO_UL: | ||
81 | + case MO_SL: | ||
82 | tcg_gen_ld_i32(dest, cpu_env, off); | ||
83 | break; | ||
84 | default: | ||
85 | @@ -XXX,XX +XXX,XX @@ static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size) | ||
86 | } | ||
87 | } | ||
88 | |||
89 | -static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp size) | ||
90 | +static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) | ||
91 | { | ||
92 | - long off = neon_element_offset(reg, ele, size); | ||
93 | + long off = neon_element_offset(reg, ele, memop); | ||
94 | |||
95 | - switch (size) { | ||
96 | + switch (memop) { | ||
97 | + case MO_8: | ||
98 | + tcg_gen_st8_i32(src, cpu_env, off); | ||
99 | + break; | ||
100 | + case MO_16: | ||
101 | + tcg_gen_st16_i32(src, cpu_env, off); | ||
102 | + break; | ||
103 | case MO_32: | ||
104 | tcg_gen_st_i32(src, cpu_env, off); | ||
105 | break; | ||
106 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
107 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
108 | --- a/target/arm/translate-vfp.c.inc | 39 | --- a/target/arm/translate-a64.c |
109 | +++ b/target/arm/translate-vfp.c.inc | 40 | +++ b/target/arm/translate-a64.c |
110 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | 41 | @@ -XXX,XX +XXX,XX @@ static bool fp_access_check(DisasContext *s) |
111 | { | 42 | s->fp_access_checked = true; |
112 | /* VMOV scalar to general purpose register */ | 43 | |
113 | TCGv_i32 tmp; | 44 | gen_exception_insn(s, s->pc_curr, EXCP_UDEF, |
114 | - int pass; | 45 | - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); |
115 | - uint32_t offset; | 46 | + syn_fp_access_trap(1, 0xe, false, 0), |
116 | 47 | + s->fp_excp_el); | |
117 | - /* SIZE == 2 is a VFP instruction; otherwise NEON. */ | ||
118 | - if (a->size == 2 | ||
119 | + /* SIZE == MO_32 is a VFP instruction; otherwise NEON. */ | ||
120 | + if (a->size == MO_32 | ||
121 | ? !dc_isar_feature(aa32_fpsp_v2, s) | ||
122 | : !arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
123 | return false; | ||
124 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | ||
125 | return false; | 48 | return false; |
126 | } | 49 | } |
127 | 50 | s->fp_access_checked = true; | |
128 | - offset = a->index << a->size; | 51 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c |
129 | - pass = extract32(offset, 2, 1); | 52 | index XXXXXXX..XXXXXXX 100644 |
130 | - offset = extract32(offset, 0, 2) * 8; | 53 | --- a/target/arm/translate-vfp.c |
131 | - | 54 | +++ b/target/arm/translate-vfp.c |
132 | if (!vfp_access_check(s)) { | 55 | @@ -XXX,XX +XXX,XX @@ static void gen_update_fp_context(DisasContext *s) |
133 | return true; | 56 | static bool vfp_access_check_a(DisasContext *s, bool ignore_vfp_enabled) |
134 | } | ||
135 | |||
136 | - tmp = neon_load_reg(a->vn, pass); | ||
137 | - switch (a->size) { | ||
138 | - case 0: | ||
139 | - if (offset) { | ||
140 | - tcg_gen_shri_i32(tmp, tmp, offset); | ||
141 | - } | ||
142 | - if (a->u) { | ||
143 | - gen_uxtb(tmp); | ||
144 | - } else { | ||
145 | - gen_sxtb(tmp); | ||
146 | - } | ||
147 | - break; | ||
148 | - case 1: | ||
149 | - if (a->u) { | ||
150 | - if (offset) { | ||
151 | - tcg_gen_shri_i32(tmp, tmp, 16); | ||
152 | - } else { | ||
153 | - gen_uxth(tmp); | ||
154 | - } | ||
155 | - } else { | ||
156 | - if (offset) { | ||
157 | - tcg_gen_sari_i32(tmp, tmp, 16); | ||
158 | - } else { | ||
159 | - gen_sxth(tmp); | ||
160 | - } | ||
161 | - } | ||
162 | - break; | ||
163 | - case 2: | ||
164 | - break; | ||
165 | - } | ||
166 | + tmp = tcg_temp_new_i32(); | ||
167 | + read_neon_element32(tmp, a->vn, a->index, a->size | (a->u ? 0 : MO_SIGN)); | ||
168 | store_reg(s, a->rt, tmp); | ||
169 | |||
170 | return true; | ||
171 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | ||
172 | static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a) | ||
173 | { | 57 | { |
174 | /* VMOV general purpose register to scalar */ | 58 | if (s->fp_excp_el) { |
175 | - TCGv_i32 tmp, tmp2; | 59 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, |
176 | - int pass; | 60 | - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); |
177 | - uint32_t offset; | 61 | + /* |
178 | + TCGv_i32 tmp; | 62 | + * The full syndrome is only used for HSR when HCPTR traps: |
179 | 63 | + * For v8, when TA==0, coproc is RES0. | |
180 | - /* SIZE == 2 is a VFP instruction; otherwise NEON. */ | 64 | + * For v7, any use of a Floating-point instruction or access |
181 | - if (a->size == 2 | 65 | + * to a Floating-point Extension register that is trapped to |
182 | + /* SIZE == MO_32 is a VFP instruction; otherwise NEON. */ | 66 | + * Hyp mode because of a trap configured in the HCPTR sets |
183 | + if (a->size == MO_32 | 67 | + * this field to 0xA. |
184 | ? !dc_isar_feature(aa32_fpsp_v2, s) | 68 | + */ |
185 | : !arm_dc_feature(s, ARM_FEATURE_NEON)) { | 69 | + int coproc = arm_dc_feature(s, ARM_FEATURE_V8) ? 0 : 0xa; |
186 | return false; | 70 | + uint32_t syn = syn_fp_access_trap(1, 0xe, false, coproc); |
187 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a) | 71 | + |
72 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn, s->fp_excp_el); | ||
188 | return false; | 73 | return false; |
189 | } | 74 | } |
190 | 75 | ||
191 | - offset = a->index << a->size; | ||
192 | - pass = extract32(offset, 2, 1); | ||
193 | - offset = extract32(offset, 0, 2) * 8; | ||
194 | - | ||
195 | if (!vfp_access_check(s)) { | ||
196 | return true; | ||
197 | } | ||
198 | |||
199 | tmp = load_reg(s, a->rt); | ||
200 | - switch (a->size) { | ||
201 | - case 0: | ||
202 | - tmp2 = neon_load_reg(a->vn, pass); | ||
203 | - tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 8); | ||
204 | - tcg_temp_free_i32(tmp2); | ||
205 | - break; | ||
206 | - case 1: | ||
207 | - tmp2 = neon_load_reg(a->vn, pass); | ||
208 | - tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 16); | ||
209 | - tcg_temp_free_i32(tmp2); | ||
210 | - break; | ||
211 | - case 2: | ||
212 | - break; | ||
213 | - } | ||
214 | - neon_store_reg(a->vn, pass, tmp); | ||
215 | + write_neon_element32(tmp, a->vn, a->index, a->size); | ||
216 | + tcg_temp_free_i32(tmp); | ||
217 | |||
218 | return true; | ||
219 | } | ||
220 | -- | 76 | -- |
221 | 2.20.1 | 77 | 2.25.1 |
222 | |||
223 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Move the function to op_helper.c, near raise_exception. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220609202901.1177572-4-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/internals.h | 16 +--------------- | ||
11 | target/arm/op_helper.c | 15 +++++++++++++++ | ||
12 | 2 files changed, 16 insertions(+), 15 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/internals.h | ||
17 | +++ b/target/arm/internals.h | ||
18 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
19 | int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx); | ||
20 | int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx); | ||
21 | |||
22 | -static inline int exception_target_el(CPUARMState *env) | ||
23 | -{ | ||
24 | - int target_el = MAX(1, arm_current_el(env)); | ||
25 | - | ||
26 | - /* | ||
27 | - * No such thing as secure EL1 if EL3 is aarch32, | ||
28 | - * so update the target EL to EL3 in this case. | ||
29 | - */ | ||
30 | - if (arm_is_secure(env) && !arm_el_is_aa64(env, 3) && target_el == 1) { | ||
31 | - target_el = 3; | ||
32 | - } | ||
33 | - | ||
34 | - return target_el; | ||
35 | -} | ||
36 | - | ||
37 | /* Determine if allocation tags are available. */ | ||
38 | static inline bool allocation_tag_access_enabled(CPUARMState *env, int el, | ||
39 | uint64_t sctlr) | ||
40 | @@ -XXX,XX +XXX,XX @@ void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); | ||
41 | bool el_is_in_host(CPUARMState *env, int el); | ||
42 | |||
43 | void aa32_max_features(ARMCPU *cpu); | ||
44 | +int exception_target_el(CPUARMState *env); | ||
45 | |||
46 | /* Powers of 2 for sve_vq_map et al. */ | ||
47 | #define SVE_VQ_POW2_MAP \ | ||
48 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/op_helper.c | ||
51 | +++ b/target/arm/op_helper.c | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | #define SIGNBIT (uint32_t)0x80000000 | ||
54 | #define SIGNBIT64 ((uint64_t)1 << 63) | ||
55 | |||
56 | +int exception_target_el(CPUARMState *env) | ||
57 | +{ | ||
58 | + int target_el = MAX(1, arm_current_el(env)); | ||
59 | + | ||
60 | + /* | ||
61 | + * No such thing as secure EL1 if EL3 is aarch32, | ||
62 | + * so update the target EL to EL3 in this case. | ||
63 | + */ | ||
64 | + if (arm_is_secure(env) && !arm_el_is_aa64(env, 3) && target_el == 1) { | ||
65 | + target_el = 3; | ||
66 | + } | ||
67 | + | ||
68 | + return target_el; | ||
69 | +} | ||
70 | + | ||
71 | void raise_exception(CPUARMState *env, uint32_t excp, | ||
72 | uint32_t syndrome, uint32_t target_el) | ||
73 | { | ||
74 | -- | ||
75 | 2.25.1 | diff view generated by jsdifflib |
1 | The randomness tests in the NPCM7xx RNG test fail intermittently | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | but fairly frequently. On my machine running the test in a loop: | ||
3 | while QTEST_QEMU_BINARY=./qemu-system-aarch64 ./tests/qtest/npcm7xx_rng-test; do true; done | ||
4 | 2 | ||
5 | will fail in less than a minute with an error like: | 3 | Move the function to debug_helper.c, and the |
6 | ERROR:../../tests/qtest/npcm7xx_rng-test.c:256:test_first_byte_runs: | 4 | declaration to internals.h. |
7 | assertion failed (calc_runs_p(buf.l, sizeof(buf) * BITS_PER_BYTE) > 0.01): (0.00286205989 > 0.01) | ||
8 | 5 | ||
9 | (Failures have been observed on all 4 of the randomness tests, | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | not just first_byte_runs.) | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220609202901.1177572-5-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 10 ---------- | ||
12 | target/arm/internals.h | 1 + | ||
13 | target/arm/debug_helper.c | 12 ++++++++++++ | ||
14 | 3 files changed, 13 insertions(+), 10 deletions(-) | ||
11 | 15 | ||
12 | It's not clear why these tests are failing like this, but intermittent | 16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
13 | failures make CI and merge testing awkward, so disable running them | ||
14 | unless a developer specifically sets QEMU_TEST_FLAKY_RNG_TESTS when | ||
15 | running the test suite, until we work out the cause. | ||
16 | |||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
19 | Message-id: 20201102152454.8287-1-peter.maydell@linaro.org | ||
20 | Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com> | ||
21 | --- | ||
22 | tests/qtest/npcm7xx_rng-test.c | 14 ++++++++++---- | ||
23 | 1 file changed, 10 insertions(+), 4 deletions(-) | ||
24 | |||
25 | diff --git a/tests/qtest/npcm7xx_rng-test.c b/tests/qtest/npcm7xx_rng-test.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/tests/qtest/npcm7xx_rng-test.c | 18 | --- a/target/arm/cpu.h |
28 | +++ b/tests/qtest/npcm7xx_rng-test.c | 19 | +++ b/target/arm/cpu.h |
29 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | 20 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_generate_debug_exceptions(CPUARMState *env) |
30 | 21 | } | |
31 | qtest_add_func("npcm7xx_rng/enable_disable", test_enable_disable); | 22 | } |
32 | qtest_add_func("npcm7xx_rng/rosel", test_rosel); | 23 | |
33 | - qtest_add_func("npcm7xx_rng/continuous/monobit", test_continuous_monobit); | 24 | -/* Is single-stepping active? (Note that the "is EL_D AArch64?" check |
34 | - qtest_add_func("npcm7xx_rng/continuous/runs", test_continuous_runs); | 25 | - * implicitly means this always returns false in pre-v8 CPUs.) |
35 | - qtest_add_func("npcm7xx_rng/first_byte/monobit", test_first_byte_monobit); | 26 | - */ |
36 | - qtest_add_func("npcm7xx_rng/first_byte/runs", test_first_byte_runs); | 27 | -static inline bool arm_singlestep_active(CPUARMState *env) |
37 | + /* | 28 | -{ |
38 | + * These tests fail intermittently; only run them on explicit | 29 | - return extract32(env->cp15.mdscr_el1, 0, 1) |
39 | + * request until we figure out why. | 30 | - && arm_el_is_aa64(env, arm_debug_target_el(env)) |
40 | + */ | 31 | - && arm_generate_debug_exceptions(env); |
41 | + if (getenv("QEMU_TEST_FLAKY_RNG_TESTS")) { | 32 | -} |
42 | + qtest_add_func("npcm7xx_rng/continuous/monobit", test_continuous_monobit); | 33 | - |
43 | + qtest_add_func("npcm7xx_rng/continuous/runs", test_continuous_runs); | 34 | static inline bool arm_sctlr_b(CPUARMState *env) |
44 | + qtest_add_func("npcm7xx_rng/first_byte/monobit", test_first_byte_monobit); | 35 | { |
45 | + qtest_add_func("npcm7xx_rng/first_byte/runs", test_first_byte_runs); | 36 | return |
46 | + } | 37 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
47 | 38 | index XXXXXXX..XXXXXXX 100644 | |
48 | qtest_start("-machine npcm750-evb"); | 39 | --- a/target/arm/internals.h |
49 | ret = g_test_run(); | 40 | +++ b/target/arm/internals.h |
41 | @@ -XXX,XX +XXX,XX @@ bool el_is_in_host(CPUARMState *env, int el); | ||
42 | |||
43 | void aa32_max_features(ARMCPU *cpu); | ||
44 | int exception_target_el(CPUARMState *env); | ||
45 | +bool arm_singlestep_active(CPUARMState *env); | ||
46 | |||
47 | /* Powers of 2 for sve_vq_map et al. */ | ||
48 | #define SVE_VQ_POW2_MAP \ | ||
49 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/debug_helper.c | ||
52 | +++ b/target/arm/debug_helper.c | ||
53 | @@ -XXX,XX +XXX,XX @@ | ||
54 | #include "exec/exec-all.h" | ||
55 | #include "exec/helper-proto.h" | ||
56 | |||
57 | + | ||
58 | +/* | ||
59 | + * Is single-stepping active? (Note that the "is EL_D AArch64?" check | ||
60 | + * implicitly means this always returns false in pre-v8 CPUs.) | ||
61 | + */ | ||
62 | +bool arm_singlestep_active(CPUARMState *env) | ||
63 | +{ | ||
64 | + return extract32(env->cp15.mdscr_el1, 0, 1) | ||
65 | + && arm_el_is_aa64(env, arm_debug_target_el(env)) | ||
66 | + && arm_generate_debug_exceptions(env); | ||
67 | +} | ||
68 | + | ||
69 | /* Return true if the linked breakpoint entry lbn passes its checks */ | ||
70 | static bool linked_bp_matches(ARMCPU *cpu, int lbn) | ||
71 | { | ||
50 | -- | 72 | -- |
51 | 2.20.1 | 73 | 2.25.1 |
52 | |||
53 | diff view generated by jsdifflib |
1 | The kerneldoc script currently emits Sphinx markup for a macro with | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | arguments that uses the c:function directive. This is correct for | ||
3 | Sphinx versions earlier than Sphinx 3, where c:macro doesn't allow | ||
4 | documentation of macros with arguments and c:function is not picky | ||
5 | about the syntax of what it is passed. However, in Sphinx 3 the | ||
6 | c:macro directive was enhanced to support macros with arguments, | ||
7 | and c:function was made more picky about what syntax it accepted. | ||
8 | 2 | ||
9 | When kerneldoc is told that it needs to produce output for Sphinx | 3 | Move arm_generate_debug_exceptions and its two subroutines, |
10 | 3 or later, make it emit c:function only for functions and c:macro | 4 | {aa32,aa64}_generate_debug_exceptions into debug_helper.c, |
11 | for macros with arguments. We assume that anything with a return | 5 | and the one interface declaration to internals.h. |
12 | type is a function and anything without is a macro. | ||
13 | 6 | ||
14 | This fixes the Sphinx error: | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220609202901.1177572-6-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 91 ------------------------------------- | ||
13 | target/arm/internals.h | 1 + | ||
14 | target/arm/debug_helper.c | 94 +++++++++++++++++++++++++++++++++++++++ | ||
15 | 3 files changed, 95 insertions(+), 91 deletions(-) | ||
15 | 16 | ||
16 | /home/petmay01/linaro/qemu-from-laptop/qemu/docs/../include/qom/object.h:155:Error in declarator | 17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
17 | If declarator-id with parameters (e.g., 'void f(int arg)'): | 18 | index XXXXXXX..XXXXXXX 100644 |
18 | Invalid C declaration: Expected identifier in nested name. [error at 25] | 19 | --- a/target/arm/cpu.h |
19 | DECLARE_INSTANCE_CHECKER ( InstanceType, OBJ_NAME, TYPENAME) | 20 | +++ b/target/arm/cpu.h |
20 | -------------------------^ | 21 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu) |
21 | If parenthesis in noptr-declarator (e.g., 'void (*f(int arg))(double)'): | 22 | return (cpu->clidr & R_V7M_CLIDR_CTYPE_ALL_MASK) != 0; |
22 | Error in declarator or parameters | 23 | } |
23 | Invalid C declaration: Expecting "(" in parameters. [error at 39] | 24 | |
24 | DECLARE_INSTANCE_CHECKER ( InstanceType, OBJ_NAME, TYPENAME) | 25 | -/* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */ |
25 | ---------------------------------------^ | 26 | -static inline bool aa64_generate_debug_exceptions(CPUARMState *env) |
26 | 27 | -{ | |
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | - int cur_el = arm_current_el(env); |
28 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | 29 | - int debug_el; |
29 | Tested-by: Stefan Hajnoczi <stefanha@redhat.com> | 30 | - |
30 | Message-id: 20201030174700.7204-2-peter.maydell@linaro.org | 31 | - if (cur_el == 3) { |
31 | --- | 32 | - return false; |
32 | scripts/kernel-doc | 18 +++++++++++++++++- | 33 | - } |
33 | 1 file changed, 17 insertions(+), 1 deletion(-) | 34 | - |
34 | 35 | - /* MDCR_EL3.SDD disables debug events from Secure state */ | |
35 | diff --git a/scripts/kernel-doc b/scripts/kernel-doc | 36 | - if (arm_is_secure_below_el3(env) |
36 | index XXXXXXX..XXXXXXX 100755 | 37 | - && extract32(env->cp15.mdcr_el3, 16, 1)) { |
37 | --- a/scripts/kernel-doc | 38 | - return false; |
38 | +++ b/scripts/kernel-doc | 39 | - } |
39 | @@ -XXX,XX +XXX,XX @@ sub output_function_rst(%) { | 40 | - |
40 | output_highlight_rst($args{'purpose'}); | 41 | - /* |
41 | $start = "\n\n**Syntax**\n\n ``"; | 42 | - * Same EL to same EL debug exceptions need MDSCR_KDE enabled |
42 | } else { | 43 | - * while not masking the (D)ebug bit in DAIF. |
43 | - print ".. c:function:: "; | 44 | - */ |
44 | + if ((split(/\./, $sphinx_version))[0] >= 3) { | 45 | - debug_el = arm_debug_target_el(env); |
45 | + # Sphinx 3 and later distinguish macros and functions and | 46 | - |
46 | + # complain if you use c:function with something that's not | 47 | - if (cur_el == debug_el) { |
47 | + # syntactically valid as a function declaration. | 48 | - return extract32(env->cp15.mdscr_el1, 13, 1) |
48 | + # We assume that anything with a return type is a function | 49 | - && !(env->daif & PSTATE_D); |
49 | + # and anything without is a macro. | 50 | - } |
50 | + if ($args{'functiontype'} ne "") { | 51 | - |
51 | + print ".. c:function:: "; | 52 | - /* Otherwise the debug target needs to be a higher EL */ |
52 | + } else { | 53 | - return debug_el > cur_el; |
53 | + print ".. c:macro:: "; | 54 | -} |
54 | + } | 55 | - |
55 | + } else { | 56 | -static inline bool aa32_generate_debug_exceptions(CPUARMState *env) |
56 | + # Older Sphinx don't support documenting macros that take | 57 | -{ |
57 | + # arguments with c:macro, and don't complain about the use | 58 | - int el = arm_current_el(env); |
58 | + # of c:function for this. | 59 | - |
59 | + print ".. c:function:: "; | 60 | - if (el == 0 && arm_el_is_aa64(env, 1)) { |
61 | - return aa64_generate_debug_exceptions(env); | ||
62 | - } | ||
63 | - | ||
64 | - if (arm_is_secure(env)) { | ||
65 | - int spd; | ||
66 | - | ||
67 | - if (el == 0 && (env->cp15.sder & 1)) { | ||
68 | - /* SDER.SUIDEN means debug exceptions from Secure EL0 | ||
69 | - * are always enabled. Otherwise they are controlled by | ||
70 | - * SDCR.SPD like those from other Secure ELs. | ||
71 | - */ | ||
72 | - return true; | ||
73 | - } | ||
74 | - | ||
75 | - spd = extract32(env->cp15.mdcr_el3, 14, 2); | ||
76 | - switch (spd) { | ||
77 | - case 1: | ||
78 | - /* SPD == 0b01 is reserved, but behaves as 0b00. */ | ||
79 | - case 0: | ||
80 | - /* For 0b00 we return true if external secure invasive debug | ||
81 | - * is enabled. On real hardware this is controlled by external | ||
82 | - * signals to the core. QEMU always permits debug, and behaves | ||
83 | - * as if DBGEN, SPIDEN, NIDEN and SPNIDEN are all tied high. | ||
84 | - */ | ||
85 | - return true; | ||
86 | - case 2: | ||
87 | - return false; | ||
88 | - case 3: | ||
89 | - return true; | ||
90 | - } | ||
91 | - } | ||
92 | - | ||
93 | - return el != 2; | ||
94 | -} | ||
95 | - | ||
96 | -/* Return true if debugging exceptions are currently enabled. | ||
97 | - * This corresponds to what in ARM ARM pseudocode would be | ||
98 | - * if UsingAArch32() then | ||
99 | - * return AArch32.GenerateDebugExceptions() | ||
100 | - * else | ||
101 | - * return AArch64.GenerateDebugExceptions() | ||
102 | - * We choose to push the if() down into this function for clarity, | ||
103 | - * since the pseudocode has it at all callsites except for the one in | ||
104 | - * CheckSoftwareStep(), where it is elided because both branches would | ||
105 | - * always return the same value. | ||
106 | - */ | ||
107 | -static inline bool arm_generate_debug_exceptions(CPUARMState *env) | ||
108 | -{ | ||
109 | - if (env->aarch64) { | ||
110 | - return aa64_generate_debug_exceptions(env); | ||
111 | - } else { | ||
112 | - return aa32_generate_debug_exceptions(env); | ||
113 | - } | ||
114 | -} | ||
115 | - | ||
116 | static inline bool arm_sctlr_b(CPUARMState *env) | ||
117 | { | ||
118 | return | ||
119 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/target/arm/internals.h | ||
122 | +++ b/target/arm/internals.h | ||
123 | @@ -XXX,XX +XXX,XX @@ bool el_is_in_host(CPUARMState *env, int el); | ||
124 | void aa32_max_features(ARMCPU *cpu); | ||
125 | int exception_target_el(CPUARMState *env); | ||
126 | bool arm_singlestep_active(CPUARMState *env); | ||
127 | +bool arm_generate_debug_exceptions(CPUARMState *env); | ||
128 | |||
129 | /* Powers of 2 for sve_vq_map et al. */ | ||
130 | #define SVE_VQ_POW2_MAP \ | ||
131 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/arm/debug_helper.c | ||
134 | +++ b/target/arm/debug_helper.c | ||
135 | @@ -XXX,XX +XXX,XX @@ | ||
136 | #include "exec/helper-proto.h" | ||
137 | |||
138 | |||
139 | +/* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */ | ||
140 | +static bool aa64_generate_debug_exceptions(CPUARMState *env) | ||
141 | +{ | ||
142 | + int cur_el = arm_current_el(env); | ||
143 | + int debug_el; | ||
144 | + | ||
145 | + if (cur_el == 3) { | ||
146 | + return false; | ||
147 | + } | ||
148 | + | ||
149 | + /* MDCR_EL3.SDD disables debug events from Secure state */ | ||
150 | + if (arm_is_secure_below_el3(env) | ||
151 | + && extract32(env->cp15.mdcr_el3, 16, 1)) { | ||
152 | + return false; | ||
153 | + } | ||
154 | + | ||
155 | + /* | ||
156 | + * Same EL to same EL debug exceptions need MDSCR_KDE enabled | ||
157 | + * while not masking the (D)ebug bit in DAIF. | ||
158 | + */ | ||
159 | + debug_el = arm_debug_target_el(env); | ||
160 | + | ||
161 | + if (cur_el == debug_el) { | ||
162 | + return extract32(env->cp15.mdscr_el1, 13, 1) | ||
163 | + && !(env->daif & PSTATE_D); | ||
164 | + } | ||
165 | + | ||
166 | + /* Otherwise the debug target needs to be a higher EL */ | ||
167 | + return debug_el > cur_el; | ||
168 | +} | ||
169 | + | ||
170 | +static bool aa32_generate_debug_exceptions(CPUARMState *env) | ||
171 | +{ | ||
172 | + int el = arm_current_el(env); | ||
173 | + | ||
174 | + if (el == 0 && arm_el_is_aa64(env, 1)) { | ||
175 | + return aa64_generate_debug_exceptions(env); | ||
176 | + } | ||
177 | + | ||
178 | + if (arm_is_secure(env)) { | ||
179 | + int spd; | ||
180 | + | ||
181 | + if (el == 0 && (env->cp15.sder & 1)) { | ||
182 | + /* | ||
183 | + * SDER.SUIDEN means debug exceptions from Secure EL0 | ||
184 | + * are always enabled. Otherwise they are controlled by | ||
185 | + * SDCR.SPD like those from other Secure ELs. | ||
186 | + */ | ||
187 | + return true; | ||
60 | + } | 188 | + } |
61 | } | 189 | + |
62 | if ($args{'functiontype'} ne "") { | 190 | + spd = extract32(env->cp15.mdcr_el3, 14, 2); |
63 | $start .= $args{'functiontype'} . " " . $args{'function'} . " ("; | 191 | + switch (spd) { |
192 | + case 1: | ||
193 | + /* SPD == 0b01 is reserved, but behaves as 0b00. */ | ||
194 | + case 0: | ||
195 | + /* | ||
196 | + * For 0b00 we return true if external secure invasive debug | ||
197 | + * is enabled. On real hardware this is controlled by external | ||
198 | + * signals to the core. QEMU always permits debug, and behaves | ||
199 | + * as if DBGEN, SPIDEN, NIDEN and SPNIDEN are all tied high. | ||
200 | + */ | ||
201 | + return true; | ||
202 | + case 2: | ||
203 | + return false; | ||
204 | + case 3: | ||
205 | + return true; | ||
206 | + } | ||
207 | + } | ||
208 | + | ||
209 | + return el != 2; | ||
210 | +} | ||
211 | + | ||
212 | +/* | ||
213 | + * Return true if debugging exceptions are currently enabled. | ||
214 | + * This corresponds to what in ARM ARM pseudocode would be | ||
215 | + * if UsingAArch32() then | ||
216 | + * return AArch32.GenerateDebugExceptions() | ||
217 | + * else | ||
218 | + * return AArch64.GenerateDebugExceptions() | ||
219 | + * We choose to push the if() down into this function for clarity, | ||
220 | + * since the pseudocode has it at all callsites except for the one in | ||
221 | + * CheckSoftwareStep(), where it is elided because both branches would | ||
222 | + * always return the same value. | ||
223 | + */ | ||
224 | +bool arm_generate_debug_exceptions(CPUARMState *env) | ||
225 | +{ | ||
226 | + if (env->aarch64) { | ||
227 | + return aa64_generate_debug_exceptions(env); | ||
228 | + } else { | ||
229 | + return aa32_generate_debug_exceptions(env); | ||
230 | + } | ||
231 | +} | ||
232 | + | ||
233 | /* | ||
234 | * Is single-stepping active? (Note that the "is EL_D AArch64?" check | ||
235 | * implicitly means this always returns false in pre-v8 CPUs.) | ||
64 | -- | 236 | -- |
65 | 2.20.1 | 237 | 2.25.1 |
66 | |||
67 | diff view generated by jsdifflib |
1 | If we're using the capstone disassembler, disassembly of a run of | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | instructions more than 32 bytes long disassembles the wrong data for | ||
3 | instructions beyond the 32 byte mark: | ||
4 | 2 | ||
5 | (qemu) xp /16x 0x100 | 3 | Use the accessor rather than the raw structure member. |
6 | 0000000000000100: 0x00000005 0x54410001 0x00000001 0x00001000 | ||
7 | 0000000000000110: 0x00000000 0x00000004 0x54410002 0x3c000000 | ||
8 | 0000000000000120: 0x00000000 0x00000004 0x54410009 0x74736574 | ||
9 | 0000000000000130: 0x00000000 0x00000000 0x00000000 0x00000000 | ||
10 | (qemu) xp /16i 0x100 | ||
11 | 0x00000100: 00000005 andeq r0, r0, r5 | ||
12 | 0x00000104: 54410001 strbpl r0, [r1], #-1 | ||
13 | 0x00000108: 00000001 andeq r0, r0, r1 | ||
14 | 0x0000010c: 00001000 andeq r1, r0, r0 | ||
15 | 0x00000110: 00000000 andeq r0, r0, r0 | ||
16 | 0x00000114: 00000004 andeq r0, r0, r4 | ||
17 | 0x00000118: 54410002 strbpl r0, [r1], #-2 | ||
18 | 0x0000011c: 3c000000 .byte 0x00, 0x00, 0x00, 0x3c | ||
19 | 0x00000120: 54410001 strbpl r0, [r1], #-1 | ||
20 | 0x00000124: 00000001 andeq r0, r0, r1 | ||
21 | 0x00000128: 00001000 andeq r1, r0, r0 | ||
22 | 0x0000012c: 00000000 andeq r0, r0, r0 | ||
23 | 0x00000130: 00000004 andeq r0, r0, r4 | ||
24 | 0x00000134: 54410002 strbpl r0, [r1], #-2 | ||
25 | 0x00000138: 3c000000 .byte 0x00, 0x00, 0x00, 0x3c | ||
26 | 0x0000013c: 00000000 andeq r0, r0, r0 | ||
27 | 4 | ||
28 | Here the disassembly of 0x120..0x13f is using the data that is in | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
29 | 0x104..0x123. | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
30 | 7 | Message-id: 20220609202901.1177572-7-richard.henderson@linaro.org | |
31 | This is caused by passing the wrong value to the read_memory_func(). | ||
32 | The intention is that at this point in the loop the 'cap_buf' buffer | ||
33 | already contains 'csize' bytes of data for the instruction at guest | ||
34 | addr 'pc', and we want to read in an extra 'tsize' bytes. Those | ||
35 | extra bytes are therefore at 'pc + csize', not 'pc'. On the first | ||
36 | time through the loop 'csize' happens to be zero, so the initial read | ||
37 | of 32 bytes into cap_buf is correct and as long as the disassembly | ||
38 | never needs to read more data we return the correct information. | ||
39 | |||
40 | Use the correct guest address in the call to read_memory_func(). | ||
41 | |||
42 | Cc: qemu-stable@nongnu.org | ||
43 | Fixes: https://bugs.launchpad.net/qemu/+bug/1900779 | ||
44 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
45 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
46 | Message-id: 20201022132445.25039-1-peter.maydell@linaro.org | ||
47 | --- | 9 | --- |
48 | disas/capstone.c | 2 +- | 10 | target/arm/debug_helper.c | 2 +- |
49 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
50 | 12 | ||
51 | diff --git a/disas/capstone.c b/disas/capstone.c | 13 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
52 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/disas/capstone.c | 15 | --- a/target/arm/debug_helper.c |
54 | +++ b/disas/capstone.c | 16 | +++ b/target/arm/debug_helper.c |
55 | @@ -XXX,XX +XXX,XX @@ bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count) | 17 | @@ -XXX,XX +XXX,XX @@ static bool aa32_generate_debug_exceptions(CPUARMState *env) |
56 | 18 | */ | |
57 | /* Make certain that we can make progress. */ | 19 | bool arm_generate_debug_exceptions(CPUARMState *env) |
58 | assert(tsize != 0); | 20 | { |
59 | - info->read_memory_func(pc, cap_buf + csize, tsize, info); | 21 | - if (env->aarch64) { |
60 | + info->read_memory_func(pc + csize, cap_buf + csize, tsize, info); | 22 | + if (is_a64(env)) { |
61 | csize += tsize; | 23 | return aa64_generate_debug_exceptions(env); |
62 | 24 | } else { | |
63 | if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { | 25 | return aa32_generate_debug_exceptions(env); |
64 | -- | 26 | -- |
65 | 2.20.1 | 27 | 2.25.1 |
66 | |||
67 | diff view generated by jsdifflib |
1 | On some hosts (eg Ubuntu Bionic) pkg-config returns a set of | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | libraries for gio-2.0 which don't actually work when compiling | ||
3 | statically. (Specifically, the returned library string includes | ||
4 | -lmount, but not -lblkid which -lmount depends upon, so linking | ||
5 | fails due to missing symbols.) | ||
6 | 2 | ||
7 | Check that the libraries work, and don't enable gio if they don't, | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | in the same way we do for gnutls. | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20220609202901.1177572-8-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/debug_helper.c | 31 +++++++++++++++++++++++++++++++ | ||
9 | target/arm/op_helper.c | 29 ----------------------------- | ||
10 | 2 files changed, 31 insertions(+), 29 deletions(-) | ||
9 | 11 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
11 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | 13 | index XXXXXXX..XXXXXXX 100644 |
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 14 | --- a/target/arm/debug_helper.c |
13 | Message-id: 20200928160402.7961-1-peter.maydell@linaro.org | 15 | +++ b/target/arm/debug_helper.c |
14 | --- | 16 | @@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs) |
15 | configure | 10 +++++++++- | 17 | } |
16 | 1 file changed, 9 insertions(+), 1 deletion(-) | 18 | } |
17 | 19 | ||
18 | diff --git a/configure b/configure | 20 | +/* |
19 | index XXXXXXX..XXXXXXX 100755 | 21 | + * Raise an EXCP_BKPT with the specified syndrome register value, |
20 | --- a/configure | 22 | + * targeting the correct exception level for debug exceptions. |
21 | +++ b/configure | 23 | + */ |
22 | @@ -XXX,XX +XXX,XX @@ if test "$static" = yes && test "$mingw32" = yes; then | 24 | +void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome) |
23 | fi | 25 | +{ |
24 | 26 | + int debug_el = arm_debug_target_el(env); | |
25 | if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then | 27 | + int cur_el = arm_current_el(env); |
26 | - gio=yes | 28 | + |
27 | gio_cflags=$($pkg_config --cflags gio-2.0) | 29 | + /* FSR will only be used if the debug target EL is AArch32. */ |
28 | gio_libs=$($pkg_config --libs gio-2.0) | 30 | + env->exception.fsr = arm_debug_exception_fsr(env); |
29 | gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0) | 31 | + /* |
30 | if [ ! -x "$gdbus_codegen" ]; then | 32 | + * FAR is UNKNOWN: clear vaddress to avoid potentially exposing |
31 | gdbus_codegen= | 33 | + * values to the guest that it shouldn't be able to see at its |
32 | fi | 34 | + * exception/security level. |
33 | + # Check that the libraries actually work -- Ubuntu 18.04 ships | 35 | + */ |
34 | + # with pkg-config --static --libs data for gio-2.0 that is missing | 36 | + env->exception.vaddress = 0; |
35 | + # -lblkid and will give a link error. | 37 | + /* |
36 | + write_c_skeleton | 38 | + * Other kinds of architectural debug exception are ignored if |
37 | + if compile_prog "" "gio_libs" ; then | 39 | + * they target an exception level below the current one (in QEMU |
38 | + gio=yes | 40 | + * this is checked by arm_generate_debug_exceptions()). Breakpoint |
39 | + else | 41 | + * instructions are special because they always generate an exception |
40 | + gio=no | 42 | + * to somewhere: if they can't go to the configured debug exception |
41 | + fi | 43 | + * level they are taken to the current exception level. |
42 | else | 44 | + */ |
43 | gio=no | 45 | + if (debug_el < cur_el) { |
44 | fi | 46 | + debug_el = cur_el; |
47 | + } | ||
48 | + raise_exception(env, EXCP_BKPT, syndrome, debug_el); | ||
49 | +} | ||
50 | + | ||
51 | #if !defined(CONFIG_USER_ONLY) | ||
52 | |||
53 | vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len) | ||
54 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/target/arm/op_helper.c | ||
57 | +++ b/target/arm/op_helper.c | ||
58 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_with_syndrome)(CPUARMState *env, uint32_t excp, | ||
59 | raise_exception(env, excp, syndrome, target_el); | ||
60 | } | ||
61 | |||
62 | -/* Raise an EXCP_BKPT with the specified syndrome register value, | ||
63 | - * targeting the correct exception level for debug exceptions. | ||
64 | - */ | ||
65 | -void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome) | ||
66 | -{ | ||
67 | - int debug_el = arm_debug_target_el(env); | ||
68 | - int cur_el = arm_current_el(env); | ||
69 | - | ||
70 | - /* FSR will only be used if the debug target EL is AArch32. */ | ||
71 | - env->exception.fsr = arm_debug_exception_fsr(env); | ||
72 | - /* FAR is UNKNOWN: clear vaddress to avoid potentially exposing | ||
73 | - * values to the guest that it shouldn't be able to see at its | ||
74 | - * exception/security level. | ||
75 | - */ | ||
76 | - env->exception.vaddress = 0; | ||
77 | - /* | ||
78 | - * Other kinds of architectural debug exception are ignored if | ||
79 | - * they target an exception level below the current one (in QEMU | ||
80 | - * this is checked by arm_generate_debug_exceptions()). Breakpoint | ||
81 | - * instructions are special because they always generate an exception | ||
82 | - * to somewhere: if they can't go to the configured debug exception | ||
83 | - * level they are taken to the current exception level. | ||
84 | - */ | ||
85 | - if (debug_el < cur_el) { | ||
86 | - debug_el = cur_el; | ||
87 | - } | ||
88 | - raise_exception(env, EXCP_BKPT, syndrome, debug_el); | ||
89 | -} | ||
90 | - | ||
91 | uint32_t HELPER(cpsr_read)(CPUARMState *env) | ||
92 | { | ||
93 | return cpsr_read(env) & ~CPSR_EXEC; | ||
45 | -- | 94 | -- |
46 | 2.20.1 | 95 | 2.25.1 |
47 | |||
48 | diff view generated by jsdifflib |
1 | In arm_v7m_mmu_idx_for_secstate() we get the 'priv' level to pass to | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | armv7m_mmu_idx_for_secstate_and_priv() by calling arm_current_el(). | ||
3 | This is incorrect when the security state being queried is not the | ||
4 | current one, because arm_current_el() uses the current security state | ||
5 | to determine which of the banked CONTROL.nPRIV bits to look at. | ||
6 | The effect was that if (for instance) Secure state was in privileged | ||
7 | mode but Non-Secure was not then we would return the wrong MMU index. | ||
8 | 2 | ||
9 | The only places where we are using this function in a way that could | 3 | This function now now only used in debug_helper.c, so there is |
10 | trigger this bug are for the stack loads during a v8M function-return | 4 | no reason to have a declaration in a header. |
11 | and for the instruction fetch of a v8M SG insn. | ||
12 | 5 | ||
13 | Fix the bug by expanding out the M-profile version of the | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | arm_current_el() logic inline so it can use the passed in secstate | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
15 | rather than env->v7m.secure. | 8 | Message-id: 20220609202901.1177572-9-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/internals.h | 25 ------------------------- | ||
12 | target/arm/debug_helper.c | 26 ++++++++++++++++++++++++++ | ||
13 | 2 files changed, 26 insertions(+), 25 deletions(-) | ||
16 | 14 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20201022164408.13214-1-peter.maydell@linaro.org | ||
20 | --- | ||
21 | target/arm/m_helper.c | 3 ++- | ||
22 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
23 | |||
24 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/m_helper.c | 17 | --- a/target/arm/internals.h |
27 | +++ b/target/arm/m_helper.c | 18 | +++ b/target/arm/internals.h |
28 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | 19 | @@ -XXX,XX +XXX,XX @@ static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx) |
29 | /* Return the MMU index for a v7M CPU in the specified security state */ | 20 | return &env->cp15.tcr_el[regime_el(env, mmu_idx)]; |
30 | ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | 21 | } |
22 | |||
23 | -/* Return the FSR value for a debug exception (watchpoint, hardware | ||
24 | - * breakpoint or BKPT insn) targeting the specified exception level. | ||
25 | - */ | ||
26 | -static inline uint32_t arm_debug_exception_fsr(CPUARMState *env) | ||
27 | -{ | ||
28 | - ARMMMUFaultInfo fi = { .type = ARMFault_Debug }; | ||
29 | - int target_el = arm_debug_target_el(env); | ||
30 | - bool using_lpae = false; | ||
31 | - | ||
32 | - if (target_el == 2 || arm_el_is_aa64(env, target_el)) { | ||
33 | - using_lpae = true; | ||
34 | - } else { | ||
35 | - if (arm_feature(env, ARM_FEATURE_LPAE) && | ||
36 | - (env->cp15.tcr_el[target_el].raw_tcr & TTBCR_EAE)) { | ||
37 | - using_lpae = true; | ||
38 | - } | ||
39 | - } | ||
40 | - | ||
41 | - if (using_lpae) { | ||
42 | - return arm_fi_to_lfsc(&fi); | ||
43 | - } else { | ||
44 | - return arm_fi_to_sfsc(&fi); | ||
45 | - } | ||
46 | -} | ||
47 | - | ||
48 | /** | ||
49 | * arm_num_brps: Return number of implemented breakpoints. | ||
50 | * Note that the ID register BRPS field is "number of bps - 1", | ||
51 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/debug_helper.c | ||
54 | +++ b/target/arm/debug_helper.c | ||
55 | @@ -XXX,XX +XXX,XX @@ bool arm_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp) | ||
56 | return check_watchpoints(cpu); | ||
57 | } | ||
58 | |||
59 | +/* | ||
60 | + * Return the FSR value for a debug exception (watchpoint, hardware | ||
61 | + * breakpoint or BKPT insn) targeting the specified exception level. | ||
62 | + */ | ||
63 | +static uint32_t arm_debug_exception_fsr(CPUARMState *env) | ||
64 | +{ | ||
65 | + ARMMMUFaultInfo fi = { .type = ARMFault_Debug }; | ||
66 | + int target_el = arm_debug_target_el(env); | ||
67 | + bool using_lpae = false; | ||
68 | + | ||
69 | + if (target_el == 2 || arm_el_is_aa64(env, target_el)) { | ||
70 | + using_lpae = true; | ||
71 | + } else { | ||
72 | + if (arm_feature(env, ARM_FEATURE_LPAE) && | ||
73 | + (env->cp15.tcr_el[target_el].raw_tcr & TTBCR_EAE)) { | ||
74 | + using_lpae = true; | ||
75 | + } | ||
76 | + } | ||
77 | + | ||
78 | + if (using_lpae) { | ||
79 | + return arm_fi_to_lfsc(&fi); | ||
80 | + } else { | ||
81 | + return arm_fi_to_sfsc(&fi); | ||
82 | + } | ||
83 | +} | ||
84 | + | ||
85 | void arm_debug_excp_handler(CPUState *cs) | ||
31 | { | 86 | { |
32 | - bool priv = arm_current_el(env) != 0; | 87 | /* |
33 | + bool priv = arm_v7m_is_handler_mode(env) || | ||
34 | + !(env->v7m.control[secstate] & 1); | ||
35 | |||
36 | return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); | ||
37 | } | ||
38 | -- | 88 | -- |
39 | 2.20.1 | 89 | 2.25.1 |
40 | |||
41 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We can use proper widening loads to extend 32-bit inputs, | 3 | Rename to helper_exception_with_syndrome_el, to emphasize |
4 | and skip the "widenfn" step. | 4 | that the target el is a parameter. |
5 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201030022618.785675-12-richard.henderson@linaro.org | 8 | Message-id: 20220609202901.1177572-10-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | target/arm/translate.c | 6 +++ | 11 | target/arm/helper.h | 2 +- |
12 | target/arm/translate-neon.c.inc | 66 ++++++++++++++++++--------------- | 12 | target/arm/translate.h | 6 +++--- |
13 | 2 files changed, 43 insertions(+), 29 deletions(-) | 13 | target/arm/op_helper.c | 6 +++--- |
14 | target/arm/translate.c | 6 +++--- | ||
15 | 4 files changed, 10 insertions(+), 10 deletions(-) | ||
14 | 16 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/helper.h | ||
20 | +++ b/target/arm/helper.h | ||
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(usad8, TCG_CALL_NO_RWG_SE, i32, i32, i32) | ||
22 | DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE, | ||
23 | i32, i32, i32, i32) | ||
24 | DEF_HELPER_2(exception_internal, noreturn, env, i32) | ||
25 | -DEF_HELPER_4(exception_with_syndrome, noreturn, env, i32, i32, i32) | ||
26 | +DEF_HELPER_4(exception_with_syndrome_el, noreturn, env, i32, i32, i32) | ||
27 | DEF_HELPER_2(exception_bkpt_insn, noreturn, env, i32) | ||
28 | DEF_HELPER_2(exception_pc_alignment, noreturn, env, tl) | ||
29 | DEF_HELPER_1(setend, void, env) | ||
30 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/translate.h | ||
33 | +++ b/target/arm/translate.h | ||
34 | @@ -XXX,XX +XXX,XX @@ static inline void gen_ss_advance(DisasContext *s) | ||
35 | static inline void gen_exception(int excp, uint32_t syndrome, | ||
36 | uint32_t target_el) | ||
37 | { | ||
38 | - gen_helper_exception_with_syndrome(cpu_env, tcg_constant_i32(excp), | ||
39 | - tcg_constant_i32(syndrome), | ||
40 | - tcg_constant_i32(target_el)); | ||
41 | + gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp), | ||
42 | + tcg_constant_i32(syndrome), | ||
43 | + tcg_constant_i32(target_el)); | ||
44 | } | ||
45 | |||
46 | /* Generate an architectural singlestep exception */ | ||
47 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/op_helper.c | ||
50 | +++ b/target/arm/op_helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ void HELPER(yield)(CPUARMState *env) | ||
52 | * those EXCP values which are special cases for QEMU to interrupt | ||
53 | * execution and not to be used for exceptions which are passed to | ||
54 | * the guest (those must all have syndrome information and thus should | ||
55 | - * use exception_with_syndrome). | ||
56 | + * use exception_with_syndrome*). | ||
57 | */ | ||
58 | void HELPER(exception_internal)(CPUARMState *env, uint32_t excp) | ||
59 | { | ||
60 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_internal)(CPUARMState *env, uint32_t excp) | ||
61 | } | ||
62 | |||
63 | /* Raise an exception with the specified syndrome register value */ | ||
64 | -void HELPER(exception_with_syndrome)(CPUARMState *env, uint32_t excp, | ||
65 | - uint32_t syndrome, uint32_t target_el) | ||
66 | +void HELPER(exception_with_syndrome_el)(CPUARMState *env, uint32_t excp, | ||
67 | + uint32_t syndrome, uint32_t target_el) | ||
68 | { | ||
69 | raise_exception(env, excp, syndrome, target_el); | ||
70 | } | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 71 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
16 | index XXXXXXX..XXXXXXX 100644 | 72 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 73 | --- a/target/arm/translate.c |
18 | +++ b/target/arm/translate.c | 74 | +++ b/target/arm/translate.c |
19 | @@ -XXX,XX +XXX,XX @@ static void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop) | 75 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_el(DisasContext *s, int excp, uint32_t syn, |
20 | long off = neon_element_offset(reg, ele, memop); | ||
21 | |||
22 | switch (memop) { | ||
23 | + case MO_SL: | ||
24 | + tcg_gen_ld32s_i64(dest, cpu_env, off); | ||
25 | + break; | ||
26 | + case MO_UL: | ||
27 | + tcg_gen_ld32u_i64(dest, cpu_env, off); | ||
28 | + break; | ||
29 | case MO_Q: | ||
30 | tcg_gen_ld_i64(dest, cpu_env, off); | ||
31 | break; | ||
32 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/translate-neon.c.inc | ||
35 | +++ b/target/arm/translate-neon.c.inc | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool trans_Vimm_1r(DisasContext *s, arg_1reg_imm *a) | ||
37 | static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
38 | NeonGenWidenFn *widenfn, | ||
39 | NeonGenTwo64OpFn *opfn, | ||
40 | - bool src1_wide) | ||
41 | + int src1_mop, int src2_mop) | ||
42 | { | 76 | { |
43 | /* 3-regs different lengths, prewidening case (VADDL/VSUBL/VAADW/VSUBW) */ | 77 | gen_set_condexec(s); |
44 | TCGv_i64 rn0_64, rn1_64, rm_64; | 78 | gen_set_pc_im(s, s->pc_curr); |
45 | - TCGv_i32 rm; | 79 | - gen_helper_exception_with_syndrome(cpu_env, |
46 | 80 | - tcg_constant_i32(excp), | |
47 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 81 | - tcg_constant_i32(syn), tcg_el); |
48 | return false; | 82 | + gen_helper_exception_with_syndrome_el(cpu_env, |
49 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | 83 | + tcg_constant_i32(excp), |
50 | return false; | 84 | + tcg_constant_i32(syn), tcg_el); |
51 | } | 85 | s->base.is_jmp = DISAS_NORETURN; |
52 | |||
53 | - if (!widenfn || !opfn) { | ||
54 | + if (!opfn) { | ||
55 | /* size == 3 case, which is an entirely different insn group */ | ||
56 | return false; | ||
57 | } | ||
58 | |||
59 | - if ((a->vd & 1) || (src1_wide && (a->vn & 1))) { | ||
60 | + if ((a->vd & 1) || (src1_mop == MO_Q && (a->vn & 1))) { | ||
61 | return false; | ||
62 | } | ||
63 | |||
64 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
65 | rn1_64 = tcg_temp_new_i64(); | ||
66 | rm_64 = tcg_temp_new_i64(); | ||
67 | |||
68 | - if (src1_wide) { | ||
69 | - read_neon_element64(rn0_64, a->vn, 0, MO_64); | ||
70 | + if (src1_mop >= 0) { | ||
71 | + read_neon_element64(rn0_64, a->vn, 0, src1_mop); | ||
72 | } else { | ||
73 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
74 | read_neon_element32(tmp, a->vn, 0, MO_32); | ||
75 | widenfn(rn0_64, tmp); | ||
76 | tcg_temp_free_i32(tmp); | ||
77 | } | ||
78 | - rm = tcg_temp_new_i32(); | ||
79 | - read_neon_element32(rm, a->vm, 0, MO_32); | ||
80 | + if (src2_mop >= 0) { | ||
81 | + read_neon_element64(rm_64, a->vm, 0, src2_mop); | ||
82 | + } else { | ||
83 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
84 | + read_neon_element32(tmp, a->vm, 0, MO_32); | ||
85 | + widenfn(rm_64, tmp); | ||
86 | + tcg_temp_free_i32(tmp); | ||
87 | + } | ||
88 | |||
89 | - widenfn(rm_64, rm); | ||
90 | - tcg_temp_free_i32(rm); | ||
91 | opfn(rn0_64, rn0_64, rm_64); | ||
92 | |||
93 | /* | ||
94 | * Load second pass inputs before storing the first pass result, to | ||
95 | * avoid incorrect results if a narrow input overlaps with the result. | ||
96 | */ | ||
97 | - if (src1_wide) { | ||
98 | - read_neon_element64(rn1_64, a->vn, 1, MO_64); | ||
99 | + if (src1_mop >= 0) { | ||
100 | + read_neon_element64(rn1_64, a->vn, 1, src1_mop); | ||
101 | } else { | ||
102 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
103 | read_neon_element32(tmp, a->vn, 1, MO_32); | ||
104 | widenfn(rn1_64, tmp); | ||
105 | tcg_temp_free_i32(tmp); | ||
106 | } | ||
107 | - rm = tcg_temp_new_i32(); | ||
108 | - read_neon_element32(rm, a->vm, 1, MO_32); | ||
109 | + if (src2_mop >= 0) { | ||
110 | + read_neon_element64(rm_64, a->vm, 1, src2_mop); | ||
111 | + } else { | ||
112 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
113 | + read_neon_element32(tmp, a->vm, 1, MO_32); | ||
114 | + widenfn(rm_64, tmp); | ||
115 | + tcg_temp_free_i32(tmp); | ||
116 | + } | ||
117 | |||
118 | write_neon_element64(rn0_64, a->vd, 0, MO_64); | ||
119 | |||
120 | - widenfn(rm_64, rm); | ||
121 | - tcg_temp_free_i32(rm); | ||
122 | opfn(rn1_64, rn1_64, rm_64); | ||
123 | write_neon_element64(rn1_64, a->vd, 1, MO_64); | ||
124 | |||
125 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
126 | return true; | ||
127 | } | 86 | } |
128 | 87 | ||
129 | -#define DO_PREWIDEN(INSN, S, EXT, OP, SRC1WIDE) \ | ||
130 | +#define DO_PREWIDEN(INSN, S, OP, SRC1WIDE, SIGN) \ | ||
131 | static bool trans_##INSN##_3d(DisasContext *s, arg_3diff *a) \ | ||
132 | { \ | ||
133 | static NeonGenWidenFn * const widenfn[] = { \ | ||
134 | gen_helper_neon_widen_##S##8, \ | ||
135 | gen_helper_neon_widen_##S##16, \ | ||
136 | - tcg_gen_##EXT##_i32_i64, \ | ||
137 | - NULL, \ | ||
138 | + NULL, NULL, \ | ||
139 | }; \ | ||
140 | static NeonGenTwo64OpFn * const addfn[] = { \ | ||
141 | gen_helper_neon_##OP##l_u16, \ | ||
142 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
143 | tcg_gen_##OP##_i64, \ | ||
144 | NULL, \ | ||
145 | }; \ | ||
146 | - return do_prewiden_3d(s, a, widenfn[a->size], \ | ||
147 | - addfn[a->size], SRC1WIDE); \ | ||
148 | + int narrow_mop = a->size == MO_32 ? MO_32 | SIGN : -1; \ | ||
149 | + return do_prewiden_3d(s, a, widenfn[a->size], addfn[a->size], \ | ||
150 | + SRC1WIDE ? MO_Q : narrow_mop, \ | ||
151 | + narrow_mop); \ | ||
152 | } | ||
153 | |||
154 | -DO_PREWIDEN(VADDL_S, s, ext, add, false) | ||
155 | -DO_PREWIDEN(VADDL_U, u, extu, add, false) | ||
156 | -DO_PREWIDEN(VSUBL_S, s, ext, sub, false) | ||
157 | -DO_PREWIDEN(VSUBL_U, u, extu, sub, false) | ||
158 | -DO_PREWIDEN(VADDW_S, s, ext, add, true) | ||
159 | -DO_PREWIDEN(VADDW_U, u, extu, add, true) | ||
160 | -DO_PREWIDEN(VSUBW_S, s, ext, sub, true) | ||
161 | -DO_PREWIDEN(VSUBW_U, u, extu, sub, true) | ||
162 | +DO_PREWIDEN(VADDL_S, s, add, false, MO_SIGN) | ||
163 | +DO_PREWIDEN(VADDL_U, u, add, false, 0) | ||
164 | +DO_PREWIDEN(VSUBL_S, s, sub, false, MO_SIGN) | ||
165 | +DO_PREWIDEN(VSUBL_U, u, sub, false, 0) | ||
166 | +DO_PREWIDEN(VADDW_S, s, add, true, MO_SIGN) | ||
167 | +DO_PREWIDEN(VADDW_U, u, add, true, 0) | ||
168 | +DO_PREWIDEN(VSUBW_S, s, sub, true, MO_SIGN) | ||
169 | +DO_PREWIDEN(VSUBW_U, u, sub, true, 0) | ||
170 | |||
171 | static bool do_narrow_3d(DisasContext *s, arg_3diff *a, | ||
172 | NeonGenTwo64OpFn *opfn, NeonGenNarrowFn *narrowfn) | ||
173 | -- | 88 | -- |
174 | 2.20.1 | 89 | 2.25.1 |
175 | |||
176 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Model these off the aa64 read/write_vec_element functions. | 3 | Create a function below gen_exception_insn that takes |
4 | Use it within translate-neon.c.inc. The new functions do | 4 | the target_el as a TCGv_i32, replacing gen_exception_el. |
5 | not allocate or free temps, so this rearranges the calling | ||
6 | code a bit. | ||
7 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201030022618.785675-6-richard.henderson@linaro.org | 8 | Message-id: 20220609202901.1177572-11-richard.henderson@linaro.org |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 10 | --- |
13 | target/arm/translate.c | 26 ++++ | 11 | target/arm/translate.c | 27 ++++++++++++--------------- |
14 | target/arm/translate-neon.c.inc | 256 ++++++++++++++++++++------------ | 12 | 1 file changed, 12 insertions(+), 15 deletions(-) |
15 | 2 files changed, 183 insertions(+), 99 deletions(-) | ||
16 | 13 | ||
17 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate.c | 16 | --- a/target/arm/translate.c |
20 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/translate.c |
21 | @@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg32(TCGv_i32 var, int reg) | 18 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp) |
22 | tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); | 19 | s->base.is_jmp = DISAS_NORETURN; |
23 | } | 20 | } |
24 | 21 | ||
25 | +static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size) | 22 | -void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, |
23 | - uint32_t syn, uint32_t target_el) | ||
24 | +static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp, | ||
25 | + uint32_t syn, TCGv_i32 tcg_el) | ||
26 | { | ||
27 | if (s->aarch64) { | ||
28 | gen_a64_set_pc_im(pc); | ||
29 | @@ -XXX,XX +XXX,XX @@ void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, | ||
30 | gen_set_condexec(s); | ||
31 | gen_set_pc_im(s, pc); | ||
32 | } | ||
33 | - gen_exception(excp, syn, target_el); | ||
34 | + gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp), | ||
35 | + tcg_constant_i32(syn), tcg_el); | ||
36 | s->base.is_jmp = DISAS_NORETURN; | ||
37 | } | ||
38 | |||
39 | +void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, | ||
40 | + uint32_t syn, uint32_t target_el) | ||
26 | +{ | 41 | +{ |
27 | + long off = neon_element_offset(reg, ele, size); | 42 | + gen_exception_insn_el_v(s, pc, excp, syn, tcg_constant_i32(target_el)); |
28 | + | ||
29 | + switch (size) { | ||
30 | + case MO_32: | ||
31 | + tcg_gen_ld_i32(dest, cpu_env, off); | ||
32 | + break; | ||
33 | + default: | ||
34 | + g_assert_not_reached(); | ||
35 | + } | ||
36 | +} | 43 | +} |
37 | + | 44 | + |
38 | +static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp size) | 45 | static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) |
39 | +{ | ||
40 | + long off = neon_element_offset(reg, ele, size); | ||
41 | + | ||
42 | + switch (size) { | ||
43 | + case MO_32: | ||
44 | + tcg_gen_st_i32(src, cpu_env, off); | ||
45 | + break; | ||
46 | + default: | ||
47 | + g_assert_not_reached(); | ||
48 | + } | ||
49 | +} | ||
50 | + | ||
51 | static TCGv_ptr vfp_reg_ptr(bool dp, int reg) | ||
52 | { | 46 | { |
53 | TCGv_ptr ret = tcg_temp_new_ptr(); | 47 | gen_set_condexec(s); |
54 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 48 | @@ -XXX,XX +XXX,XX @@ void unallocated_encoding(DisasContext *s) |
55 | index XXXXXXX..XXXXXXX 100644 | 49 | default_exception_el(s)); |
56 | --- a/target/arm/translate-neon.c.inc | ||
57 | +++ b/target/arm/translate-neon.c.inc | ||
58 | @@ -XXX,XX +XXX,XX @@ static bool do_3same_pair(DisasContext *s, arg_3same *a, NeonGenTwoOpFn *fn) | ||
59 | * early. Since Q is 0 there are always just two passes, so instead | ||
60 | * of a complicated loop over each pass we just unroll. | ||
61 | */ | ||
62 | - tmp = neon_load_reg(a->vn, 0); | ||
63 | - tmp2 = neon_load_reg(a->vn, 1); | ||
64 | + tmp = tcg_temp_new_i32(); | ||
65 | + tmp2 = tcg_temp_new_i32(); | ||
66 | + tmp3 = tcg_temp_new_i32(); | ||
67 | + | ||
68 | + read_neon_element32(tmp, a->vn, 0, MO_32); | ||
69 | + read_neon_element32(tmp2, a->vn, 1, MO_32); | ||
70 | fn(tmp, tmp, tmp2); | ||
71 | - tcg_temp_free_i32(tmp2); | ||
72 | |||
73 | - tmp3 = neon_load_reg(a->vm, 0); | ||
74 | - tmp2 = neon_load_reg(a->vm, 1); | ||
75 | + read_neon_element32(tmp3, a->vm, 0, MO_32); | ||
76 | + read_neon_element32(tmp2, a->vm, 1, MO_32); | ||
77 | fn(tmp3, tmp3, tmp2); | ||
78 | - tcg_temp_free_i32(tmp2); | ||
79 | |||
80 | - neon_store_reg(a->vd, 0, tmp); | ||
81 | - neon_store_reg(a->vd, 1, tmp3); | ||
82 | + write_neon_element32(tmp, a->vd, 0, MO_32); | ||
83 | + write_neon_element32(tmp3, a->vd, 1, MO_32); | ||
84 | + | ||
85 | + tcg_temp_free_i32(tmp); | ||
86 | + tcg_temp_free_i32(tmp2); | ||
87 | + tcg_temp_free_i32(tmp3); | ||
88 | return true; | ||
89 | } | 50 | } |
90 | 51 | ||
91 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | 52 | -static void gen_exception_el(DisasContext *s, int excp, uint32_t syn, |
92 | * 2-reg-and-shift operations, size < 3 case, where the | 53 | - TCGv_i32 tcg_el) |
93 | * helper needs to be passed cpu_env. | 54 | -{ |
94 | */ | 55 | - gen_set_condexec(s); |
95 | - TCGv_i32 constimm; | 56 | - gen_set_pc_im(s, s->pc_curr); |
96 | + TCGv_i32 constimm, tmp; | 57 | - gen_helper_exception_with_syndrome_el(cpu_env, |
97 | int pass; | 58 | - tcg_constant_i32(excp), |
98 | 59 | - tcg_constant_i32(syn), tcg_el); | |
99 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 60 | - s->base.is_jmp = DISAS_NORETURN; |
100 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | 61 | -} |
101 | * by immediate using the variable shift operations. | 62 | - |
102 | */ | 63 | /* Force a TB lookup after an instruction that changes the CPU state. */ |
103 | constimm = tcg_const_i32(dup_const(a->size, a->shift)); | 64 | void gen_lookup_tb(DisasContext *s) |
104 | + tmp = tcg_temp_new_i32(); | ||
105 | |||
106 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
107 | - TCGv_i32 tmp = neon_load_reg(a->vm, pass); | ||
108 | + read_neon_element32(tmp, a->vm, pass, MO_32); | ||
109 | fn(tmp, cpu_env, tmp, constimm); | ||
110 | - neon_store_reg(a->vd, pass, tmp); | ||
111 | + write_neon_element32(tmp, a->vd, pass, MO_32); | ||
112 | } | ||
113 | + tcg_temp_free_i32(tmp); | ||
114 | tcg_temp_free_i32(constimm); | ||
115 | return true; | ||
116 | } | ||
117 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, | ||
118 | constimm = tcg_const_i64(-a->shift); | ||
119 | rm1 = tcg_temp_new_i64(); | ||
120 | rm2 = tcg_temp_new_i64(); | ||
121 | + rd = tcg_temp_new_i32(); | ||
122 | |||
123 | /* Load both inputs first to avoid potential overwrite if rm == rd */ | ||
124 | neon_load_reg64(rm1, a->vm); | ||
125 | neon_load_reg64(rm2, a->vm + 1); | ||
126 | |||
127 | shiftfn(rm1, rm1, constimm); | ||
128 | - rd = tcg_temp_new_i32(); | ||
129 | narrowfn(rd, cpu_env, rm1); | ||
130 | - neon_store_reg(a->vd, 0, rd); | ||
131 | + write_neon_element32(rd, a->vd, 0, MO_32); | ||
132 | |||
133 | shiftfn(rm2, rm2, constimm); | ||
134 | - rd = tcg_temp_new_i32(); | ||
135 | narrowfn(rd, cpu_env, rm2); | ||
136 | - neon_store_reg(a->vd, 1, rd); | ||
137 | + write_neon_element32(rd, a->vd, 1, MO_32); | ||
138 | |||
139 | + tcg_temp_free_i32(rd); | ||
140 | tcg_temp_free_i64(rm1); | ||
141 | tcg_temp_free_i64(rm2); | ||
142 | tcg_temp_free_i64(constimm); | ||
143 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | ||
144 | constimm = tcg_const_i32(imm); | ||
145 | |||
146 | /* Load all inputs first to avoid potential overwrite */ | ||
147 | - rm1 = neon_load_reg(a->vm, 0); | ||
148 | - rm2 = neon_load_reg(a->vm, 1); | ||
149 | - rm3 = neon_load_reg(a->vm + 1, 0); | ||
150 | - rm4 = neon_load_reg(a->vm + 1, 1); | ||
151 | + rm1 = tcg_temp_new_i32(); | ||
152 | + rm2 = tcg_temp_new_i32(); | ||
153 | + rm3 = tcg_temp_new_i32(); | ||
154 | + rm4 = tcg_temp_new_i32(); | ||
155 | + read_neon_element32(rm1, a->vm, 0, MO_32); | ||
156 | + read_neon_element32(rm2, a->vm, 1, MO_32); | ||
157 | + read_neon_element32(rm3, a->vm, 2, MO_32); | ||
158 | + read_neon_element32(rm4, a->vm, 3, MO_32); | ||
159 | rtmp = tcg_temp_new_i64(); | ||
160 | |||
161 | shiftfn(rm1, rm1, constimm); | ||
162 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | ||
163 | tcg_temp_free_i32(rm2); | ||
164 | |||
165 | narrowfn(rm1, cpu_env, rtmp); | ||
166 | - neon_store_reg(a->vd, 0, rm1); | ||
167 | + write_neon_element32(rm1, a->vd, 0, MO_32); | ||
168 | + tcg_temp_free_i32(rm1); | ||
169 | |||
170 | shiftfn(rm3, rm3, constimm); | ||
171 | shiftfn(rm4, rm4, constimm); | ||
172 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | ||
173 | |||
174 | narrowfn(rm3, cpu_env, rtmp); | ||
175 | tcg_temp_free_i64(rtmp); | ||
176 | - neon_store_reg(a->vd, 1, rm3); | ||
177 | + write_neon_element32(rm3, a->vd, 1, MO_32); | ||
178 | + tcg_temp_free_i32(rm3); | ||
179 | return true; | ||
180 | } | ||
181 | |||
182 | @@ -XXX,XX +XXX,XX @@ static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, | ||
183 | widen_mask = dup_const(a->size + 1, widen_mask); | ||
184 | } | ||
185 | |||
186 | - rm0 = neon_load_reg(a->vm, 0); | ||
187 | - rm1 = neon_load_reg(a->vm, 1); | ||
188 | + rm0 = tcg_temp_new_i32(); | ||
189 | + rm1 = tcg_temp_new_i32(); | ||
190 | + read_neon_element32(rm0, a->vm, 0, MO_32); | ||
191 | + read_neon_element32(rm1, a->vm, 1, MO_32); | ||
192 | tmp = tcg_temp_new_i64(); | ||
193 | |||
194 | widenfn(tmp, rm0); | ||
195 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
196 | if (src1_wide) { | ||
197 | neon_load_reg64(rn0_64, a->vn); | ||
198 | } else { | ||
199 | - TCGv_i32 tmp = neon_load_reg(a->vn, 0); | ||
200 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
201 | + read_neon_element32(tmp, a->vn, 0, MO_32); | ||
202 | widenfn(rn0_64, tmp); | ||
203 | tcg_temp_free_i32(tmp); | ||
204 | } | ||
205 | - rm = neon_load_reg(a->vm, 0); | ||
206 | + rm = tcg_temp_new_i32(); | ||
207 | + read_neon_element32(rm, a->vm, 0, MO_32); | ||
208 | |||
209 | widenfn(rm_64, rm); | ||
210 | tcg_temp_free_i32(rm); | ||
211 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
212 | if (src1_wide) { | ||
213 | neon_load_reg64(rn1_64, a->vn + 1); | ||
214 | } else { | ||
215 | - TCGv_i32 tmp = neon_load_reg(a->vn, 1); | ||
216 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
217 | + read_neon_element32(tmp, a->vn, 1, MO_32); | ||
218 | widenfn(rn1_64, tmp); | ||
219 | tcg_temp_free_i32(tmp); | ||
220 | } | ||
221 | - rm = neon_load_reg(a->vm, 1); | ||
222 | + rm = tcg_temp_new_i32(); | ||
223 | + read_neon_element32(rm, a->vm, 1, MO_32); | ||
224 | |||
225 | neon_store_reg64(rn0_64, a->vd); | ||
226 | |||
227 | @@ -XXX,XX +XXX,XX @@ static bool do_narrow_3d(DisasContext *s, arg_3diff *a, | ||
228 | |||
229 | narrowfn(rd1, rn_64); | ||
230 | |||
231 | - neon_store_reg(a->vd, 0, rd0); | ||
232 | - neon_store_reg(a->vd, 1, rd1); | ||
233 | + write_neon_element32(rd0, a->vd, 0, MO_32); | ||
234 | + write_neon_element32(rd1, a->vd, 1, MO_32); | ||
235 | |||
236 | + tcg_temp_free_i32(rd0); | ||
237 | + tcg_temp_free_i32(rd1); | ||
238 | tcg_temp_free_i64(rn_64); | ||
239 | tcg_temp_free_i64(rm_64); | ||
240 | |||
241 | @@ -XXX,XX +XXX,XX @@ static bool do_long_3d(DisasContext *s, arg_3diff *a, | ||
242 | rd0 = tcg_temp_new_i64(); | ||
243 | rd1 = tcg_temp_new_i64(); | ||
244 | |||
245 | - rn = neon_load_reg(a->vn, 0); | ||
246 | - rm = neon_load_reg(a->vm, 0); | ||
247 | + rn = tcg_temp_new_i32(); | ||
248 | + rm = tcg_temp_new_i32(); | ||
249 | + read_neon_element32(rn, a->vn, 0, MO_32); | ||
250 | + read_neon_element32(rm, a->vm, 0, MO_32); | ||
251 | opfn(rd0, rn, rm); | ||
252 | - tcg_temp_free_i32(rn); | ||
253 | - tcg_temp_free_i32(rm); | ||
254 | |||
255 | - rn = neon_load_reg(a->vn, 1); | ||
256 | - rm = neon_load_reg(a->vm, 1); | ||
257 | + read_neon_element32(rn, a->vn, 1, MO_32); | ||
258 | + read_neon_element32(rm, a->vm, 1, MO_32); | ||
259 | opfn(rd1, rn, rm); | ||
260 | tcg_temp_free_i32(rn); | ||
261 | tcg_temp_free_i32(rm); | ||
262 | @@ -XXX,XX +XXX,XX @@ static void gen_neon_dup_high16(TCGv_i32 var) | ||
263 | |||
264 | static inline TCGv_i32 neon_get_scalar(int size, int reg) | ||
265 | { | 65 | { |
266 | - TCGv_i32 tmp; | 66 | @@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn, |
267 | - if (size == 1) { | 67 | tcg_el = tcg_constant_i32(3); |
268 | - tmp = neon_load_reg(reg & 7, reg >> 4); | 68 | } |
269 | + TCGv_i32 tmp = tcg_temp_new_i32(); | 69 | |
270 | + if (size == MO_16) { | 70 | - gen_exception_el(s, EXCP_UDEF, syn_uncategorized(), tcg_el); |
271 | + read_neon_element32(tmp, reg & 7, reg >> 4, MO_32); | 71 | + gen_exception_insn_el_v(s, s->pc_curr, EXCP_UDEF, |
272 | if (reg & 8) { | 72 | + syn_uncategorized(), tcg_el); |
273 | gen_neon_dup_high16(tmp); | 73 | tcg_temp_free_i32(tcg_el); |
274 | } else { | 74 | return false; |
275 | gen_neon_dup_low16(tmp); | ||
276 | } | 75 | } |
277 | } else { | ||
278 | - tmp = neon_load_reg(reg & 15, reg >> 4); | ||
279 | + read_neon_element32(tmp, reg & 15, reg >> 4, MO_32); | ||
280 | } | ||
281 | return tmp; | ||
282 | } | ||
283 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar(DisasContext *s, arg_2scalar *a, | ||
284 | * perform an accumulation operation of that result into the | ||
285 | * destination. | ||
286 | */ | ||
287 | - TCGv_i32 scalar; | ||
288 | + TCGv_i32 scalar, tmp; | ||
289 | int pass; | ||
290 | |||
291 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
292 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar(DisasContext *s, arg_2scalar *a, | ||
293 | } | ||
294 | |||
295 | scalar = neon_get_scalar(a->size, a->vm); | ||
296 | + tmp = tcg_temp_new_i32(); | ||
297 | |||
298 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
299 | - TCGv_i32 tmp = neon_load_reg(a->vn, pass); | ||
300 | + read_neon_element32(tmp, a->vn, pass, MO_32); | ||
301 | opfn(tmp, tmp, scalar); | ||
302 | if (accfn) { | ||
303 | - TCGv_i32 rd = neon_load_reg(a->vd, pass); | ||
304 | + TCGv_i32 rd = tcg_temp_new_i32(); | ||
305 | + read_neon_element32(rd, a->vd, pass, MO_32); | ||
306 | accfn(tmp, rd, tmp); | ||
307 | tcg_temp_free_i32(rd); | ||
308 | } | ||
309 | - neon_store_reg(a->vd, pass, tmp); | ||
310 | + write_neon_element32(tmp, a->vd, pass, MO_32); | ||
311 | } | ||
312 | + tcg_temp_free_i32(tmp); | ||
313 | tcg_temp_free_i32(scalar); | ||
314 | return true; | ||
315 | } | ||
316 | @@ -XXX,XX +XXX,XX @@ static bool do_vqrdmlah_2sc(DisasContext *s, arg_2scalar *a, | ||
317 | * performs a kind of fused op-then-accumulate using a helper | ||
318 | * function that takes all of rd, rn and the scalar at once. | ||
319 | */ | ||
320 | - TCGv_i32 scalar; | ||
321 | + TCGv_i32 scalar, rn, rd; | ||
322 | int pass; | ||
323 | |||
324 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
325 | @@ -XXX,XX +XXX,XX @@ static bool do_vqrdmlah_2sc(DisasContext *s, arg_2scalar *a, | ||
326 | } | ||
327 | |||
328 | scalar = neon_get_scalar(a->size, a->vm); | ||
329 | + rn = tcg_temp_new_i32(); | ||
330 | + rd = tcg_temp_new_i32(); | ||
331 | |||
332 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
333 | - TCGv_i32 rn = neon_load_reg(a->vn, pass); | ||
334 | - TCGv_i32 rd = neon_load_reg(a->vd, pass); | ||
335 | + read_neon_element32(rn, a->vn, pass, MO_32); | ||
336 | + read_neon_element32(rd, a->vd, pass, MO_32); | ||
337 | opfn(rd, cpu_env, rn, scalar, rd); | ||
338 | - tcg_temp_free_i32(rn); | ||
339 | - neon_store_reg(a->vd, pass, rd); | ||
340 | + write_neon_element32(rd, a->vd, pass, MO_32); | ||
341 | } | ||
342 | + tcg_temp_free_i32(rn); | ||
343 | + tcg_temp_free_i32(rd); | ||
344 | tcg_temp_free_i32(scalar); | ||
345 | |||
346 | return true; | ||
347 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar_long(DisasContext *s, arg_2scalar *a, | ||
348 | scalar = neon_get_scalar(a->size, a->vm); | ||
349 | |||
350 | /* Load all inputs before writing any outputs, in case of overlap */ | ||
351 | - rn = neon_load_reg(a->vn, 0); | ||
352 | + rn = tcg_temp_new_i32(); | ||
353 | + read_neon_element32(rn, a->vn, 0, MO_32); | ||
354 | rn0_64 = tcg_temp_new_i64(); | ||
355 | opfn(rn0_64, rn, scalar); | ||
356 | - tcg_temp_free_i32(rn); | ||
357 | |||
358 | - rn = neon_load_reg(a->vn, 1); | ||
359 | + read_neon_element32(rn, a->vn, 1, MO_32); | ||
360 | rn1_64 = tcg_temp_new_i64(); | ||
361 | opfn(rn1_64, rn, scalar); | ||
362 | tcg_temp_free_i32(rn); | ||
363 | @@ -XXX,XX +XXX,XX @@ static bool trans_VTBL(DisasContext *s, arg_VTBL *a) | ||
364 | return false; | ||
365 | } | ||
366 | n <<= 3; | ||
367 | + tmp = tcg_temp_new_i32(); | ||
368 | if (a->op) { | ||
369 | - tmp = neon_load_reg(a->vd, 0); | ||
370 | + read_neon_element32(tmp, a->vd, 0, MO_32); | ||
371 | } else { | ||
372 | - tmp = tcg_temp_new_i32(); | ||
373 | tcg_gen_movi_i32(tmp, 0); | ||
374 | } | ||
375 | - tmp2 = neon_load_reg(a->vm, 0); | ||
376 | + tmp2 = tcg_temp_new_i32(); | ||
377 | + read_neon_element32(tmp2, a->vm, 0, MO_32); | ||
378 | ptr1 = vfp_reg_ptr(true, a->vn); | ||
379 | tmp4 = tcg_const_i32(n); | ||
380 | gen_helper_neon_tbl(tmp2, tmp2, tmp, ptr1, tmp4); | ||
381 | - tcg_temp_free_i32(tmp); | ||
382 | + | ||
383 | if (a->op) { | ||
384 | - tmp = neon_load_reg(a->vd, 1); | ||
385 | + read_neon_element32(tmp, a->vd, 1, MO_32); | ||
386 | } else { | ||
387 | - tmp = tcg_temp_new_i32(); | ||
388 | tcg_gen_movi_i32(tmp, 0); | ||
389 | } | ||
390 | - tmp3 = neon_load_reg(a->vm, 1); | ||
391 | + tmp3 = tcg_temp_new_i32(); | ||
392 | + read_neon_element32(tmp3, a->vm, 1, MO_32); | ||
393 | gen_helper_neon_tbl(tmp3, tmp3, tmp, ptr1, tmp4); | ||
394 | + tcg_temp_free_i32(tmp); | ||
395 | tcg_temp_free_i32(tmp4); | ||
396 | tcg_temp_free_ptr(ptr1); | ||
397 | - neon_store_reg(a->vd, 0, tmp2); | ||
398 | - neon_store_reg(a->vd, 1, tmp3); | ||
399 | - tcg_temp_free_i32(tmp); | ||
400 | + | ||
401 | + write_neon_element32(tmp2, a->vd, 0, MO_32); | ||
402 | + write_neon_element32(tmp3, a->vd, 1, MO_32); | ||
403 | + tcg_temp_free_i32(tmp2); | ||
404 | + tcg_temp_free_i32(tmp3); | ||
405 | return true; | ||
406 | } | ||
407 | |||
408 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDUP_scalar(DisasContext *s, arg_VDUP_scalar *a) | ||
409 | static bool trans_VREV64(DisasContext *s, arg_VREV64 *a) | ||
410 | { | ||
411 | int pass, half; | ||
412 | + TCGv_i32 tmp[2]; | ||
413 | |||
414 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
415 | return false; | ||
416 | @@ -XXX,XX +XXX,XX @@ static bool trans_VREV64(DisasContext *s, arg_VREV64 *a) | ||
417 | return true; | ||
418 | } | ||
419 | |||
420 | - for (pass = 0; pass < (a->q ? 2 : 1); pass++) { | ||
421 | - TCGv_i32 tmp[2]; | ||
422 | + tmp[0] = tcg_temp_new_i32(); | ||
423 | + tmp[1] = tcg_temp_new_i32(); | ||
424 | |||
425 | + for (pass = 0; pass < (a->q ? 2 : 1); pass++) { | ||
426 | for (half = 0; half < 2; half++) { | ||
427 | - tmp[half] = neon_load_reg(a->vm, pass * 2 + half); | ||
428 | + read_neon_element32(tmp[half], a->vm, pass * 2 + half, MO_32); | ||
429 | switch (a->size) { | ||
430 | case 0: | ||
431 | tcg_gen_bswap32_i32(tmp[half], tmp[half]); | ||
432 | @@ -XXX,XX +XXX,XX @@ static bool trans_VREV64(DisasContext *s, arg_VREV64 *a) | ||
433 | g_assert_not_reached(); | ||
434 | } | ||
435 | } | ||
436 | - neon_store_reg(a->vd, pass * 2, tmp[1]); | ||
437 | - neon_store_reg(a->vd, pass * 2 + 1, tmp[0]); | ||
438 | + write_neon_element32(tmp[1], a->vd, pass * 2, MO_32); | ||
439 | + write_neon_element32(tmp[0], a->vd, pass * 2 + 1, MO_32); | ||
440 | } | ||
441 | + | ||
442 | + tcg_temp_free_i32(tmp[0]); | ||
443 | + tcg_temp_free_i32(tmp[1]); | ||
444 | return true; | ||
445 | } | ||
446 | |||
447 | @@ -XXX,XX +XXX,XX @@ static bool do_2misc_pairwise(DisasContext *s, arg_2misc *a, | ||
448 | rm0_64 = tcg_temp_new_i64(); | ||
449 | rm1_64 = tcg_temp_new_i64(); | ||
450 | rd_64 = tcg_temp_new_i64(); | ||
451 | - tmp = neon_load_reg(a->vm, pass * 2); | ||
452 | + | ||
453 | + tmp = tcg_temp_new_i32(); | ||
454 | + read_neon_element32(tmp, a->vm, pass * 2, MO_32); | ||
455 | widenfn(rm0_64, tmp); | ||
456 | - tcg_temp_free_i32(tmp); | ||
457 | - tmp = neon_load_reg(a->vm, pass * 2 + 1); | ||
458 | + read_neon_element32(tmp, a->vm, pass * 2 + 1, MO_32); | ||
459 | widenfn(rm1_64, tmp); | ||
460 | tcg_temp_free_i32(tmp); | ||
461 | + | ||
462 | opfn(rd_64, rm0_64, rm1_64); | ||
463 | tcg_temp_free_i64(rm0_64); | ||
464 | tcg_temp_free_i64(rm1_64); | ||
465 | @@ -XXX,XX +XXX,XX @@ static bool do_vmovn(DisasContext *s, arg_2misc *a, | ||
466 | narrowfn(rd0, cpu_env, rm); | ||
467 | neon_load_reg64(rm, a->vm + 1); | ||
468 | narrowfn(rd1, cpu_env, rm); | ||
469 | - neon_store_reg(a->vd, 0, rd0); | ||
470 | - neon_store_reg(a->vd, 1, rd1); | ||
471 | + write_neon_element32(rd0, a->vd, 0, MO_32); | ||
472 | + write_neon_element32(rd1, a->vd, 1, MO_32); | ||
473 | + tcg_temp_free_i32(rd0); | ||
474 | + tcg_temp_free_i32(rd1); | ||
475 | tcg_temp_free_i64(rm); | ||
476 | return true; | ||
477 | } | ||
478 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL(DisasContext *s, arg_2misc *a) | ||
479 | } | ||
480 | |||
481 | rd = tcg_temp_new_i64(); | ||
482 | + rm0 = tcg_temp_new_i32(); | ||
483 | + rm1 = tcg_temp_new_i32(); | ||
484 | |||
485 | - rm0 = neon_load_reg(a->vm, 0); | ||
486 | - rm1 = neon_load_reg(a->vm, 1); | ||
487 | + read_neon_element32(rm0, a->vm, 0, MO_32); | ||
488 | + read_neon_element32(rm1, a->vm, 1, MO_32); | ||
489 | |||
490 | widenfn(rd, rm0); | ||
491 | tcg_gen_shli_i64(rd, rd, 8 << a->size); | ||
492 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_F16_F32(DisasContext *s, arg_2misc *a) | ||
493 | |||
494 | fpst = fpstatus_ptr(FPST_STD); | ||
495 | ahp = get_ahp_flag(); | ||
496 | - tmp = neon_load_reg(a->vm, 0); | ||
497 | + tmp = tcg_temp_new_i32(); | ||
498 | + read_neon_element32(tmp, a->vm, 0, MO_32); | ||
499 | gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp); | ||
500 | - tmp2 = neon_load_reg(a->vm, 1); | ||
501 | + tmp2 = tcg_temp_new_i32(); | ||
502 | + read_neon_element32(tmp2, a->vm, 1, MO_32); | ||
503 | gen_helper_vfp_fcvt_f32_to_f16(tmp2, tmp2, fpst, ahp); | ||
504 | tcg_gen_shli_i32(tmp2, tmp2, 16); | ||
505 | tcg_gen_or_i32(tmp2, tmp2, tmp); | ||
506 | - tcg_temp_free_i32(tmp); | ||
507 | - tmp = neon_load_reg(a->vm, 2); | ||
508 | + read_neon_element32(tmp, a->vm, 2, MO_32); | ||
509 | gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp); | ||
510 | - tmp3 = neon_load_reg(a->vm, 3); | ||
511 | - neon_store_reg(a->vd, 0, tmp2); | ||
512 | + tmp3 = tcg_temp_new_i32(); | ||
513 | + read_neon_element32(tmp3, a->vm, 3, MO_32); | ||
514 | + write_neon_element32(tmp2, a->vd, 0, MO_32); | ||
515 | + tcg_temp_free_i32(tmp2); | ||
516 | gen_helper_vfp_fcvt_f32_to_f16(tmp3, tmp3, fpst, ahp); | ||
517 | tcg_gen_shli_i32(tmp3, tmp3, 16); | ||
518 | tcg_gen_or_i32(tmp3, tmp3, tmp); | ||
519 | - neon_store_reg(a->vd, 1, tmp3); | ||
520 | + write_neon_element32(tmp3, a->vd, 1, MO_32); | ||
521 | + tcg_temp_free_i32(tmp3); | ||
522 | tcg_temp_free_i32(tmp); | ||
523 | tcg_temp_free_i32(ahp); | ||
524 | tcg_temp_free_ptr(fpst); | ||
525 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_F32_F16(DisasContext *s, arg_2misc *a) | ||
526 | fpst = fpstatus_ptr(FPST_STD); | ||
527 | ahp = get_ahp_flag(); | ||
528 | tmp3 = tcg_temp_new_i32(); | ||
529 | - tmp = neon_load_reg(a->vm, 0); | ||
530 | - tmp2 = neon_load_reg(a->vm, 1); | ||
531 | + tmp2 = tcg_temp_new_i32(); | ||
532 | + tmp = tcg_temp_new_i32(); | ||
533 | + read_neon_element32(tmp, a->vm, 0, MO_32); | ||
534 | + read_neon_element32(tmp2, a->vm, 1, MO_32); | ||
535 | tcg_gen_ext16u_i32(tmp3, tmp); | ||
536 | gen_helper_vfp_fcvt_f16_to_f32(tmp3, tmp3, fpst, ahp); | ||
537 | - neon_store_reg(a->vd, 0, tmp3); | ||
538 | + write_neon_element32(tmp3, a->vd, 0, MO_32); | ||
539 | tcg_gen_shri_i32(tmp, tmp, 16); | ||
540 | gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp); | ||
541 | - neon_store_reg(a->vd, 1, tmp); | ||
542 | - tmp3 = tcg_temp_new_i32(); | ||
543 | + write_neon_element32(tmp, a->vd, 1, MO_32); | ||
544 | + tcg_temp_free_i32(tmp); | ||
545 | tcg_gen_ext16u_i32(tmp3, tmp2); | ||
546 | gen_helper_vfp_fcvt_f16_to_f32(tmp3, tmp3, fpst, ahp); | ||
547 | - neon_store_reg(a->vd, 2, tmp3); | ||
548 | + write_neon_element32(tmp3, a->vd, 2, MO_32); | ||
549 | + tcg_temp_free_i32(tmp3); | ||
550 | tcg_gen_shri_i32(tmp2, tmp2, 16); | ||
551 | gen_helper_vfp_fcvt_f16_to_f32(tmp2, tmp2, fpst, ahp); | ||
552 | - neon_store_reg(a->vd, 3, tmp2); | ||
553 | + write_neon_element32(tmp2, a->vd, 3, MO_32); | ||
554 | + tcg_temp_free_i32(tmp2); | ||
555 | tcg_temp_free_i32(ahp); | ||
556 | tcg_temp_free_ptr(fpst); | ||
557 | |||
558 | @@ -XXX,XX +XXX,XX @@ DO_2M_CRYPTO(SHA256SU0, aa32_sha2, 2) | ||
559 | |||
560 | static bool do_2misc(DisasContext *s, arg_2misc *a, NeonGenOneOpFn *fn) | ||
561 | { | ||
562 | + TCGv_i32 tmp; | ||
563 | int pass; | ||
564 | |||
565 | /* Handle a 2-reg-misc operation by iterating 32 bits at a time */ | ||
566 | @@ -XXX,XX +XXX,XX @@ static bool do_2misc(DisasContext *s, arg_2misc *a, NeonGenOneOpFn *fn) | ||
567 | return true; | ||
568 | } | ||
569 | |||
570 | + tmp = tcg_temp_new_i32(); | ||
571 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
572 | - TCGv_i32 tmp = neon_load_reg(a->vm, pass); | ||
573 | + read_neon_element32(tmp, a->vm, pass, MO_32); | ||
574 | fn(tmp, tmp); | ||
575 | - neon_store_reg(a->vd, pass, tmp); | ||
576 | + write_neon_element32(tmp, a->vd, pass, MO_32); | ||
577 | } | ||
578 | + tcg_temp_free_i32(tmp); | ||
579 | |||
580 | return true; | ||
581 | } | ||
582 | @@ -XXX,XX +XXX,XX @@ static bool trans_VTRN(DisasContext *s, arg_2misc *a) | ||
583 | return true; | ||
584 | } | ||
585 | |||
586 | - if (a->size == 2) { | ||
587 | + tmp = tcg_temp_new_i32(); | ||
588 | + tmp2 = tcg_temp_new_i32(); | ||
589 | + if (a->size == MO_32) { | ||
590 | for (pass = 0; pass < (a->q ? 4 : 2); pass += 2) { | ||
591 | - tmp = neon_load_reg(a->vm, pass); | ||
592 | - tmp2 = neon_load_reg(a->vd, pass + 1); | ||
593 | - neon_store_reg(a->vm, pass, tmp2); | ||
594 | - neon_store_reg(a->vd, pass + 1, tmp); | ||
595 | + read_neon_element32(tmp, a->vm, pass, MO_32); | ||
596 | + read_neon_element32(tmp2, a->vd, pass + 1, MO_32); | ||
597 | + write_neon_element32(tmp2, a->vm, pass, MO_32); | ||
598 | + write_neon_element32(tmp, a->vd, pass + 1, MO_32); | ||
599 | } | ||
600 | } else { | ||
601 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
602 | - tmp = neon_load_reg(a->vm, pass); | ||
603 | - tmp2 = neon_load_reg(a->vd, pass); | ||
604 | - if (a->size == 0) { | ||
605 | + read_neon_element32(tmp, a->vm, pass, MO_32); | ||
606 | + read_neon_element32(tmp2, a->vd, pass, MO_32); | ||
607 | + if (a->size == MO_8) { | ||
608 | gen_neon_trn_u8(tmp, tmp2); | ||
609 | } else { | ||
610 | gen_neon_trn_u16(tmp, tmp2); | ||
611 | } | ||
612 | - neon_store_reg(a->vm, pass, tmp2); | ||
613 | - neon_store_reg(a->vd, pass, tmp); | ||
614 | + write_neon_element32(tmp2, a->vm, pass, MO_32); | ||
615 | + write_neon_element32(tmp, a->vd, pass, MO_32); | ||
616 | } | ||
617 | } | ||
618 | + tcg_temp_free_i32(tmp); | ||
619 | + tcg_temp_free_i32(tmp2); | ||
620 | return true; | ||
621 | } | ||
622 | -- | 76 | -- |
623 | 2.20.1 | 77 | 2.25.1 |
624 | |||
625 | diff view generated by jsdifflib |
1 | From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When booting a CPU with EL3 using the -kernel flag, set up CPTR_EL3 so | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | that SVE will not trap to EL3. | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | 5 | Message-id: 20220609202901.1177572-12-richard.henderson@linaro.org | |
6 | Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20201030151541.11976-1-remi@remlab.net | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 7 | --- |
11 | hw/arm/boot.c | 3 +++ | 8 | target/arm/translate.h | 4 ++-- |
12 | 1 file changed, 3 insertions(+) | 9 | target/arm/translate-a64.c | 36 ++++++++++++++++---------------- |
10 | target/arm/translate-m-nocp.c | 16 +++++++------- | ||
11 | target/arm/translate-mve.c | 4 ++-- | ||
12 | target/arm/translate-vfp.c | 6 +++--- | ||
13 | target/arm/translate.c | 39 ++++++++++++++++++----------------- | ||
14 | 6 files changed, 53 insertions(+), 52 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 16 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/boot.c | 18 | --- a/target/arm/translate.h |
17 | +++ b/hw/arm/boot.c | 19 | +++ b/target/arm/translate.h |
18 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 20 | @@ -XXX,XX +XXX,XX @@ void arm_jump_cc(DisasCompare *cmp, TCGLabel *label); |
19 | if (cpu_isar_feature(aa64_mte, cpu)) { | 21 | void arm_gen_test_cc(int cc, TCGLabel *label); |
20 | env->cp15.scr_el3 |= SCR_ATA; | 22 | MemOp pow2_align(unsigned i); |
21 | } | 23 | void unallocated_encoding(DisasContext *s); |
22 | + if (cpu_isar_feature(aa64_sve, cpu)) { | 24 | -void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, |
23 | + env->cp15.cptr_el[3] |= CPTR_EZ; | 25 | - uint32_t syn, uint32_t target_el); |
24 | + } | 26 | +void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp, |
25 | /* AArch64 kernels never boot in secure mode */ | 27 | + uint32_t syn, uint32_t target_el); |
26 | assert(!info->secure_boot); | 28 | |
27 | /* This hook is only supported for AArch32 currently: | 29 | /* Return state of Alternate Half-precision flag, caller frees result */ |
30 | static inline TCGv_i32 get_ahp_flag(void) | ||
31 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/translate-a64.c | ||
34 | +++ b/target/arm/translate-a64.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static bool fp_access_check(DisasContext *s) | ||
36 | assert(!s->fp_access_checked); | ||
37 | s->fp_access_checked = true; | ||
38 | |||
39 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
40 | - syn_fp_access_trap(1, 0xe, false, 0), | ||
41 | - s->fp_excp_el); | ||
42 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
43 | + syn_fp_access_trap(1, 0xe, false, 0), | ||
44 | + s->fp_excp_el); | ||
45 | return false; | ||
46 | } | ||
47 | s->fp_access_checked = true; | ||
48 | @@ -XXX,XX +XXX,XX @@ bool sve_access_check(DisasContext *s) | ||
49 | assert(!s->sve_access_checked); | ||
50 | s->sve_access_checked = true; | ||
51 | |||
52 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
53 | - syn_sve_access_trap(), s->sve_excp_el); | ||
54 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
55 | + syn_sve_access_trap(), s->sve_excp_el); | ||
56 | return false; | ||
57 | } | ||
58 | s->sve_access_checked = true; | ||
59 | @@ -XXX,XX +XXX,XX @@ static void gen_sysreg_undef(DisasContext *s, bool isread, | ||
60 | } else { | ||
61 | syndrome = syn_uncategorized(); | ||
62 | } | ||
63 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syndrome, | ||
64 | - default_exception_el(s)); | ||
65 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syndrome, | ||
66 | + default_exception_el(s)); | ||
67 | } | ||
68 | |||
69 | /* MRS - move from system register | ||
70 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
71 | switch (op2_ll) { | ||
72 | case 1: /* SVC */ | ||
73 | gen_ss_advance(s); | ||
74 | - gen_exception_insn(s, s->base.pc_next, EXCP_SWI, | ||
75 | - syn_aa64_svc(imm16), default_exception_el(s)); | ||
76 | + gen_exception_insn_el(s, s->base.pc_next, EXCP_SWI, | ||
77 | + syn_aa64_svc(imm16), default_exception_el(s)); | ||
78 | break; | ||
79 | case 2: /* HVC */ | ||
80 | if (s->current_el == 0) { | ||
81 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
82 | gen_a64_set_pc_im(s->pc_curr); | ||
83 | gen_helper_pre_hvc(cpu_env); | ||
84 | gen_ss_advance(s); | ||
85 | - gen_exception_insn(s, s->base.pc_next, EXCP_HVC, | ||
86 | - syn_aa64_hvc(imm16), 2); | ||
87 | + gen_exception_insn_el(s, s->base.pc_next, EXCP_HVC, | ||
88 | + syn_aa64_hvc(imm16), 2); | ||
89 | break; | ||
90 | case 3: /* SMC */ | ||
91 | if (s->current_el == 0) { | ||
92 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
93 | gen_a64_set_pc_im(s->pc_curr); | ||
94 | gen_helper_pre_smc(cpu_env, tcg_constant_i32(syn_aa64_smc(imm16))); | ||
95 | gen_ss_advance(s); | ||
96 | - gen_exception_insn(s, s->base.pc_next, EXCP_SMC, | ||
97 | - syn_aa64_smc(imm16), 3); | ||
98 | + gen_exception_insn_el(s, s->base.pc_next, EXCP_SMC, | ||
99 | + syn_aa64_smc(imm16), 3); | ||
100 | break; | ||
101 | default: | ||
102 | unallocated_encoding(s); | ||
103 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
104 | * Illegal execution state. This has priority over BTI | ||
105 | * exceptions, but comes after instruction abort exceptions. | ||
106 | */ | ||
107 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
108 | - syn_illegalstate(), default_exception_el(s)); | ||
109 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
110 | + syn_illegalstate(), default_exception_el(s)); | ||
111 | return; | ||
112 | } | ||
113 | |||
114 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
115 | if (s->btype != 0 | ||
116 | && s->guarded_page | ||
117 | && !btype_destination_ok(insn, s->bt, s->btype)) { | ||
118 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
119 | - syn_btitrap(s->btype), | ||
120 | - default_exception_el(s)); | ||
121 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
122 | + syn_btitrap(s->btype), | ||
123 | + default_exception_el(s)); | ||
124 | return; | ||
125 | } | ||
126 | } else { | ||
127 | diff --git a/target/arm/translate-m-nocp.c b/target/arm/translate-m-nocp.c | ||
128 | index XXXXXXX..XXXXXXX 100644 | ||
129 | --- a/target/arm/translate-m-nocp.c | ||
130 | +++ b/target/arm/translate-m-nocp.c | ||
131 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a) | ||
132 | tcg_gen_brcondi_i32(TCG_COND_EQ, sfpa, 0, s->condlabel); | ||
133 | |||
134 | if (s->fp_excp_el != 0) { | ||
135 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
136 | - syn_uncategorized(), s->fp_excp_el); | ||
137 | + gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP, | ||
138 | + syn_uncategorized(), s->fp_excp_el); | ||
139 | return true; | ||
140 | } | ||
141 | |||
142 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
143 | if (!vfp_access_check_m(s, true)) { | ||
144 | /* | ||
145 | * This was only a conditional exception, so override | ||
146 | - * gen_exception_insn()'s default to DISAS_NORETURN | ||
147 | + * gen_exception_insn_el()'s default to DISAS_NORETURN | ||
148 | */ | ||
149 | s->base.is_jmp = DISAS_NEXT; | ||
150 | break; | ||
151 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
152 | if (!vfp_access_check_m(s, true)) { | ||
153 | /* | ||
154 | * This was only a conditional exception, so override | ||
155 | - * gen_exception_insn()'s default to DISAS_NORETURN | ||
156 | + * gen_exception_insn_el()'s default to DISAS_NORETURN | ||
157 | */ | ||
158 | s->base.is_jmp = DISAS_NEXT; | ||
159 | break; | ||
160 | @@ -XXX,XX +XXX,XX @@ static bool trans_NOCP(DisasContext *s, arg_nocp *a) | ||
161 | } | ||
162 | |||
163 | if (a->cp != 10) { | ||
164 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
165 | - syn_uncategorized(), default_exception_el(s)); | ||
166 | + gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP, | ||
167 | + syn_uncategorized(), default_exception_el(s)); | ||
168 | return true; | ||
169 | } | ||
170 | |||
171 | if (s->fp_excp_el != 0) { | ||
172 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
173 | - syn_uncategorized(), s->fp_excp_el); | ||
174 | + gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP, | ||
175 | + syn_uncategorized(), s->fp_excp_el); | ||
176 | return true; | ||
177 | } | ||
178 | |||
179 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
180 | index XXXXXXX..XXXXXXX 100644 | ||
181 | --- a/target/arm/translate-mve.c | ||
182 | +++ b/target/arm/translate-mve.c | ||
183 | @@ -XXX,XX +XXX,XX @@ bool mve_eci_check(DisasContext *s) | ||
184 | return true; | ||
185 | default: | ||
186 | /* Reserved value: INVSTATE UsageFault */ | ||
187 | - gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
188 | - default_exception_el(s)); | ||
189 | + gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
190 | + default_exception_el(s)); | ||
191 | return false; | ||
192 | } | ||
193 | } | ||
194 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | ||
195 | index XXXXXXX..XXXXXXX 100644 | ||
196 | --- a/target/arm/translate-vfp.c | ||
197 | +++ b/target/arm/translate-vfp.c | ||
198 | @@ -XXX,XX +XXX,XX @@ static bool vfp_access_check_a(DisasContext *s, bool ignore_vfp_enabled) | ||
199 | int coproc = arm_dc_feature(s, ARM_FEATURE_V8) ? 0 : 0xa; | ||
200 | uint32_t syn = syn_fp_access_trap(1, 0xe, false, coproc); | ||
201 | |||
202 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn, s->fp_excp_el); | ||
203 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syn, s->fp_excp_el); | ||
204 | return false; | ||
205 | } | ||
206 | |||
207 | @@ -XXX,XX +XXX,XX @@ bool vfp_access_check_m(DisasContext *s, bool skip_context_update) | ||
208 | * the encoding space handled by the patterns in m-nocp.decode, | ||
209 | * and for them we may need to raise NOCP here. | ||
210 | */ | ||
211 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
212 | - syn_uncategorized(), s->fp_excp_el); | ||
213 | + gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP, | ||
214 | + syn_uncategorized(), s->fp_excp_el); | ||
215 | return false; | ||
216 | } | ||
217 | |||
218 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
219 | index XXXXXXX..XXXXXXX 100644 | ||
220 | --- a/target/arm/translate.c | ||
221 | +++ b/target/arm/translate.c | ||
222 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp, | ||
223 | s->base.is_jmp = DISAS_NORETURN; | ||
224 | } | ||
225 | |||
226 | -void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, | ||
227 | - uint32_t syn, uint32_t target_el) | ||
228 | +void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp, | ||
229 | + uint32_t syn, uint32_t target_el) | ||
230 | { | ||
231 | gen_exception_insn_el_v(s, pc, excp, syn, tcg_constant_i32(target_el)); | ||
232 | } | ||
233 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) | ||
234 | void unallocated_encoding(DisasContext *s) | ||
235 | { | ||
236 | /* Unallocated and reserved encodings are uncategorized */ | ||
237 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
238 | - default_exception_el(s)); | ||
239 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
240 | + default_exception_el(s)); | ||
241 | } | ||
242 | |||
243 | /* Force a TB lookup after an instruction that changes the CPU state. */ | ||
244 | @@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn, | ||
245 | |||
246 | undef: | ||
247 | /* If we get here then some access check did not pass */ | ||
248 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
249 | - syn_uncategorized(), exc_target); | ||
250 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
251 | + syn_uncategorized(), exc_target); | ||
252 | return false; | ||
253 | } | ||
254 | |||
255 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
256 | * For the UNPREDICTABLE cases we choose to UNDEF. | ||
257 | */ | ||
258 | if (s->current_el == 1 && !s->ns && mode == ARM_CPU_MODE_MON) { | ||
259 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), 3); | ||
260 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
261 | + syn_uncategorized(), 3); | ||
262 | return; | ||
263 | } | ||
264 | |||
265 | @@ -XXX,XX +XXX,XX @@ static bool trans_WLS(DisasContext *s, arg_WLS *a) | ||
266 | * Do the check-and-raise-exception by hand. | ||
267 | */ | ||
268 | if (s->fp_excp_el) { | ||
269 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
270 | - syn_uncategorized(), s->fp_excp_el); | ||
271 | + gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP, | ||
272 | + syn_uncategorized(), s->fp_excp_el); | ||
273 | return true; | ||
274 | } | ||
275 | } | ||
276 | @@ -XXX,XX +XXX,XX @@ static bool trans_LE(DisasContext *s, arg_LE *a) | ||
277 | tmp = load_cpu_field(v7m.ltpsize); | ||
278 | tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 4, skipexc); | ||
279 | tcg_temp_free_i32(tmp); | ||
280 | - gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
281 | - default_exception_el(s)); | ||
282 | + gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
283 | + default_exception_el(s)); | ||
284 | gen_set_label(skipexc); | ||
285 | } | ||
286 | |||
287 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
288 | * UsageFault exception. | ||
289 | */ | ||
290 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
291 | - gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
292 | - default_exception_el(s)); | ||
293 | + gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
294 | + default_exception_el(s)); | ||
295 | return; | ||
296 | } | ||
297 | |||
298 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
299 | * Illegal execution state. This has priority over BTI | ||
300 | * exceptions, but comes after instruction abort exceptions. | ||
301 | */ | ||
302 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
303 | - syn_illegalstate(), default_exception_el(s)); | ||
304 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
305 | + syn_illegalstate(), default_exception_el(s)); | ||
306 | return; | ||
307 | } | ||
308 | |||
309 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
310 | * Illegal execution state. This has priority over BTI | ||
311 | * exceptions, but comes after instruction abort exceptions. | ||
312 | */ | ||
313 | - gen_exception_insn(dc, dc->pc_curr, EXCP_UDEF, | ||
314 | - syn_illegalstate(), default_exception_el(dc)); | ||
315 | + gen_exception_insn_el(dc, dc->pc_curr, EXCP_UDEF, | ||
316 | + syn_illegalstate(), default_exception_el(dc)); | ||
317 | return; | ||
318 | } | ||
319 | |||
320 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
321 | */ | ||
322 | tcg_remove_ops_after(dc->insn_eci_rewind); | ||
323 | dc->condjmp = 0; | ||
324 | - gen_exception_insn(dc, dc->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
325 | - default_exception_el(dc)); | ||
326 | + gen_exception_insn_el(dc, dc->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
327 | + default_exception_el(dc)); | ||
328 | } | ||
329 | |||
330 | arm_post_translate_insn(dc); | ||
28 | -- | 331 | -- |
29 | 2.20.1 | 332 | 2.25.1 |
30 | |||
31 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This will shortly have users outside of translate-neon.c.inc. | 3 | Create a new wrapper function that passes the default |
4 | exception target to gen_exception_insn_el. | ||
4 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20201030022618.785675-3-richard.henderson@linaro.org | 8 | Message-id: 20220609202901.1177572-13-richard.henderson@linaro.org |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | target/arm/translate.c | 20 ++++++++++++++++++++ | 11 | target/arm/translate.h | 1 + |
11 | target/arm/translate-neon.c.inc | 19 ------------------- | 12 | target/arm/translate-a64.c | 15 ++++++--------- |
12 | 2 files changed, 20 insertions(+), 19 deletions(-) | 13 | target/arm/translate-m-nocp.c | 3 +-- |
14 | target/arm/translate-mve.c | 3 +-- | ||
15 | target/arm/translate.c | 29 +++++++++++++---------------- | ||
16 | 5 files changed, 22 insertions(+), 29 deletions(-) | ||
13 | 17 | ||
18 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/translate.h | ||
21 | +++ b/target/arm/translate.h | ||
22 | @@ -XXX,XX +XXX,XX @@ MemOp pow2_align(unsigned i); | ||
23 | void unallocated_encoding(DisasContext *s); | ||
24 | void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp, | ||
25 | uint32_t syn, uint32_t target_el); | ||
26 | +void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, uint32_t syn); | ||
27 | |||
28 | /* Return state of Alternate Half-precision flag, caller frees result */ | ||
29 | static inline TCGv_i32 get_ahp_flag(void) | ||
30 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/translate-a64.c | ||
33 | +++ b/target/arm/translate-a64.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static void gen_sysreg_undef(DisasContext *s, bool isread, | ||
35 | } else { | ||
36 | syndrome = syn_uncategorized(); | ||
37 | } | ||
38 | - gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syndrome, | ||
39 | - default_exception_el(s)); | ||
40 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syndrome); | ||
41 | } | ||
42 | |||
43 | /* MRS - move from system register | ||
44 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
45 | switch (op2_ll) { | ||
46 | case 1: /* SVC */ | ||
47 | gen_ss_advance(s); | ||
48 | - gen_exception_insn_el(s, s->base.pc_next, EXCP_SWI, | ||
49 | - syn_aa64_svc(imm16), default_exception_el(s)); | ||
50 | + gen_exception_insn(s, s->base.pc_next, EXCP_SWI, | ||
51 | + syn_aa64_svc(imm16)); | ||
52 | break; | ||
53 | case 2: /* HVC */ | ||
54 | if (s->current_el == 0) { | ||
55 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
56 | * Illegal execution state. This has priority over BTI | ||
57 | * exceptions, but comes after instruction abort exceptions. | ||
58 | */ | ||
59 | - gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
60 | - syn_illegalstate(), default_exception_el(s)); | ||
61 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_illegalstate()); | ||
62 | return; | ||
63 | } | ||
64 | |||
65 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
66 | if (s->btype != 0 | ||
67 | && s->guarded_page | ||
68 | && !btype_destination_ok(insn, s->bt, s->btype)) { | ||
69 | - gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
70 | - syn_btitrap(s->btype), | ||
71 | - default_exception_el(s)); | ||
72 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
73 | + syn_btitrap(s->btype)); | ||
74 | return; | ||
75 | } | ||
76 | } else { | ||
77 | diff --git a/target/arm/translate-m-nocp.c b/target/arm/translate-m-nocp.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/target/arm/translate-m-nocp.c | ||
80 | +++ b/target/arm/translate-m-nocp.c | ||
81 | @@ -XXX,XX +XXX,XX @@ static bool trans_NOCP(DisasContext *s, arg_nocp *a) | ||
82 | } | ||
83 | |||
84 | if (a->cp != 10) { | ||
85 | - gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP, | ||
86 | - syn_uncategorized(), default_exception_el(s)); | ||
87 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, syn_uncategorized()); | ||
88 | return true; | ||
89 | } | ||
90 | |||
91 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/target/arm/translate-mve.c | ||
94 | +++ b/target/arm/translate-mve.c | ||
95 | @@ -XXX,XX +XXX,XX @@ bool mve_eci_check(DisasContext *s) | ||
96 | return true; | ||
97 | default: | ||
98 | /* Reserved value: INVSTATE UsageFault */ | ||
99 | - gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
100 | - default_exception_el(s)); | ||
101 | + gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized()); | ||
102 | return false; | ||
103 | } | ||
104 | } | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 105 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
15 | index XXXXXXX..XXXXXXX 100644 | 106 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 107 | --- a/target/arm/translate.c |
17 | +++ b/target/arm/translate.c | 108 | +++ b/target/arm/translate.c |
18 | @@ -XXX,XX +XXX,XX @@ static long neon_full_reg_offset(unsigned reg) | 109 | @@ -XXX,XX +XXX,XX @@ void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp, |
19 | return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); | 110 | gen_exception_insn_el_v(s, pc, excp, syn, tcg_constant_i32(target_el)); |
20 | } | 111 | } |
21 | 112 | ||
22 | +/* | 113 | +void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, uint32_t syn) |
23 | + * Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | ||
24 | + * where 0 is the least significant end of the register. | ||
25 | + */ | ||
26 | +static long neon_element_offset(int reg, int element, MemOp size) | ||
27 | +{ | 114 | +{ |
28 | + int element_size = 1 << size; | 115 | + gen_exception_insn_el(s, pc, excp, syn, default_exception_el(s)); |
29 | + int ofs = element * element_size; | ||
30 | +#ifdef HOST_WORDS_BIGENDIAN | ||
31 | + /* | ||
32 | + * Calculate the offset assuming fully little-endian, | ||
33 | + * then XOR to account for the order of the 8-byte units. | ||
34 | + */ | ||
35 | + if (element_size < 8) { | ||
36 | + ofs ^= 8 - element_size; | ||
37 | + } | ||
38 | +#endif | ||
39 | + return neon_full_reg_offset(reg) + ofs; | ||
40 | +} | 116 | +} |
41 | + | 117 | + |
42 | static inline long vfp_reg_offset(bool dp, unsigned reg) | 118 | static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) |
43 | { | 119 | { |
44 | if (dp) { | 120 | gen_set_condexec(s); |
45 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 121 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) |
46 | index XXXXXXX..XXXXXXX 100644 | 122 | void unallocated_encoding(DisasContext *s) |
47 | --- a/target/arm/translate-neon.c.inc | 123 | { |
48 | +++ b/target/arm/translate-neon.c.inc | 124 | /* Unallocated and reserved encodings are uncategorized */ |
49 | @@ -XXX,XX +XXX,XX @@ static inline int neon_3same_fp_size(DisasContext *s, int x) | 125 | - gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), |
50 | #include "decode-neon-ls.c.inc" | 126 | - default_exception_el(s)); |
51 | #include "decode-neon-shared.c.inc" | 127 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized()); |
52 | 128 | } | |
53 | -/* Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | 129 | |
54 | - * where 0 is the least significant end of the register. | 130 | /* Force a TB lookup after an instruction that changes the CPU state. */ |
55 | - */ | 131 | @@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn, |
56 | -static inline long | 132 | * an exception and return false. Otherwise it will return true, |
57 | -neon_element_offset(int reg, int element, MemOp size) | 133 | * and set *tgtmode and *regno appropriately. |
58 | -{ | 134 | */ |
59 | - int element_size = 1 << size; | 135 | - int exc_target = default_exception_el(s); |
60 | - int ofs = element * element_size; | ||
61 | -#ifdef HOST_WORDS_BIGENDIAN | ||
62 | - /* Calculate the offset assuming fully little-endian, | ||
63 | - * then XOR to account for the order of the 8-byte units. | ||
64 | - */ | ||
65 | - if (element_size < 8) { | ||
66 | - ofs ^= 8 - element_size; | ||
67 | - } | ||
68 | -#endif | ||
69 | - return neon_full_reg_offset(reg) + ofs; | ||
70 | -} | ||
71 | - | 136 | - |
72 | static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop) | 137 | /* These instructions are present only in ARMv8, or in ARMv7 with the |
73 | { | 138 | * Virtualization Extensions. |
74 | long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | 139 | */ |
140 | @@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn, | ||
141 | |||
142 | undef: | ||
143 | /* If we get here then some access check did not pass */ | ||
144 | - gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
145 | - syn_uncategorized(), exc_target); | ||
146 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized()); | ||
147 | return false; | ||
148 | } | ||
149 | |||
150 | @@ -XXX,XX +XXX,XX @@ static bool trans_LE(DisasContext *s, arg_LE *a) | ||
151 | tmp = load_cpu_field(v7m.ltpsize); | ||
152 | tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 4, skipexc); | ||
153 | tcg_temp_free_i32(tmp); | ||
154 | - gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
155 | - default_exception_el(s)); | ||
156 | + gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized()); | ||
157 | gen_set_label(skipexc); | ||
158 | } | ||
159 | |||
160 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
161 | * UsageFault exception. | ||
162 | */ | ||
163 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
164 | - gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
165 | - default_exception_el(s)); | ||
166 | + gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized()); | ||
167 | return; | ||
168 | } | ||
169 | |||
170 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
171 | * Illegal execution state. This has priority over BTI | ||
172 | * exceptions, but comes after instruction abort exceptions. | ||
173 | */ | ||
174 | - gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
175 | - syn_illegalstate(), default_exception_el(s)); | ||
176 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_illegalstate()); | ||
177 | return; | ||
178 | } | ||
179 | |||
180 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
181 | * Illegal execution state. This has priority over BTI | ||
182 | * exceptions, but comes after instruction abort exceptions. | ||
183 | */ | ||
184 | - gen_exception_insn_el(dc, dc->pc_curr, EXCP_UDEF, | ||
185 | - syn_illegalstate(), default_exception_el(dc)); | ||
186 | + gen_exception_insn(dc, dc->pc_curr, EXCP_UDEF, syn_illegalstate()); | ||
187 | return; | ||
188 | } | ||
189 | |||
190 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
191 | */ | ||
192 | tcg_remove_ops_after(dc->insn_eci_rewind); | ||
193 | dc->condjmp = 0; | ||
194 | - gen_exception_insn_el(dc, dc->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
195 | - default_exception_el(dc)); | ||
196 | + gen_exception_insn(dc, dc->pc_curr, EXCP_INVSTATE, | ||
197 | + syn_uncategorized()); | ||
198 | } | ||
199 | |||
200 | arm_post_translate_insn(dc); | ||
75 | -- | 201 | -- |
76 | 2.20.1 | 202 | 2.25.1 |
77 | |||
78 | diff view generated by jsdifflib |
1 | In gicv3_init_cpuif() we copy the ARMCPU gicv3_maintenance_interrupt | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | into the GICv3CPUState struct's maintenance_irq field. This will | ||
3 | only work if the board happens to have already wired up the CPU | ||
4 | maintenance IRQ before the GIC was realized. Unfortunately this is | ||
5 | not the case for the 'virt' board, and so the value that gets copied | ||
6 | is NULL (since a qemu_irq is really a pointer to an IRQState struct | ||
7 | under the hood). The effect is that the CPU interface code never | ||
8 | actually raises the maintenance interrupt line. | ||
9 | 2 | ||
10 | Instead, since the GICv3CPUState has a pointer to the CPUState, make | 3 | Move the computation from gen_swstep_exception into a helper. |
11 | the dereference at the point where we want to raise the interrupt, to | ||
12 | avoid an implicit requirement on board code to wire things up in a | ||
13 | particular order. | ||
14 | 4 | ||
15 | Reported-by: Jose Martins <josemartins90@gmail.com> | 5 | This fixes a bug when: |
6 | - MDSCR_EL1.KDE == 1 to enable debug exceptions within EL_D itself | ||
7 | - we singlestep an ERET from EL_D to some lower EL | ||
8 | |||
9 | Previously we were computing 'same el' based on the EL which | ||
10 | executed the ERET instruction, whereas it ought to be computed | ||
11 | based on the EL to which ERET returned. This happens naturally | ||
12 | with the new helper, which runs after EL has been changed. | ||
13 | |||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20220609202901.1177572-14-richard.henderson@linaro.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Message-id: 20201009153904.28529-1-peter.maydell@linaro.org | ||
18 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
19 | --- | 18 | --- |
20 | include/hw/intc/arm_gicv3_common.h | 1 - | 19 | target/arm/helper.h | 1 + |
21 | hw/intc/arm_gicv3_cpuif.c | 5 ++--- | 20 | target/arm/translate.h | 12 +++--------- |
22 | 2 files changed, 2 insertions(+), 4 deletions(-) | 21 | target/arm/debug_helper.c | 16 ++++++++++++++++ |
22 | 3 files changed, 20 insertions(+), 9 deletions(-) | ||
23 | 23 | ||
24 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | 24 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
25 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/intc/arm_gicv3_common.h | 26 | --- a/target/arm/helper.h |
27 | +++ b/include/hw/intc/arm_gicv3_common.h | 27 | +++ b/target/arm/helper.h |
28 | @@ -XXX,XX +XXX,XX @@ struct GICv3CPUState { | 28 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE, |
29 | qemu_irq parent_fiq; | 29 | DEF_HELPER_2(exception_internal, noreturn, env, i32) |
30 | qemu_irq parent_virq; | 30 | DEF_HELPER_4(exception_with_syndrome_el, noreturn, env, i32, i32, i32) |
31 | qemu_irq parent_vfiq; | 31 | DEF_HELPER_2(exception_bkpt_insn, noreturn, env, i32) |
32 | - qemu_irq maintenance_irq; | 32 | +DEF_HELPER_2(exception_swstep, noreturn, env, i32) |
33 | 33 | DEF_HELPER_2(exception_pc_alignment, noreturn, env, tl) | |
34 | /* Redistributor */ | 34 | DEF_HELPER_1(setend, void, env) |
35 | uint32_t level; /* Current IRQ level */ | 35 | DEF_HELPER_2(wfi, void, env, i32) |
36 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | 36 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
37 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/intc/arm_gicv3_cpuif.c | 38 | --- a/target/arm/translate.h |
39 | +++ b/hw/intc/arm_gicv3_cpuif.c | 39 | +++ b/target/arm/translate.h |
40 | @@ -XXX,XX +XXX,XX @@ static void gicv3_cpuif_virt_update(GICv3CPUState *cs) | 40 | @@ -XXX,XX +XXX,XX @@ static inline void gen_exception(int excp, uint32_t syndrome, |
41 | int irqlevel = 0; | 41 | /* Generate an architectural singlestep exception */ |
42 | int fiqlevel = 0; | 42 | static inline void gen_swstep_exception(DisasContext *s, int isv, int ex) |
43 | int maintlevel = 0; | 43 | { |
44 | + ARMCPU *cpu = ARM_CPU(cs->cpu); | 44 | - bool same_el = (s->debug_target_el == s->current_el); |
45 | 45 | - | |
46 | idx = hppvi_index(cs); | 46 | - /* |
47 | trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx); | 47 | - * If singlestep is targeting a lower EL than the current one, |
48 | @@ -XXX,XX +XXX,XX @@ static void gicv3_cpuif_virt_update(GICv3CPUState *cs) | 48 | - * then s->ss_active must be false and we can never get here. |
49 | 49 | - */ | |
50 | qemu_set_irq(cs->parent_vfiq, fiqlevel); | 50 | - assert(s->debug_target_el >= s->current_el); |
51 | qemu_set_irq(cs->parent_virq, irqlevel); | 51 | - |
52 | - qemu_set_irq(cs->maintenance_irq, maintlevel); | 52 | - gen_exception(EXCP_UDEF, syn_swstep(same_el, isv, ex), s->debug_target_el); |
53 | + qemu_set_irq(cpu->gicv3_maintenance_interrupt, maintlevel); | 53 | + /* Fill in the same_el field of the syndrome in the helper. */ |
54 | + uint32_t syn = syn_swstep(false, isv, ex); | ||
55 | + gen_helper_exception_swstep(cpu_env, tcg_constant_i32(syn)); | ||
54 | } | 56 | } |
55 | 57 | ||
56 | static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | 58 | /* |
57 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) | 59 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
58 | && cpu->gic_num_lrs) { | 60 | index XXXXXXX..XXXXXXX 100644 |
59 | int j; | 61 | --- a/target/arm/debug_helper.c |
60 | 62 | +++ b/target/arm/debug_helper.c | |
61 | - cs->maintenance_irq = cpu->gicv3_maintenance_interrupt; | 63 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome) |
62 | - | 64 | raise_exception(env, EXCP_BKPT, syndrome, debug_el); |
63 | cs->num_list_regs = cpu->gic_num_lrs; | 65 | } |
64 | cs->vpribits = cpu->gic_vpribits; | 66 | |
65 | cs->vprebits = cpu->gic_vprebits; | 67 | +void HELPER(exception_swstep)(CPUARMState *env, uint32_t syndrome) |
68 | +{ | ||
69 | + int debug_el = arm_debug_target_el(env); | ||
70 | + int cur_el = arm_current_el(env); | ||
71 | + | ||
72 | + /* | ||
73 | + * If singlestep is targeting a lower EL than the current one, then | ||
74 | + * DisasContext.ss_active must be false and we can never get here. | ||
75 | + */ | ||
76 | + assert(debug_el >= cur_el); | ||
77 | + if (debug_el == cur_el) { | ||
78 | + syndrome |= 1 << ARM_EL_EC_SHIFT; | ||
79 | + } | ||
80 | + raise_exception(env, EXCP_UDEF, syndrome, debug_el); | ||
81 | +} | ||
82 | + | ||
83 | #if !defined(CONFIG_USER_ONLY) | ||
84 | |||
85 | vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len) | ||
66 | -- | 86 | -- |
67 | 2.20.1 | 87 | 2.25.1 |
68 | |||
69 | diff view generated by jsdifflib |
1 | From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Secure mode is not exempted from checking SCR_EL3.TLOR, and in the | 3 | We no longer need this value during translation, |
4 | future HCR_EL2.TLOR when S-EL2 is enabled. | 4 | as it is now handled within the helpers. |
5 | 5 | ||
6 | Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220609202901.1177572-15-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | target/arm/helper.c | 19 +++++-------------- | 11 | target/arm/cpu.h | 6 ++---- |
11 | 1 file changed, 5 insertions(+), 14 deletions(-) | 12 | target/arm/translate.h | 2 -- |
13 | target/arm/helper.c | 12 ++---------- | ||
14 | target/arm/translate-a64.c | 1 - | ||
15 | target/arm/translate.c | 1 - | ||
16 | 5 files changed, 4 insertions(+), 18 deletions(-) | ||
12 | 17 | ||
18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/cpu.h | ||
21 | +++ b/target/arm/cpu.h | ||
22 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 3, 1) | ||
23 | FIELD(TBFLAG_ANY, MMUIDX, 4, 4) | ||
24 | /* Target EL if we take a floating-point-disabled exception */ | ||
25 | FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2) | ||
26 | -/* For A-profile only, target EL for debug exceptions. */ | ||
27 | -FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 10, 2) | ||
28 | /* Memory operations require alignment: SCTLR_ELx.A or CCR.UNALIGN_TRP */ | ||
29 | -FIELD(TBFLAG_ANY, ALIGN_MEM, 12, 1) | ||
30 | -FIELD(TBFLAG_ANY, PSTATE__IL, 13, 1) | ||
31 | +FIELD(TBFLAG_ANY, ALIGN_MEM, 10, 1) | ||
32 | +FIELD(TBFLAG_ANY, PSTATE__IL, 11, 1) | ||
33 | |||
34 | /* | ||
35 | * Bit usage when in AArch32 state, both A- and M-profile. | ||
36 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/translate.h | ||
39 | +++ b/target/arm/translate.h | ||
40 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
41 | */ | ||
42 | uint32_t svc_imm; | ||
43 | int current_el; | ||
44 | - /* Debug target exception level for single-step exceptions */ | ||
45 | - int debug_target_el; | ||
46 | GHashTable *cp_regs; | ||
47 | uint64_t features; /* CPU features bits */ | ||
48 | bool aarch64; | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 49 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 50 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 51 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/helper.c | 52 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) | 53 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el, |
18 | #endif | 54 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); |
19 | |||
20 | /* Shared logic between LORID and the rest of the LOR* registers. | ||
21 | - * Secure state has already been delt with. | ||
22 | + * Secure state exclusion has already been dealt with. | ||
23 | */ | ||
24 | -static CPAccessResult access_lor_ns(CPUARMState *env) | ||
25 | +static CPAccessResult access_lor_ns(CPUARMState *env, | ||
26 | + const ARMCPRegInfo *ri, bool isread) | ||
27 | { | ||
28 | int el = arm_current_el(env); | ||
29 | |||
30 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_lor_ns(CPUARMState *env) | ||
31 | return CP_ACCESS_OK; | ||
32 | } | 55 | } |
33 | 56 | ||
34 | -static CPAccessResult access_lorid(CPUARMState *env, const ARMCPRegInfo *ri, | 57 | -static CPUARMTBFlags rebuild_hflags_aprofile(CPUARMState *env) |
35 | - bool isread) | ||
36 | -{ | 58 | -{ |
37 | - if (arm_is_secure_below_el3(env)) { | 59 | - CPUARMTBFlags flags = {}; |
38 | - /* Access ok in secure mode. */ | 60 | - |
39 | - return CP_ACCESS_OK; | 61 | - DP_TBFLAG_ANY(flags, DEBUG_TARGET_EL, arm_debug_target_el(env)); |
40 | - } | 62 | - return flags; |
41 | - return access_lor_ns(env); | ||
42 | -} | 63 | -} |
43 | - | 64 | - |
44 | static CPAccessResult access_lor_other(CPUARMState *env, | 65 | static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, |
45 | const ARMCPRegInfo *ri, bool isread) | 66 | ARMMMUIdx mmu_idx) |
46 | { | 67 | { |
47 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_lor_other(CPUARMState *env, | 68 | - CPUARMTBFlags flags = rebuild_hflags_aprofile(env); |
48 | /* Access denied in secure mode. */ | 69 | + CPUARMTBFlags flags = {}; |
49 | return CP_ACCESS_TRAP; | 70 | int el = arm_current_el(env); |
50 | } | 71 | |
51 | - return access_lor_ns(env); | 72 | if (arm_sctlr(env, el) & SCTLR_A) { |
52 | + return access_lor_ns(env, ri, isread); | 73 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, |
53 | } | 74 | static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, |
54 | 75 | ARMMMUIdx mmu_idx) | |
55 | /* | 76 | { |
56 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lor_reginfo[] = { | 77 | - CPUARMTBFlags flags = rebuild_hflags_aprofile(env); |
57 | .type = ARM_CP_CONST, .resetvalue = 0 }, | 78 | + CPUARMTBFlags flags = {}; |
58 | { .name = "LORID_EL1", .state = ARM_CP_STATE_AA64, | 79 | ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); |
59 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, | 80 | uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; |
60 | - .access = PL1_R, .accessfn = access_lorid, | 81 | uint64_t sctlr; |
61 | + .access = PL1_R, .accessfn = access_lor_ns, | 82 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
62 | .type = ARM_CP_CONST, .resetvalue = 0 }, | 83 | index XXXXXXX..XXXXXXX 100644 |
63 | REGINFO_SENTINEL | 84 | --- a/target/arm/translate-a64.c |
64 | }; | 85 | +++ b/target/arm/translate-a64.c |
86 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
87 | dc->ss_active = EX_TBFLAG_ANY(tb_flags, SS_ACTIVE); | ||
88 | dc->pstate_ss = EX_TBFLAG_ANY(tb_flags, PSTATE__SS); | ||
89 | dc->is_ldex = false; | ||
90 | - dc->debug_target_el = EX_TBFLAG_ANY(tb_flags, DEBUG_TARGET_EL); | ||
91 | |||
92 | /* Bound the number of insns to execute to those left on the page. */ | ||
93 | bound = -(dc->base.pc_first | TARGET_PAGE_MASK) / 4; | ||
94 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
95 | index XXXXXXX..XXXXXXX 100644 | ||
96 | --- a/target/arm/translate.c | ||
97 | +++ b/target/arm/translate.c | ||
98 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
99 | dc->v7m_lspact = EX_TBFLAG_M32(tb_flags, LSPACT); | ||
100 | dc->mve_no_pred = EX_TBFLAG_M32(tb_flags, MVE_NO_PRED); | ||
101 | } else { | ||
102 | - dc->debug_target_el = EX_TBFLAG_ANY(tb_flags, DEBUG_TARGET_EL); | ||
103 | dc->sctlr_b = EX_TBFLAG_A32(tb_flags, SCTLR__B); | ||
104 | dc->hstr_active = EX_TBFLAG_A32(tb_flags, HSTR_ACTIVE); | ||
105 | dc->ns = EX_TBFLAG_A32(tb_flags, NS); | ||
65 | -- | 106 | -- |
66 | 2.20.1 | 107 | 2.25.1 |
67 | |||
68 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Replace all uses of neon_load/store_reg64 within translate-neon.c.inc. | 3 | This function is not required by any other translation file. |
4 | 4 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20201030022618.785675-9-richard.henderson@linaro.org | 7 | Message-id: 20220609202901.1177572-16-richard.henderson@linaro.org |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 9 | --- |
10 | target/arm/translate.c | 26 +++++++++ | 10 | target/arm/translate.h | 8 -------- |
11 | target/arm/translate-neon.c.inc | 94 ++++++++++++++++----------------- | 11 | target/arm/translate.c | 7 +++++++ |
12 | 2 files changed, 73 insertions(+), 47 deletions(-) | 12 | 2 files changed, 7 insertions(+), 8 deletions(-) |
13 | 13 | ||
14 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate.h | ||
17 | +++ b/target/arm/translate.h | ||
18 | @@ -XXX,XX +XXX,XX @@ static inline void gen_ss_advance(DisasContext *s) | ||
19 | } | ||
20 | } | ||
21 | |||
22 | -static inline void gen_exception(int excp, uint32_t syndrome, | ||
23 | - uint32_t target_el) | ||
24 | -{ | ||
25 | - gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp), | ||
26 | - tcg_constant_i32(syndrome), | ||
27 | - tcg_constant_i32(target_el)); | ||
28 | -} | ||
29 | - | ||
30 | /* Generate an architectural singlestep exception */ | ||
31 | static inline void gen_swstep_exception(DisasContext *s, int isv, int ex) | ||
32 | { | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 33 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
15 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 35 | --- a/target/arm/translate.c |
17 | +++ b/target/arm/translate.c | 36 | +++ b/target/arm/translate.c |
18 | @@ -XXX,XX +XXX,XX @@ static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop) | 37 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp) |
19 | } | 38 | s->base.is_jmp = DISAS_NORETURN; |
20 | } | 39 | } |
21 | 40 | ||
22 | +static void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop) | 41 | +static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el) |
23 | +{ | 42 | +{ |
24 | + long off = neon_element_offset(reg, ele, memop); | 43 | + gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp), |
25 | + | 44 | + tcg_constant_i32(syndrome), |
26 | + switch (memop) { | 45 | + tcg_constant_i32(target_el)); |
27 | + case MO_Q: | ||
28 | + tcg_gen_ld_i64(dest, cpu_env, off); | ||
29 | + break; | ||
30 | + default: | ||
31 | + g_assert_not_reached(); | ||
32 | + } | ||
33 | +} | 46 | +} |
34 | + | 47 | + |
35 | static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) | 48 | static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp, |
49 | uint32_t syn, TCGv_i32 tcg_el) | ||
36 | { | 50 | { |
37 | long off = neon_element_offset(reg, ele, memop); | ||
38 | @@ -XXX,XX +XXX,XX @@ static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) | ||
39 | } | ||
40 | } | ||
41 | |||
42 | +static void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop) | ||
43 | +{ | ||
44 | + long off = neon_element_offset(reg, ele, memop); | ||
45 | + | ||
46 | + switch (memop) { | ||
47 | + case MO_64: | ||
48 | + tcg_gen_st_i64(src, cpu_env, off); | ||
49 | + break; | ||
50 | + default: | ||
51 | + g_assert_not_reached(); | ||
52 | + } | ||
53 | +} | ||
54 | + | ||
55 | static TCGv_ptr vfp_reg_ptr(bool dp, int reg) | ||
56 | { | ||
57 | TCGv_ptr ret = tcg_temp_new_ptr(); | ||
58 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/translate-neon.c.inc | ||
61 | +++ b/target/arm/translate-neon.c.inc | ||
62 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_64(DisasContext *s, arg_2reg_shift *a, | ||
63 | for (pass = 0; pass < a->q + 1; pass++) { | ||
64 | TCGv_i64 tmp = tcg_temp_new_i64(); | ||
65 | |||
66 | - neon_load_reg64(tmp, a->vm + pass); | ||
67 | + read_neon_element64(tmp, a->vm, pass, MO_64); | ||
68 | fn(tmp, cpu_env, tmp, constimm); | ||
69 | - neon_store_reg64(tmp, a->vd + pass); | ||
70 | + write_neon_element64(tmp, a->vd, pass, MO_64); | ||
71 | tcg_temp_free_i64(tmp); | ||
72 | } | ||
73 | tcg_temp_free_i64(constimm); | ||
74 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, | ||
75 | rd = tcg_temp_new_i32(); | ||
76 | |||
77 | /* Load both inputs first to avoid potential overwrite if rm == rd */ | ||
78 | - neon_load_reg64(rm1, a->vm); | ||
79 | - neon_load_reg64(rm2, a->vm + 1); | ||
80 | + read_neon_element64(rm1, a->vm, 0, MO_64); | ||
81 | + read_neon_element64(rm2, a->vm, 1, MO_64); | ||
82 | |||
83 | shiftfn(rm1, rm1, constimm); | ||
84 | narrowfn(rd, cpu_env, rm1); | ||
85 | @@ -XXX,XX +XXX,XX @@ static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, | ||
86 | tcg_gen_shli_i64(tmp, tmp, a->shift); | ||
87 | tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | ||
88 | } | ||
89 | - neon_store_reg64(tmp, a->vd); | ||
90 | + write_neon_element64(tmp, a->vd, 0, MO_64); | ||
91 | |||
92 | widenfn(tmp, rm1); | ||
93 | tcg_temp_free_i32(rm1); | ||
94 | @@ -XXX,XX +XXX,XX @@ static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, | ||
95 | tcg_gen_shli_i64(tmp, tmp, a->shift); | ||
96 | tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | ||
97 | } | ||
98 | - neon_store_reg64(tmp, a->vd + 1); | ||
99 | + write_neon_element64(tmp, a->vd, 1, MO_64); | ||
100 | tcg_temp_free_i64(tmp); | ||
101 | return true; | ||
102 | } | ||
103 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
104 | rm_64 = tcg_temp_new_i64(); | ||
105 | |||
106 | if (src1_wide) { | ||
107 | - neon_load_reg64(rn0_64, a->vn); | ||
108 | + read_neon_element64(rn0_64, a->vn, 0, MO_64); | ||
109 | } else { | ||
110 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
111 | read_neon_element32(tmp, a->vn, 0, MO_32); | ||
112 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
113 | * avoid incorrect results if a narrow input overlaps with the result. | ||
114 | */ | ||
115 | if (src1_wide) { | ||
116 | - neon_load_reg64(rn1_64, a->vn + 1); | ||
117 | + read_neon_element64(rn1_64, a->vn, 1, MO_64); | ||
118 | } else { | ||
119 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
120 | read_neon_element32(tmp, a->vn, 1, MO_32); | ||
121 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
122 | rm = tcg_temp_new_i32(); | ||
123 | read_neon_element32(rm, a->vm, 1, MO_32); | ||
124 | |||
125 | - neon_store_reg64(rn0_64, a->vd); | ||
126 | + write_neon_element64(rn0_64, a->vd, 0, MO_64); | ||
127 | |||
128 | widenfn(rm_64, rm); | ||
129 | tcg_temp_free_i32(rm); | ||
130 | opfn(rn1_64, rn1_64, rm_64); | ||
131 | - neon_store_reg64(rn1_64, a->vd + 1); | ||
132 | + write_neon_element64(rn1_64, a->vd, 1, MO_64); | ||
133 | |||
134 | tcg_temp_free_i64(rn0_64); | ||
135 | tcg_temp_free_i64(rn1_64); | ||
136 | @@ -XXX,XX +XXX,XX @@ static bool do_narrow_3d(DisasContext *s, arg_3diff *a, | ||
137 | rd0 = tcg_temp_new_i32(); | ||
138 | rd1 = tcg_temp_new_i32(); | ||
139 | |||
140 | - neon_load_reg64(rn_64, a->vn); | ||
141 | - neon_load_reg64(rm_64, a->vm); | ||
142 | + read_neon_element64(rn_64, a->vn, 0, MO_64); | ||
143 | + read_neon_element64(rm_64, a->vm, 0, MO_64); | ||
144 | |||
145 | opfn(rn_64, rn_64, rm_64); | ||
146 | |||
147 | narrowfn(rd0, rn_64); | ||
148 | |||
149 | - neon_load_reg64(rn_64, a->vn + 1); | ||
150 | - neon_load_reg64(rm_64, a->vm + 1); | ||
151 | + read_neon_element64(rn_64, a->vn, 1, MO_64); | ||
152 | + read_neon_element64(rm_64, a->vm, 1, MO_64); | ||
153 | |||
154 | opfn(rn_64, rn_64, rm_64); | ||
155 | |||
156 | @@ -XXX,XX +XXX,XX @@ static bool do_long_3d(DisasContext *s, arg_3diff *a, | ||
157 | /* Don't store results until after all loads: they might overlap */ | ||
158 | if (accfn) { | ||
159 | tmp = tcg_temp_new_i64(); | ||
160 | - neon_load_reg64(tmp, a->vd); | ||
161 | + read_neon_element64(tmp, a->vd, 0, MO_64); | ||
162 | accfn(tmp, tmp, rd0); | ||
163 | - neon_store_reg64(tmp, a->vd); | ||
164 | - neon_load_reg64(tmp, a->vd + 1); | ||
165 | + write_neon_element64(tmp, a->vd, 0, MO_64); | ||
166 | + read_neon_element64(tmp, a->vd, 1, MO_64); | ||
167 | accfn(tmp, tmp, rd1); | ||
168 | - neon_store_reg64(tmp, a->vd + 1); | ||
169 | + write_neon_element64(tmp, a->vd, 1, MO_64); | ||
170 | tcg_temp_free_i64(tmp); | ||
171 | } else { | ||
172 | - neon_store_reg64(rd0, a->vd); | ||
173 | - neon_store_reg64(rd1, a->vd + 1); | ||
174 | + write_neon_element64(rd0, a->vd, 0, MO_64); | ||
175 | + write_neon_element64(rd1, a->vd, 1, MO_64); | ||
176 | } | ||
177 | |||
178 | tcg_temp_free_i64(rd0); | ||
179 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar_long(DisasContext *s, arg_2scalar *a, | ||
180 | |||
181 | if (accfn) { | ||
182 | TCGv_i64 t64 = tcg_temp_new_i64(); | ||
183 | - neon_load_reg64(t64, a->vd); | ||
184 | + read_neon_element64(t64, a->vd, 0, MO_64); | ||
185 | accfn(t64, t64, rn0_64); | ||
186 | - neon_store_reg64(t64, a->vd); | ||
187 | - neon_load_reg64(t64, a->vd + 1); | ||
188 | + write_neon_element64(t64, a->vd, 0, MO_64); | ||
189 | + read_neon_element64(t64, a->vd, 1, MO_64); | ||
190 | accfn(t64, t64, rn1_64); | ||
191 | - neon_store_reg64(t64, a->vd + 1); | ||
192 | + write_neon_element64(t64, a->vd, 1, MO_64); | ||
193 | tcg_temp_free_i64(t64); | ||
194 | } else { | ||
195 | - neon_store_reg64(rn0_64, a->vd); | ||
196 | - neon_store_reg64(rn1_64, a->vd + 1); | ||
197 | + write_neon_element64(rn0_64, a->vd, 0, MO_64); | ||
198 | + write_neon_element64(rn1_64, a->vd, 1, MO_64); | ||
199 | } | ||
200 | tcg_temp_free_i64(rn0_64); | ||
201 | tcg_temp_free_i64(rn1_64); | ||
202 | @@ -XXX,XX +XXX,XX @@ static bool trans_VEXT(DisasContext *s, arg_VEXT *a) | ||
203 | right = tcg_temp_new_i64(); | ||
204 | dest = tcg_temp_new_i64(); | ||
205 | |||
206 | - neon_load_reg64(right, a->vn); | ||
207 | - neon_load_reg64(left, a->vm); | ||
208 | + read_neon_element64(right, a->vn, 0, MO_64); | ||
209 | + read_neon_element64(left, a->vm, 0, MO_64); | ||
210 | tcg_gen_extract2_i64(dest, right, left, a->imm * 8); | ||
211 | - neon_store_reg64(dest, a->vd); | ||
212 | + write_neon_element64(dest, a->vd, 0, MO_64); | ||
213 | |||
214 | tcg_temp_free_i64(left); | ||
215 | tcg_temp_free_i64(right); | ||
216 | @@ -XXX,XX +XXX,XX @@ static bool trans_VEXT(DisasContext *s, arg_VEXT *a) | ||
217 | destright = tcg_temp_new_i64(); | ||
218 | |||
219 | if (a->imm < 8) { | ||
220 | - neon_load_reg64(right, a->vn); | ||
221 | - neon_load_reg64(middle, a->vn + 1); | ||
222 | + read_neon_element64(right, a->vn, 0, MO_64); | ||
223 | + read_neon_element64(middle, a->vn, 1, MO_64); | ||
224 | tcg_gen_extract2_i64(destright, right, middle, a->imm * 8); | ||
225 | - neon_load_reg64(left, a->vm); | ||
226 | + read_neon_element64(left, a->vm, 0, MO_64); | ||
227 | tcg_gen_extract2_i64(destleft, middle, left, a->imm * 8); | ||
228 | } else { | ||
229 | - neon_load_reg64(right, a->vn + 1); | ||
230 | - neon_load_reg64(middle, a->vm); | ||
231 | + read_neon_element64(right, a->vn, 1, MO_64); | ||
232 | + read_neon_element64(middle, a->vm, 0, MO_64); | ||
233 | tcg_gen_extract2_i64(destright, right, middle, (a->imm - 8) * 8); | ||
234 | - neon_load_reg64(left, a->vm + 1); | ||
235 | + read_neon_element64(left, a->vm, 1, MO_64); | ||
236 | tcg_gen_extract2_i64(destleft, middle, left, (a->imm - 8) * 8); | ||
237 | } | ||
238 | |||
239 | - neon_store_reg64(destright, a->vd); | ||
240 | - neon_store_reg64(destleft, a->vd + 1); | ||
241 | + write_neon_element64(destright, a->vd, 0, MO_64); | ||
242 | + write_neon_element64(destleft, a->vd, 1, MO_64); | ||
243 | |||
244 | tcg_temp_free_i64(destright); | ||
245 | tcg_temp_free_i64(destleft); | ||
246 | @@ -XXX,XX +XXX,XX @@ static bool do_2misc_pairwise(DisasContext *s, arg_2misc *a, | ||
247 | |||
248 | if (accfn) { | ||
249 | TCGv_i64 tmp64 = tcg_temp_new_i64(); | ||
250 | - neon_load_reg64(tmp64, a->vd + pass); | ||
251 | + read_neon_element64(tmp64, a->vd, pass, MO_64); | ||
252 | accfn(rd_64, tmp64, rd_64); | ||
253 | tcg_temp_free_i64(tmp64); | ||
254 | } | ||
255 | - neon_store_reg64(rd_64, a->vd + pass); | ||
256 | + write_neon_element64(rd_64, a->vd, pass, MO_64); | ||
257 | tcg_temp_free_i64(rd_64); | ||
258 | } | ||
259 | return true; | ||
260 | @@ -XXX,XX +XXX,XX @@ static bool do_vmovn(DisasContext *s, arg_2misc *a, | ||
261 | rd0 = tcg_temp_new_i32(); | ||
262 | rd1 = tcg_temp_new_i32(); | ||
263 | |||
264 | - neon_load_reg64(rm, a->vm); | ||
265 | + read_neon_element64(rm, a->vm, 0, MO_64); | ||
266 | narrowfn(rd0, cpu_env, rm); | ||
267 | - neon_load_reg64(rm, a->vm + 1); | ||
268 | + read_neon_element64(rm, a->vm, 1, MO_64); | ||
269 | narrowfn(rd1, cpu_env, rm); | ||
270 | write_neon_element32(rd0, a->vd, 0, MO_32); | ||
271 | write_neon_element32(rd1, a->vd, 1, MO_32); | ||
272 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL(DisasContext *s, arg_2misc *a) | ||
273 | |||
274 | widenfn(rd, rm0); | ||
275 | tcg_gen_shli_i64(rd, rd, 8 << a->size); | ||
276 | - neon_store_reg64(rd, a->vd); | ||
277 | + write_neon_element64(rd, a->vd, 0, MO_64); | ||
278 | widenfn(rd, rm1); | ||
279 | tcg_gen_shli_i64(rd, rd, 8 << a->size); | ||
280 | - neon_store_reg64(rd, a->vd + 1); | ||
281 | + write_neon_element64(rd, a->vd, 1, MO_64); | ||
282 | |||
283 | tcg_temp_free_i64(rd); | ||
284 | tcg_temp_free_i32(rm0); | ||
285 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSWP(DisasContext *s, arg_2misc *a) | ||
286 | rm = tcg_temp_new_i64(); | ||
287 | rd = tcg_temp_new_i64(); | ||
288 | for (pass = 0; pass < (a->q ? 2 : 1); pass++) { | ||
289 | - neon_load_reg64(rm, a->vm + pass); | ||
290 | - neon_load_reg64(rd, a->vd + pass); | ||
291 | - neon_store_reg64(rm, a->vd + pass); | ||
292 | - neon_store_reg64(rd, a->vm + pass); | ||
293 | + read_neon_element64(rm, a->vm, pass, MO_64); | ||
294 | + read_neon_element64(rd, a->vd, pass, MO_64); | ||
295 | + write_neon_element64(rm, a->vd, pass, MO_64); | ||
296 | + write_neon_element64(rd, a->vm, pass, MO_64); | ||
297 | } | ||
298 | tcg_temp_free_i64(rm); | ||
299 | tcg_temp_free_i64(rd); | ||
300 | -- | 51 | -- |
301 | 2.20.1 | 52 | 2.25.1 |
302 | |||
303 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The only uses of this function are for loading VFP | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | single-precision values, and nothing to do with NEON. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201030022618.785675-8-richard.henderson@linaro.org | 5 | Message-id: 20220609202901.1177572-17-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 7 | --- |
11 | target/arm/translate.c | 4 +- | 8 | target/arm/translate.c | 18 +++++++++--------- |
12 | target/arm/translate-vfp.c.inc | 184 ++++++++++++++++----------------- | 9 | 1 file changed, 9 insertions(+), 9 deletions(-) |
13 | 2 files changed, 94 insertions(+), 94 deletions(-) | ||
14 | 10 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 11 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
16 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 13 | --- a/target/arm/translate.c |
18 | +++ b/target/arm/translate.c | 14 | +++ b/target/arm/translate.c |
19 | @@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg64(TCGv_i64 var, int reg) | 15 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp) |
20 | tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 16 | s->base.is_jmp = DISAS_NORETURN; |
21 | } | 17 | } |
22 | 18 | ||
23 | -static inline void neon_load_reg32(TCGv_i32 var, int reg) | 19 | -static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el) |
24 | +static inline void vfp_load_reg32(TCGv_i32 var, int reg) | 20 | +static void gen_exception_el(int excp, uint32_t syndrome, uint32_t target_el) |
25 | { | 21 | { |
26 | tcg_gen_ld_i32(var, cpu_env, vfp_reg_offset(false, reg)); | 22 | gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp), |
27 | } | 23 | tcg_constant_i32(syndrome), |
28 | 24 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | |
29 | -static inline void neon_store_reg32(TCGv_i32 var, int reg) | 25 | switch (dc->base.is_jmp) { |
30 | +static inline void vfp_store_reg32(TCGv_i32 var, int reg) | 26 | case DISAS_SWI: |
31 | { | 27 | gen_ss_advance(dc); |
32 | tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); | 28 | - gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), |
33 | } | 29 | - default_exception_el(dc)); |
34 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | 30 | + gen_exception_el(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), |
35 | index XXXXXXX..XXXXXXX 100644 | 31 | + default_exception_el(dc)); |
36 | --- a/target/arm/translate-vfp.c.inc | ||
37 | +++ b/target/arm/translate-vfp.c.inc | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
39 | frn = tcg_temp_new_i32(); | ||
40 | frm = tcg_temp_new_i32(); | ||
41 | dest = tcg_temp_new_i32(); | ||
42 | - neon_load_reg32(frn, rn); | ||
43 | - neon_load_reg32(frm, rm); | ||
44 | + vfp_load_reg32(frn, rn); | ||
45 | + vfp_load_reg32(frm, rm); | ||
46 | switch (a->cc) { | ||
47 | case 0: /* eq: Z */ | ||
48 | tcg_gen_movcond_i32(TCG_COND_EQ, dest, cpu_ZF, zero, | ||
49 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
50 | if (sz == 1) { | ||
51 | tcg_gen_andi_i32(dest, dest, 0xffff); | ||
52 | } | ||
53 | - neon_store_reg32(dest, rd); | ||
54 | + vfp_store_reg32(dest, rd); | ||
55 | tcg_temp_free_i32(frn); | ||
56 | tcg_temp_free_i32(frm); | ||
57 | tcg_temp_free_i32(dest); | ||
58 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) | ||
59 | TCGv_i32 tcg_res; | ||
60 | tcg_op = tcg_temp_new_i32(); | ||
61 | tcg_res = tcg_temp_new_i32(); | ||
62 | - neon_load_reg32(tcg_op, rm); | ||
63 | + vfp_load_reg32(tcg_op, rm); | ||
64 | if (sz == 1) { | ||
65 | gen_helper_rinth(tcg_res, tcg_op, fpst); | ||
66 | } else { | ||
67 | gen_helper_rints(tcg_res, tcg_op, fpst); | ||
68 | } | ||
69 | - neon_store_reg32(tcg_res, rd); | ||
70 | + vfp_store_reg32(tcg_res, rd); | ||
71 | tcg_temp_free_i32(tcg_op); | ||
72 | tcg_temp_free_i32(tcg_res); | ||
73 | } | ||
74 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
75 | gen_helper_vfp_tould(tcg_res, tcg_double, tcg_shift, fpst); | ||
76 | } | ||
77 | tcg_gen_extrl_i64_i32(tcg_tmp, tcg_res); | ||
78 | - neon_store_reg32(tcg_tmp, rd); | ||
79 | + vfp_store_reg32(tcg_tmp, rd); | ||
80 | tcg_temp_free_i32(tcg_tmp); | ||
81 | tcg_temp_free_i64(tcg_res); | ||
82 | tcg_temp_free_i64(tcg_double); | ||
83 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
84 | TCGv_i32 tcg_single, tcg_res; | ||
85 | tcg_single = tcg_temp_new_i32(); | ||
86 | tcg_res = tcg_temp_new_i32(); | ||
87 | - neon_load_reg32(tcg_single, rm); | ||
88 | + vfp_load_reg32(tcg_single, rm); | ||
89 | if (sz == 1) { | ||
90 | if (is_signed) { | ||
91 | gen_helper_vfp_toslh(tcg_res, tcg_single, tcg_shift, fpst); | ||
92 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
93 | gen_helper_vfp_touls(tcg_res, tcg_single, tcg_shift, fpst); | ||
94 | } | ||
95 | } | ||
96 | - neon_store_reg32(tcg_res, rd); | ||
97 | + vfp_store_reg32(tcg_res, rd); | ||
98 | tcg_temp_free_i32(tcg_res); | ||
99 | tcg_temp_free_i32(tcg_single); | ||
100 | } | ||
101 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_half(DisasContext *s, arg_VMOV_single *a) | ||
102 | if (a->l) { | ||
103 | /* VFP to general purpose register */ | ||
104 | tmp = tcg_temp_new_i32(); | ||
105 | - neon_load_reg32(tmp, a->vn); | ||
106 | + vfp_load_reg32(tmp, a->vn); | ||
107 | tcg_gen_andi_i32(tmp, tmp, 0xffff); | ||
108 | store_reg(s, a->rt, tmp); | ||
109 | } else { | ||
110 | /* general purpose register to VFP */ | ||
111 | tmp = load_reg(s, a->rt); | ||
112 | tcg_gen_andi_i32(tmp, tmp, 0xffff); | ||
113 | - neon_store_reg32(tmp, a->vn); | ||
114 | + vfp_store_reg32(tmp, a->vn); | ||
115 | tcg_temp_free_i32(tmp); | ||
116 | } | ||
117 | |||
118 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a) | ||
119 | if (a->l) { | ||
120 | /* VFP to general purpose register */ | ||
121 | tmp = tcg_temp_new_i32(); | ||
122 | - neon_load_reg32(tmp, a->vn); | ||
123 | + vfp_load_reg32(tmp, a->vn); | ||
124 | if (a->rt == 15) { | ||
125 | /* Set the 4 flag bits in the CPSR. */ | ||
126 | gen_set_nzcv(tmp); | ||
127 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a) | ||
128 | } else { | ||
129 | /* general purpose register to VFP */ | ||
130 | tmp = load_reg(s, a->rt); | ||
131 | - neon_store_reg32(tmp, a->vn); | ||
132 | + vfp_store_reg32(tmp, a->vn); | ||
133 | tcg_temp_free_i32(tmp); | ||
134 | } | ||
135 | |||
136 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_64_sp(DisasContext *s, arg_VMOV_64_sp *a) | ||
137 | if (a->op) { | ||
138 | /* fpreg to gpreg */ | ||
139 | tmp = tcg_temp_new_i32(); | ||
140 | - neon_load_reg32(tmp, a->vm); | ||
141 | + vfp_load_reg32(tmp, a->vm); | ||
142 | store_reg(s, a->rt, tmp); | ||
143 | tmp = tcg_temp_new_i32(); | ||
144 | - neon_load_reg32(tmp, a->vm + 1); | ||
145 | + vfp_load_reg32(tmp, a->vm + 1); | ||
146 | store_reg(s, a->rt2, tmp); | ||
147 | } else { | ||
148 | /* gpreg to fpreg */ | ||
149 | tmp = load_reg(s, a->rt); | ||
150 | - neon_store_reg32(tmp, a->vm); | ||
151 | + vfp_store_reg32(tmp, a->vm); | ||
152 | tcg_temp_free_i32(tmp); | ||
153 | tmp = load_reg(s, a->rt2); | ||
154 | - neon_store_reg32(tmp, a->vm + 1); | ||
155 | + vfp_store_reg32(tmp, a->vm + 1); | ||
156 | tcg_temp_free_i32(tmp); | ||
157 | } | ||
158 | |||
159 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_64_dp(DisasContext *s, arg_VMOV_64_dp *a) | ||
160 | if (a->op) { | ||
161 | /* fpreg to gpreg */ | ||
162 | tmp = tcg_temp_new_i32(); | ||
163 | - neon_load_reg32(tmp, a->vm * 2); | ||
164 | + vfp_load_reg32(tmp, a->vm * 2); | ||
165 | store_reg(s, a->rt, tmp); | ||
166 | tmp = tcg_temp_new_i32(); | ||
167 | - neon_load_reg32(tmp, a->vm * 2 + 1); | ||
168 | + vfp_load_reg32(tmp, a->vm * 2 + 1); | ||
169 | store_reg(s, a->rt2, tmp); | ||
170 | } else { | ||
171 | /* gpreg to fpreg */ | ||
172 | tmp = load_reg(s, a->rt); | ||
173 | - neon_store_reg32(tmp, a->vm * 2); | ||
174 | + vfp_store_reg32(tmp, a->vm * 2); | ||
175 | tcg_temp_free_i32(tmp); | ||
176 | tmp = load_reg(s, a->rt2); | ||
177 | - neon_store_reg32(tmp, a->vm * 2 + 1); | ||
178 | + vfp_store_reg32(tmp, a->vm * 2 + 1); | ||
179 | tcg_temp_free_i32(tmp); | ||
180 | } | ||
181 | |||
182 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_hp(DisasContext *s, arg_VLDR_VSTR_sp *a) | ||
183 | tmp = tcg_temp_new_i32(); | ||
184 | if (a->l) { | ||
185 | gen_aa32_ld16u(s, tmp, addr, get_mem_index(s)); | ||
186 | - neon_store_reg32(tmp, a->vd); | ||
187 | + vfp_store_reg32(tmp, a->vd); | ||
188 | } else { | ||
189 | - neon_load_reg32(tmp, a->vd); | ||
190 | + vfp_load_reg32(tmp, a->vd); | ||
191 | gen_aa32_st16(s, tmp, addr, get_mem_index(s)); | ||
192 | } | ||
193 | tcg_temp_free_i32(tmp); | ||
194 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) | ||
195 | tmp = tcg_temp_new_i32(); | ||
196 | if (a->l) { | ||
197 | gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
198 | - neon_store_reg32(tmp, a->vd); | ||
199 | + vfp_store_reg32(tmp, a->vd); | ||
200 | } else { | ||
201 | - neon_load_reg32(tmp, a->vd); | ||
202 | + vfp_load_reg32(tmp, a->vd); | ||
203 | gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
204 | } | ||
205 | tcg_temp_free_i32(tmp); | ||
206 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) | ||
207 | if (a->l) { | ||
208 | /* load */ | ||
209 | gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
210 | - neon_store_reg32(tmp, a->vd + i); | ||
211 | + vfp_store_reg32(tmp, a->vd + i); | ||
212 | } else { | ||
213 | /* store */ | ||
214 | - neon_load_reg32(tmp, a->vd + i); | ||
215 | + vfp_load_reg32(tmp, a->vd + i); | ||
216 | gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
217 | } | ||
218 | tcg_gen_addi_i32(addr, addr, offset); | ||
219 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn, | ||
220 | fd = tcg_temp_new_i32(); | ||
221 | fpst = fpstatus_ptr(FPST_FPCR); | ||
222 | |||
223 | - neon_load_reg32(f0, vn); | ||
224 | - neon_load_reg32(f1, vm); | ||
225 | + vfp_load_reg32(f0, vn); | ||
226 | + vfp_load_reg32(f1, vm); | ||
227 | |||
228 | for (;;) { | ||
229 | if (reads_vd) { | ||
230 | - neon_load_reg32(fd, vd); | ||
231 | + vfp_load_reg32(fd, vd); | ||
232 | } | ||
233 | fn(fd, f0, f1, fpst); | ||
234 | - neon_store_reg32(fd, vd); | ||
235 | + vfp_store_reg32(fd, vd); | ||
236 | |||
237 | if (veclen == 0) { | ||
238 | break; | 32 | break; |
239 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn, | 33 | case DISAS_HVC: |
240 | veclen--; | 34 | gen_ss_advance(dc); |
241 | vd = vfp_advance_sreg(vd, delta_d); | 35 | - gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); |
242 | vn = vfp_advance_sreg(vn, delta_d); | 36 | + gen_exception_el(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); |
243 | - neon_load_reg32(f0, vn); | 37 | break; |
244 | + vfp_load_reg32(f0, vn); | 38 | case DISAS_SMC: |
245 | if (delta_m) { | 39 | gen_ss_advance(dc); |
246 | vm = vfp_advance_sreg(vm, delta_m); | 40 | - gen_exception(EXCP_SMC, syn_aa32_smc(), 3); |
247 | - neon_load_reg32(f1, vm); | 41 | + gen_exception_el(EXCP_SMC, syn_aa32_smc(), 3); |
248 | + vfp_load_reg32(f1, vm); | 42 | break; |
43 | case DISAS_NEXT: | ||
44 | case DISAS_TOO_MANY: | ||
45 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
46 | gen_helper_yield(cpu_env); | ||
47 | break; | ||
48 | case DISAS_SWI: | ||
49 | - gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), | ||
50 | - default_exception_el(dc)); | ||
51 | + gen_exception_el(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), | ||
52 | + default_exception_el(dc)); | ||
53 | break; | ||
54 | case DISAS_HVC: | ||
55 | - gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); | ||
56 | + gen_exception_el(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); | ||
57 | break; | ||
58 | case DISAS_SMC: | ||
59 | - gen_exception(EXCP_SMC, syn_aa32_smc(), 3); | ||
60 | + gen_exception_el(EXCP_SMC, syn_aa32_smc(), 3); | ||
61 | break; | ||
249 | } | 62 | } |
250 | } | 63 | } |
251 | |||
252 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_hp(DisasContext *s, VFPGen3OpSPFn *fn, | ||
253 | fd = tcg_temp_new_i32(); | ||
254 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
255 | |||
256 | - neon_load_reg32(f0, vn); | ||
257 | - neon_load_reg32(f1, vm); | ||
258 | + vfp_load_reg32(f0, vn); | ||
259 | + vfp_load_reg32(f1, vm); | ||
260 | |||
261 | if (reads_vd) { | ||
262 | - neon_load_reg32(fd, vd); | ||
263 | + vfp_load_reg32(fd, vd); | ||
264 | } | ||
265 | fn(fd, f0, f1, fpst); | ||
266 | - neon_store_reg32(fd, vd); | ||
267 | + vfp_store_reg32(fd, vd); | ||
268 | |||
269 | tcg_temp_free_i32(f0); | ||
270 | tcg_temp_free_i32(f1); | ||
271 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) | ||
272 | f0 = tcg_temp_new_i32(); | ||
273 | fd = tcg_temp_new_i32(); | ||
274 | |||
275 | - neon_load_reg32(f0, vm); | ||
276 | + vfp_load_reg32(f0, vm); | ||
277 | |||
278 | for (;;) { | ||
279 | fn(fd, f0); | ||
280 | - neon_store_reg32(fd, vd); | ||
281 | + vfp_store_reg32(fd, vd); | ||
282 | |||
283 | if (veclen == 0) { | ||
284 | break; | ||
285 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) | ||
286 | /* single source one-many */ | ||
287 | while (veclen--) { | ||
288 | vd = vfp_advance_sreg(vd, delta_d); | ||
289 | - neon_store_reg32(fd, vd); | ||
290 | + vfp_store_reg32(fd, vd); | ||
291 | } | ||
292 | break; | ||
293 | } | ||
294 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) | ||
295 | veclen--; | ||
296 | vd = vfp_advance_sreg(vd, delta_d); | ||
297 | vm = vfp_advance_sreg(vm, delta_m); | ||
298 | - neon_load_reg32(f0, vm); | ||
299 | + vfp_load_reg32(f0, vm); | ||
300 | } | ||
301 | |||
302 | tcg_temp_free_i32(f0); | ||
303 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_hp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) | ||
304 | } | ||
305 | |||
306 | f0 = tcg_temp_new_i32(); | ||
307 | - neon_load_reg32(f0, vm); | ||
308 | + vfp_load_reg32(f0, vm); | ||
309 | fn(f0, f0); | ||
310 | - neon_store_reg32(f0, vd); | ||
311 | + vfp_store_reg32(f0, vd); | ||
312 | tcg_temp_free_i32(f0); | ||
313 | |||
314 | return true; | ||
315 | @@ -XXX,XX +XXX,XX @@ static bool do_vfm_hp(DisasContext *s, arg_VFMA_sp *a, bool neg_n, bool neg_d) | ||
316 | vm = tcg_temp_new_i32(); | ||
317 | vd = tcg_temp_new_i32(); | ||
318 | |||
319 | - neon_load_reg32(vn, a->vn); | ||
320 | - neon_load_reg32(vm, a->vm); | ||
321 | + vfp_load_reg32(vn, a->vn); | ||
322 | + vfp_load_reg32(vm, a->vm); | ||
323 | if (neg_n) { | ||
324 | /* VFNMS, VFMS */ | ||
325 | gen_helper_vfp_negh(vn, vn); | ||
326 | } | ||
327 | - neon_load_reg32(vd, a->vd); | ||
328 | + vfp_load_reg32(vd, a->vd); | ||
329 | if (neg_d) { | ||
330 | /* VFNMA, VFNMS */ | ||
331 | gen_helper_vfp_negh(vd, vd); | ||
332 | } | ||
333 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
334 | gen_helper_vfp_muladdh(vd, vn, vm, vd, fpst); | ||
335 | - neon_store_reg32(vd, a->vd); | ||
336 | + vfp_store_reg32(vd, a->vd); | ||
337 | |||
338 | tcg_temp_free_ptr(fpst); | ||
339 | tcg_temp_free_i32(vn); | ||
340 | @@ -XXX,XX +XXX,XX @@ static bool do_vfm_sp(DisasContext *s, arg_VFMA_sp *a, bool neg_n, bool neg_d) | ||
341 | vm = tcg_temp_new_i32(); | ||
342 | vd = tcg_temp_new_i32(); | ||
343 | |||
344 | - neon_load_reg32(vn, a->vn); | ||
345 | - neon_load_reg32(vm, a->vm); | ||
346 | + vfp_load_reg32(vn, a->vn); | ||
347 | + vfp_load_reg32(vm, a->vm); | ||
348 | if (neg_n) { | ||
349 | /* VFNMS, VFMS */ | ||
350 | gen_helper_vfp_negs(vn, vn); | ||
351 | } | ||
352 | - neon_load_reg32(vd, a->vd); | ||
353 | + vfp_load_reg32(vd, a->vd); | ||
354 | if (neg_d) { | ||
355 | /* VFNMA, VFNMS */ | ||
356 | gen_helper_vfp_negs(vd, vd); | ||
357 | } | ||
358 | fpst = fpstatus_ptr(FPST_FPCR); | ||
359 | gen_helper_vfp_muladds(vd, vn, vm, vd, fpst); | ||
360 | - neon_store_reg32(vd, a->vd); | ||
361 | + vfp_store_reg32(vd, a->vd); | ||
362 | |||
363 | tcg_temp_free_ptr(fpst); | ||
364 | tcg_temp_free_i32(vn); | ||
365 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_hp(DisasContext *s, arg_VMOV_imm_sp *a) | ||
366 | } | ||
367 | |||
368 | fd = tcg_const_i32(vfp_expand_imm(MO_16, a->imm)); | ||
369 | - neon_store_reg32(fd, a->vd); | ||
370 | + vfp_store_reg32(fd, a->vd); | ||
371 | tcg_temp_free_i32(fd); | ||
372 | return true; | ||
373 | } | ||
374 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a) | ||
375 | fd = tcg_const_i32(vfp_expand_imm(MO_32, a->imm)); | ||
376 | |||
377 | for (;;) { | ||
378 | - neon_store_reg32(fd, vd); | ||
379 | + vfp_store_reg32(fd, vd); | ||
380 | |||
381 | if (veclen == 0) { | ||
382 | break; | ||
383 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_hp(DisasContext *s, arg_VCMP_sp *a) | ||
384 | vd = tcg_temp_new_i32(); | ||
385 | vm = tcg_temp_new_i32(); | ||
386 | |||
387 | - neon_load_reg32(vd, a->vd); | ||
388 | + vfp_load_reg32(vd, a->vd); | ||
389 | if (a->z) { | ||
390 | tcg_gen_movi_i32(vm, 0); | ||
391 | } else { | ||
392 | - neon_load_reg32(vm, a->vm); | ||
393 | + vfp_load_reg32(vm, a->vm); | ||
394 | } | ||
395 | |||
396 | if (a->e) { | ||
397 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_sp(DisasContext *s, arg_VCMP_sp *a) | ||
398 | vd = tcg_temp_new_i32(); | ||
399 | vm = tcg_temp_new_i32(); | ||
400 | |||
401 | - neon_load_reg32(vd, a->vd); | ||
402 | + vfp_load_reg32(vd, a->vd); | ||
403 | if (a->z) { | ||
404 | tcg_gen_movi_i32(vm, 0); | ||
405 | } else { | ||
406 | - neon_load_reg32(vm, a->vm); | ||
407 | + vfp_load_reg32(vm, a->vm); | ||
408 | } | ||
409 | |||
410 | if (a->e) { | ||
411 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f32_f16(DisasContext *s, arg_VCVT_f32_f16 *a) | ||
412 | /* The T bit tells us if we want the low or high 16 bits of Vm */ | ||
413 | tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t)); | ||
414 | gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp_mode); | ||
415 | - neon_store_reg32(tmp, a->vd); | ||
416 | + vfp_store_reg32(tmp, a->vd); | ||
417 | tcg_temp_free_i32(ahp_mode); | ||
418 | tcg_temp_free_ptr(fpst); | ||
419 | tcg_temp_free_i32(tmp); | ||
420 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f32(DisasContext *s, arg_VCVT_f16_f32 *a) | ||
421 | ahp_mode = get_ahp_flag(); | ||
422 | tmp = tcg_temp_new_i32(); | ||
423 | |||
424 | - neon_load_reg32(tmp, a->vm); | ||
425 | + vfp_load_reg32(tmp, a->vm); | ||
426 | gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp_mode); | ||
427 | tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t)); | ||
428 | tcg_temp_free_i32(ahp_mode); | ||
429 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_hp(DisasContext *s, arg_VRINTR_sp *a) | ||
430 | } | ||
431 | |||
432 | tmp = tcg_temp_new_i32(); | ||
433 | - neon_load_reg32(tmp, a->vm); | ||
434 | + vfp_load_reg32(tmp, a->vm); | ||
435 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
436 | gen_helper_rinth(tmp, tmp, fpst); | ||
437 | - neon_store_reg32(tmp, a->vd); | ||
438 | + vfp_store_reg32(tmp, a->vd); | ||
439 | tcg_temp_free_ptr(fpst); | ||
440 | tcg_temp_free_i32(tmp); | ||
441 | return true; | ||
442 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_sp(DisasContext *s, arg_VRINTR_sp *a) | ||
443 | } | ||
444 | |||
445 | tmp = tcg_temp_new_i32(); | ||
446 | - neon_load_reg32(tmp, a->vm); | ||
447 | + vfp_load_reg32(tmp, a->vm); | ||
448 | fpst = fpstatus_ptr(FPST_FPCR); | ||
449 | gen_helper_rints(tmp, tmp, fpst); | ||
450 | - neon_store_reg32(tmp, a->vd); | ||
451 | + vfp_store_reg32(tmp, a->vd); | ||
452 | tcg_temp_free_ptr(fpst); | ||
453 | tcg_temp_free_i32(tmp); | ||
454 | return true; | ||
455 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_hp(DisasContext *s, arg_VRINTZ_sp *a) | ||
456 | } | ||
457 | |||
458 | tmp = tcg_temp_new_i32(); | ||
459 | - neon_load_reg32(tmp, a->vm); | ||
460 | + vfp_load_reg32(tmp, a->vm); | ||
461 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
462 | tcg_rmode = tcg_const_i32(float_round_to_zero); | ||
463 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
464 | gen_helper_rinth(tmp, tmp, fpst); | ||
465 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
466 | - neon_store_reg32(tmp, a->vd); | ||
467 | + vfp_store_reg32(tmp, a->vd); | ||
468 | tcg_temp_free_ptr(fpst); | ||
469 | tcg_temp_free_i32(tcg_rmode); | ||
470 | tcg_temp_free_i32(tmp); | ||
471 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_sp(DisasContext *s, arg_VRINTZ_sp *a) | ||
472 | } | ||
473 | |||
474 | tmp = tcg_temp_new_i32(); | ||
475 | - neon_load_reg32(tmp, a->vm); | ||
476 | + vfp_load_reg32(tmp, a->vm); | ||
477 | fpst = fpstatus_ptr(FPST_FPCR); | ||
478 | tcg_rmode = tcg_const_i32(float_round_to_zero); | ||
479 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
480 | gen_helper_rints(tmp, tmp, fpst); | ||
481 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
482 | - neon_store_reg32(tmp, a->vd); | ||
483 | + vfp_store_reg32(tmp, a->vd); | ||
484 | tcg_temp_free_ptr(fpst); | ||
485 | tcg_temp_free_i32(tcg_rmode); | ||
486 | tcg_temp_free_i32(tmp); | ||
487 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_hp(DisasContext *s, arg_VRINTX_sp *a) | ||
488 | } | ||
489 | |||
490 | tmp = tcg_temp_new_i32(); | ||
491 | - neon_load_reg32(tmp, a->vm); | ||
492 | + vfp_load_reg32(tmp, a->vm); | ||
493 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
494 | gen_helper_rinth_exact(tmp, tmp, fpst); | ||
495 | - neon_store_reg32(tmp, a->vd); | ||
496 | + vfp_store_reg32(tmp, a->vd); | ||
497 | tcg_temp_free_ptr(fpst); | ||
498 | tcg_temp_free_i32(tmp); | ||
499 | return true; | ||
500 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_sp(DisasContext *s, arg_VRINTX_sp *a) | ||
501 | } | ||
502 | |||
503 | tmp = tcg_temp_new_i32(); | ||
504 | - neon_load_reg32(tmp, a->vm); | ||
505 | + vfp_load_reg32(tmp, a->vm); | ||
506 | fpst = fpstatus_ptr(FPST_FPCR); | ||
507 | gen_helper_rints_exact(tmp, tmp, fpst); | ||
508 | - neon_store_reg32(tmp, a->vd); | ||
509 | + vfp_store_reg32(tmp, a->vd); | ||
510 | tcg_temp_free_ptr(fpst); | ||
511 | tcg_temp_free_i32(tmp); | ||
512 | return true; | ||
513 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a) | ||
514 | |||
515 | vm = tcg_temp_new_i32(); | ||
516 | vd = tcg_temp_new_i64(); | ||
517 | - neon_load_reg32(vm, a->vm); | ||
518 | + vfp_load_reg32(vm, a->vm); | ||
519 | gen_helper_vfp_fcvtds(vd, vm, cpu_env); | ||
520 | neon_store_reg64(vd, a->vd); | ||
521 | tcg_temp_free_i32(vm); | ||
522 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) | ||
523 | vm = tcg_temp_new_i64(); | ||
524 | neon_load_reg64(vm, a->vm); | ||
525 | gen_helper_vfp_fcvtsd(vd, vm, cpu_env); | ||
526 | - neon_store_reg32(vd, a->vd); | ||
527 | + vfp_store_reg32(vd, a->vd); | ||
528 | tcg_temp_free_i32(vd); | ||
529 | tcg_temp_free_i64(vm); | ||
530 | return true; | ||
531 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_hp(DisasContext *s, arg_VCVT_int_sp *a) | ||
532 | } | ||
533 | |||
534 | vm = tcg_temp_new_i32(); | ||
535 | - neon_load_reg32(vm, a->vm); | ||
536 | + vfp_load_reg32(vm, a->vm); | ||
537 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
538 | if (a->s) { | ||
539 | /* i32 -> f16 */ | ||
540 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_hp(DisasContext *s, arg_VCVT_int_sp *a) | ||
541 | /* u32 -> f16 */ | ||
542 | gen_helper_vfp_uitoh(vm, vm, fpst); | ||
543 | } | ||
544 | - neon_store_reg32(vm, a->vd); | ||
545 | + vfp_store_reg32(vm, a->vd); | ||
546 | tcg_temp_free_i32(vm); | ||
547 | tcg_temp_free_ptr(fpst); | ||
548 | return true; | ||
549 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a) | ||
550 | } | ||
551 | |||
552 | vm = tcg_temp_new_i32(); | ||
553 | - neon_load_reg32(vm, a->vm); | ||
554 | + vfp_load_reg32(vm, a->vm); | ||
555 | fpst = fpstatus_ptr(FPST_FPCR); | ||
556 | if (a->s) { | ||
557 | /* i32 -> f32 */ | ||
558 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a) | ||
559 | /* u32 -> f32 */ | ||
560 | gen_helper_vfp_uitos(vm, vm, fpst); | ||
561 | } | ||
562 | - neon_store_reg32(vm, a->vd); | ||
563 | + vfp_store_reg32(vm, a->vd); | ||
564 | tcg_temp_free_i32(vm); | ||
565 | tcg_temp_free_ptr(fpst); | ||
566 | return true; | ||
567 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a) | ||
568 | |||
569 | vm = tcg_temp_new_i32(); | ||
570 | vd = tcg_temp_new_i64(); | ||
571 | - neon_load_reg32(vm, a->vm); | ||
572 | + vfp_load_reg32(vm, a->vm); | ||
573 | fpst = fpstatus_ptr(FPST_FPCR); | ||
574 | if (a->s) { | ||
575 | /* i32 -> f64 */ | ||
576 | @@ -XXX,XX +XXX,XX @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a) | ||
577 | vd = tcg_temp_new_i32(); | ||
578 | neon_load_reg64(vm, a->vm); | ||
579 | gen_helper_vjcvt(vd, vm, cpu_env); | ||
580 | - neon_store_reg32(vd, a->vd); | ||
581 | + vfp_store_reg32(vd, a->vd); | ||
582 | tcg_temp_free_i64(vm); | ||
583 | tcg_temp_free_i32(vd); | ||
584 | return true; | ||
585 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
586 | frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm); | ||
587 | |||
588 | vd = tcg_temp_new_i32(); | ||
589 | - neon_load_reg32(vd, a->vd); | ||
590 | + vfp_load_reg32(vd, a->vd); | ||
591 | |||
592 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
593 | shift = tcg_const_i32(frac_bits); | ||
594 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
595 | g_assert_not_reached(); | ||
596 | } | ||
597 | |||
598 | - neon_store_reg32(vd, a->vd); | ||
599 | + vfp_store_reg32(vd, a->vd); | ||
600 | tcg_temp_free_i32(vd); | ||
601 | tcg_temp_free_i32(shift); | ||
602 | tcg_temp_free_ptr(fpst); | ||
603 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
604 | frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm); | ||
605 | |||
606 | vd = tcg_temp_new_i32(); | ||
607 | - neon_load_reg32(vd, a->vd); | ||
608 | + vfp_load_reg32(vd, a->vd); | ||
609 | |||
610 | fpst = fpstatus_ptr(FPST_FPCR); | ||
611 | shift = tcg_const_i32(frac_bits); | ||
612 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
613 | g_assert_not_reached(); | ||
614 | } | ||
615 | |||
616 | - neon_store_reg32(vd, a->vd); | ||
617 | + vfp_store_reg32(vd, a->vd); | ||
618 | tcg_temp_free_i32(vd); | ||
619 | tcg_temp_free_i32(shift); | ||
620 | tcg_temp_free_ptr(fpst); | ||
621 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_hp_int(DisasContext *s, arg_VCVT_sp_int *a) | ||
622 | |||
623 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
624 | vm = tcg_temp_new_i32(); | ||
625 | - neon_load_reg32(vm, a->vm); | ||
626 | + vfp_load_reg32(vm, a->vm); | ||
627 | |||
628 | if (a->s) { | ||
629 | if (a->rz) { | ||
630 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_hp_int(DisasContext *s, arg_VCVT_sp_int *a) | ||
631 | gen_helper_vfp_touih(vm, vm, fpst); | ||
632 | } | ||
633 | } | ||
634 | - neon_store_reg32(vm, a->vd); | ||
635 | + vfp_store_reg32(vm, a->vd); | ||
636 | tcg_temp_free_i32(vm); | ||
637 | tcg_temp_free_ptr(fpst); | ||
638 | return true; | ||
639 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a) | ||
640 | |||
641 | fpst = fpstatus_ptr(FPST_FPCR); | ||
642 | vm = tcg_temp_new_i32(); | ||
643 | - neon_load_reg32(vm, a->vm); | ||
644 | + vfp_load_reg32(vm, a->vm); | ||
645 | |||
646 | if (a->s) { | ||
647 | if (a->rz) { | ||
648 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a) | ||
649 | gen_helper_vfp_touis(vm, vm, fpst); | ||
650 | } | ||
651 | } | ||
652 | - neon_store_reg32(vm, a->vd); | ||
653 | + vfp_store_reg32(vm, a->vd); | ||
654 | tcg_temp_free_i32(vm); | ||
655 | tcg_temp_free_ptr(fpst); | ||
656 | return true; | ||
657 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a) | ||
658 | gen_helper_vfp_touid(vd, vm, fpst); | ||
659 | } | ||
660 | } | ||
661 | - neon_store_reg32(vd, a->vd); | ||
662 | + vfp_store_reg32(vd, a->vd); | ||
663 | tcg_temp_free_i32(vd); | ||
664 | tcg_temp_free_i64(vm); | ||
665 | tcg_temp_free_ptr(fpst); | ||
666 | @@ -XXX,XX +XXX,XX @@ static bool trans_VINS(DisasContext *s, arg_VINS *a) | ||
667 | /* Insert low half of Vm into high half of Vd */ | ||
668 | rm = tcg_temp_new_i32(); | ||
669 | rd = tcg_temp_new_i32(); | ||
670 | - neon_load_reg32(rm, a->vm); | ||
671 | - neon_load_reg32(rd, a->vd); | ||
672 | + vfp_load_reg32(rm, a->vm); | ||
673 | + vfp_load_reg32(rd, a->vd); | ||
674 | tcg_gen_deposit_i32(rd, rd, rm, 16, 16); | ||
675 | - neon_store_reg32(rd, a->vd); | ||
676 | + vfp_store_reg32(rd, a->vd); | ||
677 | tcg_temp_free_i32(rm); | ||
678 | tcg_temp_free_i32(rd); | ||
679 | return true; | ||
680 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOVX(DisasContext *s, arg_VINS *a) | ||
681 | |||
682 | /* Set Vd to high half of Vm */ | ||
683 | rm = tcg_temp_new_i32(); | ||
684 | - neon_load_reg32(rm, a->vm); | ||
685 | + vfp_load_reg32(rm, a->vm); | ||
686 | tcg_gen_shri_i32(rm, rm, 16); | ||
687 | - neon_store_reg32(rm, a->vd); | ||
688 | + vfp_store_reg32(rm, a->vd); | ||
689 | tcg_temp_free_i32(rm); | ||
690 | return true; | ||
691 | } | ||
692 | -- | 64 | -- |
693 | 2.20.1 | 65 | 2.25.1 |
694 | |||
695 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This function makes it clear that we're talking about the whole | 3 | Create a new wrapper function that passes the default |
4 | register, and not the 32-bit piece at index 0. This fixes a bug | 4 | exception target to gen_exception_el. |
5 | when running on a big-endian host. | ||
6 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20201030022618.785675-2-richard.henderson@linaro.org | 8 | Message-id: 20220609202901.1177572-18-richard.henderson@linaro.org |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/translate.c | 8 ++++++ | 11 | target/arm/translate.c | 11 +++++++---- |
13 | target/arm/translate-neon.c.inc | 44 ++++++++++++++++----------------- | 12 | 1 file changed, 7 insertions(+), 4 deletions(-) |
14 | target/arm/translate-vfp.c.inc | 2 +- | ||
15 | 3 files changed, 31 insertions(+), 23 deletions(-) | ||
16 | 13 | ||
17 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate.c | 16 | --- a/target/arm/translate.c |
20 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/translate.c |
21 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | 18 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_el(int excp, uint32_t syndrome, uint32_t target_el) |
22 | unallocated_encoding(s); | 19 | tcg_constant_i32(target_el)); |
23 | } | 20 | } |
24 | 21 | ||
25 | +/* | 22 | +static void gen_exception(DisasContext *s, int excp, uint32_t syndrome) |
26 | + * Return the offset of a "full" NEON Dreg. | ||
27 | + */ | ||
28 | +static long neon_full_reg_offset(unsigned reg) | ||
29 | +{ | 23 | +{ |
30 | + return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); | 24 | + gen_exception_el(excp, syndrome, default_exception_el(s)); |
31 | +} | 25 | +} |
32 | + | 26 | + |
33 | static inline long vfp_reg_offset(bool dp, unsigned reg) | 27 | static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp, |
28 | uint32_t syn, TCGv_i32 tcg_el) | ||
34 | { | 29 | { |
35 | if (dp) { | 30 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) |
36 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 31 | switch (dc->base.is_jmp) { |
37 | index XXXXXXX..XXXXXXX 100644 | 32 | case DISAS_SWI: |
38 | --- a/target/arm/translate-neon.c.inc | 33 | gen_ss_advance(dc); |
39 | +++ b/target/arm/translate-neon.c.inc | 34 | - gen_exception_el(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), |
40 | @@ -XXX,XX +XXX,XX @@ neon_element_offset(int reg, int element, MemOp size) | 35 | - default_exception_el(dc)); |
41 | ofs ^= 8 - element_size; | 36 | + gen_exception(dc, EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb)); |
42 | } | 37 | break; |
43 | #endif | 38 | case DISAS_HVC: |
44 | - return neon_reg_offset(reg, 0) + ofs; | 39 | gen_ss_advance(dc); |
45 | + return neon_full_reg_offset(reg) + ofs; | 40 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) |
46 | } | 41 | gen_helper_yield(cpu_env); |
47 | 42 | break; | |
48 | static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop) | 43 | case DISAS_SWI: |
49 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | 44 | - gen_exception_el(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), |
50 | * We cannot write 16 bytes at once because the | 45 | - default_exception_el(dc)); |
51 | * destination is unaligned. | 46 | + gen_exception(dc, EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb)); |
52 | */ | 47 | break; |
53 | - tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0), | 48 | case DISAS_HVC: |
54 | + tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(vd), | 49 | gen_exception_el(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); |
55 | 8, 8, tmp); | ||
56 | - tcg_gen_gvec_mov(0, neon_reg_offset(vd + 1, 0), | ||
57 | - neon_reg_offset(vd, 0), 8, 8); | ||
58 | + tcg_gen_gvec_mov(0, neon_full_reg_offset(vd + 1), | ||
59 | + neon_full_reg_offset(vd), 8, 8); | ||
60 | } else { | ||
61 | - tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0), | ||
62 | + tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(vd), | ||
63 | vec_size, vec_size, tmp); | ||
64 | } | ||
65 | tcg_gen_addi_i32(addr, addr, 1 << size); | ||
66 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | ||
67 | static bool do_3same(DisasContext *s, arg_3same *a, GVecGen3Fn fn) | ||
68 | { | ||
69 | int vec_size = a->q ? 16 : 8; | ||
70 | - int rd_ofs = neon_reg_offset(a->vd, 0); | ||
71 | - int rn_ofs = neon_reg_offset(a->vn, 0); | ||
72 | - int rm_ofs = neon_reg_offset(a->vm, 0); | ||
73 | + int rd_ofs = neon_full_reg_offset(a->vd); | ||
74 | + int rn_ofs = neon_full_reg_offset(a->vn); | ||
75 | + int rm_ofs = neon_full_reg_offset(a->vm); | ||
76 | |||
77 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
78 | return false; | ||
79 | @@ -XXX,XX +XXX,XX @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | ||
80 | { | ||
81 | /* Handle a 2-reg-shift insn which can be vectorized. */ | ||
82 | int vec_size = a->q ? 16 : 8; | ||
83 | - int rd_ofs = neon_reg_offset(a->vd, 0); | ||
84 | - int rm_ofs = neon_reg_offset(a->vm, 0); | ||
85 | + int rd_ofs = neon_full_reg_offset(a->vd); | ||
86 | + int rm_ofs = neon_full_reg_offset(a->vm); | ||
87 | |||
88 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
89 | return false; | ||
90 | @@ -XXX,XX +XXX,XX @@ static bool do_fp_2sh(DisasContext *s, arg_2reg_shift *a, | ||
91 | { | ||
92 | /* FP operations in 2-reg-and-shift group */ | ||
93 | int vec_size = a->q ? 16 : 8; | ||
94 | - int rd_ofs = neon_reg_offset(a->vd, 0); | ||
95 | - int rm_ofs = neon_reg_offset(a->vm, 0); | ||
96 | + int rd_ofs = neon_full_reg_offset(a->vd); | ||
97 | + int rm_ofs = neon_full_reg_offset(a->vm); | ||
98 | TCGv_ptr fpst; | ||
99 | |||
100 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
101 | @@ -XXX,XX +XXX,XX @@ static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a, | ||
102 | return true; | ||
103 | } | ||
104 | |||
105 | - reg_ofs = neon_reg_offset(a->vd, 0); | ||
106 | + reg_ofs = neon_full_reg_offset(a->vd); | ||
107 | vec_size = a->q ? 16 : 8; | ||
108 | imm = asimd_imm_const(a->imm, a->cmode, a->op); | ||
109 | |||
110 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMULL_P_3d(DisasContext *s, arg_3diff *a) | ||
111 | return true; | ||
112 | } | ||
113 | |||
114 | - tcg_gen_gvec_3_ool(neon_reg_offset(a->vd, 0), | ||
115 | - neon_reg_offset(a->vn, 0), | ||
116 | - neon_reg_offset(a->vm, 0), | ||
117 | + tcg_gen_gvec_3_ool(neon_full_reg_offset(a->vd), | ||
118 | + neon_full_reg_offset(a->vn), | ||
119 | + neon_full_reg_offset(a->vm), | ||
120 | 16, 16, 0, fn_gvec); | ||
121 | return true; | ||
122 | } | ||
123 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar_fp_vec(DisasContext *s, arg_2scalar *a, | ||
124 | { | ||
125 | /* Two registers and a scalar, using gvec */ | ||
126 | int vec_size = a->q ? 16 : 8; | ||
127 | - int rd_ofs = neon_reg_offset(a->vd, 0); | ||
128 | - int rn_ofs = neon_reg_offset(a->vn, 0); | ||
129 | + int rd_ofs = neon_full_reg_offset(a->vd); | ||
130 | + int rn_ofs = neon_full_reg_offset(a->vn); | ||
131 | int rm_ofs; | ||
132 | int idx; | ||
133 | TCGv_ptr fpstatus; | ||
134 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar_fp_vec(DisasContext *s, arg_2scalar *a, | ||
135 | /* a->vm is M:Vm, which encodes both register and index */ | ||
136 | idx = extract32(a->vm, a->size + 2, 2); | ||
137 | a->vm = extract32(a->vm, 0, a->size + 2); | ||
138 | - rm_ofs = neon_reg_offset(a->vm, 0); | ||
139 | + rm_ofs = neon_full_reg_offset(a->vm); | ||
140 | |||
141 | fpstatus = fpstatus_ptr(a->size == 1 ? FPST_STD_F16 : FPST_STD); | ||
142 | tcg_gen_gvec_3_ptr(rd_ofs, rn_ofs, rm_ofs, fpstatus, | ||
143 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDUP_scalar(DisasContext *s, arg_VDUP_scalar *a) | ||
144 | return true; | ||
145 | } | ||
146 | |||
147 | - tcg_gen_gvec_dup_mem(a->size, neon_reg_offset(a->vd, 0), | ||
148 | + tcg_gen_gvec_dup_mem(a->size, neon_full_reg_offset(a->vd), | ||
149 | neon_element_offset(a->vm, a->index, a->size), | ||
150 | a->q ? 16 : 8, a->q ? 16 : 8); | ||
151 | return true; | ||
152 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_F32_F16(DisasContext *s, arg_2misc *a) | ||
153 | static bool do_2misc_vec(DisasContext *s, arg_2misc *a, GVecGen2Fn *fn) | ||
154 | { | ||
155 | int vec_size = a->q ? 16 : 8; | ||
156 | - int rd_ofs = neon_reg_offset(a->vd, 0); | ||
157 | - int rm_ofs = neon_reg_offset(a->vm, 0); | ||
158 | + int rd_ofs = neon_full_reg_offset(a->vd); | ||
159 | + int rm_ofs = neon_full_reg_offset(a->vm); | ||
160 | |||
161 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
162 | return false; | ||
163 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/target/arm/translate-vfp.c.inc | ||
166 | +++ b/target/arm/translate-vfp.c.inc | ||
167 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
168 | } | ||
169 | |||
170 | tmp = load_reg(s, a->rt); | ||
171 | - tcg_gen_gvec_dup_i32(size, neon_reg_offset(a->vn, 0), | ||
172 | + tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(a->vn), | ||
173 | vec_size, vec_size, tmp); | ||
174 | tcg_temp_free_i32(tmp); | ||
175 | |||
176 | -- | 50 | -- |
177 | 2.20.1 | 51 | 2.25.1 |
178 | |||
179 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This seems a bit more readable than using offsetof CPU_DoubleU. | 3 | Split out a common helper function for gen_exception_el |
4 | and gen_exception_insn_el_v. | ||
4 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20201030022618.785675-5-richard.henderson@linaro.org | 8 | Message-id: 20220609202901.1177572-19-richard.henderson@linaro.org |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | target/arm/translate.c | 13 ++++--------- | 11 | target/arm/translate.c | 13 ++++++++----- |
11 | 1 file changed, 4 insertions(+), 9 deletions(-) | 12 | 1 file changed, 8 insertions(+), 5 deletions(-) |
12 | 13 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 16 | --- a/target/arm/translate.c |
16 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/translate.c |
17 | @@ -XXX,XX +XXX,XX @@ static long neon_element_offset(int reg, int element, MemOp size) | 18 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp) |
18 | return neon_full_reg_offset(reg) + ofs; | 19 | s->base.is_jmp = DISAS_NORETURN; |
19 | } | 20 | } |
20 | 21 | ||
21 | -static inline long vfp_reg_offset(bool dp, unsigned reg) | 22 | -static void gen_exception_el(int excp, uint32_t syndrome, uint32_t target_el) |
22 | +/* Return the offset of a VFP Dreg (dp = true) or VFP Sreg (dp = false). */ | 23 | +static void gen_exception_el_v(int excp, uint32_t syndrome, TCGv_i32 tcg_el) |
23 | +static long vfp_reg_offset(bool dp, unsigned reg) | ||
24 | { | 24 | { |
25 | if (dp) { | 25 | gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp), |
26 | - return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); | 26 | - tcg_constant_i32(syndrome), |
27 | + return neon_element_offset(reg, 0, MO_64); | 27 | - tcg_constant_i32(target_el)); |
28 | } else { | 28 | + tcg_constant_i32(syndrome), tcg_el); |
29 | - long ofs = offsetof(CPUARMState, vfp.zregs[reg >> 2].d[(reg >> 1) & 1]); | 29 | +} |
30 | - if (reg & 1) { | 30 | + |
31 | - ofs += offsetof(CPU_DoubleU, l.upper); | 31 | +static void gen_exception_el(int excp, uint32_t syndrome, uint32_t target_el) |
32 | - } else { | 32 | +{ |
33 | - ofs += offsetof(CPU_DoubleU, l.lower); | 33 | + gen_exception_el_v(excp, syndrome, tcg_constant_i32(target_el)); |
34 | - } | 34 | } |
35 | - return ofs; | 35 | |
36 | + return neon_element_offset(reg >> 1, reg & 1, MO_32); | 36 | static void gen_exception(DisasContext *s, int excp, uint32_t syndrome) |
37 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp, | ||
38 | gen_set_condexec(s); | ||
39 | gen_set_pc_im(s, pc); | ||
37 | } | 40 | } |
41 | - gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp), | ||
42 | - tcg_constant_i32(syn), tcg_el); | ||
43 | + gen_exception_el_v(excp, syn, tcg_el); | ||
44 | s->base.is_jmp = DISAS_NORETURN; | ||
38 | } | 45 | } |
39 | 46 | ||
40 | -- | 47 | -- |
41 | 2.20.1 | 48 | 2.25.1 |
42 | |||
43 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The only uses of this function are for loading VFP | 3 | With the helper we can use exception_target_el at runtime, |
4 | double-precision values, and nothing to do with NEON. | 4 | instead of default_exception_el at translate time. |
5 | While we're at it, remove the DisasContext parameter from | ||
6 | gen_exception, as it is no longer used. | ||
5 | 7 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201030022618.785675-10-richard.henderson@linaro.org | 10 | Message-id: 20220609202901.1177572-20-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | target/arm/translate.c | 8 ++-- | 13 | target/arm/helper.h | 1 + |
12 | target/arm/translate-vfp.c.inc | 84 +++++++++++++++++----------------- | 14 | target/arm/op_helper.c | 10 ++++++++++ |
13 | 2 files changed, 46 insertions(+), 46 deletions(-) | 15 | target/arm/translate.c | 18 +++++++++++++----- |
16 | 3 files changed, 24 insertions(+), 5 deletions(-) | ||
14 | 17 | ||
18 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper.h | ||
21 | +++ b/target/arm/helper.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(usad8, TCG_CALL_NO_RWG_SE, i32, i32, i32) | ||
23 | DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE, | ||
24 | i32, i32, i32, i32) | ||
25 | DEF_HELPER_2(exception_internal, noreturn, env, i32) | ||
26 | +DEF_HELPER_3(exception_with_syndrome, noreturn, env, i32, i32) | ||
27 | DEF_HELPER_4(exception_with_syndrome_el, noreturn, env, i32, i32, i32) | ||
28 | DEF_HELPER_2(exception_bkpt_insn, noreturn, env, i32) | ||
29 | DEF_HELPER_2(exception_swstep, noreturn, env, i32) | ||
30 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/op_helper.c | ||
33 | +++ b/target/arm/op_helper.c | ||
34 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_with_syndrome_el)(CPUARMState *env, uint32_t excp, | ||
35 | raise_exception(env, excp, syndrome, target_el); | ||
36 | } | ||
37 | |||
38 | +/* | ||
39 | + * Raise an exception with the specified syndrome register value | ||
40 | + * to the default target el. | ||
41 | + */ | ||
42 | +void HELPER(exception_with_syndrome)(CPUARMState *env, uint32_t excp, | ||
43 | + uint32_t syndrome) | ||
44 | +{ | ||
45 | + raise_exception(env, excp, syndrome, exception_target_el(env)); | ||
46 | +} | ||
47 | + | ||
48 | uint32_t HELPER(cpsr_read)(CPUARMState *env) | ||
49 | { | ||
50 | return cpsr_read(env) & ~CPSR_EXEC; | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 51 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
16 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 53 | --- a/target/arm/translate.c |
18 | +++ b/target/arm/translate.c | 54 | +++ b/target/arm/translate.c |
19 | @@ -XXX,XX +XXX,XX @@ static long vfp_reg_offset(bool dp, unsigned reg) | 55 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_el(int excp, uint32_t syndrome, uint32_t target_el) |
20 | } | 56 | gen_exception_el_v(excp, syndrome, tcg_constant_i32(target_el)); |
21 | } | 57 | } |
22 | 58 | ||
23 | -static inline void neon_load_reg64(TCGv_i64 var, int reg) | 59 | -static void gen_exception(DisasContext *s, int excp, uint32_t syndrome) |
24 | +static inline void vfp_load_reg64(TCGv_i64 var, int reg) | 60 | +static void gen_exception(int excp, uint32_t syndrome) |
25 | { | 61 | { |
26 | - tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 62 | - gen_exception_el(excp, syndrome, default_exception_el(s)); |
27 | + tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(true, reg)); | 63 | + gen_helper_exception_with_syndrome(cpu_env, tcg_constant_i32(excp), |
64 | + tcg_constant_i32(syndrome)); | ||
28 | } | 65 | } |
29 | 66 | ||
30 | -static inline void neon_store_reg64(TCGv_i64 var, int reg) | 67 | static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp, |
31 | +static inline void vfp_store_reg64(TCGv_i64 var, int reg) | 68 | @@ -XXX,XX +XXX,XX @@ void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp, |
69 | |||
70 | void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, uint32_t syn) | ||
32 | { | 71 | { |
33 | - tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 72 | - gen_exception_insn_el(s, pc, excp, syn, default_exception_el(s)); |
34 | + tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(true, reg)); | 73 | + if (s->aarch64) { |
74 | + gen_a64_set_pc_im(pc); | ||
75 | + } else { | ||
76 | + gen_set_condexec(s); | ||
77 | + gen_set_pc_im(s, pc); | ||
78 | + } | ||
79 | + gen_exception(excp, syn); | ||
80 | + s->base.is_jmp = DISAS_NORETURN; | ||
35 | } | 81 | } |
36 | 82 | ||
37 | static inline void vfp_load_reg32(TCGv_i32 var, int reg) | 83 | static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) |
38 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | 84 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) |
39 | index XXXXXXX..XXXXXXX 100644 | 85 | switch (dc->base.is_jmp) { |
40 | --- a/target/arm/translate-vfp.c.inc | 86 | case DISAS_SWI: |
41 | +++ b/target/arm/translate-vfp.c.inc | 87 | gen_ss_advance(dc); |
42 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | 88 | - gen_exception(dc, EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb)); |
43 | tcg_gen_ext_i32_i64(nf, cpu_NF); | 89 | + gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb)); |
44 | tcg_gen_ext_i32_i64(vf, cpu_VF); | ||
45 | |||
46 | - neon_load_reg64(frn, rn); | ||
47 | - neon_load_reg64(frm, rm); | ||
48 | + vfp_load_reg64(frn, rn); | ||
49 | + vfp_load_reg64(frm, rm); | ||
50 | switch (a->cc) { | ||
51 | case 0: /* eq: Z */ | ||
52 | tcg_gen_movcond_i64(TCG_COND_EQ, dest, zf, zero, | ||
53 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
54 | tcg_temp_free_i64(tmp); | ||
55 | break; | 90 | break; |
56 | } | 91 | case DISAS_HVC: |
57 | - neon_store_reg64(dest, rd); | 92 | gen_ss_advance(dc); |
58 | + vfp_store_reg64(dest, rd); | 93 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) |
59 | tcg_temp_free_i64(frn); | 94 | gen_helper_yield(cpu_env); |
60 | tcg_temp_free_i64(frm); | ||
61 | tcg_temp_free_i64(dest); | ||
62 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) | ||
63 | TCGv_i64 tcg_res; | ||
64 | tcg_op = tcg_temp_new_i64(); | ||
65 | tcg_res = tcg_temp_new_i64(); | ||
66 | - neon_load_reg64(tcg_op, rm); | ||
67 | + vfp_load_reg64(tcg_op, rm); | ||
68 | gen_helper_rintd(tcg_res, tcg_op, fpst); | ||
69 | - neon_store_reg64(tcg_res, rd); | ||
70 | + vfp_store_reg64(tcg_res, rd); | ||
71 | tcg_temp_free_i64(tcg_op); | ||
72 | tcg_temp_free_i64(tcg_res); | ||
73 | } else { | ||
74 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
75 | tcg_double = tcg_temp_new_i64(); | ||
76 | tcg_res = tcg_temp_new_i64(); | ||
77 | tcg_tmp = tcg_temp_new_i32(); | ||
78 | - neon_load_reg64(tcg_double, rm); | ||
79 | + vfp_load_reg64(tcg_double, rm); | ||
80 | if (is_signed) { | ||
81 | gen_helper_vfp_tosld(tcg_res, tcg_double, tcg_shift, fpst); | ||
82 | } else { | ||
83 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a) | ||
84 | tmp = tcg_temp_new_i64(); | ||
85 | if (a->l) { | ||
86 | gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); | ||
87 | - neon_store_reg64(tmp, a->vd); | ||
88 | + vfp_store_reg64(tmp, a->vd); | ||
89 | } else { | ||
90 | - neon_load_reg64(tmp, a->vd); | ||
91 | + vfp_load_reg64(tmp, a->vd); | ||
92 | gen_aa32_st64(s, tmp, addr, get_mem_index(s)); | ||
93 | } | ||
94 | tcg_temp_free_i64(tmp); | ||
95 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) | ||
96 | if (a->l) { | ||
97 | /* load */ | ||
98 | gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); | ||
99 | - neon_store_reg64(tmp, a->vd + i); | ||
100 | + vfp_store_reg64(tmp, a->vd + i); | ||
101 | } else { | ||
102 | /* store */ | ||
103 | - neon_load_reg64(tmp, a->vd + i); | ||
104 | + vfp_load_reg64(tmp, a->vd + i); | ||
105 | gen_aa32_st64(s, tmp, addr, get_mem_index(s)); | ||
106 | } | ||
107 | tcg_gen_addi_i32(addr, addr, offset); | ||
108 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, | ||
109 | fd = tcg_temp_new_i64(); | ||
110 | fpst = fpstatus_ptr(FPST_FPCR); | ||
111 | |||
112 | - neon_load_reg64(f0, vn); | ||
113 | - neon_load_reg64(f1, vm); | ||
114 | + vfp_load_reg64(f0, vn); | ||
115 | + vfp_load_reg64(f1, vm); | ||
116 | |||
117 | for (;;) { | ||
118 | if (reads_vd) { | ||
119 | - neon_load_reg64(fd, vd); | ||
120 | + vfp_load_reg64(fd, vd); | ||
121 | } | ||
122 | fn(fd, f0, f1, fpst); | ||
123 | - neon_store_reg64(fd, vd); | ||
124 | + vfp_store_reg64(fd, vd); | ||
125 | |||
126 | if (veclen == 0) { | ||
127 | break; | 95 | break; |
128 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, | 96 | case DISAS_SWI: |
129 | veclen--; | 97 | - gen_exception(dc, EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb)); |
130 | vd = vfp_advance_dreg(vd, delta_d); | 98 | + gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb)); |
131 | vn = vfp_advance_dreg(vn, delta_d); | ||
132 | - neon_load_reg64(f0, vn); | ||
133 | + vfp_load_reg64(f0, vn); | ||
134 | if (delta_m) { | ||
135 | vm = vfp_advance_dreg(vm, delta_m); | ||
136 | - neon_load_reg64(f1, vm); | ||
137 | + vfp_load_reg64(f1, vm); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) | ||
142 | f0 = tcg_temp_new_i64(); | ||
143 | fd = tcg_temp_new_i64(); | ||
144 | |||
145 | - neon_load_reg64(f0, vm); | ||
146 | + vfp_load_reg64(f0, vm); | ||
147 | |||
148 | for (;;) { | ||
149 | fn(fd, f0); | ||
150 | - neon_store_reg64(fd, vd); | ||
151 | + vfp_store_reg64(fd, vd); | ||
152 | |||
153 | if (veclen == 0) { | ||
154 | break; | 99 | break; |
155 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) | 100 | case DISAS_HVC: |
156 | /* single source one-many */ | 101 | gen_exception_el(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); |
157 | while (veclen--) { | ||
158 | vd = vfp_advance_dreg(vd, delta_d); | ||
159 | - neon_store_reg64(fd, vd); | ||
160 | + vfp_store_reg64(fd, vd); | ||
161 | } | ||
162 | break; | ||
163 | } | ||
164 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) | ||
165 | veclen--; | ||
166 | vd = vfp_advance_dreg(vd, delta_d); | ||
167 | vd = vfp_advance_dreg(vm, delta_m); | ||
168 | - neon_load_reg64(f0, vm); | ||
169 | + vfp_load_reg64(f0, vm); | ||
170 | } | ||
171 | |||
172 | tcg_temp_free_i64(f0); | ||
173 | @@ -XXX,XX +XXX,XX @@ static bool do_vfm_dp(DisasContext *s, arg_VFMA_dp *a, bool neg_n, bool neg_d) | ||
174 | vm = tcg_temp_new_i64(); | ||
175 | vd = tcg_temp_new_i64(); | ||
176 | |||
177 | - neon_load_reg64(vn, a->vn); | ||
178 | - neon_load_reg64(vm, a->vm); | ||
179 | + vfp_load_reg64(vn, a->vn); | ||
180 | + vfp_load_reg64(vm, a->vm); | ||
181 | if (neg_n) { | ||
182 | /* VFNMS, VFMS */ | ||
183 | gen_helper_vfp_negd(vn, vn); | ||
184 | } | ||
185 | - neon_load_reg64(vd, a->vd); | ||
186 | + vfp_load_reg64(vd, a->vd); | ||
187 | if (neg_d) { | ||
188 | /* VFNMA, VFNMS */ | ||
189 | gen_helper_vfp_negd(vd, vd); | ||
190 | } | ||
191 | fpst = fpstatus_ptr(FPST_FPCR); | ||
192 | gen_helper_vfp_muladdd(vd, vn, vm, vd, fpst); | ||
193 | - neon_store_reg64(vd, a->vd); | ||
194 | + vfp_store_reg64(vd, a->vd); | ||
195 | |||
196 | tcg_temp_free_ptr(fpst); | ||
197 | tcg_temp_free_i64(vn); | ||
198 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) | ||
199 | fd = tcg_const_i64(vfp_expand_imm(MO_64, a->imm)); | ||
200 | |||
201 | for (;;) { | ||
202 | - neon_store_reg64(fd, vd); | ||
203 | + vfp_store_reg64(fd, vd); | ||
204 | |||
205 | if (veclen == 0) { | ||
206 | break; | ||
207 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_dp(DisasContext *s, arg_VCMP_dp *a) | ||
208 | vd = tcg_temp_new_i64(); | ||
209 | vm = tcg_temp_new_i64(); | ||
210 | |||
211 | - neon_load_reg64(vd, a->vd); | ||
212 | + vfp_load_reg64(vd, a->vd); | ||
213 | if (a->z) { | ||
214 | tcg_gen_movi_i64(vm, 0); | ||
215 | } else { | ||
216 | - neon_load_reg64(vm, a->vm); | ||
217 | + vfp_load_reg64(vm, a->vm); | ||
218 | } | ||
219 | |||
220 | if (a->e) { | ||
221 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) | ||
222 | tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t)); | ||
223 | vd = tcg_temp_new_i64(); | ||
224 | gen_helper_vfp_fcvt_f16_to_f64(vd, tmp, fpst, ahp_mode); | ||
225 | - neon_store_reg64(vd, a->vd); | ||
226 | + vfp_store_reg64(vd, a->vd); | ||
227 | tcg_temp_free_i32(ahp_mode); | ||
228 | tcg_temp_free_ptr(fpst); | ||
229 | tcg_temp_free_i32(tmp); | ||
230 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a) | ||
231 | tmp = tcg_temp_new_i32(); | ||
232 | vm = tcg_temp_new_i64(); | ||
233 | |||
234 | - neon_load_reg64(vm, a->vm); | ||
235 | + vfp_load_reg64(vm, a->vm); | ||
236 | gen_helper_vfp_fcvt_f64_to_f16(tmp, vm, fpst, ahp_mode); | ||
237 | tcg_temp_free_i64(vm); | ||
238 | tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t)); | ||
239 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_dp(DisasContext *s, arg_VRINTR_dp *a) | ||
240 | } | ||
241 | |||
242 | tmp = tcg_temp_new_i64(); | ||
243 | - neon_load_reg64(tmp, a->vm); | ||
244 | + vfp_load_reg64(tmp, a->vm); | ||
245 | fpst = fpstatus_ptr(FPST_FPCR); | ||
246 | gen_helper_rintd(tmp, tmp, fpst); | ||
247 | - neon_store_reg64(tmp, a->vd); | ||
248 | + vfp_store_reg64(tmp, a->vd); | ||
249 | tcg_temp_free_ptr(fpst); | ||
250 | tcg_temp_free_i64(tmp); | ||
251 | return true; | ||
252 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_dp(DisasContext *s, arg_VRINTZ_dp *a) | ||
253 | } | ||
254 | |||
255 | tmp = tcg_temp_new_i64(); | ||
256 | - neon_load_reg64(tmp, a->vm); | ||
257 | + vfp_load_reg64(tmp, a->vm); | ||
258 | fpst = fpstatus_ptr(FPST_FPCR); | ||
259 | tcg_rmode = tcg_const_i32(float_round_to_zero); | ||
260 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
261 | gen_helper_rintd(tmp, tmp, fpst); | ||
262 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
263 | - neon_store_reg64(tmp, a->vd); | ||
264 | + vfp_store_reg64(tmp, a->vd); | ||
265 | tcg_temp_free_ptr(fpst); | ||
266 | tcg_temp_free_i64(tmp); | ||
267 | tcg_temp_free_i32(tcg_rmode); | ||
268 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a) | ||
269 | } | ||
270 | |||
271 | tmp = tcg_temp_new_i64(); | ||
272 | - neon_load_reg64(tmp, a->vm); | ||
273 | + vfp_load_reg64(tmp, a->vm); | ||
274 | fpst = fpstatus_ptr(FPST_FPCR); | ||
275 | gen_helper_rintd_exact(tmp, tmp, fpst); | ||
276 | - neon_store_reg64(tmp, a->vd); | ||
277 | + vfp_store_reg64(tmp, a->vd); | ||
278 | tcg_temp_free_ptr(fpst); | ||
279 | tcg_temp_free_i64(tmp); | ||
280 | return true; | ||
281 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a) | ||
282 | vd = tcg_temp_new_i64(); | ||
283 | vfp_load_reg32(vm, a->vm); | ||
284 | gen_helper_vfp_fcvtds(vd, vm, cpu_env); | ||
285 | - neon_store_reg64(vd, a->vd); | ||
286 | + vfp_store_reg64(vd, a->vd); | ||
287 | tcg_temp_free_i32(vm); | ||
288 | tcg_temp_free_i64(vd); | ||
289 | return true; | ||
290 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) | ||
291 | |||
292 | vd = tcg_temp_new_i32(); | ||
293 | vm = tcg_temp_new_i64(); | ||
294 | - neon_load_reg64(vm, a->vm); | ||
295 | + vfp_load_reg64(vm, a->vm); | ||
296 | gen_helper_vfp_fcvtsd(vd, vm, cpu_env); | ||
297 | vfp_store_reg32(vd, a->vd); | ||
298 | tcg_temp_free_i32(vd); | ||
299 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a) | ||
300 | /* u32 -> f64 */ | ||
301 | gen_helper_vfp_uitod(vd, vm, fpst); | ||
302 | } | ||
303 | - neon_store_reg64(vd, a->vd); | ||
304 | + vfp_store_reg64(vd, a->vd); | ||
305 | tcg_temp_free_i32(vm); | ||
306 | tcg_temp_free_i64(vd); | ||
307 | tcg_temp_free_ptr(fpst); | ||
308 | @@ -XXX,XX +XXX,XX @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a) | ||
309 | |||
310 | vm = tcg_temp_new_i64(); | ||
311 | vd = tcg_temp_new_i32(); | ||
312 | - neon_load_reg64(vm, a->vm); | ||
313 | + vfp_load_reg64(vm, a->vm); | ||
314 | gen_helper_vjcvt(vd, vm, cpu_env); | ||
315 | vfp_store_reg32(vd, a->vd); | ||
316 | tcg_temp_free_i64(vm); | ||
317 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
318 | frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm); | ||
319 | |||
320 | vd = tcg_temp_new_i64(); | ||
321 | - neon_load_reg64(vd, a->vd); | ||
322 | + vfp_load_reg64(vd, a->vd); | ||
323 | |||
324 | fpst = fpstatus_ptr(FPST_FPCR); | ||
325 | shift = tcg_const_i32(frac_bits); | ||
326 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
327 | g_assert_not_reached(); | ||
328 | } | ||
329 | |||
330 | - neon_store_reg64(vd, a->vd); | ||
331 | + vfp_store_reg64(vd, a->vd); | ||
332 | tcg_temp_free_i64(vd); | ||
333 | tcg_temp_free_i32(shift); | ||
334 | tcg_temp_free_ptr(fpst); | ||
335 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a) | ||
336 | fpst = fpstatus_ptr(FPST_FPCR); | ||
337 | vm = tcg_temp_new_i64(); | ||
338 | vd = tcg_temp_new_i32(); | ||
339 | - neon_load_reg64(vm, a->vm); | ||
340 | + vfp_load_reg64(vm, a->vm); | ||
341 | |||
342 | if (a->s) { | ||
343 | if (a->rz) { | ||
344 | -- | 102 | -- |
345 | 2.20.1 | 103 | 2.25.1 |
346 | |||
347 | diff view generated by jsdifflib |
1 | The helper functions for performing the udot/sdot operations against | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | a scalar were not using an address-swizzling macro when converting | ||
3 | the index of the scalar element into a pointer into the vm array. | ||
4 | This had no effect on little-endian hosts but meant we generated | ||
5 | incorrect results on big-endian hosts. | ||
6 | 2 | ||
7 | For these insns, the index is indexing over group of 4 8-bit values, | 3 | This function is no longer used. At the same time, remove |
8 | so 32 bits per indexed entity, and H4() is therefore what we want. | 4 | DisasContext.secure_routed_to_el3, as it in turn becomes unused. |
9 | (For Neon the only possible input indexes are 0 and 1.) | ||
10 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220609202901.1177572-21-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Message-id: 20201028191712.4910-3-peter.maydell@linaro.org | ||
15 | --- | 10 | --- |
16 | target/arm/vec_helper.c | 4 ++-- | 11 | target/arm/translate.h | 16 ---------------- |
17 | 1 file changed, 2 insertions(+), 2 deletions(-) | 12 | target/arm/translate-a64.c | 5 ----- |
13 | target/arm/translate.c | 5 ----- | ||
14 | 3 files changed, 26 deletions(-) | ||
18 | 15 | ||
19 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | 16 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/vec_helper.c | 18 | --- a/target/arm/translate.h |
22 | +++ b/target/arm/vec_helper.c | 19 | +++ b/target/arm/translate.h |
23 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_sdot_idx_b)(void *vd, void *vn, void *vm, uint32_t desc) | 20 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { |
24 | intptr_t index = simd_data(desc); | 21 | int fp_excp_el; /* FP exception EL or 0 if enabled */ |
25 | uint32_t *d = vd; | 22 | int sve_excp_el; /* SVE exception EL or 0 if enabled */ |
26 | int8_t *n = vn; | 23 | int vl; /* current vector length in bytes */ |
27 | - int8_t *m_indexed = (int8_t *)vm + index * 4; | 24 | - /* Flag indicating that exceptions from secure mode are routed to EL3. */ |
28 | + int8_t *m_indexed = (int8_t *)vm + H4(index) * 4; | 25 | - bool secure_routed_to_el3; |
29 | 26 | bool vfp_enabled; /* FP enabled via FPSCR.EN */ | |
30 | /* Notice the special case of opr_sz == 8, from aa64/aa32 advsimd. | 27 | int vec_len; |
31 | * Otherwise opr_sz is a multiple of 16. | 28 | int vec_stride; |
32 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_udot_idx_b)(void *vd, void *vn, void *vm, uint32_t desc) | 29 | @@ -XXX,XX +XXX,XX @@ static inline int get_mem_index(DisasContext *s) |
33 | intptr_t index = simd_data(desc); | 30 | return arm_to_core_mmu_idx(s->mmu_idx); |
34 | uint32_t *d = vd; | 31 | } |
35 | uint8_t *n = vn; | 32 | |
36 | - uint8_t *m_indexed = (uint8_t *)vm + index * 4; | 33 | -/* Function used to determine the target exception EL when otherwise not known |
37 | + uint8_t *m_indexed = (uint8_t *)vm + H4(index) * 4; | 34 | - * or default. |
38 | 35 | - */ | |
39 | /* Notice the special case of opr_sz == 8, from aa64/aa32 advsimd. | 36 | -static inline int default_exception_el(DisasContext *s) |
40 | * Otherwise opr_sz is a multiple of 16. | 37 | -{ |
38 | - /* If we are coming from secure EL0 in a system with a 32-bit EL3, then | ||
39 | - * there is no secure EL1, so we route exceptions to EL3. Otherwise, | ||
40 | - * exceptions can only be routed to ELs above 1, so we target the higher of | ||
41 | - * 1 or the current EL. | ||
42 | - */ | ||
43 | - return (s->mmu_idx == ARMMMUIdx_SE10_0 && s->secure_routed_to_el3) | ||
44 | - ? 3 : MAX(1, s->current_el); | ||
45 | -} | ||
46 | - | ||
47 | static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) | ||
48 | { | ||
49 | /* We don't need to save all of the syndrome so we mask and shift | ||
50 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/translate-a64.c | ||
53 | +++ b/target/arm/translate-a64.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
55 | dc->condjmp = 0; | ||
56 | |||
57 | dc->aarch64 = true; | ||
58 | - /* If we are coming from secure EL0 in a system with a 32-bit EL3, then | ||
59 | - * there is no secure EL1, so we route exceptions to EL3. | ||
60 | - */ | ||
61 | - dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) && | ||
62 | - !arm_el_is_aa64(env, 3); | ||
63 | dc->thumb = false; | ||
64 | dc->sctlr_b = 0; | ||
65 | dc->be_data = EX_TBFLAG_ANY(tb_flags, BE_DATA) ? MO_BE : MO_LE; | ||
66 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/translate.c | ||
69 | +++ b/target/arm/translate.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
71 | dc->condjmp = 0; | ||
72 | |||
73 | dc->aarch64 = false; | ||
74 | - /* If we are coming from secure EL0 in a system with a 32-bit EL3, then | ||
75 | - * there is no secure EL1, so we route exceptions to EL3. | ||
76 | - */ | ||
77 | - dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) && | ||
78 | - !arm_el_is_aa64(env, 3); | ||
79 | dc->thumb = EX_TBFLAG_AM32(tb_flags, THUMB); | ||
80 | dc->be_data = EX_TBFLAG_ANY(tb_flags, BE_DATA) ? MO_BE : MO_LE; | ||
81 | condexec = EX_TBFLAG_AM32(tb_flags, CONDEXEC); | ||
41 | -- | 82 | -- |
42 | 2.20.1 | 83 | 2.25.1 |
43 | |||
44 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | These are the only users of neon_reg_offset, so remove that. | 3 | Handle the debug vs current el exception test in one place. |
4 | Leave EXCP_BKPT alone, since that treats debug < current differently. | ||
4 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20201030022618.785675-4-richard.henderson@linaro.org | 8 | Message-id: 20220609202901.1177572-22-richard.henderson@linaro.org |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | target/arm/translate.c | 14 ++------------ | 11 | target/arm/debug_helper.c | 44 +++++++++++++++++++++------------------ |
11 | 1 file changed, 2 insertions(+), 12 deletions(-) | 12 | 1 file changed, 24 insertions(+), 20 deletions(-) |
12 | 13 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 16 | --- a/target/arm/debug_helper.c |
16 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/debug_helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static inline long vfp_reg_offset(bool dp, unsigned reg) | 18 | @@ -XXX,XX +XXX,XX @@ |
19 | #include "exec/helper-proto.h" | ||
20 | |||
21 | |||
22 | +/* | ||
23 | + * Raise an exception to the debug target el. | ||
24 | + * Modify syndrome to indicate when origin and target EL are the same. | ||
25 | + */ | ||
26 | +G_NORETURN static void | ||
27 | +raise_exception_debug(CPUARMState *env, uint32_t excp, uint32_t syndrome) | ||
28 | +{ | ||
29 | + int debug_el = arm_debug_target_el(env); | ||
30 | + int cur_el = arm_current_el(env); | ||
31 | + | ||
32 | + /* | ||
33 | + * If singlestep is targeting a lower EL than the current one, then | ||
34 | + * DisasContext.ss_active must be false and we can never get here. | ||
35 | + * Similarly for watchpoint and breakpoint matches. | ||
36 | + */ | ||
37 | + assert(debug_el >= cur_el); | ||
38 | + syndrome |= (debug_el == cur_el) << ARM_EL_EC_SHIFT; | ||
39 | + raise_exception(env, excp, syndrome, debug_el); | ||
40 | +} | ||
41 | + | ||
42 | /* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */ | ||
43 | static bool aa64_generate_debug_exceptions(CPUARMState *env) | ||
44 | { | ||
45 | @@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs) | ||
46 | if (wp_hit) { | ||
47 | if (wp_hit->flags & BP_CPU) { | ||
48 | bool wnr = (wp_hit->flags & BP_WATCHPOINT_HIT_WRITE) != 0; | ||
49 | - bool same_el = arm_debug_target_el(env) == arm_current_el(env); | ||
50 | |||
51 | cs->watchpoint_hit = NULL; | ||
52 | |||
53 | env->exception.fsr = arm_debug_exception_fsr(env); | ||
54 | env->exception.vaddress = wp_hit->hitaddr; | ||
55 | - raise_exception(env, EXCP_DATA_ABORT, | ||
56 | - syn_watchpoint(same_el, 0, wnr), | ||
57 | - arm_debug_target_el(env)); | ||
58 | + raise_exception_debug(env, EXCP_DATA_ABORT, | ||
59 | + syn_watchpoint(0, 0, wnr)); | ||
60 | } | ||
61 | } else { | ||
62 | uint64_t pc = is_a64(env) ? env->pc : env->regs[15]; | ||
63 | - bool same_el = (arm_debug_target_el(env) == arm_current_el(env)); | ||
64 | |||
65 | /* | ||
66 | * (1) GDB breakpoints should be handled first. | ||
67 | @@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs) | ||
68 | * exception/security level. | ||
69 | */ | ||
70 | env->exception.vaddress = 0; | ||
71 | - raise_exception(env, EXCP_PREFETCH_ABORT, | ||
72 | - syn_breakpoint(same_el), | ||
73 | - arm_debug_target_el(env)); | ||
74 | + raise_exception_debug(env, EXCP_PREFETCH_ABORT, syn_breakpoint(0)); | ||
18 | } | 75 | } |
19 | } | 76 | } |
20 | 77 | ||
21 | -/* Return the offset of a 32-bit piece of a NEON register. | 78 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome) |
22 | - zero is the least significant end of the register. */ | 79 | |
23 | -static inline long | 80 | void HELPER(exception_swstep)(CPUARMState *env, uint32_t syndrome) |
24 | -neon_reg_offset (int reg, int n) | 81 | { |
25 | -{ | 82 | - int debug_el = arm_debug_target_el(env); |
26 | - int sreg; | 83 | - int cur_el = arm_current_el(env); |
27 | - sreg = reg * 2 + n; | ||
28 | - return vfp_reg_offset(0, sreg); | ||
29 | -} | ||
30 | - | 84 | - |
31 | static TCGv_i32 neon_load_reg(int reg, int pass) | 85 | - /* |
32 | { | 86 | - * If singlestep is targeting a lower EL than the current one, then |
33 | TCGv_i32 tmp = tcg_temp_new_i32(); | 87 | - * DisasContext.ss_active must be false and we can never get here. |
34 | - tcg_gen_ld_i32(tmp, cpu_env, neon_reg_offset(reg, pass)); | 88 | - */ |
35 | + tcg_gen_ld_i32(tmp, cpu_env, neon_element_offset(reg, pass, MO_32)); | 89 | - assert(debug_el >= cur_el); |
36 | return tmp; | 90 | - if (debug_el == cur_el) { |
91 | - syndrome |= 1 << ARM_EL_EC_SHIFT; | ||
92 | - } | ||
93 | - raise_exception(env, EXCP_UDEF, syndrome, debug_el); | ||
94 | + raise_exception_debug(env, EXCP_UDEF, syndrome); | ||
37 | } | 95 | } |
38 | 96 | ||
39 | static void neon_store_reg(int reg, int pass, TCGv_i32 var) | 97 | #if !defined(CONFIG_USER_ONLY) |
40 | { | ||
41 | - tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass)); | ||
42 | + tcg_gen_st_i32(var, cpu_env, neon_element_offset(reg, pass, MO_32)); | ||
43 | tcg_temp_free_i32(var); | ||
44 | } | ||
45 | |||
46 | -- | 98 | -- |
47 | 2.20.1 | 99 | 2.25.1 |
48 | |||
49 | diff view generated by jsdifflib |
1 | In the neon_padd/pmax/pmin helpers for float16, a cut-and-paste error | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | meant we were using the H4() address swizzler macro rather than the | ||
3 | H2() which is required for 2-byte data. This had no effect on | ||
4 | little-endian hosts but meant we put the result data into the | ||
5 | destination Dreg in the wrong order on big-endian hosts. | ||
6 | 2 | ||
3 | This function is no longer used outside debug_helper.c. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220609202901.1177572-23-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 20201028191712.4910-2-peter.maydell@linaro.org | ||
11 | --- | 9 | --- |
12 | target/arm/vec_helper.c | 8 ++++---- | 10 | target/arm/cpu.h | 21 --------------------- |
13 | 1 file changed, 4 insertions(+), 4 deletions(-) | 11 | target/arm/debug_helper.c | 21 +++++++++++++++++++++ |
12 | 2 files changed, 21 insertions(+), 21 deletions(-) | ||
14 | 13 | ||
15 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | 14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/vec_helper.c | 16 | --- a/target/arm/cpu.h |
18 | +++ b/target/arm/vec_helper.c | 17 | +++ b/target/arm/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ DO_ABA(gvec_uaba_d, uint64_t) | 18 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMASIdx { |
20 | r2 = float16_##OP(m[H2(0)], m[H2(1)], fpst); \ | 19 | ARMASIdx_TagS = 3, |
21 | r3 = float16_##OP(m[H2(2)], m[H2(3)], fpst); \ | 20 | } ARMASIdx; |
22 | \ | 21 | |
23 | - d[H4(0)] = r0; \ | 22 | -/* Return the Exception Level targeted by debug exceptions. */ |
24 | - d[H4(1)] = r1; \ | 23 | -static inline int arm_debug_target_el(CPUARMState *env) |
25 | - d[H4(2)] = r2; \ | 24 | -{ |
26 | - d[H4(3)] = r3; \ | 25 | - bool secure = arm_is_secure(env); |
27 | + d[H2(0)] = r0; \ | 26 | - bool route_to_el2 = false; |
28 | + d[H2(1)] = r1; \ | 27 | - |
29 | + d[H2(2)] = r2; \ | 28 | - if (arm_is_el2_enabled(env)) { |
30 | + d[H2(3)] = r3; \ | 29 | - route_to_el2 = env->cp15.hcr_el2 & HCR_TGE || |
31 | } | 30 | - env->cp15.mdcr_el2 & MDCR_TDE; |
32 | 31 | - } | |
33 | DO_NEON_PAIRWISE(neon_padd, add) | 32 | - |
33 | - if (route_to_el2) { | ||
34 | - return 2; | ||
35 | - } else if (arm_feature(env, ARM_FEATURE_EL3) && | ||
36 | - !arm_el_is_aa64(env, 3) && secure) { | ||
37 | - return 3; | ||
38 | - } else { | ||
39 | - return 1; | ||
40 | - } | ||
41 | -} | ||
42 | - | ||
43 | static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu) | ||
44 | { | ||
45 | /* If all the CLIDR.Ctypem bits are 0 there are no caches, and | ||
46 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/debug_helper.c | ||
49 | +++ b/target/arm/debug_helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | #include "exec/helper-proto.h" | ||
52 | |||
53 | |||
54 | +/* Return the Exception Level targeted by debug exceptions. */ | ||
55 | +static int arm_debug_target_el(CPUARMState *env) | ||
56 | +{ | ||
57 | + bool secure = arm_is_secure(env); | ||
58 | + bool route_to_el2 = false; | ||
59 | + | ||
60 | + if (arm_is_el2_enabled(env)) { | ||
61 | + route_to_el2 = env->cp15.hcr_el2 & HCR_TGE || | ||
62 | + env->cp15.mdcr_el2 & MDCR_TDE; | ||
63 | + } | ||
64 | + | ||
65 | + if (route_to_el2) { | ||
66 | + return 2; | ||
67 | + } else if (arm_feature(env, ARM_FEATURE_EL3) && | ||
68 | + !arm_el_is_aa64(env, 3) && secure) { | ||
69 | + return 3; | ||
70 | + } else { | ||
71 | + return 1; | ||
72 | + } | ||
73 | +} | ||
74 | + | ||
75 | /* | ||
76 | * Raise an exception to the debug target el. | ||
77 | * Modify syndrome to indicate when origin and target EL are the same. | ||
34 | -- | 78 | -- |
35 | 2.20.1 | 79 | 2.25.1 |
36 | |||
37 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In both cases, we can sink the write-back and perform | 3 | We were using arm_is_secure and is_a64, which are |
4 | the accumulate into the normal destination temps. | 4 | tests against the current EL, as opposed to |
5 | arm_el_is_aa64 and arm_is_secure_below_el3, which | ||
6 | can be applied to a different EL than current. | ||
7 | Consolidate the two tests. | ||
5 | 8 | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201030022618.785675-11-richard.henderson@linaro.org | 11 | Message-id: 20220609202901.1177572-24-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 13 | --- |
11 | target/arm/translate-neon.c.inc | 23 +++++++++-------------- | 14 | target/arm/helper.c | 23 +++++++++-------------- |
12 | 1 file changed, 9 insertions(+), 14 deletions(-) | 15 | 1 file changed, 9 insertions(+), 14 deletions(-) |
13 | 16 | ||
14 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-neon.c.inc | 19 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/translate-neon.c.inc | 20 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static bool do_long_3d(DisasContext *s, arg_3diff *a, | 21 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) |
19 | if (accfn) { | 22 | int fpen = FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, FPEN); |
20 | tmp = tcg_temp_new_i64(); | 23 | |
21 | read_neon_element64(tmp, a->vd, 0, MO_64); | 24 | switch (fpen) { |
22 | - accfn(tmp, tmp, rd0); | 25 | + case 1: |
23 | - write_neon_element64(tmp, a->vd, 0, MO_64); | 26 | + if (cur_el != 0) { |
24 | + accfn(rd0, tmp, rd0); | 27 | + break; |
25 | read_neon_element64(tmp, a->vd, 1, MO_64); | 28 | + } |
26 | - accfn(tmp, tmp, rd1); | 29 | + /* fall through */ |
27 | - write_neon_element64(tmp, a->vd, 1, MO_64); | 30 | case 0: |
28 | + accfn(rd1, tmp, rd1); | 31 | case 2: |
29 | tcg_temp_free_i64(tmp); | 32 | - if (cur_el == 0 || cur_el == 1) { |
30 | - } else { | 33 | - /* Trap to PL1, which might be EL1 or EL3 */ |
31 | - write_neon_element64(rd0, a->vd, 0, MO_64); | 34 | - if (arm_is_secure(env) && !arm_el_is_aa64(env, 3)) { |
32 | - write_neon_element64(rd1, a->vd, 1, MO_64); | 35 | - return 3; |
36 | - } | ||
37 | - return 1; | ||
38 | - } | ||
39 | - if (cur_el == 3 && !is_a64(env)) { | ||
40 | - /* Secure PL1 running at EL3 */ | ||
41 | + /* Trap from Secure PL0 or PL1 to Secure PL1. */ | ||
42 | + if (!arm_el_is_aa64(env, 3) | ||
43 | + && (cur_el == 3 || arm_is_secure_below_el3(env))) { | ||
44 | return 3; | ||
45 | } | ||
46 | - break; | ||
47 | - case 1: | ||
48 | - if (cur_el == 0) { | ||
49 | + if (cur_el <= 1) { | ||
50 | return 1; | ||
51 | } | ||
52 | break; | ||
53 | - case 3: | ||
54 | - break; | ||
55 | } | ||
33 | } | 56 | } |
34 | 57 | ||
35 | + write_neon_element64(rd0, a->vd, 0, MO_64); | ||
36 | + write_neon_element64(rd1, a->vd, 1, MO_64); | ||
37 | tcg_temp_free_i64(rd0); | ||
38 | tcg_temp_free_i64(rd1); | ||
39 | |||
40 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar_long(DisasContext *s, arg_2scalar *a, | ||
41 | if (accfn) { | ||
42 | TCGv_i64 t64 = tcg_temp_new_i64(); | ||
43 | read_neon_element64(t64, a->vd, 0, MO_64); | ||
44 | - accfn(t64, t64, rn0_64); | ||
45 | - write_neon_element64(t64, a->vd, 0, MO_64); | ||
46 | + accfn(rn0_64, t64, rn0_64); | ||
47 | read_neon_element64(t64, a->vd, 1, MO_64); | ||
48 | - accfn(t64, t64, rn1_64); | ||
49 | - write_neon_element64(t64, a->vd, 1, MO_64); | ||
50 | + accfn(rn1_64, t64, rn1_64); | ||
51 | tcg_temp_free_i64(t64); | ||
52 | - } else { | ||
53 | - write_neon_element64(rn0_64, a->vd, 0, MO_64); | ||
54 | - write_neon_element64(rn1_64, a->vd, 1, MO_64); | ||
55 | } | ||
56 | + | ||
57 | + write_neon_element64(rn0_64, a->vd, 0, MO_64); | ||
58 | + write_neon_element64(rn1_64, a->vd, 1, MO_64); | ||
59 | tcg_temp_free_i64(rn0_64); | ||
60 | tcg_temp_free_i64(rn1_64); | ||
61 | return true; | ||
62 | -- | 58 | -- |
63 | 2.20.1 | 59 | 2.25.1 |
64 | |||
65 | diff view generated by jsdifflib |
1 | From: AlexChen <alex.chen@huawei.com> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | In exynos4210_fimd_update(), the pointer s is dereferinced before | 3 | Creating 1GB image for a simple qtest is unnecessary |
4 | being check if it is valid, which may lead to NULL pointer dereference. | 4 | and could lead to failures. We reduce the image size |
5 | So move the assignment to global_width after checking that the s is valid. | 5 | to 1MB to reduce the test overhead. |
6 | 6 | ||
7 | Reported-by: Euler Robot <euler.robot@huawei.com> | 7 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
8 | Signed-off-by: Alex Chen <alex.chen@huawei.com> | 8 | Message-id: 20220609214125.4192212-1-wuhaotsh@google.com |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Message-id: 5F9F8D88.9030102@huawei.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | hw/display/exynos4210_fimd.c | 4 +++- | 12 | tests/qtest/npcm7xx_sdhci-test.c | 2 +- |
14 | 1 file changed, 3 insertions(+), 1 deletion(-) | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 14 | ||
16 | diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c | 15 | diff --git a/tests/qtest/npcm7xx_sdhci-test.c b/tests/qtest/npcm7xx_sdhci-test.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/display/exynos4210_fimd.c | 17 | --- a/tests/qtest/npcm7xx_sdhci-test.c |
19 | +++ b/hw/display/exynos4210_fimd.c | 18 | +++ b/tests/qtest/npcm7xx_sdhci-test.c |
20 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_fimd_update(void *opaque) | 19 | @@ -XXX,XX +XXX,XX @@ |
21 | bool blend = false; | 20 | #define NPCM7XX_REG_SIZE 0x100 |
22 | uint8_t *host_fb_addr; | 21 | #define NPCM7XX_MMC_BA 0xF0842000 |
23 | bool is_dirty = false; | 22 | #define NPCM7XX_BLK_SIZE 512 |
24 | - const int global_width = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1; | 23 | -#define NPCM7XX_TEST_IMAGE_SIZE (1 << 30) |
25 | + int global_width; | 24 | +#define NPCM7XX_TEST_IMAGE_SIZE (1 << 20) |
26 | 25 | ||
27 | if (!s || !s->console || !s->enabled || | 26 | char *sd_path; |
28 | surface_bits_per_pixel(qemu_console_surface(s->console)) == 0) { | ||
29 | return; | ||
30 | } | ||
31 | + | ||
32 | + global_width = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1; | ||
33 | exynos4210_update_resolution(s); | ||
34 | surface = qemu_console_surface(s->console); | ||
35 | 27 | ||
36 | -- | 28 | -- |
37 | 2.20.1 | 29 | 2.25.1 |
38 | |||
39 | diff view generated by jsdifflib |
1 | From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | HCR should be applied when NS is set, not when it is cleared. | 3 | Because reset always initializes the AA64 version, SCR_EL3, |
4 | test the mode of EL3 instead of the type of the cpreg. | ||
4 | 5 | ||
5 | Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20220609214657.1217913-2-richard.henderson@linaro.org | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | target/arm/helper.c | 5 ++--- | 11 | target/arm/helper.c | 14 ++++++++------ |
10 | 1 file changed, 2 insertions(+), 3 deletions(-) | 12 | 1 file changed, 8 insertions(+), 6 deletions(-) |
11 | 13 | ||
12 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/helper.c | 16 | --- a/target/arm/helper.c |
15 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/helper.c |
16 | @@ -XXX,XX +XXX,XX @@ static void tlbimvaa_is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 18 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
17 | 19 | uint32_t valid_mask = 0x3fff; | |
18 | /* | 20 | ARMCPU *cpu = env_archcpu(env); |
19 | * Non-IS variants of TLB operations are upgraded to | 21 | |
20 | - * IS versions if we are at NS EL1 and HCR_EL2.FB is set to | 22 | - if (ri->state == ARM_CP_STATE_AA64) { |
21 | + * IS versions if we are at EL1 and HCR_EL2.FB is effectively set to | 23 | - if (arm_feature(env, ARM_FEATURE_AARCH64) && |
22 | * force broadcast of these operations. | 24 | - !cpu_isar_feature(aa64_aa32_el1, cpu)) { |
23 | */ | 25 | - value |= SCR_FW | SCR_AW; /* these two bits are RES1. */ |
24 | static bool tlb_force_broadcast(CPUARMState *env) | 26 | - } |
25 | { | 27 | - valid_mask &= ~SCR_NET; |
26 | - return (env->cp15.hcr_el2 & HCR_FB) && | 28 | + /* |
27 | - arm_current_el(env) == 1 && arm_is_secure_below_el3(env); | 29 | + * Because SCR_EL3 is the "real" cpreg and SCR is the alias, reset always |
28 | + return arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_FB); | 30 | + * passes the reginfo for SCR_EL3, which has type ARM_CP_STATE_AA64. |
29 | } | 31 | + * Instead, choose the format based on the mode of EL3. |
30 | 32 | + */ | |
31 | static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri, | 33 | + if (arm_el_is_aa64(env, 3)) { |
34 | + value |= SCR_FW | SCR_AW; /* RES1 */ | ||
35 | + valid_mask &= ~SCR_NET; /* RES0 */ | ||
36 | |||
37 | if (cpu_isar_feature(aa64_ras, cpu)) { | ||
38 | valid_mask |= SCR_TERR; | ||
32 | -- | 39 | -- |
33 | 2.20.1 | 40 | 2.25.1 |
34 | |||
35 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Use the BIT_ULL() macro to ensure we use 64-bit arithmetic. | 3 | Since DDI0487F.a, the RW bit is RAO/WI. When specifically |
4 | This fixes the following Coverity issue (OVERFLOW_BEFORE_WIDEN): | 4 | targeting such a cpu, e.g. cortex-a76, it is legitimate to |
5 | ignore the bit within the secure monitor. | ||
5 | 6 | ||
6 | CID 1432363 (#1 of 1): Unintentional integer overflow: | 7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1062 |
7 | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | |
8 | overflow_before_widen: | 9 | Message-id: 20220609214657.1217913-3-richard.henderson@linaro.org |
9 | Potentially overflowing expression 1 << scale with type int | ||
10 | (32 bits, signed) is evaluated using 32-bit arithmetic, and | ||
11 | then used in a context that expects an expression of type | ||
12 | hwaddr (64 bits, unsigned). | ||
13 | |||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Acked-by: Eric Auger <eric.auger@redhat.com> | ||
16 | Message-id: 20201030144617.1535064-1-philmd@redhat.com | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 12 | --- |
20 | hw/arm/smmuv3.c | 3 ++- | 13 | target/arm/cpu.h | 5 +++++ |
21 | 1 file changed, 2 insertions(+), 1 deletion(-) | 14 | target/arm/helper.c | 4 ++++ |
15 | 2 files changed, 9 insertions(+) | ||
22 | 16 | ||
23 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | 17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
24 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/arm/smmuv3.c | 19 | --- a/target/arm/cpu.h |
26 | +++ b/hw/arm/smmuv3.c | 20 | +++ b/target/arm/cpu.h |
27 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_aa32_el1(const ARMISARegisters *id) |
28 | */ | 22 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL1) >= 2; |
29 | 23 | } | |
30 | #include "qemu/osdep.h" | 24 | |
31 | +#include "qemu/bitops.h" | 25 | +static inline bool isar_feature_aa64_aa32_el2(const ARMISARegisters *id) |
32 | #include "hw/irq.h" | 26 | +{ |
33 | #include "hw/sysbus.h" | 27 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL2) >= 2; |
34 | #include "migration/vmstate.h" | 28 | +} |
35 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | 29 | + |
36 | scale = CMD_SCALE(cmd); | 30 | static inline bool isar_feature_aa64_ras(const ARMISARegisters *id) |
37 | num = CMD_NUM(cmd); | 31 | { |
38 | ttl = CMD_TTL(cmd); | 32 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) != 0; |
39 | - num_pages = (num + 1) * (1 << (scale)); | 33 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
40 | + num_pages = (num + 1) * BIT_ULL(scale); | 34 | index XXXXXXX..XXXXXXX 100644 |
41 | } | 35 | --- a/target/arm/helper.c |
42 | 36 | +++ b/target/arm/helper.c | |
43 | if (type == SMMU_CMD_TLBI_NH_VA) { | 37 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
38 | value |= SCR_FW | SCR_AW; /* RES1 */ | ||
39 | valid_mask &= ~SCR_NET; /* RES0 */ | ||
40 | |||
41 | + if (!cpu_isar_feature(aa64_aa32_el1, cpu) && | ||
42 | + !cpu_isar_feature(aa64_aa32_el2, cpu)) { | ||
43 | + value |= SCR_RW; /* RAO/WI */ | ||
44 | + } | ||
45 | if (cpu_isar_feature(aa64_ras, cpu)) { | ||
46 | valid_mask |= SCR_TERR; | ||
47 | } | ||
44 | -- | 48 | -- |
45 | 2.20.1 | 49 | 2.25.1 |
46 | |||
47 | diff view generated by jsdifflib |
1 | From: AlexChen <alex.chen@huawei.com> | 1 | In two places in gdbstub.c we look at gdbserver_state.init to decide |
---|---|---|---|
2 | whether we're going to do a semihosting syscall via the gdb remote | ||
3 | protocol: | ||
4 | * when setting up, if the user didn't explicitly select either | ||
5 | native semihosting or gdb semihosting, we autoselect, with the | ||
6 | intended behaviour "use gdb if gdb is connected" | ||
7 | * when the semihosting layer attempts to do a syscall via gdb, we | ||
8 | silently ignore it if the gdbstub wasn't actually set up | ||
2 | 9 | ||
3 | In omap_lcd_interrupts(), the pointer omap_lcd is dereferinced before | 10 | However, if the user's commandline sets up the gdbstub but tells QEMU |
4 | being check if it is valid, which may lead to NULL pointer dereference. | 11 | to start rather than waiting for a GDB to connect (eg using '-s' but |
5 | So move the assignment to surface after checking that the omap_lcd is valid | 12 | not '-S'), then we will have gdbserver_state.init true but no actual |
6 | and move surface_bits_per_pixel(surface) to after the surface assignment. | 13 | connection; an attempt to use gdb syscalls will then crash because we |
14 | try to use gdbserver_state.c_cpu when it hasn't been set up: | ||
7 | 15 | ||
8 | Reported-by: Euler Robot <euler.robot@huawei.com> | 16 | #0 0x00007ffff6803ba8 in qemu_cpu_kick (cpu=0x0) at ../../softmmu/cpus.c:457 |
9 | Signed-off-by: AlexChen <alex.chen@huawei.com> | 17 | #1 0x00007ffff6c03913 in gdb_do_syscallv (cb=0x7ffff6c19944 <common_semi_cb>, |
10 | Message-id: 5F9CDB8A.9000001@huawei.com | 18 | fmt=0x7ffff7573b7e "", va=0x7ffff56294c0) at ../../gdbstub.c:2946 |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 19 | #2 0x00007ffff6c19c3a in common_semi_gdb_syscall (cs=0x7ffff83fe060, |
20 | cb=0x7ffff6c19944 <common_semi_cb>, fmt=0x7ffff7573b75 "isatty,%x") | ||
21 | at ../../semihosting/arm-compat-semi.c:494 | ||
22 | #3 0x00007ffff6c1a064 in gdb_isattyfn (cs=0x7ffff83fe060, gf=0x7ffff86a3690) | ||
23 | at ../../semihosting/arm-compat-semi.c:636 | ||
24 | #4 0x00007ffff6c1b20f in do_common_semihosting (cs=0x7ffff83fe060) | ||
25 | at ../../semihosting/arm-compat-semi.c:967 | ||
26 | #5 0x00007ffff693a037 in handle_semihosting (cs=0x7ffff83fe060) | ||
27 | at ../../target/arm/helper.c:10316 | ||
28 | |||
29 | You can probably also get into this state via some odd | ||
30 | corner cases involving connecting a GDB and then telling it | ||
31 | to detach from all the vCPUs. | ||
32 | |||
33 | Abstract out the test into a new gdb_attached() function | ||
34 | which returns true only if there's actually a GDB connected | ||
35 | to the debug stub and attached to at least one vCPU. | ||
36 | |||
37 | Reported-by: Liviu Ionescu <ilg@livius.net> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 38 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
39 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
40 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
41 | Message-id: 20220526190053.521505-2-peter.maydell@linaro.org | ||
13 | --- | 42 | --- |
14 | hw/display/omap_lcdc.c | 10 +++++++--- | 43 | gdbstub.c | 14 +++++++++++--- |
15 | 1 file changed, 7 insertions(+), 3 deletions(-) | 44 | 1 file changed, 11 insertions(+), 3 deletions(-) |
16 | 45 | ||
17 | diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c | 46 | diff --git a/gdbstub.c b/gdbstub.c |
18 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/display/omap_lcdc.c | 48 | --- a/gdbstub.c |
20 | +++ b/hw/display/omap_lcdc.c | 49 | +++ b/gdbstub.c |
21 | @@ -XXX,XX +XXX,XX @@ static void omap_lcd_interrupts(struct omap_lcd_panel_s *s) | 50 | @@ -XXX,XX +XXX,XX @@ static int get_char(void) |
22 | static void omap_update_display(void *opaque) | 51 | } |
23 | { | 52 | #endif |
24 | struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque; | 53 | |
25 | - DisplaySurface *surface = qemu_console_surface(omap_lcd->con); | 54 | +/* |
26 | + DisplaySurface *surface; | 55 | + * Return true if there is a GDB currently connected to the stub |
27 | draw_line_func draw_line; | 56 | + * and attached to a CPU |
28 | int size, height, first, last; | 57 | + */ |
29 | int width, linesize, step, bpp, frame_offset; | 58 | +static bool gdb_attached(void) |
30 | hwaddr frame_base; | 59 | +{ |
31 | 60 | + return gdbserver_state.init && gdbserver_state.c_cpu; | |
32 | - if (!omap_lcd || omap_lcd->plm == 1 || !omap_lcd->enable || | 61 | +} |
33 | - !surface_bits_per_pixel(surface)) { | ||
34 | + if (!omap_lcd || omap_lcd->plm == 1 || !omap_lcd->enable) { | ||
35 | + return; | ||
36 | + } | ||
37 | + | 62 | + |
38 | + surface = qemu_console_surface(omap_lcd->con); | 63 | static enum { |
39 | + if (!surface_bits_per_pixel(surface)) { | 64 | GDB_SYS_UNKNOWN, |
65 | GDB_SYS_ENABLED, | ||
66 | @@ -XXX,XX +XXX,XX @@ int use_gdb_syscalls(void) | ||
67 | /* -semihosting-config target=auto */ | ||
68 | /* On the first call check if gdb is connected and remember. */ | ||
69 | if (gdb_syscall_mode == GDB_SYS_UNKNOWN) { | ||
70 | - gdb_syscall_mode = gdbserver_state.init ? | ||
71 | - GDB_SYS_ENABLED : GDB_SYS_DISABLED; | ||
72 | + gdb_syscall_mode = gdb_attached() ? GDB_SYS_ENABLED : GDB_SYS_DISABLED; | ||
73 | } | ||
74 | return gdb_syscall_mode == GDB_SYS_ENABLED; | ||
75 | } | ||
76 | @@ -XXX,XX +XXX,XX @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) | ||
77 | target_ulong addr; | ||
78 | uint64_t i64; | ||
79 | |||
80 | - if (!gdbserver_state.init) { | ||
81 | + if (!gdb_attached()) { | ||
40 | return; | 82 | return; |
41 | } | 83 | } |
42 | 84 | ||
43 | -- | 85 | -- |
44 | 2.20.1 | 86 | 2.25.1 |
45 | 87 | ||
46 | 88 | diff view generated by jsdifflib |
1 | Sphinx 3.2 is pickier than earlier versions about the option:: markup, | 1 | Currently we mishandle the --semihosting-config option if the |
---|---|---|---|
2 | and complains about our usage in qemu-option-trace.rst: | 2 | user specifies it on the command line more than once. For |
3 | example with: | ||
4 | --semihosting-config target=gdb --semihosting-config arg=foo,arg=bar | ||
3 | 5 | ||
4 | ../../docs/qemu-option-trace.rst.inc:4:Malformed option description | 6 | the function qemu_semihosting_config_options() is called twice, once |
5 | '[enable=]PATTERN', should look like "opt", "-opt args", "--opt args", | 7 | for each argument. But that function expects to be called only once, |
6 | "/opt args" or "+opt args" | 8 | and it always unconditionally sets the semihosting.enabled, |
9 | semihost_chardev and semihosting.target variables. This means that | ||
10 | if any of those options were set anywhere except the last | ||
11 | --semihosting-config option on the command line, those settings are | ||
12 | ignored. In the example above, 'target=gdb' in the first option is | ||
13 | overridden by an implied default 'target=auto' in the second. | ||
7 | 14 | ||
8 | In this file, we're really trying to document the different parts of | 15 | The QemuOptsList machinery has a flag for handling this kind of |
9 | the top-level --trace option, which qemu-nbd.rst and qemu-img.rst | 16 | "option group is setting global state": by setting |
10 | have already introduced with an option:: markup. So it's not right | 17 | .merge_lists = true; |
11 | to use option:: here anyway. Switch to a different markup | 18 | we make the machinery merge all the --semihosting-config arguments |
12 | (definition lists) which gives about the same formatted output. | 19 | the user passes into a single set of options and call our |
13 | 20 | qemu_semihosting_config_options() just once. | |
14 | (Unlike option::, this markup doesn't produce index entries; but | ||
15 | at the moment we don't do anything much with indexes anyway, and | ||
16 | in any case I think it doesn't make much sense to have individual | ||
17 | index entries for the sub-parts of the --trace option.) | ||
18 | 21 | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | 23 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
21 | Tested-by: Stefan Hajnoczi <stefanha@redhat.com> | 24 | Message-id: 20220526190053.521505-3-peter.maydell@linaro.org |
22 | Message-id: 20201030174700.7204-3-peter.maydell@linaro.org | ||
23 | --- | 25 | --- |
24 | docs/qemu-option-trace.rst.inc | 6 +++--- | 26 | semihosting/config.c | 1 + |
25 | 1 file changed, 3 insertions(+), 3 deletions(-) | 27 | 1 file changed, 1 insertion(+) |
26 | 28 | ||
27 | diff --git a/docs/qemu-option-trace.rst.inc b/docs/qemu-option-trace.rst.inc | 29 | diff --git a/semihosting/config.c b/semihosting/config.c |
28 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/docs/qemu-option-trace.rst.inc | 31 | --- a/semihosting/config.c |
30 | +++ b/docs/qemu-option-trace.rst.inc | 32 | +++ b/semihosting/config.c |
31 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ |
32 | 34 | ||
33 | Specify tracing options. | 35 | QemuOptsList qemu_semihosting_config_opts = { |
34 | 36 | .name = "semihosting-config", | |
35 | -.. option:: [enable=]PATTERN | 37 | + .merge_lists = true, |
36 | +``[enable=]PATTERN`` | 38 | .implied_opt_name = "enable", |
37 | 39 | .head = QTAILQ_HEAD_INITIALIZER(qemu_semihosting_config_opts.head), | |
38 | Immediately enable events matching *PATTERN* | 40 | .desc = { |
39 | (either event name or a globbing pattern). This option is only | ||
40 | @@ -XXX,XX +XXX,XX @@ Specify tracing options. | ||
41 | |||
42 | Use :option:`-trace help` to print a list of names of trace points. | ||
43 | |||
44 | -.. option:: events=FILE | ||
45 | +``events=FILE`` | ||
46 | |||
47 | Immediately enable events listed in *FILE*. | ||
48 | The file must contain one event name (as listed in the ``trace-events-all`` | ||
49 | @@ -XXX,XX +XXX,XX @@ Specify tracing options. | ||
50 | available if QEMU has been compiled with the ``simple``, ``log`` or | ||
51 | ``ftrace`` tracing backend. | ||
52 | |||
53 | -.. option:: file=FILE | ||
54 | +``file=FILE`` | ||
55 | |||
56 | Log output traces to *FILE*. | ||
57 | This option is only available if QEMU has been compiled with | ||
58 | -- | 41 | -- |
59 | 2.20.1 | 42 | 2.25.1 |
60 | |||
61 | diff view generated by jsdifflib |