1 | First arm pullreq for 6.1 cycle. The big stuff here is RTH's alignment series. | 1 | Hi; here's the latest round of arm patches. I have included also |
---|---|---|---|
2 | my patchset for the RTC devices to avoid keeping time_t and | ||
3 | time_t diffs in 32-bit variables. | ||
2 | 4 | ||
3 | thanks | 5 | thanks |
4 | -- PMM | 6 | -- PMM |
5 | 7 | ||
6 | The following changes since commit ccdf06c1db192152ac70a1dd974c624f566cb7d4: | 8 | The following changes since commit 156618d9ea67f2f2e31d9dedd97f2dcccbe6808c: |
7 | 9 | ||
8 | Open 6.1 development tree (2021-04-30 11:15:40 +0100) | 10 | Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2023-08-30 09:20:27 -0400) |
9 | 11 | ||
10 | are available in the Git repository at: | 12 | are available in the Git repository at: |
11 | 13 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210430 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230831 |
13 | 15 | ||
14 | for you to fetch changes up to a6091108aa44e9017af4ca13c43f55a629e3744c: | 16 | for you to fetch changes up to e73b8bb8a3e9a162f70e9ffbf922d4fafc96bbfb: |
15 | 17 | ||
16 | hw/pci-host/gpex: Don't fault for unmapped parts of MMIO and PIO windows (2021-04-30 11:16:52 +0100) | 18 | hw/arm: Set number of MPU regions correctly for an505, an521, an524 (2023-08-31 11:07:02 +0100) |
17 | 19 | ||
18 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
19 | target-arm queue: | 21 | target-arm queue: |
20 | * hw/pci-host/gpex: Don't fault for unmapped parts of MMIO and PIO windows | 22 | * Some of the preliminary patches for Cortex-A710 support |
21 | * hw: add compat machines for 6.1 | 23 | * i.MX7 and i.MX6UL refactoring |
22 | * Fault misaligned accesses where the architecture requires it | 24 | * Implement SRC device for i.MX7 |
23 | * Fix some corner cases of MTE faults (notably with misaligned accesses) | 25 | * Catch illegal-exception-return from EL3 with bad NSE/NS |
24 | * Make Thumb store insns UNDEF for Rn==1111 | 26 | * Use 64-bit offsets for holding time_t differences in RTC devices |
25 | * hw/arm/smmuv3: Support 16K translation granule | 27 | * Model correct number of MPU regions for an505, an521, an524 boards |
26 | 28 | ||
27 | ---------------------------------------------------------------- | 29 | ---------------------------------------------------------------- |
28 | Cornelia Huck (1): | 30 | Alex Bennée (1): |
29 | hw: add compat machines for 6.1 | 31 | target/arm: properly document FEAT_CRC32 |
30 | 32 | ||
31 | Kunkun Jiang (1): | 33 | Jean-Christophe Dubois (6): |
32 | hw/arm/smmuv3: Support 16K translation granule | 34 | Remove i.MX7 IOMUX GPR device from i.MX6UL |
35 | Refactor i.MX6UL processor code | ||
36 | Add i.MX6UL missing devices. | ||
37 | Refactor i.MX7 processor code | ||
38 | Add i.MX7 missing TZ devices and memory regions | ||
39 | Add i.MX7 SRC device implementation | ||
33 | 40 | ||
34 | Peter Maydell (2): | 41 | Peter Maydell (8): |
35 | target/arm: Make Thumb store insns UNDEF for Rn==1111 | 42 | target/arm: Catch illegal-exception-return from EL3 with bad NSE/NS |
36 | hw/pci-host/gpex: Don't fault for unmapped parts of MMIO and PIO windows | 43 | hw/rtc/m48t59: Use 64-bit arithmetic in set_alarm() |
44 | hw/rtc/twl92230: Use int64_t for sec_offset and alm_sec | ||
45 | hw/rtc/aspeed_rtc: Use 64-bit offset for holding time_t difference | ||
46 | rtc: Use time_t for passing and returning time offsets | ||
47 | target/arm: Do all "ARM_FEATURE_X implies Y" checks in post_init | ||
48 | hw/arm/armv7m: Add mpu-ns-regions and mpu-s-regions properties | ||
49 | hw/arm: Set number of MPU regions correctly for an505, an521, an524 | ||
37 | 50 | ||
38 | Richard Henderson (39): | 51 | Richard Henderson (9): |
39 | target/arm: Fix mte_checkN | 52 | target/arm: Reduce dcz_blocksize to uint8_t |
40 | target/arm: Split out mte_probe_int | 53 | target/arm: Allow cpu to configure GM blocksize |
41 | target/arm: Fix unaligned checks for mte_check1, mte_probe1 | 54 | target/arm: Support more GM blocksizes |
42 | test/tcg/aarch64: Add mte-5 | 55 | target/arm: When tag memory is not present, set MTE=1 |
43 | target/arm: Replace MTEDESC ESIZE+TSIZE with SIZEM1 | 56 | target/arm: Introduce make_ccsidr64 |
44 | target/arm: Merge mte_check1, mte_checkN | 57 | target/arm: Apply access checks to neoverse-n1 special registers |
45 | target/arm: Rename mte_probe1 to mte_probe | 58 | target/arm: Apply access checks to neoverse-v1 special registers |
46 | target/arm: Simplify sve mte checking | 59 | target/arm: Suppress FEAT_TRBE (Trace Buffer Extension) |
47 | target/arm: Remove log2_esize parameter to gen_mte_checkN | 60 | target/arm: Implement FEAT_HPDS2 as a no-op |
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 | 61 | ||
79 | include/hw/boards.h | 3 + | 62 | docs/system/arm/emulation.rst | 2 + |
80 | include/hw/i386/pc.h | 3 + | 63 | include/hw/arm/armsse.h | 5 + |
81 | include/hw/pci-host/gpex.h | 4 + | 64 | include/hw/arm/armv7m.h | 8 + |
82 | target/arm/cpu.h | 105 ++++++++++----- | 65 | include/hw/arm/fsl-imx6ul.h | 158 ++++++++++++++++--- |
83 | target/arm/helper-a64.h | 3 +- | 66 | include/hw/arm/fsl-imx7.h | 338 ++++++++++++++++++++++++++++++----------- |
84 | target/arm/internals.h | 11 +- | 67 | include/hw/misc/imx7_src.h | 66 ++++++++ |
85 | target/arm/translate-a64.h | 2 +- | 68 | include/hw/rtc/aspeed_rtc.h | 2 +- |
86 | target/arm/translate.h | 38 ++++++ | 69 | include/sysemu/rtc.h | 4 +- |
87 | target/arm/neon-ls.decode | 4 +- | 70 | target/arm/cpregs.h | 2 + |
88 | hw/arm/smmuv3.c | 6 +- | 71 | target/arm/cpu.h | 5 +- |
89 | hw/arm/virt.c | 7 +- | 72 | target/arm/internals.h | 6 - |
90 | hw/core/machine.c | 5 + | 73 | target/arm/tcg/translate.h | 2 + |
91 | hw/i386/pc.c | 3 + | 74 | hw/arm/armsse.c | 16 ++ |
92 | hw/i386/pc_piix.c | 14 +- | 75 | hw/arm/armv7m.c | 21 +++ |
93 | hw/i386/pc_q35.c | 13 +- | 76 | hw/arm/fsl-imx6ul.c | 174 +++++++++++++-------- |
94 | hw/pci-host/gpex.c | 56 +++++++- | 77 | hw/arm/fsl-imx7.c | 201 +++++++++++++++++++----- |
95 | hw/ppc/spapr.c | 17 ++- | 78 | hw/arm/mps2-tz.c | 29 ++++ |
96 | hw/s390x/s390-virtio-ccw.c | 14 +- | 79 | hw/misc/imx7_src.c | 276 +++++++++++++++++++++++++++++++++ |
97 | target/arm/helper-a64.c | 2 +- | 80 | hw/rtc/aspeed_rtc.c | 5 +- |
98 | target/arm/helper.c | 162 ++++++++++++---------- | 81 | hw/rtc/m48t59.c | 2 +- |
99 | target/arm/mte_helper.c | 185 ++++++++++--------------- | 82 | hw/rtc/twl92230.c | 4 +- |
100 | target/arm/sve_helper.c | 100 +++++--------- | 83 | softmmu/rtc.c | 4 +- |
101 | target/arm/translate-a64.c | 236 ++++++++++++++++---------------- | 84 | target/arm/cpu.c | 207 ++++++++++++++----------- |
102 | target/arm/translate-sve.c | 11 +- | 85 | target/arm/helper.c | 15 +- |
103 | target/arm/translate.c | 274 ++++++++++++++++++++++---------------- | 86 | target/arm/tcg/cpu32.c | 2 +- |
104 | tests/tcg/aarch64/mte-5.c | 44 ++++++ | 87 | target/arm/tcg/cpu64.c | 102 +++++++++---- |
105 | target/arm/translate-neon.c.inc | 117 ++++++++++++---- | 88 | target/arm/tcg/helper-a64.c | 9 ++ |
106 | target/arm/translate-vfp.c.inc | 20 +-- | 89 | target/arm/tcg/mte_helper.c | 90 ++++++++--- |
107 | tests/tcg/aarch64/Makefile.target | 2 +- | 90 | target/arm/tcg/translate-a64.c | 5 +- |
108 | 29 files changed, 878 insertions(+), 583 deletions(-) | 91 | hw/misc/meson.build | 1 + |
109 | create mode 100644 tests/tcg/aarch64/mte-5.c | 92 | hw/misc/trace-events | 4 + |
93 | 31 files changed, 1393 insertions(+), 372 deletions(-) | ||
94 | create mode 100644 include/hw/misc/imx7_src.h | ||
95 | create mode 100644 hw/misc/imx7_src.c | ||
110 | 96 | 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: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We're about to rearrange the macro expansion surrounding tbflags, | 3 | This value is only 4 bits wide. |
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 | 4 | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20210419202257.161730-3-richard.henderson@linaro.org | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Message-id: 20230811214031.171020-2-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | target/arm/cpu.h | 2 +- | 11 | target/arm/cpu.h | 3 ++- |
15 | target/arm/helper.c | 2 +- | 12 | 1 file changed, 2 insertions(+), 1 deletion(-) |
16 | target/arm/translate.c | 2 +- | ||
17 | 3 files changed, 3 insertions(+), 3 deletions(-) | ||
18 | 13 | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
20 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 16 | --- a/target/arm/cpu.h |
22 | +++ b/target/arm/cpu.h | 17 | +++ b/target/arm/cpu.h |
23 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, VECSTRIDE, 12, 2) /* Not cached. */ | 18 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
24 | */ | 19 | bool prop_lpa2; |
25 | FIELD(TBFLAG_A32, XSCALE_CPAR, 12, 2) | 20 | |
26 | FIELD(TBFLAG_A32, VFPEN, 14, 1) /* Partially cached, minus FPEXC. */ | 21 | /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ |
27 | -FIELD(TBFLAG_A32, SCTLR_B, 15, 1) | 22 | - uint32_t dcz_blocksize; |
28 | +FIELD(TBFLAG_A32, SCTLR__B, 15, 1) /* Cannot overlap with SCTLR_B */ | 23 | + uint8_t dcz_blocksize; |
29 | FIELD(TBFLAG_A32, HSTR_ACTIVE, 16, 1) | 24 | + |
30 | /* | 25 | uint64_t rvbar_prop; /* Property/input signals. */ |
31 | * Indicates whether cp register reads and writes by guest code should access | 26 | |
32 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 27 | /* Configurable aspects of GIC cpu interface (which is part of the CPU) */ |
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 | -- | 28 | -- |
59 | 2.20.1 | 29 | 2.34.1 |
60 | 30 | ||
61 | 31 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Now that we have all of the proper macros defined, expanding | 3 | Previously we hard-coded the blocksize with GMID_EL1_BS. |
4 | the CPUARMTBFlags structure and populating the two TB fields | 4 | But the value we choose for -cpu max does not match the |
5 | is relatively simple. | 5 | value that cortex-a710 uses. |
6 | |||
7 | Mirror the way we handle dcz_blocksize. | ||
6 | 8 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20210419202257.161730-7-richard.henderson@linaro.org | 11 | Message-id: 20230811214031.171020-3-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 13 | --- |
12 | target/arm/cpu.h | 49 ++++++++++++++++++++++++------------------ | 14 | target/arm/cpu.h | 2 ++ |
13 | target/arm/translate.h | 2 +- | 15 | target/arm/internals.h | 6 ----- |
14 | target/arm/helper.c | 10 +++++---- | 16 | target/arm/tcg/translate.h | 2 ++ |
15 | 3 files changed, 35 insertions(+), 26 deletions(-) | 17 | target/arm/helper.c | 11 +++++--- |
18 | target/arm/tcg/cpu64.c | 1 + | ||
19 | target/arm/tcg/mte_helper.c | 46 ++++++++++++++++++++++------------ | ||
20 | target/arm/tcg/translate-a64.c | 5 ++-- | ||
21 | 7 files changed, 45 insertions(+), 28 deletions(-) | ||
16 | 22 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 23 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
18 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 25 | --- a/target/arm/cpu.h |
20 | +++ b/target/arm/cpu.h | 26 | +++ b/target/arm/cpu.h |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMPACKey { | 27 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
22 | /* See the commentary above the TBFLAG field definitions. */ | 28 | |
23 | typedef struct CPUARMTBFlags { | 29 | /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ |
24 | uint32_t flags; | 30 | uint8_t dcz_blocksize; |
25 | + target_ulong flags2; | 31 | + /* GM blocksize, in log_2(words), ie low 4 bits of GMID_EL0 */ |
26 | } CPUARMTBFlags; | 32 | + uint8_t gm_blocksize; |
27 | 33 | ||
28 | typedef struct CPUARMState { | 34 | uint64_t rvbar_prop; /* Property/input signals. */ |
29 | @@ -XXX,XX +XXX,XX @@ typedef ARMCPU ArchCPU; | 35 | |
30 | #include "exec/cpu-all.h" | 36 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
31 | 37 | index XXXXXXX..XXXXXXX 100644 | |
38 | --- a/target/arm/internals.h | ||
39 | +++ b/target/arm/internals.h | ||
40 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs); | ||
41 | |||
42 | #endif /* !CONFIG_USER_ONLY */ | ||
43 | |||
44 | -/* | ||
45 | - * The log2 of the words in the tag block, for GMID_EL1.BS. | ||
46 | - * The is the maximum, 256 bytes, which manipulates 64-bits of tags. | ||
47 | - */ | ||
48 | -#define GMID_EL1_BS 6 | ||
49 | - | ||
32 | /* | 50 | /* |
33 | - * Bit usage in the TB flags field: bit 31 indicates whether we are | 51 | * SVE predicates are 1/8 the size of SVE vectors, and cannot use |
34 | - * in 32 or 64 bit mode. The meaning of the other bits depends on that. | 52 | * the same simd_desc() encoding due to restrictions on size. |
35 | - * We put flags which are shared between 32 and 64 bit mode at the top | 53 | diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h |
36 | - * of the word, and flags which apply to only one mode at the bottom. | 54 | index XXXXXXX..XXXXXXX 100644 |
37 | + * We have more than 32-bits worth of state per TB, so we split the data | 55 | --- a/target/arm/tcg/translate.h |
38 | + * between tb->flags and tb->cs_base, which is otherwise unused for ARM. | 56 | +++ b/target/arm/tcg/translate.h |
39 | + * We collect these two parts in CPUARMTBFlags where they are named | 57 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { |
40 | + * flags and flags2 respectively. | 58 | int8_t btype; |
41 | * | 59 | /* A copy of cpu->dcz_blocksize. */ |
42 | - * 31 20 18 14 9 0 | 60 | uint8_t dcz_blocksize; |
43 | - * +--------------+-----+-----+----------+--------------+ | 61 | + /* A copy of cpu->gm_blocksize. */ |
44 | - * | | | TBFLAG_A32 | | | 62 | + uint8_t gm_blocksize; |
45 | - * | | +-----+----------+ TBFLAG_AM32 | | 63 | /* True if this page is guarded. */ |
46 | - * | TBFLAG_ANY | |TBFLAG_M32| | | 64 | bool guarded_page; |
47 | - * | +-----------+----------+--------------| | 65 | /* Bottom two bits of XScale c15_cpar coprocessor access control reg */ |
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 | 66 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
111 | index XXXXXXX..XXXXXXX 100644 | 67 | index XXXXXXX..XXXXXXX 100644 |
112 | --- a/target/arm/helper.c | 68 | --- a/target/arm/helper.c |
113 | +++ b/target/arm/helper.c | 69 | +++ b/target/arm/helper.c |
114 | @@ -XXX,XX +XXX,XX @@ static inline void assert_hflags_rebuild_correctly(CPUARMState *env) | 70 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = { |
115 | CPUARMTBFlags c = env->hflags; | 71 | .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 6, |
116 | CPUARMTBFlags r = rebuild_hflags_internal(env); | 72 | .access = PL1_RW, .accessfn = access_mte, |
117 | 73 | .fieldoffset = offsetof(CPUARMState, cp15.gcr_el1) }, | |
118 | - if (unlikely(c.flags != r.flags)) { | 74 | - { .name = "GMID_EL1", .state = ARM_CP_STATE_AA64, |
119 | - fprintf(stderr, "TCG hflags mismatch (current:0x%08x rebuilt:0x%08x)\n", | 75 | - .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 4, |
120 | - c.flags, r.flags); | 76 | - .access = PL1_R, .accessfn = access_aa64_tid5, |
121 | + if (unlikely(c.flags != r.flags || c.flags2 != r.flags2)) { | 77 | - .type = ARM_CP_CONST, .resetvalue = GMID_EL1_BS }, |
122 | + fprintf(stderr, "TCG hflags mismatch " | 78 | { .name = "TCO", .state = ARM_CP_STATE_AA64, |
123 | + "(current:(0x%08x,0x" TARGET_FMT_lx ")" | 79 | .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 7, |
124 | + " rebuilt:(0x%08x,0x" TARGET_FMT_lx ")\n", | 80 | .type = ARM_CP_NO_RAW, |
125 | + c.flags, c.flags2, r.flags, r.flags2); | 81 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
126 | abort(); | 82 | * then define only a RAZ/WI version of PSTATE.TCO. |
83 | */ | ||
84 | if (cpu_isar_feature(aa64_mte, cpu)) { | ||
85 | + ARMCPRegInfo gmid_reginfo = { | ||
86 | + .name = "GMID_EL1", .state = ARM_CP_STATE_AA64, | ||
87 | + .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 4, | ||
88 | + .access = PL1_R, .accessfn = access_aa64_tid5, | ||
89 | + .type = ARM_CP_CONST, .resetvalue = cpu->gm_blocksize, | ||
90 | + }; | ||
91 | + define_one_arm_cp_reg(cpu, &gmid_reginfo); | ||
92 | define_arm_cp_regs(cpu, mte_reginfo); | ||
93 | define_arm_cp_regs(cpu, mte_el0_cacheop_reginfo); | ||
94 | } else if (cpu_isar_feature(aa64_mte_insn_reg, cpu)) { | ||
95 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/target/arm/tcg/cpu64.c | ||
98 | +++ b/target/arm/tcg/cpu64.c | ||
99 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) | ||
100 | cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ | ||
101 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
102 | #endif | ||
103 | + cpu->gm_blocksize = 6; /* 256 bytes */ | ||
104 | |||
105 | cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); | ||
106 | cpu->sme_vq.supported = SVE_VQ_POW2_MAP; | ||
107 | diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/target/arm/tcg/mte_helper.c | ||
110 | +++ b/target/arm/tcg/mte_helper.c | ||
111 | @@ -XXX,XX +XXX,XX @@ void HELPER(st2g_stub)(CPUARMState *env, uint64_t ptr) | ||
127 | } | 112 | } |
128 | #endif | 113 | } |
129 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 114 | |
115 | -#define LDGM_STGM_SIZE (4 << GMID_EL1_BS) | ||
116 | - | ||
117 | uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) | ||
130 | { | 118 | { |
131 | CPUARMTBFlags flags; | 119 | int mmu_idx = cpu_mmu_index(env, false); |
132 | 120 | uintptr_t ra = GETPC(); | |
133 | - *cs_base = 0; | 121 | + int gm_bs = env_archcpu(env)->gm_blocksize; |
134 | assert_hflags_rebuild_correctly(env); | 122 | + int gm_bs_bytes = 4 << gm_bs; |
135 | flags = env->hflags; | 123 | void *tag_mem; |
136 | 124 | ||
137 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 125 | - ptr = QEMU_ALIGN_DOWN(ptr, LDGM_STGM_SIZE); |
126 | + ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | ||
127 | |||
128 | /* Trap if accessing an invalid page. */ | ||
129 | tag_mem = allocation_tag_mem(env, mmu_idx, ptr, MMU_DATA_LOAD, | ||
130 | - LDGM_STGM_SIZE, MMU_DATA_LOAD, | ||
131 | - LDGM_STGM_SIZE / (2 * TAG_GRANULE), ra); | ||
132 | + gm_bs_bytes, MMU_DATA_LOAD, | ||
133 | + gm_bs_bytes / (2 * TAG_GRANULE), ra); | ||
134 | |||
135 | /* The tag is squashed to zero if the page does not support tags. */ | ||
136 | if (!tag_mem) { | ||
137 | return 0; | ||
138 | } | 138 | } |
139 | 139 | ||
140 | *pflags = flags.flags; | 140 | - QEMU_BUILD_BUG_ON(GMID_EL1_BS != 6); |
141 | + *cs_base = flags.flags2; | 141 | /* |
142 | - * We are loading 64-bits worth of tags. The ordering of elements | ||
143 | - * within the word corresponds to a 64-bit little-endian operation. | ||
144 | + * The ordering of elements within the word corresponds to | ||
145 | + * a little-endian operation. | ||
146 | */ | ||
147 | - return ldq_le_p(tag_mem); | ||
148 | + switch (gm_bs) { | ||
149 | + case 6: | ||
150 | + /* 256 bytes -> 16 tags -> 64 result bits */ | ||
151 | + return ldq_le_p(tag_mem); | ||
152 | + default: | ||
153 | + /* cpu configured with unsupported gm blocksize. */ | ||
154 | + g_assert_not_reached(); | ||
155 | + } | ||
142 | } | 156 | } |
143 | 157 | ||
144 | #ifdef TARGET_AARCH64 | 158 | void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) |
159 | { | ||
160 | int mmu_idx = cpu_mmu_index(env, false); | ||
161 | uintptr_t ra = GETPC(); | ||
162 | + int gm_bs = env_archcpu(env)->gm_blocksize; | ||
163 | + int gm_bs_bytes = 4 << gm_bs; | ||
164 | void *tag_mem; | ||
165 | |||
166 | - ptr = QEMU_ALIGN_DOWN(ptr, LDGM_STGM_SIZE); | ||
167 | + ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | ||
168 | |||
169 | /* Trap if accessing an invalid page. */ | ||
170 | tag_mem = allocation_tag_mem(env, mmu_idx, ptr, MMU_DATA_STORE, | ||
171 | - LDGM_STGM_SIZE, MMU_DATA_LOAD, | ||
172 | - LDGM_STGM_SIZE / (2 * TAG_GRANULE), ra); | ||
173 | + gm_bs_bytes, MMU_DATA_LOAD, | ||
174 | + gm_bs_bytes / (2 * TAG_GRANULE), ra); | ||
175 | |||
176 | /* | ||
177 | * Tag store only happens if the page support tags, | ||
178 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
179 | return; | ||
180 | } | ||
181 | |||
182 | - QEMU_BUILD_BUG_ON(GMID_EL1_BS != 6); | ||
183 | /* | ||
184 | - * We are storing 64-bits worth of tags. The ordering of elements | ||
185 | - * within the word corresponds to a 64-bit little-endian operation. | ||
186 | + * The ordering of elements within the word corresponds to | ||
187 | + * a little-endian operation. | ||
188 | */ | ||
189 | - stq_le_p(tag_mem, val); | ||
190 | + switch (gm_bs) { | ||
191 | + case 6: | ||
192 | + stq_le_p(tag_mem, val); | ||
193 | + break; | ||
194 | + default: | ||
195 | + /* cpu configured with unsupported gm blocksize. */ | ||
196 | + g_assert_not_reached(); | ||
197 | + } | ||
198 | } | ||
199 | |||
200 | void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
201 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
202 | index XXXXXXX..XXXXXXX 100644 | ||
203 | --- a/target/arm/tcg/translate-a64.c | ||
204 | +++ b/target/arm/tcg/translate-a64.c | ||
205 | @@ -XXX,XX +XXX,XX @@ static bool trans_STGM(DisasContext *s, arg_ldst_tag *a) | ||
206 | gen_helper_stgm(cpu_env, addr, tcg_rt); | ||
207 | } else { | ||
208 | MMUAccessType acc = MMU_DATA_STORE; | ||
209 | - int size = 4 << GMID_EL1_BS; | ||
210 | + int size = 4 << s->gm_blocksize; | ||
211 | |||
212 | clean_addr = clean_data_tbi(s, addr); | ||
213 | tcg_gen_andi_i64(clean_addr, clean_addr, -size); | ||
214 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDGM(DisasContext *s, arg_ldst_tag *a) | ||
215 | gen_helper_ldgm(tcg_rt, cpu_env, addr); | ||
216 | } else { | ||
217 | MMUAccessType acc = MMU_DATA_LOAD; | ||
218 | - int size = 4 << GMID_EL1_BS; | ||
219 | + int size = 4 << s->gm_blocksize; | ||
220 | |||
221 | clean_addr = clean_data_tbi(s, addr); | ||
222 | tcg_gen_andi_i64(clean_addr, clean_addr, -size); | ||
223 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
224 | dc->cp_regs = arm_cpu->cp_regs; | ||
225 | dc->features = env->features; | ||
226 | dc->dcz_blocksize = arm_cpu->dcz_blocksize; | ||
227 | + dc->gm_blocksize = arm_cpu->gm_blocksize; | ||
228 | |||
229 | #ifdef CONFIG_USER_ONLY | ||
230 | /* In sve_probe_page, we assume TBI is enabled. */ | ||
145 | -- | 231 | -- |
146 | 2.20.1 | 232 | 2.34.1 |
147 | |||
148 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Support all of the easy GM block sizes. | ||
4 | Use direct memory operations, since the pointers are aligned. | ||
5 | |||
6 | While BS=2 (16 bytes, 1 tag) is a legal setting, that requires | ||
7 | an atomic store of one nibble. This is not difficult, but there | ||
8 | is also no point in supporting it until required. | ||
9 | |||
10 | Note that cortex-a710 sets GM blocksize to match its cacheline | ||
11 | size of 64 bytes. I expect many implementations will also | ||
12 | match the cacheline, which makes 16 bytes very unlikely. | ||
13 | |||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Message-id: 20230811214031.171020-4-richard.henderson@linaro.org |
5 | Message-id: 20210419202257.161730-28-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 18 | --- |
8 | target/arm/translate-a64.c | 23 ++++++++++++++--------- | 19 | target/arm/cpu.c | 18 +++++++++--- |
9 | 1 file changed, 14 insertions(+), 9 deletions(-) | 20 | target/arm/tcg/mte_helper.c | 56 +++++++++++++++++++++++++++++++------ |
21 | 2 files changed, 62 insertions(+), 12 deletions(-) | ||
10 | 22 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 23 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
12 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 25 | --- a/target/arm/cpu.c |
14 | +++ b/target/arm/translate-a64.c | 26 | +++ b/target/arm/cpu.c |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | 27 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
16 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | 28 | ID_PFR1, VIRTUALIZATION, 0); |
17 | clean_addr = gen_mte_check1(s, cpu_reg_sp(s, rn), | 29 | } |
18 | true, rn != 31, size); | 30 | |
19 | - do_gpr_st(s, cpu_reg(s, rt), clean_addr, size, true, rt, | 31 | + if (cpu_isar_feature(aa64_mte, cpu)) { |
20 | + /* TODO: ARMv8.4-LSE SCTLR.nAA */ | 32 | + /* |
21 | + do_gpr_st(s, cpu_reg(s, rt), clean_addr, size | MO_ALIGN, true, rt, | 33 | + * The architectural range of GM blocksize is 2-6, however qemu |
22 | disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | 34 | + * doesn't support blocksize of 2 (see HELPER(ldgm)). |
23 | return; | 35 | + */ |
24 | 36 | + if (tcg_enabled()) { | |
25 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | 37 | + assert(cpu->gm_blocksize >= 3 && cpu->gm_blocksize <= 6); |
26 | } | 38 | + } |
27 | clean_addr = gen_mte_check1(s, cpu_reg_sp(s, rn), | 39 | + |
28 | false, rn != 31, size); | 40 | #ifndef CONFIG_USER_ONLY |
29 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size, false, true, rt, | 41 | - if (cpu->tag_memory == NULL && cpu_isar_feature(aa64_mte, cpu)) { |
30 | - disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | 42 | /* |
31 | + /* TODO: ARMv8.4-LSE SCTLR.nAA */ | 43 | * Disable the MTE feature bits if we do not have tag-memory |
32 | + do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size | MO_ALIGN, false, true, | 44 | * provided by the machine. |
33 | + rt, disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | 45 | */ |
34 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | 46 | - cpu->isar.id_aa64pfr1 = |
35 | return; | 47 | - FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); |
36 | 48 | - } | |
37 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | 49 | + if (cpu->tag_memory == NULL) { |
38 | int size = extract32(insn, 30, 2); | 50 | + cpu->isar.id_aa64pfr1 = |
39 | TCGv_i64 clean_addr, dirty_addr; | 51 | + FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); |
40 | bool is_store = false; | 52 | + } |
41 | - bool is_signed = false; | 53 | #endif |
42 | bool extend = false; | 54 | + } |
43 | bool iss_sf; | 55 | |
44 | + MemOp mop; | 56 | if (tcg_enabled()) { |
45 | 57 | /* | |
46 | if (!dc_isar_feature(aa64_rcpc_8_4, s)) { | 58 | diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c |
47 | unallocated_encoding(s); | 59 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/target/arm/tcg/mte_helper.c | ||
61 | +++ b/target/arm/tcg/mte_helper.c | ||
62 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) | ||
63 | int gm_bs = env_archcpu(env)->gm_blocksize; | ||
64 | int gm_bs_bytes = 4 << gm_bs; | ||
65 | void *tag_mem; | ||
66 | + uint64_t ret; | ||
67 | + int shift; | ||
68 | |||
69 | ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | ||
70 | |||
71 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) | ||
72 | |||
73 | /* | ||
74 | * The ordering of elements within the word corresponds to | ||
75 | - * a little-endian operation. | ||
76 | + * a little-endian operation. Computation of shift comes from | ||
77 | + * | ||
78 | + * index = address<LOG2_TAG_GRANULE+3:LOG2_TAG_GRANULE> | ||
79 | + * data<index*4+3:index*4> = tag | ||
80 | + * | ||
81 | + * Because of the alignment of ptr above, BS=6 has shift=0. | ||
82 | + * All memory operations are aligned. Defer support for BS=2, | ||
83 | + * requiring insertion or extraction of a nibble, until we | ||
84 | + * support a cpu that requires it. | ||
85 | */ | ||
86 | switch (gm_bs) { | ||
87 | + case 3: | ||
88 | + /* 32 bytes -> 2 tags -> 8 result bits */ | ||
89 | + ret = *(uint8_t *)tag_mem; | ||
90 | + break; | ||
91 | + case 4: | ||
92 | + /* 64 bytes -> 4 tags -> 16 result bits */ | ||
93 | + ret = cpu_to_le16(*(uint16_t *)tag_mem); | ||
94 | + break; | ||
95 | + case 5: | ||
96 | + /* 128 bytes -> 8 tags -> 32 result bits */ | ||
97 | + ret = cpu_to_le32(*(uint32_t *)tag_mem); | ||
98 | + break; | ||
99 | case 6: | ||
100 | /* 256 bytes -> 16 tags -> 64 result bits */ | ||
101 | - return ldq_le_p(tag_mem); | ||
102 | + return cpu_to_le64(*(uint64_t *)tag_mem); | ||
103 | default: | ||
104 | - /* cpu configured with unsupported gm blocksize. */ | ||
105 | + /* | ||
106 | + * CPU configured with unsupported/invalid gm blocksize. | ||
107 | + * This is detected early in arm_cpu_realizefn. | ||
108 | + */ | ||
109 | g_assert_not_reached(); | ||
110 | } | ||
111 | + shift = extract64(ptr, LOG2_TAG_GRANULE, 4) * 4; | ||
112 | + return ret << shift; | ||
113 | } | ||
114 | |||
115 | void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
116 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
117 | int gm_bs = env_archcpu(env)->gm_blocksize; | ||
118 | int gm_bs_bytes = 4 << gm_bs; | ||
119 | void *tag_mem; | ||
120 | + int shift; | ||
121 | |||
122 | ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | ||
123 | |||
124 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
48 | return; | 125 | return; |
49 | } | 126 | } |
50 | 127 | ||
51 | + /* TODO: ARMv8.4-LSE SCTLR.nAA */ | 128 | - /* |
52 | + mop = size | MO_ALIGN; | 129 | - * The ordering of elements within the word corresponds to |
53 | + | 130 | - * a little-endian operation. |
54 | switch (opc) { | 131 | - */ |
55 | case 0: /* STLURB */ | 132 | + /* See LDGM for comments on BS and on shift. */ |
56 | is_store = true; | 133 | + shift = extract64(ptr, LOG2_TAG_GRANULE, 4) * 4; |
57 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | 134 | + val >>= shift; |
58 | unallocated_encoding(s); | 135 | switch (gm_bs) { |
59 | return; | 136 | + case 3: |
60 | } | 137 | + /* 32 bytes -> 2 tags -> 8 result bits */ |
61 | - is_signed = true; | 138 | + *(uint8_t *)tag_mem = val; |
62 | + mop |= MO_SIGN; | 139 | + break; |
63 | break; | 140 | + case 4: |
64 | case 3: /* LDAPURS* 32-bit variant */ | 141 | + /* 64 bytes -> 4 tags -> 16 result bits */ |
65 | if (size > 1) { | 142 | + *(uint16_t *)tag_mem = cpu_to_le16(val); |
66 | unallocated_encoding(s); | 143 | + break; |
67 | return; | 144 | + case 5: |
68 | } | 145 | + /* 128 bytes -> 8 tags -> 32 result bits */ |
69 | - is_signed = true; | 146 | + *(uint32_t *)tag_mem = cpu_to_le32(val); |
70 | + mop |= MO_SIGN; | 147 | + break; |
71 | extend = true; /* zero-extend 32->64 after signed load */ | 148 | case 6: |
149 | - stq_le_p(tag_mem, val); | ||
150 | + /* 256 bytes -> 16 tags -> 64 result bits */ | ||
151 | + *(uint64_t *)tag_mem = cpu_to_le64(val); | ||
72 | break; | 152 | break; |
73 | default: | 153 | default: |
74 | g_assert_not_reached(); | 154 | /* cpu configured with unsupported gm blocksize. */ |
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 { | ||
89 | /* | ||
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 | } | ||
98 | -- | 155 | -- |
99 | 2.20.1 | 156 | 2.34.1 |
100 | |||
101 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When the cpu support MTE, but the system does not, reduce cpu | ||
4 | support to user instructions at EL0 instead of completely | ||
5 | disabling MTE. If we encounter a cpu implementation which does | ||
6 | something else, we can revisit this setting. | ||
7 | |||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Message-id: 20230811214031.171020-5-richard.henderson@linaro.org |
5 | Message-id: 20210419202257.161730-21-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 12 | --- |
8 | target/arm/translate-vfp.c.inc | 8 ++++---- | 13 | target/arm/cpu.c | 7 ++++--- |
9 | 1 file changed, 4 insertions(+), 4 deletions(-) | 14 | 1 file changed, 4 insertions(+), 3 deletions(-) |
10 | 15 | ||
11 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | 16 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
12 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-vfp.c.inc | 18 | --- a/target/arm/cpu.c |
14 | +++ b/target/arm/translate-vfp.c.inc | 19 | +++ b/target/arm/cpu.c |
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) | 20 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
16 | for (i = 0; i < n; i++) { | 21 | |
17 | if (a->l) { | 22 | #ifndef CONFIG_USER_ONLY |
18 | /* load */ | 23 | /* |
19 | - gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | 24 | - * Disable the MTE feature bits if we do not have tag-memory |
20 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | 25 | - * provided by the machine. |
21 | vfp_store_reg32(tmp, a->vd + i); | 26 | + * If we do not have tag-memory provided by the machine, |
22 | } else { | 27 | + * reduce MTE support to instructions enabled at EL0. |
23 | /* store */ | 28 | + * This matches Cortex-A710 BROADCASTMTE input being LOW. |
24 | vfp_load_reg32(tmp, a->vd + i); | 29 | */ |
25 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | 30 | if (cpu->tag_memory == NULL) { |
26 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | 31 | cpu->isar.id_aa64pfr1 = |
32 | - FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); | ||
33 | + FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 1); | ||
27 | } | 34 | } |
28 | tcg_gen_addi_i32(addr, addr, offset); | 35 | #endif |
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 | } | 36 | } |
45 | -- | 37 | -- |
46 | 2.20.1 | 38 | 2.34.1 |
47 | |||
48 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Do not hard-code the constants for Neoverse V1. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Message-id: 20230811214031.171020-6-richard.henderson@linaro.org |
5 | Message-id: 20210419202257.161730-23-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 9 | --- |
8 | target/arm/translate.h | 1 + | 10 | target/arm/tcg/cpu64.c | 48 ++++++++++++++++++++++++++++-------------- |
9 | target/arm/translate.c | 15 +++++++++++++ | 11 | 1 file changed, 32 insertions(+), 16 deletions(-) |
10 | target/arm/translate-neon.c.inc | 37 +++++++++++++++++++++++++-------- | ||
11 | 3 files changed, 44 insertions(+), 9 deletions(-) | ||
12 | 12 | ||
13 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 13 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.h | 15 | --- a/target/arm/tcg/cpu64.c |
16 | +++ b/target/arm/translate.h | 16 | +++ b/target/arm/tcg/cpu64.c |
17 | @@ -XXX,XX +XXX,XX @@ void arm_test_cc(DisasCompare *cmp, int cc); | 17 | @@ -XXX,XX +XXX,XX @@ |
18 | void arm_free_cc(DisasCompare *cmp); | 18 | #include "qemu/module.h" |
19 | void arm_jump_cc(DisasCompare *cmp, TCGLabel *label); | 19 | #include "qapi/visitor.h" |
20 | void arm_gen_test_cc(int cc, TCGLabel *label); | 20 | #include "hw/qdev-properties.h" |
21 | +MemOp pow2_align(unsigned i); | 21 | +#include "qemu/units.h" |
22 | 22 | #include "internals.h" | |
23 | /* Return state of Alternate Half-precision flag, caller frees result */ | 23 | #include "cpregs.h" |
24 | static inline TCGv_i32 get_ahp_flag(void) | 24 | |
25 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 25 | +static uint64_t make_ccsidr64(unsigned assoc, unsigned linesize, |
26 | index XXXXXXX..XXXXXXX 100644 | 26 | + unsigned cachesize) |
27 | --- a/target/arm/translate.c | ||
28 | +++ b/target/arm/translate.c | ||
29 | @@ -XXX,XX +XXX,XX @@ static inline void store_reg_from_load(DisasContext *s, int reg, TCGv_i32 var) | ||
30 | #define IS_USER_ONLY 0 | ||
31 | #endif | ||
32 | |||
33 | +MemOp pow2_align(unsigned i) | ||
34 | +{ | 27 | +{ |
35 | + static const MemOp mop_align[] = { | 28 | + unsigned lg_linesize = ctz32(linesize); |
36 | + 0, MO_ALIGN_2, MO_ALIGN_4, MO_ALIGN_8, MO_ALIGN_16, | 29 | + unsigned sets; |
37 | + /* | 30 | + |
38 | + * FIXME: TARGET_PAGE_BITS_MIN affects TLB_FLAGS_MASK such | 31 | + /* |
39 | + * that 256-bit alignment (MO_ALIGN_32) cannot be supported: | 32 | + * The 64-bit CCSIDR_EL1 format is: |
40 | + * see get_alignment_bits(). Enforce only 128-bit alignment for now. | 33 | + * [55:32] number of sets - 1 |
41 | + */ | 34 | + * [23:3] associativity - 1 |
42 | + MO_ALIGN_16 | 35 | + * [2:0] log2(linesize) - 4 |
43 | + }; | 36 | + * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc |
44 | + g_assert(i < ARRAY_SIZE(mop_align)); | 37 | + */ |
45 | + return mop_align[i]; | 38 | + assert(assoc != 0); |
39 | + assert(is_power_of_2(linesize)); | ||
40 | + assert(lg_linesize >= 4 && lg_linesize <= 7 + 4); | ||
41 | + | ||
42 | + /* sets * associativity * linesize == cachesize. */ | ||
43 | + sets = cachesize / (assoc * linesize); | ||
44 | + assert(cachesize % (assoc * linesize) == 0); | ||
45 | + | ||
46 | + return ((uint64_t)(sets - 1) << 32) | ||
47 | + | ((assoc - 1) << 3) | ||
48 | + | (lg_linesize - 4); | ||
46 | +} | 49 | +} |
47 | + | 50 | + |
48 | /* | 51 | static void aarch64_a35_initfn(Object *obj) |
49 | * Abstractions of "generate code to do a guest load/store for | 52 | { |
50 | * AArch32", where a vaddr is always 32 bits (and is zero | 53 | ARMCPU *cpu = ARM_CPU(obj); |
51 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 54 | @@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_v1_initfn(Object *obj) |
52 | index XXXXXXX..XXXXXXX 100644 | 55 | * The Neoverse-V1 r1p2 TRM lists 32-bit format CCSIDR_EL1 values, |
53 | --- a/target/arm/translate-neon.c.inc | 56 | * but also says it implements CCIDX, which means they should be |
54 | +++ b/target/arm/translate-neon.c.inc | 57 | * 64-bit format. So we here use values which are based on the textual |
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | 58 | - * information in chapter 2 of the TRM (and on the fact that |
56 | int size = a->size; | 59 | - * sets * associativity * linesize == cachesize). |
57 | int nregs = a->n + 1; | 60 | - * |
58 | TCGv_i32 addr, tmp; | 61 | - * The 64-bit CCSIDR_EL1 format is: |
59 | + MemOp mop, align; | 62 | - * [55:32] number of sets - 1 |
60 | 63 | - * [23:3] associativity - 1 | |
61 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 64 | - * [2:0] log2(linesize) - 4 |
62 | return false; | 65 | - * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc |
63 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | 66 | - * |
64 | return false; | 67 | - * L1: 4-way set associative 64-byte line size, total size 64K, |
65 | } | 68 | - * so sets is 256. |
66 | 69 | + * information in chapter 2 of the TRM: | |
67 | + align = 0; | 70 | * |
68 | if (size == 3) { | 71 | + * L1: 4-way set associative 64-byte line size, total size 64K. |
69 | if (nregs != 4 || a->a == 0) { | 72 | * L2: 8-way set associative, 64 byte line size, either 512K or 1MB. |
70 | return false; | 73 | - * We pick 1MB, so this has 2048 sets. |
71 | } | 74 | - * |
72 | /* For VLD4 size == 3 a == 1 means 32 bits at 16 byte alignment */ | 75 | * L3: No L3 (this matches the CLIDR_EL1 value). |
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 | */ | 76 | */ |
106 | stride = a->t ? 2 : 1; | 77 | - cpu->ccsidr[0] = 0x000000ff0000001aull; /* 64KB L1 dcache */ |
107 | vec_size = nregs == 1 ? stride * 8 : 8; | 78 | - cpu->ccsidr[1] = 0x000000ff0000001aull; /* 64KB L1 icache */ |
108 | - | 79 | - cpu->ccsidr[2] = 0x000007ff0000003aull; /* 1MB L2 cache */ |
109 | + mop = size | align; | 80 | + cpu->ccsidr[0] = make_ccsidr64(4, 64, 64 * KiB); /* L1 dcache */ |
110 | tmp = tcg_temp_new_i32(); | 81 | + cpu->ccsidr[1] = cpu->ccsidr[0]; /* L1 icache */ |
111 | addr = tcg_temp_new_i32(); | 82 | + cpu->ccsidr[2] = make_ccsidr64(8, 64, 1 * MiB); /* L2 cache */ |
112 | load_reg_var(s, addr, a->rn); | 83 | |
113 | for (reg = 0; reg < nregs; reg++) { | 84 | /* From 3.2.115 SCTLR_EL3 */ |
114 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), size); | 85 | cpu->reset_sctlr = 0x30c50838; |
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 | -- | 86 | -- |
130 | 2.20.1 | 87 | 2.34.1 |
131 | |||
132 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In preparation for splitting tb->flags across multiple | 3 | Access to many of the special registers is enabled or disabled |
4 | fields, introduce a structure to hold the value(s). | 4 | by ACTLR_EL[23], which we implement as constant 0, which means |
5 | So far this only migrates the one uint32_t and fixes | 5 | that all writes outside EL3 should trap. |
6 | all of the places that require adjustment to match. | ||
7 | 6 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Message-id: 20230811214031.171020-7-richard.henderson@linaro.org |
10 | Message-id: 20210419202257.161730-6-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | target/arm/cpu.h | 26 ++++++++++++--------- | 12 | target/arm/cpregs.h | 2 ++ |
14 | target/arm/translate.h | 11 +++++++++ | 13 | target/arm/helper.c | 4 ++-- |
15 | target/arm/helper.c | 48 +++++++++++++++++++++----------------- | 14 | target/arm/tcg/cpu64.c | 46 +++++++++++++++++++++++++++++++++--------- |
16 | target/arm/translate-a64.c | 2 +- | 15 | 3 files changed, 41 insertions(+), 11 deletions(-) |
17 | target/arm/translate.c | 7 +++--- | ||
18 | 5 files changed, 57 insertions(+), 37 deletions(-) | ||
19 | 16 | ||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 17 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
21 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 19 | --- a/target/arm/cpregs.h |
23 | +++ b/target/arm/cpu.h | 20 | +++ b/target/arm/cpregs.h |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMPACKey { | 21 | @@ -XXX,XX +XXX,XX @@ static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } |
25 | } ARMPACKey; | 22 | void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); |
26 | #endif | 23 | #endif |
27 | 24 | ||
28 | +/* See the commentary above the TBFLAG field definitions. */ | 25 | +CPAccessResult access_tvm_trvm(CPUARMState *, const ARMCPRegInfo *, bool); |
29 | +typedef struct CPUARMTBFlags { | ||
30 | + uint32_t flags; | ||
31 | +} CPUARMTBFlags; | ||
32 | |||
33 | typedef struct CPUARMState { | ||
34 | /* Regs for current mode. */ | ||
35 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | ||
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 | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/translate.h | ||
79 | +++ b/target/arm/translate.h | ||
80 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
81 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
82 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
83 | |||
84 | +/** | ||
85 | + * arm_tbflags_from_tb: | ||
86 | + * @tb: the TranslationBlock | ||
87 | + * | ||
88 | + * Extract the flag values from @tb. | ||
89 | + */ | ||
90 | +static inline CPUARMTBFlags arm_tbflags_from_tb(const TranslationBlock *tb) | ||
91 | +{ | ||
92 | + return (CPUARMTBFlags){ tb->flags }; | ||
93 | +} | ||
94 | + | 26 | + |
95 | /* | 27 | #endif /* TARGET_ARM_CPREGS_H */ |
96 | * Enum for argument to fpstatus_ptr(). | ||
97 | */ | ||
98 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 28 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
99 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
100 | --- a/target/arm/helper.c | 30 | --- a/target/arm/helper.c |
101 | +++ b/target/arm/helper.c | 31 | +++ b/target/arm/helper.c |
102 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | 32 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri, |
103 | } | 33 | } |
104 | #endif | 34 | |
105 | 35 | /* Check for traps from EL1 due to HCR_EL2.TVM and HCR_EL2.TRVM. */ | |
106 | -static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | 36 | -static CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, |
107 | - ARMMMUIdx mmu_idx, uint32_t flags) | 37 | - bool isread) |
108 | +static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el, | 38 | +CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, |
109 | + ARMMMUIdx mmu_idx, | 39 | + bool isread) |
110 | + CPUARMTBFlags flags) | ||
111 | { | 40 | { |
112 | DP_TBFLAG_ANY(flags, FPEXC_EL, fp_el); | 41 | if (arm_current_el(env) == 1) { |
113 | DP_TBFLAG_ANY(flags, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); | 42 | uint64_t trap = isread ? HCR_TRVM : HCR_TVM; |
114 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | 43 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
115 | return flags; | 44 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/target/arm/tcg/cpu64.c | ||
46 | +++ b/target/arm/tcg/cpu64.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj) | ||
48 | /* TODO: Add A64FX specific HPC extension registers */ | ||
116 | } | 49 | } |
117 | 50 | ||
118 | -static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, | 51 | +static CPAccessResult access_actlr_w(CPUARMState *env, const ARMCPRegInfo *r, |
119 | - ARMMMUIdx mmu_idx, uint32_t flags) | 52 | + bool read) |
120 | +static CPUARMTBFlags rebuild_hflags_common_32(CPUARMState *env, int fp_el, | 53 | +{ |
121 | + ARMMMUIdx mmu_idx, | 54 | + if (!read) { |
122 | + CPUARMTBFlags flags) | 55 | + int el = arm_current_el(env); |
123 | { | ||
124 | bool sctlr_b = arm_sctlr_b(env); | ||
125 | |||
126 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, | ||
127 | return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
128 | } | ||
129 | |||
130 | -static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, | ||
131 | - ARMMMUIdx mmu_idx) | ||
132 | +static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el, | ||
133 | + ARMMMUIdx mmu_idx) | ||
134 | { | ||
135 | - uint32_t flags = 0; | ||
136 | + CPUARMTBFlags flags = {}; | ||
137 | |||
138 | if (arm_v7m_is_handler_mode(env)) { | ||
139 | DP_TBFLAG_M32(flags, HANDLER, 1); | ||
140 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, | ||
141 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | ||
142 | } | ||
143 | |||
144 | -static uint32_t rebuild_hflags_aprofile(CPUARMState *env) | ||
145 | +static CPUARMTBFlags rebuild_hflags_aprofile(CPUARMState *env) | ||
146 | { | ||
147 | - int flags = 0; | ||
148 | + CPUARMTBFlags flags = {}; | ||
149 | |||
150 | DP_TBFLAG_ANY(flags, DEBUG_TARGET_EL, arm_debug_target_el(env)); | ||
151 | return flags; | ||
152 | } | ||
153 | |||
154 | -static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, | ||
155 | - ARMMMUIdx mmu_idx) | ||
156 | +static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, | ||
157 | + ARMMMUIdx mmu_idx) | ||
158 | { | ||
159 | - uint32_t flags = rebuild_hflags_aprofile(env); | ||
160 | + CPUARMTBFlags flags = rebuild_hflags_aprofile(env); | ||
161 | |||
162 | if (arm_el_is_aa64(env, 1)) { | ||
163 | DP_TBFLAG_A32(flags, VFPEN, 1); | ||
164 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, | ||
165 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | ||
166 | } | ||
167 | |||
168 | -static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
169 | - ARMMMUIdx mmu_idx) | ||
170 | +static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
171 | + ARMMMUIdx mmu_idx) | ||
172 | { | ||
173 | - uint32_t flags = rebuild_hflags_aprofile(env); | ||
174 | + CPUARMTBFlags flags = rebuild_hflags_aprofile(env); | ||
175 | ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); | ||
176 | uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | ||
177 | uint64_t sctlr; | ||
178 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
179 | return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
180 | } | ||
181 | |||
182 | -static uint32_t rebuild_hflags_internal(CPUARMState *env) | ||
183 | +static CPUARMTBFlags rebuild_hflags_internal(CPUARMState *env) | ||
184 | { | ||
185 | int el = arm_current_el(env); | ||
186 | int fp_el = fp_exception_el(env, el); | ||
187 | @@ -XXX,XX +XXX,XX @@ void HELPER(rebuild_hflags_m32_newel)(CPUARMState *env) | ||
188 | int el = arm_current_el(env); | ||
189 | int fp_el = fp_exception_el(env, el); | ||
190 | ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); | ||
191 | + | 56 | + |
192 | env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx); | 57 | + /* Because ACTLR_EL2 is constant 0, writes below EL2 trap to EL2. */ |
193 | } | 58 | + if (el < 2 && arm_is_el2_enabled(env)) { |
194 | 59 | + return CP_ACCESS_TRAP_EL2; | |
195 | @@ -XXX,XX +XXX,XX @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el) | 60 | + } |
196 | static inline void assert_hflags_rebuild_correctly(CPUARMState *env) | 61 | + /* Because ACTLR_EL3 is constant 0, writes below EL3 trap to EL3. */ |
197 | { | 62 | + if (el < 3 && arm_feature(env, ARM_FEATURE_EL3)) { |
198 | #ifdef CONFIG_DEBUG_TCG | 63 | + return CP_ACCESS_TRAP_EL3; |
199 | - uint32_t env_flags_current = env->hflags; | 64 | + } |
200 | - uint32_t env_flags_rebuilt = rebuild_hflags_internal(env); | 65 | + } |
201 | + CPUARMTBFlags c = env->hflags; | 66 | + return CP_ACCESS_OK; |
202 | + CPUARMTBFlags r = rebuild_hflags_internal(env); | 67 | +} |
203 | 68 | + | |
204 | - if (unlikely(env_flags_current != env_flags_rebuilt)) { | 69 | static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { |
205 | + if (unlikely(c.flags != r.flags)) { | 70 | { .name = "ATCR_EL1", .state = ARM_CP_STATE_AA64, |
206 | fprintf(stderr, "TCG hflags mismatch (current:0x%08x rebuilt:0x%08x)\n", | 71 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 7, .opc2 = 0, |
207 | - env_flags_current, env_flags_rebuilt); | 72 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
208 | + c.flags, r.flags); | 73 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, |
209 | abort(); | 74 | + /* Traps and enables are the same as for TCR_EL1. */ |
210 | } | 75 | + .accessfn = access_tvm_trvm, .fgt = FGT_TCR_EL1, }, |
211 | #endif | 76 | { .name = "ATCR_EL2", .state = ARM_CP_STATE_AA64, |
212 | @@ -XXX,XX +XXX,XX @@ static inline void assert_hflags_rebuild_correctly(CPUARMState *env) | 77 | .opc0 = 3, .opc1 = 4, .crn = 15, .crm = 7, .opc2 = 0, |
213 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 78 | .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
214 | target_ulong *cs_base, uint32_t *pflags) | 79 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { |
215 | { | 80 | .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
216 | - uint32_t flags = env->hflags; | 81 | { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64, |
217 | + CPUARMTBFlags flags; | 82 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 0, |
218 | 83 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | |
219 | *cs_base = 0; | 84 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, |
220 | assert_hflags_rebuild_correctly(env); | 85 | + .accessfn = access_actlr_w }, |
221 | + flags = env->hflags; | 86 | { .name = "CPUACTLR2_EL1", .state = ARM_CP_STATE_AA64, |
222 | 87 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 1, | |
223 | if (EX_TBFLAG_ANY(flags, AARCH64_STATE)) { | 88 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
224 | *pc = env->pc; | 89 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, |
225 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 90 | + .accessfn = access_actlr_w }, |
226 | DP_TBFLAG_ANY(flags, PSTATE__SS, 1); | 91 | { .name = "CPUACTLR3_EL1", .state = ARM_CP_STATE_AA64, |
227 | } | 92 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 2, |
228 | 93 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | |
229 | - *pflags = flags; | 94 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, |
230 | + *pflags = flags.flags; | 95 | + .accessfn = access_actlr_w }, |
231 | } | 96 | /* |
232 | 97 | * Report CPUCFR_EL1.SCU as 1, as we do not implement the DSU | |
233 | #ifdef TARGET_AARCH64 | 98 | * (and in particular its system registers). |
234 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 99 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { |
235 | index XXXXXXX..XXXXXXX 100644 | 100 | .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 4 }, |
236 | --- a/target/arm/translate-a64.c | 101 | { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64, |
237 | +++ b/target/arm/translate-a64.c | 102 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 4, |
238 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 103 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010 }, |
239 | DisasContext *dc = container_of(dcbase, DisasContext, base); | 104 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010, |
240 | CPUARMState *env = cpu->env_ptr; | 105 | + .accessfn = access_actlr_w }, |
241 | ARMCPU *arm_cpu = env_archcpu(env); | 106 | { .name = "CPUPCR_EL3", .state = ARM_CP_STATE_AA64, |
242 | - uint32_t tb_flags = dc->base.tb->flags; | 107 | .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 1, |
243 | + CPUARMTBFlags tb_flags = arm_tbflags_from_tb(dc->base.tb); | 108 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
244 | int bound, core_mmu_idx; | 109 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { |
245 | 110 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | |
246 | dc->isar = &arm_cpu->isar; | 111 | { .name = "CPUPWRCTLR_EL1", .state = ARM_CP_STATE_AA64, |
247 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 112 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 7, |
248 | index XXXXXXX..XXXXXXX 100644 | 113 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
249 | --- a/target/arm/translate.c | 114 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, |
250 | +++ b/target/arm/translate.c | 115 | + .accessfn = access_actlr_w }, |
251 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 116 | { .name = "ERXPFGCDN_EL1", .state = ARM_CP_STATE_AA64, |
252 | DisasContext *dc = container_of(dcbase, DisasContext, base); | 117 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 2, |
253 | CPUARMState *env = cs->env_ptr; | 118 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
254 | ARMCPU *cpu = env_archcpu(env); | 119 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, |
255 | - uint32_t tb_flags = dc->base.tb->flags; | 120 | + .accessfn = access_actlr_w }, |
256 | + CPUARMTBFlags tb_flags = arm_tbflags_from_tb(dc->base.tb); | 121 | { .name = "ERXPFGCTL_EL1", .state = ARM_CP_STATE_AA64, |
257 | uint32_t condexec, core_mmu_idx; | 122 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 1, |
258 | 123 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | |
259 | dc->isar = &cpu->isar; | 124 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, |
260 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | 125 | + .accessfn = access_actlr_w }, |
261 | { | 126 | { .name = "ERXPFGF_EL1", .state = ARM_CP_STATE_AA64, |
262 | DisasContext dc = { }; | 127 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 0, |
263 | const TranslatorOps *ops = &arm_translator_ops; | 128 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
264 | + CPUARMTBFlags tb_flags = arm_tbflags_from_tb(tb); | 129 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, |
265 | 130 | + .accessfn = access_actlr_w }, | |
266 | - if (EX_TBFLAG_AM32(tb->flags, THUMB)) { | 131 | }; |
267 | + if (EX_TBFLAG_AM32(tb_flags, THUMB)) { | 132 | |
268 | ops = &thumb_translator_ops; | 133 | static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu) |
269 | } | ||
270 | #ifdef TARGET_AARCH64 | ||
271 | - if (EX_TBFLAG_ANY(tb->flags, AARCH64_STATE)) { | ||
272 | + if (EX_TBFLAG_ANY(tb_flags, AARCH64_STATE)) { | ||
273 | ops = &aarch64_translator_ops; | ||
274 | } | ||
275 | #endif | ||
276 | -- | 134 | -- |
277 | 2.20.1 | 135 | 2.34.1 |
278 | |||
279 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | There is only one additional EL1 register modeled, which | ||
4 | also needs to use access_actlr_w. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20230811214031.171020-8-richard.henderson@linaro.org |
5 | Message-id: 20210419202257.161730-31-richard.henderson@linaro.org | ||
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-a64.c | 9 +++++---- | 11 | target/arm/tcg/cpu64.c | 3 ++- |
9 | 1 file changed, 5 insertions(+), 4 deletions(-) | 12 | 1 file changed, 2 insertions(+), 1 deletion(-) |
10 | 13 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 14 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 16 | --- a/target/arm/tcg/cpu64.c |
14 | +++ b/target/arm/translate-a64.c | 17 | +++ b/target/arm/tcg/cpu64.c |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 18 | @@ -XXX,XX +XXX,XX @@ static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu) |
16 | int index = is_q << 3 | S << 2 | size; | 19 | static const ARMCPRegInfo neoverse_v1_cp_reginfo[] = { |
17 | int xs, total; | 20 | { .name = "CPUECTLR2_EL1", .state = ARM_CP_STATE_AA64, |
18 | TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; | 21 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 5, |
19 | + MemOp mop; | 22 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
20 | 23 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | |
21 | if (extract32(insn, 31, 1)) { | 24 | + .accessfn = access_actlr_w }, |
22 | unallocated_encoding(s); | 25 | { .name = "CPUPPMCR_EL3", .state = ARM_CP_STATE_AA64, |
23 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 26 | .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 2, .opc2 = 0, |
24 | 27 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | |
25 | clean_addr = gen_mte_checkN(s, tcg_rn, !is_load, is_postidx || rn != 31, | ||
26 | total); | ||
27 | + mop = finalize_memop(s, scale); | ||
28 | |||
29 | tcg_ebytes = tcg_const_i64(1 << scale); | ||
30 | for (xs = 0; xs < selem; xs++) { | ||
31 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
32 | /* Load and replicate to all elements */ | ||
33 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | ||
34 | |||
35 | - tcg_gen_qemu_ld_i64(tcg_tmp, clean_addr, | ||
36 | - get_mem_index(s), s->be_data + scale); | ||
37 | + tcg_gen_qemu_ld_i64(tcg_tmp, clean_addr, get_mem_index(s), mop); | ||
38 | tcg_gen_gvec_dup_i64(scale, vec_full_reg_offset(s, rt), | ||
39 | (is_q + 1) * 8, vec_full_reg_size(s), | ||
40 | tcg_tmp); | ||
41 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
42 | } else { | ||
43 | /* Load/store one element per register */ | ||
44 | if (is_load) { | ||
45 | - do_vec_ld(s, rt, index, clean_addr, scale | s->be_data); | ||
46 | + do_vec_ld(s, rt, index, clean_addr, mop); | ||
47 | } else { | ||
48 | - do_vec_st(s, rt, index, clean_addr, scale | s->be_data); | ||
49 | + do_vec_st(s, rt, index, clean_addr, mop); | ||
50 | } | ||
51 | } | ||
52 | tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); | ||
53 | -- | 28 | -- |
54 | 2.20.1 | 29 | 2.34.1 |
55 | |||
56 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Like FEAT_TRF (Self-hosted Trace Extension), suppress tracing | ||
4 | external to the cpu, which is out of scope for QEMU. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20230811214031.171020-10-richard.henderson@linaro.org |
5 | Message-id: 20210419202257.161730-30-richard.henderson@linaro.org | ||
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-a64.c | 15 +++++++++++---- | 11 | target/arm/cpu.c | 3 +++ |
9 | 1 file changed, 11 insertions(+), 4 deletions(-) | 12 | 1 file changed, 3 insertions(+) |
10 | 13 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 16 | --- a/target/arm/cpu.c |
14 | +++ b/target/arm/translate-a64.c | 17 | +++ b/target/arm/cpu.c |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
16 | bool is_postidx = extract32(insn, 23, 1); | 19 | /* FEAT_SPE (Statistical Profiling Extension) */ |
17 | bool is_q = extract32(insn, 30, 1); | 20 | cpu->isar.id_aa64dfr0 = |
18 | TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; | 21 | FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, PMSVER, 0); |
19 | - MemOp endian = s->be_data; | 22 | + /* FEAT_TRBE (Trace Buffer Extension) */ |
20 | + MemOp endian, align, mop; | 23 | + cpu->isar.id_aa64dfr0 = |
21 | 24 | + FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEBUFFER, 0); | |
22 | int total; /* total bytes */ | 25 | /* FEAT_TRF (Self-hosted Trace Extension) */ |
23 | int elements; /* elements per vector */ | 26 | cpu->isar.id_aa64dfr0 = |
24 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 27 | FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEFILT, 0); |
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 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
33 | * Consecutive little-endian elements from a single register | ||
34 | * can be promoted to a larger little-endian operation. | ||
35 | */ | ||
36 | + align = MO_ALIGN; | ||
37 | if (selem == 1 && endian == MO_LE) { | ||
38 | + align = pow2_align(size); | ||
39 | size = 3; | ||
40 | } | ||
41 | - elements = (is_q ? 16 : 8) >> size; | ||
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 | -- | 28 | -- |
64 | 2.20.1 | 29 | 2.34.1 |
65 | |||
66 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This feature allows the operating system to set TCR_ELx.HWU* | ||
4 | to allow the implementation to use the PBHA bits from the | ||
5 | block and page descriptors for for IMPLEMENTATION DEFINED | ||
6 | purposes. Since QEMU has no need to use these bits, we may | ||
7 | simply ignore them. | ||
8 | |||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Message-id: 20230811214031.171020-11-richard.henderson@linaro.org |
5 | Message-id: 20210419202257.161730-29-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 13 | --- |
8 | target/arm/translate-a64.c | 20 ++++++++++---------- | 14 | docs/system/arm/emulation.rst | 1 + |
9 | 1 file changed, 10 insertions(+), 10 deletions(-) | 15 | target/arm/tcg/cpu32.c | 2 +- |
16 | target/arm/tcg/cpu64.c | 2 +- | ||
17 | 3 files changed, 3 insertions(+), 2 deletions(-) | ||
10 | 18 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
12 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 21 | --- a/docs/system/arm/emulation.rst |
14 | +++ b/target/arm/translate-a64.c | 22 | +++ b/docs/system/arm/emulation.rst |
15 | @@ -XXX,XX +XXX,XX @@ static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src, | 23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
16 | 24 | - FEAT_HAFDBS (Hardware management of the access flag and dirty bit state) | |
17 | /* Store from vector register to memory */ | 25 | - FEAT_HCX (Support for the HCRX_EL2 register) |
18 | static void do_vec_st(DisasContext *s, int srcidx, int element, | 26 | - FEAT_HPDS (Hierarchical permission disables) |
19 | - TCGv_i64 tcg_addr, int size, MemOp endian) | 27 | +- FEAT_HPDS2 (Translation table page-based hardware attributes) |
20 | + TCGv_i64 tcg_addr, MemOp mop) | 28 | - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) |
21 | { | 29 | - FEAT_IDST (ID space trap handling) |
22 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | 30 | - FEAT_IESB (Implicit error synchronization event) |
23 | 31 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | |
24 | - read_vec_element(s, tcg_tmp, srcidx, element, size); | 32 | index XXXXXXX..XXXXXXX 100644 |
25 | - tcg_gen_qemu_st_i64(tcg_tmp, tcg_addr, get_mem_index(s), endian | size); | 33 | --- a/target/arm/tcg/cpu32.c |
26 | + read_vec_element(s, tcg_tmp, srcidx, element, mop & MO_SIZE); | 34 | +++ b/target/arm/tcg/cpu32.c |
27 | + tcg_gen_qemu_st_i64(tcg_tmp, tcg_addr, get_mem_index(s), mop); | 35 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) |
28 | 36 | cpu->isar.id_mmfr3 = t; | |
29 | tcg_temp_free_i64(tcg_tmp); | 37 | |
30 | } | 38 | t = cpu->isar.id_mmfr4; |
31 | 39 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* FEAT_AA32HPD */ | |
32 | /* Load from memory to vector register */ | 40 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 2); /* FEAT_HPDS2 */ |
33 | static void do_vec_ld(DisasContext *s, int destidx, int element, | 41 | t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ |
34 | - TCGv_i64 tcg_addr, int size, MemOp endian) | 42 | t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */ |
35 | + TCGv_i64 tcg_addr, MemOp mop) | 43 | t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX */ |
36 | { | 44 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
37 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | 45 | index XXXXXXX..XXXXXXX 100644 |
38 | 46 | --- a/target/arm/tcg/cpu64.c | |
39 | - tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, get_mem_index(s), endian | size); | 47 | +++ b/target/arm/tcg/cpu64.c |
40 | - write_vec_element(s, tcg_tmp, destidx, element, size); | 48 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
41 | + tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, get_mem_index(s), mop); | 49 | t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */ |
42 | + write_vec_element(s, tcg_tmp, destidx, element, mop & MO_SIZE); | 50 | t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ |
43 | 51 | t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ | |
44 | tcg_temp_free_i64(tcg_tmp); | 52 | - t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */ |
45 | } | 53 | + t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 2); /* FEAT_HPDS2 */ |
46 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 54 | t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */ |
47 | for (xs = 0; xs < selem; xs++) { | 55 | t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 3); /* FEAT_PAN3 */ |
48 | int tt = (rt + r + xs) % 32; | 56 | t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */ |
49 | if (is_store) { | ||
50 | - do_vec_st(s, tt, e, clean_addr, size, endian); | ||
51 | + do_vec_st(s, tt, e, clean_addr, size | endian); | ||
52 | } else { | ||
53 | - do_vec_ld(s, tt, e, clean_addr, size, endian); | ||
54 | + do_vec_ld(s, tt, e, clean_addr, size | endian); | ||
55 | } | ||
56 | tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); | ||
57 | } | ||
58 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
59 | } else { | ||
60 | /* Load/store one element per register */ | ||
61 | if (is_load) { | ||
62 | - do_vec_ld(s, rt, index, clean_addr, scale, s->be_data); | ||
63 | + do_vec_ld(s, rt, index, clean_addr, scale | s->be_data); | ||
64 | } else { | ||
65 | - do_vec_st(s, rt, index, clean_addr, scale, s->be_data); | ||
66 | + do_vec_st(s, rt, index, clean_addr, scale | s->be_data); | ||
67 | } | ||
68 | } | ||
69 | tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); | ||
70 | -- | 57 | -- |
71 | 2.20.1 | 58 | 2.34.1 |
72 | |||
73 | diff view generated by jsdifflib |
1 | From: Cornelia Huck <cohuck@redhat.com> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add 6.1 machine types for arm/i440fx/q35/s390x/spapr. | 3 | This is a mandatory feature for Armv8.1 architectures but we don't |
4 | state the feature clearly in our emulation list. Also include | ||
5 | FEAT_CRC32 comment in aarch64_max_tcg_initfn for ease of grepping. | ||
4 | 6 | ||
5 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Acked-by: Greg Kurz <groug@kaod.org> | 8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
7 | Message-id: 20210331111900.118274-1-cohuck@redhat.com | 9 | Message-id: 20230824075406.1515566-1-alex.bennee@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Cc: qemu-stable@nongnu.org |
11 | Message-Id: <20230222110104.3996971-1-alex.bennee@linaro.org> | ||
12 | [PMM: pluralize 'instructions' in docs] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 14 | --- |
11 | include/hw/boards.h | 3 +++ | 15 | docs/system/arm/emulation.rst | 1 + |
12 | include/hw/i386/pc.h | 3 +++ | 16 | target/arm/tcg/cpu64.c | 2 +- |
13 | hw/arm/virt.c | 7 ++++++- | 17 | 2 files changed, 2 insertions(+), 1 deletion(-) |
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 | 18 | ||
22 | diff --git a/include/hw/boards.h b/include/hw/boards.h | 19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
23 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/include/hw/boards.h | 21 | --- a/docs/system/arm/emulation.rst |
25 | +++ b/include/hw/boards.h | 22 | +++ b/docs/system/arm/emulation.rst |
26 | @@ -XXX,XX +XXX,XX @@ struct MachineState { | 23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
27 | } \ | 24 | - FEAT_BBM at level 2 (Translation table break-before-make levels) |
28 | type_init(machine_initfn##_register_types) | 25 | - FEAT_BF16 (AArch64 BFloat16 instructions) |
29 | 26 | - FEAT_BTI (Branch Target Identification) | |
30 | +extern GlobalProperty hw_compat_6_0[]; | 27 | +- FEAT_CRC32 (CRC32 instructions) |
31 | +extern const size_t hw_compat_6_0_len; | 28 | - FEAT_CSV2 (Cache speculation variant 2) |
32 | + | 29 | - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) |
33 | extern GlobalProperty hw_compat_5_2[]; | 30 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) |
34 | extern const size_t hw_compat_5_2_len; | 31 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
35 | |||
36 | diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/include/hw/i386/pc.h | 33 | --- a/target/arm/tcg/cpu64.c |
39 | +++ b/include/hw/i386/pc.h | 34 | +++ b/target/arm/tcg/cpu64.c |
40 | @@ -XXX,XX +XXX,XX @@ bool pc_system_ovmf_table_find(const char *entry, uint8_t **data, | 35 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
41 | void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, | 36 | t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */ |
42 | const CPUArchIdList *apic_ids, GArray *entry); | 37 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */ |
43 | 38 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */ | |
44 | +extern GlobalProperty pc_compat_6_0[]; | 39 | - t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); |
45 | +extern const size_t pc_compat_6_0_len; | 40 | + t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); /* FEAT_CRC32 */ |
46 | + | 41 | t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); /* FEAT_LSE */ |
47 | extern GlobalProperty pc_compat_5_2[]; | 42 | t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); /* FEAT_RDM */ |
48 | extern const size_t pc_compat_5_2_len; | 43 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); /* FEAT_SHA3 */ |
49 | |||
50 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/hw/arm/virt.c | ||
53 | +++ b/hw/arm/virt.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static void machvirt_machine_init(void) | ||
55 | } | ||
56 | type_init(machvirt_machine_init); | ||
57 | |||
58 | +static void virt_machine_6_1_options(MachineClass *mc) | ||
59 | +{ | ||
60 | +} | ||
61 | +DEFINE_VIRT_MACHINE_AS_LATEST(6, 1) | ||
62 | + | ||
63 | static void virt_machine_6_0_options(MachineClass *mc) | ||
64 | { | ||
65 | } | ||
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 | +} | ||
127 | + | ||
128 | DEFINE_I440FX_MACHINE(v6_0, "pc-i440fx-6.0", NULL, | ||
129 | pc_i440fx_6_0_machine_options); | ||
130 | |||
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 | + | ||
151 | +static void pc_q35_6_0_machine_options(MachineClass *m) | ||
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 | +} | ||
158 | + | ||
159 | DEFINE_Q35_MACHINE(v6_0, "pc-q35-6.0", NULL, | ||
160 | pc_q35_6_0_machine_options); | ||
161 | |||
162 | diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c | ||
163 | index XXXXXXX..XXXXXXX 100644 | ||
164 | --- a/hw/ppc/spapr.c | ||
165 | +++ b/hw/ppc/spapr.c | ||
166 | @@ -XXX,XX +XXX,XX @@ static void spapr_machine_latest_class_options(MachineClass *mc) | ||
167 | type_init(spapr_machine_register_##suffix) | ||
168 | |||
169 | /* | ||
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 | + | ||
182 | +/* | ||
183 | + * pseries-6.0 | ||
184 | + */ | ||
185 | +static void spapr_machine_6_0_class_options(MachineClass *mc) | ||
186 | +{ | ||
187 | + spapr_machine_6_1_class_options(mc); | ||
188 | + compat_props_add(mc->compat_props, hw_compat_6_0, hw_compat_6_0_len); | ||
189 | +} | ||
190 | + | ||
191 | +DEFINE_SPAPR_MACHINE(6_0, "6.0", false); | ||
192 | |||
193 | /* | ||
194 | * pseries-5.2 | ||
195 | diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c | ||
196 | index XXXXXXX..XXXXXXX 100644 | ||
197 | --- a/hw/s390x/s390-virtio-ccw.c | ||
198 | +++ b/hw/s390x/s390-virtio-ccw.c | ||
199 | @@ -XXX,XX +XXX,XX @@ bool css_migration_enabled(void) | ||
200 | } \ | ||
201 | type_init(ccw_machine_register_##suffix) | ||
202 | |||
203 | +static void ccw_machine_6_1_instance_options(MachineState *machine) | ||
204 | +{ | ||
205 | +} | ||
206 | + | ||
207 | +static void ccw_machine_6_1_class_options(MachineClass *mc) | ||
208 | +{ | ||
209 | +} | ||
210 | +DEFINE_CCW_MACHINE(6_1, "6.1", true); | ||
211 | + | ||
212 | static void ccw_machine_6_0_instance_options(MachineState *machine) | ||
213 | { | ||
214 | + ccw_machine_6_1_instance_options(machine); | ||
215 | } | ||
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 | -- | 44 | -- |
228 | 2.20.1 | 45 | 2.34.1 |
229 | 46 | ||
230 | 47 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | For 128-bit load/store, use 16-byte alignment. This | 3 | i.MX7 IOMUX GPR device is not equivalent to i.MX6UL IOMUXC GPR device. |
4 | requires that we perform the two operations in the | 4 | In particular, register 22 is not present on i.MX6UL and this is actualy |
5 | correct order so that we generate the alignment fault | 5 | The only register that is really emulated in the i.MX7 IOMUX GPR device. |
6 | before modifying memory. | ||
7 | 6 | ||
7 | Note: The i.MX6UL code is actually also implementing the IOMUX GPR device | ||
8 | as an unimplemented device at the same bus adress and the 2 instantiations | ||
9 | were actualy colliding. So we go back to the unimplemented device for now. | ||
10 | |||
11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
12 | Message-id: 48681bf51ee97646479bb261bee19abebbc8074e.1692964892.git.jcd@tribudubois.net | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210419202257.161730-27-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 15 | --- |
13 | target/arm/translate-a64.c | 42 +++++++++++++++++++++++--------------- | 16 | include/hw/arm/fsl-imx6ul.h | 2 -- |
14 | 1 file changed, 26 insertions(+), 16 deletions(-) | 17 | hw/arm/fsl-imx6ul.c | 11 ----------- |
18 | 2 files changed, 13 deletions(-) | ||
15 | 19 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 20 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h |
17 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 22 | --- a/include/hw/arm/fsl-imx6ul.h |
19 | +++ b/target/arm/translate-a64.c | 23 | +++ b/include/hw/arm/fsl-imx6ul.h |
20 | @@ -XXX,XX +XXX,XX @@ static void do_gpr_ld(DisasContext *s, TCGv_i64 dest, TCGv_i64 tcg_addr, | 24 | @@ -XXX,XX +XXX,XX @@ |
21 | static void do_fp_st(DisasContext *s, int srcidx, TCGv_i64 tcg_addr, int size) | 25 | #include "hw/misc/imx6ul_ccm.h" |
22 | { | 26 | #include "hw/misc/imx6_src.h" |
23 | /* This writes the bottom N bits of a 128 bit wide vector to memory */ | 27 | #include "hw/misc/imx7_snvs.h" |
24 | - TCGv_i64 tmp = tcg_temp_new_i64(); | 28 | -#include "hw/misc/imx7_gpr.h" |
25 | - tcg_gen_ld_i64(tmp, cpu_env, fp_reg_offset(s, srcidx, MO_64)); | 29 | #include "hw/intc/imx_gpcv2.h" |
26 | + TCGv_i64 tmplo = tcg_temp_new_i64(); | 30 | #include "hw/watchdog/wdt_imx2.h" |
27 | + MemOp mop; | 31 | #include "hw/gpio/imx_gpio.h" |
28 | + | 32 | @@ -XXX,XX +XXX,XX @@ struct FslIMX6ULState { |
29 | + tcg_gen_ld_i64(tmplo, cpu_env, fp_reg_offset(s, srcidx, MO_64)); | 33 | IMX6SRCState src; |
30 | + | 34 | IMX7SNVSState snvs; |
31 | if (size < 4) { | 35 | IMXGPCv2State gpcv2; |
32 | - tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), | 36 | - IMX7GPRState gpr; |
33 | - s->be_data + size); | 37 | IMXSPIState spi[FSL_IMX6UL_NUM_ECSPIS]; |
34 | + mop = finalize_memop(s, size); | 38 | IMXI2CState i2c[FSL_IMX6UL_NUM_I2CS]; |
35 | + tcg_gen_qemu_st_i64(tmplo, tcg_addr, get_mem_index(s), mop); | 39 | IMXSerialState uart[FSL_IMX6UL_NUM_UARTS]; |
36 | } else { | 40 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c |
37 | bool be = s->be_data == MO_BE; | 41 | index XXXXXXX..XXXXXXX 100644 |
38 | TCGv_i64 tcg_hiaddr = tcg_temp_new_i64(); | 42 | --- a/hw/arm/fsl-imx6ul.c |
39 | + TCGv_i64 tmphi = tcg_temp_new_i64(); | 43 | +++ b/hw/arm/fsl-imx6ul.c |
40 | 44 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | |
41 | + tcg_gen_ld_i64(tmphi, cpu_env, fp_reg_hi_offset(s, srcidx)); | 45 | */ |
42 | + | 46 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); |
43 | + mop = s->be_data | MO_Q; | 47 | |
44 | + tcg_gen_qemu_st_i64(be ? tmphi : tmplo, tcg_addr, get_mem_index(s), | 48 | - /* |
45 | + mop | (s->align_mem ? MO_ALIGN_16 : 0)); | 49 | - * GPR |
46 | tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8); | 50 | - */ |
47 | - tcg_gen_qemu_st_i64(tmp, be ? tcg_hiaddr : tcg_addr, get_mem_index(s), | 51 | - object_initialize_child(obj, "gpr", &s->gpr, TYPE_IMX7_GPR); |
48 | - s->be_data | MO_Q); | 52 | - |
49 | - tcg_gen_ld_i64(tmp, cpu_env, fp_reg_hi_offset(s, srcidx)); | 53 | /* |
50 | - tcg_gen_qemu_st_i64(tmp, be ? tcg_addr : tcg_hiaddr, get_mem_index(s), | 54 | * GPIOs 1 to 5 |
51 | - s->be_data | MO_Q); | 55 | */ |
52 | + tcg_gen_qemu_st_i64(be ? tmplo : tmphi, tcg_hiaddr, | 56 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
53 | + get_mem_index(s), mop); | 57 | FSL_IMX6UL_WDOGn_IRQ[i])); |
54 | + | ||
55 | tcg_temp_free_i64(tcg_hiaddr); | ||
56 | + tcg_temp_free_i64(tmphi); | ||
57 | } | 58 | } |
58 | 59 | ||
59 | - tcg_temp_free_i64(tmp); | 60 | - /* |
60 | + tcg_temp_free_i64(tmplo); | 61 | - * GPR |
61 | } | 62 | - */ |
62 | 63 | - sysbus_realize(SYS_BUS_DEVICE(&s->gpr), &error_abort); | |
63 | /* | 64 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX6UL_IOMUXC_GPR_ADDR); |
64 | @@ -XXX,XX +XXX,XX @@ static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size) | 65 | - |
65 | /* This always zero-extends and writes to a full 128 bit wide vector */ | 66 | /* |
66 | TCGv_i64 tmplo = tcg_temp_new_i64(); | 67 | * SDMA |
67 | TCGv_i64 tmphi = NULL; | 68 | */ |
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 | |||
95 | -- | 69 | -- |
96 | 2.20.1 | 70 | 2.34.1 |
97 | |||
98 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Use this to signal when memory access alignment is required. | 3 | * Add Addr and size definition for most i.MX6UL devices in i.MX6UL header file. |
4 | This value comes from the CCR register for M-profile, and | 4 | * Use those newly defined named constants whenever possible. |
5 | from the SCTLR register for A-profile. | 5 | * Standardize the way we init a familly of unimplemented devices |
6 | - SAI | ||
7 | - PWM | ||
8 | - CAN | ||
9 | * Add/rework few comments | ||
6 | 10 | ||
11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
12 | Message-id: d579043fbd4e4b490370783fda43fc02c8e9be75.1692964892.git.jcd@tribudubois.net | ||
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-11-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 | 2 ++ | 16 | include/hw/arm/fsl-imx6ul.h | 156 +++++++++++++++++++++++++++++++----- |
13 | target/arm/translate.h | 2 ++ | 17 | hw/arm/fsl-imx6ul.c | 147 ++++++++++++++++++++++----------- |
14 | target/arm/helper.c | 19 +++++++++++++++++-- | 18 | 2 files changed, 232 insertions(+), 71 deletions(-) |
15 | target/arm/translate-a64.c | 1 + | ||
16 | target/arm/translate.c | 7 +++---- | ||
17 | 5 files changed, 25 insertions(+), 6 deletions(-) | ||
18 | 19 | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 20 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h |
20 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 22 | --- a/include/hw/arm/fsl-imx6ul.h |
22 | +++ b/target/arm/cpu.h | 23 | +++ b/include/hw/arm/fsl-imx6ul.h |
23 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, MMUIDX, 4, 4) | 24 | @@ -XXX,XX +XXX,XX @@ |
24 | FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2) | 25 | #include "exec/memory.h" |
25 | /* For A-profile only, target EL for debug exceptions. */ | 26 | #include "cpu.h" |
26 | FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 10, 2) | 27 | #include "qom/object.h" |
27 | +/* Memory operations require alignment: SCTLR_ELx.A or CCR.UNALIGN_TRP */ | 28 | +#include "qemu/units.h" |
28 | +FIELD(TBFLAG_ANY, ALIGN_MEM, 12, 1) | 29 | |
29 | 30 | #define TYPE_FSL_IMX6UL "fsl-imx6ul" | |
30 | /* | 31 | OBJECT_DECLARE_SIMPLE_TYPE(FslIMX6ULState, FSL_IMX6UL) |
31 | * Bit usage when in AArch32 state, both A- and M-profile. | 32 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration { |
32 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 33 | FSL_IMX6UL_NUM_ADCS = 2, |
34 | FSL_IMX6UL_NUM_USB_PHYS = 2, | ||
35 | FSL_IMX6UL_NUM_USBS = 2, | ||
36 | + FSL_IMX6UL_NUM_SAIS = 3, | ||
37 | + FSL_IMX6UL_NUM_CANS = 2, | ||
38 | + FSL_IMX6UL_NUM_PWMS = 4, | ||
39 | }; | ||
40 | |||
41 | struct FslIMX6ULState { | ||
42 | @@ -XXX,XX +XXX,XX @@ struct FslIMX6ULState { | ||
43 | |||
44 | enum FslIMX6ULMemoryMap { | ||
45 | FSL_IMX6UL_MMDC_ADDR = 0x80000000, | ||
46 | - FSL_IMX6UL_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL, | ||
47 | + FSL_IMX6UL_MMDC_SIZE = (2 * GiB), | ||
48 | |||
49 | FSL_IMX6UL_QSPI1_MEM_ADDR = 0x60000000, | ||
50 | - FSL_IMX6UL_EIM_ALIAS_ADDR = 0x58000000, | ||
51 | - FSL_IMX6UL_EIM_CS_ADDR = 0x50000000, | ||
52 | - FSL_IMX6UL_AES_ENCRYPT_ADDR = 0x10000000, | ||
53 | - FSL_IMX6UL_QSPI1_RX_ADDR = 0x0C000000, | ||
54 | + FSL_IMX6UL_QSPI1_MEM_SIZE = (256 * MiB), | ||
55 | |||
56 | - /* AIPS-2 */ | ||
57 | + FSL_IMX6UL_EIM_ALIAS_ADDR = 0x58000000, | ||
58 | + FSL_IMX6UL_EIM_ALIAS_SIZE = (128 * MiB), | ||
59 | + | ||
60 | + FSL_IMX6UL_EIM_CS_ADDR = 0x50000000, | ||
61 | + FSL_IMX6UL_EIM_CS_SIZE = (128 * MiB), | ||
62 | + | ||
63 | + FSL_IMX6UL_AES_ENCRYPT_ADDR = 0x10000000, | ||
64 | + FSL_IMX6UL_AES_ENCRYPT_SIZE = (1 * MiB), | ||
65 | + | ||
66 | + FSL_IMX6UL_QSPI1_RX_ADDR = 0x0C000000, | ||
67 | + FSL_IMX6UL_QSPI1_RX_SIZE = (32 * MiB), | ||
68 | + | ||
69 | + /* AIPS-2 Begin */ | ||
70 | FSL_IMX6UL_UART6_ADDR = 0x021FC000, | ||
71 | + | ||
72 | FSL_IMX6UL_I2C4_ADDR = 0x021F8000, | ||
73 | + | ||
74 | FSL_IMX6UL_UART5_ADDR = 0x021F4000, | ||
75 | FSL_IMX6UL_UART4_ADDR = 0x021F0000, | ||
76 | FSL_IMX6UL_UART3_ADDR = 0x021EC000, | ||
77 | FSL_IMX6UL_UART2_ADDR = 0x021E8000, | ||
78 | + | ||
79 | FSL_IMX6UL_WDOG3_ADDR = 0x021E4000, | ||
80 | + | ||
81 | FSL_IMX6UL_QSPI_ADDR = 0x021E0000, | ||
82 | + FSL_IMX6UL_QSPI_SIZE = 0x500, | ||
83 | + | ||
84 | FSL_IMX6UL_SYS_CNT_CTRL_ADDR = 0x021DC000, | ||
85 | + FSL_IMX6UL_SYS_CNT_CTRL_SIZE = (16 * KiB), | ||
86 | + | ||
87 | FSL_IMX6UL_SYS_CNT_CMP_ADDR = 0x021D8000, | ||
88 | + FSL_IMX6UL_SYS_CNT_CMP_SIZE = (16 * KiB), | ||
89 | + | ||
90 | FSL_IMX6UL_SYS_CNT_RD_ADDR = 0x021D4000, | ||
91 | + FSL_IMX6UL_SYS_CNT_RD_SIZE = (16 * KiB), | ||
92 | + | ||
93 | FSL_IMX6UL_TZASC_ADDR = 0x021D0000, | ||
94 | + FSL_IMX6UL_TZASC_SIZE = (16 * KiB), | ||
95 | + | ||
96 | FSL_IMX6UL_PXP_ADDR = 0x021CC000, | ||
97 | + FSL_IMX6UL_PXP_SIZE = (16 * KiB), | ||
98 | + | ||
99 | FSL_IMX6UL_LCDIF_ADDR = 0x021C8000, | ||
100 | + FSL_IMX6UL_LCDIF_SIZE = 0x100, | ||
101 | + | ||
102 | FSL_IMX6UL_CSI_ADDR = 0x021C4000, | ||
103 | + FSL_IMX6UL_CSI_SIZE = 0x100, | ||
104 | + | ||
105 | FSL_IMX6UL_CSU_ADDR = 0x021C0000, | ||
106 | + FSL_IMX6UL_CSU_SIZE = (16 * KiB), | ||
107 | + | ||
108 | FSL_IMX6UL_OCOTP_CTRL_ADDR = 0x021BC000, | ||
109 | + FSL_IMX6UL_OCOTP_CTRL_SIZE = (4 * KiB), | ||
110 | + | ||
111 | FSL_IMX6UL_EIM_ADDR = 0x021B8000, | ||
112 | + FSL_IMX6UL_EIM_SIZE = 0x100, | ||
113 | + | ||
114 | FSL_IMX6UL_SIM2_ADDR = 0x021B4000, | ||
115 | + | ||
116 | FSL_IMX6UL_MMDC_CFG_ADDR = 0x021B0000, | ||
117 | + FSL_IMX6UL_MMDC_CFG_SIZE = (4 * KiB), | ||
118 | + | ||
119 | FSL_IMX6UL_ROMCP_ADDR = 0x021AC000, | ||
120 | + FSL_IMX6UL_ROMCP_SIZE = 0x300, | ||
121 | + | ||
122 | FSL_IMX6UL_I2C3_ADDR = 0x021A8000, | ||
123 | FSL_IMX6UL_I2C2_ADDR = 0x021A4000, | ||
124 | FSL_IMX6UL_I2C1_ADDR = 0x021A0000, | ||
125 | + | ||
126 | FSL_IMX6UL_ADC2_ADDR = 0x0219C000, | ||
127 | FSL_IMX6UL_ADC1_ADDR = 0x02198000, | ||
128 | + FSL_IMX6UL_ADCn_SIZE = 0x100, | ||
129 | + | ||
130 | FSL_IMX6UL_USDHC2_ADDR = 0x02194000, | ||
131 | FSL_IMX6UL_USDHC1_ADDR = 0x02190000, | ||
132 | - FSL_IMX6UL_SIM1_ADDR = 0x0218C000, | ||
133 | - FSL_IMX6UL_ENET1_ADDR = 0x02188000, | ||
134 | - FSL_IMX6UL_USBO2_USBMISC_ADDR = 0x02184800, | ||
135 | - FSL_IMX6UL_USBO2_USB_ADDR = 0x02184000, | ||
136 | - FSL_IMX6UL_USBO2_PL301_ADDR = 0x02180000, | ||
137 | - FSL_IMX6UL_AIPS2_CFG_ADDR = 0x0217C000, | ||
138 | - FSL_IMX6UL_CAAM_ADDR = 0x02140000, | ||
139 | - FSL_IMX6UL_A7MPCORE_DAP_ADDR = 0x02100000, | ||
140 | |||
141 | - /* AIPS-1 */ | ||
142 | + FSL_IMX6UL_SIM1_ADDR = 0x0218C000, | ||
143 | + FSL_IMX6UL_SIMn_SIZE = (16 * KiB), | ||
144 | + | ||
145 | + FSL_IMX6UL_ENET1_ADDR = 0x02188000, | ||
146 | + | ||
147 | + FSL_IMX6UL_USBO2_USBMISC_ADDR = 0x02184800, | ||
148 | + FSL_IMX6UL_USBO2_USB1_ADDR = 0x02184000, | ||
149 | + FSL_IMX6UL_USBO2_USB2_ADDR = 0x02184200, | ||
150 | + | ||
151 | + FSL_IMX6UL_USBO2_PL301_ADDR = 0x02180000, | ||
152 | + FSL_IMX6UL_USBO2_PL301_SIZE = (16 * KiB), | ||
153 | + | ||
154 | + FSL_IMX6UL_AIPS2_CFG_ADDR = 0x0217C000, | ||
155 | + FSL_IMX6UL_AIPS2_CFG_SIZE = 0x100, | ||
156 | + | ||
157 | + FSL_IMX6UL_CAAM_ADDR = 0x02140000, | ||
158 | + FSL_IMX6UL_CAAM_SIZE = (16 * KiB), | ||
159 | + | ||
160 | + FSL_IMX6UL_A7MPCORE_DAP_ADDR = 0x02100000, | ||
161 | + FSL_IMX6UL_A7MPCORE_DAP_SIZE = (4 * KiB), | ||
162 | + /* AIPS-2 End */ | ||
163 | + | ||
164 | + /* AIPS-1 Begin */ | ||
165 | FSL_IMX6UL_PWM8_ADDR = 0x020FC000, | ||
166 | FSL_IMX6UL_PWM7_ADDR = 0x020F8000, | ||
167 | FSL_IMX6UL_PWM6_ADDR = 0x020F4000, | ||
168 | FSL_IMX6UL_PWM5_ADDR = 0x020F0000, | ||
169 | + | ||
170 | FSL_IMX6UL_SDMA_ADDR = 0x020EC000, | ||
171 | + FSL_IMX6UL_SDMA_SIZE = 0x300, | ||
172 | + | ||
173 | FSL_IMX6UL_GPT2_ADDR = 0x020E8000, | ||
174 | + | ||
175 | FSL_IMX6UL_IOMUXC_GPR_ADDR = 0x020E4000, | ||
176 | + FSL_IMX6UL_IOMUXC_GPR_SIZE = 0x40, | ||
177 | + | ||
178 | FSL_IMX6UL_IOMUXC_ADDR = 0x020E0000, | ||
179 | + FSL_IMX6UL_IOMUXC_SIZE = 0x700, | ||
180 | + | ||
181 | FSL_IMX6UL_GPC_ADDR = 0x020DC000, | ||
182 | + | ||
183 | FSL_IMX6UL_SRC_ADDR = 0x020D8000, | ||
184 | + | ||
185 | FSL_IMX6UL_EPIT2_ADDR = 0x020D4000, | ||
186 | FSL_IMX6UL_EPIT1_ADDR = 0x020D0000, | ||
187 | + | ||
188 | FSL_IMX6UL_SNVS_HP_ADDR = 0x020CC000, | ||
189 | + | ||
190 | FSL_IMX6UL_USBPHY2_ADDR = 0x020CA000, | ||
191 | - FSL_IMX6UL_USBPHY2_SIZE = (4 * 1024), | ||
192 | FSL_IMX6UL_USBPHY1_ADDR = 0x020C9000, | ||
193 | - FSL_IMX6UL_USBPHY1_SIZE = (4 * 1024), | ||
194 | + | ||
195 | FSL_IMX6UL_ANALOG_ADDR = 0x020C8000, | ||
196 | + FSL_IMX6UL_ANALOG_SIZE = 0x300, | ||
197 | + | ||
198 | FSL_IMX6UL_CCM_ADDR = 0x020C4000, | ||
199 | + | ||
200 | FSL_IMX6UL_WDOG2_ADDR = 0x020C0000, | ||
201 | FSL_IMX6UL_WDOG1_ADDR = 0x020BC000, | ||
202 | + | ||
203 | FSL_IMX6UL_KPP_ADDR = 0x020B8000, | ||
204 | + FSL_IMX6UL_KPP_SIZE = 0x10, | ||
205 | + | ||
206 | FSL_IMX6UL_ENET2_ADDR = 0x020B4000, | ||
207 | + | ||
208 | FSL_IMX6UL_SNVS_LP_ADDR = 0x020B0000, | ||
209 | + FSL_IMX6UL_SNVS_LP_SIZE = (16 * KiB), | ||
210 | + | ||
211 | FSL_IMX6UL_GPIO5_ADDR = 0x020AC000, | ||
212 | FSL_IMX6UL_GPIO4_ADDR = 0x020A8000, | ||
213 | FSL_IMX6UL_GPIO3_ADDR = 0x020A4000, | ||
214 | FSL_IMX6UL_GPIO2_ADDR = 0x020A0000, | ||
215 | FSL_IMX6UL_GPIO1_ADDR = 0x0209C000, | ||
216 | + | ||
217 | FSL_IMX6UL_GPT1_ADDR = 0x02098000, | ||
218 | + | ||
219 | FSL_IMX6UL_CAN2_ADDR = 0x02094000, | ||
220 | FSL_IMX6UL_CAN1_ADDR = 0x02090000, | ||
221 | + FSL_IMX6UL_CANn_SIZE = (4 * KiB), | ||
222 | + | ||
223 | FSL_IMX6UL_PWM4_ADDR = 0x0208C000, | ||
224 | FSL_IMX6UL_PWM3_ADDR = 0x02088000, | ||
225 | FSL_IMX6UL_PWM2_ADDR = 0x02084000, | ||
226 | FSL_IMX6UL_PWM1_ADDR = 0x02080000, | ||
227 | + FSL_IMX6UL_PWMn_SIZE = 0x20, | ||
228 | + | ||
229 | FSL_IMX6UL_AIPS1_CFG_ADDR = 0x0207C000, | ||
230 | + FSL_IMX6UL_AIPS1_CFG_SIZE = (16 * KiB), | ||
231 | + | ||
232 | FSL_IMX6UL_BEE_ADDR = 0x02044000, | ||
233 | + FSL_IMX6UL_BEE_SIZE = (16 * KiB), | ||
234 | + | ||
235 | FSL_IMX6UL_TOUCH_CTRL_ADDR = 0x02040000, | ||
236 | + FSL_IMX6UL_TOUCH_CTRL_SIZE = 0x100, | ||
237 | + | ||
238 | FSL_IMX6UL_SPBA_ADDR = 0x0203C000, | ||
239 | + FSL_IMX6UL_SPBA_SIZE = 0x100, | ||
240 | + | ||
241 | FSL_IMX6UL_ASRC_ADDR = 0x02034000, | ||
242 | + FSL_IMX6UL_ASRC_SIZE = 0x100, | ||
243 | + | ||
244 | FSL_IMX6UL_SAI3_ADDR = 0x02030000, | ||
245 | FSL_IMX6UL_SAI2_ADDR = 0x0202C000, | ||
246 | FSL_IMX6UL_SAI1_ADDR = 0x02028000, | ||
247 | + FSL_IMX6UL_SAIn_SIZE = 0x200, | ||
248 | + | ||
249 | FSL_IMX6UL_UART8_ADDR = 0x02024000, | ||
250 | FSL_IMX6UL_UART1_ADDR = 0x02020000, | ||
251 | FSL_IMX6UL_UART7_ADDR = 0x02018000, | ||
252 | + | ||
253 | FSL_IMX6UL_ECSPI4_ADDR = 0x02014000, | ||
254 | FSL_IMX6UL_ECSPI3_ADDR = 0x02010000, | ||
255 | FSL_IMX6UL_ECSPI2_ADDR = 0x0200C000, | ||
256 | FSL_IMX6UL_ECSPI1_ADDR = 0x02008000, | ||
257 | + | ||
258 | FSL_IMX6UL_SPDIF_ADDR = 0x02004000, | ||
259 | + FSL_IMX6UL_SPDIF_SIZE = 0x100, | ||
260 | + /* AIPS-1 End */ | ||
261 | + | ||
262 | + FSL_IMX6UL_BCH_ADDR = 0x01808000, | ||
263 | + FSL_IMX6UL_BCH_SIZE = 0x200, | ||
264 | + | ||
265 | + FSL_IMX6UL_GPMI_ADDR = 0x01806000, | ||
266 | + FSL_IMX6UL_GPMI_SIZE = 0x200, | ||
267 | |||
268 | FSL_IMX6UL_APBH_DMA_ADDR = 0x01804000, | ||
269 | - FSL_IMX6UL_APBH_DMA_SIZE = (32 * 1024), | ||
270 | + FSL_IMX6UL_APBH_DMA_SIZE = (4 * KiB), | ||
271 | |||
272 | FSL_IMX6UL_A7MPCORE_ADDR = 0x00A00000, | ||
273 | |||
274 | FSL_IMX6UL_OCRAM_ALIAS_ADDR = 0x00920000, | ||
275 | - FSL_IMX6UL_OCRAM_ALIAS_SIZE = 0x00060000, | ||
276 | + FSL_IMX6UL_OCRAM_ALIAS_SIZE = (384 * KiB), | ||
277 | + | ||
278 | FSL_IMX6UL_OCRAM_MEM_ADDR = 0x00900000, | ||
279 | - FSL_IMX6UL_OCRAM_MEM_SIZE = 0x00020000, | ||
280 | + FSL_IMX6UL_OCRAM_MEM_SIZE = (128 * KiB), | ||
281 | + | ||
282 | FSL_IMX6UL_CAAM_MEM_ADDR = 0x00100000, | ||
283 | - FSL_IMX6UL_CAAM_MEM_SIZE = 0x00008000, | ||
284 | + FSL_IMX6UL_CAAM_MEM_SIZE = (32 * KiB), | ||
285 | + | ||
286 | FSL_IMX6UL_ROM_ADDR = 0x00000000, | ||
287 | - FSL_IMX6UL_ROM_SIZE = 0x00018000, | ||
288 | + FSL_IMX6UL_ROM_SIZE = (96 * KiB), | ||
289 | }; | ||
290 | |||
291 | enum FslIMX6ULIRQs { | ||
292 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 293 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/target/arm/translate.h | 294 | --- a/hw/arm/fsl-imx6ul.c |
35 | +++ b/target/arm/translate.h | 295 | +++ b/hw/arm/fsl-imx6ul.c |
36 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 296 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) |
37 | bool bt; | 297 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); |
38 | /* True if any CP15 access is trapped by HSTR_EL2 */ | 298 | |
39 | bool hstr_active; | 299 | /* |
40 | + /* True if memory operations require alignment */ | 300 | - * GPIOs 1 to 5 |
41 | + bool align_mem; | 301 | + * GPIOs |
42 | /* | 302 | */ |
43 | * >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. | 303 | for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) { |
44 | * < 0, set by the current instruction. | 304 | snprintf(name, NAME_SIZE, "gpio%d", i); |
45 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 305 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) |
46 | index XXXXXXX..XXXXXXX 100644 | 306 | } |
47 | --- a/target/arm/helper.c | 307 | |
48 | +++ b/target/arm/helper.c | 308 | /* |
49 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el, | 309 | - * GPT 1, 2 |
50 | ARMMMUIdx mmu_idx) | 310 | + * GPTs |
51 | { | 311 | */ |
52 | CPUARMTBFlags flags = {}; | 312 | for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { |
53 | + uint32_t ccr = env->v7m.ccr[env->v7m.secure]; | 313 | snprintf(name, NAME_SIZE, "gpt%d", i); |
54 | + | 314 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) |
55 | + /* Without HaveMainExt, CCR.UNALIGN_TRP is RES1. */ | 315 | } |
56 | + if (ccr & R_V7M_CCR_UNALIGN_TRP_MASK) { | 316 | |
57 | + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); | 317 | /* |
318 | - * EPIT 1, 2 | ||
319 | + * EPITs | ||
320 | */ | ||
321 | for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) { | ||
322 | snprintf(name, NAME_SIZE, "epit%d", i + 1); | ||
323 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
324 | } | ||
325 | |||
326 | /* | ||
327 | - * eCSPI | ||
328 | + * eCSPIs | ||
329 | */ | ||
330 | for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) { | ||
331 | snprintf(name, NAME_SIZE, "spi%d", i + 1); | ||
332 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
333 | } | ||
334 | |||
335 | /* | ||
336 | - * I2C | ||
337 | + * I2Cs | ||
338 | */ | ||
339 | for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) { | ||
340 | snprintf(name, NAME_SIZE, "i2c%d", i + 1); | ||
341 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
342 | } | ||
343 | |||
344 | /* | ||
345 | - * UART | ||
346 | + * UARTs | ||
347 | */ | ||
348 | for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) { | ||
349 | snprintf(name, NAME_SIZE, "uart%d", i); | ||
350 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | - * Ethernet | ||
355 | + * Ethernets | ||
356 | */ | ||
357 | for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) { | ||
358 | snprintf(name, NAME_SIZE, "eth%d", i); | ||
359 | object_initialize_child(obj, name, &s->eth[i], TYPE_IMX_ENET); | ||
360 | } | ||
361 | |||
362 | - /* USB */ | ||
363 | + /* | ||
364 | + * USB PHYs | ||
365 | + */ | ||
366 | for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { | ||
367 | snprintf(name, NAME_SIZE, "usbphy%d", i); | ||
368 | object_initialize_child(obj, name, &s->usbphy[i], TYPE_IMX_USBPHY); | ||
369 | } | ||
370 | + | ||
371 | + /* | ||
372 | + * USBs | ||
373 | + */ | ||
374 | for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { | ||
375 | snprintf(name, NAME_SIZE, "usb%d", i); | ||
376 | object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA); | ||
377 | } | ||
378 | |||
379 | /* | ||
380 | - * SDHCI | ||
381 | + * SDHCIs | ||
382 | */ | ||
383 | for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { | ||
384 | snprintf(name, NAME_SIZE, "usdhc%d", i); | ||
385 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
386 | } | ||
387 | |||
388 | /* | ||
389 | - * Watchdog | ||
390 | + * Watchdogs | ||
391 | */ | ||
392 | for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) { | ||
393 | snprintf(name, NAME_SIZE, "wdt%d", i); | ||
394 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
395 | * A7MPCORE DAP | ||
396 | */ | ||
397 | create_unimplemented_device("a7mpcore-dap", FSL_IMX6UL_A7MPCORE_DAP_ADDR, | ||
398 | - 0x100000); | ||
399 | + FSL_IMX6UL_A7MPCORE_DAP_SIZE); | ||
400 | |||
401 | /* | ||
402 | - * GPT 1, 2 | ||
403 | + * GPTs | ||
404 | */ | ||
405 | for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { | ||
406 | static const hwaddr FSL_IMX6UL_GPTn_ADDR[FSL_IMX6UL_NUM_GPTS] = { | ||
407 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
408 | } | ||
409 | |||
410 | /* | ||
411 | - * EPIT 1, 2 | ||
412 | + * EPITs | ||
413 | */ | ||
414 | for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) { | ||
415 | static const hwaddr FSL_IMX6UL_EPITn_ADDR[FSL_IMX6UL_NUM_EPITS] = { | ||
416 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
417 | } | ||
418 | |||
419 | /* | ||
420 | - * GPIO | ||
421 | + * GPIOs | ||
422 | */ | ||
423 | for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) { | ||
424 | static const hwaddr FSL_IMX6UL_GPIOn_ADDR[FSL_IMX6UL_NUM_GPIOS] = { | ||
425 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
426 | } | ||
427 | |||
428 | /* | ||
429 | - * IOMUXC and IOMUXC_GPR | ||
430 | + * IOMUXC | ||
431 | */ | ||
432 | - for (i = 0; i < 1; i++) { | ||
433 | - static const hwaddr FSL_IMX6UL_IOMUXCn_ADDR[FSL_IMX6UL_NUM_IOMUXCS] = { | ||
434 | - FSL_IMX6UL_IOMUXC_ADDR, | ||
435 | - FSL_IMX6UL_IOMUXC_GPR_ADDR, | ||
436 | - }; | ||
437 | - | ||
438 | - snprintf(name, NAME_SIZE, "iomuxc%d", i); | ||
439 | - create_unimplemented_device(name, FSL_IMX6UL_IOMUXCn_ADDR[i], 0x4000); | ||
440 | - } | ||
441 | + create_unimplemented_device("iomuxc", FSL_IMX6UL_IOMUXC_ADDR, | ||
442 | + FSL_IMX6UL_IOMUXC_SIZE); | ||
443 | + create_unimplemented_device("iomuxc_gpr", FSL_IMX6UL_IOMUXC_GPR_ADDR, | ||
444 | + FSL_IMX6UL_IOMUXC_GPR_SIZE); | ||
445 | |||
446 | /* | ||
447 | * CCM | ||
448 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
449 | sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort); | ||
450 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX6UL_GPC_ADDR); | ||
451 | |||
452 | - /* Initialize all ECSPI */ | ||
453 | + /* | ||
454 | + * ECSPIs | ||
455 | + */ | ||
456 | for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) { | ||
457 | static const hwaddr FSL_IMX6UL_SPIn_ADDR[FSL_IMX6UL_NUM_ECSPIS] = { | ||
458 | FSL_IMX6UL_ECSPI1_ADDR, | ||
459 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
460 | } | ||
461 | |||
462 | /* | ||
463 | - * I2C | ||
464 | + * I2Cs | ||
465 | */ | ||
466 | for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) { | ||
467 | static const hwaddr FSL_IMX6UL_I2Cn_ADDR[FSL_IMX6UL_NUM_I2CS] = { | ||
468 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
469 | } | ||
470 | |||
471 | /* | ||
472 | - * UART | ||
473 | + * UARTs | ||
474 | */ | ||
475 | for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) { | ||
476 | static const hwaddr FSL_IMX6UL_UARTn_ADDR[FSL_IMX6UL_NUM_UARTS] = { | ||
477 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
478 | } | ||
479 | |||
480 | /* | ||
481 | - * Ethernet | ||
482 | + * Ethernets | ||
483 | * | ||
484 | * We must use two loops since phy_connected affects the other interface | ||
485 | * and we have to set all properties before calling sysbus_realize(). | ||
486 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
487 | FSL_IMX6UL_ENETn_TIMER_IRQ[i])); | ||
488 | } | ||
489 | |||
490 | - /* USB */ | ||
491 | + /* | ||
492 | + * USB PHYs | ||
493 | + */ | ||
494 | for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { | ||
495 | + static const hwaddr | ||
496 | + FSL_IMX6UL_USB_PHYn_ADDR[FSL_IMX6UL_NUM_USB_PHYS] = { | ||
497 | + FSL_IMX6UL_USBPHY1_ADDR, | ||
498 | + FSL_IMX6UL_USBPHY2_ADDR, | ||
499 | + }; | ||
500 | + | ||
501 | sysbus_realize(SYS_BUS_DEVICE(&s->usbphy[i]), &error_abort); | ||
502 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usbphy[i]), 0, | ||
503 | - FSL_IMX6UL_USBPHY1_ADDR + i * 0x1000); | ||
504 | + FSL_IMX6UL_USB_PHYn_ADDR[i]); | ||
505 | } | ||
506 | |||
507 | + /* | ||
508 | + * USBs | ||
509 | + */ | ||
510 | for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { | ||
511 | + static const hwaddr FSL_IMX6UL_USB02_USBn_ADDR[FSL_IMX6UL_NUM_USBS] = { | ||
512 | + FSL_IMX6UL_USBO2_USB1_ADDR, | ||
513 | + FSL_IMX6UL_USBO2_USB2_ADDR, | ||
514 | + }; | ||
515 | + | ||
516 | static const int FSL_IMX6UL_USBn_IRQ[] = { | ||
517 | FSL_IMX6UL_USB1_IRQ, | ||
518 | FSL_IMX6UL_USB2_IRQ, | ||
519 | }; | ||
520 | + | ||
521 | sysbus_realize(SYS_BUS_DEVICE(&s->usb[i]), &error_abort); | ||
522 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
523 | - FSL_IMX6UL_USBO2_USB_ADDR + i * 0x200); | ||
524 | + FSL_IMX6UL_USB02_USBn_ADDR[i]); | ||
525 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
526 | qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
527 | FSL_IMX6UL_USBn_IRQ[i])); | ||
528 | } | ||
529 | |||
530 | /* | ||
531 | - * USDHC | ||
532 | + * USDHCs | ||
533 | */ | ||
534 | for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { | ||
535 | static const hwaddr FSL_IMX6UL_USDHCn_ADDR[FSL_IMX6UL_NUM_USDHCS] = { | ||
536 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
537 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX6UL_SNVS_HP_ADDR); | ||
538 | |||
539 | /* | ||
540 | - * Watchdog | ||
541 | + * Watchdogs | ||
542 | */ | ||
543 | for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) { | ||
544 | static const hwaddr FSL_IMX6UL_WDOGn_ADDR[FSL_IMX6UL_NUM_WDTS] = { | ||
545 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
546 | FSL_IMX6UL_WDOG2_ADDR, | ||
547 | FSL_IMX6UL_WDOG3_ADDR, | ||
548 | }; | ||
549 | + | ||
550 | static const int FSL_IMX6UL_WDOGn_IRQ[FSL_IMX6UL_NUM_WDTS] = { | ||
551 | FSL_IMX6UL_WDOG1_IRQ, | ||
552 | FSL_IMX6UL_WDOG2_IRQ, | ||
553 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
554 | /* | ||
555 | * SDMA | ||
556 | */ | ||
557 | - create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000); | ||
558 | + create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, | ||
559 | + FSL_IMX6UL_SDMA_SIZE); | ||
560 | |||
561 | /* | ||
562 | - * SAI (Audio SSI (Synchronous Serial Interface)) | ||
563 | + * SAIs (Audio SSI (Synchronous Serial Interface)) | ||
564 | */ | ||
565 | - create_unimplemented_device("sai1", FSL_IMX6UL_SAI1_ADDR, 0x4000); | ||
566 | - create_unimplemented_device("sai2", FSL_IMX6UL_SAI2_ADDR, 0x4000); | ||
567 | - create_unimplemented_device("sai3", FSL_IMX6UL_SAI3_ADDR, 0x4000); | ||
568 | + for (i = 0; i < FSL_IMX6UL_NUM_SAIS; i++) { | ||
569 | + static const hwaddr FSL_IMX6UL_SAIn_ADDR[FSL_IMX6UL_NUM_SAIS] = { | ||
570 | + FSL_IMX6UL_SAI1_ADDR, | ||
571 | + FSL_IMX6UL_SAI2_ADDR, | ||
572 | + FSL_IMX6UL_SAI3_ADDR, | ||
573 | + }; | ||
574 | + | ||
575 | + snprintf(name, NAME_SIZE, "sai%d", i); | ||
576 | + create_unimplemented_device(name, FSL_IMX6UL_SAIn_ADDR[i], | ||
577 | + FSL_IMX6UL_SAIn_SIZE); | ||
58 | + } | 578 | + } |
59 | 579 | ||
60 | if (arm_v7m_is_handler_mode(env)) { | 580 | /* |
61 | DP_TBFLAG_M32(flags, HANDLER, 1); | 581 | - * PWM |
62 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el, | 582 | + * PWMs |
63 | */ | 583 | */ |
64 | if (arm_feature(env, ARM_FEATURE_V8) && | 584 | - create_unimplemented_device("pwm1", FSL_IMX6UL_PWM1_ADDR, 0x4000); |
65 | !((mmu_idx & ARM_MMU_IDX_M_NEGPRI) && | 585 | - create_unimplemented_device("pwm2", FSL_IMX6UL_PWM2_ADDR, 0x4000); |
66 | - (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_STKOFHFNMIGN_MASK))) { | 586 | - create_unimplemented_device("pwm3", FSL_IMX6UL_PWM3_ADDR, 0x4000); |
67 | + (ccr & R_V7M_CCR_STKOFHFNMIGN_MASK))) { | 587 | - create_unimplemented_device("pwm4", FSL_IMX6UL_PWM4_ADDR, 0x4000); |
68 | DP_TBFLAG_M32(flags, STACKCHECK, 1); | 588 | + for (i = 0; i < FSL_IMX6UL_NUM_PWMS; i++) { |
69 | } | 589 | + static const hwaddr FSL_IMX6UL_PWMn_ADDR[FSL_IMX6UL_NUM_PWMS] = { |
70 | 590 | + FSL_IMX6UL_PWM1_ADDR, | |
71 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, | 591 | + FSL_IMX6UL_PWM2_ADDR, |
72 | ARMMMUIdx mmu_idx) | 592 | + FSL_IMX6UL_PWM3_ADDR, |
73 | { | 593 | + FSL_IMX6UL_PWM4_ADDR, |
74 | CPUARMTBFlags flags = rebuild_hflags_aprofile(env); | 594 | + }; |
75 | + int el = arm_current_el(env); | 595 | + |
76 | + | 596 | + snprintf(name, NAME_SIZE, "pwm%d", i); |
77 | + if (arm_sctlr(env, el) & SCTLR_A) { | 597 | + create_unimplemented_device(name, FSL_IMX6UL_PWMn_ADDR[i], |
78 | + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); | 598 | + FSL_IMX6UL_PWMn_SIZE); |
79 | + } | 599 | + } |
80 | 600 | ||
81 | if (arm_el_is_aa64(env, 1)) { | 601 | /* |
82 | DP_TBFLAG_A32(flags, VFPEN, 1); | 602 | * Audio ASRC (asynchronous sample rate converter) |
83 | } | 603 | */ |
84 | 604 | - create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, 0x4000); | |
85 | - if (arm_current_el(env) < 2 && env->cp15.hstr_el2 && | 605 | + create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, |
86 | + if (el < 2 && env->cp15.hstr_el2 && | 606 | + FSL_IMX6UL_ASRC_SIZE); |
87 | (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | 607 | |
88 | DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1); | 608 | /* |
89 | } | 609 | - * CAN |
90 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | 610 | + * CANs |
91 | 611 | */ | |
92 | sctlr = regime_sctlr(env, stage1); | 612 | - create_unimplemented_device("can1", FSL_IMX6UL_CAN1_ADDR, 0x4000); |
93 | 613 | - create_unimplemented_device("can2", FSL_IMX6UL_CAN2_ADDR, 0x4000); | |
94 | + if (sctlr & SCTLR_A) { | 614 | + for (i = 0; i < FSL_IMX6UL_NUM_CANS; i++) { |
95 | + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); | 615 | + static const hwaddr FSL_IMX6UL_CANn_ADDR[FSL_IMX6UL_NUM_CANS] = { |
616 | + FSL_IMX6UL_CAN1_ADDR, | ||
617 | + FSL_IMX6UL_CAN2_ADDR, | ||
618 | + }; | ||
619 | + | ||
620 | + snprintf(name, NAME_SIZE, "can%d", i); | ||
621 | + create_unimplemented_device(name, FSL_IMX6UL_CANn_ADDR[i], | ||
622 | + FSL_IMX6UL_CANn_SIZE); | ||
96 | + } | 623 | + } |
97 | + | 624 | |
98 | if (arm_cpu_data_is_big_endian_a64(el, sctlr)) { | 625 | /* |
99 | DP_TBFLAG_ANY(flags, BE_DATA, 1); | 626 | * APHB_DMA |
100 | } | 627 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
101 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 628 | }; |
102 | index XXXXXXX..XXXXXXX 100644 | 629 | |
103 | --- a/target/arm/translate-a64.c | 630 | snprintf(name, NAME_SIZE, "adc%d", i); |
104 | +++ b/target/arm/translate-a64.c | 631 | - create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i], 0x4000); |
105 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 632 | + create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i], |
106 | dc->user = (dc->current_el == 0); | 633 | + FSL_IMX6UL_ADCn_SIZE); |
107 | #endif | 634 | } |
108 | dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); | 635 | |
109 | + dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); | 636 | /* |
110 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); | 637 | * LCD |
111 | dc->sve_len = (EX_TBFLAG_A64(tb_flags, ZCR_LEN) + 1) * 16; | 638 | */ |
112 | dc->pauth_active = EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); | 639 | - create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, 0x4000); |
113 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 640 | + create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, |
114 | index XXXXXXX..XXXXXXX 100644 | 641 | + FSL_IMX6UL_LCDIF_SIZE); |
115 | --- a/target/arm/translate.c | 642 | |
116 | +++ b/target/arm/translate.c | 643 | /* |
117 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 644 | * ROM memory |
118 | { | ||
119 | TCGv addr; | ||
120 | |||
121 | - if (arm_dc_feature(s, ARM_FEATURE_M) && | ||
122 | - !arm_dc_feature(s, ARM_FEATURE_M_MAIN)) { | ||
123 | + if (s->align_mem) { | ||
124 | opc |= MO_ALIGN; | ||
125 | } | ||
126 | |||
127 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
128 | { | ||
129 | TCGv addr; | ||
130 | |||
131 | - if (arm_dc_feature(s, ARM_FEATURE_M) && | ||
132 | - !arm_dc_feature(s, ARM_FEATURE_M_MAIN)) { | ||
133 | + if (s->align_mem) { | ||
134 | opc |= MO_ALIGN; | ||
135 | } | ||
136 | |||
137 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
138 | dc->user = (dc->current_el == 0); | ||
139 | #endif | ||
140 | dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); | ||
141 | + dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); | ||
142 | |||
143 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
144 | dc->vfp_enabled = 1; | ||
145 | -- | 645 | -- |
146 | 2.20.1 | 646 | 2.34.1 |
147 | |||
148 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | * Add TZASC as unimplemented device. |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | - Allow bare metal application to access this (unimplemented) device |
5 | Message-id: 20210419202257.161730-24-richard.henderson@linaro.org | 5 | * Add CSU as unimplemented device. |
6 | - Allow bare metal application to access this (unimplemented) device | ||
7 | * Add 4 missing PWM devices | ||
8 | |||
9 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Message-id: 59e4dc56e14eccfefd379275ec19048dff9c10b3.1692964892.git.jcd@tribudubois.net | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 13 | --- |
8 | target/arm/translate-neon.c.inc | 27 ++++++++++++++++++++++----- | 14 | include/hw/arm/fsl-imx6ul.h | 2 +- |
9 | 1 file changed, 22 insertions(+), 5 deletions(-) | 15 | hw/arm/fsl-imx6ul.c | 16 ++++++++++++++++ |
16 | 2 files changed, 17 insertions(+), 1 deletion(-) | ||
10 | 17 | ||
11 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 18 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h |
12 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-neon.c.inc | 20 | --- a/include/hw/arm/fsl-imx6ul.h |
14 | +++ b/target/arm/translate-neon.c.inc | 21 | +++ b/include/hw/arm/fsl-imx6ul.h |
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | 22 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration { |
16 | { | 23 | FSL_IMX6UL_NUM_USBS = 2, |
17 | /* Neon load/store multiple structures */ | 24 | FSL_IMX6UL_NUM_SAIS = 3, |
18 | int nregs, interleave, spacing, reg, n; | 25 | FSL_IMX6UL_NUM_CANS = 2, |
19 | - MemOp endian = s->be_data; | 26 | - FSL_IMX6UL_NUM_PWMS = 4, |
20 | + MemOp mop, align, endian; | 27 | + FSL_IMX6UL_NUM_PWMS = 8, |
21 | int mmu_idx = get_mem_index(s); | 28 | }; |
22 | int size = a->size; | 29 | |
23 | TCGv_i64 tmp64; | 30 | struct FslIMX6ULState { |
24 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | 31 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c |
25 | } | 32 | index XXXXXXX..XXXXXXX 100644 |
26 | 33 | --- a/hw/arm/fsl-imx6ul.c | |
27 | /* For our purposes, bytes are always little-endian. */ | 34 | +++ b/hw/arm/fsl-imx6ul.c |
28 | + endian = s->be_data; | 35 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
29 | if (size == 0) { | 36 | FSL_IMX6UL_PWM2_ADDR, |
30 | endian = MO_LE; | 37 | FSL_IMX6UL_PWM3_ADDR, |
31 | } | 38 | FSL_IMX6UL_PWM4_ADDR, |
39 | + FSL_IMX6UL_PWM5_ADDR, | ||
40 | + FSL_IMX6UL_PWM6_ADDR, | ||
41 | + FSL_IMX6UL_PWM7_ADDR, | ||
42 | + FSL_IMX6UL_PWM8_ADDR, | ||
43 | }; | ||
44 | |||
45 | snprintf(name, NAME_SIZE, "pwm%d", i); | ||
46 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
47 | create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, | ||
48 | FSL_IMX6UL_LCDIF_SIZE); | ||
49 | |||
50 | + /* | ||
51 | + * CSU | ||
52 | + */ | ||
53 | + create_unimplemented_device("csu", FSL_IMX6UL_CSU_ADDR, | ||
54 | + FSL_IMX6UL_CSU_SIZE); | ||
32 | + | 55 | + |
33 | + /* Enforce alignment requested by the instruction */ | 56 | + /* |
34 | + if (a->align) { | 57 | + * TZASC |
35 | + align = pow2_align(a->align + 2); /* 4 ** a->align */ | 58 | + */ |
36 | + } else { | 59 | + create_unimplemented_device("tzasc", FSL_IMX6UL_TZASC_ADDR, |
37 | + align = s->align_mem ? MO_ALIGN : 0; | 60 | + FSL_IMX6UL_TZASC_SIZE); |
38 | + } | ||
39 | + | 61 | + |
40 | /* | 62 | /* |
41 | * Consecutive little-endian elements from a single register | 63 | * ROM memory |
42 | * can be promoted to a larger little-endian operation. | ||
43 | */ | 64 | */ |
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 | + | ||
52 | tmp64 = tcg_temp_new_i64(); | ||
53 | addr = tcg_temp_new_i32(); | ||
54 | tmp = tcg_const_i32(1 << size); | ||
55 | load_reg_var(s, addr, a->rn); | ||
56 | + | ||
57 | + mop = endian | size | align; | ||
58 | for (reg = 0; reg < nregs; reg++) { | ||
59 | for (n = 0; n < 8 >> size; n++) { | ||
60 | int xs; | ||
61 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | ||
62 | int tt = a->vd + reg + spacing * xs; | ||
63 | |||
64 | if (a->l) { | ||
65 | - gen_aa32_ld_internal_i64(s, tmp64, addr, mmu_idx, | ||
66 | - endian | size); | ||
67 | + gen_aa32_ld_internal_i64(s, tmp64, addr, mmu_idx, mop); | ||
68 | neon_store_element64(tt, n, size, tmp64); | ||
69 | } else { | ||
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 | + | ||
77 | + /* Subsequent memory operations inherit alignment */ | ||
78 | + mop &= ~MO_AMASK; | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | -- | 65 | -- |
83 | 2.20.1 | 66 | 2.34.1 |
84 | 67 | ||
85 | 68 | diff view generated by jsdifflib |
1 | Currently the gpex PCI controller implements no special behaviour for | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | guest accesses to areas of the PIO and MMIO where it has not mapped | ||
3 | any PCI devices, which means that for Arm you end up with a CPU | ||
4 | exception due to a data abort. | ||
5 | 2 | ||
6 | Most host OSes expect "like an x86 PC" behaviour, where bad accesses | 3 | * Add Addr and size definition for all i.MX7 devices in i.MX7 header file. |
7 | like this return -1 for reads and ignore writes. In the interests of | 4 | * Use those newly defined named constants whenever possible. |
8 | not being surprising, make host CPU accesses to these windows behave | 5 | * Standardize the way we init a familly of unimplemented devices |
9 | as -1/discard where there's no mapped PCI device. | 6 | - SAI |
7 | - PWM | ||
8 | - CAN | ||
9 | * Add/rework few comments | ||
10 | 10 | ||
11 | The old behaviour generally didn't cause any problems, because | 11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
12 | almost always the guest OS will map the PCI devices and then only | 12 | Message-id: 59e195d33e4d486a8d131392acd46633c8c10ed7.1692964892.git.jcd@tribudubois.net |
13 | access where it has mapped them. One corner case where you will see | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
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> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | ||
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> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | --- | 15 | --- |
26 | include/hw/pci-host/gpex.h | 4 +++ | 16 | include/hw/arm/fsl-imx7.h | 330 ++++++++++++++++++++++++++++---------- |
27 | hw/core/machine.c | 4 ++- | 17 | hw/arm/fsl-imx7.c | 130 ++++++++++----- |
28 | hw/pci-host/gpex.c | 56 ++++++++++++++++++++++++++++++++++++-- | 18 | 2 files changed, 335 insertions(+), 125 deletions(-) |
29 | 3 files changed, 60 insertions(+), 4 deletions(-) | ||
30 | 19 | ||
31 | diff --git a/include/hw/pci-host/gpex.h b/include/hw/pci-host/gpex.h | 20 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
32 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/include/hw/pci-host/gpex.h | 22 | --- a/include/hw/arm/fsl-imx7.h |
34 | +++ b/include/hw/pci-host/gpex.h | 23 | +++ b/include/hw/arm/fsl-imx7.h |
35 | @@ -XXX,XX +XXX,XX @@ struct GPEXHost { | 24 | @@ -XXX,XX +XXX,XX @@ |
36 | 25 | #include "hw/misc/imx7_ccm.h" | |
37 | MemoryRegion io_ioport; | 26 | #include "hw/misc/imx7_snvs.h" |
38 | MemoryRegion io_mmio; | 27 | #include "hw/misc/imx7_gpr.h" |
39 | + MemoryRegion io_ioport_window; | 28 | -#include "hw/misc/imx6_src.h" |
40 | + MemoryRegion io_mmio_window; | 29 | #include "hw/watchdog/wdt_imx2.h" |
41 | qemu_irq irq[GPEX_NUM_IRQS]; | 30 | #include "hw/gpio/imx_gpio.h" |
42 | int irq_num[GPEX_NUM_IRQS]; | 31 | #include "hw/char/imx_serial.h" |
43 | + | 32 | @@ -XXX,XX +XXX,XX @@ |
44 | + bool allow_unmapped_accesses; | 33 | #include "hw/usb/chipidea.h" |
34 | #include "cpu.h" | ||
35 | #include "qom/object.h" | ||
36 | +#include "qemu/units.h" | ||
37 | |||
38 | #define TYPE_FSL_IMX7 "fsl-imx7" | ||
39 | OBJECT_DECLARE_SIMPLE_TYPE(FslIMX7State, FSL_IMX7) | ||
40 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7Configuration { | ||
41 | FSL_IMX7_NUM_ECSPIS = 4, | ||
42 | FSL_IMX7_NUM_USBS = 3, | ||
43 | FSL_IMX7_NUM_ADCS = 2, | ||
44 | + FSL_IMX7_NUM_SAIS = 3, | ||
45 | + FSL_IMX7_NUM_CANS = 2, | ||
46 | + FSL_IMX7_NUM_PWMS = 4, | ||
45 | }; | 47 | }; |
46 | 48 | ||
47 | struct GPEXConfig { | 49 | struct FslIMX7State { |
48 | diff --git a/hw/core/machine.c b/hw/core/machine.c | 50 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { |
51 | |||
52 | enum FslIMX7MemoryMap { | ||
53 | FSL_IMX7_MMDC_ADDR = 0x80000000, | ||
54 | - FSL_IMX7_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL, | ||
55 | + FSL_IMX7_MMDC_SIZE = (2 * GiB), | ||
56 | |||
57 | - FSL_IMX7_GPIO1_ADDR = 0x30200000, | ||
58 | - FSL_IMX7_GPIO2_ADDR = 0x30210000, | ||
59 | - FSL_IMX7_GPIO3_ADDR = 0x30220000, | ||
60 | - FSL_IMX7_GPIO4_ADDR = 0x30230000, | ||
61 | - FSL_IMX7_GPIO5_ADDR = 0x30240000, | ||
62 | - FSL_IMX7_GPIO6_ADDR = 0x30250000, | ||
63 | - FSL_IMX7_GPIO7_ADDR = 0x30260000, | ||
64 | + FSL_IMX7_QSPI1_MEM_ADDR = 0x60000000, | ||
65 | + FSL_IMX7_QSPI1_MEM_SIZE = (256 * MiB), | ||
66 | |||
67 | - FSL_IMX7_IOMUXC_LPSR_GPR_ADDR = 0x30270000, | ||
68 | + FSL_IMX7_PCIE1_MEM_ADDR = 0x40000000, | ||
69 | + FSL_IMX7_PCIE1_MEM_SIZE = (256 * MiB), | ||
70 | |||
71 | - FSL_IMX7_WDOG1_ADDR = 0x30280000, | ||
72 | - FSL_IMX7_WDOG2_ADDR = 0x30290000, | ||
73 | - FSL_IMX7_WDOG3_ADDR = 0x302A0000, | ||
74 | - FSL_IMX7_WDOG4_ADDR = 0x302B0000, | ||
75 | + FSL_IMX7_QSPI1_RX_BUF_ADDR = 0x34000000, | ||
76 | + FSL_IMX7_QSPI1_RX_BUF_SIZE = (32 * MiB), | ||
77 | |||
78 | - FSL_IMX7_IOMUXC_LPSR_ADDR = 0x302C0000, | ||
79 | + /* PCIe Peripherals */ | ||
80 | + FSL_IMX7_PCIE_REG_ADDR = 0x33800000, | ||
81 | |||
82 | - FSL_IMX7_GPT1_ADDR = 0x302D0000, | ||
83 | - FSL_IMX7_GPT2_ADDR = 0x302E0000, | ||
84 | - FSL_IMX7_GPT3_ADDR = 0x302F0000, | ||
85 | - FSL_IMX7_GPT4_ADDR = 0x30300000, | ||
86 | + /* MMAP Peripherals */ | ||
87 | + FSL_IMX7_DMA_APBH_ADDR = 0x33000000, | ||
88 | + FSL_IMX7_DMA_APBH_SIZE = 0x8000, | ||
89 | |||
90 | - FSL_IMX7_IOMUXC_ADDR = 0x30330000, | ||
91 | - FSL_IMX7_IOMUXC_GPR_ADDR = 0x30340000, | ||
92 | - FSL_IMX7_IOMUXCn_SIZE = 0x1000, | ||
93 | + /* GPV configuration */ | ||
94 | + FSL_IMX7_GPV6_ADDR = 0x32600000, | ||
95 | + FSL_IMX7_GPV5_ADDR = 0x32500000, | ||
96 | + FSL_IMX7_GPV4_ADDR = 0x32400000, | ||
97 | + FSL_IMX7_GPV3_ADDR = 0x32300000, | ||
98 | + FSL_IMX7_GPV2_ADDR = 0x32200000, | ||
99 | + FSL_IMX7_GPV1_ADDR = 0x32100000, | ||
100 | + FSL_IMX7_GPV0_ADDR = 0x32000000, | ||
101 | + FSL_IMX7_GPVn_SIZE = (1 * MiB), | ||
102 | |||
103 | - FSL_IMX7_OCOTP_ADDR = 0x30350000, | ||
104 | - FSL_IMX7_OCOTP_SIZE = 0x10000, | ||
105 | + /* Arm Peripherals */ | ||
106 | + FSL_IMX7_A7MPCORE_ADDR = 0x31000000, | ||
107 | |||
108 | - FSL_IMX7_ANALOG_ADDR = 0x30360000, | ||
109 | - FSL_IMX7_SNVS_ADDR = 0x30370000, | ||
110 | - FSL_IMX7_CCM_ADDR = 0x30380000, | ||
111 | + /* AIPS-3 Begin */ | ||
112 | |||
113 | - FSL_IMX7_SRC_ADDR = 0x30390000, | ||
114 | - FSL_IMX7_SRC_SIZE = 0x1000, | ||
115 | + FSL_IMX7_ENET2_ADDR = 0x30BF0000, | ||
116 | + FSL_IMX7_ENET1_ADDR = 0x30BE0000, | ||
117 | |||
118 | - FSL_IMX7_ADC1_ADDR = 0x30610000, | ||
119 | - FSL_IMX7_ADC2_ADDR = 0x30620000, | ||
120 | - FSL_IMX7_ADCn_SIZE = 0x1000, | ||
121 | + FSL_IMX7_SDMA_ADDR = 0x30BD0000, | ||
122 | + FSL_IMX7_SDMA_SIZE = (4 * KiB), | ||
123 | |||
124 | - FSL_IMX7_PWM1_ADDR = 0x30660000, | ||
125 | - FSL_IMX7_PWM2_ADDR = 0x30670000, | ||
126 | - FSL_IMX7_PWM3_ADDR = 0x30680000, | ||
127 | - FSL_IMX7_PWM4_ADDR = 0x30690000, | ||
128 | - FSL_IMX7_PWMn_SIZE = 0x10000, | ||
129 | + FSL_IMX7_EIM_ADDR = 0x30BC0000, | ||
130 | + FSL_IMX7_EIM_SIZE = (4 * KiB), | ||
131 | |||
132 | - FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000, | ||
133 | - FSL_IMX7_PCIE_PHY_SIZE = 0x10000, | ||
134 | + FSL_IMX7_QSPI_ADDR = 0x30BB0000, | ||
135 | + FSL_IMX7_QSPI_SIZE = 0x8000, | ||
136 | |||
137 | - FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
138 | + FSL_IMX7_SIM2_ADDR = 0x30BA0000, | ||
139 | + FSL_IMX7_SIM1_ADDR = 0x30B90000, | ||
140 | + FSL_IMX7_SIMn_SIZE = (4 * KiB), | ||
141 | + | ||
142 | + FSL_IMX7_USDHC3_ADDR = 0x30B60000, | ||
143 | + FSL_IMX7_USDHC2_ADDR = 0x30B50000, | ||
144 | + FSL_IMX7_USDHC1_ADDR = 0x30B40000, | ||
145 | + | ||
146 | + FSL_IMX7_USB3_ADDR = 0x30B30000, | ||
147 | + FSL_IMX7_USBMISC3_ADDR = 0x30B30200, | ||
148 | + FSL_IMX7_USB2_ADDR = 0x30B20000, | ||
149 | + FSL_IMX7_USBMISC2_ADDR = 0x30B20200, | ||
150 | + FSL_IMX7_USB1_ADDR = 0x30B10000, | ||
151 | + FSL_IMX7_USBMISC1_ADDR = 0x30B10200, | ||
152 | + FSL_IMX7_USBMISCn_SIZE = 0x200, | ||
153 | + | ||
154 | + FSL_IMX7_USB_PL301_ADDR = 0x30AD0000, | ||
155 | + FSL_IMX7_USB_PL301_SIZE = (64 * KiB), | ||
156 | + | ||
157 | + FSL_IMX7_SEMAPHORE_HS_ADDR = 0x30AC0000, | ||
158 | + FSL_IMX7_SEMAPHORE_HS_SIZE = (64 * KiB), | ||
159 | + | ||
160 | + FSL_IMX7_MUB_ADDR = 0x30AB0000, | ||
161 | + FSL_IMX7_MUA_ADDR = 0x30AA0000, | ||
162 | + FSL_IMX7_MUn_SIZE = (KiB), | ||
163 | + | ||
164 | + FSL_IMX7_UART7_ADDR = 0x30A90000, | ||
165 | + FSL_IMX7_UART6_ADDR = 0x30A80000, | ||
166 | + FSL_IMX7_UART5_ADDR = 0x30A70000, | ||
167 | + FSL_IMX7_UART4_ADDR = 0x30A60000, | ||
168 | + | ||
169 | + FSL_IMX7_I2C4_ADDR = 0x30A50000, | ||
170 | + FSL_IMX7_I2C3_ADDR = 0x30A40000, | ||
171 | + FSL_IMX7_I2C2_ADDR = 0x30A30000, | ||
172 | + FSL_IMX7_I2C1_ADDR = 0x30A20000, | ||
173 | + | ||
174 | + FSL_IMX7_CAN2_ADDR = 0x30A10000, | ||
175 | + FSL_IMX7_CAN1_ADDR = 0x30A00000, | ||
176 | + FSL_IMX7_CANn_SIZE = (4 * KiB), | ||
177 | + | ||
178 | + FSL_IMX7_AIPS3_CONF_ADDR = 0x309F0000, | ||
179 | + FSL_IMX7_AIPS3_CONF_SIZE = (64 * KiB), | ||
180 | |||
181 | FSL_IMX7_CAAM_ADDR = 0x30900000, | ||
182 | - FSL_IMX7_CAAM_SIZE = 0x40000, | ||
183 | + FSL_IMX7_CAAM_SIZE = (256 * KiB), | ||
184 | |||
185 | - FSL_IMX7_CAN1_ADDR = 0x30A00000, | ||
186 | - FSL_IMX7_CAN2_ADDR = 0x30A10000, | ||
187 | - FSL_IMX7_CANn_SIZE = 0x10000, | ||
188 | + FSL_IMX7_SPBA_ADDR = 0x308F0000, | ||
189 | + FSL_IMX7_SPBA_SIZE = (4 * KiB), | ||
190 | |||
191 | - FSL_IMX7_I2C1_ADDR = 0x30A20000, | ||
192 | - FSL_IMX7_I2C2_ADDR = 0x30A30000, | ||
193 | - FSL_IMX7_I2C3_ADDR = 0x30A40000, | ||
194 | - FSL_IMX7_I2C4_ADDR = 0x30A50000, | ||
195 | + FSL_IMX7_SAI3_ADDR = 0x308C0000, | ||
196 | + FSL_IMX7_SAI2_ADDR = 0x308B0000, | ||
197 | + FSL_IMX7_SAI1_ADDR = 0x308A0000, | ||
198 | + FSL_IMX7_SAIn_SIZE = (4 * KiB), | ||
199 | |||
200 | - FSL_IMX7_ECSPI1_ADDR = 0x30820000, | ||
201 | - FSL_IMX7_ECSPI2_ADDR = 0x30830000, | ||
202 | - FSL_IMX7_ECSPI3_ADDR = 0x30840000, | ||
203 | - FSL_IMX7_ECSPI4_ADDR = 0x30630000, | ||
204 | - | ||
205 | - FSL_IMX7_LCDIF_ADDR = 0x30730000, | ||
206 | - FSL_IMX7_LCDIF_SIZE = 0x1000, | ||
207 | - | ||
208 | - FSL_IMX7_UART1_ADDR = 0x30860000, | ||
209 | + FSL_IMX7_UART3_ADDR = 0x30880000, | ||
210 | /* | ||
211 | * Some versions of the reference manual claim that UART2 is @ | ||
212 | * 0x30870000, but experiments with HW + DT files in upstream | ||
213 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | ||
214 | * actually located @ 0x30890000 | ||
215 | */ | ||
216 | FSL_IMX7_UART2_ADDR = 0x30890000, | ||
217 | - FSL_IMX7_UART3_ADDR = 0x30880000, | ||
218 | - FSL_IMX7_UART4_ADDR = 0x30A60000, | ||
219 | - FSL_IMX7_UART5_ADDR = 0x30A70000, | ||
220 | - FSL_IMX7_UART6_ADDR = 0x30A80000, | ||
221 | - FSL_IMX7_UART7_ADDR = 0x30A90000, | ||
222 | + FSL_IMX7_UART1_ADDR = 0x30860000, | ||
223 | |||
224 | - FSL_IMX7_SAI1_ADDR = 0x308A0000, | ||
225 | - FSL_IMX7_SAI2_ADDR = 0x308B0000, | ||
226 | - FSL_IMX7_SAI3_ADDR = 0x308C0000, | ||
227 | - FSL_IMX7_SAIn_SIZE = 0x10000, | ||
228 | + FSL_IMX7_ECSPI3_ADDR = 0x30840000, | ||
229 | + FSL_IMX7_ECSPI2_ADDR = 0x30830000, | ||
230 | + FSL_IMX7_ECSPI1_ADDR = 0x30820000, | ||
231 | + FSL_IMX7_ECSPIn_SIZE = (4 * KiB), | ||
232 | |||
233 | - FSL_IMX7_ENET1_ADDR = 0x30BE0000, | ||
234 | - FSL_IMX7_ENET2_ADDR = 0x30BF0000, | ||
235 | + /* AIPS-3 End */ | ||
236 | |||
237 | - FSL_IMX7_USB1_ADDR = 0x30B10000, | ||
238 | - FSL_IMX7_USBMISC1_ADDR = 0x30B10200, | ||
239 | - FSL_IMX7_USB2_ADDR = 0x30B20000, | ||
240 | - FSL_IMX7_USBMISC2_ADDR = 0x30B20200, | ||
241 | - FSL_IMX7_USB3_ADDR = 0x30B30000, | ||
242 | - FSL_IMX7_USBMISC3_ADDR = 0x30B30200, | ||
243 | - FSL_IMX7_USBMISCn_SIZE = 0x200, | ||
244 | + /* AIPS-2 Begin */ | ||
245 | |||
246 | - FSL_IMX7_USDHC1_ADDR = 0x30B40000, | ||
247 | - FSL_IMX7_USDHC2_ADDR = 0x30B50000, | ||
248 | - FSL_IMX7_USDHC3_ADDR = 0x30B60000, | ||
249 | + FSL_IMX7_AXI_DEBUG_MON_ADDR = 0x307E0000, | ||
250 | + FSL_IMX7_AXI_DEBUG_MON_SIZE = (64 * KiB), | ||
251 | |||
252 | - FSL_IMX7_SDMA_ADDR = 0x30BD0000, | ||
253 | - FSL_IMX7_SDMA_SIZE = 0x1000, | ||
254 | + FSL_IMX7_PERFMON2_ADDR = 0x307D0000, | ||
255 | + FSL_IMX7_PERFMON1_ADDR = 0x307C0000, | ||
256 | + FSL_IMX7_PERFMONn_SIZE = (64 * KiB), | ||
257 | + | ||
258 | + FSL_IMX7_DDRC_ADDR = 0x307A0000, | ||
259 | + FSL_IMX7_DDRC_SIZE = (4 * KiB), | ||
260 | + | ||
261 | + FSL_IMX7_DDRC_PHY_ADDR = 0x30790000, | ||
262 | + FSL_IMX7_DDRC_PHY_SIZE = (4 * KiB), | ||
263 | + | ||
264 | + FSL_IMX7_TZASC_ADDR = 0x30780000, | ||
265 | + FSL_IMX7_TZASC_SIZE = (64 * KiB), | ||
266 | + | ||
267 | + FSL_IMX7_MIPI_DSI_ADDR = 0x30760000, | ||
268 | + FSL_IMX7_MIPI_DSI_SIZE = (4 * KiB), | ||
269 | + | ||
270 | + FSL_IMX7_MIPI_CSI_ADDR = 0x30750000, | ||
271 | + FSL_IMX7_MIPI_CSI_SIZE = 0x4000, | ||
272 | + | ||
273 | + FSL_IMX7_LCDIF_ADDR = 0x30730000, | ||
274 | + FSL_IMX7_LCDIF_SIZE = 0x8000, | ||
275 | + | ||
276 | + FSL_IMX7_CSI_ADDR = 0x30710000, | ||
277 | + FSL_IMX7_CSI_SIZE = (4 * KiB), | ||
278 | + | ||
279 | + FSL_IMX7_PXP_ADDR = 0x30700000, | ||
280 | + FSL_IMX7_PXP_SIZE = 0x4000, | ||
281 | + | ||
282 | + FSL_IMX7_EPDC_ADDR = 0x306F0000, | ||
283 | + FSL_IMX7_EPDC_SIZE = (4 * KiB), | ||
284 | + | ||
285 | + FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000, | ||
286 | + FSL_IMX7_PCIE_PHY_SIZE = (4 * KiB), | ||
287 | + | ||
288 | + FSL_IMX7_SYSCNT_CTRL_ADDR = 0x306C0000, | ||
289 | + FSL_IMX7_SYSCNT_CMP_ADDR = 0x306B0000, | ||
290 | + FSL_IMX7_SYSCNT_RD_ADDR = 0x306A0000, | ||
291 | + | ||
292 | + FSL_IMX7_PWM4_ADDR = 0x30690000, | ||
293 | + FSL_IMX7_PWM3_ADDR = 0x30680000, | ||
294 | + FSL_IMX7_PWM2_ADDR = 0x30670000, | ||
295 | + FSL_IMX7_PWM1_ADDR = 0x30660000, | ||
296 | + FSL_IMX7_PWMn_SIZE = (4 * KiB), | ||
297 | + | ||
298 | + FSL_IMX7_FlEXTIMER2_ADDR = 0x30650000, | ||
299 | + FSL_IMX7_FlEXTIMER1_ADDR = 0x30640000, | ||
300 | + FSL_IMX7_FLEXTIMERn_SIZE = (4 * KiB), | ||
301 | + | ||
302 | + FSL_IMX7_ECSPI4_ADDR = 0x30630000, | ||
303 | + | ||
304 | + FSL_IMX7_ADC2_ADDR = 0x30620000, | ||
305 | + FSL_IMX7_ADC1_ADDR = 0x30610000, | ||
306 | + FSL_IMX7_ADCn_SIZE = (4 * KiB), | ||
307 | + | ||
308 | + FSL_IMX7_AIPS2_CONF_ADDR = 0x305F0000, | ||
309 | + FSL_IMX7_AIPS2_CONF_SIZE = (64 * KiB), | ||
310 | + | ||
311 | + /* AIPS-2 End */ | ||
312 | + | ||
313 | + /* AIPS-1 Begin */ | ||
314 | + | ||
315 | + FSL_IMX7_CSU_ADDR = 0x303E0000, | ||
316 | + FSL_IMX7_CSU_SIZE = (64 * KiB), | ||
317 | + | ||
318 | + FSL_IMX7_RDC_ADDR = 0x303D0000, | ||
319 | + FSL_IMX7_RDC_SIZE = (4 * KiB), | ||
320 | + | ||
321 | + FSL_IMX7_SEMAPHORE2_ADDR = 0x303C0000, | ||
322 | + FSL_IMX7_SEMAPHORE1_ADDR = 0x303B0000, | ||
323 | + FSL_IMX7_SEMAPHOREn_SIZE = (4 * KiB), | ||
324 | + | ||
325 | + FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
326 | + | ||
327 | + FSL_IMX7_SRC_ADDR = 0x30390000, | ||
328 | + FSL_IMX7_SRC_SIZE = (4 * KiB), | ||
329 | + | ||
330 | + FSL_IMX7_CCM_ADDR = 0x30380000, | ||
331 | + | ||
332 | + FSL_IMX7_SNVS_HP_ADDR = 0x30370000, | ||
333 | + | ||
334 | + FSL_IMX7_ANALOG_ADDR = 0x30360000, | ||
335 | + | ||
336 | + FSL_IMX7_OCOTP_ADDR = 0x30350000, | ||
337 | + FSL_IMX7_OCOTP_SIZE = 0x10000, | ||
338 | + | ||
339 | + FSL_IMX7_IOMUXC_GPR_ADDR = 0x30340000, | ||
340 | + FSL_IMX7_IOMUXC_GPR_SIZE = (4 * KiB), | ||
341 | + | ||
342 | + FSL_IMX7_IOMUXC_ADDR = 0x30330000, | ||
343 | + FSL_IMX7_IOMUXC_SIZE = (4 * KiB), | ||
344 | + | ||
345 | + FSL_IMX7_KPP_ADDR = 0x30320000, | ||
346 | + FSL_IMX7_KPP_SIZE = (4 * KiB), | ||
347 | + | ||
348 | + FSL_IMX7_ROMCP_ADDR = 0x30310000, | ||
349 | + FSL_IMX7_ROMCP_SIZE = (4 * KiB), | ||
350 | + | ||
351 | + FSL_IMX7_GPT4_ADDR = 0x30300000, | ||
352 | + FSL_IMX7_GPT3_ADDR = 0x302F0000, | ||
353 | + FSL_IMX7_GPT2_ADDR = 0x302E0000, | ||
354 | + FSL_IMX7_GPT1_ADDR = 0x302D0000, | ||
355 | + | ||
356 | + FSL_IMX7_IOMUXC_LPSR_ADDR = 0x302C0000, | ||
357 | + FSL_IMX7_IOMUXC_LPSR_SIZE = (4 * KiB), | ||
358 | + | ||
359 | + FSL_IMX7_WDOG4_ADDR = 0x302B0000, | ||
360 | + FSL_IMX7_WDOG3_ADDR = 0x302A0000, | ||
361 | + FSL_IMX7_WDOG2_ADDR = 0x30290000, | ||
362 | + FSL_IMX7_WDOG1_ADDR = 0x30280000, | ||
363 | + | ||
364 | + FSL_IMX7_IOMUXC_LPSR_GPR_ADDR = 0x30270000, | ||
365 | + | ||
366 | + FSL_IMX7_GPIO7_ADDR = 0x30260000, | ||
367 | + FSL_IMX7_GPIO6_ADDR = 0x30250000, | ||
368 | + FSL_IMX7_GPIO5_ADDR = 0x30240000, | ||
369 | + FSL_IMX7_GPIO4_ADDR = 0x30230000, | ||
370 | + FSL_IMX7_GPIO3_ADDR = 0x30220000, | ||
371 | + FSL_IMX7_GPIO2_ADDR = 0x30210000, | ||
372 | + FSL_IMX7_GPIO1_ADDR = 0x30200000, | ||
373 | + | ||
374 | + FSL_IMX7_AIPS1_CONF_ADDR = 0x301F0000, | ||
375 | + FSL_IMX7_AIPS1_CONF_SIZE = (64 * KiB), | ||
376 | |||
377 | - FSL_IMX7_A7MPCORE_ADDR = 0x31000000, | ||
378 | FSL_IMX7_A7MPCORE_DAP_ADDR = 0x30000000, | ||
379 | + FSL_IMX7_A7MPCORE_DAP_SIZE = (1 * MiB), | ||
380 | |||
381 | - FSL_IMX7_PCIE_REG_ADDR = 0x33800000, | ||
382 | - FSL_IMX7_PCIE_REG_SIZE = 16 * 1024, | ||
383 | + /* AIPS-1 End */ | ||
384 | |||
385 | - FSL_IMX7_GPR_ADDR = 0x30340000, | ||
386 | + FSL_IMX7_EIM_CS0_ADDR = 0x28000000, | ||
387 | + FSL_IMX7_EIM_CS0_SIZE = (128 * MiB), | ||
388 | |||
389 | - FSL_IMX7_DMA_APBH_ADDR = 0x33000000, | ||
390 | - FSL_IMX7_DMA_APBH_SIZE = 0x2000, | ||
391 | + FSL_IMX7_OCRAM_PXP_ADDR = 0x00940000, | ||
392 | + FSL_IMX7_OCRAM_PXP_SIZE = (32 * KiB), | ||
393 | + | ||
394 | + FSL_IMX7_OCRAM_EPDC_ADDR = 0x00920000, | ||
395 | + FSL_IMX7_OCRAM_EPDC_SIZE = (128 * KiB), | ||
396 | + | ||
397 | + FSL_IMX7_OCRAM_MEM_ADDR = 0x00900000, | ||
398 | + FSL_IMX7_OCRAM_MEM_SIZE = (128 * KiB), | ||
399 | + | ||
400 | + FSL_IMX7_TCMU_ADDR = 0x00800000, | ||
401 | + FSL_IMX7_TCMU_SIZE = (32 * KiB), | ||
402 | + | ||
403 | + FSL_IMX7_TCML_ADDR = 0x007F8000, | ||
404 | + FSL_IMX7_TCML_SIZE = (32 * KiB), | ||
405 | + | ||
406 | + FSL_IMX7_OCRAM_S_ADDR = 0x00180000, | ||
407 | + FSL_IMX7_OCRAM_S_SIZE = (32 * KiB), | ||
408 | + | ||
409 | + FSL_IMX7_CAAM_MEM_ADDR = 0x00100000, | ||
410 | + FSL_IMX7_CAAM_MEM_SIZE = (32 * KiB), | ||
411 | + | ||
412 | + FSL_IMX7_ROM_ADDR = 0x00000000, | ||
413 | + FSL_IMX7_ROM_SIZE = (96 * KiB), | ||
414 | }; | ||
415 | |||
416 | enum FslIMX7IRQs { | ||
417 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | 418 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/hw/core/machine.c | 419 | --- a/hw/arm/fsl-imx7.c |
51 | +++ b/hw/core/machine.c | 420 | +++ b/hw/arm/fsl-imx7.c |
52 | @@ -XXX,XX +XXX,XX @@ | 421 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) |
53 | #include "hw/virtio/virtio.h" | 422 | char name[NAME_SIZE]; |
54 | #include "hw/virtio/virtio-pci.h" | ||
55 | |||
56 | -GlobalProperty hw_compat_6_0[] = {}; | ||
57 | +GlobalProperty hw_compat_6_0[] = { | ||
58 | + { "gpex-pcihost", "allow-unmapped-accesses", "false" }, | ||
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 | ||
65 | --- a/hw/pci-host/gpex.c | ||
66 | +++ b/hw/pci-host/gpex.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static void gpex_host_realize(DeviceState *dev, Error **errp) | ||
68 | int i; | 423 | int i; |
69 | 424 | ||
70 | pcie_host_mmcfg_init(pex, PCIE_MMCFG_SIZE_MAX); | 425 | + /* |
71 | + sysbus_init_mmio(sbd, &pex->mmio); | 426 | + * CPUs |
72 | + | 427 | + */ |
73 | + /* | 428 | for (i = 0; i < MIN(ms->smp.cpus, FSL_IMX7_NUM_CPUS); i++) { |
74 | + * Note that the MemoryRegions io_mmio and io_ioport that we pass | 429 | snprintf(name, NAME_SIZE, "cpu%d", i); |
75 | + * to pci_register_root_bus() are not the same as the | 430 | object_initialize_child(obj, name, &s->cpu[i], |
76 | + * MemoryRegions io_mmio_window and io_ioport_window that we | 431 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) |
77 | + * expose as SysBus MRs. The difference is in the behaviour of | 432 | TYPE_A15MPCORE_PRIV); |
78 | + * accesses to addresses where no PCI device has been mapped. | 433 | |
79 | + * | 434 | /* |
80 | + * io_mmio and io_ioport are the underlying PCI view of the PCI | 435 | - * GPIOs 1 to 7 |
81 | + * address space, and when a PCI device does a bus master access | 436 | + * GPIOs |
82 | + * to a bad address this is reported back to it as a transaction | 437 | */ |
83 | + * failure. | 438 | for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) { |
84 | + * | 439 | snprintf(name, NAME_SIZE, "gpio%d", i); |
85 | + * io_mmio_window and io_ioport_window implement "unmapped | 440 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) |
86 | + * addresses read as -1 and ignore writes"; this is traditional | 441 | } |
87 | + * x86 PC behaviour, which is not mandated by the PCI spec proper | 442 | |
88 | + * but expected by much PCI-using guest software, including Linux. | 443 | /* |
89 | + * | 444 | - * GPT1, 2, 3, 4 |
90 | + * In the interests of not being unnecessarily surprising, we | 445 | + * GPTs |
91 | + * implement it in the gpex PCI host controller, by providing the | 446 | */ |
92 | + * _window MRs, which are containers with io ops that implement | 447 | for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) { |
93 | + * the 'background' behaviour and which hold the real PCI MRs as | 448 | snprintf(name, NAME_SIZE, "gpt%d", i); |
94 | + * subregions. | 449 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) |
95 | + */ | 450 | */ |
96 | memory_region_init(&s->io_mmio, OBJECT(s), "gpex_mmio", UINT64_MAX); | 451 | object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2); |
97 | memory_region_init(&s->io_ioport, OBJECT(s), "gpex_ioport", 64 * 1024); | 452 | |
98 | 453 | + /* | |
99 | - sysbus_init_mmio(sbd, &pex->mmio); | 454 | + * ECSPIs |
100 | - sysbus_init_mmio(sbd, &s->io_mmio); | 455 | + */ |
101 | - sysbus_init_mmio(sbd, &s->io_ioport); | 456 | for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) { |
102 | + if (s->allow_unmapped_accesses) { | 457 | snprintf(name, NAME_SIZE, "spi%d", i + 1); |
103 | + memory_region_init_io(&s->io_mmio_window, OBJECT(s), | 458 | object_initialize_child(obj, name, &s->spi[i], TYPE_IMX_SPI); |
104 | + &unassigned_io_ops, OBJECT(s), | 459 | } |
105 | + "gpex_mmio_window", UINT64_MAX); | 460 | |
106 | + memory_region_init_io(&s->io_ioport_window, OBJECT(s), | 461 | - |
107 | + &unassigned_io_ops, OBJECT(s), | 462 | + /* |
108 | + "gpex_ioport_window", 64 * 1024); | 463 | + * I2Cs |
109 | + | 464 | + */ |
110 | + memory_region_add_subregion(&s->io_mmio_window, 0, &s->io_mmio); | 465 | for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) { |
111 | + memory_region_add_subregion(&s->io_ioport_window, 0, &s->io_ioport); | 466 | snprintf(name, NAME_SIZE, "i2c%d", i + 1); |
112 | + sysbus_init_mmio(sbd, &s->io_mmio_window); | 467 | object_initialize_child(obj, name, &s->i2c[i], TYPE_IMX_I2C); |
113 | + sysbus_init_mmio(sbd, &s->io_ioport_window); | 468 | } |
114 | + } else { | 469 | |
115 | + sysbus_init_mmio(sbd, &s->io_mmio); | 470 | /* |
116 | + sysbus_init_mmio(sbd, &s->io_ioport); | 471 | - * UART |
472 | + * UARTs | ||
473 | */ | ||
474 | for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) { | ||
475 | snprintf(name, NAME_SIZE, "uart%d", i); | ||
476 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
477 | } | ||
478 | |||
479 | /* | ||
480 | - * Ethernet | ||
481 | + * Ethernets | ||
482 | */ | ||
483 | for (i = 0; i < FSL_IMX7_NUM_ETHS; i++) { | ||
484 | snprintf(name, NAME_SIZE, "eth%d", i); | ||
485 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
486 | } | ||
487 | |||
488 | /* | ||
489 | - * SDHCI | ||
490 | + * SDHCIs | ||
491 | */ | ||
492 | for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) { | ||
493 | snprintf(name, NAME_SIZE, "usdhc%d", i); | ||
494 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
495 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); | ||
496 | |||
497 | /* | ||
498 | - * Watchdog | ||
499 | + * Watchdogs | ||
500 | */ | ||
501 | for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) { | ||
502 | snprintf(name, NAME_SIZE, "wdt%d", i); | ||
503 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
504 | */ | ||
505 | object_initialize_child(obj, "gpr", &s->gpr, TYPE_IMX7_GPR); | ||
506 | |||
507 | + /* | ||
508 | + * PCIE | ||
509 | + */ | ||
510 | object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HOST); | ||
511 | |||
512 | + /* | ||
513 | + * USBs | ||
514 | + */ | ||
515 | for (i = 0; i < FSL_IMX7_NUM_USBS; i++) { | ||
516 | snprintf(name, NAME_SIZE, "usb%d", i); | ||
517 | object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA); | ||
518 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
519 | return; | ||
520 | } | ||
521 | |||
522 | + /* | ||
523 | + * CPUs | ||
524 | + */ | ||
525 | for (i = 0; i < smp_cpus; i++) { | ||
526 | o = OBJECT(&s->cpu[i]); | ||
527 | |||
528 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
529 | * A7MPCORE DAP | ||
530 | */ | ||
531 | create_unimplemented_device("a7mpcore-dap", FSL_IMX7_A7MPCORE_DAP_ADDR, | ||
532 | - 0x100000); | ||
533 | + FSL_IMX7_A7MPCORE_DAP_SIZE); | ||
534 | |||
535 | /* | ||
536 | - * GPT1, 2, 3, 4 | ||
537 | + * GPTs | ||
538 | */ | ||
539 | for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) { | ||
540 | static const hwaddr FSL_IMX7_GPTn_ADDR[FSL_IMX7_NUM_GPTS] = { | ||
541 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
542 | FSL_IMX7_GPTn_IRQ[i])); | ||
543 | } | ||
544 | |||
545 | + /* | ||
546 | + * GPIOs | ||
547 | + */ | ||
548 | for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) { | ||
549 | static const hwaddr FSL_IMX7_GPIOn_ADDR[FSL_IMX7_NUM_GPIOS] = { | ||
550 | FSL_IMX7_GPIO1_ADDR, | ||
551 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
552 | /* | ||
553 | * IOMUXC and IOMUXC_LPSR | ||
554 | */ | ||
555 | - for (i = 0; i < FSL_IMX7_NUM_IOMUXCS; i++) { | ||
556 | - static const hwaddr FSL_IMX7_IOMUXCn_ADDR[FSL_IMX7_NUM_IOMUXCS] = { | ||
557 | - FSL_IMX7_IOMUXC_ADDR, | ||
558 | - FSL_IMX7_IOMUXC_LPSR_ADDR, | ||
559 | - }; | ||
560 | - | ||
561 | - snprintf(name, NAME_SIZE, "iomuxc%d", i); | ||
562 | - create_unimplemented_device(name, FSL_IMX7_IOMUXCn_ADDR[i], | ||
563 | - FSL_IMX7_IOMUXCn_SIZE); | ||
564 | - } | ||
565 | + create_unimplemented_device("iomuxc", FSL_IMX7_IOMUXC_ADDR, | ||
566 | + FSL_IMX7_IOMUXC_SIZE); | ||
567 | + create_unimplemented_device("iomuxc_lspr", FSL_IMX7_IOMUXC_LPSR_ADDR, | ||
568 | + FSL_IMX7_IOMUXC_LPSR_SIZE); | ||
569 | |||
570 | /* | ||
571 | * CCM | ||
572 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
573 | sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort); | ||
574 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX7_GPC_ADDR); | ||
575 | |||
576 | - /* Initialize all ECSPI */ | ||
577 | + /* | ||
578 | + * ECSPIs | ||
579 | + */ | ||
580 | for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) { | ||
581 | static const hwaddr FSL_IMX7_SPIn_ADDR[FSL_IMX7_NUM_ECSPIS] = { | ||
582 | FSL_IMX7_ECSPI1_ADDR, | ||
583 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
584 | FSL_IMX7_SPIn_IRQ[i])); | ||
585 | } | ||
586 | |||
587 | + /* | ||
588 | + * I2Cs | ||
589 | + */ | ||
590 | for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) { | ||
591 | static const hwaddr FSL_IMX7_I2Cn_ADDR[FSL_IMX7_NUM_I2CS] = { | ||
592 | FSL_IMX7_I2C1_ADDR, | ||
593 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
594 | } | ||
595 | |||
596 | /* | ||
597 | - * UART | ||
598 | + * UARTs | ||
599 | */ | ||
600 | for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) { | ||
601 | static const hwaddr FSL_IMX7_UARTn_ADDR[FSL_IMX7_NUM_UARTS] = { | ||
602 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
603 | } | ||
604 | |||
605 | /* | ||
606 | - * Ethernet | ||
607 | + * Ethernets | ||
608 | * | ||
609 | * We must use two loops since phy_connected affects the other interface | ||
610 | * and we have to set all properties before calling sysbus_realize(). | ||
611 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
612 | } | ||
613 | |||
614 | /* | ||
615 | - * USDHC | ||
616 | + * USDHCs | ||
617 | */ | ||
618 | for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) { | ||
619 | static const hwaddr FSL_IMX7_USDHCn_ADDR[FSL_IMX7_NUM_USDHCS] = { | ||
620 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
621 | * SNVS | ||
622 | */ | ||
623 | sysbus_realize(SYS_BUS_DEVICE(&s->snvs), &error_abort); | ||
624 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX7_SNVS_ADDR); | ||
625 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX7_SNVS_HP_ADDR); | ||
626 | |||
627 | /* | ||
628 | * SRC | ||
629 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
630 | create_unimplemented_device("src", FSL_IMX7_SRC_ADDR, FSL_IMX7_SRC_SIZE); | ||
631 | |||
632 | /* | ||
633 | - * Watchdog | ||
634 | + * Watchdogs | ||
635 | */ | ||
636 | for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) { | ||
637 | static const hwaddr FSL_IMX7_WDOGn_ADDR[FSL_IMX7_NUM_WDTS] = { | ||
638 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
639 | create_unimplemented_device("caam", FSL_IMX7_CAAM_ADDR, FSL_IMX7_CAAM_SIZE); | ||
640 | |||
641 | /* | ||
642 | - * PWM | ||
643 | + * PWMs | ||
644 | */ | ||
645 | - create_unimplemented_device("pwm1", FSL_IMX7_PWM1_ADDR, FSL_IMX7_PWMn_SIZE); | ||
646 | - create_unimplemented_device("pwm2", FSL_IMX7_PWM2_ADDR, FSL_IMX7_PWMn_SIZE); | ||
647 | - create_unimplemented_device("pwm3", FSL_IMX7_PWM3_ADDR, FSL_IMX7_PWMn_SIZE); | ||
648 | - create_unimplemented_device("pwm4", FSL_IMX7_PWM4_ADDR, FSL_IMX7_PWMn_SIZE); | ||
649 | + for (i = 0; i < FSL_IMX7_NUM_PWMS; i++) { | ||
650 | + static const hwaddr FSL_IMX7_PWMn_ADDR[FSL_IMX7_NUM_PWMS] = { | ||
651 | + FSL_IMX7_PWM1_ADDR, | ||
652 | + FSL_IMX7_PWM2_ADDR, | ||
653 | + FSL_IMX7_PWM3_ADDR, | ||
654 | + FSL_IMX7_PWM4_ADDR, | ||
655 | + }; | ||
656 | + | ||
657 | + snprintf(name, NAME_SIZE, "pwm%d", i); | ||
658 | + create_unimplemented_device(name, FSL_IMX7_PWMn_ADDR[i], | ||
659 | + FSL_IMX7_PWMn_SIZE); | ||
117 | + } | 660 | + } |
118 | + | 661 | |
119 | for (i = 0; i < GPEX_NUM_IRQS; i++) { | 662 | /* |
120 | sysbus_init_irq(sbd, &s->irq[i]); | 663 | - * CAN |
121 | s->irq_num[i] = -1; | 664 | + * CANs |
122 | @@ -XXX,XX +XXX,XX @@ static const char *gpex_host_root_bus_path(PCIHostState *host_bridge, | 665 | */ |
123 | return "0000:00"; | 666 | - create_unimplemented_device("can1", FSL_IMX7_CAN1_ADDR, FSL_IMX7_CANn_SIZE); |
667 | - create_unimplemented_device("can2", FSL_IMX7_CAN2_ADDR, FSL_IMX7_CANn_SIZE); | ||
668 | + for (i = 0; i < FSL_IMX7_NUM_CANS; i++) { | ||
669 | + static const hwaddr FSL_IMX7_CANn_ADDR[FSL_IMX7_NUM_CANS] = { | ||
670 | + FSL_IMX7_CAN1_ADDR, | ||
671 | + FSL_IMX7_CAN2_ADDR, | ||
672 | + }; | ||
673 | + | ||
674 | + snprintf(name, NAME_SIZE, "can%d", i); | ||
675 | + create_unimplemented_device(name, FSL_IMX7_CANn_ADDR[i], | ||
676 | + FSL_IMX7_CANn_SIZE); | ||
677 | + } | ||
678 | |||
679 | /* | ||
680 | - * SAI (Audio SSI (Synchronous Serial Interface)) | ||
681 | + * SAIs (Audio SSI (Synchronous Serial Interface)) | ||
682 | */ | ||
683 | - create_unimplemented_device("sai1", FSL_IMX7_SAI1_ADDR, FSL_IMX7_SAIn_SIZE); | ||
684 | - create_unimplemented_device("sai2", FSL_IMX7_SAI2_ADDR, FSL_IMX7_SAIn_SIZE); | ||
685 | - create_unimplemented_device("sai2", FSL_IMX7_SAI3_ADDR, FSL_IMX7_SAIn_SIZE); | ||
686 | + for (i = 0; i < FSL_IMX7_NUM_SAIS; i++) { | ||
687 | + static const hwaddr FSL_IMX7_SAIn_ADDR[FSL_IMX7_NUM_SAIS] = { | ||
688 | + FSL_IMX7_SAI1_ADDR, | ||
689 | + FSL_IMX7_SAI2_ADDR, | ||
690 | + FSL_IMX7_SAI3_ADDR, | ||
691 | + }; | ||
692 | + | ||
693 | + snprintf(name, NAME_SIZE, "sai%d", i); | ||
694 | + create_unimplemented_device(name, FSL_IMX7_SAIn_ADDR[i], | ||
695 | + FSL_IMX7_SAIn_SIZE); | ||
696 | + } | ||
697 | |||
698 | /* | ||
699 | * OCOTP | ||
700 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
701 | create_unimplemented_device("ocotp", FSL_IMX7_OCOTP_ADDR, | ||
702 | FSL_IMX7_OCOTP_SIZE); | ||
703 | |||
704 | + /* | ||
705 | + * GPR | ||
706 | + */ | ||
707 | sysbus_realize(SYS_BUS_DEVICE(&s->gpr), &error_abort); | ||
708 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX7_GPR_ADDR); | ||
709 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX7_IOMUXC_GPR_ADDR); | ||
710 | |||
711 | + /* | ||
712 | + * PCIE | ||
713 | + */ | ||
714 | sysbus_realize(SYS_BUS_DEVICE(&s->pcie), &error_abort); | ||
715 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcie), 0, FSL_IMX7_PCIE_REG_ADDR); | ||
716 | |||
717 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
718 | irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTD_IRQ); | ||
719 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 3, irq); | ||
720 | |||
721 | - | ||
722 | + /* | ||
723 | + * USBs | ||
724 | + */ | ||
725 | for (i = 0; i < FSL_IMX7_NUM_USBS; i++) { | ||
726 | static const hwaddr FSL_IMX7_USBMISCn_ADDR[FSL_IMX7_NUM_USBS] = { | ||
727 | FSL_IMX7_USBMISC1_ADDR, | ||
728 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
729 | */ | ||
730 | create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR, | ||
731 | FSL_IMX7_PCIE_PHY_SIZE); | ||
732 | + | ||
124 | } | 733 | } |
125 | 734 | ||
126 | +static Property gpex_host_properties[] = { | 735 | static Property fsl_imx7_properties[] = { |
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 | -- | 736 | -- |
148 | 2.20.1 | 737 | 2.34.1 |
149 | |||
150 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | In the case of gpr load, merge the size and is_signed arguments; | 3 | * Add TZASC as unimplemented device. |
4 | otherwise, simply convert size to memop. | 4 | - Allow bare metal application to access this (unimplemented) device |
5 | * Add CSU as unimplemented device. | ||
6 | - Allow bare metal application to access this (unimplemented) device | ||
7 | * Add various memory segments | ||
8 | - OCRAM | ||
9 | - OCRAM EPDC | ||
10 | - OCRAM PXP | ||
11 | - OCRAM S | ||
12 | - ROM | ||
13 | - CAAM | ||
5 | 14 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Message-id: 20210419202257.161730-26-richard.henderson@linaro.org | 17 | Message-id: f887a3483996ba06d40bd62ffdfb0ecf68621987.1692964892.git.jcd@tribudubois.net |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 19 | --- |
11 | target/arm/translate-a64.c | 78 ++++++++++++++++---------------------- | 20 | include/hw/arm/fsl-imx7.h | 7 +++++ |
12 | 1 file changed, 33 insertions(+), 45 deletions(-) | 21 | hw/arm/fsl-imx7.c | 63 +++++++++++++++++++++++++++++++++++++++ |
22 | 2 files changed, 70 insertions(+) | ||
13 | 23 | ||
14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 24 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
15 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-a64.c | 26 | --- a/include/hw/arm/fsl-imx7.h |
17 | +++ b/target/arm/translate-a64.c | 27 | +++ b/include/hw/arm/fsl-imx7.h |
18 | @@ -XXX,XX +XXX,XX @@ static void gen_adc_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) | 28 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { |
19 | * Store from GPR register to memory. | 29 | IMX7GPRState gpr; |
20 | */ | 30 | ChipideaState usb[FSL_IMX7_NUM_USBS]; |
21 | static void do_gpr_st_memidx(DisasContext *s, TCGv_i64 source, | 31 | DesignwarePCIEHost pcie; |
22 | - TCGv_i64 tcg_addr, int size, int memidx, | 32 | + MemoryRegion rom; |
23 | + TCGv_i64 tcg_addr, MemOp memop, int memidx, | 33 | + MemoryRegion caam; |
24 | bool iss_valid, | 34 | + MemoryRegion ocram; |
25 | unsigned int iss_srt, | 35 | + MemoryRegion ocram_epdc; |
26 | bool iss_sf, bool iss_ar) | 36 | + MemoryRegion ocram_pxp; |
27 | { | 37 | + MemoryRegion ocram_s; |
28 | - g_assert(size <= 3); | 38 | + |
29 | - tcg_gen_qemu_st_i64(source, tcg_addr, memidx, s->be_data + size); | 39 | uint32_t phy_num[FSL_IMX7_NUM_ETHS]; |
30 | + memop = finalize_memop(s, memop); | 40 | bool phy_connected[FSL_IMX7_NUM_ETHS]; |
31 | + tcg_gen_qemu_st_i64(source, tcg_addr, memidx, memop); | 41 | }; |
32 | 42 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | |
33 | if (iss_valid) { | 43 | index XXXXXXX..XXXXXXX 100644 |
34 | uint32_t syn; | 44 | --- a/hw/arm/fsl-imx7.c |
35 | 45 | +++ b/hw/arm/fsl-imx7.c | |
36 | syn = syn_data_abort_with_iss(0, | 46 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
37 | - size, | 47 | create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR, |
38 | + (memop & MO_SIZE), | 48 | FSL_IMX7_PCIE_PHY_SIZE); |
39 | false, | 49 | |
40 | iss_srt, | 50 | + /* |
41 | iss_sf, | 51 | + * CSU |
42 | @@ -XXX,XX +XXX,XX @@ static void do_gpr_st_memidx(DisasContext *s, TCGv_i64 source, | 52 | + */ |
53 | + create_unimplemented_device("csu", FSL_IMX7_CSU_ADDR, | ||
54 | + FSL_IMX7_CSU_SIZE); | ||
55 | + | ||
56 | + /* | ||
57 | + * TZASC | ||
58 | + */ | ||
59 | + create_unimplemented_device("tzasc", FSL_IMX7_TZASC_ADDR, | ||
60 | + FSL_IMX7_TZASC_SIZE); | ||
61 | + | ||
62 | + /* | ||
63 | + * OCRAM memory | ||
64 | + */ | ||
65 | + memory_region_init_ram(&s->ocram, NULL, "imx7.ocram", | ||
66 | + FSL_IMX7_OCRAM_MEM_SIZE, | ||
67 | + &error_abort); | ||
68 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_MEM_ADDR, | ||
69 | + &s->ocram); | ||
70 | + | ||
71 | + /* | ||
72 | + * OCRAM EPDC memory | ||
73 | + */ | ||
74 | + memory_region_init_ram(&s->ocram_epdc, NULL, "imx7.ocram_epdc", | ||
75 | + FSL_IMX7_OCRAM_EPDC_SIZE, | ||
76 | + &error_abort); | ||
77 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_EPDC_ADDR, | ||
78 | + &s->ocram_epdc); | ||
79 | + | ||
80 | + /* | ||
81 | + * OCRAM PXP memory | ||
82 | + */ | ||
83 | + memory_region_init_ram(&s->ocram_pxp, NULL, "imx7.ocram_pxp", | ||
84 | + FSL_IMX7_OCRAM_PXP_SIZE, | ||
85 | + &error_abort); | ||
86 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_PXP_ADDR, | ||
87 | + &s->ocram_pxp); | ||
88 | + | ||
89 | + /* | ||
90 | + * OCRAM_S memory | ||
91 | + */ | ||
92 | + memory_region_init_ram(&s->ocram_s, NULL, "imx7.ocram_s", | ||
93 | + FSL_IMX7_OCRAM_S_SIZE, | ||
94 | + &error_abort); | ||
95 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_S_ADDR, | ||
96 | + &s->ocram_s); | ||
97 | + | ||
98 | + /* | ||
99 | + * ROM memory | ||
100 | + */ | ||
101 | + memory_region_init_rom(&s->rom, OBJECT(dev), "imx7.rom", | ||
102 | + FSL_IMX7_ROM_SIZE, &error_abort); | ||
103 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_ROM_ADDR, | ||
104 | + &s->rom); | ||
105 | + | ||
106 | + /* | ||
107 | + * CAAM memory | ||
108 | + */ | ||
109 | + memory_region_init_rom(&s->caam, OBJECT(dev), "imx7.caam", | ||
110 | + FSL_IMX7_CAAM_MEM_SIZE, &error_abort); | ||
111 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_CAAM_MEM_ADDR, | ||
112 | + &s->caam); | ||
43 | } | 113 | } |
44 | 114 | ||
45 | static void do_gpr_st(DisasContext *s, TCGv_i64 source, | 115 | static Property fsl_imx7_properties[] = { |
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 | } | ||
100 | } | ||
101 | |||
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 | -- | 116 | -- |
216 | 2.20.1 | 117 | 2.34.1 |
217 | 118 | ||
218 | 119 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Buglink: https://bugs.launchpad.net/bugs/1921948 | 3 | The SRC device is normally used to start the secondary CPU. |
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 4 | |
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | When running Linux directly, QEMU is emulating a PSCI interface that UBOOT |
6 | Message-id: 20210416183106.1516563-5-richard.henderson@linaro.org | 6 | is installing at boot time and therefore the fact that the SRC device is |
7 | unimplemented is hidden as Qemu respond directly to PSCI requets without | ||
8 | using the SRC device. | ||
9 | |||
10 | But if you try to run a more bare metal application (maybe uboot itself), | ||
11 | then it is not possible to start the secondary CPU as the SRC is an | ||
12 | unimplemented device. | ||
13 | |||
14 | This patch adds the ability to start the secondary CPU through the SRC | ||
15 | device so that you can use this feature in bare metal applications. | ||
16 | |||
17 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Message-id: ce9a0162defd2acee5dc7f8a674743de0cded569.1692964892.git.jcd@tribudubois.net | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 21 | --- |
9 | tests/tcg/aarch64/mte-5.c | 44 +++++++++++++++++++++++++++++++ | 22 | include/hw/arm/fsl-imx7.h | 3 +- |
10 | tests/tcg/aarch64/Makefile.target | 2 +- | 23 | include/hw/misc/imx7_src.h | 66 +++++++++ |
11 | 2 files changed, 45 insertions(+), 1 deletion(-) | 24 | hw/arm/fsl-imx7.c | 8 +- |
12 | create mode 100644 tests/tcg/aarch64/mte-5.c | 25 | hw/misc/imx7_src.c | 276 +++++++++++++++++++++++++++++++++++++ |
13 | 26 | hw/misc/meson.build | 1 + | |
14 | diff --git a/tests/tcg/aarch64/mte-5.c b/tests/tcg/aarch64/mte-5.c | 27 | hw/misc/trace-events | 4 + |
28 | 6 files changed, 356 insertions(+), 2 deletions(-) | ||
29 | create mode 100644 include/hw/misc/imx7_src.h | ||
30 | create mode 100644 hw/misc/imx7_src.c | ||
31 | |||
32 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/include/hw/arm/fsl-imx7.h | ||
35 | +++ b/include/hw/arm/fsl-imx7.h | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | #include "hw/misc/imx7_ccm.h" | ||
38 | #include "hw/misc/imx7_snvs.h" | ||
39 | #include "hw/misc/imx7_gpr.h" | ||
40 | +#include "hw/misc/imx7_src.h" | ||
41 | #include "hw/watchdog/wdt_imx2.h" | ||
42 | #include "hw/gpio/imx_gpio.h" | ||
43 | #include "hw/char/imx_serial.h" | ||
44 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { | ||
45 | IMX7CCMState ccm; | ||
46 | IMX7AnalogState analog; | ||
47 | IMX7SNVSState snvs; | ||
48 | + IMX7SRCState src; | ||
49 | IMXGPCv2State gpcv2; | ||
50 | IMXSPIState spi[FSL_IMX7_NUM_ECSPIS]; | ||
51 | IMXI2CState i2c[FSL_IMX7_NUM_I2CS]; | ||
52 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | ||
53 | FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
54 | |||
55 | FSL_IMX7_SRC_ADDR = 0x30390000, | ||
56 | - FSL_IMX7_SRC_SIZE = (4 * KiB), | ||
57 | |||
58 | FSL_IMX7_CCM_ADDR = 0x30380000, | ||
59 | |||
60 | diff --git a/include/hw/misc/imx7_src.h b/include/hw/misc/imx7_src.h | ||
15 | new file mode 100644 | 61 | new file mode 100644 |
16 | index XXXXXXX..XXXXXXX | 62 | index XXXXXXX..XXXXXXX |
17 | --- /dev/null | 63 | --- /dev/null |
18 | +++ b/tests/tcg/aarch64/mte-5.c | 64 | +++ b/include/hw/misc/imx7_src.h |
19 | @@ -XXX,XX +XXX,XX @@ | 65 | @@ -XXX,XX +XXX,XX @@ |
20 | +/* | 66 | +/* |
21 | + * Memory tagging, faulting unaligned access. | 67 | + * IMX7 System Reset Controller |
22 | + * | 68 | + * |
23 | + * Copyright (c) 2021 Linaro Ltd | 69 | + * Copyright (C) 2023 Jean-Christophe Dubois <jcd@tribudubois.net> |
24 | + * SPDX-License-Identifier: GPL-2.0-or-later | 70 | + * |
71 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
72 | + * See the COPYING file in the top-level directory. | ||
25 | + */ | 73 | + */ |
26 | + | 74 | + |
27 | +#include "mte.h" | 75 | +#ifndef IMX7_SRC_H |
28 | + | 76 | +#define IMX7_SRC_H |
29 | +void pass(int sig, siginfo_t *info, void *uc) | 77 | + |
30 | +{ | 78 | +#include "hw/sysbus.h" |
31 | + assert(info->si_code == SEGV_MTESERR); | 79 | +#include "qemu/bitops.h" |
32 | + exit(0); | 80 | +#include "qom/object.h" |
33 | +} | 81 | + |
34 | + | 82 | +#define SRC_SCR 0 |
35 | +int main(int ac, char **av) | 83 | +#define SRC_A7RCR0 1 |
36 | +{ | 84 | +#define SRC_A7RCR1 2 |
37 | + struct sigaction sa; | 85 | +#define SRC_M4RCR 3 |
38 | + void *p0, *p1, *p2; | 86 | +#define SRC_ERCR 5 |
39 | + long excl = 1; | 87 | +#define SRC_HSICPHY_RCR 7 |
40 | + | 88 | +#define SRC_USBOPHY1_RCR 8 |
41 | + enable_mte(PR_MTE_TCF_SYNC); | 89 | +#define SRC_USBOPHY2_RCR 9 |
42 | + p0 = alloc_mte_mem(sizeof(*p0)); | 90 | +#define SRC_MPIPHY_RCR 10 |
43 | + | 91 | +#define SRC_PCIEPHY_RCR 11 |
44 | + /* Create two differently tagged pointers. */ | 92 | +#define SRC_SBMR1 22 |
45 | + asm("irg %0,%1,%2" : "=r"(p1) : "r"(p0), "r"(excl)); | 93 | +#define SRC_SRSR 23 |
46 | + asm("gmi %0,%1,%0" : "+r"(excl) : "r" (p1)); | 94 | +#define SRC_SISR 26 |
47 | + assert(excl != 1); | 95 | +#define SRC_SIMR 27 |
48 | + asm("irg %0,%1,%2" : "=r"(p2) : "r"(p0), "r"(excl)); | 96 | +#define SRC_SBMR2 28 |
49 | + assert(p1 != p2); | 97 | +#define SRC_GPR1 29 |
50 | + | 98 | +#define SRC_GPR2 30 |
51 | + memset(&sa, 0, sizeof(sa)); | 99 | +#define SRC_GPR3 31 |
52 | + sa.sa_sigaction = pass; | 100 | +#define SRC_GPR4 32 |
53 | + sa.sa_flags = SA_SIGINFO; | 101 | +#define SRC_GPR5 33 |
54 | + sigaction(SIGSEGV, &sa, NULL); | 102 | +#define SRC_GPR6 34 |
55 | + | 103 | +#define SRC_GPR7 35 |
56 | + /* Store store two different tags in sequential granules. */ | 104 | +#define SRC_GPR8 36 |
57 | + asm("stg %0, [%0]" : : "r"(p1)); | 105 | +#define SRC_GPR9 37 |
58 | + asm("stg %0, [%0]" : : "r"(p2 + 16)); | 106 | +#define SRC_GPR10 38 |
59 | + | 107 | +#define SRC_MAX 39 |
60 | + /* Perform an unaligned load crossing the granules. */ | 108 | + |
61 | + asm volatile("ldr %0, [%1]" : "=r"(p0) : "r"(p1 + 12)); | 109 | +/* SRC_A7SCR1 */ |
62 | + abort(); | 110 | +#define R_CORE1_ENABLE_SHIFT 1 |
63 | +} | 111 | +#define R_CORE1_ENABLE_LENGTH 1 |
64 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | 112 | +/* SRC_A7SCR0 */ |
113 | +#define R_CORE1_RST_SHIFT 5 | ||
114 | +#define R_CORE1_RST_LENGTH 1 | ||
115 | +#define R_CORE0_RST_SHIFT 4 | ||
116 | +#define R_CORE0_RST_LENGTH 1 | ||
117 | + | ||
118 | +#define TYPE_IMX7_SRC "imx7.src" | ||
119 | +OBJECT_DECLARE_SIMPLE_TYPE(IMX7SRCState, IMX7_SRC) | ||
120 | + | ||
121 | +struct IMX7SRCState { | ||
122 | + /* <private> */ | ||
123 | + SysBusDevice parent_obj; | ||
124 | + | ||
125 | + /* <public> */ | ||
126 | + MemoryRegion iomem; | ||
127 | + | ||
128 | + uint32_t regs[SRC_MAX]; | ||
129 | +}; | ||
130 | + | ||
131 | +#endif /* IMX7_SRC_H */ | ||
132 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | 133 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/tests/tcg/aarch64/Makefile.target | 134 | --- a/hw/arm/fsl-imx7.c |
67 | +++ b/tests/tcg/aarch64/Makefile.target | 135 | +++ b/hw/arm/fsl-imx7.c |
68 | @@ -XXX,XX +XXX,XX @@ AARCH64_TESTS += bti-2 | 136 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) |
69 | 137 | */ | |
70 | # MTE Tests | 138 | object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2); |
71 | ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_MTE),) | 139 | |
72 | -AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-6 | 140 | + /* |
73 | +AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-5 mte-6 | 141 | + * SRC |
74 | mte-%: CFLAGS += -march=armv8.5-a+memtag | 142 | + */ |
75 | endif | 143 | + object_initialize_child(obj, "src", &s->src, TYPE_IMX7_SRC); |
76 | 144 | + | |
145 | /* | ||
146 | * ECSPIs | ||
147 | */ | ||
148 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
149 | /* | ||
150 | * SRC | ||
151 | */ | ||
152 | - create_unimplemented_device("src", FSL_IMX7_SRC_ADDR, FSL_IMX7_SRC_SIZE); | ||
153 | + sysbus_realize(SYS_BUS_DEVICE(&s->src), &error_abort); | ||
154 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->src), 0, FSL_IMX7_SRC_ADDR); | ||
155 | |||
156 | /* | ||
157 | * Watchdogs | ||
158 | diff --git a/hw/misc/imx7_src.c b/hw/misc/imx7_src.c | ||
159 | new file mode 100644 | ||
160 | index XXXXXXX..XXXXXXX | ||
161 | --- /dev/null | ||
162 | +++ b/hw/misc/imx7_src.c | ||
163 | @@ -XXX,XX +XXX,XX @@ | ||
164 | +/* | ||
165 | + * IMX7 System Reset Controller | ||
166 | + * | ||
167 | + * Copyright (c) 2023 Jean-Christophe Dubois <jcd@tribudubois.net> | ||
168 | + * | ||
169 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
170 | + * See the COPYING file in the top-level directory. | ||
171 | + * | ||
172 | + */ | ||
173 | + | ||
174 | +#include "qemu/osdep.h" | ||
175 | +#include "hw/misc/imx7_src.h" | ||
176 | +#include "migration/vmstate.h" | ||
177 | +#include "qemu/bitops.h" | ||
178 | +#include "qemu/log.h" | ||
179 | +#include "qemu/main-loop.h" | ||
180 | +#include "qemu/module.h" | ||
181 | +#include "target/arm/arm-powerctl.h" | ||
182 | +#include "hw/core/cpu.h" | ||
183 | +#include "hw/registerfields.h" | ||
184 | + | ||
185 | +#include "trace.h" | ||
186 | + | ||
187 | +static const char *imx7_src_reg_name(uint32_t reg) | ||
188 | +{ | ||
189 | + static char unknown[20]; | ||
190 | + | ||
191 | + switch (reg) { | ||
192 | + case SRC_SCR: | ||
193 | + return "SRC_SCR"; | ||
194 | + case SRC_A7RCR0: | ||
195 | + return "SRC_A7RCR0"; | ||
196 | + case SRC_A7RCR1: | ||
197 | + return "SRC_A7RCR1"; | ||
198 | + case SRC_M4RCR: | ||
199 | + return "SRC_M4RCR"; | ||
200 | + case SRC_ERCR: | ||
201 | + return "SRC_ERCR"; | ||
202 | + case SRC_HSICPHY_RCR: | ||
203 | + return "SRC_HSICPHY_RCR"; | ||
204 | + case SRC_USBOPHY1_RCR: | ||
205 | + return "SRC_USBOPHY1_RCR"; | ||
206 | + case SRC_USBOPHY2_RCR: | ||
207 | + return "SRC_USBOPHY2_RCR"; | ||
208 | + case SRC_PCIEPHY_RCR: | ||
209 | + return "SRC_PCIEPHY_RCR"; | ||
210 | + case SRC_SBMR1: | ||
211 | + return "SRC_SBMR1"; | ||
212 | + case SRC_SRSR: | ||
213 | + return "SRC_SRSR"; | ||
214 | + case SRC_SISR: | ||
215 | + return "SRC_SISR"; | ||
216 | + case SRC_SIMR: | ||
217 | + return "SRC_SIMR"; | ||
218 | + case SRC_SBMR2: | ||
219 | + return "SRC_SBMR2"; | ||
220 | + case SRC_GPR1: | ||
221 | + return "SRC_GPR1"; | ||
222 | + case SRC_GPR2: | ||
223 | + return "SRC_GPR2"; | ||
224 | + case SRC_GPR3: | ||
225 | + return "SRC_GPR3"; | ||
226 | + case SRC_GPR4: | ||
227 | + return "SRC_GPR4"; | ||
228 | + case SRC_GPR5: | ||
229 | + return "SRC_GPR5"; | ||
230 | + case SRC_GPR6: | ||
231 | + return "SRC_GPR6"; | ||
232 | + case SRC_GPR7: | ||
233 | + return "SRC_GPR7"; | ||
234 | + case SRC_GPR8: | ||
235 | + return "SRC_GPR8"; | ||
236 | + case SRC_GPR9: | ||
237 | + return "SRC_GPR9"; | ||
238 | + case SRC_GPR10: | ||
239 | + return "SRC_GPR10"; | ||
240 | + default: | ||
241 | + sprintf(unknown, "%u ?", reg); | ||
242 | + return unknown; | ||
243 | + } | ||
244 | +} | ||
245 | + | ||
246 | +static const VMStateDescription vmstate_imx7_src = { | ||
247 | + .name = TYPE_IMX7_SRC, | ||
248 | + .version_id = 1, | ||
249 | + .minimum_version_id = 1, | ||
250 | + .fields = (VMStateField[]) { | ||
251 | + VMSTATE_UINT32_ARRAY(regs, IMX7SRCState, SRC_MAX), | ||
252 | + VMSTATE_END_OF_LIST() | ||
253 | + }, | ||
254 | +}; | ||
255 | + | ||
256 | +static void imx7_src_reset(DeviceState *dev) | ||
257 | +{ | ||
258 | + IMX7SRCState *s = IMX7_SRC(dev); | ||
259 | + | ||
260 | + memset(s->regs, 0, sizeof(s->regs)); | ||
261 | + | ||
262 | + /* Set reset values */ | ||
263 | + s->regs[SRC_SCR] = 0xA0; | ||
264 | + s->regs[SRC_SRSR] = 0x1; | ||
265 | + s->regs[SRC_SIMR] = 0x1F; | ||
266 | +} | ||
267 | + | ||
268 | +static uint64_t imx7_src_read(void *opaque, hwaddr offset, unsigned size) | ||
269 | +{ | ||
270 | + uint32_t value = 0; | ||
271 | + IMX7SRCState *s = (IMX7SRCState *)opaque; | ||
272 | + uint32_t index = offset >> 2; | ||
273 | + | ||
274 | + if (index < SRC_MAX) { | ||
275 | + value = s->regs[index]; | ||
276 | + } else { | ||
277 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%" | ||
278 | + HWADDR_PRIx "\n", TYPE_IMX7_SRC, __func__, offset); | ||
279 | + } | ||
280 | + | ||
281 | + trace_imx7_src_read(imx7_src_reg_name(index), value); | ||
282 | + | ||
283 | + return value; | ||
284 | +} | ||
285 | + | ||
286 | + | ||
287 | +/* | ||
288 | + * The reset is asynchronous so we need to defer clearing the reset | ||
289 | + * bit until the work is completed. | ||
290 | + */ | ||
291 | + | ||
292 | +struct SRCSCRResetInfo { | ||
293 | + IMX7SRCState *s; | ||
294 | + uint32_t reset_bit; | ||
295 | +}; | ||
296 | + | ||
297 | +static void imx7_clear_reset_bit(CPUState *cpu, run_on_cpu_data data) | ||
298 | +{ | ||
299 | + struct SRCSCRResetInfo *ri = data.host_ptr; | ||
300 | + IMX7SRCState *s = ri->s; | ||
301 | + | ||
302 | + assert(qemu_mutex_iothread_locked()); | ||
303 | + | ||
304 | + s->regs[SRC_A7RCR0] = deposit32(s->regs[SRC_A7RCR0], ri->reset_bit, 1, 0); | ||
305 | + | ||
306 | + trace_imx7_src_write(imx7_src_reg_name(SRC_A7RCR0), s->regs[SRC_A7RCR0]); | ||
307 | + | ||
308 | + g_free(ri); | ||
309 | +} | ||
310 | + | ||
311 | +static void imx7_defer_clear_reset_bit(uint32_t cpuid, | ||
312 | + IMX7SRCState *s, | ||
313 | + uint32_t reset_shift) | ||
314 | +{ | ||
315 | + struct SRCSCRResetInfo *ri; | ||
316 | + CPUState *cpu = arm_get_cpu_by_id(cpuid); | ||
317 | + | ||
318 | + if (!cpu) { | ||
319 | + return; | ||
320 | + } | ||
321 | + | ||
322 | + ri = g_new(struct SRCSCRResetInfo, 1); | ||
323 | + ri->s = s; | ||
324 | + ri->reset_bit = reset_shift; | ||
325 | + | ||
326 | + async_run_on_cpu(cpu, imx7_clear_reset_bit, RUN_ON_CPU_HOST_PTR(ri)); | ||
327 | +} | ||
328 | + | ||
329 | + | ||
330 | +static void imx7_src_write(void *opaque, hwaddr offset, uint64_t value, | ||
331 | + unsigned size) | ||
332 | +{ | ||
333 | + IMX7SRCState *s = (IMX7SRCState *)opaque; | ||
334 | + uint32_t index = offset >> 2; | ||
335 | + long unsigned int change_mask; | ||
336 | + uint32_t current_value = value; | ||
337 | + | ||
338 | + if (index >= SRC_MAX) { | ||
339 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%" | ||
340 | + HWADDR_PRIx "\n", TYPE_IMX7_SRC, __func__, offset); | ||
341 | + return; | ||
342 | + } | ||
343 | + | ||
344 | + trace_imx7_src_write(imx7_src_reg_name(SRC_A7RCR0), s->regs[SRC_A7RCR0]); | ||
345 | + | ||
346 | + change_mask = s->regs[index] ^ (uint32_t)current_value; | ||
347 | + | ||
348 | + switch (index) { | ||
349 | + case SRC_A7RCR0: | ||
350 | + if (FIELD_EX32(change_mask, CORE0, RST)) { | ||
351 | + arm_reset_cpu(0); | ||
352 | + imx7_defer_clear_reset_bit(0, s, R_CORE0_RST_SHIFT); | ||
353 | + } | ||
354 | + if (FIELD_EX32(change_mask, CORE1, RST)) { | ||
355 | + arm_reset_cpu(1); | ||
356 | + imx7_defer_clear_reset_bit(1, s, R_CORE1_RST_SHIFT); | ||
357 | + } | ||
358 | + s->regs[index] = current_value; | ||
359 | + break; | ||
360 | + case SRC_A7RCR1: | ||
361 | + /* | ||
362 | + * On real hardware when the system reset controller starts a | ||
363 | + * secondary CPU it runs through some boot ROM code which reads | ||
364 | + * the SRC_GPRX registers controlling the start address and branches | ||
365 | + * to it. | ||
366 | + * Here we are taking a short cut and branching directly to the | ||
367 | + * requested address (we don't want to run the boot ROM code inside | ||
368 | + * QEMU) | ||
369 | + */ | ||
370 | + if (FIELD_EX32(change_mask, CORE1, ENABLE)) { | ||
371 | + if (FIELD_EX32(current_value, CORE1, ENABLE)) { | ||
372 | + /* CORE 1 is brought up */ | ||
373 | + arm_set_cpu_on(1, s->regs[SRC_GPR3], s->regs[SRC_GPR4], | ||
374 | + 3, false); | ||
375 | + } else { | ||
376 | + /* CORE 1 is shut down */ | ||
377 | + arm_set_cpu_off(1); | ||
378 | + } | ||
379 | + /* We clear the reset bits as the processor changed state */ | ||
380 | + imx7_defer_clear_reset_bit(1, s, R_CORE1_RST_SHIFT); | ||
381 | + clear_bit(R_CORE1_RST_SHIFT, &change_mask); | ||
382 | + } | ||
383 | + s->regs[index] = current_value; | ||
384 | + break; | ||
385 | + default: | ||
386 | + s->regs[index] = current_value; | ||
387 | + break; | ||
388 | + } | ||
389 | +} | ||
390 | + | ||
391 | +static const struct MemoryRegionOps imx7_src_ops = { | ||
392 | + .read = imx7_src_read, | ||
393 | + .write = imx7_src_write, | ||
394 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
395 | + .valid = { | ||
396 | + /* | ||
397 | + * Our device would not work correctly if the guest was doing | ||
398 | + * unaligned access. This might not be a limitation on the real | ||
399 | + * device but in practice there is no reason for a guest to access | ||
400 | + * this device unaligned. | ||
401 | + */ | ||
402 | + .min_access_size = 4, | ||
403 | + .max_access_size = 4, | ||
404 | + .unaligned = false, | ||
405 | + }, | ||
406 | +}; | ||
407 | + | ||
408 | +static void imx7_src_realize(DeviceState *dev, Error **errp) | ||
409 | +{ | ||
410 | + IMX7SRCState *s = IMX7_SRC(dev); | ||
411 | + | ||
412 | + memory_region_init_io(&s->iomem, OBJECT(dev), &imx7_src_ops, s, | ||
413 | + TYPE_IMX7_SRC, 0x1000); | ||
414 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | ||
415 | +} | ||
416 | + | ||
417 | +static void imx7_src_class_init(ObjectClass *klass, void *data) | ||
418 | +{ | ||
419 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
420 | + | ||
421 | + dc->realize = imx7_src_realize; | ||
422 | + dc->reset = imx7_src_reset; | ||
423 | + dc->vmsd = &vmstate_imx7_src; | ||
424 | + dc->desc = "i.MX6 System Reset Controller"; | ||
425 | +} | ||
426 | + | ||
427 | +static const TypeInfo imx7_src_info = { | ||
428 | + .name = TYPE_IMX7_SRC, | ||
429 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
430 | + .instance_size = sizeof(IMX7SRCState), | ||
431 | + .class_init = imx7_src_class_init, | ||
432 | +}; | ||
433 | + | ||
434 | +static void imx7_src_register_types(void) | ||
435 | +{ | ||
436 | + type_register_static(&imx7_src_info); | ||
437 | +} | ||
438 | + | ||
439 | +type_init(imx7_src_register_types) | ||
440 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
441 | index XXXXXXX..XXXXXXX 100644 | ||
442 | --- a/hw/misc/meson.build | ||
443 | +++ b/hw/misc/meson.build | ||
444 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_IMX', if_true: files( | ||
445 | 'imx6_src.c', | ||
446 | 'imx6ul_ccm.c', | ||
447 | 'imx7_ccm.c', | ||
448 | + 'imx7_src.c', | ||
449 | 'imx7_gpr.c', | ||
450 | 'imx7_snvs.c', | ||
451 | 'imx_ccm.c', | ||
452 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | ||
453 | index XXXXXXX..XXXXXXX 100644 | ||
454 | --- a/hw/misc/trace-events | ||
455 | +++ b/hw/misc/trace-events | ||
456 | @@ -XXX,XX +XXX,XX @@ ccm_clock_freq(uint32_t clock, uint32_t freq) "(Clock = %d) = %d" | ||
457 | ccm_read_reg(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 | ||
458 | ccm_write_reg(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 | ||
459 | |||
460 | +# imx7_src.c | ||
461 | +imx7_src_read(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 | ||
462 | +imx7_src_write(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 | ||
463 | + | ||
464 | # iotkit-sysinfo.c | ||
465 | iotkit_sysinfo_read(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | ||
466 | iotkit_sysinfo_write(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | ||
77 | -- | 467 | -- |
78 | 2.20.1 | 468 | 2.34.1 |
79 | |||
80 | diff view generated by jsdifflib |
1 | The Arm ARM specifies that for Thumb encodings of the various plain | 1 | The architecture requires (R_TYTWB) that an attempt to return from EL3 |
---|---|---|---|
2 | store insns, if the Rn field is 1111 then we must UNDEF. This is | 2 | when SCR_EL3.{NSE,NS} are {1,0} is an illegal exception return. (This |
3 | different from the Arm encodings, where this case is either | 3 | enforces that the CPU can't ever be executing below EL3 with the |
4 | UNPREDICTABLE or has well-defined behaviour. The exclusive stores, | 4 | NSE,NS bits indicating an invalid security state.) |
5 | store-release and STRD do not have this UNDEF case for any encoding. | ||
6 | 5 | ||
7 | Enforce the UNDEF for this case in the Thumb plain store insns. | 6 | We were missing this check; add it. |
8 | 7 | ||
9 | Fixes: https://bugs.launchpad.net/qemu/+bug/1922887 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20210408162402.5822-1-peter.maydell@linaro.org | 10 | Message-id: 20230807150618.101357-1-peter.maydell@linaro.org |
13 | --- | 11 | --- |
14 | target/arm/translate.c | 16 ++++++++++++++++ | 12 | target/arm/tcg/helper-a64.c | 9 +++++++++ |
15 | 1 file changed, 16 insertions(+) | 13 | 1 file changed, 9 insertions(+) |
16 | 14 | ||
17 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate.c | 17 | --- a/target/arm/tcg/helper-a64.c |
20 | +++ b/target/arm/translate.c | 18 | +++ b/target/arm/tcg/helper-a64.c |
21 | @@ -XXX,XX +XXX,XX @@ static bool op_store_rr(DisasContext *s, arg_ldst_rr *a, | 19 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) |
22 | ISSInfo issinfo = make_issinfo(s, a->rt, a->p, a->w) | ISSIsWrite; | 20 | spsr &= ~PSTATE_SS; |
23 | TCGv_i32 addr, tmp; | 21 | } |
24 | 22 | ||
25 | + /* | 23 | + /* |
26 | + * In Thumb encodings of stores Rn=1111 is UNDEF; for Arm it | 24 | + * FEAT_RME forbids return from EL3 with an invalid security state. |
27 | + * is either UNPREDICTABLE or has defined behaviour | 25 | + * We don't need an explicit check for FEAT_RME here because we enforce |
26 | + * in scr_write() that you can't set the NSE bit without it. | ||
28 | + */ | 27 | + */ |
29 | + if (s->thumb && a->rn == 15) { | 28 | + if (cur_el == 3 && (env->cp15.scr_el3 & (SCR_NS | SCR_NSE)) == SCR_NSE) { |
30 | + return false; | 29 | + goto illegal_return; |
31 | + } | 30 | + } |
32 | + | 31 | + |
33 | addr = op_addr_rr_pre(s, a); | 32 | new_el = el_from_spsr(spsr); |
34 | 33 | if (new_el == -1) { | |
35 | tmp = load_reg(s, a->rt); | 34 | goto illegal_return; |
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; | ||
46 | + } | ||
47 | + | ||
48 | addr = op_addr_ri_pre(s, a); | ||
49 | |||
50 | tmp = load_reg(s, a->rt); | ||
51 | -- | 35 | -- |
52 | 2.20.1 | 36 | 2.34.1 |
53 | |||
54 | 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 |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | In the m48t59 device we almost always use 64-bit arithmetic when |
---|---|---|---|
2 | dealing with time_t deltas. The one exception is in set_alarm(), | ||
3 | which currently uses a plain 'int' to hold the difference between two | ||
4 | time_t values. Switch to int64_t instead to avoid any possible | ||
5 | overflow issues. | ||
2 | 6 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210419202257.161730-32-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | --- | 9 | --- |
8 | target/arm/translate-sve.c | 2 +- | 10 | hw/rtc/m48t59.c | 2 +- |
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 12 | ||
11 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 13 | diff --git a/hw/rtc/m48t59.c b/hw/rtc/m48t59.c |
12 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-sve.c | 15 | --- a/hw/rtc/m48t59.c |
14 | +++ b/target/arm/translate-sve.c | 16 | +++ b/hw/rtc/m48t59.c |
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD1R_zpri(DisasContext *s, arg_rpri_load *a) | 17 | @@ -XXX,XX +XXX,XX @@ static void alarm_cb (void *opaque) |
16 | clean_addr = gen_mte_check1(s, temp, false, true, msz); | 18 | |
17 | 19 | static void set_alarm(M48t59State *NVRAM) | |
18 | tcg_gen_qemu_ld_i64(temp, clean_addr, get_mem_index(s), | 20 | { |
19 | - s->be_data | dtype_mop[a->dtype]); | 21 | - int diff; |
20 | + finalize_memop(s, dtype_mop[a->dtype])); | 22 | + int64_t diff; |
21 | 23 | if (NVRAM->alrm_timer != NULL) { | |
22 | /* Broadcast to *all* elements. */ | 24 | timer_del(NVRAM->alrm_timer); |
23 | tcg_gen_gvec_dup_i64(esz, vec_full_reg_offset(s, a->rd), | 25 | diff = qemu_timedate_diff(&NVRAM->alarm) - NVRAM->time_offset; |
24 | -- | 26 | -- |
25 | 2.20.1 | 27 | 2.34.1 |
26 | 28 | ||
27 | 29 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | In the twl92230 device, use int64_t for the two state fields |
---|---|---|---|
2 | sec_offset and alm_sec, because we set these to values that | ||
3 | are either time_t or differences between two time_t values. | ||
2 | 4 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | These fields aren't saved in vmstate anywhere, so we can |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | safely widen them. |
5 | Message-id: 20210419202257.161730-20-richard.henderson@linaro.org | 7 | |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | --- | 10 | --- |
8 | target/arm/translate.c | 4 ++-- | 11 | hw/rtc/twl92230.c | 4 ++-- |
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | 12 | 1 file changed, 2 insertions(+), 2 deletions(-) |
10 | 13 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 16 | --- a/hw/rtc/twl92230.c |
14 | +++ b/target/arm/translate.c | 17 | +++ b/hw/rtc/twl92230.c |
15 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | 18 | @@ -XXX,XX +XXX,XX @@ struct MenelausState { |
16 | } | 19 | struct tm tm; |
17 | tcg_gen_addi_i32(addr, addr, offset); | 20 | struct tm new; |
18 | tmp = load_reg(s, 14); | 21 | struct tm alm; |
19 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | 22 | - int sec_offset; |
20 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | 23 | - int alm_sec; |
21 | tcg_temp_free_i32(tmp); | 24 | + int64_t sec_offset; |
22 | tmp = load_cpu_field(spsr); | 25 | + int64_t alm_sec; |
23 | tcg_gen_addi_i32(addr, addr, 4); | 26 | int next_comp; |
24 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | 27 | } rtc; |
25 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | 28 | uint16_t rtc_next_vmstate; |
26 | tcg_temp_free_i32(tmp); | ||
27 | if (writeback) { | ||
28 | switch (amode) { | ||
29 | -- | 29 | -- |
30 | 2.20.1 | 30 | 2.34.1 |
31 | 31 | ||
32 | 32 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | In the aspeed_rtc device we store a difference between two time_t |
---|---|---|---|
2 | values in an 'int'. This is not really correct when time_t could | ||
3 | be 64 bits. Enlarge the field to 'int64_t'. | ||
2 | 4 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | This is a migration compatibility break for the aspeed boards. |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | While we are changing the vmstate, remove the accidental |
5 | Message-id: 20210419202257.161730-25-richard.henderson@linaro.org | 7 | duplicate of the offset field. |
8 | |||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
7 | --- | 11 | --- |
8 | target/arm/translate-neon.c.inc | 48 ++++++++++++++++++++++++++++----- | 12 | include/hw/rtc/aspeed_rtc.h | 2 +- |
9 | 1 file changed, 42 insertions(+), 6 deletions(-) | 13 | hw/rtc/aspeed_rtc.c | 5 ++--- |
14 | 2 files changed, 3 insertions(+), 4 deletions(-) | ||
10 | 15 | ||
11 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 16 | diff --git a/include/hw/rtc/aspeed_rtc.h b/include/hw/rtc/aspeed_rtc.h |
12 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-neon.c.inc | 18 | --- a/include/hw/rtc/aspeed_rtc.h |
14 | +++ b/target/arm/translate-neon.c.inc | 19 | +++ b/include/hw/rtc/aspeed_rtc.h |
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | 20 | @@ -XXX,XX +XXX,XX @@ struct AspeedRtcState { |
16 | int nregs = a->n + 1; | 21 | qemu_irq irq; |
17 | int vd = a->vd; | 22 | |
18 | TCGv_i32 addr, tmp; | 23 | uint32_t reg[0x18]; |
19 | + MemOp mop; | 24 | - int offset; |
20 | 25 | + int64_t offset; | |
21 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 26 | |
22 | return false; | 27 | }; |
23 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | 28 | |
24 | return true; | 29 | diff --git a/hw/rtc/aspeed_rtc.c b/hw/rtc/aspeed_rtc.c |
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/rtc/aspeed_rtc.c | ||
32 | +++ b/hw/rtc/aspeed_rtc.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_rtc_ops = { | ||
34 | |||
35 | static const VMStateDescription vmstate_aspeed_rtc = { | ||
36 | .name = TYPE_ASPEED_RTC, | ||
37 | - .version_id = 1, | ||
38 | + .version_id = 2, | ||
39 | .fields = (VMStateField[]) { | ||
40 | VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18), | ||
41 | - VMSTATE_INT32(offset, AspeedRtcState), | ||
42 | - VMSTATE_INT32(offset, AspeedRtcState), | ||
43 | + VMSTATE_INT64(offset, AspeedRtcState), | ||
44 | VMSTATE_END_OF_LIST() | ||
25 | } | 45 | } |
26 | 46 | }; | |
27 | + /* Pick up SCTLR settings */ | ||
28 | + mop = finalize_memop(s, a->size); | ||
29 | + | ||
30 | + if (a->align) { | ||
31 | + MemOp align_op; | ||
32 | + | ||
33 | + switch (nregs) { | ||
34 | + case 1: | ||
35 | + /* For VLD1, use natural alignment. */ | ||
36 | + align_op = MO_ALIGN; | ||
37 | + break; | ||
38 | + case 2: | ||
39 | + /* For VLD2, use double alignment. */ | ||
40 | + align_op = pow2_align(a->size + 1); | ||
41 | + break; | ||
42 | + case 4: | ||
43 | + if (a->size == MO_32) { | ||
44 | + /* | ||
45 | + * For VLD4.32, align = 1 is double alignment, align = 2 is | ||
46 | + * quad alignment; align = 3 is rejected above. | ||
47 | + */ | ||
48 | + align_op = pow2_align(a->size + a->align); | ||
49 | + } else { | ||
50 | + /* For VLD4.8 and VLD.16, we want quad alignment. */ | ||
51 | + align_op = pow2_align(a->size + 2); | ||
52 | + } | ||
53 | + break; | ||
54 | + default: | ||
55 | + /* For VLD3, the alignment field is zero and rejected above. */ | ||
56 | + g_assert_not_reached(); | ||
57 | + } | ||
58 | + | ||
59 | + mop = (mop & ~MO_AMASK) | align_op; | ||
60 | + } | ||
61 | + | ||
62 | tmp = tcg_temp_new_i32(); | ||
63 | addr = tcg_temp_new_i32(); | ||
64 | load_reg_var(s, addr, a->rn); | ||
65 | - /* | ||
66 | - * TODO: if we implemented alignment exceptions, we should check | ||
67 | - * addr against the alignment encoded in a->align here. | ||
68 | - */ | ||
69 | + | ||
70 | for (reg = 0; reg < nregs; reg++) { | ||
71 | if (a->l) { | ||
72 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), a->size); | ||
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 | + | ||
83 | + /* Subsequent memory operations inherit alignment */ | ||
84 | + mop &= ~MO_AMASK; | ||
85 | } | ||
86 | tcg_temp_free_i32(addr); | ||
87 | tcg_temp_free_i32(tmp); | ||
88 | -- | 47 | -- |
89 | 2.20.1 | 48 | 2.34.1 |
90 | 49 | ||
91 | 50 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The functions qemu_get_timedate() and qemu_timedate_diff() take |
---|---|---|---|
2 | and return a time offset as an integer. Coverity points out that | ||
3 | means that when an RTC device implementation holds an offset | ||
4 | as a time_t, as the m48t59 does, the time_t will get truncated. | ||
5 | (CID 1507157, 1517772). | ||
2 | 6 | ||
3 | Now that mte_check1 and mte_checkN have been merged, we can | 7 | The functions work with time_t internally, so make them use that type |
4 | merge sve_cont_ldst_mte_check1 and sve_cont_ldst_mte_checkN. | 8 | in their APIs. |
5 | 9 | ||
6 | Which means that we can eliminate the function pointer into | 10 | Note that this won't help any Y2038 issues where either the device |
7 | sve_ldN_r and sve_stN_r, calling sve_cont_ldst_mte_check directly. | 11 | model itself is keeping the offset in a 32-bit integer, or where the |
12 | hardware under emulation has Y2038 or other rollover problems. If we | ||
13 | missed any cases of the former then hopefully Coverity will warn us | ||
14 | about them since after this patch we'd be truncating a time_t in | ||
15 | assignments from qemu_timedate_diff().) | ||
8 | 16 | ||
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> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
13 | --- | 19 | --- |
14 | target/arm/sve_helper.c | 84 +++++++++++++---------------------------- | 20 | include/sysemu/rtc.h | 4 ++-- |
15 | 1 file changed, 26 insertions(+), 58 deletions(-) | 21 | softmmu/rtc.c | 4 ++-- |
22 | 2 files changed, 4 insertions(+), 4 deletions(-) | ||
16 | 23 | ||
17 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 24 | diff --git a/include/sysemu/rtc.h b/include/sysemu/rtc.h |
18 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/sve_helper.c | 26 | --- a/include/sysemu/rtc.h |
20 | +++ b/target/arm/sve_helper.c | 27 | +++ b/include/sysemu/rtc.h |
21 | @@ -XXX,XX +XXX,XX @@ static void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, | 28 | @@ -XXX,XX +XXX,XX @@ |
29 | * The behaviour of the clock whose value this function returns will | ||
30 | * depend on the -rtc command line option passed by the user. | ||
31 | */ | ||
32 | -void qemu_get_timedate(struct tm *tm, int offset); | ||
33 | +void qemu_get_timedate(struct tm *tm, time_t offset); | ||
34 | |||
35 | /** | ||
36 | * qemu_timedate_diff: Return difference between a struct tm and the RTC | ||
37 | @@ -XXX,XX +XXX,XX @@ void qemu_get_timedate(struct tm *tm, int offset); | ||
38 | * a timestamp one hour further ahead than the current RTC time | ||
39 | * then this function will return 3600. | ||
40 | */ | ||
41 | -int qemu_timedate_diff(struct tm *tm); | ||
42 | +time_t qemu_timedate_diff(struct tm *tm); | ||
43 | |||
22 | #endif | 44 | #endif |
45 | diff --git a/softmmu/rtc.c b/softmmu/rtc.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/softmmu/rtc.c | ||
48 | +++ b/softmmu/rtc.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static time_t qemu_ref_timedate(QEMUClockType clock) | ||
50 | return value; | ||
23 | } | 51 | } |
24 | 52 | ||
25 | -typedef uint64_t mte_check_fn(CPUARMState *, uint32_t, uint64_t, uintptr_t); | 53 | -void qemu_get_timedate(struct tm *tm, int offset) |
26 | - | 54 | +void qemu_get_timedate(struct tm *tm, time_t offset) |
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 | { | 55 | { |
36 | intptr_t mem_off, reg_off, reg_last; | 56 | time_t ti = qemu_ref_timedate(rtc_clock); |
37 | 57 | ||
38 | @@ -XXX,XX +XXX,XX @@ void sve_cont_ldst_mte_check_int(SVEContLdSt *info, CPUARMState *env, | 58 | @@ -XXX,XX +XXX,XX @@ void qemu_get_timedate(struct tm *tm, int offset) |
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 | } | 59 | } |
58 | } | 60 | } |
59 | 61 | ||
60 | -typedef void sve_cont_ldst_mte_check_fn(SVEContLdSt *info, CPUARMState *env, | 62 | -int qemu_timedate_diff(struct tm *tm) |
61 | - uint64_t *vg, target_ulong addr, | 63 | +time_t qemu_timedate_diff(struct tm *tm) |
62 | - int esize, int msize, uint32_t mtedesc, | ||
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 | { | 64 | { |
95 | const unsigned rd = simd_data(desc); | 65 | time_t seconds; |
96 | const intptr_t reg_max = simd_oprsz(desc); | 66 | |
97 | @@ -XXX,XX +XXX,XX @@ void sve_ldN_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, | ||
98 | * Handle mte checks for all active elements. | ||
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 | } | ||
108 | |||
109 | flags = info.page[0].flags | info.page[1].flags; | ||
110 | @@ -XXX,XX +XXX,XX @@ void sve_ldN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr, | ||
111 | mtedesc = 0; | ||
112 | } | ||
113 | |||
114 | - sve_ldN_r(env, vg, addr, desc, ra, esz, msz, N, mtedesc, host_fn, tlb_fn, | ||
115 | - N == 1 ? sve_cont_ldst_mte_check1 : sve_cont_ldst_mte_checkN); | ||
116 | + sve_ldN_r(env, vg, addr, desc, ra, esz, msz, N, mtedesc, host_fn, tlb_fn); | ||
117 | } | ||
118 | |||
119 | #define DO_LD1_1(NAME, ESZ) \ | ||
120 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_##NAME##_r)(CPUARMState *env, void *vg, \ | ||
121 | target_ulong addr, uint32_t desc) \ | ||
122 | { \ | ||
123 | sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, MO_8, 1, 0, \ | ||
124 | - sve_##NAME##_host, sve_##NAME##_tlb, NULL); \ | ||
125 | + sve_##NAME##_host, sve_##NAME##_tlb); \ | ||
126 | } \ | ||
127 | void HELPER(sve_##NAME##_r_mte)(CPUARMState *env, void *vg, \ | ||
128 | target_ulong addr, uint32_t desc) \ | ||
129 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_##NAME##_le_r)(CPUARMState *env, void *vg, \ | ||
130 | target_ulong addr, uint32_t desc) \ | ||
131 | { \ | ||
132 | sve_ldN_r(env, vg, addr, desc, GETPC(), ESZ, MSZ, 1, 0, \ | ||
133 | - sve_##NAME##_le_host, sve_##NAME##_le_tlb, NULL); \ | ||
134 | + sve_##NAME##_le_host, sve_##NAME##_le_tlb); \ | ||
135 | } \ | ||
136 | void HELPER(sve_##NAME##_be_r)(CPUARMState *env, void *vg, \ | ||
137 | target_ulong addr, uint32_t desc) \ | ||
138 | { \ | ||
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 | { | ||
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 | -- | 67 | -- |
240 | 2.20.1 | 68 | 2.34.1 |
241 | 69 | ||
242 | 70 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Where architecturally one ARM_FEATURE_X flag implies another |
---|---|---|---|
2 | 2 | ARM_FEATURE_Y, we allow the CPU init function to only set X, and then | |
3 | Adjust the interface to match what has been done to the | 3 | set Y for it. Currently we do this in two places -- we set a few |
4 | TCGv_i32 load/store functions. | 4 | flags in arm_cpu_post_init() because we need them to decide which |
5 | 5 | properties to create on the CPU object, and then we do the rest in | |
6 | This is less obvious, because at present the only user of | 6 | arm_cpu_realizefn(). However, this is fragile, because it's easy to |
7 | these functions, trans_VLDST_multiple, also wants to manipulate | 7 | add a new property and not notice that this means that an X-implies-Y |
8 | the endianness to speed up loading multiple bytes. Thus we | 8 | check now has to move from realize to post-init. |
9 | retain an "internal" interface which is identical to the | 9 | |
10 | current gen_aa32_{ld,st}_i64 interface. | 10 | As a specific example, the pmsav7-dregion property is conditional |
11 | 11 | on ARM_FEATURE_PMSA && ARM_FEATURE_V7, which means it won't appear | |
12 | The "new" interface will gain users as we remove the legacy | 12 | on the Cortex-M33 and -M55, because they set ARM_FEATURE_V8 and |
13 | interfaces, gen_aa32_ld64 and gen_aa32_st64. | 13 | rely on V8-implies-V7, which doesn't happen until the realizefn. |
14 | 14 | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Move all of these X-implies-Y checks into a new function, which |
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 16 | we call at the top of arm_cpu_post_init(), so the feature bits |
17 | Message-id: 20210419202257.161730-15-richard.henderson@linaro.org | 17 | are available at that point. |
18 | |||
19 | This does now give us the reverse issue, that if there's a feature | ||
20 | bit which is enabled or disabled by the setting of a property then | ||
21 | then X-implies-Y features that are dependent on that property need to | ||
22 | be in realize, not in this new function. But the only one of those | ||
23 | is the "EL3 implies VBAR" which is already in the right place, so | ||
24 | putting things this way round seems better to me. | ||
25 | |||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
27 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
28 | Message-id: 20230724174335.2150499-2-peter.maydell@linaro.org | ||
19 | --- | 29 | --- |
20 | target/arm/translate.c | 78 +++++++++++++++++++-------------- | 30 | target/arm/cpu.c | 179 +++++++++++++++++++++++++---------------------- |
21 | target/arm/translate-neon.c.inc | 6 ++- | 31 | 1 file changed, 97 insertions(+), 82 deletions(-) |
22 | 2 files changed, 49 insertions(+), 35 deletions(-) | 32 | |
23 | 33 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | |
24 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/translate.c | 35 | --- a/target/arm/cpu.c |
27 | +++ b/target/arm/translate.c | 36 | +++ b/target/arm/cpu.c |
28 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_internal_i32(DisasContext *s, TCGv_i32 val, | 37 | @@ -XXX,XX +XXX,XX @@ unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) |
29 | tcg_temp_free(addr); | 38 | NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1; |
30 | } | 39 | } |
31 | 40 | ||
32 | +static void gen_aa32_ld_internal_i64(DisasContext *s, TCGv_i64 val, | 41 | +static void arm_cpu_propagate_feature_implications(ARMCPU *cpu) |
33 | + TCGv_i32 a32, int index, MemOp opc) | ||
34 | +{ | 42 | +{ |
35 | + TCGv addr = gen_aa32_addr(s, a32, opc); | 43 | + CPUARMState *env = &cpu->env; |
36 | + | 44 | + bool no_aa32 = false; |
37 | + tcg_gen_qemu_ld_i64(val, addr, index, opc); | 45 | + |
38 | + | 46 | + /* |
39 | + /* Not needed for user-mode BE32, where we use MO_BE instead. */ | 47 | + * Some features automatically imply others: set the feature |
40 | + if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | 48 | + * bits explicitly for these cases. |
41 | + tcg_gen_rotri_i64(val, val, 32); | 49 | + */ |
42 | + } | 50 | + |
43 | + tcg_temp_free(addr); | 51 | + if (arm_feature(env, ARM_FEATURE_M)) { |
52 | + set_feature(env, ARM_FEATURE_PMSA); | ||
53 | + } | ||
54 | + | ||
55 | + if (arm_feature(env, ARM_FEATURE_V8)) { | ||
56 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
57 | + set_feature(env, ARM_FEATURE_V7); | ||
58 | + } else { | ||
59 | + set_feature(env, ARM_FEATURE_V7VE); | ||
60 | + } | ||
61 | + } | ||
62 | + | ||
63 | + /* | ||
64 | + * There exist AArch64 cpus without AArch32 support. When KVM | ||
65 | + * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. | ||
66 | + * Similarly, we cannot check ID_AA64PFR0 without AArch64 support. | ||
67 | + * As a general principle, we also do not make ID register | ||
68 | + * consistency checks anywhere unless using TCG, because only | ||
69 | + * for TCG would a consistency-check failure be a QEMU bug. | ||
70 | + */ | ||
71 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
72 | + no_aa32 = !cpu_isar_feature(aa64_aa32, cpu); | ||
73 | + } | ||
74 | + | ||
75 | + if (arm_feature(env, ARM_FEATURE_V7VE)) { | ||
76 | + /* | ||
77 | + * v7 Virtualization Extensions. In real hardware this implies | ||
78 | + * EL2 and also the presence of the Security Extensions. | ||
79 | + * For QEMU, for backwards-compatibility we implement some | ||
80 | + * CPUs or CPU configs which have no actual EL2 or EL3 but do | ||
81 | + * include the various other features that V7VE implies. | ||
82 | + * Presence of EL2 itself is ARM_FEATURE_EL2, and of the | ||
83 | + * Security Extensions is ARM_FEATURE_EL3. | ||
84 | + */ | ||
85 | + assert(!tcg_enabled() || no_aa32 || | ||
86 | + cpu_isar_feature(aa32_arm_div, cpu)); | ||
87 | + set_feature(env, ARM_FEATURE_LPAE); | ||
88 | + set_feature(env, ARM_FEATURE_V7); | ||
89 | + } | ||
90 | + if (arm_feature(env, ARM_FEATURE_V7)) { | ||
91 | + set_feature(env, ARM_FEATURE_VAPA); | ||
92 | + set_feature(env, ARM_FEATURE_THUMB2); | ||
93 | + set_feature(env, ARM_FEATURE_MPIDR); | ||
94 | + if (!arm_feature(env, ARM_FEATURE_M)) { | ||
95 | + set_feature(env, ARM_FEATURE_V6K); | ||
96 | + } else { | ||
97 | + set_feature(env, ARM_FEATURE_V6); | ||
98 | + } | ||
99 | + | ||
100 | + /* | ||
101 | + * Always define VBAR for V7 CPUs even if it doesn't exist in | ||
102 | + * non-EL3 configs. This is needed by some legacy boards. | ||
103 | + */ | ||
104 | + set_feature(env, ARM_FEATURE_VBAR); | ||
105 | + } | ||
106 | + if (arm_feature(env, ARM_FEATURE_V6K)) { | ||
107 | + set_feature(env, ARM_FEATURE_V6); | ||
108 | + set_feature(env, ARM_FEATURE_MVFR); | ||
109 | + } | ||
110 | + if (arm_feature(env, ARM_FEATURE_V6)) { | ||
111 | + set_feature(env, ARM_FEATURE_V5); | ||
112 | + if (!arm_feature(env, ARM_FEATURE_M)) { | ||
113 | + assert(!tcg_enabled() || no_aa32 || | ||
114 | + cpu_isar_feature(aa32_jazelle, cpu)); | ||
115 | + set_feature(env, ARM_FEATURE_AUXCR); | ||
116 | + } | ||
117 | + } | ||
118 | + if (arm_feature(env, ARM_FEATURE_V5)) { | ||
119 | + set_feature(env, ARM_FEATURE_V4T); | ||
120 | + } | ||
121 | + if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
122 | + set_feature(env, ARM_FEATURE_V7MP); | ||
123 | + } | ||
124 | + if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { | ||
125 | + set_feature(env, ARM_FEATURE_CBAR); | ||
126 | + } | ||
127 | + if (arm_feature(env, ARM_FEATURE_THUMB2) && | ||
128 | + !arm_feature(env, ARM_FEATURE_M)) { | ||
129 | + set_feature(env, ARM_FEATURE_THUMB_DSP); | ||
130 | + } | ||
44 | +} | 131 | +} |
45 | + | 132 | + |
46 | +static void gen_aa32_st_internal_i64(DisasContext *s, TCGv_i64 val, | 133 | void arm_cpu_post_init(Object *obj) |
47 | + TCGv_i32 a32, int index, MemOp opc) | ||
48 | +{ | ||
49 | + TCGv addr = gen_aa32_addr(s, a32, opc); | ||
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 | +} | ||
62 | + | ||
63 | static void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
64 | int index, MemOp opc) | ||
65 | { | 134 | { |
66 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 135 | ARMCPU *cpu = ARM_CPU(obj); |
67 | gen_aa32_st_internal_i32(s, val, a32, index, finalize_memop(s, opc)); | 136 | |
68 | } | 137 | - /* M profile implies PMSA. We have to do this here rather than |
69 | 138 | - * in realize with the other feature-implication checks because | |
70 | +static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | 139 | - * we look at the PMSA bit to see if we should add some properties. |
71 | + int index, MemOp opc) | 140 | + /* |
72 | +{ | 141 | + * Some features imply others. Figure this out now, because we |
73 | + gen_aa32_ld_internal_i64(s, val, a32, index, finalize_memop(s, opc)); | 142 | + * are going to look at the feature bits in deciding which |
74 | +} | 143 | + * properties to add. |
75 | + | 144 | */ |
76 | +static void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | 145 | - if (arm_feature(&cpu->env, ARM_FEATURE_M)) { |
77 | + int index, MemOp opc) | 146 | - set_feature(&cpu->env, ARM_FEATURE_PMSA); |
78 | +{ | 147 | - } |
79 | + gen_aa32_st_internal_i64(s, val, a32, index, finalize_memop(s, opc)); | 148 | + arm_cpu_propagate_feature_implications(cpu); |
80 | +} | 149 | |
81 | + | 150 | if (arm_feature(&cpu->env, ARM_FEATURE_CBAR) || |
82 | #define DO_GEN_LD(SUFF, OPC) \ | 151 | arm_feature(&cpu->env, ARM_FEATURE_CBAR_RO)) { |
83 | static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val, \ | 152 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
84 | TCGv_i32 a32, int index) \ | 153 | CPUARMState *env = &cpu->env; |
85 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 154 | int pagebits; |
86 | gen_aa32_st_i32(s, val, a32, index, OPC); \ | 155 | Error *local_err = NULL; |
156 | - bool no_aa32 = false; | ||
157 | |||
158 | /* Use pc-relative instructions in system-mode */ | ||
159 | #ifndef CONFIG_USER_ONLY | ||
160 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
161 | cpu->isar.id_isar3 = u; | ||
87 | } | 162 | } |
88 | 163 | ||
89 | -static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | 164 | - /* Some features automatically imply others: */ |
90 | - int index, MemOp opc) | 165 | - if (arm_feature(env, ARM_FEATURE_V8)) { |
91 | -{ | 166 | - if (arm_feature(env, ARM_FEATURE_M)) { |
92 | - TCGv addr = gen_aa32_addr(s, a32, opc); | 167 | - set_feature(env, ARM_FEATURE_V7); |
93 | - tcg_gen_qemu_ld_i64(val, addr, index, opc); | 168 | - } else { |
169 | - set_feature(env, ARM_FEATURE_V7VE); | ||
170 | - } | ||
171 | - } | ||
94 | - | 172 | - |
95 | - /* Not needed for user-mode BE32, where we use MO_BE instead. */ | 173 | - /* |
96 | - if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | 174 | - * There exist AArch64 cpus without AArch32 support. When KVM |
97 | - tcg_gen_rotri_i64(val, val, 32); | 175 | - * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. |
176 | - * Similarly, we cannot check ID_AA64PFR0 without AArch64 support. | ||
177 | - * As a general principle, we also do not make ID register | ||
178 | - * consistency checks anywhere unless using TCG, because only | ||
179 | - * for TCG would a consistency-check failure be a QEMU bug. | ||
180 | - */ | ||
181 | - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
182 | - no_aa32 = !cpu_isar_feature(aa64_aa32, cpu); | ||
98 | - } | 183 | - } |
99 | - | 184 | - |
100 | - tcg_temp_free(addr); | 185 | - if (arm_feature(env, ARM_FEATURE_V7VE)) { |
101 | -} | 186 | - /* v7 Virtualization Extensions. In real hardware this implies |
187 | - * EL2 and also the presence of the Security Extensions. | ||
188 | - * For QEMU, for backwards-compatibility we implement some | ||
189 | - * CPUs or CPU configs which have no actual EL2 or EL3 but do | ||
190 | - * include the various other features that V7VE implies. | ||
191 | - * Presence of EL2 itself is ARM_FEATURE_EL2, and of the | ||
192 | - * Security Extensions is ARM_FEATURE_EL3. | ||
193 | - */ | ||
194 | - assert(!tcg_enabled() || no_aa32 || | ||
195 | - cpu_isar_feature(aa32_arm_div, cpu)); | ||
196 | - set_feature(env, ARM_FEATURE_LPAE); | ||
197 | - set_feature(env, ARM_FEATURE_V7); | ||
198 | - } | ||
199 | - if (arm_feature(env, ARM_FEATURE_V7)) { | ||
200 | - set_feature(env, ARM_FEATURE_VAPA); | ||
201 | - set_feature(env, ARM_FEATURE_THUMB2); | ||
202 | - set_feature(env, ARM_FEATURE_MPIDR); | ||
203 | - if (!arm_feature(env, ARM_FEATURE_M)) { | ||
204 | - set_feature(env, ARM_FEATURE_V6K); | ||
205 | - } else { | ||
206 | - set_feature(env, ARM_FEATURE_V6); | ||
207 | - } | ||
102 | - | 208 | - |
103 | static inline void gen_aa32_ld64(DisasContext *s, TCGv_i64 val, | 209 | - /* Always define VBAR for V7 CPUs even if it doesn't exist in |
104 | TCGv_i32 a32, int index) | 210 | - * non-EL3 configs. This is needed by some legacy boards. |
105 | { | 211 | - */ |
106 | - gen_aa32_ld_i64(s, val, a32, index, MO_Q | s->be_data); | 212 | - set_feature(env, ARM_FEATURE_VBAR); |
107 | -} | 213 | - } |
108 | - | 214 | - if (arm_feature(env, ARM_FEATURE_V6K)) { |
109 | -static void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | 215 | - set_feature(env, ARM_FEATURE_V6); |
110 | - int index, MemOp opc) | 216 | - set_feature(env, ARM_FEATURE_MVFR); |
111 | -{ | 217 | - } |
112 | - TCGv addr = gen_aa32_addr(s, a32, opc); | 218 | - if (arm_feature(env, ARM_FEATURE_V6)) { |
113 | - | 219 | - set_feature(env, ARM_FEATURE_V5); |
114 | - /* Not needed for user-mode BE32, where we use MO_BE instead. */ | 220 | - if (!arm_feature(env, ARM_FEATURE_M)) { |
115 | - if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | 221 | - assert(!tcg_enabled() || no_aa32 || |
116 | - TCGv_i64 tmp = tcg_temp_new_i64(); | 222 | - cpu_isar_feature(aa32_jazelle, cpu)); |
117 | - tcg_gen_rotri_i64(tmp, val, 32); | 223 | - set_feature(env, ARM_FEATURE_AUXCR); |
118 | - tcg_gen_qemu_st_i64(tmp, addr, index, opc); | 224 | - } |
119 | - tcg_temp_free_i64(tmp); | 225 | - } |
120 | - } else { | 226 | - if (arm_feature(env, ARM_FEATURE_V5)) { |
121 | - tcg_gen_qemu_st_i64(val, addr, index, opc); | 227 | - set_feature(env, ARM_FEATURE_V4T); |
122 | - } | 228 | - } |
123 | - tcg_temp_free(addr); | 229 | - if (arm_feature(env, ARM_FEATURE_LPAE)) { |
124 | + gen_aa32_ld_i64(s, val, a32, index, MO_Q); | 230 | - set_feature(env, ARM_FEATURE_V7MP); |
125 | } | 231 | - } |
126 | 232 | - if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { | |
127 | static inline void gen_aa32_st64(DisasContext *s, TCGv_i64 val, | 233 | - set_feature(env, ARM_FEATURE_CBAR); |
128 | TCGv_i32 a32, int index) | 234 | - } |
129 | { | 235 | - if (arm_feature(env, ARM_FEATURE_THUMB2) && |
130 | - gen_aa32_st_i64(s, val, a32, index, MO_Q | s->be_data); | 236 | - !arm_feature(env, ARM_FEATURE_M)) { |
131 | + gen_aa32_st_i64(s, val, a32, index, MO_Q); | 237 | - set_feature(env, ARM_FEATURE_THUMB_DSP); |
132 | } | 238 | - } |
133 | 239 | ||
134 | DO_GEN_LD(8u, MO_UB) | 240 | /* |
135 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 241 | * We rely on no XScale CPU having VFP so we can use the same bits in the |
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 | -- | 242 | -- |
156 | 2.20.1 | 243 | 2.34.1 |
157 | |||
158 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | M-profile CPUs generally allow configuration of the number of MPU |
---|---|---|---|
2 | regions that they have. We don't currently model this, so our | ||
3 | implementations of some of the board models provide CPUs with the | ||
4 | wrong number of regions. RTOSes like Zephyr that hardcode the | ||
5 | expected number of regions may therefore not run on the model if they | ||
6 | are set up to run on real hardware. | ||
2 | 7 | ||
3 | Split out a helper function from mte_checkN to perform | 8 | Add properties mpu-ns-regions and mpu-s-regions to the ARMV7M object, |
4 | all of the checking and address manpulation. So far, | 9 | matching the ability of hardware to configure the number of Secure |
5 | just use this in mte_checkN itself. | 10 | and NonSecure regions separately. Our actual CPU implementation |
11 | doesn't currently support that, and it happens that none of the MPS | ||
12 | boards we model set the number of regions differently for Secure vs | ||
13 | NonSecure, so we provide an interface to the boards and SoCs that | ||
14 | won't need to change if we ever do add that functionality in future, | ||
15 | but make it an error to configure the two properties to different | ||
16 | values. | ||
6 | 17 | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 18 | (The property name on the CPU is the somewhat misnamed-for-M-profile |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 19 | "pmsav7-dregion", so we don't follow that naming convention for |
9 | Message-id: 20210416183106.1516563-3-richard.henderson@linaro.org | 20 | the properties here. The TRM doesn't say what the CPU configuration |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 21 | variable names are, so we pick something, and follow the lowercase |
22 | convention we already have for properties here.) | ||
23 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
26 | Message-id: 20230724174335.2150499-3-peter.maydell@linaro.org | ||
12 | --- | 27 | --- |
13 | target/arm/mte_helper.c | 52 +++++++++++++++++++++++++++++++---------- | 28 | include/hw/arm/armv7m.h | 8 ++++++++ |
14 | 1 file changed, 40 insertions(+), 12 deletions(-) | 29 | hw/arm/armv7m.c | 21 +++++++++++++++++++++ |
30 | 2 files changed, 29 insertions(+) | ||
15 | 31 | ||
16 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | 32 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h |
17 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/mte_helper.c | 34 | --- a/include/hw/arm/armv7m.h |
19 | +++ b/target/arm/mte_helper.c | 35 | +++ b/include/hw/arm/armv7m.h |
20 | @@ -XXX,XX +XXX,XX @@ static int checkN(uint8_t *mem, int odd, int cmp, int count) | 36 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(ARMv7MState, ARMV7M) |
21 | return n; | 37 | * + Property "vfp": enable VFP (forwarded to CPU object) |
22 | } | 38 | * + Property "dsp": enable DSP (forwarded to CPU object) |
23 | 39 | * + Property "enable-bitband": expose bitbanded IO | |
24 | -uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | 40 | + * + Property "mpu-ns-regions": number of Non-Secure MPU regions (forwarded |
25 | - uint64_t ptr, uintptr_t ra) | 41 | + * to CPU object pmsav7-dregion property; default is whatever the default |
26 | +/** | 42 | + * for the CPU is) |
27 | + * mte_probe_int() - helper for mte_probe and mte_check | 43 | + * + Property "mpu-s-regions": number of Secure MPU regions (default is |
28 | + * @env: CPU environment | 44 | + * whatever the default for the CPU is; must currently be set to the same |
29 | + * @desc: MTEDESC descriptor | 45 | + * value as mpu-ns-regions if the CPU implements the Security Extension) |
30 | + * @ptr: virtual address of the base of the access | 46 | * + Clock input "refclk" is the external reference clock for the systick timers |
31 | + * @fault: return virtual address of the first check failure | 47 | * + Clock input "cpuclk" is the main CPU clock |
32 | + * | 48 | */ |
33 | + * Internal routine for both mte_probe and mte_check. | 49 | @@ -XXX,XX +XXX,XX @@ struct ARMv7MState { |
34 | + * Return zero on failure, filling in *fault. | 50 | Object *idau; |
35 | + * Return negative on trivial success for tbi disabled. | 51 | uint32_t init_svtor; |
36 | + * Return positive on success with tbi enabled. | 52 | uint32_t init_nsvtor; |
37 | + */ | 53 | + uint32_t mpu_ns_regions; |
38 | +static int mte_probe_int(CPUARMState *env, uint32_t desc, uint64_t ptr, | 54 | + uint32_t mpu_s_regions; |
39 | + uintptr_t ra, uint32_t total, uint64_t *fault) | 55 | bool enable_bitband; |
40 | { | 56 | bool start_powered_off; |
41 | int mmu_idx, ptr_tag, bit55; | 57 | bool vfp; |
42 | uint64_t ptr_last, prev_page, next_page; | 58 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c |
43 | uint64_t tag_first, tag_last; | 59 | index XXXXXXX..XXXXXXX 100644 |
44 | uint64_t tag_byte_first, tag_byte_last; | 60 | --- a/hw/arm/armv7m.c |
45 | - uint32_t total, tag_count, tag_size, n, c; | 61 | +++ b/hw/arm/armv7m.c |
46 | + uint32_t tag_count, tag_size, n, c; | 62 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) |
47 | uint8_t *mem1, *mem2; | ||
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 | } | 63 | } |
90 | } | 64 | } |
91 | 65 | ||
92 | + if (likely(n == tag_count)) { | 66 | + /* |
93 | + return 1; | 67 | + * Real M-profile hardware can be configured with a different number of |
68 | + * MPU regions for Secure vs NonSecure. QEMU's CPU implementation doesn't | ||
69 | + * support that yet, so catch attempts to select that. | ||
70 | + */ | ||
71 | + if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) && | ||
72 | + s->mpu_ns_regions != s->mpu_s_regions) { | ||
73 | + error_setg(errp, | ||
74 | + "mpu-ns-regions and mpu-s-regions properties must have the same value"); | ||
75 | + return; | ||
76 | + } | ||
77 | + if (s->mpu_ns_regions != UINT_MAX && | ||
78 | + object_property_find(OBJECT(s->cpu), "pmsav7-dregion")) { | ||
79 | + if (!object_property_set_uint(OBJECT(s->cpu), "pmsav7-dregion", | ||
80 | + s->mpu_ns_regions, errp)) { | ||
81 | + return; | ||
82 | + } | ||
94 | + } | 83 | + } |
95 | + | 84 | + |
96 | /* | 85 | /* |
97 | * If we failed, we know which granule. For the first granule, the | 86 | * Tell the CPU where the NVIC is; it will fail realize if it doesn't |
98 | * failure address is @ptr, the first byte accessed. Otherwise the | 87 | * have one. Similarly, tell the NVIC where its CPU is. |
99 | * failure address is the first byte of the nth granule. | 88 | @@ -XXX,XX +XXX,XX @@ static Property armv7m_properties[] = { |
100 | */ | 89 | false), |
101 | - if (unlikely(n < tag_count)) { | 90 | DEFINE_PROP_BOOL("vfp", ARMv7MState, vfp, true), |
102 | - uint64_t fault = (n == 0 ? ptr : tag_first + n * TAG_GRANULE); | 91 | DEFINE_PROP_BOOL("dsp", ARMv7MState, dsp, true), |
103 | - mte_check_fail(env, desc, fault, ra); | 92 | + DEFINE_PROP_UINT32("mpu-ns-regions", ARMv7MState, mpu_ns_regions, UINT_MAX), |
104 | + if (n > 0) { | 93 | + DEFINE_PROP_UINT32("mpu-s-regions", ARMv7MState, mpu_s_regions, UINT_MAX), |
105 | + *fault = tag_first + n * TAG_GRANULE; | 94 | DEFINE_PROP_END_OF_LIST(), |
106 | } | 95 | }; |
107 | + return 0; | ||
108 | +} | ||
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 | + | ||
118 | + if (unlikely(ret == 0)) { | ||
119 | + mte_check_fail(env, desc, fault, ra); | ||
120 | + } else if (ret < 0) { | ||
121 | + return ptr; | ||
122 | + } | ||
123 | return useronly_clean_ptr(ptr); | ||
124 | } | ||
125 | 96 | ||
126 | -- | 97 | -- |
127 | 2.20.1 | 98 | 2.34.1 |
128 | 99 | ||
129 | 100 | 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 | 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> | ||
18 | --- | ||
19 | target/arm/mte_helper.c | 109 +++++++++++++--------------------------- | ||
20 | 1 file changed, 35 insertions(+), 74 deletions(-) | ||
21 | |||
22 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/target/arm/mte_helper.c | ||
25 | +++ b/target/arm/mte_helper.c | ||
26 | @@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc, | ||
27 | } | ||
28 | } | ||
29 | |||
30 | -/* | ||
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 | +{ | ||
114 | + uint64_t fault; | ||
115 | + uint32_t total = FIELD_EX32(desc, MTEDESC, ESIZE); | ||
116 | + int ret = mte_probe_int(env, desc, ptr, ra, total, &fault); | ||
117 | + | ||
118 | + if (unlikely(ret == 0)) { | ||
119 | + mte_check_fail(env, desc, fault, ra); | ||
120 | + } else if (ret < 0) { | ||
121 | + return ptr; | ||
122 | + } | ||
123 | + return useronly_clean_ptr(ptr); | ||
124 | +} | ||
125 | + | ||
126 | +uint64_t HELPER(mte_check1)(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
127 | +{ | ||
128 | + return mte_check1(env, desc, ptr, GETPC()); | ||
129 | +} | ||
130 | + | ||
131 | +/* | ||
132 | + * No-fault version of mte_check1, to be used by SVE for MemSingleNF. | ||
133 | + * Returns false if the access is Checked and the check failed. This | ||
134 | + * is only intended to probe the tag -- the validity of the page must | ||
135 | + * be checked beforehand. | ||
136 | + */ | ||
137 | +bool mte_probe1(CPUARMState *env, uint32_t desc, uint64_t ptr) | ||
138 | +{ | ||
139 | + uint64_t fault; | ||
140 | + uint32_t total = FIELD_EX32(desc, MTEDESC, ESIZE); | ||
141 | + int ret = mte_probe_int(env, desc, ptr, 0, total, &fault); | ||
142 | + | ||
143 | + return ret != 0; | ||
144 | +} | ||
145 | + | ||
146 | /* | ||
147 | * Perform an MTE checked access for DC_ZVA. | ||
148 | */ | ||
149 | -- | ||
150 | 2.20.1 | ||
151 | |||
152 | 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 PSTATE_SS -> PSTATE__SS in the 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-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 | ||
22 | --- a/target/arm/cpu.h | ||
23 | +++ b/target/arm/cpu.h | ||
24 | @@ -XXX,XX +XXX,XX @@ typedef ARMCPU ArchCPU; | ||
25 | */ | ||
26 | FIELD(TBFLAG_ANY, AARCH64_STATE, 31, 1) | ||
27 | FIELD(TBFLAG_ANY, SS_ACTIVE, 30, 1) | ||
28 | -FIELD(TBFLAG_ANY, PSTATE_SS, 29, 1) /* Not cached. */ | ||
29 | +FIELD(TBFLAG_ANY, PSTATE__SS, 29, 1) /* Not cached. */ | ||
30 | FIELD(TBFLAG_ANY, BE_DATA, 28, 1) | ||
31 | FIELD(TBFLAG_ANY, MMUIDX, 24, 4) | ||
32 | /* Target EL if we take a floating-point-disabled exception */ | ||
33 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
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 | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/translate-a64.c | ||
54 | +++ b/target/arm/translate-a64.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
56 | * end the TB | ||
57 | */ | ||
58 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | ||
59 | - dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | ||
60 | + dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE__SS); | ||
61 | dc->is_ldex = false; | ||
62 | dc->debug_target_el = FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | ||
63 | |||
64 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/translate.c | ||
67 | +++ b/target/arm/translate.c | ||
68 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
69 | * end the TB | ||
70 | */ | ||
71 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | ||
72 | - dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | ||
73 | + dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE__SS); | ||
74 | dc->is_ldex = false; | ||
75 | |||
76 | dc->page_start = dc->base.pc_first & TARGET_PAGE_MASK; | ||
77 | -- | ||
78 | 2.20.1 | ||
79 | |||
80 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | We're about to split tbflags into two parts. These macros | ||
4 | will ensure that the correct part is used with the correct | ||
5 | set of bits. | ||
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-5-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 22 +++++++++- | ||
13 | target/arm/helper-a64.c | 2 +- | ||
14 | target/arm/helper.c | 85 +++++++++++++++++--------------------- | ||
15 | target/arm/translate-a64.c | 36 ++++++++-------- | ||
16 | target/arm/translate.c | 48 ++++++++++----------- | ||
17 | 5 files changed, 101 insertions(+), 92 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_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 | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/arm/helper-a64.c | ||
62 | +++ b/target/arm/helper-a64.c | ||
63 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) | ||
64 | * the hflags rebuild, since we can pull the composite TBII field | ||
65 | * from there. | ||
66 | */ | ||
67 | - tbii = FIELD_EX32(env->hflags, TBFLAG_A64, TBII); | ||
68 | + tbii = EX_TBFLAG_A64(env->hflags, TBII); | ||
69 | if ((tbii >> extract64(new_pc, 55, 1)) & 1) { | ||
70 | /* TBI is enabled. */ | ||
71 | int core_mmu_idx = cpu_mmu_index(env, false); | ||
72 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/target/arm/helper.c | ||
75 | +++ b/target/arm/helper.c | ||
76 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | ||
77 | static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | ||
78 | ARMMMUIdx mmu_idx, uint32_t flags) | ||
79 | { | ||
80 | - flags = FIELD_DP32(flags, TBFLAG_ANY, FPEXC_EL, fp_el); | ||
81 | - flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, | ||
82 | - arm_to_core_mmu_idx(mmu_idx)); | ||
83 | + DP_TBFLAG_ANY(flags, FPEXC_EL, fp_el); | ||
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 | } | ||
173 | - flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); | ||
174 | - flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); | ||
175 | + DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); | ||
176 | + DP_TBFLAG_A64(flags, ZCR_LEN, zcr_len); | ||
177 | } | ||
178 | |||
179 | sctlr = regime_sctlr(env, stage1); | ||
180 | |||
181 | if (arm_cpu_data_is_big_endian_a64(el, sctlr)) { | ||
182 | - flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); | ||
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 | } | ||
194 | } | ||
195 | |||
196 | if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { | ||
197 | /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */ | ||
198 | if (sctlr & (el == 0 ? SCTLR_BT0 : SCTLR_BT1)) { | ||
199 | - flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1); | ||
200 | + DP_TBFLAG_A64(flags, BT, 1); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
205 | case ARMMMUIdx_SE10_1: | ||
206 | case ARMMMUIdx_SE10_1_PAN: | ||
207 | /* TODO: ARMv8.3-NV */ | ||
208 | - flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); | ||
209 | + DP_TBFLAG_A64(flags, UNPRIV, 1); | ||
210 | break; | ||
211 | case ARMMMUIdx_E20_2: | ||
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 | } | ||
235 | /* And again for unprivileged accesses, if required. */ | ||
236 | - if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV) | ||
237 | + if (EX_TBFLAG_A64(flags, UNPRIV) | ||
238 | && tbid | ||
239 | && !(env->pstate & PSTATE_TCO) | ||
240 | && (sctlr & SCTLR_TCF0) | ||
241 | && allocation_tag_access_enabled(env, 0, sctlr)) { | ||
242 | - flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1); | ||
243 | + DP_TBFLAG_A64(flags, MTE0_ACTIVE, 1); | ||
244 | } | ||
245 | /* Cache TCMA as well as TBI. */ | ||
246 | - flags = FIELD_DP32(flags, TBFLAG_A64, TCMA, | ||
247 | - aa64_va_parameter_tcma(tcr, mmu_idx)); | ||
248 | + DP_TBFLAG_A64(flags, TCMA, aa64_va_parameter_tcma(tcr, mmu_idx)); | ||
249 | } | ||
250 | |||
251 | return rebuild_hflags_common(env, fp_el, mmu_idx, flags); | ||
252 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
253 | *cs_base = 0; | ||
254 | assert_hflags_rebuild_correctly(env); | ||
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 | } | ||
263 | } else { | ||
264 | *pc = env->regs[15]; | ||
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 | -- | ||
486 | 2.20.1 | ||
487 | |||
488 | 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 |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
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> | ||
14 | --- | ||
15 | target/arm/translate.h | 24 ++++++++ | ||
16 | target/arm/translate.c | 100 +++++++++++++++++--------------- | ||
17 | target/arm/translate-neon.c.inc | 9 +-- | ||
18 | 3 files changed, 79 insertions(+), 54 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/translate.h | ||
23 | +++ b/target/arm/translate.h | ||
24 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_ptr fpstatus_ptr(ARMFPStatusFlavour flavour) | ||
25 | return statusptr; | ||
26 | } | ||
27 | |||
28 | +/** | ||
29 | + * finalize_memop: | ||
30 | + * @s: DisasContext | ||
31 | + * @opc: size+sign+align of the memory operation | ||
32 | + * | ||
33 | + * Build the complete MemOp for a memory operation, including alignment | ||
34 | + * and endianness. | ||
35 | + * | ||
36 | + * If (op & MO_AMASK) then the operation already contains the required | ||
37 | + * alignment, e.g. for AccType_ATOMIC. Otherwise, this an optionally | ||
38 | + * unaligned operation, e.g. for AccType_NORMAL. | ||
39 | + * | ||
40 | + * In the latter case, there are configuration bits that require alignment, | ||
41 | + * and this is applied here. Note that there is no way to indicate that | ||
42 | + * no alignment should ever be enforced; this must be handled manually. | ||
43 | + */ | ||
44 | +static inline MemOp finalize_memop(DisasContext *s, MemOp opc) | ||
45 | +{ | ||
46 | + if (s->align_mem && !(opc & MO_AMASK)) { | ||
47 | + opc |= MO_ALIGN; | ||
48 | + } | ||
49 | + return opc | s->be_data; | ||
50 | +} | ||
51 | + | ||
52 | #endif /* TARGET_ARM_TRANSLATE_H */ | ||
53 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/translate.c | ||
56 | +++ b/target/arm/translate.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static inline void store_reg_from_load(DisasContext *s, int reg, TCGv_i32 var) | ||
58 | #define IS_USER_ONLY 0 | ||
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 | } | ||
79 | |||
80 | +/* | ||
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 | +{ | ||
87 | + TCGv addr = gen_aa32_addr(s, a32, opc); | ||
88 | + tcg_gen_qemu_ld_i32(val, addr, index, opc); | ||
89 | + tcg_temp_free(addr); | ||
90 | +} | ||
91 | + | ||
92 | +static void gen_aa32_st_internal_i32(DisasContext *s, TCGv_i32 val, | ||
93 | + TCGv_i32 a32, int index, MemOp opc) | ||
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 | { | ||
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 | -- | ||
317 | 2.20.1 | ||
318 | |||
319 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The IoTKit, SSE200 and SSE300 all default to 8 MPU regions. The |
---|---|---|---|
2 | 2 | MPS2/MPS3 FPGA images don't override these except in the case of | |
3 | This is the only caller. Adjust some commentary to talk | 3 | AN547, which uses 16 MPU regions. |
4 | about SCTLR_B instead of the vanishing function. | 4 | |
5 | 5 | Define properties on the ARMSSE object for the MPU regions (using the | |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | same names as the documented RTL configuration settings, and |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | following the pattern we already have for this device of using |
8 | Message-id: 20210419202257.161730-13-richard.henderson@linaro.org | 8 | all-caps names as the RTL does), and set them in the board code. |
9 | |||
10 | We don't actually need to override the default except on AN547, | ||
11 | but it's simpler code to have the board code set them always | ||
12 | rather than tracking which board subtypes want to set them to | ||
13 | a non-default value separately from what that value is. | ||
14 | |||
15 | Tho overall effect is that for mps2-an505, mps2-an521 and mps3-an524 | ||
16 | we now correctly use 8 MPU regions, while mps3-an547 stays at its | ||
17 | current 16 regions. | ||
18 | |||
19 | It's possible some guest code wrongly depended on the previous | ||
20 | incorrectly modeled number of memory regions. (Such guest code | ||
21 | should ideally check the number of regions via the MPU_TYPE | ||
22 | register.) The old behaviour can be obtained with additional | ||
23 | -global arguments to QEMU: | ||
24 | |||
25 | For mps2-an521 and mps2-an524: | ||
26 | -global sse-200.CPU0_MPU_NS=16 -global sse-200.CPU0_MPU_S=16 -global sse-200.CPU1_MPU_NS=16 -global sse-200.CPU1_MPU_S=16 | ||
27 | |||
28 | For mps2-an505: | ||
29 | -global sse-200.CPU0_MPU_NS=16 -global sse-200.CPU0_MPU_S=16 | ||
30 | |||
31 | NB that the way the implementation allows this use of -global | ||
32 | is slightly fragile: if the board code explicitly sets the | ||
33 | properties on the sse-200 object, this overrides the -global | ||
34 | command line option. So we rely on: | ||
35 | - the boards that need fixing all happen to use the SSE defaults | ||
36 | - we can write the board code to only set the property if it | ||
37 | is different from the default, rather than having all boards | ||
38 | explicitly set the property | ||
39 | - the board that does need to use a non-default value happens | ||
40 | to need to set it to the same value (16) we previously used | ||
41 | This works, but there are some kinds of refactoring of the | ||
42 | mps2-tz.c code that would break the support for -global here. | ||
43 | |||
44 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1772 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 45 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
46 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
47 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
48 | Message-id: 20230724174335.2150499-4-peter.maydell@linaro.org | ||
10 | --- | 49 | --- |
11 | target/arm/translate.c | 37 ++++++++++++++++--------------------- | 50 | include/hw/arm/armsse.h | 5 +++++ |
12 | 1 file changed, 16 insertions(+), 21 deletions(-) | 51 | hw/arm/armsse.c | 16 ++++++++++++++++ |
13 | 52 | hw/arm/mps2-tz.c | 29 +++++++++++++++++++++++++++++ | |
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 53 | 3 files changed, 50 insertions(+) |
54 | |||
55 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | 56 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 57 | --- a/include/hw/arm/armsse.h |
17 | +++ b/target/arm/translate.c | 58 | +++ b/include/hw/arm/armsse.h |
18 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 59 | @@ -XXX,XX +XXX,XX @@ |
19 | gen_aa32_st_i32(s, val, a32, index, OPC); \ | 60 | * (matching the hardware) is that for CPU0 in an IoTKit and CPU1 in an |
20 | } | 61 | * SSE-200 both are present; CPU0 in an SSE-200 has neither. |
21 | 62 | * Since the IoTKit has only one CPU, it does not have the CPU1_* properties. | |
22 | -static inline void gen_aa32_frob64(DisasContext *s, TCGv_i64 val) | 63 | + * + QOM properties "CPU0_MPU_NS", "CPU0_MPU_S", "CPU1_MPU_NS" and "CPU1_MPU_S" |
23 | -{ | 64 | + * which set the number of MPU regions on the CPUs. If there is only one |
24 | - /* Not needed for user-mode BE32, where we use MO_BE instead. */ | 65 | + * CPU the CPU1 properties are not present. |
25 | - if (!IS_USER_ONLY && s->sctlr_b) { | 66 | * + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts for CPU 0, |
26 | - tcg_gen_rotri_i64(val, val, 32); | 67 | * which are wired to its NVIC lines 32 .. n+32 |
27 | - } | 68 | * + Named GPIO inputs "EXP_CPU1_IRQ" 0..n are the expansion interrupts for |
28 | -} | 69 | @@ -XXX,XX +XXX,XX @@ struct ARMSSE { |
29 | - | 70 | uint32_t exp_numirq; |
30 | static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | 71 | uint32_t sram_addr_width; |
31 | int index, MemOp opc) | 72 | uint32_t init_svtor; |
73 | + uint32_t cpu_mpu_ns[SSE_MAX_CPUS]; | ||
74 | + uint32_t cpu_mpu_s[SSE_MAX_CPUS]; | ||
75 | bool cpu_fpu[SSE_MAX_CPUS]; | ||
76 | bool cpu_dsp[SSE_MAX_CPUS]; | ||
77 | }; | ||
78 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/hw/arm/armsse.c | ||
81 | +++ b/hw/arm/armsse.c | ||
82 | @@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = { | ||
83 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
84 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), | ||
85 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true), | ||
86 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), | ||
87 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), | ||
88 | DEFINE_PROP_END_OF_LIST() | ||
89 | }; | ||
90 | |||
91 | @@ -XXX,XX +XXX,XX @@ static Property sse200_properties[] = { | ||
92 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], false), | ||
93 | DEFINE_PROP_BOOL("CPU1_FPU", ARMSSE, cpu_fpu[1], true), | ||
94 | DEFINE_PROP_BOOL("CPU1_DSP", ARMSSE, cpu_dsp[1], true), | ||
95 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), | ||
96 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), | ||
97 | + DEFINE_PROP_UINT32("CPU1_MPU_NS", ARMSSE, cpu_mpu_ns[1], 8), | ||
98 | + DEFINE_PROP_UINT32("CPU1_MPU_S", ARMSSE, cpu_mpu_s[1], 8), | ||
99 | DEFINE_PROP_END_OF_LIST() | ||
100 | }; | ||
101 | |||
102 | @@ -XXX,XX +XXX,XX @@ static Property sse300_properties[] = { | ||
103 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
104 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), | ||
105 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true), | ||
106 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), | ||
107 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), | ||
108 | DEFINE_PROP_END_OF_LIST() | ||
109 | }; | ||
110 | |||
111 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
112 | return; | ||
113 | } | ||
114 | } | ||
115 | + if (!object_property_set_uint(cpuobj, "mpu-ns-regions", | ||
116 | + s->cpu_mpu_ns[i], errp)) { | ||
117 | + return; | ||
118 | + } | ||
119 | + if (!object_property_set_uint(cpuobj, "mpu-s-regions", | ||
120 | + s->cpu_mpu_s[i], errp)) { | ||
121 | + return; | ||
122 | + } | ||
123 | |||
124 | if (i > 0) { | ||
125 | memory_region_add_subregion_overlap(&s->cpu_container[i], 0, | ||
126 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
127 | index XXXXXXX..XXXXXXX 100644 | ||
128 | --- a/hw/arm/mps2-tz.c | ||
129 | +++ b/hw/arm/mps2-tz.c | ||
130 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineClass { | ||
131 | int uart_overflow_irq; /* number of the combined UART overflow IRQ */ | ||
132 | uint32_t init_svtor; /* init-svtor setting for SSE */ | ||
133 | uint32_t sram_addr_width; /* SRAM_ADDR_WIDTH setting for SSE */ | ||
134 | + uint32_t cpu0_mpu_ns; /* CPU0_MPU_NS setting for SSE */ | ||
135 | + uint32_t cpu0_mpu_s; /* CPU0_MPU_S setting for SSE */ | ||
136 | + uint32_t cpu1_mpu_ns; /* CPU1_MPU_NS setting for SSE */ | ||
137 | + uint32_t cpu1_mpu_s; /* CPU1_MPU_S setting for SSE */ | ||
138 | const RAMInfo *raminfo; | ||
139 | const char *armsse_type; | ||
140 | uint32_t boot_ram_size; /* size of ram at address 0; 0 == find in raminfo */ | ||
141 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE) | ||
142 | #define MPS3_DDR_SIZE (2 * GiB) | ||
143 | #endif | ||
144 | |||
145 | +/* For cpu{0,1}_mpu_{ns,s}, means "leave at SSE's default value" */ | ||
146 | +#define MPU_REGION_DEFAULT UINT32_MAX | ||
147 | + | ||
148 | static const uint32_t an505_oscclk[] = { | ||
149 | 40000000, | ||
150 | 24580000, | ||
151 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
152 | OBJECT(system_memory), &error_abort); | ||
153 | qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", mmc->numirq); | ||
154 | qdev_prop_set_uint32(iotkitdev, "init-svtor", mmc->init_svtor); | ||
155 | + if (mmc->cpu0_mpu_ns != MPU_REGION_DEFAULT) { | ||
156 | + qdev_prop_set_uint32(iotkitdev, "CPU0_MPU_NS", mmc->cpu0_mpu_ns); | ||
157 | + } | ||
158 | + if (mmc->cpu0_mpu_s != MPU_REGION_DEFAULT) { | ||
159 | + qdev_prop_set_uint32(iotkitdev, "CPU0_MPU_S", mmc->cpu0_mpu_s); | ||
160 | + } | ||
161 | + if (object_property_find(OBJECT(iotkitdev), "CPU1_MPU_NS")) { | ||
162 | + if (mmc->cpu1_mpu_ns != MPU_REGION_DEFAULT) { | ||
163 | + qdev_prop_set_uint32(iotkitdev, "CPU1_MPU_NS", mmc->cpu1_mpu_ns); | ||
164 | + } | ||
165 | + if (mmc->cpu1_mpu_s != MPU_REGION_DEFAULT) { | ||
166 | + qdev_prop_set_uint32(iotkitdev, "CPU1_MPU_S", mmc->cpu1_mpu_s); | ||
167 | + } | ||
168 | + } | ||
169 | qdev_prop_set_uint32(iotkitdev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); | ||
170 | qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk); | ||
171 | qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk); | ||
172 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_class_init(ObjectClass *oc, void *data) | ||
32 | { | 173 | { |
33 | TCGv addr = gen_aa32_addr(s, a32, opc); | 174 | MachineClass *mc = MACHINE_CLASS(oc); |
34 | tcg_gen_qemu_ld_i64(val, addr, index, opc); | 175 | IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(oc); |
35 | - gen_aa32_frob64(s, val); | 176 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_CLASS(oc); |
177 | |||
178 | mc->init = mps2tz_common_init; | ||
179 | mc->reset = mps2_machine_reset; | ||
180 | iic->check = mps2_tz_idau_check; | ||
36 | + | 181 | + |
37 | + /* Not needed for user-mode BE32, where we use MO_BE instead. */ | 182 | + /* Most machines leave these at the SSE defaults */ |
38 | + if (!IS_USER_ONLY && s->sctlr_b) { | 183 | + mmc->cpu0_mpu_ns = MPU_REGION_DEFAULT; |
39 | + tcg_gen_rotri_i64(val, val, 32); | 184 | + mmc->cpu0_mpu_s = MPU_REGION_DEFAULT; |
40 | + } | 185 | + mmc->cpu1_mpu_ns = MPU_REGION_DEFAULT; |
41 | + | 186 | + mmc->cpu1_mpu_s = MPU_REGION_DEFAULT; |
42 | tcg_temp_free(addr); | ||
43 | } | 187 | } |
44 | 188 | ||
45 | @@ -XXX,XX +XXX,XX @@ static void gen_load_exclusive(DisasContext *s, int rt, int rt2, | 189 | static void mps2tz_set_default_ram_info(MPS2TZMachineClass *mmc) |
46 | TCGv_i32 tmp2 = tcg_temp_new_i32(); | 190 | @@ -XXX,XX +XXX,XX @@ static void mps3tz_an547_class_init(ObjectClass *oc, void *data) |
47 | TCGv_i64 t64 = tcg_temp_new_i64(); | 191 | mmc->numirq = 96; |
48 | 192 | mmc->uart_overflow_irq = 48; | |
49 | - /* For AArch32, architecturally the 32-bit word at the lowest | 193 | mmc->init_svtor = 0x00000000; |
50 | + /* | 194 | + mmc->cpu0_mpu_s = mmc->cpu0_mpu_ns = 16; |
51 | + * For AArch32, architecturally the 32-bit word at the lowest | 195 | mmc->sram_addr_width = 21; |
52 | * address is always Rt and the one at addr+4 is Rt2, even if | 196 | mmc->raminfo = an547_raminfo; |
53 | * the CPU is big-endian. That means we don't want to do a | 197 | mmc->armsse_type = TYPE_SSE300; |
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 | + | ||
73 | + /* | ||
74 | + * For AArch32, architecturally the 32-bit word at the lowest | ||
75 | * address is always Rt and the one at addr+4 is Rt2, even if | ||
76 | * the CPU is big-endian. Since we're going to treat this as a | ||
77 | * single 64-bit BE store, we need to put the two halves in the | ||
78 | * opposite order for BE to LE, so that they end up in the right | ||
79 | - * places. | ||
80 | - * We don't want gen_aa32_frob64() because that does the wrong | ||
81 | - * thing for BE32 usermode. | ||
82 | + * places. We don't want gen_aa32_st_i64, because that checks | ||
83 | + * SCTLR_B as if for an architectural 64-bit access. | ||
84 | */ | ||
85 | if (s->be_data == MO_BE) { | ||
86 | tcg_gen_concat_i32_i64(n64, t2, t1); | ||
87 | -- | 198 | -- |
88 | 2.20.1 | 199 | 2.34.1 |
89 | 200 | ||
90 | 201 | 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-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 |