1 | First set of arm patches for 6.2. I have a lot more in my | 1 | Hi; here's the latest round of arm patches. I have included also |
---|---|---|---|
2 | to-review queue still... | 2 | my patchset for the RTC devices to avoid keeping time_t and |
3 | time_t diffs in 32-bit variables. | ||
3 | 4 | ||
5 | thanks | ||
4 | -- PMM | 6 | -- PMM |
5 | 7 | ||
6 | The following changes since commit d42685765653ec155fdf60910662f8830bdb2cef: | 8 | The following changes since commit 156618d9ea67f2f2e31d9dedd97f2dcccbe6808c: |
7 | 9 | ||
8 | Open 6.2 development tree (2021-08-25 10:25:12 +0100) | 10 | Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2023-08-30 09:20:27 -0400) |
9 | 11 | ||
10 | are available in the Git repository at: | 12 | are available in the Git repository at: |
11 | 13 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210825 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230831 |
13 | 15 | ||
14 | for you to fetch changes up to 24b1a6aa43615be22c7ee66bd68ec5675f6a6a9a: | 16 | for you to fetch changes up to e73b8bb8a3e9a162f70e9ffbf922d4fafc96bbfb: |
15 | 17 | ||
16 | docs: Document how to use gdb with unix sockets (2021-08-25 10:48:51 +0100) | 18 | hw/arm: Set number of MPU regions correctly for an505, an521, an524 (2023-08-31 11:07:02 +0100) |
17 | 19 | ||
18 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
19 | target-arm queue: | 21 | target-arm queue: |
20 | * More MVE emulation work | 22 | * Some of the preliminary patches for Cortex-A710 support |
21 | * Implement M-profile trapping on division by zero | 23 | * i.MX7 and i.MX6UL refactoring |
22 | * kvm: use RCU_READ_LOCK_GUARD() in kvm_arch_fixup_msi_route() | 24 | * Implement SRC device for i.MX7 |
23 | * hw/char/pl011: add support for sending break | 25 | * Catch illegal-exception-return from EL3 with bad NSE/NS |
24 | * fsl-imx6ul: Instantiate SAI1/2/3 and ASRC as unimplemented devices | 26 | * Use 64-bit offsets for holding time_t differences in RTC devices |
25 | * hw/dma/pl330: Add memory region to replace default | 27 | * Model correct number of MPU regions for an505, an521, an524 boards |
26 | * sbsa-ref: Rename SBSA_GWDT enum value | ||
27 | * fsl-imx7: Instantiate SAI1/2/3 as unimplemented devices | ||
28 | * docs: Document how to use gdb with unix sockets | ||
29 | 28 | ||
30 | ---------------------------------------------------------------- | 29 | ---------------------------------------------------------------- |
31 | Eduardo Habkost (1): | 30 | Alex Bennée (1): |
32 | sbsa-ref: Rename SBSA_GWDT enum value | 31 | target/arm: properly document FEAT_CRC32 |
33 | 32 | ||
34 | Guenter Roeck (2): | 33 | Jean-Christophe Dubois (6): |
35 | fsl-imx6ul: Instantiate SAI1/2/3 and ASRC as unimplemented devices | 34 | Remove i.MX7 IOMUX GPR device from i.MX6UL |
36 | fsl-imx7: Instantiate SAI1/2/3 as unimplemented devices | 35 | Refactor i.MX6UL processor code |
36 | Add i.MX6UL missing devices. | ||
37 | Refactor i.MX7 processor code | ||
38 | Add i.MX7 missing TZ devices and memory regions | ||
39 | Add i.MX7 SRC device implementation | ||
37 | 40 | ||
38 | Hamza Mahfooz (1): | 41 | Peter Maydell (8): |
39 | target/arm: kvm: use RCU_READ_LOCK_GUARD() in kvm_arch_fixup_msi_route() | 42 | target/arm: Catch illegal-exception-return from EL3 with bad NSE/NS |
43 | hw/rtc/m48t59: Use 64-bit arithmetic in set_alarm() | ||
44 | hw/rtc/twl92230: Use int64_t for sec_offset and alm_sec | ||
45 | hw/rtc/aspeed_rtc: Use 64-bit offset for holding time_t difference | ||
46 | rtc: Use time_t for passing and returning time offsets | ||
47 | target/arm: Do all "ARM_FEATURE_X implies Y" checks in post_init | ||
48 | hw/arm/armv7m: Add mpu-ns-regions and mpu-s-regions properties | ||
49 | hw/arm: Set number of MPU regions correctly for an505, an521, an524 | ||
40 | 50 | ||
41 | Jan Luebbe (1): | 51 | Richard Henderson (9): |
42 | hw/char/pl011: add support for sending break | 52 | target/arm: Reduce dcz_blocksize to uint8_t |
53 | target/arm: Allow cpu to configure GM blocksize | ||
54 | target/arm: Support more GM blocksizes | ||
55 | target/arm: When tag memory is not present, set MTE=1 | ||
56 | target/arm: Introduce make_ccsidr64 | ||
57 | target/arm: Apply access checks to neoverse-n1 special registers | ||
58 | target/arm: Apply access checks to neoverse-v1 special registers | ||
59 | target/arm: Suppress FEAT_TRBE (Trace Buffer Extension) | ||
60 | target/arm: Implement FEAT_HPDS2 as a no-op | ||
43 | 61 | ||
44 | Peter Maydell (37): | 62 | docs/system/arm/emulation.rst | 2 + |
45 | target/arm: Note that we handle VMOVL as a special case of VSHLL | 63 | include/hw/arm/armsse.h | 5 + |
46 | target/arm: Print MVE VPR in CPU dumps | 64 | include/hw/arm/armv7m.h | 8 + |
47 | target/arm: Fix MVE VSLI by 0 and VSRI by <dt> | 65 | include/hw/arm/fsl-imx6ul.h | 158 ++++++++++++++++--- |
48 | target/arm: Fix signed VADDV | 66 | include/hw/arm/fsl-imx7.h | 338 ++++++++++++++++++++++++++++++----------- |
49 | target/arm: Fix mask handling for MVE narrowing operations | 67 | include/hw/misc/imx7_src.h | 66 ++++++++ |
50 | target/arm: Fix 48-bit saturating shifts | 68 | include/hw/rtc/aspeed_rtc.h | 2 +- |
51 | target/arm: Fix MVE 48-bit SQRSHRL for small right shifts | 69 | include/sysemu/rtc.h | 4 +- |
52 | target/arm: Fix calculation of LTP mask when LR is 0 | 70 | target/arm/cpregs.h | 2 + |
53 | target/arm: Factor out mve_eci_mask() | 71 | target/arm/cpu.h | 5 +- |
54 | target/arm: Fix VPT advance when ECI is non-zero | 72 | target/arm/internals.h | 6 - |
55 | target/arm: Fix VLDRB/H/W for predicated elements | 73 | target/arm/tcg/translate.h | 2 + |
56 | target/arm: Implement MVE VMULL (polynomial) | 74 | hw/arm/armsse.c | 16 ++ |
57 | target/arm: Implement MVE incrementing/decrementing dup insns | 75 | hw/arm/armv7m.c | 21 +++ |
58 | target/arm: Factor out gen_vpst() | 76 | hw/arm/fsl-imx6ul.c | 174 +++++++++++++-------- |
59 | target/arm: Implement MVE integer vector comparisons | 77 | hw/arm/fsl-imx7.c | 201 +++++++++++++++++++----- |
60 | target/arm: Implement MVE integer vector-vs-scalar comparisons | 78 | hw/arm/mps2-tz.c | 29 ++++ |
61 | target/arm: Implement MVE VPSEL | 79 | hw/misc/imx7_src.c | 276 +++++++++++++++++++++++++++++++++ |
62 | target/arm: Implement MVE VMLAS | 80 | hw/rtc/aspeed_rtc.c | 5 +- |
63 | target/arm: Implement MVE shift-by-scalar | 81 | hw/rtc/m48t59.c | 2 +- |
64 | target/arm: Move 'x' and 'a' bit definitions into vmlaldav formats | 82 | hw/rtc/twl92230.c | 4 +- |
65 | target/arm: Implement MVE integer min/max across vector | 83 | softmmu/rtc.c | 4 +- |
66 | target/arm: Implement MVE VABAV | 84 | target/arm/cpu.c | 207 ++++++++++++++----------- |
67 | target/arm: Implement MVE narrowing moves | 85 | target/arm/helper.c | 15 +- |
68 | target/arm: Rename MVEGenDualAccOpFn to MVEGenLongDualAccOpFn | 86 | target/arm/tcg/cpu32.c | 2 +- |
69 | target/arm: Implement MVE VMLADAV and VMLSLDAV | 87 | target/arm/tcg/cpu64.c | 102 +++++++++---- |
70 | target/arm: Implement MVE VMLA | 88 | target/arm/tcg/helper-a64.c | 9 ++ |
71 | target/arm: Implement MVE saturating doubling multiply accumulates | 89 | target/arm/tcg/mte_helper.c | 90 ++++++++--- |
72 | target/arm: Implement MVE VQABS, VQNEG | 90 | target/arm/tcg/translate-a64.c | 5 +- |
73 | target/arm: Implement MVE VMAXA, VMINA | 91 | hw/misc/meson.build | 1 + |
74 | target/arm: Implement MVE VMOV to/from 2 general-purpose registers | 92 | hw/misc/trace-events | 4 + |
75 | target/arm: Implement MVE VPNOT | 93 | 31 files changed, 1393 insertions(+), 372 deletions(-) |
76 | target/arm: Implement MVE VCTP | 94 | create mode 100644 include/hw/misc/imx7_src.h |
77 | target/arm: Implement MVE scatter-gather insns | 95 | create mode 100644 hw/misc/imx7_src.c |
78 | target/arm: Implement MVE scatter-gather immediate forms | ||
79 | target/arm: Implement MVE interleaving loads/stores | ||
80 | target/arm: Re-indent sdiv and udiv helpers | ||
81 | target/arm: Implement M-profile trapping on division by zero | ||
82 | 96 | ||
83 | Sebastian Meyer (1): | ||
84 | docs: Document how to use gdb with unix sockets | ||
85 | |||
86 | Wen, Jianxian (1): | ||
87 | hw/dma/pl330: Add memory region to replace default | ||
88 | |||
89 | docs/system/gdb.rst | 26 +- | ||
90 | include/hw/arm/fsl-imx7.h | 5 + | ||
91 | target/arm/cpu.h | 1 + | ||
92 | target/arm/helper-mve.h | 283 ++++++++++ | ||
93 | target/arm/helper.h | 4 +- | ||
94 | target/arm/translate-a32.h | 2 + | ||
95 | target/arm/vec_internal.h | 11 + | ||
96 | target/arm/mve.decode | 226 +++++++- | ||
97 | target/arm/t32.decode | 1 + | ||
98 | hw/arm/exynos4210.c | 3 + | ||
99 | hw/arm/fsl-imx6ul.c | 12 + | ||
100 | hw/arm/fsl-imx7.c | 7 + | ||
101 | hw/arm/sbsa-ref.c | 6 +- | ||
102 | hw/arm/xilinx_zynq.c | 3 + | ||
103 | hw/char/pl011.c | 6 + | ||
104 | hw/dma/pl330.c | 26 +- | ||
105 | target/arm/cpu.c | 3 + | ||
106 | target/arm/helper.c | 34 +- | ||
107 | target/arm/kvm.c | 17 +- | ||
108 | target/arm/m_helper.c | 4 + | ||
109 | target/arm/mve_helper.c | 1254 ++++++++++++++++++++++++++++++++++++++++++-- | ||
110 | target/arm/translate-mve.c | 877 ++++++++++++++++++++++++++++++- | ||
111 | target/arm/translate-vfp.c | 2 +- | ||
112 | target/arm/translate.c | 37 +- | ||
113 | target/arm/vec_helper.c | 14 +- | ||
114 | 25 files changed, 2746 insertions(+), 118 deletions(-) | ||
115 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Although the architecture doesn't define it as an alias, VMOVL | ||
2 | (vector move long) is encoded as a VSHLL with a zero shift. | ||
3 | Add a comment in the decode file noting that we handle VMOVL | ||
4 | as part of VSHLL. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | target/arm/mve.decode | 2 ++ | ||
10 | 1 file changed, 2 insertions(+) | ||
11 | |||
12 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/mve.decode | ||
15 | +++ b/target/arm/mve.decode | ||
16 | @@ -XXX,XX +XXX,XX @@ VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
17 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
18 | |||
19 | # VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file | ||
20 | +# Note that VMOVL is encoded as "VSHLL with a zero shift count"; we | ||
21 | +# implement it that way rather than special-casing it in the decode. | ||
22 | VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | ||
23 | VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | ||
24 | |||
25 | -- | ||
26 | 2.20.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
1 | Implement the MVE interleaving load/store functions VLD2, VLD4, VST2 | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | and VST4. VLD2 loads 16 bytes of data from memory and writes to 2 | ||
3 | consecutive Qregs; VLD4 loads 16 bytes of data from memory and writes | ||
4 | to 4 consecutive Qregs. The 'pattern' field in the encoding | ||
5 | determines the offset into memory which is accessed and also which | ||
6 | elements in the Qregs are written to. (The intention is that a | ||
7 | sequence of four consecutive VLD4 with different pattern values | ||
8 | performs a complete de-interleaving load of 64 bytes into all | ||
9 | elements of the 4 Qregs.) VST2 and VST4 do the same, but for stores. | ||
10 | 2 | ||
3 | This value is only 4 bits wide. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Message-id: 20230811214031.171020-2-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 | --- | 10 | --- |
14 | target/arm/helper-mve.h | 48 ++++++ | 11 | target/arm/cpu.h | 3 ++- |
15 | target/arm/mve.decode | 11 ++ | 12 | 1 file changed, 2 insertions(+), 1 deletion(-) |
16 | target/arm/mve_helper.c | 342 +++++++++++++++++++++++++++++++++++++ | ||
17 | target/arm/translate-mve.c | 94 ++++++++++ | ||
18 | 4 files changed, 495 insertions(+) | ||
19 | 13 | ||
20 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper-mve.h | 16 | --- a/target/arm/cpu.h |
23 | +++ b/target/arm/helper-mve.h | 17 | +++ b/target/arm/cpu.h |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vldrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 18 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
25 | DEF_HELPER_FLAGS_4(mve_vstrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | bool prop_lpa2; |
26 | DEF_HELPER_FLAGS_4(mve_vstrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 20 | |
27 | 21 | /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ | |
28 | +DEF_HELPER_FLAGS_3(mve_vld20b, TCG_CALL_NO_WG, void, env, i32, i32) | 22 | - uint32_t dcz_blocksize; |
29 | +DEF_HELPER_FLAGS_3(mve_vld20h, TCG_CALL_NO_WG, void, env, i32, i32) | 23 | + uint8_t dcz_blocksize; |
30 | +DEF_HELPER_FLAGS_3(mve_vld20w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
31 | + | 24 | + |
32 | +DEF_HELPER_FLAGS_3(mve_vld21b, TCG_CALL_NO_WG, void, env, i32, i32) | 25 | uint64_t rvbar_prop; /* Property/input signals. */ |
33 | +DEF_HELPER_FLAGS_3(mve_vld21h, TCG_CALL_NO_WG, void, env, i32, i32) | 26 | |
34 | +DEF_HELPER_FLAGS_3(mve_vld21w, TCG_CALL_NO_WG, void, env, i32, i32) | 27 | /* Configurable aspects of GIC cpu interface (which is part of the CPU) */ |
35 | + | ||
36 | +DEF_HELPER_FLAGS_3(mve_vld40b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
37 | +DEF_HELPER_FLAGS_3(mve_vld40h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
38 | +DEF_HELPER_FLAGS_3(mve_vld40w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
39 | + | ||
40 | +DEF_HELPER_FLAGS_3(mve_vld41b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vld41h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
42 | +DEF_HELPER_FLAGS_3(mve_vld41w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
43 | + | ||
44 | +DEF_HELPER_FLAGS_3(mve_vld42b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
45 | +DEF_HELPER_FLAGS_3(mve_vld42h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
46 | +DEF_HELPER_FLAGS_3(mve_vld42w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
47 | + | ||
48 | +DEF_HELPER_FLAGS_3(mve_vld43b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
49 | +DEF_HELPER_FLAGS_3(mve_vld43h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
50 | +DEF_HELPER_FLAGS_3(mve_vld43w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
51 | + | ||
52 | +DEF_HELPER_FLAGS_3(mve_vst20b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
53 | +DEF_HELPER_FLAGS_3(mve_vst20h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
54 | +DEF_HELPER_FLAGS_3(mve_vst20w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
55 | + | ||
56 | +DEF_HELPER_FLAGS_3(mve_vst21b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
57 | +DEF_HELPER_FLAGS_3(mve_vst21h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
58 | +DEF_HELPER_FLAGS_3(mve_vst21w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
59 | + | ||
60 | +DEF_HELPER_FLAGS_3(mve_vst40b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
61 | +DEF_HELPER_FLAGS_3(mve_vst40h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
62 | +DEF_HELPER_FLAGS_3(mve_vst40w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
63 | + | ||
64 | +DEF_HELPER_FLAGS_3(mve_vst41b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
65 | +DEF_HELPER_FLAGS_3(mve_vst41h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
66 | +DEF_HELPER_FLAGS_3(mve_vst41w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
67 | + | ||
68 | +DEF_HELPER_FLAGS_3(mve_vst42b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
69 | +DEF_HELPER_FLAGS_3(mve_vst42h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
70 | +DEF_HELPER_FLAGS_3(mve_vst42w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
71 | + | ||
72 | +DEF_HELPER_FLAGS_3(mve_vst43b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
73 | +DEF_HELPER_FLAGS_3(mve_vst43h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
74 | +DEF_HELPER_FLAGS_3(mve_vst43w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
75 | + | ||
76 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
77 | |||
78 | DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
79 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/target/arm/mve.decode | ||
82 | +++ b/target/arm/mve.decode | ||
83 | @@ -XXX,XX +XXX,XX @@ | ||
84 | &vabav qn qm rda size | ||
85 | &vldst_sg qd qm rn size msize os | ||
86 | &vldst_sg_imm qd qm a w imm | ||
87 | +&vldst_il qd rn size pat w | ||
88 | |||
89 | # scatter-gather memory size is in bits 6:4 | ||
90 | %sg_msize 6:1 4:1 | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | @vldst_sg_imm .... .... a:1 . w:1 . .... .... .... . imm:7 &vldst_sg_imm \ | ||
93 | qd=%qd qm=%qn | ||
94 | |||
95 | +# Deinterleaving load/interleaving store | ||
96 | +@vldst_il .... .... .. w:1 . rn:4 .... ... size:2 pat:2 ..... &vldst_il \ | ||
97 | + qd=%qd | ||
98 | + | ||
99 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | ||
100 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | ||
101 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | ||
102 | @@ -XXX,XX +XXX,XX @@ VLDRD_sg_imm 111 1 1101 ... 1 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
103 | VSTRW_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1110 .... .... @vldst_sg_imm | ||
104 | VSTRD_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
105 | |||
106 | +# deinterleaving loads/interleaving stores | ||
107 | +VLD2 1111 1100 1 .. 1 .... ... 1 111 .. .. 00000 @vldst_il | ||
108 | +VLD4 1111 1100 1 .. 1 .... ... 1 111 .. .. 00001 @vldst_il | ||
109 | +VST2 1111 1100 1 .. 0 .... ... 1 111 .. .. 00000 @vldst_il | ||
110 | +VST4 1111 1100 1 .. 0 .... ... 1 111 .. .. 00001 @vldst_il | ||
111 | + | ||
112 | # Moves between 2 32-bit vector lanes and 2 general purpose registers | ||
113 | VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
114 | VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
115 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
116 | index XXXXXXX..XXXXXXX 100644 | ||
117 | --- a/target/arm/mve_helper.c | ||
118 | +++ b/target/arm/mve_helper.c | ||
119 | @@ -XXX,XX +XXX,XX @@ DO_VLDR64_SG(vldrd_sg_wb_ud, ADDR_ADD, true) | ||
120 | DO_VSTR_SG(vstrw_sg_wb_uw, stl, 4, uint32_t, ADDR_ADD, true) | ||
121 | DO_VSTR64_SG(vstrd_sg_wb_ud, ADDR_ADD, true) | ||
122 | |||
123 | +/* | ||
124 | + * Deinterleaving loads/interleaving stores. | ||
125 | + * | ||
126 | + * For these helpers we are passed the index of the first Qreg | ||
127 | + * (VLD2/VST2 will also access Qn+1, VLD4/VST4 access Qn .. Qn+3) | ||
128 | + * and the value of the base address register Rn. | ||
129 | + * The helpers are specialized for pattern and element size, so | ||
130 | + * for instance vld42h is VLD4 with pattern 2, element size MO_16. | ||
131 | + * | ||
132 | + * These insns are beatwise but not predicated, so we must honour ECI, | ||
133 | + * but need not look at mve_element_mask(). | ||
134 | + * | ||
135 | + * The pseudocode implements these insns with multiple memory accesses | ||
136 | + * of the element size, but rules R_VVVG and R_FXDM permit us to make | ||
137 | + * one 32-bit memory access per beat. | ||
138 | + */ | ||
139 | +#define DO_VLD4B(OP, O1, O2, O3, O4) \ | ||
140 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
141 | + uint32_t base) \ | ||
142 | + { \ | ||
143 | + int beat, e; \ | ||
144 | + uint16_t mask = mve_eci_mask(env); \ | ||
145 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
146 | + uint32_t addr, data; \ | ||
147 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
148 | + if ((mask & 1) == 0) { \ | ||
149 | + /* ECI says skip this beat */ \ | ||
150 | + continue; \ | ||
151 | + } \ | ||
152 | + addr = base + off[beat] * 4; \ | ||
153 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
154 | + for (e = 0; e < 4; e++, data >>= 8) { \ | ||
155 | + uint8_t *qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
156 | + qd[H1(off[beat])] = data; \ | ||
157 | + } \ | ||
158 | + } \ | ||
159 | + } | ||
160 | + | ||
161 | +#define DO_VLD4H(OP, O1, O2) \ | ||
162 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
163 | + uint32_t base) \ | ||
164 | + { \ | ||
165 | + int beat; \ | ||
166 | + uint16_t mask = mve_eci_mask(env); \ | ||
167 | + static const uint8_t off[4] = { O1, O1, O2, O2 }; \ | ||
168 | + uint32_t addr, data; \ | ||
169 | + int y; /* y counts 0 2 0 2 */ \ | ||
170 | + uint16_t *qd; \ | ||
171 | + for (beat = 0, y = 0; beat < 4; beat++, mask >>= 4, y ^= 2) { \ | ||
172 | + if ((mask & 1) == 0) { \ | ||
173 | + /* ECI says skip this beat */ \ | ||
174 | + continue; \ | ||
175 | + } \ | ||
176 | + addr = base + off[beat] * 8 + (beat & 1) * 4; \ | ||
177 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
178 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
179 | + qd[H2(off[beat])] = data; \ | ||
180 | + data >>= 16; \ | ||
181 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y + 1); \ | ||
182 | + qd[H2(off[beat])] = data; \ | ||
183 | + } \ | ||
184 | + } | ||
185 | + | ||
186 | +#define DO_VLD4W(OP, O1, O2, O3, O4) \ | ||
187 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
188 | + uint32_t base) \ | ||
189 | + { \ | ||
190 | + int beat; \ | ||
191 | + uint16_t mask = mve_eci_mask(env); \ | ||
192 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
193 | + uint32_t addr, data; \ | ||
194 | + uint32_t *qd; \ | ||
195 | + int y; \ | ||
196 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
197 | + if ((mask & 1) == 0) { \ | ||
198 | + /* ECI says skip this beat */ \ | ||
199 | + continue; \ | ||
200 | + } \ | ||
201 | + addr = base + off[beat] * 4; \ | ||
202 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
203 | + y = (beat + (O1 & 2)) & 3; \ | ||
204 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
205 | + qd[H4(off[beat] >> 2)] = data; \ | ||
206 | + } \ | ||
207 | + } | ||
208 | + | ||
209 | +DO_VLD4B(vld40b, 0, 1, 10, 11) | ||
210 | +DO_VLD4B(vld41b, 2, 3, 12, 13) | ||
211 | +DO_VLD4B(vld42b, 4, 5, 14, 15) | ||
212 | +DO_VLD4B(vld43b, 6, 7, 8, 9) | ||
213 | + | ||
214 | +DO_VLD4H(vld40h, 0, 5) | ||
215 | +DO_VLD4H(vld41h, 1, 6) | ||
216 | +DO_VLD4H(vld42h, 2, 7) | ||
217 | +DO_VLD4H(vld43h, 3, 4) | ||
218 | + | ||
219 | +DO_VLD4W(vld40w, 0, 1, 10, 11) | ||
220 | +DO_VLD4W(vld41w, 2, 3, 12, 13) | ||
221 | +DO_VLD4W(vld42w, 4, 5, 14, 15) | ||
222 | +DO_VLD4W(vld43w, 6, 7, 8, 9) | ||
223 | + | ||
224 | +#define DO_VLD2B(OP, O1, O2, O3, O4) \ | ||
225 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
226 | + uint32_t base) \ | ||
227 | + { \ | ||
228 | + int beat, e; \ | ||
229 | + uint16_t mask = mve_eci_mask(env); \ | ||
230 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
231 | + uint32_t addr, data; \ | ||
232 | + uint8_t *qd; \ | ||
233 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
234 | + if ((mask & 1) == 0) { \ | ||
235 | + /* ECI says skip this beat */ \ | ||
236 | + continue; \ | ||
237 | + } \ | ||
238 | + addr = base + off[beat] * 2; \ | ||
239 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
240 | + for (e = 0; e < 4; e++, data >>= 8) { \ | ||
241 | + qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + (e & 1)); \ | ||
242 | + qd[H1(off[beat] + (e >> 1))] = data; \ | ||
243 | + } \ | ||
244 | + } \ | ||
245 | + } | ||
246 | + | ||
247 | +#define DO_VLD2H(OP, O1, O2, O3, O4) \ | ||
248 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
249 | + uint32_t base) \ | ||
250 | + { \ | ||
251 | + int beat; \ | ||
252 | + uint16_t mask = mve_eci_mask(env); \ | ||
253 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
254 | + uint32_t addr, data; \ | ||
255 | + int e; \ | ||
256 | + uint16_t *qd; \ | ||
257 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
258 | + if ((mask & 1) == 0) { \ | ||
259 | + /* ECI says skip this beat */ \ | ||
260 | + continue; \ | ||
261 | + } \ | ||
262 | + addr = base + off[beat] * 4; \ | ||
263 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
264 | + for (e = 0; e < 2; e++, data >>= 16) { \ | ||
265 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
266 | + qd[H2(off[beat])] = data; \ | ||
267 | + } \ | ||
268 | + } \ | ||
269 | + } | ||
270 | + | ||
271 | +#define DO_VLD2W(OP, O1, O2, O3, O4) \ | ||
272 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
273 | + uint32_t base) \ | ||
274 | + { \ | ||
275 | + int beat; \ | ||
276 | + uint16_t mask = mve_eci_mask(env); \ | ||
277 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
278 | + uint32_t addr, data; \ | ||
279 | + uint32_t *qd; \ | ||
280 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
281 | + if ((mask & 1) == 0) { \ | ||
282 | + /* ECI says skip this beat */ \ | ||
283 | + continue; \ | ||
284 | + } \ | ||
285 | + addr = base + off[beat]; \ | ||
286 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
287 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + (beat & 1)); \ | ||
288 | + qd[H4(off[beat] >> 3)] = data; \ | ||
289 | + } \ | ||
290 | + } | ||
291 | + | ||
292 | +DO_VLD2B(vld20b, 0, 2, 12, 14) | ||
293 | +DO_VLD2B(vld21b, 4, 6, 8, 10) | ||
294 | + | ||
295 | +DO_VLD2H(vld20h, 0, 1, 6, 7) | ||
296 | +DO_VLD2H(vld21h, 2, 3, 4, 5) | ||
297 | + | ||
298 | +DO_VLD2W(vld20w, 0, 4, 24, 28) | ||
299 | +DO_VLD2W(vld21w, 8, 12, 16, 20) | ||
300 | + | ||
301 | +#define DO_VST4B(OP, O1, O2, O3, O4) \ | ||
302 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
303 | + uint32_t base) \ | ||
304 | + { \ | ||
305 | + int beat, e; \ | ||
306 | + uint16_t mask = mve_eci_mask(env); \ | ||
307 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
308 | + uint32_t addr, data; \ | ||
309 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
310 | + if ((mask & 1) == 0) { \ | ||
311 | + /* ECI says skip this beat */ \ | ||
312 | + continue; \ | ||
313 | + } \ | ||
314 | + addr = base + off[beat] * 4; \ | ||
315 | + data = 0; \ | ||
316 | + for (e = 3; e >= 0; e--) { \ | ||
317 | + uint8_t *qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
318 | + data = (data << 8) | qd[H1(off[beat])]; \ | ||
319 | + } \ | ||
320 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
321 | + } \ | ||
322 | + } | ||
323 | + | ||
324 | +#define DO_VST4H(OP, O1, O2) \ | ||
325 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
326 | + uint32_t base) \ | ||
327 | + { \ | ||
328 | + int beat; \ | ||
329 | + uint16_t mask = mve_eci_mask(env); \ | ||
330 | + static const uint8_t off[4] = { O1, O1, O2, O2 }; \ | ||
331 | + uint32_t addr, data; \ | ||
332 | + int y; /* y counts 0 2 0 2 */ \ | ||
333 | + uint16_t *qd; \ | ||
334 | + for (beat = 0, y = 0; beat < 4; beat++, mask >>= 4, y ^= 2) { \ | ||
335 | + if ((mask & 1) == 0) { \ | ||
336 | + /* ECI says skip this beat */ \ | ||
337 | + continue; \ | ||
338 | + } \ | ||
339 | + addr = base + off[beat] * 8 + (beat & 1) * 4; \ | ||
340 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
341 | + data = qd[H2(off[beat])]; \ | ||
342 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y + 1); \ | ||
343 | + data |= qd[H2(off[beat])] << 16; \ | ||
344 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
345 | + } \ | ||
346 | + } | ||
347 | + | ||
348 | +#define DO_VST4W(OP, O1, O2, O3, O4) \ | ||
349 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
350 | + uint32_t base) \ | ||
351 | + { \ | ||
352 | + int beat; \ | ||
353 | + uint16_t mask = mve_eci_mask(env); \ | ||
354 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
355 | + uint32_t addr, data; \ | ||
356 | + uint32_t *qd; \ | ||
357 | + int y; \ | ||
358 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
359 | + if ((mask & 1) == 0) { \ | ||
360 | + /* ECI says skip this beat */ \ | ||
361 | + continue; \ | ||
362 | + } \ | ||
363 | + addr = base + off[beat] * 4; \ | ||
364 | + y = (beat + (O1 & 2)) & 3; \ | ||
365 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
366 | + data = qd[H4(off[beat] >> 2)]; \ | ||
367 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
368 | + } \ | ||
369 | + } | ||
370 | + | ||
371 | +DO_VST4B(vst40b, 0, 1, 10, 11) | ||
372 | +DO_VST4B(vst41b, 2, 3, 12, 13) | ||
373 | +DO_VST4B(vst42b, 4, 5, 14, 15) | ||
374 | +DO_VST4B(vst43b, 6, 7, 8, 9) | ||
375 | + | ||
376 | +DO_VST4H(vst40h, 0, 5) | ||
377 | +DO_VST4H(vst41h, 1, 6) | ||
378 | +DO_VST4H(vst42h, 2, 7) | ||
379 | +DO_VST4H(vst43h, 3, 4) | ||
380 | + | ||
381 | +DO_VST4W(vst40w, 0, 1, 10, 11) | ||
382 | +DO_VST4W(vst41w, 2, 3, 12, 13) | ||
383 | +DO_VST4W(vst42w, 4, 5, 14, 15) | ||
384 | +DO_VST4W(vst43w, 6, 7, 8, 9) | ||
385 | + | ||
386 | +#define DO_VST2B(OP, O1, O2, O3, O4) \ | ||
387 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
388 | + uint32_t base) \ | ||
389 | + { \ | ||
390 | + int beat, e; \ | ||
391 | + uint16_t mask = mve_eci_mask(env); \ | ||
392 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
393 | + uint32_t addr, data; \ | ||
394 | + uint8_t *qd; \ | ||
395 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
396 | + if ((mask & 1) == 0) { \ | ||
397 | + /* ECI says skip this beat */ \ | ||
398 | + continue; \ | ||
399 | + } \ | ||
400 | + addr = base + off[beat] * 2; \ | ||
401 | + data = 0; \ | ||
402 | + for (e = 3; e >= 0; e--) { \ | ||
403 | + qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + (e & 1)); \ | ||
404 | + data = (data << 8) | qd[H1(off[beat] + (e >> 1))]; \ | ||
405 | + } \ | ||
406 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
407 | + } \ | ||
408 | + } | ||
409 | + | ||
410 | +#define DO_VST2H(OP, O1, O2, O3, O4) \ | ||
411 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
412 | + uint32_t base) \ | ||
413 | + { \ | ||
414 | + int beat; \ | ||
415 | + uint16_t mask = mve_eci_mask(env); \ | ||
416 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
417 | + uint32_t addr, data; \ | ||
418 | + int e; \ | ||
419 | + uint16_t *qd; \ | ||
420 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
421 | + if ((mask & 1) == 0) { \ | ||
422 | + /* ECI says skip this beat */ \ | ||
423 | + continue; \ | ||
424 | + } \ | ||
425 | + addr = base + off[beat] * 4; \ | ||
426 | + data = 0; \ | ||
427 | + for (e = 1; e >= 0; e--) { \ | ||
428 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
429 | + data = (data << 16) | qd[H2(off[beat])]; \ | ||
430 | + } \ | ||
431 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
432 | + } \ | ||
433 | + } | ||
434 | + | ||
435 | +#define DO_VST2W(OP, O1, O2, O3, O4) \ | ||
436 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
437 | + uint32_t base) \ | ||
438 | + { \ | ||
439 | + int beat; \ | ||
440 | + uint16_t mask = mve_eci_mask(env); \ | ||
441 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
442 | + uint32_t addr, data; \ | ||
443 | + uint32_t *qd; \ | ||
444 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
445 | + if ((mask & 1) == 0) { \ | ||
446 | + /* ECI says skip this beat */ \ | ||
447 | + continue; \ | ||
448 | + } \ | ||
449 | + addr = base + off[beat]; \ | ||
450 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + (beat & 1)); \ | ||
451 | + data = qd[H4(off[beat] >> 3)]; \ | ||
452 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
453 | + } \ | ||
454 | + } | ||
455 | + | ||
456 | +DO_VST2B(vst20b, 0, 2, 12, 14) | ||
457 | +DO_VST2B(vst21b, 4, 6, 8, 10) | ||
458 | + | ||
459 | +DO_VST2H(vst20h, 0, 1, 6, 7) | ||
460 | +DO_VST2H(vst21h, 2, 3, 4, 5) | ||
461 | + | ||
462 | +DO_VST2W(vst20w, 0, 4, 24, 28) | ||
463 | +DO_VST2W(vst21w, 8, 12, 16, 20) | ||
464 | + | ||
465 | /* | ||
466 | * The mergemask(D, R, M) macro performs the operation "*D = R" but | ||
467 | * storing only the bytes which correspond to 1 bits in M, | ||
468 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
469 | index XXXXXXX..XXXXXXX 100644 | ||
470 | --- a/target/arm/translate-mve.c | ||
471 | +++ b/target/arm/translate-mve.c | ||
472 | @@ -XXX,XX +XXX,XX @@ static inline int vidup_imm(DisasContext *s, int x) | ||
473 | |||
474 | typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
475 | typedef void MVEGenLdStSGFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
476 | +typedef void MVEGenLdStIlFn(TCGv_ptr, TCGv_i32, TCGv_i32); | ||
477 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
478 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
479 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
480 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSTRD_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
481 | return do_ldst_sg_imm(s, a, fns[a->w], MO_64); | ||
482 | } | ||
483 | |||
484 | +static bool do_vldst_il(DisasContext *s, arg_vldst_il *a, MVEGenLdStIlFn *fn, | ||
485 | + int addrinc) | ||
486 | +{ | ||
487 | + TCGv_i32 rn; | ||
488 | + | ||
489 | + if (!dc_isar_feature(aa32_mve, s) || | ||
490 | + !mve_check_qreg_bank(s, a->qd) || | ||
491 | + !fn || (a->rn == 13 && a->w) || a->rn == 15) { | ||
492 | + /* Variously UNPREDICTABLE or UNDEF or related-encoding */ | ||
493 | + return false; | ||
494 | + } | ||
495 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
496 | + return true; | ||
497 | + } | ||
498 | + | ||
499 | + rn = load_reg(s, a->rn); | ||
500 | + /* | ||
501 | + * We pass the index of Qd, not a pointer, because the helper must | ||
502 | + * access multiple Q registers starting at Qd and working up. | ||
503 | + */ | ||
504 | + fn(cpu_env, tcg_constant_i32(a->qd), rn); | ||
505 | + | ||
506 | + if (a->w) { | ||
507 | + tcg_gen_addi_i32(rn, rn, addrinc); | ||
508 | + store_reg(s, a->rn, rn); | ||
509 | + } else { | ||
510 | + tcg_temp_free_i32(rn); | ||
511 | + } | ||
512 | + mve_update_and_store_eci(s); | ||
513 | + return true; | ||
514 | +} | ||
515 | + | ||
516 | +/* This macro is just to make the arrays more compact in these functions */ | ||
517 | +#define F(N) gen_helper_mve_##N | ||
518 | + | ||
519 | +static bool trans_VLD2(DisasContext *s, arg_vldst_il *a) | ||
520 | +{ | ||
521 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
522 | + { F(vld20b), F(vld20h), F(vld20w), NULL, }, | ||
523 | + { F(vld21b), F(vld21h), F(vld21w), NULL, }, | ||
524 | + { NULL, NULL, NULL, NULL }, | ||
525 | + { NULL, NULL, NULL, NULL }, | ||
526 | + }; | ||
527 | + if (a->qd > 6) { | ||
528 | + return false; | ||
529 | + } | ||
530 | + return do_vldst_il(s, a, fns[a->pat][a->size], 32); | ||
531 | +} | ||
532 | + | ||
533 | +static bool trans_VLD4(DisasContext *s, arg_vldst_il *a) | ||
534 | +{ | ||
535 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
536 | + { F(vld40b), F(vld40h), F(vld40w), NULL, }, | ||
537 | + { F(vld41b), F(vld41h), F(vld41w), NULL, }, | ||
538 | + { F(vld42b), F(vld42h), F(vld42w), NULL, }, | ||
539 | + { F(vld43b), F(vld43h), F(vld43w), NULL, }, | ||
540 | + }; | ||
541 | + if (a->qd > 4) { | ||
542 | + return false; | ||
543 | + } | ||
544 | + return do_vldst_il(s, a, fns[a->pat][a->size], 64); | ||
545 | +} | ||
546 | + | ||
547 | +static bool trans_VST2(DisasContext *s, arg_vldst_il *a) | ||
548 | +{ | ||
549 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
550 | + { F(vst20b), F(vst20h), F(vst20w), NULL, }, | ||
551 | + { F(vst21b), F(vst21h), F(vst21w), NULL, }, | ||
552 | + { NULL, NULL, NULL, NULL }, | ||
553 | + { NULL, NULL, NULL, NULL }, | ||
554 | + }; | ||
555 | + if (a->qd > 6) { | ||
556 | + return false; | ||
557 | + } | ||
558 | + return do_vldst_il(s, a, fns[a->pat][a->size], 32); | ||
559 | +} | ||
560 | + | ||
561 | +static bool trans_VST4(DisasContext *s, arg_vldst_il *a) | ||
562 | +{ | ||
563 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
564 | + { F(vst40b), F(vst40h), F(vst40w), NULL, }, | ||
565 | + { F(vst41b), F(vst41h), F(vst41w), NULL, }, | ||
566 | + { F(vst42b), F(vst42h), F(vst42w), NULL, }, | ||
567 | + { F(vst43b), F(vst43h), F(vst43w), NULL, }, | ||
568 | + }; | ||
569 | + if (a->qd > 4) { | ||
570 | + return false; | ||
571 | + } | ||
572 | + return do_vldst_il(s, a, fns[a->pat][a->size], 64); | ||
573 | +} | ||
574 | + | ||
575 | +#undef F | ||
576 | + | ||
577 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
578 | { | ||
579 | TCGv_ptr qd; | ||
580 | -- | 28 | -- |
581 | 2.20.1 | 29 | 2.34.1 |
582 | 30 | ||
583 | 31 | diff view generated by jsdifflib |
1 | Unlike A-profile, for M-profile the UDIV and SDIV insns can be | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | configured to raise an exception on division by zero, using the CCR | 2 | |
3 | DIV_0_TRP bit. | 3 | Previously we hard-coded the blocksize with GMID_EL1_BS. |
4 | 4 | But the value we choose for -cpu max does not match the | |
5 | Implement support for setting this bit by making the helper functions | 5 | value that cortex-a710 uses. |
6 | raise the appropriate exception. | 6 | |
7 | 7 | Mirror the way we handle dcz_blocksize. | |
8 | |||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20230811214031.171020-3-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210730151636.17254-3-peter.maydell@linaro.org | ||
11 | --- | 13 | --- |
12 | target/arm/cpu.h | 1 + | 14 | target/arm/cpu.h | 2 ++ |
13 | target/arm/helper.h | 4 ++-- | 15 | target/arm/internals.h | 6 ----- |
14 | target/arm/helper.c | 19 +++++++++++++++++-- | 16 | target/arm/tcg/translate.h | 2 ++ |
15 | target/arm/m_helper.c | 4 ++++ | 17 | target/arm/helper.c | 11 +++++--- |
16 | target/arm/translate.c | 4 ++-- | 18 | target/arm/tcg/cpu64.c | 1 + |
17 | 5 files changed, 26 insertions(+), 6 deletions(-) | 19 | target/arm/tcg/mte_helper.c | 46 ++++++++++++++++++++++------------ |
20 | target/arm/tcg/translate-a64.c | 5 ++-- | ||
21 | 7 files changed, 45 insertions(+), 28 deletions(-) | ||
18 | 22 | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 23 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
20 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 25 | --- a/target/arm/cpu.h |
22 | +++ b/target/arm/cpu.h | 26 | +++ b/target/arm/cpu.h |
23 | @@ -XXX,XX +XXX,XX @@ | 27 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
24 | #define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */ | 28 | |
25 | #define EXCP_LSERR 21 /* v8M LSERR SecureFault */ | 29 | /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ |
26 | #define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */ | 30 | uint8_t dcz_blocksize; |
27 | +#define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */ | 31 | + /* GM blocksize, in log_2(words), ie low 4 bits of GMID_EL0 */ |
28 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | 32 | + uint8_t gm_blocksize; |
29 | 33 | ||
30 | #define ARMV7M_EXCP_RESET 1 | 34 | uint64_t rvbar_prop; /* Property/input signals. */ |
31 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 35 | |
32 | index XXXXXXX..XXXXXXX 100644 | 36 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
33 | --- a/target/arm/helper.h | 37 | index XXXXXXX..XXXXXXX 100644 |
34 | +++ b/target/arm/helper.h | 38 | --- a/target/arm/internals.h |
35 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(add_saturate, i32, env, i32, i32) | 39 | +++ b/target/arm/internals.h |
36 | DEF_HELPER_3(sub_saturate, i32, env, i32, i32) | 40 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs); |
37 | DEF_HELPER_3(add_usaturate, i32, env, i32, i32) | 41 | |
38 | DEF_HELPER_3(sub_usaturate, i32, env, i32, i32) | 42 | #endif /* !CONFIG_USER_ONLY */ |
39 | -DEF_HELPER_FLAGS_2(sdiv, TCG_CALL_NO_RWG_SE, s32, s32, s32) | 43 | |
40 | -DEF_HELPER_FLAGS_2(udiv, TCG_CALL_NO_RWG_SE, i32, i32, i32) | 44 | -/* |
41 | +DEF_HELPER_FLAGS_3(sdiv, TCG_CALL_NO_RWG, s32, env, s32, s32) | 45 | - * The log2 of the words in the tag block, for GMID_EL1.BS. |
42 | +DEF_HELPER_FLAGS_3(udiv, TCG_CALL_NO_RWG, i32, env, i32, i32) | 46 | - * The is the maximum, 256 bytes, which manipulates 64-bits of tags. |
43 | DEF_HELPER_FLAGS_1(rbit, TCG_CALL_NO_RWG_SE, i32, i32) | 47 | - */ |
44 | 48 | -#define GMID_EL1_BS 6 | |
45 | #define PAS_OP(pfx) \ | 49 | - |
50 | /* | ||
51 | * SVE predicates are 1/8 the size of SVE vectors, and cannot use | ||
52 | * the same simd_desc() encoding due to restrictions on size. | ||
53 | diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/tcg/translate.h | ||
56 | +++ b/target/arm/tcg/translate.h | ||
57 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
58 | int8_t btype; | ||
59 | /* A copy of cpu->dcz_blocksize. */ | ||
60 | uint8_t dcz_blocksize; | ||
61 | + /* A copy of cpu->gm_blocksize. */ | ||
62 | + uint8_t gm_blocksize; | ||
63 | /* True if this page is guarded. */ | ||
64 | bool guarded_page; | ||
65 | /* Bottom two bits of XScale c15_cpar coprocessor access control reg */ | ||
46 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 66 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
47 | index XXXXXXX..XXXXXXX 100644 | 67 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/target/arm/helper.c | 68 | --- a/target/arm/helper.c |
49 | +++ b/target/arm/helper.c | 69 | +++ b/target/arm/helper.c |
50 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sxtb16)(uint32_t x) | 70 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = { |
51 | return res; | 71 | .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 6, |
72 | .access = PL1_RW, .accessfn = access_mte, | ||
73 | .fieldoffset = offsetof(CPUARMState, cp15.gcr_el1) }, | ||
74 | - { .name = "GMID_EL1", .state = ARM_CP_STATE_AA64, | ||
75 | - .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 4, | ||
76 | - .access = PL1_R, .accessfn = access_aa64_tid5, | ||
77 | - .type = ARM_CP_CONST, .resetvalue = GMID_EL1_BS }, | ||
78 | { .name = "TCO", .state = ARM_CP_STATE_AA64, | ||
79 | .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 7, | ||
80 | .type = ARM_CP_NO_RAW, | ||
81 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
82 | * then define only a RAZ/WI version of PSTATE.TCO. | ||
83 | */ | ||
84 | if (cpu_isar_feature(aa64_mte, cpu)) { | ||
85 | + ARMCPRegInfo gmid_reginfo = { | ||
86 | + .name = "GMID_EL1", .state = ARM_CP_STATE_AA64, | ||
87 | + .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 4, | ||
88 | + .access = PL1_R, .accessfn = access_aa64_tid5, | ||
89 | + .type = ARM_CP_CONST, .resetvalue = cpu->gm_blocksize, | ||
90 | + }; | ||
91 | + define_one_arm_cp_reg(cpu, &gmid_reginfo); | ||
92 | define_arm_cp_regs(cpu, mte_reginfo); | ||
93 | define_arm_cp_regs(cpu, mte_el0_cacheop_reginfo); | ||
94 | } else if (cpu_isar_feature(aa64_mte_insn_reg, cpu)) { | ||
95 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/target/arm/tcg/cpu64.c | ||
98 | +++ b/target/arm/tcg/cpu64.c | ||
99 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) | ||
100 | cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ | ||
101 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
102 | #endif | ||
103 | + cpu->gm_blocksize = 6; /* 256 bytes */ | ||
104 | |||
105 | cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); | ||
106 | cpu->sme_vq.supported = SVE_VQ_POW2_MAP; | ||
107 | diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/target/arm/tcg/mte_helper.c | ||
110 | +++ b/target/arm/tcg/mte_helper.c | ||
111 | @@ -XXX,XX +XXX,XX @@ void HELPER(st2g_stub)(CPUARMState *env, uint64_t ptr) | ||
112 | } | ||
52 | } | 113 | } |
53 | 114 | ||
54 | +static void handle_possible_div0_trap(CPUARMState *env, uintptr_t ra) | 115 | -#define LDGM_STGM_SIZE (4 << GMID_EL1_BS) |
55 | +{ | 116 | - |
56 | + /* | 117 | uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) |
57 | + * Take a division-by-zero exception if necessary; otherwise return | ||
58 | + * to get the usual non-trapping division behaviour (result of 0) | ||
59 | + */ | ||
60 | + if (arm_feature(env, ARM_FEATURE_M) | ||
61 | + && (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_DIV_0_TRP_MASK)) { | ||
62 | + raise_exception_ra(env, EXCP_DIVBYZERO, 0, 1, ra); | ||
63 | + } | ||
64 | +} | ||
65 | + | ||
66 | uint32_t HELPER(uxtb16)(uint32_t x) | ||
67 | { | 118 | { |
68 | uint32_t res; | 119 | int mmu_idx = cpu_mmu_index(env, false); |
69 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(uxtb16)(uint32_t x) | 120 | uintptr_t ra = GETPC(); |
70 | return res; | 121 | + int gm_bs = env_archcpu(env)->gm_blocksize; |
71 | } | 122 | + int gm_bs_bytes = 4 << gm_bs; |
72 | 123 | void *tag_mem; | |
73 | -int32_t HELPER(sdiv)(int32_t num, int32_t den) | 124 | |
74 | +int32_t HELPER(sdiv)(CPUARMState *env, int32_t num, int32_t den) | 125 | - ptr = QEMU_ALIGN_DOWN(ptr, LDGM_STGM_SIZE); |
75 | { | 126 | + ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); |
76 | if (den == 0) { | 127 | |
77 | + handle_possible_div0_trap(env, GETPC()); | 128 | /* Trap if accessing an invalid page. */ |
129 | tag_mem = allocation_tag_mem(env, mmu_idx, ptr, MMU_DATA_LOAD, | ||
130 | - LDGM_STGM_SIZE, MMU_DATA_LOAD, | ||
131 | - LDGM_STGM_SIZE / (2 * TAG_GRANULE), ra); | ||
132 | + gm_bs_bytes, MMU_DATA_LOAD, | ||
133 | + gm_bs_bytes / (2 * TAG_GRANULE), ra); | ||
134 | |||
135 | /* The tag is squashed to zero if the page does not support tags. */ | ||
136 | if (!tag_mem) { | ||
78 | return 0; | 137 | return 0; |
79 | } | 138 | } |
80 | if (num == INT_MIN && den == -1) { | 139 | |
81 | @@ -XXX,XX +XXX,XX @@ int32_t HELPER(sdiv)(int32_t num, int32_t den) | 140 | - QEMU_BUILD_BUG_ON(GMID_EL1_BS != 6); |
82 | return num / den; | 141 | /* |
142 | - * We are loading 64-bits worth of tags. The ordering of elements | ||
143 | - * within the word corresponds to a 64-bit little-endian operation. | ||
144 | + * The ordering of elements within the word corresponds to | ||
145 | + * a little-endian operation. | ||
146 | */ | ||
147 | - return ldq_le_p(tag_mem); | ||
148 | + switch (gm_bs) { | ||
149 | + case 6: | ||
150 | + /* 256 bytes -> 16 tags -> 64 result bits */ | ||
151 | + return ldq_le_p(tag_mem); | ||
152 | + default: | ||
153 | + /* cpu configured with unsupported gm blocksize. */ | ||
154 | + g_assert_not_reached(); | ||
155 | + } | ||
83 | } | 156 | } |
84 | 157 | ||
85 | -uint32_t HELPER(udiv)(uint32_t num, uint32_t den) | 158 | void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) |
86 | +uint32_t HELPER(udiv)(CPUARMState *env, uint32_t num, uint32_t den) | ||
87 | { | 159 | { |
88 | if (den == 0) { | 160 | int mmu_idx = cpu_mmu_index(env, false); |
89 | + handle_possible_div0_trap(env, GETPC()); | 161 | uintptr_t ra = GETPC(); |
90 | return 0; | 162 | + int gm_bs = env_archcpu(env)->gm_blocksize; |
163 | + int gm_bs_bytes = 4 << gm_bs; | ||
164 | void *tag_mem; | ||
165 | |||
166 | - ptr = QEMU_ALIGN_DOWN(ptr, LDGM_STGM_SIZE); | ||
167 | + ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | ||
168 | |||
169 | /* Trap if accessing an invalid page. */ | ||
170 | tag_mem = allocation_tag_mem(env, mmu_idx, ptr, MMU_DATA_STORE, | ||
171 | - LDGM_STGM_SIZE, MMU_DATA_LOAD, | ||
172 | - LDGM_STGM_SIZE / (2 * TAG_GRANULE), ra); | ||
173 | + gm_bs_bytes, MMU_DATA_LOAD, | ||
174 | + gm_bs_bytes / (2 * TAG_GRANULE), ra); | ||
175 | |||
176 | /* | ||
177 | * Tag store only happens if the page support tags, | ||
178 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
179 | return; | ||
91 | } | 180 | } |
92 | return num / den; | 181 | |
93 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(int idx) | 182 | - QEMU_BUILD_BUG_ON(GMID_EL1_BS != 6); |
94 | [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | 183 | /* |
95 | [EXCP_LSERR] = "v8M LSERR UsageFault", | 184 | - * We are storing 64-bits worth of tags. The ordering of elements |
96 | [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | 185 | - * within the word corresponds to a 64-bit little-endian operation. |
97 | + [EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault", | 186 | + * The ordering of elements within the word corresponds to |
98 | }; | 187 | + * a little-endian operation. |
99 | 188 | */ | |
100 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | 189 | - stq_le_p(tag_mem, val); |
101 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 190 | + switch (gm_bs) { |
102 | index XXXXXXX..XXXXXXX 100644 | 191 | + case 6: |
103 | --- a/target/arm/m_helper.c | 192 | + stq_le_p(tag_mem, val); |
104 | +++ b/target/arm/m_helper.c | ||
105 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
106 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
107 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; | ||
108 | break; | ||
109 | + case EXCP_DIVBYZERO: | ||
110 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
111 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_DIVBYZERO_MASK; | ||
112 | + break; | 193 | + break; |
113 | case EXCP_SWI: | 194 | + default: |
114 | /* The PC already points to the next instruction. */ | 195 | + /* cpu configured with unsupported gm blocksize. */ |
115 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure); | 196 | + g_assert_not_reached(); |
116 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 197 | + } |
117 | index XXXXXXX..XXXXXXX 100644 | 198 | } |
118 | --- a/target/arm/translate.c | 199 | |
119 | +++ b/target/arm/translate.c | 200 | void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val) |
120 | @@ -XXX,XX +XXX,XX @@ static bool op_div(DisasContext *s, arg_rrr *a, bool u) | 201 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
121 | t1 = load_reg(s, a->rn); | 202 | index XXXXXXX..XXXXXXX 100644 |
122 | t2 = load_reg(s, a->rm); | 203 | --- a/target/arm/tcg/translate-a64.c |
123 | if (u) { | 204 | +++ b/target/arm/tcg/translate-a64.c |
124 | - gen_helper_udiv(t1, t1, t2); | 205 | @@ -XXX,XX +XXX,XX @@ static bool trans_STGM(DisasContext *s, arg_ldst_tag *a) |
125 | + gen_helper_udiv(t1, cpu_env, t1, t2); | 206 | gen_helper_stgm(cpu_env, addr, tcg_rt); |
126 | } else { | 207 | } else { |
127 | - gen_helper_sdiv(t1, t1, t2); | 208 | MMUAccessType acc = MMU_DATA_STORE; |
128 | + gen_helper_sdiv(t1, cpu_env, t1, t2); | 209 | - int size = 4 << GMID_EL1_BS; |
129 | } | 210 | + int size = 4 << s->gm_blocksize; |
130 | tcg_temp_free_i32(t2); | 211 | |
131 | store_reg(s, a->rd, t1); | 212 | clean_addr = clean_data_tbi(s, addr); |
213 | tcg_gen_andi_i64(clean_addr, clean_addr, -size); | ||
214 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDGM(DisasContext *s, arg_ldst_tag *a) | ||
215 | gen_helper_ldgm(tcg_rt, cpu_env, addr); | ||
216 | } else { | ||
217 | MMUAccessType acc = MMU_DATA_LOAD; | ||
218 | - int size = 4 << GMID_EL1_BS; | ||
219 | + int size = 4 << s->gm_blocksize; | ||
220 | |||
221 | clean_addr = clean_data_tbi(s, addr); | ||
222 | tcg_gen_andi_i64(clean_addr, clean_addr, -size); | ||
223 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
224 | dc->cp_regs = arm_cpu->cp_regs; | ||
225 | dc->features = env->features; | ||
226 | dc->dcz_blocksize = arm_cpu->dcz_blocksize; | ||
227 | + dc->gm_blocksize = arm_cpu->gm_blocksize; | ||
228 | |||
229 | #ifdef CONFIG_USER_ONLY | ||
230 | /* In sve_probe_page, we assume TBI is enabled. */ | ||
132 | -- | 231 | -- |
133 | 2.20.1 | 232 | 2.34.1 |
134 | |||
135 | diff view generated by jsdifflib |
1 | Implement the MVE integer vector comparison instructions that compare | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | each element against a scalar from a general purpose register. These | ||
3 | are "VCMP (vector)" encodings T4, T5 and T6 and "VPT (vector)" | ||
4 | encodings T4, T5 and T6. | ||
5 | 2 | ||
6 | We have to move the decodetree pattern for VPST, because it | 3 | Support all of the easy GM block sizes. |
7 | overlaps with VCMP T4 with size = 0b11. | 4 | Use direct memory operations, since the pointers are aligned. |
8 | 5 | ||
6 | While BS=2 (16 bytes, 1 tag) is a legal setting, that requires | ||
7 | an atomic store of one nibble. This is not difficult, but there | ||
8 | is also no point in supporting it until required. | ||
9 | |||
10 | Note that cortex-a710 sets GM blocksize to match its cacheline | ||
11 | size of 64 bytes. I expect many implementations will also | ||
12 | match the cacheline, which makes 16 bytes very unlikely. | ||
13 | |||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Message-id: 20230811214031.171020-4-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | 18 | --- |
12 | target/arm/helper-mve.h | 32 +++++++++++++++++++++++++++ | 19 | target/arm/cpu.c | 18 +++++++++--- |
13 | target/arm/mve.decode | 18 +++++++++++++--- | 20 | target/arm/tcg/mte_helper.c | 56 +++++++++++++++++++++++++++++++------ |
14 | target/arm/mve_helper.c | 44 +++++++++++++++++++++++++++++++------- | 21 | 2 files changed, 62 insertions(+), 12 deletions(-) |
15 | target/arm/translate-mve.c | 43 +++++++++++++++++++++++++++++++++++++ | ||
16 | 4 files changed, 126 insertions(+), 11 deletions(-) | ||
17 | 22 | ||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 23 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
19 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper-mve.h | 25 | --- a/target/arm/cpu.c |
21 | +++ b/target/arm/helper-mve.h | 26 | +++ b/target/arm/cpu.c |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vcmpgtw, TCG_CALL_NO_WG, void, env, ptr, ptr) | 27 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
23 | DEF_HELPER_FLAGS_3(mve_vcmpleb, TCG_CALL_NO_WG, void, env, ptr, ptr) | 28 | ID_PFR1, VIRTUALIZATION, 0); |
24 | DEF_HELPER_FLAGS_3(mve_vcmpleh, TCG_CALL_NO_WG, void, env, ptr, ptr) | 29 | } |
25 | DEF_HELPER_FLAGS_3(mve_vcmplew, TCG_CALL_NO_WG, void, env, ptr, ptr) | 30 | |
31 | + if (cpu_isar_feature(aa64_mte, cpu)) { | ||
32 | + /* | ||
33 | + * The architectural range of GM blocksize is 2-6, however qemu | ||
34 | + * doesn't support blocksize of 2 (see HELPER(ldgm)). | ||
35 | + */ | ||
36 | + if (tcg_enabled()) { | ||
37 | + assert(cpu->gm_blocksize >= 3 && cpu->gm_blocksize <= 6); | ||
38 | + } | ||
26 | + | 39 | + |
27 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | 40 | #ifndef CONFIG_USER_ONLY |
28 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | 41 | - if (cpu->tag_memory == NULL && cpu_isar_feature(aa64_mte, cpu)) { |
29 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | 42 | /* |
30 | + | 43 | * Disable the MTE feature bits if we do not have tag-memory |
31 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | 44 | * provided by the machine. |
32 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | 45 | */ |
33 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | 46 | - cpu->isar.id_aa64pfr1 = |
34 | + | 47 | - FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); |
35 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | 48 | - } |
36 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | 49 | + if (cpu->tag_memory == NULL) { |
37 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | 50 | + cpu->isar.id_aa64pfr1 = |
38 | + | 51 | + FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); |
39 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | 52 | + } |
40 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | 53 | #endif |
41 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | 54 | + } |
42 | + | 55 | |
43 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | 56 | if (tcg_enabled()) { |
44 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | 57 | /* |
45 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | 58 | diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c |
46 | + | ||
47 | +DEF_HELPER_FLAGS_3(mve_vcmplt_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
48 | +DEF_HELPER_FLAGS_3(mve_vcmplt_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
49 | +DEF_HELPER_FLAGS_3(mve_vcmplt_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
50 | + | ||
51 | +DEF_HELPER_FLAGS_3(mve_vcmpgt_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_3(mve_vcmpgt_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
53 | +DEF_HELPER_FLAGS_3(mve_vcmpgt_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
54 | + | ||
55 | +DEF_HELPER_FLAGS_3(mve_vcmple_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
56 | +DEF_HELPER_FLAGS_3(mve_vcmple_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
57 | +DEF_HELPER_FLAGS_3(mve_vcmple_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
58 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
59 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/target/arm/mve.decode | 60 | --- a/target/arm/tcg/mte_helper.c |
61 | +++ b/target/arm/mve.decode | 61 | +++ b/target/arm/tcg/mte_helper.c |
62 | @@ -XXX,XX +XXX,XX @@ | 62 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) |
63 | &vidup qd rn size imm | 63 | int gm_bs = env_archcpu(env)->gm_blocksize; |
64 | &viwdup qd rn rm size imm | 64 | int gm_bs_bytes = 4 << gm_bs; |
65 | &vcmp qm qn size mask | 65 | void *tag_mem; |
66 | +&vcmp_scalar qn rm size mask | 66 | + uint64_t ret; |
67 | 67 | + int shift; | |
68 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | 68 | |
69 | # Note that both Rn and Qd are 3 bits only (no D bit) | 69 | ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); |
70 | @@ -XXX,XX +XXX,XX @@ | 70 | |
71 | # Vector comparison; 4-bit Qm but 3-bit Qn | 71 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) |
72 | %mask_22_13 22:1 13:3 | 72 | |
73 | @vcmp .... .... .. size:2 qn:3 . .... .... .... .... &vcmp qm=%qm mask=%mask_22_13 | 73 | /* |
74 | +@vcmp_scalar .... .... .. size:2 qn:3 . .... .... .... rm:4 &vcmp_scalar \ | 74 | * The ordering of elements within the word corresponds to |
75 | + mask=%mask_22_13 | 75 | - * a little-endian operation. |
76 | 76 | + * a little-endian operation. Computation of shift comes from | |
77 | # Vector loads and stores | 77 | + * |
78 | 78 | + * index = address<LOG2_TAG_GRANULE+3:LOG2_TAG_GRANULE> | |
79 | @@ -XXX,XX +XXX,XX @@ VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | 79 | + * data<index*4+3:index*4> = tag |
80 | rdahi=%rdahi rdalo=%rdalo | 80 | + * |
81 | + * Because of the alignment of ptr above, BS=6 has shift=0. | ||
82 | + * All memory operations are aligned. Defer support for BS=2, | ||
83 | + * requiring insertion or extraction of a nibble, until we | ||
84 | + * support a cpu that requires it. | ||
85 | */ | ||
86 | switch (gm_bs) { | ||
87 | + case 3: | ||
88 | + /* 32 bytes -> 2 tags -> 8 result bits */ | ||
89 | + ret = *(uint8_t *)tag_mem; | ||
90 | + break; | ||
91 | + case 4: | ||
92 | + /* 64 bytes -> 4 tags -> 16 result bits */ | ||
93 | + ret = cpu_to_le16(*(uint16_t *)tag_mem); | ||
94 | + break; | ||
95 | + case 5: | ||
96 | + /* 128 bytes -> 8 tags -> 32 result bits */ | ||
97 | + ret = cpu_to_le32(*(uint32_t *)tag_mem); | ||
98 | + break; | ||
99 | case 6: | ||
100 | /* 256 bytes -> 16 tags -> 64 result bits */ | ||
101 | - return ldq_le_p(tag_mem); | ||
102 | + return cpu_to_le64(*(uint64_t *)tag_mem); | ||
103 | default: | ||
104 | - /* cpu configured with unsupported gm blocksize. */ | ||
105 | + /* | ||
106 | + * CPU configured with unsupported/invalid gm blocksize. | ||
107 | + * This is detected early in arm_cpu_realizefn. | ||
108 | + */ | ||
109 | g_assert_not_reached(); | ||
110 | } | ||
111 | + shift = extract64(ptr, LOG2_TAG_GRANULE, 4) * 4; | ||
112 | + return ret << shift; | ||
81 | } | 113 | } |
82 | 114 | ||
83 | -# Predicate operations | 115 | void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) |
84 | -VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | 116 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) |
85 | - | 117 | int gm_bs = env_archcpu(env)->gm_blocksize; |
86 | # Logical immediate operations (1 reg and modified-immediate) | 118 | int gm_bs_bytes = 4 << gm_bs; |
87 | 119 | void *tag_mem; | |
88 | # The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but | 120 | + int shift; |
89 | @@ -XXX,XX +XXX,XX @@ VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | 121 | |
90 | VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | 122 | ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); |
91 | VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | 123 | |
92 | VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | 124 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) |
93 | + | 125 | return; |
94 | +{ | ||
95 | + VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
96 | + VCMPEQ_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 0 0 .... @vcmp_scalar | ||
97 | +} | ||
98 | +VCMPNE_scalar 1111 1110 0 . .. ... 1 ... 0 1111 1 1 0 0 .... @vcmp_scalar | ||
99 | +VCMPCS_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 1 0 .... @vcmp_scalar | ||
100 | +VCMPHI_scalar 1111 1110 0 . .. ... 1 ... 0 1111 1 1 1 0 .... @vcmp_scalar | ||
101 | +VCMPGE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 0 0 .... @vcmp_scalar | ||
102 | +VCMPLT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 0 0 .... @vcmp_scalar | ||
103 | +VCMPGT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 1 0 .... @vcmp_scalar | ||
104 | +VCMPLE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 1 0 .... @vcmp_scalar | ||
105 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/mve_helper.c | ||
108 | +++ b/target/arm/mve_helper.c | ||
109 | @@ -XXX,XX +XXX,XX @@ DO_VIWDUP_ALL(vdwdup, do_sub_wrap) | ||
110 | mve_advance_vpt(env); \ | ||
111 | } | 126 | } |
112 | 127 | ||
113 | -#define DO_VCMP_S(OP, FN) \ | 128 | - /* |
114 | - DO_VCMP(OP##b, 1, int8_t, FN) \ | 129 | - * The ordering of elements within the word corresponds to |
115 | - DO_VCMP(OP##h, 2, int16_t, FN) \ | 130 | - * a little-endian operation. |
116 | - DO_VCMP(OP##w, 4, int32_t, FN) | 131 | - */ |
117 | +#define DO_VCMP_SCALAR(OP, ESIZE, TYPE, FN) \ | 132 | + /* See LDGM for comments on BS and on shift. */ |
118 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | 133 | + shift = extract64(ptr, LOG2_TAG_GRANULE, 4) * 4; |
119 | + uint32_t rm) \ | 134 | + val >>= shift; |
120 | + { \ | 135 | switch (gm_bs) { |
121 | + TYPE *n = vn; \ | 136 | + case 3: |
122 | + uint16_t mask = mve_element_mask(env); \ | 137 | + /* 32 bytes -> 2 tags -> 8 result bits */ |
123 | + uint16_t eci_mask = mve_eci_mask(env); \ | 138 | + *(uint8_t *)tag_mem = val; |
124 | + uint16_t beatpred = 0; \ | 139 | + break; |
125 | + uint16_t emask = MAKE_64BIT_MASK(0, ESIZE); \ | 140 | + case 4: |
126 | + unsigned e; \ | 141 | + /* 64 bytes -> 4 tags -> 16 result bits */ |
127 | + for (e = 0; e < 16 / ESIZE; e++) { \ | 142 | + *(uint16_t *)tag_mem = cpu_to_le16(val); |
128 | + bool r = FN(n[H##ESIZE(e)], (TYPE)rm); \ | 143 | + break; |
129 | + /* Comparison sets 0/1 bits for each byte in the element */ \ | 144 | + case 5: |
130 | + beatpred |= r * emask; \ | 145 | + /* 128 bytes -> 8 tags -> 32 result bits */ |
131 | + emask <<= ESIZE; \ | 146 | + *(uint32_t *)tag_mem = cpu_to_le32(val); |
132 | + } \ | 147 | + break; |
133 | + beatpred &= mask; \ | 148 | case 6: |
134 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | \ | 149 | - stq_le_p(tag_mem, val); |
135 | + (beatpred & eci_mask); \ | 150 | + /* 256 bytes -> 16 tags -> 64 result bits */ |
136 | + mve_advance_vpt(env); \ | 151 | + *(uint64_t *)tag_mem = cpu_to_le64(val); |
137 | + } | 152 | break; |
138 | 153 | default: | |
139 | -#define DO_VCMP_U(OP, FN) \ | 154 | /* cpu configured with unsupported gm blocksize. */ |
140 | - DO_VCMP(OP##b, 1, uint8_t, FN) \ | ||
141 | - DO_VCMP(OP##h, 2, uint16_t, FN) \ | ||
142 | - DO_VCMP(OP##w, 4, uint32_t, FN) | ||
143 | +#define DO_VCMP_S(OP, FN) \ | ||
144 | + DO_VCMP(OP##b, 1, int8_t, FN) \ | ||
145 | + DO_VCMP(OP##h, 2, int16_t, FN) \ | ||
146 | + DO_VCMP(OP##w, 4, int32_t, FN) \ | ||
147 | + DO_VCMP_SCALAR(OP##_scalarb, 1, int8_t, FN) \ | ||
148 | + DO_VCMP_SCALAR(OP##_scalarh, 2, int16_t, FN) \ | ||
149 | + DO_VCMP_SCALAR(OP##_scalarw, 4, int32_t, FN) | ||
150 | + | ||
151 | +#define DO_VCMP_U(OP, FN) \ | ||
152 | + DO_VCMP(OP##b, 1, uint8_t, FN) \ | ||
153 | + DO_VCMP(OP##h, 2, uint16_t, FN) \ | ||
154 | + DO_VCMP(OP##w, 4, uint32_t, FN) \ | ||
155 | + DO_VCMP_SCALAR(OP##_scalarb, 1, uint8_t, FN) \ | ||
156 | + DO_VCMP_SCALAR(OP##_scalarh, 2, uint16_t, FN) \ | ||
157 | + DO_VCMP_SCALAR(OP##_scalarw, 4, uint32_t, FN) | ||
158 | |||
159 | #define DO_EQ(N, M) ((N) == (M)) | ||
160 | #define DO_NE(N, M) ((N) != (M)) | ||
161 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
162 | index XXXXXXX..XXXXXXX 100644 | ||
163 | --- a/target/arm/translate-mve.c | ||
164 | +++ b/target/arm/translate-mve.c | ||
165 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
166 | typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
167 | typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
168 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
169 | +typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
170 | |||
171 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
172 | static inline long mve_qreg_offset(unsigned reg) | ||
173 | @@ -XXX,XX +XXX,XX @@ static bool do_vcmp(DisasContext *s, arg_vcmp *a, MVEGenCmpFn *fn) | ||
174 | return true; | ||
175 | } | ||
176 | |||
177 | +static bool do_vcmp_scalar(DisasContext *s, arg_vcmp_scalar *a, | ||
178 | + MVEGenScalarCmpFn *fn) | ||
179 | +{ | ||
180 | + TCGv_ptr qn; | ||
181 | + TCGv_i32 rm; | ||
182 | + | ||
183 | + if (!dc_isar_feature(aa32_mve, s) || !fn || a->rm == 13) { | ||
184 | + return false; | ||
185 | + } | ||
186 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
187 | + return true; | ||
188 | + } | ||
189 | + | ||
190 | + qn = mve_qreg_ptr(a->qn); | ||
191 | + if (a->rm == 15) { | ||
192 | + /* Encoding Rm=0b1111 means "constant zero" */ | ||
193 | + rm = tcg_constant_i32(0); | ||
194 | + } else { | ||
195 | + rm = load_reg(s, a->rm); | ||
196 | + } | ||
197 | + fn(cpu_env, qn, rm); | ||
198 | + tcg_temp_free_ptr(qn); | ||
199 | + tcg_temp_free_i32(rm); | ||
200 | + if (a->mask) { | ||
201 | + /* VPT */ | ||
202 | + gen_vpst(s, a->mask); | ||
203 | + } | ||
204 | + mve_update_eci(s); | ||
205 | + return true; | ||
206 | +} | ||
207 | + | ||
208 | #define DO_VCMP(INSN, FN) \ | ||
209 | static bool trans_##INSN(DisasContext *s, arg_vcmp *a) \ | ||
210 | { \ | ||
211 | @@ -XXX,XX +XXX,XX @@ static bool do_vcmp(DisasContext *s, arg_vcmp *a, MVEGenCmpFn *fn) | ||
212 | NULL, \ | ||
213 | }; \ | ||
214 | return do_vcmp(s, a, fns[a->size]); \ | ||
215 | + } \ | ||
216 | + static bool trans_##INSN##_scalar(DisasContext *s, \ | ||
217 | + arg_vcmp_scalar *a) \ | ||
218 | + { \ | ||
219 | + static MVEGenScalarCmpFn * const fns[] = { \ | ||
220 | + gen_helper_mve_##FN##_scalarb, \ | ||
221 | + gen_helper_mve_##FN##_scalarh, \ | ||
222 | + gen_helper_mve_##FN##_scalarw, \ | ||
223 | + NULL, \ | ||
224 | + }; \ | ||
225 | + return do_vcmp_scalar(s, a, fns[a->size]); \ | ||
226 | } | ||
227 | |||
228 | DO_VCMP(VCMPEQ, vcmpeq) | ||
229 | -- | 155 | -- |
230 | 2.20.1 | 156 | 2.34.1 |
231 | |||
232 | diff view generated by jsdifflib |
1 | From: Sebastian Meyer <meyer@absint.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | With gdb 9.0 and better it is possible to connect to a gdbstub | 3 | When the cpu support MTE, but the system does not, reduce cpu |
4 | over unix sockets, which is better than a TCP socket connection | 4 | support to user instructions at EL0 instead of completely |
5 | in some situations. The QEMU command line to set this up is | 5 | disabling MTE. If we encounter a cpu implementation which does |
6 | non-obvious; document it. | 6 | something else, we can revisit this setting. |
7 | 7 | ||
8 | Signed-off-by: Sebastian Meyer <meyer@absint.com> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 162867284829.27377.4784930719350564918-0@git.sr.ht | ||
10 | [PMM: Tweaked commit message; adjusted wording in a couple of | ||
11 | places; fixed rST formatting issue; moved section up out of | ||
12 | the 'advanced debugging options' subsection] | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 10 | Message-id: 20230811214031.171020-5-richard.henderson@linaro.org |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 12 | --- |
17 | docs/system/gdb.rst | 26 +++++++++++++++++++++++++- | 13 | target/arm/cpu.c | 7 ++++--- |
18 | 1 file changed, 25 insertions(+), 1 deletion(-) | 14 | 1 file changed, 4 insertions(+), 3 deletions(-) |
19 | 15 | ||
20 | diff --git a/docs/system/gdb.rst b/docs/system/gdb.rst | 16 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/docs/system/gdb.rst | 18 | --- a/target/arm/cpu.c |
23 | +++ b/docs/system/gdb.rst | 19 | +++ b/target/arm/cpu.c |
24 | @@ -XXX,XX +XXX,XX @@ The ``-s`` option will make QEMU listen for an incoming connection | 20 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
25 | from gdb on TCP port 1234, and ``-S`` will make QEMU not start the | 21 | |
26 | guest until you tell it to from gdb. (If you want to specify which | 22 | #ifndef CONFIG_USER_ONLY |
27 | TCP port to use or to use something other than TCP for the gdbstub | 23 | /* |
28 | -connection, use the ``-gdb dev`` option instead of ``-s``.) | 24 | - * Disable the MTE feature bits if we do not have tag-memory |
29 | +connection, use the ``-gdb dev`` option instead of ``-s``. See | 25 | - * provided by the machine. |
30 | +`Using unix sockets`_ for an example.) | 26 | + * If we do not have tag-memory provided by the machine, |
31 | 27 | + * reduce MTE support to instructions enabled at EL0. | |
32 | .. parsed-literal:: | 28 | + * This matches Cortex-A710 BROADCASTMTE input being LOW. |
33 | 29 | */ | |
34 | @@ -XXX,XX +XXX,XX @@ not just those in the cluster you are currently working on:: | 30 | if (cpu->tag_memory == NULL) { |
35 | 31 | cpu->isar.id_aa64pfr1 = | |
36 | (gdb) set schedule-multiple on | 32 | - FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); |
37 | 33 | + FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 1); | |
38 | +Using unix sockets | 34 | } |
39 | +================== | 35 | #endif |
40 | + | 36 | } |
41 | +An alternate method for connecting gdb to the QEMU gdbstub is to use | ||
42 | +a unix socket (if supported by your operating system). This is useful when | ||
43 | +running several tests in parallel, or if you do not have a known free TCP | ||
44 | +port (e.g. when running automated tests). | ||
45 | + | ||
46 | +First create a chardev with the appropriate options, then | ||
47 | +instruct the gdbserver to use that device: | ||
48 | + | ||
49 | +.. parsed-literal:: | ||
50 | + | ||
51 | + |qemu_system| -chardev socket,path=/tmp/gdb-socket,server=on,wait=off,id=gdb0 -gdb chardev:gdb0 -S ... | ||
52 | + | ||
53 | +Start gdb as before, but this time connect using the path to | ||
54 | +the socket:: | ||
55 | + | ||
56 | + (gdb) target remote /tmp/gdb-socket | ||
57 | + | ||
58 | +Note that to use a unix socket for the connection you will need | ||
59 | +gdb version 9.0 or newer. | ||
60 | + | ||
61 | Advanced debugging options | ||
62 | ========================== | ||
63 | |||
64 | -- | 37 | -- |
65 | 2.20.1 | 38 | 2.34.1 |
66 | |||
67 | diff view generated by jsdifflib |
1 | Implement the MVE VLDR/VSTR insns which do scatter-gather using base | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | addresses from Qm plus or minus an immediate offset (possibly with | ||
3 | writeback). Note that writeback is not predicated but it does have | ||
4 | to honour ECI state, so we have to add an eci_mask check to the | ||
5 | VSTR_SG macros (the VLDR_SG macros already needed this to be able | ||
6 | to distinguish "skip beat" from "set predicated element to 0"). | ||
7 | 2 | ||
3 | Do not hard-code the constants for Neoverse V1. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20230811214031.171020-6-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | 9 | --- |
11 | target/arm/helper-mve.h | 5 +++ | 10 | target/arm/tcg/cpu64.c | 48 ++++++++++++++++++++++++++++-------------- |
12 | target/arm/mve.decode | 10 +++++ | 11 | 1 file changed, 32 insertions(+), 16 deletions(-) |
13 | target/arm/mve_helper.c | 91 ++++++++++++++++++++++++-------------- | ||
14 | target/arm/translate-mve.c | 72 ++++++++++++++++++++++++++++++ | ||
15 | 4 files changed, 146 insertions(+), 32 deletions(-) | ||
16 | 12 | ||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 13 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper-mve.h | 15 | --- a/target/arm/tcg/cpu64.c |
20 | +++ b/target/arm/helper-mve.h | 16 | +++ b/target/arm/tcg/cpu64.c |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 17 | @@ -XXX,XX +XXX,XX @@ |
22 | DEF_HELPER_FLAGS_4(mve_vstrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 18 | #include "qemu/module.h" |
23 | DEF_HELPER_FLAGS_4(mve_vstrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | #include "qapi/visitor.h" |
24 | 20 | #include "hw/qdev-properties.h" | |
25 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 21 | +#include "qemu/units.h" |
26 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 22 | #include "internals.h" |
27 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 23 | #include "cpregs.h" |
28 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 24 | |
25 | +static uint64_t make_ccsidr64(unsigned assoc, unsigned linesize, | ||
26 | + unsigned cachesize) | ||
27 | +{ | ||
28 | + unsigned lg_linesize = ctz32(linesize); | ||
29 | + unsigned sets; | ||
29 | + | 30 | + |
30 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | 31 | + /* |
31 | 32 | + * The 64-bit CCSIDR_EL1 format is: | |
32 | DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | 33 | + * [55:32] number of sets - 1 |
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 34 | + * [23:3] associativity - 1 |
34 | index XXXXXXX..XXXXXXX 100644 | 35 | + * [2:0] log2(linesize) - 4 |
35 | --- a/target/arm/mve.decode | 36 | + * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc |
36 | +++ b/target/arm/mve.decode | 37 | + */ |
37 | @@ -XXX,XX +XXX,XX @@ | 38 | + assert(assoc != 0); |
38 | &vmaxv qm rda size | 39 | + assert(is_power_of_2(linesize)); |
39 | &vabav qn qm rda size | 40 | + assert(lg_linesize >= 4 && lg_linesize <= 7 + 4); |
40 | &vldst_sg qd qm rn size msize os | ||
41 | +&vldst_sg_imm qd qm a w imm | ||
42 | |||
43 | # scatter-gather memory size is in bits 6:4 | ||
44 | %sg_msize 6:1 4:1 | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | @vldst_sg .... .... .... rn:4 .... ... size:2 ... ... os:1 &vldst_sg \ | ||
47 | qd=%qd qm=%qm msize=%sg_msize | ||
48 | |||
49 | +# Qm is in the fields usually labeled Qn | ||
50 | +@vldst_sg_imm .... .... a:1 . w:1 . .... .... .... . imm:7 &vldst_sg_imm \ | ||
51 | + qd=%qd qm=%qn | ||
52 | + | 41 | + |
53 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | 42 | + /* sets * associativity * linesize == cachesize. */ |
54 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | 43 | + sets = cachesize / (assoc * linesize); |
55 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | 44 | + assert(cachesize % (assoc * linesize) == 0); |
56 | @@ -XXX,XX +XXX,XX @@ VLDR_S_sg 111 0 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
57 | VLDR_U_sg 111 1 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
58 | VSTR_sg 111 0 1100 1 . 00 .... ... 0 111 . .... .... @vldst_sg | ||
59 | |||
60 | +VLDRW_sg_imm 111 1 1101 ... 1 ... 0 ... 1 1110 .... .... @vldst_sg_imm | ||
61 | +VLDRD_sg_imm 111 1 1101 ... 1 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
62 | +VSTRW_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1110 .... .... @vldst_sg_imm | ||
63 | +VSTRD_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
64 | + | 45 | + |
65 | # Moves between 2 32-bit vector lanes and 2 general purpose registers | 46 | + return ((uint64_t)(sets - 1) << 32) |
66 | VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | 47 | + | ((assoc - 1) << 3) |
67 | VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | 48 | + | (lg_linesize - 4); |
68 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/arm/mve_helper.c | ||
71 | +++ b/target/arm/mve_helper.c | ||
72 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
73 | * For loads, predicated lanes are zeroed instead of retaining | ||
74 | * their previous values. | ||
75 | */ | ||
76 | -#define DO_VLDR_SG(OP, LDTYPE, ESIZE, TYPE, OFFTYPE, ADDRFN) \ | ||
77 | +#define DO_VLDR_SG(OP, LDTYPE, ESIZE, TYPE, OFFTYPE, ADDRFN, WB) \ | ||
78 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
79 | uint32_t base) \ | ||
80 | { \ | ||
81 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
82 | addr = ADDRFN(base, m[H##ESIZE(e)]); \ | ||
83 | d[H##ESIZE(e)] = (mask & 1) ? \ | ||
84 | cpu_##LDTYPE##_data_ra(env, addr, GETPC()) : 0; \ | ||
85 | + if (WB) { \ | ||
86 | + m[H##ESIZE(e)] = addr; \ | ||
87 | + } \ | ||
88 | } \ | ||
89 | mve_advance_vpt(env); \ | ||
90 | } | ||
91 | |||
92 | /* We know here TYPE is unsigned so always the same as the offset type */ | ||
93 | -#define DO_VSTR_SG(OP, STTYPE, ESIZE, TYPE, ADDRFN) \ | ||
94 | +#define DO_VSTR_SG(OP, STTYPE, ESIZE, TYPE, ADDRFN, WB) \ | ||
95 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
96 | uint32_t base) \ | ||
97 | { \ | ||
98 | TYPE *d = vd; \ | ||
99 | TYPE *m = vm; \ | ||
100 | uint16_t mask = mve_element_mask(env); \ | ||
101 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
102 | unsigned e; \ | ||
103 | uint32_t addr; \ | ||
104 | - for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
105 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE, eci_mask >>= ESIZE) { \ | ||
106 | + if (!(eci_mask & 1)) { \ | ||
107 | + continue; \ | ||
108 | + } \ | ||
109 | addr = ADDRFN(base, m[H##ESIZE(e)]); \ | ||
110 | if (mask & 1) { \ | ||
111 | cpu_##STTYPE##_data_ra(env, addr, d[H##ESIZE(e)], GETPC()); \ | ||
112 | } \ | ||
113 | + if (WB) { \ | ||
114 | + m[H##ESIZE(e)] = addr; \ | ||
115 | + } \ | ||
116 | } \ | ||
117 | mve_advance_vpt(env); \ | ||
118 | } | ||
119 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
120 | * accesses, controlled by the predicate mask for the relevant beat, | ||
121 | * and with a single 32-bit offset in the first of the two Qm elements. | ||
122 | * Note that for QEMU our IMPDEF AIRCR.ENDIANNESS is always 0 (little). | ||
123 | + * Address writeback happens on the odd beats and updates the address | ||
124 | + * stored in the even-beat element. | ||
125 | */ | ||
126 | -#define DO_VLDR64_SG(OP, ADDRFN) \ | ||
127 | +#define DO_VLDR64_SG(OP, ADDRFN, WB) \ | ||
128 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
129 | uint32_t base) \ | ||
130 | { \ | ||
131 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
132 | addr = ADDRFN(base, m[H4(e & ~1)]); \ | ||
133 | addr += 4 * (e & 1); \ | ||
134 | d[H4(e)] = (mask & 1) ? cpu_ldl_data_ra(env, addr, GETPC()) : 0; \ | ||
135 | + if (WB && (e & 1)) { \ | ||
136 | + m[H4(e & ~1)] = addr - 4; \ | ||
137 | + } \ | ||
138 | } \ | ||
139 | mve_advance_vpt(env); \ | ||
140 | } | ||
141 | |||
142 | -#define DO_VSTR64_SG(OP, ADDRFN) \ | ||
143 | +#define DO_VSTR64_SG(OP, ADDRFN, WB) \ | ||
144 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
145 | uint32_t base) \ | ||
146 | { \ | ||
147 | uint32_t *d = vd; \ | ||
148 | uint32_t *m = vm; \ | ||
149 | uint16_t mask = mve_element_mask(env); \ | ||
150 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
151 | unsigned e; \ | ||
152 | uint32_t addr; \ | ||
153 | - for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
154 | + for (e = 0; e < 16 / 4; e++, mask >>= 4, eci_mask >>= 4) { \ | ||
155 | + if (!(eci_mask & 1)) { \ | ||
156 | + continue; \ | ||
157 | + } \ | ||
158 | addr = ADDRFN(base, m[H4(e & ~1)]); \ | ||
159 | addr += 4 * (e & 1); \ | ||
160 | if (mask & 1) { \ | ||
161 | cpu_stl_data_ra(env, addr, d[H4(e)], GETPC()); \ | ||
162 | } \ | ||
163 | + if (WB && (e & 1)) { \ | ||
164 | + m[H4(e & ~1)] = addr - 4; \ | ||
165 | + } \ | ||
166 | } \ | ||
167 | mve_advance_vpt(env); \ | ||
168 | } | ||
169 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
170 | #define ADDR_ADD_OSW(BASE, OFFSET) ((BASE) + ((OFFSET) << 2)) | ||
171 | #define ADDR_ADD_OSD(BASE, OFFSET) ((BASE) + ((OFFSET) << 3)) | ||
172 | |||
173 | -DO_VLDR_SG(vldrb_sg_sh, ldsb, 2, int16_t, uint16_t, ADDR_ADD) | ||
174 | -DO_VLDR_SG(vldrb_sg_sw, ldsb, 4, int32_t, uint32_t, ADDR_ADD) | ||
175 | -DO_VLDR_SG(vldrh_sg_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD) | ||
176 | +DO_VLDR_SG(vldrb_sg_sh, ldsb, 2, int16_t, uint16_t, ADDR_ADD, false) | ||
177 | +DO_VLDR_SG(vldrb_sg_sw, ldsb, 4, int32_t, uint32_t, ADDR_ADD, false) | ||
178 | +DO_VLDR_SG(vldrh_sg_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD, false) | ||
179 | |||
180 | -DO_VLDR_SG(vldrb_sg_ub, ldub, 1, uint8_t, uint8_t, ADDR_ADD) | ||
181 | -DO_VLDR_SG(vldrb_sg_uh, ldub, 2, uint16_t, uint16_t, ADDR_ADD) | ||
182 | -DO_VLDR_SG(vldrb_sg_uw, ldub, 4, uint32_t, uint32_t, ADDR_ADD) | ||
183 | -DO_VLDR_SG(vldrh_sg_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD) | ||
184 | -DO_VLDR_SG(vldrh_sg_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD) | ||
185 | -DO_VLDR_SG(vldrw_sg_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD) | ||
186 | -DO_VLDR64_SG(vldrd_sg_ud, ADDR_ADD) | ||
187 | +DO_VLDR_SG(vldrb_sg_ub, ldub, 1, uint8_t, uint8_t, ADDR_ADD, false) | ||
188 | +DO_VLDR_SG(vldrb_sg_uh, ldub, 2, uint16_t, uint16_t, ADDR_ADD, false) | ||
189 | +DO_VLDR_SG(vldrb_sg_uw, ldub, 4, uint32_t, uint32_t, ADDR_ADD, false) | ||
190 | +DO_VLDR_SG(vldrh_sg_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD, false) | ||
191 | +DO_VLDR_SG(vldrh_sg_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD, false) | ||
192 | +DO_VLDR_SG(vldrw_sg_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD, false) | ||
193 | +DO_VLDR64_SG(vldrd_sg_ud, ADDR_ADD, false) | ||
194 | |||
195 | -DO_VLDR_SG(vldrh_sg_os_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD_OSH) | ||
196 | -DO_VLDR_SG(vldrh_sg_os_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD_OSH) | ||
197 | -DO_VLDR_SG(vldrh_sg_os_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD_OSH) | ||
198 | -DO_VLDR_SG(vldrw_sg_os_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD_OSW) | ||
199 | -DO_VLDR64_SG(vldrd_sg_os_ud, ADDR_ADD_OSD) | ||
200 | +DO_VLDR_SG(vldrh_sg_os_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD_OSH, false) | ||
201 | +DO_VLDR_SG(vldrh_sg_os_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD_OSH, false) | ||
202 | +DO_VLDR_SG(vldrh_sg_os_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD_OSH, false) | ||
203 | +DO_VLDR_SG(vldrw_sg_os_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD_OSW, false) | ||
204 | +DO_VLDR64_SG(vldrd_sg_os_ud, ADDR_ADD_OSD, false) | ||
205 | |||
206 | -DO_VSTR_SG(vstrb_sg_ub, stb, 1, uint8_t, ADDR_ADD) | ||
207 | -DO_VSTR_SG(vstrb_sg_uh, stb, 2, uint16_t, ADDR_ADD) | ||
208 | -DO_VSTR_SG(vstrb_sg_uw, stb, 4, uint32_t, ADDR_ADD) | ||
209 | -DO_VSTR_SG(vstrh_sg_uh, stw, 2, uint16_t, ADDR_ADD) | ||
210 | -DO_VSTR_SG(vstrh_sg_uw, stw, 4, uint32_t, ADDR_ADD) | ||
211 | -DO_VSTR_SG(vstrw_sg_uw, stl, 4, uint32_t, ADDR_ADD) | ||
212 | -DO_VSTR64_SG(vstrd_sg_ud, ADDR_ADD) | ||
213 | +DO_VSTR_SG(vstrb_sg_ub, stb, 1, uint8_t, ADDR_ADD, false) | ||
214 | +DO_VSTR_SG(vstrb_sg_uh, stb, 2, uint16_t, ADDR_ADD, false) | ||
215 | +DO_VSTR_SG(vstrb_sg_uw, stb, 4, uint32_t, ADDR_ADD, false) | ||
216 | +DO_VSTR_SG(vstrh_sg_uh, stw, 2, uint16_t, ADDR_ADD, false) | ||
217 | +DO_VSTR_SG(vstrh_sg_uw, stw, 4, uint32_t, ADDR_ADD, false) | ||
218 | +DO_VSTR_SG(vstrw_sg_uw, stl, 4, uint32_t, ADDR_ADD, false) | ||
219 | +DO_VSTR64_SG(vstrd_sg_ud, ADDR_ADD, false) | ||
220 | |||
221 | -DO_VSTR_SG(vstrh_sg_os_uh, stw, 2, uint16_t, ADDR_ADD_OSH) | ||
222 | -DO_VSTR_SG(vstrh_sg_os_uw, stw, 4, uint32_t, ADDR_ADD_OSH) | ||
223 | -DO_VSTR_SG(vstrw_sg_os_uw, stl, 4, uint32_t, ADDR_ADD_OSW) | ||
224 | -DO_VSTR64_SG(vstrd_sg_os_ud, ADDR_ADD_OSD) | ||
225 | +DO_VSTR_SG(vstrh_sg_os_uh, stw, 2, uint16_t, ADDR_ADD_OSH, false) | ||
226 | +DO_VSTR_SG(vstrh_sg_os_uw, stw, 4, uint32_t, ADDR_ADD_OSH, false) | ||
227 | +DO_VSTR_SG(vstrw_sg_os_uw, stl, 4, uint32_t, ADDR_ADD_OSW, false) | ||
228 | +DO_VSTR64_SG(vstrd_sg_os_ud, ADDR_ADD_OSD, false) | ||
229 | + | ||
230 | +DO_VLDR_SG(vldrw_sg_wb_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD, true) | ||
231 | +DO_VLDR64_SG(vldrd_sg_wb_ud, ADDR_ADD, true) | ||
232 | +DO_VSTR_SG(vstrw_sg_wb_uw, stl, 4, uint32_t, ADDR_ADD, true) | ||
233 | +DO_VSTR64_SG(vstrd_sg_wb_ud, ADDR_ADD, true) | ||
234 | |||
235 | /* | ||
236 | * The mergemask(D, R, M) macro performs the operation "*D = R" but | ||
237 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
238 | index XXXXXXX..XXXXXXX 100644 | ||
239 | --- a/target/arm/translate-mve.c | ||
240 | +++ b/target/arm/translate-mve.c | ||
241 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSTR_sg(DisasContext *s, arg_vldst_sg *a) | ||
242 | |||
243 | #undef F | ||
244 | |||
245 | +static bool do_ldst_sg_imm(DisasContext *s, arg_vldst_sg_imm *a, | ||
246 | + MVEGenLdStSGFn *fn, unsigned msize) | ||
247 | +{ | ||
248 | + uint32_t offset; | ||
249 | + TCGv_ptr qd, qm; | ||
250 | + | ||
251 | + if (!dc_isar_feature(aa32_mve, s) || | ||
252 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | ||
253 | + !fn) { | ||
254 | + return false; | ||
255 | + } | ||
256 | + | ||
257 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
258 | + return true; | ||
259 | + } | ||
260 | + | ||
261 | + offset = a->imm << msize; | ||
262 | + if (!a->a) { | ||
263 | + offset = -offset; | ||
264 | + } | ||
265 | + | ||
266 | + qd = mve_qreg_ptr(a->qd); | ||
267 | + qm = mve_qreg_ptr(a->qm); | ||
268 | + fn(cpu_env, qd, qm, tcg_constant_i32(offset)); | ||
269 | + tcg_temp_free_ptr(qd); | ||
270 | + tcg_temp_free_ptr(qm); | ||
271 | + mve_update_eci(s); | ||
272 | + return true; | ||
273 | +} | 49 | +} |
274 | + | 50 | + |
275 | +static bool trans_VLDRW_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | 51 | static void aarch64_a35_initfn(Object *obj) |
276 | +{ | ||
277 | + static MVEGenLdStSGFn * const fns[] = { | ||
278 | + gen_helper_mve_vldrw_sg_uw, | ||
279 | + gen_helper_mve_vldrw_sg_wb_uw, | ||
280 | + }; | ||
281 | + if (a->qd == a->qm) { | ||
282 | + return false; /* UNPREDICTABLE */ | ||
283 | + } | ||
284 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_32); | ||
285 | +} | ||
286 | + | ||
287 | +static bool trans_VLDRD_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
288 | +{ | ||
289 | + static MVEGenLdStSGFn * const fns[] = { | ||
290 | + gen_helper_mve_vldrd_sg_ud, | ||
291 | + gen_helper_mve_vldrd_sg_wb_ud, | ||
292 | + }; | ||
293 | + if (a->qd == a->qm) { | ||
294 | + return false; /* UNPREDICTABLE */ | ||
295 | + } | ||
296 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_64); | ||
297 | +} | ||
298 | + | ||
299 | +static bool trans_VSTRW_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
300 | +{ | ||
301 | + static MVEGenLdStSGFn * const fns[] = { | ||
302 | + gen_helper_mve_vstrw_sg_uw, | ||
303 | + gen_helper_mve_vstrw_sg_wb_uw, | ||
304 | + }; | ||
305 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_32); | ||
306 | +} | ||
307 | + | ||
308 | +static bool trans_VSTRD_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
309 | +{ | ||
310 | + static MVEGenLdStSGFn * const fns[] = { | ||
311 | + gen_helper_mve_vstrd_sg_ud, | ||
312 | + gen_helper_mve_vstrd_sg_wb_ud, | ||
313 | + }; | ||
314 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_64); | ||
315 | +} | ||
316 | + | ||
317 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
318 | { | 52 | { |
319 | TCGv_ptr qd; | 53 | ARMCPU *cpu = ARM_CPU(obj); |
54 | @@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_v1_initfn(Object *obj) | ||
55 | * The Neoverse-V1 r1p2 TRM lists 32-bit format CCSIDR_EL1 values, | ||
56 | * but also says it implements CCIDX, which means they should be | ||
57 | * 64-bit format. So we here use values which are based on the textual | ||
58 | - * information in chapter 2 of the TRM (and on the fact that | ||
59 | - * sets * associativity * linesize == cachesize). | ||
60 | - * | ||
61 | - * The 64-bit CCSIDR_EL1 format is: | ||
62 | - * [55:32] number of sets - 1 | ||
63 | - * [23:3] associativity - 1 | ||
64 | - * [2:0] log2(linesize) - 4 | ||
65 | - * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc | ||
66 | - * | ||
67 | - * L1: 4-way set associative 64-byte line size, total size 64K, | ||
68 | - * so sets is 256. | ||
69 | + * information in chapter 2 of the TRM: | ||
70 | * | ||
71 | + * L1: 4-way set associative 64-byte line size, total size 64K. | ||
72 | * L2: 8-way set associative, 64 byte line size, either 512K or 1MB. | ||
73 | - * We pick 1MB, so this has 2048 sets. | ||
74 | - * | ||
75 | * L3: No L3 (this matches the CLIDR_EL1 value). | ||
76 | */ | ||
77 | - cpu->ccsidr[0] = 0x000000ff0000001aull; /* 64KB L1 dcache */ | ||
78 | - cpu->ccsidr[1] = 0x000000ff0000001aull; /* 64KB L1 icache */ | ||
79 | - cpu->ccsidr[2] = 0x000007ff0000003aull; /* 1MB L2 cache */ | ||
80 | + cpu->ccsidr[0] = make_ccsidr64(4, 64, 64 * KiB); /* L1 dcache */ | ||
81 | + cpu->ccsidr[1] = cpu->ccsidr[0]; /* L1 icache */ | ||
82 | + cpu->ccsidr[2] = make_ccsidr64(8, 64, 1 * MiB); /* L2 cache */ | ||
83 | |||
84 | /* From 3.2.115 SCTLR_EL3 */ | ||
85 | cpu->reset_sctlr = 0x30c50838; | ||
320 | -- | 86 | -- |
321 | 2.20.1 | 87 | 2.34.1 |
322 | |||
323 | diff view generated by jsdifflib |
1 | We're about to make a code change to the sdiv and udiv helper | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | functions, so first fix their indentation and coding style. | ||
3 | 2 | ||
3 | Access to many of the special registers is enabled or disabled | ||
4 | by ACTLR_EL[23], which we implement as constant 0, which means | ||
5 | that all writes outside EL3 should trap. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20230811214031.171020-7-richard.henderson@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210730151636.17254-2-peter.maydell@linaro.org | ||
7 | --- | 11 | --- |
8 | target/arm/helper.c | 15 +++++++++------ | 12 | target/arm/cpregs.h | 2 ++ |
9 | 1 file changed, 9 insertions(+), 6 deletions(-) | 13 | target/arm/helper.c | 4 ++-- |
14 | target/arm/tcg/cpu64.c | 46 +++++++++++++++++++++++++++++++++--------- | ||
15 | 3 files changed, 41 insertions(+), 11 deletions(-) | ||
10 | 16 | ||
17 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpregs.h | ||
20 | +++ b/target/arm/cpregs.h | ||
21 | @@ -XXX,XX +XXX,XX @@ static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } | ||
22 | void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); | ||
23 | #endif | ||
24 | |||
25 | +CPAccessResult access_tvm_trvm(CPUARMState *, const ARMCPRegInfo *, bool); | ||
26 | + | ||
27 | #endif /* TARGET_ARM_CPREGS_H */ | ||
11 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 28 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/helper.c | 30 | --- a/target/arm/helper.c |
14 | +++ b/target/arm/helper.c | 31 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(uxtb16)(uint32_t x) | 32 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri, |
16 | 33 | } | |
17 | int32_t HELPER(sdiv)(int32_t num, int32_t den) | 34 | |
35 | /* Check for traps from EL1 due to HCR_EL2.TVM and HCR_EL2.TRVM. */ | ||
36 | -static CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, | ||
37 | - bool isread) | ||
38 | +CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, | ||
39 | + bool isread) | ||
18 | { | 40 | { |
19 | - if (den == 0) | 41 | if (arm_current_el(env) == 1) { |
20 | - return 0; | 42 | uint64_t trap = isread ? HCR_TRVM : HCR_TVM; |
21 | - if (num == INT_MIN && den == -1) | 43 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
22 | - return INT_MIN; | 44 | index XXXXXXX..XXXXXXX 100644 |
23 | + if (den == 0) { | 45 | --- a/target/arm/tcg/cpu64.c |
24 | + return 0; | 46 | +++ b/target/arm/tcg/cpu64.c |
47 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj) | ||
48 | /* TODO: Add A64FX specific HPC extension registers */ | ||
49 | } | ||
50 | |||
51 | +static CPAccessResult access_actlr_w(CPUARMState *env, const ARMCPRegInfo *r, | ||
52 | + bool read) | ||
53 | +{ | ||
54 | + if (!read) { | ||
55 | + int el = arm_current_el(env); | ||
56 | + | ||
57 | + /* Because ACTLR_EL2 is constant 0, writes below EL2 trap to EL2. */ | ||
58 | + if (el < 2 && arm_is_el2_enabled(env)) { | ||
59 | + return CP_ACCESS_TRAP_EL2; | ||
60 | + } | ||
61 | + /* Because ACTLR_EL3 is constant 0, writes below EL3 trap to EL3. */ | ||
62 | + if (el < 3 && arm_feature(env, ARM_FEATURE_EL3)) { | ||
63 | + return CP_ACCESS_TRAP_EL3; | ||
64 | + } | ||
25 | + } | 65 | + } |
26 | + if (num == INT_MIN && den == -1) { | 66 | + return CP_ACCESS_OK; |
27 | + return INT_MIN; | 67 | +} |
28 | + } | 68 | + |
29 | return num / den; | 69 | static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { |
30 | } | 70 | { .name = "ATCR_EL1", .state = ARM_CP_STATE_AA64, |
31 | 71 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 7, .opc2 = 0, | |
32 | uint32_t HELPER(udiv)(uint32_t num, uint32_t den) | 72 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
33 | { | 73 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, |
34 | - if (den == 0) | 74 | + /* Traps and enables are the same as for TCR_EL1. */ |
35 | - return 0; | 75 | + .accessfn = access_tvm_trvm, .fgt = FGT_TCR_EL1, }, |
36 | + if (den == 0) { | 76 | { .name = "ATCR_EL2", .state = ARM_CP_STATE_AA64, |
37 | + return 0; | 77 | .opc0 = 3, .opc1 = 4, .crn = 15, .crm = 7, .opc2 = 0, |
38 | + } | 78 | .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
39 | return num / den; | 79 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { |
40 | } | 80 | .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
41 | 81 | { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64, | |
82 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 0, | ||
83 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
84 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
85 | + .accessfn = access_actlr_w }, | ||
86 | { .name = "CPUACTLR2_EL1", .state = ARM_CP_STATE_AA64, | ||
87 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 1, | ||
88 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
89 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
90 | + .accessfn = access_actlr_w }, | ||
91 | { .name = "CPUACTLR3_EL1", .state = ARM_CP_STATE_AA64, | ||
92 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 2, | ||
93 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
94 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
95 | + .accessfn = access_actlr_w }, | ||
96 | /* | ||
97 | * Report CPUCFR_EL1.SCU as 1, as we do not implement the DSU | ||
98 | * (and in particular its system registers). | ||
99 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { | ||
100 | .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 4 }, | ||
101 | { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
102 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 4, | ||
103 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010 }, | ||
104 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010, | ||
105 | + .accessfn = access_actlr_w }, | ||
106 | { .name = "CPUPCR_EL3", .state = ARM_CP_STATE_AA64, | ||
107 | .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 1, | ||
108 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
109 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { | ||
110 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
111 | { .name = "CPUPWRCTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
112 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 7, | ||
113 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
114 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
115 | + .accessfn = access_actlr_w }, | ||
116 | { .name = "ERXPFGCDN_EL1", .state = ARM_CP_STATE_AA64, | ||
117 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 2, | ||
118 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
119 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
120 | + .accessfn = access_actlr_w }, | ||
121 | { .name = "ERXPFGCTL_EL1", .state = ARM_CP_STATE_AA64, | ||
122 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 1, | ||
123 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
124 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
125 | + .accessfn = access_actlr_w }, | ||
126 | { .name = "ERXPFGF_EL1", .state = ARM_CP_STATE_AA64, | ||
127 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 0, | ||
128 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
129 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
130 | + .accessfn = access_actlr_w }, | ||
131 | }; | ||
132 | |||
133 | static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu) | ||
42 | -- | 134 | -- |
43 | 2.20.1 | 135 | 2.34.1 |
44 | |||
45 | diff view generated by jsdifflib |
1 | In mve_element_mask(), we calculate a mask for tail predication which | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | should have a number of 1 bits based on the value of LR. However, | ||
3 | our MAKE_64BIT_MASK() macro has undefined behaviour when passed a | ||
4 | zero length. Special case this to give the all-zeroes mask we | ||
5 | require. | ||
6 | 2 | ||
3 | There is only one additional EL1 register modeled, which | ||
4 | also needs to use access_actlr_w. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20230811214031.171020-8-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | 10 | --- |
10 | target/arm/mve_helper.c | 3 ++- | 11 | target/arm/tcg/cpu64.c | 3 ++- |
11 | 1 file changed, 2 insertions(+), 1 deletion(-) | 12 | 1 file changed, 2 insertions(+), 1 deletion(-) |
12 | 13 | ||
13 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 14 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/mve_helper.c | 16 | --- a/target/arm/tcg/cpu64.c |
16 | +++ b/target/arm/mve_helper.c | 17 | +++ b/target/arm/tcg/cpu64.c |
17 | @@ -XXX,XX +XXX,XX @@ static uint16_t mve_element_mask(CPUARMState *env) | 18 | @@ -XXX,XX +XXX,XX @@ static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu) |
18 | */ | 19 | static const ARMCPRegInfo neoverse_v1_cp_reginfo[] = { |
19 | int masklen = env->regs[14] << env->v7m.ltpsize; | 20 | { .name = "CPUECTLR2_EL1", .state = ARM_CP_STATE_AA64, |
20 | assert(masklen <= 16); | 21 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 5, |
21 | - mask &= MAKE_64BIT_MASK(0, masklen); | 22 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
22 | + uint16_t ltpmask = masklen ? MAKE_64BIT_MASK(0, masklen) : 0; | 23 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, |
23 | + mask &= ltpmask; | 24 | + .accessfn = access_actlr_w }, |
24 | } | 25 | { .name = "CPUPPMCR_EL3", .state = ARM_CP_STATE_AA64, |
25 | 26 | .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 2, .opc2 = 0, | |
26 | if ((env->condexec_bits & 0xf) == 0) { | 27 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
27 | -- | 28 | -- |
28 | 2.20.1 | 29 | 2.34.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | Include the MVE VPR register value in the CPU dumps produced by | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | arm_cpu_dump_state() if we are printing FPU information. This | ||
3 | makes it easier to interpret debug logs when predication is | ||
4 | active. | ||
5 | 2 | ||
3 | Like FEAT_TRF (Self-hosted Trace Extension), suppress tracing | ||
4 | external to the cpu, which is out of scope for QEMU. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20230811214031.171020-10-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | 10 | --- |
9 | target/arm/cpu.c | 3 +++ | 11 | target/arm/cpu.c | 3 +++ |
10 | 1 file changed, 3 insertions(+) | 12 | 1 file changed, 3 insertions(+) |
11 | 13 | ||
12 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/cpu.c | 16 | --- a/target/arm/cpu.c |
15 | +++ b/target/arm/cpu.c | 17 | +++ b/target/arm/cpu.c |
16 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | 18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
17 | i, v); | 19 | /* FEAT_SPE (Statistical Profiling Extension) */ |
18 | } | 20 | cpu->isar.id_aa64dfr0 = |
19 | qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); | 21 | FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, PMSVER, 0); |
20 | + if (cpu_isar_feature(aa32_mve, cpu)) { | 22 | + /* FEAT_TRBE (Trace Buffer Extension) */ |
21 | + qemu_fprintf(f, "VPR: %08x\n", env->v7m.vpr); | 23 | + cpu->isar.id_aa64dfr0 = |
22 | + } | 24 | + FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEBUFFER, 0); |
23 | } | 25 | /* FEAT_TRF (Self-hosted Trace Extension) */ |
24 | } | 26 | cpu->isar.id_aa64dfr0 = |
25 | 27 | FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEFILT, 0); | |
26 | -- | 28 | -- |
27 | 2.20.1 | 29 | 2.34.1 |
28 | |||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In the MVE shift-and-insert insns, we special case VSLI by 0 | ||
2 | and VSRI by <dt>. VSRI by <dt> means "don't update the destination", | ||
3 | which is what we've implemented. However VSLI by 0 is "set | ||
4 | destination to the input", so we don't want to use the same | ||
5 | special-casing that we do for VSRI by <dt>. | ||
6 | 1 | ||
7 | Since the generic logic gives the right answer for a shift | ||
8 | by 0, just use that. | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | target/arm/mve_helper.c | 9 +++++---- | ||
14 | 1 file changed, 5 insertions(+), 4 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/mve_helper.c | ||
19 | +++ b/target/arm/mve_helper.c | ||
20 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
21 | uint16_t mask; \ | ||
22 | uint64_t shiftmask; \ | ||
23 | unsigned e; \ | ||
24 | - if (shift == 0 || shift == ESIZE * 8) { \ | ||
25 | + if (shift == ESIZE * 8) { \ | ||
26 | /* \ | ||
27 | - * Only VSLI can shift by 0; only VSRI can shift by <dt>. \ | ||
28 | - * The generic logic would give the right answer for 0 but \ | ||
29 | - * fails for <dt>. \ | ||
30 | + * Only VSRI can shift by <dt>; it should mean "don't \ | ||
31 | + * update the destination". The generic logic can't handle \ | ||
32 | + * this because it would try to shift by an out-of-range \ | ||
33 | + * amount, so special case it here. \ | ||
34 | */ \ | ||
35 | goto done; \ | ||
36 | } \ | ||
37 | -- | ||
38 | 2.20.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | A cut-and-paste error meant we handled signed VADDV like | ||
2 | unsigned VADDV; fix the type used. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/mve_helper.c | 6 +++--- | ||
8 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
9 | |||
10 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/arm/mve_helper.c | ||
13 | +++ b/target/arm/mve_helper.c | ||
14 | @@ -XXX,XX +XXX,XX @@ DO_LDAVH(vrmlsldavhxsw, int32_t, int64_t, true, true) | ||
15 | return ra; \ | ||
16 | } \ | ||
17 | |||
18 | -DO_VADDV(vaddvsb, 1, uint8_t) | ||
19 | -DO_VADDV(vaddvsh, 2, uint16_t) | ||
20 | -DO_VADDV(vaddvsw, 4, uint32_t) | ||
21 | +DO_VADDV(vaddvsb, 1, int8_t) | ||
22 | +DO_VADDV(vaddvsh, 2, int16_t) | ||
23 | +DO_VADDV(vaddvsw, 4, int32_t) | ||
24 | DO_VADDV(vaddvub, 1, uint8_t) | ||
25 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
26 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In the MVE helpers for the narrowing operations (DO_VSHRN and | ||
2 | DO_VSHRN_SAT) we were using the wrong bits of the predicate mask for | ||
3 | the 'top' versions of the insn. This is because the loop works over | ||
4 | the double-sized input elements and shifts the predicate mask by that | ||
5 | many bits each time, but when we write out the half-sized output we | ||
6 | must look at the mask bits for whichever half of the element we are | ||
7 | writing to. | ||
8 | 1 | ||
9 | Correct this by shifting the whole mask right by ESIZE bits for the | ||
10 | 'top' insns. This allows us also to simplify the saturation bit | ||
11 | checking (where we had noticed that we needed to look at a different | ||
12 | mask bit for the 'top' insn.) | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | ||
17 | target/arm/mve_helper.c | 4 +++- | ||
18 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/mve_helper.c | ||
23 | +++ b/target/arm/mve_helper.c | ||
24 | @@ -XXX,XX +XXX,XX @@ DO_VSHLL_ALL(vshllt, true) | ||
25 | TYPE *d = vd; \ | ||
26 | uint16_t mask = mve_element_mask(env); \ | ||
27 | unsigned le; \ | ||
28 | + mask >>= ESIZE * TOP; \ | ||
29 | for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
30 | TYPE r = FN(m[H##LESIZE(le)], shift); \ | ||
31 | mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
32 | @@ -XXX,XX +XXX,XX @@ static inline int32_t do_sat_bhs(int64_t val, int64_t min, int64_t max, | ||
33 | uint16_t mask = mve_element_mask(env); \ | ||
34 | bool qc = false; \ | ||
35 | unsigned le; \ | ||
36 | + mask >>= ESIZE * TOP; \ | ||
37 | for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
38 | bool sat = false; \ | ||
39 | TYPE r = FN(m[H##LESIZE(le)], shift, &sat); \ | ||
40 | mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
41 | - qc |= sat && (mask & 1 << (TOP * ESIZE)); \ | ||
42 | + qc |= sat & mask & 1; \ | ||
43 | } \ | ||
44 | if (qc) { \ | ||
45 | env->vfp.qc[0] = qc; \ | ||
46 | -- | ||
47 | 2.20.1 | ||
48 | |||
49 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In do_sqrshl48_d() and do_uqrshl48_d() we got some of the edge | ||
2 | cases wrong and failed to saturate correctly: | ||
3 | 1 | ||
4 | (1) In do_sqrshl48_d() we used the same code that do_shrshl_bhs() | ||
5 | does to obtain the saturated most-negative and most-positive 48-bit | ||
6 | signed values for the large-shift-left case. This gives (1 << 47) | ||
7 | for saturate-to-most-negative, but we weren't sign-extending this | ||
8 | value to the 64-bit output as the pseudocode requires. | ||
9 | |||
10 | (2) For left shifts by less than 48, we copied the "8/16 bit" code | ||
11 | from do_sqrshl_bhs() and do_uqrshl_bhs(). This doesn't do the right | ||
12 | thing because it assumes the C type we're working with is at least | ||
13 | twice the number of bits we're saturating to (so that a shift left by | ||
14 | bits-1 can't shift anything off the top of the value). This isn't | ||
15 | true for bits == 48, so we would incorrectly return 0 rather than the | ||
16 | most-positive value for situations like "shift (1 << 44) right by | ||
17 | 20". Instead check for saturation by doing the shift and signextend | ||
18 | and then testing whether shifting back left again gives the original | ||
19 | value. | ||
20 | |||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
23 | --- | ||
24 | target/arm/mve_helper.c | 12 +++++------- | ||
25 | 1 file changed, 5 insertions(+), 7 deletions(-) | ||
26 | |||
27 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/mve_helper.c | ||
30 | +++ b/target/arm/mve_helper.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
32 | } | ||
33 | return src >> -shift; | ||
34 | } else if (shift < 48) { | ||
35 | - int64_t val = src << shift; | ||
36 | - int64_t extval = sextract64(val, 0, 48); | ||
37 | - if (!sat || val == extval) { | ||
38 | + int64_t extval = sextract64(src << shift, 0, 48); | ||
39 | + if (!sat || src == (extval >> shift)) { | ||
40 | return extval; | ||
41 | } | ||
42 | } else if (!sat || src == 0) { | ||
43 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
44 | } | ||
45 | |||
46 | *sat = 1; | ||
47 | - return (1ULL << 47) - (src >= 0); | ||
48 | + return src >= 0 ? MAKE_64BIT_MASK(0, 47) : MAKE_64BIT_MASK(47, 17); | ||
49 | } | ||
50 | |||
51 | /* Operate on 64-bit values, but saturate at 48 bits */ | ||
52 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t do_uqrshl48_d(uint64_t src, int64_t shift, | ||
53 | return extval; | ||
54 | } | ||
55 | } else if (shift < 48) { | ||
56 | - uint64_t val = src << shift; | ||
57 | - uint64_t extval = extract64(val, 0, 48); | ||
58 | - if (!sat || val == extval) { | ||
59 | + uint64_t extval = extract64(src << shift, 0, 48); | ||
60 | + if (!sat || src == (extval >> shift)) { | ||
61 | return extval; | ||
62 | } | ||
63 | } else if (!sat || src == 0) { | ||
64 | -- | ||
65 | 2.20.1 | ||
66 | |||
67 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We got an edge case wrong in the 48-bit SQRSHRL implementation: if | ||
2 | the shift is to the right, although it always makes the result | ||
3 | smaller than the input value it might not be within the 48-bit range | ||
4 | the result is supposed to be if the input had some bits in [63..48] | ||
5 | set and the shift didn't bring all of those within the [47..0] range. | ||
6 | 1 | ||
7 | Handle this similarly to the way we already do for this case in | ||
8 | do_uqrshl48_d(): extend the calculated result from 48 bits, | ||
9 | and return that if not saturating or if it doesn't change the | ||
10 | result; otherwise fall through to return a saturated value. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | --- | ||
15 | target/arm/mve_helper.c | 11 +++++++++-- | ||
16 | 1 file changed, 9 insertions(+), 2 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/mve_helper.c | ||
21 | +++ b/target/arm/mve_helper.c | ||
22 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqrshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
23 | static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
24 | bool round, uint32_t *sat) | ||
25 | { | ||
26 | + int64_t val, extval; | ||
27 | + | ||
28 | if (shift <= -48) { | ||
29 | /* Rounding the sign bit always produces 0. */ | ||
30 | if (round) { | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
32 | } else if (shift < 0) { | ||
33 | if (round) { | ||
34 | src >>= -shift - 1; | ||
35 | - return (src >> 1) + (src & 1); | ||
36 | + val = (src >> 1) + (src & 1); | ||
37 | + } else { | ||
38 | + val = src >> -shift; | ||
39 | + } | ||
40 | + extval = sextract64(val, 0, 48); | ||
41 | + if (!sat || val == extval) { | ||
42 | + return extval; | ||
43 | } | ||
44 | - return src >> -shift; | ||
45 | } else if (shift < 48) { | ||
46 | int64_t extval = sextract64(src << shift, 0, 48); | ||
47 | if (!sat || src == (extval >> shift)) { | ||
48 | -- | ||
49 | 2.20.1 | ||
50 | |||
51 | diff view generated by jsdifflib |
1 | Implement the MVE gather-loads and scatter-stores which | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | form the address by adding a base value from a scalar | ||
3 | register to an offset in each element of a vector. | ||
4 | 2 | ||
3 | This feature allows the operating system to set TCR_ELx.HWU* | ||
4 | to allow the implementation to use the PBHA bits from the | ||
5 | block and page descriptors for for IMPLEMENTATION DEFINED | ||
6 | purposes. Since QEMU has no need to use these bits, we may | ||
7 | simply ignore them. | ||
8 | |||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20230811214031.171020-11-richard.henderson@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | 13 | --- |
8 | target/arm/helper-mve.h | 32 +++++++++ | 14 | docs/system/arm/emulation.rst | 1 + |
9 | target/arm/mve.decode | 12 ++++ | 15 | target/arm/tcg/cpu32.c | 2 +- |
10 | target/arm/mve_helper.c | 129 +++++++++++++++++++++++++++++++++++++ | 16 | target/arm/tcg/cpu64.c | 2 +- |
11 | target/arm/translate-mve.c | 97 ++++++++++++++++++++++++++++ | 17 | 3 files changed, 3 insertions(+), 2 deletions(-) |
12 | 4 files changed, 270 insertions(+) | ||
13 | 18 | ||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper-mve.h | 21 | --- a/docs/system/arm/emulation.rst |
17 | +++ b/target/arm/helper-mve.h | 22 | +++ b/docs/system/arm/emulation.rst |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) | 23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
19 | DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) | 24 | - FEAT_HAFDBS (Hardware management of the access flag and dirty bit state) |
20 | DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) | 25 | - FEAT_HCX (Support for the HCRX_EL2 register) |
21 | 26 | - FEAT_HPDS (Hierarchical permission disables) | |
22 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 27 | +- FEAT_HPDS2 (Translation table page-based hardware attributes) |
23 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 28 | - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) |
24 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 29 | - FEAT_IDST (ID space trap handling) |
25 | + | 30 | - FEAT_IESB (Implicit error synchronization event) |
26 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 31 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c |
27 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | + | ||
34 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | + | ||
42 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
43 | + | ||
44 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
45 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
46 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
47 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
48 | + | ||
49 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
50 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
51 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
53 | + | ||
54 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
55 | |||
56 | DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
57 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
58 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
59 | --- a/target/arm/mve.decode | 33 | --- a/target/arm/tcg/cpu32.c |
60 | +++ b/target/arm/mve.decode | 34 | +++ b/target/arm/tcg/cpu32.c |
61 | @@ -XXX,XX +XXX,XX @@ | 35 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) |
62 | &shl_scalar qda rm size | 36 | cpu->isar.id_mmfr3 = t; |
63 | &vmaxv qm rda size | 37 | |
64 | &vabav qn qm rda size | 38 | t = cpu->isar.id_mmfr4; |
65 | +&vldst_sg qd qm rn size msize os | 39 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* FEAT_AA32HPD */ |
66 | + | 40 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 2); /* FEAT_HPDS2 */ |
67 | +# scatter-gather memory size is in bits 6:4 | 41 | t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ |
68 | +%sg_msize 6:1 4:1 | 42 | t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */ |
69 | 43 | t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX */ | |
70 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | 44 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
71 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
72 | @vldst_wn ... u:1 ... . . . . l:1 . rn:3 qd:3 . ... .. imm:7 &vldr_vstr | ||
73 | |||
74 | +@vldst_sg .... .... .... rn:4 .... ... size:2 ... ... os:1 &vldst_sg \ | ||
75 | + qd=%qd qm=%qm msize=%sg_msize | ||
76 | + | ||
77 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | ||
78 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | ||
79 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | ||
80 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ | ||
81 | VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ | ||
82 | size=2 p=1 | ||
83 | |||
84 | +# gather loads/scatter stores | ||
85 | +VLDR_S_sg 111 0 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
86 | +VLDR_U_sg 111 1 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
87 | +VSTR_sg 111 0 1100 1 . 00 .... ... 0 111 . .... .... @vldst_sg | ||
88 | + | ||
89 | # Moves between 2 32-bit vector lanes and 2 general purpose registers | ||
90 | VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
91 | VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
92 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
94 | --- a/target/arm/mve_helper.c | 46 | --- a/target/arm/tcg/cpu64.c |
95 | +++ b/target/arm/mve_helper.c | 47 | +++ b/target/arm/tcg/cpu64.c |
96 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | 48 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
97 | #undef DO_VLDR | 49 | t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */ |
98 | #undef DO_VSTR | 50 | t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ |
99 | 51 | t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ | |
100 | +/* | 52 | - t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */ |
101 | + * Gather loads/scatter stores. Here each element of Qm specifies | 53 | + t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 2); /* FEAT_HPDS2 */ |
102 | + * an offset to use from the base register Rm. In the _os_ versions | 54 | t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */ |
103 | + * that offset is scaled by the element size. | 55 | t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 3); /* FEAT_PAN3 */ |
104 | + * For loads, predicated lanes are zeroed instead of retaining | 56 | t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */ |
105 | + * their previous values. | ||
106 | + */ | ||
107 | +#define DO_VLDR_SG(OP, LDTYPE, ESIZE, TYPE, OFFTYPE, ADDRFN) \ | ||
108 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
109 | + uint32_t base) \ | ||
110 | + { \ | ||
111 | + TYPE *d = vd; \ | ||
112 | + OFFTYPE *m = vm; \ | ||
113 | + uint16_t mask = mve_element_mask(env); \ | ||
114 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
115 | + unsigned e; \ | ||
116 | + uint32_t addr; \ | ||
117 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE, eci_mask >>= ESIZE) { \ | ||
118 | + if (!(eci_mask & 1)) { \ | ||
119 | + continue; \ | ||
120 | + } \ | ||
121 | + addr = ADDRFN(base, m[H##ESIZE(e)]); \ | ||
122 | + d[H##ESIZE(e)] = (mask & 1) ? \ | ||
123 | + cpu_##LDTYPE##_data_ra(env, addr, GETPC()) : 0; \ | ||
124 | + } \ | ||
125 | + mve_advance_vpt(env); \ | ||
126 | + } | ||
127 | + | ||
128 | +/* We know here TYPE is unsigned so always the same as the offset type */ | ||
129 | +#define DO_VSTR_SG(OP, STTYPE, ESIZE, TYPE, ADDRFN) \ | ||
130 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
131 | + uint32_t base) \ | ||
132 | + { \ | ||
133 | + TYPE *d = vd; \ | ||
134 | + TYPE *m = vm; \ | ||
135 | + uint16_t mask = mve_element_mask(env); \ | ||
136 | + unsigned e; \ | ||
137 | + uint32_t addr; \ | ||
138 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
139 | + addr = ADDRFN(base, m[H##ESIZE(e)]); \ | ||
140 | + if (mask & 1) { \ | ||
141 | + cpu_##STTYPE##_data_ra(env, addr, d[H##ESIZE(e)], GETPC()); \ | ||
142 | + } \ | ||
143 | + } \ | ||
144 | + mve_advance_vpt(env); \ | ||
145 | + } | ||
146 | + | ||
147 | +/* | ||
148 | + * 64-bit accesses are slightly different: they are done as two 32-bit | ||
149 | + * accesses, controlled by the predicate mask for the relevant beat, | ||
150 | + * and with a single 32-bit offset in the first of the two Qm elements. | ||
151 | + * Note that for QEMU our IMPDEF AIRCR.ENDIANNESS is always 0 (little). | ||
152 | + */ | ||
153 | +#define DO_VLDR64_SG(OP, ADDRFN) \ | ||
154 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
155 | + uint32_t base) \ | ||
156 | + { \ | ||
157 | + uint32_t *d = vd; \ | ||
158 | + uint32_t *m = vm; \ | ||
159 | + uint16_t mask = mve_element_mask(env); \ | ||
160 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
161 | + unsigned e; \ | ||
162 | + uint32_t addr; \ | ||
163 | + for (e = 0; e < 16 / 4; e++, mask >>= 4, eci_mask >>= 4) { \ | ||
164 | + if (!(eci_mask & 1)) { \ | ||
165 | + continue; \ | ||
166 | + } \ | ||
167 | + addr = ADDRFN(base, m[H4(e & ~1)]); \ | ||
168 | + addr += 4 * (e & 1); \ | ||
169 | + d[H4(e)] = (mask & 1) ? cpu_ldl_data_ra(env, addr, GETPC()) : 0; \ | ||
170 | + } \ | ||
171 | + mve_advance_vpt(env); \ | ||
172 | + } | ||
173 | + | ||
174 | +#define DO_VSTR64_SG(OP, ADDRFN) \ | ||
175 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
176 | + uint32_t base) \ | ||
177 | + { \ | ||
178 | + uint32_t *d = vd; \ | ||
179 | + uint32_t *m = vm; \ | ||
180 | + uint16_t mask = mve_element_mask(env); \ | ||
181 | + unsigned e; \ | ||
182 | + uint32_t addr; \ | ||
183 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
184 | + addr = ADDRFN(base, m[H4(e & ~1)]); \ | ||
185 | + addr += 4 * (e & 1); \ | ||
186 | + if (mask & 1) { \ | ||
187 | + cpu_stl_data_ra(env, addr, d[H4(e)], GETPC()); \ | ||
188 | + } \ | ||
189 | + } \ | ||
190 | + mve_advance_vpt(env); \ | ||
191 | + } | ||
192 | + | ||
193 | +#define ADDR_ADD(BASE, OFFSET) ((BASE) + (OFFSET)) | ||
194 | +#define ADDR_ADD_OSH(BASE, OFFSET) ((BASE) + ((OFFSET) << 1)) | ||
195 | +#define ADDR_ADD_OSW(BASE, OFFSET) ((BASE) + ((OFFSET) << 2)) | ||
196 | +#define ADDR_ADD_OSD(BASE, OFFSET) ((BASE) + ((OFFSET) << 3)) | ||
197 | + | ||
198 | +DO_VLDR_SG(vldrb_sg_sh, ldsb, 2, int16_t, uint16_t, ADDR_ADD) | ||
199 | +DO_VLDR_SG(vldrb_sg_sw, ldsb, 4, int32_t, uint32_t, ADDR_ADD) | ||
200 | +DO_VLDR_SG(vldrh_sg_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD) | ||
201 | + | ||
202 | +DO_VLDR_SG(vldrb_sg_ub, ldub, 1, uint8_t, uint8_t, ADDR_ADD) | ||
203 | +DO_VLDR_SG(vldrb_sg_uh, ldub, 2, uint16_t, uint16_t, ADDR_ADD) | ||
204 | +DO_VLDR_SG(vldrb_sg_uw, ldub, 4, uint32_t, uint32_t, ADDR_ADD) | ||
205 | +DO_VLDR_SG(vldrh_sg_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD) | ||
206 | +DO_VLDR_SG(vldrh_sg_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD) | ||
207 | +DO_VLDR_SG(vldrw_sg_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD) | ||
208 | +DO_VLDR64_SG(vldrd_sg_ud, ADDR_ADD) | ||
209 | + | ||
210 | +DO_VLDR_SG(vldrh_sg_os_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD_OSH) | ||
211 | +DO_VLDR_SG(vldrh_sg_os_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD_OSH) | ||
212 | +DO_VLDR_SG(vldrh_sg_os_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD_OSH) | ||
213 | +DO_VLDR_SG(vldrw_sg_os_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD_OSW) | ||
214 | +DO_VLDR64_SG(vldrd_sg_os_ud, ADDR_ADD_OSD) | ||
215 | + | ||
216 | +DO_VSTR_SG(vstrb_sg_ub, stb, 1, uint8_t, ADDR_ADD) | ||
217 | +DO_VSTR_SG(vstrb_sg_uh, stb, 2, uint16_t, ADDR_ADD) | ||
218 | +DO_VSTR_SG(vstrb_sg_uw, stb, 4, uint32_t, ADDR_ADD) | ||
219 | +DO_VSTR_SG(vstrh_sg_uh, stw, 2, uint16_t, ADDR_ADD) | ||
220 | +DO_VSTR_SG(vstrh_sg_uw, stw, 4, uint32_t, ADDR_ADD) | ||
221 | +DO_VSTR_SG(vstrw_sg_uw, stl, 4, uint32_t, ADDR_ADD) | ||
222 | +DO_VSTR64_SG(vstrd_sg_ud, ADDR_ADD) | ||
223 | + | ||
224 | +DO_VSTR_SG(vstrh_sg_os_uh, stw, 2, uint16_t, ADDR_ADD_OSH) | ||
225 | +DO_VSTR_SG(vstrh_sg_os_uw, stw, 4, uint32_t, ADDR_ADD_OSH) | ||
226 | +DO_VSTR_SG(vstrw_sg_os_uw, stl, 4, uint32_t, ADDR_ADD_OSW) | ||
227 | +DO_VSTR64_SG(vstrd_sg_os_ud, ADDR_ADD_OSD) | ||
228 | + | ||
229 | /* | ||
230 | * The mergemask(D, R, M) macro performs the operation "*D = R" but | ||
231 | * storing only the bytes which correspond to 1 bits in M, | ||
232 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
233 | index XXXXXXX..XXXXXXX 100644 | ||
234 | --- a/target/arm/translate-mve.c | ||
235 | +++ b/target/arm/translate-mve.c | ||
236 | @@ -XXX,XX +XXX,XX @@ static inline int vidup_imm(DisasContext *s, int x) | ||
237 | #include "decode-mve.c.inc" | ||
238 | |||
239 | typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
240 | +typedef void MVEGenLdStSGFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
241 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
242 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
243 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
244 | @@ -XXX,XX +XXX,XX @@ DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h, MO_8) | ||
245 | DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w, MO_8) | ||
246 | DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w, MO_16) | ||
247 | |||
248 | +static bool do_ldst_sg(DisasContext *s, arg_vldst_sg *a, MVEGenLdStSGFn fn) | ||
249 | +{ | ||
250 | + TCGv_i32 addr; | ||
251 | + TCGv_ptr qd, qm; | ||
252 | + | ||
253 | + if (!dc_isar_feature(aa32_mve, s) || | ||
254 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | ||
255 | + !fn || a->rn == 15) { | ||
256 | + /* Rn case is UNPREDICTABLE */ | ||
257 | + return false; | ||
258 | + } | ||
259 | + | ||
260 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
261 | + return true; | ||
262 | + } | ||
263 | + | ||
264 | + addr = load_reg(s, a->rn); | ||
265 | + | ||
266 | + qd = mve_qreg_ptr(a->qd); | ||
267 | + qm = mve_qreg_ptr(a->qm); | ||
268 | + fn(cpu_env, qd, qm, addr); | ||
269 | + tcg_temp_free_ptr(qd); | ||
270 | + tcg_temp_free_ptr(qm); | ||
271 | + tcg_temp_free_i32(addr); | ||
272 | + mve_update_eci(s); | ||
273 | + return true; | ||
274 | +} | ||
275 | + | ||
276 | +/* | ||
277 | + * The naming scheme here is "vldrb_sg_sh == in-memory byte loads | ||
278 | + * signextended to halfword elements in register". _os_ indicates that | ||
279 | + * the offsets in Qm should be scaled by the element size. | ||
280 | + */ | ||
281 | +/* This macro is just to make the arrays more compact in these functions */ | ||
282 | +#define F(N) gen_helper_mve_##N | ||
283 | + | ||
284 | +/* VLDRB/VSTRB (ie msize 1) with OS=1 is UNPREDICTABLE; we UNDEF */ | ||
285 | +static bool trans_VLDR_S_sg(DisasContext *s, arg_vldst_sg *a) | ||
286 | +{ | ||
287 | + static MVEGenLdStSGFn * const fns[2][4][4] = { { | ||
288 | + { NULL, F(vldrb_sg_sh), F(vldrb_sg_sw), NULL }, | ||
289 | + { NULL, NULL, F(vldrh_sg_sw), NULL }, | ||
290 | + { NULL, NULL, NULL, NULL }, | ||
291 | + { NULL, NULL, NULL, NULL } | ||
292 | + }, { | ||
293 | + { NULL, NULL, NULL, NULL }, | ||
294 | + { NULL, NULL, F(vldrh_sg_os_sw), NULL }, | ||
295 | + { NULL, NULL, NULL, NULL }, | ||
296 | + { NULL, NULL, NULL, NULL } | ||
297 | + } | ||
298 | + }; | ||
299 | + if (a->qd == a->qm) { | ||
300 | + return false; /* UNPREDICTABLE */ | ||
301 | + } | ||
302 | + return do_ldst_sg(s, a, fns[a->os][a->msize][a->size]); | ||
303 | +} | ||
304 | + | ||
305 | +static bool trans_VLDR_U_sg(DisasContext *s, arg_vldst_sg *a) | ||
306 | +{ | ||
307 | + static MVEGenLdStSGFn * const fns[2][4][4] = { { | ||
308 | + { F(vldrb_sg_ub), F(vldrb_sg_uh), F(vldrb_sg_uw), NULL }, | ||
309 | + { NULL, F(vldrh_sg_uh), F(vldrh_sg_uw), NULL }, | ||
310 | + { NULL, NULL, F(vldrw_sg_uw), NULL }, | ||
311 | + { NULL, NULL, NULL, F(vldrd_sg_ud) } | ||
312 | + }, { | ||
313 | + { NULL, NULL, NULL, NULL }, | ||
314 | + { NULL, F(vldrh_sg_os_uh), F(vldrh_sg_os_uw), NULL }, | ||
315 | + { NULL, NULL, F(vldrw_sg_os_uw), NULL }, | ||
316 | + { NULL, NULL, NULL, F(vldrd_sg_os_ud) } | ||
317 | + } | ||
318 | + }; | ||
319 | + if (a->qd == a->qm) { | ||
320 | + return false; /* UNPREDICTABLE */ | ||
321 | + } | ||
322 | + return do_ldst_sg(s, a, fns[a->os][a->msize][a->size]); | ||
323 | +} | ||
324 | + | ||
325 | +static bool trans_VSTR_sg(DisasContext *s, arg_vldst_sg *a) | ||
326 | +{ | ||
327 | + static MVEGenLdStSGFn * const fns[2][4][4] = { { | ||
328 | + { F(vstrb_sg_ub), F(vstrb_sg_uh), F(vstrb_sg_uw), NULL }, | ||
329 | + { NULL, F(vstrh_sg_uh), F(vstrh_sg_uw), NULL }, | ||
330 | + { NULL, NULL, F(vstrw_sg_uw), NULL }, | ||
331 | + { NULL, NULL, NULL, F(vstrd_sg_ud) } | ||
332 | + }, { | ||
333 | + { NULL, NULL, NULL, NULL }, | ||
334 | + { NULL, F(vstrh_sg_os_uh), F(vstrh_sg_os_uw), NULL }, | ||
335 | + { NULL, NULL, F(vstrw_sg_os_uw), NULL }, | ||
336 | + { NULL, NULL, NULL, F(vstrd_sg_os_ud) } | ||
337 | + } | ||
338 | + }; | ||
339 | + return do_ldst_sg(s, a, fns[a->os][a->msize][a->size]); | ||
340 | +} | ||
341 | + | ||
342 | +#undef F | ||
343 | + | ||
344 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
345 | { | ||
346 | TCGv_ptr qd; | ||
347 | -- | 57 | -- |
348 | 2.20.1 | 58 | 2.34.1 |
349 | |||
350 | diff view generated by jsdifflib |
1 | From: Hamza Mahfooz <someguy@effective-light.com> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | As per commit 5626f8c6d468 ("rcu: Add automatically released rcu_read_lock | 3 | This is a mandatory feature for Armv8.1 architectures but we don't |
4 | variants"), RCU_READ_LOCK_GUARD() should be used instead of | 4 | state the feature clearly in our emulation list. Also include |
5 | rcu_read_{un}lock(). | 5 | FEAT_CRC32 comment in aarch64_max_tcg_initfn for ease of grepping. |
6 | 6 | ||
7 | Signed-off-by: Hamza Mahfooz <someguy@effective-light.com> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | 8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
9 | Message-id: 20210727235201.11491-1-someguy@effective-light.com | 9 | Message-id: 20230824075406.1515566-1-alex.bennee@linaro.org |
10 | Cc: qemu-stable@nongnu.org | ||
11 | Message-Id: <20230222110104.3996971-1-alex.bennee@linaro.org> | ||
12 | [PMM: pluralize 'instructions' in docs] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 14 | --- |
12 | target/arm/kvm.c | 17 ++++++++--------- | 15 | docs/system/arm/emulation.rst | 1 + |
13 | 1 file changed, 8 insertions(+), 9 deletions(-) | 16 | target/arm/tcg/cpu64.c | 2 +- |
17 | 2 files changed, 2 insertions(+), 1 deletion(-) | ||
14 | 18 | ||
15 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | 19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/kvm.c | 21 | --- a/docs/system/arm/emulation.rst |
18 | +++ b/target/arm/kvm.c | 22 | +++ b/docs/system/arm/emulation.rst |
19 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, | 23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
20 | hwaddr xlat, len, doorbell_gpa; | 24 | - FEAT_BBM at level 2 (Translation table break-before-make levels) |
21 | MemoryRegionSection mrs; | 25 | - FEAT_BF16 (AArch64 BFloat16 instructions) |
22 | MemoryRegion *mr; | 26 | - FEAT_BTI (Branch Target Identification) |
23 | - int ret = 1; | 27 | +- FEAT_CRC32 (CRC32 instructions) |
24 | 28 | - FEAT_CSV2 (Cache speculation variant 2) | |
25 | if (as == &address_space_memory) { | 29 | - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) |
26 | return 0; | 30 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) |
27 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, | 31 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
28 | 32 | index XXXXXXX..XXXXXXX 100644 | |
29 | /* MSI doorbell address is translated by an IOMMU */ | 33 | --- a/target/arm/tcg/cpu64.c |
30 | 34 | +++ b/target/arm/tcg/cpu64.c | |
31 | - rcu_read_lock(); | 35 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
32 | + RCU_READ_LOCK_GUARD(); | 36 | t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */ |
33 | + | 37 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */ |
34 | mr = address_space_translate(as, address, &xlat, &len, true, | 38 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */ |
35 | MEMTXATTRS_UNSPECIFIED); | 39 | - t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); |
36 | + | 40 | + t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); /* FEAT_CRC32 */ |
37 | if (!mr) { | 41 | t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); /* FEAT_LSE */ |
38 | - goto unlock; | 42 | t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); /* FEAT_RDM */ |
39 | + return 1; | 43 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); /* FEAT_SHA3 */ |
40 | } | ||
41 | + | ||
42 | mrs = memory_region_find(mr, xlat, 1); | ||
43 | + | ||
44 | if (!mrs.mr) { | ||
45 | - goto unlock; | ||
46 | + return 1; | ||
47 | } | ||
48 | |||
49 | doorbell_gpa = mrs.offset_within_address_space; | ||
50 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, | ||
51 | |||
52 | trace_kvm_arm_fixup_msi_route(address, doorbell_gpa); | ||
53 | |||
54 | - ret = 0; | ||
55 | - | ||
56 | -unlock: | ||
57 | - rcu_read_unlock(); | ||
58 | - return ret; | ||
59 | + return 0; | ||
60 | } | ||
61 | |||
62 | int kvm_arch_add_msi_route_post(struct kvm_irq_routing_entry *route, | ||
63 | -- | 44 | -- |
64 | 2.20.1 | 45 | 2.34.1 |
65 | 46 | ||
66 | 47 | diff view generated by jsdifflib |
1 | From: Jan Luebbe <jlu@pengutronix.de> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Break events are currently only handled by chardev/char-serial.c, so we | 3 | i.MX7 IOMUX GPR device is not equivalent to i.MX6UL IOMUXC GPR device. |
4 | just ignore errors, which results in no behaviour change for other | 4 | In particular, register 22 is not present on i.MX6UL and this is actualy |
5 | chardevs. | 5 | The only register that is really emulated in the i.MX7 IOMUX GPR device. |
6 | 6 | ||
7 | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> | 7 | Note: The i.MX6UL code is actually also implementing the IOMUX GPR device |
8 | Message-id: 20210806144700.3751979-1-jlu@pengutronix.de | 8 | as an unimplemented device at the same bus adress and the 2 instantiations |
9 | were actualy colliding. So we go back to the unimplemented device for now. | ||
10 | |||
11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
12 | Message-id: 48681bf51ee97646479bb261bee19abebbc8074e.1692964892.git.jcd@tribudubois.net | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 15 | --- |
12 | hw/char/pl011.c | 6 ++++++ | 16 | include/hw/arm/fsl-imx6ul.h | 2 -- |
13 | 1 file changed, 6 insertions(+) | 17 | hw/arm/fsl-imx6ul.c | 11 ----------- |
18 | 2 files changed, 13 deletions(-) | ||
14 | 19 | ||
15 | diff --git a/hw/char/pl011.c b/hw/char/pl011.c | 20 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h |
16 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/char/pl011.c | 22 | --- a/include/hw/arm/fsl-imx6ul.h |
18 | +++ b/hw/char/pl011.c | 23 | +++ b/include/hw/arm/fsl-imx6ul.h |
19 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ |
20 | #include "hw/qdev-properties-system.h" | 25 | #include "hw/misc/imx6ul_ccm.h" |
21 | #include "migration/vmstate.h" | 26 | #include "hw/misc/imx6_src.h" |
22 | #include "chardev/char-fe.h" | 27 | #include "hw/misc/imx7_snvs.h" |
23 | +#include "chardev/char-serial.h" | 28 | -#include "hw/misc/imx7_gpr.h" |
24 | #include "qemu/log.h" | 29 | #include "hw/intc/imx_gpcv2.h" |
25 | #include "qemu/module.h" | 30 | #include "hw/watchdog/wdt_imx2.h" |
26 | #include "trace.h" | 31 | #include "hw/gpio/imx_gpio.h" |
27 | @@ -XXX,XX +XXX,XX @@ static void pl011_write(void *opaque, hwaddr offset, | 32 | @@ -XXX,XX +XXX,XX @@ struct FslIMX6ULState { |
28 | s->read_count = 0; | 33 | IMX6SRCState src; |
29 | s->read_pos = 0; | 34 | IMX7SNVSState snvs; |
30 | } | 35 | IMXGPCv2State gpcv2; |
31 | + if ((s->lcr ^ value) & 0x1) { | 36 | - IMX7GPRState gpr; |
32 | + int break_enable = value & 0x1; | 37 | IMXSPIState spi[FSL_IMX6UL_NUM_ECSPIS]; |
33 | + qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_BREAK, | 38 | IMXI2CState i2c[FSL_IMX6UL_NUM_I2CS]; |
34 | + &break_enable); | 39 | IMXSerialState uart[FSL_IMX6UL_NUM_UARTS]; |
35 | + } | 40 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c |
36 | s->lcr = value; | 41 | index XXXXXXX..XXXXXXX 100644 |
37 | pl011_set_read_trigger(s); | 42 | --- a/hw/arm/fsl-imx6ul.c |
38 | break; | 43 | +++ b/hw/arm/fsl-imx6ul.c |
44 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
45 | */ | ||
46 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); | ||
47 | |||
48 | - /* | ||
49 | - * GPR | ||
50 | - */ | ||
51 | - object_initialize_child(obj, "gpr", &s->gpr, TYPE_IMX7_GPR); | ||
52 | - | ||
53 | /* | ||
54 | * GPIOs 1 to 5 | ||
55 | */ | ||
56 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
57 | FSL_IMX6UL_WDOGn_IRQ[i])); | ||
58 | } | ||
59 | |||
60 | - /* | ||
61 | - * GPR | ||
62 | - */ | ||
63 | - sysbus_realize(SYS_BUS_DEVICE(&s->gpr), &error_abort); | ||
64 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX6UL_IOMUXC_GPR_ADDR); | ||
65 | - | ||
66 | /* | ||
67 | * SDMA | ||
68 | */ | ||
39 | -- | 69 | -- |
40 | 2.20.1 | 70 | 2.34.1 |
41 | |||
42 | diff view generated by jsdifflib |
1 | From: Eduardo Habkost <ehabkost@redhat.com> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | The SBSA_GWDT enum value conflicts with the SBSA_GWDT() QOM type | 3 | * Add Addr and size definition for most i.MX6UL devices in i.MX6UL header file. |
4 | checking helper, preventing us from using a OBJECT_DEFINE* or | 4 | * Use those newly defined named constants whenever possible. |
5 | DEFINE_INSTANCE_CHECKER macro for the SBSA_GWDT() wrapper. | 5 | * Standardize the way we init a familly of unimplemented devices |
6 | - SAI | ||
7 | - PWM | ||
8 | - CAN | ||
9 | * Add/rework few comments | ||
6 | 10 | ||
7 | If I understand the SBSA 6.0 specification correctly, the signal | 11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
8 | being connected to IRQ 16 is the WS0 output signal from the | 12 | Message-id: d579043fbd4e4b490370783fda43fc02c8e9be75.1692964892.git.jcd@tribudubois.net |
9 | Generic Watchdog. Rename the enum value to SBSA_GWDT_WS0 to be | ||
10 | more explicit and avoid the name conflict. | ||
11 | |||
12 | Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> | ||
13 | Message-id: 20210806023119.431680-1-ehabkost@redhat.com | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 15 | --- |
17 | hw/arm/sbsa-ref.c | 6 +++--- | 16 | include/hw/arm/fsl-imx6ul.h | 156 +++++++++++++++++++++++++++++++----- |
18 | 1 file changed, 3 insertions(+), 3 deletions(-) | 17 | hw/arm/fsl-imx6ul.c | 147 ++++++++++++++++++++++----------- |
18 | 2 files changed, 232 insertions(+), 71 deletions(-) | ||
19 | 19 | ||
20 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | 20 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h |
21 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/sbsa-ref.c | 22 | --- a/include/hw/arm/fsl-imx6ul.h |
23 | +++ b/hw/arm/sbsa-ref.c | 23 | +++ b/include/hw/arm/fsl-imx6ul.h |
24 | @@ -XXX,XX +XXX,XX @@ enum { | 24 | @@ -XXX,XX +XXX,XX @@ |
25 | SBSA_GIC_DIST, | 25 | #include "exec/memory.h" |
26 | SBSA_GIC_REDIST, | 26 | #include "cpu.h" |
27 | SBSA_SECURE_EC, | 27 | #include "qom/object.h" |
28 | - SBSA_GWDT, | 28 | +#include "qemu/units.h" |
29 | + SBSA_GWDT_WS0, | 29 | |
30 | SBSA_GWDT_REFRESH, | 30 | #define TYPE_FSL_IMX6UL "fsl-imx6ul" |
31 | SBSA_GWDT_CONTROL, | 31 | OBJECT_DECLARE_SIMPLE_TYPE(FslIMX6ULState, FSL_IMX6UL) |
32 | SBSA_SMMU, | 32 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration { |
33 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { | 33 | FSL_IMX6UL_NUM_ADCS = 2, |
34 | [SBSA_AHCI] = 10, | 34 | FSL_IMX6UL_NUM_USB_PHYS = 2, |
35 | [SBSA_EHCI] = 11, | 35 | FSL_IMX6UL_NUM_USBS = 2, |
36 | [SBSA_SMMU] = 12, /* ... to 15 */ | 36 | + FSL_IMX6UL_NUM_SAIS = 3, |
37 | - [SBSA_GWDT] = 16, | 37 | + FSL_IMX6UL_NUM_CANS = 2, |
38 | + [SBSA_GWDT_WS0] = 16, | 38 | + FSL_IMX6UL_NUM_PWMS = 4, |
39 | }; | 39 | }; |
40 | 40 | ||
41 | static const char * const valid_cpus[] = { | 41 | struct FslIMX6ULState { |
42 | @@ -XXX,XX +XXX,XX @@ static void create_wdt(const SBSAMachineState *sms) | 42 | @@ -XXX,XX +XXX,XX @@ struct FslIMX6ULState { |
43 | hwaddr cbase = sbsa_ref_memmap[SBSA_GWDT_CONTROL].base; | 43 | |
44 | DeviceState *dev = qdev_new(TYPE_WDT_SBSA); | 44 | enum FslIMX6ULMemoryMap { |
45 | SysBusDevice *s = SYS_BUS_DEVICE(dev); | 45 | FSL_IMX6UL_MMDC_ADDR = 0x80000000, |
46 | - int irq = sbsa_ref_irqmap[SBSA_GWDT]; | 46 | - FSL_IMX6UL_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL, |
47 | + int irq = sbsa_ref_irqmap[SBSA_GWDT_WS0]; | 47 | + FSL_IMX6UL_MMDC_SIZE = (2 * GiB), |
48 | 48 | ||
49 | sysbus_realize_and_unref(s, &error_fatal); | 49 | FSL_IMX6UL_QSPI1_MEM_ADDR = 0x60000000, |
50 | sysbus_mmio_map(s, 0, rbase); | 50 | - FSL_IMX6UL_EIM_ALIAS_ADDR = 0x58000000, |
51 | - FSL_IMX6UL_EIM_CS_ADDR = 0x50000000, | ||
52 | - FSL_IMX6UL_AES_ENCRYPT_ADDR = 0x10000000, | ||
53 | - FSL_IMX6UL_QSPI1_RX_ADDR = 0x0C000000, | ||
54 | + FSL_IMX6UL_QSPI1_MEM_SIZE = (256 * MiB), | ||
55 | |||
56 | - /* AIPS-2 */ | ||
57 | + FSL_IMX6UL_EIM_ALIAS_ADDR = 0x58000000, | ||
58 | + FSL_IMX6UL_EIM_ALIAS_SIZE = (128 * MiB), | ||
59 | + | ||
60 | + FSL_IMX6UL_EIM_CS_ADDR = 0x50000000, | ||
61 | + FSL_IMX6UL_EIM_CS_SIZE = (128 * MiB), | ||
62 | + | ||
63 | + FSL_IMX6UL_AES_ENCRYPT_ADDR = 0x10000000, | ||
64 | + FSL_IMX6UL_AES_ENCRYPT_SIZE = (1 * MiB), | ||
65 | + | ||
66 | + FSL_IMX6UL_QSPI1_RX_ADDR = 0x0C000000, | ||
67 | + FSL_IMX6UL_QSPI1_RX_SIZE = (32 * MiB), | ||
68 | + | ||
69 | + /* AIPS-2 Begin */ | ||
70 | FSL_IMX6UL_UART6_ADDR = 0x021FC000, | ||
71 | + | ||
72 | FSL_IMX6UL_I2C4_ADDR = 0x021F8000, | ||
73 | + | ||
74 | FSL_IMX6UL_UART5_ADDR = 0x021F4000, | ||
75 | FSL_IMX6UL_UART4_ADDR = 0x021F0000, | ||
76 | FSL_IMX6UL_UART3_ADDR = 0x021EC000, | ||
77 | FSL_IMX6UL_UART2_ADDR = 0x021E8000, | ||
78 | + | ||
79 | FSL_IMX6UL_WDOG3_ADDR = 0x021E4000, | ||
80 | + | ||
81 | FSL_IMX6UL_QSPI_ADDR = 0x021E0000, | ||
82 | + FSL_IMX6UL_QSPI_SIZE = 0x500, | ||
83 | + | ||
84 | FSL_IMX6UL_SYS_CNT_CTRL_ADDR = 0x021DC000, | ||
85 | + FSL_IMX6UL_SYS_CNT_CTRL_SIZE = (16 * KiB), | ||
86 | + | ||
87 | FSL_IMX6UL_SYS_CNT_CMP_ADDR = 0x021D8000, | ||
88 | + FSL_IMX6UL_SYS_CNT_CMP_SIZE = (16 * KiB), | ||
89 | + | ||
90 | FSL_IMX6UL_SYS_CNT_RD_ADDR = 0x021D4000, | ||
91 | + FSL_IMX6UL_SYS_CNT_RD_SIZE = (16 * KiB), | ||
92 | + | ||
93 | FSL_IMX6UL_TZASC_ADDR = 0x021D0000, | ||
94 | + FSL_IMX6UL_TZASC_SIZE = (16 * KiB), | ||
95 | + | ||
96 | FSL_IMX6UL_PXP_ADDR = 0x021CC000, | ||
97 | + FSL_IMX6UL_PXP_SIZE = (16 * KiB), | ||
98 | + | ||
99 | FSL_IMX6UL_LCDIF_ADDR = 0x021C8000, | ||
100 | + FSL_IMX6UL_LCDIF_SIZE = 0x100, | ||
101 | + | ||
102 | FSL_IMX6UL_CSI_ADDR = 0x021C4000, | ||
103 | + FSL_IMX6UL_CSI_SIZE = 0x100, | ||
104 | + | ||
105 | FSL_IMX6UL_CSU_ADDR = 0x021C0000, | ||
106 | + FSL_IMX6UL_CSU_SIZE = (16 * KiB), | ||
107 | + | ||
108 | FSL_IMX6UL_OCOTP_CTRL_ADDR = 0x021BC000, | ||
109 | + FSL_IMX6UL_OCOTP_CTRL_SIZE = (4 * KiB), | ||
110 | + | ||
111 | FSL_IMX6UL_EIM_ADDR = 0x021B8000, | ||
112 | + FSL_IMX6UL_EIM_SIZE = 0x100, | ||
113 | + | ||
114 | FSL_IMX6UL_SIM2_ADDR = 0x021B4000, | ||
115 | + | ||
116 | FSL_IMX6UL_MMDC_CFG_ADDR = 0x021B0000, | ||
117 | + FSL_IMX6UL_MMDC_CFG_SIZE = (4 * KiB), | ||
118 | + | ||
119 | FSL_IMX6UL_ROMCP_ADDR = 0x021AC000, | ||
120 | + FSL_IMX6UL_ROMCP_SIZE = 0x300, | ||
121 | + | ||
122 | FSL_IMX6UL_I2C3_ADDR = 0x021A8000, | ||
123 | FSL_IMX6UL_I2C2_ADDR = 0x021A4000, | ||
124 | FSL_IMX6UL_I2C1_ADDR = 0x021A0000, | ||
125 | + | ||
126 | FSL_IMX6UL_ADC2_ADDR = 0x0219C000, | ||
127 | FSL_IMX6UL_ADC1_ADDR = 0x02198000, | ||
128 | + FSL_IMX6UL_ADCn_SIZE = 0x100, | ||
129 | + | ||
130 | FSL_IMX6UL_USDHC2_ADDR = 0x02194000, | ||
131 | FSL_IMX6UL_USDHC1_ADDR = 0x02190000, | ||
132 | - FSL_IMX6UL_SIM1_ADDR = 0x0218C000, | ||
133 | - FSL_IMX6UL_ENET1_ADDR = 0x02188000, | ||
134 | - FSL_IMX6UL_USBO2_USBMISC_ADDR = 0x02184800, | ||
135 | - FSL_IMX6UL_USBO2_USB_ADDR = 0x02184000, | ||
136 | - FSL_IMX6UL_USBO2_PL301_ADDR = 0x02180000, | ||
137 | - FSL_IMX6UL_AIPS2_CFG_ADDR = 0x0217C000, | ||
138 | - FSL_IMX6UL_CAAM_ADDR = 0x02140000, | ||
139 | - FSL_IMX6UL_A7MPCORE_DAP_ADDR = 0x02100000, | ||
140 | |||
141 | - /* AIPS-1 */ | ||
142 | + FSL_IMX6UL_SIM1_ADDR = 0x0218C000, | ||
143 | + FSL_IMX6UL_SIMn_SIZE = (16 * KiB), | ||
144 | + | ||
145 | + FSL_IMX6UL_ENET1_ADDR = 0x02188000, | ||
146 | + | ||
147 | + FSL_IMX6UL_USBO2_USBMISC_ADDR = 0x02184800, | ||
148 | + FSL_IMX6UL_USBO2_USB1_ADDR = 0x02184000, | ||
149 | + FSL_IMX6UL_USBO2_USB2_ADDR = 0x02184200, | ||
150 | + | ||
151 | + FSL_IMX6UL_USBO2_PL301_ADDR = 0x02180000, | ||
152 | + FSL_IMX6UL_USBO2_PL301_SIZE = (16 * KiB), | ||
153 | + | ||
154 | + FSL_IMX6UL_AIPS2_CFG_ADDR = 0x0217C000, | ||
155 | + FSL_IMX6UL_AIPS2_CFG_SIZE = 0x100, | ||
156 | + | ||
157 | + FSL_IMX6UL_CAAM_ADDR = 0x02140000, | ||
158 | + FSL_IMX6UL_CAAM_SIZE = (16 * KiB), | ||
159 | + | ||
160 | + FSL_IMX6UL_A7MPCORE_DAP_ADDR = 0x02100000, | ||
161 | + FSL_IMX6UL_A7MPCORE_DAP_SIZE = (4 * KiB), | ||
162 | + /* AIPS-2 End */ | ||
163 | + | ||
164 | + /* AIPS-1 Begin */ | ||
165 | FSL_IMX6UL_PWM8_ADDR = 0x020FC000, | ||
166 | FSL_IMX6UL_PWM7_ADDR = 0x020F8000, | ||
167 | FSL_IMX6UL_PWM6_ADDR = 0x020F4000, | ||
168 | FSL_IMX6UL_PWM5_ADDR = 0x020F0000, | ||
169 | + | ||
170 | FSL_IMX6UL_SDMA_ADDR = 0x020EC000, | ||
171 | + FSL_IMX6UL_SDMA_SIZE = 0x300, | ||
172 | + | ||
173 | FSL_IMX6UL_GPT2_ADDR = 0x020E8000, | ||
174 | + | ||
175 | FSL_IMX6UL_IOMUXC_GPR_ADDR = 0x020E4000, | ||
176 | + FSL_IMX6UL_IOMUXC_GPR_SIZE = 0x40, | ||
177 | + | ||
178 | FSL_IMX6UL_IOMUXC_ADDR = 0x020E0000, | ||
179 | + FSL_IMX6UL_IOMUXC_SIZE = 0x700, | ||
180 | + | ||
181 | FSL_IMX6UL_GPC_ADDR = 0x020DC000, | ||
182 | + | ||
183 | FSL_IMX6UL_SRC_ADDR = 0x020D8000, | ||
184 | + | ||
185 | FSL_IMX6UL_EPIT2_ADDR = 0x020D4000, | ||
186 | FSL_IMX6UL_EPIT1_ADDR = 0x020D0000, | ||
187 | + | ||
188 | FSL_IMX6UL_SNVS_HP_ADDR = 0x020CC000, | ||
189 | + | ||
190 | FSL_IMX6UL_USBPHY2_ADDR = 0x020CA000, | ||
191 | - FSL_IMX6UL_USBPHY2_SIZE = (4 * 1024), | ||
192 | FSL_IMX6UL_USBPHY1_ADDR = 0x020C9000, | ||
193 | - FSL_IMX6UL_USBPHY1_SIZE = (4 * 1024), | ||
194 | + | ||
195 | FSL_IMX6UL_ANALOG_ADDR = 0x020C8000, | ||
196 | + FSL_IMX6UL_ANALOG_SIZE = 0x300, | ||
197 | + | ||
198 | FSL_IMX6UL_CCM_ADDR = 0x020C4000, | ||
199 | + | ||
200 | FSL_IMX6UL_WDOG2_ADDR = 0x020C0000, | ||
201 | FSL_IMX6UL_WDOG1_ADDR = 0x020BC000, | ||
202 | + | ||
203 | FSL_IMX6UL_KPP_ADDR = 0x020B8000, | ||
204 | + FSL_IMX6UL_KPP_SIZE = 0x10, | ||
205 | + | ||
206 | FSL_IMX6UL_ENET2_ADDR = 0x020B4000, | ||
207 | + | ||
208 | FSL_IMX6UL_SNVS_LP_ADDR = 0x020B0000, | ||
209 | + FSL_IMX6UL_SNVS_LP_SIZE = (16 * KiB), | ||
210 | + | ||
211 | FSL_IMX6UL_GPIO5_ADDR = 0x020AC000, | ||
212 | FSL_IMX6UL_GPIO4_ADDR = 0x020A8000, | ||
213 | FSL_IMX6UL_GPIO3_ADDR = 0x020A4000, | ||
214 | FSL_IMX6UL_GPIO2_ADDR = 0x020A0000, | ||
215 | FSL_IMX6UL_GPIO1_ADDR = 0x0209C000, | ||
216 | + | ||
217 | FSL_IMX6UL_GPT1_ADDR = 0x02098000, | ||
218 | + | ||
219 | FSL_IMX6UL_CAN2_ADDR = 0x02094000, | ||
220 | FSL_IMX6UL_CAN1_ADDR = 0x02090000, | ||
221 | + FSL_IMX6UL_CANn_SIZE = (4 * KiB), | ||
222 | + | ||
223 | FSL_IMX6UL_PWM4_ADDR = 0x0208C000, | ||
224 | FSL_IMX6UL_PWM3_ADDR = 0x02088000, | ||
225 | FSL_IMX6UL_PWM2_ADDR = 0x02084000, | ||
226 | FSL_IMX6UL_PWM1_ADDR = 0x02080000, | ||
227 | + FSL_IMX6UL_PWMn_SIZE = 0x20, | ||
228 | + | ||
229 | FSL_IMX6UL_AIPS1_CFG_ADDR = 0x0207C000, | ||
230 | + FSL_IMX6UL_AIPS1_CFG_SIZE = (16 * KiB), | ||
231 | + | ||
232 | FSL_IMX6UL_BEE_ADDR = 0x02044000, | ||
233 | + FSL_IMX6UL_BEE_SIZE = (16 * KiB), | ||
234 | + | ||
235 | FSL_IMX6UL_TOUCH_CTRL_ADDR = 0x02040000, | ||
236 | + FSL_IMX6UL_TOUCH_CTRL_SIZE = 0x100, | ||
237 | + | ||
238 | FSL_IMX6UL_SPBA_ADDR = 0x0203C000, | ||
239 | + FSL_IMX6UL_SPBA_SIZE = 0x100, | ||
240 | + | ||
241 | FSL_IMX6UL_ASRC_ADDR = 0x02034000, | ||
242 | + FSL_IMX6UL_ASRC_SIZE = 0x100, | ||
243 | + | ||
244 | FSL_IMX6UL_SAI3_ADDR = 0x02030000, | ||
245 | FSL_IMX6UL_SAI2_ADDR = 0x0202C000, | ||
246 | FSL_IMX6UL_SAI1_ADDR = 0x02028000, | ||
247 | + FSL_IMX6UL_SAIn_SIZE = 0x200, | ||
248 | + | ||
249 | FSL_IMX6UL_UART8_ADDR = 0x02024000, | ||
250 | FSL_IMX6UL_UART1_ADDR = 0x02020000, | ||
251 | FSL_IMX6UL_UART7_ADDR = 0x02018000, | ||
252 | + | ||
253 | FSL_IMX6UL_ECSPI4_ADDR = 0x02014000, | ||
254 | FSL_IMX6UL_ECSPI3_ADDR = 0x02010000, | ||
255 | FSL_IMX6UL_ECSPI2_ADDR = 0x0200C000, | ||
256 | FSL_IMX6UL_ECSPI1_ADDR = 0x02008000, | ||
257 | + | ||
258 | FSL_IMX6UL_SPDIF_ADDR = 0x02004000, | ||
259 | + FSL_IMX6UL_SPDIF_SIZE = 0x100, | ||
260 | + /* AIPS-1 End */ | ||
261 | + | ||
262 | + FSL_IMX6UL_BCH_ADDR = 0x01808000, | ||
263 | + FSL_IMX6UL_BCH_SIZE = 0x200, | ||
264 | + | ||
265 | + FSL_IMX6UL_GPMI_ADDR = 0x01806000, | ||
266 | + FSL_IMX6UL_GPMI_SIZE = 0x200, | ||
267 | |||
268 | FSL_IMX6UL_APBH_DMA_ADDR = 0x01804000, | ||
269 | - FSL_IMX6UL_APBH_DMA_SIZE = (32 * 1024), | ||
270 | + FSL_IMX6UL_APBH_DMA_SIZE = (4 * KiB), | ||
271 | |||
272 | FSL_IMX6UL_A7MPCORE_ADDR = 0x00A00000, | ||
273 | |||
274 | FSL_IMX6UL_OCRAM_ALIAS_ADDR = 0x00920000, | ||
275 | - FSL_IMX6UL_OCRAM_ALIAS_SIZE = 0x00060000, | ||
276 | + FSL_IMX6UL_OCRAM_ALIAS_SIZE = (384 * KiB), | ||
277 | + | ||
278 | FSL_IMX6UL_OCRAM_MEM_ADDR = 0x00900000, | ||
279 | - FSL_IMX6UL_OCRAM_MEM_SIZE = 0x00020000, | ||
280 | + FSL_IMX6UL_OCRAM_MEM_SIZE = (128 * KiB), | ||
281 | + | ||
282 | FSL_IMX6UL_CAAM_MEM_ADDR = 0x00100000, | ||
283 | - FSL_IMX6UL_CAAM_MEM_SIZE = 0x00008000, | ||
284 | + FSL_IMX6UL_CAAM_MEM_SIZE = (32 * KiB), | ||
285 | + | ||
286 | FSL_IMX6UL_ROM_ADDR = 0x00000000, | ||
287 | - FSL_IMX6UL_ROM_SIZE = 0x00018000, | ||
288 | + FSL_IMX6UL_ROM_SIZE = (96 * KiB), | ||
289 | }; | ||
290 | |||
291 | enum FslIMX6ULIRQs { | ||
292 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | ||
293 | index XXXXXXX..XXXXXXX 100644 | ||
294 | --- a/hw/arm/fsl-imx6ul.c | ||
295 | +++ b/hw/arm/fsl-imx6ul.c | ||
296 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
297 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); | ||
298 | |||
299 | /* | ||
300 | - * GPIOs 1 to 5 | ||
301 | + * GPIOs | ||
302 | */ | ||
303 | for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) { | ||
304 | snprintf(name, NAME_SIZE, "gpio%d", i); | ||
305 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
306 | } | ||
307 | |||
308 | /* | ||
309 | - * GPT 1, 2 | ||
310 | + * GPTs | ||
311 | */ | ||
312 | for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { | ||
313 | snprintf(name, NAME_SIZE, "gpt%d", i); | ||
314 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
315 | } | ||
316 | |||
317 | /* | ||
318 | - * EPIT 1, 2 | ||
319 | + * EPITs | ||
320 | */ | ||
321 | for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) { | ||
322 | snprintf(name, NAME_SIZE, "epit%d", i + 1); | ||
323 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
324 | } | ||
325 | |||
326 | /* | ||
327 | - * eCSPI | ||
328 | + * eCSPIs | ||
329 | */ | ||
330 | for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) { | ||
331 | snprintf(name, NAME_SIZE, "spi%d", i + 1); | ||
332 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
333 | } | ||
334 | |||
335 | /* | ||
336 | - * I2C | ||
337 | + * I2Cs | ||
338 | */ | ||
339 | for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) { | ||
340 | snprintf(name, NAME_SIZE, "i2c%d", i + 1); | ||
341 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
342 | } | ||
343 | |||
344 | /* | ||
345 | - * UART | ||
346 | + * UARTs | ||
347 | */ | ||
348 | for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) { | ||
349 | snprintf(name, NAME_SIZE, "uart%d", i); | ||
350 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | - * Ethernet | ||
355 | + * Ethernets | ||
356 | */ | ||
357 | for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) { | ||
358 | snprintf(name, NAME_SIZE, "eth%d", i); | ||
359 | object_initialize_child(obj, name, &s->eth[i], TYPE_IMX_ENET); | ||
360 | } | ||
361 | |||
362 | - /* USB */ | ||
363 | + /* | ||
364 | + * USB PHYs | ||
365 | + */ | ||
366 | for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { | ||
367 | snprintf(name, NAME_SIZE, "usbphy%d", i); | ||
368 | object_initialize_child(obj, name, &s->usbphy[i], TYPE_IMX_USBPHY); | ||
369 | } | ||
370 | + | ||
371 | + /* | ||
372 | + * USBs | ||
373 | + */ | ||
374 | for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { | ||
375 | snprintf(name, NAME_SIZE, "usb%d", i); | ||
376 | object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA); | ||
377 | } | ||
378 | |||
379 | /* | ||
380 | - * SDHCI | ||
381 | + * SDHCIs | ||
382 | */ | ||
383 | for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { | ||
384 | snprintf(name, NAME_SIZE, "usdhc%d", i); | ||
385 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
386 | } | ||
387 | |||
388 | /* | ||
389 | - * Watchdog | ||
390 | + * Watchdogs | ||
391 | */ | ||
392 | for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) { | ||
393 | snprintf(name, NAME_SIZE, "wdt%d", i); | ||
394 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
395 | * A7MPCORE DAP | ||
396 | */ | ||
397 | create_unimplemented_device("a7mpcore-dap", FSL_IMX6UL_A7MPCORE_DAP_ADDR, | ||
398 | - 0x100000); | ||
399 | + FSL_IMX6UL_A7MPCORE_DAP_SIZE); | ||
400 | |||
401 | /* | ||
402 | - * GPT 1, 2 | ||
403 | + * GPTs | ||
404 | */ | ||
405 | for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { | ||
406 | static const hwaddr FSL_IMX6UL_GPTn_ADDR[FSL_IMX6UL_NUM_GPTS] = { | ||
407 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
408 | } | ||
409 | |||
410 | /* | ||
411 | - * EPIT 1, 2 | ||
412 | + * EPITs | ||
413 | */ | ||
414 | for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) { | ||
415 | static const hwaddr FSL_IMX6UL_EPITn_ADDR[FSL_IMX6UL_NUM_EPITS] = { | ||
416 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
417 | } | ||
418 | |||
419 | /* | ||
420 | - * GPIO | ||
421 | + * GPIOs | ||
422 | */ | ||
423 | for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) { | ||
424 | static const hwaddr FSL_IMX6UL_GPIOn_ADDR[FSL_IMX6UL_NUM_GPIOS] = { | ||
425 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
426 | } | ||
427 | |||
428 | /* | ||
429 | - * IOMUXC and IOMUXC_GPR | ||
430 | + * IOMUXC | ||
431 | */ | ||
432 | - for (i = 0; i < 1; i++) { | ||
433 | - static const hwaddr FSL_IMX6UL_IOMUXCn_ADDR[FSL_IMX6UL_NUM_IOMUXCS] = { | ||
434 | - FSL_IMX6UL_IOMUXC_ADDR, | ||
435 | - FSL_IMX6UL_IOMUXC_GPR_ADDR, | ||
436 | - }; | ||
437 | - | ||
438 | - snprintf(name, NAME_SIZE, "iomuxc%d", i); | ||
439 | - create_unimplemented_device(name, FSL_IMX6UL_IOMUXCn_ADDR[i], 0x4000); | ||
440 | - } | ||
441 | + create_unimplemented_device("iomuxc", FSL_IMX6UL_IOMUXC_ADDR, | ||
442 | + FSL_IMX6UL_IOMUXC_SIZE); | ||
443 | + create_unimplemented_device("iomuxc_gpr", FSL_IMX6UL_IOMUXC_GPR_ADDR, | ||
444 | + FSL_IMX6UL_IOMUXC_GPR_SIZE); | ||
445 | |||
446 | /* | ||
447 | * CCM | ||
448 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
449 | sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort); | ||
450 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX6UL_GPC_ADDR); | ||
451 | |||
452 | - /* Initialize all ECSPI */ | ||
453 | + /* | ||
454 | + * ECSPIs | ||
455 | + */ | ||
456 | for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) { | ||
457 | static const hwaddr FSL_IMX6UL_SPIn_ADDR[FSL_IMX6UL_NUM_ECSPIS] = { | ||
458 | FSL_IMX6UL_ECSPI1_ADDR, | ||
459 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
460 | } | ||
461 | |||
462 | /* | ||
463 | - * I2C | ||
464 | + * I2Cs | ||
465 | */ | ||
466 | for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) { | ||
467 | static const hwaddr FSL_IMX6UL_I2Cn_ADDR[FSL_IMX6UL_NUM_I2CS] = { | ||
468 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
469 | } | ||
470 | |||
471 | /* | ||
472 | - * UART | ||
473 | + * UARTs | ||
474 | */ | ||
475 | for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) { | ||
476 | static const hwaddr FSL_IMX6UL_UARTn_ADDR[FSL_IMX6UL_NUM_UARTS] = { | ||
477 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
478 | } | ||
479 | |||
480 | /* | ||
481 | - * Ethernet | ||
482 | + * Ethernets | ||
483 | * | ||
484 | * We must use two loops since phy_connected affects the other interface | ||
485 | * and we have to set all properties before calling sysbus_realize(). | ||
486 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
487 | FSL_IMX6UL_ENETn_TIMER_IRQ[i])); | ||
488 | } | ||
489 | |||
490 | - /* USB */ | ||
491 | + /* | ||
492 | + * USB PHYs | ||
493 | + */ | ||
494 | for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { | ||
495 | + static const hwaddr | ||
496 | + FSL_IMX6UL_USB_PHYn_ADDR[FSL_IMX6UL_NUM_USB_PHYS] = { | ||
497 | + FSL_IMX6UL_USBPHY1_ADDR, | ||
498 | + FSL_IMX6UL_USBPHY2_ADDR, | ||
499 | + }; | ||
500 | + | ||
501 | sysbus_realize(SYS_BUS_DEVICE(&s->usbphy[i]), &error_abort); | ||
502 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usbphy[i]), 0, | ||
503 | - FSL_IMX6UL_USBPHY1_ADDR + i * 0x1000); | ||
504 | + FSL_IMX6UL_USB_PHYn_ADDR[i]); | ||
505 | } | ||
506 | |||
507 | + /* | ||
508 | + * USBs | ||
509 | + */ | ||
510 | for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { | ||
511 | + static const hwaddr FSL_IMX6UL_USB02_USBn_ADDR[FSL_IMX6UL_NUM_USBS] = { | ||
512 | + FSL_IMX6UL_USBO2_USB1_ADDR, | ||
513 | + FSL_IMX6UL_USBO2_USB2_ADDR, | ||
514 | + }; | ||
515 | + | ||
516 | static const int FSL_IMX6UL_USBn_IRQ[] = { | ||
517 | FSL_IMX6UL_USB1_IRQ, | ||
518 | FSL_IMX6UL_USB2_IRQ, | ||
519 | }; | ||
520 | + | ||
521 | sysbus_realize(SYS_BUS_DEVICE(&s->usb[i]), &error_abort); | ||
522 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
523 | - FSL_IMX6UL_USBO2_USB_ADDR + i * 0x200); | ||
524 | + FSL_IMX6UL_USB02_USBn_ADDR[i]); | ||
525 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
526 | qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
527 | FSL_IMX6UL_USBn_IRQ[i])); | ||
528 | } | ||
529 | |||
530 | /* | ||
531 | - * USDHC | ||
532 | + * USDHCs | ||
533 | */ | ||
534 | for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { | ||
535 | static const hwaddr FSL_IMX6UL_USDHCn_ADDR[FSL_IMX6UL_NUM_USDHCS] = { | ||
536 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
537 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX6UL_SNVS_HP_ADDR); | ||
538 | |||
539 | /* | ||
540 | - * Watchdog | ||
541 | + * Watchdogs | ||
542 | */ | ||
543 | for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) { | ||
544 | static const hwaddr FSL_IMX6UL_WDOGn_ADDR[FSL_IMX6UL_NUM_WDTS] = { | ||
545 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
546 | FSL_IMX6UL_WDOG2_ADDR, | ||
547 | FSL_IMX6UL_WDOG3_ADDR, | ||
548 | }; | ||
549 | + | ||
550 | static const int FSL_IMX6UL_WDOGn_IRQ[FSL_IMX6UL_NUM_WDTS] = { | ||
551 | FSL_IMX6UL_WDOG1_IRQ, | ||
552 | FSL_IMX6UL_WDOG2_IRQ, | ||
553 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
554 | /* | ||
555 | * SDMA | ||
556 | */ | ||
557 | - create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000); | ||
558 | + create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, | ||
559 | + FSL_IMX6UL_SDMA_SIZE); | ||
560 | |||
561 | /* | ||
562 | - * SAI (Audio SSI (Synchronous Serial Interface)) | ||
563 | + * SAIs (Audio SSI (Synchronous Serial Interface)) | ||
564 | */ | ||
565 | - create_unimplemented_device("sai1", FSL_IMX6UL_SAI1_ADDR, 0x4000); | ||
566 | - create_unimplemented_device("sai2", FSL_IMX6UL_SAI2_ADDR, 0x4000); | ||
567 | - create_unimplemented_device("sai3", FSL_IMX6UL_SAI3_ADDR, 0x4000); | ||
568 | + for (i = 0; i < FSL_IMX6UL_NUM_SAIS; i++) { | ||
569 | + static const hwaddr FSL_IMX6UL_SAIn_ADDR[FSL_IMX6UL_NUM_SAIS] = { | ||
570 | + FSL_IMX6UL_SAI1_ADDR, | ||
571 | + FSL_IMX6UL_SAI2_ADDR, | ||
572 | + FSL_IMX6UL_SAI3_ADDR, | ||
573 | + }; | ||
574 | + | ||
575 | + snprintf(name, NAME_SIZE, "sai%d", i); | ||
576 | + create_unimplemented_device(name, FSL_IMX6UL_SAIn_ADDR[i], | ||
577 | + FSL_IMX6UL_SAIn_SIZE); | ||
578 | + } | ||
579 | |||
580 | /* | ||
581 | - * PWM | ||
582 | + * PWMs | ||
583 | */ | ||
584 | - create_unimplemented_device("pwm1", FSL_IMX6UL_PWM1_ADDR, 0x4000); | ||
585 | - create_unimplemented_device("pwm2", FSL_IMX6UL_PWM2_ADDR, 0x4000); | ||
586 | - create_unimplemented_device("pwm3", FSL_IMX6UL_PWM3_ADDR, 0x4000); | ||
587 | - create_unimplemented_device("pwm4", FSL_IMX6UL_PWM4_ADDR, 0x4000); | ||
588 | + for (i = 0; i < FSL_IMX6UL_NUM_PWMS; i++) { | ||
589 | + static const hwaddr FSL_IMX6UL_PWMn_ADDR[FSL_IMX6UL_NUM_PWMS] = { | ||
590 | + FSL_IMX6UL_PWM1_ADDR, | ||
591 | + FSL_IMX6UL_PWM2_ADDR, | ||
592 | + FSL_IMX6UL_PWM3_ADDR, | ||
593 | + FSL_IMX6UL_PWM4_ADDR, | ||
594 | + }; | ||
595 | + | ||
596 | + snprintf(name, NAME_SIZE, "pwm%d", i); | ||
597 | + create_unimplemented_device(name, FSL_IMX6UL_PWMn_ADDR[i], | ||
598 | + FSL_IMX6UL_PWMn_SIZE); | ||
599 | + } | ||
600 | |||
601 | /* | ||
602 | * Audio ASRC (asynchronous sample rate converter) | ||
603 | */ | ||
604 | - create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, 0x4000); | ||
605 | + create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, | ||
606 | + FSL_IMX6UL_ASRC_SIZE); | ||
607 | |||
608 | /* | ||
609 | - * CAN | ||
610 | + * CANs | ||
611 | */ | ||
612 | - create_unimplemented_device("can1", FSL_IMX6UL_CAN1_ADDR, 0x4000); | ||
613 | - create_unimplemented_device("can2", FSL_IMX6UL_CAN2_ADDR, 0x4000); | ||
614 | + for (i = 0; i < FSL_IMX6UL_NUM_CANS; i++) { | ||
615 | + static const hwaddr FSL_IMX6UL_CANn_ADDR[FSL_IMX6UL_NUM_CANS] = { | ||
616 | + FSL_IMX6UL_CAN1_ADDR, | ||
617 | + FSL_IMX6UL_CAN2_ADDR, | ||
618 | + }; | ||
619 | + | ||
620 | + snprintf(name, NAME_SIZE, "can%d", i); | ||
621 | + create_unimplemented_device(name, FSL_IMX6UL_CANn_ADDR[i], | ||
622 | + FSL_IMX6UL_CANn_SIZE); | ||
623 | + } | ||
624 | |||
625 | /* | ||
626 | * APHB_DMA | ||
627 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
628 | }; | ||
629 | |||
630 | snprintf(name, NAME_SIZE, "adc%d", i); | ||
631 | - create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i], 0x4000); | ||
632 | + create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i], | ||
633 | + FSL_IMX6UL_ADCn_SIZE); | ||
634 | } | ||
635 | |||
636 | /* | ||
637 | * LCD | ||
638 | */ | ||
639 | - create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, 0x4000); | ||
640 | + create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, | ||
641 | + FSL_IMX6UL_LCDIF_SIZE); | ||
642 | |||
643 | /* | ||
644 | * ROM memory | ||
51 | -- | 645 | -- |
52 | 2.20.1 | 646 | 2.34.1 |
53 | |||
54 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Instantiate SAI1/2/3 and ASRC as unimplemented devices to avoid random | 3 | * Add TZASC as unimplemented device. |
4 | Linux kernel crashes, such as | 4 | - Allow bare metal application to access this (unimplemented) device |
5 | * Add CSU as unimplemented device. | ||
6 | - Allow bare metal application to access this (unimplemented) device | ||
7 | * Add 4 missing PWM devices | ||
5 | 8 | ||
6 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd1580010 | 9 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
7 | pgd = (ptrval) | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | [d1580010] *pgd=8231b811, *pte=02034653, *ppte=02034453 | 11 | Message-id: 59e4dc56e14eccfefd379275ec19048dff9c10b3.1692964892.git.jcd@tribudubois.net |
9 | Internal error: : 808 [#1] SMP ARM | ||
10 | ... | ||
11 | [<c095e974>] (regmap_mmio_write32le) from [<c095eb48>] (regmap_mmio_write+0x3c/0x54) | ||
12 | [<c095eb48>] (regmap_mmio_write) from [<c09580f4>] (_regmap_write+0x4c/0x1f0) | ||
13 | [<c09580f4>] (_regmap_write) from [<c095837c>] (_regmap_update_bits+0xe4/0xec) | ||
14 | [<c095837c>] (_regmap_update_bits) from [<c09599b4>] (regmap_update_bits_base+0x50/0x74) | ||
15 | [<c09599b4>] (regmap_update_bits_base) from [<c0d3e9e4>] (fsl_asrc_runtime_resume+0x1e4/0x21c) | ||
16 | [<c0d3e9e4>] (fsl_asrc_runtime_resume) from [<c0942464>] (__rpm_callback+0x3c/0x108) | ||
17 | [<c0942464>] (__rpm_callback) from [<c0942590>] (rpm_callback+0x60/0x64) | ||
18 | [<c0942590>] (rpm_callback) from [<c0942b60>] (rpm_resume+0x5cc/0x808) | ||
19 | [<c0942b60>] (rpm_resume) from [<c0942dfc>] (__pm_runtime_resume+0x60/0xa0) | ||
20 | [<c0942dfc>] (__pm_runtime_resume) from [<c0d3ecc4>] (fsl_asrc_probe+0x2a8/0x708) | ||
21 | [<c0d3ecc4>] (fsl_asrc_probe) from [<c0935b08>] (platform_probe+0x58/0xb8) | ||
22 | [<c0935b08>] (platform_probe) from [<c0933264>] (really_probe.part.0+0x9c/0x334) | ||
23 | [<c0933264>] (really_probe.part.0) from [<c093359c>] (__driver_probe_device+0xa0/0x138) | ||
24 | [<c093359c>] (__driver_probe_device) from [<c0933664>] (driver_probe_device+0x30/0xc8) | ||
25 | [<c0933664>] (driver_probe_device) from [<c0933c88>] (__driver_attach+0x90/0x130) | ||
26 | [<c0933c88>] (__driver_attach) from [<c0931060>] (bus_for_each_dev+0x78/0xb8) | ||
27 | [<c0931060>] (bus_for_each_dev) from [<c093254c>] (bus_add_driver+0xf0/0x1d8) | ||
28 | [<c093254c>] (bus_add_driver) from [<c0934a30>] (driver_register+0x88/0x118) | ||
29 | [<c0934a30>] (driver_register) from [<c01022c0>] (do_one_initcall+0x7c/0x3a4) | ||
30 | [<c01022c0>] (do_one_initcall) from [<c1601204>] (kernel_init_freeable+0x198/0x22c) | ||
31 | [<c1601204>] (kernel_init_freeable) from [<c0f5ff2c>] (kernel_init+0x10/0x128) | ||
32 | [<c0f5ff2c>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38) | ||
33 | |||
34 | or | ||
35 | |||
36 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd19b0000 | ||
37 | pgd = (ptrval) | ||
38 | [d19b0000] *pgd=82711811, *pte=308a0653, *ppte=308a0453 | ||
39 | Internal error: : 808 [#1] SMP ARM | ||
40 | ... | ||
41 | [<c095e974>] (regmap_mmio_write32le) from [<c095eb48>] (regmap_mmio_write+0x3c/0x54) | ||
42 | [<c095eb48>] (regmap_mmio_write) from [<c09580f4>] (_regmap_write+0x4c/0x1f0) | ||
43 | [<c09580f4>] (_regmap_write) from [<c0959b28>] (regmap_write+0x3c/0x60) | ||
44 | [<c0959b28>] (regmap_write) from [<c0d41130>] (fsl_sai_runtime_resume+0x9c/0x1ec) | ||
45 | [<c0d41130>] (fsl_sai_runtime_resume) from [<c0942464>] (__rpm_callback+0x3c/0x108) | ||
46 | [<c0942464>] (__rpm_callback) from [<c0942590>] (rpm_callback+0x60/0x64) | ||
47 | [<c0942590>] (rpm_callback) from [<c0942b60>] (rpm_resume+0x5cc/0x808) | ||
48 | [<c0942b60>] (rpm_resume) from [<c0942dfc>] (__pm_runtime_resume+0x60/0xa0) | ||
49 | [<c0942dfc>] (__pm_runtime_resume) from [<c0d4231c>] (fsl_sai_probe+0x2b8/0x65c) | ||
50 | [<c0d4231c>] (fsl_sai_probe) from [<c0935b08>] (platform_probe+0x58/0xb8) | ||
51 | [<c0935b08>] (platform_probe) from [<c0933264>] (really_probe.part.0+0x9c/0x334) | ||
52 | [<c0933264>] (really_probe.part.0) from [<c093359c>] (__driver_probe_device+0xa0/0x138) | ||
53 | [<c093359c>] (__driver_probe_device) from [<c0933664>] (driver_probe_device+0x30/0xc8) | ||
54 | [<c0933664>] (driver_probe_device) from [<c0933c88>] (__driver_attach+0x90/0x130) | ||
55 | [<c0933c88>] (__driver_attach) from [<c0931060>] (bus_for_each_dev+0x78/0xb8) | ||
56 | [<c0931060>] (bus_for_each_dev) from [<c093254c>] (bus_add_driver+0xf0/0x1d8) | ||
57 | [<c093254c>] (bus_add_driver) from [<c0934a30>] (driver_register+0x88/0x118) | ||
58 | [<c0934a30>] (driver_register) from [<c01022c0>] (do_one_initcall+0x7c/0x3a4) | ||
59 | [<c01022c0>] (do_one_initcall) from [<c1601204>] (kernel_init_freeable+0x198/0x22c) | ||
60 | [<c1601204>] (kernel_init_freeable) from [<c0f5ff2c>] (kernel_init+0x10/0x128) | ||
61 | [<c0f5ff2c>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38) | ||
62 | |||
63 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
64 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
65 | Message-id: 20210810160318.87376-1-linux@roeck-us.net | ||
66 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
67 | --- | 13 | --- |
68 | hw/arm/fsl-imx6ul.c | 12 ++++++++++++ | 14 | include/hw/arm/fsl-imx6ul.h | 2 +- |
69 | 1 file changed, 12 insertions(+) | 15 | hw/arm/fsl-imx6ul.c | 16 ++++++++++++++++ |
16 | 2 files changed, 17 insertions(+), 1 deletion(-) | ||
70 | 17 | ||
18 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/hw/arm/fsl-imx6ul.h | ||
21 | +++ b/include/hw/arm/fsl-imx6ul.h | ||
22 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration { | ||
23 | FSL_IMX6UL_NUM_USBS = 2, | ||
24 | FSL_IMX6UL_NUM_SAIS = 3, | ||
25 | FSL_IMX6UL_NUM_CANS = 2, | ||
26 | - FSL_IMX6UL_NUM_PWMS = 4, | ||
27 | + FSL_IMX6UL_NUM_PWMS = 8, | ||
28 | }; | ||
29 | |||
30 | struct FslIMX6ULState { | ||
71 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | 31 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c |
72 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
73 | --- a/hw/arm/fsl-imx6ul.c | 33 | --- a/hw/arm/fsl-imx6ul.c |
74 | +++ b/hw/arm/fsl-imx6ul.c | 34 | +++ b/hw/arm/fsl-imx6ul.c |
75 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | 35 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
76 | */ | 36 | FSL_IMX6UL_PWM2_ADDR, |
77 | create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000); | 37 | FSL_IMX6UL_PWM3_ADDR, |
38 | FSL_IMX6UL_PWM4_ADDR, | ||
39 | + FSL_IMX6UL_PWM5_ADDR, | ||
40 | + FSL_IMX6UL_PWM6_ADDR, | ||
41 | + FSL_IMX6UL_PWM7_ADDR, | ||
42 | + FSL_IMX6UL_PWM8_ADDR, | ||
43 | }; | ||
44 | |||
45 | snprintf(name, NAME_SIZE, "pwm%d", i); | ||
46 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
47 | create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, | ||
48 | FSL_IMX6UL_LCDIF_SIZE); | ||
78 | 49 | ||
79 | + /* | 50 | + /* |
80 | + * SAI (Audio SSI (Synchronous Serial Interface)) | 51 | + * CSU |
81 | + */ | 52 | + */ |
82 | + create_unimplemented_device("sai1", FSL_IMX6UL_SAI1_ADDR, 0x4000); | 53 | + create_unimplemented_device("csu", FSL_IMX6UL_CSU_ADDR, |
83 | + create_unimplemented_device("sai2", FSL_IMX6UL_SAI2_ADDR, 0x4000); | 54 | + FSL_IMX6UL_CSU_SIZE); |
84 | + create_unimplemented_device("sai3", FSL_IMX6UL_SAI3_ADDR, 0x4000); | 55 | + |
56 | + /* | ||
57 | + * TZASC | ||
58 | + */ | ||
59 | + create_unimplemented_device("tzasc", FSL_IMX6UL_TZASC_ADDR, | ||
60 | + FSL_IMX6UL_TZASC_SIZE); | ||
85 | + | 61 | + |
86 | /* | 62 | /* |
87 | * PWM | 63 | * ROM memory |
88 | */ | ||
89 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
90 | create_unimplemented_device("pwm3", FSL_IMX6UL_PWM3_ADDR, 0x4000); | ||
91 | create_unimplemented_device("pwm4", FSL_IMX6UL_PWM4_ADDR, 0x4000); | ||
92 | |||
93 | + /* | ||
94 | + * Audio ASRC (asynchronous sample rate converter) | ||
95 | + */ | ||
96 | + create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, 0x4000); | ||
97 | + | ||
98 | /* | ||
99 | * CAN | ||
100 | */ | 64 | */ |
101 | -- | 65 | -- |
102 | 2.20.1 | 66 | 2.34.1 |
103 | 67 | ||
104 | 68 | diff view generated by jsdifflib |
1 | We were not paying attention to the ECI state when advancing the VPT | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | state. Architecturally, VPT state advance happens for every beat | ||
3 | (see the pseudocode VPTAdvance()), so on every beat the 4 bits of | ||
4 | VPR.P0 corresponding to the current beat are inverted if required, | ||
5 | and at the end of beats 1 and 3 the VPR MASK fields are updated. | ||
6 | This means that if the ECI state says we should not be executing all | ||
7 | 4 beats then we need to skip some of the updating of the VPR that we | ||
8 | currently do in mve_advance_vpt(). | ||
9 | 2 | ||
3 | * Add Addr and size definition for all i.MX7 devices in i.MX7 header file. | ||
4 | * Use those newly defined named constants whenever possible. | ||
5 | * Standardize the way we init a familly of unimplemented devices | ||
6 | - SAI | ||
7 | - PWM | ||
8 | - CAN | ||
9 | * Add/rework few comments | ||
10 | |||
11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
12 | Message-id: 59e195d33e4d486a8d131392acd46633c8c10ed7.1692964892.git.jcd@tribudubois.net | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | 15 | --- |
13 | target/arm/mve_helper.c | 24 +++++++++++++++++------- | 16 | include/hw/arm/fsl-imx7.h | 330 ++++++++++++++++++++++++++++---------- |
14 | 1 file changed, 17 insertions(+), 7 deletions(-) | 17 | hw/arm/fsl-imx7.c | 130 ++++++++++----- |
18 | 2 files changed, 335 insertions(+), 125 deletions(-) | ||
15 | 19 | ||
16 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 20 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
17 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/mve_helper.c | 22 | --- a/include/hw/arm/fsl-imx7.h |
19 | +++ b/target/arm/mve_helper.c | 23 | +++ b/include/hw/arm/fsl-imx7.h |
20 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) | 24 | @@ -XXX,XX +XXX,XX @@ |
21 | /* Advance the VPT and ECI state if necessary */ | 25 | #include "hw/misc/imx7_ccm.h" |
22 | uint32_t vpr = env->v7m.vpr; | 26 | #include "hw/misc/imx7_snvs.h" |
23 | unsigned mask01, mask23; | 27 | #include "hw/misc/imx7_gpr.h" |
24 | + uint16_t inv_mask; | 28 | -#include "hw/misc/imx6_src.h" |
25 | + uint16_t eci_mask = mve_eci_mask(env); | 29 | #include "hw/watchdog/wdt_imx2.h" |
26 | 30 | #include "hw/gpio/imx_gpio.h" | |
27 | if ((env->condexec_bits & 0xf) == 0) { | 31 | #include "hw/char/imx_serial.h" |
28 | env->condexec_bits = (env->condexec_bits == (ECI_A0A1A2B0 << 4)) ? | 32 | @@ -XXX,XX +XXX,XX @@ |
29 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) | 33 | #include "hw/usb/chipidea.h" |
34 | #include "cpu.h" | ||
35 | #include "qom/object.h" | ||
36 | +#include "qemu/units.h" | ||
37 | |||
38 | #define TYPE_FSL_IMX7 "fsl-imx7" | ||
39 | OBJECT_DECLARE_SIMPLE_TYPE(FslIMX7State, FSL_IMX7) | ||
40 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7Configuration { | ||
41 | FSL_IMX7_NUM_ECSPIS = 4, | ||
42 | FSL_IMX7_NUM_USBS = 3, | ||
43 | FSL_IMX7_NUM_ADCS = 2, | ||
44 | + FSL_IMX7_NUM_SAIS = 3, | ||
45 | + FSL_IMX7_NUM_CANS = 2, | ||
46 | + FSL_IMX7_NUM_PWMS = 4, | ||
47 | }; | ||
48 | |||
49 | struct FslIMX7State { | ||
50 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { | ||
51 | |||
52 | enum FslIMX7MemoryMap { | ||
53 | FSL_IMX7_MMDC_ADDR = 0x80000000, | ||
54 | - FSL_IMX7_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL, | ||
55 | + FSL_IMX7_MMDC_SIZE = (2 * GiB), | ||
56 | |||
57 | - FSL_IMX7_GPIO1_ADDR = 0x30200000, | ||
58 | - FSL_IMX7_GPIO2_ADDR = 0x30210000, | ||
59 | - FSL_IMX7_GPIO3_ADDR = 0x30220000, | ||
60 | - FSL_IMX7_GPIO4_ADDR = 0x30230000, | ||
61 | - FSL_IMX7_GPIO5_ADDR = 0x30240000, | ||
62 | - FSL_IMX7_GPIO6_ADDR = 0x30250000, | ||
63 | - FSL_IMX7_GPIO7_ADDR = 0x30260000, | ||
64 | + FSL_IMX7_QSPI1_MEM_ADDR = 0x60000000, | ||
65 | + FSL_IMX7_QSPI1_MEM_SIZE = (256 * MiB), | ||
66 | |||
67 | - FSL_IMX7_IOMUXC_LPSR_GPR_ADDR = 0x30270000, | ||
68 | + FSL_IMX7_PCIE1_MEM_ADDR = 0x40000000, | ||
69 | + FSL_IMX7_PCIE1_MEM_SIZE = (256 * MiB), | ||
70 | |||
71 | - FSL_IMX7_WDOG1_ADDR = 0x30280000, | ||
72 | - FSL_IMX7_WDOG2_ADDR = 0x30290000, | ||
73 | - FSL_IMX7_WDOG3_ADDR = 0x302A0000, | ||
74 | - FSL_IMX7_WDOG4_ADDR = 0x302B0000, | ||
75 | + FSL_IMX7_QSPI1_RX_BUF_ADDR = 0x34000000, | ||
76 | + FSL_IMX7_QSPI1_RX_BUF_SIZE = (32 * MiB), | ||
77 | |||
78 | - FSL_IMX7_IOMUXC_LPSR_ADDR = 0x302C0000, | ||
79 | + /* PCIe Peripherals */ | ||
80 | + FSL_IMX7_PCIE_REG_ADDR = 0x33800000, | ||
81 | |||
82 | - FSL_IMX7_GPT1_ADDR = 0x302D0000, | ||
83 | - FSL_IMX7_GPT2_ADDR = 0x302E0000, | ||
84 | - FSL_IMX7_GPT3_ADDR = 0x302F0000, | ||
85 | - FSL_IMX7_GPT4_ADDR = 0x30300000, | ||
86 | + /* MMAP Peripherals */ | ||
87 | + FSL_IMX7_DMA_APBH_ADDR = 0x33000000, | ||
88 | + FSL_IMX7_DMA_APBH_SIZE = 0x8000, | ||
89 | |||
90 | - FSL_IMX7_IOMUXC_ADDR = 0x30330000, | ||
91 | - FSL_IMX7_IOMUXC_GPR_ADDR = 0x30340000, | ||
92 | - FSL_IMX7_IOMUXCn_SIZE = 0x1000, | ||
93 | + /* GPV configuration */ | ||
94 | + FSL_IMX7_GPV6_ADDR = 0x32600000, | ||
95 | + FSL_IMX7_GPV5_ADDR = 0x32500000, | ||
96 | + FSL_IMX7_GPV4_ADDR = 0x32400000, | ||
97 | + FSL_IMX7_GPV3_ADDR = 0x32300000, | ||
98 | + FSL_IMX7_GPV2_ADDR = 0x32200000, | ||
99 | + FSL_IMX7_GPV1_ADDR = 0x32100000, | ||
100 | + FSL_IMX7_GPV0_ADDR = 0x32000000, | ||
101 | + FSL_IMX7_GPVn_SIZE = (1 * MiB), | ||
102 | |||
103 | - FSL_IMX7_OCOTP_ADDR = 0x30350000, | ||
104 | - FSL_IMX7_OCOTP_SIZE = 0x10000, | ||
105 | + /* Arm Peripherals */ | ||
106 | + FSL_IMX7_A7MPCORE_ADDR = 0x31000000, | ||
107 | |||
108 | - FSL_IMX7_ANALOG_ADDR = 0x30360000, | ||
109 | - FSL_IMX7_SNVS_ADDR = 0x30370000, | ||
110 | - FSL_IMX7_CCM_ADDR = 0x30380000, | ||
111 | + /* AIPS-3 Begin */ | ||
112 | |||
113 | - FSL_IMX7_SRC_ADDR = 0x30390000, | ||
114 | - FSL_IMX7_SRC_SIZE = 0x1000, | ||
115 | + FSL_IMX7_ENET2_ADDR = 0x30BF0000, | ||
116 | + FSL_IMX7_ENET1_ADDR = 0x30BE0000, | ||
117 | |||
118 | - FSL_IMX7_ADC1_ADDR = 0x30610000, | ||
119 | - FSL_IMX7_ADC2_ADDR = 0x30620000, | ||
120 | - FSL_IMX7_ADCn_SIZE = 0x1000, | ||
121 | + FSL_IMX7_SDMA_ADDR = 0x30BD0000, | ||
122 | + FSL_IMX7_SDMA_SIZE = (4 * KiB), | ||
123 | |||
124 | - FSL_IMX7_PWM1_ADDR = 0x30660000, | ||
125 | - FSL_IMX7_PWM2_ADDR = 0x30670000, | ||
126 | - FSL_IMX7_PWM3_ADDR = 0x30680000, | ||
127 | - FSL_IMX7_PWM4_ADDR = 0x30690000, | ||
128 | - FSL_IMX7_PWMn_SIZE = 0x10000, | ||
129 | + FSL_IMX7_EIM_ADDR = 0x30BC0000, | ||
130 | + FSL_IMX7_EIM_SIZE = (4 * KiB), | ||
131 | |||
132 | - FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000, | ||
133 | - FSL_IMX7_PCIE_PHY_SIZE = 0x10000, | ||
134 | + FSL_IMX7_QSPI_ADDR = 0x30BB0000, | ||
135 | + FSL_IMX7_QSPI_SIZE = 0x8000, | ||
136 | |||
137 | - FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
138 | + FSL_IMX7_SIM2_ADDR = 0x30BA0000, | ||
139 | + FSL_IMX7_SIM1_ADDR = 0x30B90000, | ||
140 | + FSL_IMX7_SIMn_SIZE = (4 * KiB), | ||
141 | + | ||
142 | + FSL_IMX7_USDHC3_ADDR = 0x30B60000, | ||
143 | + FSL_IMX7_USDHC2_ADDR = 0x30B50000, | ||
144 | + FSL_IMX7_USDHC1_ADDR = 0x30B40000, | ||
145 | + | ||
146 | + FSL_IMX7_USB3_ADDR = 0x30B30000, | ||
147 | + FSL_IMX7_USBMISC3_ADDR = 0x30B30200, | ||
148 | + FSL_IMX7_USB2_ADDR = 0x30B20000, | ||
149 | + FSL_IMX7_USBMISC2_ADDR = 0x30B20200, | ||
150 | + FSL_IMX7_USB1_ADDR = 0x30B10000, | ||
151 | + FSL_IMX7_USBMISC1_ADDR = 0x30B10200, | ||
152 | + FSL_IMX7_USBMISCn_SIZE = 0x200, | ||
153 | + | ||
154 | + FSL_IMX7_USB_PL301_ADDR = 0x30AD0000, | ||
155 | + FSL_IMX7_USB_PL301_SIZE = (64 * KiB), | ||
156 | + | ||
157 | + FSL_IMX7_SEMAPHORE_HS_ADDR = 0x30AC0000, | ||
158 | + FSL_IMX7_SEMAPHORE_HS_SIZE = (64 * KiB), | ||
159 | + | ||
160 | + FSL_IMX7_MUB_ADDR = 0x30AB0000, | ||
161 | + FSL_IMX7_MUA_ADDR = 0x30AA0000, | ||
162 | + FSL_IMX7_MUn_SIZE = (KiB), | ||
163 | + | ||
164 | + FSL_IMX7_UART7_ADDR = 0x30A90000, | ||
165 | + FSL_IMX7_UART6_ADDR = 0x30A80000, | ||
166 | + FSL_IMX7_UART5_ADDR = 0x30A70000, | ||
167 | + FSL_IMX7_UART4_ADDR = 0x30A60000, | ||
168 | + | ||
169 | + FSL_IMX7_I2C4_ADDR = 0x30A50000, | ||
170 | + FSL_IMX7_I2C3_ADDR = 0x30A40000, | ||
171 | + FSL_IMX7_I2C2_ADDR = 0x30A30000, | ||
172 | + FSL_IMX7_I2C1_ADDR = 0x30A20000, | ||
173 | + | ||
174 | + FSL_IMX7_CAN2_ADDR = 0x30A10000, | ||
175 | + FSL_IMX7_CAN1_ADDR = 0x30A00000, | ||
176 | + FSL_IMX7_CANn_SIZE = (4 * KiB), | ||
177 | + | ||
178 | + FSL_IMX7_AIPS3_CONF_ADDR = 0x309F0000, | ||
179 | + FSL_IMX7_AIPS3_CONF_SIZE = (64 * KiB), | ||
180 | |||
181 | FSL_IMX7_CAAM_ADDR = 0x30900000, | ||
182 | - FSL_IMX7_CAAM_SIZE = 0x40000, | ||
183 | + FSL_IMX7_CAAM_SIZE = (256 * KiB), | ||
184 | |||
185 | - FSL_IMX7_CAN1_ADDR = 0x30A00000, | ||
186 | - FSL_IMX7_CAN2_ADDR = 0x30A10000, | ||
187 | - FSL_IMX7_CANn_SIZE = 0x10000, | ||
188 | + FSL_IMX7_SPBA_ADDR = 0x308F0000, | ||
189 | + FSL_IMX7_SPBA_SIZE = (4 * KiB), | ||
190 | |||
191 | - FSL_IMX7_I2C1_ADDR = 0x30A20000, | ||
192 | - FSL_IMX7_I2C2_ADDR = 0x30A30000, | ||
193 | - FSL_IMX7_I2C3_ADDR = 0x30A40000, | ||
194 | - FSL_IMX7_I2C4_ADDR = 0x30A50000, | ||
195 | + FSL_IMX7_SAI3_ADDR = 0x308C0000, | ||
196 | + FSL_IMX7_SAI2_ADDR = 0x308B0000, | ||
197 | + FSL_IMX7_SAI1_ADDR = 0x308A0000, | ||
198 | + FSL_IMX7_SAIn_SIZE = (4 * KiB), | ||
199 | |||
200 | - FSL_IMX7_ECSPI1_ADDR = 0x30820000, | ||
201 | - FSL_IMX7_ECSPI2_ADDR = 0x30830000, | ||
202 | - FSL_IMX7_ECSPI3_ADDR = 0x30840000, | ||
203 | - FSL_IMX7_ECSPI4_ADDR = 0x30630000, | ||
204 | - | ||
205 | - FSL_IMX7_LCDIF_ADDR = 0x30730000, | ||
206 | - FSL_IMX7_LCDIF_SIZE = 0x1000, | ||
207 | - | ||
208 | - FSL_IMX7_UART1_ADDR = 0x30860000, | ||
209 | + FSL_IMX7_UART3_ADDR = 0x30880000, | ||
210 | /* | ||
211 | * Some versions of the reference manual claim that UART2 is @ | ||
212 | * 0x30870000, but experiments with HW + DT files in upstream | ||
213 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | ||
214 | * actually located @ 0x30890000 | ||
215 | */ | ||
216 | FSL_IMX7_UART2_ADDR = 0x30890000, | ||
217 | - FSL_IMX7_UART3_ADDR = 0x30880000, | ||
218 | - FSL_IMX7_UART4_ADDR = 0x30A60000, | ||
219 | - FSL_IMX7_UART5_ADDR = 0x30A70000, | ||
220 | - FSL_IMX7_UART6_ADDR = 0x30A80000, | ||
221 | - FSL_IMX7_UART7_ADDR = 0x30A90000, | ||
222 | + FSL_IMX7_UART1_ADDR = 0x30860000, | ||
223 | |||
224 | - FSL_IMX7_SAI1_ADDR = 0x308A0000, | ||
225 | - FSL_IMX7_SAI2_ADDR = 0x308B0000, | ||
226 | - FSL_IMX7_SAI3_ADDR = 0x308C0000, | ||
227 | - FSL_IMX7_SAIn_SIZE = 0x10000, | ||
228 | + FSL_IMX7_ECSPI3_ADDR = 0x30840000, | ||
229 | + FSL_IMX7_ECSPI2_ADDR = 0x30830000, | ||
230 | + FSL_IMX7_ECSPI1_ADDR = 0x30820000, | ||
231 | + FSL_IMX7_ECSPIn_SIZE = (4 * KiB), | ||
232 | |||
233 | - FSL_IMX7_ENET1_ADDR = 0x30BE0000, | ||
234 | - FSL_IMX7_ENET2_ADDR = 0x30BF0000, | ||
235 | + /* AIPS-3 End */ | ||
236 | |||
237 | - FSL_IMX7_USB1_ADDR = 0x30B10000, | ||
238 | - FSL_IMX7_USBMISC1_ADDR = 0x30B10200, | ||
239 | - FSL_IMX7_USB2_ADDR = 0x30B20000, | ||
240 | - FSL_IMX7_USBMISC2_ADDR = 0x30B20200, | ||
241 | - FSL_IMX7_USB3_ADDR = 0x30B30000, | ||
242 | - FSL_IMX7_USBMISC3_ADDR = 0x30B30200, | ||
243 | - FSL_IMX7_USBMISCn_SIZE = 0x200, | ||
244 | + /* AIPS-2 Begin */ | ||
245 | |||
246 | - FSL_IMX7_USDHC1_ADDR = 0x30B40000, | ||
247 | - FSL_IMX7_USDHC2_ADDR = 0x30B50000, | ||
248 | - FSL_IMX7_USDHC3_ADDR = 0x30B60000, | ||
249 | + FSL_IMX7_AXI_DEBUG_MON_ADDR = 0x307E0000, | ||
250 | + FSL_IMX7_AXI_DEBUG_MON_SIZE = (64 * KiB), | ||
251 | |||
252 | - FSL_IMX7_SDMA_ADDR = 0x30BD0000, | ||
253 | - FSL_IMX7_SDMA_SIZE = 0x1000, | ||
254 | + FSL_IMX7_PERFMON2_ADDR = 0x307D0000, | ||
255 | + FSL_IMX7_PERFMON1_ADDR = 0x307C0000, | ||
256 | + FSL_IMX7_PERFMONn_SIZE = (64 * KiB), | ||
257 | + | ||
258 | + FSL_IMX7_DDRC_ADDR = 0x307A0000, | ||
259 | + FSL_IMX7_DDRC_SIZE = (4 * KiB), | ||
260 | + | ||
261 | + FSL_IMX7_DDRC_PHY_ADDR = 0x30790000, | ||
262 | + FSL_IMX7_DDRC_PHY_SIZE = (4 * KiB), | ||
263 | + | ||
264 | + FSL_IMX7_TZASC_ADDR = 0x30780000, | ||
265 | + FSL_IMX7_TZASC_SIZE = (64 * KiB), | ||
266 | + | ||
267 | + FSL_IMX7_MIPI_DSI_ADDR = 0x30760000, | ||
268 | + FSL_IMX7_MIPI_DSI_SIZE = (4 * KiB), | ||
269 | + | ||
270 | + FSL_IMX7_MIPI_CSI_ADDR = 0x30750000, | ||
271 | + FSL_IMX7_MIPI_CSI_SIZE = 0x4000, | ||
272 | + | ||
273 | + FSL_IMX7_LCDIF_ADDR = 0x30730000, | ||
274 | + FSL_IMX7_LCDIF_SIZE = 0x8000, | ||
275 | + | ||
276 | + FSL_IMX7_CSI_ADDR = 0x30710000, | ||
277 | + FSL_IMX7_CSI_SIZE = (4 * KiB), | ||
278 | + | ||
279 | + FSL_IMX7_PXP_ADDR = 0x30700000, | ||
280 | + FSL_IMX7_PXP_SIZE = 0x4000, | ||
281 | + | ||
282 | + FSL_IMX7_EPDC_ADDR = 0x306F0000, | ||
283 | + FSL_IMX7_EPDC_SIZE = (4 * KiB), | ||
284 | + | ||
285 | + FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000, | ||
286 | + FSL_IMX7_PCIE_PHY_SIZE = (4 * KiB), | ||
287 | + | ||
288 | + FSL_IMX7_SYSCNT_CTRL_ADDR = 0x306C0000, | ||
289 | + FSL_IMX7_SYSCNT_CMP_ADDR = 0x306B0000, | ||
290 | + FSL_IMX7_SYSCNT_RD_ADDR = 0x306A0000, | ||
291 | + | ||
292 | + FSL_IMX7_PWM4_ADDR = 0x30690000, | ||
293 | + FSL_IMX7_PWM3_ADDR = 0x30680000, | ||
294 | + FSL_IMX7_PWM2_ADDR = 0x30670000, | ||
295 | + FSL_IMX7_PWM1_ADDR = 0x30660000, | ||
296 | + FSL_IMX7_PWMn_SIZE = (4 * KiB), | ||
297 | + | ||
298 | + FSL_IMX7_FlEXTIMER2_ADDR = 0x30650000, | ||
299 | + FSL_IMX7_FlEXTIMER1_ADDR = 0x30640000, | ||
300 | + FSL_IMX7_FLEXTIMERn_SIZE = (4 * KiB), | ||
301 | + | ||
302 | + FSL_IMX7_ECSPI4_ADDR = 0x30630000, | ||
303 | + | ||
304 | + FSL_IMX7_ADC2_ADDR = 0x30620000, | ||
305 | + FSL_IMX7_ADC1_ADDR = 0x30610000, | ||
306 | + FSL_IMX7_ADCn_SIZE = (4 * KiB), | ||
307 | + | ||
308 | + FSL_IMX7_AIPS2_CONF_ADDR = 0x305F0000, | ||
309 | + FSL_IMX7_AIPS2_CONF_SIZE = (64 * KiB), | ||
310 | + | ||
311 | + /* AIPS-2 End */ | ||
312 | + | ||
313 | + /* AIPS-1 Begin */ | ||
314 | + | ||
315 | + FSL_IMX7_CSU_ADDR = 0x303E0000, | ||
316 | + FSL_IMX7_CSU_SIZE = (64 * KiB), | ||
317 | + | ||
318 | + FSL_IMX7_RDC_ADDR = 0x303D0000, | ||
319 | + FSL_IMX7_RDC_SIZE = (4 * KiB), | ||
320 | + | ||
321 | + FSL_IMX7_SEMAPHORE2_ADDR = 0x303C0000, | ||
322 | + FSL_IMX7_SEMAPHORE1_ADDR = 0x303B0000, | ||
323 | + FSL_IMX7_SEMAPHOREn_SIZE = (4 * KiB), | ||
324 | + | ||
325 | + FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
326 | + | ||
327 | + FSL_IMX7_SRC_ADDR = 0x30390000, | ||
328 | + FSL_IMX7_SRC_SIZE = (4 * KiB), | ||
329 | + | ||
330 | + FSL_IMX7_CCM_ADDR = 0x30380000, | ||
331 | + | ||
332 | + FSL_IMX7_SNVS_HP_ADDR = 0x30370000, | ||
333 | + | ||
334 | + FSL_IMX7_ANALOG_ADDR = 0x30360000, | ||
335 | + | ||
336 | + FSL_IMX7_OCOTP_ADDR = 0x30350000, | ||
337 | + FSL_IMX7_OCOTP_SIZE = 0x10000, | ||
338 | + | ||
339 | + FSL_IMX7_IOMUXC_GPR_ADDR = 0x30340000, | ||
340 | + FSL_IMX7_IOMUXC_GPR_SIZE = (4 * KiB), | ||
341 | + | ||
342 | + FSL_IMX7_IOMUXC_ADDR = 0x30330000, | ||
343 | + FSL_IMX7_IOMUXC_SIZE = (4 * KiB), | ||
344 | + | ||
345 | + FSL_IMX7_KPP_ADDR = 0x30320000, | ||
346 | + FSL_IMX7_KPP_SIZE = (4 * KiB), | ||
347 | + | ||
348 | + FSL_IMX7_ROMCP_ADDR = 0x30310000, | ||
349 | + FSL_IMX7_ROMCP_SIZE = (4 * KiB), | ||
350 | + | ||
351 | + FSL_IMX7_GPT4_ADDR = 0x30300000, | ||
352 | + FSL_IMX7_GPT3_ADDR = 0x302F0000, | ||
353 | + FSL_IMX7_GPT2_ADDR = 0x302E0000, | ||
354 | + FSL_IMX7_GPT1_ADDR = 0x302D0000, | ||
355 | + | ||
356 | + FSL_IMX7_IOMUXC_LPSR_ADDR = 0x302C0000, | ||
357 | + FSL_IMX7_IOMUXC_LPSR_SIZE = (4 * KiB), | ||
358 | + | ||
359 | + FSL_IMX7_WDOG4_ADDR = 0x302B0000, | ||
360 | + FSL_IMX7_WDOG3_ADDR = 0x302A0000, | ||
361 | + FSL_IMX7_WDOG2_ADDR = 0x30290000, | ||
362 | + FSL_IMX7_WDOG1_ADDR = 0x30280000, | ||
363 | + | ||
364 | + FSL_IMX7_IOMUXC_LPSR_GPR_ADDR = 0x30270000, | ||
365 | + | ||
366 | + FSL_IMX7_GPIO7_ADDR = 0x30260000, | ||
367 | + FSL_IMX7_GPIO6_ADDR = 0x30250000, | ||
368 | + FSL_IMX7_GPIO5_ADDR = 0x30240000, | ||
369 | + FSL_IMX7_GPIO4_ADDR = 0x30230000, | ||
370 | + FSL_IMX7_GPIO3_ADDR = 0x30220000, | ||
371 | + FSL_IMX7_GPIO2_ADDR = 0x30210000, | ||
372 | + FSL_IMX7_GPIO1_ADDR = 0x30200000, | ||
373 | + | ||
374 | + FSL_IMX7_AIPS1_CONF_ADDR = 0x301F0000, | ||
375 | + FSL_IMX7_AIPS1_CONF_SIZE = (64 * KiB), | ||
376 | |||
377 | - FSL_IMX7_A7MPCORE_ADDR = 0x31000000, | ||
378 | FSL_IMX7_A7MPCORE_DAP_ADDR = 0x30000000, | ||
379 | + FSL_IMX7_A7MPCORE_DAP_SIZE = (1 * MiB), | ||
380 | |||
381 | - FSL_IMX7_PCIE_REG_ADDR = 0x33800000, | ||
382 | - FSL_IMX7_PCIE_REG_SIZE = 16 * 1024, | ||
383 | + /* AIPS-1 End */ | ||
384 | |||
385 | - FSL_IMX7_GPR_ADDR = 0x30340000, | ||
386 | + FSL_IMX7_EIM_CS0_ADDR = 0x28000000, | ||
387 | + FSL_IMX7_EIM_CS0_SIZE = (128 * MiB), | ||
388 | |||
389 | - FSL_IMX7_DMA_APBH_ADDR = 0x33000000, | ||
390 | - FSL_IMX7_DMA_APBH_SIZE = 0x2000, | ||
391 | + FSL_IMX7_OCRAM_PXP_ADDR = 0x00940000, | ||
392 | + FSL_IMX7_OCRAM_PXP_SIZE = (32 * KiB), | ||
393 | + | ||
394 | + FSL_IMX7_OCRAM_EPDC_ADDR = 0x00920000, | ||
395 | + FSL_IMX7_OCRAM_EPDC_SIZE = (128 * KiB), | ||
396 | + | ||
397 | + FSL_IMX7_OCRAM_MEM_ADDR = 0x00900000, | ||
398 | + FSL_IMX7_OCRAM_MEM_SIZE = (128 * KiB), | ||
399 | + | ||
400 | + FSL_IMX7_TCMU_ADDR = 0x00800000, | ||
401 | + FSL_IMX7_TCMU_SIZE = (32 * KiB), | ||
402 | + | ||
403 | + FSL_IMX7_TCML_ADDR = 0x007F8000, | ||
404 | + FSL_IMX7_TCML_SIZE = (32 * KiB), | ||
405 | + | ||
406 | + FSL_IMX7_OCRAM_S_ADDR = 0x00180000, | ||
407 | + FSL_IMX7_OCRAM_S_SIZE = (32 * KiB), | ||
408 | + | ||
409 | + FSL_IMX7_CAAM_MEM_ADDR = 0x00100000, | ||
410 | + FSL_IMX7_CAAM_MEM_SIZE = (32 * KiB), | ||
411 | + | ||
412 | + FSL_IMX7_ROM_ADDR = 0x00000000, | ||
413 | + FSL_IMX7_ROM_SIZE = (96 * KiB), | ||
414 | }; | ||
415 | |||
416 | enum FslIMX7IRQs { | ||
417 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
418 | index XXXXXXX..XXXXXXX 100644 | ||
419 | --- a/hw/arm/fsl-imx7.c | ||
420 | +++ b/hw/arm/fsl-imx7.c | ||
421 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
422 | char name[NAME_SIZE]; | ||
423 | int i; | ||
424 | |||
425 | + /* | ||
426 | + * CPUs | ||
427 | + */ | ||
428 | for (i = 0; i < MIN(ms->smp.cpus, FSL_IMX7_NUM_CPUS); i++) { | ||
429 | snprintf(name, NAME_SIZE, "cpu%d", i); | ||
430 | object_initialize_child(obj, name, &s->cpu[i], | ||
431 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
432 | TYPE_A15MPCORE_PRIV); | ||
433 | |||
434 | /* | ||
435 | - * GPIOs 1 to 7 | ||
436 | + * GPIOs | ||
437 | */ | ||
438 | for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) { | ||
439 | snprintf(name, NAME_SIZE, "gpio%d", i); | ||
440 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
441 | } | ||
442 | |||
443 | /* | ||
444 | - * GPT1, 2, 3, 4 | ||
445 | + * GPTs | ||
446 | */ | ||
447 | for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) { | ||
448 | snprintf(name, NAME_SIZE, "gpt%d", i); | ||
449 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
450 | */ | ||
451 | object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2); | ||
452 | |||
453 | + /* | ||
454 | + * ECSPIs | ||
455 | + */ | ||
456 | for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) { | ||
457 | snprintf(name, NAME_SIZE, "spi%d", i + 1); | ||
458 | object_initialize_child(obj, name, &s->spi[i], TYPE_IMX_SPI); | ||
459 | } | ||
460 | |||
461 | - | ||
462 | + /* | ||
463 | + * I2Cs | ||
464 | + */ | ||
465 | for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) { | ||
466 | snprintf(name, NAME_SIZE, "i2c%d", i + 1); | ||
467 | object_initialize_child(obj, name, &s->i2c[i], TYPE_IMX_I2C); | ||
468 | } | ||
469 | |||
470 | /* | ||
471 | - * UART | ||
472 | + * UARTs | ||
473 | */ | ||
474 | for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) { | ||
475 | snprintf(name, NAME_SIZE, "uart%d", i); | ||
476 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
477 | } | ||
478 | |||
479 | /* | ||
480 | - * Ethernet | ||
481 | + * Ethernets | ||
482 | */ | ||
483 | for (i = 0; i < FSL_IMX7_NUM_ETHS; i++) { | ||
484 | snprintf(name, NAME_SIZE, "eth%d", i); | ||
485 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
486 | } | ||
487 | |||
488 | /* | ||
489 | - * SDHCI | ||
490 | + * SDHCIs | ||
491 | */ | ||
492 | for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) { | ||
493 | snprintf(name, NAME_SIZE, "usdhc%d", i); | ||
494 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
495 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); | ||
496 | |||
497 | /* | ||
498 | - * Watchdog | ||
499 | + * Watchdogs | ||
500 | */ | ||
501 | for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) { | ||
502 | snprintf(name, NAME_SIZE, "wdt%d", i); | ||
503 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
504 | */ | ||
505 | object_initialize_child(obj, "gpr", &s->gpr, TYPE_IMX7_GPR); | ||
506 | |||
507 | + /* | ||
508 | + * PCIE | ||
509 | + */ | ||
510 | object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HOST); | ||
511 | |||
512 | + /* | ||
513 | + * USBs | ||
514 | + */ | ||
515 | for (i = 0; i < FSL_IMX7_NUM_USBS; i++) { | ||
516 | snprintf(name, NAME_SIZE, "usb%d", i); | ||
517 | object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA); | ||
518 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
30 | return; | 519 | return; |
31 | } | 520 | } |
32 | 521 | ||
33 | + /* Invert P0 bits if needed, but only for beats we actually executed */ | 522 | + /* |
34 | mask01 = FIELD_EX32(vpr, V7M_VPR, MASK01); | 523 | + * CPUs |
35 | mask23 = FIELD_EX32(vpr, V7M_VPR, MASK23); | 524 | + */ |
36 | - if (mask01 > 8) { | 525 | for (i = 0; i < smp_cpus; i++) { |
37 | - /* high bit set, but not 0b1000: invert the relevant half of P0 */ | 526 | o = OBJECT(&s->cpu[i]); |
38 | - vpr ^= 0xff; | 527 | |
39 | + /* Start by assuming we invert all bits corresponding to executed beats */ | 528 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
40 | + inv_mask = eci_mask; | 529 | * A7MPCORE DAP |
41 | + if (mask01 <= 8) { | 530 | */ |
42 | + /* MASK01 says don't invert low half of P0 */ | 531 | create_unimplemented_device("a7mpcore-dap", FSL_IMX7_A7MPCORE_DAP_ADDR, |
43 | + inv_mask &= ~0xff; | 532 | - 0x100000); |
44 | } | 533 | + FSL_IMX7_A7MPCORE_DAP_SIZE); |
45 | - if (mask23 > 8) { | 534 | |
46 | - /* high bit set, but not 0b1000: invert the relevant half of P0 */ | 535 | /* |
47 | - vpr ^= 0xff00; | 536 | - * GPT1, 2, 3, 4 |
48 | + if (mask23 <= 8) { | 537 | + * GPTs |
49 | + /* MASK23 says don't invert high half of P0 */ | 538 | */ |
50 | + inv_mask &= ~0xff00; | 539 | for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) { |
51 | } | 540 | static const hwaddr FSL_IMX7_GPTn_ADDR[FSL_IMX7_NUM_GPTS] = { |
52 | - vpr = FIELD_DP32(vpr, V7M_VPR, MASK01, mask01 << 1); | 541 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
53 | + vpr ^= inv_mask; | 542 | FSL_IMX7_GPTn_IRQ[i])); |
54 | + /* Only update MASK01 if beat 1 executed */ | 543 | } |
55 | + if (eci_mask & 0xf0) { | 544 | |
56 | + vpr = FIELD_DP32(vpr, V7M_VPR, MASK01, mask01 << 1); | 545 | + /* |
546 | + * GPIOs | ||
547 | + */ | ||
548 | for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) { | ||
549 | static const hwaddr FSL_IMX7_GPIOn_ADDR[FSL_IMX7_NUM_GPIOS] = { | ||
550 | FSL_IMX7_GPIO1_ADDR, | ||
551 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
552 | /* | ||
553 | * IOMUXC and IOMUXC_LPSR | ||
554 | */ | ||
555 | - for (i = 0; i < FSL_IMX7_NUM_IOMUXCS; i++) { | ||
556 | - static const hwaddr FSL_IMX7_IOMUXCn_ADDR[FSL_IMX7_NUM_IOMUXCS] = { | ||
557 | - FSL_IMX7_IOMUXC_ADDR, | ||
558 | - FSL_IMX7_IOMUXC_LPSR_ADDR, | ||
559 | - }; | ||
560 | - | ||
561 | - snprintf(name, NAME_SIZE, "iomuxc%d", i); | ||
562 | - create_unimplemented_device(name, FSL_IMX7_IOMUXCn_ADDR[i], | ||
563 | - FSL_IMX7_IOMUXCn_SIZE); | ||
564 | - } | ||
565 | + create_unimplemented_device("iomuxc", FSL_IMX7_IOMUXC_ADDR, | ||
566 | + FSL_IMX7_IOMUXC_SIZE); | ||
567 | + create_unimplemented_device("iomuxc_lspr", FSL_IMX7_IOMUXC_LPSR_ADDR, | ||
568 | + FSL_IMX7_IOMUXC_LPSR_SIZE); | ||
569 | |||
570 | /* | ||
571 | * CCM | ||
572 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
573 | sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort); | ||
574 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX7_GPC_ADDR); | ||
575 | |||
576 | - /* Initialize all ECSPI */ | ||
577 | + /* | ||
578 | + * ECSPIs | ||
579 | + */ | ||
580 | for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) { | ||
581 | static const hwaddr FSL_IMX7_SPIn_ADDR[FSL_IMX7_NUM_ECSPIS] = { | ||
582 | FSL_IMX7_ECSPI1_ADDR, | ||
583 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
584 | FSL_IMX7_SPIn_IRQ[i])); | ||
585 | } | ||
586 | |||
587 | + /* | ||
588 | + * I2Cs | ||
589 | + */ | ||
590 | for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) { | ||
591 | static const hwaddr FSL_IMX7_I2Cn_ADDR[FSL_IMX7_NUM_I2CS] = { | ||
592 | FSL_IMX7_I2C1_ADDR, | ||
593 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
594 | } | ||
595 | |||
596 | /* | ||
597 | - * UART | ||
598 | + * UARTs | ||
599 | */ | ||
600 | for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) { | ||
601 | static const hwaddr FSL_IMX7_UARTn_ADDR[FSL_IMX7_NUM_UARTS] = { | ||
602 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
603 | } | ||
604 | |||
605 | /* | ||
606 | - * Ethernet | ||
607 | + * Ethernets | ||
608 | * | ||
609 | * We must use two loops since phy_connected affects the other interface | ||
610 | * and we have to set all properties before calling sysbus_realize(). | ||
611 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
612 | } | ||
613 | |||
614 | /* | ||
615 | - * USDHC | ||
616 | + * USDHCs | ||
617 | */ | ||
618 | for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) { | ||
619 | static const hwaddr FSL_IMX7_USDHCn_ADDR[FSL_IMX7_NUM_USDHCS] = { | ||
620 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
621 | * SNVS | ||
622 | */ | ||
623 | sysbus_realize(SYS_BUS_DEVICE(&s->snvs), &error_abort); | ||
624 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX7_SNVS_ADDR); | ||
625 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX7_SNVS_HP_ADDR); | ||
626 | |||
627 | /* | ||
628 | * SRC | ||
629 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
630 | create_unimplemented_device("src", FSL_IMX7_SRC_ADDR, FSL_IMX7_SRC_SIZE); | ||
631 | |||
632 | /* | ||
633 | - * Watchdog | ||
634 | + * Watchdogs | ||
635 | */ | ||
636 | for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) { | ||
637 | static const hwaddr FSL_IMX7_WDOGn_ADDR[FSL_IMX7_NUM_WDTS] = { | ||
638 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
639 | create_unimplemented_device("caam", FSL_IMX7_CAAM_ADDR, FSL_IMX7_CAAM_SIZE); | ||
640 | |||
641 | /* | ||
642 | - * PWM | ||
643 | + * PWMs | ||
644 | */ | ||
645 | - create_unimplemented_device("pwm1", FSL_IMX7_PWM1_ADDR, FSL_IMX7_PWMn_SIZE); | ||
646 | - create_unimplemented_device("pwm2", FSL_IMX7_PWM2_ADDR, FSL_IMX7_PWMn_SIZE); | ||
647 | - create_unimplemented_device("pwm3", FSL_IMX7_PWM3_ADDR, FSL_IMX7_PWMn_SIZE); | ||
648 | - create_unimplemented_device("pwm4", FSL_IMX7_PWM4_ADDR, FSL_IMX7_PWMn_SIZE); | ||
649 | + for (i = 0; i < FSL_IMX7_NUM_PWMS; i++) { | ||
650 | + static const hwaddr FSL_IMX7_PWMn_ADDR[FSL_IMX7_NUM_PWMS] = { | ||
651 | + FSL_IMX7_PWM1_ADDR, | ||
652 | + FSL_IMX7_PWM2_ADDR, | ||
653 | + FSL_IMX7_PWM3_ADDR, | ||
654 | + FSL_IMX7_PWM4_ADDR, | ||
655 | + }; | ||
656 | + | ||
657 | + snprintf(name, NAME_SIZE, "pwm%d", i); | ||
658 | + create_unimplemented_device(name, FSL_IMX7_PWMn_ADDR[i], | ||
659 | + FSL_IMX7_PWMn_SIZE); | ||
57 | + } | 660 | + } |
58 | + /* Beat 3 always executes, so update MASK23 */ | 661 | |
59 | vpr = FIELD_DP32(vpr, V7M_VPR, MASK23, mask23 << 1); | 662 | /* |
60 | env->v7m.vpr = vpr; | 663 | - * CAN |
664 | + * CANs | ||
665 | */ | ||
666 | - create_unimplemented_device("can1", FSL_IMX7_CAN1_ADDR, FSL_IMX7_CANn_SIZE); | ||
667 | - create_unimplemented_device("can2", FSL_IMX7_CAN2_ADDR, FSL_IMX7_CANn_SIZE); | ||
668 | + for (i = 0; i < FSL_IMX7_NUM_CANS; i++) { | ||
669 | + static const hwaddr FSL_IMX7_CANn_ADDR[FSL_IMX7_NUM_CANS] = { | ||
670 | + FSL_IMX7_CAN1_ADDR, | ||
671 | + FSL_IMX7_CAN2_ADDR, | ||
672 | + }; | ||
673 | + | ||
674 | + snprintf(name, NAME_SIZE, "can%d", i); | ||
675 | + create_unimplemented_device(name, FSL_IMX7_CANn_ADDR[i], | ||
676 | + FSL_IMX7_CANn_SIZE); | ||
677 | + } | ||
678 | |||
679 | /* | ||
680 | - * SAI (Audio SSI (Synchronous Serial Interface)) | ||
681 | + * SAIs (Audio SSI (Synchronous Serial Interface)) | ||
682 | */ | ||
683 | - create_unimplemented_device("sai1", FSL_IMX7_SAI1_ADDR, FSL_IMX7_SAIn_SIZE); | ||
684 | - create_unimplemented_device("sai2", FSL_IMX7_SAI2_ADDR, FSL_IMX7_SAIn_SIZE); | ||
685 | - create_unimplemented_device("sai2", FSL_IMX7_SAI3_ADDR, FSL_IMX7_SAIn_SIZE); | ||
686 | + for (i = 0; i < FSL_IMX7_NUM_SAIS; i++) { | ||
687 | + static const hwaddr FSL_IMX7_SAIn_ADDR[FSL_IMX7_NUM_SAIS] = { | ||
688 | + FSL_IMX7_SAI1_ADDR, | ||
689 | + FSL_IMX7_SAI2_ADDR, | ||
690 | + FSL_IMX7_SAI3_ADDR, | ||
691 | + }; | ||
692 | + | ||
693 | + snprintf(name, NAME_SIZE, "sai%d", i); | ||
694 | + create_unimplemented_device(name, FSL_IMX7_SAIn_ADDR[i], | ||
695 | + FSL_IMX7_SAIn_SIZE); | ||
696 | + } | ||
697 | |||
698 | /* | ||
699 | * OCOTP | ||
700 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
701 | create_unimplemented_device("ocotp", FSL_IMX7_OCOTP_ADDR, | ||
702 | FSL_IMX7_OCOTP_SIZE); | ||
703 | |||
704 | + /* | ||
705 | + * GPR | ||
706 | + */ | ||
707 | sysbus_realize(SYS_BUS_DEVICE(&s->gpr), &error_abort); | ||
708 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX7_GPR_ADDR); | ||
709 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX7_IOMUXC_GPR_ADDR); | ||
710 | |||
711 | + /* | ||
712 | + * PCIE | ||
713 | + */ | ||
714 | sysbus_realize(SYS_BUS_DEVICE(&s->pcie), &error_abort); | ||
715 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcie), 0, FSL_IMX7_PCIE_REG_ADDR); | ||
716 | |||
717 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
718 | irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTD_IRQ); | ||
719 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 3, irq); | ||
720 | |||
721 | - | ||
722 | + /* | ||
723 | + * USBs | ||
724 | + */ | ||
725 | for (i = 0; i < FSL_IMX7_NUM_USBS; i++) { | ||
726 | static const hwaddr FSL_IMX7_USBMISCn_ADDR[FSL_IMX7_NUM_USBS] = { | ||
727 | FSL_IMX7_USBMISC1_ADDR, | ||
728 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
729 | */ | ||
730 | create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR, | ||
731 | FSL_IMX7_PCIE_PHY_SIZE); | ||
732 | + | ||
61 | } | 733 | } |
734 | |||
735 | static Property fsl_imx7_properties[] = { | ||
62 | -- | 736 | -- |
63 | 2.20.1 | 737 | 2.34.1 |
64 | |||
65 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Instantiate SAI1/2/3 as unimplemented devices to avoid Linux kernel crashes | 3 | * Add TZASC as unimplemented device. |
4 | such as the following. | 4 | - Allow bare metal application to access this (unimplemented) device |
5 | * Add CSU as unimplemented device. | ||
6 | - Allow bare metal application to access this (unimplemented) device | ||
7 | * Add various memory segments | ||
8 | - OCRAM | ||
9 | - OCRAM EPDC | ||
10 | - OCRAM PXP | ||
11 | - OCRAM S | ||
12 | - ROM | ||
13 | - CAAM | ||
5 | 14 | ||
6 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd19b0000 | 15 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
7 | pgd = (ptrval) | 16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | [d19b0000] *pgd=82711811, *pte=308a0653, *ppte=308a0453 | 17 | Message-id: f887a3483996ba06d40bd62ffdfb0ecf68621987.1692964892.git.jcd@tribudubois.net |
9 | Internal error: : 808 [#1] SMP ARM | ||
10 | Modules linked in: | ||
11 | CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.14.0-rc5 #1 | ||
12 | ... | ||
13 | [<c095e974>] (regmap_mmio_write32le) from [<c095eb48>] (regmap_mmio_write+0x3c/0x54) | ||
14 | [<c095eb48>] (regmap_mmio_write) from [<c09580f4>] (_regmap_write+0x4c/0x1f0) | ||
15 | [<c09580f4>] (_regmap_write) from [<c0959b28>] (regmap_write+0x3c/0x60) | ||
16 | [<c0959b28>] (regmap_write) from [<c0d41130>] (fsl_sai_runtime_resume+0x9c/0x1ec) | ||
17 | [<c0d41130>] (fsl_sai_runtime_resume) from [<c0942464>] (__rpm_callback+0x3c/0x108) | ||
18 | [<c0942464>] (__rpm_callback) from [<c0942590>] (rpm_callback+0x60/0x64) | ||
19 | [<c0942590>] (rpm_callback) from [<c0942b60>] (rpm_resume+0x5cc/0x808) | ||
20 | [<c0942b60>] (rpm_resume) from [<c0942dfc>] (__pm_runtime_resume+0x60/0xa0) | ||
21 | [<c0942dfc>] (__pm_runtime_resume) from [<c0d4231c>] (fsl_sai_probe+0x2b8/0x65c) | ||
22 | [<c0d4231c>] (fsl_sai_probe) from [<c0935b08>] (platform_probe+0x58/0xb8) | ||
23 | [<c0935b08>] (platform_probe) from [<c0933264>] (really_probe.part.0+0x9c/0x334) | ||
24 | [<c0933264>] (really_probe.part.0) from [<c093359c>] (__driver_probe_device+0xa0/0x138) | ||
25 | [<c093359c>] (__driver_probe_device) from [<c0933664>] (driver_probe_device+0x30/0xc8) | ||
26 | [<c0933664>] (driver_probe_device) from [<c0933c88>] (__driver_attach+0x90/0x130) | ||
27 | [<c0933c88>] (__driver_attach) from [<c0931060>] (bus_for_each_dev+0x78/0xb8) | ||
28 | [<c0931060>] (bus_for_each_dev) from [<c093254c>] (bus_add_driver+0xf0/0x1d8) | ||
29 | [<c093254c>] (bus_add_driver) from [<c0934a30>] (driver_register+0x88/0x118) | ||
30 | [<c0934a30>] (driver_register) from [<c01022c0>] (do_one_initcall+0x7c/0x3a4) | ||
31 | [<c01022c0>] (do_one_initcall) from [<c1601204>] (kernel_init_freeable+0x198/0x22c) | ||
32 | [<c1601204>] (kernel_init_freeable) from [<c0f5ff2c>] (kernel_init+0x10/0x128) | ||
33 | [<c0f5ff2c>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38) | ||
34 | |||
35 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
36 | Message-id: 20210810175607.538090-1-linux@roeck-us.net | ||
37 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
38 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
39 | --- | 19 | --- |
40 | include/hw/arm/fsl-imx7.h | 5 +++++ | 20 | include/hw/arm/fsl-imx7.h | 7 +++++ |
41 | hw/arm/fsl-imx7.c | 7 +++++++ | 21 | hw/arm/fsl-imx7.c | 63 +++++++++++++++++++++++++++++++++++++++ |
42 | 2 files changed, 12 insertions(+) | 22 | 2 files changed, 70 insertions(+) |
43 | 23 | ||
44 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | 24 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
45 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/include/hw/arm/fsl-imx7.h | 26 | --- a/include/hw/arm/fsl-imx7.h |
47 | +++ b/include/hw/arm/fsl-imx7.h | 27 | +++ b/include/hw/arm/fsl-imx7.h |
48 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | 28 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { |
49 | FSL_IMX7_UART6_ADDR = 0x30A80000, | 29 | IMX7GPRState gpr; |
50 | FSL_IMX7_UART7_ADDR = 0x30A90000, | 30 | ChipideaState usb[FSL_IMX7_NUM_USBS]; |
51 | 31 | DesignwarePCIEHost pcie; | |
52 | + FSL_IMX7_SAI1_ADDR = 0x308A0000, | 32 | + MemoryRegion rom; |
53 | + FSL_IMX7_SAI2_ADDR = 0x308B0000, | 33 | + MemoryRegion caam; |
54 | + FSL_IMX7_SAI3_ADDR = 0x308C0000, | 34 | + MemoryRegion ocram; |
55 | + FSL_IMX7_SAIn_SIZE = 0x10000, | 35 | + MemoryRegion ocram_epdc; |
36 | + MemoryRegion ocram_pxp; | ||
37 | + MemoryRegion ocram_s; | ||
56 | + | 38 | + |
57 | FSL_IMX7_ENET1_ADDR = 0x30BE0000, | 39 | uint32_t phy_num[FSL_IMX7_NUM_ETHS]; |
58 | FSL_IMX7_ENET2_ADDR = 0x30BF0000, | 40 | bool phy_connected[FSL_IMX7_NUM_ETHS]; |
59 | 41 | }; | |
60 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | 42 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c |
61 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
62 | --- a/hw/arm/fsl-imx7.c | 44 | --- a/hw/arm/fsl-imx7.c |
63 | +++ b/hw/arm/fsl-imx7.c | 45 | +++ b/hw/arm/fsl-imx7.c |
64 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | 46 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
65 | create_unimplemented_device("can1", FSL_IMX7_CAN1_ADDR, FSL_IMX7_CANn_SIZE); | 47 | create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR, |
66 | create_unimplemented_device("can2", FSL_IMX7_CAN2_ADDR, FSL_IMX7_CANn_SIZE); | 48 | FSL_IMX7_PCIE_PHY_SIZE); |
67 | 49 | ||
68 | + /* | 50 | + /* |
69 | + * SAI (Audio SSI (Synchronous Serial Interface)) | 51 | + * CSU |
70 | + */ | 52 | + */ |
71 | + create_unimplemented_device("sai1", FSL_IMX7_SAI1_ADDR, FSL_IMX7_SAIn_SIZE); | 53 | + create_unimplemented_device("csu", FSL_IMX7_CSU_ADDR, |
72 | + create_unimplemented_device("sai2", FSL_IMX7_SAI2_ADDR, FSL_IMX7_SAIn_SIZE); | 54 | + FSL_IMX7_CSU_SIZE); |
73 | + create_unimplemented_device("sai2", FSL_IMX7_SAI3_ADDR, FSL_IMX7_SAIn_SIZE); | ||
74 | + | 55 | + |
75 | /* | 56 | + /* |
76 | * OCOTP | 57 | + * TZASC |
77 | */ | 58 | + */ |
59 | + create_unimplemented_device("tzasc", FSL_IMX7_TZASC_ADDR, | ||
60 | + FSL_IMX7_TZASC_SIZE); | ||
61 | + | ||
62 | + /* | ||
63 | + * OCRAM memory | ||
64 | + */ | ||
65 | + memory_region_init_ram(&s->ocram, NULL, "imx7.ocram", | ||
66 | + FSL_IMX7_OCRAM_MEM_SIZE, | ||
67 | + &error_abort); | ||
68 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_MEM_ADDR, | ||
69 | + &s->ocram); | ||
70 | + | ||
71 | + /* | ||
72 | + * OCRAM EPDC memory | ||
73 | + */ | ||
74 | + memory_region_init_ram(&s->ocram_epdc, NULL, "imx7.ocram_epdc", | ||
75 | + FSL_IMX7_OCRAM_EPDC_SIZE, | ||
76 | + &error_abort); | ||
77 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_EPDC_ADDR, | ||
78 | + &s->ocram_epdc); | ||
79 | + | ||
80 | + /* | ||
81 | + * OCRAM PXP memory | ||
82 | + */ | ||
83 | + memory_region_init_ram(&s->ocram_pxp, NULL, "imx7.ocram_pxp", | ||
84 | + FSL_IMX7_OCRAM_PXP_SIZE, | ||
85 | + &error_abort); | ||
86 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_PXP_ADDR, | ||
87 | + &s->ocram_pxp); | ||
88 | + | ||
89 | + /* | ||
90 | + * OCRAM_S memory | ||
91 | + */ | ||
92 | + memory_region_init_ram(&s->ocram_s, NULL, "imx7.ocram_s", | ||
93 | + FSL_IMX7_OCRAM_S_SIZE, | ||
94 | + &error_abort); | ||
95 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_S_ADDR, | ||
96 | + &s->ocram_s); | ||
97 | + | ||
98 | + /* | ||
99 | + * ROM memory | ||
100 | + */ | ||
101 | + memory_region_init_rom(&s->rom, OBJECT(dev), "imx7.rom", | ||
102 | + FSL_IMX7_ROM_SIZE, &error_abort); | ||
103 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_ROM_ADDR, | ||
104 | + &s->rom); | ||
105 | + | ||
106 | + /* | ||
107 | + * CAAM memory | ||
108 | + */ | ||
109 | + memory_region_init_rom(&s->caam, OBJECT(dev), "imx7.caam", | ||
110 | + FSL_IMX7_CAAM_MEM_SIZE, &error_abort); | ||
111 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_CAAM_MEM_ADDR, | ||
112 | + &s->caam); | ||
113 | } | ||
114 | |||
115 | static Property fsl_imx7_properties[] = { | ||
78 | -- | 116 | -- |
79 | 2.20.1 | 117 | 2.34.1 |
80 | 118 | ||
81 | 119 | diff view generated by jsdifflib |
1 | In some situations we need a mask telling us which parts of the | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | vector correspond to beats that are not being executed because of | 2 | |
3 | ECI, separately from the combined "which bytes are predicated away" | 3 | The SRC device is normally used to start the secondary CPU. |
4 | mask. Factor this mask calculation out of mve_element_mask() into | 4 | |
5 | its own function. | 5 | When running Linux directly, QEMU is emulating a PSCI interface that UBOOT |
6 | 6 | is installing at boot time and therefore the fact that the SRC device is | |
7 | unimplemented is hidden as Qemu respond directly to PSCI requets without | ||
8 | using the SRC device. | ||
9 | |||
10 | But if you try to run a more bare metal application (maybe uboot itself), | ||
11 | then it is not possible to start the secondary CPU as the SRC is an | ||
12 | unimplemented device. | ||
13 | |||
14 | This patch adds the ability to start the secondary CPU through the SRC | ||
15 | device so that you can use this feature in bare metal applications. | ||
16 | |||
17 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Message-id: ce9a0162defd2acee5dc7f8a674743de0cded569.1692964892.git.jcd@tribudubois.net | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | 21 | --- |
10 | target/arm/mve_helper.c | 58 ++++++++++++++++++++++++----------------- | 22 | include/hw/arm/fsl-imx7.h | 3 +- |
11 | 1 file changed, 34 insertions(+), 24 deletions(-) | 23 | include/hw/misc/imx7_src.h | 66 +++++++++ |
12 | 24 | hw/arm/fsl-imx7.c | 8 +- | |
13 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 25 | hw/misc/imx7_src.c | 276 +++++++++++++++++++++++++++++++++++++ |
26 | hw/misc/meson.build | 1 + | ||
27 | hw/misc/trace-events | 4 + | ||
28 | 6 files changed, 356 insertions(+), 2 deletions(-) | ||
29 | create mode 100644 include/hw/misc/imx7_src.h | ||
30 | create mode 100644 hw/misc/imx7_src.c | ||
31 | |||
32 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/mve_helper.c | 34 | --- a/include/hw/arm/fsl-imx7.h |
16 | +++ b/target/arm/mve_helper.c | 35 | +++ b/include/hw/arm/fsl-imx7.h |
17 | @@ -XXX,XX +XXX,XX @@ | 36 | @@ -XXX,XX +XXX,XX @@ |
18 | #include "exec/exec-all.h" | 37 | #include "hw/misc/imx7_ccm.h" |
19 | #include "tcg/tcg.h" | 38 | #include "hw/misc/imx7_snvs.h" |
20 | 39 | #include "hw/misc/imx7_gpr.h" | |
21 | +static uint16_t mve_eci_mask(CPUARMState *env) | 40 | +#include "hw/misc/imx7_src.h" |
22 | +{ | 41 | #include "hw/watchdog/wdt_imx2.h" |
42 | #include "hw/gpio/imx_gpio.h" | ||
43 | #include "hw/char/imx_serial.h" | ||
44 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { | ||
45 | IMX7CCMState ccm; | ||
46 | IMX7AnalogState analog; | ||
47 | IMX7SNVSState snvs; | ||
48 | + IMX7SRCState src; | ||
49 | IMXGPCv2State gpcv2; | ||
50 | IMXSPIState spi[FSL_IMX7_NUM_ECSPIS]; | ||
51 | IMXI2CState i2c[FSL_IMX7_NUM_I2CS]; | ||
52 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | ||
53 | FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
54 | |||
55 | FSL_IMX7_SRC_ADDR = 0x30390000, | ||
56 | - FSL_IMX7_SRC_SIZE = (4 * KiB), | ||
57 | |||
58 | FSL_IMX7_CCM_ADDR = 0x30380000, | ||
59 | |||
60 | diff --git a/include/hw/misc/imx7_src.h b/include/hw/misc/imx7_src.h | ||
61 | new file mode 100644 | ||
62 | index XXXXXXX..XXXXXXX | ||
63 | --- /dev/null | ||
64 | +++ b/include/hw/misc/imx7_src.h | ||
65 | @@ -XXX,XX +XXX,XX @@ | ||
66 | +/* | ||
67 | + * IMX7 System Reset Controller | ||
68 | + * | ||
69 | + * Copyright (C) 2023 Jean-Christophe Dubois <jcd@tribudubois.net> | ||
70 | + * | ||
71 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
72 | + * See the COPYING file in the top-level directory. | ||
73 | + */ | ||
74 | + | ||
75 | +#ifndef IMX7_SRC_H | ||
76 | +#define IMX7_SRC_H | ||
77 | + | ||
78 | +#include "hw/sysbus.h" | ||
79 | +#include "qemu/bitops.h" | ||
80 | +#include "qom/object.h" | ||
81 | + | ||
82 | +#define SRC_SCR 0 | ||
83 | +#define SRC_A7RCR0 1 | ||
84 | +#define SRC_A7RCR1 2 | ||
85 | +#define SRC_M4RCR 3 | ||
86 | +#define SRC_ERCR 5 | ||
87 | +#define SRC_HSICPHY_RCR 7 | ||
88 | +#define SRC_USBOPHY1_RCR 8 | ||
89 | +#define SRC_USBOPHY2_RCR 9 | ||
90 | +#define SRC_MPIPHY_RCR 10 | ||
91 | +#define SRC_PCIEPHY_RCR 11 | ||
92 | +#define SRC_SBMR1 22 | ||
93 | +#define SRC_SRSR 23 | ||
94 | +#define SRC_SISR 26 | ||
95 | +#define SRC_SIMR 27 | ||
96 | +#define SRC_SBMR2 28 | ||
97 | +#define SRC_GPR1 29 | ||
98 | +#define SRC_GPR2 30 | ||
99 | +#define SRC_GPR3 31 | ||
100 | +#define SRC_GPR4 32 | ||
101 | +#define SRC_GPR5 33 | ||
102 | +#define SRC_GPR6 34 | ||
103 | +#define SRC_GPR7 35 | ||
104 | +#define SRC_GPR8 36 | ||
105 | +#define SRC_GPR9 37 | ||
106 | +#define SRC_GPR10 38 | ||
107 | +#define SRC_MAX 39 | ||
108 | + | ||
109 | +/* SRC_A7SCR1 */ | ||
110 | +#define R_CORE1_ENABLE_SHIFT 1 | ||
111 | +#define R_CORE1_ENABLE_LENGTH 1 | ||
112 | +/* SRC_A7SCR0 */ | ||
113 | +#define R_CORE1_RST_SHIFT 5 | ||
114 | +#define R_CORE1_RST_LENGTH 1 | ||
115 | +#define R_CORE0_RST_SHIFT 4 | ||
116 | +#define R_CORE0_RST_LENGTH 1 | ||
117 | + | ||
118 | +#define TYPE_IMX7_SRC "imx7.src" | ||
119 | +OBJECT_DECLARE_SIMPLE_TYPE(IMX7SRCState, IMX7_SRC) | ||
120 | + | ||
121 | +struct IMX7SRCState { | ||
122 | + /* <private> */ | ||
123 | + SysBusDevice parent_obj; | ||
124 | + | ||
125 | + /* <public> */ | ||
126 | + MemoryRegion iomem; | ||
127 | + | ||
128 | + uint32_t regs[SRC_MAX]; | ||
129 | +}; | ||
130 | + | ||
131 | +#endif /* IMX7_SRC_H */ | ||
132 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
133 | index XXXXXXX..XXXXXXX 100644 | ||
134 | --- a/hw/arm/fsl-imx7.c | ||
135 | +++ b/hw/arm/fsl-imx7.c | ||
136 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
137 | */ | ||
138 | object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2); | ||
139 | |||
23 | + /* | 140 | + /* |
24 | + * Return the mask of which elements in the MVE vector correspond | 141 | + * SRC |
25 | + * to beats being executed. The mask has 1 bits for executed lanes | ||
26 | + * and 0 bits where ECI says this beat was already executed. | ||
27 | + */ | 142 | + */ |
28 | + int eci; | 143 | + object_initialize_child(obj, "src", &s->src, TYPE_IMX7_SRC); |
29 | + | 144 | + |
30 | + if ((env->condexec_bits & 0xf) != 0) { | 145 | /* |
31 | + return 0xffff; | 146 | * ECSPIs |
147 | */ | ||
148 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
149 | /* | ||
150 | * SRC | ||
151 | */ | ||
152 | - create_unimplemented_device("src", FSL_IMX7_SRC_ADDR, FSL_IMX7_SRC_SIZE); | ||
153 | + sysbus_realize(SYS_BUS_DEVICE(&s->src), &error_abort); | ||
154 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->src), 0, FSL_IMX7_SRC_ADDR); | ||
155 | |||
156 | /* | ||
157 | * Watchdogs | ||
158 | diff --git a/hw/misc/imx7_src.c b/hw/misc/imx7_src.c | ||
159 | new file mode 100644 | ||
160 | index XXXXXXX..XXXXXXX | ||
161 | --- /dev/null | ||
162 | +++ b/hw/misc/imx7_src.c | ||
163 | @@ -XXX,XX +XXX,XX @@ | ||
164 | +/* | ||
165 | + * IMX7 System Reset Controller | ||
166 | + * | ||
167 | + * Copyright (c) 2023 Jean-Christophe Dubois <jcd@tribudubois.net> | ||
168 | + * | ||
169 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
170 | + * See the COPYING file in the top-level directory. | ||
171 | + * | ||
172 | + */ | ||
173 | + | ||
174 | +#include "qemu/osdep.h" | ||
175 | +#include "hw/misc/imx7_src.h" | ||
176 | +#include "migration/vmstate.h" | ||
177 | +#include "qemu/bitops.h" | ||
178 | +#include "qemu/log.h" | ||
179 | +#include "qemu/main-loop.h" | ||
180 | +#include "qemu/module.h" | ||
181 | +#include "target/arm/arm-powerctl.h" | ||
182 | +#include "hw/core/cpu.h" | ||
183 | +#include "hw/registerfields.h" | ||
184 | + | ||
185 | +#include "trace.h" | ||
186 | + | ||
187 | +static const char *imx7_src_reg_name(uint32_t reg) | ||
188 | +{ | ||
189 | + static char unknown[20]; | ||
190 | + | ||
191 | + switch (reg) { | ||
192 | + case SRC_SCR: | ||
193 | + return "SRC_SCR"; | ||
194 | + case SRC_A7RCR0: | ||
195 | + return "SRC_A7RCR0"; | ||
196 | + case SRC_A7RCR1: | ||
197 | + return "SRC_A7RCR1"; | ||
198 | + case SRC_M4RCR: | ||
199 | + return "SRC_M4RCR"; | ||
200 | + case SRC_ERCR: | ||
201 | + return "SRC_ERCR"; | ||
202 | + case SRC_HSICPHY_RCR: | ||
203 | + return "SRC_HSICPHY_RCR"; | ||
204 | + case SRC_USBOPHY1_RCR: | ||
205 | + return "SRC_USBOPHY1_RCR"; | ||
206 | + case SRC_USBOPHY2_RCR: | ||
207 | + return "SRC_USBOPHY2_RCR"; | ||
208 | + case SRC_PCIEPHY_RCR: | ||
209 | + return "SRC_PCIEPHY_RCR"; | ||
210 | + case SRC_SBMR1: | ||
211 | + return "SRC_SBMR1"; | ||
212 | + case SRC_SRSR: | ||
213 | + return "SRC_SRSR"; | ||
214 | + case SRC_SISR: | ||
215 | + return "SRC_SISR"; | ||
216 | + case SRC_SIMR: | ||
217 | + return "SRC_SIMR"; | ||
218 | + case SRC_SBMR2: | ||
219 | + return "SRC_SBMR2"; | ||
220 | + case SRC_GPR1: | ||
221 | + return "SRC_GPR1"; | ||
222 | + case SRC_GPR2: | ||
223 | + return "SRC_GPR2"; | ||
224 | + case SRC_GPR3: | ||
225 | + return "SRC_GPR3"; | ||
226 | + case SRC_GPR4: | ||
227 | + return "SRC_GPR4"; | ||
228 | + case SRC_GPR5: | ||
229 | + return "SRC_GPR5"; | ||
230 | + case SRC_GPR6: | ||
231 | + return "SRC_GPR6"; | ||
232 | + case SRC_GPR7: | ||
233 | + return "SRC_GPR7"; | ||
234 | + case SRC_GPR8: | ||
235 | + return "SRC_GPR8"; | ||
236 | + case SRC_GPR9: | ||
237 | + return "SRC_GPR9"; | ||
238 | + case SRC_GPR10: | ||
239 | + return "SRC_GPR10"; | ||
240 | + default: | ||
241 | + sprintf(unknown, "%u ?", reg); | ||
242 | + return unknown; | ||
32 | + } | 243 | + } |
33 | + | 244 | +} |
34 | + eci = env->condexec_bits >> 4; | 245 | + |
35 | + switch (eci) { | 246 | +static const VMStateDescription vmstate_imx7_src = { |
36 | + case ECI_NONE: | 247 | + .name = TYPE_IMX7_SRC, |
37 | + return 0xffff; | 248 | + .version_id = 1, |
38 | + case ECI_A0: | 249 | + .minimum_version_id = 1, |
39 | + return 0xfff0; | 250 | + .fields = (VMStateField[]) { |
40 | + case ECI_A0A1: | 251 | + VMSTATE_UINT32_ARRAY(regs, IMX7SRCState, SRC_MAX), |
41 | + return 0xff00; | 252 | + VMSTATE_END_OF_LIST() |
42 | + case ECI_A0A1A2: | 253 | + }, |
43 | + case ECI_A0A1A2B0: | 254 | +}; |
44 | + return 0xf000; | 255 | + |
256 | +static void imx7_src_reset(DeviceState *dev) | ||
257 | +{ | ||
258 | + IMX7SRCState *s = IMX7_SRC(dev); | ||
259 | + | ||
260 | + memset(s->regs, 0, sizeof(s->regs)); | ||
261 | + | ||
262 | + /* Set reset values */ | ||
263 | + s->regs[SRC_SCR] = 0xA0; | ||
264 | + s->regs[SRC_SRSR] = 0x1; | ||
265 | + s->regs[SRC_SIMR] = 0x1F; | ||
266 | +} | ||
267 | + | ||
268 | +static uint64_t imx7_src_read(void *opaque, hwaddr offset, unsigned size) | ||
269 | +{ | ||
270 | + uint32_t value = 0; | ||
271 | + IMX7SRCState *s = (IMX7SRCState *)opaque; | ||
272 | + uint32_t index = offset >> 2; | ||
273 | + | ||
274 | + if (index < SRC_MAX) { | ||
275 | + value = s->regs[index]; | ||
276 | + } else { | ||
277 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%" | ||
278 | + HWADDR_PRIx "\n", TYPE_IMX7_SRC, __func__, offset); | ||
279 | + } | ||
280 | + | ||
281 | + trace_imx7_src_read(imx7_src_reg_name(index), value); | ||
282 | + | ||
283 | + return value; | ||
284 | +} | ||
285 | + | ||
286 | + | ||
287 | +/* | ||
288 | + * The reset is asynchronous so we need to defer clearing the reset | ||
289 | + * bit until the work is completed. | ||
290 | + */ | ||
291 | + | ||
292 | +struct SRCSCRResetInfo { | ||
293 | + IMX7SRCState *s; | ||
294 | + uint32_t reset_bit; | ||
295 | +}; | ||
296 | + | ||
297 | +static void imx7_clear_reset_bit(CPUState *cpu, run_on_cpu_data data) | ||
298 | +{ | ||
299 | + struct SRCSCRResetInfo *ri = data.host_ptr; | ||
300 | + IMX7SRCState *s = ri->s; | ||
301 | + | ||
302 | + assert(qemu_mutex_iothread_locked()); | ||
303 | + | ||
304 | + s->regs[SRC_A7RCR0] = deposit32(s->regs[SRC_A7RCR0], ri->reset_bit, 1, 0); | ||
305 | + | ||
306 | + trace_imx7_src_write(imx7_src_reg_name(SRC_A7RCR0), s->regs[SRC_A7RCR0]); | ||
307 | + | ||
308 | + g_free(ri); | ||
309 | +} | ||
310 | + | ||
311 | +static void imx7_defer_clear_reset_bit(uint32_t cpuid, | ||
312 | + IMX7SRCState *s, | ||
313 | + uint32_t reset_shift) | ||
314 | +{ | ||
315 | + struct SRCSCRResetInfo *ri; | ||
316 | + CPUState *cpu = arm_get_cpu_by_id(cpuid); | ||
317 | + | ||
318 | + if (!cpu) { | ||
319 | + return; | ||
320 | + } | ||
321 | + | ||
322 | + ri = g_new(struct SRCSCRResetInfo, 1); | ||
323 | + ri->s = s; | ||
324 | + ri->reset_bit = reset_shift; | ||
325 | + | ||
326 | + async_run_on_cpu(cpu, imx7_clear_reset_bit, RUN_ON_CPU_HOST_PTR(ri)); | ||
327 | +} | ||
328 | + | ||
329 | + | ||
330 | +static void imx7_src_write(void *opaque, hwaddr offset, uint64_t value, | ||
331 | + unsigned size) | ||
332 | +{ | ||
333 | + IMX7SRCState *s = (IMX7SRCState *)opaque; | ||
334 | + uint32_t index = offset >> 2; | ||
335 | + long unsigned int change_mask; | ||
336 | + uint32_t current_value = value; | ||
337 | + | ||
338 | + if (index >= SRC_MAX) { | ||
339 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%" | ||
340 | + HWADDR_PRIx "\n", TYPE_IMX7_SRC, __func__, offset); | ||
341 | + return; | ||
342 | + } | ||
343 | + | ||
344 | + trace_imx7_src_write(imx7_src_reg_name(SRC_A7RCR0), s->regs[SRC_A7RCR0]); | ||
345 | + | ||
346 | + change_mask = s->regs[index] ^ (uint32_t)current_value; | ||
347 | + | ||
348 | + switch (index) { | ||
349 | + case SRC_A7RCR0: | ||
350 | + if (FIELD_EX32(change_mask, CORE0, RST)) { | ||
351 | + arm_reset_cpu(0); | ||
352 | + imx7_defer_clear_reset_bit(0, s, R_CORE0_RST_SHIFT); | ||
353 | + } | ||
354 | + if (FIELD_EX32(change_mask, CORE1, RST)) { | ||
355 | + arm_reset_cpu(1); | ||
356 | + imx7_defer_clear_reset_bit(1, s, R_CORE1_RST_SHIFT); | ||
357 | + } | ||
358 | + s->regs[index] = current_value; | ||
359 | + break; | ||
360 | + case SRC_A7RCR1: | ||
361 | + /* | ||
362 | + * On real hardware when the system reset controller starts a | ||
363 | + * secondary CPU it runs through some boot ROM code which reads | ||
364 | + * the SRC_GPRX registers controlling the start address and branches | ||
365 | + * to it. | ||
366 | + * Here we are taking a short cut and branching directly to the | ||
367 | + * requested address (we don't want to run the boot ROM code inside | ||
368 | + * QEMU) | ||
369 | + */ | ||
370 | + if (FIELD_EX32(change_mask, CORE1, ENABLE)) { | ||
371 | + if (FIELD_EX32(current_value, CORE1, ENABLE)) { | ||
372 | + /* CORE 1 is brought up */ | ||
373 | + arm_set_cpu_on(1, s->regs[SRC_GPR3], s->regs[SRC_GPR4], | ||
374 | + 3, false); | ||
375 | + } else { | ||
376 | + /* CORE 1 is shut down */ | ||
377 | + arm_set_cpu_off(1); | ||
378 | + } | ||
379 | + /* We clear the reset bits as the processor changed state */ | ||
380 | + imx7_defer_clear_reset_bit(1, s, R_CORE1_RST_SHIFT); | ||
381 | + clear_bit(R_CORE1_RST_SHIFT, &change_mask); | ||
382 | + } | ||
383 | + s->regs[index] = current_value; | ||
384 | + break; | ||
45 | + default: | 385 | + default: |
46 | + g_assert_not_reached(); | 386 | + s->regs[index] = current_value; |
387 | + break; | ||
47 | + } | 388 | + } |
48 | +} | 389 | +} |
49 | + | 390 | + |
50 | static uint16_t mve_element_mask(CPUARMState *env) | 391 | +static const struct MemoryRegionOps imx7_src_ops = { |
51 | { | 392 | + .read = imx7_src_read, |
52 | /* | 393 | + .write = imx7_src_write, |
53 | @@ -XXX,XX +XXX,XX @@ static uint16_t mve_element_mask(CPUARMState *env) | 394 | + .endianness = DEVICE_NATIVE_ENDIAN, |
54 | mask &= ltpmask; | 395 | + .valid = { |
55 | } | 396 | + /* |
56 | 397 | + * Our device would not work correctly if the guest was doing | |
57 | - if ((env->condexec_bits & 0xf) == 0) { | 398 | + * unaligned access. This might not be a limitation on the real |
58 | - /* | 399 | + * device but in practice there is no reason for a guest to access |
59 | - * ECI bits indicate which beats are already executed; | 400 | + * this device unaligned. |
60 | - * we handle this by effectively predicating them out. | 401 | + */ |
61 | - */ | 402 | + .min_access_size = 4, |
62 | - int eci = env->condexec_bits >> 4; | 403 | + .max_access_size = 4, |
63 | - switch (eci) { | 404 | + .unaligned = false, |
64 | - case ECI_NONE: | 405 | + }, |
65 | - break; | 406 | +}; |
66 | - case ECI_A0: | 407 | + |
67 | - mask &= 0xfff0; | 408 | +static void imx7_src_realize(DeviceState *dev, Error **errp) |
68 | - break; | 409 | +{ |
69 | - case ECI_A0A1: | 410 | + IMX7SRCState *s = IMX7_SRC(dev); |
70 | - mask &= 0xff00; | 411 | + |
71 | - break; | 412 | + memory_region_init_io(&s->iomem, OBJECT(dev), &imx7_src_ops, s, |
72 | - case ECI_A0A1A2: | 413 | + TYPE_IMX7_SRC, 0x1000); |
73 | - case ECI_A0A1A2B0: | 414 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); |
74 | - mask &= 0xf000; | 415 | +} |
75 | - break; | 416 | + |
76 | - default: | 417 | +static void imx7_src_class_init(ObjectClass *klass, void *data) |
77 | - g_assert_not_reached(); | 418 | +{ |
78 | - } | 419 | + DeviceClass *dc = DEVICE_CLASS(klass); |
79 | - } | 420 | + |
80 | - | 421 | + dc->realize = imx7_src_realize; |
81 | + /* | 422 | + dc->reset = imx7_src_reset; |
82 | + * ECI bits indicate which beats are already executed; | 423 | + dc->vmsd = &vmstate_imx7_src; |
83 | + * we handle this by effectively predicating them out. | 424 | + dc->desc = "i.MX6 System Reset Controller"; |
84 | + */ | 425 | +} |
85 | + mask &= mve_eci_mask(env); | 426 | + |
86 | return mask; | 427 | +static const TypeInfo imx7_src_info = { |
87 | } | 428 | + .name = TYPE_IMX7_SRC, |
88 | 429 | + .parent = TYPE_SYS_BUS_DEVICE, | |
430 | + .instance_size = sizeof(IMX7SRCState), | ||
431 | + .class_init = imx7_src_class_init, | ||
432 | +}; | ||
433 | + | ||
434 | +static void imx7_src_register_types(void) | ||
435 | +{ | ||
436 | + type_register_static(&imx7_src_info); | ||
437 | +} | ||
438 | + | ||
439 | +type_init(imx7_src_register_types) | ||
440 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
441 | index XXXXXXX..XXXXXXX 100644 | ||
442 | --- a/hw/misc/meson.build | ||
443 | +++ b/hw/misc/meson.build | ||
444 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_IMX', if_true: files( | ||
445 | 'imx6_src.c', | ||
446 | 'imx6ul_ccm.c', | ||
447 | 'imx7_ccm.c', | ||
448 | + 'imx7_src.c', | ||
449 | 'imx7_gpr.c', | ||
450 | 'imx7_snvs.c', | ||
451 | 'imx_ccm.c', | ||
452 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | ||
453 | index XXXXXXX..XXXXXXX 100644 | ||
454 | --- a/hw/misc/trace-events | ||
455 | +++ b/hw/misc/trace-events | ||
456 | @@ -XXX,XX +XXX,XX @@ ccm_clock_freq(uint32_t clock, uint32_t freq) "(Clock = %d) = %d" | ||
457 | ccm_read_reg(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 | ||
458 | ccm_write_reg(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 | ||
459 | |||
460 | +# imx7_src.c | ||
461 | +imx7_src_read(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 | ||
462 | +imx7_src_write(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 | ||
463 | + | ||
464 | # iotkit-sysinfo.c | ||
465 | iotkit_sysinfo_read(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | ||
466 | iotkit_sysinfo_write(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | ||
89 | -- | 467 | -- |
90 | 2.20.1 | 468 | 2.34.1 |
91 | |||
92 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | For vector loads, predicated elements are zeroed, instead of | ||
2 | retaining their previous values (as happens for most data | ||
3 | processing operations). This means we need to distinguish | ||
4 | "beat not executed due to ECI" (don't touch destination | ||
5 | element) from "beat executed but predicated out" (zero | ||
6 | destination element). | ||
7 | 1 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | target/arm/mve_helper.c | 8 +++++--- | ||
12 | 1 file changed, 5 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/mve_helper.c | ||
17 | +++ b/target/arm/mve_helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) | ||
19 | env->v7m.vpr = vpr; | ||
20 | } | ||
21 | |||
22 | - | ||
23 | +/* For loads, predicated lanes are zeroed instead of keeping their old values */ | ||
24 | #define DO_VLDR(OP, MSIZE, LDTYPE, ESIZE, TYPE) \ | ||
25 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, uint32_t addr) \ | ||
26 | { \ | ||
27 | TYPE *d = vd; \ | ||
28 | uint16_t mask = mve_element_mask(env); \ | ||
29 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
30 | unsigned b, e; \ | ||
31 | /* \ | ||
32 | * R_SXTM allows the dest reg to become UNKNOWN for abandoned \ | ||
33 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) | ||
34 | * then take an exception. \ | ||
35 | */ \ | ||
36 | for (b = 0, e = 0; b < 16; b += ESIZE, e++) { \ | ||
37 | - if (mask & (1 << b)) { \ | ||
38 | - d[H##ESIZE(e)] = cpu_##LDTYPE##_data_ra(env, addr, GETPC()); \ | ||
39 | + if (eci_mask & (1 << b)) { \ | ||
40 | + d[H##ESIZE(e)] = (mask & (1 << b)) ? \ | ||
41 | + cpu_##LDTYPE##_data_ra(env, addr, GETPC()) : 0; \ | ||
42 | } \ | ||
43 | addr += MSIZE; \ | ||
44 | } \ | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMULL (polynomial) insn. Unlike Neon, this comes | ||
2 | in two flavours: 8x8->16 and a 16x16->32. Also unlike Neon, the | ||
3 | inputs are in either the low or the high half of each double-width | ||
4 | element. | ||
5 | 1 | ||
6 | The assembler for this insn indicates the size with "P8" or "P16", | ||
7 | encoded into bit 28 as size = 0 or 1. We choose to follow the | ||
8 | same encoding as VQDMULL and decode this into a->size as MO_16 | ||
9 | or MO_32 indicating the size of the result elements. This then | ||
10 | carries through to the helper function names where it then | ||
11 | matches up with the existing pmull_h() which does an 8x8->16 | ||
12 | operation and a new pmull_w() which does the 16x16->32. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | ||
17 | target/arm/helper-mve.h | 5 +++++ | ||
18 | target/arm/vec_internal.h | 11 +++++++++++ | ||
19 | target/arm/mve.decode | 14 ++++++++++---- | ||
20 | target/arm/mve_helper.c | 16 ++++++++++++++++ | ||
21 | target/arm/translate-mve.c | 28 ++++++++++++++++++++++++++++ | ||
22 | target/arm/vec_helper.c | 14 +++++++++++++- | ||
23 | 6 files changed, 83 insertions(+), 5 deletions(-) | ||
24 | |||
25 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/helper-mve.h | ||
28 | +++ b/target/arm/helper-mve.h | ||
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
30 | DEF_HELPER_FLAGS_4(mve_vmulltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | DEF_HELPER_FLAGS_4(mve_vmulltuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
32 | |||
33 | +DEF_HELPER_FLAGS_4(mve_vmullpbh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vmullpth, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vmullpbw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
36 | +DEF_HELPER_FLAGS_4(mve_vmullptw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
37 | + | ||
38 | DEF_HELPER_FLAGS_4(mve_vqdmulhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
39 | DEF_HELPER_FLAGS_4(mve_vqdmulhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
40 | DEF_HELPER_FLAGS_4(mve_vqdmulhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
41 | diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/vec_internal.h | ||
44 | +++ b/target/arm/vec_internal.h | ||
45 | @@ -XXX,XX +XXX,XX @@ int16_t do_sqrdmlah_h(int16_t, int16_t, int16_t, bool, bool, uint32_t *); | ||
46 | int32_t do_sqrdmlah_s(int32_t, int32_t, int32_t, bool, bool, uint32_t *); | ||
47 | int64_t do_sqrdmlah_d(int64_t, int64_t, int64_t, bool, bool); | ||
48 | |||
49 | +/* | ||
50 | + * 8 x 8 -> 16 vector polynomial multiply where the inputs are | ||
51 | + * in the low 8 bits of each 16-bit element | ||
52 | +*/ | ||
53 | +uint64_t pmull_h(uint64_t op1, uint64_t op2); | ||
54 | +/* | ||
55 | + * 16 x 16 -> 32 vector polynomial multiply where the inputs are | ||
56 | + * in the low 16 bits of each 32-bit element | ||
57 | + */ | ||
58 | +uint64_t pmull_w(uint64_t op1, uint64_t op2); | ||
59 | + | ||
60 | #endif /* TARGET_ARM_VEC_INTERNALS_H */ | ||
61 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/mve.decode | ||
64 | +++ b/target/arm/mve.decode | ||
65 | @@ -XXX,XX +XXX,XX @@ VHADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 0 ... 0 @2op | ||
66 | VHSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op | ||
67 | VHSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op | ||
68 | |||
69 | -VMULL_BS 111 0 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
70 | -VMULL_BU 111 1 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
71 | -VMULL_TS 111 0 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
72 | -VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
73 | +{ | ||
74 | + VMULLP_B 111 . 1110 0 . 11 ... 1 ... 0 1110 . 0 . 0 ... 0 @2op_sz28 | ||
75 | + VMULL_BS 111 0 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
76 | + VMULL_BU 111 1 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
77 | +} | ||
78 | +{ | ||
79 | + VMULLP_T 111 . 1110 0 . 11 ... 1 ... 1 1110 . 0 . 0 ... 0 @2op_sz28 | ||
80 | + VMULL_TS 111 0 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
81 | + VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
82 | +} | ||
83 | |||
84 | VQDMULH 1110 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op | ||
85 | VQRDMULH 1111 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op | ||
86 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/target/arm/mve_helper.c | ||
89 | +++ b/target/arm/mve_helper.c | ||
90 | @@ -XXX,XX +XXX,XX @@ DO_2OP_L(vmulltub, 1, 1, uint8_t, 2, uint16_t, DO_MUL) | ||
91 | DO_2OP_L(vmulltuh, 1, 2, uint16_t, 4, uint32_t, DO_MUL) | ||
92 | DO_2OP_L(vmulltuw, 1, 4, uint32_t, 8, uint64_t, DO_MUL) | ||
93 | |||
94 | +/* | ||
95 | + * Polynomial multiply. We can always do this generating 64 bits | ||
96 | + * of the result at a time, so we don't need to use DO_2OP_L. | ||
97 | + */ | ||
98 | +#define VMULLPH_MASK 0x00ff00ff00ff00ffULL | ||
99 | +#define VMULLPW_MASK 0x0000ffff0000ffffULL | ||
100 | +#define DO_VMULLPBH(N, M) pmull_h((N) & VMULLPH_MASK, (M) & VMULLPH_MASK) | ||
101 | +#define DO_VMULLPTH(N, M) DO_VMULLPBH((N) >> 8, (M) >> 8) | ||
102 | +#define DO_VMULLPBW(N, M) pmull_w((N) & VMULLPW_MASK, (M) & VMULLPW_MASK) | ||
103 | +#define DO_VMULLPTW(N, M) DO_VMULLPBW((N) >> 16, (M) >> 16) | ||
104 | + | ||
105 | +DO_2OP(vmullpbh, 8, uint64_t, DO_VMULLPBH) | ||
106 | +DO_2OP(vmullpth, 8, uint64_t, DO_VMULLPTH) | ||
107 | +DO_2OP(vmullpbw, 8, uint64_t, DO_VMULLPBW) | ||
108 | +DO_2OP(vmullptw, 8, uint64_t, DO_VMULLPTW) | ||
109 | + | ||
110 | /* | ||
111 | * Because the computation type is at least twice as large as required, | ||
112 | * these work for both signed and unsigned source types. | ||
113 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
114 | index XXXXXXX..XXXXXXX 100644 | ||
115 | --- a/target/arm/translate-mve.c | ||
116 | +++ b/target/arm/translate-mve.c | ||
117 | @@ -XXX,XX +XXX,XX @@ static bool trans_VQDMULLT(DisasContext *s, arg_2op *a) | ||
118 | return do_2op(s, a, fns[a->size]); | ||
119 | } | ||
120 | |||
121 | +static bool trans_VMULLP_B(DisasContext *s, arg_2op *a) | ||
122 | +{ | ||
123 | + /* | ||
124 | + * Note that a->size indicates the output size, ie VMULL.P8 | ||
125 | + * is the 8x8->16 operation and a->size is MO_16; VMULL.P16 | ||
126 | + * is the 16x16->32 operation and a->size is MO_32. | ||
127 | + */ | ||
128 | + static MVEGenTwoOpFn * const fns[] = { | ||
129 | + NULL, | ||
130 | + gen_helper_mve_vmullpbh, | ||
131 | + gen_helper_mve_vmullpbw, | ||
132 | + NULL, | ||
133 | + }; | ||
134 | + return do_2op(s, a, fns[a->size]); | ||
135 | +} | ||
136 | + | ||
137 | +static bool trans_VMULLP_T(DisasContext *s, arg_2op *a) | ||
138 | +{ | ||
139 | + /* a->size is as for trans_VMULLP_B */ | ||
140 | + static MVEGenTwoOpFn * const fns[] = { | ||
141 | + NULL, | ||
142 | + gen_helper_mve_vmullpth, | ||
143 | + gen_helper_mve_vmullptw, | ||
144 | + NULL, | ||
145 | + }; | ||
146 | + return do_2op(s, a, fns[a->size]); | ||
147 | +} | ||
148 | + | ||
149 | /* | ||
150 | * VADC and VSBC: these perform an add-with-carry or subtract-with-carry | ||
151 | * of the 32-bit elements in each lane of the input vectors, where the | ||
152 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/arm/vec_helper.c | ||
155 | +++ b/target/arm/vec_helper.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static uint64_t expand_byte_to_half(uint64_t x) | ||
157 | | ((x & 0xff000000) << 24); | ||
158 | } | ||
159 | |||
160 | -static uint64_t pmull_h(uint64_t op1, uint64_t op2) | ||
161 | +uint64_t pmull_w(uint64_t op1, uint64_t op2) | ||
162 | { | ||
163 | uint64_t result = 0; | ||
164 | int i; | ||
165 | + for (i = 0; i < 16; ++i) { | ||
166 | + uint64_t mask = (op1 & 0x0000000100000001ull) * 0xffffffff; | ||
167 | + result ^= op2 & mask; | ||
168 | + op1 >>= 1; | ||
169 | + op2 <<= 1; | ||
170 | + } | ||
171 | + return result; | ||
172 | +} | ||
173 | |||
174 | +uint64_t pmull_h(uint64_t op1, uint64_t op2) | ||
175 | +{ | ||
176 | + uint64_t result = 0; | ||
177 | + int i; | ||
178 | for (i = 0; i < 8; ++i) { | ||
179 | uint64_t mask = (op1 & 0x0001000100010001ull) * 0xffff; | ||
180 | result ^= op2 & mask; | ||
181 | -- | ||
182 | 2.20.1 | ||
183 | |||
184 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE incrementing/decrementing dup insns VIDUP, VDDUP, | ||
2 | VIWDUP and VDWDUP. These fill the elements of a vector with | ||
3 | successively incrementing values, starting at the offset specified in | ||
4 | a general purpose register. The final value of the offset is written | ||
5 | back to this register. The wrapping variants take a second general | ||
6 | purpose register which specifies the point where the count should | ||
7 | wrap back to 0. | ||
8 | 1 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper-mve.h | 12 ++++ | ||
13 | target/arm/mve.decode | 25 ++++++++ | ||
14 | target/arm/mve_helper.c | 63 +++++++++++++++++++ | ||
15 | target/arm/translate-mve.c | 120 +++++++++++++++++++++++++++++++++++++ | ||
16 | 4 files changed, 220 insertions(+) | ||
17 | |||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper-mve.h | ||
21 | +++ b/target/arm/helper-mve.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
23 | |||
24 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
25 | |||
26 | +DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_viduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vidupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_5(mve_viwdupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
31 | +DEF_HELPER_FLAGS_5(mve_viwduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
32 | +DEF_HELPER_FLAGS_5(mve_viwdupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
33 | + | ||
34 | +DEF_HELPER_FLAGS_5(mve_vdwdupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
35 | +DEF_HELPER_FLAGS_5(mve_vdwduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
36 | +DEF_HELPER_FLAGS_5(mve_vdwdupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
37 | + | ||
38 | DEF_HELPER_FLAGS_3(mve_vclsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
39 | DEF_HELPER_FLAGS_3(mve_vclsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
40 | DEF_HELPER_FLAGS_3(mve_vclsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/mve.decode | ||
44 | +++ b/target/arm/mve.decode | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | &2scalar qd qn rm size | ||
47 | &1imm qd imm cmode op | ||
48 | &2shift qd qm shift size | ||
49 | +&vidup qd rn size imm | ||
50 | +&viwdup qd rn rm size imm | ||
51 | |||
52 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
53 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
54 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 1 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=0 | ||
55 | VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 1 1 0000 @vdup size=1 | ||
56 | VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
57 | |||
58 | +# Incrementing and decrementing dup | ||
59 | + | ||
60 | +# VIDUP, VDDUP format immediate: 1 << (immh:imml) | ||
61 | +%imm_vidup 7:1 0:1 !function=vidup_imm | ||
62 | + | ||
63 | +# VIDUP, VDDUP registers: Rm bits [3:1] from insn, bit 0 is 1; | ||
64 | +# Rn bits [3:1] from insn, bit 0 is 0 | ||
65 | +%vidup_rm 1:3 !function=times_2_plus_1 | ||
66 | +%vidup_rn 17:3 !function=times_2 | ||
67 | + | ||
68 | +@vidup .... .... . . size:2 .... .... .... .... .... \ | ||
69 | + qd=%qd imm=%imm_vidup rn=%vidup_rn &vidup | ||
70 | +@viwdup .... .... . . size:2 .... .... .... .... .... \ | ||
71 | + qd=%qd imm=%imm_vidup rm=%vidup_rm rn=%vidup_rn &viwdup | ||
72 | +{ | ||
73 | + VIDUP 1110 1110 0 . .. ... 1 ... 0 1111 . 110 111 . @vidup | ||
74 | + VIWDUP 1110 1110 0 . .. ... 1 ... 0 1111 . 110 ... . @viwdup | ||
75 | +} | ||
76 | +{ | ||
77 | + VDDUP 1110 1110 0 . .. ... 1 ... 1 1111 . 110 111 . @vidup | ||
78 | + VDWDUP 1110 1110 0 . .. ... 1 ... 1 1111 . 110 ... . @viwdup | ||
79 | +} | ||
80 | + | ||
81 | # multiply-add long dual accumulate | ||
82 | # rdahi: bits [3:1] from insn, bit 0 is 1 | ||
83 | # rdalo: bits [3:1] from insn, bit 0 is 0 | ||
84 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/target/arm/mve_helper.c | ||
87 | +++ b/target/arm/mve_helper.c | ||
88 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_sqrshr)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
89 | { | ||
90 | return do_sqrshl_bhs(n, -(int8_t)shift, 32, true, &env->QF); | ||
91 | } | ||
92 | + | ||
93 | +#define DO_VIDUP(OP, ESIZE, TYPE, FN) \ | ||
94 | + uint32_t HELPER(mve_##OP)(CPUARMState *env, void *vd, \ | ||
95 | + uint32_t offset, uint32_t imm) \ | ||
96 | + { \ | ||
97 | + TYPE *d = vd; \ | ||
98 | + uint16_t mask = mve_element_mask(env); \ | ||
99 | + unsigned e; \ | ||
100 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
101 | + mergemask(&d[H##ESIZE(e)], offset, mask); \ | ||
102 | + offset = FN(offset, imm); \ | ||
103 | + } \ | ||
104 | + mve_advance_vpt(env); \ | ||
105 | + return offset; \ | ||
106 | + } | ||
107 | + | ||
108 | +#define DO_VIWDUP(OP, ESIZE, TYPE, FN) \ | ||
109 | + uint32_t HELPER(mve_##OP)(CPUARMState *env, void *vd, \ | ||
110 | + uint32_t offset, uint32_t wrap, \ | ||
111 | + uint32_t imm) \ | ||
112 | + { \ | ||
113 | + TYPE *d = vd; \ | ||
114 | + uint16_t mask = mve_element_mask(env); \ | ||
115 | + unsigned e; \ | ||
116 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
117 | + mergemask(&d[H##ESIZE(e)], offset, mask); \ | ||
118 | + offset = FN(offset, wrap, imm); \ | ||
119 | + } \ | ||
120 | + mve_advance_vpt(env); \ | ||
121 | + return offset; \ | ||
122 | + } | ||
123 | + | ||
124 | +#define DO_VIDUP_ALL(OP, FN) \ | ||
125 | + DO_VIDUP(OP##b, 1, int8_t, FN) \ | ||
126 | + DO_VIDUP(OP##h, 2, int16_t, FN) \ | ||
127 | + DO_VIDUP(OP##w, 4, int32_t, FN) | ||
128 | + | ||
129 | +#define DO_VIWDUP_ALL(OP, FN) \ | ||
130 | + DO_VIWDUP(OP##b, 1, int8_t, FN) \ | ||
131 | + DO_VIWDUP(OP##h, 2, int16_t, FN) \ | ||
132 | + DO_VIWDUP(OP##w, 4, int32_t, FN) | ||
133 | + | ||
134 | +static uint32_t do_add_wrap(uint32_t offset, uint32_t wrap, uint32_t imm) | ||
135 | +{ | ||
136 | + offset += imm; | ||
137 | + if (offset == wrap) { | ||
138 | + offset = 0; | ||
139 | + } | ||
140 | + return offset; | ||
141 | +} | ||
142 | + | ||
143 | +static uint32_t do_sub_wrap(uint32_t offset, uint32_t wrap, uint32_t imm) | ||
144 | +{ | ||
145 | + if (offset == 0) { | ||
146 | + offset = wrap; | ||
147 | + } | ||
148 | + offset -= imm; | ||
149 | + return offset; | ||
150 | +} | ||
151 | + | ||
152 | +DO_VIDUP_ALL(vidup, DO_ADD) | ||
153 | +DO_VIWDUP_ALL(viwdup, do_add_wrap) | ||
154 | +DO_VIWDUP_ALL(vdwdup, do_sub_wrap) | ||
155 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
156 | index XXXXXXX..XXXXXXX 100644 | ||
157 | --- a/target/arm/translate-mve.c | ||
158 | +++ b/target/arm/translate-mve.c | ||
159 | @@ -XXX,XX +XXX,XX @@ | ||
160 | #include "translate.h" | ||
161 | #include "translate-a32.h" | ||
162 | |||
163 | +static inline int vidup_imm(DisasContext *s, int x) | ||
164 | +{ | ||
165 | + return 1 << x; | ||
166 | +} | ||
167 | + | ||
168 | /* Include the generated decoder */ | ||
169 | #include "decode-mve.c.inc" | ||
170 | |||
171 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
172 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
173 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
174 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
175 | +typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
176 | +typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
177 | |||
178 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
179 | static inline long mve_qreg_offset(unsigned reg) | ||
180 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLC(DisasContext *s, arg_VSHLC *a) | ||
181 | mve_update_eci(s); | ||
182 | return true; | ||
183 | } | ||
184 | + | ||
185 | +static bool do_vidup(DisasContext *s, arg_vidup *a, MVEGenVIDUPFn *fn) | ||
186 | +{ | ||
187 | + TCGv_ptr qd; | ||
188 | + TCGv_i32 rn; | ||
189 | + | ||
190 | + /* | ||
191 | + * Vector increment/decrement with wrap and duplicate (VIDUP, VDDUP). | ||
192 | + * This fills the vector with elements of successively increasing | ||
193 | + * or decreasing values, starting from Rn. | ||
194 | + */ | ||
195 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) { | ||
196 | + return false; | ||
197 | + } | ||
198 | + if (a->size == MO_64) { | ||
199 | + /* size 0b11 is another encoding */ | ||
200 | + return false; | ||
201 | + } | ||
202 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
203 | + return true; | ||
204 | + } | ||
205 | + | ||
206 | + qd = mve_qreg_ptr(a->qd); | ||
207 | + rn = load_reg(s, a->rn); | ||
208 | + fn(rn, cpu_env, qd, rn, tcg_constant_i32(a->imm)); | ||
209 | + store_reg(s, a->rn, rn); | ||
210 | + tcg_temp_free_ptr(qd); | ||
211 | + mve_update_eci(s); | ||
212 | + return true; | ||
213 | +} | ||
214 | + | ||
215 | +static bool do_viwdup(DisasContext *s, arg_viwdup *a, MVEGenVIWDUPFn *fn) | ||
216 | +{ | ||
217 | + TCGv_ptr qd; | ||
218 | + TCGv_i32 rn, rm; | ||
219 | + | ||
220 | + /* | ||
221 | + * Vector increment/decrement with wrap and duplicate (VIWDUp, VDWDUP) | ||
222 | + * This fills the vector with elements of successively increasing | ||
223 | + * or decreasing values, starting from Rn. Rm specifies a point where | ||
224 | + * the count wraps back around to 0. The updated offset is written back | ||
225 | + * to Rn. | ||
226 | + */ | ||
227 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) { | ||
228 | + return false; | ||
229 | + } | ||
230 | + if (!fn || a->rm == 13 || a->rm == 15) { | ||
231 | + /* | ||
232 | + * size 0b11 is another encoding; Rm == 13 is UNPREDICTABLE; | ||
233 | + * Rm == 13 is VIWDUP, VDWDUP. | ||
234 | + */ | ||
235 | + return false; | ||
236 | + } | ||
237 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
238 | + return true; | ||
239 | + } | ||
240 | + | ||
241 | + qd = mve_qreg_ptr(a->qd); | ||
242 | + rn = load_reg(s, a->rn); | ||
243 | + rm = load_reg(s, a->rm); | ||
244 | + fn(rn, cpu_env, qd, rn, rm, tcg_constant_i32(a->imm)); | ||
245 | + store_reg(s, a->rn, rn); | ||
246 | + tcg_temp_free_ptr(qd); | ||
247 | + tcg_temp_free_i32(rm); | ||
248 | + mve_update_eci(s); | ||
249 | + return true; | ||
250 | +} | ||
251 | + | ||
252 | +static bool trans_VIDUP(DisasContext *s, arg_vidup *a) | ||
253 | +{ | ||
254 | + static MVEGenVIDUPFn * const fns[] = { | ||
255 | + gen_helper_mve_vidupb, | ||
256 | + gen_helper_mve_viduph, | ||
257 | + gen_helper_mve_vidupw, | ||
258 | + NULL, | ||
259 | + }; | ||
260 | + return do_vidup(s, a, fns[a->size]); | ||
261 | +} | ||
262 | + | ||
263 | +static bool trans_VDDUP(DisasContext *s, arg_vidup *a) | ||
264 | +{ | ||
265 | + static MVEGenVIDUPFn * const fns[] = { | ||
266 | + gen_helper_mve_vidupb, | ||
267 | + gen_helper_mve_viduph, | ||
268 | + gen_helper_mve_vidupw, | ||
269 | + NULL, | ||
270 | + }; | ||
271 | + /* VDDUP is just like VIDUP but with a negative immediate */ | ||
272 | + a->imm = -a->imm; | ||
273 | + return do_vidup(s, a, fns[a->size]); | ||
274 | +} | ||
275 | + | ||
276 | +static bool trans_VIWDUP(DisasContext *s, arg_viwdup *a) | ||
277 | +{ | ||
278 | + static MVEGenVIWDUPFn * const fns[] = { | ||
279 | + gen_helper_mve_viwdupb, | ||
280 | + gen_helper_mve_viwduph, | ||
281 | + gen_helper_mve_viwdupw, | ||
282 | + NULL, | ||
283 | + }; | ||
284 | + return do_viwdup(s, a, fns[a->size]); | ||
285 | +} | ||
286 | + | ||
287 | +static bool trans_VDWDUP(DisasContext *s, arg_viwdup *a) | ||
288 | +{ | ||
289 | + static MVEGenVIWDUPFn * const fns[] = { | ||
290 | + gen_helper_mve_vdwdupb, | ||
291 | + gen_helper_mve_vdwduph, | ||
292 | + gen_helper_mve_vdwdupw, | ||
293 | + NULL, | ||
294 | + }; | ||
295 | + return do_viwdup(s, a, fns[a->size]); | ||
296 | +} | ||
297 | -- | ||
298 | 2.20.1 | ||
299 | |||
300 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Factor out the "generate code to update VPR.MASK01/MASK23" part of | ||
2 | trans_VPST(); we are going to want to reuse it for the VPT insns. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/translate-mve.c | 31 +++++++++++++++++-------------- | ||
8 | 1 file changed, 17 insertions(+), 14 deletions(-) | ||
9 | |||
10 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/arm/translate-mve.c | ||
13 | +++ b/target/arm/translate-mve.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) | ||
15 | return do_long_dual_acc(s, a, fns[a->x]); | ||
16 | } | ||
17 | |||
18 | -static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
19 | +static void gen_vpst(DisasContext *s, uint32_t mask) | ||
20 | { | ||
21 | - TCGv_i32 vpr; | ||
22 | - | ||
23 | - /* mask == 0 is a "related encoding" */ | ||
24 | - if (!dc_isar_feature(aa32_mve, s) || !a->mask) { | ||
25 | - return false; | ||
26 | - } | ||
27 | - if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
28 | - return true; | ||
29 | - } | ||
30 | /* | ||
31 | * Set the VPR mask fields. We take advantage of MASK01 and MASK23 | ||
32 | * being adjacent fields in the register. | ||
33 | * | ||
34 | - * This insn is not predicated, but it is subject to beat-wise | ||
35 | + * Updating the masks is not predicated, but it is subject to beat-wise | ||
36 | * execution, and the mask is updated on the odd-numbered beats. | ||
37 | * So if PSR.ECI says we should skip beat 1, we mustn't update the | ||
38 | * 01 mask field. | ||
39 | */ | ||
40 | - vpr = load_cpu_field(v7m.vpr); | ||
41 | + TCGv_i32 vpr = load_cpu_field(v7m.vpr); | ||
42 | switch (s->eci) { | ||
43 | case ECI_NONE: | ||
44 | case ECI_A0: | ||
45 | /* Update both 01 and 23 fields */ | ||
46 | tcg_gen_deposit_i32(vpr, vpr, | ||
47 | - tcg_constant_i32(a->mask | (a->mask << 4)), | ||
48 | + tcg_constant_i32(mask | (mask << 4)), | ||
49 | R_V7M_VPR_MASK01_SHIFT, | ||
50 | R_V7M_VPR_MASK01_LENGTH + R_V7M_VPR_MASK23_LENGTH); | ||
51 | break; | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
53 | case ECI_A0A1A2B0: | ||
54 | /* Update only the 23 mask field */ | ||
55 | tcg_gen_deposit_i32(vpr, vpr, | ||
56 | - tcg_constant_i32(a->mask), | ||
57 | + tcg_constant_i32(mask), | ||
58 | R_V7M_VPR_MASK23_SHIFT, R_V7M_VPR_MASK23_LENGTH); | ||
59 | break; | ||
60 | default: | ||
61 | g_assert_not_reached(); | ||
62 | } | ||
63 | store_cpu_field(vpr, v7m.vpr); | ||
64 | +} | ||
65 | + | ||
66 | +static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
67 | +{ | ||
68 | + /* mask == 0 is a "related encoding" */ | ||
69 | + if (!dc_isar_feature(aa32_mve, s) || !a->mask) { | ||
70 | + return false; | ||
71 | + } | ||
72 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
73 | + return true; | ||
74 | + } | ||
75 | + gen_vpst(s, a->mask); | ||
76 | mve_update_and_store_eci(s); | ||
77 | return true; | ||
78 | } | ||
79 | -- | ||
80 | 2.20.1 | ||
81 | |||
82 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE integer vector comparison instructions. These are | ||
2 | "VCMP (vector)" encodings T1, T2 and T3, and "VPT (vector)" encodings | ||
3 | T1, T2 and T3. | ||
4 | 1 | ||
5 | These insns compare corresponding elements in each vector, and update | ||
6 | the VPR.P0 predicate bits with the results of the comparison. VPT | ||
7 | also sets the VPR.MASK01 and VPR.MASK23 fields -- it is effectively | ||
8 | "VCMP then VPST". | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | target/arm/helper-mve.h | 32 ++++++++++++++++++++++ | ||
14 | target/arm/mve.decode | 18 +++++++++++- | ||
15 | target/arm/mve_helper.c | 56 ++++++++++++++++++++++++++++++++++++++ | ||
16 | target/arm/translate-mve.c | 47 ++++++++++++++++++++++++++++++++ | ||
17 | 4 files changed, 152 insertions(+), 1 deletion(-) | ||
18 | |||
19 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/helper-mve.h | ||
22 | +++ b/target/arm/helper-mve.h | ||
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
24 | DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
25 | DEF_HELPER_FLAGS_3(mve_uqrshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
26 | DEF_HELPER_FLAGS_3(mve_sqrshr, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
27 | + | ||
28 | +DEF_HELPER_FLAGS_3(mve_vcmpeqb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vcmpeqh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vcmpeqw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | + | ||
32 | +DEF_HELPER_FLAGS_3(mve_vcmpneb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
33 | +DEF_HELPER_FLAGS_3(mve_vcmpneh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vcmpnew, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
35 | + | ||
36 | +DEF_HELPER_FLAGS_3(mve_vcmpcsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
37 | +DEF_HELPER_FLAGS_3(mve_vcmpcsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
38 | +DEF_HELPER_FLAGS_3(mve_vcmpcsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
39 | + | ||
40 | +DEF_HELPER_FLAGS_3(mve_vcmphib, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vcmphih, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
42 | +DEF_HELPER_FLAGS_3(mve_vcmphiw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
43 | + | ||
44 | +DEF_HELPER_FLAGS_3(mve_vcmpgeb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
45 | +DEF_HELPER_FLAGS_3(mve_vcmpgeh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
46 | +DEF_HELPER_FLAGS_3(mve_vcmpgew, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
47 | + | ||
48 | +DEF_HELPER_FLAGS_3(mve_vcmpltb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
49 | +DEF_HELPER_FLAGS_3(mve_vcmplth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
50 | +DEF_HELPER_FLAGS_3(mve_vcmpltw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
51 | + | ||
52 | +DEF_HELPER_FLAGS_3(mve_vcmpgtb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
53 | +DEF_HELPER_FLAGS_3(mve_vcmpgth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
54 | +DEF_HELPER_FLAGS_3(mve_vcmpgtw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
55 | + | ||
56 | +DEF_HELPER_FLAGS_3(mve_vcmpleb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
57 | +DEF_HELPER_FLAGS_3(mve_vcmpleh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
58 | +DEF_HELPER_FLAGS_3(mve_vcmplew, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
59 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/arm/mve.decode | ||
62 | +++ b/target/arm/mve.decode | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | &2shift qd qm shift size | ||
65 | &vidup qd rn size imm | ||
66 | &viwdup qd rn rm size imm | ||
67 | +&vcmp qm qn size mask | ||
68 | |||
69 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
70 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
71 | @@ -XXX,XX +XXX,XX @@ | ||
72 | @2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
73 | size=2 shift=%rshift_i5 | ||
74 | |||
75 | +# Vector comparison; 4-bit Qm but 3-bit Qn | ||
76 | +%mask_22_13 22:1 13:3 | ||
77 | +@vcmp .... .... .. size:2 qn:3 . .... .... .... .... &vcmp qm=%qm mask=%mask_22_13 | ||
78 | + | ||
79 | # Vector loads and stores | ||
80 | |||
81 | # Widening loads and narrowing stores: | ||
82 | @@ -XXX,XX +XXX,XX @@ VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
83 | } | ||
84 | |||
85 | # Predicate operations | ||
86 | -%mask_22_13 22:1 13:3 | ||
87 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
88 | |||
89 | # Logical immediate operations (1 reg and modified-immediate) | ||
90 | @@ -XXX,XX +XXX,XX @@ VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
91 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
92 | |||
93 | VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | ||
94 | + | ||
95 | +# Comparisons. We expand out the conditions which are split across | ||
96 | +# encodings T1, T2, T3 and the fc bits. These include VPT, which is | ||
97 | +# effectively "VCMP then VPST". A plain "VCMP" has a mask field of zero. | ||
98 | +VCMPEQ 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 0 @vcmp | ||
99 | +VCMPNE 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 0 @vcmp | ||
100 | +VCMPCS 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 1 @vcmp | ||
101 | +VCMPHI 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 1 @vcmp | ||
102 | +VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | ||
103 | +VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | ||
104 | +VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
105 | +VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | ||
106 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/mve_helper.c | ||
109 | +++ b/target/arm/mve_helper.c | ||
110 | @@ -XXX,XX +XXX,XX @@ static uint32_t do_sub_wrap(uint32_t offset, uint32_t wrap, uint32_t imm) | ||
111 | DO_VIDUP_ALL(vidup, DO_ADD) | ||
112 | DO_VIWDUP_ALL(viwdup, do_add_wrap) | ||
113 | DO_VIWDUP_ALL(vdwdup, do_sub_wrap) | ||
114 | + | ||
115 | +/* | ||
116 | + * Vector comparison. | ||
117 | + * P0 bits for non-executed beats (where eci_mask is 0) are unchanged. | ||
118 | + * P0 bits for predicated lanes in executed beats (where mask is 0) are 0. | ||
119 | + * P0 bits otherwise are updated with the results of the comparisons. | ||
120 | + * We must also keep unchanged the MASK fields at the top of v7m.vpr. | ||
121 | + */ | ||
122 | +#define DO_VCMP(OP, ESIZE, TYPE, FN) \ | ||
123 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, void *vm) \ | ||
124 | + { \ | ||
125 | + TYPE *n = vn, *m = vm; \ | ||
126 | + uint16_t mask = mve_element_mask(env); \ | ||
127 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
128 | + uint16_t beatpred = 0; \ | ||
129 | + uint16_t emask = MAKE_64BIT_MASK(0, ESIZE); \ | ||
130 | + unsigned e; \ | ||
131 | + for (e = 0; e < 16 / ESIZE; e++) { \ | ||
132 | + bool r = FN(n[H##ESIZE(e)], m[H##ESIZE(e)]); \ | ||
133 | + /* Comparison sets 0/1 bits for each byte in the element */ \ | ||
134 | + beatpred |= r * emask; \ | ||
135 | + emask <<= ESIZE; \ | ||
136 | + } \ | ||
137 | + beatpred &= mask; \ | ||
138 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | \ | ||
139 | + (beatpred & eci_mask); \ | ||
140 | + mve_advance_vpt(env); \ | ||
141 | + } | ||
142 | + | ||
143 | +#define DO_VCMP_S(OP, FN) \ | ||
144 | + DO_VCMP(OP##b, 1, int8_t, FN) \ | ||
145 | + DO_VCMP(OP##h, 2, int16_t, FN) \ | ||
146 | + DO_VCMP(OP##w, 4, int32_t, FN) | ||
147 | + | ||
148 | +#define DO_VCMP_U(OP, FN) \ | ||
149 | + DO_VCMP(OP##b, 1, uint8_t, FN) \ | ||
150 | + DO_VCMP(OP##h, 2, uint16_t, FN) \ | ||
151 | + DO_VCMP(OP##w, 4, uint32_t, FN) | ||
152 | + | ||
153 | +#define DO_EQ(N, M) ((N) == (M)) | ||
154 | +#define DO_NE(N, M) ((N) != (M)) | ||
155 | +#define DO_EQ(N, M) ((N) == (M)) | ||
156 | +#define DO_EQ(N, M) ((N) == (M)) | ||
157 | +#define DO_GE(N, M) ((N) >= (M)) | ||
158 | +#define DO_LT(N, M) ((N) < (M)) | ||
159 | +#define DO_GT(N, M) ((N) > (M)) | ||
160 | +#define DO_LE(N, M) ((N) <= (M)) | ||
161 | + | ||
162 | +DO_VCMP_U(vcmpeq, DO_EQ) | ||
163 | +DO_VCMP_U(vcmpne, DO_NE) | ||
164 | +DO_VCMP_U(vcmpcs, DO_GE) | ||
165 | +DO_VCMP_U(vcmphi, DO_GT) | ||
166 | +DO_VCMP_S(vcmpge, DO_GE) | ||
167 | +DO_VCMP_S(vcmplt, DO_LT) | ||
168 | +DO_VCMP_S(vcmpgt, DO_GT) | ||
169 | +DO_VCMP_S(vcmple, DO_LE) | ||
170 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
171 | index XXXXXXX..XXXXXXX 100644 | ||
172 | --- a/target/arm/translate-mve.c | ||
173 | +++ b/target/arm/translate-mve.c | ||
174 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
175 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
176 | typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
177 | typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
178 | +typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
179 | |||
180 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
181 | static inline long mve_qreg_offset(unsigned reg) | ||
182 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDWDUP(DisasContext *s, arg_viwdup *a) | ||
183 | }; | ||
184 | return do_viwdup(s, a, fns[a->size]); | ||
185 | } | ||
186 | + | ||
187 | +static bool do_vcmp(DisasContext *s, arg_vcmp *a, MVEGenCmpFn *fn) | ||
188 | +{ | ||
189 | + TCGv_ptr qn, qm; | ||
190 | + | ||
191 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qm) || | ||
192 | + !fn) { | ||
193 | + return false; | ||
194 | + } | ||
195 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
196 | + return true; | ||
197 | + } | ||
198 | + | ||
199 | + qn = mve_qreg_ptr(a->qn); | ||
200 | + qm = mve_qreg_ptr(a->qm); | ||
201 | + fn(cpu_env, qn, qm); | ||
202 | + tcg_temp_free_ptr(qn); | ||
203 | + tcg_temp_free_ptr(qm); | ||
204 | + if (a->mask) { | ||
205 | + /* VPT */ | ||
206 | + gen_vpst(s, a->mask); | ||
207 | + } | ||
208 | + mve_update_eci(s); | ||
209 | + return true; | ||
210 | +} | ||
211 | + | ||
212 | +#define DO_VCMP(INSN, FN) \ | ||
213 | + static bool trans_##INSN(DisasContext *s, arg_vcmp *a) \ | ||
214 | + { \ | ||
215 | + static MVEGenCmpFn * const fns[] = { \ | ||
216 | + gen_helper_mve_##FN##b, \ | ||
217 | + gen_helper_mve_##FN##h, \ | ||
218 | + gen_helper_mve_##FN##w, \ | ||
219 | + NULL, \ | ||
220 | + }; \ | ||
221 | + return do_vcmp(s, a, fns[a->size]); \ | ||
222 | + } | ||
223 | + | ||
224 | +DO_VCMP(VCMPEQ, vcmpeq) | ||
225 | +DO_VCMP(VCMPNE, vcmpne) | ||
226 | +DO_VCMP(VCMPCS, vcmpcs) | ||
227 | +DO_VCMP(VCMPHI, vcmphi) | ||
228 | +DO_VCMP(VCMPGE, vcmpge) | ||
229 | +DO_VCMP(VCMPLT, vcmplt) | ||
230 | +DO_VCMP(VCMPGT, vcmpgt) | ||
231 | +DO_VCMP(VCMPLE, vcmple) | ||
232 | -- | ||
233 | 2.20.1 | ||
234 | |||
235 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VPSEL insn, which sets each byte of the destination | ||
2 | vector Qd to the byte from either Qn or Qm depending on the value of | ||
3 | the corresponding bit in VPR.P0. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 2 ++ | ||
9 | target/arm/mve.decode | 7 +++++-- | ||
10 | target/arm/mve_helper.c | 19 +++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 2 ++ | ||
12 | 4 files changed, 28 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper-mve.h | ||
17 | +++ b/target/arm/helper-mve.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vorr, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | |||
22 | +DEF_HELPER_FLAGS_4(mve_vpsel, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
23 | + | ||
24 | DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | DEF_HELPER_FLAGS_4(mve_vaddw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/mve.decode | ||
30 | +++ b/target/arm/mve.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | ||
32 | # effectively "VCMP then VPST". A plain "VCMP" has a mask field of zero. | ||
33 | VCMPEQ 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 0 @vcmp | ||
34 | VCMPNE 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 0 @vcmp | ||
35 | -VCMPCS 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 1 @vcmp | ||
36 | -VCMPHI 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 1 @vcmp | ||
37 | +{ | ||
38 | + VPSEL 1111 1110 0 . 11 ... 1 ... 0 1111 . 0 . 0 ... 1 @2op_nosz | ||
39 | + VCMPCS 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 1 @vcmp | ||
40 | + VCMPHI 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 1 @vcmp | ||
41 | +} | ||
42 | VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | ||
43 | VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | ||
44 | VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
45 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/mve_helper.c | ||
48 | +++ b/target/arm/mve_helper.c | ||
49 | @@ -XXX,XX +XXX,XX @@ DO_VCMP_S(vcmpge, DO_GE) | ||
50 | DO_VCMP_S(vcmplt, DO_LT) | ||
51 | DO_VCMP_S(vcmpgt, DO_GT) | ||
52 | DO_VCMP_S(vcmple, DO_LE) | ||
53 | + | ||
54 | +void HELPER(mve_vpsel)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
55 | +{ | ||
56 | + /* | ||
57 | + * Qd[n] = VPR.P0[n] ? Qn[n] : Qm[n] | ||
58 | + * but note that whether bytes are written to Qd is still subject | ||
59 | + * to (all forms of) predication in the usual way. | ||
60 | + */ | ||
61 | + uint64_t *d = vd, *n = vn, *m = vm; | ||
62 | + uint16_t mask = mve_element_mask(env); | ||
63 | + uint16_t p0 = FIELD_EX32(env->v7m.vpr, V7M_VPR, P0); | ||
64 | + unsigned e; | ||
65 | + for (e = 0; e < 16 / 8; e++, mask >>= 8, p0 >>= 8) { | ||
66 | + uint64_t r = m[H8(e)]; | ||
67 | + mergemask(&r, n[H8(e)], p0); | ||
68 | + mergemask(&d[H8(e)], r, mask); | ||
69 | + } | ||
70 | + mve_advance_vpt(env); | ||
71 | +} | ||
72 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/target/arm/translate-mve.c | ||
75 | +++ b/target/arm/translate-mve.c | ||
76 | @@ -XXX,XX +XXX,XX @@ DO_LOGIC(VORR, gen_helper_mve_vorr) | ||
77 | DO_LOGIC(VORN, gen_helper_mve_vorn) | ||
78 | DO_LOGIC(VEOR, gen_helper_mve_veor) | ||
79 | |||
80 | +DO_LOGIC(VPSEL, gen_helper_mve_vpsel) | ||
81 | + | ||
82 | #define DO_2OP(INSN, FN) \ | ||
83 | static bool trans_##INSN(DisasContext *s, arg_2op *a) \ | ||
84 | { \ | ||
85 | -- | ||
86 | 2.20.1 | ||
87 | |||
88 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMLAS insn, which multiplies a vector by a vector | ||
2 | and adds a scalar. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 4 ++++ | ||
8 | target/arm/mve.decode | 3 +++ | ||
9 | target/arm/mve_helper.c | 26 ++++++++++++++++++++++++++ | ||
10 | target/arm/translate-mve.c | 1 + | ||
11 | 4 files changed, 34 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper-mve.h | ||
16 | +++ b/target/arm/helper-mve.h | ||
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i3 | ||
18 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | |||
21 | +DEF_HELPER_FLAGS_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vmlash, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vmlasw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
26 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
27 | DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/mve.decode | ||
31 | +++ b/target/arm/mve.decode | ||
32 | @@ -XXX,XX +XXX,XX @@ VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
33 | VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
34 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
35 | |||
36 | +# The U bit (28) is don't-care because it does not affect the result | ||
37 | +VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
38 | + | ||
39 | # Vector add across vector | ||
40 | { | ||
41 | VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
42 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/mve_helper.c | ||
45 | +++ b/target/arm/mve_helper.c | ||
46 | @@ -XXX,XX +XXX,XX @@ DO_VQDMLADH_OP(vqrdmlsdhxw, 4, int32_t, 1, 1, do_vqdmlsdh_w) | ||
47 | mve_advance_vpt(env); \ | ||
48 | } | ||
49 | |||
50 | +/* "accumulating" version where FN takes d as well as n and m */ | ||
51 | +#define DO_2OP_ACC_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
52 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
53 | + uint32_t rm) \ | ||
54 | + { \ | ||
55 | + TYPE *d = vd, *n = vn; \ | ||
56 | + TYPE m = rm; \ | ||
57 | + uint16_t mask = mve_element_mask(env); \ | ||
58 | + unsigned e; \ | ||
59 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
60 | + mergemask(&d[H##ESIZE(e)], \ | ||
61 | + FN(d[H##ESIZE(e)], n[H##ESIZE(e)], m), mask); \ | ||
62 | + } \ | ||
63 | + mve_advance_vpt(env); \ | ||
64 | + } | ||
65 | + | ||
66 | /* provide unsigned 2-op scalar helpers for all sizes */ | ||
67 | #define DO_2OP_SCALAR_U(OP, FN) \ | ||
68 | DO_2OP_SCALAR(OP##b, 1, uint8_t, FN) \ | ||
69 | @@ -XXX,XX +XXX,XX @@ DO_VQDMLADH_OP(vqrdmlsdhxw, 4, int32_t, 1, 1, do_vqdmlsdh_w) | ||
70 | DO_2OP_SCALAR(OP##h, 2, int16_t, FN) \ | ||
71 | DO_2OP_SCALAR(OP##w, 4, int32_t, FN) | ||
72 | |||
73 | +#define DO_2OP_ACC_SCALAR_U(OP, FN) \ | ||
74 | + DO_2OP_ACC_SCALAR(OP##b, 1, uint8_t, FN) \ | ||
75 | + DO_2OP_ACC_SCALAR(OP##h, 2, uint16_t, FN) \ | ||
76 | + DO_2OP_ACC_SCALAR(OP##w, 4, uint32_t, FN) | ||
77 | + | ||
78 | DO_2OP_SCALAR_U(vadd_scalar, DO_ADD) | ||
79 | DO_2OP_SCALAR_U(vsub_scalar, DO_SUB) | ||
80 | DO_2OP_SCALAR_U(vmul_scalar, DO_MUL) | ||
81 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) | ||
82 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) | ||
83 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W) | ||
84 | |||
85 | +/* Vector by vector plus scalar */ | ||
86 | +#define DO_VMLAS(D, N, M) ((N) * (D) + (M)) | ||
87 | + | ||
88 | +DO_2OP_ACC_SCALAR_U(vmlas, DO_VMLAS) | ||
89 | + | ||
90 | /* | ||
91 | * Long saturating scalar ops. As with DO_2OP_L, TYPE and H are for the | ||
92 | * input (smaller) type and LESIZE, LTYPE, LH for the output (long) type. | ||
93 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/translate-mve.c | ||
96 | +++ b/target/arm/translate-mve.c | ||
97 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VQSUB_U_scalar, vqsubu_scalar) | ||
98 | DO_2OP_SCALAR(VQDMULH_scalar, vqdmulh_scalar) | ||
99 | DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) | ||
100 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
101 | +DO_2OP_SCALAR(VMLAS, vmlas) | ||
102 | |||
103 | static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a) | ||
104 | { | ||
105 | -- | ||
106 | 2.20.1 | ||
107 | |||
108 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE instructions which perform shifts by a scalar. | ||
2 | These are VSHL T2, VRSHL T2, VQSHL T1 and VQRSHL T2. They take the | ||
3 | shift amount in a general purpose register and shift every element in | ||
4 | the vector by that amount. | ||
5 | 1 | ||
6 | Mostly we can reuse the helper functions for shift-by-immediate; we | ||
7 | do need two new helpers for VQRSHL. | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper-mve.h | 8 +++++++ | ||
13 | target/arm/mve.decode | 23 ++++++++++++++++--- | ||
14 | target/arm/mve_helper.c | 2 ++ | ||
15 | target/arm/translate-mve.c | 46 ++++++++++++++++++++++++++++++++++++++ | ||
16 | 4 files changed, 76 insertions(+), 3 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper-mve.h | ||
21 | +++ b/target/arm/helper-mve.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
25 | |||
26 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_4(mve_vqrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vqrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | + | ||
34 | DEF_HELPER_FLAGS_4(mve_vshllbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | DEF_HELPER_FLAGS_4(mve_vshllbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | DEF_HELPER_FLAGS_4(mve_vshllbub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/mve.decode | ||
40 | +++ b/target/arm/mve.decode | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | &viwdup qd rn rm size imm | ||
43 | &vcmp qm qn size mask | ||
44 | &vcmp_scalar qn rm size mask | ||
45 | +&shl_scalar qda rm size | ||
46 | |||
47 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
48 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | @2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
51 | size=2 shift=%rshift_i5 | ||
52 | |||
53 | +@shl_scalar .... .... .... size:2 .. .... .... .... rm:4 &shl_scalar qda=%qd | ||
54 | + | ||
55 | # Vector comparison; 4-bit Qm but 3-bit Qn | ||
56 | %mask_22_13 22:1 13:3 | ||
57 | @vcmp .... .... .. size:2 qn:3 . .... .... .... .... &vcmp qm=%qm mask=%mask_22_13 | ||
58 | @@ -XXX,XX +XXX,XX @@ VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_no | ||
59 | |||
60 | VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar | ||
61 | VSUB_scalar 1110 1110 0 . .. ... 1 ... 1 1111 . 100 .... @2scalar | ||
62 | -VMUL_scalar 1110 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
63 | + | ||
64 | +{ | ||
65 | + VSHL_S_scalar 1110 1110 0 . 11 .. 01 ... 1 1110 0110 .... @shl_scalar | ||
66 | + VRSHL_S_scalar 1110 1110 0 . 11 .. 11 ... 1 1110 0110 .... @shl_scalar | ||
67 | + VQSHL_S_scalar 1110 1110 0 . 11 .. 01 ... 1 1110 1110 .... @shl_scalar | ||
68 | + VQRSHL_S_scalar 1110 1110 0 . 11 .. 11 ... 1 1110 1110 .... @shl_scalar | ||
69 | + VMUL_scalar 1110 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
70 | +} | ||
71 | + | ||
72 | +{ | ||
73 | + VSHL_U_scalar 1111 1110 0 . 11 .. 01 ... 1 1110 0110 .... @shl_scalar | ||
74 | + VRSHL_U_scalar 1111 1110 0 . 11 .. 11 ... 1 1110 0110 .... @shl_scalar | ||
75 | + VQSHL_U_scalar 1111 1110 0 . 11 .. 01 ... 1 1110 1110 .... @shl_scalar | ||
76 | + VQRSHL_U_scalar 1111 1110 0 . 11 .. 11 ... 1 1110 1110 .... @shl_scalar | ||
77 | + VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
78 | +} | ||
79 | + | ||
80 | VHADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
81 | VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
82 | VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
83 | @@ -XXX,XX +XXX,XX @@ VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
84 | size=%size_28 | ||
85 | } | ||
86 | |||
87 | -VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
88 | - | ||
89 | VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
90 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
91 | |||
92 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/mve_helper.c | ||
95 | +++ b/target/arm/mve_helper.c | ||
96 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
97 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
98 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
99 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
100 | +DO_2SHIFT_SAT_U(vqrshli_u, DO_UQRSHL_OP) | ||
101 | +DO_2SHIFT_SAT_S(vqrshli_s, DO_SQRSHL_OP) | ||
102 | |||
103 | /* Shift-and-insert; we always work with 64 bits at a time */ | ||
104 | #define DO_2SHIFT_INSERT(OP, ESIZE, SHIFTFN, MASKFN) \ | ||
105 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/translate-mve.c | ||
108 | +++ b/target/arm/translate-mve.c | ||
109 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
110 | DO_2SHIFT(VSRI, vsri, false) | ||
111 | DO_2SHIFT(VSLI, vsli, false) | ||
112 | |||
113 | +static bool do_2shift_scalar(DisasContext *s, arg_shl_scalar *a, | ||
114 | + MVEGenTwoOpShiftFn *fn) | ||
115 | +{ | ||
116 | + TCGv_ptr qda; | ||
117 | + TCGv_i32 rm; | ||
118 | + | ||
119 | + if (!dc_isar_feature(aa32_mve, s) || | ||
120 | + !mve_check_qreg_bank(s, a->qda) || | ||
121 | + a->rm == 13 || a->rm == 15 || !fn) { | ||
122 | + /* Rm cases are UNPREDICTABLE */ | ||
123 | + return false; | ||
124 | + } | ||
125 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
126 | + return true; | ||
127 | + } | ||
128 | + | ||
129 | + qda = mve_qreg_ptr(a->qda); | ||
130 | + rm = load_reg(s, a->rm); | ||
131 | + fn(cpu_env, qda, qda, rm); | ||
132 | + tcg_temp_free_ptr(qda); | ||
133 | + tcg_temp_free_i32(rm); | ||
134 | + mve_update_eci(s); | ||
135 | + return true; | ||
136 | +} | ||
137 | + | ||
138 | +#define DO_2SHIFT_SCALAR(INSN, FN) \ | ||
139 | + static bool trans_##INSN(DisasContext *s, arg_shl_scalar *a) \ | ||
140 | + { \ | ||
141 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
142 | + gen_helper_mve_##FN##b, \ | ||
143 | + gen_helper_mve_##FN##h, \ | ||
144 | + gen_helper_mve_##FN##w, \ | ||
145 | + NULL, \ | ||
146 | + }; \ | ||
147 | + return do_2shift_scalar(s, a, fns[a->size]); \ | ||
148 | + } | ||
149 | + | ||
150 | +DO_2SHIFT_SCALAR(VSHL_S_scalar, vshli_s) | ||
151 | +DO_2SHIFT_SCALAR(VSHL_U_scalar, vshli_u) | ||
152 | +DO_2SHIFT_SCALAR(VRSHL_S_scalar, vrshli_s) | ||
153 | +DO_2SHIFT_SCALAR(VRSHL_U_scalar, vrshli_u) | ||
154 | +DO_2SHIFT_SCALAR(VQSHL_S_scalar, vqshli_s) | ||
155 | +DO_2SHIFT_SCALAR(VQSHL_U_scalar, vqshli_u) | ||
156 | +DO_2SHIFT_SCALAR(VQRSHL_S_scalar, vqrshli_s) | ||
157 | +DO_2SHIFT_SCALAR(VQRSHL_U_scalar, vqrshli_u) | ||
158 | + | ||
159 | #define DO_VSHLL(INSN, FN) \ | ||
160 | static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
161 | { \ | ||
162 | -- | ||
163 | 2.20.1 | ||
164 | |||
165 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | All the users of the vmlaldav formats have an 'x bit in bit 12 and an | ||
2 | 'a' bit in bit 5; move these to the format rather than specifying them | ||
3 | in each insn pattern. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | target/arm/mve.decode | 16 ++++++++-------- | ||
9 | 1 file changed, 8 insertions(+), 8 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/mve.decode | ||
14 | +++ b/target/arm/mve.decode | ||
15 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
16 | |||
17 | &vmlaldav rdahi rdalo size qn qm x a | ||
18 | |||
19 | -@vmlaldav .... .... . ... ... . ... . .... .... qm:3 . \ | ||
20 | +@vmlaldav .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
21 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav | ||
22 | -@vmlaldav_nosz .... .... . ... ... . ... . .... .... qm:3 . \ | ||
23 | +@vmlaldav_nosz .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
24 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=0 &vmlaldav | ||
25 | -VMLALDAV_S 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
26 | -VMLALDAV_U 1111 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
27 | +VMLALDAV_S 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
28 | +VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
29 | |||
30 | -VMLSLDAV 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav | ||
31 | +VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
32 | |||
33 | -VRMLALDAVH_S 1110 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz | ||
34 | -VRMLALDAVH_U 1111 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz | ||
35 | +VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
36 | +VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
37 | |||
38 | -VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_nosz | ||
39 | +VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | ||
40 | |||
41 | # Scalar operations | ||
42 | |||
43 | -- | ||
44 | 2.20.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE integer min/max across vector insns | ||
2 | VMAXV, VMINV, VMAXAV and VMINAV, which find the maximum | ||
3 | from the vector elements and a general purpose register, | ||
4 | and store the maximum back into the general purpose | ||
5 | register. | ||
6 | 1 | ||
7 | These insns overlap with VRMLALDAVH (they use what would | ||
8 | be RdaHi=0b110). | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | target/arm/helper-mve.h | 20 ++++++++++++ | ||
14 | target/arm/mve.decode | 18 +++++++++-- | ||
15 | target/arm/mve_helper.c | 66 ++++++++++++++++++++++++++++++++++++++ | ||
16 | target/arm/translate-mve.c | 48 +++++++++++++++++++++++++++ | ||
17 | 4 files changed, 150 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/helper-mve.h | ||
22 | +++ b/target/arm/helper-mve.h | ||
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
24 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
25 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
26 | |||
27 | +DEF_HELPER_FLAGS_3(mve_vmaxvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_3(mve_vmaxvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vmaxvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vmaxvub, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_3(mve_vmaxvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_3(mve_vmaxvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_3(mve_vmaxavb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vmaxavh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
35 | +DEF_HELPER_FLAGS_3(mve_vmaxavw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
36 | + | ||
37 | +DEF_HELPER_FLAGS_3(mve_vminvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_3(mve_vminvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_3(mve_vminvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_3(mve_vminvub, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vminvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
42 | +DEF_HELPER_FLAGS_3(mve_vminvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
43 | +DEF_HELPER_FLAGS_3(mve_vminavb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
44 | +DEF_HELPER_FLAGS_3(mve_vminavh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
45 | +DEF_HELPER_FLAGS_3(mve_vminavw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
46 | + | ||
47 | DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
48 | DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
49 | |||
50 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/mve.decode | ||
53 | +++ b/target/arm/mve.decode | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | &vcmp qm qn size mask | ||
56 | &vcmp_scalar qn rm size mask | ||
57 | &shl_scalar qda rm size | ||
58 | +&vmaxv qm rda size | ||
59 | |||
60 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
61 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
62 | @@ -XXX,XX +XXX,XX @@ | ||
63 | @vcmp_scalar .... .... .. size:2 qn:3 . .... .... .... rm:4 &vcmp_scalar \ | ||
64 | mask=%mask_22_13 | ||
65 | |||
66 | +@vmaxv .... .... .... size:2 .. rda:4 .... .... .... &vmaxv qm=%qm | ||
67 | + | ||
68 | # Vector loads and stores | ||
69 | |||
70 | # Widening loads and narrowing stores: | ||
71 | @@ -XXX,XX +XXX,XX @@ VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
72 | |||
73 | VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
74 | |||
75 | -VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
76 | -VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
77 | +{ | ||
78 | + VMAXV_S 1110 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
79 | + VMINV_S 1110 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
80 | + VMAXAV 1110 1110 1110 .. 00 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
81 | + VMINAV 1110 1110 1110 .. 00 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
82 | + VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
83 | +} | ||
84 | + | ||
85 | +{ | ||
86 | + VMAXV_U 1111 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
87 | + VMINV_U 1111 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
88 | + VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
89 | +} | ||
90 | |||
91 | VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | ||
92 | |||
93 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/mve_helper.c | ||
96 | +++ b/target/arm/mve_helper.c | ||
97 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvub, 1, uint8_t) | ||
98 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
99 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
100 | |||
101 | +/* | ||
102 | + * Vector max/min across vector. Unlike VADDV, we must | ||
103 | + * read ra as the element size, not its full width. | ||
104 | + * We work with int64_t internally for simplicity. | ||
105 | + */ | ||
106 | +#define DO_VMAXMINV(OP, ESIZE, TYPE, RATYPE, FN) \ | ||
107 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
108 | + uint32_t ra_in) \ | ||
109 | + { \ | ||
110 | + uint16_t mask = mve_element_mask(env); \ | ||
111 | + unsigned e; \ | ||
112 | + TYPE *m = vm; \ | ||
113 | + int64_t ra = (RATYPE)ra_in; \ | ||
114 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
115 | + if (mask & 1) { \ | ||
116 | + ra = FN(ra, m[H##ESIZE(e)]); \ | ||
117 | + } \ | ||
118 | + } \ | ||
119 | + mve_advance_vpt(env); \ | ||
120 | + return ra; \ | ||
121 | + } \ | ||
122 | + | ||
123 | +#define DO_VMAXMINV_U(INSN, FN) \ | ||
124 | + DO_VMAXMINV(INSN##b, 1, uint8_t, uint8_t, FN) \ | ||
125 | + DO_VMAXMINV(INSN##h, 2, uint16_t, uint16_t, FN) \ | ||
126 | + DO_VMAXMINV(INSN##w, 4, uint32_t, uint32_t, FN) | ||
127 | +#define DO_VMAXMINV_S(INSN, FN) \ | ||
128 | + DO_VMAXMINV(INSN##b, 1, int8_t, int8_t, FN) \ | ||
129 | + DO_VMAXMINV(INSN##h, 2, int16_t, int16_t, FN) \ | ||
130 | + DO_VMAXMINV(INSN##w, 4, int32_t, int32_t, FN) | ||
131 | + | ||
132 | +/* | ||
133 | + * Helpers for max and min of absolute values across vector: | ||
134 | + * note that we only take the absolute value of 'm', not 'n' | ||
135 | + */ | ||
136 | +static int64_t do_maxa(int64_t n, int64_t m) | ||
137 | +{ | ||
138 | + if (m < 0) { | ||
139 | + m = -m; | ||
140 | + } | ||
141 | + return MAX(n, m); | ||
142 | +} | ||
143 | + | ||
144 | +static int64_t do_mina(int64_t n, int64_t m) | ||
145 | +{ | ||
146 | + if (m < 0) { | ||
147 | + m = -m; | ||
148 | + } | ||
149 | + return MIN(n, m); | ||
150 | +} | ||
151 | + | ||
152 | +DO_VMAXMINV_S(vmaxvs, DO_MAX) | ||
153 | +DO_VMAXMINV_U(vmaxvu, DO_MAX) | ||
154 | +DO_VMAXMINV_S(vminvs, DO_MIN) | ||
155 | +DO_VMAXMINV_U(vminvu, DO_MIN) | ||
156 | +/* | ||
157 | + * VMAXAV, VMINAV treat the general purpose input as unsigned | ||
158 | + * and the vector elements as signed. | ||
159 | + */ | ||
160 | +DO_VMAXMINV(vmaxavb, 1, int8_t, uint8_t, do_maxa) | ||
161 | +DO_VMAXMINV(vmaxavh, 2, int16_t, uint16_t, do_maxa) | ||
162 | +DO_VMAXMINV(vmaxavw, 4, int32_t, uint32_t, do_maxa) | ||
163 | +DO_VMAXMINV(vminavb, 1, int8_t, uint8_t, do_mina) | ||
164 | +DO_VMAXMINV(vminavh, 2, int16_t, uint16_t, do_mina) | ||
165 | +DO_VMAXMINV(vminavw, 4, int32_t, uint32_t, do_mina) | ||
166 | + | ||
167 | #define DO_VADDLV(OP, TYPE, LTYPE) \ | ||
168 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
169 | uint64_t ra) \ | ||
170 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
171 | index XXXXXXX..XXXXXXX 100644 | ||
172 | --- a/target/arm/translate-mve.c | ||
173 | +++ b/target/arm/translate-mve.c | ||
174 | @@ -XXX,XX +XXX,XX @@ DO_VCMP(VCMPGE, vcmpge) | ||
175 | DO_VCMP(VCMPLT, vcmplt) | ||
176 | DO_VCMP(VCMPGT, vcmpgt) | ||
177 | DO_VCMP(VCMPLE, vcmple) | ||
178 | + | ||
179 | +static bool do_vmaxv(DisasContext *s, arg_vmaxv *a, MVEGenVADDVFn fn) | ||
180 | +{ | ||
181 | + /* | ||
182 | + * MIN/MAX operations across a vector: compute the min or | ||
183 | + * max of the initial value in a general purpose register | ||
184 | + * and all the elements in the vector, and store it back | ||
185 | + * into the general purpose register. | ||
186 | + */ | ||
187 | + TCGv_ptr qm; | ||
188 | + TCGv_i32 rda; | ||
189 | + | ||
190 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qm) || | ||
191 | + !fn || a->rda == 13 || a->rda == 15) { | ||
192 | + /* Rda cases are UNPREDICTABLE */ | ||
193 | + return false; | ||
194 | + } | ||
195 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
196 | + return true; | ||
197 | + } | ||
198 | + | ||
199 | + qm = mve_qreg_ptr(a->qm); | ||
200 | + rda = load_reg(s, a->rda); | ||
201 | + fn(rda, cpu_env, qm, rda); | ||
202 | + store_reg(s, a->rda, rda); | ||
203 | + tcg_temp_free_ptr(qm); | ||
204 | + mve_update_eci(s); | ||
205 | + return true; | ||
206 | +} | ||
207 | + | ||
208 | +#define DO_VMAXV(INSN, FN) \ | ||
209 | + static bool trans_##INSN(DisasContext *s, arg_vmaxv *a) \ | ||
210 | + { \ | ||
211 | + static MVEGenVADDVFn * const fns[] = { \ | ||
212 | + gen_helper_mve_##FN##b, \ | ||
213 | + gen_helper_mve_##FN##h, \ | ||
214 | + gen_helper_mve_##FN##w, \ | ||
215 | + NULL, \ | ||
216 | + }; \ | ||
217 | + return do_vmaxv(s, a, fns[a->size]); \ | ||
218 | + } | ||
219 | + | ||
220 | +DO_VMAXV(VMAXV_S, vmaxvs) | ||
221 | +DO_VMAXV(VMAXV_U, vmaxvu) | ||
222 | +DO_VMAXV(VMAXAV, vmaxav) | ||
223 | +DO_VMAXV(VMINV_S, vminvs) | ||
224 | +DO_VMAXV(VMINV_U, vminvu) | ||
225 | +DO_VMAXV(VMINAV, vminav) | ||
226 | -- | ||
227 | 2.20.1 | ||
228 | |||
229 | diff view generated by jsdifflib |
1 | Implement the MVE saturating doubling multiply accumulate insns | 1 | The architecture requires (R_TYTWB) that an attempt to return from EL3 |
---|---|---|---|
2 | VQDMLAH, VQRDMLAH, VQDMLASH and VQRDMLASH. These perform a multiply, | 2 | when SCR_EL3.{NSE,NS} are {1,0} is an illegal exception return. (This |
3 | double, add the accumulator shifted by the element size, possibly | 3 | enforces that the CPU can't ever be executing below EL3 with the |
4 | round, saturate to twice the element size, then take the high half of | 4 | NSE,NS bits indicating an invalid security state.) |
5 | the result. The *MLAH insns do vector * scalar + vector, and the | 5 | |
6 | *MLASH insns do vector * vector + scalar. | 6 | We were missing this check; add it. |
7 | 7 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20230807150618.101357-1-peter.maydell@linaro.org | ||
10 | --- | 11 | --- |
11 | target/arm/helper-mve.h | 16 +++++++ | 12 | target/arm/tcg/helper-a64.c | 9 +++++++++ |
12 | target/arm/mve.decode | 5 ++ | 13 | 1 file changed, 9 insertions(+) |
13 | target/arm/mve_helper.c | 95 ++++++++++++++++++++++++++++++++++++++ | ||
14 | target/arm/translate-mve.c | 4 ++ | ||
15 | 4 files changed, 120 insertions(+) | ||
16 | 14 | ||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 15 | diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper-mve.h | 17 | --- a/target/arm/tcg/helper-a64.c |
20 | +++ b/target/arm/helper-mve.h | 18 | +++ b/target/arm/tcg/helper-a64.c |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) |
22 | DEF_HELPER_FLAGS_4(mve_vmlash, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 20 | spsr &= ~PSTATE_SS; |
23 | DEF_HELPER_FLAGS_4(mve_vmlasw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | |||
25 | +DEF_HELPER_FLAGS_4(mve_vqdmlahb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vqdmlahh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vqdmlahw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | + | ||
29 | +DEF_HELPER_FLAGS_4(mve_vqrdmlahb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vqrdmlahh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqrdmlahw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | + | ||
33 | +DEF_HELPER_FLAGS_4(mve_vqdmlashb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vqdmlashh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vqdmlashw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | + | ||
37 | +DEF_HELPER_FLAGS_4(mve_vqrdmlashb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(mve_vqrdmlashh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(mve_vqrdmlashw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | + | ||
41 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
42 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
43 | DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
44 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/mve.decode | ||
47 | +++ b/target/arm/mve.decode | ||
48 | @@ -XXX,XX +XXX,XX @@ VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
49 | VMLA 111- 1110 0 . .. ... 1 ... 0 1110 . 100 .... @2scalar | ||
50 | VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
51 | |||
52 | +VQRDMLAH 1110 1110 0 . .. ... 0 ... 0 1110 . 100 .... @2scalar | ||
53 | +VQRDMLASH 1110 1110 0 . .. ... 0 ... 1 1110 . 100 .... @2scalar | ||
54 | +VQDMLAH 1110 1110 0 . .. ... 0 ... 0 1110 . 110 .... @2scalar | ||
55 | +VQDMLASH 1110 1110 0 . .. ... 0 ... 1 1110 . 110 .... @2scalar | ||
56 | + | ||
57 | # Vector add across vector | ||
58 | { | ||
59 | VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
60 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/mve_helper.c | ||
63 | +++ b/target/arm/mve_helper.c | ||
64 | @@ -XXX,XX +XXX,XX @@ DO_VQDMLADH_OP(vqrdmlsdhxw, 4, int32_t, 1, 1, do_vqdmlsdh_w) | ||
65 | mve_advance_vpt(env); \ | ||
66 | } | 21 | } |
67 | 22 | ||
68 | +#define DO_2OP_SAT_ACC_SCALAR(OP, ESIZE, TYPE, FN) \ | 23 | + /* |
69 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | 24 | + * FEAT_RME forbids return from EL3 with an invalid security state. |
70 | + uint32_t rm) \ | 25 | + * We don't need an explicit check for FEAT_RME here because we enforce |
71 | + { \ | 26 | + * in scr_write() that you can't set the NSE bit without it. |
72 | + TYPE *d = vd, *n = vn; \ | 27 | + */ |
73 | + TYPE m = rm; \ | 28 | + if (cur_el == 3 && (env->cp15.scr_el3 & (SCR_NS | SCR_NSE)) == SCR_NSE) { |
74 | + uint16_t mask = mve_element_mask(env); \ | 29 | + goto illegal_return; |
75 | + unsigned e; \ | ||
76 | + bool qc = false; \ | ||
77 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
78 | + bool sat = false; \ | ||
79 | + mergemask(&d[H##ESIZE(e)], \ | ||
80 | + FN(d[H##ESIZE(e)], n[H##ESIZE(e)], m, &sat), \ | ||
81 | + mask); \ | ||
82 | + qc |= sat & mask & 1; \ | ||
83 | + } \ | ||
84 | + if (qc) { \ | ||
85 | + env->vfp.qc[0] = qc; \ | ||
86 | + } \ | ||
87 | + mve_advance_vpt(env); \ | ||
88 | + } | 30 | + } |
89 | + | 31 | + |
90 | /* provide unsigned 2-op scalar helpers for all sizes */ | 32 | new_el = el_from_spsr(spsr); |
91 | #define DO_2OP_SCALAR_U(OP, FN) \ | 33 | if (new_el == -1) { |
92 | DO_2OP_SCALAR(OP##b, 1, uint8_t, FN) \ | 34 | goto illegal_return; |
93 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) | ||
94 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) | ||
95 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W) | ||
96 | |||
97 | +static int8_t do_vqdmlah_b(int8_t a, int8_t b, int8_t c, int round, bool *sat) | ||
98 | +{ | ||
99 | + int64_t r = (int64_t)a * b * 2 + ((int64_t)c << 8) + (round << 7); | ||
100 | + return do_sat_bhw(r, INT16_MIN, INT16_MAX, sat) >> 8; | ||
101 | +} | ||
102 | + | ||
103 | +static int16_t do_vqdmlah_h(int16_t a, int16_t b, int16_t c, | ||
104 | + int round, bool *sat) | ||
105 | +{ | ||
106 | + int64_t r = (int64_t)a * b * 2 + ((int64_t)c << 16) + (round << 15); | ||
107 | + return do_sat_bhw(r, INT32_MIN, INT32_MAX, sat) >> 16; | ||
108 | +} | ||
109 | + | ||
110 | +static int32_t do_vqdmlah_w(int32_t a, int32_t b, int32_t c, | ||
111 | + int round, bool *sat) | ||
112 | +{ | ||
113 | + /* | ||
114 | + * Architecturally we should do the entire add, double, round | ||
115 | + * and then check for saturation. We do three saturating adds, | ||
116 | + * but we need to be careful about the order. If the first | ||
117 | + * m1 + m2 saturates then it's impossible for the *2+rc to | ||
118 | + * bring it back into the non-saturated range. However, if | ||
119 | + * m1 + m2 is negative then it's possible that doing the doubling | ||
120 | + * would take the intermediate result below INT64_MAX and the | ||
121 | + * addition of the rounding constant then brings it back in range. | ||
122 | + * So we add half the rounding constant and half the "c << esize" | ||
123 | + * before doubling rather than adding the rounding constant after | ||
124 | + * the doubling. | ||
125 | + */ | ||
126 | + int64_t m1 = (int64_t)a * b; | ||
127 | + int64_t m2 = (int64_t)c << 31; | ||
128 | + int64_t r; | ||
129 | + if (sadd64_overflow(m1, m2, &r) || | ||
130 | + sadd64_overflow(r, (round << 30), &r) || | ||
131 | + sadd64_overflow(r, r, &r)) { | ||
132 | + *sat = true; | ||
133 | + return r < 0 ? INT32_MAX : INT32_MIN; | ||
134 | + } | ||
135 | + return r >> 32; | ||
136 | +} | ||
137 | + | ||
138 | +/* | ||
139 | + * The *MLAH insns are vector * scalar + vector; | ||
140 | + * the *MLASH insns are vector * vector + scalar | ||
141 | + */ | ||
142 | +#define DO_VQDMLAH_B(D, N, M, S) do_vqdmlah_b(N, M, D, 0, S) | ||
143 | +#define DO_VQDMLAH_H(D, N, M, S) do_vqdmlah_h(N, M, D, 0, S) | ||
144 | +#define DO_VQDMLAH_W(D, N, M, S) do_vqdmlah_w(N, M, D, 0, S) | ||
145 | +#define DO_VQRDMLAH_B(D, N, M, S) do_vqdmlah_b(N, M, D, 1, S) | ||
146 | +#define DO_VQRDMLAH_H(D, N, M, S) do_vqdmlah_h(N, M, D, 1, S) | ||
147 | +#define DO_VQRDMLAH_W(D, N, M, S) do_vqdmlah_w(N, M, D, 1, S) | ||
148 | + | ||
149 | +#define DO_VQDMLASH_B(D, N, M, S) do_vqdmlah_b(N, D, M, 0, S) | ||
150 | +#define DO_VQDMLASH_H(D, N, M, S) do_vqdmlah_h(N, D, M, 0, S) | ||
151 | +#define DO_VQDMLASH_W(D, N, M, S) do_vqdmlah_w(N, D, M, 0, S) | ||
152 | +#define DO_VQRDMLASH_B(D, N, M, S) do_vqdmlah_b(N, D, M, 1, S) | ||
153 | +#define DO_VQRDMLASH_H(D, N, M, S) do_vqdmlah_h(N, D, M, 1, S) | ||
154 | +#define DO_VQRDMLASH_W(D, N, M, S) do_vqdmlah_w(N, D, M, 1, S) | ||
155 | + | ||
156 | +DO_2OP_SAT_ACC_SCALAR(vqdmlahb, 1, int8_t, DO_VQDMLAH_B) | ||
157 | +DO_2OP_SAT_ACC_SCALAR(vqdmlahh, 2, int16_t, DO_VQDMLAH_H) | ||
158 | +DO_2OP_SAT_ACC_SCALAR(vqdmlahw, 4, int32_t, DO_VQDMLAH_W) | ||
159 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlahb, 1, int8_t, DO_VQRDMLAH_B) | ||
160 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlahh, 2, int16_t, DO_VQRDMLAH_H) | ||
161 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlahw, 4, int32_t, DO_VQRDMLAH_W) | ||
162 | + | ||
163 | +DO_2OP_SAT_ACC_SCALAR(vqdmlashb, 1, int8_t, DO_VQDMLASH_B) | ||
164 | +DO_2OP_SAT_ACC_SCALAR(vqdmlashh, 2, int16_t, DO_VQDMLASH_H) | ||
165 | +DO_2OP_SAT_ACC_SCALAR(vqdmlashw, 4, int32_t, DO_VQDMLASH_W) | ||
166 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlashb, 1, int8_t, DO_VQRDMLASH_B) | ||
167 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlashh, 2, int16_t, DO_VQRDMLASH_H) | ||
168 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlashw, 4, int32_t, DO_VQRDMLASH_W) | ||
169 | + | ||
170 | /* Vector by scalar plus vector */ | ||
171 | #define DO_VMLA(D, N, M) ((N) * (M) + (D)) | ||
172 | |||
173 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
174 | index XXXXXXX..XXXXXXX 100644 | ||
175 | --- a/target/arm/translate-mve.c | ||
176 | +++ b/target/arm/translate-mve.c | ||
177 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) | ||
178 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
179 | DO_2OP_SCALAR(VMLA, vmla) | ||
180 | DO_2OP_SCALAR(VMLAS, vmlas) | ||
181 | +DO_2OP_SCALAR(VQDMLAH, vqdmlah) | ||
182 | +DO_2OP_SCALAR(VQRDMLAH, vqrdmlah) | ||
183 | +DO_2OP_SCALAR(VQDMLASH, vqdmlash) | ||
184 | +DO_2OP_SCALAR(VQRDMLASH, vqrdmlash) | ||
185 | |||
186 | static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a) | ||
187 | { | ||
188 | -- | 35 | -- |
189 | 2.20.1 | 36 | 2.34.1 |
190 | |||
191 | diff view generated by jsdifflib |
1 | Implement the MVE VCTP insn, which sets the VPR.P0 predicate bits so | 1 | In the m48t59 device we almost always use 64-bit arithmetic when |
---|---|---|---|
2 | as to predicate any element at index Rn or greater is predicated. As | 2 | dealing with time_t deltas. The one exception is in set_alarm(), |
3 | with VPNOT, this insn itself is predicable and subject to beatwise | 3 | which currently uses a plain 'int' to hold the difference between two |
4 | execution. | 4 | time_t values. Switch to int64_t instead to avoid any possible |
5 | 5 | overflow issues. | |
6 | The calculation of the mask is the same as is used to determine | ||
7 | ltpmask in mve_element_mask(), but we precalculate masklen in | ||
8 | generated code to avoid having to have 4 helpers specialized by size. | ||
9 | |||
10 | We put the decode line in with the low-overhead-loop insns in | ||
11 | t32.decode because it's logically part of that collection of insn | ||
12 | patterns, even though it is an MVE only insn. | ||
13 | 6 | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
16 | --- | 9 | --- |
17 | target/arm/helper-mve.h | 2 ++ | 10 | hw/rtc/m48t59.c | 2 +- |
18 | target/arm/translate-a32.h | 1 + | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
19 | target/arm/t32.decode | 1 + | ||
20 | target/arm/mve_helper.c | 20 ++++++++++++++++++++ | ||
21 | target/arm/translate-mve.c | 2 +- | ||
22 | target/arm/translate.c | 33 +++++++++++++++++++++++++++++++++ | ||
23 | 6 files changed, 58 insertions(+), 1 deletion(-) | ||
24 | 12 | ||
25 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 13 | diff --git a/hw/rtc/m48t59.c b/hw/rtc/m48t59.c |
26 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/helper-mve.h | 15 | --- a/hw/rtc/m48t59.c |
28 | +++ b/target/arm/helper-mve.h | 16 | +++ b/hw/rtc/m48t59.c |
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 17 | @@ -XXX,XX +XXX,XX @@ static void alarm_cb (void *opaque) |
30 | DEF_HELPER_FLAGS_4(mve_vpsel, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 18 | |
31 | DEF_HELPER_FLAGS_1(mve_vpnot, TCG_CALL_NO_WG, void, env) | 19 | static void set_alarm(M48t59State *NVRAM) |
32 | |||
33 | +DEF_HELPER_FLAGS_2(mve_vctp, TCG_CALL_NO_WG, void, env, i32) | ||
34 | + | ||
35 | DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
36 | DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
37 | DEF_HELPER_FLAGS_4(mve_vaddw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
38 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/translate-a32.h | ||
41 | +++ b/target/arm/translate-a32.h | ||
42 | @@ -XXX,XX +XXX,XX @@ long neon_element_offset(int reg, int element, MemOp memop); | ||
43 | void gen_rev16(TCGv_i32 dest, TCGv_i32 var); | ||
44 | void clear_eci_state(DisasContext *s); | ||
45 | bool mve_eci_check(DisasContext *s); | ||
46 | +void mve_update_eci(DisasContext *s); | ||
47 | void mve_update_and_store_eci(DisasContext *s); | ||
48 | bool mve_skip_vmov(DisasContext *s, int vn, int index, int size); | ||
49 | |||
50 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/t32.decode | ||
53 | +++ b/target/arm/t32.decode | ||
54 | @@ -XXX,XX +XXX,XX @@ BL 1111 0. .......... 11.1 ............ @branch24 | ||
55 | # This is DLSTP | ||
56 | DLS 1111 0 0000 0 size:2 rn:4 1110 0000 0000 0001 | ||
57 | } | ||
58 | + VCTP 1111 0 0000 0 size:2 rn:4 1110 1000 0000 0001 | ||
59 | ] | ||
60 | } | ||
61 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/mve_helper.c | ||
64 | +++ b/target/arm/mve_helper.c | ||
65 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vpnot)(CPUARMState *env) | ||
66 | mve_advance_vpt(env); | ||
67 | } | ||
68 | |||
69 | +/* | ||
70 | + * VCTP: P0 unexecuted bits unchanged, predicated bits zeroed, | ||
71 | + * otherwise set according to value of Rn. The calculation of | ||
72 | + * newmask here works in the same way as the calculation of the | ||
73 | + * ltpmask in mve_element_mask(), but we have pre-calculated | ||
74 | + * the masklen in the generated code. | ||
75 | + */ | ||
76 | +void HELPER(mve_vctp)(CPUARMState *env, uint32_t masklen) | ||
77 | +{ | ||
78 | + uint16_t mask = mve_element_mask(env); | ||
79 | + uint16_t eci_mask = mve_eci_mask(env); | ||
80 | + uint16_t newmask; | ||
81 | + | ||
82 | + assert(masklen <= 16); | ||
83 | + newmask = masklen ? MAKE_64BIT_MASK(0, masklen) : 0; | ||
84 | + newmask &= mask; | ||
85 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | (newmask & eci_mask); | ||
86 | + mve_advance_vpt(env); | ||
87 | +} | ||
88 | + | ||
89 | #define DO_1OP_SAT(OP, ESIZE, TYPE, FN) \ | ||
90 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
91 | { \ | ||
92 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/translate-mve.c | ||
95 | +++ b/target/arm/translate-mve.c | ||
96 | @@ -XXX,XX +XXX,XX @@ bool mve_eci_check(DisasContext *s) | ||
97 | } | ||
98 | } | ||
99 | |||
100 | -static void mve_update_eci(DisasContext *s) | ||
101 | +void mve_update_eci(DisasContext *s) | ||
102 | { | 20 | { |
103 | /* | 21 | - int diff; |
104 | * The helper function will always update the CPUState field, | 22 | + int64_t diff; |
105 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 23 | if (NVRAM->alrm_timer != NULL) { |
106 | index XXXXXXX..XXXXXXX 100644 | 24 | timer_del(NVRAM->alrm_timer); |
107 | --- a/target/arm/translate.c | 25 | diff = qemu_timedate_diff(&NVRAM->alarm) - NVRAM->time_offset; |
108 | +++ b/target/arm/translate.c | ||
109 | @@ -XXX,XX +XXX,XX @@ static bool trans_LCTP(DisasContext *s, arg_LCTP *a) | ||
110 | return true; | ||
111 | } | ||
112 | |||
113 | +static bool trans_VCTP(DisasContext *s, arg_VCTP *a) | ||
114 | +{ | ||
115 | + /* | ||
116 | + * M-profile Create Vector Tail Predicate. This insn is itself | ||
117 | + * predicated and is subject to beatwise execution. | ||
118 | + */ | ||
119 | + TCGv_i32 rn_shifted, masklen; | ||
120 | + | ||
121 | + if (!dc_isar_feature(aa32_mve, s) || a->rn == 13 || a->rn == 15) { | ||
122 | + return false; | ||
123 | + } | ||
124 | + | ||
125 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
126 | + return true; | ||
127 | + } | ||
128 | + | ||
129 | + /* | ||
130 | + * We pre-calculate the mask length here to avoid having | ||
131 | + * to have multiple helpers specialized for size. | ||
132 | + * We pass the helper "rn <= (1 << (4 - size)) ? (rn << size) : 16". | ||
133 | + */ | ||
134 | + rn_shifted = tcg_temp_new_i32(); | ||
135 | + masklen = load_reg(s, a->rn); | ||
136 | + tcg_gen_shli_i32(rn_shifted, masklen, a->size); | ||
137 | + tcg_gen_movcond_i32(TCG_COND_LEU, masklen, | ||
138 | + masklen, tcg_constant_i32(1 << (4 - a->size)), | ||
139 | + rn_shifted, tcg_constant_i32(16)); | ||
140 | + gen_helper_mve_vctp(cpu_env, masklen); | ||
141 | + tcg_temp_free_i32(masklen); | ||
142 | + tcg_temp_free_i32(rn_shifted); | ||
143 | + mve_update_eci(s); | ||
144 | + return true; | ||
145 | +} | ||
146 | |||
147 | static bool op_tbranch(DisasContext *s, arg_tbranch *a, bool half) | ||
148 | { | ||
149 | -- | 26 | -- |
150 | 2.20.1 | 27 | 2.34.1 |
151 | 28 | ||
152 | 29 | diff view generated by jsdifflib |
1 | Implement the MVE VPNOT insn, which inverts the bits in VPR.P0 | 1 | In the twl92230 device, use int64_t for the two state fields |
---|---|---|---|
2 | (subject to both predication and to beatwise execution). | 2 | sec_offset and alm_sec, because we set these to values that |
3 | are either time_t or differences between two time_t values. | ||
4 | |||
5 | These fields aren't saved in vmstate anywhere, so we can | ||
6 | safely widen them. | ||
3 | 7 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | --- | 10 | --- |
7 | target/arm/helper-mve.h | 1 + | 11 | hw/rtc/twl92230.c | 4 ++-- |
8 | target/arm/mve.decode | 1 + | 12 | 1 file changed, 2 insertions(+), 2 deletions(-) |
9 | target/arm/mve_helper.c | 17 +++++++++++++++++ | ||
10 | target/arm/translate-mve.c | 19 +++++++++++++++++++ | ||
11 | 4 files changed, 38 insertions(+) | ||
12 | 13 | ||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 14 | diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper-mve.h | 16 | --- a/hw/rtc/twl92230.c |
16 | +++ b/target/arm/helper-mve.h | 17 | +++ b/hw/rtc/twl92230.c |
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 18 | @@ -XXX,XX +XXX,XX @@ struct MenelausState { |
18 | DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 19 | struct tm tm; |
19 | 20 | struct tm new; | |
20 | DEF_HELPER_FLAGS_4(mve_vpsel, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 21 | struct tm alm; |
21 | +DEF_HELPER_FLAGS_1(mve_vpnot, TCG_CALL_NO_WG, void, env) | 22 | - int sec_offset; |
22 | 23 | - int alm_sec; | |
23 | DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 24 | + int64_t sec_offset; |
24 | DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 25 | + int64_t alm_sec; |
25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 26 | int next_comp; |
26 | index XXXXXXX..XXXXXXX 100644 | 27 | } rtc; |
27 | --- a/target/arm/mve.decode | 28 | uint16_t rtc_next_vmstate; |
28 | +++ b/target/arm/mve.decode | ||
29 | @@ -XXX,XX +XXX,XX @@ VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
30 | VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | ||
31 | |||
32 | { | ||
33 | + VPNOT 1111 1110 0 0 11 000 1 000 0 1111 0100 1101 | ||
34 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
35 | VCMPEQ_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 0 0 .... @vcmp_scalar | ||
36 | } | ||
37 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/mve_helper.c | ||
40 | +++ b/target/arm/mve_helper.c | ||
41 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vpsel)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
42 | mve_advance_vpt(env); | ||
43 | } | ||
44 | |||
45 | +void HELPER(mve_vpnot)(CPUARMState *env) | ||
46 | +{ | ||
47 | + /* | ||
48 | + * P0 bits for unexecuted beats (where eci_mask is 0) are unchanged. | ||
49 | + * P0 bits for predicated lanes in executed bits (where mask is 0) are 0. | ||
50 | + * P0 bits otherwise are inverted. | ||
51 | + * (This is the same logic as VCMP.) | ||
52 | + * This insn is itself subject to predication and to beat-wise execution, | ||
53 | + * and after it executes VPT state advances in the usual way. | ||
54 | + */ | ||
55 | + uint16_t mask = mve_element_mask(env); | ||
56 | + uint16_t eci_mask = mve_eci_mask(env); | ||
57 | + uint16_t beatpred = ~env->v7m.vpr & mask; | ||
58 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | (beatpred & eci_mask); | ||
59 | + mve_advance_vpt(env); | ||
60 | +} | ||
61 | + | ||
62 | #define DO_1OP_SAT(OP, ESIZE, TYPE, FN) \ | ||
63 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
64 | { \ | ||
65 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/arm/translate-mve.c | ||
68 | +++ b/target/arm/translate-mve.c | ||
69 | @@ -XXX,XX +XXX,XX @@ static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
70 | return true; | ||
71 | } | ||
72 | |||
73 | +static bool trans_VPNOT(DisasContext *s, arg_VPNOT *a) | ||
74 | +{ | ||
75 | + /* | ||
76 | + * Invert the predicate in VPR.P0. We have call out to | ||
77 | + * a helper because this insn itself is beatwise and can | ||
78 | + * be predicated. | ||
79 | + */ | ||
80 | + if (!dc_isar_feature(aa32_mve, s)) { | ||
81 | + return false; | ||
82 | + } | ||
83 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
84 | + return true; | ||
85 | + } | ||
86 | + | ||
87 | + gen_helper_mve_vpnot(cpu_env); | ||
88 | + mve_update_eci(s); | ||
89 | + return true; | ||
90 | +} | ||
91 | + | ||
92 | static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | ||
93 | { | ||
94 | /* VADDV: vector add across vector */ | ||
95 | -- | 29 | -- |
96 | 2.20.1 | 30 | 2.34.1 |
97 | 31 | ||
98 | 32 | diff view generated by jsdifflib |
1 | Implement the MVE VMOV forms that move data between 2 general-purpose | 1 | In the aspeed_rtc device we store a difference between two time_t |
---|---|---|---|
2 | registers and 2 32-bit lanes in a vector register. | 2 | values in an 'int'. This is not really correct when time_t could |
3 | be 64 bits. Enlarge the field to 'int64_t'. | ||
4 | |||
5 | This is a migration compatibility break for the aspeed boards. | ||
6 | While we are changing the vmstate, remove the accidental | ||
7 | duplicate of the offset field. | ||
3 | 8 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
6 | --- | 11 | --- |
7 | target/arm/translate-a32.h | 1 + | 12 | include/hw/rtc/aspeed_rtc.h | 2 +- |
8 | target/arm/mve.decode | 4 ++ | 13 | hw/rtc/aspeed_rtc.c | 5 ++--- |
9 | target/arm/translate-mve.c | 85 ++++++++++++++++++++++++++++++++++++++ | 14 | 2 files changed, 3 insertions(+), 4 deletions(-) |
10 | target/arm/translate-vfp.c | 2 +- | ||
11 | 4 files changed, 91 insertions(+), 1 deletion(-) | ||
12 | 15 | ||
13 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h | 16 | diff --git a/include/hw/rtc/aspeed_rtc.h b/include/hw/rtc/aspeed_rtc.h |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate-a32.h | 18 | --- a/include/hw/rtc/aspeed_rtc.h |
16 | +++ b/target/arm/translate-a32.h | 19 | +++ b/include/hw/rtc/aspeed_rtc.h |
17 | @@ -XXX,XX +XXX,XX @@ void gen_rev16(TCGv_i32 dest, TCGv_i32 var); | 20 | @@ -XXX,XX +XXX,XX @@ struct AspeedRtcState { |
18 | void clear_eci_state(DisasContext *s); | 21 | qemu_irq irq; |
19 | bool mve_eci_check(DisasContext *s); | 22 | |
20 | void mve_update_and_store_eci(DisasContext *s); | 23 | uint32_t reg[0x18]; |
21 | +bool mve_skip_vmov(DisasContext *s, int vn, int index, int size); | 24 | - int offset; |
22 | 25 | + int64_t offset; | |
23 | static inline TCGv_i32 load_cpu_offset(int offset) | 26 | |
24 | { | 27 | }; |
25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 28 | |
29 | diff --git a/hw/rtc/aspeed_rtc.c b/hw/rtc/aspeed_rtc.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/mve.decode | 31 | --- a/hw/rtc/aspeed_rtc.c |
28 | +++ b/target/arm/mve.decode | 32 | +++ b/hw/rtc/aspeed_rtc.c |
29 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ | 33 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_rtc_ops = { |
30 | VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ | 34 | |
31 | size=2 p=1 | 35 | static const VMStateDescription vmstate_aspeed_rtc = { |
32 | 36 | .name = TYPE_ASPEED_RTC, | |
33 | +# Moves between 2 32-bit vector lanes and 2 general purpose registers | 37 | - .version_id = 1, |
34 | +VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | 38 | + .version_id = 2, |
35 | +VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | 39 | .fields = (VMStateField[]) { |
36 | + | 40 | VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18), |
37 | # Vector 2-op | 41 | - VMSTATE_INT32(offset, AspeedRtcState), |
38 | VAND 1110 1111 0 . 00 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | 42 | - VMSTATE_INT32(offset, AspeedRtcState), |
39 | VBIC 1110 1111 0 . 01 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | 43 | + VMSTATE_INT64(offset, AspeedRtcState), |
40 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 44 | VMSTATE_END_OF_LIST() |
41 | index XXXXXXX..XXXXXXX 100644 | 45 | } |
42 | --- a/target/arm/translate-mve.c | 46 | }; |
43 | +++ b/target/arm/translate-mve.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool do_vabav(DisasContext *s, arg_vabav *a, MVEGenVABAVFn *fn) | ||
45 | |||
46 | DO_VABAV(VABAV_S, vabavs) | ||
47 | DO_VABAV(VABAV_U, vabavu) | ||
48 | + | ||
49 | +static bool trans_VMOV_to_2gp(DisasContext *s, arg_VMOV_to_2gp *a) | ||
50 | +{ | ||
51 | + /* | ||
52 | + * VMOV two 32-bit vector lanes to two general-purpose registers. | ||
53 | + * This insn is not predicated but it is subject to beat-wise | ||
54 | + * execution if it is not in an IT block. For us this means | ||
55 | + * only that if PSR.ECI says we should not be executing the beat | ||
56 | + * corresponding to the lane of the vector register being accessed | ||
57 | + * then we should skip perfoming the move, and that we need to do | ||
58 | + * the usual check for bad ECI state and advance of ECI state. | ||
59 | + * (If PSR.ECI is non-zero then we cannot be in an IT block.) | ||
60 | + */ | ||
61 | + TCGv_i32 tmp; | ||
62 | + int vd; | ||
63 | + | ||
64 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd) || | ||
65 | + a->rt == 13 || a->rt == 15 || a->rt2 == 13 || a->rt2 == 15 || | ||
66 | + a->rt == a->rt2) { | ||
67 | + /* Rt/Rt2 cases are UNPREDICTABLE */ | ||
68 | + return false; | ||
69 | + } | ||
70 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + | ||
74 | + /* Convert Qreg index to Dreg for read_neon_element32() etc */ | ||
75 | + vd = a->qd * 2; | ||
76 | + | ||
77 | + if (!mve_skip_vmov(s, vd, a->idx, MO_32)) { | ||
78 | + tmp = tcg_temp_new_i32(); | ||
79 | + read_neon_element32(tmp, vd, a->idx, MO_32); | ||
80 | + store_reg(s, a->rt, tmp); | ||
81 | + } | ||
82 | + if (!mve_skip_vmov(s, vd + 1, a->idx, MO_32)) { | ||
83 | + tmp = tcg_temp_new_i32(); | ||
84 | + read_neon_element32(tmp, vd + 1, a->idx, MO_32); | ||
85 | + store_reg(s, a->rt2, tmp); | ||
86 | + } | ||
87 | + | ||
88 | + mve_update_and_store_eci(s); | ||
89 | + return true; | ||
90 | +} | ||
91 | + | ||
92 | +static bool trans_VMOV_from_2gp(DisasContext *s, arg_VMOV_to_2gp *a) | ||
93 | +{ | ||
94 | + /* | ||
95 | + * VMOV two general-purpose registers to two 32-bit vector lanes. | ||
96 | + * This insn is not predicated but it is subject to beat-wise | ||
97 | + * execution if it is not in an IT block. For us this means | ||
98 | + * only that if PSR.ECI says we should not be executing the beat | ||
99 | + * corresponding to the lane of the vector register being accessed | ||
100 | + * then we should skip perfoming the move, and that we need to do | ||
101 | + * the usual check for bad ECI state and advance of ECI state. | ||
102 | + * (If PSR.ECI is non-zero then we cannot be in an IT block.) | ||
103 | + */ | ||
104 | + TCGv_i32 tmp; | ||
105 | + int vd; | ||
106 | + | ||
107 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd) || | ||
108 | + a->rt == 13 || a->rt == 15 || a->rt2 == 13 || a->rt2 == 15) { | ||
109 | + /* Rt/Rt2 cases are UNPREDICTABLE */ | ||
110 | + return false; | ||
111 | + } | ||
112 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
113 | + return true; | ||
114 | + } | ||
115 | + | ||
116 | + /* Convert Qreg idx to Dreg for read_neon_element32() etc */ | ||
117 | + vd = a->qd * 2; | ||
118 | + | ||
119 | + if (!mve_skip_vmov(s, vd, a->idx, MO_32)) { | ||
120 | + tmp = load_reg(s, a->rt); | ||
121 | + write_neon_element32(tmp, vd, a->idx, MO_32); | ||
122 | + tcg_temp_free_i32(tmp); | ||
123 | + } | ||
124 | + if (!mve_skip_vmov(s, vd + 1, a->idx, MO_32)) { | ||
125 | + tmp = load_reg(s, a->rt2); | ||
126 | + write_neon_element32(tmp, vd + 1, a->idx, MO_32); | ||
127 | + tcg_temp_free_i32(tmp); | ||
128 | + } | ||
129 | + | ||
130 | + mve_update_and_store_eci(s); | ||
131 | + return true; | ||
132 | +} | ||
133 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/target/arm/translate-vfp.c | ||
136 | +++ b/target/arm/translate-vfp.c | ||
137 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
138 | return true; | ||
139 | } | ||
140 | |||
141 | -static bool mve_skip_vmov(DisasContext *s, int vn, int index, int size) | ||
142 | +bool mve_skip_vmov(DisasContext *s, int vn, int index, int size) | ||
143 | { | ||
144 | /* | ||
145 | * In a CPU with MVE, the VMOV (vector lane to general-purpose register) | ||
146 | -- | 47 | -- |
147 | 2.20.1 | 48 | 2.34.1 |
148 | 49 | ||
149 | 50 | diff view generated by jsdifflib |
1 | Implement the MVE VMAXA and VMINA insns, which take the absolute | 1 | The functions qemu_get_timedate() and qemu_timedate_diff() take |
---|---|---|---|
2 | value of the signed elements in the input vector and then accumulate | 2 | and return a time offset as an integer. Coverity points out that |
3 | the unsigned max or min into the destination vector. | 3 | means that when an RTC device implementation holds an offset |
4 | as a time_t, as the m48t59 does, the time_t will get truncated. | ||
5 | (CID 1507157, 1517772). | ||
6 | |||
7 | The functions work with time_t internally, so make them use that type | ||
8 | in their APIs. | ||
9 | |||
10 | Note that this won't help any Y2038 issues where either the device | ||
11 | model itself is keeping the offset in a 32-bit integer, or where the | ||
12 | hardware under emulation has Y2038 or other rollover problems. If we | ||
13 | missed any cases of the former then hopefully Coverity will warn us | ||
14 | about them since after this patch we'd be truncating a time_t in | ||
15 | assignments from qemu_timedate_diff().) | ||
4 | 16 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | --- | 19 | --- |
8 | target/arm/helper-mve.h | 8 ++++++++ | 20 | include/sysemu/rtc.h | 4 ++-- |
9 | target/arm/mve.decode | 4 ++++ | 21 | softmmu/rtc.c | 4 ++-- |
10 | target/arm/mve_helper.c | 26 ++++++++++++++++++++++++++ | 22 | 2 files changed, 4 insertions(+), 4 deletions(-) |
11 | target/arm/translate-mve.c | 2 ++ | ||
12 | 4 files changed, 40 insertions(+) | ||
13 | 23 | ||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 24 | diff --git a/include/sysemu/rtc.h b/include/sysemu/rtc.h |
15 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper-mve.h | 26 | --- a/include/sysemu/rtc.h |
17 | +++ b/target/arm/helper-mve.h | 27 | +++ b/include/sysemu/rtc.h |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vqnegb, TCG_CALL_NO_WG, void, env, ptr, ptr) | 28 | @@ -XXX,XX +XXX,XX @@ |
19 | DEF_HELPER_FLAGS_3(mve_vqnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | 29 | * The behaviour of the clock whose value this function returns will |
20 | DEF_HELPER_FLAGS_3(mve_vqnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | 30 | * depend on the -rtc command line option passed by the user. |
21 | 31 | */ | |
22 | +DEF_HELPER_FLAGS_3(mve_vmaxab, TCG_CALL_NO_WG, void, env, ptr, ptr) | 32 | -void qemu_get_timedate(struct tm *tm, int offset); |
23 | +DEF_HELPER_FLAGS_3(mve_vmaxah, TCG_CALL_NO_WG, void, env, ptr, ptr) | 33 | +void qemu_get_timedate(struct tm *tm, time_t offset); |
24 | +DEF_HELPER_FLAGS_3(mve_vmaxaw, TCG_CALL_NO_WG, void, env, ptr, ptr) | 34 | |
25 | + | 35 | /** |
26 | +DEF_HELPER_FLAGS_3(mve_vminab, TCG_CALL_NO_WG, void, env, ptr, ptr) | 36 | * qemu_timedate_diff: Return difference between a struct tm and the RTC |
27 | +DEF_HELPER_FLAGS_3(mve_vminah, TCG_CALL_NO_WG, void, env, ptr, ptr) | 37 | @@ -XXX,XX +XXX,XX @@ void qemu_get_timedate(struct tm *tm, int offset); |
28 | +DEF_HELPER_FLAGS_3(mve_vminaw, TCG_CALL_NO_WG, void, env, ptr, ptr) | 38 | * a timestamp one hour further ahead than the current RTC time |
29 | + | 39 | * then this function will return 3600. |
30 | DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | 40 | */ |
31 | DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | 41 | -int qemu_timedate_diff(struct tm *tm); |
32 | DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | 42 | +time_t qemu_timedate_diff(struct tm *tm); |
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 43 | |
44 | #endif | ||
45 | diff --git a/softmmu/rtc.c b/softmmu/rtc.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/mve.decode | 47 | --- a/softmmu/rtc.c |
36 | +++ b/target/arm/mve.decode | 48 | +++ b/softmmu/rtc.c |
37 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | 49 | @@ -XXX,XX +XXX,XX @@ static time_t qemu_ref_timedate(QEMUClockType clock) |
38 | VQMOVUNB 111 0 1110 0 . 11 .. 01 ... 0 1110 1 0 . 0 ... 1 @1op | 50 | return value; |
39 | VQMOVN_BS 111 0 1110 0 . 11 .. 11 ... 0 1110 0 0 . 0 ... 1 @1op | ||
40 | |||
41 | + VMAXA 111 0 1110 0 . 11 .. 11 ... 0 1110 1 0 . 0 ... 1 @1op | ||
42 | + | ||
43 | VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
44 | } | 51 | } |
45 | 52 | ||
46 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | 53 | -void qemu_get_timedate(struct tm *tm, int offset) |
47 | VQMOVUNT 111 0 1110 0 . 11 .. 01 ... 1 1110 1 0 . 0 ... 1 @1op | 54 | +void qemu_get_timedate(struct tm *tm, time_t offset) |
48 | VQMOVN_TS 111 0 1110 0 . 11 .. 11 ... 1 1110 0 0 . 0 ... 1 @1op | 55 | { |
49 | 56 | time_t ti = qemu_ref_timedate(rtc_clock); | |
50 | + VMINA 111 0 1110 0 . 11 .. 11 ... 1 1110 1 0 . 0 ... 1 @1op | 57 | |
51 | + | 58 | @@ -XXX,XX +XXX,XX @@ void qemu_get_timedate(struct tm *tm, int offset) |
52 | VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | 59 | } |
53 | } | 60 | } |
54 | 61 | ||
55 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 62 | -int qemu_timedate_diff(struct tm *tm) |
56 | index XXXXXXX..XXXXXXX 100644 | 63 | +time_t qemu_timedate_diff(struct tm *tm) |
57 | --- a/target/arm/mve_helper.c | 64 | { |
58 | +++ b/target/arm/mve_helper.c | 65 | time_t seconds; |
59 | @@ -XXX,XX +XXX,XX @@ DO_1OP_SAT(vqabsw, 4, int32_t, DO_VQABS_W) | 66 | |
60 | DO_1OP_SAT(vqnegb, 1, int8_t, DO_VQNEG_B) | ||
61 | DO_1OP_SAT(vqnegh, 2, int16_t, DO_VQNEG_H) | ||
62 | DO_1OP_SAT(vqnegw, 4, int32_t, DO_VQNEG_W) | ||
63 | + | ||
64 | +/* | ||
65 | + * VMAXA, VMINA: vd is unsigned; vm is signed, and we take its | ||
66 | + * absolute value; we then do an unsigned comparison. | ||
67 | + */ | ||
68 | +#define DO_VMAXMINA(OP, ESIZE, STYPE, UTYPE, FN) \ | ||
69 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
70 | + { \ | ||
71 | + UTYPE *d = vd; \ | ||
72 | + STYPE *m = vm; \ | ||
73 | + uint16_t mask = mve_element_mask(env); \ | ||
74 | + unsigned e; \ | ||
75 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
76 | + UTYPE r = DO_ABS(m[H##ESIZE(e)]); \ | ||
77 | + r = FN(d[H##ESIZE(e)], r); \ | ||
78 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
79 | + } \ | ||
80 | + mve_advance_vpt(env); \ | ||
81 | + } | ||
82 | + | ||
83 | +DO_VMAXMINA(vmaxab, 1, int8_t, uint8_t, DO_MAX) | ||
84 | +DO_VMAXMINA(vmaxah, 2, int16_t, uint16_t, DO_MAX) | ||
85 | +DO_VMAXMINA(vmaxaw, 4, int32_t, uint32_t, DO_MAX) | ||
86 | +DO_VMAXMINA(vminab, 1, int8_t, uint8_t, DO_MIN) | ||
87 | +DO_VMAXMINA(vminah, 2, int16_t, uint16_t, DO_MIN) | ||
88 | +DO_VMAXMINA(vminaw, 4, int32_t, uint32_t, DO_MIN) | ||
89 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/target/arm/translate-mve.c | ||
92 | +++ b/target/arm/translate-mve.c | ||
93 | @@ -XXX,XX +XXX,XX @@ DO_1OP(VABS, vabs) | ||
94 | DO_1OP(VNEG, vneg) | ||
95 | DO_1OP(VQABS, vqabs) | ||
96 | DO_1OP(VQNEG, vqneg) | ||
97 | +DO_1OP(VMAXA, vmaxa) | ||
98 | +DO_1OP(VMINA, vmina) | ||
99 | |||
100 | /* Narrowing moves: only size 0 and 1 are valid */ | ||
101 | #define DO_VMOVN(INSN, FN) \ | ||
102 | -- | 67 | -- |
103 | 2.20.1 | 68 | 2.34.1 |
104 | 69 | ||
105 | 70 | diff view generated by jsdifflib |
1 | Implement the MVE VABAV insn, which computes absolute differences | 1 | Where architecturally one ARM_FEATURE_X flag implies another |
---|---|---|---|
2 | between elements of two vectors and accumulates the result into | 2 | ARM_FEATURE_Y, we allow the CPU init function to only set X, and then |
3 | a general purpose register. | 3 | set Y for it. Currently we do this in two places -- we set a few |
4 | flags in arm_cpu_post_init() because we need them to decide which | ||
5 | properties to create on the CPU object, and then we do the rest in | ||
6 | arm_cpu_realizefn(). However, this is fragile, because it's easy to | ||
7 | add a new property and not notice that this means that an X-implies-Y | ||
8 | check now has to move from realize to post-init. | ||
9 | |||
10 | As a specific example, the pmsav7-dregion property is conditional | ||
11 | on ARM_FEATURE_PMSA && ARM_FEATURE_V7, which means it won't appear | ||
12 | on the Cortex-M33 and -M55, because they set ARM_FEATURE_V8 and | ||
13 | rely on V8-implies-V7, which doesn't happen until the realizefn. | ||
14 | |||
15 | Move all of these X-implies-Y checks into a new function, which | ||
16 | we call at the top of arm_cpu_post_init(), so the feature bits | ||
17 | are available at that point. | ||
18 | |||
19 | This does now give us the reverse issue, that if there's a feature | ||
20 | bit which is enabled or disabled by the setting of a property then | ||
21 | then X-implies-Y features that are dependent on that property need to | ||
22 | be in realize, not in this new function. But the only one of those | ||
23 | is the "EL3 implies VBAR" which is already in the right place, so | ||
24 | putting things this way round seems better to me. | ||
4 | 25 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 27 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
28 | Message-id: 20230724174335.2150499-2-peter.maydell@linaro.org | ||
7 | --- | 29 | --- |
8 | target/arm/helper-mve.h | 7 +++++++ | 30 | target/arm/cpu.c | 179 +++++++++++++++++++++++++---------------------- |
9 | target/arm/mve.decode | 6 ++++++ | 31 | 1 file changed, 97 insertions(+), 82 deletions(-) |
10 | target/arm/mve_helper.c | 26 +++++++++++++++++++++++ | 32 | |
11 | target/arm/translate-mve.c | 43 ++++++++++++++++++++++++++++++++++++++ | 33 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
12 | 4 files changed, 82 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper-mve.h | 35 | --- a/target/arm/cpu.c |
17 | +++ b/target/arm/helper-mve.h | 36 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vminavw, TCG_CALL_NO_WG, i32, env, ptr, i32) | 37 | @@ -XXX,XX +XXX,XX @@ unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) |
19 | DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) | 38 | NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1; |
20 | DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
21 | |||
22 | +DEF_HELPER_FLAGS_4(mve_vabavsb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vabavsh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vabavsw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vabavub, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vabavuh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vabavuw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
28 | + | ||
29 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
30 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
31 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
32 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/mve.decode | ||
35 | +++ b/target/arm/mve.decode | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | &vcmp_scalar qn rm size mask | ||
38 | &shl_scalar qda rm size | ||
39 | &vmaxv qm rda size | ||
40 | +&vabav qn qm rda size | ||
41 | |||
42 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
43 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
44 | @@ -XXX,XX +XXX,XX @@ VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
45 | rdahi=%rdahi rdalo=%rdalo | ||
46 | } | 39 | } |
47 | 40 | ||
48 | +@vabav .... .... .. size:2 .... rda:4 .... .... .... &vabav qn=%qn qm=%qm | 41 | +static void arm_cpu_propagate_feature_implications(ARMCPU *cpu) |
49 | + | ||
50 | +VABAV_S 111 0 1110 10 .. ... 0 .... 1111 . 0 . 0 ... 1 @vabav | ||
51 | +VABAV_U 111 1 1110 10 .. ... 0 .... 1111 . 0 . 0 ... 1 @vabav | ||
52 | + | ||
53 | # Logical immediate operations (1 reg and modified-immediate) | ||
54 | |||
55 | # The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but | ||
56 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/mve_helper.c | ||
59 | +++ b/target/arm/mve_helper.c | ||
60 | @@ -XXX,XX +XXX,XX @@ DO_VMAXMINV(vminavb, 1, int8_t, uint8_t, do_mina) | ||
61 | DO_VMAXMINV(vminavh, 2, int16_t, uint16_t, do_mina) | ||
62 | DO_VMAXMINV(vminavw, 4, int32_t, uint32_t, do_mina) | ||
63 | |||
64 | +#define DO_VABAV(OP, ESIZE, TYPE) \ | ||
65 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
66 | + void *vm, uint32_t ra) \ | ||
67 | + { \ | ||
68 | + uint16_t mask = mve_element_mask(env); \ | ||
69 | + unsigned e; \ | ||
70 | + TYPE *m = vm, *n = vn; \ | ||
71 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
72 | + if (mask & 1) { \ | ||
73 | + int64_t n0 = n[H##ESIZE(e)]; \ | ||
74 | + int64_t m0 = m[H##ESIZE(e)]; \ | ||
75 | + uint32_t r = n0 >= m0 ? (n0 - m0) : (m0 - n0); \ | ||
76 | + ra += r; \ | ||
77 | + } \ | ||
78 | + } \ | ||
79 | + mve_advance_vpt(env); \ | ||
80 | + return ra; \ | ||
81 | + } | ||
82 | + | ||
83 | +DO_VABAV(vabavsb, 1, int8_t) | ||
84 | +DO_VABAV(vabavsh, 2, int16_t) | ||
85 | +DO_VABAV(vabavsw, 4, int32_t) | ||
86 | +DO_VABAV(vabavub, 1, uint8_t) | ||
87 | +DO_VABAV(vabavuh, 2, uint16_t) | ||
88 | +DO_VABAV(vabavuw, 4, uint32_t) | ||
89 | + | ||
90 | #define DO_VADDLV(OP, TYPE, LTYPE) \ | ||
91 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
92 | uint64_t ra) \ | ||
93 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/translate-mve.c | ||
96 | +++ b/target/arm/translate-mve.c | ||
97 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
98 | typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
99 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
100 | typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
101 | +typedef void MVEGenVABAVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
102 | |||
103 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
104 | static inline long mve_qreg_offset(unsigned reg) | ||
105 | @@ -XXX,XX +XXX,XX @@ DO_VMAXV(VMAXAV, vmaxav) | ||
106 | DO_VMAXV(VMINV_S, vminvs) | ||
107 | DO_VMAXV(VMINV_U, vminvu) | ||
108 | DO_VMAXV(VMINAV, vminav) | ||
109 | + | ||
110 | +static bool do_vabav(DisasContext *s, arg_vabav *a, MVEGenVABAVFn *fn) | ||
111 | +{ | 42 | +{ |
112 | + /* Absolute difference accumulated across vector */ | 43 | + CPUARMState *env = &cpu->env; |
113 | + TCGv_ptr qn, qm; | 44 | + bool no_aa32 = false; |
114 | + TCGv_i32 rda; | 45 | + |
115 | + | 46 | + /* |
116 | + if (!dc_isar_feature(aa32_mve, s) || | 47 | + * Some features automatically imply others: set the feature |
117 | + !mve_check_qreg_bank(s, a->qm | a->qn) || | 48 | + * bits explicitly for these cases. |
118 | + !fn || a->rda == 13 || a->rda == 15) { | 49 | + */ |
119 | + /* Rda cases are UNPREDICTABLE */ | 50 | + |
120 | + return false; | 51 | + if (arm_feature(env, ARM_FEATURE_M)) { |
121 | + } | 52 | + set_feature(env, ARM_FEATURE_PMSA); |
122 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | 53 | + } |
123 | + return true; | 54 | + |
124 | + } | 55 | + if (arm_feature(env, ARM_FEATURE_V8)) { |
125 | + | 56 | + if (arm_feature(env, ARM_FEATURE_M)) { |
126 | + qm = mve_qreg_ptr(a->qm); | 57 | + set_feature(env, ARM_FEATURE_V7); |
127 | + qn = mve_qreg_ptr(a->qn); | 58 | + } else { |
128 | + rda = load_reg(s, a->rda); | 59 | + set_feature(env, ARM_FEATURE_V7VE); |
129 | + fn(rda, cpu_env, qn, qm, rda); | 60 | + } |
130 | + store_reg(s, a->rda, rda); | 61 | + } |
131 | + tcg_temp_free_ptr(qm); | 62 | + |
132 | + tcg_temp_free_ptr(qn); | 63 | + /* |
133 | + mve_update_eci(s); | 64 | + * There exist AArch64 cpus without AArch32 support. When KVM |
134 | + return true; | 65 | + * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. |
66 | + * Similarly, we cannot check ID_AA64PFR0 without AArch64 support. | ||
67 | + * As a general principle, we also do not make ID register | ||
68 | + * consistency checks anywhere unless using TCG, because only | ||
69 | + * for TCG would a consistency-check failure be a QEMU bug. | ||
70 | + */ | ||
71 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
72 | + no_aa32 = !cpu_isar_feature(aa64_aa32, cpu); | ||
73 | + } | ||
74 | + | ||
75 | + if (arm_feature(env, ARM_FEATURE_V7VE)) { | ||
76 | + /* | ||
77 | + * v7 Virtualization Extensions. In real hardware this implies | ||
78 | + * EL2 and also the presence of the Security Extensions. | ||
79 | + * For QEMU, for backwards-compatibility we implement some | ||
80 | + * CPUs or CPU configs which have no actual EL2 or EL3 but do | ||
81 | + * include the various other features that V7VE implies. | ||
82 | + * Presence of EL2 itself is ARM_FEATURE_EL2, and of the | ||
83 | + * Security Extensions is ARM_FEATURE_EL3. | ||
84 | + */ | ||
85 | + assert(!tcg_enabled() || no_aa32 || | ||
86 | + cpu_isar_feature(aa32_arm_div, cpu)); | ||
87 | + set_feature(env, ARM_FEATURE_LPAE); | ||
88 | + set_feature(env, ARM_FEATURE_V7); | ||
89 | + } | ||
90 | + if (arm_feature(env, ARM_FEATURE_V7)) { | ||
91 | + set_feature(env, ARM_FEATURE_VAPA); | ||
92 | + set_feature(env, ARM_FEATURE_THUMB2); | ||
93 | + set_feature(env, ARM_FEATURE_MPIDR); | ||
94 | + if (!arm_feature(env, ARM_FEATURE_M)) { | ||
95 | + set_feature(env, ARM_FEATURE_V6K); | ||
96 | + } else { | ||
97 | + set_feature(env, ARM_FEATURE_V6); | ||
98 | + } | ||
99 | + | ||
100 | + /* | ||
101 | + * Always define VBAR for V7 CPUs even if it doesn't exist in | ||
102 | + * non-EL3 configs. This is needed by some legacy boards. | ||
103 | + */ | ||
104 | + set_feature(env, ARM_FEATURE_VBAR); | ||
105 | + } | ||
106 | + if (arm_feature(env, ARM_FEATURE_V6K)) { | ||
107 | + set_feature(env, ARM_FEATURE_V6); | ||
108 | + set_feature(env, ARM_FEATURE_MVFR); | ||
109 | + } | ||
110 | + if (arm_feature(env, ARM_FEATURE_V6)) { | ||
111 | + set_feature(env, ARM_FEATURE_V5); | ||
112 | + if (!arm_feature(env, ARM_FEATURE_M)) { | ||
113 | + assert(!tcg_enabled() || no_aa32 || | ||
114 | + cpu_isar_feature(aa32_jazelle, cpu)); | ||
115 | + set_feature(env, ARM_FEATURE_AUXCR); | ||
116 | + } | ||
117 | + } | ||
118 | + if (arm_feature(env, ARM_FEATURE_V5)) { | ||
119 | + set_feature(env, ARM_FEATURE_V4T); | ||
120 | + } | ||
121 | + if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
122 | + set_feature(env, ARM_FEATURE_V7MP); | ||
123 | + } | ||
124 | + if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { | ||
125 | + set_feature(env, ARM_FEATURE_CBAR); | ||
126 | + } | ||
127 | + if (arm_feature(env, ARM_FEATURE_THUMB2) && | ||
128 | + !arm_feature(env, ARM_FEATURE_M)) { | ||
129 | + set_feature(env, ARM_FEATURE_THUMB_DSP); | ||
130 | + } | ||
135 | +} | 131 | +} |
136 | + | 132 | + |
137 | +#define DO_VABAV(INSN, FN) \ | 133 | void arm_cpu_post_init(Object *obj) |
138 | + static bool trans_##INSN(DisasContext *s, arg_vabav *a) \ | 134 | { |
139 | + { \ | 135 | ARMCPU *cpu = ARM_CPU(obj); |
140 | + static MVEGenVABAVFn * const fns[] = { \ | 136 | |
141 | + gen_helper_mve_##FN##b, \ | 137 | - /* M profile implies PMSA. We have to do this here rather than |
142 | + gen_helper_mve_##FN##h, \ | 138 | - * in realize with the other feature-implication checks because |
143 | + gen_helper_mve_##FN##w, \ | 139 | - * we look at the PMSA bit to see if we should add some properties. |
144 | + NULL, \ | 140 | + /* |
145 | + }; \ | 141 | + * Some features imply others. Figure this out now, because we |
146 | + return do_vabav(s, a, fns[a->size]); \ | 142 | + * are going to look at the feature bits in deciding which |
147 | + } | 143 | + * properties to add. |
148 | + | 144 | */ |
149 | +DO_VABAV(VABAV_S, vabavs) | 145 | - if (arm_feature(&cpu->env, ARM_FEATURE_M)) { |
150 | +DO_VABAV(VABAV_U, vabavu) | 146 | - set_feature(&cpu->env, ARM_FEATURE_PMSA); |
147 | - } | ||
148 | + arm_cpu_propagate_feature_implications(cpu); | ||
149 | |||
150 | if (arm_feature(&cpu->env, ARM_FEATURE_CBAR) || | ||
151 | arm_feature(&cpu->env, ARM_FEATURE_CBAR_RO)) { | ||
152 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
153 | CPUARMState *env = &cpu->env; | ||
154 | int pagebits; | ||
155 | Error *local_err = NULL; | ||
156 | - bool no_aa32 = false; | ||
157 | |||
158 | /* Use pc-relative instructions in system-mode */ | ||
159 | #ifndef CONFIG_USER_ONLY | ||
160 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
161 | cpu->isar.id_isar3 = u; | ||
162 | } | ||
163 | |||
164 | - /* Some features automatically imply others: */ | ||
165 | - if (arm_feature(env, ARM_FEATURE_V8)) { | ||
166 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
167 | - set_feature(env, ARM_FEATURE_V7); | ||
168 | - } else { | ||
169 | - set_feature(env, ARM_FEATURE_V7VE); | ||
170 | - } | ||
171 | - } | ||
172 | - | ||
173 | - /* | ||
174 | - * There exist AArch64 cpus without AArch32 support. When KVM | ||
175 | - * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. | ||
176 | - * Similarly, we cannot check ID_AA64PFR0 without AArch64 support. | ||
177 | - * As a general principle, we also do not make ID register | ||
178 | - * consistency checks anywhere unless using TCG, because only | ||
179 | - * for TCG would a consistency-check failure be a QEMU bug. | ||
180 | - */ | ||
181 | - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
182 | - no_aa32 = !cpu_isar_feature(aa64_aa32, cpu); | ||
183 | - } | ||
184 | - | ||
185 | - if (arm_feature(env, ARM_FEATURE_V7VE)) { | ||
186 | - /* v7 Virtualization Extensions. In real hardware this implies | ||
187 | - * EL2 and also the presence of the Security Extensions. | ||
188 | - * For QEMU, for backwards-compatibility we implement some | ||
189 | - * CPUs or CPU configs which have no actual EL2 or EL3 but do | ||
190 | - * include the various other features that V7VE implies. | ||
191 | - * Presence of EL2 itself is ARM_FEATURE_EL2, and of the | ||
192 | - * Security Extensions is ARM_FEATURE_EL3. | ||
193 | - */ | ||
194 | - assert(!tcg_enabled() || no_aa32 || | ||
195 | - cpu_isar_feature(aa32_arm_div, cpu)); | ||
196 | - set_feature(env, ARM_FEATURE_LPAE); | ||
197 | - set_feature(env, ARM_FEATURE_V7); | ||
198 | - } | ||
199 | - if (arm_feature(env, ARM_FEATURE_V7)) { | ||
200 | - set_feature(env, ARM_FEATURE_VAPA); | ||
201 | - set_feature(env, ARM_FEATURE_THUMB2); | ||
202 | - set_feature(env, ARM_FEATURE_MPIDR); | ||
203 | - if (!arm_feature(env, ARM_FEATURE_M)) { | ||
204 | - set_feature(env, ARM_FEATURE_V6K); | ||
205 | - } else { | ||
206 | - set_feature(env, ARM_FEATURE_V6); | ||
207 | - } | ||
208 | - | ||
209 | - /* Always define VBAR for V7 CPUs even if it doesn't exist in | ||
210 | - * non-EL3 configs. This is needed by some legacy boards. | ||
211 | - */ | ||
212 | - set_feature(env, ARM_FEATURE_VBAR); | ||
213 | - } | ||
214 | - if (arm_feature(env, ARM_FEATURE_V6K)) { | ||
215 | - set_feature(env, ARM_FEATURE_V6); | ||
216 | - set_feature(env, ARM_FEATURE_MVFR); | ||
217 | - } | ||
218 | - if (arm_feature(env, ARM_FEATURE_V6)) { | ||
219 | - set_feature(env, ARM_FEATURE_V5); | ||
220 | - if (!arm_feature(env, ARM_FEATURE_M)) { | ||
221 | - assert(!tcg_enabled() || no_aa32 || | ||
222 | - cpu_isar_feature(aa32_jazelle, cpu)); | ||
223 | - set_feature(env, ARM_FEATURE_AUXCR); | ||
224 | - } | ||
225 | - } | ||
226 | - if (arm_feature(env, ARM_FEATURE_V5)) { | ||
227 | - set_feature(env, ARM_FEATURE_V4T); | ||
228 | - } | ||
229 | - if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
230 | - set_feature(env, ARM_FEATURE_V7MP); | ||
231 | - } | ||
232 | - if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { | ||
233 | - set_feature(env, ARM_FEATURE_CBAR); | ||
234 | - } | ||
235 | - if (arm_feature(env, ARM_FEATURE_THUMB2) && | ||
236 | - !arm_feature(env, ARM_FEATURE_M)) { | ||
237 | - set_feature(env, ARM_FEATURE_THUMB_DSP); | ||
238 | - } | ||
239 | |||
240 | /* | ||
241 | * We rely on no XScale CPU having VFP so we can use the same bits in the | ||
151 | -- | 242 | -- |
152 | 2.20.1 | 243 | 2.34.1 |
153 | |||
154 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE narrowing move insns VMOVN, VQMOVN and VQMOVUN. | ||
2 | These take a double-width input, narrow it (possibly saturating) and | ||
3 | store the result to either the top or bottom half of the output | ||
4 | element. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | target/arm/helper-mve.h | 20 ++++++++++ | ||
10 | target/arm/mve.decode | 12 ++++++ | ||
11 | target/arm/mve_helper.c | 78 ++++++++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 22 +++++++++++ | ||
13 | 4 files changed, 132 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/helper-mve.h | ||
18 | +++ b/target/arm/helper-mve.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_3(mve_vfnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | DEF_HELPER_FLAGS_3(mve_vfnegs, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
22 | |||
23 | +DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vmovnth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | + | ||
28 | +DEF_HELPER_FLAGS_3(mve_vqmovunbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vqmovunbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vqmovuntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | +DEF_HELPER_FLAGS_3(mve_vqmovunth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
32 | + | ||
33 | +DEF_HELPER_FLAGS_3(mve_vqmovnbsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vqmovnbsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
35 | +DEF_HELPER_FLAGS_3(mve_vqmovntsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
36 | +DEF_HELPER_FLAGS_3(mve_vqmovntsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
37 | + | ||
38 | +DEF_HELPER_FLAGS_3(mve_vqmovnbub, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
39 | +DEF_HELPER_FLAGS_3(mve_vqmovnbuh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
40 | +DEF_HELPER_FLAGS_3(mve_vqmovntub, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vqmovntuh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
42 | + | ||
43 | DEF_HELPER_FLAGS_4(mve_vand, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
44 | DEF_HELPER_FLAGS_4(mve_vbic, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
45 | DEF_HELPER_FLAGS_4(mve_vorr, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
46 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mve.decode | ||
49 | +++ b/target/arm/mve.decode | ||
50 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
51 | VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
52 | VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
53 | |||
54 | + VQMOVUNB 111 0 1110 0 . 11 .. 01 ... 0 1110 1 0 . 0 ... 1 @1op | ||
55 | + VQMOVN_BS 111 0 1110 0 . 11 .. 11 ... 0 1110 0 0 . 0 ... 1 @1op | ||
56 | + | ||
57 | VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
58 | } | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
61 | VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
62 | VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
63 | |||
64 | + VMOVNB 111 1 1110 0 . 11 .. 01 ... 0 1110 1 0 . 0 ... 1 @1op | ||
65 | + VQMOVN_BU 111 1 1110 0 . 11 .. 11 ... 0 1110 0 0 . 0 ... 1 @1op | ||
66 | + | ||
67 | VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
68 | } | ||
69 | |||
70 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
71 | VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
72 | VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
73 | |||
74 | + VQMOVUNT 111 0 1110 0 . 11 .. 01 ... 1 1110 1 0 . 0 ... 1 @1op | ||
75 | + VQMOVN_TS 111 0 1110 0 . 11 .. 11 ... 1 1110 0 0 . 0 ... 1 @1op | ||
76 | + | ||
77 | VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
78 | } | ||
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
81 | VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
82 | VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
83 | |||
84 | + VMOVNT 111 1 1110 0 . 11 .. 01 ... 1 1110 1 0 . 0 ... 1 @1op | ||
85 | + VQMOVN_TU 111 1 1110 0 . 11 .. 11 ... 1 1110 0 0 . 0 ... 1 @1op | ||
86 | + | ||
87 | VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
88 | } | ||
89 | |||
90 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/mve_helper.c | ||
93 | +++ b/target/arm/mve_helper.c | ||
94 | @@ -XXX,XX +XXX,XX @@ DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) | ||
95 | DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | ||
96 | DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) | ||
97 | |||
98 | +#define DO_VMOVN(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE) \ | ||
99 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
100 | + { \ | ||
101 | + LTYPE *m = vm; \ | ||
102 | + TYPE *d = vd; \ | ||
103 | + uint16_t mask = mve_element_mask(env); \ | ||
104 | + unsigned le; \ | ||
105 | + mask >>= ESIZE * TOP; \ | ||
106 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
107 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], \ | ||
108 | + m[H##LESIZE(le)], mask); \ | ||
109 | + } \ | ||
110 | + mve_advance_vpt(env); \ | ||
111 | + } | ||
112 | + | ||
113 | +DO_VMOVN(vmovnbb, false, 1, uint8_t, 2, uint16_t) | ||
114 | +DO_VMOVN(vmovnbh, false, 2, uint16_t, 4, uint32_t) | ||
115 | +DO_VMOVN(vmovntb, true, 1, uint8_t, 2, uint16_t) | ||
116 | +DO_VMOVN(vmovnth, true, 2, uint16_t, 4, uint32_t) | ||
117 | + | ||
118 | +#define DO_VMOVN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | ||
119 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
120 | + { \ | ||
121 | + LTYPE *m = vm; \ | ||
122 | + TYPE *d = vd; \ | ||
123 | + uint16_t mask = mve_element_mask(env); \ | ||
124 | + bool qc = false; \ | ||
125 | + unsigned le; \ | ||
126 | + mask >>= ESIZE * TOP; \ | ||
127 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
128 | + bool sat = false; \ | ||
129 | + TYPE r = FN(m[H##LESIZE(le)], &sat); \ | ||
130 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
131 | + qc |= sat & mask & 1; \ | ||
132 | + } \ | ||
133 | + if (qc) { \ | ||
134 | + env->vfp.qc[0] = qc; \ | ||
135 | + } \ | ||
136 | + mve_advance_vpt(env); \ | ||
137 | + } | ||
138 | + | ||
139 | +#define DO_VMOVN_SAT_UB(BOP, TOP, FN) \ | ||
140 | + DO_VMOVN_SAT(BOP, false, 1, uint8_t, 2, uint16_t, FN) \ | ||
141 | + DO_VMOVN_SAT(TOP, true, 1, uint8_t, 2, uint16_t, FN) | ||
142 | + | ||
143 | +#define DO_VMOVN_SAT_UH(BOP, TOP, FN) \ | ||
144 | + DO_VMOVN_SAT(BOP, false, 2, uint16_t, 4, uint32_t, FN) \ | ||
145 | + DO_VMOVN_SAT(TOP, true, 2, uint16_t, 4, uint32_t, FN) | ||
146 | + | ||
147 | +#define DO_VMOVN_SAT_SB(BOP, TOP, FN) \ | ||
148 | + DO_VMOVN_SAT(BOP, false, 1, int8_t, 2, int16_t, FN) \ | ||
149 | + DO_VMOVN_SAT(TOP, true, 1, int8_t, 2, int16_t, FN) | ||
150 | + | ||
151 | +#define DO_VMOVN_SAT_SH(BOP, TOP, FN) \ | ||
152 | + DO_VMOVN_SAT(BOP, false, 2, int16_t, 4, int32_t, FN) \ | ||
153 | + DO_VMOVN_SAT(TOP, true, 2, int16_t, 4, int32_t, FN) | ||
154 | + | ||
155 | +#define DO_VQMOVN_SB(N, SATP) \ | ||
156 | + do_sat_bhs((int64_t)(N), INT8_MIN, INT8_MAX, SATP) | ||
157 | +#define DO_VQMOVN_UB(N, SATP) \ | ||
158 | + do_sat_bhs((uint64_t)(N), 0, UINT8_MAX, SATP) | ||
159 | +#define DO_VQMOVUN_B(N, SATP) \ | ||
160 | + do_sat_bhs((int64_t)(N), 0, UINT8_MAX, SATP) | ||
161 | + | ||
162 | +#define DO_VQMOVN_SH(N, SATP) \ | ||
163 | + do_sat_bhs((int64_t)(N), INT16_MIN, INT16_MAX, SATP) | ||
164 | +#define DO_VQMOVN_UH(N, SATP) \ | ||
165 | + do_sat_bhs((uint64_t)(N), 0, UINT16_MAX, SATP) | ||
166 | +#define DO_VQMOVUN_H(N, SATP) \ | ||
167 | + do_sat_bhs((int64_t)(N), 0, UINT16_MAX, SATP) | ||
168 | + | ||
169 | +DO_VMOVN_SAT_SB(vqmovnbsb, vqmovntsb, DO_VQMOVN_SB) | ||
170 | +DO_VMOVN_SAT_SH(vqmovnbsh, vqmovntsh, DO_VQMOVN_SH) | ||
171 | +DO_VMOVN_SAT_UB(vqmovnbub, vqmovntub, DO_VQMOVN_UB) | ||
172 | +DO_VMOVN_SAT_UH(vqmovnbuh, vqmovntuh, DO_VQMOVN_UH) | ||
173 | +DO_VMOVN_SAT_SB(vqmovunbb, vqmovuntb, DO_VQMOVUN_B) | ||
174 | +DO_VMOVN_SAT_SH(vqmovunbh, vqmovunth, DO_VQMOVUN_H) | ||
175 | + | ||
176 | uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
177 | uint32_t shift) | ||
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 @@ DO_1OP(VCLS, vcls) | ||
184 | DO_1OP(VABS, vabs) | ||
185 | DO_1OP(VNEG, vneg) | ||
186 | |||
187 | +/* Narrowing moves: only size 0 and 1 are valid */ | ||
188 | +#define DO_VMOVN(INSN, FN) \ | ||
189 | + static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
190 | + { \ | ||
191 | + static MVEGenOneOpFn * const fns[] = { \ | ||
192 | + gen_helper_mve_##FN##b, \ | ||
193 | + gen_helper_mve_##FN##h, \ | ||
194 | + NULL, \ | ||
195 | + NULL, \ | ||
196 | + }; \ | ||
197 | + return do_1op(s, a, fns[a->size]); \ | ||
198 | + } | ||
199 | + | ||
200 | +DO_VMOVN(VMOVNB, vmovnb) | ||
201 | +DO_VMOVN(VMOVNT, vmovnt) | ||
202 | +DO_VMOVN(VQMOVUNB, vqmovunb) | ||
203 | +DO_VMOVN(VQMOVUNT, vqmovunt) | ||
204 | +DO_VMOVN(VQMOVN_BS, vqmovnbs) | ||
205 | +DO_VMOVN(VQMOVN_TS, vqmovnts) | ||
206 | +DO_VMOVN(VQMOVN_BU, vqmovnbu) | ||
207 | +DO_VMOVN(VQMOVN_TU, vqmovntu) | ||
208 | + | ||
209 | static bool trans_VREV16(DisasContext *s, arg_1op *a) | ||
210 | { | ||
211 | static MVEGenOneOpFn * const fns[] = { | ||
212 | -- | ||
213 | 2.20.1 | ||
214 | |||
215 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The MVEGenDualAccOpFn is a bit misnamed, since it is used for | ||
2 | the "long dual accumulate" operations that use a 64-bit | ||
3 | accumulator. Rename it to MVEGenLongDualAccOpFn so we can | ||
4 | use the former name for the 32-bit accumulator insns. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | target/arm/translate-mve.c | 16 ++++++++-------- | ||
10 | 1 file changed, 8 insertions(+), 8 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/translate-mve.c | ||
15 | +++ b/target/arm/translate-mve.c | ||
16 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
17 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
18 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
19 | typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
20 | -typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
21 | +typedef void MVEGenLongDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
22 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
23 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
24 | typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
25 | @@ -XXX,XX +XXX,XX @@ static bool trans_VQDMULLT_scalar(DisasContext *s, arg_2scalar *a) | ||
26 | } | ||
27 | |||
28 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
29 | - MVEGenDualAccOpFn *fn) | ||
30 | + MVEGenLongDualAccOpFn *fn) | ||
31 | { | ||
32 | TCGv_ptr qn, qm; | ||
33 | TCGv_i64 rda; | ||
34 | @@ -XXX,XX +XXX,XX @@ static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
35 | |||
36 | static bool trans_VMLALDAV_S(DisasContext *s, arg_vmlaldav *a) | ||
37 | { | ||
38 | - static MVEGenDualAccOpFn * const fns[4][2] = { | ||
39 | + static MVEGenLongDualAccOpFn * const fns[4][2] = { | ||
40 | { NULL, NULL }, | ||
41 | { gen_helper_mve_vmlaldavsh, gen_helper_mve_vmlaldavxsh }, | ||
42 | { gen_helper_mve_vmlaldavsw, gen_helper_mve_vmlaldavxsw }, | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLALDAV_S(DisasContext *s, arg_vmlaldav *a) | ||
44 | |||
45 | static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) | ||
46 | { | ||
47 | - static MVEGenDualAccOpFn * const fns[4][2] = { | ||
48 | + static MVEGenLongDualAccOpFn * const fns[4][2] = { | ||
49 | { NULL, NULL }, | ||
50 | { gen_helper_mve_vmlaldavuh, NULL }, | ||
51 | { gen_helper_mve_vmlaldavuw, NULL }, | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) | ||
53 | |||
54 | static bool trans_VMLSLDAV(DisasContext *s, arg_vmlaldav *a) | ||
55 | { | ||
56 | - static MVEGenDualAccOpFn * const fns[4][2] = { | ||
57 | + static MVEGenLongDualAccOpFn * const fns[4][2] = { | ||
58 | { NULL, NULL }, | ||
59 | { gen_helper_mve_vmlsldavsh, gen_helper_mve_vmlsldavxsh }, | ||
60 | { gen_helper_mve_vmlsldavsw, gen_helper_mve_vmlsldavxsw }, | ||
61 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLSLDAV(DisasContext *s, arg_vmlaldav *a) | ||
62 | |||
63 | static bool trans_VRMLALDAVH_S(DisasContext *s, arg_vmlaldav *a) | ||
64 | { | ||
65 | - static MVEGenDualAccOpFn * const fns[] = { | ||
66 | + static MVEGenLongDualAccOpFn * const fns[] = { | ||
67 | gen_helper_mve_vrmlaldavhsw, gen_helper_mve_vrmlaldavhxsw, | ||
68 | }; | ||
69 | return do_long_dual_acc(s, a, fns[a->x]); | ||
70 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLALDAVH_S(DisasContext *s, arg_vmlaldav *a) | ||
71 | |||
72 | static bool trans_VRMLALDAVH_U(DisasContext *s, arg_vmlaldav *a) | ||
73 | { | ||
74 | - static MVEGenDualAccOpFn * const fns[] = { | ||
75 | + static MVEGenLongDualAccOpFn * const fns[] = { | ||
76 | gen_helper_mve_vrmlaldavhuw, NULL, | ||
77 | }; | ||
78 | return do_long_dual_acc(s, a, fns[a->x]); | ||
79 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLALDAVH_U(DisasContext *s, arg_vmlaldav *a) | ||
80 | |||
81 | static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) | ||
82 | { | ||
83 | - static MVEGenDualAccOpFn * const fns[] = { | ||
84 | + static MVEGenLongDualAccOpFn * const fns[] = { | ||
85 | gen_helper_mve_vrmlsldavhsw, gen_helper_mve_vrmlsldavhxsw, | ||
86 | }; | ||
87 | return do_long_dual_acc(s, a, fns[a->x]); | ||
88 | -- | ||
89 | 2.20.1 | ||
90 | |||
91 | diff view generated by jsdifflib |
1 | From: "Wen, Jianxian" <Jianxian.Wen@verisilicon.com> | 1 | M-profile CPUs generally allow configuration of the number of MPU |
---|---|---|---|
2 | regions that they have. We don't currently model this, so our | ||
3 | implementations of some of the board models provide CPUs with the | ||
4 | wrong number of regions. RTOSes like Zephyr that hardcode the | ||
5 | expected number of regions may therefore not run on the model if they | ||
6 | are set up to run on real hardware. | ||
2 | 7 | ||
3 | Add property memory region which can connect with IOMMU region to support SMMU translate. | 8 | Add properties mpu-ns-regions and mpu-s-regions to the ARMV7M object, |
9 | matching the ability of hardware to configure the number of Secure | ||
10 | and NonSecure regions separately. Our actual CPU implementation | ||
11 | doesn't currently support that, and it happens that none of the MPS | ||
12 | boards we model set the number of regions differently for Secure vs | ||
13 | NonSecure, so we provide an interface to the boards and SoCs that | ||
14 | won't need to change if we ever do add that functionality in future, | ||
15 | but make it an error to configure the two properties to different | ||
16 | values. | ||
4 | 17 | ||
5 | Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com> | 18 | (The property name on the CPU is the somewhat misnamed-for-M-profile |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 19 | "pmsav7-dregion", so we don't follow that naming convention for |
7 | Message-id: 4C23C17B8E87E74E906A25A3254A03F4FA1FEC31@SHASXM03.verisilicon.com | 20 | the properties here. The TRM doesn't say what the CPU configuration |
21 | variable names are, so we pick something, and follow the lowercase | ||
22 | convention we already have for properties here.) | ||
23 | |||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
26 | Message-id: 20230724174335.2150499-3-peter.maydell@linaro.org | ||
9 | --- | 27 | --- |
10 | hw/arm/exynos4210.c | 3 +++ | 28 | include/hw/arm/armv7m.h | 8 ++++++++ |
11 | hw/arm/xilinx_zynq.c | 3 +++ | 29 | hw/arm/armv7m.c | 21 +++++++++++++++++++++ |
12 | hw/dma/pl330.c | 26 ++++++++++++++++++++++---- | 30 | 2 files changed, 29 insertions(+) |
13 | 3 files changed, 28 insertions(+), 4 deletions(-) | ||
14 | 31 | ||
15 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 32 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h |
16 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/exynos4210.c | 34 | --- a/include/hw/arm/armv7m.h |
18 | +++ b/hw/arm/exynos4210.c | 35 | +++ b/include/hw/arm/armv7m.h |
19 | @@ -XXX,XX +XXX,XX @@ static DeviceState *pl330_create(uint32_t base, qemu_or_irq *orgate, | 36 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(ARMv7MState, ARMV7M) |
20 | int i; | 37 | * + Property "vfp": enable VFP (forwarded to CPU object) |
21 | 38 | * + Property "dsp": enable DSP (forwarded to CPU object) | |
22 | dev = qdev_new("pl330"); | 39 | * + Property "enable-bitband": expose bitbanded IO |
23 | + object_property_set_link(OBJECT(dev), "memory", | 40 | + * + Property "mpu-ns-regions": number of Non-Secure MPU regions (forwarded |
24 | + OBJECT(get_system_memory()), | 41 | + * to CPU object pmsav7-dregion property; default is whatever the default |
25 | + &error_fatal); | 42 | + * for the CPU is) |
26 | qdev_prop_set_uint8(dev, "num_events", nevents); | 43 | + * + Property "mpu-s-regions": number of Secure MPU regions (default is |
27 | qdev_prop_set_uint8(dev, "num_chnls", 8); | 44 | + * whatever the default for the CPU is; must currently be set to the same |
28 | qdev_prop_set_uint8(dev, "num_periph_req", nreq); | 45 | + * value as mpu-ns-regions if the CPU implements the Security Extension) |
29 | diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c | 46 | * + Clock input "refclk" is the external reference clock for the systick timers |
47 | * + Clock input "cpuclk" is the main CPU clock | ||
48 | */ | ||
49 | @@ -XXX,XX +XXX,XX @@ struct ARMv7MState { | ||
50 | Object *idau; | ||
51 | uint32_t init_svtor; | ||
52 | uint32_t init_nsvtor; | ||
53 | + uint32_t mpu_ns_regions; | ||
54 | + uint32_t mpu_s_regions; | ||
55 | bool enable_bitband; | ||
56 | bool start_powered_off; | ||
57 | bool vfp; | ||
58 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/hw/arm/xilinx_zynq.c | 60 | --- a/hw/arm/armv7m.c |
32 | +++ b/hw/arm/xilinx_zynq.c | 61 | +++ b/hw/arm/armv7m.c |
33 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) | 62 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) |
34 | sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[39-IRQ_OFFSET]); | ||
35 | |||
36 | dev = qdev_new("pl330"); | ||
37 | + object_property_set_link(OBJECT(dev), "memory", | ||
38 | + OBJECT(address_space_mem), | ||
39 | + &error_fatal); | ||
40 | qdev_prop_set_uint8(dev, "num_chnls", 8); | ||
41 | qdev_prop_set_uint8(dev, "num_periph_req", 4); | ||
42 | qdev_prop_set_uint8(dev, "num_events", 16); | ||
43 | diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/dma/pl330.c | ||
46 | +++ b/hw/dma/pl330.c | ||
47 | @@ -XXX,XX +XXX,XX @@ struct PL330State { | ||
48 | uint8_t num_faulting; | ||
49 | uint8_t periph_busy[PL330_PERIPH_NUM]; | ||
50 | |||
51 | + /* Memory region that DMA operation access */ | ||
52 | + MemoryRegion *mem_mr; | ||
53 | + AddressSpace *mem_as; | ||
54 | }; | ||
55 | |||
56 | #define TYPE_PL330 "pl330" | ||
57 | @@ -XXX,XX +XXX,XX @@ static inline const PL330InsnDesc *pl330_fetch_insn(PL330Chan *ch) | ||
58 | uint8_t opcode; | ||
59 | int i; | ||
60 | |||
61 | - dma_memory_read(&address_space_memory, ch->pc, &opcode, 1); | ||
62 | + dma_memory_read(ch->parent->mem_as, ch->pc, &opcode, 1); | ||
63 | for (i = 0; insn_desc[i].size; i++) { | ||
64 | if ((opcode & insn_desc[i].opmask) == insn_desc[i].opcode) { | ||
65 | return &insn_desc[i]; | ||
66 | @@ -XXX,XX +XXX,XX @@ static inline void pl330_exec_insn(PL330Chan *ch, const PL330InsnDesc *insn) | ||
67 | uint8_t buf[PL330_INSN_MAXSIZE]; | ||
68 | |||
69 | assert(insn->size <= PL330_INSN_MAXSIZE); | ||
70 | - dma_memory_read(&address_space_memory, ch->pc, buf, insn->size); | ||
71 | + dma_memory_read(ch->parent->mem_as, ch->pc, buf, insn->size); | ||
72 | insn->exec(ch, buf[0], &buf[1], insn->size - 1); | ||
73 | } | ||
74 | |||
75 | @@ -XXX,XX +XXX,XX @@ static int pl330_exec_cycle(PL330Chan *channel) | ||
76 | if (q != NULL && q->len <= pl330_fifo_num_free(&s->fifo)) { | ||
77 | int len = q->len - (q->addr & (q->len - 1)); | ||
78 | |||
79 | - dma_memory_read(&address_space_memory, q->addr, buf, len); | ||
80 | + dma_memory_read(s->mem_as, q->addr, buf, len); | ||
81 | trace_pl330_exec_cycle(q->addr, len); | ||
82 | if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { | ||
83 | pl330_hexdump(buf, len); | ||
84 | @@ -XXX,XX +XXX,XX @@ static int pl330_exec_cycle(PL330Chan *channel) | ||
85 | fifo_res = pl330_fifo_get(&s->fifo, buf, len, q->tag); | ||
86 | } | 63 | } |
87 | if (fifo_res == PL330_FIFO_OK || q->z) { | 64 | } |
88 | - dma_memory_write(&address_space_memory, q->addr, buf, len); | 65 | |
89 | + dma_memory_write(s->mem_as, q->addr, buf, len); | 66 | + /* |
90 | trace_pl330_exec_cycle(q->addr, len); | 67 | + * Real M-profile hardware can be configured with a different number of |
91 | if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { | 68 | + * MPU regions for Secure vs NonSecure. QEMU's CPU implementation doesn't |
92 | pl330_hexdump(buf, len); | 69 | + * support that yet, so catch attempts to select that. |
93 | @@ -XXX,XX +XXX,XX @@ static void pl330_realize(DeviceState *dev, Error **errp) | 70 | + */ |
94 | "dma", PL330_IOMEM_SIZE); | 71 | + if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) && |
95 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | 72 | + s->mpu_ns_regions != s->mpu_s_regions) { |
96 | 73 | + error_setg(errp, | |
97 | + if (!s->mem_mr) { | 74 | + "mpu-ns-regions and mpu-s-regions properties must have the same value"); |
98 | + error_setg(errp, "'memory' link is not set"); | ||
99 | + return; | 75 | + return; |
100 | + } else if (s->mem_mr == get_system_memory()) { | 76 | + } |
101 | + /* Avoid creating new AS for system memory. */ | 77 | + if (s->mpu_ns_regions != UINT_MAX && |
102 | + s->mem_as = &address_space_memory; | 78 | + object_property_find(OBJECT(s->cpu), "pmsav7-dregion")) { |
103 | + } else { | 79 | + if (!object_property_set_uint(OBJECT(s->cpu), "pmsav7-dregion", |
104 | + s->mem_as = g_new0(AddressSpace, 1); | 80 | + s->mpu_ns_regions, errp)) { |
105 | + address_space_init(s->mem_as, s->mem_mr, | 81 | + return; |
106 | + memory_region_name(s->mem_mr)); | 82 | + } |
107 | + } | 83 | + } |
108 | + | 84 | + |
109 | s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pl330_exec_cycle_timer, s); | 85 | /* |
110 | 86 | * Tell the CPU where the NVIC is; it will fail realize if it doesn't | |
111 | s->cfg[0] = (s->mgr_ns_at_rst ? 0x4 : 0) | | 87 | * have one. Similarly, tell the NVIC where its CPU is. |
112 | @@ -XXX,XX +XXX,XX @@ static Property pl330_properties[] = { | 88 | @@ -XXX,XX +XXX,XX @@ static Property armv7m_properties[] = { |
113 | DEFINE_PROP_UINT8("rd_q_dep", PL330State, rd_q_dep, 16), | 89 | false), |
114 | DEFINE_PROP_UINT16("data_buffer_dep", PL330State, data_buffer_dep, 256), | 90 | DEFINE_PROP_BOOL("vfp", ARMv7MState, vfp, true), |
115 | 91 | DEFINE_PROP_BOOL("dsp", ARMv7MState, dsp, true), | |
116 | + DEFINE_PROP_LINK("memory", PL330State, mem_mr, | 92 | + DEFINE_PROP_UINT32("mpu-ns-regions", ARMv7MState, mpu_ns_regions, UINT_MAX), |
117 | + TYPE_MEMORY_REGION, MemoryRegion *), | 93 | + DEFINE_PROP_UINT32("mpu-s-regions", ARMv7MState, mpu_s_regions, UINT_MAX), |
118 | + | ||
119 | DEFINE_PROP_END_OF_LIST(), | 94 | DEFINE_PROP_END_OF_LIST(), |
120 | }; | 95 | }; |
121 | 96 | ||
122 | -- | 97 | -- |
123 | 2.20.1 | 98 | 2.34.1 |
124 | 99 | ||
125 | 100 | diff view generated by jsdifflib |
1 | Implement the MVE VMLADAV and VMLSLDAV insns. Like the VMLALDAV and | 1 | The IoTKit, SSE200 and SSE300 all default to 8 MPU regions. The |
---|---|---|---|
2 | VMLSLDAV insns already implemented, these accumulate multiplied | 2 | MPS2/MPS3 FPGA images don't override these except in the case of |
3 | vector elements; but they accumulate a 32-bit result rather than a | 3 | AN547, which uses 16 MPU regions. |
4 | 64-bit one. | 4 | |
5 | 5 | Define properties on the ARMSSE object for the MPU regions (using the | |
6 | Note that these encodings overlap with what would be RdaHi=0b111 for | 6 | same names as the documented RTL configuration settings, and |
7 | VMLALDAV, VMLSLDAV, VRMLALDAVH and VRMLSLDAVH. | 7 | following the pattern we already have for this device of using |
8 | 8 | all-caps names as the RTL does), and set them in the board code. | |
9 | |||
10 | We don't actually need to override the default except on AN547, | ||
11 | but it's simpler code to have the board code set them always | ||
12 | rather than tracking which board subtypes want to set them to | ||
13 | a non-default value separately from what that value is. | ||
14 | |||
15 | Tho overall effect is that for mps2-an505, mps2-an521 and mps3-an524 | ||
16 | we now correctly use 8 MPU regions, while mps3-an547 stays at its | ||
17 | current 16 regions. | ||
18 | |||
19 | It's possible some guest code wrongly depended on the previous | ||
20 | incorrectly modeled number of memory regions. (Such guest code | ||
21 | should ideally check the number of regions via the MPU_TYPE | ||
22 | register.) The old behaviour can be obtained with additional | ||
23 | -global arguments to QEMU: | ||
24 | |||
25 | For mps2-an521 and mps2-an524: | ||
26 | -global sse-200.CPU0_MPU_NS=16 -global sse-200.CPU0_MPU_S=16 -global sse-200.CPU1_MPU_NS=16 -global sse-200.CPU1_MPU_S=16 | ||
27 | |||
28 | For mps2-an505: | ||
29 | -global sse-200.CPU0_MPU_NS=16 -global sse-200.CPU0_MPU_S=16 | ||
30 | |||
31 | NB that the way the implementation allows this use of -global | ||
32 | is slightly fragile: if the board code explicitly sets the | ||
33 | properties on the sse-200 object, this overrides the -global | ||
34 | command line option. So we rely on: | ||
35 | - the boards that need fixing all happen to use the SSE defaults | ||
36 | - we can write the board code to only set the property if it | ||
37 | is different from the default, rather than having all boards | ||
38 | explicitly set the property | ||
39 | - the board that does need to use a non-default value happens | ||
40 | to need to set it to the same value (16) we previously used | ||
41 | This works, but there are some kinds of refactoring of the | ||
42 | mps2-tz.c code that would break the support for -global here. | ||
43 | |||
44 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1772 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 45 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 46 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
47 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
48 | Message-id: 20230724174335.2150499-4-peter.maydell@linaro.org | ||
11 | --- | 49 | --- |
12 | target/arm/helper-mve.h | 17 ++++++++++ | 50 | include/hw/arm/armsse.h | 5 +++++ |
13 | target/arm/mve.decode | 33 +++++++++++++++++--- | 51 | hw/arm/armsse.c | 16 ++++++++++++++++ |
14 | target/arm/mve_helper.c | 41 ++++++++++++++++++++++++ | 52 | hw/arm/mps2-tz.c | 29 +++++++++++++++++++++++++++++ |
15 | target/arm/translate-mve.c | 64 ++++++++++++++++++++++++++++++++++++++ | 53 | 3 files changed, 50 insertions(+) |
16 | 4 files changed, 150 insertions(+), 5 deletions(-) | 54 | |
17 | 55 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h | |
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | 56 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper-mve.h | 57 | --- a/include/hw/arm/armsse.h |
21 | +++ b/target/arm/helper-mve.h | 58 | +++ b/include/hw/arm/armsse.h |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrmlaldavhuw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | 59 | @@ -XXX,XX +XXX,XX @@ |
23 | DEF_HELPER_FLAGS_4(mve_vrmlsldavhsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | 60 | * (matching the hardware) is that for CPU0 in an IoTKit and CPU1 in an |
24 | DEF_HELPER_FLAGS_4(mve_vrmlsldavhxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | 61 | * SSE-200 both are present; CPU0 in an SSE-200 has neither. |
25 | 62 | * Since the IoTKit has only one CPU, it does not have the CPU1_* properties. | |
26 | +DEF_HELPER_FLAGS_4(mve_vmladavsb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 63 | + * + QOM properties "CPU0_MPU_NS", "CPU0_MPU_S", "CPU1_MPU_NS" and "CPU1_MPU_S" |
27 | +DEF_HELPER_FLAGS_4(mve_vmladavsh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 64 | + * which set the number of MPU regions on the CPUs. If there is only one |
28 | +DEF_HELPER_FLAGS_4(mve_vmladavsw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 65 | + * CPU the CPU1 properties are not present. |
29 | +DEF_HELPER_FLAGS_4(mve_vmladavub, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 66 | * + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts for CPU 0, |
30 | +DEF_HELPER_FLAGS_4(mve_vmladavuh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 67 | * which are wired to its NVIC lines 32 .. n+32 |
31 | +DEF_HELPER_FLAGS_4(mve_vmladavuw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 68 | * + Named GPIO inputs "EXP_CPU1_IRQ" 0..n are the expansion interrupts for |
32 | +DEF_HELPER_FLAGS_4(mve_vmlsdavb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 69 | @@ -XXX,XX +XXX,XX @@ struct ARMSSE { |
33 | +DEF_HELPER_FLAGS_4(mve_vmlsdavh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 70 | uint32_t exp_numirq; |
34 | +DEF_HELPER_FLAGS_4(mve_vmlsdavw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 71 | uint32_t sram_addr_width; |
72 | uint32_t init_svtor; | ||
73 | + uint32_t cpu_mpu_ns[SSE_MAX_CPUS]; | ||
74 | + uint32_t cpu_mpu_s[SSE_MAX_CPUS]; | ||
75 | bool cpu_fpu[SSE_MAX_CPUS]; | ||
76 | bool cpu_dsp[SSE_MAX_CPUS]; | ||
77 | }; | ||
78 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/hw/arm/armsse.c | ||
81 | +++ b/hw/arm/armsse.c | ||
82 | @@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = { | ||
83 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
84 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), | ||
85 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true), | ||
86 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), | ||
87 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), | ||
88 | DEFINE_PROP_END_OF_LIST() | ||
89 | }; | ||
90 | |||
91 | @@ -XXX,XX +XXX,XX @@ static Property sse200_properties[] = { | ||
92 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], false), | ||
93 | DEFINE_PROP_BOOL("CPU1_FPU", ARMSSE, cpu_fpu[1], true), | ||
94 | DEFINE_PROP_BOOL("CPU1_DSP", ARMSSE, cpu_dsp[1], true), | ||
95 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), | ||
96 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), | ||
97 | + DEFINE_PROP_UINT32("CPU1_MPU_NS", ARMSSE, cpu_mpu_ns[1], 8), | ||
98 | + DEFINE_PROP_UINT32("CPU1_MPU_S", ARMSSE, cpu_mpu_s[1], 8), | ||
99 | DEFINE_PROP_END_OF_LIST() | ||
100 | }; | ||
101 | |||
102 | @@ -XXX,XX +XXX,XX @@ static Property sse300_properties[] = { | ||
103 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
104 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), | ||
105 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true), | ||
106 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), | ||
107 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), | ||
108 | DEFINE_PROP_END_OF_LIST() | ||
109 | }; | ||
110 | |||
111 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
112 | return; | ||
113 | } | ||
114 | } | ||
115 | + if (!object_property_set_uint(cpuobj, "mpu-ns-regions", | ||
116 | + s->cpu_mpu_ns[i], errp)) { | ||
117 | + return; | ||
118 | + } | ||
119 | + if (!object_property_set_uint(cpuobj, "mpu-s-regions", | ||
120 | + s->cpu_mpu_s[i], errp)) { | ||
121 | + return; | ||
122 | + } | ||
123 | |||
124 | if (i > 0) { | ||
125 | memory_region_add_subregion_overlap(&s->cpu_container[i], 0, | ||
126 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
127 | index XXXXXXX..XXXXXXX 100644 | ||
128 | --- a/hw/arm/mps2-tz.c | ||
129 | +++ b/hw/arm/mps2-tz.c | ||
130 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineClass { | ||
131 | int uart_overflow_irq; /* number of the combined UART overflow IRQ */ | ||
132 | uint32_t init_svtor; /* init-svtor setting for SSE */ | ||
133 | uint32_t sram_addr_width; /* SRAM_ADDR_WIDTH setting for SSE */ | ||
134 | + uint32_t cpu0_mpu_ns; /* CPU0_MPU_NS setting for SSE */ | ||
135 | + uint32_t cpu0_mpu_s; /* CPU0_MPU_S setting for SSE */ | ||
136 | + uint32_t cpu1_mpu_ns; /* CPU1_MPU_NS setting for SSE */ | ||
137 | + uint32_t cpu1_mpu_s; /* CPU1_MPU_S setting for SSE */ | ||
138 | const RAMInfo *raminfo; | ||
139 | const char *armsse_type; | ||
140 | uint32_t boot_ram_size; /* size of ram at address 0; 0 == find in raminfo */ | ||
141 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE) | ||
142 | #define MPS3_DDR_SIZE (2 * GiB) | ||
143 | #endif | ||
144 | |||
145 | +/* For cpu{0,1}_mpu_{ns,s}, means "leave at SSE's default value" */ | ||
146 | +#define MPU_REGION_DEFAULT UINT32_MAX | ||
35 | + | 147 | + |
36 | +DEF_HELPER_FLAGS_4(mve_vmladavsxb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 148 | static const uint32_t an505_oscclk[] = { |
37 | +DEF_HELPER_FLAGS_4(mve_vmladavsxh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 149 | 40000000, |
38 | +DEF_HELPER_FLAGS_4(mve_vmladavsxw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 150 | 24580000, |
39 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 151 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) |
40 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 152 | OBJECT(system_memory), &error_abort); |
41 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | 153 | qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", mmc->numirq); |
154 | qdev_prop_set_uint32(iotkitdev, "init-svtor", mmc->init_svtor); | ||
155 | + if (mmc->cpu0_mpu_ns != MPU_REGION_DEFAULT) { | ||
156 | + qdev_prop_set_uint32(iotkitdev, "CPU0_MPU_NS", mmc->cpu0_mpu_ns); | ||
157 | + } | ||
158 | + if (mmc->cpu0_mpu_s != MPU_REGION_DEFAULT) { | ||
159 | + qdev_prop_set_uint32(iotkitdev, "CPU0_MPU_S", mmc->cpu0_mpu_s); | ||
160 | + } | ||
161 | + if (object_property_find(OBJECT(iotkitdev), "CPU1_MPU_NS")) { | ||
162 | + if (mmc->cpu1_mpu_ns != MPU_REGION_DEFAULT) { | ||
163 | + qdev_prop_set_uint32(iotkitdev, "CPU1_MPU_NS", mmc->cpu1_mpu_ns); | ||
164 | + } | ||
165 | + if (mmc->cpu1_mpu_s != MPU_REGION_DEFAULT) { | ||
166 | + qdev_prop_set_uint32(iotkitdev, "CPU1_MPU_S", mmc->cpu1_mpu_s); | ||
167 | + } | ||
168 | + } | ||
169 | qdev_prop_set_uint32(iotkitdev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); | ||
170 | qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk); | ||
171 | qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk); | ||
172 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_class_init(ObjectClass *oc, void *data) | ||
173 | { | ||
174 | MachineClass *mc = MACHINE_CLASS(oc); | ||
175 | IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(oc); | ||
176 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_CLASS(oc); | ||
177 | |||
178 | mc->init = mps2tz_common_init; | ||
179 | mc->reset = mps2_machine_reset; | ||
180 | iic->check = mps2_tz_idau_check; | ||
42 | + | 181 | + |
43 | DEF_HELPER_FLAGS_3(mve_vaddvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) | 182 | + /* Most machines leave these at the SSE defaults */ |
44 | DEF_HELPER_FLAGS_3(mve_vaddvub, TCG_CALL_NO_WG, i32, env, ptr, i32) | 183 | + mmc->cpu0_mpu_ns = MPU_REGION_DEFAULT; |
45 | DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | 184 | + mmc->cpu0_mpu_s = MPU_REGION_DEFAULT; |
46 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 185 | + mmc->cpu1_mpu_ns = MPU_REGION_DEFAULT; |
47 | index XXXXXXX..XXXXXXX 100644 | 186 | + mmc->cpu1_mpu_s = MPU_REGION_DEFAULT; |
48 | --- a/target/arm/mve.decode | ||
49 | +++ b/target/arm/mve.decode | ||
50 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
51 | %size_16 16:1 !function=plus_1 | ||
52 | |||
53 | &vmlaldav rdahi rdalo size qn qm x a | ||
54 | +&vmladav rda size qn qm x a | ||
55 | |||
56 | @vmlaldav .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
57 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav | ||
58 | @vmlaldav_nosz .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
59 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=0 &vmlaldav | ||
60 | -VMLALDAV_S 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
61 | -VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
62 | +@vmladav .... .... .... ... . ... x:1 .... . . a:1 . qm:3 . \ | ||
63 | + qn=%qn rda=%rdalo size=%size_16 &vmladav | ||
64 | +@vmladav_nosz .... .... .... ... . ... x:1 .... . . a:1 . qm:3 . \ | ||
65 | + qn=%qn rda=%rdalo size=0 &vmladav | ||
66 | |||
67 | -VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
68 | +{ | ||
69 | + VMLADAV_S 1110 1110 1111 ... . ... . 1110 . 0 . 0 ... 0 @vmladav | ||
70 | + VMLALDAV_S 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
71 | +} | ||
72 | +{ | ||
73 | + VMLADAV_U 1111 1110 1111 ... . ... . 1110 . 0 . 0 ... 0 @vmladav | ||
74 | + VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
75 | +} | ||
76 | + | ||
77 | +{ | ||
78 | + VMLSDAV 1110 1110 1111 ... . ... . 1110 . 0 . 0 ... 1 @vmladav | ||
79 | + VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
80 | +} | ||
81 | + | ||
82 | +{ | ||
83 | + VMLSDAV 1111 1110 1111 ... 0 ... . 1110 . 0 . 0 ... 1 @vmladav_nosz | ||
84 | + VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | ||
85 | +} | ||
86 | + | ||
87 | +VMLADAV_S 1110 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 1 @vmladav_nosz | ||
88 | +VMLADAV_U 1111 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 1 @vmladav_nosz | ||
89 | |||
90 | { | ||
91 | VMAXV_S 1110 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
92 | VMINV_S 1110 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
93 | VMAXAV 1110 1110 1110 .. 00 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
94 | VMINAV 1110 1110 1110 .. 00 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
95 | + VMLADAV_S 1110 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 0 @vmladav_nosz | ||
96 | VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
97 | } | 187 | } |
98 | 188 | ||
99 | { | 189 | static void mps2tz_set_default_ram_info(MPS2TZMachineClass *mmc) |
100 | VMAXV_U 1111 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | 190 | @@ -XXX,XX +XXX,XX @@ static void mps3tz_an547_class_init(ObjectClass *oc, void *data) |
101 | VMINV_U 1111 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | 191 | mmc->numirq = 96; |
102 | + VMLADAV_U 1111 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 0 @vmladav_nosz | 192 | mmc->uart_overflow_irq = 48; |
103 | VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | 193 | mmc->init_svtor = 0x00000000; |
104 | } | 194 | + mmc->cpu0_mpu_s = mmc->cpu0_mpu_ns = 16; |
105 | 195 | mmc->sram_addr_width = 21; | |
106 | -VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | 196 | mmc->raminfo = an547_raminfo; |
107 | - | 197 | mmc->armsse_type = TYPE_SSE300; |
108 | # Scalar operations | ||
109 | |||
110 | VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar | ||
111 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/target/arm/mve_helper.c | ||
114 | +++ b/target/arm/mve_helper.c | ||
115 | @@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavxsh, 2, int16_t, true, +=, -=) | ||
116 | DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=) | ||
117 | DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=) | ||
118 | |||
119 | +/* | ||
120 | + * Multiply add dual accumulate ops | ||
121 | + */ | ||
122 | +#define DO_DAV(OP, ESIZE, TYPE, XCHG, EVENACC, ODDACC) \ | ||
123 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
124 | + void *vm, uint32_t a) \ | ||
125 | + { \ | ||
126 | + uint16_t mask = mve_element_mask(env); \ | ||
127 | + unsigned e; \ | ||
128 | + TYPE *n = vn, *m = vm; \ | ||
129 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
130 | + if (mask & 1) { \ | ||
131 | + if (e & 1) { \ | ||
132 | + a ODDACC \ | ||
133 | + n[H##ESIZE(e - 1 * XCHG)] * m[H##ESIZE(e)]; \ | ||
134 | + } else { \ | ||
135 | + a EVENACC \ | ||
136 | + n[H##ESIZE(e + 1 * XCHG)] * m[H##ESIZE(e)]; \ | ||
137 | + } \ | ||
138 | + } \ | ||
139 | + } \ | ||
140 | + mve_advance_vpt(env); \ | ||
141 | + return a; \ | ||
142 | + } | ||
143 | + | ||
144 | +#define DO_DAV_S(INSN, XCHG, EVENACC, ODDACC) \ | ||
145 | + DO_DAV(INSN##b, 1, int8_t, XCHG, EVENACC, ODDACC) \ | ||
146 | + DO_DAV(INSN##h, 2, int16_t, XCHG, EVENACC, ODDACC) \ | ||
147 | + DO_DAV(INSN##w, 4, int32_t, XCHG, EVENACC, ODDACC) | ||
148 | + | ||
149 | +#define DO_DAV_U(INSN, XCHG, EVENACC, ODDACC) \ | ||
150 | + DO_DAV(INSN##b, 1, uint8_t, XCHG, EVENACC, ODDACC) \ | ||
151 | + DO_DAV(INSN##h, 2, uint16_t, XCHG, EVENACC, ODDACC) \ | ||
152 | + DO_DAV(INSN##w, 4, uint32_t, XCHG, EVENACC, ODDACC) | ||
153 | + | ||
154 | +DO_DAV_S(vmladavs, false, +=, +=) | ||
155 | +DO_DAV_U(vmladavu, false, +=, +=) | ||
156 | +DO_DAV_S(vmlsdav, false, +=, -=) | ||
157 | +DO_DAV_S(vmladavsx, true, +=, +=) | ||
158 | +DO_DAV_S(vmlsdavx, true, +=, -=) | ||
159 | + | ||
160 | /* | ||
161 | * Rounding multiply add long dual accumulate high. In the pseudocode | ||
162 | * this is implemented with a 72-bit internal accumulator value of which | ||
163 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/target/arm/translate-mve.c | ||
166 | +++ b/target/arm/translate-mve.c | ||
167 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TC | ||
168 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
169 | typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
170 | typedef void MVEGenVABAVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
171 | +typedef void MVEGenDualAccOpFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
172 | |||
173 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
174 | static inline long mve_qreg_offset(unsigned reg) | ||
175 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) | ||
176 | return do_long_dual_acc(s, a, fns[a->x]); | ||
177 | } | ||
178 | |||
179 | +static bool do_dual_acc(DisasContext *s, arg_vmladav *a, MVEGenDualAccOpFn *fn) | ||
180 | +{ | ||
181 | + TCGv_ptr qn, qm; | ||
182 | + TCGv_i32 rda; | ||
183 | + | ||
184 | + if (!dc_isar_feature(aa32_mve, s) || | ||
185 | + !mve_check_qreg_bank(s, a->qn) || | ||
186 | + !fn) { | ||
187 | + return false; | ||
188 | + } | ||
189 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
190 | + return true; | ||
191 | + } | ||
192 | + | ||
193 | + qn = mve_qreg_ptr(a->qn); | ||
194 | + qm = mve_qreg_ptr(a->qm); | ||
195 | + | ||
196 | + /* | ||
197 | + * This insn is subject to beat-wise execution. Partial execution | ||
198 | + * of an A=0 (no-accumulate) insn which does not execute the first | ||
199 | + * beat must start with the current rda value, not 0. | ||
200 | + */ | ||
201 | + if (a->a || mve_skip_first_beat(s)) { | ||
202 | + rda = load_reg(s, a->rda); | ||
203 | + } else { | ||
204 | + rda = tcg_const_i32(0); | ||
205 | + } | ||
206 | + | ||
207 | + fn(rda, cpu_env, qn, qm, rda); | ||
208 | + store_reg(s, a->rda, rda); | ||
209 | + tcg_temp_free_ptr(qn); | ||
210 | + tcg_temp_free_ptr(qm); | ||
211 | + | ||
212 | + mve_update_eci(s); | ||
213 | + return true; | ||
214 | +} | ||
215 | + | ||
216 | +#define DO_DUAL_ACC(INSN, FN) \ | ||
217 | + static bool trans_##INSN(DisasContext *s, arg_vmladav *a) \ | ||
218 | + { \ | ||
219 | + static MVEGenDualAccOpFn * const fns[4][2] = { \ | ||
220 | + { gen_helper_mve_##FN##b, gen_helper_mve_##FN##xb }, \ | ||
221 | + { gen_helper_mve_##FN##h, gen_helper_mve_##FN##xh }, \ | ||
222 | + { gen_helper_mve_##FN##w, gen_helper_mve_##FN##xw }, \ | ||
223 | + { NULL, NULL }, \ | ||
224 | + }; \ | ||
225 | + return do_dual_acc(s, a, fns[a->size][a->x]); \ | ||
226 | + } | ||
227 | + | ||
228 | +DO_DUAL_ACC(VMLADAV_S, vmladavs) | ||
229 | +DO_DUAL_ACC(VMLSDAV, vmlsdav) | ||
230 | + | ||
231 | +static bool trans_VMLADAV_U(DisasContext *s, arg_vmladav *a) | ||
232 | +{ | ||
233 | + static MVEGenDualAccOpFn * const fns[4][2] = { | ||
234 | + { gen_helper_mve_vmladavub, NULL }, | ||
235 | + { gen_helper_mve_vmladavuh, NULL }, | ||
236 | + { gen_helper_mve_vmladavuw, NULL }, | ||
237 | + { NULL, NULL }, | ||
238 | + }; | ||
239 | + return do_dual_acc(s, a, fns[a->size][a->x]); | ||
240 | +} | ||
241 | + | ||
242 | static void gen_vpst(DisasContext *s, uint32_t mask) | ||
243 | { | ||
244 | /* | ||
245 | -- | 198 | -- |
246 | 2.20.1 | 199 | 2.34.1 |
247 | 200 | ||
248 | 201 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMLA insn, which multiplies a vector by a scalar | ||
2 | and accumulates into another vector. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 4 ++++ | ||
8 | target/arm/mve.decode | 1 + | ||
9 | target/arm/mve_helper.c | 5 +++++ | ||
10 | target/arm/translate-mve.c | 1 + | ||
11 | 4 files changed, 11 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper-mve.h | ||
16 | +++ b/target/arm/helper-mve.h | ||
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i3 | ||
18 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | |||
21 | +DEF_HELPER_FLAGS_4(mve_vmlab, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vmlah, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vmlaw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | DEF_HELPER_FLAGS_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | DEF_HELPER_FLAGS_4(mve_vmlash, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | DEF_HELPER_FLAGS_4(mve_vmlasw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/mve.decode | ||
31 | +++ b/target/arm/mve.decode | ||
32 | @@ -XXX,XX +XXX,XX @@ VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
33 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
34 | |||
35 | # The U bit (28) is don't-care because it does not affect the result | ||
36 | +VMLA 111- 1110 0 . .. ... 1 ... 0 1110 . 100 .... @2scalar | ||
37 | VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
38 | |||
39 | # Vector add across vector | ||
40 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/mve_helper.c | ||
43 | +++ b/target/arm/mve_helper.c | ||
44 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) | ||
45 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) | ||
46 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W) | ||
47 | |||
48 | +/* Vector by scalar plus vector */ | ||
49 | +#define DO_VMLA(D, N, M) ((N) * (M) + (D)) | ||
50 | + | ||
51 | +DO_2OP_ACC_SCALAR_U(vmla, DO_VMLA) | ||
52 | + | ||
53 | /* Vector by vector plus scalar */ | ||
54 | #define DO_VMLAS(D, N, M) ((N) * (D) + (M)) | ||
55 | |||
56 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/translate-mve.c | ||
59 | +++ b/target/arm/translate-mve.c | ||
60 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VQSUB_U_scalar, vqsubu_scalar) | ||
61 | DO_2OP_SCALAR(VQDMULH_scalar, vqdmulh_scalar) | ||
62 | DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) | ||
63 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
64 | +DO_2OP_SCALAR(VMLA, vmla) | ||
65 | DO_2OP_SCALAR(VMLAS, vmlas) | ||
66 | |||
67 | static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a) | ||
68 | -- | ||
69 | 2.20.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE 1-operand saturating operations VQABS and VQNEG. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | target/arm/helper-mve.h | 8 ++++++++ | ||
7 | target/arm/mve.decode | 3 +++ | ||
8 | target/arm/mve_helper.c | 37 +++++++++++++++++++++++++++++++++++++ | ||
9 | target/arm/translate-mve.c | 2 ++ | ||
10 | 4 files changed, 50 insertions(+) | ||
11 | |||
12 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper-mve.h | ||
15 | +++ b/target/arm/helper-mve.h | ||
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
17 | DEF_HELPER_FLAGS_3(mve_vfnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_3(mve_vfnegs, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
19 | |||
20 | +DEF_HELPER_FLAGS_3(mve_vqabsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | +DEF_HELPER_FLAGS_3(mve_vqabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
22 | +DEF_HELPER_FLAGS_3(mve_vqabsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
23 | + | ||
24 | +DEF_HELPER_FLAGS_3(mve_vqnegb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_3(mve_vqnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vqnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | + | ||
28 | DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/mve.decode | ||
34 | +++ b/target/arm/mve.decode | ||
35 | @@ -XXX,XX +XXX,XX @@ VABS_fp 1111 1111 1 . 11 .. 01 ... 0 0111 01 . 0 ... 0 @1op | ||
36 | VNEG 1111 1111 1 . 11 .. 01 ... 0 0011 11 . 0 ... 0 @1op | ||
37 | VNEG_fp 1111 1111 1 . 11 .. 01 ... 0 0111 11 . 0 ... 0 @1op | ||
38 | |||
39 | +VQABS 1111 1111 1 . 11 .. 00 ... 0 0111 01 . 0 ... 0 @1op | ||
40 | +VQNEG 1111 1111 1 . 11 .. 00 ... 0 0111 11 . 0 ... 0 @1op | ||
41 | + | ||
42 | &vdup qd rt size | ||
43 | # Qd is in the fields usually named Qn | ||
44 | @vdup .... .... . . .. ... . rt:4 .... . . . . .... qd=%qn &vdup | ||
45 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/mve_helper.c | ||
48 | +++ b/target/arm/mve_helper.c | ||
49 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vpsel)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
50 | } | ||
51 | mve_advance_vpt(env); | ||
52 | } | ||
53 | + | ||
54 | +#define DO_1OP_SAT(OP, ESIZE, TYPE, FN) \ | ||
55 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
56 | + { \ | ||
57 | + TYPE *d = vd, *m = vm; \ | ||
58 | + uint16_t mask = mve_element_mask(env); \ | ||
59 | + unsigned e; \ | ||
60 | + bool qc = false; \ | ||
61 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
62 | + bool sat = false; \ | ||
63 | + mergemask(&d[H##ESIZE(e)], FN(m[H##ESIZE(e)], &sat), mask); \ | ||
64 | + qc |= sat & mask & 1; \ | ||
65 | + } \ | ||
66 | + if (qc) { \ | ||
67 | + env->vfp.qc[0] = qc; \ | ||
68 | + } \ | ||
69 | + mve_advance_vpt(env); \ | ||
70 | + } | ||
71 | + | ||
72 | +#define DO_VQABS_B(N, SATP) \ | ||
73 | + do_sat_bhs(DO_ABS((int64_t)N), INT8_MIN, INT8_MAX, SATP) | ||
74 | +#define DO_VQABS_H(N, SATP) \ | ||
75 | + do_sat_bhs(DO_ABS((int64_t)N), INT16_MIN, INT16_MAX, SATP) | ||
76 | +#define DO_VQABS_W(N, SATP) \ | ||
77 | + do_sat_bhs(DO_ABS((int64_t)N), INT32_MIN, INT32_MAX, SATP) | ||
78 | + | ||
79 | +#define DO_VQNEG_B(N, SATP) do_sat_bhs(-(int64_t)N, INT8_MIN, INT8_MAX, SATP) | ||
80 | +#define DO_VQNEG_H(N, SATP) do_sat_bhs(-(int64_t)N, INT16_MIN, INT16_MAX, SATP) | ||
81 | +#define DO_VQNEG_W(N, SATP) do_sat_bhs(-(int64_t)N, INT32_MIN, INT32_MAX, SATP) | ||
82 | + | ||
83 | +DO_1OP_SAT(vqabsb, 1, int8_t, DO_VQABS_B) | ||
84 | +DO_1OP_SAT(vqabsh, 2, int16_t, DO_VQABS_H) | ||
85 | +DO_1OP_SAT(vqabsw, 4, int32_t, DO_VQABS_W) | ||
86 | + | ||
87 | +DO_1OP_SAT(vqnegb, 1, int8_t, DO_VQNEG_B) | ||
88 | +DO_1OP_SAT(vqnegh, 2, int16_t, DO_VQNEG_H) | ||
89 | +DO_1OP_SAT(vqnegw, 4, int32_t, DO_VQNEG_W) | ||
90 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/translate-mve.c | ||
93 | +++ b/target/arm/translate-mve.c | ||
94 | @@ -XXX,XX +XXX,XX @@ DO_1OP(VCLZ, vclz) | ||
95 | DO_1OP(VCLS, vcls) | ||
96 | DO_1OP(VABS, vabs) | ||
97 | DO_1OP(VNEG, vneg) | ||
98 | +DO_1OP(VQABS, vqabs) | ||
99 | +DO_1OP(VQNEG, vqneg) | ||
100 | |||
101 | /* Narrowing moves: only size 0 and 1 are valid */ | ||
102 | #define DO_VMOVN(INSN, FN) \ | ||
103 | -- | ||
104 | 2.20.1 | ||
105 | |||
106 | diff view generated by jsdifflib |