1 | First pullreq for arm of the 4.1 series, since I'm back from | 1 | First set of arm patches for 6.2. I have a lot more in my |
---|---|---|---|
2 | holiday now. This is mostly my M-profile FPU series and Philippe's | 2 | to-review queue still... |
3 | devices.h cleanup. I have a pile of other patchsets to work through | ||
4 | in my to-review folder, but 42 patches is definitely quite | ||
5 | big enough to send now... | ||
6 | 3 | ||
7 | thanks | ||
8 | -- PMM | 4 | -- PMM |
9 | 5 | ||
10 | The following changes since commit 413a99a92c13ec408dcf2adaa87918dc81e890c8: | 6 | The following changes since commit d42685765653ec155fdf60910662f8830bdb2cef: |
11 | 7 | ||
12 | Add Nios II semihosting support. (2019-04-29 16:09:51 +0100) | 8 | Open 6.2 development tree (2021-08-25 10:25:12 +0100) |
13 | 9 | ||
14 | are available in the Git repository at: | 10 | are available in the Git repository at: |
15 | 11 | ||
16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190429 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210825 |
17 | 13 | ||
18 | for you to fetch changes up to 437cc27ddfded3bbab6afd5ac1761e0e195edba7: | 14 | for you to fetch changes up to 24b1a6aa43615be22c7ee66bd68ec5675f6a6a9a: |
19 | 15 | ||
20 | hw/devices: Move SMSC 91C111 declaration into a new header (2019-04-29 17:57:21 +0100) | 16 | docs: Document how to use gdb with unix sockets (2021-08-25 10:48:51 +0100) |
21 | 17 | ||
22 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
23 | target-arm queue: | 19 | target-arm queue: |
24 | * remove "bag of random stuff" hw/devices.h header | 20 | * More MVE emulation work |
25 | * implement FPU for Cortex-M and enable it for Cortex-M4 and -M33 | 21 | * Implement M-profile trapping on division by zero |
26 | * hw/dma: Compile the bcm2835_dma device as common object | 22 | * kvm: use RCU_READ_LOCK_GUARD() in kvm_arch_fixup_msi_route() |
27 | * configure: Remove --source-path option | 23 | * hw/char/pl011: add support for sending break |
28 | * hw/ssi/xilinx_spips: Avoid variable length array | 24 | * fsl-imx6ul: Instantiate SAI1/2/3 and ASRC as unimplemented devices |
29 | * hw/arm/smmuv3: Remove SMMUNotifierNode | 25 | * hw/dma/pl330: Add memory region to replace default |
26 | * sbsa-ref: Rename SBSA_GWDT enum value | ||
27 | * fsl-imx7: Instantiate SAI1/2/3 as unimplemented devices | ||
28 | * docs: Document how to use gdb with unix sockets | ||
30 | 29 | ||
31 | ---------------------------------------------------------------- | 30 | ---------------------------------------------------------------- |
32 | Eric Auger (1): | 31 | Eduardo Habkost (1): |
33 | hw/arm/smmuv3: Remove SMMUNotifierNode | 32 | sbsa-ref: Rename SBSA_GWDT enum value |
34 | 33 | ||
35 | Peter Maydell (28): | 34 | Guenter Roeck (2): |
36 | hw/ssi/xilinx_spips: Avoid variable length array | 35 | fsl-imx6ul: Instantiate SAI1/2/3 and ASRC as unimplemented devices |
37 | configure: Remove --source-path option | 36 | fsl-imx7: Instantiate SAI1/2/3 as unimplemented devices |
38 | target/arm: Make sure M-profile FPSCR RES0 bits are not settable | ||
39 | hw/intc/armv7m_nvic: Allow reading of M-profile MVFR* registers | ||
40 | target/arm: Implement dummy versions of M-profile FP-related registers | ||
41 | target/arm: Disable most VFP sysregs for M-profile | ||
42 | target/arm: Honour M-profile FP enable bits | ||
43 | target/arm: Decode FP instructions for M profile | ||
44 | target/arm: Clear CONTROL_S.SFPA in SG insn if FPU present | ||
45 | target/arm: Handle SFPA and FPCA bits in reads and writes of CONTROL | ||
46 | target/arm/helper: don't return early for STKOF faults during stacking | ||
47 | target/arm: Handle floating point registers in exception entry | ||
48 | target/arm: Implement v7m_update_fpccr() | ||
49 | target/arm: Clear CONTROL.SFPA in BXNS and BLXNS | ||
50 | target/arm: Clean excReturn bits when tail chaining | ||
51 | target/arm: Allow for floating point in callee stack integrity check | ||
52 | target/arm: Handle floating point registers in exception return | ||
53 | target/arm: Move NS TBFLAG from bit 19 to bit 6 | ||
54 | target/arm: Overlap VECSTRIDE and XSCALE_CPAR TB flags | ||
55 | target/arm: Set FPCCR.S when executing M-profile floating point insns | ||
56 | target/arm: Activate M-profile floating point context when FPCCR.ASPEN is set | ||
57 | target/arm: New helper function arm_v7m_mmu_idx_all() | ||
58 | target/arm: New function armv7m_nvic_set_pending_lazyfp() | ||
59 | target/arm: Add lazy-FP-stacking support to v7m_stack_write() | ||
60 | target/arm: Implement M-profile lazy FP state preservation | ||
61 | target/arm: Implement VLSTM for v7M CPUs with an FPU | ||
62 | target/arm: Implement VLLDM for v7M CPUs with an FPU | ||
63 | target/arm: Enable FPU for Cortex-M4 and Cortex-M33 | ||
64 | 37 | ||
65 | Philippe Mathieu-Daudé (13): | 38 | Hamza Mahfooz (1): |
66 | hw/dma: Compile the bcm2835_dma device as common object | 39 | target/arm: kvm: use RCU_READ_LOCK_GUARD() in kvm_arch_fixup_msi_route() |
67 | hw/arm/aspeed: Use TYPE_TMP105/TYPE_PCA9552 instead of hardcoded string | ||
68 | hw/arm/nseries: Use TYPE_TMP105 instead of hardcoded string | ||
69 | hw/display/tc6393xb: Remove unused functions | ||
70 | hw/devices: Move TC6393XB declarations into a new header | ||
71 | hw/devices: Move Blizzard declarations into a new header | ||
72 | hw/devices: Move CBus declarations into a new header | ||
73 | hw/devices: Move Gamepad declarations into a new header | ||
74 | hw/devices: Move TI touchscreen declarations into a new header | ||
75 | hw/devices: Move LAN9118 declarations into a new header | ||
76 | hw/net/ne2000-isa: Add guards to the header | ||
77 | hw/net/lan9118: Export TYPE_LAN9118 and use it instead of hardcoded string | ||
78 | hw/devices: Move SMSC 91C111 declaration into a new header | ||
79 | 40 | ||
80 | configure | 10 +- | 41 | Jan Luebbe (1): |
81 | hw/dma/Makefile.objs | 2 +- | 42 | hw/char/pl011: add support for sending break |
82 | include/hw/arm/omap.h | 6 +- | ||
83 | include/hw/arm/smmu-common.h | 8 +- | ||
84 | include/hw/devices.h | 62 --- | ||
85 | include/hw/display/blizzard.h | 22 ++ | ||
86 | include/hw/display/tc6393xb.h | 24 ++ | ||
87 | include/hw/input/gamepad.h | 19 + | ||
88 | include/hw/input/tsc2xxx.h | 36 ++ | ||
89 | include/hw/misc/cbus.h | 32 ++ | ||
90 | include/hw/net/lan9118.h | 21 + | ||
91 | include/hw/net/ne2000-isa.h | 6 + | ||
92 | include/hw/net/smc91c111.h | 19 + | ||
93 | include/qemu/typedefs.h | 1 - | ||
94 | target/arm/cpu.h | 95 ++++- | ||
95 | target/arm/helper.h | 5 + | ||
96 | target/arm/translate.h | 3 + | ||
97 | hw/arm/aspeed.c | 13 +- | ||
98 | hw/arm/exynos4_boards.c | 3 +- | ||
99 | hw/arm/gumstix.c | 2 +- | ||
100 | hw/arm/integratorcp.c | 2 +- | ||
101 | hw/arm/kzm.c | 2 +- | ||
102 | hw/arm/mainstone.c | 2 +- | ||
103 | hw/arm/mps2-tz.c | 3 +- | ||
104 | hw/arm/mps2.c | 2 +- | ||
105 | hw/arm/nseries.c | 7 +- | ||
106 | hw/arm/palm.c | 2 +- | ||
107 | hw/arm/realview.c | 3 +- | ||
108 | hw/arm/smmu-common.c | 6 +- | ||
109 | hw/arm/smmuv3.c | 28 +- | ||
110 | hw/arm/stellaris.c | 2 +- | ||
111 | hw/arm/tosa.c | 2 +- | ||
112 | hw/arm/versatilepb.c | 2 +- | ||
113 | hw/arm/vexpress.c | 2 +- | ||
114 | hw/display/blizzard.c | 2 +- | ||
115 | hw/display/tc6393xb.c | 18 +- | ||
116 | hw/input/stellaris_input.c | 2 +- | ||
117 | hw/input/tsc2005.c | 2 +- | ||
118 | hw/input/tsc210x.c | 4 +- | ||
119 | hw/intc/armv7m_nvic.c | 261 +++++++++++++ | ||
120 | hw/misc/cbus.c | 2 +- | ||
121 | hw/net/lan9118.c | 3 +- | ||
122 | hw/net/smc91c111.c | 2 +- | ||
123 | hw/ssi/xilinx_spips.c | 6 +- | ||
124 | target/arm/cpu.c | 20 + | ||
125 | target/arm/helper.c | 873 +++++++++++++++++++++++++++++++++++++++--- | ||
126 | target/arm/machine.c | 16 + | ||
127 | target/arm/translate.c | 150 +++++++- | ||
128 | target/arm/vfp_helper.c | 8 + | ||
129 | MAINTAINERS | 7 + | ||
130 | 50 files changed, 1595 insertions(+), 235 deletions(-) | ||
131 | delete mode 100644 include/hw/devices.h | ||
132 | create mode 100644 include/hw/display/blizzard.h | ||
133 | create mode 100644 include/hw/display/tc6393xb.h | ||
134 | create mode 100644 include/hw/input/gamepad.h | ||
135 | create mode 100644 include/hw/input/tsc2xxx.h | ||
136 | create mode 100644 include/hw/misc/cbus.h | ||
137 | create mode 100644 include/hw/net/lan9118.h | ||
138 | create mode 100644 include/hw/net/smc91c111.h | ||
139 | 43 | ||
44 | Peter Maydell (37): | ||
45 | target/arm: Note that we handle VMOVL as a special case of VSHLL | ||
46 | target/arm: Print MVE VPR in CPU dumps | ||
47 | target/arm: Fix MVE VSLI by 0 and VSRI by <dt> | ||
48 | target/arm: Fix signed VADDV | ||
49 | target/arm: Fix mask handling for MVE narrowing operations | ||
50 | target/arm: Fix 48-bit saturating shifts | ||
51 | target/arm: Fix MVE 48-bit SQRSHRL for small right shifts | ||
52 | target/arm: Fix calculation of LTP mask when LR is 0 | ||
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 | ||
82 | |||
83 | Sebastian Meyer (1): | ||
84 | docs: Document how to use gdb with unix sockets | ||
85 | |||
86 | Wen, Jianxian (1): | ||
87 | hw/dma/pl330: Add memory region to replace default | ||
88 | |||
89 | docs/system/gdb.rst | 26 +- | ||
90 | include/hw/arm/fsl-imx7.h | 5 + | ||
91 | target/arm/cpu.h | 1 + | ||
92 | target/arm/helper-mve.h | 283 ++++++++++ | ||
93 | target/arm/helper.h | 4 +- | ||
94 | target/arm/translate-a32.h | 2 + | ||
95 | target/arm/vec_internal.h | 11 + | ||
96 | target/arm/mve.decode | 226 +++++++- | ||
97 | target/arm/t32.decode | 1 + | ||
98 | hw/arm/exynos4210.c | 3 + | ||
99 | hw/arm/fsl-imx6ul.c | 12 + | ||
100 | hw/arm/fsl-imx7.c | 7 + | ||
101 | hw/arm/sbsa-ref.c | 6 +- | ||
102 | hw/arm/xilinx_zynq.c | 3 + | ||
103 | hw/char/pl011.c | 6 + | ||
104 | hw/dma/pl330.c | 26 +- | ||
105 | target/arm/cpu.c | 3 + | ||
106 | target/arm/helper.c | 34 +- | ||
107 | target/arm/kvm.c | 17 +- | ||
108 | target/arm/m_helper.c | 4 + | ||
109 | target/arm/mve_helper.c | 1254 ++++++++++++++++++++++++++++++++++++++++++-- | ||
110 | target/arm/translate-mve.c | 877 ++++++++++++++++++++++++++++++- | ||
111 | target/arm/translate-vfp.c | 2 +- | ||
112 | target/arm/translate.c | 37 +- | ||
113 | target/arm/vec_helper.c | 14 +- | ||
114 | 25 files changed, 2746 insertions(+), 118 deletions(-) | ||
115 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 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. | ||
2 | 5 | ||
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
5 | Message-id: 20190412165416.7977-10-philmd@redhat.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | 8 | --- |
8 | include/hw/devices.h | 3 --- | 9 | target/arm/mve.decode | 2 ++ |
9 | include/hw/net/lan9118.h | 19 +++++++++++++++++++ | 10 | 1 file changed, 2 insertions(+) |
10 | hw/arm/kzm.c | 2 +- | ||
11 | hw/arm/mps2.c | 2 +- | ||
12 | hw/arm/realview.c | 1 + | ||
13 | hw/arm/vexpress.c | 2 +- | ||
14 | hw/net/lan9118.c | 2 +- | ||
15 | 7 files changed, 24 insertions(+), 7 deletions(-) | ||
16 | create mode 100644 include/hw/net/lan9118.h | ||
17 | 11 | ||
18 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 12 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
19 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/devices.h | 14 | --- a/target/arm/mve.decode |
21 | +++ b/include/hw/devices.h | 15 | +++ b/target/arm/mve.decode |
22 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h |
23 | /* smc91c111.c */ | 17 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w |
24 | void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | 18 | |
25 | 19 | # VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file | |
26 | -/* lan9118.c */ | 20 | +# Note that VMOVL is encoded as "VSHLL with a zero shift count"; we |
27 | -void lan9118_init(NICInfo *, uint32_t, qemu_irq); | 21 | +# implement it that way rather than special-casing it in the decode. |
28 | - | 22 | VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b |
29 | #endif | 23 | VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h |
30 | diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h | 24 | |
31 | new file mode 100644 | ||
32 | index XXXXXXX..XXXXXXX | ||
33 | --- /dev/null | ||
34 | +++ b/include/hw/net/lan9118.h | ||
35 | @@ -XXX,XX +XXX,XX @@ | ||
36 | +/* | ||
37 | + * SMSC LAN9118 Ethernet interface emulation | ||
38 | + * | ||
39 | + * Copyright (c) 2009 CodeSourcery, LLC. | ||
40 | + * Written by Paul Brook | ||
41 | + * | ||
42 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
43 | + * See the COPYING file in the top-level directory. | ||
44 | + */ | ||
45 | + | ||
46 | +#ifndef HW_NET_LAN9118_H | ||
47 | +#define HW_NET_LAN9118_H | ||
48 | + | ||
49 | +#include "hw/irq.h" | ||
50 | +#include "net/net.h" | ||
51 | + | ||
52 | +void lan9118_init(NICInfo *, uint32_t, qemu_irq); | ||
53 | + | ||
54 | +#endif | ||
55 | diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/hw/arm/kzm.c | ||
58 | +++ b/hw/arm/kzm.c | ||
59 | @@ -XXX,XX +XXX,XX @@ | ||
60 | #include "qemu/error-report.h" | ||
61 | #include "exec/address-spaces.h" | ||
62 | #include "net/net.h" | ||
63 | -#include "hw/devices.h" | ||
64 | +#include "hw/net/lan9118.h" | ||
65 | #include "hw/char/serial.h" | ||
66 | #include "sysemu/qtest.h" | ||
67 | |||
68 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/arm/mps2.c | ||
71 | +++ b/hw/arm/mps2.c | ||
72 | @@ -XXX,XX +XXX,XX @@ | ||
73 | #include "hw/timer/cmsdk-apb-timer.h" | ||
74 | #include "hw/timer/cmsdk-apb-dualtimer.h" | ||
75 | #include "hw/misc/mps2-scc.h" | ||
76 | -#include "hw/devices.h" | ||
77 | +#include "hw/net/lan9118.h" | ||
78 | #include "net/net.h" | ||
79 | |||
80 | typedef enum MPS2FPGAType { | ||
81 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/hw/arm/realview.c | ||
84 | +++ b/hw/arm/realview.c | ||
85 | @@ -XXX,XX +XXX,XX @@ | ||
86 | #include "hw/arm/arm.h" | ||
87 | #include "hw/arm/primecell.h" | ||
88 | #include "hw/devices.h" | ||
89 | +#include "hw/net/lan9118.h" | ||
90 | #include "hw/pci/pci.h" | ||
91 | #include "net/net.h" | ||
92 | #include "sysemu/sysemu.h" | ||
93 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/hw/arm/vexpress.c | ||
96 | +++ b/hw/arm/vexpress.c | ||
97 | @@ -XXX,XX +XXX,XX @@ | ||
98 | #include "hw/sysbus.h" | ||
99 | #include "hw/arm/arm.h" | ||
100 | #include "hw/arm/primecell.h" | ||
101 | -#include "hw/devices.h" | ||
102 | +#include "hw/net/lan9118.h" | ||
103 | #include "hw/i2c/i2c.h" | ||
104 | #include "net/net.h" | ||
105 | #include "sysemu/sysemu.h" | ||
106 | diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/hw/net/lan9118.c | ||
109 | +++ b/hw/net/lan9118.c | ||
110 | @@ -XXX,XX +XXX,XX @@ | ||
111 | #include "hw/sysbus.h" | ||
112 | #include "net/net.h" | ||
113 | #include "net/eth.h" | ||
114 | -#include "hw/devices.h" | ||
115 | +#include "hw/net/lan9118.h" | ||
116 | #include "sysemu/sysemu.h" | ||
117 | #include "hw/ptimer.h" | ||
118 | #include "qemu/log.h" | ||
119 | -- | 25 | -- |
120 | 2.20.1 | 26 | 2.20.1 |
121 | 27 | ||
122 | 28 | diff view generated by jsdifflib |
1 | Enable the FPU by default for the Cortex-M4 and Cortex-M33. | 1 | Include the MVE VPR register value in the CPU dumps produced by |
---|---|---|---|
2 | arm_cpu_dump_state() if we are printing FPU information. This | ||
3 | makes it easier to interpret debug logs when predication is | ||
4 | active. | ||
2 | 5 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20190416125744.27770-27-peter.maydell@linaro.org | ||
6 | --- | 8 | --- |
7 | target/arm/cpu.c | 8 ++++++++ | 9 | target/arm/cpu.c | 3 +++ |
8 | 1 file changed, 8 insertions(+) | 10 | 1 file changed, 3 insertions(+) |
9 | 11 | ||
10 | 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 |
11 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/target/arm/cpu.c | 14 | --- a/target/arm/cpu.c |
13 | +++ b/target/arm/cpu.c | 15 | +++ b/target/arm/cpu.c |
14 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | 16 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
15 | set_feature(&cpu->env, ARM_FEATURE_M); | 17 | i, v); |
16 | set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | 18 | } |
17 | set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | 19 | qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); |
18 | + set_feature(&cpu->env, ARM_FEATURE_VFP4); | 20 | + if (cpu_isar_feature(aa32_mve, cpu)) { |
19 | cpu->midr = 0x410fc240; /* r0p0 */ | 21 | + qemu_fprintf(f, "VPR: %08x\n", env->v7m.vpr); |
20 | cpu->pmsav7_dregion = 8; | 22 | + } |
21 | + cpu->isar.mvfr0 = 0x10110021; | 23 | } |
22 | + cpu->isar.mvfr1 = 0x11000011; | 24 | } |
23 | + cpu->isar.mvfr2 = 0x00000000; | 25 | |
24 | cpu->id_pfr0 = 0x00000030; | ||
25 | cpu->id_pfr1 = 0x00000200; | ||
26 | cpu->id_dfr0 = 0x00100000; | ||
27 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) | ||
28 | set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
29 | set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
30 | set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
31 | + set_feature(&cpu->env, ARM_FEATURE_VFP4); | ||
32 | cpu->midr = 0x410fd213; /* r0p3 */ | ||
33 | cpu->pmsav7_dregion = 16; | ||
34 | cpu->sau_sregion = 8; | ||
35 | + cpu->isar.mvfr0 = 0x10110021; | ||
36 | + cpu->isar.mvfr1 = 0x11000011; | ||
37 | + cpu->isar.mvfr2 = 0x00000040; | ||
38 | cpu->id_pfr0 = 0x00000030; | ||
39 | cpu->id_pfr1 = 0x00000210; | ||
40 | cpu->id_dfr0 = 0x00200000; | ||
41 | -- | 26 | -- |
42 | 2.20.1 | 27 | 2.20.1 |
43 | 28 | ||
44 | 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 |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 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. | ||
2 | 8 | ||
3 | This commit finally deletes "hw/devices.h". | 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.) | ||
4 | 13 | ||
5 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Message-id: 20190412165416.7977-13-philmd@redhat.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | 16 | --- |
10 | include/hw/devices.h | 11 ----------- | 17 | target/arm/mve_helper.c | 4 +++- |
11 | include/hw/net/smc91c111.h | 19 +++++++++++++++++++ | 18 | 1 file changed, 3 insertions(+), 1 deletion(-) |
12 | hw/arm/gumstix.c | 2 +- | ||
13 | hw/arm/integratorcp.c | 2 +- | ||
14 | hw/arm/mainstone.c | 2 +- | ||
15 | hw/arm/realview.c | 2 +- | ||
16 | hw/arm/versatilepb.c | 2 +- | ||
17 | hw/net/smc91c111.c | 2 +- | ||
18 | 8 files changed, 25 insertions(+), 17 deletions(-) | ||
19 | delete mode 100644 include/hw/devices.h | ||
20 | create mode 100644 include/hw/net/smc91c111.h | ||
21 | 19 | ||
22 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 20 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
23 | deleted file mode 100644 | ||
24 | index XXXXXXX..XXXXXXX | ||
25 | --- a/include/hw/devices.h | ||
26 | +++ /dev/null | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | -#ifndef QEMU_DEVICES_H | ||
29 | -#define QEMU_DEVICES_H | ||
30 | - | ||
31 | -/* Devices that have nowhere better to go. */ | ||
32 | - | ||
33 | -#include "hw/hw.h" | ||
34 | - | ||
35 | -/* smc91c111.c */ | ||
36 | -void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | ||
37 | - | ||
38 | -#endif | ||
39 | diff --git a/include/hw/net/smc91c111.h b/include/hw/net/smc91c111.h | ||
40 | new file mode 100644 | ||
41 | index XXXXXXX..XXXXXXX | ||
42 | --- /dev/null | ||
43 | +++ b/include/hw/net/smc91c111.h | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | +/* | ||
46 | + * SMSC 91C111 Ethernet interface emulation | ||
47 | + * | ||
48 | + * Copyright (c) 2005 CodeSourcery, LLC. | ||
49 | + * Written by Paul Brook | ||
50 | + * | ||
51 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
52 | + * See the COPYING file in the top-level directory. | ||
53 | + */ | ||
54 | + | ||
55 | +#ifndef HW_NET_SMC91C111_H | ||
56 | +#define HW_NET_SMC91C111_H | ||
57 | + | ||
58 | +#include "hw/irq.h" | ||
59 | +#include "net/net.h" | ||
60 | + | ||
61 | +void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | ||
62 | + | ||
63 | +#endif | ||
64 | diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/hw/arm/gumstix.c | 22 | --- a/target/arm/mve_helper.c |
67 | +++ b/hw/arm/gumstix.c | 23 | +++ b/target/arm/mve_helper.c |
68 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ DO_VSHLL_ALL(vshllt, true) |
69 | #include "hw/arm/pxa.h" | 25 | TYPE *d = vd; \ |
70 | #include "net/net.h" | 26 | uint16_t mask = mve_element_mask(env); \ |
71 | #include "hw/block/flash.h" | 27 | unsigned le; \ |
72 | -#include "hw/devices.h" | 28 | + mask >>= ESIZE * TOP; \ |
73 | +#include "hw/net/smc91c111.h" | 29 | for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ |
74 | #include "hw/boards.h" | 30 | TYPE r = FN(m[H##LESIZE(le)], shift); \ |
75 | #include "exec/address-spaces.h" | 31 | mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ |
76 | #include "sysemu/qtest.h" | 32 | @@ -XXX,XX +XXX,XX @@ static inline int32_t do_sat_bhs(int64_t val, int64_t min, int64_t max, |
77 | diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c | 33 | uint16_t mask = mve_element_mask(env); \ |
78 | index XXXXXXX..XXXXXXX 100644 | 34 | bool qc = false; \ |
79 | --- a/hw/arm/integratorcp.c | 35 | unsigned le; \ |
80 | +++ b/hw/arm/integratorcp.c | 36 | + mask >>= ESIZE * TOP; \ |
81 | @@ -XXX,XX +XXX,XX @@ | 37 | for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ |
82 | #include "qemu-common.h" | 38 | bool sat = false; \ |
83 | #include "cpu.h" | 39 | TYPE r = FN(m[H##LESIZE(le)], shift, &sat); \ |
84 | #include "hw/sysbus.h" | 40 | mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ |
85 | -#include "hw/devices.h" | 41 | - qc |= sat && (mask & 1 << (TOP * ESIZE)); \ |
86 | #include "hw/boards.h" | 42 | + qc |= sat & mask & 1; \ |
87 | #include "hw/arm/arm.h" | 43 | } \ |
88 | #include "hw/misc/arm_integrator_debug.h" | 44 | if (qc) { \ |
89 | +#include "hw/net/smc91c111.h" | 45 | env->vfp.qc[0] = qc; \ |
90 | #include "net/net.h" | ||
91 | #include "exec/address-spaces.h" | ||
92 | #include "sysemu/sysemu.h" | ||
93 | diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/hw/arm/mainstone.c | ||
96 | +++ b/hw/arm/mainstone.c | ||
97 | @@ -XXX,XX +XXX,XX @@ | ||
98 | #include "hw/arm/pxa.h" | ||
99 | #include "hw/arm/arm.h" | ||
100 | #include "net/net.h" | ||
101 | -#include "hw/devices.h" | ||
102 | +#include "hw/net/smc91c111.h" | ||
103 | #include "hw/boards.h" | ||
104 | #include "hw/block/flash.h" | ||
105 | #include "hw/sysbus.h" | ||
106 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/hw/arm/realview.c | ||
109 | +++ b/hw/arm/realview.c | ||
110 | @@ -XXX,XX +XXX,XX @@ | ||
111 | #include "hw/sysbus.h" | ||
112 | #include "hw/arm/arm.h" | ||
113 | #include "hw/arm/primecell.h" | ||
114 | -#include "hw/devices.h" | ||
115 | #include "hw/net/lan9118.h" | ||
116 | +#include "hw/net/smc91c111.h" | ||
117 | #include "hw/pci/pci.h" | ||
118 | #include "net/net.h" | ||
119 | #include "sysemu/sysemu.h" | ||
120 | diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/hw/arm/versatilepb.c | ||
123 | +++ b/hw/arm/versatilepb.c | ||
124 | @@ -XXX,XX +XXX,XX @@ | ||
125 | #include "cpu.h" | ||
126 | #include "hw/sysbus.h" | ||
127 | #include "hw/arm/arm.h" | ||
128 | -#include "hw/devices.h" | ||
129 | +#include "hw/net/smc91c111.h" | ||
130 | #include "net/net.h" | ||
131 | #include "sysemu/sysemu.h" | ||
132 | #include "hw/pci/pci.h" | ||
133 | diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/hw/net/smc91c111.c | ||
136 | +++ b/hw/net/smc91c111.c | ||
137 | @@ -XXX,XX +XXX,XX @@ | ||
138 | #include "qemu/osdep.h" | ||
139 | #include "hw/sysbus.h" | ||
140 | #include "net/net.h" | ||
141 | -#include "hw/devices.h" | ||
142 | +#include "hw/net/smc91c111.h" | ||
143 | #include "qemu/log.h" | ||
144 | /* For crc32 */ | ||
145 | #include <zlib.h> | ||
146 | -- | 46 | -- |
147 | 2.20.1 | 47 | 2.20.1 |
148 | 48 | ||
149 | 49 | diff view generated by jsdifflib |
1 | We are close to running out of TB flags for AArch32; we could | 1 | In do_sqrshl48_d() and do_uqrshl48_d() we got some of the edge |
---|---|---|---|
2 | start using the cs_base word, but before we do that we can | 2 | cases wrong and failed to saturate correctly: |
3 | economise on our usage by sharing the same bits for the VFP | 3 | |
4 | VECSTRIDE field and the XScale XSCALE_CPAR field. This | 4 | (1) In do_sqrshl48_d() we used the same code that do_shrshl_bhs() |
5 | works because no XScale CPU ever had VFP. | 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. | ||
6 | 20 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20190416125744.27770-18-peter.maydell@linaro.org | ||
10 | --- | 23 | --- |
11 | target/arm/cpu.h | 10 ++++++---- | 24 | target/arm/mve_helper.c | 12 +++++------- |
12 | target/arm/cpu.c | 7 +++++++ | 25 | 1 file changed, 5 insertions(+), 7 deletions(-) |
13 | target/arm/helper.c | 6 +++++- | ||
14 | target/arm/translate.c | 9 +++++++-- | ||
15 | 4 files changed, 25 insertions(+), 7 deletions(-) | ||
16 | 26 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 27 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 29 | --- a/target/arm/mve_helper.c |
20 | +++ b/target/arm/cpu.h | 30 | +++ b/target/arm/mve_helper.c |
21 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1) | 31 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, |
22 | FIELD(TBFLAG_A32, THUMB, 0, 1) | 32 | } |
23 | FIELD(TBFLAG_A32, VECLEN, 1, 3) | 33 | return src >> -shift; |
24 | FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) | 34 | } else if (shift < 48) { |
25 | +/* | 35 | - int64_t val = src << shift; |
26 | + * We store the bottom two bits of the CPAR as TB flags and handle | 36 | - int64_t extval = sextract64(val, 0, 48); |
27 | + * checks on the other bits at runtime. This shares the same bits as | 37 | - if (!sat || val == extval) { |
28 | + * VECSTRIDE, which is OK as no XScale CPU has VFP. | 38 | + int64_t extval = sextract64(src << shift, 0, 48); |
29 | + */ | 39 | + if (!sat || src == (extval >> shift)) { |
30 | +FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2) | 40 | return extval; |
31 | /* | 41 | } |
32 | * Indicates whether cp register reads and writes by guest code should access | 42 | } else if (!sat || src == 0) { |
33 | * the secure or nonsecure bank of banked registers; note that this is not | 43 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, |
34 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | ||
35 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | ||
36 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | ||
37 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | ||
38 | -/* We store the bottom two bits of the CPAR as TB flags and handle | ||
39 | - * checks on the other bits at runtime | ||
40 | - */ | ||
41 | -FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2) | ||
42 | /* For M profile only, Handler (ie not Thread) mode */ | ||
43 | FIELD(TBFLAG_A32, HANDLER, 21, 1) | ||
44 | /* For M profile only, whether we should generate stack-limit checks */ | ||
45 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/cpu.c | ||
48 | +++ b/target/arm/cpu.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
50 | set_feature(env, ARM_FEATURE_THUMB_DSP); | ||
51 | } | 44 | } |
52 | 45 | ||
53 | + /* | 46 | *sat = 1; |
54 | + * We rely on no XScale CPU having VFP so we can use the same bits in the | 47 | - return (1ULL << 47) - (src >= 0); |
55 | + * TB flags field for VECSTRIDE and XSCALE_CPAR. | 48 | + return src >= 0 ? MAKE_64BIT_MASK(0, 47) : MAKE_64BIT_MASK(47, 17); |
56 | + */ | 49 | } |
57 | + assert(!(arm_feature(env, ARM_FEATURE_VFP) && | 50 | |
58 | + arm_feature(env, ARM_FEATURE_XSCALE))); | 51 | /* Operate on 64-bit values, but saturate at 48 bits */ |
59 | + | 52 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t do_uqrshl48_d(uint64_t src, int64_t shift, |
60 | if (arm_feature(env, ARM_FEATURE_V7) && | 53 | return extval; |
61 | !arm_feature(env, ARM_FEATURE_M) && | ||
62 | !arm_feature(env, ARM_FEATURE_PMSA)) { | ||
63 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/helper.c | ||
66 | +++ b/target/arm/helper.c | ||
67 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
68 | || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { | ||
69 | flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
70 | } | 54 | } |
71 | - flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar); | 55 | } else if (shift < 48) { |
72 | + /* Note that XSCALE_CPAR shares bits with VECSTRIDE */ | 56 | - uint64_t val = src << shift; |
73 | + if (arm_feature(env, ARM_FEATURE_XSCALE)) { | 57 | - uint64_t extval = extract64(val, 0, 48); |
74 | + flags = FIELD_DP32(flags, TBFLAG_A32, | 58 | - if (!sat || val == extval) { |
75 | + XSCALE_CPAR, env->cp15.c15_cpar); | 59 | + uint64_t extval = extract64(src << shift, 0, 48); |
76 | + } | 60 | + if (!sat || src == (extval >> shift)) { |
77 | } | 61 | return extval; |
78 | 62 | } | |
79 | flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); | 63 | } else if (!sat || src == 0) { |
80 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/arm/translate.c | ||
83 | +++ b/target/arm/translate.c | ||
84 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
85 | dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL); | ||
86 | dc->vfp_enabled = FIELD_EX32(tb_flags, TBFLAG_A32, VFPEN); | ||
87 | dc->vec_len = FIELD_EX32(tb_flags, TBFLAG_A32, VECLEN); | ||
88 | - dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE); | ||
89 | - dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR); | ||
90 | + if (arm_feature(env, ARM_FEATURE_XSCALE)) { | ||
91 | + dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR); | ||
92 | + dc->vec_stride = 0; | ||
93 | + } else { | ||
94 | + dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE); | ||
95 | + dc->c15_cpar = 0; | ||
96 | + } | ||
97 | dc->v7m_handler_mode = FIELD_EX32(tb_flags, TBFLAG_A32, HANDLER); | ||
98 | dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
99 | regime_is_secure(env, dc->mmu_idx); | ||
100 | -- | 64 | -- |
101 | 2.20.1 | 65 | 2.20.1 |
102 | 66 | ||
103 | 67 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 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. | ||
2 | 6 | ||
3 | Since uWireSlave is only used in this new header, there is no | 7 | Handle this similarly to the way we already do for this case in |
4 | need to expose it via "qemu/typedefs.h". | 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. | ||
5 | 11 | ||
6 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190412165416.7977-9-philmd@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | 14 | --- |
11 | include/hw/arm/omap.h | 6 +----- | 15 | target/arm/mve_helper.c | 11 +++++++++-- |
12 | include/hw/devices.h | 15 --------------- | 16 | 1 file changed, 9 insertions(+), 2 deletions(-) |
13 | include/hw/input/tsc2xxx.h | 36 ++++++++++++++++++++++++++++++++++++ | ||
14 | include/qemu/typedefs.h | 1 - | ||
15 | hw/arm/nseries.c | 2 +- | ||
16 | hw/arm/palm.c | 2 +- | ||
17 | hw/input/tsc2005.c | 2 +- | ||
18 | hw/input/tsc210x.c | 4 ++-- | ||
19 | MAINTAINERS | 2 ++ | ||
20 | 9 files changed, 44 insertions(+), 26 deletions(-) | ||
21 | create mode 100644 include/hw/input/tsc2xxx.h | ||
22 | 17 | ||
23 | diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h | 18 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
24 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/arm/omap.h | 20 | --- a/target/arm/mve_helper.c |
26 | +++ b/include/hw/arm/omap.h | 21 | +++ b/target/arm/mve_helper.c |
27 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqrshll)(CPUARMState *env, uint64_t n, uint32_t shift) |
28 | #include "exec/memory.h" | 23 | static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, |
29 | # define hw_omap_h "omap.h" | 24 | bool round, uint32_t *sat) |
30 | #include "hw/irq.h" | 25 | { |
31 | +#include "hw/input/tsc2xxx.h" | 26 | + int64_t val, extval; |
32 | #include "target/arm/cpu-qom.h" | ||
33 | #include "qemu/log.h" | ||
34 | |||
35 | @@ -XXX,XX +XXX,XX @@ qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s); | ||
36 | void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler); | ||
37 | void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down); | ||
38 | |||
39 | -struct uWireSlave { | ||
40 | - uint16_t (*receive)(void *opaque); | ||
41 | - void (*send)(void *opaque, uint16_t data); | ||
42 | - void *opaque; | ||
43 | -}; | ||
44 | struct omap_uwire_s; | ||
45 | void omap_uwire_attach(struct omap_uwire_s *s, | ||
46 | uWireSlave *slave, int chipselect); | ||
47 | diff --git a/include/hw/devices.h b/include/hw/devices.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/include/hw/devices.h | ||
50 | +++ b/include/hw/devices.h | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | /* Devices that have nowhere better to go. */ | ||
53 | |||
54 | #include "hw/hw.h" | ||
55 | -#include "ui/console.h" | ||
56 | |||
57 | /* smc91c111.c */ | ||
58 | void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | ||
59 | @@ -XXX,XX +XXX,XX @@ void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | ||
60 | /* lan9118.c */ | ||
61 | void lan9118_init(NICInfo *, uint32_t, qemu_irq); | ||
62 | |||
63 | -/* tsc210x.c */ | ||
64 | -uWireSlave *tsc2102_init(qemu_irq pint); | ||
65 | -uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav); | ||
66 | -I2SCodec *tsc210x_codec(uWireSlave *chip); | ||
67 | -uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len); | ||
68 | -void tsc210x_set_transform(uWireSlave *chip, | ||
69 | - MouseTransformInfo *info); | ||
70 | -void tsc210x_key_event(uWireSlave *chip, int key, int down); | ||
71 | - | ||
72 | -/* tsc2005.c */ | ||
73 | -void *tsc2005_init(qemu_irq pintdav); | ||
74 | -uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); | ||
75 | -void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | ||
76 | - | ||
77 | #endif | ||
78 | diff --git a/include/hw/input/tsc2xxx.h b/include/hw/input/tsc2xxx.h | ||
79 | new file mode 100644 | ||
80 | index XXXXXXX..XXXXXXX | ||
81 | --- /dev/null | ||
82 | +++ b/include/hw/input/tsc2xxx.h | ||
83 | @@ -XXX,XX +XXX,XX @@ | ||
84 | +/* | ||
85 | + * TI touchscreen controller | ||
86 | + * | ||
87 | + * Copyright (c) 2006 Andrzej Zaborowski | ||
88 | + * Copyright (C) 2008 Nokia Corporation | ||
89 | + * | ||
90 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
91 | + * See the COPYING file in the top-level directory. | ||
92 | + */ | ||
93 | + | 27 | + |
94 | +#ifndef HW_INPUT_TSC2XXX_H | 28 | if (shift <= -48) { |
95 | +#define HW_INPUT_TSC2XXX_H | 29 | /* Rounding the sign bit always produces 0. */ |
96 | + | 30 | if (round) { |
97 | +#include "hw/irq.h" | 31 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, |
98 | +#include "ui/console.h" | 32 | } else if (shift < 0) { |
99 | + | 33 | if (round) { |
100 | +typedef struct uWireSlave { | 34 | src >>= -shift - 1; |
101 | + uint16_t (*receive)(void *opaque); | 35 | - return (src >> 1) + (src & 1); |
102 | + void (*send)(void *opaque, uint16_t data); | 36 | + val = (src >> 1) + (src & 1); |
103 | + void *opaque; | 37 | + } else { |
104 | +} uWireSlave; | 38 | + val = src >> -shift; |
105 | + | 39 | + } |
106 | +/* tsc210x.c */ | 40 | + extval = sextract64(val, 0, 48); |
107 | +uWireSlave *tsc2102_init(qemu_irq pint); | 41 | + if (!sat || val == extval) { |
108 | +uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav); | 42 | + return extval; |
109 | +I2SCodec *tsc210x_codec(uWireSlave *chip); | 43 | } |
110 | +uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len); | 44 | - return src >> -shift; |
111 | +void tsc210x_set_transform(uWireSlave *chip, MouseTransformInfo *info); | 45 | } else if (shift < 48) { |
112 | +void tsc210x_key_event(uWireSlave *chip, int key, int down); | 46 | int64_t extval = sextract64(src << shift, 0, 48); |
113 | + | 47 | if (!sat || src == (extval >> shift)) { |
114 | +/* tsc2005.c */ | ||
115 | +void *tsc2005_init(qemu_irq pintdav); | ||
116 | +uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); | ||
117 | +void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | ||
118 | + | ||
119 | +#endif | ||
120 | diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/include/qemu/typedefs.h | ||
123 | +++ b/include/qemu/typedefs.h | ||
124 | @@ -XXX,XX +XXX,XX @@ typedef struct RAMBlock RAMBlock; | ||
125 | typedef struct Range Range; | ||
126 | typedef struct SHPCDevice SHPCDevice; | ||
127 | typedef struct SSIBus SSIBus; | ||
128 | -typedef struct uWireSlave uWireSlave; | ||
129 | typedef struct VirtIODevice VirtIODevice; | ||
130 | typedef struct Visitor Visitor; | ||
131 | typedef void SaveStateHandler(QEMUFile *f, void *opaque); | ||
132 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | ||
133 | index XXXXXXX..XXXXXXX 100644 | ||
134 | --- a/hw/arm/nseries.c | ||
135 | +++ b/hw/arm/nseries.c | ||
136 | @@ -XXX,XX +XXX,XX @@ | ||
137 | #include "ui/console.h" | ||
138 | #include "hw/boards.h" | ||
139 | #include "hw/i2c/i2c.h" | ||
140 | -#include "hw/devices.h" | ||
141 | #include "hw/display/blizzard.h" | ||
142 | +#include "hw/input/tsc2xxx.h" | ||
143 | #include "hw/misc/cbus.h" | ||
144 | #include "hw/misc/tmp105.h" | ||
145 | #include "hw/block/flash.h" | ||
146 | diff --git a/hw/arm/palm.c b/hw/arm/palm.c | ||
147 | index XXXXXXX..XXXXXXX 100644 | ||
148 | --- a/hw/arm/palm.c | ||
149 | +++ b/hw/arm/palm.c | ||
150 | @@ -XXX,XX +XXX,XX @@ | ||
151 | #include "hw/arm/omap.h" | ||
152 | #include "hw/boards.h" | ||
153 | #include "hw/arm/arm.h" | ||
154 | -#include "hw/devices.h" | ||
155 | +#include "hw/input/tsc2xxx.h" | ||
156 | #include "hw/loader.h" | ||
157 | #include "exec/address-spaces.h" | ||
158 | #include "cpu.h" | ||
159 | diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c | ||
160 | index XXXXXXX..XXXXXXX 100644 | ||
161 | --- a/hw/input/tsc2005.c | ||
162 | +++ b/hw/input/tsc2005.c | ||
163 | @@ -XXX,XX +XXX,XX @@ | ||
164 | #include "hw/hw.h" | ||
165 | #include "qemu/timer.h" | ||
166 | #include "ui/console.h" | ||
167 | -#include "hw/devices.h" | ||
168 | +#include "hw/input/tsc2xxx.h" | ||
169 | #include "trace.h" | ||
170 | |||
171 | #define TSC_CUT_RESOLUTION(value, p) ((value) >> (16 - (p ? 12 : 10))) | ||
172 | diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c | ||
173 | index XXXXXXX..XXXXXXX 100644 | ||
174 | --- a/hw/input/tsc210x.c | ||
175 | +++ b/hw/input/tsc210x.c | ||
176 | @@ -XXX,XX +XXX,XX @@ | ||
177 | #include "audio/audio.h" | ||
178 | #include "qemu/timer.h" | ||
179 | #include "ui/console.h" | ||
180 | -#include "hw/arm/omap.h" /* For I2SCodec and uWireSlave */ | ||
181 | -#include "hw/devices.h" | ||
182 | +#include "hw/arm/omap.h" /* For I2SCodec */ | ||
183 | +#include "hw/input/tsc2xxx.h" | ||
184 | |||
185 | #define TSC_DATA_REGISTERS_PAGE 0x0 | ||
186 | #define TSC_CONTROL_REGISTERS_PAGE 0x1 | ||
187 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
188 | index XXXXXXX..XXXXXXX 100644 | ||
189 | --- a/MAINTAINERS | ||
190 | +++ b/MAINTAINERS | ||
191 | @@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c | ||
192 | F: hw/misc/cbus.c | ||
193 | F: hw/timer/twl92230.c | ||
194 | F: include/hw/display/blizzard.h | ||
195 | +F: include/hw/input/tsc2xxx.h | ||
196 | F: include/hw/misc/cbus.h | ||
197 | |||
198 | Palm | ||
199 | @@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org | ||
200 | S: Odd Fixes | ||
201 | F: hw/arm/palm.c | ||
202 | F: hw/input/tsc210x.c | ||
203 | +F: include/hw/input/tsc2xxx.h | ||
204 | |||
205 | Raspberry Pi | ||
206 | M: Peter Maydell <peter.maydell@linaro.org> | ||
207 | -- | 48 | -- |
208 | 2.20.1 | 49 | 2.20.1 |
209 | 50 | ||
210 | 51 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 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. | ||
2 | 6 | ||
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
5 | Message-id: 20190412165416.7977-8-philmd@redhat.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | 9 | --- |
8 | include/hw/devices.h | 3 --- | 10 | target/arm/mve_helper.c | 3 ++- |
9 | include/hw/input/gamepad.h | 19 +++++++++++++++++++ | 11 | 1 file changed, 2 insertions(+), 1 deletion(-) |
10 | hw/arm/stellaris.c | 2 +- | ||
11 | hw/input/stellaris_input.c | 2 +- | ||
12 | MAINTAINERS | 1 + | ||
13 | 5 files changed, 22 insertions(+), 5 deletions(-) | ||
14 | create mode 100644 include/hw/input/gamepad.h | ||
15 | 12 | ||
16 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 13 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/devices.h | 15 | --- a/target/arm/mve_helper.c |
19 | +++ b/include/hw/devices.h | 16 | +++ b/target/arm/mve_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ void *tsc2005_init(qemu_irq pintdav); | 17 | @@ -XXX,XX +XXX,XX @@ static uint16_t mve_element_mask(CPUARMState *env) |
21 | uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); | 18 | */ |
22 | void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | 19 | int masklen = env->regs[14] << env->v7m.ltpsize; |
23 | 20 | assert(masklen <= 16); | |
24 | -/* stellaris_input.c */ | 21 | - mask &= MAKE_64BIT_MASK(0, masklen); |
25 | -void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | 22 | + uint16_t ltpmask = masklen ? MAKE_64BIT_MASK(0, masklen) : 0; |
26 | - | 23 | + mask &= ltpmask; |
27 | #endif | 24 | } |
28 | diff --git a/include/hw/input/gamepad.h b/include/hw/input/gamepad.h | 25 | |
29 | new file mode 100644 | 26 | if ((env->condexec_bits & 0xf) == 0) { |
30 | index XXXXXXX..XXXXXXX | ||
31 | --- /dev/null | ||
32 | +++ b/include/hw/input/gamepad.h | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | +/* | ||
35 | + * Gamepad style buttons connected to IRQ/GPIO lines | ||
36 | + * | ||
37 | + * Copyright (c) 2007 CodeSourcery. | ||
38 | + * Written by Paul Brook | ||
39 | + * | ||
40 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
41 | + * See the COPYING file in the top-level directory. | ||
42 | + */ | ||
43 | + | ||
44 | +#ifndef HW_INPUT_GAMEPAD_H | ||
45 | +#define HW_INPUT_GAMEPAD_H | ||
46 | + | ||
47 | +#include "hw/irq.h" | ||
48 | + | ||
49 | +/* stellaris_input.c */ | ||
50 | +void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | ||
51 | + | ||
52 | +#endif | ||
53 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/arm/stellaris.c | ||
56 | +++ b/hw/arm/stellaris.c | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | #include "hw/sysbus.h" | ||
59 | #include "hw/ssi/ssi.h" | ||
60 | #include "hw/arm/arm.h" | ||
61 | -#include "hw/devices.h" | ||
62 | #include "qemu/timer.h" | ||
63 | #include "hw/i2c/i2c.h" | ||
64 | #include "net/net.h" | ||
65 | @@ -XXX,XX +XXX,XX @@ | ||
66 | #include "sysemu/sysemu.h" | ||
67 | #include "hw/arm/armv7m.h" | ||
68 | #include "hw/char/pl011.h" | ||
69 | +#include "hw/input/gamepad.h" | ||
70 | #include "hw/watchdog/cmsdk-apb-watchdog.h" | ||
71 | #include "hw/misc/unimp.h" | ||
72 | #include "cpu.h" | ||
73 | diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/hw/input/stellaris_input.c | ||
76 | +++ b/hw/input/stellaris_input.c | ||
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | */ | ||
79 | #include "qemu/osdep.h" | ||
80 | #include "hw/hw.h" | ||
81 | -#include "hw/devices.h" | ||
82 | +#include "hw/input/gamepad.h" | ||
83 | #include "ui/console.h" | ||
84 | |||
85 | typedef struct { | ||
86 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/MAINTAINERS | ||
89 | +++ b/MAINTAINERS | ||
90 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | ||
91 | L: qemu-arm@nongnu.org | ||
92 | S: Maintained | ||
93 | F: hw/*/stellaris* | ||
94 | +F: include/hw/input/gamepad.h | ||
95 | |||
96 | Versatile Express | ||
97 | M: Peter Maydell <peter.maydell@linaro.org> | ||
98 | -- | 27 | -- |
99 | 2.20.1 | 28 | 2.20.1 |
100 | 29 | ||
101 | 30 | diff view generated by jsdifflib |
1 | Like AArch64, M-profile floating point has no FPEXC enable | 1 | In some situations we need a mask telling us which parts of the |
---|---|---|---|
2 | bit to gate floating point; so always set the VFPEN TB flag. | 2 | vector correspond to beats that are not being executed because of |
3 | 3 | ECI, separately from the combined "which bytes are predicated away" | |
4 | M-profile also has CPACR and NSACR similar to A-profile; | 4 | mask. Factor this mask calculation out of mve_element_mask() into |
5 | they behave slightly differently: | 5 | its own function. |
6 | * the CPACR is banked between Secure and Non-Secure | ||
7 | * if the NSACR forces a trap then this is taken to | ||
8 | the Secure state, not the Non-Secure state | ||
9 | |||
10 | Honour the CPACR and NSACR settings. The NSACR handling | ||
11 | requires us to borrow the exception.target_el field | ||
12 | (usually meaningless for M profile) to distinguish the | ||
13 | NOCP UsageFault taken to Secure state from the more | ||
14 | usual fault taken to the current security state. | ||
15 | 6 | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
18 | Message-id: 20190416125744.27770-6-peter.maydell@linaro.org | ||
19 | --- | 9 | --- |
20 | target/arm/helper.c | 55 +++++++++++++++++++++++++++++++++++++++--- | 10 | target/arm/mve_helper.c | 58 ++++++++++++++++++++++++----------------- |
21 | target/arm/translate.c | 10 ++++++-- | 11 | 1 file changed, 34 insertions(+), 24 deletions(-) |
22 | 2 files changed, 60 insertions(+), 5 deletions(-) | ||
23 | 12 | ||
24 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
25 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/helper.c | 15 | --- a/target/arm/mve_helper.c |
27 | +++ b/target/arm/helper.c | 16 | +++ b/target/arm/mve_helper.c |
28 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | 17 | @@ -XXX,XX +XXX,XX @@ |
29 | return target_el; | 18 | #include "exec/exec-all.h" |
30 | } | 19 | #include "tcg/tcg.h" |
31 | 20 | ||
32 | +/* | 21 | +static uint16_t mve_eci_mask(CPUARMState *env) |
33 | + * Return true if the v7M CPACR permits access to the FPU for the specified | ||
34 | + * security state and privilege level. | ||
35 | + */ | ||
36 | +static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv) | ||
37 | +{ | 22 | +{ |
38 | + switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) { | 23 | + /* |
39 | + case 0: | 24 | + * Return the mask of which elements in the MVE vector correspond |
40 | + case 2: /* UNPREDICTABLE: we treat like 0 */ | 25 | + * to beats being executed. The mask has 1 bits for executed lanes |
41 | + return false; | 26 | + * and 0 bits where ECI says this beat was already executed. |
42 | + case 1: | 27 | + */ |
43 | + return is_priv; | 28 | + int eci; |
44 | + case 3: | 29 | + |
45 | + return true; | 30 | + if ((env->condexec_bits & 0xf) != 0) { |
31 | + return 0xffff; | ||
32 | + } | ||
33 | + | ||
34 | + eci = env->condexec_bits >> 4; | ||
35 | + switch (eci) { | ||
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; | ||
46 | + default: | 45 | + default: |
47 | + g_assert_not_reached(); | 46 | + g_assert_not_reached(); |
48 | + } | 47 | + } |
49 | +} | 48 | +} |
50 | + | 49 | + |
51 | static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | 50 | static uint16_t mve_element_mask(CPUARMState *env) |
52 | ARMMMUIdx mmu_idx, bool ignfault) | ||
53 | { | 51 | { |
54 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 52 | /* |
55 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK; | 53 | @@ -XXX,XX +XXX,XX @@ static uint16_t mve_element_mask(CPUARMState *env) |
56 | break; | 54 | mask &= ltpmask; |
57 | case EXCP_NOCP: | ||
58 | - armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
59 | - env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK; | ||
60 | + { | ||
61 | + /* | ||
62 | + * NOCP might be directed to something other than the current | ||
63 | + * security state if this fault is because of NSACR; we indicate | ||
64 | + * the target security state using exception.target_el. | ||
65 | + */ | ||
66 | + int target_secstate; | ||
67 | + | ||
68 | + if (env->exception.target_el == 3) { | ||
69 | + target_secstate = M_REG_S; | ||
70 | + } else { | ||
71 | + target_secstate = env->v7m.secure; | ||
72 | + } | ||
73 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, target_secstate); | ||
74 | + env->v7m.cfsr[target_secstate] |= R_V7M_CFSR_NOCP_MASK; | ||
75 | break; | ||
76 | + } | ||
77 | case EXCP_INVSTATE: | ||
78 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
79 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK; | ||
80 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | ||
81 | return 0; | ||
82 | } | 55 | } |
83 | 56 | ||
84 | + if (arm_feature(env, ARM_FEATURE_M)) { | 57 | - if ((env->condexec_bits & 0xf) == 0) { |
85 | + /* CPACR can cause a NOCP UsageFault taken to current security state */ | 58 | - /* |
86 | + if (!v7m_cpacr_pass(env, env->v7m.secure, cur_el != 0)) { | 59 | - * ECI bits indicate which beats are already executed; |
87 | + return 1; | 60 | - * we handle this by effectively predicating them out. |
88 | + } | 61 | - */ |
89 | + | 62 | - int eci = env->condexec_bits >> 4; |
90 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY) && !env->v7m.secure) { | 63 | - switch (eci) { |
91 | + if (!extract32(env->v7m.nsacr, 10, 1)) { | 64 | - case ECI_NONE: |
92 | + /* FP insns cause a NOCP UsageFault taken to Secure */ | 65 | - break; |
93 | + return 3; | 66 | - case ECI_A0: |
94 | + } | 67 | - mask &= 0xfff0; |
95 | + } | 68 | - break; |
96 | + | 69 | - case ECI_A0A1: |
97 | + return 0; | 70 | - mask &= 0xff00; |
98 | + } | 71 | - break; |
99 | + | 72 | - case ECI_A0A1A2: |
100 | /* The CPACR controls traps to EL1, or PL1 if we're 32 bit: | 73 | - case ECI_A0A1A2B0: |
101 | * 0, 2 : trap EL0 and EL1/PL1 accesses | 74 | - mask &= 0xf000; |
102 | * 1 : trap only EL0 accesses | 75 | - break; |
103 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 76 | - default: |
104 | flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env)); | 77 | - g_assert_not_reached(); |
105 | flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env)); | 78 | - } |
106 | if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30) | 79 | - } |
107 | - || arm_el_is_aa64(env, 1)) { | 80 | - |
108 | + || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { | 81 | + /* |
109 | flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | 82 | + * ECI bits indicate which beats are already executed; |
110 | } | 83 | + * we handle this by effectively predicating them out. |
111 | flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar); | 84 | + */ |
112 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 85 | + mask &= mve_eci_mask(env); |
113 | index XXXXXXX..XXXXXXX 100644 | 86 | return mask; |
114 | --- a/target/arm/translate.c | 87 | } |
115 | +++ b/target/arm/translate.c | ||
116 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
117 | * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
118 | */ | ||
119 | if (s->fp_excp_el) { | ||
120 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
121 | - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
122 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
123 | + gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | ||
124 | + s->fp_excp_el); | ||
125 | + } else { | ||
126 | + gen_exception_insn(s, 4, EXCP_UDEF, | ||
127 | + syn_fp_access_trap(1, 0xe, false), | ||
128 | + s->fp_excp_el); | ||
129 | + } | ||
130 | return 0; | ||
131 | } | ||
132 | 88 | ||
133 | -- | 89 | -- |
134 | 2.20.1 | 90 | 2.20.1 |
135 | 91 | ||
136 | 92 | diff view generated by jsdifflib |
1 | Currently the code in v7m_push_stack() which detects a violation | 1 | We were not paying attention to the ECI state when advancing the VPT |
---|---|---|---|
2 | of the v8M stack limit simply returns early if it does so. This | 2 | state. Architecturally, VPT state advance happens for every beat |
3 | is OK for the current integer-only code, but won't work for the | 3 | (see the pseudocode VPTAdvance()), so on every beat the 4 bits of |
4 | floating point handling we're about to add. We need to continue | 4 | VPR.P0 corresponding to the current beat are inverted if required, |
5 | executing the rest of the function so that we check for other | 5 | and at the end of beats 1 and 3 the VPR MASK fields are updated. |
6 | exceptions like not having permission to use the FPU and so | 6 | This means that if the ECI state says we should not be executing all |
7 | that we correctly set the FPCCR state if we are doing lazy | 7 | 4 beats then we need to skip some of the updating of the VPR that we |
8 | stacking. Refactor to avoid the early return. | 8 | currently do in mve_advance_vpt(). |
9 | 9 | ||
10 | 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> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20190416125744.27770-10-peter.maydell@linaro.org | ||
13 | --- | 12 | --- |
14 | target/arm/helper.c | 23 ++++++++++++++++++----- | 13 | target/arm/mve_helper.c | 24 +++++++++++++++++------- |
15 | 1 file changed, 18 insertions(+), 5 deletions(-) | 14 | 1 file changed, 17 insertions(+), 7 deletions(-) |
16 | 15 | ||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 16 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.c | 18 | --- a/target/arm/mve_helper.c |
20 | +++ b/target/arm/helper.c | 19 | +++ b/target/arm/mve_helper.c |
21 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 20 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) |
22 | * should ignore further stack faults trying to process | 21 | /* Advance the VPT and ECI state if necessary */ |
23 | * that derived exception.) | 22 | uint32_t vpr = env->v7m.vpr; |
24 | */ | 23 | unsigned mask01, mask23; |
25 | - bool stacked_ok; | 24 | + uint16_t inv_mask; |
26 | + bool stacked_ok = true, limitviol = false; | 25 | + uint16_t eci_mask = mve_eci_mask(env); |
27 | CPUARMState *env = &cpu->env; | 26 | |
28 | uint32_t xpsr = xpsr_read(env); | 27 | if ((env->condexec_bits & 0xf) == 0) { |
29 | uint32_t frameptr = env->regs[13]; | 28 | env->condexec_bits = (env->condexec_bits == (ECI_A0A1A2B0 << 4)) ? |
30 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 29 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) |
31 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | 30 | return; |
32 | env->v7m.secure); | ||
33 | env->regs[13] = limit; | ||
34 | - return true; | ||
35 | + /* | ||
36 | + * We won't try to perform any further memory accesses but | ||
37 | + * we must continue through the following code to check for | ||
38 | + * permission faults during FPU state preservation, and we | ||
39 | + * must update FPCCR if lazy stacking is enabled. | ||
40 | + */ | ||
41 | + limitviol = true; | ||
42 | + stacked_ok = false; | ||
43 | } | ||
44 | } | 31 | } |
45 | 32 | ||
46 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 33 | + /* Invert P0 bits if needed, but only for beats we actually executed */ |
47 | * (which may be taken in preference to the one we started with | 34 | mask01 = FIELD_EX32(vpr, V7M_VPR, MASK01); |
48 | * if it has higher priority). | 35 | mask23 = FIELD_EX32(vpr, V7M_VPR, MASK23); |
49 | */ | 36 | - if (mask01 > 8) { |
50 | - stacked_ok = | 37 | - /* high bit set, but not 0b1000: invert the relevant half of P0 */ |
51 | + stacked_ok = stacked_ok && | 38 | - vpr ^= 0xff; |
52 | v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) && | 39 | + /* Start by assuming we invert all bits corresponding to executed beats */ |
53 | v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) && | 40 | + inv_mask = eci_mask; |
54 | v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) && | 41 | + if (mask01 <= 8) { |
55 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 42 | + /* MASK01 says don't invert low half of P0 */ |
56 | v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) && | 43 | + inv_mask &= ~0xff; |
57 | v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false); | 44 | } |
58 | 45 | - if (mask23 > 8) { | |
59 | - /* Update SP regardless of whether any of the stack accesses failed. */ | 46 | - /* high bit set, but not 0b1000: invert the relevant half of P0 */ |
60 | - env->regs[13] = frameptr; | 47 | - vpr ^= 0xff00; |
61 | + /* | 48 | + if (mask23 <= 8) { |
62 | + * If we broke a stack limit then SP was already updated earlier; | 49 | + /* MASK23 says don't invert high half of P0 */ |
63 | + * otherwise we update SP regardless of whether any of the stack | 50 | + inv_mask &= ~0xff00; |
64 | + * accesses failed or we took some other kind of fault. | 51 | } |
65 | + */ | 52 | - vpr = FIELD_DP32(vpr, V7M_VPR, MASK01, mask01 << 1); |
66 | + if (!limitviol) { | 53 | + vpr ^= inv_mask; |
67 | + env->regs[13] = frameptr; | 54 | + /* Only update MASK01 if beat 1 executed */ |
55 | + if (eci_mask & 0xf0) { | ||
56 | + vpr = FIELD_DP32(vpr, V7M_VPR, MASK01, mask01 << 1); | ||
68 | + } | 57 | + } |
69 | 58 | + /* Beat 3 always executes, so update MASK23 */ | |
70 | return !stacked_ok; | 59 | vpr = FIELD_DP32(vpr, V7M_VPR, MASK23, mask23 << 1); |
60 | env->v7m.vpr = vpr; | ||
71 | } | 61 | } |
72 | -- | 62 | -- |
73 | 2.20.1 | 63 | 2.20.1 |
74 | 64 | ||
75 | 65 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 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). | ||
2 | 7 | ||
3 | Suggested-by: Markus Armbruster <armbru@redhat.com> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
5 | Message-id: 20190412165416.7977-3-philmd@redhat.com | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | 10 | --- |
9 | hw/arm/nseries.c | 3 ++- | 11 | target/arm/mve_helper.c | 8 +++++--- |
10 | 1 file changed, 2 insertions(+), 1 deletion(-) | 12 | 1 file changed, 5 insertions(+), 3 deletions(-) |
11 | 13 | ||
12 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | 14 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/arm/nseries.c | 16 | --- a/target/arm/mve_helper.c |
15 | +++ b/hw/arm/nseries.c | 17 | +++ b/target/arm/mve_helper.c |
16 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) |
17 | #include "hw/boards.h" | 19 | env->v7m.vpr = vpr; |
18 | #include "hw/i2c/i2c.h" | ||
19 | #include "hw/devices.h" | ||
20 | +#include "hw/misc/tmp105.h" | ||
21 | #include "hw/block/flash.h" | ||
22 | #include "hw/hw.h" | ||
23 | #include "hw/bt.h" | ||
24 | @@ -XXX,XX +XXX,XX @@ static void n8x0_i2c_setup(struct n800_s *s) | ||
25 | qemu_register_powerdown_notifier(&n8x0_system_powerdown_notifier); | ||
26 | |||
27 | /* Attach a TMP105 PM chip (A0 wired to ground) */ | ||
28 | - dev = i2c_create_slave(i2c, "tmp105", N8X0_TMP105_ADDR); | ||
29 | + dev = i2c_create_slave(i2c, TYPE_TMP105, N8X0_TMP105_ADDR); | ||
30 | qdev_connect_gpio_out(dev, 0, tmp_irq); | ||
31 | } | 20 | } |
32 | 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 | } \ | ||
33 | -- | 45 | -- |
34 | 2.20.1 | 46 | 2.20.1 |
35 | 47 | ||
36 | 48 | diff view generated by jsdifflib |
1 | The magic value pushed onto the callee stack as an integrity | 1 | Implement the MVE VMULL (polynomial) insn. Unlike Neon, this comes |
---|---|---|---|
2 | check is different if floating point is present. | 2 | in two flavours: 8x8->16 and a 16x16->32. Also unlike Neon, the |
3 | inputs are in either the low or the high half of each double-width | ||
4 | element. | ||
5 | |||
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. | ||
3 | 13 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20190416125744.27770-15-peter.maydell@linaro.org | ||
7 | --- | 16 | --- |
8 | target/arm/helper.c | 22 +++++++++++++++++++--- | 17 | target/arm/helper-mve.h | 5 +++++ |
9 | 1 file changed, 19 insertions(+), 3 deletions(-) | 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(-) | ||
10 | 24 | ||
11 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 25 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
12 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/helper.c | 27 | --- a/target/arm/helper-mve.h |
14 | +++ b/target/arm/helper.c | 28 | +++ b/target/arm/helper-mve.h |
15 | @@ -XXX,XX +XXX,XX @@ load_fail: | 29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
16 | return false; | 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]); | ||
17 | } | 119 | } |
18 | 120 | ||
19 | +static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr) | 121 | +static bool trans_VMULLP_B(DisasContext *s, arg_2op *a) |
20 | +{ | 122 | +{ |
21 | + /* | 123 | + /* |
22 | + * Return the integrity signature value for the callee-saves | 124 | + * Note that a->size indicates the output size, ie VMULL.P8 |
23 | + * stack frame section. @lr is the exception return payload/LR value | 125 | + * is the 8x8->16 operation and a->size is MO_16; VMULL.P16 |
24 | + * whose FType bit forms bit 0 of the signature if FP is present. | 126 | + * is the 16x16->32 operation and a->size is MO_32. |
25 | + */ | 127 | + */ |
26 | + uint32_t sig = 0xfefa125a; | 128 | + static MVEGenTwoOpFn * const fns[] = { |
27 | + | 129 | + NULL, |
28 | + if (!arm_feature(env, ARM_FEATURE_VFP) || (lr & R_V7M_EXCRET_FTYPE_MASK)) { | 130 | + gen_helper_mve_vmullpbh, |
29 | + sig |= 1; | 131 | + gen_helper_mve_vmullpbw, |
30 | + } | 132 | + NULL, |
31 | + return sig; | 133 | + }; |
134 | + return do_2op(s, a, fns[a->size]); | ||
32 | +} | 135 | +} |
33 | + | 136 | + |
34 | static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 137 | +static bool trans_VMULLP_T(DisasContext *s, arg_2op *a) |
35 | bool ignore_faults) | 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) | ||
36 | { | 162 | { |
37 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 163 | uint64_t result = 0; |
38 | bool stacked_ok; | 164 | int i; |
39 | uint32_t limit; | 165 | + for (i = 0; i < 16; ++i) { |
40 | bool want_psp; | 166 | + uint64_t mask = (op1 & 0x0000000100000001ull) * 0xffffffff; |
41 | + uint32_t sig; | 167 | + result ^= op2 & mask; |
42 | 168 | + op1 >>= 1; | |
43 | if (dotailchain) { | 169 | + op2 <<= 1; |
44 | bool mode = lr & R_V7M_EXCRET_MODE_MASK; | 170 | + } |
45 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 171 | + return result; |
46 | /* Write as much of the stack frame as we can. A write failure may | 172 | +} |
47 | * cause us to pend a derived exception. | 173 | |
48 | */ | 174 | +uint64_t pmull_h(uint64_t op1, uint64_t op2) |
49 | + sig = v7m_integrity_sig(env, lr); | 175 | +{ |
50 | stacked_ok = | 176 | + uint64_t result = 0; |
51 | - v7m_stack_write(cpu, frameptr, 0xfefa125b, mmu_idx, ignore_faults) && | 177 | + int i; |
52 | + v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) && | 178 | for (i = 0; i < 8; ++i) { |
53 | v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, | 179 | uint64_t mask = (op1 & 0x0001000100010001ull) * 0xffff; |
54 | ignore_faults) && | 180 | result ^= op2 & mask; |
55 | v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, | ||
56 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
57 | if (return_to_secure && | ||
58 | ((excret & R_V7M_EXCRET_ES_MASK) == 0 || | ||
59 | (excret & R_V7M_EXCRET_DCRS_MASK) == 0)) { | ||
60 | - uint32_t expected_sig = 0xfefa125b; | ||
61 | uint32_t actual_sig; | ||
62 | |||
63 | pop_ok = v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx); | ||
64 | |||
65 | - if (pop_ok && expected_sig != actual_sig) { | ||
66 | + if (pop_ok && v7m_integrity_sig(env, excret) != actual_sig) { | ||
67 | /* Take a SecureFault on the current stack */ | ||
68 | env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK; | ||
69 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
70 | -- | 181 | -- |
71 | 2.20.1 | 182 | 2.20.1 |
72 | 183 | ||
73 | 184 | diff view generated by jsdifflib |
1 | Move the NS TBFLAG down from bit 19 to bit 6, which has not | 1 | Implement the MVE incrementing/decrementing dup insns VIDUP, VDDUP, |
---|---|---|---|
2 | been used since commit c1e3781090b9d36c60 in 2015, when we | 2 | VIWDUP and VDWDUP. These fill the elements of a vector with |
3 | started passing the entire MMU index in the TB flags rather | 3 | successively incrementing values, starting at the offset specified in |
4 | than just a 'privilege level' bit. | 4 | a general purpose register. The final value of the offset is written |
5 | 5 | back to this register. The wrapping variants take a second general | |
6 | This rearrangement is not strictly necessary, but means that | 6 | purpose register which specifies the point where the count should |
7 | we can put M-profile-only bits next to each other rather | 7 | wrap back to 0. |
8 | than scattered across the flag word. | ||
9 | 8 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20190416125744.27770-17-peter.maydell@linaro.org | ||
13 | --- | 11 | --- |
14 | target/arm/cpu.h | 11 ++++++----- | 12 | target/arm/helper-mve.h | 12 ++++ |
15 | 1 file changed, 6 insertions(+), 5 deletions(-) | 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(+) | ||
16 | 17 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
18 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 20 | --- a/target/arm/helper-mve.h |
20 | +++ b/target/arm/cpu.h | 21 | +++ b/target/arm/helper-mve.h |
21 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1) | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) |
22 | FIELD(TBFLAG_A32, THUMB, 0, 1) | 23 | |
23 | FIELD(TBFLAG_A32, VECLEN, 1, 3) | 24 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) |
24 | FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) | 25 | |
25 | +/* | 26 | +DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
26 | + * Indicates whether cp register reads and writes by guest code should access | 27 | +DEF_HELPER_FLAGS_4(mve_viduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
27 | + * the secure or nonsecure bank of banked registers; note that this is not | 28 | +DEF_HELPER_FLAGS_4(mve_vidupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
28 | + * the same thing as the current security state of the processor! | 29 | + |
29 | + */ | 30 | +DEF_HELPER_FLAGS_5(mve_viwdupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) |
30 | +FIELD(TBFLAG_A32, NS, 6, 1) | 31 | +DEF_HELPER_FLAGS_5(mve_viwduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) |
31 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | 32 | +DEF_HELPER_FLAGS_5(mve_viwdupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) |
32 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | 33 | + |
33 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 34 | +DEF_HELPER_FLAGS_5(mve_vdwdupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) |
34 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 35 | +DEF_HELPER_FLAGS_5(mve_vdwduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) |
35 | * checks on the other bits at runtime | 36 | +DEF_HELPER_FLAGS_5(mve_vdwdupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) |
36 | */ | 37 | + |
37 | FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2) | 38 | DEF_HELPER_FLAGS_3(mve_vclsb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
38 | -/* Indicates whether cp register reads and writes by guest code should access | 39 | DEF_HELPER_FLAGS_3(mve_vclsh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
39 | - * the secure or nonsecure bank of banked registers; note that this is not | 40 | DEF_HELPER_FLAGS_3(mve_vclsw, TCG_CALL_NO_WG, void, env, ptr, ptr) |
40 | - * the same thing as the current security state of the processor! | 41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
41 | - */ | 42 | index XXXXXXX..XXXXXXX 100644 |
42 | -FIELD(TBFLAG_A32, NS, 19, 1) | 43 | --- a/target/arm/mve.decode |
43 | /* For M profile only, Handler (ie not Thread) mode */ | 44 | +++ b/target/arm/mve.decode |
44 | FIELD(TBFLAG_A32, HANDLER, 21, 1) | 45 | @@ -XXX,XX +XXX,XX @@ |
45 | /* For M profile only, whether we should generate stack-limit checks */ | 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 | +} | ||
46 | -- | 297 | -- |
47 | 2.20.1 | 298 | 2.20.1 |
48 | 299 | ||
49 | 300 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Factor out the "generate code to update VPR.MASK01/MASK23" part of |
---|---|---|---|
2 | trans_VPST(); we are going to want to reuse it for the VPT insns. | ||
2 | 3 | ||
3 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
4 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
5 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Message-id: 20190412165416.7977-2-philmd@redhat.com | ||
8 | 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> | ||
9 | --- | 6 | --- |
10 | hw/arm/aspeed.c | 13 +++++++++---- | 7 | target/arm/translate-mve.c | 31 +++++++++++++++++-------------- |
11 | 1 file changed, 9 insertions(+), 4 deletions(-) | 8 | 1 file changed, 17 insertions(+), 14 deletions(-) |
12 | 9 | ||
13 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 10 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
14 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/aspeed.c | 12 | --- a/target/arm/translate-mve.c |
16 | +++ b/hw/arm/aspeed.c | 13 | +++ b/target/arm/translate-mve.c |
17 | @@ -XXX,XX +XXX,XX @@ | 14 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) |
18 | #include "hw/arm/aspeed_soc.h" | 15 | return do_long_dual_acc(s, a, fns[a->x]); |
19 | #include "hw/boards.h" | ||
20 | #include "hw/i2c/smbus_eeprom.h" | ||
21 | +#include "hw/misc/pca9552.h" | ||
22 | +#include "hw/misc/tmp105.h" | ||
23 | #include "qemu/log.h" | ||
24 | #include "sysemu/block-backend.h" | ||
25 | #include "hw/loader.h" | ||
26 | @@ -XXX,XX +XXX,XX @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc) | ||
27 | eeprom_buf); | ||
28 | |||
29 | /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ | ||
30 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d); | ||
31 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), | ||
32 | + TYPE_TMP105, 0x4d); | ||
33 | |||
34 | /* The AST2500 EVB does not have an RTC. Let's pretend that one is | ||
35 | * plugged on the I2C bus header */ | ||
36 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | ||
37 | AspeedSoCState *soc = &bmc->soc; | ||
38 | uint8_t *eeprom_buf = g_malloc0(8 * 1024); | ||
39 | |||
40 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60); | ||
41 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552, | ||
42 | + 0x60); | ||
43 | |||
44 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c); | ||
45 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c); | ||
46 | |||
47 | /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ | ||
48 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a); | ||
49 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105, | ||
50 | + 0x4a); | ||
51 | |||
52 | /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is | ||
53 | * good enough */ | ||
54 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | ||
55 | |||
56 | smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51, | ||
57 | eeprom_buf); | ||
58 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "pca9552", | ||
59 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552, | ||
60 | 0x60); | ||
61 | } | 16 | } |
62 | 17 | ||
18 | -static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
19 | +static void gen_vpst(DisasContext *s, uint32_t mask) | ||
20 | { | ||
21 | - TCGv_i32 vpr; | ||
22 | - | ||
23 | - /* mask == 0 is a "related encoding" */ | ||
24 | - if (!dc_isar_feature(aa32_mve, s) || !a->mask) { | ||
25 | - return false; | ||
26 | - } | ||
27 | - if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
28 | - return true; | ||
29 | - } | ||
30 | /* | ||
31 | * Set the VPR mask fields. We take advantage of MASK01 and MASK23 | ||
32 | * being adjacent fields in the register. | ||
33 | * | ||
34 | - * This insn is not predicated, but it is subject to beat-wise | ||
35 | + * Updating the masks is not predicated, but it is subject to beat-wise | ||
36 | * execution, and the mask is updated on the odd-numbered beats. | ||
37 | * So if PSR.ECI says we should skip beat 1, we mustn't update the | ||
38 | * 01 mask field. | ||
39 | */ | ||
40 | - vpr = load_cpu_field(v7m.vpr); | ||
41 | + TCGv_i32 vpr = load_cpu_field(v7m.vpr); | ||
42 | switch (s->eci) { | ||
43 | case ECI_NONE: | ||
44 | case ECI_A0: | ||
45 | /* Update both 01 and 23 fields */ | ||
46 | tcg_gen_deposit_i32(vpr, vpr, | ||
47 | - tcg_constant_i32(a->mask | (a->mask << 4)), | ||
48 | + tcg_constant_i32(mask | (mask << 4)), | ||
49 | R_V7M_VPR_MASK01_SHIFT, | ||
50 | R_V7M_VPR_MASK01_LENGTH + R_V7M_VPR_MASK23_LENGTH); | ||
51 | break; | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
53 | case ECI_A0A1A2B0: | ||
54 | /* Update only the 23 mask field */ | ||
55 | tcg_gen_deposit_i32(vpr, vpr, | ||
56 | - tcg_constant_i32(a->mask), | ||
57 | + tcg_constant_i32(mask), | ||
58 | R_V7M_VPR_MASK23_SHIFT, R_V7M_VPR_MASK23_LENGTH); | ||
59 | break; | ||
60 | default: | ||
61 | g_assert_not_reached(); | ||
62 | } | ||
63 | store_cpu_field(vpr, v7m.vpr); | ||
64 | +} | ||
65 | + | ||
66 | +static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
67 | +{ | ||
68 | + /* mask == 0 is a "related encoding" */ | ||
69 | + if (!dc_isar_feature(aa32_mve, s) || !a->mask) { | ||
70 | + return false; | ||
71 | + } | ||
72 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
73 | + return true; | ||
74 | + } | ||
75 | + gen_vpst(s, a->mask); | ||
76 | mve_update_and_store_eci(s); | ||
77 | return true; | ||
78 | } | ||
63 | -- | 79 | -- |
64 | 2.20.1 | 80 | 2.20.1 |
65 | 81 | ||
66 | 82 | diff view generated by jsdifflib |
1 | Add a new helper function which returns the MMU index to use | 1 | Implement the MVE integer vector comparison instructions. These are |
---|---|---|---|
2 | for v7M, where the caller specifies all of the security | 2 | "VCMP (vector)" encodings T1, T2 and T3, and "VPT (vector)" encodings |
3 | state, privilege level and whether the execution priority | 3 | T1, T2 and T3. |
4 | is negative, and reimplement the existing | 4 | |
5 | arm_v7m_mmu_idx_for_secstate_and_priv() in terms of 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 | We are going to need this for the lazy-FP-stacking code. | 7 | also sets the VPR.MASK01 and VPR.MASK23 fields -- it is effectively |
8 | "VCMP then VPST". | ||
8 | 9 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20190416125744.27770-21-peter.maydell@linaro.org | ||
12 | --- | 12 | --- |
13 | target/arm/cpu.h | 7 +++++++ | 13 | target/arm/helper-mve.h | 32 ++++++++++++++++++++++ |
14 | target/arm/helper.c | 14 +++++++++++--- | 14 | target/arm/mve.decode | 18 +++++++++++- |
15 | 2 files changed, 18 insertions(+), 3 deletions(-) | 15 | target/arm/mve_helper.c | 56 ++++++++++++++++++++++++++++++++++++++ |
16 | 16 | target/arm/translate-mve.c | 47 ++++++++++++++++++++++++++++++++ | |
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 17 | 4 files changed, 152 insertions(+), 1 deletion(-) |
18 | index XXXXXXX..XXXXXXX 100644 | 18 | |
19 | --- a/target/arm/cpu.h | 19 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
20 | +++ b/target/arm/cpu.h | 20 | index XXXXXXX..XXXXXXX 100644 |
21 | @@ -XXX,XX +XXX,XX @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) | 21 | --- a/target/arm/helper-mve.h |
22 | } | 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 | ||
23 | } | 83 | } |
24 | 84 | ||
85 | # Predicate operations | ||
86 | -%mask_22_13 22:1 13:3 | ||
87 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
88 | |||
89 | # Logical immediate operations (1 reg and modified-immediate) | ||
90 | @@ -XXX,XX +XXX,XX @@ VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
91 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
92 | |||
93 | VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | ||
94 | + | ||
95 | +# Comparisons. We expand out the conditions which are split across | ||
96 | +# encodings T1, T2, T3 and the fc bits. These include VPT, which is | ||
97 | +# effectively "VCMP then VPST". A plain "VCMP" has a mask field of zero. | ||
98 | +VCMPEQ 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 0 @vcmp | ||
99 | +VCMPNE 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 0 @vcmp | ||
100 | +VCMPCS 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 1 @vcmp | ||
101 | +VCMPHI 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 1 @vcmp | ||
102 | +VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | ||
103 | +VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | ||
104 | +VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
105 | +VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | ||
106 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/mve_helper.c | ||
109 | +++ b/target/arm/mve_helper.c | ||
110 | @@ -XXX,XX +XXX,XX @@ static uint32_t do_sub_wrap(uint32_t offset, uint32_t wrap, uint32_t imm) | ||
111 | DO_VIDUP_ALL(vidup, DO_ADD) | ||
112 | DO_VIWDUP_ALL(viwdup, do_add_wrap) | ||
113 | DO_VIWDUP_ALL(vdwdup, do_sub_wrap) | ||
114 | + | ||
25 | +/* | 115 | +/* |
26 | + * Return the MMU index for a v7M CPU with all relevant information | 116 | + * Vector comparison. |
27 | + * manually specified. | 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. | ||
28 | + */ | 121 | + */ |
29 | +ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | 122 | +#define DO_VCMP(OP, ESIZE, TYPE, FN) \ |
30 | + bool secstate, bool priv, bool negpri); | 123 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, void *vm) \ |
31 | + | 124 | + { \ |
32 | /* Return the MMU index for a v7M CPU in the specified security and | 125 | + TYPE *n = vn, *m = vm; \ |
33 | * privilege state. | 126 | + uint16_t mask = mve_element_mask(env); \ |
34 | */ | 127 | + uint16_t eci_mask = mve_eci_mask(env); \ |
35 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 128 | + uint16_t beatpred = 0; \ |
36 | index XXXXXXX..XXXXXXX 100644 | 129 | + uint16_t emask = MAKE_64BIT_MASK(0, ESIZE); \ |
37 | --- a/target/arm/helper.c | 130 | + unsigned e; \ |
38 | +++ b/target/arm/helper.c | 131 | + for (e = 0; e < 16 / ESIZE; e++) { \ |
39 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | 132 | + bool r = FN(n[H##ESIZE(e)], m[H##ESIZE(e)]); \ |
40 | return 0; | 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]); | ||
41 | } | 185 | } |
42 | 186 | + | |
43 | -ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | 187 | +static bool do_vcmp(DisasContext *s, arg_vcmp *a, MVEGenCmpFn *fn) |
44 | - bool secstate, bool priv) | ||
45 | +ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | ||
46 | + bool secstate, bool priv, bool negpri) | ||
47 | { | ||
48 | ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; | ||
49 | |||
50 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
51 | mmu_idx |= ARM_MMU_IDX_M_PRIV; | ||
52 | } | ||
53 | |||
54 | - if (armv7m_nvic_neg_prio_requested(env->nvic, secstate)) { | ||
55 | + if (negpri) { | ||
56 | mmu_idx |= ARM_MMU_IDX_M_NEGPRI; | ||
57 | } | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
60 | return mmu_idx; | ||
61 | } | ||
62 | |||
63 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
64 | + bool secstate, bool priv) | ||
65 | +{ | 188 | +{ |
66 | + bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate); | 189 | + TCGv_ptr qn, qm; |
67 | + | 190 | + |
68 | + return arm_v7m_mmu_idx_all(env, secstate, priv, negpri); | 191 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qm) || |
192 | + !fn) { | ||
193 | + return false; | ||
194 | + } | ||
195 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
196 | + return true; | ||
197 | + } | ||
198 | + | ||
199 | + qn = mve_qreg_ptr(a->qn); | ||
200 | + qm = mve_qreg_ptr(a->qm); | ||
201 | + fn(cpu_env, qn, qm); | ||
202 | + tcg_temp_free_ptr(qn); | ||
203 | + tcg_temp_free_ptr(qm); | ||
204 | + if (a->mask) { | ||
205 | + /* VPT */ | ||
206 | + gen_vpst(s, a->mask); | ||
207 | + } | ||
208 | + mve_update_eci(s); | ||
209 | + return true; | ||
69 | +} | 210 | +} |
70 | + | 211 | + |
71 | /* Return the MMU index for a v7M CPU in the specified security state */ | 212 | +#define DO_VCMP(INSN, FN) \ |
72 | ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | 213 | + static bool trans_##INSN(DisasContext *s, arg_vcmp *a) \ |
73 | { | 214 | + { \ |
215 | + static MVEGenCmpFn * const fns[] = { \ | ||
216 | + gen_helper_mve_##FN##b, \ | ||
217 | + gen_helper_mve_##FN##h, \ | ||
218 | + gen_helper_mve_##FN##w, \ | ||
219 | + NULL, \ | ||
220 | + }; \ | ||
221 | + return do_vcmp(s, a, fns[a->size]); \ | ||
222 | + } | ||
223 | + | ||
224 | +DO_VCMP(VCMPEQ, vcmpeq) | ||
225 | +DO_VCMP(VCMPNE, vcmpne) | ||
226 | +DO_VCMP(VCMPCS, vcmpcs) | ||
227 | +DO_VCMP(VCMPHI, vcmphi) | ||
228 | +DO_VCMP(VCMPGE, vcmpge) | ||
229 | +DO_VCMP(VCMPLT, vcmplt) | ||
230 | +DO_VCMP(VCMPGT, vcmpgt) | ||
231 | +DO_VCMP(VCMPLE, vcmple) | ||
74 | -- | 232 | -- |
75 | 2.20.1 | 233 | 2.20.1 |
76 | 234 | ||
77 | 235 | diff view generated by jsdifflib |
1 | The M-profile FPCCR.ASPEN bit indicates that automatic floating-point | 1 | Implement the MVE integer vector comparison instructions that compare |
---|---|---|---|
2 | context preservation is enabled. Before executing any floating-point | 2 | each element against a scalar from a general purpose register. These |
3 | instruction, if FPCCR.ASPEN is set and the CONTROL FPCA/SFPA bits | 3 | are "VCMP (vector)" encodings T4, T5 and T6 and "VPT (vector)" |
4 | indicate that there is no active floating point context then we | 4 | encodings T4, T5 and T6. |
5 | must create a new context (by initializing FPSCR and setting | 5 | |
6 | FPCA/SFPA to indicate that the context is now active). In the | 6 | We have to move the decodetree pattern for VPST, because it |
7 | pseudocode this is handled by ExecuteFPCheck(). | 7 | overlaps with VCMP T4 with size = 0b11. |
8 | |||
9 | Implement this with a new TB flag which tracks whether we | ||
10 | need to create a new FP context. | ||
11 | 8 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20190416125744.27770-20-peter.maydell@linaro.org | ||
15 | --- | 11 | --- |
16 | target/arm/cpu.h | 2 ++ | 12 | target/arm/helper-mve.h | 32 +++++++++++++++++++++++++++ |
17 | target/arm/translate.h | 1 + | 13 | target/arm/mve.decode | 18 +++++++++++++--- |
18 | target/arm/helper.c | 13 +++++++++++++ | 14 | target/arm/mve_helper.c | 44 +++++++++++++++++++++++++++++++------- |
19 | target/arm/translate.c | 29 +++++++++++++++++++++++++++++ | 15 | target/arm/translate-mve.c | 43 +++++++++++++++++++++++++++++++++++++ |
20 | 4 files changed, 45 insertions(+) | 16 | 4 files changed, 126 insertions(+), 11 deletions(-) |
21 | 17 | ||
22 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
23 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/cpu.h | 20 | --- a/target/arm/helper-mve.h |
25 | +++ b/target/arm/cpu.h | 21 | +++ b/target/arm/helper-mve.h |
26 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vcmpgtw, TCG_CALL_NO_WG, void, env, ptr, ptr) |
27 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | 23 | DEF_HELPER_FLAGS_3(mve_vcmpleb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
28 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | 24 | DEF_HELPER_FLAGS_3(mve_vcmpleh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
29 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 25 | DEF_HELPER_FLAGS_3(mve_vcmplew, TCG_CALL_NO_WG, void, env, ptr, ptr) |
30 | +/* For M profile only, set if we must create a new FP context */ | 26 | + |
31 | +FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) | 27 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) |
32 | /* For M profile only, set if FPCCR.S does not match current security state */ | 28 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) |
33 | FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) | 29 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) |
34 | /* For M profile only, Handler (ie not Thread) mode */ | 30 | + |
35 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 31 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) |
36 | index XXXXXXX..XXXXXXX 100644 | 32 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) |
37 | --- a/target/arm/translate.h | 33 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) |
38 | +++ b/target/arm/translate.h | 34 | + |
39 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 35 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) |
40 | bool v8m_secure; /* true if v8M and we're in Secure mode */ | 36 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) |
41 | bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */ | 37 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) |
42 | bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */ | 38 | + |
43 | + bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */ | 39 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) |
44 | /* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI | 40 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) |
45 | * so that top level loop can generate correct syndrome information. | 41 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) |
46 | */ | 42 | + |
47 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 43 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) |
48 | index XXXXXXX..XXXXXXX 100644 | 44 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) |
49 | --- a/target/arm/helper.c | 45 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) |
50 | +++ b/target/arm/helper.c | 46 | + |
51 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 47 | +DEF_HELPER_FLAGS_3(mve_vcmplt_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) |
52 | flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); | 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 | ||
81 | } | ||
82 | |||
83 | -# Predicate operations | ||
84 | -VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
85 | - | ||
86 | # Logical immediate operations (1 reg and modified-immediate) | ||
87 | |||
88 | # The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but | ||
89 | @@ -XXX,XX +XXX,XX @@ VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | ||
90 | VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | ||
91 | VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
92 | VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | ||
93 | + | ||
94 | +{ | ||
95 | + VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
96 | + VCMPEQ_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 0 0 .... @vcmp_scalar | ||
97 | +} | ||
98 | +VCMPNE_scalar 1111 1110 0 . .. ... 1 ... 0 1111 1 1 0 0 .... @vcmp_scalar | ||
99 | +VCMPCS_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 1 0 .... @vcmp_scalar | ||
100 | +VCMPHI_scalar 1111 1110 0 . .. ... 1 ... 0 1111 1 1 1 0 .... @vcmp_scalar | ||
101 | +VCMPGE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 0 0 .... @vcmp_scalar | ||
102 | +VCMPLT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 0 0 .... @vcmp_scalar | ||
103 | +VCMPGT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 1 0 .... @vcmp_scalar | ||
104 | +VCMPLE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 1 0 .... @vcmp_scalar | ||
105 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/mve_helper.c | ||
108 | +++ b/target/arm/mve_helper.c | ||
109 | @@ -XXX,XX +XXX,XX @@ DO_VIWDUP_ALL(vdwdup, do_sub_wrap) | ||
110 | mve_advance_vpt(env); \ | ||
53 | } | 111 | } |
54 | 112 | ||
55 | + if (arm_feature(env, ARM_FEATURE_M) && | 113 | -#define DO_VCMP_S(OP, FN) \ |
56 | + (env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) && | 114 | - DO_VCMP(OP##b, 1, int8_t, FN) \ |
57 | + (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) || | 115 | - DO_VCMP(OP##h, 2, int16_t, FN) \ |
58 | + (env->v7m.secure && | 116 | - DO_VCMP(OP##w, 4, int32_t, FN) |
59 | + !(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)))) { | 117 | +#define DO_VCMP_SCALAR(OP, ESIZE, TYPE, FN) \ |
60 | + /* | 118 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ |
61 | + * ASPEN is set, but FPCA/SFPA indicate that there is no active | 119 | + uint32_t rm) \ |
62 | + * FP context; we must create a new FP context before executing | 120 | + { \ |
63 | + * any FP insn. | 121 | + TYPE *n = vn; \ |
64 | + */ | 122 | + uint16_t mask = mve_element_mask(env); \ |
65 | + flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1); | 123 | + uint16_t eci_mask = mve_eci_mask(env); \ |
66 | + } | 124 | + uint16_t beatpred = 0; \ |
67 | + | 125 | + uint16_t emask = MAKE_64BIT_MASK(0, ESIZE); \ |
68 | *pflags = flags; | 126 | + unsigned e; \ |
69 | *cs_base = 0; | 127 | + for (e = 0; e < 16 / ESIZE; e++) { \ |
128 | + bool r = FN(n[H##ESIZE(e)], (TYPE)rm); \ | ||
129 | + /* Comparison sets 0/1 bits for each byte in the element */ \ | ||
130 | + beatpred |= r * emask; \ | ||
131 | + emask <<= ESIZE; \ | ||
132 | + } \ | ||
133 | + beatpred &= mask; \ | ||
134 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | \ | ||
135 | + (beatpred & eci_mask); \ | ||
136 | + mve_advance_vpt(env); \ | ||
137 | + } | ||
138 | |||
139 | -#define DO_VCMP_U(OP, FN) \ | ||
140 | - DO_VCMP(OP##b, 1, uint8_t, FN) \ | ||
141 | - DO_VCMP(OP##h, 2, uint16_t, FN) \ | ||
142 | - DO_VCMP(OP##w, 4, uint32_t, FN) | ||
143 | +#define DO_VCMP_S(OP, FN) \ | ||
144 | + DO_VCMP(OP##b, 1, int8_t, FN) \ | ||
145 | + DO_VCMP(OP##h, 2, int16_t, FN) \ | ||
146 | + DO_VCMP(OP##w, 4, int32_t, FN) \ | ||
147 | + DO_VCMP_SCALAR(OP##_scalarb, 1, int8_t, FN) \ | ||
148 | + DO_VCMP_SCALAR(OP##_scalarh, 2, int16_t, FN) \ | ||
149 | + DO_VCMP_SCALAR(OP##_scalarw, 4, int32_t, FN) | ||
150 | + | ||
151 | +#define DO_VCMP_U(OP, FN) \ | ||
152 | + DO_VCMP(OP##b, 1, uint8_t, FN) \ | ||
153 | + DO_VCMP(OP##h, 2, uint16_t, FN) \ | ||
154 | + DO_VCMP(OP##w, 4, uint32_t, FN) \ | ||
155 | + DO_VCMP_SCALAR(OP##_scalarb, 1, uint8_t, FN) \ | ||
156 | + DO_VCMP_SCALAR(OP##_scalarh, 2, uint16_t, FN) \ | ||
157 | + DO_VCMP_SCALAR(OP##_scalarw, 4, uint32_t, FN) | ||
158 | |||
159 | #define DO_EQ(N, M) ((N) == (M)) | ||
160 | #define DO_NE(N, M) ((N) != (M)) | ||
161 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
162 | index XXXXXXX..XXXXXXX 100644 | ||
163 | --- a/target/arm/translate-mve.c | ||
164 | +++ b/target/arm/translate-mve.c | ||
165 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
166 | typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
167 | typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
168 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
169 | +typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
170 | |||
171 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
172 | static inline long mve_qreg_offset(unsigned reg) | ||
173 | @@ -XXX,XX +XXX,XX @@ static bool do_vcmp(DisasContext *s, arg_vcmp *a, MVEGenCmpFn *fn) | ||
174 | return true; | ||
70 | } | 175 | } |
71 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 176 | |
72 | index XXXXXXX..XXXXXXX 100644 | 177 | +static bool do_vcmp_scalar(DisasContext *s, arg_vcmp_scalar *a, |
73 | --- a/target/arm/translate.c | 178 | + MVEGenScalarCmpFn *fn) |
74 | +++ b/target/arm/translate.c | 179 | +{ |
75 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 180 | + TCGv_ptr qn; |
76 | /* Don't need to do this for any further FP insns in this TB */ | 181 | + TCGv_i32 rm; |
77 | s->v8m_fpccr_s_wrong = false; | 182 | + |
78 | } | 183 | + if (!dc_isar_feature(aa32_mve, s) || !fn || a->rm == 13) { |
79 | + | 184 | + return false; |
80 | + if (s->v7m_new_fp_ctxt_needed) { | 185 | + } |
81 | + /* | 186 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
82 | + * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA | 187 | + return true; |
83 | + * and the FPSCR. | 188 | + } |
84 | + */ | 189 | + |
85 | + TCGv_i32 control, fpscr; | 190 | + qn = mve_qreg_ptr(a->qn); |
86 | + uint32_t bits = R_V7M_CONTROL_FPCA_MASK; | 191 | + if (a->rm == 15) { |
87 | + | 192 | + /* Encoding Rm=0b1111 means "constant zero" */ |
88 | + fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]); | 193 | + rm = tcg_constant_i32(0); |
89 | + gen_helper_vfp_set_fpscr(cpu_env, fpscr); | 194 | + } else { |
90 | + tcg_temp_free_i32(fpscr); | 195 | + rm = load_reg(s, a->rm); |
91 | + /* | 196 | + } |
92 | + * We don't need to arrange to end the TB, because the only | 197 | + fn(cpu_env, qn, rm); |
93 | + * parts of FPSCR which we cache in the TB flags are the VECLEN | 198 | + tcg_temp_free_ptr(qn); |
94 | + * and VECSTRIDE, and those don't exist for M-profile. | 199 | + tcg_temp_free_i32(rm); |
95 | + */ | 200 | + if (a->mask) { |
96 | + | 201 | + /* VPT */ |
97 | + if (s->v8m_secure) { | 202 | + gen_vpst(s, a->mask); |
98 | + bits |= R_V7M_CONTROL_SFPA_MASK; | 203 | + } |
99 | + } | 204 | + mve_update_eci(s); |
100 | + control = load_cpu_field(v7m.control[M_REG_S]); | 205 | + return true; |
101 | + tcg_gen_ori_i32(control, control, bits); | 206 | +} |
102 | + store_cpu_field(control, v7m.control[M_REG_S]); | 207 | + |
103 | + /* Don't need to do this for any further FP insns in this TB */ | 208 | #define DO_VCMP(INSN, FN) \ |
104 | + s->v7m_new_fp_ctxt_needed = false; | 209 | static bool trans_##INSN(DisasContext *s, arg_vcmp *a) \ |
105 | + } | 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]); \ | ||
106 | } | 226 | } |
107 | 227 | ||
108 | if (extract32(insn, 28, 4) == 0xf) { | 228 | DO_VCMP(VCMPEQ, vcmpeq) |
109 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
110 | regime_is_secure(env, dc->mmu_idx); | ||
111 | dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK); | ||
112 | dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG); | ||
113 | + dc->v7m_new_fp_ctxt_needed = | ||
114 | + FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED); | ||
115 | dc->cp_regs = cpu->cp_regs; | ||
116 | dc->features = env->features; | ||
117 | |||
118 | -- | 229 | -- |
119 | 2.20.1 | 230 | 2.20.1 |
120 | 231 | ||
121 | 232 | diff view generated by jsdifflib |
1 | For v8M floating point support, transitions from Secure | 1 | Implement the MVE VPSEL insn, which sets each byte of the destination |
---|---|---|---|
2 | to Non-secure state via BLNS and BLXNS must clear the | 2 | vector Qd to the byte from either Qn or Qm depending on the value of |
3 | CONTROL.SFPA bit. (This corresponds to the pseudocode | 3 | the corresponding bit in VPR.P0. |
4 | BranchToNS() function.) | ||
5 | 4 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20190416125744.27770-13-peter.maydell@linaro.org | ||
9 | --- | 7 | --- |
10 | target/arm/helper.c | 4 ++++ | 8 | target/arm/helper-mve.h | 2 ++ |
11 | 1 file changed, 4 insertions(+) | 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(-) | ||
12 | 13 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 16 | --- a/target/arm/helper-mve.h |
16 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/helper-mve.h |
17 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vorr, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
18 | /* translate.c should have made BXNS UNDEF unless we're secure */ | 19 | DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
19 | assert(env->v7m.secure); | 20 | DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
20 | 21 | ||
21 | + if (!(dest & 1)) { | 22 | +DEF_HELPER_FLAGS_4(mve_vpsel, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
22 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | 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); | ||
23 | + } | 69 | + } |
24 | switch_v7m_security_state(env, dest & 1); | 70 | + mve_advance_vpt(env); |
25 | env->thumb = 1; | 71 | +} |
26 | env->regs[15] = dest & ~1; | 72 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
27 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | 73 | index XXXXXXX..XXXXXXX 100644 |
28 | */ | 74 | --- a/target/arm/translate-mve.c |
29 | write_v7m_exception(env, 1); | 75 | +++ b/target/arm/translate-mve.c |
30 | } | 76 | @@ -XXX,XX +XXX,XX @@ DO_LOGIC(VORR, gen_helper_mve_vorr) |
31 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | 77 | DO_LOGIC(VORN, gen_helper_mve_vorn) |
32 | switch_v7m_security_state(env, 0); | 78 | DO_LOGIC(VEOR, gen_helper_mve_veor) |
33 | env->thumb = 1; | 79 | |
34 | env->regs[15] = dest; | 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 | { \ | ||
35 | -- | 85 | -- |
36 | 2.20.1 | 86 | 2.20.1 |
37 | 87 | ||
38 | 88 | diff view generated by jsdifflib |
1 | Handle floating point registers in exception return. | 1 | Implement the MVE VMLAS insn, which multiplies a vector by a vector |
---|---|---|---|
2 | This corresponds to pseudocode functions ValidateExceptionReturn(), | 2 | and adds a scalar. |
3 | ExceptionReturn(), PopStack() and ConsumeExcStackFrame(). | ||
4 | 3 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20190416125744.27770-16-peter.maydell@linaro.org | ||
8 | --- | 6 | --- |
9 | target/arm/helper.c | 142 +++++++++++++++++++++++++++++++++++++++++++- | 7 | target/arm/helper-mve.h | 4 ++++ |
10 | 1 file changed, 141 insertions(+), 1 deletion(-) | 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(+) | ||
11 | 12 | ||
12 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/helper.c | 15 | --- a/target/arm/helper-mve.h |
15 | +++ b/target/arm/helper.c | 16 | +++ b/target/arm/helper-mve.h |
16 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i3 |
17 | bool rettobase = false; | 18 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
18 | bool exc_secure = false; | 19 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
19 | bool return_to_secure; | 20 | |
20 | + bool ftype; | 21 | +DEF_HELPER_FLAGS_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | + bool restore_s16_s31; | 22 | +DEF_HELPER_FLAGS_4(mve_vmlash, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
22 | 23 | +DEF_HELPER_FLAGS_4(mve_vmlasw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
23 | /* If we're not in Handler mode then jumps to magic exception-exit | 24 | + |
24 | * addresses don't have magic behaviour. However for the v8M | 25 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) |
25 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 26 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) |
26 | excret); | 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); \ | ||
27 | } | 48 | } |
28 | 49 | ||
29 | + ftype = excret & R_V7M_EXCRET_FTYPE_MASK; | 50 | +/* "accumulating" version where FN takes d as well as n and m */ |
30 | + | 51 | +#define DO_2OP_ACC_SCALAR(OP, ESIZE, TYPE, FN) \ |
31 | + if (!arm_feature(env, ARM_FEATURE_VFP) && !ftype) { | 52 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ |
32 | + qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero FTYPE in exception " | 53 | + uint32_t rm) \ |
33 | + "exit PC value 0x%" PRIx32 " is UNPREDICTABLE " | 54 | + { \ |
34 | + "if FPU not present\n", | 55 | + TYPE *d = vd, *n = vn; \ |
35 | + excret); | 56 | + TYPE m = rm; \ |
36 | + ftype = true; | 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); \ | ||
37 | + } | 64 | + } |
38 | + | 65 | + |
39 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | 66 | /* provide unsigned 2-op scalar helpers for all sizes */ |
40 | /* EXC_RETURN.ES validation check (R_SMFL). We must do this before | 67 | #define DO_2OP_SCALAR_U(OP, FN) \ |
41 | * we pick which FAULTMASK to clear. | 68 | DO_2OP_SCALAR(OP##b, 1, uint8_t, FN) \ |
42 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 69 | @@ -XXX,XX +XXX,XX @@ DO_VQDMLADH_OP(vqrdmlsdhxw, 4, int32_t, 1, 1, do_vqdmlsdh_w) |
43 | */ | 70 | DO_2OP_SCALAR(OP##h, 2, int16_t, FN) \ |
44 | write_v7m_control_spsel_for_secstate(env, return_to_sp_process, exc_secure); | 71 | DO_2OP_SCALAR(OP##w, 4, int32_t, FN) |
45 | 72 | ||
46 | + /* | 73 | +#define DO_2OP_ACC_SCALAR_U(OP, FN) \ |
47 | + * Clear scratch FP values left in caller saved registers; this | 74 | + DO_2OP_ACC_SCALAR(OP##b, 1, uint8_t, FN) \ |
48 | + * must happen before any kind of tail chaining. | 75 | + DO_2OP_ACC_SCALAR(OP##h, 2, uint16_t, FN) \ |
49 | + */ | 76 | + DO_2OP_ACC_SCALAR(OP##w, 4, uint32_t, FN) |
50 | + if ((env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_CLRONRET_MASK) && | ||
51 | + (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) { | ||
52 | + if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) { | ||
53 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | ||
54 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
55 | + qemu_log_mask(CPU_LOG_INT, "...taking SecureFault on existing " | ||
56 | + "stackframe: error during lazy state deactivation\n"); | ||
57 | + v7m_exception_taken(cpu, excret, true, false); | ||
58 | + return; | ||
59 | + } else { | ||
60 | + /* Clear s0..s15 and FPSCR */ | ||
61 | + int i; | ||
62 | + | 77 | + |
63 | + for (i = 0; i < 16; i += 2) { | 78 | DO_2OP_SCALAR_U(vadd_scalar, DO_ADD) |
64 | + *aa32_vfp_dreg(env, i / 2) = 0; | 79 | DO_2OP_SCALAR_U(vsub_scalar, DO_SUB) |
65 | + } | 80 | DO_2OP_SCALAR_U(vmul_scalar, DO_MUL) |
66 | + vfp_set_fpscr(env, 0); | 81 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) |
67 | + } | 82 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) |
68 | + } | 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)) | ||
69 | + | 87 | + |
70 | if (sfault) { | 88 | +DO_2OP_ACC_SCALAR_U(vmlas, DO_VMLAS) |
71 | env->v7m.sfsr |= R_V7M_SFSR_INVER_MASK; | ||
72 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
73 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
74 | } | ||
75 | } | ||
76 | |||
77 | + if (!ftype) { | ||
78 | + /* FP present and we need to handle it */ | ||
79 | + if (!return_to_secure && | ||
80 | + (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK)) { | ||
81 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
82 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | ||
83 | + qemu_log_mask(CPU_LOG_INT, | ||
84 | + "...taking SecureFault on existing stackframe: " | ||
85 | + "Secure LSPACT set but exception return is " | ||
86 | + "not to secure state\n"); | ||
87 | + v7m_exception_taken(cpu, excret, true, false); | ||
88 | + return; | ||
89 | + } | ||
90 | + | 89 | + |
91 | + restore_s16_s31 = return_to_secure && | 90 | /* |
92 | + (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK); | 91 | * Long saturating scalar ops. As with DO_2OP_L, TYPE and H are for the |
93 | + | 92 | * input (smaller) type and LESIZE, LTYPE, LH for the output (long) type. |
94 | + if (env->v7m.fpccr[return_to_secure] & R_V7M_FPCCR_LSPACT_MASK) { | 93 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
95 | + /* State in FPU is still valid, just clear LSPACT */ | 94 | index XXXXXXX..XXXXXXX 100644 |
96 | + env->v7m.fpccr[return_to_secure] &= ~R_V7M_FPCCR_LSPACT_MASK; | 95 | --- a/target/arm/translate-mve.c |
97 | + } else { | 96 | +++ b/target/arm/translate-mve.c |
98 | + int i; | 97 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VQSUB_U_scalar, vqsubu_scalar) |
99 | + uint32_t fpscr; | 98 | DO_2OP_SCALAR(VQDMULH_scalar, vqdmulh_scalar) |
100 | + bool cpacr_pass, nsacr_pass; | 99 | DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) |
101 | + | 100 | DO_2OP_SCALAR(VBRSR, vbrsr) |
102 | + cpacr_pass = v7m_cpacr_pass(env, return_to_secure, | 101 | +DO_2OP_SCALAR(VMLAS, vmlas) |
103 | + return_to_priv); | 102 | |
104 | + nsacr_pass = return_to_secure || | 103 | static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a) |
105 | + extract32(env->v7m.nsacr, 10, 1); | 104 | { |
106 | + | ||
107 | + if (!cpacr_pass) { | ||
108 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | ||
109 | + return_to_secure); | ||
110 | + env->v7m.cfsr[return_to_secure] |= R_V7M_CFSR_NOCP_MASK; | ||
111 | + qemu_log_mask(CPU_LOG_INT, | ||
112 | + "...taking UsageFault on existing " | ||
113 | + "stackframe: CPACR.CP10 prevents unstacking " | ||
114 | + "FP regs\n"); | ||
115 | + v7m_exception_taken(cpu, excret, true, false); | ||
116 | + return; | ||
117 | + } else if (!nsacr_pass) { | ||
118 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, true); | ||
119 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_INVPC_MASK; | ||
120 | + qemu_log_mask(CPU_LOG_INT, | ||
121 | + "...taking Secure UsageFault on existing " | ||
122 | + "stackframe: NSACR.CP10 prevents unstacking " | ||
123 | + "FP regs\n"); | ||
124 | + v7m_exception_taken(cpu, excret, true, false); | ||
125 | + return; | ||
126 | + } | ||
127 | + | ||
128 | + for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) { | ||
129 | + uint32_t slo, shi; | ||
130 | + uint64_t dn; | ||
131 | + uint32_t faddr = frameptr + 0x20 + 4 * i; | ||
132 | + | ||
133 | + if (i >= 16) { | ||
134 | + faddr += 8; /* Skip the slot for the FPSCR */ | ||
135 | + } | ||
136 | + | ||
137 | + pop_ok = pop_ok && | ||
138 | + v7m_stack_read(cpu, &slo, faddr, mmu_idx) && | ||
139 | + v7m_stack_read(cpu, &shi, faddr + 4, mmu_idx); | ||
140 | + | ||
141 | + if (!pop_ok) { | ||
142 | + break; | ||
143 | + } | ||
144 | + | ||
145 | + dn = (uint64_t)shi << 32 | slo; | ||
146 | + *aa32_vfp_dreg(env, i / 2) = dn; | ||
147 | + } | ||
148 | + pop_ok = pop_ok && | ||
149 | + v7m_stack_read(cpu, &fpscr, frameptr + 0x60, mmu_idx); | ||
150 | + if (pop_ok) { | ||
151 | + vfp_set_fpscr(env, fpscr); | ||
152 | + } | ||
153 | + if (!pop_ok) { | ||
154 | + /* | ||
155 | + * These regs are 0 if security extension present; | ||
156 | + * otherwise merely UNKNOWN. We zero always. | ||
157 | + */ | ||
158 | + for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) { | ||
159 | + *aa32_vfp_dreg(env, i / 2) = 0; | ||
160 | + } | ||
161 | + vfp_set_fpscr(env, 0); | ||
162 | + } | ||
163 | + } | ||
164 | + } | ||
165 | + env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S], | ||
166 | + V7M_CONTROL, FPCA, !ftype); | ||
167 | + | ||
168 | /* Commit to consuming the stack frame */ | ||
169 | frameptr += 0x20; | ||
170 | + if (!ftype) { | ||
171 | + frameptr += 0x48; | ||
172 | + if (restore_s16_s31) { | ||
173 | + frameptr += 0x40; | ||
174 | + } | ||
175 | + } | ||
176 | /* Undo stack alignment (the SPREALIGN bit indicates that the original | ||
177 | * pre-exception SP was not 8-aligned and we added a padding word to | ||
178 | * align it, so we undo this by ORing in the bit that increases it | ||
179 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
180 | *frame_sp_p = frameptr; | ||
181 | } | ||
182 | /* This xpsr_write() will invalidate frame_sp_p as it may switch stack */ | ||
183 | - xpsr_write(env, xpsr, ~XPSR_SPREALIGN); | ||
184 | + xpsr_write(env, xpsr, ~(XPSR_SPREALIGN | XPSR_SFPA)); | ||
185 | + | ||
186 | + if (env->v7m.secure) { | ||
187 | + bool sfpa = xpsr & XPSR_SFPA; | ||
188 | + | ||
189 | + env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S], | ||
190 | + V7M_CONTROL, SFPA, sfpa); | ||
191 | + } | ||
192 | |||
193 | /* The restored xPSR exception field will be zero if we're | ||
194 | * resuming in Thread mode. If that doesn't match what the | ||
195 | -- | 105 | -- |
196 | 2.20.1 | 106 | 2.20.1 |
197 | 107 | ||
198 | 108 | diff view generated by jsdifflib |
1 | Implement the VLLDM instruction for v7M for the FPU present cas. | 1 | Implement the MVE instructions which perform shifts by a scalar. |
---|---|---|---|
2 | These are VSHL T2, VRSHL T2, VQSHL T1 and VQRSHL T2. They take the | ||
3 | shift amount in a general purpose register and shift every element in | ||
4 | the vector by that amount. | ||
5 | |||
6 | Mostly we can reuse the helper functions for shift-by-immediate; we | ||
7 | do need two new helpers for VQRSHL. | ||
2 | 8 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20190416125744.27770-26-peter.maydell@linaro.org | ||
6 | --- | 11 | --- |
7 | target/arm/helper.h | 1 + | 12 | target/arm/helper-mve.h | 8 +++++++ |
8 | target/arm/helper.c | 54 ++++++++++++++++++++++++++++++++++++++++++ | 13 | target/arm/mve.decode | 23 ++++++++++++++++--- |
9 | target/arm/translate.c | 2 +- | 14 | target/arm/mve_helper.c | 2 ++ |
10 | 3 files changed, 56 insertions(+), 1 deletion(-) | 15 | target/arm/translate-mve.c | 46 ++++++++++++++++++++++++++++++++++++++ |
16 | 4 files changed, 76 insertions(+), 3 deletions(-) | ||
11 | 17 | ||
12 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
13 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/helper.h | 20 | --- a/target/arm/helper-mve.h |
15 | +++ b/target/arm/helper.h | 21 | +++ b/target/arm/helper-mve.h |
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32) | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
17 | DEF_HELPER_1(v7m_preserve_fp_state, void, env) | 23 | DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
18 | 24 | DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
19 | DEF_HELPER_2(v7m_vlstm, void, env, i32) | 25 | |
20 | +DEF_HELPER_2(v7m_vlldm, void, env, i32) | 26 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | 27 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
22 | DEF_HELPER_2(v8m_stackcheck, void, env, i32) | 28 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | 29 | + | |
24 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 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 | ||
25 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/helper.c | 39 | --- a/target/arm/mve.decode |
27 | +++ b/target/arm/helper.c | 40 | +++ b/target/arm/mve.decode |
28 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | 41 | @@ -XXX,XX +XXX,XX @@ |
29 | g_assert_not_reached(); | 42 | &viwdup qd rn rm size imm |
30 | } | 43 | &vcmp qm qn size mask |
31 | 44 | &vcmp_scalar qn rm size mask | |
32 | +void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | 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 | + | ||
33 | +{ | 64 | +{ |
34 | + /* translate.c should never generate calls here in user-only mode */ | 65 | + VSHL_S_scalar 1110 1110 0 . 11 .. 01 ... 1 1110 0110 .... @shl_scalar |
35 | + g_assert_not_reached(); | 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 | ||
36 | +} | 70 | +} |
37 | + | 71 | + |
38 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 72 | +{ |
39 | { | 73 | + VSHL_U_scalar 1111 1110 0 . 11 .. 01 ... 1 1110 0110 .... @shl_scalar |
40 | /* The TT instructions can be used by unprivileged code, but in | 74 | + VRSHL_U_scalar 1111 1110 0 . 11 .. 11 ... 1 1110 0110 .... @shl_scalar |
41 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | 75 | + VQSHL_U_scalar 1111 1110 0 . 11 .. 01 ... 1 1110 1110 .... @shl_scalar |
42 | env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | 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 | ||
43 | } | 85 | } |
44 | 86 | ||
45 | +void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | 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) | ||
46 | +{ | 115 | +{ |
47 | + /* fptr is the value of Rn, the frame pointer we load the FP regs from */ | 116 | + TCGv_ptr qda; |
48 | + assert(env->v7m.secure); | 117 | + TCGv_i32 rm; |
49 | + | 118 | + |
50 | + if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) { | 119 | + if (!dc_isar_feature(aa32_mve, s) || |
51 | + return; | 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; | ||
52 | + } | 127 | + } |
53 | + | 128 | + |
54 | + /* Check access to the coprocessor is permitted */ | 129 | + qda = mve_qreg_ptr(a->qda); |
55 | + if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) { | 130 | + rm = load_reg(s, a->rm); |
56 | + raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC()); | 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]); \ | ||
57 | + } | 148 | + } |
58 | + | 149 | + |
59 | + if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) { | 150 | +DO_2SHIFT_SCALAR(VSHL_S_scalar, vshli_s) |
60 | + /* State in FP is still valid */ | 151 | +DO_2SHIFT_SCALAR(VSHL_U_scalar, vshli_u) |
61 | + env->v7m.fpccr[M_REG_S] &= ~R_V7M_FPCCR_LSPACT_MASK; | 152 | +DO_2SHIFT_SCALAR(VRSHL_S_scalar, vrshli_s) |
62 | + } else { | 153 | +DO_2SHIFT_SCALAR(VRSHL_U_scalar, vrshli_u) |
63 | + bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK; | 154 | +DO_2SHIFT_SCALAR(VQSHL_S_scalar, vqshli_s) |
64 | + int i; | 155 | +DO_2SHIFT_SCALAR(VQSHL_U_scalar, vqshli_u) |
65 | + uint32_t fpscr; | 156 | +DO_2SHIFT_SCALAR(VQRSHL_S_scalar, vqrshli_s) |
157 | +DO_2SHIFT_SCALAR(VQRSHL_U_scalar, vqrshli_u) | ||
66 | + | 158 | + |
67 | + if (fptr & 7) { | 159 | #define DO_VSHLL(INSN, FN) \ |
68 | + raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC()); | 160 | static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ |
69 | + } | 161 | { \ |
70 | + | ||
71 | + for (i = 0; i < (ts ? 32 : 16); i += 2) { | ||
72 | + uint32_t slo, shi; | ||
73 | + uint64_t dn; | ||
74 | + uint32_t faddr = fptr + 4 * i; | ||
75 | + | ||
76 | + if (i >= 16) { | ||
77 | + faddr += 8; /* skip the slot for the FPSCR */ | ||
78 | + } | ||
79 | + | ||
80 | + slo = cpu_ldl_data(env, faddr); | ||
81 | + shi = cpu_ldl_data(env, faddr + 4); | ||
82 | + | ||
83 | + dn = (uint64_t) shi << 32 | slo; | ||
84 | + *aa32_vfp_dreg(env, i / 2) = dn; | ||
85 | + } | ||
86 | + fpscr = cpu_ldl_data(env, fptr + 0x40); | ||
87 | + vfp_set_fpscr(env, fpscr); | ||
88 | + } | ||
89 | + | ||
90 | + env->v7m.control[M_REG_S] |= R_V7M_CONTROL_FPCA_MASK; | ||
91 | +} | ||
92 | + | ||
93 | static bool v7m_push_stack(ARMCPU *cpu) | ||
94 | { | ||
95 | /* Do the "set up stack frame" part of exception entry, | ||
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate.c | ||
99 | +++ b/target/arm/translate.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
101 | TCGv_i32 fptr = load_reg(s, rn); | ||
102 | |||
103 | if (extract32(insn, 20, 1)) { | ||
104 | - /* VLLDM */ | ||
105 | + gen_helper_v7m_vlldm(cpu_env, fptr); | ||
106 | } else { | ||
107 | gen_helper_v7m_vlstm(cpu_env, fptr); | ||
108 | } | ||
109 | -- | 162 | -- |
110 | 2.20.1 | 163 | 2.20.1 |
111 | 164 | ||
112 | 165 | diff view generated by jsdifflib |
1 | The M-profile FPCCR.S bit indicates the security status of | 1 | All the users of the vmlaldav formats have an 'x bit in bit 12 and an |
---|---|---|---|
2 | the floating point context. In the pseudocode ExecuteFPCheck() | 2 | 'a' bit in bit 5; move these to the format rather than specifying them |
3 | function it is unconditionally set to match the current | 3 | in each insn pattern. |
4 | security state whenever a floating point instruction is | ||
5 | executed. | ||
6 | |||
7 | Implement this by adding a new TB flag which tracks whether | ||
8 | FPCCR.S is different from the current security state, so | ||
9 | that we only need to emit the code to update it in the | ||
10 | less-common case when it is not already set correctly. | ||
11 | |||
12 | Note that we will add the handling for the other work done | ||
13 | by ExecuteFPCheck() in later commits. | ||
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: 20190416125744.27770-19-peter.maydell@linaro.org | ||
18 | --- | 7 | --- |
19 | target/arm/cpu.h | 2 ++ | 8 | target/arm/mve.decode | 16 ++++++++-------- |
20 | target/arm/translate.h | 1 + | 9 | 1 file changed, 8 insertions(+), 8 deletions(-) |
21 | target/arm/helper.c | 5 +++++ | ||
22 | target/arm/translate.c | 20 ++++++++++++++++++++ | ||
23 | 4 files changed, 28 insertions(+) | ||
24 | 10 | ||
25 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 11 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
26 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/cpu.h | 13 | --- a/target/arm/mve.decode |
28 | +++ b/target/arm/cpu.h | 14 | +++ b/target/arm/mve.decode |
29 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 15 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 |
30 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | 16 | |
31 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | 17 | &vmlaldav rdahi rdalo size qn qm x a |
32 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 18 | |
33 | +/* For M profile only, set if FPCCR.S does not match current security state */ | 19 | -@vmlaldav .... .... . ... ... . ... . .... .... qm:3 . \ |
34 | +FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) | 20 | +@vmlaldav .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ |
35 | /* For M profile only, Handler (ie not Thread) mode */ | 21 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav |
36 | FIELD(TBFLAG_A32, HANDLER, 21, 1) | 22 | -@vmlaldav_nosz .... .... . ... ... . ... . .... .... qm:3 . \ |
37 | /* For M profile only, whether we should generate stack-limit checks */ | 23 | +@vmlaldav_nosz .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ |
38 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 24 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=0 &vmlaldav |
39 | index XXXXXXX..XXXXXXX 100644 | 25 | -VMLALDAV_S 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav |
40 | --- a/target/arm/translate.h | 26 | -VMLALDAV_U 1111 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav |
41 | +++ b/target/arm/translate.h | 27 | +VMLALDAV_S 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav |
42 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 28 | +VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav |
43 | bool v7m_handler_mode; | 29 | |
44 | bool v8m_secure; /* true if v8M and we're in Secure mode */ | 30 | -VMLSLDAV 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav |
45 | bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */ | 31 | +VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav |
46 | + bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */ | 32 | |
47 | /* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI | 33 | -VRMLALDAVH_S 1110 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz |
48 | * so that top level loop can generate correct syndrome information. | 34 | -VRMLALDAVH_U 1111 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz |
49 | */ | 35 | +VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz |
50 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 36 | +VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz |
51 | index XXXXXXX..XXXXXXX 100644 | 37 | |
52 | --- a/target/arm/helper.c | 38 | -VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_nosz |
53 | +++ b/target/arm/helper.c | 39 | +VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz |
54 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 40 | |
55 | flags = FIELD_DP32(flags, TBFLAG_A32, STACKCHECK, 1); | 41 | # Scalar operations |
56 | } | ||
57 | |||
58 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
59 | + FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) { | ||
60 | + flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); | ||
61 | + } | ||
62 | + | ||
63 | *pflags = flags; | ||
64 | *cs_base = 0; | ||
65 | } | ||
66 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/translate.c | ||
69 | +++ b/target/arm/translate.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
71 | } | ||
72 | } | ||
73 | |||
74 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
75 | + /* Handle M-profile lazy FP state mechanics */ | ||
76 | + | ||
77 | + /* Update ownership of FP context: set FPCCR.S to match current state */ | ||
78 | + if (s->v8m_fpccr_s_wrong) { | ||
79 | + TCGv_i32 tmp; | ||
80 | + | ||
81 | + tmp = load_cpu_field(v7m.fpccr[M_REG_S]); | ||
82 | + if (s->v8m_secure) { | ||
83 | + tcg_gen_ori_i32(tmp, tmp, R_V7M_FPCCR_S_MASK); | ||
84 | + } else { | ||
85 | + tcg_gen_andi_i32(tmp, tmp, ~R_V7M_FPCCR_S_MASK); | ||
86 | + } | ||
87 | + store_cpu_field(tmp, v7m.fpccr[M_REG_S]); | ||
88 | + /* Don't need to do this for any further FP insns in this TB */ | ||
89 | + s->v8m_fpccr_s_wrong = false; | ||
90 | + } | ||
91 | + } | ||
92 | + | ||
93 | if (extract32(insn, 28, 4) == 0xf) { | ||
94 | /* | ||
95 | * Encodings with T=1 (Thumb) or unconditional (ARM): | ||
96 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
97 | dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
98 | regime_is_secure(env, dc->mmu_idx); | ||
99 | dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK); | ||
100 | + dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG); | ||
101 | dc->cp_regs = cpu->cp_regs; | ||
102 | dc->features = env->features; | ||
103 | 42 | ||
104 | -- | 43 | -- |
105 | 2.20.1 | 44 | 2.20.1 |
106 | 45 | ||
107 | 46 | diff view generated by jsdifflib |
1 | Pushing registers to the stack for v7M needs to handle three cases: | 1 | Implement the MVE integer min/max across vector insns |
---|---|---|---|
2 | * the "normal" case where we pend exceptions | 2 | VMAXV, VMINV, VMAXAV and VMINAV, which find the maximum |
3 | * an "ignore faults" case where we set FSR bits but | 3 | from the vector elements and a general purpose register, |
4 | do not pend exceptions (this is used when we are | 4 | and store the maximum back into the general purpose |
5 | handling some kinds of derived exception on exception entry) | 5 | register. |
6 | * a "lazy FP stacking" case, where different FSR bits | 6 | |
7 | are set and the exception is pended differently | 7 | These insns overlap with VRMLALDAVH (they use what would |
8 | 8 | be RdaHi=0b110). | |
9 | Implement this by changing the existing flag argument that | ||
10 | tells us whether to ignore faults or not into an enum that | ||
11 | specifies which of the 3 modes we should handle. | ||
12 | 9 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20190416125744.27770-23-peter.maydell@linaro.org | ||
16 | --- | 12 | --- |
17 | target/arm/helper.c | 118 +++++++++++++++++++++++++++++--------------- | 13 | target/arm/helper-mve.h | 20 ++++++++++++ |
18 | 1 file changed, 79 insertions(+), 39 deletions(-) | 14 | target/arm/mve.decode | 18 +++++++++-- |
19 | 15 | target/arm/mve_helper.c | 66 ++++++++++++++++++++++++++++++++++++++ | |
20 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 16 | target/arm/translate-mve.c | 48 +++++++++++++++++++++++++++ |
21 | index XXXXXXX..XXXXXXX 100644 | 17 | 4 files changed, 150 insertions(+), 2 deletions(-) |
22 | --- a/target/arm/helper.c | 18 | |
23 | +++ b/target/arm/helper.c | 19 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
24 | @@ -XXX,XX +XXX,XX @@ static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv) | 20 | index XXXXXXX..XXXXXXX 100644 |
25 | } | 21 | --- a/target/arm/helper-mve.h |
26 | } | 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) | ||
27 | 100 | ||
28 | +/* | 101 | +/* |
29 | + * What kind of stack write are we doing? This affects how exceptions | 102 | + * Vector max/min across vector. Unlike VADDV, we must |
30 | + * generated during the stacking are treated. | 103 | + * read ra as the element size, not its full width. |
104 | + * We work with int64_t internally for simplicity. | ||
31 | + */ | 105 | + */ |
32 | +typedef enum StackingMode { | 106 | +#define DO_VMAXMINV(OP, ESIZE, TYPE, RATYPE, FN) \ |
33 | + STACK_NORMAL, | 107 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ |
34 | + STACK_IGNFAULTS, | 108 | + uint32_t ra_in) \ |
35 | + STACK_LAZYFP, | 109 | + { \ |
36 | +} StackingMode; | 110 | + uint16_t mask = mve_element_mask(env); \ |
37 | + | 111 | + unsigned e; \ |
38 | static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | 112 | + TYPE *m = vm; \ |
39 | - ARMMMUIdx mmu_idx, bool ignfault) | 113 | + int64_t ra = (RATYPE)ra_in; \ |
40 | + ARMMMUIdx mmu_idx, StackingMode mode) | 114 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ |
41 | { | 115 | + if (mask & 1) { \ |
42 | CPUState *cs = CPU(cpu); | 116 | + ra = FN(ra, m[H##ESIZE(e)]); \ |
43 | CPUARMState *env = &cpu->env; | 117 | + } \ |
44 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | 118 | + } \ |
45 | &attrs, &prot, &page_size, &fi, NULL)) { | 119 | + mve_advance_vpt(env); \ |
46 | /* MPU/SAU lookup failed */ | 120 | + return ra; \ |
47 | if (fi.type == ARMFault_QEMU_SFault) { | 121 | + } \ |
48 | - qemu_log_mask(CPU_LOG_INT, | 122 | + |
49 | - "...SecureFault with SFSR.AUVIOL during stacking\n"); | 123 | +#define DO_VMAXMINV_U(INSN, FN) \ |
50 | - env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK | R_V7M_SFSR_SFARVALID_MASK; | 124 | + DO_VMAXMINV(INSN##b, 1, uint8_t, uint8_t, FN) \ |
51 | + if (mode == STACK_LAZYFP) { | 125 | + DO_VMAXMINV(INSN##h, 2, uint16_t, uint16_t, FN) \ |
52 | + qemu_log_mask(CPU_LOG_INT, | 126 | + DO_VMAXMINV(INSN##w, 4, uint32_t, uint32_t, FN) |
53 | + "...SecureFault with SFSR.LSPERR " | 127 | +#define DO_VMAXMINV_S(INSN, FN) \ |
54 | + "during lazy stacking\n"); | 128 | + DO_VMAXMINV(INSN##b, 1, int8_t, int8_t, FN) \ |
55 | + env->v7m.sfsr |= R_V7M_SFSR_LSPERR_MASK; | 129 | + DO_VMAXMINV(INSN##h, 2, int16_t, int16_t, FN) \ |
56 | + } else { | 130 | + DO_VMAXMINV(INSN##w, 4, int32_t, int32_t, FN) |
57 | + qemu_log_mask(CPU_LOG_INT, | 131 | + |
58 | + "...SecureFault with SFSR.AUVIOL " | 132 | +/* |
59 | + "during stacking\n"); | 133 | + * Helpers for max and min of absolute values across vector: |
60 | + env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK; | 134 | + * note that we only take the absolute value of 'm', not 'n' |
61 | + } | 135 | + */ |
62 | + env->v7m.sfsr |= R_V7M_SFSR_SFARVALID_MASK; | 136 | +static int64_t do_maxa(int64_t n, int64_t m) |
63 | env->v7m.sfar = addr; | 137 | +{ |
64 | exc = ARMV7M_EXCP_SECURE; | 138 | + if (m < 0) { |
65 | exc_secure = false; | 139 | + m = -m; |
66 | } else { | 140 | + } |
67 | - qemu_log_mask(CPU_LOG_INT, "...MemManageFault with CFSR.MSTKERR\n"); | 141 | + return MAX(n, m); |
68 | - env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK; | 142 | +} |
69 | + if (mode == STACK_LAZYFP) { | 143 | + |
70 | + qemu_log_mask(CPU_LOG_INT, | 144 | +static int64_t do_mina(int64_t n, int64_t m) |
71 | + "...MemManageFault with CFSR.MLSPERR\n"); | 145 | +{ |
72 | + env->v7m.cfsr[secure] |= R_V7M_CFSR_MLSPERR_MASK; | 146 | + if (m < 0) { |
73 | + } else { | 147 | + m = -m; |
74 | + qemu_log_mask(CPU_LOG_INT, | 148 | + } |
75 | + "...MemManageFault with CFSR.MSTKERR\n"); | 149 | + return MIN(n, m); |
76 | + env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK; | 150 | +} |
77 | + } | 151 | + |
78 | exc = ARMV7M_EXCP_MEM; | 152 | +DO_VMAXMINV_S(vmaxvs, DO_MAX) |
79 | exc_secure = secure; | 153 | +DO_VMAXMINV_U(vmaxvu, DO_MAX) |
80 | } | 154 | +DO_VMAXMINV_S(vminvs, DO_MIN) |
81 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | 155 | +DO_VMAXMINV_U(vminvu, DO_MIN) |
82 | attrs, &txres); | 156 | +/* |
83 | if (txres != MEMTX_OK) { | 157 | + * VMAXAV, VMINAV treat the general purpose input as unsigned |
84 | /* BusFault trying to write the data */ | 158 | + * and the vector elements as signed. |
85 | - qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n"); | 159 | + */ |
86 | - env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK; | 160 | +DO_VMAXMINV(vmaxavb, 1, int8_t, uint8_t, do_maxa) |
87 | + if (mode == STACK_LAZYFP) { | 161 | +DO_VMAXMINV(vmaxavh, 2, int16_t, uint16_t, do_maxa) |
88 | + qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.LSPERR\n"); | 162 | +DO_VMAXMINV(vmaxavw, 4, int32_t, uint32_t, do_maxa) |
89 | + env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_LSPERR_MASK; | 163 | +DO_VMAXMINV(vminavb, 1, int8_t, uint8_t, do_mina) |
90 | + } else { | 164 | +DO_VMAXMINV(vminavh, 2, int16_t, uint16_t, do_mina) |
91 | + qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n"); | 165 | +DO_VMAXMINV(vminavw, 4, int32_t, uint32_t, do_mina) |
92 | + env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK; | 166 | + |
93 | + } | 167 | #define DO_VADDLV(OP, TYPE, LTYPE) \ |
94 | exc = ARMV7M_EXCP_BUS; | 168 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ |
95 | exc_secure = false; | 169 | uint64_t ra) \ |
96 | goto pend_fault; | 170 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
97 | @@ -XXX,XX +XXX,XX @@ pend_fault: | 171 | index XXXXXXX..XXXXXXX 100644 |
98 | * later if we have two derived exceptions. | 172 | --- a/target/arm/translate-mve.c |
99 | * The only case when we must not pend the exception but instead | 173 | +++ b/target/arm/translate-mve.c |
100 | * throw it away is if we are doing the push of the callee registers | 174 | @@ -XXX,XX +XXX,XX @@ DO_VCMP(VCMPGE, vcmpge) |
101 | - * and we've already generated a derived exception. Even in this | 175 | DO_VCMP(VCMPLT, vcmplt) |
102 | - * case we will still update the fault status registers. | 176 | DO_VCMP(VCMPGT, vcmpgt) |
103 | + * and we've already generated a derived exception (this is indicated | 177 | DO_VCMP(VCMPLE, vcmple) |
104 | + * by the caller passing STACK_IGNFAULTS). Even in this case we will | 178 | + |
105 | + * still update the fault status registers. | 179 | +static bool do_vmaxv(DisasContext *s, arg_vmaxv *a, MVEGenVADDVFn fn) |
106 | */ | 180 | +{ |
107 | - if (!ignfault) { | 181 | + /* |
108 | + switch (mode) { | 182 | + * MIN/MAX operations across a vector: compute the min or |
109 | + case STACK_NORMAL: | 183 | + * max of the initial value in a general purpose register |
110 | armv7m_nvic_set_pending_derived(env->nvic, exc, exc_secure); | 184 | + * and all the elements in the vector, and store it back |
111 | + break; | 185 | + * into the general purpose register. |
112 | + case STACK_LAZYFP: | 186 | + */ |
113 | + armv7m_nvic_set_pending_lazyfp(env->nvic, exc, exc_secure); | 187 | + TCGv_ptr qm; |
114 | + break; | 188 | + TCGv_i32 rda; |
115 | + case STACK_IGNFAULTS: | 189 | + |
116 | + break; | 190 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qm) || |
117 | } | 191 | + !fn || a->rda == 13 || a->rda == 15) { |
118 | return false; | 192 | + /* Rda cases are UNPREDICTABLE */ |
119 | } | 193 | + return false; |
120 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 194 | + } |
121 | uint32_t limit; | 195 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
122 | bool want_psp; | 196 | + return true; |
123 | uint32_t sig; | 197 | + } |
124 | + StackingMode smode = ignore_faults ? STACK_IGNFAULTS : STACK_NORMAL; | 198 | + |
125 | 199 | + qm = mve_qreg_ptr(a->qm); | |
126 | if (dotailchain) { | 200 | + rda = load_reg(s, a->rda); |
127 | bool mode = lr & R_V7M_EXCRET_MODE_MASK; | 201 | + fn(rda, cpu_env, qm, rda); |
128 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 202 | + store_reg(s, a->rda, rda); |
129 | */ | 203 | + tcg_temp_free_ptr(qm); |
130 | sig = v7m_integrity_sig(env, lr); | 204 | + mve_update_eci(s); |
131 | stacked_ok = | 205 | + return true; |
132 | - v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) && | 206 | +} |
133 | - v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, | 207 | + |
134 | - ignore_faults) && | 208 | +#define DO_VMAXV(INSN, FN) \ |
135 | - v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, | 209 | + static bool trans_##INSN(DisasContext *s, arg_vmaxv *a) \ |
136 | - ignore_faults) && | 210 | + { \ |
137 | - v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx, | 211 | + static MVEGenVADDVFn * const fns[] = { \ |
138 | - ignore_faults) && | 212 | + gen_helper_mve_##FN##b, \ |
139 | - v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx, | 213 | + gen_helper_mve_##FN##h, \ |
140 | - ignore_faults) && | 214 | + gen_helper_mve_##FN##w, \ |
141 | - v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx, | 215 | + NULL, \ |
142 | - ignore_faults) && | 216 | + }; \ |
143 | - v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx, | 217 | + return do_vmaxv(s, a, fns[a->size]); \ |
144 | - ignore_faults) && | 218 | + } |
145 | - v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx, | 219 | + |
146 | - ignore_faults) && | 220 | +DO_VMAXV(VMAXV_S, vmaxvs) |
147 | - v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx, | 221 | +DO_VMAXV(VMAXV_U, vmaxvu) |
148 | - ignore_faults); | 222 | +DO_VMAXV(VMAXAV, vmaxav) |
149 | + v7m_stack_write(cpu, frameptr, sig, mmu_idx, smode) && | 223 | +DO_VMAXV(VMINV_S, vminvs) |
150 | + v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, smode) && | 224 | +DO_VMAXV(VMINV_U, vminvu) |
151 | + v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, smode) && | 225 | +DO_VMAXV(VMINAV, vminav) |
152 | + v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx, smode) && | ||
153 | + v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx, smode) && | ||
154 | + v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx, smode) && | ||
155 | + v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx, smode) && | ||
156 | + v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx, smode) && | ||
157 | + v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx, smode); | ||
158 | |||
159 | /* Update SP regardless of whether any of the stack accesses failed. */ | ||
160 | *frame_sp_p = frameptr; | ||
161 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
162 | * if it has higher priority). | ||
163 | */ | ||
164 | stacked_ok = stacked_ok && | ||
165 | - v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) && | ||
166 | - v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) && | ||
167 | - v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) && | ||
168 | - v7m_stack_write(cpu, frameptr + 12, env->regs[3], mmu_idx, false) && | ||
169 | - v7m_stack_write(cpu, frameptr + 16, env->regs[12], mmu_idx, false) && | ||
170 | - v7m_stack_write(cpu, frameptr + 20, env->regs[14], mmu_idx, false) && | ||
171 | - v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) && | ||
172 | - v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false); | ||
173 | + v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, STACK_NORMAL) && | ||
174 | + v7m_stack_write(cpu, frameptr + 4, env->regs[1], | ||
175 | + mmu_idx, STACK_NORMAL) && | ||
176 | + v7m_stack_write(cpu, frameptr + 8, env->regs[2], | ||
177 | + mmu_idx, STACK_NORMAL) && | ||
178 | + v7m_stack_write(cpu, frameptr + 12, env->regs[3], | ||
179 | + mmu_idx, STACK_NORMAL) && | ||
180 | + v7m_stack_write(cpu, frameptr + 16, env->regs[12], | ||
181 | + mmu_idx, STACK_NORMAL) && | ||
182 | + v7m_stack_write(cpu, frameptr + 20, env->regs[14], | ||
183 | + mmu_idx, STACK_NORMAL) && | ||
184 | + v7m_stack_write(cpu, frameptr + 24, env->regs[15], | ||
185 | + mmu_idx, STACK_NORMAL) && | ||
186 | + v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, STACK_NORMAL); | ||
187 | |||
188 | if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) { | ||
189 | /* FPU is active, try to save its registers */ | ||
190 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
191 | faddr += 8; /* skip the slot for the FPSCR */ | ||
192 | } | ||
193 | stacked_ok = stacked_ok && | ||
194 | - v7m_stack_write(cpu, faddr, slo, mmu_idx, false) && | ||
195 | - v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false); | ||
196 | + v7m_stack_write(cpu, faddr, slo, | ||
197 | + mmu_idx, STACK_NORMAL) && | ||
198 | + v7m_stack_write(cpu, faddr + 4, shi, | ||
199 | + mmu_idx, STACK_NORMAL); | ||
200 | } | ||
201 | stacked_ok = stacked_ok && | ||
202 | v7m_stack_write(cpu, frameptr + 0x60, | ||
203 | - vfp_get_fpscr(env), mmu_idx, false); | ||
204 | + vfp_get_fpscr(env), mmu_idx, STACK_NORMAL); | ||
205 | if (cpacr_pass) { | ||
206 | for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) { | ||
207 | *aa32_vfp_dreg(env, i / 2) = 0; | ||
208 | -- | 226 | -- |
209 | 2.20.1 | 227 | 2.20.1 |
210 | 228 | ||
211 | 229 | diff view generated by jsdifflib |
1 | In the v7M architecture, if an exception is generated in the process | 1 | Implement the MVE VABAV insn, which computes absolute differences |
---|---|---|---|
2 | of doing the lazy stacking of FP registers, the handling of | 2 | between elements of two vectors and accumulates the result into |
3 | possible escalation to HardFault is treated differently to the normal | 3 | a general purpose register. |
4 | approach: it works based on the saved information about exception | ||
5 | readiness that was stored in the FPCCR when the stack frame was | ||
6 | created. Provide a new function armv7m_nvic_set_pending_lazyfp() | ||
7 | which pends exceptions during lazy stacking, and implements | ||
8 | this logic. | ||
9 | |||
10 | This corresponds to the pseudocode TakePreserveFPException(). | ||
11 | 4 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20190416125744.27770-22-peter.maydell@linaro.org | ||
15 | --- | 7 | --- |
16 | target/arm/cpu.h | 12 ++++++ | 8 | target/arm/helper-mve.h | 7 +++++++ |
17 | hw/intc/armv7m_nvic.c | 96 +++++++++++++++++++++++++++++++++++++++++++ | 9 | target/arm/mve.decode | 6 ++++++ |
18 | 2 files changed, 108 insertions(+) | 10 | target/arm/mve_helper.c | 26 +++++++++++++++++++++++ |
11 | target/arm/translate-mve.c | 43 ++++++++++++++++++++++++++++++++++++++ | ||
12 | 4 files changed, 82 insertions(+) | ||
19 | 13 | ||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 16 | --- a/target/arm/helper-mve.h |
23 | +++ b/target/arm/cpu.h | 17 | +++ b/target/arm/helper-mve.h |
24 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure); | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vminavw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
25 | * a different exception). | 19 | DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) |
26 | */ | 20 | DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) |
27 | void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure); | 21 | |
28 | +/** | 22 | +DEF_HELPER_FLAGS_4(mve_vabavsb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
29 | + * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending | 23 | +DEF_HELPER_FLAGS_4(mve_vabavsh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
30 | + * @opaque: the NVIC | 24 | +DEF_HELPER_FLAGS_4(mve_vabavsw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
31 | + * @irq: the exception number to mark pending | 25 | +DEF_HELPER_FLAGS_4(mve_vabavub, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
32 | + * @secure: false for non-banked exceptions or for the nonsecure | 26 | +DEF_HELPER_FLAGS_4(mve_vabavuh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
33 | + * version of a banked exception, true for the secure version of a banked | 27 | +DEF_HELPER_FLAGS_4(mve_vabavuw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
34 | + * exception. | 28 | + |
35 | + * | 29 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) |
36 | + * Similar to armv7m_nvic_set_pending(), but specifically for exceptions | 30 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) |
37 | + * generated in the course of lazy stacking of FP registers. | 31 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) |
38 | + */ | 32 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
39 | +void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure); | ||
40 | /** | ||
41 | * armv7m_nvic_get_pending_irq_info: return highest priority pending | ||
42 | * exception, and whether it targets Secure state | ||
43 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/hw/intc/armv7m_nvic.c | 34 | --- a/target/arm/mve.decode |
46 | +++ b/hw/intc/armv7m_nvic.c | 35 | +++ b/target/arm/mve.decode |
47 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure) | 36 | @@ -XXX,XX +XXX,XX @@ |
48 | do_armv7m_nvic_set_pending(opaque, irq, secure, true); | 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 | ||
49 | } | 46 | } |
50 | 47 | ||
51 | +void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure) | 48 | +@vabav .... .... .. size:2 .... rda:4 .... .... .... &vabav qn=%qn qm=%qm |
52 | +{ | ||
53 | + /* | ||
54 | + * Pend an exception during lazy FP stacking. This differs | ||
55 | + * from the usual exception pending because the logic for | ||
56 | + * whether we should escalate depends on the saved context | ||
57 | + * in the FPCCR register, not on the current state of the CPU/NVIC. | ||
58 | + */ | ||
59 | + NVICState *s = (NVICState *)opaque; | ||
60 | + bool banked = exc_is_banked(irq); | ||
61 | + VecInfo *vec; | ||
62 | + bool targets_secure; | ||
63 | + bool escalate = false; | ||
64 | + /* | ||
65 | + * We will only look at bits in fpccr if this is a banked exception | ||
66 | + * (in which case 'secure' tells us whether it is the S or NS version). | ||
67 | + * All the bits for the non-banked exceptions are in fpccr_s. | ||
68 | + */ | ||
69 | + uint32_t fpccr_s = s->cpu->env.v7m.fpccr[M_REG_S]; | ||
70 | + uint32_t fpccr = s->cpu->env.v7m.fpccr[secure]; | ||
71 | + | 49 | + |
72 | + assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq); | 50 | +VABAV_S 111 0 1110 10 .. ... 0 .... 1111 . 0 . 0 ... 1 @vabav |
73 | + assert(!secure || banked); | 51 | +VABAV_U 111 1 1110 10 .. ... 0 .... 1111 . 0 . 0 ... 1 @vabav |
74 | + | 52 | + |
75 | + vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq]; | 53 | # Logical immediate operations (1 reg and modified-immediate) |
76 | + | 54 | |
77 | + targets_secure = banked ? secure : exc_targets_secure(s, irq); | 55 | # The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but |
78 | + | 56 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
79 | + switch (irq) { | 57 | index XXXXXXX..XXXXXXX 100644 |
80 | + case ARMV7M_EXCP_DEBUG: | 58 | --- a/target/arm/mve_helper.c |
81 | + if (!(fpccr_s & R_V7M_FPCCR_MONRDY_MASK)) { | 59 | +++ b/target/arm/mve_helper.c |
82 | + /* Ignore DebugMonitor exception */ | 60 | @@ -XXX,XX +XXX,XX @@ DO_VMAXMINV(vminavb, 1, int8_t, uint8_t, do_mina) |
83 | + return; | 61 | DO_VMAXMINV(vminavh, 2, int16_t, uint16_t, do_mina) |
84 | + } | 62 | DO_VMAXMINV(vminavw, 4, int32_t, uint32_t, do_mina) |
85 | + break; | 63 | |
86 | + case ARMV7M_EXCP_MEM: | 64 | +#define DO_VABAV(OP, ESIZE, TYPE) \ |
87 | + escalate = !(fpccr & R_V7M_FPCCR_MMRDY_MASK); | 65 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ |
88 | + break; | 66 | + void *vm, uint32_t ra) \ |
89 | + case ARMV7M_EXCP_USAGE: | 67 | + { \ |
90 | + escalate = !(fpccr & R_V7M_FPCCR_UFRDY_MASK); | 68 | + uint16_t mask = mve_element_mask(env); \ |
91 | + break; | 69 | + unsigned e; \ |
92 | + case ARMV7M_EXCP_BUS: | 70 | + TYPE *m = vm, *n = vn; \ |
93 | + escalate = !(fpccr_s & R_V7M_FPCCR_BFRDY_MASK); | 71 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ |
94 | + break; | 72 | + if (mask & 1) { \ |
95 | + case ARMV7M_EXCP_SECURE: | 73 | + int64_t n0 = n[H##ESIZE(e)]; \ |
96 | + escalate = !(fpccr_s & R_V7M_FPCCR_SFRDY_MASK); | 74 | + int64_t m0 = m[H##ESIZE(e)]; \ |
97 | + break; | 75 | + uint32_t r = n0 >= m0 ? (n0 - m0) : (m0 - n0); \ |
98 | + default: | 76 | + ra += r; \ |
99 | + g_assert_not_reached(); | 77 | + } \ |
78 | + } \ | ||
79 | + mve_advance_vpt(env); \ | ||
80 | + return ra; \ | ||
100 | + } | 81 | + } |
101 | + | 82 | + |
102 | + if (escalate) { | 83 | +DO_VABAV(vabavsb, 1, int8_t) |
103 | + /* | 84 | +DO_VABAV(vabavsh, 2, int16_t) |
104 | + * Escalate to HardFault: faults that initially targeted Secure | 85 | +DO_VABAV(vabavsw, 4, int32_t) |
105 | + * continue to do so, even if HF normally targets NonSecure. | 86 | +DO_VABAV(vabavub, 1, uint8_t) |
106 | + */ | 87 | +DO_VABAV(vabavuh, 2, uint16_t) |
107 | + irq = ARMV7M_EXCP_HARD; | 88 | +DO_VABAV(vabavuw, 4, uint32_t) |
108 | + if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) && | 89 | + |
109 | + (targets_secure || | 90 | #define DO_VADDLV(OP, TYPE, LTYPE) \ |
110 | + !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK))) { | 91 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ |
111 | + vec = &s->sec_vectors[irq]; | 92 | uint64_t ra) \ |
112 | + } else { | 93 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
113 | + vec = &s->vectors[irq]; | 94 | index XXXXXXX..XXXXXXX 100644 |
114 | + } | 95 | --- a/target/arm/translate-mve.c |
96 | +++ b/target/arm/translate-mve.c | ||
97 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
98 | typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
99 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
100 | typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
101 | +typedef void MVEGenVABAVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
102 | |||
103 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
104 | static inline long mve_qreg_offset(unsigned reg) | ||
105 | @@ -XXX,XX +XXX,XX @@ DO_VMAXV(VMAXAV, vmaxav) | ||
106 | DO_VMAXV(VMINV_S, vminvs) | ||
107 | DO_VMAXV(VMINV_U, vminvu) | ||
108 | DO_VMAXV(VMINAV, vminav) | ||
109 | + | ||
110 | +static bool do_vabav(DisasContext *s, arg_vabav *a, MVEGenVABAVFn *fn) | ||
111 | +{ | ||
112 | + /* Absolute difference accumulated across vector */ | ||
113 | + TCGv_ptr qn, qm; | ||
114 | + TCGv_i32 rda; | ||
115 | + | ||
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; | ||
115 | + } | 124 | + } |
116 | + | 125 | + |
117 | + if (!vec->enabled || | 126 | + qm = mve_qreg_ptr(a->qm); |
118 | + nvic_exec_prio(s) <= exc_group_prio(s, vec->prio, secure)) { | 127 | + qn = mve_qreg_ptr(a->qn); |
119 | + if (!(fpccr_s & R_V7M_FPCCR_HFRDY_MASK)) { | 128 | + rda = load_reg(s, a->rda); |
120 | + /* | 129 | + fn(rda, cpu_env, qn, qm, rda); |
121 | + * We want to escalate to HardFault but the context the | 130 | + store_reg(s, a->rda, rda); |
122 | + * FP state belongs to prevents the exception pre-empting. | 131 | + tcg_temp_free_ptr(qm); |
123 | + */ | 132 | + tcg_temp_free_ptr(qn); |
124 | + cpu_abort(&s->cpu->parent_obj, | 133 | + mve_update_eci(s); |
125 | + "Lockup: can't escalate to HardFault during " | 134 | + return true; |
126 | + "lazy FP register stacking\n"); | 135 | +} |
127 | + } | 136 | + |
137 | +#define DO_VABAV(INSN, FN) \ | ||
138 | + static bool trans_##INSN(DisasContext *s, arg_vabav *a) \ | ||
139 | + { \ | ||
140 | + static MVEGenVABAVFn * const fns[] = { \ | ||
141 | + gen_helper_mve_##FN##b, \ | ||
142 | + gen_helper_mve_##FN##h, \ | ||
143 | + gen_helper_mve_##FN##w, \ | ||
144 | + NULL, \ | ||
145 | + }; \ | ||
146 | + return do_vabav(s, a, fns[a->size]); \ | ||
128 | + } | 147 | + } |
129 | + | 148 | + |
130 | + if (escalate) { | 149 | +DO_VABAV(VABAV_S, vabavs) |
131 | + s->cpu->env.v7m.hfsr |= R_V7M_HFSR_FORCED_MASK; | 150 | +DO_VABAV(VABAV_U, vabavu) |
132 | + } | ||
133 | + if (!vec->pending) { | ||
134 | + vec->pending = 1; | ||
135 | + /* | ||
136 | + * We do not call nvic_irq_update(), because we know our caller | ||
137 | + * is going to handle causing us to take the exception by | ||
138 | + * raising EXCP_LAZYFP, so raising the IRQ line would be | ||
139 | + * pointless extra work. We just need to recompute the | ||
140 | + * priorities so that armv7m_nvic_can_take_pending_exception() | ||
141 | + * returns the right answer. | ||
142 | + */ | ||
143 | + nvic_recompute_state(s); | ||
144 | + } | ||
145 | +} | ||
146 | + | ||
147 | /* Make pending IRQ active. */ | ||
148 | void armv7m_nvic_acknowledge_irq(void *opaque) | ||
149 | { | ||
150 | -- | 151 | -- |
151 | 2.20.1 | 152 | 2.20.1 |
152 | 153 | ||
153 | 154 | diff view generated by jsdifflib |
1 | Handle floating point registers in exception entry. | 1 | Implement the MVE narrowing move insns VMOVN, VQMOVN and VQMOVUN. |
---|---|---|---|
2 | This corresponds to the FP-specific parts of the pseudocode | 2 | These take a double-width input, narrow it (possibly saturating) and |
3 | functions ActivateException() and PushStack(). | 3 | store the result to either the top or bottom half of the output |
4 | 4 | element. | |
5 | We defer the code corresponding to UpdateFPCCR() to a later patch. | ||
6 | 5 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20190416125744.27770-11-peter.maydell@linaro.org | ||
10 | --- | 8 | --- |
11 | target/arm/helper.c | 98 +++++++++++++++++++++++++++++++++++++++++++-- | 9 | target/arm/helper-mve.h | 20 ++++++++++ |
12 | 1 file changed, 95 insertions(+), 3 deletions(-) | 10 | target/arm/mve.decode | 12 ++++++ |
13 | 11 | target/arm/mve_helper.c | 78 ++++++++++++++++++++++++++++++++++++++ | |
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 12 | target/arm/translate-mve.c | 22 +++++++++++ |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | 4 files changed, 132 insertions(+) |
16 | --- a/target/arm/helper.c | 14 | |
17 | +++ b/target/arm/helper.c | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
18 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | switch_v7m_security_state(env, targets_secure); | 17 | --- a/target/arm/helper-mve.h |
20 | write_v7m_control_spsel(env, 0); | 18 | +++ b/target/arm/helper-mve.h |
21 | arm_clear_exclusive(env); | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) |
22 | + /* Clear SFPA and FPCA (has no effect if no FPU) */ | 20 | DEF_HELPER_FLAGS_3(mve_vfnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
23 | + env->v7m.control[M_REG_S] &= | 21 | DEF_HELPER_FLAGS_3(mve_vfnegs, TCG_CALL_NO_WG, void, env, ptr, ptr) |
24 | + ~(R_V7M_CONTROL_FPCA_MASK | R_V7M_CONTROL_SFPA_MASK); | 22 | |
25 | /* Clear IT bits */ | 23 | +DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
26 | env->condexec_bits = 0; | 24 | +DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
27 | env->regs[14] = lr; | 25 | +DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
28 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 26 | +DEF_HELPER_FLAGS_3(mve_vmovnth, TCG_CALL_NO_WG, void, env, ptr, ptr) |
29 | uint32_t xpsr = xpsr_read(env); | 27 | + |
30 | uint32_t frameptr = env->regs[13]; | 28 | +DEF_HELPER_FLAGS_3(mve_vqmovunbb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
31 | ARMMMUIdx mmu_idx = arm_mmu_idx(env); | 29 | +DEF_HELPER_FLAGS_3(mve_vqmovunbh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
32 | + uint32_t framesize; | 30 | +DEF_HELPER_FLAGS_3(mve_vqmovuntb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
33 | + bool nsacr_cp10 = extract32(env->v7m.nsacr, 10, 1); | 31 | +DEF_HELPER_FLAGS_3(mve_vqmovunth, TCG_CALL_NO_WG, void, env, ptr, ptr) |
34 | + | 32 | + |
35 | + if ((env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) && | 33 | +DEF_HELPER_FLAGS_3(mve_vqmovnbsb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
36 | + (env->v7m.secure || nsacr_cp10)) { | 34 | +DEF_HELPER_FLAGS_3(mve_vqmovnbsh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
37 | + if (env->v7m.secure && | 35 | +DEF_HELPER_FLAGS_3(mve_vqmovntsb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
38 | + env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK) { | 36 | +DEF_HELPER_FLAGS_3(mve_vqmovntsh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
39 | + framesize = 0xa8; | 37 | + |
40 | + } else { | 38 | +DEF_HELPER_FLAGS_3(mve_vqmovnbub, TCG_CALL_NO_WG, void, env, ptr, ptr) |
41 | + framesize = 0x68; | 39 | +DEF_HELPER_FLAGS_3(mve_vqmovnbuh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
42 | + } | 40 | +DEF_HELPER_FLAGS_3(mve_vqmovntub, TCG_CALL_NO_WG, void, env, ptr, ptr) |
43 | + } else { | 41 | +DEF_HELPER_FLAGS_3(mve_vqmovntuh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
44 | + framesize = 0x20; | 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); \ | ||
45 | + } | 111 | + } |
46 | 112 | + | |
47 | /* Align stack pointer if the guest wants that */ | 113 | +DO_VMOVN(vmovnbb, false, 1, uint8_t, 2, uint16_t) |
48 | if ((frameptr & 4) && | 114 | +DO_VMOVN(vmovnbh, false, 2, uint16_t, 4, uint32_t) |
49 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 115 | +DO_VMOVN(vmovntb, true, 1, uint8_t, 2, uint16_t) |
50 | xpsr |= XPSR_SPREALIGN; | 116 | +DO_VMOVN(vmovnth, true, 2, uint16_t, 4, uint32_t) |
51 | } | 117 | + |
52 | 118 | +#define DO_VMOVN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | |
53 | - frameptr -= 0x20; | 119 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ |
54 | + xpsr &= ~XPSR_SFPA; | 120 | + { \ |
55 | + if (env->v7m.secure && | 121 | + LTYPE *m = vm; \ |
56 | + (env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) { | 122 | + TYPE *d = vd; \ |
57 | + xpsr |= XPSR_SFPA; | 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); \ | ||
58 | + } | 137 | + } |
59 | + | 138 | + |
60 | + frameptr -= framesize; | 139 | +#define DO_VMOVN_SAT_UB(BOP, TOP, FN) \ |
61 | 140 | + DO_VMOVN_SAT(BOP, false, 1, uint8_t, 2, uint16_t, FN) \ | |
62 | if (arm_feature(env, ARM_FEATURE_V8)) { | 141 | + DO_VMOVN_SAT(TOP, true, 1, uint8_t, 2, uint16_t, FN) |
63 | uint32_t limit = v7m_sp_limit(env); | 142 | + |
64 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 143 | +#define DO_VMOVN_SAT_UH(BOP, TOP, FN) \ |
65 | v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) && | 144 | + DO_VMOVN_SAT(BOP, false, 2, uint16_t, 4, uint32_t, FN) \ |
66 | v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false); | 145 | + DO_VMOVN_SAT(TOP, true, 2, uint16_t, 4, uint32_t, FN) |
67 | 146 | + | |
68 | + if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) { | 147 | +#define DO_VMOVN_SAT_SB(BOP, TOP, FN) \ |
69 | + /* FPU is active, try to save its registers */ | 148 | + DO_VMOVN_SAT(BOP, false, 1, int8_t, 2, int16_t, FN) \ |
70 | + bool fpccr_s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | 149 | + DO_VMOVN_SAT(TOP, true, 1, int8_t, 2, int16_t, FN) |
71 | + bool lspact = env->v7m.fpccr[fpccr_s] & R_V7M_FPCCR_LSPACT_MASK; | 150 | + |
72 | + | 151 | +#define DO_VMOVN_SAT_SH(BOP, TOP, FN) \ |
73 | + if (lspact && arm_feature(env, ARM_FEATURE_M_SECURITY)) { | 152 | + DO_VMOVN_SAT(BOP, false, 2, int16_t, 4, int32_t, FN) \ |
74 | + qemu_log_mask(CPU_LOG_INT, | 153 | + DO_VMOVN_SAT(TOP, true, 2, int16_t, 4, int32_t, FN) |
75 | + "...SecureFault because LSPACT and FPCA both set\n"); | 154 | + |
76 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | 155 | +#define DO_VQMOVN_SB(N, SATP) \ |
77 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | 156 | + do_sat_bhs((int64_t)(N), INT8_MIN, INT8_MAX, SATP) |
78 | + } else if (!env->v7m.secure && !nsacr_cp10) { | 157 | +#define DO_VQMOVN_UB(N, SATP) \ |
79 | + qemu_log_mask(CPU_LOG_INT, | 158 | + do_sat_bhs((uint64_t)(N), 0, UINT8_MAX, SATP) |
80 | + "...Secure UsageFault with CFSR.NOCP because " | 159 | +#define DO_VQMOVUN_B(N, SATP) \ |
81 | + "NSACR.CP10 prevents stacking FP regs\n"); | 160 | + do_sat_bhs((int64_t)(N), 0, UINT8_MAX, SATP) |
82 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S); | 161 | + |
83 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK; | 162 | +#define DO_VQMOVN_SH(N, SATP) \ |
84 | + } else { | 163 | + do_sat_bhs((int64_t)(N), INT16_MIN, INT16_MAX, SATP) |
85 | + if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) { | 164 | +#define DO_VQMOVN_UH(N, SATP) \ |
86 | + /* Lazy stacking disabled, save registers now */ | 165 | + do_sat_bhs((uint64_t)(N), 0, UINT16_MAX, SATP) |
87 | + int i; | 166 | +#define DO_VQMOVUN_H(N, SATP) \ |
88 | + bool cpacr_pass = v7m_cpacr_pass(env, env->v7m.secure, | 167 | + do_sat_bhs((int64_t)(N), 0, UINT16_MAX, SATP) |
89 | + arm_current_el(env) != 0); | 168 | + |
90 | + | 169 | +DO_VMOVN_SAT_SB(vqmovnbsb, vqmovntsb, DO_VQMOVN_SB) |
91 | + if (stacked_ok && !cpacr_pass) { | 170 | +DO_VMOVN_SAT_SH(vqmovnbsh, vqmovntsh, DO_VQMOVN_SH) |
92 | + /* | 171 | +DO_VMOVN_SAT_UB(vqmovnbub, vqmovntub, DO_VQMOVN_UB) |
93 | + * Take UsageFault if CPACR forbids access. The pseudocode | 172 | +DO_VMOVN_SAT_UH(vqmovnbuh, vqmovntuh, DO_VQMOVN_UH) |
94 | + * here does a full CheckCPEnabled() but we know the NSACR | 173 | +DO_VMOVN_SAT_SB(vqmovunbb, vqmovuntb, DO_VQMOVUN_B) |
95 | + * check can never fail as we have already handled that. | 174 | +DO_VMOVN_SAT_SH(vqmovunbh, vqmovunth, DO_VQMOVUN_H) |
96 | + */ | 175 | + |
97 | + qemu_log_mask(CPU_LOG_INT, | 176 | uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, |
98 | + "...UsageFault with CFSR.NOCP because " | 177 | uint32_t shift) |
99 | + "CPACR.CP10 prevents stacking FP regs\n"); | 178 | { |
100 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | 179 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
101 | + env->v7m.secure); | 180 | index XXXXXXX..XXXXXXX 100644 |
102 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK; | 181 | --- a/target/arm/translate-mve.c |
103 | + stacked_ok = false; | 182 | +++ b/target/arm/translate-mve.c |
104 | + } | 183 | @@ -XXX,XX +XXX,XX @@ DO_1OP(VCLS, vcls) |
105 | + | 184 | DO_1OP(VABS, vabs) |
106 | + for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) { | 185 | DO_1OP(VNEG, vneg) |
107 | + uint64_t dn = *aa32_vfp_dreg(env, i / 2); | 186 | |
108 | + uint32_t faddr = frameptr + 0x20 + 4 * i; | 187 | +/* Narrowing moves: only size 0 and 1 are valid */ |
109 | + uint32_t slo = extract64(dn, 0, 32); | 188 | +#define DO_VMOVN(INSN, FN) \ |
110 | + uint32_t shi = extract64(dn, 32, 32); | 189 | + static bool trans_##INSN(DisasContext *s, arg_1op *a) \ |
111 | + | 190 | + { \ |
112 | + if (i >= 16) { | 191 | + static MVEGenOneOpFn * const fns[] = { \ |
113 | + faddr += 8; /* skip the slot for the FPSCR */ | 192 | + gen_helper_mve_##FN##b, \ |
114 | + } | 193 | + gen_helper_mve_##FN##h, \ |
115 | + stacked_ok = stacked_ok && | 194 | + NULL, \ |
116 | + v7m_stack_write(cpu, faddr, slo, mmu_idx, false) && | 195 | + NULL, \ |
117 | + v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false); | 196 | + }; \ |
118 | + } | 197 | + return do_1op(s, a, fns[a->size]); \ |
119 | + stacked_ok = stacked_ok && | ||
120 | + v7m_stack_write(cpu, frameptr + 0x60, | ||
121 | + vfp_get_fpscr(env), mmu_idx, false); | ||
122 | + if (cpacr_pass) { | ||
123 | + for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) { | ||
124 | + *aa32_vfp_dreg(env, i / 2) = 0; | ||
125 | + } | ||
126 | + vfp_set_fpscr(env, 0); | ||
127 | + } | ||
128 | + } else { | ||
129 | + /* Lazy stacking enabled, save necessary info to stack later */ | ||
130 | + /* TODO : equivalent of UpdateFPCCR() pseudocode */ | ||
131 | + } | ||
132 | + } | ||
133 | + } | 198 | + } |
134 | + | 199 | + |
135 | /* | 200 | +DO_VMOVN(VMOVNB, vmovnb) |
136 | * If we broke a stack limit then SP was already updated earlier; | 201 | +DO_VMOVN(VMOVNT, vmovnt) |
137 | * otherwise we update SP regardless of whether any of the stack | 202 | +DO_VMOVN(VQMOVUNB, vqmovunb) |
138 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 203 | +DO_VMOVN(VQMOVUNT, vqmovunt) |
139 | 204 | +DO_VMOVN(VQMOVN_BS, vqmovnbs) | |
140 | if (arm_feature(env, ARM_FEATURE_V8)) { | 205 | +DO_VMOVN(VQMOVN_TS, vqmovnts) |
141 | lr = R_V7M_EXCRET_RES1_MASK | | 206 | +DO_VMOVN(VQMOVN_BU, vqmovnbu) |
142 | - R_V7M_EXCRET_DCRS_MASK | | 207 | +DO_VMOVN(VQMOVN_TU, vqmovntu) |
143 | - R_V7M_EXCRET_FTYPE_MASK; | 208 | + |
144 | + R_V7M_EXCRET_DCRS_MASK; | 209 | static bool trans_VREV16(DisasContext *s, arg_1op *a) |
145 | /* The S bit indicates whether we should return to Secure | 210 | { |
146 | * or NonSecure (ie our current state). | 211 | static MVEGenOneOpFn * const fns[] = { |
147 | * The ES bit indicates whether we're taking this exception | ||
148 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
149 | if (env->v7m.secure) { | ||
150 | lr |= R_V7M_EXCRET_S_MASK; | ||
151 | } | ||
152 | + if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) { | ||
153 | + lr |= R_V7M_EXCRET_FTYPE_MASK; | ||
154 | + } | ||
155 | } else { | ||
156 | lr = R_V7M_EXCRET_RES1_MASK | | ||
157 | R_V7M_EXCRET_S_MASK | | ||
158 | -- | 212 | -- |
159 | 2.20.1 | 213 | 2.20.1 |
160 | 214 | ||
161 | 215 | diff view generated by jsdifflib |
1 | Correct the decode of the M-profile "coprocessor and | 1 | The MVEGenDualAccOpFn is a bit misnamed, since it is used for |
---|---|---|---|
2 | floating-point instructions" space: | 2 | the "long dual accumulate" operations that use a 64-bit |
3 | * op0 == 0b11 is always unallocated | 3 | accumulator. Rename it to MVEGenLongDualAccOpFn so we can |
4 | * if the CPU has an FPU then all insns with op1 == 0b101 | 4 | use the former name for the 32-bit accumulator insns. |
5 | are floating point and go to disas_vfp_insn() | ||
6 | |||
7 | For the moment we leave VLLDM and VLSTM as NOPs; in | ||
8 | a later commit we will fill in the proper implementation | ||
9 | for the case where an FPU is present. | ||
10 | 5 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Message-id: 20190416125744.27770-7-peter.maydell@linaro.org | ||
14 | --- | 8 | --- |
15 | target/arm/translate.c | 26 ++++++++++++++++++++++---- | 9 | target/arm/translate-mve.c | 16 ++++++++-------- |
16 | 1 file changed, 22 insertions(+), 4 deletions(-) | 10 | 1 file changed, 8 insertions(+), 8 deletions(-) |
17 | 11 | ||
18 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 12 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
19 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/translate.c | 14 | --- a/target/arm/translate-mve.c |
21 | +++ b/target/arm/translate.c | 15 | +++ b/target/arm/translate-mve.c |
22 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 16 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); |
23 | case 6: case 7: case 14: case 15: | 17 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); |
24 | /* Coprocessor. */ | 18 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); |
25 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | 19 | typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); |
26 | - /* We don't currently implement M profile FP support, | 20 | -typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); |
27 | - * so this entire space should give a NOCP fault, with | 21 | +typedef void MVEGenLongDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); |
28 | - * the exception of the v8M VLLDM and VLSTM insns, which | 22 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); |
29 | - * must be NOPs in Secure state and UNDEF in Nonsecure state. | 23 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); |
30 | + /* 0b111x_11xx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx */ | 24 | typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); |
31 | + if (extract32(insn, 24, 2) == 3) { | 25 | @@ -XXX,XX +XXX,XX @@ static bool trans_VQDMULLT_scalar(DisasContext *s, arg_2scalar *a) |
32 | + goto illegal_op; /* op0 = 0b11 : unallocated */ | 26 | } |
33 | + } | 27 | |
34 | + | 28 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, |
35 | + /* | 29 | - MVEGenDualAccOpFn *fn) |
36 | + * Decode VLLDM and VLSTM first: these are nonstandard because: | 30 | + MVEGenLongDualAccOpFn *fn) |
37 | + * * if there is no FPU then these insns must NOP in | 31 | { |
38 | + * Secure state and UNDEF in Nonsecure state | 32 | TCGv_ptr qn, qm; |
39 | + * * if there is an FPU then these insns do not have | 33 | TCGv_i64 rda; |
40 | + * the usual behaviour that disas_vfp_insn() provides of | 34 | @@ -XXX,XX +XXX,XX @@ static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, |
41 | + * being controlled by CPACR/NSACR enable bits or the | 35 | |
42 | + * lazy-stacking logic. | 36 | static bool trans_VMLALDAV_S(DisasContext *s, arg_vmlaldav *a) |
43 | */ | 37 | { |
44 | if (arm_dc_feature(s, ARM_FEATURE_V8) && | 38 | - static MVEGenDualAccOpFn * const fns[4][2] = { |
45 | (insn & 0xffa00f00) == 0xec200a00) { | 39 | + static MVEGenLongDualAccOpFn * const fns[4][2] = { |
46 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 40 | { NULL, NULL }, |
47 | /* Just NOP since FP support is not implemented */ | 41 | { gen_helper_mve_vmlaldavsh, gen_helper_mve_vmlaldavxsh }, |
48 | break; | 42 | { gen_helper_mve_vmlaldavsw, gen_helper_mve_vmlaldavxsw }, |
49 | } | 43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLALDAV_S(DisasContext *s, arg_vmlaldav *a) |
50 | + if (arm_dc_feature(s, ARM_FEATURE_VFP) && | 44 | |
51 | + ((insn >> 8) & 0xe) == 10) { | 45 | static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) |
52 | + /* FP, and the CPU supports it */ | 46 | { |
53 | + if (disas_vfp_insn(s, insn)) { | 47 | - static MVEGenDualAccOpFn * const fns[4][2] = { |
54 | + goto illegal_op; | 48 | + static MVEGenLongDualAccOpFn * const fns[4][2] = { |
55 | + } | 49 | { NULL, NULL }, |
56 | + break; | 50 | { gen_helper_mve_vmlaldavuh, NULL }, |
57 | + } | 51 | { gen_helper_mve_vmlaldavuw, NULL }, |
58 | + | 52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) |
59 | /* All other insns: NOCP */ | 53 | |
60 | gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | 54 | static bool trans_VMLSLDAV(DisasContext *s, arg_vmlaldav *a) |
61 | default_exception_el(s)); | 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]); | ||
62 | -- | 88 | -- |
63 | 2.20.1 | 89 | 2.20.1 |
64 | 90 | ||
65 | 91 | diff view generated by jsdifflib |
1 | The M-profile floating point support has three associated config | 1 | Implement the MVE VMLADAV and VMLSLDAV insns. Like the VMLALDAV and |
---|---|---|---|
2 | registers: FPCAR, FPCCR and FPDSCR. It also makes the registers | 2 | VMLSLDAV insns already implemented, these accumulate multiplied |
3 | CPACR and NSACR have behaviour other than reads-as-zero. | 3 | vector elements; but they accumulate a 32-bit result rather than a |
4 | Add support for all of these as simple reads-as-written registers. | 4 | 64-bit one. |
5 | We will hook up actual functionality later. | 5 | |
6 | 6 | Note that these encodings overlap with what would be RdaHi=0b111 for | |
7 | The main complexity here is handling the FPCCR register, which | 7 | VMLALDAV, VMLSLDAV, VRMLALDAVH and VRMLSLDAVH. |
8 | has a mix of banked and unbanked bits. | ||
9 | |||
10 | Note that we don't share storage with the A-profile | ||
11 | cpu->cp15.nsacr and cpu->cp15.cpacr_el1, though the behaviour | ||
12 | is quite similar, for two reasons: | ||
13 | * the M profile CPACR is banked between security states | ||
14 | * it preserves the invariant that M profile uses no state | ||
15 | inside the cp15 substruct | ||
16 | 8 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
19 | Message-id: 20190416125744.27770-4-peter.maydell@linaro.org | ||
20 | --- | 11 | --- |
21 | target/arm/cpu.h | 34 ++++++++++++ | 12 | target/arm/helper-mve.h | 17 ++++++++++ |
22 | hw/intc/armv7m_nvic.c | 125 ++++++++++++++++++++++++++++++++++++++++++ | 13 | target/arm/mve.decode | 33 +++++++++++++++++--- |
23 | target/arm/cpu.c | 5 ++ | 14 | target/arm/mve_helper.c | 41 ++++++++++++++++++++++++ |
24 | target/arm/machine.c | 16 ++++++ | 15 | target/arm/translate-mve.c | 64 ++++++++++++++++++++++++++++++++++++++ |
25 | 4 files changed, 180 insertions(+) | 16 | 4 files changed, 150 insertions(+), 5 deletions(-) |
26 | 17 | ||
27 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
28 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/cpu.h | 20 | --- a/target/arm/helper-mve.h |
30 | +++ b/target/arm/cpu.h | 21 | +++ b/target/arm/helper-mve.h |
31 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrmlaldavhuw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) |
32 | uint32_t scr[M_REG_NUM_BANKS]; | 23 | DEF_HELPER_FLAGS_4(mve_vrmlsldavhsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) |
33 | uint32_t msplim[M_REG_NUM_BANKS]; | 24 | DEF_HELPER_FLAGS_4(mve_vrmlsldavhxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) |
34 | uint32_t psplim[M_REG_NUM_BANKS]; | 25 | |
35 | + uint32_t fpcar[M_REG_NUM_BANKS]; | 26 | +DEF_HELPER_FLAGS_4(mve_vmladavsb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
36 | + uint32_t fpccr[M_REG_NUM_BANKS]; | 27 | +DEF_HELPER_FLAGS_4(mve_vmladavsh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
37 | + uint32_t fpdscr[M_REG_NUM_BANKS]; | 28 | +DEF_HELPER_FLAGS_4(mve_vmladavsw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
38 | + uint32_t cpacr[M_REG_NUM_BANKS]; | 29 | +DEF_HELPER_FLAGS_4(mve_vmladavub, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
39 | + uint32_t nsacr; | 30 | +DEF_HELPER_FLAGS_4(mve_vmladavuh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
40 | } v7m; | 31 | +DEF_HELPER_FLAGS_4(mve_vmladavuw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
41 | 32 | +DEF_HELPER_FLAGS_4(mve_vmlsdavb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | |
42 | /* Information associated with an exception about to be taken: | 33 | +DEF_HELPER_FLAGS_4(mve_vmlsdavh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
43 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_CSSELR, LEVEL, 1, 3) | 34 | +DEF_HELPER_FLAGS_4(mve_vmlsdavw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
44 | */ | 35 | + |
45 | FIELD(V7M_CSSELR, INDEX, 0, 4) | 36 | +DEF_HELPER_FLAGS_4(mve_vmladavsxb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
46 | 37 | +DEF_HELPER_FLAGS_4(mve_vmladavsxh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | |
47 | +/* v7M FPCCR bits */ | 38 | +DEF_HELPER_FLAGS_4(mve_vmladavsxw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
48 | +FIELD(V7M_FPCCR, LSPACT, 0, 1) | 39 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
49 | +FIELD(V7M_FPCCR, USER, 1, 1) | 40 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
50 | +FIELD(V7M_FPCCR, S, 2, 1) | 41 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) |
51 | +FIELD(V7M_FPCCR, THREAD, 3, 1) | 42 | + |
52 | +FIELD(V7M_FPCCR, HFRDY, 4, 1) | 43 | DEF_HELPER_FLAGS_3(mve_vaddvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) |
53 | +FIELD(V7M_FPCCR, MMRDY, 5, 1) | 44 | DEF_HELPER_FLAGS_3(mve_vaddvub, TCG_CALL_NO_WG, i32, env, ptr, i32) |
54 | +FIELD(V7M_FPCCR, BFRDY, 6, 1) | 45 | DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) |
55 | +FIELD(V7M_FPCCR, SFRDY, 7, 1) | 46 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
56 | +FIELD(V7M_FPCCR, MONRDY, 8, 1) | 47 | index XXXXXXX..XXXXXXX 100644 |
57 | +FIELD(V7M_FPCCR, SPLIMVIOL, 9, 1) | 48 | --- a/target/arm/mve.decode |
58 | +FIELD(V7M_FPCCR, UFRDY, 10, 1) | 49 | +++ b/target/arm/mve.decode |
59 | +FIELD(V7M_FPCCR, RES0, 11, 15) | 50 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 |
60 | +FIELD(V7M_FPCCR, TS, 26, 1) | 51 | %size_16 16:1 !function=plus_1 |
61 | +FIELD(V7M_FPCCR, CLRONRETS, 27, 1) | 52 | |
62 | +FIELD(V7M_FPCCR, CLRONRET, 28, 1) | 53 | &vmlaldav rdahi rdalo size qn qm x a |
63 | +FIELD(V7M_FPCCR, LSPENS, 29, 1) | 54 | +&vmladav rda size qn qm x a |
64 | +FIELD(V7M_FPCCR, LSPEN, 30, 1) | 55 | |
65 | +FIELD(V7M_FPCCR, ASPEN, 31, 1) | 56 | @vmlaldav .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ |
66 | +/* These bits are banked. Others are non-banked and live in the M_REG_S bank */ | 57 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav |
67 | +#define R_V7M_FPCCR_BANKED_MASK \ | 58 | @vmlaldav_nosz .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ |
68 | + (R_V7M_FPCCR_LSPACT_MASK | \ | 59 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=0 &vmlaldav |
69 | + R_V7M_FPCCR_USER_MASK | \ | 60 | -VMLALDAV_S 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav |
70 | + R_V7M_FPCCR_THREAD_MASK | \ | 61 | -VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav |
71 | + R_V7M_FPCCR_MMRDY_MASK | \ | 62 | +@vmladav .... .... .... ... . ... x:1 .... . . a:1 . qm:3 . \ |
72 | + R_V7M_FPCCR_SPLIMVIOL_MASK | \ | 63 | + qn=%qn rda=%rdalo size=%size_16 &vmladav |
73 | + R_V7M_FPCCR_UFRDY_MASK | \ | 64 | +@vmladav_nosz .... .... .... ... . ... x:1 .... . . a:1 . qm:3 . \ |
74 | + R_V7M_FPCCR_ASPEN_MASK) | 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, +=, -=) | ||
75 | + | 159 | + |
76 | /* | 160 | /* |
77 | * System register ID fields. | 161 | * Rounding multiply add long dual accumulate high. In the pseudocode |
78 | */ | 162 | * this is implemented with a 72-bit internal accumulator value of which |
79 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 163 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
80 | index XXXXXXX..XXXXXXX 100644 | 164 | index XXXXXXX..XXXXXXX 100644 |
81 | --- a/hw/intc/armv7m_nvic.c | 165 | --- a/target/arm/translate-mve.c |
82 | +++ b/hw/intc/armv7m_nvic.c | 166 | +++ b/target/arm/translate-mve.c |
83 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 167 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TC |
84 | } | 168 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); |
85 | case 0xd84: /* CSSELR */ | 169 | typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); |
86 | return cpu->env.v7m.csselr[attrs.secure]; | 170 | typedef void MVEGenVABAVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); |
87 | + case 0xd88: /* CPACR */ | 171 | +typedef void MVEGenDualAccOpFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); |
88 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | 172 | |
89 | + return 0; | 173 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ |
90 | + } | 174 | static inline long mve_qreg_offset(unsigned reg) |
91 | + return cpu->env.v7m.cpacr[attrs.secure]; | 175 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) |
92 | + case 0xd8c: /* NSACR */ | 176 | return do_long_dual_acc(s, a, fns[a->x]); |
93 | + if (!attrs.secure || !arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | 177 | } |
94 | + return 0; | 178 | |
95 | + } | 179 | +static bool do_dual_acc(DisasContext *s, arg_vmladav *a, MVEGenDualAccOpFn *fn) |
96 | + return cpu->env.v7m.nsacr; | 180 | +{ |
97 | /* TODO: Implement debug registers. */ | 181 | + TCGv_ptr qn, qm; |
98 | case 0xd90: /* MPU_TYPE */ | 182 | + TCGv_i32 rda; |
99 | /* Unified MPU; if the MPU is not present this value is zero */ | 183 | + |
100 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 184 | + if (!dc_isar_feature(aa32_mve, s) || |
101 | return 0; | 185 | + !mve_check_qreg_bank(s, a->qn) || |
102 | } | 186 | + !fn) { |
103 | return cpu->env.v7m.sfar; | 187 | + return false; |
104 | + case 0xf34: /* FPCCR */ | 188 | + } |
105 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | 189 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
106 | + return 0; | 190 | + return true; |
107 | + } | 191 | + } |
108 | + if (attrs.secure) { | 192 | + |
109 | + return cpu->env.v7m.fpccr[M_REG_S]; | 193 | + qn = mve_qreg_ptr(a->qn); |
110 | + } else { | 194 | + qm = mve_qreg_ptr(a->qm); |
111 | + /* | 195 | + |
112 | + * NS can read LSPEN, CLRONRET and MONRDY. It can read | 196 | + /* |
113 | + * BFRDY and HFRDY if AIRCR.BFHFNMINS != 0; | 197 | + * This insn is subject to beat-wise execution. Partial execution |
114 | + * other non-banked bits RAZ. | 198 | + * of an A=0 (no-accumulate) insn which does not execute the first |
115 | + * TODO: MONRDY should RAZ/WI if DEMCR.SDME is set. | 199 | + * beat must start with the current rda value, not 0. |
116 | + */ | 200 | + */ |
117 | + uint32_t value = cpu->env.v7m.fpccr[M_REG_S]; | 201 | + if (a->a || mve_skip_first_beat(s)) { |
118 | + uint32_t mask = R_V7M_FPCCR_LSPEN_MASK | | 202 | + rda = load_reg(s, a->rda); |
119 | + R_V7M_FPCCR_CLRONRET_MASK | | 203 | + } else { |
120 | + R_V7M_FPCCR_MONRDY_MASK; | 204 | + rda = tcg_const_i32(0); |
121 | + | 205 | + } |
122 | + if (s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) { | 206 | + |
123 | + mask |= R_V7M_FPCCR_BFRDY_MASK | R_V7M_FPCCR_HFRDY_MASK; | 207 | + fn(rda, cpu_env, qn, qm, rda); |
124 | + } | 208 | + store_reg(s, a->rda, rda); |
125 | + | 209 | + tcg_temp_free_ptr(qn); |
126 | + value &= mask; | 210 | + tcg_temp_free_ptr(qm); |
127 | + | 211 | + |
128 | + value |= cpu->env.v7m.fpccr[M_REG_NS]; | 212 | + mve_update_eci(s); |
129 | + return value; | 213 | + return true; |
130 | + } | 214 | +} |
131 | + case 0xf38: /* FPCAR */ | 215 | + |
132 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | 216 | +#define DO_DUAL_ACC(INSN, FN) \ |
133 | + return 0; | 217 | + static bool trans_##INSN(DisasContext *s, arg_vmladav *a) \ |
134 | + } | 218 | + { \ |
135 | + return cpu->env.v7m.fpcar[attrs.secure]; | 219 | + static MVEGenDualAccOpFn * const fns[4][2] = { \ |
136 | + case 0xf3c: /* FPDSCR */ | 220 | + { gen_helper_mve_##FN##b, gen_helper_mve_##FN##xb }, \ |
137 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | 221 | + { gen_helper_mve_##FN##h, gen_helper_mve_##FN##xh }, \ |
138 | + return 0; | 222 | + { gen_helper_mve_##FN##w, gen_helper_mve_##FN##xw }, \ |
139 | + } | 223 | + { NULL, NULL }, \ |
140 | + return cpu->env.v7m.fpdscr[attrs.secure]; | 224 | + }; \ |
141 | case 0xf40: /* MVFR0 */ | 225 | + return do_dual_acc(s, a, fns[a->size][a->x]); \ |
142 | return cpu->isar.mvfr0; | 226 | + } |
143 | case 0xf44: /* MVFR1 */ | 227 | + |
144 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | 228 | +DO_DUAL_ACC(VMLADAV_S, vmladavs) |
145 | cpu->env.v7m.csselr[attrs.secure] = value & R_V7M_CSSELR_INDEX_MASK; | 229 | +DO_DUAL_ACC(VMLSDAV, vmlsdav) |
146 | } | 230 | + |
147 | break; | 231 | +static bool trans_VMLADAV_U(DisasContext *s, arg_vmladav *a) |
148 | + case 0xd88: /* CPACR */ | 232 | +{ |
149 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | 233 | + static MVEGenDualAccOpFn * const fns[4][2] = { |
150 | + /* We implement only the Floating Point extension's CP10/CP11 */ | 234 | + { gen_helper_mve_vmladavub, NULL }, |
151 | + cpu->env.v7m.cpacr[attrs.secure] = value & (0xf << 20); | 235 | + { gen_helper_mve_vmladavuh, NULL }, |
152 | + } | 236 | + { gen_helper_mve_vmladavuw, NULL }, |
153 | + break; | 237 | + { NULL, NULL }, |
154 | + case 0xd8c: /* NSACR */ | 238 | + }; |
155 | + if (attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | 239 | + return do_dual_acc(s, a, fns[a->size][a->x]); |
156 | + /* We implement only the Floating Point extension's CP10/CP11 */ | 240 | +} |
157 | + cpu->env.v7m.nsacr = value & (3 << 10); | 241 | + |
158 | + } | 242 | static void gen_vpst(DisasContext *s, uint32_t mask) |
159 | + break; | 243 | { |
160 | case 0xd90: /* MPU_TYPE */ | 244 | /* |
161 | return; /* RO */ | ||
162 | case 0xd94: /* MPU_CTRL */ | ||
163 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
164 | } | ||
165 | break; | ||
166 | } | ||
167 | + case 0xf34: /* FPCCR */ | ||
168 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
169 | + /* Not all bits here are banked. */ | ||
170 | + uint32_t fpccr_s; | ||
171 | + | ||
172 | + if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { | ||
173 | + /* Don't allow setting of bits not present in v7M */ | ||
174 | + value &= (R_V7M_FPCCR_LSPACT_MASK | | ||
175 | + R_V7M_FPCCR_USER_MASK | | ||
176 | + R_V7M_FPCCR_THREAD_MASK | | ||
177 | + R_V7M_FPCCR_HFRDY_MASK | | ||
178 | + R_V7M_FPCCR_MMRDY_MASK | | ||
179 | + R_V7M_FPCCR_BFRDY_MASK | | ||
180 | + R_V7M_FPCCR_MONRDY_MASK | | ||
181 | + R_V7M_FPCCR_LSPEN_MASK | | ||
182 | + R_V7M_FPCCR_ASPEN_MASK); | ||
183 | + } | ||
184 | + value &= ~R_V7M_FPCCR_RES0_MASK; | ||
185 | + | ||
186 | + if (!attrs.secure) { | ||
187 | + /* Some non-banked bits are configurably writable by NS */ | ||
188 | + fpccr_s = cpu->env.v7m.fpccr[M_REG_S]; | ||
189 | + if (!(fpccr_s & R_V7M_FPCCR_LSPENS_MASK)) { | ||
190 | + uint32_t lspen = FIELD_EX32(value, V7M_FPCCR, LSPEN); | ||
191 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, LSPEN, lspen); | ||
192 | + } | ||
193 | + if (!(fpccr_s & R_V7M_FPCCR_CLRONRETS_MASK)) { | ||
194 | + uint32_t cor = FIELD_EX32(value, V7M_FPCCR, CLRONRET); | ||
195 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, CLRONRET, cor); | ||
196 | + } | ||
197 | + if ((s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | ||
198 | + uint32_t hfrdy = FIELD_EX32(value, V7M_FPCCR, HFRDY); | ||
199 | + uint32_t bfrdy = FIELD_EX32(value, V7M_FPCCR, BFRDY); | ||
200 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, HFRDY, hfrdy); | ||
201 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, BFRDY, bfrdy); | ||
202 | + } | ||
203 | + /* TODO MONRDY should RAZ/WI if DEMCR.SDME is set */ | ||
204 | + { | ||
205 | + uint32_t monrdy = FIELD_EX32(value, V7M_FPCCR, MONRDY); | ||
206 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, MONRDY, monrdy); | ||
207 | + } | ||
208 | + | ||
209 | + /* | ||
210 | + * All other non-banked bits are RAZ/WI from NS; write | ||
211 | + * just the banked bits to fpccr[M_REG_NS]. | ||
212 | + */ | ||
213 | + value &= R_V7M_FPCCR_BANKED_MASK; | ||
214 | + cpu->env.v7m.fpccr[M_REG_NS] = value; | ||
215 | + } else { | ||
216 | + fpccr_s = value; | ||
217 | + } | ||
218 | + cpu->env.v7m.fpccr[M_REG_S] = fpccr_s; | ||
219 | + } | ||
220 | + break; | ||
221 | + case 0xf38: /* FPCAR */ | ||
222 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
223 | + value &= ~7; | ||
224 | + cpu->env.v7m.fpcar[attrs.secure] = value; | ||
225 | + } | ||
226 | + break; | ||
227 | + case 0xf3c: /* FPDSCR */ | ||
228 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
229 | + value &= 0x07c00000; | ||
230 | + cpu->env.v7m.fpdscr[attrs.secure] = value; | ||
231 | + } | ||
232 | + break; | ||
233 | case 0xf50: /* ICIALLU */ | ||
234 | case 0xf58: /* ICIMVAU */ | ||
235 | case 0xf5c: /* DCIMVAC */ | ||
236 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
237 | index XXXXXXX..XXXXXXX 100644 | ||
238 | --- a/target/arm/cpu.c | ||
239 | +++ b/target/arm/cpu.c | ||
240 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | ||
241 | env->v7m.ccr[M_REG_S] |= R_V7M_CCR_UNALIGN_TRP_MASK; | ||
242 | } | ||
243 | |||
244 | + if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
245 | + env->v7m.fpccr[M_REG_NS] = R_V7M_FPCCR_ASPEN_MASK; | ||
246 | + env->v7m.fpccr[M_REG_S] = R_V7M_FPCCR_ASPEN_MASK | | ||
247 | + R_V7M_FPCCR_LSPEN_MASK | R_V7M_FPCCR_S_MASK; | ||
248 | + } | ||
249 | /* Unlike A/R profile, M profile defines the reset LR value */ | ||
250 | env->regs[14] = 0xffffffff; | ||
251 | |||
252 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
253 | index XXXXXXX..XXXXXXX 100644 | ||
254 | --- a/target/arm/machine.c | ||
255 | +++ b/target/arm/machine.c | ||
256 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_v8m = { | ||
257 | } | ||
258 | }; | ||
259 | |||
260 | +static const VMStateDescription vmstate_m_fp = { | ||
261 | + .name = "cpu/m/fp", | ||
262 | + .version_id = 1, | ||
263 | + .minimum_version_id = 1, | ||
264 | + .needed = vfp_needed, | ||
265 | + .fields = (VMStateField[]) { | ||
266 | + VMSTATE_UINT32_ARRAY(env.v7m.fpcar, ARMCPU, M_REG_NUM_BANKS), | ||
267 | + VMSTATE_UINT32_ARRAY(env.v7m.fpccr, ARMCPU, M_REG_NUM_BANKS), | ||
268 | + VMSTATE_UINT32_ARRAY(env.v7m.fpdscr, ARMCPU, M_REG_NUM_BANKS), | ||
269 | + VMSTATE_UINT32_ARRAY(env.v7m.cpacr, ARMCPU, M_REG_NUM_BANKS), | ||
270 | + VMSTATE_UINT32(env.v7m.nsacr, ARMCPU), | ||
271 | + VMSTATE_END_OF_LIST() | ||
272 | + } | ||
273 | +}; | ||
274 | + | ||
275 | static const VMStateDescription vmstate_m = { | ||
276 | .name = "cpu/m", | ||
277 | .version_id = 4, | ||
278 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = { | ||
279 | &vmstate_m_scr, | ||
280 | &vmstate_m_other_sp, | ||
281 | &vmstate_m_v8m, | ||
282 | + &vmstate_m_fp, | ||
283 | NULL | ||
284 | } | ||
285 | }; | ||
286 | -- | 245 | -- |
287 | 2.20.1 | 246 | 2.20.1 |
288 | 247 | ||
289 | 248 | diff view generated by jsdifflib |
1 | For M-profile the MVFR* ID registers are memory mapped, in the | 1 | Implement the MVE VMLA insn, which multiplies a vector by a scalar |
---|---|---|---|
2 | range we implement via the NVIC. Allow them to be read. | 2 | and accumulates into another vector. |
3 | (If the CPU has no FPU, these registers are defined to be RAZ.) | ||
4 | 3 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20190416125744.27770-3-peter.maydell@linaro.org | ||
8 | --- | 6 | --- |
9 | hw/intc/armv7m_nvic.c | 6 ++++++ | 7 | target/arm/helper-mve.h | 4 ++++ |
10 | 1 file changed, 6 insertions(+) | 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(+) | ||
11 | 12 | ||
12 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/intc/armv7m_nvic.c | 15 | --- a/target/arm/helper-mve.h |
15 | +++ b/hw/intc/armv7m_nvic.c | 16 | +++ b/target/arm/helper-mve.h |
16 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i3 |
17 | return 0; | 18 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
18 | } | 19 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
19 | return cpu->env.v7m.sfar; | 20 | |
20 | + case 0xf40: /* MVFR0 */ | 21 | +DEF_HELPER_FLAGS_4(mve_vmlab, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | + return cpu->isar.mvfr0; | 22 | +DEF_HELPER_FLAGS_4(mve_vmlah, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
22 | + case 0xf44: /* MVFR1 */ | 23 | +DEF_HELPER_FLAGS_4(mve_vmlaw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | + return cpu->isar.mvfr1; | 24 | + |
24 | + case 0xf48: /* MVFR2 */ | 25 | DEF_HELPER_FLAGS_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | + return cpu->isar.mvfr2; | 26 | DEF_HELPER_FLAGS_4(mve_vmlash, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
26 | default: | 27 | DEF_HELPER_FLAGS_4(mve_vmlasw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
27 | bad_offset: | 28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
28 | qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset); | 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) | ||
29 | -- | 68 | -- |
30 | 2.20.1 | 69 | 2.20.1 |
31 | 70 | ||
32 | 71 | diff view generated by jsdifflib |
1 | Enforce that for M-profile various FPSCR bits which are RES0 there | 1 | Implement the MVE saturating doubling multiply accumulate insns |
---|---|---|---|
2 | but have defined meanings on A-profile are never settable. This | 2 | VQDMLAH, VQRDMLAH, VQDMLASH and VQRDMLASH. These perform a multiply, |
3 | ensures that M-profile code can't enable the A-profile behaviour | 3 | double, add the accumulator shifted by the element size, possibly |
4 | (notably vector length/stride handling) by accident. | 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. | ||
5 | 7 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20190416125744.27770-2-peter.maydell@linaro.org | ||
9 | --- | 10 | --- |
10 | target/arm/vfp_helper.c | 8 ++++++++ | 11 | target/arm/helper-mve.h | 16 +++++++ |
11 | 1 file changed, 8 insertions(+) | 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(+) | ||
12 | 16 | ||
13 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/vfp_helper.c | 19 | --- a/target/arm/helper-mve.h |
16 | +++ b/target/arm/vfp_helper.c | 20 | +++ b/target/arm/helper-mve.h |
17 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | 21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
18 | val &= ~FPCR_FZ16; | 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); \ | ||
19 | } | 66 | } |
20 | 67 | ||
21 | + if (arm_feature(env, ARM_FEATURE_M)) { | 68 | +#define DO_2OP_SAT_ACC_SCALAR(OP, ESIZE, TYPE, FN) \ |
22 | + /* | 69 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ |
23 | + * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits | 70 | + uint32_t rm) \ |
24 | + * and also for the trapped-exception-handling bits IxE. | 71 | + { \ |
25 | + */ | 72 | + TYPE *d = vd, *n = vn; \ |
26 | + val &= 0xf7c0009f; | 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); \ | ||
27 | + } | 88 | + } |
28 | + | 89 | + |
29 | /* | 90 | /* provide unsigned 2-op scalar helpers for all sizes */ |
30 | * We don't implement trapped exception handling, so the | 91 | #define DO_2OP_SCALAR_U(OP, FN) \ |
31 | * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) | 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 | { | ||
32 | -- | 188 | -- |
33 | 2.20.1 | 189 | 2.20.1 |
34 | 190 | ||
35 | 191 | diff view generated by jsdifflib |
1 | The TailChain() pseudocode specifies that a tail chaining | 1 | Implement the MVE 1-operand saturating operations VQABS and VQNEG. |
---|---|---|---|
2 | exception should sanitize the excReturn all-ones bits and | ||
3 | (if there is no FPU) the excReturn FType bits; we weren't | ||
4 | doing this. | ||
5 | 2 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20190416125744.27770-14-peter.maydell@linaro.org | ||
9 | --- | 5 | --- |
10 | target/arm/helper.c | 8 ++++++++ | 6 | target/arm/helper-mve.h | 8 ++++++++ |
11 | 1 file changed, 8 insertions(+) | 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(+) | ||
12 | 11 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 12 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 14 | --- a/target/arm/helper-mve.h |
16 | +++ b/target/arm/helper.c | 15 | +++ b/target/arm/helper-mve.h |
17 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) |
18 | qemu_log_mask(CPU_LOG_INT, "...taking pending %s exception %d\n", | 17 | DEF_HELPER_FLAGS_3(mve_vfnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
19 | targets_secure ? "secure" : "nonsecure", exc); | 18 | DEF_HELPER_FLAGS_3(mve_vfnegs, TCG_CALL_NO_WG, void, env, ptr, ptr) |
20 | 19 | ||
21 | + if (dotailchain) { | 20 | +DEF_HELPER_FLAGS_3(mve_vqabsb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
22 | + /* Sanitize LR FType and PREFIX bits */ | 21 | +DEF_HELPER_FLAGS_3(mve_vqabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
23 | + if (!arm_feature(env, ARM_FEATURE_VFP)) { | 22 | +DEF_HELPER_FLAGS_3(mve_vqabsw, TCG_CALL_NO_WG, void, env, ptr, ptr) |
24 | + lr |= R_V7M_EXCRET_FTYPE_MASK; | 23 | + |
25 | + } | 24 | +DEF_HELPER_FLAGS_3(mve_vqnegb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
26 | + lr = deposit32(lr, 24, 8, 0xff); | 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); \ | ||
27 | + } | 70 | + } |
28 | + | 71 | + |
29 | if (arm_feature(env, ARM_FEATURE_V8)) { | 72 | +#define DO_VQABS_B(N, SATP) \ |
30 | if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | 73 | + do_sat_bhs(DO_ABS((int64_t)N), INT8_MIN, INT8_MAX, SATP) |
31 | (lr & R_V7M_EXCRET_S_MASK)) { | 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) \ | ||
32 | -- | 103 | -- |
33 | 2.20.1 | 104 | 2.20.1 |
34 | 105 | ||
35 | 106 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | Implement the MVE VMAXA and VMINA insns, which take the absolute |
---|---|---|---|
2 | value of the signed elements in the input vector and then accumulate | ||
3 | the unsigned max or min into the destination vector. | ||
2 | 4 | ||
3 | The SMMUNotifierNode struct is not necessary and brings extra | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | complexity so let's remove it. We now directly track the SMMUDevices | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | which have registered IOMMU MR notifiers. | 7 | --- |
8 | target/arm/helper-mve.h | 8 ++++++++ | ||
9 | target/arm/mve.decode | 4 ++++ | ||
10 | target/arm/mve_helper.c | 26 ++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 2 ++ | ||
12 | 4 files changed, 40 insertions(+) | ||
6 | 13 | ||
7 | This is inspired from the same transformation on intel-iommu | 14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
8 | done in commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef | ||
9 | ("intel-iommu: remove IntelIOMMUNotifierNode") | ||
10 | |||
11 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
12 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
13 | Message-id: 20190409160219.19026-1-eric.auger@redhat.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | include/hw/arm/smmu-common.h | 8 ++------ | ||
17 | hw/arm/smmu-common.c | 6 +++--- | ||
18 | hw/arm/smmuv3.c | 28 +++++++--------------------- | ||
19 | 3 files changed, 12 insertions(+), 30 deletions(-) | ||
20 | |||
21 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/hw/arm/smmu-common.h | 16 | --- a/target/arm/helper-mve.h |
24 | +++ b/include/hw/arm/smmu-common.h | 17 | +++ b/target/arm/helper-mve.h |
25 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUDevice { | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vqnegb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
26 | AddressSpace as; | 19 | DEF_HELPER_FLAGS_3(mve_vqnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
27 | uint32_t cfg_cache_hits; | 20 | DEF_HELPER_FLAGS_3(mve_vqnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) |
28 | uint32_t cfg_cache_misses; | 21 | |
29 | + QLIST_ENTRY(SMMUDevice) next; | 22 | +DEF_HELPER_FLAGS_3(mve_vmaxab, TCG_CALL_NO_WG, void, env, ptr, ptr) |
30 | } SMMUDevice; | 23 | +DEF_HELPER_FLAGS_3(mve_vmaxah, TCG_CALL_NO_WG, void, env, ptr, ptr) |
31 | 24 | +DEF_HELPER_FLAGS_3(mve_vmaxaw, TCG_CALL_NO_WG, void, env, ptr, ptr) | |
32 | -typedef struct SMMUNotifierNode { | 25 | + |
33 | - SMMUDevice *sdev; | 26 | +DEF_HELPER_FLAGS_3(mve_vminab, TCG_CALL_NO_WG, void, env, ptr, ptr) |
34 | - QLIST_ENTRY(SMMUNotifierNode) next; | 27 | +DEF_HELPER_FLAGS_3(mve_vminah, TCG_CALL_NO_WG, void, env, ptr, ptr) |
35 | -} SMMUNotifierNode; | 28 | +DEF_HELPER_FLAGS_3(mve_vminaw, TCG_CALL_NO_WG, void, env, ptr, ptr) |
36 | - | 29 | + |
37 | typedef struct SMMUPciBus { | 30 | DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
38 | PCIBus *bus; | 31 | DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) |
39 | SMMUDevice *pbdev[0]; /* Parent array is sparse, so dynamically alloc */ | 32 | DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) |
40 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUState { | 33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
41 | GHashTable *iotlb; | ||
42 | SMMUPciBus *smmu_pcibus_by_bus_num[SMMU_PCI_BUS_MAX]; | ||
43 | PCIBus *pci_bus; | ||
44 | - QLIST_HEAD(, SMMUNotifierNode) notifiers_list; | ||
45 | + QLIST_HEAD(, SMMUDevice) devices_with_notifiers; | ||
46 | uint8_t bus_num; | ||
47 | PCIBus *primary_bus; | ||
48 | } SMMUState; | ||
49 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/hw/arm/smmu-common.c | 35 | --- a/target/arm/mve.decode |
52 | +++ b/hw/arm/smmu-common.c | 36 | +++ b/target/arm/mve.decode |
53 | @@ -XXX,XX +XXX,XX @@ inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr) | 37 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op |
54 | /* Unmap all notifiers of all mr's */ | 38 | VQMOVUNB 111 0 1110 0 . 11 .. 01 ... 0 1110 1 0 . 0 ... 1 @1op |
55 | void smmu_inv_notifiers_all(SMMUState *s) | 39 | VQMOVN_BS 111 0 1110 0 . 11 .. 11 ... 0 1110 0 0 . 0 ... 1 @1op |
56 | { | 40 | |
57 | - SMMUNotifierNode *node; | 41 | + VMAXA 111 0 1110 0 . 11 .. 11 ... 0 1110 1 0 . 0 ... 1 @1op |
58 | + SMMUDevice *sdev; | 42 | + |
59 | 43 | VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | |
60 | - QLIST_FOREACH(node, &s->notifiers_list, next) { | ||
61 | - smmu_inv_notifiers_mr(&node->sdev->iommu); | ||
62 | + QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) { | ||
63 | + smmu_inv_notifiers_mr(&sdev->iommu); | ||
64 | } | ||
65 | } | 44 | } |
66 | 45 | ||
67 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | 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 | ||
68 | index XXXXXXX..XXXXXXX 100644 | 56 | index XXXXXXX..XXXXXXX 100644 |
69 | --- a/hw/arm/smmuv3.c | 57 | --- a/target/arm/mve_helper.c |
70 | +++ b/hw/arm/smmuv3.c | 58 | +++ b/target/arm/mve_helper.c |
71 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, | 59 | @@ -XXX,XX +XXX,XX @@ DO_1OP_SAT(vqabsw, 4, int32_t, DO_VQABS_W) |
72 | /* invalidate an asid/iova tuple in all mr's */ | 60 | DO_1OP_SAT(vqnegb, 1, int8_t, DO_VQNEG_B) |
73 | static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova) | 61 | DO_1OP_SAT(vqnegh, 2, int16_t, DO_VQNEG_H) |
74 | { | 62 | DO_1OP_SAT(vqnegw, 4, int32_t, DO_VQNEG_W) |
75 | - SMMUNotifierNode *node; | 63 | + |
76 | + SMMUDevice *sdev; | 64 | +/* |
77 | 65 | + * VMAXA, VMINA: vd is unsigned; vm is signed, and we take its | |
78 | - QLIST_FOREACH(node, &s->notifiers_list, next) { | 66 | + * absolute value; we then do an unsigned comparison. |
79 | - IOMMUMemoryRegion *mr = &node->sdev->iommu; | 67 | + */ |
80 | + QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) { | 68 | +#define DO_VMAXMINA(OP, ESIZE, STYPE, UTYPE, FN) \ |
81 | + IOMMUMemoryRegion *mr = &sdev->iommu; | 69 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ |
82 | IOMMUNotifier *n; | 70 | + { \ |
83 | 71 | + UTYPE *d = vd; \ | |
84 | trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova); | 72 | + STYPE *m = vm; \ |
85 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, | 73 | + uint16_t mask = mve_element_mask(env); \ |
86 | SMMUDevice *sdev = container_of(iommu, SMMUDevice, iommu); | 74 | + unsigned e; \ |
87 | SMMUv3State *s3 = sdev->smmu; | 75 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ |
88 | SMMUState *s = &(s3->smmu_state); | 76 | + UTYPE r = DO_ABS(m[H##ESIZE(e)]); \ |
89 | - SMMUNotifierNode *node = NULL; | 77 | + r = FN(d[H##ESIZE(e)], r); \ |
90 | - SMMUNotifierNode *next_node = NULL; | 78 | + mergemask(&d[H##ESIZE(e)], r, mask); \ |
91 | 79 | + } \ | |
92 | if (new & IOMMU_NOTIFIER_MAP) { | 80 | + mve_advance_vpt(env); \ |
93 | int bus_num = pci_bus_num(sdev->bus); | 81 | + } |
94 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, | 82 | + |
95 | 83 | +DO_VMAXMINA(vmaxab, 1, int8_t, uint8_t, DO_MAX) | |
96 | if (old == IOMMU_NOTIFIER_NONE) { | 84 | +DO_VMAXMINA(vmaxah, 2, int16_t, uint16_t, DO_MAX) |
97 | trace_smmuv3_notify_flag_add(iommu->parent_obj.name); | 85 | +DO_VMAXMINA(vmaxaw, 4, int32_t, uint32_t, DO_MAX) |
98 | - node = g_malloc0(sizeof(*node)); | 86 | +DO_VMAXMINA(vminab, 1, int8_t, uint8_t, DO_MIN) |
99 | - node->sdev = sdev; | 87 | +DO_VMAXMINA(vminah, 2, int16_t, uint16_t, DO_MIN) |
100 | - QLIST_INSERT_HEAD(&s->notifiers_list, node, next); | 88 | +DO_VMAXMINA(vminaw, 4, int32_t, uint32_t, DO_MIN) |
101 | - return; | 89 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
102 | - } | 90 | index XXXXXXX..XXXXXXX 100644 |
103 | - | 91 | --- a/target/arm/translate-mve.c |
104 | - /* update notifier node with new flags */ | 92 | +++ b/target/arm/translate-mve.c |
105 | - QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) { | 93 | @@ -XXX,XX +XXX,XX @@ DO_1OP(VABS, vabs) |
106 | - if (node->sdev == sdev) { | 94 | DO_1OP(VNEG, vneg) |
107 | - if (new == IOMMU_NOTIFIER_NONE) { | 95 | DO_1OP(VQABS, vqabs) |
108 | - trace_smmuv3_notify_flag_del(iommu->parent_obj.name); | 96 | DO_1OP(VQNEG, vqneg) |
109 | - QLIST_REMOVE(node, next); | 97 | +DO_1OP(VMAXA, vmaxa) |
110 | - g_free(node); | 98 | +DO_1OP(VMINA, vmina) |
111 | - } | 99 | |
112 | - return; | 100 | /* Narrowing moves: only size 0 and 1 are valid */ |
113 | - } | 101 | #define DO_VMOVN(INSN, FN) \ |
114 | + QLIST_INSERT_HEAD(&s->devices_with_notifiers, sdev, next); | ||
115 | + } else if (new == IOMMU_NOTIFIER_NONE) { | ||
116 | + trace_smmuv3_notify_flag_del(iommu->parent_obj.name); | ||
117 | + QLIST_REMOVE(sdev, next); | ||
118 | } | ||
119 | } | ||
120 | |||
121 | -- | 102 | -- |
122 | 2.20.1 | 103 | 2.20.1 |
123 | 104 | ||
124 | 105 | diff view generated by jsdifflib |
1 | Implement the code which updates the FPCCR register on an | 1 | Implement the MVE VMOV forms that move data between 2 general-purpose |
---|---|---|---|
2 | exception entry where we are going to use lazy FP stacking. | 2 | registers and 2 32-bit lanes in a vector register. |
3 | We have to defer to the NVIC to determine whether the | ||
4 | various exceptions are currently ready or not. | ||
5 | 3 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20190416125744.27770-12-peter.maydell@linaro.org | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | --- | 6 | --- |
9 | target/arm/cpu.h | 14 +++++++++ | 7 | target/arm/translate-a32.h | 1 + |
10 | hw/intc/armv7m_nvic.c | 34 ++++++++++++++++++++++ | 8 | target/arm/mve.decode | 4 ++ |
11 | target/arm/helper.c | 67 ++++++++++++++++++++++++++++++++++++++++++- | 9 | target/arm/translate-mve.c | 85 ++++++++++++++++++++++++++++++++++++++ |
12 | 3 files changed, 114 insertions(+), 1 deletion(-) | 10 | target/arm/translate-vfp.c | 2 +- |
11 | 4 files changed, 91 insertions(+), 1 deletion(-) | ||
13 | 12 | ||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 13 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.h | 15 | --- a/target/arm/translate-a32.h |
17 | +++ b/target/arm/cpu.h | 16 | +++ b/target/arm/translate-a32.h |
18 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque); | 17 | @@ -XXX,XX +XXX,XX @@ void gen_rev16(TCGv_i32 dest, TCGv_i32 var); |
19 | * (Ignoring -1, this is the same as the RETTOBASE value before completion.) | 18 | void clear_eci_state(DisasContext *s); |
20 | */ | 19 | bool mve_eci_check(DisasContext *s); |
21 | int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure); | 20 | void mve_update_and_store_eci(DisasContext *s); |
22 | +/** | 21 | +bool mve_skip_vmov(DisasContext *s, int vn, int index, int size); |
23 | + * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | 22 | |
24 | + * @opaque: the NVIC | 23 | static inline TCGv_i32 load_cpu_offset(int offset) |
25 | + * @irq: the exception number to mark pending | 24 | { |
26 | + * @secure: false for non-banked exceptions or for the nonsecure | 25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
27 | + * version of a banked exception, true for the secure version of a banked | ||
28 | + * exception. | ||
29 | + * | ||
30 | + * Return whether an exception is "ready", i.e. whether the exception is | ||
31 | + * enabled and is configured at a priority which would allow it to | ||
32 | + * interrupt the current execution priority. This controls whether the | ||
33 | + * RDY bit for it in the FPCCR is set. | ||
34 | + */ | ||
35 | +bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure); | ||
36 | /** | ||
37 | * armv7m_nvic_raw_execution_priority: return the raw execution priority | ||
38 | * @opaque: the NVIC | ||
39 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/hw/intc/armv7m_nvic.c | 27 | --- a/target/arm/mve.decode |
42 | +++ b/hw/intc/armv7m_nvic.c | 28 | +++ b/target/arm/mve.decode |
43 | @@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure) | 29 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ |
44 | return ret; | 30 | VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ |
45 | } | 31 | size=2 p=1 |
46 | 32 | ||
47 | +bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | 33 | +# Moves between 2 32-bit vector lanes and 2 general purpose registers |
34 | +VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
35 | +VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
36 | + | ||
37 | # Vector 2-op | ||
38 | VAND 1110 1111 0 . 00 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | ||
39 | VBIC 1110 1111 0 . 01 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | ||
40 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/translate-mve.c | ||
43 | +++ b/target/arm/translate-mve.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool do_vabav(DisasContext *s, arg_vabav *a, MVEGenVABAVFn *fn) | ||
45 | |||
46 | DO_VABAV(VABAV_S, vabavs) | ||
47 | DO_VABAV(VABAV_U, vabavu) | ||
48 | + | ||
49 | +static bool trans_VMOV_to_2gp(DisasContext *s, arg_VMOV_to_2gp *a) | ||
48 | +{ | 50 | +{ |
49 | + /* | 51 | + /* |
50 | + * Return whether an exception is "ready", i.e. it is enabled and is | 52 | + * VMOV two 32-bit vector lanes to two general-purpose registers. |
51 | + * configured at a priority which would allow it to interrupt the | 53 | + * This insn is not predicated but it is subject to beat-wise |
52 | + * current execution priority. | 54 | + * execution if it is not in an IT block. For us this means |
53 | + * | 55 | + * only that if PSR.ECI says we should not be executing the beat |
54 | + * irq and secure have the same semantics as for armv7m_nvic_set_pending(): | 56 | + * corresponding to the lane of the vector register being accessed |
55 | + * for non-banked exceptions secure is always false; for banked exceptions | 57 | + * then we should skip perfoming the move, and that we need to do |
56 | + * it indicates which of the exceptions is required. | 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.) | ||
57 | + */ | 60 | + */ |
58 | + NVICState *s = (NVICState *)opaque; | 61 | + TCGv_i32 tmp; |
59 | + bool banked = exc_is_banked(irq); | 62 | + int vd; |
60 | + VecInfo *vec; | ||
61 | + int running = nvic_exec_prio(s); | ||
62 | + | 63 | + |
63 | + assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq); | 64 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd) || |
64 | + assert(!secure || banked); | 65 | + a->rt == 13 || a->rt == 15 || a->rt2 == 13 || a->rt2 == 15 || |
65 | + | 66 | + a->rt == a->rt2) { |
66 | + /* | 67 | + /* Rt/Rt2 cases are UNPREDICTABLE */ |
67 | + * HardFault is an odd special case: we always check against -1, | 68 | + return false; |
68 | + * even if we're secure and HardFault has priority -3; we never | 69 | + } |
69 | + * need to check for enabled state. | 70 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
70 | + */ | 71 | + return true; |
71 | + if (irq == ARMV7M_EXCP_HARD) { | ||
72 | + return running > -1; | ||
73 | + } | 72 | + } |
74 | + | 73 | + |
75 | + vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq]; | 74 | + /* Convert Qreg index to Dreg for read_neon_element32() etc */ |
75 | + vd = a->qd * 2; | ||
76 | + | 76 | + |
77 | + return vec->enabled && | 77 | + if (!mve_skip_vmov(s, vd, a->idx, MO_32)) { |
78 | + exc_group_prio(s, vec->prio, secure) < running; | 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; | ||
79 | +} | 90 | +} |
80 | + | 91 | + |
81 | /* callback when external interrupt line is changed */ | 92 | +static bool trans_VMOV_from_2gp(DisasContext *s, arg_VMOV_to_2gp *a) |
82 | static void set_irq_level(void *opaque, int n, int level) | ||
83 | { | ||
84 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/target/arm/helper.c | ||
87 | +++ b/target/arm/helper.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
89 | env->thumb = addr & 1; | ||
90 | } | ||
91 | |||
92 | +static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, | ||
93 | + bool apply_splim) | ||
94 | +{ | 93 | +{ |
95 | + /* | 94 | + /* |
96 | + * Like the pseudocode UpdateFPCCR: save state in FPCAR and FPCCR | 95 | + * VMOV two general-purpose registers to two 32-bit vector lanes. |
97 | + * that we will need later in order to do lazy FP reg stacking. | 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.) | ||
98 | + */ | 103 | + */ |
99 | + bool is_secure = env->v7m.secure; | 104 | + TCGv_i32 tmp; |
100 | + void *nvic = env->nvic; | 105 | + int vd; |
101 | + /* | ||
102 | + * Some bits are unbanked and live always in fpccr[M_REG_S]; some bits | ||
103 | + * are banked and we want to update the bit in the bank for the | ||
104 | + * current security state; and in one case we want to specifically | ||
105 | + * update the NS banked version of a bit even if we are secure. | ||
106 | + */ | ||
107 | + uint32_t *fpccr_s = &env->v7m.fpccr[M_REG_S]; | ||
108 | + uint32_t *fpccr_ns = &env->v7m.fpccr[M_REG_NS]; | ||
109 | + uint32_t *fpccr = &env->v7m.fpccr[is_secure]; | ||
110 | + bool hfrdy, bfrdy, mmrdy, ns_ufrdy, s_ufrdy, sfrdy, monrdy; | ||
111 | + | 106 | + |
112 | + env->v7m.fpcar[is_secure] = frameptr & ~0x7; | 107 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd) || |
113 | + | 108 | + a->rt == 13 || a->rt == 15 || a->rt2 == 13 || a->rt2 == 15) { |
114 | + if (apply_splim && arm_feature(env, ARM_FEATURE_V8)) { | 109 | + /* Rt/Rt2 cases are UNPREDICTABLE */ |
115 | + bool splimviol; | 110 | + return false; |
116 | + uint32_t splim = v7m_sp_limit(env); | 111 | + } |
117 | + bool ign = armv7m_nvic_neg_prio_requested(nvic, is_secure) && | 112 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
118 | + (env->v7m.ccr[is_secure] & R_V7M_CCR_STKOFHFNMIGN_MASK); | 113 | + return true; |
119 | + | ||
120 | + splimviol = !ign && frameptr < splim; | ||
121 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, SPLIMVIOL, splimviol); | ||
122 | + } | 114 | + } |
123 | + | 115 | + |
124 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, LSPACT, 1); | 116 | + /* Convert Qreg idx to Dreg for read_neon_element32() etc */ |
117 | + vd = a->qd * 2; | ||
125 | + | 118 | + |
126 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, S, is_secure); | 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 | + } | ||
127 | + | 129 | + |
128 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, USER, arm_current_el(env) == 0); | 130 | + mve_update_and_store_eci(s); |
129 | + | 131 | + return true; |
130 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, THREAD, | ||
131 | + !arm_v7m_is_handler_mode(env)); | ||
132 | + | ||
133 | + hfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_HARD, false); | ||
134 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, HFRDY, hfrdy); | ||
135 | + | ||
136 | + bfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_BUS, false); | ||
137 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, BFRDY, bfrdy); | ||
138 | + | ||
139 | + mmrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_MEM, is_secure); | ||
140 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, MMRDY, mmrdy); | ||
141 | + | ||
142 | + ns_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, false); | ||
143 | + *fpccr_ns = FIELD_DP32(*fpccr_ns, V7M_FPCCR, UFRDY, ns_ufrdy); | ||
144 | + | ||
145 | + monrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_DEBUG, false); | ||
146 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, MONRDY, monrdy); | ||
147 | + | ||
148 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
149 | + s_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, true); | ||
150 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, UFRDY, s_ufrdy); | ||
151 | + | ||
152 | + sfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_SECURE, false); | ||
153 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, SFRDY, sfrdy); | ||
154 | + } | ||
155 | +} | 132 | +} |
156 | + | 133 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c |
157 | static bool v7m_push_stack(ARMCPU *cpu) | 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) | ||
158 | { | 143 | { |
159 | /* Do the "set up stack frame" part of exception entry, | 144 | /* |
160 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 145 | * In a CPU with MVE, the VMOV (vector lane to general-purpose register) |
161 | } | ||
162 | } else { | ||
163 | /* Lazy stacking enabled, save necessary info to stack later */ | ||
164 | - /* TODO : equivalent of UpdateFPCCR() pseudocode */ | ||
165 | + v7m_update_fpccr(env, frameptr + 0x20, true); | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | -- | 146 | -- |
170 | 2.20.1 | 147 | 2.20.1 |
171 | 148 | ||
172 | 149 | diff view generated by jsdifflib |
1 | The M-profile architecture floating point system supports | 1 | Implement the MVE VPNOT insn, which inverts the bits in VPR.P0 |
---|---|---|---|
2 | lazy FP state preservation, where FP registers are not | 2 | (subject to both predication and to beatwise execution). |
3 | pushed to the stack when an exception occurs but are instead | ||
4 | only saved if and when the first FP instruction in the exception | ||
5 | handler is executed. Implement this in QEMU, corresponding | ||
6 | to the check of LSPACT in the pseudocode ExecuteFPCheck(). | ||
7 | 3 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20190416125744.27770-24-peter.maydell@linaro.org | ||
11 | --- | 6 | --- |
12 | target/arm/cpu.h | 3 ++ | 7 | target/arm/helper-mve.h | 1 + |
13 | target/arm/helper.h | 2 + | 8 | target/arm/mve.decode | 1 + |
14 | target/arm/translate.h | 1 + | 9 | target/arm/mve_helper.c | 17 +++++++++++++++++ |
15 | target/arm/helper.c | 112 +++++++++++++++++++++++++++++++++++++++++ | 10 | target/arm/translate-mve.c | 19 +++++++++++++++++++ |
16 | target/arm/translate.c | 22 ++++++++ | 11 | 4 files changed, 38 insertions(+) |
17 | 5 files changed, 140 insertions(+) | ||
18 | 12 | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
20 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 15 | --- a/target/arm/helper-mve.h |
22 | +++ b/target/arm/cpu.h | 16 | +++ b/target/arm/helper-mve.h |
23 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
24 | #define EXCP_NOCP 17 /* v7M NOCP UsageFault */ | 18 | DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
25 | #define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */ | 19 | |
26 | #define EXCP_STKOF 19 /* v8M STKOF UsageFault */ | 20 | DEF_HELPER_FLAGS_4(mve_vpsel, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
27 | +#define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */ | 21 | +DEF_HELPER_FLAGS_1(mve_vpnot, TCG_CALL_NO_WG, void, env) |
28 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | 22 | |
29 | 23 | DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | |
30 | #define ARMV7M_EXCP_RESET 1 | 24 | DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) |
31 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
32 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | ||
33 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | ||
34 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | ||
35 | +/* For M profile only, set if FPCCR.LSPACT is set */ | ||
36 | +FIELD(TBFLAG_A32, LSPACT, 18, 1) | ||
37 | /* For M profile only, set if we must create a new FP context */ | ||
38 | FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) | ||
39 | /* For M profile only, set if FPCCR.S does not match current security state */ | ||
40 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/target/arm/helper.h | 27 | --- a/target/arm/mve.decode |
43 | +++ b/target/arm/helper.h | 28 | +++ b/target/arm/mve.decode |
44 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(v7m_blxns, void, env, i32) | 29 | @@ -XXX,XX +XXX,XX @@ VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp |
45 | 30 | VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | |
46 | DEF_HELPER_3(v7m_tt, i32, env, i32, i32) | 31 | |
47 | 32 | { | |
48 | +DEF_HELPER_1(v7m_preserve_fp_state, void, env) | 33 | + VPNOT 1111 1110 0 0 11 000 1 000 0 1111 0100 1101 |
49 | + | 34 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 |
50 | DEF_HELPER_2(v8m_stackcheck, void, env, i32) | 35 | VCMPEQ_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 0 0 .... @vcmp_scalar |
51 | 36 | } | |
52 | DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32) | 37 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
53 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
54 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/target/arm/translate.h | 39 | --- a/target/arm/mve_helper.c |
56 | +++ b/target/arm/translate.h | 40 | +++ b/target/arm/mve_helper.c |
57 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 41 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vpsel)(CPUARMState *env, void *vd, void *vn, void *vm) |
58 | bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */ | 42 | mve_advance_vpt(env); |
59 | bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */ | ||
60 | bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */ | ||
61 | + bool v7m_lspact; /* FPCCR.LSPACT set */ | ||
62 | /* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI | ||
63 | * so that top level loop can generate correct syndrome information. | ||
64 | */ | ||
65 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/arm/helper.c | ||
68 | +++ b/target/arm/helper.c | ||
69 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
70 | g_assert_not_reached(); | ||
71 | } | 43 | } |
72 | 44 | ||
73 | +void HELPER(v7m_preserve_fp_state)(CPUARMState *env) | 45 | +void HELPER(mve_vpnot)(CPUARMState *env) |
74 | +{ | 46 | +{ |
75 | + /* translate.c should never generate calls here in user-only mode */ | 47 | + /* |
76 | + g_assert_not_reached(); | 48 | + * P0 bits for unexecuted beats (where eci_mask is 0) are unchanged. |
49 | + * P0 bits for predicated lanes in executed bits (where mask is 0) are 0. | ||
50 | + * P0 bits otherwise are inverted. | ||
51 | + * (This is the same logic as VCMP.) | ||
52 | + * This insn is itself subject to predication and to beat-wise execution, | ||
53 | + * and after it executes VPT state advances in the usual way. | ||
54 | + */ | ||
55 | + uint16_t mask = mve_element_mask(env); | ||
56 | + uint16_t eci_mask = mve_eci_mask(env); | ||
57 | + uint16_t beatpred = ~env->v7m.vpr & mask; | ||
58 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | (beatpred & eci_mask); | ||
59 | + mve_advance_vpt(env); | ||
77 | +} | 60 | +} |
78 | + | 61 | + |
79 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 62 | #define DO_1OP_SAT(OP, ESIZE, TYPE, FN) \ |
80 | { | 63 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ |
81 | /* The TT instructions can be used by unprivileged code, but in | 64 | { \ |
82 | @@ -XXX,XX +XXX,XX @@ pend_fault: | 65 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
83 | return false; | 66 | index XXXXXXX..XXXXXXX 100644 |
67 | --- a/target/arm/translate-mve.c | ||
68 | +++ b/target/arm/translate-mve.c | ||
69 | @@ -XXX,XX +XXX,XX @@ static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
70 | return true; | ||
84 | } | 71 | } |
85 | 72 | ||
86 | +void HELPER(v7m_preserve_fp_state)(CPUARMState *env) | 73 | +static bool trans_VPNOT(DisasContext *s, arg_VPNOT *a) |
87 | +{ | 74 | +{ |
88 | + /* | 75 | + /* |
89 | + * Preserve FP state (because LSPACT was set and we are about | 76 | + * Invert the predicate in VPR.P0. We have call out to |
90 | + * to execute an FP instruction). This corresponds to the | 77 | + * a helper because this insn itself is beatwise and can |
91 | + * PreserveFPState() pseudocode. | 78 | + * be predicated. |
92 | + * We may throw an exception if the stacking fails. | ||
93 | + */ | 79 | + */ |
94 | + ARMCPU *cpu = arm_env_get_cpu(env); | 80 | + if (!dc_isar_feature(aa32_mve, s)) { |
95 | + bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | 81 | + return false; |
96 | + bool negpri = !(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_HFRDY_MASK); | 82 | + } |
97 | + bool is_priv = !(env->v7m.fpccr[is_secure] & R_V7M_FPCCR_USER_MASK); | 83 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
98 | + bool splimviol = env->v7m.fpccr[is_secure] & R_V7M_FPCCR_SPLIMVIOL_MASK; | 84 | + return true; |
99 | + uint32_t fpcar = env->v7m.fpcar[is_secure]; | ||
100 | + bool stacked_ok = true; | ||
101 | + bool ts = is_secure && (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK); | ||
102 | + bool take_exception; | ||
103 | + | ||
104 | + /* Take the iothread lock as we are going to touch the NVIC */ | ||
105 | + qemu_mutex_lock_iothread(); | ||
106 | + | ||
107 | + /* Check the background context had access to the FPU */ | ||
108 | + if (!v7m_cpacr_pass(env, is_secure, is_priv)) { | ||
109 | + armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, is_secure); | ||
110 | + env->v7m.cfsr[is_secure] |= R_V7M_CFSR_NOCP_MASK; | ||
111 | + stacked_ok = false; | ||
112 | + } else if (!is_secure && !extract32(env->v7m.nsacr, 10, 1)) { | ||
113 | + armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S); | ||
114 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK; | ||
115 | + stacked_ok = false; | ||
116 | + } | 85 | + } |
117 | + | 86 | + |
118 | + if (!splimviol && stacked_ok) { | 87 | + gen_helper_mve_vpnot(cpu_env); |
119 | + /* We only stack if the stack limit wasn't violated */ | 88 | + mve_update_eci(s); |
120 | + int i; | 89 | + return true; |
121 | + ARMMMUIdx mmu_idx; | ||
122 | + | ||
123 | + mmu_idx = arm_v7m_mmu_idx_all(env, is_secure, is_priv, negpri); | ||
124 | + for (i = 0; i < (ts ? 32 : 16); i += 2) { | ||
125 | + uint64_t dn = *aa32_vfp_dreg(env, i / 2); | ||
126 | + uint32_t faddr = fpcar + 4 * i; | ||
127 | + uint32_t slo = extract64(dn, 0, 32); | ||
128 | + uint32_t shi = extract64(dn, 32, 32); | ||
129 | + | ||
130 | + if (i >= 16) { | ||
131 | + faddr += 8; /* skip the slot for the FPSCR */ | ||
132 | + } | ||
133 | + stacked_ok = stacked_ok && | ||
134 | + v7m_stack_write(cpu, faddr, slo, mmu_idx, STACK_LAZYFP) && | ||
135 | + v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, STACK_LAZYFP); | ||
136 | + } | ||
137 | + | ||
138 | + stacked_ok = stacked_ok && | ||
139 | + v7m_stack_write(cpu, fpcar + 0x40, | ||
140 | + vfp_get_fpscr(env), mmu_idx, STACK_LAZYFP); | ||
141 | + } | ||
142 | + | ||
143 | + /* | ||
144 | + * We definitely pended an exception, but it's possible that it | ||
145 | + * might not be able to be taken now. If its priority permits us | ||
146 | + * to take it now, then we must not update the LSPACT or FP regs, | ||
147 | + * but instead jump out to take the exception immediately. | ||
148 | + * If it's just pending and won't be taken until the current | ||
149 | + * handler exits, then we do update LSPACT and the FP regs. | ||
150 | + */ | ||
151 | + take_exception = !stacked_ok && | ||
152 | + armv7m_nvic_can_take_pending_exception(env->nvic); | ||
153 | + | ||
154 | + qemu_mutex_unlock_iothread(); | ||
155 | + | ||
156 | + if (take_exception) { | ||
157 | + raise_exception_ra(env, EXCP_LAZYFP, 0, 1, GETPC()); | ||
158 | + } | ||
159 | + | ||
160 | + env->v7m.fpccr[is_secure] &= ~R_V7M_FPCCR_LSPACT_MASK; | ||
161 | + | ||
162 | + if (ts) { | ||
163 | + /* Clear s0 to s31 and the FPSCR */ | ||
164 | + int i; | ||
165 | + | ||
166 | + for (i = 0; i < 32; i += 2) { | ||
167 | + *aa32_vfp_dreg(env, i / 2) = 0; | ||
168 | + } | ||
169 | + vfp_set_fpscr(env, 0); | ||
170 | + } | ||
171 | + /* | ||
172 | + * Otherwise s0 to s15 and FPSCR are UNKNOWN; we choose to leave them | ||
173 | + * unchanged. | ||
174 | + */ | ||
175 | +} | 90 | +} |
176 | + | 91 | + |
177 | /* Write to v7M CONTROL.SPSEL bit for the specified security bank. | 92 | static bool trans_VADDV(DisasContext *s, arg_VADDV *a) |
178 | * This may change the current stack pointer between Main and Process | 93 | { |
179 | * stack pointers if it is done for the CONTROL register for the current | 94 | /* VADDV: vector add across vector */ |
180 | @@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx) | ||
181 | [EXCP_NOCP] = "v7M NOCP UsageFault", | ||
182 | [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
183 | [EXCP_STKOF] = "v8M STKOF UsageFault", | ||
184 | + [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | ||
185 | }; | ||
186 | |||
187 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | ||
188 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
189 | return; | ||
190 | } | ||
191 | break; | ||
192 | + case EXCP_LAZYFP: | ||
193 | + /* | ||
194 | + * We already pended the specific exception in the NVIC in the | ||
195 | + * v7m_preserve_fp_state() helper function. | ||
196 | + */ | ||
197 | + break; | ||
198 | default: | ||
199 | cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); | ||
200 | return; /* Never happens. Keep compiler happy. */ | ||
201 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
202 | flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1); | ||
203 | } | ||
204 | |||
205 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
206 | + bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | ||
207 | + | ||
208 | + if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) { | ||
209 | + flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); | ||
210 | + } | ||
211 | + } | ||
212 | + | ||
213 | *pflags = flags; | ||
214 | *cs_base = 0; | ||
215 | } | ||
216 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
217 | index XXXXXXX..XXXXXXX 100644 | ||
218 | --- a/target/arm/translate.c | ||
219 | +++ b/target/arm/translate.c | ||
220 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
221 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
222 | /* Handle M-profile lazy FP state mechanics */ | ||
223 | |||
224 | + /* Trigger lazy-state preservation if necessary */ | ||
225 | + if (s->v7m_lspact) { | ||
226 | + /* | ||
227 | + * Lazy state saving affects external memory and also the NVIC, | ||
228 | + * so we must mark it as an IO operation for icount. | ||
229 | + */ | ||
230 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
231 | + gen_io_start(); | ||
232 | + } | ||
233 | + gen_helper_v7m_preserve_fp_state(cpu_env); | ||
234 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
235 | + gen_io_end(); | ||
236 | + } | ||
237 | + /* | ||
238 | + * If the preserve_fp_state helper doesn't throw an exception | ||
239 | + * then it will clear LSPACT; we don't need to repeat this for | ||
240 | + * any further FP insns in this TB. | ||
241 | + */ | ||
242 | + s->v7m_lspact = false; | ||
243 | + } | ||
244 | + | ||
245 | /* Update ownership of FP context: set FPCCR.S to match current state */ | ||
246 | if (s->v8m_fpccr_s_wrong) { | ||
247 | TCGv_i32 tmp; | ||
248 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
249 | dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG); | ||
250 | dc->v7m_new_fp_ctxt_needed = | ||
251 | FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED); | ||
252 | + dc->v7m_lspact = FIELD_EX32(tb_flags, TBFLAG_A32, LSPACT); | ||
253 | dc->cp_regs = cpu->cp_regs; | ||
254 | dc->features = env->features; | ||
255 | |||
256 | -- | 95 | -- |
257 | 2.20.1 | 96 | 2.20.1 |
258 | 97 | ||
259 | 98 | diff view generated by jsdifflib |
1 | The only "system register" that M-profile floating point exposes | 1 | Implement the MVE VCTP insn, which sets the VPR.P0 predicate bits so |
---|---|---|---|
2 | via the VMRS/VMRS instructions is FPSCR, and it does not have | 2 | as to predicate any element at index Rn or greater is predicated. As |
3 | the odd special case for rd==15. Add a check to ensure we only | 3 | with VPNOT, this insn itself is predicable and subject to beatwise |
4 | expose FPSCR. | 4 | execution. |
5 | |||
6 | The calculation of the mask is the same as is used to determine | ||
7 | ltpmask in mve_element_mask(), but we precalculate masklen in | ||
8 | generated code to avoid having to have 4 helpers specialized by size. | ||
9 | |||
10 | We put the decode line in with the low-overhead-loop insns in | ||
11 | t32.decode because it's logically part of that collection of insn | ||
12 | patterns, even though it is an MVE only insn. | ||
5 | 13 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20190416125744.27770-5-peter.maydell@linaro.org | ||
9 | --- | 16 | --- |
10 | target/arm/translate.c | 19 +++++++++++++++++-- | 17 | target/arm/helper-mve.h | 2 ++ |
11 | 1 file changed, 17 insertions(+), 2 deletions(-) | 18 | target/arm/translate-a32.h | 1 + |
19 | target/arm/t32.decode | 1 + | ||
20 | target/arm/mve_helper.c | 20 ++++++++++++++++++++ | ||
21 | target/arm/translate-mve.c | 2 +- | ||
22 | target/arm/translate.c | 33 +++++++++++++++++++++++++++++++++ | ||
23 | 6 files changed, 58 insertions(+), 1 deletion(-) | ||
12 | 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_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) | ||
97 | } | ||
98 | } | ||
99 | |||
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, | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 105 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
14 | index XXXXXXX..XXXXXXX 100644 | 106 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 107 | --- a/target/arm/translate.c |
16 | +++ b/target/arm/translate.c | 108 | +++ b/target/arm/translate.c |
17 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 109 | @@ -XXX,XX +XXX,XX @@ static bool trans_LCTP(DisasContext *s, arg_LCTP *a) |
18 | } | 110 | return true; |
19 | } | 111 | } |
20 | } else { /* !dp */ | 112 | |
21 | + bool is_sysreg; | 113 | +static bool trans_VCTP(DisasContext *s, arg_VCTP *a) |
114 | +{ | ||
115 | + /* | ||
116 | + * M-profile Create Vector Tail Predicate. This insn is itself | ||
117 | + * predicated and is subject to beatwise execution. | ||
118 | + */ | ||
119 | + TCGv_i32 rn_shifted, masklen; | ||
22 | + | 120 | + |
23 | if ((insn & 0x6f) != 0x00) | 121 | + if (!dc_isar_feature(aa32_mve, s) || a->rn == 13 || a->rn == 15) { |
24 | return 1; | 122 | + return false; |
25 | rn = VFP_SREG_N(insn); | 123 | + } |
26 | + | 124 | + |
27 | + is_sysreg = extract32(insn, 21, 1); | 125 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
126 | + return true; | ||
127 | + } | ||
28 | + | 128 | + |
29 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | 129 | + /* |
30 | + /* | 130 | + * We pre-calculate the mask length here to avoid having |
31 | + * The only M-profile VFP vmrs/vmsr sysreg is FPSCR. | 131 | + * to have multiple helpers specialized for size. |
32 | + * Writes to R15 are UNPREDICTABLE; we choose to undef. | 132 | + * We pass the helper "rn <= (1 << (4 - size)) ? (rn << size) : 16". |
33 | + */ | 133 | + */ |
34 | + if (is_sysreg && (rd == 15 || (rn >> 1) != ARM_VFP_FPSCR)) { | 134 | + rn_shifted = tcg_temp_new_i32(); |
35 | + return 1; | 135 | + masklen = load_reg(s, a->rn); |
36 | + } | 136 | + tcg_gen_shli_i32(rn_shifted, masklen, a->size); |
37 | + } | 137 | + tcg_gen_movcond_i32(TCG_COND_LEU, masklen, |
38 | + | 138 | + masklen, tcg_constant_i32(1 << (4 - a->size)), |
39 | if (insn & ARM_CP_RW_BIT) { | 139 | + rn_shifted, tcg_constant_i32(16)); |
40 | /* vfp->arm */ | 140 | + gen_helper_mve_vctp(cpu_env, masklen); |
41 | - if (insn & (1 << 21)) { | 141 | + tcg_temp_free_i32(masklen); |
42 | + if (is_sysreg) { | 142 | + tcg_temp_free_i32(rn_shifted); |
43 | /* system register */ | 143 | + mve_update_eci(s); |
44 | rn >>= 1; | 144 | + return true; |
45 | 145 | +} | |
46 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 146 | |
47 | } | 147 | static bool op_tbranch(DisasContext *s, arg_tbranch *a, bool half) |
48 | } else { | 148 | { |
49 | /* arm->vfp */ | ||
50 | - if (insn & (1 << 21)) { | ||
51 | + if (is_sysreg) { | ||
52 | rn >>= 1; | ||
53 | /* system register */ | ||
54 | switch (rn) { | ||
55 | -- | 149 | -- |
56 | 2.20.1 | 150 | 2.20.1 |
57 | 151 | ||
58 | 152 | diff view generated by jsdifflib |
1 | Normally configure identifies the source path by looking | 1 | Implement the MVE gather-loads and scatter-stores which |
---|---|---|---|
2 | at the location where the configure script itself exists. | 2 | form the address by adding a base value from a scalar |
3 | We also provide a --source-path option which lets the user | 3 | register to an offset in each element of a vector. |
4 | manually override this. | ||
5 | |||
6 | There isn't really an obvious use case for the --source-path | ||
7 | option, and in commit 927128222b0a91f56c13a in 2017 we | ||
8 | accidentally added some logic that looks at $source_path | ||
9 | before the command line option that overrides it has been | ||
10 | processed. | ||
11 | |||
12 | The fact that nobody complained suggests that there isn't | ||
13 | any use of this option and we aren't testing it either; | ||
14 | remove it. This allows us to move the "make $source_path | ||
15 | absolute" logic up so that there is no window in the script | ||
16 | where $source_path is set but not yet absolute. | ||
17 | 4 | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
20 | Message-id: 20190318134019.23729-1-peter.maydell@linaro.org | ||
21 | --- | 7 | --- |
22 | configure | 10 ++-------- | 8 | target/arm/helper-mve.h | 32 +++++++++ |
23 | 1 file changed, 2 insertions(+), 8 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(+) | ||
24 | 13 | ||
25 | diff --git a/configure b/configure | 14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
26 | index XXXXXXX..XXXXXXX 100755 | 15 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/configure | 16 | --- a/target/arm/helper-mve.h |
28 | +++ b/configure | 17 | +++ b/target/arm/helper-mve.h |
29 | @@ -XXX,XX +XXX,XX @@ ld_has() { | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) |
30 | 19 | DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) | |
31 | # default parameters | 20 | DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) |
32 | source_path=$(dirname "$0") | 21 | |
33 | +# make source path absolute | 22 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
34 | +source_path=$(cd "$source_path"; pwd) | 23 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
35 | cpu="" | 24 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
36 | iasl="iasl" | 25 | + |
37 | interp_prefix="/usr/gnemul/qemu-%M" | 26 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
38 | @@ -XXX,XX +XXX,XX @@ for opt do | 27 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
39 | ;; | 28 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
40 | --cxx=*) CXX="$optarg" | 29 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
41 | ;; | 30 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
42 | - --source-path=*) source_path="$optarg" | 31 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
43 | - ;; | 32 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
44 | --cpu=*) cpu="$optarg" | 33 | + |
45 | ;; | 34 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
46 | --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg" | 35 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
47 | @@ -XXX,XX +XXX,XX @@ if test "$debug_info" = "yes"; then | 36 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
48 | LDFLAGS="-g $LDFLAGS" | 37 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
49 | fi | 38 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
50 | 39 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
51 | -# make source path absolute | 40 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
52 | -source_path=$(cd "$source_path"; pwd) | 41 | + |
53 | - | 42 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
54 | # running configure in the source tree? | 43 | + |
55 | # we know that's the case if configure is there. | 44 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
56 | if test -f "./configure"; then | 45 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
57 | @@ -XXX,XX +XXX,XX @@ for opt do | 46 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
58 | ;; | 47 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
59 | --interp-prefix=*) interp_prefix="$optarg" | 48 | + |
60 | ;; | 49 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
61 | - --source-path=*) | 50 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
62 | - ;; | 51 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
63 | --cross-prefix=*) | 52 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
64 | ;; | 53 | + |
65 | --cc=*) | 54 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) |
66 | @@ -XXX,XX +XXX,XX @@ $(echo Available targets: $default_target_list | \ | 55 | |
67 | --target-list-exclude=LIST exclude a set of targets from the default target-list | 56 | DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
68 | 57 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | |
69 | Advanced options (experts only): | 58 | index XXXXXXX..XXXXXXX 100644 |
70 | - --source-path=PATH path of source code [$source_path] | 59 | --- a/target/arm/mve.decode |
71 | --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix] | 60 | +++ b/target/arm/mve.decode |
72 | --cc=CC use C compiler CC [$cc] | 61 | @@ -XXX,XX +XXX,XX @@ |
73 | --iasl=IASL use ACPI compiler IASL [$iasl] | 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; | ||
74 | -- | 347 | -- |
75 | 2.20.1 | 348 | 2.20.1 |
76 | 349 | ||
77 | 350 | diff view generated by jsdifflib |
1 | The M-profile CONTROL register has two bits -- SFPA and FPCA -- | 1 | Implement the MVE VLDR/VSTR insns which do scatter-gather using base |
---|---|---|---|
2 | which relate to floating-point support, and should be RES0 otherwise. | 2 | addresses from Qm plus or minus an immediate offset (possibly with |
3 | Handle them correctly in the MSR/MRS register access code. | 3 | writeback). Note that writeback is not predicated but it does have |
4 | Neither is banked between security states, so they are stored | 4 | to honour ECI state, so we have to add an eci_mask check to the |
5 | in v7m.control[M_REG_S] regardless of current security state. | 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: 20190416125744.27770-9-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | target/arm/helper.c | 57 ++++++++++++++++++++++++++++++++++++++------- | 11 | target/arm/helper-mve.h | 5 +++ |
12 | 1 file changed, 49 insertions(+), 8 deletions(-) | 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/target/arm/helper.c b/target/arm/helper.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/target/arm/helper.c | 19 | --- a/target/arm/helper-mve.h |
17 | +++ b/target/arm/helper.c | 20 | +++ b/target/arm/helper-mve.h |
18 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | 21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
19 | return xpsr_read(env) & mask; | 22 | DEF_HELPER_FLAGS_4(mve_vstrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
20 | break; | 23 | DEF_HELPER_FLAGS_4(mve_vstrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | case 20: /* CONTROL */ | 24 | |
22 | - return env->v7m.control[env->v7m.secure]; | 25 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | + { | 26 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
24 | + uint32_t value = env->v7m.control[env->v7m.secure]; | 27 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | + if (!env->v7m.secure) { | 28 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
26 | + /* SFPA is RAZ/WI from NS; FPCA is stored in the M_REG_S bank */ | 29 | + |
27 | + value |= env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK; | 30 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) |
28 | + } | 31 | |
29 | + return value; | 32 | DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
30 | + } | 33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
31 | case 0x94: /* CONTROL_NS */ | 34 | index XXXXXXX..XXXXXXX 100644 |
32 | /* We have to handle this here because unprivileged Secure code | 35 | --- a/target/arm/mve.decode |
33 | * can read the NS CONTROL register. | 36 | +++ b/target/arm/mve.decode |
34 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | 37 | @@ -XXX,XX +XXX,XX @@ |
35 | if (!env->v7m.secure) { | 38 | &vmaxv qm rda size |
36 | return 0; | 39 | &vabav qn qm rda size |
37 | } | 40 | &vldst_sg qd qm rn size msize os |
38 | - return env->v7m.control[M_REG_NS]; | 41 | +&vldst_sg_imm qd qm a w imm |
39 | + return env->v7m.control[M_REG_NS] | | 42 | |
40 | + (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK); | 43 | # scatter-gather memory size is in bits 6:4 |
44 | %sg_msize 6:1 4:1 | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | @vldst_sg .... .... .... rn:4 .... ... size:2 ... ... os:1 &vldst_sg \ | ||
47 | qd=%qd qm=%qm msize=%sg_msize | ||
48 | |||
49 | +# Qm is in the fields usually labeled Qn | ||
50 | +@vldst_sg_imm .... .... a:1 . w:1 . .... .... .... . imm:7 &vldst_sg_imm \ | ||
51 | + qd=%qd qm=%qn | ||
52 | + | ||
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); \ | ||
41 | } | 90 | } |
42 | 91 | ||
43 | if (el == 0) { | 92 | /* We know here TYPE is unsigned so always the same as the offset type */ |
44 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | 93 | -#define DO_VSTR_SG(OP, STTYPE, ESIZE, TYPE, ADDRFN) \ |
45 | */ | 94 | +#define DO_VSTR_SG(OP, STTYPE, ESIZE, TYPE, ADDRFN, WB) \ |
46 | uint32_t mask = extract32(maskreg, 8, 4); | 95 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ |
47 | uint32_t reg = extract32(maskreg, 0, 8); | 96 | uint32_t base) \ |
48 | + int cur_el = arm_current_el(env); | 97 | { \ |
49 | 98 | TYPE *d = vd; \ | |
50 | - if (arm_current_el(env) == 0 && reg > 7) { | 99 | TYPE *m = vm; \ |
51 | - /* only xPSR sub-fields may be written by unprivileged */ | 100 | uint16_t mask = mve_element_mask(env); \ |
52 | + if (cur_el == 0 && reg > 7 && reg != 20) { | 101 | + uint16_t eci_mask = mve_eci_mask(env); \ |
53 | + /* | 102 | unsigned e; \ |
54 | + * only xPSR sub-fields and CONTROL.SFPA may be written by | 103 | uint32_t addr; \ |
55 | + * unprivileged code | 104 | - for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ |
56 | + */ | 105 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE, eci_mask >>= ESIZE) { \ |
57 | return; | 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); \ | ||
58 | } | 118 | } |
59 | 119 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | |
60 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | 120 | * accesses, controlled by the predicate mask for the relevant beat, |
61 | env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK; | 121 | * and with a single 32-bit offset in the first of the two Qm elements. |
62 | env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK; | 122 | * Note that for QEMU our IMPDEF AIRCR.ENDIANNESS is always 0 (little). |
63 | } | 123 | + * Address writeback happens on the odd beats and updates the address |
64 | + /* | 124 | + * stored in the even-beat element. |
65 | + * SFPA is RAZ/WI from NS. FPCA is RO if NSACR.CP10 == 0, | 125 | */ |
66 | + * RES0 if the FPU is not present, and is stored in the S bank | 126 | -#define DO_VLDR64_SG(OP, ADDRFN) \ |
67 | + */ | 127 | +#define DO_VLDR64_SG(OP, ADDRFN, WB) \ |
68 | + if (arm_feature(env, ARM_FEATURE_VFP) && | 128 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ |
69 | + extract32(env->v7m.nsacr, 10, 1)) { | 129 | uint32_t base) \ |
70 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | 130 | { \ |
71 | + env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK; | 131 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) |
72 | + } | 132 | addr = ADDRFN(base, m[H4(e & ~1)]); \ |
73 | return; | 133 | addr += 4 * (e & 1); \ |
74 | case 0x98: /* SP_NS */ | 134 | d[H4(e)] = (mask & 1) ? cpu_ldl_data_ra(env, addr, GETPC()) : 0; \ |
75 | { | 135 | + if (WB && (e & 1)) { \ |
76 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | 136 | + m[H4(e & ~1)] = addr - 4; \ |
77 | env->v7m.faultmask[env->v7m.secure] = val & 1; | 137 | + } \ |
78 | break; | 138 | } \ |
79 | case 20: /* CONTROL */ | 139 | mve_advance_vpt(env); \ |
80 | - /* Writing to the SPSEL bit only has an effect if we are in | 140 | } |
81 | + /* | 141 | |
82 | + * Writing to the SPSEL bit only has an effect if we are in | 142 | -#define DO_VSTR64_SG(OP, ADDRFN) \ |
83 | * thread mode; other bits can be updated by any privileged code. | 143 | +#define DO_VSTR64_SG(OP, ADDRFN, WB) \ |
84 | * write_v7m_control_spsel() deals with updating the SPSEL bit in | 144 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ |
85 | * env->v7m.control, so we only need update the others. | 145 | uint32_t base) \ |
86 | * For v7M, we must just ignore explicit writes to SPSEL in handler | 146 | { \ |
87 | * mode; for v8M the write is permitted but will have no effect. | 147 | uint32_t *d = vd; \ |
88 | + * All these bits are writes-ignored from non-privileged code, | 148 | uint32_t *m = vm; \ |
89 | + * except for SFPA. | 149 | uint16_t mask = mve_element_mask(env); \ |
90 | */ | 150 | + uint16_t eci_mask = mve_eci_mask(env); \ |
91 | - if (arm_feature(env, ARM_FEATURE_V8) || | 151 | unsigned e; \ |
92 | - !arm_v7m_is_handler_mode(env)) { | 152 | uint32_t addr; \ |
93 | + if (cur_el > 0 && (arm_feature(env, ARM_FEATURE_V8) || | 153 | - for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ |
94 | + !arm_v7m_is_handler_mode(env))) { | 154 | + for (e = 0; e < 16 / 4; e++, mask >>= 4, eci_mask >>= 4) { \ |
95 | write_v7m_control_spsel(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0); | 155 | + if (!(eci_mask & 1)) { \ |
96 | } | 156 | + continue; \ |
97 | - if (arm_feature(env, ARM_FEATURE_M_MAIN)) { | 157 | + } \ |
98 | + if (cur_el > 0 && arm_feature(env, ARM_FEATURE_M_MAIN)) { | 158 | addr = ADDRFN(base, m[H4(e & ~1)]); \ |
99 | env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK; | 159 | addr += 4 * (e & 1); \ |
100 | env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK; | 160 | if (mask & 1) { \ |
101 | } | 161 | cpu_stl_data_ra(env, addr, d[H4(e)], GETPC()); \ |
102 | + if (arm_feature(env, ARM_FEATURE_VFP)) { | 162 | } \ |
103 | + /* | 163 | + if (WB && (e & 1)) { \ |
104 | + * SFPA is RAZ/WI from NS or if no FPU. | 164 | + m[H4(e & ~1)] = addr - 4; \ |
105 | + * FPCA is RO if NSACR.CP10 == 0, RES0 if the FPU is not present. | 165 | + } \ |
106 | + * Both are stored in the S bank. | 166 | } \ |
107 | + */ | 167 | mve_advance_vpt(env); \ |
108 | + if (env->v7m.secure) { | 168 | } |
109 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | 169 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) |
110 | + env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_SFPA_MASK; | 170 | #define ADDR_ADD_OSW(BASE, OFFSET) ((BASE) + ((OFFSET) << 2)) |
111 | + } | 171 | #define ADDR_ADD_OSD(BASE, OFFSET) ((BASE) + ((OFFSET) << 3)) |
112 | + if (cur_el > 0 && | 172 | |
113 | + (env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_SECURITY) || | 173 | -DO_VLDR_SG(vldrb_sg_sh, ldsb, 2, int16_t, uint16_t, ADDR_ADD) |
114 | + extract32(env->v7m.nsacr, 10, 1))) { | 174 | -DO_VLDR_SG(vldrb_sg_sw, ldsb, 4, int32_t, uint32_t, ADDR_ADD) |
115 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | 175 | -DO_VLDR_SG(vldrh_sg_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD) |
116 | + env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK; | 176 | +DO_VLDR_SG(vldrb_sg_sh, ldsb, 2, int16_t, uint16_t, ADDR_ADD, false) |
117 | + } | 177 | +DO_VLDR_SG(vldrb_sg_sw, ldsb, 4, int32_t, uint32_t, ADDR_ADD, false) |
118 | + } | 178 | +DO_VLDR_SG(vldrh_sg_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD, false) |
119 | break; | 179 | |
120 | default: | 180 | -DO_VLDR_SG(vldrb_sg_ub, ldub, 1, uint8_t, uint8_t, ADDR_ADD) |
121 | bad_reg: | 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; | ||
122 | -- | 320 | -- |
123 | 2.20.1 | 321 | 2.20.1 |
124 | 322 | ||
125 | 323 | diff view generated by jsdifflib |
1 | In the stripe8() function we use a variable length array; however | 1 | Implement the MVE interleaving load/store functions VLD2, VLD4, VST2 |
---|---|---|---|
2 | we know that the maximum length required is MAX_NUM_BUSSES. Use | 2 | and VST4. VLD2 loads 16 bytes of data from memory and writes to 2 |
3 | a fixed-length array and an assert instead. | 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: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> | ||
10 | Message-id: 20190328152635.2794-1-peter.maydell@linaro.org | ||
11 | --- | 13 | --- |
12 | hw/ssi/xilinx_spips.c | 6 ++++-- | 14 | target/arm/helper-mve.h | 48 ++++++ |
13 | 1 file changed, 4 insertions(+), 2 deletions(-) | 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(+) | ||
14 | 19 | ||
15 | diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c | 20 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
16 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/ssi/xilinx_spips.c | 22 | --- a/target/arm/helper-mve.h |
18 | +++ b/hw/ssi/xilinx_spips.c | 23 | +++ b/target/arm/helper-mve.h |
19 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_qspips_reset(DeviceState *d) | 24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vldrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
20 | 25 | DEF_HELPER_FLAGS_4(mve_vstrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
21 | static inline void stripe8(uint8_t *x, int num, bool dir) | 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); | ||
482 | } | ||
483 | |||
484 | +static bool do_vldst_il(DisasContext *s, arg_vldst_il *a, MVEGenLdStIlFn *fn, | ||
485 | + int addrinc) | ||
486 | +{ | ||
487 | + TCGv_i32 rn; | ||
488 | + | ||
489 | + if (!dc_isar_feature(aa32_mve, s) || | ||
490 | + !mve_check_qreg_bank(s, a->qd) || | ||
491 | + !fn || (a->rn == 13 && a->w) || a->rn == 15) { | ||
492 | + /* Variously UNPREDICTABLE or UNDEF or related-encoding */ | ||
493 | + return false; | ||
494 | + } | ||
495 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
496 | + return true; | ||
497 | + } | ||
498 | + | ||
499 | + rn = load_reg(s, a->rn); | ||
500 | + /* | ||
501 | + * We pass the index of Qd, not a pointer, because the helper must | ||
502 | + * access multiple Q registers starting at Qd and working up. | ||
503 | + */ | ||
504 | + fn(cpu_env, tcg_constant_i32(a->qd), rn); | ||
505 | + | ||
506 | + if (a->w) { | ||
507 | + tcg_gen_addi_i32(rn, rn, addrinc); | ||
508 | + store_reg(s, a->rn, rn); | ||
509 | + } else { | ||
510 | + tcg_temp_free_i32(rn); | ||
511 | + } | ||
512 | + mve_update_and_store_eci(s); | ||
513 | + return true; | ||
514 | +} | ||
515 | + | ||
516 | +/* This macro is just to make the arrays more compact in these functions */ | ||
517 | +#define F(N) gen_helper_mve_##N | ||
518 | + | ||
519 | +static bool trans_VLD2(DisasContext *s, arg_vldst_il *a) | ||
520 | +{ | ||
521 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
522 | + { F(vld20b), F(vld20h), F(vld20w), NULL, }, | ||
523 | + { F(vld21b), F(vld21h), F(vld21w), NULL, }, | ||
524 | + { NULL, NULL, NULL, NULL }, | ||
525 | + { NULL, NULL, NULL, NULL }, | ||
526 | + }; | ||
527 | + if (a->qd > 6) { | ||
528 | + return false; | ||
529 | + } | ||
530 | + return do_vldst_il(s, a, fns[a->pat][a->size], 32); | ||
531 | +} | ||
532 | + | ||
533 | +static bool trans_VLD4(DisasContext *s, arg_vldst_il *a) | ||
534 | +{ | ||
535 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
536 | + { F(vld40b), F(vld40h), F(vld40w), NULL, }, | ||
537 | + { F(vld41b), F(vld41h), F(vld41w), NULL, }, | ||
538 | + { F(vld42b), F(vld42h), F(vld42w), NULL, }, | ||
539 | + { F(vld43b), F(vld43h), F(vld43w), NULL, }, | ||
540 | + }; | ||
541 | + if (a->qd > 4) { | ||
542 | + return false; | ||
543 | + } | ||
544 | + return do_vldst_il(s, a, fns[a->pat][a->size], 64); | ||
545 | +} | ||
546 | + | ||
547 | +static bool trans_VST2(DisasContext *s, arg_vldst_il *a) | ||
548 | +{ | ||
549 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
550 | + { F(vst20b), F(vst20h), F(vst20w), NULL, }, | ||
551 | + { F(vst21b), F(vst21h), F(vst21w), NULL, }, | ||
552 | + { NULL, NULL, NULL, NULL }, | ||
553 | + { NULL, NULL, NULL, NULL }, | ||
554 | + }; | ||
555 | + if (a->qd > 6) { | ||
556 | + return false; | ||
557 | + } | ||
558 | + return do_vldst_il(s, a, fns[a->pat][a->size], 32); | ||
559 | +} | ||
560 | + | ||
561 | +static bool trans_VST4(DisasContext *s, arg_vldst_il *a) | ||
562 | +{ | ||
563 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
564 | + { F(vst40b), F(vst40h), F(vst40w), NULL, }, | ||
565 | + { F(vst41b), F(vst41h), F(vst41w), NULL, }, | ||
566 | + { F(vst42b), F(vst42h), F(vst42w), NULL, }, | ||
567 | + { F(vst43b), F(vst43h), F(vst43w), NULL, }, | ||
568 | + }; | ||
569 | + if (a->qd > 4) { | ||
570 | + return false; | ||
571 | + } | ||
572 | + return do_vldst_il(s, a, fns[a->pat][a->size], 64); | ||
573 | +} | ||
574 | + | ||
575 | +#undef F | ||
576 | + | ||
577 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
22 | { | 578 | { |
23 | - uint8_t r[num]; | 579 | TCGv_ptr qd; |
24 | - memset(r, 0, sizeof(uint8_t) * num); | ||
25 | + uint8_t r[MAX_NUM_BUSSES]; | ||
26 | int idx[2] = {0, 0}; | ||
27 | int bit[2] = {0, 7}; | ||
28 | int d = dir; | ||
29 | |||
30 | + assert(num <= MAX_NUM_BUSSES); | ||
31 | + memset(r, 0, sizeof(uint8_t) * num); | ||
32 | + | ||
33 | for (idx[0] = 0; idx[0] < num; ++idx[0]) { | ||
34 | for (bit[0] = 7; bit[0] >= 0; bit[0]--) { | ||
35 | r[idx[!d]] |= x[idx[d]] & 1 << bit[d] ? 1 << bit[!d] : 0; | ||
36 | -- | 580 | -- |
37 | 2.20.1 | 581 | 2.20.1 |
38 | 582 | ||
39 | 583 | diff view generated by jsdifflib |
1 | If the floating point extension is present, then the SG instruction | 1 | We're about to make a code change to the sdiv and udiv helper |
---|---|---|---|
2 | must clear the CONTROL_S.SFPA bit. Implement this. | 2 | functions, so first fix their indentation and coding style. |
3 | |||
4 | (On a no-FPU system the bit will always be zero, so we don't need | ||
5 | to make the clearing of the bit conditional on ARM_FEATURE_VFP.) | ||
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: 20190416125744.27770-8-peter.maydell@linaro.org | 6 | Message-id: 20210730151636.17254-2-peter.maydell@linaro.org |
10 | --- | 7 | --- |
11 | target/arm/helper.c | 1 + | 8 | target/arm/helper.c | 15 +++++++++------ |
12 | 1 file changed, 1 insertion(+) | 9 | 1 file changed, 9 insertions(+), 6 deletions(-) |
13 | 10 | ||
14 | 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 |
15 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 13 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/helper.c | 14 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) | 15 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(uxtb16)(uint32_t x) |
19 | qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32 | 16 | |
20 | ", executing it\n", env->regs[15]); | 17 | int32_t HELPER(sdiv)(int32_t num, int32_t den) |
21 | env->regs[14] &= ~1; | 18 | { |
22 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | 19 | - if (den == 0) |
23 | switch_v7m_security_state(env, true); | 20 | - return 0; |
24 | xpsr_write(env, 0, XPSR_IT); | 21 | - if (num == INT_MIN && den == -1) |
25 | env->regs[15] += 4; | 22 | - return INT_MIN; |
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 | |||
26 | -- | 42 | -- |
27 | 2.20.1 | 43 | 2.20.1 |
28 | 44 | ||
29 | 45 | diff view generated by jsdifflib |
1 | Implement the VLSTM instruction for v7M for the FPU present case. | 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. | ||
4 | |||
5 | Implement support for setting this bit by making the helper functions | ||
6 | raise the appropriate exception. | ||
2 | 7 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20190416125744.27770-25-peter.maydell@linaro.org | 10 | Message-id: 20210730151636.17254-3-peter.maydell@linaro.org |
6 | --- | 11 | --- |
7 | target/arm/cpu.h | 2 + | 12 | target/arm/cpu.h | 1 + |
8 | target/arm/helper.h | 2 + | 13 | target/arm/helper.h | 4 ++-- |
9 | target/arm/helper.c | 84 ++++++++++++++++++++++++++++++++++++++++++ | 14 | target/arm/helper.c | 19 +++++++++++++++++-- |
10 | target/arm/translate.c | 15 +++++++- | 15 | target/arm/m_helper.c | 4 ++++ |
11 | 4 files changed, 102 insertions(+), 1 deletion(-) | 16 | target/arm/translate.c | 4 ++-- |
17 | 5 files changed, 26 insertions(+), 6 deletions(-) | ||
12 | 18 | ||
13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu.h | 21 | --- a/target/arm/cpu.h |
16 | +++ b/target/arm/cpu.h | 22 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
18 | #define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */ | ||
19 | #define EXCP_STKOF 19 /* v8M STKOF UsageFault */ | ||
20 | #define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */ | 24 | #define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */ |
21 | +#define EXCP_LSERR 21 /* v8M LSERR SecureFault */ | 25 | #define EXCP_LSERR 21 /* v8M LSERR SecureFault */ |
22 | +#define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */ | 26 | #define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */ |
27 | +#define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */ | ||
23 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | 28 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ |
24 | 29 | ||
25 | #define ARMV7M_EXCP_RESET 1 | 30 | #define ARMV7M_EXCP_RESET 1 |
26 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 31 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
27 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/helper.h | 33 | --- a/target/arm/helper.h |
29 | +++ b/target/arm/helper.h | 34 | +++ b/target/arm/helper.h |
30 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32) | 35 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(add_saturate, i32, env, i32, i32) |
31 | 36 | DEF_HELPER_3(sub_saturate, i32, env, i32, i32) | |
32 | DEF_HELPER_1(v7m_preserve_fp_state, void, env) | 37 | DEF_HELPER_3(add_usaturate, i32, env, i32, i32) |
33 | 38 | DEF_HELPER_3(sub_usaturate, i32, env, i32, i32) | |
34 | +DEF_HELPER_2(v7m_vlstm, void, env, i32) | 39 | -DEF_HELPER_FLAGS_2(sdiv, TCG_CALL_NO_RWG_SE, s32, s32, s32) |
35 | + | 40 | -DEF_HELPER_FLAGS_2(udiv, TCG_CALL_NO_RWG_SE, i32, i32, i32) |
36 | DEF_HELPER_2(v8m_stackcheck, void, env, i32) | 41 | +DEF_HELPER_FLAGS_3(sdiv, TCG_CALL_NO_RWG, s32, env, s32, s32) |
37 | 42 | +DEF_HELPER_FLAGS_3(udiv, TCG_CALL_NO_RWG, i32, env, i32, i32) | |
38 | DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32) | 43 | DEF_HELPER_FLAGS_1(rbit, TCG_CALL_NO_RWG_SE, i32, i32) |
44 | |||
45 | #define PAS_OP(pfx) \ | ||
39 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 46 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
40 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/arm/helper.c | 48 | --- a/target/arm/helper.c |
42 | +++ b/target/arm/helper.c | 49 | +++ b/target/arm/helper.c |
43 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) | 50 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sxtb16)(uint32_t x) |
44 | g_assert_not_reached(); | 51 | return res; |
45 | } | 52 | } |
46 | 53 | ||
47 | +void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | 54 | +static void handle_possible_div0_trap(CPUARMState *env, uintptr_t ra) |
48 | +{ | 55 | +{ |
49 | + /* translate.c should never generate calls here in user-only mode */ | 56 | + /* |
50 | + g_assert_not_reached(); | 57 | + * Take a division-by-zero exception if necessary; otherwise return |
58 | + * to get the usual non-trapping division behaviour (result of 0) | ||
59 | + */ | ||
60 | + if (arm_feature(env, ARM_FEATURE_M) | ||
61 | + && (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_DIV_0_TRP_MASK)) { | ||
62 | + raise_exception_ra(env, EXCP_DIVBYZERO, 0, 1, ra); | ||
63 | + } | ||
51 | +} | 64 | +} |
52 | + | 65 | + |
53 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 66 | uint32_t HELPER(uxtb16)(uint32_t x) |
54 | { | 67 | { |
55 | /* The TT instructions can be used by unprivileged code, but in | 68 | uint32_t res; |
56 | @@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, | 69 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(uxtb16)(uint32_t x) |
70 | return res; | ||
71 | } | ||
72 | |||
73 | -int32_t HELPER(sdiv)(int32_t num, int32_t den) | ||
74 | +int32_t HELPER(sdiv)(CPUARMState *env, int32_t num, int32_t den) | ||
75 | { | ||
76 | if (den == 0) { | ||
77 | + handle_possible_div0_trap(env, GETPC()); | ||
78 | return 0; | ||
57 | } | 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; | ||
58 | } | 83 | } |
59 | 84 | ||
60 | +void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | 85 | -uint32_t HELPER(udiv)(uint32_t num, uint32_t den) |
61 | +{ | 86 | +uint32_t HELPER(udiv)(CPUARMState *env, uint32_t num, uint32_t den) |
62 | + /* fptr is the value of Rn, the frame pointer we store the FP regs to */ | ||
63 | + bool s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | ||
64 | + bool lspact = env->v7m.fpccr[s] & R_V7M_FPCCR_LSPACT_MASK; | ||
65 | + | ||
66 | + assert(env->v7m.secure); | ||
67 | + | ||
68 | + if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) { | ||
69 | + return; | ||
70 | + } | ||
71 | + | ||
72 | + /* Check access to the coprocessor is permitted */ | ||
73 | + if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) { | ||
74 | + raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC()); | ||
75 | + } | ||
76 | + | ||
77 | + if (lspact) { | ||
78 | + /* LSPACT should not be active when there is active FP state */ | ||
79 | + raise_exception_ra(env, EXCP_LSERR, 0, 1, GETPC()); | ||
80 | + } | ||
81 | + | ||
82 | + if (fptr & 7) { | ||
83 | + raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC()); | ||
84 | + } | ||
85 | + | ||
86 | + /* | ||
87 | + * Note that we do not use v7m_stack_write() here, because the | ||
88 | + * accesses should not set the FSR bits for stacking errors if they | ||
89 | + * fail. (In pseudocode terms, they are AccType_NORMAL, not AccType_STACK | ||
90 | + * or AccType_LAZYFP). Faults in cpu_stl_data() will throw exceptions | ||
91 | + * and longjmp out. | ||
92 | + */ | ||
93 | + if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) { | ||
94 | + bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK; | ||
95 | + int i; | ||
96 | + | ||
97 | + for (i = 0; i < (ts ? 32 : 16); i += 2) { | ||
98 | + uint64_t dn = *aa32_vfp_dreg(env, i / 2); | ||
99 | + uint32_t faddr = fptr + 4 * i; | ||
100 | + uint32_t slo = extract64(dn, 0, 32); | ||
101 | + uint32_t shi = extract64(dn, 32, 32); | ||
102 | + | ||
103 | + if (i >= 16) { | ||
104 | + faddr += 8; /* skip the slot for the FPSCR */ | ||
105 | + } | ||
106 | + cpu_stl_data(env, faddr, slo); | ||
107 | + cpu_stl_data(env, faddr + 4, shi); | ||
108 | + } | ||
109 | + cpu_stl_data(env, fptr + 0x40, vfp_get_fpscr(env)); | ||
110 | + | ||
111 | + /* | ||
112 | + * If TS is 0 then s0 to s15 and FPSCR are UNKNOWN; we choose to | ||
113 | + * leave them unchanged, matching our choice in v7m_preserve_fp_state. | ||
114 | + */ | ||
115 | + if (ts) { | ||
116 | + for (i = 0; i < 32; i += 2) { | ||
117 | + *aa32_vfp_dreg(env, i / 2) = 0; | ||
118 | + } | ||
119 | + vfp_set_fpscr(env, 0); | ||
120 | + } | ||
121 | + } else { | ||
122 | + v7m_update_fpccr(env, fptr, false); | ||
123 | + } | ||
124 | + | ||
125 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | ||
126 | +} | ||
127 | + | ||
128 | static bool v7m_push_stack(ARMCPU *cpu) | ||
129 | { | 87 | { |
130 | /* Do the "set up stack frame" part of exception entry, | 88 | if (den == 0) { |
131 | @@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx) | 89 | + handle_possible_div0_trap(env, GETPC()); |
132 | [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | 90 | return 0; |
133 | [EXCP_STKOF] = "v8M STKOF UsageFault", | 91 | } |
92 | return num / den; | ||
93 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(int idx) | ||
134 | [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | 94 | [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", |
135 | + [EXCP_LSERR] = "v8M LSERR UsageFault", | 95 | [EXCP_LSERR] = "v8M LSERR UsageFault", |
136 | + [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | 96 | [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", |
97 | + [EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault", | ||
137 | }; | 98 | }; |
138 | 99 | ||
139 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | 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 | ||
140 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 105 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) |
141 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | 106 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); |
142 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_STKOF_MASK; | 107 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; |
143 | break; | 108 | break; |
144 | + case EXCP_LSERR: | 109 | + case EXCP_DIVBYZERO: |
145 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
146 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | ||
147 | + break; | ||
148 | + case EXCP_UNALIGNED: | ||
149 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | 110 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); |
150 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; | 111 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_DIVBYZERO_MASK; |
151 | + break; | 112 | + break; |
152 | case EXCP_SWI: | 113 | case EXCP_SWI: |
153 | /* The PC already points to the next instruction. */ | 114 | /* The PC already points to the next instruction. */ |
154 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure); | 115 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure); |
155 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 116 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
156 | index XXXXXXX..XXXXXXX 100644 | 117 | index XXXXXXX..XXXXXXX 100644 |
157 | --- a/target/arm/translate.c | 118 | --- a/target/arm/translate.c |
158 | +++ b/target/arm/translate.c | 119 | +++ b/target/arm/translate.c |
159 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 120 | @@ -XXX,XX +XXX,XX @@ static bool op_div(DisasContext *s, arg_rrr *a, bool u) |
160 | if (!s->v8m_secure || (insn & 0x0040f0ff)) { | 121 | t1 = load_reg(s, a->rn); |
161 | goto illegal_op; | 122 | t2 = load_reg(s, a->rm); |
162 | } | 123 | if (u) { |
163 | - /* Just NOP since FP support is not implemented */ | 124 | - gen_helper_udiv(t1, t1, t2); |
164 | + | 125 | + gen_helper_udiv(t1, cpu_env, t1, t2); |
165 | + if (arm_dc_feature(s, ARM_FEATURE_VFP)) { | 126 | } else { |
166 | + TCGv_i32 fptr = load_reg(s, rn); | 127 | - gen_helper_sdiv(t1, t1, t2); |
167 | + | 128 | + gen_helper_sdiv(t1, cpu_env, t1, t2); |
168 | + if (extract32(insn, 20, 1)) { | 129 | } |
169 | + /* VLLDM */ | 130 | tcg_temp_free_i32(t2); |
170 | + } else { | 131 | store_reg(s, a->rd, t1); |
171 | + gen_helper_v7m_vlstm(cpu_env, fptr); | ||
172 | + } | ||
173 | + tcg_temp_free_i32(fptr); | ||
174 | + | ||
175 | + /* End the TB, because we have updated FP control bits */ | ||
176 | + s->base.is_jmp = DISAS_UPDATE; | ||
177 | + } | ||
178 | break; | ||
179 | } | ||
180 | if (arm_dc_feature(s, ARM_FEATURE_VFP) && | ||
181 | -- | 132 | -- |
182 | 2.20.1 | 133 | 2.20.1 |
183 | 134 | ||
184 | 135 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Hamza Mahfooz <someguy@effective-light.com> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 3 | As per commit 5626f8c6d468 ("rcu: Add automatically released rcu_read_lock |
4 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 4 | variants"), RCU_READ_LOCK_GUARD() should be used instead of |
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 5 | rcu_read_{un}lock(). |
6 | Message-id: 20190412165416.7977-7-philmd@redhat.com | 6 | |
7 | Signed-off-by: Hamza Mahfooz <someguy@effective-light.com> | ||
8 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | ||
9 | Message-id: 20210727235201.11491-1-someguy@effective-light.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 11 | --- |
9 | include/hw/devices.h | 14 -------------- | 12 | target/arm/kvm.c | 17 ++++++++--------- |
10 | include/hw/misc/cbus.h | 32 ++++++++++++++++++++++++++++++++ | 13 | 1 file changed, 8 insertions(+), 9 deletions(-) |
11 | hw/arm/nseries.c | 1 + | ||
12 | hw/misc/cbus.c | 2 +- | ||
13 | MAINTAINERS | 1 + | ||
14 | 5 files changed, 35 insertions(+), 15 deletions(-) | ||
15 | create mode 100644 include/hw/misc/cbus.h | ||
16 | 14 | ||
17 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 15 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/devices.h | 17 | --- a/target/arm/kvm.c |
20 | +++ b/include/hw/devices.h | 18 | +++ b/target/arm/kvm.c |
21 | @@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | 19 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, |
22 | /* stellaris_input.c */ | 20 | hwaddr xlat, len, doorbell_gpa; |
23 | void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | 21 | MemoryRegionSection mrs; |
24 | 22 | MemoryRegion *mr; | |
25 | -/* cbus.c */ | 23 | - int ret = 1; |
26 | -typedef struct { | 24 | |
27 | - qemu_irq clk; | 25 | if (as == &address_space_memory) { |
28 | - qemu_irq dat; | 26 | return 0; |
29 | - qemu_irq sel; | 27 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, |
30 | -} CBus; | 28 | |
31 | -CBus *cbus_init(qemu_irq dat_out); | 29 | /* MSI doorbell address is translated by an IOMMU */ |
32 | -void cbus_attach(CBus *bus, void *slave_opaque); | 30 | |
31 | - rcu_read_lock(); | ||
32 | + RCU_READ_LOCK_GUARD(); | ||
33 | + | ||
34 | mr = address_space_translate(as, address, &xlat, &len, true, | ||
35 | MEMTXATTRS_UNSPECIFIED); | ||
36 | + | ||
37 | if (!mr) { | ||
38 | - goto unlock; | ||
39 | + return 1; | ||
40 | } | ||
41 | + | ||
42 | mrs = memory_region_find(mr, xlat, 1); | ||
43 | + | ||
44 | if (!mrs.mr) { | ||
45 | - goto unlock; | ||
46 | + return 1; | ||
47 | } | ||
48 | |||
49 | doorbell_gpa = mrs.offset_within_address_space; | ||
50 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, | ||
51 | |||
52 | trace_kvm_arm_fixup_msi_route(address, doorbell_gpa); | ||
53 | |||
54 | - ret = 0; | ||
33 | - | 55 | - |
34 | -void *retu_init(qemu_irq irq, int vilma); | 56 | -unlock: |
35 | -void *tahvo_init(qemu_irq irq, int betty); | 57 | - rcu_read_unlock(); |
36 | - | 58 | - return ret; |
37 | -void retu_key_event(void *retu, int state); | 59 | + return 0; |
38 | - | 60 | } |
39 | #endif | 61 | |
40 | diff --git a/include/hw/misc/cbus.h b/include/hw/misc/cbus.h | 62 | int kvm_arch_add_msi_route_post(struct kvm_irq_routing_entry *route, |
41 | new file mode 100644 | ||
42 | index XXXXXXX..XXXXXXX | ||
43 | --- /dev/null | ||
44 | +++ b/include/hw/misc/cbus.h | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | +/* | ||
47 | + * CBUS three-pin bus and the Retu / Betty / Tahvo / Vilma / Avilma / | ||
48 | + * Hinku / Vinku / Ahne / Pihi chips used in various Nokia platforms. | ||
49 | + * Based on reverse-engineering of a linux driver. | ||
50 | + * | ||
51 | + * Copyright (C) 2008 Nokia Corporation | ||
52 | + * Written by Andrzej Zaborowski | ||
53 | + * | ||
54 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
55 | + * See the COPYING file in the top-level directory. | ||
56 | + */ | ||
57 | + | ||
58 | +#ifndef HW_MISC_CBUS_H | ||
59 | +#define HW_MISC_CBUS_H | ||
60 | + | ||
61 | +#include "hw/irq.h" | ||
62 | + | ||
63 | +typedef struct { | ||
64 | + qemu_irq clk; | ||
65 | + qemu_irq dat; | ||
66 | + qemu_irq sel; | ||
67 | +} CBus; | ||
68 | + | ||
69 | +CBus *cbus_init(qemu_irq dat_out); | ||
70 | +void cbus_attach(CBus *bus, void *slave_opaque); | ||
71 | + | ||
72 | +void *retu_init(qemu_irq irq, int vilma); | ||
73 | +void *tahvo_init(qemu_irq irq, int betty); | ||
74 | + | ||
75 | +void retu_key_event(void *retu, int state); | ||
76 | + | ||
77 | +#endif | ||
78 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/hw/arm/nseries.c | ||
81 | +++ b/hw/arm/nseries.c | ||
82 | @@ -XXX,XX +XXX,XX @@ | ||
83 | #include "hw/i2c/i2c.h" | ||
84 | #include "hw/devices.h" | ||
85 | #include "hw/display/blizzard.h" | ||
86 | +#include "hw/misc/cbus.h" | ||
87 | #include "hw/misc/tmp105.h" | ||
88 | #include "hw/block/flash.h" | ||
89 | #include "hw/hw.h" | ||
90 | diff --git a/hw/misc/cbus.c b/hw/misc/cbus.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/hw/misc/cbus.c | ||
93 | +++ b/hw/misc/cbus.c | ||
94 | @@ -XXX,XX +XXX,XX @@ | ||
95 | #include "qemu/osdep.h" | ||
96 | #include "hw/hw.h" | ||
97 | #include "hw/irq.h" | ||
98 | -#include "hw/devices.h" | ||
99 | +#include "hw/misc/cbus.h" | ||
100 | #include "sysemu/sysemu.h" | ||
101 | |||
102 | //#define DEBUG | ||
103 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/MAINTAINERS | ||
106 | +++ b/MAINTAINERS | ||
107 | @@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c | ||
108 | F: hw/misc/cbus.c | ||
109 | F: hw/timer/twl92230.c | ||
110 | F: include/hw/display/blizzard.h | ||
111 | +F: include/hw/misc/cbus.h | ||
112 | |||
113 | Palm | ||
114 | M: Andrzej Zaborowski <balrogg@gmail.com> | ||
115 | -- | 63 | -- |
116 | 2.20.1 | 64 | 2.20.1 |
117 | 65 | ||
118 | 66 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Jan Luebbe <jlu@pengutronix.de> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 3 | Break events are currently only handled by chardev/char-serial.c, so we |
4 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 4 | just ignore errors, which results in no behaviour change for other |
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 5 | chardevs. |
6 | Message-id: 20190412165416.7977-11-philmd@redhat.com | 6 | |
7 | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> | ||
8 | Message-id: 20210806144700.3751979-1-jlu@pengutronix.de | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 11 | --- |
9 | include/hw/net/ne2000-isa.h | 6 ++++++ | 12 | hw/char/pl011.c | 6 ++++++ |
10 | 1 file changed, 6 insertions(+) | 13 | 1 file changed, 6 insertions(+) |
11 | 14 | ||
12 | diff --git a/include/hw/net/ne2000-isa.h b/include/hw/net/ne2000-isa.h | 15 | diff --git a/hw/char/pl011.c b/hw/char/pl011.c |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/include/hw/net/ne2000-isa.h | 17 | --- a/hw/char/pl011.c |
15 | +++ b/include/hw/net/ne2000-isa.h | 18 | +++ b/hw/char/pl011.c |
16 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
17 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | 20 | #include "hw/qdev-properties-system.h" |
18 | * See the COPYING file in the top-level directory. | 21 | #include "migration/vmstate.h" |
19 | */ | 22 | #include "chardev/char-fe.h" |
20 | + | 23 | +#include "chardev/char-serial.h" |
21 | +#ifndef HW_NET_NE2K_ISA_H | 24 | #include "qemu/log.h" |
22 | +#define HW_NET_NE2K_ISA_H | 25 | #include "qemu/module.h" |
23 | + | 26 | #include "trace.h" |
24 | #include "hw/hw.h" | 27 | @@ -XXX,XX +XXX,XX @@ static void pl011_write(void *opaque, hwaddr offset, |
25 | #include "hw/qdev.h" | 28 | s->read_count = 0; |
26 | #include "hw/isa/isa.h" | 29 | s->read_pos = 0; |
27 | @@ -XXX,XX +XXX,XX @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int base, int irq, | 30 | } |
28 | } | 31 | + if ((s->lcr ^ value) & 0x1) { |
29 | return d; | 32 | + int break_enable = value & 0x1; |
30 | } | 33 | + qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_BREAK, |
31 | + | 34 | + &break_enable); |
32 | +#endif | 35 | + } |
36 | s->lcr = value; | ||
37 | pl011_set_read_trigger(s); | ||
38 | break; | ||
33 | -- | 39 | -- |
34 | 2.20.1 | 40 | 2.20.1 |
35 | 41 | ||
36 | 42 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | 2 | ||
3 | Add an entries the Blizzard device in MAINTAINERS. | 3 | Instantiate SAI1/2/3 and ASRC as unimplemented devices to avoid random |
4 | Linux kernel crashes, such as | ||
4 | 5 | ||
5 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 6 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd1580010 |
6 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 7 | pgd = (ptrval) |
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | [d1580010] *pgd=8231b811, *pte=02034653, *ppte=02034453 |
8 | Message-id: 20190412165416.7977-6-philmd@redhat.com | 9 | Internal error: : 808 [#1] SMP ARM |
10 | ... | ||
11 | [<c095e974>] (regmap_mmio_write32le) from [<c095eb48>] (regmap_mmio_write+0x3c/0x54) | ||
12 | [<c095eb48>] (regmap_mmio_write) from [<c09580f4>] (_regmap_write+0x4c/0x1f0) | ||
13 | [<c09580f4>] (_regmap_write) from [<c095837c>] (_regmap_update_bits+0xe4/0xec) | ||
14 | [<c095837c>] (_regmap_update_bits) from [<c09599b4>] (regmap_update_bits_base+0x50/0x74) | ||
15 | [<c09599b4>] (regmap_update_bits_base) from [<c0d3e9e4>] (fsl_asrc_runtime_resume+0x1e4/0x21c) | ||
16 | [<c0d3e9e4>] (fsl_asrc_runtime_resume) from [<c0942464>] (__rpm_callback+0x3c/0x108) | ||
17 | [<c0942464>] (__rpm_callback) from [<c0942590>] (rpm_callback+0x60/0x64) | ||
18 | [<c0942590>] (rpm_callback) from [<c0942b60>] (rpm_resume+0x5cc/0x808) | ||
19 | [<c0942b60>] (rpm_resume) from [<c0942dfc>] (__pm_runtime_resume+0x60/0xa0) | ||
20 | [<c0942dfc>] (__pm_runtime_resume) from [<c0d3ecc4>] (fsl_asrc_probe+0x2a8/0x708) | ||
21 | [<c0d3ecc4>] (fsl_asrc_probe) from [<c0935b08>] (platform_probe+0x58/0xb8) | ||
22 | [<c0935b08>] (platform_probe) from [<c0933264>] (really_probe.part.0+0x9c/0x334) | ||
23 | [<c0933264>] (really_probe.part.0) from [<c093359c>] (__driver_probe_device+0xa0/0x138) | ||
24 | [<c093359c>] (__driver_probe_device) from [<c0933664>] (driver_probe_device+0x30/0xc8) | ||
25 | [<c0933664>] (driver_probe_device) from [<c0933c88>] (__driver_attach+0x90/0x130) | ||
26 | [<c0933c88>] (__driver_attach) from [<c0931060>] (bus_for_each_dev+0x78/0xb8) | ||
27 | [<c0931060>] (bus_for_each_dev) from [<c093254c>] (bus_add_driver+0xf0/0x1d8) | ||
28 | [<c093254c>] (bus_add_driver) from [<c0934a30>] (driver_register+0x88/0x118) | ||
29 | [<c0934a30>] (driver_register) from [<c01022c0>] (do_one_initcall+0x7c/0x3a4) | ||
30 | [<c01022c0>] (do_one_initcall) from [<c1601204>] (kernel_init_freeable+0x198/0x22c) | ||
31 | [<c1601204>] (kernel_init_freeable) from [<c0f5ff2c>] (kernel_init+0x10/0x128) | ||
32 | [<c0f5ff2c>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38) | ||
33 | |||
34 | or | ||
35 | |||
36 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd19b0000 | ||
37 | pgd = (ptrval) | ||
38 | [d19b0000] *pgd=82711811, *pte=308a0653, *ppte=308a0453 | ||
39 | Internal error: : 808 [#1] SMP ARM | ||
40 | ... | ||
41 | [<c095e974>] (regmap_mmio_write32le) from [<c095eb48>] (regmap_mmio_write+0x3c/0x54) | ||
42 | [<c095eb48>] (regmap_mmio_write) from [<c09580f4>] (_regmap_write+0x4c/0x1f0) | ||
43 | [<c09580f4>] (_regmap_write) from [<c0959b28>] (regmap_write+0x3c/0x60) | ||
44 | [<c0959b28>] (regmap_write) from [<c0d41130>] (fsl_sai_runtime_resume+0x9c/0x1ec) | ||
45 | [<c0d41130>] (fsl_sai_runtime_resume) from [<c0942464>] (__rpm_callback+0x3c/0x108) | ||
46 | [<c0942464>] (__rpm_callback) from [<c0942590>] (rpm_callback+0x60/0x64) | ||
47 | [<c0942590>] (rpm_callback) from [<c0942b60>] (rpm_resume+0x5cc/0x808) | ||
48 | [<c0942b60>] (rpm_resume) from [<c0942dfc>] (__pm_runtime_resume+0x60/0xa0) | ||
49 | [<c0942dfc>] (__pm_runtime_resume) from [<c0d4231c>] (fsl_sai_probe+0x2b8/0x65c) | ||
50 | [<c0d4231c>] (fsl_sai_probe) from [<c0935b08>] (platform_probe+0x58/0xb8) | ||
51 | [<c0935b08>] (platform_probe) from [<c0933264>] (really_probe.part.0+0x9c/0x334) | ||
52 | [<c0933264>] (really_probe.part.0) from [<c093359c>] (__driver_probe_device+0xa0/0x138) | ||
53 | [<c093359c>] (__driver_probe_device) from [<c0933664>] (driver_probe_device+0x30/0xc8) | ||
54 | [<c0933664>] (driver_probe_device) from [<c0933c88>] (__driver_attach+0x90/0x130) | ||
55 | [<c0933c88>] (__driver_attach) from [<c0931060>] (bus_for_each_dev+0x78/0xb8) | ||
56 | [<c0931060>] (bus_for_each_dev) from [<c093254c>] (bus_add_driver+0xf0/0x1d8) | ||
57 | [<c093254c>] (bus_add_driver) from [<c0934a30>] (driver_register+0x88/0x118) | ||
58 | [<c0934a30>] (driver_register) from [<c01022c0>] (do_one_initcall+0x7c/0x3a4) | ||
59 | [<c01022c0>] (do_one_initcall) from [<c1601204>] (kernel_init_freeable+0x198/0x22c) | ||
60 | [<c1601204>] (kernel_init_freeable) from [<c0f5ff2c>] (kernel_init+0x10/0x128) | ||
61 | [<c0f5ff2c>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38) | ||
62 | |||
63 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
64 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
65 | Message-id: 20210810160318.87376-1-linux@roeck-us.net | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 66 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 67 | --- |
11 | include/hw/devices.h | 7 ------- | 68 | hw/arm/fsl-imx6ul.c | 12 ++++++++++++ |
12 | include/hw/display/blizzard.h | 22 ++++++++++++++++++++++ | 69 | 1 file changed, 12 insertions(+) |
13 | hw/arm/nseries.c | 1 + | ||
14 | hw/display/blizzard.c | 2 +- | ||
15 | MAINTAINERS | 2 ++ | ||
16 | 5 files changed, 26 insertions(+), 8 deletions(-) | ||
17 | create mode 100644 include/hw/display/blizzard.h | ||
18 | 70 | ||
19 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 71 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c |
20 | index XXXXXXX..XXXXXXX 100644 | 72 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/hw/devices.h | 73 | --- a/hw/arm/fsl-imx6ul.c |
22 | +++ b/include/hw/devices.h | 74 | +++ b/hw/arm/fsl-imx6ul.c |
23 | @@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | 75 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
24 | /* stellaris_input.c */ | 76 | */ |
25 | void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | 77 | create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000); |
26 | 78 | ||
27 | -/* blizzard.c */ | 79 | + /* |
28 | -void *s1d13745_init(qemu_irq gpio_int); | 80 | + * SAI (Audio SSI (Synchronous Serial Interface)) |
29 | -void s1d13745_write(void *opaque, int dc, uint16_t value); | 81 | + */ |
30 | -void s1d13745_write_block(void *opaque, int dc, | 82 | + create_unimplemented_device("sai1", FSL_IMX6UL_SAI1_ADDR, 0x4000); |
31 | - void *buf, size_t len, int pitch); | 83 | + create_unimplemented_device("sai2", FSL_IMX6UL_SAI2_ADDR, 0x4000); |
32 | -uint16_t s1d13745_read(void *opaque, int dc); | 84 | + create_unimplemented_device("sai3", FSL_IMX6UL_SAI3_ADDR, 0x4000); |
33 | - | ||
34 | /* cbus.c */ | ||
35 | typedef struct { | ||
36 | qemu_irq clk; | ||
37 | diff --git a/include/hw/display/blizzard.h b/include/hw/display/blizzard.h | ||
38 | new file mode 100644 | ||
39 | index XXXXXXX..XXXXXXX | ||
40 | --- /dev/null | ||
41 | +++ b/include/hw/display/blizzard.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | +/* | ||
44 | + * Epson S1D13744/S1D13745 (Blizzard/Hailstorm/Tornado) LCD/TV controller. | ||
45 | + * | ||
46 | + * Copyright (C) 2008 Nokia Corporation | ||
47 | + * Written by Andrzej Zaborowski | ||
48 | + * | ||
49 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
50 | + * See the COPYING file in the top-level directory. | ||
51 | + */ | ||
52 | + | 85 | + |
53 | +#ifndef HW_DISPLAY_BLIZZARD_H | 86 | /* |
54 | +#define HW_DISPLAY_BLIZZARD_H | 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); | ||
55 | + | 97 | + |
56 | +#include "hw/irq.h" | 98 | /* |
57 | + | 99 | * CAN |
58 | +void *s1d13745_init(qemu_irq gpio_int); | 100 | */ |
59 | +void s1d13745_write(void *opaque, int dc, uint16_t value); | ||
60 | +void s1d13745_write_block(void *opaque, int dc, | ||
61 | + void *buf, size_t len, int pitch); | ||
62 | +uint16_t s1d13745_read(void *opaque, int dc); | ||
63 | + | ||
64 | +#endif | ||
65 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/hw/arm/nseries.c | ||
68 | +++ b/hw/arm/nseries.c | ||
69 | @@ -XXX,XX +XXX,XX @@ | ||
70 | #include "hw/boards.h" | ||
71 | #include "hw/i2c/i2c.h" | ||
72 | #include "hw/devices.h" | ||
73 | +#include "hw/display/blizzard.h" | ||
74 | #include "hw/misc/tmp105.h" | ||
75 | #include "hw/block/flash.h" | ||
76 | #include "hw/hw.h" | ||
77 | diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/display/blizzard.c | ||
80 | +++ b/hw/display/blizzard.c | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | #include "qemu/osdep.h" | ||
83 | #include "qemu-common.h" | ||
84 | #include "ui/console.h" | ||
85 | -#include "hw/devices.h" | ||
86 | +#include "hw/display/blizzard.h" | ||
87 | #include "ui/pixel_ops.h" | ||
88 | |||
89 | typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int); | ||
90 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/MAINTAINERS | ||
93 | +++ b/MAINTAINERS | ||
94 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | ||
95 | L: qemu-arm@nongnu.org | ||
96 | S: Odd Fixes | ||
97 | F: hw/arm/nseries.c | ||
98 | +F: hw/display/blizzard.c | ||
99 | F: hw/input/lm832x.c | ||
100 | F: hw/input/tsc2005.c | ||
101 | F: hw/misc/cbus.c | ||
102 | F: hw/timer/twl92230.c | ||
103 | +F: include/hw/display/blizzard.h | ||
104 | |||
105 | Palm | ||
106 | M: Andrzej Zaborowski <balrogg@gmail.com> | ||
107 | -- | 101 | -- |
108 | 2.20.1 | 102 | 2.20.1 |
109 | 103 | ||
110 | 104 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: "Wen, Jianxian" <Jianxian.Wen@verisilicon.com> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 3 | Add property memory region which can connect with IOMMU region to support SMMU translate. |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | |
5 | Message-id: 20190412165416.7977-12-philmd@redhat.com | 5 | Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Message-id: 4C23C17B8E87E74E906A25A3254A03F4FA1FEC31@SHASXM03.verisilicon.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 9 | --- |
8 | include/hw/net/lan9118.h | 2 ++ | 10 | hw/arm/exynos4210.c | 3 +++ |
9 | hw/arm/exynos4_boards.c | 3 ++- | 11 | hw/arm/xilinx_zynq.c | 3 +++ |
10 | hw/arm/mps2-tz.c | 3 ++- | 12 | hw/dma/pl330.c | 26 ++++++++++++++++++++++---- |
11 | hw/net/lan9118.c | 1 - | 13 | 3 files changed, 28 insertions(+), 4 deletions(-) |
12 | 4 files changed, 6 insertions(+), 3 deletions(-) | ||
13 | 14 | ||
14 | diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h | 15 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/net/lan9118.h | 17 | --- a/hw/arm/exynos4210.c |
17 | +++ b/include/hw/net/lan9118.h | 18 | +++ b/hw/arm/exynos4210.c |
18 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static DeviceState *pl330_create(uint32_t base, qemu_or_irq *orgate, |
19 | #include "hw/irq.h" | 20 | int i; |
20 | #include "net/net.h" | 21 | |
21 | 22 | dev = qdev_new("pl330"); | |
22 | +#define TYPE_LAN9118 "lan9118" | 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); | ||
73 | } | ||
74 | |||
75 | @@ -XXX,XX +XXX,XX @@ static int pl330_exec_cycle(PL330Chan *channel) | ||
76 | if (q != NULL && q->len <= pl330_fifo_num_free(&s->fifo)) { | ||
77 | int len = q->len - (q->addr & (q->len - 1)); | ||
78 | |||
79 | - dma_memory_read(&address_space_memory, q->addr, buf, len); | ||
80 | + dma_memory_read(s->mem_as, q->addr, buf, len); | ||
81 | trace_pl330_exec_cycle(q->addr, len); | ||
82 | if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { | ||
83 | pl330_hexdump(buf, len); | ||
84 | @@ -XXX,XX +XXX,XX @@ static int pl330_exec_cycle(PL330Chan *channel) | ||
85 | fifo_res = pl330_fifo_get(&s->fifo, buf, len, q->tag); | ||
86 | } | ||
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 | + } | ||
23 | + | 108 | + |
24 | void lan9118_init(NICInfo *, uint32_t, qemu_irq); | 109 | s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pl330_exec_cycle_timer, s); |
25 | 110 | ||
26 | #endif | 111 | s->cfg[0] = (s->mgr_ns_at_rst ? 0x4 : 0) | |
27 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c | 112 | @@ -XXX,XX +XXX,XX @@ static Property pl330_properties[] = { |
28 | index XXXXXXX..XXXXXXX 100644 | 113 | DEFINE_PROP_UINT8("rd_q_dep", PL330State, rd_q_dep, 16), |
29 | --- a/hw/arm/exynos4_boards.c | 114 | DEFINE_PROP_UINT16("data_buffer_dep", PL330State, data_buffer_dep, 256), |
30 | +++ b/hw/arm/exynos4_boards.c | 115 | |
31 | @@ -XXX,XX +XXX,XX @@ | 116 | + DEFINE_PROP_LINK("memory", PL330State, mem_mr, |
32 | #include "hw/arm/arm.h" | 117 | + TYPE_MEMORY_REGION, MemoryRegion *), |
33 | #include "exec/address-spaces.h" | 118 | + |
34 | #include "hw/arm/exynos4210.h" | 119 | DEFINE_PROP_END_OF_LIST(), |
35 | +#include "hw/net/lan9118.h" | ||
36 | #include "hw/boards.h" | ||
37 | |||
38 | #undef DEBUG | ||
39 | @@ -XXX,XX +XXX,XX @@ static void lan9215_init(uint32_t base, qemu_irq irq) | ||
40 | /* This should be a 9215 but the 9118 is close enough */ | ||
41 | if (nd_table[0].used) { | ||
42 | qemu_check_nic_model(&nd_table[0], "lan9118"); | ||
43 | - dev = qdev_create(NULL, "lan9118"); | ||
44 | + dev = qdev_create(NULL, TYPE_LAN9118); | ||
45 | qdev_set_nic_properties(dev, &nd_table[0]); | ||
46 | qdev_prop_set_uint32(dev, "mode_16bit", 1); | ||
47 | qdev_init_nofail(dev); | ||
48 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/hw/arm/mps2-tz.c | ||
51 | +++ b/hw/arm/mps2-tz.c | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | #include "hw/arm/armsse.h" | ||
54 | #include "hw/dma/pl080.h" | ||
55 | #include "hw/ssi/pl022.h" | ||
56 | +#include "hw/net/lan9118.h" | ||
57 | #include "net/net.h" | ||
58 | #include "hw/core/split-irq.h" | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque, | ||
61 | * except that it doesn't support the checksum-offload feature. | ||
62 | */ | ||
63 | qemu_check_nic_model(nd, "lan9118"); | ||
64 | - mms->lan9118 = qdev_create(NULL, "lan9118"); | ||
65 | + mms->lan9118 = qdev_create(NULL, TYPE_LAN9118); | ||
66 | qdev_set_nic_properties(mms->lan9118, nd); | ||
67 | qdev_init_nofail(mms->lan9118); | ||
68 | |||
69 | diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/hw/net/lan9118.c | ||
72 | +++ b/hw/net/lan9118.c | ||
73 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_lan9118_packet = { | ||
74 | } | ||
75 | }; | 120 | }; |
76 | 121 | ||
77 | -#define TYPE_LAN9118 "lan9118" | ||
78 | #define LAN9118(obj) OBJECT_CHECK(lan9118_state, (obj), TYPE_LAN9118) | ||
79 | |||
80 | typedef struct { | ||
81 | -- | 122 | -- |
82 | 2.20.1 | 123 | 2.20.1 |
83 | 124 | ||
84 | 125 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Eduardo Habkost <ehabkost@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | No code used the tc6393xb_gpio_in_get() and tc6393xb_gpio_out_set() | 3 | The SBSA_GWDT enum value conflicts with the SBSA_GWDT() QOM type |
4 | functions since their introduction in commit 88d2c950b002. Time to | 4 | checking helper, preventing us from using a OBJECT_DEFINE* or |
5 | remove them. | 5 | DEFINE_INSTANCE_CHECKER macro for the SBSA_GWDT() wrapper. |
6 | 6 | ||
7 | Suggested-by: Markus Armbruster <armbru@redhat.com> | 7 | If I understand the SBSA 6.0 specification correctly, the signal |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | being connected to IRQ 16 is the WS0 output signal from the |
9 | Message-id: 20190412165416.7977-4-philmd@redhat.com | 9 | Generic Watchdog. Rename the enum value to SBSA_GWDT_WS0 to be |
10 | more explicit and avoid the name conflict. | ||
11 | |||
12 | Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> | ||
13 | Message-id: 20210806023119.431680-1-ehabkost@redhat.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 16 | --- |
13 | include/hw/devices.h | 3 --- | 17 | hw/arm/sbsa-ref.c | 6 +++--- |
14 | hw/display/tc6393xb.c | 16 ---------------- | 18 | 1 file changed, 3 insertions(+), 3 deletions(-) |
15 | 2 files changed, 19 deletions(-) | ||
16 | 19 | ||
17 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 20 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
18 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/devices.h | 22 | --- a/hw/arm/sbsa-ref.c |
20 | +++ b/include/hw/devices.h | 23 | +++ b/hw/arm/sbsa-ref.c |
21 | @@ -XXX,XX +XXX,XX @@ void retu_key_event(void *retu, int state); | 24 | @@ -XXX,XX +XXX,XX @@ enum { |
22 | typedef struct TC6393xbState TC6393xbState; | 25 | SBSA_GIC_DIST, |
23 | TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem, | 26 | SBSA_GIC_REDIST, |
24 | uint32_t base, qemu_irq irq); | 27 | SBSA_SECURE_EC, |
25 | -void tc6393xb_gpio_out_set(TC6393xbState *s, int line, | 28 | - SBSA_GWDT, |
26 | - qemu_irq handler); | 29 | + SBSA_GWDT_WS0, |
27 | -qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s); | 30 | SBSA_GWDT_REFRESH, |
28 | qemu_irq tc6393xb_l3v_get(TC6393xbState *s); | 31 | SBSA_GWDT_CONTROL, |
29 | 32 | SBSA_SMMU, | |
30 | #endif | 33 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { |
31 | diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c | 34 | [SBSA_AHCI] = 10, |
32 | index XXXXXXX..XXXXXXX 100644 | 35 | [SBSA_EHCI] = 11, |
33 | --- a/hw/display/tc6393xb.c | 36 | [SBSA_SMMU] = 12, /* ... to 15 */ |
34 | +++ b/hw/display/tc6393xb.c | 37 | - [SBSA_GWDT] = 16, |
35 | @@ -XXX,XX +XXX,XX @@ struct TC6393xbState { | 38 | + [SBSA_GWDT_WS0] = 16, |
36 | blanked : 1; | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | -qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s) | 41 | static const char * const valid_cpus[] = { |
40 | -{ | 42 | @@ -XXX,XX +XXX,XX @@ static void create_wdt(const SBSAMachineState *sms) |
41 | - return s->gpio_in; | 43 | hwaddr cbase = sbsa_ref_memmap[SBSA_GWDT_CONTROL].base; |
42 | -} | 44 | DeviceState *dev = qdev_new(TYPE_WDT_SBSA); |
43 | - | 45 | SysBusDevice *s = SYS_BUS_DEVICE(dev); |
44 | static void tc6393xb_gpio_set(void *opaque, int line, int level) | 46 | - int irq = sbsa_ref_irqmap[SBSA_GWDT]; |
45 | { | 47 | + int irq = sbsa_ref_irqmap[SBSA_GWDT_WS0]; |
46 | // TC6393xbState *s = opaque; | 48 | |
47 | @@ -XXX,XX +XXX,XX @@ static void tc6393xb_gpio_set(void *opaque, int line, int level) | 49 | sysbus_realize_and_unref(s, &error_fatal); |
48 | // FIXME: how does the chip reflect the GPIO input level change? | 50 | sysbus_mmio_map(s, 0, rbase); |
49 | } | ||
50 | |||
51 | -void tc6393xb_gpio_out_set(TC6393xbState *s, int line, | ||
52 | - qemu_irq handler) | ||
53 | -{ | ||
54 | - if (line >= TC6393XB_GPIOS) { | ||
55 | - fprintf(stderr, "TC6393xb: no GPIO pin %d\n", line); | ||
56 | - return; | ||
57 | - } | ||
58 | - | ||
59 | - s->handler[line] = handler; | ||
60 | -} | ||
61 | - | ||
62 | static void tc6393xb_gpio_handler_update(TC6393xbState *s) | ||
63 | { | ||
64 | uint32_t level, diff; | ||
65 | -- | 51 | -- |
66 | 2.20.1 | 52 | 2.20.1 |
67 | 53 | ||
68 | 54 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | 2 | ||
3 | This device is used by both ARM (BCM2836, for raspi2) and AArch64 | 3 | Instantiate SAI1/2/3 as unimplemented devices to avoid Linux kernel crashes |
4 | (BCM2837, for raspi3) targets, and is not CPU-specific. | 4 | such as the following. |
5 | Move it to common object, so we build it once for all targets. | ||
6 | 5 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd19b0000 |
8 | Message-id: 20190427133028.12874-1-philmd@redhat.com | 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) | ||
34 | |||
35 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
36 | Message-id: 20210810175607.538090-1-linux@roeck-us.net | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 37 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 38 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 39 | --- |
12 | hw/dma/Makefile.objs | 2 +- | 40 | include/hw/arm/fsl-imx7.h | 5 +++++ |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 41 | hw/arm/fsl-imx7.c | 7 +++++++ |
42 | 2 files changed, 12 insertions(+) | ||
14 | 43 | ||
15 | diff --git a/hw/dma/Makefile.objs b/hw/dma/Makefile.objs | 44 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
16 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/dma/Makefile.objs | 46 | --- a/include/hw/arm/fsl-imx7.h |
18 | +++ b/hw/dma/Makefile.objs | 47 | +++ b/include/hw/arm/fsl-imx7.h |
19 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zdma.o | 48 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { |
20 | 49 | FSL_IMX7_UART6_ADDR = 0x30A80000, | |
21 | obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o | 50 | FSL_IMX7_UART7_ADDR = 0x30A90000, |
22 | obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o | 51 | |
23 | -obj-$(CONFIG_RASPI) += bcm2835_dma.o | 52 | + FSL_IMX7_SAI1_ADDR = 0x308A0000, |
24 | +common-obj-$(CONFIG_RASPI) += bcm2835_dma.o | 53 | + FSL_IMX7_SAI2_ADDR = 0x308B0000, |
54 | + FSL_IMX7_SAI3_ADDR = 0x308C0000, | ||
55 | + FSL_IMX7_SAIn_SIZE = 0x10000, | ||
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 | */ | ||
25 | -- | 78 | -- |
26 | 2.20.1 | 79 | 2.20.1 |
27 | 80 | ||
28 | 81 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Sebastian Meyer <meyer@absint.com> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 3 | With gdb 9.0 and better it is possible to connect to a gdbstub |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | over unix sockets, which is better than a TCP socket connection |
5 | Message-id: 20190412165416.7977-5-philmd@redhat.com | 5 | in some situations. The QEMU command line to set this up is |
6 | non-obvious; document it. | ||
7 | |||
8 | Signed-off-by: Sebastian Meyer <meyer@absint.com> | ||
9 | Message-id: 162867284829.27377.4784930719350564918-0@git.sr.ht | ||
10 | [PMM: Tweaked commit message; adjusted wording in a couple of | ||
11 | places; fixed rST formatting issue; moved section up out of | ||
12 | the 'advanced debugging options' subsection] | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 16 | --- |
8 | include/hw/devices.h | 6 ------ | 17 | docs/system/gdb.rst | 26 +++++++++++++++++++++++++- |
9 | include/hw/display/tc6393xb.h | 24 ++++++++++++++++++++++++ | 18 | 1 file changed, 25 insertions(+), 1 deletion(-) |
10 | hw/arm/tosa.c | 2 +- | ||
11 | hw/display/tc6393xb.c | 2 +- | ||
12 | MAINTAINERS | 1 + | ||
13 | 5 files changed, 27 insertions(+), 8 deletions(-) | ||
14 | create mode 100644 include/hw/display/tc6393xb.h | ||
15 | 19 | ||
16 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 20 | diff --git a/docs/system/gdb.rst b/docs/system/gdb.rst |
17 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/devices.h | 22 | --- a/docs/system/gdb.rst |
19 | +++ b/include/hw/devices.h | 23 | +++ b/docs/system/gdb.rst |
20 | @@ -XXX,XX +XXX,XX @@ void *tahvo_init(qemu_irq irq, int betty); | 24 | @@ -XXX,XX +XXX,XX @@ The ``-s`` option will make QEMU listen for an incoming connection |
21 | 25 | from gdb on TCP port 1234, and ``-S`` will make QEMU not start the | |
22 | void retu_key_event(void *retu, int state); | 26 | guest until you tell it to from gdb. (If you want to specify which |
23 | 27 | TCP port to use or to use something other than TCP for the gdbstub | |
24 | -/* tc6393xb.c */ | 28 | -connection, use the ``-gdb dev`` option instead of ``-s``.) |
25 | -typedef struct TC6393xbState TC6393xbState; | 29 | +connection, use the ``-gdb dev`` option instead of ``-s``. See |
26 | -TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem, | 30 | +`Using unix sockets`_ for an example.) |
27 | - uint32_t base, qemu_irq irq); | 31 | |
28 | -qemu_irq tc6393xb_l3v_get(TC6393xbState *s); | 32 | .. parsed-literal:: |
29 | - | 33 | |
30 | #endif | 34 | @@ -XXX,XX +XXX,XX @@ not just those in the cluster you are currently working on:: |
31 | diff --git a/include/hw/display/tc6393xb.h b/include/hw/display/tc6393xb.h | 35 | |
32 | new file mode 100644 | 36 | (gdb) set schedule-multiple on |
33 | index XXXXXXX..XXXXXXX | 37 | |
34 | --- /dev/null | 38 | +Using unix sockets |
35 | +++ b/include/hw/display/tc6393xb.h | 39 | +================== |
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | +/* | ||
38 | + * Toshiba TC6393XB I/O Controller. | ||
39 | + * Found in Sharp Zaurus SL-6000 (tosa) or some | ||
40 | + * Toshiba e-Series PDAs. | ||
41 | + * | ||
42 | + * Copyright (c) 2007 Hervé Poussineau | ||
43 | + * | ||
44 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
45 | + * See the COPYING file in the top-level directory. | ||
46 | + */ | ||
47 | + | 40 | + |
48 | +#ifndef HW_DISPLAY_TC6393XB_H | 41 | +An alternate method for connecting gdb to the QEMU gdbstub is to use |
49 | +#define HW_DISPLAY_TC6393XB_H | 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). | ||
50 | + | 45 | + |
51 | +#include "exec/memory.h" | 46 | +First create a chardev with the appropriate options, then |
52 | +#include "hw/irq.h" | 47 | +instruct the gdbserver to use that device: |
53 | + | 48 | + |
54 | +typedef struct TC6393xbState TC6393xbState; | 49 | +.. parsed-literal:: |
55 | + | 50 | + |
56 | +TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem, | 51 | + |qemu_system| -chardev socket,path=/tmp/gdb-socket,server=on,wait=off,id=gdb0 -gdb chardev:gdb0 -S ... |
57 | + uint32_t base, qemu_irq irq); | ||
58 | +qemu_irq tc6393xb_l3v_get(TC6393xbState *s); | ||
59 | + | 52 | + |
60 | +#endif | 53 | +Start gdb as before, but this time connect using the path to |
61 | diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c | 54 | +the socket:: |
62 | index XXXXXXX..XXXXXXX 100644 | 55 | + |
63 | --- a/hw/arm/tosa.c | 56 | + (gdb) target remote /tmp/gdb-socket |
64 | +++ b/hw/arm/tosa.c | 57 | + |
65 | @@ -XXX,XX +XXX,XX @@ | 58 | +Note that to use a unix socket for the connection you will need |
66 | #include "hw/hw.h" | 59 | +gdb version 9.0 or newer. |
67 | #include "hw/arm/pxa.h" | 60 | + |
68 | #include "hw/arm/arm.h" | 61 | Advanced debugging options |
69 | -#include "hw/devices.h" | 62 | ========================== |
70 | #include "hw/arm/sharpsl.h" | 63 | |
71 | #include "hw/pcmcia.h" | ||
72 | #include "hw/boards.h" | ||
73 | +#include "hw/display/tc6393xb.h" | ||
74 | #include "hw/i2c/i2c.h" | ||
75 | #include "hw/ssi/ssi.h" | ||
76 | #include "hw/sysbus.h" | ||
77 | diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/display/tc6393xb.c | ||
80 | +++ b/hw/display/tc6393xb.c | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | #include "qapi/error.h" | ||
83 | #include "qemu/host-utils.h" | ||
84 | #include "hw/hw.h" | ||
85 | -#include "hw/devices.h" | ||
86 | +#include "hw/display/tc6393xb.h" | ||
87 | #include "hw/block/flash.h" | ||
88 | #include "ui/console.h" | ||
89 | #include "ui/pixel_ops.h" | ||
90 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/MAINTAINERS | ||
93 | +++ b/MAINTAINERS | ||
94 | @@ -XXX,XX +XXX,XX @@ F: hw/misc/mst_fpga.c | ||
95 | F: hw/misc/max111x.c | ||
96 | F: include/hw/arm/pxa.h | ||
97 | F: include/hw/arm/sharpsl.h | ||
98 | +F: include/hw/display/tc6393xb.h | ||
99 | |||
100 | SABRELITE / i.MX6 | ||
101 | M: Peter Maydell <peter.maydell@linaro.org> | ||
102 | -- | 64 | -- |
103 | 2.20.1 | 65 | 2.20.1 |
104 | 66 | ||
105 | 67 | diff view generated by jsdifflib |