1 | The following changes since commit 5a67d7735d4162630769ef495cf813244fc850df: | 1 | Here's another arm pullreq; nothing too exciting in here I think. |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/berrange-gitlab/tags/tls-deps-pull-request' into staging (2021-07-02 08:22:39 +0100) | 3 | thanks |
4 | -- PMM | ||
5 | |||
6 | The following changes since commit 5fee33d97a7f2e95716417bd164f2f5264acd976: | ||
7 | |||
8 | Merge tag 'samuel-thibault' of https://people.debian.org/~sthibault/qemu into staging (2024-04-29 14:34:25 -0700) | ||
4 | 9 | ||
5 | are available in the Git repository at: | 10 | are available in the Git repository at: |
6 | 11 | ||
7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210702 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240430 |
8 | 13 | ||
9 | for you to fetch changes up to 04ea4d3cfd0a21b248ece8eb7a9436a3d9898dd8: | 14 | for you to fetch changes up to a0c325c4b05cf7815739d6a84e567b95c8c5be7e: |
10 | 15 | ||
11 | target/arm: Implement MVE shifts by register (2021-07-02 11:48:38 +0100) | 16 | tests/qtest : Add testcase for DM163 (2024-04-30 16:05:08 +0100) |
12 | 17 | ||
13 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
14 | target-arm queue: | 19 | target-arm queue: |
15 | * more MVE instructions | 20 | * hw/core/clock: allow clock_propagate on child clocks |
16 | * hw/gpio/gpio_pwr: use shutdown function for reboot | 21 | * hvf: arm: Remove unused PL1_WRITE_MASK define |
17 | * target/arm: Check NaN mode before silencing NaN | 22 | * target/arm: Restrict translation disabled alignment check to VMSA |
18 | * tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine | 23 | * docs/system/arm/emulation.rst: Add missing implemented features |
19 | * hw/arm: Add basic power management to raspi. | 24 | * target/arm: Enable FEAT_CSV2_3, FEAT_ETS2, FEAT_Spec_FPACC for 'max' |
20 | * docs/system/arm: Add quanta-gbs-bmc, quanta-q7l1-bmc | 25 | * tests/avocado: update sunxi kernel from armbian to 6.6.16 |
26 | * target/arm: Make new CPUs default to 1GHz generic timer | ||
27 | * hw/dmax/xlnx_dpdma: fix handling of address_extension descriptor fields | ||
28 | * hw/char/stm32l4x5_usart: Fix memory corruption by adding correct class_size | ||
29 | * hw/arm/npcm7xx: Store derivative OTP fuse key in little endian | ||
30 | * hw/arm: Add DM163 display to B-L475E-IOT01A board | ||
21 | 31 | ||
22 | ---------------------------------------------------------------- | 32 | ---------------------------------------------------------------- |
23 | Joe Komlodi (1): | 33 | Alexandra Diupina (1): |
24 | target/arm: Check NaN mode before silencing NaN | 34 | hw/dmax/xlnx_dpdma: fix handling of address_extension descriptor fields |
25 | 35 | ||
26 | Maxim Uvarov (1): | 36 | Inès Varhol (5): |
27 | hw/gpio/gpio_pwr: use shutdown function for reboot | 37 | hw/display : Add device DM163 |
38 | hw/arm : Pass STM32L4x5 SYSCFG gpios to STM32L4x5 SoC | ||
39 | hw/arm : Create Bl475eMachineState | ||
40 | hw/arm : Connect DM163 to B-L475E-IOT01A | ||
41 | tests/qtest : Add testcase for DM163 | ||
28 | 42 | ||
29 | Nolan Leake (1): | 43 | Peter Maydell (10): |
30 | hw/arm: Add basic power management to raspi. | 44 | docs/system/arm/emulation.rst: Add missing implemented features |
31 | 45 | target/arm: Enable FEAT_CSV2_3 for -cpu max | |
32 | Patrick Venture (2): | 46 | target/arm: Enable FEAT_ETS2 for -cpu max |
33 | docs/system/arm: Add quanta-q7l1-bmc reference | 47 | target/arm: Implement ID_AA64MMFR3_EL1 |
34 | docs/system/arm: Add quanta-gbs-bmc reference | 48 | target/arm: Enable FEAT_Spec_FPACC for -cpu max |
35 | 49 | tests/avocado: update sunxi kernel from armbian to 6.6.16 | |
36 | Peter Maydell (18): | 50 | target/arm: Refactor default generic timer frequency handling |
37 | target/arm: Fix MVE widening/narrowing VLDR/VSTR offset calculation | 51 | hw/arm/sbsa-ref: Force CPU generic timer to 62.5MHz |
38 | target/arm: Fix bugs in MVE VRMLALDAVH, VRMLSLDAVH | 52 | hw/watchdog/sbsa_gwdt: Make watchdog timer frequency a QOM property |
39 | target/arm: Make asimd_imm_const() public | 53 | target/arm: Default to 1GHz cntfrq for 'max' and new CPUs |
40 | target/arm: Use asimd_imm_const for A64 decode | ||
41 | target/arm: Use dup_const() instead of bitfield_replicate() | ||
42 | target/arm: Implement MVE logical immediate insns | ||
43 | target/arm: Implement MVE vector shift left by immediate insns | ||
44 | target/arm: Implement MVE vector shift right by immediate insns | ||
45 | target/arm: Implement MVE VSHLL | ||
46 | target/arm: Implement MVE VSRI, VSLI | ||
47 | target/arm: Implement MVE VSHRN, VRSHRN | ||
48 | target/arm: Implement MVE saturating narrowing shifts | ||
49 | target/arm: Implement MVE VSHLC | ||
50 | target/arm: Implement MVE VADDLV | ||
51 | target/arm: Implement MVE long shifts by immediate | ||
52 | target/arm: Implement MVE long shifts by register | ||
53 | target/arm: Implement MVE shifts by immediate | ||
54 | target/arm: Implement MVE shifts by register | ||
55 | 54 | ||
56 | Philippe Mathieu-Daudé (1): | 55 | Philippe Mathieu-Daudé (1): |
57 | tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine | 56 | hw/arm/npcm7xx: Store derivative OTP fuse key in little endian |
58 | 57 | ||
59 | docs/system/arm/aspeed.rst | 1 + | 58 | Raphael Poggi (1): |
60 | docs/system/arm/nuvoton.rst | 5 +- | 59 | hw/core/clock: allow clock_propagate on child clocks |
61 | include/hw/arm/bcm2835_peripherals.h | 3 +- | ||
62 | include/hw/misc/bcm2835_powermgt.h | 29 ++ | ||
63 | target/arm/helper-mve.h | 108 +++++++ | ||
64 | target/arm/translate.h | 41 +++ | ||
65 | target/arm/mve.decode | 177 ++++++++++- | ||
66 | target/arm/t32.decode | 71 ++++- | ||
67 | hw/arm/bcm2835_peripherals.c | 13 +- | ||
68 | hw/gpio/gpio_pwr.c | 2 +- | ||
69 | hw/misc/bcm2835_powermgt.c | 160 ++++++++++ | ||
70 | target/arm/helper-a64.c | 12 +- | ||
71 | target/arm/mve_helper.c | 524 +++++++++++++++++++++++++++++++-- | ||
72 | target/arm/translate-a64.c | 86 +----- | ||
73 | target/arm/translate-mve.c | 261 +++++++++++++++- | ||
74 | target/arm/translate-neon.c | 81 ----- | ||
75 | target/arm/translate.c | 327 +++++++++++++++++++- | ||
76 | target/arm/vfp_helper.c | 24 +- | ||
77 | hw/misc/meson.build | 1 + | ||
78 | tests/acceptance/boot_linux_console.py | 43 +++ | ||
79 | 20 files changed, 1760 insertions(+), 209 deletions(-) | ||
80 | create mode 100644 include/hw/misc/bcm2835_powermgt.h | ||
81 | create mode 100644 hw/misc/bcm2835_powermgt.c | ||
82 | 60 | ||
61 | Richard Henderson (1): | ||
62 | target/arm: Restrict translation disabled alignment check to VMSA | ||
63 | |||
64 | Thomas Huth (1): | ||
65 | hw/char/stm32l4x5_usart: Fix memory corruption by adding correct class_size | ||
66 | |||
67 | Zenghui Yu (1): | ||
68 | hvf: arm: Remove PL1_WRITE_MASK | ||
69 | |||
70 | docs/system/arm/b-l475e-iot01a.rst | 3 +- | ||
71 | docs/system/arm/emulation.rst | 42 ++++- | ||
72 | include/hw/display/dm163.h | 59 ++++++ | ||
73 | include/hw/watchdog/sbsa_gwdt.h | 3 +- | ||
74 | target/arm/cpu.h | 28 +++ | ||
75 | target/arm/internals.h | 15 +- | ||
76 | hw/arm/b-l475e-iot01a.c | 105 +++++++++-- | ||
77 | hw/arm/npcm7xx.c | 3 +- | ||
78 | hw/arm/sbsa-ref.c | 16 ++ | ||
79 | hw/arm/stm32l4x5_soc.c | 6 +- | ||
80 | hw/char/stm32l4x5_usart.c | 1 + | ||
81 | hw/core/clock.c | 1 - | ||
82 | hw/core/machine.c | 4 +- | ||
83 | hw/display/dm163.c | 349 ++++++++++++++++++++++++++++++++++++ | ||
84 | hw/dma/xlnx_dpdma.c | 20 +-- | ||
85 | hw/watchdog/sbsa_gwdt.c | 15 +- | ||
86 | target/arm/cpu.c | 42 +++-- | ||
87 | target/arm/cpu64.c | 2 + | ||
88 | target/arm/helper.c | 22 +-- | ||
89 | target/arm/hvf/hvf.c | 3 +- | ||
90 | target/arm/kvm.c | 2 + | ||
91 | target/arm/tcg/cpu32.c | 6 +- | ||
92 | target/arm/tcg/cpu64.c | 28 ++- | ||
93 | target/arm/tcg/hflags.c | 12 +- | ||
94 | tests/qtest/dm163-test.c | 194 ++++++++++++++++++++ | ||
95 | tests/qtest/stm32l4x5_gpio-test.c | 13 +- | ||
96 | tests/qtest/stm32l4x5_syscfg-test.c | 17 +- | ||
97 | hw/arm/Kconfig | 1 + | ||
98 | hw/display/Kconfig | 3 + | ||
99 | hw/display/meson.build | 1 + | ||
100 | hw/display/trace-events | 14 ++ | ||
101 | tests/avocado/boot_linux_console.py | 70 ++++---- | ||
102 | tests/avocado/replay_kernel.py | 8 +- | ||
103 | tests/qtest/meson.build | 2 + | ||
104 | 34 files changed, 987 insertions(+), 123 deletions(-) | ||
105 | create mode 100644 include/hw/display/dm163.h | ||
106 | create mode 100644 hw/display/dm163.c | ||
107 | create mode 100644 tests/qtest/dm163-test.c | ||
108 | diff view generated by jsdifflib |
1 | Implement the MVE shifts by register, which perform | 1 | From: Raphael Poggi <raphael.poggi@lynxleap.co.uk> |
---|---|---|---|
2 | shifts on a single general-purpose register. | ||
3 | 2 | ||
3 | clock_propagate() has an assert that clk->source is NULL, i.e. that | ||
4 | you are calling it on a clock which has no source clock. This made | ||
5 | sense in the original design where the only way for a clock's | ||
6 | frequency to change if it had a source clock was when that source | ||
7 | clock changed. However, we subsequently added multiplier/divider | ||
8 | support, but didn't look at what that meant for propagation. | ||
9 | |||
10 | If a clock-management device changes the multiplier or divider value | ||
11 | on a clock, it needs to propagate that change down to child clocks, | ||
12 | even if the clock has a source clock set. So the assertion is now | ||
13 | incorrect. | ||
14 | |||
15 | Remove the assertion. | ||
16 | |||
17 | Signed-off-by: Raphael Poggi <raphael.poggi@lynxleap.co.uk> | ||
18 | Message-id: 20240419162951.23558-1-raphael.poggi@lynxleap.co.uk | ||
19 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | [PMM: Rewrote the commit message] | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210628135835.6690-19-peter.maydell@linaro.org | ||
7 | --- | 22 | --- |
8 | target/arm/helper-mve.h | 2 ++ | 23 | hw/core/clock.c | 1 - |
9 | target/arm/translate.h | 1 + | 24 | 1 file changed, 1 deletion(-) |
10 | target/arm/t32.decode | 18 ++++++++++++++---- | ||
11 | target/arm/mve_helper.c | 10 ++++++++++ | ||
12 | target/arm/translate.c | 30 ++++++++++++++++++++++++++++++ | ||
13 | 5 files changed, 57 insertions(+), 4 deletions(-) | ||
14 | 25 | ||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 26 | diff --git a/hw/core/clock.c b/hw/core/clock.c |
16 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-mve.h | 28 | --- a/hw/core/clock.c |
18 | +++ b/target/arm/helper-mve.h | 29 | +++ b/hw/core/clock.c |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) | 30 | @@ -XXX,XX +XXX,XX @@ static void clock_propagate_period(Clock *clk, bool call_callbacks) |
20 | 31 | ||
21 | DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | 32 | void clock_propagate(Clock *clk) |
22 | DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
23 | +DEF_HELPER_FLAGS_3(mve_uqrshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
24 | +DEF_HELPER_FLAGS_3(mve_sqrshr, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
25 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/translate.h | ||
28 | +++ b/target/arm/translate.h | ||
29 | @@ -XXX,XX +XXX,XX @@ typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
30 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | ||
31 | typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); | ||
32 | typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift); | ||
33 | +typedef void ShiftFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
34 | |||
35 | /** | ||
36 | * arm_tbflags_from_tb: | ||
37 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/t32.decode | ||
40 | +++ b/target/arm/t32.decode | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | &mve_shl_ri rdalo rdahi shim | ||
43 | &mve_shl_rr rdalo rdahi rm | ||
44 | &mve_sh_ri rda shim | ||
45 | +&mve_sh_rr rda rm | ||
46 | |||
47 | # rdahi: bits [3:1] from insn, bit 0 is 1 | ||
48 | # rdalo: bits [3:1] from insn, bit 0 is 0 | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
51 | @mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \ | ||
52 | &mve_sh_ri shim=%imm5_12_6 | ||
53 | +@mve_sh_rr ....... .... . rda:4 rm:4 .... .... .... &mve_sh_rr | ||
54 | |||
55 | { | 33 | { |
56 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | 34 | - assert(clk->source == NULL); |
57 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | 35 | trace_clock_propagate(CLOCK_PATH(clk)); |
58 | SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | 36 | clock_propagate_period(clk, true); |
59 | } | ||
60 | |||
61 | - LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
62 | - ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
63 | - UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr | ||
64 | - SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr | ||
65 | + { | ||
66 | + UQRSHL_rr 1110101 0010 1 .... .... 1111 0000 1101 @mve_sh_rr | ||
67 | + LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
68 | + UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr | ||
69 | + } | ||
70 | + | ||
71 | + { | ||
72 | + SQRSHR_rr 1110101 0010 1 .... .... 1111 0010 1101 @mve_sh_rr | ||
73 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
74 | + SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr | ||
75 | + } | ||
76 | + | ||
77 | UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr | ||
78 | SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr | ||
79 | ] | ||
80 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/arm/mve_helper.c | ||
83 | +++ b/target/arm/mve_helper.c | ||
84 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
85 | { | ||
86 | return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | ||
87 | } | 37 | } |
88 | + | ||
89 | +uint32_t HELPER(mve_uqrshl)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
90 | +{ | ||
91 | + return do_uqrshl_bhs(n, (int8_t)shift, 32, true, &env->QF); | ||
92 | +} | ||
93 | + | ||
94 | +uint32_t HELPER(mve_sqrshr)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
95 | +{ | ||
96 | + return do_sqrshl_bhs(n, -(int8_t)shift, 32, true, &env->QF); | ||
97 | +} | ||
98 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/target/arm/translate.c | ||
101 | +++ b/target/arm/translate.c | ||
102 | @@ -XXX,XX +XXX,XX @@ static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
103 | return do_mve_sh_ri(s, a, gen_mve_uqshl); | ||
104 | } | ||
105 | |||
106 | +static bool do_mve_sh_rr(DisasContext *s, arg_mve_sh_rr *a, ShiftFn *fn) | ||
107 | +{ | ||
108 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
109 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
110 | + return false; | ||
111 | + } | ||
112 | + if (!dc_isar_feature(aa32_mve, s) || | ||
113 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || | ||
114 | + a->rda == 13 || a->rda == 15 || a->rm == 13 || a->rm == 15 || | ||
115 | + a->rm == a->rda) { | ||
116 | + /* These rda/rm cases are UNPREDICTABLE; we choose to UNDEF */ | ||
117 | + unallocated_encoding(s); | ||
118 | + return true; | ||
119 | + } | ||
120 | + | ||
121 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ | ||
122 | + fn(cpu_R[a->rda], cpu_env, cpu_R[a->rda], cpu_R[a->rm]); | ||
123 | + return true; | ||
124 | +} | ||
125 | + | ||
126 | +static bool trans_SQRSHR_rr(DisasContext *s, arg_mve_sh_rr *a) | ||
127 | +{ | ||
128 | + return do_mve_sh_rr(s, a, gen_helper_mve_sqrshr); | ||
129 | +} | ||
130 | + | ||
131 | +static bool trans_UQRSHL_rr(DisasContext *s, arg_mve_sh_rr *a) | ||
132 | +{ | ||
133 | + return do_mve_sh_rr(s, a, gen_helper_mve_uqrshl); | ||
134 | +} | ||
135 | + | ||
136 | /* | ||
137 | * Multiply and multiply accumulate | ||
138 | */ | ||
139 | -- | 38 | -- |
140 | 2.20.1 | 39 | 2.34.1 |
141 | |||
142 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Zenghui Yu <zenghui.yu@linux.dev> |
---|---|---|---|
2 | 2 | ||
3 | Add a test booting and quickly shutdown a raspi2 machine, | 3 | As it had never been used since the first commit a1477da3ddeb ("hvf: Add |
4 | to test the power management model: | 4 | Apple Silicon support"). |
5 | 5 | ||
6 | (1/1) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd: | 6 | Signed-off-by: Zenghui Yu <zenghui.yu@linux.dev> |
7 | console: [ 0.000000] Booting Linux on physical CPU 0xf00 | 7 | Message-id: 20240422092715.71973-1-zenghui.yu@linux.dev |
8 | console: [ 0.000000] Linux version 4.14.98-v7+ (dom@dom-XPS-13-9370) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1200 SMP Tue Feb 12 20:27:48 GMT 2019 | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | console: [ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d | ||
10 | console: [ 0.000000] CPU: div instructions available: patching division code | ||
11 | console: [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache | ||
12 | console: [ 0.000000] OF: fdt: Machine model: Raspberry Pi 2 Model B | ||
13 | ... | ||
14 | console: Boot successful. | ||
15 | console: cat /proc/cpuinfo | ||
16 | console: / # cat /proc/cpuinfo | ||
17 | ... | ||
18 | console: processor : 3 | ||
19 | console: model name : ARMv7 Processor rev 5 (v7l) | ||
20 | console: BogoMIPS : 125.00 | ||
21 | console: Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm | ||
22 | console: CPU implementer : 0x41 | ||
23 | console: CPU architecture: 7 | ||
24 | console: CPU variant : 0x0 | ||
25 | console: CPU part : 0xc07 | ||
26 | console: CPU revision : 5 | ||
27 | console: Hardware : BCM2835 | ||
28 | console: Revision : 0000 | ||
29 | console: Serial : 0000000000000000 | ||
30 | console: cat /proc/iomem | ||
31 | console: / # cat /proc/iomem | ||
32 | console: 00000000-3bffffff : System RAM | ||
33 | console: 00008000-00afffff : Kernel code | ||
34 | console: 00c00000-00d468ef : Kernel data | ||
35 | console: 3f006000-3f006fff : dwc_otg | ||
36 | console: 3f007000-3f007eff : /soc/dma@7e007000 | ||
37 | console: 3f00b880-3f00b8bf : /soc/mailbox@7e00b880 | ||
38 | console: 3f100000-3f100027 : /soc/watchdog@7e100000 | ||
39 | console: 3f101000-3f102fff : /soc/cprman@7e101000 | ||
40 | console: 3f200000-3f2000b3 : /soc/gpio@7e200000 | ||
41 | PASS (24.59 s) | ||
42 | RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 | ||
43 | JOB TIME : 25.02 s | ||
44 | |||
45 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
46 | Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> | ||
47 | Message-id: 20210531113837.1689775-1-f4bug@amsat.org | ||
48 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
49 | --- | 10 | --- |
50 | tests/acceptance/boot_linux_console.py | 43 ++++++++++++++++++++++++++ | 11 | target/arm/hvf/hvf.c | 1 - |
51 | 1 file changed, 43 insertions(+) | 12 | 1 file changed, 1 deletion(-) |
52 | 13 | ||
53 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 14 | diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c |
54 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/tests/acceptance/boot_linux_console.py | 16 | --- a/target/arm/hvf/hvf.c |
56 | +++ b/tests/acceptance/boot_linux_console.py | 17 | +++ b/target/arm/hvf/hvf.c |
57 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ void hvf_arm_init_debug(void) |
58 | from avocado import skip | 19 | |
59 | from avocado import skipUnless | 20 | #define HVF_SYSREG(crn, crm, op0, op1, op2) \ |
60 | from avocado_qemu import Test | 21 | ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP, crn, crm, op0, op1, op2) |
61 | +from avocado_qemu import exec_command | 22 | -#define PL1_WRITE_MASK 0x4 |
62 | from avocado_qemu import exec_command_and_wait_for_pattern | 23 | |
63 | from avocado_qemu import interrupt_interactive_console_until_pattern | 24 | #define SYSREG_OP0_SHIFT 20 |
64 | from avocado_qemu import wait_for_console_pattern | 25 | #define SYSREG_OP0_MASK 0x3 |
65 | @@ -XXX,XX +XXX,XX @@ def test_arm_raspi2_uart0(self): | ||
66 | """ | ||
67 | self.do_test_arm_raspi2(0) | ||
68 | |||
69 | + def test_arm_raspi2_initrd(self): | ||
70 | + """ | ||
71 | + :avocado: tags=arch:arm | ||
72 | + :avocado: tags=machine:raspi2 | ||
73 | + """ | ||
74 | + deb_url = ('http://archive.raspberrypi.org/debian/' | ||
75 | + 'pool/main/r/raspberrypi-firmware/' | ||
76 | + 'raspberrypi-kernel_1.20190215-1_armhf.deb') | ||
77 | + deb_hash = 'cd284220b32128c5084037553db3c482426f3972' | ||
78 | + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
79 | + kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img') | ||
80 | + dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb') | ||
81 | + | ||
82 | + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
83 | + '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
84 | + 'arm/rootfs-armv7a.cpio.gz') | ||
85 | + initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' | ||
86 | + initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) | ||
87 | + initrd_path = os.path.join(self.workdir, 'rootfs.cpio') | ||
88 | + archive.gzip_uncompress(initrd_path_gz, initrd_path) | ||
89 | + | ||
90 | + self.vm.set_console() | ||
91 | + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + | ||
92 | + 'earlycon=pl011,0x3f201000 console=ttyAMA0 ' | ||
93 | + 'panic=-1 noreboot ' + | ||
94 | + 'dwc_otg.fiq_fsm_enable=0') | ||
95 | + self.vm.add_args('-kernel', kernel_path, | ||
96 | + '-dtb', dtb_path, | ||
97 | + '-initrd', initrd_path, | ||
98 | + '-append', kernel_command_line, | ||
99 | + '-no-reboot') | ||
100 | + self.vm.launch() | ||
101 | + self.wait_for_console_pattern('Boot successful.') | ||
102 | + | ||
103 | + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', | ||
104 | + 'BCM2835') | ||
105 | + exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', | ||
106 | + '/soc/cprman@7e101000') | ||
107 | + exec_command(self, 'halt') | ||
108 | + # Wait for VM to shut down gracefully | ||
109 | + self.vm.wait() | ||
110 | + | ||
111 | def test_arm_exynos4210_initrd(self): | ||
112 | """ | ||
113 | :avocado: tags=arch:arm | ||
114 | -- | 26 | -- |
115 | 2.20.1 | 27 | 2.34.1 |
116 | |||
117 | diff view generated by jsdifflib |
1 | Implement the MVE VADDLV insn; this is similar to VADDV, except | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | that it accumulates 32-bit elements into a 64-bit accumulator | ||
3 | stored in a pair of general-purpose registers. | ||
4 | 2 | ||
3 | For cpus using PMSA, when the MPU is disabled, the default memory | ||
4 | type is Normal, Non-cachable. This means that it should not | ||
5 | have alignment restrictions enforced. | ||
6 | |||
7 | Cc: qemu-stable@nongnu.org | ||
8 | Fixes: 59754f85ed3 ("target/arm: Do memory type alignment check when translation disabled") | ||
9 | Reported-by: Clément Chigot <chigot@adacore.com> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
12 | Tested-by: Clément Chigot <chigot@adacore.com> | ||
13 | Message-id: 20240422170722.117409-1-richard.henderson@linaro.org | ||
14 | [PMM: trivial comment, commit message tweaks] | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210628135835.6690-15-peter.maydell@linaro.org | ||
8 | --- | 16 | --- |
9 | target/arm/helper-mve.h | 3 ++ | 17 | target/arm/tcg/hflags.c | 12 ++++++++++-- |
10 | target/arm/mve.decode | 6 +++- | 18 | 1 file changed, 10 insertions(+), 2 deletions(-) |
11 | target/arm/mve_helper.c | 19 ++++++++++++ | ||
12 | target/arm/translate-mve.c | 63 ++++++++++++++++++++++++++++++++++++++ | ||
13 | 4 files changed, 90 insertions(+), 1 deletion(-) | ||
14 | 19 | ||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 20 | diff --git a/target/arm/tcg/hflags.c b/target/arm/tcg/hflags.c |
16 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-mve.h | 22 | --- a/target/arm/tcg/hflags.c |
18 | +++ b/target/arm/helper-mve.h | 23 | +++ b/target/arm/tcg/hflags.c |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | 24 | @@ -XXX,XX +XXX,XX @@ static bool aprofile_require_alignment(CPUARMState *env, int el, uint64_t sctlr) |
20 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | 25 | } |
21 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | 26 | |
22 | 27 | /* | |
23 | +DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) | 28 | - * If translation is disabled, then the default memory type is |
24 | +DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) | 29 | - * Device(-nGnRnE) instead of Normal, which requires that alignment |
25 | + | 30 | + * With PMSA, when the MPU is disabled, all memory types in the |
26 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | 31 | + * default map are Normal, so don't need aligment enforcing. |
27 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
28 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mve.decode | ||
32 | +++ b/target/arm/mve.decode | ||
33 | @@ -XXX,XX +XXX,XX @@ VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
34 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
35 | |||
36 | # Vector add across vector | ||
37 | -VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
38 | +{ | ||
39 | + VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
40 | + VADDLV 111 u:1 1110 1 ... 1001 ... 0 1111 00 a:1 0 qm:3 0 \ | ||
41 | + rdahi=%rdahi rdalo=%rdalo | ||
42 | +} | ||
43 | |||
44 | # Predicate operations | ||
45 | %mask_22_13 22:1 13:3 | ||
46 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mve_helper.c | ||
49 | +++ b/target/arm/mve_helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvub, 1, uint8_t) | ||
51 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
52 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
53 | |||
54 | +#define DO_VADDLV(OP, TYPE, LTYPE) \ | ||
55 | + uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
56 | + uint64_t ra) \ | ||
57 | + { \ | ||
58 | + uint16_t mask = mve_element_mask(env); \ | ||
59 | + unsigned e; \ | ||
60 | + TYPE *m = vm; \ | ||
61 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
62 | + if (mask & 1) { \ | ||
63 | + ra += (LTYPE)m[H4(e)]; \ | ||
64 | + } \ | ||
65 | + } \ | ||
66 | + mve_advance_vpt(env); \ | ||
67 | + return ra; \ | ||
68 | + } \ | ||
69 | + | ||
70 | +DO_VADDLV(vaddlv_s, int32_t, int64_t) | ||
71 | +DO_VADDLV(vaddlv_u, uint32_t, uint64_t) | ||
72 | + | ||
73 | /* Shifts by immediate */ | ||
74 | #define DO_2SHIFT(OP, ESIZE, TYPE, FN) \ | ||
75 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
76 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/translate-mve.c | ||
79 | +++ b/target/arm/translate-mve.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | ||
81 | return true; | ||
82 | } | ||
83 | |||
84 | +static bool trans_VADDLV(DisasContext *s, arg_VADDLV *a) | ||
85 | +{ | ||
86 | + /* | ||
87 | + * Vector Add Long Across Vector: accumulate the 32-bit | ||
88 | + * elements of the vector into a 64-bit result stored in | ||
89 | + * a pair of general-purpose registers. | ||
90 | + * No need to check Qm's bank: it is only 3 bits in decode. | ||
91 | + */ | 32 | + */ |
92 | + TCGv_ptr qm; | 33 | + if (arm_feature(env, ARM_FEATURE_PMSA)) { |
93 | + TCGv_i64 rda; | ||
94 | + TCGv_i32 rdalo, rdahi; | ||
95 | + | ||
96 | + if (!dc_isar_feature(aa32_mve, s)) { | ||
97 | + return false; | 34 | + return false; |
98 | + } | ||
99 | + /* | ||
100 | + * rdahi == 13 is UNPREDICTABLE; rdahi == 15 is a related | ||
101 | + * encoding; rdalo always has bit 0 clear so cannot be 13 or 15. | ||
102 | + */ | ||
103 | + if (a->rdahi == 13 || a->rdahi == 15) { | ||
104 | + return false; | ||
105 | + } | ||
106 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
107 | + return true; | ||
108 | + } | 35 | + } |
109 | + | 36 | + |
110 | + /* | 37 | + /* |
111 | + * This insn is subject to beat-wise execution. Partial execution | 38 | + * With VMSA, if translation is disabled, then the default memory type |
112 | + * of an A=0 (no-accumulate) insn which does not execute the first | 39 | + * is Device(-nGnRnE) instead of Normal, which requires that alignment |
113 | + * beat must start with the current value of RdaHi:RdaLo, not zero. | 40 | * be enforced. Since this affects all ram, it is most efficient |
114 | + */ | 41 | * to handle this during translation. |
115 | + if (a->a || mve_skip_first_beat(s)) { | 42 | */ |
116 | + /* Accumulate input from RdaHi:RdaLo */ | ||
117 | + rda = tcg_temp_new_i64(); | ||
118 | + rdalo = load_reg(s, a->rdalo); | ||
119 | + rdahi = load_reg(s, a->rdahi); | ||
120 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | ||
121 | + tcg_temp_free_i32(rdalo); | ||
122 | + tcg_temp_free_i32(rdahi); | ||
123 | + } else { | ||
124 | + /* Accumulate starting at zero */ | ||
125 | + rda = tcg_const_i64(0); | ||
126 | + } | ||
127 | + | ||
128 | + qm = mve_qreg_ptr(a->qm); | ||
129 | + if (a->u) { | ||
130 | + gen_helper_mve_vaddlv_u(rda, cpu_env, qm, rda); | ||
131 | + } else { | ||
132 | + gen_helper_mve_vaddlv_s(rda, cpu_env, qm, rda); | ||
133 | + } | ||
134 | + tcg_temp_free_ptr(qm); | ||
135 | + | ||
136 | + rdalo = tcg_temp_new_i32(); | ||
137 | + rdahi = tcg_temp_new_i32(); | ||
138 | + tcg_gen_extrl_i64_i32(rdalo, rda); | ||
139 | + tcg_gen_extrh_i64_i32(rdahi, rda); | ||
140 | + store_reg(s, a->rdalo, rdalo); | ||
141 | + store_reg(s, a->rdahi, rdahi); | ||
142 | + tcg_temp_free_i64(rda); | ||
143 | + mve_update_eci(s); | ||
144 | + return true; | ||
145 | +} | ||
146 | + | ||
147 | static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) | ||
148 | { | ||
149 | TCGv_ptr qd; | ||
150 | -- | 43 | -- |
151 | 2.20.1 | 44 | 2.34.1 |
152 | 45 | ||
153 | 46 | diff view generated by jsdifflib |
1 | Implement the MVE shifts by immediate, which perform shifts | 1 | As of version DDI0487K.a of the Arm ARM, some architectural features |
---|---|---|---|
2 | on a single general-purpose register. | 2 | which previously didn't have official names have been named. Add |
3 | 3 | these to the list of features which QEMU's TCG emulation supports. | |
4 | These patterns overlap with the long-shift-by-immediates, | 4 | Mostly these are features which we thought of as part of baseline 8.0 |
5 | so we have to rearrange the grouping a little here. | 5 | support. For SVE and SVE2, the names have been brought into line |
6 | with the FEAT_* naming convention of other extensions, and some | ||
7 | sub-components split into separate FEAT_ items. In a few cases (eg | ||
8 | FEAT_CCIDX, FEAT_DPB2) the omission from our list was just an oversight. | ||
6 | 9 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20210628135835.6690-18-peter.maydell@linaro.org | 12 | Message-id: 20240418152004.2106516-2-peter.maydell@linaro.org |
10 | --- | 13 | --- |
11 | target/arm/helper-mve.h | 3 ++ | 14 | docs/system/arm/emulation.rst | 38 +++++++++++++++++++++++++++++++++-- |
12 | target/arm/translate.h | 1 + | 15 | 1 file changed, 36 insertions(+), 2 deletions(-) |
13 | target/arm/t32.decode | 31 ++++++++++++++----- | ||
14 | target/arm/mve_helper.c | 10 ++++++ | ||
15 | target/arm/translate.c | 68 +++++++++++++++++++++++++++++++++++++++-- | ||
16 | 5 files changed, 104 insertions(+), 9 deletions(-) | ||
17 | 16 | ||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 17 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
19 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper-mve.h | 19 | --- a/docs/system/arm/emulation.rst |
21 | +++ b/target/arm/helper-mve.h | 20 | +++ b/docs/system/arm/emulation.rst |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | 21 | @@ -XXX,XX +XXX,XX @@ Armv8 versions of the A-profile architecture. It also has support for |
23 | DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | 22 | the following architecture extensions: |
24 | DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32) | 23 | |
25 | DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) | 24 | - FEAT_AA32BF16 (AArch32 BFloat16 instructions) |
26 | + | 25 | +- FEAT_AA32EL0 (Support for AArch32 at EL0) |
27 | +DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | 26 | +- FEAT_AA32EL1 (Support for AArch32 at EL1) |
28 | +DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | 27 | +- FEAT_AA32EL2 (Support for AArch32 at EL2) |
29 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 28 | +- FEAT_AA32EL3 (Support for AArch32 at EL3) |
30 | index XXXXXXX..XXXXXXX 100644 | 29 | - FEAT_AA32HPD (AArch32 hierarchical permission disables) |
31 | --- a/target/arm/translate.h | 30 | - FEAT_AA32I8MM (AArch32 Int8 matrix multiplication instructions) |
32 | +++ b/target/arm/translate.h | 31 | +- FEAT_AA64EL0 (Support for AArch64 at EL0) |
33 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | 32 | +- FEAT_AA64EL1 (Support for AArch64 at EL1) |
34 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | 33 | +- FEAT_AA64EL2 (Support for AArch64 at EL2) |
35 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | 34 | +- FEAT_AA64EL3 (Support for AArch64 at EL3) |
36 | typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); | 35 | +- FEAT_AdvSIMD (Advanced SIMD Extension) |
37 | +typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift); | 36 | - FEAT_AES (AESD and AESE instructions) |
38 | 37 | +- FEAT_Armv9_Crypto (Armv9 Cryptographic Extension) | |
39 | /** | 38 | +- FEAT_ASID16 (16 bit ASID) |
40 | * arm_tbflags_from_tb: | 39 | - FEAT_BBM at level 2 (Translation table break-before-make levels) |
41 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | 40 | - FEAT_BF16 (AArch64 BFloat16 instructions) |
42 | index XXXXXXX..XXXXXXX 100644 | 41 | - FEAT_BTI (Branch Target Identification) |
43 | --- a/target/arm/t32.decode | 42 | +- FEAT_CCIDX (Extended cache index) |
44 | +++ b/target/arm/t32.decode | 43 | - FEAT_CRC32 (CRC32 instructions) |
45 | @@ -XXX,XX +XXX,XX @@ | 44 | +- FEAT_Crypto (Cryptographic Extension) |
46 | 45 | - FEAT_CSV2 (Cache speculation variant 2) | |
47 | &mve_shl_ri rdalo rdahi shim | 46 | - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) |
48 | &mve_shl_rr rdalo rdahi rm | 47 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) |
49 | +&mve_sh_ri rda shim | 48 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
50 | 49 | - FEAT_DGH (Data gathering hint) | |
51 | # rdahi: bits [3:1] from insn, bit 0 is 1 | 50 | - FEAT_DIT (Data Independent Timing instructions) |
52 | # rdalo: bits [3:1] from insn, bit 0 is 0 | 51 | - FEAT_DPB (DC CVAP instruction) |
53 | @@ -XXX,XX +XXX,XX @@ | 52 | +- FEAT_DPB2 (DC CVADP instruction) |
54 | &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 | 53 | +- FEAT_Debugv8p1 (Debug with VHE) |
55 | @mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \ | 54 | - FEAT_Debugv8p2 (Debug changes for v8.2) |
56 | &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | 55 | - FEAT_Debugv8p4 (Debug changes for v8.4) |
57 | +@mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \ | 56 | - FEAT_DotProd (Advanced SIMD dot product instructions) |
58 | + &mve_sh_ri shim=%imm5_12_6 | 57 | - FEAT_DoubleFault (Double Fault Extension) |
59 | 58 | - FEAT_E0PD (Preventing EL0 access to halves of address maps) | |
60 | { | 59 | - FEAT_ECV (Enhanced Counter Virtualization) |
61 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | 60 | +- FEAT_EL0 (Support for execution at EL0) |
62 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | 61 | +- FEAT_EL1 (Support for execution at EL1) |
63 | # the rest fall through (where ORR_rrri and MOV_rxri will end up | 62 | +- FEAT_EL2 (Support for execution at EL2) |
64 | # handling them as r13 and r15 accesses with the same semantics as A32). | 63 | +- FEAT_EL3 (Support for execution at EL3) |
65 | [ | 64 | - FEAT_EPAC (Enhanced pointer authentication) |
66 | - LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri | 65 | - FEAT_ETS (Enhanced Translation Synchronization) |
67 | - LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri | 66 | - FEAT_EVT (Enhanced Virtualization Traps) |
68 | - ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | 67 | +- FEAT_F32MM (Single-precision Matrix Multiplication) |
69 | + { | 68 | +- FEAT_F64MM (Double-precision Matrix Multiplication) |
70 | + UQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 00 1111 @mve_sh_ri | 69 | - FEAT_FCMA (Floating-point complex number instructions) |
71 | + LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri | 70 | - FEAT_FGT (Fine-Grained Traps) |
72 | + UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri | 71 | - FEAT_FHM (Floating-point half-precision multiplication instructions) |
73 | + } | 72 | +- FEAT_FP (Floating Point extensions) |
74 | 73 | - FEAT_FP16 (Half-precision floating-point data processing) | |
75 | - UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri | 74 | - FEAT_FPAC (Faulting on AUT* instructions) |
76 | - URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | 75 | - FEAT_FPACCOMBINE (Faulting on combined pointer authentication instructions) |
77 | - SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | 76 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
78 | - SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | 77 | - FEAT_LSE (Large System Extensions) |
79 | + { | 78 | - FEAT_LSE2 (Large System Extensions v2) |
80 | + URSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 01 1111 @mve_sh_ri | 79 | - FEAT_LVA (Large Virtual Address space) |
81 | + LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri | 80 | +- FEAT_MixedEnd (Mixed-endian support) |
82 | + URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | 81 | +- FEAT_MixdEndEL0 (Mixed-endian support at EL0) |
83 | + } | 82 | - FEAT_MOPS (Standardization of memory operations) |
84 | + | 83 | - FEAT_MTE (Memory Tagging Extension) |
85 | + { | 84 | - FEAT_MTE2 (Memory Tagging Extension) |
86 | + SRSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 10 1111 @mve_sh_ri | 85 | - FEAT_MTE3 (MTE Asymmetric Fault Handling) |
87 | + ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | 86 | +- FEAT_MTE_ASYM_FAULT (Memory tagging asymmetric faults) |
88 | + SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | 87 | - FEAT_NMI (Non-maskable Interrupt) |
89 | + } | 88 | - FEAT_NV (Nested Virtualization) |
90 | + | 89 | - FEAT_NV2 (Enhanced nested virtualization support) |
91 | + { | 90 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
92 | + SQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 11 1111 @mve_sh_ri | 91 | - FEAT_PAuth (Pointer authentication) |
93 | + SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | 92 | - FEAT_PAuth2 (Enhancements to pointer authentication) |
94 | + } | 93 | - FEAT_PMULL (PMULL, PMULL2 instructions) |
95 | 94 | +- FEAT_PMUv3 (PMU extension version 3) | |
96 | LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | 95 | - FEAT_PMUv3p1 (PMU Extensions v3.1) |
97 | ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | 96 | - FEAT_PMUv3p4 (PMU Extensions v3.4) |
98 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 97 | - FEAT_PMUv3p5 (PMU Extensions v3.5) |
99 | index XXXXXXX..XXXXXXX 100644 | 98 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
100 | --- a/target/arm/mve_helper.c | 99 | - FEAT_SME_FA64 (Full A64 instruction set in Streaming SVE mode) |
101 | +++ b/target/arm/mve_helper.c | 100 | - FEAT_SME_F64F64 (Double-precision floating-point outer product instructions) |
102 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift) | 101 | - FEAT_SME_I16I64 (16-bit to 64-bit integer widening outer product instructions) |
103 | { | 102 | +- FEAT_SVE (Scalable Vector Extension) |
104 | return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF); | 103 | +- FEAT_SVE_AES (Scalable Vector AES instructions) |
105 | } | 104 | +- FEAT_SVE_BitPerm (Scalable Vector Bit Permutes instructions) |
106 | + | 105 | +- FEAT_SVE_PMULL128 (Scalable Vector PMULL instructions) |
107 | +uint32_t HELPER(mve_uqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | 106 | +- FEAT_SVE_SHA3 (Scalable Vector SHA3 instructions) |
108 | +{ | 107 | +- FEAT_SVE_SM4 (Scalable Vector SM4 instructions) |
109 | + return do_uqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | 108 | +- FEAT_SVE2 (Scalable Vector Extension version 2) |
110 | +} | 109 | - FEAT_SPECRES (Speculation restriction instructions) |
111 | + | 110 | - FEAT_SSBS (Speculative Store Bypass Safe) |
112 | +uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | 111 | +- FEAT_TGran16K (Support for 16KB memory translation granule size at stage 1) |
113 | +{ | 112 | +- FEAT_TGran4K (Support for 4KB memory translation granule size at stage 1) |
114 | + return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | 113 | +- FEAT_TGran64K (Support for 64KB memory translation granule size at stage 1) |
115 | +} | 114 | - FEAT_TIDCP1 (EL0 use of IMPLEMENTATION DEFINED functionality) |
116 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 115 | - FEAT_TLBIOS (TLB invalidate instructions in Outer Shareable domain) |
117 | index XXXXXXX..XXXXXXX 100644 | 116 | - FEAT_TLBIRANGE (TLB invalidate range instructions) |
118 | --- a/target/arm/translate.c | 117 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
119 | +++ b/target/arm/translate.c | 118 | - FEAT_VHE (Virtualization Host Extensions) |
120 | @@ -XXX,XX +XXX,XX @@ static void gen_srshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh) | 119 | - FEAT_VMID16 (16-bit VMID) |
121 | 120 | - FEAT_XNX (Translation table stage 2 Unprivileged Execute-never) | |
122 | static void gen_srshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh) | 121 | -- SVE (The Scalable Vector Extension) |
123 | { | 122 | -- SVE2 (The Scalable Vector Extension v2) |
124 | - TCGv_i32 t = tcg_temp_new_i32(); | 123 | |
125 | + TCGv_i32 t; | 124 | For information on the specifics of these extensions, please refer |
126 | 125 | to the `Armv8-A Arm Architecture Reference Manual | |
127 | + /* Handle shift by the input size for the benefit of trans_SRSHR_ri */ | ||
128 | + if (sh == 32) { | ||
129 | + tcg_gen_movi_i32(d, 0); | ||
130 | + return; | ||
131 | + } | ||
132 | + t = tcg_temp_new_i32(); | ||
133 | tcg_gen_extract_i32(t, a, sh - 1, 1); | ||
134 | tcg_gen_sari_i32(d, a, sh); | ||
135 | tcg_gen_add_i32(d, d, t); | ||
136 | @@ -XXX,XX +XXX,XX @@ static void gen_urshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh) | ||
137 | |||
138 | static void gen_urshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh) | ||
139 | { | ||
140 | - TCGv_i32 t = tcg_temp_new_i32(); | ||
141 | + TCGv_i32 t; | ||
142 | |||
143 | + /* Handle shift by the input size for the benefit of trans_URSHR_ri */ | ||
144 | + if (sh == 32) { | ||
145 | + tcg_gen_extract_i32(d, a, sh - 1, 1); | ||
146 | + return; | ||
147 | + } | ||
148 | + t = tcg_temp_new_i32(); | ||
149 | tcg_gen_extract_i32(t, a, sh - 1, 1); | ||
150 | tcg_gen_shri_i32(d, a, sh); | ||
151 | tcg_gen_add_i32(d, d, t); | ||
152 | @@ -XXX,XX +XXX,XX @@ static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
153 | return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48); | ||
154 | } | ||
155 | |||
156 | +static bool do_mve_sh_ri(DisasContext *s, arg_mve_sh_ri *a, ShiftImmFn *fn) | ||
157 | +{ | ||
158 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
159 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
160 | + return false; | ||
161 | + } | ||
162 | + if (!dc_isar_feature(aa32_mve, s) || | ||
163 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || | ||
164 | + a->rda == 13 || a->rda == 15) { | ||
165 | + /* These rda cases are UNPREDICTABLE; we choose to UNDEF */ | ||
166 | + unallocated_encoding(s); | ||
167 | + return true; | ||
168 | + } | ||
169 | + | ||
170 | + if (a->shim == 0) { | ||
171 | + a->shim = 32; | ||
172 | + } | ||
173 | + fn(cpu_R[a->rda], cpu_R[a->rda], a->shim); | ||
174 | + | ||
175 | + return true; | ||
176 | +} | ||
177 | + | ||
178 | +static bool trans_URSHR_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
179 | +{ | ||
180 | + return do_mve_sh_ri(s, a, gen_urshr32_i32); | ||
181 | +} | ||
182 | + | ||
183 | +static bool trans_SRSHR_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
184 | +{ | ||
185 | + return do_mve_sh_ri(s, a, gen_srshr32_i32); | ||
186 | +} | ||
187 | + | ||
188 | +static void gen_mve_sqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift) | ||
189 | +{ | ||
190 | + gen_helper_mve_sqshl(r, cpu_env, n, tcg_constant_i32(shift)); | ||
191 | +} | ||
192 | + | ||
193 | +static bool trans_SQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
194 | +{ | ||
195 | + return do_mve_sh_ri(s, a, gen_mve_sqshl); | ||
196 | +} | ||
197 | + | ||
198 | +static void gen_mve_uqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift) | ||
199 | +{ | ||
200 | + gen_helper_mve_uqshl(r, cpu_env, n, tcg_constant_i32(shift)); | ||
201 | +} | ||
202 | + | ||
203 | +static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
204 | +{ | ||
205 | + return do_mve_sh_ri(s, a, gen_mve_uqshl); | ||
206 | +} | ||
207 | + | ||
208 | /* | ||
209 | * Multiply and multiply accumulate | ||
210 | */ | ||
211 | -- | 126 | -- |
212 | 2.20.1 | 127 | 2.34.1 |
213 | |||
214 | diff view generated by jsdifflib |
1 | Implement the MVE long shifts by register, which perform shifts on a | 1 | FEAT_CSV2_3 adds a mechanism to identify if hardware cannot disclose |
---|---|---|---|
2 | pair of general-purpose registers treated as a 64-bit quantity, with | 2 | information about whether branch targets and branch history trained |
3 | the shift count in another general-purpose register, which might be | 3 | in one hardware described context can control speculative execution |
4 | either positive or negative. | 4 | in a different hardware context. |
5 | 5 | ||
6 | Like the long-shifts-by-immediate, these encodings sit in the space | 6 | There is no branch prediction in TCG, so we don't need to do anything |
7 | that was previously the UNPREDICTABLE MOVS/ORRS with Rm==13,15. | 7 | to be compliant with this. Upadte the '-cpu max' ID registers to |
8 | Because LSLL_rr and ASRL_rr overlap with both MOV_rxri/ORR_rrri and | 8 | advertise the feature. |
9 | also with CSEL (as one of the previously-UNPREDICTABLE Rm==13 cases), | ||
10 | we have to move the CSEL pattern into the same decodetree group. | ||
11 | 9 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20210628135835.6690-17-peter.maydell@linaro.org | 12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
13 | Message-id: 20240418152004.2106516-3-peter.maydell@linaro.org | ||
15 | --- | 14 | --- |
16 | target/arm/helper-mve.h | 6 +++ | 15 | docs/system/arm/emulation.rst | 1 + |
17 | target/arm/translate.h | 1 + | 16 | target/arm/tcg/cpu64.c | 4 ++-- |
18 | target/arm/t32.decode | 16 +++++-- | 17 | 2 files changed, 3 insertions(+), 2 deletions(-) |
19 | target/arm/mve_helper.c | 93 +++++++++++++++++++++++++++++++++++++++++ | ||
20 | target/arm/translate.c | 69 ++++++++++++++++++++++++++++++ | ||
21 | 5 files changed, 182 insertions(+), 3 deletions(-) | ||
22 | 18 | ||
23 | 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 |
24 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/arm/helper-mve.h | 21 | --- a/docs/system/arm/emulation.rst |
26 | +++ b/target/arm/helper-mve.h | 22 | +++ b/docs/system/arm/emulation.rst |
27 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
28 | 24 | - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) | |
29 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | 25 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) |
30 | 26 | - FEAT_CSV2_2 (Cache speculation variant 2, version 2) | |
31 | +DEF_HELPER_FLAGS_3(mve_sshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | 27 | +- FEAT_CSV2_3 (Cache speculation variant 2, version 3) |
32 | +DEF_HELPER_FLAGS_3(mve_ushll, TCG_CALL_NO_RWG, i64, env, i64, i32) | 28 | - FEAT_CSV3 (Cache speculation variant 3) |
33 | DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | 29 | - FEAT_DGH (Data gathering hint) |
34 | DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | 30 | - FEAT_DIT (Data Independent Timing instructions) |
35 | +DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | 31 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
36 | +DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
37 | +DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
38 | +DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
39 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/arm/translate.h | 33 | --- a/target/arm/tcg/cpu64.c |
42 | +++ b/target/arm/translate.h | 34 | +++ b/target/arm/tcg/cpu64.c |
43 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | 35 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
44 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | 36 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); |
45 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | 37 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ |
46 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | 38 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ |
47 | +typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); | 39 | - t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */ |
48 | 40 | + t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 3); /* FEAT_CSV2_3 */ | |
49 | /** | 41 | t = FIELD_DP64(t, ID_AA64PFR0, CSV3, 1); /* FEAT_CSV3 */ |
50 | * arm_tbflags_from_tb: | 42 | cpu->isar.id_aa64pfr0 = t; |
51 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | 43 | |
52 | index XXXXXXX..XXXXXXX 100644 | 44 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
53 | --- a/target/arm/t32.decode | 45 | t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ |
54 | +++ b/target/arm/t32.decode | 46 | t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT_DoubleFault */ |
55 | @@ -XXX,XX +XXX,XX @@ | 47 | t = FIELD_DP64(t, ID_AA64PFR1, SME, 1); /* FEAT_SME */ |
56 | &mcrr !extern cp opc1 crm rt rt2 | 48 | - t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ |
57 | 49 | + t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_3 */ | |
58 | &mve_shl_ri rdalo rdahi shim | 50 | t = FIELD_DP64(t, ID_AA64PFR1, NMI, 1); /* FEAT_NMI */ |
59 | +&mve_shl_rr rdalo rdahi rm | 51 | cpu->isar.id_aa64pfr1 = t; |
60 | 52 | ||
61 | # rdahi: bits [3:1] from insn, bit 0 is 1 | ||
62 | # rdalo: bits [3:1] from insn, bit 0 is 0 | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | |||
65 | @mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ | ||
66 | &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
67 | +@mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \ | ||
68 | + &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
69 | |||
70 | { | ||
71 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | ||
72 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | ||
73 | URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
74 | SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
75 | SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
76 | + | ||
77 | + LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
78 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
79 | + UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr | ||
80 | + SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr | ||
81 | + UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr | ||
82 | + SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr | ||
83 | ] | ||
84 | |||
85 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi | ||
86 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi | ||
87 | + | ||
88 | + # v8.1M CSEL and friends | ||
89 | + CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 | ||
90 | } | ||
91 | { | ||
92 | MVN_rxri 1110101 0011 . 1111 0 ... .... .... .... @s_rxr_shi | ||
93 | @@ -XXX,XX +XXX,XX @@ SBC_rrri 1110101 1011 . .... 0 ... .... .... .... @s_rrr_shi | ||
94 | } | ||
95 | RSB_rrri 1110101 1110 . .... 0 ... .... .... .... @s_rrr_shi | ||
96 | |||
97 | -# v8.1M CSEL and friends | ||
98 | -CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 | ||
99 | - | ||
100 | # Data-processing (register-shifted register) | ||
101 | |||
102 | MOV_rxrr 1111 1010 0 shty:2 s:1 rm:4 1111 rd:4 0000 rs:4 \ | ||
103 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/target/arm/mve_helper.c | ||
106 | +++ b/target/arm/mve_helper.c | ||
107 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
108 | return rdm; | ||
109 | } | ||
110 | |||
111 | +uint64_t HELPER(mve_sshrl)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
112 | +{ | ||
113 | + return do_sqrshl_d(n, -(int8_t)shift, false, NULL); | ||
114 | +} | ||
115 | + | ||
116 | +uint64_t HELPER(mve_ushll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
117 | +{ | ||
118 | + return do_uqrshl_d(n, (int8_t)shift, false, NULL); | ||
119 | +} | ||
120 | + | ||
121 | uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
122 | { | ||
123 | return do_sqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
124 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
125 | { | ||
126 | return do_uqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
127 | } | ||
128 | + | ||
129 | +uint64_t HELPER(mve_sqrshrl)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
130 | +{ | ||
131 | + return do_sqrshl_d(n, -(int8_t)shift, true, &env->QF); | ||
132 | +} | ||
133 | + | ||
134 | +uint64_t HELPER(mve_uqrshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
135 | +{ | ||
136 | + return do_uqrshl_d(n, (int8_t)shift, true, &env->QF); | ||
137 | +} | ||
138 | + | ||
139 | +/* Operate on 64-bit values, but saturate at 48 bits */ | ||
140 | +static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
141 | + bool round, uint32_t *sat) | ||
142 | +{ | ||
143 | + if (shift <= -48) { | ||
144 | + /* Rounding the sign bit always produces 0. */ | ||
145 | + if (round) { | ||
146 | + return 0; | ||
147 | + } | ||
148 | + return src >> 63; | ||
149 | + } else if (shift < 0) { | ||
150 | + if (round) { | ||
151 | + src >>= -shift - 1; | ||
152 | + return (src >> 1) + (src & 1); | ||
153 | + } | ||
154 | + return src >> -shift; | ||
155 | + } else if (shift < 48) { | ||
156 | + int64_t val = src << shift; | ||
157 | + int64_t extval = sextract64(val, 0, 48); | ||
158 | + if (!sat || val == extval) { | ||
159 | + return extval; | ||
160 | + } | ||
161 | + } else if (!sat || src == 0) { | ||
162 | + return 0; | ||
163 | + } | ||
164 | + | ||
165 | + *sat = 1; | ||
166 | + return (1ULL << 47) - (src >= 0); | ||
167 | +} | ||
168 | + | ||
169 | +/* Operate on 64-bit values, but saturate at 48 bits */ | ||
170 | +static inline uint64_t do_uqrshl48_d(uint64_t src, int64_t shift, | ||
171 | + bool round, uint32_t *sat) | ||
172 | +{ | ||
173 | + uint64_t val, extval; | ||
174 | + | ||
175 | + if (shift <= -(48 + round)) { | ||
176 | + return 0; | ||
177 | + } else if (shift < 0) { | ||
178 | + if (round) { | ||
179 | + val = src >> (-shift - 1); | ||
180 | + val = (val >> 1) + (val & 1); | ||
181 | + } else { | ||
182 | + val = src >> -shift; | ||
183 | + } | ||
184 | + extval = extract64(val, 0, 48); | ||
185 | + if (!sat || val == extval) { | ||
186 | + return extval; | ||
187 | + } | ||
188 | + } else if (shift < 48) { | ||
189 | + uint64_t val = src << shift; | ||
190 | + uint64_t extval = extract64(val, 0, 48); | ||
191 | + if (!sat || val == extval) { | ||
192 | + return extval; | ||
193 | + } | ||
194 | + } else if (!sat || src == 0) { | ||
195 | + return 0; | ||
196 | + } | ||
197 | + | ||
198 | + *sat = 1; | ||
199 | + return MAKE_64BIT_MASK(0, 48); | ||
200 | +} | ||
201 | + | ||
202 | +uint64_t HELPER(mve_sqrshrl48)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
203 | +{ | ||
204 | + return do_sqrshl48_d(n, -(int8_t)shift, true, &env->QF); | ||
205 | +} | ||
206 | + | ||
207 | +uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
208 | +{ | ||
209 | + return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF); | ||
210 | +} | ||
211 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
212 | index XXXXXXX..XXXXXXX 100644 | ||
213 | --- a/target/arm/translate.c | ||
214 | +++ b/target/arm/translate.c | ||
215 | @@ -XXX,XX +XXX,XX @@ static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
216 | return do_mve_shl_ri(s, a, gen_urshr64_i64); | ||
217 | } | ||
218 | |||
219 | +static bool do_mve_shl_rr(DisasContext *s, arg_mve_shl_rr *a, WideShiftFn *fn) | ||
220 | +{ | ||
221 | + TCGv_i64 rda; | ||
222 | + TCGv_i32 rdalo, rdahi; | ||
223 | + | ||
224 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
225 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
226 | + return false; | ||
227 | + } | ||
228 | + if (a->rdahi == 15) { | ||
229 | + /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */ | ||
230 | + return false; | ||
231 | + } | ||
232 | + if (!dc_isar_feature(aa32_mve, s) || | ||
233 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || | ||
234 | + a->rdahi == 13 || a->rm == 13 || a->rm == 15 || | ||
235 | + a->rm == a->rdahi || a->rm == a->rdalo) { | ||
236 | + /* These rdahi/rdalo/rm cases are UNPREDICTABLE; we choose to UNDEF */ | ||
237 | + unallocated_encoding(s); | ||
238 | + return true; | ||
239 | + } | ||
240 | + | ||
241 | + rda = tcg_temp_new_i64(); | ||
242 | + rdalo = load_reg(s, a->rdalo); | ||
243 | + rdahi = load_reg(s, a->rdahi); | ||
244 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | ||
245 | + | ||
246 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ | ||
247 | + fn(rda, cpu_env, rda, cpu_R[a->rm]); | ||
248 | + | ||
249 | + tcg_gen_extrl_i64_i32(rdalo, rda); | ||
250 | + tcg_gen_extrh_i64_i32(rdahi, rda); | ||
251 | + store_reg(s, a->rdalo, rdalo); | ||
252 | + store_reg(s, a->rdahi, rdahi); | ||
253 | + tcg_temp_free_i64(rda); | ||
254 | + | ||
255 | + return true; | ||
256 | +} | ||
257 | + | ||
258 | +static bool trans_LSLL_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
259 | +{ | ||
260 | + return do_mve_shl_rr(s, a, gen_helper_mve_ushll); | ||
261 | +} | ||
262 | + | ||
263 | +static bool trans_ASRL_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
264 | +{ | ||
265 | + return do_mve_shl_rr(s, a, gen_helper_mve_sshrl); | ||
266 | +} | ||
267 | + | ||
268 | +static bool trans_UQRSHLL64_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
269 | +{ | ||
270 | + return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll); | ||
271 | +} | ||
272 | + | ||
273 | +static bool trans_SQRSHRL64_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
274 | +{ | ||
275 | + return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl); | ||
276 | +} | ||
277 | + | ||
278 | +static bool trans_UQRSHLL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
279 | +{ | ||
280 | + return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll48); | ||
281 | +} | ||
282 | + | ||
283 | +static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
284 | +{ | ||
285 | + return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48); | ||
286 | +} | ||
287 | + | ||
288 | /* | ||
289 | * Multiply and multiply accumulate | ||
290 | */ | ||
291 | -- | 53 | -- |
292 | 2.20.1 | 54 | 2.34.1 |
293 | 55 | ||
294 | 56 | diff view generated by jsdifflib |
1 | The MVE extension to v8.1M includes some new shift instructions which | 1 | FEAT_ETS2 is a tighter set of guarantees about memory ordering |
---|---|---|---|
2 | sit entirely within the non-coprocessor part of the encoding space | 2 | involving translation table walks than the old FEAT_ETS; FEAT_ETS has |
3 | and which operate only on general-purpose registers. They take up | 3 | been retired from the Arm ARM and the old ID_AA64MMFR1.ETS == 1 |
4 | the space which was previously UNPREDICTABLE MOVS and ORRS encodings | 4 | now gives no greater guarantees than ETS == 0. |
5 | with Rm == 13 or 15. | ||
6 | 5 | ||
7 | Implement the long shifts by immediate, which perform shifts on a | 6 | FEAT_ETS2 requires: |
8 | pair of general-purpose registers treated as a 64-bit quantity, with | 7 | * the virtual address of a load or store that appears in program |
9 | an immediate shift count between 1 and 32. | 8 | order after a DSB cannot be translated until after the DSB |
9 | completes (section B2.10.9) | ||
10 | * TLB maintenance operations that only affect translations without | ||
11 | execute permission are guaranteed complete after a DSB | ||
12 | (R_BLDZX) | ||
13 | * if a memory access RW2 is ordered-before memory access RW2, | ||
14 | then RW1 is also ordered-before any translation table walk | ||
15 | generated by RW2 that generates a Translation, Address size | ||
16 | or Access flag fault (R_NNFPF, I_CLGHP) | ||
10 | 17 | ||
11 | Awkwardly, because the MOVS and ORRS trans functions do not UNDEF for | 18 | As with FEAT_ETS, QEMU is already compliant, because we do not |
12 | the Rm==13,15 case, we need to explicitly emit code to UNDEF for the | 19 | reorder translation table walk memory accesses relative to other |
13 | cases where v8.1M now requires that. (Trying to change MOVS and ORRS | 20 | memory accesses, and we always guarantee to have finished TLB |
14 | is too difficult, because the functions that generate the code are | 21 | maintenance as soon as the TLB op is done. |
15 | shared between a dozen different kinds of arithmetic or logical | ||
16 | instruction for all A32, T16 and T32 encodings, and for some insns | ||
17 | and some encodings Rm==13,15 are valid.) | ||
18 | 22 | ||
19 | We make the helper functions we need for UQSHLL and SQSHLL take | 23 | Update the documentation to list FEAT_ETS2 instead of the |
20 | a 32-bit value which the helper casts to int8_t because we'll need | 24 | no-longer-existent FEAT_ETS, and update the 'max' CPU ID registers. |
21 | these helpers also for the shift-by-register insns, where the shift | ||
22 | count might be < 0 or > 32. | ||
23 | 25 | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 27 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
26 | Message-id: 20210628135835.6690-16-peter.maydell@linaro.org | 28 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
29 | Message-id: 20240418152004.2106516-4-peter.maydell@linaro.org | ||
27 | --- | 30 | --- |
28 | target/arm/helper-mve.h | 3 ++ | 31 | docs/system/arm/emulation.rst | 2 +- |
29 | target/arm/translate.h | 1 + | 32 | target/arm/tcg/cpu32.c | 2 +- |
30 | target/arm/t32.decode | 28 +++++++++++++ | 33 | target/arm/tcg/cpu64.c | 2 +- |
31 | target/arm/mve_helper.c | 10 +++++ | 34 | 3 files changed, 3 insertions(+), 3 deletions(-) |
32 | target/arm/translate.c | 90 +++++++++++++++++++++++++++++++++++++++++ | ||
33 | 5 files changed, 132 insertions(+) | ||
34 | 35 | ||
35 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 36 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
36 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/target/arm/helper-mve.h | 38 | --- a/docs/system/arm/emulation.rst |
38 | +++ b/target/arm/helper-mve.h | 39 | +++ b/docs/system/arm/emulation.rst |
39 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 40 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
40 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 41 | - FEAT_EL2 (Support for execution at EL2) |
41 | 42 | - FEAT_EL3 (Support for execution at EL3) | |
42 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | 43 | - FEAT_EPAC (Enhanced pointer authentication) |
43 | + | 44 | -- FEAT_ETS (Enhanced Translation Synchronization) |
44 | +DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | 45 | +- FEAT_ETS2 (Enhanced Translation Synchronization) |
45 | +DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | 46 | - FEAT_EVT (Enhanced Virtualization Traps) |
46 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 47 | - FEAT_F32MM (Single-precision Matrix Multiplication) |
48 | - FEAT_F64MM (Double-precision Matrix Multiplication) | ||
49 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | 50 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/target/arm/translate.h | 51 | --- a/target/arm/tcg/cpu32.c |
49 | +++ b/target/arm/translate.h | 52 | +++ b/target/arm/tcg/cpu32.c |
50 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); | 53 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) |
51 | typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | 54 | cpu->isar.id_mmfr4 = t; |
52 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | 55 | |
53 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | 56 | t = cpu->isar.id_mmfr5; |
54 | +typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | 57 | - t = FIELD_DP32(t, ID_MMFR5, ETS, 1); /* FEAT_ETS */ |
55 | 58 | + t = FIELD_DP32(t, ID_MMFR5, ETS, 2); /* FEAT_ETS2 */ | |
56 | /** | 59 | cpu->isar.id_mmfr5 = t; |
57 | * arm_tbflags_from_tb: | 60 | |
58 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | 61 | t = cpu->isar.id_pfr0; |
62 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | 63 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/target/arm/t32.decode | 64 | --- a/target/arm/tcg/cpu64.c |
61 | +++ b/target/arm/t32.decode | 65 | +++ b/target/arm/tcg/cpu64.c |
62 | @@ -XXX,XX +XXX,XX @@ | 66 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
63 | &mcr !extern cp opc1 crn crm opc2 rt | 67 | t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */ |
64 | &mcrr !extern cp opc1 crm rt rt2 | 68 | t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 3); /* FEAT_PAN3 */ |
65 | 69 | t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */ | |
66 | +&mve_shl_ri rdalo rdahi shim | 70 | - t = FIELD_DP64(t, ID_AA64MMFR1, ETS, 1); /* FEAT_ETS */ |
67 | + | 71 | + t = FIELD_DP64(t, ID_AA64MMFR1, ETS, 2); /* FEAT_ETS2 */ |
68 | +# rdahi: bits [3:1] from insn, bit 0 is 1 | 72 | t = FIELD_DP64(t, ID_AA64MMFR1, HCX, 1); /* FEAT_HCX */ |
69 | +# rdalo: bits [3:1] from insn, bit 0 is 0 | 73 | t = FIELD_DP64(t, ID_AA64MMFR1, TIDCP1, 1); /* FEAT_TIDCP1 */ |
70 | +%rdahi_9 9:3 !function=times_2_plus_1 | 74 | cpu->isar.id_aa64mmfr1 = t; |
71 | +%rdalo_17 17:3 !function=times_2 | ||
72 | + | ||
73 | # Data-processing (register) | ||
74 | |||
75 | %imm5_12_6 12:3 6:2 | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | @S_xrr_shi ....... .... . rn:4 .... .... .. shty:2 rm:4 \ | ||
78 | &s_rrr_shi shim=%imm5_12_6 s=1 rd=0 | ||
79 | |||
80 | +@mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ | ||
81 | + &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
82 | + | ||
83 | { | ||
84 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | ||
85 | AND_rrri 1110101 0000 . .... 0 ... .... .... .... @s_rrr_shi | ||
86 | } | ||
87 | BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | ||
88 | { | ||
89 | + # The v8.1M MVE shift insns overlap in encoding with MOVS/ORRS | ||
90 | + # and are distinguished by having Rm==13 or 15. Those are UNPREDICTABLE | ||
91 | + # cases for MOVS/ORRS. We decode the MVE cases first, ensuring that | ||
92 | + # they explicitly call unallocated_encoding() for cases that must UNDEF | ||
93 | + # (eg "using a new shift insn on a v8.1M CPU without MVE"), and letting | ||
94 | + # the rest fall through (where ORR_rrri and MOV_rxri will end up | ||
95 | + # handling them as r13 and r15 accesses with the same semantics as A32). | ||
96 | + [ | ||
97 | + LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
98 | + LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
99 | + ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
100 | + | ||
101 | + UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
102 | + URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
103 | + SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
104 | + SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
105 | + ] | ||
106 | + | ||
107 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi | ||
108 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi | ||
109 | } | ||
110 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/target/arm/mve_helper.c | ||
113 | +++ b/target/arm/mve_helper.c | ||
114 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
115 | mve_advance_vpt(env); | ||
116 | return rdm; | ||
117 | } | ||
118 | + | ||
119 | +uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
120 | +{ | ||
121 | + return do_sqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
122 | +} | ||
123 | + | ||
124 | +uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
125 | +{ | ||
126 | + return do_uqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
127 | +} | ||
128 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/target/arm/translate.c | ||
131 | +++ b/target/arm/translate.c | ||
132 | @@ -XXX,XX +XXX,XX @@ static bool trans_MOVT(DisasContext *s, arg_MOVW *a) | ||
133 | return true; | ||
134 | } | ||
135 | |||
136 | +/* | ||
137 | + * v8.1M MVE wide-shifts | ||
138 | + */ | ||
139 | +static bool do_mve_shl_ri(DisasContext *s, arg_mve_shl_ri *a, | ||
140 | + WideShiftImmFn *fn) | ||
141 | +{ | ||
142 | + TCGv_i64 rda; | ||
143 | + TCGv_i32 rdalo, rdahi; | ||
144 | + | ||
145 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
146 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
147 | + return false; | ||
148 | + } | ||
149 | + if (a->rdahi == 15) { | ||
150 | + /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */ | ||
151 | + return false; | ||
152 | + } | ||
153 | + if (!dc_isar_feature(aa32_mve, s) || | ||
154 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || | ||
155 | + a->rdahi == 13) { | ||
156 | + /* RdaHi == 13 is UNPREDICTABLE; we choose to UNDEF */ | ||
157 | + unallocated_encoding(s); | ||
158 | + return true; | ||
159 | + } | ||
160 | + | ||
161 | + if (a->shim == 0) { | ||
162 | + a->shim = 32; | ||
163 | + } | ||
164 | + | ||
165 | + rda = tcg_temp_new_i64(); | ||
166 | + rdalo = load_reg(s, a->rdalo); | ||
167 | + rdahi = load_reg(s, a->rdahi); | ||
168 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | ||
169 | + | ||
170 | + fn(rda, rda, a->shim); | ||
171 | + | ||
172 | + tcg_gen_extrl_i64_i32(rdalo, rda); | ||
173 | + tcg_gen_extrh_i64_i32(rdahi, rda); | ||
174 | + store_reg(s, a->rdalo, rdalo); | ||
175 | + store_reg(s, a->rdahi, rdahi); | ||
176 | + tcg_temp_free_i64(rda); | ||
177 | + | ||
178 | + return true; | ||
179 | +} | ||
180 | + | ||
181 | +static bool trans_ASRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
182 | +{ | ||
183 | + return do_mve_shl_ri(s, a, tcg_gen_sari_i64); | ||
184 | +} | ||
185 | + | ||
186 | +static bool trans_LSLL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
187 | +{ | ||
188 | + return do_mve_shl_ri(s, a, tcg_gen_shli_i64); | ||
189 | +} | ||
190 | + | ||
191 | +static bool trans_LSRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
192 | +{ | ||
193 | + return do_mve_shl_ri(s, a, tcg_gen_shri_i64); | ||
194 | +} | ||
195 | + | ||
196 | +static void gen_mve_sqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) | ||
197 | +{ | ||
198 | + gen_helper_mve_sqshll(r, cpu_env, n, tcg_constant_i32(shift)); | ||
199 | +} | ||
200 | + | ||
201 | +static bool trans_SQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
202 | +{ | ||
203 | + return do_mve_shl_ri(s, a, gen_mve_sqshll); | ||
204 | +} | ||
205 | + | ||
206 | +static void gen_mve_uqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) | ||
207 | +{ | ||
208 | + gen_helper_mve_uqshll(r, cpu_env, n, tcg_constant_i32(shift)); | ||
209 | +} | ||
210 | + | ||
211 | +static bool trans_UQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
212 | +{ | ||
213 | + return do_mve_shl_ri(s, a, gen_mve_uqshll); | ||
214 | +} | ||
215 | + | ||
216 | +static bool trans_SRSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
217 | +{ | ||
218 | + return do_mve_shl_ri(s, a, gen_srshr64_i64); | ||
219 | +} | ||
220 | + | ||
221 | +static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
222 | +{ | ||
223 | + return do_mve_shl_ri(s, a, gen_urshr64_i64); | ||
224 | +} | ||
225 | + | ||
226 | /* | ||
227 | * Multiply and multiply accumulate | ||
228 | */ | ||
229 | -- | 75 | -- |
230 | 2.20.1 | 76 | 2.34.1 |
231 | 77 | ||
232 | 78 | diff view generated by jsdifflib |
1 | Implement the MVE VSHLC insn, which performs a shift left of the | 1 | Newer versions of the Arm ARM (e.g. rev K.a) now define fields for |
---|---|---|---|
2 | entire vector with carry in bits provided from a general purpose | 2 | ID_AA64MMFR3_EL1. Implement this register, so that we can set the |
3 | register and carry out bits written back to that register. | 3 | fields if we need to. There's no behaviour change here since we |
4 | don't currently set the register value to non-zero. | ||
4 | 5 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20210628135835.6690-14-peter.maydell@linaro.org | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Message-id: 20240418152004.2106516-5-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | target/arm/helper-mve.h | 2 ++ | 11 | target/arm/cpu.h | 17 +++++++++++++++++ |
10 | target/arm/mve.decode | 2 ++ | 12 | target/arm/helper.c | 6 ++++-- |
11 | target/arm/mve_helper.c | 38 ++++++++++++++++++++++++++++++++++++++ | 13 | target/arm/hvf/hvf.c | 2 ++ |
12 | target/arm/translate-mve.c | 30 ++++++++++++++++++++++++++++++ | 14 | target/arm/kvm.c | 2 ++ |
13 | 4 files changed, 72 insertions(+) | 15 | 4 files changed, 25 insertions(+), 2 deletions(-) |
14 | 16 | ||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-mve.h | 19 | --- a/target/arm/cpu.h |
18 | +++ b/target/arm/helper-mve.h | 20 | +++ b/target/arm/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 21 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
20 | DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 22 | uint64_t id_aa64mmfr0; |
21 | DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 23 | uint64_t id_aa64mmfr1; |
22 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 24 | uint64_t id_aa64mmfr2; |
25 | + uint64_t id_aa64mmfr3; | ||
26 | uint64_t id_aa64dfr0; | ||
27 | uint64_t id_aa64dfr1; | ||
28 | uint64_t id_aa64zfr0; | ||
29 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64MMFR2, BBM, 52, 4) | ||
30 | FIELD(ID_AA64MMFR2, EVT, 56, 4) | ||
31 | FIELD(ID_AA64MMFR2, E0PD, 60, 4) | ||
32 | |||
33 | +FIELD(ID_AA64MMFR3, TCRX, 0, 4) | ||
34 | +FIELD(ID_AA64MMFR3, SCTLRX, 4, 4) | ||
35 | +FIELD(ID_AA64MMFR3, S1PIE, 8, 4) | ||
36 | +FIELD(ID_AA64MMFR3, S2PIE, 12, 4) | ||
37 | +FIELD(ID_AA64MMFR3, S1POE, 16, 4) | ||
38 | +FIELD(ID_AA64MMFR3, S2POE, 20, 4) | ||
39 | +FIELD(ID_AA64MMFR3, AIE, 24, 4) | ||
40 | +FIELD(ID_AA64MMFR3, MEC, 28, 4) | ||
41 | +FIELD(ID_AA64MMFR3, D128, 32, 4) | ||
42 | +FIELD(ID_AA64MMFR3, D128_2, 36, 4) | ||
43 | +FIELD(ID_AA64MMFR3, SNERR, 40, 4) | ||
44 | +FIELD(ID_AA64MMFR3, ANERR, 44, 4) | ||
45 | +FIELD(ID_AA64MMFR3, SDERR, 52, 4) | ||
46 | +FIELD(ID_AA64MMFR3, ADERR, 56, 4) | ||
47 | +FIELD(ID_AA64MMFR3, SPEC_FPACC, 60, 4) | ||
23 | + | 48 | + |
24 | +DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | 49 | FIELD(ID_AA64DFR0, DEBUGVER, 0, 4) |
25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 50 | FIELD(ID_AA64DFR0, TRACEVER, 4, 4) |
51 | FIELD(ID_AA64DFR0, PMUVER, 8, 4) | ||
52 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | 53 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/mve.decode | 54 | --- a/target/arm/helper.c |
28 | +++ b/target/arm/mve.decode | 55 | +++ b/target/arm/helper.c |
29 | @@ -XXX,XX +XXX,XX @@ VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | 56 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
30 | VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | 57 | .access = PL1_R, .type = ARM_CP_CONST, |
31 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | 58 | .accessfn = access_aa64_tid3, |
32 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | 59 | .resetvalue = cpu->isar.id_aa64mmfr2 }, |
33 | + | 60 | - { .name = "ID_AA64MMFR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, |
34 | +VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | 61 | + { .name = "ID_AA64MMFR3_EL1", .state = ARM_CP_STATE_AA64, |
35 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 62 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 3, |
63 | .access = PL1_R, .type = ARM_CP_CONST, | ||
64 | .accessfn = access_aa64_tid3, | ||
65 | - .resetvalue = 0 }, | ||
66 | + .resetvalue = cpu->isar.id_aa64mmfr3 }, | ||
67 | { .name = "ID_AA64MMFR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64, | ||
68 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 4, | ||
69 | .access = PL1_R, .type = ARM_CP_CONST, | ||
70 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
71 | .exported_bits = R_ID_AA64MMFR1_AFP_MASK }, | ||
72 | { .name = "ID_AA64MMFR2_EL1", | ||
73 | .exported_bits = R_ID_AA64MMFR2_AT_MASK }, | ||
74 | + { .name = "ID_AA64MMFR3_EL1", | ||
75 | + .exported_bits = 0 }, | ||
76 | { .name = "ID_AA64MMFR*_EL1_RESERVED", | ||
77 | .is_glob = true }, | ||
78 | { .name = "ID_AA64DFR0_EL1", | ||
79 | diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | 80 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/target/arm/mve_helper.c | 81 | --- a/target/arm/hvf/hvf.c |
38 | +++ b/target/arm/mve_helper.c | 82 | +++ b/target/arm/hvf/hvf.c |
39 | @@ -XXX,XX +XXX,XX @@ DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB) | 83 | @@ -XXX,XX +XXX,XX @@ static struct hvf_sreg_match hvf_sreg_match[] = { |
40 | DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) | 84 | #endif |
41 | DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | 85 | { HV_SYS_REG_ID_AA64MMFR1_EL1, HVF_SYSREG(0, 7, 3, 0, 1) }, |
42 | DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) | 86 | { HV_SYS_REG_ID_AA64MMFR2_EL1, HVF_SYSREG(0, 7, 3, 0, 2) }, |
43 | + | 87 | + /* Add ID_AA64MMFR3_EL1 here when HVF supports it */ |
44 | +uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | 88 | |
45 | + uint32_t shift) | 89 | { HV_SYS_REG_MDSCR_EL1, HVF_SYSREG(0, 2, 2, 0, 2) }, |
46 | +{ | 90 | { HV_SYS_REG_SCTLR_EL1, HVF_SYSREG(1, 0, 3, 0, 0) }, |
47 | + uint32_t *d = vd; | 91 | @@ -XXX,XX +XXX,XX @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) |
48 | + uint16_t mask = mve_element_mask(env); | 92 | { HV_SYS_REG_ID_AA64MMFR0_EL1, &host_isar.id_aa64mmfr0 }, |
49 | + unsigned e; | 93 | { HV_SYS_REG_ID_AA64MMFR1_EL1, &host_isar.id_aa64mmfr1 }, |
50 | + uint32_t r; | 94 | { HV_SYS_REG_ID_AA64MMFR2_EL1, &host_isar.id_aa64mmfr2 }, |
51 | + | 95 | + /* Add ID_AA64MMFR3_EL1 here when HVF supports it */ |
52 | + /* | 96 | }; |
53 | + * For each 32-bit element, we shift it left, bringing in the | 97 | hv_vcpu_t fd; |
54 | + * low 'shift' bits of rdm at the bottom. Bits shifted out at | 98 | hv_return_t r = HV_SUCCESS; |
55 | + * the top become the new rdm, if the predicate mask permits. | 99 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c |
56 | + * The final rdm value is returned to update the register. | ||
57 | + * shift == 0 here means "shift by 32 bits". | ||
58 | + */ | ||
59 | + if (shift == 0) { | ||
60 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
61 | + r = rdm; | ||
62 | + if (mask & 1) { | ||
63 | + rdm = d[H4(e)]; | ||
64 | + } | ||
65 | + mergemask(&d[H4(e)], r, mask); | ||
66 | + } | ||
67 | + } else { | ||
68 | + uint32_t shiftmask = MAKE_64BIT_MASK(0, shift); | ||
69 | + | ||
70 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
71 | + r = (d[H4(e)] << shift) | (rdm & shiftmask); | ||
72 | + if (mask & 1) { | ||
73 | + rdm = d[H4(e)] >> (32 - shift); | ||
74 | + } | ||
75 | + mergemask(&d[H4(e)], r, mask); | ||
76 | + } | ||
77 | + } | ||
78 | + mve_advance_vpt(env); | ||
79 | + return rdm; | ||
80 | +} | ||
81 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | 100 | index XXXXXXX..XXXXXXX 100644 |
83 | --- a/target/arm/translate-mve.c | 101 | --- a/target/arm/kvm.c |
84 | +++ b/target/arm/translate-mve.c | 102 | +++ b/target/arm/kvm.c |
85 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_N(VQRSHRNB_U, vqrshrnb_u) | 103 | @@ -XXX,XX +XXX,XX @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) |
86 | DO_2SHIFT_N(VQRSHRNT_U, vqrshrnt_u) | 104 | ARM64_SYS_REG(3, 0, 0, 7, 1)); |
87 | DO_2SHIFT_N(VQRSHRUNB, vqrshrunb) | 105 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr2, |
88 | DO_2SHIFT_N(VQRSHRUNT, vqrshrunt) | 106 | ARM64_SYS_REG(3, 0, 0, 7, 2)); |
89 | + | 107 | + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr3, |
90 | +static bool trans_VSHLC(DisasContext *s, arg_VSHLC *a) | 108 | + ARM64_SYS_REG(3, 0, 0, 7, 3)); |
91 | +{ | 109 | |
92 | + /* | 110 | /* |
93 | + * Whole Vector Left Shift with Carry. The carry is taken | 111 | * Note that if AArch32 support is not present in the host, |
94 | + * from a general purpose register and written back there. | ||
95 | + * An imm of 0 means "shift by 32". | ||
96 | + */ | ||
97 | + TCGv_ptr qd; | ||
98 | + TCGv_i32 rdm; | ||
99 | + | ||
100 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) { | ||
101 | + return false; | ||
102 | + } | ||
103 | + if (a->rdm == 13 || a->rdm == 15) { | ||
104 | + /* CONSTRAINED UNPREDICTABLE: we UNDEF */ | ||
105 | + return false; | ||
106 | + } | ||
107 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
108 | + return true; | ||
109 | + } | ||
110 | + | ||
111 | + qd = mve_qreg_ptr(a->qd); | ||
112 | + rdm = load_reg(s, a->rdm); | ||
113 | + gen_helper_mve_vshlc(rdm, cpu_env, qd, rdm, tcg_constant_i32(a->imm)); | ||
114 | + store_reg(s, a->rdm, rdm); | ||
115 | + tcg_temp_free_ptr(qd); | ||
116 | + mve_update_eci(s); | ||
117 | + return true; | ||
118 | +} | ||
119 | -- | 112 | -- |
120 | 2.20.1 | 113 | 2.34.1 |
121 | 114 | ||
122 | 115 | diff view generated by jsdifflib |
1 | Implement the MVE saturating shift-right-and-narrow insns | 1 | FEAT_Spec_FPACC is a feature describing speculative behaviour in the |
---|---|---|---|
2 | VQSHRN, VQSHRUN, VQRSHRN and VQRSHRUN. | 2 | event of a PAC authontication failure when FEAT_FPACCOMBINE is |
3 | implemented. FEAT_Spec_FPACC means that the speculative use of | ||
4 | pointers processed by a PAC Authentication is not materially | ||
5 | different in terms of the impact on cached microarchitectural state | ||
6 | (caches, TLBs, etc) between passing and failing of the PAC | ||
7 | Authentication. | ||
3 | 8 | ||
4 | do_srshr() is borrowed from sve_helper.c. | 9 | QEMU doesn't do speculative execution, so we can advertise |
10 | this feature. | ||
5 | 11 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210628135835.6690-13-peter.maydell@linaro.org | 14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
15 | Message-id: 20240418152004.2106516-6-peter.maydell@linaro.org | ||
9 | --- | 16 | --- |
10 | target/arm/helper-mve.h | 30 +++++++++++ | 17 | docs/system/arm/emulation.rst | 1 + |
11 | target/arm/mve.decode | 28 ++++++++++ | 18 | target/arm/tcg/cpu64.c | 4 ++++ |
12 | target/arm/mve_helper.c | 104 +++++++++++++++++++++++++++++++++++++ | 19 | 2 files changed, 5 insertions(+) |
13 | target/arm/translate-mve.c | 12 +++++ | ||
14 | 4 files changed, 174 insertions(+) | ||
15 | 20 | ||
16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 21 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
17 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper-mve.h | 23 | --- a/docs/system/arm/emulation.rst |
19 | +++ b/target/arm/helper-mve.h | 24 | +++ b/docs/system/arm/emulation.rst |
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 25 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
21 | DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 26 | - FEAT_FP16 (Half-precision floating-point data processing) |
22 | DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 27 | - FEAT_FPAC (Faulting on AUT* instructions) |
23 | DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 28 | - FEAT_FPACCOMBINE (Faulting on combined pointer authentication instructions) |
29 | +- FEAT_FPACC_SPEC (Speculative behavior of combined pointer authentication instructions) | ||
30 | - FEAT_FRINTTS (Floating-point to integer instructions) | ||
31 | - FEAT_FlagM (Flag manipulation instructions v2) | ||
32 | - FEAT_FlagM2 (Enhancements to flag manipulation instructions) | ||
33 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/tcg/cpu64.c | ||
36 | +++ b/target/arm/tcg/cpu64.c | ||
37 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) | ||
38 | t = FIELD_DP64(t, ID_AA64MMFR2, E0PD, 1); /* FEAT_E0PD */ | ||
39 | cpu->isar.id_aa64mmfr2 = t; | ||
40 | |||
41 | + t = cpu->isar.id_aa64mmfr3; | ||
42 | + t = FIELD_DP64(t, ID_AA64MMFR3, SPEC_FPACC, 1); /* FEAT_FPACC_SPEC */ | ||
43 | + cpu->isar.id_aa64mmfr3 = t; | ||
24 | + | 44 | + |
25 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 45 | t = cpu->isar.id_aa64zfr0; |
26 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 46 | t = FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 1); |
27 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 47 | t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* FEAT_SVE_PMULL128 */ |
28 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | + | ||
35 | +DEF_HELPER_FLAGS_4(mve_vqshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_4(mve_vqshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | +DEF_HELPER_FLAGS_4(mve_vqshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(mve_vqshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | + | ||
40 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
42 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
43 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
44 | + | ||
45 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
46 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
47 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
48 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
49 | + | ||
50 | +DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
51 | +DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
53 | +DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
54 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/target/arm/mve.decode | ||
57 | +++ b/target/arm/mve.decode | ||
58 | @@ -XXX,XX +XXX,XX @@ VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | ||
59 | VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | ||
60 | VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | ||
61 | VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | ||
62 | + | ||
63 | +VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b | ||
64 | +VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h | ||
65 | +VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b | ||
66 | +VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h | ||
67 | +VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b | ||
68 | +VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h | ||
69 | +VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b | ||
70 | +VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h | ||
71 | + | ||
72 | +VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
73 | +VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
74 | +VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
75 | +VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
76 | + | ||
77 | +VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b | ||
78 | +VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h | ||
79 | +VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b | ||
80 | +VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h | ||
81 | +VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b | ||
82 | +VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h | ||
83 | +VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b | ||
84 | +VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h | ||
85 | + | ||
86 | +VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
87 | +VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
88 | +VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
89 | +VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
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 @@ static inline uint64_t do_urshr(uint64_t x, unsigned sh) | ||
95 | } | ||
96 | } | ||
97 | |||
98 | +static inline int64_t do_srshr(int64_t x, unsigned sh) | ||
99 | +{ | ||
100 | + if (likely(sh < 64)) { | ||
101 | + return (x >> sh) + ((x >> (sh - 1)) & 1); | ||
102 | + } else { | ||
103 | + /* Rounding the sign bit always produces 0. */ | ||
104 | + return 0; | ||
105 | + } | ||
106 | +} | ||
107 | + | ||
108 | DO_VSHRN_ALL(vshrn, DO_SHR) | ||
109 | DO_VSHRN_ALL(vrshrn, do_urshr) | ||
110 | + | ||
111 | +static inline int32_t do_sat_bhs(int64_t val, int64_t min, int64_t max, | ||
112 | + bool *satp) | ||
113 | +{ | ||
114 | + if (val > max) { | ||
115 | + *satp = true; | ||
116 | + return max; | ||
117 | + } else if (val < min) { | ||
118 | + *satp = true; | ||
119 | + return min; | ||
120 | + } else { | ||
121 | + return val; | ||
122 | + } | ||
123 | +} | ||
124 | + | ||
125 | +/* Saturating narrowing right shifts */ | ||
126 | +#define DO_VSHRN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | ||
127 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
128 | + void *vm, uint32_t shift) \ | ||
129 | + { \ | ||
130 | + LTYPE *m = vm; \ | ||
131 | + TYPE *d = vd; \ | ||
132 | + uint16_t mask = mve_element_mask(env); \ | ||
133 | + bool qc = false; \ | ||
134 | + unsigned le; \ | ||
135 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
136 | + bool sat = false; \ | ||
137 | + TYPE r = FN(m[H##LESIZE(le)], shift, &sat); \ | ||
138 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
139 | + qc |= sat && (mask & 1 << (TOP * ESIZE)); \ | ||
140 | + } \ | ||
141 | + if (qc) { \ | ||
142 | + env->vfp.qc[0] = qc; \ | ||
143 | + } \ | ||
144 | + mve_advance_vpt(env); \ | ||
145 | + } | ||
146 | + | ||
147 | +#define DO_VSHRN_SAT_UB(BOP, TOP, FN) \ | ||
148 | + DO_VSHRN_SAT(BOP, false, 1, uint8_t, 2, uint16_t, FN) \ | ||
149 | + DO_VSHRN_SAT(TOP, true, 1, uint8_t, 2, uint16_t, FN) | ||
150 | + | ||
151 | +#define DO_VSHRN_SAT_UH(BOP, TOP, FN) \ | ||
152 | + DO_VSHRN_SAT(BOP, false, 2, uint16_t, 4, uint32_t, FN) \ | ||
153 | + DO_VSHRN_SAT(TOP, true, 2, uint16_t, 4, uint32_t, FN) | ||
154 | + | ||
155 | +#define DO_VSHRN_SAT_SB(BOP, TOP, FN) \ | ||
156 | + DO_VSHRN_SAT(BOP, false, 1, int8_t, 2, int16_t, FN) \ | ||
157 | + DO_VSHRN_SAT(TOP, true, 1, int8_t, 2, int16_t, FN) | ||
158 | + | ||
159 | +#define DO_VSHRN_SAT_SH(BOP, TOP, FN) \ | ||
160 | + DO_VSHRN_SAT(BOP, false, 2, int16_t, 4, int32_t, FN) \ | ||
161 | + DO_VSHRN_SAT(TOP, true, 2, int16_t, 4, int32_t, FN) | ||
162 | + | ||
163 | +#define DO_SHRN_SB(N, M, SATP) \ | ||
164 | + do_sat_bhs((int64_t)(N) >> (M), INT8_MIN, INT8_MAX, SATP) | ||
165 | +#define DO_SHRN_UB(N, M, SATP) \ | ||
166 | + do_sat_bhs((uint64_t)(N) >> (M), 0, UINT8_MAX, SATP) | ||
167 | +#define DO_SHRUN_B(N, M, SATP) \ | ||
168 | + do_sat_bhs((int64_t)(N) >> (M), 0, UINT8_MAX, SATP) | ||
169 | + | ||
170 | +#define DO_SHRN_SH(N, M, SATP) \ | ||
171 | + do_sat_bhs((int64_t)(N) >> (M), INT16_MIN, INT16_MAX, SATP) | ||
172 | +#define DO_SHRN_UH(N, M, SATP) \ | ||
173 | + do_sat_bhs((uint64_t)(N) >> (M), 0, UINT16_MAX, SATP) | ||
174 | +#define DO_SHRUN_H(N, M, SATP) \ | ||
175 | + do_sat_bhs((int64_t)(N) >> (M), 0, UINT16_MAX, SATP) | ||
176 | + | ||
177 | +#define DO_RSHRN_SB(N, M, SATP) \ | ||
178 | + do_sat_bhs(do_srshr(N, M), INT8_MIN, INT8_MAX, SATP) | ||
179 | +#define DO_RSHRN_UB(N, M, SATP) \ | ||
180 | + do_sat_bhs(do_urshr(N, M), 0, UINT8_MAX, SATP) | ||
181 | +#define DO_RSHRUN_B(N, M, SATP) \ | ||
182 | + do_sat_bhs(do_srshr(N, M), 0, UINT8_MAX, SATP) | ||
183 | + | ||
184 | +#define DO_RSHRN_SH(N, M, SATP) \ | ||
185 | + do_sat_bhs(do_srshr(N, M), INT16_MIN, INT16_MAX, SATP) | ||
186 | +#define DO_RSHRN_UH(N, M, SATP) \ | ||
187 | + do_sat_bhs(do_urshr(N, M), 0, UINT16_MAX, SATP) | ||
188 | +#define DO_RSHRUN_H(N, M, SATP) \ | ||
189 | + do_sat_bhs(do_srshr(N, M), 0, UINT16_MAX, SATP) | ||
190 | + | ||
191 | +DO_VSHRN_SAT_SB(vqshrnb_sb, vqshrnt_sb, DO_SHRN_SB) | ||
192 | +DO_VSHRN_SAT_SH(vqshrnb_sh, vqshrnt_sh, DO_SHRN_SH) | ||
193 | +DO_VSHRN_SAT_UB(vqshrnb_ub, vqshrnt_ub, DO_SHRN_UB) | ||
194 | +DO_VSHRN_SAT_UH(vqshrnb_uh, vqshrnt_uh, DO_SHRN_UH) | ||
195 | +DO_VSHRN_SAT_SB(vqshrunbb, vqshruntb, DO_SHRUN_B) | ||
196 | +DO_VSHRN_SAT_SH(vqshrunbh, vqshrunth, DO_SHRUN_H) | ||
197 | + | ||
198 | +DO_VSHRN_SAT_SB(vqrshrnb_sb, vqrshrnt_sb, DO_RSHRN_SB) | ||
199 | +DO_VSHRN_SAT_SH(vqrshrnb_sh, vqrshrnt_sh, DO_RSHRN_SH) | ||
200 | +DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB) | ||
201 | +DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) | ||
202 | +DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | ||
203 | +DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) | ||
204 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
205 | index XXXXXXX..XXXXXXX 100644 | ||
206 | --- a/target/arm/translate-mve.c | ||
207 | +++ b/target/arm/translate-mve.c | ||
208 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_N(VSHRNB, vshrnb) | ||
209 | DO_2SHIFT_N(VSHRNT, vshrnt) | ||
210 | DO_2SHIFT_N(VRSHRNB, vrshrnb) | ||
211 | DO_2SHIFT_N(VRSHRNT, vrshrnt) | ||
212 | +DO_2SHIFT_N(VQSHRNB_S, vqshrnb_s) | ||
213 | +DO_2SHIFT_N(VQSHRNT_S, vqshrnt_s) | ||
214 | +DO_2SHIFT_N(VQSHRNB_U, vqshrnb_u) | ||
215 | +DO_2SHIFT_N(VQSHRNT_U, vqshrnt_u) | ||
216 | +DO_2SHIFT_N(VQSHRUNB, vqshrunb) | ||
217 | +DO_2SHIFT_N(VQSHRUNT, vqshrunt) | ||
218 | +DO_2SHIFT_N(VQRSHRNB_S, vqrshrnb_s) | ||
219 | +DO_2SHIFT_N(VQRSHRNT_S, vqrshrnt_s) | ||
220 | +DO_2SHIFT_N(VQRSHRNB_U, vqrshrnb_u) | ||
221 | +DO_2SHIFT_N(VQRSHRNT_U, vqrshrnt_u) | ||
222 | +DO_2SHIFT_N(VQRSHRUNB, vqrshrunb) | ||
223 | +DO_2SHIFT_N(VQRSHRUNT, vqrshrunt) | ||
224 | -- | 48 | -- |
225 | 2.20.1 | 49 | 2.34.1 |
226 | 50 | ||
227 | 51 | diff view generated by jsdifflib |
1 | Implement the MVE shift-right-and-narrow insn VSHRN and VRSHRN. | 1 | The Linux kernel 5.10.16 binary for sunxi has been removed from |
---|---|---|---|
2 | apt.armbian.com. This means that the avocado tests for these machines | ||
3 | will be skipped (status CANCEL) if the old binary isn't present in | ||
4 | the avocado cache. | ||
2 | 5 | ||
3 | do_urshr() is borrowed from sve_helper.c. | 6 | Update to 6.6.16, in the same way we did in commit e384db41d8661 |
7 | when we moved to 5.10.16 in 2021. | ||
4 | 8 | ||
9 | Cc: qemu-stable@nongnu.org | ||
10 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2284 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Reviewed-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> |
7 | Message-id: 20210628135835.6690-12-peter.maydell@linaro.org | 13 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> |
14 | Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
15 | Message-id: 20240415151845.1564201-1-peter.maydell@linaro.org | ||
8 | --- | 16 | --- |
9 | target/arm/helper-mve.h | 10 ++++++++++ | 17 | tests/avocado/boot_linux_console.py | 70 ++++++++++++++--------------- |
10 | target/arm/mve.decode | 11 +++++++++++ | 18 | tests/avocado/replay_kernel.py | 8 ++-- |
11 | target/arm/mve_helper.c | 40 ++++++++++++++++++++++++++++++++++++++ | 19 | 2 files changed, 39 insertions(+), 39 deletions(-) |
12 | target/arm/translate-mve.c | 15 ++++++++++++++ | ||
13 | 4 files changed, 76 insertions(+) | ||
14 | 20 | ||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 21 | diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py |
16 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-mve.h | 23 | --- a/tests/avocado/boot_linux_console.py |
18 | +++ b/target/arm/helper-mve.h | 24 | +++ b/tests/avocado/boot_linux_console.py |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 25 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self): |
20 | DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 26 | :avocado: tags=accel:tcg |
21 | DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 27 | """ |
22 | DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 28 | deb_url = ('https://apt.armbian.com/pool/main/l/' |
23 | + | 29 | - 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') |
24 | +DEF_HELPER_FLAGS_4(mve_vshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 30 | - deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' |
25 | +DEF_HELPER_FLAGS_4(mve_vshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 31 | + 'linux-6.6.16/linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb') |
26 | +DEF_HELPER_FLAGS_4(mve_vshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 32 | + deb_hash = 'f7c3c8c5432f765445dc6e7eab02f3bbe668256b' |
27 | +DEF_HELPER_FLAGS_4(mve_vshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 33 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
28 | + | 34 | kernel_path = self.extract_from_deb(deb_path, |
29 | +DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 35 | - '/boot/vmlinuz-5.10.16-sunxi') |
30 | +DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 36 | - dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' |
31 | +DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 37 | + '/boot/vmlinuz-6.6.16-current-sunxi') |
32 | +DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 38 | + dtb_path = '/usr/lib/linux-image-6.6.16-current-sunxi/sun4i-a10-cubieboard.dtb' |
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 39 | dtb_path = self.extract_from_deb(deb_path, dtb_path) |
40 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
41 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
42 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_sata(self): | ||
43 | :avocado: tags=accel:tcg | ||
44 | """ | ||
45 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
46 | - 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
47 | - deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
48 | + 'linux-6.6.16/linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb') | ||
49 | + deb_hash = 'f7c3c8c5432f765445dc6e7eab02f3bbe668256b' | ||
50 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
51 | kernel_path = self.extract_from_deb(deb_path, | ||
52 | - '/boot/vmlinuz-5.10.16-sunxi') | ||
53 | - dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' | ||
54 | + '/boot/vmlinuz-6.6.16-current-sunxi') | ||
55 | + dtb_path = '/usr/lib/linux-image-6.6.16-current-sunxi/sun4i-a10-cubieboard.dtb' | ||
56 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
57 | rootfs_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
58 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
59 | @@ -XXX,XX +XXX,XX @@ def test_arm_bpim2u(self): | ||
60 | :avocado: tags=machine:bpim2u | ||
61 | :avocado: tags=accel:tcg | ||
62 | """ | ||
63 | - deb_url = ('https://apt.armbian.com/pool/main/l/linux-5.10.16-sunxi/' | ||
64 | - 'linux-image-current-sunxi_21.02.2_armhf.deb') | ||
65 | - deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
66 | + deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
67 | + 'linux-6.6.16/linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb') | ||
68 | + deb_hash = 'f7c3c8c5432f765445dc6e7eab02f3bbe668256b' | ||
69 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
70 | kernel_path = self.extract_from_deb(deb_path, | ||
71 | - '/boot/vmlinuz-5.10.16-sunxi') | ||
72 | - dtb_path = ('/usr/lib/linux-image-current-sunxi/' | ||
73 | + '/boot/vmlinuz-6.6.16-current-sunxi') | ||
74 | + dtb_path = ('/usr/lib/linux-image-6.6.16-current-sunxi/' | ||
75 | 'sun8i-r40-bananapi-m2-ultra.dtb') | ||
76 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
77 | |||
78 | @@ -XXX,XX +XXX,XX @@ def test_arm_bpim2u_initrd(self): | ||
79 | :avocado: tags=accel:tcg | ||
80 | :avocado: tags=machine:bpim2u | ||
81 | """ | ||
82 | - deb_url = ('https://apt.armbian.com/pool/main/l/linux-5.10.16-sunxi/' | ||
83 | - 'linux-image-current-sunxi_21.02.2_armhf.deb') | ||
84 | - deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
85 | + deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
86 | + 'linux-6.6.16/linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb') | ||
87 | + deb_hash = 'f7c3c8c5432f765445dc6e7eab02f3bbe668256b' | ||
88 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
89 | kernel_path = self.extract_from_deb(deb_path, | ||
90 | - '/boot/vmlinuz-5.10.16-sunxi') | ||
91 | - dtb_path = ('/usr/lib/linux-image-current-sunxi/' | ||
92 | + '/boot/vmlinuz-6.6.16-current-sunxi') | ||
93 | + dtb_path = ('/usr/lib/linux-image-6.6.16-current-sunxi/' | ||
94 | 'sun8i-r40-bananapi-m2-ultra.dtb') | ||
95 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
96 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
97 | @@ -XXX,XX +XXX,XX @@ def test_arm_bpim2u_gmac(self): | ||
98 | """ | ||
99 | self.require_netdev('user') | ||
100 | |||
101 | - deb_url = ('https://apt.armbian.com/pool/main/l/linux-5.10.16-sunxi/' | ||
102 | - 'linux-image-current-sunxi_21.02.2_armhf.deb') | ||
103 | - deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
104 | + deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
105 | + 'linux-6.6.16/linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb') | ||
106 | + deb_hash = 'f7c3c8c5432f765445dc6e7eab02f3bbe668256b' | ||
107 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
108 | kernel_path = self.extract_from_deb(deb_path, | ||
109 | - '/boot/vmlinuz-5.10.16-sunxi') | ||
110 | - dtb_path = ('/usr/lib/linux-image-current-sunxi/' | ||
111 | + '/boot/vmlinuz-6.6.16-current-sunxi') | ||
112 | + dtb_path = ('/usr/lib/linux-image-6.6.16-current-sunxi/' | ||
113 | 'sun8i-r40-bananapi-m2-ultra.dtb') | ||
114 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
115 | rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/' | ||
116 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi(self): | ||
117 | :avocado: tags=accel:tcg | ||
118 | """ | ||
119 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
120 | - 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
121 | - deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
122 | + 'linux-6.6.16/linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb') | ||
123 | + deb_hash = 'f7c3c8c5432f765445dc6e7eab02f3bbe668256b' | ||
124 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
125 | kernel_path = self.extract_from_deb(deb_path, | ||
126 | - '/boot/vmlinuz-5.10.16-sunxi') | ||
127 | - dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
128 | + '/boot/vmlinuz-6.6.16-current-sunxi') | ||
129 | + dtb_path = '/usr/lib/linux-image-6.6.16-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
130 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
131 | |||
132 | self.vm.set_console() | ||
133 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_initrd(self): | ||
134 | :avocado: tags=machine:orangepi-pc | ||
135 | """ | ||
136 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
137 | - 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
138 | - deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
139 | + 'linux-6.6.16/linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb') | ||
140 | + deb_hash = 'f7c3c8c5432f765445dc6e7eab02f3bbe668256b' | ||
141 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
142 | kernel_path = self.extract_from_deb(deb_path, | ||
143 | - '/boot/vmlinuz-5.10.16-sunxi') | ||
144 | - dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
145 | + '/boot/vmlinuz-6.6.16-current-sunxi') | ||
146 | + dtb_path = '/usr/lib/linux-image-6.6.16-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
147 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
148 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
149 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
150 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_sd(self): | ||
151 | self.require_netdev('user') | ||
152 | |||
153 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
154 | - 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
155 | - deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
156 | + 'linux-6.6.16/linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb') | ||
157 | + deb_hash = 'f7c3c8c5432f765445dc6e7eab02f3bbe668256b' | ||
158 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
159 | kernel_path = self.extract_from_deb(deb_path, | ||
160 | - '/boot/vmlinuz-5.10.16-sunxi') | ||
161 | - dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
162 | + '/boot/vmlinuz-6.6.16-current-sunxi') | ||
163 | + dtb_path = '/usr/lib/linux-image-6.6.16-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
164 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
165 | rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/' | ||
166 | 'buildroot-baseline/20221116.0/armel/rootfs.ext2.xz') | ||
167 | diff --git a/tests/avocado/replay_kernel.py b/tests/avocado/replay_kernel.py | ||
34 | index XXXXXXX..XXXXXXX 100644 | 168 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/mve.decode | 169 | --- a/tests/avocado/replay_kernel.py |
36 | +++ b/target/arm/mve.decode | 170 | +++ b/tests/avocado/replay_kernel.py |
37 | @@ -XXX,XX +XXX,XX @@ VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w | 171 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self): |
38 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | 172 | :avocado: tags=machine:cubieboard |
39 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | 173 | """ |
40 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | 174 | deb_url = ('https://apt.armbian.com/pool/main/l/' |
41 | + | 175 | - 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') |
42 | +# Narrowing shifts (which only support b and h sizes) | 176 | - deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' |
43 | +VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | 177 | + 'linux-6.6.16/linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb') |
44 | +VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | 178 | + deb_hash = 'f7c3c8c5432f765445dc6e7eab02f3bbe668256b' |
45 | +VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | 179 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
46 | +VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | 180 | kernel_path = self.extract_from_deb(deb_path, |
47 | + | 181 | - '/boot/vmlinuz-5.10.16-sunxi') |
48 | +VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | 182 | - dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' |
49 | +VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | 183 | + '/boot/vmlinuz-6.6.16-current-sunxi') |
50 | +VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | 184 | + dtb_path = '/usr/lib/linux-image-6.6.16-current-sunxi/sun4i-a10-cubieboard.dtb' |
51 | +VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | 185 | dtb_path = self.extract_from_deb(deb_path, dtb_path) |
52 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 186 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' |
53 | index XXXXXXX..XXXXXXX 100644 | 187 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' |
54 | --- a/target/arm/mve_helper.c | ||
55 | +++ b/target/arm/mve_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK) | ||
57 | |||
58 | DO_VSHLL_ALL(vshllb, false) | ||
59 | DO_VSHLL_ALL(vshllt, true) | ||
60 | + | ||
61 | +/* | ||
62 | + * Narrowing right shifts, taking a double sized input, shifting it | ||
63 | + * and putting the result in either the top or bottom half of the output. | ||
64 | + * ESIZE, TYPE are the output, and LESIZE, LTYPE the input. | ||
65 | + */ | ||
66 | +#define DO_VSHRN(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | ||
67 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
68 | + void *vm, uint32_t shift) \ | ||
69 | + { \ | ||
70 | + LTYPE *m = vm; \ | ||
71 | + TYPE *d = vd; \ | ||
72 | + uint16_t mask = mve_element_mask(env); \ | ||
73 | + unsigned le; \ | ||
74 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
75 | + TYPE r = FN(m[H##LESIZE(le)], shift); \ | ||
76 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
77 | + } \ | ||
78 | + mve_advance_vpt(env); \ | ||
79 | + } | ||
80 | + | ||
81 | +#define DO_VSHRN_ALL(OP, FN) \ | ||
82 | + DO_VSHRN(OP##bb, false, 1, uint8_t, 2, uint16_t, FN) \ | ||
83 | + DO_VSHRN(OP##bh, false, 2, uint16_t, 4, uint32_t, FN) \ | ||
84 | + DO_VSHRN(OP##tb, true, 1, uint8_t, 2, uint16_t, FN) \ | ||
85 | + DO_VSHRN(OP##th, true, 2, uint16_t, 4, uint32_t, FN) | ||
86 | + | ||
87 | +static inline uint64_t do_urshr(uint64_t x, unsigned sh) | ||
88 | +{ | ||
89 | + if (likely(sh < 64)) { | ||
90 | + return (x >> sh) + ((x >> (sh - 1)) & 1); | ||
91 | + } else if (sh == 64) { | ||
92 | + return x >> 63; | ||
93 | + } else { | ||
94 | + return 0; | ||
95 | + } | ||
96 | +} | ||
97 | + | ||
98 | +DO_VSHRN_ALL(vshrn, DO_SHR) | ||
99 | +DO_VSHRN_ALL(vrshrn, do_urshr) | ||
100 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/target/arm/translate-mve.c | ||
103 | +++ b/target/arm/translate-mve.c | ||
104 | @@ -XXX,XX +XXX,XX @@ DO_VSHLL(VSHLL_BS, vshllbs) | ||
105 | DO_VSHLL(VSHLL_BU, vshllbu) | ||
106 | DO_VSHLL(VSHLL_TS, vshllts) | ||
107 | DO_VSHLL(VSHLL_TU, vshlltu) | ||
108 | + | ||
109 | +#define DO_2SHIFT_N(INSN, FN) \ | ||
110 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
111 | + { \ | ||
112 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
113 | + gen_helper_mve_##FN##b, \ | ||
114 | + gen_helper_mve_##FN##h, \ | ||
115 | + }; \ | ||
116 | + return do_2shift(s, a, fns[a->size], false); \ | ||
117 | + } | ||
118 | + | ||
119 | +DO_2SHIFT_N(VSHRNB, vshrnb) | ||
120 | +DO_2SHIFT_N(VSHRNT, vshrnt) | ||
121 | +DO_2SHIFT_N(VRSHRNB, vrshrnb) | ||
122 | +DO_2SHIFT_N(VRSHRNT, vrshrnt) | ||
123 | -- | 188 | -- |
124 | 2.20.1 | 189 | 2.34.1 |
125 | |||
126 | diff view generated by jsdifflib |
1 | Implement the MVE vector shift right by immediate insns VSHRI and | 1 | The generic timer frequency is settable by board code via a QOM |
---|---|---|---|
2 | VRSHRI. As with Neon, we implement these by using helper functions | 2 | property "cntfrq", but otherwise defaults to 62.5MHz. The way this |
3 | which perform left shifts but allow negative shift counts to indicate | 3 | is done includes some complication resulting from how this was |
4 | right shifts. | 4 | originally a fixed value with no QOM property. Clean it up: |
5 | |||
6 | * always set cpu->gt_cntfrq_hz to some sensible value, whether | ||
7 | the CPU has the generic timer or not, and whether it's system | ||
8 | or user-only emulation | ||
9 | * this means we can always use gt_cntfrq_hz, and never need | ||
10 | the old GTIMER_SCALE define | ||
11 | * set the default value in exactly one place, in the realize fn | ||
12 | |||
13 | The aim here is to pave the way for handling the ARMv8.6 requirement | ||
14 | that the generic timer frequency is always 1GHz. We're going to do | ||
15 | that by having old CPU types keep their legacy-in-QEMU behaviour and | ||
16 | having the default for any new CPU types be a 1GHz rather han 62.5MHz | ||
17 | cntfrq, so we want the point where the default is decided to be in | ||
18 | one place, and in code, not in a DEFINE_PROP_UINT64() initializer. | ||
19 | |||
20 | This commit should have no behavioural changes. | ||
5 | 21 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 24 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210628135835.6690-9-peter.maydell@linaro.org | 25 | Message-id: 20240426122913.3427983-2-peter.maydell@linaro.org |
9 | --- | 26 | --- |
10 | target/arm/helper-mve.h | 12 ++++++++++++ | 27 | target/arm/internals.h | 7 ++++--- |
11 | target/arm/translate.h | 20 ++++++++++++++++++++ | 28 | target/arm/cpu.c | 31 +++++++++++++++++-------------- |
12 | target/arm/mve.decode | 28 ++++++++++++++++++++++++++++ | 29 | target/arm/helper.c | 16 ++++++++-------- |
13 | target/arm/mve_helper.c | 7 +++++++ | 30 | 3 files changed, 29 insertions(+), 25 deletions(-) |
14 | target/arm/translate-mve.c | 5 +++++ | ||
15 | target/arm/translate-neon.c | 18 ------------------ | ||
16 | 6 files changed, 72 insertions(+), 18 deletions(-) | ||
17 | 31 | ||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 32 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
19 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper-mve.h | 34 | --- a/target/arm/internals.h |
21 | +++ b/target/arm/helper-mve.h | 35 | +++ b/target/arm/internals.h |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | 36 | @@ -XXX,XX +XXX,XX @@ static inline bool excp_is_internal(int excp) |
23 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | 37 | || excp == EXCP_SEMIHOST; |
24 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | 38 | } |
25 | 39 | ||
26 | +DEF_HELPER_FLAGS_4(mve_vshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 40 | -/* Scale factor for generic timers, ie number of ns per tick. |
27 | +DEF_HELPER_FLAGS_4(mve_vshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 41 | - * This gives a 62.5MHz timer. |
28 | +DEF_HELPER_FLAGS_4(mve_vshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 42 | +/* |
43 | + * Default frequency for the generic timer, in Hz. | ||
44 | + * This is 62.5MHz, which gives a 16 ns tick period. | ||
45 | */ | ||
46 | -#define GTIMER_SCALE 16 | ||
47 | +#define GTIMER_DEFAULT_HZ 62500000 | ||
48 | |||
49 | /* Bit definitions for the v7M CONTROL register */ | ||
50 | FIELD(V7M_CONTROL, NPRIV, 0, 1) | ||
51 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/cpu.c | ||
54 | +++ b/target/arm/cpu.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) | ||
56 | } | ||
57 | } | ||
58 | |||
59 | +/* | ||
60 | + * 0 means "unset, use the default value". That default might vary depending | ||
61 | + * on the CPU type, and is set in the realize fn. | ||
62 | + */ | ||
63 | static Property arm_cpu_gt_cntfrq_property = | ||
64 | - DEFINE_PROP_UINT64("cntfrq", ARMCPU, gt_cntfrq_hz, | ||
65 | - NANOSECONDS_PER_SECOND / GTIMER_SCALE); | ||
66 | + DEFINE_PROP_UINT64("cntfrq", ARMCPU, gt_cntfrq_hz, 0); | ||
67 | |||
68 | static Property arm_cpu_reset_cbar_property = | ||
69 | DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); | ||
70 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
71 | return; | ||
72 | } | ||
73 | |||
74 | + if (!cpu->gt_cntfrq_hz) { | ||
75 | + /* | ||
76 | + * 0 means "the board didn't set a value, use the default". | ||
77 | + * The default value of the generic timer frequency (as seen in | ||
78 | + * CNTFRQ_EL0) is 62.5MHz, which corresponds to a period of 16ns. | ||
79 | + * This is what you get (a) for a CONFIG_USER_ONLY CPU (b) if the | ||
80 | + * board doesn't set it. | ||
81 | + */ | ||
82 | + cpu->gt_cntfrq_hz = GTIMER_DEFAULT_HZ; | ||
83 | + } | ||
29 | + | 84 | + |
30 | DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 85 | #ifndef CONFIG_USER_ONLY |
31 | DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 86 | /* The NVIC and M-profile CPU are two halves of a single piece of |
32 | DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 87 | * hardware; trying to use one without the other is a command line |
33 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 88 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
34 | DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 89 | } |
35 | DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 90 | |
36 | DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 91 | { |
92 | - uint64_t scale; | ||
93 | - | ||
94 | - if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { | ||
95 | - if (!cpu->gt_cntfrq_hz) { | ||
96 | - error_setg(errp, "Invalid CNTFRQ: %"PRId64"Hz", | ||
97 | - cpu->gt_cntfrq_hz); | ||
98 | - return; | ||
99 | - } | ||
100 | - scale = gt_cntfrq_period_ns(cpu); | ||
101 | - } else { | ||
102 | - scale = GTIMER_SCALE; | ||
103 | - } | ||
104 | + uint64_t scale = gt_cntfrq_period_ns(cpu); | ||
105 | |||
106 | cpu->gt_timer[GTIMER_PHYS] = timer_new(QEMU_CLOCK_VIRTUAL, scale, | ||
107 | arm_gt_ptimer_cb, cpu); | ||
108 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/target/arm/helper.c | ||
111 | +++ b/target/arm/helper.c | ||
112 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = { | ||
113 | .resetvalue = 0 }, | ||
114 | }; | ||
115 | |||
116 | +static void arm_gt_cntfrq_reset(CPUARMState *env, const ARMCPRegInfo *opaque) | ||
117 | +{ | ||
118 | + ARMCPU *cpu = env_archcpu(env); | ||
37 | + | 119 | + |
38 | +DEF_HELPER_FLAGS_4(mve_vrshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 120 | + cpu->env.cp15.c14_cntfrq = cpu->gt_cntfrq_hz; |
39 | +DEF_HELPER_FLAGS_4(mve_vrshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | + | ||
42 | +DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
43 | +DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
44 | +DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
45 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/translate.h | ||
48 | +++ b/target/arm/translate.h | ||
49 | @@ -XXX,XX +XXX,XX @@ static inline int times_2_plus_1(DisasContext *s, int x) | ||
50 | return x * 2 + 1; | ||
51 | } | ||
52 | |||
53 | +static inline int rsub_64(DisasContext *s, int x) | ||
54 | +{ | ||
55 | + return 64 - x; | ||
56 | +} | 121 | +} |
57 | + | 122 | + |
58 | +static inline int rsub_32(DisasContext *s, int x) | 123 | #ifndef CONFIG_USER_ONLY |
59 | +{ | 124 | |
60 | + return 32 - x; | 125 | static CPAccessResult gt_cntfrq_access(CPUARMState *env, const ARMCPRegInfo *ri, |
61 | +} | 126 | @@ -XXX,XX +XXX,XX @@ void arm_gt_hvtimer_cb(void *opaque) |
62 | + | 127 | gt_recalc_timer(cpu, GTIMER_HYPVIRT); |
63 | +static inline int rsub_16(DisasContext *s, int x) | ||
64 | +{ | ||
65 | + return 16 - x; | ||
66 | +} | ||
67 | + | ||
68 | +static inline int rsub_8(DisasContext *s, int x) | ||
69 | +{ | ||
70 | + return 8 - x; | ||
71 | +} | ||
72 | + | ||
73 | static inline int arm_dc_feature(DisasContext *dc, int feature) | ||
74 | { | ||
75 | return (dc->features & (1ULL << feature)) != 0; | ||
76 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/mve.decode | ||
79 | +++ b/target/arm/mve.decode | ||
80 | @@ -XXX,XX +XXX,XX @@ | ||
81 | @2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | ||
82 | @2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | ||
83 | |||
84 | +# Right shifts are encoded as N - shift, where N is the element size in bits. | ||
85 | +%rshift_i5 16:5 !function=rsub_32 | ||
86 | +%rshift_i4 16:4 !function=rsub_16 | ||
87 | +%rshift_i3 16:3 !function=rsub_8 | ||
88 | + | ||
89 | +@2_shr_b .... .... .. 001 ... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
90 | + size=0 shift=%rshift_i3 | ||
91 | +@2_shr_h .... .... .. 01 .... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
92 | + size=1 shift=%rshift_i4 | ||
93 | +@2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
94 | + size=2 shift=%rshift_i5 | ||
95 | + | ||
96 | # Vector loads and stores | ||
97 | |||
98 | # Widening loads and narrowing stores: | ||
99 | @@ -XXX,XX +XXX,XX @@ VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
100 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b | ||
101 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h | ||
102 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w | ||
103 | + | ||
104 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b | ||
105 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h | ||
106 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w | ||
107 | + | ||
108 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b | ||
109 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h | ||
110 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w | ||
111 | + | ||
112 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
113 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
114 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
115 | + | ||
116 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
117 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
118 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
119 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/target/arm/mve_helper.c | ||
122 | +++ b/target/arm/mve_helper.c | ||
123 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t) | ||
124 | DO_2SHIFT(OP##b, 1, uint8_t, FN) \ | ||
125 | DO_2SHIFT(OP##h, 2, uint16_t, FN) \ | ||
126 | DO_2SHIFT(OP##w, 4, uint32_t, FN) | ||
127 | +#define DO_2SHIFT_S(OP, FN) \ | ||
128 | + DO_2SHIFT(OP##b, 1, int8_t, FN) \ | ||
129 | + DO_2SHIFT(OP##h, 2, int16_t, FN) \ | ||
130 | + DO_2SHIFT(OP##w, 4, int32_t, FN) | ||
131 | |||
132 | #define DO_2SHIFT_SAT_U(OP, FN) \ | ||
133 | DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \ | ||
134 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t) | ||
135 | DO_2SHIFT_SAT(OP##w, 4, int32_t, FN) | ||
136 | |||
137 | DO_2SHIFT_U(vshli_u, DO_VSHLU) | ||
138 | +DO_2SHIFT_S(vshli_s, DO_VSHLS) | ||
139 | DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP) | ||
140 | DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
141 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
142 | +DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
143 | +DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
144 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
145 | index XXXXXXX..XXXXXXX 100644 | ||
146 | --- a/target/arm/translate-mve.c | ||
147 | +++ b/target/arm/translate-mve.c | ||
148 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHLI, vshli_u, false) | ||
149 | DO_2SHIFT(VQSHLI_S, vqshli_s, false) | ||
150 | DO_2SHIFT(VQSHLI_U, vqshli_u, false) | ||
151 | DO_2SHIFT(VQSHLUI, vqshlui_s, false) | ||
152 | +/* These right shifts use a left-shift helper with negated shift count */ | ||
153 | +DO_2SHIFT(VSHRI_S, vshli_s, true) | ||
154 | +DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
155 | +DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
156 | +DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
157 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/target/arm/translate-neon.c | ||
160 | +++ b/target/arm/translate-neon.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static inline int plus1(DisasContext *s, int x) | ||
162 | return x + 1; | ||
163 | } | 128 | } |
164 | 129 | ||
165 | -static inline int rsub_64(DisasContext *s, int x) | 130 | -static void arm_gt_cntfrq_reset(CPUARMState *env, const ARMCPRegInfo *opaque) |
166 | -{ | 131 | -{ |
167 | - return 64 - x; | 132 | - ARMCPU *cpu = env_archcpu(env); |
133 | - | ||
134 | - cpu->env.cp15.c14_cntfrq = cpu->gt_cntfrq_hz; | ||
168 | -} | 135 | -} |
169 | - | 136 | - |
170 | -static inline int rsub_32(DisasContext *s, int x) | 137 | static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
171 | -{ | 138 | /* |
172 | - return 32 - x; | 139 | * Note that CNTFRQ is purely reads-as-written for the benefit |
173 | -} | 140 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
174 | -static inline int rsub_16(DisasContext *s, int x) | 141 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 0, |
175 | -{ | 142 | .type = ARM_CP_CONST, .access = PL0_R /* no PL1_RW in linux-user */, |
176 | - return 16 - x; | 143 | .fieldoffset = offsetof(CPUARMState, cp15.c14_cntfrq), |
177 | -} | 144 | - .resetvalue = NANOSECONDS_PER_SECOND / GTIMER_SCALE, |
178 | -static inline int rsub_8(DisasContext *s, int x) | 145 | + .resetfn = arm_gt_cntfrq_reset, |
179 | -{ | 146 | }, |
180 | - return 8 - x; | 147 | { .name = "CNTVCT_EL0", .state = ARM_CP_STATE_AA64, |
181 | -} | 148 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 2, |
182 | - | ||
183 | static inline int neon_3same_fp_size(DisasContext *s, int x) | ||
184 | { | ||
185 | /* Convert 0==fp32, 1==fp16 into a MO_* value */ | ||
186 | -- | 149 | -- |
187 | 2.20.1 | 150 | 2.34.1 |
188 | 151 | ||
189 | 152 | diff view generated by jsdifflib |
1 | Implement the MVE VSRI and VSLI insns, which perform a | 1 | Currently QEMU CPUs always run with a generic timer counter frequency |
---|---|---|---|
2 | shift-and-insert operation. | 2 | of 62.5MHz, but ARMv8.6 CPUs will run at 1GHz. For older versions of |
3 | the TF-A firmware that sbsa-ref runs, the frequency of the generic | ||
4 | timer is hardcoded into the firmware, and so if the CPU actually has | ||
5 | a different frequency then timers in the guest will be set | ||
6 | incorrectly. | ||
7 | |||
8 | The default frequency used by the 'max' CPU is about to change, so | ||
9 | make the sbsa-ref board force the CPU frequency to the value which | ||
10 | the firmware expects. | ||
11 | |||
12 | Newer versions of TF-A will read the frequency from the CPU's | ||
13 | CNTFRQ_EL0 register: | ||
14 | https://github.com/ARM-software/arm-trusted-firmware/commit/4c77fac98dac0bebc63798aae9101ac865b87148 | ||
15 | so in the longer term we could make this board use the 1GHz | ||
16 | frequency. We will need to make sure we update the binaries used | ||
17 | by our avocado test | ||
18 | Aarch64SbsarefMachine.test_sbsaref_alpine_linux_max_pauth_impdef | ||
19 | before we can do that. | ||
3 | 20 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 22 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Message-id: 20210628135835.6690-11-peter.maydell@linaro.org | 23 | Reviewed-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
24 | Message-id: 20240426122913.3427983-3-peter.maydell@linaro.org | ||
7 | --- | 25 | --- |
8 | target/arm/helper-mve.h | 8 ++++++++ | 26 | hw/arm/sbsa-ref.c | 15 +++++++++++++++ |
9 | target/arm/mve.decode | 9 ++++++++ | 27 | 1 file changed, 15 insertions(+) |
10 | target/arm/mve_helper.c | 42 ++++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 3 +++ | ||
12 | 4 files changed, 62 insertions(+) | ||
13 | 28 | ||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 29 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
15 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper-mve.h | 31 | --- a/hw/arm/sbsa-ref.c |
17 | +++ b/target/arm/helper-mve.h | 32 | +++ b/hw/arm/sbsa-ref.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 33 | @@ -XXX,XX +XXX,XX @@ |
19 | DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 34 | #define NUM_SMMU_IRQS 4 |
20 | DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 35 | #define NUM_SATA_PORTS 6 |
21 | DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 36 | |
37 | +/* | ||
38 | + * Generic timer frequency in Hz (which drives both the CPU generic timers | ||
39 | + * and the SBSA watchdog-timer). Older versions of the TF-A firmware | ||
40 | + * typically used with sbsa-ref (including the binaries in our Avocado test | ||
41 | + * Aarch64SbsarefMachine.test_sbsaref_alpine_linux_max_pauth_impdef | ||
42 | + * assume it is this value. | ||
43 | + * | ||
44 | + * TODO: this value is not architecturally correct for an Armv8.6 or | ||
45 | + * better CPU, so we should move to 1GHz once the TF-A fix above has | ||
46 | + * made it into a release and into our Avocado test. | ||
47 | + */ | ||
48 | +#define SBSA_GTIMER_HZ 62500000 | ||
22 | + | 49 | + |
23 | +DEF_HELPER_FLAGS_4(mve_vsrib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 50 | enum { |
24 | +DEF_HELPER_FLAGS_4(mve_vsrih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 51 | SBSA_FLASH, |
25 | +DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 52 | SBSA_MEM, |
53 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
54 | &error_abort); | ||
55 | } | ||
56 | |||
57 | + object_property_set_int(cpuobj, "cntfrq", SBSA_GTIMER_HZ, &error_abort); | ||
26 | + | 58 | + |
27 | +DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 59 | object_property_set_link(cpuobj, "memory", OBJECT(sysmem), |
28 | +DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 60 | &error_abort); |
29 | +DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 61 | |
30 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/mve.decode | ||
33 | +++ b/target/arm/mve.decode | ||
34 | @@ -XXX,XX +XXX,XX @@ VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
35 | |||
36 | VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
37 | VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
38 | + | ||
39 | +# Shift-and-insert | ||
40 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_b | ||
41 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_h | ||
42 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w | ||
43 | + | ||
44 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | ||
45 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | ||
46 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | ||
47 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/mve_helper.c | ||
50 | +++ b/target/arm/mve_helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
52 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
53 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
54 | |||
55 | +/* Shift-and-insert; we always work with 64 bits at a time */ | ||
56 | +#define DO_2SHIFT_INSERT(OP, ESIZE, SHIFTFN, MASKFN) \ | ||
57 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
58 | + void *vm, uint32_t shift) \ | ||
59 | + { \ | ||
60 | + uint64_t *d = vd, *m = vm; \ | ||
61 | + uint16_t mask; \ | ||
62 | + uint64_t shiftmask; \ | ||
63 | + unsigned e; \ | ||
64 | + if (shift == 0 || shift == ESIZE * 8) { \ | ||
65 | + /* \ | ||
66 | + * Only VSLI can shift by 0; only VSRI can shift by <dt>. \ | ||
67 | + * The generic logic would give the right answer for 0 but \ | ||
68 | + * fails for <dt>. \ | ||
69 | + */ \ | ||
70 | + goto done; \ | ||
71 | + } \ | ||
72 | + assert(shift < ESIZE * 8); \ | ||
73 | + mask = mve_element_mask(env); \ | ||
74 | + /* ESIZE / 2 gives the MO_* value if ESIZE is in [1,2,4] */ \ | ||
75 | + shiftmask = dup_const(ESIZE / 2, MASKFN(ESIZE * 8, shift)); \ | ||
76 | + for (e = 0; e < 16 / 8; e++, mask >>= 8) { \ | ||
77 | + uint64_t r = (SHIFTFN(m[H8(e)], shift) & shiftmask) | \ | ||
78 | + (d[H8(e)] & ~shiftmask); \ | ||
79 | + mergemask(&d[H8(e)], r, mask); \ | ||
80 | + } \ | ||
81 | +done: \ | ||
82 | + mve_advance_vpt(env); \ | ||
83 | + } | ||
84 | + | ||
85 | +#define DO_SHL(N, SHIFT) ((N) << (SHIFT)) | ||
86 | +#define DO_SHR(N, SHIFT) ((N) >> (SHIFT)) | ||
87 | +#define SHL_MASK(EBITS, SHIFT) MAKE_64BIT_MASK((SHIFT), (EBITS) - (SHIFT)) | ||
88 | +#define SHR_MASK(EBITS, SHIFT) MAKE_64BIT_MASK(0, (EBITS) - (SHIFT)) | ||
89 | + | ||
90 | +DO_2SHIFT_INSERT(vsrib, 1, DO_SHR, SHR_MASK) | ||
91 | +DO_2SHIFT_INSERT(vsrih, 2, DO_SHR, SHR_MASK) | ||
92 | +DO_2SHIFT_INSERT(vsriw, 4, DO_SHR, SHR_MASK) | ||
93 | +DO_2SHIFT_INSERT(vslib, 1, DO_SHL, SHL_MASK) | ||
94 | +DO_2SHIFT_INSERT(vslih, 2, DO_SHL, SHL_MASK) | ||
95 | +DO_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK) | ||
96 | + | ||
97 | /* | ||
98 | * Long shifts taking half-sized inputs from top or bottom of the input | ||
99 | * vector and producing a double-width result. ESIZE, TYPE are for | ||
100 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/target/arm/translate-mve.c | ||
103 | +++ b/target/arm/translate-mve.c | ||
104 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
105 | DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
106 | DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
107 | |||
108 | +DO_2SHIFT(VSRI, vsri, false) | ||
109 | +DO_2SHIFT(VSLI, vsli, false) | ||
110 | + | ||
111 | #define DO_VSHLL(INSN, FN) \ | ||
112 | static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
113 | { \ | ||
114 | -- | 62 | -- |
115 | 2.20.1 | 63 | 2.34.1 |
116 | 64 | ||
117 | 65 | diff view generated by jsdifflib |
1 | The function asimd_imm_const() in translate-neon.c is an | 1 | Currently the sbsa_gdwt watchdog device hardcodes its frequency at |
---|---|---|---|
2 | implementation of the pseudocode AdvSIMDExpandImm(), which we will | 2 | 62.5MHz. In real hardware, this watchdog is supposed to be driven |
3 | also want for MVE. Move the implementation to translate.c, with a | 3 | from the system counter, which also drives the CPU generic timers. |
4 | prototype in translate.h. | 4 | Newer CPU types (in particular from Armv8.6) should have a CPU |
5 | generic timer frequency of 1GHz, so we can't leave the watchdog | ||
6 | on the old QEMU default of 62.5GHz. | ||
7 | |||
8 | Make the frequency a QOM property so it can be set by the board, | ||
9 | and have our only board that uses this device set that frequency | ||
10 | to the same value it sets the CPU frequency. | ||
5 | 11 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Message-id: 20210628135835.6690-4-peter.maydell@linaro.org | 14 | Message-id: 20240426122913.3427983-4-peter.maydell@linaro.org |
9 | --- | 15 | --- |
10 | target/arm/translate.h | 16 ++++++++++ | 16 | include/hw/watchdog/sbsa_gwdt.h | 3 +-- |
11 | target/arm/translate-neon.c | 63 ------------------------------------- | 17 | hw/arm/sbsa-ref.c | 1 + |
12 | target/arm/translate.c | 57 +++++++++++++++++++++++++++++++++ | 18 | hw/watchdog/sbsa_gwdt.c | 15 ++++++++++++++- |
13 | 3 files changed, 73 insertions(+), 63 deletions(-) | 19 | 3 files changed, 16 insertions(+), 3 deletions(-) |
14 | 20 | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 21 | diff --git a/include/hw/watchdog/sbsa_gwdt.h b/include/hw/watchdog/sbsa_gwdt.h |
16 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 23 | --- a/include/hw/watchdog/sbsa_gwdt.h |
18 | +++ b/target/arm/translate.h | 24 | +++ b/include/hw/watchdog/sbsa_gwdt.h |
19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) | 25 | @@ -XXX,XX +XXX,XX @@ |
20 | return opc | s->be_data; | 26 | #define SBSA_GWDT_RMMIO_SIZE 0x1000 |
27 | #define SBSA_GWDT_CMMIO_SIZE 0x1000 | ||
28 | |||
29 | -#define SBSA_TIMER_FREQ 62500000 /* Hz */ | ||
30 | - | ||
31 | typedef struct SBSA_GWDTState { | ||
32 | /* <private> */ | ||
33 | SysBusDevice parent_obj; | ||
34 | @@ -XXX,XX +XXX,XX @@ typedef struct SBSA_GWDTState { | ||
35 | qemu_irq irq; | ||
36 | |||
37 | QEMUTimer *timer; | ||
38 | + uint64_t freq; | ||
39 | |||
40 | uint32_t id; | ||
41 | uint32_t wcs; | ||
42 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/hw/arm/sbsa-ref.c | ||
45 | +++ b/hw/arm/sbsa-ref.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static void create_wdt(const SBSAMachineState *sms) | ||
47 | SysBusDevice *s = SYS_BUS_DEVICE(dev); | ||
48 | int irq = sbsa_ref_irqmap[SBSA_GWDT_WS0]; | ||
49 | |||
50 | + qdev_prop_set_uint64(dev, "clock-frequency", SBSA_GTIMER_HZ); | ||
51 | sysbus_realize_and_unref(s, &error_fatal); | ||
52 | sysbus_mmio_map(s, 0, rbase); | ||
53 | sysbus_mmio_map(s, 1, cbase); | ||
54 | diff --git a/hw/watchdog/sbsa_gwdt.c b/hw/watchdog/sbsa_gwdt.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/watchdog/sbsa_gwdt.c | ||
57 | +++ b/hw/watchdog/sbsa_gwdt.c | ||
58 | @@ -XXX,XX +XXX,XX @@ | ||
59 | #include "qemu/osdep.h" | ||
60 | #include "sysemu/reset.h" | ||
61 | #include "sysemu/watchdog.h" | ||
62 | +#include "hw/qdev-properties.h" | ||
63 | #include "hw/watchdog/sbsa_gwdt.h" | ||
64 | #include "qemu/timer.h" | ||
65 | #include "migration/vmstate.h" | ||
66 | @@ -XXX,XX +XXX,XX @@ static void sbsa_gwdt_update_timer(SBSA_GWDTState *s, WdtRefreshType rtype) | ||
67 | timeout = s->woru; | ||
68 | timeout <<= 32; | ||
69 | timeout |= s->worl; | ||
70 | - timeout = muldiv64(timeout, NANOSECONDS_PER_SECOND, SBSA_TIMER_FREQ); | ||
71 | + timeout = muldiv64(timeout, NANOSECONDS_PER_SECOND, s->freq); | ||
72 | timeout += qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
73 | |||
74 | if ((rtype == EXPLICIT_REFRESH) || ((rtype == TIMEOUT_REFRESH) && | ||
75 | @@ -XXX,XX +XXX,XX @@ static void wdt_sbsa_gwdt_realize(DeviceState *dev, Error **errp) | ||
76 | dev); | ||
21 | } | 77 | } |
22 | 78 | ||
23 | +/** | 79 | +static Property wdt_sbsa_gwdt_props[] = { |
24 | + * asimd_imm_const: Expand an encoded SIMD constant value | 80 | + /* |
25 | + * | 81 | + * Timer frequency in Hz. This must match the frequency used by |
26 | + * Expand a SIMD constant value. This is essentially the pseudocode | 82 | + * the CPU's generic timer. Default 62.5Hz matches QEMU's legacy |
27 | + * AdvSIMDExpandImm, except that we also perform the boolean NOT needed for | 83 | + * CPU timer frequency default. |
28 | + * VMVN and VBIC (when cmode < 14 && op == 1). | 84 | + */ |
29 | + * | 85 | + DEFINE_PROP_UINT64("clock-frequency", struct SBSA_GWDTState, freq, |
30 | + * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; | 86 | + 62500000), |
31 | + * callers must catch this. | 87 | + DEFINE_PROP_END_OF_LIST(), |
32 | + * | 88 | +}; |
33 | + * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but | ||
34 | + * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; | ||
35 | + * we produce an immediate constant value of 0 in these cases. | ||
36 | + */ | ||
37 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op); | ||
38 | + | 89 | + |
39 | #endif /* TARGET_ARM_TRANSLATE_H */ | 90 | static void wdt_sbsa_gwdt_class_init(ObjectClass *klass, void *data) |
40 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/translate-neon.c | ||
43 | +++ b/target/arm/translate-neon.c | ||
44 | @@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_UH, gen_helper_gvec_vcvt_uh) | ||
45 | DO_FP_2SH(VCVT_HS, gen_helper_gvec_vcvt_hs) | ||
46 | DO_FP_2SH(VCVT_HU, gen_helper_gvec_vcvt_hu) | ||
47 | |||
48 | -static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | ||
49 | -{ | ||
50 | - /* | ||
51 | - * Expand the encoded constant. | ||
52 | - * Note that cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. | ||
53 | - * We choose to not special-case this and will behave as if a | ||
54 | - * valid constant encoding of 0 had been given. | ||
55 | - * cmode = 15 op = 1 must UNDEF; we assume decode has handled that. | ||
56 | - */ | ||
57 | - switch (cmode) { | ||
58 | - case 0: case 1: | ||
59 | - /* no-op */ | ||
60 | - break; | ||
61 | - case 2: case 3: | ||
62 | - imm <<= 8; | ||
63 | - break; | ||
64 | - case 4: case 5: | ||
65 | - imm <<= 16; | ||
66 | - break; | ||
67 | - case 6: case 7: | ||
68 | - imm <<= 24; | ||
69 | - break; | ||
70 | - case 8: case 9: | ||
71 | - imm |= imm << 16; | ||
72 | - break; | ||
73 | - case 10: case 11: | ||
74 | - imm = (imm << 8) | (imm << 24); | ||
75 | - break; | ||
76 | - case 12: | ||
77 | - imm = (imm << 8) | 0xff; | ||
78 | - break; | ||
79 | - case 13: | ||
80 | - imm = (imm << 16) | 0xffff; | ||
81 | - break; | ||
82 | - case 14: | ||
83 | - if (op) { | ||
84 | - /* | ||
85 | - * This is the only case where the top and bottom 32 bits | ||
86 | - * of the encoded constant differ. | ||
87 | - */ | ||
88 | - uint64_t imm64 = 0; | ||
89 | - int n; | ||
90 | - | ||
91 | - for (n = 0; n < 8; n++) { | ||
92 | - if (imm & (1 << n)) { | ||
93 | - imm64 |= (0xffULL << (n * 8)); | ||
94 | - } | ||
95 | - } | ||
96 | - return imm64; | ||
97 | - } | ||
98 | - imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
99 | - break; | ||
100 | - case 15: | ||
101 | - imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
102 | - | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
103 | - break; | ||
104 | - } | ||
105 | - if (op) { | ||
106 | - imm = ~imm; | ||
107 | - } | ||
108 | - return dup_const(MO_32, imm); | ||
109 | -} | ||
110 | - | ||
111 | static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a, | ||
112 | GVecGen2iFn *fn) | ||
113 | { | 91 | { |
114 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 92 | DeviceClass *dc = DEVICE_CLASS(klass); |
115 | index XXXXXXX..XXXXXXX 100644 | 93 | @@ -XXX,XX +XXX,XX @@ static void wdt_sbsa_gwdt_class_init(ObjectClass *klass, void *data) |
116 | --- a/target/arm/translate.c | 94 | set_bit(DEVICE_CATEGORY_WATCHDOG, dc->categories); |
117 | +++ b/target/arm/translate.c | 95 | dc->vmsd = &vmstate_sbsa_gwdt; |
118 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void) | 96 | dc->desc = "SBSA-compliant generic watchdog device"; |
119 | a64_translate_init(); | 97 | + device_class_set_props(dc, wdt_sbsa_gwdt_props); |
120 | } | 98 | } |
121 | 99 | ||
122 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | 100 | static const TypeInfo wdt_sbsa_gwdt_info = { |
123 | +{ | ||
124 | + /* Expand the encoded constant as per AdvSIMDExpandImm pseudocode */ | ||
125 | + switch (cmode) { | ||
126 | + case 0: case 1: | ||
127 | + /* no-op */ | ||
128 | + break; | ||
129 | + case 2: case 3: | ||
130 | + imm <<= 8; | ||
131 | + break; | ||
132 | + case 4: case 5: | ||
133 | + imm <<= 16; | ||
134 | + break; | ||
135 | + case 6: case 7: | ||
136 | + imm <<= 24; | ||
137 | + break; | ||
138 | + case 8: case 9: | ||
139 | + imm |= imm << 16; | ||
140 | + break; | ||
141 | + case 10: case 11: | ||
142 | + imm = (imm << 8) | (imm << 24); | ||
143 | + break; | ||
144 | + case 12: | ||
145 | + imm = (imm << 8) | 0xff; | ||
146 | + break; | ||
147 | + case 13: | ||
148 | + imm = (imm << 16) | 0xffff; | ||
149 | + break; | ||
150 | + case 14: | ||
151 | + if (op) { | ||
152 | + /* | ||
153 | + * This is the only case where the top and bottom 32 bits | ||
154 | + * of the encoded constant differ. | ||
155 | + */ | ||
156 | + uint64_t imm64 = 0; | ||
157 | + int n; | ||
158 | + | ||
159 | + for (n = 0; n < 8; n++) { | ||
160 | + if (imm & (1 << n)) { | ||
161 | + imm64 |= (0xffULL << (n * 8)); | ||
162 | + } | ||
163 | + } | ||
164 | + return imm64; | ||
165 | + } | ||
166 | + imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
167 | + break; | ||
168 | + case 15: | ||
169 | + imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
170 | + | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
171 | + break; | ||
172 | + } | ||
173 | + if (op) { | ||
174 | + imm = ~imm; | ||
175 | + } | ||
176 | + return dup_const(MO_32, imm); | ||
177 | +} | ||
178 | + | ||
179 | /* Generate a label used for skipping this instruction */ | ||
180 | void arm_gen_condlabel(DisasContext *s) | ||
181 | { | ||
182 | -- | 101 | -- |
183 | 2.20.1 | 102 | 2.34.1 |
184 | 103 | ||
185 | 104 | diff view generated by jsdifflib |
1 | The A64 AdvSIMD modified-immediate grouping uses almost the same | 1 | In previous versions of the Arm architecture, the frequency of the |
---|---|---|---|
2 | constant encoding that A32 Neon does; reuse asimd_imm_const() (to | 2 | generic timers as reported in CNTFRQ_EL0 could be any IMPDEF value, |
3 | which we add the AArch64-specific case for cmode 15 op 1) instead of | 3 | and for QEMU we picked 62.5MHz, giving a timer tick period of 16ns. |
4 | reimplementing it all. | 4 | In Armv8.6, the architecture standardized this frequency to 1GHz. |
5 | |||
6 | Because there is no ID register feature field that indicates whether | ||
7 | a CPU is v8.6 or that it ought to have this counter frequency, we | ||
8 | implement this by changing our default CNTFRQ value for all CPUs, | ||
9 | with exceptions for backwards compatibility: | ||
10 | |||
11 | * CPU types which we already implement will retain the old | ||
12 | default value. None of these are v8.6 CPUs, so this is | ||
13 | architecturally OK. | ||
14 | * CPUs used in versioned machine types with a version of 9.0 | ||
15 | or earlier will retain the old default value. | ||
16 | |||
17 | The upshot is that the only CPU type that changes is 'max'; but any | ||
18 | new type we add in future (whether v8.6 or not) will also get the new | ||
19 | 1GHz default. | ||
20 | |||
21 | It remains the case that the machine model can override the default | ||
22 | value via the 'cntfrq' QOM property (regardless of the CPU type). | ||
5 | 23 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210628135835.6690-5-peter.maydell@linaro.org | 26 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
27 | Message-id: 20240426122913.3427983-5-peter.maydell@linaro.org | ||
9 | --- | 28 | --- |
10 | target/arm/translate.h | 3 +- | 29 | target/arm/cpu.h | 11 +++++++++++ |
11 | target/arm/translate-a64.c | 86 ++++---------------------------------- | 30 | target/arm/internals.h | 12 ++++++++++-- |
12 | target/arm/translate.c | 17 +++++++- | 31 | hw/core/machine.c | 4 +++- |
13 | 3 files changed, 24 insertions(+), 82 deletions(-) | 32 | target/arm/cpu.c | 23 +++++++++++++++++------ |
14 | 33 | target/arm/cpu64.c | 2 ++ | |
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 34 | target/arm/tcg/cpu32.c | 4 ++++ |
16 | index XXXXXXX..XXXXXXX 100644 | 35 | target/arm/tcg/cpu64.c | 18 ++++++++++++++++++ |
17 | --- a/target/arm/translate.h | 36 | 7 files changed, 65 insertions(+), 9 deletions(-) |
18 | +++ b/target/arm/translate.h | 37 | |
19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) | 38 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
20 | * VMVN and VBIC (when cmode < 14 && op == 1). | 39 | index XXXXXXX..XXXXXXX 100644 |
21 | * | 40 | --- a/target/arm/cpu.h |
22 | * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; | 41 | +++ b/target/arm/cpu.h |
23 | - * callers must catch this. | 42 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
24 | + * callers must catch this; we return the 64-bit constant value defined | 43 | */ |
25 | + * for AArch64. | 44 | bool host_cpu_probe_failed; |
26 | * | 45 | |
27 | * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but | 46 | + /* QOM property to indicate we should use the back-compat CNTFRQ default */ |
28 | * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; | 47 | + bool backcompat_cntfrq; |
29 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 48 | + |
30 | index XXXXXXX..XXXXXXX 100644 | 49 | /* Specify the number of cores in this CPU cluster. Used for the L2CTLR |
31 | --- a/target/arm/translate-a64.c | 50 | * register. |
32 | +++ b/target/arm/translate-a64.c | 51 | */ |
33 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) | 52 | @@ -XXX,XX +XXX,XX @@ enum arm_features { |
34 | { | 53 | ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ |
35 | int rd = extract32(insn, 0, 5); | 54 | ARM_FEATURE_M_MAIN, /* M profile Main Extension */ |
36 | int cmode = extract32(insn, 12, 4); | 55 | ARM_FEATURE_V8_1M, /* M profile extras only in v8.1M and later */ |
37 | - int cmode_3_1 = extract32(cmode, 1, 3); | 56 | + /* |
38 | - int cmode_0 = extract32(cmode, 0, 1); | 57 | + * ARM_FEATURE_BACKCOMPAT_CNTFRQ makes the CPU default cntfrq be 62.5MHz |
39 | int o2 = extract32(insn, 11, 1); | 58 | + * if the board doesn't set a value, instead of 1GHz. It is for backwards |
40 | uint64_t abcdefgh = extract32(insn, 5, 5) | (extract32(insn, 16, 3) << 5); | 59 | + * compatibility and used only with CPU definitions that were already |
41 | bool is_neg = extract32(insn, 29, 1); | 60 | + * in QEMU before we changed the default. It should not be set on any |
42 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) | 61 | + * CPU types added in future. |
43 | return; | 62 | + */ |
63 | + ARM_FEATURE_BACKCOMPAT_CNTFRQ, /* 62.5MHz timer default */ | ||
64 | }; | ||
65 | |||
66 | static inline int arm_feature(CPUARMState *env, int feature) | ||
67 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/target/arm/internals.h | ||
70 | +++ b/target/arm/internals.h | ||
71 | @@ -XXX,XX +XXX,XX @@ static inline bool excp_is_internal(int excp) | ||
72 | |||
73 | /* | ||
74 | * Default frequency for the generic timer, in Hz. | ||
75 | - * This is 62.5MHz, which gives a 16 ns tick period. | ||
76 | + * ARMv8.6 and later CPUs architecturally must use a 1GHz timer; before | ||
77 | + * that it was an IMPDEF choice, and QEMU initially picked 62.5MHz, | ||
78 | + * which gives a 16ns tick period. | ||
79 | + * | ||
80 | + * We will use the back-compat value: | ||
81 | + * - for QEMU CPU types added before we standardized on 1GHz | ||
82 | + * - for versioned machine types with a version of 9.0 or earlier | ||
83 | + * In any case, the machine model may override via the cntfrq property. | ||
84 | */ | ||
85 | -#define GTIMER_DEFAULT_HZ 62500000 | ||
86 | +#define GTIMER_DEFAULT_HZ 1000000000 | ||
87 | +#define GTIMER_BACKCOMPAT_HZ 62500000 | ||
88 | |||
89 | /* Bit definitions for the v7M CONTROL register */ | ||
90 | FIELD(V7M_CONTROL, NPRIV, 0, 1) | ||
91 | diff --git a/hw/core/machine.c b/hw/core/machine.c | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/hw/core/machine.c | ||
94 | +++ b/hw/core/machine.c | ||
95 | @@ -XXX,XX +XXX,XX @@ | ||
96 | #include "hw/virtio/virtio-iommu.h" | ||
97 | #include "audio/audio.h" | ||
98 | |||
99 | -GlobalProperty hw_compat_9_0[] = {}; | ||
100 | +GlobalProperty hw_compat_9_0[] = { | ||
101 | + {"arm-cpu", "backcompat-cntfrq", "true" }, | ||
102 | +}; | ||
103 | const size_t hw_compat_9_0_len = G_N_ELEMENTS(hw_compat_9_0); | ||
104 | |||
105 | GlobalProperty hw_compat_8_2[] = { | ||
106 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/cpu.c | ||
109 | +++ b/target/arm/cpu.c | ||
110 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
111 | |||
112 | if (!cpu->gt_cntfrq_hz) { | ||
113 | /* | ||
114 | - * 0 means "the board didn't set a value, use the default". | ||
115 | - * The default value of the generic timer frequency (as seen in | ||
116 | - * CNTFRQ_EL0) is 62.5MHz, which corresponds to a period of 16ns. | ||
117 | - * This is what you get (a) for a CONFIG_USER_ONLY CPU (b) if the | ||
118 | - * board doesn't set it. | ||
119 | + * 0 means "the board didn't set a value, use the default". (We also | ||
120 | + * get here for the CONFIG_USER_ONLY case.) | ||
121 | + * ARMv8.6 and later CPUs architecturally must use a 1GHz timer; before | ||
122 | + * that it was an IMPDEF choice, and QEMU initially picked 62.5MHz, | ||
123 | + * which gives a 16ns tick period. | ||
124 | + * | ||
125 | + * We will use the back-compat value: | ||
126 | + * - for QEMU CPU types added before we standardized on 1GHz | ||
127 | + * - for versioned machine types with a version of 9.0 or earlier | ||
128 | */ | ||
129 | - cpu->gt_cntfrq_hz = GTIMER_DEFAULT_HZ; | ||
130 | + if (arm_feature(env, ARM_FEATURE_BACKCOMPAT_CNTFRQ) || | ||
131 | + cpu->backcompat_cntfrq) { | ||
132 | + cpu->gt_cntfrq_hz = GTIMER_BACKCOMPAT_HZ; | ||
133 | + } else { | ||
134 | + cpu->gt_cntfrq_hz = GTIMER_DEFAULT_HZ; | ||
135 | + } | ||
44 | } | 136 | } |
45 | 137 | ||
46 | - /* See AdvSIMDExpandImm() in ARM ARM */ | 138 | #ifndef CONFIG_USER_ONLY |
47 | - switch (cmode_3_1) { | 139 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_properties[] = { |
48 | - case 0: /* Replicate(Zeros(24):imm8, 2) */ | 140 | mp_affinity, ARM64_AFFINITY_INVALID), |
49 | - case 1: /* Replicate(Zeros(16):imm8:Zeros(8), 2) */ | 141 | DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID), |
50 | - case 2: /* Replicate(Zeros(8):imm8:Zeros(16), 2) */ | 142 | DEFINE_PROP_INT32("core-count", ARMCPU, core_count, -1), |
51 | - case 3: /* Replicate(imm8:Zeros(24), 2) */ | 143 | + /* True to default to the backward-compat old CNTFRQ rather than 1Ghz */ |
52 | - { | 144 | + DEFINE_PROP_BOOL("backcompat-cntfrq", ARMCPU, backcompat_cntfrq, false), |
53 | - int shift = cmode_3_1 * 8; | 145 | DEFINE_PROP_END_OF_LIST() |
54 | - imm = bitfield_replicate(abcdefgh << shift, 32); | 146 | }; |
55 | - break; | 147 | |
56 | - } | 148 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
57 | - case 4: /* Replicate(Zeros(8):imm8, 4) */ | 149 | index XXXXXXX..XXXXXXX 100644 |
58 | - case 5: /* Replicate(imm8:Zeros(8), 4) */ | 150 | --- a/target/arm/cpu64.c |
59 | - { | 151 | +++ b/target/arm/cpu64.c |
60 | - int shift = (cmode_3_1 & 0x1) * 8; | 152 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) |
61 | - imm = bitfield_replicate(abcdefgh << shift, 16); | 153 | set_feature(&cpu->env, ARM_FEATURE_V8); |
62 | - break; | 154 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
63 | - } | 155 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
64 | - case 6: | 156 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
65 | - if (cmode_0) { | 157 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); |
66 | - /* Replicate(Zeros(8):imm8:Ones(16), 2) */ | 158 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
67 | - imm = (abcdefgh << 16) | 0xffff; | 159 | set_feature(&cpu->env, ARM_FEATURE_EL2); |
68 | - } else { | 160 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) |
69 | - /* Replicate(Zeros(16):imm8:Ones(8), 2) */ | 161 | set_feature(&cpu->env, ARM_FEATURE_V8); |
70 | - imm = (abcdefgh << 8) | 0xff; | 162 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
71 | - } | 163 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
72 | - imm = bitfield_replicate(imm, 32); | 164 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
73 | - break; | 165 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); |
74 | - case 7: | 166 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
75 | - if (!cmode_0 && !is_neg) { | 167 | set_feature(&cpu->env, ARM_FEATURE_EL2); |
76 | - imm = bitfield_replicate(abcdefgh, 8); | 168 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c |
77 | - } else if (!cmode_0 && is_neg) { | 169 | index XXXXXXX..XXXXXXX 100644 |
78 | - int i; | 170 | --- a/target/arm/tcg/cpu32.c |
79 | - imm = 0; | 171 | +++ b/target/arm/tcg/cpu32.c |
80 | - for (i = 0; i < 8; i++) { | 172 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) |
81 | - if ((abcdefgh) & (1 << i)) { | 173 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
82 | - imm |= 0xffULL << (i * 8); | 174 | set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); |
83 | - } | 175 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
84 | - } | 176 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
85 | - } else if (cmode_0) { | 177 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); |
86 | - if (is_neg) { | 178 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
87 | - imm = (abcdefgh & 0x3f) << 48; | 179 | set_feature(&cpu->env, ARM_FEATURE_EL2); |
88 | - if (abcdefgh & 0x80) { | 180 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) |
89 | - imm |= 0x8000000000000000ULL; | 181 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
90 | - } | 182 | set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); |
91 | - if (abcdefgh & 0x40) { | 183 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
92 | - imm |= 0x3fc0000000000000ULL; | 184 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
93 | - } else { | 185 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); |
94 | - imm |= 0x4000000000000000ULL; | 186 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
95 | - } | 187 | set_feature(&cpu->env, ARM_FEATURE_EL2); |
96 | - } else { | 188 | @@ -XXX,XX +XXX,XX @@ static void cortex_r52_initfn(Object *obj) |
97 | - if (o2) { | 189 | set_feature(&cpu->env, ARM_FEATURE_PMSA); |
98 | - /* FMOV (vector, immediate) - half-precision */ | 190 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
99 | - imm = vfp_expand_imm(MO_16, abcdefgh); | 191 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
100 | - /* now duplicate across the lanes */ | 192 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
101 | - imm = bitfield_replicate(imm, 16); | 193 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
102 | - } else { | 194 | set_feature(&cpu->env, ARM_FEATURE_AUXCR); |
103 | - imm = (abcdefgh & 0x3f) << 19; | 195 | cpu->midr = 0x411fd133; /* r1p3 */ |
104 | - if (abcdefgh & 0x80) { | 196 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) |
105 | - imm |= 0x80000000; | 197 | set_feature(&cpu->env, ARM_FEATURE_V8); |
106 | - } | 198 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
107 | - if (abcdefgh & 0x40) { | 199 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
108 | - imm |= 0x3e000000; | 200 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
109 | - } else { | 201 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
110 | - imm |= 0x40000000; | 202 | set_feature(&cpu->env, ARM_FEATURE_EL2); |
111 | - } | 203 | set_feature(&cpu->env, ARM_FEATURE_EL3); |
112 | - imm |= (imm << 32); | 204 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
113 | - } | 205 | index XXXXXXX..XXXXXXX 100644 |
114 | - } | 206 | --- a/target/arm/tcg/cpu64.c |
115 | - } | 207 | +++ b/target/arm/tcg/cpu64.c |
116 | - break; | 208 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a35_initfn(Object *obj) |
117 | - default: | 209 | set_feature(&cpu->env, ARM_FEATURE_V8); |
118 | - g_assert_not_reached(); | 210 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
119 | - } | 211 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
120 | - | 212 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
121 | - if (cmode_3_1 != 7 && is_neg) { | 213 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); |
122 | - imm = ~imm; | 214 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
123 | + if (cmode == 15 && o2 && !is_neg) { | 215 | set_feature(&cpu->env, ARM_FEATURE_EL2); |
124 | + /* FMOV (vector, immediate) - half-precision */ | 216 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a55_initfn(Object *obj) |
125 | + imm = vfp_expand_imm(MO_16, abcdefgh); | 217 | set_feature(&cpu->env, ARM_FEATURE_V8); |
126 | + /* now duplicate across the lanes */ | 218 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
127 | + imm = bitfield_replicate(imm, 16); | 219 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
128 | + } else { | 220 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
129 | + imm = asimd_imm_const(abcdefgh, cmode, is_neg); | 221 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); |
130 | } | 222 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
131 | 223 | set_feature(&cpu->env, ARM_FEATURE_EL2); | |
132 | if (!((cmode & 0x9) == 0x1 || (cmode & 0xd) == 0x9)) { | 224 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) |
133 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 225 | set_feature(&cpu->env, ARM_FEATURE_V8); |
134 | index XXXXXXX..XXXXXXX 100644 | 226 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
135 | --- a/target/arm/translate.c | 227 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
136 | +++ b/target/arm/translate.c | 228 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
137 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | 229 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); |
138 | case 14: | 230 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
139 | if (op) { | 231 | set_feature(&cpu->env, ARM_FEATURE_EL2); |
140 | /* | 232 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a76_initfn(Object *obj) |
141 | - * This is the only case where the top and bottom 32 bits | 233 | set_feature(&cpu->env, ARM_FEATURE_V8); |
142 | - * of the encoded constant differ. | 234 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
143 | + * This and cmode == 15 op == 1 are the only cases where | 235 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
144 | + * the top and bottom 32 bits of the encoded constant differ. | 236 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
145 | */ | 237 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); |
146 | uint64_t imm64 = 0; | 238 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
147 | int n; | 239 | set_feature(&cpu->env, ARM_FEATURE_EL2); |
148 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | 240 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj) |
149 | imm |= (imm << 8) | (imm << 16) | (imm << 24); | 241 | set_feature(&cpu->env, ARM_FEATURE_V8); |
150 | break; | 242 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
151 | case 15: | 243 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
152 | + if (op) { | 244 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
153 | + /* Reserved encoding for AArch32; valid for AArch64 */ | 245 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); |
154 | + uint64_t imm64 = (uint64_t)(imm & 0x3f) << 48; | 246 | set_feature(&cpu->env, ARM_FEATURE_EL2); |
155 | + if (imm & 0x80) { | 247 | set_feature(&cpu->env, ARM_FEATURE_EL3); |
156 | + imm64 |= 0x8000000000000000ULL; | 248 | @@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_n1_initfn(Object *obj) |
157 | + } | 249 | set_feature(&cpu->env, ARM_FEATURE_V8); |
158 | + if (imm & 0x40) { | 250 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
159 | + imm64 |= 0x3fc0000000000000ULL; | 251 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
160 | + } else { | 252 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); |
161 | + imm64 |= 0x4000000000000000ULL; | 253 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); |
162 | + } | 254 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
163 | + return imm64; | 255 | set_feature(&cpu->env, ARM_FEATURE_EL2); |
164 | + } | 256 | @@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_v1_initfn(Object *obj) |
165 | imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | 257 | set_feature(&cpu->env, ARM_FEATURE_V8); |
166 | | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | 258 | set_feature(&cpu->env, ARM_FEATURE_NEON); |
167 | break; | 259 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
260 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); | ||
261 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
262 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
263 | set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
264 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a710_initfn(Object *obj) | ||
265 | set_feature(&cpu->env, ARM_FEATURE_V8); | ||
266 | set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
267 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
268 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); | ||
269 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
270 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
271 | set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
272 | @@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_n2_initfn(Object *obj) | ||
273 | set_feature(&cpu->env, ARM_FEATURE_V8); | ||
274 | set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
275 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
276 | + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); | ||
277 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
278 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
279 | set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
280 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) | ||
281 | uint64_t t; | ||
282 | uint32_t u; | ||
283 | |||
284 | + /* | ||
285 | + * Unset ARM_FEATURE_BACKCOMPAT_CNTFRQ, which we would otherwise default | ||
286 | + * to because we started with aarch64_a57_initfn(). A 'max' CPU might | ||
287 | + * be a v8.6-or-later one, in which case the cntfrq must be 1GHz; and | ||
288 | + * because it is our "may change" CPU type we are OK with it not being | ||
289 | + * backwards-compatible with how it worked in old QEMU. | ||
290 | + */ | ||
291 | + unset_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); | ||
292 | + | ||
293 | /* | ||
294 | * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real | ||
295 | * one and try to apply errata workarounds or use impdef features we | ||
168 | -- | 296 | -- |
169 | 2.20.1 | 297 | 2.34.1 |
170 | 298 | ||
171 | 299 | diff view generated by jsdifflib |
1 | From: Patrick Venture <venture@google.com> | 1 | From: Alexandra Diupina <adiupina@astralinux.ru> |
---|---|---|---|
2 | 2 | ||
3 | Add line item reference to quanta-gbs-bmc machine. | 3 | The DMA descriptor structures for this device have |
4 | a set of "address extension" fields which extend the 32 | ||
5 | bit source addresses with an extra 16 bits to give a | ||
6 | 48 bit address: | ||
7 | https://docs.amd.com/r/en-US/ug1085-zynq-ultrascale-trm/ADDR_EXT-Field | ||
4 | 8 | ||
5 | Signed-off-by: Patrick Venture <venture@google.com> | 9 | However, we misimplemented this address extension in several ways: |
6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 10 | * we only extracted 12 bits of the extension fields, not 16 |
7 | Message-id: 20210615192848.1065297-3-venture@google.com | 11 | * we didn't shift the extension field up far enough |
8 | [PMM: fixed underline Sphinx warning] | 12 | * we accidentally did the shift as 32-bit arithmetic, which |
13 | meant that we would have an overflow instead of setting | ||
14 | bits [47:32] of the resulting 64-bit address | ||
15 | |||
16 | Add a type cast and use extract64() instead of extract32() | ||
17 | to avoid integer overflow on addition. Fix bit fields | ||
18 | extraction according to documentation. | ||
19 | |||
20 | Found by Linux Verification Center (linuxtesting.org) with SVACE. | ||
21 | |||
22 | Cc: qemu-stable@nongnu.org | ||
23 | Fixes: d3c6369a96 ("introduce xlnx-dpdma") | ||
24 | Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru> | ||
25 | Message-id: 20240428181131.23801-1-adiupina@astralinux.ru | ||
26 | [PMM: adjusted commit message] | ||
27 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 29 | --- |
11 | docs/system/arm/nuvoton.rst | 5 +++-- | 30 | hw/dma/xlnx_dpdma.c | 20 ++++++++++---------- |
12 | 1 file changed, 3 insertions(+), 2 deletions(-) | 31 | 1 file changed, 10 insertions(+), 10 deletions(-) |
13 | 32 | ||
14 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst | 33 | diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c |
15 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/docs/system/arm/nuvoton.rst | 35 | --- a/hw/dma/xlnx_dpdma.c |
17 | +++ b/docs/system/arm/nuvoton.rst | 36 | +++ b/hw/dma/xlnx_dpdma.c |
18 | @@ -XXX,XX +XXX,XX @@ | 37 | @@ -XXX,XX +XXX,XX @@ static uint64_t xlnx_dpdma_desc_get_source_address(DPDMADescriptor *desc, |
19 | -Nuvoton iBMC boards (``npcm750-evb``, ``quanta-gsj``) | 38 | |
20 | -===================================================== | 39 | switch (frag) { |
21 | +Nuvoton iBMC boards (``*-bmc``, ``npcm750-evb``, ``quanta-gsj``) | 40 | case 0: |
22 | +================================================================ | 41 | - addr = desc->source_address |
23 | 42 | - + (extract32(desc->address_extension, 16, 12) << 20); | |
24 | The `Nuvoton iBMC`_ chips (NPCM7xx) are a family of ARM-based SoCs that are | 43 | + addr = (uint64_t)desc->source_address |
25 | designed to be used as Baseboard Management Controllers (BMCs) in various | 44 | + + (extract64(desc->address_extension, 16, 16) << 32); |
26 | @@ -XXX,XX +XXX,XX @@ segment. The following machines are based on this chip : | 45 | break; |
27 | The NPCM730 SoC has two Cortex-A9 cores and is targeted for Data Center and | 46 | case 1: |
28 | Hyperscale applications. The following machines are based on this chip : | 47 | - addr = desc->source_address2 |
29 | 48 | - + (extract32(desc->address_extension_23, 0, 12) << 8); | |
30 | +- ``quanta-gbs-bmc`` Quanta GBS server BMC | 49 | + addr = (uint64_t)desc->source_address2 |
31 | - ``quanta-gsj`` Quanta GSJ server BMC | 50 | + + (extract64(desc->address_extension_23, 0, 16) << 32); |
32 | 51 | break; | |
33 | There are also two more SoCs, NPCM710 and NPCM705, which are single-core | 52 | case 2: |
53 | - addr = desc->source_address3 | ||
54 | - + (extract32(desc->address_extension_23, 16, 12) << 20); | ||
55 | + addr = (uint64_t)desc->source_address3 | ||
56 | + + (extract64(desc->address_extension_23, 16, 16) << 32); | ||
57 | break; | ||
58 | case 3: | ||
59 | - addr = desc->source_address4 | ||
60 | - + (extract32(desc->address_extension_45, 0, 12) << 8); | ||
61 | + addr = (uint64_t)desc->source_address4 | ||
62 | + + (extract64(desc->address_extension_45, 0, 16) << 32); | ||
63 | break; | ||
64 | case 4: | ||
65 | - addr = desc->source_address5 | ||
66 | - + (extract32(desc->address_extension_45, 16, 12) << 20); | ||
67 | + addr = (uint64_t)desc->source_address5 | ||
68 | + + (extract64(desc->address_extension_45, 16, 16) << 32); | ||
69 | break; | ||
70 | default: | ||
71 | addr = 0; | ||
34 | -- | 72 | -- |
35 | 2.20.1 | 73 | 2.34.1 |
36 | |||
37 | diff view generated by jsdifflib |
1 | From: Patrick Venture <venture@google.com> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Adds a line-item reference to the supported quanta-q71l-bmc aspeed | 3 | "make check-qtest-aarch64" recently started failing on FreeBSD builds, |
4 | entry. | 4 | and valgrind on Linux also detected that there is something fishy with |
5 | the new stm32l4x5-usart: The code forgot to set the correct class_size | ||
6 | here, so the various class_init functions in this file wrote beyond | ||
7 | the allocated buffer when setting the subc->type field. | ||
5 | 8 | ||
6 | Signed-off-by: Patrick Venture <venture@google.com> | 9 | Fixes: 4fb37aea7e ("hw/char: Implement STM32L4x5 USART skeleton") |
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 10 | Signed-off-by: Thomas Huth <thuth@redhat.com> |
8 | Message-id: 20210615192848.1065297-2-venture@google.com | 11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | Message-id: 20240429075908.36302-1-thuth@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 14 | --- |
11 | docs/system/arm/aspeed.rst | 1 + | 15 | hw/char/stm32l4x5_usart.c | 1 + |
12 | 1 file changed, 1 insertion(+) | 16 | 1 file changed, 1 insertion(+) |
13 | 17 | ||
14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | 18 | diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/docs/system/arm/aspeed.rst | 20 | --- a/hw/char/stm32l4x5_usart.c |
17 | +++ b/docs/system/arm/aspeed.rst | 21 | +++ b/hw/char/stm32l4x5_usart.c |
18 | @@ -XXX,XX +XXX,XX @@ etc. | 22 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo stm32l4x5_usart_types[] = { |
19 | AST2400 SoC based machines : | 23 | .parent = TYPE_SYS_BUS_DEVICE, |
20 | 24 | .instance_size = sizeof(Stm32l4x5UsartBaseState), | |
21 | - ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC | 25 | .instance_init = stm32l4x5_usart_base_init, |
22 | +- ``quanta-q71l-bmc`` OpenBMC Quanta BMC | 26 | + .class_size = sizeof(Stm32l4x5UsartBaseClass), |
23 | 27 | .class_init = stm32l4x5_usart_base_class_init, | |
24 | AST2500 SoC based machines : | 28 | .abstract = true, |
25 | 29 | }, { | |
26 | -- | 30 | -- |
27 | 2.20.1 | 31 | 2.34.1 |
28 | 32 | ||
29 | 33 | diff view generated by jsdifflib |
1 | From: Joe Komlodi <joe.komlodi@xilinx.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | If the CPU is running in default NaN mode (FPCR.DN == 1) and we execute | 3 | Use little endian for derivative OTP fuse key. |
4 | FRSQRTE, FRECPE, or FRECPX with a signaling NaN, parts_silence_nan_frac() will | ||
5 | assert due to fpst->default_nan_mode being set. | ||
6 | 4 | ||
7 | To avoid this, we check to see what NaN mode we're running in before we call | 5 | Cc: qemu-stable@nongnu.org |
8 | floatxx_silence_nan(). | 6 | Fixes: c752bb079b ("hw/nvram: NPCM7xx OTP device model") |
9 | 7 | Suggested-by: Avi Fishman <Avi.Fishman@nuvoton.com> | |
10 | Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com> | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Message-id: 20240422125813.1403-1-philmd@linaro.org |
12 | Message-id: 1624662174-175828-2-git-send-email-joe.komlodi@xilinx.com | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 12 | --- |
16 | target/arm/helper-a64.c | 12 +++++++++--- | 13 | hw/arm/npcm7xx.c | 3 ++- |
17 | target/arm/vfp_helper.c | 24 ++++++++++++++++++------ | 14 | 1 file changed, 2 insertions(+), 1 deletion(-) |
18 | 2 files changed, 27 insertions(+), 9 deletions(-) | ||
19 | 15 | ||
20 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 16 | diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c |
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper-a64.c | 18 | --- a/hw/arm/npcm7xx.c |
23 | +++ b/target/arm/helper-a64.c | 19 | +++ b/hw/arm/npcm7xx.c |
24 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp) | 20 | @@ -XXX,XX +XXX,XX @@ |
25 | float16 nan = a; | 21 | #include "hw/qdev-clock.h" |
26 | if (float16_is_signaling_nan(a, fpst)) { | 22 | #include "hw/qdev-properties.h" |
27 | float_raise(float_flag_invalid, fpst); | 23 | #include "qapi/error.h" |
28 | - nan = float16_silence_nan(a, fpst); | 24 | +#include "qemu/bswap.h" |
29 | + if (!fpst->default_nan_mode) { | 25 | #include "qemu/units.h" |
30 | + nan = float16_silence_nan(a, fpst); | 26 | #include "sysemu/sysemu.h" |
31 | + } | 27 | #include "target/arm/cpu-qom.h" |
32 | } | 28 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_init_fuses(NPCM7xxState *s) |
33 | if (fpst->default_nan_mode) { | 29 | * The initial mask of disabled modules indicates the chip derivative (e.g. |
34 | nan = float16_default_nan(fpst); | 30 | * NPCM750 or NPCM730). |
35 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) | 31 | */ |
36 | float32 nan = a; | 32 | - value = tswap32(nc->disabled_modules); |
37 | if (float32_is_signaling_nan(a, fpst)) { | 33 | + value = cpu_to_le32(nc->disabled_modules); |
38 | float_raise(float_flag_invalid, fpst); | 34 | npcm7xx_otp_array_write(&s->fuse_array, &value, NPCM7XX_FUSE_DERIVATIVE, |
39 | - nan = float32_silence_nan(a, fpst); | 35 | sizeof(value)); |
40 | + if (!fpst->default_nan_mode) { | 36 | } |
41 | + nan = float32_silence_nan(a, fpst); | ||
42 | + } | ||
43 | } | ||
44 | if (fpst->default_nan_mode) { | ||
45 | nan = float32_default_nan(fpst); | ||
46 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) | ||
47 | float64 nan = a; | ||
48 | if (float64_is_signaling_nan(a, fpst)) { | ||
49 | float_raise(float_flag_invalid, fpst); | ||
50 | - nan = float64_silence_nan(a, fpst); | ||
51 | + if (!fpst->default_nan_mode) { | ||
52 | + nan = float64_silence_nan(a, fpst); | ||
53 | + } | ||
54 | } | ||
55 | if (fpst->default_nan_mode) { | ||
56 | nan = float64_default_nan(fpst); | ||
57 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/target/arm/vfp_helper.c | ||
60 | +++ b/target/arm/vfp_helper.c | ||
61 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) | ||
62 | float16 nan = f16; | ||
63 | if (float16_is_signaling_nan(f16, fpst)) { | ||
64 | float_raise(float_flag_invalid, fpst); | ||
65 | - nan = float16_silence_nan(f16, fpst); | ||
66 | + if (!fpst->default_nan_mode) { | ||
67 | + nan = float16_silence_nan(f16, fpst); | ||
68 | + } | ||
69 | } | ||
70 | if (fpst->default_nan_mode) { | ||
71 | nan = float16_default_nan(fpst); | ||
72 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp) | ||
73 | float32 nan = f32; | ||
74 | if (float32_is_signaling_nan(f32, fpst)) { | ||
75 | float_raise(float_flag_invalid, fpst); | ||
76 | - nan = float32_silence_nan(f32, fpst); | ||
77 | + if (!fpst->default_nan_mode) { | ||
78 | + nan = float32_silence_nan(f32, fpst); | ||
79 | + } | ||
80 | } | ||
81 | if (fpst->default_nan_mode) { | ||
82 | nan = float32_default_nan(fpst); | ||
83 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp) | ||
84 | float64 nan = f64; | ||
85 | if (float64_is_signaling_nan(f64, fpst)) { | ||
86 | float_raise(float_flag_invalid, fpst); | ||
87 | - nan = float64_silence_nan(f64, fpst); | ||
88 | + if (!fpst->default_nan_mode) { | ||
89 | + nan = float64_silence_nan(f64, fpst); | ||
90 | + } | ||
91 | } | ||
92 | if (fpst->default_nan_mode) { | ||
93 | nan = float64_default_nan(fpst); | ||
94 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) | ||
95 | float16 nan = f16; | ||
96 | if (float16_is_signaling_nan(f16, s)) { | ||
97 | float_raise(float_flag_invalid, s); | ||
98 | - nan = float16_silence_nan(f16, s); | ||
99 | + if (!s->default_nan_mode) { | ||
100 | + nan = float16_silence_nan(f16, fpstp); | ||
101 | + } | ||
102 | } | ||
103 | if (s->default_nan_mode) { | ||
104 | nan = float16_default_nan(s); | ||
105 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) | ||
106 | float32 nan = f32; | ||
107 | if (float32_is_signaling_nan(f32, s)) { | ||
108 | float_raise(float_flag_invalid, s); | ||
109 | - nan = float32_silence_nan(f32, s); | ||
110 | + if (!s->default_nan_mode) { | ||
111 | + nan = float32_silence_nan(f32, fpstp); | ||
112 | + } | ||
113 | } | ||
114 | if (s->default_nan_mode) { | ||
115 | nan = float32_default_nan(s); | ||
116 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) | ||
117 | float64 nan = f64; | ||
118 | if (float64_is_signaling_nan(f64, s)) { | ||
119 | float_raise(float_flag_invalid, s); | ||
120 | - nan = float64_silence_nan(f64, s); | ||
121 | + if (!s->default_nan_mode) { | ||
122 | + nan = float64_silence_nan(f64, fpstp); | ||
123 | + } | ||
124 | } | ||
125 | if (s->default_nan_mode) { | ||
126 | nan = float64_default_nan(s); | ||
127 | -- | 37 | -- |
128 | 2.20.1 | 38 | 2.34.1 |
129 | 39 | ||
130 | 40 | diff view generated by jsdifflib |
1 | From: Nolan Leake <nolan@sigbus.net> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | This is just enough to make reboot and poweroff work. Works for | 3 | This device implements the IM120417002 colors shield v1.1 for Arduino |
4 | linux, u-boot, and the arm trusted firmware. Not tested, but should | 4 | (which relies on the DM163 8x3-channel led driving logic) and features |
5 | work for plan9, and bare-metal/hobby OSes, since they seem to generally | 5 | a simple display of an 8x8 RGB matrix. The columns of the matrix are |
6 | do what linux does for reset. | 6 | driven by the DM163 and the rows are driven externally. |
7 | 7 | ||
8 | The watchdog timer functionality is not yet implemented. | 8 | Acked-by: Alistair Francis <alistair.francis@wdc.com> |
9 | 9 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> | |
10 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/64 | 10 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
11 | Signed-off-by: Nolan Leake <nolan@sigbus.net> | 11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | Message-id: 20240424200929.240921-2-ines.varhol@telecom-paris.fr |
13 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | [PMM: updated to new reset hold method prototype] |
14 | Message-id: 20210625210209.1870217-1-nolan@sigbus.net | ||
15 | [PMM: tweaked commit title; fixed region size to 0x200; | ||
16 | moved header file to include/] | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 15 | --- |
19 | include/hw/arm/bcm2835_peripherals.h | 3 +- | 16 | docs/system/arm/b-l475e-iot01a.rst | 3 +- |
20 | include/hw/misc/bcm2835_powermgt.h | 29 +++++ | 17 | include/hw/display/dm163.h | 59 +++++ |
21 | hw/arm/bcm2835_peripherals.c | 13 ++- | 18 | hw/display/dm163.c | 349 +++++++++++++++++++++++++++++ |
22 | hw/misc/bcm2835_powermgt.c | 160 +++++++++++++++++++++++++++ | 19 | hw/display/Kconfig | 3 + |
23 | hw/misc/meson.build | 1 + | 20 | hw/display/meson.build | 1 + |
24 | 5 files changed, 204 insertions(+), 2 deletions(-) | 21 | hw/display/trace-events | 14 ++ |
25 | create mode 100644 include/hw/misc/bcm2835_powermgt.h | 22 | 6 files changed, 428 insertions(+), 1 deletion(-) |
26 | create mode 100644 hw/misc/bcm2835_powermgt.c | 23 | create mode 100644 include/hw/display/dm163.h |
24 | create mode 100644 hw/display/dm163.c | ||
27 | 25 | ||
28 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 26 | diff --git a/docs/system/arm/b-l475e-iot01a.rst b/docs/system/arm/b-l475e-iot01a.rst |
29 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/include/hw/arm/bcm2835_peripherals.h | 28 | --- a/docs/system/arm/b-l475e-iot01a.rst |
31 | +++ b/include/hw/arm/bcm2835_peripherals.h | 29 | +++ b/docs/system/arm/b-l475e-iot01a.rst |
32 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ USART, I2C, SPI, CAN and USB OTG, as well as a variety of sensors. |
33 | #include "hw/misc/bcm2835_mphi.h" | 31 | Supported devices |
34 | #include "hw/misc/bcm2835_thermal.h" | 32 | """"""""""""""""" |
35 | #include "hw/misc/bcm2835_cprman.h" | 33 | |
36 | +#include "hw/misc/bcm2835_powermgt.h" | 34 | -Currently B-L475E-IOT01A machine's only supports the following devices: |
37 | #include "hw/sd/sdhci.h" | 35 | +Currently B-L475E-IOT01A machines support the following devices: |
38 | #include "hw/sd/bcm2835_sdhost.h" | 36 | |
39 | #include "hw/gpio/bcm2835_gpio.h" | 37 | - Cortex-M4F based STM32L4x5 SoC |
40 | @@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState { | 38 | - STM32L4x5 EXTI (Extended interrupts and events controller) |
41 | BCM2835MphiState mphi; | 39 | @@ -XXX,XX +XXX,XX @@ Currently B-L475E-IOT01A machine's only supports the following devices: |
42 | UnimplementedDeviceState txp; | 40 | - STM32L4x5 RCC (Reset and clock control) |
43 | UnimplementedDeviceState armtmr; | 41 | - STM32L4x5 GPIOs (General-purpose I/Os) |
44 | - UnimplementedDeviceState powermgt; | 42 | - STM32L4x5 USARTs, UARTs and LPUART (Serial ports) |
45 | + BCM2835PowerMgtState powermgt; | 43 | +- optional 8x8 led display (based on DM163 driver) |
46 | BCM2835CprmanState cprman; | 44 | |
47 | PL011State uart0; | 45 | Missing devices |
48 | BCM2835AuxState aux; | 46 | """"""""""""""" |
49 | diff --git a/include/hw/misc/bcm2835_powermgt.h b/include/hw/misc/bcm2835_powermgt.h | 47 | diff --git a/include/hw/display/dm163.h b/include/hw/display/dm163.h |
50 | new file mode 100644 | 48 | new file mode 100644 |
51 | index XXXXXXX..XXXXXXX | 49 | index XXXXXXX..XXXXXXX |
52 | --- /dev/null | 50 | --- /dev/null |
53 | +++ b/include/hw/misc/bcm2835_powermgt.h | 51 | +++ b/include/hw/display/dm163.h |
54 | @@ -XXX,XX +XXX,XX @@ | 52 | @@ -XXX,XX +XXX,XX @@ |
55 | +/* | 53 | +/* |
56 | + * BCM2835 Power Management emulation | 54 | + * QEMU DM163 8x3-channel constant current led driver |
55 | + * driving columns of associated 8x8 RGB matrix. | ||
57 | + * | 56 | + * |
58 | + * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com> | 57 | + * Copyright (C) 2024 Samuel Tardieu <sam@rfc1149.net> |
59 | + * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net> | 58 | + * Copyright (C) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
59 | + * Copyright (C) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
60 | + * | 60 | + * |
61 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 61 | + * SPDX-License-Identifier: GPL-2.0-or-later |
62 | + * See the COPYING file in the top-level directory. | ||
63 | + */ | 62 | + */ |
64 | + | 63 | + |
65 | +#ifndef BCM2835_POWERMGT_H | 64 | +#ifndef HW_DISPLAY_DM163_H |
66 | +#define BCM2835_POWERMGT_H | 65 | +#define HW_DISPLAY_DM163_H |
67 | + | 66 | + |
68 | +#include "hw/sysbus.h" | ||
69 | +#include "qom/object.h" | 67 | +#include "qom/object.h" |
70 | + | 68 | +#include "hw/qdev-core.h" |
71 | +#define TYPE_BCM2835_POWERMGT "bcm2835-powermgt" | 69 | + |
72 | +OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PowerMgtState, BCM2835_POWERMGT) | 70 | +#define TYPE_DM163 "dm163" |
73 | + | 71 | +OBJECT_DECLARE_SIMPLE_TYPE(DM163State, DM163); |
74 | +struct BCM2835PowerMgtState { | 72 | + |
75 | + SysBusDevice busdev; | 73 | +#define RGB_MATRIX_NUM_ROWS 8 |
76 | + MemoryRegion iomem; | 74 | +#define RGB_MATRIX_NUM_COLS 8 |
77 | + | 75 | +#define DM163_NUM_LEDS (RGB_MATRIX_NUM_COLS * 3) |
78 | + uint32_t rstc; | 76 | +/* The last row is filled with 0 (turned off row) */ |
79 | + uint32_t rsts; | 77 | +#define COLOR_BUFFER_SIZE (RGB_MATRIX_NUM_ROWS + 1) |
80 | + uint32_t wdog; | 78 | + |
81 | +}; | 79 | +typedef struct DM163State { |
82 | + | 80 | + DeviceState parent_obj; |
83 | +#endif | 81 | + |
84 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | 82 | + /* DM163 driver */ |
85 | index XXXXXXX..XXXXXXX 100644 | 83 | + uint64_t bank0_shift_register[3]; |
86 | --- a/hw/arm/bcm2835_peripherals.c | 84 | + uint64_t bank1_shift_register[3]; |
87 | +++ b/hw/arm/bcm2835_peripherals.c | 85 | + uint16_t latched_outputs[DM163_NUM_LEDS]; |
88 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | 86 | + uint16_t outputs[DM163_NUM_LEDS]; |
89 | 87 | + qemu_irq sout; | |
90 | object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr", | 88 | + |
91 | OBJECT(&s->gpu_bus_mr)); | 89 | + uint8_t sin; |
92 | + | 90 | + uint8_t dck; |
93 | + /* Power Management */ | 91 | + uint8_t rst_b; |
94 | + object_initialize_child(obj, "powermgt", &s->powermgt, | 92 | + uint8_t lat_b; |
95 | + TYPE_BCM2835_POWERMGT); | 93 | + uint8_t selbk; |
96 | } | 94 | + uint8_t en_b; |
97 | 95 | + | |
98 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 96 | + /* IM120417002 colors shield */ |
99 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 97 | + uint8_t activated_rows; |
100 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | 98 | + |
101 | INTERRUPT_USB)); | 99 | + /* 8x8 RGB matrix */ |
102 | 100 | + QemuConsole *console; | |
103 | + /* Power Management */ | 101 | + uint8_t redraw; |
104 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->powermgt), errp)) { | 102 | + /* Rows currently being displayed on the matrix. */ |
105 | + return; | 103 | + /* The last row is filled with 0 (turned off row) */ |
106 | + } | 104 | + uint32_t buffer[COLOR_BUFFER_SIZE][RGB_MATRIX_NUM_COLS]; |
107 | + | 105 | + uint8_t last_buffer_idx; |
108 | + memory_region_add_subregion(&s->peri_mr, PM_OFFSET, | 106 | + uint8_t buffer_idx_of_row[RGB_MATRIX_NUM_ROWS]; |
109 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->powermgt), 0)); | 107 | + /* Used to simulate retinal persistence of rows */ |
110 | + | 108 | + uint8_t row_persistence_delay[RGB_MATRIX_NUM_ROWS]; |
111 | create_unimp(s, &s->txp, "bcm2835-txp", TXP_OFFSET, 0x1000); | 109 | +} DM163State; |
112 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | 110 | + |
113 | - create_unimp(s, &s->powermgt, "bcm2835-powermgt", PM_OFFSET, 0x114); | 111 | +#endif /* HW_DISPLAY_DM163_H */ |
114 | create_unimp(s, &s->i2s, "bcm2835-i2s", I2S_OFFSET, 0x100); | 112 | diff --git a/hw/display/dm163.c b/hw/display/dm163.c |
115 | create_unimp(s, &s->smi, "bcm2835-smi", SMI_OFFSET, 0x100); | ||
116 | create_unimp(s, &s->spi[0], "bcm2835-spi0", SPI0_OFFSET, 0x20); | ||
117 | diff --git a/hw/misc/bcm2835_powermgt.c b/hw/misc/bcm2835_powermgt.c | ||
118 | new file mode 100644 | 113 | new file mode 100644 |
119 | index XXXXXXX..XXXXXXX | 114 | index XXXXXXX..XXXXXXX |
120 | --- /dev/null | 115 | --- /dev/null |
121 | +++ b/hw/misc/bcm2835_powermgt.c | 116 | +++ b/hw/display/dm163.c |
122 | @@ -XXX,XX +XXX,XX @@ | 117 | @@ -XXX,XX +XXX,XX @@ |
123 | +/* | 118 | +/* |
124 | + * BCM2835 Power Management emulation | 119 | + * QEMU DM163 8x3-channel constant current led driver |
120 | + * driving columns of associated 8x8 RGB matrix. | ||
125 | + * | 121 | + * |
126 | + * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com> | 122 | + * Copyright (C) 2024 Samuel Tardieu <sam@rfc1149.net> |
127 | + * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net> | 123 | + * Copyright (C) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
124 | + * Copyright (C) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
128 | + * | 125 | + * |
129 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 126 | + * SPDX-License-Identifier: GPL-2.0-or-later |
130 | + * See the COPYING file in the top-level directory. | ||
131 | + */ | 127 | + */ |
132 | + | 128 | + |
129 | +/* | ||
130 | + * The reference used for the DM163 is the following : | ||
131 | + * http://www.siti.com.tw/product/spec/LED/DM163.pdf | ||
132 | + */ | ||
133 | + | ||
133 | +#include "qemu/osdep.h" | 134 | +#include "qemu/osdep.h" |
134 | +#include "qemu/log.h" | 135 | +#include "qapi/error.h" |
135 | +#include "qemu/module.h" | ||
136 | +#include "hw/misc/bcm2835_powermgt.h" | ||
137 | +#include "migration/vmstate.h" | 136 | +#include "migration/vmstate.h" |
138 | +#include "sysemu/runstate.h" | 137 | +#include "hw/irq.h" |
139 | + | 138 | +#include "hw/qdev-properties.h" |
140 | +#define PASSWORD 0x5a000000 | 139 | +#include "hw/display/dm163.h" |
141 | +#define PASSWORD_MASK 0xff000000 | 140 | +#include "ui/console.h" |
142 | + | 141 | +#include "trace.h" |
143 | +#define R_RSTC 0x1c | 142 | + |
144 | +#define V_RSTC_RESET 0x20 | 143 | +#define LED_SQUARE_SIZE 100 |
145 | +#define R_RSTS 0x20 | 144 | +/* Number of frames a row stays visible after being turned off. */ |
146 | +#define V_RSTS_POWEROFF 0x555 /* Linux uses partition 63 to indicate halt. */ | 145 | +#define ROW_PERSISTENCE 3 |
147 | +#define R_WDOG 0x24 | 146 | +#define TURNED_OFF_ROW (COLOR_BUFFER_SIZE - 1) |
148 | + | 147 | + |
149 | +static uint64_t bcm2835_powermgt_read(void *opaque, hwaddr offset, | 148 | +static const VMStateDescription vmstate_dm163 = { |
150 | + unsigned size) | 149 | + .name = TYPE_DM163, |
151 | +{ | ||
152 | + BCM2835PowerMgtState *s = (BCM2835PowerMgtState *)opaque; | ||
153 | + uint32_t res = 0; | ||
154 | + | ||
155 | + switch (offset) { | ||
156 | + case R_RSTC: | ||
157 | + res = s->rstc; | ||
158 | + break; | ||
159 | + case R_RSTS: | ||
160 | + res = s->rsts; | ||
161 | + break; | ||
162 | + case R_WDOG: | ||
163 | + res = s->wdog; | ||
164 | + break; | ||
165 | + | ||
166 | + default: | ||
167 | + qemu_log_mask(LOG_UNIMP, | ||
168 | + "bcm2835_powermgt_read: Unknown offset 0x%08"HWADDR_PRIx | ||
169 | + "\n", offset); | ||
170 | + res = 0; | ||
171 | + break; | ||
172 | + } | ||
173 | + | ||
174 | + return res; | ||
175 | +} | ||
176 | + | ||
177 | +static void bcm2835_powermgt_write(void *opaque, hwaddr offset, | ||
178 | + uint64_t value, unsigned size) | ||
179 | +{ | ||
180 | + BCM2835PowerMgtState *s = (BCM2835PowerMgtState *)opaque; | ||
181 | + | ||
182 | + if ((value & PASSWORD_MASK) != PASSWORD) { | ||
183 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
184 | + "bcm2835_powermgt_write: Bad password 0x%"PRIx64 | ||
185 | + " at offset 0x%08"HWADDR_PRIx"\n", | ||
186 | + value, offset); | ||
187 | + return; | ||
188 | + } | ||
189 | + | ||
190 | + value = value & ~PASSWORD_MASK; | ||
191 | + | ||
192 | + switch (offset) { | ||
193 | + case R_RSTC: | ||
194 | + s->rstc = value; | ||
195 | + if (value & V_RSTC_RESET) { | ||
196 | + if ((s->rsts & 0xfff) == V_RSTS_POWEROFF) { | ||
197 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); | ||
198 | + } else { | ||
199 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
200 | + } | ||
201 | + } | ||
202 | + break; | ||
203 | + case R_RSTS: | ||
204 | + qemu_log_mask(LOG_UNIMP, | ||
205 | + "bcm2835_powermgt_write: RSTS\n"); | ||
206 | + s->rsts = value; | ||
207 | + break; | ||
208 | + case R_WDOG: | ||
209 | + qemu_log_mask(LOG_UNIMP, | ||
210 | + "bcm2835_powermgt_write: WDOG\n"); | ||
211 | + s->wdog = value; | ||
212 | + break; | ||
213 | + | ||
214 | + default: | ||
215 | + qemu_log_mask(LOG_UNIMP, | ||
216 | + "bcm2835_powermgt_write: Unknown offset 0x%08"HWADDR_PRIx | ||
217 | + "\n", offset); | ||
218 | + break; | ||
219 | + } | ||
220 | +} | ||
221 | + | ||
222 | +static const MemoryRegionOps bcm2835_powermgt_ops = { | ||
223 | + .read = bcm2835_powermgt_read, | ||
224 | + .write = bcm2835_powermgt_write, | ||
225 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
226 | + .impl.min_access_size = 4, | ||
227 | + .impl.max_access_size = 4, | ||
228 | +}; | ||
229 | + | ||
230 | +static const VMStateDescription vmstate_bcm2835_powermgt = { | ||
231 | + .name = TYPE_BCM2835_POWERMGT, | ||
232 | + .version_id = 1, | 150 | + .version_id = 1, |
233 | + .minimum_version_id = 1, | 151 | + .minimum_version_id = 1, |
234 | + .fields = (VMStateField[]) { | 152 | + .fields = (const VMStateField[]) { |
235 | + VMSTATE_UINT32(rstc, BCM2835PowerMgtState), | 153 | + VMSTATE_UINT64_ARRAY(bank0_shift_register, DM163State, 3), |
236 | + VMSTATE_UINT32(rsts, BCM2835PowerMgtState), | 154 | + VMSTATE_UINT64_ARRAY(bank1_shift_register, DM163State, 3), |
237 | + VMSTATE_UINT32(wdog, BCM2835PowerMgtState), | 155 | + VMSTATE_UINT16_ARRAY(latched_outputs, DM163State, DM163_NUM_LEDS), |
156 | + VMSTATE_UINT16_ARRAY(outputs, DM163State, DM163_NUM_LEDS), | ||
157 | + VMSTATE_UINT8(dck, DM163State), | ||
158 | + VMSTATE_UINT8(en_b, DM163State), | ||
159 | + VMSTATE_UINT8(lat_b, DM163State), | ||
160 | + VMSTATE_UINT8(rst_b, DM163State), | ||
161 | + VMSTATE_UINT8(selbk, DM163State), | ||
162 | + VMSTATE_UINT8(sin, DM163State), | ||
163 | + VMSTATE_UINT8(activated_rows, DM163State), | ||
164 | + VMSTATE_UINT32_2DARRAY(buffer, DM163State, COLOR_BUFFER_SIZE, | ||
165 | + RGB_MATRIX_NUM_COLS), | ||
166 | + VMSTATE_UINT8(last_buffer_idx, DM163State), | ||
167 | + VMSTATE_UINT8_ARRAY(buffer_idx_of_row, DM163State, RGB_MATRIX_NUM_ROWS), | ||
168 | + VMSTATE_UINT8_ARRAY(row_persistence_delay, DM163State, | ||
169 | + RGB_MATRIX_NUM_ROWS), | ||
238 | + VMSTATE_END_OF_LIST() | 170 | + VMSTATE_END_OF_LIST() |
239 | + } | 171 | + } |
240 | +}; | 172 | +}; |
241 | + | 173 | + |
242 | +static void bcm2835_powermgt_init(Object *obj) | 174 | +static void dm163_reset_hold(Object *obj, ResetType type) |
243 | +{ | 175 | +{ |
244 | + BCM2835PowerMgtState *s = BCM2835_POWERMGT(obj); | 176 | + DM163State *s = DM163(obj); |
245 | + | 177 | + |
246 | + memory_region_init_io(&s->iomem, obj, &bcm2835_powermgt_ops, s, | 178 | + s->sin = 0; |
247 | + TYPE_BCM2835_POWERMGT, 0x200); | 179 | + s->dck = 0; |
248 | + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); | 180 | + s->rst_b = 0; |
249 | +} | 181 | + /* Ensuring the first falling edge of lat_b isn't missed */ |
250 | + | 182 | + s->lat_b = 1; |
251 | +static void bcm2835_powermgt_reset(DeviceState *dev) | 183 | + s->selbk = 0; |
252 | +{ | 184 | + s->en_b = 0; |
253 | + BCM2835PowerMgtState *s = BCM2835_POWERMGT(dev); | 185 | + /* Reset stops the PWM, not the shift and latched registers. */ |
254 | + | 186 | + memset(s->outputs, 0, sizeof(s->outputs)); |
255 | + /* https://elinux.org/BCM2835_registers#PM */ | 187 | + |
256 | + s->rstc = 0x00000102; | 188 | + s->activated_rows = 0; |
257 | + s->rsts = 0x00001000; | 189 | + s->redraw = 0; |
258 | + s->wdog = 0x00000000; | 190 | + trace_dm163_redraw(s->redraw); |
259 | +} | 191 | + for (unsigned i = 0; i < COLOR_BUFFER_SIZE; i++) { |
260 | + | 192 | + memset(s->buffer[i], 0, sizeof(s->buffer[0])); |
261 | +static void bcm2835_powermgt_class_init(ObjectClass *klass, void *data) | 193 | + } |
194 | + s->last_buffer_idx = 0; | ||
195 | + memset(s->buffer_idx_of_row, TURNED_OFF_ROW, sizeof(s->buffer_idx_of_row)); | ||
196 | + memset(s->row_persistence_delay, 0, sizeof(s->row_persistence_delay)); | ||
197 | +} | ||
198 | + | ||
199 | +static void dm163_dck_gpio_handler(void *opaque, int line, int new_state) | ||
200 | +{ | ||
201 | + DM163State *s = opaque; | ||
202 | + | ||
203 | + if (new_state && !s->dck) { | ||
204 | + /* | ||
205 | + * On raising dck, sample selbk to get the bank to use, and | ||
206 | + * sample sin for the bit to enter into the bank shift buffer. | ||
207 | + */ | ||
208 | + uint64_t *sb = | ||
209 | + s->selbk ? s->bank1_shift_register : s->bank0_shift_register; | ||
210 | + /* Output the outgoing bit on sout */ | ||
211 | + const bool sout = (s->selbk ? sb[2] & MAKE_64BIT_MASK(63, 1) : | ||
212 | + sb[2] & MAKE_64BIT_MASK(15, 1)) != 0; | ||
213 | + qemu_set_irq(s->sout, sout); | ||
214 | + /* Enter sin into the shift buffer */ | ||
215 | + sb[2] = (sb[2] << 1) | ((sb[1] >> 63) & 1); | ||
216 | + sb[1] = (sb[1] << 1) | ((sb[0] >> 63) & 1); | ||
217 | + sb[0] = (sb[0] << 1) | s->sin; | ||
218 | + } | ||
219 | + | ||
220 | + s->dck = new_state; | ||
221 | + trace_dm163_dck(new_state); | ||
222 | +} | ||
223 | + | ||
224 | +static void dm163_propagate_outputs(DM163State *s) | ||
225 | +{ | ||
226 | + s->last_buffer_idx = (s->last_buffer_idx + 1) % RGB_MATRIX_NUM_ROWS; | ||
227 | + /* Values are output when reset is high and enable is low. */ | ||
228 | + if (s->rst_b && !s->en_b) { | ||
229 | + memcpy(s->outputs, s->latched_outputs, sizeof(s->outputs)); | ||
230 | + } else { | ||
231 | + memset(s->outputs, 0, sizeof(s->outputs)); | ||
232 | + } | ||
233 | + for (unsigned x = 0; x < RGB_MATRIX_NUM_COLS; x++) { | ||
234 | + /* Grouping the 3 RGB channels in a pixel value */ | ||
235 | + const uint16_t b = extract16(s->outputs[3 * x + 0], 6, 8); | ||
236 | + const uint16_t g = extract16(s->outputs[3 * x + 1], 6, 8); | ||
237 | + const uint16_t r = extract16(s->outputs[3 * x + 2], 6, 8); | ||
238 | + uint32_t rgba = 0; | ||
239 | + | ||
240 | + trace_dm163_channels(3 * x + 2, r); | ||
241 | + trace_dm163_channels(3 * x + 1, g); | ||
242 | + trace_dm163_channels(3 * x + 0, b); | ||
243 | + | ||
244 | + rgba = deposit32(rgba, 0, 8, r); | ||
245 | + rgba = deposit32(rgba, 8, 8, g); | ||
246 | + rgba = deposit32(rgba, 16, 8, b); | ||
247 | + | ||
248 | + /* Led values are sent from the last one to the first one */ | ||
249 | + s->buffer[s->last_buffer_idx][RGB_MATRIX_NUM_COLS - x - 1] = rgba; | ||
250 | + } | ||
251 | + for (unsigned row = 0; row < RGB_MATRIX_NUM_ROWS; row++) { | ||
252 | + if (s->activated_rows & (1 << row)) { | ||
253 | + s->buffer_idx_of_row[row] = s->last_buffer_idx; | ||
254 | + s->redraw |= (1 << row); | ||
255 | + trace_dm163_redraw(s->redraw); | ||
256 | + } | ||
257 | + } | ||
258 | +} | ||
259 | + | ||
260 | +static void dm163_en_b_gpio_handler(void *opaque, int line, int new_state) | ||
261 | +{ | ||
262 | + DM163State *s = opaque; | ||
263 | + | ||
264 | + s->en_b = new_state; | ||
265 | + dm163_propagate_outputs(s); | ||
266 | + trace_dm163_en_b(new_state); | ||
267 | +} | ||
268 | + | ||
269 | +static uint8_t dm163_bank0(const DM163State *s, uint8_t led) | ||
270 | +{ | ||
271 | + /* | ||
272 | + * Bank 0 uses 6 bits per led, so a value may be stored accross | ||
273 | + * two uint64_t entries. | ||
274 | + */ | ||
275 | + const uint8_t low_bit = 6 * led; | ||
276 | + const uint8_t low_word = low_bit / 64; | ||
277 | + const uint8_t high_word = (low_bit + 5) / 64; | ||
278 | + const uint8_t low_shift = low_bit % 64; | ||
279 | + | ||
280 | + if (low_word == high_word) { | ||
281 | + /* Simple case: the value belongs to one entry. */ | ||
282 | + return extract64(s->bank0_shift_register[low_word], low_shift, 6); | ||
283 | + } | ||
284 | + | ||
285 | + const uint8_t nb_bits_in_low_word = 64 - low_shift; | ||
286 | + const uint8_t nb_bits_in_high_word = 6 - nb_bits_in_low_word; | ||
287 | + | ||
288 | + const uint64_t bits_in_low_word = \ | ||
289 | + extract64(s->bank0_shift_register[low_word], low_shift, | ||
290 | + nb_bits_in_low_word); | ||
291 | + const uint64_t bits_in_high_word = \ | ||
292 | + extract64(s->bank0_shift_register[high_word], 0, | ||
293 | + nb_bits_in_high_word); | ||
294 | + uint8_t val = 0; | ||
295 | + | ||
296 | + val = deposit32(val, 0, nb_bits_in_low_word, bits_in_low_word); | ||
297 | + val = deposit32(val, nb_bits_in_low_word, nb_bits_in_high_word, | ||
298 | + bits_in_high_word); | ||
299 | + | ||
300 | + return val; | ||
301 | +} | ||
302 | + | ||
303 | +static uint8_t dm163_bank1(const DM163State *s, uint8_t led) | ||
304 | +{ | ||
305 | + const uint64_t entry = s->bank1_shift_register[led / RGB_MATRIX_NUM_COLS]; | ||
306 | + return extract64(entry, 8 * (led % RGB_MATRIX_NUM_COLS), 8); | ||
307 | +} | ||
308 | + | ||
309 | +static void dm163_lat_b_gpio_handler(void *opaque, int line, int new_state) | ||
310 | +{ | ||
311 | + DM163State *s = opaque; | ||
312 | + | ||
313 | + if (s->lat_b && !new_state) { | ||
314 | + for (int led = 0; led < DM163_NUM_LEDS; led++) { | ||
315 | + s->latched_outputs[led] = dm163_bank0(s, led) * dm163_bank1(s, led); | ||
316 | + } | ||
317 | + dm163_propagate_outputs(s); | ||
318 | + } | ||
319 | + | ||
320 | + s->lat_b = new_state; | ||
321 | + trace_dm163_lat_b(new_state); | ||
322 | +} | ||
323 | + | ||
324 | +static void dm163_rst_b_gpio_handler(void *opaque, int line, int new_state) | ||
325 | +{ | ||
326 | + DM163State *s = opaque; | ||
327 | + | ||
328 | + s->rst_b = new_state; | ||
329 | + dm163_propagate_outputs(s); | ||
330 | + trace_dm163_rst_b(new_state); | ||
331 | +} | ||
332 | + | ||
333 | +static void dm163_selbk_gpio_handler(void *opaque, int line, int new_state) | ||
334 | +{ | ||
335 | + DM163State *s = opaque; | ||
336 | + | ||
337 | + s->selbk = new_state; | ||
338 | + trace_dm163_selbk(new_state); | ||
339 | +} | ||
340 | + | ||
341 | +static void dm163_sin_gpio_handler(void *opaque, int line, int new_state) | ||
342 | +{ | ||
343 | + DM163State *s = opaque; | ||
344 | + | ||
345 | + s->sin = new_state; | ||
346 | + trace_dm163_sin(new_state); | ||
347 | +} | ||
348 | + | ||
349 | +static void dm163_rows_gpio_handler(void *opaque, int line, int new_state) | ||
350 | +{ | ||
351 | + DM163State *s = opaque; | ||
352 | + | ||
353 | + if (new_state) { | ||
354 | + s->activated_rows |= (1 << line); | ||
355 | + s->buffer_idx_of_row[line] = s->last_buffer_idx; | ||
356 | + s->redraw |= (1 << line); | ||
357 | + trace_dm163_redraw(s->redraw); | ||
358 | + } else { | ||
359 | + s->activated_rows &= ~(1 << line); | ||
360 | + s->row_persistence_delay[line] = ROW_PERSISTENCE; | ||
361 | + } | ||
362 | + trace_dm163_activated_rows(s->activated_rows); | ||
363 | +} | ||
364 | + | ||
365 | +static void dm163_invalidate_display(void *opaque) | ||
366 | +{ | ||
367 | + DM163State *s = (DM163State *)opaque; | ||
368 | + s->redraw = 0xFF; | ||
369 | + trace_dm163_redraw(s->redraw); | ||
370 | +} | ||
371 | + | ||
372 | +static void update_row_persistence_delay(DM163State *s, unsigned row) | ||
373 | +{ | ||
374 | + if (s->row_persistence_delay[row]) { | ||
375 | + s->row_persistence_delay[row]--; | ||
376 | + } else { | ||
377 | + /* | ||
378 | + * If the ROW_PERSISTENCE delay is up, | ||
379 | + * the row is turned off. | ||
380 | + */ | ||
381 | + s->buffer_idx_of_row[row] = TURNED_OFF_ROW; | ||
382 | + s->redraw |= (1 << row); | ||
383 | + trace_dm163_redraw(s->redraw); | ||
384 | + } | ||
385 | +} | ||
386 | + | ||
387 | +static uint32_t *update_display_of_row(DM163State *s, uint32_t *dest, | ||
388 | + unsigned row) | ||
389 | +{ | ||
390 | + for (unsigned _ = 0; _ < LED_SQUARE_SIZE; _++) { | ||
391 | + for (int x = 0; x < RGB_MATRIX_NUM_COLS * LED_SQUARE_SIZE; x++) { | ||
392 | + /* UI layer guarantees that there's 32 bits per pixel (Mar 2024) */ | ||
393 | + *dest++ = s->buffer[s->buffer_idx_of_row[row]][x / LED_SQUARE_SIZE]; | ||
394 | + } | ||
395 | + } | ||
396 | + | ||
397 | + dpy_gfx_update(s->console, 0, LED_SQUARE_SIZE * row, | ||
398 | + RGB_MATRIX_NUM_COLS * LED_SQUARE_SIZE, LED_SQUARE_SIZE); | ||
399 | + s->redraw &= ~(1 << row); | ||
400 | + trace_dm163_redraw(s->redraw); | ||
401 | + | ||
402 | + return dest; | ||
403 | +} | ||
404 | + | ||
405 | +static void dm163_update_display(void *opaque) | ||
406 | +{ | ||
407 | + DM163State *s = (DM163State *)opaque; | ||
408 | + DisplaySurface *surface = qemu_console_surface(s->console); | ||
409 | + uint32_t *dest; | ||
410 | + | ||
411 | + dest = surface_data(surface); | ||
412 | + for (unsigned row = 0; row < RGB_MATRIX_NUM_ROWS; row++) { | ||
413 | + update_row_persistence_delay(s, row); | ||
414 | + if (!extract8(s->redraw, row, 1)) { | ||
415 | + dest += LED_SQUARE_SIZE * LED_SQUARE_SIZE * RGB_MATRIX_NUM_COLS; | ||
416 | + continue; | ||
417 | + } | ||
418 | + dest = update_display_of_row(s, dest, row); | ||
419 | + } | ||
420 | +} | ||
421 | + | ||
422 | +static const GraphicHwOps dm163_ops = { | ||
423 | + .invalidate = dm163_invalidate_display, | ||
424 | + .gfx_update = dm163_update_display, | ||
425 | +}; | ||
426 | + | ||
427 | +static void dm163_realize(DeviceState *dev, Error **errp) | ||
428 | +{ | ||
429 | + DM163State *s = DM163(dev); | ||
430 | + | ||
431 | + qdev_init_gpio_in(dev, dm163_rows_gpio_handler, RGB_MATRIX_NUM_ROWS); | ||
432 | + qdev_init_gpio_in(dev, dm163_sin_gpio_handler, 1); | ||
433 | + qdev_init_gpio_in(dev, dm163_dck_gpio_handler, 1); | ||
434 | + qdev_init_gpio_in(dev, dm163_rst_b_gpio_handler, 1); | ||
435 | + qdev_init_gpio_in(dev, dm163_lat_b_gpio_handler, 1); | ||
436 | + qdev_init_gpio_in(dev, dm163_selbk_gpio_handler, 1); | ||
437 | + qdev_init_gpio_in(dev, dm163_en_b_gpio_handler, 1); | ||
438 | + qdev_init_gpio_out_named(dev, &s->sout, "sout", 1); | ||
439 | + | ||
440 | + s->console = graphic_console_init(dev, 0, &dm163_ops, s); | ||
441 | + qemu_console_resize(s->console, RGB_MATRIX_NUM_COLS * LED_SQUARE_SIZE, | ||
442 | + RGB_MATRIX_NUM_ROWS * LED_SQUARE_SIZE); | ||
443 | +} | ||
444 | + | ||
445 | +static void dm163_class_init(ObjectClass *klass, void *data) | ||
262 | +{ | 446 | +{ |
263 | + DeviceClass *dc = DEVICE_CLASS(klass); | 447 | + DeviceClass *dc = DEVICE_CLASS(klass); |
264 | + | 448 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
265 | + dc->reset = bcm2835_powermgt_reset; | 449 | + |
266 | + dc->vmsd = &vmstate_bcm2835_powermgt; | 450 | + dc->desc = "DM163"; |
267 | +} | 451 | + dc->vmsd = &vmstate_dm163; |
268 | + | 452 | + dc->realize = dm163_realize; |
269 | +static TypeInfo bcm2835_powermgt_info = { | 453 | + rc->phases.hold = dm163_reset_hold; |
270 | + .name = TYPE_BCM2835_POWERMGT, | 454 | + set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); |
271 | + .parent = TYPE_SYS_BUS_DEVICE, | 455 | +} |
272 | + .instance_size = sizeof(BCM2835PowerMgtState), | 456 | + |
273 | + .class_init = bcm2835_powermgt_class_init, | 457 | +static const TypeInfo dm163_types[] = { |
274 | + .instance_init = bcm2835_powermgt_init, | 458 | + { |
459 | + .name = TYPE_DM163, | ||
460 | + .parent = TYPE_DEVICE, | ||
461 | + .instance_size = sizeof(DM163State), | ||
462 | + .class_init = dm163_class_init | ||
463 | + } | ||
275 | +}; | 464 | +}; |
276 | + | 465 | + |
277 | +static void bcm2835_powermgt_register_types(void) | 466 | +DEFINE_TYPES(dm163_types) |
278 | +{ | 467 | diff --git a/hw/display/Kconfig b/hw/display/Kconfig |
279 | + type_register_static(&bcm2835_powermgt_info); | ||
280 | +} | ||
281 | + | ||
282 | +type_init(bcm2835_powermgt_register_types) | ||
283 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
284 | index XXXXXXX..XXXXXXX 100644 | 468 | index XXXXXXX..XXXXXXX 100644 |
285 | --- a/hw/misc/meson.build | 469 | --- a/hw/display/Kconfig |
286 | +++ b/hw/misc/meson.build | 470 | +++ b/hw/display/Kconfig |
287 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files( | 471 | @@ -XXX,XX +XXX,XX @@ config XLNX_DISPLAYPORT |
288 | 'bcm2835_rng.c', | 472 | bool |
289 | 'bcm2835_thermal.c', | 473 | # defaults to "N", enabled by specific boards |
290 | 'bcm2835_cprman.c', | 474 | depends on PIXMAN |
291 | + 'bcm2835_powermgt.c', | 475 | + |
292 | )) | 476 | +config DM163 |
293 | softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) | 477 | + bool |
294 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c', 'zynq-xadc.c')) | 478 | diff --git a/hw/display/meson.build b/hw/display/meson.build |
479 | index XXXXXXX..XXXXXXX 100644 | ||
480 | --- a/hw/display/meson.build | ||
481 | +++ b/hw/display/meson.build | ||
482 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_NEXTCUBE', if_true: files('next-fb.c')) | ||
483 | |||
484 | system_ss.add(when: 'CONFIG_VGA', if_true: files('vga.c')) | ||
485 | system_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-dmabuf.c')) | ||
486 | +system_ss.add(when: 'CONFIG_DM163', if_true: files('dm163.c')) | ||
487 | |||
488 | if (config_all_devices.has_key('CONFIG_VGA_CIRRUS') or | ||
489 | config_all_devices.has_key('CONFIG_VGA_PCI') or | ||
490 | diff --git a/hw/display/trace-events b/hw/display/trace-events | ||
491 | index XXXXXXX..XXXXXXX 100644 | ||
492 | --- a/hw/display/trace-events | ||
493 | +++ b/hw/display/trace-events | ||
494 | @@ -XXX,XX +XXX,XX @@ macfb_ctrl_write(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%"PRI | ||
495 | macfb_sense_read(uint32_t value) "video sense: 0x%"PRIx32 | ||
496 | macfb_sense_write(uint32_t value) "video sense: 0x%"PRIx32 | ||
497 | macfb_update_mode(uint32_t width, uint32_t height, uint8_t depth) "setting mode to width %"PRId32 " height %"PRId32 " size %d" | ||
498 | + | ||
499 | +# dm163.c | ||
500 | +dm163_redraw(uint8_t redraw) "0x%02x" | ||
501 | +dm163_dck(unsigned new_state) "dck : %u" | ||
502 | +dm163_en_b(unsigned new_state) "en_b : %u" | ||
503 | +dm163_rst_b(unsigned new_state) "rst_b : %u" | ||
504 | +dm163_lat_b(unsigned new_state) "lat_b : %u" | ||
505 | +dm163_sin(unsigned new_state) "sin : %u" | ||
506 | +dm163_selbk(unsigned new_state) "selbk : %u" | ||
507 | +dm163_activated_rows(int new_state) "Activated rows : 0x%" PRIx32 "" | ||
508 | +dm163_bits_ppi(unsigned dest_width) "dest_width : %u" | ||
509 | +dm163_leds(int led, uint32_t value) "led %d: 0x%x" | ||
510 | +dm163_channels(int channel, uint8_t value) "channel %d: 0x%x" | ||
511 | +dm163_refresh_rate(uint32_t rr) "refresh rate %d" | ||
295 | -- | 512 | -- |
296 | 2.20.1 | 513 | 2.34.1 |
297 | 514 | ||
298 | 515 | diff view generated by jsdifflib |
1 | The initial implementation of the MVE VRMLALDAVH and VRMLSLDAVH | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | insns had some bugs: | ||
3 | * the 32x32 multiply of elements was being done as 32x32->32, | ||
4 | not 32x32->64 | ||
5 | * we were incorrectly maintaining the accumulator in its full | ||
6 | 72-bit form across all 4 beats of the insn; in the pseudocode | ||
7 | it is squashed back into the 64 bits of the RdaHi:RdaLo | ||
8 | registers after each beat | ||
9 | 2 | ||
10 | In particular, fixing the second of these allows us to recast | 3 | Exposing SYSCFG inputs to the SoC is practical in order to wire the SoC |
11 | the implementation to avoid 128-bit arithmetic entirely. | 4 | to the optional DM163 display from the board code (GPIOs outputs need |
5 | to be connected to both SYSCFG inputs and DM163 inputs). | ||
12 | 6 | ||
13 | Since the element size here is always 4, we can also drop the | 7 | STM32L4x5 SYSCFG in-irq interception needed to be changed accordingly. |
14 | parameterization of ESIZE to make the code a little more readable. | ||
15 | 8 | ||
16 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
10 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
12 | Message-id: 20240424200929.240921-3-ines.varhol@telecom-paris.fr | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20210628135835.6690-3-peter.maydell@linaro.org | ||
20 | --- | 14 | --- |
21 | target/arm/mve_helper.c | 38 +++++++++++++++++++++----------------- | 15 | hw/arm/stm32l4x5_soc.c | 6 ++++-- |
22 | 1 file changed, 21 insertions(+), 17 deletions(-) | 16 | tests/qtest/stm32l4x5_gpio-test.c | 13 ++++++++----- |
17 | tests/qtest/stm32l4x5_syscfg-test.c | 17 ++++++++++------- | ||
18 | 3 files changed, 22 insertions(+), 14 deletions(-) | ||
23 | 19 | ||
24 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 20 | diff --git a/hw/arm/stm32l4x5_soc.c b/hw/arm/stm32l4x5_soc.c |
25 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/mve_helper.c | 22 | --- a/hw/arm/stm32l4x5_soc.c |
27 | +++ b/target/arm/mve_helper.c | 23 | +++ b/hw/arm/stm32l4x5_soc.c |
28 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ |
29 | */ | ||
30 | |||
31 | #include "qemu/osdep.h" | ||
32 | -#include "qemu/int128.h" | ||
33 | #include "cpu.h" | ||
34 | #include "internals.h" | ||
35 | #include "vec_internal.h" | ||
36 | @@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=) | ||
37 | DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=) | ||
38 | |||
39 | /* | 25 | /* |
40 | - * Rounding multiply add long dual accumulate high: we must keep | 26 | * STM32L4x5 SoC family |
41 | - * a 72-bit internal accumulator value and return the top 64 bits. | 27 | * |
42 | + * Rounding multiply add long dual accumulate high. In the pseudocode | 28 | - * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
43 | + * this is implemented with a 72-bit internal accumulator value of which | 29 | - * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr> |
44 | + * the top 64 bits are returned. We optimize this to avoid having to | 30 | + * Copyright (c) 2023-2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
45 | + * use 128-bit arithmetic -- we can do this because the 74-bit accumulator | 31 | + * Copyright (c) 2023-2024 Inès Varhol <ines.varhol@telecom-paris.fr> |
46 | + * is squashed back into 64-bits after each beat. | 32 | * |
47 | */ | 33 | * SPDX-License-Identifier: GPL-2.0-or-later |
48 | -#define DO_LDAVH(OP, ESIZE, TYPE, XCHG, EVENACC, ODDACC, TO128) \ | 34 | * |
49 | +#define DO_LDAVH(OP, TYPE, LTYPE, XCHG, SUB) \ | 35 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) |
50 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | 36 | } |
51 | void *vm, uint64_t a) \ | ||
52 | { \ | ||
53 | uint16_t mask = mve_element_mask(env); \ | ||
54 | unsigned e; \ | ||
55 | TYPE *n = vn, *m = vm; \ | ||
56 | - Int128 acc = int128_lshift(TO128(a), 8); \ | ||
57 | - for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
58 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
59 | if (mask & 1) { \ | ||
60 | + LTYPE mul; \ | ||
61 | if (e & 1) { \ | ||
62 | - acc = ODDACC(acc, TO128(n[H##ESIZE(e - 1 * XCHG)] * \ | ||
63 | - m[H##ESIZE(e)])); \ | ||
64 | + mul = (LTYPE)n[H4(e - 1 * XCHG)] * m[H4(e)]; \ | ||
65 | + if (SUB) { \ | ||
66 | + mul = -mul; \ | ||
67 | + } \ | ||
68 | } else { \ | ||
69 | - acc = EVENACC(acc, TO128(n[H##ESIZE(e + 1 * XCHG)] * \ | ||
70 | - m[H##ESIZE(e)])); \ | ||
71 | + mul = (LTYPE)n[H4(e + 1 * XCHG)] * m[H4(e)]; \ | ||
72 | } \ | ||
73 | - acc = int128_add(acc, int128_make64(1 << 7)); \ | ||
74 | + mul = (mul >> 8) + ((mul >> 7) & 1); \ | ||
75 | + a += mul; \ | ||
76 | } \ | ||
77 | } \ | ||
78 | mve_advance_vpt(env); \ | ||
79 | - return int128_getlo(int128_rshift(acc, 8)); \ | ||
80 | + return a; \ | ||
81 | } | 37 | } |
82 | 38 | ||
83 | -DO_LDAVH(vrmlaldavhsw, 4, int32_t, false, int128_add, int128_add, int128_makes64) | 39 | + qdev_pass_gpios(DEVICE(&s->syscfg), dev_soc, NULL); |
84 | -DO_LDAVH(vrmlaldavhxsw, 4, int32_t, true, int128_add, int128_add, int128_makes64) | 40 | + |
85 | +DO_LDAVH(vrmlaldavhsw, int32_t, int64_t, false, false) | 41 | /* EXTI device */ |
86 | +DO_LDAVH(vrmlaldavhxsw, int32_t, int64_t, true, false) | 42 | busdev = SYS_BUS_DEVICE(&s->exti); |
87 | 43 | if (!sysbus_realize(busdev, errp)) { | |
88 | -DO_LDAVH(vrmlaldavhuw, 4, uint32_t, false, int128_add, int128_add, int128_make64) | 44 | diff --git a/tests/qtest/stm32l4x5_gpio-test.c b/tests/qtest/stm32l4x5_gpio-test.c |
89 | +DO_LDAVH(vrmlaldavhuw, uint32_t, uint64_t, false, false) | 45 | index XXXXXXX..XXXXXXX 100644 |
90 | 46 | --- a/tests/qtest/stm32l4x5_gpio-test.c | |
91 | -DO_LDAVH(vrmlsldavhsw, 4, int32_t, false, int128_add, int128_sub, int128_makes64) | 47 | +++ b/tests/qtest/stm32l4x5_gpio-test.c |
92 | -DO_LDAVH(vrmlsldavhxsw, 4, int32_t, true, int128_add, int128_sub, int128_makes64) | 48 | @@ -XXX,XX +XXX,XX @@ |
93 | +DO_LDAVH(vrmlsldavhsw, int32_t, int64_t, false, true) | 49 | #define OTYPER_PUSH_PULL 0 |
94 | +DO_LDAVH(vrmlsldavhxsw, int32_t, int64_t, true, true) | 50 | #define OTYPER_OPEN_DRAIN 1 |
95 | 51 | ||
96 | /* Vector add across vector */ | 52 | +/* SoC forwards GPIOs to SysCfg */ |
97 | #define DO_VADDV(OP, ESIZE, TYPE) \ | 53 | +#define SYSCFG "/machine/soc" |
54 | + | ||
55 | const uint32_t moder_reset[NUM_GPIOS] = { | ||
56 | 0xABFFFFFF, | ||
57 | 0xFFFFFEBF, | ||
58 | @@ -XXX,XX +XXX,XX @@ static void test_gpio_output_mode(const void *data) | ||
59 | uint32_t gpio = test_gpio_addr(data); | ||
60 | unsigned int gpio_id = get_gpio_id(gpio); | ||
61 | |||
62 | - qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
63 | + qtest_irq_intercept_in(global_qtest, SYSCFG); | ||
64 | |||
65 | /* Set a bit in ODR and check nothing happens */ | ||
66 | gpio_set_bit(gpio, ODR, pin, 1); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void test_gpio_input_mode(const void *data) | ||
68 | uint32_t gpio = test_gpio_addr(data); | ||
69 | unsigned int gpio_id = get_gpio_id(gpio); | ||
70 | |||
71 | - qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
72 | + qtest_irq_intercept_in(global_qtest, SYSCFG); | ||
73 | |||
74 | /* Configure a line as input, raise it, and check that the pin is high */ | ||
75 | gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); | ||
76 | @@ -XXX,XX +XXX,XX @@ static void test_pull_up_pull_down(const void *data) | ||
77 | uint32_t gpio = test_gpio_addr(data); | ||
78 | unsigned int gpio_id = get_gpio_id(gpio); | ||
79 | |||
80 | - qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
81 | + qtest_irq_intercept_in(global_qtest, SYSCFG); | ||
82 | |||
83 | /* Configure a line as input with pull-up, check the line is set high */ | ||
84 | gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); | ||
85 | @@ -XXX,XX +XXX,XX @@ static void test_push_pull(const void *data) | ||
86 | uint32_t gpio = test_gpio_addr(data); | ||
87 | uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
88 | |||
89 | - qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
90 | + qtest_irq_intercept_in(global_qtest, SYSCFG); | ||
91 | |||
92 | /* Setting a line high externally, configuring it in push-pull output */ | ||
93 | /* And checking the pin was disconnected */ | ||
94 | @@ -XXX,XX +XXX,XX @@ static void test_open_drain(const void *data) | ||
95 | uint32_t gpio = test_gpio_addr(data); | ||
96 | uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
97 | |||
98 | - qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
99 | + qtest_irq_intercept_in(global_qtest, SYSCFG); | ||
100 | |||
101 | /* Setting a line high externally, configuring it in open-drain output */ | ||
102 | /* And checking the pin was disconnected */ | ||
103 | diff --git a/tests/qtest/stm32l4x5_syscfg-test.c b/tests/qtest/stm32l4x5_syscfg-test.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/tests/qtest/stm32l4x5_syscfg-test.c | ||
106 | +++ b/tests/qtest/stm32l4x5_syscfg-test.c | ||
107 | @@ -XXX,XX +XXX,XX @@ | ||
108 | /* | ||
109 | * QTest testcase for STM32L4x5_SYSCFG | ||
110 | * | ||
111 | - * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
112 | - * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
113 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
114 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
115 | * | ||
116 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
117 | * See the COPYING file in the top-level directory. | ||
118 | @@ -XXX,XX +XXX,XX @@ | ||
119 | #define SYSCFG_SWPR2 0x28 | ||
120 | #define INVALID_ADDR 0x2C | ||
121 | |||
122 | +/* SoC forwards GPIOs to SysCfg */ | ||
123 | +#define SYSCFG "/machine/soc" | ||
124 | +#define EXTI "/machine/soc/exti" | ||
125 | + | ||
126 | static void syscfg_writel(unsigned int offset, uint32_t value) | ||
127 | { | ||
128 | writel(SYSCFG_BASE_ADDR + offset, value); | ||
129 | @@ -XXX,XX +XXX,XX @@ static uint32_t syscfg_readl(unsigned int offset) | ||
130 | |||
131 | static void syscfg_set_irq(int num, int level) | ||
132 | { | ||
133 | - qtest_set_irq_in(global_qtest, "/machine/soc/syscfg", | ||
134 | - NULL, num, level); | ||
135 | + qtest_set_irq_in(global_qtest, SYSCFG, NULL, num, level); | ||
136 | } | ||
137 | |||
138 | static void system_reset(void) | ||
139 | @@ -XXX,XX +XXX,XX @@ static void test_interrupt(void) | ||
140 | * Test that GPIO rising lines result in an irq | ||
141 | * with the right configuration | ||
142 | */ | ||
143 | - qtest_irq_intercept_in(global_qtest, "/machine/soc/exti"); | ||
144 | + qtest_irq_intercept_in(global_qtest, EXTI); | ||
145 | |||
146 | /* GPIOA is the default source for EXTI lines 0 to 15 */ | ||
147 | |||
148 | @@ -XXX,XX +XXX,XX @@ static void test_irq_pin_multiplexer(void) | ||
149 | * Test that syscfg irq sets the right exti irq | ||
150 | */ | ||
151 | |||
152 | - qtest_irq_intercept_in(global_qtest, "/machine/soc/exti"); | ||
153 | + qtest_irq_intercept_in(global_qtest, EXTI); | ||
154 | |||
155 | syscfg_set_irq(0, 1); | ||
156 | |||
157 | @@ -XXX,XX +XXX,XX @@ static void test_irq_gpio_multiplexer(void) | ||
158 | * Test that an irq is generated only by the right GPIO | ||
159 | */ | ||
160 | |||
161 | - qtest_irq_intercept_in(global_qtest, "/machine/soc/exti"); | ||
162 | + qtest_irq_intercept_in(global_qtest, EXTI); | ||
163 | |||
164 | /* GPIOA is the default source for EXTI lines 0 to 15 */ | ||
165 | |||
98 | -- | 166 | -- |
99 | 2.20.1 | 167 | 2.34.1 |
100 | 168 | ||
101 | 169 | diff view generated by jsdifflib |
1 | In do_ldst(), the calculation of the offset needs to be based on the | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | size of the memory access, not the size of the elements in the | ||
3 | vector. This meant we were getting it wrong for the widening and | ||
4 | narrowing variants of the various VLDR and VSTR insns. | ||
5 | 2 | ||
3 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
4 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Message-id: 20240424200929.240921-4-ines.varhol@telecom-paris.fr | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-2-peter.maydell@linaro.org | ||
9 | --- | 8 | --- |
10 | target/arm/translate-mve.c | 17 +++++++++-------- | 9 | hw/arm/b-l475e-iot01a.c | 46 ++++++++++++++++++++++++++++------------- |
11 | 1 file changed, 9 insertions(+), 8 deletions(-) | 10 | 1 file changed, 32 insertions(+), 14 deletions(-) |
12 | 11 | ||
13 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 12 | diff --git a/hw/arm/b-l475e-iot01a.c b/hw/arm/b-l475e-iot01a.c |
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate-mve.c | 14 | --- a/hw/arm/b-l475e-iot01a.c |
16 | +++ b/target/arm/translate-mve.c | 15 | +++ b/hw/arm/b-l475e-iot01a.c |
17 | @@ -XXX,XX +XXX,XX @@ static bool mve_skip_first_beat(DisasContext *s) | 16 | @@ -XXX,XX +XXX,XX @@ |
18 | } | 17 | * B-L475E-IOT01A Discovery Kit machine |
18 | * (B-L475E-IOT01A IoT Node) | ||
19 | * | ||
20 | - * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
21 | - * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
22 | + * Copyright (c) 2023-2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
23 | + * Copyright (c) 2023-2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
24 | * | ||
25 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
26 | * | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | |||
29 | /* B-L475E-IOT01A implementation is derived from netduinoplus2 */ | ||
30 | |||
31 | -static void b_l475e_iot01a_init(MachineState *machine) | ||
32 | +#define TYPE_B_L475E_IOT01A MACHINE_TYPE_NAME("b-l475e-iot01a") | ||
33 | +OBJECT_DECLARE_SIMPLE_TYPE(Bl475eMachineState, B_L475E_IOT01A) | ||
34 | + | ||
35 | +typedef struct Bl475eMachineState { | ||
36 | + MachineState parent_obj; | ||
37 | + | ||
38 | + Stm32l4x5SocState soc; | ||
39 | +} Bl475eMachineState; | ||
40 | + | ||
41 | +static void bl475e_init(MachineState *machine) | ||
42 | { | ||
43 | + Bl475eMachineState *s = B_L475E_IOT01A(machine); | ||
44 | const Stm32l4x5SocClass *sc; | ||
45 | - DeviceState *dev; | ||
46 | |||
47 | - dev = qdev_new(TYPE_STM32L4X5XG_SOC); | ||
48 | - object_property_add_child(OBJECT(machine), "soc", OBJECT(dev)); | ||
49 | - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
50 | + object_initialize_child(OBJECT(machine), "soc", &s->soc, | ||
51 | + TYPE_STM32L4X5XG_SOC); | ||
52 | + sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal); | ||
53 | |||
54 | - sc = STM32L4X5_SOC_GET_CLASS(dev); | ||
55 | - armv7m_load_kernel(ARM_CPU(first_cpu), | ||
56 | - machine->kernel_filename, | ||
57 | - 0, sc->flash_size); | ||
58 | + sc = STM32L4X5_SOC_GET_CLASS(&s->soc); | ||
59 | + armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0, | ||
60 | + sc->flash_size); | ||
19 | } | 61 | } |
20 | 62 | ||
21 | -static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) | 63 | -static void b_l475e_iot01a_machine_init(MachineClass *mc) |
22 | +static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn, | 64 | +static void bl475e_machine_init(ObjectClass *oc, void *data) |
23 | + unsigned msize) | ||
24 | { | 65 | { |
25 | TCGv_i32 addr; | 66 | + MachineClass *mc = MACHINE_CLASS(oc); |
26 | uint32_t offset; | 67 | static const char *machine_valid_cpu_types[] = { |
27 | @@ -XXX,XX +XXX,XX @@ static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) | 68 | ARM_CPU_TYPE_NAME("cortex-m4"), |
28 | return true; | 69 | NULL |
29 | } | ||
30 | |||
31 | - offset = a->imm << a->size; | ||
32 | + offset = a->imm << msize; | ||
33 | if (!a->a) { | ||
34 | offset = -offset; | ||
35 | } | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) | ||
37 | { gen_helper_mve_vstrw, gen_helper_mve_vldrw }, | ||
38 | { NULL, NULL } | ||
39 | }; | 70 | }; |
40 | - return do_ldst(s, a, ldstfns[a->size][a->l]); | 71 | mc->desc = "B-L475E-IOT01A Discovery Kit (Cortex-M4)"; |
41 | + return do_ldst(s, a, ldstfns[a->size][a->l], a->size); | 72 | - mc->init = b_l475e_iot01a_init; |
73 | + mc->init = bl475e_init; | ||
74 | mc->valid_cpu_types = machine_valid_cpu_types; | ||
75 | |||
76 | /* SRAM pre-allocated as part of the SoC instantiation */ | ||
77 | mc->default_ram_size = 0; | ||
42 | } | 78 | } |
43 | 79 | ||
44 | -#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST) \ | 80 | -DEFINE_MACHINE("b-l475e-iot01a", b_l475e_iot01a_machine_init) |
45 | +#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST, MSIZE) \ | 81 | +static const TypeInfo bl475e_machine_type[] = { |
46 | static bool trans_##OP(DisasContext *s, arg_VLDR_VSTR *a) \ | 82 | + { |
47 | { \ | 83 | + .name = TYPE_B_L475E_IOT01A, |
48 | static MVEGenLdStFn * const ldstfns[2][2] = { \ | 84 | + .parent = TYPE_MACHINE, |
49 | { gen_helper_mve_##ST, gen_helper_mve_##SLD }, \ | 85 | + .instance_size = sizeof(Bl475eMachineState), |
50 | { NULL, gen_helper_mve_##ULD }, \ | 86 | + .class_init = bl475e_machine_init, |
51 | }; \ | 87 | + } |
52 | - return do_ldst(s, a, ldstfns[a->u][a->l]); \ | 88 | +}; |
53 | + return do_ldst(s, a, ldstfns[a->u][a->l], MSIZE); \ | 89 | + |
54 | } | 90 | +DEFINE_TYPES(bl475e_machine_type) |
55 | |||
56 | -DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h) | ||
57 | -DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w) | ||
58 | -DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w) | ||
59 | +DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h, MO_8) | ||
60 | +DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w, MO_8) | ||
61 | +DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w, MO_16) | ||
62 | |||
63 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
64 | { | ||
65 | -- | 91 | -- |
66 | 2.20.1 | 92 | 2.34.1 |
67 | 93 | ||
68 | 94 | diff view generated by jsdifflib |
1 | Implement the MVE VHLL (vector shift left long) insn. This has two | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | encodings: the T1 encoding is the usual shift-by-immediate format, | ||
3 | and the T2 encoding is a special case where the shift count is always | ||
4 | equal to the element size. | ||
5 | 2 | ||
3 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
4 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Message-id: 20240424200929.240921-5-ines.varhol@telecom-paris.fr | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-10-peter.maydell@linaro.org | ||
9 | --- | 8 | --- |
10 | target/arm/helper-mve.h | 9 +++++++ | 9 | hw/arm/b-l475e-iot01a.c | 59 +++++++++++++++++++++++++++++++++++++++-- |
11 | target/arm/mve.decode | 53 +++++++++++++++++++++++++++++++++++--- | 10 | hw/arm/Kconfig | 1 + |
12 | target/arm/mve_helper.c | 32 +++++++++++++++++++++++ | 11 | 2 files changed, 58 insertions(+), 2 deletions(-) |
13 | target/arm/translate-mve.c | 15 +++++++++++ | ||
14 | 4 files changed, 105 insertions(+), 4 deletions(-) | ||
15 | 12 | ||
16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 13 | diff --git a/hw/arm/b-l475e-iot01a.c b/hw/arm/b-l475e-iot01a.c |
17 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper-mve.h | 15 | --- a/hw/arm/b-l475e-iot01a.c |
19 | +++ b/target/arm/helper-mve.h | 16 | +++ b/hw/arm/b-l475e-iot01a.c |
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
21 | DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | +DEF_HELPER_FLAGS_4(mve_vshllbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vshllbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vshllbub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vshllbuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/mve.decode | ||
36 | +++ b/target/arm/mve.decode | ||
37 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ |
38 | @2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | 18 | #include "hw/boards.h" |
39 | @2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | 19 | #include "hw/qdev-properties.h" |
40 | 20 | #include "qemu/error-report.h" | |
41 | +@2_shll_b .... .... ... 01 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0 | 21 | -#include "hw/arm/stm32l4x5_soc.h" |
42 | +@2_shll_h .... .... ... 1 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | 22 | #include "hw/arm/boot.h" |
43 | +# VSHLL encoding T2 where shift == esize | 23 | +#include "hw/core/split-irq.h" |
44 | +@2_shll_esize_b .... .... .... 00 .. .... .... .... .... &2shift \ | 24 | +#include "hw/arm/stm32l4x5_soc.h" |
45 | + qd=%qd qm=%qm size=0 shift=8 | 25 | +#include "hw/gpio/stm32l4x5_gpio.h" |
46 | +@2_shll_esize_h .... .... .... 01 .. .... .... .... .... &2shift \ | 26 | +#include "hw/display/dm163.h" |
47 | + qd=%qd qm=%qm size=1 shift=16 | 27 | |
48 | + | 28 | -/* B-L475E-IOT01A implementation is derived from netduinoplus2 */ |
49 | # Right shifts are encoded as N - shift, where N is the element size in bits. | 29 | +/* B-L475E-IOT01A implementation is inspired from netduinoplus2 and arduino */ |
50 | %rshift_i5 16:5 !function=rsub_32 | ||
51 | %rshift_i4 16:4 !function=rsub_16 | ||
52 | @@ -XXX,XX +XXX,XX @@ VADD 1110 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | ||
53 | VSUB 1111 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | ||
54 | VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
55 | |||
56 | -VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
57 | -VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
58 | +# The VSHLL T2 encoding is not a @2op pattern, but is here because it | ||
59 | +# overlaps what would be size=0b11 VMULH/VRMULH | ||
60 | +{ | ||
61 | + VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
62 | + VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
63 | |||
64 | -VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
65 | -VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
66 | + VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
67 | +} | ||
68 | + | ||
69 | +{ | ||
70 | + VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
71 | + VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
72 | + | ||
73 | + VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
74 | +} | ||
75 | + | ||
76 | +{ | ||
77 | + VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
78 | + VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
79 | + | ||
80 | + VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
81 | +} | ||
82 | + | ||
83 | +{ | ||
84 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
85 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
86 | + | ||
87 | + VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
88 | +} | ||
89 | |||
90 | VMAX_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op | ||
91 | VMAX_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op | ||
92 | @@ -XXX,XX +XXX,XX @@ VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
93 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
94 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
95 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
96 | + | ||
97 | +# VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file | ||
98 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | ||
99 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | ||
100 | + | ||
101 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | ||
102 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | ||
103 | + | ||
104 | +VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
105 | +VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
106 | + | ||
107 | +VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
108 | +VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
109 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
110 | index XXXXXXX..XXXXXXX 100644 | ||
111 | --- a/target/arm/mve_helper.c | ||
112 | +++ b/target/arm/mve_helper.c | ||
113 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
114 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
115 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
116 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
117 | + | 30 | + |
118 | +/* | 31 | +/* |
119 | + * Long shifts taking half-sized inputs from top or bottom of the input | 32 | + * There are actually 14 input pins in the DM163 device. |
120 | + * vector and producing a double-width result. ESIZE, TYPE are for | 33 | + * Here the DM163 input pin EN isn't connected to the STM32L4x5 |
121 | + * the input, and LESIZE, LTYPE for the output. | 34 | + * GPIOs as the IM120417002 colors shield doesn't actually use |
122 | + * Unlike the normal shift helpers, we do not handle negative shift counts, | 35 | + * this pin to drive the RGB matrix. |
123 | + * because the long shift is strictly left-only. | ||
124 | + */ | 36 | + */ |
125 | +#define DO_VSHLL(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE) \ | 37 | +#define NUM_DM163_INPUTS 13 |
126 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | 38 | + |
127 | + void *vm, uint32_t shift) \ | 39 | +static const unsigned dm163_input[NUM_DM163_INPUTS] = { |
128 | + { \ | 40 | + 1 * GPIO_NUM_PINS + 2, /* ROW0 PB2 */ |
129 | + LTYPE *d = vd; \ | 41 | + 0 * GPIO_NUM_PINS + 15, /* ROW1 PA15 */ |
130 | + TYPE *m = vm; \ | 42 | + 0 * GPIO_NUM_PINS + 2, /* ROW2 PA2 */ |
131 | + uint16_t mask = mve_element_mask(env); \ | 43 | + 0 * GPIO_NUM_PINS + 7, /* ROW3 PA7 */ |
132 | + unsigned le; \ | 44 | + 0 * GPIO_NUM_PINS + 6, /* ROW4 PA6 */ |
133 | + assert(shift <= 16); \ | 45 | + 0 * GPIO_NUM_PINS + 5, /* ROW5 PA5 */ |
134 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | 46 | + 1 * GPIO_NUM_PINS + 0, /* ROW6 PB0 */ |
135 | + LTYPE r = (LTYPE)m[H##ESIZE(le * 2 + TOP)] << shift; \ | 47 | + 0 * GPIO_NUM_PINS + 3, /* ROW7 PA3 */ |
136 | + mergemask(&d[H##LESIZE(le)], r, mask); \ | 48 | + 0 * GPIO_NUM_PINS + 4, /* SIN (SDA) PA4 */ |
137 | + } \ | 49 | + 1 * GPIO_NUM_PINS + 1, /* DCK (SCK) PB1 */ |
138 | + mve_advance_vpt(env); \ | 50 | + 2 * GPIO_NUM_PINS + 3, /* RST_B (RST) PC3 */ |
51 | + 2 * GPIO_NUM_PINS + 4, /* LAT_B (LAT) PC4 */ | ||
52 | + 2 * GPIO_NUM_PINS + 5, /* SELBK (SB) PC5 */ | ||
53 | +}; | ||
54 | |||
55 | #define TYPE_B_L475E_IOT01A MACHINE_TYPE_NAME("b-l475e-iot01a") | ||
56 | OBJECT_DECLARE_SIMPLE_TYPE(Bl475eMachineState, B_L475E_IOT01A) | ||
57 | @@ -XXX,XX +XXX,XX @@ typedef struct Bl475eMachineState { | ||
58 | MachineState parent_obj; | ||
59 | |||
60 | Stm32l4x5SocState soc; | ||
61 | + SplitIRQ gpio_splitters[NUM_DM163_INPUTS]; | ||
62 | + DM163State dm163; | ||
63 | } Bl475eMachineState; | ||
64 | |||
65 | static void bl475e_init(MachineState *machine) | ||
66 | { | ||
67 | Bl475eMachineState *s = B_L475E_IOT01A(machine); | ||
68 | const Stm32l4x5SocClass *sc; | ||
69 | + DeviceState *dev, *gpio_out_splitter; | ||
70 | + unsigned gpio, pin; | ||
71 | |||
72 | object_initialize_child(OBJECT(machine), "soc", &s->soc, | ||
73 | TYPE_STM32L4X5XG_SOC); | ||
74 | @@ -XXX,XX +XXX,XX @@ static void bl475e_init(MachineState *machine) | ||
75 | sc = STM32L4X5_SOC_GET_CLASS(&s->soc); | ||
76 | armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0, | ||
77 | sc->flash_size); | ||
78 | + | ||
79 | + if (object_class_by_name(TYPE_DM163)) { | ||
80 | + object_initialize_child(OBJECT(machine), "dm163", | ||
81 | + &s->dm163, TYPE_DM163); | ||
82 | + dev = DEVICE(&s->dm163); | ||
83 | + qdev_realize(dev, NULL, &error_abort); | ||
84 | + | ||
85 | + for (unsigned i = 0; i < NUM_DM163_INPUTS; i++) { | ||
86 | + object_initialize_child(OBJECT(machine), "gpio-out-splitters[*]", | ||
87 | + &s->gpio_splitters[i], TYPE_SPLIT_IRQ); | ||
88 | + gpio_out_splitter = DEVICE(&s->gpio_splitters[i]); | ||
89 | + qdev_prop_set_uint32(gpio_out_splitter, "num-lines", 2); | ||
90 | + qdev_realize(gpio_out_splitter, NULL, &error_fatal); | ||
91 | + | ||
92 | + qdev_connect_gpio_out(gpio_out_splitter, 0, | ||
93 | + qdev_get_gpio_in(DEVICE(&s->soc), dm163_input[i])); | ||
94 | + qdev_connect_gpio_out(gpio_out_splitter, 1, | ||
95 | + qdev_get_gpio_in(dev, i)); | ||
96 | + gpio = dm163_input[i] / GPIO_NUM_PINS; | ||
97 | + pin = dm163_input[i] % GPIO_NUM_PINS; | ||
98 | + qdev_connect_gpio_out(DEVICE(&s->soc.gpio[gpio]), pin, | ||
99 | + qdev_get_gpio_in(DEVICE(gpio_out_splitter), 0)); | ||
100 | + } | ||
139 | + } | 101 | + } |
140 | + | 102 | } |
141 | +#define DO_VSHLL_ALL(OP, TOP) \ | 103 | |
142 | + DO_VSHLL(OP##sb, TOP, 1, int8_t, 2, int16_t) \ | 104 | static void bl475e_machine_init(ObjectClass *oc, void *data) |
143 | + DO_VSHLL(OP##ub, TOP, 1, uint8_t, 2, uint16_t) \ | 105 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
144 | + DO_VSHLL(OP##sh, TOP, 2, int16_t, 4, int32_t) \ | ||
145 | + DO_VSHLL(OP##uh, TOP, 2, uint16_t, 4, uint32_t) \ | ||
146 | + | ||
147 | +DO_VSHLL_ALL(vshllb, false) | ||
148 | +DO_VSHLL_ALL(vshllt, true) | ||
149 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
150 | index XXXXXXX..XXXXXXX 100644 | 106 | index XXXXXXX..XXXXXXX 100644 |
151 | --- a/target/arm/translate-mve.c | 107 | --- a/hw/arm/Kconfig |
152 | +++ b/target/arm/translate-mve.c | 108 | +++ b/hw/arm/Kconfig |
153 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_S, vshli_s, true) | 109 | @@ -XXX,XX +XXX,XX @@ config B_L475E_IOT01A |
154 | DO_2SHIFT(VSHRI_U, vshli_u, true) | 110 | default y |
155 | DO_2SHIFT(VRSHRI_S, vrshli_s, true) | 111 | depends on TCG && ARM |
156 | DO_2SHIFT(VRSHRI_U, vrshli_u, true) | 112 | select STM32L4X5_SOC |
157 | + | 113 | + imply DM163 |
158 | +#define DO_VSHLL(INSN, FN) \ | 114 | |
159 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | 115 | config STM32L4X5_SOC |
160 | + { \ | 116 | bool |
161 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
162 | + gen_helper_mve_##FN##b, \ | ||
163 | + gen_helper_mve_##FN##h, \ | ||
164 | + }; \ | ||
165 | + return do_2shift(s, a, fns[a->size], false); \ | ||
166 | + } | ||
167 | + | ||
168 | +DO_VSHLL(VSHLL_BS, vshllbs) | ||
169 | +DO_VSHLL(VSHLL_BU, vshllbu) | ||
170 | +DO_VSHLL(VSHLL_TS, vshllts) | ||
171 | +DO_VSHLL(VSHLL_TU, vshlltu) | ||
172 | -- | 117 | -- |
173 | 2.20.1 | 118 | 2.34.1 |
174 | 119 | ||
175 | 120 | diff view generated by jsdifflib |
1 | From: Maxim Uvarov <maxim.uvarov@linaro.org> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | qemu has 2 type of functions: shutdown and reboot. Shutdown | 3 | `test_dm163_bank()` |
4 | function has to be used for machine shutdown. Otherwise we cause | 4 | Checks that the pin "sout" of the DM163 led driver outputs the values |
5 | a reset with a bogus "cause" value, when we intended a shutdown. | 5 | received on pin "sin" with the expected latency (depending on the bank). |
6 | 6 | ||
7 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> | 7 | `test_dm163_gpio_connection()` |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Check that changes to relevant STM32L4x5 GPIO pins are propagated to the |
9 | Message-id: 20210625111842.3790-3-maxim.uvarov@linaro.org | 9 | DM163 device. |
10 | [PMM: tweaked commit message] | 10 | |
11 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
12 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | ||
13 | Acked-by: Thomas Huth <thuth@redhat.com> | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
15 | Message-id: 20240424200929.240921-6-ines.varhol@telecom-paris.fr | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 17 | --- |
13 | hw/gpio/gpio_pwr.c | 2 +- | 18 | tests/qtest/dm163-test.c | 194 +++++++++++++++++++++++++++++++++++++++ |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 19 | tests/qtest/meson.build | 2 + |
15 | 20 | 2 files changed, 196 insertions(+) | |
16 | diff --git a/hw/gpio/gpio_pwr.c b/hw/gpio/gpio_pwr.c | 21 | create mode 100644 tests/qtest/dm163-test.c |
22 | |||
23 | diff --git a/tests/qtest/dm163-test.c b/tests/qtest/dm163-test.c | ||
24 | new file mode 100644 | ||
25 | index XXXXXXX..XXXXXXX | ||
26 | --- /dev/null | ||
27 | +++ b/tests/qtest/dm163-test.c | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | +/* | ||
30 | + * QTest testcase for DM163 | ||
31 | + * | ||
32 | + * Copyright (C) 2024 Samuel Tardieu <sam@rfc1149.net> | ||
33 | + * Copyright (C) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
34 | + * Copyright (C) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
35 | + * | ||
36 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
37 | + */ | ||
38 | + | ||
39 | +#include "qemu/osdep.h" | ||
40 | +#include "libqtest.h" | ||
41 | + | ||
42 | +enum DM163_INPUTS { | ||
43 | + SIN = 8, | ||
44 | + DCK = 9, | ||
45 | + RST_B = 10, | ||
46 | + LAT_B = 11, | ||
47 | + SELBK = 12, | ||
48 | + EN_B = 13 | ||
49 | +}; | ||
50 | + | ||
51 | +#define DEVICE_NAME "/machine/dm163" | ||
52 | +#define GPIO_OUT(name, value) qtest_set_irq_in(qts, DEVICE_NAME, NULL, name, \ | ||
53 | + value) | ||
54 | +#define GPIO_PULSE(name) \ | ||
55 | + do { \ | ||
56 | + GPIO_OUT(name, 1); \ | ||
57 | + GPIO_OUT(name, 0); \ | ||
58 | + } while (0) | ||
59 | + | ||
60 | + | ||
61 | +static void rise_gpio_pin_dck(QTestState *qts) | ||
62 | +{ | ||
63 | + /* Configure output mode for pin PB1 */ | ||
64 | + qtest_writel(qts, 0x48000400, 0xFFFFFEB7); | ||
65 | + /* Write 1 in ODR for PB1 */ | ||
66 | + qtest_writel(qts, 0x48000414, 0x00000002); | ||
67 | +} | ||
68 | + | ||
69 | +static void lower_gpio_pin_dck(QTestState *qts) | ||
70 | +{ | ||
71 | + /* Configure output mode for pin PB1 */ | ||
72 | + qtest_writel(qts, 0x48000400, 0xFFFFFEB7); | ||
73 | + /* Write 0 in ODR for PB1 */ | ||
74 | + qtest_writel(qts, 0x48000414, 0x00000000); | ||
75 | +} | ||
76 | + | ||
77 | +static void rise_gpio_pin_selbk(QTestState *qts) | ||
78 | +{ | ||
79 | + /* Configure output mode for pin PC5 */ | ||
80 | + qtest_writel(qts, 0x48000800, 0xFFFFF7FF); | ||
81 | + /* Write 1 in ODR for PC5 */ | ||
82 | + qtest_writel(qts, 0x48000814, 0x00000020); | ||
83 | +} | ||
84 | + | ||
85 | +static void lower_gpio_pin_selbk(QTestState *qts) | ||
86 | +{ | ||
87 | + /* Configure output mode for pin PC5 */ | ||
88 | + qtest_writel(qts, 0x48000800, 0xFFFFF7FF); | ||
89 | + /* Write 0 in ODR for PC5 */ | ||
90 | + qtest_writel(qts, 0x48000814, 0x00000000); | ||
91 | +} | ||
92 | + | ||
93 | +static void rise_gpio_pin_lat_b(QTestState *qts) | ||
94 | +{ | ||
95 | + /* Configure output mode for pin PC4 */ | ||
96 | + qtest_writel(qts, 0x48000800, 0xFFFFFDFF); | ||
97 | + /* Write 1 in ODR for PC4 */ | ||
98 | + qtest_writel(qts, 0x48000814, 0x00000010); | ||
99 | +} | ||
100 | + | ||
101 | +static void lower_gpio_pin_lat_b(QTestState *qts) | ||
102 | +{ | ||
103 | + /* Configure output mode for pin PC4 */ | ||
104 | + qtest_writel(qts, 0x48000800, 0xFFFFFDFF); | ||
105 | + /* Write 0 in ODR for PC4 */ | ||
106 | + qtest_writel(qts, 0x48000814, 0x00000000); | ||
107 | +} | ||
108 | + | ||
109 | +static void rise_gpio_pin_rst_b(QTestState *qts) | ||
110 | +{ | ||
111 | + /* Configure output mode for pin PC3 */ | ||
112 | + qtest_writel(qts, 0x48000800, 0xFFFFFF7F); | ||
113 | + /* Write 1 in ODR for PC3 */ | ||
114 | + qtest_writel(qts, 0x48000814, 0x00000008); | ||
115 | +} | ||
116 | + | ||
117 | +static void lower_gpio_pin_rst_b(QTestState *qts) | ||
118 | +{ | ||
119 | + /* Configure output mode for pin PC3 */ | ||
120 | + qtest_writel(qts, 0x48000800, 0xFFFFFF7F); | ||
121 | + /* Write 0 in ODR for PC3 */ | ||
122 | + qtest_writel(qts, 0x48000814, 0x00000000); | ||
123 | +} | ||
124 | + | ||
125 | +static void rise_gpio_pin_sin(QTestState *qts) | ||
126 | +{ | ||
127 | + /* Configure output mode for pin PA4 */ | ||
128 | + qtest_writel(qts, 0x48000000, 0xFFFFFDFF); | ||
129 | + /* Write 1 in ODR for PA4 */ | ||
130 | + qtest_writel(qts, 0x48000014, 0x00000010); | ||
131 | +} | ||
132 | + | ||
133 | +static void lower_gpio_pin_sin(QTestState *qts) | ||
134 | +{ | ||
135 | + /* Configure output mode for pin PA4 */ | ||
136 | + qtest_writel(qts, 0x48000000, 0xFFFFFDFF); | ||
137 | + /* Write 0 in ODR for PA4 */ | ||
138 | + qtest_writel(qts, 0x48000014, 0x00000000); | ||
139 | +} | ||
140 | + | ||
141 | +static void test_dm163_bank(const void *opaque) | ||
142 | +{ | ||
143 | + const unsigned bank = (uintptr_t) opaque; | ||
144 | + const int width = bank ? 192 : 144; | ||
145 | + | ||
146 | + QTestState *qts = qtest_initf("-M b-l475e-iot01a"); | ||
147 | + qtest_irq_intercept_out_named(qts, DEVICE_NAME, "sout"); | ||
148 | + GPIO_OUT(RST_B, 1); | ||
149 | + GPIO_OUT(EN_B, 0); | ||
150 | + GPIO_OUT(DCK, 0); | ||
151 | + GPIO_OUT(SELBK, bank); | ||
152 | + GPIO_OUT(LAT_B, 1); | ||
153 | + | ||
154 | + /* Fill bank with zeroes */ | ||
155 | + GPIO_OUT(SIN, 0); | ||
156 | + for (int i = 0; i < width; i++) { | ||
157 | + GPIO_PULSE(DCK); | ||
158 | + } | ||
159 | + /* Fill bank with ones, check that we get the previous zeroes */ | ||
160 | + GPIO_OUT(SIN, 1); | ||
161 | + for (int i = 0; i < width; i++) { | ||
162 | + GPIO_PULSE(DCK); | ||
163 | + g_assert(!qtest_get_irq(qts, 0)); | ||
164 | + } | ||
165 | + | ||
166 | + /* Pulse one more bit in the bank, check that we get a one */ | ||
167 | + GPIO_PULSE(DCK); | ||
168 | + g_assert(qtest_get_irq(qts, 0)); | ||
169 | + | ||
170 | + qtest_quit(qts); | ||
171 | +} | ||
172 | + | ||
173 | +static void test_dm163_gpio_connection(void) | ||
174 | +{ | ||
175 | + QTestState *qts = qtest_init("-M b-l475e-iot01a"); | ||
176 | + qtest_irq_intercept_in(qts, DEVICE_NAME); | ||
177 | + | ||
178 | + g_assert_false(qtest_get_irq(qts, SIN)); | ||
179 | + g_assert_false(qtest_get_irq(qts, DCK)); | ||
180 | + g_assert_false(qtest_get_irq(qts, RST_B)); | ||
181 | + g_assert_false(qtest_get_irq(qts, LAT_B)); | ||
182 | + g_assert_false(qtest_get_irq(qts, SELBK)); | ||
183 | + | ||
184 | + rise_gpio_pin_dck(qts); | ||
185 | + g_assert_true(qtest_get_irq(qts, DCK)); | ||
186 | + lower_gpio_pin_dck(qts); | ||
187 | + g_assert_false(qtest_get_irq(qts, DCK)); | ||
188 | + | ||
189 | + rise_gpio_pin_lat_b(qts); | ||
190 | + g_assert_true(qtest_get_irq(qts, LAT_B)); | ||
191 | + lower_gpio_pin_lat_b(qts); | ||
192 | + g_assert_false(qtest_get_irq(qts, LAT_B)); | ||
193 | + | ||
194 | + rise_gpio_pin_selbk(qts); | ||
195 | + g_assert_true(qtest_get_irq(qts, SELBK)); | ||
196 | + lower_gpio_pin_selbk(qts); | ||
197 | + g_assert_false(qtest_get_irq(qts, SELBK)); | ||
198 | + | ||
199 | + rise_gpio_pin_rst_b(qts); | ||
200 | + g_assert_true(qtest_get_irq(qts, RST_B)); | ||
201 | + lower_gpio_pin_rst_b(qts); | ||
202 | + g_assert_false(qtest_get_irq(qts, RST_B)); | ||
203 | + | ||
204 | + rise_gpio_pin_sin(qts); | ||
205 | + g_assert_true(qtest_get_irq(qts, SIN)); | ||
206 | + lower_gpio_pin_sin(qts); | ||
207 | + g_assert_false(qtest_get_irq(qts, SIN)); | ||
208 | + | ||
209 | + g_assert_false(qtest_get_irq(qts, DCK)); | ||
210 | + g_assert_false(qtest_get_irq(qts, LAT_B)); | ||
211 | + g_assert_false(qtest_get_irq(qts, SELBK)); | ||
212 | + g_assert_false(qtest_get_irq(qts, RST_B)); | ||
213 | +} | ||
214 | + | ||
215 | +int main(int argc, char **argv) | ||
216 | +{ | ||
217 | + g_test_init(&argc, &argv, NULL); | ||
218 | + qtest_add_data_func("/dm163/bank0", (void *)0, test_dm163_bank); | ||
219 | + qtest_add_data_func("/dm163/bank1", (void *)1, test_dm163_bank); | ||
220 | + qtest_add_func("/dm163/gpio_connection", test_dm163_gpio_connection); | ||
221 | + return g_test_run(); | ||
222 | +} | ||
223 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
17 | index XXXXXXX..XXXXXXX 100644 | 224 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/gpio/gpio_pwr.c | 225 | --- a/tests/qtest/meson.build |
19 | +++ b/hw/gpio/gpio_pwr.c | 226 | +++ b/tests/qtest/meson.build |
20 | @@ -XXX,XX +XXX,XX @@ static void gpio_pwr_reset(void *opaque, int n, int level) | 227 | @@ -XXX,XX +XXX,XX @@ qtests_arm = \ |
21 | static void gpio_pwr_shutdown(void *opaque, int n, int level) | 228 | (config_all_devices.has_key('CONFIG_MICROBIT') ? ['microbit-test'] : []) + \ |
22 | { | 229 | (config_all_devices.has_key('CONFIG_STM32L4X5_SOC') ? qtests_stm32l4x5 : []) + \ |
23 | if (level) { | 230 | (config_all_devices.has_key('CONFIG_FSI_APB2OPB_ASPEED') ? ['aspeed_fsi-test'] : []) + \ |
24 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); | 231 | + (config_all_devices.has_key('CONFIG_STM32L4X5_SOC') and |
25 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); | 232 | + config_all_devices.has_key('CONFIG_DM163')? ['dm163-test'] : []) + \ |
26 | } | 233 | ['arm-cpu-features', |
27 | } | 234 | 'boot-serial-test'] |
28 | 235 | ||
29 | -- | 236 | -- |
30 | 2.20.1 | 237 | 2.34.1 |
31 | 238 | ||
32 | 239 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Use dup_const() instead of bitfield_replicate() in | ||
2 | disas_simd_mod_imm(). | ||
3 | 1 | ||
4 | (We can't replace the other use of bitfield_replicate() in this file, | ||
5 | in logic_imm_decode_wmask(), because that location needs to handle 2 | ||
6 | and 4 bit elements, which dup_const() cannot.) | ||
7 | |||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210628135835.6690-6-peter.maydell@linaro.org | ||
11 | --- | ||
12 | target/arm/translate-a64.c | 2 +- | ||
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/translate-a64.c | ||
18 | +++ b/target/arm/translate-a64.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) | ||
20 | /* FMOV (vector, immediate) - half-precision */ | ||
21 | imm = vfp_expand_imm(MO_16, abcdefgh); | ||
22 | /* now duplicate across the lanes */ | ||
23 | - imm = bitfield_replicate(imm, 16); | ||
24 | + imm = dup_const(MO_16, imm); | ||
25 | } else { | ||
26 | imm = asimd_imm_const(abcdefgh, cmode, is_neg); | ||
27 | } | ||
28 | -- | ||
29 | 2.20.1 | ||
30 | |||
31 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE logical-immediate insns (VMOV, VMVN, | ||
2 | VORR and VBIC). These have essentially the same encoding | ||
3 | as their Neon equivalents, and we implement the decode | ||
4 | in the same way. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-7-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/helper-mve.h | 4 +++ | ||
11 | target/arm/mve.decode | 17 +++++++++++++ | ||
12 | target/arm/mve_helper.c | 24 ++++++++++++++++++ | ||
13 | target/arm/translate-mve.c | 50 ++++++++++++++++++++++++++++++++++++++ | ||
14 | 4 files changed, 95 insertions(+) | ||
15 | |||
16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/helper-mve.h | ||
19 | +++ b/target/arm/helper-mve.h | ||
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
21 | DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
22 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
23 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
24 | + | ||
25 | +DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
27 | +DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, 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 @@ | ||
33 | # VQDMULL has size in bit 28: 0 for 16 bit, 1 for 32 bit | ||
34 | %size_28 28:1 !function=plus_1 | ||
35 | |||
36 | +# 1imm format immediate | ||
37 | +%imm_28_16_0 28:1 16:3 0:4 | ||
38 | + | ||
39 | &vldr_vstr rn qd imm p a w size l u | ||
40 | &1op qd qm size | ||
41 | &2op qd qm qn size | ||
42 | &2scalar qd qn rm size | ||
43 | +&1imm qd imm cmode op | ||
44 | |||
45 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
46 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
47 | @@ -XXX,XX +XXX,XX @@ | ||
48 | @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 | ||
49 | @2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \ | ||
50 | size=%size_28 | ||
51 | +@1imm .... .... .... .... .... cmode:4 .. op:1 . .... &1imm qd=%qd imm=%imm_28_16_0 | ||
52 | |||
53 | # The _rev suffix indicates that Vn and Vm are reversed. This is | ||
54 | # the case for shifts. In the Arm ARM these insns are documented | ||
55 | @@ -XXX,XX +XXX,XX @@ VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rd | ||
56 | # Predicate operations | ||
57 | %mask_22_13 22:1 13:3 | ||
58 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
59 | + | ||
60 | +# Logical immediate operations (1 reg and modified-immediate) | ||
61 | + | ||
62 | +# The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but | ||
63 | +# not in a way we can conveniently represent in decodetree without | ||
64 | +# a lot of repetition: | ||
65 | +# VORR: op=0, (cmode & 1) && cmode < 12 | ||
66 | +# VBIC: op=1, (cmode & 1) && cmode < 12 | ||
67 | +# VMOV: everything else | ||
68 | +# So we have a single decode line and check the cmode/op in the | ||
69 | +# trans function. | ||
70 | +Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm | ||
71 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/mve_helper.c | ||
74 | +++ b/target/arm/mve_helper.c | ||
75 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vnegw, 4, int32_t, DO_NEG) | ||
76 | DO_1OP(vfnegh, 8, uint64_t, DO_FNEGH) | ||
77 | DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) | ||
78 | |||
79 | +/* | ||
80 | + * 1 operand immediates: Vda is destination and possibly also one source. | ||
81 | + * All these insns work at 64-bit widths. | ||
82 | + */ | ||
83 | +#define DO_1OP_IMM(OP, FN) \ | ||
84 | + void HELPER(mve_##OP)(CPUARMState *env, void *vda, uint64_t imm) \ | ||
85 | + { \ | ||
86 | + uint64_t *da = vda; \ | ||
87 | + uint16_t mask = mve_element_mask(env); \ | ||
88 | + unsigned e; \ | ||
89 | + for (e = 0; e < 16 / 8; e++, mask >>= 8) { \ | ||
90 | + mergemask(&da[H8(e)], FN(da[H8(e)], imm), mask); \ | ||
91 | + } \ | ||
92 | + mve_advance_vpt(env); \ | ||
93 | + } | ||
94 | + | ||
95 | +#define DO_MOVI(N, I) (I) | ||
96 | +#define DO_ANDI(N, I) ((N) & (I)) | ||
97 | +#define DO_ORRI(N, I) ((N) | (I)) | ||
98 | + | ||
99 | +DO_1OP_IMM(vmovi, DO_MOVI) | ||
100 | +DO_1OP_IMM(vandi, DO_ANDI) | ||
101 | +DO_1OP_IMM(vorri, DO_ORRI) | ||
102 | + | ||
103 | #define DO_2OP(OP, ESIZE, TYPE, FN) \ | ||
104 | void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
105 | void *vd, void *vn, void *vm) \ | ||
106 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/translate-mve.c | ||
109 | +++ b/target/arm/translate-mve.c | ||
110 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
111 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
112 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
113 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
114 | +typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
115 | |||
116 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
117 | static inline long mve_qreg_offset(unsigned reg) | ||
118 | @@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | ||
119 | mve_update_eci(s); | ||
120 | return true; | ||
121 | } | ||
122 | + | ||
123 | +static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) | ||
124 | +{ | ||
125 | + TCGv_ptr qd; | ||
126 | + uint64_t imm; | ||
127 | + | ||
128 | + if (!dc_isar_feature(aa32_mve, s) || | ||
129 | + !mve_check_qreg_bank(s, a->qd) || | ||
130 | + !fn) { | ||
131 | + return false; | ||
132 | + } | ||
133 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
134 | + return true; | ||
135 | + } | ||
136 | + | ||
137 | + imm = asimd_imm_const(a->imm, a->cmode, a->op); | ||
138 | + | ||
139 | + qd = mve_qreg_ptr(a->qd); | ||
140 | + fn(cpu_env, qd, tcg_constant_i64(imm)); | ||
141 | + tcg_temp_free_ptr(qd); | ||
142 | + mve_update_eci(s); | ||
143 | + return true; | ||
144 | +} | ||
145 | + | ||
146 | +static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a) | ||
147 | +{ | ||
148 | + /* Handle decode of cmode/op here between VORR/VBIC/VMOV */ | ||
149 | + MVEGenOneOpImmFn *fn; | ||
150 | + | ||
151 | + if ((a->cmode & 1) && a->cmode < 12) { | ||
152 | + if (a->op) { | ||
153 | + /* | ||
154 | + * For op=1, the immediate will be inverted by asimd_imm_const(), | ||
155 | + * so the VBIC becomes a logical AND operation. | ||
156 | + */ | ||
157 | + fn = gen_helper_mve_vandi; | ||
158 | + } else { | ||
159 | + fn = gen_helper_mve_vorri; | ||
160 | + } | ||
161 | + } else { | ||
162 | + /* There is one unallocated cmode/op combination in this space */ | ||
163 | + if (a->cmode == 15 && a->op == 1) { | ||
164 | + return false; | ||
165 | + } | ||
166 | + /* asimd_imm_const() sorts out VMVNI vs VMOVI for us */ | ||
167 | + fn = gen_helper_mve_vmovi; | ||
168 | + } | ||
169 | + return do_1imm(s, a, fn); | ||
170 | +} | ||
171 | -- | ||
172 | 2.20.1 | ||
173 | |||
174 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE shift-vector-left-by-immediate insns VSHL, VQSHL | ||
2 | and VQSHLU. | ||
3 | 1 | ||
4 | The size-and-immediate encoding here is the same as Neon, and we | ||
5 | handle it the same way neon-dp.decode does. | ||
6 | |||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210628135835.6690-8-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/helper-mve.h | 16 +++++++++++ | ||
12 | target/arm/mve.decode | 23 +++++++++++++++ | ||
13 | target/arm/mve_helper.c | 57 ++++++++++++++++++++++++++++++++++++++ | ||
14 | target/arm/translate-mve.c | 51 ++++++++++++++++++++++++++++++++++ | ||
15 | 4 files changed, 147 insertions(+) | ||
16 | |||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/helper-mve.h | ||
20 | +++ b/target/arm/helper-mve.h | ||
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
22 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
23 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
24 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
25 | + | ||
26 | +DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_4(mve_vqshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vqshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | + | ||
34 | +DEF_HELPER_FLAGS_4(mve_vqshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vqshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | + | ||
38 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
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 | &2op qd qm qn size | ||
47 | &2scalar qd qn rm size | ||
48 | &1imm qd imm cmode op | ||
49 | +&2shift qd qm shift size | ||
50 | |||
51 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
52 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
53 | @@ -XXX,XX +XXX,XX @@ | ||
54 | @2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | ||
55 | @2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | ||
56 | |||
57 | +@2_shl_b .... .... .. 001 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0 | ||
58 | +@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | ||
59 | +@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | ||
60 | + | ||
61 | # Vector loads and stores | ||
62 | |||
63 | # Widening loads and narrowing stores: | ||
64 | @@ -XXX,XX +XXX,XX @@ VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
65 | # So we have a single decode line and check the cmode/op in the | ||
66 | # trans function. | ||
67 | Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm | ||
68 | + | ||
69 | +# Shifts by immediate | ||
70 | + | ||
71 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | ||
72 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | ||
73 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | ||
74 | + | ||
75 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b | ||
76 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h | ||
77 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
78 | + | ||
79 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b | ||
80 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h | ||
81 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
82 | + | ||
83 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b | ||
84 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h | ||
85 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w | ||
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_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W) | ||
91 | WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, true, satp) | ||
92 | #define DO_UQRSHL_OP(N, M, satp) \ | ||
93 | WRAP_QRSHL_HELPER(do_uqrshl_bhs, N, M, true, satp) | ||
94 | +#define DO_SUQSHL_OP(N, M, satp) \ | ||
95 | + WRAP_QRSHL_HELPER(do_suqrshl_bhs, N, M, false, satp) | ||
96 | |||
97 | DO_2OP_SAT_S(vqshls, DO_SQSHL_OP) | ||
98 | DO_2OP_SAT_U(vqshlu, DO_UQSHL_OP) | ||
99 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvsw, 4, uint32_t) | ||
100 | DO_VADDV(vaddvub, 1, uint8_t) | ||
101 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
102 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
103 | + | ||
104 | +/* Shifts by immediate */ | ||
105 | +#define DO_2SHIFT(OP, ESIZE, TYPE, FN) \ | ||
106 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
107 | + void *vm, uint32_t shift) \ | ||
108 | + { \ | ||
109 | + TYPE *d = vd, *m = vm; \ | ||
110 | + uint16_t mask = mve_element_mask(env); \ | ||
111 | + unsigned e; \ | ||
112 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
113 | + mergemask(&d[H##ESIZE(e)], \ | ||
114 | + FN(m[H##ESIZE(e)], shift), mask); \ | ||
115 | + } \ | ||
116 | + mve_advance_vpt(env); \ | ||
117 | + } | ||
118 | + | ||
119 | +#define DO_2SHIFT_SAT(OP, ESIZE, TYPE, FN) \ | ||
120 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
121 | + void *vm, uint32_t shift) \ | ||
122 | + { \ | ||
123 | + TYPE *d = vd, *m = vm; \ | ||
124 | + uint16_t mask = mve_element_mask(env); \ | ||
125 | + unsigned e; \ | ||
126 | + bool qc = false; \ | ||
127 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
128 | + bool sat = false; \ | ||
129 | + mergemask(&d[H##ESIZE(e)], \ | ||
130 | + FN(m[H##ESIZE(e)], shift, &sat), 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 | +/* provide unsigned 2-op shift helpers for all sizes */ | ||
140 | +#define DO_2SHIFT_U(OP, FN) \ | ||
141 | + DO_2SHIFT(OP##b, 1, uint8_t, FN) \ | ||
142 | + DO_2SHIFT(OP##h, 2, uint16_t, FN) \ | ||
143 | + DO_2SHIFT(OP##w, 4, uint32_t, FN) | ||
144 | + | ||
145 | +#define DO_2SHIFT_SAT_U(OP, FN) \ | ||
146 | + DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \ | ||
147 | + DO_2SHIFT_SAT(OP##h, 2, uint16_t, FN) \ | ||
148 | + DO_2SHIFT_SAT(OP##w, 4, uint32_t, FN) | ||
149 | +#define DO_2SHIFT_SAT_S(OP, FN) \ | ||
150 | + DO_2SHIFT_SAT(OP##b, 1, int8_t, FN) \ | ||
151 | + DO_2SHIFT_SAT(OP##h, 2, int16_t, FN) \ | ||
152 | + DO_2SHIFT_SAT(OP##w, 4, int32_t, FN) | ||
153 | + | ||
154 | +DO_2SHIFT_U(vshli_u, DO_VSHLU) | ||
155 | +DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP) | ||
156 | +DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
157 | +DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
158 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
159 | index XXXXXXX..XXXXXXX 100644 | ||
160 | --- a/target/arm/translate-mve.c | ||
161 | +++ b/target/arm/translate-mve.c | ||
162 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
163 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
164 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
165 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
166 | +typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
167 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
168 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
169 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
170 | @@ -XXX,XX +XXX,XX @@ static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a) | ||
171 | } | ||
172 | return do_1imm(s, a, fn); | ||
173 | } | ||
174 | + | ||
175 | +static bool do_2shift(DisasContext *s, arg_2shift *a, MVEGenTwoOpShiftFn fn, | ||
176 | + bool negateshift) | ||
177 | +{ | ||
178 | + TCGv_ptr qd, qm; | ||
179 | + int shift = a->shift; | ||
180 | + | ||
181 | + if (!dc_isar_feature(aa32_mve, s) || | ||
182 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | ||
183 | + !fn) { | ||
184 | + return false; | ||
185 | + } | ||
186 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
187 | + return true; | ||
188 | + } | ||
189 | + | ||
190 | + /* | ||
191 | + * When we handle a right shift insn using a left-shift helper | ||
192 | + * which permits a negative shift count to indicate a right-shift, | ||
193 | + * we must negate the shift count. | ||
194 | + */ | ||
195 | + if (negateshift) { | ||
196 | + shift = -shift; | ||
197 | + } | ||
198 | + | ||
199 | + qd = mve_qreg_ptr(a->qd); | ||
200 | + qm = mve_qreg_ptr(a->qm); | ||
201 | + fn(cpu_env, qd, qm, tcg_constant_i32(shift)); | ||
202 | + tcg_temp_free_ptr(qd); | ||
203 | + tcg_temp_free_ptr(qm); | ||
204 | + mve_update_eci(s); | ||
205 | + return true; | ||
206 | +} | ||
207 | + | ||
208 | +#define DO_2SHIFT(INSN, FN, NEGATESHIFT) \ | ||
209 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
210 | + { \ | ||
211 | + static MVEGenTwoOpShiftFn * 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_2shift(s, a, fns[a->size], NEGATESHIFT); \ | ||
218 | + } | ||
219 | + | ||
220 | +DO_2SHIFT(VSHLI, vshli_u, false) | ||
221 | +DO_2SHIFT(VQSHLI_S, vqshli_s, false) | ||
222 | +DO_2SHIFT(VQSHLI_U, vqshli_u, false) | ||
223 | +DO_2SHIFT(VQSHLUI, vqshlui_s, false) | ||
224 | -- | ||
225 | 2.20.1 | ||
226 | |||
227 | diff view generated by jsdifflib |