1 | First arm pullreq for 6.1 cycle. The big stuff here is RTH's alignment series. | 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 ccdf06c1db192152ac70a1dd974c624f566cb7d4: | ||
7 | |||
8 | Open 6.1 development tree (2021-04-30 11:15:40 +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-20210430 | 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 a6091108aa44e9017af4ca13c43f55a629e3744c: | 9 | for you to fetch changes up to 04ea4d3cfd0a21b248ece8eb7a9436a3d9898dd8: |
15 | 10 | ||
16 | hw/pci-host/gpex: Don't fault for unmapped parts of MMIO and PIO windows (2021-04-30 11:16:52 +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 | * hw/pci-host/gpex: Don't fault for unmapped parts of MMIO and PIO windows | 15 | * more MVE instructions |
21 | * hw: add compat machines for 6.1 | 16 | * hw/gpio/gpio_pwr: use shutdown function for reboot |
22 | * Fault misaligned accesses where the architecture requires it | 17 | * target/arm: Check NaN mode before silencing NaN |
23 | * Fix some corner cases of MTE faults (notably with misaligned accesses) | 18 | * tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine |
24 | * Make Thumb store insns UNDEF for Rn==1111 | 19 | * hw/arm: Add basic power management to raspi. |
25 | * hw/arm/smmuv3: Support 16K translation granule | 20 | * docs/system/arm: Add quanta-gbs-bmc, quanta-q7l1-bmc |
26 | 21 | ||
27 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
28 | Cornelia Huck (1): | 23 | Joe Komlodi (1): |
29 | hw: add compat machines for 6.1 | 24 | target/arm: Check NaN mode before silencing NaN |
30 | 25 | ||
31 | Kunkun Jiang (1): | 26 | Maxim Uvarov (1): |
32 | hw/arm/smmuv3: Support 16K translation granule | 27 | hw/gpio/gpio_pwr: use shutdown function for reboot |
33 | 28 | ||
34 | Peter Maydell (2): | 29 | Nolan Leake (1): |
35 | target/arm: Make Thumb store insns UNDEF for Rn==1111 | 30 | hw/arm: Add basic power management to raspi. |
36 | hw/pci-host/gpex: Don't fault for unmapped parts of MMIO and PIO windows | ||
37 | 31 | ||
38 | Richard Henderson (39): | 32 | Patrick Venture (2): |
39 | target/arm: Fix mte_checkN | 33 | docs/system/arm: Add quanta-q7l1-bmc reference |
40 | target/arm: Split out mte_probe_int | 34 | docs/system/arm: Add quanta-gbs-bmc reference |
41 | target/arm: Fix unaligned checks for mte_check1, mte_probe1 | ||
42 | test/tcg/aarch64: Add mte-5 | ||
43 | target/arm: Replace MTEDESC ESIZE+TSIZE with SIZEM1 | ||
44 | target/arm: Merge mte_check1, mte_checkN | ||
45 | target/arm: Rename mte_probe1 to mte_probe | ||
46 | target/arm: Simplify sve mte checking | ||
47 | target/arm: Remove log2_esize parameter to gen_mte_checkN | ||
48 | target/arm: Fix decode of align in VLDST_single | ||
49 | target/arm: Rename TBFLAG_A32, SCTLR_B | ||
50 | target/arm: Rename TBFLAG_ANY, PSTATE_SS | ||
51 | target/arm: Add wrapper macros for accessing tbflags | ||
52 | target/arm: Introduce CPUARMTBFlags | ||
53 | target/arm: Move mode specific TB flags to tb->cs_base | ||
54 | target/arm: Move TBFLAG_AM32 bits to the top | ||
55 | target/arm: Move TBFLAG_ANY bits to the bottom | ||
56 | target/arm: Add ALIGN_MEM to TBFLAG_ANY | ||
57 | target/arm: Adjust gen_aa32_{ld, st}_i32 for align+endianness | ||
58 | target/arm: Merge gen_aa32_frob64 into gen_aa32_ld_i64 | ||
59 | target/arm: Fix SCTLR_B test for TCGv_i64 load/store | ||
60 | target/arm: Adjust gen_aa32_{ld, st}_i64 for align+endianness | ||
61 | target/arm: Enforce word alignment for LDRD/STRD | ||
62 | target/arm: Enforce alignment for LDA/LDAH/STL/STLH | ||
63 | target/arm: Enforce alignment for LDM/STM | ||
64 | target/arm: Enforce alignment for RFE | ||
65 | target/arm: Enforce alignment for SRS | ||
66 | target/arm: Enforce alignment for VLDM/VSTM | ||
67 | target/arm: Enforce alignment for VLDR/VSTR | ||
68 | target/arm: Enforce alignment for VLDn (all lanes) | ||
69 | target/arm: Enforce alignment for VLDn/VSTn (multiple) | ||
70 | target/arm: Enforce alignment for VLDn/VSTn (single) | ||
71 | target/arm: Use finalize_memop for aa64 gpr load/store | ||
72 | target/arm: Use finalize_memop for aa64 fpr load/store | ||
73 | target/arm: Enforce alignment for aa64 load-acq/store-rel | ||
74 | target/arm: Use MemOp for size + endian in aa64 vector ld/st | ||
75 | target/arm: Enforce alignment for aa64 vector LDn/STn (multiple) | ||
76 | target/arm: Enforce alignment for aa64 vector LDn/STn (single) | ||
77 | target/arm: Enforce alignment for sve LD1R | ||
78 | 35 | ||
79 | include/hw/boards.h | 3 + | 36 | Peter Maydell (18): |
80 | include/hw/i386/pc.h | 3 + | 37 | target/arm: Fix MVE widening/narrowing VLDR/VSTR offset calculation |
81 | include/hw/pci-host/gpex.h | 4 + | 38 | target/arm: Fix bugs in MVE VRMLALDAVH, VRMLSLDAVH |
82 | target/arm/cpu.h | 105 ++++++++++----- | 39 | target/arm: Make asimd_imm_const() public |
83 | target/arm/helper-a64.h | 3 +- | 40 | target/arm: Use asimd_imm_const for A64 decode |
84 | target/arm/internals.h | 11 +- | 41 | target/arm: Use dup_const() instead of bitfield_replicate() |
85 | target/arm/translate-a64.h | 2 +- | 42 | target/arm: Implement MVE logical immediate insns |
86 | target/arm/translate.h | 38 ++++++ | 43 | target/arm: Implement MVE vector shift left by immediate insns |
87 | target/arm/neon-ls.decode | 4 +- | 44 | target/arm: Implement MVE vector shift right by immediate insns |
88 | hw/arm/smmuv3.c | 6 +- | 45 | target/arm: Implement MVE VSHLL |
89 | hw/arm/virt.c | 7 +- | 46 | target/arm: Implement MVE VSRI, VSLI |
90 | hw/core/machine.c | 5 + | 47 | target/arm: Implement MVE VSHRN, VRSHRN |
91 | hw/i386/pc.c | 3 + | 48 | target/arm: Implement MVE saturating narrowing shifts |
92 | hw/i386/pc_piix.c | 14 +- | 49 | target/arm: Implement MVE VSHLC |
93 | hw/i386/pc_q35.c | 13 +- | 50 | target/arm: Implement MVE VADDLV |
94 | hw/pci-host/gpex.c | 56 +++++++- | 51 | target/arm: Implement MVE long shifts by immediate |
95 | hw/ppc/spapr.c | 17 ++- | 52 | target/arm: Implement MVE long shifts by register |
96 | hw/s390x/s390-virtio-ccw.c | 14 +- | 53 | target/arm: Implement MVE shifts by immediate |
97 | target/arm/helper-a64.c | 2 +- | 54 | target/arm: Implement MVE shifts by register |
98 | target/arm/helper.c | 162 ++++++++++++---------- | ||
99 | target/arm/mte_helper.c | 185 ++++++++++--------------- | ||
100 | target/arm/sve_helper.c | 100 +++++--------- | ||
101 | target/arm/translate-a64.c | 236 ++++++++++++++++---------------- | ||
102 | target/arm/translate-sve.c | 11 +- | ||
103 | target/arm/translate.c | 274 ++++++++++++++++++++++---------------- | ||
104 | tests/tcg/aarch64/mte-5.c | 44 ++++++ | ||
105 | target/arm/translate-neon.c.inc | 117 ++++++++++++---- | ||
106 | target/arm/translate-vfp.c.inc | 20 +-- | ||
107 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
108 | 29 files changed, 878 insertions(+), 583 deletions(-) | ||
109 | create mode 100644 tests/tcg/aarch64/mte-5.c | ||
110 | 55 | ||
56 | Philippe Mathieu-Daudé (1): | ||
57 | tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine | ||
58 | |||
59 | docs/system/arm/aspeed.rst | 1 + | ||
60 | docs/system/arm/nuvoton.rst | 5 +- | ||
61 | include/hw/arm/bcm2835_peripherals.h | 3 +- | ||
62 | include/hw/misc/bcm2835_powermgt.h | 29 ++ | ||
63 | target/arm/helper-mve.h | 108 +++++++ | ||
64 | target/arm/translate.h | 41 +++ | ||
65 | target/arm/mve.decode | 177 ++++++++++- | ||
66 | target/arm/t32.decode | 71 ++++- | ||
67 | hw/arm/bcm2835_peripherals.c | 13 +- | ||
68 | hw/gpio/gpio_pwr.c | 2 +- | ||
69 | hw/misc/bcm2835_powermgt.c | 160 ++++++++++ | ||
70 | target/arm/helper-a64.c | 12 +- | ||
71 | target/arm/mve_helper.c | 524 +++++++++++++++++++++++++++++++-- | ||
72 | target/arm/translate-a64.c | 86 +----- | ||
73 | target/arm/translate-mve.c | 261 +++++++++++++++- | ||
74 | target/arm/translate-neon.c | 81 ----- | ||
75 | target/arm/translate.c | 327 +++++++++++++++++++- | ||
76 | target/arm/vfp_helper.c | 24 +- | ||
77 | hw/misc/meson.build | 1 + | ||
78 | tests/acceptance/boot_linux_console.py | 43 +++ | ||
79 | 20 files changed, 1760 insertions(+), 209 deletions(-) | ||
80 | create mode 100644 include/hw/misc/bcm2835_powermgt.h | ||
81 | create mode 100644 hw/misc/bcm2835_powermgt.c | ||
82 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Kunkun Jiang <jiangkunkun@huawei.com> | ||
2 | 1 | ||
3 | The driver can query some bits in SMMUv3 IDR5 to learn which | ||
4 | translation granules are supported. Arm recommends that SMMUv3 | ||
5 | implementations support at least 4K and 64K granules. But in | ||
6 | the vSMMUv3, there seems to be no reason not to support 16K | ||
7 | translation granule. In addition, if 16K is not supported, | ||
8 | vSVA will failed to be enabled in the future for 16K guest | ||
9 | kernel. So it'd better to support it. | ||
10 | |||
11 | Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com> | ||
12 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
13 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/arm/smmuv3.c | 6 ++++-- | ||
17 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/arm/smmuv3.c | ||
22 | +++ b/hw/arm/smmuv3.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s) | ||
24 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1); | ||
25 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1); | ||
26 | |||
27 | - /* 4K and 64K granule support */ | ||
28 | + /* 4K, 16K and 64K granule support */ | ||
29 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN4K, 1); | ||
30 | + s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN16K, 1); | ||
31 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN64K, 1); | ||
32 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */ | ||
33 | |||
34 | @@ -XXX,XX +XXX,XX @@ static int decode_cd(SMMUTransCfg *cfg, CD *cd, SMMUEventInfo *event) | ||
35 | |||
36 | tg = CD_TG(cd, i); | ||
37 | tt->granule_sz = tg2granule(tg, i); | ||
38 | - if ((tt->granule_sz != 12 && tt->granule_sz != 16) || CD_ENDI(cd)) { | ||
39 | + if ((tt->granule_sz != 12 && tt->granule_sz != 14 && | ||
40 | + tt->granule_sz != 16) || CD_ENDI(cd)) { | ||
41 | goto bad_cd; | ||
42 | } | ||
43 | |||
44 | -- | ||
45 | 2.20.1 | ||
46 | |||
47 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Patrick Venture <venture@google.com> |
---|---|---|---|
2 | 2 | ||
3 | For 128-bit load/store, use 16-byte alignment. This | 3 | Adds a line-item reference to the supported quanta-q71l-bmc aspeed |
4 | requires that we perform the two operations in the | 4 | entry. |
5 | correct order so that we generate the alignment fault | ||
6 | before modifying memory. | ||
7 | 5 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Patrick Venture <venture@google.com> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
10 | Message-id: 20210419202257.161730-27-richard.henderson@linaro.org | 8 | Message-id: 20210615192848.1065297-2-venture@google.com |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 10 | --- |
13 | target/arm/translate-a64.c | 42 +++++++++++++++++++++++--------------- | 11 | docs/system/arm/aspeed.rst | 1 + |
14 | 1 file changed, 26 insertions(+), 16 deletions(-) | 12 | 1 file changed, 1 insertion(+) |
15 | 13 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 16 | --- a/docs/system/arm/aspeed.rst |
19 | +++ b/target/arm/translate-a64.c | 17 | +++ b/docs/system/arm/aspeed.rst |
20 | @@ -XXX,XX +XXX,XX @@ static void do_gpr_ld(DisasContext *s, TCGv_i64 dest, TCGv_i64 tcg_addr, | 18 | @@ -XXX,XX +XXX,XX @@ etc. |
21 | static void do_fp_st(DisasContext *s, int srcidx, TCGv_i64 tcg_addr, int size) | 19 | AST2400 SoC based machines : |
22 | { | 20 | |
23 | /* This writes the bottom N bits of a 128 bit wide vector to memory */ | 21 | - ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC |
24 | - TCGv_i64 tmp = tcg_temp_new_i64(); | 22 | +- ``quanta-q71l-bmc`` OpenBMC Quanta BMC |
25 | - tcg_gen_ld_i64(tmp, cpu_env, fp_reg_offset(s, srcidx, MO_64)); | 23 | |
26 | + TCGv_i64 tmplo = tcg_temp_new_i64(); | 24 | AST2500 SoC based machines : |
27 | + MemOp mop; | ||
28 | + | ||
29 | + tcg_gen_ld_i64(tmplo, cpu_env, fp_reg_offset(s, srcidx, MO_64)); | ||
30 | + | ||
31 | if (size < 4) { | ||
32 | - tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), | ||
33 | - s->be_data + size); | ||
34 | + mop = finalize_memop(s, size); | ||
35 | + tcg_gen_qemu_st_i64(tmplo, tcg_addr, get_mem_index(s), mop); | ||
36 | } else { | ||
37 | bool be = s->be_data == MO_BE; | ||
38 | TCGv_i64 tcg_hiaddr = tcg_temp_new_i64(); | ||
39 | + TCGv_i64 tmphi = tcg_temp_new_i64(); | ||
40 | |||
41 | + tcg_gen_ld_i64(tmphi, cpu_env, fp_reg_hi_offset(s, srcidx)); | ||
42 | + | ||
43 | + mop = s->be_data | MO_Q; | ||
44 | + tcg_gen_qemu_st_i64(be ? tmphi : tmplo, tcg_addr, get_mem_index(s), | ||
45 | + mop | (s->align_mem ? MO_ALIGN_16 : 0)); | ||
46 | tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8); | ||
47 | - tcg_gen_qemu_st_i64(tmp, be ? tcg_hiaddr : tcg_addr, get_mem_index(s), | ||
48 | - s->be_data | MO_Q); | ||
49 | - tcg_gen_ld_i64(tmp, cpu_env, fp_reg_hi_offset(s, srcidx)); | ||
50 | - tcg_gen_qemu_st_i64(tmp, be ? tcg_addr : tcg_hiaddr, get_mem_index(s), | ||
51 | - s->be_data | MO_Q); | ||
52 | + tcg_gen_qemu_st_i64(be ? tmplo : tmphi, tcg_hiaddr, | ||
53 | + get_mem_index(s), mop); | ||
54 | + | ||
55 | tcg_temp_free_i64(tcg_hiaddr); | ||
56 | + tcg_temp_free_i64(tmphi); | ||
57 | } | ||
58 | |||
59 | - tcg_temp_free_i64(tmp); | ||
60 | + tcg_temp_free_i64(tmplo); | ||
61 | } | ||
62 | |||
63 | /* | ||
64 | @@ -XXX,XX +XXX,XX @@ static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size) | ||
65 | /* This always zero-extends and writes to a full 128 bit wide vector */ | ||
66 | TCGv_i64 tmplo = tcg_temp_new_i64(); | ||
67 | TCGv_i64 tmphi = NULL; | ||
68 | + MemOp mop; | ||
69 | |||
70 | if (size < 4) { | ||
71 | - MemOp memop = s->be_data + size; | ||
72 | - tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), memop); | ||
73 | + mop = finalize_memop(s, size); | ||
74 | + tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), mop); | ||
75 | } else { | ||
76 | bool be = s->be_data == MO_BE; | ||
77 | TCGv_i64 tcg_hiaddr; | ||
78 | @@ -XXX,XX +XXX,XX @@ static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size) | ||
79 | tmphi = tcg_temp_new_i64(); | ||
80 | tcg_hiaddr = tcg_temp_new_i64(); | ||
81 | |||
82 | + mop = s->be_data | MO_Q; | ||
83 | + tcg_gen_qemu_ld_i64(be ? tmphi : tmplo, tcg_addr, get_mem_index(s), | ||
84 | + mop | (s->align_mem ? MO_ALIGN_16 : 0)); | ||
85 | tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8); | ||
86 | - tcg_gen_qemu_ld_i64(tmplo, be ? tcg_hiaddr : tcg_addr, get_mem_index(s), | ||
87 | - s->be_data | MO_Q); | ||
88 | - tcg_gen_qemu_ld_i64(tmphi, be ? tcg_addr : tcg_hiaddr, get_mem_index(s), | ||
89 | - s->be_data | MO_Q); | ||
90 | + tcg_gen_qemu_ld_i64(be ? tmplo : tmphi, tcg_hiaddr, | ||
91 | + get_mem_index(s), mop); | ||
92 | tcg_temp_free_i64(tcg_hiaddr); | ||
93 | } | ||
94 | 25 | ||
95 | -- | 26 | -- |
96 | 2.20.1 | 27 | 2.20.1 |
97 | 28 | ||
98 | 29 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Patrick Venture <venture@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Add line item reference to quanta-gbs-bmc machine. |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | |
5 | Message-id: 20210419202257.161730-32-richard.henderson@linaro.org | 5 | Signed-off-by: Patrick Venture <venture@google.com> |
6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Message-id: 20210615192848.1065297-3-venture@google.com | ||
8 | [PMM: fixed underline Sphinx warning] | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | target/arm/translate-sve.c | 2 +- | 11 | docs/system/arm/nuvoton.rst | 5 +++-- |
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 3 insertions(+), 2 deletions(-) |
10 | 13 | ||
11 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 14 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-sve.c | 16 | --- a/docs/system/arm/nuvoton.rst |
14 | +++ b/target/arm/translate-sve.c | 17 | +++ b/docs/system/arm/nuvoton.rst |
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD1R_zpri(DisasContext *s, arg_rpri_load *a) | 18 | @@ -XXX,XX +XXX,XX @@ |
16 | clean_addr = gen_mte_check1(s, temp, false, true, msz); | 19 | -Nuvoton iBMC boards (``npcm750-evb``, ``quanta-gsj``) |
17 | 20 | -===================================================== | |
18 | tcg_gen_qemu_ld_i64(temp, clean_addr, get_mem_index(s), | 21 | +Nuvoton iBMC boards (``*-bmc``, ``npcm750-evb``, ``quanta-gsj``) |
19 | - s->be_data | dtype_mop[a->dtype]); | 22 | +================================================================ |
20 | + finalize_memop(s, dtype_mop[a->dtype])); | 23 | |
21 | 24 | The `Nuvoton iBMC`_ chips (NPCM7xx) are a family of ARM-based SoCs that are | |
22 | /* Broadcast to *all* elements. */ | 25 | designed to be used as Baseboard Management Controllers (BMCs) in various |
23 | tcg_gen_gvec_dup_i64(esz, vec_full_reg_offset(s, a->rd), | 26 | @@ -XXX,XX +XXX,XX @@ segment. The following machines are based on this chip : |
27 | The NPCM730 SoC has two Cortex-A9 cores and is targeted for Data Center and | ||
28 | Hyperscale applications. The following machines are based on this chip : | ||
29 | |||
30 | +- ``quanta-gbs-bmc`` Quanta GBS server BMC | ||
31 | - ``quanta-gsj`` Quanta GSJ server BMC | ||
32 | |||
33 | There are also two more SoCs, NPCM710 and NPCM705, which are single-core | ||
24 | -- | 34 | -- |
25 | 2.20.1 | 35 | 2.20.1 |
26 | 36 | ||
27 | 37 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Nolan Leake <nolan@sigbus.net> |
---|---|---|---|
2 | 2 | ||
3 | Buglink: https://bugs.launchpad.net/bugs/1921948 | 3 | This is just enough to make reboot and poweroff work. Works for |
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 4 | linux, u-boot, and the arm trusted firmware. Not tested, but should |
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | work for plan9, and bare-metal/hobby OSes, since they seem to generally |
6 | Message-id: 20210416183106.1516563-5-richard.henderson@linaro.org | 6 | do what linux does for reset. |
7 | |||
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/] | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 18 | --- |
9 | tests/tcg/aarch64/mte-5.c | 44 +++++++++++++++++++++++++++++++ | 19 | include/hw/arm/bcm2835_peripherals.h | 3 +- |
10 | tests/tcg/aarch64/Makefile.target | 2 +- | 20 | include/hw/misc/bcm2835_powermgt.h | 29 +++++ |
11 | 2 files changed, 45 insertions(+), 1 deletion(-) | 21 | hw/arm/bcm2835_peripherals.c | 13 ++- |
12 | create mode 100644 tests/tcg/aarch64/mte-5.c | 22 | hw/misc/bcm2835_powermgt.c | 160 +++++++++++++++++++++++++++ |
13 | 23 | hw/misc/meson.build | 1 + | |
14 | diff --git a/tests/tcg/aarch64/mte-5.c b/tests/tcg/aarch64/mte-5.c | 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 | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/include/hw/arm/bcm2835_peripherals.h | ||
31 | +++ b/include/hw/arm/bcm2835_peripherals.h | ||
32 | @@ -XXX,XX +XXX,XX @@ | ||
33 | #include "hw/misc/bcm2835_mphi.h" | ||
34 | #include "hw/misc/bcm2835_thermal.h" | ||
35 | #include "hw/misc/bcm2835_cprman.h" | ||
36 | +#include "hw/misc/bcm2835_powermgt.h" | ||
37 | #include "hw/sd/sdhci.h" | ||
38 | #include "hw/sd/bcm2835_sdhost.h" | ||
39 | #include "hw/gpio/bcm2835_gpio.h" | ||
40 | @@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState { | ||
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 | ||
15 | new file mode 100644 | 50 | new file mode 100644 |
16 | index XXXXXXX..XXXXXXX | 51 | index XXXXXXX..XXXXXXX |
17 | --- /dev/null | 52 | --- /dev/null |
18 | +++ b/tests/tcg/aarch64/mte-5.c | 53 | +++ b/include/hw/misc/bcm2835_powermgt.h |
19 | @@ -XXX,XX +XXX,XX @@ | 54 | @@ -XXX,XX +XXX,XX @@ |
20 | +/* | 55 | +/* |
21 | + * Memory tagging, faulting unaligned access. | 56 | + * BCM2835 Power Management emulation |
22 | + * | 57 | + * |
23 | + * Copyright (c) 2021 Linaro Ltd | 58 | + * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com> |
24 | + * SPDX-License-Identifier: GPL-2.0-or-later | 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. | ||
25 | + */ | 63 | + */ |
26 | + | 64 | + |
27 | +#include "mte.h" | 65 | +#ifndef BCM2835_POWERMGT_H |
28 | + | 66 | +#define BCM2835_POWERMGT_H |
29 | +void pass(int sig, siginfo_t *info, void *uc) | 67 | + |
30 | +{ | 68 | +#include "hw/sysbus.h" |
31 | + assert(info->si_code == SEGV_MTESERR); | 69 | +#include "qom/object.h" |
32 | + exit(0); | 70 | + |
33 | +} | 71 | +#define TYPE_BCM2835_POWERMGT "bcm2835-powermgt" |
34 | + | 72 | +OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PowerMgtState, BCM2835_POWERMGT) |
35 | +int main(int ac, char **av) | 73 | + |
36 | +{ | 74 | +struct BCM2835PowerMgtState { |
37 | + struct sigaction sa; | 75 | + SysBusDevice busdev; |
38 | + void *p0, *p1, *p2; | 76 | + MemoryRegion iomem; |
39 | + long excl = 1; | 77 | + |
40 | + | 78 | + uint32_t rstc; |
41 | + enable_mte(PR_MTE_TCF_SYNC); | 79 | + uint32_t rsts; |
42 | + p0 = alloc_mte_mem(sizeof(*p0)); | 80 | + uint32_t wdog; |
43 | + | 81 | +}; |
44 | + /* Create two differently tagged pointers. */ | 82 | + |
45 | + asm("irg %0,%1,%2" : "=r"(p1) : "r"(p0), "r"(excl)); | 83 | +#endif |
46 | + asm("gmi %0,%1,%0" : "+r"(excl) : "r" (p1)); | 84 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c |
47 | + assert(excl != 1); | ||
48 | + asm("irg %0,%1,%2" : "=r"(p2) : "r"(p0), "r"(excl)); | ||
49 | + assert(p1 != p2); | ||
50 | + | ||
51 | + memset(&sa, 0, sizeof(sa)); | ||
52 | + sa.sa_sigaction = pass; | ||
53 | + sa.sa_flags = SA_SIGINFO; | ||
54 | + sigaction(SIGSEGV, &sa, NULL); | ||
55 | + | ||
56 | + /* Store store two different tags in sequential granules. */ | ||
57 | + asm("stg %0, [%0]" : : "r"(p1)); | ||
58 | + asm("stg %0, [%0]" : : "r"(p2 + 16)); | ||
59 | + | ||
60 | + /* Perform an unaligned load crossing the granules. */ | ||
61 | + asm volatile("ldr %0, [%1]" : "=r"(p0) : "r"(p1 + 12)); | ||
62 | + abort(); | ||
63 | +} | ||
64 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
65 | index XXXXXXX..XXXXXXX 100644 | 85 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/tests/tcg/aarch64/Makefile.target | 86 | --- a/hw/arm/bcm2835_peripherals.c |
67 | +++ b/tests/tcg/aarch64/Makefile.target | 87 | +++ b/hw/arm/bcm2835_peripherals.c |
68 | @@ -XXX,XX +XXX,XX @@ AARCH64_TESTS += bti-2 | 88 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) |
69 | 89 | ||
70 | # MTE Tests | 90 | object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr", |
71 | ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_MTE),) | 91 | OBJECT(&s->gpu_bus_mr)); |
72 | -AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-6 | 92 | + |
73 | +AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-5 mte-6 | 93 | + /* Power Management */ |
74 | mte-%: CFLAGS += -march=armv8.5-a+memtag | 94 | + object_initialize_child(obj, "powermgt", &s->powermgt, |
75 | endif | 95 | + TYPE_BCM2835_POWERMGT); |
76 | 96 | } | |
97 | |||
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')) | ||
77 | -- | 295 | -- |
78 | 2.20.1 | 296 | 2.20.1 |
79 | 297 | ||
80 | 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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Add a test booting and quickly shutdown a raspi2 machine, |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | to test the power management model: |
5 | Message-id: 20210419202257.161730-31-richard.henderson@linaro.org | 5 | |
6 | (1/1) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd: | ||
7 | console: [ 0.000000] Booting Linux on physical CPU 0xf00 | ||
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 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 48 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 49 | --- |
8 | target/arm/translate-a64.c | 9 +++++---- | 50 | tests/acceptance/boot_linux_console.py | 43 ++++++++++++++++++++++++++ |
9 | 1 file changed, 5 insertions(+), 4 deletions(-) | 51 | 1 file changed, 43 insertions(+) |
10 | 52 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 53 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py |
12 | index XXXXXXX..XXXXXXX 100644 | 54 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 55 | --- a/tests/acceptance/boot_linux_console.py |
14 | +++ b/target/arm/translate-a64.c | 56 | +++ b/tests/acceptance/boot_linux_console.py |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 57 | @@ -XXX,XX +XXX,XX @@ |
16 | int index = is_q << 3 | S << 2 | size; | 58 | from avocado import skip |
17 | int xs, total; | 59 | from avocado import skipUnless |
18 | TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; | 60 | from avocado_qemu import Test |
19 | + MemOp mop; | 61 | +from avocado_qemu import exec_command |
20 | 62 | from avocado_qemu import exec_command_and_wait_for_pattern | |
21 | if (extract32(insn, 31, 1)) { | 63 | from avocado_qemu import interrupt_interactive_console_until_pattern |
22 | unallocated_encoding(s); | 64 | from avocado_qemu import wait_for_console_pattern |
23 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 65 | @@ -XXX,XX +XXX,XX @@ def test_arm_raspi2_uart0(self): |
24 | 66 | """ | |
25 | clean_addr = gen_mte_checkN(s, tcg_rn, !is_load, is_postidx || rn != 31, | 67 | self.do_test_arm_raspi2(0) |
26 | total); | 68 | |
27 | + mop = finalize_memop(s, scale); | 69 | + def test_arm_raspi2_initrd(self): |
28 | 70 | + """ | |
29 | tcg_ebytes = tcg_const_i64(1 << scale); | 71 | + :avocado: tags=arch:arm |
30 | for (xs = 0; xs < selem; xs++) { | 72 | + :avocado: tags=machine:raspi2 |
31 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 73 | + """ |
32 | /* Load and replicate to all elements */ | 74 | + deb_url = ('http://archive.raspberrypi.org/debian/' |
33 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | 75 | + 'pool/main/r/raspberrypi-firmware/' |
34 | 76 | + 'raspberrypi-kernel_1.20190215-1_armhf.deb') | |
35 | - tcg_gen_qemu_ld_i64(tcg_tmp, clean_addr, | 77 | + deb_hash = 'cd284220b32128c5084037553db3c482426f3972' |
36 | - get_mem_index(s), s->be_data + scale); | 78 | + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
37 | + tcg_gen_qemu_ld_i64(tcg_tmp, clean_addr, get_mem_index(s), mop); | 79 | + kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img') |
38 | tcg_gen_gvec_dup_i64(scale, vec_full_reg_offset(s, rt), | 80 | + dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb') |
39 | (is_q + 1) * 8, vec_full_reg_size(s), | 81 | + |
40 | tcg_tmp); | 82 | + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' |
41 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 83 | + '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' |
42 | } else { | 84 | + 'arm/rootfs-armv7a.cpio.gz') |
43 | /* Load/store one element per register */ | 85 | + initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' |
44 | if (is_load) { | 86 | + initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) |
45 | - do_vec_ld(s, rt, index, clean_addr, scale | s->be_data); | 87 | + initrd_path = os.path.join(self.workdir, 'rootfs.cpio') |
46 | + do_vec_ld(s, rt, index, clean_addr, mop); | 88 | + archive.gzip_uncompress(initrd_path_gz, initrd_path) |
47 | } else { | 89 | + |
48 | - do_vec_st(s, rt, index, clean_addr, scale | s->be_data); | 90 | + self.vm.set_console() |
49 | + do_vec_st(s, rt, index, clean_addr, mop); | 91 | + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
50 | } | 92 | + 'earlycon=pl011,0x3f201000 console=ttyAMA0 ' |
51 | } | 93 | + 'panic=-1 noreboot ' + |
52 | tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); | 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 | ||
53 | -- | 114 | -- |
54 | 2.20.1 | 115 | 2.20.1 |
55 | 116 | ||
56 | 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 | We're about to split tbflags into two parts. These macros | 3 | If the CPU is running in default NaN mode (FPCR.DN == 1) and we execute |
4 | will ensure that the correct part is used with the correct | 4 | FRSQRTE, FRECPE, or FRECPX with a signaling NaN, parts_silence_nan_frac() will |
5 | set of bits. | 5 | assert due to fpst->default_nan_mode being set. |
6 | 6 | ||
7 | To avoid this, we check to see what NaN mode we're running in before we call | ||
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 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210419202257.161730-5-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 15 | --- |
12 | target/arm/cpu.h | 22 +++++++++- | 16 | target/arm/helper-a64.c | 12 +++++++++--- |
13 | target/arm/helper-a64.c | 2 +- | 17 | target/arm/vfp_helper.c | 24 ++++++++++++++++++------ |
14 | target/arm/helper.c | 85 +++++++++++++++++--------------------- | 18 | 2 files changed, 27 insertions(+), 9 deletions(-) |
15 | target/arm/translate-a64.c | 36 ++++++++-------- | ||
16 | target/arm/translate.c | 48 ++++++++++----------- | ||
17 | 5 files changed, 101 insertions(+), 92 deletions(-) | ||
18 | 19 | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/cpu.h | ||
22 | +++ b/target/arm/cpu.h | ||
23 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, TCMA, 16, 2) | ||
24 | FIELD(TBFLAG_A64, MTE_ACTIVE, 18, 1) | ||
25 | FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) | ||
26 | |||
27 | +/* | ||
28 | + * Helpers for using the above. | ||
29 | + */ | ||
30 | +#define DP_TBFLAG_ANY(DST, WHICH, VAL) \ | ||
31 | + (DST = FIELD_DP32(DST, TBFLAG_ANY, WHICH, VAL)) | ||
32 | +#define DP_TBFLAG_A64(DST, WHICH, VAL) \ | ||
33 | + (DST = FIELD_DP32(DST, TBFLAG_A64, WHICH, VAL)) | ||
34 | +#define DP_TBFLAG_A32(DST, WHICH, VAL) \ | ||
35 | + (DST = FIELD_DP32(DST, TBFLAG_A32, WHICH, VAL)) | ||
36 | +#define DP_TBFLAG_M32(DST, WHICH, VAL) \ | ||
37 | + (DST = FIELD_DP32(DST, TBFLAG_M32, WHICH, VAL)) | ||
38 | +#define DP_TBFLAG_AM32(DST, WHICH, VAL) \ | ||
39 | + (DST = FIELD_DP32(DST, TBFLAG_AM32, WHICH, VAL)) | ||
40 | + | ||
41 | +#define EX_TBFLAG_ANY(IN, WHICH) FIELD_EX32(IN, TBFLAG_ANY, WHICH) | ||
42 | +#define EX_TBFLAG_A64(IN, WHICH) FIELD_EX32(IN, TBFLAG_A64, WHICH) | ||
43 | +#define EX_TBFLAG_A32(IN, WHICH) FIELD_EX32(IN, TBFLAG_A32, WHICH) | ||
44 | +#define EX_TBFLAG_M32(IN, WHICH) FIELD_EX32(IN, TBFLAG_M32, WHICH) | ||
45 | +#define EX_TBFLAG_AM32(IN, WHICH) FIELD_EX32(IN, TBFLAG_AM32, WHICH) | ||
46 | + | ||
47 | /** | ||
48 | * cpu_mmu_index: | ||
49 | * @env: The cpu environment | ||
50 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) | ||
51 | */ | ||
52 | static inline int cpu_mmu_index(CPUARMState *env, bool ifetch) | ||
53 | { | ||
54 | - return FIELD_EX32(env->hflags, TBFLAG_ANY, MMUIDX); | ||
55 | + return EX_TBFLAG_ANY(env->hflags, MMUIDX); | ||
56 | } | ||
57 | |||
58 | static inline bool bswap_code(bool sctlr_b) | ||
59 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 20 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c |
60 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
61 | --- a/target/arm/helper-a64.c | 22 | --- a/target/arm/helper-a64.c |
62 | +++ b/target/arm/helper-a64.c | 23 | +++ b/target/arm/helper-a64.c |
63 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) | 24 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp) |
64 | * the hflags rebuild, since we can pull the composite TBII field | 25 | float16 nan = a; |
65 | * from there. | 26 | if (float16_is_signaling_nan(a, fpst)) { |
66 | */ | 27 | float_raise(float_flag_invalid, fpst); |
67 | - tbii = FIELD_EX32(env->hflags, TBFLAG_A64, TBII); | 28 | - nan = float16_silence_nan(a, fpst); |
68 | + tbii = EX_TBFLAG_A64(env->hflags, TBII); | 29 | + if (!fpst->default_nan_mode) { |
69 | if ((tbii >> extract64(new_pc, 55, 1)) & 1) { | 30 | + nan = float16_silence_nan(a, fpst); |
70 | /* TBI is enabled. */ | 31 | + } |
71 | int core_mmu_idx = cpu_mmu_index(env, false); | 32 | } |
72 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 33 | if (fpst->default_nan_mode) { |
34 | nan = float16_default_nan(fpst); | ||
35 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) | ||
36 | float32 nan = a; | ||
37 | if (float32_is_signaling_nan(a, fpst)) { | ||
38 | float_raise(float_flag_invalid, fpst); | ||
39 | - nan = float32_silence_nan(a, fpst); | ||
40 | + if (!fpst->default_nan_mode) { | ||
41 | + nan = float32_silence_nan(a, fpst); | ||
42 | + } | ||
43 | } | ||
44 | if (fpst->default_nan_mode) { | ||
45 | nan = float32_default_nan(fpst); | ||
46 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) | ||
47 | float64 nan = a; | ||
48 | if (float64_is_signaling_nan(a, fpst)) { | ||
49 | float_raise(float_flag_invalid, fpst); | ||
50 | - nan = float64_silence_nan(a, fpst); | ||
51 | + if (!fpst->default_nan_mode) { | ||
52 | + nan = float64_silence_nan(a, fpst); | ||
53 | + } | ||
54 | } | ||
55 | if (fpst->default_nan_mode) { | ||
56 | nan = float64_default_nan(fpst); | ||
57 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | 58 | index XXXXXXX..XXXXXXX 100644 |
74 | --- a/target/arm/helper.c | 59 | --- a/target/arm/vfp_helper.c |
75 | +++ b/target/arm/helper.c | 60 | +++ b/target/arm/vfp_helper.c |
76 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | 61 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) |
77 | static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | 62 | float16 nan = f16; |
78 | ARMMMUIdx mmu_idx, uint32_t flags) | 63 | if (float16_is_signaling_nan(f16, fpst)) { |
79 | { | 64 | float_raise(float_flag_invalid, fpst); |
80 | - flags = FIELD_DP32(flags, TBFLAG_ANY, FPEXC_EL, fp_el); | 65 | - nan = float16_silence_nan(f16, fpst); |
81 | - flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, | 66 | + if (!fpst->default_nan_mode) { |
82 | - arm_to_core_mmu_idx(mmu_idx)); | 67 | + nan = float16_silence_nan(f16, fpst); |
83 | + DP_TBFLAG_ANY(flags, FPEXC_EL, fp_el); | 68 | + } |
84 | + DP_TBFLAG_ANY(flags, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); | ||
85 | |||
86 | if (arm_singlestep_active(env)) { | ||
87 | - flags = FIELD_DP32(flags, TBFLAG_ANY, SS_ACTIVE, 1); | ||
88 | + DP_TBFLAG_ANY(flags, SS_ACTIVE, 1); | ||
89 | } | ||
90 | return flags; | ||
91 | } | ||
92 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, | ||
93 | bool sctlr_b = arm_sctlr_b(env); | ||
94 | |||
95 | if (sctlr_b) { | ||
96 | - flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR__B, 1); | ||
97 | + DP_TBFLAG_A32(flags, SCTLR__B, 1); | ||
98 | } | ||
99 | if (arm_cpu_data_is_big_endian_a32(env, sctlr_b)) { | ||
100 | - flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); | ||
101 | + DP_TBFLAG_ANY(flags, BE_DATA, 1); | ||
102 | } | ||
103 | - flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env)); | ||
104 | + DP_TBFLAG_A32(flags, NS, !access_secure_reg(env)); | ||
105 | |||
106 | return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
107 | } | ||
108 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, | ||
109 | uint32_t flags = 0; | ||
110 | |||
111 | if (arm_v7m_is_handler_mode(env)) { | ||
112 | - flags = FIELD_DP32(flags, TBFLAG_M32, HANDLER, 1); | ||
113 | + DP_TBFLAG_M32(flags, HANDLER, 1); | ||
114 | } | ||
115 | |||
116 | /* | ||
117 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, | ||
118 | if (arm_feature(env, ARM_FEATURE_V8) && | ||
119 | !((mmu_idx & ARM_MMU_IDX_M_NEGPRI) && | ||
120 | (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_STKOFHFNMIGN_MASK))) { | ||
121 | - flags = FIELD_DP32(flags, TBFLAG_M32, STACKCHECK, 1); | ||
122 | + DP_TBFLAG_M32(flags, STACKCHECK, 1); | ||
123 | } | ||
124 | |||
125 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | ||
126 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_aprofile(CPUARMState *env) | ||
127 | { | ||
128 | int flags = 0; | ||
129 | |||
130 | - flags = FIELD_DP32(flags, TBFLAG_ANY, DEBUG_TARGET_EL, | ||
131 | - arm_debug_target_el(env)); | ||
132 | + DP_TBFLAG_ANY(flags, DEBUG_TARGET_EL, arm_debug_target_el(env)); | ||
133 | return flags; | ||
134 | } | ||
135 | |||
136 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, | ||
137 | uint32_t flags = rebuild_hflags_aprofile(env); | ||
138 | |||
139 | if (arm_el_is_aa64(env, 1)) { | ||
140 | - flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
141 | + DP_TBFLAG_A32(flags, VFPEN, 1); | ||
142 | } | ||
143 | |||
144 | if (arm_current_el(env) < 2 && env->cp15.hstr_el2 && | ||
145 | (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | ||
146 | - flags = FIELD_DP32(flags, TBFLAG_A32, HSTR_ACTIVE, 1); | ||
147 | + DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1); | ||
148 | } | ||
149 | |||
150 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | ||
151 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
152 | uint64_t sctlr; | ||
153 | int tbii, tbid; | ||
154 | |||
155 | - flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); | ||
156 | + DP_TBFLAG_ANY(flags, AARCH64_STATE, 1); | ||
157 | |||
158 | /* Get control bits for tagged addresses. */ | ||
159 | tbid = aa64_va_parameter_tbi(tcr, mmu_idx); | ||
160 | tbii = tbid & ~aa64_va_parameter_tbid(tcr, mmu_idx); | ||
161 | |||
162 | - flags = FIELD_DP32(flags, TBFLAG_A64, TBII, tbii); | ||
163 | - flags = FIELD_DP32(flags, TBFLAG_A64, TBID, tbid); | ||
164 | + DP_TBFLAG_A64(flags, TBII, tbii); | ||
165 | + DP_TBFLAG_A64(flags, TBID, tbid); | ||
166 | |||
167 | if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { | ||
168 | int sve_el = sve_exception_el(env, el); | ||
169 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
170 | } else { | ||
171 | zcr_len = sve_zcr_len_for_el(env, el); | ||
172 | } | 69 | } |
173 | - flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); | 70 | if (fpst->default_nan_mode) { |
174 | - flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); | 71 | nan = float16_default_nan(fpst); |
175 | + DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); | 72 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp) |
176 | + DP_TBFLAG_A64(flags, ZCR_LEN, zcr_len); | 73 | float32 nan = f32; |
177 | } | 74 | if (float32_is_signaling_nan(f32, fpst)) { |
178 | 75 | float_raise(float_flag_invalid, fpst); | |
179 | sctlr = regime_sctlr(env, stage1); | 76 | - nan = float32_silence_nan(f32, fpst); |
180 | 77 | + if (!fpst->default_nan_mode) { | |
181 | if (arm_cpu_data_is_big_endian_a64(el, sctlr)) { | 78 | + nan = float32_silence_nan(f32, fpst); |
182 | - flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); | 79 | + } |
183 | + DP_TBFLAG_ANY(flags, BE_DATA, 1); | ||
184 | } | ||
185 | |||
186 | if (cpu_isar_feature(aa64_pauth, env_archcpu(env))) { | ||
187 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
188 | * The decision of which action to take is left to a helper. | ||
189 | */ | ||
190 | if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { | ||
191 | - flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); | ||
192 | + DP_TBFLAG_A64(flags, PAUTH_ACTIVE, 1); | ||
193 | } | 80 | } |
194 | } | 81 | if (fpst->default_nan_mode) { |
195 | 82 | nan = float32_default_nan(fpst); | |
196 | if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { | 83 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp) |
197 | /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */ | 84 | float64 nan = f64; |
198 | if (sctlr & (el == 0 ? SCTLR_BT0 : SCTLR_BT1)) { | 85 | if (float64_is_signaling_nan(f64, fpst)) { |
199 | - flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1); | 86 | float_raise(float_flag_invalid, fpst); |
200 | + DP_TBFLAG_A64(flags, BT, 1); | 87 | - nan = float64_silence_nan(f64, fpst); |
88 | + if (!fpst->default_nan_mode) { | ||
89 | + nan = float64_silence_nan(f64, fpst); | ||
90 | + } | ||
201 | } | 91 | } |
202 | } | 92 | if (fpst->default_nan_mode) { |
203 | 93 | nan = float64_default_nan(fpst); | |
204 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | 94 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) |
205 | case ARMMMUIdx_SE10_1: | 95 | float16 nan = f16; |
206 | case ARMMMUIdx_SE10_1_PAN: | 96 | if (float16_is_signaling_nan(f16, s)) { |
207 | /* TODO: ARMv8.3-NV */ | 97 | float_raise(float_flag_invalid, s); |
208 | - flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); | 98 | - nan = float16_silence_nan(f16, s); |
209 | + DP_TBFLAG_A64(flags, UNPRIV, 1); | 99 | + if (!s->default_nan_mode) { |
210 | break; | 100 | + nan = float16_silence_nan(f16, fpstp); |
211 | case ARMMMUIdx_E20_2: | 101 | + } |
212 | case ARMMMUIdx_E20_2_PAN: | ||
213 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
214 | * gated by HCR_EL2.<E2H,TGE> == '11', and so is LDTR. | ||
215 | */ | ||
216 | if (env->cp15.hcr_el2 & HCR_TGE) { | ||
217 | - flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); | ||
218 | + DP_TBFLAG_A64(flags, UNPRIV, 1); | ||
219 | } | ||
220 | break; | ||
221 | default: | ||
222 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
223 | * 4) If no Allocation Tag Access, then all accesses are Unchecked. | ||
224 | */ | ||
225 | if (allocation_tag_access_enabled(env, el, sctlr)) { | ||
226 | - flags = FIELD_DP32(flags, TBFLAG_A64, ATA, 1); | ||
227 | + DP_TBFLAG_A64(flags, ATA, 1); | ||
228 | if (tbid | ||
229 | && !(env->pstate & PSTATE_TCO) | ||
230 | && (sctlr & (el == 0 ? SCTLR_TCF0 : SCTLR_TCF))) { | ||
231 | - flags = FIELD_DP32(flags, TBFLAG_A64, MTE_ACTIVE, 1); | ||
232 | + DP_TBFLAG_A64(flags, MTE_ACTIVE, 1); | ||
233 | } | ||
234 | } | 102 | } |
235 | /* And again for unprivileged accesses, if required. */ | 103 | if (s->default_nan_mode) { |
236 | - if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV) | 104 | nan = float16_default_nan(s); |
237 | + if (EX_TBFLAG_A64(flags, UNPRIV) | 105 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) |
238 | && tbid | 106 | float32 nan = f32; |
239 | && !(env->pstate & PSTATE_TCO) | 107 | if (float32_is_signaling_nan(f32, s)) { |
240 | && (sctlr & SCTLR_TCF0) | 108 | float_raise(float_flag_invalid, s); |
241 | && allocation_tag_access_enabled(env, 0, sctlr)) { | 109 | - nan = float32_silence_nan(f32, s); |
242 | - flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1); | 110 | + if (!s->default_nan_mode) { |
243 | + DP_TBFLAG_A64(flags, MTE0_ACTIVE, 1); | 111 | + nan = float32_silence_nan(f32, fpstp); |
112 | + } | ||
244 | } | 113 | } |
245 | /* Cache TCMA as well as TBI. */ | 114 | if (s->default_nan_mode) { |
246 | - flags = FIELD_DP32(flags, TBFLAG_A64, TCMA, | 115 | nan = float32_default_nan(s); |
247 | - aa64_va_parameter_tcma(tcr, mmu_idx)); | 116 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) |
248 | + DP_TBFLAG_A64(flags, TCMA, aa64_va_parameter_tcma(tcr, mmu_idx)); | 117 | float64 nan = f64; |
249 | } | 118 | if (float64_is_signaling_nan(f64, s)) { |
250 | 119 | float_raise(float_flag_invalid, s); | |
251 | return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | 120 | - nan = float64_silence_nan(f64, s); |
252 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 121 | + if (!s->default_nan_mode) { |
253 | *cs_base = 0; | 122 | + nan = float64_silence_nan(f64, fpstp); |
254 | assert_hflags_rebuild_correctly(env); | 123 | + } |
255 | |||
256 | - if (FIELD_EX32(flags, TBFLAG_ANY, AARCH64_STATE)) { | ||
257 | + if (EX_TBFLAG_ANY(flags, AARCH64_STATE)) { | ||
258 | *pc = env->pc; | ||
259 | if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { | ||
260 | - flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); | ||
261 | + DP_TBFLAG_A64(flags, BTYPE, env->btype); | ||
262 | } | 124 | } |
263 | } else { | 125 | if (s->default_nan_mode) { |
264 | *pc = env->regs[15]; | 126 | nan = float64_default_nan(s); |
265 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
266 | if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
267 | FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) | ||
268 | != env->v7m.secure) { | ||
269 | - flags = FIELD_DP32(flags, TBFLAG_M32, FPCCR_S_WRONG, 1); | ||
270 | + DP_TBFLAG_M32(flags, FPCCR_S_WRONG, 1); | ||
271 | } | ||
272 | |||
273 | if ((env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) && | ||
274 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
275 | * active FP context; we must create a new FP context before | ||
276 | * executing any FP insn. | ||
277 | */ | ||
278 | - flags = FIELD_DP32(flags, TBFLAG_M32, NEW_FP_CTXT_NEEDED, 1); | ||
279 | + DP_TBFLAG_M32(flags, NEW_FP_CTXT_NEEDED, 1); | ||
280 | } | ||
281 | |||
282 | bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | ||
283 | if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) { | ||
284 | - flags = FIELD_DP32(flags, TBFLAG_M32, LSPACT, 1); | ||
285 | + DP_TBFLAG_M32(flags, LSPACT, 1); | ||
286 | } | ||
287 | } else { | ||
288 | /* | ||
289 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
290 | * Note that VECLEN+VECSTRIDE are RES0 for M-profile. | ||
291 | */ | ||
292 | if (arm_feature(env, ARM_FEATURE_XSCALE)) { | ||
293 | - flags = FIELD_DP32(flags, TBFLAG_A32, | ||
294 | - XSCALE_CPAR, env->cp15.c15_cpar); | ||
295 | + DP_TBFLAG_A32(flags, XSCALE_CPAR, env->cp15.c15_cpar); | ||
296 | } else { | ||
297 | - flags = FIELD_DP32(flags, TBFLAG_A32, VECLEN, | ||
298 | - env->vfp.vec_len); | ||
299 | - flags = FIELD_DP32(flags, TBFLAG_A32, VECSTRIDE, | ||
300 | - env->vfp.vec_stride); | ||
301 | + DP_TBFLAG_A32(flags, VECLEN, env->vfp.vec_len); | ||
302 | + DP_TBFLAG_A32(flags, VECSTRIDE, env->vfp.vec_stride); | ||
303 | } | ||
304 | if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30)) { | ||
305 | - flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
306 | + DP_TBFLAG_A32(flags, VFPEN, 1); | ||
307 | } | ||
308 | } | ||
309 | |||
310 | - flags = FIELD_DP32(flags, TBFLAG_AM32, THUMB, env->thumb); | ||
311 | - flags = FIELD_DP32(flags, TBFLAG_AM32, CONDEXEC, env->condexec_bits); | ||
312 | + DP_TBFLAG_AM32(flags, THUMB, env->thumb); | ||
313 | + DP_TBFLAG_AM32(flags, CONDEXEC, env->condexec_bits); | ||
314 | } | ||
315 | |||
316 | /* | ||
317 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
318 | * 1 1 Active-not-pending | ||
319 | * SS_ACTIVE is set in hflags; PSTATE__SS is computed every TB. | ||
320 | */ | ||
321 | - if (FIELD_EX32(flags, TBFLAG_ANY, SS_ACTIVE) && | ||
322 | - (env->pstate & PSTATE_SS)) { | ||
323 | - flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE__SS, 1); | ||
324 | + if (EX_TBFLAG_ANY(flags, SS_ACTIVE) && (env->pstate & PSTATE_SS)) { | ||
325 | + DP_TBFLAG_ANY(flags, PSTATE__SS, 1); | ||
326 | } | ||
327 | |||
328 | *pflags = flags; | ||
329 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
330 | index XXXXXXX..XXXXXXX 100644 | ||
331 | --- a/target/arm/translate-a64.c | ||
332 | +++ b/target/arm/translate-a64.c | ||
333 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
334 | !arm_el_is_aa64(env, 3); | ||
335 | dc->thumb = 0; | ||
336 | dc->sctlr_b = 0; | ||
337 | - dc->be_data = FIELD_EX32(tb_flags, TBFLAG_ANY, BE_DATA) ? MO_BE : MO_LE; | ||
338 | + dc->be_data = EX_TBFLAG_ANY(tb_flags, BE_DATA) ? MO_BE : MO_LE; | ||
339 | dc->condexec_mask = 0; | ||
340 | dc->condexec_cond = 0; | ||
341 | - core_mmu_idx = FIELD_EX32(tb_flags, TBFLAG_ANY, MMUIDX); | ||
342 | + core_mmu_idx = EX_TBFLAG_ANY(tb_flags, MMUIDX); | ||
343 | dc->mmu_idx = core_to_aa64_mmu_idx(core_mmu_idx); | ||
344 | - dc->tbii = FIELD_EX32(tb_flags, TBFLAG_A64, TBII); | ||
345 | - dc->tbid = FIELD_EX32(tb_flags, TBFLAG_A64, TBID); | ||
346 | - dc->tcma = FIELD_EX32(tb_flags, TBFLAG_A64, TCMA); | ||
347 | + dc->tbii = EX_TBFLAG_A64(tb_flags, TBII); | ||
348 | + dc->tbid = EX_TBFLAG_A64(tb_flags, TBID); | ||
349 | + dc->tcma = EX_TBFLAG_A64(tb_flags, TCMA); | ||
350 | dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx); | ||
351 | #if !defined(CONFIG_USER_ONLY) | ||
352 | dc->user = (dc->current_el == 0); | ||
353 | #endif | ||
354 | - dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL); | ||
355 | - dc->sve_excp_el = FIELD_EX32(tb_flags, TBFLAG_A64, SVEEXC_EL); | ||
356 | - dc->sve_len = (FIELD_EX32(tb_flags, TBFLAG_A64, ZCR_LEN) + 1) * 16; | ||
357 | - dc->pauth_active = FIELD_EX32(tb_flags, TBFLAG_A64, PAUTH_ACTIVE); | ||
358 | - dc->bt = FIELD_EX32(tb_flags, TBFLAG_A64, BT); | ||
359 | - dc->btype = FIELD_EX32(tb_flags, TBFLAG_A64, BTYPE); | ||
360 | - dc->unpriv = FIELD_EX32(tb_flags, TBFLAG_A64, UNPRIV); | ||
361 | - dc->ata = FIELD_EX32(tb_flags, TBFLAG_A64, ATA); | ||
362 | - dc->mte_active[0] = FIELD_EX32(tb_flags, TBFLAG_A64, MTE_ACTIVE); | ||
363 | - dc->mte_active[1] = FIELD_EX32(tb_flags, TBFLAG_A64, MTE0_ACTIVE); | ||
364 | + dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); | ||
365 | + dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); | ||
366 | + dc->sve_len = (EX_TBFLAG_A64(tb_flags, ZCR_LEN) + 1) * 16; | ||
367 | + dc->pauth_active = EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); | ||
368 | + dc->bt = EX_TBFLAG_A64(tb_flags, BT); | ||
369 | + dc->btype = EX_TBFLAG_A64(tb_flags, BTYPE); | ||
370 | + dc->unpriv = EX_TBFLAG_A64(tb_flags, UNPRIV); | ||
371 | + dc->ata = EX_TBFLAG_A64(tb_flags, ATA); | ||
372 | + dc->mte_active[0] = EX_TBFLAG_A64(tb_flags, MTE_ACTIVE); | ||
373 | + dc->mte_active[1] = EX_TBFLAG_A64(tb_flags, MTE0_ACTIVE); | ||
374 | dc->vec_len = 0; | ||
375 | dc->vec_stride = 0; | ||
376 | dc->cp_regs = arm_cpu->cp_regs; | ||
377 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
378 | * emit code to generate a software step exception | ||
379 | * end the TB | ||
380 | */ | ||
381 | - dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | ||
382 | - dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE__SS); | ||
383 | + dc->ss_active = EX_TBFLAG_ANY(tb_flags, SS_ACTIVE); | ||
384 | + dc->pstate_ss = EX_TBFLAG_ANY(tb_flags, PSTATE__SS); | ||
385 | dc->is_ldex = false; | ||
386 | - dc->debug_target_el = FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | ||
387 | + dc->debug_target_el = EX_TBFLAG_ANY(tb_flags, DEBUG_TARGET_EL); | ||
388 | |||
389 | /* Bound the number of insns to execute to those left on the page. */ | ||
390 | bound = -(dc->base.pc_first | TARGET_PAGE_MASK) / 4; | ||
391 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
392 | index XXXXXXX..XXXXXXX 100644 | ||
393 | --- a/target/arm/translate.c | ||
394 | +++ b/target/arm/translate.c | ||
395 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
396 | */ | ||
397 | dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) && | ||
398 | !arm_el_is_aa64(env, 3); | ||
399 | - dc->thumb = FIELD_EX32(tb_flags, TBFLAG_AM32, THUMB); | ||
400 | - dc->be_data = FIELD_EX32(tb_flags, TBFLAG_ANY, BE_DATA) ? MO_BE : MO_LE; | ||
401 | - condexec = FIELD_EX32(tb_flags, TBFLAG_AM32, CONDEXEC); | ||
402 | + dc->thumb = EX_TBFLAG_AM32(tb_flags, THUMB); | ||
403 | + dc->be_data = EX_TBFLAG_ANY(tb_flags, BE_DATA) ? MO_BE : MO_LE; | ||
404 | + condexec = EX_TBFLAG_AM32(tb_flags, CONDEXEC); | ||
405 | dc->condexec_mask = (condexec & 0xf) << 1; | ||
406 | dc->condexec_cond = condexec >> 4; | ||
407 | |||
408 | - core_mmu_idx = FIELD_EX32(tb_flags, TBFLAG_ANY, MMUIDX); | ||
409 | + core_mmu_idx = EX_TBFLAG_ANY(tb_flags, MMUIDX); | ||
410 | dc->mmu_idx = core_to_arm_mmu_idx(env, core_mmu_idx); | ||
411 | dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx); | ||
412 | #if !defined(CONFIG_USER_ONLY) | ||
413 | dc->user = (dc->current_el == 0); | ||
414 | #endif | ||
415 | - dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL); | ||
416 | + dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); | ||
417 | |||
418 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
419 | dc->vfp_enabled = 1; | ||
420 | dc->be_data = MO_TE; | ||
421 | - dc->v7m_handler_mode = FIELD_EX32(tb_flags, TBFLAG_M32, HANDLER); | ||
422 | + dc->v7m_handler_mode = EX_TBFLAG_M32(tb_flags, HANDLER); | ||
423 | dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
424 | regime_is_secure(env, dc->mmu_idx); | ||
425 | - dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_M32, STACKCHECK); | ||
426 | - dc->v8m_fpccr_s_wrong = | ||
427 | - FIELD_EX32(tb_flags, TBFLAG_M32, FPCCR_S_WRONG); | ||
428 | + dc->v8m_stackcheck = EX_TBFLAG_M32(tb_flags, STACKCHECK); | ||
429 | + dc->v8m_fpccr_s_wrong = EX_TBFLAG_M32(tb_flags, FPCCR_S_WRONG); | ||
430 | dc->v7m_new_fp_ctxt_needed = | ||
431 | - FIELD_EX32(tb_flags, TBFLAG_M32, NEW_FP_CTXT_NEEDED); | ||
432 | - dc->v7m_lspact = FIELD_EX32(tb_flags, TBFLAG_M32, LSPACT); | ||
433 | + EX_TBFLAG_M32(tb_flags, NEW_FP_CTXT_NEEDED); | ||
434 | + dc->v7m_lspact = EX_TBFLAG_M32(tb_flags, LSPACT); | ||
435 | } else { | ||
436 | - dc->be_data = | ||
437 | - FIELD_EX32(tb_flags, TBFLAG_ANY, BE_DATA) ? MO_BE : MO_LE; | ||
438 | - dc->debug_target_el = | ||
439 | - FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | ||
440 | - dc->sctlr_b = FIELD_EX32(tb_flags, TBFLAG_A32, SCTLR__B); | ||
441 | - dc->hstr_active = FIELD_EX32(tb_flags, TBFLAG_A32, HSTR_ACTIVE); | ||
442 | - dc->ns = FIELD_EX32(tb_flags, TBFLAG_A32, NS); | ||
443 | - dc->vfp_enabled = FIELD_EX32(tb_flags, TBFLAG_A32, VFPEN); | ||
444 | + dc->debug_target_el = EX_TBFLAG_ANY(tb_flags, DEBUG_TARGET_EL); | ||
445 | + dc->sctlr_b = EX_TBFLAG_A32(tb_flags, SCTLR__B); | ||
446 | + dc->hstr_active = EX_TBFLAG_A32(tb_flags, HSTR_ACTIVE); | ||
447 | + dc->ns = EX_TBFLAG_A32(tb_flags, NS); | ||
448 | + dc->vfp_enabled = EX_TBFLAG_A32(tb_flags, VFPEN); | ||
449 | if (arm_feature(env, ARM_FEATURE_XSCALE)) { | ||
450 | - dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR); | ||
451 | + dc->c15_cpar = EX_TBFLAG_A32(tb_flags, XSCALE_CPAR); | ||
452 | } else { | ||
453 | - dc->vec_len = FIELD_EX32(tb_flags, TBFLAG_A32, VECLEN); | ||
454 | - dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE); | ||
455 | + dc->vec_len = EX_TBFLAG_A32(tb_flags, VECLEN); | ||
456 | + dc->vec_stride = EX_TBFLAG_A32(tb_flags, VECSTRIDE); | ||
457 | } | ||
458 | } | ||
459 | dc->cp_regs = cpu->cp_regs; | ||
460 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
461 | * emit code to generate a software step exception | ||
462 | * end the TB | ||
463 | */ | ||
464 | - dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | ||
465 | - dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE__SS); | ||
466 | + dc->ss_active = EX_TBFLAG_ANY(tb_flags, SS_ACTIVE); | ||
467 | + dc->pstate_ss = EX_TBFLAG_ANY(tb_flags, PSTATE__SS); | ||
468 | dc->is_ldex = false; | ||
469 | |||
470 | dc->page_start = dc->base.pc_first & TARGET_PAGE_MASK; | ||
471 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | ||
472 | DisasContext dc = { }; | ||
473 | const TranslatorOps *ops = &arm_translator_ops; | ||
474 | |||
475 | - if (FIELD_EX32(tb->flags, TBFLAG_AM32, THUMB)) { | ||
476 | + if (EX_TBFLAG_AM32(tb->flags, THUMB)) { | ||
477 | ops = &thumb_translator_ops; | ||
478 | } | ||
479 | #ifdef TARGET_AARCH64 | ||
480 | - if (FIELD_EX32(tb->flags, TBFLAG_ANY, AARCH64_STATE)) { | ||
481 | + if (EX_TBFLAG_ANY(tb->flags, AARCH64_STATE)) { | ||
482 | ops = &aarch64_translator_ops; | ||
483 | } | ||
484 | #endif | ||
485 | -- | 127 | -- |
486 | 2.20.1 | 128 | 2.20.1 |
487 | 129 | ||
488 | 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 | In the case of gpr load, merge the size and is_signed arguments; | 3 | qemu has 2 type of functions: shutdown and reboot. Shutdown |
4 | otherwise, simply convert size to memop. | 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 | ||
7 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Message-id: 20210625111842.3790-3-maxim.uvarov@linaro.org |
8 | Message-id: 20210419202257.161730-26-richard.henderson@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-a64.c | 78 ++++++++++++++++---------------------- | 13 | hw/gpio/gpio_pwr.c | 2 +- |
12 | 1 file changed, 33 insertions(+), 45 deletions(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 15 | ||
14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.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-a64.c | 18 | --- a/hw/gpio/gpio_pwr.c |
17 | +++ b/target/arm/translate-a64.c | 19 | +++ b/hw/gpio/gpio_pwr.c |
18 | @@ -XXX,XX +XXX,XX @@ static void gen_adc_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) | 20 | @@ -XXX,XX +XXX,XX @@ static void gpio_pwr_reset(void *opaque, int n, int level) |
19 | * Store from GPR register to memory. | 21 | static void gpio_pwr_shutdown(void *opaque, int n, int level) |
20 | */ | ||
21 | static void do_gpr_st_memidx(DisasContext *s, TCGv_i64 source, | ||
22 | - TCGv_i64 tcg_addr, int size, int memidx, | ||
23 | + TCGv_i64 tcg_addr, MemOp memop, int memidx, | ||
24 | bool iss_valid, | ||
25 | unsigned int iss_srt, | ||
26 | bool iss_sf, bool iss_ar) | ||
27 | { | 22 | { |
28 | - g_assert(size <= 3); | 23 | if (level) { |
29 | - tcg_gen_qemu_st_i64(source, tcg_addr, memidx, s->be_data + size); | 24 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
30 | + memop = finalize_memop(s, memop); | 25 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
31 | + tcg_gen_qemu_st_i64(source, tcg_addr, memidx, memop); | ||
32 | |||
33 | if (iss_valid) { | ||
34 | uint32_t syn; | ||
35 | |||
36 | syn = syn_data_abort_with_iss(0, | ||
37 | - size, | ||
38 | + (memop & MO_SIZE), | ||
39 | false, | ||
40 | iss_srt, | ||
41 | iss_sf, | ||
42 | @@ -XXX,XX +XXX,XX @@ static void do_gpr_st_memidx(DisasContext *s, TCGv_i64 source, | ||
43 | } | ||
44 | |||
45 | static void do_gpr_st(DisasContext *s, TCGv_i64 source, | ||
46 | - TCGv_i64 tcg_addr, int size, | ||
47 | + TCGv_i64 tcg_addr, MemOp memop, | ||
48 | bool iss_valid, | ||
49 | unsigned int iss_srt, | ||
50 | bool iss_sf, bool iss_ar) | ||
51 | { | ||
52 | - do_gpr_st_memidx(s, source, tcg_addr, size, get_mem_index(s), | ||
53 | + do_gpr_st_memidx(s, source, tcg_addr, memop, get_mem_index(s), | ||
54 | iss_valid, iss_srt, iss_sf, iss_ar); | ||
55 | } | ||
56 | |||
57 | /* | ||
58 | * Load from memory to GPR register | ||
59 | */ | ||
60 | -static void do_gpr_ld_memidx(DisasContext *s, | ||
61 | - TCGv_i64 dest, TCGv_i64 tcg_addr, | ||
62 | - int size, bool is_signed, | ||
63 | - bool extend, int memidx, | ||
64 | +static void do_gpr_ld_memidx(DisasContext *s, TCGv_i64 dest, TCGv_i64 tcg_addr, | ||
65 | + MemOp memop, bool extend, int memidx, | ||
66 | bool iss_valid, unsigned int iss_srt, | ||
67 | bool iss_sf, bool iss_ar) | ||
68 | { | ||
69 | - MemOp memop = s->be_data + size; | ||
70 | - | ||
71 | - g_assert(size <= 3); | ||
72 | - | ||
73 | - if (is_signed) { | ||
74 | - memop += MO_SIGN; | ||
75 | - } | ||
76 | - | ||
77 | + memop = finalize_memop(s, memop); | ||
78 | tcg_gen_qemu_ld_i64(dest, tcg_addr, memidx, memop); | ||
79 | |||
80 | - if (extend && is_signed) { | ||
81 | - g_assert(size < 3); | ||
82 | + if (extend && (memop & MO_SIGN)) { | ||
83 | + g_assert((memop & MO_SIZE) <= MO_32); | ||
84 | tcg_gen_ext32u_i64(dest, dest); | ||
85 | } | ||
86 | |||
87 | @@ -XXX,XX +XXX,XX @@ static void do_gpr_ld_memidx(DisasContext *s, | ||
88 | uint32_t syn; | ||
89 | |||
90 | syn = syn_data_abort_with_iss(0, | ||
91 | - size, | ||
92 | - is_signed, | ||
93 | + (memop & MO_SIZE), | ||
94 | + (memop & MO_SIGN) != 0, | ||
95 | iss_srt, | ||
96 | iss_sf, | ||
97 | iss_ar, | ||
98 | @@ -XXX,XX +XXX,XX @@ static void do_gpr_ld_memidx(DisasContext *s, | ||
99 | } | 26 | } |
100 | } | 27 | } |
101 | 28 | ||
102 | -static void do_gpr_ld(DisasContext *s, | ||
103 | - TCGv_i64 dest, TCGv_i64 tcg_addr, | ||
104 | - int size, bool is_signed, bool extend, | ||
105 | +static void do_gpr_ld(DisasContext *s, TCGv_i64 dest, TCGv_i64 tcg_addr, | ||
106 | + MemOp memop, bool extend, | ||
107 | bool iss_valid, unsigned int iss_srt, | ||
108 | bool iss_sf, bool iss_ar) | ||
109 | { | ||
110 | - do_gpr_ld_memidx(s, dest, tcg_addr, size, is_signed, extend, | ||
111 | - get_mem_index(s), | ||
112 | + do_gpr_ld_memidx(s, dest, tcg_addr, memop, extend, get_mem_index(s), | ||
113 | iss_valid, iss_srt, iss_sf, iss_ar); | ||
114 | } | ||
115 | |||
116 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | ||
117 | } | ||
118 | clean_addr = gen_mte_check1(s, cpu_reg_sp(s, rn), | ||
119 | false, rn != 31, size); | ||
120 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size, false, false, true, rt, | ||
121 | + do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size, false, true, rt, | ||
122 | disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | ||
123 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
124 | return; | ||
125 | @@ -XXX,XX +XXX,XX @@ static void disas_ld_lit(DisasContext *s, uint32_t insn) | ||
126 | /* Only unsigned 32bit loads target 32bit registers. */ | ||
127 | bool iss_sf = opc != 0; | ||
128 | |||
129 | - do_gpr_ld(s, tcg_rt, clean_addr, size, is_signed, false, | ||
130 | - true, rt, iss_sf, false); | ||
131 | + do_gpr_ld(s, tcg_rt, clean_addr, size + is_signed * MO_SIGN, | ||
132 | + false, true, rt, iss_sf, false); | ||
133 | } | ||
134 | tcg_temp_free_i64(clean_addr); | ||
135 | } | ||
136 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn) | ||
137 | /* Do not modify tcg_rt before recognizing any exception | ||
138 | * from the second load. | ||
139 | */ | ||
140 | - do_gpr_ld(s, tmp, clean_addr, size, is_signed, false, | ||
141 | - false, 0, false, false); | ||
142 | + do_gpr_ld(s, tmp, clean_addr, size + is_signed * MO_SIGN, | ||
143 | + false, false, 0, false, false); | ||
144 | tcg_gen_addi_i64(clean_addr, clean_addr, 1 << size); | ||
145 | - do_gpr_ld(s, tcg_rt2, clean_addr, size, is_signed, false, | ||
146 | - false, 0, false, false); | ||
147 | + do_gpr_ld(s, tcg_rt2, clean_addr, size + is_signed * MO_SIGN, | ||
148 | + false, false, 0, false, false); | ||
149 | |||
150 | tcg_gen_mov_i64(tcg_rt, tmp); | ||
151 | tcg_temp_free_i64(tmp); | ||
152 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn, | ||
153 | do_gpr_st_memidx(s, tcg_rt, clean_addr, size, memidx, | ||
154 | iss_valid, rt, iss_sf, false); | ||
155 | } else { | ||
156 | - do_gpr_ld_memidx(s, tcg_rt, clean_addr, size, | ||
157 | - is_signed, is_extended, memidx, | ||
158 | + do_gpr_ld_memidx(s, tcg_rt, clean_addr, size + is_signed * MO_SIGN, | ||
159 | + is_extended, memidx, | ||
160 | iss_valid, rt, iss_sf, false); | ||
161 | } | ||
162 | } | ||
163 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_roffset(DisasContext *s, uint32_t insn, | ||
164 | do_gpr_st(s, tcg_rt, clean_addr, size, | ||
165 | true, rt, iss_sf, false); | ||
166 | } else { | ||
167 | - do_gpr_ld(s, tcg_rt, clean_addr, size, | ||
168 | - is_signed, is_extended, | ||
169 | - true, rt, iss_sf, false); | ||
170 | + do_gpr_ld(s, tcg_rt, clean_addr, size + is_signed * MO_SIGN, | ||
171 | + is_extended, true, rt, iss_sf, false); | ||
172 | } | ||
173 | } | ||
174 | } | ||
175 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_unsigned_imm(DisasContext *s, uint32_t insn, | ||
176 | do_gpr_st(s, tcg_rt, clean_addr, size, | ||
177 | true, rt, iss_sf, false); | ||
178 | } else { | ||
179 | - do_gpr_ld(s, tcg_rt, clean_addr, size, is_signed, is_extended, | ||
180 | - true, rt, iss_sf, false); | ||
181 | + do_gpr_ld(s, tcg_rt, clean_addr, size + is_signed * MO_SIGN, | ||
182 | + is_extended, true, rt, iss_sf, false); | ||
183 | } | ||
184 | } | ||
185 | } | ||
186 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | ||
187 | * full load-acquire (we only need "load-acquire processor consistent"), | ||
188 | * but we choose to implement them as full LDAQ. | ||
189 | */ | ||
190 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size, false, false, | ||
191 | + do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size, false, | ||
192 | true, rt, disas_ldst_compute_iss_sf(size, false, 0), true); | ||
193 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
194 | return; | ||
195 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_pac(DisasContext *s, uint32_t insn, | ||
196 | is_wback || rn != 31, size); | ||
197 | |||
198 | tcg_rt = cpu_reg(s, rt); | ||
199 | - do_gpr_ld(s, tcg_rt, clean_addr, size, /* is_signed */ false, | ||
200 | + do_gpr_ld(s, tcg_rt, clean_addr, size, | ||
201 | /* extend */ false, /* iss_valid */ !is_wback, | ||
202 | /* iss_srt */ rt, /* iss_sf */ true, /* iss_ar */ false); | ||
203 | |||
204 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | ||
205 | * Load-AcquirePC semantics; we implement as the slightly more | ||
206 | * restrictive Load-Acquire. | ||
207 | */ | ||
208 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size, is_signed, extend, | ||
209 | - true, rt, iss_sf, true); | ||
210 | + do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size + is_signed * MO_SIGN, | ||
211 | + extend, true, rt, iss_sf, true); | ||
212 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
213 | } | ||
214 | } | ||
215 | -- | 29 | -- |
216 | 2.20.1 | 30 | 2.20.1 |
217 | 31 | ||
218 | 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 | Now that mte_check1 and mte_checkN have been merged, we can | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | merge sve_cont_ldst_mte_check1 and sve_cont_ldst_mte_checkN. | 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 | Which means that we can eliminate the function pointer into | 13 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
7 | sve_ldN_r and sve_stN_r, calling sve_cont_ldst_mte_check directly. | ||
8 | |||
9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20210416183106.1516563-9-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/sve_helper.c | 84 +++++++++++++---------------------------- | ||
15 | 1 file changed, 26 insertions(+), 58 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/sve_helper.c | 15 | --- a/target/arm/translate-mve.c |
20 | +++ b/target/arm/sve_helper.c | 16 | +++ b/target/arm/translate-mve.c |
21 | @@ -XXX,XX +XXX,XX @@ static void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, | 17 | @@ -XXX,XX +XXX,XX @@ static bool mve_skip_first_beat(DisasContext *s) |
22 | #endif | ||
23 | } | ||
24 | |||
25 | -typedef uint64_t mte_check_fn(CPUARMState *, uint32_t, uint64_t, uintptr_t); | ||
26 | - | ||
27 | -static inline QEMU_ALWAYS_INLINE | ||
28 | -void sve_cont_ldst_mte_check_int(SVEContLdSt *info, CPUARMState *env, | ||
29 | - uint64_t *vg, target_ulong addr, int esize, | ||
30 | - int msize, uint32_t mtedesc, uintptr_t ra, | ||
31 | - mte_check_fn *check) | ||
32 | +static void sve_cont_ldst_mte_check(SVEContLdSt *info, CPUARMState *env, | ||
33 | + uint64_t *vg, target_ulong addr, int esize, | ||
34 | + int msize, uint32_t mtedesc, uintptr_t ra) | ||
35 | { | ||
36 | intptr_t mem_off, reg_off, reg_last; | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ void sve_cont_ldst_mte_check_int(SVEContLdSt *info, CPUARMState *env, | ||
39 | uint64_t pg = vg[reg_off >> 6]; | ||
40 | do { | ||
41 | if ((pg >> (reg_off & 63)) & 1) { | ||
42 | - check(env, mtedesc, addr, ra); | ||
43 | + mte_check(env, mtedesc, addr, ra); | ||
44 | } | ||
45 | reg_off += esize; | ||
46 | mem_off += msize; | ||
47 | @@ -XXX,XX +XXX,XX @@ void sve_cont_ldst_mte_check_int(SVEContLdSt *info, CPUARMState *env, | ||
48 | uint64_t pg = vg[reg_off >> 6]; | ||
49 | do { | ||
50 | if ((pg >> (reg_off & 63)) & 1) { | ||
51 | - check(env, mtedesc, addr, ra); | ||
52 | + mte_check(env, mtedesc, addr, ra); | ||
53 | } | ||
54 | reg_off += esize; | ||
55 | mem_off += msize; | ||
56 | @@ -XXX,XX +XXX,XX @@ void sve_cont_ldst_mte_check_int(SVEContLdSt *info, CPUARMState *env, | ||
57 | } | 18 | } |
58 | } | 19 | } |
59 | 20 | ||
60 | -typedef void sve_cont_ldst_mte_check_fn(SVEContLdSt *info, CPUARMState *env, | 21 | -static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) |
61 | - uint64_t *vg, target_ulong addr, | 22 | +static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn, |
62 | - int esize, int msize, uint32_t mtedesc, | 23 | + unsigned msize) |
63 | - uintptr_t ra); | ||
64 | - | ||
65 | -static void sve_cont_ldst_mte_check1(SVEContLdSt *info, CPUARMState *env, | ||
66 | - uint64_t *vg, target_ulong addr, | ||
67 | - int esize, int msize, uint32_t mtedesc, | ||
68 | - uintptr_t ra) | ||
69 | -{ | ||
70 | - sve_cont_ldst_mte_check_int(info, env, vg, addr, esize, msize, | ||
71 | - mtedesc, ra, mte_check); | ||
72 | -} | ||
73 | - | ||
74 | -static void sve_cont_ldst_mte_checkN(SVEContLdSt *info, CPUARMState *env, | ||
75 | - uint64_t *vg, target_ulong addr, | ||
76 | - int esize, int msize, uint32_t mtedesc, | ||
77 | - uintptr_t ra) | ||
78 | -{ | ||
79 | - sve_cont_ldst_mte_check_int(info, env, vg, addr, esize, msize, | ||
80 | - mtedesc, ra, mte_check); | ||
81 | -} | ||
82 | - | ||
83 | - | ||
84 | /* | ||
85 | * Common helper for all contiguous 1,2,3,4-register predicated stores. | ||
86 | */ | ||
87 | @@ -XXX,XX +XXX,XX @@ void sve_ldN_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | ||
88 | uint32_t desc, const uintptr_t retaddr, | ||
89 | const int esz, const int msz, const int N, uint32_t mtedesc, | ||
90 | sve_ldst1_host_fn *host_fn, | ||
91 | - sve_ldst1_tlb_fn *tlb_fn, | ||
92 | - sve_cont_ldst_mte_check_fn *mte_check_fn) | ||
93 | + sve_ldst1_tlb_fn *tlb_fn) | ||
94 | { | 24 | { |
95 | const unsigned rd = simd_data(desc); | 25 | TCGv_i32 addr; |
96 | const intptr_t reg_max = simd_oprsz(desc); | 26 | uint32_t offset; |
97 | @@ -XXX,XX +XXX,XX @@ void sve_ldN_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | 27 | @@ -XXX,XX +XXX,XX @@ static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) |
98 | * Handle mte checks for all active elements. | 28 | return true; |
99 | * Since TBI must be set for MTE, !mtedesc => !mte_active. | ||
100 | */ | ||
101 | - if (mte_check_fn && mtedesc) { | ||
102 | - mte_check_fn(&info, env, vg, addr, 1 << esz, N << msz, | ||
103 | - mtedesc, retaddr); | ||
104 | + if (mtedesc) { | ||
105 | + sve_cont_ldst_mte_check(&info, env, vg, addr, 1 << esz, N << msz, | ||
106 | + mtedesc, retaddr); | ||
107 | } | 29 | } |
108 | 30 | ||
109 | flags = info.page[0].flags | info.page[1].flags; | 31 | - offset = a->imm << a->size; |
110 | @@ -XXX,XX +XXX,XX @@ void sve_ldN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr, | 32 | + offset = a->imm << msize; |
111 | mtedesc = 0; | 33 | if (!a->a) { |
34 | offset = -offset; | ||
112 | } | 35 | } |
113 | 36 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) | |
114 | - sve_ldN_r(env, vg, addr, desc, ra, esz, msz, N, mtedesc, host_fn, tlb_fn, | 37 | { gen_helper_mve_vstrw, gen_helper_mve_vldrw }, |
115 | - N == 1 ? sve_cont_ldst_mte_check1 : sve_cont_ldst_mte_checkN); | 38 | { NULL, NULL } |
116 | + sve_ldN_r(env, vg, addr, desc, ra, esz, msz, N, mtedesc, host_fn, tlb_fn); | 39 | }; |
40 | - return do_ldst(s, a, ldstfns[a->size][a->l]); | ||
41 | + return do_ldst(s, a, ldstfns[a->size][a->l], a->size); | ||
117 | } | 42 | } |
118 | 43 | ||
119 | #define DO_LD1_1(NAME, ESZ) \ | 44 | -#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST) \ |
120 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_##NAME##_r)(CPUARMState *env, void *vg, \ | 45 | +#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST, MSIZE) \ |
121 | target_ulong addr, uint32_t desc) \ | 46 | static bool trans_##OP(DisasContext *s, arg_VLDR_VSTR *a) \ |
122 | { \ | 47 | { \ |
123 | sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, MO_8, 1, 0, \ | 48 | static MVEGenLdStFn * const ldstfns[2][2] = { \ |
124 | - sve_##NAME##_host, sve_##NAME##_tlb, NULL); \ | 49 | { gen_helper_mve_##ST, gen_helper_mve_##SLD }, \ |
125 | + sve_##NAME##_host, sve_##NAME##_tlb); \ | 50 | { NULL, gen_helper_mve_##ULD }, \ |
126 | } \ | 51 | }; \ |
127 | void HELPER(sve_##NAME##_r_mte)(CPUARMState *env, void *vg, \ | 52 | - return do_ldst(s, a, ldstfns[a->u][a->l]); \ |
128 | target_ulong addr, uint32_t desc) \ | 53 | + return do_ldst(s, a, ldstfns[a->u][a->l], MSIZE); \ |
129 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_##NAME##_le_r)(CPUARMState *env, void *vg, \ | 54 | } |
130 | target_ulong addr, uint32_t desc) \ | 55 | |
131 | { \ | 56 | -DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h) |
132 | sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, 1, 0, \ | 57 | -DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w) |
133 | - sve_##NAME##_le_host, sve_##NAME##_le_tlb, NULL); \ | 58 | -DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w) |
134 | + sve_##NAME##_le_host, sve_##NAME##_le_tlb); \ | 59 | +DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h, MO_8) |
135 | } \ | 60 | +DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w, MO_8) |
136 | void HELPER(sve_##NAME##_be_r)(CPUARMState *env, void *vg, \ | 61 | +DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w, MO_16) |
137 | target_ulong addr, uint32_t desc) \ | 62 | |
138 | { \ | 63 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) |
139 | sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, 1, 0, \ | ||
140 | - sve_##NAME##_be_host, sve_##NAME##_be_tlb, NULL); \ | ||
141 | + sve_##NAME##_be_host, sve_##NAME##_be_tlb); \ | ||
142 | } \ | ||
143 | void HELPER(sve_##NAME##_le_r_mte)(CPUARMState *env, void *vg, \ | ||
144 | - target_ulong addr, uint32_t desc) \ | ||
145 | + target_ulong addr, uint32_t desc) \ | ||
146 | { \ | ||
147 | sve_ldN_r_mte(env, vg, addr, desc, GETPC(), ESZ, MSZ, 1, \ | ||
148 | sve_##NAME##_le_host, sve_##NAME##_le_tlb); \ | ||
149 | } \ | ||
150 | void HELPER(sve_##NAME##_be_r_mte)(CPUARMState *env, void *vg, \ | ||
151 | - target_ulong addr, uint32_t desc) \ | ||
152 | + target_ulong addr, uint32_t desc) \ | ||
153 | { \ | ||
154 | sve_ldN_r_mte(env, vg, addr, desc, GETPC(), ESZ, MSZ, 1, \ | ||
155 | sve_##NAME##_be_host, sve_##NAME##_be_tlb); \ | ||
156 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_ld##N##bb_r)(CPUARMState *env, void *vg, \ | ||
157 | target_ulong addr, uint32_t desc) \ | ||
158 | { \ | ||
159 | sve_ldN_r(env, vg, addr, desc, GETPC(), MO_8, MO_8, N, 0, \ | ||
160 | - sve_ld1bb_host, sve_ld1bb_tlb, NULL); \ | ||
161 | + sve_ld1bb_host, sve_ld1bb_tlb); \ | ||
162 | } \ | ||
163 | void HELPER(sve_ld##N##bb_r_mte)(CPUARMState *env, void *vg, \ | ||
164 | target_ulong addr, uint32_t desc) \ | ||
165 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_ld##N##SUFF##_le_r)(CPUARMState *env, void *vg, \ | ||
166 | target_ulong addr, uint32_t desc) \ | ||
167 | { \ | ||
168 | sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, ESZ, N, 0, \ | ||
169 | - sve_ld1##SUFF##_le_host, sve_ld1##SUFF##_le_tlb, NULL); \ | ||
170 | + sve_ld1##SUFF##_le_host, sve_ld1##SUFF##_le_tlb); \ | ||
171 | } \ | ||
172 | void HELPER(sve_ld##N##SUFF##_be_r)(CPUARMState *env, void *vg, \ | ||
173 | target_ulong addr, uint32_t desc) \ | ||
174 | { \ | ||
175 | sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, ESZ, N, 0, \ | ||
176 | - sve_ld1##SUFF##_be_host, sve_ld1##SUFF##_be_tlb, NULL); \ | ||
177 | + sve_ld1##SUFF##_be_host, sve_ld1##SUFF##_be_tlb); \ | ||
178 | } \ | ||
179 | void HELPER(sve_ld##N##SUFF##_le_r_mte)(CPUARMState *env, void *vg, \ | ||
180 | target_ulong addr, uint32_t desc) \ | ||
181 | @@ -XXX,XX +XXX,XX @@ void sve_stN_r(CPUARMState *env, uint64_t *vg, target_ulong addr, | ||
182 | uint32_t desc, const uintptr_t retaddr, | ||
183 | const int esz, const int msz, const int N, uint32_t mtedesc, | ||
184 | sve_ldst1_host_fn *host_fn, | ||
185 | - sve_ldst1_tlb_fn *tlb_fn, | ||
186 | - sve_cont_ldst_mte_check_fn *mte_check_fn) | ||
187 | + sve_ldst1_tlb_fn *tlb_fn) | ||
188 | { | 64 | { |
189 | const unsigned rd = simd_data(desc); | ||
190 | const intptr_t reg_max = simd_oprsz(desc); | ||
191 | @@ -XXX,XX +XXX,XX @@ void sve_stN_r(CPUARMState *env, uint64_t *vg, target_ulong addr, | ||
192 | * Handle mte checks for all active elements. | ||
193 | * Since TBI must be set for MTE, !mtedesc => !mte_active. | ||
194 | */ | ||
195 | - if (mte_check_fn && mtedesc) { | ||
196 | - mte_check_fn(&info, env, vg, addr, 1 << esz, N << msz, | ||
197 | - mtedesc, retaddr); | ||
198 | + if (mtedesc) { | ||
199 | + sve_cont_ldst_mte_check(&info, env, vg, addr, 1 << esz, N << msz, | ||
200 | + mtedesc, retaddr); | ||
201 | } | ||
202 | |||
203 | flags = info.page[0].flags | info.page[1].flags; | ||
204 | @@ -XXX,XX +XXX,XX @@ void sve_stN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr, | ||
205 | mtedesc = 0; | ||
206 | } | ||
207 | |||
208 | - sve_stN_r(env, vg, addr, desc, ra, esz, msz, N, mtedesc, host_fn, tlb_fn, | ||
209 | - N == 1 ? sve_cont_ldst_mte_check1 : sve_cont_ldst_mte_checkN); | ||
210 | + sve_stN_r(env, vg, addr, desc, ra, esz, msz, N, mtedesc, host_fn, tlb_fn); | ||
211 | } | ||
212 | |||
213 | #define DO_STN_1(N, NAME, ESZ) \ | ||
214 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_st##N##NAME##_r)(CPUARMState *env, void *vg, \ | ||
215 | target_ulong addr, uint32_t desc) \ | ||
216 | { \ | ||
217 | sve_stN_r(env, vg, addr, desc, GETPC(), ESZ, MO_8, N, 0, \ | ||
218 | - sve_st1##NAME##_host, sve_st1##NAME##_tlb, NULL); \ | ||
219 | + sve_st1##NAME##_host, sve_st1##NAME##_tlb); \ | ||
220 | } \ | ||
221 | void HELPER(sve_st##N##NAME##_r_mte)(CPUARMState *env, void *vg, \ | ||
222 | target_ulong addr, uint32_t desc) \ | ||
223 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_st##N##NAME##_le_r)(CPUARMState *env, void *vg, \ | ||
224 | target_ulong addr, uint32_t desc) \ | ||
225 | { \ | ||
226 | sve_stN_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, N, 0, \ | ||
227 | - sve_st1##NAME##_le_host, sve_st1##NAME##_le_tlb, NULL); \ | ||
228 | + sve_st1##NAME##_le_host, sve_st1##NAME##_le_tlb); \ | ||
229 | } \ | ||
230 | void HELPER(sve_st##N##NAME##_be_r)(CPUARMState *env, void *vg, \ | ||
231 | target_ulong addr, uint32_t desc) \ | ||
232 | { \ | ||
233 | sve_stN_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, N, 0, \ | ||
234 | - sve_st1##NAME##_be_host, sve_st1##NAME##_be_tlb, NULL); \ | ||
235 | + sve_st1##NAME##_be_host, sve_st1##NAME##_be_tlb); \ | ||
236 | } \ | ||
237 | void HELPER(sve_st##N##NAME##_le_r_mte)(CPUARMState *env, void *vg, \ | ||
238 | target_ulong addr, uint32_t desc) \ | ||
239 | -- | 65 | -- |
240 | 2.20.1 | 66 | 2.20.1 |
241 | 67 | ||
242 | 68 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | In particular, fixing the second of these allows us to recast |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | the implementation to avoid 128-bit arithmetic entirely. |
5 | Message-id: 20210419202257.161730-30-richard.henderson@linaro.org | 12 | |
13 | Since the element size here is always 4, we can also drop the | ||
14 | parameterization of ESIZE to make the code a little more readable. | ||
15 | |||
16 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20210628135835.6690-3-peter.maydell@linaro.org | ||
7 | --- | 20 | --- |
8 | target/arm/translate-a64.c | 15 +++++++++++---- | 21 | target/arm/mve_helper.c | 38 +++++++++++++++++++++----------------- |
9 | 1 file changed, 11 insertions(+), 4 deletions(-) | 22 | 1 file changed, 21 insertions(+), 17 deletions(-) |
10 | 23 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 24 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 26 | --- a/target/arm/mve_helper.c |
14 | +++ b/target/arm/translate-a64.c | 27 | +++ b/target/arm/mve_helper.c |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 28 | @@ -XXX,XX +XXX,XX @@ |
16 | bool is_postidx = extract32(insn, 23, 1); | 29 | */ |
17 | bool is_q = extract32(insn, 30, 1); | 30 | |
18 | TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; | 31 | #include "qemu/osdep.h" |
19 | - MemOp endian = s->be_data; | 32 | -#include "qemu/int128.h" |
20 | + MemOp endian, align, mop; | 33 | #include "cpu.h" |
21 | 34 | #include "internals.h" | |
22 | int total; /* total bytes */ | 35 | #include "vec_internal.h" |
23 | int elements; /* elements per vector */ | 36 | @@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=) |
24 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 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; \ | ||
25 | } | 81 | } |
26 | 82 | ||
27 | /* For our purposes, bytes are always little-endian. */ | 83 | -DO_LDAVH(vrmlaldavhsw, 4, int32_t, false, int128_add, int128_add, int128_makes64) |
28 | + endian = s->be_data; | 84 | -DO_LDAVH(vrmlaldavhxsw, 4, int32_t, true, int128_add, int128_add, int128_makes64) |
29 | if (size == 0) { | 85 | +DO_LDAVH(vrmlaldavhsw, int32_t, int64_t, false, false) |
30 | endian = MO_LE; | 86 | +DO_LDAVH(vrmlaldavhxsw, int32_t, int64_t, true, false) |
31 | } | 87 | |
32 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 88 | -DO_LDAVH(vrmlaldavhuw, 4, uint32_t, false, int128_add, int128_add, int128_make64) |
33 | * Consecutive little-endian elements from a single register | 89 | +DO_LDAVH(vrmlaldavhuw, uint32_t, uint64_t, false, false) |
34 | * can be promoted to a larger little-endian operation. | 90 | |
35 | */ | 91 | -DO_LDAVH(vrmlsldavhsw, 4, int32_t, false, int128_add, int128_sub, int128_makes64) |
36 | + align = MO_ALIGN; | 92 | -DO_LDAVH(vrmlsldavhxsw, 4, int32_t, true, int128_add, int128_sub, int128_makes64) |
37 | if (selem == 1 && endian == MO_LE) { | 93 | +DO_LDAVH(vrmlsldavhsw, int32_t, int64_t, false, true) |
38 | + align = pow2_align(size); | 94 | +DO_LDAVH(vrmlsldavhxsw, int32_t, int64_t, true, true) |
39 | size = 3; | 95 | |
40 | } | 96 | /* Vector add across vector */ |
41 | - elements = (is_q ? 16 : 8) >> size; | 97 | #define DO_VADDV(OP, ESIZE, TYPE) \ |
42 | + if (!s->align_mem) { | ||
43 | + align = 0; | ||
44 | + } | ||
45 | + mop = endian | size | align; | ||
46 | |||
47 | + elements = (is_q ? 16 : 8) >> size; | ||
48 | tcg_ebytes = tcg_const_i64(1 << size); | ||
49 | for (r = 0; r < rpt; r++) { | ||
50 | int e; | ||
51 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
52 | for (xs = 0; xs < selem; xs++) { | ||
53 | int tt = (rt + r + xs) % 32; | ||
54 | if (is_store) { | ||
55 | - do_vec_st(s, tt, e, clean_addr, size | endian); | ||
56 | + do_vec_st(s, tt, e, clean_addr, mop); | ||
57 | } else { | ||
58 | - do_vec_ld(s, tt, e, clean_addr, size | endian); | ||
59 | + do_vec_ld(s, tt, e, clean_addr, mop); | ||
60 | } | ||
61 | tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); | ||
62 | } | ||
63 | -- | 98 | -- |
64 | 2.20.1 | 99 | 2.20.1 |
65 | 100 | ||
66 | 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 | Create a finalize_memop function that computes alignment and | ||
4 | endianness and returns the final MemOp for the operation. | ||
5 | |||
6 | Split out gen_aa32_{ld,st}_internal_i32 which bypasses any special | ||
7 | handling of endianness or alignment. Adjust gen_aa32_{ld,st}_i32 | ||
8 | so that s->be_data is not added by the callers. | ||
9 | |||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20210419202257.161730-12-richard.henderson@linaro.org | ||
13 | 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-4-peter.maydell@linaro.org | ||
14 | --- | 9 | --- |
15 | target/arm/translate.h | 24 ++++++++ | 10 | target/arm/translate.h | 16 ++++++++++ |
16 | target/arm/translate.c | 100 +++++++++++++++++--------------- | 11 | target/arm/translate-neon.c | 63 ------------------------------------- |
17 | target/arm/translate-neon.c.inc | 9 +-- | 12 | target/arm/translate.c | 57 +++++++++++++++++++++++++++++++++ |
18 | 3 files changed, 79 insertions(+), 54 deletions(-) | 13 | 3 files changed, 73 insertions(+), 63 deletions(-) |
19 | 14 | ||
20 | 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 |
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/translate.h | 17 | --- a/target/arm/translate.h |
23 | +++ b/target/arm/translate.h | 18 | +++ b/target/arm/translate.h |
24 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_ptr fpstatus_ptr(ARMFPStatusFlavour flavour) | 19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) |
25 | return statusptr; | 20 | return opc | s->be_data; |
26 | } | 21 | } |
27 | 22 | ||
28 | +/** | 23 | +/** |
29 | + * finalize_memop: | 24 | + * asimd_imm_const: Expand an encoded SIMD constant value |
30 | + * @s: DisasContext | ||
31 | + * @opc: size+sign+align of the memory operation | ||
32 | + * | 25 | + * |
33 | + * Build the complete MemOp for a memory operation, including alignment | 26 | + * Expand a SIMD constant value. This is essentially the pseudocode |
34 | + * and endianness. | 27 | + * AdvSIMDExpandImm, except that we also perform the boolean NOT needed for |
28 | + * VMVN and VBIC (when cmode < 14 && op == 1). | ||
35 | + * | 29 | + * |
36 | + * If (op & MO_AMASK) then the operation already contains the required | 30 | + * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; |
37 | + * alignment, e.g. for AccType_ATOMIC. Otherwise, this an optionally | 31 | + * callers must catch this. |
38 | + * unaligned operation, e.g. for AccType_NORMAL. | ||
39 | + * | 32 | + * |
40 | + * In the latter case, there are configuration bits that require alignment, | 33 | + * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but |
41 | + * and this is applied here. Note that there is no way to indicate that | 34 | + * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; |
42 | + * no alignment should ever be enforced; this must be handled manually. | 35 | + * we produce an immediate constant value of 0 in these cases. |
43 | + */ | 36 | + */ |
44 | +static inline MemOp finalize_memop(DisasContext *s, MemOp opc) | 37 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op); |
45 | +{ | ||
46 | + if (s->align_mem && !(opc & MO_AMASK)) { | ||
47 | + opc |= MO_ALIGN; | ||
48 | + } | ||
49 | + return opc | s->be_data; | ||
50 | +} | ||
51 | + | 38 | + |
52 | #endif /* TARGET_ARM_TRANSLATE_H */ | 39 | #endif /* TARGET_ARM_TRANSLATE_H */ |
40 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/translate-neon.c | ||
43 | +++ b/target/arm/translate-neon.c | ||
44 | @@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_UH, gen_helper_gvec_vcvt_uh) | ||
45 | DO_FP_2SH(VCVT_HS, gen_helper_gvec_vcvt_hs) | ||
46 | DO_FP_2SH(VCVT_HU, gen_helper_gvec_vcvt_hu) | ||
47 | |||
48 | -static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | ||
49 | -{ | ||
50 | - /* | ||
51 | - * Expand the encoded constant. | ||
52 | - * Note that cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. | ||
53 | - * We choose to not special-case this and will behave as if a | ||
54 | - * valid constant encoding of 0 had been given. | ||
55 | - * cmode = 15 op = 1 must UNDEF; we assume decode has handled that. | ||
56 | - */ | ||
57 | - switch (cmode) { | ||
58 | - case 0: case 1: | ||
59 | - /* no-op */ | ||
60 | - break; | ||
61 | - case 2: case 3: | ||
62 | - imm <<= 8; | ||
63 | - break; | ||
64 | - case 4: case 5: | ||
65 | - imm <<= 16; | ||
66 | - break; | ||
67 | - case 6: case 7: | ||
68 | - imm <<= 24; | ||
69 | - break; | ||
70 | - case 8: case 9: | ||
71 | - imm |= imm << 16; | ||
72 | - break; | ||
73 | - case 10: case 11: | ||
74 | - imm = (imm << 8) | (imm << 24); | ||
75 | - break; | ||
76 | - case 12: | ||
77 | - imm = (imm << 8) | 0xff; | ||
78 | - break; | ||
79 | - case 13: | ||
80 | - imm = (imm << 16) | 0xffff; | ||
81 | - break; | ||
82 | - case 14: | ||
83 | - if (op) { | ||
84 | - /* | ||
85 | - * This is the only case where the top and bottom 32 bits | ||
86 | - * of the encoded constant differ. | ||
87 | - */ | ||
88 | - uint64_t imm64 = 0; | ||
89 | - int n; | ||
90 | - | ||
91 | - for (n = 0; n < 8; n++) { | ||
92 | - if (imm & (1 << n)) { | ||
93 | - imm64 |= (0xffULL << (n * 8)); | ||
94 | - } | ||
95 | - } | ||
96 | - return imm64; | ||
97 | - } | ||
98 | - imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
99 | - break; | ||
100 | - case 15: | ||
101 | - imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
102 | - | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
103 | - break; | ||
104 | - } | ||
105 | - if (op) { | ||
106 | - imm = ~imm; | ||
107 | - } | ||
108 | - return dup_const(MO_32, imm); | ||
109 | -} | ||
110 | - | ||
111 | static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a, | ||
112 | GVecGen2iFn *fn) | ||
113 | { | ||
53 | 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 |
54 | index XXXXXXX..XXXXXXX 100644 | 115 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/target/arm/translate.c | 116 | --- a/target/arm/translate.c |
56 | +++ b/target/arm/translate.c | 117 | +++ b/target/arm/translate.c |
57 | @@ -XXX,XX +XXX,XX @@ static inline void store_reg_from_load(DisasContext *s, int reg, TCGv_i32 var) | 118 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void) |
58 | #define IS_USER_ONLY 0 | 119 | a64_translate_init(); |
59 | #endif | ||
60 | |||
61 | -/* Abstractions of "generate code to do a guest load/store for | ||
62 | +/* | ||
63 | + * Abstractions of "generate code to do a guest load/store for | ||
64 | * AArch32", where a vaddr is always 32 bits (and is zero | ||
65 | * extended if we're a 64 bit core) and data is also | ||
66 | * 32 bits unless specifically doing a 64 bit access. | ||
67 | @@ -XXX,XX +XXX,XX @@ static inline void store_reg_from_load(DisasContext *s, int reg, TCGv_i32 var) | ||
68 | * that the address argument is TCGv_i32 rather than TCGv. | ||
69 | */ | ||
70 | |||
71 | -static inline TCGv gen_aa32_addr(DisasContext *s, TCGv_i32 a32, MemOp op) | ||
72 | +static TCGv gen_aa32_addr(DisasContext *s, TCGv_i32 a32, MemOp op) | ||
73 | { | ||
74 | TCGv addr = tcg_temp_new(); | ||
75 | tcg_gen_extu_i32_tl(addr, a32); | ||
76 | @@ -XXX,XX +XXX,XX @@ static inline TCGv gen_aa32_addr(DisasContext *s, TCGv_i32 a32, MemOp op) | ||
77 | return addr; | ||
78 | } | 120 | } |
79 | 121 | ||
80 | +/* | 122 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) |
81 | + * Internal routines are used for NEON cases where the endianness | ||
82 | + * and/or alignment has already been taken into account and manipulated. | ||
83 | + */ | ||
84 | +static void gen_aa32_ld_internal_i32(DisasContext *s, TCGv_i32 val, | ||
85 | + TCGv_i32 a32, int index, MemOp opc) | ||
86 | +{ | 123 | +{ |
87 | + TCGv addr = gen_aa32_addr(s, a32, opc); | 124 | + /* Expand the encoded constant as per AdvSIMDExpandImm pseudocode */ |
88 | + tcg_gen_qemu_ld_i32(val, addr, index, opc); | 125 | + switch (cmode) { |
89 | + tcg_temp_free(addr); | 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); | ||
90 | +} | 177 | +} |
91 | + | 178 | + |
92 | +static void gen_aa32_st_internal_i32(DisasContext *s, TCGv_i32 val, | 179 | /* Generate a label used for skipping this instruction */ |
93 | + TCGv_i32 a32, int index, MemOp opc) | 180 | void arm_gen_condlabel(DisasContext *s) |
94 | +{ | ||
95 | + TCGv addr = gen_aa32_addr(s, a32, opc); | ||
96 | + tcg_gen_qemu_st_i32(val, addr, index, opc); | ||
97 | + tcg_temp_free(addr); | ||
98 | +} | ||
99 | + | ||
100 | static void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
101 | int index, MemOp opc) | ||
102 | { | 181 | { |
103 | - TCGv addr; | ||
104 | - | ||
105 | - if (s->align_mem) { | ||
106 | - opc |= MO_ALIGN; | ||
107 | - } | ||
108 | - | ||
109 | - addr = gen_aa32_addr(s, a32, opc); | ||
110 | - tcg_gen_qemu_ld_i32(val, addr, index, opc); | ||
111 | - tcg_temp_free(addr); | ||
112 | + gen_aa32_ld_internal_i32(s, val, a32, index, finalize_memop(s, opc)); | ||
113 | } | ||
114 | |||
115 | static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
116 | int index, MemOp opc) | ||
117 | { | ||
118 | - TCGv addr; | ||
119 | + gen_aa32_st_internal_i32(s, val, a32, index, finalize_memop(s, opc)); | ||
120 | +} | ||
121 | |||
122 | - if (s->align_mem) { | ||
123 | - opc |= MO_ALIGN; | ||
124 | +#define DO_GEN_LD(SUFF, OPC) \ | ||
125 | + static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val, \ | ||
126 | + TCGv_i32 a32, int index) \ | ||
127 | + { \ | ||
128 | + gen_aa32_ld_i32(s, val, a32, index, OPC); \ | ||
129 | } | ||
130 | |||
131 | - addr = gen_aa32_addr(s, a32, opc); | ||
132 | - tcg_gen_qemu_st_i32(val, addr, index, opc); | ||
133 | - tcg_temp_free(addr); | ||
134 | -} | ||
135 | - | ||
136 | -#define DO_GEN_LD(SUFF, OPC) \ | ||
137 | -static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val, \ | ||
138 | - TCGv_i32 a32, int index) \ | ||
139 | -{ \ | ||
140 | - gen_aa32_ld_i32(s, val, a32, index, OPC | s->be_data); \ | ||
141 | -} | ||
142 | - | ||
143 | -#define DO_GEN_ST(SUFF, OPC) \ | ||
144 | -static inline void gen_aa32_st##SUFF(DisasContext *s, TCGv_i32 val, \ | ||
145 | - TCGv_i32 a32, int index) \ | ||
146 | -{ \ | ||
147 | - gen_aa32_st_i32(s, val, a32, index, OPC | s->be_data); \ | ||
148 | -} | ||
149 | +#define DO_GEN_ST(SUFF, OPC) \ | ||
150 | + static inline void gen_aa32_st##SUFF(DisasContext *s, TCGv_i32 val, \ | ||
151 | + TCGv_i32 a32, int index) \ | ||
152 | + { \ | ||
153 | + gen_aa32_st_i32(s, val, a32, index, OPC); \ | ||
154 | + } | ||
155 | |||
156 | static inline void gen_aa32_frob64(DisasContext *s, TCGv_i64 val) | ||
157 | { | ||
158 | @@ -XXX,XX +XXX,XX @@ static bool op_load_rr(DisasContext *s, arg_ldst_rr *a, | ||
159 | addr = op_addr_rr_pre(s, a); | ||
160 | |||
161 | tmp = tcg_temp_new_i32(); | ||
162 | - gen_aa32_ld_i32(s, tmp, addr, mem_idx, mop | s->be_data); | ||
163 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, mop); | ||
164 | disas_set_da_iss(s, mop, issinfo); | ||
165 | |||
166 | /* | ||
167 | @@ -XXX,XX +XXX,XX @@ static bool op_store_rr(DisasContext *s, arg_ldst_rr *a, | ||
168 | addr = op_addr_rr_pre(s, a); | ||
169 | |||
170 | tmp = load_reg(s, a->rt); | ||
171 | - gen_aa32_st_i32(s, tmp, addr, mem_idx, mop | s->be_data); | ||
172 | + gen_aa32_st_i32(s, tmp, addr, mem_idx, mop); | ||
173 | disas_set_da_iss(s, mop, issinfo); | ||
174 | tcg_temp_free_i32(tmp); | ||
175 | |||
176 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDRD_rr(DisasContext *s, arg_ldst_rr *a) | ||
177 | addr = op_addr_rr_pre(s, a); | ||
178 | |||
179 | tmp = tcg_temp_new_i32(); | ||
180 | - gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL | s->be_data); | ||
181 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL); | ||
182 | store_reg(s, a->rt, tmp); | ||
183 | |||
184 | tcg_gen_addi_i32(addr, addr, 4); | ||
185 | |||
186 | tmp = tcg_temp_new_i32(); | ||
187 | - gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL | s->be_data); | ||
188 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL); | ||
189 | store_reg(s, a->rt + 1, tmp); | ||
190 | |||
191 | /* LDRD w/ base writeback is undefined if the registers overlap. */ | ||
192 | @@ -XXX,XX +XXX,XX @@ static bool trans_STRD_rr(DisasContext *s, arg_ldst_rr *a) | ||
193 | addr = op_addr_rr_pre(s, a); | ||
194 | |||
195 | tmp = load_reg(s, a->rt); | ||
196 | - gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL | s->be_data); | ||
197 | + gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL); | ||
198 | tcg_temp_free_i32(tmp); | ||
199 | |||
200 | tcg_gen_addi_i32(addr, addr, 4); | ||
201 | |||
202 | tmp = load_reg(s, a->rt + 1); | ||
203 | - gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL | s->be_data); | ||
204 | + gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL); | ||
205 | tcg_temp_free_i32(tmp); | ||
206 | |||
207 | op_addr_rr_post(s, a, addr, -4); | ||
208 | @@ -XXX,XX +XXX,XX @@ static bool op_load_ri(DisasContext *s, arg_ldst_ri *a, | ||
209 | addr = op_addr_ri_pre(s, a); | ||
210 | |||
211 | tmp = tcg_temp_new_i32(); | ||
212 | - gen_aa32_ld_i32(s, tmp, addr, mem_idx, mop | s->be_data); | ||
213 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, mop); | ||
214 | disas_set_da_iss(s, mop, issinfo); | ||
215 | |||
216 | /* | ||
217 | @@ -XXX,XX +XXX,XX @@ static bool op_store_ri(DisasContext *s, arg_ldst_ri *a, | ||
218 | addr = op_addr_ri_pre(s, a); | ||
219 | |||
220 | tmp = load_reg(s, a->rt); | ||
221 | - gen_aa32_st_i32(s, tmp, addr, mem_idx, mop | s->be_data); | ||
222 | + gen_aa32_st_i32(s, tmp, addr, mem_idx, mop); | ||
223 | disas_set_da_iss(s, mop, issinfo); | ||
224 | tcg_temp_free_i32(tmp); | ||
225 | |||
226 | @@ -XXX,XX +XXX,XX @@ static bool op_ldrd_ri(DisasContext *s, arg_ldst_ri *a, int rt2) | ||
227 | addr = op_addr_ri_pre(s, a); | ||
228 | |||
229 | tmp = tcg_temp_new_i32(); | ||
230 | - gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL | s->be_data); | ||
231 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL); | ||
232 | store_reg(s, a->rt, tmp); | ||
233 | |||
234 | tcg_gen_addi_i32(addr, addr, 4); | ||
235 | |||
236 | tmp = tcg_temp_new_i32(); | ||
237 | - gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL | s->be_data); | ||
238 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL); | ||
239 | store_reg(s, rt2, tmp); | ||
240 | |||
241 | /* LDRD w/ base writeback is undefined if the registers overlap. */ | ||
242 | @@ -XXX,XX +XXX,XX @@ static bool op_strd_ri(DisasContext *s, arg_ldst_ri *a, int rt2) | ||
243 | addr = op_addr_ri_pre(s, a); | ||
244 | |||
245 | tmp = load_reg(s, a->rt); | ||
246 | - gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL | s->be_data); | ||
247 | + gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL); | ||
248 | tcg_temp_free_i32(tmp); | ||
249 | |||
250 | tcg_gen_addi_i32(addr, addr, 4); | ||
251 | |||
252 | tmp = load_reg(s, rt2); | ||
253 | - gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL | s->be_data); | ||
254 | + gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL); | ||
255 | tcg_temp_free_i32(tmp); | ||
256 | |||
257 | op_addr_ri_post(s, a, addr, -4); | ||
258 | @@ -XXX,XX +XXX,XX @@ static bool op_stl(DisasContext *s, arg_STL *a, MemOp mop) | ||
259 | addr = load_reg(s, a->rn); | ||
260 | tmp = load_reg(s, a->rt); | ||
261 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | ||
262 | - gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), mop | s->be_data); | ||
263 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), mop); | ||
264 | disas_set_da_iss(s, mop, a->rt | ISSIsAcqRel | ISSIsWrite); | ||
265 | |||
266 | tcg_temp_free_i32(tmp); | ||
267 | @@ -XXX,XX +XXX,XX @@ static bool op_lda(DisasContext *s, arg_LDA *a, MemOp mop) | ||
268 | |||
269 | addr = load_reg(s, a->rn); | ||
270 | tmp = tcg_temp_new_i32(); | ||
271 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), mop | s->be_data); | ||
272 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), mop); | ||
273 | disas_set_da_iss(s, mop, a->rt | ISSIsAcqRel); | ||
274 | tcg_temp_free_i32(addr); | ||
275 | |||
276 | @@ -XXX,XX +XXX,XX @@ static bool op_tbranch(DisasContext *s, arg_tbranch *a, bool half) | ||
277 | addr = load_reg(s, a->rn); | ||
278 | tcg_gen_add_i32(addr, addr, tmp); | ||
279 | |||
280 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), | ||
281 | - half ? MO_UW | s->be_data : MO_UB); | ||
282 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), half ? MO_UW : MO_UB); | ||
283 | tcg_temp_free_i32(addr); | ||
284 | |||
285 | tcg_gen_add_i32(tmp, tmp, tmp); | ||
286 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | ||
287 | index XXXXXXX..XXXXXXX 100644 | ||
288 | --- a/target/arm/translate-neon.c.inc | ||
289 | +++ b/target/arm/translate-neon.c.inc | ||
290 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | ||
291 | addr = tcg_temp_new_i32(); | ||
292 | load_reg_var(s, addr, a->rn); | ||
293 | for (reg = 0; reg < nregs; reg++) { | ||
294 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), | ||
295 | - s->be_data | size); | ||
296 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), size); | ||
297 | if ((vd & 1) && vec_size == 16) { | ||
298 | /* | ||
299 | * We cannot write 16 bytes at once because the | ||
300 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | ||
301 | */ | ||
302 | for (reg = 0; reg < nregs; reg++) { | ||
303 | if (a->l) { | ||
304 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), | ||
305 | - s->be_data | a->size); | ||
306 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), a->size); | ||
307 | neon_store_element(vd, a->reg_idx, a->size, tmp); | ||
308 | } else { /* Store */ | ||
309 | neon_load_element(tmp, vd, a->reg_idx, a->size); | ||
310 | - gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), | ||
311 | - s->be_data | a->size); | ||
312 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), a->size); | ||
313 | } | ||
314 | vd += a->stride; | ||
315 | tcg_gen_addi_i32(addr, addr, 1 << a->size); | ||
316 | -- | 182 | -- |
317 | 2.20.1 | 183 | 2.20.1 |
318 | 184 | ||
319 | 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're about to rearrange the macro expansion surrounding tbflags, | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | and this field name will be expanded using the bit definition of | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | the same name, resulting in a token pasting error. | 8 | Message-id: 20210628135835.6690-5-peter.maydell@linaro.org |
9 | --- | ||
10 | target/arm/translate.h | 3 +- | ||
11 | target/arm/translate-a64.c | 86 ++++---------------------------------- | ||
12 | target/arm/translate.c | 17 +++++++- | ||
13 | 3 files changed, 24 insertions(+), 82 deletions(-) | ||
6 | 14 | ||
7 | So PSTATE_SS -> PSTATE__SS in the uses, and document it. | 15 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
8 | |||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20210419202257.161730-4-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/cpu.h | 2 +- | ||
15 | target/arm/helper.c | 4 ++-- | ||
16 | target/arm/translate-a64.c | 2 +- | ||
17 | target/arm/translate.c | 2 +- | ||
18 | 4 files changed, 5 insertions(+), 5 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/translate.h |
23 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/translate.h |
24 | @@ -XXX,XX +XXX,XX @@ typedef ARMCPU ArchCPU; | 19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) |
25 | */ | 20 | * VMVN and VBIC (when cmode < 14 && op == 1). |
26 | FIELD(TBFLAG_ANY, AARCH64_STATE, 31, 1) | 21 | * |
27 | FIELD(TBFLAG_ANY, SS_ACTIVE, 30, 1) | 22 | * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; |
28 | -FIELD(TBFLAG_ANY, PSTATE_SS, 29, 1) /* Not cached. */ | 23 | - * callers must catch this. |
29 | +FIELD(TBFLAG_ANY, PSTATE__SS, 29, 1) /* Not cached. */ | 24 | + * callers must catch this; we return the 64-bit constant value defined |
30 | FIELD(TBFLAG_ANY, BE_DATA, 28, 1) | 25 | + * for AArch64. |
31 | FIELD(TBFLAG_ANY, MMUIDX, 24, 4) | 26 | * |
32 | /* Target EL if we take a floating-point-disabled exception */ | 27 | * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but |
33 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 28 | * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; |
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/helper.c | ||
36 | +++ b/target/arm/helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
38 | * 0 x Inactive (the TB flag for SS is always 0) | ||
39 | * 1 0 Active-pending | ||
40 | * 1 1 Active-not-pending | ||
41 | - * SS_ACTIVE is set in hflags; PSTATE_SS is computed every TB. | ||
42 | + * SS_ACTIVE is set in hflags; PSTATE__SS is computed every TB. | ||
43 | */ | ||
44 | if (FIELD_EX32(flags, TBFLAG_ANY, SS_ACTIVE) && | ||
45 | (env->pstate & PSTATE_SS)) { | ||
46 | - flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE_SS, 1); | ||
47 | + flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE__SS, 1); | ||
48 | } | ||
49 | |||
50 | *pflags = flags; | ||
51 | 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 |
52 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/target/arm/translate-a64.c | 31 | --- a/target/arm/translate-a64.c |
54 | +++ b/target/arm/translate-a64.c | 32 | +++ b/target/arm/translate-a64.c |
55 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 33 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) |
56 | * end the TB | 34 | { |
57 | */ | 35 | int rd = extract32(insn, 0, 5); |
58 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | 36 | int cmode = extract32(insn, 12, 4); |
59 | - dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | 37 | - int cmode_3_1 = extract32(cmode, 1, 3); |
60 | + dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE__SS); | 38 | - int cmode_0 = extract32(cmode, 0, 1); |
61 | dc->is_ldex = false; | 39 | int o2 = extract32(insn, 11, 1); |
62 | dc->debug_target_el = FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | 40 | uint64_t abcdefgh = extract32(insn, 5, 5) | (extract32(insn, 16, 3) << 5); |
63 | 41 | bool is_neg = extract32(insn, 29, 1); | |
42 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) | ||
43 | return; | ||
44 | } | ||
45 | |||
46 | - /* See AdvSIMDExpandImm() in ARM ARM */ | ||
47 | - switch (cmode_3_1) { | ||
48 | - case 0: /* Replicate(Zeros(24):imm8, 2) */ | ||
49 | - case 1: /* Replicate(Zeros(16):imm8:Zeros(8), 2) */ | ||
50 | - case 2: /* Replicate(Zeros(8):imm8:Zeros(16), 2) */ | ||
51 | - case 3: /* Replicate(imm8:Zeros(24), 2) */ | ||
52 | - { | ||
53 | - int shift = cmode_3_1 * 8; | ||
54 | - imm = bitfield_replicate(abcdefgh << shift, 32); | ||
55 | - break; | ||
56 | - } | ||
57 | - case 4: /* Replicate(Zeros(8):imm8, 4) */ | ||
58 | - case 5: /* Replicate(imm8:Zeros(8), 4) */ | ||
59 | - { | ||
60 | - int shift = (cmode_3_1 & 0x1) * 8; | ||
61 | - imm = bitfield_replicate(abcdefgh << shift, 16); | ||
62 | - break; | ||
63 | - } | ||
64 | - case 6: | ||
65 | - if (cmode_0) { | ||
66 | - /* Replicate(Zeros(8):imm8:Ones(16), 2) */ | ||
67 | - imm = (abcdefgh << 16) | 0xffff; | ||
68 | - } else { | ||
69 | - /* Replicate(Zeros(16):imm8:Ones(8), 2) */ | ||
70 | - imm = (abcdefgh << 8) | 0xff; | ||
71 | - } | ||
72 | - imm = bitfield_replicate(imm, 32); | ||
73 | - break; | ||
74 | - case 7: | ||
75 | - if (!cmode_0 && !is_neg) { | ||
76 | - imm = bitfield_replicate(abcdefgh, 8); | ||
77 | - } else if (!cmode_0 && is_neg) { | ||
78 | - int i; | ||
79 | - imm = 0; | ||
80 | - for (i = 0; i < 8; i++) { | ||
81 | - if ((abcdefgh) & (1 << i)) { | ||
82 | - imm |= 0xffULL << (i * 8); | ||
83 | - } | ||
84 | - } | ||
85 | - } else if (cmode_0) { | ||
86 | - if (is_neg) { | ||
87 | - imm = (abcdefgh & 0x3f) << 48; | ||
88 | - if (abcdefgh & 0x80) { | ||
89 | - imm |= 0x8000000000000000ULL; | ||
90 | - } | ||
91 | - if (abcdefgh & 0x40) { | ||
92 | - imm |= 0x3fc0000000000000ULL; | ||
93 | - } else { | ||
94 | - imm |= 0x4000000000000000ULL; | ||
95 | - } | ||
96 | - } else { | ||
97 | - if (o2) { | ||
98 | - /* FMOV (vector, immediate) - half-precision */ | ||
99 | - imm = vfp_expand_imm(MO_16, abcdefgh); | ||
100 | - /* now duplicate across the lanes */ | ||
101 | - imm = bitfield_replicate(imm, 16); | ||
102 | - } else { | ||
103 | - imm = (abcdefgh & 0x3f) << 19; | ||
104 | - if (abcdefgh & 0x80) { | ||
105 | - imm |= 0x80000000; | ||
106 | - } | ||
107 | - if (abcdefgh & 0x40) { | ||
108 | - imm |= 0x3e000000; | ||
109 | - } else { | ||
110 | - imm |= 0x40000000; | ||
111 | - } | ||
112 | - imm |= (imm << 32); | ||
113 | - } | ||
114 | - } | ||
115 | - } | ||
116 | - break; | ||
117 | - default: | ||
118 | - g_assert_not_reached(); | ||
119 | - } | ||
120 | - | ||
121 | - if (cmode_3_1 != 7 && is_neg) { | ||
122 | - imm = ~imm; | ||
123 | + if (cmode == 15 && o2 && !is_neg) { | ||
124 | + /* FMOV (vector, immediate) - half-precision */ | ||
125 | + imm = vfp_expand_imm(MO_16, abcdefgh); | ||
126 | + /* now duplicate across the lanes */ | ||
127 | + imm = bitfield_replicate(imm, 16); | ||
128 | + } else { | ||
129 | + imm = asimd_imm_const(abcdefgh, cmode, is_neg); | ||
130 | } | ||
131 | |||
132 | if (!((cmode & 0x9) == 0x1 || (cmode & 0xd) == 0x9)) { | ||
64 | 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 |
65 | index XXXXXXX..XXXXXXX 100644 | 134 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/target/arm/translate.c | 135 | --- a/target/arm/translate.c |
67 | +++ b/target/arm/translate.c | 136 | +++ b/target/arm/translate.c |
68 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 137 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) |
69 | * end the TB | 138 | case 14: |
70 | */ | 139 | if (op) { |
71 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | 140 | /* |
72 | - dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | 141 | - * This is the only case where the top and bottom 32 bits |
73 | + dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE__SS); | 142 | - * of the encoded constant differ. |
74 | dc->is_ldex = false; | 143 | + * This and cmode == 15 op == 1 are the only cases where |
75 | 144 | + * the top and bottom 32 bits of the encoded constant differ. | |
76 | dc->page_start = dc->base.pc_first & TARGET_PAGE_MASK; | 145 | */ |
146 | uint64_t imm64 = 0; | ||
147 | int n; | ||
148 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | ||
149 | imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
150 | break; | ||
151 | case 15: | ||
152 | + if (op) { | ||
153 | + /* Reserved encoding for AArch32; valid for AArch64 */ | ||
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)); | ||
167 | break; | ||
77 | -- | 168 | -- |
78 | 2.20.1 | 169 | 2.20.1 |
79 | 170 | ||
80 | 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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | (We can't replace the other use of bitfield_replicate() in this file, |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | in logic_imm_decode_wmask(), because that location needs to handle 2 |
5 | Message-id: 20210419202257.161730-28-richard.henderson@linaro.org | 6 | and 4 bit elements, which dup_const() cannot.) |
7 | |||
6 | 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 | ||
7 | --- | 11 | --- |
8 | target/arm/translate-a64.c | 23 ++++++++++++++--------- | 12 | target/arm/translate-a64.c | 2 +- |
9 | 1 file changed, 14 insertions(+), 9 deletions(-) | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 14 | ||
11 | 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 |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 17 | --- a/target/arm/translate-a64.c |
14 | +++ b/target/arm/translate-a64.c | 18 | +++ b/target/arm/translate-a64.c |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | 19 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) |
16 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | 20 | /* FMOV (vector, immediate) - half-precision */ |
17 | clean_addr = gen_mte_check1(s, cpu_reg_sp(s, rn), | 21 | imm = vfp_expand_imm(MO_16, abcdefgh); |
18 | true, rn != 31, size); | 22 | /* now duplicate across the lanes */ |
19 | - do_gpr_st(s, cpu_reg(s, rt), clean_addr, size, true, rt, | 23 | - imm = bitfield_replicate(imm, 16); |
20 | + /* TODO: ARMv8.4-LSE SCTLR.nAA */ | 24 | + imm = dup_const(MO_16, imm); |
21 | + do_gpr_st(s, cpu_reg(s, rt), clean_addr, size | MO_ALIGN, true, rt, | ||
22 | disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | ||
23 | return; | ||
24 | |||
25 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | ||
26 | } | ||
27 | clean_addr = gen_mte_check1(s, cpu_reg_sp(s, rn), | ||
28 | false, rn != 31, size); | ||
29 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size, false, true, rt, | ||
30 | - disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | ||
31 | + /* TODO: ARMv8.4-LSE SCTLR.nAA */ | ||
32 | + do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size | MO_ALIGN, false, true, | ||
33 | + rt, disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | ||
34 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
35 | return; | ||
36 | |||
37 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | ||
38 | int size = extract32(insn, 30, 2); | ||
39 | TCGv_i64 clean_addr, dirty_addr; | ||
40 | bool is_store = false; | ||
41 | - bool is_signed = false; | ||
42 | bool extend = false; | ||
43 | bool iss_sf; | ||
44 | + MemOp mop; | ||
45 | |||
46 | if (!dc_isar_feature(aa64_rcpc_8_4, s)) { | ||
47 | unallocated_encoding(s); | ||
48 | return; | ||
49 | } | ||
50 | |||
51 | + /* TODO: ARMv8.4-LSE SCTLR.nAA */ | ||
52 | + mop = size | MO_ALIGN; | ||
53 | + | ||
54 | switch (opc) { | ||
55 | case 0: /* STLURB */ | ||
56 | is_store = true; | ||
57 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | ||
58 | unallocated_encoding(s); | ||
59 | return; | ||
60 | } | ||
61 | - is_signed = true; | ||
62 | + mop |= MO_SIGN; | ||
63 | break; | ||
64 | case 3: /* LDAPURS* 32-bit variant */ | ||
65 | if (size > 1) { | ||
66 | unallocated_encoding(s); | ||
67 | return; | ||
68 | } | ||
69 | - is_signed = true; | ||
70 | + mop |= MO_SIGN; | ||
71 | extend = true; /* zero-extend 32->64 after signed load */ | ||
72 | break; | ||
73 | default: | ||
74 | g_assert_not_reached(); | ||
75 | } | ||
76 | |||
77 | - iss_sf = disas_ldst_compute_iss_sf(size, is_signed, opc); | ||
78 | + iss_sf = disas_ldst_compute_iss_sf(size, (mop & MO_SIGN) != 0, opc); | ||
79 | |||
80 | if (rn == 31) { | ||
81 | gen_check_sp_alignment(s); | ||
82 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | ||
83 | if (is_store) { | ||
84 | /* Store-Release semantics */ | ||
85 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | ||
86 | - do_gpr_st(s, cpu_reg(s, rt), clean_addr, size, true, rt, iss_sf, true); | ||
87 | + do_gpr_st(s, cpu_reg(s, rt), clean_addr, mop, true, rt, iss_sf, true); | ||
88 | } else { | 25 | } else { |
89 | /* | 26 | imm = asimd_imm_const(abcdefgh, cmode, is_neg); |
90 | * Load-AcquirePC semantics; we implement as the slightly more | ||
91 | * restrictive Load-Acquire. | ||
92 | */ | ||
93 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size + is_signed * MO_SIGN, | ||
94 | + do_gpr_ld(s, cpu_reg(s, rt), clean_addr, mop, | ||
95 | extend, true, rt, iss_sf, true); | ||
96 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
97 | } | 27 | } |
98 | -- | 28 | -- |
99 | 2.20.1 | 29 | 2.20.1 |
100 | 30 | ||
101 | 31 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210419202257.161730-25-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-7-peter.maydell@linaro.org | ||
7 | --- | 9 | --- |
8 | target/arm/translate-neon.c.inc | 48 ++++++++++++++++++++++++++++----- | 10 | target/arm/helper-mve.h | 4 +++ |
9 | 1 file changed, 42 insertions(+), 6 deletions(-) | 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(+) | ||
10 | 15 | ||
11 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
12 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-neon.c.inc | 18 | --- a/target/arm/helper-mve.h |
14 | +++ b/target/arm/translate-neon.c.inc | 19 | +++ b/target/arm/helper-mve.h |
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | 20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) |
16 | int nregs = a->n + 1; | 21 | DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) |
17 | int vd = a->vd; | 22 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
18 | TCGv_i32 addr, tmp; | 23 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
19 | + MemOp mop; | ||
20 | |||
21 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
22 | return false; | ||
23 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | ||
24 | return true; | ||
25 | } | ||
26 | |||
27 | + /* Pick up SCTLR settings */ | ||
28 | + mop = finalize_memop(s, a->size); | ||
29 | + | 24 | + |
30 | + if (a->align) { | 25 | +DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) |
31 | + MemOp align_op; | 26 | +DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) |
27 | +DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/mve.decode | ||
31 | +++ b/target/arm/mve.decode | ||
32 | @@ -XXX,XX +XXX,XX @@ | ||
33 | # VQDMULL has size in bit 28: 0 for 16 bit, 1 for 32 bit | ||
34 | %size_28 28:1 !function=plus_1 | ||
35 | |||
36 | +# 1imm format immediate | ||
37 | +%imm_28_16_0 28:1 16:3 0:4 | ||
32 | + | 38 | + |
33 | + switch (nregs) { | 39 | &vldr_vstr rn qd imm p a w size l u |
34 | + case 1: | 40 | &1op qd qm size |
35 | + /* For VLD1, use natural alignment. */ | 41 | &2op qd qm qn size |
36 | + align_op = MO_ALIGN; | 42 | &2scalar qd qn rm size |
37 | + break; | 43 | +&1imm qd imm cmode op |
38 | + case 2: | 44 | |
39 | + /* For VLD2, use double alignment. */ | 45 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 |
40 | + align_op = pow2_align(a->size + 1); | 46 | # Note that both Rn and Qd are 3 bits only (no D bit) |
41 | + break; | 47 | @@ -XXX,XX +XXX,XX @@ |
42 | + case 4: | 48 | @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 |
43 | + if (a->size == MO_32) { | 49 | @2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \ |
44 | + /* | 50 | size=%size_28 |
45 | + * For VLD4.32, align = 1 is double alignment, align = 2 is | 51 | +@1imm .... .... .... .... .... cmode:4 .. op:1 . .... &1imm qd=%qd imm=%imm_28_16_0 |
46 | + * quad alignment; align = 3 is rejected above. | 52 | |
47 | + */ | 53 | # The _rev suffix indicates that Vn and Vm are reversed. This is |
48 | + align_op = pow2_align(a->size + a->align); | 54 | # the case for shifts. In the Arm ARM these insns are documented |
49 | + } else { | 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 |
50 | + /* For VLD4.8 and VLD.16, we want quad alignment. */ | 56 | # Predicate operations |
51 | + align_op = pow2_align(a->size + 2); | 57 | %mask_22_13 22:1 13:3 |
52 | + } | 58 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 |
53 | + break; | ||
54 | + default: | ||
55 | + /* For VLD3, the alignment field is zero and rejected above. */ | ||
56 | + g_assert_not_reached(); | ||
57 | + } | ||
58 | + | 59 | + |
59 | + mop = (mop & ~MO_AMASK) | align_op; | 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); \ | ||
60 | + } | 93 | + } |
61 | + | 94 | + |
62 | tmp = tcg_temp_new_i32(); | 95 | +#define DO_MOVI(N, I) (I) |
63 | addr = tcg_temp_new_i32(); | 96 | +#define DO_ANDI(N, I) ((N) & (I)) |
64 | load_reg_var(s, addr, a->rn); | 97 | +#define DO_ORRI(N, I) ((N) | (I)) |
65 | - /* | ||
66 | - * TODO: if we implemented alignment exceptions, we should check | ||
67 | - * addr against the alignment encoded in a->align here. | ||
68 | - */ | ||
69 | + | 98 | + |
70 | for (reg = 0; reg < nregs; reg++) { | 99 | +DO_1OP_IMM(vmovi, DO_MOVI) |
71 | if (a->l) { | 100 | +DO_1OP_IMM(vandi, DO_ANDI) |
72 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), a->size); | 101 | +DO_1OP_IMM(vorri, DO_ORRI) |
73 | + gen_aa32_ld_internal_i32(s, tmp, addr, get_mem_index(s), mop); | ||
74 | neon_store_element(vd, a->reg_idx, a->size, tmp); | ||
75 | } else { /* Store */ | ||
76 | neon_load_element(tmp, vd, a->reg_idx, a->size); | ||
77 | - gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), a->size); | ||
78 | + gen_aa32_st_internal_i32(s, tmp, addr, get_mem_index(s), mop); | ||
79 | } | ||
80 | vd += a->stride; | ||
81 | tcg_gen_addi_i32(addr, addr, 1 << a->size); | ||
82 | + | 102 | + |
83 | + /* Subsequent memory operations inherit alignment */ | 103 | #define DO_2OP(OP, ESIZE, TYPE, FN) \ |
84 | + mop &= ~MO_AMASK; | 104 | void HELPER(glue(mve_, OP))(CPUARMState *env, \ |
85 | } | 105 | void *vd, void *vn, void *vm) \ |
86 | tcg_temp_free_i32(addr); | 106 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
87 | tcg_temp_free_i32(tmp); | 107 | index XXXXXXX..XXXXXXX 100644 |
108 | --- a/target/arm/translate-mve.c | ||
109 | +++ b/target/arm/translate-mve.c | ||
110 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
111 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
112 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
113 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
114 | +typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
115 | |||
116 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
117 | static inline long mve_qreg_offset(unsigned reg) | ||
118 | @@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | ||
119 | mve_update_eci(s); | ||
120 | return true; | ||
121 | } | ||
122 | + | ||
123 | +static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) | ||
124 | +{ | ||
125 | + TCGv_ptr qd; | ||
126 | + uint64_t imm; | ||
127 | + | ||
128 | + if (!dc_isar_feature(aa32_mve, s) || | ||
129 | + !mve_check_qreg_bank(s, a->qd) || | ||
130 | + !fn) { | ||
131 | + return false; | ||
132 | + } | ||
133 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
134 | + return true; | ||
135 | + } | ||
136 | + | ||
137 | + imm = asimd_imm_const(a->imm, a->cmode, a->op); | ||
138 | + | ||
139 | + qd = mve_qreg_ptr(a->qd); | ||
140 | + fn(cpu_env, qd, tcg_constant_i64(imm)); | ||
141 | + tcg_temp_free_ptr(qd); | ||
142 | + mve_update_eci(s); | ||
143 | + return true; | ||
144 | +} | ||
145 | + | ||
146 | +static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a) | ||
147 | +{ | ||
148 | + /* Handle decode of cmode/op here between VORR/VBIC/VMOV */ | ||
149 | + MVEGenOneOpImmFn *fn; | ||
150 | + | ||
151 | + if ((a->cmode & 1) && a->cmode < 12) { | ||
152 | + if (a->op) { | ||
153 | + /* | ||
154 | + * For op=1, the immediate will be inverted by asimd_imm_const(), | ||
155 | + * so the VBIC becomes a logical AND operation. | ||
156 | + */ | ||
157 | + fn = gen_helper_mve_vandi; | ||
158 | + } else { | ||
159 | + fn = gen_helper_mve_vorri; | ||
160 | + } | ||
161 | + } else { | ||
162 | + /* There is one unallocated cmode/op combination in this space */ | ||
163 | + if (a->cmode == 15 && a->op == 1) { | ||
164 | + return false; | ||
165 | + } | ||
166 | + /* asimd_imm_const() sorts out VMVNI vs VMOVI for us */ | ||
167 | + fn = gen_helper_mve_vmovi; | ||
168 | + } | ||
169 | + return do_1imm(s, a, fn); | ||
170 | +} | ||
88 | -- | 171 | -- |
89 | 2.20.1 | 172 | 2.20.1 |
90 | 173 | ||
91 | 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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | The size-and-immediate encoding here is the same as Neon, and we |
5 | Message-id: 20210419202257.161730-29-richard.henderson@linaro.org | 5 | handle it the same way neon-dp.decode does. |
6 | |||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210628135835.6690-8-peter.maydell@linaro.org | ||
7 | --- | 10 | --- |
8 | target/arm/translate-a64.c | 20 ++++++++++---------- | 11 | target/arm/helper-mve.h | 16 +++++++++++ |
9 | 1 file changed, 10 insertions(+), 10 deletions(-) | 12 | target/arm/mve.decode | 23 +++++++++++++++ |
10 | 13 | target/arm/mve_helper.c | 57 ++++++++++++++++++++++++++++++++++++++ | |
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 14 | target/arm/translate-mve.c | 51 ++++++++++++++++++++++++++++++++++ |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | 4 files changed, 147 insertions(+) |
13 | --- a/target/arm/translate-a64.c | 16 | |
14 | +++ b/target/arm/translate-a64.c | 17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
15 | @@ -XXX,XX +XXX,XX @@ static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src, | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | 19 | --- a/target/arm/helper-mve.h | |
17 | /* Store from vector register to memory */ | 20 | +++ b/target/arm/helper-mve.h |
18 | static void do_vec_st(DisasContext *s, int srcidx, int element, | 21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
19 | - TCGv_i64 tcg_addr, int size, MemOp endian) | 22 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) |
20 | + TCGv_i64 tcg_addr, MemOp mop) | 23 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) |
21 | { | 24 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) |
22 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | 25 | + |
23 | 26 | +DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
24 | - read_vec_element(s, tcg_tmp, srcidx, element, size); | 27 | +DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | - tcg_gen_qemu_st_i64(tcg_tmp, tcg_addr, get_mem_index(s), endian | size); | 28 | +DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
26 | + read_vec_element(s, tcg_tmp, srcidx, element, mop & MO_SIZE); | 29 | + |
27 | + tcg_gen_qemu_st_i64(tcg_tmp, tcg_addr, get_mem_index(s), mop); | 30 | +DEF_HELPER_FLAGS_4(mve_vqshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
28 | 31 | +DEF_HELPER_FLAGS_4(mve_vqshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
29 | tcg_temp_free_i64(tcg_tmp); | 32 | +DEF_HELPER_FLAGS_4(mve_vqshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
33 | + | ||
34 | +DEF_HELPER_FLAGS_4(mve_vqshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vqshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | + | ||
38 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/mve.decode | ||
44 | +++ b/target/arm/mve.decode | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | &2op qd qm qn size | ||
47 | &2scalar qd qn rm size | ||
48 | &1imm qd imm cmode op | ||
49 | +&2shift qd qm shift size | ||
50 | |||
51 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
52 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
53 | @@ -XXX,XX +XXX,XX @@ | ||
54 | @2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | ||
55 | @2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | ||
56 | |||
57 | +@2_shl_b .... .... .. 001 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0 | ||
58 | +@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | ||
59 | +@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | ||
60 | + | ||
61 | # Vector loads and stores | ||
62 | |||
63 | # Widening loads and narrowing stores: | ||
64 | @@ -XXX,XX +XXX,XX @@ VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
65 | # So we have a single decode line and check the cmode/op in the | ||
66 | # trans function. | ||
67 | Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm | ||
68 | + | ||
69 | +# Shifts by immediate | ||
70 | + | ||
71 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | ||
72 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | ||
73 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | ||
74 | + | ||
75 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b | ||
76 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h | ||
77 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
78 | + | ||
79 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b | ||
80 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h | ||
81 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
82 | + | ||
83 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b | ||
84 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h | ||
85 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w | ||
86 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/target/arm/mve_helper.c | ||
89 | +++ b/target/arm/mve_helper.c | ||
90 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W) | ||
91 | WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, true, satp) | ||
92 | #define DO_UQRSHL_OP(N, M, satp) \ | ||
93 | WRAP_QRSHL_HELPER(do_uqrshl_bhs, N, M, true, satp) | ||
94 | +#define DO_SUQSHL_OP(N, M, satp) \ | ||
95 | + WRAP_QRSHL_HELPER(do_suqrshl_bhs, N, M, false, satp) | ||
96 | |||
97 | DO_2OP_SAT_S(vqshls, DO_SQSHL_OP) | ||
98 | DO_2OP_SAT_U(vqshlu, DO_UQSHL_OP) | ||
99 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvsw, 4, uint32_t) | ||
100 | DO_VADDV(vaddvub, 1, uint8_t) | ||
101 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
102 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
103 | + | ||
104 | +/* Shifts by immediate */ | ||
105 | +#define DO_2SHIFT(OP, ESIZE, TYPE, FN) \ | ||
106 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
107 | + void *vm, uint32_t shift) \ | ||
108 | + { \ | ||
109 | + TYPE *d = vd, *m = vm; \ | ||
110 | + uint16_t mask = mve_element_mask(env); \ | ||
111 | + unsigned e; \ | ||
112 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
113 | + mergemask(&d[H##ESIZE(e)], \ | ||
114 | + FN(m[H##ESIZE(e)], shift), mask); \ | ||
115 | + } \ | ||
116 | + mve_advance_vpt(env); \ | ||
117 | + } | ||
118 | + | ||
119 | +#define DO_2SHIFT_SAT(OP, ESIZE, TYPE, FN) \ | ||
120 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
121 | + void *vm, uint32_t shift) \ | ||
122 | + { \ | ||
123 | + TYPE *d = vd, *m = vm; \ | ||
124 | + uint16_t mask = mve_element_mask(env); \ | ||
125 | + unsigned e; \ | ||
126 | + bool qc = false; \ | ||
127 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
128 | + bool sat = false; \ | ||
129 | + mergemask(&d[H##ESIZE(e)], \ | ||
130 | + FN(m[H##ESIZE(e)], shift, &sat), mask); \ | ||
131 | + qc |= sat & mask & 1; \ | ||
132 | + } \ | ||
133 | + if (qc) { \ | ||
134 | + env->vfp.qc[0] = qc; \ | ||
135 | + } \ | ||
136 | + mve_advance_vpt(env); \ | ||
137 | + } | ||
138 | + | ||
139 | +/* provide unsigned 2-op shift helpers for all sizes */ | ||
140 | +#define DO_2SHIFT_U(OP, FN) \ | ||
141 | + DO_2SHIFT(OP##b, 1, uint8_t, FN) \ | ||
142 | + DO_2SHIFT(OP##h, 2, uint16_t, FN) \ | ||
143 | + DO_2SHIFT(OP##w, 4, uint32_t, FN) | ||
144 | + | ||
145 | +#define DO_2SHIFT_SAT_U(OP, FN) \ | ||
146 | + DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \ | ||
147 | + DO_2SHIFT_SAT(OP##h, 2, uint16_t, FN) \ | ||
148 | + DO_2SHIFT_SAT(OP##w, 4, uint32_t, FN) | ||
149 | +#define DO_2SHIFT_SAT_S(OP, FN) \ | ||
150 | + DO_2SHIFT_SAT(OP##b, 1, int8_t, FN) \ | ||
151 | + DO_2SHIFT_SAT(OP##h, 2, int16_t, FN) \ | ||
152 | + DO_2SHIFT_SAT(OP##w, 4, int32_t, FN) | ||
153 | + | ||
154 | +DO_2SHIFT_U(vshli_u, DO_VSHLU) | ||
155 | +DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP) | ||
156 | +DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
157 | +DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
158 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
159 | index XXXXXXX..XXXXXXX 100644 | ||
160 | --- a/target/arm/translate-mve.c | ||
161 | +++ b/target/arm/translate-mve.c | ||
162 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
163 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
164 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
165 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
166 | +typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
167 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
168 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
169 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
170 | @@ -XXX,XX +XXX,XX @@ static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a) | ||
171 | } | ||
172 | return do_1imm(s, a, fn); | ||
30 | } | 173 | } |
31 | 174 | + | |
32 | /* Load from memory to vector register */ | 175 | +static bool do_2shift(DisasContext *s, arg_2shift *a, MVEGenTwoOpShiftFn fn, |
33 | static void do_vec_ld(DisasContext *s, int destidx, int element, | 176 | + bool negateshift) |
34 | - TCGv_i64 tcg_addr, int size, MemOp endian) | 177 | +{ |
35 | + TCGv_i64 tcg_addr, MemOp mop) | 178 | + TCGv_ptr qd, qm; |
36 | { | 179 | + int shift = a->shift; |
37 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | 180 | + |
38 | 181 | + if (!dc_isar_feature(aa32_mve, s) || | |
39 | - tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, get_mem_index(s), endian | size); | 182 | + !mve_check_qreg_bank(s, a->qd | a->qm) || |
40 | - write_vec_element(s, tcg_tmp, destidx, element, size); | 183 | + !fn) { |
41 | + tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, get_mem_index(s), mop); | 184 | + return false; |
42 | + write_vec_element(s, tcg_tmp, destidx, element, mop & MO_SIZE); | 185 | + } |
43 | 186 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | |
44 | tcg_temp_free_i64(tcg_tmp); | 187 | + return true; |
45 | } | 188 | + } |
46 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 189 | + |
47 | for (xs = 0; xs < selem; xs++) { | 190 | + /* |
48 | int tt = (rt + r + xs) % 32; | 191 | + * When we handle a right shift insn using a left-shift helper |
49 | if (is_store) { | 192 | + * which permits a negative shift count to indicate a right-shift, |
50 | - do_vec_st(s, tt, e, clean_addr, size, endian); | 193 | + * we must negate the shift count. |
51 | + do_vec_st(s, tt, e, clean_addr, size | endian); | 194 | + */ |
52 | } else { | 195 | + if (negateshift) { |
53 | - do_vec_ld(s, tt, e, clean_addr, size, endian); | 196 | + shift = -shift; |
54 | + do_vec_ld(s, tt, e, clean_addr, size | endian); | 197 | + } |
55 | } | 198 | + |
56 | tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); | 199 | + qd = mve_qreg_ptr(a->qd); |
57 | } | 200 | + qm = mve_qreg_ptr(a->qm); |
58 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 201 | + fn(cpu_env, qd, qm, tcg_constant_i32(shift)); |
59 | } else { | 202 | + tcg_temp_free_ptr(qd); |
60 | /* Load/store one element per register */ | 203 | + tcg_temp_free_ptr(qm); |
61 | if (is_load) { | 204 | + mve_update_eci(s); |
62 | - do_vec_ld(s, rt, index, clean_addr, scale, s->be_data); | 205 | + return true; |
63 | + do_vec_ld(s, rt, index, clean_addr, scale | s->be_data); | 206 | +} |
64 | } else { | 207 | + |
65 | - do_vec_st(s, rt, index, clean_addr, scale, s->be_data); | 208 | +#define DO_2SHIFT(INSN, FN, NEGATESHIFT) \ |
66 | + do_vec_st(s, rt, index, clean_addr, scale | s->be_data); | 209 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ |
67 | } | 210 | + { \ |
68 | } | 211 | + static MVEGenTwoOpShiftFn * const fns[] = { \ |
69 | tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); | 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) | ||
70 | -- | 224 | -- |
71 | 2.20.1 | 225 | 2.20.1 |
72 | 226 | ||
73 | 227 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE vector shift right by immediate insns VSHRI and |
---|---|---|---|
2 | VRSHRI. As with Neon, we implement these by using helper functions | ||
3 | which perform left shifts but allow negative shift counts to indicate | ||
4 | right shifts. | ||
2 | 5 | ||
3 | Adjust the interface to match what has been done to the | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | TCGv_i32 load/store functions. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210628135835.6690-9-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/helper-mve.h | 12 ++++++++++++ | ||
11 | target/arm/translate.h | 20 ++++++++++++++++++++ | ||
12 | target/arm/mve.decode | 28 ++++++++++++++++++++++++++++ | ||
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(-) | ||
5 | 17 | ||
6 | This is less obvious, because at present the only user of | 18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
7 | these functions, trans_VLDST_multiple, also wants to manipulate | ||
8 | the endianness to speed up loading multiple bytes. Thus we | ||
9 | retain an "internal" interface which is identical to the | ||
10 | current gen_aa32_{ld,st}_i64 interface. | ||
11 | |||
12 | The "new" interface will gain users as we remove the legacy | ||
13 | interfaces, gen_aa32_ld64 and gen_aa32_st64. | ||
14 | |||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20210419202257.161730-15-richard.henderson@linaro.org | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | target/arm/translate.c | 78 +++++++++++++++++++-------------- | ||
21 | target/arm/translate-neon.c.inc | 6 ++- | ||
22 | 2 files changed, 49 insertions(+), 35 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/translate.c | 20 | --- a/target/arm/helper-mve.h |
27 | +++ b/target/arm/translate.c | 21 | +++ b/target/arm/helper-mve.h |
28 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_internal_i32(DisasContext *s, TCGv_i32 val, | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) |
29 | tcg_temp_free(addr); | 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) | ||
45 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/translate.h | ||
48 | +++ b/target/arm/translate.h | ||
49 | @@ -XXX,XX +XXX,XX @@ static inline int times_2_plus_1(DisasContext *s, int x) | ||
50 | return x * 2 + 1; | ||
30 | } | 51 | } |
31 | 52 | ||
32 | +static void gen_aa32_ld_internal_i64(DisasContext *s, TCGv_i64 val, | 53 | +static inline int rsub_64(DisasContext *s, int x) |
33 | + TCGv_i32 a32, int index, MemOp opc) | ||
34 | +{ | 54 | +{ |
35 | + TCGv addr = gen_aa32_addr(s, a32, opc); | 55 | + return 64 - x; |
36 | + | ||
37 | + tcg_gen_qemu_ld_i64(val, addr, index, opc); | ||
38 | + | ||
39 | + /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
40 | + if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | ||
41 | + tcg_gen_rotri_i64(val, val, 32); | ||
42 | + } | ||
43 | + tcg_temp_free(addr); | ||
44 | +} | 56 | +} |
45 | + | 57 | + |
46 | +static void gen_aa32_st_internal_i64(DisasContext *s, TCGv_i64 val, | 58 | +static inline int rsub_32(DisasContext *s, int x) |
47 | + TCGv_i32 a32, int index, MemOp opc) | ||
48 | +{ | 59 | +{ |
49 | + TCGv addr = gen_aa32_addr(s, a32, opc); | 60 | + return 32 - x; |
50 | + | ||
51 | + /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
52 | + if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | ||
53 | + TCGv_i64 tmp = tcg_temp_new_i64(); | ||
54 | + tcg_gen_rotri_i64(tmp, val, 32); | ||
55 | + tcg_gen_qemu_st_i64(tmp, addr, index, opc); | ||
56 | + tcg_temp_free_i64(tmp); | ||
57 | + } else { | ||
58 | + tcg_gen_qemu_st_i64(val, addr, index, opc); | ||
59 | + } | ||
60 | + tcg_temp_free(addr); | ||
61 | +} | 61 | +} |
62 | + | 62 | + |
63 | static void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 63 | +static inline int rsub_16(DisasContext *s, int x) |
64 | int index, MemOp opc) | ||
65 | { | ||
66 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
67 | gen_aa32_st_internal_i32(s, val, a32, index, finalize_memop(s, opc)); | ||
68 | } | ||
69 | |||
70 | +static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
71 | + int index, MemOp opc) | ||
72 | +{ | 64 | +{ |
73 | + gen_aa32_ld_internal_i64(s, val, a32, index, finalize_memop(s, opc)); | 65 | + return 16 - x; |
74 | +} | 66 | +} |
75 | + | 67 | + |
76 | +static void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | 68 | +static inline int rsub_8(DisasContext *s, int x) |
77 | + int index, MemOp opc) | ||
78 | +{ | 69 | +{ |
79 | + gen_aa32_st_internal_i64(s, val, a32, index, finalize_memop(s, opc)); | 70 | + return 8 - x; |
80 | +} | 71 | +} |
81 | + | 72 | + |
82 | #define DO_GEN_LD(SUFF, OPC) \ | 73 | static inline int arm_dc_feature(DisasContext *dc, int feature) |
83 | static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val, \ | 74 | { |
84 | TCGv_i32 a32, int index) \ | 75 | return (dc->features & (1ULL << feature)) != 0; |
85 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 76 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
86 | gen_aa32_st_i32(s, val, a32, index, OPC); \ | 77 | index XXXXXXX..XXXXXXX 100644 |
87 | } | 78 | --- a/target/arm/mve.decode |
88 | 79 | +++ b/target/arm/mve.decode | |
89 | -static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | 80 | @@ -XXX,XX +XXX,XX @@ |
90 | - int index, MemOp opc) | 81 | @2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 |
82 | @2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | ||
83 | |||
84 | +# Right shifts are encoded as N - shift, where N is the element size in bits. | ||
85 | +%rshift_i5 16:5 !function=rsub_32 | ||
86 | +%rshift_i4 16:4 !function=rsub_16 | ||
87 | +%rshift_i3 16:3 !function=rsub_8 | ||
88 | + | ||
89 | +@2_shr_b .... .... .. 001 ... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
90 | + size=0 shift=%rshift_i3 | ||
91 | +@2_shr_h .... .... .. 01 .... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
92 | + size=1 shift=%rshift_i4 | ||
93 | +@2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
94 | + size=2 shift=%rshift_i5 | ||
95 | + | ||
96 | # Vector loads and stores | ||
97 | |||
98 | # Widening loads and narrowing stores: | ||
99 | @@ -XXX,XX +XXX,XX @@ VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
100 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b | ||
101 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h | ||
102 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w | ||
103 | + | ||
104 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b | ||
105 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h | ||
106 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w | ||
107 | + | ||
108 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b | ||
109 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h | ||
110 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w | ||
111 | + | ||
112 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
113 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
114 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
115 | + | ||
116 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
117 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
118 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
119 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/target/arm/mve_helper.c | ||
122 | +++ b/target/arm/mve_helper.c | ||
123 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t) | ||
124 | DO_2SHIFT(OP##b, 1, uint8_t, FN) \ | ||
125 | DO_2SHIFT(OP##h, 2, uint16_t, FN) \ | ||
126 | DO_2SHIFT(OP##w, 4, uint32_t, FN) | ||
127 | +#define DO_2SHIFT_S(OP, FN) \ | ||
128 | + DO_2SHIFT(OP##b, 1, int8_t, FN) \ | ||
129 | + DO_2SHIFT(OP##h, 2, int16_t, FN) \ | ||
130 | + DO_2SHIFT(OP##w, 4, int32_t, FN) | ||
131 | |||
132 | #define DO_2SHIFT_SAT_U(OP, FN) \ | ||
133 | DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \ | ||
134 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t) | ||
135 | DO_2SHIFT_SAT(OP##w, 4, int32_t, FN) | ||
136 | |||
137 | DO_2SHIFT_U(vshli_u, DO_VSHLU) | ||
138 | +DO_2SHIFT_S(vshli_s, DO_VSHLS) | ||
139 | DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP) | ||
140 | DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
141 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
142 | +DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
143 | +DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
144 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
145 | index XXXXXXX..XXXXXXX 100644 | ||
146 | --- a/target/arm/translate-mve.c | ||
147 | +++ b/target/arm/translate-mve.c | ||
148 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHLI, vshli_u, false) | ||
149 | DO_2SHIFT(VQSHLI_S, vqshli_s, false) | ||
150 | DO_2SHIFT(VQSHLI_U, vqshli_u, false) | ||
151 | DO_2SHIFT(VQSHLUI, vqshlui_s, false) | ||
152 | +/* These right shifts use a left-shift helper with negated shift count */ | ||
153 | +DO_2SHIFT(VSHRI_S, vshli_s, true) | ||
154 | +DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
155 | +DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
156 | +DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
157 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/target/arm/translate-neon.c | ||
160 | +++ b/target/arm/translate-neon.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static inline int plus1(DisasContext *s, int x) | ||
162 | return x + 1; | ||
163 | } | ||
164 | |||
165 | -static inline int rsub_64(DisasContext *s, int x) | ||
91 | -{ | 166 | -{ |
92 | - TCGv addr = gen_aa32_addr(s, a32, opc); | 167 | - return 64 - x; |
93 | - tcg_gen_qemu_ld_i64(val, addr, index, opc); | ||
94 | - | ||
95 | - /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
96 | - if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | ||
97 | - tcg_gen_rotri_i64(val, val, 32); | ||
98 | - } | ||
99 | - | ||
100 | - tcg_temp_free(addr); | ||
101 | -} | 168 | -} |
102 | - | 169 | - |
103 | static inline void gen_aa32_ld64(DisasContext *s, TCGv_i64 val, | 170 | -static inline int rsub_32(DisasContext *s, int x) |
104 | TCGv_i32 a32, int index) | 171 | -{ |
105 | { | 172 | - return 32 - x; |
106 | - gen_aa32_ld_i64(s, val, a32, index, MO_Q | s->be_data); | 173 | -} |
174 | -static inline int rsub_16(DisasContext *s, int x) | ||
175 | -{ | ||
176 | - return 16 - x; | ||
177 | -} | ||
178 | -static inline int rsub_8(DisasContext *s, int x) | ||
179 | -{ | ||
180 | - return 8 - x; | ||
107 | -} | 181 | -} |
108 | - | 182 | - |
109 | -static void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | 183 | static inline int neon_3same_fp_size(DisasContext *s, int x) |
110 | - int index, MemOp opc) | ||
111 | -{ | ||
112 | - TCGv addr = gen_aa32_addr(s, a32, opc); | ||
113 | - | ||
114 | - /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
115 | - if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | ||
116 | - TCGv_i64 tmp = tcg_temp_new_i64(); | ||
117 | - tcg_gen_rotri_i64(tmp, val, 32); | ||
118 | - tcg_gen_qemu_st_i64(tmp, addr, index, opc); | ||
119 | - tcg_temp_free_i64(tmp); | ||
120 | - } else { | ||
121 | - tcg_gen_qemu_st_i64(val, addr, index, opc); | ||
122 | - } | ||
123 | - tcg_temp_free(addr); | ||
124 | + gen_aa32_ld_i64(s, val, a32, index, MO_Q); | ||
125 | } | ||
126 | |||
127 | static inline void gen_aa32_st64(DisasContext *s, TCGv_i64 val, | ||
128 | TCGv_i32 a32, int index) | ||
129 | { | 184 | { |
130 | - gen_aa32_st_i64(s, val, a32, index, MO_Q | s->be_data); | 185 | /* Convert 0==fp32, 1==fp16 into a MO_* value */ |
131 | + gen_aa32_st_i64(s, val, a32, index, MO_Q); | ||
132 | } | ||
133 | |||
134 | DO_GEN_LD(8u, MO_UB) | ||
135 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | ||
136 | index XXXXXXX..XXXXXXX 100644 | ||
137 | --- a/target/arm/translate-neon.c.inc | ||
138 | +++ b/target/arm/translate-neon.c.inc | ||
139 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | ||
140 | int tt = a->vd + reg + spacing * xs; | ||
141 | |||
142 | if (a->l) { | ||
143 | - gen_aa32_ld_i64(s, tmp64, addr, mmu_idx, endian | size); | ||
144 | + gen_aa32_ld_internal_i64(s, tmp64, addr, mmu_idx, | ||
145 | + endian | size); | ||
146 | neon_store_element64(tt, n, size, tmp64); | ||
147 | } else { | ||
148 | neon_load_element64(tmp64, tt, n, size); | ||
149 | - gen_aa32_st_i64(s, tmp64, addr, mmu_idx, endian | size); | ||
150 | + gen_aa32_st_internal_i64(s, tmp64, addr, mmu_idx, | ||
151 | + endian | size); | ||
152 | } | ||
153 | tcg_gen_add_i32(addr, addr, tmp); | ||
154 | } | ||
155 | -- | 186 | -- |
156 | 2.20.1 | 187 | 2.20.1 |
157 | 188 | ||
158 | 189 | diff view generated by jsdifflib |
1 | From: Cornelia Huck <cohuck@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 | Add 6.1 machine types for arm/i440fx/q35/s390x/spapr. | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-10-peter.maydell@linaro.org | ||
9 | --- | ||
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(-) | ||
4 | 15 | ||
5 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
6 | Acked-by: Greg Kurz <groug@kaod.org> | ||
7 | Message-id: 20210331111900.118274-1-cohuck@redhat.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/boards.h | 3 +++ | ||
12 | include/hw/i386/pc.h | 3 +++ | ||
13 | hw/arm/virt.c | 7 ++++++- | ||
14 | hw/core/machine.c | 3 +++ | ||
15 | hw/i386/pc.c | 3 +++ | ||
16 | hw/i386/pc_piix.c | 14 +++++++++++++- | ||
17 | hw/i386/pc_q35.c | 13 ++++++++++++- | ||
18 | hw/ppc/spapr.c | 17 ++++++++++++++--- | ||
19 | hw/s390x/s390-virtio-ccw.c | 14 +++++++++++++- | ||
20 | 9 files changed, 70 insertions(+), 7 deletions(-) | ||
21 | |||
22 | diff --git a/include/hw/boards.h b/include/hw/boards.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/include/hw/boards.h | 18 | --- a/target/arm/helper-mve.h |
25 | +++ b/include/hw/boards.h | 19 | +++ b/target/arm/helper-mve.h |
26 | @@ -XXX,XX +XXX,XX @@ struct MachineState { | 20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
27 | } \ | 21 | DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
28 | type_init(machine_initfn##_register_types) | 22 | DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
29 | 23 | DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
30 | +extern GlobalProperty hw_compat_6_0[]; | ||
31 | +extern const size_t hw_compat_6_0_len; | ||
32 | + | 24 | + |
33 | extern GlobalProperty hw_compat_5_2[]; | 25 | +DEF_HELPER_FLAGS_4(mve_vshllbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
34 | extern const size_t hw_compat_5_2_len; | 26 | +DEF_HELPER_FLAGS_4(mve_vshllbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
35 | 27 | +DEF_HELPER_FLAGS_4(mve_vshllbub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
36 | diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h | 28 | +DEF_HELPER_FLAGS_4(mve_vshllbuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
29 | +DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
37 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/include/hw/i386/pc.h | 35 | --- a/target/arm/mve.decode |
39 | +++ b/include/hw/i386/pc.h | 36 | +++ b/target/arm/mve.decode |
40 | @@ -XXX,XX +XXX,XX @@ bool pc_system_ovmf_table_find(const char *entry, uint8_t **data, | 37 | @@ -XXX,XX +XXX,XX @@ |
41 | void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, | 38 | @2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 |
42 | const CPUArchIdList *apic_ids, GArray *entry); | 39 | @2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 |
43 | 40 | ||
44 | +extern GlobalProperty pc_compat_6_0[]; | 41 | +@2_shll_b .... .... ... 01 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0 |
45 | +extern const size_t pc_compat_6_0_len; | 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 | ||
46 | + | 48 | + |
47 | extern GlobalProperty pc_compat_5_2[]; | 49 | # Right shifts are encoded as N - shift, where N is the element size in bits. |
48 | extern const size_t pc_compat_5_2_len; | 50 | %rshift_i5 16:5 !function=rsub_32 |
49 | 51 | %rshift_i4 16:4 !function=rsub_16 | |
50 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 52 | @@ -XXX,XX +XXX,XX @@ VADD 1110 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op |
51 | index XXXXXXX..XXXXXXX 100644 | 53 | VSUB 1111 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op |
52 | --- a/hw/arm/virt.c | 54 | VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op |
53 | +++ b/hw/arm/virt.c | 55 | |
54 | @@ -XXX,XX +XXX,XX @@ static void machvirt_machine_init(void) | 56 | -VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op |
55 | } | 57 | -VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op |
56 | type_init(machvirt_machine_init); | 58 | +# The VSHLL T2 encoding is not a @2op pattern, but is here because it |
57 | 59 | +# overlaps what would be size=0b11 VMULH/VRMULH | |
58 | +static void virt_machine_6_1_options(MachineClass *mc) | ||
59 | +{ | 60 | +{ |
60 | +} | 61 | + VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b |
61 | +DEFINE_VIRT_MACHINE_AS_LATEST(6, 1) | 62 | + VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h |
62 | + | 63 | |
63 | static void virt_machine_6_0_options(MachineClass *mc) | 64 | -VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op |
64 | { | 65 | -VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op |
65 | } | 66 | + VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op |
66 | -DEFINE_VIRT_MACHINE_AS_LATEST(6, 0) | ||
67 | +DEFINE_VIRT_MACHINE(6, 0) | ||
68 | |||
69 | static void virt_machine_5_2_options(MachineClass *mc) | ||
70 | { | ||
71 | diff --git a/hw/core/machine.c b/hw/core/machine.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/hw/core/machine.c | ||
74 | +++ b/hw/core/machine.c | ||
75 | @@ -XXX,XX +XXX,XX @@ | ||
76 | #include "hw/virtio/virtio.h" | ||
77 | #include "hw/virtio/virtio-pci.h" | ||
78 | |||
79 | +GlobalProperty hw_compat_6_0[] = {}; | ||
80 | +const size_t hw_compat_6_0_len = G_N_ELEMENTS(hw_compat_6_0); | ||
81 | + | ||
82 | GlobalProperty hw_compat_5_2[] = { | ||
83 | { "ICH9-LPC", "smm-compat", "on"}, | ||
84 | { "PIIX4_PM", "smm-compat", "on"}, | ||
85 | diff --git a/hw/i386/pc.c b/hw/i386/pc.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/hw/i386/pc.c | ||
88 | +++ b/hw/i386/pc.c | ||
89 | @@ -XXX,XX +XXX,XX @@ | ||
90 | #include "trace.h" | ||
91 | #include CONFIG_DEVICES | ||
92 | |||
93 | +GlobalProperty pc_compat_6_0[] = {}; | ||
94 | +const size_t pc_compat_6_0_len = G_N_ELEMENTS(pc_compat_6_0); | ||
95 | + | ||
96 | GlobalProperty pc_compat_5_2[] = { | ||
97 | { "ICH9-LPC", "x-smi-cpu-hotunplug", "off" }, | ||
98 | }; | ||
99 | diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/hw/i386/pc_piix.c | ||
102 | +++ b/hw/i386/pc_piix.c | ||
103 | @@ -XXX,XX +XXX,XX @@ static void pc_i440fx_machine_options(MachineClass *m) | ||
104 | machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE); | ||
105 | } | ||
106 | |||
107 | -static void pc_i440fx_6_0_machine_options(MachineClass *m) | ||
108 | +static void pc_i440fx_6_1_machine_options(MachineClass *m) | ||
109 | { | ||
110 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); | ||
111 | pc_i440fx_machine_options(m); | ||
112 | @@ -XXX,XX +XXX,XX @@ static void pc_i440fx_6_0_machine_options(MachineClass *m) | ||
113 | pcmc->default_cpu_version = 1; | ||
114 | } | ||
115 | |||
116 | +DEFINE_I440FX_MACHINE(v6_1, "pc-i440fx-6.1", NULL, | ||
117 | + pc_i440fx_6_1_machine_options); | ||
118 | + | ||
119 | +static void pc_i440fx_6_0_machine_options(MachineClass *m) | ||
120 | +{ | ||
121 | + pc_i440fx_6_1_machine_options(m); | ||
122 | + m->alias = NULL; | ||
123 | + m->is_default = false; | ||
124 | + compat_props_add(m->compat_props, hw_compat_6_0, hw_compat_6_0_len); | ||
125 | + compat_props_add(m->compat_props, pc_compat_6_0, pc_compat_6_0_len); | ||
126 | +} | 67 | +} |
127 | + | 68 | + |
128 | DEFINE_I440FX_MACHINE(v6_0, "pc-i440fx-6.0", NULL, | 69 | +{ |
129 | pc_i440fx_6_0_machine_options); | 70 | + VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b |
130 | 71 | + VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | |
131 | diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/hw/i386/pc_q35.c | ||
134 | +++ b/hw/i386/pc_q35.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static void pc_q35_machine_options(MachineClass *m) | ||
136 | m->max_cpus = 288; | ||
137 | } | ||
138 | |||
139 | -static void pc_q35_6_0_machine_options(MachineClass *m) | ||
140 | +static void pc_q35_6_1_machine_options(MachineClass *m) | ||
141 | { | ||
142 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); | ||
143 | pc_q35_machine_options(m); | ||
144 | @@ -XXX,XX +XXX,XX @@ static void pc_q35_6_0_machine_options(MachineClass *m) | ||
145 | pcmc->default_cpu_version = 1; | ||
146 | } | ||
147 | |||
148 | +DEFINE_Q35_MACHINE(v6_1, "pc-q35-6.1", NULL, | ||
149 | + pc_q35_6_1_machine_options); | ||
150 | + | 72 | + |
151 | +static void pc_q35_6_0_machine_options(MachineClass *m) | 73 | + VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op |
152 | +{ | ||
153 | + pc_q35_6_1_machine_options(m); | ||
154 | + m->alias = NULL; | ||
155 | + compat_props_add(m->compat_props, hw_compat_6_0, hw_compat_6_0_len); | ||
156 | + compat_props_add(m->compat_props, pc_compat_6_0, pc_compat_6_0_len); | ||
157 | +} | 74 | +} |
158 | + | 75 | + |
159 | DEFINE_Q35_MACHINE(v6_0, "pc-q35-6.0", NULL, | 76 | +{ |
160 | pc_q35_6_0_machine_options); | 77 | + VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b |
161 | 78 | + VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | |
162 | diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c | 79 | + |
80 | + VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
81 | +} | ||
82 | + | ||
83 | +{ | ||
84 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
85 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
86 | + | ||
87 | + VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
88 | +} | ||
89 | |||
90 | VMAX_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op | ||
91 | VMAX_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op | ||
92 | @@ -XXX,XX +XXX,XX @@ VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
93 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
94 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
95 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
96 | + | ||
97 | +# VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file | ||
98 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | ||
99 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | ||
100 | + | ||
101 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | ||
102 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | ||
103 | + | ||
104 | +VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
105 | +VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
106 | + | ||
107 | +VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
108 | +VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
109 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
163 | index XXXXXXX..XXXXXXX 100644 | 110 | index XXXXXXX..XXXXXXX 100644 |
164 | --- a/hw/ppc/spapr.c | 111 | --- a/target/arm/mve_helper.c |
165 | +++ b/hw/ppc/spapr.c | 112 | +++ b/target/arm/mve_helper.c |
166 | @@ -XXX,XX +XXX,XX @@ static void spapr_machine_latest_class_options(MachineClass *mc) | 113 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) |
167 | type_init(spapr_machine_register_##suffix) | 114 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) |
168 | 115 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | |
169 | /* | 116 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) |
170 | - * pseries-6.0 | ||
171 | + * pseries-6.1 | ||
172 | */ | ||
173 | -static void spapr_machine_6_0_class_options(MachineClass *mc) | ||
174 | +static void spapr_machine_6_1_class_options(MachineClass *mc) | ||
175 | { | ||
176 | /* Defaults for the latest behaviour inherited from the base class */ | ||
177 | } | ||
178 | |||
179 | -DEFINE_SPAPR_MACHINE(6_0, "6.0", true); | ||
180 | +DEFINE_SPAPR_MACHINE(6_1, "6.1", true); | ||
181 | + | 117 | + |
182 | +/* | 118 | +/* |
183 | + * pseries-6.0 | 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. | ||
184 | + */ | 124 | + */ |
185 | +static void spapr_machine_6_0_class_options(MachineClass *mc) | 125 | +#define DO_VSHLL(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE) \ |
186 | +{ | 126 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ |
187 | + spapr_machine_6_1_class_options(mc); | 127 | + void *vm, uint32_t shift) \ |
188 | + compat_props_add(mc->compat_props, hw_compat_6_0, hw_compat_6_0_len); | 128 | + { \ |
189 | +} | 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 | + } | ||
190 | + | 140 | + |
191 | +DEFINE_SPAPR_MACHINE(6_0, "6.0", false); | 141 | +#define DO_VSHLL_ALL(OP, TOP) \ |
192 | 142 | + DO_VSHLL(OP##sb, TOP, 1, int8_t, 2, int16_t) \ | |
193 | /* | 143 | + DO_VSHLL(OP##ub, TOP, 1, uint8_t, 2, uint16_t) \ |
194 | * pseries-5.2 | 144 | + DO_VSHLL(OP##sh, TOP, 2, int16_t, 4, int32_t) \ |
195 | diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c | 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 | ||
196 | index XXXXXXX..XXXXXXX 100644 | 150 | index XXXXXXX..XXXXXXX 100644 |
197 | --- a/hw/s390x/s390-virtio-ccw.c | 151 | --- a/target/arm/translate-mve.c |
198 | +++ b/hw/s390x/s390-virtio-ccw.c | 152 | +++ b/target/arm/translate-mve.c |
199 | @@ -XXX,XX +XXX,XX @@ bool css_migration_enabled(void) | 153 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_S, vshli_s, true) |
200 | } \ | 154 | DO_2SHIFT(VSHRI_U, vshli_u, true) |
201 | type_init(ccw_machine_register_##suffix) | 155 | DO_2SHIFT(VRSHRI_S, vrshli_s, true) |
202 | 156 | DO_2SHIFT(VRSHRI_U, vrshli_u, true) | |
203 | +static void ccw_machine_6_1_instance_options(MachineState *machine) | ||
204 | +{ | ||
205 | +} | ||
206 | + | 157 | + |
207 | +static void ccw_machine_6_1_class_options(MachineClass *mc) | 158 | +#define DO_VSHLL(INSN, FN) \ |
208 | +{ | 159 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ |
209 | +} | 160 | + { \ |
210 | +DEFINE_CCW_MACHINE(6_1, "6.1", true); | 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 | + } | ||
211 | + | 167 | + |
212 | static void ccw_machine_6_0_instance_options(MachineState *machine) | 168 | +DO_VSHLL(VSHLL_BS, vshllbs) |
213 | { | 169 | +DO_VSHLL(VSHLL_BU, vshllbu) |
214 | + ccw_machine_6_1_instance_options(machine); | 170 | +DO_VSHLL(VSHLL_TS, vshllts) |
215 | } | 171 | +DO_VSHLL(VSHLL_TU, vshlltu) |
216 | |||
217 | static void ccw_machine_6_0_class_options(MachineClass *mc) | ||
218 | { | ||
219 | + ccw_machine_6_1_class_options(mc); | ||
220 | + compat_props_add(mc->compat_props, hw_compat_6_0, hw_compat_6_0_len); | ||
221 | } | ||
222 | -DEFINE_CCW_MACHINE(6_0, "6.0", true); | ||
223 | +DEFINE_CCW_MACHINE(6_0, "6.0", false); | ||
224 | |||
225 | static void ccw_machine_5_2_instance_options(MachineState *machine) | ||
226 | { | ||
227 | -- | 172 | -- |
228 | 2.20.1 | 173 | 2.20.1 |
229 | 174 | ||
230 | 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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210419202257.161730-24-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210628135835.6690-11-peter.maydell@linaro.org | ||
7 | --- | 7 | --- |
8 | target/arm/translate-neon.c.inc | 27 ++++++++++++++++++++++----- | 8 | target/arm/helper-mve.h | 8 ++++++++ |
9 | 1 file changed, 22 insertions(+), 5 deletions(-) | 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(+) | ||
10 | 13 | ||
11 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-neon.c.inc | 16 | --- a/target/arm/helper-mve.h |
14 | +++ b/target/arm/translate-neon.c.inc | 17 | +++ b/target/arm/helper-mve.h |
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
16 | { | 19 | DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
17 | /* Neon load/store multiple structures */ | 20 | DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
18 | int nregs, interleave, spacing, reg, n; | 21 | DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
19 | - MemOp endian = s->be_data; | ||
20 | + MemOp mop, align, endian; | ||
21 | int mmu_idx = get_mem_index(s); | ||
22 | int size = a->size; | ||
23 | TCGv_i64 tmp64; | ||
24 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | ||
25 | } | ||
26 | |||
27 | /* For our purposes, bytes are always little-endian. */ | ||
28 | + endian = s->be_data; | ||
29 | if (size == 0) { | ||
30 | endian = MO_LE; | ||
31 | } | ||
32 | + | 22 | + |
33 | + /* Enforce alignment requested by the instruction */ | 23 | +DEF_HELPER_FLAGS_4(mve_vsrib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
34 | + if (a->align) { | 24 | +DEF_HELPER_FLAGS_4(mve_vsrih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
35 | + align = pow2_align(a->align + 2); /* 4 ** a->align */ | 25 | +DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
36 | + } else { | 26 | + |
37 | + align = s->align_mem ? MO_ALIGN : 0; | 27 | +DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
28 | +DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/mve.decode | ||
33 | +++ b/target/arm/mve.decode | ||
34 | @@ -XXX,XX +XXX,XX @@ VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
35 | |||
36 | VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
37 | VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
38 | + | ||
39 | +# Shift-and-insert | ||
40 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_b | ||
41 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_h | ||
42 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w | ||
43 | + | ||
44 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | ||
45 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | ||
46 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | ||
47 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/mve_helper.c | ||
50 | +++ b/target/arm/mve_helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
52 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
53 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
54 | |||
55 | +/* Shift-and-insert; we always work with 64 bits at a time */ | ||
56 | +#define DO_2SHIFT_INSERT(OP, ESIZE, SHIFTFN, MASKFN) \ | ||
57 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
58 | + void *vm, uint32_t shift) \ | ||
59 | + { \ | ||
60 | + uint64_t *d = vd, *m = vm; \ | ||
61 | + uint16_t mask; \ | ||
62 | + uint64_t shiftmask; \ | ||
63 | + unsigned e; \ | ||
64 | + if (shift == 0 || shift == ESIZE * 8) { \ | ||
65 | + /* \ | ||
66 | + * Only VSLI can shift by 0; only VSRI can shift by <dt>. \ | ||
67 | + * The generic logic would give the right answer for 0 but \ | ||
68 | + * fails for <dt>. \ | ||
69 | + */ \ | ||
70 | + goto done; \ | ||
71 | + } \ | ||
72 | + assert(shift < ESIZE * 8); \ | ||
73 | + mask = mve_element_mask(env); \ | ||
74 | + /* ESIZE / 2 gives the MO_* value if ESIZE is in [1,2,4] */ \ | ||
75 | + shiftmask = dup_const(ESIZE / 2, MASKFN(ESIZE * 8, shift)); \ | ||
76 | + for (e = 0; e < 16 / 8; e++, mask >>= 8) { \ | ||
77 | + uint64_t r = (SHIFTFN(m[H8(e)], shift) & shiftmask) | \ | ||
78 | + (d[H8(e)] & ~shiftmask); \ | ||
79 | + mergemask(&d[H8(e)], r, mask); \ | ||
80 | + } \ | ||
81 | +done: \ | ||
82 | + mve_advance_vpt(env); \ | ||
38 | + } | 83 | + } |
39 | + | 84 | + |
40 | /* | 85 | +#define DO_SHL(N, SHIFT) ((N) << (SHIFT)) |
41 | * Consecutive little-endian elements from a single register | 86 | +#define DO_SHR(N, SHIFT) ((N) >> (SHIFT)) |
42 | * can be promoted to a larger little-endian operation. | 87 | +#define SHL_MASK(EBITS, SHIFT) MAKE_64BIT_MASK((SHIFT), (EBITS) - (SHIFT)) |
43 | */ | 88 | +#define SHR_MASK(EBITS, SHIFT) MAKE_64BIT_MASK(0, (EBITS) - (SHIFT)) |
44 | if (interleave == 1 && endian == MO_LE) { | ||
45 | + /* Retain any natural alignment. */ | ||
46 | + if (align == MO_ALIGN) { | ||
47 | + align = pow2_align(size); | ||
48 | + } | ||
49 | size = 3; | ||
50 | } | ||
51 | + | 89 | + |
52 | tmp64 = tcg_temp_new_i64(); | 90 | +DO_2SHIFT_INSERT(vsrib, 1, DO_SHR, SHR_MASK) |
53 | addr = tcg_temp_new_i32(); | 91 | +DO_2SHIFT_INSERT(vsrih, 2, DO_SHR, SHR_MASK) |
54 | tmp = tcg_const_i32(1 << size); | 92 | +DO_2SHIFT_INSERT(vsriw, 4, DO_SHR, SHR_MASK) |
55 | load_reg_var(s, addr, a->rn); | 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) | ||
56 | + | 96 | + |
57 | + mop = endian | size | align; | 97 | /* |
58 | for (reg = 0; reg < nregs; reg++) { | 98 | * Long shifts taking half-sized inputs from top or bottom of the input |
59 | for (n = 0; n < 8 >> size; n++) { | 99 | * vector and producing a double-width result. ESIZE, TYPE are for |
60 | int xs; | 100 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
61 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | 101 | index XXXXXXX..XXXXXXX 100644 |
62 | int tt = a->vd + reg + spacing * xs; | 102 | --- a/target/arm/translate-mve.c |
63 | 103 | +++ b/target/arm/translate-mve.c | |
64 | if (a->l) { | 104 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_U, vshli_u, true) |
65 | - gen_aa32_ld_internal_i64(s, tmp64, addr, mmu_idx, | 105 | DO_2SHIFT(VRSHRI_S, vrshli_s, true) |
66 | - endian | size); | 106 | DO_2SHIFT(VRSHRI_U, vrshli_u, true) |
67 | + gen_aa32_ld_internal_i64(s, tmp64, addr, mmu_idx, mop); | 107 | |
68 | neon_store_element64(tt, n, size, tmp64); | 108 | +DO_2SHIFT(VSRI, vsri, false) |
69 | } else { | 109 | +DO_2SHIFT(VSLI, vsli, false) |
70 | neon_load_element64(tmp64, tt, n, size); | ||
71 | - gen_aa32_st_internal_i64(s, tmp64, addr, mmu_idx, | ||
72 | - endian | size); | ||
73 | + gen_aa32_st_internal_i64(s, tmp64, addr, mmu_idx, mop); | ||
74 | } | ||
75 | tcg_gen_add_i32(addr, addr, tmp); | ||
76 | + | 110 | + |
77 | + /* Subsequent memory operations inherit alignment */ | 111 | #define DO_VSHLL(INSN, FN) \ |
78 | + mop &= ~MO_AMASK; | 112 | static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ |
79 | } | 113 | { \ |
80 | } | ||
81 | } | ||
82 | -- | 114 | -- |
83 | 2.20.1 | 115 | 2.20.1 |
84 | 116 | ||
85 | 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 | This is the only caller. Adjust some commentary to talk | 3 | do_urshr() is borrowed from sve_helper.c. |
4 | about SCTLR_B instead of the vanishing function. | ||
5 | 4 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210419202257.161730-13-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210628135835.6690-12-peter.maydell@linaro.org | ||
10 | --- | 8 | --- |
11 | target/arm/translate.c | 37 ++++++++++++++++--------------------- | 9 | target/arm/helper-mve.h | 10 ++++++++++ |
12 | 1 file changed, 16 insertions(+), 21 deletions(-) | 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(+) | ||
13 | 14 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 17 | --- a/target/arm/helper-mve.h |
17 | +++ b/target/arm/translate.c | 18 | +++ b/target/arm/helper-mve.h |
18 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
19 | gen_aa32_st_i32(s, val, a32, index, OPC); \ | 20 | DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
20 | } | 21 | DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | 22 | DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
22 | -static inline void gen_aa32_frob64(DisasContext *s, TCGv_i64 val) | ||
23 | -{ | ||
24 | - /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
25 | - if (!IS_USER_ONLY && s->sctlr_b) { | ||
26 | - tcg_gen_rotri_i64(val, val, 32); | ||
27 | - } | ||
28 | -} | ||
29 | - | ||
30 | static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
31 | int index, MemOp opc) | ||
32 | { | ||
33 | TCGv addr = gen_aa32_addr(s, a32, opc); | ||
34 | tcg_gen_qemu_ld_i64(val, addr, index, opc); | ||
35 | - gen_aa32_frob64(s, val); | ||
36 | + | 23 | + |
37 | + /* Not needed for user-mode BE32, where we use MO_BE instead. */ | 24 | +DEF_HELPER_FLAGS_4(mve_vshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
38 | + if (!IS_USER_ONLY && s->sctlr_b) { | 25 | +DEF_HELPER_FLAGS_4(mve_vshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
39 | + tcg_gen_rotri_i64(val, val, 32); | 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); \ | ||
40 | + } | 79 | + } |
41 | + | 80 | + |
42 | tcg_temp_free(addr); | 81 | +#define DO_VSHRN_ALL(OP, FN) \ |
43 | } | 82 | + DO_VSHRN(OP##bb, false, 1, uint8_t, 2, uint16_t, FN) \ |
44 | 83 | + DO_VSHRN(OP##bh, false, 2, uint16_t, 4, uint32_t, FN) \ | |
45 | @@ -XXX,XX +XXX,XX @@ static void gen_load_exclusive(DisasContext *s, int rt, int rt2, | 84 | + DO_VSHRN(OP##tb, true, 1, uint8_t, 2, uint16_t, FN) \ |
46 | TCGv_i32 tmp2 = tcg_temp_new_i32(); | 85 | + DO_VSHRN(OP##th, true, 2, uint16_t, 4, uint32_t, FN) |
47 | TCGv_i64 t64 = tcg_temp_new_i64(); | ||
48 | |||
49 | - /* For AArch32, architecturally the 32-bit word at the lowest | ||
50 | + /* | ||
51 | + * For AArch32, architecturally the 32-bit word at the lowest | ||
52 | * address is always Rt and the one at addr+4 is Rt2, even if | ||
53 | * the CPU is big-endian. That means we don't want to do a | ||
54 | - * gen_aa32_ld_i64(), which invokes gen_aa32_frob64() as if | ||
55 | - * for an architecturally 64-bit access, but instead do a | ||
56 | - * 64-bit access using MO_BE if appropriate and then split | ||
57 | - * the two halves. | ||
58 | - * This only makes a difference for BE32 user-mode, where | ||
59 | - * frob64() must not flip the two halves of the 64-bit data | ||
60 | - * but this code must treat BE32 user-mode like BE32 system. | ||
61 | + * gen_aa32_ld_i64(), which checks SCTLR_B as if for an | ||
62 | + * architecturally 64-bit access, but instead do a 64-bit access | ||
63 | + * using MO_BE if appropriate and then split the two halves. | ||
64 | */ | ||
65 | TCGv taddr = gen_aa32_addr(s, addr, opc); | ||
66 | |||
67 | @@ -XXX,XX +XXX,XX @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2, | ||
68 | TCGv_i64 n64 = tcg_temp_new_i64(); | ||
69 | |||
70 | t2 = load_reg(s, rt2); | ||
71 | - /* For AArch32, architecturally the 32-bit word at the lowest | ||
72 | + | 86 | + |
73 | + /* | 87 | +static inline uint64_t do_urshr(uint64_t x, unsigned sh) |
74 | + * For AArch32, architecturally the 32-bit word at the lowest | 88 | +{ |
75 | * address is always Rt and the one at addr+4 is Rt2, even if | 89 | + if (likely(sh < 64)) { |
76 | * the CPU is big-endian. Since we're going to treat this as a | 90 | + return (x >> sh) + ((x >> (sh - 1)) & 1); |
77 | * single 64-bit BE store, we need to put the two halves in the | 91 | + } else if (sh == 64) { |
78 | * opposite order for BE to LE, so that they end up in the right | 92 | + return x >> 63; |
79 | - * places. | 93 | + } else { |
80 | - * We don't want gen_aa32_frob64() because that does the wrong | 94 | + return 0; |
81 | - * thing for BE32 usermode. | 95 | + } |
82 | + * places. We don't want gen_aa32_st_i64, because that checks | 96 | +} |
83 | + * SCTLR_B as if for an architectural 64-bit access. | 97 | + |
84 | */ | 98 | +DO_VSHRN_ALL(vshrn, DO_SHR) |
85 | if (s->be_data == MO_BE) { | 99 | +DO_VSHRN_ALL(vrshrn, do_urshr) |
86 | tcg_gen_concat_i32_i64(n64, t2, t1); | 100 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/target/arm/translate-mve.c | ||
103 | +++ b/target/arm/translate-mve.c | ||
104 | @@ -XXX,XX +XXX,XX @@ DO_VSHLL(VSHLL_BS, vshllbs) | ||
105 | DO_VSHLL(VSHLL_BU, vshllbu) | ||
106 | DO_VSHLL(VSHLL_TS, vshllts) | ||
107 | DO_VSHLL(VSHLL_TU, vshlltu) | ||
108 | + | ||
109 | +#define DO_2SHIFT_N(INSN, FN) \ | ||
110 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
111 | + { \ | ||
112 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
113 | + gen_helper_mve_##FN##b, \ | ||
114 | + gen_helper_mve_##FN##h, \ | ||
115 | + }; \ | ||
116 | + return do_2shift(s, a, fns[a->size], false); \ | ||
117 | + } | ||
118 | + | ||
119 | +DO_2SHIFT_N(VSHRNB, vshrnb) | ||
120 | +DO_2SHIFT_N(VSHRNT, vshrnt) | ||
121 | +DO_2SHIFT_N(VRSHRNB, vrshrnb) | ||
122 | +DO_2SHIFT_N(VRSHRNT, vrshrnt) | ||
87 | -- | 123 | -- |
88 | 2.20.1 | 124 | 2.20.1 |
89 | 125 | ||
90 | 126 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE saturating shift-right-and-narrow insns |
---|---|---|---|
2 | 2 | VQSHRN, VQSHRUN, VQRSHRN and VQRSHRUN. | |
3 | We were incorrectly assuming that only the first byte of an MTE access | 3 | |
4 | is checked against the tags. But per the ARM, unaligned accesses are | 4 | do_srshr() is borrowed from sve_helper.c. |
5 | pre-decomposed into single-byte accesses. So by the time we reach the | 5 | |
6 | actual MTE check in the ARM pseudocode, all accesses are aligned. | ||
7 | |||
8 | We cannot tell a priori whether or not a given scalar access is aligned, | ||
9 | therefore we must at least check. Use mte_probe_int, which is already | ||
10 | set up for checking multiple granules. | ||
11 | |||
12 | Buglink: https://bugs.launchpad.net/bugs/1921948 | ||
13 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
14 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20210416183106.1516563-4-richard.henderson@linaro.org | ||
17 | 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 | ||
18 | --- | 9 | --- |
19 | target/arm/mte_helper.c | 109 +++++++++++++--------------------------- | 10 | target/arm/helper-mve.h | 30 +++++++++++ |
20 | 1 file changed, 35 insertions(+), 74 deletions(-) | 11 | target/arm/mve.decode | 28 ++++++++++ |
21 | 12 | target/arm/mve_helper.c | 104 +++++++++++++++++++++++++++++++++++++ | |
22 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | 13 | target/arm/translate-mve.c | 12 +++++ |
23 | index XXXXXXX..XXXXXXX 100644 | 14 | 4 files changed, 174 insertions(+) |
24 | --- a/target/arm/mte_helper.c | 15 | |
25 | +++ b/target/arm/mte_helper.c | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
26 | @@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc, | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper-mve.h | ||
19 | +++ b/target/arm/helper-mve.h | ||
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
21 | DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | + | ||
35 | +DEF_HELPER_FLAGS_4(mve_vqshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_4(mve_vqshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | +DEF_HELPER_FLAGS_4(mve_vqshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(mve_vqshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | + | ||
40 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
42 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
43 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
44 | + | ||
45 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
46 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
47 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
48 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
49 | + | ||
50 | +DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
51 | +DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
53 | +DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
54 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/target/arm/mve.decode | ||
57 | +++ b/target/arm/mve.decode | ||
58 | @@ -XXX,XX +XXX,XX @@ VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | ||
59 | VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | ||
60 | VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | ||
61 | VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | ||
62 | + | ||
63 | +VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b | ||
64 | +VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h | ||
65 | +VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b | ||
66 | +VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h | ||
67 | +VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b | ||
68 | +VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h | ||
69 | +VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b | ||
70 | +VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h | ||
71 | + | ||
72 | +VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
73 | +VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
74 | +VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
75 | +VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
76 | + | ||
77 | +VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b | ||
78 | +VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h | ||
79 | +VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b | ||
80 | +VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h | ||
81 | +VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b | ||
82 | +VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h | ||
83 | +VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b | ||
84 | +VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h | ||
85 | + | ||
86 | +VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
87 | +VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
88 | +VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
89 | +VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
90 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/mve_helper.c | ||
93 | +++ b/target/arm/mve_helper.c | ||
94 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t do_urshr(uint64_t x, unsigned sh) | ||
27 | } | 95 | } |
28 | } | 96 | } |
29 | 97 | ||
30 | -/* | 98 | +static inline int64_t do_srshr(int64_t x, unsigned sh) |
31 | - * Perform an MTE checked access for a single logical or atomic access. | ||
32 | - */ | ||
33 | -static bool mte_probe1_int(CPUARMState *env, uint32_t desc, uint64_t ptr, | ||
34 | - uintptr_t ra, int bit55) | ||
35 | -{ | ||
36 | - int mem_tag, mmu_idx, ptr_tag, size; | ||
37 | - MMUAccessType type; | ||
38 | - uint8_t *mem; | ||
39 | - | ||
40 | - ptr_tag = allocation_tag_from_addr(ptr); | ||
41 | - | ||
42 | - if (tcma_check(desc, bit55, ptr_tag)) { | ||
43 | - return true; | ||
44 | - } | ||
45 | - | ||
46 | - mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX); | ||
47 | - type = FIELD_EX32(desc, MTEDESC, WRITE) ? MMU_DATA_STORE : MMU_DATA_LOAD; | ||
48 | - size = FIELD_EX32(desc, MTEDESC, ESIZE); | ||
49 | - | ||
50 | - mem = allocation_tag_mem(env, mmu_idx, ptr, type, size, | ||
51 | - MMU_DATA_LOAD, 1, ra); | ||
52 | - if (!mem) { | ||
53 | - return true; | ||
54 | - } | ||
55 | - | ||
56 | - mem_tag = load_tag1(ptr, mem); | ||
57 | - return ptr_tag == mem_tag; | ||
58 | -} | ||
59 | - | ||
60 | -/* | ||
61 | - * No-fault version of mte_check1, to be used by SVE for MemSingleNF. | ||
62 | - * Returns false if the access is Checked and the check failed. This | ||
63 | - * is only intended to probe the tag -- the validity of the page must | ||
64 | - * be checked beforehand. | ||
65 | - */ | ||
66 | -bool mte_probe1(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
67 | -{ | ||
68 | - int bit55 = extract64(ptr, 55, 1); | ||
69 | - | ||
70 | - /* If TBI is disabled, the access is unchecked. */ | ||
71 | - if (unlikely(!tbi_check(desc, bit55))) { | ||
72 | - return true; | ||
73 | - } | ||
74 | - | ||
75 | - return mte_probe1_int(env, desc, ptr, 0, bit55); | ||
76 | -} | ||
77 | - | ||
78 | -uint64_t mte_check1(CPUARMState *env, uint32_t desc, | ||
79 | - uint64_t ptr, uintptr_t ra) | ||
80 | -{ | ||
81 | - int bit55 = extract64(ptr, 55, 1); | ||
82 | - | ||
83 | - /* If TBI is disabled, the access is unchecked, and ptr is not dirty. */ | ||
84 | - if (unlikely(!tbi_check(desc, bit55))) { | ||
85 | - return ptr; | ||
86 | - } | ||
87 | - | ||
88 | - if (unlikely(!mte_probe1_int(env, desc, ptr, ra, bit55))) { | ||
89 | - mte_check_fail(env, desc, ptr, ra); | ||
90 | - } | ||
91 | - | ||
92 | - return useronly_clean_ptr(ptr); | ||
93 | -} | ||
94 | - | ||
95 | -uint64_t HELPER(mte_check1)(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
96 | -{ | ||
97 | - return mte_check1(env, desc, ptr, GETPC()); | ||
98 | -} | ||
99 | - | ||
100 | -/* | ||
101 | - * Perform an MTE checked access for multiple logical accesses. | ||
102 | - */ | ||
103 | - | ||
104 | /** | ||
105 | * checkN: | ||
106 | * @tag: tag memory to test | ||
107 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mte_checkN)(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
108 | return mte_checkN(env, desc, ptr, GETPC()); | ||
109 | } | ||
110 | |||
111 | +uint64_t mte_check1(CPUARMState *env, uint32_t desc, | ||
112 | + uint64_t ptr, uintptr_t ra) | ||
113 | +{ | 99 | +{ |
114 | + uint64_t fault; | 100 | + if (likely(sh < 64)) { |
115 | + uint32_t total = FIELD_EX32(desc, MTEDESC, ESIZE); | 101 | + return (x >> sh) + ((x >> (sh - 1)) & 1); |
116 | + int ret = mte_probe_int(env, desc, ptr, ra, total, &fault); | 102 | + } else { |
117 | + | 103 | + /* Rounding the sign bit always produces 0. */ |
118 | + if (unlikely(ret == 0)) { | 104 | + return 0; |
119 | + mte_check_fail(env, desc, fault, ra); | ||
120 | + } else if (ret < 0) { | ||
121 | + return ptr; | ||
122 | + } | 105 | + } |
123 | + return useronly_clean_ptr(ptr); | ||
124 | +} | 106 | +} |
125 | + | 107 | + |
126 | +uint64_t HELPER(mte_check1)(CPUARMState *env, uint32_t desc, uint64_t ptr) | 108 | DO_VSHRN_ALL(vshrn, DO_SHR) |
109 | DO_VSHRN_ALL(vrshrn, do_urshr) | ||
110 | + | ||
111 | +static inline int32_t do_sat_bhs(int64_t val, int64_t min, int64_t max, | ||
112 | + bool *satp) | ||
127 | +{ | 113 | +{ |
128 | + return mte_check1(env, desc, ptr, GETPC()); | 114 | + if (val > max) { |
115 | + *satp = true; | ||
116 | + return max; | ||
117 | + } else if (val < min) { | ||
118 | + *satp = true; | ||
119 | + return min; | ||
120 | + } else { | ||
121 | + return val; | ||
122 | + } | ||
129 | +} | 123 | +} |
130 | + | 124 | + |
131 | +/* | 125 | +/* Saturating narrowing right shifts */ |
132 | + * No-fault version of mte_check1, to be used by SVE for MemSingleNF. | 126 | +#define DO_VSHRN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ |
133 | + * Returns false if the access is Checked and the check failed. This | 127 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ |
134 | + * is only intended to probe the tag -- the validity of the page must | 128 | + void *vm, uint32_t shift) \ |
135 | + * be checked beforehand. | 129 | + { \ |
136 | + */ | 130 | + LTYPE *m = vm; \ |
137 | +bool mte_probe1(CPUARMState *env, uint32_t desc, uint64_t ptr) | 131 | + TYPE *d = vd; \ |
138 | +{ | 132 | + uint16_t mask = mve_element_mask(env); \ |
139 | + uint64_t fault; | 133 | + bool qc = false; \ |
140 | + uint32_t total = FIELD_EX32(desc, MTEDESC, ESIZE); | 134 | + unsigned le; \ |
141 | + int ret = mte_probe_int(env, desc, ptr, 0, total, &fault); | 135 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ |
142 | + | 136 | + bool sat = false; \ |
143 | + return ret != 0; | 137 | + TYPE r = FN(m[H##LESIZE(le)], shift, &sat); \ |
144 | +} | 138 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ |
145 | + | 139 | + qc |= sat && (mask & 1 << (TOP * ESIZE)); \ |
146 | /* | 140 | + } \ |
147 | * Perform an MTE checked access for DC_ZVA. | 141 | + if (qc) { \ |
148 | */ | 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) | ||
149 | -- | 224 | -- |
150 | 2.20.1 | 225 | 2.20.1 |
151 | 226 | ||
152 | 227 | diff view generated by jsdifflib |
1 | Currently the gpex PCI controller implements no special behaviour for | 1 | Implement the MVE VSHLC insn, which performs a shift left of the |
---|---|---|---|
2 | guest accesses to areas of the PIO and MMIO where it has not mapped | 2 | entire vector with carry in bits provided from a general purpose |
3 | any PCI devices, which means that for Arm you end up with a CPU | 3 | register and carry out bits written back to that register. |
4 | exception due to a data abort. | ||
5 | 4 | ||
6 | Most host OSes expect "like an x86 PC" behaviour, where bad accesses | ||
7 | like this return -1 for reads and ignore writes. In the interests of | ||
8 | not being surprising, make host CPU accesses to these windows behave | ||
9 | as -1/discard where there's no mapped PCI device. | ||
10 | |||
11 | The old behaviour generally didn't cause any problems, because | ||
12 | almost always the guest OS will map the PCI devices and then only | ||
13 | access where it has mapped them. One corner case where you will see | ||
14 | this kind of access is if Linux attempts to probe legacy ISA | ||
15 | devices via a PIO window access. So far the only case where we've | ||
16 | seen this has been via the syzkaller fuzzer. | ||
17 | |||
18 | Reported-by: Dmitry Vyukov <dvyukov@google.com> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
21 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | 7 | Message-id: 20210628135835.6690-14-peter.maydell@linaro.org |
22 | Message-id: 20210325163315.27724-1-peter.maydell@linaro.org | ||
23 | Fixes: https://bugs.launchpad.net/qemu/+bug/1918917 | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
25 | --- | 8 | --- |
26 | include/hw/pci-host/gpex.h | 4 +++ | 9 | target/arm/helper-mve.h | 2 ++ |
27 | hw/core/machine.c | 4 ++- | 10 | target/arm/mve.decode | 2 ++ |
28 | hw/pci-host/gpex.c | 56 ++++++++++++++++++++++++++++++++++++-- | 11 | target/arm/mve_helper.c | 38 ++++++++++++++++++++++++++++++++++++++ |
29 | 3 files changed, 60 insertions(+), 4 deletions(-) | 12 | target/arm/translate-mve.c | 30 ++++++++++++++++++++++++++++++ |
13 | 4 files changed, 72 insertions(+) | ||
30 | 14 | ||
31 | diff --git a/include/hw/pci-host/gpex.h b/include/hw/pci-host/gpex.h | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
32 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/include/hw/pci-host/gpex.h | 17 | --- a/target/arm/helper-mve.h |
34 | +++ b/include/hw/pci-host/gpex.h | 18 | +++ b/target/arm/helper-mve.h |
35 | @@ -XXX,XX +XXX,XX @@ struct GPEXHost { | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
36 | 20 | DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
37 | MemoryRegion io_ioport; | 21 | DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
38 | MemoryRegion io_mmio; | 22 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
39 | + MemoryRegion io_ioport_window; | ||
40 | + MemoryRegion io_mmio_window; | ||
41 | qemu_irq irq[GPEX_NUM_IRQS]; | ||
42 | int irq_num[GPEX_NUM_IRQS]; | ||
43 | + | 23 | + |
44 | + bool allow_unmapped_accesses; | 24 | +DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
45 | }; | 25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
46 | |||
47 | struct GPEXConfig { | ||
48 | diff --git a/hw/core/machine.c b/hw/core/machine.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/hw/core/machine.c | 27 | --- a/target/arm/mve.decode |
51 | +++ b/hw/core/machine.c | 28 | +++ b/target/arm/mve.decode |
52 | @@ -XXX,XX +XXX,XX @@ | 29 | @@ -XXX,XX +XXX,XX @@ VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b |
53 | #include "hw/virtio/virtio.h" | 30 | VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h |
54 | #include "hw/virtio/virtio-pci.h" | 31 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b |
55 | 32 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | |
56 | -GlobalProperty hw_compat_6_0[] = {}; | 33 | + |
57 | +GlobalProperty hw_compat_6_0[] = { | 34 | +VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd |
58 | + { "gpex-pcihost", "allow-unmapped-accesses", "false" }, | 35 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
59 | +}; | ||
60 | const size_t hw_compat_6_0_len = G_N_ELEMENTS(hw_compat_6_0); | ||
61 | |||
62 | GlobalProperty hw_compat_5_2[] = { | ||
63 | diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
65 | --- a/hw/pci-host/gpex.c | 37 | --- a/target/arm/mve_helper.c |
66 | +++ b/hw/pci-host/gpex.c | 38 | +++ b/target/arm/mve_helper.c |
67 | @@ -XXX,XX +XXX,XX @@ static void gpex_host_realize(DeviceState *dev, Error **errp) | 39 | @@ -XXX,XX +XXX,XX @@ DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB) |
68 | int i; | 40 | DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) |
69 | 41 | DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | |
70 | pcie_host_mmcfg_init(pex, PCIE_MMCFG_SIZE_MAX); | 42 | DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) |
71 | + sysbus_init_mmio(sbd, &pex->mmio); | 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; | ||
72 | + | 51 | + |
73 | + /* | 52 | + /* |
74 | + * Note that the MemoryRegions io_mmio and io_ioport that we pass | 53 | + * For each 32-bit element, we shift it left, bringing in the |
75 | + * to pci_register_root_bus() are not the same as the | 54 | + * low 'shift' bits of rdm at the bottom. Bits shifted out at |
76 | + * MemoryRegions io_mmio_window and io_ioport_window that we | 55 | + * the top become the new rdm, if the predicate mask permits. |
77 | + * expose as SysBus MRs. The difference is in the behaviour of | 56 | + * The final rdm value is returned to update the register. |
78 | + * accesses to addresses where no PCI device has been mapped. | 57 | + * shift == 0 here means "shift by 32 bits". |
79 | + * | ||
80 | + * io_mmio and io_ioport are the underlying PCI view of the PCI | ||
81 | + * address space, and when a PCI device does a bus master access | ||
82 | + * to a bad address this is reported back to it as a transaction | ||
83 | + * failure. | ||
84 | + * | ||
85 | + * io_mmio_window and io_ioport_window implement "unmapped | ||
86 | + * addresses read as -1 and ignore writes"; this is traditional | ||
87 | + * x86 PC behaviour, which is not mandated by the PCI spec proper | ||
88 | + * but expected by much PCI-using guest software, including Linux. | ||
89 | + * | ||
90 | + * In the interests of not being unnecessarily surprising, we | ||
91 | + * implement it in the gpex PCI host controller, by providing the | ||
92 | + * _window MRs, which are containers with io ops that implement | ||
93 | + * the 'background' behaviour and which hold the real PCI MRs as | ||
94 | + * subregions. | ||
95 | + */ | 58 | + */ |
96 | memory_region_init(&s->io_mmio, OBJECT(s), "gpex_mmio", UINT64_MAX); | 59 | + if (shift == 0) { |
97 | memory_region_init(&s->io_ioport, OBJECT(s), "gpex_ioport", 64 * 1024); | 60 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { |
98 | 61 | + r = rdm; | |
99 | - sysbus_init_mmio(sbd, &pex->mmio); | 62 | + if (mask & 1) { |
100 | - sysbus_init_mmio(sbd, &s->io_mmio); | 63 | + rdm = d[H4(e)]; |
101 | - sysbus_init_mmio(sbd, &s->io_ioport); | 64 | + } |
102 | + if (s->allow_unmapped_accesses) { | 65 | + mergemask(&d[H4(e)], r, mask); |
103 | + memory_region_init_io(&s->io_mmio_window, OBJECT(s), | 66 | + } |
104 | + &unassigned_io_ops, OBJECT(s), | 67 | + } else { |
105 | + "gpex_mmio_window", UINT64_MAX); | 68 | + uint32_t shiftmask = MAKE_64BIT_MASK(0, shift); |
106 | + memory_region_init_io(&s->io_ioport_window, OBJECT(s), | ||
107 | + &unassigned_io_ops, OBJECT(s), | ||
108 | + "gpex_ioport_window", 64 * 1024); | ||
109 | + | 69 | + |
110 | + memory_region_add_subregion(&s->io_mmio_window, 0, &s->io_mmio); | 70 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { |
111 | + memory_region_add_subregion(&s->io_ioport_window, 0, &s->io_ioport); | 71 | + r = (d[H4(e)] << shift) | (rdm & shiftmask); |
112 | + sysbus_init_mmio(sbd, &s->io_mmio_window); | 72 | + if (mask & 1) { |
113 | + sysbus_init_mmio(sbd, &s->io_ioport_window); | 73 | + rdm = d[H4(e)] >> (32 - shift); |
114 | + } else { | 74 | + } |
115 | + sysbus_init_mmio(sbd, &s->io_mmio); | 75 | + mergemask(&d[H4(e)], r, mask); |
116 | + sysbus_init_mmio(sbd, &s->io_ioport); | 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; | ||
117 | + } | 109 | + } |
118 | + | 110 | + |
119 | for (i = 0; i < GPEX_NUM_IRQS; i++) { | 111 | + qd = mve_qreg_ptr(a->qd); |
120 | sysbus_init_irq(sbd, &s->irq[i]); | 112 | + rdm = load_reg(s, a->rdm); |
121 | s->irq_num[i] = -1; | 113 | + gen_helper_mve_vshlc(rdm, cpu_env, qd, rdm, tcg_constant_i32(a->imm)); |
122 | @@ -XXX,XX +XXX,XX @@ static const char *gpex_host_root_bus_path(PCIHostState *host_bridge, | 114 | + store_reg(s, a->rdm, rdm); |
123 | return "0000:00"; | 115 | + tcg_temp_free_ptr(qd); |
124 | } | 116 | + mve_update_eci(s); |
125 | 117 | + return true; | |
126 | +static Property gpex_host_properties[] = { | 118 | +} |
127 | + /* | ||
128 | + * Permit CPU accesses to unmapped areas of the PIO and MMIO windows | ||
129 | + * (discarding writes and returning -1 for reads) rather than aborting. | ||
130 | + */ | ||
131 | + DEFINE_PROP_BOOL("allow-unmapped-accesses", GPEXHost, | ||
132 | + allow_unmapped_accesses, true), | ||
133 | + DEFINE_PROP_END_OF_LIST(), | ||
134 | +}; | ||
135 | + | ||
136 | static void gpex_host_class_init(ObjectClass *klass, void *data) | ||
137 | { | ||
138 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
139 | @@ -XXX,XX +XXX,XX @@ static void gpex_host_class_init(ObjectClass *klass, void *data) | ||
140 | dc->realize = gpex_host_realize; | ||
141 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); | ||
142 | dc->fw_name = "pci"; | ||
143 | + device_class_set_props(dc, gpex_host_properties); | ||
144 | } | ||
145 | |||
146 | static void gpex_host_initfn(Object *obj) | ||
147 | -- | 119 | -- |
148 | 2.20.1 | 120 | 2.20.1 |
149 | 121 | ||
150 | 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 | Split out a helper function from mte_checkN to perform | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | all of the checking and address manpulation. So far, | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | just use this in mte_checkN itself. | 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(-) | ||
6 | 14 | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210416183106.1516563-3-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/mte_helper.c | 52 +++++++++++++++++++++++++++++++---------- | ||
14 | 1 file changed, 40 insertions(+), 12 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/mte_helper.c | 17 | --- a/target/arm/helper-mve.h |
19 | +++ b/target/arm/mte_helper.c | 18 | +++ b/target/arm/helper-mve.h |
20 | @@ -XXX,XX +XXX,XX @@ static int checkN(uint8_t *mem, int odd, int cmp, int count) | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) |
21 | return n; | 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 | -uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | 84 | +static bool trans_VADDLV(DisasContext *s, arg_VADDLV *a) |
25 | - uint64_t ptr, uintptr_t ra) | 85 | +{ |
26 | +/** | 86 | + /* |
27 | + * mte_probe_int() - helper for mte_probe and mte_check | 87 | + * Vector Add Long Across Vector: accumulate the 32-bit |
28 | + * @env: CPU environment | 88 | + * elements of the vector into a 64-bit result stored in |
29 | + * @desc: MTEDESC descriptor | 89 | + * a pair of general-purpose registers. |
30 | + * @ptr: virtual address of the base of the access | 90 | + * No need to check Qm's bank: it is only 3 bits in decode. |
31 | + * @fault: return virtual address of the first check failure | 91 | + */ |
32 | + * | 92 | + TCGv_ptr qm; |
33 | + * Internal routine for both mte_probe and mte_check. | 93 | + TCGv_i64 rda; |
34 | + * Return zero on failure, filling in *fault. | 94 | + TCGv_i32 rdalo, rdahi; |
35 | + * Return negative on trivial success for tbi disabled. | 95 | + |
36 | + * Return positive on success with tbi enabled. | 96 | + if (!dc_isar_feature(aa32_mve, s)) { |
37 | + */ | 97 | + return false; |
38 | +static int mte_probe_int(CPUARMState *env, uint32_t desc, uint64_t ptr, | 98 | + } |
39 | + uintptr_t ra, uint32_t total, uint64_t *fault) | 99 | + /* |
40 | { | 100 | + * rdahi == 13 is UNPREDICTABLE; rdahi == 15 is a related |
41 | int mmu_idx, ptr_tag, bit55; | 101 | + * encoding; rdalo always has bit 0 clear so cannot be 13 or 15. |
42 | uint64_t ptr_last, prev_page, next_page; | 102 | + */ |
43 | uint64_t tag_first, tag_last; | 103 | + if (a->rdahi == 13 || a->rdahi == 15) { |
44 | uint64_t tag_byte_first, tag_byte_last; | 104 | + return false; |
45 | - uint32_t total, tag_count, tag_size, n, c; | 105 | + } |
46 | + uint32_t tag_count, tag_size, n, c; | 106 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
47 | uint8_t *mem1, *mem2; | 107 | + return true; |
48 | MMUAccessType type; | ||
49 | |||
50 | bit55 = extract64(ptr, 55, 1); | ||
51 | + *fault = ptr; | ||
52 | |||
53 | /* If TBI is disabled, the access is unchecked, and ptr is not dirty. */ | ||
54 | if (unlikely(!tbi_check(desc, bit55))) { | ||
55 | - return ptr; | ||
56 | + return -1; | ||
57 | } | ||
58 | |||
59 | ptr_tag = allocation_tag_from_addr(ptr); | ||
60 | |||
61 | if (tcma_check(desc, bit55, ptr_tag)) { | ||
62 | - goto done; | ||
63 | + return 1; | ||
64 | } | ||
65 | |||
66 | mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX); | ||
67 | type = FIELD_EX32(desc, MTEDESC, WRITE) ? MMU_DATA_STORE : MMU_DATA_LOAD; | ||
68 | - total = FIELD_EX32(desc, MTEDESC, TSIZE); | ||
69 | |||
70 | /* Find the addr of the end of the access */ | ||
71 | ptr_last = ptr + total - 1; | ||
72 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
73 | mem1 = allocation_tag_mem(env, mmu_idx, ptr, type, total, | ||
74 | MMU_DATA_LOAD, tag_size, ra); | ||
75 | if (!mem1) { | ||
76 | - goto done; | ||
77 | + return 1; | ||
78 | } | ||
79 | /* Perform all of the comparisons. */ | ||
80 | n = checkN(mem1, ptr & TAG_GRANULE, ptr_tag, tag_count); | ||
81 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
82 | } | ||
83 | if (n == c) { | ||
84 | if (!mem2) { | ||
85 | - goto done; | ||
86 | + return 1; | ||
87 | } | ||
88 | n += checkN(mem2, 0, ptr_tag, tag_count - c); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | + if (likely(n == tag_count)) { | ||
93 | + return 1; | ||
94 | + } | 108 | + } |
95 | + | 109 | + |
96 | /* | 110 | + /* |
97 | * If we failed, we know which granule. For the first granule, the | 111 | + * This insn is subject to beat-wise execution. Partial execution |
98 | * failure address is @ptr, the first byte accessed. Otherwise the | 112 | + * of an A=0 (no-accumulate) insn which does not execute the first |
99 | * failure address is the first byte of the nth granule. | 113 | + * beat must start with the current value of RdaHi:RdaLo, not zero. |
100 | */ | 114 | + */ |
101 | - if (unlikely(n < tag_count)) { | 115 | + if (a->a || mve_skip_first_beat(s)) { |
102 | - uint64_t fault = (n == 0 ? ptr : tag_first + n * TAG_GRANULE); | 116 | + /* Accumulate input from RdaHi:RdaLo */ |
103 | - mte_check_fail(env, desc, fault, ra); | 117 | + rda = tcg_temp_new_i64(); |
104 | + if (n > 0) { | 118 | + rdalo = load_reg(s, a->rdalo); |
105 | + *fault = tag_first + n * TAG_GRANULE; | 119 | + rdahi = load_reg(s, a->rdahi); |
106 | } | 120 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); |
107 | + return 0; | 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; | ||
108 | +} | 145 | +} |
109 | |||
110 | - done: | ||
111 | +uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
112 | + uint64_t ptr, uintptr_t ra) | ||
113 | +{ | ||
114 | + uint64_t fault; | ||
115 | + uint32_t total = FIELD_EX32(desc, MTEDESC, TSIZE); | ||
116 | + int ret = mte_probe_int(env, desc, ptr, ra, total, &fault); | ||
117 | + | 146 | + |
118 | + if (unlikely(ret == 0)) { | 147 | static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) |
119 | + mte_check_fail(env, desc, fault, ra); | 148 | { |
120 | + } else if (ret < 0) { | 149 | TCGv_ptr qd; |
121 | + return ptr; | ||
122 | + } | ||
123 | return useronly_clean_ptr(ptr); | ||
124 | } | ||
125 | |||
126 | -- | 150 | -- |
127 | 2.20.1 | 151 | 2.20.1 |
128 | 152 | ||
129 | 153 | diff view generated by jsdifflib |
1 | The Arm ARM specifies that for Thumb encodings of the various plain | 1 | The MVE extension to v8.1M includes some new shift instructions which |
---|---|---|---|
2 | store insns, if the Rn field is 1111 then we must UNDEF. This is | 2 | sit entirely within the non-coprocessor part of the encoding space |
3 | different from the Arm encodings, where this case is either | 3 | and which operate only on general-purpose registers. They take up |
4 | UNPREDICTABLE or has well-defined behaviour. The exclusive stores, | 4 | the space which was previously UNPREDICTABLE MOVS and ORRS encodings |
5 | store-release and STRD do not have this UNDEF case for any encoding. | 5 | with Rm == 13 or 15. |
6 | 6 | ||
7 | Enforce the UNDEF for this case in the Thumb plain store insns. | 7 | Implement the long shifts by immediate, which perform shifts on a |
8 | 8 | pair of general-purpose registers treated as a 64-bit quantity, with | |
9 | Fixes: https://bugs.launchpad.net/qemu/+bug/1922887 | 9 | an immediate shift count between 1 and 32. |
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 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20210408162402.5822-1-peter.maydell@linaro.org | 26 | Message-id: 20210628135835.6690-16-peter.maydell@linaro.org |
13 | --- | 27 | --- |
14 | target/arm/translate.c | 16 ++++++++++++++++ | 28 | target/arm/helper-mve.h | 3 ++ |
15 | 1 file changed, 16 insertions(+) | 29 | target/arm/translate.h | 1 + |
16 | 30 | target/arm/t32.decode | 28 +++++++++++++ | |
31 | target/arm/mve_helper.c | 10 +++++ | ||
32 | target/arm/translate.c | 90 +++++++++++++++++++++++++++++++++++++++++ | ||
33 | 5 files changed, 132 insertions(+) | ||
34 | |||
35 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/helper-mve.h | ||
38 | +++ b/target/arm/helper-mve.h | ||
39 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | |||
42 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
43 | + | ||
44 | +DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
45 | +DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
46 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/translate.h | ||
49 | +++ b/target/arm/translate.h | ||
50 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); | ||
51 | typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
52 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
53 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
54 | +typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | ||
55 | |||
56 | /** | ||
57 | * arm_tbflags_from_tb: | ||
58 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/t32.decode | ||
61 | +++ b/target/arm/t32.decode | ||
62 | @@ -XXX,XX +XXX,XX @@ | ||
63 | &mcr !extern cp opc1 crn crm opc2 rt | ||
64 | &mcrr !extern cp opc1 crm rt rt2 | ||
65 | |||
66 | +&mve_shl_ri rdalo rdahi shim | ||
67 | + | ||
68 | +# rdahi: bits [3:1] from insn, bit 0 is 1 | ||
69 | +# rdalo: bits [3:1] from insn, bit 0 is 0 | ||
70 | +%rdahi_9 9:3 !function=times_2_plus_1 | ||
71 | +%rdalo_17 17:3 !function=times_2 | ||
72 | + | ||
73 | # Data-processing (register) | ||
74 | |||
75 | %imm5_12_6 12:3 6:2 | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | @S_xrr_shi ....... .... . rn:4 .... .... .. shty:2 rm:4 \ | ||
78 | &s_rrr_shi shim=%imm5_12_6 s=1 rd=0 | ||
79 | |||
80 | +@mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ | ||
81 | + &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
82 | + | ||
83 | { | ||
84 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | ||
85 | AND_rrri 1110101 0000 . .... 0 ... .... .... .... @s_rrr_shi | ||
86 | } | ||
87 | BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | ||
88 | { | ||
89 | + # The v8.1M MVE shift insns overlap in encoding with MOVS/ORRS | ||
90 | + # and are distinguished by having Rm==13 or 15. Those are UNPREDICTABLE | ||
91 | + # cases for MOVS/ORRS. We decode the MVE cases first, ensuring that | ||
92 | + # they explicitly call unallocated_encoding() for cases that must UNDEF | ||
93 | + # (eg "using a new shift insn on a v8.1M CPU without MVE"), and letting | ||
94 | + # the rest fall through (where ORR_rrri and MOV_rxri will end up | ||
95 | + # handling them as r13 and r15 accesses with the same semantics as A32). | ||
96 | + [ | ||
97 | + LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
98 | + LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
99 | + ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
100 | + | ||
101 | + UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
102 | + URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
103 | + SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
104 | + SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
105 | + ] | ||
106 | + | ||
107 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi | ||
108 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi | ||
109 | } | ||
110 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/target/arm/mve_helper.c | ||
113 | +++ b/target/arm/mve_helper.c | ||
114 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
115 | mve_advance_vpt(env); | ||
116 | return rdm; | ||
117 | } | ||
118 | + | ||
119 | +uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
120 | +{ | ||
121 | + return do_sqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
122 | +} | ||
123 | + | ||
124 | +uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
125 | +{ | ||
126 | + return do_uqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
127 | +} | ||
17 | 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 |
18 | index XXXXXXX..XXXXXXX 100644 | 129 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate.c | 130 | --- a/target/arm/translate.c |
20 | +++ b/target/arm/translate.c | 131 | +++ b/target/arm/translate.c |
21 | @@ -XXX,XX +XXX,XX @@ static bool op_store_rr(DisasContext *s, arg_ldst_rr *a, | 132 | @@ -XXX,XX +XXX,XX @@ static bool trans_MOVT(DisasContext *s, arg_MOVW *a) |
22 | ISSInfo issinfo = make_issinfo(s, a->rt, a->p, a->w) | ISSIsWrite; | 133 | return true; |
23 | TCGv_i32 addr, tmp; | 134 | } |
24 | 135 | ||
25 | + /* | 136 | +/* |
26 | + * In Thumb encodings of stores Rn=1111 is UNDEF; for Arm it | 137 | + * v8.1M MVE wide-shifts |
27 | + * is either UNPREDICTABLE or has defined behaviour | 138 | + */ |
28 | + */ | 139 | +static bool do_mve_shl_ri(DisasContext *s, arg_mve_shl_ri *a, |
29 | + if (s->thumb && a->rn == 15) { | 140 | + WideShiftImmFn *fn) |
141 | +{ | ||
142 | + TCGv_i64 rda; | ||
143 | + TCGv_i32 rdalo, rdahi; | ||
144 | + | ||
145 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
146 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
30 | + return false; | 147 | + return false; |
31 | + } | 148 | + } |
32 | + | 149 | + if (a->rdahi == 15) { |
33 | addr = op_addr_rr_pre(s, a); | 150 | + /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */ |
34 | |||
35 | tmp = load_reg(s, a->rt); | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool op_store_ri(DisasContext *s, arg_ldst_ri *a, | ||
37 | ISSInfo issinfo = make_issinfo(s, a->rt, a->p, a->w) | ISSIsWrite; | ||
38 | TCGv_i32 addr, tmp; | ||
39 | |||
40 | + /* | ||
41 | + * In Thumb encodings of stores Rn=1111 is UNDEF; for Arm it | ||
42 | + * is either UNPREDICTABLE or has defined behaviour | ||
43 | + */ | ||
44 | + if (s->thumb && a->rn == 15) { | ||
45 | + return false; | 151 | + return false; |
46 | + } | 152 | + } |
47 | + | 153 | + if (!dc_isar_feature(aa32_mve, s) || |
48 | addr = op_addr_ri_pre(s, a); | 154 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || |
49 | 155 | + a->rdahi == 13) { | |
50 | tmp = load_reg(s, a->rt); | 156 | + /* RdaHi == 13 is UNPREDICTABLE; we choose to UNDEF */ |
157 | + unallocated_encoding(s); | ||
158 | + return true; | ||
159 | + } | ||
160 | + | ||
161 | + if (a->shim == 0) { | ||
162 | + a->shim = 32; | ||
163 | + } | ||
164 | + | ||
165 | + rda = tcg_temp_new_i64(); | ||
166 | + rdalo = load_reg(s, a->rdalo); | ||
167 | + rdahi = load_reg(s, a->rdahi); | ||
168 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | ||
169 | + | ||
170 | + fn(rda, rda, a->shim); | ||
171 | + | ||
172 | + tcg_gen_extrl_i64_i32(rdalo, rda); | ||
173 | + tcg_gen_extrh_i64_i32(rdahi, rda); | ||
174 | + store_reg(s, a->rdalo, rdalo); | ||
175 | + store_reg(s, a->rdahi, rdahi); | ||
176 | + tcg_temp_free_i64(rda); | ||
177 | + | ||
178 | + return true; | ||
179 | +} | ||
180 | + | ||
181 | +static bool trans_ASRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
182 | +{ | ||
183 | + return do_mve_shl_ri(s, a, tcg_gen_sari_i64); | ||
184 | +} | ||
185 | + | ||
186 | +static bool trans_LSLL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
187 | +{ | ||
188 | + return do_mve_shl_ri(s, a, tcg_gen_shli_i64); | ||
189 | +} | ||
190 | + | ||
191 | +static bool trans_LSRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
192 | +{ | ||
193 | + return do_mve_shl_ri(s, a, tcg_gen_shri_i64); | ||
194 | +} | ||
195 | + | ||
196 | +static void gen_mve_sqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) | ||
197 | +{ | ||
198 | + gen_helper_mve_sqshll(r, cpu_env, n, tcg_constant_i32(shift)); | ||
199 | +} | ||
200 | + | ||
201 | +static bool trans_SQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
202 | +{ | ||
203 | + return do_mve_shl_ri(s, a, gen_mve_sqshll); | ||
204 | +} | ||
205 | + | ||
206 | +static void gen_mve_uqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) | ||
207 | +{ | ||
208 | + gen_helper_mve_uqshll(r, cpu_env, n, tcg_constant_i32(shift)); | ||
209 | +} | ||
210 | + | ||
211 | +static bool trans_UQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
212 | +{ | ||
213 | + return do_mve_shl_ri(s, a, gen_mve_uqshll); | ||
214 | +} | ||
215 | + | ||
216 | +static bool trans_SRSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
217 | +{ | ||
218 | + return do_mve_shl_ri(s, a, gen_srshr64_i64); | ||
219 | +} | ||
220 | + | ||
221 | +static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
222 | +{ | ||
223 | + return do_mve_shl_ri(s, a, gen_urshr64_i64); | ||
224 | +} | ||
225 | + | ||
226 | /* | ||
227 | * Multiply and multiply accumulate | ||
228 | */ | ||
51 | -- | 229 | -- |
52 | 2.20.1 | 230 | 2.20.1 |
53 | 231 | ||
54 | 232 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | We were incorrectly assuming that only the first byte of an MTE access | ||
4 | is checked against the tags. But per the ARM, unaligned accesses are | ||
5 | pre-decomposed into single-byte accesses. So by the time we reach the | ||
6 | actual MTE check in the ARM pseudocode, all accesses are aligned. | ||
7 | |||
8 | Therefore, the first failure is always either the first byte of the | ||
9 | access, or the first byte of the granule. | ||
10 | |||
11 | In addition, some of the arithmetic is off for last-first -> count. | ||
12 | This does not become directly visible until a later patch that passes | ||
13 | single bytes into this function, so ptr == ptr_last. | ||
14 | |||
15 | Buglink: https://bugs.launchpad.net/bugs/1921948 | ||
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20210416183106.1516563-2-richard.henderson@linaro.org | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | [PMM: tweaked a comment] | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | --- | ||
22 | target/arm/mte_helper.c | 40 ++++++++++++++++++---------------------- | ||
23 | 1 file changed, 18 insertions(+), 22 deletions(-) | ||
24 | |||
25 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/mte_helper.c | ||
28 | +++ b/target/arm/mte_helper.c | ||
29 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
30 | uint64_t ptr, uintptr_t ra) | ||
31 | { | ||
32 | int mmu_idx, ptr_tag, bit55; | ||
33 | - uint64_t ptr_last, ptr_end, prev_page, next_page; | ||
34 | - uint64_t tag_first, tag_end; | ||
35 | - uint64_t tag_byte_first, tag_byte_end; | ||
36 | - uint32_t esize, total, tag_count, tag_size, n, c; | ||
37 | + uint64_t ptr_last, prev_page, next_page; | ||
38 | + uint64_t tag_first, tag_last; | ||
39 | + uint64_t tag_byte_first, tag_byte_last; | ||
40 | + uint32_t total, tag_count, tag_size, n, c; | ||
41 | uint8_t *mem1, *mem2; | ||
42 | MMUAccessType type; | ||
43 | |||
44 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
45 | |||
46 | mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX); | ||
47 | type = FIELD_EX32(desc, MTEDESC, WRITE) ? MMU_DATA_STORE : MMU_DATA_LOAD; | ||
48 | - esize = FIELD_EX32(desc, MTEDESC, ESIZE); | ||
49 | total = FIELD_EX32(desc, MTEDESC, TSIZE); | ||
50 | |||
51 | - /* Find the addr of the end of the access, and of the last element. */ | ||
52 | - ptr_end = ptr + total; | ||
53 | - ptr_last = ptr_end - esize; | ||
54 | + /* Find the addr of the end of the access */ | ||
55 | + ptr_last = ptr + total - 1; | ||
56 | |||
57 | /* Round the bounds to the tag granule, and compute the number of tags. */ | ||
58 | tag_first = QEMU_ALIGN_DOWN(ptr, TAG_GRANULE); | ||
59 | - tag_end = QEMU_ALIGN_UP(ptr_last, TAG_GRANULE); | ||
60 | - tag_count = (tag_end - tag_first) / TAG_GRANULE; | ||
61 | + tag_last = QEMU_ALIGN_DOWN(ptr_last, TAG_GRANULE); | ||
62 | + tag_count = ((tag_last - tag_first) / TAG_GRANULE) + 1; | ||
63 | |||
64 | /* Round the bounds to twice the tag granule, and compute the bytes. */ | ||
65 | tag_byte_first = QEMU_ALIGN_DOWN(ptr, 2 * TAG_GRANULE); | ||
66 | - tag_byte_end = QEMU_ALIGN_UP(ptr_last, 2 * TAG_GRANULE); | ||
67 | + tag_byte_last = QEMU_ALIGN_DOWN(ptr_last, 2 * TAG_GRANULE); | ||
68 | |||
69 | /* Locate the page boundaries. */ | ||
70 | prev_page = ptr & TARGET_PAGE_MASK; | ||
71 | next_page = prev_page + TARGET_PAGE_SIZE; | ||
72 | |||
73 | - if (likely(tag_end - prev_page <= TARGET_PAGE_SIZE)) { | ||
74 | + if (likely(tag_last - prev_page <= TARGET_PAGE_SIZE)) { | ||
75 | /* Memory access stays on one page. */ | ||
76 | - tag_size = (tag_byte_end - tag_byte_first) / (2 * TAG_GRANULE); | ||
77 | + tag_size = ((tag_byte_last - tag_byte_first) / (2 * TAG_GRANULE)) + 1; | ||
78 | mem1 = allocation_tag_mem(env, mmu_idx, ptr, type, total, | ||
79 | MMU_DATA_LOAD, tag_size, ra); | ||
80 | if (!mem1) { | ||
81 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
82 | mem1 = allocation_tag_mem(env, mmu_idx, ptr, type, next_page - ptr, | ||
83 | MMU_DATA_LOAD, tag_size, ra); | ||
84 | |||
85 | - tag_size = (tag_byte_end - next_page) / (2 * TAG_GRANULE); | ||
86 | + tag_size = ((tag_byte_last - next_page) / (2 * TAG_GRANULE)) + 1; | ||
87 | mem2 = allocation_tag_mem(env, mmu_idx, next_page, type, | ||
88 | - ptr_end - next_page, | ||
89 | + ptr_last - next_page + 1, | ||
90 | MMU_DATA_LOAD, tag_size, ra); | ||
91 | |||
92 | /* | ||
93 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | - * If we failed, we know which granule. Compute the element that | ||
98 | - * is first in that granule, and signal failure on that element. | ||
99 | + * If we failed, we know which granule. For the first granule, the | ||
100 | + * failure address is @ptr, the first byte accessed. Otherwise the | ||
101 | + * failure address is the first byte of the nth granule. | ||
102 | */ | ||
103 | if (unlikely(n < tag_count)) { | ||
104 | - uint64_t fail_ofs; | ||
105 | - | ||
106 | - fail_ofs = tag_first + n * TAG_GRANULE - ptr; | ||
107 | - fail_ofs = ROUND_UP(fail_ofs, esize); | ||
108 | - mte_check_fail(env, desc, ptr + fail_ofs, ra); | ||
109 | + uint64_t fault = (n == 0 ? ptr : tag_first + n * TAG_GRANULE); | ||
110 | + mte_check_fail(env, desc, fault, ra); | ||
111 | } | ||
112 | |||
113 | done: | ||
114 | -- | ||
115 | 2.20.1 | ||
116 | |||
117 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | After recent changes, mte_checkN does not use ESIZE, | ||
4 | and mte_check1 never used TSIZE. We can combine the | ||
5 | two into a single field: SIZEM1. | ||
6 | |||
7 | Choose to pass size - 1 because size == 0 is never used, | ||
8 | our immediate need in mte_probe_int is for the address | ||
9 | of the last byte (ptr + size - 1), and since almost all | ||
10 | operations are powers of 2, this makes the immediate | ||
11 | constant one bit smaller. | ||
12 | |||
13 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20210416183106.1516563-6-richard.henderson@linaro.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | target/arm/internals.h | 4 ++-- | ||
19 | target/arm/mte_helper.c | 18 ++++++++---------- | ||
20 | target/arm/translate-a64.c | 5 ++--- | ||
21 | target/arm/translate-sve.c | 5 ++--- | ||
22 | 4 files changed, 14 insertions(+), 18 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/internals.h | ||
27 | +++ b/target/arm/internals.h | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | #define TARGET_ARM_INTERNALS_H | ||
30 | |||
31 | #include "hw/registerfields.h" | ||
32 | +#include "tcg/tcg-gvec-desc.h" | ||
33 | #include "syndrome.h" | ||
34 | |||
35 | /* register banks for CPU modes */ | ||
36 | @@ -XXX,XX +XXX,XX @@ FIELD(MTEDESC, MIDX, 0, 4) | ||
37 | FIELD(MTEDESC, TBI, 4, 2) | ||
38 | FIELD(MTEDESC, TCMA, 6, 2) | ||
39 | FIELD(MTEDESC, WRITE, 8, 1) | ||
40 | -FIELD(MTEDESC, ESIZE, 9, 5) | ||
41 | -FIELD(MTEDESC, TSIZE, 14, 10) /* mte_checkN only */ | ||
42 | +FIELD(MTEDESC, SIZEM1, 9, SIMD_DATA_BITS - 9) /* size - 1 */ | ||
43 | |||
44 | bool mte_probe1(CPUARMState *env, uint32_t desc, uint64_t ptr); | ||
45 | uint64_t mte_check1(CPUARMState *env, uint32_t desc, | ||
46 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mte_helper.c | ||
49 | +++ b/target/arm/mte_helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static int checkN(uint8_t *mem, int odd, int cmp, int count) | ||
51 | * Return positive on success with tbi enabled. | ||
52 | */ | ||
53 | static int mte_probe_int(CPUARMState *env, uint32_t desc, uint64_t ptr, | ||
54 | - uintptr_t ra, uint32_t total, uint64_t *fault) | ||
55 | + uintptr_t ra, uint64_t *fault) | ||
56 | { | ||
57 | int mmu_idx, ptr_tag, bit55; | ||
58 | uint64_t ptr_last, prev_page, next_page; | ||
59 | uint64_t tag_first, tag_last; | ||
60 | uint64_t tag_byte_first, tag_byte_last; | ||
61 | - uint32_t tag_count, tag_size, n, c; | ||
62 | + uint32_t sizem1, tag_count, tag_size, n, c; | ||
63 | uint8_t *mem1, *mem2; | ||
64 | MMUAccessType type; | ||
65 | |||
66 | @@ -XXX,XX +XXX,XX @@ static int mte_probe_int(CPUARMState *env, uint32_t desc, uint64_t ptr, | ||
67 | |||
68 | mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX); | ||
69 | type = FIELD_EX32(desc, MTEDESC, WRITE) ? MMU_DATA_STORE : MMU_DATA_LOAD; | ||
70 | + sizem1 = FIELD_EX32(desc, MTEDESC, SIZEM1); | ||
71 | |||
72 | /* Find the addr of the end of the access */ | ||
73 | - ptr_last = ptr + total - 1; | ||
74 | + ptr_last = ptr + sizem1; | ||
75 | |||
76 | /* Round the bounds to the tag granule, and compute the number of tags. */ | ||
77 | tag_first = QEMU_ALIGN_DOWN(ptr, TAG_GRANULE); | ||
78 | @@ -XXX,XX +XXX,XX @@ static int mte_probe_int(CPUARMState *env, uint32_t desc, uint64_t ptr, | ||
79 | if (likely(tag_last - prev_page <= TARGET_PAGE_SIZE)) { | ||
80 | /* Memory access stays on one page. */ | ||
81 | tag_size = ((tag_byte_last - tag_byte_first) / (2 * TAG_GRANULE)) + 1; | ||
82 | - mem1 = allocation_tag_mem(env, mmu_idx, ptr, type, total, | ||
83 | + mem1 = allocation_tag_mem(env, mmu_idx, ptr, type, sizem1 + 1, | ||
84 | MMU_DATA_LOAD, tag_size, ra); | ||
85 | if (!mem1) { | ||
86 | return 1; | ||
87 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
88 | uint64_t ptr, uintptr_t ra) | ||
89 | { | ||
90 | uint64_t fault; | ||
91 | - uint32_t total = FIELD_EX32(desc, MTEDESC, TSIZE); | ||
92 | - int ret = mte_probe_int(env, desc, ptr, ra, total, &fault); | ||
93 | + int ret = mte_probe_int(env, desc, ptr, ra, &fault); | ||
94 | |||
95 | if (unlikely(ret == 0)) { | ||
96 | mte_check_fail(env, desc, fault, ra); | ||
97 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_check1(CPUARMState *env, uint32_t desc, | ||
98 | uint64_t ptr, uintptr_t ra) | ||
99 | { | ||
100 | uint64_t fault; | ||
101 | - uint32_t total = FIELD_EX32(desc, MTEDESC, ESIZE); | ||
102 | - int ret = mte_probe_int(env, desc, ptr, ra, total, &fault); | ||
103 | + int ret = mte_probe_int(env, desc, ptr, ra, &fault); | ||
104 | |||
105 | if (unlikely(ret == 0)) { | ||
106 | mte_check_fail(env, desc, fault, ra); | ||
107 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mte_check1)(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
108 | bool mte_probe1(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
109 | { | ||
110 | uint64_t fault; | ||
111 | - uint32_t total = FIELD_EX32(desc, MTEDESC, ESIZE); | ||
112 | - int ret = mte_probe_int(env, desc, ptr, 0, total, &fault); | ||
113 | + int ret = mte_probe_int(env, desc, ptr, 0, &fault); | ||
114 | |||
115 | return ret != 0; | ||
116 | } | ||
117 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
118 | index XXXXXXX..XXXXXXX 100644 | ||
119 | --- a/target/arm/translate-a64.c | ||
120 | +++ b/target/arm/translate-a64.c | ||
121 | @@ -XXX,XX +XXX,XX @@ static TCGv_i64 gen_mte_check1_mmuidx(DisasContext *s, TCGv_i64 addr, | ||
122 | desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); | ||
123 | desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); | ||
124 | desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); | ||
125 | - desc = FIELD_DP32(desc, MTEDESC, ESIZE, 1 << log2_size); | ||
126 | + desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (1 << log2_size) - 1); | ||
127 | tcg_desc = tcg_const_i32(desc); | ||
128 | |||
129 | ret = new_tmp_a64(s); | ||
130 | @@ -XXX,XX +XXX,XX @@ TCGv_i64 gen_mte_checkN(DisasContext *s, TCGv_i64 addr, bool is_write, | ||
131 | desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); | ||
132 | desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); | ||
133 | desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); | ||
134 | - desc = FIELD_DP32(desc, MTEDESC, ESIZE, 1 << log2_esize); | ||
135 | - desc = FIELD_DP32(desc, MTEDESC, TSIZE, total_size); | ||
136 | + desc = FIELD_DP32(desc, MTEDESC, SIZEM1, total_size - 1); | ||
137 | tcg_desc = tcg_const_i32(desc); | ||
138 | |||
139 | ret = new_tmp_a64(s); | ||
140 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/target/arm/translate-sve.c | ||
143 | +++ b/target/arm/translate-sve.c | ||
144 | @@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | ||
145 | desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); | ||
146 | desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); | ||
147 | desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); | ||
148 | - desc = FIELD_DP32(desc, MTEDESC, ESIZE, 1 << msz); | ||
149 | - desc = FIELD_DP32(desc, MTEDESC, TSIZE, mte_n << msz); | ||
150 | + desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (mte_n << msz) - 1); | ||
151 | desc <<= SVE_MTEDESC_SHIFT; | ||
152 | } else { | ||
153 | addr = clean_data_tbi(s, addr); | ||
154 | @@ -XXX,XX +XXX,XX @@ static void do_mem_zpz(DisasContext *s, int zt, int pg, int zm, | ||
155 | desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); | ||
156 | desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); | ||
157 | desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); | ||
158 | - desc = FIELD_DP32(desc, MTEDESC, ESIZE, 1 << msz); | ||
159 | + desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (1 << msz) - 1); | ||
160 | desc <<= SVE_MTEDESC_SHIFT; | ||
161 | } | ||
162 | desc = simd_desc(vsz, vsz, desc | scale); | ||
163 | -- | ||
164 | 2.20.1 | ||
165 | |||
166 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | The mte_check1 and mte_checkN functions are now identical. | ||
4 | Drop mte_check1 and rename mte_checkN to mte_check. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210416183106.1516563-7-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper-a64.h | 3 +-- | ||
12 | target/arm/internals.h | 5 +---- | ||
13 | target/arm/mte_helper.c | 26 +++----------------------- | ||
14 | target/arm/sve_helper.c | 14 +++++++------- | ||
15 | target/arm/translate-a64.c | 4 ++-- | ||
16 | 5 files changed, 14 insertions(+), 38 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper-a64.h | ||
21 | +++ b/target/arm/helper-a64.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(autdb, TCG_CALL_NO_WG, i64, env, i64, i64) | ||
23 | DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64) | ||
24 | DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64) | ||
25 | |||
26 | -DEF_HELPER_FLAGS_3(mte_check1, TCG_CALL_NO_WG, i64, env, i32, i64) | ||
27 | -DEF_HELPER_FLAGS_3(mte_checkN, TCG_CALL_NO_WG, i64, env, i32, i64) | ||
28 | +DEF_HELPER_FLAGS_3(mte_check, TCG_CALL_NO_WG, i64, env, i32, i64) | ||
29 | DEF_HELPER_FLAGS_3(mte_check_zva, TCG_CALL_NO_WG, i64, env, i32, i64) | ||
30 | DEF_HELPER_FLAGS_3(irg, TCG_CALL_NO_RWG, i64, env, i64, i64) | ||
31 | DEF_HELPER_FLAGS_4(addsubg, TCG_CALL_NO_RWG_SE, i64, env, i64, s32, i32) | ||
32 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/internals.h | ||
35 | +++ b/target/arm/internals.h | ||
36 | @@ -XXX,XX +XXX,XX @@ FIELD(MTEDESC, WRITE, 8, 1) | ||
37 | FIELD(MTEDESC, SIZEM1, 9, SIMD_DATA_BITS - 9) /* size - 1 */ | ||
38 | |||
39 | bool mte_probe1(CPUARMState *env, uint32_t desc, uint64_t ptr); | ||
40 | -uint64_t mte_check1(CPUARMState *env, uint32_t desc, | ||
41 | - uint64_t ptr, uintptr_t ra); | ||
42 | -uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
43 | - uint64_t ptr, uintptr_t ra); | ||
44 | +uint64_t mte_check(CPUARMState *env, uint32_t desc, uint64_t ptr, uintptr_t ra); | ||
45 | |||
46 | static inline int allocation_tag_from_addr(uint64_t ptr) | ||
47 | { | ||
48 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/mte_helper.c | ||
51 | +++ b/target/arm/mte_helper.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static int mte_probe_int(CPUARMState *env, uint32_t desc, uint64_t ptr, | ||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | -uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
57 | - uint64_t ptr, uintptr_t ra) | ||
58 | +uint64_t mte_check(CPUARMState *env, uint32_t desc, uint64_t ptr, uintptr_t ra) | ||
59 | { | ||
60 | uint64_t fault; | ||
61 | int ret = mte_probe_int(env, desc, ptr, ra, &fault); | ||
62 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
63 | return useronly_clean_ptr(ptr); | ||
64 | } | ||
65 | |||
66 | -uint64_t HELPER(mte_checkN)(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
67 | +uint64_t HELPER(mte_check)(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
68 | { | ||
69 | - return mte_checkN(env, desc, ptr, GETPC()); | ||
70 | -} | ||
71 | - | ||
72 | -uint64_t mte_check1(CPUARMState *env, uint32_t desc, | ||
73 | - uint64_t ptr, uintptr_t ra) | ||
74 | -{ | ||
75 | - uint64_t fault; | ||
76 | - int ret = mte_probe_int(env, desc, ptr, ra, &fault); | ||
77 | - | ||
78 | - if (unlikely(ret == 0)) { | ||
79 | - mte_check_fail(env, desc, fault, ra); | ||
80 | - } else if (ret < 0) { | ||
81 | - return ptr; | ||
82 | - } | ||
83 | - return useronly_clean_ptr(ptr); | ||
84 | -} | ||
85 | - | ||
86 | -uint64_t HELPER(mte_check1)(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
87 | -{ | ||
88 | - return mte_check1(env, desc, ptr, GETPC()); | ||
89 | + return mte_check(env, desc, ptr, GETPC()); | ||
90 | } | ||
91 | |||
92 | /* | ||
93 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/sve_helper.c | ||
96 | +++ b/target/arm/sve_helper.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static void sve_cont_ldst_mte_check1(SVEContLdSt *info, CPUARMState *env, | ||
98 | uintptr_t ra) | ||
99 | { | ||
100 | sve_cont_ldst_mte_check_int(info, env, vg, addr, esize, msize, | ||
101 | - mtedesc, ra, mte_check1); | ||
102 | + mtedesc, ra, mte_check); | ||
103 | } | ||
104 | |||
105 | static void sve_cont_ldst_mte_checkN(SVEContLdSt *info, CPUARMState *env, | ||
106 | @@ -XXX,XX +XXX,XX @@ static void sve_cont_ldst_mte_checkN(SVEContLdSt *info, CPUARMState *env, | ||
107 | uintptr_t ra) | ||
108 | { | ||
109 | sve_cont_ldst_mte_check_int(info, env, vg, addr, esize, msize, | ||
110 | - mtedesc, ra, mte_checkN); | ||
111 | + mtedesc, ra, mte_check); | ||
112 | } | ||
113 | |||
114 | |||
115 | @@ -XXX,XX +XXX,XX @@ void sve_ldnfff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
116 | if (fault == FAULT_FIRST) { | ||
117 | /* Trapping mte check for the first-fault element. */ | ||
118 | if (mtedesc) { | ||
119 | - mte_check1(env, mtedesc, addr + mem_off, retaddr); | ||
120 | + mte_check(env, mtedesc, addr + mem_off, retaddr); | ||
121 | } | ||
122 | |||
123 | /* | ||
124 | @@ -XXX,XX +XXX,XX @@ void sve_ld1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, | ||
125 | info.attrs, BP_MEM_READ, retaddr); | ||
126 | } | ||
127 | if (mtedesc && arm_tlb_mte_tagged(&info.attrs)) { | ||
128 | - mte_check1(env, mtedesc, addr, retaddr); | ||
129 | + mte_check(env, mtedesc, addr, retaddr); | ||
130 | } | ||
131 | host_fn(&scratch, reg_off, info.host); | ||
132 | } else { | ||
133 | @@ -XXX,XX +XXX,XX @@ void sve_ld1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, | ||
134 | BP_MEM_READ, retaddr); | ||
135 | } | ||
136 | if (mtedesc && arm_tlb_mte_tagged(&info.attrs)) { | ||
137 | - mte_check1(env, mtedesc, addr, retaddr); | ||
138 | + mte_check(env, mtedesc, addr, retaddr); | ||
139 | } | ||
140 | tlb_fn(env, &scratch, reg_off, addr, retaddr); | ||
141 | } | ||
142 | @@ -XXX,XX +XXX,XX @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, | ||
143 | */ | ||
144 | addr = base + (off_fn(vm, reg_off) << scale); | ||
145 | if (mtedesc) { | ||
146 | - mte_check1(env, mtedesc, addr, retaddr); | ||
147 | + mte_check(env, mtedesc, addr, retaddr); | ||
148 | } | ||
149 | tlb_fn(env, vd, reg_off, addr, retaddr); | ||
150 | |||
151 | @@ -XXX,XX +XXX,XX @@ void sve_st1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, | ||
152 | } | ||
153 | |||
154 | if (mtedesc && arm_tlb_mte_tagged(&info.attrs)) { | ||
155 | - mte_check1(env, mtedesc, addr, retaddr); | ||
156 | + mte_check(env, mtedesc, addr, retaddr); | ||
157 | } | ||
158 | } | ||
159 | i += 1; | ||
160 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
161 | index XXXXXXX..XXXXXXX 100644 | ||
162 | --- a/target/arm/translate-a64.c | ||
163 | +++ b/target/arm/translate-a64.c | ||
164 | @@ -XXX,XX +XXX,XX @@ static TCGv_i64 gen_mte_check1_mmuidx(DisasContext *s, TCGv_i64 addr, | ||
165 | tcg_desc = tcg_const_i32(desc); | ||
166 | |||
167 | ret = new_tmp_a64(s); | ||
168 | - gen_helper_mte_check1(ret, cpu_env, tcg_desc, addr); | ||
169 | + gen_helper_mte_check(ret, cpu_env, tcg_desc, addr); | ||
170 | tcg_temp_free_i32(tcg_desc); | ||
171 | |||
172 | return ret; | ||
173 | @@ -XXX,XX +XXX,XX @@ TCGv_i64 gen_mte_checkN(DisasContext *s, TCGv_i64 addr, bool is_write, | ||
174 | tcg_desc = tcg_const_i32(desc); | ||
175 | |||
176 | ret = new_tmp_a64(s); | ||
177 | - gen_helper_mte_checkN(ret, cpu_env, tcg_desc, addr); | ||
178 | + gen_helper_mte_check(ret, cpu_env, tcg_desc, addr); | ||
179 | tcg_temp_free_i32(tcg_desc); | ||
180 | |||
181 | return ret; | ||
182 | -- | ||
183 | 2.20.1 | ||
184 | |||
185 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | For consistency with the mte_check1 + mte_checkN merge | ||
4 | to mte_check, rename the probe function as well. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210416183106.1516563-8-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/internals.h | 2 +- | ||
12 | target/arm/mte_helper.c | 6 +++--- | ||
13 | target/arm/sve_helper.c | 6 +++--- | ||
14 | 3 files changed, 7 insertions(+), 7 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/internals.h | ||
19 | +++ b/target/arm/internals.h | ||
20 | @@ -XXX,XX +XXX,XX @@ FIELD(MTEDESC, TCMA, 6, 2) | ||
21 | FIELD(MTEDESC, WRITE, 8, 1) | ||
22 | FIELD(MTEDESC, SIZEM1, 9, SIMD_DATA_BITS - 9) /* size - 1 */ | ||
23 | |||
24 | -bool mte_probe1(CPUARMState *env, uint32_t desc, uint64_t ptr); | ||
25 | +bool mte_probe(CPUARMState *env, uint32_t desc, uint64_t ptr); | ||
26 | uint64_t mte_check(CPUARMState *env, uint32_t desc, uint64_t ptr, uintptr_t ra); | ||
27 | |||
28 | static inline int allocation_tag_from_addr(uint64_t ptr) | ||
29 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mte_helper.c | ||
32 | +++ b/target/arm/mte_helper.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, | ||
34 | * exception for inaccessible pages, and resolves the virtual address | ||
35 | * into the softmmu tlb. | ||
36 | * | ||
37 | - * When RA == 0, this is for mte_probe1. The page is expected to be | ||
38 | + * When RA == 0, this is for mte_probe. The page is expected to be | ||
39 | * valid. Indicate to probe_access_flags no-fault, then assert that | ||
40 | * we received a valid page. | ||
41 | */ | ||
42 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mte_check)(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
43 | } | ||
44 | |||
45 | /* | ||
46 | - * No-fault version of mte_check1, to be used by SVE for MemSingleNF. | ||
47 | + * No-fault version of mte_check, to be used by SVE for MemSingleNF. | ||
48 | * Returns false if the access is Checked and the check failed. This | ||
49 | * is only intended to probe the tag -- the validity of the page must | ||
50 | * be checked beforehand. | ||
51 | */ | ||
52 | -bool mte_probe1(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
53 | +bool mte_probe(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
54 | { | ||
55 | uint64_t fault; | ||
56 | int ret = mte_probe_int(env, desc, ptr, 0, &fault); | ||
57 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/target/arm/sve_helper.c | ||
60 | +++ b/target/arm/sve_helper.c | ||
61 | @@ -XXX,XX +XXX,XX @@ void sve_ldnfff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
62 | /* Watchpoint hit, see below. */ | ||
63 | goto do_fault; | ||
64 | } | ||
65 | - if (mtedesc && !mte_probe1(env, mtedesc, addr + mem_off)) { | ||
66 | + if (mtedesc && !mte_probe(env, mtedesc, addr + mem_off)) { | ||
67 | goto do_fault; | ||
68 | } | ||
69 | /* | ||
70 | @@ -XXX,XX +XXX,XX @@ void sve_ldnfff1_r(CPUARMState *env, void *vg, const target_ulong addr, | ||
71 | & BP_MEM_READ)) { | ||
72 | goto do_fault; | ||
73 | } | ||
74 | - if (mtedesc && !mte_probe1(env, mtedesc, addr + mem_off)) { | ||
75 | + if (mtedesc && !mte_probe(env, mtedesc, addr + mem_off)) { | ||
76 | goto do_fault; | ||
77 | } | ||
78 | host_fn(vd, reg_off, host + mem_off); | ||
79 | @@ -XXX,XX +XXX,XX @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, | ||
80 | } | ||
81 | if (mtedesc && | ||
82 | arm_tlb_mte_tagged(&info.attrs) && | ||
83 | - !mte_probe1(env, mtedesc, addr)) { | ||
84 | + !mte_probe(env, mtedesc, addr)) { | ||
85 | goto fault; | ||
86 | } | ||
87 | |||
88 | -- | ||
89 | 2.20.1 | ||
90 | |||
91 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | The log2_esize parameter is not used except trivially. | ||
4 | Drop the parameter and the deferral to gen_mte_check1. | ||
5 | |||
6 | This fixes a bug in that the parameters as documented | ||
7 | in the header file were the reverse from those in the | ||
8 | implementation. Which meant that translate-sve.c was | ||
9 | passing the parameters in the wrong order. | ||
10 | |||
11 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20210416183106.1516563-10-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | target/arm/translate-a64.h | 2 +- | ||
17 | target/arm/translate-a64.c | 15 +++++++-------- | ||
18 | target/arm/translate-sve.c | 4 ++-- | ||
19 | 3 files changed, 10 insertions(+), 11 deletions(-) | ||
20 | |||
21 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/target/arm/translate-a64.h | ||
24 | +++ b/target/arm/translate-a64.h | ||
25 | @@ -XXX,XX +XXX,XX @@ TCGv_i64 clean_data_tbi(DisasContext *s, TCGv_i64 addr); | ||
26 | TCGv_i64 gen_mte_check1(DisasContext *s, TCGv_i64 addr, bool is_write, | ||
27 | bool tag_checked, int log2_size); | ||
28 | TCGv_i64 gen_mte_checkN(DisasContext *s, TCGv_i64 addr, bool is_write, | ||
29 | - bool tag_checked, int count, int log2_esize); | ||
30 | + bool tag_checked, int size); | ||
31 | |||
32 | /* We should have at some point before trying to access an FP register | ||
33 | * done the necessary access check, so assert that | ||
34 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/translate-a64.c | ||
37 | +++ b/target/arm/translate-a64.c | ||
38 | @@ -XXX,XX +XXX,XX @@ TCGv_i64 gen_mte_check1(DisasContext *s, TCGv_i64 addr, bool is_write, | ||
39 | * For MTE, check multiple logical sequential accesses. | ||
40 | */ | ||
41 | TCGv_i64 gen_mte_checkN(DisasContext *s, TCGv_i64 addr, bool is_write, | ||
42 | - bool tag_checked, int log2_esize, int total_size) | ||
43 | + bool tag_checked, int size) | ||
44 | { | ||
45 | - if (tag_checked && s->mte_active[0] && total_size != (1 << log2_esize)) { | ||
46 | + if (tag_checked && s->mte_active[0]) { | ||
47 | TCGv_i32 tcg_desc; | ||
48 | TCGv_i64 ret; | ||
49 | int desc = 0; | ||
50 | @@ -XXX,XX +XXX,XX @@ TCGv_i64 gen_mte_checkN(DisasContext *s, TCGv_i64 addr, bool is_write, | ||
51 | desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); | ||
52 | desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); | ||
53 | desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); | ||
54 | - desc = FIELD_DP32(desc, MTEDESC, SIZEM1, total_size - 1); | ||
55 | + desc = FIELD_DP32(desc, MTEDESC, SIZEM1, size - 1); | ||
56 | tcg_desc = tcg_const_i32(desc); | ||
57 | |||
58 | ret = new_tmp_a64(s); | ||
59 | @@ -XXX,XX +XXX,XX @@ TCGv_i64 gen_mte_checkN(DisasContext *s, TCGv_i64 addr, bool is_write, | ||
60 | |||
61 | return ret; | ||
62 | } | ||
63 | - return gen_mte_check1(s, addr, is_write, tag_checked, log2_esize); | ||
64 | + return clean_data_tbi(s, addr); | ||
65 | } | ||
66 | |||
67 | typedef struct DisasCompare64 { | ||
68 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn) | ||
69 | } | ||
70 | |||
71 | clean_addr = gen_mte_checkN(s, dirty_addr, !is_load, | ||
72 | - (wback || rn != 31) && !set_tag, | ||
73 | - size, 2 << size); | ||
74 | + (wback || rn != 31) && !set_tag, 2 << size); | ||
75 | |||
76 | if (is_vector) { | ||
77 | if (is_load) { | ||
78 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
79 | * promote consecutive little-endian elements below. | ||
80 | */ | ||
81 | clean_addr = gen_mte_checkN(s, tcg_rn, is_store, is_postidx || rn != 31, | ||
82 | - size, total); | ||
83 | + total); | ||
84 | |||
85 | /* | ||
86 | * Consecutive little-endian elements from a single register | ||
87 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
88 | tcg_rn = cpu_reg_sp(s, rn); | ||
89 | |||
90 | clean_addr = gen_mte_checkN(s, tcg_rn, !is_load, is_postidx || rn != 31, | ||
91 | - scale, total); | ||
92 | + total); | ||
93 | |||
94 | tcg_ebytes = tcg_const_i64(1 << scale); | ||
95 | for (xs = 0; xs < selem; xs++) { | ||
96 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate-sve.c | ||
99 | +++ b/target/arm/translate-sve.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | ||
101 | |||
102 | dirty_addr = tcg_temp_new_i64(); | ||
103 | tcg_gen_addi_i64(dirty_addr, cpu_reg_sp(s, rn), imm); | ||
104 | - clean_addr = gen_mte_checkN(s, dirty_addr, false, rn != 31, len, MO_8); | ||
105 | + clean_addr = gen_mte_checkN(s, dirty_addr, false, rn != 31, len); | ||
106 | tcg_temp_free_i64(dirty_addr); | ||
107 | |||
108 | /* | ||
109 | @@ -XXX,XX +XXX,XX @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | ||
110 | |||
111 | dirty_addr = tcg_temp_new_i64(); | ||
112 | tcg_gen_addi_i64(dirty_addr, cpu_reg_sp(s, rn), imm); | ||
113 | - clean_addr = gen_mte_checkN(s, dirty_addr, false, rn != 31, len, MO_8); | ||
114 | + clean_addr = gen_mte_checkN(s, dirty_addr, false, rn != 31, len); | ||
115 | tcg_temp_free_i64(dirty_addr); | ||
116 | |||
117 | /* Note that unpredicated load/store of vector/predicate registers | ||
118 | -- | ||
119 | 2.20.1 | ||
120 | |||
121 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | The encoding of size = 2 and size = 3 had the incorrect decode | ||
4 | for align, overlapping the stride field. This error was hidden | ||
5 | by what should have been unnecessary masking in translate. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210419202257.161730-2-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/neon-ls.decode | 4 ++-- | ||
13 | target/arm/translate-neon.c.inc | 4 ++-- | ||
14 | 2 files changed, 4 insertions(+), 4 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/neon-ls.decode | ||
19 | +++ b/target/arm/neon-ls.decode | ||
20 | @@ -XXX,XX +XXX,XX @@ VLD_all_lanes 1111 0100 1 . 1 0 rn:4 .... 11 n:2 size:2 t:1 a:1 rm:4 \ | ||
21 | |||
22 | VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 00 n:2 reg_idx:3 align:1 rm:4 \ | ||
23 | vd=%vd_dp size=0 stride=1 | ||
24 | -VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 01 n:2 reg_idx:2 align:2 rm:4 \ | ||
25 | +VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 01 n:2 reg_idx:2 . align:1 rm:4 \ | ||
26 | vd=%vd_dp size=1 stride=%imm1_5_p1 | ||
27 | -VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 10 n:2 reg_idx:1 align:3 rm:4 \ | ||
28 | +VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 10 n:2 reg_idx:1 . align:2 rm:4 \ | ||
29 | vd=%vd_dp size=2 stride=%imm1_6_p1 | ||
30 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/translate-neon.c.inc | ||
33 | +++ b/target/arm/translate-neon.c.inc | ||
34 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | ||
35 | switch (nregs) { | ||
36 | case 1: | ||
37 | if (((a->align & (1 << a->size)) != 0) || | ||
38 | - (a->size == 2 && ((a->align & 3) == 1 || (a->align & 3) == 2))) { | ||
39 | + (a->size == 2 && (a->align == 1 || a->align == 2))) { | ||
40 | return false; | ||
41 | } | ||
42 | break; | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | ||
44 | } | ||
45 | break; | ||
46 | case 4: | ||
47 | - if ((a->size == 2) && ((a->align & 3) == 3)) { | ||
48 | + if (a->size == 2 && a->align == 3) { | ||
49 | return false; | ||
50 | } | ||
51 | break; | ||
52 | -- | ||
53 | 2.20.1 | ||
54 | |||
55 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | We're about to rearrange the macro expansion surrounding tbflags, | ||
4 | and this field name will be expanded using the bit definition of | ||
5 | the same name, resulting in a token pasting error. | ||
6 | |||
7 | So SCTLR_B -> SCTLR__B in the 3 uses, and document it. | ||
8 | |||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20210419202257.161730-3-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/cpu.h | 2 +- | ||
15 | target/arm/helper.c | 2 +- | ||
16 | target/arm/translate.c | 2 +- | ||
17 | 3 files changed, 3 insertions(+), 3 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/cpu.h | ||
22 | +++ b/target/arm/cpu.h | ||
23 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, VECSTRIDE, 12, 2) /* Not cached. */ | ||
24 | */ | ||
25 | FIELD(TBFLAG_A32, XSCALE_CPAR, 12, 2) | ||
26 | FIELD(TBFLAG_A32, VFPEN, 14, 1) /* Partially cached, minus FPEXC. */ | ||
27 | -FIELD(TBFLAG_A32, SCTLR_B, 15, 1) | ||
28 | +FIELD(TBFLAG_A32, SCTLR__B, 15, 1) /* Cannot overlap with SCTLR_B */ | ||
29 | FIELD(TBFLAG_A32, HSTR_ACTIVE, 16, 1) | ||
30 | /* | ||
31 | * Indicates whether cp register reads and writes by guest code should access | ||
32 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/helper.c | ||
35 | +++ b/target/arm/helper.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, | ||
37 | bool sctlr_b = arm_sctlr_b(env); | ||
38 | |||
39 | if (sctlr_b) { | ||
40 | - flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, 1); | ||
41 | + flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR__B, 1); | ||
42 | } | ||
43 | if (arm_cpu_data_is_big_endian_a32(env, sctlr_b)) { | ||
44 | flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); | ||
45 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/translate.c | ||
48 | +++ b/target/arm/translate.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
50 | FIELD_EX32(tb_flags, TBFLAG_ANY, BE_DATA) ? MO_BE : MO_LE; | ||
51 | dc->debug_target_el = | ||
52 | FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | ||
53 | - dc->sctlr_b = FIELD_EX32(tb_flags, TBFLAG_A32, SCTLR_B); | ||
54 | + dc->sctlr_b = FIELD_EX32(tb_flags, TBFLAG_A32, SCTLR__B); | ||
55 | dc->hstr_active = FIELD_EX32(tb_flags, TBFLAG_A32, HSTR_ACTIVE); | ||
56 | dc->ns = FIELD_EX32(tb_flags, TBFLAG_A32, NS); | ||
57 | dc->vfp_enabled = FIELD_EX32(tb_flags, TBFLAG_A32, VFPEN); | ||
58 | -- | ||
59 | 2.20.1 | ||
60 | |||
61 | 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 | In preparation for splitting tb->flags across multiple | 3 | the shift count in another general-purpose register, which might be |
4 | fields, introduce a structure to hold the value(s). | 4 | either positive or negative. |
5 | So far this only migrates the one uint32_t and fixes | 5 | |
6 | all of the places that require adjustment to match. | 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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Because LSLL_rr and ASRL_rr overlap with both MOV_rxri/ORR_rrri and |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | also with CSEL (as one of the previously-UNPREDICTABLE Rm==13 cases), |
10 | Message-id: 20210419202257.161730-6-richard.henderson@linaro.org | 10 | we have to move the CSEL pattern into the same decodetree group. |
11 | |||
11 | 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 | ||
12 | --- | 15 | --- |
13 | target/arm/cpu.h | 26 ++++++++++++--------- | 16 | target/arm/helper-mve.h | 6 +++ |
14 | target/arm/translate.h | 11 +++++++++ | 17 | target/arm/translate.h | 1 + |
15 | target/arm/helper.c | 48 +++++++++++++++++++++----------------- | 18 | target/arm/t32.decode | 16 +++++-- |
16 | target/arm/translate-a64.c | 2 +- | 19 | target/arm/mve_helper.c | 93 +++++++++++++++++++++++++++++++++++++++++ |
17 | target/arm/translate.c | 7 +++--- | 20 | target/arm/translate.c | 69 ++++++++++++++++++++++++++++++ |
18 | 5 files changed, 57 insertions(+), 37 deletions(-) | 21 | 5 files changed, 182 insertions(+), 3 deletions(-) |
19 | 22 | ||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 23 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
21 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 25 | --- a/target/arm/helper-mve.h |
23 | +++ b/target/arm/cpu.h | 26 | +++ b/target/arm/helper-mve.h |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMPACKey { | 27 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | } ARMPACKey; | 28 | |
26 | #endif | 29 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
27 | 30 | ||
28 | +/* See the commentary above the TBFLAG field definitions. */ | 31 | +DEF_HELPER_FLAGS_3(mve_sshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) |
29 | +typedef struct CPUARMTBFlags { | 32 | +DEF_HELPER_FLAGS_3(mve_ushll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
30 | + uint32_t flags; | 33 | DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
31 | +} CPUARMTBFlags; | 34 | DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
32 | 35 | +DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | |
33 | typedef struct CPUARMState { | 36 | +DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
34 | /* Regs for current mode. */ | 37 | +DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32) |
35 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 38 | +DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) |
36 | uint32_t aarch64; /* 1 if CPU is in aarch64 state; inverse of PSTATE.nRW */ | ||
37 | |||
38 | /* Cached TBFLAGS state. See below for which bits are included. */ | ||
39 | - uint32_t hflags; | ||
40 | + CPUARMTBFlags hflags; | ||
41 | |||
42 | /* Frequently accessed CPSR bits are stored separately for efficiency. | ||
43 | This contains all the other bits. Use cpsr_{read,write} to access | ||
44 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) | ||
45 | * Helpers for using the above. | ||
46 | */ | ||
47 | #define DP_TBFLAG_ANY(DST, WHICH, VAL) \ | ||
48 | - (DST = FIELD_DP32(DST, TBFLAG_ANY, WHICH, VAL)) | ||
49 | + (DST.flags = FIELD_DP32(DST.flags, TBFLAG_ANY, WHICH, VAL)) | ||
50 | #define DP_TBFLAG_A64(DST, WHICH, VAL) \ | ||
51 | - (DST = FIELD_DP32(DST, TBFLAG_A64, WHICH, VAL)) | ||
52 | + (DST.flags = FIELD_DP32(DST.flags, TBFLAG_A64, WHICH, VAL)) | ||
53 | #define DP_TBFLAG_A32(DST, WHICH, VAL) \ | ||
54 | - (DST = FIELD_DP32(DST, TBFLAG_A32, WHICH, VAL)) | ||
55 | + (DST.flags = FIELD_DP32(DST.flags, TBFLAG_A32, WHICH, VAL)) | ||
56 | #define DP_TBFLAG_M32(DST, WHICH, VAL) \ | ||
57 | - (DST = FIELD_DP32(DST, TBFLAG_M32, WHICH, VAL)) | ||
58 | + (DST.flags = FIELD_DP32(DST.flags, TBFLAG_M32, WHICH, VAL)) | ||
59 | #define DP_TBFLAG_AM32(DST, WHICH, VAL) \ | ||
60 | - (DST = FIELD_DP32(DST, TBFLAG_AM32, WHICH, VAL)) | ||
61 | + (DST.flags = FIELD_DP32(DST.flags, TBFLAG_AM32, WHICH, VAL)) | ||
62 | |||
63 | -#define EX_TBFLAG_ANY(IN, WHICH) FIELD_EX32(IN, TBFLAG_ANY, WHICH) | ||
64 | -#define EX_TBFLAG_A64(IN, WHICH) FIELD_EX32(IN, TBFLAG_A64, WHICH) | ||
65 | -#define EX_TBFLAG_A32(IN, WHICH) FIELD_EX32(IN, TBFLAG_A32, WHICH) | ||
66 | -#define EX_TBFLAG_M32(IN, WHICH) FIELD_EX32(IN, TBFLAG_M32, WHICH) | ||
67 | -#define EX_TBFLAG_AM32(IN, WHICH) FIELD_EX32(IN, TBFLAG_AM32, WHICH) | ||
68 | +#define EX_TBFLAG_ANY(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_ANY, WHICH) | ||
69 | +#define EX_TBFLAG_A64(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_A64, WHICH) | ||
70 | +#define EX_TBFLAG_A32(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_A32, WHICH) | ||
71 | +#define EX_TBFLAG_M32(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_M32, WHICH) | ||
72 | +#define EX_TBFLAG_AM32(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_AM32, WHICH) | ||
73 | |||
74 | /** | ||
75 | * cpu_mmu_index: | ||
76 | 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 |
77 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
78 | --- a/target/arm/translate.h | 41 | --- a/target/arm/translate.h |
79 | +++ b/target/arm/translate.h | 42 | +++ b/target/arm/translate.h |
80 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | 43 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); |
81 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | 44 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); |
82 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | 45 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); |
83 | 46 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | |
84 | +/** | 47 | +typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); |
85 | + * arm_tbflags_from_tb: | 48 | |
86 | + * @tb: the TranslationBlock | 49 | /** |
87 | + * | 50 | * arm_tbflags_from_tb: |
88 | + * Extract the flag values from @tb. | 51 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode |
89 | + */ | 52 | index XXXXXXX..XXXXXXX 100644 |
90 | +static inline CPUARMTBFlags arm_tbflags_from_tb(const TranslationBlock *tb) | 53 | --- a/target/arm/t32.decode |
91 | +{ | 54 | +++ b/target/arm/t32.decode |
92 | + return (CPUARMTBFlags){ tb->flags }; | 55 | @@ -XXX,XX +XXX,XX @@ |
93 | +} | 56 | &mcrr !extern cp opc1 crm rt rt2 |
94 | + | 57 | |
95 | /* | 58 | &mve_shl_ri rdalo rdahi shim |
96 | * Enum for argument to fpstatus_ptr(). | 59 | +&mve_shl_rr rdalo rdahi rm |
97 | */ | 60 | |
98 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 61 | # rdahi: bits [3:1] from insn, bit 0 is 1 |
99 | index XXXXXXX..XXXXXXX 100644 | 62 | # rdalo: bits [3:1] from insn, bit 0 is 0 |
100 | --- a/target/arm/helper.c | 63 | @@ -XXX,XX +XXX,XX @@ |
101 | +++ b/target/arm/helper.c | 64 | |
102 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | 65 | @mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ |
103 | } | 66 | &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 |
104 | #endif | 67 | +@mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \ |
105 | 68 | + &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | |
106 | -static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | 69 | |
107 | - ARMMMUIdx mmu_idx, uint32_t flags) | 70 | { |
108 | +static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el, | 71 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi |
109 | + ARMMMUIdx mmu_idx, | 72 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi |
110 | + CPUARMTBFlags flags) | 73 | URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri |
111 | { | 74 | SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri |
112 | DP_TBFLAG_ANY(flags, FPEXC_EL, fp_el); | 75 | SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri |
113 | DP_TBFLAG_ANY(flags, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); | 76 | + |
114 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | 77 | + LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr |
115 | return flags; | 78 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr |
116 | } | 79 | + UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr |
117 | 80 | + SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr | |
118 | -static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, | 81 | + UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr |
119 | - ARMMMUIdx mmu_idx, uint32_t flags) | 82 | + SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr |
120 | +static CPUARMTBFlags rebuild_hflags_common_32(CPUARMState *env, int fp_el, | 83 | ] |
121 | + ARMMMUIdx mmu_idx, | 84 | |
122 | + CPUARMTBFlags flags) | 85 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi |
123 | { | 86 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi |
124 | bool sctlr_b = arm_sctlr_b(env); | 87 | + |
125 | 88 | + # v8.1M CSEL and friends | |
126 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, | 89 | + CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 |
127 | return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | 90 | } |
128 | } | 91 | { |
129 | 92 | MVN_rxri 1110101 0011 . 1111 0 ... .... .... .... @s_rxr_shi | |
130 | -static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, | 93 | @@ -XXX,XX +XXX,XX @@ SBC_rrri 1110101 1011 . .... 0 ... .... .... .... @s_rrr_shi |
131 | - ARMMMUIdx mmu_idx) | 94 | } |
132 | +static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el, | 95 | RSB_rrri 1110101 1110 . .... 0 ... .... .... .... @s_rrr_shi |
133 | + ARMMMUIdx mmu_idx) | 96 | |
134 | { | 97 | -# v8.1M CSEL and friends |
135 | - uint32_t flags = 0; | 98 | -CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 |
136 | + CPUARMTBFlags flags = {}; | 99 | - |
137 | 100 | # Data-processing (register-shifted register) | |
138 | if (arm_v7m_is_handler_mode(env)) { | 101 | |
139 | DP_TBFLAG_M32(flags, HANDLER, 1); | 102 | MOV_rxrr 1111 1010 0 shty:2 s:1 rm:4 1111 rd:4 0000 rs:4 \ |
140 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, | 103 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
141 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | 104 | index XXXXXXX..XXXXXXX 100644 |
142 | } | 105 | --- a/target/arm/mve_helper.c |
143 | 106 | +++ b/target/arm/mve_helper.c | |
144 | -static uint32_t rebuild_hflags_aprofile(CPUARMState *env) | 107 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, |
145 | +static CPUARMTBFlags rebuild_hflags_aprofile(CPUARMState *env) | 108 | return rdm; |
146 | { | 109 | } |
147 | - int flags = 0; | 110 | |
148 | + CPUARMTBFlags flags = {}; | 111 | +uint64_t HELPER(mve_sshrl)(CPUARMState *env, uint64_t n, uint32_t shift) |
149 | 112 | +{ | |
150 | DP_TBFLAG_ANY(flags, DEBUG_TARGET_EL, arm_debug_target_el(env)); | 113 | + return do_sqrshl_d(n, -(int8_t)shift, false, NULL); |
151 | return flags; | 114 | +} |
152 | } | 115 | + |
153 | 116 | +uint64_t HELPER(mve_ushll)(CPUARMState *env, uint64_t n, uint32_t shift) | |
154 | -static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, | 117 | +{ |
155 | - ARMMMUIdx mmu_idx) | 118 | + return do_uqrshl_d(n, (int8_t)shift, false, NULL); |
156 | +static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, | 119 | +} |
157 | + ARMMMUIdx mmu_idx) | 120 | + |
158 | { | 121 | uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift) |
159 | - uint32_t flags = rebuild_hflags_aprofile(env); | 122 | { |
160 | + CPUARMTBFlags flags = rebuild_hflags_aprofile(env); | 123 | return do_sqrshl_d(n, (int8_t)shift, false, &env->QF); |
161 | 124 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | |
162 | if (arm_el_is_aa64(env, 1)) { | 125 | { |
163 | DP_TBFLAG_A32(flags, VFPEN, 1); | 126 | return do_uqrshl_d(n, (int8_t)shift, false, &env->QF); |
164 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, | 127 | } |
165 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | 128 | + |
166 | } | 129 | +uint64_t HELPER(mve_sqrshrl)(CPUARMState *env, uint64_t n, uint32_t shift) |
167 | 130 | +{ | |
168 | -static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | 131 | + return do_sqrshl_d(n, -(int8_t)shift, true, &env->QF); |
169 | - ARMMMUIdx mmu_idx) | 132 | +} |
170 | +static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | 133 | + |
171 | + ARMMMUIdx mmu_idx) | 134 | +uint64_t HELPER(mve_uqrshll)(CPUARMState *env, uint64_t n, uint32_t shift) |
172 | { | 135 | +{ |
173 | - uint32_t flags = rebuild_hflags_aprofile(env); | 136 | + return do_uqrshl_d(n, (int8_t)shift, true, &env->QF); |
174 | + CPUARMTBFlags flags = rebuild_hflags_aprofile(env); | 137 | +} |
175 | ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); | 138 | + |
176 | uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | 139 | +/* Operate on 64-bit values, but saturate at 48 bits */ |
177 | uint64_t sctlr; | 140 | +static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, |
178 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | 141 | + bool round, uint32_t *sat) |
179 | return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | 142 | +{ |
180 | } | 143 | + if (shift <= -48) { |
181 | 144 | + /* Rounding the sign bit always produces 0. */ | |
182 | -static uint32_t rebuild_hflags_internal(CPUARMState *env) | 145 | + if (round) { |
183 | +static CPUARMTBFlags rebuild_hflags_internal(CPUARMState *env) | 146 | + return 0; |
184 | { | 147 | + } |
185 | int el = arm_current_el(env); | 148 | + return src >> 63; |
186 | int fp_el = fp_exception_el(env, el); | 149 | + } else if (shift < 0) { |
187 | @@ -XXX,XX +XXX,XX @@ void HELPER(rebuild_hflags_m32_newel)(CPUARMState *env) | 150 | + if (round) { |
188 | int el = arm_current_el(env); | 151 | + src >>= -shift - 1; |
189 | int fp_el = fp_exception_el(env, el); | 152 | + return (src >> 1) + (src & 1); |
190 | ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); | 153 | + } |
191 | + | 154 | + return src >> -shift; |
192 | env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx); | 155 | + } else if (shift < 48) { |
193 | } | 156 | + int64_t val = src << shift; |
194 | 157 | + int64_t extval = sextract64(val, 0, 48); | |
195 | @@ -XXX,XX +XXX,XX @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el) | 158 | + if (!sat || val == extval) { |
196 | static inline void assert_hflags_rebuild_correctly(CPUARMState *env) | 159 | + return extval; |
197 | { | 160 | + } |
198 | #ifdef CONFIG_DEBUG_TCG | 161 | + } else if (!sat || src == 0) { |
199 | - uint32_t env_flags_current = env->hflags; | 162 | + return 0; |
200 | - uint32_t env_flags_rebuilt = rebuild_hflags_internal(env); | 163 | + } |
201 | + CPUARMTBFlags c = env->hflags; | 164 | + |
202 | + CPUARMTBFlags r = rebuild_hflags_internal(env); | 165 | + *sat = 1; |
203 | 166 | + return (1ULL << 47) - (src >= 0); | |
204 | - if (unlikely(env_flags_current != env_flags_rebuilt)) { | 167 | +} |
205 | + if (unlikely(c.flags != r.flags)) { | 168 | + |
206 | fprintf(stderr, "TCG hflags mismatch (current:0x%08x rebuilt:0x%08x)\n", | 169 | +/* Operate on 64-bit values, but saturate at 48 bits */ |
207 | - env_flags_current, env_flags_rebuilt); | 170 | +static inline uint64_t do_uqrshl48_d(uint64_t src, int64_t shift, |
208 | + c.flags, r.flags); | 171 | + bool round, uint32_t *sat) |
209 | abort(); | 172 | +{ |
210 | } | 173 | + uint64_t val, extval; |
211 | #endif | 174 | + |
212 | @@ -XXX,XX +XXX,XX @@ static inline void assert_hflags_rebuild_correctly(CPUARMState *env) | 175 | + if (shift <= -(48 + round)) { |
213 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 176 | + return 0; |
214 | target_ulong *cs_base, uint32_t *pflags) | 177 | + } else if (shift < 0) { |
215 | { | 178 | + if (round) { |
216 | - uint32_t flags = env->hflags; | 179 | + val = src >> (-shift - 1); |
217 | + CPUARMTBFlags flags; | 180 | + val = (val >> 1) + (val & 1); |
218 | 181 | + } else { | |
219 | *cs_base = 0; | 182 | + val = src >> -shift; |
220 | assert_hflags_rebuild_correctly(env); | 183 | + } |
221 | + flags = env->hflags; | 184 | + extval = extract64(val, 0, 48); |
222 | 185 | + if (!sat || val == extval) { | |
223 | if (EX_TBFLAG_ANY(flags, AARCH64_STATE)) { | 186 | + return extval; |
224 | *pc = env->pc; | 187 | + } |
225 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 188 | + } else if (shift < 48) { |
226 | DP_TBFLAG_ANY(flags, PSTATE__SS, 1); | 189 | + uint64_t val = src << shift; |
227 | } | 190 | + uint64_t extval = extract64(val, 0, 48); |
228 | 191 | + if (!sat || val == extval) { | |
229 | - *pflags = flags; | 192 | + return extval; |
230 | + *pflags = flags.flags; | 193 | + } |
231 | } | 194 | + } else if (!sat || src == 0) { |
232 | 195 | + return 0; | |
233 | #ifdef TARGET_AARCH64 | 196 | + } |
234 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 197 | + |
235 | index XXXXXXX..XXXXXXX 100644 | 198 | + *sat = 1; |
236 | --- a/target/arm/translate-a64.c | 199 | + return MAKE_64BIT_MASK(0, 48); |
237 | +++ b/target/arm/translate-a64.c | 200 | +} |
238 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 201 | + |
239 | DisasContext *dc = container_of(dcbase, DisasContext, base); | 202 | +uint64_t HELPER(mve_sqrshrl48)(CPUARMState *env, uint64_t n, uint32_t shift) |
240 | CPUARMState *env = cpu->env_ptr; | 203 | +{ |
241 | ARMCPU *arm_cpu = env_archcpu(env); | 204 | + return do_sqrshl48_d(n, -(int8_t)shift, true, &env->QF); |
242 | - uint32_t tb_flags = dc->base.tb->flags; | 205 | +} |
243 | + CPUARMTBFlags tb_flags = arm_tbflags_from_tb(dc->base.tb); | 206 | + |
244 | int bound, core_mmu_idx; | 207 | +uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift) |
245 | 208 | +{ | |
246 | dc->isar = &arm_cpu->isar; | 209 | + return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF); |
210 | +} | ||
247 | 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 |
248 | index XXXXXXX..XXXXXXX 100644 | 212 | index XXXXXXX..XXXXXXX 100644 |
249 | --- a/target/arm/translate.c | 213 | --- a/target/arm/translate.c |
250 | +++ b/target/arm/translate.c | 214 | +++ b/target/arm/translate.c |
251 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 215 | @@ -XXX,XX +XXX,XX @@ static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) |
252 | DisasContext *dc = container_of(dcbase, DisasContext, base); | 216 | return do_mve_shl_ri(s, a, gen_urshr64_i64); |
253 | CPUARMState *env = cs->env_ptr; | 217 | } |
254 | ARMCPU *cpu = env_archcpu(env); | 218 | |
255 | - uint32_t tb_flags = dc->base.tb->flags; | 219 | +static bool do_mve_shl_rr(DisasContext *s, arg_mve_shl_rr *a, WideShiftFn *fn) |
256 | + CPUARMTBFlags tb_flags = arm_tbflags_from_tb(dc->base.tb); | 220 | +{ |
257 | uint32_t condexec, core_mmu_idx; | 221 | + TCGv_i64 rda; |
258 | 222 | + TCGv_i32 rdalo, rdahi; | |
259 | dc->isar = &cpu->isar; | 223 | + |
260 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | 224 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
261 | { | 225 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ |
262 | DisasContext dc = { }; | 226 | + return false; |
263 | const TranslatorOps *ops = &arm_translator_ops; | 227 | + } |
264 | + CPUARMTBFlags tb_flags = arm_tbflags_from_tb(tb); | 228 | + if (a->rdahi == 15) { |
265 | 229 | + /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */ | |
266 | - if (EX_TBFLAG_AM32(tb->flags, THUMB)) { | 230 | + return false; |
267 | + if (EX_TBFLAG_AM32(tb_flags, THUMB)) { | 231 | + } |
268 | ops = &thumb_translator_ops; | 232 | + if (!dc_isar_feature(aa32_mve, s) || |
269 | } | 233 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || |
270 | #ifdef TARGET_AARCH64 | 234 | + a->rdahi == 13 || a->rm == 13 || a->rm == 15 || |
271 | - if (EX_TBFLAG_ANY(tb->flags, AARCH64_STATE)) { | 235 | + a->rm == a->rdahi || a->rm == a->rdalo) { |
272 | + if (EX_TBFLAG_ANY(tb_flags, AARCH64_STATE)) { | 236 | + /* These rdahi/rdalo/rm cases are UNPREDICTABLE; we choose to UNDEF */ |
273 | ops = &aarch64_translator_ops; | 237 | + unallocated_encoding(s); |
274 | } | 238 | + return true; |
275 | #endif | 239 | + } |
240 | + | ||
241 | + rda = tcg_temp_new_i64(); | ||
242 | + rdalo = load_reg(s, a->rdalo); | ||
243 | + rdahi = load_reg(s, a->rdahi); | ||
244 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | ||
245 | + | ||
246 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ | ||
247 | + fn(rda, cpu_env, rda, cpu_R[a->rm]); | ||
248 | + | ||
249 | + tcg_gen_extrl_i64_i32(rdalo, rda); | ||
250 | + tcg_gen_extrh_i64_i32(rdahi, rda); | ||
251 | + store_reg(s, a->rdalo, rdalo); | ||
252 | + store_reg(s, a->rdahi, rdahi); | ||
253 | + tcg_temp_free_i64(rda); | ||
254 | + | ||
255 | + return true; | ||
256 | +} | ||
257 | + | ||
258 | +static bool trans_LSLL_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
259 | +{ | ||
260 | + return do_mve_shl_rr(s, a, gen_helper_mve_ushll); | ||
261 | +} | ||
262 | + | ||
263 | +static bool trans_ASRL_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
264 | +{ | ||
265 | + return do_mve_shl_rr(s, a, gen_helper_mve_sshrl); | ||
266 | +} | ||
267 | + | ||
268 | +static bool trans_UQRSHLL64_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
269 | +{ | ||
270 | + return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll); | ||
271 | +} | ||
272 | + | ||
273 | +static bool trans_SQRSHRL64_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
274 | +{ | ||
275 | + return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl); | ||
276 | +} | ||
277 | + | ||
278 | +static bool trans_UQRSHLL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
279 | +{ | ||
280 | + return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll48); | ||
281 | +} | ||
282 | + | ||
283 | +static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
284 | +{ | ||
285 | + return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48); | ||
286 | +} | ||
287 | + | ||
288 | /* | ||
289 | * Multiply and multiply accumulate | ||
290 | */ | ||
276 | -- | 291 | -- |
277 | 2.20.1 | 292 | 2.20.1 |
278 | 293 | ||
279 | 294 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Now that we have all of the proper macros defined, expanding | ||
4 | the CPUARMTBFlags structure and populating the two TB fields | ||
5 | is relatively simple. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210419202257.161730-7-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 49 ++++++++++++++++++++++++------------------ | ||
13 | target/arm/translate.h | 2 +- | ||
14 | target/arm/helper.c | 10 +++++---- | ||
15 | 3 files changed, 35 insertions(+), 26 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMPACKey { | ||
22 | /* See the commentary above the TBFLAG field definitions. */ | ||
23 | typedef struct CPUARMTBFlags { | ||
24 | uint32_t flags; | ||
25 | + target_ulong flags2; | ||
26 | } CPUARMTBFlags; | ||
27 | |||
28 | typedef struct CPUARMState { | ||
29 | @@ -XXX,XX +XXX,XX @@ typedef ARMCPU ArchCPU; | ||
30 | #include "exec/cpu-all.h" | ||
31 | |||
32 | /* | ||
33 | - * Bit usage in the TB flags field: bit 31 indicates whether we are | ||
34 | - * in 32 or 64 bit mode. The meaning of the other bits depends on that. | ||
35 | - * We put flags which are shared between 32 and 64 bit mode at the top | ||
36 | - * of the word, and flags which apply to only one mode at the bottom. | ||
37 | + * We have more than 32-bits worth of state per TB, so we split the data | ||
38 | + * between tb->flags and tb->cs_base, which is otherwise unused for ARM. | ||
39 | + * We collect these two parts in CPUARMTBFlags where they are named | ||
40 | + * flags and flags2 respectively. | ||
41 | * | ||
42 | - * 31 20 18 14 9 0 | ||
43 | - * +--------------+-----+-----+----------+--------------+ | ||
44 | - * | | | TBFLAG_A32 | | | ||
45 | - * | | +-----+----------+ TBFLAG_AM32 | | ||
46 | - * | TBFLAG_ANY | |TBFLAG_M32| | | ||
47 | - * | +-----------+----------+--------------| | ||
48 | - * | | TBFLAG_A64 | | ||
49 | - * +--------------+-------------------------------------+ | ||
50 | - * 31 20 0 | ||
51 | + * The flags that are shared between all execution modes, TBFLAG_ANY, | ||
52 | + * are stored in flags. The flags that are specific to a given mode | ||
53 | + * are stores in flags2. Since cs_base is sized on the configured | ||
54 | + * address size, flags2 always has 64-bits for A64, and a minimum of | ||
55 | + * 32-bits for A32 and M32. | ||
56 | + * | ||
57 | + * The bits for 32-bit A-profile and M-profile partially overlap: | ||
58 | + * | ||
59 | + * 18 9 0 | ||
60 | + * +----------------+--------------+ | ||
61 | + * | TBFLAG_A32 | | | ||
62 | + * +-----+----------+ TBFLAG_AM32 | | ||
63 | + * | |TBFLAG_M32| | | ||
64 | + * +-----+----------+--------------+ | ||
65 | + * 14 9 0 | ||
66 | * | ||
67 | * Unless otherwise noted, these bits are cached in env->hflags. | ||
68 | */ | ||
69 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) | ||
70 | #define DP_TBFLAG_ANY(DST, WHICH, VAL) \ | ||
71 | (DST.flags = FIELD_DP32(DST.flags, TBFLAG_ANY, WHICH, VAL)) | ||
72 | #define DP_TBFLAG_A64(DST, WHICH, VAL) \ | ||
73 | - (DST.flags = FIELD_DP32(DST.flags, TBFLAG_A64, WHICH, VAL)) | ||
74 | + (DST.flags2 = FIELD_DP32(DST.flags2, TBFLAG_A64, WHICH, VAL)) | ||
75 | #define DP_TBFLAG_A32(DST, WHICH, VAL) \ | ||
76 | - (DST.flags = FIELD_DP32(DST.flags, TBFLAG_A32, WHICH, VAL)) | ||
77 | + (DST.flags2 = FIELD_DP32(DST.flags2, TBFLAG_A32, WHICH, VAL)) | ||
78 | #define DP_TBFLAG_M32(DST, WHICH, VAL) \ | ||
79 | - (DST.flags = FIELD_DP32(DST.flags, TBFLAG_M32, WHICH, VAL)) | ||
80 | + (DST.flags2 = FIELD_DP32(DST.flags2, TBFLAG_M32, WHICH, VAL)) | ||
81 | #define DP_TBFLAG_AM32(DST, WHICH, VAL) \ | ||
82 | - (DST.flags = FIELD_DP32(DST.flags, TBFLAG_AM32, WHICH, VAL)) | ||
83 | + (DST.flags2 = FIELD_DP32(DST.flags2, TBFLAG_AM32, WHICH, VAL)) | ||
84 | |||
85 | #define EX_TBFLAG_ANY(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_ANY, WHICH) | ||
86 | -#define EX_TBFLAG_A64(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_A64, WHICH) | ||
87 | -#define EX_TBFLAG_A32(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_A32, WHICH) | ||
88 | -#define EX_TBFLAG_M32(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_M32, WHICH) | ||
89 | -#define EX_TBFLAG_AM32(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_AM32, WHICH) | ||
90 | +#define EX_TBFLAG_A64(IN, WHICH) FIELD_EX32(IN.flags2, TBFLAG_A64, WHICH) | ||
91 | +#define EX_TBFLAG_A32(IN, WHICH) FIELD_EX32(IN.flags2, TBFLAG_A32, WHICH) | ||
92 | +#define EX_TBFLAG_M32(IN, WHICH) FIELD_EX32(IN.flags2, TBFLAG_M32, WHICH) | ||
93 | +#define EX_TBFLAG_AM32(IN, WHICH) FIELD_EX32(IN.flags2, TBFLAG_AM32, WHICH) | ||
94 | |||
95 | /** | ||
96 | * cpu_mmu_index: | ||
97 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
98 | index XXXXXXX..XXXXXXX 100644 | ||
99 | --- a/target/arm/translate.h | ||
100 | +++ b/target/arm/translate.h | ||
101 | @@ -XXX,XX +XXX,XX @@ typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
102 | */ | ||
103 | static inline CPUARMTBFlags arm_tbflags_from_tb(const TranslationBlock *tb) | ||
104 | { | ||
105 | - return (CPUARMTBFlags){ tb->flags }; | ||
106 | + return (CPUARMTBFlags){ tb->flags, tb->cs_base }; | ||
107 | } | ||
108 | |||
109 | /* | ||
110 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/target/arm/helper.c | ||
113 | +++ b/target/arm/helper.c | ||
114 | @@ -XXX,XX +XXX,XX @@ static inline void assert_hflags_rebuild_correctly(CPUARMState *env) | ||
115 | CPUARMTBFlags c = env->hflags; | ||
116 | CPUARMTBFlags r = rebuild_hflags_internal(env); | ||
117 | |||
118 | - if (unlikely(c.flags != r.flags)) { | ||
119 | - fprintf(stderr, "TCG hflags mismatch (current:0x%08x rebuilt:0x%08x)\n", | ||
120 | - c.flags, r.flags); | ||
121 | + if (unlikely(c.flags != r.flags || c.flags2 != r.flags2)) { | ||
122 | + fprintf(stderr, "TCG hflags mismatch " | ||
123 | + "(current:(0x%08x,0x" TARGET_FMT_lx ")" | ||
124 | + " rebuilt:(0x%08x,0x" TARGET_FMT_lx ")\n", | ||
125 | + c.flags, c.flags2, r.flags, r.flags2); | ||
126 | abort(); | ||
127 | } | ||
128 | #endif | ||
129 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
130 | { | ||
131 | CPUARMTBFlags flags; | ||
132 | |||
133 | - *cs_base = 0; | ||
134 | assert_hflags_rebuild_correctly(env); | ||
135 | flags = env->hflags; | ||
136 | |||
137 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
138 | } | ||
139 | |||
140 | *pflags = flags.flags; | ||
141 | + *cs_base = flags.flags2; | ||
142 | } | ||
143 | |||
144 | #ifdef TARGET_AARCH64 | ||
145 | -- | ||
146 | 2.20.1 | ||
147 | |||
148 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Now that these bits have been moved out of tb->flags, | ||
4 | where TBFLAG_ANY was filling from the top, move AM32 | ||
5 | to fill from the top, and A32 and M32 to fill from the | ||
6 | bottom. This means fewer changes when adding new bits. | ||
7 | |||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210419202257.161730-9-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/cpu.h | 42 +++++++++++++++++++++--------------------- | ||
14 | 1 file changed, 21 insertions(+), 21 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/cpu.h | ||
19 | +++ b/target/arm/cpu.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef ARMCPU ArchCPU; | ||
21 | * | ||
22 | * The bits for 32-bit A-profile and M-profile partially overlap: | ||
23 | * | ||
24 | - * 18 9 0 | ||
25 | - * +----------------+--------------+ | ||
26 | - * | TBFLAG_A32 | | | ||
27 | - * +-----+----------+ TBFLAG_AM32 | | ||
28 | - * | |TBFLAG_M32| | | ||
29 | - * +-----+----------+--------------+ | ||
30 | - * 14 9 0 | ||
31 | + * 31 23 11 10 0 | ||
32 | + * +-------------+----------+----------------+ | ||
33 | + * | | | TBFLAG_A32 | | ||
34 | + * | TBFLAG_AM32 | +-----+----------+ | ||
35 | + * | | |TBFLAG_M32| | ||
36 | + * +-------------+----------------+----------+ | ||
37 | + * 31 23 5 4 0 | ||
38 | * | ||
39 | * Unless otherwise noted, these bits are cached in env->hflags. | ||
40 | */ | ||
41 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 20, 2) | ||
42 | /* | ||
43 | * Bit usage when in AArch32 state, both A- and M-profile. | ||
44 | */ | ||
45 | -FIELD(TBFLAG_AM32, CONDEXEC, 0, 8) /* Not cached. */ | ||
46 | -FIELD(TBFLAG_AM32, THUMB, 8, 1) /* Not cached. */ | ||
47 | +FIELD(TBFLAG_AM32, CONDEXEC, 24, 8) /* Not cached. */ | ||
48 | +FIELD(TBFLAG_AM32, THUMB, 23, 1) /* Not cached. */ | ||
49 | |||
50 | /* | ||
51 | * Bit usage when in AArch32 state, for A-profile only. | ||
52 | */ | ||
53 | -FIELD(TBFLAG_A32, VECLEN, 9, 3) /* Not cached. */ | ||
54 | -FIELD(TBFLAG_A32, VECSTRIDE, 12, 2) /* Not cached. */ | ||
55 | +FIELD(TBFLAG_A32, VECLEN, 0, 3) /* Not cached. */ | ||
56 | +FIELD(TBFLAG_A32, VECSTRIDE, 3, 2) /* Not cached. */ | ||
57 | /* | ||
58 | * We store the bottom two bits of the CPAR as TB flags and handle | ||
59 | * checks on the other bits at runtime. This shares the same bits as | ||
60 | * VECSTRIDE, which is OK as no XScale CPU has VFP. | ||
61 | * Not cached, because VECLEN+VECSTRIDE are not cached. | ||
62 | */ | ||
63 | -FIELD(TBFLAG_A32, XSCALE_CPAR, 12, 2) | ||
64 | -FIELD(TBFLAG_A32, VFPEN, 14, 1) /* Partially cached, minus FPEXC. */ | ||
65 | -FIELD(TBFLAG_A32, SCTLR__B, 15, 1) /* Cannot overlap with SCTLR_B */ | ||
66 | -FIELD(TBFLAG_A32, HSTR_ACTIVE, 16, 1) | ||
67 | +FIELD(TBFLAG_A32, XSCALE_CPAR, 5, 2) | ||
68 | +FIELD(TBFLAG_A32, VFPEN, 7, 1) /* Partially cached, minus FPEXC. */ | ||
69 | +FIELD(TBFLAG_A32, SCTLR__B, 8, 1) /* Cannot overlap with SCTLR_B */ | ||
70 | +FIELD(TBFLAG_A32, HSTR_ACTIVE, 9, 1) | ||
71 | /* | ||
72 | * Indicates whether cp register reads and writes by guest code should access | ||
73 | * the secure or nonsecure bank of banked registers; note that this is not | ||
74 | * the same thing as the current security state of the processor! | ||
75 | */ | ||
76 | -FIELD(TBFLAG_A32, NS, 17, 1) | ||
77 | +FIELD(TBFLAG_A32, NS, 10, 1) | ||
78 | |||
79 | /* | ||
80 | * Bit usage when in AArch32 state, for M-profile only. | ||
81 | */ | ||
82 | /* Handler (ie not Thread) mode */ | ||
83 | -FIELD(TBFLAG_M32, HANDLER, 9, 1) | ||
84 | +FIELD(TBFLAG_M32, HANDLER, 0, 1) | ||
85 | /* Whether we should generate stack-limit checks */ | ||
86 | -FIELD(TBFLAG_M32, STACKCHECK, 10, 1) | ||
87 | +FIELD(TBFLAG_M32, STACKCHECK, 1, 1) | ||
88 | /* Set if FPCCR.LSPACT is set */ | ||
89 | -FIELD(TBFLAG_M32, LSPACT, 11, 1) /* Not cached. */ | ||
90 | +FIELD(TBFLAG_M32, LSPACT, 2, 1) /* Not cached. */ | ||
91 | /* Set if we must create a new FP context */ | ||
92 | -FIELD(TBFLAG_M32, NEW_FP_CTXT_NEEDED, 12, 1) /* Not cached. */ | ||
93 | +FIELD(TBFLAG_M32, NEW_FP_CTXT_NEEDED, 3, 1) /* Not cached. */ | ||
94 | /* Set if FPCCR.S does not match current security state */ | ||
95 | -FIELD(TBFLAG_M32, FPCCR_S_WRONG, 13, 1) /* Not cached. */ | ||
96 | +FIELD(TBFLAG_M32, FPCCR_S_WRONG, 4, 1) /* Not cached. */ | ||
97 | |||
98 | /* | ||
99 | * Bit usage when in AArch64 state | ||
100 | -- | ||
101 | 2.20.1 | ||
102 | |||
103 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Now that other bits have been moved out of tb->flags, | ||
4 | there's no point in filling from the top. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210419202257.161730-10-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 14 +++++++------- | ||
12 | 1 file changed, 7 insertions(+), 7 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/cpu.h | ||
17 | +++ b/target/arm/cpu.h | ||
18 | @@ -XXX,XX +XXX,XX @@ typedef ARMCPU ArchCPU; | ||
19 | * | ||
20 | * Unless otherwise noted, these bits are cached in env->hflags. | ||
21 | */ | ||
22 | -FIELD(TBFLAG_ANY, AARCH64_STATE, 31, 1) | ||
23 | -FIELD(TBFLAG_ANY, SS_ACTIVE, 30, 1) | ||
24 | -FIELD(TBFLAG_ANY, PSTATE__SS, 29, 1) /* Not cached. */ | ||
25 | -FIELD(TBFLAG_ANY, BE_DATA, 28, 1) | ||
26 | -FIELD(TBFLAG_ANY, MMUIDX, 24, 4) | ||
27 | +FIELD(TBFLAG_ANY, AARCH64_STATE, 0, 1) | ||
28 | +FIELD(TBFLAG_ANY, SS_ACTIVE, 1, 1) | ||
29 | +FIELD(TBFLAG_ANY, PSTATE__SS, 2, 1) /* Not cached. */ | ||
30 | +FIELD(TBFLAG_ANY, BE_DATA, 3, 1) | ||
31 | +FIELD(TBFLAG_ANY, MMUIDX, 4, 4) | ||
32 | /* Target EL if we take a floating-point-disabled exception */ | ||
33 | -FIELD(TBFLAG_ANY, FPEXC_EL, 22, 2) | ||
34 | +FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2) | ||
35 | /* For A-profile only, target EL for debug exceptions. */ | ||
36 | -FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 20, 2) | ||
37 | +FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 10, 2) | ||
38 | |||
39 | /* | ||
40 | * Bit usage when in AArch32 state, both A- and M-profile. | ||
41 | -- | ||
42 | 2.20.1 | ||
43 | |||
44 | 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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | These patterns overlap with the long-shift-by-immediates, |
5 | Message-id: 20210419202257.161730-23-richard.henderson@linaro.org | 5 | so we have to rearrange the grouping a little here. |
6 | |||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210628135835.6690-18-peter.maydell@linaro.org | ||
7 | --- | 10 | --- |
8 | target/arm/translate.h | 1 + | 11 | target/arm/helper-mve.h | 3 ++ |
9 | target/arm/translate.c | 15 +++++++++++++ | 12 | target/arm/translate.h | 1 + |
10 | target/arm/translate-neon.c.inc | 37 +++++++++++++++++++++++++-------- | 13 | target/arm/t32.decode | 31 ++++++++++++++----- |
11 | 3 files changed, 44 insertions(+), 9 deletions(-) | 14 | target/arm/mve_helper.c | 10 ++++++ |
12 | 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) | ||
13 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 29 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
14 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.h | 31 | --- a/target/arm/translate.h |
16 | +++ b/target/arm/translate.h | 32 | +++ b/target/arm/translate.h |
17 | @@ -XXX,XX +XXX,XX @@ void arm_test_cc(DisasCompare *cmp, int cc); | 33 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); |
18 | void arm_free_cc(DisasCompare *cmp); | 34 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); |
19 | void arm_jump_cc(DisasCompare *cmp, TCGLabel *label); | 35 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); |
20 | void arm_gen_test_cc(int cc, TCGLabel *label); | 36 | typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); |
21 | +MemOp pow2_align(unsigned i); | 37 | +typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift); |
22 | 38 | ||
23 | /* Return state of Alternate Half-precision flag, caller frees result */ | 39 | /** |
24 | static inline TCGv_i32 get_ahp_flag(void) | 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 | +} | ||
25 | 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 |
26 | index XXXXXXX..XXXXXXX 100644 | 117 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/translate.c | 118 | --- a/target/arm/translate.c |
28 | +++ b/target/arm/translate.c | 119 | +++ b/target/arm/translate.c |
29 | @@ -XXX,XX +XXX,XX @@ static inline void store_reg_from_load(DisasContext *s, int reg, TCGv_i32 var) | 120 | @@ -XXX,XX +XXX,XX @@ static void gen_srshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh) |
30 | #define IS_USER_ONLY 0 | 121 | |
31 | #endif | 122 | static void gen_srshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh) |
32 | 123 | { | |
33 | +MemOp pow2_align(unsigned i) | 124 | - TCGv_i32 t = tcg_temp_new_i32(); |
34 | +{ | 125 | + TCGv_i32 t; |
35 | + static const MemOp mop_align[] = { | 126 | |
36 | + 0, MO_ALIGN_2, MO_ALIGN_4, MO_ALIGN_8, MO_ALIGN_16, | 127 | + /* Handle shift by the input size for the benefit of trans_SRSHR_ri */ |
37 | + /* | 128 | + if (sh == 32) { |
38 | + * FIXME: TARGET_PAGE_BITS_MIN affects TLB_FLAGS_MASK such | 129 | + tcg_gen_movi_i32(d, 0); |
39 | + * that 256-bit alignment (MO_ALIGN_32) cannot be supported: | 130 | + return; |
40 | + * see get_alignment_bits(). Enforce only 128-bit alignment for now. | 131 | + } |
41 | + */ | 132 | + t = tcg_temp_new_i32(); |
42 | + MO_ALIGN_16 | 133 | tcg_gen_extract_i32(t, a, sh - 1, 1); |
43 | + }; | 134 | tcg_gen_sari_i32(d, a, sh); |
44 | + g_assert(i < ARRAY_SIZE(mop_align)); | 135 | tcg_gen_add_i32(d, d, t); |
45 | + return mop_align[i]; | 136 | @@ -XXX,XX +XXX,XX @@ static void gen_urshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh) |
137 | |||
138 | static void gen_urshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh) | ||
139 | { | ||
140 | - TCGv_i32 t = tcg_temp_new_i32(); | ||
141 | + TCGv_i32 t; | ||
142 | |||
143 | + /* Handle shift by the input size for the benefit of trans_URSHR_ri */ | ||
144 | + if (sh == 32) { | ||
145 | + tcg_gen_extract_i32(d, a, sh - 1, 1); | ||
146 | + return; | ||
147 | + } | ||
148 | + t = tcg_temp_new_i32(); | ||
149 | tcg_gen_extract_i32(t, a, sh - 1, 1); | ||
150 | tcg_gen_shri_i32(d, a, sh); | ||
151 | tcg_gen_add_i32(d, d, t); | ||
152 | @@ -XXX,XX +XXX,XX @@ static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
153 | return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48); | ||
154 | } | ||
155 | |||
156 | +static bool do_mve_sh_ri(DisasContext *s, arg_mve_sh_ri *a, ShiftImmFn *fn) | ||
157 | +{ | ||
158 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
159 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
160 | + return false; | ||
161 | + } | ||
162 | + if (!dc_isar_feature(aa32_mve, s) || | ||
163 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || | ||
164 | + a->rda == 13 || a->rda == 15) { | ||
165 | + /* These rda cases are UNPREDICTABLE; we choose to UNDEF */ | ||
166 | + unallocated_encoding(s); | ||
167 | + return true; | ||
168 | + } | ||
169 | + | ||
170 | + if (a->shim == 0) { | ||
171 | + a->shim = 32; | ||
172 | + } | ||
173 | + fn(cpu_R[a->rda], cpu_R[a->rda], a->shim); | ||
174 | + | ||
175 | + return true; | ||
176 | +} | ||
177 | + | ||
178 | +static bool trans_URSHR_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
179 | +{ | ||
180 | + return do_mve_sh_ri(s, a, gen_urshr32_i32); | ||
181 | +} | ||
182 | + | ||
183 | +static bool trans_SRSHR_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
184 | +{ | ||
185 | + return do_mve_sh_ri(s, a, gen_srshr32_i32); | ||
186 | +} | ||
187 | + | ||
188 | +static void gen_mve_sqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift) | ||
189 | +{ | ||
190 | + gen_helper_mve_sqshl(r, cpu_env, n, tcg_constant_i32(shift)); | ||
191 | +} | ||
192 | + | ||
193 | +static bool trans_SQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
194 | +{ | ||
195 | + return do_mve_sh_ri(s, a, gen_mve_sqshl); | ||
196 | +} | ||
197 | + | ||
198 | +static void gen_mve_uqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift) | ||
199 | +{ | ||
200 | + gen_helper_mve_uqshl(r, cpu_env, n, tcg_constant_i32(shift)); | ||
201 | +} | ||
202 | + | ||
203 | +static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
204 | +{ | ||
205 | + return do_mve_sh_ri(s, a, gen_mve_uqshl); | ||
46 | +} | 206 | +} |
47 | + | 207 | + |
48 | /* | 208 | /* |
49 | * Abstractions of "generate code to do a guest load/store for | 209 | * Multiply and multiply accumulate |
50 | * AArch32", where a vaddr is always 32 bits (and is zero | 210 | */ |
51 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/translate-neon.c.inc | ||
54 | +++ b/target/arm/translate-neon.c.inc | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | ||
56 | int size = a->size; | ||
57 | int nregs = a->n + 1; | ||
58 | TCGv_i32 addr, tmp; | ||
59 | + MemOp mop, align; | ||
60 | |||
61 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
62 | return false; | ||
63 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | ||
64 | return false; | ||
65 | } | ||
66 | |||
67 | + align = 0; | ||
68 | if (size == 3) { | ||
69 | if (nregs != 4 || a->a == 0) { | ||
70 | return false; | ||
71 | } | ||
72 | /* For VLD4 size == 3 a == 1 means 32 bits at 16 byte alignment */ | ||
73 | - size = 2; | ||
74 | - } | ||
75 | - if (nregs == 1 && a->a == 1 && size == 0) { | ||
76 | - return false; | ||
77 | - } | ||
78 | - if (nregs == 3 && a->a == 1) { | ||
79 | - return false; | ||
80 | + size = MO_32; | ||
81 | + align = MO_ALIGN_16; | ||
82 | + } else if (a->a) { | ||
83 | + switch (nregs) { | ||
84 | + case 1: | ||
85 | + if (size == 0) { | ||
86 | + return false; | ||
87 | + } | ||
88 | + align = MO_ALIGN; | ||
89 | + break; | ||
90 | + case 2: | ||
91 | + align = pow2_align(size + 1); | ||
92 | + break; | ||
93 | + case 3: | ||
94 | + return false; | ||
95 | + case 4: | ||
96 | + align = pow2_align(size + 2); | ||
97 | + break; | ||
98 | + default: | ||
99 | + g_assert_not_reached(); | ||
100 | + } | ||
101 | } | ||
102 | |||
103 | if (!vfp_access_check(s)) { | ||
104 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | ||
105 | */ | ||
106 | stride = a->t ? 2 : 1; | ||
107 | vec_size = nregs == 1 ? stride * 8 : 8; | ||
108 | - | ||
109 | + mop = size | align; | ||
110 | tmp = tcg_temp_new_i32(); | ||
111 | addr = tcg_temp_new_i32(); | ||
112 | load_reg_var(s, addr, a->rn); | ||
113 | for (reg = 0; reg < nregs; reg++) { | ||
114 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), size); | ||
115 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), mop); | ||
116 | if ((vd & 1) && vec_size == 16) { | ||
117 | /* | ||
118 | * We cannot write 16 bytes at once because the | ||
119 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | ||
120 | } | ||
121 | tcg_gen_addi_i32(addr, addr, 1 << size); | ||
122 | vd += stride; | ||
123 | + | ||
124 | + /* Subsequent memory operations inherit alignment */ | ||
125 | + mop &= ~MO_AMASK; | ||
126 | } | ||
127 | tcg_temp_free_i32(tmp); | ||
128 | tcg_temp_free_i32(addr); | ||
129 | -- | 211 | -- |
130 | 2.20.1 | 212 | 2.20.1 |
131 | 213 | ||
132 | 214 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE shifts by register, which perform |
---|---|---|---|
2 | shifts on a single general-purpose register. | ||
2 | 3 | ||
3 | Use this to signal when memory access alignment is required. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | This value comes from the CCR register for M-profile, and | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | from the SCTLR register for A-profile. | 6 | Message-id: 20210628135835.6690-19-peter.maydell@linaro.org |
7 | --- | ||
8 | target/arm/helper-mve.h | 2 ++ | ||
9 | target/arm/translate.h | 1 + | ||
10 | target/arm/t32.decode | 18 ++++++++++++++---- | ||
11 | target/arm/mve_helper.c | 10 ++++++++++ | ||
12 | target/arm/translate.c | 30 ++++++++++++++++++++++++++++++ | ||
13 | 5 files changed, 57 insertions(+), 4 deletions(-) | ||
6 | 14 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210419202257.161730-11-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 2 ++ | ||
13 | target/arm/translate.h | 2 ++ | ||
14 | target/arm/helper.c | 19 +++++++++++++++++-- | ||
15 | target/arm/translate-a64.c | 1 + | ||
16 | target/arm/translate.c | 7 +++---- | ||
17 | 5 files changed, 25 insertions(+), 6 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/helper-mve.h |
22 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/helper-mve.h |
23 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, MMUIDX, 4, 4) | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) |
24 | FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2) | 20 | |
25 | /* For A-profile only, target EL for debug exceptions. */ | 21 | DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) |
26 | FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 10, 2) | 22 | DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) |
27 | +/* Memory operations require alignment: SCTLR_ELx.A or CCR.UNALIGN_TRP */ | 23 | +DEF_HELPER_FLAGS_3(mve_uqrshl, TCG_CALL_NO_RWG, i32, env, i32, i32) |
28 | +FIELD(TBFLAG_ANY, ALIGN_MEM, 12, 1) | 24 | +DEF_HELPER_FLAGS_3(mve_sqrshr, TCG_CALL_NO_RWG, i32, env, i32, i32) |
29 | |||
30 | /* | ||
31 | * Bit usage when in AArch32 state, both A- and M-profile. | ||
32 | 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 |
33 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/target/arm/translate.h | 27 | --- a/target/arm/translate.h |
35 | +++ b/target/arm/translate.h | 28 | +++ b/target/arm/translate.h |
36 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 29 | @@ -XXX,XX +XXX,XX @@ typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); |
37 | bool bt; | 30 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); |
38 | /* True if any CP15 access is trapped by HSTR_EL2 */ | 31 | typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); |
39 | bool hstr_active; | 32 | typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift); |
40 | + /* True if memory operations require alignment */ | 33 | +typedef void ShiftFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32); |
41 | + bool align_mem; | 34 | |
42 | /* | 35 | /** |
43 | * >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. | 36 | * arm_tbflags_from_tb: |
44 | * < 0, set by the current instruction. | 37 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode |
45 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/helper.c | 39 | --- a/target/arm/t32.decode |
48 | +++ b/target/arm/helper.c | 40 | +++ b/target/arm/t32.decode |
49 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el, | 41 | @@ -XXX,XX +XXX,XX @@ |
50 | ARMMMUIdx mmu_idx) | 42 | &mve_shl_ri rdalo rdahi shim |
43 | &mve_shl_rr rdalo rdahi rm | ||
44 | &mve_sh_ri rda shim | ||
45 | +&mve_sh_rr rda rm | ||
46 | |||
47 | # rdahi: bits [3:1] from insn, bit 0 is 1 | ||
48 | # rdalo: bits [3:1] from insn, bit 0 is 0 | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
51 | @mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \ | ||
52 | &mve_sh_ri shim=%imm5_12_6 | ||
53 | +@mve_sh_rr ....... .... . rda:4 rm:4 .... .... .... &mve_sh_rr | ||
54 | |||
51 | { | 55 | { |
52 | CPUARMTBFlags flags = {}; | 56 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi |
53 | + uint32_t ccr = env->v7m.ccr[env->v7m.secure]; | 57 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi |
54 | + | 58 | SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri |
55 | + /* Without HaveMainExt, CCR.UNALIGN_TRP is RES1. */ | ||
56 | + if (ccr & R_V7M_CCR_UNALIGN_TRP_MASK) { | ||
57 | + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); | ||
58 | + } | ||
59 | |||
60 | if (arm_v7m_is_handler_mode(env)) { | ||
61 | DP_TBFLAG_M32(flags, HANDLER, 1); | ||
62 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el, | ||
63 | */ | ||
64 | if (arm_feature(env, ARM_FEATURE_V8) && | ||
65 | !((mmu_idx & ARM_MMU_IDX_M_NEGPRI) && | ||
66 | - (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_STKOFHFNMIGN_MASK))) { | ||
67 | + (ccr & R_V7M_CCR_STKOFHFNMIGN_MASK))) { | ||
68 | DP_TBFLAG_M32(flags, STACKCHECK, 1); | ||
69 | } | 59 | } |
70 | 60 | ||
71 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, | 61 | - LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr |
72 | ARMMMUIdx mmu_idx) | 62 | - ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr |
73 | { | 63 | - UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr |
74 | CPUARMTBFlags flags = rebuild_hflags_aprofile(env); | 64 | - SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr |
75 | + int el = arm_current_el(env); | 65 | + { |
76 | + | 66 | + UQRSHL_rr 1110101 0010 1 .... .... 1111 0000 1101 @mve_sh_rr |
77 | + if (arm_sctlr(env, el) & SCTLR_A) { | 67 | + LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr |
78 | + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); | 68 | + UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr |
79 | + } | ||
80 | |||
81 | if (arm_el_is_aa64(env, 1)) { | ||
82 | DP_TBFLAG_A32(flags, VFPEN, 1); | ||
83 | } | ||
84 | |||
85 | - if (arm_current_el(env) < 2 && env->cp15.hstr_el2 && | ||
86 | + if (el < 2 && env->cp15.hstr_el2 && | ||
87 | (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | ||
88 | DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1); | ||
89 | } | ||
90 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
91 | |||
92 | sctlr = regime_sctlr(env, stage1); | ||
93 | |||
94 | + if (sctlr & SCTLR_A) { | ||
95 | + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); | ||
96 | + } | 69 | + } |
97 | + | 70 | + |
98 | if (arm_cpu_data_is_big_endian_a64(el, sctlr)) { | 71 | + { |
99 | DP_TBFLAG_ANY(flags, BE_DATA, 1); | 72 | + SQRSHR_rr 1110101 0010 1 .... .... 1111 0010 1101 @mve_sh_rr |
100 | } | 73 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr |
101 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 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 | ||
102 | index XXXXXXX..XXXXXXX 100644 | 81 | index XXXXXXX..XXXXXXX 100644 |
103 | --- a/target/arm/translate-a64.c | 82 | --- a/target/arm/mve_helper.c |
104 | +++ b/target/arm/translate-a64.c | 83 | +++ b/target/arm/mve_helper.c |
105 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 84 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift) |
106 | dc->user = (dc->current_el == 0); | 85 | { |
107 | #endif | 86 | return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); |
108 | dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); | 87 | } |
109 | + dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); | 88 | + |
110 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); | 89 | +uint32_t HELPER(mve_uqrshl)(CPUARMState *env, uint32_t n, uint32_t shift) |
111 | dc->sve_len = (EX_TBFLAG_A64(tb_flags, ZCR_LEN) + 1) * 16; | 90 | +{ |
112 | dc->pauth_active = EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); | 91 | + return do_uqrshl_bhs(n, (int8_t)shift, 32, true, &env->QF); |
92 | +} | ||
93 | + | ||
94 | +uint32_t HELPER(mve_sqrshr)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
95 | +{ | ||
96 | + return do_sqrshl_bhs(n, -(int8_t)shift, 32, true, &env->QF); | ||
97 | +} | ||
113 | 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 |
114 | index XXXXXXX..XXXXXXX 100644 | 99 | index XXXXXXX..XXXXXXX 100644 |
115 | --- a/target/arm/translate.c | 100 | --- a/target/arm/translate.c |
116 | +++ b/target/arm/translate.c | 101 | +++ b/target/arm/translate.c |
117 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 102 | @@ -XXX,XX +XXX,XX @@ static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) |
118 | { | 103 | return do_mve_sh_ri(s, a, gen_mve_uqshl); |
119 | TCGv addr; | 104 | } |
120 | 105 | ||
121 | - if (arm_dc_feature(s, ARM_FEATURE_M) && | 106 | +static bool do_mve_sh_rr(DisasContext *s, arg_mve_sh_rr *a, ShiftFn *fn) |
122 | - !arm_dc_feature(s, ARM_FEATURE_M_MAIN)) { | 107 | +{ |
123 | + if (s->align_mem) { | 108 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
124 | opc |= MO_ALIGN; | 109 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ |
125 | } | 110 | + return false; |
126 | 111 | + } | |
127 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 112 | + if (!dc_isar_feature(aa32_mve, s) || |
128 | { | 113 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || |
129 | TCGv addr; | 114 | + a->rda == 13 || a->rda == 15 || a->rm == 13 || a->rm == 15 || |
130 | 115 | + a->rm == a->rda) { | |
131 | - if (arm_dc_feature(s, ARM_FEATURE_M) && | 116 | + /* These rda/rm cases are UNPREDICTABLE; we choose to UNDEF */ |
132 | - !arm_dc_feature(s, ARM_FEATURE_M_MAIN)) { | 117 | + unallocated_encoding(s); |
133 | + if (s->align_mem) { | 118 | + return true; |
134 | opc |= MO_ALIGN; | 119 | + } |
135 | } | 120 | + |
136 | 121 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ | |
137 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 122 | + fn(cpu_R[a->rda], cpu_env, cpu_R[a->rda], cpu_R[a->rm]); |
138 | dc->user = (dc->current_el == 0); | 123 | + return true; |
139 | #endif | 124 | +} |
140 | dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); | 125 | + |
141 | + dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); | 126 | +static bool trans_SQRSHR_rr(DisasContext *s, arg_mve_sh_rr *a) |
142 | 127 | +{ | |
143 | if (arm_feature(env, ARM_FEATURE_M)) { | 128 | + return do_mve_sh_rr(s, a, gen_helper_mve_sqrshr); |
144 | dc->vfp_enabled = 1; | 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 | */ | ||
145 | -- | 139 | -- |
146 | 2.20.1 | 140 | 2.20.1 |
147 | 141 | ||
148 | 142 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Just because operating on a TCGv_i64 temporary does not | ||
4 | mean that we're performing a 64-bit operation. Restrict | ||
5 | the frobbing to actual 64-bit operations. | ||
6 | |||
7 | This bug is not currently visible because all current | ||
8 | users of these two functions always pass MO_64. | ||
9 | |||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20210419202257.161730-14-richard.henderson@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | target/arm/translate.c | 4 ++-- | ||
16 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/translate.c | ||
21 | +++ b/target/arm/translate.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
23 | tcg_gen_qemu_ld_i64(val, addr, index, opc); | ||
24 | |||
25 | /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
26 | - if (!IS_USER_ONLY && s->sctlr_b) { | ||
27 | + if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | ||
28 | tcg_gen_rotri_i64(val, val, 32); | ||
29 | } | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
32 | TCGv addr = gen_aa32_addr(s, a32, opc); | ||
33 | |||
34 | /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
35 | - if (!IS_USER_ONLY && s->sctlr_b) { | ||
36 | + if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | ||
37 | TCGv_i64 tmp = tcg_temp_new_i64(); | ||
38 | tcg_gen_rotri_i64(tmp, val, 32); | ||
39 | tcg_gen_qemu_st_i64(tmp, addr, index, opc); | ||
40 | -- | ||
41 | 2.20.1 | ||
42 | |||
43 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Buglink: https://bugs.launchpad.net/qemu/+bug/1905356 | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210419202257.161730-16-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | target/arm/translate.c | 16 ++++++++-------- | ||
10 | 1 file changed, 8 insertions(+), 8 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/translate.c | ||
15 | +++ b/target/arm/translate.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDRD_rr(DisasContext *s, arg_ldst_rr *a) | ||
17 | addr = op_addr_rr_pre(s, a); | ||
18 | |||
19 | tmp = tcg_temp_new_i32(); | ||
20 | - gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL); | ||
21 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL | MO_ALIGN); | ||
22 | store_reg(s, a->rt, tmp); | ||
23 | |||
24 | tcg_gen_addi_i32(addr, addr, 4); | ||
25 | |||
26 | tmp = tcg_temp_new_i32(); | ||
27 | - gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL); | ||
28 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL | MO_ALIGN); | ||
29 | store_reg(s, a->rt + 1, tmp); | ||
30 | |||
31 | /* LDRD w/ base writeback is undefined if the registers overlap. */ | ||
32 | @@ -XXX,XX +XXX,XX @@ static bool trans_STRD_rr(DisasContext *s, arg_ldst_rr *a) | ||
33 | addr = op_addr_rr_pre(s, a); | ||
34 | |||
35 | tmp = load_reg(s, a->rt); | ||
36 | - gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL); | ||
37 | + gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL | MO_ALIGN); | ||
38 | tcg_temp_free_i32(tmp); | ||
39 | |||
40 | tcg_gen_addi_i32(addr, addr, 4); | ||
41 | |||
42 | tmp = load_reg(s, a->rt + 1); | ||
43 | - gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL); | ||
44 | + gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL | MO_ALIGN); | ||
45 | tcg_temp_free_i32(tmp); | ||
46 | |||
47 | op_addr_rr_post(s, a, addr, -4); | ||
48 | @@ -XXX,XX +XXX,XX @@ static bool op_ldrd_ri(DisasContext *s, arg_ldst_ri *a, int rt2) | ||
49 | addr = op_addr_ri_pre(s, a); | ||
50 | |||
51 | tmp = tcg_temp_new_i32(); | ||
52 | - gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL); | ||
53 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL | MO_ALIGN); | ||
54 | store_reg(s, a->rt, tmp); | ||
55 | |||
56 | tcg_gen_addi_i32(addr, addr, 4); | ||
57 | |||
58 | tmp = tcg_temp_new_i32(); | ||
59 | - gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL); | ||
60 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL | MO_ALIGN); | ||
61 | store_reg(s, rt2, tmp); | ||
62 | |||
63 | /* LDRD w/ base writeback is undefined if the registers overlap. */ | ||
64 | @@ -XXX,XX +XXX,XX @@ static bool op_strd_ri(DisasContext *s, arg_ldst_ri *a, int rt2) | ||
65 | addr = op_addr_ri_pre(s, a); | ||
66 | |||
67 | tmp = load_reg(s, a->rt); | ||
68 | - gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL); | ||
69 | + gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL | MO_ALIGN); | ||
70 | tcg_temp_free_i32(tmp); | ||
71 | |||
72 | tcg_gen_addi_i32(addr, addr, 4); | ||
73 | |||
74 | tmp = load_reg(s, rt2); | ||
75 | - gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL); | ||
76 | + gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL | MO_ALIGN); | ||
77 | tcg_temp_free_i32(tmp); | ||
78 | |||
79 | op_addr_ri_post(s, a, addr, -4); | ||
80 | -- | ||
81 | 2.20.1 | ||
82 | |||
83 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210419202257.161730-17-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate.c | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate.c | ||
14 | +++ b/target/arm/translate.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static bool op_stl(DisasContext *s, arg_STL *a, MemOp mop) | ||
16 | addr = load_reg(s, a->rn); | ||
17 | tmp = load_reg(s, a->rt); | ||
18 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | ||
19 | - gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), mop); | ||
20 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), mop | MO_ALIGN); | ||
21 | disas_set_da_iss(s, mop, a->rt | ISSIsAcqRel | ISSIsWrite); | ||
22 | |||
23 | tcg_temp_free_i32(tmp); | ||
24 | @@ -XXX,XX +XXX,XX @@ static bool op_lda(DisasContext *s, arg_LDA *a, MemOp mop) | ||
25 | |||
26 | addr = load_reg(s, a->rn); | ||
27 | tmp = tcg_temp_new_i32(); | ||
28 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), mop); | ||
29 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), mop | MO_ALIGN); | ||
30 | disas_set_da_iss(s, mop, a->rt | ISSIsAcqRel); | ||
31 | tcg_temp_free_i32(addr); | ||
32 | |||
33 | -- | ||
34 | 2.20.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210419202257.161730-18-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate.c | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate.c | ||
14 | +++ b/target/arm/translate.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n) | ||
16 | } else { | ||
17 | tmp = load_reg(s, i); | ||
18 | } | ||
19 | - gen_aa32_st32(s, tmp, addr, mem_idx); | ||
20 | + gen_aa32_st_i32(s, tmp, addr, mem_idx, MO_UL | MO_ALIGN); | ||
21 | tcg_temp_free_i32(tmp); | ||
22 | |||
23 | /* No need to add after the last transfer. */ | ||
24 | @@ -XXX,XX +XXX,XX @@ static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n) | ||
25 | } | ||
26 | |||
27 | tmp = tcg_temp_new_i32(); | ||
28 | - gen_aa32_ld32u(s, tmp, addr, mem_idx); | ||
29 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, MO_UL | MO_ALIGN); | ||
30 | if (user) { | ||
31 | tmp2 = tcg_const_i32(i); | ||
32 | gen_helper_set_user_reg(cpu_env, tmp2, tmp); | ||
33 | -- | ||
34 | 2.20.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210419202257.161730-19-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate.c | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate.c | ||
14 | +++ b/target/arm/translate.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_RFE(DisasContext *s, arg_RFE *a) | ||
16 | |||
17 | /* Load PC into tmp and CPSR into tmp2. */ | ||
18 | t1 = tcg_temp_new_i32(); | ||
19 | - gen_aa32_ld32u(s, t1, addr, get_mem_index(s)); | ||
20 | + gen_aa32_ld_i32(s, t1, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
21 | tcg_gen_addi_i32(addr, addr, 4); | ||
22 | t2 = tcg_temp_new_i32(); | ||
23 | - gen_aa32_ld32u(s, t2, addr, get_mem_index(s)); | ||
24 | + gen_aa32_ld_i32(s, t2, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
25 | |||
26 | if (a->w) { | ||
27 | /* Base writeback. */ | ||
28 | -- | ||
29 | 2.20.1 | ||
30 | |||
31 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210419202257.161730-20-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate.c | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate.c | ||
14 | +++ b/target/arm/translate.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
16 | } | ||
17 | tcg_gen_addi_i32(addr, addr, offset); | ||
18 | tmp = load_reg(s, 14); | ||
19 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
20 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
21 | tcg_temp_free_i32(tmp); | ||
22 | tmp = load_cpu_field(spsr); | ||
23 | tcg_gen_addi_i32(addr, addr, 4); | ||
24 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
25 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
26 | tcg_temp_free_i32(tmp); | ||
27 | if (writeback) { | ||
28 | switch (amode) { | ||
29 | -- | ||
30 | 2.20.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210419202257.161730-21-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate-vfp.c.inc | 8 ++++---- | ||
9 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate-vfp.c.inc | ||
14 | +++ b/target/arm/translate-vfp.c.inc | ||
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) | ||
16 | for (i = 0; i < n; i++) { | ||
17 | if (a->l) { | ||
18 | /* load */ | ||
19 | - gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
20 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
21 | vfp_store_reg32(tmp, a->vd + i); | ||
22 | } else { | ||
23 | /* store */ | ||
24 | vfp_load_reg32(tmp, a->vd + i); | ||
25 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
26 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
27 | } | ||
28 | tcg_gen_addi_i32(addr, addr, offset); | ||
29 | } | ||
30 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) | ||
31 | for (i = 0; i < n; i++) { | ||
32 | if (a->l) { | ||
33 | /* load */ | ||
34 | - gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); | ||
35 | + gen_aa32_ld_i64(s, tmp, addr, get_mem_index(s), MO_Q | MO_ALIGN_4); | ||
36 | vfp_store_reg64(tmp, a->vd + i); | ||
37 | } else { | ||
38 | /* store */ | ||
39 | vfp_load_reg64(tmp, a->vd + i); | ||
40 | - gen_aa32_st64(s, tmp, addr, get_mem_index(s)); | ||
41 | + gen_aa32_st_i64(s, tmp, addr, get_mem_index(s), MO_Q | MO_ALIGN_4); | ||
42 | } | ||
43 | tcg_gen_addi_i32(addr, addr, offset); | ||
44 | } | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210419202257.161730-22-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate-vfp.c.inc | 12 ++++++------ | ||
9 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate-vfp.c.inc | ||
14 | +++ b/target/arm/translate-vfp.c.inc | ||
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_hp(DisasContext *s, arg_VLDR_VSTR_sp *a) | ||
16 | addr = add_reg_for_lit(s, a->rn, offset); | ||
17 | tmp = tcg_temp_new_i32(); | ||
18 | if (a->l) { | ||
19 | - gen_aa32_ld16u(s, tmp, addr, get_mem_index(s)); | ||
20 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), MO_UW | MO_ALIGN); | ||
21 | vfp_store_reg32(tmp, a->vd); | ||
22 | } else { | ||
23 | vfp_load_reg32(tmp, a->vd); | ||
24 | - gen_aa32_st16(s, tmp, addr, get_mem_index(s)); | ||
25 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UW | MO_ALIGN); | ||
26 | } | ||
27 | tcg_temp_free_i32(tmp); | ||
28 | tcg_temp_free_i32(addr); | ||
29 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) | ||
30 | addr = add_reg_for_lit(s, a->rn, offset); | ||
31 | tmp = tcg_temp_new_i32(); | ||
32 | if (a->l) { | ||
33 | - gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
34 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
35 | vfp_store_reg32(tmp, a->vd); | ||
36 | } else { | ||
37 | vfp_load_reg32(tmp, a->vd); | ||
38 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
39 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
40 | } | ||
41 | tcg_temp_free_i32(tmp); | ||
42 | tcg_temp_free_i32(addr); | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a) | ||
44 | addr = add_reg_for_lit(s, a->rn, offset); | ||
45 | tmp = tcg_temp_new_i64(); | ||
46 | if (a->l) { | ||
47 | - gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); | ||
48 | + gen_aa32_ld_i64(s, tmp, addr, get_mem_index(s), MO_Q | MO_ALIGN_4); | ||
49 | vfp_store_reg64(tmp, a->vd); | ||
50 | } else { | ||
51 | vfp_load_reg64(tmp, a->vd); | ||
52 | - gen_aa32_st64(s, tmp, addr, get_mem_index(s)); | ||
53 | + gen_aa32_st_i64(s, tmp, addr, get_mem_index(s), MO_Q | MO_ALIGN_4); | ||
54 | } | ||
55 | tcg_temp_free_i64(tmp); | ||
56 | tcg_temp_free_i32(addr); | ||
57 | -- | ||
58 | 2.20.1 | ||
59 | |||
60 | diff view generated by jsdifflib |