1 | First arm pullreq of 4.2... | 1 | The following changes since commit 5a67d7735d4162630769ef495cf813244fc850df: |
---|---|---|---|
2 | 2 | ||
3 | thanks | 3 | Merge remote-tracking branch 'remotes/berrange-gitlab/tags/tls-deps-pull-request' into staging (2021-07-02 08:22:39 +0100) |
4 | -- PMM | ||
5 | |||
6 | The following changes since commit 27608c7c66bd923eb5e5faab80e795408cbe2b51: | ||
7 | |||
8 | Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20190814a' into staging (2019-08-16 12:00:18 +0100) | ||
9 | 4 | ||
10 | are available in the Git repository at: | 5 | are available in the Git repository at: |
11 | 6 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190816 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210702 |
13 | 8 | ||
14 | for you to fetch changes up to 664b7e3b97d6376f3329986c465b3782458b0f8b: | 9 | for you to fetch changes up to 04ea4d3cfd0a21b248ece8eb7a9436a3d9898dd8: |
15 | 10 | ||
16 | target/arm: Use tcg_gen_extrh_i64_i32 to extract the high word (2019-08-16 14:02:53 +0100) | 11 | target/arm: Implement MVE shifts by register (2021-07-02 11:48:38 +0100) |
17 | 12 | ||
18 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
19 | target-arm queue: | 14 | target-arm queue: |
20 | * target/arm: generate a custom MIDR for -cpu max | 15 | * more MVE instructions |
21 | * hw/misc/zynq_slcr: refactor to use standard register definition | 16 | * hw/gpio/gpio_pwr: use shutdown function for reboot |
22 | * Set ENET_BD_BDU in I.MX FEC controller | 17 | * target/arm: Check NaN mode before silencing NaN |
23 | * target/arm: Fix routing of singlestep exceptions | 18 | * tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine |
24 | * refactor a32/t32 decoder handling of PC | 19 | * hw/arm: Add basic power management to raspi. |
25 | * minor optimisations/cleanups of some a32/t32 codegen | 20 | * docs/system/arm: Add quanta-gbs-bmc, quanta-q7l1-bmc |
26 | * target/arm/cpu64: Ensure kvm really supports aarch64=off | ||
27 | * target/arm/cpu: Ensure we can use the pmu with kvm | ||
28 | * target/arm: Minor cleanups preparatory to KVM SVE support | ||
29 | 21 | ||
30 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
31 | Aaron Hill (1): | 23 | Joe Komlodi (1): |
32 | Set ENET_BD_BDU in I.MX FEC controller | 24 | target/arm: Check NaN mode before silencing NaN |
33 | 25 | ||
34 | Alex Bennée (1): | 26 | Maxim Uvarov (1): |
35 | target/arm: generate a custom MIDR for -cpu max | 27 | hw/gpio/gpio_pwr: use shutdown function for reboot |
36 | 28 | ||
37 | Andrew Jones (6): | 29 | Nolan Leake (1): |
38 | target/arm/cpu64: Ensure kvm really supports aarch64=off | 30 | hw/arm: Add basic power management to raspi. |
39 | target/arm/cpu: Ensure we can use the pmu with kvm | ||
40 | target/arm/helper: zcr: Add build bug next to value range assumption | ||
41 | target/arm/cpu: Use div-round-up to determine predicate register array size | ||
42 | target/arm/kvm64: Fix error returns | ||
43 | target/arm/kvm64: Move the get/put of fpsimd registers out | ||
44 | 31 | ||
45 | Damien Hedde (1): | 32 | Patrick Venture (2): |
46 | hw/misc/zynq_slcr: use standard register definition | 33 | docs/system/arm: Add quanta-q7l1-bmc reference |
34 | docs/system/arm: Add quanta-gbs-bmc reference | ||
47 | 35 | ||
48 | Peter Maydell (2): | 36 | Peter Maydell (18): |
49 | target/arm: Factor out 'generate singlestep exception' function | 37 | target/arm: Fix MVE widening/narrowing VLDR/VSTR offset calculation |
50 | target/arm: Fix routing of singlestep exceptions | 38 | target/arm: Fix bugs in MVE VRMLALDAVH, VRMLSLDAVH |
39 | target/arm: Make asimd_imm_const() public | ||
40 | target/arm: Use asimd_imm_const for A64 decode | ||
41 | target/arm: Use dup_const() instead of bitfield_replicate() | ||
42 | target/arm: Implement MVE logical immediate insns | ||
43 | target/arm: Implement MVE vector shift left by immediate insns | ||
44 | target/arm: Implement MVE vector shift right by immediate insns | ||
45 | target/arm: Implement MVE VSHLL | ||
46 | target/arm: Implement MVE VSRI, VSLI | ||
47 | target/arm: Implement MVE VSHRN, VRSHRN | ||
48 | target/arm: Implement MVE saturating narrowing shifts | ||
49 | target/arm: Implement MVE VSHLC | ||
50 | target/arm: Implement MVE VADDLV | ||
51 | target/arm: Implement MVE long shifts by immediate | ||
52 | target/arm: Implement MVE long shifts by register | ||
53 | target/arm: Implement MVE shifts by immediate | ||
54 | target/arm: Implement MVE shifts by register | ||
51 | 55 | ||
52 | Richard Henderson (18): | 56 | Philippe Mathieu-Daudé (1): |
53 | target/arm: Pass in pc to thumb_insn_is_16bit | 57 | tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine |
54 | target/arm: Introduce pc_curr | ||
55 | target/arm: Introduce read_pc | ||
56 | target/arm: Introduce add_reg_for_lit | ||
57 | target/arm: Remove redundant s->pc & ~1 | ||
58 | target/arm: Replace s->pc with s->base.pc_next | ||
59 | target/arm: Replace offset with pc in gen_exception_insn | ||
60 | target/arm: Replace offset with pc in gen_exception_internal_insn | ||
61 | target/arm: Remove offset argument to gen_exception_bkpt_insn | ||
62 | target/arm: Use unallocated_encoding for aarch32 | ||
63 | target/arm: Remove helper_double_saturate | ||
64 | target/arm: Use tcg_gen_extract_i32 for shifter_out_im | ||
65 | target/arm: Use tcg_gen_deposit_i32 for PKHBT, PKHTB | ||
66 | target/arm: Remove redundant shift tests | ||
67 | target/arm: Use ror32 instead of open-coding the operation | ||
68 | target/arm: Use tcg_gen_rotri_i32 for gen_swap_half | ||
69 | target/arm: Simplify SMMLA, SMMLAR, SMMLS, SMMLSR | ||
70 | target/arm: Use tcg_gen_extrh_i64_i32 to extract the high word | ||
71 | 58 | ||
72 | target/arm/cpu.h | 13 +- | 59 | docs/system/arm/aspeed.rst | 1 + |
73 | target/arm/helper.h | 1 - | 60 | docs/system/arm/nuvoton.rst | 5 +- |
74 | target/arm/kvm_arm.h | 28 ++ | 61 | include/hw/arm/bcm2835_peripherals.h | 3 +- |
75 | target/arm/translate-a64.h | 4 +- | 62 | include/hw/misc/bcm2835_powermgt.h | 29 ++ |
76 | target/arm/translate.h | 39 ++- | 63 | target/arm/helper-mve.h | 108 +++++++ |
77 | hw/misc/zynq_slcr.c | 450 ++++++++++++++++---------------- | 64 | target/arm/translate.h | 41 +++ |
78 | hw/net/imx_fec.c | 4 + | 65 | target/arm/mve.decode | 177 ++++++++++- |
79 | target/arm/cpu.c | 30 ++- | 66 | target/arm/t32.decode | 71 ++++- |
80 | target/arm/cpu64.c | 31 ++- | 67 | hw/arm/bcm2835_peripherals.c | 13 +- |
81 | target/arm/helper.c | 7 + | 68 | hw/gpio/gpio_pwr.c | 2 +- |
82 | target/arm/kvm.c | 7 + | 69 | hw/misc/bcm2835_powermgt.c | 160 ++++++++++ |
83 | target/arm/kvm64.c | 161 +++++++----- | 70 | target/arm/helper-a64.c | 12 +- |
84 | target/arm/op_helper.c | 15 -- | 71 | target/arm/mve_helper.c | 524 +++++++++++++++++++++++++++++++-- |
85 | target/arm/translate-a64.c | 130 ++++------ | 72 | target/arm/translate-a64.c | 86 +----- |
86 | target/arm/translate-vfp.inc.c | 45 +--- | 73 | target/arm/translate-mve.c | 261 +++++++++++++++- |
87 | target/arm/translate.c | 572 +++++++++++++++++------------------------ | 74 | target/arm/translate-neon.c | 81 ----- |
88 | 16 files changed, 771 insertions(+), 766 deletions(-) | 75 | target/arm/translate.c | 327 +++++++++++++++++++- |
76 | target/arm/vfp_helper.c | 24 +- | ||
77 | hw/misc/meson.build | 1 + | ||
78 | tests/acceptance/boot_linux_console.py | 43 +++ | ||
79 | 20 files changed, 1760 insertions(+), 209 deletions(-) | ||
80 | create mode 100644 include/hw/misc/bcm2835_powermgt.h | ||
81 | create mode 100644 hw/misc/bcm2835_powermgt.c | ||
89 | 82 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alex Bennée <alex.bennee@linaro.org> | ||
2 | 1 | ||
3 | While most features are now detected by probing the ID_* registers | ||
4 | kernels can (and do) use MIDR_EL1 for working out of they have to | ||
5 | apply errata. This can trip up warnings in the kernel as it tries to | ||
6 | work out if it should apply workarounds to features that don't | ||
7 | actually exist in the reported CPU type. | ||
8 | |||
9 | Avoid this problem by synthesising our own MIDR value. | ||
10 | |||
11 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20190726113950.7499-1-alex.bennee@linaro.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | target/arm/cpu.h | 6 ++++++ | ||
18 | target/arm/cpu64.c | 19 +++++++++++++++++++ | ||
19 | 2 files changed, 25 insertions(+) | ||
20 | |||
21 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/target/arm/cpu.h | ||
24 | +++ b/target/arm/cpu.h | ||
25 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_FPCCR, ASPEN, 31, 1) | ||
26 | /* | ||
27 | * System register ID fields. | ||
28 | */ | ||
29 | +FIELD(MIDR_EL1, REVISION, 0, 4) | ||
30 | +FIELD(MIDR_EL1, PARTNUM, 4, 12) | ||
31 | +FIELD(MIDR_EL1, ARCHITECTURE, 16, 4) | ||
32 | +FIELD(MIDR_EL1, VARIANT, 20, 4) | ||
33 | +FIELD(MIDR_EL1, IMPLEMENTER, 24, 8) | ||
34 | + | ||
35 | FIELD(ID_ISAR0, SWAP, 0, 4) | ||
36 | FIELD(ID_ISAR0, BITCOUNT, 4, 4) | ||
37 | FIELD(ID_ISAR0, BITFIELD, 8, 4) | ||
38 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/cpu64.c | ||
41 | +++ b/target/arm/cpu64.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
43 | uint32_t u; | ||
44 | aarch64_a57_initfn(obj); | ||
45 | |||
46 | + /* | ||
47 | + * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real | ||
48 | + * one and try to apply errata workarounds or use impdef features we | ||
49 | + * don't provide. | ||
50 | + * An IMPLEMENTER field of 0 means "reserved for software use"; | ||
51 | + * ARCHITECTURE must be 0xf indicating "v7 or later, check ID registers | ||
52 | + * to see which features are present"; | ||
53 | + * the VARIANT, PARTNUM and REVISION fields are all implementation | ||
54 | + * defined and we choose to define PARTNUM just in case guest | ||
55 | + * code needs to distinguish this QEMU CPU from other software | ||
56 | + * implementations, though this shouldn't be needed. | ||
57 | + */ | ||
58 | + t = FIELD_DP64(0, MIDR_EL1, IMPLEMENTER, 0); | ||
59 | + t = FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf); | ||
60 | + t = FIELD_DP64(t, MIDR_EL1, PARTNUM, 'Q'); | ||
61 | + t = FIELD_DP64(t, MIDR_EL1, VARIANT, 0); | ||
62 | + t = FIELD_DP64(t, MIDR_EL1, REVISION, 0); | ||
63 | + cpu->midr = t; | ||
64 | + | ||
65 | t = cpu->isar.id_aa64isar0; | ||
66 | t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */ | ||
67 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); | ||
68 | -- | ||
69 | 2.20.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Damien Hedde <damien.hedde@greensocs.com> | ||
2 | 1 | ||
3 | Replace the zynq_slcr registers enum and macros using the | ||
4 | hw/registerfields.h macros. | ||
5 | |||
6 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Message-id: 20190729145654.14644-30-damien.hedde@greensocs.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/misc/zynq_slcr.c | 450 ++++++++++++++++++++++---------------------- | ||
13 | 1 file changed, 225 insertions(+), 225 deletions(-) | ||
14 | |||
15 | diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/misc/zynq_slcr.c | ||
18 | +++ b/hw/misc/zynq_slcr.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "sysemu/sysemu.h" | ||
21 | #include "qemu/log.h" | ||
22 | #include "qemu/module.h" | ||
23 | +#include "hw/registerfields.h" | ||
24 | |||
25 | #ifndef ZYNQ_SLCR_ERR_DEBUG | ||
26 | #define ZYNQ_SLCR_ERR_DEBUG 0 | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | #define XILINX_LOCK_KEY 0x767b | ||
29 | #define XILINX_UNLOCK_KEY 0xdf0d | ||
30 | |||
31 | -#define R_PSS_RST_CTRL_SOFT_RST 0x1 | ||
32 | +REG32(SCL, 0x000) | ||
33 | +REG32(LOCK, 0x004) | ||
34 | +REG32(UNLOCK, 0x008) | ||
35 | +REG32(LOCKSTA, 0x00c) | ||
36 | |||
37 | -enum { | ||
38 | - SCL = 0x000 / 4, | ||
39 | - LOCK, | ||
40 | - UNLOCK, | ||
41 | - LOCKSTA, | ||
42 | +REG32(ARM_PLL_CTRL, 0x100) | ||
43 | +REG32(DDR_PLL_CTRL, 0x104) | ||
44 | +REG32(IO_PLL_CTRL, 0x108) | ||
45 | +REG32(PLL_STATUS, 0x10c) | ||
46 | +REG32(ARM_PLL_CFG, 0x110) | ||
47 | +REG32(DDR_PLL_CFG, 0x114) | ||
48 | +REG32(IO_PLL_CFG, 0x118) | ||
49 | |||
50 | - ARM_PLL_CTRL = 0x100 / 4, | ||
51 | - DDR_PLL_CTRL, | ||
52 | - IO_PLL_CTRL, | ||
53 | - PLL_STATUS, | ||
54 | - ARM_PLL_CFG, | ||
55 | - DDR_PLL_CFG, | ||
56 | - IO_PLL_CFG, | ||
57 | - | ||
58 | - ARM_CLK_CTRL = 0x120 / 4, | ||
59 | - DDR_CLK_CTRL, | ||
60 | - DCI_CLK_CTRL, | ||
61 | - APER_CLK_CTRL, | ||
62 | - USB0_CLK_CTRL, | ||
63 | - USB1_CLK_CTRL, | ||
64 | - GEM0_RCLK_CTRL, | ||
65 | - GEM1_RCLK_CTRL, | ||
66 | - GEM0_CLK_CTRL, | ||
67 | - GEM1_CLK_CTRL, | ||
68 | - SMC_CLK_CTRL, | ||
69 | - LQSPI_CLK_CTRL, | ||
70 | - SDIO_CLK_CTRL, | ||
71 | - UART_CLK_CTRL, | ||
72 | - SPI_CLK_CTRL, | ||
73 | - CAN_CLK_CTRL, | ||
74 | - CAN_MIOCLK_CTRL, | ||
75 | - DBG_CLK_CTRL, | ||
76 | - PCAP_CLK_CTRL, | ||
77 | - TOPSW_CLK_CTRL, | ||
78 | +REG32(ARM_CLK_CTRL, 0x120) | ||
79 | +REG32(DDR_CLK_CTRL, 0x124) | ||
80 | +REG32(DCI_CLK_CTRL, 0x128) | ||
81 | +REG32(APER_CLK_CTRL, 0x12c) | ||
82 | +REG32(USB0_CLK_CTRL, 0x130) | ||
83 | +REG32(USB1_CLK_CTRL, 0x134) | ||
84 | +REG32(GEM0_RCLK_CTRL, 0x138) | ||
85 | +REG32(GEM1_RCLK_CTRL, 0x13c) | ||
86 | +REG32(GEM0_CLK_CTRL, 0x140) | ||
87 | +REG32(GEM1_CLK_CTRL, 0x144) | ||
88 | +REG32(SMC_CLK_CTRL, 0x148) | ||
89 | +REG32(LQSPI_CLK_CTRL, 0x14c) | ||
90 | +REG32(SDIO_CLK_CTRL, 0x150) | ||
91 | +REG32(UART_CLK_CTRL, 0x154) | ||
92 | +REG32(SPI_CLK_CTRL, 0x158) | ||
93 | +REG32(CAN_CLK_CTRL, 0x15c) | ||
94 | +REG32(CAN_MIOCLK_CTRL, 0x160) | ||
95 | +REG32(DBG_CLK_CTRL, 0x164) | ||
96 | +REG32(PCAP_CLK_CTRL, 0x168) | ||
97 | +REG32(TOPSW_CLK_CTRL, 0x16c) | ||
98 | |||
99 | #define FPGA_CTRL_REGS(n, start) \ | ||
100 | - FPGA ## n ## _CLK_CTRL = (start) / 4, \ | ||
101 | - FPGA ## n ## _THR_CTRL, \ | ||
102 | - FPGA ## n ## _THR_CNT, \ | ||
103 | - FPGA ## n ## _THR_STA, | ||
104 | - FPGA_CTRL_REGS(0, 0x170) | ||
105 | - FPGA_CTRL_REGS(1, 0x180) | ||
106 | - FPGA_CTRL_REGS(2, 0x190) | ||
107 | - FPGA_CTRL_REGS(3, 0x1a0) | ||
108 | + REG32(FPGA ## n ## _CLK_CTRL, (start)) \ | ||
109 | + REG32(FPGA ## n ## _THR_CTRL, (start) + 0x4)\ | ||
110 | + REG32(FPGA ## n ## _THR_CNT, (start) + 0x8)\ | ||
111 | + REG32(FPGA ## n ## _THR_STA, (start) + 0xc) | ||
112 | +FPGA_CTRL_REGS(0, 0x170) | ||
113 | +FPGA_CTRL_REGS(1, 0x180) | ||
114 | +FPGA_CTRL_REGS(2, 0x190) | ||
115 | +FPGA_CTRL_REGS(3, 0x1a0) | ||
116 | |||
117 | - BANDGAP_TRIP = 0x1b8 / 4, | ||
118 | - PLL_PREDIVISOR = 0x1c0 / 4, | ||
119 | - CLK_621_TRUE, | ||
120 | +REG32(BANDGAP_TRIP, 0x1b8) | ||
121 | +REG32(PLL_PREDIVISOR, 0x1c0) | ||
122 | +REG32(CLK_621_TRUE, 0x1c4) | ||
123 | |||
124 | - PSS_RST_CTRL = 0x200 / 4, | ||
125 | - DDR_RST_CTRL, | ||
126 | - TOPSW_RESET_CTRL, | ||
127 | - DMAC_RST_CTRL, | ||
128 | - USB_RST_CTRL, | ||
129 | - GEM_RST_CTRL, | ||
130 | - SDIO_RST_CTRL, | ||
131 | - SPI_RST_CTRL, | ||
132 | - CAN_RST_CTRL, | ||
133 | - I2C_RST_CTRL, | ||
134 | - UART_RST_CTRL, | ||
135 | - GPIO_RST_CTRL, | ||
136 | - LQSPI_RST_CTRL, | ||
137 | - SMC_RST_CTRL, | ||
138 | - OCM_RST_CTRL, | ||
139 | - FPGA_RST_CTRL = 0x240 / 4, | ||
140 | - A9_CPU_RST_CTRL, | ||
141 | +REG32(PSS_RST_CTRL, 0x200) | ||
142 | + FIELD(PSS_RST_CTRL, SOFT_RST, 0, 1) | ||
143 | +REG32(DDR_RST_CTRL, 0x204) | ||
144 | +REG32(TOPSW_RESET_CTRL, 0x208) | ||
145 | +REG32(DMAC_RST_CTRL, 0x20c) | ||
146 | +REG32(USB_RST_CTRL, 0x210) | ||
147 | +REG32(GEM_RST_CTRL, 0x214) | ||
148 | +REG32(SDIO_RST_CTRL, 0x218) | ||
149 | +REG32(SPI_RST_CTRL, 0x21c) | ||
150 | +REG32(CAN_RST_CTRL, 0x220) | ||
151 | +REG32(I2C_RST_CTRL, 0x224) | ||
152 | +REG32(UART_RST_CTRL, 0x228) | ||
153 | +REG32(GPIO_RST_CTRL, 0x22c) | ||
154 | +REG32(LQSPI_RST_CTRL, 0x230) | ||
155 | +REG32(SMC_RST_CTRL, 0x234) | ||
156 | +REG32(OCM_RST_CTRL, 0x238) | ||
157 | +REG32(FPGA_RST_CTRL, 0x240) | ||
158 | +REG32(A9_CPU_RST_CTRL, 0x244) | ||
159 | |||
160 | - RS_AWDT_CTRL = 0x24c / 4, | ||
161 | - RST_REASON, | ||
162 | +REG32(RS_AWDT_CTRL, 0x24c) | ||
163 | +REG32(RST_REASON, 0x250) | ||
164 | |||
165 | - REBOOT_STATUS = 0x258 / 4, | ||
166 | - BOOT_MODE, | ||
167 | +REG32(REBOOT_STATUS, 0x258) | ||
168 | +REG32(BOOT_MODE, 0x25c) | ||
169 | |||
170 | - APU_CTRL = 0x300 / 4, | ||
171 | - WDT_CLK_SEL, | ||
172 | +REG32(APU_CTRL, 0x300) | ||
173 | +REG32(WDT_CLK_SEL, 0x304) | ||
174 | |||
175 | - TZ_DMA_NS = 0x440 / 4, | ||
176 | - TZ_DMA_IRQ_NS, | ||
177 | - TZ_DMA_PERIPH_NS, | ||
178 | +REG32(TZ_DMA_NS, 0x440) | ||
179 | +REG32(TZ_DMA_IRQ_NS, 0x444) | ||
180 | +REG32(TZ_DMA_PERIPH_NS, 0x448) | ||
181 | |||
182 | - PSS_IDCODE = 0x530 / 4, | ||
183 | +REG32(PSS_IDCODE, 0x530) | ||
184 | |||
185 | - DDR_URGENT = 0x600 / 4, | ||
186 | - DDR_CAL_START = 0x60c / 4, | ||
187 | - DDR_REF_START = 0x614 / 4, | ||
188 | - DDR_CMD_STA, | ||
189 | - DDR_URGENT_SEL, | ||
190 | - DDR_DFI_STATUS, | ||
191 | +REG32(DDR_URGENT, 0x600) | ||
192 | +REG32(DDR_CAL_START, 0x60c) | ||
193 | +REG32(DDR_REF_START, 0x614) | ||
194 | +REG32(DDR_CMD_STA, 0x618) | ||
195 | +REG32(DDR_URGENT_SEL, 0x61c) | ||
196 | +REG32(DDR_DFI_STATUS, 0x620) | ||
197 | |||
198 | - MIO = 0x700 / 4, | ||
199 | +REG32(MIO, 0x700) | ||
200 | #define MIO_LENGTH 54 | ||
201 | |||
202 | - MIO_LOOPBACK = 0x804 / 4, | ||
203 | - MIO_MST_TRI0, | ||
204 | - MIO_MST_TRI1, | ||
205 | +REG32(MIO_LOOPBACK, 0x804) | ||
206 | +REG32(MIO_MST_TRI0, 0x808) | ||
207 | +REG32(MIO_MST_TRI1, 0x80c) | ||
208 | |||
209 | - SD0_WP_CD_SEL = 0x830 / 4, | ||
210 | - SD1_WP_CD_SEL, | ||
211 | +REG32(SD0_WP_CD_SEL, 0x830) | ||
212 | +REG32(SD1_WP_CD_SEL, 0x834) | ||
213 | |||
214 | - LVL_SHFTR_EN = 0x900 / 4, | ||
215 | - OCM_CFG = 0x910 / 4, | ||
216 | +REG32(LVL_SHFTR_EN, 0x900) | ||
217 | +REG32(OCM_CFG, 0x910) | ||
218 | |||
219 | - CPU_RAM = 0xa00 / 4, | ||
220 | +REG32(CPU_RAM, 0xa00) | ||
221 | |||
222 | - IOU = 0xa30 / 4, | ||
223 | +REG32(IOU, 0xa30) | ||
224 | |||
225 | - DMAC_RAM = 0xa50 / 4, | ||
226 | +REG32(DMAC_RAM, 0xa50) | ||
227 | |||
228 | - AFI0 = 0xa60 / 4, | ||
229 | - AFI1 = AFI0 + 3, | ||
230 | - AFI2 = AFI1 + 3, | ||
231 | - AFI3 = AFI2 + 3, | ||
232 | +REG32(AFI0, 0xa60) | ||
233 | +REG32(AFI1, 0xa6c) | ||
234 | +REG32(AFI2, 0xa78) | ||
235 | +REG32(AFI3, 0xa84) | ||
236 | #define AFI_LENGTH 3 | ||
237 | |||
238 | - OCM = 0xa90 / 4, | ||
239 | +REG32(OCM, 0xa90) | ||
240 | |||
241 | - DEVCI_RAM = 0xaa0 / 4, | ||
242 | +REG32(DEVCI_RAM, 0xaa0) | ||
243 | |||
244 | - CSG_RAM = 0xab0 / 4, | ||
245 | +REG32(CSG_RAM, 0xab0) | ||
246 | |||
247 | - GPIOB_CTRL = 0xb00 / 4, | ||
248 | - GPIOB_CFG_CMOS18, | ||
249 | - GPIOB_CFG_CMOS25, | ||
250 | - GPIOB_CFG_CMOS33, | ||
251 | - GPIOB_CFG_HSTL = 0xb14 / 4, | ||
252 | - GPIOB_DRVR_BIAS_CTRL, | ||
253 | +REG32(GPIOB_CTRL, 0xb00) | ||
254 | +REG32(GPIOB_CFG_CMOS18, 0xb04) | ||
255 | +REG32(GPIOB_CFG_CMOS25, 0xb08) | ||
256 | +REG32(GPIOB_CFG_CMOS33, 0xb0c) | ||
257 | +REG32(GPIOB_CFG_HSTL, 0xb14) | ||
258 | +REG32(GPIOB_DRVR_BIAS_CTRL, 0xb18) | ||
259 | |||
260 | - DDRIOB = 0xb40 / 4, | ||
261 | +REG32(DDRIOB, 0xb40) | ||
262 | #define DDRIOB_LENGTH 14 | ||
263 | -}; | ||
264 | |||
265 | #define ZYNQ_SLCR_MMIO_SIZE 0x1000 | ||
266 | #define ZYNQ_SLCR_NUM_REGS (ZYNQ_SLCR_MMIO_SIZE / 4) | ||
267 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_reset(DeviceState *d) | ||
268 | |||
269 | DB_PRINT("RESET\n"); | ||
270 | |||
271 | - s->regs[LOCKSTA] = 1; | ||
272 | + s->regs[R_LOCKSTA] = 1; | ||
273 | /* 0x100 - 0x11C */ | ||
274 | - s->regs[ARM_PLL_CTRL] = 0x0001A008; | ||
275 | - s->regs[DDR_PLL_CTRL] = 0x0001A008; | ||
276 | - s->regs[IO_PLL_CTRL] = 0x0001A008; | ||
277 | - s->regs[PLL_STATUS] = 0x0000003F; | ||
278 | - s->regs[ARM_PLL_CFG] = 0x00014000; | ||
279 | - s->regs[DDR_PLL_CFG] = 0x00014000; | ||
280 | - s->regs[IO_PLL_CFG] = 0x00014000; | ||
281 | + s->regs[R_ARM_PLL_CTRL] = 0x0001A008; | ||
282 | + s->regs[R_DDR_PLL_CTRL] = 0x0001A008; | ||
283 | + s->regs[R_IO_PLL_CTRL] = 0x0001A008; | ||
284 | + s->regs[R_PLL_STATUS] = 0x0000003F; | ||
285 | + s->regs[R_ARM_PLL_CFG] = 0x00014000; | ||
286 | + s->regs[R_DDR_PLL_CFG] = 0x00014000; | ||
287 | + s->regs[R_IO_PLL_CFG] = 0x00014000; | ||
288 | |||
289 | /* 0x120 - 0x16C */ | ||
290 | - s->regs[ARM_CLK_CTRL] = 0x1F000400; | ||
291 | - s->regs[DDR_CLK_CTRL] = 0x18400003; | ||
292 | - s->regs[DCI_CLK_CTRL] = 0x01E03201; | ||
293 | - s->regs[APER_CLK_CTRL] = 0x01FFCCCD; | ||
294 | - s->regs[USB0_CLK_CTRL] = s->regs[USB1_CLK_CTRL] = 0x00101941; | ||
295 | - s->regs[GEM0_RCLK_CTRL] = s->regs[GEM1_RCLK_CTRL] = 0x00000001; | ||
296 | - s->regs[GEM0_CLK_CTRL] = s->regs[GEM1_CLK_CTRL] = 0x00003C01; | ||
297 | - s->regs[SMC_CLK_CTRL] = 0x00003C01; | ||
298 | - s->regs[LQSPI_CLK_CTRL] = 0x00002821; | ||
299 | - s->regs[SDIO_CLK_CTRL] = 0x00001E03; | ||
300 | - s->regs[UART_CLK_CTRL] = 0x00003F03; | ||
301 | - s->regs[SPI_CLK_CTRL] = 0x00003F03; | ||
302 | - s->regs[CAN_CLK_CTRL] = 0x00501903; | ||
303 | - s->regs[DBG_CLK_CTRL] = 0x00000F03; | ||
304 | - s->regs[PCAP_CLK_CTRL] = 0x00000F01; | ||
305 | + s->regs[R_ARM_CLK_CTRL] = 0x1F000400; | ||
306 | + s->regs[R_DDR_CLK_CTRL] = 0x18400003; | ||
307 | + s->regs[R_DCI_CLK_CTRL] = 0x01E03201; | ||
308 | + s->regs[R_APER_CLK_CTRL] = 0x01FFCCCD; | ||
309 | + s->regs[R_USB0_CLK_CTRL] = s->regs[R_USB1_CLK_CTRL] = 0x00101941; | ||
310 | + s->regs[R_GEM0_RCLK_CTRL] = s->regs[R_GEM1_RCLK_CTRL] = 0x00000001; | ||
311 | + s->regs[R_GEM0_CLK_CTRL] = s->regs[R_GEM1_CLK_CTRL] = 0x00003C01; | ||
312 | + s->regs[R_SMC_CLK_CTRL] = 0x00003C01; | ||
313 | + s->regs[R_LQSPI_CLK_CTRL] = 0x00002821; | ||
314 | + s->regs[R_SDIO_CLK_CTRL] = 0x00001E03; | ||
315 | + s->regs[R_UART_CLK_CTRL] = 0x00003F03; | ||
316 | + s->regs[R_SPI_CLK_CTRL] = 0x00003F03; | ||
317 | + s->regs[R_CAN_CLK_CTRL] = 0x00501903; | ||
318 | + s->regs[R_DBG_CLK_CTRL] = 0x00000F03; | ||
319 | + s->regs[R_PCAP_CLK_CTRL] = 0x00000F01; | ||
320 | |||
321 | /* 0x170 - 0x1AC */ | ||
322 | - s->regs[FPGA0_CLK_CTRL] = s->regs[FPGA1_CLK_CTRL] = s->regs[FPGA2_CLK_CTRL] | ||
323 | - = s->regs[FPGA3_CLK_CTRL] = 0x00101800; | ||
324 | - s->regs[FPGA0_THR_STA] = s->regs[FPGA1_THR_STA] = s->regs[FPGA2_THR_STA] | ||
325 | - = s->regs[FPGA3_THR_STA] = 0x00010000; | ||
326 | + s->regs[R_FPGA0_CLK_CTRL] = s->regs[R_FPGA1_CLK_CTRL] | ||
327 | + = s->regs[R_FPGA2_CLK_CTRL] | ||
328 | + = s->regs[R_FPGA3_CLK_CTRL] = 0x00101800; | ||
329 | + s->regs[R_FPGA0_THR_STA] = s->regs[R_FPGA1_THR_STA] | ||
330 | + = s->regs[R_FPGA2_THR_STA] | ||
331 | + = s->regs[R_FPGA3_THR_STA] = 0x00010000; | ||
332 | |||
333 | /* 0x1B0 - 0x1D8 */ | ||
334 | - s->regs[BANDGAP_TRIP] = 0x0000001F; | ||
335 | - s->regs[PLL_PREDIVISOR] = 0x00000001; | ||
336 | - s->regs[CLK_621_TRUE] = 0x00000001; | ||
337 | + s->regs[R_BANDGAP_TRIP] = 0x0000001F; | ||
338 | + s->regs[R_PLL_PREDIVISOR] = 0x00000001; | ||
339 | + s->regs[R_CLK_621_TRUE] = 0x00000001; | ||
340 | |||
341 | /* 0x200 - 0x25C */ | ||
342 | - s->regs[FPGA_RST_CTRL] = 0x01F33F0F; | ||
343 | - s->regs[RST_REASON] = 0x00000040; | ||
344 | + s->regs[R_FPGA_RST_CTRL] = 0x01F33F0F; | ||
345 | + s->regs[R_RST_REASON] = 0x00000040; | ||
346 | |||
347 | - s->regs[BOOT_MODE] = 0x00000001; | ||
348 | + s->regs[R_BOOT_MODE] = 0x00000001; | ||
349 | |||
350 | /* 0x700 - 0x7D4 */ | ||
351 | for (i = 0; i < 54; i++) { | ||
352 | - s->regs[MIO + i] = 0x00001601; | ||
353 | + s->regs[R_MIO + i] = 0x00001601; | ||
354 | } | ||
355 | for (i = 2; i <= 8; i++) { | ||
356 | - s->regs[MIO + i] = 0x00000601; | ||
357 | + s->regs[R_MIO + i] = 0x00000601; | ||
358 | } | ||
359 | |||
360 | - s->regs[MIO_MST_TRI0] = s->regs[MIO_MST_TRI1] = 0xFFFFFFFF; | ||
361 | + s->regs[R_MIO_MST_TRI0] = s->regs[R_MIO_MST_TRI1] = 0xFFFFFFFF; | ||
362 | |||
363 | - s->regs[CPU_RAM + 0] = s->regs[CPU_RAM + 1] = s->regs[CPU_RAM + 3] | ||
364 | - = s->regs[CPU_RAM + 4] = s->regs[CPU_RAM + 7] | ||
365 | - = 0x00010101; | ||
366 | - s->regs[CPU_RAM + 2] = s->regs[CPU_RAM + 5] = 0x01010101; | ||
367 | - s->regs[CPU_RAM + 6] = 0x00000001; | ||
368 | + s->regs[R_CPU_RAM + 0] = s->regs[R_CPU_RAM + 1] = s->regs[R_CPU_RAM + 3] | ||
369 | + = s->regs[R_CPU_RAM + 4] = s->regs[R_CPU_RAM + 7] | ||
370 | + = 0x00010101; | ||
371 | + s->regs[R_CPU_RAM + 2] = s->regs[R_CPU_RAM + 5] = 0x01010101; | ||
372 | + s->regs[R_CPU_RAM + 6] = 0x00000001; | ||
373 | |||
374 | - s->regs[IOU + 0] = s->regs[IOU + 1] = s->regs[IOU + 2] = s->regs[IOU + 3] | ||
375 | - = 0x09090909; | ||
376 | - s->regs[IOU + 4] = s->regs[IOU + 5] = 0x00090909; | ||
377 | - s->regs[IOU + 6] = 0x00000909; | ||
378 | + s->regs[R_IOU + 0] = s->regs[R_IOU + 1] = s->regs[R_IOU + 2] | ||
379 | + = s->regs[R_IOU + 3] = 0x09090909; | ||
380 | + s->regs[R_IOU + 4] = s->regs[R_IOU + 5] = 0x00090909; | ||
381 | + s->regs[R_IOU + 6] = 0x00000909; | ||
382 | |||
383 | - s->regs[DMAC_RAM] = 0x00000009; | ||
384 | + s->regs[R_DMAC_RAM] = 0x00000009; | ||
385 | |||
386 | - s->regs[AFI0 + 0] = s->regs[AFI0 + 1] = 0x09090909; | ||
387 | - s->regs[AFI1 + 0] = s->regs[AFI1 + 1] = 0x09090909; | ||
388 | - s->regs[AFI2 + 0] = s->regs[AFI2 + 1] = 0x09090909; | ||
389 | - s->regs[AFI3 + 0] = s->regs[AFI3 + 1] = 0x09090909; | ||
390 | - s->regs[AFI0 + 2] = s->regs[AFI1 + 2] = s->regs[AFI2 + 2] | ||
391 | - = s->regs[AFI3 + 2] = 0x00000909; | ||
392 | + s->regs[R_AFI0 + 0] = s->regs[R_AFI0 + 1] = 0x09090909; | ||
393 | + s->regs[R_AFI1 + 0] = s->regs[R_AFI1 + 1] = 0x09090909; | ||
394 | + s->regs[R_AFI2 + 0] = s->regs[R_AFI2 + 1] = 0x09090909; | ||
395 | + s->regs[R_AFI3 + 0] = s->regs[R_AFI3 + 1] = 0x09090909; | ||
396 | + s->regs[R_AFI0 + 2] = s->regs[R_AFI1 + 2] = s->regs[R_AFI2 + 2] | ||
397 | + = s->regs[R_AFI3 + 2] = 0x00000909; | ||
398 | |||
399 | - s->regs[OCM + 0] = 0x01010101; | ||
400 | - s->regs[OCM + 1] = s->regs[OCM + 2] = 0x09090909; | ||
401 | + s->regs[R_OCM + 0] = 0x01010101; | ||
402 | + s->regs[R_OCM + 1] = s->regs[R_OCM + 2] = 0x09090909; | ||
403 | |||
404 | - s->regs[DEVCI_RAM] = 0x00000909; | ||
405 | - s->regs[CSG_RAM] = 0x00000001; | ||
406 | + s->regs[R_DEVCI_RAM] = 0x00000909; | ||
407 | + s->regs[R_CSG_RAM] = 0x00000001; | ||
408 | |||
409 | - s->regs[DDRIOB + 0] = s->regs[DDRIOB + 1] = s->regs[DDRIOB + 2] | ||
410 | - = s->regs[DDRIOB + 3] = 0x00000e00; | ||
411 | - s->regs[DDRIOB + 4] = s->regs[DDRIOB + 5] = s->regs[DDRIOB + 6] | ||
412 | - = 0x00000e00; | ||
413 | - s->regs[DDRIOB + 12] = 0x00000021; | ||
414 | + s->regs[R_DDRIOB + 0] = s->regs[R_DDRIOB + 1] = s->regs[R_DDRIOB + 2] | ||
415 | + = s->regs[R_DDRIOB + 3] = 0x00000e00; | ||
416 | + s->regs[R_DDRIOB + 4] = s->regs[R_DDRIOB + 5] = s->regs[R_DDRIOB + 6] | ||
417 | + = 0x00000e00; | ||
418 | + s->regs[R_DDRIOB + 12] = 0x00000021; | ||
419 | } | ||
420 | |||
421 | |||
422 | static bool zynq_slcr_check_offset(hwaddr offset, bool rnw) | ||
423 | { | ||
424 | switch (offset) { | ||
425 | - case LOCK: | ||
426 | - case UNLOCK: | ||
427 | - case DDR_CAL_START: | ||
428 | - case DDR_REF_START: | ||
429 | + case R_LOCK: | ||
430 | + case R_UNLOCK: | ||
431 | + case R_DDR_CAL_START: | ||
432 | + case R_DDR_REF_START: | ||
433 | return !rnw; /* Write only */ | ||
434 | - case LOCKSTA: | ||
435 | - case FPGA0_THR_STA: | ||
436 | - case FPGA1_THR_STA: | ||
437 | - case FPGA2_THR_STA: | ||
438 | - case FPGA3_THR_STA: | ||
439 | - case BOOT_MODE: | ||
440 | - case PSS_IDCODE: | ||
441 | - case DDR_CMD_STA: | ||
442 | - case DDR_DFI_STATUS: | ||
443 | - case PLL_STATUS: | ||
444 | + case R_LOCKSTA: | ||
445 | + case R_FPGA0_THR_STA: | ||
446 | + case R_FPGA1_THR_STA: | ||
447 | + case R_FPGA2_THR_STA: | ||
448 | + case R_FPGA3_THR_STA: | ||
449 | + case R_BOOT_MODE: | ||
450 | + case R_PSS_IDCODE: | ||
451 | + case R_DDR_CMD_STA: | ||
452 | + case R_DDR_DFI_STATUS: | ||
453 | + case R_PLL_STATUS: | ||
454 | return rnw;/* read only */ | ||
455 | - case SCL: | ||
456 | - case ARM_PLL_CTRL ... IO_PLL_CTRL: | ||
457 | - case ARM_PLL_CFG ... IO_PLL_CFG: | ||
458 | - case ARM_CLK_CTRL ... TOPSW_CLK_CTRL: | ||
459 | - case FPGA0_CLK_CTRL ... FPGA0_THR_CNT: | ||
460 | - case FPGA1_CLK_CTRL ... FPGA1_THR_CNT: | ||
461 | - case FPGA2_CLK_CTRL ... FPGA2_THR_CNT: | ||
462 | - case FPGA3_CLK_CTRL ... FPGA3_THR_CNT: | ||
463 | - case BANDGAP_TRIP: | ||
464 | - case PLL_PREDIVISOR: | ||
465 | - case CLK_621_TRUE: | ||
466 | - case PSS_RST_CTRL ... A9_CPU_RST_CTRL: | ||
467 | - case RS_AWDT_CTRL: | ||
468 | - case RST_REASON: | ||
469 | - case REBOOT_STATUS: | ||
470 | - case APU_CTRL: | ||
471 | - case WDT_CLK_SEL: | ||
472 | - case TZ_DMA_NS ... TZ_DMA_PERIPH_NS: | ||
473 | - case DDR_URGENT: | ||
474 | - case DDR_URGENT_SEL: | ||
475 | - case MIO ... MIO + MIO_LENGTH - 1: | ||
476 | - case MIO_LOOPBACK ... MIO_MST_TRI1: | ||
477 | - case SD0_WP_CD_SEL: | ||
478 | - case SD1_WP_CD_SEL: | ||
479 | - case LVL_SHFTR_EN: | ||
480 | - case OCM_CFG: | ||
481 | - case CPU_RAM: | ||
482 | - case IOU: | ||
483 | - case DMAC_RAM: | ||
484 | - case AFI0 ... AFI3 + AFI_LENGTH - 1: | ||
485 | - case OCM: | ||
486 | - case DEVCI_RAM: | ||
487 | - case CSG_RAM: | ||
488 | - case GPIOB_CTRL ... GPIOB_CFG_CMOS33: | ||
489 | - case GPIOB_CFG_HSTL: | ||
490 | - case GPIOB_DRVR_BIAS_CTRL: | ||
491 | - case DDRIOB ... DDRIOB + DDRIOB_LENGTH - 1: | ||
492 | + case R_SCL: | ||
493 | + case R_ARM_PLL_CTRL ... R_IO_PLL_CTRL: | ||
494 | + case R_ARM_PLL_CFG ... R_IO_PLL_CFG: | ||
495 | + case R_ARM_CLK_CTRL ... R_TOPSW_CLK_CTRL: | ||
496 | + case R_FPGA0_CLK_CTRL ... R_FPGA0_THR_CNT: | ||
497 | + case R_FPGA1_CLK_CTRL ... R_FPGA1_THR_CNT: | ||
498 | + case R_FPGA2_CLK_CTRL ... R_FPGA2_THR_CNT: | ||
499 | + case R_FPGA3_CLK_CTRL ... R_FPGA3_THR_CNT: | ||
500 | + case R_BANDGAP_TRIP: | ||
501 | + case R_PLL_PREDIVISOR: | ||
502 | + case R_CLK_621_TRUE: | ||
503 | + case R_PSS_RST_CTRL ... R_A9_CPU_RST_CTRL: | ||
504 | + case R_RS_AWDT_CTRL: | ||
505 | + case R_RST_REASON: | ||
506 | + case R_REBOOT_STATUS: | ||
507 | + case R_APU_CTRL: | ||
508 | + case R_WDT_CLK_SEL: | ||
509 | + case R_TZ_DMA_NS ... R_TZ_DMA_PERIPH_NS: | ||
510 | + case R_DDR_URGENT: | ||
511 | + case R_DDR_URGENT_SEL: | ||
512 | + case R_MIO ... R_MIO + MIO_LENGTH - 1: | ||
513 | + case R_MIO_LOOPBACK ... R_MIO_MST_TRI1: | ||
514 | + case R_SD0_WP_CD_SEL: | ||
515 | + case R_SD1_WP_CD_SEL: | ||
516 | + case R_LVL_SHFTR_EN: | ||
517 | + case R_OCM_CFG: | ||
518 | + case R_CPU_RAM: | ||
519 | + case R_IOU: | ||
520 | + case R_DMAC_RAM: | ||
521 | + case R_AFI0 ... R_AFI3 + AFI_LENGTH - 1: | ||
522 | + case R_OCM: | ||
523 | + case R_DEVCI_RAM: | ||
524 | + case R_CSG_RAM: | ||
525 | + case R_GPIOB_CTRL ... R_GPIOB_CFG_CMOS33: | ||
526 | + case R_GPIOB_CFG_HSTL: | ||
527 | + case R_GPIOB_DRVR_BIAS_CTRL: | ||
528 | + case R_DDRIOB ... R_DDRIOB + DDRIOB_LENGTH - 1: | ||
529 | return true; | ||
530 | default: | ||
531 | return false; | ||
532 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_write(void *opaque, hwaddr offset, | ||
533 | } | ||
534 | |||
535 | switch (offset) { | ||
536 | - case SCL: | ||
537 | - s->regs[SCL] = val & 0x1; | ||
538 | + case R_SCL: | ||
539 | + s->regs[R_SCL] = val & 0x1; | ||
540 | return; | ||
541 | - case LOCK: | ||
542 | + case R_LOCK: | ||
543 | if ((val & 0xFFFF) == XILINX_LOCK_KEY) { | ||
544 | DB_PRINT("XILINX LOCK 0xF8000000 + 0x%x <= 0x%x\n", (int)offset, | ||
545 | (unsigned)val & 0xFFFF); | ||
546 | - s->regs[LOCKSTA] = 1; | ||
547 | + s->regs[R_LOCKSTA] = 1; | ||
548 | } else { | ||
549 | DB_PRINT("WRONG XILINX LOCK KEY 0xF8000000 + 0x%x <= 0x%x\n", | ||
550 | (int)offset, (unsigned)val & 0xFFFF); | ||
551 | } | ||
552 | return; | ||
553 | - case UNLOCK: | ||
554 | + case R_UNLOCK: | ||
555 | if ((val & 0xFFFF) == XILINX_UNLOCK_KEY) { | ||
556 | DB_PRINT("XILINX UNLOCK 0xF8000000 + 0x%x <= 0x%x\n", (int)offset, | ||
557 | (unsigned)val & 0xFFFF); | ||
558 | - s->regs[LOCKSTA] = 0; | ||
559 | + s->regs[R_LOCKSTA] = 0; | ||
560 | } else { | ||
561 | DB_PRINT("WRONG XILINX UNLOCK KEY 0xF8000000 + 0x%x <= 0x%x\n", | ||
562 | (int)offset, (unsigned)val & 0xFFFF); | ||
563 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_write(void *opaque, hwaddr offset, | ||
564 | return; | ||
565 | } | ||
566 | |||
567 | - if (s->regs[LOCKSTA]) { | ||
568 | + if (s->regs[R_LOCKSTA]) { | ||
569 | qemu_log_mask(LOG_GUEST_ERROR, | ||
570 | "SCLR registers are locked. Unlock them first\n"); | ||
571 | return; | ||
572 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_write(void *opaque, hwaddr offset, | ||
573 | s->regs[offset] = val; | ||
574 | |||
575 | switch (offset) { | ||
576 | - case PSS_RST_CTRL: | ||
577 | - if (val & R_PSS_RST_CTRL_SOFT_RST) { | ||
578 | + case R_PSS_RST_CTRL: | ||
579 | + if (FIELD_EX32(val, PSS_RST_CTRL, SOFT_RST)) { | ||
580 | qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
581 | } | ||
582 | break; | ||
583 | -- | ||
584 | 2.20.1 | ||
585 | |||
586 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Aaron Hill <aa1ronham@gmail.com> | ||
2 | 1 | ||
3 | This commit properly sets the ENET_BD_BDU flag once the emulated FEC controller | ||
4 | has finished processing the last descriptor. This is done for both transmit | ||
5 | and receive descriptors. | ||
6 | |||
7 | This allows the QNX 7.0.0 BSP for the Sabrelite board (which can be | ||
8 | found at http://blackberry.qnx.com/en/developers/bsp) to properly | ||
9 | control the FEC. Without this patch, the BSP ethernet driver will never | ||
10 | re-use FEC descriptors, as the unset ENET_BD_BDU flag will cause | ||
11 | it to believe that the descriptors are still in use by the NIC. | ||
12 | |||
13 | Note that Linux does not appear to use this field at all, and is | ||
14 | unaffected by this patch. | ||
15 | |||
16 | Without this patch, QNX will think that the NIC is still processing its | ||
17 | transaction descriptors, and won't send any more data over the network. | ||
18 | |||
19 | For reference: | ||
20 | |||
21 | On page 1192 of the I.MX 6DQ reference manual revision (Rev. 5, 06/2018), | ||
22 | which can be found at https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/i.mx-applications-processors/i.mx-6-processors/i.mx-6quad-processors-high-performance-3d-graphics-hd-video-arm-cortex-a9-core:i.MX6Q?&tab=Documentation_Tab&linkline=Application-Note | ||
23 | |||
24 | the 'BDU' field is described as follows for the 'Enhanced transmit | ||
25 | buffer descriptor': | ||
26 | |||
27 | 'Last buffer descriptor update done. Indicates that the last BD data has been updated by | ||
28 | uDMA. This field is written by the user (=0) and uDMA (=1).' | ||
29 | |||
30 | The same description is used for the receive buffer descriptor. | ||
31 | |||
32 | Signed-off-by: Aaron Hill <aa1ronham@gmail.com> | ||
33 | Message-id: 20190805142417.10433-1-aaron.hill@alertinnovation.com | ||
34 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
35 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
36 | --- | ||
37 | hw/net/imx_fec.c | 4 ++++ | ||
38 | 1 file changed, 4 insertions(+) | ||
39 | |||
40 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/net/imx_fec.c | ||
43 | +++ b/hw/net/imx_fec.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t index) | ||
45 | if (bd.option & ENET_BD_TX_INT) { | ||
46 | s->regs[ENET_EIR] |= int_txf; | ||
47 | } | ||
48 | + /* Indicate that we've updated the last buffer descriptor. */ | ||
49 | + bd.last_buffer = ENET_BD_BDU; | ||
50 | } | ||
51 | if (bd.option & ENET_BD_TX_INT) { | ||
52 | s->regs[ENET_EIR] |= int_txb; | ||
53 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | ||
54 | /* Last buffer in frame. */ | ||
55 | bd.flags |= flags | ENET_BD_L; | ||
56 | FEC_PRINTF("rx frame flags %04x\n", bd.flags); | ||
57 | + /* Indicate that we've updated the last buffer descriptor. */ | ||
58 | + bd.last_buffer = ENET_BD_BDU; | ||
59 | if (bd.option & ENET_BD_RX_INT) { | ||
60 | s->regs[ENET_EIR] |= ENET_INT_RXF; | ||
61 | } | ||
62 | -- | ||
63 | 2.20.1 | ||
64 | |||
65 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Patrick Venture <venture@google.com> |
---|---|---|---|
2 | 2 | ||
3 | The current implementation of ZCR_ELx matches the architecture, only | 3 | Adds a line-item reference to the supported quanta-q71l-bmc aspeed |
4 | implementing the lower four bits, with the rest RAZ/WI. This puts | 4 | entry. |
5 | a strict limit on ARM_MAX_VQ of 16. Make sure we don't let ARM_MAX_VQ | ||
6 | grow without a corresponding update here. | ||
7 | 5 | ||
8 | Suggested-by: Dave Martin <Dave.Martin@arm.com> | 6 | Signed-off-by: Patrick Venture <venture@google.com> |
9 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20210615192848.1065297-2-venture@google.com |
11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | target/arm/helper.c | 1 + | 11 | docs/system/arm/aspeed.rst | 1 + |
15 | 1 file changed, 1 insertion(+) | 12 | 1 file changed, 1 insertion(+) |
16 | 13 | ||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.c | 16 | --- a/docs/system/arm/aspeed.rst |
20 | +++ b/target/arm/helper.c | 17 | +++ b/docs/system/arm/aspeed.rst |
21 | @@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 18 | @@ -XXX,XX +XXX,XX @@ etc. |
22 | int new_len; | 19 | AST2400 SoC based machines : |
23 | 20 | ||
24 | /* Bits other than [3:0] are RAZ/WI. */ | 21 | - ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC |
25 | + QEMU_BUILD_BUG_ON(ARM_MAX_VQ > 16); | 22 | +- ``quanta-q71l-bmc`` OpenBMC Quanta BMC |
26 | raw_write(env, ri, value & 0xf); | 23 | |
27 | 24 | AST2500 SoC based machines : | |
28 | /* | 25 | |
29 | -- | 26 | -- |
30 | 2.20.1 | 27 | 2.20.1 |
31 | 28 | ||
32 | 29 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Patrick Venture <venture@google.com> |
---|---|---|---|
2 | 2 | ||
3 | All of the inputs to these instructions are 32-bits. Rather than | 3 | Add line item reference to quanta-gbs-bmc machine. |
4 | extend each input to 64-bits and then extract the high 32-bits of | ||
5 | the output, use tcg_gen_muls2_i32 and other 32-bit generator functions. | ||
6 | 4 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Patrick Venture <venture@google.com> |
8 | Message-id: 20190808202616.13782-7-richard.henderson@linaro.org | 6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Message-id: 20210615192848.1065297-3-venture@google.com |
8 | [PMM: fixed underline Sphinx warning] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/translate.c | 72 +++++++++++++++--------------------------- | 11 | docs/system/arm/nuvoton.rst | 5 +++-- |
13 | 1 file changed, 26 insertions(+), 46 deletions(-) | 12 | 1 file changed, 3 insertions(+), 2 deletions(-) |
14 | 13 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 16 | --- a/docs/system/arm/nuvoton.rst |
18 | +++ b/target/arm/translate.c | 17 | +++ b/docs/system/arm/nuvoton.rst |
19 | @@ -XXX,XX +XXX,XX @@ static void gen_revsh(TCGv_i32 var) | 18 | @@ -XXX,XX +XXX,XX @@ |
20 | tcg_gen_ext16s_i32(var, var); | 19 | -Nuvoton iBMC boards (``npcm750-evb``, ``quanta-gsj``) |
21 | } | 20 | -===================================================== |
22 | 21 | +Nuvoton iBMC boards (``*-bmc``, ``npcm750-evb``, ``quanta-gsj``) | |
23 | -/* Return (b << 32) + a. Mark inputs as dead */ | 22 | +================================================================ |
24 | -static TCGv_i64 gen_addq_msw(TCGv_i64 a, TCGv_i32 b) | 23 | |
25 | -{ | 24 | The `Nuvoton iBMC`_ chips (NPCM7xx) are a family of ARM-based SoCs that are |
26 | - TCGv_i64 tmp64 = tcg_temp_new_i64(); | 25 | designed to be used as Baseboard Management Controllers (BMCs) in various |
27 | - | 26 | @@ -XXX,XX +XXX,XX @@ segment. The following machines are based on this chip : |
28 | - tcg_gen_extu_i32_i64(tmp64, b); | 27 | The NPCM730 SoC has two Cortex-A9 cores and is targeted for Data Center and |
29 | - tcg_temp_free_i32(b); | 28 | Hyperscale applications. The following machines are based on this chip : |
30 | - tcg_gen_shli_i64(tmp64, tmp64, 32); | 29 | |
31 | - tcg_gen_add_i64(a, tmp64, a); | 30 | +- ``quanta-gbs-bmc`` Quanta GBS server BMC |
32 | - | 31 | - ``quanta-gsj`` Quanta GSJ server BMC |
33 | - tcg_temp_free_i64(tmp64); | 32 | |
34 | - return a; | 33 | There are also two more SoCs, NPCM710 and NPCM705, which are single-core |
35 | -} | ||
36 | - | ||
37 | -/* Return (b << 32) - a. Mark inputs as dead. */ | ||
38 | -static TCGv_i64 gen_subq_msw(TCGv_i64 a, TCGv_i32 b) | ||
39 | -{ | ||
40 | - TCGv_i64 tmp64 = tcg_temp_new_i64(); | ||
41 | - | ||
42 | - tcg_gen_extu_i32_i64(tmp64, b); | ||
43 | - tcg_temp_free_i32(b); | ||
44 | - tcg_gen_shli_i64(tmp64, tmp64, 32); | ||
45 | - tcg_gen_sub_i64(a, tmp64, a); | ||
46 | - | ||
47 | - tcg_temp_free_i64(tmp64); | ||
48 | - return a; | ||
49 | -} | ||
50 | - | ||
51 | /* 32x32->64 multiply. Marks inputs as dead. */ | ||
52 | static TCGv_i64 gen_mulu_i64_i32(TCGv_i32 a, TCGv_i32 b) | ||
53 | { | ||
54 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
55 | (SMMUL, SMMLA, SMMLS) */ | ||
56 | tmp = load_reg(s, rm); | ||
57 | tmp2 = load_reg(s, rs); | ||
58 | - tmp64 = gen_muls_i64_i32(tmp, tmp2); | ||
59 | + tcg_gen_muls2_i32(tmp2, tmp, tmp, tmp2); | ||
60 | |||
61 | if (rd != 15) { | ||
62 | - tmp = load_reg(s, rd); | ||
63 | + tmp3 = load_reg(s, rd); | ||
64 | if (insn & (1 << 6)) { | ||
65 | - tmp64 = gen_subq_msw(tmp64, tmp); | ||
66 | + tcg_gen_sub_i32(tmp, tmp, tmp3); | ||
67 | } else { | ||
68 | - tmp64 = gen_addq_msw(tmp64, tmp); | ||
69 | + tcg_gen_add_i32(tmp, tmp, tmp3); | ||
70 | } | ||
71 | + tcg_temp_free_i32(tmp3); | ||
72 | } | ||
73 | if (insn & (1 << 5)) { | ||
74 | - tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); | ||
75 | + /* | ||
76 | + * Adding 0x80000000 to the 64-bit quantity | ||
77 | + * means that we have carry in to the high | ||
78 | + * word when the low word has the high bit set. | ||
79 | + */ | ||
80 | + tcg_gen_shri_i32(tmp2, tmp2, 31); | ||
81 | + tcg_gen_add_i32(tmp, tmp, tmp2); | ||
82 | } | ||
83 | - tcg_gen_shri_i64(tmp64, tmp64, 32); | ||
84 | - tmp = tcg_temp_new_i32(); | ||
85 | - tcg_gen_extrl_i64_i32(tmp, tmp64); | ||
86 | - tcg_temp_free_i64(tmp64); | ||
87 | + tcg_temp_free_i32(tmp2); | ||
88 | store_reg(s, rn, tmp); | ||
89 | break; | ||
90 | case 0: | ||
91 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
92 | } | ||
93 | break; | ||
94 | case 5: case 6: /* 32 * 32 -> 32msb (SMMUL, SMMLA, SMMLS) */ | ||
95 | - tmp64 = gen_muls_i64_i32(tmp, tmp2); | ||
96 | + tcg_gen_muls2_i32(tmp2, tmp, tmp, tmp2); | ||
97 | if (rs != 15) { | ||
98 | - tmp = load_reg(s, rs); | ||
99 | + tmp3 = load_reg(s, rs); | ||
100 | if (insn & (1 << 20)) { | ||
101 | - tmp64 = gen_addq_msw(tmp64, tmp); | ||
102 | + tcg_gen_add_i32(tmp, tmp, tmp3); | ||
103 | } else { | ||
104 | - tmp64 = gen_subq_msw(tmp64, tmp); | ||
105 | + tcg_gen_sub_i32(tmp, tmp, tmp3); | ||
106 | } | ||
107 | + tcg_temp_free_i32(tmp3); | ||
108 | } | ||
109 | if (insn & (1 << 4)) { | ||
110 | - tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); | ||
111 | + /* | ||
112 | + * Adding 0x80000000 to the 64-bit quantity | ||
113 | + * means that we have carry in to the high | ||
114 | + * word when the low word has the high bit set. | ||
115 | + */ | ||
116 | + tcg_gen_shri_i32(tmp2, tmp2, 31); | ||
117 | + tcg_gen_add_i32(tmp, tmp, tmp2); | ||
118 | } | ||
119 | - tcg_gen_shri_i64(tmp64, tmp64, 32); | ||
120 | - tmp = tcg_temp_new_i32(); | ||
121 | - tcg_gen_extrl_i64_i32(tmp, tmp64); | ||
122 | - tcg_temp_free_i64(tmp64); | ||
123 | + tcg_temp_free_i32(tmp2); | ||
124 | break; | ||
125 | case 7: /* Unsigned sum of absolute differences. */ | ||
126 | gen_helper_usad8(tmp, tmp, tmp2); | ||
127 | -- | 34 | -- |
128 | 2.20.1 | 35 | 2.20.1 |
129 | 36 | ||
130 | 37 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Nolan Leake <nolan@sigbus.net> |
---|---|---|---|
2 | 2 | ||
3 | Rotate is the more compact and obvious way to swap 16-bit | 3 | This is just enough to make reboot and poweroff work. Works for |
4 | elements of a 32-bit word. | 4 | linux, u-boot, and the arm trusted firmware. Not tested, but should |
5 | 5 | work for plan9, and bare-metal/hobby OSes, since they seem to generally | |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | do what linux does for reset. |
7 | Message-id: 20190808202616.13782-6-richard.henderson@linaro.org | 7 | |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | The watchdog timer functionality is not yet implemented. |
9 | |||
10 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/64 | ||
11 | Signed-off-by: Nolan Leake <nolan@sigbus.net> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Message-id: 20210625210209.1870217-1-nolan@sigbus.net | ||
15 | [PMM: tweaked commit title; fixed region size to 0x200; | ||
16 | moved header file to include/] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 18 | --- |
11 | target/arm/translate.c | 6 +----- | 19 | include/hw/arm/bcm2835_peripherals.h | 3 +- |
12 | 1 file changed, 1 insertion(+), 5 deletions(-) | 20 | include/hw/misc/bcm2835_powermgt.h | 29 +++++ |
13 | 21 | hw/arm/bcm2835_peripherals.c | 13 ++- | |
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 22 | hw/misc/bcm2835_powermgt.c | 160 +++++++++++++++++++++++++++ |
23 | hw/misc/meson.build | 1 + | ||
24 | 5 files changed, 204 insertions(+), 2 deletions(-) | ||
25 | create mode 100644 include/hw/misc/bcm2835_powermgt.h | ||
26 | create mode 100644 hw/misc/bcm2835_powermgt.c | ||
27 | |||
28 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 30 | --- a/include/hw/arm/bcm2835_peripherals.h |
17 | +++ b/target/arm/translate.c | 31 | +++ b/include/hw/arm/bcm2835_peripherals.h |
18 | @@ -XXX,XX +XXX,XX @@ static TCGv_i64 gen_muls_i64_i32(TCGv_i32 a, TCGv_i32 b) | 32 | @@ -XXX,XX +XXX,XX @@ |
19 | /* Swap low and high halfwords. */ | 33 | #include "hw/misc/bcm2835_mphi.h" |
20 | static void gen_swap_half(TCGv_i32 var) | 34 | #include "hw/misc/bcm2835_thermal.h" |
21 | { | 35 | #include "hw/misc/bcm2835_cprman.h" |
22 | - TCGv_i32 tmp = tcg_temp_new_i32(); | 36 | +#include "hw/misc/bcm2835_powermgt.h" |
23 | - tcg_gen_shri_i32(tmp, var, 16); | 37 | #include "hw/sd/sdhci.h" |
24 | - tcg_gen_shli_i32(var, var, 16); | 38 | #include "hw/sd/bcm2835_sdhost.h" |
25 | - tcg_gen_or_i32(var, var, tmp); | 39 | #include "hw/gpio/bcm2835_gpio.h" |
26 | - tcg_temp_free_i32(tmp); | 40 | @@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState { |
27 | + tcg_gen_rotri_i32(var, var, 16); | 41 | BCM2835MphiState mphi; |
42 | UnimplementedDeviceState txp; | ||
43 | UnimplementedDeviceState armtmr; | ||
44 | - UnimplementedDeviceState powermgt; | ||
45 | + BCM2835PowerMgtState powermgt; | ||
46 | BCM2835CprmanState cprman; | ||
47 | PL011State uart0; | ||
48 | BCM2835AuxState aux; | ||
49 | diff --git a/include/hw/misc/bcm2835_powermgt.h b/include/hw/misc/bcm2835_powermgt.h | ||
50 | new file mode 100644 | ||
51 | index XXXXXXX..XXXXXXX | ||
52 | --- /dev/null | ||
53 | +++ b/include/hw/misc/bcm2835_powermgt.h | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | +/* | ||
56 | + * BCM2835 Power Management emulation | ||
57 | + * | ||
58 | + * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com> | ||
59 | + * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net> | ||
60 | + * | ||
61 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
62 | + * See the COPYING file in the top-level directory. | ||
63 | + */ | ||
64 | + | ||
65 | +#ifndef BCM2835_POWERMGT_H | ||
66 | +#define BCM2835_POWERMGT_H | ||
67 | + | ||
68 | +#include "hw/sysbus.h" | ||
69 | +#include "qom/object.h" | ||
70 | + | ||
71 | +#define TYPE_BCM2835_POWERMGT "bcm2835-powermgt" | ||
72 | +OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PowerMgtState, BCM2835_POWERMGT) | ||
73 | + | ||
74 | +struct BCM2835PowerMgtState { | ||
75 | + SysBusDevice busdev; | ||
76 | + MemoryRegion iomem; | ||
77 | + | ||
78 | + uint32_t rstc; | ||
79 | + uint32_t rsts; | ||
80 | + uint32_t wdog; | ||
81 | +}; | ||
82 | + | ||
83 | +#endif | ||
84 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/hw/arm/bcm2835_peripherals.c | ||
87 | +++ b/hw/arm/bcm2835_peripherals.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | ||
89 | |||
90 | object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr", | ||
91 | OBJECT(&s->gpu_bus_mr)); | ||
92 | + | ||
93 | + /* Power Management */ | ||
94 | + object_initialize_child(obj, "powermgt", &s->powermgt, | ||
95 | + TYPE_BCM2835_POWERMGT); | ||
28 | } | 96 | } |
29 | 97 | ||
30 | /* Dual 16-bit add. Result placed in t0 and t1 is marked as dead. | 98 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) |
99 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
100 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | ||
101 | INTERRUPT_USB)); | ||
102 | |||
103 | + /* Power Management */ | ||
104 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->powermgt), errp)) { | ||
105 | + return; | ||
106 | + } | ||
107 | + | ||
108 | + memory_region_add_subregion(&s->peri_mr, PM_OFFSET, | ||
109 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->powermgt), 0)); | ||
110 | + | ||
111 | create_unimp(s, &s->txp, "bcm2835-txp", TXP_OFFSET, 0x1000); | ||
112 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | ||
113 | - create_unimp(s, &s->powermgt, "bcm2835-powermgt", PM_OFFSET, 0x114); | ||
114 | create_unimp(s, &s->i2s, "bcm2835-i2s", I2S_OFFSET, 0x100); | ||
115 | create_unimp(s, &s->smi, "bcm2835-smi", SMI_OFFSET, 0x100); | ||
116 | create_unimp(s, &s->spi[0], "bcm2835-spi0", SPI0_OFFSET, 0x20); | ||
117 | diff --git a/hw/misc/bcm2835_powermgt.c b/hw/misc/bcm2835_powermgt.c | ||
118 | new file mode 100644 | ||
119 | index XXXXXXX..XXXXXXX | ||
120 | --- /dev/null | ||
121 | +++ b/hw/misc/bcm2835_powermgt.c | ||
122 | @@ -XXX,XX +XXX,XX @@ | ||
123 | +/* | ||
124 | + * BCM2835 Power Management emulation | ||
125 | + * | ||
126 | + * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com> | ||
127 | + * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net> | ||
128 | + * | ||
129 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
130 | + * See the COPYING file in the top-level directory. | ||
131 | + */ | ||
132 | + | ||
133 | +#include "qemu/osdep.h" | ||
134 | +#include "qemu/log.h" | ||
135 | +#include "qemu/module.h" | ||
136 | +#include "hw/misc/bcm2835_powermgt.h" | ||
137 | +#include "migration/vmstate.h" | ||
138 | +#include "sysemu/runstate.h" | ||
139 | + | ||
140 | +#define PASSWORD 0x5a000000 | ||
141 | +#define PASSWORD_MASK 0xff000000 | ||
142 | + | ||
143 | +#define R_RSTC 0x1c | ||
144 | +#define V_RSTC_RESET 0x20 | ||
145 | +#define R_RSTS 0x20 | ||
146 | +#define V_RSTS_POWEROFF 0x555 /* Linux uses partition 63 to indicate halt. */ | ||
147 | +#define R_WDOG 0x24 | ||
148 | + | ||
149 | +static uint64_t bcm2835_powermgt_read(void *opaque, hwaddr offset, | ||
150 | + unsigned size) | ||
151 | +{ | ||
152 | + BCM2835PowerMgtState *s = (BCM2835PowerMgtState *)opaque; | ||
153 | + uint32_t res = 0; | ||
154 | + | ||
155 | + switch (offset) { | ||
156 | + case R_RSTC: | ||
157 | + res = s->rstc; | ||
158 | + break; | ||
159 | + case R_RSTS: | ||
160 | + res = s->rsts; | ||
161 | + break; | ||
162 | + case R_WDOG: | ||
163 | + res = s->wdog; | ||
164 | + break; | ||
165 | + | ||
166 | + default: | ||
167 | + qemu_log_mask(LOG_UNIMP, | ||
168 | + "bcm2835_powermgt_read: Unknown offset 0x%08"HWADDR_PRIx | ||
169 | + "\n", offset); | ||
170 | + res = 0; | ||
171 | + break; | ||
172 | + } | ||
173 | + | ||
174 | + return res; | ||
175 | +} | ||
176 | + | ||
177 | +static void bcm2835_powermgt_write(void *opaque, hwaddr offset, | ||
178 | + uint64_t value, unsigned size) | ||
179 | +{ | ||
180 | + BCM2835PowerMgtState *s = (BCM2835PowerMgtState *)opaque; | ||
181 | + | ||
182 | + if ((value & PASSWORD_MASK) != PASSWORD) { | ||
183 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
184 | + "bcm2835_powermgt_write: Bad password 0x%"PRIx64 | ||
185 | + " at offset 0x%08"HWADDR_PRIx"\n", | ||
186 | + value, offset); | ||
187 | + return; | ||
188 | + } | ||
189 | + | ||
190 | + value = value & ~PASSWORD_MASK; | ||
191 | + | ||
192 | + switch (offset) { | ||
193 | + case R_RSTC: | ||
194 | + s->rstc = value; | ||
195 | + if (value & V_RSTC_RESET) { | ||
196 | + if ((s->rsts & 0xfff) == V_RSTS_POWEROFF) { | ||
197 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); | ||
198 | + } else { | ||
199 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
200 | + } | ||
201 | + } | ||
202 | + break; | ||
203 | + case R_RSTS: | ||
204 | + qemu_log_mask(LOG_UNIMP, | ||
205 | + "bcm2835_powermgt_write: RSTS\n"); | ||
206 | + s->rsts = value; | ||
207 | + break; | ||
208 | + case R_WDOG: | ||
209 | + qemu_log_mask(LOG_UNIMP, | ||
210 | + "bcm2835_powermgt_write: WDOG\n"); | ||
211 | + s->wdog = value; | ||
212 | + break; | ||
213 | + | ||
214 | + default: | ||
215 | + qemu_log_mask(LOG_UNIMP, | ||
216 | + "bcm2835_powermgt_write: Unknown offset 0x%08"HWADDR_PRIx | ||
217 | + "\n", offset); | ||
218 | + break; | ||
219 | + } | ||
220 | +} | ||
221 | + | ||
222 | +static const MemoryRegionOps bcm2835_powermgt_ops = { | ||
223 | + .read = bcm2835_powermgt_read, | ||
224 | + .write = bcm2835_powermgt_write, | ||
225 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
226 | + .impl.min_access_size = 4, | ||
227 | + .impl.max_access_size = 4, | ||
228 | +}; | ||
229 | + | ||
230 | +static const VMStateDescription vmstate_bcm2835_powermgt = { | ||
231 | + .name = TYPE_BCM2835_POWERMGT, | ||
232 | + .version_id = 1, | ||
233 | + .minimum_version_id = 1, | ||
234 | + .fields = (VMStateField[]) { | ||
235 | + VMSTATE_UINT32(rstc, BCM2835PowerMgtState), | ||
236 | + VMSTATE_UINT32(rsts, BCM2835PowerMgtState), | ||
237 | + VMSTATE_UINT32(wdog, BCM2835PowerMgtState), | ||
238 | + VMSTATE_END_OF_LIST() | ||
239 | + } | ||
240 | +}; | ||
241 | + | ||
242 | +static void bcm2835_powermgt_init(Object *obj) | ||
243 | +{ | ||
244 | + BCM2835PowerMgtState *s = BCM2835_POWERMGT(obj); | ||
245 | + | ||
246 | + memory_region_init_io(&s->iomem, obj, &bcm2835_powermgt_ops, s, | ||
247 | + TYPE_BCM2835_POWERMGT, 0x200); | ||
248 | + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); | ||
249 | +} | ||
250 | + | ||
251 | +static void bcm2835_powermgt_reset(DeviceState *dev) | ||
252 | +{ | ||
253 | + BCM2835PowerMgtState *s = BCM2835_POWERMGT(dev); | ||
254 | + | ||
255 | + /* https://elinux.org/BCM2835_registers#PM */ | ||
256 | + s->rstc = 0x00000102; | ||
257 | + s->rsts = 0x00001000; | ||
258 | + s->wdog = 0x00000000; | ||
259 | +} | ||
260 | + | ||
261 | +static void bcm2835_powermgt_class_init(ObjectClass *klass, void *data) | ||
262 | +{ | ||
263 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
264 | + | ||
265 | + dc->reset = bcm2835_powermgt_reset; | ||
266 | + dc->vmsd = &vmstate_bcm2835_powermgt; | ||
267 | +} | ||
268 | + | ||
269 | +static TypeInfo bcm2835_powermgt_info = { | ||
270 | + .name = TYPE_BCM2835_POWERMGT, | ||
271 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
272 | + .instance_size = sizeof(BCM2835PowerMgtState), | ||
273 | + .class_init = bcm2835_powermgt_class_init, | ||
274 | + .instance_init = bcm2835_powermgt_init, | ||
275 | +}; | ||
276 | + | ||
277 | +static void bcm2835_powermgt_register_types(void) | ||
278 | +{ | ||
279 | + type_register_static(&bcm2835_powermgt_info); | ||
280 | +} | ||
281 | + | ||
282 | +type_init(bcm2835_powermgt_register_types) | ||
283 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
284 | index XXXXXXX..XXXXXXX 100644 | ||
285 | --- a/hw/misc/meson.build | ||
286 | +++ b/hw/misc/meson.build | ||
287 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files( | ||
288 | 'bcm2835_rng.c', | ||
289 | 'bcm2835_thermal.c', | ||
290 | 'bcm2835_cprman.c', | ||
291 | + 'bcm2835_powermgt.c', | ||
292 | )) | ||
293 | softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) | ||
294 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c', 'zynq-xadc.c')) | ||
31 | -- | 295 | -- |
32 | 2.20.1 | 296 | 2.20.1 |
33 | 297 | ||
34 | 298 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The helper function is more documentary, and also already | 3 | Add a test booting and quickly shutdown a raspi2 machine, |
4 | handles the case of rotate by zero. | 4 | to test the power management model: |
5 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | (1/1) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd: |
7 | Message-id: 20190808202616.13782-5-richard.henderson@linaro.org | 7 | console: [ 0.000000] Booting Linux on physical CPU 0xf00 |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | console: [ 0.000000] Linux version 4.14.98-v7+ (dom@dom-XPS-13-9370) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1200 SMP Tue Feb 12 20:27:48 GMT 2019 |
9 | console: [ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d | ||
10 | console: [ 0.000000] CPU: div instructions available: patching division code | ||
11 | console: [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache | ||
12 | console: [ 0.000000] OF: fdt: Machine model: Raspberry Pi 2 Model B | ||
13 | ... | ||
14 | console: Boot successful. | ||
15 | console: cat /proc/cpuinfo | ||
16 | console: / # cat /proc/cpuinfo | ||
17 | ... | ||
18 | console: processor : 3 | ||
19 | console: model name : ARMv7 Processor rev 5 (v7l) | ||
20 | console: BogoMIPS : 125.00 | ||
21 | console: Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm | ||
22 | console: CPU implementer : 0x41 | ||
23 | console: CPU architecture: 7 | ||
24 | console: CPU variant : 0x0 | ||
25 | console: CPU part : 0xc07 | ||
26 | console: CPU revision : 5 | ||
27 | console: Hardware : BCM2835 | ||
28 | console: Revision : 0000 | ||
29 | console: Serial : 0000000000000000 | ||
30 | console: cat /proc/iomem | ||
31 | console: / # cat /proc/iomem | ||
32 | console: 00000000-3bffffff : System RAM | ||
33 | console: 00008000-00afffff : Kernel code | ||
34 | console: 00c00000-00d468ef : Kernel data | ||
35 | console: 3f006000-3f006fff : dwc_otg | ||
36 | console: 3f007000-3f007eff : /soc/dma@7e007000 | ||
37 | console: 3f00b880-3f00b8bf : /soc/mailbox@7e00b880 | ||
38 | console: 3f100000-3f100027 : /soc/watchdog@7e100000 | ||
39 | console: 3f101000-3f102fff : /soc/cprman@7e101000 | ||
40 | console: 3f200000-3f2000b3 : /soc/gpio@7e200000 | ||
41 | PASS (24.59 s) | ||
42 | RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 | ||
43 | JOB TIME : 25.02 s | ||
44 | |||
45 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
46 | Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> | ||
47 | Message-id: 20210531113837.1689775-1-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 48 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 49 | --- |
11 | target/arm/translate.c | 7 ++----- | 50 | tests/acceptance/boot_linux_console.py | 43 ++++++++++++++++++++++++++ |
12 | 1 file changed, 2 insertions(+), 5 deletions(-) | 51 | 1 file changed, 43 insertions(+) |
13 | 52 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 53 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py |
15 | index XXXXXXX..XXXXXXX 100644 | 54 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 55 | --- a/tests/acceptance/boot_linux_console.py |
17 | +++ b/target/arm/translate.c | 56 | +++ b/tests/acceptance/boot_linux_console.py |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 57 | @@ -XXX,XX +XXX,XX @@ |
19 | /* CPSR = immediate */ | 58 | from avocado import skip |
20 | val = insn & 0xff; | 59 | from avocado import skipUnless |
21 | shift = ((insn >> 8) & 0xf) * 2; | 60 | from avocado_qemu import Test |
22 | - if (shift) | 61 | +from avocado_qemu import exec_command |
23 | - val = (val >> shift) | (val << (32 - shift)); | 62 | from avocado_qemu import exec_command_and_wait_for_pattern |
24 | + val = ror32(val, shift); | 63 | from avocado_qemu import interrupt_interactive_console_until_pattern |
25 | i = ((insn & (1 << 22)) != 0); | 64 | from avocado_qemu import wait_for_console_pattern |
26 | if (gen_set_psr_im(s, msr_mask(s, (insn >> 16) & 0xf, i), | 65 | @@ -XXX,XX +XXX,XX @@ def test_arm_raspi2_uart0(self): |
27 | i, val)) { | 66 | """ |
28 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 67 | self.do_test_arm_raspi2(0) |
29 | /* immediate operand */ | 68 | |
30 | val = insn & 0xff; | 69 | + def test_arm_raspi2_initrd(self): |
31 | shift = ((insn >> 8) & 0xf) * 2; | 70 | + """ |
32 | - if (shift) { | 71 | + :avocado: tags=arch:arm |
33 | - val = (val >> shift) | (val << (32 - shift)); | 72 | + :avocado: tags=machine:raspi2 |
34 | - } | 73 | + """ |
35 | + val = ror32(val, shift); | 74 | + deb_url = ('http://archive.raspberrypi.org/debian/' |
36 | tmp2 = tcg_temp_new_i32(); | 75 | + 'pool/main/r/raspberrypi-firmware/' |
37 | tcg_gen_movi_i32(tmp2, val); | 76 | + 'raspberrypi-kernel_1.20190215-1_armhf.deb') |
38 | if (logic_cc && shift) { | 77 | + deb_hash = 'cd284220b32128c5084037553db3c482426f3972' |
78 | + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
79 | + kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img') | ||
80 | + dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb') | ||
81 | + | ||
82 | + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
83 | + '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
84 | + 'arm/rootfs-armv7a.cpio.gz') | ||
85 | + initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' | ||
86 | + initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) | ||
87 | + initrd_path = os.path.join(self.workdir, 'rootfs.cpio') | ||
88 | + archive.gzip_uncompress(initrd_path_gz, initrd_path) | ||
89 | + | ||
90 | + self.vm.set_console() | ||
91 | + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + | ||
92 | + 'earlycon=pl011,0x3f201000 console=ttyAMA0 ' | ||
93 | + 'panic=-1 noreboot ' + | ||
94 | + 'dwc_otg.fiq_fsm_enable=0') | ||
95 | + self.vm.add_args('-kernel', kernel_path, | ||
96 | + '-dtb', dtb_path, | ||
97 | + '-initrd', initrd_path, | ||
98 | + '-append', kernel_command_line, | ||
99 | + '-no-reboot') | ||
100 | + self.vm.launch() | ||
101 | + self.wait_for_console_pattern('Boot successful.') | ||
102 | + | ||
103 | + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', | ||
104 | + 'BCM2835') | ||
105 | + exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', | ||
106 | + '/soc/cprman@7e101000') | ||
107 | + exec_command(self, 'halt') | ||
108 | + # Wait for VM to shut down gracefully | ||
109 | + self.vm.wait() | ||
110 | + | ||
111 | def test_arm_exynos4210_initrd(self): | ||
112 | """ | ||
113 | :avocado: tags=arch:arm | ||
39 | -- | 114 | -- |
40 | 2.20.1 | 115 | 2.20.1 |
41 | 116 | ||
42 | 117 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joe Komlodi <joe.komlodi@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | The immediate shift generator functions already test for, | 3 | If the CPU is running in default NaN mode (FPCR.DN == 1) and we execute |
4 | and eliminate, the case of a shift by zero. | 4 | FRSQRTE, FRECPE, or FRECPX with a signaling NaN, parts_silence_nan_frac() will |
5 | assert due to fpst->default_nan_mode being set. | ||
5 | 6 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | To avoid this, we check to see what NaN mode we're running in before we call |
7 | Message-id: 20190808202616.13782-4-richard.henderson@linaro.org | 8 | floatxx_silence_nan(). |
9 | |||
10 | Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 1624662174-175828-2-git-send-email-joe.komlodi@xilinx.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 15 | --- |
11 | target/arm/translate.c | 19 +++++++------------ | 16 | target/arm/helper-a64.c | 12 +++++++++--- |
12 | 1 file changed, 7 insertions(+), 12 deletions(-) | 17 | target/arm/vfp_helper.c | 24 ++++++++++++++++++------ |
18 | 2 files changed, 27 insertions(+), 9 deletions(-) | ||
13 | 19 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 20 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c |
15 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 22 | --- a/target/arm/helper-a64.c |
17 | +++ b/target/arm/translate.c | 23 | +++ b/target/arm/helper-a64.c |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 24 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp) |
19 | shift = (insn >> 10) & 3; | 25 | float16 nan = a; |
20 | /* ??? In many cases it's not necessary to do a | 26 | if (float16_is_signaling_nan(a, fpst)) { |
21 | rotate, a shift is sufficient. */ | 27 | float_raise(float_flag_invalid, fpst); |
22 | - if (shift != 0) | 28 | - nan = float16_silence_nan(a, fpst); |
23 | - tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 29 | + if (!fpst->default_nan_mode) { |
24 | + tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 30 | + nan = float16_silence_nan(a, fpst); |
25 | op1 = (insn >> 20) & 7; | 31 | + } |
26 | switch (op1) { | 32 | } |
27 | case 0: gen_sxtb16(tmp); break; | 33 | if (fpst->default_nan_mode) { |
28 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 34 | nan = float16_default_nan(fpst); |
29 | shift = (insn >> 4) & 3; | 35 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) |
30 | /* ??? In many cases it's not necessary to do a | 36 | float32 nan = a; |
31 | rotate, a shift is sufficient. */ | 37 | if (float32_is_signaling_nan(a, fpst)) { |
32 | - if (shift != 0) | 38 | float_raise(float_flag_invalid, fpst); |
33 | - tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 39 | - nan = float32_silence_nan(a, fpst); |
34 | + tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 40 | + if (!fpst->default_nan_mode) { |
35 | op = (insn >> 20) & 7; | 41 | + nan = float32_silence_nan(a, fpst); |
36 | switch (op) { | 42 | + } |
37 | case 0: gen_sxth(tmp); break; | 43 | } |
38 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 44 | if (fpst->default_nan_mode) { |
39 | case 7: | 45 | nan = float32_default_nan(fpst); |
40 | goto illegal_op; | 46 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) |
41 | default: /* Saturate. */ | 47 | float64 nan = a; |
42 | - if (shift) { | 48 | if (float64_is_signaling_nan(a, fpst)) { |
43 | - if (op & 1) | 49 | float_raise(float_flag_invalid, fpst); |
44 | - tcg_gen_sari_i32(tmp, tmp, shift); | 50 | - nan = float64_silence_nan(a, fpst); |
45 | - else | 51 | + if (!fpst->default_nan_mode) { |
46 | - tcg_gen_shli_i32(tmp, tmp, shift); | 52 | + nan = float64_silence_nan(a, fpst); |
47 | + if (op & 1) { | 53 | + } |
48 | + tcg_gen_sari_i32(tmp, tmp, shift); | 54 | } |
49 | + } else { | 55 | if (fpst->default_nan_mode) { |
50 | + tcg_gen_shli_i32(tmp, tmp, shift); | 56 | nan = float64_default_nan(fpst); |
51 | } | 57 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c |
52 | tmp2 = tcg_const_i32(imm); | 58 | index XXXXXXX..XXXXXXX 100644 |
53 | if (op & 4) { | 59 | --- a/target/arm/vfp_helper.c |
54 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 60 | +++ b/target/arm/vfp_helper.c |
55 | goto illegal_op; | 61 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) |
56 | } | 62 | float16 nan = f16; |
57 | tmp = load_reg(s, rm); | 63 | if (float16_is_signaling_nan(f16, fpst)) { |
58 | - if (shift) { | 64 | float_raise(float_flag_invalid, fpst); |
59 | - tcg_gen_shli_i32(tmp, tmp, shift); | 65 | - nan = float16_silence_nan(f16, fpst); |
60 | - } | 66 | + if (!fpst->default_nan_mode) { |
61 | + tcg_gen_shli_i32(tmp, tmp, shift); | 67 | + nan = float16_silence_nan(f16, fpst); |
62 | tcg_gen_add_i32(addr, addr, tmp); | 68 | + } |
63 | tcg_temp_free_i32(tmp); | 69 | } |
64 | break; | 70 | if (fpst->default_nan_mode) { |
71 | nan = float16_default_nan(fpst); | ||
72 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp) | ||
73 | float32 nan = f32; | ||
74 | if (float32_is_signaling_nan(f32, fpst)) { | ||
75 | float_raise(float_flag_invalid, fpst); | ||
76 | - nan = float32_silence_nan(f32, fpst); | ||
77 | + if (!fpst->default_nan_mode) { | ||
78 | + nan = float32_silence_nan(f32, fpst); | ||
79 | + } | ||
80 | } | ||
81 | if (fpst->default_nan_mode) { | ||
82 | nan = float32_default_nan(fpst); | ||
83 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp) | ||
84 | float64 nan = f64; | ||
85 | if (float64_is_signaling_nan(f64, fpst)) { | ||
86 | float_raise(float_flag_invalid, fpst); | ||
87 | - nan = float64_silence_nan(f64, fpst); | ||
88 | + if (!fpst->default_nan_mode) { | ||
89 | + nan = float64_silence_nan(f64, fpst); | ||
90 | + } | ||
91 | } | ||
92 | if (fpst->default_nan_mode) { | ||
93 | nan = float64_default_nan(fpst); | ||
94 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) | ||
95 | float16 nan = f16; | ||
96 | if (float16_is_signaling_nan(f16, s)) { | ||
97 | float_raise(float_flag_invalid, s); | ||
98 | - nan = float16_silence_nan(f16, s); | ||
99 | + if (!s->default_nan_mode) { | ||
100 | + nan = float16_silence_nan(f16, fpstp); | ||
101 | + } | ||
102 | } | ||
103 | if (s->default_nan_mode) { | ||
104 | nan = float16_default_nan(s); | ||
105 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) | ||
106 | float32 nan = f32; | ||
107 | if (float32_is_signaling_nan(f32, s)) { | ||
108 | float_raise(float_flag_invalid, s); | ||
109 | - nan = float32_silence_nan(f32, s); | ||
110 | + if (!s->default_nan_mode) { | ||
111 | + nan = float32_silence_nan(f32, fpstp); | ||
112 | + } | ||
113 | } | ||
114 | if (s->default_nan_mode) { | ||
115 | nan = float32_default_nan(s); | ||
116 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) | ||
117 | float64 nan = f64; | ||
118 | if (float64_is_signaling_nan(f64, s)) { | ||
119 | float_raise(float_flag_invalid, s); | ||
120 | - nan = float64_silence_nan(f64, s); | ||
121 | + if (!s->default_nan_mode) { | ||
122 | + nan = float64_silence_nan(f64, fpstp); | ||
123 | + } | ||
124 | } | ||
125 | if (s->default_nan_mode) { | ||
126 | nan = float64_default_nan(s); | ||
65 | -- | 127 | -- |
66 | 2.20.1 | 128 | 2.20.1 |
67 | 129 | ||
68 | 130 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Maxim Uvarov <maxim.uvarov@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Separate shift + extract low will result in one extra insn | 3 | qemu has 2 type of functions: shutdown and reboot. Shutdown |
4 | for hosts like RISC-V, MIPS, and Sparc. | 4 | function has to be used for machine shutdown. Otherwise we cause |
5 | a reset with a bogus "cause" value, when we intended a shutdown. | ||
5 | 6 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> |
7 | Message-id: 20190808202616.13782-8-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20210625111842.3790-3-maxim.uvarov@linaro.org | ||
10 | [PMM: tweaked commit message] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | target/arm/translate.c | 18 ++++++------------ | 13 | hw/gpio/gpio_pwr.c | 2 +- |
12 | 1 file changed, 6 insertions(+), 12 deletions(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 15 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/hw/gpio/gpio_pwr.c b/hw/gpio/gpio_pwr.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 18 | --- a/hw/gpio/gpio_pwr.c |
17 | +++ b/target/arm/translate.c | 19 | +++ b/hw/gpio/gpio_pwr.c |
18 | @@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn) | 20 | @@ -XXX,XX +XXX,XX @@ static void gpio_pwr_reset(void *opaque, int n, int level) |
19 | if (insn & ARM_CP_RW_BIT) { /* TMRRC */ | 21 | static void gpio_pwr_shutdown(void *opaque, int n, int level) |
20 | iwmmxt_load_reg(cpu_V0, wrd); | 22 | { |
21 | tcg_gen_extrl_i64_i32(cpu_R[rdlo], cpu_V0); | 23 | if (level) { |
22 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | 24 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
23 | - tcg_gen_extrl_i64_i32(cpu_R[rdhi], cpu_V0); | 25 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
24 | + tcg_gen_extrh_i64_i32(cpu_R[rdhi], cpu_V0); | 26 | } |
25 | } else { /* TMCRR */ | ||
26 | tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]); | ||
27 | iwmmxt_store_reg(cpu_V0, wrd); | ||
28 | @@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn) | ||
29 | if (insn & ARM_CP_RW_BIT) { /* MRA */ | ||
30 | iwmmxt_load_reg(cpu_V0, acc); | ||
31 | tcg_gen_extrl_i64_i32(cpu_R[rdlo], cpu_V0); | ||
32 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | ||
33 | - tcg_gen_extrl_i64_i32(cpu_R[rdhi], cpu_V0); | ||
34 | + tcg_gen_extrh_i64_i32(cpu_R[rdhi], cpu_V0); | ||
35 | tcg_gen_andi_i32(cpu_R[rdhi], cpu_R[rdhi], (1 << (40 - 32)) - 1); | ||
36 | } else { /* MAR */ | ||
37 | tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]); | ||
38 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
39 | gen_helper_neon_narrow_high_u16(tmp, cpu_V0); | ||
40 | break; | ||
41 | case 2: | ||
42 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | ||
43 | - tcg_gen_extrl_i64_i32(tmp, cpu_V0); | ||
44 | + tcg_gen_extrh_i64_i32(tmp, cpu_V0); | ||
45 | break; | ||
46 | default: abort(); | ||
47 | } | ||
48 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
49 | break; | ||
50 | case 2: | ||
51 | tcg_gen_addi_i64(cpu_V0, cpu_V0, 1u << 31); | ||
52 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | ||
53 | - tcg_gen_extrl_i64_i32(tmp, cpu_V0); | ||
54 | + tcg_gen_extrh_i64_i32(tmp, cpu_V0); | ||
55 | break; | ||
56 | default: abort(); | ||
57 | } | ||
58 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
59 | tmp = tcg_temp_new_i32(); | ||
60 | tcg_gen_extrl_i64_i32(tmp, tmp64); | ||
61 | store_reg(s, rt, tmp); | ||
62 | - tcg_gen_shri_i64(tmp64, tmp64, 32); | ||
63 | tmp = tcg_temp_new_i32(); | ||
64 | - tcg_gen_extrl_i64_i32(tmp, tmp64); | ||
65 | + tcg_gen_extrh_i64_i32(tmp, tmp64); | ||
66 | tcg_temp_free_i64(tmp64); | ||
67 | store_reg(s, rt2, tmp); | ||
68 | } else { | ||
69 | @@ -XXX,XX +XXX,XX @@ static void gen_storeq_reg(DisasContext *s, int rlow, int rhigh, TCGv_i64 val) | ||
70 | tcg_gen_extrl_i64_i32(tmp, val); | ||
71 | store_reg(s, rlow, tmp); | ||
72 | tmp = tcg_temp_new_i32(); | ||
73 | - tcg_gen_shri_i64(val, val, 32); | ||
74 | - tcg_gen_extrl_i64_i32(tmp, val); | ||
75 | + tcg_gen_extrh_i64_i32(tmp, val); | ||
76 | store_reg(s, rhigh, tmp); | ||
77 | } | 27 | } |
78 | 28 | ||
79 | -- | 29 | -- |
80 | 2.20.1 | 30 | 2.20.1 |
81 | 31 | ||
82 | 32 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | In do_ldst(), the calculation of the offset needs to be based on the |
---|---|---|---|
2 | size of the memory access, not the size of the elements in the | ||
3 | vector. This meant we were getting it wrong for the widening and | ||
4 | narrowing variants of the various VLDR and VSTR insns. | ||
2 | 5 | ||
3 | This function is used in two different contexts, and it will be | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | clearer if the function is given the address to which it applies. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210628135835.6690-2-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/translate-mve.c | 17 +++++++++-------- | ||
11 | 1 file changed, 9 insertions(+), 8 deletions(-) | ||
5 | 12 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 13 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190807045335.1361-2-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/translate.c | 14 +++++++------- | ||
13 | 1 file changed, 7 insertions(+), 7 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 15 | --- a/target/arm/translate-mve.c |
18 | +++ b/target/arm/translate.c | 16 | +++ b/target/arm/translate-mve.c |
19 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 17 | @@ -XXX,XX +XXX,XX @@ static bool mve_skip_first_beat(DisasContext *s) |
20 | } | 18 | } |
21 | } | 19 | } |
22 | 20 | ||
23 | -static bool thumb_insn_is_16bit(DisasContext *s, uint32_t insn) | 21 | -static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) |
24 | +static bool thumb_insn_is_16bit(DisasContext *s, uint32_t pc, uint32_t insn) | 22 | +static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn, |
23 | + unsigned msize) | ||
25 | { | 24 | { |
26 | - /* Return true if this is a 16 bit instruction. We must be precise | 25 | TCGv_i32 addr; |
27 | - * about this (matching the decode). We assume that s->pc still | 26 | uint32_t offset; |
28 | - * points to the first 16 bits of the insn. | 27 | @@ -XXX,XX +XXX,XX @@ static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) |
29 | + /* | 28 | return true; |
30 | + * Return true if this is a 16 bit instruction. We must be precise | ||
31 | + * about this (matching the decode). | ||
32 | */ | ||
33 | if ((insn >> 11) < 0x1d) { | ||
34 | /* Definitely a 16-bit instruction */ | ||
35 | @@ -XXX,XX +XXX,XX @@ static bool thumb_insn_is_16bit(DisasContext *s, uint32_t insn) | ||
36 | return false; | ||
37 | } | 29 | } |
38 | 30 | ||
39 | - if ((insn >> 11) == 0x1e && s->pc - s->page_start < TARGET_PAGE_SIZE - 3) { | 31 | - offset = a->imm << a->size; |
40 | + if ((insn >> 11) == 0x1e && pc - s->page_start < TARGET_PAGE_SIZE - 3) { | 32 | + offset = a->imm << msize; |
41 | /* 0b1111_0xxx_xxxx_xxxx : BL/BLX prefix, and the suffix | 33 | if (!a->a) { |
42 | * is not on the next page; we merge this into a 32-bit | 34 | offset = -offset; |
43 | * insn. | 35 | } |
44 | @@ -XXX,XX +XXX,XX @@ static bool insn_crosses_page(CPUARMState *env, DisasContext *s) | 36 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) |
45 | */ | 37 | { gen_helper_mve_vstrw, gen_helper_mve_vldrw }, |
46 | uint16_t insn = arm_lduw_code(env, s->pc, s->sctlr_b); | 38 | { NULL, NULL } |
47 | 39 | }; | |
48 | - return !thumb_insn_is_16bit(s, insn); | 40 | - return do_ldst(s, a, ldstfns[a->size][a->l]); |
49 | + return !thumb_insn_is_16bit(s, s->pc, insn); | 41 | + return do_ldst(s, a, ldstfns[a->size][a->l], a->size); |
50 | } | 42 | } |
51 | 43 | ||
52 | static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 44 | -#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST) \ |
53 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 45 | +#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST, MSIZE) \ |
46 | static bool trans_##OP(DisasContext *s, arg_VLDR_VSTR *a) \ | ||
47 | { \ | ||
48 | static MVEGenLdStFn * const ldstfns[2][2] = { \ | ||
49 | { gen_helper_mve_##ST, gen_helper_mve_##SLD }, \ | ||
50 | { NULL, gen_helper_mve_##ULD }, \ | ||
51 | }; \ | ||
52 | - return do_ldst(s, a, ldstfns[a->u][a->l]); \ | ||
53 | + return do_ldst(s, a, ldstfns[a->u][a->l], MSIZE); \ | ||
54 | } | 54 | } |
55 | 55 | ||
56 | insn = arm_lduw_code(env, dc->pc, dc->sctlr_b); | 56 | -DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h) |
57 | - is_16bit = thumb_insn_is_16bit(dc, insn); | 57 | -DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w) |
58 | + is_16bit = thumb_insn_is_16bit(dc, dc->pc, insn); | 58 | -DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w) |
59 | dc->pc += 2; | 59 | +DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h, MO_8) |
60 | if (!is_16bit) { | 60 | +DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w, MO_8) |
61 | uint32_t insn2 = arm_lduw_code(env, dc->pc, dc->sctlr_b); | 61 | +DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w, MO_16) |
62 | |||
63 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
64 | { | ||
62 | -- | 65 | -- |
63 | 2.20.1 | 66 | 2.20.1 |
64 | 67 | ||
65 | 68 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | The initial implementation of the MVE VRMLALDAVH and VRMLSLDAVH |
---|---|---|---|
2 | insns had some bugs: | ||
3 | * the 32x32 multiply of elements was being done as 32x32->32, | ||
4 | not 32x32->64 | ||
5 | * we were incorrectly maintaining the accumulator in its full | ||
6 | 72-bit form across all 4 beats of the insn; in the pseudocode | ||
7 | it is squashed back into the 64 bits of the RdaHi:RdaLo | ||
8 | registers after each beat | ||
2 | 9 | ||
3 | A couple return -EINVAL's forgot their '-'s. | 10 | In particular, fixing the second of these allows us to recast |
11 | the implementation to avoid 128-bit arithmetic entirely. | ||
4 | 12 | ||
5 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 13 | Since the element size here is always 4, we can also drop the |
6 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 14 | parameterization of ESIZE to make the code a little more readable. |
15 | |||
16 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Message-id: 20210628135835.6690-3-peter.maydell@linaro.org |
9 | --- | 20 | --- |
10 | target/arm/kvm64.c | 4 ++-- | 21 | target/arm/mve_helper.c | 38 +++++++++++++++++++++----------------- |
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | 22 | 1 file changed, 21 insertions(+), 17 deletions(-) |
12 | 23 | ||
13 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | 24 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/kvm64.c | 26 | --- a/target/arm/mve_helper.c |
16 | +++ b/target/arm/kvm64.c | 27 | +++ b/target/arm/mve_helper.c |
17 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | 28 | @@ -XXX,XX +XXX,XX @@ |
18 | write_cpustate_to_list(cpu, true); | 29 | */ |
19 | 30 | ||
20 | if (!write_list_to_kvmstate(cpu, level)) { | 31 | #include "qemu/osdep.h" |
21 | - return EINVAL; | 32 | -#include "qemu/int128.h" |
22 | + return -EINVAL; | 33 | #include "cpu.h" |
34 | #include "internals.h" | ||
35 | #include "vec_internal.h" | ||
36 | @@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=) | ||
37 | DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=) | ||
38 | |||
39 | /* | ||
40 | - * Rounding multiply add long dual accumulate high: we must keep | ||
41 | - * a 72-bit internal accumulator value and return the top 64 bits. | ||
42 | + * Rounding multiply add long dual accumulate high. In the pseudocode | ||
43 | + * this is implemented with a 72-bit internal accumulator value of which | ||
44 | + * the top 64 bits are returned. We optimize this to avoid having to | ||
45 | + * use 128-bit arithmetic -- we can do this because the 74-bit accumulator | ||
46 | + * is squashed back into 64-bits after each beat. | ||
47 | */ | ||
48 | -#define DO_LDAVH(OP, ESIZE, TYPE, XCHG, EVENACC, ODDACC, TO128) \ | ||
49 | +#define DO_LDAVH(OP, TYPE, LTYPE, XCHG, SUB) \ | ||
50 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
51 | void *vm, uint64_t a) \ | ||
52 | { \ | ||
53 | uint16_t mask = mve_element_mask(env); \ | ||
54 | unsigned e; \ | ||
55 | TYPE *n = vn, *m = vm; \ | ||
56 | - Int128 acc = int128_lshift(TO128(a), 8); \ | ||
57 | - for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
58 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
59 | if (mask & 1) { \ | ||
60 | + LTYPE mul; \ | ||
61 | if (e & 1) { \ | ||
62 | - acc = ODDACC(acc, TO128(n[H##ESIZE(e - 1 * XCHG)] * \ | ||
63 | - m[H##ESIZE(e)])); \ | ||
64 | + mul = (LTYPE)n[H4(e - 1 * XCHG)] * m[H4(e)]; \ | ||
65 | + if (SUB) { \ | ||
66 | + mul = -mul; \ | ||
67 | + } \ | ||
68 | } else { \ | ||
69 | - acc = EVENACC(acc, TO128(n[H##ESIZE(e + 1 * XCHG)] * \ | ||
70 | - m[H##ESIZE(e)])); \ | ||
71 | + mul = (LTYPE)n[H4(e + 1 * XCHG)] * m[H4(e)]; \ | ||
72 | } \ | ||
73 | - acc = int128_add(acc, int128_make64(1 << 7)); \ | ||
74 | + mul = (mul >> 8) + ((mul >> 7) & 1); \ | ||
75 | + a += mul; \ | ||
76 | } \ | ||
77 | } \ | ||
78 | mve_advance_vpt(env); \ | ||
79 | - return int128_getlo(int128_rshift(acc, 8)); \ | ||
80 | + return a; \ | ||
23 | } | 81 | } |
24 | 82 | ||
25 | kvm_arm_sync_mpstate_to_kvm(cpu); | 83 | -DO_LDAVH(vrmlaldavhsw, 4, int32_t, false, int128_add, int128_add, int128_makes64) |
26 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | 84 | -DO_LDAVH(vrmlaldavhxsw, 4, int32_t, true, int128_add, int128_add, int128_makes64) |
27 | } | 85 | +DO_LDAVH(vrmlaldavhsw, int32_t, int64_t, false, false) |
28 | 86 | +DO_LDAVH(vrmlaldavhxsw, int32_t, int64_t, true, false) | |
29 | if (!write_kvmstate_to_list(cpu)) { | 87 | |
30 | - return EINVAL; | 88 | -DO_LDAVH(vrmlaldavhuw, 4, uint32_t, false, int128_add, int128_add, int128_make64) |
31 | + return -EINVAL; | 89 | +DO_LDAVH(vrmlaldavhuw, uint32_t, uint64_t, false, false) |
32 | } | 90 | |
33 | /* Note that it's OK to have registers which aren't in CPUState, | 91 | -DO_LDAVH(vrmlsldavhsw, 4, int32_t, false, int128_add, int128_sub, int128_makes64) |
34 | * so we can ignore a failure return here. | 92 | -DO_LDAVH(vrmlsldavhxsw, 4, int32_t, true, int128_add, int128_sub, int128_makes64) |
93 | +DO_LDAVH(vrmlsldavhsw, int32_t, int64_t, false, true) | ||
94 | +DO_LDAVH(vrmlsldavhxsw, int32_t, int64_t, true, true) | ||
95 | |||
96 | /* Vector add across vector */ | ||
97 | #define DO_VADDV(OP, ESIZE, TYPE) \ | ||
35 | -- | 98 | -- |
36 | 2.20.1 | 99 | 2.20.1 |
37 | 100 | ||
38 | 101 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The function asimd_imm_const() in translate-neon.c is an |
---|---|---|---|
2 | implementation of the pseudocode AdvSIMDExpandImm(), which we will | ||
3 | also want for MVE. Move the implementation to translate.c, with a | ||
4 | prototype in translate.h. | ||
2 | 5 | ||
3 | Promote this function from aarch64 to fully general use. | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Use it to unify the code sequences for generating illegal | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | opcode exceptions. | 8 | Message-id: 20210628135835.6690-4-peter.maydell@linaro.org |
9 | --- | ||
10 | target/arm/translate.h | 16 ++++++++++ | ||
11 | target/arm/translate-neon.c | 63 ------------------------------------- | ||
12 | target/arm/translate.c | 57 +++++++++++++++++++++++++++++++++ | ||
13 | 3 files changed, 73 insertions(+), 63 deletions(-) | ||
6 | 14 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20190807045335.1361-11-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/translate-a64.h | 2 -- | ||
14 | target/arm/translate.h | 2 ++ | ||
15 | target/arm/translate-a64.c | 7 ------- | ||
16 | target/arm/translate-vfp.inc.c | 3 +-- | ||
17 | target/arm/translate.c | 22 ++++++++++++---------- | ||
18 | 5 files changed, 15 insertions(+), 21 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/translate-a64.h | ||
23 | +++ b/target/arm/translate-a64.h | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | #ifndef TARGET_ARM_TRANSLATE_A64_H | ||
26 | #define TARGET_ARM_TRANSLATE_A64_H | ||
27 | |||
28 | -void unallocated_encoding(DisasContext *s); | ||
29 | - | ||
30 | #define unsupported_encoding(s, insn) \ | ||
31 | do { \ | ||
32 | qemu_log_mask(LOG_UNIMP, \ | ||
33 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 15 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
34 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/translate.h | 17 | --- a/target/arm/translate.h |
36 | +++ b/target/arm/translate.h | 18 | +++ b/target/arm/translate.h |
37 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasCompare { | 19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) |
38 | bool value_global; | 20 | return opc | s->be_data; |
39 | } DisasCompare; | 21 | } |
40 | 22 | ||
41 | +void unallocated_encoding(DisasContext *s); | 23 | +/** |
24 | + * asimd_imm_const: Expand an encoded SIMD constant value | ||
25 | + * | ||
26 | + * Expand a SIMD constant value. This is essentially the pseudocode | ||
27 | + * AdvSIMDExpandImm, except that we also perform the boolean NOT needed for | ||
28 | + * VMVN and VBIC (when cmode < 14 && op == 1). | ||
29 | + * | ||
30 | + * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; | ||
31 | + * callers must catch this. | ||
32 | + * | ||
33 | + * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but | ||
34 | + * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; | ||
35 | + * we produce an immediate constant value of 0 in these cases. | ||
36 | + */ | ||
37 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op); | ||
42 | + | 38 | + |
43 | /* Share the TCG temporaries common between 32 and 64 bit modes. */ | 39 | #endif /* TARGET_ARM_TRANSLATE_H */ |
44 | extern TCGv_i32 cpu_NF, cpu_ZF, cpu_CF, cpu_VF; | 40 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c |
45 | extern TCGv_i64 cpu_exclusive_addr; | ||
46 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/target/arm/translate-a64.c | 42 | --- a/target/arm/translate-neon.c |
49 | +++ b/target/arm/translate-a64.c | 43 | +++ b/target/arm/translate-neon.c |
50 | @@ -XXX,XX +XXX,XX @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) | 44 | @@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_UH, gen_helper_gvec_vcvt_uh) |
51 | } | 45 | DO_FP_2SH(VCVT_HS, gen_helper_gvec_vcvt_hs) |
52 | } | 46 | DO_FP_2SH(VCVT_HU, gen_helper_gvec_vcvt_hu) |
53 | 47 | ||
54 | -void unallocated_encoding(DisasContext *s) | 48 | -static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) |
55 | -{ | 49 | -{ |
56 | - /* Unallocated and reserved encodings are uncategorized */ | 50 | - /* |
57 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | 51 | - * Expand the encoded constant. |
58 | - default_exception_el(s)); | 52 | - * Note that cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. |
53 | - * We choose to not special-case this and will behave as if a | ||
54 | - * valid constant encoding of 0 had been given. | ||
55 | - * cmode = 15 op = 1 must UNDEF; we assume decode has handled that. | ||
56 | - */ | ||
57 | - switch (cmode) { | ||
58 | - case 0: case 1: | ||
59 | - /* no-op */ | ||
60 | - break; | ||
61 | - case 2: case 3: | ||
62 | - imm <<= 8; | ||
63 | - break; | ||
64 | - case 4: case 5: | ||
65 | - imm <<= 16; | ||
66 | - break; | ||
67 | - case 6: case 7: | ||
68 | - imm <<= 24; | ||
69 | - break; | ||
70 | - case 8: case 9: | ||
71 | - imm |= imm << 16; | ||
72 | - break; | ||
73 | - case 10: case 11: | ||
74 | - imm = (imm << 8) | (imm << 24); | ||
75 | - break; | ||
76 | - case 12: | ||
77 | - imm = (imm << 8) | 0xff; | ||
78 | - break; | ||
79 | - case 13: | ||
80 | - imm = (imm << 16) | 0xffff; | ||
81 | - break; | ||
82 | - case 14: | ||
83 | - if (op) { | ||
84 | - /* | ||
85 | - * This is the only case where the top and bottom 32 bits | ||
86 | - * of the encoded constant differ. | ||
87 | - */ | ||
88 | - uint64_t imm64 = 0; | ||
89 | - int n; | ||
90 | - | ||
91 | - for (n = 0; n < 8; n++) { | ||
92 | - if (imm & (1 << n)) { | ||
93 | - imm64 |= (0xffULL << (n * 8)); | ||
94 | - } | ||
95 | - } | ||
96 | - return imm64; | ||
97 | - } | ||
98 | - imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
99 | - break; | ||
100 | - case 15: | ||
101 | - imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
102 | - | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
103 | - break; | ||
104 | - } | ||
105 | - if (op) { | ||
106 | - imm = ~imm; | ||
107 | - } | ||
108 | - return dup_const(MO_32, imm); | ||
59 | -} | 109 | -} |
60 | - | 110 | - |
61 | static void init_tmp_a64_array(DisasContext *s) | 111 | static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a, |
112 | GVecGen2iFn *fn) | ||
62 | { | 113 | { |
63 | #ifdef CONFIG_DEBUG_TCG | ||
64 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/translate-vfp.inc.c | ||
67 | +++ b/target/arm/translate-vfp.inc.c | ||
68 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | ||
69 | |||
70 | if (!s->vfp_enabled && !ignore_vfp_enabled) { | ||
71 | assert(!arm_dc_feature(s, ARM_FEATURE_M)); | ||
72 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
73 | - default_exception_el(s)); | ||
74 | + unallocated_encoding(s); | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 114 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
79 | index XXXXXXX..XXXXXXX 100644 | 115 | index XXXXXXX..XXXXXXX 100644 |
80 | --- a/target/arm/translate.c | 116 | --- a/target/arm/translate.c |
81 | +++ b/target/arm/translate.c | 117 | +++ b/target/arm/translate.c |
82 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) | 118 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void) |
83 | s->base.is_jmp = DISAS_NORETURN; | 119 | a64_translate_init(); |
84 | } | 120 | } |
85 | 121 | ||
86 | +void unallocated_encoding(DisasContext *s) | 122 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) |
87 | +{ | 123 | +{ |
88 | + /* Unallocated and reserved encodings are uncategorized */ | 124 | + /* Expand the encoded constant as per AdvSIMDExpandImm pseudocode */ |
89 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | 125 | + switch (cmode) { |
90 | + default_exception_el(s)); | 126 | + case 0: case 1: |
127 | + /* no-op */ | ||
128 | + break; | ||
129 | + case 2: case 3: | ||
130 | + imm <<= 8; | ||
131 | + break; | ||
132 | + case 4: case 5: | ||
133 | + imm <<= 16; | ||
134 | + break; | ||
135 | + case 6: case 7: | ||
136 | + imm <<= 24; | ||
137 | + break; | ||
138 | + case 8: case 9: | ||
139 | + imm |= imm << 16; | ||
140 | + break; | ||
141 | + case 10: case 11: | ||
142 | + imm = (imm << 8) | (imm << 24); | ||
143 | + break; | ||
144 | + case 12: | ||
145 | + imm = (imm << 8) | 0xff; | ||
146 | + break; | ||
147 | + case 13: | ||
148 | + imm = (imm << 16) | 0xffff; | ||
149 | + break; | ||
150 | + case 14: | ||
151 | + if (op) { | ||
152 | + /* | ||
153 | + * This is the only case where the top and bottom 32 bits | ||
154 | + * of the encoded constant differ. | ||
155 | + */ | ||
156 | + uint64_t imm64 = 0; | ||
157 | + int n; | ||
158 | + | ||
159 | + for (n = 0; n < 8; n++) { | ||
160 | + if (imm & (1 << n)) { | ||
161 | + imm64 |= (0xffULL << (n * 8)); | ||
162 | + } | ||
163 | + } | ||
164 | + return imm64; | ||
165 | + } | ||
166 | + imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
167 | + break; | ||
168 | + case 15: | ||
169 | + imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
170 | + | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
171 | + break; | ||
172 | + } | ||
173 | + if (op) { | ||
174 | + imm = ~imm; | ||
175 | + } | ||
176 | + return dup_const(MO_32, imm); | ||
91 | +} | 177 | +} |
92 | + | 178 | + |
93 | /* Force a TB lookup after an instruction that changes the CPU state. */ | 179 | /* Generate a label used for skipping this instruction */ |
94 | static inline void gen_lookup_tb(DisasContext *s) | 180 | void arm_gen_condlabel(DisasContext *s) |
95 | { | 181 | { |
96 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | ||
97 | return; | ||
98 | } | ||
99 | |||
100 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
101 | - default_exception_el(s)); | ||
102 | + unallocated_encoding(s); | ||
103 | } | ||
104 | |||
105 | static inline void gen_add_data_offset(DisasContext *s, unsigned int insn, | ||
106 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
107 | } | ||
108 | |||
109 | if (undef) { | ||
110 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
111 | - default_exception_el(s)); | ||
112 | + unallocated_encoding(s); | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
117 | break; | ||
118 | default: | ||
119 | illegal_op: | ||
120 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
121 | - default_exception_el(s)); | ||
122 | + unallocated_encoding(s); | ||
123 | break; | ||
124 | } | ||
125 | } | ||
126 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
127 | } | ||
128 | return; | ||
129 | illegal_op: | ||
130 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
131 | - default_exception_el(s)); | ||
132 | + unallocated_encoding(s); | ||
133 | } | ||
134 | |||
135 | static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
136 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
137 | return; | ||
138 | illegal_op: | ||
139 | undef: | ||
140 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
141 | - default_exception_el(s)); | ||
142 | + unallocated_encoding(s); | ||
143 | } | ||
144 | |||
145 | static bool insn_crosses_page(CPUARMState *env, DisasContext *s) | ||
146 | -- | 182 | -- |
147 | 2.20.1 | 183 | 2.20.1 |
148 | 184 | ||
149 | 185 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The A64 AdvSIMD modified-immediate grouping uses almost the same |
---|---|---|---|
2 | constant encoding that A32 Neon does; reuse asimd_imm_const() (to | ||
3 | which we add the AArch64-specific case for cmode 15 op 1) instead of | ||
4 | reimplementing it all. | ||
2 | 5 | ||
3 | We must update s->base.pc_next when we return from the translate_insn | ||
4 | hook to the main translator loop. By incrementing s->base.pc_next | ||
5 | immediately after reading the insn word, "pc_next" contains the address | ||
6 | of the next instruction throughout translation. | ||
7 | |||
8 | All remaining uses of s->pc are referencing the address of the next insn, | ||
9 | so this is now a simple global replacement. Remove the "s->pc" field. | ||
10 | |||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
14 | Message-id: 20190807045335.1361-7-richard.henderson@linaro.org | ||
15 | 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> | ||
8 | Message-id: 20210628135835.6690-5-peter.maydell@linaro.org | ||
16 | --- | 9 | --- |
17 | target/arm/translate.h | 1 - | 10 | target/arm/translate.h | 3 +- |
18 | target/arm/translate-a64.c | 51 +++++++++--------- | 11 | target/arm/translate-a64.c | 86 ++++---------------------------------- |
19 | target/arm/translate.c | 103 ++++++++++++++++++------------------- | 12 | target/arm/translate.c | 17 +++++++- |
20 | 3 files changed, 72 insertions(+), 83 deletions(-) | 13 | 3 files changed, 24 insertions(+), 82 deletions(-) |
21 | 14 | ||
22 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 15 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
23 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/translate.h | 17 | --- a/target/arm/translate.h |
25 | +++ b/target/arm/translate.h | 18 | +++ b/target/arm/translate.h |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) |
27 | DisasContextBase base; | 20 | * VMVN and VBIC (when cmode < 14 && op == 1). |
28 | const ARMISARegisters *isar; | 21 | * |
29 | 22 | * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; | |
30 | - target_ulong pc; | 23 | - * callers must catch this. |
31 | /* The address of the current instruction being translated. */ | 24 | + * callers must catch this; we return the 64-bit constant value defined |
32 | target_ulong pc_curr; | 25 | + * for AArch64. |
33 | target_ulong page_start; | 26 | * |
27 | * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but | ||
28 | * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; | ||
34 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 29 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
35 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/translate-a64.c | 31 | --- a/target/arm/translate-a64.c |
37 | +++ b/target/arm/translate-a64.c | 32 | +++ b/target/arm/translate-a64.c |
38 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal(int excp) | 33 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) |
39 | |||
40 | static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
41 | { | 34 | { |
42 | - gen_a64_set_pc_im(s->pc - offset); | 35 | int rd = extract32(insn, 0, 5); |
43 | + gen_a64_set_pc_im(s->base.pc_next - offset); | 36 | int cmode = extract32(insn, 12, 4); |
44 | gen_exception_internal(excp); | 37 | - int cmode_3_1 = extract32(cmode, 1, 3); |
45 | s->base.is_jmp = DISAS_NORETURN; | 38 | - int cmode_0 = extract32(cmode, 0, 1); |
46 | } | 39 | int o2 = extract32(insn, 11, 1); |
47 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | 40 | uint64_t abcdefgh = extract32(insn, 5, 5) | (extract32(insn, 16, 3) << 5); |
48 | static void gen_exception_insn(DisasContext *s, int offset, int excp, | 41 | bool is_neg = extract32(insn, 29, 1); |
49 | uint32_t syndrome, uint32_t target_el) | 42 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) |
50 | { | 43 | return; |
51 | - gen_a64_set_pc_im(s->pc - offset); | ||
52 | + gen_a64_set_pc_im(s->base.pc_next - offset); | ||
53 | gen_exception(excp, syndrome, target_el); | ||
54 | s->base.is_jmp = DISAS_NORETURN; | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, | ||
57 | { | ||
58 | TCGv_i32 tcg_syn; | ||
59 | |||
60 | - gen_a64_set_pc_im(s->pc - offset); | ||
61 | + gen_a64_set_pc_im(s->base.pc_next - offset); | ||
62 | tcg_syn = tcg_const_i32(syndrome); | ||
63 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | ||
64 | tcg_temp_free_i32(tcg_syn); | ||
65 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_imm(DisasContext *s, uint32_t insn) | ||
66 | |||
67 | if (insn & (1U << 31)) { | ||
68 | /* BL Branch with link */ | ||
69 | - tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); | ||
70 | + tcg_gen_movi_i64(cpu_reg(s, 30), s->base.pc_next); | ||
71 | } | 44 | } |
72 | 45 | ||
73 | /* B Branch / BL Branch with link */ | 46 | - /* See AdvSIMDExpandImm() in ARM ARM */ |
74 | @@ -XXX,XX +XXX,XX @@ static void disas_comp_b_imm(DisasContext *s, uint32_t insn) | 47 | - switch (cmode_3_1) { |
75 | tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, | 48 | - case 0: /* Replicate(Zeros(24):imm8, 2) */ |
76 | tcg_cmp, 0, label_match); | 49 | - case 1: /* Replicate(Zeros(16):imm8:Zeros(8), 2) */ |
77 | 50 | - case 2: /* Replicate(Zeros(8):imm8:Zeros(16), 2) */ | |
78 | - gen_goto_tb(s, 0, s->pc); | 51 | - case 3: /* Replicate(imm8:Zeros(24), 2) */ |
79 | + gen_goto_tb(s, 0, s->base.pc_next); | 52 | - { |
80 | gen_set_label(label_match); | 53 | - int shift = cmode_3_1 * 8; |
81 | gen_goto_tb(s, 1, addr); | 54 | - imm = bitfield_replicate(abcdefgh << shift, 32); |
82 | } | 55 | - break; |
83 | @@ -XXX,XX +XXX,XX @@ static void disas_test_b_imm(DisasContext *s, uint32_t insn) | 56 | - } |
84 | tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, | 57 | - case 4: /* Replicate(Zeros(8):imm8, 4) */ |
85 | tcg_cmp, 0, label_match); | 58 | - case 5: /* Replicate(imm8:Zeros(8), 4) */ |
86 | tcg_temp_free_i64(tcg_cmp); | 59 | - { |
87 | - gen_goto_tb(s, 0, s->pc); | 60 | - int shift = (cmode_3_1 & 0x1) * 8; |
88 | + gen_goto_tb(s, 0, s->base.pc_next); | 61 | - imm = bitfield_replicate(abcdefgh << shift, 16); |
89 | gen_set_label(label_match); | 62 | - break; |
90 | gen_goto_tb(s, 1, addr); | 63 | - } |
91 | } | 64 | - case 6: |
92 | @@ -XXX,XX +XXX,XX @@ static void disas_cond_b_imm(DisasContext *s, uint32_t insn) | 65 | - if (cmode_0) { |
93 | /* genuinely conditional branches */ | 66 | - /* Replicate(Zeros(8):imm8:Ones(16), 2) */ |
94 | TCGLabel *label_match = gen_new_label(); | 67 | - imm = (abcdefgh << 16) | 0xffff; |
95 | arm_gen_test_cc(cond, label_match); | 68 | - } else { |
96 | - gen_goto_tb(s, 0, s->pc); | 69 | - /* Replicate(Zeros(16):imm8:Ones(8), 2) */ |
97 | + gen_goto_tb(s, 0, s->base.pc_next); | 70 | - imm = (abcdefgh << 8) | 0xff; |
98 | gen_set_label(label_match); | 71 | - } |
99 | gen_goto_tb(s, 1, addr); | 72 | - imm = bitfield_replicate(imm, 32); |
100 | } else { | 73 | - break; |
101 | @@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn, | 74 | - case 7: |
102 | * any pending interrupts immediately. | 75 | - if (!cmode_0 && !is_neg) { |
103 | */ | 76 | - imm = bitfield_replicate(abcdefgh, 8); |
104 | reset_btype(s); | 77 | - } else if (!cmode_0 && is_neg) { |
105 | - gen_goto_tb(s, 0, s->pc); | 78 | - int i; |
106 | + gen_goto_tb(s, 0, s->base.pc_next); | 79 | - imm = 0; |
107 | return; | 80 | - for (i = 0; i < 8; i++) { |
108 | 81 | - if ((abcdefgh) & (1 << i)) { | |
109 | case 7: /* SB */ | 82 | - imm |= 0xffULL << (i * 8); |
110 | @@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn, | 83 | - } |
111 | * MB and end the TB instead. | 84 | - } |
112 | */ | 85 | - } else if (cmode_0) { |
113 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | 86 | - if (is_neg) { |
114 | - gen_goto_tb(s, 0, s->pc); | 87 | - imm = (abcdefgh & 0x3f) << 48; |
115 | + gen_goto_tb(s, 0, s->base.pc_next); | 88 | - if (abcdefgh & 0x80) { |
116 | return; | 89 | - imm |= 0x8000000000000000ULL; |
117 | 90 | - } | |
118 | default: | 91 | - if (abcdefgh & 0x40) { |
119 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | 92 | - imm |= 0x3fc0000000000000ULL; |
120 | gen_a64_set_pc(s, dst); | 93 | - } else { |
121 | /* BLR also needs to load return address */ | 94 | - imm |= 0x4000000000000000ULL; |
122 | if (opc == 1) { | 95 | - } |
123 | - tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); | 96 | - } else { |
124 | + tcg_gen_movi_i64(cpu_reg(s, 30), s->base.pc_next); | 97 | - if (o2) { |
125 | } | 98 | - /* FMOV (vector, immediate) - half-precision */ |
126 | break; | 99 | - imm = vfp_expand_imm(MO_16, abcdefgh); |
127 | 100 | - /* now duplicate across the lanes */ | |
128 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | 101 | - imm = bitfield_replicate(imm, 16); |
129 | gen_a64_set_pc(s, dst); | 102 | - } else { |
130 | /* BLRAA also needs to load return address */ | 103 | - imm = (abcdefgh & 0x3f) << 19; |
131 | if (opc == 9) { | 104 | - if (abcdefgh & 0x80) { |
132 | - tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); | 105 | - imm |= 0x80000000; |
133 | + tcg_gen_movi_i64(cpu_reg(s, 30), s->base.pc_next); | 106 | - } |
134 | } | 107 | - if (abcdefgh & 0x40) { |
135 | break; | 108 | - imm |= 0x3e000000; |
136 | 109 | - } else { | |
137 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | 110 | - imm |= 0x40000000; |
138 | { | 111 | - } |
139 | uint32_t insn; | 112 | - imm |= (imm << 32); |
140 | 113 | - } | |
141 | - s->pc_curr = s->pc; | 114 | - } |
142 | - insn = arm_ldl_code(env, s->pc, s->sctlr_b); | 115 | - } |
143 | + s->pc_curr = s->base.pc_next; | 116 | - break; |
144 | + insn = arm_ldl_code(env, s->base.pc_next, s->sctlr_b); | 117 | - default: |
145 | s->insn = insn; | 118 | - g_assert_not_reached(); |
146 | - s->pc += 4; | 119 | - } |
147 | + s->base.pc_next += 4; | 120 | - |
148 | 121 | - if (cmode_3_1 != 7 && is_neg) { | |
149 | s->fp_access_checked = false; | 122 | - imm = ~imm; |
150 | 123 | + if (cmode == 15 && o2 && !is_neg) { | |
151 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 124 | + /* FMOV (vector, immediate) - half-precision */ |
152 | int bound, core_mmu_idx; | 125 | + imm = vfp_expand_imm(MO_16, abcdefgh); |
153 | 126 | + /* now duplicate across the lanes */ | |
154 | dc->isar = &arm_cpu->isar; | 127 | + imm = bitfield_replicate(imm, 16); |
155 | - dc->pc = dc->base.pc_first; | 128 | + } else { |
156 | dc->condjmp = 0; | 129 | + imm = asimd_imm_const(abcdefgh, cmode, is_neg); |
157 | |||
158 | dc->aarch64 = 1; | ||
159 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | ||
160 | { | ||
161 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
162 | |||
163 | - tcg_gen_insn_start(dc->pc, 0, 0); | ||
164 | + tcg_gen_insn_start(dc->base.pc_next, 0, 0); | ||
165 | dc->insn_start = tcg_last_op(); | ||
166 | } | ||
167 | |||
168 | @@ -XXX,XX +XXX,XX @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
169 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
170 | |||
171 | if (bp->flags & BP_CPU) { | ||
172 | - gen_a64_set_pc_im(dc->pc); | ||
173 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
174 | gen_helper_check_breakpoints(cpu_env); | ||
175 | /* End the TB early; it likely won't be executed */ | ||
176 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
177 | @@ -XXX,XX +XXX,XX @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
178 | to for it to be properly cleared -- thus we | ||
179 | increment the PC here so that the logic setting | ||
180 | tb->size below does the right thing. */ | ||
181 | - dc->pc += 4; | ||
182 | + dc->base.pc_next += 4; | ||
183 | dc->base.is_jmp = DISAS_NORETURN; | ||
184 | } | 130 | } |
185 | 131 | ||
186 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 132 | if (!((cmode & 0x9) == 0x1 || (cmode & 0xd) == 0x9)) { |
187 | disas_a64_insn(env, dc); | ||
188 | } | ||
189 | |||
190 | - dc->base.pc_next = dc->pc; | ||
191 | translator_loop_temp_check(&dc->base); | ||
192 | } | ||
193 | |||
194 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
195 | */ | ||
196 | switch (dc->base.is_jmp) { | ||
197 | default: | ||
198 | - gen_a64_set_pc_im(dc->pc); | ||
199 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
200 | /* fall through */ | ||
201 | case DISAS_EXIT: | ||
202 | case DISAS_JUMP: | ||
203 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
204 | switch (dc->base.is_jmp) { | ||
205 | case DISAS_NEXT: | ||
206 | case DISAS_TOO_MANY: | ||
207 | - gen_goto_tb(dc, 1, dc->pc); | ||
208 | + gen_goto_tb(dc, 1, dc->base.pc_next); | ||
209 | break; | ||
210 | default: | ||
211 | case DISAS_UPDATE: | ||
212 | - gen_a64_set_pc_im(dc->pc); | ||
213 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
214 | /* fall through */ | ||
215 | case DISAS_EXIT: | ||
216 | tcg_gen_exit_tb(NULL, 0); | ||
217 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
218 | case DISAS_SWI: | ||
219 | break; | ||
220 | case DISAS_WFE: | ||
221 | - gen_a64_set_pc_im(dc->pc); | ||
222 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
223 | gen_helper_wfe(cpu_env); | ||
224 | break; | ||
225 | case DISAS_YIELD: | ||
226 | - gen_a64_set_pc_im(dc->pc); | ||
227 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
228 | gen_helper_yield(cpu_env); | ||
229 | break; | ||
230 | case DISAS_WFI: | ||
231 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
232 | */ | ||
233 | TCGv_i32 tmp = tcg_const_i32(4); | ||
234 | |||
235 | - gen_a64_set_pc_im(dc->pc); | ||
236 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
237 | gen_helper_wfi(cpu_env, tmp); | ||
238 | tcg_temp_free_i32(tmp); | ||
239 | /* The helper doesn't necessarily throw an exception, but we | ||
240 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
241 | } | ||
242 | } | ||
243 | } | ||
244 | - | ||
245 | - /* Functions above can change dc->pc, so re-align db->pc_next */ | ||
246 | - dc->base.pc_next = dc->pc; | ||
247 | } | ||
248 | |||
249 | static void aarch64_tr_disas_log(const DisasContextBase *dcbase, | ||
250 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 133 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
251 | index XXXXXXX..XXXXXXX 100644 | 134 | index XXXXXXX..XXXXXXX 100644 |
252 | --- a/target/arm/translate.c | 135 | --- a/target/arm/translate.c |
253 | +++ b/target/arm/translate.c | 136 | +++ b/target/arm/translate.c |
254 | @@ -XXX,XX +XXX,XX @@ static inline void gen_blxns(DisasContext *s, int rm) | 137 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) |
255 | * We do however need to set the PC, because the blxns helper reads it. | 138 | case 14: |
256 | * The blxns helper may throw an exception. | 139 | if (op) { |
257 | */ | 140 | /* |
258 | - gen_set_pc_im(s, s->pc); | 141 | - * This is the only case where the top and bottom 32 bits |
259 | + gen_set_pc_im(s, s->base.pc_next); | 142 | - * of the encoded constant differ. |
260 | gen_helper_v7m_blxns(cpu_env, var); | 143 | + * This and cmode == 15 op == 1 are the only cases where |
261 | tcg_temp_free_i32(var); | 144 | + * the top and bottom 32 bits of the encoded constant differ. |
262 | s->base.is_jmp = DISAS_EXIT; | 145 | */ |
263 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hvc(DisasContext *s, int imm16) | 146 | uint64_t imm64 = 0; |
264 | * for single stepping.) | 147 | int n; |
265 | */ | 148 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) |
266 | s->svc_imm = imm16; | 149 | imm |= (imm << 8) | (imm << 16) | (imm << 24); |
267 | - gen_set_pc_im(s, s->pc); | ||
268 | + gen_set_pc_im(s, s->base.pc_next); | ||
269 | s->base.is_jmp = DISAS_HVC; | ||
270 | } | ||
271 | |||
272 | @@ -XXX,XX +XXX,XX @@ static inline void gen_smc(DisasContext *s) | ||
273 | tmp = tcg_const_i32(syn_aa32_smc()); | ||
274 | gen_helper_pre_smc(cpu_env, tmp); | ||
275 | tcg_temp_free_i32(tmp); | ||
276 | - gen_set_pc_im(s, s->pc); | ||
277 | + gen_set_pc_im(s, s->base.pc_next); | ||
278 | s->base.is_jmp = DISAS_SMC; | ||
279 | } | ||
280 | |||
281 | static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
282 | { | ||
283 | gen_set_condexec(s); | ||
284 | - gen_set_pc_im(s, s->pc - offset); | ||
285 | + gen_set_pc_im(s, s->base.pc_next - offset); | ||
286 | gen_exception_internal(excp); | ||
287 | s->base.is_jmp = DISAS_NORETURN; | ||
288 | } | ||
289 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_insn(DisasContext *s, int offset, int excp, | ||
290 | int syn, uint32_t target_el) | ||
291 | { | ||
292 | gen_set_condexec(s); | ||
293 | - gen_set_pc_im(s, s->pc - offset); | ||
294 | + gen_set_pc_im(s, s->base.pc_next - offset); | ||
295 | gen_exception(excp, syn, target_el); | ||
296 | s->base.is_jmp = DISAS_NORETURN; | ||
297 | } | ||
298 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | ||
299 | TCGv_i32 tcg_syn; | ||
300 | |||
301 | gen_set_condexec(s); | ||
302 | - gen_set_pc_im(s, s->pc - offset); | ||
303 | + gen_set_pc_im(s, s->base.pc_next - offset); | ||
304 | tcg_syn = tcg_const_i32(syn); | ||
305 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | ||
306 | tcg_temp_free_i32(tcg_syn); | ||
307 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | ||
308 | /* Force a TB lookup after an instruction that changes the CPU state. */ | ||
309 | static inline void gen_lookup_tb(DisasContext *s) | ||
310 | { | ||
311 | - tcg_gen_movi_i32(cpu_R[15], s->pc); | ||
312 | + tcg_gen_movi_i32(cpu_R[15], s->base.pc_next); | ||
313 | s->base.is_jmp = DISAS_EXIT; | ||
314 | } | ||
315 | |||
316 | @@ -XXX,XX +XXX,XX @@ static inline bool use_goto_tb(DisasContext *s, target_ulong dest) | ||
317 | { | ||
318 | #ifndef CONFIG_USER_ONLY | ||
319 | return (s->base.tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK) || | ||
320 | - ((s->pc - 1) & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK); | ||
321 | + ((s->base.pc_next - 1) & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK); | ||
322 | #else | ||
323 | return true; | ||
324 | #endif | ||
325 | @@ -XXX,XX +XXX,XX @@ static void gen_nop_hint(DisasContext *s, int val) | ||
326 | */ | ||
327 | case 1: /* yield */ | ||
328 | if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | ||
329 | - gen_set_pc_im(s, s->pc); | ||
330 | + gen_set_pc_im(s, s->base.pc_next); | ||
331 | s->base.is_jmp = DISAS_YIELD; | ||
332 | } | ||
333 | break; | 150 | break; |
334 | case 3: /* wfi */ | 151 | case 15: |
335 | - gen_set_pc_im(s, s->pc); | 152 | + if (op) { |
336 | + gen_set_pc_im(s, s->base.pc_next); | 153 | + /* Reserved encoding for AArch32; valid for AArch64 */ |
337 | s->base.is_jmp = DISAS_WFI; | 154 | + uint64_t imm64 = (uint64_t)(imm & 0x3f) << 48; |
155 | + if (imm & 0x80) { | ||
156 | + imm64 |= 0x8000000000000000ULL; | ||
157 | + } | ||
158 | + if (imm & 0x40) { | ||
159 | + imm64 |= 0x3fc0000000000000ULL; | ||
160 | + } else { | ||
161 | + imm64 |= 0x4000000000000000ULL; | ||
162 | + } | ||
163 | + return imm64; | ||
164 | + } | ||
165 | imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
166 | | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
338 | break; | 167 | break; |
339 | case 2: /* wfe */ | ||
340 | if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | ||
341 | - gen_set_pc_im(s, s->pc); | ||
342 | + gen_set_pc_im(s, s->base.pc_next); | ||
343 | s->base.is_jmp = DISAS_WFE; | ||
344 | } | ||
345 | break; | ||
346 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
347 | if (isread) { | ||
348 | return 1; | ||
349 | } | ||
350 | - gen_set_pc_im(s, s->pc); | ||
351 | + gen_set_pc_im(s, s->base.pc_next); | ||
352 | s->base.is_jmp = DISAS_WFI; | ||
353 | return 0; | ||
354 | default: | ||
355 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
356 | * self-modifying code correctly and also to take | ||
357 | * any pending interrupts immediately. | ||
358 | */ | ||
359 | - gen_goto_tb(s, 0, s->pc); | ||
360 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
361 | return; | ||
362 | case 7: /* sb */ | ||
363 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | ||
364 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
365 | * for TCG; MB and end the TB instead. | ||
366 | */ | ||
367 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
368 | - gen_goto_tb(s, 0, s->pc); | ||
369 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
370 | return; | ||
371 | default: | ||
372 | goto illegal_op; | ||
373 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
374 | int32_t offset; | ||
375 | |||
376 | tmp = tcg_temp_new_i32(); | ||
377 | - tcg_gen_movi_i32(tmp, s->pc); | ||
378 | + tcg_gen_movi_i32(tmp, s->base.pc_next); | ||
379 | store_reg(s, 14, tmp); | ||
380 | /* Sign-extend the 24-bit offset */ | ||
381 | offset = (((int32_t)insn) << 8) >> 8; | ||
382 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
383 | /* branch link/exchange thumb (blx) */ | ||
384 | tmp = load_reg(s, rm); | ||
385 | tmp2 = tcg_temp_new_i32(); | ||
386 | - tcg_gen_movi_i32(tmp2, s->pc); | ||
387 | + tcg_gen_movi_i32(tmp2, s->base.pc_next); | ||
388 | store_reg(s, 14, tmp2); | ||
389 | gen_bx(s, tmp); | ||
390 | break; | ||
391 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
392 | /* branch (and link) */ | ||
393 | if (insn & (1 << 24)) { | ||
394 | tmp = tcg_temp_new_i32(); | ||
395 | - tcg_gen_movi_i32(tmp, s->pc); | ||
396 | + tcg_gen_movi_i32(tmp, s->base.pc_next); | ||
397 | store_reg(s, 14, tmp); | ||
398 | } | ||
399 | offset = sextract32(insn << 2, 0, 26); | ||
400 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
401 | break; | ||
402 | case 0xf: | ||
403 | /* swi */ | ||
404 | - gen_set_pc_im(s, s->pc); | ||
405 | + gen_set_pc_im(s, s->base.pc_next); | ||
406 | s->svc_imm = extract32(insn, 0, 24); | ||
407 | s->base.is_jmp = DISAS_SWI; | ||
408 | break; | ||
409 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
410 | |||
411 | if (insn & (1 << 14)) { | ||
412 | /* Branch and link. */ | ||
413 | - tcg_gen_movi_i32(cpu_R[14], s->pc | 1); | ||
414 | + tcg_gen_movi_i32(cpu_R[14], s->base.pc_next | 1); | ||
415 | } | ||
416 | |||
417 | offset += read_pc(s); | ||
418 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
419 | * and also to take any pending interrupts | ||
420 | * immediately. | ||
421 | */ | ||
422 | - gen_goto_tb(s, 0, s->pc); | ||
423 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
424 | break; | ||
425 | case 7: /* sb */ | ||
426 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | ||
427 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
428 | * for TCG; MB and end the TB instead. | ||
429 | */ | ||
430 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
431 | - gen_goto_tb(s, 0, s->pc); | ||
432 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
433 | break; | ||
434 | default: | ||
435 | goto illegal_op; | ||
436 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
437 | /* BLX/BX */ | ||
438 | tmp = load_reg(s, rm); | ||
439 | if (link) { | ||
440 | - val = (uint32_t)s->pc | 1; | ||
441 | + val = (uint32_t)s->base.pc_next | 1; | ||
442 | tmp2 = tcg_temp_new_i32(); | ||
443 | tcg_gen_movi_i32(tmp2, val); | ||
444 | store_reg(s, 14, tmp2); | ||
445 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
446 | |||
447 | if (cond == 0xf) { | ||
448 | /* swi */ | ||
449 | - gen_set_pc_im(s, s->pc); | ||
450 | + gen_set_pc_im(s, s->base.pc_next); | ||
451 | s->svc_imm = extract32(insn, 0, 8); | ||
452 | s->base.is_jmp = DISAS_SWI; | ||
453 | break; | ||
454 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
455 | tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); | ||
456 | |||
457 | tmp2 = tcg_temp_new_i32(); | ||
458 | - tcg_gen_movi_i32(tmp2, s->pc | 1); | ||
459 | + tcg_gen_movi_i32(tmp2, s->base.pc_next | 1); | ||
460 | store_reg(s, 14, tmp2); | ||
461 | gen_bx(s, tmp); | ||
462 | break; | ||
463 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
464 | tcg_gen_addi_i32(tmp, tmp, offset); | ||
465 | |||
466 | tmp2 = tcg_temp_new_i32(); | ||
467 | - tcg_gen_movi_i32(tmp2, s->pc | 1); | ||
468 | + tcg_gen_movi_i32(tmp2, s->base.pc_next | 1); | ||
469 | store_reg(s, 14, tmp2); | ||
470 | gen_bx(s, tmp); | ||
471 | } else { | ||
472 | @@ -XXX,XX +XXX,XX @@ undef: | ||
473 | |||
474 | static bool insn_crosses_page(CPUARMState *env, DisasContext *s) | ||
475 | { | ||
476 | - /* Return true if the insn at dc->pc might cross a page boundary. | ||
477 | + /* Return true if the insn at dc->base.pc_next might cross a page boundary. | ||
478 | * (False positives are OK, false negatives are not.) | ||
479 | * We know this is a Thumb insn, and our caller ensures we are | ||
480 | - * only called if dc->pc is less than 4 bytes from the page | ||
481 | + * only called if dc->base.pc_next is less than 4 bytes from the page | ||
482 | * boundary, so we cross the page if the first 16 bits indicate | ||
483 | * that this is a 32 bit insn. | ||
484 | */ | ||
485 | - uint16_t insn = arm_lduw_code(env, s->pc, s->sctlr_b); | ||
486 | + uint16_t insn = arm_lduw_code(env, s->base.pc_next, s->sctlr_b); | ||
487 | |||
488 | - return !thumb_insn_is_16bit(s, s->pc, insn); | ||
489 | + return !thumb_insn_is_16bit(s, s->base.pc_next, insn); | ||
490 | } | ||
491 | |||
492 | static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
493 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
494 | uint32_t condexec, core_mmu_idx; | ||
495 | |||
496 | dc->isar = &cpu->isar; | ||
497 | - dc->pc = dc->base.pc_first; | ||
498 | dc->condjmp = 0; | ||
499 | |||
500 | dc->aarch64 = 0; | ||
501 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | ||
502 | { | ||
503 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
504 | |||
505 | - tcg_gen_insn_start(dc->pc, | ||
506 | + tcg_gen_insn_start(dc->base.pc_next, | ||
507 | (dc->condexec_cond << 4) | (dc->condexec_mask >> 1), | ||
508 | 0); | ||
509 | dc->insn_start = tcg_last_op(); | ||
510 | @@ -XXX,XX +XXX,XX @@ static bool arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
511 | |||
512 | if (bp->flags & BP_CPU) { | ||
513 | gen_set_condexec(dc); | ||
514 | - gen_set_pc_im(dc, dc->pc); | ||
515 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
516 | gen_helper_check_breakpoints(cpu_env); | ||
517 | /* End the TB early; it's likely not going to be executed */ | ||
518 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
519 | @@ -XXX,XX +XXX,XX @@ static bool arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
520 | tb->size below does the right thing. */ | ||
521 | /* TODO: Advance PC by correct instruction length to | ||
522 | * avoid disassembler error messages */ | ||
523 | - dc->pc += 2; | ||
524 | + dc->base.pc_next += 2; | ||
525 | dc->base.is_jmp = DISAS_NORETURN; | ||
526 | } | ||
527 | |||
528 | @@ -XXX,XX +XXX,XX @@ static bool arm_pre_translate_insn(DisasContext *dc) | ||
529 | { | ||
530 | #ifdef CONFIG_USER_ONLY | ||
531 | /* Intercept jump to the magic kernel page. */ | ||
532 | - if (dc->pc >= 0xffff0000) { | ||
533 | + if (dc->base.pc_next >= 0xffff0000) { | ||
534 | /* We always get here via a jump, so know we are not in a | ||
535 | conditional execution block. */ | ||
536 | gen_exception_internal(EXCP_KERNEL_TRAP); | ||
537 | @@ -XXX,XX +XXX,XX @@ static void arm_post_translate_insn(DisasContext *dc) | ||
538 | gen_set_label(dc->condlabel); | ||
539 | dc->condjmp = 0; | ||
540 | } | ||
541 | - dc->base.pc_next = dc->pc; | ||
542 | translator_loop_temp_check(&dc->base); | ||
543 | } | ||
544 | |||
545 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
546 | return; | ||
547 | } | ||
548 | |||
549 | - dc->pc_curr = dc->pc; | ||
550 | - insn = arm_ldl_code(env, dc->pc, dc->sctlr_b); | ||
551 | + dc->pc_curr = dc->base.pc_next; | ||
552 | + insn = arm_ldl_code(env, dc->base.pc_next, dc->sctlr_b); | ||
553 | dc->insn = insn; | ||
554 | - dc->pc += 4; | ||
555 | + dc->base.pc_next += 4; | ||
556 | disas_arm_insn(dc, insn); | ||
557 | |||
558 | arm_post_translate_insn(dc); | ||
559 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
560 | return; | ||
561 | } | ||
562 | |||
563 | - dc->pc_curr = dc->pc; | ||
564 | - insn = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
565 | - is_16bit = thumb_insn_is_16bit(dc, dc->pc, insn); | ||
566 | - dc->pc += 2; | ||
567 | + dc->pc_curr = dc->base.pc_next; | ||
568 | + insn = arm_lduw_code(env, dc->base.pc_next, dc->sctlr_b); | ||
569 | + is_16bit = thumb_insn_is_16bit(dc, dc->base.pc_next, insn); | ||
570 | + dc->base.pc_next += 2; | ||
571 | if (!is_16bit) { | ||
572 | - uint32_t insn2 = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
573 | + uint32_t insn2 = arm_lduw_code(env, dc->base.pc_next, dc->sctlr_b); | ||
574 | |||
575 | insn = insn << 16 | insn2; | ||
576 | - dc->pc += 2; | ||
577 | + dc->base.pc_next += 2; | ||
578 | } | ||
579 | dc->insn = insn; | ||
580 | |||
581 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
582 | * but isn't very efficient). | ||
583 | */ | ||
584 | if (dc->base.is_jmp == DISAS_NEXT | ||
585 | - && (dc->pc - dc->page_start >= TARGET_PAGE_SIZE | ||
586 | - || (dc->pc - dc->page_start >= TARGET_PAGE_SIZE - 3 | ||
587 | + && (dc->base.pc_next - dc->page_start >= TARGET_PAGE_SIZE | ||
588 | + || (dc->base.pc_next - dc->page_start >= TARGET_PAGE_SIZE - 3 | ||
589 | && insn_crosses_page(env, dc)))) { | ||
590 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
591 | } | ||
592 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
593 | case DISAS_NEXT: | ||
594 | case DISAS_TOO_MANY: | ||
595 | case DISAS_UPDATE: | ||
596 | - gen_set_pc_im(dc, dc->pc); | ||
597 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
598 | /* fall through */ | ||
599 | default: | ||
600 | /* FIXME: Single stepping a WFI insn will not halt the CPU. */ | ||
601 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
602 | switch(dc->base.is_jmp) { | ||
603 | case DISAS_NEXT: | ||
604 | case DISAS_TOO_MANY: | ||
605 | - gen_goto_tb(dc, 1, dc->pc); | ||
606 | + gen_goto_tb(dc, 1, dc->base.pc_next); | ||
607 | break; | ||
608 | case DISAS_JUMP: | ||
609 | gen_goto_ptr(); | ||
610 | break; | ||
611 | case DISAS_UPDATE: | ||
612 | - gen_set_pc_im(dc, dc->pc); | ||
613 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
614 | /* fall through */ | ||
615 | default: | ||
616 | /* indicate that the hash table must be used to find the next TB */ | ||
617 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
618 | gen_set_label(dc->condlabel); | ||
619 | gen_set_condexec(dc); | ||
620 | if (unlikely(is_singlestepping(dc))) { | ||
621 | - gen_set_pc_im(dc, dc->pc); | ||
622 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
623 | gen_singlestep_exception(dc); | ||
624 | } else { | ||
625 | - gen_goto_tb(dc, 1, dc->pc); | ||
626 | + gen_goto_tb(dc, 1, dc->base.pc_next); | ||
627 | } | ||
628 | } | ||
629 | - | ||
630 | - /* Functions above can change dc->pc, so re-align db->pc_next */ | ||
631 | - dc->base.pc_next = dc->pc; | ||
632 | } | ||
633 | |||
634 | static void arm_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) | ||
635 | -- | 168 | -- |
636 | 2.20.1 | 169 | 2.20.1 |
637 | 170 | ||
638 | 171 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Use dup_const() instead of bitfield_replicate() in |
---|---|---|---|
2 | disas_simd_mod_imm(). | ||
2 | 3 | ||
3 | Unlike the other more generic gen_exception{,_internal}_insn | 4 | (We can't replace the other use of bitfield_replicate() in this file, |
4 | interfaces, breakpoints always refer to the current instruction. | 5 | in logic_imm_decode_wmask(), because that location needs to handle 2 |
6 | and 4 bit elements, which dup_const() cannot.) | ||
5 | 7 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190807045335.1361-10-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210628135835.6690-6-peter.maydell@linaro.org | ||
11 | --- | 11 | --- |
12 | target/arm/translate-a64.c | 7 +++---- | 12 | target/arm/translate-a64.c | 2 +- |
13 | target/arm/translate.c | 8 ++++---- | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 2 files changed, 7 insertions(+), 8 deletions(-) | ||
15 | 14 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 17 | --- a/target/arm/translate-a64.c |
19 | +++ b/target/arm/translate-a64.c | 18 | +++ b/target/arm/translate-a64.c |
20 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, | 19 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) |
21 | s->base.is_jmp = DISAS_NORETURN; | 20 | /* FMOV (vector, immediate) - half-precision */ |
22 | } | 21 | imm = vfp_expand_imm(MO_16, abcdefgh); |
23 | 22 | /* now duplicate across the lanes */ | |
24 | -static void gen_exception_bkpt_insn(DisasContext *s, int offset, | 23 | - imm = bitfield_replicate(imm, 16); |
25 | - uint32_t syndrome) | 24 | + imm = dup_const(MO_16, imm); |
26 | +static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syndrome) | 25 | } else { |
27 | { | 26 | imm = asimd_imm_const(abcdefgh, cmode, is_neg); |
28 | TCGv_i32 tcg_syn; | 27 | } |
29 | |||
30 | - gen_a64_set_pc_im(s->base.pc_next - offset); | ||
31 | + gen_a64_set_pc_im(s->pc_curr); | ||
32 | tcg_syn = tcg_const_i32(syndrome); | ||
33 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | ||
34 | tcg_temp_free_i32(tcg_syn); | ||
35 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
36 | break; | ||
37 | } | ||
38 | /* BRK */ | ||
39 | - gen_exception_bkpt_insn(s, 4, syn_aa64_bkpt(imm16)); | ||
40 | + gen_exception_bkpt_insn(s, syn_aa64_bkpt(imm16)); | ||
41 | break; | ||
42 | case 2: | ||
43 | if (op2_ll != 0) { | ||
44 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/translate.c | ||
47 | +++ b/target/arm/translate.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_insn(DisasContext *s, uint32_t pc, int excp, | ||
49 | s->base.is_jmp = DISAS_NORETURN; | ||
50 | } | ||
51 | |||
52 | -static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | ||
53 | +static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) | ||
54 | { | ||
55 | TCGv_i32 tcg_syn; | ||
56 | |||
57 | gen_set_condexec(s); | ||
58 | - gen_set_pc_im(s, s->base.pc_next - offset); | ||
59 | + gen_set_pc_im(s, s->pc_curr); | ||
60 | tcg_syn = tcg_const_i32(syn); | ||
61 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | ||
62 | tcg_temp_free_i32(tcg_syn); | ||
63 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
64 | case 1: | ||
65 | /* bkpt */ | ||
66 | ARCH(5); | ||
67 | - gen_exception_bkpt_insn(s, 4, syn_aa32_bkpt(imm16, false)); | ||
68 | + gen_exception_bkpt_insn(s, syn_aa32_bkpt(imm16, false)); | ||
69 | break; | ||
70 | case 2: | ||
71 | /* Hypervisor call (v7) */ | ||
72 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
73 | { | ||
74 | int imm8 = extract32(insn, 0, 8); | ||
75 | ARCH(5); | ||
76 | - gen_exception_bkpt_insn(s, 2, syn_aa32_bkpt(imm8, true)); | ||
77 | + gen_exception_bkpt_insn(s, syn_aa32_bkpt(imm8, true)); | ||
78 | break; | ||
79 | } | ||
80 | |||
81 | -- | 28 | -- |
82 | 2.20.1 | 29 | 2.20.1 |
83 | 30 | ||
84 | 31 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | Implement the MVE logical-immediate insns (VMOV, VMVN, |
---|---|---|---|
2 | VORR and VBIC). These have essentially the same encoding | ||
3 | as their Neon equivalents, and we implement the decode | ||
4 | in the same way. | ||
2 | 5 | ||
3 | Move the getting/putting of the fpsimd registers out of | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | kvm_arch_get/put_registers() into their own helper functions | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | to prepare for alternatively getting/putting SVE registers. | 8 | Message-id: 20210628135835.6690-7-peter.maydell@linaro.org |
9 | --- | ||
10 | target/arm/helper-mve.h | 4 +++ | ||
11 | target/arm/mve.decode | 17 +++++++++++++ | ||
12 | target/arm/mve_helper.c | 24 ++++++++++++++++++ | ||
13 | target/arm/translate-mve.c | 50 ++++++++++++++++++++++++++++++++++++++ | ||
14 | 4 files changed, 95 insertions(+) | ||
6 | 15 | ||
7 | No functional change. | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
8 | |||
9 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/kvm64.c | 148 +++++++++++++++++++++++++++------------------ | ||
15 | 1 file changed, 88 insertions(+), 60 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/kvm64.c | 18 | --- a/target/arm/helper-mve.h |
20 | +++ b/target/arm/kvm64.c | 19 | +++ b/target/arm/helper-mve.h |
21 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_cpreg_level(uint64_t regidx) | 20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) |
22 | #define AARCH64_SIMD_CTRL_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U32 | \ | 21 | DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) |
23 | KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) | 22 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
24 | 23 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | |
25 | +static int kvm_arch_put_fpsimd(CPUState *cs) | ||
26 | +{ | ||
27 | + ARMCPU *cpu = ARM_CPU(cs); | ||
28 | + CPUARMState *env = &cpu->env; | ||
29 | + struct kvm_one_reg reg; | ||
30 | + uint32_t fpr; | ||
31 | + int i, ret; | ||
32 | + | 24 | + |
33 | + for (i = 0; i < 32; i++) { | 25 | +DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) |
34 | + uint64_t *q = aa64_vfp_qreg(env, i); | 26 | +DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) |
35 | +#ifdef HOST_WORDS_BIGENDIAN | 27 | +DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) |
36 | + uint64_t fp_val[2] = { q[1], q[0] }; | 28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
37 | + reg.addr = (uintptr_t)fp_val; | 29 | index XXXXXXX..XXXXXXX 100644 |
38 | +#else | 30 | --- a/target/arm/mve.decode |
39 | + reg.addr = (uintptr_t)q; | 31 | +++ b/target/arm/mve.decode |
40 | +#endif | 32 | @@ -XXX,XX +XXX,XX @@ |
41 | + reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | 33 | # VQDMULL has size in bit 28: 0 for 16 bit, 1 for 32 bit |
42 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | 34 | %size_28 28:1 !function=plus_1 |
43 | + if (ret) { | 35 | |
44 | + return ret; | 36 | +# 1imm format immediate |
45 | + } | 37 | +%imm_28_16_0 28:1 16:3 0:4 |
38 | + | ||
39 | &vldr_vstr rn qd imm p a w size l u | ||
40 | &1op qd qm size | ||
41 | &2op qd qm qn size | ||
42 | &2scalar qd qn rm size | ||
43 | +&1imm qd imm cmode op | ||
44 | |||
45 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
46 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
47 | @@ -XXX,XX +XXX,XX @@ | ||
48 | @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 | ||
49 | @2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \ | ||
50 | size=%size_28 | ||
51 | +@1imm .... .... .... .... .... cmode:4 .. op:1 . .... &1imm qd=%qd imm=%imm_28_16_0 | ||
52 | |||
53 | # The _rev suffix indicates that Vn and Vm are reversed. This is | ||
54 | # the case for shifts. In the Arm ARM these insns are documented | ||
55 | @@ -XXX,XX +XXX,XX @@ VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rd | ||
56 | # Predicate operations | ||
57 | %mask_22_13 22:1 13:3 | ||
58 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
59 | + | ||
60 | +# Logical immediate operations (1 reg and modified-immediate) | ||
61 | + | ||
62 | +# The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but | ||
63 | +# not in a way we can conveniently represent in decodetree without | ||
64 | +# a lot of repetition: | ||
65 | +# VORR: op=0, (cmode & 1) && cmode < 12 | ||
66 | +# VBIC: op=1, (cmode & 1) && cmode < 12 | ||
67 | +# VMOV: everything else | ||
68 | +# So we have a single decode line and check the cmode/op in the | ||
69 | +# trans function. | ||
70 | +Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm | ||
71 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/mve_helper.c | ||
74 | +++ b/target/arm/mve_helper.c | ||
75 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vnegw, 4, int32_t, DO_NEG) | ||
76 | DO_1OP(vfnegh, 8, uint64_t, DO_FNEGH) | ||
77 | DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) | ||
78 | |||
79 | +/* | ||
80 | + * 1 operand immediates: Vda is destination and possibly also one source. | ||
81 | + * All these insns work at 64-bit widths. | ||
82 | + */ | ||
83 | +#define DO_1OP_IMM(OP, FN) \ | ||
84 | + void HELPER(mve_##OP)(CPUARMState *env, void *vda, uint64_t imm) \ | ||
85 | + { \ | ||
86 | + uint64_t *da = vda; \ | ||
87 | + uint16_t mask = mve_element_mask(env); \ | ||
88 | + unsigned e; \ | ||
89 | + for (e = 0; e < 16 / 8; e++, mask >>= 8) { \ | ||
90 | + mergemask(&da[H8(e)], FN(da[H8(e)], imm), mask); \ | ||
91 | + } \ | ||
92 | + mve_advance_vpt(env); \ | ||
46 | + } | 93 | + } |
47 | + | 94 | + |
48 | + reg.addr = (uintptr_t)(&fpr); | 95 | +#define DO_MOVI(N, I) (I) |
49 | + fpr = vfp_get_fpsr(env); | 96 | +#define DO_ANDI(N, I) ((N) & (I)) |
50 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | 97 | +#define DO_ORRI(N, I) ((N) | (I)) |
51 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | 98 | + |
52 | + if (ret) { | 99 | +DO_1OP_IMM(vmovi, DO_MOVI) |
53 | + return ret; | 100 | +DO_1OP_IMM(vandi, DO_ANDI) |
101 | +DO_1OP_IMM(vorri, DO_ORRI) | ||
102 | + | ||
103 | #define DO_2OP(OP, ESIZE, TYPE, FN) \ | ||
104 | void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
105 | void *vd, void *vn, void *vm) \ | ||
106 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/translate-mve.c | ||
109 | +++ b/target/arm/translate-mve.c | ||
110 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
111 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
112 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
113 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
114 | +typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
115 | |||
116 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
117 | static inline long mve_qreg_offset(unsigned reg) | ||
118 | @@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | ||
119 | mve_update_eci(s); | ||
120 | return true; | ||
121 | } | ||
122 | + | ||
123 | +static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) | ||
124 | +{ | ||
125 | + TCGv_ptr qd; | ||
126 | + uint64_t imm; | ||
127 | + | ||
128 | + if (!dc_isar_feature(aa32_mve, s) || | ||
129 | + !mve_check_qreg_bank(s, a->qd) || | ||
130 | + !fn) { | ||
131 | + return false; | ||
132 | + } | ||
133 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
134 | + return true; | ||
54 | + } | 135 | + } |
55 | + | 136 | + |
56 | + reg.addr = (uintptr_t)(&fpr); | 137 | + imm = asimd_imm_const(a->imm, a->cmode, a->op); |
57 | + fpr = vfp_get_fpcr(env); | ||
58 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
59 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
60 | + if (ret) { | ||
61 | + return ret; | ||
62 | + } | ||
63 | + | 138 | + |
64 | + return 0; | 139 | + qd = mve_qreg_ptr(a->qd); |
140 | + fn(cpu_env, qd, tcg_constant_i64(imm)); | ||
141 | + tcg_temp_free_ptr(qd); | ||
142 | + mve_update_eci(s); | ||
143 | + return true; | ||
65 | +} | 144 | +} |
66 | + | 145 | + |
67 | int kvm_arch_put_registers(CPUState *cs, int level) | 146 | +static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a) |
68 | { | ||
69 | struct kvm_one_reg reg; | ||
70 | - uint32_t fpr; | ||
71 | uint64_t val; | ||
72 | - int i; | ||
73 | - int ret; | ||
74 | + int i, ret; | ||
75 | unsigned int el; | ||
76 | |||
77 | ARMCPU *cpu = ARM_CPU(cs); | ||
78 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
79 | } | ||
80 | } | ||
81 | |||
82 | - /* Advanced SIMD and FP registers. */ | ||
83 | - for (i = 0; i < 32; i++) { | ||
84 | - uint64_t *q = aa64_vfp_qreg(env, i); | ||
85 | -#ifdef HOST_WORDS_BIGENDIAN | ||
86 | - uint64_t fp_val[2] = { q[1], q[0] }; | ||
87 | - reg.addr = (uintptr_t)fp_val; | ||
88 | -#else | ||
89 | - reg.addr = (uintptr_t)q; | ||
90 | -#endif | ||
91 | - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
92 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
93 | - if (ret) { | ||
94 | - return ret; | ||
95 | - } | ||
96 | - } | ||
97 | - | ||
98 | - reg.addr = (uintptr_t)(&fpr); | ||
99 | - fpr = vfp_get_fpsr(env); | ||
100 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
101 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
102 | - if (ret) { | ||
103 | - return ret; | ||
104 | - } | ||
105 | - | ||
106 | - fpr = vfp_get_fpcr(env); | ||
107 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
108 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
109 | + ret = kvm_arch_put_fpsimd(cs); | ||
110 | if (ret) { | ||
111 | return ret; | ||
112 | } | ||
113 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
114 | return ret; | ||
115 | } | ||
116 | |||
117 | +static int kvm_arch_get_fpsimd(CPUState *cs) | ||
118 | +{ | 147 | +{ |
119 | + ARMCPU *cpu = ARM_CPU(cs); | 148 | + /* Handle decode of cmode/op here between VORR/VBIC/VMOV */ |
120 | + CPUARMState *env = &cpu->env; | 149 | + MVEGenOneOpImmFn *fn; |
121 | + struct kvm_one_reg reg; | ||
122 | + uint32_t fpr; | ||
123 | + int i, ret; | ||
124 | + | 150 | + |
125 | + for (i = 0; i < 32; i++) { | 151 | + if ((a->cmode & 1) && a->cmode < 12) { |
126 | + uint64_t *q = aa64_vfp_qreg(env, i); | 152 | + if (a->op) { |
127 | + reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | 153 | + /* |
128 | + reg.addr = (uintptr_t)q; | 154 | + * For op=1, the immediate will be inverted by asimd_imm_const(), |
129 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | 155 | + * so the VBIC becomes a logical AND operation. |
130 | + if (ret) { | 156 | + */ |
131 | + return ret; | 157 | + fn = gen_helper_mve_vandi; |
132 | + } else { | 158 | + } else { |
133 | +#ifdef HOST_WORDS_BIGENDIAN | 159 | + fn = gen_helper_mve_vorri; |
134 | + uint64_t t; | ||
135 | + t = q[0], q[0] = q[1], q[1] = t; | ||
136 | +#endif | ||
137 | + } | 160 | + } |
161 | + } else { | ||
162 | + /* There is one unallocated cmode/op combination in this space */ | ||
163 | + if (a->cmode == 15 && a->op == 1) { | ||
164 | + return false; | ||
165 | + } | ||
166 | + /* asimd_imm_const() sorts out VMVNI vs VMOVI for us */ | ||
167 | + fn = gen_helper_mve_vmovi; | ||
138 | + } | 168 | + } |
139 | + | 169 | + return do_1imm(s, a, fn); |
140 | + reg.addr = (uintptr_t)(&fpr); | ||
141 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
142 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
143 | + if (ret) { | ||
144 | + return ret; | ||
145 | + } | ||
146 | + vfp_set_fpsr(env, fpr); | ||
147 | + | ||
148 | + reg.addr = (uintptr_t)(&fpr); | ||
149 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
150 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
151 | + if (ret) { | ||
152 | + return ret; | ||
153 | + } | ||
154 | + vfp_set_fpcr(env, fpr); | ||
155 | + | ||
156 | + return 0; | ||
157 | +} | 170 | +} |
158 | + | ||
159 | int kvm_arch_get_registers(CPUState *cs) | ||
160 | { | ||
161 | struct kvm_one_reg reg; | ||
162 | uint64_t val; | ||
163 | - uint32_t fpr; | ||
164 | unsigned int el; | ||
165 | - int i; | ||
166 | - int ret; | ||
167 | + int i, ret; | ||
168 | |||
169 | ARMCPU *cpu = ARM_CPU(cs); | ||
170 | CPUARMState *env = &cpu->env; | ||
171 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
172 | env->spsr = env->banked_spsr[i]; | ||
173 | } | ||
174 | |||
175 | - /* Advanced SIMD and FP registers */ | ||
176 | - for (i = 0; i < 32; i++) { | ||
177 | - uint64_t *q = aa64_vfp_qreg(env, i); | ||
178 | - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
179 | - reg.addr = (uintptr_t)q; | ||
180 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
181 | - if (ret) { | ||
182 | - return ret; | ||
183 | - } else { | ||
184 | -#ifdef HOST_WORDS_BIGENDIAN | ||
185 | - uint64_t t; | ||
186 | - t = q[0], q[0] = q[1], q[1] = t; | ||
187 | -#endif | ||
188 | - } | ||
189 | - } | ||
190 | - | ||
191 | - reg.addr = (uintptr_t)(&fpr); | ||
192 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
193 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
194 | + ret = kvm_arch_get_fpsimd(cs); | ||
195 | if (ret) { | ||
196 | return ret; | ||
197 | } | ||
198 | - vfp_set_fpsr(env, fpr); | ||
199 | - | ||
200 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
201 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
202 | - if (ret) { | ||
203 | - return ret; | ||
204 | - } | ||
205 | - vfp_set_fpcr(env, fpr); | ||
206 | |||
207 | ret = kvm_get_vcpu_events(cpu); | ||
208 | if (ret) { | ||
209 | -- | 171 | -- |
210 | 2.20.1 | 172 | 2.20.1 |
211 | 173 | ||
212 | 174 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE shift-vector-left-by-immediate insns VSHL, VQSHL |
---|---|---|---|
2 | 2 | and VQSHLU. | |
3 | Use deposit as the composit operation to merge the | 3 | |
4 | bits from the two inputs. | 4 | The size-and-immediate encoding here is the same as Neon, and we |
5 | 5 | handle it the same way neon-dp.decode does. | |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | |
7 | Message-id: 20190808202616.13782-3-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | 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> | ||
9 | Message-id: 20210628135835.6690-8-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | target/arm/translate.c | 26 ++++++++++---------------- | 11 | target/arm/helper-mve.h | 16 +++++++++++ |
12 | 1 file changed, 10 insertions(+), 16 deletions(-) | 12 | target/arm/mve.decode | 23 +++++++++++++++ |
13 | 13 | target/arm/mve_helper.c | 57 ++++++++++++++++++++++++++++++++++++++ | |
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | target/arm/translate-mve.c | 51 ++++++++++++++++++++++++++++++++++ |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | 4 files changed, 147 insertions(+) |
16 | --- a/target/arm/translate.c | 16 | |
17 | +++ b/target/arm/translate.c | 17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | shift = (insn >> 7) & 0x1f; | 19 | --- a/target/arm/helper-mve.h |
20 | if (insn & (1 << 6)) { | 20 | +++ b/target/arm/helper-mve.h |
21 | /* pkhtb */ | 21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
22 | - if (shift == 0) | 22 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) |
23 | + if (shift == 0) { | 23 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) |
24 | shift = 31; | 24 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) |
25 | + } | 25 | + |
26 | tcg_gen_sari_i32(tmp2, tmp2, shift); | 26 | +DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
27 | - tcg_gen_andi_i32(tmp, tmp, 0xffff0000); | 27 | +DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
28 | - tcg_gen_ext16u_i32(tmp2, tmp2); | 28 | +DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
29 | + tcg_gen_deposit_i32(tmp, tmp, tmp2, 0, 16); | 29 | + |
30 | } else { | 30 | +DEF_HELPER_FLAGS_4(mve_vqshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
31 | /* pkhbt */ | 31 | +DEF_HELPER_FLAGS_4(mve_vqshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
32 | - if (shift) | 32 | +DEF_HELPER_FLAGS_4(mve_vqshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
33 | - tcg_gen_shli_i32(tmp2, tmp2, shift); | 33 | + |
34 | - tcg_gen_ext16u_i32(tmp, tmp); | 34 | +DEF_HELPER_FLAGS_4(mve_vqshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
35 | - tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); | 35 | +DEF_HELPER_FLAGS_4(mve_vqshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
36 | + tcg_gen_shli_i32(tmp2, tmp2, shift); | 36 | +DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
37 | + tcg_gen_deposit_i32(tmp, tmp2, tmp, 0, 16); | 37 | + |
38 | } | 38 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
39 | - tcg_gen_or_i32(tmp, tmp, tmp2); | 39 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
40 | tcg_temp_free_i32(tmp2); | 40 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
41 | store_reg(s, rd, tmp); | 41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
42 | } else if ((insn & 0x00200020) == 0x00200000) { | 42 | index XXXXXXX..XXXXXXX 100644 |
43 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 43 | --- a/target/arm/mve.decode |
44 | shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3); | 44 | +++ b/target/arm/mve.decode |
45 | if (insn & (1 << 5)) { | 45 | @@ -XXX,XX +XXX,XX @@ |
46 | /* pkhtb */ | 46 | &2op qd qm qn size |
47 | - if (shift == 0) | 47 | &2scalar qd qn rm size |
48 | + if (shift == 0) { | 48 | &1imm qd imm cmode op |
49 | shift = 31; | 49 | +&2shift qd qm shift size |
50 | + } | 50 | |
51 | tcg_gen_sari_i32(tmp2, tmp2, shift); | 51 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 |
52 | - tcg_gen_andi_i32(tmp, tmp, 0xffff0000); | 52 | # Note that both Rn and Qd are 3 bits only (no D bit) |
53 | - tcg_gen_ext16u_i32(tmp2, tmp2); | 53 | @@ -XXX,XX +XXX,XX @@ |
54 | + tcg_gen_deposit_i32(tmp, tmp, tmp2, 0, 16); | 54 | @2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn |
55 | } else { | 55 | @2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn |
56 | /* pkhbt */ | 56 | |
57 | - if (shift) | 57 | +@2_shl_b .... .... .. 001 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0 |
58 | - tcg_gen_shli_i32(tmp2, tmp2, shift); | 58 | +@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 |
59 | - tcg_gen_ext16u_i32(tmp, tmp); | 59 | +@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 |
60 | - tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); | 60 | + |
61 | + tcg_gen_shli_i32(tmp2, tmp2, shift); | 61 | # Vector loads and stores |
62 | + tcg_gen_deposit_i32(tmp, tmp2, tmp, 0, 16); | 62 | |
63 | } | 63 | # Widening loads and narrowing stores: |
64 | - tcg_gen_or_i32(tmp, tmp, tmp2); | 64 | @@ -XXX,XX +XXX,XX @@ VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 |
65 | tcg_temp_free_i32(tmp2); | 65 | # So we have a single decode line and check the cmode/op in the |
66 | store_reg(s, rd, tmp); | 66 | # trans function. |
67 | } else { | 67 | Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm |
68 | + | ||
69 | +# Shifts by immediate | ||
70 | + | ||
71 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | ||
72 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | ||
73 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | ||
74 | + | ||
75 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b | ||
76 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h | ||
77 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
78 | + | ||
79 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b | ||
80 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h | ||
81 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
82 | + | ||
83 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b | ||
84 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h | ||
85 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w | ||
86 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/target/arm/mve_helper.c | ||
89 | +++ b/target/arm/mve_helper.c | ||
90 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W) | ||
91 | WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, true, satp) | ||
92 | #define DO_UQRSHL_OP(N, M, satp) \ | ||
93 | WRAP_QRSHL_HELPER(do_uqrshl_bhs, N, M, true, satp) | ||
94 | +#define DO_SUQSHL_OP(N, M, satp) \ | ||
95 | + WRAP_QRSHL_HELPER(do_suqrshl_bhs, N, M, false, satp) | ||
96 | |||
97 | DO_2OP_SAT_S(vqshls, DO_SQSHL_OP) | ||
98 | DO_2OP_SAT_U(vqshlu, DO_UQSHL_OP) | ||
99 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvsw, 4, uint32_t) | ||
100 | DO_VADDV(vaddvub, 1, uint8_t) | ||
101 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
102 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
103 | + | ||
104 | +/* Shifts by immediate */ | ||
105 | +#define DO_2SHIFT(OP, ESIZE, TYPE, FN) \ | ||
106 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
107 | + void *vm, uint32_t shift) \ | ||
108 | + { \ | ||
109 | + TYPE *d = vd, *m = vm; \ | ||
110 | + uint16_t mask = mve_element_mask(env); \ | ||
111 | + unsigned e; \ | ||
112 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
113 | + mergemask(&d[H##ESIZE(e)], \ | ||
114 | + FN(m[H##ESIZE(e)], shift), mask); \ | ||
115 | + } \ | ||
116 | + mve_advance_vpt(env); \ | ||
117 | + } | ||
118 | + | ||
119 | +#define DO_2SHIFT_SAT(OP, ESIZE, TYPE, FN) \ | ||
120 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
121 | + void *vm, uint32_t shift) \ | ||
122 | + { \ | ||
123 | + TYPE *d = vd, *m = vm; \ | ||
124 | + uint16_t mask = mve_element_mask(env); \ | ||
125 | + unsigned e; \ | ||
126 | + bool qc = false; \ | ||
127 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
128 | + bool sat = false; \ | ||
129 | + mergemask(&d[H##ESIZE(e)], \ | ||
130 | + FN(m[H##ESIZE(e)], shift, &sat), mask); \ | ||
131 | + qc |= sat & mask & 1; \ | ||
132 | + } \ | ||
133 | + if (qc) { \ | ||
134 | + env->vfp.qc[0] = qc; \ | ||
135 | + } \ | ||
136 | + mve_advance_vpt(env); \ | ||
137 | + } | ||
138 | + | ||
139 | +/* provide unsigned 2-op shift helpers for all sizes */ | ||
140 | +#define DO_2SHIFT_U(OP, FN) \ | ||
141 | + DO_2SHIFT(OP##b, 1, uint8_t, FN) \ | ||
142 | + DO_2SHIFT(OP##h, 2, uint16_t, FN) \ | ||
143 | + DO_2SHIFT(OP##w, 4, uint32_t, FN) | ||
144 | + | ||
145 | +#define DO_2SHIFT_SAT_U(OP, FN) \ | ||
146 | + DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \ | ||
147 | + DO_2SHIFT_SAT(OP##h, 2, uint16_t, FN) \ | ||
148 | + DO_2SHIFT_SAT(OP##w, 4, uint32_t, FN) | ||
149 | +#define DO_2SHIFT_SAT_S(OP, FN) \ | ||
150 | + DO_2SHIFT_SAT(OP##b, 1, int8_t, FN) \ | ||
151 | + DO_2SHIFT_SAT(OP##h, 2, int16_t, FN) \ | ||
152 | + DO_2SHIFT_SAT(OP##w, 4, int32_t, FN) | ||
153 | + | ||
154 | +DO_2SHIFT_U(vshli_u, DO_VSHLU) | ||
155 | +DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP) | ||
156 | +DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
157 | +DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
158 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
159 | index XXXXXXX..XXXXXXX 100644 | ||
160 | --- a/target/arm/translate-mve.c | ||
161 | +++ b/target/arm/translate-mve.c | ||
162 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
163 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
164 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
165 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
166 | +typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
167 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
168 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
169 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
170 | @@ -XXX,XX +XXX,XX @@ static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a) | ||
171 | } | ||
172 | return do_1imm(s, a, fn); | ||
173 | } | ||
174 | + | ||
175 | +static bool do_2shift(DisasContext *s, arg_2shift *a, MVEGenTwoOpShiftFn fn, | ||
176 | + bool negateshift) | ||
177 | +{ | ||
178 | + TCGv_ptr qd, qm; | ||
179 | + int shift = a->shift; | ||
180 | + | ||
181 | + if (!dc_isar_feature(aa32_mve, s) || | ||
182 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | ||
183 | + !fn) { | ||
184 | + return false; | ||
185 | + } | ||
186 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
187 | + return true; | ||
188 | + } | ||
189 | + | ||
190 | + /* | ||
191 | + * When we handle a right shift insn using a left-shift helper | ||
192 | + * which permits a negative shift count to indicate a right-shift, | ||
193 | + * we must negate the shift count. | ||
194 | + */ | ||
195 | + if (negateshift) { | ||
196 | + shift = -shift; | ||
197 | + } | ||
198 | + | ||
199 | + qd = mve_qreg_ptr(a->qd); | ||
200 | + qm = mve_qreg_ptr(a->qm); | ||
201 | + fn(cpu_env, qd, qm, tcg_constant_i32(shift)); | ||
202 | + tcg_temp_free_ptr(qd); | ||
203 | + tcg_temp_free_ptr(qm); | ||
204 | + mve_update_eci(s); | ||
205 | + return true; | ||
206 | +} | ||
207 | + | ||
208 | +#define DO_2SHIFT(INSN, FN, NEGATESHIFT) \ | ||
209 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
210 | + { \ | ||
211 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
212 | + gen_helper_mve_##FN##b, \ | ||
213 | + gen_helper_mve_##FN##h, \ | ||
214 | + gen_helper_mve_##FN##w, \ | ||
215 | + NULL, \ | ||
216 | + }; \ | ||
217 | + return do_2shift(s, a, fns[a->size], NEGATESHIFT); \ | ||
218 | + } | ||
219 | + | ||
220 | +DO_2SHIFT(VSHLI, vshli_u, false) | ||
221 | +DO_2SHIFT(VQSHLI_S, vqshli_s, false) | ||
222 | +DO_2SHIFT(VQSHLI_U, vqshli_u, false) | ||
223 | +DO_2SHIFT(VQSHLUI, vqshlui_s, false) | ||
68 | -- | 224 | -- |
69 | 2.20.1 | 225 | 2.20.1 |
70 | 226 | ||
71 | 227 | diff view generated by jsdifflib |
1 | Factor out code to 'generate a singlestep exception', which is | 1 | Implement the MVE vector shift right by immediate insns VSHRI and |
---|---|---|---|
2 | currently repeated in four places. | 2 | VRSHRI. As with Neon, we implement these by using helper functions |
3 | 3 | which perform left shifts but allow negative shift counts to indicate | |
4 | To do this we need to also pull the identical copies of the | 4 | right shifts. |
5 | gen-exception() function out of translate-a64.c and translate.c | ||
6 | into translate.h. | ||
7 | |||
8 | (There is a bug in the code: we're taking the exception to the wrong | ||
9 | target EL. This will be simpler to fix if there's only one place to | ||
10 | do it.) | ||
11 | 5 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Message-id: 20210628135835.6690-9-peter.maydell@linaro.org |
15 | Message-id: 20190805130952.4415-2-peter.maydell@linaro.org | ||
16 | --- | 9 | --- |
17 | target/arm/translate.h | 23 +++++++++++++++++++++++ | 10 | target/arm/helper-mve.h | 12 ++++++++++++ |
18 | target/arm/translate-a64.c | 19 ++----------------- | 11 | target/arm/translate.h | 20 ++++++++++++++++++++ |
19 | target/arm/translate.c | 20 ++------------------ | 12 | target/arm/mve.decode | 28 ++++++++++++++++++++++++++++ |
20 | 3 files changed, 27 insertions(+), 35 deletions(-) | 13 | target/arm/mve_helper.c | 7 +++++++ |
14 | target/arm/translate-mve.c | 5 +++++ | ||
15 | target/arm/translate-neon.c | 18 ------------------ | ||
16 | 6 files changed, 72 insertions(+), 18 deletions(-) | ||
21 | 17 | ||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper-mve.h | ||
21 | +++ b/target/arm/helper-mve.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
23 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
24 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
25 | |||
26 | +DEF_HELPER_FLAGS_4(mve_vshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | + | ||
30 | DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | + | ||
38 | +DEF_HELPER_FLAGS_4(mve_vrshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(mve_vrshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | + | ||
42 | +DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
43 | +DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
44 | +DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 45 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
23 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/translate.h | 47 | --- a/target/arm/translate.h |
25 | +++ b/target/arm/translate.h | 48 | +++ b/target/arm/translate.h |
26 | @@ -XXX,XX +XXX,XX @@ | 49 | @@ -XXX,XX +XXX,XX @@ static inline int times_2_plus_1(DisasContext *s, int x) |
27 | #define TARGET_ARM_TRANSLATE_H | 50 | return x * 2 + 1; |
28 | |||
29 | #include "exec/translator.h" | ||
30 | +#include "internals.h" | ||
31 | |||
32 | |||
33 | /* internal defines */ | ||
34 | @@ -XXX,XX +XXX,XX @@ static inline void gen_ss_advance(DisasContext *s) | ||
35 | } | ||
36 | } | 51 | } |
37 | 52 | ||
38 | +static inline void gen_exception(int excp, uint32_t syndrome, | 53 | +static inline int rsub_64(DisasContext *s, int x) |
39 | + uint32_t target_el) | ||
40 | +{ | 54 | +{ |
41 | + TCGv_i32 tcg_excp = tcg_const_i32(excp); | 55 | + return 64 - x; |
42 | + TCGv_i32 tcg_syn = tcg_const_i32(syndrome); | ||
43 | + TCGv_i32 tcg_el = tcg_const_i32(target_el); | ||
44 | + | ||
45 | + gen_helper_exception_with_syndrome(cpu_env, tcg_excp, | ||
46 | + tcg_syn, tcg_el); | ||
47 | + | ||
48 | + tcg_temp_free_i32(tcg_el); | ||
49 | + tcg_temp_free_i32(tcg_syn); | ||
50 | + tcg_temp_free_i32(tcg_excp); | ||
51 | +} | 56 | +} |
52 | + | 57 | + |
53 | +/* Generate an architectural singlestep exception */ | 58 | +static inline int rsub_32(DisasContext *s, int x) |
54 | +static inline void gen_swstep_exception(DisasContext *s, int isv, int ex) | ||
55 | +{ | 59 | +{ |
56 | + gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, isv, ex), | 60 | + return 32 - x; |
57 | + default_exception_el(s)); | ||
58 | +} | 61 | +} |
59 | + | 62 | + |
60 | /* | 63 | +static inline int rsub_16(DisasContext *s, int x) |
61 | * Given a VFP floating point constant encoded into an 8 bit immediate in an | 64 | +{ |
62 | * instruction, expand it to the actual constant value of the specified | 65 | + return 16 - x; |
63 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 66 | +} |
67 | + | ||
68 | +static inline int rsub_8(DisasContext *s, int x) | ||
69 | +{ | ||
70 | + return 8 - x; | ||
71 | +} | ||
72 | + | ||
73 | static inline int arm_dc_feature(DisasContext *dc, int feature) | ||
74 | { | ||
75 | return (dc->features & (1ULL << feature)) != 0; | ||
76 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
64 | index XXXXXXX..XXXXXXX 100644 | 77 | index XXXXXXX..XXXXXXX 100644 |
65 | --- a/target/arm/translate-a64.c | 78 | --- a/target/arm/mve.decode |
66 | +++ b/target/arm/translate-a64.c | 79 | +++ b/target/arm/mve.decode |
67 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal(int excp) | 80 | @@ -XXX,XX +XXX,XX @@ |
68 | tcg_temp_free_i32(tcg_excp); | 81 | @2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 |
82 | @2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | ||
83 | |||
84 | +# Right shifts are encoded as N - shift, where N is the element size in bits. | ||
85 | +%rshift_i5 16:5 !function=rsub_32 | ||
86 | +%rshift_i4 16:4 !function=rsub_16 | ||
87 | +%rshift_i3 16:3 !function=rsub_8 | ||
88 | + | ||
89 | +@2_shr_b .... .... .. 001 ... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
90 | + size=0 shift=%rshift_i3 | ||
91 | +@2_shr_h .... .... .. 01 .... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
92 | + size=1 shift=%rshift_i4 | ||
93 | +@2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
94 | + size=2 shift=%rshift_i5 | ||
95 | + | ||
96 | # Vector loads and stores | ||
97 | |||
98 | # Widening loads and narrowing stores: | ||
99 | @@ -XXX,XX +XXX,XX @@ VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
100 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b | ||
101 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h | ||
102 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w | ||
103 | + | ||
104 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b | ||
105 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h | ||
106 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w | ||
107 | + | ||
108 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b | ||
109 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h | ||
110 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w | ||
111 | + | ||
112 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
113 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
114 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
115 | + | ||
116 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
117 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
118 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
119 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/target/arm/mve_helper.c | ||
122 | +++ b/target/arm/mve_helper.c | ||
123 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t) | ||
124 | DO_2SHIFT(OP##b, 1, uint8_t, FN) \ | ||
125 | DO_2SHIFT(OP##h, 2, uint16_t, FN) \ | ||
126 | DO_2SHIFT(OP##w, 4, uint32_t, FN) | ||
127 | +#define DO_2SHIFT_S(OP, FN) \ | ||
128 | + DO_2SHIFT(OP##b, 1, int8_t, FN) \ | ||
129 | + DO_2SHIFT(OP##h, 2, int16_t, FN) \ | ||
130 | + DO_2SHIFT(OP##w, 4, int32_t, FN) | ||
131 | |||
132 | #define DO_2SHIFT_SAT_U(OP, FN) \ | ||
133 | DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \ | ||
134 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t) | ||
135 | DO_2SHIFT_SAT(OP##w, 4, int32_t, FN) | ||
136 | |||
137 | DO_2SHIFT_U(vshli_u, DO_VSHLU) | ||
138 | +DO_2SHIFT_S(vshli_s, DO_VSHLS) | ||
139 | DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP) | ||
140 | DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
141 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
142 | +DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
143 | +DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
144 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
145 | index XXXXXXX..XXXXXXX 100644 | ||
146 | --- a/target/arm/translate-mve.c | ||
147 | +++ b/target/arm/translate-mve.c | ||
148 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHLI, vshli_u, false) | ||
149 | DO_2SHIFT(VQSHLI_S, vqshli_s, false) | ||
150 | DO_2SHIFT(VQSHLI_U, vqshli_u, false) | ||
151 | DO_2SHIFT(VQSHLUI, vqshlui_s, false) | ||
152 | +/* These right shifts use a left-shift helper with negated shift count */ | ||
153 | +DO_2SHIFT(VSHRI_S, vshli_s, true) | ||
154 | +DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
155 | +DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
156 | +DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
157 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/target/arm/translate-neon.c | ||
160 | +++ b/target/arm/translate-neon.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static inline int plus1(DisasContext *s, int x) | ||
162 | return x + 1; | ||
69 | } | 163 | } |
70 | 164 | ||
71 | -static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el) | 165 | -static inline int rsub_64(DisasContext *s, int x) |
72 | -{ | 166 | -{ |
73 | - TCGv_i32 tcg_excp = tcg_const_i32(excp); | 167 | - return 64 - x; |
74 | - TCGv_i32 tcg_syn = tcg_const_i32(syndrome); | ||
75 | - TCGv_i32 tcg_el = tcg_const_i32(target_el); | ||
76 | - | ||
77 | - gen_helper_exception_with_syndrome(cpu_env, tcg_excp, | ||
78 | - tcg_syn, tcg_el); | ||
79 | - tcg_temp_free_i32(tcg_el); | ||
80 | - tcg_temp_free_i32(tcg_syn); | ||
81 | - tcg_temp_free_i32(tcg_excp); | ||
82 | -} | 168 | -} |
83 | - | 169 | - |
84 | static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | 170 | -static inline int rsub_32(DisasContext *s, int x) |
85 | { | ||
86 | gen_a64_set_pc_im(s->pc - offset); | ||
87 | @@ -XXX,XX +XXX,XX @@ static void gen_step_complete_exception(DisasContext *s) | ||
88 | * of the exception, and our syndrome information is always correct. | ||
89 | */ | ||
90 | gen_ss_advance(s); | ||
91 | - gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->is_ldex), | ||
92 | - default_exception_el(s)); | ||
93 | + gen_swstep_exception(s, 1, s->is_ldex); | ||
94 | s->base.is_jmp = DISAS_NORETURN; | ||
95 | } | ||
96 | |||
97 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
98 | * bits should be zero. | ||
99 | */ | ||
100 | assert(dc->base.num_insns == 1); | ||
101 | - gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), | ||
102 | - default_exception_el(dc)); | ||
103 | + gen_swstep_exception(dc, 0, 0); | ||
104 | dc->base.is_jmp = DISAS_NORETURN; | ||
105 | } else { | ||
106 | disas_a64_insn(env, dc); | ||
107 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/target/arm/translate.c | ||
110 | +++ b/target/arm/translate.c | ||
111 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal(int excp) | ||
112 | tcg_temp_free_i32(tcg_excp); | ||
113 | } | ||
114 | |||
115 | -static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el) | ||
116 | -{ | 171 | -{ |
117 | - TCGv_i32 tcg_excp = tcg_const_i32(excp); | 172 | - return 32 - x; |
118 | - TCGv_i32 tcg_syn = tcg_const_i32(syndrome); | 173 | -} |
119 | - TCGv_i32 tcg_el = tcg_const_i32(target_el); | 174 | -static inline int rsub_16(DisasContext *s, int x) |
120 | - | 175 | -{ |
121 | - gen_helper_exception_with_syndrome(cpu_env, tcg_excp, | 176 | - return 16 - x; |
122 | - tcg_syn, tcg_el); | 177 | -} |
123 | - | 178 | -static inline int rsub_8(DisasContext *s, int x) |
124 | - tcg_temp_free_i32(tcg_el); | 179 | -{ |
125 | - tcg_temp_free_i32(tcg_syn); | 180 | - return 8 - x; |
126 | - tcg_temp_free_i32(tcg_excp); | ||
127 | -} | 181 | -} |
128 | - | 182 | - |
129 | static void gen_step_complete_exception(DisasContext *s) | 183 | static inline int neon_3same_fp_size(DisasContext *s, int x) |
130 | { | 184 | { |
131 | /* We just completed step of an insn. Move from Active-not-pending | 185 | /* Convert 0==fp32, 1==fp16 into a MO_* value */ |
132 | @@ -XXX,XX +XXX,XX @@ static void gen_step_complete_exception(DisasContext *s) | ||
133 | * of the exception, and our syndrome information is always correct. | ||
134 | */ | ||
135 | gen_ss_advance(s); | ||
136 | - gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->is_ldex), | ||
137 | - default_exception_el(s)); | ||
138 | + gen_swstep_exception(s, 1, s->is_ldex); | ||
139 | s->base.is_jmp = DISAS_NORETURN; | ||
140 | } | ||
141 | |||
142 | @@ -XXX,XX +XXX,XX @@ static bool arm_pre_translate_insn(DisasContext *dc) | ||
143 | * bits should be zero. | ||
144 | */ | ||
145 | assert(dc->base.num_insns == 1); | ||
146 | - gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), | ||
147 | - default_exception_el(dc)); | ||
148 | + gen_swstep_exception(dc, 0, 0); | ||
149 | dc->base.is_jmp = DISAS_NORETURN; | ||
150 | return true; | ||
151 | } | ||
152 | -- | 186 | -- |
153 | 2.20.1 | 187 | 2.20.1 |
154 | 188 | ||
155 | 189 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | Implement the MVE VHLL (vector shift left long) insn. This has two |
---|---|---|---|
2 | encodings: the T1 encoding is the usual shift-by-immediate format, | ||
3 | and the T2 encoding is a special case where the shift count is always | ||
4 | equal to the element size. | ||
2 | 5 | ||
3 | We first convert the pmu property from a static property to one with | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | its own accessors. Then we use the set accessor to check if the PMU is | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | supported when using KVM. Indeed a 32-bit KVM host does not support | 8 | Message-id: 20210628135835.6690-10-peter.maydell@linaro.org |
6 | the PMU, so this check will catch an attempt to use it at property-set | 9 | --- |
7 | time. | 10 | target/arm/helper-mve.h | 9 +++++++ |
11 | target/arm/mve.decode | 53 +++++++++++++++++++++++++++++++++++--- | ||
12 | target/arm/mve_helper.c | 32 +++++++++++++++++++++++ | ||
13 | target/arm/translate-mve.c | 15 +++++++++++ | ||
14 | 4 files changed, 105 insertions(+), 4 deletions(-) | ||
8 | 15 | ||
9 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/kvm_arm.h | 14 ++++++++++++++ | ||
14 | target/arm/cpu.c | 30 +++++++++++++++++++++++++----- | ||
15 | target/arm/kvm.c | 7 +++++++ | ||
16 | 3 files changed, 46 insertions(+), 5 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/kvm_arm.h | 18 | --- a/target/arm/helper-mve.h |
21 | +++ b/target/arm/kvm_arm.h | 19 | +++ b/target/arm/helper-mve.h |
22 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); | 20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | */ | 21 | DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
24 | bool kvm_arm_aarch32_supported(CPUState *cs); | 22 | DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | 23 | DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
26 | +/** | ||
27 | + * bool kvm_arm_pmu_supported: | ||
28 | + * @cs: CPUState | ||
29 | + * | ||
30 | + * Returns: true if the KVM VCPU can enable its PMU | ||
31 | + * and false otherwise. | ||
32 | + */ | ||
33 | +bool kvm_arm_pmu_supported(CPUState *cs); | ||
34 | + | 24 | + |
35 | /** | 25 | +DEF_HELPER_FLAGS_4(mve_vshllbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
36 | * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the | 26 | +DEF_HELPER_FLAGS_4(mve_vshllbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
37 | * IPA address space supported by KVM | 27 | +DEF_HELPER_FLAGS_4(mve_vshllbub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
38 | @@ -XXX,XX +XXX,XX @@ static inline bool kvm_arm_aarch32_supported(CPUState *cs) | 28 | +DEF_HELPER_FLAGS_4(mve_vshllbuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
39 | return false; | 29 | +DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
40 | } | 30 | +DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
41 | 31 | +DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
42 | +static inline bool kvm_arm_pmu_supported(CPUState *cs) | 32 | +DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/mve.decode | ||
36 | +++ b/target/arm/mve.decode | ||
37 | @@ -XXX,XX +XXX,XX @@ | ||
38 | @2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | ||
39 | @2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | ||
40 | |||
41 | +@2_shll_b .... .... ... 01 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0 | ||
42 | +@2_shll_h .... .... ... 1 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | ||
43 | +# VSHLL encoding T2 where shift == esize | ||
44 | +@2_shll_esize_b .... .... .... 00 .. .... .... .... .... &2shift \ | ||
45 | + qd=%qd qm=%qm size=0 shift=8 | ||
46 | +@2_shll_esize_h .... .... .... 01 .. .... .... .... .... &2shift \ | ||
47 | + qd=%qd qm=%qm size=1 shift=16 | ||
48 | + | ||
49 | # Right shifts are encoded as N - shift, where N is the element size in bits. | ||
50 | %rshift_i5 16:5 !function=rsub_32 | ||
51 | %rshift_i4 16:4 !function=rsub_16 | ||
52 | @@ -XXX,XX +XXX,XX @@ VADD 1110 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | ||
53 | VSUB 1111 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | ||
54 | VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
55 | |||
56 | -VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
57 | -VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
58 | +# The VSHLL T2 encoding is not a @2op pattern, but is here because it | ||
59 | +# overlaps what would be size=0b11 VMULH/VRMULH | ||
43 | +{ | 60 | +{ |
44 | + return false; | 61 | + VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b |
62 | + VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
63 | |||
64 | -VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
65 | -VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
66 | + VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
45 | +} | 67 | +} |
46 | + | 68 | + |
47 | static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | ||
48 | { | ||
49 | return -ENOENT; | ||
50 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/cpu.c | ||
53 | +++ b/target/arm/cpu.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_has_el3_property = | ||
55 | static Property arm_cpu_cfgend_property = | ||
56 | DEFINE_PROP_BOOL("cfgend", ARMCPU, cfgend, false); | ||
57 | |||
58 | -/* use property name "pmu" to match other archs and virt tools */ | ||
59 | -static Property arm_cpu_has_pmu_property = | ||
60 | - DEFINE_PROP_BOOL("pmu", ARMCPU, has_pmu, true); | ||
61 | - | ||
62 | static Property arm_cpu_has_vfp_property = | ||
63 | DEFINE_PROP_BOOL("vfp", ARMCPU, has_vfp, true); | ||
64 | |||
65 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pmsav7_dregion_property = | ||
66 | pmsav7_dregion, | ||
67 | qdev_prop_uint32, uint32_t); | ||
68 | |||
69 | +static bool arm_get_pmu(Object *obj, Error **errp) | ||
70 | +{ | 69 | +{ |
71 | + ARMCPU *cpu = ARM_CPU(obj); | 70 | + VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b |
71 | + VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
72 | + | 72 | + |
73 | + return cpu->has_pmu; | 73 | + VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op |
74 | +} | 74 | +} |
75 | + | 75 | + |
76 | +static void arm_set_pmu(Object *obj, bool value, Error **errp) | ||
77 | +{ | 76 | +{ |
78 | + ARMCPU *cpu = ARM_CPU(obj); | 77 | + VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b |
78 | + VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
79 | + | 79 | + |
80 | + if (value) { | 80 | + VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op |
81 | + if (kvm_enabled() && !kvm_arm_pmu_supported(CPU(cpu))) { | ||
82 | + error_setg(errp, "'pmu' feature not supported by KVM on this host"); | ||
83 | + return; | ||
84 | + } | ||
85 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
86 | + } else { | ||
87 | + unset_feature(&cpu->env, ARM_FEATURE_PMU); | ||
88 | + } | ||
89 | + cpu->has_pmu = value; | ||
90 | +} | 81 | +} |
91 | + | 82 | + |
92 | static void arm_get_init_svtor(Object *obj, Visitor *v, const char *name, | 83 | +{ |
93 | void *opaque, Error **errp) | 84 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b |
94 | { | 85 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h |
95 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj) | 86 | + |
96 | } | 87 | + VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op |
97 | 88 | +} | |
98 | if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { | 89 | |
99 | - qdev_property_add_static(DEVICE(obj), &arm_cpu_has_pmu_property, | 90 | VMAX_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op |
100 | + cpu->has_pmu = true; | 91 | VMAX_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op |
101 | + object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu, | 92 | @@ -XXX,XX +XXX,XX @@ VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w |
102 | &error_abort); | 93 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b |
103 | } | 94 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h |
104 | 95 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | |
105 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | 96 | + |
97 | +# VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file | ||
98 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | ||
99 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | ||
100 | + | ||
101 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | ||
102 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | ||
103 | + | ||
104 | +VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
105 | +VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
106 | + | ||
107 | +VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
108 | +VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
109 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | 110 | index XXXXXXX..XXXXXXX 100644 |
107 | --- a/target/arm/kvm.c | 111 | --- a/target/arm/mve_helper.c |
108 | +++ b/target/arm/kvm.c | 112 | +++ b/target/arm/mve_helper.c |
109 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) | 113 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) |
110 | env->features = arm_host_cpu_features.features; | 114 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) |
111 | } | 115 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) |
112 | 116 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | |
113 | +bool kvm_arm_pmu_supported(CPUState *cpu) | ||
114 | +{ | ||
115 | + KVMState *s = KVM_STATE(current_machine->accelerator); | ||
116 | + | 117 | + |
117 | + return kvm_check_extension(s, KVM_CAP_ARM_PMU_V3); | 118 | +/* |
118 | +} | 119 | + * Long shifts taking half-sized inputs from top or bottom of the input |
120 | + * vector and producing a double-width result. ESIZE, TYPE are for | ||
121 | + * the input, and LESIZE, LTYPE for the output. | ||
122 | + * Unlike the normal shift helpers, we do not handle negative shift counts, | ||
123 | + * because the long shift is strictly left-only. | ||
124 | + */ | ||
125 | +#define DO_VSHLL(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE) \ | ||
126 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
127 | + void *vm, uint32_t shift) \ | ||
128 | + { \ | ||
129 | + LTYPE *d = vd; \ | ||
130 | + TYPE *m = vm; \ | ||
131 | + uint16_t mask = mve_element_mask(env); \ | ||
132 | + unsigned le; \ | ||
133 | + assert(shift <= 16); \ | ||
134 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
135 | + LTYPE r = (LTYPE)m[H##ESIZE(le * 2 + TOP)] << shift; \ | ||
136 | + mergemask(&d[H##LESIZE(le)], r, mask); \ | ||
137 | + } \ | ||
138 | + mve_advance_vpt(env); \ | ||
139 | + } | ||
119 | + | 140 | + |
120 | int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | 141 | +#define DO_VSHLL_ALL(OP, TOP) \ |
121 | { | 142 | + DO_VSHLL(OP##sb, TOP, 1, int8_t, 2, int16_t) \ |
122 | KVMState *s = KVM_STATE(ms->accelerator); | 143 | + DO_VSHLL(OP##ub, TOP, 1, uint8_t, 2, uint16_t) \ |
144 | + DO_VSHLL(OP##sh, TOP, 2, int16_t, 4, int32_t) \ | ||
145 | + DO_VSHLL(OP##uh, TOP, 2, uint16_t, 4, uint32_t) \ | ||
146 | + | ||
147 | +DO_VSHLL_ALL(vshllb, false) | ||
148 | +DO_VSHLL_ALL(vshllt, true) | ||
149 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
150 | index XXXXXXX..XXXXXXX 100644 | ||
151 | --- a/target/arm/translate-mve.c | ||
152 | +++ b/target/arm/translate-mve.c | ||
153 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_S, vshli_s, true) | ||
154 | DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
155 | DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
156 | DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
157 | + | ||
158 | +#define DO_VSHLL(INSN, FN) \ | ||
159 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
160 | + { \ | ||
161 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
162 | + gen_helper_mve_##FN##b, \ | ||
163 | + gen_helper_mve_##FN##h, \ | ||
164 | + }; \ | ||
165 | + return do_2shift(s, a, fns[a->size], false); \ | ||
166 | + } | ||
167 | + | ||
168 | +DO_VSHLL(VSHLL_BS, vshllbs) | ||
169 | +DO_VSHLL(VSHLL_BU, vshllbu) | ||
170 | +DO_VSHLL(VSHLL_TS, vshllts) | ||
171 | +DO_VSHLL(VSHLL_TU, vshlltu) | ||
123 | -- | 172 | -- |
124 | 2.20.1 | 173 | 2.20.1 |
125 | 174 | ||
126 | 175 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE VSRI and VSLI insns, which perform a |
---|---|---|---|
2 | shift-and-insert operation. | ||
2 | 3 | ||
3 | Extract is a compact combination of shift + and. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210628135835.6690-11-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 8 ++++++++ | ||
9 | target/arm/mve.decode | 9 ++++++++ | ||
10 | target/arm/mve_helper.c | 42 ++++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 3 +++ | ||
12 | 4 files changed, 62 insertions(+) | ||
4 | 13 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
6 | Message-id: 20190808202616.13782-2-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate.c | 9 +-------- | ||
11 | 1 file changed, 1 insertion(+), 8 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 16 | --- a/target/arm/helper-mve.h |
16 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/helper-mve.h |
17 | @@ -XXX,XX +XXX,XX @@ static void gen_sar(TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1) | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
18 | 19 | DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
19 | static void shifter_out_im(TCGv_i32 var, int shift) | 20 | DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
20 | { | 21 | DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | - if (shift == 0) { | 22 | + |
22 | - tcg_gen_andi_i32(cpu_CF, var, 1); | 23 | +DEF_HELPER_FLAGS_4(mve_vsrib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | - } else { | 24 | +DEF_HELPER_FLAGS_4(mve_vsrih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
24 | - tcg_gen_shri_i32(cpu_CF, var, shift); | 25 | +DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | - if (shift != 31) { | 26 | + |
26 | - tcg_gen_andi_i32(cpu_CF, cpu_CF, 1); | 27 | +DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
27 | - } | 28 | +DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
28 | - } | 29 | +DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
29 | + tcg_gen_extract_i32(cpu_CF, var, shift, 1); | 30 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
30 | } | 31 | index XXXXXXX..XXXXXXX 100644 |
31 | 32 | --- a/target/arm/mve.decode | |
32 | /* Shift by immediate. Includes special handling for shift == 0. */ | 33 | +++ b/target/arm/mve.decode |
34 | @@ -XXX,XX +XXX,XX @@ VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
35 | |||
36 | VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
37 | VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
38 | + | ||
39 | +# Shift-and-insert | ||
40 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_b | ||
41 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_h | ||
42 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w | ||
43 | + | ||
44 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | ||
45 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | ||
46 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | ||
47 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/mve_helper.c | ||
50 | +++ b/target/arm/mve_helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
52 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
53 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
54 | |||
55 | +/* Shift-and-insert; we always work with 64 bits at a time */ | ||
56 | +#define DO_2SHIFT_INSERT(OP, ESIZE, SHIFTFN, MASKFN) \ | ||
57 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
58 | + void *vm, uint32_t shift) \ | ||
59 | + { \ | ||
60 | + uint64_t *d = vd, *m = vm; \ | ||
61 | + uint16_t mask; \ | ||
62 | + uint64_t shiftmask; \ | ||
63 | + unsigned e; \ | ||
64 | + if (shift == 0 || shift == ESIZE * 8) { \ | ||
65 | + /* \ | ||
66 | + * Only VSLI can shift by 0; only VSRI can shift by <dt>. \ | ||
67 | + * The generic logic would give the right answer for 0 but \ | ||
68 | + * fails for <dt>. \ | ||
69 | + */ \ | ||
70 | + goto done; \ | ||
71 | + } \ | ||
72 | + assert(shift < ESIZE * 8); \ | ||
73 | + mask = mve_element_mask(env); \ | ||
74 | + /* ESIZE / 2 gives the MO_* value if ESIZE is in [1,2,4] */ \ | ||
75 | + shiftmask = dup_const(ESIZE / 2, MASKFN(ESIZE * 8, shift)); \ | ||
76 | + for (e = 0; e < 16 / 8; e++, mask >>= 8) { \ | ||
77 | + uint64_t r = (SHIFTFN(m[H8(e)], shift) & shiftmask) | \ | ||
78 | + (d[H8(e)] & ~shiftmask); \ | ||
79 | + mergemask(&d[H8(e)], r, mask); \ | ||
80 | + } \ | ||
81 | +done: \ | ||
82 | + mve_advance_vpt(env); \ | ||
83 | + } | ||
84 | + | ||
85 | +#define DO_SHL(N, SHIFT) ((N) << (SHIFT)) | ||
86 | +#define DO_SHR(N, SHIFT) ((N) >> (SHIFT)) | ||
87 | +#define SHL_MASK(EBITS, SHIFT) MAKE_64BIT_MASK((SHIFT), (EBITS) - (SHIFT)) | ||
88 | +#define SHR_MASK(EBITS, SHIFT) MAKE_64BIT_MASK(0, (EBITS) - (SHIFT)) | ||
89 | + | ||
90 | +DO_2SHIFT_INSERT(vsrib, 1, DO_SHR, SHR_MASK) | ||
91 | +DO_2SHIFT_INSERT(vsrih, 2, DO_SHR, SHR_MASK) | ||
92 | +DO_2SHIFT_INSERT(vsriw, 4, DO_SHR, SHR_MASK) | ||
93 | +DO_2SHIFT_INSERT(vslib, 1, DO_SHL, SHL_MASK) | ||
94 | +DO_2SHIFT_INSERT(vslih, 2, DO_SHL, SHL_MASK) | ||
95 | +DO_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK) | ||
96 | + | ||
97 | /* | ||
98 | * Long shifts taking half-sized inputs from top or bottom of the input | ||
99 | * vector and producing a double-width result. ESIZE, TYPE are for | ||
100 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/target/arm/translate-mve.c | ||
103 | +++ b/target/arm/translate-mve.c | ||
104 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
105 | DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
106 | DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
107 | |||
108 | +DO_2SHIFT(VSRI, vsri, false) | ||
109 | +DO_2SHIFT(VSLI, vsli, false) | ||
110 | + | ||
111 | #define DO_VSHLL(INSN, FN) \ | ||
112 | static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
113 | { \ | ||
33 | -- | 114 | -- |
34 | 2.20.1 | 115 | 2.20.1 |
35 | 116 | ||
36 | 117 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE shift-right-and-narrow insn VSHRN and VRSHRN. |
---|---|---|---|
2 | 2 | ||
3 | We currently have 3 different ways of computing the architectural | 3 | do_urshr() is borrowed from sve_helper.c. |
4 | value of "PC" as seen in the ARM ARM. | ||
5 | 4 | ||
6 | The value of s->pc has been incremented past the current insn, | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | but that is all. Thus for a32, PC = s->pc + 4; for t32, PC = s->pc; | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | for t16, PC = s->pc + 2. These differing computations make it | 7 | Message-id: 20210628135835.6690-12-peter.maydell@linaro.org |
9 | impossible at present to unify the various code paths. | 8 | --- |
9 | target/arm/helper-mve.h | 10 ++++++++++ | ||
10 | target/arm/mve.decode | 11 +++++++++++ | ||
11 | target/arm/mve_helper.c | 40 ++++++++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 15 ++++++++++++++ | ||
13 | 4 files changed, 76 insertions(+) | ||
10 | 14 | ||
11 | With the newly introduced s->pc_curr, we can compute the correct | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
12 | value for all cases, using the formula given in the ARM ARM. | ||
13 | |||
14 | This changes the behaviour for load_reg() and load_reg_var() | ||
15 | when called with reg==15 from a 32-bit Thumb instruction: | ||
16 | previously they would have returned the incorrect value | ||
17 | of pc_curr + 6, and now they will return the architecturally | ||
18 | correct value of PC, which is pc_curr + 4. This will not | ||
19 | affect well-behaved guest software, because all of the places | ||
20 | we call these functions from T32 code are instructions where | ||
21 | using r15 is UNPREDICTABLE. Using the architectural PC value | ||
22 | here is more consistent with the T16 and A32 behaviour. | ||
23 | |||
24 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
26 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
27 | Message-id: 20190807045335.1361-4-richard.henderson@linaro.org | ||
28 | [PMM: added commit message note about UNPREDICTABLE T32 cases] | ||
29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
30 | --- | ||
31 | target/arm/translate.c | 59 ++++++++++++++++-------------------------- | ||
32 | 1 file changed, 23 insertions(+), 36 deletions(-) | ||
33 | |||
34 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/translate.c | 17 | --- a/target/arm/helper-mve.h |
37 | +++ b/target/arm/translate.c | 18 | +++ b/target/arm/helper-mve.h |
38 | @@ -XXX,XX +XXX,XX @@ static inline void store_cpu_offset(TCGv_i32 var, int offset) | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
39 | #define store_cpu_field(var, name) \ | 20 | DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
40 | store_cpu_offset(var, offsetof(CPUARMState, name)) | 21 | DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
41 | 22 | DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
42 | +/* The architectural value of PC. */ | 23 | + |
43 | +static uint32_t read_pc(DisasContext *s) | 24 | +DEF_HELPER_FLAGS_4(mve_vshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | +DEF_HELPER_FLAGS_4(mve_vshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | + | ||
29 | +DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/mve.decode | ||
36 | +++ b/target/arm/mve.decode | ||
37 | @@ -XXX,XX +XXX,XX @@ VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w | ||
38 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | ||
39 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | ||
40 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | ||
41 | + | ||
42 | +# Narrowing shifts (which only support b and h sizes) | ||
43 | +VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | ||
44 | +VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | ||
45 | +VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | ||
46 | +VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | ||
47 | + | ||
48 | +VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | ||
49 | +VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | ||
50 | +VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | ||
51 | +VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | ||
52 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/mve_helper.c | ||
55 | +++ b/target/arm/mve_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK) | ||
57 | |||
58 | DO_VSHLL_ALL(vshllb, false) | ||
59 | DO_VSHLL_ALL(vshllt, true) | ||
60 | + | ||
61 | +/* | ||
62 | + * Narrowing right shifts, taking a double sized input, shifting it | ||
63 | + * and putting the result in either the top or bottom half of the output. | ||
64 | + * ESIZE, TYPE are the output, and LESIZE, LTYPE the input. | ||
65 | + */ | ||
66 | +#define DO_VSHRN(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | ||
67 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
68 | + void *vm, uint32_t shift) \ | ||
69 | + { \ | ||
70 | + LTYPE *m = vm; \ | ||
71 | + TYPE *d = vd; \ | ||
72 | + uint16_t mask = mve_element_mask(env); \ | ||
73 | + unsigned le; \ | ||
74 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
75 | + TYPE r = FN(m[H##LESIZE(le)], shift); \ | ||
76 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
77 | + } \ | ||
78 | + mve_advance_vpt(env); \ | ||
79 | + } | ||
80 | + | ||
81 | +#define DO_VSHRN_ALL(OP, FN) \ | ||
82 | + DO_VSHRN(OP##bb, false, 1, uint8_t, 2, uint16_t, FN) \ | ||
83 | + DO_VSHRN(OP##bh, false, 2, uint16_t, 4, uint32_t, FN) \ | ||
84 | + DO_VSHRN(OP##tb, true, 1, uint8_t, 2, uint16_t, FN) \ | ||
85 | + DO_VSHRN(OP##th, true, 2, uint16_t, 4, uint32_t, FN) | ||
86 | + | ||
87 | +static inline uint64_t do_urshr(uint64_t x, unsigned sh) | ||
44 | +{ | 88 | +{ |
45 | + return s->pc_curr + (s->thumb ? 4 : 8); | 89 | + if (likely(sh < 64)) { |
90 | + return (x >> sh) + ((x >> (sh - 1)) & 1); | ||
91 | + } else if (sh == 64) { | ||
92 | + return x >> 63; | ||
93 | + } else { | ||
94 | + return 0; | ||
95 | + } | ||
46 | +} | 96 | +} |
47 | + | 97 | + |
48 | /* Set a variable to the value of a CPU register. */ | 98 | +DO_VSHRN_ALL(vshrn, DO_SHR) |
49 | static void load_reg_var(DisasContext *s, TCGv_i32 var, int reg) | 99 | +DO_VSHRN_ALL(vrshrn, do_urshr) |
50 | { | 100 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
51 | if (reg == 15) { | 101 | index XXXXXXX..XXXXXXX 100644 |
52 | - uint32_t addr; | 102 | --- a/target/arm/translate-mve.c |
53 | - /* normally, since we updated PC, we need only to add one insn */ | 103 | +++ b/target/arm/translate-mve.c |
54 | - if (s->thumb) | 104 | @@ -XXX,XX +XXX,XX @@ DO_VSHLL(VSHLL_BS, vshllbs) |
55 | - addr = (long)s->pc + 2; | 105 | DO_VSHLL(VSHLL_BU, vshllbu) |
56 | - else | 106 | DO_VSHLL(VSHLL_TS, vshllts) |
57 | - addr = (long)s->pc + 4; | 107 | DO_VSHLL(VSHLL_TU, vshlltu) |
58 | - tcg_gen_movi_i32(var, addr); | 108 | + |
59 | + tcg_gen_movi_i32(var, read_pc(s)); | 109 | +#define DO_2SHIFT_N(INSN, FN) \ |
60 | } else { | 110 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ |
61 | tcg_gen_mov_i32(var, cpu_R[reg]); | 111 | + { \ |
62 | } | 112 | + static MVEGenTwoOpShiftFn * const fns[] = { \ |
63 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 113 | + gen_helper_mve_##FN##b, \ |
64 | /* branch link and change to thumb (blx <offset>) */ | 114 | + gen_helper_mve_##FN##h, \ |
65 | int32_t offset; | 115 | + }; \ |
66 | 116 | + return do_2shift(s, a, fns[a->size], false); \ | |
67 | - val = (uint32_t)s->pc; | 117 | + } |
68 | tmp = tcg_temp_new_i32(); | 118 | + |
69 | - tcg_gen_movi_i32(tmp, val); | 119 | +DO_2SHIFT_N(VSHRNB, vshrnb) |
70 | + tcg_gen_movi_i32(tmp, s->pc); | 120 | +DO_2SHIFT_N(VSHRNT, vshrnt) |
71 | store_reg(s, 14, tmp); | 121 | +DO_2SHIFT_N(VRSHRNB, vrshrnb) |
72 | /* Sign-extend the 24-bit offset */ | 122 | +DO_2SHIFT_N(VRSHRNT, vrshrnt) |
73 | offset = (((int32_t)insn) << 8) >> 8; | ||
74 | + val = read_pc(s); | ||
75 | /* offset * 4 + bit24 * 2 + (thumb bit) */ | ||
76 | val += (offset << 2) | ((insn >> 23) & 2) | 1; | ||
77 | - /* pipeline offset */ | ||
78 | - val += 4; | ||
79 | /* protected by ARCH(5); above, near the start of uncond block */ | ||
80 | gen_bx_im(s, val); | ||
81 | return; | ||
82 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
83 | } else { | ||
84 | /* store */ | ||
85 | if (i == 15) { | ||
86 | - /* special case: r15 = PC + 8 */ | ||
87 | - val = (long)s->pc + 4; | ||
88 | tmp = tcg_temp_new_i32(); | ||
89 | - tcg_gen_movi_i32(tmp, val); | ||
90 | + tcg_gen_movi_i32(tmp, read_pc(s)); | ||
91 | } else if (user) { | ||
92 | tmp = tcg_temp_new_i32(); | ||
93 | tmp2 = tcg_const_i32(i); | ||
94 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
95 | int32_t offset; | ||
96 | |||
97 | /* branch (and link) */ | ||
98 | - val = (int32_t)s->pc; | ||
99 | if (insn & (1 << 24)) { | ||
100 | tmp = tcg_temp_new_i32(); | ||
101 | - tcg_gen_movi_i32(tmp, val); | ||
102 | + tcg_gen_movi_i32(tmp, s->pc); | ||
103 | store_reg(s, 14, tmp); | ||
104 | } | ||
105 | offset = sextract32(insn << 2, 0, 26); | ||
106 | - val += offset + 4; | ||
107 | - gen_jmp(s, val); | ||
108 | + gen_jmp(s, read_pc(s) + offset); | ||
109 | } | ||
110 | break; | ||
111 | case 0xc: | ||
112 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
113 | tcg_temp_free_i32(addr); | ||
114 | } else if ((insn & (7 << 5)) == 0) { | ||
115 | /* Table Branch. */ | ||
116 | - if (rn == 15) { | ||
117 | - addr = tcg_temp_new_i32(); | ||
118 | - tcg_gen_movi_i32(addr, s->pc); | ||
119 | - } else { | ||
120 | - addr = load_reg(s, rn); | ||
121 | - } | ||
122 | + addr = load_reg(s, rn); | ||
123 | tmp = load_reg(s, rm); | ||
124 | tcg_gen_add_i32(addr, addr, tmp); | ||
125 | if (insn & (1 << 4)) { | ||
126 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
127 | } | ||
128 | tcg_temp_free_i32(addr); | ||
129 | tcg_gen_shli_i32(tmp, tmp, 1); | ||
130 | - tcg_gen_addi_i32(tmp, tmp, s->pc); | ||
131 | + tcg_gen_addi_i32(tmp, tmp, read_pc(s)); | ||
132 | store_reg(s, 15, tmp); | ||
133 | } else { | ||
134 | bool is_lasr = false; | ||
135 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
136 | tcg_gen_movi_i32(cpu_R[14], s->pc | 1); | ||
137 | } | ||
138 | |||
139 | - offset += s->pc; | ||
140 | + offset += read_pc(s); | ||
141 | if (insn & (1 << 12)) { | ||
142 | /* b/bl */ | ||
143 | gen_jmp(s, offset); | ||
144 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
145 | offset |= (insn & (1 << 11)) << 8; | ||
146 | |||
147 | /* jump to the offset */ | ||
148 | - gen_jmp(s, s->pc + offset); | ||
149 | + gen_jmp(s, read_pc(s) + offset); | ||
150 | } | ||
151 | } else { | ||
152 | /* | ||
153 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
154 | if (insn & (1 << 11)) { | ||
155 | rd = (insn >> 8) & 7; | ||
156 | /* load pc-relative. Bit 1 of PC is ignored. */ | ||
157 | - val = s->pc + 2 + ((insn & 0xff) * 4); | ||
158 | + val = read_pc(s) + ((insn & 0xff) * 4); | ||
159 | val &= ~(uint32_t)2; | ||
160 | addr = tcg_temp_new_i32(); | ||
161 | tcg_gen_movi_i32(addr, val); | ||
162 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
163 | } else { | ||
164 | /* PC. bit 1 is ignored. */ | ||
165 | tmp = tcg_temp_new_i32(); | ||
166 | - tcg_gen_movi_i32(tmp, (s->pc + 2) & ~(uint32_t)2); | ||
167 | + tcg_gen_movi_i32(tmp, read_pc(s) & ~(uint32_t)2); | ||
168 | } | ||
169 | val = (insn & 0xff) * 4; | ||
170 | tcg_gen_addi_i32(tmp, tmp, val); | ||
171 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
172 | tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, s->condlabel); | ||
173 | tcg_temp_free_i32(tmp); | ||
174 | offset = ((insn & 0xf8) >> 2) | (insn & 0x200) >> 3; | ||
175 | - val = (uint32_t)s->pc + 2; | ||
176 | - val += offset; | ||
177 | - gen_jmp(s, val); | ||
178 | + gen_jmp(s, read_pc(s) + offset); | ||
179 | break; | ||
180 | |||
181 | case 15: /* IT, nop-hint. */ | ||
182 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
183 | arm_skip_unless(s, cond); | ||
184 | |||
185 | /* jump to the offset */ | ||
186 | - val = (uint32_t)s->pc + 2; | ||
187 | + val = read_pc(s); | ||
188 | offset = ((int32_t)insn << 24) >> 24; | ||
189 | val += offset << 1; | ||
190 | gen_jmp(s, val); | ||
191 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
192 | break; | ||
193 | } | ||
194 | /* unconditional branch */ | ||
195 | - val = (uint32_t)s->pc; | ||
196 | + val = read_pc(s); | ||
197 | offset = ((int32_t)insn << 21) >> 21; | ||
198 | - val += (offset << 1) + 2; | ||
199 | + val += offset << 1; | ||
200 | gen_jmp(s, val); | ||
201 | break; | ||
202 | |||
203 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
204 | /* 0b1111_0xxx_xxxx_xxxx : BL/BLX prefix */ | ||
205 | uint32_t uoffset = ((int32_t)insn << 21) >> 9; | ||
206 | |||
207 | - tcg_gen_movi_i32(cpu_R[14], s->pc + 2 + uoffset); | ||
208 | + tcg_gen_movi_i32(cpu_R[14], read_pc(s) + uoffset); | ||
209 | } | ||
210 | break; | ||
211 | } | ||
212 | -- | 123 | -- |
213 | 2.20.1 | 124 | 2.20.1 |
214 | 125 | ||
215 | 126 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | Implement the MVE saturating shift-right-and-narrow insns |
---|---|---|---|
2 | 2 | VQSHRN, VQSHRUN, VQRSHRN and VQRSHRUN. | |
3 | If -cpu <cpu>,aarch64=off is used then KVM must also be used, and it | 3 | |
4 | and the host must support running the vcpu in 32-bit mode. Also, if | 4 | do_srshr() is borrowed from sve_helper.c. |
5 | -cpu <cpu>,aarch64=on is used, then it doesn't matter if kvm is | 5 | |
6 | enabled or not. | ||
7 | |||
8 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
10 | 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> | ||
8 | Message-id: 20210628135835.6690-13-peter.maydell@linaro.org | ||
11 | --- | 9 | --- |
12 | target/arm/kvm_arm.h | 14 ++++++++++++++ | 10 | target/arm/helper-mve.h | 30 +++++++++++ |
13 | target/arm/cpu64.c | 12 ++++++------ | 11 | target/arm/mve.decode | 28 ++++++++++ |
14 | target/arm/kvm64.c | 9 +++++++++ | 12 | target/arm/mve_helper.c | 104 +++++++++++++++++++++++++++++++++++++ |
15 | 3 files changed, 29 insertions(+), 6 deletions(-) | 13 | target/arm/translate-mve.c | 12 +++++ |
16 | 14 | 4 files changed, 174 insertions(+) | |
17 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | 15 | |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
19 | --- a/target/arm/kvm_arm.h | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | +++ b/target/arm/kvm_arm.h | 18 | --- a/target/arm/helper-mve.h |
21 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf); | 19 | +++ b/target/arm/helper-mve.h |
22 | */ | 20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); | 21 | DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
24 | 22 | DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
25 | +/** | 23 | DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
26 | + * kvm_arm_aarch32_supported: | 24 | + |
27 | + * @cs: CPUState | 25 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
28 | + * | 26 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
29 | + * Returns: true if the KVM VCPU can enable AArch32 mode | 27 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
30 | + * and false otherwise. | 28 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
31 | + */ | 29 | + |
32 | +bool kvm_arm_aarch32_supported(CPUState *cs); | 30 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
33 | + | 31 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
34 | /** | 32 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
35 | * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the | 33 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
36 | * IPA address space supported by KVM | 34 | + |
37 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) | 35 | +DEF_HELPER_FLAGS_4(mve_vqshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
38 | cpu->host_cpu_probe_failed = true; | 36 | +DEF_HELPER_FLAGS_4(mve_vqshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
37 | +DEF_HELPER_FLAGS_4(mve_vqshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(mve_vqshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | + | ||
40 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
42 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
43 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
44 | + | ||
45 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
46 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
47 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
48 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
49 | + | ||
50 | +DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
51 | +DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
53 | +DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
54 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/target/arm/mve.decode | ||
57 | +++ b/target/arm/mve.decode | ||
58 | @@ -XXX,XX +XXX,XX @@ VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | ||
59 | VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | ||
60 | VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | ||
61 | VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | ||
62 | + | ||
63 | +VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b | ||
64 | +VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h | ||
65 | +VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b | ||
66 | +VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h | ||
67 | +VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b | ||
68 | +VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h | ||
69 | +VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b | ||
70 | +VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h | ||
71 | + | ||
72 | +VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
73 | +VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
74 | +VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
75 | +VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
76 | + | ||
77 | +VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b | ||
78 | +VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h | ||
79 | +VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b | ||
80 | +VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h | ||
81 | +VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b | ||
82 | +VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h | ||
83 | +VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b | ||
84 | +VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h | ||
85 | + | ||
86 | +VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
87 | +VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
88 | +VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
89 | +VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
90 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/mve_helper.c | ||
93 | +++ b/target/arm/mve_helper.c | ||
94 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t do_urshr(uint64_t x, unsigned sh) | ||
95 | } | ||
39 | } | 96 | } |
40 | 97 | ||
41 | +static inline bool kvm_arm_aarch32_supported(CPUState *cs) | 98 | +static inline int64_t do_srshr(int64_t x, unsigned sh) |
42 | +{ | 99 | +{ |
43 | + return false; | 100 | + if (likely(sh < 64)) { |
101 | + return (x >> sh) + ((x >> (sh - 1)) & 1); | ||
102 | + } else { | ||
103 | + /* Rounding the sign bit always produces 0. */ | ||
104 | + return 0; | ||
105 | + } | ||
44 | +} | 106 | +} |
45 | + | 107 | + |
46 | static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | 108 | DO_VSHRN_ALL(vshrn, DO_SHR) |
47 | { | 109 | DO_VSHRN_ALL(vrshrn, do_urshr) |
48 | return -ENOENT; | 110 | + |
49 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 111 | +static inline int32_t do_sat_bhs(int64_t val, int64_t min, int64_t max, |
50 | index XXXXXXX..XXXXXXX 100644 | 112 | + bool *satp) |
51 | --- a/target/arm/cpu64.c | ||
52 | +++ b/target/arm/cpu64.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp) | ||
54 | * restriction allows us to avoid fixing up functionality that assumes a | ||
55 | * uniform execution state like do_interrupt. | ||
56 | */ | ||
57 | - if (!kvm_enabled()) { | ||
58 | - error_setg(errp, "'aarch64' feature cannot be disabled " | ||
59 | - "unless KVM is enabled"); | ||
60 | - return; | ||
61 | - } | ||
62 | - | ||
63 | if (value == false) { | ||
64 | + if (!kvm_enabled() || !kvm_arm_aarch32_supported(CPU(cpu))) { | ||
65 | + error_setg(errp, "'aarch64' feature cannot be disabled " | ||
66 | + "unless KVM is enabled and 32-bit EL1 " | ||
67 | + "is supported"); | ||
68 | + return; | ||
69 | + } | ||
70 | unset_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
71 | } else { | ||
72 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
73 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/arm/kvm64.c | ||
76 | +++ b/target/arm/kvm64.c | ||
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | #include "exec/gdbstub.h" | ||
79 | #include "sysemu/sysemu.h" | ||
80 | #include "sysemu/kvm.h" | ||
81 | +#include "sysemu/kvm_int.h" | ||
82 | #include "kvm_arm.h" | ||
83 | +#include "hw/boards.h" | ||
84 | #include "internals.h" | ||
85 | |||
86 | static bool have_guest_debug; | ||
87 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
88 | return true; | ||
89 | } | ||
90 | |||
91 | +bool kvm_arm_aarch32_supported(CPUState *cpu) | ||
92 | +{ | 113 | +{ |
93 | + KVMState *s = KVM_STATE(current_machine->accelerator); | 114 | + if (val > max) { |
94 | + | 115 | + *satp = true; |
95 | + return kvm_check_extension(s, KVM_CAP_ARM_EL1_32BIT); | 116 | + return max; |
117 | + } else if (val < min) { | ||
118 | + *satp = true; | ||
119 | + return min; | ||
120 | + } else { | ||
121 | + return val; | ||
122 | + } | ||
96 | +} | 123 | +} |
97 | + | 124 | + |
98 | #define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 | 125 | +/* Saturating narrowing right shifts */ |
99 | 126 | +#define DO_VSHRN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | |
100 | int kvm_arch_init_vcpu(CPUState *cs) | 127 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ |
128 | + void *vm, uint32_t shift) \ | ||
129 | + { \ | ||
130 | + LTYPE *m = vm; \ | ||
131 | + TYPE *d = vd; \ | ||
132 | + uint16_t mask = mve_element_mask(env); \ | ||
133 | + bool qc = false; \ | ||
134 | + unsigned le; \ | ||
135 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
136 | + bool sat = false; \ | ||
137 | + TYPE r = FN(m[H##LESIZE(le)], shift, &sat); \ | ||
138 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
139 | + qc |= sat && (mask & 1 << (TOP * ESIZE)); \ | ||
140 | + } \ | ||
141 | + if (qc) { \ | ||
142 | + env->vfp.qc[0] = qc; \ | ||
143 | + } \ | ||
144 | + mve_advance_vpt(env); \ | ||
145 | + } | ||
146 | + | ||
147 | +#define DO_VSHRN_SAT_UB(BOP, TOP, FN) \ | ||
148 | + DO_VSHRN_SAT(BOP, false, 1, uint8_t, 2, uint16_t, FN) \ | ||
149 | + DO_VSHRN_SAT(TOP, true, 1, uint8_t, 2, uint16_t, FN) | ||
150 | + | ||
151 | +#define DO_VSHRN_SAT_UH(BOP, TOP, FN) \ | ||
152 | + DO_VSHRN_SAT(BOP, false, 2, uint16_t, 4, uint32_t, FN) \ | ||
153 | + DO_VSHRN_SAT(TOP, true, 2, uint16_t, 4, uint32_t, FN) | ||
154 | + | ||
155 | +#define DO_VSHRN_SAT_SB(BOP, TOP, FN) \ | ||
156 | + DO_VSHRN_SAT(BOP, false, 1, int8_t, 2, int16_t, FN) \ | ||
157 | + DO_VSHRN_SAT(TOP, true, 1, int8_t, 2, int16_t, FN) | ||
158 | + | ||
159 | +#define DO_VSHRN_SAT_SH(BOP, TOP, FN) \ | ||
160 | + DO_VSHRN_SAT(BOP, false, 2, int16_t, 4, int32_t, FN) \ | ||
161 | + DO_VSHRN_SAT(TOP, true, 2, int16_t, 4, int32_t, FN) | ||
162 | + | ||
163 | +#define DO_SHRN_SB(N, M, SATP) \ | ||
164 | + do_sat_bhs((int64_t)(N) >> (M), INT8_MIN, INT8_MAX, SATP) | ||
165 | +#define DO_SHRN_UB(N, M, SATP) \ | ||
166 | + do_sat_bhs((uint64_t)(N) >> (M), 0, UINT8_MAX, SATP) | ||
167 | +#define DO_SHRUN_B(N, M, SATP) \ | ||
168 | + do_sat_bhs((int64_t)(N) >> (M), 0, UINT8_MAX, SATP) | ||
169 | + | ||
170 | +#define DO_SHRN_SH(N, M, SATP) \ | ||
171 | + do_sat_bhs((int64_t)(N) >> (M), INT16_MIN, INT16_MAX, SATP) | ||
172 | +#define DO_SHRN_UH(N, M, SATP) \ | ||
173 | + do_sat_bhs((uint64_t)(N) >> (M), 0, UINT16_MAX, SATP) | ||
174 | +#define DO_SHRUN_H(N, M, SATP) \ | ||
175 | + do_sat_bhs((int64_t)(N) >> (M), 0, UINT16_MAX, SATP) | ||
176 | + | ||
177 | +#define DO_RSHRN_SB(N, M, SATP) \ | ||
178 | + do_sat_bhs(do_srshr(N, M), INT8_MIN, INT8_MAX, SATP) | ||
179 | +#define DO_RSHRN_UB(N, M, SATP) \ | ||
180 | + do_sat_bhs(do_urshr(N, M), 0, UINT8_MAX, SATP) | ||
181 | +#define DO_RSHRUN_B(N, M, SATP) \ | ||
182 | + do_sat_bhs(do_srshr(N, M), 0, UINT8_MAX, SATP) | ||
183 | + | ||
184 | +#define DO_RSHRN_SH(N, M, SATP) \ | ||
185 | + do_sat_bhs(do_srshr(N, M), INT16_MIN, INT16_MAX, SATP) | ||
186 | +#define DO_RSHRN_UH(N, M, SATP) \ | ||
187 | + do_sat_bhs(do_urshr(N, M), 0, UINT16_MAX, SATP) | ||
188 | +#define DO_RSHRUN_H(N, M, SATP) \ | ||
189 | + do_sat_bhs(do_srshr(N, M), 0, UINT16_MAX, SATP) | ||
190 | + | ||
191 | +DO_VSHRN_SAT_SB(vqshrnb_sb, vqshrnt_sb, DO_SHRN_SB) | ||
192 | +DO_VSHRN_SAT_SH(vqshrnb_sh, vqshrnt_sh, DO_SHRN_SH) | ||
193 | +DO_VSHRN_SAT_UB(vqshrnb_ub, vqshrnt_ub, DO_SHRN_UB) | ||
194 | +DO_VSHRN_SAT_UH(vqshrnb_uh, vqshrnt_uh, DO_SHRN_UH) | ||
195 | +DO_VSHRN_SAT_SB(vqshrunbb, vqshruntb, DO_SHRUN_B) | ||
196 | +DO_VSHRN_SAT_SH(vqshrunbh, vqshrunth, DO_SHRUN_H) | ||
197 | + | ||
198 | +DO_VSHRN_SAT_SB(vqrshrnb_sb, vqrshrnt_sb, DO_RSHRN_SB) | ||
199 | +DO_VSHRN_SAT_SH(vqrshrnb_sh, vqrshrnt_sh, DO_RSHRN_SH) | ||
200 | +DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB) | ||
201 | +DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) | ||
202 | +DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | ||
203 | +DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) | ||
204 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
205 | index XXXXXXX..XXXXXXX 100644 | ||
206 | --- a/target/arm/translate-mve.c | ||
207 | +++ b/target/arm/translate-mve.c | ||
208 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_N(VSHRNB, vshrnb) | ||
209 | DO_2SHIFT_N(VSHRNT, vshrnt) | ||
210 | DO_2SHIFT_N(VRSHRNB, vrshrnb) | ||
211 | DO_2SHIFT_N(VRSHRNT, vrshrnt) | ||
212 | +DO_2SHIFT_N(VQSHRNB_S, vqshrnb_s) | ||
213 | +DO_2SHIFT_N(VQSHRNT_S, vqshrnt_s) | ||
214 | +DO_2SHIFT_N(VQSHRNB_U, vqshrnb_u) | ||
215 | +DO_2SHIFT_N(VQSHRNT_U, vqshrnt_u) | ||
216 | +DO_2SHIFT_N(VQSHRUNB, vqshrunb) | ||
217 | +DO_2SHIFT_N(VQSHRUNT, vqshrunt) | ||
218 | +DO_2SHIFT_N(VQRSHRNB_S, vqrshrnb_s) | ||
219 | +DO_2SHIFT_N(VQRSHRNT_S, vqrshrnt_s) | ||
220 | +DO_2SHIFT_N(VQRSHRNB_U, vqrshrnb_u) | ||
221 | +DO_2SHIFT_N(VQRSHRNT_U, vqrshrnt_u) | ||
222 | +DO_2SHIFT_N(VQRSHRUNB, vqrshrunb) | ||
223 | +DO_2SHIFT_N(VQRSHRUNT, vqrshrunt) | ||
101 | -- | 224 | -- |
102 | 2.20.1 | 225 | 2.20.1 |
103 | 226 | ||
104 | 227 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | Implement the MVE VSHLC insn, which performs a shift left of the |
---|---|---|---|
2 | entire vector with carry in bits provided from a general purpose | ||
3 | register and carry out bits written back to that register. | ||
2 | 4 | ||
3 | Unless we're guaranteed to always increase ARM_MAX_VQ by a multiple of | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | four, then we should use DIV_ROUND_UP to ensure we get an appropriate | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | array size. | 7 | Message-id: 20210628135835.6690-14-peter.maydell@linaro.org |
8 | --- | ||
9 | target/arm/helper-mve.h | 2 ++ | ||
10 | target/arm/mve.decode | 2 ++ | ||
11 | target/arm/mve_helper.c | 38 ++++++++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 30 ++++++++++++++++++++++++++++++ | ||
13 | 4 files changed, 72 insertions(+) | ||
6 | 14 | ||
7 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/helper-mve.h |
17 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/helper-mve.h |
18 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMVectorReg { | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
19 | #ifdef TARGET_AARCH64 | 20 | DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
20 | /* In AArch32 mode, predicate registers do not exist at all. */ | 21 | DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | typedef struct ARMPredicateReg { | 22 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
22 | - uint64_t p[2 * ARM_MAX_VQ / 8] QEMU_ALIGNED(16); | 23 | + |
23 | + uint64_t p[DIV_ROUND_UP(2 * ARM_MAX_VQ, 8)] QEMU_ALIGNED(16); | 24 | +DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
24 | } ARMPredicateReg; | 25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
25 | 26 | index XXXXXXX..XXXXXXX 100644 | |
26 | /* In AArch32 mode, PAC keys do not exist at all. */ | 27 | --- a/target/arm/mve.decode |
28 | +++ b/target/arm/mve.decode | ||
29 | @@ -XXX,XX +XXX,XX @@ VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
30 | VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
31 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
32 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
33 | + | ||
34 | +VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | ||
35 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/mve_helper.c | ||
38 | +++ b/target/arm/mve_helper.c | ||
39 | @@ -XXX,XX +XXX,XX @@ DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB) | ||
40 | DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) | ||
41 | DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | ||
42 | DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) | ||
43 | + | ||
44 | +uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
45 | + uint32_t shift) | ||
46 | +{ | ||
47 | + uint32_t *d = vd; | ||
48 | + uint16_t mask = mve_element_mask(env); | ||
49 | + unsigned e; | ||
50 | + uint32_t r; | ||
51 | + | ||
52 | + /* | ||
53 | + * For each 32-bit element, we shift it left, bringing in the | ||
54 | + * low 'shift' bits of rdm at the bottom. Bits shifted out at | ||
55 | + * the top become the new rdm, if the predicate mask permits. | ||
56 | + * The final rdm value is returned to update the register. | ||
57 | + * shift == 0 here means "shift by 32 bits". | ||
58 | + */ | ||
59 | + if (shift == 0) { | ||
60 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
61 | + r = rdm; | ||
62 | + if (mask & 1) { | ||
63 | + rdm = d[H4(e)]; | ||
64 | + } | ||
65 | + mergemask(&d[H4(e)], r, mask); | ||
66 | + } | ||
67 | + } else { | ||
68 | + uint32_t shiftmask = MAKE_64BIT_MASK(0, shift); | ||
69 | + | ||
70 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
71 | + r = (d[H4(e)] << shift) | (rdm & shiftmask); | ||
72 | + if (mask & 1) { | ||
73 | + rdm = d[H4(e)] >> (32 - shift); | ||
74 | + } | ||
75 | + mergemask(&d[H4(e)], r, mask); | ||
76 | + } | ||
77 | + } | ||
78 | + mve_advance_vpt(env); | ||
79 | + return rdm; | ||
80 | +} | ||
81 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/target/arm/translate-mve.c | ||
84 | +++ b/target/arm/translate-mve.c | ||
85 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_N(VQRSHRNB_U, vqrshrnb_u) | ||
86 | DO_2SHIFT_N(VQRSHRNT_U, vqrshrnt_u) | ||
87 | DO_2SHIFT_N(VQRSHRUNB, vqrshrunb) | ||
88 | DO_2SHIFT_N(VQRSHRUNT, vqrshrunt) | ||
89 | + | ||
90 | +static bool trans_VSHLC(DisasContext *s, arg_VSHLC *a) | ||
91 | +{ | ||
92 | + /* | ||
93 | + * Whole Vector Left Shift with Carry. The carry is taken | ||
94 | + * from a general purpose register and written back there. | ||
95 | + * An imm of 0 means "shift by 32". | ||
96 | + */ | ||
97 | + TCGv_ptr qd; | ||
98 | + TCGv_i32 rdm; | ||
99 | + | ||
100 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) { | ||
101 | + return false; | ||
102 | + } | ||
103 | + if (a->rdm == 13 || a->rdm == 15) { | ||
104 | + /* CONSTRAINED UNPREDICTABLE: we UNDEF */ | ||
105 | + return false; | ||
106 | + } | ||
107 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
108 | + return true; | ||
109 | + } | ||
110 | + | ||
111 | + qd = mve_qreg_ptr(a->qd); | ||
112 | + rdm = load_reg(s, a->rdm); | ||
113 | + gen_helper_mve_vshlc(rdm, cpu_env, qd, rdm, tcg_constant_i32(a->imm)); | ||
114 | + store_reg(s, a->rdm, rdm); | ||
115 | + tcg_temp_free_ptr(qd); | ||
116 | + mve_update_eci(s); | ||
117 | + return true; | ||
118 | +} | ||
27 | -- | 119 | -- |
28 | 2.20.1 | 120 | 2.20.1 |
29 | 121 | ||
30 | 122 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE VADDLV insn; this is similar to VADDV, except |
---|---|---|---|
2 | that it accumulates 32-bit elements into a 64-bit accumulator | ||
3 | stored in a pair of general-purpose registers. | ||
2 | 4 | ||
3 | The offset is variable depending on the instruction set. | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Passing in the actual value is clearer in intent. | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20210628135835.6690-15-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/helper-mve.h | 3 ++ | ||
10 | target/arm/mve.decode | 6 +++- | ||
11 | target/arm/mve_helper.c | 19 ++++++++++++ | ||
12 | target/arm/translate-mve.c | 63 ++++++++++++++++++++++++++++++++++++++ | ||
13 | 4 files changed, 90 insertions(+), 1 deletion(-) | ||
5 | 14 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190807045335.1361-9-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/translate-a64.c | 8 ++++---- | ||
13 | target/arm/translate.c | 8 ++++---- | ||
14 | 2 files changed, 8 insertions(+), 8 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 17 | --- a/target/arm/helper-mve.h |
19 | +++ b/target/arm/translate-a64.c | 18 | +++ b/target/arm/helper-mve.h |
20 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal(int excp) | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) |
21 | tcg_temp_free_i32(tcg_excp); | 20 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
21 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
22 | |||
23 | +DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
25 | + | ||
26 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
27 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
28 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mve.decode | ||
32 | +++ b/target/arm/mve.decode | ||
33 | @@ -XXX,XX +XXX,XX @@ VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
34 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
35 | |||
36 | # Vector add across vector | ||
37 | -VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
38 | +{ | ||
39 | + VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
40 | + VADDLV 111 u:1 1110 1 ... 1001 ... 0 1111 00 a:1 0 qm:3 0 \ | ||
41 | + rdahi=%rdahi rdalo=%rdalo | ||
42 | +} | ||
43 | |||
44 | # Predicate operations | ||
45 | %mask_22_13 22:1 13:3 | ||
46 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mve_helper.c | ||
49 | +++ b/target/arm/mve_helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvub, 1, uint8_t) | ||
51 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
52 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
53 | |||
54 | +#define DO_VADDLV(OP, TYPE, LTYPE) \ | ||
55 | + uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
56 | + uint64_t ra) \ | ||
57 | + { \ | ||
58 | + uint16_t mask = mve_element_mask(env); \ | ||
59 | + unsigned e; \ | ||
60 | + TYPE *m = vm; \ | ||
61 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
62 | + if (mask & 1) { \ | ||
63 | + ra += (LTYPE)m[H4(e)]; \ | ||
64 | + } \ | ||
65 | + } \ | ||
66 | + mve_advance_vpt(env); \ | ||
67 | + return ra; \ | ||
68 | + } \ | ||
69 | + | ||
70 | +DO_VADDLV(vaddlv_s, int32_t, int64_t) | ||
71 | +DO_VADDLV(vaddlv_u, uint32_t, uint64_t) | ||
72 | + | ||
73 | /* Shifts by immediate */ | ||
74 | #define DO_2SHIFT(OP, ESIZE, TYPE, FN) \ | ||
75 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
76 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/translate-mve.c | ||
79 | +++ b/target/arm/translate-mve.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | ||
81 | return true; | ||
22 | } | 82 | } |
23 | 83 | ||
24 | -static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | 84 | +static bool trans_VADDLV(DisasContext *s, arg_VADDLV *a) |
25 | +static void gen_exception_internal_insn(DisasContext *s, uint64_t pc, int excp) | 85 | +{ |
86 | + /* | ||
87 | + * Vector Add Long Across Vector: accumulate the 32-bit | ||
88 | + * elements of the vector into a 64-bit result stored in | ||
89 | + * a pair of general-purpose registers. | ||
90 | + * No need to check Qm's bank: it is only 3 bits in decode. | ||
91 | + */ | ||
92 | + TCGv_ptr qm; | ||
93 | + TCGv_i64 rda; | ||
94 | + TCGv_i32 rdalo, rdahi; | ||
95 | + | ||
96 | + if (!dc_isar_feature(aa32_mve, s)) { | ||
97 | + return false; | ||
98 | + } | ||
99 | + /* | ||
100 | + * rdahi == 13 is UNPREDICTABLE; rdahi == 15 is a related | ||
101 | + * encoding; rdalo always has bit 0 clear so cannot be 13 or 15. | ||
102 | + */ | ||
103 | + if (a->rdahi == 13 || a->rdahi == 15) { | ||
104 | + return false; | ||
105 | + } | ||
106 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
107 | + return true; | ||
108 | + } | ||
109 | + | ||
110 | + /* | ||
111 | + * This insn is subject to beat-wise execution. Partial execution | ||
112 | + * of an A=0 (no-accumulate) insn which does not execute the first | ||
113 | + * beat must start with the current value of RdaHi:RdaLo, not zero. | ||
114 | + */ | ||
115 | + if (a->a || mve_skip_first_beat(s)) { | ||
116 | + /* Accumulate input from RdaHi:RdaLo */ | ||
117 | + rda = tcg_temp_new_i64(); | ||
118 | + rdalo = load_reg(s, a->rdalo); | ||
119 | + rdahi = load_reg(s, a->rdahi); | ||
120 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | ||
121 | + tcg_temp_free_i32(rdalo); | ||
122 | + tcg_temp_free_i32(rdahi); | ||
123 | + } else { | ||
124 | + /* Accumulate starting at zero */ | ||
125 | + rda = tcg_const_i64(0); | ||
126 | + } | ||
127 | + | ||
128 | + qm = mve_qreg_ptr(a->qm); | ||
129 | + if (a->u) { | ||
130 | + gen_helper_mve_vaddlv_u(rda, cpu_env, qm, rda); | ||
131 | + } else { | ||
132 | + gen_helper_mve_vaddlv_s(rda, cpu_env, qm, rda); | ||
133 | + } | ||
134 | + tcg_temp_free_ptr(qm); | ||
135 | + | ||
136 | + rdalo = tcg_temp_new_i32(); | ||
137 | + rdahi = tcg_temp_new_i32(); | ||
138 | + tcg_gen_extrl_i64_i32(rdalo, rda); | ||
139 | + tcg_gen_extrh_i64_i32(rdahi, rda); | ||
140 | + store_reg(s, a->rdalo, rdalo); | ||
141 | + store_reg(s, a->rdahi, rdahi); | ||
142 | + tcg_temp_free_i64(rda); | ||
143 | + mve_update_eci(s); | ||
144 | + return true; | ||
145 | +} | ||
146 | + | ||
147 | static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) | ||
26 | { | 148 | { |
27 | - gen_a64_set_pc_im(s->base.pc_next - offset); | 149 | TCGv_ptr qd; |
28 | + gen_a64_set_pc_im(pc); | ||
29 | gen_exception_internal(excp); | ||
30 | s->base.is_jmp = DISAS_NORETURN; | ||
31 | } | ||
32 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
33 | break; | ||
34 | } | ||
35 | #endif | ||
36 | - gen_exception_internal_insn(s, 0, EXCP_SEMIHOST); | ||
37 | + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); | ||
38 | } else { | ||
39 | unsupported_encoding(s, insn); | ||
40 | } | ||
41 | @@ -XXX,XX +XXX,XX @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
42 | /* End the TB early; it likely won't be executed */ | ||
43 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
44 | } else { | ||
45 | - gen_exception_internal_insn(dc, 0, EXCP_DEBUG); | ||
46 | + gen_exception_internal_insn(dc, dc->base.pc_next, EXCP_DEBUG); | ||
47 | /* The address covered by the breakpoint must be | ||
48 | included in [tb->pc, tb->pc + tb->size) in order | ||
49 | to for it to be properly cleared -- thus we | ||
50 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/translate.c | ||
53 | +++ b/target/arm/translate.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static inline void gen_smc(DisasContext *s) | ||
55 | s->base.is_jmp = DISAS_SMC; | ||
56 | } | ||
57 | |||
58 | -static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
59 | +static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp) | ||
60 | { | ||
61 | gen_set_condexec(s); | ||
62 | - gen_set_pc_im(s, s->base.pc_next - offset); | ||
63 | + gen_set_pc_im(s, pc); | ||
64 | gen_exception_internal(excp); | ||
65 | s->base.is_jmp = DISAS_NORETURN; | ||
66 | } | ||
67 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | ||
68 | s->current_el != 0 && | ||
69 | #endif | ||
70 | (imm == (s->thumb ? 0x3c : 0xf000))) { | ||
71 | - gen_exception_internal_insn(s, 0, EXCP_SEMIHOST); | ||
72 | + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); | ||
73 | return; | ||
74 | } | ||
75 | |||
76 | @@ -XXX,XX +XXX,XX @@ static bool arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
77 | /* End the TB early; it's likely not going to be executed */ | ||
78 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
79 | } else { | ||
80 | - gen_exception_internal_insn(dc, 0, EXCP_DEBUG); | ||
81 | + gen_exception_internal_insn(dc, dc->base.pc_next, EXCP_DEBUG); | ||
82 | /* The address covered by the breakpoint must be | ||
83 | included in [tb->pc, tb->pc + tb->size) in order | ||
84 | to for it to be properly cleared -- thus we | ||
85 | -- | 150 | -- |
86 | 2.20.1 | 151 | 2.20.1 |
87 | 152 | ||
88 | 153 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The MVE extension to v8.1M includes some new shift instructions which |
---|---|---|---|
2 | 2 | sit entirely within the non-coprocessor part of the encoding space | |
3 | Provide a common routine for the places that require ALIGN(PC, 4) | 3 | and which operate only on general-purpose registers. They take up |
4 | as the base address as opposed to plain PC. The two are always | 4 | the space which was previously UNPREDICTABLE MOVS and ORRS encodings |
5 | the same for A32, but the difference is meaningful for thumb mode. | 5 | with Rm == 13 or 15. |
6 | 6 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Implement the long shifts by immediate, which perform shifts on a |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | pair of general-purpose registers treated as a 64-bit quantity, with |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 9 | an immediate shift count between 1 and 32. |
10 | Message-id: 20190807045335.1361-5-richard.henderson@linaro.org | 10 | |
11 | Awkwardly, because the MOVS and ORRS trans functions do not UNDEF for | ||
12 | the Rm==13,15 case, we need to explicitly emit code to UNDEF for the | ||
13 | cases where v8.1M now requires that. (Trying to change MOVS and ORRS | ||
14 | is too difficult, because the functions that generate the code are | ||
15 | shared between a dozen different kinds of arithmetic or logical | ||
16 | instruction for all A32, T16 and T32 encodings, and for some insns | ||
17 | and some encodings Rm==13,15 are valid.) | ||
18 | |||
19 | We make the helper functions we need for UQSHLL and SQSHLL take | ||
20 | a 32-bit value which the helper casts to int8_t because we'll need | ||
21 | these helpers also for the shift-by-register insns, where the shift | ||
22 | count might be < 0 or > 32. | ||
23 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
26 | Message-id: 20210628135835.6690-16-peter.maydell@linaro.org | ||
12 | --- | 27 | --- |
13 | target/arm/translate-vfp.inc.c | 38 ++------ | 28 | target/arm/helper-mve.h | 3 ++ |
14 | target/arm/translate.c | 166 +++++++++++++++------------------ | 29 | target/arm/translate.h | 1 + |
15 | 2 files changed, 82 insertions(+), 122 deletions(-) | 30 | target/arm/t32.decode | 28 +++++++++++++ |
16 | 31 | target/arm/mve_helper.c | 10 +++++ | |
17 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | 32 | target/arm/translate.c | 90 +++++++++++++++++++++++++++++++++++++++++ |
18 | index XXXXXXX..XXXXXXX 100644 | 33 | 5 files changed, 132 insertions(+) |
19 | --- a/target/arm/translate-vfp.inc.c | 34 | |
20 | +++ b/target/arm/translate-vfp.inc.c | 35 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
21 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) | 36 | index XXXXXXX..XXXXXXX 100644 |
22 | offset = -offset; | 37 | --- a/target/arm/helper-mve.h |
23 | } | 38 | +++ b/target/arm/helper-mve.h |
24 | 39 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
25 | - if (s->thumb && a->rn == 15) { | 40 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
26 | - /* This is actually UNPREDICTABLE */ | 41 | |
27 | - addr = tcg_temp_new_i32(); | 42 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
28 | - tcg_gen_movi_i32(addr, s->pc & ~2); | 43 | + |
29 | - } else { | 44 | +DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
30 | - addr = load_reg(s, a->rn); | 45 | +DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
31 | - } | 46 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
32 | - tcg_gen_addi_i32(addr, addr, offset); | 47 | index XXXXXXX..XXXXXXX 100644 |
33 | + /* For thumb, use of PC is UNPREDICTABLE. */ | 48 | --- a/target/arm/translate.h |
34 | + addr = add_reg_for_lit(s, a->rn, offset); | 49 | +++ b/target/arm/translate.h |
35 | tmp = tcg_temp_new_i32(); | 50 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); |
36 | if (a->l) { | 51 | typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); |
37 | gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | 52 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); |
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a) | 53 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); |
39 | offset = -offset; | 54 | +typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); |
40 | } | 55 | |
41 | 56 | /** | |
42 | - if (s->thumb && a->rn == 15) { | 57 | * arm_tbflags_from_tb: |
43 | - /* This is actually UNPREDICTABLE */ | 58 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode |
44 | - addr = tcg_temp_new_i32(); | 59 | index XXXXXXX..XXXXXXX 100644 |
45 | - tcg_gen_movi_i32(addr, s->pc & ~2); | 60 | --- a/target/arm/t32.decode |
46 | - } else { | 61 | +++ b/target/arm/t32.decode |
47 | - addr = load_reg(s, a->rn); | 62 | @@ -XXX,XX +XXX,XX @@ |
48 | - } | 63 | &mcr !extern cp opc1 crn crm opc2 rt |
49 | - tcg_gen_addi_i32(addr, addr, offset); | 64 | &mcrr !extern cp opc1 crm rt rt2 |
50 | + /* For thumb, use of PC is UNPREDICTABLE. */ | 65 | |
51 | + addr = add_reg_for_lit(s, a->rn, offset); | 66 | +&mve_shl_ri rdalo rdahi shim |
52 | tmp = tcg_temp_new_i64(); | 67 | + |
53 | if (a->l) { | 68 | +# rdahi: bits [3:1] from insn, bit 0 is 1 |
54 | gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); | 69 | +# rdalo: bits [3:1] from insn, bit 0 is 0 |
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) | 70 | +%rdahi_9 9:3 !function=times_2_plus_1 |
56 | return true; | 71 | +%rdalo_17 17:3 !function=times_2 |
57 | } | 72 | + |
58 | 73 | # Data-processing (register) | |
59 | - if (s->thumb && a->rn == 15) { | 74 | |
60 | - /* This is actually UNPREDICTABLE */ | 75 | %imm5_12_6 12:3 6:2 |
61 | - addr = tcg_temp_new_i32(); | 76 | @@ -XXX,XX +XXX,XX @@ |
62 | - tcg_gen_movi_i32(addr, s->pc & ~2); | 77 | @S_xrr_shi ....... .... . rn:4 .... .... .. shty:2 rm:4 \ |
63 | - } else { | 78 | &s_rrr_shi shim=%imm5_12_6 s=1 rd=0 |
64 | - addr = load_reg(s, a->rn); | 79 | |
65 | - } | 80 | +@mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ |
66 | + /* For thumb, use of PC is UNPREDICTABLE. */ | 81 | + &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 |
67 | + addr = add_reg_for_lit(s, a->rn, 0); | 82 | + |
68 | if (a->p) { | 83 | { |
69 | /* pre-decrement */ | 84 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi |
70 | tcg_gen_addi_i32(addr, addr, -(a->imm << 2)); | 85 | AND_rrri 1110101 0000 . .... 0 ... .... .... .... @s_rrr_shi |
71 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) | 86 | } |
72 | return true; | 87 | BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi |
73 | } | 88 | { |
74 | 89 | + # The v8.1M MVE shift insns overlap in encoding with MOVS/ORRS | |
75 | - if (s->thumb && a->rn == 15) { | 90 | + # and are distinguished by having Rm==13 or 15. Those are UNPREDICTABLE |
76 | - /* This is actually UNPREDICTABLE */ | 91 | + # cases for MOVS/ORRS. We decode the MVE cases first, ensuring that |
77 | - addr = tcg_temp_new_i32(); | 92 | + # they explicitly call unallocated_encoding() for cases that must UNDEF |
78 | - tcg_gen_movi_i32(addr, s->pc & ~2); | 93 | + # (eg "using a new shift insn on a v8.1M CPU without MVE"), and letting |
79 | - } else { | 94 | + # the rest fall through (where ORR_rrri and MOV_rxri will end up |
80 | - addr = load_reg(s, a->rn); | 95 | + # handling them as r13 and r15 accesses with the same semantics as A32). |
81 | - } | 96 | + [ |
82 | + /* For thumb, use of PC is UNPREDICTABLE. */ | 97 | + LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri |
83 | + addr = add_reg_for_lit(s, a->rn, 0); | 98 | + LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri |
84 | if (a->p) { | 99 | + ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri |
85 | /* pre-decrement */ | 100 | + |
86 | tcg_gen_addi_i32(addr, addr, -(a->imm << 2)); | 101 | + UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri |
102 | + URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
103 | + SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
104 | + SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
105 | + ] | ||
106 | + | ||
107 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi | ||
108 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi | ||
109 | } | ||
110 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/target/arm/mve_helper.c | ||
113 | +++ b/target/arm/mve_helper.c | ||
114 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
115 | mve_advance_vpt(env); | ||
116 | return rdm; | ||
117 | } | ||
118 | + | ||
119 | +uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
120 | +{ | ||
121 | + return do_sqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
122 | +} | ||
123 | + | ||
124 | +uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
125 | +{ | ||
126 | + return do_uqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
127 | +} | ||
87 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 128 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
88 | index XXXXXXX..XXXXXXX 100644 | 129 | index XXXXXXX..XXXXXXX 100644 |
89 | --- a/target/arm/translate.c | 130 | --- a/target/arm/translate.c |
90 | +++ b/target/arm/translate.c | 131 | +++ b/target/arm/translate.c |
91 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 load_reg(DisasContext *s, int reg) | 132 | @@ -XXX,XX +XXX,XX @@ static bool trans_MOVT(DisasContext *s, arg_MOVW *a) |
92 | return tmp; | 133 | return true; |
93 | } | 134 | } |
94 | 135 | ||
95 | +/* | 136 | +/* |
96 | + * Create a new temp, REG + OFS, except PC is ALIGN(PC, 4). | 137 | + * v8.1M MVE wide-shifts |
97 | + * This is used for load/store for which use of PC implies (literal), | ||
98 | + * or ADD that implies ADR. | ||
99 | + */ | 138 | + */ |
100 | +static TCGv_i32 add_reg_for_lit(DisasContext *s, int reg, int ofs) | 139 | +static bool do_mve_shl_ri(DisasContext *s, arg_mve_shl_ri *a, |
101 | +{ | 140 | + WideShiftImmFn *fn) |
102 | + TCGv_i32 tmp = tcg_temp_new_i32(); | 141 | +{ |
103 | + | 142 | + TCGv_i64 rda; |
104 | + if (reg == 15) { | 143 | + TCGv_i32 rdalo, rdahi; |
105 | + tcg_gen_movi_i32(tmp, (read_pc(s) & ~3) + ofs); | 144 | + |
106 | + } else { | 145 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
107 | + tcg_gen_addi_i32(tmp, cpu_R[reg], ofs); | 146 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ |
108 | + } | 147 | + return false; |
109 | + return tmp; | 148 | + } |
110 | +} | 149 | + if (a->rdahi == 15) { |
111 | + | 150 | + /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */ |
112 | /* Set a CPU register. The source must be a temporary and will be | 151 | + return false; |
113 | marked as dead. */ | 152 | + } |
114 | static void store_reg(DisasContext *s, int reg, TCGv_i32 var) | 153 | + if (!dc_isar_feature(aa32_mve, s) || |
115 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 154 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || |
116 | */ | 155 | + a->rdahi == 13) { |
117 | bool wback = extract32(insn, 21, 1); | 156 | + /* RdaHi == 13 is UNPREDICTABLE; we choose to UNDEF */ |
118 | 157 | + unallocated_encoding(s); | |
119 | - if (rn == 15) { | 158 | + return true; |
120 | - if (insn & (1 << 21)) { | 159 | + } |
121 | - /* UNPREDICTABLE */ | 160 | + |
122 | - goto illegal_op; | 161 | + if (a->shim == 0) { |
123 | - } | 162 | + a->shim = 32; |
124 | - addr = tcg_temp_new_i32(); | 163 | + } |
125 | - tcg_gen_movi_i32(addr, s->pc & ~3); | 164 | + |
126 | - } else { | 165 | + rda = tcg_temp_new_i64(); |
127 | - addr = load_reg(s, rn); | 166 | + rdalo = load_reg(s, a->rdalo); |
128 | + if (rn == 15 && (insn & (1 << 21))) { | 167 | + rdahi = load_reg(s, a->rdahi); |
129 | + /* UNPREDICTABLE */ | 168 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); |
130 | + goto illegal_op; | 169 | + |
131 | } | 170 | + fn(rda, rda, a->shim); |
132 | + | 171 | + |
133 | + addr = add_reg_for_lit(s, rn, 0); | 172 | + tcg_gen_extrl_i64_i32(rdalo, rda); |
134 | offset = (insn & 0xff) * 4; | 173 | + tcg_gen_extrh_i64_i32(rdahi, rda); |
135 | if ((insn & (1 << 23)) == 0) { | 174 | + store_reg(s, a->rdalo, rdalo); |
136 | offset = -offset; | 175 | + store_reg(s, a->rdahi, rdahi); |
137 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 176 | + tcg_temp_free_i64(rda); |
138 | store_reg(s, rd, tmp); | 177 | + |
139 | } else { | 178 | + return true; |
140 | /* Add/sub 12-bit immediate. */ | 179 | +} |
141 | - if (rn == 15) { | 180 | + |
142 | - offset = s->pc & ~(uint32_t)3; | 181 | +static bool trans_ASRL_ri(DisasContext *s, arg_mve_shl_ri *a) |
143 | - if (insn & (1 << 23)) | 182 | +{ |
144 | - offset -= imm; | 183 | + return do_mve_shl_ri(s, a, tcg_gen_sari_i64); |
145 | - else | 184 | +} |
146 | - offset += imm; | 185 | + |
147 | - tmp = tcg_temp_new_i32(); | 186 | +static bool trans_LSLL_ri(DisasContext *s, arg_mve_shl_ri *a) |
148 | - tcg_gen_movi_i32(tmp, offset); | 187 | +{ |
149 | - store_reg(s, rd, tmp); | 188 | + return do_mve_shl_ri(s, a, tcg_gen_shli_i64); |
150 | + if (insn & (1 << 23)) { | 189 | +} |
151 | + imm = -imm; | 190 | + |
152 | + } | 191 | +static bool trans_LSRL_ri(DisasContext *s, arg_mve_shl_ri *a) |
153 | + tmp = add_reg_for_lit(s, rn, imm); | 192 | +{ |
154 | + if (rn == 13 && rd == 13) { | 193 | + return do_mve_shl_ri(s, a, tcg_gen_shri_i64); |
155 | + /* ADD SP, SP, imm or SUB SP, SP, imm */ | 194 | +} |
156 | + store_sp_checked(s, tmp); | 195 | + |
157 | } else { | 196 | +static void gen_mve_sqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) |
158 | - tmp = load_reg(s, rn); | 197 | +{ |
159 | - if (insn & (1 << 23)) | 198 | + gen_helper_mve_sqshll(r, cpu_env, n, tcg_constant_i32(shift)); |
160 | - tcg_gen_subi_i32(tmp, tmp, imm); | 199 | +} |
161 | - else | 200 | + |
162 | - tcg_gen_addi_i32(tmp, tmp, imm); | 201 | +static bool trans_SQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) |
163 | - if (rn == 13 && rd == 13) { | 202 | +{ |
164 | - /* ADD SP, SP, imm or SUB SP, SP, imm */ | 203 | + return do_mve_shl_ri(s, a, gen_mve_sqshll); |
165 | - store_sp_checked(s, tmp); | 204 | +} |
166 | - } else { | 205 | + |
167 | - store_reg(s, rd, tmp); | 206 | +static void gen_mve_uqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) |
168 | - } | 207 | +{ |
169 | + store_reg(s, rd, tmp); | 208 | + gen_helper_mve_uqshll(r, cpu_env, n, tcg_constant_i32(shift)); |
170 | } | 209 | +} |
171 | } | 210 | + |
172 | } | 211 | +static bool trans_UQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) |
173 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 212 | +{ |
174 | } | 213 | + return do_mve_shl_ri(s, a, gen_mve_uqshll); |
175 | } | 214 | +} |
176 | memidx = get_mem_index(s); | 215 | + |
177 | - if (rn == 15) { | 216 | +static bool trans_SRSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) |
178 | - addr = tcg_temp_new_i32(); | 217 | +{ |
179 | - /* PC relative. */ | 218 | + return do_mve_shl_ri(s, a, gen_srshr64_i64); |
180 | - /* s->pc has already been incremented by 4. */ | 219 | +} |
181 | - imm = s->pc & 0xfffffffc; | 220 | + |
182 | - if (insn & (1 << 23)) | 221 | +static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) |
183 | - imm += insn & 0xfff; | 222 | +{ |
184 | - else | 223 | + return do_mve_shl_ri(s, a, gen_urshr64_i64); |
185 | - imm -= insn & 0xfff; | 224 | +} |
186 | - tcg_gen_movi_i32(addr, imm); | 225 | + |
187 | + imm = insn & 0xfff; | 226 | /* |
188 | + if (insn & (1 << 23)) { | 227 | * Multiply and multiply accumulate |
189 | + /* PC relative or Positive offset. */ | 228 | */ |
190 | + addr = add_reg_for_lit(s, rn, imm); | ||
191 | + } else if (rn == 15) { | ||
192 | + /* PC relative with negative offset. */ | ||
193 | + addr = add_reg_for_lit(s, rn, -imm); | ||
194 | } else { | ||
195 | addr = load_reg(s, rn); | ||
196 | - if (insn & (1 << 23)) { | ||
197 | - /* Positive offset. */ | ||
198 | - imm = insn & 0xfff; | ||
199 | - tcg_gen_addi_i32(addr, addr, imm); | ||
200 | - } else { | ||
201 | - imm = insn & 0xff; | ||
202 | - switch ((insn >> 8) & 0xf) { | ||
203 | - case 0x0: /* Shifted Register. */ | ||
204 | - shift = (insn >> 4) & 0xf; | ||
205 | - if (shift > 3) { | ||
206 | - tcg_temp_free_i32(addr); | ||
207 | - goto illegal_op; | ||
208 | - } | ||
209 | - tmp = load_reg(s, rm); | ||
210 | - if (shift) | ||
211 | - tcg_gen_shli_i32(tmp, tmp, shift); | ||
212 | - tcg_gen_add_i32(addr, addr, tmp); | ||
213 | - tcg_temp_free_i32(tmp); | ||
214 | - break; | ||
215 | - case 0xc: /* Negative offset. */ | ||
216 | - tcg_gen_addi_i32(addr, addr, -imm); | ||
217 | - break; | ||
218 | - case 0xe: /* User privilege. */ | ||
219 | - tcg_gen_addi_i32(addr, addr, imm); | ||
220 | - memidx = get_a32_user_mem_index(s); | ||
221 | - break; | ||
222 | - case 0x9: /* Post-decrement. */ | ||
223 | - imm = -imm; | ||
224 | - /* Fall through. */ | ||
225 | - case 0xb: /* Post-increment. */ | ||
226 | - postinc = 1; | ||
227 | - writeback = 1; | ||
228 | - break; | ||
229 | - case 0xd: /* Pre-decrement. */ | ||
230 | - imm = -imm; | ||
231 | - /* Fall through. */ | ||
232 | - case 0xf: /* Pre-increment. */ | ||
233 | - writeback = 1; | ||
234 | - break; | ||
235 | - default: | ||
236 | + imm = insn & 0xff; | ||
237 | + switch ((insn >> 8) & 0xf) { | ||
238 | + case 0x0: /* Shifted Register. */ | ||
239 | + shift = (insn >> 4) & 0xf; | ||
240 | + if (shift > 3) { | ||
241 | tcg_temp_free_i32(addr); | ||
242 | goto illegal_op; | ||
243 | } | ||
244 | + tmp = load_reg(s, rm); | ||
245 | + if (shift) { | ||
246 | + tcg_gen_shli_i32(tmp, tmp, shift); | ||
247 | + } | ||
248 | + tcg_gen_add_i32(addr, addr, tmp); | ||
249 | + tcg_temp_free_i32(tmp); | ||
250 | + break; | ||
251 | + case 0xc: /* Negative offset. */ | ||
252 | + tcg_gen_addi_i32(addr, addr, -imm); | ||
253 | + break; | ||
254 | + case 0xe: /* User privilege. */ | ||
255 | + tcg_gen_addi_i32(addr, addr, imm); | ||
256 | + memidx = get_a32_user_mem_index(s); | ||
257 | + break; | ||
258 | + case 0x9: /* Post-decrement. */ | ||
259 | + imm = -imm; | ||
260 | + /* Fall through. */ | ||
261 | + case 0xb: /* Post-increment. */ | ||
262 | + postinc = 1; | ||
263 | + writeback = 1; | ||
264 | + break; | ||
265 | + case 0xd: /* Pre-decrement. */ | ||
266 | + imm = -imm; | ||
267 | + /* Fall through. */ | ||
268 | + case 0xf: /* Pre-increment. */ | ||
269 | + writeback = 1; | ||
270 | + break; | ||
271 | + default: | ||
272 | + tcg_temp_free_i32(addr); | ||
273 | + goto illegal_op; | ||
274 | } | ||
275 | } | ||
276 | |||
277 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
278 | if (insn & (1 << 11)) { | ||
279 | rd = (insn >> 8) & 7; | ||
280 | /* load pc-relative. Bit 1 of PC is ignored. */ | ||
281 | - val = read_pc(s) + ((insn & 0xff) * 4); | ||
282 | - val &= ~(uint32_t)2; | ||
283 | - addr = tcg_temp_new_i32(); | ||
284 | - tcg_gen_movi_i32(addr, val); | ||
285 | + addr = add_reg_for_lit(s, 15, (insn & 0xff) * 4); | ||
286 | tmp = tcg_temp_new_i32(); | ||
287 | gen_aa32_ld32u_iss(s, tmp, addr, get_mem_index(s), | ||
288 | rd | ISSIs16Bit); | ||
289 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
290 | * - Add PC/SP (immediate) | ||
291 | */ | ||
292 | rd = (insn >> 8) & 7; | ||
293 | - if (insn & (1 << 11)) { | ||
294 | - /* SP */ | ||
295 | - tmp = load_reg(s, 13); | ||
296 | - } else { | ||
297 | - /* PC. bit 1 is ignored. */ | ||
298 | - tmp = tcg_temp_new_i32(); | ||
299 | - tcg_gen_movi_i32(tmp, read_pc(s) & ~(uint32_t)2); | ||
300 | - } | ||
301 | val = (insn & 0xff) * 4; | ||
302 | - tcg_gen_addi_i32(tmp, tmp, val); | ||
303 | + tmp = add_reg_for_lit(s, insn & (1 << 11) ? 13 : 15, val); | ||
304 | store_reg(s, rd, tmp); | ||
305 | break; | ||
306 | |||
307 | -- | 229 | -- |
308 | 2.20.1 | 230 | 2.20.1 |
309 | 231 | ||
310 | 232 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE long shifts by register, which perform shifts on a |
---|---|---|---|
2 | 2 | pair of general-purpose registers treated as a 64-bit quantity, with | |
3 | Add a new field to retain the address of the instruction currently | 3 | the shift count in another general-purpose register, which might be |
4 | being translated. The 32-bit uses are all within subroutines used | 4 | either positive or negative. |
5 | by a32 and t32. This will become less obvious when t16 support is | 5 | |
6 | merged with a32+t32, and having a clear definition will help. | 6 | Like the long-shifts-by-immediate, these encodings sit in the space |
7 | 7 | that was previously the UNPREDICTABLE MOVS/ORRS with Rm==13,15. | |
8 | Convert aarch64 as well for consistency. Note that there is one | 8 | Because LSLL_rr and ASRL_rr overlap with both MOV_rxri/ORR_rrri and |
9 | instance of a pre-assert fprintf that used the wrong value for the | 9 | also with CSEL (as one of the previously-UNPREDICTABLE Rm==13 cases), |
10 | address of the current instruction. | 10 | we have to move the CSEL pattern into the same decodetree group. |
11 | 11 | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Message-id: 20190807045335.1361-3-richard.henderson@linaro.org | ||
16 | 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> | ||
14 | Message-id: 20210628135835.6690-17-peter.maydell@linaro.org | ||
17 | --- | 15 | --- |
18 | target/arm/translate-a64.h | 2 +- | 16 | target/arm/helper-mve.h | 6 +++ |
19 | target/arm/translate.h | 2 ++ | 17 | target/arm/translate.h | 1 + |
20 | target/arm/translate-a64.c | 21 +++++++++++---------- | 18 | target/arm/t32.decode | 16 +++++-- |
21 | target/arm/translate.c | 14 ++++++++------ | 19 | target/arm/mve_helper.c | 93 +++++++++++++++++++++++++++++++++++++++++ |
22 | 4 files changed, 22 insertions(+), 17 deletions(-) | 20 | target/arm/translate.c | 69 ++++++++++++++++++++++++++++++ |
23 | 21 | 5 files changed, 182 insertions(+), 3 deletions(-) | |
24 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | 22 | |
25 | index XXXXXXX..XXXXXXX 100644 | 23 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
26 | --- a/target/arm/translate-a64.h | 24 | index XXXXXXX..XXXXXXX 100644 |
27 | +++ b/target/arm/translate-a64.h | 25 | --- a/target/arm/helper-mve.h |
28 | @@ -XXX,XX +XXX,XX @@ void unallocated_encoding(DisasContext *s); | 26 | +++ b/target/arm/helper-mve.h |
29 | qemu_log_mask(LOG_UNIMP, \ | 27 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
30 | "%s:%d: unsupported instruction encoding 0x%08x " \ | 28 | |
31 | "at pc=%016" PRIx64 "\n", \ | 29 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
32 | - __FILE__, __LINE__, insn, s->pc - 4); \ | 30 | |
33 | + __FILE__, __LINE__, insn, s->pc_curr); \ | 31 | +DEF_HELPER_FLAGS_3(mve_sshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) |
34 | unallocated_encoding(s); \ | 32 | +DEF_HELPER_FLAGS_3(mve_ushll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
35 | } while (0) | 33 | DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
36 | 34 | DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | |
35 | +DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
36 | +DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
37 | +DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
38 | +DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
37 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 39 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
38 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/target/arm/translate.h | 41 | --- a/target/arm/translate.h |
40 | +++ b/target/arm/translate.h | 42 | +++ b/target/arm/translate.h |
41 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 43 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); |
42 | const ARMISARegisters *isar; | 44 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); |
43 | 45 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | |
44 | target_ulong pc; | 46 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); |
45 | + /* The address of the current instruction being translated. */ | 47 | +typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); |
46 | + target_ulong pc_curr; | 48 | |
47 | target_ulong page_start; | 49 | /** |
48 | uint32_t insn; | 50 | * arm_tbflags_from_tb: |
49 | /* Nonzero if this instruction has been conditionally skipped. */ | 51 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode |
50 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 52 | index XXXXXXX..XXXXXXX 100644 |
51 | index XXXXXXX..XXXXXXX 100644 | 53 | --- a/target/arm/t32.decode |
52 | --- a/target/arm/translate-a64.c | 54 | +++ b/target/arm/t32.decode |
53 | +++ b/target/arm/translate-a64.c | 55 | @@ -XXX,XX +XXX,XX @@ |
54 | @@ -XXX,XX +XXX,XX @@ static inline AArch64DecodeFn *lookup_disas_fn(const AArch64DecodeTable *table, | 56 | &mcrr !extern cp opc1 crm rt rt2 |
55 | */ | 57 | |
56 | static void disas_uncond_b_imm(DisasContext *s, uint32_t insn) | 58 | &mve_shl_ri rdalo rdahi shim |
57 | { | 59 | +&mve_shl_rr rdalo rdahi rm |
58 | - uint64_t addr = s->pc + sextract32(insn, 0, 26) * 4 - 4; | 60 | |
59 | + uint64_t addr = s->pc_curr + sextract32(insn, 0, 26) * 4; | 61 | # rdahi: bits [3:1] from insn, bit 0 is 1 |
60 | 62 | # rdalo: bits [3:1] from insn, bit 0 is 0 | |
61 | if (insn & (1U << 31)) { | 63 | @@ -XXX,XX +XXX,XX @@ |
62 | /* BL Branch with link */ | 64 | |
63 | @@ -XXX,XX +XXX,XX @@ static void disas_comp_b_imm(DisasContext *s, uint32_t insn) | 65 | @mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ |
64 | sf = extract32(insn, 31, 1); | 66 | &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 |
65 | op = extract32(insn, 24, 1); /* 0: CBZ; 1: CBNZ */ | 67 | +@mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \ |
66 | rt = extract32(insn, 0, 5); | 68 | + &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 |
67 | - addr = s->pc + sextract32(insn, 5, 19) * 4 - 4; | 69 | |
68 | + addr = s->pc_curr + sextract32(insn, 5, 19) * 4; | 70 | { |
69 | 71 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | |
70 | tcg_cmp = read_cpu_reg(s, rt, sf); | 72 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi |
71 | label_match = gen_new_label(); | 73 | URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri |
72 | @@ -XXX,XX +XXX,XX @@ static void disas_test_b_imm(DisasContext *s, uint32_t insn) | 74 | SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri |
73 | 75 | SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | |
74 | bit_pos = (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5); | 76 | + |
75 | op = extract32(insn, 24, 1); /* 0: TBZ; 1: TBNZ */ | 77 | + LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr |
76 | - addr = s->pc + sextract32(insn, 5, 14) * 4 - 4; | 78 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr |
77 | + addr = s->pc_curr + sextract32(insn, 5, 14) * 4; | 79 | + UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr |
78 | rt = extract32(insn, 0, 5); | 80 | + SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr |
79 | 81 | + UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr | |
80 | tcg_cmp = tcg_temp_new_i64(); | 82 | + SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr |
81 | @@ -XXX,XX +XXX,XX @@ static void disas_cond_b_imm(DisasContext *s, uint32_t insn) | 83 | ] |
82 | unallocated_encoding(s); | 84 | |
83 | return; | 85 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi |
84 | } | 86 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi |
85 | - addr = s->pc + sextract32(insn, 5, 19) * 4 - 4; | 87 | + |
86 | + addr = s->pc_curr + sextract32(insn, 5, 19) * 4; | 88 | + # v8.1M CSEL and friends |
87 | cond = extract32(insn, 0, 4); | 89 | + CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 |
88 | 90 | } | |
89 | reset_btype(s); | 91 | { |
90 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | 92 | MVN_rxri 1110101 0011 . 1111 0 ... .... .... .... @s_rxr_shi |
91 | TCGv_i32 tcg_syn, tcg_isread; | 93 | @@ -XXX,XX +XXX,XX @@ SBC_rrri 1110101 1011 . .... 0 ... .... .... .... @s_rrr_shi |
92 | uint32_t syndrome; | 94 | } |
93 | 95 | RSB_rrri 1110101 1110 . .... 0 ... .... .... .... @s_rrr_shi | |
94 | - gen_a64_set_pc_im(s->pc - 4); | 96 | |
95 | + gen_a64_set_pc_im(s->pc_curr); | 97 | -# v8.1M CSEL and friends |
96 | tmpptr = tcg_const_ptr(ri); | 98 | -CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 |
97 | syndrome = syn_aa64_sysregtrap(op0, op1, op2, crn, crm, rt, isread); | 99 | - |
98 | tcg_syn = tcg_const_i32(syndrome); | 100 | # Data-processing (register-shifted register) |
99 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | 101 | |
100 | /* The pre HVC helper handles cases when HVC gets trapped | 102 | MOV_rxrr 1111 1010 0 shty:2 s:1 rm:4 1111 rd:4 0000 rs:4 \ |
101 | * as an undefined insn by runtime configuration. | 103 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
102 | */ | 104 | index XXXXXXX..XXXXXXX 100644 |
103 | - gen_a64_set_pc_im(s->pc - 4); | 105 | --- a/target/arm/mve_helper.c |
104 | + gen_a64_set_pc_im(s->pc_curr); | 106 | +++ b/target/arm/mve_helper.c |
105 | gen_helper_pre_hvc(cpu_env); | 107 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, |
106 | gen_ss_advance(s); | 108 | return rdm; |
107 | gen_exception_insn(s, 0, EXCP_HVC, syn_aa64_hvc(imm16), 2); | 109 | } |
108 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | 110 | |
109 | unallocated_encoding(s); | 111 | +uint64_t HELPER(mve_sshrl)(CPUARMState *env, uint64_t n, uint32_t shift) |
110 | break; | 112 | +{ |
111 | } | 113 | + return do_sqrshl_d(n, -(int8_t)shift, false, NULL); |
112 | - gen_a64_set_pc_im(s->pc - 4); | 114 | +} |
113 | + gen_a64_set_pc_im(s->pc_curr); | 115 | + |
114 | tmp = tcg_const_i32(syn_aa64_smc(imm16)); | 116 | +uint64_t HELPER(mve_ushll)(CPUARMState *env, uint64_t n, uint32_t shift) |
115 | gen_helper_pre_smc(cpu_env, tmp); | 117 | +{ |
116 | tcg_temp_free_i32(tmp); | 118 | + return do_uqrshl_d(n, (int8_t)shift, false, NULL); |
117 | @@ -XXX,XX +XXX,XX @@ static void disas_ld_lit(DisasContext *s, uint32_t insn) | 119 | +} |
118 | 120 | + | |
119 | tcg_rt = cpu_reg(s, rt); | 121 | uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift) |
120 | 122 | { | |
121 | - clean_addr = tcg_const_i64((s->pc - 4) + imm); | 123 | return do_sqrshl_d(n, (int8_t)shift, false, &env->QF); |
122 | + clean_addr = tcg_const_i64(s->pc_curr + imm); | 124 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift) |
123 | if (is_vector) { | 125 | { |
124 | do_fp_ld(s, rt, clean_addr, size); | 126 | return do_uqrshl_d(n, (int8_t)shift, false, &env->QF); |
125 | } else { | 127 | } |
126 | @@ -XXX,XX +XXX,XX @@ static void disas_pc_rel_adr(DisasContext *s, uint32_t insn) | 128 | + |
127 | offset = sextract64(insn, 5, 19); | 129 | +uint64_t HELPER(mve_sqrshrl)(CPUARMState *env, uint64_t n, uint32_t shift) |
128 | offset = offset << 2 | extract32(insn, 29, 2); | 130 | +{ |
129 | rd = extract32(insn, 0, 5); | 131 | + return do_sqrshl_d(n, -(int8_t)shift, true, &env->QF); |
130 | - base = s->pc - 4; | 132 | +} |
131 | + base = s->pc_curr; | 133 | + |
132 | 134 | +uint64_t HELPER(mve_uqrshll)(CPUARMState *env, uint64_t n, uint32_t shift) | |
133 | if (page) { | 135 | +{ |
134 | /* ADRP (page based) */ | 136 | + return do_uqrshl_d(n, (int8_t)shift, true, &env->QF); |
135 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) | 137 | +} |
136 | break; | 138 | + |
137 | default: | 139 | +/* Operate on 64-bit values, but saturate at 48 bits */ |
138 | fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n", | 140 | +static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, |
139 | - __func__, insn, fpopcode, s->pc); | 141 | + bool round, uint32_t *sat) |
140 | + __func__, insn, fpopcode, s->pc_curr); | 142 | +{ |
141 | g_assert_not_reached(); | 143 | + if (shift <= -48) { |
142 | } | 144 | + /* Rounding the sign bit always produces 0. */ |
143 | 145 | + if (round) { | |
144 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | 146 | + return 0; |
145 | { | 147 | + } |
146 | uint32_t insn; | 148 | + return src >> 63; |
147 | 149 | + } else if (shift < 0) { | |
148 | + s->pc_curr = s->pc; | 150 | + if (round) { |
149 | insn = arm_ldl_code(env, s->pc, s->sctlr_b); | 151 | + src >>= -shift - 1; |
150 | s->insn = insn; | 152 | + return (src >> 1) + (src & 1); |
151 | s->pc += 4; | 153 | + } |
154 | + return src >> -shift; | ||
155 | + } else if (shift < 48) { | ||
156 | + int64_t val = src << shift; | ||
157 | + int64_t extval = sextract64(val, 0, 48); | ||
158 | + if (!sat || val == extval) { | ||
159 | + return extval; | ||
160 | + } | ||
161 | + } else if (!sat || src == 0) { | ||
162 | + return 0; | ||
163 | + } | ||
164 | + | ||
165 | + *sat = 1; | ||
166 | + return (1ULL << 47) - (src >= 0); | ||
167 | +} | ||
168 | + | ||
169 | +/* Operate on 64-bit values, but saturate at 48 bits */ | ||
170 | +static inline uint64_t do_uqrshl48_d(uint64_t src, int64_t shift, | ||
171 | + bool round, uint32_t *sat) | ||
172 | +{ | ||
173 | + uint64_t val, extval; | ||
174 | + | ||
175 | + if (shift <= -(48 + round)) { | ||
176 | + return 0; | ||
177 | + } else if (shift < 0) { | ||
178 | + if (round) { | ||
179 | + val = src >> (-shift - 1); | ||
180 | + val = (val >> 1) + (val & 1); | ||
181 | + } else { | ||
182 | + val = src >> -shift; | ||
183 | + } | ||
184 | + extval = extract64(val, 0, 48); | ||
185 | + if (!sat || val == extval) { | ||
186 | + return extval; | ||
187 | + } | ||
188 | + } else if (shift < 48) { | ||
189 | + uint64_t val = src << shift; | ||
190 | + uint64_t extval = extract64(val, 0, 48); | ||
191 | + if (!sat || val == extval) { | ||
192 | + return extval; | ||
193 | + } | ||
194 | + } else if (!sat || src == 0) { | ||
195 | + return 0; | ||
196 | + } | ||
197 | + | ||
198 | + *sat = 1; | ||
199 | + return MAKE_64BIT_MASK(0, 48); | ||
200 | +} | ||
201 | + | ||
202 | +uint64_t HELPER(mve_sqrshrl48)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
203 | +{ | ||
204 | + return do_sqrshl48_d(n, -(int8_t)shift, true, &env->QF); | ||
205 | +} | ||
206 | + | ||
207 | +uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
208 | +{ | ||
209 | + return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF); | ||
210 | +} | ||
152 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 211 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
153 | index XXXXXXX..XXXXXXX 100644 | 212 | index XXXXXXX..XXXXXXX 100644 |
154 | --- a/target/arm/translate.c | 213 | --- a/target/arm/translate.c |
155 | +++ b/target/arm/translate.c | 214 | +++ b/target/arm/translate.c |
156 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hvc(DisasContext *s, int imm16) | 215 | @@ -XXX,XX +XXX,XX @@ static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) |
157 | * as an undefined insn by runtime configuration (ie before | 216 | return do_mve_shl_ri(s, a, gen_urshr64_i64); |
158 | * the insn really executes). | 217 | } |
159 | */ | 218 | |
160 | - gen_set_pc_im(s, s->pc - 4); | 219 | +static bool do_mve_shl_rr(DisasContext *s, arg_mve_shl_rr *a, WideShiftFn *fn) |
161 | + gen_set_pc_im(s, s->pc_curr); | 220 | +{ |
162 | gen_helper_pre_hvc(cpu_env); | 221 | + TCGv_i64 rda; |
163 | /* Otherwise we will treat this as a real exception which | 222 | + TCGv_i32 rdalo, rdahi; |
164 | * happens after execution of the insn. (The distinction matters | 223 | + |
165 | @@ -XXX,XX +XXX,XX @@ static inline void gen_smc(DisasContext *s) | 224 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
166 | */ | 225 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ |
167 | TCGv_i32 tmp; | 226 | + return false; |
168 | 227 | + } | |
169 | - gen_set_pc_im(s, s->pc - 4); | 228 | + if (a->rdahi == 15) { |
170 | + gen_set_pc_im(s, s->pc_curr); | 229 | + /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */ |
171 | tmp = tcg_const_i32(syn_aa32_smc()); | 230 | + return false; |
172 | gen_helper_pre_smc(cpu_env, tmp); | 231 | + } |
173 | tcg_temp_free_i32(tmp); | 232 | + if (!dc_isar_feature(aa32_mve, s) || |
174 | @@ -XXX,XX +XXX,XX @@ static void gen_msr_banked(DisasContext *s, int r, int sysm, int rn) | 233 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || |
175 | 234 | + a->rdahi == 13 || a->rm == 13 || a->rm == 15 || | |
176 | /* Sync state because msr_banked() can raise exceptions */ | 235 | + a->rm == a->rdahi || a->rm == a->rdalo) { |
177 | gen_set_condexec(s); | 236 | + /* These rdahi/rdalo/rm cases are UNPREDICTABLE; we choose to UNDEF */ |
178 | - gen_set_pc_im(s, s->pc - 4); | 237 | + unallocated_encoding(s); |
179 | + gen_set_pc_im(s, s->pc_curr); | 238 | + return true; |
180 | tcg_reg = load_reg(s, rn); | 239 | + } |
181 | tcg_tgtmode = tcg_const_i32(tgtmode); | 240 | + |
182 | tcg_regno = tcg_const_i32(regno); | 241 | + rda = tcg_temp_new_i64(); |
183 | @@ -XXX,XX +XXX,XX @@ static void gen_mrs_banked(DisasContext *s, int r, int sysm, int rn) | 242 | + rdalo = load_reg(s, a->rdalo); |
184 | 243 | + rdahi = load_reg(s, a->rdahi); | |
185 | /* Sync state because mrs_banked() can raise exceptions */ | 244 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); |
186 | gen_set_condexec(s); | 245 | + |
187 | - gen_set_pc_im(s, s->pc - 4); | 246 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ |
188 | + gen_set_pc_im(s, s->pc_curr); | 247 | + fn(rda, cpu_env, rda, cpu_R[a->rm]); |
189 | tcg_reg = tcg_temp_new_i32(); | 248 | + |
190 | tcg_tgtmode = tcg_const_i32(tgtmode); | 249 | + tcg_gen_extrl_i64_i32(rdalo, rda); |
191 | tcg_regno = tcg_const_i32(regno); | 250 | + tcg_gen_extrh_i64_i32(rdahi, rda); |
192 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | 251 | + store_reg(s, a->rdalo, rdalo); |
193 | } | 252 | + store_reg(s, a->rdahi, rdahi); |
194 | 253 | + tcg_temp_free_i64(rda); | |
195 | gen_set_condexec(s); | 254 | + |
196 | - gen_set_pc_im(s, s->pc - 4); | 255 | + return true; |
197 | + gen_set_pc_im(s, s->pc_curr); | 256 | +} |
198 | tmpptr = tcg_const_ptr(ri); | 257 | + |
199 | tcg_syn = tcg_const_i32(syndrome); | 258 | +static bool trans_LSLL_rr(DisasContext *s, arg_mve_shl_rr *a) |
200 | tcg_isread = tcg_const_i32(isread); | 259 | +{ |
201 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | 260 | + return do_mve_shl_rr(s, a, gen_helper_mve_ushll); |
202 | tmp = tcg_const_i32(mode); | 261 | +} |
203 | /* get_r13_banked() will raise an exception if called from System mode */ | 262 | + |
204 | gen_set_condexec(s); | 263 | +static bool trans_ASRL_rr(DisasContext *s, arg_mve_shl_rr *a) |
205 | - gen_set_pc_im(s, s->pc - 4); | 264 | +{ |
206 | + gen_set_pc_im(s, s->pc_curr); | 265 | + return do_mve_shl_rr(s, a, gen_helper_mve_sshrl); |
207 | gen_helper_get_r13_banked(addr, cpu_env, tmp); | 266 | +} |
208 | tcg_temp_free_i32(tmp); | 267 | + |
209 | switch (amode) { | 268 | +static bool trans_UQRSHLL64_rr(DisasContext *s, arg_mve_shl_rr *a) |
210 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 269 | +{ |
211 | return; | 270 | + return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll); |
212 | } | 271 | +} |
213 | 272 | + | |
214 | + dc->pc_curr = dc->pc; | 273 | +static bool trans_SQRSHRL64_rr(DisasContext *s, arg_mve_shl_rr *a) |
215 | insn = arm_ldl_code(env, dc->pc, dc->sctlr_b); | 274 | +{ |
216 | dc->insn = insn; | 275 | + return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl); |
217 | dc->pc += 4; | 276 | +} |
218 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 277 | + |
219 | return; | 278 | +static bool trans_UQRSHLL48_rr(DisasContext *s, arg_mve_shl_rr *a) |
220 | } | 279 | +{ |
221 | 280 | + return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll48); | |
222 | + dc->pc_curr = dc->pc; | 281 | +} |
223 | insn = arm_lduw_code(env, dc->pc, dc->sctlr_b); | 282 | + |
224 | is_16bit = thumb_insn_is_16bit(dc, dc->pc, insn); | 283 | +static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a) |
225 | dc->pc += 2; | 284 | +{ |
285 | + return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48); | ||
286 | +} | ||
287 | + | ||
288 | /* | ||
289 | * Multiply and multiply accumulate | ||
290 | */ | ||
226 | -- | 291 | -- |
227 | 2.20.1 | 292 | 2.20.1 |
228 | 293 | ||
229 | 294 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE shifts by immediate, which perform shifts |
---|---|---|---|
2 | 2 | on a single general-purpose register. | |
3 | The thumb bit has already been removed from s->pc, and is always even. | 3 | |
4 | 4 | These patterns overlap with the long-shift-by-immediates, | |
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | so we have to rearrange the grouping a little here. |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190807045335.1361-6-richard.henderson@linaro.org | ||
9 | 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> | ||
9 | Message-id: 20210628135835.6690-18-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | target/arm/translate.c | 10 +++++----- | 11 | target/arm/helper-mve.h | 3 ++ |
12 | 1 file changed, 5 insertions(+), 5 deletions(-) | 12 | target/arm/translate.h | 1 + |
13 | 13 | target/arm/t32.decode | 31 ++++++++++++++----- | |
14 | target/arm/mve_helper.c | 10 ++++++ | ||
15 | target/arm/translate.c | 68 +++++++++++++++++++++++++++++++++++++++-- | ||
16 | 5 files changed, 104 insertions(+), 9 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper-mve.h | ||
21 | +++ b/target/arm/helper-mve.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
23 | DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
24 | DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
25 | DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
26 | + | ||
27 | +DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
28 | +DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
29 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/translate.h | ||
32 | +++ b/target/arm/translate.h | ||
33 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
34 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
35 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | ||
36 | typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); | ||
37 | +typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift); | ||
38 | |||
39 | /** | ||
40 | * arm_tbflags_from_tb: | ||
41 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/t32.decode | ||
44 | +++ b/target/arm/t32.decode | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | |||
47 | &mve_shl_ri rdalo rdahi shim | ||
48 | &mve_shl_rr rdalo rdahi rm | ||
49 | +&mve_sh_ri rda shim | ||
50 | |||
51 | # rdahi: bits [3:1] from insn, bit 0 is 1 | ||
52 | # rdalo: bits [3:1] from insn, bit 0 is 0 | ||
53 | @@ -XXX,XX +XXX,XX @@ | ||
54 | &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
55 | @mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \ | ||
56 | &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
57 | +@mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \ | ||
58 | + &mve_sh_ri shim=%imm5_12_6 | ||
59 | |||
60 | { | ||
61 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | ||
62 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | ||
63 | # the rest fall through (where ORR_rrri and MOV_rxri will end up | ||
64 | # handling them as r13 and r15 accesses with the same semantics as A32). | ||
65 | [ | ||
66 | - LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
67 | - LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
68 | - ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
69 | + { | ||
70 | + UQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 00 1111 @mve_sh_ri | ||
71 | + LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
72 | + UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
73 | + } | ||
74 | |||
75 | - UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
76 | - URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
77 | - SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
78 | - SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
79 | + { | ||
80 | + URSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 01 1111 @mve_sh_ri | ||
81 | + LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
82 | + URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
83 | + } | ||
84 | + | ||
85 | + { | ||
86 | + SRSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 10 1111 @mve_sh_ri | ||
87 | + ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
88 | + SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
89 | + } | ||
90 | + | ||
91 | + { | ||
92 | + SQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 11 1111 @mve_sh_ri | ||
93 | + SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
94 | + } | ||
95 | |||
96 | LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
97 | ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
98 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/target/arm/mve_helper.c | ||
101 | +++ b/target/arm/mve_helper.c | ||
102 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
103 | { | ||
104 | return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF); | ||
105 | } | ||
106 | + | ||
107 | +uint32_t HELPER(mve_uqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
108 | +{ | ||
109 | + return do_uqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | ||
110 | +} | ||
111 | + | ||
112 | +uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
113 | +{ | ||
114 | + return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | ||
115 | +} | ||
14 | 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 |
15 | index XXXXXXX..XXXXXXX 100644 | 117 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 118 | --- a/target/arm/translate.c |
17 | +++ b/target/arm/translate.c | 119 | +++ b/target/arm/translate.c |
18 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | 120 | @@ -XXX,XX +XXX,XX @@ static void gen_srshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh) |
19 | /* Force a TB lookup after an instruction that changes the CPU state. */ | 121 | |
20 | static inline void gen_lookup_tb(DisasContext *s) | 122 | static void gen_srshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh) |
21 | { | 123 | { |
22 | - tcg_gen_movi_i32(cpu_R[15], s->pc & ~1); | 124 | - TCGv_i32 t = tcg_temp_new_i32(); |
23 | + tcg_gen_movi_i32(cpu_R[15], s->pc); | 125 | + TCGv_i32 t; |
24 | s->base.is_jmp = DISAS_EXIT; | 126 | |
127 | + /* Handle shift by the input size for the benefit of trans_SRSHR_ri */ | ||
128 | + if (sh == 32) { | ||
129 | + tcg_gen_movi_i32(d, 0); | ||
130 | + return; | ||
131 | + } | ||
132 | + t = tcg_temp_new_i32(); | ||
133 | tcg_gen_extract_i32(t, a, sh - 1, 1); | ||
134 | tcg_gen_sari_i32(d, a, sh); | ||
135 | tcg_gen_add_i32(d, d, t); | ||
136 | @@ -XXX,XX +XXX,XX @@ static void gen_urshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh) | ||
137 | |||
138 | static void gen_urshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh) | ||
139 | { | ||
140 | - TCGv_i32 t = tcg_temp_new_i32(); | ||
141 | + TCGv_i32 t; | ||
142 | |||
143 | + /* Handle shift by the input size for the benefit of trans_URSHR_ri */ | ||
144 | + if (sh == 32) { | ||
145 | + tcg_gen_extract_i32(d, a, sh - 1, 1); | ||
146 | + return; | ||
147 | + } | ||
148 | + t = tcg_temp_new_i32(); | ||
149 | tcg_gen_extract_i32(t, a, sh - 1, 1); | ||
150 | tcg_gen_shri_i32(d, a, sh); | ||
151 | tcg_gen_add_i32(d, d, t); | ||
152 | @@ -XXX,XX +XXX,XX @@ static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
153 | return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48); | ||
25 | } | 154 | } |
26 | 155 | ||
27 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 156 | +static bool do_mve_sh_ri(DisasContext *s, arg_mve_sh_ri *a, ShiftImmFn *fn) |
28 | * self-modifying code correctly and also to take | 157 | +{ |
29 | * any pending interrupts immediately. | 158 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
30 | */ | 159 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ |
31 | - gen_goto_tb(s, 0, s->pc & ~1); | 160 | + return false; |
32 | + gen_goto_tb(s, 0, s->pc); | 161 | + } |
33 | return; | 162 | + if (!dc_isar_feature(aa32_mve, s) || |
34 | case 7: /* sb */ | 163 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || |
35 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | 164 | + a->rda == 13 || a->rda == 15) { |
36 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 165 | + /* These rda cases are UNPREDICTABLE; we choose to UNDEF */ |
37 | * for TCG; MB and end the TB instead. | 166 | + unallocated_encoding(s); |
38 | */ | 167 | + return true; |
39 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | 168 | + } |
40 | - gen_goto_tb(s, 0, s->pc & ~1); | 169 | + |
41 | + gen_goto_tb(s, 0, s->pc); | 170 | + if (a->shim == 0) { |
42 | return; | 171 | + a->shim = 32; |
43 | default: | 172 | + } |
44 | goto illegal_op; | 173 | + fn(cpu_R[a->rda], cpu_R[a->rda], a->shim); |
45 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 174 | + |
46 | * and also to take any pending interrupts | 175 | + return true; |
47 | * immediately. | 176 | +} |
48 | */ | 177 | + |
49 | - gen_goto_tb(s, 0, s->pc & ~1); | 178 | +static bool trans_URSHR_ri(DisasContext *s, arg_mve_sh_ri *a) |
50 | + gen_goto_tb(s, 0, s->pc); | 179 | +{ |
51 | break; | 180 | + return do_mve_sh_ri(s, a, gen_urshr32_i32); |
52 | case 7: /* sb */ | 181 | +} |
53 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | 182 | + |
54 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 183 | +static bool trans_SRSHR_ri(DisasContext *s, arg_mve_sh_ri *a) |
55 | * for TCG; MB and end the TB instead. | 184 | +{ |
56 | */ | 185 | + return do_mve_sh_ri(s, a, gen_srshr32_i32); |
57 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | 186 | +} |
58 | - gen_goto_tb(s, 0, s->pc & ~1); | 187 | + |
59 | + gen_goto_tb(s, 0, s->pc); | 188 | +static void gen_mve_sqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift) |
60 | break; | 189 | +{ |
61 | default: | 190 | + gen_helper_mve_sqshl(r, cpu_env, n, tcg_constant_i32(shift)); |
62 | goto illegal_op; | 191 | +} |
192 | + | ||
193 | +static bool trans_SQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
194 | +{ | ||
195 | + return do_mve_sh_ri(s, a, gen_mve_sqshl); | ||
196 | +} | ||
197 | + | ||
198 | +static void gen_mve_uqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift) | ||
199 | +{ | ||
200 | + gen_helper_mve_uqshl(r, cpu_env, n, tcg_constant_i32(shift)); | ||
201 | +} | ||
202 | + | ||
203 | +static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
204 | +{ | ||
205 | + return do_mve_sh_ri(s, a, gen_mve_uqshl); | ||
206 | +} | ||
207 | + | ||
208 | /* | ||
209 | * Multiply and multiply accumulate | ||
210 | */ | ||
63 | -- | 211 | -- |
64 | 2.20.1 | 212 | 2.20.1 |
65 | 213 | ||
66 | 214 | diff view generated by jsdifflib |
1 | When generating an architectural single-step exception we were | 1 | Implement the MVE shifts by register, which perform |
---|---|---|---|
2 | routing it to the "default exception level", which is to say | 2 | shifts on a single general-purpose register. |
3 | the same exception level we execute at except that EL0 exceptions | ||
4 | go to EL1. This is incorrect because the debug exception level | ||
5 | can be configured by the guest for situations such as single | ||
6 | stepping of EL0 and EL1 code by EL2. | ||
7 | 3 | ||
8 | We have to track the target debug exception level in the TB | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | flags, because it is dependent on CPU state like HCR_EL2.TGE | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | and MDCR_EL2.TDE. (That we were previously calling the | 6 | Message-id: 20210628135835.6690-19-peter.maydell@linaro.org |
11 | arm_debug_target_el() function to determine dc->ss_same_el | 7 | --- |
12 | is itself a bug, though one that would only have manifested | 8 | target/arm/helper-mve.h | 2 ++ |
13 | as incorrect syndrome information.) Since we are out of TB | 9 | target/arm/translate.h | 1 + |
14 | flag bits unless we want to expand into the cs_base field, | 10 | target/arm/t32.decode | 18 ++++++++++++++---- |
15 | we share some bits with the M-profile only HANDLER and | 11 | target/arm/mve_helper.c | 10 ++++++++++ |
16 | STACKCHECK bits, since only A-profile has this singlestep. | 12 | target/arm/translate.c | 30 ++++++++++++++++++++++++++++++ |
13 | 5 files changed, 57 insertions(+), 4 deletions(-) | ||
17 | 14 | ||
18 | Fixes: https://bugs.launchpad.net/qemu/+bug/1838913 | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
21 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
22 | Message-id: 20190805130952.4415-3-peter.maydell@linaro.org | ||
23 | --- | ||
24 | target/arm/cpu.h | 5 +++++ | ||
25 | target/arm/translate.h | 15 +++++++++++---- | ||
26 | target/arm/helper.c | 6 ++++++ | ||
27 | target/arm/translate-a64.c | 2 +- | ||
28 | target/arm/translate.c | 4 +++- | ||
29 | 5 files changed, 26 insertions(+), 6 deletions(-) | ||
30 | |||
31 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/helper-mve.h |
34 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/helper-mve.h |
35 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, PSTATE_SS, 26, 1) | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) |
36 | /* Target EL if we take a floating-point-disabled exception */ | 20 | |
37 | FIELD(TBFLAG_ANY, FPEXC_EL, 24, 2) | 21 | DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) |
38 | FIELD(TBFLAG_ANY, BE_DATA, 23, 1) | 22 | DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) |
39 | +/* | 23 | +DEF_HELPER_FLAGS_3(mve_uqrshl, TCG_CALL_NO_RWG, i32, env, i32, i32) |
40 | + * For A-profile only, target EL for debug exceptions. | 24 | +DEF_HELPER_FLAGS_3(mve_sqrshr, TCG_CALL_NO_RWG, i32, env, i32, i32) |
41 | + * Note that this overlaps with the M-profile-only HANDLER and STACKCHECK bits. | ||
42 | + */ | ||
43 | +FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 21, 2) | ||
44 | |||
45 | /* Bit usage when in AArch32 state: */ | ||
46 | FIELD(TBFLAG_A32, THUMB, 0, 1) | ||
47 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 25 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
48 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/target/arm/translate.h | 27 | --- a/target/arm/translate.h |
50 | +++ b/target/arm/translate.h | 28 | +++ b/target/arm/translate.h |
51 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 29 | @@ -XXX,XX +XXX,XX @@ typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); |
52 | uint32_t svc_imm; | 30 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); |
53 | int aarch64; | 31 | typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); |
54 | int current_el; | 32 | typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift); |
55 | + /* Debug target exception level for single-step exceptions */ | 33 | +typedef void ShiftFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32); |
56 | + int debug_target_el; | 34 | |
57 | GHashTable *cp_regs; | 35 | /** |
58 | uint64_t features; /* CPU features bits */ | 36 | * arm_tbflags_from_tb: |
59 | /* Because unallocated encodings generate different exception syndrome | 37 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode |
60 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 38 | index XXXXXXX..XXXXXXX 100644 |
61 | * ie A64 LDX*, LDAX*, A32/T32 LDREX*, LDAEX*. | 39 | --- a/target/arm/t32.decode |
62 | */ | 40 | +++ b/target/arm/t32.decode |
63 | bool is_ldex; | 41 | @@ -XXX,XX +XXX,XX @@ |
64 | - /* True if a single-step exception will be taken to the current EL */ | 42 | &mve_shl_ri rdalo rdahi shim |
65 | - bool ss_same_el; | 43 | &mve_shl_rr rdalo rdahi rm |
66 | /* True if v8.3-PAuth is active. */ | 44 | &mve_sh_ri rda shim |
67 | bool pauth_active; | 45 | +&mve_sh_rr rda rm |
68 | /* True with v8.5-BTI and SCTLR_ELx.BT* set. */ | 46 | |
69 | @@ -XXX,XX +XXX,XX @@ static inline void gen_exception(int excp, uint32_t syndrome, | 47 | # rdahi: bits [3:1] from insn, bit 0 is 1 |
70 | /* Generate an architectural singlestep exception */ | 48 | # rdalo: bits [3:1] from insn, bit 0 is 0 |
71 | static inline void gen_swstep_exception(DisasContext *s, int isv, int ex) | 49 | @@ -XXX,XX +XXX,XX @@ |
50 | &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
51 | @mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \ | ||
52 | &mve_sh_ri shim=%imm5_12_6 | ||
53 | +@mve_sh_rr ....... .... . rda:4 rm:4 .... .... .... &mve_sh_rr | ||
54 | |||
72 | { | 55 | { |
73 | - gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, isv, ex), | 56 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi |
74 | - default_exception_el(s)); | 57 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi |
75 | + bool same_el = (s->debug_target_el == s->current_el); | 58 | SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri |
76 | + | ||
77 | + /* | ||
78 | + * If singlestep is targeting a lower EL than the current one, | ||
79 | + * then s->ss_active must be false and we can never get here. | ||
80 | + */ | ||
81 | + assert(s->debug_target_el >= s->current_el); | ||
82 | + | ||
83 | + gen_exception(EXCP_UDEF, syn_swstep(same_el, isv, ex), s->debug_target_el); | ||
84 | } | ||
85 | |||
86 | /* | ||
87 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/target/arm/helper.c | ||
90 | +++ b/target/arm/helper.c | ||
91 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
92 | } | ||
93 | } | 59 | } |
94 | 60 | ||
95 | + if (!arm_feature(env, ARM_FEATURE_M)) { | 61 | - LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr |
96 | + int target_el = arm_debug_target_el(env); | 62 | - ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr |
97 | + | 63 | - UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr |
98 | + flags = FIELD_DP32(flags, TBFLAG_ANY, DEBUG_TARGET_EL, target_el); | 64 | - SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr |
65 | + { | ||
66 | + UQRSHL_rr 1110101 0010 1 .... .... 1111 0000 1101 @mve_sh_rr | ||
67 | + LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
68 | + UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr | ||
99 | + } | 69 | + } |
100 | + | 70 | + |
101 | *pflags = flags; | 71 | + { |
102 | *cs_base = 0; | 72 | + SQRSHR_rr 1110101 0010 1 .... .... 1111 0010 1101 @mve_sh_rr |
73 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
74 | + SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr | ||
75 | + } | ||
76 | + | ||
77 | UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr | ||
78 | SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr | ||
79 | ] | ||
80 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/arm/mve_helper.c | ||
83 | +++ b/target/arm/mve_helper.c | ||
84 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
85 | { | ||
86 | return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | ||
103 | } | 87 | } |
104 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 88 | + |
105 | index XXXXXXX..XXXXXXX 100644 | 89 | +uint32_t HELPER(mve_uqrshl)(CPUARMState *env, uint32_t n, uint32_t shift) |
106 | --- a/target/arm/translate-a64.c | 90 | +{ |
107 | +++ b/target/arm/translate-a64.c | 91 | + return do_uqrshl_bhs(n, (int8_t)shift, 32, true, &env->QF); |
108 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 92 | +} |
109 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | 93 | + |
110 | dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | 94 | +uint32_t HELPER(mve_sqrshr)(CPUARMState *env, uint32_t n, uint32_t shift) |
111 | dc->is_ldex = false; | 95 | +{ |
112 | - dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el); | 96 | + return do_sqrshl_bhs(n, -(int8_t)shift, 32, true, &env->QF); |
113 | + dc->debug_target_el = FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | 97 | +} |
114 | |||
115 | /* Bound the number of insns to execute to those left on the page. */ | ||
116 | bound = -(dc->base.pc_first | TARGET_PAGE_MASK) / 4; | ||
117 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 98 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
118 | index XXXXXXX..XXXXXXX 100644 | 99 | index XXXXXXX..XXXXXXX 100644 |
119 | --- a/target/arm/translate.c | 100 | --- a/target/arm/translate.c |
120 | +++ b/target/arm/translate.c | 101 | +++ b/target/arm/translate.c |
121 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 102 | @@ -XXX,XX +XXX,XX @@ static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) |
122 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | 103 | return do_mve_sh_ri(s, a, gen_mve_uqshl); |
123 | dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | 104 | } |
124 | dc->is_ldex = false; | 105 | |
125 | - dc->ss_same_el = false; /* Can't be true since EL_d must be AArch64 */ | 106 | +static bool do_mve_sh_rr(DisasContext *s, arg_mve_sh_rr *a, ShiftFn *fn) |
126 | + if (!arm_feature(env, ARM_FEATURE_M)) { | 107 | +{ |
127 | + dc->debug_target_el = FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | 108 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
109 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
110 | + return false; | ||
128 | + } | 111 | + } |
129 | 112 | + if (!dc_isar_feature(aa32_mve, s) || | |
130 | dc->page_start = dc->base.pc_first & TARGET_PAGE_MASK; | 113 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || |
131 | 114 | + a->rda == 13 || a->rda == 15 || a->rm == 13 || a->rm == 15 || | |
115 | + a->rm == a->rda) { | ||
116 | + /* These rda/rm cases are UNPREDICTABLE; we choose to UNDEF */ | ||
117 | + unallocated_encoding(s); | ||
118 | + return true; | ||
119 | + } | ||
120 | + | ||
121 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ | ||
122 | + fn(cpu_R[a->rda], cpu_env, cpu_R[a->rda], cpu_R[a->rm]); | ||
123 | + return true; | ||
124 | +} | ||
125 | + | ||
126 | +static bool trans_SQRSHR_rr(DisasContext *s, arg_mve_sh_rr *a) | ||
127 | +{ | ||
128 | + return do_mve_sh_rr(s, a, gen_helper_mve_sqrshr); | ||
129 | +} | ||
130 | + | ||
131 | +static bool trans_UQRSHL_rr(DisasContext *s, arg_mve_sh_rr *a) | ||
132 | +{ | ||
133 | + return do_mve_sh_rr(s, a, gen_helper_mve_uqrshl); | ||
134 | +} | ||
135 | + | ||
136 | /* | ||
137 | * Multiply and multiply accumulate | ||
138 | */ | ||
132 | -- | 139 | -- |
133 | 2.20.1 | 140 | 2.20.1 |
134 | 141 | ||
135 | 142 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | The offset is variable depending on the instruction set, whereas | ||
4 | we have stored values for the current pc and the next pc. Passing | ||
5 | in the actual value is clearer in intent. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20190807045335.1361-8-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/translate-a64.c | 25 ++++++++++++++----------- | ||
14 | target/arm/translate-vfp.inc.c | 6 +++--- | ||
15 | target/arm/translate.c | 31 ++++++++++++++++--------------- | ||
16 | 3 files changed, 33 insertions(+), 29 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/translate-a64.c | ||
21 | +++ b/target/arm/translate-a64.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
23 | s->base.is_jmp = DISAS_NORETURN; | ||
24 | } | ||
25 | |||
26 | -static void gen_exception_insn(DisasContext *s, int offset, int excp, | ||
27 | +static void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, | ||
28 | uint32_t syndrome, uint32_t target_el) | ||
29 | { | ||
30 | - gen_a64_set_pc_im(s->base.pc_next - offset); | ||
31 | + gen_a64_set_pc_im(pc); | ||
32 | gen_exception(excp, syndrome, target_el); | ||
33 | s->base.is_jmp = DISAS_NORETURN; | ||
34 | } | ||
35 | @@ -XXX,XX +XXX,XX @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) | ||
36 | void unallocated_encoding(DisasContext *s) | ||
37 | { | ||
38 | /* Unallocated and reserved encodings are uncategorized */ | ||
39 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
40 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
41 | default_exception_el(s)); | ||
42 | } | ||
43 | |||
44 | @@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s) | ||
45 | return true; | ||
46 | } | ||
47 | |||
48 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_fp_access_trap(1, 0xe, false), | ||
49 | - s->fp_excp_el); | ||
50 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
51 | + syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
52 | return false; | ||
53 | } | ||
54 | |||
55 | @@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s) | ||
56 | bool sve_access_check(DisasContext *s) | ||
57 | { | ||
58 | if (s->sve_excp_el) { | ||
59 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_sve_access_trap(), | ||
60 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_sve_access_trap(), | ||
61 | s->sve_excp_el); | ||
62 | return false; | ||
63 | } | ||
64 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
65 | switch (op2_ll) { | ||
66 | case 1: /* SVC */ | ||
67 | gen_ss_advance(s); | ||
68 | - gen_exception_insn(s, 0, EXCP_SWI, syn_aa64_svc(imm16), | ||
69 | - default_exception_el(s)); | ||
70 | + gen_exception_insn(s, s->base.pc_next, EXCP_SWI, | ||
71 | + syn_aa64_svc(imm16), default_exception_el(s)); | ||
72 | break; | ||
73 | case 2: /* HVC */ | ||
74 | if (s->current_el == 0) { | ||
75 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
76 | gen_a64_set_pc_im(s->pc_curr); | ||
77 | gen_helper_pre_hvc(cpu_env); | ||
78 | gen_ss_advance(s); | ||
79 | - gen_exception_insn(s, 0, EXCP_HVC, syn_aa64_hvc(imm16), 2); | ||
80 | + gen_exception_insn(s, s->base.pc_next, EXCP_HVC, | ||
81 | + syn_aa64_hvc(imm16), 2); | ||
82 | break; | ||
83 | case 3: /* SMC */ | ||
84 | if (s->current_el == 0) { | ||
85 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
86 | gen_helper_pre_smc(cpu_env, tmp); | ||
87 | tcg_temp_free_i32(tmp); | ||
88 | gen_ss_advance(s); | ||
89 | - gen_exception_insn(s, 0, EXCP_SMC, syn_aa64_smc(imm16), 3); | ||
90 | + gen_exception_insn(s, s->base.pc_next, EXCP_SMC, | ||
91 | + syn_aa64_smc(imm16), 3); | ||
92 | break; | ||
93 | default: | ||
94 | unallocated_encoding(s); | ||
95 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | ||
96 | if (s->btype != 0 | ||
97 | && s->guarded_page | ||
98 | && !btype_destination_ok(insn, s->bt, s->btype)) { | ||
99 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_btitrap(s->btype), | ||
100 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
101 | + syn_btitrap(s->btype), | ||
102 | default_exception_el(s)); | ||
103 | return; | ||
104 | } | ||
105 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/translate-vfp.inc.c | ||
108 | +++ b/target/arm/translate-vfp.inc.c | ||
109 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | ||
110 | { | ||
111 | if (s->fp_excp_el) { | ||
112 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
113 | - gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | ||
114 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, syn_uncategorized(), | ||
115 | s->fp_excp_el); | ||
116 | } else { | ||
117 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
118 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
119 | syn_fp_access_trap(1, 0xe, false), | ||
120 | s->fp_excp_el); | ||
121 | } | ||
122 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | ||
123 | |||
124 | if (!s->vfp_enabled && !ignore_vfp_enabled) { | ||
125 | assert(!arm_dc_feature(s, ARM_FEATURE_M)); | ||
126 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
127 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
128 | default_exception_el(s)); | ||
129 | return false; | ||
130 | } | ||
131 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/arm/translate.c | ||
134 | +++ b/target/arm/translate.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
136 | s->base.is_jmp = DISAS_NORETURN; | ||
137 | } | ||
138 | |||
139 | -static void gen_exception_insn(DisasContext *s, int offset, int excp, | ||
140 | +static void gen_exception_insn(DisasContext *s, uint32_t pc, int excp, | ||
141 | int syn, uint32_t target_el) | ||
142 | { | ||
143 | gen_set_condexec(s); | ||
144 | - gen_set_pc_im(s, s->base.pc_next - offset); | ||
145 | + gen_set_pc_im(s, pc); | ||
146 | gen_exception(excp, syn, target_el); | ||
147 | s->base.is_jmp = DISAS_NORETURN; | ||
148 | } | ||
149 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | ||
150 | return; | ||
151 | } | ||
152 | |||
153 | - gen_exception_insn(s, s->thumb ? 2 : 4, EXCP_UDEF, syn_uncategorized(), | ||
154 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
155 | default_exception_el(s)); | ||
156 | } | ||
157 | |||
158 | @@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn, | ||
159 | |||
160 | undef: | ||
161 | /* If we get here then some access check did not pass */ | ||
162 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), exc_target); | ||
163 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
164 | + syn_uncategorized(), exc_target); | ||
165 | return false; | ||
166 | } | ||
167 | |||
168 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
169 | * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
170 | */ | ||
171 | if (s->fp_excp_el) { | ||
172 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
173 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
174 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
175 | return 0; | ||
176 | } | ||
177 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
178 | * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
179 | */ | ||
180 | if (s->fp_excp_el) { | ||
181 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
182 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
183 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
184 | return 0; | ||
185 | } | ||
186 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
187 | } | ||
188 | |||
189 | if (s->fp_excp_el) { | ||
190 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
191 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
192 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
193 | return 0; | ||
194 | } | ||
195 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) | ||
196 | off_rm = vfp_reg_offset(0, rm); | ||
197 | } | ||
198 | if (s->fp_excp_el) { | ||
199 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
200 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
201 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
202 | return 0; | ||
203 | } | ||
204 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
205 | * For the UNPREDICTABLE cases we choose to UNDEF. | ||
206 | */ | ||
207 | if (s->current_el == 1 && !s->ns && mode == ARM_CPU_MODE_MON) { | ||
208 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), 3); | ||
209 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), 3); | ||
210 | return; | ||
211 | } | ||
212 | |||
213 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
214 | } | ||
215 | |||
216 | if (undef) { | ||
217 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
218 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
219 | default_exception_el(s)); | ||
220 | return; | ||
221 | } | ||
222 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
223 | * UsageFault exception. | ||
224 | */ | ||
225 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
226 | - gen_exception_insn(s, 4, EXCP_INVSTATE, syn_uncategorized(), | ||
227 | + gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
228 | default_exception_el(s)); | ||
229 | return; | ||
230 | } | ||
231 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
232 | break; | ||
233 | default: | ||
234 | illegal_op: | ||
235 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
236 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
237 | default_exception_el(s)); | ||
238 | break; | ||
239 | } | ||
240 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
241 | } | ||
242 | |||
243 | /* All other insns: NOCP */ | ||
244 | - gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | ||
245 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, syn_uncategorized(), | ||
246 | default_exception_el(s)); | ||
247 | break; | ||
248 | } | ||
249 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
250 | } | ||
251 | return; | ||
252 | illegal_op: | ||
253 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
254 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
255 | default_exception_el(s)); | ||
256 | } | ||
257 | |||
258 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
259 | return; | ||
260 | illegal_op: | ||
261 | undef: | ||
262 | - gen_exception_insn(s, 2, EXCP_UDEF, syn_uncategorized(), | ||
263 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
264 | default_exception_el(s)); | ||
265 | } | ||
266 | |||
267 | -- | ||
268 | 2.20.1 | ||
269 | |||
270 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Replace x = double_saturate(y) with x = add_saturate(y, y). | ||
4 | There is no need for a separate more specialized helper. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190807045335.1361-12-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper.h | 1 - | ||
13 | target/arm/op_helper.c | 15 --------------- | ||
14 | target/arm/translate.c | 4 ++-- | ||
15 | 3 files changed, 2 insertions(+), 18 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/helper.h | ||
20 | +++ b/target/arm/helper.h | ||
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(add_saturate, i32, env, i32, i32) | ||
22 | DEF_HELPER_3(sub_saturate, i32, env, i32, i32) | ||
23 | DEF_HELPER_3(add_usaturate, i32, env, i32, i32) | ||
24 | DEF_HELPER_3(sub_usaturate, i32, env, i32, i32) | ||
25 | -DEF_HELPER_2(double_saturate, i32, env, s32) | ||
26 | DEF_HELPER_FLAGS_2(sdiv, TCG_CALL_NO_RWG_SE, s32, s32, s32) | ||
27 | DEF_HELPER_FLAGS_2(udiv, TCG_CALL_NO_RWG_SE, i32, i32, i32) | ||
28 | DEF_HELPER_FLAGS_1(rbit, TCG_CALL_NO_RWG_SE, i32, i32) | ||
29 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/op_helper.c | ||
32 | +++ b/target/arm/op_helper.c | ||
33 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sub_saturate)(CPUARMState *env, uint32_t a, uint32_t b) | ||
34 | return res; | ||
35 | } | ||
36 | |||
37 | -uint32_t HELPER(double_saturate)(CPUARMState *env, int32_t val) | ||
38 | -{ | ||
39 | - uint32_t res; | ||
40 | - if (val >= 0x40000000) { | ||
41 | - res = ~SIGNBIT; | ||
42 | - env->QF = 1; | ||
43 | - } else if (val <= (int32_t)0xc0000000) { | ||
44 | - res = SIGNBIT; | ||
45 | - env->QF = 1; | ||
46 | - } else { | ||
47 | - res = val << 1; | ||
48 | - } | ||
49 | - return res; | ||
50 | -} | ||
51 | - | ||
52 | uint32_t HELPER(add_usaturate)(CPUARMState *env, uint32_t a, uint32_t b) | ||
53 | { | ||
54 | uint32_t res = a + b; | ||
55 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/translate.c | ||
58 | +++ b/target/arm/translate.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
60 | tmp = load_reg(s, rm); | ||
61 | tmp2 = load_reg(s, rn); | ||
62 | if (op1 & 2) | ||
63 | - gen_helper_double_saturate(tmp2, cpu_env, tmp2); | ||
64 | + gen_helper_add_saturate(tmp2, cpu_env, tmp2, tmp2); | ||
65 | if (op1 & 1) | ||
66 | gen_helper_sub_saturate(tmp, cpu_env, tmp, tmp2); | ||
67 | else | ||
68 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
69 | tmp = load_reg(s, rn); | ||
70 | tmp2 = load_reg(s, rm); | ||
71 | if (op & 1) | ||
72 | - gen_helper_double_saturate(tmp, cpu_env, tmp); | ||
73 | + gen_helper_add_saturate(tmp, cpu_env, tmp, tmp); | ||
74 | if (op & 2) | ||
75 | gen_helper_sub_saturate(tmp, cpu_env, tmp2, tmp); | ||
76 | else | ||
77 | -- | ||
78 | 2.20.1 | ||
79 | |||
80 | diff view generated by jsdifflib |