1 | Nothing too exciting, but does include the last bits of v8.1M support work. | 1 | First set of arm patches for 6.2. I have a lot more in my |
---|---|---|---|
2 | to-review queue still... | ||
2 | 3 | ||
3 | -- PMM | 4 | -- PMM |
4 | 5 | ||
5 | The following changes since commit e79de63ab1bd1f6550e7b915e433bec1ad1a870a: | 6 | The following changes since commit d42685765653ec155fdf60910662f8830bdb2cef: |
6 | 7 | ||
7 | Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210107' into staging (2021-01-07 20:34:05 +0000) | 8 | Open 6.2 development tree (2021-08-25 10:25:12 +0100) |
8 | 9 | ||
9 | are available in the Git repository at: | 10 | are available in the Git repository at: |
10 | 11 | ||
11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210108 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210825 |
12 | 13 | ||
13 | for you to fetch changes up to c9f8511ea8d2b80723af0fea1f716d752c1b5208: | 14 | for you to fetch changes up to 24b1a6aa43615be22c7ee66bd68ec5675f6a6a9a: |
14 | 15 | ||
15 | docs/system: arm: Add sabrelite board description (2021-01-08 15:13:39 +0000) | 16 | docs: Document how to use gdb with unix sockets (2021-08-25 10:48:51 +0100) |
16 | 17 | ||
17 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
18 | target-arm queue: | 19 | target-arm queue: |
19 | * intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs | 20 | * More MVE emulation work |
20 | * target/arm: Fix MTE0_ACTIVE | 21 | * Implement M-profile trapping on division by zero |
21 | * target/arm: Implement v8.1M and Cortex-M55 model | 22 | * kvm: use RCU_READ_LOCK_GUARD() in kvm_arch_fixup_msi_route() |
22 | * hw/arm/highbank: Drop dead KVM support code | 23 | * hw/char/pl011: add support for sending break |
23 | * util/qemu-timer: Make timer_free() imply timer_del() | 24 | * fsl-imx6ul: Instantiate SAI1/2/3 and ASRC as unimplemented devices |
24 | * various devices: Use ptimer_free() in finalize function | 25 | * hw/dma/pl330: Add memory region to replace default |
25 | * docs/system: arm: Add sabrelite board description | 26 | * sbsa-ref: Rename SBSA_GWDT enum value |
26 | * sabrelite: Minor fixes to allow booting U-Boot | 27 | * fsl-imx7: Instantiate SAI1/2/3 as unimplemented devices |
28 | * docs: Document how to use gdb with unix sockets | ||
27 | 29 | ||
28 | ---------------------------------------------------------------- | 30 | ---------------------------------------------------------------- |
29 | Andrew Jones (1): | 31 | Eduardo Habkost (1): |
30 | hw/arm/virt: Remove virt machine state 'smp_cpus' | 32 | sbsa-ref: Rename SBSA_GWDT enum value |
31 | 33 | ||
32 | Bin Meng (4): | 34 | Guenter Roeck (2): |
33 | hw/misc: imx6_ccm: Update PMU_MISC0 reset value | 35 | fsl-imx6ul: Instantiate SAI1/2/3 and ASRC as unimplemented devices |
34 | hw/msic: imx6_ccm: Correct register value for silicon type | 36 | fsl-imx7: Instantiate SAI1/2/3 as unimplemented devices |
35 | hw/arm: sabrelite: Connect the Ethernet PHY at address 6 | ||
36 | docs/system: arm: Add sabrelite board description | ||
37 | 37 | ||
38 | Edgar E. Iglesias (1): | 38 | Hamza Mahfooz (1): |
39 | intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs | 39 | target/arm: kvm: use RCU_READ_LOCK_GUARD() in kvm_arch_fixup_msi_route() |
40 | 40 | ||
41 | Gan Qixin (7): | 41 | Jan Luebbe (1): |
42 | digic-timer: Use ptimer_free() in the finalize function to avoid memleaks | 42 | hw/char/pl011: add support for sending break |
43 | allwinner-a10-pit: Use ptimer_free() in the finalize function to avoid memleaks | ||
44 | exynos4210_rtc: Use ptimer_free() in the finalize function to avoid memleaks | ||
45 | exynos4210_pwm: Use ptimer_free() in the finalize function to avoid memleaks | ||
46 | mss-timer: Use ptimer_free() in the finalize function to avoid memleaks | ||
47 | musicpal: Use ptimer_free() in the finalize function to avoid memleaks | ||
48 | exynos4210_mct: Use ptimer_free() in the finalize function to avoid memleaks | ||
49 | 43 | ||
50 | Peter Maydell (9): | 44 | Peter Maydell (37): |
51 | hw/intc/armv7m_nvic: Correct handling of CCR.BFHFNMIGN | 45 | target/arm: Note that we handle VMOVL as a special case of VSHLL |
52 | target/arm: Correct store of FPSCR value via FPCXT_S | 46 | target/arm: Print MVE VPR in CPU dumps |
53 | target/arm: Implement FPCXT_NS fp system register | 47 | target/arm: Fix MVE VSLI by 0 and VSRI by <dt> |
54 | target/arm: Implement Cortex-M55 model | 48 | target/arm: Fix signed VADDV |
55 | hw/arm/highbank: Drop dead KVM support code | 49 | target/arm: Fix mask handling for MVE narrowing operations |
56 | util/qemu-timer: Make timer_free() imply timer_del() | 50 | target/arm: Fix 48-bit saturating shifts |
57 | scripts/coccinelle: New script to remove unnecessary timer_del() calls | 51 | target/arm: Fix MVE 48-bit SQRSHRL for small right shifts |
58 | Remove superfluous timer_del() calls | 52 | target/arm: Fix calculation of LTP mask when LR is 0 |
59 | target/arm: Remove timer_del()/timer_deinit() before timer_free() | 53 | target/arm: Factor out mve_eci_mask() |
54 | target/arm: Fix VPT advance when ECI is non-zero | ||
55 | target/arm: Fix VLDRB/H/W for predicated elements | ||
56 | target/arm: Implement MVE VMULL (polynomial) | ||
57 | target/arm: Implement MVE incrementing/decrementing dup insns | ||
58 | target/arm: Factor out gen_vpst() | ||
59 | target/arm: Implement MVE integer vector comparisons | ||
60 | target/arm: Implement MVE integer vector-vs-scalar comparisons | ||
61 | target/arm: Implement MVE VPSEL | ||
62 | target/arm: Implement MVE VMLAS | ||
63 | target/arm: Implement MVE shift-by-scalar | ||
64 | target/arm: Move 'x' and 'a' bit definitions into vmlaldav formats | ||
65 | target/arm: Implement MVE integer min/max across vector | ||
66 | target/arm: Implement MVE VABAV | ||
67 | target/arm: Implement MVE narrowing moves | ||
68 | target/arm: Rename MVEGenDualAccOpFn to MVEGenLongDualAccOpFn | ||
69 | target/arm: Implement MVE VMLADAV and VMLSLDAV | ||
70 | target/arm: Implement MVE VMLA | ||
71 | target/arm: Implement MVE saturating doubling multiply accumulates | ||
72 | target/arm: Implement MVE VQABS, VQNEG | ||
73 | target/arm: Implement MVE VMAXA, VMINA | ||
74 | target/arm: Implement MVE VMOV to/from 2 general-purpose registers | ||
75 | target/arm: Implement MVE VPNOT | ||
76 | target/arm: Implement MVE VCTP | ||
77 | target/arm: Implement MVE scatter-gather insns | ||
78 | target/arm: Implement MVE scatter-gather immediate forms | ||
79 | target/arm: Implement MVE interleaving loads/stores | ||
80 | target/arm: Re-indent sdiv and udiv helpers | ||
81 | target/arm: Implement M-profile trapping on division by zero | ||
60 | 82 | ||
61 | Richard Henderson (1): | 83 | Sebastian Meyer (1): |
62 | target/arm: Fix MTE0_ACTIVE | 84 | docs: Document how to use gdb with unix sockets |
63 | 85 | ||
64 | docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++ | 86 | Wen, Jianxian (1): |
65 | docs/system/target-arm.rst | 1 + | 87 | hw/dma/pl330: Add memory region to replace default |
66 | scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++ | ||
67 | include/hw/arm/virt.h | 3 +- | ||
68 | include/qemu/timer.h | 24 +++--- | ||
69 | block/iscsi.c | 2 - | ||
70 | block/nbd.c | 1 - | ||
71 | block/qcow2.c | 1 - | ||
72 | hw/arm/highbank.c | 14 +-- | ||
73 | hw/arm/musicpal.c | 12 +++ | ||
74 | hw/arm/sabrelite.c | 4 + | ||
75 | hw/arm/virt-acpi-build.c | 9 +- | ||
76 | hw/arm/virt.c | 21 +++-- | ||
77 | hw/block/nvme.c | 2 - | ||
78 | hw/char/serial.c | 2 - | ||
79 | hw/char/virtio-serial-bus.c | 2 - | ||
80 | hw/ide/core.c | 1 - | ||
81 | hw/input/hid.c | 1 - | ||
82 | hw/intc/apic.c | 1 - | ||
83 | hw/intc/arm_gic.c | 4 +- | ||
84 | hw/intc/armv7m_nvic.c | 15 ++++ | ||
85 | hw/intc/ioapic.c | 1 - | ||
86 | hw/ipmi/ipmi_bmc_extern.c | 1 - | ||
87 | hw/misc/imx6_ccm.c | 4 +- | ||
88 | hw/net/e1000.c | 3 - | ||
89 | hw/net/e1000e_core.c | 8 -- | ||
90 | hw/net/pcnet-pci.c | 1 - | ||
91 | hw/net/rtl8139.c | 1 - | ||
92 | hw/net/spapr_llan.c | 1 - | ||
93 | hw/net/virtio-net.c | 2 - | ||
94 | hw/rtc/exynos4210_rtc.c | 9 ++ | ||
95 | hw/s390x/s390-pci-inst.c | 1 - | ||
96 | hw/sd/sd.c | 1 - | ||
97 | hw/sd/sdhci.c | 2 - | ||
98 | hw/timer/allwinner-a10-pit.c | 11 +++ | ||
99 | hw/timer/digic-timer.c | 8 ++ | ||
100 | hw/timer/exynos4210_mct.c | 14 +++ | ||
101 | hw/timer/exynos4210_pwm.c | 11 +++ | ||
102 | hw/timer/mss-timer.c | 13 +++ | ||
103 | hw/usb/dev-hub.c | 1 - | ||
104 | hw/usb/hcd-ehci.c | 1 - | ||
105 | hw/usb/hcd-ohci-pci.c | 1 - | ||
106 | hw/usb/hcd-uhci.c | 1 - | ||
107 | hw/usb/hcd-xhci.c | 1 - | ||
108 | hw/usb/redirect.c | 1 - | ||
109 | hw/vfio/display.c | 1 - | ||
110 | hw/virtio/vhost-vsock-common.c | 1 - | ||
111 | hw/virtio/virtio-balloon.c | 1 - | ||
112 | hw/virtio/virtio-rng.c | 1 - | ||
113 | hw/watchdog/wdt_diag288.c | 1 - | ||
114 | hw/watchdog/wdt_i6300esb.c | 1 - | ||
115 | migration/colo.c | 1 - | ||
116 | monitor/hmp-cmds.c | 1 - | ||
117 | net/announce.c | 1 - | ||
118 | net/colo-compare.c | 1 - | ||
119 | net/slirp.c | 1 - | ||
120 | replay/replay-debugging.c | 1 - | ||
121 | target/arm/cpu.c | 2 - | ||
122 | target/arm/cpu_tcg.c | 42 +++++++++ | ||
123 | target/arm/helper.c | 2 +- | ||
124 | target/s390x/cpu.c | 2 - | ||
125 | ui/console.c | 1 - | ||
126 | ui/spice-core.c | 1 - | ||
127 | util/throttle.c | 1 - | ||
128 | target/arm/translate-vfp.c.inc | 114 ++++++++++++++++++++++-- | ||
129 | 65 files changed, 421 insertions(+), 111 deletions(-) | ||
130 | create mode 100644 docs/system/arm/sabrelite.rst | ||
131 | create mode 100644 scripts/coccinelle/timer-del-timer-free.cocci | ||
132 | 88 | ||
89 | docs/system/gdb.rst | 26 +- | ||
90 | include/hw/arm/fsl-imx7.h | 5 + | ||
91 | target/arm/cpu.h | 1 + | ||
92 | target/arm/helper-mve.h | 283 ++++++++++ | ||
93 | target/arm/helper.h | 4 +- | ||
94 | target/arm/translate-a32.h | 2 + | ||
95 | target/arm/vec_internal.h | 11 + | ||
96 | target/arm/mve.decode | 226 +++++++- | ||
97 | target/arm/t32.decode | 1 + | ||
98 | hw/arm/exynos4210.c | 3 + | ||
99 | hw/arm/fsl-imx6ul.c | 12 + | ||
100 | hw/arm/fsl-imx7.c | 7 + | ||
101 | hw/arm/sbsa-ref.c | 6 +- | ||
102 | hw/arm/xilinx_zynq.c | 3 + | ||
103 | hw/char/pl011.c | 6 + | ||
104 | hw/dma/pl330.c | 26 +- | ||
105 | target/arm/cpu.c | 3 + | ||
106 | target/arm/helper.c | 34 +- | ||
107 | target/arm/kvm.c | 17 +- | ||
108 | target/arm/m_helper.c | 4 + | ||
109 | target/arm/mve_helper.c | 1254 ++++++++++++++++++++++++++++++++++++++++++-- | ||
110 | target/arm/translate-mve.c | 877 ++++++++++++++++++++++++++++++- | ||
111 | target/arm/translate-vfp.c | 2 +- | ||
112 | target/arm/translate.c | 37 +- | ||
113 | target/arm/vec_helper.c | 14 +- | ||
114 | 25 files changed, 2746 insertions(+), 118 deletions(-) | ||
115 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Although the architecture doesn't define it as an alias, VMOVL | ||
2 | (vector move long) is encoded as a VSHLL with a zero shift. | ||
3 | Add a comment in the decode file noting that we handle VMOVL | ||
4 | as part of VSHLL. | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | target/arm/mve.decode | 2 ++ | ||
10 | 1 file changed, 2 insertions(+) | ||
11 | |||
12 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/mve.decode | ||
15 | +++ b/target/arm/mve.decode | ||
16 | @@ -XXX,XX +XXX,XX @@ VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
17 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
18 | |||
19 | # VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file | ||
20 | +# Note that VMOVL is encoded as "VSHLL with a zero shift count"; we | ||
21 | +# implement it that way rather than special-casing it in the decode. | ||
22 | VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | ||
23 | VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | ||
24 | |||
25 | -- | ||
26 | 2.20.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
1 | The Arm CPU finalize function uses a sequence of timer_del(), timer_deinit(), | 1 | Include the MVE VPR register value in the CPU dumps produced by |
---|---|---|---|
2 | timer_free() to free the timer. The timer_deinit() step in this was always | 2 | arm_cpu_dump_state() if we are printing FPU information. This |
3 | unnecessary, and now the timer_del() is implied by timer_free(), so we can | 3 | makes it easier to interpret debug logs when predication is |
4 | collapse this down to simply calling timer_free(). | 4 | active. |
5 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201215154107.3255-5-peter.maydell@linaro.org | ||
10 | --- | 8 | --- |
11 | target/arm/cpu.c | 2 -- | 9 | target/arm/cpu.c | 3 +++ |
12 | 1 file changed, 2 deletions(-) | 10 | 1 file changed, 3 insertions(+) |
13 | 11 | ||
14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 12 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 14 | --- a/target/arm/cpu.c |
17 | +++ b/target/arm/cpu.c | 15 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_finalizefn(Object *obj) | 16 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
17 | i, v); | ||
18 | } | ||
19 | qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); | ||
20 | + if (cpu_isar_feature(aa32_mve, cpu)) { | ||
21 | + qemu_fprintf(f, "VPR: %08x\n", env->v7m.vpr); | ||
22 | + } | ||
19 | } | 23 | } |
20 | #ifndef CONFIG_USER_ONLY | 24 | } |
21 | if (cpu->pmu_timer) { | 25 | |
22 | - timer_del(cpu->pmu_timer); | ||
23 | - timer_deinit(cpu->pmu_timer); | ||
24 | timer_free(cpu->pmu_timer); | ||
25 | } | ||
26 | #endif | ||
27 | -- | 26 | -- |
28 | 2.20.1 | 27 | 2.20.1 |
29 | 28 | ||
30 | 29 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In the MVE shift-and-insert insns, we special case VSLI by 0 | ||
2 | and VSRI by <dt>. VSRI by <dt> means "don't update the destination", | ||
3 | which is what we've implemented. However VSLI by 0 is "set | ||
4 | destination to the input", so we don't want to use the same | ||
5 | special-casing that we do for VSRI by <dt>. | ||
1 | 6 | ||
7 | Since the generic logic gives the right answer for a shift | ||
8 | by 0, just use that. | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | target/arm/mve_helper.c | 9 +++++---- | ||
14 | 1 file changed, 5 insertions(+), 4 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/mve_helper.c | ||
19 | +++ b/target/arm/mve_helper.c | ||
20 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
21 | uint16_t mask; \ | ||
22 | uint64_t shiftmask; \ | ||
23 | unsigned e; \ | ||
24 | - if (shift == 0 || shift == ESIZE * 8) { \ | ||
25 | + if (shift == ESIZE * 8) { \ | ||
26 | /* \ | ||
27 | - * Only VSLI can shift by 0; only VSRI can shift by <dt>. \ | ||
28 | - * The generic logic would give the right answer for 0 but \ | ||
29 | - * fails for <dt>. \ | ||
30 | + * Only VSRI can shift by <dt>; it should mean "don't \ | ||
31 | + * update the destination". The generic logic can't handle \ | ||
32 | + * this because it would try to shift by an out-of-range \ | ||
33 | + * amount, so special case it here. \ | ||
34 | */ \ | ||
35 | goto done; \ | ||
36 | } \ | ||
37 | -- | ||
38 | 2.20.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | A cut-and-paste error meant we handled signed VADDV like | ||
2 | unsigned VADDV; fix the type used. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/mve_helper.c | 6 +++--- | ||
8 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
9 | |||
10 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/arm/mve_helper.c | ||
13 | +++ b/target/arm/mve_helper.c | ||
14 | @@ -XXX,XX +XXX,XX @@ DO_LDAVH(vrmlsldavhxsw, int32_t, int64_t, true, true) | ||
15 | return ra; \ | ||
16 | } \ | ||
17 | |||
18 | -DO_VADDV(vaddvsb, 1, uint8_t) | ||
19 | -DO_VADDV(vaddvsh, 2, uint16_t) | ||
20 | -DO_VADDV(vaddvsw, 4, uint32_t) | ||
21 | +DO_VADDV(vaddvsb, 1, int8_t) | ||
22 | +DO_VADDV(vaddvsh, 2, int16_t) | ||
23 | +DO_VADDV(vaddvsw, 4, int32_t) | ||
24 | DO_VADDV(vaddvub, 1, uint8_t) | ||
25 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
26 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In the MVE helpers for the narrowing operations (DO_VSHRN and | ||
2 | DO_VSHRN_SAT) we were using the wrong bits of the predicate mask for | ||
3 | the 'top' versions of the insn. This is because the loop works over | ||
4 | the double-sized input elements and shifts the predicate mask by that | ||
5 | many bits each time, but when we write out the half-sized output we | ||
6 | must look at the mask bits for whichever half of the element we are | ||
7 | writing to. | ||
1 | 8 | ||
9 | Correct this by shifting the whole mask right by ESIZE bits for the | ||
10 | 'top' insns. This allows us also to simplify the saturation bit | ||
11 | checking (where we had noticed that we needed to look at a different | ||
12 | mask bit for the 'top' insn.) | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | ||
17 | target/arm/mve_helper.c | 4 +++- | ||
18 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/mve_helper.c | ||
23 | +++ b/target/arm/mve_helper.c | ||
24 | @@ -XXX,XX +XXX,XX @@ DO_VSHLL_ALL(vshllt, true) | ||
25 | TYPE *d = vd; \ | ||
26 | uint16_t mask = mve_element_mask(env); \ | ||
27 | unsigned le; \ | ||
28 | + mask >>= ESIZE * TOP; \ | ||
29 | for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
30 | TYPE r = FN(m[H##LESIZE(le)], shift); \ | ||
31 | mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
32 | @@ -XXX,XX +XXX,XX @@ static inline int32_t do_sat_bhs(int64_t val, int64_t min, int64_t max, | ||
33 | uint16_t mask = mve_element_mask(env); \ | ||
34 | bool qc = false; \ | ||
35 | unsigned le; \ | ||
36 | + mask >>= ESIZE * TOP; \ | ||
37 | for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
38 | bool sat = false; \ | ||
39 | TYPE r = FN(m[H##LESIZE(le)], shift, &sat); \ | ||
40 | mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
41 | - qc |= sat && (mask & 1 << (TOP * ESIZE)); \ | ||
42 | + qc |= sat & mask & 1; \ | ||
43 | } \ | ||
44 | if (qc) { \ | ||
45 | env->vfp.qc[0] = qc; \ | ||
46 | -- | ||
47 | 2.20.1 | ||
48 | |||
49 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In do_sqrshl48_d() and do_uqrshl48_d() we got some of the edge | ||
2 | cases wrong and failed to saturate correctly: | ||
1 | 3 | ||
4 | (1) In do_sqrshl48_d() we used the same code that do_shrshl_bhs() | ||
5 | does to obtain the saturated most-negative and most-positive 48-bit | ||
6 | signed values for the large-shift-left case. This gives (1 << 47) | ||
7 | for saturate-to-most-negative, but we weren't sign-extending this | ||
8 | value to the 64-bit output as the pseudocode requires. | ||
9 | |||
10 | (2) For left shifts by less than 48, we copied the "8/16 bit" code | ||
11 | from do_sqrshl_bhs() and do_uqrshl_bhs(). This doesn't do the right | ||
12 | thing because it assumes the C type we're working with is at least | ||
13 | twice the number of bits we're saturating to (so that a shift left by | ||
14 | bits-1 can't shift anything off the top of the value). This isn't | ||
15 | true for bits == 48, so we would incorrectly return 0 rather than the | ||
16 | most-positive value for situations like "shift (1 << 44) right by | ||
17 | 20". Instead check for saturation by doing the shift and signextend | ||
18 | and then testing whether shifting back left again gives the original | ||
19 | value. | ||
20 | |||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
23 | --- | ||
24 | target/arm/mve_helper.c | 12 +++++------- | ||
25 | 1 file changed, 5 insertions(+), 7 deletions(-) | ||
26 | |||
27 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/mve_helper.c | ||
30 | +++ b/target/arm/mve_helper.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
32 | } | ||
33 | return src >> -shift; | ||
34 | } else if (shift < 48) { | ||
35 | - int64_t val = src << shift; | ||
36 | - int64_t extval = sextract64(val, 0, 48); | ||
37 | - if (!sat || val == extval) { | ||
38 | + int64_t extval = sextract64(src << shift, 0, 48); | ||
39 | + if (!sat || src == (extval >> shift)) { | ||
40 | return extval; | ||
41 | } | ||
42 | } else if (!sat || src == 0) { | ||
43 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
44 | } | ||
45 | |||
46 | *sat = 1; | ||
47 | - return (1ULL << 47) - (src >= 0); | ||
48 | + return src >= 0 ? MAKE_64BIT_MASK(0, 47) : MAKE_64BIT_MASK(47, 17); | ||
49 | } | ||
50 | |||
51 | /* Operate on 64-bit values, but saturate at 48 bits */ | ||
52 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t do_uqrshl48_d(uint64_t src, int64_t shift, | ||
53 | return extval; | ||
54 | } | ||
55 | } else if (shift < 48) { | ||
56 | - uint64_t val = src << shift; | ||
57 | - uint64_t extval = extract64(val, 0, 48); | ||
58 | - if (!sat || val == extval) { | ||
59 | + uint64_t extval = extract64(src << shift, 0, 48); | ||
60 | + if (!sat || src == (extval >> shift)) { | ||
61 | return extval; | ||
62 | } | ||
63 | } else if (!sat || src == 0) { | ||
64 | -- | ||
65 | 2.20.1 | ||
66 | |||
67 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We got an edge case wrong in the 48-bit SQRSHRL implementation: if | ||
2 | the shift is to the right, although it always makes the result | ||
3 | smaller than the input value it might not be within the 48-bit range | ||
4 | the result is supposed to be if the input had some bits in [63..48] | ||
5 | set and the shift didn't bring all of those within the [47..0] range. | ||
1 | 6 | ||
7 | Handle this similarly to the way we already do for this case in | ||
8 | do_uqrshl48_d(): extend the calculated result from 48 bits, | ||
9 | and return that if not saturating or if it doesn't change the | ||
10 | result; otherwise fall through to return a saturated value. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | --- | ||
15 | target/arm/mve_helper.c | 11 +++++++++-- | ||
16 | 1 file changed, 9 insertions(+), 2 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/mve_helper.c | ||
21 | +++ b/target/arm/mve_helper.c | ||
22 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqrshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
23 | static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
24 | bool round, uint32_t *sat) | ||
25 | { | ||
26 | + int64_t val, extval; | ||
27 | + | ||
28 | if (shift <= -48) { | ||
29 | /* Rounding the sign bit always produces 0. */ | ||
30 | if (round) { | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
32 | } else if (shift < 0) { | ||
33 | if (round) { | ||
34 | src >>= -shift - 1; | ||
35 | - return (src >> 1) + (src & 1); | ||
36 | + val = (src >> 1) + (src & 1); | ||
37 | + } else { | ||
38 | + val = src >> -shift; | ||
39 | + } | ||
40 | + extval = sextract64(val, 0, 48); | ||
41 | + if (!sat || val == extval) { | ||
42 | + return extval; | ||
43 | } | ||
44 | - return src >> -shift; | ||
45 | } else if (shift < 48) { | ||
46 | int64_t extval = sextract64(src << shift, 0, 48); | ||
47 | if (!sat || src == (extval >> shift)) { | ||
48 | -- | ||
49 | 2.20.1 | ||
50 | |||
51 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In mve_element_mask(), we calculate a mask for tail predication which | ||
2 | should have a number of 1 bits based on the value of LR. However, | ||
3 | our MAKE_64BIT_MASK() macro has undefined behaviour when passed a | ||
4 | zero length. Special case this to give the all-zeroes mask we | ||
5 | require. | ||
1 | 6 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | target/arm/mve_helper.c | 3 ++- | ||
11 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/mve_helper.c | ||
16 | +++ b/target/arm/mve_helper.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static uint16_t mve_element_mask(CPUARMState *env) | ||
18 | */ | ||
19 | int masklen = env->regs[14] << env->v7m.ltpsize; | ||
20 | assert(masklen <= 16); | ||
21 | - mask &= MAKE_64BIT_MASK(0, masklen); | ||
22 | + uint16_t ltpmask = masklen ? MAKE_64BIT_MASK(0, masklen) : 0; | ||
23 | + mask &= ltpmask; | ||
24 | } | ||
25 | |||
26 | if ((env->condexec_bits & 0xf) == 0) { | ||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | In some situations we need a mask telling us which parts of the |
---|---|---|---|
2 | vector correspond to beats that are not being executed because of | ||
3 | ECI, separately from the combined "which bytes are predicated away" | ||
4 | mask. Factor this mask calculation out of mve_element_mask() into | ||
5 | its own function. | ||
2 | 6 | ||
3 | When running device-introspect-test, a memory leak occurred in the | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | exynos4210_mct_init function, so use ptimer_free() in the finalize function to | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | avoid it. | 9 | --- |
10 | target/arm/mve_helper.c | 58 ++++++++++++++++++++++++----------------- | ||
11 | 1 file changed, 34 insertions(+), 24 deletions(-) | ||
6 | 12 | ||
7 | ASAN shows memory leak stack: | 13 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
8 | |||
9 | Indirect leak of 96 byte(s) in 1 object(s) allocated from: | ||
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf56b01a0 in exynos4210_mct_init /qemu/hw/timer/exynos4210_mct.c:1505 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
16 | #6 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
17 | #7 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
18 | #8 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
19 | #9 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136 | ||
20 | #10 0xaaabf6552708 in aio_bh_poll /qemu/util/async.c:164 | ||
21 | #11 0xaaabf655f19c in aio_dispatch /qemu/util/aio-posix.c:381 | ||
22 | #12 0xaaabf65523f4 in aio_ctx_dispatch /qemu/util/async.c:306 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
28 | --- | ||
29 | hw/timer/exynos4210_mct.c | 14 ++++++++++++++ | ||
30 | 1 file changed, 14 insertions(+) | ||
31 | |||
32 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/timer/exynos4210_mct.c | 15 | --- a/target/arm/mve_helper.c |
35 | +++ b/hw/timer/exynos4210_mct.c | 16 | +++ b/target/arm/mve_helper.c |
36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_init(Object *obj) | 17 | @@ -XXX,XX +XXX,XX @@ |
37 | sysbus_init_mmio(dev, &s->iomem); | 18 | #include "exec/exec-all.h" |
38 | } | 19 | #include "tcg/tcg.h" |
39 | 20 | ||
40 | +static void exynos4210_mct_finalize(Object *obj) | 21 | +static uint16_t mve_eci_mask(CPUARMState *env) |
41 | +{ | 22 | +{ |
42 | + int i; | 23 | + /* |
43 | + Exynos4210MCTState *s = EXYNOS4210_MCT(obj); | 24 | + * Return the mask of which elements in the MVE vector correspond |
25 | + * to beats being executed. The mask has 1 bits for executed lanes | ||
26 | + * and 0 bits where ECI says this beat was already executed. | ||
27 | + */ | ||
28 | + int eci; | ||
44 | + | 29 | + |
45 | + ptimer_free(s->g_timer.ptimer_frc); | 30 | + if ((env->condexec_bits & 0xf) != 0) { |
31 | + return 0xffff; | ||
32 | + } | ||
46 | + | 33 | + |
47 | + for (i = 0; i < 2; i++) { | 34 | + eci = env->condexec_bits >> 4; |
48 | + ptimer_free(s->l_timer[i].tick_timer.ptimer_tick); | 35 | + switch (eci) { |
49 | + ptimer_free(s->l_timer[i].ptimer_frc); | 36 | + case ECI_NONE: |
37 | + return 0xffff; | ||
38 | + case ECI_A0: | ||
39 | + return 0xfff0; | ||
40 | + case ECI_A0A1: | ||
41 | + return 0xff00; | ||
42 | + case ECI_A0A1A2: | ||
43 | + case ECI_A0A1A2B0: | ||
44 | + return 0xf000; | ||
45 | + default: | ||
46 | + g_assert_not_reached(); | ||
50 | + } | 47 | + } |
51 | +} | 48 | +} |
52 | + | 49 | + |
53 | static void exynos4210_mct_class_init(ObjectClass *klass, void *data) | 50 | static uint16_t mve_element_mask(CPUARMState *env) |
54 | { | 51 | { |
55 | DeviceClass *dc = DEVICE_CLASS(klass); | 52 | /* |
56 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_mct_info = { | 53 | @@ -XXX,XX +XXX,XX @@ static uint16_t mve_element_mask(CPUARMState *env) |
57 | .parent = TYPE_SYS_BUS_DEVICE, | 54 | mask &= ltpmask; |
58 | .instance_size = sizeof(Exynos4210MCTState), | 55 | } |
59 | .instance_init = exynos4210_mct_init, | 56 | |
60 | + .instance_finalize = exynos4210_mct_finalize, | 57 | - if ((env->condexec_bits & 0xf) == 0) { |
61 | .class_init = exynos4210_mct_class_init, | 58 | - /* |
62 | }; | 59 | - * ECI bits indicate which beats are already executed; |
60 | - * we handle this by effectively predicating them out. | ||
61 | - */ | ||
62 | - int eci = env->condexec_bits >> 4; | ||
63 | - switch (eci) { | ||
64 | - case ECI_NONE: | ||
65 | - break; | ||
66 | - case ECI_A0: | ||
67 | - mask &= 0xfff0; | ||
68 | - break; | ||
69 | - case ECI_A0A1: | ||
70 | - mask &= 0xff00; | ||
71 | - break; | ||
72 | - case ECI_A0A1A2: | ||
73 | - case ECI_A0A1A2B0: | ||
74 | - mask &= 0xf000; | ||
75 | - break; | ||
76 | - default: | ||
77 | - g_assert_not_reached(); | ||
78 | - } | ||
79 | - } | ||
80 | - | ||
81 | + /* | ||
82 | + * ECI bits indicate which beats are already executed; | ||
83 | + * we handle this by effectively predicating them out. | ||
84 | + */ | ||
85 | + mask &= mve_eci_mask(env); | ||
86 | return mask; | ||
87 | } | ||
63 | 88 | ||
64 | -- | 89 | -- |
65 | 2.20.1 | 90 | 2.20.1 |
66 | 91 | ||
67 | 92 | diff view generated by jsdifflib |
1 | This commit is the result of running the timer-del-timer-free.cocci | 1 | We were not paying attention to the ECI state when advancing the VPT |
---|---|---|---|
2 | script on the whole source tree. | 2 | state. Architecturally, VPT state advance happens for every beat |
3 | (see the pseudocode VPTAdvance()), so on every beat the 4 bits of | ||
4 | VPR.P0 corresponding to the current beat are inverted if required, | ||
5 | and at the end of beats 1 and 3 the VPR MASK fields are updated. | ||
6 | This means that if the ECI state says we should not be executing all | ||
7 | 4 beats then we need to skip some of the updating of the VPR that we | ||
8 | currently do in mve_advance_vpt(). | ||
3 | 9 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Acked-by: Corey Minyard <cminyard@mvista.com> | ||
6 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201215154107.3255-4-peter.maydell@linaro.org | ||
10 | --- | 12 | --- |
11 | block/iscsi.c | 2 -- | 13 | target/arm/mve_helper.c | 24 +++++++++++++++++------- |
12 | block/nbd.c | 1 - | 14 | 1 file changed, 17 insertions(+), 7 deletions(-) |
13 | block/qcow2.c | 1 - | ||
14 | hw/block/nvme.c | 2 -- | ||
15 | hw/char/serial.c | 2 -- | ||
16 | hw/char/virtio-serial-bus.c | 2 -- | ||
17 | hw/ide/core.c | 1 - | ||
18 | hw/input/hid.c | 1 - | ||
19 | hw/intc/apic.c | 1 - | ||
20 | hw/intc/ioapic.c | 1 - | ||
21 | hw/ipmi/ipmi_bmc_extern.c | 1 - | ||
22 | hw/net/e1000.c | 3 --- | ||
23 | hw/net/e1000e_core.c | 8 -------- | ||
24 | hw/net/pcnet-pci.c | 1 - | ||
25 | hw/net/rtl8139.c | 1 - | ||
26 | hw/net/spapr_llan.c | 1 - | ||
27 | hw/net/virtio-net.c | 2 -- | ||
28 | hw/s390x/s390-pci-inst.c | 1 - | ||
29 | hw/sd/sd.c | 1 - | ||
30 | hw/sd/sdhci.c | 2 -- | ||
31 | hw/usb/dev-hub.c | 1 - | ||
32 | hw/usb/hcd-ehci.c | 1 - | ||
33 | hw/usb/hcd-ohci-pci.c | 1 - | ||
34 | hw/usb/hcd-uhci.c | 1 - | ||
35 | hw/usb/hcd-xhci.c | 1 - | ||
36 | hw/usb/redirect.c | 1 - | ||
37 | hw/vfio/display.c | 1 - | ||
38 | hw/virtio/vhost-vsock-common.c | 1 - | ||
39 | hw/virtio/virtio-balloon.c | 1 - | ||
40 | hw/virtio/virtio-rng.c | 1 - | ||
41 | hw/watchdog/wdt_diag288.c | 1 - | ||
42 | hw/watchdog/wdt_i6300esb.c | 1 - | ||
43 | migration/colo.c | 1 - | ||
44 | monitor/hmp-cmds.c | 1 - | ||
45 | net/announce.c | 1 - | ||
46 | net/colo-compare.c | 1 - | ||
47 | net/slirp.c | 1 - | ||
48 | replay/replay-debugging.c | 1 - | ||
49 | target/s390x/cpu.c | 2 -- | ||
50 | ui/console.c | 1 - | ||
51 | ui/spice-core.c | 1 - | ||
52 | util/throttle.c | 1 - | ||
53 | 42 files changed, 58 deletions(-) | ||
54 | 15 | ||
55 | diff --git a/block/iscsi.c b/block/iscsi.c | 16 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
56 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/block/iscsi.c | 18 | --- a/target/arm/mve_helper.c |
58 | +++ b/block/iscsi.c | 19 | +++ b/target/arm/mve_helper.c |
59 | @@ -XXX,XX +XXX,XX @@ static void iscsi_detach_aio_context(BlockDriverState *bs) | 20 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) |
60 | iscsilun->events = 0; | 21 | /* Advance the VPT and ECI state if necessary */ |
61 | 22 | uint32_t vpr = env->v7m.vpr; | |
62 | if (iscsilun->nop_timer) { | 23 | unsigned mask01, mask23; |
63 | - timer_del(iscsilun->nop_timer); | 24 | + uint16_t inv_mask; |
64 | timer_free(iscsilun->nop_timer); | 25 | + uint16_t eci_mask = mve_eci_mask(env); |
65 | iscsilun->nop_timer = NULL; | 26 | |
66 | } | 27 | if ((env->condexec_bits & 0xf) == 0) { |
67 | if (iscsilun->event_timer) { | 28 | env->condexec_bits = (env->condexec_bits == (ECI_A0A1A2B0 << 4)) ? |
68 | - timer_del(iscsilun->event_timer); | 29 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) |
69 | timer_free(iscsilun->event_timer); | ||
70 | iscsilun->event_timer = NULL; | ||
71 | } | ||
72 | diff --git a/block/nbd.c b/block/nbd.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/block/nbd.c | ||
75 | +++ b/block/nbd.c | ||
76 | @@ -XXX,XX +XXX,XX @@ static void nbd_recv_coroutines_wake_all(BDRVNBDState *s) | ||
77 | static void reconnect_delay_timer_del(BDRVNBDState *s) | ||
78 | { | ||
79 | if (s->reconnect_delay_timer) { | ||
80 | - timer_del(s->reconnect_delay_timer); | ||
81 | timer_free(s->reconnect_delay_timer); | ||
82 | s->reconnect_delay_timer = NULL; | ||
83 | } | ||
84 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/block/qcow2.c | ||
87 | +++ b/block/qcow2.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static void cache_clean_timer_del(BlockDriverState *bs) | ||
89 | { | ||
90 | BDRVQcow2State *s = bs->opaque; | ||
91 | if (s->cache_clean_timer) { | ||
92 | - timer_del(s->cache_clean_timer); | ||
93 | timer_free(s->cache_clean_timer); | ||
94 | s->cache_clean_timer = NULL; | ||
95 | } | ||
96 | diff --git a/hw/block/nvme.c b/hw/block/nvme.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/hw/block/nvme.c | ||
99 | +++ b/hw/block/nvme.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req) | ||
101 | static void nvme_free_sq(NvmeSQueue *sq, NvmeCtrl *n) | ||
102 | { | ||
103 | n->sq[sq->sqid] = NULL; | ||
104 | - timer_del(sq->timer); | ||
105 | timer_free(sq->timer); | ||
106 | g_free(sq->io_req); | ||
107 | if (sq->sqid) { | ||
108 | @@ -XXX,XX +XXX,XX @@ static uint16_t nvme_get_log(NvmeCtrl *n, NvmeRequest *req) | ||
109 | static void nvme_free_cq(NvmeCQueue *cq, NvmeCtrl *n) | ||
110 | { | ||
111 | n->cq[cq->cqid] = NULL; | ||
112 | - timer_del(cq->timer); | ||
113 | timer_free(cq->timer); | ||
114 | msix_vector_unuse(&n->parent_obj, cq->vector); | ||
115 | if (cq->cqid) { | ||
116 | diff --git a/hw/char/serial.c b/hw/char/serial.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/hw/char/serial.c | ||
119 | +++ b/hw/char/serial.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static void serial_unrealize(DeviceState *dev) | ||
121 | |||
122 | qemu_chr_fe_deinit(&s->chr, false); | ||
123 | |||
124 | - timer_del(s->modem_status_poll); | ||
125 | timer_free(s->modem_status_poll); | ||
126 | |||
127 | - timer_del(s->fifo_timeout_timer); | ||
128 | timer_free(s->fifo_timeout_timer); | ||
129 | |||
130 | fifo8_destroy(&s->recv_fifo); | ||
131 | diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/hw/char/virtio-serial-bus.c | ||
134 | +++ b/hw/char/virtio-serial-bus.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static void virtio_serial_post_load_timer_cb(void *opaque) | ||
136 | } | ||
137 | } | ||
138 | g_free(s->post_load->connected); | ||
139 | - timer_del(s->post_load->timer); | ||
140 | timer_free(s->post_load->timer); | ||
141 | g_free(s->post_load); | ||
142 | s->post_load = NULL; | ||
143 | @@ -XXX,XX +XXX,XX @@ static void virtio_serial_device_unrealize(DeviceState *dev) | ||
144 | g_free(vser->ports_map); | ||
145 | if (vser->post_load) { | ||
146 | g_free(vser->post_load->connected); | ||
147 | - timer_del(vser->post_load->timer); | ||
148 | timer_free(vser->post_load->timer); | ||
149 | g_free(vser->post_load); | ||
150 | } | ||
151 | diff --git a/hw/ide/core.c b/hw/ide/core.c | ||
152 | index XXXXXXX..XXXXXXX 100644 | ||
153 | --- a/hw/ide/core.c | ||
154 | +++ b/hw/ide/core.c | ||
155 | @@ -XXX,XX +XXX,XX @@ void ide_init2(IDEBus *bus, qemu_irq irq) | ||
156 | |||
157 | void ide_exit(IDEState *s) | ||
158 | { | ||
159 | - timer_del(s->sector_write_timer); | ||
160 | timer_free(s->sector_write_timer); | ||
161 | qemu_vfree(s->smart_selftest_data); | ||
162 | qemu_vfree(s->io_buffer); | ||
163 | diff --git a/hw/input/hid.c b/hw/input/hid.c | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/hw/input/hid.c | ||
166 | +++ b/hw/input/hid.c | ||
167 | @@ -XXX,XX +XXX,XX @@ static void hid_idle_timer(void *opaque) | ||
168 | static void hid_del_idle_timer(HIDState *hs) | ||
169 | { | ||
170 | if (hs->idle_timer) { | ||
171 | - timer_del(hs->idle_timer); | ||
172 | timer_free(hs->idle_timer); | ||
173 | hs->idle_timer = NULL; | ||
174 | } | ||
175 | diff --git a/hw/intc/apic.c b/hw/intc/apic.c | ||
176 | index XXXXXXX..XXXXXXX 100644 | ||
177 | --- a/hw/intc/apic.c | ||
178 | +++ b/hw/intc/apic.c | ||
179 | @@ -XXX,XX +XXX,XX @@ static void apic_unrealize(DeviceState *dev) | ||
180 | { | ||
181 | APICCommonState *s = APIC(dev); | ||
182 | |||
183 | - timer_del(s->timer); | ||
184 | timer_free(s->timer); | ||
185 | local_apics[s->id] = NULL; | ||
186 | } | ||
187 | diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c | ||
188 | index XXXXXXX..XXXXXXX 100644 | ||
189 | --- a/hw/intc/ioapic.c | ||
190 | +++ b/hw/intc/ioapic.c | ||
191 | @@ -XXX,XX +XXX,XX @@ static void ioapic_unrealize(DeviceState *dev) | ||
192 | { | ||
193 | IOAPICCommonState *s = IOAPIC_COMMON(dev); | ||
194 | |||
195 | - timer_del(s->delayed_ioapic_service_timer); | ||
196 | timer_free(s->delayed_ioapic_service_timer); | ||
197 | } | ||
198 | |||
199 | diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c | ||
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/hw/ipmi/ipmi_bmc_extern.c | ||
202 | +++ b/hw/ipmi/ipmi_bmc_extern.c | ||
203 | @@ -XXX,XX +XXX,XX @@ static void ipmi_bmc_extern_finalize(Object *obj) | ||
204 | { | ||
205 | IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj); | ||
206 | |||
207 | - timer_del(ibe->extern_timer); | ||
208 | timer_free(ibe->extern_timer); | ||
209 | } | ||
210 | |||
211 | diff --git a/hw/net/e1000.c b/hw/net/e1000.c | ||
212 | index XXXXXXX..XXXXXXX 100644 | ||
213 | --- a/hw/net/e1000.c | ||
214 | +++ b/hw/net/e1000.c | ||
215 | @@ -XXX,XX +XXX,XX @@ pci_e1000_uninit(PCIDevice *dev) | ||
216 | { | ||
217 | E1000State *d = E1000(dev); | ||
218 | |||
219 | - timer_del(d->autoneg_timer); | ||
220 | timer_free(d->autoneg_timer); | ||
221 | - timer_del(d->mit_timer); | ||
222 | timer_free(d->mit_timer); | ||
223 | - timer_del(d->flush_queue_timer); | ||
224 | timer_free(d->flush_queue_timer); | ||
225 | qemu_del_nic(d->nic); | ||
226 | } | ||
227 | diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c | ||
228 | index XXXXXXX..XXXXXXX 100644 | ||
229 | --- a/hw/net/e1000e_core.c | ||
230 | +++ b/hw/net/e1000e_core.c | ||
231 | @@ -XXX,XX +XXX,XX @@ e1000e_intrmgr_pci_unint(E1000ECore *core) | ||
232 | { | ||
233 | int i; | ||
234 | |||
235 | - timer_del(core->radv.timer); | ||
236 | timer_free(core->radv.timer); | ||
237 | - timer_del(core->rdtr.timer); | ||
238 | timer_free(core->rdtr.timer); | ||
239 | - timer_del(core->raid.timer); | ||
240 | timer_free(core->raid.timer); | ||
241 | |||
242 | - timer_del(core->tadv.timer); | ||
243 | timer_free(core->tadv.timer); | ||
244 | - timer_del(core->tidv.timer); | ||
245 | timer_free(core->tidv.timer); | ||
246 | |||
247 | - timer_del(core->itr.timer); | ||
248 | timer_free(core->itr.timer); | ||
249 | |||
250 | for (i = 0; i < E1000E_MSIX_VEC_NUM; i++) { | ||
251 | - timer_del(core->eitr[i].timer); | ||
252 | timer_free(core->eitr[i].timer); | ||
253 | } | ||
254 | } | ||
255 | @@ -XXX,XX +XXX,XX @@ e1000e_core_pci_uninit(E1000ECore *core) | ||
256 | { | ||
257 | int i; | ||
258 | |||
259 | - timer_del(core->autoneg_timer); | ||
260 | timer_free(core->autoneg_timer); | ||
261 | |||
262 | e1000e_intrmgr_pci_unint(core); | ||
263 | diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c | ||
264 | index XXXXXXX..XXXXXXX 100644 | ||
265 | --- a/hw/net/pcnet-pci.c | ||
266 | +++ b/hw/net/pcnet-pci.c | ||
267 | @@ -XXX,XX +XXX,XX @@ static void pci_pcnet_uninit(PCIDevice *dev) | ||
268 | PCIPCNetState *d = PCI_PCNET(dev); | ||
269 | |||
270 | qemu_free_irq(d->state.irq); | ||
271 | - timer_del(d->state.poll_timer); | ||
272 | timer_free(d->state.poll_timer); | ||
273 | qemu_del_nic(d->state.nic); | ||
274 | } | ||
275 | diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c | ||
276 | index XXXXXXX..XXXXXXX 100644 | ||
277 | --- a/hw/net/rtl8139.c | ||
278 | +++ b/hw/net/rtl8139.c | ||
279 | @@ -XXX,XX +XXX,XX @@ static void pci_rtl8139_uninit(PCIDevice *dev) | ||
280 | |||
281 | g_free(s->cplus_txbuffer); | ||
282 | s->cplus_txbuffer = NULL; | ||
283 | - timer_del(s->timer); | ||
284 | timer_free(s->timer); | ||
285 | qemu_del_nic(s->nic); | ||
286 | } | ||
287 | diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c | ||
288 | index XXXXXXX..XXXXXXX 100644 | ||
289 | --- a/hw/net/spapr_llan.c | ||
290 | +++ b/hw/net/spapr_llan.c | ||
291 | @@ -XXX,XX +XXX,XX @@ static void spapr_vlan_instance_finalize(Object *obj) | ||
292 | } | ||
293 | |||
294 | if (dev->rxp_timer) { | ||
295 | - timer_del(dev->rxp_timer); | ||
296 | timer_free(dev->rxp_timer); | ||
297 | } | ||
298 | } | ||
299 | diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c | ||
300 | index XXXXXXX..XXXXXXX 100644 | ||
301 | --- a/hw/net/virtio-net.c | ||
302 | +++ b/hw/net/virtio-net.c | ||
303 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_rsc_cleanup(VirtIONet *n) | ||
304 | g_free(seg); | ||
305 | } | ||
306 | |||
307 | - timer_del(chain->drain_timer); | ||
308 | timer_free(chain->drain_timer); | ||
309 | QTAILQ_REMOVE(&n->rsc_chains, chain, next); | ||
310 | g_free(chain); | ||
311 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_del_queue(VirtIONet *n, int index) | ||
312 | |||
313 | virtio_del_queue(vdev, index * 2); | ||
314 | if (q->tx_timer) { | ||
315 | - timer_del(q->tx_timer); | ||
316 | timer_free(q->tx_timer); | ||
317 | q->tx_timer = NULL; | ||
318 | } else { | ||
319 | diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c | ||
320 | index XXXXXXX..XXXXXXX 100644 | ||
321 | --- a/hw/s390x/s390-pci-inst.c | ||
322 | +++ b/hw/s390x/s390-pci-inst.c | ||
323 | @@ -XXX,XX +XXX,XX @@ void pci_dereg_ioat(S390PCIIOMMU *iommu) | ||
324 | void fmb_timer_free(S390PCIBusDevice *pbdev) | ||
325 | { | ||
326 | if (pbdev->fmb_timer) { | ||
327 | - timer_del(pbdev->fmb_timer); | ||
328 | timer_free(pbdev->fmb_timer); | ||
329 | pbdev->fmb_timer = NULL; | ||
330 | } | ||
331 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
332 | index XXXXXXX..XXXXXXX 100644 | ||
333 | --- a/hw/sd/sd.c | ||
334 | +++ b/hw/sd/sd.c | ||
335 | @@ -XXX,XX +XXX,XX @@ static void sd_instance_finalize(Object *obj) | ||
336 | { | ||
337 | SDState *sd = SD_CARD(obj); | ||
338 | |||
339 | - timer_del(sd->ocr_power_timer); | ||
340 | timer_free(sd->ocr_power_timer); | ||
341 | } | ||
342 | |||
343 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | ||
344 | index XXXXXXX..XXXXXXX 100644 | ||
345 | --- a/hw/sd/sdhci.c | ||
346 | +++ b/hw/sd/sdhci.c | ||
347 | @@ -XXX,XX +XXX,XX @@ void sdhci_initfn(SDHCIState *s) | ||
348 | |||
349 | void sdhci_uninitfn(SDHCIState *s) | ||
350 | { | ||
351 | - timer_del(s->insert_timer); | ||
352 | timer_free(s->insert_timer); | ||
353 | - timer_del(s->transfer_timer); | ||
354 | timer_free(s->transfer_timer); | ||
355 | |||
356 | g_free(s->fifo_buffer); | ||
357 | diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c | ||
358 | index XXXXXXX..XXXXXXX 100644 | ||
359 | --- a/hw/usb/dev-hub.c | ||
360 | +++ b/hw/usb/dev-hub.c | ||
361 | @@ -XXX,XX +XXX,XX @@ static void usb_hub_unrealize(USBDevice *dev) | ||
362 | &s->ports[i].port); | ||
363 | } | ||
364 | |||
365 | - timer_del(s->port_timer); | ||
366 | timer_free(s->port_timer); | ||
367 | } | ||
368 | |||
369 | diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c | ||
370 | index XXXXXXX..XXXXXXX 100644 | ||
371 | --- a/hw/usb/hcd-ehci.c | ||
372 | +++ b/hw/usb/hcd-ehci.c | ||
373 | @@ -XXX,XX +XXX,XX @@ void usb_ehci_unrealize(EHCIState *s, DeviceState *dev) | ||
374 | trace_usb_ehci_unrealize(); | ||
375 | |||
376 | if (s->frame_timer) { | ||
377 | - timer_del(s->frame_timer); | ||
378 | timer_free(s->frame_timer); | ||
379 | s->frame_timer = NULL; | ||
380 | } | ||
381 | diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c | ||
382 | index XXXXXXX..XXXXXXX 100644 | ||
383 | --- a/hw/usb/hcd-ohci-pci.c | ||
384 | +++ b/hw/usb/hcd-ohci-pci.c | ||
385 | @@ -XXX,XX +XXX,XX @@ static void usb_ohci_exit(PCIDevice *dev) | ||
386 | usb_bus_release(&s->bus); | ||
387 | } | ||
388 | |||
389 | - timer_del(s->eof_timer); | ||
390 | timer_free(s->eof_timer); | ||
391 | } | ||
392 | |||
393 | diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c | ||
394 | index XXXXXXX..XXXXXXX 100644 | ||
395 | --- a/hw/usb/hcd-uhci.c | ||
396 | +++ b/hw/usb/hcd-uhci.c | ||
397 | @@ -XXX,XX +XXX,XX @@ static void usb_uhci_exit(PCIDevice *dev) | ||
398 | trace_usb_uhci_exit(); | ||
399 | |||
400 | if (s->frame_timer) { | ||
401 | - timer_del(s->frame_timer); | ||
402 | timer_free(s->frame_timer); | ||
403 | s->frame_timer = NULL; | ||
404 | } | ||
405 | diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c | ||
406 | index XXXXXXX..XXXXXXX 100644 | ||
407 | --- a/hw/usb/hcd-xhci.c | ||
408 | +++ b/hw/usb/hcd-xhci.c | ||
409 | @@ -XXX,XX +XXX,XX @@ static void usb_xhci_unrealize(DeviceState *dev) | ||
410 | } | ||
411 | |||
412 | if (xhci->mfwrap_timer) { | ||
413 | - timer_del(xhci->mfwrap_timer); | ||
414 | timer_free(xhci->mfwrap_timer); | ||
415 | xhci->mfwrap_timer = NULL; | ||
416 | } | ||
417 | diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c | ||
418 | index XXXXXXX..XXXXXXX 100644 | ||
419 | --- a/hw/usb/redirect.c | ||
420 | +++ b/hw/usb/redirect.c | ||
421 | @@ -XXX,XX +XXX,XX @@ static void usbredir_unrealize(USBDevice *udev) | ||
422 | qemu_bh_delete(dev->chardev_close_bh); | ||
423 | qemu_bh_delete(dev->device_reject_bh); | ||
424 | |||
425 | - timer_del(dev->attach_timer); | ||
426 | timer_free(dev->attach_timer); | ||
427 | |||
428 | usbredir_cleanup_device_queues(dev); | ||
429 | diff --git a/hw/vfio/display.c b/hw/vfio/display.c | ||
430 | index XXXXXXX..XXXXXXX 100644 | ||
431 | --- a/hw/vfio/display.c | ||
432 | +++ b/hw/vfio/display.c | ||
433 | @@ -XXX,XX +XXX,XX @@ static void vfio_display_edid_exit(VFIODisplay *dpy) | ||
434 | |||
435 | g_free(dpy->edid_regs); | ||
436 | g_free(dpy->edid_blob); | ||
437 | - timer_del(dpy->edid_link_timer); | ||
438 | timer_free(dpy->edid_link_timer); | ||
439 | } | ||
440 | |||
441 | diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c | ||
442 | index XXXXXXX..XXXXXXX 100644 | ||
443 | --- a/hw/virtio/vhost-vsock-common.c | ||
444 | +++ b/hw/virtio/vhost-vsock-common.c | ||
445 | @@ -XXX,XX +XXX,XX @@ static void vhost_vsock_common_post_load_timer_cleanup(VHostVSockCommon *vvc) | ||
446 | return; | 30 | return; |
447 | } | 31 | } |
448 | 32 | ||
449 | - timer_del(vvc->post_load_timer); | 33 | + /* Invert P0 bits if needed, but only for beats we actually executed */ |
450 | timer_free(vvc->post_load_timer); | 34 | mask01 = FIELD_EX32(vpr, V7M_VPR, MASK01); |
451 | vvc->post_load_timer = NULL; | 35 | mask23 = FIELD_EX32(vpr, V7M_VPR, MASK23); |
452 | } | 36 | - if (mask01 > 8) { |
453 | diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c | 37 | - /* high bit set, but not 0b1000: invert the relevant half of P0 */ |
454 | index XXXXXXX..XXXXXXX 100644 | 38 | - vpr ^= 0xff; |
455 | --- a/hw/virtio/virtio-balloon.c | 39 | + /* Start by assuming we invert all bits corresponding to executed beats */ |
456 | +++ b/hw/virtio/virtio-balloon.c | 40 | + inv_mask = eci_mask; |
457 | @@ -XXX,XX +XXX,XX @@ static bool balloon_stats_enabled(const VirtIOBalloon *s) | 41 | + if (mask01 <= 8) { |
458 | static void balloon_stats_destroy_timer(VirtIOBalloon *s) | 42 | + /* MASK01 says don't invert low half of P0 */ |
459 | { | 43 | + inv_mask &= ~0xff; |
460 | if (balloon_stats_enabled(s)) { | ||
461 | - timer_del(s->stats_timer); | ||
462 | timer_free(s->stats_timer); | ||
463 | s->stats_timer = NULL; | ||
464 | s->stats_poll_interval = 0; | ||
465 | diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c | ||
466 | index XXXXXXX..XXXXXXX 100644 | ||
467 | --- a/hw/virtio/virtio-rng.c | ||
468 | +++ b/hw/virtio/virtio-rng.c | ||
469 | @@ -XXX,XX +XXX,XX @@ static void virtio_rng_device_unrealize(DeviceState *dev) | ||
470 | VirtIORNG *vrng = VIRTIO_RNG(dev); | ||
471 | |||
472 | qemu_del_vm_change_state_handler(vrng->vmstate); | ||
473 | - timer_del(vrng->rate_limit_timer); | ||
474 | timer_free(vrng->rate_limit_timer); | ||
475 | virtio_del_queue(vdev, 0); | ||
476 | virtio_cleanup(vdev); | ||
477 | diff --git a/hw/watchdog/wdt_diag288.c b/hw/watchdog/wdt_diag288.c | ||
478 | index XXXXXXX..XXXXXXX 100644 | ||
479 | --- a/hw/watchdog/wdt_diag288.c | ||
480 | +++ b/hw/watchdog/wdt_diag288.c | ||
481 | @@ -XXX,XX +XXX,XX @@ static void wdt_diag288_unrealize(DeviceState *dev) | ||
482 | { | ||
483 | DIAG288State *diag288 = DIAG288(dev); | ||
484 | |||
485 | - timer_del(diag288->timer); | ||
486 | timer_free(diag288->timer); | ||
487 | } | ||
488 | |||
489 | diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c | ||
490 | index XXXXXXX..XXXXXXX 100644 | ||
491 | --- a/hw/watchdog/wdt_i6300esb.c | ||
492 | +++ b/hw/watchdog/wdt_i6300esb.c | ||
493 | @@ -XXX,XX +XXX,XX @@ static void i6300esb_exit(PCIDevice *dev) | ||
494 | { | ||
495 | I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); | ||
496 | |||
497 | - timer_del(d->timer); | ||
498 | timer_free(d->timer); | ||
499 | } | ||
500 | |||
501 | diff --git a/migration/colo.c b/migration/colo.c | ||
502 | index XXXXXXX..XXXXXXX 100644 | ||
503 | --- a/migration/colo.c | ||
504 | +++ b/migration/colo.c | ||
505 | @@ -XXX,XX +XXX,XX @@ out: | ||
506 | * error. | ||
507 | */ | ||
508 | colo_compare_unregister_notifier(&packets_compare_notifier); | ||
509 | - timer_del(s->colo_delay_timer); | ||
510 | timer_free(s->colo_delay_timer); | ||
511 | qemu_event_destroy(&s->colo_checkpoint_event); | ||
512 | |||
513 | diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c | ||
514 | index XXXXXXX..XXXXXXX 100644 | ||
515 | --- a/monitor/hmp-cmds.c | ||
516 | +++ b/monitor/hmp-cmds.c | ||
517 | @@ -XXX,XX +XXX,XX @@ static void hmp_migrate_status_cb(void *opaque) | ||
518 | error_report("%s", info->error_desc); | ||
519 | } | ||
520 | monitor_resume(status->mon); | ||
521 | - timer_del(status->timer); | ||
522 | timer_free(status->timer); | ||
523 | g_free(status); | ||
524 | } | 44 | } |
525 | diff --git a/net/announce.c b/net/announce.c | 45 | - if (mask23 > 8) { |
526 | index XXXXXXX..XXXXXXX 100644 | 46 | - /* high bit set, but not 0b1000: invert the relevant half of P0 */ |
527 | --- a/net/announce.c | 47 | - vpr ^= 0xff00; |
528 | +++ b/net/announce.c | 48 | + if (mask23 <= 8) { |
529 | @@ -XXX,XX +XXX,XX @@ void qemu_announce_timer_del(AnnounceTimer *timer, bool free_named) | 49 | + /* MASK23 says don't invert high half of P0 */ |
530 | { | 50 | + inv_mask &= ~0xff00; |
531 | bool free_timer = false; | ||
532 | if (timer->tm) { | ||
533 | - timer_del(timer->tm); | ||
534 | timer_free(timer->tm); | ||
535 | timer->tm = NULL; | ||
536 | } | 51 | } |
537 | diff --git a/net/colo-compare.c b/net/colo-compare.c | 52 | - vpr = FIELD_DP32(vpr, V7M_VPR, MASK01, mask01 << 1); |
538 | index XXXXXXX..XXXXXXX 100644 | 53 | + vpr ^= inv_mask; |
539 | --- a/net/colo-compare.c | 54 | + /* Only update MASK01 if beat 1 executed */ |
540 | +++ b/net/colo-compare.c | 55 | + if (eci_mask & 0xf0) { |
541 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_timer_init(CompareState *s) | 56 | + vpr = FIELD_DP32(vpr, V7M_VPR, MASK01, mask01 << 1); |
542 | static void colo_compare_timer_del(CompareState *s) | 57 | + } |
543 | { | 58 | + /* Beat 3 always executes, so update MASK23 */ |
544 | if (s->packet_check_timer) { | 59 | vpr = FIELD_DP32(vpr, V7M_VPR, MASK23, mask23 << 1); |
545 | - timer_del(s->packet_check_timer); | 60 | env->v7m.vpr = vpr; |
546 | timer_free(s->packet_check_timer); | ||
547 | s->packet_check_timer = NULL; | ||
548 | } | ||
549 | diff --git a/net/slirp.c b/net/slirp.c | ||
550 | index XXXXXXX..XXXXXXX 100644 | ||
551 | --- a/net/slirp.c | ||
552 | +++ b/net/slirp.c | ||
553 | @@ -XXX,XX +XXX,XX @@ static void *net_slirp_timer_new(SlirpTimerCb cb, | ||
554 | |||
555 | static void net_slirp_timer_free(void *timer, void *opaque) | ||
556 | { | ||
557 | - timer_del(timer); | ||
558 | timer_free(timer); | ||
559 | } | ||
560 | |||
561 | diff --git a/replay/replay-debugging.c b/replay/replay-debugging.c | ||
562 | index XXXXXXX..XXXXXXX 100644 | ||
563 | --- a/replay/replay-debugging.c | ||
564 | +++ b/replay/replay-debugging.c | ||
565 | @@ -XXX,XX +XXX,XX @@ static void replay_delete_break(void) | ||
566 | assert(replay_mutex_locked()); | ||
567 | |||
568 | if (replay_break_timer) { | ||
569 | - timer_del(replay_break_timer); | ||
570 | timer_free(replay_break_timer); | ||
571 | replay_break_timer = NULL; | ||
572 | } | ||
573 | diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c | ||
574 | index XXXXXXX..XXXXXXX 100644 | ||
575 | --- a/target/s390x/cpu.c | ||
576 | +++ b/target/s390x/cpu.c | ||
577 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_finalize(Object *obj) | ||
578 | #if !defined(CONFIG_USER_ONLY) | ||
579 | S390CPU *cpu = S390_CPU(obj); | ||
580 | |||
581 | - timer_del(cpu->env.tod_timer); | ||
582 | timer_free(cpu->env.tod_timer); | ||
583 | - timer_del(cpu->env.cpu_timer); | ||
584 | timer_free(cpu->env.cpu_timer); | ||
585 | |||
586 | qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu); | ||
587 | diff --git a/ui/console.c b/ui/console.c | ||
588 | index XXXXXXX..XXXXXXX 100644 | ||
589 | --- a/ui/console.c | ||
590 | +++ b/ui/console.c | ||
591 | @@ -XXX,XX +XXX,XX @@ static void gui_setup_refresh(DisplayState *ds) | ||
592 | timer_mod(ds->gui_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); | ||
593 | } | ||
594 | if (!need_timer && ds->gui_timer != NULL) { | ||
595 | - timer_del(ds->gui_timer); | ||
596 | timer_free(ds->gui_timer); | ||
597 | ds->gui_timer = NULL; | ||
598 | } | ||
599 | diff --git a/ui/spice-core.c b/ui/spice-core.c | ||
600 | index XXXXXXX..XXXXXXX 100644 | ||
601 | --- a/ui/spice-core.c | ||
602 | +++ b/ui/spice-core.c | ||
603 | @@ -XXX,XX +XXX,XX @@ static void timer_cancel(SpiceTimer *timer) | ||
604 | |||
605 | static void timer_remove(SpiceTimer *timer) | ||
606 | { | ||
607 | - timer_del(timer->timer); | ||
608 | timer_free(timer->timer); | ||
609 | g_free(timer); | ||
610 | } | ||
611 | diff --git a/util/throttle.c b/util/throttle.c | ||
612 | index XXXXXXX..XXXXXXX 100644 | ||
613 | --- a/util/throttle.c | ||
614 | +++ b/util/throttle.c | ||
615 | @@ -XXX,XX +XXX,XX @@ static void throttle_timer_destroy(QEMUTimer **timer) | ||
616 | { | ||
617 | assert(*timer != NULL); | ||
618 | |||
619 | - timer_del(*timer); | ||
620 | timer_free(*timer); | ||
621 | *timer = NULL; | ||
622 | } | 61 | } |
623 | -- | 62 | -- |
624 | 2.20.1 | 63 | 2.20.1 |
625 | 64 | ||
626 | 65 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | For vector loads, predicated elements are zeroed, instead of | ||
2 | retaining their previous values (as happens for most data | ||
3 | processing operations). This means we need to distinguish | ||
4 | "beat not executed due to ECI" (don't touch destination | ||
5 | element) from "beat executed but predicated out" (zero | ||
6 | destination element). | ||
1 | 7 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | target/arm/mve_helper.c | 8 +++++--- | ||
12 | 1 file changed, 5 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/mve_helper.c | ||
17 | +++ b/target/arm/mve_helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) | ||
19 | env->v7m.vpr = vpr; | ||
20 | } | ||
21 | |||
22 | - | ||
23 | +/* For loads, predicated lanes are zeroed instead of keeping their old values */ | ||
24 | #define DO_VLDR(OP, MSIZE, LDTYPE, ESIZE, TYPE) \ | ||
25 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, uint32_t addr) \ | ||
26 | { \ | ||
27 | TYPE *d = vd; \ | ||
28 | uint16_t mask = mve_element_mask(env); \ | ||
29 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
30 | unsigned b, e; \ | ||
31 | /* \ | ||
32 | * R_SXTM allows the dest reg to become UNKNOWN for abandoned \ | ||
33 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) | ||
34 | * then take an exception. \ | ||
35 | */ \ | ||
36 | for (b = 0, e = 0; b < 16; b += ESIZE, e++) { \ | ||
37 | - if (mask & (1 << b)) { \ | ||
38 | - d[H##ESIZE(e)] = cpu_##LDTYPE##_data_ra(env, addr, GETPC()); \ | ||
39 | + if (eci_mask & (1 << b)) { \ | ||
40 | + d[H##ESIZE(e)] = (mask & (1 << b)) ? \ | ||
41 | + cpu_##LDTYPE##_data_ra(env, addr, GETPC()) : 0; \ | ||
42 | } \ | ||
43 | addr += MSIZE; \ | ||
44 | } \ | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the MVE VMULL (polynomial) insn. Unlike Neon, this comes | ||
2 | in two flavours: 8x8->16 and a 16x16->32. Also unlike Neon, the | ||
3 | inputs are in either the low or the high half of each double-width | ||
4 | element. | ||
1 | 5 | ||
6 | The assembler for this insn indicates the size with "P8" or "P16", | ||
7 | encoded into bit 28 as size = 0 or 1. We choose to follow the | ||
8 | same encoding as VQDMULL and decode this into a->size as MO_16 | ||
9 | or MO_32 indicating the size of the result elements. This then | ||
10 | carries through to the helper function names where it then | ||
11 | matches up with the existing pmull_h() which does an 8x8->16 | ||
12 | operation and a new pmull_w() which does the 16x16->32. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | ||
17 | target/arm/helper-mve.h | 5 +++++ | ||
18 | target/arm/vec_internal.h | 11 +++++++++++ | ||
19 | target/arm/mve.decode | 14 ++++++++++---- | ||
20 | target/arm/mve_helper.c | 16 ++++++++++++++++ | ||
21 | target/arm/translate-mve.c | 28 ++++++++++++++++++++++++++++ | ||
22 | target/arm/vec_helper.c | 14 +++++++++++++- | ||
23 | 6 files changed, 83 insertions(+), 5 deletions(-) | ||
24 | |||
25 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/helper-mve.h | ||
28 | +++ b/target/arm/helper-mve.h | ||
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
30 | DEF_HELPER_FLAGS_4(mve_vmulltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | DEF_HELPER_FLAGS_4(mve_vmulltuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
32 | |||
33 | +DEF_HELPER_FLAGS_4(mve_vmullpbh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vmullpth, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vmullpbw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
36 | +DEF_HELPER_FLAGS_4(mve_vmullptw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
37 | + | ||
38 | DEF_HELPER_FLAGS_4(mve_vqdmulhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
39 | DEF_HELPER_FLAGS_4(mve_vqdmulhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
40 | DEF_HELPER_FLAGS_4(mve_vqdmulhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
41 | diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/vec_internal.h | ||
44 | +++ b/target/arm/vec_internal.h | ||
45 | @@ -XXX,XX +XXX,XX @@ int16_t do_sqrdmlah_h(int16_t, int16_t, int16_t, bool, bool, uint32_t *); | ||
46 | int32_t do_sqrdmlah_s(int32_t, int32_t, int32_t, bool, bool, uint32_t *); | ||
47 | int64_t do_sqrdmlah_d(int64_t, int64_t, int64_t, bool, bool); | ||
48 | |||
49 | +/* | ||
50 | + * 8 x 8 -> 16 vector polynomial multiply where the inputs are | ||
51 | + * in the low 8 bits of each 16-bit element | ||
52 | +*/ | ||
53 | +uint64_t pmull_h(uint64_t op1, uint64_t op2); | ||
54 | +/* | ||
55 | + * 16 x 16 -> 32 vector polynomial multiply where the inputs are | ||
56 | + * in the low 16 bits of each 32-bit element | ||
57 | + */ | ||
58 | +uint64_t pmull_w(uint64_t op1, uint64_t op2); | ||
59 | + | ||
60 | #endif /* TARGET_ARM_VEC_INTERNALS_H */ | ||
61 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/mve.decode | ||
64 | +++ b/target/arm/mve.decode | ||
65 | @@ -XXX,XX +XXX,XX @@ VHADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 0 ... 0 @2op | ||
66 | VHSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op | ||
67 | VHSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op | ||
68 | |||
69 | -VMULL_BS 111 0 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
70 | -VMULL_BU 111 1 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
71 | -VMULL_TS 111 0 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
72 | -VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
73 | +{ | ||
74 | + VMULLP_B 111 . 1110 0 . 11 ... 1 ... 0 1110 . 0 . 0 ... 0 @2op_sz28 | ||
75 | + VMULL_BS 111 0 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
76 | + VMULL_BU 111 1 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
77 | +} | ||
78 | +{ | ||
79 | + VMULLP_T 111 . 1110 0 . 11 ... 1 ... 1 1110 . 0 . 0 ... 0 @2op_sz28 | ||
80 | + VMULL_TS 111 0 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
81 | + VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
82 | +} | ||
83 | |||
84 | VQDMULH 1110 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op | ||
85 | VQRDMULH 1111 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op | ||
86 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/target/arm/mve_helper.c | ||
89 | +++ b/target/arm/mve_helper.c | ||
90 | @@ -XXX,XX +XXX,XX @@ DO_2OP_L(vmulltub, 1, 1, uint8_t, 2, uint16_t, DO_MUL) | ||
91 | DO_2OP_L(vmulltuh, 1, 2, uint16_t, 4, uint32_t, DO_MUL) | ||
92 | DO_2OP_L(vmulltuw, 1, 4, uint32_t, 8, uint64_t, DO_MUL) | ||
93 | |||
94 | +/* | ||
95 | + * Polynomial multiply. We can always do this generating 64 bits | ||
96 | + * of the result at a time, so we don't need to use DO_2OP_L. | ||
97 | + */ | ||
98 | +#define VMULLPH_MASK 0x00ff00ff00ff00ffULL | ||
99 | +#define VMULLPW_MASK 0x0000ffff0000ffffULL | ||
100 | +#define DO_VMULLPBH(N, M) pmull_h((N) & VMULLPH_MASK, (M) & VMULLPH_MASK) | ||
101 | +#define DO_VMULLPTH(N, M) DO_VMULLPBH((N) >> 8, (M) >> 8) | ||
102 | +#define DO_VMULLPBW(N, M) pmull_w((N) & VMULLPW_MASK, (M) & VMULLPW_MASK) | ||
103 | +#define DO_VMULLPTW(N, M) DO_VMULLPBW((N) >> 16, (M) >> 16) | ||
104 | + | ||
105 | +DO_2OP(vmullpbh, 8, uint64_t, DO_VMULLPBH) | ||
106 | +DO_2OP(vmullpth, 8, uint64_t, DO_VMULLPTH) | ||
107 | +DO_2OP(vmullpbw, 8, uint64_t, DO_VMULLPBW) | ||
108 | +DO_2OP(vmullptw, 8, uint64_t, DO_VMULLPTW) | ||
109 | + | ||
110 | /* | ||
111 | * Because the computation type is at least twice as large as required, | ||
112 | * these work for both signed and unsigned source types. | ||
113 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
114 | index XXXXXXX..XXXXXXX 100644 | ||
115 | --- a/target/arm/translate-mve.c | ||
116 | +++ b/target/arm/translate-mve.c | ||
117 | @@ -XXX,XX +XXX,XX @@ static bool trans_VQDMULLT(DisasContext *s, arg_2op *a) | ||
118 | return do_2op(s, a, fns[a->size]); | ||
119 | } | ||
120 | |||
121 | +static bool trans_VMULLP_B(DisasContext *s, arg_2op *a) | ||
122 | +{ | ||
123 | + /* | ||
124 | + * Note that a->size indicates the output size, ie VMULL.P8 | ||
125 | + * is the 8x8->16 operation and a->size is MO_16; VMULL.P16 | ||
126 | + * is the 16x16->32 operation and a->size is MO_32. | ||
127 | + */ | ||
128 | + static MVEGenTwoOpFn * const fns[] = { | ||
129 | + NULL, | ||
130 | + gen_helper_mve_vmullpbh, | ||
131 | + gen_helper_mve_vmullpbw, | ||
132 | + NULL, | ||
133 | + }; | ||
134 | + return do_2op(s, a, fns[a->size]); | ||
135 | +} | ||
136 | + | ||
137 | +static bool trans_VMULLP_T(DisasContext *s, arg_2op *a) | ||
138 | +{ | ||
139 | + /* a->size is as for trans_VMULLP_B */ | ||
140 | + static MVEGenTwoOpFn * const fns[] = { | ||
141 | + NULL, | ||
142 | + gen_helper_mve_vmullpth, | ||
143 | + gen_helper_mve_vmullptw, | ||
144 | + NULL, | ||
145 | + }; | ||
146 | + return do_2op(s, a, fns[a->size]); | ||
147 | +} | ||
148 | + | ||
149 | /* | ||
150 | * VADC and VSBC: these perform an add-with-carry or subtract-with-carry | ||
151 | * of the 32-bit elements in each lane of the input vectors, where the | ||
152 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/arm/vec_helper.c | ||
155 | +++ b/target/arm/vec_helper.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static uint64_t expand_byte_to_half(uint64_t x) | ||
157 | | ((x & 0xff000000) << 24); | ||
158 | } | ||
159 | |||
160 | -static uint64_t pmull_h(uint64_t op1, uint64_t op2) | ||
161 | +uint64_t pmull_w(uint64_t op1, uint64_t op2) | ||
162 | { | ||
163 | uint64_t result = 0; | ||
164 | int i; | ||
165 | + for (i = 0; i < 16; ++i) { | ||
166 | + uint64_t mask = (op1 & 0x0000000100000001ull) * 0xffffffff; | ||
167 | + result ^= op2 & mask; | ||
168 | + op1 >>= 1; | ||
169 | + op2 <<= 1; | ||
170 | + } | ||
171 | + return result; | ||
172 | +} | ||
173 | |||
174 | +uint64_t pmull_h(uint64_t op1, uint64_t op2) | ||
175 | +{ | ||
176 | + uint64_t result = 0; | ||
177 | + int i; | ||
178 | for (i = 0; i < 8; ++i) { | ||
179 | uint64_t mask = (op1 & 0x0001000100010001ull) * 0xffff; | ||
180 | result ^= op2 & mask; | ||
181 | -- | ||
182 | 2.20.1 | ||
183 | |||
184 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the MVE incrementing/decrementing dup insns VIDUP, VDDUP, | ||
2 | VIWDUP and VDWDUP. These fill the elements of a vector with | ||
3 | successively incrementing values, starting at the offset specified in | ||
4 | a general purpose register. The final value of the offset is written | ||
5 | back to this register. The wrapping variants take a second general | ||
6 | purpose register which specifies the point where the count should | ||
7 | wrap back to 0. | ||
1 | 8 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper-mve.h | 12 ++++ | ||
13 | target/arm/mve.decode | 25 ++++++++ | ||
14 | target/arm/mve_helper.c | 63 +++++++++++++++++++ | ||
15 | target/arm/translate-mve.c | 120 +++++++++++++++++++++++++++++++++++++ | ||
16 | 4 files changed, 220 insertions(+) | ||
17 | |||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper-mve.h | ||
21 | +++ b/target/arm/helper-mve.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
23 | |||
24 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
25 | |||
26 | +DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_viduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vidupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_5(mve_viwdupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
31 | +DEF_HELPER_FLAGS_5(mve_viwduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
32 | +DEF_HELPER_FLAGS_5(mve_viwdupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
33 | + | ||
34 | +DEF_HELPER_FLAGS_5(mve_vdwdupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
35 | +DEF_HELPER_FLAGS_5(mve_vdwduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
36 | +DEF_HELPER_FLAGS_5(mve_vdwdupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
37 | + | ||
38 | DEF_HELPER_FLAGS_3(mve_vclsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
39 | DEF_HELPER_FLAGS_3(mve_vclsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
40 | DEF_HELPER_FLAGS_3(mve_vclsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/mve.decode | ||
44 | +++ b/target/arm/mve.decode | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | &2scalar qd qn rm size | ||
47 | &1imm qd imm cmode op | ||
48 | &2shift qd qm shift size | ||
49 | +&vidup qd rn size imm | ||
50 | +&viwdup qd rn rm size imm | ||
51 | |||
52 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
53 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
54 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 1 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=0 | ||
55 | VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 1 1 0000 @vdup size=1 | ||
56 | VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
57 | |||
58 | +# Incrementing and decrementing dup | ||
59 | + | ||
60 | +# VIDUP, VDDUP format immediate: 1 << (immh:imml) | ||
61 | +%imm_vidup 7:1 0:1 !function=vidup_imm | ||
62 | + | ||
63 | +# VIDUP, VDDUP registers: Rm bits [3:1] from insn, bit 0 is 1; | ||
64 | +# Rn bits [3:1] from insn, bit 0 is 0 | ||
65 | +%vidup_rm 1:3 !function=times_2_plus_1 | ||
66 | +%vidup_rn 17:3 !function=times_2 | ||
67 | + | ||
68 | +@vidup .... .... . . size:2 .... .... .... .... .... \ | ||
69 | + qd=%qd imm=%imm_vidup rn=%vidup_rn &vidup | ||
70 | +@viwdup .... .... . . size:2 .... .... .... .... .... \ | ||
71 | + qd=%qd imm=%imm_vidup rm=%vidup_rm rn=%vidup_rn &viwdup | ||
72 | +{ | ||
73 | + VIDUP 1110 1110 0 . .. ... 1 ... 0 1111 . 110 111 . @vidup | ||
74 | + VIWDUP 1110 1110 0 . .. ... 1 ... 0 1111 . 110 ... . @viwdup | ||
75 | +} | ||
76 | +{ | ||
77 | + VDDUP 1110 1110 0 . .. ... 1 ... 1 1111 . 110 111 . @vidup | ||
78 | + VDWDUP 1110 1110 0 . .. ... 1 ... 1 1111 . 110 ... . @viwdup | ||
79 | +} | ||
80 | + | ||
81 | # multiply-add long dual accumulate | ||
82 | # rdahi: bits [3:1] from insn, bit 0 is 1 | ||
83 | # rdalo: bits [3:1] from insn, bit 0 is 0 | ||
84 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/target/arm/mve_helper.c | ||
87 | +++ b/target/arm/mve_helper.c | ||
88 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_sqrshr)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
89 | { | ||
90 | return do_sqrshl_bhs(n, -(int8_t)shift, 32, true, &env->QF); | ||
91 | } | ||
92 | + | ||
93 | +#define DO_VIDUP(OP, ESIZE, TYPE, FN) \ | ||
94 | + uint32_t HELPER(mve_##OP)(CPUARMState *env, void *vd, \ | ||
95 | + uint32_t offset, uint32_t imm) \ | ||
96 | + { \ | ||
97 | + TYPE *d = vd; \ | ||
98 | + uint16_t mask = mve_element_mask(env); \ | ||
99 | + unsigned e; \ | ||
100 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
101 | + mergemask(&d[H##ESIZE(e)], offset, mask); \ | ||
102 | + offset = FN(offset, imm); \ | ||
103 | + } \ | ||
104 | + mve_advance_vpt(env); \ | ||
105 | + return offset; \ | ||
106 | + } | ||
107 | + | ||
108 | +#define DO_VIWDUP(OP, ESIZE, TYPE, FN) \ | ||
109 | + uint32_t HELPER(mve_##OP)(CPUARMState *env, void *vd, \ | ||
110 | + uint32_t offset, uint32_t wrap, \ | ||
111 | + uint32_t imm) \ | ||
112 | + { \ | ||
113 | + TYPE *d = vd; \ | ||
114 | + uint16_t mask = mve_element_mask(env); \ | ||
115 | + unsigned e; \ | ||
116 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
117 | + mergemask(&d[H##ESIZE(e)], offset, mask); \ | ||
118 | + offset = FN(offset, wrap, imm); \ | ||
119 | + } \ | ||
120 | + mve_advance_vpt(env); \ | ||
121 | + return offset; \ | ||
122 | + } | ||
123 | + | ||
124 | +#define DO_VIDUP_ALL(OP, FN) \ | ||
125 | + DO_VIDUP(OP##b, 1, int8_t, FN) \ | ||
126 | + DO_VIDUP(OP##h, 2, int16_t, FN) \ | ||
127 | + DO_VIDUP(OP##w, 4, int32_t, FN) | ||
128 | + | ||
129 | +#define DO_VIWDUP_ALL(OP, FN) \ | ||
130 | + DO_VIWDUP(OP##b, 1, int8_t, FN) \ | ||
131 | + DO_VIWDUP(OP##h, 2, int16_t, FN) \ | ||
132 | + DO_VIWDUP(OP##w, 4, int32_t, FN) | ||
133 | + | ||
134 | +static uint32_t do_add_wrap(uint32_t offset, uint32_t wrap, uint32_t imm) | ||
135 | +{ | ||
136 | + offset += imm; | ||
137 | + if (offset == wrap) { | ||
138 | + offset = 0; | ||
139 | + } | ||
140 | + return offset; | ||
141 | +} | ||
142 | + | ||
143 | +static uint32_t do_sub_wrap(uint32_t offset, uint32_t wrap, uint32_t imm) | ||
144 | +{ | ||
145 | + if (offset == 0) { | ||
146 | + offset = wrap; | ||
147 | + } | ||
148 | + offset -= imm; | ||
149 | + return offset; | ||
150 | +} | ||
151 | + | ||
152 | +DO_VIDUP_ALL(vidup, DO_ADD) | ||
153 | +DO_VIWDUP_ALL(viwdup, do_add_wrap) | ||
154 | +DO_VIWDUP_ALL(vdwdup, do_sub_wrap) | ||
155 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
156 | index XXXXXXX..XXXXXXX 100644 | ||
157 | --- a/target/arm/translate-mve.c | ||
158 | +++ b/target/arm/translate-mve.c | ||
159 | @@ -XXX,XX +XXX,XX @@ | ||
160 | #include "translate.h" | ||
161 | #include "translate-a32.h" | ||
162 | |||
163 | +static inline int vidup_imm(DisasContext *s, int x) | ||
164 | +{ | ||
165 | + return 1 << x; | ||
166 | +} | ||
167 | + | ||
168 | /* Include the generated decoder */ | ||
169 | #include "decode-mve.c.inc" | ||
170 | |||
171 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
172 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
173 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
174 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
175 | +typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
176 | +typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
177 | |||
178 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
179 | static inline long mve_qreg_offset(unsigned reg) | ||
180 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLC(DisasContext *s, arg_VSHLC *a) | ||
181 | mve_update_eci(s); | ||
182 | return true; | ||
183 | } | ||
184 | + | ||
185 | +static bool do_vidup(DisasContext *s, arg_vidup *a, MVEGenVIDUPFn *fn) | ||
186 | +{ | ||
187 | + TCGv_ptr qd; | ||
188 | + TCGv_i32 rn; | ||
189 | + | ||
190 | + /* | ||
191 | + * Vector increment/decrement with wrap and duplicate (VIDUP, VDDUP). | ||
192 | + * This fills the vector with elements of successively increasing | ||
193 | + * or decreasing values, starting from Rn. | ||
194 | + */ | ||
195 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) { | ||
196 | + return false; | ||
197 | + } | ||
198 | + if (a->size == MO_64) { | ||
199 | + /* size 0b11 is another encoding */ | ||
200 | + return false; | ||
201 | + } | ||
202 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
203 | + return true; | ||
204 | + } | ||
205 | + | ||
206 | + qd = mve_qreg_ptr(a->qd); | ||
207 | + rn = load_reg(s, a->rn); | ||
208 | + fn(rn, cpu_env, qd, rn, tcg_constant_i32(a->imm)); | ||
209 | + store_reg(s, a->rn, rn); | ||
210 | + tcg_temp_free_ptr(qd); | ||
211 | + mve_update_eci(s); | ||
212 | + return true; | ||
213 | +} | ||
214 | + | ||
215 | +static bool do_viwdup(DisasContext *s, arg_viwdup *a, MVEGenVIWDUPFn *fn) | ||
216 | +{ | ||
217 | + TCGv_ptr qd; | ||
218 | + TCGv_i32 rn, rm; | ||
219 | + | ||
220 | + /* | ||
221 | + * Vector increment/decrement with wrap and duplicate (VIWDUp, VDWDUP) | ||
222 | + * This fills the vector with elements of successively increasing | ||
223 | + * or decreasing values, starting from Rn. Rm specifies a point where | ||
224 | + * the count wraps back around to 0. The updated offset is written back | ||
225 | + * to Rn. | ||
226 | + */ | ||
227 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) { | ||
228 | + return false; | ||
229 | + } | ||
230 | + if (!fn || a->rm == 13 || a->rm == 15) { | ||
231 | + /* | ||
232 | + * size 0b11 is another encoding; Rm == 13 is UNPREDICTABLE; | ||
233 | + * Rm == 13 is VIWDUP, VDWDUP. | ||
234 | + */ | ||
235 | + return false; | ||
236 | + } | ||
237 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
238 | + return true; | ||
239 | + } | ||
240 | + | ||
241 | + qd = mve_qreg_ptr(a->qd); | ||
242 | + rn = load_reg(s, a->rn); | ||
243 | + rm = load_reg(s, a->rm); | ||
244 | + fn(rn, cpu_env, qd, rn, rm, tcg_constant_i32(a->imm)); | ||
245 | + store_reg(s, a->rn, rn); | ||
246 | + tcg_temp_free_ptr(qd); | ||
247 | + tcg_temp_free_i32(rm); | ||
248 | + mve_update_eci(s); | ||
249 | + return true; | ||
250 | +} | ||
251 | + | ||
252 | +static bool trans_VIDUP(DisasContext *s, arg_vidup *a) | ||
253 | +{ | ||
254 | + static MVEGenVIDUPFn * const fns[] = { | ||
255 | + gen_helper_mve_vidupb, | ||
256 | + gen_helper_mve_viduph, | ||
257 | + gen_helper_mve_vidupw, | ||
258 | + NULL, | ||
259 | + }; | ||
260 | + return do_vidup(s, a, fns[a->size]); | ||
261 | +} | ||
262 | + | ||
263 | +static bool trans_VDDUP(DisasContext *s, arg_vidup *a) | ||
264 | +{ | ||
265 | + static MVEGenVIDUPFn * const fns[] = { | ||
266 | + gen_helper_mve_vidupb, | ||
267 | + gen_helper_mve_viduph, | ||
268 | + gen_helper_mve_vidupw, | ||
269 | + NULL, | ||
270 | + }; | ||
271 | + /* VDDUP is just like VIDUP but with a negative immediate */ | ||
272 | + a->imm = -a->imm; | ||
273 | + return do_vidup(s, a, fns[a->size]); | ||
274 | +} | ||
275 | + | ||
276 | +static bool trans_VIWDUP(DisasContext *s, arg_viwdup *a) | ||
277 | +{ | ||
278 | + static MVEGenVIWDUPFn * const fns[] = { | ||
279 | + gen_helper_mve_viwdupb, | ||
280 | + gen_helper_mve_viwduph, | ||
281 | + gen_helper_mve_viwdupw, | ||
282 | + NULL, | ||
283 | + }; | ||
284 | + return do_viwdup(s, a, fns[a->size]); | ||
285 | +} | ||
286 | + | ||
287 | +static bool trans_VDWDUP(DisasContext *s, arg_viwdup *a) | ||
288 | +{ | ||
289 | + static MVEGenVIWDUPFn * const fns[] = { | ||
290 | + gen_helper_mve_vdwdupb, | ||
291 | + gen_helper_mve_vdwduph, | ||
292 | + gen_helper_mve_vdwdupw, | ||
293 | + NULL, | ||
294 | + }; | ||
295 | + return do_viwdup(s, a, fns[a->size]); | ||
296 | +} | ||
297 | -- | ||
298 | 2.20.1 | ||
299 | |||
300 | diff view generated by jsdifflib |
1 | Support for running KVM on 32-bit Arm hosts was removed in commit | 1 | Factor out the "generate code to update VPR.MASK01/MASK23" part of |
---|---|---|---|
2 | 82bf7ae84ce739e. You can still run a 32-bit guest on a 64-bit Arm | 2 | trans_VPST(); we are going to want to reuse it for the VPT insns. |
3 | host CPU, but because Arm KVM requires the host and guest CPU types | ||
4 | to match, it is not possible to run a guest that requires a Cortex-A9 | ||
5 | or Cortex-A15 CPU there. That means that the code in the | ||
6 | highbank/midway board models to support KVM is no longer used, and we | ||
7 | can delete it. | ||
8 | 3 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Message-id: 20201215144215.28482-1-peter.maydell@linaro.org | ||
13 | --- | 6 | --- |
14 | hw/arm/highbank.c | 14 ++++---------- | 7 | target/arm/translate-mve.c | 31 +++++++++++++++++-------------- |
15 | 1 file changed, 4 insertions(+), 10 deletions(-) | 8 | 1 file changed, 17 insertions(+), 14 deletions(-) |
16 | 9 | ||
17 | diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c | 10 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
18 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/highbank.c | 12 | --- a/target/arm/translate-mve.c |
20 | +++ b/hw/arm/highbank.c | 13 | +++ b/target/arm/translate-mve.c |
21 | @@ -XXX,XX +XXX,XX @@ | 14 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) |
22 | #include "hw/arm/boot.h" | 15 | return do_long_dual_acc(s, a, fns[a->x]); |
23 | #include "hw/loader.h" | 16 | } |
24 | #include "net/net.h" | 17 | |
25 | -#include "sysemu/kvm.h" | 18 | -static bool trans_VPST(DisasContext *s, arg_VPST *a) |
26 | #include "sysemu/runstate.h" | 19 | +static void gen_vpst(DisasContext *s, uint32_t mask) |
27 | #include "sysemu/sysemu.h" | 20 | { |
28 | #include "hw/boards.h" | 21 | - TCGv_i32 vpr; |
29 | @@ -XXX,XX +XXX,XX @@ | 22 | - |
30 | #include "hw/cpu/a15mpcore.h" | 23 | - /* mask == 0 is a "related encoding" */ |
31 | #include "qemu/log.h" | 24 | - if (!dc_isar_feature(aa32_mve, s) || !a->mask) { |
32 | #include "qom/object.h" | 25 | - return false; |
33 | +#include "cpu.h" | ||
34 | |||
35 | #define SMP_BOOT_ADDR 0x100 | ||
36 | #define SMP_BOOT_REG 0x40 | ||
37 | @@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) | ||
38 | highbank_binfo.loader_start = 0; | ||
39 | highbank_binfo.write_secondary_boot = hb_write_secondary; | ||
40 | highbank_binfo.secondary_cpu_reset_hook = hb_reset_secondary; | ||
41 | - if (!kvm_enabled()) { | ||
42 | - highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR; | ||
43 | - highbank_binfo.write_board_setup = hb_write_board_setup; | ||
44 | - highbank_binfo.secure_board_setup = true; | ||
45 | - } else { | ||
46 | - warn_report("cannot load built-in Monitor support " | ||
47 | - "if KVM is enabled. Some guests (such as Linux) " | ||
48 | - "may not boot."); | ||
49 | - } | 26 | - } |
50 | + highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR; | 27 | - if (!mve_eci_check(s) || !vfp_access_check(s)) { |
51 | + highbank_binfo.write_board_setup = hb_write_board_setup; | 28 | - return true; |
52 | + highbank_binfo.secure_board_setup = true; | 29 | - } |
53 | 30 | /* | |
54 | arm_load_kernel(ARM_CPU(first_cpu), machine, &highbank_binfo); | 31 | * Set the VPR mask fields. We take advantage of MASK01 and MASK23 |
32 | * being adjacent fields in the register. | ||
33 | * | ||
34 | - * This insn is not predicated, but it is subject to beat-wise | ||
35 | + * Updating the masks is not predicated, but it is subject to beat-wise | ||
36 | * execution, and the mask is updated on the odd-numbered beats. | ||
37 | * So if PSR.ECI says we should skip beat 1, we mustn't update the | ||
38 | * 01 mask field. | ||
39 | */ | ||
40 | - vpr = load_cpu_field(v7m.vpr); | ||
41 | + TCGv_i32 vpr = load_cpu_field(v7m.vpr); | ||
42 | switch (s->eci) { | ||
43 | case ECI_NONE: | ||
44 | case ECI_A0: | ||
45 | /* Update both 01 and 23 fields */ | ||
46 | tcg_gen_deposit_i32(vpr, vpr, | ||
47 | - tcg_constant_i32(a->mask | (a->mask << 4)), | ||
48 | + tcg_constant_i32(mask | (mask << 4)), | ||
49 | R_V7M_VPR_MASK01_SHIFT, | ||
50 | R_V7M_VPR_MASK01_LENGTH + R_V7M_VPR_MASK23_LENGTH); | ||
51 | break; | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
53 | case ECI_A0A1A2B0: | ||
54 | /* Update only the 23 mask field */ | ||
55 | tcg_gen_deposit_i32(vpr, vpr, | ||
56 | - tcg_constant_i32(a->mask), | ||
57 | + tcg_constant_i32(mask), | ||
58 | R_V7M_VPR_MASK23_SHIFT, R_V7M_VPR_MASK23_LENGTH); | ||
59 | break; | ||
60 | default: | ||
61 | g_assert_not_reached(); | ||
62 | } | ||
63 | store_cpu_field(vpr, v7m.vpr); | ||
64 | +} | ||
65 | + | ||
66 | +static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
67 | +{ | ||
68 | + /* mask == 0 is a "related encoding" */ | ||
69 | + if (!dc_isar_feature(aa32_mve, s) || !a->mask) { | ||
70 | + return false; | ||
71 | + } | ||
72 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
73 | + return true; | ||
74 | + } | ||
75 | + gen_vpst(s, a->mask); | ||
76 | mve_update_and_store_eci(s); | ||
77 | return true; | ||
55 | } | 78 | } |
56 | -- | 79 | -- |
57 | 2.20.1 | 80 | 2.20.1 |
58 | 81 | ||
59 | 82 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | Implement the MVE integer vector comparison instructions. These are |
---|---|---|---|
2 | 2 | "VCMP (vector)" encodings T1, T2 and T3, and "VPT (vector)" encodings | |
3 | When running device-introspect-test, a memory leak occurred in the | 3 | T1, T2 and T3. |
4 | mv88w8618_pit_init function, so use ptimer_free() in the finalize function to | 4 | |
5 | avoid it. | 5 | These insns compare corresponding elements in each vector, and update |
6 | 6 | the VPR.P0 predicate bits with the results of the comparison. VPT | |
7 | ASAN shows memory leak stack: | 7 | also sets the VPR.MASK01 and VPR.MASK23 fields -- it is effectively |
8 | 8 | "VCMP then VPST". | |
9 | Indirect leak of 192 byte(s) in 4 object(s) allocated from: | 9 | |
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523 | ||
13 | #3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544 | ||
14 | #4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562 | ||
15 | #5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433 | ||
16 | #6 0xaaabf5bb2290 in mv88w8618_timer_init /qemu/hw/arm/musicpal.c:862 | ||
17 | #7 0xaaabf5bb2290 in mv88w8618_pit_init /qemu/hw/arm/musicpal.c:954 | ||
18 | #8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
19 | #9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
20 | #10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
21 | #11 0xaaabf5a95540 in qdev_device_help /qemu/softmmu/qdev-monitor.c:283 | ||
22 | #12 0xaaabf5a96940 in qmp_device_add /qemu/softmmu/qdev-monitor.c:801 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
28 | --- | 12 | --- |
29 | hw/arm/musicpal.c | 12 ++++++++++++ | 13 | target/arm/helper-mve.h | 32 ++++++++++++++++++++++ |
30 | 1 file changed, 12 insertions(+) | 14 | target/arm/mve.decode | 18 +++++++++++- |
31 | 15 | target/arm/mve_helper.c | 56 ++++++++++++++++++++++++++++++++++++++ | |
32 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | 16 | target/arm/translate-mve.c | 47 ++++++++++++++++++++++++++++++++ |
33 | index XXXXXXX..XXXXXXX 100644 | 17 | 4 files changed, 152 insertions(+), 1 deletion(-) |
34 | --- a/hw/arm/musicpal.c | 18 | |
35 | +++ b/hw/arm/musicpal.c | 19 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
36 | @@ -XXX,XX +XXX,XX @@ static void mv88w8618_pit_init(Object *obj) | 20 | index XXXXXXX..XXXXXXX 100644 |
37 | sysbus_init_mmio(dev, &s->iomem); | 21 | --- a/target/arm/helper-mve.h |
22 | +++ b/target/arm/helper-mve.h | ||
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
24 | DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
25 | DEF_HELPER_FLAGS_3(mve_uqrshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
26 | DEF_HELPER_FLAGS_3(mve_sqrshr, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
27 | + | ||
28 | +DEF_HELPER_FLAGS_3(mve_vcmpeqb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vcmpeqh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vcmpeqw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | + | ||
32 | +DEF_HELPER_FLAGS_3(mve_vcmpneb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
33 | +DEF_HELPER_FLAGS_3(mve_vcmpneh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vcmpnew, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
35 | + | ||
36 | +DEF_HELPER_FLAGS_3(mve_vcmpcsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
37 | +DEF_HELPER_FLAGS_3(mve_vcmpcsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
38 | +DEF_HELPER_FLAGS_3(mve_vcmpcsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
39 | + | ||
40 | +DEF_HELPER_FLAGS_3(mve_vcmphib, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vcmphih, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
42 | +DEF_HELPER_FLAGS_3(mve_vcmphiw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
43 | + | ||
44 | +DEF_HELPER_FLAGS_3(mve_vcmpgeb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
45 | +DEF_HELPER_FLAGS_3(mve_vcmpgeh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
46 | +DEF_HELPER_FLAGS_3(mve_vcmpgew, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
47 | + | ||
48 | +DEF_HELPER_FLAGS_3(mve_vcmpltb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
49 | +DEF_HELPER_FLAGS_3(mve_vcmplth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
50 | +DEF_HELPER_FLAGS_3(mve_vcmpltw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
51 | + | ||
52 | +DEF_HELPER_FLAGS_3(mve_vcmpgtb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
53 | +DEF_HELPER_FLAGS_3(mve_vcmpgth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
54 | +DEF_HELPER_FLAGS_3(mve_vcmpgtw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
55 | + | ||
56 | +DEF_HELPER_FLAGS_3(mve_vcmpleb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
57 | +DEF_HELPER_FLAGS_3(mve_vcmpleh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
58 | +DEF_HELPER_FLAGS_3(mve_vcmplew, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
59 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/arm/mve.decode | ||
62 | +++ b/target/arm/mve.decode | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | &2shift qd qm shift size | ||
65 | &vidup qd rn size imm | ||
66 | &viwdup qd rn rm size imm | ||
67 | +&vcmp qm qn size mask | ||
68 | |||
69 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
70 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
71 | @@ -XXX,XX +XXX,XX @@ | ||
72 | @2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
73 | size=2 shift=%rshift_i5 | ||
74 | |||
75 | +# Vector comparison; 4-bit Qm but 3-bit Qn | ||
76 | +%mask_22_13 22:1 13:3 | ||
77 | +@vcmp .... .... .. size:2 qn:3 . .... .... .... .... &vcmp qm=%qm mask=%mask_22_13 | ||
78 | + | ||
79 | # Vector loads and stores | ||
80 | |||
81 | # Widening loads and narrowing stores: | ||
82 | @@ -XXX,XX +XXX,XX @@ VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
38 | } | 83 | } |
39 | 84 | ||
40 | +static void mv88w8618_pit_finalize(Object *obj) | 85 | # Predicate operations |
86 | -%mask_22_13 22:1 13:3 | ||
87 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
88 | |||
89 | # Logical immediate operations (1 reg and modified-immediate) | ||
90 | @@ -XXX,XX +XXX,XX @@ VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
91 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
92 | |||
93 | VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | ||
94 | + | ||
95 | +# Comparisons. We expand out the conditions which are split across | ||
96 | +# encodings T1, T2, T3 and the fc bits. These include VPT, which is | ||
97 | +# effectively "VCMP then VPST". A plain "VCMP" has a mask field of zero. | ||
98 | +VCMPEQ 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 0 @vcmp | ||
99 | +VCMPNE 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 0 @vcmp | ||
100 | +VCMPCS 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 1 @vcmp | ||
101 | +VCMPHI 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 1 @vcmp | ||
102 | +VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | ||
103 | +VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | ||
104 | +VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
105 | +VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | ||
106 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/mve_helper.c | ||
109 | +++ b/target/arm/mve_helper.c | ||
110 | @@ -XXX,XX +XXX,XX @@ static uint32_t do_sub_wrap(uint32_t offset, uint32_t wrap, uint32_t imm) | ||
111 | DO_VIDUP_ALL(vidup, DO_ADD) | ||
112 | DO_VIWDUP_ALL(viwdup, do_add_wrap) | ||
113 | DO_VIWDUP_ALL(vdwdup, do_sub_wrap) | ||
114 | + | ||
115 | +/* | ||
116 | + * Vector comparison. | ||
117 | + * P0 bits for non-executed beats (where eci_mask is 0) are unchanged. | ||
118 | + * P0 bits for predicated lanes in executed beats (where mask is 0) are 0. | ||
119 | + * P0 bits otherwise are updated with the results of the comparisons. | ||
120 | + * We must also keep unchanged the MASK fields at the top of v7m.vpr. | ||
121 | + */ | ||
122 | +#define DO_VCMP(OP, ESIZE, TYPE, FN) \ | ||
123 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, void *vm) \ | ||
124 | + { \ | ||
125 | + TYPE *n = vn, *m = vm; \ | ||
126 | + uint16_t mask = mve_element_mask(env); \ | ||
127 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
128 | + uint16_t beatpred = 0; \ | ||
129 | + uint16_t emask = MAKE_64BIT_MASK(0, ESIZE); \ | ||
130 | + unsigned e; \ | ||
131 | + for (e = 0; e < 16 / ESIZE; e++) { \ | ||
132 | + bool r = FN(n[H##ESIZE(e)], m[H##ESIZE(e)]); \ | ||
133 | + /* Comparison sets 0/1 bits for each byte in the element */ \ | ||
134 | + beatpred |= r * emask; \ | ||
135 | + emask <<= ESIZE; \ | ||
136 | + } \ | ||
137 | + beatpred &= mask; \ | ||
138 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | \ | ||
139 | + (beatpred & eci_mask); \ | ||
140 | + mve_advance_vpt(env); \ | ||
141 | + } | ||
142 | + | ||
143 | +#define DO_VCMP_S(OP, FN) \ | ||
144 | + DO_VCMP(OP##b, 1, int8_t, FN) \ | ||
145 | + DO_VCMP(OP##h, 2, int16_t, FN) \ | ||
146 | + DO_VCMP(OP##w, 4, int32_t, FN) | ||
147 | + | ||
148 | +#define DO_VCMP_U(OP, FN) \ | ||
149 | + DO_VCMP(OP##b, 1, uint8_t, FN) \ | ||
150 | + DO_VCMP(OP##h, 2, uint16_t, FN) \ | ||
151 | + DO_VCMP(OP##w, 4, uint32_t, FN) | ||
152 | + | ||
153 | +#define DO_EQ(N, M) ((N) == (M)) | ||
154 | +#define DO_NE(N, M) ((N) != (M)) | ||
155 | +#define DO_EQ(N, M) ((N) == (M)) | ||
156 | +#define DO_EQ(N, M) ((N) == (M)) | ||
157 | +#define DO_GE(N, M) ((N) >= (M)) | ||
158 | +#define DO_LT(N, M) ((N) < (M)) | ||
159 | +#define DO_GT(N, M) ((N) > (M)) | ||
160 | +#define DO_LE(N, M) ((N) <= (M)) | ||
161 | + | ||
162 | +DO_VCMP_U(vcmpeq, DO_EQ) | ||
163 | +DO_VCMP_U(vcmpne, DO_NE) | ||
164 | +DO_VCMP_U(vcmpcs, DO_GE) | ||
165 | +DO_VCMP_U(vcmphi, DO_GT) | ||
166 | +DO_VCMP_S(vcmpge, DO_GE) | ||
167 | +DO_VCMP_S(vcmplt, DO_LT) | ||
168 | +DO_VCMP_S(vcmpgt, DO_GT) | ||
169 | +DO_VCMP_S(vcmple, DO_LE) | ||
170 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
171 | index XXXXXXX..XXXXXXX 100644 | ||
172 | --- a/target/arm/translate-mve.c | ||
173 | +++ b/target/arm/translate-mve.c | ||
174 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
175 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
176 | typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
177 | typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
178 | +typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
179 | |||
180 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
181 | static inline long mve_qreg_offset(unsigned reg) | ||
182 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDWDUP(DisasContext *s, arg_viwdup *a) | ||
183 | }; | ||
184 | return do_viwdup(s, a, fns[a->size]); | ||
185 | } | ||
186 | + | ||
187 | +static bool do_vcmp(DisasContext *s, arg_vcmp *a, MVEGenCmpFn *fn) | ||
41 | +{ | 188 | +{ |
42 | + SysBusDevice *dev = SYS_BUS_DEVICE(obj); | 189 | + TCGv_ptr qn, qm; |
43 | + mv88w8618_pit_state *s = MV88W8618_PIT(dev); | 190 | + |
44 | + int i; | 191 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qm) || |
45 | + | 192 | + !fn) { |
46 | + for (i = 0; i < 4; i++) { | 193 | + return false; |
47 | + ptimer_free(s->timer[i].ptimer); | 194 | + } |
48 | + } | 195 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
196 | + return true; | ||
197 | + } | ||
198 | + | ||
199 | + qn = mve_qreg_ptr(a->qn); | ||
200 | + qm = mve_qreg_ptr(a->qm); | ||
201 | + fn(cpu_env, qn, qm); | ||
202 | + tcg_temp_free_ptr(qn); | ||
203 | + tcg_temp_free_ptr(qm); | ||
204 | + if (a->mask) { | ||
205 | + /* VPT */ | ||
206 | + gen_vpst(s, a->mask); | ||
207 | + } | ||
208 | + mve_update_eci(s); | ||
209 | + return true; | ||
49 | +} | 210 | +} |
50 | + | 211 | + |
51 | static const VMStateDescription mv88w8618_timer_vmsd = { | 212 | +#define DO_VCMP(INSN, FN) \ |
52 | .name = "timer", | 213 | + static bool trans_##INSN(DisasContext *s, arg_vcmp *a) \ |
53 | .version_id = 1, | 214 | + { \ |
54 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo mv88w8618_pit_info = { | 215 | + static MVEGenCmpFn * const fns[] = { \ |
55 | .parent = TYPE_SYS_BUS_DEVICE, | 216 | + gen_helper_mve_##FN##b, \ |
56 | .instance_size = sizeof(mv88w8618_pit_state), | 217 | + gen_helper_mve_##FN##h, \ |
57 | .instance_init = mv88w8618_pit_init, | 218 | + gen_helper_mve_##FN##w, \ |
58 | + .instance_finalize = mv88w8618_pit_finalize, | 219 | + NULL, \ |
59 | .class_init = mv88w8618_pit_class_init, | 220 | + }; \ |
60 | }; | 221 | + return do_vcmp(s, a, fns[a->size]); \ |
61 | 222 | + } | |
223 | + | ||
224 | +DO_VCMP(VCMPEQ, vcmpeq) | ||
225 | +DO_VCMP(VCMPNE, vcmpne) | ||
226 | +DO_VCMP(VCMPCS, vcmpcs) | ||
227 | +DO_VCMP(VCMPHI, vcmphi) | ||
228 | +DO_VCMP(VCMPGE, vcmpge) | ||
229 | +DO_VCMP(VCMPLT, vcmplt) | ||
230 | +DO_VCMP(VCMPGT, vcmpgt) | ||
231 | +DO_VCMP(VCMPLE, vcmple) | ||
62 | -- | 232 | -- |
63 | 2.20.1 | 233 | 2.20.1 |
64 | 234 | ||
65 | 235 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | Implement the MVE integer vector comparison instructions that compare |
---|---|---|---|
2 | 2 | each element against a scalar from a general purpose register. These | |
3 | virt machine's 'smp_cpus' and machine->smp.cpus must always have the | 3 | are "VCMP (vector)" encodings T4, T5 and T6 and "VPT (vector)" |
4 | same value. And, anywhere we have virt machine state we have machine | 4 | encodings T4, T5 and T6. |
5 | state. So let's remove the redundancy. Also, to make it easier to see | 5 | |
6 | that machine->smp is the true source for "smp_cpus" and "max_cpus", | 6 | We have to move the decodetree pattern for VPST, because it |
7 | avoid passing them in function parameters, preferring instead to get | 7 | overlaps with VCMP T4 with size = 0b11. |
8 | them from the state. | 8 | |
9 | |||
10 | No functional change intended. | ||
11 | |||
12 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
13 | Reviewed-by: David Edmondson <david.edmondson@oracle.com> | ||
14 | Reviewed-by: Ying Fang <fangying1@huawei.com> | ||
15 | Message-id: 20201215174815.51520-1-drjones@redhat.com | ||
16 | [PMM: minor formatting tweak to smp_cpus variable declaration] | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | --- | 11 | --- |
19 | include/hw/arm/virt.h | 3 +-- | 12 | target/arm/helper-mve.h | 32 +++++++++++++++++++++++++++ |
20 | hw/arm/virt-acpi-build.c | 9 +++++---- | 13 | target/arm/mve.decode | 18 +++++++++++++--- |
21 | hw/arm/virt.c | 21 ++++++++++----------- | 14 | target/arm/mve_helper.c | 44 +++++++++++++++++++++++++++++++------- |
22 | 3 files changed, 16 insertions(+), 17 deletions(-) | 15 | target/arm/translate-mve.c | 43 +++++++++++++++++++++++++++++++++++++ |
23 | 16 | 4 files changed, 126 insertions(+), 11 deletions(-) | |
24 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | 17 | |
25 | index XXXXXXX..XXXXXXX 100644 | 18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
26 | --- a/include/hw/arm/virt.h | 19 | index XXXXXXX..XXXXXXX 100644 |
27 | +++ b/include/hw/arm/virt.h | 20 | --- a/target/arm/helper-mve.h |
28 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineState { | 21 | +++ b/target/arm/helper-mve.h |
29 | MemMapEntry *memmap; | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vcmpgtw, TCG_CALL_NO_WG, void, env, ptr, ptr) |
30 | char *pciehb_nodename; | 23 | DEF_HELPER_FLAGS_3(mve_vcmpleb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
31 | const int *irqmap; | 24 | DEF_HELPER_FLAGS_3(mve_vcmpleh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
32 | - int smp_cpus; | 25 | DEF_HELPER_FLAGS_3(mve_vcmplew, TCG_CALL_NO_WG, void, env, ptr, ptr) |
33 | void *fdt; | 26 | + |
34 | int fdt_size; | 27 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) |
35 | uint32_t clock_phandle; | 28 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) |
36 | @@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) | 29 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) |
37 | 30 | + | |
38 | assert(vms->gic_version == VIRT_GIC_VERSION_3); | 31 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) |
39 | 32 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | |
40 | - return vms->smp_cpus > redist0_capacity ? 2 : 1; | 33 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) |
41 | + return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1; | 34 | + |
35 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
37 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
38 | + | ||
39 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
42 | + | ||
43 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
44 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
45 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
46 | + | ||
47 | +DEF_HELPER_FLAGS_3(mve_vcmplt_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
48 | +DEF_HELPER_FLAGS_3(mve_vcmplt_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
49 | +DEF_HELPER_FLAGS_3(mve_vcmplt_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
50 | + | ||
51 | +DEF_HELPER_FLAGS_3(mve_vcmpgt_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_3(mve_vcmpgt_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
53 | +DEF_HELPER_FLAGS_3(mve_vcmpgt_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
54 | + | ||
55 | +DEF_HELPER_FLAGS_3(mve_vcmple_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
56 | +DEF_HELPER_FLAGS_3(mve_vcmple_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
57 | +DEF_HELPER_FLAGS_3(mve_vcmple_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
58 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/mve.decode | ||
61 | +++ b/target/arm/mve.decode | ||
62 | @@ -XXX,XX +XXX,XX @@ | ||
63 | &vidup qd rn size imm | ||
64 | &viwdup qd rn rm size imm | ||
65 | &vcmp qm qn size mask | ||
66 | +&vcmp_scalar qn rm size mask | ||
67 | |||
68 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
69 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
70 | @@ -XXX,XX +XXX,XX @@ | ||
71 | # Vector comparison; 4-bit Qm but 3-bit Qn | ||
72 | %mask_22_13 22:1 13:3 | ||
73 | @vcmp .... .... .. size:2 qn:3 . .... .... .... .... &vcmp qm=%qm mask=%mask_22_13 | ||
74 | +@vcmp_scalar .... .... .. size:2 qn:3 . .... .... .... rm:4 &vcmp_scalar \ | ||
75 | + mask=%mask_22_13 | ||
76 | |||
77 | # Vector loads and stores | ||
78 | |||
79 | @@ -XXX,XX +XXX,XX @@ VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
80 | rdahi=%rdahi rdalo=%rdalo | ||
42 | } | 81 | } |
43 | 82 | ||
44 | #endif /* QEMU_ARM_VIRT_H */ | 83 | -# Predicate operations |
45 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 84 | -VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 |
46 | index XXXXXXX..XXXXXXX 100644 | 85 | - |
47 | --- a/hw/arm/virt-acpi-build.c | 86 | # Logical immediate operations (1 reg and modified-immediate) |
48 | +++ b/hw/arm/virt-acpi-build.c | 87 | |
49 | @@ -XXX,XX +XXX,XX @@ | 88 | # The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but |
50 | 89 | @@ -XXX,XX +XXX,XX @@ VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | |
51 | #define ACPI_BUILD_TABLE_SIZE 0x20000 | 90 | VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp |
52 | 91 | VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | |
53 | -static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) | 92 | VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp |
54 | +static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineState *vms) | 93 | + |
55 | { | 94 | +{ |
56 | + MachineState *ms = MACHINE(vms); | 95 | + VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 |
57 | uint16_t i; | 96 | + VCMPEQ_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 0 0 .... @vcmp_scalar |
58 | 97 | +} | |
59 | - for (i = 0; i < smp_cpus; i++) { | 98 | +VCMPNE_scalar 1111 1110 0 . .. ... 1 ... 0 1111 1 1 0 0 .... @vcmp_scalar |
60 | + for (i = 0; i < ms->smp.cpus; i++) { | 99 | +VCMPCS_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 1 0 .... @vcmp_scalar |
61 | Aml *dev = aml_device("C%.03X", i); | 100 | +VCMPHI_scalar 1111 1110 0 . .. ... 1 ... 0 1111 1 1 1 0 .... @vcmp_scalar |
62 | aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007"))); | 101 | +VCMPGE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 0 0 .... @vcmp_scalar |
63 | aml_append(dev, aml_name_decl("_UID", aml_int(i))); | 102 | +VCMPLT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 0 0 .... @vcmp_scalar |
64 | @@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 103 | +VCMPGT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 1 0 .... @vcmp_scalar |
65 | gicd->base_address = cpu_to_le64(memmap[VIRT_GIC_DIST].base); | 104 | +VCMPLE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 1 0 .... @vcmp_scalar |
66 | gicd->version = vms->gic_version; | 105 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
67 | 106 | index XXXXXXX..XXXXXXX 100644 | |
68 | - for (i = 0; i < vms->smp_cpus; i++) { | 107 | --- a/target/arm/mve_helper.c |
69 | + for (i = 0; i < MACHINE(vms)->smp.cpus; i++) { | 108 | +++ b/target/arm/mve_helper.c |
70 | AcpiMadtGenericCpuInterface *gicc = acpi_data_push(table_data, | 109 | @@ -XXX,XX +XXX,XX @@ DO_VIWDUP_ALL(vdwdup, do_sub_wrap) |
71 | sizeof(*gicc)); | 110 | mve_advance_vpt(env); \ |
72 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i)); | ||
73 | @@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
74 | * the RTC ACPI device at all when using UEFI. | ||
75 | */ | ||
76 | scope = aml_scope("\\_SB"); | ||
77 | - acpi_dsdt_add_cpus(scope, vms->smp_cpus); | ||
78 | + acpi_dsdt_add_cpus(scope, vms); | ||
79 | acpi_dsdt_add_uart(scope, &memmap[VIRT_UART], | ||
80 | (irqmap[VIRT_UART] + ARM_SPI_BASE)); | ||
81 | if (vmc->acpi_expose_flash) { | ||
82 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/hw/arm/virt.c | ||
85 | +++ b/hw/arm/virt.c | ||
86 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms) | ||
87 | if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
88 | irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START, | ||
89 | GIC_FDT_IRQ_PPI_CPU_WIDTH, | ||
90 | - (1 << vms->smp_cpus) - 1); | ||
91 | + (1 << MACHINE(vms)->smp.cpus) - 1); | ||
92 | } | 111 | } |
93 | 112 | ||
94 | qemu_fdt_add_subnode(vms->fdt, "/timer"); | 113 | -#define DO_VCMP_S(OP, FN) \ |
95 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | 114 | - DO_VCMP(OP##b, 1, int8_t, FN) \ |
96 | int cpu; | 115 | - DO_VCMP(OP##h, 2, int16_t, FN) \ |
97 | int addr_cells = 1; | 116 | - DO_VCMP(OP##w, 4, int32_t, FN) |
98 | const MachineState *ms = MACHINE(vms); | 117 | +#define DO_VCMP_SCALAR(OP, ESIZE, TYPE, FN) \ |
99 | + int smp_cpus = ms->smp.cpus; | 118 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ |
100 | 119 | + uint32_t rm) \ | |
101 | /* | 120 | + { \ |
102 | * From Documentation/devicetree/bindings/arm/cpus.txt | 121 | + TYPE *n = vn; \ |
103 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | 122 | + uint16_t mask = mve_element_mask(env); \ |
104 | * The simplest way to go is to examine affinity IDs of all our CPUs. If | 123 | + uint16_t eci_mask = mve_eci_mask(env); \ |
105 | * at least one of them has Aff3 populated, we set #address-cells to 2. | 124 | + uint16_t beatpred = 0; \ |
106 | */ | 125 | + uint16_t emask = MAKE_64BIT_MASK(0, ESIZE); \ |
107 | - for (cpu = 0; cpu < vms->smp_cpus; cpu++) { | 126 | + unsigned e; \ |
108 | + for (cpu = 0; cpu < smp_cpus; cpu++) { | 127 | + for (e = 0; e < 16 / ESIZE; e++) { \ |
109 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); | 128 | + bool r = FN(n[H##ESIZE(e)], (TYPE)rm); \ |
110 | 129 | + /* Comparison sets 0/1 bits for each byte in the element */ \ | |
111 | if (armcpu->mp_affinity & ARM_AFF3_MASK) { | 130 | + beatpred |= r * emask; \ |
112 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | 131 | + emask <<= ESIZE; \ |
113 | qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#address-cells", addr_cells); | 132 | + } \ |
114 | qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#size-cells", 0x0); | 133 | + beatpred &= mask; \ |
115 | 134 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | \ | |
116 | - for (cpu = vms->smp_cpus - 1; cpu >= 0; cpu--) { | 135 | + (beatpred & eci_mask); \ |
117 | + for (cpu = smp_cpus - 1; cpu >= 0; cpu--) { | 136 | + mve_advance_vpt(env); \ |
118 | char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu); | 137 | + } |
119 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); | 138 | |
120 | CPUState *cs = CPU(armcpu); | 139 | -#define DO_VCMP_U(OP, FN) \ |
121 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | 140 | - DO_VCMP(OP##b, 1, uint8_t, FN) \ |
122 | qemu_fdt_setprop_string(vms->fdt, nodename, "compatible", | 141 | - DO_VCMP(OP##h, 2, uint16_t, FN) \ |
123 | armcpu->dtb_compatible); | 142 | - DO_VCMP(OP##w, 4, uint32_t, FN) |
124 | 143 | +#define DO_VCMP_S(OP, FN) \ | |
125 | - if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED | 144 | + DO_VCMP(OP##b, 1, int8_t, FN) \ |
126 | - && vms->smp_cpus > 1) { | 145 | + DO_VCMP(OP##h, 2, int16_t, FN) \ |
127 | + if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED && smp_cpus > 1) { | 146 | + DO_VCMP(OP##w, 4, int32_t, FN) \ |
128 | qemu_fdt_setprop_string(vms->fdt, nodename, | 147 | + DO_VCMP_SCALAR(OP##_scalarb, 1, int8_t, FN) \ |
129 | "enable-method", "psci"); | 148 | + DO_VCMP_SCALAR(OP##_scalarh, 2, int16_t, FN) \ |
130 | } | 149 | + DO_VCMP_SCALAR(OP##_scalarw, 4, int32_t, FN) |
131 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) | 150 | + |
132 | if (vms->gic_version == VIRT_GIC_VERSION_2) { | 151 | +#define DO_VCMP_U(OP, FN) \ |
133 | irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START, | 152 | + DO_VCMP(OP##b, 1, uint8_t, FN) \ |
134 | GIC_FDT_IRQ_PPI_CPU_WIDTH, | 153 | + DO_VCMP(OP##h, 2, uint16_t, FN) \ |
135 | - (1 << vms->smp_cpus) - 1); | 154 | + DO_VCMP(OP##w, 4, uint32_t, FN) \ |
136 | + (1 << MACHINE(vms)->smp.cpus) - 1); | 155 | + DO_VCMP_SCALAR(OP##_scalarb, 1, uint8_t, FN) \ |
156 | + DO_VCMP_SCALAR(OP##_scalarh, 2, uint16_t, FN) \ | ||
157 | + DO_VCMP_SCALAR(OP##_scalarw, 4, uint32_t, FN) | ||
158 | |||
159 | #define DO_EQ(N, M) ((N) == (M)) | ||
160 | #define DO_NE(N, M) ((N) != (M)) | ||
161 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
162 | index XXXXXXX..XXXXXXX 100644 | ||
163 | --- a/target/arm/translate-mve.c | ||
164 | +++ b/target/arm/translate-mve.c | ||
165 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
166 | typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
167 | typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
168 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
169 | +typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
170 | |||
171 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
172 | static inline long mve_qreg_offset(unsigned reg) | ||
173 | @@ -XXX,XX +XXX,XX @@ static bool do_vcmp(DisasContext *s, arg_vcmp *a, MVEGenCmpFn *fn) | ||
174 | return true; | ||
175 | } | ||
176 | |||
177 | +static bool do_vcmp_scalar(DisasContext *s, arg_vcmp_scalar *a, | ||
178 | + MVEGenScalarCmpFn *fn) | ||
179 | +{ | ||
180 | + TCGv_ptr qn; | ||
181 | + TCGv_i32 rm; | ||
182 | + | ||
183 | + if (!dc_isar_feature(aa32_mve, s) || !fn || a->rm == 13) { | ||
184 | + return false; | ||
185 | + } | ||
186 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
187 | + return true; | ||
188 | + } | ||
189 | + | ||
190 | + qn = mve_qreg_ptr(a->qn); | ||
191 | + if (a->rm == 15) { | ||
192 | + /* Encoding Rm=0b1111 means "constant zero" */ | ||
193 | + rm = tcg_constant_i32(0); | ||
194 | + } else { | ||
195 | + rm = load_reg(s, a->rm); | ||
196 | + } | ||
197 | + fn(cpu_env, qn, rm); | ||
198 | + tcg_temp_free_ptr(qn); | ||
199 | + tcg_temp_free_i32(rm); | ||
200 | + if (a->mask) { | ||
201 | + /* VPT */ | ||
202 | + gen_vpst(s, a->mask); | ||
203 | + } | ||
204 | + mve_update_eci(s); | ||
205 | + return true; | ||
206 | +} | ||
207 | + | ||
208 | #define DO_VCMP(INSN, FN) \ | ||
209 | static bool trans_##INSN(DisasContext *s, arg_vcmp *a) \ | ||
210 | { \ | ||
211 | @@ -XXX,XX +XXX,XX @@ static bool do_vcmp(DisasContext *s, arg_vcmp *a, MVEGenCmpFn *fn) | ||
212 | NULL, \ | ||
213 | }; \ | ||
214 | return do_vcmp(s, a, fns[a->size]); \ | ||
215 | + } \ | ||
216 | + static bool trans_##INSN##_scalar(DisasContext *s, \ | ||
217 | + arg_vcmp_scalar *a) \ | ||
218 | + { \ | ||
219 | + static MVEGenScalarCmpFn * const fns[] = { \ | ||
220 | + gen_helper_mve_##FN##_scalarb, \ | ||
221 | + gen_helper_mve_##FN##_scalarh, \ | ||
222 | + gen_helper_mve_##FN##_scalarw, \ | ||
223 | + NULL, \ | ||
224 | + }; \ | ||
225 | + return do_vcmp_scalar(s, a, fns[a->size]); \ | ||
137 | } | 226 | } |
138 | 227 | ||
139 | qemu_fdt_add_subnode(vms->fdt, "/pmu"); | 228 | DO_VCMP(VCMPEQ, vcmpeq) |
140 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) | ||
141 | * virt_cpu_post_init() must be called after the CPUs have | ||
142 | * been realized and the GIC has been created. | ||
143 | */ | ||
144 | -static void virt_cpu_post_init(VirtMachineState *vms, int max_cpus, | ||
145 | - MemoryRegion *sysmem) | ||
146 | +static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem) | ||
147 | { | ||
148 | + int max_cpus = MACHINE(vms)->smp.max_cpus; | ||
149 | bool aarch64, pmu, steal_time; | ||
150 | CPUState *cpu; | ||
151 | |||
152 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
153 | exit(1); | ||
154 | } | ||
155 | |||
156 | - vms->smp_cpus = smp_cpus; | ||
157 | - | ||
158 | if (vms->virt && kvm_enabled()) { | ||
159 | error_report("mach-virt: KVM does not support providing " | ||
160 | "Virtualization extensions to the guest CPU"); | ||
161 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
162 | create_fdt(vms); | ||
163 | |||
164 | possible_cpus = mc->possible_cpu_arch_ids(machine); | ||
165 | + assert(possible_cpus->len == max_cpus); | ||
166 | for (n = 0; n < possible_cpus->len; n++) { | ||
167 | Object *cpuobj; | ||
168 | CPUState *cs; | ||
169 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
170 | |||
171 | create_gic(vms); | ||
172 | |||
173 | - virt_cpu_post_init(vms, possible_cpus->len, sysmem); | ||
174 | + virt_cpu_post_init(vms, sysmem); | ||
175 | |||
176 | fdt_add_pmu_nodes(vms); | ||
177 | |||
178 | -- | 229 | -- |
179 | 2.20.1 | 230 | 2.20.1 |
180 | 231 | ||
181 | 232 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the MVE VPSEL insn, which sets each byte of the destination | ||
2 | vector Qd to the byte from either Qn or Qm depending on the value of | ||
3 | the corresponding bit in VPR.P0. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 2 ++ | ||
9 | target/arm/mve.decode | 7 +++++-- | ||
10 | target/arm/mve_helper.c | 19 +++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 2 ++ | ||
12 | 4 files changed, 28 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper-mve.h | ||
17 | +++ b/target/arm/helper-mve.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vorr, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | |||
22 | +DEF_HELPER_FLAGS_4(mve_vpsel, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
23 | + | ||
24 | DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | DEF_HELPER_FLAGS_4(mve_vaddw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/mve.decode | ||
30 | +++ b/target/arm/mve.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | ||
32 | # effectively "VCMP then VPST". A plain "VCMP" has a mask field of zero. | ||
33 | VCMPEQ 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 0 @vcmp | ||
34 | VCMPNE 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 0 @vcmp | ||
35 | -VCMPCS 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 1 @vcmp | ||
36 | -VCMPHI 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 1 @vcmp | ||
37 | +{ | ||
38 | + VPSEL 1111 1110 0 . 11 ... 1 ... 0 1111 . 0 . 0 ... 1 @2op_nosz | ||
39 | + VCMPCS 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 1 @vcmp | ||
40 | + VCMPHI 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 1 @vcmp | ||
41 | +} | ||
42 | VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | ||
43 | VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | ||
44 | VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
45 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/mve_helper.c | ||
48 | +++ b/target/arm/mve_helper.c | ||
49 | @@ -XXX,XX +XXX,XX @@ DO_VCMP_S(vcmpge, DO_GE) | ||
50 | DO_VCMP_S(vcmplt, DO_LT) | ||
51 | DO_VCMP_S(vcmpgt, DO_GT) | ||
52 | DO_VCMP_S(vcmple, DO_LE) | ||
53 | + | ||
54 | +void HELPER(mve_vpsel)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
55 | +{ | ||
56 | + /* | ||
57 | + * Qd[n] = VPR.P0[n] ? Qn[n] : Qm[n] | ||
58 | + * but note that whether bytes are written to Qd is still subject | ||
59 | + * to (all forms of) predication in the usual way. | ||
60 | + */ | ||
61 | + uint64_t *d = vd, *n = vn, *m = vm; | ||
62 | + uint16_t mask = mve_element_mask(env); | ||
63 | + uint16_t p0 = FIELD_EX32(env->v7m.vpr, V7M_VPR, P0); | ||
64 | + unsigned e; | ||
65 | + for (e = 0; e < 16 / 8; e++, mask >>= 8, p0 >>= 8) { | ||
66 | + uint64_t r = m[H8(e)]; | ||
67 | + mergemask(&r, n[H8(e)], p0); | ||
68 | + mergemask(&d[H8(e)], r, mask); | ||
69 | + } | ||
70 | + mve_advance_vpt(env); | ||
71 | +} | ||
72 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/target/arm/translate-mve.c | ||
75 | +++ b/target/arm/translate-mve.c | ||
76 | @@ -XXX,XX +XXX,XX @@ DO_LOGIC(VORR, gen_helper_mve_vorr) | ||
77 | DO_LOGIC(VORN, gen_helper_mve_vorn) | ||
78 | DO_LOGIC(VEOR, gen_helper_mve_veor) | ||
79 | |||
80 | +DO_LOGIC(VPSEL, gen_helper_mve_vpsel) | ||
81 | + | ||
82 | #define DO_2OP(INSN, FN) \ | ||
83 | static bool trans_##INSN(DisasContext *s, arg_2op *a) \ | ||
84 | { \ | ||
85 | -- | ||
86 | 2.20.1 | ||
87 | |||
88 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the MVE VMLAS insn, which multiplies a vector by a vector | ||
2 | and adds a scalar. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 4 ++++ | ||
8 | target/arm/mve.decode | 3 +++ | ||
9 | target/arm/mve_helper.c | 26 ++++++++++++++++++++++++++ | ||
10 | target/arm/translate-mve.c | 1 + | ||
11 | 4 files changed, 34 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper-mve.h | ||
16 | +++ b/target/arm/helper-mve.h | ||
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i3 | ||
18 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | |||
21 | +DEF_HELPER_FLAGS_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vmlash, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vmlasw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
26 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
27 | DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/mve.decode | ||
31 | +++ b/target/arm/mve.decode | ||
32 | @@ -XXX,XX +XXX,XX @@ VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
33 | VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
34 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
35 | |||
36 | +# The U bit (28) is don't-care because it does not affect the result | ||
37 | +VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
38 | + | ||
39 | # Vector add across vector | ||
40 | { | ||
41 | VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
42 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/mve_helper.c | ||
45 | +++ b/target/arm/mve_helper.c | ||
46 | @@ -XXX,XX +XXX,XX @@ DO_VQDMLADH_OP(vqrdmlsdhxw, 4, int32_t, 1, 1, do_vqdmlsdh_w) | ||
47 | mve_advance_vpt(env); \ | ||
48 | } | ||
49 | |||
50 | +/* "accumulating" version where FN takes d as well as n and m */ | ||
51 | +#define DO_2OP_ACC_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
52 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
53 | + uint32_t rm) \ | ||
54 | + { \ | ||
55 | + TYPE *d = vd, *n = vn; \ | ||
56 | + TYPE m = rm; \ | ||
57 | + uint16_t mask = mve_element_mask(env); \ | ||
58 | + unsigned e; \ | ||
59 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
60 | + mergemask(&d[H##ESIZE(e)], \ | ||
61 | + FN(d[H##ESIZE(e)], n[H##ESIZE(e)], m), mask); \ | ||
62 | + } \ | ||
63 | + mve_advance_vpt(env); \ | ||
64 | + } | ||
65 | + | ||
66 | /* provide unsigned 2-op scalar helpers for all sizes */ | ||
67 | #define DO_2OP_SCALAR_U(OP, FN) \ | ||
68 | DO_2OP_SCALAR(OP##b, 1, uint8_t, FN) \ | ||
69 | @@ -XXX,XX +XXX,XX @@ DO_VQDMLADH_OP(vqrdmlsdhxw, 4, int32_t, 1, 1, do_vqdmlsdh_w) | ||
70 | DO_2OP_SCALAR(OP##h, 2, int16_t, FN) \ | ||
71 | DO_2OP_SCALAR(OP##w, 4, int32_t, FN) | ||
72 | |||
73 | +#define DO_2OP_ACC_SCALAR_U(OP, FN) \ | ||
74 | + DO_2OP_ACC_SCALAR(OP##b, 1, uint8_t, FN) \ | ||
75 | + DO_2OP_ACC_SCALAR(OP##h, 2, uint16_t, FN) \ | ||
76 | + DO_2OP_ACC_SCALAR(OP##w, 4, uint32_t, FN) | ||
77 | + | ||
78 | DO_2OP_SCALAR_U(vadd_scalar, DO_ADD) | ||
79 | DO_2OP_SCALAR_U(vsub_scalar, DO_SUB) | ||
80 | DO_2OP_SCALAR_U(vmul_scalar, DO_MUL) | ||
81 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) | ||
82 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) | ||
83 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W) | ||
84 | |||
85 | +/* Vector by vector plus scalar */ | ||
86 | +#define DO_VMLAS(D, N, M) ((N) * (D) + (M)) | ||
87 | + | ||
88 | +DO_2OP_ACC_SCALAR_U(vmlas, DO_VMLAS) | ||
89 | + | ||
90 | /* | ||
91 | * Long saturating scalar ops. As with DO_2OP_L, TYPE and H are for the | ||
92 | * input (smaller) type and LESIZE, LTYPE, LH for the output (long) type. | ||
93 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/translate-mve.c | ||
96 | +++ b/target/arm/translate-mve.c | ||
97 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VQSUB_U_scalar, vqsubu_scalar) | ||
98 | DO_2OP_SCALAR(VQDMULH_scalar, vqdmulh_scalar) | ||
99 | DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) | ||
100 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
101 | +DO_2OP_SCALAR(VMLAS, vmlas) | ||
102 | |||
103 | static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a) | ||
104 | { | ||
105 | -- | ||
106 | 2.20.1 | ||
107 | |||
108 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the MVE instructions which perform shifts by a scalar. | ||
2 | These are VSHL T2, VRSHL T2, VQSHL T1 and VQRSHL T2. They take the | ||
3 | shift amount in a general purpose register and shift every element in | ||
4 | the vector by that amount. | ||
1 | 5 | ||
6 | Mostly we can reuse the helper functions for shift-by-immediate; we | ||
7 | do need two new helpers for VQRSHL. | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper-mve.h | 8 +++++++ | ||
13 | target/arm/mve.decode | 23 ++++++++++++++++--- | ||
14 | target/arm/mve_helper.c | 2 ++ | ||
15 | target/arm/translate-mve.c | 46 ++++++++++++++++++++++++++++++++++++++ | ||
16 | 4 files changed, 76 insertions(+), 3 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper-mve.h | ||
21 | +++ b/target/arm/helper-mve.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
25 | |||
26 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_4(mve_vqrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vqrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | + | ||
34 | DEF_HELPER_FLAGS_4(mve_vshllbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | DEF_HELPER_FLAGS_4(mve_vshllbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | DEF_HELPER_FLAGS_4(mve_vshllbub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/mve.decode | ||
40 | +++ b/target/arm/mve.decode | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | &viwdup qd rn rm size imm | ||
43 | &vcmp qm qn size mask | ||
44 | &vcmp_scalar qn rm size mask | ||
45 | +&shl_scalar qda rm size | ||
46 | |||
47 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
48 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | @2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
51 | size=2 shift=%rshift_i5 | ||
52 | |||
53 | +@shl_scalar .... .... .... size:2 .. .... .... .... rm:4 &shl_scalar qda=%qd | ||
54 | + | ||
55 | # Vector comparison; 4-bit Qm but 3-bit Qn | ||
56 | %mask_22_13 22:1 13:3 | ||
57 | @vcmp .... .... .. size:2 qn:3 . .... .... .... .... &vcmp qm=%qm mask=%mask_22_13 | ||
58 | @@ -XXX,XX +XXX,XX @@ VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_no | ||
59 | |||
60 | VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar | ||
61 | VSUB_scalar 1110 1110 0 . .. ... 1 ... 1 1111 . 100 .... @2scalar | ||
62 | -VMUL_scalar 1110 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
63 | + | ||
64 | +{ | ||
65 | + VSHL_S_scalar 1110 1110 0 . 11 .. 01 ... 1 1110 0110 .... @shl_scalar | ||
66 | + VRSHL_S_scalar 1110 1110 0 . 11 .. 11 ... 1 1110 0110 .... @shl_scalar | ||
67 | + VQSHL_S_scalar 1110 1110 0 . 11 .. 01 ... 1 1110 1110 .... @shl_scalar | ||
68 | + VQRSHL_S_scalar 1110 1110 0 . 11 .. 11 ... 1 1110 1110 .... @shl_scalar | ||
69 | + VMUL_scalar 1110 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
70 | +} | ||
71 | + | ||
72 | +{ | ||
73 | + VSHL_U_scalar 1111 1110 0 . 11 .. 01 ... 1 1110 0110 .... @shl_scalar | ||
74 | + VRSHL_U_scalar 1111 1110 0 . 11 .. 11 ... 1 1110 0110 .... @shl_scalar | ||
75 | + VQSHL_U_scalar 1111 1110 0 . 11 .. 01 ... 1 1110 1110 .... @shl_scalar | ||
76 | + VQRSHL_U_scalar 1111 1110 0 . 11 .. 11 ... 1 1110 1110 .... @shl_scalar | ||
77 | + VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
78 | +} | ||
79 | + | ||
80 | VHADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
81 | VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
82 | VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
83 | @@ -XXX,XX +XXX,XX @@ VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
84 | size=%size_28 | ||
85 | } | ||
86 | |||
87 | -VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
88 | - | ||
89 | VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
90 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
91 | |||
92 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/mve_helper.c | ||
95 | +++ b/target/arm/mve_helper.c | ||
96 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
97 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
98 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
99 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
100 | +DO_2SHIFT_SAT_U(vqrshli_u, DO_UQRSHL_OP) | ||
101 | +DO_2SHIFT_SAT_S(vqrshli_s, DO_SQRSHL_OP) | ||
102 | |||
103 | /* Shift-and-insert; we always work with 64 bits at a time */ | ||
104 | #define DO_2SHIFT_INSERT(OP, ESIZE, SHIFTFN, MASKFN) \ | ||
105 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/translate-mve.c | ||
108 | +++ b/target/arm/translate-mve.c | ||
109 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
110 | DO_2SHIFT(VSRI, vsri, false) | ||
111 | DO_2SHIFT(VSLI, vsli, false) | ||
112 | |||
113 | +static bool do_2shift_scalar(DisasContext *s, arg_shl_scalar *a, | ||
114 | + MVEGenTwoOpShiftFn *fn) | ||
115 | +{ | ||
116 | + TCGv_ptr qda; | ||
117 | + TCGv_i32 rm; | ||
118 | + | ||
119 | + if (!dc_isar_feature(aa32_mve, s) || | ||
120 | + !mve_check_qreg_bank(s, a->qda) || | ||
121 | + a->rm == 13 || a->rm == 15 || !fn) { | ||
122 | + /* Rm cases are UNPREDICTABLE */ | ||
123 | + return false; | ||
124 | + } | ||
125 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
126 | + return true; | ||
127 | + } | ||
128 | + | ||
129 | + qda = mve_qreg_ptr(a->qda); | ||
130 | + rm = load_reg(s, a->rm); | ||
131 | + fn(cpu_env, qda, qda, rm); | ||
132 | + tcg_temp_free_ptr(qda); | ||
133 | + tcg_temp_free_i32(rm); | ||
134 | + mve_update_eci(s); | ||
135 | + return true; | ||
136 | +} | ||
137 | + | ||
138 | +#define DO_2SHIFT_SCALAR(INSN, FN) \ | ||
139 | + static bool trans_##INSN(DisasContext *s, arg_shl_scalar *a) \ | ||
140 | + { \ | ||
141 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
142 | + gen_helper_mve_##FN##b, \ | ||
143 | + gen_helper_mve_##FN##h, \ | ||
144 | + gen_helper_mve_##FN##w, \ | ||
145 | + NULL, \ | ||
146 | + }; \ | ||
147 | + return do_2shift_scalar(s, a, fns[a->size]); \ | ||
148 | + } | ||
149 | + | ||
150 | +DO_2SHIFT_SCALAR(VSHL_S_scalar, vshli_s) | ||
151 | +DO_2SHIFT_SCALAR(VSHL_U_scalar, vshli_u) | ||
152 | +DO_2SHIFT_SCALAR(VRSHL_S_scalar, vrshli_s) | ||
153 | +DO_2SHIFT_SCALAR(VRSHL_U_scalar, vrshli_u) | ||
154 | +DO_2SHIFT_SCALAR(VQSHL_S_scalar, vqshli_s) | ||
155 | +DO_2SHIFT_SCALAR(VQSHL_U_scalar, vqshli_u) | ||
156 | +DO_2SHIFT_SCALAR(VQRSHL_S_scalar, vqrshli_s) | ||
157 | +DO_2SHIFT_SCALAR(VQRSHL_U_scalar, vqrshli_u) | ||
158 | + | ||
159 | #define DO_VSHLL(INSN, FN) \ | ||
160 | static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
161 | { \ | ||
162 | -- | ||
163 | 2.20.1 | ||
164 | |||
165 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | All the users of the vmlaldav formats have an 'x bit in bit 12 and an | ||
2 | 'a' bit in bit 5; move these to the format rather than specifying them | ||
3 | in each insn pattern. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | target/arm/mve.decode | 16 ++++++++-------- | ||
9 | 1 file changed, 8 insertions(+), 8 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/mve.decode | ||
14 | +++ b/target/arm/mve.decode | ||
15 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
16 | |||
17 | &vmlaldav rdahi rdalo size qn qm x a | ||
18 | |||
19 | -@vmlaldav .... .... . ... ... . ... . .... .... qm:3 . \ | ||
20 | +@vmlaldav .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
21 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav | ||
22 | -@vmlaldav_nosz .... .... . ... ... . ... . .... .... qm:3 . \ | ||
23 | +@vmlaldav_nosz .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
24 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=0 &vmlaldav | ||
25 | -VMLALDAV_S 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
26 | -VMLALDAV_U 1111 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
27 | +VMLALDAV_S 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
28 | +VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
29 | |||
30 | -VMLSLDAV 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav | ||
31 | +VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
32 | |||
33 | -VRMLALDAVH_S 1110 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz | ||
34 | -VRMLALDAVH_U 1111 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz | ||
35 | +VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
36 | +VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
37 | |||
38 | -VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_nosz | ||
39 | +VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | ||
40 | |||
41 | # Scalar operations | ||
42 | |||
43 | -- | ||
44 | 2.20.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | Implement the MVE integer min/max across vector insns | |
2 | VMAXV, VMINV, VMAXAV and VMINAV, which find the maximum | ||
3 | from the vector elements and a general purpose register, | ||
4 | and store the maximum back into the general purpose | ||
5 | register. | ||
6 | |||
7 | These insns overlap with VRMLALDAVH (they use what would | ||
8 | be RdaHi=0b110). | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | target/arm/helper-mve.h | 20 ++++++++++++ | ||
14 | target/arm/mve.decode | 18 +++++++++-- | ||
15 | target/arm/mve_helper.c | 66 ++++++++++++++++++++++++++++++++++++++ | ||
16 | target/arm/translate-mve.c | 48 +++++++++++++++++++++++++++ | ||
17 | 4 files changed, 150 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/helper-mve.h | ||
22 | +++ b/target/arm/helper-mve.h | ||
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
24 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
25 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
26 | |||
27 | +DEF_HELPER_FLAGS_3(mve_vmaxvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_3(mve_vmaxvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vmaxvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vmaxvub, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_3(mve_vmaxvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_3(mve_vmaxvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_3(mve_vmaxavb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vmaxavh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
35 | +DEF_HELPER_FLAGS_3(mve_vmaxavw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
36 | + | ||
37 | +DEF_HELPER_FLAGS_3(mve_vminvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_3(mve_vminvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_3(mve_vminvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_3(mve_vminvub, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vminvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
42 | +DEF_HELPER_FLAGS_3(mve_vminvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
43 | +DEF_HELPER_FLAGS_3(mve_vminavb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
44 | +DEF_HELPER_FLAGS_3(mve_vminavh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
45 | +DEF_HELPER_FLAGS_3(mve_vminavw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
46 | + | ||
47 | DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
48 | DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
49 | |||
50 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/mve.decode | ||
53 | +++ b/target/arm/mve.decode | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | &vcmp qm qn size mask | ||
56 | &vcmp_scalar qn rm size mask | ||
57 | &shl_scalar qda rm size | ||
58 | +&vmaxv qm rda size | ||
59 | |||
60 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
61 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
62 | @@ -XXX,XX +XXX,XX @@ | ||
63 | @vcmp_scalar .... .... .. size:2 qn:3 . .... .... .... rm:4 &vcmp_scalar \ | ||
64 | mask=%mask_22_13 | ||
65 | |||
66 | +@vmaxv .... .... .... size:2 .. rda:4 .... .... .... &vmaxv qm=%qm | ||
67 | + | ||
68 | # Vector loads and stores | ||
69 | |||
70 | # Widening loads and narrowing stores: | ||
71 | @@ -XXX,XX +XXX,XX @@ VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
72 | |||
73 | VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
74 | |||
75 | -VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
76 | -VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
77 | +{ | ||
78 | + VMAXV_S 1110 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
79 | + VMINV_S 1110 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
80 | + VMAXAV 1110 1110 1110 .. 00 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
81 | + VMINAV 1110 1110 1110 .. 00 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
82 | + VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
83 | +} | ||
84 | + | ||
85 | +{ | ||
86 | + VMAXV_U 1111 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
87 | + VMINV_U 1111 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
88 | + VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
89 | +} | ||
90 | |||
91 | VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | ||
92 | |||
93 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/mve_helper.c | ||
96 | +++ b/target/arm/mve_helper.c | ||
97 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvub, 1, uint8_t) | ||
98 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
99 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
100 | |||
101 | +/* | ||
102 | + * Vector max/min across vector. Unlike VADDV, we must | ||
103 | + * read ra as the element size, not its full width. | ||
104 | + * We work with int64_t internally for simplicity. | ||
105 | + */ | ||
106 | +#define DO_VMAXMINV(OP, ESIZE, TYPE, RATYPE, FN) \ | ||
107 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
108 | + uint32_t ra_in) \ | ||
109 | + { \ | ||
110 | + uint16_t mask = mve_element_mask(env); \ | ||
111 | + unsigned e; \ | ||
112 | + TYPE *m = vm; \ | ||
113 | + int64_t ra = (RATYPE)ra_in; \ | ||
114 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
115 | + if (mask & 1) { \ | ||
116 | + ra = FN(ra, m[H##ESIZE(e)]); \ | ||
117 | + } \ | ||
118 | + } \ | ||
119 | + mve_advance_vpt(env); \ | ||
120 | + return ra; \ | ||
121 | + } \ | ||
122 | + | ||
123 | +#define DO_VMAXMINV_U(INSN, FN) \ | ||
124 | + DO_VMAXMINV(INSN##b, 1, uint8_t, uint8_t, FN) \ | ||
125 | + DO_VMAXMINV(INSN##h, 2, uint16_t, uint16_t, FN) \ | ||
126 | + DO_VMAXMINV(INSN##w, 4, uint32_t, uint32_t, FN) | ||
127 | +#define DO_VMAXMINV_S(INSN, FN) \ | ||
128 | + DO_VMAXMINV(INSN##b, 1, int8_t, int8_t, FN) \ | ||
129 | + DO_VMAXMINV(INSN##h, 2, int16_t, int16_t, FN) \ | ||
130 | + DO_VMAXMINV(INSN##w, 4, int32_t, int32_t, FN) | ||
131 | + | ||
132 | +/* | ||
133 | + * Helpers for max and min of absolute values across vector: | ||
134 | + * note that we only take the absolute value of 'm', not 'n' | ||
135 | + */ | ||
136 | +static int64_t do_maxa(int64_t n, int64_t m) | ||
137 | +{ | ||
138 | + if (m < 0) { | ||
139 | + m = -m; | ||
140 | + } | ||
141 | + return MAX(n, m); | ||
142 | +} | ||
143 | + | ||
144 | +static int64_t do_mina(int64_t n, int64_t m) | ||
145 | +{ | ||
146 | + if (m < 0) { | ||
147 | + m = -m; | ||
148 | + } | ||
149 | + return MIN(n, m); | ||
150 | +} | ||
151 | + | ||
152 | +DO_VMAXMINV_S(vmaxvs, DO_MAX) | ||
153 | +DO_VMAXMINV_U(vmaxvu, DO_MAX) | ||
154 | +DO_VMAXMINV_S(vminvs, DO_MIN) | ||
155 | +DO_VMAXMINV_U(vminvu, DO_MIN) | ||
156 | +/* | ||
157 | + * VMAXAV, VMINAV treat the general purpose input as unsigned | ||
158 | + * and the vector elements as signed. | ||
159 | + */ | ||
160 | +DO_VMAXMINV(vmaxavb, 1, int8_t, uint8_t, do_maxa) | ||
161 | +DO_VMAXMINV(vmaxavh, 2, int16_t, uint16_t, do_maxa) | ||
162 | +DO_VMAXMINV(vmaxavw, 4, int32_t, uint32_t, do_maxa) | ||
163 | +DO_VMAXMINV(vminavb, 1, int8_t, uint8_t, do_mina) | ||
164 | +DO_VMAXMINV(vminavh, 2, int16_t, uint16_t, do_mina) | ||
165 | +DO_VMAXMINV(vminavw, 4, int32_t, uint32_t, do_mina) | ||
166 | + | ||
167 | #define DO_VADDLV(OP, TYPE, LTYPE) \ | ||
168 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
169 | uint64_t ra) \ | ||
170 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
171 | index XXXXXXX..XXXXXXX 100644 | ||
172 | --- a/target/arm/translate-mve.c | ||
173 | +++ b/target/arm/translate-mve.c | ||
174 | @@ -XXX,XX +XXX,XX @@ DO_VCMP(VCMPGE, vcmpge) | ||
175 | DO_VCMP(VCMPLT, vcmplt) | ||
176 | DO_VCMP(VCMPGT, vcmpgt) | ||
177 | DO_VCMP(VCMPLE, vcmple) | ||
178 | + | ||
179 | +static bool do_vmaxv(DisasContext *s, arg_vmaxv *a, MVEGenVADDVFn fn) | ||
180 | +{ | ||
181 | + /* | ||
182 | + * MIN/MAX operations across a vector: compute the min or | ||
183 | + * max of the initial value in a general purpose register | ||
184 | + * and all the elements in the vector, and store it back | ||
185 | + * into the general purpose register. | ||
186 | + */ | ||
187 | + TCGv_ptr qm; | ||
188 | + TCGv_i32 rda; | ||
189 | + | ||
190 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qm) || | ||
191 | + !fn || a->rda == 13 || a->rda == 15) { | ||
192 | + /* Rda cases are UNPREDICTABLE */ | ||
193 | + return false; | ||
194 | + } | ||
195 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
196 | + return true; | ||
197 | + } | ||
198 | + | ||
199 | + qm = mve_qreg_ptr(a->qm); | ||
200 | + rda = load_reg(s, a->rda); | ||
201 | + fn(rda, cpu_env, qm, rda); | ||
202 | + store_reg(s, a->rda, rda); | ||
203 | + tcg_temp_free_ptr(qm); | ||
204 | + mve_update_eci(s); | ||
205 | + return true; | ||
206 | +} | ||
207 | + | ||
208 | +#define DO_VMAXV(INSN, FN) \ | ||
209 | + static bool trans_##INSN(DisasContext *s, arg_vmaxv *a) \ | ||
210 | + { \ | ||
211 | + static MVEGenVADDVFn * const fns[] = { \ | ||
212 | + gen_helper_mve_##FN##b, \ | ||
213 | + gen_helper_mve_##FN##h, \ | ||
214 | + gen_helper_mve_##FN##w, \ | ||
215 | + NULL, \ | ||
216 | + }; \ | ||
217 | + return do_vmaxv(s, a, fns[a->size]); \ | ||
218 | + } | ||
219 | + | ||
220 | +DO_VMAXV(VMAXV_S, vmaxvs) | ||
221 | +DO_VMAXV(VMAXV_U, vmaxvu) | ||
222 | +DO_VMAXV(VMAXAV, vmaxav) | ||
223 | +DO_VMAXV(VMINV_S, vminvs) | ||
224 | +DO_VMAXV(VMINV_U, vminvu) | ||
225 | +DO_VMAXV(VMINAV, vminav) | ||
226 | -- | ||
227 | 2.20.1 | ||
228 | |||
229 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | Implement the MVE VABAV insn, which computes absolute differences |
---|---|---|---|
2 | between elements of two vectors and accumulates the result into | ||
3 | a general purpose register. | ||
2 | 4 | ||
3 | When running device-introspect-test, a memory leak occurred in the | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | digic_timer_init function, so use ptimer_free() in the finalize function to | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | avoid it. | 7 | --- |
8 | target/arm/helper-mve.h | 7 +++++++ | ||
9 | target/arm/mve.decode | 6 ++++++ | ||
10 | target/arm/mve_helper.c | 26 +++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 43 ++++++++++++++++++++++++++++++++++++++ | ||
12 | 4 files changed, 82 insertions(+) | ||
6 | 13 | ||
7 | ASAN shows memory leak stack: | 14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
8 | |||
9 | Indirect leak of 288 byte(s) in 3 object(s) allocated from: | ||
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf5b04084 in digic_timer_init /qemu/hw/timer/digic-timer.c:142 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564 | ||
16 | #6 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547 | ||
17 | #7 0xaaabf5b40e84 in digic_init /qemu/hw/arm/digic.c:46 | ||
18 | #8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
19 | #9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
20 | #10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
21 | #11 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
22 | #12 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
28 | --- | ||
29 | hw/timer/digic-timer.c | 8 ++++++++ | ||
30 | 1 file changed, 8 insertions(+) | ||
31 | |||
32 | diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/timer/digic-timer.c | 16 | --- a/target/arm/helper-mve.h |
35 | +++ b/hw/timer/digic-timer.c | 17 | +++ b/target/arm/helper-mve.h |
36 | @@ -XXX,XX +XXX,XX @@ static void digic_timer_init(Object *obj) | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vminavw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
37 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); | 19 | DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) |
20 | DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
21 | |||
22 | +DEF_HELPER_FLAGS_4(mve_vabavsb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vabavsh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vabavsw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vabavub, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vabavuh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vabavuw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
28 | + | ||
29 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
30 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
31 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
32 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/mve.decode | ||
35 | +++ b/target/arm/mve.decode | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | &vcmp_scalar qn rm size mask | ||
38 | &shl_scalar qda rm size | ||
39 | &vmaxv qm rda size | ||
40 | +&vabav qn qm rda size | ||
41 | |||
42 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
43 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
44 | @@ -XXX,XX +XXX,XX @@ VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
45 | rdahi=%rdahi rdalo=%rdalo | ||
38 | } | 46 | } |
39 | 47 | ||
40 | +static void digic_timer_finalize(Object *obj) | 48 | +@vabav .... .... .. size:2 .... rda:4 .... .... .... &vabav qn=%qn qm=%qm |
49 | + | ||
50 | +VABAV_S 111 0 1110 10 .. ... 0 .... 1111 . 0 . 0 ... 1 @vabav | ||
51 | +VABAV_U 111 1 1110 10 .. ... 0 .... 1111 . 0 . 0 ... 1 @vabav | ||
52 | + | ||
53 | # Logical immediate operations (1 reg and modified-immediate) | ||
54 | |||
55 | # The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but | ||
56 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/mve_helper.c | ||
59 | +++ b/target/arm/mve_helper.c | ||
60 | @@ -XXX,XX +XXX,XX @@ DO_VMAXMINV(vminavb, 1, int8_t, uint8_t, do_mina) | ||
61 | DO_VMAXMINV(vminavh, 2, int16_t, uint16_t, do_mina) | ||
62 | DO_VMAXMINV(vminavw, 4, int32_t, uint32_t, do_mina) | ||
63 | |||
64 | +#define DO_VABAV(OP, ESIZE, TYPE) \ | ||
65 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
66 | + void *vm, uint32_t ra) \ | ||
67 | + { \ | ||
68 | + uint16_t mask = mve_element_mask(env); \ | ||
69 | + unsigned e; \ | ||
70 | + TYPE *m = vm, *n = vn; \ | ||
71 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
72 | + if (mask & 1) { \ | ||
73 | + int64_t n0 = n[H##ESIZE(e)]; \ | ||
74 | + int64_t m0 = m[H##ESIZE(e)]; \ | ||
75 | + uint32_t r = n0 >= m0 ? (n0 - m0) : (m0 - n0); \ | ||
76 | + ra += r; \ | ||
77 | + } \ | ||
78 | + } \ | ||
79 | + mve_advance_vpt(env); \ | ||
80 | + return ra; \ | ||
81 | + } | ||
82 | + | ||
83 | +DO_VABAV(vabavsb, 1, int8_t) | ||
84 | +DO_VABAV(vabavsh, 2, int16_t) | ||
85 | +DO_VABAV(vabavsw, 4, int32_t) | ||
86 | +DO_VABAV(vabavub, 1, uint8_t) | ||
87 | +DO_VABAV(vabavuh, 2, uint16_t) | ||
88 | +DO_VABAV(vabavuw, 4, uint32_t) | ||
89 | + | ||
90 | #define DO_VADDLV(OP, TYPE, LTYPE) \ | ||
91 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
92 | uint64_t ra) \ | ||
93 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/translate-mve.c | ||
96 | +++ b/target/arm/translate-mve.c | ||
97 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
98 | typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
99 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
100 | typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
101 | +typedef void MVEGenVABAVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
102 | |||
103 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
104 | static inline long mve_qreg_offset(unsigned reg) | ||
105 | @@ -XXX,XX +XXX,XX @@ DO_VMAXV(VMAXAV, vmaxav) | ||
106 | DO_VMAXV(VMINV_S, vminvs) | ||
107 | DO_VMAXV(VMINV_U, vminvu) | ||
108 | DO_VMAXV(VMINAV, vminav) | ||
109 | + | ||
110 | +static bool do_vabav(DisasContext *s, arg_vabav *a, MVEGenVABAVFn *fn) | ||
41 | +{ | 111 | +{ |
42 | + DigicTimerState *s = DIGIC_TIMER(obj); | 112 | + /* Absolute difference accumulated across vector */ |
113 | + TCGv_ptr qn, qm; | ||
114 | + TCGv_i32 rda; | ||
43 | + | 115 | + |
44 | + ptimer_free(s->ptimer); | 116 | + if (!dc_isar_feature(aa32_mve, s) || |
117 | + !mve_check_qreg_bank(s, a->qm | a->qn) || | ||
118 | + !fn || a->rda == 13 || a->rda == 15) { | ||
119 | + /* Rda cases are UNPREDICTABLE */ | ||
120 | + return false; | ||
121 | + } | ||
122 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
123 | + return true; | ||
124 | + } | ||
125 | + | ||
126 | + qm = mve_qreg_ptr(a->qm); | ||
127 | + qn = mve_qreg_ptr(a->qn); | ||
128 | + rda = load_reg(s, a->rda); | ||
129 | + fn(rda, cpu_env, qn, qm, rda); | ||
130 | + store_reg(s, a->rda, rda); | ||
131 | + tcg_temp_free_ptr(qm); | ||
132 | + tcg_temp_free_ptr(qn); | ||
133 | + mve_update_eci(s); | ||
134 | + return true; | ||
45 | +} | 135 | +} |
46 | + | 136 | + |
47 | static void digic_timer_class_init(ObjectClass *klass, void *class_data) | 137 | +#define DO_VABAV(INSN, FN) \ |
48 | { | 138 | + static bool trans_##INSN(DisasContext *s, arg_vabav *a) \ |
49 | DeviceClass *dc = DEVICE_CLASS(klass); | 139 | + { \ |
50 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo digic_timer_info = { | 140 | + static MVEGenVABAVFn * const fns[] = { \ |
51 | .parent = TYPE_SYS_BUS_DEVICE, | 141 | + gen_helper_mve_##FN##b, \ |
52 | .instance_size = sizeof(DigicTimerState), | 142 | + gen_helper_mve_##FN##h, \ |
53 | .instance_init = digic_timer_init, | 143 | + gen_helper_mve_##FN##w, \ |
54 | + .instance_finalize = digic_timer_finalize, | 144 | + NULL, \ |
55 | .class_init = digic_timer_class_init, | 145 | + }; \ |
56 | }; | 146 | + return do_vabav(s, a, fns[a->size]); \ |
57 | 147 | + } | |
148 | + | ||
149 | +DO_VABAV(VABAV_S, vabavs) | ||
150 | +DO_VABAV(VABAV_U, vabavu) | ||
58 | -- | 151 | -- |
59 | 2.20.1 | 152 | 2.20.1 |
60 | 153 | ||
61 | 154 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | Implement the MVE narrowing move insns VMOVN, VQMOVN and VQMOVUN. | |
2 | These take a double-width input, narrow it (possibly saturating) and | ||
3 | store the result to either the top or bottom half of the output | ||
4 | element. | ||
5 | |||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | target/arm/helper-mve.h | 20 ++++++++++ | ||
10 | target/arm/mve.decode | 12 ++++++ | ||
11 | target/arm/mve_helper.c | 78 ++++++++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 22 +++++++++++ | ||
13 | 4 files changed, 132 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/helper-mve.h | ||
18 | +++ b/target/arm/helper-mve.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_3(mve_vfnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | DEF_HELPER_FLAGS_3(mve_vfnegs, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
22 | |||
23 | +DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vmovnth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | + | ||
28 | +DEF_HELPER_FLAGS_3(mve_vqmovunbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vqmovunbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vqmovuntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | +DEF_HELPER_FLAGS_3(mve_vqmovunth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
32 | + | ||
33 | +DEF_HELPER_FLAGS_3(mve_vqmovnbsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vqmovnbsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
35 | +DEF_HELPER_FLAGS_3(mve_vqmovntsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
36 | +DEF_HELPER_FLAGS_3(mve_vqmovntsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
37 | + | ||
38 | +DEF_HELPER_FLAGS_3(mve_vqmovnbub, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
39 | +DEF_HELPER_FLAGS_3(mve_vqmovnbuh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
40 | +DEF_HELPER_FLAGS_3(mve_vqmovntub, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vqmovntuh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
42 | + | ||
43 | DEF_HELPER_FLAGS_4(mve_vand, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
44 | DEF_HELPER_FLAGS_4(mve_vbic, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
45 | DEF_HELPER_FLAGS_4(mve_vorr, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
46 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mve.decode | ||
49 | +++ b/target/arm/mve.decode | ||
50 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
51 | VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
52 | VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
53 | |||
54 | + VQMOVUNB 111 0 1110 0 . 11 .. 01 ... 0 1110 1 0 . 0 ... 1 @1op | ||
55 | + VQMOVN_BS 111 0 1110 0 . 11 .. 11 ... 0 1110 0 0 . 0 ... 1 @1op | ||
56 | + | ||
57 | VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
58 | } | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
61 | VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
62 | VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
63 | |||
64 | + VMOVNB 111 1 1110 0 . 11 .. 01 ... 0 1110 1 0 . 0 ... 1 @1op | ||
65 | + VQMOVN_BU 111 1 1110 0 . 11 .. 11 ... 0 1110 0 0 . 0 ... 1 @1op | ||
66 | + | ||
67 | VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
68 | } | ||
69 | |||
70 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
71 | VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
72 | VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
73 | |||
74 | + VQMOVUNT 111 0 1110 0 . 11 .. 01 ... 1 1110 1 0 . 0 ... 1 @1op | ||
75 | + VQMOVN_TS 111 0 1110 0 . 11 .. 11 ... 1 1110 0 0 . 0 ... 1 @1op | ||
76 | + | ||
77 | VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
78 | } | ||
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
81 | VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
82 | VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
83 | |||
84 | + VMOVNT 111 1 1110 0 . 11 .. 01 ... 1 1110 1 0 . 0 ... 1 @1op | ||
85 | + VQMOVN_TU 111 1 1110 0 . 11 .. 11 ... 1 1110 0 0 . 0 ... 1 @1op | ||
86 | + | ||
87 | VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
88 | } | ||
89 | |||
90 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/mve_helper.c | ||
93 | +++ b/target/arm/mve_helper.c | ||
94 | @@ -XXX,XX +XXX,XX @@ DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) | ||
95 | DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | ||
96 | DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) | ||
97 | |||
98 | +#define DO_VMOVN(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE) \ | ||
99 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
100 | + { \ | ||
101 | + LTYPE *m = vm; \ | ||
102 | + TYPE *d = vd; \ | ||
103 | + uint16_t mask = mve_element_mask(env); \ | ||
104 | + unsigned le; \ | ||
105 | + mask >>= ESIZE * TOP; \ | ||
106 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
107 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], \ | ||
108 | + m[H##LESIZE(le)], mask); \ | ||
109 | + } \ | ||
110 | + mve_advance_vpt(env); \ | ||
111 | + } | ||
112 | + | ||
113 | +DO_VMOVN(vmovnbb, false, 1, uint8_t, 2, uint16_t) | ||
114 | +DO_VMOVN(vmovnbh, false, 2, uint16_t, 4, uint32_t) | ||
115 | +DO_VMOVN(vmovntb, true, 1, uint8_t, 2, uint16_t) | ||
116 | +DO_VMOVN(vmovnth, true, 2, uint16_t, 4, uint32_t) | ||
117 | + | ||
118 | +#define DO_VMOVN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | ||
119 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
120 | + { \ | ||
121 | + LTYPE *m = vm; \ | ||
122 | + TYPE *d = vd; \ | ||
123 | + uint16_t mask = mve_element_mask(env); \ | ||
124 | + bool qc = false; \ | ||
125 | + unsigned le; \ | ||
126 | + mask >>= ESIZE * TOP; \ | ||
127 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
128 | + bool sat = false; \ | ||
129 | + TYPE r = FN(m[H##LESIZE(le)], &sat); \ | ||
130 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
131 | + qc |= sat & mask & 1; \ | ||
132 | + } \ | ||
133 | + if (qc) { \ | ||
134 | + env->vfp.qc[0] = qc; \ | ||
135 | + } \ | ||
136 | + mve_advance_vpt(env); \ | ||
137 | + } | ||
138 | + | ||
139 | +#define DO_VMOVN_SAT_UB(BOP, TOP, FN) \ | ||
140 | + DO_VMOVN_SAT(BOP, false, 1, uint8_t, 2, uint16_t, FN) \ | ||
141 | + DO_VMOVN_SAT(TOP, true, 1, uint8_t, 2, uint16_t, FN) | ||
142 | + | ||
143 | +#define DO_VMOVN_SAT_UH(BOP, TOP, FN) \ | ||
144 | + DO_VMOVN_SAT(BOP, false, 2, uint16_t, 4, uint32_t, FN) \ | ||
145 | + DO_VMOVN_SAT(TOP, true, 2, uint16_t, 4, uint32_t, FN) | ||
146 | + | ||
147 | +#define DO_VMOVN_SAT_SB(BOP, TOP, FN) \ | ||
148 | + DO_VMOVN_SAT(BOP, false, 1, int8_t, 2, int16_t, FN) \ | ||
149 | + DO_VMOVN_SAT(TOP, true, 1, int8_t, 2, int16_t, FN) | ||
150 | + | ||
151 | +#define DO_VMOVN_SAT_SH(BOP, TOP, FN) \ | ||
152 | + DO_VMOVN_SAT(BOP, false, 2, int16_t, 4, int32_t, FN) \ | ||
153 | + DO_VMOVN_SAT(TOP, true, 2, int16_t, 4, int32_t, FN) | ||
154 | + | ||
155 | +#define DO_VQMOVN_SB(N, SATP) \ | ||
156 | + do_sat_bhs((int64_t)(N), INT8_MIN, INT8_MAX, SATP) | ||
157 | +#define DO_VQMOVN_UB(N, SATP) \ | ||
158 | + do_sat_bhs((uint64_t)(N), 0, UINT8_MAX, SATP) | ||
159 | +#define DO_VQMOVUN_B(N, SATP) \ | ||
160 | + do_sat_bhs((int64_t)(N), 0, UINT8_MAX, SATP) | ||
161 | + | ||
162 | +#define DO_VQMOVN_SH(N, SATP) \ | ||
163 | + do_sat_bhs((int64_t)(N), INT16_MIN, INT16_MAX, SATP) | ||
164 | +#define DO_VQMOVN_UH(N, SATP) \ | ||
165 | + do_sat_bhs((uint64_t)(N), 0, UINT16_MAX, SATP) | ||
166 | +#define DO_VQMOVUN_H(N, SATP) \ | ||
167 | + do_sat_bhs((int64_t)(N), 0, UINT16_MAX, SATP) | ||
168 | + | ||
169 | +DO_VMOVN_SAT_SB(vqmovnbsb, vqmovntsb, DO_VQMOVN_SB) | ||
170 | +DO_VMOVN_SAT_SH(vqmovnbsh, vqmovntsh, DO_VQMOVN_SH) | ||
171 | +DO_VMOVN_SAT_UB(vqmovnbub, vqmovntub, DO_VQMOVN_UB) | ||
172 | +DO_VMOVN_SAT_UH(vqmovnbuh, vqmovntuh, DO_VQMOVN_UH) | ||
173 | +DO_VMOVN_SAT_SB(vqmovunbb, vqmovuntb, DO_VQMOVUN_B) | ||
174 | +DO_VMOVN_SAT_SH(vqmovunbh, vqmovunth, DO_VQMOVUN_H) | ||
175 | + | ||
176 | uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
177 | uint32_t shift) | ||
178 | { | ||
179 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
180 | index XXXXXXX..XXXXXXX 100644 | ||
181 | --- a/target/arm/translate-mve.c | ||
182 | +++ b/target/arm/translate-mve.c | ||
183 | @@ -XXX,XX +XXX,XX @@ DO_1OP(VCLS, vcls) | ||
184 | DO_1OP(VABS, vabs) | ||
185 | DO_1OP(VNEG, vneg) | ||
186 | |||
187 | +/* Narrowing moves: only size 0 and 1 are valid */ | ||
188 | +#define DO_VMOVN(INSN, FN) \ | ||
189 | + static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
190 | + { \ | ||
191 | + static MVEGenOneOpFn * const fns[] = { \ | ||
192 | + gen_helper_mve_##FN##b, \ | ||
193 | + gen_helper_mve_##FN##h, \ | ||
194 | + NULL, \ | ||
195 | + NULL, \ | ||
196 | + }; \ | ||
197 | + return do_1op(s, a, fns[a->size]); \ | ||
198 | + } | ||
199 | + | ||
200 | +DO_VMOVN(VMOVNB, vmovnb) | ||
201 | +DO_VMOVN(VMOVNT, vmovnt) | ||
202 | +DO_VMOVN(VQMOVUNB, vqmovunb) | ||
203 | +DO_VMOVN(VQMOVUNT, vqmovunt) | ||
204 | +DO_VMOVN(VQMOVN_BS, vqmovnbs) | ||
205 | +DO_VMOVN(VQMOVN_TS, vqmovnts) | ||
206 | +DO_VMOVN(VQMOVN_BU, vqmovnbu) | ||
207 | +DO_VMOVN(VQMOVN_TU, vqmovntu) | ||
208 | + | ||
209 | static bool trans_VREV16(DisasContext *s, arg_1op *a) | ||
210 | { | ||
211 | static MVEGenOneOpFn * const fns[] = { | ||
212 | -- | ||
213 | 2.20.1 | ||
214 | |||
215 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The MVEGenDualAccOpFn is a bit misnamed, since it is used for | ||
2 | the "long dual accumulate" operations that use a 64-bit | ||
3 | accumulator. Rename it to MVEGenLongDualAccOpFn so we can | ||
4 | use the former name for the 32-bit accumulator insns. | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | target/arm/translate-mve.c | 16 ++++++++-------- | ||
10 | 1 file changed, 8 insertions(+), 8 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/translate-mve.c | ||
15 | +++ b/target/arm/translate-mve.c | ||
16 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
17 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
18 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
19 | typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
20 | -typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
21 | +typedef void MVEGenLongDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
22 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
23 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
24 | typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
25 | @@ -XXX,XX +XXX,XX @@ static bool trans_VQDMULLT_scalar(DisasContext *s, arg_2scalar *a) | ||
26 | } | ||
27 | |||
28 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
29 | - MVEGenDualAccOpFn *fn) | ||
30 | + MVEGenLongDualAccOpFn *fn) | ||
31 | { | ||
32 | TCGv_ptr qn, qm; | ||
33 | TCGv_i64 rda; | ||
34 | @@ -XXX,XX +XXX,XX @@ static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
35 | |||
36 | static bool trans_VMLALDAV_S(DisasContext *s, arg_vmlaldav *a) | ||
37 | { | ||
38 | - static MVEGenDualAccOpFn * const fns[4][2] = { | ||
39 | + static MVEGenLongDualAccOpFn * const fns[4][2] = { | ||
40 | { NULL, NULL }, | ||
41 | { gen_helper_mve_vmlaldavsh, gen_helper_mve_vmlaldavxsh }, | ||
42 | { gen_helper_mve_vmlaldavsw, gen_helper_mve_vmlaldavxsw }, | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLALDAV_S(DisasContext *s, arg_vmlaldav *a) | ||
44 | |||
45 | static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) | ||
46 | { | ||
47 | - static MVEGenDualAccOpFn * const fns[4][2] = { | ||
48 | + static MVEGenLongDualAccOpFn * const fns[4][2] = { | ||
49 | { NULL, NULL }, | ||
50 | { gen_helper_mve_vmlaldavuh, NULL }, | ||
51 | { gen_helper_mve_vmlaldavuw, NULL }, | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) | ||
53 | |||
54 | static bool trans_VMLSLDAV(DisasContext *s, arg_vmlaldav *a) | ||
55 | { | ||
56 | - static MVEGenDualAccOpFn * const fns[4][2] = { | ||
57 | + static MVEGenLongDualAccOpFn * const fns[4][2] = { | ||
58 | { NULL, NULL }, | ||
59 | { gen_helper_mve_vmlsldavsh, gen_helper_mve_vmlsldavxsh }, | ||
60 | { gen_helper_mve_vmlsldavsw, gen_helper_mve_vmlsldavxsw }, | ||
61 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLSLDAV(DisasContext *s, arg_vmlaldav *a) | ||
62 | |||
63 | static bool trans_VRMLALDAVH_S(DisasContext *s, arg_vmlaldav *a) | ||
64 | { | ||
65 | - static MVEGenDualAccOpFn * const fns[] = { | ||
66 | + static MVEGenLongDualAccOpFn * const fns[] = { | ||
67 | gen_helper_mve_vrmlaldavhsw, gen_helper_mve_vrmlaldavhxsw, | ||
68 | }; | ||
69 | return do_long_dual_acc(s, a, fns[a->x]); | ||
70 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLALDAVH_S(DisasContext *s, arg_vmlaldav *a) | ||
71 | |||
72 | static bool trans_VRMLALDAVH_U(DisasContext *s, arg_vmlaldav *a) | ||
73 | { | ||
74 | - static MVEGenDualAccOpFn * const fns[] = { | ||
75 | + static MVEGenLongDualAccOpFn * const fns[] = { | ||
76 | gen_helper_mve_vrmlaldavhuw, NULL, | ||
77 | }; | ||
78 | return do_long_dual_acc(s, a, fns[a->x]); | ||
79 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLALDAVH_U(DisasContext *s, arg_vmlaldav *a) | ||
80 | |||
81 | static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) | ||
82 | { | ||
83 | - static MVEGenDualAccOpFn * const fns[] = { | ||
84 | + static MVEGenLongDualAccOpFn * const fns[] = { | ||
85 | gen_helper_mve_vrmlsldavhsw, gen_helper_mve_vrmlsldavhxsw, | ||
86 | }; | ||
87 | return do_long_dual_acc(s, a, fns[a->x]); | ||
88 | -- | ||
89 | 2.20.1 | ||
90 | |||
91 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | Implement the MVE VMLADAV and VMLSLDAV insns. Like the VMLALDAV and | |
2 | VMLSLDAV insns already implemented, these accumulate multiplied | ||
3 | vector elements; but they accumulate a 32-bit result rather than a | ||
4 | 64-bit one. | ||
5 | |||
6 | Note that these encodings overlap with what would be RdaHi=0b111 for | ||
7 | VMLALDAV, VMLSLDAV, VRMLALDAVH and VRMLSLDAVH. | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper-mve.h | 17 ++++++++++ | ||
13 | target/arm/mve.decode | 33 +++++++++++++++++--- | ||
14 | target/arm/mve_helper.c | 41 ++++++++++++++++++++++++ | ||
15 | target/arm/translate-mve.c | 64 ++++++++++++++++++++++++++++++++++++++ | ||
16 | 4 files changed, 150 insertions(+), 5 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper-mve.h | ||
21 | +++ b/target/arm/helper-mve.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrmlaldavhuw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
23 | DEF_HELPER_FLAGS_4(mve_vrmlsldavhsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
24 | DEF_HELPER_FLAGS_4(mve_vrmlsldavhxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
25 | |||
26 | +DEF_HELPER_FLAGS_4(mve_vmladavsb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vmladavsh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vmladavsw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vmladavub, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vmladavuh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vmladavuw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vmlsdavb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vmlsdavh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vmlsdavw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
35 | + | ||
36 | +DEF_HELPER_FLAGS_4(mve_vmladavsxb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
37 | +DEF_HELPER_FLAGS_4(mve_vmladavsxh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(mve_vmladavsxw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
42 | + | ||
43 | DEF_HELPER_FLAGS_3(mve_vaddvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
44 | DEF_HELPER_FLAGS_3(mve_vaddvub, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
45 | DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
46 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mve.decode | ||
49 | +++ b/target/arm/mve.decode | ||
50 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
51 | %size_16 16:1 !function=plus_1 | ||
52 | |||
53 | &vmlaldav rdahi rdalo size qn qm x a | ||
54 | +&vmladav rda size qn qm x a | ||
55 | |||
56 | @vmlaldav .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
57 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav | ||
58 | @vmlaldav_nosz .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
59 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=0 &vmlaldav | ||
60 | -VMLALDAV_S 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
61 | -VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
62 | +@vmladav .... .... .... ... . ... x:1 .... . . a:1 . qm:3 . \ | ||
63 | + qn=%qn rda=%rdalo size=%size_16 &vmladav | ||
64 | +@vmladav_nosz .... .... .... ... . ... x:1 .... . . a:1 . qm:3 . \ | ||
65 | + qn=%qn rda=%rdalo size=0 &vmladav | ||
66 | |||
67 | -VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
68 | +{ | ||
69 | + VMLADAV_S 1110 1110 1111 ... . ... . 1110 . 0 . 0 ... 0 @vmladav | ||
70 | + VMLALDAV_S 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
71 | +} | ||
72 | +{ | ||
73 | + VMLADAV_U 1111 1110 1111 ... . ... . 1110 . 0 . 0 ... 0 @vmladav | ||
74 | + VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
75 | +} | ||
76 | + | ||
77 | +{ | ||
78 | + VMLSDAV 1110 1110 1111 ... . ... . 1110 . 0 . 0 ... 1 @vmladav | ||
79 | + VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
80 | +} | ||
81 | + | ||
82 | +{ | ||
83 | + VMLSDAV 1111 1110 1111 ... 0 ... . 1110 . 0 . 0 ... 1 @vmladav_nosz | ||
84 | + VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | ||
85 | +} | ||
86 | + | ||
87 | +VMLADAV_S 1110 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 1 @vmladav_nosz | ||
88 | +VMLADAV_U 1111 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 1 @vmladav_nosz | ||
89 | |||
90 | { | ||
91 | VMAXV_S 1110 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
92 | VMINV_S 1110 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
93 | VMAXAV 1110 1110 1110 .. 00 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
94 | VMINAV 1110 1110 1110 .. 00 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
95 | + VMLADAV_S 1110 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 0 @vmladav_nosz | ||
96 | VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
97 | } | ||
98 | |||
99 | { | ||
100 | VMAXV_U 1111 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
101 | VMINV_U 1111 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
102 | + VMLADAV_U 1111 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 0 @vmladav_nosz | ||
103 | VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
104 | } | ||
105 | |||
106 | -VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | ||
107 | - | ||
108 | # Scalar operations | ||
109 | |||
110 | VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar | ||
111 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/target/arm/mve_helper.c | ||
114 | +++ b/target/arm/mve_helper.c | ||
115 | @@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavxsh, 2, int16_t, true, +=, -=) | ||
116 | DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=) | ||
117 | DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=) | ||
118 | |||
119 | +/* | ||
120 | + * Multiply add dual accumulate ops | ||
121 | + */ | ||
122 | +#define DO_DAV(OP, ESIZE, TYPE, XCHG, EVENACC, ODDACC) \ | ||
123 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
124 | + void *vm, uint32_t a) \ | ||
125 | + { \ | ||
126 | + uint16_t mask = mve_element_mask(env); \ | ||
127 | + unsigned e; \ | ||
128 | + TYPE *n = vn, *m = vm; \ | ||
129 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
130 | + if (mask & 1) { \ | ||
131 | + if (e & 1) { \ | ||
132 | + a ODDACC \ | ||
133 | + n[H##ESIZE(e - 1 * XCHG)] * m[H##ESIZE(e)]; \ | ||
134 | + } else { \ | ||
135 | + a EVENACC \ | ||
136 | + n[H##ESIZE(e + 1 * XCHG)] * m[H##ESIZE(e)]; \ | ||
137 | + } \ | ||
138 | + } \ | ||
139 | + } \ | ||
140 | + mve_advance_vpt(env); \ | ||
141 | + return a; \ | ||
142 | + } | ||
143 | + | ||
144 | +#define DO_DAV_S(INSN, XCHG, EVENACC, ODDACC) \ | ||
145 | + DO_DAV(INSN##b, 1, int8_t, XCHG, EVENACC, ODDACC) \ | ||
146 | + DO_DAV(INSN##h, 2, int16_t, XCHG, EVENACC, ODDACC) \ | ||
147 | + DO_DAV(INSN##w, 4, int32_t, XCHG, EVENACC, ODDACC) | ||
148 | + | ||
149 | +#define DO_DAV_U(INSN, XCHG, EVENACC, ODDACC) \ | ||
150 | + DO_DAV(INSN##b, 1, uint8_t, XCHG, EVENACC, ODDACC) \ | ||
151 | + DO_DAV(INSN##h, 2, uint16_t, XCHG, EVENACC, ODDACC) \ | ||
152 | + DO_DAV(INSN##w, 4, uint32_t, XCHG, EVENACC, ODDACC) | ||
153 | + | ||
154 | +DO_DAV_S(vmladavs, false, +=, +=) | ||
155 | +DO_DAV_U(vmladavu, false, +=, +=) | ||
156 | +DO_DAV_S(vmlsdav, false, +=, -=) | ||
157 | +DO_DAV_S(vmladavsx, true, +=, +=) | ||
158 | +DO_DAV_S(vmlsdavx, true, +=, -=) | ||
159 | + | ||
160 | /* | ||
161 | * Rounding multiply add long dual accumulate high. In the pseudocode | ||
162 | * this is implemented with a 72-bit internal accumulator value of which | ||
163 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/target/arm/translate-mve.c | ||
166 | +++ b/target/arm/translate-mve.c | ||
167 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TC | ||
168 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
169 | typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
170 | typedef void MVEGenVABAVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
171 | +typedef void MVEGenDualAccOpFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
172 | |||
173 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
174 | static inline long mve_qreg_offset(unsigned reg) | ||
175 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) | ||
176 | return do_long_dual_acc(s, a, fns[a->x]); | ||
177 | } | ||
178 | |||
179 | +static bool do_dual_acc(DisasContext *s, arg_vmladav *a, MVEGenDualAccOpFn *fn) | ||
180 | +{ | ||
181 | + TCGv_ptr qn, qm; | ||
182 | + TCGv_i32 rda; | ||
183 | + | ||
184 | + if (!dc_isar_feature(aa32_mve, s) || | ||
185 | + !mve_check_qreg_bank(s, a->qn) || | ||
186 | + !fn) { | ||
187 | + return false; | ||
188 | + } | ||
189 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
190 | + return true; | ||
191 | + } | ||
192 | + | ||
193 | + qn = mve_qreg_ptr(a->qn); | ||
194 | + qm = mve_qreg_ptr(a->qm); | ||
195 | + | ||
196 | + /* | ||
197 | + * This insn is subject to beat-wise execution. Partial execution | ||
198 | + * of an A=0 (no-accumulate) insn which does not execute the first | ||
199 | + * beat must start with the current rda value, not 0. | ||
200 | + */ | ||
201 | + if (a->a || mve_skip_first_beat(s)) { | ||
202 | + rda = load_reg(s, a->rda); | ||
203 | + } else { | ||
204 | + rda = tcg_const_i32(0); | ||
205 | + } | ||
206 | + | ||
207 | + fn(rda, cpu_env, qn, qm, rda); | ||
208 | + store_reg(s, a->rda, rda); | ||
209 | + tcg_temp_free_ptr(qn); | ||
210 | + tcg_temp_free_ptr(qm); | ||
211 | + | ||
212 | + mve_update_eci(s); | ||
213 | + return true; | ||
214 | +} | ||
215 | + | ||
216 | +#define DO_DUAL_ACC(INSN, FN) \ | ||
217 | + static bool trans_##INSN(DisasContext *s, arg_vmladav *a) \ | ||
218 | + { \ | ||
219 | + static MVEGenDualAccOpFn * const fns[4][2] = { \ | ||
220 | + { gen_helper_mve_##FN##b, gen_helper_mve_##FN##xb }, \ | ||
221 | + { gen_helper_mve_##FN##h, gen_helper_mve_##FN##xh }, \ | ||
222 | + { gen_helper_mve_##FN##w, gen_helper_mve_##FN##xw }, \ | ||
223 | + { NULL, NULL }, \ | ||
224 | + }; \ | ||
225 | + return do_dual_acc(s, a, fns[a->size][a->x]); \ | ||
226 | + } | ||
227 | + | ||
228 | +DO_DUAL_ACC(VMLADAV_S, vmladavs) | ||
229 | +DO_DUAL_ACC(VMLSDAV, vmlsdav) | ||
230 | + | ||
231 | +static bool trans_VMLADAV_U(DisasContext *s, arg_vmladav *a) | ||
232 | +{ | ||
233 | + static MVEGenDualAccOpFn * const fns[4][2] = { | ||
234 | + { gen_helper_mve_vmladavub, NULL }, | ||
235 | + { gen_helper_mve_vmladavuh, NULL }, | ||
236 | + { gen_helper_mve_vmladavuw, NULL }, | ||
237 | + { NULL, NULL }, | ||
238 | + }; | ||
239 | + return do_dual_acc(s, a, fns[a->size][a->x]); | ||
240 | +} | ||
241 | + | ||
242 | static void gen_vpst(DisasContext *s, uint32_t mask) | ||
243 | { | ||
244 | /* | ||
245 | -- | ||
246 | 2.20.1 | ||
247 | |||
248 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the MVE VMLA insn, which multiplies a vector by a scalar | ||
2 | and accumulates into another vector. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 4 ++++ | ||
8 | target/arm/mve.decode | 1 + | ||
9 | target/arm/mve_helper.c | 5 +++++ | ||
10 | target/arm/translate-mve.c | 1 + | ||
11 | 4 files changed, 11 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper-mve.h | ||
16 | +++ b/target/arm/helper-mve.h | ||
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i3 | ||
18 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | |||
21 | +DEF_HELPER_FLAGS_4(mve_vmlab, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vmlah, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vmlaw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | DEF_HELPER_FLAGS_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | DEF_HELPER_FLAGS_4(mve_vmlash, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | DEF_HELPER_FLAGS_4(mve_vmlasw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/mve.decode | ||
31 | +++ b/target/arm/mve.decode | ||
32 | @@ -XXX,XX +XXX,XX @@ VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
33 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
34 | |||
35 | # The U bit (28) is don't-care because it does not affect the result | ||
36 | +VMLA 111- 1110 0 . .. ... 1 ... 0 1110 . 100 .... @2scalar | ||
37 | VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
38 | |||
39 | # Vector add across vector | ||
40 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/mve_helper.c | ||
43 | +++ b/target/arm/mve_helper.c | ||
44 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) | ||
45 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) | ||
46 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W) | ||
47 | |||
48 | +/* Vector by scalar plus vector */ | ||
49 | +#define DO_VMLA(D, N, M) ((N) * (M) + (D)) | ||
50 | + | ||
51 | +DO_2OP_ACC_SCALAR_U(vmla, DO_VMLA) | ||
52 | + | ||
53 | /* Vector by vector plus scalar */ | ||
54 | #define DO_VMLAS(D, N, M) ((N) * (D) + (M)) | ||
55 | |||
56 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/translate-mve.c | ||
59 | +++ b/target/arm/translate-mve.c | ||
60 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VQSUB_U_scalar, vqsubu_scalar) | ||
61 | DO_2OP_SCALAR(VQDMULH_scalar, vqdmulh_scalar) | ||
62 | DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) | ||
63 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
64 | +DO_2OP_SCALAR(VMLA, vmla) | ||
65 | DO_2OP_SCALAR(VMLAS, vmlas) | ||
66 | |||
67 | static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a) | ||
68 | -- | ||
69 | 2.20.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the MVE saturating doubling multiply accumulate insns | ||
2 | VQDMLAH, VQRDMLAH, VQDMLASH and VQRDMLASH. These perform a multiply, | ||
3 | double, add the accumulator shifted by the element size, possibly | ||
4 | round, saturate to twice the element size, then take the high half of | ||
5 | the result. The *MLAH insns do vector * scalar + vector, and the | ||
6 | *MLASH insns do vector * vector + scalar. | ||
1 | 7 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper-mve.h | 16 +++++++ | ||
12 | target/arm/mve.decode | 5 ++ | ||
13 | target/arm/mve_helper.c | 95 ++++++++++++++++++++++++++++++++++++++ | ||
14 | target/arm/translate-mve.c | 4 ++ | ||
15 | 4 files changed, 120 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_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | DEF_HELPER_FLAGS_4(mve_vmlash, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | DEF_HELPER_FLAGS_4(mve_vmlasw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | |||
25 | +DEF_HELPER_FLAGS_4(mve_vqdmlahb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vqdmlahh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vqdmlahw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | + | ||
29 | +DEF_HELPER_FLAGS_4(mve_vqrdmlahb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vqrdmlahh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqrdmlahw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | + | ||
33 | +DEF_HELPER_FLAGS_4(mve_vqdmlashb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vqdmlashh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vqdmlashw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | + | ||
37 | +DEF_HELPER_FLAGS_4(mve_vqrdmlashb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(mve_vqrdmlashh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(mve_vqrdmlashw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | + | ||
41 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
42 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
43 | DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
44 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/mve.decode | ||
47 | +++ b/target/arm/mve.decode | ||
48 | @@ -XXX,XX +XXX,XX @@ VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
49 | VMLA 111- 1110 0 . .. ... 1 ... 0 1110 . 100 .... @2scalar | ||
50 | VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
51 | |||
52 | +VQRDMLAH 1110 1110 0 . .. ... 0 ... 0 1110 . 100 .... @2scalar | ||
53 | +VQRDMLASH 1110 1110 0 . .. ... 0 ... 1 1110 . 100 .... @2scalar | ||
54 | +VQDMLAH 1110 1110 0 . .. ... 0 ... 0 1110 . 110 .... @2scalar | ||
55 | +VQDMLASH 1110 1110 0 . .. ... 0 ... 1 1110 . 110 .... @2scalar | ||
56 | + | ||
57 | # Vector add across vector | ||
58 | { | ||
59 | VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
60 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/mve_helper.c | ||
63 | +++ b/target/arm/mve_helper.c | ||
64 | @@ -XXX,XX +XXX,XX @@ DO_VQDMLADH_OP(vqrdmlsdhxw, 4, int32_t, 1, 1, do_vqdmlsdh_w) | ||
65 | mve_advance_vpt(env); \ | ||
66 | } | ||
67 | |||
68 | +#define DO_2OP_SAT_ACC_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
69 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
70 | + uint32_t rm) \ | ||
71 | + { \ | ||
72 | + TYPE *d = vd, *n = vn; \ | ||
73 | + TYPE m = rm; \ | ||
74 | + uint16_t mask = mve_element_mask(env); \ | ||
75 | + unsigned e; \ | ||
76 | + bool qc = false; \ | ||
77 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
78 | + bool sat = false; \ | ||
79 | + mergemask(&d[H##ESIZE(e)], \ | ||
80 | + FN(d[H##ESIZE(e)], n[H##ESIZE(e)], m, &sat), \ | ||
81 | + mask); \ | ||
82 | + qc |= sat & mask & 1; \ | ||
83 | + } \ | ||
84 | + if (qc) { \ | ||
85 | + env->vfp.qc[0] = qc; \ | ||
86 | + } \ | ||
87 | + mve_advance_vpt(env); \ | ||
88 | + } | ||
89 | + | ||
90 | /* provide unsigned 2-op scalar helpers for all sizes */ | ||
91 | #define DO_2OP_SCALAR_U(OP, FN) \ | ||
92 | DO_2OP_SCALAR(OP##b, 1, uint8_t, FN) \ | ||
93 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) | ||
94 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) | ||
95 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W) | ||
96 | |||
97 | +static int8_t do_vqdmlah_b(int8_t a, int8_t b, int8_t c, int round, bool *sat) | ||
98 | +{ | ||
99 | + int64_t r = (int64_t)a * b * 2 + ((int64_t)c << 8) + (round << 7); | ||
100 | + return do_sat_bhw(r, INT16_MIN, INT16_MAX, sat) >> 8; | ||
101 | +} | ||
102 | + | ||
103 | +static int16_t do_vqdmlah_h(int16_t a, int16_t b, int16_t c, | ||
104 | + int round, bool *sat) | ||
105 | +{ | ||
106 | + int64_t r = (int64_t)a * b * 2 + ((int64_t)c << 16) + (round << 15); | ||
107 | + return do_sat_bhw(r, INT32_MIN, INT32_MAX, sat) >> 16; | ||
108 | +} | ||
109 | + | ||
110 | +static int32_t do_vqdmlah_w(int32_t a, int32_t b, int32_t c, | ||
111 | + int round, bool *sat) | ||
112 | +{ | ||
113 | + /* | ||
114 | + * Architecturally we should do the entire add, double, round | ||
115 | + * and then check for saturation. We do three saturating adds, | ||
116 | + * but we need to be careful about the order. If the first | ||
117 | + * m1 + m2 saturates then it's impossible for the *2+rc to | ||
118 | + * bring it back into the non-saturated range. However, if | ||
119 | + * m1 + m2 is negative then it's possible that doing the doubling | ||
120 | + * would take the intermediate result below INT64_MAX and the | ||
121 | + * addition of the rounding constant then brings it back in range. | ||
122 | + * So we add half the rounding constant and half the "c << esize" | ||
123 | + * before doubling rather than adding the rounding constant after | ||
124 | + * the doubling. | ||
125 | + */ | ||
126 | + int64_t m1 = (int64_t)a * b; | ||
127 | + int64_t m2 = (int64_t)c << 31; | ||
128 | + int64_t r; | ||
129 | + if (sadd64_overflow(m1, m2, &r) || | ||
130 | + sadd64_overflow(r, (round << 30), &r) || | ||
131 | + sadd64_overflow(r, r, &r)) { | ||
132 | + *sat = true; | ||
133 | + return r < 0 ? INT32_MAX : INT32_MIN; | ||
134 | + } | ||
135 | + return r >> 32; | ||
136 | +} | ||
137 | + | ||
138 | +/* | ||
139 | + * The *MLAH insns are vector * scalar + vector; | ||
140 | + * the *MLASH insns are vector * vector + scalar | ||
141 | + */ | ||
142 | +#define DO_VQDMLAH_B(D, N, M, S) do_vqdmlah_b(N, M, D, 0, S) | ||
143 | +#define DO_VQDMLAH_H(D, N, M, S) do_vqdmlah_h(N, M, D, 0, S) | ||
144 | +#define DO_VQDMLAH_W(D, N, M, S) do_vqdmlah_w(N, M, D, 0, S) | ||
145 | +#define DO_VQRDMLAH_B(D, N, M, S) do_vqdmlah_b(N, M, D, 1, S) | ||
146 | +#define DO_VQRDMLAH_H(D, N, M, S) do_vqdmlah_h(N, M, D, 1, S) | ||
147 | +#define DO_VQRDMLAH_W(D, N, M, S) do_vqdmlah_w(N, M, D, 1, S) | ||
148 | + | ||
149 | +#define DO_VQDMLASH_B(D, N, M, S) do_vqdmlah_b(N, D, M, 0, S) | ||
150 | +#define DO_VQDMLASH_H(D, N, M, S) do_vqdmlah_h(N, D, M, 0, S) | ||
151 | +#define DO_VQDMLASH_W(D, N, M, S) do_vqdmlah_w(N, D, M, 0, S) | ||
152 | +#define DO_VQRDMLASH_B(D, N, M, S) do_vqdmlah_b(N, D, M, 1, S) | ||
153 | +#define DO_VQRDMLASH_H(D, N, M, S) do_vqdmlah_h(N, D, M, 1, S) | ||
154 | +#define DO_VQRDMLASH_W(D, N, M, S) do_vqdmlah_w(N, D, M, 1, S) | ||
155 | + | ||
156 | +DO_2OP_SAT_ACC_SCALAR(vqdmlahb, 1, int8_t, DO_VQDMLAH_B) | ||
157 | +DO_2OP_SAT_ACC_SCALAR(vqdmlahh, 2, int16_t, DO_VQDMLAH_H) | ||
158 | +DO_2OP_SAT_ACC_SCALAR(vqdmlahw, 4, int32_t, DO_VQDMLAH_W) | ||
159 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlahb, 1, int8_t, DO_VQRDMLAH_B) | ||
160 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlahh, 2, int16_t, DO_VQRDMLAH_H) | ||
161 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlahw, 4, int32_t, DO_VQRDMLAH_W) | ||
162 | + | ||
163 | +DO_2OP_SAT_ACC_SCALAR(vqdmlashb, 1, int8_t, DO_VQDMLASH_B) | ||
164 | +DO_2OP_SAT_ACC_SCALAR(vqdmlashh, 2, int16_t, DO_VQDMLASH_H) | ||
165 | +DO_2OP_SAT_ACC_SCALAR(vqdmlashw, 4, int32_t, DO_VQDMLASH_W) | ||
166 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlashb, 1, int8_t, DO_VQRDMLASH_B) | ||
167 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlashh, 2, int16_t, DO_VQRDMLASH_H) | ||
168 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlashw, 4, int32_t, DO_VQRDMLASH_W) | ||
169 | + | ||
170 | /* Vector by scalar plus vector */ | ||
171 | #define DO_VMLA(D, N, M) ((N) * (M) + (D)) | ||
172 | |||
173 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
174 | index XXXXXXX..XXXXXXX 100644 | ||
175 | --- a/target/arm/translate-mve.c | ||
176 | +++ b/target/arm/translate-mve.c | ||
177 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) | ||
178 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
179 | DO_2OP_SCALAR(VMLA, vmla) | ||
180 | DO_2OP_SCALAR(VMLAS, vmlas) | ||
181 | +DO_2OP_SCALAR(VQDMLAH, vqdmlah) | ||
182 | +DO_2OP_SCALAR(VQRDMLAH, vqrdmlah) | ||
183 | +DO_2OP_SCALAR(VQDMLASH, vqdmlash) | ||
184 | +DO_2OP_SCALAR(VQRDMLASH, vqrdmlash) | ||
185 | |||
186 | static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a) | ||
187 | { | ||
188 | -- | ||
189 | 2.20.1 | ||
190 | |||
191 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the MVE 1-operand saturating operations VQABS and VQNEG. | ||
1 | 2 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | target/arm/helper-mve.h | 8 ++++++++ | ||
7 | target/arm/mve.decode | 3 +++ | ||
8 | target/arm/mve_helper.c | 37 +++++++++++++++++++++++++++++++++++++ | ||
9 | target/arm/translate-mve.c | 2 ++ | ||
10 | 4 files changed, 50 insertions(+) | ||
11 | |||
12 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper-mve.h | ||
15 | +++ b/target/arm/helper-mve.h | ||
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
17 | DEF_HELPER_FLAGS_3(mve_vfnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_3(mve_vfnegs, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
19 | |||
20 | +DEF_HELPER_FLAGS_3(mve_vqabsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | +DEF_HELPER_FLAGS_3(mve_vqabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
22 | +DEF_HELPER_FLAGS_3(mve_vqabsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
23 | + | ||
24 | +DEF_HELPER_FLAGS_3(mve_vqnegb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_3(mve_vqnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vqnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | + | ||
28 | DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/mve.decode | ||
34 | +++ b/target/arm/mve.decode | ||
35 | @@ -XXX,XX +XXX,XX @@ VABS_fp 1111 1111 1 . 11 .. 01 ... 0 0111 01 . 0 ... 0 @1op | ||
36 | VNEG 1111 1111 1 . 11 .. 01 ... 0 0011 11 . 0 ... 0 @1op | ||
37 | VNEG_fp 1111 1111 1 . 11 .. 01 ... 0 0111 11 . 0 ... 0 @1op | ||
38 | |||
39 | +VQABS 1111 1111 1 . 11 .. 00 ... 0 0111 01 . 0 ... 0 @1op | ||
40 | +VQNEG 1111 1111 1 . 11 .. 00 ... 0 0111 11 . 0 ... 0 @1op | ||
41 | + | ||
42 | &vdup qd rt size | ||
43 | # Qd is in the fields usually named Qn | ||
44 | @vdup .... .... . . .. ... . rt:4 .... . . . . .... qd=%qn &vdup | ||
45 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/mve_helper.c | ||
48 | +++ b/target/arm/mve_helper.c | ||
49 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vpsel)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
50 | } | ||
51 | mve_advance_vpt(env); | ||
52 | } | ||
53 | + | ||
54 | +#define DO_1OP_SAT(OP, ESIZE, TYPE, FN) \ | ||
55 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
56 | + { \ | ||
57 | + TYPE *d = vd, *m = vm; \ | ||
58 | + uint16_t mask = mve_element_mask(env); \ | ||
59 | + unsigned e; \ | ||
60 | + bool qc = false; \ | ||
61 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
62 | + bool sat = false; \ | ||
63 | + mergemask(&d[H##ESIZE(e)], FN(m[H##ESIZE(e)], &sat), mask); \ | ||
64 | + qc |= sat & mask & 1; \ | ||
65 | + } \ | ||
66 | + if (qc) { \ | ||
67 | + env->vfp.qc[0] = qc; \ | ||
68 | + } \ | ||
69 | + mve_advance_vpt(env); \ | ||
70 | + } | ||
71 | + | ||
72 | +#define DO_VQABS_B(N, SATP) \ | ||
73 | + do_sat_bhs(DO_ABS((int64_t)N), INT8_MIN, INT8_MAX, SATP) | ||
74 | +#define DO_VQABS_H(N, SATP) \ | ||
75 | + do_sat_bhs(DO_ABS((int64_t)N), INT16_MIN, INT16_MAX, SATP) | ||
76 | +#define DO_VQABS_W(N, SATP) \ | ||
77 | + do_sat_bhs(DO_ABS((int64_t)N), INT32_MIN, INT32_MAX, SATP) | ||
78 | + | ||
79 | +#define DO_VQNEG_B(N, SATP) do_sat_bhs(-(int64_t)N, INT8_MIN, INT8_MAX, SATP) | ||
80 | +#define DO_VQNEG_H(N, SATP) do_sat_bhs(-(int64_t)N, INT16_MIN, INT16_MAX, SATP) | ||
81 | +#define DO_VQNEG_W(N, SATP) do_sat_bhs(-(int64_t)N, INT32_MIN, INT32_MAX, SATP) | ||
82 | + | ||
83 | +DO_1OP_SAT(vqabsb, 1, int8_t, DO_VQABS_B) | ||
84 | +DO_1OP_SAT(vqabsh, 2, int16_t, DO_VQABS_H) | ||
85 | +DO_1OP_SAT(vqabsw, 4, int32_t, DO_VQABS_W) | ||
86 | + | ||
87 | +DO_1OP_SAT(vqnegb, 1, int8_t, DO_VQNEG_B) | ||
88 | +DO_1OP_SAT(vqnegh, 2, int16_t, DO_VQNEG_H) | ||
89 | +DO_1OP_SAT(vqnegw, 4, int32_t, DO_VQNEG_W) | ||
90 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/translate-mve.c | ||
93 | +++ b/target/arm/translate-mve.c | ||
94 | @@ -XXX,XX +XXX,XX @@ DO_1OP(VCLZ, vclz) | ||
95 | DO_1OP(VCLS, vcls) | ||
96 | DO_1OP(VABS, vabs) | ||
97 | DO_1OP(VNEG, vneg) | ||
98 | +DO_1OP(VQABS, vqabs) | ||
99 | +DO_1OP(VQNEG, vqneg) | ||
100 | |||
101 | /* Narrowing moves: only size 0 and 1 are valid */ | ||
102 | #define DO_VMOVN(INSN, FN) \ | ||
103 | -- | ||
104 | 2.20.1 | ||
105 | |||
106 | diff view generated by jsdifflib |
1 | Now that timer_free() implicitly calls timer_del(), sequences | 1 | Implement the MVE VMAXA and VMINA insns, which take the absolute |
---|---|---|---|
2 | timer_del(mytimer); | 2 | value of the signed elements in the input vector and then accumulate |
3 | timer_free(mytimer); | 3 | the unsigned max or min into the destination vector. |
4 | |||
5 | can be simplified to just | ||
6 | timer_free(mytimer); | ||
7 | |||
8 | Add a Coccinelle script to do this transformation. | ||
9 | 4 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20201215154107.3255-3-peter.maydell@linaro.org | ||
15 | --- | 7 | --- |
16 | scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++++++++++++++++ | 8 | target/arm/helper-mve.h | 8 ++++++++ |
17 | 1 file changed, 18 insertions(+) | 9 | target/arm/mve.decode | 4 ++++ |
18 | create mode 100644 scripts/coccinelle/timer-del-timer-free.cocci | 10 | target/arm/mve_helper.c | 26 ++++++++++++++++++++++++++ |
11 | target/arm/translate-mve.c | 2 ++ | ||
12 | 4 files changed, 40 insertions(+) | ||
19 | 13 | ||
20 | diff --git a/scripts/coccinelle/timer-del-timer-free.cocci b/scripts/coccinelle/timer-del-timer-free.cocci | 14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
21 | new file mode 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | index XXXXXXX..XXXXXXX | 16 | --- a/target/arm/helper-mve.h |
23 | --- /dev/null | 17 | +++ b/target/arm/helper-mve.h |
24 | +++ b/scripts/coccinelle/timer-del-timer-free.cocci | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vqnegb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
25 | @@ -XXX,XX +XXX,XX @@ | 19 | DEF_HELPER_FLAGS_3(mve_vqnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
26 | +// Remove superfluous timer_del() calls | 20 | DEF_HELPER_FLAGS_3(mve_vqnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) |
27 | +// | 21 | |
28 | +// Copyright Linaro Limited 2020 | 22 | +DEF_HELPER_FLAGS_3(mve_vmaxab, TCG_CALL_NO_WG, void, env, ptr, ptr) |
29 | +// This work is licensed under the terms of the GNU GPLv2 or later. | 23 | +DEF_HELPER_FLAGS_3(mve_vmaxah, TCG_CALL_NO_WG, void, env, ptr, ptr) |
30 | +// | 24 | +DEF_HELPER_FLAGS_3(mve_vmaxaw, TCG_CALL_NO_WG, void, env, ptr, ptr) |
31 | +// spatch --macro-file scripts/cocci-macro-file.h \ | ||
32 | +// --sp-file scripts/coccinelle/timer-del-timer-free.cocci \ | ||
33 | +// --in-place --dir . | ||
34 | +// | ||
35 | +// The timer_free() function now implicitly calls timer_del() | ||
36 | +// for you, so calls to timer_del() immediately before the | ||
37 | +// timer_free() of the same timer can be deleted. | ||
38 | + | 25 | + |
39 | +@@ | 26 | +DEF_HELPER_FLAGS_3(mve_vminab, TCG_CALL_NO_WG, void, env, ptr, ptr) |
40 | +expression T; | 27 | +DEF_HELPER_FLAGS_3(mve_vminah, TCG_CALL_NO_WG, void, env, ptr, ptr) |
41 | +@@ | 28 | +DEF_HELPER_FLAGS_3(mve_vminaw, TCG_CALL_NO_WG, void, env, ptr, ptr) |
42 | +-timer_del(T); | 29 | + |
43 | + timer_free(T); | 30 | DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
31 | DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
32 | DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
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 @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
38 | VQMOVUNB 111 0 1110 0 . 11 .. 01 ... 0 1110 1 0 . 0 ... 1 @1op | ||
39 | VQMOVN_BS 111 0 1110 0 . 11 .. 11 ... 0 1110 0 0 . 0 ... 1 @1op | ||
40 | |||
41 | + VMAXA 111 0 1110 0 . 11 .. 11 ... 0 1110 1 0 . 0 ... 1 @1op | ||
42 | + | ||
43 | VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
44 | } | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
47 | VQMOVUNT 111 0 1110 0 . 11 .. 01 ... 1 1110 1 0 . 0 ... 1 @1op | ||
48 | VQMOVN_TS 111 0 1110 0 . 11 .. 11 ... 1 1110 0 0 . 0 ... 1 @1op | ||
49 | |||
50 | + VMINA 111 0 1110 0 . 11 .. 11 ... 1 1110 1 0 . 0 ... 1 @1op | ||
51 | + | ||
52 | VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
53 | } | ||
54 | |||
55 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/mve_helper.c | ||
58 | +++ b/target/arm/mve_helper.c | ||
59 | @@ -XXX,XX +XXX,XX @@ DO_1OP_SAT(vqabsw, 4, int32_t, DO_VQABS_W) | ||
60 | DO_1OP_SAT(vqnegb, 1, int8_t, DO_VQNEG_B) | ||
61 | DO_1OP_SAT(vqnegh, 2, int16_t, DO_VQNEG_H) | ||
62 | DO_1OP_SAT(vqnegw, 4, int32_t, DO_VQNEG_W) | ||
63 | + | ||
64 | +/* | ||
65 | + * VMAXA, VMINA: vd is unsigned; vm is signed, and we take its | ||
66 | + * absolute value; we then do an unsigned comparison. | ||
67 | + */ | ||
68 | +#define DO_VMAXMINA(OP, ESIZE, STYPE, UTYPE, FN) \ | ||
69 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
70 | + { \ | ||
71 | + UTYPE *d = vd; \ | ||
72 | + STYPE *m = vm; \ | ||
73 | + uint16_t mask = mve_element_mask(env); \ | ||
74 | + unsigned e; \ | ||
75 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
76 | + UTYPE r = DO_ABS(m[H##ESIZE(e)]); \ | ||
77 | + r = FN(d[H##ESIZE(e)], r); \ | ||
78 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
79 | + } \ | ||
80 | + mve_advance_vpt(env); \ | ||
81 | + } | ||
82 | + | ||
83 | +DO_VMAXMINA(vmaxab, 1, int8_t, uint8_t, DO_MAX) | ||
84 | +DO_VMAXMINA(vmaxah, 2, int16_t, uint16_t, DO_MAX) | ||
85 | +DO_VMAXMINA(vmaxaw, 4, int32_t, uint32_t, DO_MAX) | ||
86 | +DO_VMAXMINA(vminab, 1, int8_t, uint8_t, DO_MIN) | ||
87 | +DO_VMAXMINA(vminah, 2, int16_t, uint16_t, DO_MIN) | ||
88 | +DO_VMAXMINA(vminaw, 4, int32_t, uint32_t, DO_MIN) | ||
89 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/target/arm/translate-mve.c | ||
92 | +++ b/target/arm/translate-mve.c | ||
93 | @@ -XXX,XX +XXX,XX @@ DO_1OP(VABS, vabs) | ||
94 | DO_1OP(VNEG, vneg) | ||
95 | DO_1OP(VQABS, vqabs) | ||
96 | DO_1OP(VQNEG, vqneg) | ||
97 | +DO_1OP(VMAXA, vmaxa) | ||
98 | +DO_1OP(VMINA, vmina) | ||
99 | |||
100 | /* Narrowing moves: only size 0 and 1 are valid */ | ||
101 | #define DO_VMOVN(INSN, FN) \ | ||
44 | -- | 102 | -- |
45 | 2.20.1 | 103 | 2.20.1 |
46 | 104 | ||
47 | 105 | diff view generated by jsdifflib |
1 | Currently timer_free() is a simple wrapper for g_free(). This means | 1 | Implement the MVE VMOV forms that move data between 2 general-purpose |
---|---|---|---|
2 | that the timer being freed must not be currently active, as otherwise | 2 | registers and 2 32-bit lanes in a vector register. |
3 | QEMU might crash later when the active list is processed and still | ||
4 | has a pointer to freed memory on it. As a result almost all calls to | ||
5 | timer_free() are preceded by a timer_del() call, as can be seen in | ||
6 | the output of | ||
7 | git grep -B1 '\<timer_free\>' | ||
8 | |||
9 | This is unfortunate API design as it makes it easy to accidentally | ||
10 | misuse (by forgetting the timer_del()), and the correct use is | ||
11 | annoyingly verbose. | ||
12 | |||
13 | Make timer_free() imply a timer_del(). | ||
14 | 3 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
18 | Message-id: 20201215154107.3255-2-peter.maydell@linaro.org | ||
19 | --- | 6 | --- |
20 | include/qemu/timer.h | 24 +++++++++++++----------- | 7 | target/arm/translate-a32.h | 1 + |
21 | 1 file changed, 13 insertions(+), 11 deletions(-) | 8 | target/arm/mve.decode | 4 ++ |
9 | target/arm/translate-mve.c | 85 ++++++++++++++++++++++++++++++++++++++ | ||
10 | target/arm/translate-vfp.c | 2 +- | ||
11 | 4 files changed, 91 insertions(+), 1 deletion(-) | ||
22 | 12 | ||
23 | diff --git a/include/qemu/timer.h b/include/qemu/timer.h | 13 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h |
24 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/qemu/timer.h | 15 | --- a/target/arm/translate-a32.h |
26 | +++ b/include/qemu/timer.h | 16 | +++ b/target/arm/translate-a32.h |
27 | @@ -XXX,XX +XXX,XX @@ static inline QEMUTimer *timer_new_ms(QEMUClockType type, QEMUTimerCB *cb, | 17 | @@ -XXX,XX +XXX,XX @@ void gen_rev16(TCGv_i32 dest, TCGv_i32 var); |
28 | */ | 18 | void clear_eci_state(DisasContext *s); |
29 | void timer_deinit(QEMUTimer *ts); | 19 | bool mve_eci_check(DisasContext *s); |
30 | 20 | void mve_update_and_store_eci(DisasContext *s); | |
31 | -/** | 21 | +bool mve_skip_vmov(DisasContext *s, int vn, int index, int size); |
32 | - * timer_free: | 22 | |
33 | - * @ts: the timer | 23 | static inline TCGv_i32 load_cpu_offset(int offset) |
34 | - * | 24 | { |
35 | - * Free a timer (it must not be on the active list) | 25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
36 | - */ | 26 | index XXXXXXX..XXXXXXX 100644 |
37 | -static inline void timer_free(QEMUTimer *ts) | 27 | --- a/target/arm/mve.decode |
38 | -{ | 28 | +++ b/target/arm/mve.decode |
39 | - g_free(ts); | 29 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ |
40 | -} | 30 | VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ |
41 | - | 31 | size=2 p=1 |
42 | /** | 32 | |
43 | * timer_del: | 33 | +# Moves between 2 32-bit vector lanes and 2 general purpose registers |
44 | * @ts: the timer | 34 | +VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd |
45 | @@ -XXX,XX +XXX,XX @@ static inline void timer_free(QEMUTimer *ts) | 35 | +VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd |
46 | */ | 36 | + |
47 | void timer_del(QEMUTimer *ts); | 37 | # Vector 2-op |
48 | 38 | VAND 1110 1111 0 . 00 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | |
49 | +/** | 39 | VBIC 1110 1111 0 . 01 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz |
50 | + * timer_free: | 40 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
51 | + * @ts: the timer | 41 | index XXXXXXX..XXXXXXX 100644 |
52 | + * | 42 | --- a/target/arm/translate-mve.c |
53 | + * Free a timer. This will call timer_del() for you to remove | 43 | +++ b/target/arm/translate-mve.c |
54 | + * the timer from the active list if it was still active. | 44 | @@ -XXX,XX +XXX,XX @@ static bool do_vabav(DisasContext *s, arg_vabav *a, MVEGenVABAVFn *fn) |
55 | + */ | 45 | |
56 | +static inline void timer_free(QEMUTimer *ts) | 46 | DO_VABAV(VABAV_S, vabavs) |
47 | DO_VABAV(VABAV_U, vabavu) | ||
48 | + | ||
49 | +static bool trans_VMOV_to_2gp(DisasContext *s, arg_VMOV_to_2gp *a) | ||
57 | +{ | 50 | +{ |
58 | + timer_del(ts); | 51 | + /* |
59 | + g_free(ts); | 52 | + * VMOV two 32-bit vector lanes to two general-purpose registers. |
53 | + * This insn is not predicated but it is subject to beat-wise | ||
54 | + * execution if it is not in an IT block. For us this means | ||
55 | + * only that if PSR.ECI says we should not be executing the beat | ||
56 | + * corresponding to the lane of the vector register being accessed | ||
57 | + * then we should skip perfoming the move, and that we need to do | ||
58 | + * the usual check for bad ECI state and advance of ECI state. | ||
59 | + * (If PSR.ECI is non-zero then we cannot be in an IT block.) | ||
60 | + */ | ||
61 | + TCGv_i32 tmp; | ||
62 | + int vd; | ||
63 | + | ||
64 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd) || | ||
65 | + a->rt == 13 || a->rt == 15 || a->rt2 == 13 || a->rt2 == 15 || | ||
66 | + a->rt == a->rt2) { | ||
67 | + /* Rt/Rt2 cases are UNPREDICTABLE */ | ||
68 | + return false; | ||
69 | + } | ||
70 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + | ||
74 | + /* Convert Qreg index to Dreg for read_neon_element32() etc */ | ||
75 | + vd = a->qd * 2; | ||
76 | + | ||
77 | + if (!mve_skip_vmov(s, vd, a->idx, MO_32)) { | ||
78 | + tmp = tcg_temp_new_i32(); | ||
79 | + read_neon_element32(tmp, vd, a->idx, MO_32); | ||
80 | + store_reg(s, a->rt, tmp); | ||
81 | + } | ||
82 | + if (!mve_skip_vmov(s, vd + 1, a->idx, MO_32)) { | ||
83 | + tmp = tcg_temp_new_i32(); | ||
84 | + read_neon_element32(tmp, vd + 1, a->idx, MO_32); | ||
85 | + store_reg(s, a->rt2, tmp); | ||
86 | + } | ||
87 | + | ||
88 | + mve_update_and_store_eci(s); | ||
89 | + return true; | ||
60 | +} | 90 | +} |
61 | + | 91 | + |
62 | /** | 92 | +static bool trans_VMOV_from_2gp(DisasContext *s, arg_VMOV_to_2gp *a) |
63 | * timer_mod_ns: | 93 | +{ |
64 | * @ts: the timer | 94 | + /* |
95 | + * VMOV two general-purpose registers to two 32-bit vector lanes. | ||
96 | + * This insn is not predicated but it is subject to beat-wise | ||
97 | + * execution if it is not in an IT block. For us this means | ||
98 | + * only that if PSR.ECI says we should not be executing the beat | ||
99 | + * corresponding to the lane of the vector register being accessed | ||
100 | + * then we should skip perfoming the move, and that we need to do | ||
101 | + * the usual check for bad ECI state and advance of ECI state. | ||
102 | + * (If PSR.ECI is non-zero then we cannot be in an IT block.) | ||
103 | + */ | ||
104 | + TCGv_i32 tmp; | ||
105 | + int vd; | ||
106 | + | ||
107 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd) || | ||
108 | + a->rt == 13 || a->rt == 15 || a->rt2 == 13 || a->rt2 == 15) { | ||
109 | + /* Rt/Rt2 cases are UNPREDICTABLE */ | ||
110 | + return false; | ||
111 | + } | ||
112 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
113 | + return true; | ||
114 | + } | ||
115 | + | ||
116 | + /* Convert Qreg idx to Dreg for read_neon_element32() etc */ | ||
117 | + vd = a->qd * 2; | ||
118 | + | ||
119 | + if (!mve_skip_vmov(s, vd, a->idx, MO_32)) { | ||
120 | + tmp = load_reg(s, a->rt); | ||
121 | + write_neon_element32(tmp, vd, a->idx, MO_32); | ||
122 | + tcg_temp_free_i32(tmp); | ||
123 | + } | ||
124 | + if (!mve_skip_vmov(s, vd + 1, a->idx, MO_32)) { | ||
125 | + tmp = load_reg(s, a->rt2); | ||
126 | + write_neon_element32(tmp, vd + 1, a->idx, MO_32); | ||
127 | + tcg_temp_free_i32(tmp); | ||
128 | + } | ||
129 | + | ||
130 | + mve_update_and_store_eci(s); | ||
131 | + return true; | ||
132 | +} | ||
133 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/target/arm/translate-vfp.c | ||
136 | +++ b/target/arm/translate-vfp.c | ||
137 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
138 | return true; | ||
139 | } | ||
140 | |||
141 | -static bool mve_skip_vmov(DisasContext *s, int vn, int index, int size) | ||
142 | +bool mve_skip_vmov(DisasContext *s, int vn, int index, int size) | ||
143 | { | ||
144 | /* | ||
145 | * In a CPU with MVE, the VMOV (vector lane to general-purpose register) | ||
65 | -- | 146 | -- |
66 | 2.20.1 | 147 | 2.20.1 |
67 | 148 | ||
68 | 149 | diff view generated by jsdifflib |
1 | Implement the v8.1M FPCXT_NS floating-point system register. This is | 1 | Implement the MVE VPNOT insn, which inverts the bits in VPR.P0 |
---|---|---|---|
2 | a little more complicated than FPCXT_S, because it has specific | 2 | (subject to both predication and to beatwise execution). |
3 | handling for "current FP state is inactive", and it only wants to do | ||
4 | PreserveFPState(), not the full set of actions done by | ||
5 | ExecuteFPCheck() which vfp_access_check() implements. | ||
6 | 3 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201210201433.26262-4-peter.maydell@linaro.org | ||
10 | --- | 6 | --- |
11 | target/arm/translate-vfp.c.inc | 102 ++++++++++++++++++++++++++++++++- | 7 | target/arm/helper-mve.h | 1 + |
12 | 1 file changed, 99 insertions(+), 3 deletions(-) | 8 | target/arm/mve.decode | 1 + |
9 | target/arm/mve_helper.c | 17 +++++++++++++++++ | ||
10 | target/arm/translate-mve.c | 19 +++++++++++++++++++ | ||
11 | 4 files changed, 38 insertions(+) | ||
13 | 12 | ||
14 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | 13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-vfp.c.inc | 15 | --- a/target/arm/helper-mve.h |
17 | +++ b/target/arm/translate-vfp.c.inc | 16 | +++ b/target/arm/helper-mve.h |
18 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | 17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
19 | } | 18 | DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
20 | break; | 19 | |
21 | case ARM_VFP_FPCXT_S: | 20 | DEF_HELPER_FLAGS_4(mve_vpsel, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
22 | + case ARM_VFP_FPCXT_NS: | 21 | +DEF_HELPER_FLAGS_1(mve_vpnot, TCG_CALL_NO_WG, void, env) |
23 | if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | 22 | |
24 | return false; | 23 | DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
25 | } | 24 | DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
26 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | 25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
27 | return FPSysRegCheckFailed; | 26 | index XXXXXXX..XXXXXXX 100644 |
28 | } | 27 | --- a/target/arm/mve.decode |
29 | 28 | +++ b/target/arm/mve.decode | |
30 | - if (!vfp_access_check(s)) { | 29 | @@ -XXX,XX +XXX,XX @@ VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp |
31 | + /* | 30 | VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp |
32 | + * FPCXT_NS is a special case: it has specific handling for | 31 | |
33 | + * "current FP state is inactive", and must do the PreserveFPState() | 32 | { |
34 | + * but not the usual full set of actions done by ExecuteFPCheck(). | 33 | + VPNOT 1111 1110 0 0 11 000 1 000 0 1111 0100 1101 |
35 | + * So we don't call vfp_access_check() and the callers must handle this. | 34 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 |
36 | + */ | 35 | VCMPEQ_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 0 0 .... @vcmp_scalar |
37 | + if (regno != ARM_VFP_FPCXT_NS && !vfp_access_check(s)) { | ||
38 | return FPSysRegCheckDone; | ||
39 | } | ||
40 | - | ||
41 | return FPSysRegCheckContinue; | ||
42 | } | 36 | } |
43 | 37 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | |
44 | +static void gen_branch_fpInactive(DisasContext *s, TCGCond cond, | 38 | index XXXXXXX..XXXXXXX 100644 |
45 | + TCGLabel *label) | 39 | --- a/target/arm/mve_helper.c |
40 | +++ b/target/arm/mve_helper.c | ||
41 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vpsel)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
42 | mve_advance_vpt(env); | ||
43 | } | ||
44 | |||
45 | +void HELPER(mve_vpnot)(CPUARMState *env) | ||
46 | +{ | 46 | +{ |
47 | + /* | 47 | + /* |
48 | + * FPCXT_NS is a special case: it has specific handling for | 48 | + * P0 bits for unexecuted beats (where eci_mask is 0) are unchanged. |
49 | + * "current FP state is inactive", and must do the PreserveFPState() | 49 | + * P0 bits for predicated lanes in executed bits (where mask is 0) are 0. |
50 | + * but not the usual full set of actions done by ExecuteFPCheck(). | 50 | + * P0 bits otherwise are inverted. |
51 | + * We don't have a TB flag that matches the fpInactive check, so we | 51 | + * (This is the same logic as VCMP.) |
52 | + * do it at runtime as we don't expect FPCXT_NS accesses to be frequent. | 52 | + * This insn is itself subject to predication and to beat-wise execution, |
53 | + * | 53 | + * and after it executes VPT state advances in the usual way. |
54 | + * Emit code that checks fpInactive and does a conditional | ||
55 | + * branch to label based on it: | ||
56 | + * if cond is TCG_COND_NE then branch if fpInactive != 0 (ie if inactive) | ||
57 | + * if cond is TCG_COND_EQ then branch if fpInactive == 0 (ie if active) | ||
58 | + */ | 54 | + */ |
59 | + assert(cond == TCG_COND_EQ || cond == TCG_COND_NE); | 55 | + uint16_t mask = mve_element_mask(env); |
60 | + | 56 | + uint16_t eci_mask = mve_eci_mask(env); |
61 | + /* fpInactive = FPCCR_NS.ASPEN == 1 && CONTROL.FPCA == 0 */ | 57 | + uint16_t beatpred = ~env->v7m.vpr & mask; |
62 | + TCGv_i32 aspen, fpca; | 58 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | (beatpred & eci_mask); |
63 | + aspen = load_cpu_field(v7m.fpccr[M_REG_NS]); | 59 | + mve_advance_vpt(env); |
64 | + fpca = load_cpu_field(v7m.control[M_REG_S]); | ||
65 | + tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
66 | + tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
67 | + tcg_gen_andi_i32(fpca, fpca, R_V7M_CONTROL_FPCA_MASK); | ||
68 | + tcg_gen_or_i32(fpca, fpca, aspen); | ||
69 | + tcg_gen_brcondi_i32(tcg_invert_cond(cond), fpca, 0, label); | ||
70 | + tcg_temp_free_i32(aspen); | ||
71 | + tcg_temp_free_i32(fpca); | ||
72 | +} | 60 | +} |
73 | + | 61 | + |
74 | static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 62 | #define DO_1OP_SAT(OP, ESIZE, TYPE, FN) \ |
75 | 63 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | |
76 | fp_sysreg_loadfn *loadfn, | 64 | { \ |
77 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 65 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
78 | { | 66 | index XXXXXXX..XXXXXXX 100644 |
79 | /* Do a write to an M-profile floating point system register */ | 67 | --- a/target/arm/translate-mve.c |
80 | TCGv_i32 tmp; | 68 | +++ b/target/arm/translate-mve.c |
81 | + TCGLabel *lab_end = NULL; | 69 | @@ -XXX,XX +XXX,XX @@ static bool trans_VPST(DisasContext *s, arg_VPST *a) |
82 | |||
83 | switch (fp_sysreg_checks(s, regno)) { | ||
84 | case FPSysRegCheckFailed: | ||
85 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
86 | tcg_temp_free_i32(tmp); | ||
87 | break; | ||
88 | } | ||
89 | + case ARM_VFP_FPCXT_NS: | ||
90 | + lab_end = gen_new_label(); | ||
91 | + /* fpInactive case: write is a NOP, so branch to end */ | ||
92 | + gen_branch_fpInactive(s, TCG_COND_NE, lab_end); | ||
93 | + /* !fpInactive: PreserveFPState(), and reads same as FPCXT_S */ | ||
94 | + gen_preserve_fp_state(s); | ||
95 | + /* fall through */ | ||
96 | case ARM_VFP_FPCXT_S: | ||
97 | { | ||
98 | TCGv_i32 sfpa, control; | ||
99 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
100 | default: | ||
101 | g_assert_not_reached(); | ||
102 | } | ||
103 | + if (lab_end) { | ||
104 | + gen_set_label(lab_end); | ||
105 | + } | ||
106 | return true; | 70 | return true; |
107 | } | 71 | } |
108 | 72 | ||
109 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | 73 | +static bool trans_VPNOT(DisasContext *s, arg_VPNOT *a) |
74 | +{ | ||
75 | + /* | ||
76 | + * Invert the predicate in VPR.P0. We have call out to | ||
77 | + * a helper because this insn itself is beatwise and can | ||
78 | + * be predicated. | ||
79 | + */ | ||
80 | + if (!dc_isar_feature(aa32_mve, s)) { | ||
81 | + return false; | ||
82 | + } | ||
83 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
84 | + return true; | ||
85 | + } | ||
86 | + | ||
87 | + gen_helper_mve_vpnot(cpu_env); | ||
88 | + mve_update_eci(s); | ||
89 | + return true; | ||
90 | +} | ||
91 | + | ||
92 | static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | ||
110 | { | 93 | { |
111 | /* Do a read from an M-profile floating point system register */ | 94 | /* VADDV: vector add across vector */ |
112 | TCGv_i32 tmp; | ||
113 | + TCGLabel *lab_end = NULL; | ||
114 | + bool lookup_tb = false; | ||
115 | |||
116 | switch (fp_sysreg_checks(s, regno)) { | ||
117 | case FPSysRegCheckFailed: | ||
118 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
119 | fpscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
120 | gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
121 | tcg_temp_free_i32(fpscr); | ||
122 | - gen_lookup_tb(s); | ||
123 | + lookup_tb = true; | ||
124 | + break; | ||
125 | + } | ||
126 | + case ARM_VFP_FPCXT_NS: | ||
127 | + { | ||
128 | + TCGv_i32 control, sfpa, fpscr, fpdscr, zero; | ||
129 | + TCGLabel *lab_active = gen_new_label(); | ||
130 | + | ||
131 | + lookup_tb = true; | ||
132 | + | ||
133 | + gen_branch_fpInactive(s, TCG_COND_EQ, lab_active); | ||
134 | + /* fpInactive case: reads as FPDSCR_NS */ | ||
135 | + TCGv_i32 tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
136 | + storefn(s, opaque, tmp); | ||
137 | + lab_end = gen_new_label(); | ||
138 | + tcg_gen_br(lab_end); | ||
139 | + | ||
140 | + gen_set_label(lab_active); | ||
141 | + /* !fpInactive: Reads the same as FPCXT_S, but side effects differ */ | ||
142 | + gen_preserve_fp_state(s); | ||
143 | + tmp = tcg_temp_new_i32(); | ||
144 | + sfpa = tcg_temp_new_i32(); | ||
145 | + fpscr = tcg_temp_new_i32(); | ||
146 | + gen_helper_vfp_get_fpscr(fpscr, cpu_env); | ||
147 | + tcg_gen_andi_i32(tmp, fpscr, ~FPCR_NZCV_MASK); | ||
148 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
149 | + tcg_gen_andi_i32(sfpa, control, R_V7M_CONTROL_SFPA_MASK); | ||
150 | + tcg_gen_shli_i32(sfpa, sfpa, 31 - R_V7M_CONTROL_SFPA_SHIFT); | ||
151 | + tcg_gen_or_i32(tmp, tmp, sfpa); | ||
152 | + tcg_temp_free_i32(control); | ||
153 | + /* Store result before updating FPSCR, in case it faults */ | ||
154 | + storefn(s, opaque, tmp); | ||
155 | + /* If SFPA is zero then set FPSCR from FPDSCR_NS */ | ||
156 | + fpdscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
157 | + zero = tcg_const_i32(0); | ||
158 | + tcg_gen_movcond_i32(TCG_COND_EQ, fpscr, sfpa, zero, fpdscr, fpscr); | ||
159 | + gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
160 | + tcg_temp_free_i32(zero); | ||
161 | + tcg_temp_free_i32(sfpa); | ||
162 | + tcg_temp_free_i32(fpdscr); | ||
163 | + tcg_temp_free_i32(fpscr); | ||
164 | break; | ||
165 | } | ||
166 | default: | ||
167 | g_assert_not_reached(); | ||
168 | } | ||
169 | + | ||
170 | + if (lab_end) { | ||
171 | + gen_set_label(lab_end); | ||
172 | + } | ||
173 | + if (lookup_tb) { | ||
174 | + gen_lookup_tb(s); | ||
175 | + } | ||
176 | return true; | ||
177 | } | ||
178 | |||
179 | -- | 95 | -- |
180 | 2.20.1 | 96 | 2.20.1 |
181 | 97 | ||
182 | 98 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | Implement the MVE VCTP insn, which sets the VPR.P0 predicate bits so |
---|---|---|---|
2 | as to predicate any element at index Rn or greater is predicated. As | ||
3 | with VPNOT, this insn itself is predicable and subject to beatwise | ||
4 | execution. | ||
2 | 5 | ||
3 | When running device-introspect-test, a memory leak occurred in the a10_pit_init | 6 | The calculation of the mask is the same as is used to determine |
4 | function, so use ptimer_free() in the finalize function to avoid it. | 7 | ltpmask in mve_element_mask(), but we precalculate masklen in |
8 | generated code to avoid having to have 4 helpers specialized by size. | ||
5 | 9 | ||
6 | ASAN shows memory leak stack: | 10 | We put the decode line in with the low-overhead-loop insns in |
11 | t32.decode because it's logically part of that collection of insn | ||
12 | patterns, even though it is an MVE only insn. | ||
7 | 13 | ||
8 | Indirect leak of 288 byte(s) in 6 object(s) allocated from: | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | 15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | 16 | --- |
11 | #2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523 | 17 | target/arm/helper-mve.h | 2 ++ |
12 | #3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544 | 18 | target/arm/translate-a32.h | 1 + |
13 | #4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562 | 19 | target/arm/t32.decode | 1 + |
14 | #5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433 | 20 | target/arm/mve_helper.c | 20 ++++++++++++++++++++ |
15 | #6 0xaaabf57415e8 in a10_pit_init /qemu/hw/timer/allwinner-a10-pit.c:278 | 21 | target/arm/translate-mve.c | 2 +- |
16 | #7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | 22 | target/arm/translate.c | 33 +++++++++++++++++++++++++++++++++ |
17 | #8 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564 | 23 | 6 files changed, 58 insertions(+), 1 deletion(-) |
18 | #9 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547 | ||
19 | #10 0xaaabf5b94680 in aw_a10_init /qemu/hw/arm/allwinner-a10.c:49 | ||
20 | #11 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
21 | #12 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
22 | 24 | ||
23 | Reported-by: Euler Robot <euler.robot@huawei.com> | 25 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
24 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | --- | ||
28 | hw/timer/allwinner-a10-pit.c | 11 +++++++++++ | ||
29 | 1 file changed, 11 insertions(+) | ||
30 | |||
31 | diff --git a/hw/timer/allwinner-a10-pit.c b/hw/timer/allwinner-a10-pit.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/hw/timer/allwinner-a10-pit.c | 27 | --- a/target/arm/helper-mve.h |
34 | +++ b/hw/timer/allwinner-a10-pit.c | 28 | +++ b/target/arm/helper-mve.h |
35 | @@ -XXX,XX +XXX,XX @@ static void a10_pit_init(Object *obj) | 29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
30 | DEF_HELPER_FLAGS_4(mve_vpsel, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | DEF_HELPER_FLAGS_1(mve_vpnot, TCG_CALL_NO_WG, void, env) | ||
32 | |||
33 | +DEF_HELPER_FLAGS_2(mve_vctp, TCG_CALL_NO_WG, void, env, i32) | ||
34 | + | ||
35 | DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
36 | DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
37 | DEF_HELPER_FLAGS_4(mve_vaddw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
38 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/translate-a32.h | ||
41 | +++ b/target/arm/translate-a32.h | ||
42 | @@ -XXX,XX +XXX,XX @@ long neon_element_offset(int reg, int element, MemOp memop); | ||
43 | void gen_rev16(TCGv_i32 dest, TCGv_i32 var); | ||
44 | void clear_eci_state(DisasContext *s); | ||
45 | bool mve_eci_check(DisasContext *s); | ||
46 | +void mve_update_eci(DisasContext *s); | ||
47 | void mve_update_and_store_eci(DisasContext *s); | ||
48 | bool mve_skip_vmov(DisasContext *s, int vn, int index, int size); | ||
49 | |||
50 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/t32.decode | ||
53 | +++ b/target/arm/t32.decode | ||
54 | @@ -XXX,XX +XXX,XX @@ BL 1111 0. .......... 11.1 ............ @branch24 | ||
55 | # This is DLSTP | ||
56 | DLS 1111 0 0000 0 size:2 rn:4 1110 0000 0000 0001 | ||
57 | } | ||
58 | + VCTP 1111 0 0000 0 size:2 rn:4 1110 1000 0000 0001 | ||
59 | ] | ||
60 | } | ||
61 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/mve_helper.c | ||
64 | +++ b/target/arm/mve_helper.c | ||
65 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vpnot)(CPUARMState *env) | ||
66 | mve_advance_vpt(env); | ||
67 | } | ||
68 | |||
69 | +/* | ||
70 | + * VCTP: P0 unexecuted bits unchanged, predicated bits zeroed, | ||
71 | + * otherwise set according to value of Rn. The calculation of | ||
72 | + * newmask here works in the same way as the calculation of the | ||
73 | + * ltpmask in mve_element_mask(), but we have pre-calculated | ||
74 | + * the masklen in the generated code. | ||
75 | + */ | ||
76 | +void HELPER(mve_vctp)(CPUARMState *env, uint32_t masklen) | ||
77 | +{ | ||
78 | + uint16_t mask = mve_element_mask(env); | ||
79 | + uint16_t eci_mask = mve_eci_mask(env); | ||
80 | + uint16_t newmask; | ||
81 | + | ||
82 | + assert(masklen <= 16); | ||
83 | + newmask = masklen ? MAKE_64BIT_MASK(0, masklen) : 0; | ||
84 | + newmask &= mask; | ||
85 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | (newmask & eci_mask); | ||
86 | + mve_advance_vpt(env); | ||
87 | +} | ||
88 | + | ||
89 | #define DO_1OP_SAT(OP, ESIZE, TYPE, FN) \ | ||
90 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
91 | { \ | ||
92 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/translate-mve.c | ||
95 | +++ b/target/arm/translate-mve.c | ||
96 | @@ -XXX,XX +XXX,XX @@ bool mve_eci_check(DisasContext *s) | ||
36 | } | 97 | } |
37 | } | 98 | } |
38 | 99 | ||
39 | +static void a10_pit_finalize(Object *obj) | 100 | -static void mve_update_eci(DisasContext *s) |
101 | +void mve_update_eci(DisasContext *s) | ||
102 | { | ||
103 | /* | ||
104 | * The helper function will always update the CPUState field, | ||
105 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/translate.c | ||
108 | +++ b/target/arm/translate.c | ||
109 | @@ -XXX,XX +XXX,XX @@ static bool trans_LCTP(DisasContext *s, arg_LCTP *a) | ||
110 | return true; | ||
111 | } | ||
112 | |||
113 | +static bool trans_VCTP(DisasContext *s, arg_VCTP *a) | ||
40 | +{ | 114 | +{ |
41 | + AwA10PITState *s = AW_A10_PIT(obj); | 115 | + /* |
42 | + int i; | 116 | + * M-profile Create Vector Tail Predicate. This insn is itself |
117 | + * predicated and is subject to beatwise execution. | ||
118 | + */ | ||
119 | + TCGv_i32 rn_shifted, masklen; | ||
43 | + | 120 | + |
44 | + for (i = 0; i < AW_A10_PIT_TIMER_NR; i++) { | 121 | + if (!dc_isar_feature(aa32_mve, s) || a->rn == 13 || a->rn == 15) { |
45 | + ptimer_free(s->timer[i]); | 122 | + return false; |
46 | + } | 123 | + } |
124 | + | ||
125 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
126 | + return true; | ||
127 | + } | ||
128 | + | ||
129 | + /* | ||
130 | + * We pre-calculate the mask length here to avoid having | ||
131 | + * to have multiple helpers specialized for size. | ||
132 | + * We pass the helper "rn <= (1 << (4 - size)) ? (rn << size) : 16". | ||
133 | + */ | ||
134 | + rn_shifted = tcg_temp_new_i32(); | ||
135 | + masklen = load_reg(s, a->rn); | ||
136 | + tcg_gen_shli_i32(rn_shifted, masklen, a->size); | ||
137 | + tcg_gen_movcond_i32(TCG_COND_LEU, masklen, | ||
138 | + masklen, tcg_constant_i32(1 << (4 - a->size)), | ||
139 | + rn_shifted, tcg_constant_i32(16)); | ||
140 | + gen_helper_mve_vctp(cpu_env, masklen); | ||
141 | + tcg_temp_free_i32(masklen); | ||
142 | + tcg_temp_free_i32(rn_shifted); | ||
143 | + mve_update_eci(s); | ||
144 | + return true; | ||
47 | +} | 145 | +} |
48 | + | 146 | |
49 | static void a10_pit_class_init(ObjectClass *klass, void *data) | 147 | static bool op_tbranch(DisasContext *s, arg_tbranch *a, bool half) |
50 | { | 148 | { |
51 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
52 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo a10_pit_info = { | ||
53 | .parent = TYPE_SYS_BUS_DEVICE, | ||
54 | .instance_size = sizeof(AwA10PITState), | ||
55 | .instance_init = a10_pit_init, | ||
56 | + .instance_finalize = a10_pit_finalize, | ||
57 | .class_init = a10_pit_class_init, | ||
58 | }; | ||
59 | |||
60 | -- | 149 | -- |
61 | 2.20.1 | 150 | 2.20.1 |
62 | 151 | ||
63 | 152 | diff view generated by jsdifflib |
1 | In commit 64f863baeedc8659 we implemented the v8.1M FPCXT_S register, | 1 | Implement the MVE gather-loads and scatter-stores which |
---|---|---|---|
2 | but we got the write behaviour wrong. On read, this register reads | 2 | form the address by adding a base value from a scalar |
3 | bits [27:0] of FPSCR plus the CONTROL.SFPA bit. On write, it doesn't | 3 | register to an offset in each element of a vector. |
4 | just write back those bits -- it writes a value to the whole FPSCR, | ||
5 | whose upper 4 bits are zeroes. | ||
6 | |||
7 | We also incorrectly implemented the write-to-FPSCR as a simple store | ||
8 | to vfp.xregs; this skips the "update the softfloat flags" part of | ||
9 | the vfp_set_fpscr helper so the value would read back correctly but | ||
10 | not actually take effect. | ||
11 | |||
12 | Fix both of these things by doing a complete write to the FPSCR | ||
13 | using the helper function. | ||
14 | 4 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-id: 20201210201433.26262-3-peter.maydell@linaro.org | ||
18 | --- | 7 | --- |
19 | target/arm/translate-vfp.c.inc | 12 ++++++------ | 8 | target/arm/helper-mve.h | 32 +++++++++ |
20 | 1 file changed, 6 insertions(+), 6 deletions(-) | 9 | target/arm/mve.decode | 12 ++++ |
10 | target/arm/mve_helper.c | 129 +++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 97 ++++++++++++++++++++++++++++ | ||
12 | 4 files changed, 270 insertions(+) | ||
21 | 13 | ||
22 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | 14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
23 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/translate-vfp.c.inc | 16 | --- a/target/arm/helper-mve.h |
25 | +++ b/target/arm/translate-vfp.c.inc | 17 | +++ b/target/arm/helper-mve.h |
26 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) |
27 | } | 19 | DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) |
28 | case ARM_VFP_FPCXT_S: | 20 | DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) |
29 | { | 21 | |
30 | - TCGv_i32 sfpa, control, fpscr; | 22 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
31 | - /* Set FPSCR[27:0] and CONTROL.SFPA from value */ | 23 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
32 | + TCGv_i32 sfpa, control; | 24 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
33 | + /* | 25 | + |
34 | + * Set FPSCR and CONTROL.SFPA from value; the new FPSCR takes | 26 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
35 | + * bits [27:0] from value and zeroes bits [31:28]. | 27 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
36 | + */ | 28 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
37 | tmp = loadfn(s, opaque); | 29 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
38 | sfpa = tcg_temp_new_i32(); | 30 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
39 | tcg_gen_shri_i32(sfpa, tmp, 31); | 31 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
40 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 32 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
41 | tcg_gen_deposit_i32(control, control, sfpa, | 33 | + |
42 | R_V7M_CONTROL_SFPA_SHIFT, 1); | 34 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
43 | store_cpu_field(control, v7m.control[M_REG_S]); | 35 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
44 | - fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | 36 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
45 | - tcg_gen_andi_i32(fpscr, fpscr, FPCR_NZCV_MASK); | 37 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
46 | tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); | 38 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
47 | - tcg_gen_or_i32(fpscr, fpscr, tmp); | 39 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
48 | - store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]); | 40 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
49 | + gen_helper_vfp_set_fpscr(cpu_env, tmp); | 41 | + |
50 | tcg_temp_free_i32(tmp); | 42 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
51 | tcg_temp_free_i32(sfpa); | 43 | + |
52 | break; | 44 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
45 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
46 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
47 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
48 | + | ||
49 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
50 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
51 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
53 | + | ||
54 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
55 | |||
56 | DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
57 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/target/arm/mve.decode | ||
60 | +++ b/target/arm/mve.decode | ||
61 | @@ -XXX,XX +XXX,XX @@ | ||
62 | &shl_scalar qda rm size | ||
63 | &vmaxv qm rda size | ||
64 | &vabav qn qm rda size | ||
65 | +&vldst_sg qd qm rn size msize os | ||
66 | + | ||
67 | +# scatter-gather memory size is in bits 6:4 | ||
68 | +%sg_msize 6:1 4:1 | ||
69 | |||
70 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
71 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
72 | @vldst_wn ... u:1 ... . . . . l:1 . rn:3 qd:3 . ... .. imm:7 &vldr_vstr | ||
73 | |||
74 | +@vldst_sg .... .... .... rn:4 .... ... size:2 ... ... os:1 &vldst_sg \ | ||
75 | + qd=%qd qm=%qm msize=%sg_msize | ||
76 | + | ||
77 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | ||
78 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | ||
79 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | ||
80 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ | ||
81 | VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ | ||
82 | size=2 p=1 | ||
83 | |||
84 | +# gather loads/scatter stores | ||
85 | +VLDR_S_sg 111 0 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
86 | +VLDR_U_sg 111 1 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
87 | +VSTR_sg 111 0 1100 1 . 00 .... ... 0 111 . .... .... @vldst_sg | ||
88 | + | ||
89 | # Moves between 2 32-bit vector lanes and 2 general purpose registers | ||
90 | VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
91 | VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
92 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/mve_helper.c | ||
95 | +++ b/target/arm/mve_helper.c | ||
96 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
97 | #undef DO_VLDR | ||
98 | #undef DO_VSTR | ||
99 | |||
100 | +/* | ||
101 | + * Gather loads/scatter stores. Here each element of Qm specifies | ||
102 | + * an offset to use from the base register Rm. In the _os_ versions | ||
103 | + * that offset is scaled by the element size. | ||
104 | + * For loads, predicated lanes are zeroed instead of retaining | ||
105 | + * their previous values. | ||
106 | + */ | ||
107 | +#define DO_VLDR_SG(OP, LDTYPE, ESIZE, TYPE, OFFTYPE, ADDRFN) \ | ||
108 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
109 | + uint32_t base) \ | ||
110 | + { \ | ||
111 | + TYPE *d = vd; \ | ||
112 | + OFFTYPE *m = vm; \ | ||
113 | + uint16_t mask = mve_element_mask(env); \ | ||
114 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
115 | + unsigned e; \ | ||
116 | + uint32_t addr; \ | ||
117 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE, eci_mask >>= ESIZE) { \ | ||
118 | + if (!(eci_mask & 1)) { \ | ||
119 | + continue; \ | ||
120 | + } \ | ||
121 | + addr = ADDRFN(base, m[H##ESIZE(e)]); \ | ||
122 | + d[H##ESIZE(e)] = (mask & 1) ? \ | ||
123 | + cpu_##LDTYPE##_data_ra(env, addr, GETPC()) : 0; \ | ||
124 | + } \ | ||
125 | + mve_advance_vpt(env); \ | ||
126 | + } | ||
127 | + | ||
128 | +/* We know here TYPE is unsigned so always the same as the offset type */ | ||
129 | +#define DO_VSTR_SG(OP, STTYPE, ESIZE, TYPE, ADDRFN) \ | ||
130 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
131 | + uint32_t base) \ | ||
132 | + { \ | ||
133 | + TYPE *d = vd; \ | ||
134 | + TYPE *m = vm; \ | ||
135 | + uint16_t mask = mve_element_mask(env); \ | ||
136 | + unsigned e; \ | ||
137 | + uint32_t addr; \ | ||
138 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
139 | + addr = ADDRFN(base, m[H##ESIZE(e)]); \ | ||
140 | + if (mask & 1) { \ | ||
141 | + cpu_##STTYPE##_data_ra(env, addr, d[H##ESIZE(e)], GETPC()); \ | ||
142 | + } \ | ||
143 | + } \ | ||
144 | + mve_advance_vpt(env); \ | ||
145 | + } | ||
146 | + | ||
147 | +/* | ||
148 | + * 64-bit accesses are slightly different: they are done as two 32-bit | ||
149 | + * accesses, controlled by the predicate mask for the relevant beat, | ||
150 | + * and with a single 32-bit offset in the first of the two Qm elements. | ||
151 | + * Note that for QEMU our IMPDEF AIRCR.ENDIANNESS is always 0 (little). | ||
152 | + */ | ||
153 | +#define DO_VLDR64_SG(OP, ADDRFN) \ | ||
154 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
155 | + uint32_t base) \ | ||
156 | + { \ | ||
157 | + uint32_t *d = vd; \ | ||
158 | + uint32_t *m = vm; \ | ||
159 | + uint16_t mask = mve_element_mask(env); \ | ||
160 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
161 | + unsigned e; \ | ||
162 | + uint32_t addr; \ | ||
163 | + for (e = 0; e < 16 / 4; e++, mask >>= 4, eci_mask >>= 4) { \ | ||
164 | + if (!(eci_mask & 1)) { \ | ||
165 | + continue; \ | ||
166 | + } \ | ||
167 | + addr = ADDRFN(base, m[H4(e & ~1)]); \ | ||
168 | + addr += 4 * (e & 1); \ | ||
169 | + d[H4(e)] = (mask & 1) ? cpu_ldl_data_ra(env, addr, GETPC()) : 0; \ | ||
170 | + } \ | ||
171 | + mve_advance_vpt(env); \ | ||
172 | + } | ||
173 | + | ||
174 | +#define DO_VSTR64_SG(OP, ADDRFN) \ | ||
175 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
176 | + uint32_t base) \ | ||
177 | + { \ | ||
178 | + uint32_t *d = vd; \ | ||
179 | + uint32_t *m = vm; \ | ||
180 | + uint16_t mask = mve_element_mask(env); \ | ||
181 | + unsigned e; \ | ||
182 | + uint32_t addr; \ | ||
183 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
184 | + addr = ADDRFN(base, m[H4(e & ~1)]); \ | ||
185 | + addr += 4 * (e & 1); \ | ||
186 | + if (mask & 1) { \ | ||
187 | + cpu_stl_data_ra(env, addr, d[H4(e)], GETPC()); \ | ||
188 | + } \ | ||
189 | + } \ | ||
190 | + mve_advance_vpt(env); \ | ||
191 | + } | ||
192 | + | ||
193 | +#define ADDR_ADD(BASE, OFFSET) ((BASE) + (OFFSET)) | ||
194 | +#define ADDR_ADD_OSH(BASE, OFFSET) ((BASE) + ((OFFSET) << 1)) | ||
195 | +#define ADDR_ADD_OSW(BASE, OFFSET) ((BASE) + ((OFFSET) << 2)) | ||
196 | +#define ADDR_ADD_OSD(BASE, OFFSET) ((BASE) + ((OFFSET) << 3)) | ||
197 | + | ||
198 | +DO_VLDR_SG(vldrb_sg_sh, ldsb, 2, int16_t, uint16_t, ADDR_ADD) | ||
199 | +DO_VLDR_SG(vldrb_sg_sw, ldsb, 4, int32_t, uint32_t, ADDR_ADD) | ||
200 | +DO_VLDR_SG(vldrh_sg_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD) | ||
201 | + | ||
202 | +DO_VLDR_SG(vldrb_sg_ub, ldub, 1, uint8_t, uint8_t, ADDR_ADD) | ||
203 | +DO_VLDR_SG(vldrb_sg_uh, ldub, 2, uint16_t, uint16_t, ADDR_ADD) | ||
204 | +DO_VLDR_SG(vldrb_sg_uw, ldub, 4, uint32_t, uint32_t, ADDR_ADD) | ||
205 | +DO_VLDR_SG(vldrh_sg_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD) | ||
206 | +DO_VLDR_SG(vldrh_sg_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD) | ||
207 | +DO_VLDR_SG(vldrw_sg_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD) | ||
208 | +DO_VLDR64_SG(vldrd_sg_ud, ADDR_ADD) | ||
209 | + | ||
210 | +DO_VLDR_SG(vldrh_sg_os_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD_OSH) | ||
211 | +DO_VLDR_SG(vldrh_sg_os_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD_OSH) | ||
212 | +DO_VLDR_SG(vldrh_sg_os_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD_OSH) | ||
213 | +DO_VLDR_SG(vldrw_sg_os_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD_OSW) | ||
214 | +DO_VLDR64_SG(vldrd_sg_os_ud, ADDR_ADD_OSD) | ||
215 | + | ||
216 | +DO_VSTR_SG(vstrb_sg_ub, stb, 1, uint8_t, ADDR_ADD) | ||
217 | +DO_VSTR_SG(vstrb_sg_uh, stb, 2, uint16_t, ADDR_ADD) | ||
218 | +DO_VSTR_SG(vstrb_sg_uw, stb, 4, uint32_t, ADDR_ADD) | ||
219 | +DO_VSTR_SG(vstrh_sg_uh, stw, 2, uint16_t, ADDR_ADD) | ||
220 | +DO_VSTR_SG(vstrh_sg_uw, stw, 4, uint32_t, ADDR_ADD) | ||
221 | +DO_VSTR_SG(vstrw_sg_uw, stl, 4, uint32_t, ADDR_ADD) | ||
222 | +DO_VSTR64_SG(vstrd_sg_ud, ADDR_ADD) | ||
223 | + | ||
224 | +DO_VSTR_SG(vstrh_sg_os_uh, stw, 2, uint16_t, ADDR_ADD_OSH) | ||
225 | +DO_VSTR_SG(vstrh_sg_os_uw, stw, 4, uint32_t, ADDR_ADD_OSH) | ||
226 | +DO_VSTR_SG(vstrw_sg_os_uw, stl, 4, uint32_t, ADDR_ADD_OSW) | ||
227 | +DO_VSTR64_SG(vstrd_sg_os_ud, ADDR_ADD_OSD) | ||
228 | + | ||
229 | /* | ||
230 | * The mergemask(D, R, M) macro performs the operation "*D = R" but | ||
231 | * storing only the bytes which correspond to 1 bits in M, | ||
232 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
233 | index XXXXXXX..XXXXXXX 100644 | ||
234 | --- a/target/arm/translate-mve.c | ||
235 | +++ b/target/arm/translate-mve.c | ||
236 | @@ -XXX,XX +XXX,XX @@ static inline int vidup_imm(DisasContext *s, int x) | ||
237 | #include "decode-mve.c.inc" | ||
238 | |||
239 | typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
240 | +typedef void MVEGenLdStSGFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
241 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
242 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
243 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
244 | @@ -XXX,XX +XXX,XX @@ DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h, MO_8) | ||
245 | DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w, MO_8) | ||
246 | DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w, MO_16) | ||
247 | |||
248 | +static bool do_ldst_sg(DisasContext *s, arg_vldst_sg *a, MVEGenLdStSGFn fn) | ||
249 | +{ | ||
250 | + TCGv_i32 addr; | ||
251 | + TCGv_ptr qd, qm; | ||
252 | + | ||
253 | + if (!dc_isar_feature(aa32_mve, s) || | ||
254 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | ||
255 | + !fn || a->rn == 15) { | ||
256 | + /* Rn case is UNPREDICTABLE */ | ||
257 | + return false; | ||
258 | + } | ||
259 | + | ||
260 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
261 | + return true; | ||
262 | + } | ||
263 | + | ||
264 | + addr = load_reg(s, a->rn); | ||
265 | + | ||
266 | + qd = mve_qreg_ptr(a->qd); | ||
267 | + qm = mve_qreg_ptr(a->qm); | ||
268 | + fn(cpu_env, qd, qm, addr); | ||
269 | + tcg_temp_free_ptr(qd); | ||
270 | + tcg_temp_free_ptr(qm); | ||
271 | + tcg_temp_free_i32(addr); | ||
272 | + mve_update_eci(s); | ||
273 | + return true; | ||
274 | +} | ||
275 | + | ||
276 | +/* | ||
277 | + * The naming scheme here is "vldrb_sg_sh == in-memory byte loads | ||
278 | + * signextended to halfword elements in register". _os_ indicates that | ||
279 | + * the offsets in Qm should be scaled by the element size. | ||
280 | + */ | ||
281 | +/* This macro is just to make the arrays more compact in these functions */ | ||
282 | +#define F(N) gen_helper_mve_##N | ||
283 | + | ||
284 | +/* VLDRB/VSTRB (ie msize 1) with OS=1 is UNPREDICTABLE; we UNDEF */ | ||
285 | +static bool trans_VLDR_S_sg(DisasContext *s, arg_vldst_sg *a) | ||
286 | +{ | ||
287 | + static MVEGenLdStSGFn * const fns[2][4][4] = { { | ||
288 | + { NULL, F(vldrb_sg_sh), F(vldrb_sg_sw), NULL }, | ||
289 | + { NULL, NULL, F(vldrh_sg_sw), NULL }, | ||
290 | + { NULL, NULL, NULL, NULL }, | ||
291 | + { NULL, NULL, NULL, NULL } | ||
292 | + }, { | ||
293 | + { NULL, NULL, NULL, NULL }, | ||
294 | + { NULL, NULL, F(vldrh_sg_os_sw), NULL }, | ||
295 | + { NULL, NULL, NULL, NULL }, | ||
296 | + { NULL, NULL, NULL, NULL } | ||
297 | + } | ||
298 | + }; | ||
299 | + if (a->qd == a->qm) { | ||
300 | + return false; /* UNPREDICTABLE */ | ||
301 | + } | ||
302 | + return do_ldst_sg(s, a, fns[a->os][a->msize][a->size]); | ||
303 | +} | ||
304 | + | ||
305 | +static bool trans_VLDR_U_sg(DisasContext *s, arg_vldst_sg *a) | ||
306 | +{ | ||
307 | + static MVEGenLdStSGFn * const fns[2][4][4] = { { | ||
308 | + { F(vldrb_sg_ub), F(vldrb_sg_uh), F(vldrb_sg_uw), NULL }, | ||
309 | + { NULL, F(vldrh_sg_uh), F(vldrh_sg_uw), NULL }, | ||
310 | + { NULL, NULL, F(vldrw_sg_uw), NULL }, | ||
311 | + { NULL, NULL, NULL, F(vldrd_sg_ud) } | ||
312 | + }, { | ||
313 | + { NULL, NULL, NULL, NULL }, | ||
314 | + { NULL, F(vldrh_sg_os_uh), F(vldrh_sg_os_uw), NULL }, | ||
315 | + { NULL, NULL, F(vldrw_sg_os_uw), NULL }, | ||
316 | + { NULL, NULL, NULL, F(vldrd_sg_os_ud) } | ||
317 | + } | ||
318 | + }; | ||
319 | + if (a->qd == a->qm) { | ||
320 | + return false; /* UNPREDICTABLE */ | ||
321 | + } | ||
322 | + return do_ldst_sg(s, a, fns[a->os][a->msize][a->size]); | ||
323 | +} | ||
324 | + | ||
325 | +static bool trans_VSTR_sg(DisasContext *s, arg_vldst_sg *a) | ||
326 | +{ | ||
327 | + static MVEGenLdStSGFn * const fns[2][4][4] = { { | ||
328 | + { F(vstrb_sg_ub), F(vstrb_sg_uh), F(vstrb_sg_uw), NULL }, | ||
329 | + { NULL, F(vstrh_sg_uh), F(vstrh_sg_uw), NULL }, | ||
330 | + { NULL, NULL, F(vstrw_sg_uw), NULL }, | ||
331 | + { NULL, NULL, NULL, F(vstrd_sg_ud) } | ||
332 | + }, { | ||
333 | + { NULL, NULL, NULL, NULL }, | ||
334 | + { NULL, F(vstrh_sg_os_uh), F(vstrh_sg_os_uw), NULL }, | ||
335 | + { NULL, NULL, F(vstrw_sg_os_uw), NULL }, | ||
336 | + { NULL, NULL, NULL, F(vstrd_sg_os_ud) } | ||
337 | + } | ||
338 | + }; | ||
339 | + return do_ldst_sg(s, a, fns[a->os][a->msize][a->size]); | ||
340 | +} | ||
341 | + | ||
342 | +#undef F | ||
343 | + | ||
344 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
345 | { | ||
346 | TCGv_ptr qd; | ||
53 | -- | 347 | -- |
54 | 2.20.1 | 348 | 2.20.1 |
55 | 349 | ||
56 | 350 | diff view generated by jsdifflib |
1 | The CCR is a register most of whose bits are banked between security | 1 | Implement the MVE VLDR/VSTR insns which do scatter-gather using base |
---|---|---|---|
2 | states but where BFHFNMIGN is not, and we keep it in the non-secure | 2 | addresses from Qm plus or minus an immediate offset (possibly with |
3 | entry of the v7m.ccr[] array. The logic which tries to handle this | 3 | writeback). Note that writeback is not predicated but it does have |
4 | bit fails to implement the "RAZ/WI from Nonsecure if AIRCR.BFHFNMINS | 4 | to honour ECI state, so we have to add an eci_mask check to the |
5 | is zero" requirement; correct the omission. | 5 | VSTR_SG macros (the VLDR_SG macros already needed this to be able |
6 | to distinguish "skip beat" from "set predicated element to 0"). | ||
6 | 7 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201210201433.26262-2-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | hw/intc/armv7m_nvic.c | 15 +++++++++++++++ | 11 | target/arm/helper-mve.h | 5 +++ |
12 | 1 file changed, 15 insertions(+) | 12 | target/arm/mve.decode | 10 +++++ |
13 | target/arm/mve_helper.c | 91 ++++++++++++++++++++++++-------------- | ||
14 | target/arm/translate-mve.c | 72 ++++++++++++++++++++++++++++++ | ||
15 | 4 files changed, 146 insertions(+), 32 deletions(-) | ||
13 | 16 | ||
14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/intc/armv7m_nvic.c | 19 | --- a/target/arm/helper-mve.h |
17 | +++ b/hw/intc/armv7m_nvic.c | 20 | +++ b/target/arm/helper-mve.h |
18 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
19 | */ | 22 | DEF_HELPER_FLAGS_4(mve_vstrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
20 | val = cpu->env.v7m.ccr[attrs.secure]; | 23 | DEF_HELPER_FLAGS_4(mve_vstrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; | 24 | |
22 | + /* BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0 */ | 25 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | + if (!attrs.secure) { | 26 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
24 | + if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | 27 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | + val &= ~R_V7M_CCR_BFHFNMIGN_MASK; | 28 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
26 | + } | 29 | + |
27 | + } | 30 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) |
28 | return val; | 31 | |
29 | case 0xd24: /* System Handler Control and State (SHCSR) */ | 32 | DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
30 | if (!arm_feature(&cpu->env, ARM_FEATURE_V7)) { | 33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
31 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | 34 | index XXXXXXX..XXXXXXX 100644 |
32 | (cpu->env.v7m.ccr[M_REG_NS] & ~R_V7M_CCR_BFHFNMIGN_MASK) | 35 | --- a/target/arm/mve.decode |
33 | | (value & R_V7M_CCR_BFHFNMIGN_MASK); | 36 | +++ b/target/arm/mve.decode |
34 | value &= ~R_V7M_CCR_BFHFNMIGN_MASK; | 37 | @@ -XXX,XX +XXX,XX @@ |
35 | + } else { | 38 | &vmaxv qm rda size |
36 | + /* | 39 | &vabav qn qm rda size |
37 | + * BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0, so | 40 | &vldst_sg qd qm rn size msize os |
38 | + * preserve the state currently in the NS element of the array | 41 | +&vldst_sg_imm qd qm a w imm |
39 | + */ | 42 | |
40 | + if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | 43 | # scatter-gather memory size is in bits 6:4 |
41 | + value &= ~R_V7M_CCR_BFHFNMIGN_MASK; | 44 | %sg_msize 6:1 4:1 |
42 | + value |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; | 45 | @@ -XXX,XX +XXX,XX @@ |
43 | + } | 46 | @vldst_sg .... .... .... rn:4 .... ... size:2 ... ... os:1 &vldst_sg \ |
44 | } | 47 | qd=%qd qm=%qm msize=%sg_msize |
45 | 48 | ||
46 | cpu->env.v7m.ccr[attrs.secure] = value; | 49 | +# Qm is in the fields usually labeled Qn |
50 | +@vldst_sg_imm .... .... a:1 . w:1 . .... .... .... . imm:7 &vldst_sg_imm \ | ||
51 | + qd=%qd qm=%qn | ||
52 | + | ||
53 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | ||
54 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | ||
55 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | ||
56 | @@ -XXX,XX +XXX,XX @@ VLDR_S_sg 111 0 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
57 | VLDR_U_sg 111 1 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
58 | VSTR_sg 111 0 1100 1 . 00 .... ... 0 111 . .... .... @vldst_sg | ||
59 | |||
60 | +VLDRW_sg_imm 111 1 1101 ... 1 ... 0 ... 1 1110 .... .... @vldst_sg_imm | ||
61 | +VLDRD_sg_imm 111 1 1101 ... 1 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
62 | +VSTRW_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1110 .... .... @vldst_sg_imm | ||
63 | +VSTRD_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
64 | + | ||
65 | # Moves between 2 32-bit vector lanes and 2 general purpose registers | ||
66 | VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
67 | VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
68 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/arm/mve_helper.c | ||
71 | +++ b/target/arm/mve_helper.c | ||
72 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
73 | * For loads, predicated lanes are zeroed instead of retaining | ||
74 | * their previous values. | ||
75 | */ | ||
76 | -#define DO_VLDR_SG(OP, LDTYPE, ESIZE, TYPE, OFFTYPE, ADDRFN) \ | ||
77 | +#define DO_VLDR_SG(OP, LDTYPE, ESIZE, TYPE, OFFTYPE, ADDRFN, WB) \ | ||
78 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
79 | uint32_t base) \ | ||
80 | { \ | ||
81 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
82 | addr = ADDRFN(base, m[H##ESIZE(e)]); \ | ||
83 | d[H##ESIZE(e)] = (mask & 1) ? \ | ||
84 | cpu_##LDTYPE##_data_ra(env, addr, GETPC()) : 0; \ | ||
85 | + if (WB) { \ | ||
86 | + m[H##ESIZE(e)] = addr; \ | ||
87 | + } \ | ||
88 | } \ | ||
89 | mve_advance_vpt(env); \ | ||
90 | } | ||
91 | |||
92 | /* We know here TYPE is unsigned so always the same as the offset type */ | ||
93 | -#define DO_VSTR_SG(OP, STTYPE, ESIZE, TYPE, ADDRFN) \ | ||
94 | +#define DO_VSTR_SG(OP, STTYPE, ESIZE, TYPE, ADDRFN, WB) \ | ||
95 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
96 | uint32_t base) \ | ||
97 | { \ | ||
98 | TYPE *d = vd; \ | ||
99 | TYPE *m = vm; \ | ||
100 | uint16_t mask = mve_element_mask(env); \ | ||
101 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
102 | unsigned e; \ | ||
103 | uint32_t addr; \ | ||
104 | - for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
105 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE, eci_mask >>= ESIZE) { \ | ||
106 | + if (!(eci_mask & 1)) { \ | ||
107 | + continue; \ | ||
108 | + } \ | ||
109 | addr = ADDRFN(base, m[H##ESIZE(e)]); \ | ||
110 | if (mask & 1) { \ | ||
111 | cpu_##STTYPE##_data_ra(env, addr, d[H##ESIZE(e)], GETPC()); \ | ||
112 | } \ | ||
113 | + if (WB) { \ | ||
114 | + m[H##ESIZE(e)] = addr; \ | ||
115 | + } \ | ||
116 | } \ | ||
117 | mve_advance_vpt(env); \ | ||
118 | } | ||
119 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
120 | * accesses, controlled by the predicate mask for the relevant beat, | ||
121 | * and with a single 32-bit offset in the first of the two Qm elements. | ||
122 | * Note that for QEMU our IMPDEF AIRCR.ENDIANNESS is always 0 (little). | ||
123 | + * Address writeback happens on the odd beats and updates the address | ||
124 | + * stored in the even-beat element. | ||
125 | */ | ||
126 | -#define DO_VLDR64_SG(OP, ADDRFN) \ | ||
127 | +#define DO_VLDR64_SG(OP, ADDRFN, WB) \ | ||
128 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
129 | uint32_t base) \ | ||
130 | { \ | ||
131 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
132 | addr = ADDRFN(base, m[H4(e & ~1)]); \ | ||
133 | addr += 4 * (e & 1); \ | ||
134 | d[H4(e)] = (mask & 1) ? cpu_ldl_data_ra(env, addr, GETPC()) : 0; \ | ||
135 | + if (WB && (e & 1)) { \ | ||
136 | + m[H4(e & ~1)] = addr - 4; \ | ||
137 | + } \ | ||
138 | } \ | ||
139 | mve_advance_vpt(env); \ | ||
140 | } | ||
141 | |||
142 | -#define DO_VSTR64_SG(OP, ADDRFN) \ | ||
143 | +#define DO_VSTR64_SG(OP, ADDRFN, WB) \ | ||
144 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
145 | uint32_t base) \ | ||
146 | { \ | ||
147 | uint32_t *d = vd; \ | ||
148 | uint32_t *m = vm; \ | ||
149 | uint16_t mask = mve_element_mask(env); \ | ||
150 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
151 | unsigned e; \ | ||
152 | uint32_t addr; \ | ||
153 | - for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
154 | + for (e = 0; e < 16 / 4; e++, mask >>= 4, eci_mask >>= 4) { \ | ||
155 | + if (!(eci_mask & 1)) { \ | ||
156 | + continue; \ | ||
157 | + } \ | ||
158 | addr = ADDRFN(base, m[H4(e & ~1)]); \ | ||
159 | addr += 4 * (e & 1); \ | ||
160 | if (mask & 1) { \ | ||
161 | cpu_stl_data_ra(env, addr, d[H4(e)], GETPC()); \ | ||
162 | } \ | ||
163 | + if (WB && (e & 1)) { \ | ||
164 | + m[H4(e & ~1)] = addr - 4; \ | ||
165 | + } \ | ||
166 | } \ | ||
167 | mve_advance_vpt(env); \ | ||
168 | } | ||
169 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
170 | #define ADDR_ADD_OSW(BASE, OFFSET) ((BASE) + ((OFFSET) << 2)) | ||
171 | #define ADDR_ADD_OSD(BASE, OFFSET) ((BASE) + ((OFFSET) << 3)) | ||
172 | |||
173 | -DO_VLDR_SG(vldrb_sg_sh, ldsb, 2, int16_t, uint16_t, ADDR_ADD) | ||
174 | -DO_VLDR_SG(vldrb_sg_sw, ldsb, 4, int32_t, uint32_t, ADDR_ADD) | ||
175 | -DO_VLDR_SG(vldrh_sg_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD) | ||
176 | +DO_VLDR_SG(vldrb_sg_sh, ldsb, 2, int16_t, uint16_t, ADDR_ADD, false) | ||
177 | +DO_VLDR_SG(vldrb_sg_sw, ldsb, 4, int32_t, uint32_t, ADDR_ADD, false) | ||
178 | +DO_VLDR_SG(vldrh_sg_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD, false) | ||
179 | |||
180 | -DO_VLDR_SG(vldrb_sg_ub, ldub, 1, uint8_t, uint8_t, ADDR_ADD) | ||
181 | -DO_VLDR_SG(vldrb_sg_uh, ldub, 2, uint16_t, uint16_t, ADDR_ADD) | ||
182 | -DO_VLDR_SG(vldrb_sg_uw, ldub, 4, uint32_t, uint32_t, ADDR_ADD) | ||
183 | -DO_VLDR_SG(vldrh_sg_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD) | ||
184 | -DO_VLDR_SG(vldrh_sg_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD) | ||
185 | -DO_VLDR_SG(vldrw_sg_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD) | ||
186 | -DO_VLDR64_SG(vldrd_sg_ud, ADDR_ADD) | ||
187 | +DO_VLDR_SG(vldrb_sg_ub, ldub, 1, uint8_t, uint8_t, ADDR_ADD, false) | ||
188 | +DO_VLDR_SG(vldrb_sg_uh, ldub, 2, uint16_t, uint16_t, ADDR_ADD, false) | ||
189 | +DO_VLDR_SG(vldrb_sg_uw, ldub, 4, uint32_t, uint32_t, ADDR_ADD, false) | ||
190 | +DO_VLDR_SG(vldrh_sg_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD, false) | ||
191 | +DO_VLDR_SG(vldrh_sg_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD, false) | ||
192 | +DO_VLDR_SG(vldrw_sg_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD, false) | ||
193 | +DO_VLDR64_SG(vldrd_sg_ud, ADDR_ADD, false) | ||
194 | |||
195 | -DO_VLDR_SG(vldrh_sg_os_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD_OSH) | ||
196 | -DO_VLDR_SG(vldrh_sg_os_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD_OSH) | ||
197 | -DO_VLDR_SG(vldrh_sg_os_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD_OSH) | ||
198 | -DO_VLDR_SG(vldrw_sg_os_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD_OSW) | ||
199 | -DO_VLDR64_SG(vldrd_sg_os_ud, ADDR_ADD_OSD) | ||
200 | +DO_VLDR_SG(vldrh_sg_os_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD_OSH, false) | ||
201 | +DO_VLDR_SG(vldrh_sg_os_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD_OSH, false) | ||
202 | +DO_VLDR_SG(vldrh_sg_os_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD_OSH, false) | ||
203 | +DO_VLDR_SG(vldrw_sg_os_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD_OSW, false) | ||
204 | +DO_VLDR64_SG(vldrd_sg_os_ud, ADDR_ADD_OSD, false) | ||
205 | |||
206 | -DO_VSTR_SG(vstrb_sg_ub, stb, 1, uint8_t, ADDR_ADD) | ||
207 | -DO_VSTR_SG(vstrb_sg_uh, stb, 2, uint16_t, ADDR_ADD) | ||
208 | -DO_VSTR_SG(vstrb_sg_uw, stb, 4, uint32_t, ADDR_ADD) | ||
209 | -DO_VSTR_SG(vstrh_sg_uh, stw, 2, uint16_t, ADDR_ADD) | ||
210 | -DO_VSTR_SG(vstrh_sg_uw, stw, 4, uint32_t, ADDR_ADD) | ||
211 | -DO_VSTR_SG(vstrw_sg_uw, stl, 4, uint32_t, ADDR_ADD) | ||
212 | -DO_VSTR64_SG(vstrd_sg_ud, ADDR_ADD) | ||
213 | +DO_VSTR_SG(vstrb_sg_ub, stb, 1, uint8_t, ADDR_ADD, false) | ||
214 | +DO_VSTR_SG(vstrb_sg_uh, stb, 2, uint16_t, ADDR_ADD, false) | ||
215 | +DO_VSTR_SG(vstrb_sg_uw, stb, 4, uint32_t, ADDR_ADD, false) | ||
216 | +DO_VSTR_SG(vstrh_sg_uh, stw, 2, uint16_t, ADDR_ADD, false) | ||
217 | +DO_VSTR_SG(vstrh_sg_uw, stw, 4, uint32_t, ADDR_ADD, false) | ||
218 | +DO_VSTR_SG(vstrw_sg_uw, stl, 4, uint32_t, ADDR_ADD, false) | ||
219 | +DO_VSTR64_SG(vstrd_sg_ud, ADDR_ADD, false) | ||
220 | |||
221 | -DO_VSTR_SG(vstrh_sg_os_uh, stw, 2, uint16_t, ADDR_ADD_OSH) | ||
222 | -DO_VSTR_SG(vstrh_sg_os_uw, stw, 4, uint32_t, ADDR_ADD_OSH) | ||
223 | -DO_VSTR_SG(vstrw_sg_os_uw, stl, 4, uint32_t, ADDR_ADD_OSW) | ||
224 | -DO_VSTR64_SG(vstrd_sg_os_ud, ADDR_ADD_OSD) | ||
225 | +DO_VSTR_SG(vstrh_sg_os_uh, stw, 2, uint16_t, ADDR_ADD_OSH, false) | ||
226 | +DO_VSTR_SG(vstrh_sg_os_uw, stw, 4, uint32_t, ADDR_ADD_OSH, false) | ||
227 | +DO_VSTR_SG(vstrw_sg_os_uw, stl, 4, uint32_t, ADDR_ADD_OSW, false) | ||
228 | +DO_VSTR64_SG(vstrd_sg_os_ud, ADDR_ADD_OSD, false) | ||
229 | + | ||
230 | +DO_VLDR_SG(vldrw_sg_wb_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD, true) | ||
231 | +DO_VLDR64_SG(vldrd_sg_wb_ud, ADDR_ADD, true) | ||
232 | +DO_VSTR_SG(vstrw_sg_wb_uw, stl, 4, uint32_t, ADDR_ADD, true) | ||
233 | +DO_VSTR64_SG(vstrd_sg_wb_ud, ADDR_ADD, true) | ||
234 | |||
235 | /* | ||
236 | * The mergemask(D, R, M) macro performs the operation "*D = R" but | ||
237 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
238 | index XXXXXXX..XXXXXXX 100644 | ||
239 | --- a/target/arm/translate-mve.c | ||
240 | +++ b/target/arm/translate-mve.c | ||
241 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSTR_sg(DisasContext *s, arg_vldst_sg *a) | ||
242 | |||
243 | #undef F | ||
244 | |||
245 | +static bool do_ldst_sg_imm(DisasContext *s, arg_vldst_sg_imm *a, | ||
246 | + MVEGenLdStSGFn *fn, unsigned msize) | ||
247 | +{ | ||
248 | + uint32_t offset; | ||
249 | + TCGv_ptr qd, qm; | ||
250 | + | ||
251 | + if (!dc_isar_feature(aa32_mve, s) || | ||
252 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | ||
253 | + !fn) { | ||
254 | + return false; | ||
255 | + } | ||
256 | + | ||
257 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
258 | + return true; | ||
259 | + } | ||
260 | + | ||
261 | + offset = a->imm << msize; | ||
262 | + if (!a->a) { | ||
263 | + offset = -offset; | ||
264 | + } | ||
265 | + | ||
266 | + qd = mve_qreg_ptr(a->qd); | ||
267 | + qm = mve_qreg_ptr(a->qm); | ||
268 | + fn(cpu_env, qd, qm, tcg_constant_i32(offset)); | ||
269 | + tcg_temp_free_ptr(qd); | ||
270 | + tcg_temp_free_ptr(qm); | ||
271 | + mve_update_eci(s); | ||
272 | + return true; | ||
273 | +} | ||
274 | + | ||
275 | +static bool trans_VLDRW_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
276 | +{ | ||
277 | + static MVEGenLdStSGFn * const fns[] = { | ||
278 | + gen_helper_mve_vldrw_sg_uw, | ||
279 | + gen_helper_mve_vldrw_sg_wb_uw, | ||
280 | + }; | ||
281 | + if (a->qd == a->qm) { | ||
282 | + return false; /* UNPREDICTABLE */ | ||
283 | + } | ||
284 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_32); | ||
285 | +} | ||
286 | + | ||
287 | +static bool trans_VLDRD_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
288 | +{ | ||
289 | + static MVEGenLdStSGFn * const fns[] = { | ||
290 | + gen_helper_mve_vldrd_sg_ud, | ||
291 | + gen_helper_mve_vldrd_sg_wb_ud, | ||
292 | + }; | ||
293 | + if (a->qd == a->qm) { | ||
294 | + return false; /* UNPREDICTABLE */ | ||
295 | + } | ||
296 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_64); | ||
297 | +} | ||
298 | + | ||
299 | +static bool trans_VSTRW_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
300 | +{ | ||
301 | + static MVEGenLdStSGFn * const fns[] = { | ||
302 | + gen_helper_mve_vstrw_sg_uw, | ||
303 | + gen_helper_mve_vstrw_sg_wb_uw, | ||
304 | + }; | ||
305 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_32); | ||
306 | +} | ||
307 | + | ||
308 | +static bool trans_VSTRD_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
309 | +{ | ||
310 | + static MVEGenLdStSGFn * const fns[] = { | ||
311 | + gen_helper_mve_vstrd_sg_ud, | ||
312 | + gen_helper_mve_vstrd_sg_wb_ud, | ||
313 | + }; | ||
314 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_64); | ||
315 | +} | ||
316 | + | ||
317 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
318 | { | ||
319 | TCGv_ptr qd; | ||
47 | -- | 320 | -- |
48 | 2.20.1 | 321 | 2.20.1 |
49 | 322 | ||
50 | 323 | diff view generated by jsdifflib |
1 | Now that we have implemented all the features needed by the v8.1M | 1 | Implement the MVE interleaving load/store functions VLD2, VLD4, VST2 |
---|---|---|---|
2 | architecture, we can add the model of the Cortex-M55. This is the | 2 | and VST4. VLD2 loads 16 bytes of data from memory and writes to 2 |
3 | configuration without MVE support; we'll add MVE later. | 3 | consecutive Qregs; VLD4 loads 16 bytes of data from memory and writes |
4 | to 4 consecutive Qregs. The 'pattern' field in the encoding | ||
5 | determines the offset into memory which is accessed and also which | ||
6 | elements in the Qregs are written to. (The intention is that a | ||
7 | sequence of four consecutive VLD4 with different pattern values | ||
8 | performs a complete de-interleaving load of 64 bytes into all | ||
9 | elements of the 4 Qregs.) VST2 and VST4 do the same, but for stores. | ||
4 | 10 | ||
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: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201210201433.26262-5-peter.maydell@linaro.org | ||
8 | --- | 13 | --- |
9 | target/arm/cpu_tcg.c | 42 ++++++++++++++++++++++++++++++++++++++++++ | 14 | target/arm/helper-mve.h | 48 ++++++ |
10 | 1 file changed, 42 insertions(+) | 15 | target/arm/mve.decode | 11 ++ |
16 | target/arm/mve_helper.c | 342 +++++++++++++++++++++++++++++++++++++ | ||
17 | target/arm/translate-mve.c | 94 ++++++++++ | ||
18 | 4 files changed, 495 insertions(+) | ||
11 | 19 | ||
12 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 20 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
13 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/cpu_tcg.c | 22 | --- a/target/arm/helper-mve.h |
15 | +++ b/target/arm/cpu_tcg.c | 23 | +++ b/target/arm/helper-mve.h |
16 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) | 24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vldrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
17 | cpu->ctr = 0x8000c000; | 25 | DEF_HELPER_FLAGS_4(mve_vstrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
26 | DEF_HELPER_FLAGS_4(mve_vstrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | |||
28 | +DEF_HELPER_FLAGS_3(mve_vld20b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vld20h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vld20w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
31 | + | ||
32 | +DEF_HELPER_FLAGS_3(mve_vld21b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
33 | +DEF_HELPER_FLAGS_3(mve_vld21h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vld21w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
35 | + | ||
36 | +DEF_HELPER_FLAGS_3(mve_vld40b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
37 | +DEF_HELPER_FLAGS_3(mve_vld40h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
38 | +DEF_HELPER_FLAGS_3(mve_vld40w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
39 | + | ||
40 | +DEF_HELPER_FLAGS_3(mve_vld41b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vld41h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
42 | +DEF_HELPER_FLAGS_3(mve_vld41w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
43 | + | ||
44 | +DEF_HELPER_FLAGS_3(mve_vld42b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
45 | +DEF_HELPER_FLAGS_3(mve_vld42h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
46 | +DEF_HELPER_FLAGS_3(mve_vld42w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
47 | + | ||
48 | +DEF_HELPER_FLAGS_3(mve_vld43b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
49 | +DEF_HELPER_FLAGS_3(mve_vld43h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
50 | +DEF_HELPER_FLAGS_3(mve_vld43w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
51 | + | ||
52 | +DEF_HELPER_FLAGS_3(mve_vst20b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
53 | +DEF_HELPER_FLAGS_3(mve_vst20h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
54 | +DEF_HELPER_FLAGS_3(mve_vst20w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
55 | + | ||
56 | +DEF_HELPER_FLAGS_3(mve_vst21b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
57 | +DEF_HELPER_FLAGS_3(mve_vst21h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
58 | +DEF_HELPER_FLAGS_3(mve_vst21w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
59 | + | ||
60 | +DEF_HELPER_FLAGS_3(mve_vst40b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
61 | +DEF_HELPER_FLAGS_3(mve_vst40h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
62 | +DEF_HELPER_FLAGS_3(mve_vst40w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
63 | + | ||
64 | +DEF_HELPER_FLAGS_3(mve_vst41b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
65 | +DEF_HELPER_FLAGS_3(mve_vst41h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
66 | +DEF_HELPER_FLAGS_3(mve_vst41w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
67 | + | ||
68 | +DEF_HELPER_FLAGS_3(mve_vst42b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
69 | +DEF_HELPER_FLAGS_3(mve_vst42h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
70 | +DEF_HELPER_FLAGS_3(mve_vst42w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
71 | + | ||
72 | +DEF_HELPER_FLAGS_3(mve_vst43b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
73 | +DEF_HELPER_FLAGS_3(mve_vst43h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
74 | +DEF_HELPER_FLAGS_3(mve_vst43w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
75 | + | ||
76 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
77 | |||
78 | DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
79 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/target/arm/mve.decode | ||
82 | +++ b/target/arm/mve.decode | ||
83 | @@ -XXX,XX +XXX,XX @@ | ||
84 | &vabav qn qm rda size | ||
85 | &vldst_sg qd qm rn size msize os | ||
86 | &vldst_sg_imm qd qm a w imm | ||
87 | +&vldst_il qd rn size pat w | ||
88 | |||
89 | # scatter-gather memory size is in bits 6:4 | ||
90 | %sg_msize 6:1 4:1 | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | @vldst_sg_imm .... .... a:1 . w:1 . .... .... .... . imm:7 &vldst_sg_imm \ | ||
93 | qd=%qd qm=%qn | ||
94 | |||
95 | +# Deinterleaving load/interleaving store | ||
96 | +@vldst_il .... .... .. w:1 . rn:4 .... ... size:2 pat:2 ..... &vldst_il \ | ||
97 | + qd=%qd | ||
98 | + | ||
99 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | ||
100 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | ||
101 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | ||
102 | @@ -XXX,XX +XXX,XX @@ VLDRD_sg_imm 111 1 1101 ... 1 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
103 | VSTRW_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1110 .... .... @vldst_sg_imm | ||
104 | VSTRD_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
105 | |||
106 | +# deinterleaving loads/interleaving stores | ||
107 | +VLD2 1111 1100 1 .. 1 .... ... 1 111 .. .. 00000 @vldst_il | ||
108 | +VLD4 1111 1100 1 .. 1 .... ... 1 111 .. .. 00001 @vldst_il | ||
109 | +VST2 1111 1100 1 .. 0 .... ... 1 111 .. .. 00000 @vldst_il | ||
110 | +VST4 1111 1100 1 .. 0 .... ... 1 111 .. .. 00001 @vldst_il | ||
111 | + | ||
112 | # Moves between 2 32-bit vector lanes and 2 general purpose registers | ||
113 | VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
114 | VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
115 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
116 | index XXXXXXX..XXXXXXX 100644 | ||
117 | --- a/target/arm/mve_helper.c | ||
118 | +++ b/target/arm/mve_helper.c | ||
119 | @@ -XXX,XX +XXX,XX @@ DO_VLDR64_SG(vldrd_sg_wb_ud, ADDR_ADD, true) | ||
120 | DO_VSTR_SG(vstrw_sg_wb_uw, stl, 4, uint32_t, ADDR_ADD, true) | ||
121 | DO_VSTR64_SG(vstrd_sg_wb_ud, ADDR_ADD, true) | ||
122 | |||
123 | +/* | ||
124 | + * Deinterleaving loads/interleaving stores. | ||
125 | + * | ||
126 | + * For these helpers we are passed the index of the first Qreg | ||
127 | + * (VLD2/VST2 will also access Qn+1, VLD4/VST4 access Qn .. Qn+3) | ||
128 | + * and the value of the base address register Rn. | ||
129 | + * The helpers are specialized for pattern and element size, so | ||
130 | + * for instance vld42h is VLD4 with pattern 2, element size MO_16. | ||
131 | + * | ||
132 | + * These insns are beatwise but not predicated, so we must honour ECI, | ||
133 | + * but need not look at mve_element_mask(). | ||
134 | + * | ||
135 | + * The pseudocode implements these insns with multiple memory accesses | ||
136 | + * of the element size, but rules R_VVVG and R_FXDM permit us to make | ||
137 | + * one 32-bit memory access per beat. | ||
138 | + */ | ||
139 | +#define DO_VLD4B(OP, O1, O2, O3, O4) \ | ||
140 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
141 | + uint32_t base) \ | ||
142 | + { \ | ||
143 | + int beat, e; \ | ||
144 | + uint16_t mask = mve_eci_mask(env); \ | ||
145 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
146 | + uint32_t addr, data; \ | ||
147 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
148 | + if ((mask & 1) == 0) { \ | ||
149 | + /* ECI says skip this beat */ \ | ||
150 | + continue; \ | ||
151 | + } \ | ||
152 | + addr = base + off[beat] * 4; \ | ||
153 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
154 | + for (e = 0; e < 4; e++, data >>= 8) { \ | ||
155 | + uint8_t *qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
156 | + qd[H1(off[beat])] = data; \ | ||
157 | + } \ | ||
158 | + } \ | ||
159 | + } | ||
160 | + | ||
161 | +#define DO_VLD4H(OP, O1, O2) \ | ||
162 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
163 | + uint32_t base) \ | ||
164 | + { \ | ||
165 | + int beat; \ | ||
166 | + uint16_t mask = mve_eci_mask(env); \ | ||
167 | + static const uint8_t off[4] = { O1, O1, O2, O2 }; \ | ||
168 | + uint32_t addr, data; \ | ||
169 | + int y; /* y counts 0 2 0 2 */ \ | ||
170 | + uint16_t *qd; \ | ||
171 | + for (beat = 0, y = 0; beat < 4; beat++, mask >>= 4, y ^= 2) { \ | ||
172 | + if ((mask & 1) == 0) { \ | ||
173 | + /* ECI says skip this beat */ \ | ||
174 | + continue; \ | ||
175 | + } \ | ||
176 | + addr = base + off[beat] * 8 + (beat & 1) * 4; \ | ||
177 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
178 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
179 | + qd[H2(off[beat])] = data; \ | ||
180 | + data >>= 16; \ | ||
181 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y + 1); \ | ||
182 | + qd[H2(off[beat])] = data; \ | ||
183 | + } \ | ||
184 | + } | ||
185 | + | ||
186 | +#define DO_VLD4W(OP, O1, O2, O3, O4) \ | ||
187 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
188 | + uint32_t base) \ | ||
189 | + { \ | ||
190 | + int beat; \ | ||
191 | + uint16_t mask = mve_eci_mask(env); \ | ||
192 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
193 | + uint32_t addr, data; \ | ||
194 | + uint32_t *qd; \ | ||
195 | + int y; \ | ||
196 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
197 | + if ((mask & 1) == 0) { \ | ||
198 | + /* ECI says skip this beat */ \ | ||
199 | + continue; \ | ||
200 | + } \ | ||
201 | + addr = base + off[beat] * 4; \ | ||
202 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
203 | + y = (beat + (O1 & 2)) & 3; \ | ||
204 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
205 | + qd[H4(off[beat] >> 2)] = data; \ | ||
206 | + } \ | ||
207 | + } | ||
208 | + | ||
209 | +DO_VLD4B(vld40b, 0, 1, 10, 11) | ||
210 | +DO_VLD4B(vld41b, 2, 3, 12, 13) | ||
211 | +DO_VLD4B(vld42b, 4, 5, 14, 15) | ||
212 | +DO_VLD4B(vld43b, 6, 7, 8, 9) | ||
213 | + | ||
214 | +DO_VLD4H(vld40h, 0, 5) | ||
215 | +DO_VLD4H(vld41h, 1, 6) | ||
216 | +DO_VLD4H(vld42h, 2, 7) | ||
217 | +DO_VLD4H(vld43h, 3, 4) | ||
218 | + | ||
219 | +DO_VLD4W(vld40w, 0, 1, 10, 11) | ||
220 | +DO_VLD4W(vld41w, 2, 3, 12, 13) | ||
221 | +DO_VLD4W(vld42w, 4, 5, 14, 15) | ||
222 | +DO_VLD4W(vld43w, 6, 7, 8, 9) | ||
223 | + | ||
224 | +#define DO_VLD2B(OP, O1, O2, O3, O4) \ | ||
225 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
226 | + uint32_t base) \ | ||
227 | + { \ | ||
228 | + int beat, e; \ | ||
229 | + uint16_t mask = mve_eci_mask(env); \ | ||
230 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
231 | + uint32_t addr, data; \ | ||
232 | + uint8_t *qd; \ | ||
233 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
234 | + if ((mask & 1) == 0) { \ | ||
235 | + /* ECI says skip this beat */ \ | ||
236 | + continue; \ | ||
237 | + } \ | ||
238 | + addr = base + off[beat] * 2; \ | ||
239 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
240 | + for (e = 0; e < 4; e++, data >>= 8) { \ | ||
241 | + qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + (e & 1)); \ | ||
242 | + qd[H1(off[beat] + (e >> 1))] = data; \ | ||
243 | + } \ | ||
244 | + } \ | ||
245 | + } | ||
246 | + | ||
247 | +#define DO_VLD2H(OP, O1, O2, O3, O4) \ | ||
248 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
249 | + uint32_t base) \ | ||
250 | + { \ | ||
251 | + int beat; \ | ||
252 | + uint16_t mask = mve_eci_mask(env); \ | ||
253 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
254 | + uint32_t addr, data; \ | ||
255 | + int e; \ | ||
256 | + uint16_t *qd; \ | ||
257 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
258 | + if ((mask & 1) == 0) { \ | ||
259 | + /* ECI says skip this beat */ \ | ||
260 | + continue; \ | ||
261 | + } \ | ||
262 | + addr = base + off[beat] * 4; \ | ||
263 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
264 | + for (e = 0; e < 2; e++, data >>= 16) { \ | ||
265 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
266 | + qd[H2(off[beat])] = data; \ | ||
267 | + } \ | ||
268 | + } \ | ||
269 | + } | ||
270 | + | ||
271 | +#define DO_VLD2W(OP, O1, O2, O3, O4) \ | ||
272 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
273 | + uint32_t base) \ | ||
274 | + { \ | ||
275 | + int beat; \ | ||
276 | + uint16_t mask = mve_eci_mask(env); \ | ||
277 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
278 | + uint32_t addr, data; \ | ||
279 | + uint32_t *qd; \ | ||
280 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
281 | + if ((mask & 1) == 0) { \ | ||
282 | + /* ECI says skip this beat */ \ | ||
283 | + continue; \ | ||
284 | + } \ | ||
285 | + addr = base + off[beat]; \ | ||
286 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
287 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + (beat & 1)); \ | ||
288 | + qd[H4(off[beat] >> 3)] = data; \ | ||
289 | + } \ | ||
290 | + } | ||
291 | + | ||
292 | +DO_VLD2B(vld20b, 0, 2, 12, 14) | ||
293 | +DO_VLD2B(vld21b, 4, 6, 8, 10) | ||
294 | + | ||
295 | +DO_VLD2H(vld20h, 0, 1, 6, 7) | ||
296 | +DO_VLD2H(vld21h, 2, 3, 4, 5) | ||
297 | + | ||
298 | +DO_VLD2W(vld20w, 0, 4, 24, 28) | ||
299 | +DO_VLD2W(vld21w, 8, 12, 16, 20) | ||
300 | + | ||
301 | +#define DO_VST4B(OP, O1, O2, O3, O4) \ | ||
302 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
303 | + uint32_t base) \ | ||
304 | + { \ | ||
305 | + int beat, e; \ | ||
306 | + uint16_t mask = mve_eci_mask(env); \ | ||
307 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
308 | + uint32_t addr, data; \ | ||
309 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
310 | + if ((mask & 1) == 0) { \ | ||
311 | + /* ECI says skip this beat */ \ | ||
312 | + continue; \ | ||
313 | + } \ | ||
314 | + addr = base + off[beat] * 4; \ | ||
315 | + data = 0; \ | ||
316 | + for (e = 3; e >= 0; e--) { \ | ||
317 | + uint8_t *qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
318 | + data = (data << 8) | qd[H1(off[beat])]; \ | ||
319 | + } \ | ||
320 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
321 | + } \ | ||
322 | + } | ||
323 | + | ||
324 | +#define DO_VST4H(OP, O1, O2) \ | ||
325 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
326 | + uint32_t base) \ | ||
327 | + { \ | ||
328 | + int beat; \ | ||
329 | + uint16_t mask = mve_eci_mask(env); \ | ||
330 | + static const uint8_t off[4] = { O1, O1, O2, O2 }; \ | ||
331 | + uint32_t addr, data; \ | ||
332 | + int y; /* y counts 0 2 0 2 */ \ | ||
333 | + uint16_t *qd; \ | ||
334 | + for (beat = 0, y = 0; beat < 4; beat++, mask >>= 4, y ^= 2) { \ | ||
335 | + if ((mask & 1) == 0) { \ | ||
336 | + /* ECI says skip this beat */ \ | ||
337 | + continue; \ | ||
338 | + } \ | ||
339 | + addr = base + off[beat] * 8 + (beat & 1) * 4; \ | ||
340 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
341 | + data = qd[H2(off[beat])]; \ | ||
342 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y + 1); \ | ||
343 | + data |= qd[H2(off[beat])] << 16; \ | ||
344 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
345 | + } \ | ||
346 | + } | ||
347 | + | ||
348 | +#define DO_VST4W(OP, O1, O2, O3, O4) \ | ||
349 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
350 | + uint32_t base) \ | ||
351 | + { \ | ||
352 | + int beat; \ | ||
353 | + uint16_t mask = mve_eci_mask(env); \ | ||
354 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
355 | + uint32_t addr, data; \ | ||
356 | + uint32_t *qd; \ | ||
357 | + int y; \ | ||
358 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
359 | + if ((mask & 1) == 0) { \ | ||
360 | + /* ECI says skip this beat */ \ | ||
361 | + continue; \ | ||
362 | + } \ | ||
363 | + addr = base + off[beat] * 4; \ | ||
364 | + y = (beat + (O1 & 2)) & 3; \ | ||
365 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
366 | + data = qd[H4(off[beat] >> 2)]; \ | ||
367 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
368 | + } \ | ||
369 | + } | ||
370 | + | ||
371 | +DO_VST4B(vst40b, 0, 1, 10, 11) | ||
372 | +DO_VST4B(vst41b, 2, 3, 12, 13) | ||
373 | +DO_VST4B(vst42b, 4, 5, 14, 15) | ||
374 | +DO_VST4B(vst43b, 6, 7, 8, 9) | ||
375 | + | ||
376 | +DO_VST4H(vst40h, 0, 5) | ||
377 | +DO_VST4H(vst41h, 1, 6) | ||
378 | +DO_VST4H(vst42h, 2, 7) | ||
379 | +DO_VST4H(vst43h, 3, 4) | ||
380 | + | ||
381 | +DO_VST4W(vst40w, 0, 1, 10, 11) | ||
382 | +DO_VST4W(vst41w, 2, 3, 12, 13) | ||
383 | +DO_VST4W(vst42w, 4, 5, 14, 15) | ||
384 | +DO_VST4W(vst43w, 6, 7, 8, 9) | ||
385 | + | ||
386 | +#define DO_VST2B(OP, O1, O2, O3, O4) \ | ||
387 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
388 | + uint32_t base) \ | ||
389 | + { \ | ||
390 | + int beat, e; \ | ||
391 | + uint16_t mask = mve_eci_mask(env); \ | ||
392 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
393 | + uint32_t addr, data; \ | ||
394 | + uint8_t *qd; \ | ||
395 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
396 | + if ((mask & 1) == 0) { \ | ||
397 | + /* ECI says skip this beat */ \ | ||
398 | + continue; \ | ||
399 | + } \ | ||
400 | + addr = base + off[beat] * 2; \ | ||
401 | + data = 0; \ | ||
402 | + for (e = 3; e >= 0; e--) { \ | ||
403 | + qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + (e & 1)); \ | ||
404 | + data = (data << 8) | qd[H1(off[beat] + (e >> 1))]; \ | ||
405 | + } \ | ||
406 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
407 | + } \ | ||
408 | + } | ||
409 | + | ||
410 | +#define DO_VST2H(OP, O1, O2, O3, O4) \ | ||
411 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
412 | + uint32_t base) \ | ||
413 | + { \ | ||
414 | + int beat; \ | ||
415 | + uint16_t mask = mve_eci_mask(env); \ | ||
416 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
417 | + uint32_t addr, data; \ | ||
418 | + int e; \ | ||
419 | + uint16_t *qd; \ | ||
420 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
421 | + if ((mask & 1) == 0) { \ | ||
422 | + /* ECI says skip this beat */ \ | ||
423 | + continue; \ | ||
424 | + } \ | ||
425 | + addr = base + off[beat] * 4; \ | ||
426 | + data = 0; \ | ||
427 | + for (e = 1; e >= 0; e--) { \ | ||
428 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
429 | + data = (data << 16) | qd[H2(off[beat])]; \ | ||
430 | + } \ | ||
431 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
432 | + } \ | ||
433 | + } | ||
434 | + | ||
435 | +#define DO_VST2W(OP, O1, O2, O3, O4) \ | ||
436 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
437 | + uint32_t base) \ | ||
438 | + { \ | ||
439 | + int beat; \ | ||
440 | + uint16_t mask = mve_eci_mask(env); \ | ||
441 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
442 | + uint32_t addr, data; \ | ||
443 | + uint32_t *qd; \ | ||
444 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
445 | + if ((mask & 1) == 0) { \ | ||
446 | + /* ECI says skip this beat */ \ | ||
447 | + continue; \ | ||
448 | + } \ | ||
449 | + addr = base + off[beat]; \ | ||
450 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + (beat & 1)); \ | ||
451 | + data = qd[H4(off[beat] >> 3)]; \ | ||
452 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
453 | + } \ | ||
454 | + } | ||
455 | + | ||
456 | +DO_VST2B(vst20b, 0, 2, 12, 14) | ||
457 | +DO_VST2B(vst21b, 4, 6, 8, 10) | ||
458 | + | ||
459 | +DO_VST2H(vst20h, 0, 1, 6, 7) | ||
460 | +DO_VST2H(vst21h, 2, 3, 4, 5) | ||
461 | + | ||
462 | +DO_VST2W(vst20w, 0, 4, 24, 28) | ||
463 | +DO_VST2W(vst21w, 8, 12, 16, 20) | ||
464 | + | ||
465 | /* | ||
466 | * The mergemask(D, R, M) macro performs the operation "*D = R" but | ||
467 | * storing only the bytes which correspond to 1 bits in M, | ||
468 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
469 | index XXXXXXX..XXXXXXX 100644 | ||
470 | --- a/target/arm/translate-mve.c | ||
471 | +++ b/target/arm/translate-mve.c | ||
472 | @@ -XXX,XX +XXX,XX @@ static inline int vidup_imm(DisasContext *s, int x) | ||
473 | |||
474 | typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
475 | typedef void MVEGenLdStSGFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
476 | +typedef void MVEGenLdStIlFn(TCGv_ptr, TCGv_i32, TCGv_i32); | ||
477 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
478 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
479 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
480 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSTRD_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
481 | return do_ldst_sg_imm(s, a, fns[a->w], MO_64); | ||
18 | } | 482 | } |
19 | 483 | ||
20 | +static void cortex_m55_initfn(Object *obj) | 484 | +static bool do_vldst_il(DisasContext *s, arg_vldst_il *a, MVEGenLdStIlFn *fn, |
485 | + int addrinc) | ||
21 | +{ | 486 | +{ |
22 | + ARMCPU *cpu = ARM_CPU(obj); | 487 | + TCGv_i32 rn; |
23 | + | 488 | + |
24 | + set_feature(&cpu->env, ARM_FEATURE_V8); | 489 | + if (!dc_isar_feature(aa32_mve, s) || |
25 | + set_feature(&cpu->env, ARM_FEATURE_V8_1M); | 490 | + !mve_check_qreg_bank(s, a->qd) || |
26 | + set_feature(&cpu->env, ARM_FEATURE_M); | 491 | + !fn || (a->rn == 13 && a->w) || a->rn == 15) { |
27 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | 492 | + /* Variously UNPREDICTABLE or UNDEF or related-encoding */ |
28 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | 493 | + return false; |
29 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | 494 | + } |
30 | + cpu->midr = 0x410fd221; /* r0p1 */ | 495 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
31 | + cpu->revidr = 0; | 496 | + return true; |
32 | + cpu->pmsav7_dregion = 16; | 497 | + } |
33 | + cpu->sau_sregion = 8; | 498 | + |
499 | + rn = load_reg(s, a->rn); | ||
34 | + /* | 500 | + /* |
35 | + * These are the MVFR* values for the FPU, no MVE configuration; | 501 | + * We pass the index of Qd, not a pointer, because the helper must |
36 | + * we will update them later when we implement MVE | 502 | + * access multiple Q registers starting at Qd and working up. |
37 | + */ | 503 | + */ |
38 | + cpu->isar.mvfr0 = 0x10110221; | 504 | + fn(cpu_env, tcg_constant_i32(a->qd), rn); |
39 | + cpu->isar.mvfr1 = 0x12100011; | 505 | + |
40 | + cpu->isar.mvfr2 = 0x00000040; | 506 | + if (a->w) { |
41 | + cpu->isar.id_pfr0 = 0x20000030; | 507 | + tcg_gen_addi_i32(rn, rn, addrinc); |
42 | + cpu->isar.id_pfr1 = 0x00000230; | 508 | + store_reg(s, a->rn, rn); |
43 | + cpu->isar.id_dfr0 = 0x10200000; | 509 | + } else { |
44 | + cpu->id_afr0 = 0x00000000; | 510 | + tcg_temp_free_i32(rn); |
45 | + cpu->isar.id_mmfr0 = 0x00111040; | 511 | + } |
46 | + cpu->isar.id_mmfr1 = 0x00000000; | 512 | + mve_update_and_store_eci(s); |
47 | + cpu->isar.id_mmfr2 = 0x01000000; | 513 | + return true; |
48 | + cpu->isar.id_mmfr3 = 0x00000011; | ||
49 | + cpu->isar.id_isar0 = 0x01103110; | ||
50 | + cpu->isar.id_isar1 = 0x02212000; | ||
51 | + cpu->isar.id_isar2 = 0x20232232; | ||
52 | + cpu->isar.id_isar3 = 0x01111131; | ||
53 | + cpu->isar.id_isar4 = 0x01310132; | ||
54 | + cpu->isar.id_isar5 = 0x00000000; | ||
55 | + cpu->isar.id_isar6 = 0x00000000; | ||
56 | + cpu->clidr = 0x00000000; /* caches not implemented */ | ||
57 | + cpu->ctr = 0x8303c003; | ||
58 | +} | 514 | +} |
59 | + | 515 | + |
60 | static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | 516 | +/* This macro is just to make the arrays more compact in these functions */ |
61 | /* Dummy the TCM region regs for the moment */ | 517 | +#define F(N) gen_helper_mve_##N |
62 | { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, | 518 | + |
63 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { | 519 | +static bool trans_VLD2(DisasContext *s, arg_vldst_il *a) |
64 | .class_init = arm_v7m_class_init }, | 520 | +{ |
65 | { .name = "cortex-m33", .initfn = cortex_m33_initfn, | 521 | + static MVEGenLdStIlFn * const fns[4][4] = { |
66 | .class_init = arm_v7m_class_init }, | 522 | + { F(vld20b), F(vld20h), F(vld20w), NULL, }, |
67 | + { .name = "cortex-m55", .initfn = cortex_m55_initfn, | 523 | + { F(vld21b), F(vld21h), F(vld21w), NULL, }, |
68 | + .class_init = arm_v7m_class_init }, | 524 | + { NULL, NULL, NULL, NULL }, |
69 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, | 525 | + { NULL, NULL, NULL, NULL }, |
70 | { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, | 526 | + }; |
71 | { .name = "ti925t", .initfn = ti925t_initfn }, | 527 | + if (a->qd > 6) { |
528 | + return false; | ||
529 | + } | ||
530 | + return do_vldst_il(s, a, fns[a->pat][a->size], 32); | ||
531 | +} | ||
532 | + | ||
533 | +static bool trans_VLD4(DisasContext *s, arg_vldst_il *a) | ||
534 | +{ | ||
535 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
536 | + { F(vld40b), F(vld40h), F(vld40w), NULL, }, | ||
537 | + { F(vld41b), F(vld41h), F(vld41w), NULL, }, | ||
538 | + { F(vld42b), F(vld42h), F(vld42w), NULL, }, | ||
539 | + { F(vld43b), F(vld43h), F(vld43w), NULL, }, | ||
540 | + }; | ||
541 | + if (a->qd > 4) { | ||
542 | + return false; | ||
543 | + } | ||
544 | + return do_vldst_il(s, a, fns[a->pat][a->size], 64); | ||
545 | +} | ||
546 | + | ||
547 | +static bool trans_VST2(DisasContext *s, arg_vldst_il *a) | ||
548 | +{ | ||
549 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
550 | + { F(vst20b), F(vst20h), F(vst20w), NULL, }, | ||
551 | + { F(vst21b), F(vst21h), F(vst21w), NULL, }, | ||
552 | + { NULL, NULL, NULL, NULL }, | ||
553 | + { NULL, NULL, NULL, NULL }, | ||
554 | + }; | ||
555 | + if (a->qd > 6) { | ||
556 | + return false; | ||
557 | + } | ||
558 | + return do_vldst_il(s, a, fns[a->pat][a->size], 32); | ||
559 | +} | ||
560 | + | ||
561 | +static bool trans_VST4(DisasContext *s, arg_vldst_il *a) | ||
562 | +{ | ||
563 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
564 | + { F(vst40b), F(vst40h), F(vst40w), NULL, }, | ||
565 | + { F(vst41b), F(vst41h), F(vst41w), NULL, }, | ||
566 | + { F(vst42b), F(vst42h), F(vst42w), NULL, }, | ||
567 | + { F(vst43b), F(vst43h), F(vst43w), NULL, }, | ||
568 | + }; | ||
569 | + if (a->qd > 4) { | ||
570 | + return false; | ||
571 | + } | ||
572 | + return do_vldst_il(s, a, fns[a->pat][a->size], 64); | ||
573 | +} | ||
574 | + | ||
575 | +#undef F | ||
576 | + | ||
577 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
578 | { | ||
579 | TCGv_ptr qd; | ||
72 | -- | 580 | -- |
73 | 2.20.1 | 581 | 2.20.1 |
74 | 582 | ||
75 | 583 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | We're about to make a code change to the sdiv and udiv helper |
---|---|---|---|
2 | functions, so first fix their indentation and coding style. | ||
2 | 3 | ||
3 | In 50244cc76abc we updated mte_check_fail to match the ARM | ||
4 | pseudocode, using the correct EL to select the TCF field. | ||
5 | But we failed to update MTE0_ACTIVE the same way, which led | ||
6 | to g_assert_not_reached(). | ||
7 | |||
8 | Cc: qemu-stable@nongnu.org | ||
9 | Buglink: https://bugs.launchpad.net/bugs/1907137 | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20201221204426.88514-1-richard.henderson@linaro.org | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210730151636.17254-2-peter.maydell@linaro.org | ||
14 | --- | 7 | --- |
15 | target/arm/helper.c | 2 +- | 8 | target/arm/helper.c | 15 +++++++++------ |
16 | 1 file changed, 1 insertion(+), 1 deletion(-) | 9 | 1 file changed, 9 insertions(+), 6 deletions(-) |
17 | 10 | ||
18 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 11 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper.c | 13 | --- a/target/arm/helper.c |
21 | +++ b/target/arm/helper.c | 14 | +++ b/target/arm/helper.c |
22 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | 15 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(uxtb16)(uint32_t x) |
23 | if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV) | 16 | |
24 | && tbid | 17 | int32_t HELPER(sdiv)(int32_t num, int32_t den) |
25 | && !(env->pstate & PSTATE_TCO) | 18 | { |
26 | - && (sctlr & SCTLR_TCF0) | 19 | - if (den == 0) |
27 | + && (sctlr & SCTLR_TCF) | 20 | - return 0; |
28 | && allocation_tag_access_enabled(env, 0, sctlr)) { | 21 | - if (num == INT_MIN && den == -1) |
29 | flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1); | 22 | - return INT_MIN; |
30 | } | 23 | + if (den == 0) { |
24 | + return 0; | ||
25 | + } | ||
26 | + if (num == INT_MIN && den == -1) { | ||
27 | + return INT_MIN; | ||
28 | + } | ||
29 | return num / den; | ||
30 | } | ||
31 | |||
32 | uint32_t HELPER(udiv)(uint32_t num, uint32_t den) | ||
33 | { | ||
34 | - if (den == 0) | ||
35 | - return 0; | ||
36 | + if (den == 0) { | ||
37 | + return 0; | ||
38 | + } | ||
39 | return num / den; | ||
40 | } | ||
41 | |||
31 | -- | 42 | -- |
32 | 2.20.1 | 43 | 2.20.1 |
33 | 44 | ||
34 | 45 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | Unlike A-profile, for M-profile the UDIV and SDIV insns can be |
---|---|---|---|
2 | configured to raise an exception on division by zero, using the CCR | ||
3 | DIV_0_TRP bit. | ||
2 | 4 | ||
3 | When running device-introspect-test, a memory leak occurred in the | 5 | Implement support for setting this bit by making the helper functions |
4 | mss_timer_init function, so use ptimer_free() in the finalize function to avoid | 6 | raise the appropriate exception. |
5 | it. | ||
6 | 7 | ||
7 | ASAN shows memory leak stack: | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210730151636.17254-3-peter.maydell@linaro.org | ||
11 | --- | ||
12 | target/arm/cpu.h | 1 + | ||
13 | target/arm/helper.h | 4 ++-- | ||
14 | target/arm/helper.c | 19 +++++++++++++++++-- | ||
15 | target/arm/m_helper.c | 4 ++++ | ||
16 | target/arm/translate.c | 4 ++-- | ||
17 | 5 files changed, 26 insertions(+), 6 deletions(-) | ||
8 | 18 | ||
9 | Indirect leak of 192 byte(s) in 2 object(s) allocated from: | 19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf58a0010 in mss_timer_init /qemu/hw/timer/mss-timer.c:235 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564 | ||
16 | #6 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547 | ||
17 | #7 0xaaabf5b8316c in m2sxxx_soc_initfn /qemu/hw/arm/msf2-soc.c:70 | ||
18 | #8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
19 | #9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
20 | #10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
21 | #11 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
22 | #12 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
28 | --- | ||
29 | hw/timer/mss-timer.c | 13 +++++++++++++ | ||
30 | 1 file changed, 13 insertions(+) | ||
31 | |||
32 | diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/timer/mss-timer.c | 21 | --- a/target/arm/cpu.h |
35 | +++ b/hw/timer/mss-timer.c | 22 | +++ b/target/arm/cpu.h |
36 | @@ -XXX,XX +XXX,XX @@ static void mss_timer_init(Object *obj) | 23 | @@ -XXX,XX +XXX,XX @@ |
37 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &t->mmio); | 24 | #define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */ |
25 | #define EXCP_LSERR 21 /* v8M LSERR SecureFault */ | ||
26 | #define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */ | ||
27 | +#define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */ | ||
28 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | ||
29 | |||
30 | #define ARMV7M_EXCP_RESET 1 | ||
31 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/helper.h | ||
34 | +++ b/target/arm/helper.h | ||
35 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(add_saturate, i32, env, i32, i32) | ||
36 | DEF_HELPER_3(sub_saturate, i32, env, i32, i32) | ||
37 | DEF_HELPER_3(add_usaturate, i32, env, i32, i32) | ||
38 | DEF_HELPER_3(sub_usaturate, i32, env, i32, i32) | ||
39 | -DEF_HELPER_FLAGS_2(sdiv, TCG_CALL_NO_RWG_SE, s32, s32, s32) | ||
40 | -DEF_HELPER_FLAGS_2(udiv, TCG_CALL_NO_RWG_SE, i32, i32, i32) | ||
41 | +DEF_HELPER_FLAGS_3(sdiv, TCG_CALL_NO_RWG, s32, env, s32, s32) | ||
42 | +DEF_HELPER_FLAGS_3(udiv, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
43 | DEF_HELPER_FLAGS_1(rbit, TCG_CALL_NO_RWG_SE, i32, i32) | ||
44 | |||
45 | #define PAS_OP(pfx) \ | ||
46 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/helper.c | ||
49 | +++ b/target/arm/helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sxtb16)(uint32_t x) | ||
51 | return res; | ||
38 | } | 52 | } |
39 | 53 | ||
40 | +static void mss_timer_finalize(Object *obj) | 54 | +static void handle_possible_div0_trap(CPUARMState *env, uintptr_t ra) |
41 | +{ | 55 | +{ |
42 | + MSSTimerState *t = MSS_TIMER(obj); | 56 | + /* |
43 | + int i; | 57 | + * Take a division-by-zero exception if necessary; otherwise return |
44 | + | 58 | + * to get the usual non-trapping division behaviour (result of 0) |
45 | + for (i = 0; i < NUM_TIMERS; i++) { | 59 | + */ |
46 | + struct Msf2Timer *st = &t->timers[i]; | 60 | + if (arm_feature(env, ARM_FEATURE_M) |
47 | + | 61 | + && (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_DIV_0_TRP_MASK)) { |
48 | + ptimer_free(st->ptimer); | 62 | + raise_exception_ra(env, EXCP_DIVBYZERO, 0, 1, ra); |
49 | + } | 63 | + } |
50 | +} | 64 | +} |
51 | + | 65 | + |
52 | static const VMStateDescription vmstate_timers = { | 66 | uint32_t HELPER(uxtb16)(uint32_t x) |
53 | .name = "mss-timer-block", | 67 | { |
54 | .version_id = 1, | 68 | uint32_t res; |
55 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo mss_timer_info = { | 69 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(uxtb16)(uint32_t x) |
56 | .parent = TYPE_SYS_BUS_DEVICE, | 70 | return res; |
57 | .instance_size = sizeof(MSSTimerState), | 71 | } |
58 | .instance_init = mss_timer_init, | 72 | |
59 | + .instance_finalize = mss_timer_finalize, | 73 | -int32_t HELPER(sdiv)(int32_t num, int32_t den) |
60 | .class_init = mss_timer_class_init, | 74 | +int32_t HELPER(sdiv)(CPUARMState *env, int32_t num, int32_t den) |
61 | }; | 75 | { |
62 | 76 | if (den == 0) { | |
77 | + handle_possible_div0_trap(env, GETPC()); | ||
78 | return 0; | ||
79 | } | ||
80 | if (num == INT_MIN && den == -1) { | ||
81 | @@ -XXX,XX +XXX,XX @@ int32_t HELPER(sdiv)(int32_t num, int32_t den) | ||
82 | return num / den; | ||
83 | } | ||
84 | |||
85 | -uint32_t HELPER(udiv)(uint32_t num, uint32_t den) | ||
86 | +uint32_t HELPER(udiv)(CPUARMState *env, uint32_t num, uint32_t den) | ||
87 | { | ||
88 | if (den == 0) { | ||
89 | + handle_possible_div0_trap(env, GETPC()); | ||
90 | return 0; | ||
91 | } | ||
92 | return num / den; | ||
93 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(int idx) | ||
94 | [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | ||
95 | [EXCP_LSERR] = "v8M LSERR UsageFault", | ||
96 | [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | ||
97 | + [EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault", | ||
98 | }; | ||
99 | |||
100 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | ||
101 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/target/arm/m_helper.c | ||
104 | +++ b/target/arm/m_helper.c | ||
105 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
106 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
107 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; | ||
108 | break; | ||
109 | + case EXCP_DIVBYZERO: | ||
110 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
111 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_DIVBYZERO_MASK; | ||
112 | + break; | ||
113 | case EXCP_SWI: | ||
114 | /* The PC already points to the next instruction. */ | ||
115 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure); | ||
116 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/target/arm/translate.c | ||
119 | +++ b/target/arm/translate.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static bool op_div(DisasContext *s, arg_rrr *a, bool u) | ||
121 | t1 = load_reg(s, a->rn); | ||
122 | t2 = load_reg(s, a->rm); | ||
123 | if (u) { | ||
124 | - gen_helper_udiv(t1, t1, t2); | ||
125 | + gen_helper_udiv(t1, cpu_env, t1, t2); | ||
126 | } else { | ||
127 | - gen_helper_sdiv(t1, t1, t2); | ||
128 | + gen_helper_sdiv(t1, cpu_env, t1, t2); | ||
129 | } | ||
130 | tcg_temp_free_i32(t2); | ||
131 | store_reg(s, a->rd, t1); | ||
63 | -- | 132 | -- |
64 | 2.20.1 | 133 | 2.20.1 |
65 | 134 | ||
66 | 135 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Hamza Mahfooz <someguy@effective-light.com> |
---|---|---|---|
2 | 2 | ||
3 | Correct the indexing into s->cpu_ctlr for vCPUs. | 3 | As per commit 5626f8c6d468 ("rcu: Add automatically released rcu_read_lock |
4 | variants"), RCU_READ_LOCK_GUARD() should be used instead of | ||
5 | rcu_read_{un}lock(). | ||
4 | 6 | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 7 | Signed-off-by: Hamza Mahfooz <someguy@effective-light.com> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> |
7 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 9 | Message-id: 20210727235201.11491-1-someguy@effective-light.com |
8 | Message-id: 20201214222154.3480243-2-edgar.iglesias@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | hw/intc/arm_gic.c | 4 +++- | 12 | target/arm/kvm.c | 17 ++++++++--------- |
12 | 1 file changed, 3 insertions(+), 1 deletion(-) | 13 | 1 file changed, 8 insertions(+), 9 deletions(-) |
13 | 14 | ||
14 | diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c | 15 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/intc/arm_gic.c | 17 | --- a/target/arm/kvm.c |
17 | +++ b/hw/intc/arm_gic.c | 18 | +++ b/target/arm/kvm.c |
18 | @@ -XXX,XX +XXX,XX @@ static inline void gic_get_best_virq(GICState *s, int cpu, | 19 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, |
19 | static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt, | 20 | hwaddr xlat, len, doorbell_gpa; |
20 | int group_mask) | 21 | MemoryRegionSection mrs; |
21 | { | 22 | MemoryRegion *mr; |
22 | + int cpu_iface = virt ? (cpu + GIC_NCPU) : cpu; | 23 | - int ret = 1; |
24 | |||
25 | if (as == &address_space_memory) { | ||
26 | return 0; | ||
27 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, | ||
28 | |||
29 | /* MSI doorbell address is translated by an IOMMU */ | ||
30 | |||
31 | - rcu_read_lock(); | ||
32 | + RCU_READ_LOCK_GUARD(); | ||
23 | + | 33 | + |
24 | if (!virt && !(s->ctlr & group_mask)) { | 34 | mr = address_space_translate(as, address, &xlat, &len, true, |
25 | return false; | 35 | MEMTXATTRS_UNSPECIFIED); |
36 | + | ||
37 | if (!mr) { | ||
38 | - goto unlock; | ||
39 | + return 1; | ||
26 | } | 40 | } |
27 | @@ -XXX,XX +XXX,XX @@ static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt, | 41 | + |
28 | return false; | 42 | mrs = memory_region_find(mr, xlat, 1); |
43 | + | ||
44 | if (!mrs.mr) { | ||
45 | - goto unlock; | ||
46 | + return 1; | ||
29 | } | 47 | } |
30 | 48 | ||
31 | - if (!(s->cpu_ctlr[cpu] & group_mask)) { | 49 | doorbell_gpa = mrs.offset_within_address_space; |
32 | + if (!(s->cpu_ctlr[cpu_iface] & group_mask)) { | 50 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, |
33 | return false; | 51 | |
34 | } | 52 | trace_kvm_arm_fixup_msi_route(address, doorbell_gpa); |
35 | 53 | ||
54 | - ret = 0; | ||
55 | - | ||
56 | -unlock: | ||
57 | - rcu_read_unlock(); | ||
58 | - return ret; | ||
59 | + return 0; | ||
60 | } | ||
61 | |||
62 | int kvm_arch_add_msi_route_post(struct kvm_irq_routing_entry *route, | ||
36 | -- | 63 | -- |
37 | 2.20.1 | 64 | 2.20.1 |
38 | 65 | ||
39 | 66 | diff view generated by jsdifflib |
1 | From: Bin Meng <bin.meng@windriver.com> | 1 | From: Jan Luebbe <jlu@pengutronix.de> |
---|---|---|---|
2 | 2 | ||
3 | This adds the target guide for SABRE Lite board, and documents how | 3 | Break events are currently only handled by chardev/char-serial.c, so we |
4 | to boot a Linux kernel and U-Boot bootloader. | 4 | just ignore errors, which results in no behaviour change for other |
5 | chardevs. | ||
5 | 6 | ||
6 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | 7 | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Message-id: 20210806144700.3751979-1-jlu@pengutronix.de |
8 | Message-id: 20210106063504.10841-5-bmeng.cn@gmail.com | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++++++++++ | 12 | hw/char/pl011.c | 6 ++++++ |
12 | docs/system/target-arm.rst | 1 + | 13 | 1 file changed, 6 insertions(+) |
13 | 2 files changed, 120 insertions(+) | ||
14 | create mode 100644 docs/system/arm/sabrelite.rst | ||
15 | 14 | ||
16 | diff --git a/docs/system/arm/sabrelite.rst b/docs/system/arm/sabrelite.rst | 15 | diff --git a/hw/char/pl011.c b/hw/char/pl011.c |
17 | new file mode 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | index XXXXXXX..XXXXXXX | 17 | --- a/hw/char/pl011.c |
19 | --- /dev/null | 18 | +++ b/hw/char/pl011.c |
20 | +++ b/docs/system/arm/sabrelite.rst | ||
21 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
22 | +Boundary Devices SABRE Lite (``sabrelite``) | 20 | #include "hw/qdev-properties-system.h" |
23 | +=========================================== | 21 | #include "migration/vmstate.h" |
24 | + | 22 | #include "chardev/char-fe.h" |
25 | +Boundary Devices SABRE Lite i.MX6 Development Board is a low-cost development | 23 | +#include "chardev/char-serial.h" |
26 | +platform featuring the powerful Freescale / NXP Semiconductor's i.MX 6 Quad | 24 | #include "qemu/log.h" |
27 | +Applications Processor. | 25 | #include "qemu/module.h" |
28 | + | 26 | #include "trace.h" |
29 | +Supported devices | 27 | @@ -XXX,XX +XXX,XX @@ static void pl011_write(void *opaque, hwaddr offset, |
30 | +----------------- | 28 | s->read_count = 0; |
31 | + | 29 | s->read_pos = 0; |
32 | +The SABRE Lite machine supports the following devices: | 30 | } |
33 | + | 31 | + if ((s->lcr ^ value) & 0x1) { |
34 | + * Up to 4 Cortex A9 cores | 32 | + int break_enable = value & 0x1; |
35 | + * Generic Interrupt Controller | 33 | + qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_BREAK, |
36 | + * 1 Clock Controller Module | 34 | + &break_enable); |
37 | + * 1 System Reset Controller | 35 | + } |
38 | + * 5 UARTs | 36 | s->lcr = value; |
39 | + * 2 EPIC timers | 37 | pl011_set_read_trigger(s); |
40 | + * 1 GPT timer | 38 | break; |
41 | + * 2 Watchdog timers | ||
42 | + * 1 FEC Ethernet controller | ||
43 | + * 3 I2C controllers | ||
44 | + * 7 GPIO controllers | ||
45 | + * 4 SDHC storage controllers | ||
46 | + * 4 USB 2.0 host controllers | ||
47 | + * 5 ECSPI controllers | ||
48 | + * 1 SST 25VF016B flash | ||
49 | + | ||
50 | +Please note above list is a complete superset the QEMU SABRE Lite machine can | ||
51 | +support. For a normal use case, a device tree blob that represents a real world | ||
52 | +SABRE Lite board, only exposes a subset of devices to the guest software. | ||
53 | + | ||
54 | +Boot options | ||
55 | +------------ | ||
56 | + | ||
57 | +The SABRE Lite machine can start using the standard -kernel functionality | ||
58 | +for loading a Linux kernel, U-Boot bootloader or ELF executable. | ||
59 | + | ||
60 | +Running Linux kernel | ||
61 | +-------------------- | ||
62 | + | ||
63 | +Linux mainline v5.10 release is tested at the time of writing. To build a Linux | ||
64 | +mainline kernel that can be booted by the SABRE Lite machine, simply configure | ||
65 | +the kernel using the imx_v6_v7_defconfig configuration: | ||
66 | + | ||
67 | +.. code-block:: bash | ||
68 | + | ||
69 | + $ export ARCH=arm | ||
70 | + $ export CROSS_COMPILE=arm-linux-gnueabihf- | ||
71 | + $ make imx_v6_v7_defconfig | ||
72 | + $ make | ||
73 | + | ||
74 | +To boot the newly built Linux kernel in QEMU with the SABRE Lite machine, use: | ||
75 | + | ||
76 | +.. code-block:: bash | ||
77 | + | ||
78 | + $ qemu-system-arm -M sabrelite -smp 4 -m 1G \ | ||
79 | + -display none -serial null -serial stdio \ | ||
80 | + -kernel arch/arm/boot/zImage \ | ||
81 | + -dtb arch/arm/boot/dts/imx6q-sabrelite.dtb \ | ||
82 | + -initrd /path/to/rootfs.ext4 \ | ||
83 | + -append "root=/dev/ram" | ||
84 | + | ||
85 | +Running U-Boot | ||
86 | +-------------- | ||
87 | + | ||
88 | +U-Boot mainline v2020.10 release is tested at the time of writing. To build a | ||
89 | +U-Boot mainline bootloader that can be booted by the SABRE Lite machine, use | ||
90 | +the mx6qsabrelite_defconfig with similar commands as described above for Linux: | ||
91 | + | ||
92 | +.. code-block:: bash | ||
93 | + | ||
94 | + $ export CROSS_COMPILE=arm-linux-gnueabihf- | ||
95 | + $ make mx6qsabrelite_defconfig | ||
96 | + | ||
97 | +Note we need to adjust settings by: | ||
98 | + | ||
99 | +.. code-block:: bash | ||
100 | + | ||
101 | + $ make menuconfig | ||
102 | + | ||
103 | +then manually select the following configuration in U-Boot: | ||
104 | + | ||
105 | + Device Tree Control > Provider of DTB for DT Control > Embedded DTB | ||
106 | + | ||
107 | +To start U-Boot using the SABRE Lite machine, provide the u-boot binary to | ||
108 | +the -kernel argument, along with an SD card image with rootfs: | ||
109 | + | ||
110 | +.. code-block:: bash | ||
111 | + | ||
112 | + $ qemu-system-arm -M sabrelite -smp 4 -m 1G \ | ||
113 | + -display none -serial null -serial stdio \ | ||
114 | + -kernel u-boot | ||
115 | + | ||
116 | +The following example shows booting Linux kernel from dhcp, and uses the | ||
117 | +rootfs on an SD card. This requires some additional command line parameters | ||
118 | +for QEMU: | ||
119 | + | ||
120 | +.. code-block:: none | ||
121 | + | ||
122 | + -nic user,tftp=/path/to/kernel/zImage \ | ||
123 | + -drive file=sdcard.img,id=rootfs -device sd-card,drive=rootfs | ||
124 | + | ||
125 | +The directory for the built-in TFTP server should also contain the device tree | ||
126 | +blob of the SABRE Lite board. The sample SD card image was populated with the | ||
127 | +root file system with one single partition. You may adjust the kernel "root=" | ||
128 | +boot parameter accordingly. | ||
129 | + | ||
130 | +After U-Boot boots, type the following commands in the U-Boot command shell to | ||
131 | +boot the Linux kernel: | ||
132 | + | ||
133 | +.. code-block:: none | ||
134 | + | ||
135 | + => setenv ethaddr 00:11:22:33:44:55 | ||
136 | + => setenv bootfile zImage | ||
137 | + => dhcp | ||
138 | + => tftpboot 14000000 imx6q-sabrelite.dtb | ||
139 | + => setenv bootargs root=/dev/mmcblk3p1 | ||
140 | + => bootz 12000000 - 14000000 | ||
141 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
142 | index XXXXXXX..XXXXXXX 100644 | ||
143 | --- a/docs/system/target-arm.rst | ||
144 | +++ b/docs/system/target-arm.rst | ||
145 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | ||
146 | arm/versatile | ||
147 | arm/vexpress | ||
148 | arm/aspeed | ||
149 | + arm/sabrelite | ||
150 | arm/digic | ||
151 | arm/musicpal | ||
152 | arm/gumstix | ||
153 | -- | 39 | -- |
154 | 2.20.1 | 40 | 2.20.1 |
155 | 41 | ||
156 | 42 | diff view generated by jsdifflib |
1 | From: Bin Meng <bin.meng@windriver.com> | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | 2 | ||
3 | At present, when booting U-Boot on QEMU sabrelite, we see: | 3 | Instantiate SAI1/2/3 and ASRC as unimplemented devices to avoid random |
4 | Linux kernel crashes, such as | ||
4 | 5 | ||
5 | Net: Board Net Initialization Failed | 6 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd1580010 |
6 | No ethernet found. | 7 | pgd = (ptrval) |
8 | [d1580010] *pgd=8231b811, *pte=02034653, *ppte=02034453 | ||
9 | Internal error: : 808 [#1] SMP ARM | ||
10 | ... | ||
11 | [<c095e974>] (regmap_mmio_write32le) from [<c095eb48>] (regmap_mmio_write+0x3c/0x54) | ||
12 | [<c095eb48>] (regmap_mmio_write) from [<c09580f4>] (_regmap_write+0x4c/0x1f0) | ||
13 | [<c09580f4>] (_regmap_write) from [<c095837c>] (_regmap_update_bits+0xe4/0xec) | ||
14 | [<c095837c>] (_regmap_update_bits) from [<c09599b4>] (regmap_update_bits_base+0x50/0x74) | ||
15 | [<c09599b4>] (regmap_update_bits_base) from [<c0d3e9e4>] (fsl_asrc_runtime_resume+0x1e4/0x21c) | ||
16 | [<c0d3e9e4>] (fsl_asrc_runtime_resume) from [<c0942464>] (__rpm_callback+0x3c/0x108) | ||
17 | [<c0942464>] (__rpm_callback) from [<c0942590>] (rpm_callback+0x60/0x64) | ||
18 | [<c0942590>] (rpm_callback) from [<c0942b60>] (rpm_resume+0x5cc/0x808) | ||
19 | [<c0942b60>] (rpm_resume) from [<c0942dfc>] (__pm_runtime_resume+0x60/0xa0) | ||
20 | [<c0942dfc>] (__pm_runtime_resume) from [<c0d3ecc4>] (fsl_asrc_probe+0x2a8/0x708) | ||
21 | [<c0d3ecc4>] (fsl_asrc_probe) from [<c0935b08>] (platform_probe+0x58/0xb8) | ||
22 | [<c0935b08>] (platform_probe) from [<c0933264>] (really_probe.part.0+0x9c/0x334) | ||
23 | [<c0933264>] (really_probe.part.0) from [<c093359c>] (__driver_probe_device+0xa0/0x138) | ||
24 | [<c093359c>] (__driver_probe_device) from [<c0933664>] (driver_probe_device+0x30/0xc8) | ||
25 | [<c0933664>] (driver_probe_device) from [<c0933c88>] (__driver_attach+0x90/0x130) | ||
26 | [<c0933c88>] (__driver_attach) from [<c0931060>] (bus_for_each_dev+0x78/0xb8) | ||
27 | [<c0931060>] (bus_for_each_dev) from [<c093254c>] (bus_add_driver+0xf0/0x1d8) | ||
28 | [<c093254c>] (bus_add_driver) from [<c0934a30>] (driver_register+0x88/0x118) | ||
29 | [<c0934a30>] (driver_register) from [<c01022c0>] (do_one_initcall+0x7c/0x3a4) | ||
30 | [<c01022c0>] (do_one_initcall) from [<c1601204>] (kernel_init_freeable+0x198/0x22c) | ||
31 | [<c1601204>] (kernel_init_freeable) from [<c0f5ff2c>] (kernel_init+0x10/0x128) | ||
32 | [<c0f5ff2c>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38) | ||
7 | 33 | ||
8 | U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the | 34 | or |
9 | U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real | ||
10 | board, the Ethernet PHY is at address 6. Adjust this by updating the | ||
11 | "fec-phy-num" property of the fsl_imx6 SoC object. | ||
12 | 35 | ||
13 | With this change, U-Boot sees the PHY but complains MAC address: | 36 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd19b0000 |
37 | pgd = (ptrval) | ||
38 | [d19b0000] *pgd=82711811, *pte=308a0653, *ppte=308a0453 | ||
39 | Internal error: : 808 [#1] SMP ARM | ||
40 | ... | ||
41 | [<c095e974>] (regmap_mmio_write32le) from [<c095eb48>] (regmap_mmio_write+0x3c/0x54) | ||
42 | [<c095eb48>] (regmap_mmio_write) from [<c09580f4>] (_regmap_write+0x4c/0x1f0) | ||
43 | [<c09580f4>] (_regmap_write) from [<c0959b28>] (regmap_write+0x3c/0x60) | ||
44 | [<c0959b28>] (regmap_write) from [<c0d41130>] (fsl_sai_runtime_resume+0x9c/0x1ec) | ||
45 | [<c0d41130>] (fsl_sai_runtime_resume) from [<c0942464>] (__rpm_callback+0x3c/0x108) | ||
46 | [<c0942464>] (__rpm_callback) from [<c0942590>] (rpm_callback+0x60/0x64) | ||
47 | [<c0942590>] (rpm_callback) from [<c0942b60>] (rpm_resume+0x5cc/0x808) | ||
48 | [<c0942b60>] (rpm_resume) from [<c0942dfc>] (__pm_runtime_resume+0x60/0xa0) | ||
49 | [<c0942dfc>] (__pm_runtime_resume) from [<c0d4231c>] (fsl_sai_probe+0x2b8/0x65c) | ||
50 | [<c0d4231c>] (fsl_sai_probe) from [<c0935b08>] (platform_probe+0x58/0xb8) | ||
51 | [<c0935b08>] (platform_probe) from [<c0933264>] (really_probe.part.0+0x9c/0x334) | ||
52 | [<c0933264>] (really_probe.part.0) from [<c093359c>] (__driver_probe_device+0xa0/0x138) | ||
53 | [<c093359c>] (__driver_probe_device) from [<c0933664>] (driver_probe_device+0x30/0xc8) | ||
54 | [<c0933664>] (driver_probe_device) from [<c0933c88>] (__driver_attach+0x90/0x130) | ||
55 | [<c0933c88>] (__driver_attach) from [<c0931060>] (bus_for_each_dev+0x78/0xb8) | ||
56 | [<c0931060>] (bus_for_each_dev) from [<c093254c>] (bus_add_driver+0xf0/0x1d8) | ||
57 | [<c093254c>] (bus_add_driver) from [<c0934a30>] (driver_register+0x88/0x118) | ||
58 | [<c0934a30>] (driver_register) from [<c01022c0>] (do_one_initcall+0x7c/0x3a4) | ||
59 | [<c01022c0>] (do_one_initcall) from [<c1601204>] (kernel_init_freeable+0x198/0x22c) | ||
60 | [<c1601204>] (kernel_init_freeable) from [<c0f5ff2c>] (kernel_init+0x10/0x128) | ||
61 | [<c0f5ff2c>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38) | ||
14 | 62 | ||
15 | Net: using phy at 6 | 63 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
16 | FEC [PRIME] | 64 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> |
17 | Error: FEC address not set. | 65 | Message-id: 20210810160318.87376-1-linux@roeck-us.net |
18 | |||
19 | This is due to U-Boot tries to read the MAC address from the fuse, | ||
20 | which QEMU does not have any valid content filled in. However this | ||
21 | does not prevent the Ethernet from working in QEMU. We just need to | ||
22 | set up the MAC address later in the U-Boot command shell, by: | ||
23 | |||
24 | => setenv ethaddr 00:11:22:33:44:55 | ||
25 | |||
26 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
27 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
28 | Message-id: 20210106063504.10841-4-bmeng.cn@gmail.com | ||
29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 66 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
30 | --- | 67 | --- |
31 | hw/arm/sabrelite.c | 4 ++++ | 68 | hw/arm/fsl-imx6ul.c | 12 ++++++++++++ |
32 | 1 file changed, 4 insertions(+) | 69 | 1 file changed, 12 insertions(+) |
33 | 70 | ||
34 | diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c | 71 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c |
35 | index XXXXXXX..XXXXXXX 100644 | 72 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/hw/arm/sabrelite.c | 73 | --- a/hw/arm/fsl-imx6ul.c |
37 | +++ b/hw/arm/sabrelite.c | 74 | +++ b/hw/arm/fsl-imx6ul.c |
38 | @@ -XXX,XX +XXX,XX @@ static void sabrelite_init(MachineState *machine) | 75 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
39 | 76 | */ | |
40 | s = FSL_IMX6(object_new(TYPE_FSL_IMX6)); | 77 | create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000); |
41 | object_property_add_child(OBJECT(machine), "soc", OBJECT(s)); | 78 | |
79 | + /* | ||
80 | + * SAI (Audio SSI (Synchronous Serial Interface)) | ||
81 | + */ | ||
82 | + create_unimplemented_device("sai1", FSL_IMX6UL_SAI1_ADDR, 0x4000); | ||
83 | + create_unimplemented_device("sai2", FSL_IMX6UL_SAI2_ADDR, 0x4000); | ||
84 | + create_unimplemented_device("sai3", FSL_IMX6UL_SAI3_ADDR, 0x4000); | ||
42 | + | 85 | + |
43 | + /* Ethernet PHY address is 6 */ | 86 | /* |
44 | + object_property_set_int(OBJECT(s), "fec-phy-num", 6, &error_fatal); | 87 | * PWM |
88 | */ | ||
89 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
90 | create_unimplemented_device("pwm3", FSL_IMX6UL_PWM3_ADDR, 0x4000); | ||
91 | create_unimplemented_device("pwm4", FSL_IMX6UL_PWM4_ADDR, 0x4000); | ||
92 | |||
93 | + /* | ||
94 | + * Audio ASRC (asynchronous sample rate converter) | ||
95 | + */ | ||
96 | + create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, 0x4000); | ||
45 | + | 97 | + |
46 | qdev_realize(DEVICE(s), NULL, &error_fatal); | 98 | /* |
47 | 99 | * CAN | |
48 | memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR, | 100 | */ |
49 | -- | 101 | -- |
50 | 2.20.1 | 102 | 2.20.1 |
51 | 103 | ||
52 | 104 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | From: "Wen, Jianxian" <Jianxian.Wen@verisilicon.com> |
---|---|---|---|
2 | 2 | ||
3 | When running device-introspect-test, a memory leak occurred in the | 3 | Add property memory region which can connect with IOMMU region to support SMMU translate. |
4 | exynos4210_pwm_init function, so use ptimer_free() in the finalize function to | ||
5 | avoid it. | ||
6 | 4 | ||
7 | ASAN shows memory leak stack: | 5 | Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com> |
8 | 6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | |
9 | Indirect leak of 240 byte(s) in 5 object(s) allocated from: | 7 | Message-id: 4C23C17B8E87E74E906A25A3254A03F4FA1FEC31@SHASXM03.verisilicon.com |
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523 | ||
13 | #3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544 | ||
14 | #4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562 | ||
15 | #5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433 | ||
16 | #6 0xaaabf56a36cc in exynos4210_pwm_init /qemu/hw/timer/exynos4210_pwm.c:401 | ||
17 | #7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
18 | #8 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
19 | #9 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
20 | #10 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
21 | #11 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
22 | #12 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | --- | 9 | --- |
29 | hw/timer/exynos4210_pwm.c | 11 +++++++++++ | 10 | hw/arm/exynos4210.c | 3 +++ |
30 | 1 file changed, 11 insertions(+) | 11 | hw/arm/xilinx_zynq.c | 3 +++ |
12 | hw/dma/pl330.c | 26 ++++++++++++++++++++++---- | ||
13 | 3 files changed, 28 insertions(+), 4 deletions(-) | ||
31 | 14 | ||
32 | diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c | 15 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
33 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/timer/exynos4210_pwm.c | 17 | --- a/hw/arm/exynos4210.c |
35 | +++ b/hw/timer/exynos4210_pwm.c | 18 | +++ b/hw/arm/exynos4210.c |
36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_init(Object *obj) | 19 | @@ -XXX,XX +XXX,XX @@ static DeviceState *pl330_create(uint32_t base, qemu_or_irq *orgate, |
37 | sysbus_init_mmio(dev, &s->iomem); | 20 | int i; |
21 | |||
22 | dev = qdev_new("pl330"); | ||
23 | + object_property_set_link(OBJECT(dev), "memory", | ||
24 | + OBJECT(get_system_memory()), | ||
25 | + &error_fatal); | ||
26 | qdev_prop_set_uint8(dev, "num_events", nevents); | ||
27 | qdev_prop_set_uint8(dev, "num_chnls", 8); | ||
28 | qdev_prop_set_uint8(dev, "num_periph_req", nreq); | ||
29 | diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/xilinx_zynq.c | ||
32 | +++ b/hw/arm/xilinx_zynq.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) | ||
34 | sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[39-IRQ_OFFSET]); | ||
35 | |||
36 | dev = qdev_new("pl330"); | ||
37 | + object_property_set_link(OBJECT(dev), "memory", | ||
38 | + OBJECT(address_space_mem), | ||
39 | + &error_fatal); | ||
40 | qdev_prop_set_uint8(dev, "num_chnls", 8); | ||
41 | qdev_prop_set_uint8(dev, "num_periph_req", 4); | ||
42 | qdev_prop_set_uint8(dev, "num_events", 16); | ||
43 | diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/dma/pl330.c | ||
46 | +++ b/hw/dma/pl330.c | ||
47 | @@ -XXX,XX +XXX,XX @@ struct PL330State { | ||
48 | uint8_t num_faulting; | ||
49 | uint8_t periph_busy[PL330_PERIPH_NUM]; | ||
50 | |||
51 | + /* Memory region that DMA operation access */ | ||
52 | + MemoryRegion *mem_mr; | ||
53 | + AddressSpace *mem_as; | ||
54 | }; | ||
55 | |||
56 | #define TYPE_PL330 "pl330" | ||
57 | @@ -XXX,XX +XXX,XX @@ static inline const PL330InsnDesc *pl330_fetch_insn(PL330Chan *ch) | ||
58 | uint8_t opcode; | ||
59 | int i; | ||
60 | |||
61 | - dma_memory_read(&address_space_memory, ch->pc, &opcode, 1); | ||
62 | + dma_memory_read(ch->parent->mem_as, ch->pc, &opcode, 1); | ||
63 | for (i = 0; insn_desc[i].size; i++) { | ||
64 | if ((opcode & insn_desc[i].opmask) == insn_desc[i].opcode) { | ||
65 | return &insn_desc[i]; | ||
66 | @@ -XXX,XX +XXX,XX @@ static inline void pl330_exec_insn(PL330Chan *ch, const PL330InsnDesc *insn) | ||
67 | uint8_t buf[PL330_INSN_MAXSIZE]; | ||
68 | |||
69 | assert(insn->size <= PL330_INSN_MAXSIZE); | ||
70 | - dma_memory_read(&address_space_memory, ch->pc, buf, insn->size); | ||
71 | + dma_memory_read(ch->parent->mem_as, ch->pc, buf, insn->size); | ||
72 | insn->exec(ch, buf[0], &buf[1], insn->size - 1); | ||
38 | } | 73 | } |
39 | 74 | ||
40 | +static void exynos4210_pwm_finalize(Object *obj) | 75 | @@ -XXX,XX +XXX,XX @@ static int pl330_exec_cycle(PL330Chan *channel) |
41 | +{ | 76 | if (q != NULL && q->len <= pl330_fifo_num_free(&s->fifo)) { |
42 | + Exynos4210PWMState *s = EXYNOS4210_PWM(obj); | 77 | int len = q->len - (q->addr & (q->len - 1)); |
43 | + int i; | 78 | |
79 | - dma_memory_read(&address_space_memory, q->addr, buf, len); | ||
80 | + dma_memory_read(s->mem_as, q->addr, buf, len); | ||
81 | trace_pl330_exec_cycle(q->addr, len); | ||
82 | if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { | ||
83 | pl330_hexdump(buf, len); | ||
84 | @@ -XXX,XX +XXX,XX @@ static int pl330_exec_cycle(PL330Chan *channel) | ||
85 | fifo_res = pl330_fifo_get(&s->fifo, buf, len, q->tag); | ||
86 | } | ||
87 | if (fifo_res == PL330_FIFO_OK || q->z) { | ||
88 | - dma_memory_write(&address_space_memory, q->addr, buf, len); | ||
89 | + dma_memory_write(s->mem_as, q->addr, buf, len); | ||
90 | trace_pl330_exec_cycle(q->addr, len); | ||
91 | if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { | ||
92 | pl330_hexdump(buf, len); | ||
93 | @@ -XXX,XX +XXX,XX @@ static void pl330_realize(DeviceState *dev, Error **errp) | ||
94 | "dma", PL330_IOMEM_SIZE); | ||
95 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | ||
96 | |||
97 | + if (!s->mem_mr) { | ||
98 | + error_setg(errp, "'memory' link is not set"); | ||
99 | + return; | ||
100 | + } else if (s->mem_mr == get_system_memory()) { | ||
101 | + /* Avoid creating new AS for system memory. */ | ||
102 | + s->mem_as = &address_space_memory; | ||
103 | + } else { | ||
104 | + s->mem_as = g_new0(AddressSpace, 1); | ||
105 | + address_space_init(s->mem_as, s->mem_mr, | ||
106 | + memory_region_name(s->mem_mr)); | ||
107 | + } | ||
44 | + | 108 | + |
45 | + for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) { | 109 | s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pl330_exec_cycle_timer, s); |
46 | + ptimer_free(s->timer[i].ptimer); | 110 | |
47 | + } | 111 | s->cfg[0] = (s->mgr_ns_at_rst ? 0x4 : 0) | |
48 | +} | 112 | @@ -XXX,XX +XXX,XX @@ static Property pl330_properties[] = { |
113 | DEFINE_PROP_UINT8("rd_q_dep", PL330State, rd_q_dep, 16), | ||
114 | DEFINE_PROP_UINT16("data_buffer_dep", PL330State, data_buffer_dep, 256), | ||
115 | |||
116 | + DEFINE_PROP_LINK("memory", PL330State, mem_mr, | ||
117 | + TYPE_MEMORY_REGION, MemoryRegion *), | ||
49 | + | 118 | + |
50 | static void exynos4210_pwm_class_init(ObjectClass *klass, void *data) | 119 | DEFINE_PROP_END_OF_LIST(), |
51 | { | ||
52 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
53 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_pwm_info = { | ||
54 | .parent = TYPE_SYS_BUS_DEVICE, | ||
55 | .instance_size = sizeof(Exynos4210PWMState), | ||
56 | .instance_init = exynos4210_pwm_init, | ||
57 | + .instance_finalize = exynos4210_pwm_finalize, | ||
58 | .class_init = exynos4210_pwm_class_init, | ||
59 | }; | 120 | }; |
60 | 121 | ||
61 | -- | 122 | -- |
62 | 2.20.1 | 123 | 2.20.1 |
63 | 124 | ||
64 | 125 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | From: Eduardo Habkost <ehabkost@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | When running device-introspect-test, a memory leak occurred in the | 3 | The SBSA_GWDT enum value conflicts with the SBSA_GWDT() QOM type |
4 | exynos4210_rtc_init function, so use ptimer_free() in the finalize function to | 4 | checking helper, preventing us from using a OBJECT_DEFINE* or |
5 | avoid it. | 5 | DEFINE_INSTANCE_CHECKER macro for the SBSA_GWDT() wrapper. |
6 | 6 | ||
7 | ASAN shows memory leak stack: | 7 | If I understand the SBSA 6.0 specification correctly, the signal |
8 | being connected to IRQ 16 is the WS0 output signal from the | ||
9 | Generic Watchdog. Rename the enum value to SBSA_GWDT_WS0 to be | ||
10 | more explicit and avoid the name conflict. | ||
8 | 11 | ||
9 | Indirect leak of 96 byte(s) in 1 object(s) allocated from: | 12 | Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> |
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | 13 | Message-id: 20210806023119.431680-1-ehabkost@redhat.com |
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf57b3934 in exynos4210_rtc_init /qemu/hw/rtc/exynos4210_rtc.c:567 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
16 | #6 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
17 | #7 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
18 | #8 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
19 | #9 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136 | ||
20 | #10 0xaaabf6552708 in aio_bh_poll /qemu/util/async.c:164 | ||
21 | #11 0xaaabf655f19c in aio_dispatch /qemu/util/aio-posix.c:381 | ||
22 | #12 0xaaabf65523f4 in aio_ctx_dispatch /qemu/util/async.c:306 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | --- | 16 | --- |
29 | hw/rtc/exynos4210_rtc.c | 9 +++++++++ | 17 | hw/arm/sbsa-ref.c | 6 +++--- |
30 | 1 file changed, 9 insertions(+) | 18 | 1 file changed, 3 insertions(+), 3 deletions(-) |
31 | 19 | ||
32 | diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c | 20 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
33 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/rtc/exynos4210_rtc.c | 22 | --- a/hw/arm/sbsa-ref.c |
35 | +++ b/hw/rtc/exynos4210_rtc.c | 23 | +++ b/hw/arm/sbsa-ref.c |
36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_rtc_init(Object *obj) | 24 | @@ -XXX,XX +XXX,XX @@ enum { |
37 | sysbus_init_mmio(dev, &s->iomem); | 25 | SBSA_GIC_DIST, |
38 | } | 26 | SBSA_GIC_REDIST, |
39 | 27 | SBSA_SECURE_EC, | |
40 | +static void exynos4210_rtc_finalize(Object *obj) | 28 | - SBSA_GWDT, |
41 | +{ | 29 | + SBSA_GWDT_WS0, |
42 | + Exynos4210RTCState *s = EXYNOS4210_RTC(obj); | 30 | SBSA_GWDT_REFRESH, |
43 | + | 31 | SBSA_GWDT_CONTROL, |
44 | + ptimer_free(s->ptimer); | 32 | SBSA_SMMU, |
45 | + ptimer_free(s->ptimer_1Hz); | 33 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { |
46 | +} | 34 | [SBSA_AHCI] = 10, |
47 | + | 35 | [SBSA_EHCI] = 11, |
48 | static void exynos4210_rtc_class_init(ObjectClass *klass, void *data) | 36 | [SBSA_SMMU] = 12, /* ... to 15 */ |
49 | { | 37 | - [SBSA_GWDT] = 16, |
50 | DeviceClass *dc = DEVICE_CLASS(klass); | 38 | + [SBSA_GWDT_WS0] = 16, |
51 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_rtc_info = { | ||
52 | .parent = TYPE_SYS_BUS_DEVICE, | ||
53 | .instance_size = sizeof(Exynos4210RTCState), | ||
54 | .instance_init = exynos4210_rtc_init, | ||
55 | + .instance_finalize = exynos4210_rtc_finalize, | ||
56 | .class_init = exynos4210_rtc_class_init, | ||
57 | }; | 39 | }; |
58 | 40 | ||
41 | static const char * const valid_cpus[] = { | ||
42 | @@ -XXX,XX +XXX,XX @@ static void create_wdt(const SBSAMachineState *sms) | ||
43 | hwaddr cbase = sbsa_ref_memmap[SBSA_GWDT_CONTROL].base; | ||
44 | DeviceState *dev = qdev_new(TYPE_WDT_SBSA); | ||
45 | SysBusDevice *s = SYS_BUS_DEVICE(dev); | ||
46 | - int irq = sbsa_ref_irqmap[SBSA_GWDT]; | ||
47 | + int irq = sbsa_ref_irqmap[SBSA_GWDT_WS0]; | ||
48 | |||
49 | sysbus_realize_and_unref(s, &error_fatal); | ||
50 | sysbus_mmio_map(s, 0, rbase); | ||
59 | -- | 51 | -- |
60 | 2.20.1 | 52 | 2.20.1 |
61 | 53 | ||
62 | 54 | diff view generated by jsdifflib |
1 | From: Bin Meng <bin.meng@windriver.com> | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | 2 | ||
3 | Currently when U-Boot boots, it prints "??" for i.MX processor: | 3 | Instantiate SAI1/2/3 as unimplemented devices to avoid Linux kernel crashes |
4 | such as the following. | ||
4 | 5 | ||
5 | CPU: Freescale i.MX?? rev1.0 at 792 MHz | 6 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd19b0000 |
7 | pgd = (ptrval) | ||
8 | [d19b0000] *pgd=82711811, *pte=308a0653, *ppte=308a0453 | ||
9 | Internal error: : 808 [#1] SMP ARM | ||
10 | Modules linked in: | ||
11 | CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.14.0-rc5 #1 | ||
12 | ... | ||
13 | [<c095e974>] (regmap_mmio_write32le) from [<c095eb48>] (regmap_mmio_write+0x3c/0x54) | ||
14 | [<c095eb48>] (regmap_mmio_write) from [<c09580f4>] (_regmap_write+0x4c/0x1f0) | ||
15 | [<c09580f4>] (_regmap_write) from [<c0959b28>] (regmap_write+0x3c/0x60) | ||
16 | [<c0959b28>] (regmap_write) from [<c0d41130>] (fsl_sai_runtime_resume+0x9c/0x1ec) | ||
17 | [<c0d41130>] (fsl_sai_runtime_resume) from [<c0942464>] (__rpm_callback+0x3c/0x108) | ||
18 | [<c0942464>] (__rpm_callback) from [<c0942590>] (rpm_callback+0x60/0x64) | ||
19 | [<c0942590>] (rpm_callback) from [<c0942b60>] (rpm_resume+0x5cc/0x808) | ||
20 | [<c0942b60>] (rpm_resume) from [<c0942dfc>] (__pm_runtime_resume+0x60/0xa0) | ||
21 | [<c0942dfc>] (__pm_runtime_resume) from [<c0d4231c>] (fsl_sai_probe+0x2b8/0x65c) | ||
22 | [<c0d4231c>] (fsl_sai_probe) from [<c0935b08>] (platform_probe+0x58/0xb8) | ||
23 | [<c0935b08>] (platform_probe) from [<c0933264>] (really_probe.part.0+0x9c/0x334) | ||
24 | [<c0933264>] (really_probe.part.0) from [<c093359c>] (__driver_probe_device+0xa0/0x138) | ||
25 | [<c093359c>] (__driver_probe_device) from [<c0933664>] (driver_probe_device+0x30/0xc8) | ||
26 | [<c0933664>] (driver_probe_device) from [<c0933c88>] (__driver_attach+0x90/0x130) | ||
27 | [<c0933c88>] (__driver_attach) from [<c0931060>] (bus_for_each_dev+0x78/0xb8) | ||
28 | [<c0931060>] (bus_for_each_dev) from [<c093254c>] (bus_add_driver+0xf0/0x1d8) | ||
29 | [<c093254c>] (bus_add_driver) from [<c0934a30>] (driver_register+0x88/0x118) | ||
30 | [<c0934a30>] (driver_register) from [<c01022c0>] (do_one_initcall+0x7c/0x3a4) | ||
31 | [<c01022c0>] (do_one_initcall) from [<c1601204>] (kernel_init_freeable+0x198/0x22c) | ||
32 | [<c1601204>] (kernel_init_freeable) from [<c0f5ff2c>] (kernel_init+0x10/0x128) | ||
33 | [<c0f5ff2c>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38) | ||
6 | 34 | ||
7 | The register that was used to determine the silicon type is | 35 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> |
8 | undocumented in the latest IMX6DQRM (Rev. 6, 05/2020), but we | 36 | Message-id: 20210810175607.538090-1-linux@roeck-us.net |
9 | can refer to get_cpu_rev() in arch/arm/mach-imx/mx6/soc.c in | 37 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | the U-Boot source codes that USB_ANALOG_DIGPROG is used. | ||
11 | |||
12 | Update its reset value to indicate i.MX6Q. | ||
13 | |||
14 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
15 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
16 | Message-id: 20210106063504.10841-3-bmeng.cn@gmail.com | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 38 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 39 | --- |
19 | hw/misc/imx6_ccm.c | 2 +- | 40 | include/hw/arm/fsl-imx7.h | 5 +++++ |
20 | 1 file changed, 1 insertion(+), 1 deletion(-) | 41 | hw/arm/fsl-imx7.c | 7 +++++++ |
42 | 2 files changed, 12 insertions(+) | ||
21 | 43 | ||
22 | diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c | 44 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
23 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/misc/imx6_ccm.c | 46 | --- a/include/hw/arm/fsl-imx7.h |
25 | +++ b/hw/misc/imx6_ccm.c | 47 | +++ b/include/hw/arm/fsl-imx7.h |
26 | @@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev) | 48 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { |
27 | s->analog[USB_ANALOG_USB2_VBUS_DETECT] = 0x00000004; | 49 | FSL_IMX7_UART6_ADDR = 0x30A80000, |
28 | s->analog[USB_ANALOG_USB2_CHRG_DETECT] = 0x00000000; | 50 | FSL_IMX7_UART7_ADDR = 0x30A90000, |
29 | s->analog[USB_ANALOG_USB2_MISC] = 0x00000002; | 51 | |
30 | - s->analog[USB_ANALOG_DIGPROG] = 0x00000000; | 52 | + FSL_IMX7_SAI1_ADDR = 0x308A0000, |
31 | + s->analog[USB_ANALOG_DIGPROG] = 0x00630000; | 53 | + FSL_IMX7_SAI2_ADDR = 0x308B0000, |
32 | 54 | + FSL_IMX7_SAI3_ADDR = 0x308C0000, | |
33 | /* all PLLs need to be locked */ | 55 | + FSL_IMX7_SAIn_SIZE = 0x10000, |
34 | s->analog[CCM_ANALOG_PLL_ARM] |= CCM_ANALOG_PLL_LOCK; | 56 | + |
57 | FSL_IMX7_ENET1_ADDR = 0x30BE0000, | ||
58 | FSL_IMX7_ENET2_ADDR = 0x30BF0000, | ||
59 | |||
60 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/hw/arm/fsl-imx7.c | ||
63 | +++ b/hw/arm/fsl-imx7.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
65 | create_unimplemented_device("can1", FSL_IMX7_CAN1_ADDR, FSL_IMX7_CANn_SIZE); | ||
66 | create_unimplemented_device("can2", FSL_IMX7_CAN2_ADDR, FSL_IMX7_CANn_SIZE); | ||
67 | |||
68 | + /* | ||
69 | + * SAI (Audio SSI (Synchronous Serial Interface)) | ||
70 | + */ | ||
71 | + create_unimplemented_device("sai1", FSL_IMX7_SAI1_ADDR, FSL_IMX7_SAIn_SIZE); | ||
72 | + create_unimplemented_device("sai2", FSL_IMX7_SAI2_ADDR, FSL_IMX7_SAIn_SIZE); | ||
73 | + create_unimplemented_device("sai2", FSL_IMX7_SAI3_ADDR, FSL_IMX7_SAIn_SIZE); | ||
74 | + | ||
75 | /* | ||
76 | * OCOTP | ||
77 | */ | ||
35 | -- | 78 | -- |
36 | 2.20.1 | 79 | 2.20.1 |
37 | 80 | ||
38 | 81 | diff view generated by jsdifflib |
1 | From: Bin Meng <bin.meng@windriver.com> | 1 | From: Sebastian Meyer <meyer@absint.com> |
---|---|---|---|
2 | 2 | ||
3 | U-Boot expects PMU_MISC0 register bit 7 is set (see init_bandgap() | 3 | With gdb 9.0 and better it is possible to connect to a gdbstub |
4 | in arch/arm/mach-imx/mx6/soc.c) during boot. This bit indicates the | 4 | over unix sockets, which is better than a TCP socket connection |
5 | bandgap has stabilized. | 5 | in some situations. The QEMU command line to set this up is |
6 | non-obvious; document it. | ||
6 | 7 | ||
7 | With this change, the latest upstream U-Boot (v2021.01-rc3) for imx6 | 8 | Signed-off-by: Sebastian Meyer <meyer@absint.com> |
8 | sabrelite board (mx6qsabrelite_defconfig), with a slight change made | 9 | Message-id: 162867284829.27377.4784930719350564918-0@git.sr.ht |
9 | by switching CONFIG_OF_SEPARATE to CONFIG_OF_EMBED, boots to U-Boot | 10 | [PMM: Tweaked commit message; adjusted wording in a couple of |
10 | shell on QEMU with the following command: | 11 | places; fixed rST formatting issue; moved section up out of |
11 | 12 | the 'advanced debugging options' subsection] | |
12 | $ qemu-system-arm -M sabrelite -smp 4 -m 1G -kernel u-boot \ | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | -display none -serial null -serial stdio | 14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
14 | |||
15 | Boot log below: | ||
16 | |||
17 | U-Boot 2021.01-rc3 (Dec 12 2020 - 17:40:02 +0800) | ||
18 | |||
19 | CPU: Freescale i.MX?? rev1.0 at 792 MHz | ||
20 | Reset cause: POR | ||
21 | Model: Freescale i.MX6 Quad SABRE Lite Board | ||
22 | Board: SABRE Lite | ||
23 | I2C: ready | ||
24 | DRAM: 1 GiB | ||
25 | force_idle_bus: sda=0 scl=0 sda.gp=0x5c scl.gp=0x55 | ||
26 | force_idle_bus: failed to clear bus, sda=0 scl=0 | ||
27 | force_idle_bus: sda=0 scl=0 sda.gp=0x6d scl.gp=0x6c | ||
28 | force_idle_bus: failed to clear bus, sda=0 scl=0 | ||
29 | force_idle_bus: sda=0 scl=0 sda.gp=0xcb scl.gp=0x5 | ||
30 | force_idle_bus: failed to clear bus, sda=0 scl=0 | ||
31 | MMC: FSL_SDHC: 0, FSL_SDHC: 1 | ||
32 | Loading Environment from MMC... *** Warning - No block device, using default environment | ||
33 | |||
34 | In: serial | ||
35 | Out: serial | ||
36 | Err: serial | ||
37 | Net: Board Net Initialization Failed | ||
38 | No ethernet found. | ||
39 | starting USB... | ||
40 | Bus usb@2184000: usb dr_mode not found | ||
41 | USB EHCI 1.00 | ||
42 | Bus usb@2184200: USB EHCI 1.00 | ||
43 | scanning bus usb@2184000 for devices... 1 USB Device(s) found | ||
44 | scanning bus usb@2184200 for devices... 1 USB Device(s) found | ||
45 | scanning usb for storage devices... 0 Storage Device(s) found | ||
46 | scanning usb for ethernet devices... 0 Ethernet Device(s) found | ||
47 | Hit any key to stop autoboot: 0 | ||
48 | => | ||
49 | |||
50 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
51 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
52 | Message-id: 20210106063504.10841-2-bmeng.cn@gmail.com | ||
53 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
54 | --- | 16 | --- |
55 | hw/misc/imx6_ccm.c | 2 +- | 17 | docs/system/gdb.rst | 26 +++++++++++++++++++++++++- |
56 | 1 file changed, 1 insertion(+), 1 deletion(-) | 18 | 1 file changed, 25 insertions(+), 1 deletion(-) |
57 | 19 | ||
58 | diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c | 20 | diff --git a/docs/system/gdb.rst b/docs/system/gdb.rst |
59 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/hw/misc/imx6_ccm.c | 22 | --- a/docs/system/gdb.rst |
61 | +++ b/hw/misc/imx6_ccm.c | 23 | +++ b/docs/system/gdb.rst |
62 | @@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev) | 24 | @@ -XXX,XX +XXX,XX @@ The ``-s`` option will make QEMU listen for an incoming connection |
63 | s->analog[PMU_REG_3P0] = 0x00000F74; | 25 | from gdb on TCP port 1234, and ``-S`` will make QEMU not start the |
64 | s->analog[PMU_REG_2P5] = 0x00005071; | 26 | guest until you tell it to from gdb. (If you want to specify which |
65 | s->analog[PMU_REG_CORE] = 0x00402010; | 27 | TCP port to use or to use something other than TCP for the gdbstub |
66 | - s->analog[PMU_MISC0] = 0x04000000; | 28 | -connection, use the ``-gdb dev`` option instead of ``-s``.) |
67 | + s->analog[PMU_MISC0] = 0x04000080; | 29 | +connection, use the ``-gdb dev`` option instead of ``-s``. See |
68 | s->analog[PMU_MISC1] = 0x00000000; | 30 | +`Using unix sockets`_ for an example.) |
69 | s->analog[PMU_MISC2] = 0x00272727; | 31 | |
32 | .. parsed-literal:: | ||
33 | |||
34 | @@ -XXX,XX +XXX,XX @@ not just those in the cluster you are currently working on:: | ||
35 | |||
36 | (gdb) set schedule-multiple on | ||
37 | |||
38 | +Using unix sockets | ||
39 | +================== | ||
40 | + | ||
41 | +An alternate method for connecting gdb to the QEMU gdbstub is to use | ||
42 | +a unix socket (if supported by your operating system). This is useful when | ||
43 | +running several tests in parallel, or if you do not have a known free TCP | ||
44 | +port (e.g. when running automated tests). | ||
45 | + | ||
46 | +First create a chardev with the appropriate options, then | ||
47 | +instruct the gdbserver to use that device: | ||
48 | + | ||
49 | +.. parsed-literal:: | ||
50 | + | ||
51 | + |qemu_system| -chardev socket,path=/tmp/gdb-socket,server=on,wait=off,id=gdb0 -gdb chardev:gdb0 -S ... | ||
52 | + | ||
53 | +Start gdb as before, but this time connect using the path to | ||
54 | +the socket:: | ||
55 | + | ||
56 | + (gdb) target remote /tmp/gdb-socket | ||
57 | + | ||
58 | +Note that to use a unix socket for the connection you will need | ||
59 | +gdb version 9.0 or newer. | ||
60 | + | ||
61 | Advanced debugging options | ||
62 | ========================== | ||
70 | 63 | ||
71 | -- | 64 | -- |
72 | 2.20.1 | 65 | 2.20.1 |
73 | 66 | ||
74 | 67 | diff view generated by jsdifflib |