1 | First arm pullreq for 6.1 cycle. The big stuff here is RTH's alignment series. | 1 | Two small bugfixes, plus most of RTH's refactoring of cpregs |
---|---|---|---|
2 | handling. | ||
2 | 3 | ||
3 | thanks | ||
4 | -- PMM | 4 | -- PMM |
5 | 5 | ||
6 | The following changes since commit ccdf06c1db192152ac70a1dd974c624f566cb7d4: | 6 | The following changes since commit 1fba9dc71a170b3a05b9d3272dd8ecfe7f26e215: |
7 | 7 | ||
8 | Open 6.1 development tree (2021-04-30 11:15:40 +0100) | 8 | Merge tag 'pull-request-2022-05-04' of https://gitlab.com/thuth/qemu into staging (2022-05-04 08:07:02 -0700) |
9 | 9 | ||
10 | are available in the Git repository at: | 10 | are available in the Git repository at: |
11 | 11 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210430 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220505 |
13 | 13 | ||
14 | for you to fetch changes up to a6091108aa44e9017af4ca13c43f55a629e3744c: | 14 | for you to fetch changes up to 99a50d1a67c602126fc2b3a4812d3000eba9bf34: |
15 | 15 | ||
16 | hw/pci-host/gpex: Don't fault for unmapped parts of MMIO and PIO windows (2021-04-30 11:16:52 +0100) | 16 | target/arm: read access to performance counters from EL0 (2022-05-05 09:36:22 +0100) |
17 | 17 | ||
18 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
19 | target-arm queue: | 19 | target-arm queue: |
20 | * hw/pci-host/gpex: Don't fault for unmapped parts of MMIO and PIO windows | 20 | * Enable read access to performance counters from EL0 |
21 | * hw: add compat machines for 6.1 | 21 | * Enable SCTLR_EL1.BT0 for aarch64-linux-user |
22 | * Fault misaligned accesses where the architecture requires it | 22 | * Refactoring of cpreg handling |
23 | * Fix some corner cases of MTE faults (notably with misaligned accesses) | ||
24 | * Make Thumb store insns UNDEF for Rn==1111 | ||
25 | * hw/arm/smmuv3: Support 16K translation granule | ||
26 | 23 | ||
27 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
28 | Cornelia Huck (1): | 25 | Alex Zuepke (1): |
29 | hw: add compat machines for 6.1 | 26 | target/arm: read access to performance counters from EL0 |
30 | 27 | ||
31 | Kunkun Jiang (1): | 28 | Richard Henderson (22): |
32 | hw/arm/smmuv3: Support 16K translation granule | 29 | target/arm: Enable SCTLR_EL1.BT0 for aarch64-linux-user |
30 | target/arm: Split out cpregs.h | ||
31 | target/arm: Reorg CPAccessResult and access_check_cp_reg | ||
32 | target/arm: Replace sentinels with ARRAY_SIZE in cpregs.h | ||
33 | target/arm: Make some more cpreg data static const | ||
34 | target/arm: Reorg ARMCPRegInfo type field bits | ||
35 | target/arm: Avoid bare abort() or assert(0) | ||
36 | target/arm: Change cpreg access permissions to enum | ||
37 | target/arm: Name CPState type | ||
38 | target/arm: Name CPSecureState type | ||
39 | target/arm: Drop always-true test in define_arm_vh_e2h_redirects_aliases | ||
40 | target/arm: Store cpregs key in the hash table directly | ||
41 | target/arm: Merge allocation of the cpreg and its name | ||
42 | target/arm: Hoist computation of key in add_cpreg_to_hashtable | ||
43 | target/arm: Consolidate cpreg updates in add_cpreg_to_hashtable | ||
44 | target/arm: Use bool for is64 and ns in add_cpreg_to_hashtable | ||
45 | target/arm: Hoist isbanked computation in add_cpreg_to_hashtable | ||
46 | target/arm: Perform override check early in add_cpreg_to_hashtable | ||
47 | target/arm: Reformat comments in add_cpreg_to_hashtable | ||
48 | target/arm: Remove HOST_BIG_ENDIAN ifdef in add_cpreg_to_hashtable | ||
49 | target/arm: Add isar predicates for FEAT_Debugv8p2 | ||
50 | target/arm: Add isar_feature_{aa64,any}_ras | ||
33 | 51 | ||
34 | Peter Maydell (2): | 52 | target/arm/cpregs.h | 453 ++++++++++++++++++++++++++++++++++++++ |
35 | target/arm: Make Thumb store insns UNDEF for Rn==1111 | 53 | target/arm/cpu.h | 393 +++------------------------------ |
36 | hw/pci-host/gpex: Don't fault for unmapped parts of MMIO and PIO windows | 54 | hw/arm/pxa2xx.c | 2 +- |
37 | 55 | hw/arm/pxa2xx_pic.c | 2 +- | |
38 | Richard Henderson (39): | 56 | hw/intc/arm_gicv3_cpuif.c | 6 +- |
39 | target/arm: Fix mte_checkN | 57 | hw/intc/arm_gicv3_kvm.c | 3 +- |
40 | target/arm: Split out mte_probe_int | 58 | target/arm/cpu.c | 25 +-- |
41 | target/arm: Fix unaligned checks for mte_check1, mte_probe1 | 59 | target/arm/cpu64.c | 2 +- |
42 | test/tcg/aarch64: Add mte-5 | 60 | target/arm/cpu_tcg.c | 5 +- |
43 | target/arm: Replace MTEDESC ESIZE+TSIZE with SIZEM1 | 61 | target/arm/gdbstub.c | 5 +- |
44 | target/arm: Merge mte_check1, mte_checkN | 62 | target/arm/helper.c | 358 +++++++++++++----------------- |
45 | target/arm: Rename mte_probe1 to mte_probe | 63 | target/arm/hvf/hvf.c | 2 +- |
46 | target/arm: Simplify sve mte checking | 64 | target/arm/kvm-stub.c | 4 +- |
47 | target/arm: Remove log2_esize parameter to gen_mte_checkN | 65 | target/arm/kvm.c | 4 +- |
48 | target/arm: Fix decode of align in VLDST_single | 66 | target/arm/machine.c | 4 +- |
49 | target/arm: Rename TBFLAG_A32, SCTLR_B | 67 | target/arm/op_helper.c | 57 ++--- |
50 | target/arm: Rename TBFLAG_ANY, PSTATE_SS | 68 | target/arm/translate-a64.c | 14 +- |
51 | target/arm: Add wrapper macros for accessing tbflags | 69 | target/arm/translate-neon.c | 2 +- |
52 | target/arm: Introduce CPUARMTBFlags | 70 | target/arm/translate.c | 13 +- |
53 | target/arm: Move mode specific TB flags to tb->cs_base | 71 | tests/tcg/aarch64/bti-3.c | 42 ++++ |
54 | target/arm: Move TBFLAG_AM32 bits to the top | 72 | tests/tcg/aarch64/Makefile.target | 6 +- |
55 | target/arm: Move TBFLAG_ANY bits to the bottom | 73 | 21 files changed, 738 insertions(+), 664 deletions(-) |
56 | target/arm: Add ALIGN_MEM to TBFLAG_ANY | 74 | create mode 100644 target/arm/cpregs.h |
57 | target/arm: Adjust gen_aa32_{ld, st}_i32 for align+endianness | 75 | create mode 100644 tests/tcg/aarch64/bti-3.c |
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 | |||
79 | include/hw/boards.h | 3 + | ||
80 | include/hw/i386/pc.h | 3 + | ||
81 | include/hw/pci-host/gpex.h | 4 + | ||
82 | target/arm/cpu.h | 105 ++++++++++----- | ||
83 | target/arm/helper-a64.h | 3 +- | ||
84 | target/arm/internals.h | 11 +- | ||
85 | target/arm/translate-a64.h | 2 +- | ||
86 | target/arm/translate.h | 38 ++++++ | ||
87 | target/arm/neon-ls.decode | 4 +- | ||
88 | hw/arm/smmuv3.c | 6 +- | ||
89 | hw/arm/virt.c | 7 +- | ||
90 | hw/core/machine.c | 5 + | ||
91 | hw/i386/pc.c | 3 + | ||
92 | hw/i386/pc_piix.c | 14 +- | ||
93 | hw/i386/pc_q35.c | 13 +- | ||
94 | hw/pci-host/gpex.c | 56 +++++++- | ||
95 | hw/ppc/spapr.c | 17 ++- | ||
96 | hw/s390x/s390-virtio-ccw.c | 14 +- | ||
97 | target/arm/helper-a64.c | 2 +- | ||
98 | target/arm/helper.c | 162 ++++++++++++---------- | ||
99 | target/arm/mte_helper.c | 185 ++++++++++--------------- | ||
100 | target/arm/sve_helper.c | 100 +++++--------- | ||
101 | target/arm/translate-a64.c | 236 ++++++++++++++++---------------- | ||
102 | target/arm/translate-sve.c | 11 +- | ||
103 | target/arm/translate.c | 274 ++++++++++++++++++++++---------------- | ||
104 | tests/tcg/aarch64/mte-5.c | 44 ++++++ | ||
105 | target/arm/translate-neon.c.inc | 117 ++++++++++++---- | ||
106 | target/arm/translate-vfp.c.inc | 20 +-- | ||
107 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
108 | 29 files changed, 878 insertions(+), 583 deletions(-) | ||
109 | create mode 100644 tests/tcg/aarch64/mte-5.c | ||
110 | 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 |
Deleted patch | |||
---|---|---|---|
1 | The Arm ARM specifies that for Thumb encodings of the various plain | ||
2 | store insns, if the Rn field is 1111 then we must UNDEF. This is | ||
3 | different from the Arm encodings, where this case is either | ||
4 | UNPREDICTABLE or has well-defined behaviour. The exclusive stores, | ||
5 | store-release and STRD do not have this UNDEF case for any encoding. | ||
6 | 1 | ||
7 | Enforce the UNDEF for this case in the Thumb plain store insns. | ||
8 | |||
9 | Fixes: https://bugs.launchpad.net/qemu/+bug/1922887 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20210408162402.5822-1-peter.maydell@linaro.org | ||
13 | --- | ||
14 | target/arm/translate.c | 16 ++++++++++++++++ | ||
15 | 1 file changed, 16 insertions(+) | ||
16 | |||
17 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/translate.c | ||
20 | +++ b/target/arm/translate.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static bool op_store_rr(DisasContext *s, arg_ldst_rr *a, | ||
22 | ISSInfo issinfo = make_issinfo(s, a->rt, a->p, a->w) | ISSIsWrite; | ||
23 | TCGv_i32 addr, tmp; | ||
24 | |||
25 | + /* | ||
26 | + * In Thumb encodings of stores Rn=1111 is UNDEF; for Arm it | ||
27 | + * is either UNPREDICTABLE or has defined behaviour | ||
28 | + */ | ||
29 | + if (s->thumb && a->rn == 15) { | ||
30 | + return false; | ||
31 | + } | ||
32 | + | ||
33 | addr = op_addr_rr_pre(s, a); | ||
34 | |||
35 | tmp = load_reg(s, a->rt); | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool op_store_ri(DisasContext *s, arg_ldst_ri *a, | ||
37 | ISSInfo issinfo = make_issinfo(s, a->rt, a->p, a->w) | ISSIsWrite; | ||
38 | TCGv_i32 addr, tmp; | ||
39 | |||
40 | + /* | ||
41 | + * In Thumb encodings of stores Rn=1111 is UNDEF; for Arm it | ||
42 | + * is either UNPREDICTABLE or has defined behaviour | ||
43 | + */ | ||
44 | + if (s->thumb && a->rn == 15) { | ||
45 | + return false; | ||
46 | + } | ||
47 | + | ||
48 | addr = op_addr_ri_pre(s, a); | ||
49 | |||
50 | tmp = load_reg(s, a->rt); | ||
51 | -- | ||
52 | 2.20.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 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Buglink: https://bugs.launchpad.net/bugs/1921948 | 3 | This controls whether the PACI{A,B}SP instructions trap with BTYPE=3 |
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 4 | (indirect branch from register other than x16/x17). The linux kernel |
5 | sets this in bti_enable(). | ||
6 | |||
7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/998 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20210416183106.1516563-5-richard.henderson@linaro.org | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Message-id: 20220427042312.294300-1-richard.henderson@linaro.org | ||
11 | [PMM: remove stray change to makefile comment] | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 13 | --- |
9 | tests/tcg/aarch64/mte-5.c | 44 +++++++++++++++++++++++++++++++ | 14 | target/arm/cpu.c | 2 ++ |
10 | tests/tcg/aarch64/Makefile.target | 2 +- | 15 | tests/tcg/aarch64/bti-3.c | 42 +++++++++++++++++++++++++++++++ |
11 | 2 files changed, 45 insertions(+), 1 deletion(-) | 16 | tests/tcg/aarch64/Makefile.target | 6 ++--- |
12 | create mode 100644 tests/tcg/aarch64/mte-5.c | 17 | 3 files changed, 47 insertions(+), 3 deletions(-) |
18 | create mode 100644 tests/tcg/aarch64/bti-3.c | ||
13 | 19 | ||
14 | diff --git a/tests/tcg/aarch64/mte-5.c b/tests/tcg/aarch64/mte-5.c | 20 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/cpu.c | ||
23 | +++ b/target/arm/cpu.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) | ||
25 | /* Enable all PAC keys. */ | ||
26 | env->cp15.sctlr_el[1] |= (SCTLR_EnIA | SCTLR_EnIB | | ||
27 | SCTLR_EnDA | SCTLR_EnDB); | ||
28 | + /* Trap on btype=3 for PACIxSP. */ | ||
29 | + env->cp15.sctlr_el[1] |= SCTLR_BT0; | ||
30 | /* and to the FP/Neon instructions */ | ||
31 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3); | ||
32 | /* and to the SVE instructions */ | ||
33 | diff --git a/tests/tcg/aarch64/bti-3.c b/tests/tcg/aarch64/bti-3.c | ||
15 | new file mode 100644 | 34 | new file mode 100644 |
16 | index XXXXXXX..XXXXXXX | 35 | index XXXXXXX..XXXXXXX |
17 | --- /dev/null | 36 | --- /dev/null |
18 | +++ b/tests/tcg/aarch64/mte-5.c | 37 | +++ b/tests/tcg/aarch64/bti-3.c |
19 | @@ -XXX,XX +XXX,XX @@ | 38 | @@ -XXX,XX +XXX,XX @@ |
20 | +/* | 39 | +/* |
21 | + * Memory tagging, faulting unaligned access. | 40 | + * BTI vs PACIASP |
22 | + * | ||
23 | + * Copyright (c) 2021 Linaro Ltd | ||
24 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
25 | + */ | 41 | + */ |
26 | + | 42 | + |
27 | +#include "mte.h" | 43 | +#include "bti-crt.inc.c" |
28 | + | 44 | + |
29 | +void pass(int sig, siginfo_t *info, void *uc) | 45 | +static void skip2_sigill(int sig, siginfo_t *info, ucontext_t *uc) |
30 | +{ | 46 | +{ |
31 | + assert(info->si_code == SEGV_MTESERR); | 47 | + uc->uc_mcontext.pc += 8; |
32 | + exit(0); | 48 | + uc->uc_mcontext.pstate = 1; |
33 | +} | 49 | +} |
34 | + | 50 | + |
35 | +int main(int ac, char **av) | 51 | +#define BTYPE_1() \ |
52 | + asm("mov %0,#1; adr x16, 1f; br x16; 1: hint #25; mov %0,#0" \ | ||
53 | + : "=r"(skipped) : : "x16", "x30") | ||
54 | + | ||
55 | +#define BTYPE_2() \ | ||
56 | + asm("mov %0,#1; adr x16, 1f; blr x16; 1: hint #25; mov %0,#0" \ | ||
57 | + : "=r"(skipped) : : "x16", "x30") | ||
58 | + | ||
59 | +#define BTYPE_3() \ | ||
60 | + asm("mov %0,#1; adr x15, 1f; br x15; 1: hint #25; mov %0,#0" \ | ||
61 | + : "=r"(skipped) : : "x15", "x30") | ||
62 | + | ||
63 | +#define TEST(WHICH, EXPECT) \ | ||
64 | + do { WHICH(); fail += skipped ^ EXPECT; } while (0) | ||
65 | + | ||
66 | +int main() | ||
36 | +{ | 67 | +{ |
37 | + struct sigaction sa; | 68 | + int fail = 0; |
38 | + void *p0, *p1, *p2; | 69 | + int skipped; |
39 | + long excl = 1; | ||
40 | + | 70 | + |
41 | + enable_mte(PR_MTE_TCF_SYNC); | 71 | + /* Signal-like with SA_SIGINFO. */ |
42 | + p0 = alloc_mte_mem(sizeof(*p0)); | 72 | + signal_info(SIGILL, skip2_sigill); |
43 | + | 73 | + |
44 | + /* Create two differently tagged pointers. */ | 74 | + /* With SCTLR_EL1.BT0 set, PACIASP is not compatible with type=3. */ |
45 | + asm("irg %0,%1,%2" : "=r"(p1) : "r"(p0), "r"(excl)); | 75 | + TEST(BTYPE_1, 0); |
46 | + asm("gmi %0,%1,%0" : "+r"(excl) : "r" (p1)); | 76 | + TEST(BTYPE_2, 0); |
47 | + assert(excl != 1); | 77 | + TEST(BTYPE_3, 1); |
48 | + asm("irg %0,%1,%2" : "=r"(p2) : "r"(p0), "r"(excl)); | ||
49 | + assert(p1 != p2); | ||
50 | + | 78 | + |
51 | + memset(&sa, 0, sizeof(sa)); | 79 | + return fail; |
52 | + sa.sa_sigaction = pass; | ||
53 | + sa.sa_flags = SA_SIGINFO; | ||
54 | + sigaction(SIGSEGV, &sa, NULL); | ||
55 | + | ||
56 | + /* Store store two different tags in sequential granules. */ | ||
57 | + asm("stg %0, [%0]" : : "r"(p1)); | ||
58 | + asm("stg %0, [%0]" : : "r"(p2 + 16)); | ||
59 | + | ||
60 | + /* Perform an unaligned load crossing the granules. */ | ||
61 | + asm volatile("ldr %0, [%1]" : "=r"(p0) : "r"(p1 + 12)); | ||
62 | + abort(); | ||
63 | +} | 80 | +} |
64 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | 81 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target |
65 | index XXXXXXX..XXXXXXX 100644 | 82 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/tests/tcg/aarch64/Makefile.target | 83 | --- a/tests/tcg/aarch64/Makefile.target |
67 | +++ b/tests/tcg/aarch64/Makefile.target | 84 | +++ b/tests/tcg/aarch64/Makefile.target |
68 | @@ -XXX,XX +XXX,XX @@ AARCH64_TESTS += bti-2 | 85 | @@ -XXX,XX +XXX,XX @@ endif |
69 | 86 | # BTI Tests | |
70 | # MTE Tests | 87 | # bti-1 tests the elf notes, so we require special compiler support. |
71 | ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_MTE),) | 88 | ifneq ($(CROSS_CC_HAS_ARMV8_BTI),) |
72 | -AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-6 | 89 | -AARCH64_TESTS += bti-1 |
73 | +AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-5 mte-6 | 90 | -bti-1: CFLAGS += -mbranch-protection=standard |
74 | mte-%: CFLAGS += -march=armv8.5-a+memtag | 91 | -bti-1: LDFLAGS += -nostdlib |
92 | +AARCH64_TESTS += bti-1 bti-3 | ||
93 | +bti-1 bti-3: CFLAGS += -mbranch-protection=standard | ||
94 | +bti-1 bti-3: LDFLAGS += -nostdlib | ||
75 | endif | 95 | endif |
76 | 96 | # bti-2 tests PROT_BTI, so no special compiler support required. | |
97 | AARCH64_TESTS += bti-2 | ||
77 | -- | 98 | -- |
78 | 2.20.1 | 99 | 2.25.1 |
79 | |||
80 | 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 | Move ARMCPRegInfo and all related declarations to a new |
4 | and this field name will be expanded using the bit definition of | 4 | internal header, out of the public cpu.h. |
5 | the same name, resulting in a token pasting error. | ||
6 | 5 | ||
7 | So PSTATE_SS -> PSTATE__SS in the uses, and document it. | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
8 | |||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20210419202257.161730-4-richard.henderson@linaro.org | 9 | Message-id: 20220501055028.646596-2-richard.henderson@linaro.org |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | target/arm/cpu.h | 2 +- | 12 | target/arm/cpregs.h | 413 +++++++++++++++++++++++++++++++++++++ |
15 | target/arm/helper.c | 4 ++-- | 13 | target/arm/cpu.h | 368 --------------------------------- |
16 | target/arm/translate-a64.c | 2 +- | 14 | hw/arm/pxa2xx.c | 1 + |
17 | target/arm/translate.c | 2 +- | 15 | hw/arm/pxa2xx_pic.c | 1 + |
18 | 4 files changed, 5 insertions(+), 5 deletions(-) | 16 | hw/intc/arm_gicv3_cpuif.c | 1 + |
17 | hw/intc/arm_gicv3_kvm.c | 2 + | ||
18 | target/arm/cpu.c | 1 + | ||
19 | target/arm/cpu64.c | 1 + | ||
20 | target/arm/cpu_tcg.c | 1 + | ||
21 | target/arm/gdbstub.c | 3 +- | ||
22 | target/arm/helper.c | 1 + | ||
23 | target/arm/op_helper.c | 1 + | ||
24 | target/arm/translate-a64.c | 4 +- | ||
25 | target/arm/translate.c | 3 +- | ||
26 | 14 files changed, 427 insertions(+), 374 deletions(-) | ||
27 | create mode 100644 target/arm/cpregs.h | ||
19 | 28 | ||
29 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
30 | new file mode 100644 | ||
31 | index XXXXXXX..XXXXXXX | ||
32 | --- /dev/null | ||
33 | +++ b/target/arm/cpregs.h | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | +/* | ||
36 | + * QEMU ARM CP Register access and descriptions | ||
37 | + * | ||
38 | + * Copyright (c) 2022 Linaro Ltd | ||
39 | + * | ||
40 | + * This program is free software; you can redistribute it and/or | ||
41 | + * modify it under the terms of the GNU General Public License | ||
42 | + * as published by the Free Software Foundation; either version 2 | ||
43 | + * of the License, or (at your option) any later version. | ||
44 | + * | ||
45 | + * This program is distributed in the hope that it will be useful, | ||
46 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
47 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
48 | + * GNU General Public License for more details. | ||
49 | + * | ||
50 | + * You should have received a copy of the GNU General Public License | ||
51 | + * along with this program; if not, see | ||
52 | + * <http://www.gnu.org/licenses/gpl-2.0.html> | ||
53 | + */ | ||
54 | + | ||
55 | +#ifndef TARGET_ARM_CPREGS_H | ||
56 | +#define TARGET_ARM_CPREGS_H | ||
57 | + | ||
58 | +/* | ||
59 | + * ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a | ||
60 | + * special-behaviour cp reg and bits [11..8] indicate what behaviour | ||
61 | + * it has. Otherwise it is a simple cp reg, where CONST indicates that | ||
62 | + * TCG can assume the value to be constant (ie load at translate time) | ||
63 | + * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END | ||
64 | + * indicates that the TB should not be ended after a write to this register | ||
65 | + * (the default is that the TB ends after cp writes). OVERRIDE permits | ||
66 | + * a register definition to override a previous definition for the | ||
67 | + * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the | ||
68 | + * old must have the OVERRIDE bit set. | ||
69 | + * ALIAS indicates that this register is an alias view of some underlying | ||
70 | + * state which is also visible via another register, and that the other | ||
71 | + * register is handling migration and reset; registers marked ALIAS will not be | ||
72 | + * migrated but may have their state set by syncing of register state from KVM. | ||
73 | + * NO_RAW indicates that this register has no underlying state and does not | ||
74 | + * support raw access for state saving/loading; it will not be used for either | ||
75 | + * migration or KVM state synchronization. (Typically this is for "registers" | ||
76 | + * which are actually used as instructions for cache maintenance and so on.) | ||
77 | + * IO indicates that this register does I/O and therefore its accesses | ||
78 | + * need to be marked with gen_io_start() and also end the TB. In particular, | ||
79 | + * registers which implement clocks or timers require this. | ||
80 | + * RAISES_EXC is for when the read or write hook might raise an exception; | ||
81 | + * the generated code will synchronize the CPU state before calling the hook | ||
82 | + * so that it is safe for the hook to call raise_exception(). | ||
83 | + * NEWEL is for writes to registers that might change the exception | ||
84 | + * level - typically on older ARM chips. For those cases we need to | ||
85 | + * re-read the new el when recomputing the translation flags. | ||
86 | + */ | ||
87 | +#define ARM_CP_SPECIAL 0x0001 | ||
88 | +#define ARM_CP_CONST 0x0002 | ||
89 | +#define ARM_CP_64BIT 0x0004 | ||
90 | +#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
91 | +#define ARM_CP_OVERRIDE 0x0010 | ||
92 | +#define ARM_CP_ALIAS 0x0020 | ||
93 | +#define ARM_CP_IO 0x0040 | ||
94 | +#define ARM_CP_NO_RAW 0x0080 | ||
95 | +#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
96 | +#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
97 | +#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
98 | +#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
99 | +#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
100 | +#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) | ||
101 | +#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) | ||
102 | +#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA | ||
103 | +#define ARM_CP_FPU 0x1000 | ||
104 | +#define ARM_CP_SVE 0x2000 | ||
105 | +#define ARM_CP_NO_GDB 0x4000 | ||
106 | +#define ARM_CP_RAISES_EXC 0x8000 | ||
107 | +#define ARM_CP_NEWEL 0x10000 | ||
108 | +/* Used only as a terminator for ARMCPRegInfo lists */ | ||
109 | +#define ARM_CP_SENTINEL 0xfffff | ||
110 | +/* Mask of only the flag bits in a type field */ | ||
111 | +#define ARM_CP_FLAG_MASK 0x1f0ff | ||
112 | + | ||
113 | +/* | ||
114 | + * Valid values for ARMCPRegInfo state field, indicating which of | ||
115 | + * the AArch32 and AArch64 execution states this register is visible in. | ||
116 | + * If the reginfo doesn't explicitly specify then it is AArch32 only. | ||
117 | + * If the reginfo is declared to be visible in both states then a second | ||
118 | + * reginfo is synthesised for the AArch32 view of the AArch64 register, | ||
119 | + * such that the AArch32 view is the lower 32 bits of the AArch64 one. | ||
120 | + * Note that we rely on the values of these enums as we iterate through | ||
121 | + * the various states in some places. | ||
122 | + */ | ||
123 | +enum { | ||
124 | + ARM_CP_STATE_AA32 = 0, | ||
125 | + ARM_CP_STATE_AA64 = 1, | ||
126 | + ARM_CP_STATE_BOTH = 2, | ||
127 | +}; | ||
128 | + | ||
129 | +/* | ||
130 | + * ARM CP register secure state flags. These flags identify security state | ||
131 | + * attributes for a given CP register entry. | ||
132 | + * The existence of both or neither secure and non-secure flags indicates that | ||
133 | + * the register has both a secure and non-secure hash entry. A single one of | ||
134 | + * these flags causes the register to only be hashed for the specified | ||
135 | + * security state. | ||
136 | + * Although definitions may have any combination of the S/NS bits, each | ||
137 | + * registered entry will only have one to identify whether the entry is secure | ||
138 | + * or non-secure. | ||
139 | + */ | ||
140 | +enum { | ||
141 | + ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ | ||
142 | + ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ | ||
143 | +}; | ||
144 | + | ||
145 | +/* | ||
146 | + * Return true if cptype is a valid type field. This is used to try to | ||
147 | + * catch errors where the sentinel has been accidentally left off the end | ||
148 | + * of a list of registers. | ||
149 | + */ | ||
150 | +static inline bool cptype_valid(int cptype) | ||
151 | +{ | ||
152 | + return ((cptype & ~ARM_CP_FLAG_MASK) == 0) | ||
153 | + || ((cptype & ARM_CP_SPECIAL) && | ||
154 | + ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); | ||
155 | +} | ||
156 | + | ||
157 | +/* | ||
158 | + * Access rights: | ||
159 | + * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM | ||
160 | + * defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and | ||
161 | + * PL2 (hyp). The other level which has Read and Write bits is Secure PL1 | ||
162 | + * (ie any of the privileged modes in Secure state, or Monitor mode). | ||
163 | + * If a register is accessible in one privilege level it's always accessible | ||
164 | + * in higher privilege levels too. Since "Secure PL1" also follows this rule | ||
165 | + * (ie anything visible in PL2 is visible in S-PL1, some things are only | ||
166 | + * visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the | ||
167 | + * terminology a little and call this PL3. | ||
168 | + * In AArch64 things are somewhat simpler as the PLx bits line up exactly | ||
169 | + * with the ELx exception levels. | ||
170 | + * | ||
171 | + * If access permissions for a register are more complex than can be | ||
172 | + * described with these bits, then use a laxer set of restrictions, and | ||
173 | + * do the more restrictive/complex check inside a helper function. | ||
174 | + */ | ||
175 | +#define PL3_R 0x80 | ||
176 | +#define PL3_W 0x40 | ||
177 | +#define PL2_R (0x20 | PL3_R) | ||
178 | +#define PL2_W (0x10 | PL3_W) | ||
179 | +#define PL1_R (0x08 | PL2_R) | ||
180 | +#define PL1_W (0x04 | PL2_W) | ||
181 | +#define PL0_R (0x02 | PL1_R) | ||
182 | +#define PL0_W (0x01 | PL1_W) | ||
183 | + | ||
184 | +/* | ||
185 | + * For user-mode some registers are accessible to EL0 via a kernel | ||
186 | + * trap-and-emulate ABI. In this case we define the read permissions | ||
187 | + * as actually being PL0_R. However some bits of any given register | ||
188 | + * may still be masked. | ||
189 | + */ | ||
190 | +#ifdef CONFIG_USER_ONLY | ||
191 | +#define PL0U_R PL0_R | ||
192 | +#else | ||
193 | +#define PL0U_R PL1_R | ||
194 | +#endif | ||
195 | + | ||
196 | +#define PL3_RW (PL3_R | PL3_W) | ||
197 | +#define PL2_RW (PL2_R | PL2_W) | ||
198 | +#define PL1_RW (PL1_R | PL1_W) | ||
199 | +#define PL0_RW (PL0_R | PL0_W) | ||
200 | + | ||
201 | +typedef enum CPAccessResult { | ||
202 | + /* Access is permitted */ | ||
203 | + CP_ACCESS_OK = 0, | ||
204 | + /* | ||
205 | + * Access fails due to a configurable trap or enable which would | ||
206 | + * result in a categorized exception syndrome giving information about | ||
207 | + * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
208 | + * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
209 | + * PL1 if in EL0, otherwise to the current EL). | ||
210 | + */ | ||
211 | + CP_ACCESS_TRAP = 1, | ||
212 | + /* | ||
213 | + * Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
214 | + * Note that this is not a catch-all case -- the set of cases which may | ||
215 | + * result in this failure is specifically defined by the architecture. | ||
216 | + */ | ||
217 | + CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
218 | + /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
219 | + CP_ACCESS_TRAP_EL2 = 3, | ||
220 | + CP_ACCESS_TRAP_EL3 = 4, | ||
221 | + /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
222 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
223 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
224 | +} CPAccessResult; | ||
225 | + | ||
226 | +typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
227 | + | ||
228 | +/* | ||
229 | + * Access functions for coprocessor registers. These cannot fail and | ||
230 | + * may not raise exceptions. | ||
231 | + */ | ||
232 | +typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
233 | +typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque, | ||
234 | + uint64_t value); | ||
235 | +/* Access permission check functions for coprocessor registers. */ | ||
236 | +typedef CPAccessResult CPAccessFn(CPUARMState *env, | ||
237 | + const ARMCPRegInfo *opaque, | ||
238 | + bool isread); | ||
239 | +/* Hook function for register reset */ | ||
240 | +typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
241 | + | ||
242 | +#define CP_ANY 0xff | ||
243 | + | ||
244 | +/* Definition of an ARM coprocessor register */ | ||
245 | +struct ARMCPRegInfo { | ||
246 | + /* Name of register (useful mainly for debugging, need not be unique) */ | ||
247 | + const char *name; | ||
248 | + /* | ||
249 | + * Location of register: coprocessor number and (crn,crm,opc1,opc2) | ||
250 | + * tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a | ||
251 | + * 'wildcard' field -- any value of that field in the MRC/MCR insn | ||
252 | + * will be decoded to this register. The register read and write | ||
253 | + * callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2 | ||
254 | + * used by the program, so it is possible to register a wildcard and | ||
255 | + * then behave differently on read/write if necessary. | ||
256 | + * For 64 bit registers, only crm and opc1 are relevant; crn and opc2 | ||
257 | + * must both be zero. | ||
258 | + * For AArch64-visible registers, opc0 is also used. | ||
259 | + * Since there are no "coprocessors" in AArch64, cp is purely used as a | ||
260 | + * way to distinguish (for KVM's benefit) guest-visible system registers | ||
261 | + * from demuxed ones provided to preserve the "no side effects on | ||
262 | + * KVM register read/write from QEMU" semantics. cp==0x13 is guest | ||
263 | + * visible (to match KVM's encoding); cp==0 will be converted to | ||
264 | + * cp==0x13 when the ARMCPRegInfo is registered, for convenience. | ||
265 | + */ | ||
266 | + uint8_t cp; | ||
267 | + uint8_t crn; | ||
268 | + uint8_t crm; | ||
269 | + uint8_t opc0; | ||
270 | + uint8_t opc1; | ||
271 | + uint8_t opc2; | ||
272 | + /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
273 | + int state; | ||
274 | + /* Register type: ARM_CP_* bits/values */ | ||
275 | + int type; | ||
276 | + /* Access rights: PL*_[RW] */ | ||
277 | + int access; | ||
278 | + /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
279 | + int secure; | ||
280 | + /* | ||
281 | + * The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
282 | + * this register was defined: can be used to hand data through to the | ||
283 | + * register read/write functions, since they are passed the ARMCPRegInfo*. | ||
284 | + */ | ||
285 | + void *opaque; | ||
286 | + /* | ||
287 | + * Value of this register, if it is ARM_CP_CONST. Otherwise, if | ||
288 | + * fieldoffset is non-zero, the reset value of the register. | ||
289 | + */ | ||
290 | + uint64_t resetvalue; | ||
291 | + /* | ||
292 | + * Offset of the field in CPUARMState for this register. | ||
293 | + * This is not needed if either: | ||
294 | + * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs | ||
295 | + * 2. both readfn and writefn are specified | ||
296 | + */ | ||
297 | + ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */ | ||
298 | + | ||
299 | + /* | ||
300 | + * Offsets of the secure and non-secure fields in CPUARMState for the | ||
301 | + * register if it is banked. These fields are only used during the static | ||
302 | + * registration of a register. During hashing the bank associated | ||
303 | + * with a given security state is copied to fieldoffset which is used from | ||
304 | + * there on out. | ||
305 | + * | ||
306 | + * It is expected that register definitions use either fieldoffset or | ||
307 | + * bank_fieldoffsets in the definition but not both. It is also expected | ||
308 | + * that both bank offsets are set when defining a banked register. This | ||
309 | + * use indicates that a register is banked. | ||
310 | + */ | ||
311 | + ptrdiff_t bank_fieldoffsets[2]; | ||
312 | + | ||
313 | + /* | ||
314 | + * Function for making any access checks for this register in addition to | ||
315 | + * those specified by the 'access' permissions bits. If NULL, no extra | ||
316 | + * checks required. The access check is performed at runtime, not at | ||
317 | + * translate time. | ||
318 | + */ | ||
319 | + CPAccessFn *accessfn; | ||
320 | + /* | ||
321 | + * Function for handling reads of this register. If NULL, then reads | ||
322 | + * will be done by loading from the offset into CPUARMState specified | ||
323 | + * by fieldoffset. | ||
324 | + */ | ||
325 | + CPReadFn *readfn; | ||
326 | + /* | ||
327 | + * Function for handling writes of this register. If NULL, then writes | ||
328 | + * will be done by writing to the offset into CPUARMState specified | ||
329 | + * by fieldoffset. | ||
330 | + */ | ||
331 | + CPWriteFn *writefn; | ||
332 | + /* | ||
333 | + * Function for doing a "raw" read; used when we need to copy | ||
334 | + * coprocessor state to the kernel for KVM or out for | ||
335 | + * migration. This only needs to be provided if there is also a | ||
336 | + * readfn and it has side effects (for instance clear-on-read bits). | ||
337 | + */ | ||
338 | + CPReadFn *raw_readfn; | ||
339 | + /* | ||
340 | + * Function for doing a "raw" write; used when we need to copy KVM | ||
341 | + * kernel coprocessor state into userspace, or for inbound | ||
342 | + * migration. This only needs to be provided if there is also a | ||
343 | + * writefn and it masks out "unwritable" bits or has write-one-to-clear | ||
344 | + * or similar behaviour. | ||
345 | + */ | ||
346 | + CPWriteFn *raw_writefn; | ||
347 | + /* | ||
348 | + * Function for resetting the register. If NULL, then reset will be done | ||
349 | + * by writing resetvalue to the field specified in fieldoffset. If | ||
350 | + * fieldoffset is 0 then no reset will be done. | ||
351 | + */ | ||
352 | + CPResetFn *resetfn; | ||
353 | + | ||
354 | + /* | ||
355 | + * "Original" writefn and readfn. | ||
356 | + * For ARMv8.1-VHE register aliases, we overwrite the read/write | ||
357 | + * accessor functions of various EL1/EL0 to perform the runtime | ||
358 | + * check for which sysreg should actually be modified, and then | ||
359 | + * forwards the operation. Before overwriting the accessors, | ||
360 | + * the original function is copied here, so that accesses that | ||
361 | + * really do go to the EL1/EL0 version proceed normally. | ||
362 | + * (The corresponding EL2 register is linked via opaque.) | ||
363 | + */ | ||
364 | + CPReadFn *orig_readfn; | ||
365 | + CPWriteFn *orig_writefn; | ||
366 | +}; | ||
367 | + | ||
368 | +/* | ||
369 | + * Macros which are lvalues for the field in CPUARMState for the | ||
370 | + * ARMCPRegInfo *ri. | ||
371 | + */ | ||
372 | +#define CPREG_FIELD32(env, ri) \ | ||
373 | + (*(uint32_t *)((char *)(env) + (ri)->fieldoffset)) | ||
374 | +#define CPREG_FIELD64(env, ri) \ | ||
375 | + (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) | ||
376 | + | ||
377 | +#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } | ||
378 | + | ||
379 | +void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
380 | + const ARMCPRegInfo *regs, void *opaque); | ||
381 | +void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
382 | + const ARMCPRegInfo *regs, void *opaque); | ||
383 | +static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
384 | +{ | ||
385 | + define_arm_cp_regs_with_opaque(cpu, regs, 0); | ||
386 | +} | ||
387 | +static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
388 | +{ | ||
389 | + define_one_arm_cp_reg_with_opaque(cpu, regs, 0); | ||
390 | +} | ||
391 | +const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); | ||
392 | + | ||
393 | +/* | ||
394 | + * Definition of an ARM co-processor register as viewed from | ||
395 | + * userspace. This is used for presenting sanitised versions of | ||
396 | + * registers to userspace when emulating the Linux AArch64 CPU | ||
397 | + * ID/feature ABI (advertised as HWCAP_CPUID). | ||
398 | + */ | ||
399 | +typedef struct ARMCPRegUserSpaceInfo { | ||
400 | + /* Name of register */ | ||
401 | + const char *name; | ||
402 | + | ||
403 | + /* Is the name actually a glob pattern */ | ||
404 | + bool is_glob; | ||
405 | + | ||
406 | + /* Only some bits are exported to user space */ | ||
407 | + uint64_t exported_bits; | ||
408 | + | ||
409 | + /* Fixed bits are applied after the mask */ | ||
410 | + uint64_t fixed_bits; | ||
411 | +} ARMCPRegUserSpaceInfo; | ||
412 | + | ||
413 | +#define REGUSERINFO_SENTINEL { .name = NULL } | ||
414 | + | ||
415 | +void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); | ||
416 | + | ||
417 | +/* CPWriteFn that can be used to implement writes-ignored behaviour */ | ||
418 | +void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, | ||
419 | + uint64_t value); | ||
420 | +/* CPReadFn that can be used for read-as-zero behaviour */ | ||
421 | +uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri); | ||
422 | + | ||
423 | +/* | ||
424 | + * CPResetFn that does nothing, for use if no reset is required even | ||
425 | + * if fieldoffset is non zero. | ||
426 | + */ | ||
427 | +void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
428 | + | ||
429 | +/* | ||
430 | + * Return true if this reginfo struct's field in the cpu state struct | ||
431 | + * is 64 bits wide. | ||
432 | + */ | ||
433 | +static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri) | ||
434 | +{ | ||
435 | + return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT); | ||
436 | +} | ||
437 | + | ||
438 | +static inline bool cp_access_ok(int current_el, | ||
439 | + const ARMCPRegInfo *ri, int isread) | ||
440 | +{ | ||
441 | + return (ri->access >> ((current_el * 2) + isread)) & 1; | ||
442 | +} | ||
443 | + | ||
444 | +/* Raw read of a coprocessor register (as needed for migration, etc) */ | ||
445 | +uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri); | ||
446 | + | ||
447 | +#endif /* TARGET_ARM_CPREGS_H */ | ||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 448 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
21 | index XXXXXXX..XXXXXXX 100644 | 449 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 450 | --- a/target/arm/cpu.h |
23 | +++ b/target/arm/cpu.h | 451 | +++ b/target/arm/cpu.h |
24 | @@ -XXX,XX +XXX,XX @@ typedef ARMCPU ArchCPU; | 452 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) |
453 | return kvmid; | ||
454 | } | ||
455 | |||
456 | -/* ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a | ||
457 | - * special-behaviour cp reg and bits [11..8] indicate what behaviour | ||
458 | - * it has. Otherwise it is a simple cp reg, where CONST indicates that | ||
459 | - * TCG can assume the value to be constant (ie load at translate time) | ||
460 | - * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END | ||
461 | - * indicates that the TB should not be ended after a write to this register | ||
462 | - * (the default is that the TB ends after cp writes). OVERRIDE permits | ||
463 | - * a register definition to override a previous definition for the | ||
464 | - * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the | ||
465 | - * old must have the OVERRIDE bit set. | ||
466 | - * ALIAS indicates that this register is an alias view of some underlying | ||
467 | - * state which is also visible via another register, and that the other | ||
468 | - * register is handling migration and reset; registers marked ALIAS will not be | ||
469 | - * migrated but may have their state set by syncing of register state from KVM. | ||
470 | - * NO_RAW indicates that this register has no underlying state and does not | ||
471 | - * support raw access for state saving/loading; it will not be used for either | ||
472 | - * migration or KVM state synchronization. (Typically this is for "registers" | ||
473 | - * which are actually used as instructions for cache maintenance and so on.) | ||
474 | - * IO indicates that this register does I/O and therefore its accesses | ||
475 | - * need to be marked with gen_io_start() and also end the TB. In particular, | ||
476 | - * registers which implement clocks or timers require this. | ||
477 | - * RAISES_EXC is for when the read or write hook might raise an exception; | ||
478 | - * the generated code will synchronize the CPU state before calling the hook | ||
479 | - * so that it is safe for the hook to call raise_exception(). | ||
480 | - * NEWEL is for writes to registers that might change the exception | ||
481 | - * level - typically on older ARM chips. For those cases we need to | ||
482 | - * re-read the new el when recomputing the translation flags. | ||
483 | - */ | ||
484 | -#define ARM_CP_SPECIAL 0x0001 | ||
485 | -#define ARM_CP_CONST 0x0002 | ||
486 | -#define ARM_CP_64BIT 0x0004 | ||
487 | -#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
488 | -#define ARM_CP_OVERRIDE 0x0010 | ||
489 | -#define ARM_CP_ALIAS 0x0020 | ||
490 | -#define ARM_CP_IO 0x0040 | ||
491 | -#define ARM_CP_NO_RAW 0x0080 | ||
492 | -#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
493 | -#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
494 | -#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
495 | -#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
496 | -#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
497 | -#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) | ||
498 | -#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) | ||
499 | -#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA | ||
500 | -#define ARM_CP_FPU 0x1000 | ||
501 | -#define ARM_CP_SVE 0x2000 | ||
502 | -#define ARM_CP_NO_GDB 0x4000 | ||
503 | -#define ARM_CP_RAISES_EXC 0x8000 | ||
504 | -#define ARM_CP_NEWEL 0x10000 | ||
505 | -/* Used only as a terminator for ARMCPRegInfo lists */ | ||
506 | -#define ARM_CP_SENTINEL 0xfffff | ||
507 | -/* Mask of only the flag bits in a type field */ | ||
508 | -#define ARM_CP_FLAG_MASK 0x1f0ff | ||
509 | - | ||
510 | -/* Valid values for ARMCPRegInfo state field, indicating which of | ||
511 | - * the AArch32 and AArch64 execution states this register is visible in. | ||
512 | - * If the reginfo doesn't explicitly specify then it is AArch32 only. | ||
513 | - * If the reginfo is declared to be visible in both states then a second | ||
514 | - * reginfo is synthesised for the AArch32 view of the AArch64 register, | ||
515 | - * such that the AArch32 view is the lower 32 bits of the AArch64 one. | ||
516 | - * Note that we rely on the values of these enums as we iterate through | ||
517 | - * the various states in some places. | ||
518 | - */ | ||
519 | -enum { | ||
520 | - ARM_CP_STATE_AA32 = 0, | ||
521 | - ARM_CP_STATE_AA64 = 1, | ||
522 | - ARM_CP_STATE_BOTH = 2, | ||
523 | -}; | ||
524 | - | ||
525 | -/* ARM CP register secure state flags. These flags identify security state | ||
526 | - * attributes for a given CP register entry. | ||
527 | - * The existence of both or neither secure and non-secure flags indicates that | ||
528 | - * the register has both a secure and non-secure hash entry. A single one of | ||
529 | - * these flags causes the register to only be hashed for the specified | ||
530 | - * security state. | ||
531 | - * Although definitions may have any combination of the S/NS bits, each | ||
532 | - * registered entry will only have one to identify whether the entry is secure | ||
533 | - * or non-secure. | ||
534 | - */ | ||
535 | -enum { | ||
536 | - ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ | ||
537 | - ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ | ||
538 | -}; | ||
539 | - | ||
540 | -/* Return true if cptype is a valid type field. This is used to try to | ||
541 | - * catch errors where the sentinel has been accidentally left off the end | ||
542 | - * of a list of registers. | ||
543 | - */ | ||
544 | -static inline bool cptype_valid(int cptype) | ||
545 | -{ | ||
546 | - return ((cptype & ~ARM_CP_FLAG_MASK) == 0) | ||
547 | - || ((cptype & ARM_CP_SPECIAL) && | ||
548 | - ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); | ||
549 | -} | ||
550 | - | ||
551 | -/* Access rights: | ||
552 | - * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM | ||
553 | - * defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and | ||
554 | - * PL2 (hyp). The other level which has Read and Write bits is Secure PL1 | ||
555 | - * (ie any of the privileged modes in Secure state, or Monitor mode). | ||
556 | - * If a register is accessible in one privilege level it's always accessible | ||
557 | - * in higher privilege levels too. Since "Secure PL1" also follows this rule | ||
558 | - * (ie anything visible in PL2 is visible in S-PL1, some things are only | ||
559 | - * visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the | ||
560 | - * terminology a little and call this PL3. | ||
561 | - * In AArch64 things are somewhat simpler as the PLx bits line up exactly | ||
562 | - * with the ELx exception levels. | ||
563 | - * | ||
564 | - * If access permissions for a register are more complex than can be | ||
565 | - * described with these bits, then use a laxer set of restrictions, and | ||
566 | - * do the more restrictive/complex check inside a helper function. | ||
567 | - */ | ||
568 | -#define PL3_R 0x80 | ||
569 | -#define PL3_W 0x40 | ||
570 | -#define PL2_R (0x20 | PL3_R) | ||
571 | -#define PL2_W (0x10 | PL3_W) | ||
572 | -#define PL1_R (0x08 | PL2_R) | ||
573 | -#define PL1_W (0x04 | PL2_W) | ||
574 | -#define PL0_R (0x02 | PL1_R) | ||
575 | -#define PL0_W (0x01 | PL1_W) | ||
576 | - | ||
577 | -/* | ||
578 | - * For user-mode some registers are accessible to EL0 via a kernel | ||
579 | - * trap-and-emulate ABI. In this case we define the read permissions | ||
580 | - * as actually being PL0_R. However some bits of any given register | ||
581 | - * may still be masked. | ||
582 | - */ | ||
583 | -#ifdef CONFIG_USER_ONLY | ||
584 | -#define PL0U_R PL0_R | ||
585 | -#else | ||
586 | -#define PL0U_R PL1_R | ||
587 | -#endif | ||
588 | - | ||
589 | -#define PL3_RW (PL3_R | PL3_W) | ||
590 | -#define PL2_RW (PL2_R | PL2_W) | ||
591 | -#define PL1_RW (PL1_R | PL1_W) | ||
592 | -#define PL0_RW (PL0_R | PL0_W) | ||
593 | - | ||
594 | /* Return the highest implemented Exception Level */ | ||
595 | static inline int arm_highest_el(CPUARMState *env) | ||
596 | { | ||
597 | @@ -XXX,XX +XXX,XX @@ static inline int arm_current_el(CPUARMState *env) | ||
598 | } | ||
599 | } | ||
600 | |||
601 | -typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
602 | - | ||
603 | -typedef enum CPAccessResult { | ||
604 | - /* Access is permitted */ | ||
605 | - CP_ACCESS_OK = 0, | ||
606 | - /* Access fails due to a configurable trap or enable which would | ||
607 | - * result in a categorized exception syndrome giving information about | ||
608 | - * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
609 | - * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
610 | - * PL1 if in EL0, otherwise to the current EL). | ||
611 | - */ | ||
612 | - CP_ACCESS_TRAP = 1, | ||
613 | - /* Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
614 | - * Note that this is not a catch-all case -- the set of cases which may | ||
615 | - * result in this failure is specifically defined by the architecture. | ||
616 | - */ | ||
617 | - CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
618 | - /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
619 | - CP_ACCESS_TRAP_EL2 = 3, | ||
620 | - CP_ACCESS_TRAP_EL3 = 4, | ||
621 | - /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
622 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
623 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
624 | -} CPAccessResult; | ||
625 | - | ||
626 | -/* Access functions for coprocessor registers. These cannot fail and | ||
627 | - * may not raise exceptions. | ||
628 | - */ | ||
629 | -typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
630 | -typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque, | ||
631 | - uint64_t value); | ||
632 | -/* Access permission check functions for coprocessor registers. */ | ||
633 | -typedef CPAccessResult CPAccessFn(CPUARMState *env, | ||
634 | - const ARMCPRegInfo *opaque, | ||
635 | - bool isread); | ||
636 | -/* Hook function for register reset */ | ||
637 | -typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
638 | - | ||
639 | -#define CP_ANY 0xff | ||
640 | - | ||
641 | -/* Definition of an ARM coprocessor register */ | ||
642 | -struct ARMCPRegInfo { | ||
643 | - /* Name of register (useful mainly for debugging, need not be unique) */ | ||
644 | - const char *name; | ||
645 | - /* Location of register: coprocessor number and (crn,crm,opc1,opc2) | ||
646 | - * tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a | ||
647 | - * 'wildcard' field -- any value of that field in the MRC/MCR insn | ||
648 | - * will be decoded to this register. The register read and write | ||
649 | - * callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2 | ||
650 | - * used by the program, so it is possible to register a wildcard and | ||
651 | - * then behave differently on read/write if necessary. | ||
652 | - * For 64 bit registers, only crm and opc1 are relevant; crn and opc2 | ||
653 | - * must both be zero. | ||
654 | - * For AArch64-visible registers, opc0 is also used. | ||
655 | - * Since there are no "coprocessors" in AArch64, cp is purely used as a | ||
656 | - * way to distinguish (for KVM's benefit) guest-visible system registers | ||
657 | - * from demuxed ones provided to preserve the "no side effects on | ||
658 | - * KVM register read/write from QEMU" semantics. cp==0x13 is guest | ||
659 | - * visible (to match KVM's encoding); cp==0 will be converted to | ||
660 | - * cp==0x13 when the ARMCPRegInfo is registered, for convenience. | ||
661 | - */ | ||
662 | - uint8_t cp; | ||
663 | - uint8_t crn; | ||
664 | - uint8_t crm; | ||
665 | - uint8_t opc0; | ||
666 | - uint8_t opc1; | ||
667 | - uint8_t opc2; | ||
668 | - /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
669 | - int state; | ||
670 | - /* Register type: ARM_CP_* bits/values */ | ||
671 | - int type; | ||
672 | - /* Access rights: PL*_[RW] */ | ||
673 | - int access; | ||
674 | - /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
675 | - int secure; | ||
676 | - /* The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
677 | - * this register was defined: can be used to hand data through to the | ||
678 | - * register read/write functions, since they are passed the ARMCPRegInfo*. | ||
679 | - */ | ||
680 | - void *opaque; | ||
681 | - /* Value of this register, if it is ARM_CP_CONST. Otherwise, if | ||
682 | - * fieldoffset is non-zero, the reset value of the register. | ||
683 | - */ | ||
684 | - uint64_t resetvalue; | ||
685 | - /* Offset of the field in CPUARMState for this register. | ||
686 | - * | ||
687 | - * This is not needed if either: | ||
688 | - * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs | ||
689 | - * 2. both readfn and writefn are specified | ||
690 | - */ | ||
691 | - ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */ | ||
692 | - | ||
693 | - /* Offsets of the secure and non-secure fields in CPUARMState for the | ||
694 | - * register if it is banked. These fields are only used during the static | ||
695 | - * registration of a register. During hashing the bank associated | ||
696 | - * with a given security state is copied to fieldoffset which is used from | ||
697 | - * there on out. | ||
698 | - * | ||
699 | - * It is expected that register definitions use either fieldoffset or | ||
700 | - * bank_fieldoffsets in the definition but not both. It is also expected | ||
701 | - * that both bank offsets are set when defining a banked register. This | ||
702 | - * use indicates that a register is banked. | ||
703 | - */ | ||
704 | - ptrdiff_t bank_fieldoffsets[2]; | ||
705 | - | ||
706 | - /* Function for making any access checks for this register in addition to | ||
707 | - * those specified by the 'access' permissions bits. If NULL, no extra | ||
708 | - * checks required. The access check is performed at runtime, not at | ||
709 | - * translate time. | ||
710 | - */ | ||
711 | - CPAccessFn *accessfn; | ||
712 | - /* Function for handling reads of this register. If NULL, then reads | ||
713 | - * will be done by loading from the offset into CPUARMState specified | ||
714 | - * by fieldoffset. | ||
715 | - */ | ||
716 | - CPReadFn *readfn; | ||
717 | - /* Function for handling writes of this register. If NULL, then writes | ||
718 | - * will be done by writing to the offset into CPUARMState specified | ||
719 | - * by fieldoffset. | ||
720 | - */ | ||
721 | - CPWriteFn *writefn; | ||
722 | - /* Function for doing a "raw" read; used when we need to copy | ||
723 | - * coprocessor state to the kernel for KVM or out for | ||
724 | - * migration. This only needs to be provided if there is also a | ||
725 | - * readfn and it has side effects (for instance clear-on-read bits). | ||
726 | - */ | ||
727 | - CPReadFn *raw_readfn; | ||
728 | - /* Function for doing a "raw" write; used when we need to copy KVM | ||
729 | - * kernel coprocessor state into userspace, or for inbound | ||
730 | - * migration. This only needs to be provided if there is also a | ||
731 | - * writefn and it masks out "unwritable" bits or has write-one-to-clear | ||
732 | - * or similar behaviour. | ||
733 | - */ | ||
734 | - CPWriteFn *raw_writefn; | ||
735 | - /* Function for resetting the register. If NULL, then reset will be done | ||
736 | - * by writing resetvalue to the field specified in fieldoffset. If | ||
737 | - * fieldoffset is 0 then no reset will be done. | ||
738 | - */ | ||
739 | - CPResetFn *resetfn; | ||
740 | - | ||
741 | - /* | ||
742 | - * "Original" writefn and readfn. | ||
743 | - * For ARMv8.1-VHE register aliases, we overwrite the read/write | ||
744 | - * accessor functions of various EL1/EL0 to perform the runtime | ||
745 | - * check for which sysreg should actually be modified, and then | ||
746 | - * forwards the operation. Before overwriting the accessors, | ||
747 | - * the original function is copied here, so that accesses that | ||
748 | - * really do go to the EL1/EL0 version proceed normally. | ||
749 | - * (The corresponding EL2 register is linked via opaque.) | ||
750 | - */ | ||
751 | - CPReadFn *orig_readfn; | ||
752 | - CPWriteFn *orig_writefn; | ||
753 | -}; | ||
754 | - | ||
755 | -/* Macros which are lvalues for the field in CPUARMState for the | ||
756 | - * ARMCPRegInfo *ri. | ||
757 | - */ | ||
758 | -#define CPREG_FIELD32(env, ri) \ | ||
759 | - (*(uint32_t *)((char *)(env) + (ri)->fieldoffset)) | ||
760 | -#define CPREG_FIELD64(env, ri) \ | ||
761 | - (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) | ||
762 | - | ||
763 | -#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } | ||
764 | - | ||
765 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
766 | - const ARMCPRegInfo *regs, void *opaque); | ||
767 | -void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
768 | - const ARMCPRegInfo *regs, void *opaque); | ||
769 | -static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
770 | -{ | ||
771 | - define_arm_cp_regs_with_opaque(cpu, regs, 0); | ||
772 | -} | ||
773 | -static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
774 | -{ | ||
775 | - define_one_arm_cp_reg_with_opaque(cpu, regs, 0); | ||
776 | -} | ||
777 | -const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); | ||
778 | - | ||
779 | -/* | ||
780 | - * Definition of an ARM co-processor register as viewed from | ||
781 | - * userspace. This is used for presenting sanitised versions of | ||
782 | - * registers to userspace when emulating the Linux AArch64 CPU | ||
783 | - * ID/feature ABI (advertised as HWCAP_CPUID). | ||
784 | - */ | ||
785 | -typedef struct ARMCPRegUserSpaceInfo { | ||
786 | - /* Name of register */ | ||
787 | - const char *name; | ||
788 | - | ||
789 | - /* Is the name actually a glob pattern */ | ||
790 | - bool is_glob; | ||
791 | - | ||
792 | - /* Only some bits are exported to user space */ | ||
793 | - uint64_t exported_bits; | ||
794 | - | ||
795 | - /* Fixed bits are applied after the mask */ | ||
796 | - uint64_t fixed_bits; | ||
797 | -} ARMCPRegUserSpaceInfo; | ||
798 | - | ||
799 | -#define REGUSERINFO_SENTINEL { .name = NULL } | ||
800 | - | ||
801 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); | ||
802 | - | ||
803 | -/* CPWriteFn that can be used to implement writes-ignored behaviour */ | ||
804 | -void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, | ||
805 | - uint64_t value); | ||
806 | -/* CPReadFn that can be used for read-as-zero behaviour */ | ||
807 | -uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri); | ||
808 | - | ||
809 | -/* CPResetFn that does nothing, for use if no reset is required even | ||
810 | - * if fieldoffset is non zero. | ||
811 | - */ | ||
812 | -void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
813 | - | ||
814 | -/* Return true if this reginfo struct's field in the cpu state struct | ||
815 | - * is 64 bits wide. | ||
816 | - */ | ||
817 | -static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri) | ||
818 | -{ | ||
819 | - return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT); | ||
820 | -} | ||
821 | - | ||
822 | -static inline bool cp_access_ok(int current_el, | ||
823 | - const ARMCPRegInfo *ri, int isread) | ||
824 | -{ | ||
825 | - return (ri->access >> ((current_el * 2) + isread)) & 1; | ||
826 | -} | ||
827 | - | ||
828 | -/* Raw read of a coprocessor register (as needed for migration, etc) */ | ||
829 | -uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri); | ||
830 | - | ||
831 | /** | ||
832 | * write_list_to_cpustate | ||
833 | * @cpu: ARMCPU | ||
834 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | ||
835 | index XXXXXXX..XXXXXXX 100644 | ||
836 | --- a/hw/arm/pxa2xx.c | ||
837 | +++ b/hw/arm/pxa2xx.c | ||
838 | @@ -XXX,XX +XXX,XX @@ | ||
839 | #include "qemu/cutils.h" | ||
840 | #include "qemu/log.h" | ||
841 | #include "qom/object.h" | ||
842 | +#include "target/arm/cpregs.h" | ||
843 | |||
844 | static struct { | ||
845 | hwaddr io_base; | ||
846 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c | ||
847 | index XXXXXXX..XXXXXXX 100644 | ||
848 | --- a/hw/arm/pxa2xx_pic.c | ||
849 | +++ b/hw/arm/pxa2xx_pic.c | ||
850 | @@ -XXX,XX +XXX,XX @@ | ||
851 | #include "hw/sysbus.h" | ||
852 | #include "migration/vmstate.h" | ||
853 | #include "qom/object.h" | ||
854 | +#include "target/arm/cpregs.h" | ||
855 | |||
856 | #define ICIP 0x00 /* Interrupt Controller IRQ Pending register */ | ||
857 | #define ICMR 0x04 /* Interrupt Controller Mask register */ | ||
858 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
859 | index XXXXXXX..XXXXXXX 100644 | ||
860 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
861 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
862 | @@ -XXX,XX +XXX,XX @@ | ||
863 | #include "gicv3_internal.h" | ||
864 | #include "hw/irq.h" | ||
865 | #include "cpu.h" | ||
866 | +#include "target/arm/cpregs.h" | ||
867 | |||
868 | /* | ||
869 | * Special case return value from hppvi_index(); must be larger than | ||
870 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
871 | index XXXXXXX..XXXXXXX 100644 | ||
872 | --- a/hw/intc/arm_gicv3_kvm.c | ||
873 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
874 | @@ -XXX,XX +XXX,XX @@ | ||
875 | #include "vgic_common.h" | ||
876 | #include "migration/blocker.h" | ||
877 | #include "qom/object.h" | ||
878 | +#include "target/arm/cpregs.h" | ||
879 | + | ||
880 | |||
881 | #ifdef DEBUG_GICV3_KVM | ||
882 | #define DPRINTF(fmt, ...) \ | ||
883 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
884 | index XXXXXXX..XXXXXXX 100644 | ||
885 | --- a/target/arm/cpu.c | ||
886 | +++ b/target/arm/cpu.c | ||
887 | @@ -XXX,XX +XXX,XX @@ | ||
888 | #include "kvm_arm.h" | ||
889 | #include "disas/capstone.h" | ||
890 | #include "fpu/softfloat.h" | ||
891 | +#include "cpregs.h" | ||
892 | |||
893 | static void arm_cpu_set_pc(CPUState *cs, vaddr value) | ||
894 | { | ||
895 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
896 | index XXXXXXX..XXXXXXX 100644 | ||
897 | --- a/target/arm/cpu64.c | ||
898 | +++ b/target/arm/cpu64.c | ||
899 | @@ -XXX,XX +XXX,XX @@ | ||
900 | #include "hvf_arm.h" | ||
901 | #include "qapi/visitor.h" | ||
902 | #include "hw/qdev-properties.h" | ||
903 | +#include "cpregs.h" | ||
904 | |||
905 | |||
906 | #ifndef CONFIG_USER_ONLY | ||
907 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
908 | index XXXXXXX..XXXXXXX 100644 | ||
909 | --- a/target/arm/cpu_tcg.c | ||
910 | +++ b/target/arm/cpu_tcg.c | ||
911 | @@ -XXX,XX +XXX,XX @@ | ||
912 | #if !defined(CONFIG_USER_ONLY) | ||
913 | #include "hw/boards.h" | ||
914 | #endif | ||
915 | +#include "cpregs.h" | ||
916 | |||
917 | /* CPU models. These are not needed for the AArch64 linux-user build. */ | ||
918 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
919 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
920 | index XXXXXXX..XXXXXXX 100644 | ||
921 | --- a/target/arm/gdbstub.c | ||
922 | +++ b/target/arm/gdbstub.c | ||
923 | @@ -XXX,XX +XXX,XX @@ | ||
25 | */ | 924 | */ |
26 | FIELD(TBFLAG_ANY, AARCH64_STATE, 31, 1) | 925 | #include "qemu/osdep.h" |
27 | FIELD(TBFLAG_ANY, SS_ACTIVE, 30, 1) | 926 | #include "cpu.h" |
28 | -FIELD(TBFLAG_ANY, PSTATE_SS, 29, 1) /* Not cached. */ | 927 | -#include "internals.h" |
29 | +FIELD(TBFLAG_ANY, PSTATE__SS, 29, 1) /* Not cached. */ | 928 | #include "exec/gdbstub.h" |
30 | FIELD(TBFLAG_ANY, BE_DATA, 28, 1) | 929 | +#include "internals.h" |
31 | FIELD(TBFLAG_ANY, MMUIDX, 24, 4) | 930 | +#include "cpregs.h" |
32 | /* Target EL if we take a floating-point-disabled exception */ | 931 | |
932 | typedef struct RegisterSysregXmlParam { | ||
933 | CPUState *cs; | ||
33 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 934 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
34 | index XXXXXXX..XXXXXXX 100644 | 935 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/helper.c | 936 | --- a/target/arm/helper.c |
36 | +++ b/target/arm/helper.c | 937 | +++ b/target/arm/helper.c |
37 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 938 | @@ -XXX,XX +XXX,XX @@ |
38 | * 0 x Inactive (the TB flag for SS is always 0) | 939 | #include "exec/cpu_ldst.h" |
39 | * 1 0 Active-pending | 940 | #include "semihosting/common-semi.h" |
40 | * 1 1 Active-not-pending | 941 | #endif |
41 | - * SS_ACTIVE is set in hflags; PSTATE_SS is computed every TB. | 942 | +#include "cpregs.h" |
42 | + * SS_ACTIVE is set in hflags; PSTATE__SS is computed every TB. | 943 | |
43 | */ | 944 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ |
44 | if (FIELD_EX32(flags, TBFLAG_ANY, SS_ACTIVE) && | 945 | #define PMCR_NUM_COUNTERS 4 /* QEMU IMPDEF choice */ |
45 | (env->pstate & PSTATE_SS)) { | 946 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c |
46 | - flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE_SS, 1); | 947 | index XXXXXXX..XXXXXXX 100644 |
47 | + flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE__SS, 1); | 948 | --- a/target/arm/op_helper.c |
48 | } | 949 | +++ b/target/arm/op_helper.c |
49 | 950 | @@ -XXX,XX +XXX,XX @@ | |
50 | *pflags = flags; | 951 | #include "internals.h" |
952 | #include "exec/exec-all.h" | ||
953 | #include "exec/cpu_ldst.h" | ||
954 | +#include "cpregs.h" | ||
955 | |||
956 | #define SIGNBIT (uint32_t)0x80000000 | ||
957 | #define SIGNBIT64 ((uint64_t)1 << 63) | ||
51 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 958 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
52 | index XXXXXXX..XXXXXXX 100644 | 959 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/target/arm/translate-a64.c | 960 | --- a/target/arm/translate-a64.c |
54 | +++ b/target/arm/translate-a64.c | 961 | +++ b/target/arm/translate-a64.c |
55 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 962 | @@ -XXX,XX +XXX,XX @@ |
56 | * end the TB | 963 | #include "translate.h" |
57 | */ | 964 | #include "internals.h" |
58 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | 965 | #include "qemu/host-utils.h" |
59 | - dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | 966 | - |
60 | + dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE__SS); | 967 | #include "semihosting/semihost.h" |
61 | dc->is_ldex = false; | 968 | #include "exec/gen-icount.h" |
62 | dc->debug_target_el = FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | 969 | - |
970 | #include "exec/helper-proto.h" | ||
971 | #include "exec/helper-gen.h" | ||
972 | #include "exec/log.h" | ||
973 | - | ||
974 | +#include "cpregs.h" | ||
975 | #include "translate-a64.h" | ||
976 | #include "qemu/atomic128.h" | ||
63 | 977 | ||
64 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 978 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
65 | index XXXXXXX..XXXXXXX 100644 | 979 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/target/arm/translate.c | 980 | --- a/target/arm/translate.c |
67 | +++ b/target/arm/translate.c | 981 | +++ b/target/arm/translate.c |
68 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 982 | @@ -XXX,XX +XXX,XX @@ |
69 | * end the TB | 983 | #include "qemu/bitops.h" |
70 | */ | 984 | #include "arm_ldst.h" |
71 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | 985 | #include "semihosting/semihost.h" |
72 | - dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | 986 | - |
73 | + dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE__SS); | 987 | #include "exec/helper-proto.h" |
74 | dc->is_ldex = false; | 988 | #include "exec/helper-gen.h" |
75 | 989 | - | |
76 | dc->page_start = dc->base.pc_first & TARGET_PAGE_MASK; | 990 | #include "exec/log.h" |
991 | +#include "cpregs.h" | ||
992 | |||
993 | |||
994 | #define ENABLE_ARCH_4T arm_dc_feature(s, ARM_FEATURE_V4T) | ||
77 | -- | 995 | -- |
78 | 2.20.1 | 996 | 2.25.1 |
79 | 997 | ||
80 | 998 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Rearrange the values of the enumerators of CPAccessResult | ||
4 | so that we may directly extract the target el. For the two | ||
5 | special cases in access_check_cp_reg, use CPAccessResult. | ||
6 | |||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20210419202257.161730-28-richard.henderson@linaro.org | 10 | Message-id: 20220501055028.646596-3-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-a64.c | 23 ++++++++++++++--------- | 13 | target/arm/cpregs.h | 26 ++++++++++++-------- |
9 | 1 file changed, 14 insertions(+), 9 deletions(-) | 14 | target/arm/op_helper.c | 56 +++++++++++++++++++++--------------------- |
15 | 2 files changed, 44 insertions(+), 38 deletions(-) | ||
10 | 16 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 17 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 19 | --- a/target/arm/cpregs.h |
14 | +++ b/target/arm/translate-a64.c | 20 | +++ b/target/arm/cpregs.h |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | 21 | @@ -XXX,XX +XXX,XX @@ static inline bool cptype_valid(int cptype) |
16 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | 22 | typedef enum CPAccessResult { |
17 | clean_addr = gen_mte_check1(s, cpu_reg_sp(s, rn), | 23 | /* Access is permitted */ |
18 | true, rn != 31, size); | 24 | CP_ACCESS_OK = 0, |
19 | - do_gpr_st(s, cpu_reg(s, rt), clean_addr, size, true, rt, | 25 | + |
20 | + /* TODO: ARMv8.4-LSE SCTLR.nAA */ | 26 | + /* |
21 | + do_gpr_st(s, cpu_reg(s, rt), clean_addr, size | MO_ALIGN, true, rt, | 27 | + * Combined with one of the following, the low 2 bits indicate the |
22 | disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | 28 | + * target exception level. If 0, the exception is taken to the usual |
23 | return; | 29 | + * target EL (EL1 or PL1 if in EL0, otherwise to the current EL). |
24 | 30 | + */ | |
25 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | 31 | + CP_ACCESS_EL_MASK = 3, |
32 | + | ||
33 | /* | ||
34 | * Access fails due to a configurable trap or enable which would | ||
35 | * result in a categorized exception syndrome giving information about | ||
36 | * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
37 | - * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
38 | - * PL1 if in EL0, otherwise to the current EL). | ||
39 | + * 0xc or 0x18). | ||
40 | */ | ||
41 | - CP_ACCESS_TRAP = 1, | ||
42 | + CP_ACCESS_TRAP = (1 << 2), | ||
43 | + CP_ACCESS_TRAP_EL2 = CP_ACCESS_TRAP | 2, | ||
44 | + CP_ACCESS_TRAP_EL3 = CP_ACCESS_TRAP | 3, | ||
45 | + | ||
46 | /* | ||
47 | * Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
48 | * Note that this is not a catch-all case -- the set of cases which may | ||
49 | * result in this failure is specifically defined by the architecture. | ||
50 | */ | ||
51 | - CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
52 | - /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
53 | - CP_ACCESS_TRAP_EL2 = 3, | ||
54 | - CP_ACCESS_TRAP_EL3 = 4, | ||
55 | - /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
56 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
57 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
58 | + CP_ACCESS_TRAP_UNCATEGORIZED = (2 << 2), | ||
59 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = CP_ACCESS_TRAP_UNCATEGORIZED | 2, | ||
60 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = CP_ACCESS_TRAP_UNCATEGORIZED | 3, | ||
61 | } CPAccessResult; | ||
62 | |||
63 | typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
64 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/op_helper.c | ||
67 | +++ b/target/arm/op_helper.c | ||
68 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
69 | uint32_t isread) | ||
70 | { | ||
71 | const ARMCPRegInfo *ri = rip; | ||
72 | + CPAccessResult res = CP_ACCESS_OK; | ||
73 | int target_el; | ||
74 | |||
75 | if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14 | ||
76 | && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) { | ||
77 | - raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env)); | ||
78 | + res = CP_ACCESS_TRAP; | ||
79 | + goto fail; | ||
80 | } | ||
81 | |||
82 | /* | ||
83 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
84 | mask &= ~((1 << 4) | (1 << 14)); | ||
85 | |||
86 | if (env->cp15.hstr_el2 & mask) { | ||
87 | - target_el = 2; | ||
88 | - goto exept; | ||
89 | + res = CP_ACCESS_TRAP_EL2; | ||
90 | + goto fail; | ||
26 | } | 91 | } |
27 | clean_addr = gen_mte_check1(s, cpu_reg_sp(s, rn), | 92 | } |
28 | false, rn != 31, size); | 93 | |
29 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size, false, true, rt, | 94 | - if (!ri->accessfn) { |
30 | - disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | 95 | + if (ri->accessfn) { |
31 | + /* TODO: ARMv8.4-LSE SCTLR.nAA */ | 96 | + res = ri->accessfn(env, ri, isread); |
32 | + do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size | MO_ALIGN, false, true, | 97 | + } |
33 | + rt, disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | 98 | + if (likely(res == CP_ACCESS_OK)) { |
34 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
35 | return; | ||
36 | |||
37 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | ||
38 | int size = extract32(insn, 30, 2); | ||
39 | TCGv_i64 clean_addr, dirty_addr; | ||
40 | bool is_store = false; | ||
41 | - bool is_signed = false; | ||
42 | bool extend = false; | ||
43 | bool iss_sf; | ||
44 | + MemOp mop; | ||
45 | |||
46 | if (!dc_isar_feature(aa64_rcpc_8_4, s)) { | ||
47 | unallocated_encoding(s); | ||
48 | return; | 99 | return; |
49 | } | 100 | } |
50 | 101 | ||
51 | + /* TODO: ARMv8.4-LSE SCTLR.nAA */ | 102 | - switch (ri->accessfn(env, ri, isread)) { |
52 | + mop = size | MO_ALIGN; | 103 | - case CP_ACCESS_OK: |
53 | + | 104 | - return; |
54 | switch (opc) { | 105 | + fail: |
55 | case 0: /* STLURB */ | 106 | + switch (res & ~CP_ACCESS_EL_MASK) { |
56 | is_store = true; | 107 | case CP_ACCESS_TRAP: |
57 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | 108 | - target_el = exception_target_el(env); |
58 | unallocated_encoding(s); | 109 | - break; |
59 | return; | 110 | - case CP_ACCESS_TRAP_EL2: |
60 | } | 111 | - /* Requesting a trap to EL2 when we're in EL3 is |
61 | - is_signed = true; | 112 | - * a bug in the access function. |
62 | + mop |= MO_SIGN; | 113 | - */ |
114 | - assert(arm_current_el(env) != 3); | ||
115 | - target_el = 2; | ||
116 | - break; | ||
117 | - case CP_ACCESS_TRAP_EL3: | ||
118 | - target_el = 3; | ||
63 | break; | 119 | break; |
64 | case 3: /* LDAPURS* 32-bit variant */ | 120 | case CP_ACCESS_TRAP_UNCATEGORIZED: |
65 | if (size > 1) { | 121 | - target_el = exception_target_el(env); |
66 | unallocated_encoding(s); | 122 | - syndrome = syn_uncategorized(); |
67 | return; | 123 | - break; |
68 | } | 124 | - case CP_ACCESS_TRAP_UNCATEGORIZED_EL2: |
69 | - is_signed = true; | 125 | - target_el = 2; |
70 | + mop |= MO_SIGN; | 126 | - syndrome = syn_uncategorized(); |
71 | extend = true; /* zero-extend 32->64 after signed load */ | 127 | - break; |
128 | - case CP_ACCESS_TRAP_UNCATEGORIZED_EL3: | ||
129 | - target_el = 3; | ||
130 | syndrome = syn_uncategorized(); | ||
72 | break; | 131 | break; |
73 | default: | 132 | default: |
74 | g_assert_not_reached(); | 133 | g_assert_not_reached(); |
75 | } | 134 | } |
76 | 135 | ||
77 | - iss_sf = disas_ldst_compute_iss_sf(size, is_signed, opc); | 136 | -exept: |
78 | + iss_sf = disas_ldst_compute_iss_sf(size, (mop & MO_SIGN) != 0, opc); | 137 | + target_el = res & CP_ACCESS_EL_MASK; |
79 | 138 | + switch (target_el) { | |
80 | if (rn == 31) { | 139 | + case 0: |
81 | gen_check_sp_alignment(s); | 140 | + target_el = exception_target_el(env); |
82 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | 141 | + break; |
83 | if (is_store) { | 142 | + case 2: |
84 | /* Store-Release semantics */ | 143 | + assert(arm_current_el(env) != 3); |
85 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | 144 | + assert(arm_is_el2_enabled(env)); |
86 | - do_gpr_st(s, cpu_reg(s, rt), clean_addr, size, true, rt, iss_sf, true); | 145 | + break; |
87 | + do_gpr_st(s, cpu_reg(s, rt), clean_addr, mop, true, rt, iss_sf, true); | 146 | + case 3: |
88 | } else { | 147 | + assert(arm_feature(env, ARM_FEATURE_EL3)); |
89 | /* | 148 | + break; |
90 | * Load-AcquirePC semantics; we implement as the slightly more | 149 | + default: |
91 | * restrictive Load-Acquire. | 150 | + /* No "direct" traps to EL1 */ |
92 | */ | 151 | + g_assert_not_reached(); |
93 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size + is_signed * MO_SIGN, | 152 | + } |
94 | + do_gpr_ld(s, cpu_reg(s, rt), clean_addr, mop, | 153 | + |
95 | extend, true, rt, iss_sf, true); | 154 | raise_exception(env, EXCP_UDEF, syndrome, target_el); |
96 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | 155 | } |
97 | } | 156 | |
98 | -- | 157 | -- |
99 | 2.20.1 | 158 | 2.25.1 |
100 | 159 | ||
101 | 160 | 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 the case of gpr load, merge the size and is_signed arguments; | 3 | Remove a possible source of error by removing REGINFO_SENTINEL |
4 | otherwise, simply convert size to memop. | 4 | and using ARRAY_SIZE (convinently hidden inside a macro) to |
5 | find the end of the set of regs being registered or modified. | ||
5 | 6 | ||
7 | The space saved by not having the extra array element reduces | ||
8 | the executable's .data.rel.ro section by about 9k. | ||
9 | |||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210419202257.161730-26-richard.henderson@linaro.org | 13 | Message-id: 20220501055028.646596-4-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 15 | --- |
11 | target/arm/translate-a64.c | 78 ++++++++++++++++---------------------- | 16 | target/arm/cpregs.h | 53 +++++++++--------- |
12 | 1 file changed, 33 insertions(+), 45 deletions(-) | 17 | hw/arm/pxa2xx.c | 1 - |
18 | hw/arm/pxa2xx_pic.c | 1 - | ||
19 | hw/intc/arm_gicv3_cpuif.c | 5 -- | ||
20 | hw/intc/arm_gicv3_kvm.c | 1 - | ||
21 | target/arm/cpu64.c | 1 - | ||
22 | target/arm/cpu_tcg.c | 4 -- | ||
23 | target/arm/helper.c | 111 ++++++++------------------------------ | ||
24 | 8 files changed, 48 insertions(+), 129 deletions(-) | ||
13 | 25 | ||
14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 26 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
15 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-a64.c | 28 | --- a/target/arm/cpregs.h |
17 | +++ b/target/arm/translate-a64.c | 29 | +++ b/target/arm/cpregs.h |
18 | @@ -XXX,XX +XXX,XX @@ static void gen_adc_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) | 30 | @@ -XXX,XX +XXX,XX @@ |
19 | * Store from GPR register to memory. | 31 | #define ARM_CP_NO_GDB 0x4000 |
20 | */ | 32 | #define ARM_CP_RAISES_EXC 0x8000 |
21 | static void do_gpr_st_memidx(DisasContext *s, TCGv_i64 source, | 33 | #define ARM_CP_NEWEL 0x10000 |
22 | - TCGv_i64 tcg_addr, int size, int memidx, | 34 | -/* Used only as a terminator for ARMCPRegInfo lists */ |
23 | + TCGv_i64 tcg_addr, MemOp memop, int memidx, | 35 | -#define ARM_CP_SENTINEL 0xfffff |
24 | bool iss_valid, | 36 | /* Mask of only the flag bits in a type field */ |
25 | unsigned int iss_srt, | 37 | #define ARM_CP_FLAG_MASK 0x1f0ff |
26 | bool iss_sf, bool iss_ar) | 38 | |
39 | @@ -XXX,XX +XXX,XX @@ enum { | ||
40 | ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ | ||
41 | }; | ||
42 | |||
43 | -/* | ||
44 | - * Return true if cptype is a valid type field. This is used to try to | ||
45 | - * catch errors where the sentinel has been accidentally left off the end | ||
46 | - * of a list of registers. | ||
47 | - */ | ||
48 | -static inline bool cptype_valid(int cptype) | ||
49 | -{ | ||
50 | - return ((cptype & ~ARM_CP_FLAG_MASK) == 0) | ||
51 | - || ((cptype & ARM_CP_SPECIAL) && | ||
52 | - ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); | ||
53 | -} | ||
54 | - | ||
55 | /* | ||
56 | * Access rights: | ||
57 | * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM | ||
58 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { | ||
59 | #define CPREG_FIELD64(env, ri) \ | ||
60 | (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) | ||
61 | |||
62 | -#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } | ||
63 | +void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, const ARMCPRegInfo *reg, | ||
64 | + void *opaque); | ||
65 | |||
66 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
67 | - const ARMCPRegInfo *regs, void *opaque); | ||
68 | -void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
69 | - const ARMCPRegInfo *regs, void *opaque); | ||
70 | -static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
71 | -{ | ||
72 | - define_arm_cp_regs_with_opaque(cpu, regs, 0); | ||
73 | -} | ||
74 | static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
27 | { | 75 | { |
28 | - g_assert(size <= 3); | 76 | - define_one_arm_cp_reg_with_opaque(cpu, regs, 0); |
29 | - tcg_gen_qemu_st_i64(source, tcg_addr, memidx, s->be_data + size); | 77 | + define_one_arm_cp_reg_with_opaque(cpu, regs, NULL); |
30 | + memop = finalize_memop(s, memop); | ||
31 | + tcg_gen_qemu_st_i64(source, tcg_addr, memidx, memop); | ||
32 | |||
33 | if (iss_valid) { | ||
34 | uint32_t syn; | ||
35 | |||
36 | syn = syn_data_abort_with_iss(0, | ||
37 | - size, | ||
38 | + (memop & MO_SIZE), | ||
39 | false, | ||
40 | iss_srt, | ||
41 | iss_sf, | ||
42 | @@ -XXX,XX +XXX,XX @@ static void do_gpr_st_memidx(DisasContext *s, TCGv_i64 source, | ||
43 | } | 78 | } |
44 | 79 | + | |
45 | static void do_gpr_st(DisasContext *s, TCGv_i64 source, | 80 | +void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs, |
46 | - TCGv_i64 tcg_addr, int size, | 81 | + void *opaque, size_t len); |
47 | + TCGv_i64 tcg_addr, MemOp memop, | 82 | + |
48 | bool iss_valid, | 83 | +#define define_arm_cp_regs_with_opaque(CPU, REGS, OPAQUE) \ |
49 | unsigned int iss_srt, | 84 | + do { \ |
50 | bool iss_sf, bool iss_ar) | 85 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \ |
51 | { | 86 | + define_arm_cp_regs_with_opaque_len(CPU, REGS, OPAQUE, \ |
52 | - do_gpr_st_memidx(s, source, tcg_addr, size, get_mem_index(s), | 87 | + ARRAY_SIZE(REGS)); \ |
53 | + do_gpr_st_memidx(s, source, tcg_addr, memop, get_mem_index(s), | 88 | + } while (0) |
54 | iss_valid, iss_srt, iss_sf, iss_ar); | 89 | + |
55 | } | 90 | +#define define_arm_cp_regs(CPU, REGS) \ |
91 | + define_arm_cp_regs_with_opaque(CPU, REGS, NULL) | ||
92 | + | ||
93 | const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); | ||
56 | 94 | ||
57 | /* | 95 | /* |
58 | * Load from memory to GPR register | 96 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMCPRegUserSpaceInfo { |
59 | */ | 97 | uint64_t fixed_bits; |
60 | -static void do_gpr_ld_memidx(DisasContext *s, | 98 | } ARMCPRegUserSpaceInfo; |
61 | - TCGv_i64 dest, TCGv_i64 tcg_addr, | 99 | |
62 | - int size, bool is_signed, | 100 | -#define REGUSERINFO_SENTINEL { .name = NULL } |
63 | - bool extend, int memidx, | 101 | +void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, |
64 | +static void do_gpr_ld_memidx(DisasContext *s, TCGv_i64 dest, TCGv_i64 tcg_addr, | 102 | + const ARMCPRegUserSpaceInfo *mods, |
65 | + MemOp memop, bool extend, int memidx, | 103 | + size_t mods_len); |
66 | bool iss_valid, unsigned int iss_srt, | 104 | |
67 | bool iss_sf, bool iss_ar) | 105 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); |
68 | { | 106 | +#define modify_arm_cp_regs(REGS, MODS) \ |
69 | - MemOp memop = s->be_data + size; | 107 | + do { \ |
70 | - | 108 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \ |
71 | - g_assert(size <= 3); | 109 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(MODS) == 0); \ |
72 | - | 110 | + modify_arm_cp_regs_with_len(REGS, ARRAY_SIZE(REGS), \ |
73 | - if (is_signed) { | 111 | + MODS, ARRAY_SIZE(MODS)); \ |
74 | - memop += MO_SIGN; | 112 | + } while (0) |
75 | - } | 113 | |
76 | - | 114 | /* CPWriteFn that can be used to implement writes-ignored behaviour */ |
77 | + memop = finalize_memop(s, memop); | 115 | void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, |
78 | tcg_gen_qemu_ld_i64(dest, tcg_addr, memidx, memop); | 116 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c |
79 | 117 | index XXXXXXX..XXXXXXX 100644 | |
80 | - if (extend && is_signed) { | 118 | --- a/hw/arm/pxa2xx.c |
81 | - g_assert(size < 3); | 119 | +++ b/hw/arm/pxa2xx.c |
82 | + if (extend && (memop & MO_SIGN)) { | 120 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pxa_cp_reginfo[] = { |
83 | + g_assert((memop & MO_SIZE) <= MO_32); | 121 | { .name = "PWRMODE", .cp = 14, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 0, |
84 | tcg_gen_ext32u_i64(dest, dest); | 122 | .access = PL1_RW, .type = ARM_CP_IO, |
123 | .readfn = arm_cp_read_zero, .writefn = pxa2xx_pwrmode_write }, | ||
124 | - REGINFO_SENTINEL | ||
125 | }; | ||
126 | |||
127 | static void pxa2xx_setup_cp14(PXA2xxState *s) | ||
128 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/hw/arm/pxa2xx_pic.c | ||
131 | +++ b/hw/arm/pxa2xx_pic.c | ||
132 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pxa_pic_cp_reginfo[] = { | ||
133 | REGINFO_FOR_PIC_CP("ICLR2", 8), | ||
134 | REGINFO_FOR_PIC_CP("ICFP2", 9), | ||
135 | REGINFO_FOR_PIC_CP("ICPR2", 0xa), | ||
136 | - REGINFO_SENTINEL | ||
137 | }; | ||
138 | |||
139 | static const MemoryRegionOps pxa2xx_pic_ops = { | ||
140 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
143 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
144 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
145 | .readfn = icc_igrpen1_el3_read, | ||
146 | .writefn = icc_igrpen1_el3_write, | ||
147 | }, | ||
148 | - REGINFO_SENTINEL | ||
149 | }; | ||
150 | |||
151 | static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
152 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_hcr_reginfo[] = { | ||
153 | .readfn = ich_vmcr_read, | ||
154 | .writefn = ich_vmcr_write, | ||
155 | }, | ||
156 | - REGINFO_SENTINEL | ||
157 | }; | ||
158 | |||
159 | static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = { | ||
160 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = { | ||
161 | .readfn = ich_ap_read, | ||
162 | .writefn = ich_ap_write, | ||
163 | }, | ||
164 | - REGINFO_SENTINEL | ||
165 | }; | ||
166 | |||
167 | static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = { | ||
168 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = { | ||
169 | .readfn = ich_ap_read, | ||
170 | .writefn = ich_ap_write, | ||
171 | }, | ||
172 | - REGINFO_SENTINEL | ||
173 | }; | ||
174 | |||
175 | static void gicv3_cpuif_el_change_hook(ARMCPU *cpu, void *opaque) | ||
176 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) | ||
177 | .readfn = ich_lr_read, | ||
178 | .writefn = ich_lr_write, | ||
179 | }, | ||
180 | - REGINFO_SENTINEL | ||
181 | }; | ||
182 | define_arm_cp_regs(cpu, lr_regset); | ||
183 | } | ||
184 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
185 | index XXXXXXX..XXXXXXX 100644 | ||
186 | --- a/hw/intc/arm_gicv3_kvm.c | ||
187 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
188 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
189 | */ | ||
190 | .resetfn = arm_gicv3_icc_reset, | ||
191 | }, | ||
192 | - REGINFO_SENTINEL | ||
193 | }; | ||
194 | |||
195 | /** | ||
196 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
197 | index XXXXXXX..XXXXXXX 100644 | ||
198 | --- a/target/arm/cpu64.c | ||
199 | +++ b/target/arm/cpu64.c | ||
200 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { | ||
201 | { .name = "L2MERRSR", | ||
202 | .cp = 15, .opc1 = 3, .crm = 15, | ||
203 | .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
204 | - REGINFO_SENTINEL | ||
205 | }; | ||
206 | |||
207 | static void aarch64_a57_initfn(Object *obj) | ||
208 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
209 | index XXXXXXX..XXXXXXX 100644 | ||
210 | --- a/target/arm/cpu_tcg.c | ||
211 | +++ b/target/arm/cpu_tcg.c | ||
212 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa8_cp_reginfo[] = { | ||
213 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
214 | { .name = "L2AUXCR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2, | ||
215 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
216 | - REGINFO_SENTINEL | ||
217 | }; | ||
218 | |||
219 | static void cortex_a8_initfn(Object *obj) | ||
220 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa9_cp_reginfo[] = { | ||
221 | .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST }, | ||
222 | { .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2, | ||
223 | .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST }, | ||
224 | - REGINFO_SENTINEL | ||
225 | }; | ||
226 | |||
227 | static void cortex_a9_initfn(Object *obj) | ||
228 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = { | ||
229 | #endif | ||
230 | { .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3, | ||
231 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
232 | - REGINFO_SENTINEL | ||
233 | }; | ||
234 | |||
235 | static void cortex_a7_initfn(Object *obj) | ||
236 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | ||
237 | .access = PL1_RW, .type = ARM_CP_CONST }, | ||
238 | { .name = "DCACHE_INVAL", .cp = 15, .opc1 = 0, .crn = 15, .crm = 5, | ||
239 | .opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP }, | ||
240 | - REGINFO_SENTINEL | ||
241 | }; | ||
242 | |||
243 | static void cortex_r5_initfn(Object *obj) | ||
244 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
245 | index XXXXXXX..XXXXXXX 100644 | ||
246 | --- a/target/arm/helper.c | ||
247 | +++ b/target/arm/helper.c | ||
248 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = { | ||
249 | .secure = ARM_CP_SECSTATE_S, | ||
250 | .fieldoffset = offsetof(CPUARMState, cp15.contextidr_s), | ||
251 | .resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, }, | ||
252 | - REGINFO_SENTINEL | ||
253 | }; | ||
254 | |||
255 | static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
256 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
257 | { .name = "CACHEMAINT", .cp = 15, .crn = 7, .crm = CP_ANY, | ||
258 | .opc1 = 0, .opc2 = CP_ANY, .access = PL1_W, | ||
259 | .type = ARM_CP_NOP | ARM_CP_OVERRIDE }, | ||
260 | - REGINFO_SENTINEL | ||
261 | }; | ||
262 | |||
263 | static const ARMCPRegInfo not_v6_cp_reginfo[] = { | ||
264 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v6_cp_reginfo[] = { | ||
265 | */ | ||
266 | { .name = "WFI_v5", .cp = 15, .crn = 7, .crm = 8, .opc1 = 0, .opc2 = 2, | ||
267 | .access = PL1_W, .type = ARM_CP_WFI }, | ||
268 | - REGINFO_SENTINEL | ||
269 | }; | ||
270 | |||
271 | static const ARMCPRegInfo not_v7_cp_reginfo[] = { | ||
272 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v7_cp_reginfo[] = { | ||
273 | .opc1 = 0, .opc2 = 0, .access = PL1_RW, .type = ARM_CP_NOP }, | ||
274 | { .name = "NMRR", .cp = 15, .crn = 10, .crm = 2, | ||
275 | .opc1 = 0, .opc2 = 1, .access = PL1_RW, .type = ARM_CP_NOP }, | ||
276 | - REGINFO_SENTINEL | ||
277 | }; | ||
278 | |||
279 | static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
280 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
281 | .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, | ||
282 | .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), | ||
283 | .resetfn = cpacr_reset, .writefn = cpacr_write, .readfn = cpacr_read }, | ||
284 | - REGINFO_SENTINEL | ||
285 | }; | ||
286 | |||
287 | typedef struct pm_event { | ||
288 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
289 | { .name = "TLBIMVAA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, | ||
290 | .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
291 | .writefn = tlbimvaa_write }, | ||
292 | - REGINFO_SENTINEL | ||
293 | }; | ||
294 | |||
295 | static const ARMCPRegInfo v7mp_cp_reginfo[] = { | ||
296 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7mp_cp_reginfo[] = { | ||
297 | { .name = "TLBIMVAAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, | ||
298 | .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
299 | .writefn = tlbimvaa_is_write }, | ||
300 | - REGINFO_SENTINEL | ||
301 | }; | ||
302 | |||
303 | static const ARMCPRegInfo pmovsset_cp_reginfo[] = { | ||
304 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmovsset_cp_reginfo[] = { | ||
305 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), | ||
306 | .writefn = pmovsset_write, | ||
307 | .raw_writefn = raw_write }, | ||
308 | - REGINFO_SENTINEL | ||
309 | }; | ||
310 | |||
311 | static void teecr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
312 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo t2ee_cp_reginfo[] = { | ||
313 | { .name = "TEEHBR", .cp = 14, .crn = 1, .crm = 0, .opc1 = 6, .opc2 = 0, | ||
314 | .access = PL0_RW, .fieldoffset = offsetof(CPUARMState, teehbr), | ||
315 | .accessfn = teehbr_access, .resetvalue = 0 }, | ||
316 | - REGINFO_SENTINEL | ||
317 | }; | ||
318 | |||
319 | static const ARMCPRegInfo v6k_cp_reginfo[] = { | ||
320 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = { | ||
321 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidrprw_s), | ||
322 | offsetoflow32(CPUARMState, cp15.tpidrprw_ns) }, | ||
323 | .resetvalue = 0 }, | ||
324 | - REGINFO_SENTINEL | ||
325 | }; | ||
326 | |||
327 | #ifndef CONFIG_USER_ONLY | ||
328 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
329 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_SEC].cval), | ||
330 | .writefn = gt_sec_cval_write, .raw_writefn = raw_write, | ||
331 | }, | ||
332 | - REGINFO_SENTINEL | ||
333 | }; | ||
334 | |||
335 | static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
336 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
337 | .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
338 | .readfn = gt_virt_cnt_read, | ||
339 | }, | ||
340 | - REGINFO_SENTINEL | ||
341 | }; | ||
342 | |||
343 | #endif | ||
344 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vapa_cp_reginfo[] = { | ||
345 | .access = PL1_W, .accessfn = ats_access, | ||
346 | .writefn = ats_write, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC }, | ||
347 | #endif | ||
348 | - REGINFO_SENTINEL | ||
349 | }; | ||
350 | |||
351 | /* Return basic MPU access permission bits. */ | ||
352 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav7_cp_reginfo[] = { | ||
353 | .fieldoffset = offsetof(CPUARMState, pmsav7.rnr[M_REG_NS]), | ||
354 | .writefn = pmsav7_rgnr_write, | ||
355 | .resetfn = arm_cp_reset_ignore }, | ||
356 | - REGINFO_SENTINEL | ||
357 | }; | ||
358 | |||
359 | static const ARMCPRegInfo pmsav5_cp_reginfo[] = { | ||
360 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav5_cp_reginfo[] = { | ||
361 | { .name = "946_PRBS7", .cp = 15, .crn = 6, .crm = 7, .opc1 = 0, | ||
362 | .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0, | ||
363 | .fieldoffset = offsetof(CPUARMState, cp15.c6_region[7]) }, | ||
364 | - REGINFO_SENTINEL | ||
365 | }; | ||
366 | |||
367 | static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
368 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = { | ||
369 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
370 | .fieldoffset = offsetof(CPUARMState, cp15.far_el[1]), | ||
371 | .resetvalue = 0, }, | ||
372 | - REGINFO_SENTINEL | ||
373 | }; | ||
374 | |||
375 | static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
376 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
377 | /* No offsetoflow32 -- pass the entire TCR to writefn/raw_writefn. */ | ||
378 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.tcr_el[3]), | ||
379 | offsetof(CPUARMState, cp15.tcr_el[1])} }, | ||
380 | - REGINFO_SENTINEL | ||
381 | }; | ||
382 | |||
383 | /* Note that unlike TTBCR, writing to TTBCR2 does not require flushing | ||
384 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo omap_cp_reginfo[] = { | ||
385 | { .name = "C9", .cp = 15, .crn = 9, | ||
386 | .crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_RW, | ||
387 | .type = ARM_CP_CONST | ARM_CP_OVERRIDE, .resetvalue = 0 }, | ||
388 | - REGINFO_SENTINEL | ||
389 | }; | ||
390 | |||
391 | static void xscale_cpar_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
392 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo xscale_cp_reginfo[] = { | ||
393 | { .name = "XSCALE_UNLOCK_DCACHE", | ||
394 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 2, .opc2 = 1, | ||
395 | .access = PL1_W, .type = ARM_CP_NOP }, | ||
396 | - REGINFO_SENTINEL | ||
397 | }; | ||
398 | |||
399 | static const ARMCPRegInfo dummy_c15_cp_reginfo[] = { | ||
400 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dummy_c15_cp_reginfo[] = { | ||
401 | .access = PL1_RW, | ||
402 | .type = ARM_CP_CONST | ARM_CP_NO_RAW | ARM_CP_OVERRIDE, | ||
403 | .resetvalue = 0 }, | ||
404 | - REGINFO_SENTINEL | ||
405 | }; | ||
406 | |||
407 | static const ARMCPRegInfo cache_dirty_status_cp_reginfo[] = { | ||
408 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_dirty_status_cp_reginfo[] = { | ||
409 | { .name = "CDSR", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 6, | ||
410 | .access = PL1_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW, | ||
411 | .resetvalue = 0 }, | ||
412 | - REGINFO_SENTINEL | ||
413 | }; | ||
414 | |||
415 | static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = { | ||
416 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = { | ||
417 | .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
418 | { .name = "CIDCR", .cp = 15, .crm = 14, .opc1 = 0, | ||
419 | .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
420 | - REGINFO_SENTINEL | ||
421 | }; | ||
422 | |||
423 | static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = { | ||
424 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = { | ||
425 | { .name = "TCI_DCACHE", .cp = 15, .crn = 7, .crm = 14, .opc1 = 0, .opc2 = 3, | ||
426 | .access = PL0_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW, | ||
427 | .resetvalue = (1 << 30) }, | ||
428 | - REGINFO_SENTINEL | ||
429 | }; | ||
430 | |||
431 | static const ARMCPRegInfo strongarm_cp_reginfo[] = { | ||
432 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo strongarm_cp_reginfo[] = { | ||
433 | .crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY, | ||
434 | .access = PL1_RW, .resetvalue = 0, | ||
435 | .type = ARM_CP_CONST | ARM_CP_OVERRIDE | ARM_CP_NO_RAW }, | ||
436 | - REGINFO_SENTINEL | ||
437 | }; | ||
438 | |||
439 | static uint64_t midr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
440 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = { | ||
441 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), | ||
442 | offsetof(CPUARMState, cp15.ttbr1_ns) }, | ||
443 | .writefn = vmsa_ttbr_write, }, | ||
444 | - REGINFO_SENTINEL | ||
445 | }; | ||
446 | |||
447 | static uint64_t aa64_fpcr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
448 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
449 | .access = PL1_RW, .accessfn = access_trap_aa32s_el1, | ||
450 | .writefn = sdcr_write, | ||
451 | .fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) }, | ||
452 | - REGINFO_SENTINEL | ||
453 | }; | ||
454 | |||
455 | /* Used to describe the behaviour of EL2 regs when EL2 does not exist. */ | ||
456 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = { | ||
457 | .type = ARM_CP_CONST, | ||
458 | .cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 2, | ||
459 | .access = PL2_RW, .resetvalue = 0 }, | ||
460 | - REGINFO_SENTINEL | ||
461 | }; | ||
462 | |||
463 | /* Ditto, but for registers which exist in ARMv8 but not v7 */ | ||
464 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { | ||
465 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, | ||
466 | .access = PL2_RW, | ||
467 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
468 | - REGINFO_SENTINEL | ||
469 | }; | ||
470 | |||
471 | static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
472 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
473 | .cp = 15, .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3, | ||
474 | .access = PL2_RW, | ||
475 | .fieldoffset = offsetof(CPUARMState, cp15.hstr_el2) }, | ||
476 | - REGINFO_SENTINEL | ||
477 | }; | ||
478 | |||
479 | static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
480 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
481 | .access = PL2_RW, | ||
482 | .fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2), | ||
483 | .writefn = hcr_writehigh }, | ||
484 | - REGINFO_SENTINEL | ||
485 | }; | ||
486 | |||
487 | static CPAccessResult sel2_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
488 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_sec_cp_reginfo[] = { | ||
489 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 6, .opc2 = 2, | ||
490 | .access = PL2_RW, .accessfn = sel2_access, | ||
491 | .fieldoffset = offsetof(CPUARMState, cp15.vstcr_el2) }, | ||
492 | - REGINFO_SENTINEL | ||
493 | }; | ||
494 | |||
495 | static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
496 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_cp_reginfo[] = { | ||
497 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 7, .opc2 = 5, | ||
498 | .access = PL3_W, .type = ARM_CP_NO_RAW, | ||
499 | .writefn = tlbi_aa64_vae3_write }, | ||
500 | - REGINFO_SENTINEL | ||
501 | }; | ||
502 | |||
503 | #ifndef CONFIG_USER_ONLY | ||
504 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { | ||
505 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, | ||
506 | .access = PL1_RW, .accessfn = access_tda, | ||
507 | .type = ARM_CP_NOP }, | ||
508 | - REGINFO_SENTINEL | ||
509 | }; | ||
510 | |||
511 | static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | ||
512 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | ||
513 | .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, | ||
514 | { .name = "DBGDSAR", .cp = 14, .crm = 2, .opc1 = 0, | ||
515 | .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, | ||
516 | - REGINFO_SENTINEL | ||
517 | }; | ||
518 | |||
519 | /* Return the exception level to which exceptions should be taken | ||
520 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) | ||
521 | .fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]), | ||
522 | .writefn = dbgbcr_write, .raw_writefn = raw_write | ||
523 | }, | ||
524 | - REGINFO_SENTINEL | ||
525 | }; | ||
526 | define_arm_cp_regs(cpu, dbgregs); | ||
85 | } | 527 | } |
86 | 528 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) | |
87 | @@ -XXX,XX +XXX,XX @@ static void do_gpr_ld_memidx(DisasContext *s, | 529 | .fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]), |
88 | uint32_t syn; | 530 | .writefn = dbgwcr_write, .raw_writefn = raw_write |
89 | 531 | }, | |
90 | syn = syn_data_abort_with_iss(0, | 532 | - REGINFO_SENTINEL |
91 | - size, | 533 | }; |
92 | - is_signed, | 534 | define_arm_cp_regs(cpu, dbgregs); |
93 | + (memop & MO_SIZE), | 535 | } |
94 | + (memop & MO_SIGN) != 0, | 536 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) |
95 | iss_srt, | 537 | .type = ARM_CP_IO, |
96 | iss_sf, | 538 | .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, |
97 | iss_ar, | 539 | .raw_writefn = pmevtyper_rawwrite }, |
98 | @@ -XXX,XX +XXX,XX @@ static void do_gpr_ld_memidx(DisasContext *s, | 540 | - REGINFO_SENTINEL |
541 | }; | ||
542 | define_arm_cp_regs(cpu, pmev_regs); | ||
543 | g_free(pmevcntr_name); | ||
544 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
545 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 5, | ||
546 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
547 | .resetvalue = extract64(cpu->pmceid1, 32, 32) }, | ||
548 | - REGINFO_SENTINEL | ||
549 | }; | ||
550 | define_arm_cp_regs(cpu, v81_pmu_regs); | ||
551 | } | ||
552 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lor_reginfo[] = { | ||
553 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, | ||
554 | .access = PL1_R, .accessfn = access_lor_ns, | ||
555 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
556 | - REGINFO_SENTINEL | ||
557 | }; | ||
558 | |||
559 | #ifdef TARGET_AARCH64 | ||
560 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pauth_reginfo[] = { | ||
561 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 3, | ||
562 | .access = PL1_RW, .accessfn = access_pauth, | ||
563 | .fieldoffset = offsetof(CPUARMState, keys.apib.hi) }, | ||
564 | - REGINFO_SENTINEL | ||
565 | }; | ||
566 | |||
567 | static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
568 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
569 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 6, .opc2 = 5, | ||
570 | .access = PL3_W, .type = ARM_CP_NO_RAW, | ||
571 | .writefn = tlbi_aa64_rvae3_write }, | ||
572 | - REGINFO_SENTINEL | ||
573 | }; | ||
574 | |||
575 | static const ARMCPRegInfo tlbios_reginfo[] = { | ||
576 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = { | ||
577 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 5, | ||
578 | .access = PL3_W, .type = ARM_CP_NO_RAW, | ||
579 | .writefn = tlbi_aa64_vae3is_write }, | ||
580 | - REGINFO_SENTINEL | ||
581 | }; | ||
582 | |||
583 | static uint64_t rndr_readfn(CPUARMState *env, const ARMCPRegInfo *ri) | ||
584 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rndr_reginfo[] = { | ||
585 | .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END | ARM_CP_IO, | ||
586 | .opc0 = 3, .opc1 = 3, .crn = 2, .crm = 4, .opc2 = 1, | ||
587 | .access = PL0_R, .readfn = rndr_readfn }, | ||
588 | - REGINFO_SENTINEL | ||
589 | }; | ||
590 | |||
591 | #ifndef CONFIG_USER_ONLY | ||
592 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpop_reg[] = { | ||
593 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1, | ||
594 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
595 | .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, | ||
596 | - REGINFO_SENTINEL | ||
597 | }; | ||
598 | |||
599 | static const ARMCPRegInfo dcpodp_reg[] = { | ||
600 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpodp_reg[] = { | ||
601 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1, | ||
602 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
603 | .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, | ||
604 | - REGINFO_SENTINEL | ||
605 | }; | ||
606 | #endif /*CONFIG_USER_ONLY*/ | ||
607 | |||
608 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = { | ||
609 | { .name = "DC_CIGDSW", .state = ARM_CP_STATE_AA64, | ||
610 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 6, | ||
611 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
612 | - REGINFO_SENTINEL | ||
613 | }; | ||
614 | |||
615 | static const ARMCPRegInfo mte_tco_ro_reginfo[] = { | ||
616 | { .name = "TCO", .state = ARM_CP_STATE_AA64, | ||
617 | .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 7, | ||
618 | .type = ARM_CP_CONST, .access = PL0_RW, }, | ||
619 | - REGINFO_SENTINEL | ||
620 | }; | ||
621 | |||
622 | static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
623 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
624 | .accessfn = aa64_zva_access, | ||
625 | #endif | ||
626 | }, | ||
627 | - REGINFO_SENTINEL | ||
628 | }; | ||
629 | |||
630 | #endif | ||
631 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo predinv_reginfo[] = { | ||
632 | { .name = "CPPRCTX", .state = ARM_CP_STATE_AA32, | ||
633 | .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 7, | ||
634 | .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, | ||
635 | - REGINFO_SENTINEL | ||
636 | }; | ||
637 | |||
638 | static uint64_t ccsidr2_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
639 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ccsidr2_reginfo[] = { | ||
640 | .access = PL1_R, | ||
641 | .accessfn = access_aa64_tid2, | ||
642 | .readfn = ccsidr2_read, .type = ARM_CP_NO_RAW }, | ||
643 | - REGINFO_SENTINEL | ||
644 | }; | ||
645 | |||
646 | static CPAccessResult access_aa64_tid3(CPUARMState *env, const ARMCPRegInfo *ri, | ||
647 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo jazelle_regs[] = { | ||
648 | .cp = 14, .crn = 2, .crm = 0, .opc1 = 7, .opc2 = 0, | ||
649 | .accessfn = access_joscr_jmcr, | ||
650 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
651 | - REGINFO_SENTINEL | ||
652 | }; | ||
653 | |||
654 | static const ARMCPRegInfo vhe_reginfo[] = { | ||
655 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { | ||
656 | .access = PL2_RW, .accessfn = e2h_access, | ||
657 | .writefn = gt_virt_cval_write, .raw_writefn = raw_write }, | ||
658 | #endif | ||
659 | - REGINFO_SENTINEL | ||
660 | }; | ||
661 | |||
662 | #ifndef CONFIG_USER_ONLY | ||
663 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1e1_reginfo[] = { | ||
664 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, | ||
665 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
666 | .writefn = ats_write64 }, | ||
667 | - REGINFO_SENTINEL | ||
668 | }; | ||
669 | |||
670 | static const ARMCPRegInfo ats1cp_reginfo[] = { | ||
671 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1cp_reginfo[] = { | ||
672 | .cp = 15, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, | ||
673 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
674 | .writefn = ats_write }, | ||
675 | - REGINFO_SENTINEL | ||
676 | }; | ||
677 | #endif | ||
678 | |||
679 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo actlr2_hactlr2_reginfo[] = { | ||
680 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 3, | ||
681 | .access = PL2_RW, .type = ARM_CP_CONST, | ||
682 | .resetvalue = 0 }, | ||
683 | - REGINFO_SENTINEL | ||
684 | }; | ||
685 | |||
686 | void register_cp_regs_for_features(ARMCPU *cpu) | ||
687 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
688 | .access = PL1_R, .type = ARM_CP_CONST, | ||
689 | .accessfn = access_aa32_tid3, | ||
690 | .resetvalue = cpu->isar.id_isar6 }, | ||
691 | - REGINFO_SENTINEL | ||
692 | }; | ||
693 | define_arm_cp_regs(cpu, v6_idregs); | ||
694 | define_arm_cp_regs(cpu, v6_cp_reginfo); | ||
695 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
696 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 7, | ||
697 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
698 | .resetvalue = cpu->pmceid1 }, | ||
699 | - REGINFO_SENTINEL | ||
700 | }; | ||
701 | #ifdef CONFIG_USER_ONLY | ||
702 | ARMCPRegUserSpaceInfo v8_user_idregs[] = { | ||
703 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
704 | .exported_bits = 0x000000f0ffffffff }, | ||
705 | { .name = "ID_AA64ISAR*_EL1_RESERVED", | ||
706 | .is_glob = true }, | ||
707 | - REGUSERINFO_SENTINEL | ||
708 | }; | ||
709 | modify_arm_cp_regs(v8_idregs, v8_user_idregs); | ||
710 | #endif | ||
711 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
712 | .access = PL2_RW, | ||
713 | .resetvalue = vmpidr_def, | ||
714 | .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, | ||
715 | - REGINFO_SENTINEL | ||
716 | }; | ||
717 | define_arm_cp_regs(cpu, vpidr_regs); | ||
718 | define_arm_cp_regs(cpu, el2_cp_reginfo); | ||
719 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
720 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
721 | .type = ARM_CP_NO_RAW, | ||
722 | .writefn = arm_cp_write_ignore, .readfn = mpidr_read }, | ||
723 | - REGINFO_SENTINEL | ||
724 | }; | ||
725 | define_arm_cp_regs(cpu, vpidr_regs); | ||
726 | define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo); | ||
727 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
728 | .raw_writefn = raw_write, .writefn = sctlr_write, | ||
729 | .fieldoffset = offsetof(CPUARMState, cp15.sctlr_el[3]), | ||
730 | .resetvalue = cpu->reset_sctlr }, | ||
731 | - REGINFO_SENTINEL | ||
732 | }; | ||
733 | |||
734 | define_arm_cp_regs(cpu, el3_regs); | ||
735 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
736 | { .name = "DUMMY", | ||
737 | .cp = 15, .crn = 0, .crm = 7, .opc1 = 0, .opc2 = CP_ANY, | ||
738 | .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
739 | - REGINFO_SENTINEL | ||
740 | }; | ||
741 | ARMCPRegInfo id_v8_midr_cp_reginfo[] = { | ||
742 | { .name = "MIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
743 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
744 | .access = PL1_R, | ||
745 | .accessfn = access_aa64_tid1, | ||
746 | .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, | ||
747 | - REGINFO_SENTINEL | ||
748 | }; | ||
749 | ARMCPRegInfo id_cp_reginfo[] = { | ||
750 | /* These are common to v8 and pre-v8 */ | ||
751 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
752 | .access = PL1_R, | ||
753 | .accessfn = access_aa32_tid1, | ||
754 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
755 | - REGINFO_SENTINEL | ||
756 | }; | ||
757 | /* TLBTR is specific to VMSA */ | ||
758 | ARMCPRegInfo id_tlbtr_reginfo = { | ||
759 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
760 | { .name = "MIDR_EL1", | ||
761 | .exported_bits = 0x00000000ffffffff }, | ||
762 | { .name = "REVIDR_EL1" }, | ||
763 | - REGUSERINFO_SENTINEL | ||
764 | }; | ||
765 | modify_arm_cp_regs(id_v8_midr_cp_reginfo, id_v8_user_midr_cp_reginfo); | ||
766 | #endif | ||
767 | if (arm_feature(env, ARM_FEATURE_OMAPCP) || | ||
768 | arm_feature(env, ARM_FEATURE_STRONGARM)) { | ||
769 | - ARMCPRegInfo *r; | ||
770 | + size_t i; | ||
771 | /* Register the blanket "writes ignored" value first to cover the | ||
772 | * whole space. Then update the specific ID registers to allow write | ||
773 | * access, so that they ignore writes rather than causing them to | ||
774 | * UNDEF. | ||
775 | */ | ||
776 | define_one_arm_cp_reg(cpu, &crn0_wi_reginfo); | ||
777 | - for (r = id_pre_v8_midr_cp_reginfo; | ||
778 | - r->type != ARM_CP_SENTINEL; r++) { | ||
779 | - r->access = PL1_RW; | ||
780 | + for (i = 0; i < ARRAY_SIZE(id_pre_v8_midr_cp_reginfo); ++i) { | ||
781 | + id_pre_v8_midr_cp_reginfo[i].access = PL1_RW; | ||
782 | } | ||
783 | - for (r = id_cp_reginfo; r->type != ARM_CP_SENTINEL; r++) { | ||
784 | - r->access = PL1_RW; | ||
785 | + for (i = 0; i < ARRAY_SIZE(id_cp_reginfo); ++i) { | ||
786 | + id_cp_reginfo[i].access = PL1_RW; | ||
787 | } | ||
788 | id_mpuir_reginfo.access = PL1_RW; | ||
789 | id_tlbtr_reginfo.access = PL1_RW; | ||
790 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
791 | { .name = "MPIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
792 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 5, | ||
793 | .access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW }, | ||
794 | - REGINFO_SENTINEL | ||
795 | }; | ||
796 | #ifdef CONFIG_USER_ONLY | ||
797 | ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { | ||
798 | { .name = "MPIDR_EL1", | ||
799 | .fixed_bits = 0x0000000080000000 }, | ||
800 | - REGUSERINFO_SENTINEL | ||
801 | }; | ||
802 | modify_arm_cp_regs(mpidr_cp_reginfo, mpidr_user_cp_reginfo); | ||
803 | #endif | ||
804 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
805 | .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 0, .opc2 = 1, | ||
806 | .access = PL3_RW, .type = ARM_CP_CONST, | ||
807 | .resetvalue = 0 }, | ||
808 | - REGINFO_SENTINEL | ||
809 | }; | ||
810 | define_arm_cp_regs(cpu, auxcr_reginfo); | ||
811 | if (cpu_isar_feature(aa32_ac2, cpu)) { | ||
812 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
813 | .type = ARM_CP_CONST, | ||
814 | .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 0, | ||
815 | .access = PL1_R, .resetvalue = cpu->reset_cbar }, | ||
816 | - REGINFO_SENTINEL | ||
817 | }; | ||
818 | /* We don't implement a r/w 64 bit CBAR currently */ | ||
819 | assert(arm_feature(env, ARM_FEATURE_CBAR_RO)); | ||
820 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
821 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.vbar_s), | ||
822 | offsetof(CPUARMState, cp15.vbar_ns) }, | ||
823 | .resetvalue = 0 }, | ||
824 | - REGINFO_SENTINEL | ||
825 | }; | ||
826 | define_arm_cp_regs(cpu, vbar_cp_reginfo); | ||
827 | } | ||
828 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
829 | r->writefn); | ||
830 | } | ||
831 | } | ||
832 | - /* Bad type field probably means missing sentinel at end of reg list */ | ||
833 | - assert(cptype_valid(r->type)); | ||
834 | + | ||
835 | for (crm = crmmin; crm <= crmmax; crm++) { | ||
836 | for (opc1 = opc1min; opc1 <= opc1max; opc1++) { | ||
837 | for (opc2 = opc2min; opc2 <= opc2max; opc2++) { | ||
838 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
99 | } | 839 | } |
100 | } | 840 | } |
101 | 841 | ||
102 | -static void do_gpr_ld(DisasContext *s, | 842 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, |
103 | - TCGv_i64 dest, TCGv_i64 tcg_addr, | 843 | - const ARMCPRegInfo *regs, void *opaque) |
104 | - int size, bool is_signed, bool extend, | 844 | +/* Define a whole list of registers */ |
105 | +static void do_gpr_ld(DisasContext *s, TCGv_i64 dest, TCGv_i64 tcg_addr, | 845 | +void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs, |
106 | + MemOp memop, bool extend, | 846 | + void *opaque, size_t len) |
107 | bool iss_valid, unsigned int iss_srt, | ||
108 | bool iss_sf, bool iss_ar) | ||
109 | { | 847 | { |
110 | - do_gpr_ld_memidx(s, dest, tcg_addr, size, is_signed, extend, | 848 | - /* Define a whole list of registers */ |
111 | - get_mem_index(s), | 849 | - const ARMCPRegInfo *r; |
112 | + do_gpr_ld_memidx(s, dest, tcg_addr, memop, extend, get_mem_index(s), | 850 | - for (r = regs; r->type != ARM_CP_SENTINEL; r++) { |
113 | iss_valid, iss_srt, iss_sf, iss_ar); | 851 | - define_one_arm_cp_reg_with_opaque(cpu, r, opaque); |
114 | } | 852 | + size_t i; |
115 | 853 | + for (i = 0; i < len; ++i) { | |
116 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | 854 | + define_one_arm_cp_reg_with_opaque(cpu, regs + i, opaque); |
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 | } | 855 | } |
174 | } | 856 | } |
175 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_unsigned_imm(DisasContext *s, uint32_t insn, | 857 | |
176 | do_gpr_st(s, tcg_rt, clean_addr, size, | 858 | @@ -XXX,XX +XXX,XX @@ void define_arm_cp_regs_with_opaque(ARMCPU *cpu, |
177 | true, rt, iss_sf, false); | 859 | * user-space cannot alter any values and dynamic values pertaining to |
178 | } else { | 860 | * execution state are hidden from user space view anyway. |
179 | - do_gpr_ld(s, tcg_rt, clean_addr, size, is_signed, is_extended, | 861 | */ |
180 | - true, rt, iss_sf, false); | 862 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods) |
181 | + do_gpr_ld(s, tcg_rt, clean_addr, size + is_signed * MO_SIGN, | 863 | +void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, |
182 | + is_extended, true, rt, iss_sf, false); | 864 | + const ARMCPRegUserSpaceInfo *mods, |
865 | + size_t mods_len) | ||
866 | { | ||
867 | - const ARMCPRegUserSpaceInfo *m; | ||
868 | - ARMCPRegInfo *r; | ||
869 | - | ||
870 | - for (m = mods; m->name; m++) { | ||
871 | + for (size_t mi = 0; mi < mods_len; ++mi) { | ||
872 | + const ARMCPRegUserSpaceInfo *m = mods + mi; | ||
873 | GPatternSpec *pat = NULL; | ||
874 | + | ||
875 | if (m->is_glob) { | ||
876 | pat = g_pattern_spec_new(m->name); | ||
183 | } | 877 | } |
184 | } | 878 | - for (r = regs; r->type != ARM_CP_SENTINEL; r++) { |
185 | } | 879 | + for (size_t ri = 0; ri < regs_len; ++ri) { |
186 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | 880 | + ARMCPRegInfo *r = regs + ri; |
187 | * full load-acquire (we only need "load-acquire processor consistent"), | 881 | + |
188 | * but we choose to implement them as full LDAQ. | 882 | if (pat && g_pattern_match_string(pat, r->name)) { |
189 | */ | 883 | r->type = ARM_CP_CONST; |
190 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, size, false, false, | 884 | r->access = PL0U_R; |
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 | -- | 885 | -- |
216 | 2.20.1 | 886 | 2.25.1 |
217 | 887 | ||
218 | 888 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | These particular data structures are not modified at runtime. | ||
4 | |||
5 | Reviewed-by: Alex Bennée <alex.bennee@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 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20210419202257.161730-30-richard.henderson@linaro.org | 8 | Message-id: 20220501055028.646596-5-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/helper.c | 16 ++++++++-------- |
9 | 1 file changed, 11 insertions(+), 4 deletions(-) | 12 | 1 file changed, 8 insertions(+), 8 deletions(-) |
10 | 13 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 16 | --- a/target/arm/helper.c |
14 | +++ b/target/arm/translate-a64.c | 17 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 18 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
16 | bool is_postidx = extract32(insn, 23, 1); | 19 | .resetvalue = cpu->pmceid1 }, |
17 | bool is_q = extract32(insn, 30, 1); | 20 | }; |
18 | TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; | 21 | #ifdef CONFIG_USER_ONLY |
19 | - MemOp endian = s->be_data; | 22 | - ARMCPRegUserSpaceInfo v8_user_idregs[] = { |
20 | + MemOp endian, align, mop; | 23 | + static const ARMCPRegUserSpaceInfo v8_user_idregs[] = { |
21 | 24 | { .name = "ID_AA64PFR0_EL1", | |
22 | int total; /* total bytes */ | 25 | .exported_bits = 0x000f000f00ff0000, |
23 | int elements; /* elements per vector */ | 26 | .fixed_bits = 0x0000000000000011 }, |
24 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 27 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
28 | */ | ||
29 | if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
30 | if (arm_feature(env, ARM_FEATURE_AARCH64)) { | ||
31 | - ARMCPRegInfo nsacr = { | ||
32 | + static const ARMCPRegInfo nsacr = { | ||
33 | .name = "NSACR", .type = ARM_CP_CONST, | ||
34 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, | ||
35 | .access = PL1_RW, .accessfn = nsacr_access, | ||
36 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
37 | }; | ||
38 | define_one_arm_cp_reg(cpu, &nsacr); | ||
39 | } else { | ||
40 | - ARMCPRegInfo nsacr = { | ||
41 | + static const ARMCPRegInfo nsacr = { | ||
42 | .name = "NSACR", | ||
43 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, | ||
44 | .access = PL3_RW | PL1_R, | ||
45 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
46 | } | ||
47 | } else { | ||
48 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
49 | - ARMCPRegInfo nsacr = { | ||
50 | + static const ARMCPRegInfo nsacr = { | ||
51 | .name = "NSACR", .type = ARM_CP_CONST, | ||
52 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, | ||
53 | .access = PL1_R, | ||
54 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
55 | .access = PL1_R, .type = ARM_CP_CONST, | ||
56 | .resetvalue = cpu->pmsav7_dregion << 8 | ||
57 | }; | ||
58 | - ARMCPRegInfo crn0_wi_reginfo = { | ||
59 | + static const ARMCPRegInfo crn0_wi_reginfo = { | ||
60 | .name = "CRN0_WI", .cp = 15, .crn = 0, .crm = CP_ANY, | ||
61 | .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_W, | ||
62 | .type = ARM_CP_NOP | ARM_CP_OVERRIDE | ||
63 | }; | ||
64 | #ifdef CONFIG_USER_ONLY | ||
65 | - ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = { | ||
66 | + static const ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = { | ||
67 | { .name = "MIDR_EL1", | ||
68 | .exported_bits = 0x00000000ffffffff }, | ||
69 | { .name = "REVIDR_EL1" }, | ||
70 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
71 | .access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW }, | ||
72 | }; | ||
73 | #ifdef CONFIG_USER_ONLY | ||
74 | - ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { | ||
75 | + static const ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { | ||
76 | { .name = "MPIDR_EL1", | ||
77 | .fixed_bits = 0x0000000080000000 }, | ||
78 | }; | ||
79 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
25 | } | 80 | } |
26 | 81 | ||
27 | /* For our purposes, bytes are always little-endian. */ | 82 | if (arm_feature(env, ARM_FEATURE_VBAR)) { |
28 | + endian = s->be_data; | 83 | - ARMCPRegInfo vbar_cp_reginfo[] = { |
29 | if (size == 0) { | 84 | + static const ARMCPRegInfo vbar_cp_reginfo[] = { |
30 | endian = MO_LE; | 85 | { .name = "VBAR", .state = ARM_CP_STATE_BOTH, |
31 | } | 86 | .opc0 = 3, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0, |
32 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 87 | .access = PL1_RW, .writefn = vbar_write, |
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 | -- | 88 | -- |
64 | 2.20.1 | 89 | 2.25.1 |
65 | 90 | ||
66 | 91 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Use this to signal when memory access alignment is required. | 3 | Instead of defining ARM_CP_FLAG_MASK to remove flags, |
4 | This value comes from the CCR register for M-profile, and | 4 | define ARM_CP_SPECIAL_MASK to isolate special cases. |
5 | from the SCTLR register for A-profile. | 5 | Sort the specials to the low bits. Use an enum. |
6 | 6 | ||
7 | Split the large comment block so as to document each | ||
8 | value separately. | ||
9 | |||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Message-id: 20220501055028.646596-6-richard.henderson@linaro.org |
9 | Message-id: 20210419202257.161730-11-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 14 | --- |
12 | target/arm/cpu.h | 2 ++ | 15 | target/arm/cpregs.h | 130 +++++++++++++++++++++++-------------- |
13 | target/arm/translate.h | 2 ++ | 16 | target/arm/cpu.c | 4 +- |
14 | target/arm/helper.c | 19 +++++++++++++++++-- | 17 | target/arm/helper.c | 4 +- |
15 | target/arm/translate-a64.c | 1 + | 18 | target/arm/translate-a64.c | 6 +- |
16 | target/arm/translate.c | 7 +++---- | 19 | target/arm/translate.c | 6 +- |
17 | 5 files changed, 25 insertions(+), 6 deletions(-) | 20 | 5 files changed, 92 insertions(+), 58 deletions(-) |
18 | 21 | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 22 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
20 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 24 | --- a/target/arm/cpregs.h |
22 | +++ b/target/arm/cpu.h | 25 | +++ b/target/arm/cpregs.h |
23 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, MMUIDX, 4, 4) | 26 | @@ -XXX,XX +XXX,XX @@ |
24 | FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2) | 27 | #define TARGET_ARM_CPREGS_H |
25 | /* For A-profile only, target EL for debug exceptions. */ | ||
26 | FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 10, 2) | ||
27 | +/* Memory operations require alignment: SCTLR_ELx.A or CCR.UNALIGN_TRP */ | ||
28 | +FIELD(TBFLAG_ANY, ALIGN_MEM, 12, 1) | ||
29 | 28 | ||
30 | /* | 29 | /* |
31 | * Bit usage when in AArch32 state, both A- and M-profile. | 30 | - * ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a |
32 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 31 | - * special-behaviour cp reg and bits [11..8] indicate what behaviour |
33 | index XXXXXXX..XXXXXXX 100644 | 32 | - * it has. Otherwise it is a simple cp reg, where CONST indicates that |
34 | --- a/target/arm/translate.h | 33 | - * TCG can assume the value to be constant (ie load at translate time) |
35 | +++ b/target/arm/translate.h | 34 | - * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END |
36 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 35 | - * indicates that the TB should not be ended after a write to this register |
37 | bool bt; | 36 | - * (the default is that the TB ends after cp writes). OVERRIDE permits |
38 | /* True if any CP15 access is trapped by HSTR_EL2 */ | 37 | - * a register definition to override a previous definition for the |
39 | bool hstr_active; | 38 | - * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the |
40 | + /* True if memory operations require alignment */ | 39 | - * old must have the OVERRIDE bit set. |
41 | + bool align_mem; | 40 | - * ALIAS indicates that this register is an alias view of some underlying |
42 | /* | 41 | - * state which is also visible via another register, and that the other |
43 | * >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. | 42 | - * register is handling migration and reset; registers marked ALIAS will not be |
44 | * < 0, set by the current instruction. | 43 | - * migrated but may have their state set by syncing of register state from KVM. |
44 | - * NO_RAW indicates that this register has no underlying state and does not | ||
45 | - * support raw access for state saving/loading; it will not be used for either | ||
46 | - * migration or KVM state synchronization. (Typically this is for "registers" | ||
47 | - * which are actually used as instructions for cache maintenance and so on.) | ||
48 | - * IO indicates that this register does I/O and therefore its accesses | ||
49 | - * need to be marked with gen_io_start() and also end the TB. In particular, | ||
50 | - * registers which implement clocks or timers require this. | ||
51 | - * RAISES_EXC is for when the read or write hook might raise an exception; | ||
52 | - * the generated code will synchronize the CPU state before calling the hook | ||
53 | - * so that it is safe for the hook to call raise_exception(). | ||
54 | - * NEWEL is for writes to registers that might change the exception | ||
55 | - * level - typically on older ARM chips. For those cases we need to | ||
56 | - * re-read the new el when recomputing the translation flags. | ||
57 | + * ARMCPRegInfo type field bits: | ||
58 | */ | ||
59 | -#define ARM_CP_SPECIAL 0x0001 | ||
60 | -#define ARM_CP_CONST 0x0002 | ||
61 | -#define ARM_CP_64BIT 0x0004 | ||
62 | -#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
63 | -#define ARM_CP_OVERRIDE 0x0010 | ||
64 | -#define ARM_CP_ALIAS 0x0020 | ||
65 | -#define ARM_CP_IO 0x0040 | ||
66 | -#define ARM_CP_NO_RAW 0x0080 | ||
67 | -#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
68 | -#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
69 | -#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
70 | -#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
71 | -#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
72 | -#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) | ||
73 | -#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) | ||
74 | -#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA | ||
75 | -#define ARM_CP_FPU 0x1000 | ||
76 | -#define ARM_CP_SVE 0x2000 | ||
77 | -#define ARM_CP_NO_GDB 0x4000 | ||
78 | -#define ARM_CP_RAISES_EXC 0x8000 | ||
79 | -#define ARM_CP_NEWEL 0x10000 | ||
80 | -/* Mask of only the flag bits in a type field */ | ||
81 | -#define ARM_CP_FLAG_MASK 0x1f0ff | ||
82 | +enum { | ||
83 | + /* | ||
84 | + * Register must be handled specially during translation. | ||
85 | + * The method is one of the values below: | ||
86 | + */ | ||
87 | + ARM_CP_SPECIAL_MASK = 0x000f, | ||
88 | + /* Special: no change to PE state: writes ignored, reads ignored. */ | ||
89 | + ARM_CP_NOP = 0x0001, | ||
90 | + /* Special: sysreg is WFI, for v5 and v6. */ | ||
91 | + ARM_CP_WFI = 0x0002, | ||
92 | + /* Special: sysreg is NZCV. */ | ||
93 | + ARM_CP_NZCV = 0x0003, | ||
94 | + /* Special: sysreg is CURRENTEL. */ | ||
95 | + ARM_CP_CURRENTEL = 0x0004, | ||
96 | + /* Special: sysreg is DC ZVA or similar. */ | ||
97 | + ARM_CP_DC_ZVA = 0x0005, | ||
98 | + ARM_CP_DC_GVA = 0x0006, | ||
99 | + ARM_CP_DC_GZVA = 0x0007, | ||
100 | + | ||
101 | + /* Flag: reads produce resetvalue; writes ignored. */ | ||
102 | + ARM_CP_CONST = 1 << 4, | ||
103 | + /* Flag: For ARM_CP_STATE_AA32, sysreg is 64-bit. */ | ||
104 | + ARM_CP_64BIT = 1 << 5, | ||
105 | + /* | ||
106 | + * Flag: TB should not be ended after a write to this register | ||
107 | + * (the default is that the TB ends after cp writes). | ||
108 | + */ | ||
109 | + ARM_CP_SUPPRESS_TB_END = 1 << 6, | ||
110 | + /* | ||
111 | + * Flag: Permit a register definition to override a previous definition | ||
112 | + * for the same (cp, is64, crn, crm, opc1, opc2) tuple: either the new | ||
113 | + * or the old must have the ARM_CP_OVERRIDE bit set. | ||
114 | + */ | ||
115 | + ARM_CP_OVERRIDE = 1 << 7, | ||
116 | + /* | ||
117 | + * Flag: Register is an alias view of some underlying state which is also | ||
118 | + * visible via another register, and that the other register is handling | ||
119 | + * migration and reset; registers marked ARM_CP_ALIAS will not be migrated | ||
120 | + * but may have their state set by syncing of register state from KVM. | ||
121 | + */ | ||
122 | + ARM_CP_ALIAS = 1 << 8, | ||
123 | + /* | ||
124 | + * Flag: Register does I/O and therefore its accesses need to be marked | ||
125 | + * with gen_io_start() and also end the TB. In particular, registers which | ||
126 | + * implement clocks or timers require this. | ||
127 | + */ | ||
128 | + ARM_CP_IO = 1 << 9, | ||
129 | + /* | ||
130 | + * Flag: Register has no underlying state and does not support raw access | ||
131 | + * for state saving/loading; it will not be used for either migration or | ||
132 | + * KVM state synchronization. Typically this is for "registers" which are | ||
133 | + * actually used as instructions for cache maintenance and so on. | ||
134 | + */ | ||
135 | + ARM_CP_NO_RAW = 1 << 10, | ||
136 | + /* | ||
137 | + * Flag: The read or write hook might raise an exception; the generated | ||
138 | + * code will synchronize the CPU state before calling the hook so that it | ||
139 | + * is safe for the hook to call raise_exception(). | ||
140 | + */ | ||
141 | + ARM_CP_RAISES_EXC = 1 << 11, | ||
142 | + /* | ||
143 | + * Flag: Writes to the sysreg might change the exception level - typically | ||
144 | + * on older ARM chips. For those cases we need to re-read the new el when | ||
145 | + * recomputing the translation flags. | ||
146 | + */ | ||
147 | + ARM_CP_NEWEL = 1 << 12, | ||
148 | + /* | ||
149 | + * Flag: Access check for this sysreg is identical to accessing FPU state | ||
150 | + * from an instruction: use translation fp_access_check(). | ||
151 | + */ | ||
152 | + ARM_CP_FPU = 1 << 13, | ||
153 | + /* | ||
154 | + * Flag: Access check for this sysreg is identical to accessing SVE state | ||
155 | + * from an instruction: use translation sve_access_check(). | ||
156 | + */ | ||
157 | + ARM_CP_SVE = 1 << 14, | ||
158 | + /* Flag: Do not expose in gdb sysreg xml. */ | ||
159 | + ARM_CP_NO_GDB = 1 << 15, | ||
160 | +}; | ||
161 | |||
162 | /* | ||
163 | * Valid values for ARMCPRegInfo state field, indicating which of | ||
164 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
165 | index XXXXXXX..XXXXXXX 100644 | ||
166 | --- a/target/arm/cpu.c | ||
167 | +++ b/target/arm/cpu.c | ||
168 | @@ -XXX,XX +XXX,XX @@ static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque) | ||
169 | ARMCPRegInfo *ri = value; | ||
170 | ARMCPU *cpu = opaque; | ||
171 | |||
172 | - if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS)) { | ||
173 | + if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS)) { | ||
174 | return; | ||
175 | } | ||
176 | |||
177 | @@ -XXX,XX +XXX,XX @@ static void cp_reg_check_reset(gpointer key, gpointer value, gpointer opaque) | ||
178 | ARMCPU *cpu = opaque; | ||
179 | uint64_t oldvalue, newvalue; | ||
180 | |||
181 | - if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS | ARM_CP_NO_RAW)) { | ||
182 | + if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS | ARM_CP_NO_RAW)) { | ||
183 | return; | ||
184 | } | ||
185 | |||
45 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 186 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
46 | index XXXXXXX..XXXXXXX 100644 | 187 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/helper.c | 188 | --- a/target/arm/helper.c |
48 | +++ b/target/arm/helper.c | 189 | +++ b/target/arm/helper.c |
49 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el, | 190 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
50 | ARMMMUIdx mmu_idx) | 191 | * multiple times. Special registers (ie NOP/WFI) are |
51 | { | 192 | * never migratable and not even raw-accessible. |
52 | CPUARMTBFlags flags = {}; | ||
53 | + uint32_t ccr = env->v7m.ccr[env->v7m.secure]; | ||
54 | + | ||
55 | + /* Without HaveMainExt, CCR.UNALIGN_TRP is RES1. */ | ||
56 | + if (ccr & R_V7M_CCR_UNALIGN_TRP_MASK) { | ||
57 | + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); | ||
58 | + } | ||
59 | |||
60 | if (arm_v7m_is_handler_mode(env)) { | ||
61 | DP_TBFLAG_M32(flags, HANDLER, 1); | ||
62 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el, | ||
63 | */ | 193 | */ |
64 | if (arm_feature(env, ARM_FEATURE_V8) && | 194 | - if ((r->type & ARM_CP_SPECIAL)) { |
65 | !((mmu_idx & ARM_MMU_IDX_M_NEGPRI) && | 195 | + if (r->type & ARM_CP_SPECIAL_MASK) { |
66 | - (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_STKOFHFNMIGN_MASK))) { | 196 | r2->type |= ARM_CP_NO_RAW; |
67 | + (ccr & R_V7M_CCR_STKOFHFNMIGN_MASK))) { | 197 | } |
68 | DP_TBFLAG_M32(flags, STACKCHECK, 1); | 198 | if (((r->crm == CP_ANY) && crm != 0) || |
69 | } | 199 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
70 | 200 | /* Check that the register definition has enough info to handle | |
71 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, | 201 | * reads and writes if they are permitted. |
72 | ARMMMUIdx mmu_idx) | 202 | */ |
73 | { | 203 | - if (!(r->type & (ARM_CP_SPECIAL|ARM_CP_CONST))) { |
74 | CPUARMTBFlags flags = rebuild_hflags_aprofile(env); | 204 | + if (!(r->type & (ARM_CP_SPECIAL_MASK | ARM_CP_CONST))) { |
75 | + int el = arm_current_el(env); | 205 | if (r->access & PL3_R) { |
76 | + | 206 | assert((r->fieldoffset || |
77 | + if (arm_sctlr(env, el) & SCTLR_A) { | 207 | (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1])) || |
78 | + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); | ||
79 | + } | ||
80 | |||
81 | if (arm_el_is_aa64(env, 1)) { | ||
82 | DP_TBFLAG_A32(flags, VFPEN, 1); | ||
83 | } | ||
84 | |||
85 | - if (arm_current_el(env) < 2 && env->cp15.hstr_el2 && | ||
86 | + if (el < 2 && env->cp15.hstr_el2 && | ||
87 | (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | ||
88 | DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1); | ||
89 | } | ||
90 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
91 | |||
92 | sctlr = regime_sctlr(env, stage1); | ||
93 | |||
94 | + if (sctlr & SCTLR_A) { | ||
95 | + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); | ||
96 | + } | ||
97 | + | ||
98 | if (arm_cpu_data_is_big_endian_a64(el, sctlr)) { | ||
99 | DP_TBFLAG_ANY(flags, BE_DATA, 1); | ||
100 | } | ||
101 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 208 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
102 | index XXXXXXX..XXXXXXX 100644 | 209 | index XXXXXXX..XXXXXXX 100644 |
103 | --- a/target/arm/translate-a64.c | 210 | --- a/target/arm/translate-a64.c |
104 | +++ b/target/arm/translate-a64.c | 211 | +++ b/target/arm/translate-a64.c |
105 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 212 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, |
106 | dc->user = (dc->current_el == 0); | 213 | } |
107 | #endif | 214 | |
108 | dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); | 215 | /* Handle special cases first */ |
109 | + dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); | 216 | - switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { |
110 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); | 217 | + switch (ri->type & ARM_CP_SPECIAL_MASK) { |
111 | dc->sve_len = (EX_TBFLAG_A64(tb_flags, ZCR_LEN) + 1) * 16; | 218 | + case 0: |
112 | dc->pauth_active = EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); | 219 | + break; |
220 | case ARM_CP_NOP: | ||
221 | return; | ||
222 | case ARM_CP_NZCV: | ||
223 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
224 | } | ||
225 | return; | ||
226 | default: | ||
227 | - break; | ||
228 | + g_assert_not_reached(); | ||
229 | } | ||
230 | if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) { | ||
231 | return; | ||
113 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 232 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
114 | index XXXXXXX..XXXXXXX 100644 | 233 | index XXXXXXX..XXXXXXX 100644 |
115 | --- a/target/arm/translate.c | 234 | --- a/target/arm/translate.c |
116 | +++ b/target/arm/translate.c | 235 | +++ b/target/arm/translate.c |
117 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 236 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
118 | { | 237 | } |
119 | TCGv addr; | 238 | |
120 | 239 | /* Handle special cases first */ | |
121 | - if (arm_dc_feature(s, ARM_FEATURE_M) && | 240 | - switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { |
122 | - !arm_dc_feature(s, ARM_FEATURE_M_MAIN)) { | 241 | + switch (ri->type & ARM_CP_SPECIAL_MASK) { |
123 | + if (s->align_mem) { | 242 | + case 0: |
124 | opc |= MO_ALIGN; | 243 | + break; |
125 | } | 244 | case ARM_CP_NOP: |
126 | 245 | return; | |
127 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 246 | case ARM_CP_WFI: |
128 | { | 247 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
129 | TCGv addr; | 248 | s->base.is_jmp = DISAS_WFI; |
130 | 249 | return; | |
131 | - if (arm_dc_feature(s, ARM_FEATURE_M) && | 250 | default: |
132 | - !arm_dc_feature(s, ARM_FEATURE_M_MAIN)) { | 251 | - break; |
133 | + if (s->align_mem) { | 252 | + g_assert_not_reached(); |
134 | opc |= MO_ALIGN; | 253 | } |
135 | } | 254 | |
136 | 255 | if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { | |
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 | -- | 256 | -- |
146 | 2.20.1 | 257 | 2.25.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 | We're about to split tbflags into two parts. These macros | 3 | Standardize on g_assert_not_reached() for "should not happen". |
4 | will ensure that the correct part is used with the correct | 4 | Retain abort() when preceeded by fprintf or error_report. |
5 | set of bits. | ||
6 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20220501055028.646596-7-richard.henderson@linaro.org |
9 | Message-id: 20210419202257.161730-5-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/cpu.h | 22 +++++++++- | 11 | target/arm/helper.c | 7 +++---- |
13 | target/arm/helper-a64.c | 2 +- | 12 | target/arm/hvf/hvf.c | 2 +- |
14 | target/arm/helper.c | 85 +++++++++++++++++--------------------- | 13 | target/arm/kvm-stub.c | 4 ++-- |
15 | target/arm/translate-a64.c | 36 ++++++++-------- | 14 | target/arm/kvm.c | 4 ++-- |
16 | target/arm/translate.c | 48 ++++++++++----------- | 15 | target/arm/machine.c | 4 ++-- |
17 | 5 files changed, 101 insertions(+), 92 deletions(-) | 16 | target/arm/translate-a64.c | 4 ++-- |
17 | target/arm/translate-neon.c | 2 +- | ||
18 | target/arm/translate.c | 4 ++-- | ||
19 | 8 files changed, 15 insertions(+), 16 deletions(-) | ||
18 | 20 | ||
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 | 21 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
73 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
74 | --- a/target/arm/helper.c | 23 | --- a/target/arm/helper.c |
75 | +++ b/target/arm/helper.c | 24 | +++ b/target/arm/helper.c |
76 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | 25 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
77 | static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | 26 | break; |
78 | ARMMMUIdx mmu_idx, uint32_t flags) | 27 | default: |
79 | { | 28 | /* broken reginfo with out-of-range opc1 */ |
80 | - flags = FIELD_DP32(flags, TBFLAG_ANY, FPEXC_EL, fp_el); | 29 | - assert(false); |
81 | - flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, | 30 | - break; |
82 | - arm_to_core_mmu_idx(mmu_idx)); | 31 | + g_assert_not_reached(); |
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 | } | 32 | } |
173 | - flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); | 33 | /* assert our permissions are not too lax (stricter is fine) */ |
174 | - flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); | 34 | assert((r->access & ~mask) == 0); |
175 | + DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); | 35 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, |
176 | + DP_TBFLAG_A64(flags, ZCR_LEN, zcr_len); | 36 | break; |
177 | } | 37 | default: |
178 | 38 | /* Never happens, but compiler isn't smart enough to tell. */ | |
179 | sctlr = regime_sctlr(env, stage1); | 39 | - abort(); |
180 | 40 | + g_assert_not_reached(); | |
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 | } | 41 | } |
194 | } | 42 | } |
195 | 43 | *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); | |
196 | if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { | 44 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, |
197 | /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */ | 45 | break; |
198 | if (sctlr & (el == 0 ? SCTLR_BT0 : SCTLR_BT1)) { | 46 | default: |
199 | - flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1); | 47 | /* Never happens, but compiler isn't smart enough to tell. */ |
200 | + DP_TBFLAG_A64(flags, BT, 1); | 48 | - abort(); |
49 | + g_assert_not_reached(); | ||
201 | } | 50 | } |
202 | } | 51 | } |
203 | 52 | if (domain_prot == 3) { | |
204 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | 53 | diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c |
205 | case ARMMMUIdx_SE10_1: | 54 | index XXXXXXX..XXXXXXX 100644 |
206 | case ARMMMUIdx_SE10_1_PAN: | 55 | --- a/target/arm/hvf/hvf.c |
207 | /* TODO: ARMv8.3-NV */ | 56 | +++ b/target/arm/hvf/hvf.c |
208 | - flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); | 57 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) |
209 | + DP_TBFLAG_A64(flags, UNPRIV, 1); | 58 | /* we got kicked, no exit to process */ |
210 | break; | 59 | return 0; |
211 | case ARMMMUIdx_E20_2: | 60 | default: |
212 | case ARMMMUIdx_E20_2_PAN: | 61 | - assert(0); |
213 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | 62 | + g_assert_not_reached(); |
214 | * gated by HCR_EL2.<E2H,TGE> == '11', and so is LDTR. | 63 | } |
215 | */ | 64 | |
216 | if (env->cp15.hcr_el2 & HCR_TGE) { | 65 | hvf_sync_vtimer(cpu); |
217 | - flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); | 66 | diff --git a/target/arm/kvm-stub.c b/target/arm/kvm-stub.c |
218 | + DP_TBFLAG_A64(flags, UNPRIV, 1); | 67 | index XXXXXXX..XXXXXXX 100644 |
219 | } | 68 | --- a/target/arm/kvm-stub.c |
69 | +++ b/target/arm/kvm-stub.c | ||
70 | @@ -XXX,XX +XXX,XX @@ | ||
71 | |||
72 | bool write_kvmstate_to_list(ARMCPU *cpu) | ||
73 | { | ||
74 | - abort(); | ||
75 | + g_assert_not_reached(); | ||
76 | } | ||
77 | |||
78 | bool write_list_to_kvmstate(ARMCPU *cpu, int level) | ||
79 | { | ||
80 | - abort(); | ||
81 | + g_assert_not_reached(); | ||
82 | } | ||
83 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/target/arm/kvm.c | ||
86 | +++ b/target/arm/kvm.c | ||
87 | @@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu) | ||
88 | ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r); | ||
220 | break; | 89 | break; |
221 | default: | 90 | default: |
222 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | 91 | - abort(); |
223 | * 4) If no Allocation Tag Access, then all accesses are Unchecked. | 92 | + g_assert_not_reached(); |
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 | } | 93 | } |
235 | /* And again for unprivileged accesses, if required. */ | 94 | if (ret) { |
236 | - if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV) | 95 | ok = false; |
237 | + if (EX_TBFLAG_A64(flags, UNPRIV) | 96 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level) |
238 | && tbid | 97 | r.addr = (uintptr_t)(cpu->cpreg_values + i); |
239 | && !(env->pstate & PSTATE_TCO) | 98 | break; |
240 | && (sctlr & SCTLR_TCF0) | 99 | default: |
241 | && allocation_tag_access_enabled(env, 0, sctlr)) { | 100 | - abort(); |
242 | - flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1); | 101 | + g_assert_not_reached(); |
243 | + DP_TBFLAG_A64(flags, MTE0_ACTIVE, 1); | ||
244 | } | 102 | } |
245 | /* Cache TCMA as well as TBI. */ | 103 | ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r); |
246 | - flags = FIELD_DP32(flags, TBFLAG_A64, TCMA, | 104 | if (ret) { |
247 | - aa64_va_parameter_tcma(tcr, mmu_idx)); | 105 | diff --git a/target/arm/machine.c b/target/arm/machine.c |
248 | + DP_TBFLAG_A64(flags, TCMA, aa64_va_parameter_tcma(tcr, mmu_idx)); | 106 | index XXXXXXX..XXXXXXX 100644 |
107 | --- a/target/arm/machine.c | ||
108 | +++ b/target/arm/machine.c | ||
109 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) | ||
110 | if (kvm_enabled()) { | ||
111 | if (!write_kvmstate_to_list(cpu)) { | ||
112 | /* This should never fail */ | ||
113 | - abort(); | ||
114 | + g_assert_not_reached(); | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) | ||
119 | } else { | ||
120 | if (!write_cpustate_to_list(cpu, false)) { | ||
121 | /* This should never fail. */ | ||
122 | - abort(); | ||
123 | + g_assert_not_reached(); | ||
124 | } | ||
249 | } | 125 | } |
250 | 126 | ||
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 | 127 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
330 | index XXXXXXX..XXXXXXX 100644 | 128 | index XXXXXXX..XXXXXXX 100644 |
331 | --- a/target/arm/translate-a64.c | 129 | --- a/target/arm/translate-a64.c |
332 | +++ b/target/arm/translate-a64.c | 130 | +++ b/target/arm/translate-a64.c |
333 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 131 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) |
334 | !arm_el_is_aa64(env, 3); | 132 | gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst); |
335 | dc->thumb = 0; | 133 | break; |
336 | dc->sctlr_b = 0; | 134 | default: |
337 | - dc->be_data = FIELD_EX32(tb_flags, TBFLAG_ANY, BE_DATA) ? MO_BE : MO_LE; | 135 | - abort(); |
338 | + dc->be_data = EX_TBFLAG_ANY(tb_flags, BE_DATA) ? MO_BE : MO_LE; | 136 | + g_assert_not_reached(); |
339 | dc->condexec_mask = 0; | 137 | } |
340 | dc->condexec_cond = 0; | 138 | |
341 | - core_mmu_idx = FIELD_EX32(tb_flags, TBFLAG_ANY, MMUIDX); | 139 | write_fp_sreg(s, rd, tcg_res); |
342 | + core_mmu_idx = EX_TBFLAG_ANY(tb_flags, MMUIDX); | 140 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_fcvt(DisasContext *s, int opcode, |
343 | dc->mmu_idx = core_to_aa64_mmu_idx(core_mmu_idx); | 141 | break; |
344 | - dc->tbii = FIELD_EX32(tb_flags, TBFLAG_A64, TBII); | 142 | } |
345 | - dc->tbid = FIELD_EX32(tb_flags, TBFLAG_A64, TBID); | 143 | default: |
346 | - dc->tcma = FIELD_EX32(tb_flags, TBFLAG_A64, TCMA); | 144 | - abort(); |
347 | + dc->tbii = EX_TBFLAG_A64(tb_flags, TBII); | 145 | + g_assert_not_reached(); |
348 | + dc->tbid = EX_TBFLAG_A64(tb_flags, TBID); | 146 | } |
349 | + dc->tcma = EX_TBFLAG_A64(tb_flags, TCMA); | 147 | } |
350 | dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx); | 148 | |
351 | #if !defined(CONFIG_USER_ONLY) | 149 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c |
352 | dc->user = (dc->current_el == 0); | 150 | index XXXXXXX..XXXXXXX 100644 |
353 | #endif | 151 | --- a/target/arm/translate-neon.c |
354 | - dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL); | 152 | +++ b/target/arm/translate-neon.c |
355 | - dc->sve_excp_el = FIELD_EX32(tb_flags, TBFLAG_A64, SVEEXC_EL); | 153 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) |
356 | - dc->sve_len = (FIELD_EX32(tb_flags, TBFLAG_A64, ZCR_LEN) + 1) * 16; | 154 | } |
357 | - dc->pauth_active = FIELD_EX32(tb_flags, TBFLAG_A64, PAUTH_ACTIVE); | 155 | break; |
358 | - dc->bt = FIELD_EX32(tb_flags, TBFLAG_A64, BT); | 156 | default: |
359 | - dc->btype = FIELD_EX32(tb_flags, TBFLAG_A64, BTYPE); | 157 | - abort(); |
360 | - dc->unpriv = FIELD_EX32(tb_flags, TBFLAG_A64, UNPRIV); | 158 | + g_assert_not_reached(); |
361 | - dc->ata = FIELD_EX32(tb_flags, TBFLAG_A64, ATA); | 159 | } |
362 | - dc->mte_active[0] = FIELD_EX32(tb_flags, TBFLAG_A64, MTE_ACTIVE); | 160 | if ((vd + a->stride * (nregs - 1)) > 31) { |
363 | - dc->mte_active[1] = FIELD_EX32(tb_flags, TBFLAG_A64, MTE0_ACTIVE); | 161 | /* |
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 | 162 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
392 | index XXXXXXX..XXXXXXX 100644 | 163 | index XXXXXXX..XXXXXXX 100644 |
393 | --- a/target/arm/translate.c | 164 | --- a/target/arm/translate.c |
394 | +++ b/target/arm/translate.c | 165 | +++ b/target/arm/translate.c |
395 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 166 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, |
396 | */ | 167 | offset = 4; |
397 | dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) && | 168 | break; |
398 | !arm_el_is_aa64(env, 3); | 169 | default: |
399 | - dc->thumb = FIELD_EX32(tb_flags, TBFLAG_AM32, THUMB); | 170 | - abort(); |
400 | - dc->be_data = FIELD_EX32(tb_flags, TBFLAG_ANY, BE_DATA) ? MO_BE : MO_LE; | 171 | + g_assert_not_reached(); |
401 | - condexec = FIELD_EX32(tb_flags, TBFLAG_AM32, CONDEXEC); | 172 | } |
402 | + dc->thumb = EX_TBFLAG_AM32(tb_flags, THUMB); | 173 | tcg_gen_addi_i32(addr, addr, offset); |
403 | + dc->be_data = EX_TBFLAG_ANY(tb_flags, BE_DATA) ? MO_BE : MO_LE; | 174 | tmp = load_reg(s, 14); |
404 | + condexec = EX_TBFLAG_AM32(tb_flags, CONDEXEC); | 175 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, |
405 | dc->condexec_mask = (condexec & 0xf) << 1; | 176 | offset = 0; |
406 | dc->condexec_cond = condexec >> 4; | 177 | break; |
407 | 178 | default: | |
408 | - core_mmu_idx = FIELD_EX32(tb_flags, TBFLAG_ANY, MMUIDX); | 179 | - abort(); |
409 | + core_mmu_idx = EX_TBFLAG_ANY(tb_flags, MMUIDX); | 180 | + g_assert_not_reached(); |
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 | } | 181 | } |
458 | } | 182 | tcg_gen_addi_i32(addr, addr, offset); |
459 | dc->cp_regs = cpu->cp_regs; | 183 | gen_helper_set_r13_banked(cpu_env, tcg_constant_i32(mode), addr); |
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 | -- | 184 | -- |
486 | 2.20.1 | 185 | 2.25.1 |
487 | |||
488 | 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 | Create a typedef as well, and use it in ARMCPRegInfo. |
4 | fields, introduce a structure to hold the value(s). | 4 | This won't be perfect for debugging, but it'll nicely |
5 | So far this only migrates the one uint32_t and fixes | 5 | display the most common cases. |
6 | all of the places that require adjustment to match. | ||
7 | 6 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20210419202257.161730-6-richard.henderson@linaro.org | 9 | Message-id: 20220501055028.646596-8-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 | 44 +++++++++++++++++++++++--------------------- |
14 | target/arm/translate.h | 11 +++++++++ | 13 | target/arm/helper.c | 2 +- |
15 | target/arm/helper.c | 48 +++++++++++++++++++++----------------- | 14 | 2 files changed, 24 insertions(+), 22 deletions(-) |
16 | target/arm/translate-a64.c | 2 +- | ||
17 | target/arm/translate.c | 7 +++--- | ||
18 | 5 files changed, 57 insertions(+), 37 deletions(-) | ||
19 | 15 | ||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 18 | --- a/target/arm/cpregs.h |
23 | +++ b/target/arm/cpu.h | 19 | +++ b/target/arm/cpregs.h |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMPACKey { | 20 | @@ -XXX,XX +XXX,XX @@ enum { |
25 | } ARMPACKey; | 21 | * described with these bits, then use a laxer set of restrictions, and |
22 | * do the more restrictive/complex check inside a helper function. | ||
23 | */ | ||
24 | -#define PL3_R 0x80 | ||
25 | -#define PL3_W 0x40 | ||
26 | -#define PL2_R (0x20 | PL3_R) | ||
27 | -#define PL2_W (0x10 | PL3_W) | ||
28 | -#define PL1_R (0x08 | PL2_R) | ||
29 | -#define PL1_W (0x04 | PL2_W) | ||
30 | -#define PL0_R (0x02 | PL1_R) | ||
31 | -#define PL0_W (0x01 | PL1_W) | ||
32 | +typedef enum { | ||
33 | + PL3_R = 0x80, | ||
34 | + PL3_W = 0x40, | ||
35 | + PL2_R = 0x20 | PL3_R, | ||
36 | + PL2_W = 0x10 | PL3_W, | ||
37 | + PL1_R = 0x08 | PL2_R, | ||
38 | + PL1_W = 0x04 | PL2_W, | ||
39 | + PL0_R = 0x02 | PL1_R, | ||
40 | + PL0_W = 0x01 | PL1_W, | ||
41 | |||
42 | -/* | ||
43 | - * For user-mode some registers are accessible to EL0 via a kernel | ||
44 | - * trap-and-emulate ABI. In this case we define the read permissions | ||
45 | - * as actually being PL0_R. However some bits of any given register | ||
46 | - * may still be masked. | ||
47 | - */ | ||
48 | + /* | ||
49 | + * For user-mode some registers are accessible to EL0 via a kernel | ||
50 | + * trap-and-emulate ABI. In this case we define the read permissions | ||
51 | + * as actually being PL0_R. However some bits of any given register | ||
52 | + * may still be masked. | ||
53 | + */ | ||
54 | #ifdef CONFIG_USER_ONLY | ||
55 | -#define PL0U_R PL0_R | ||
56 | + PL0U_R = PL0_R, | ||
57 | #else | ||
58 | -#define PL0U_R PL1_R | ||
59 | + PL0U_R = PL1_R, | ||
26 | #endif | 60 | #endif |
27 | 61 | ||
28 | +/* See the commentary above the TBFLAG field definitions. */ | 62 | -#define PL3_RW (PL3_R | PL3_W) |
29 | +typedef struct CPUARMTBFlags { | 63 | -#define PL2_RW (PL2_R | PL2_W) |
30 | + uint32_t flags; | 64 | -#define PL1_RW (PL1_R | PL1_W) |
31 | +} CPUARMTBFlags; | 65 | -#define PL0_RW (PL0_R | PL0_W) |
32 | 66 | + PL3_RW = PL3_R | PL3_W, | |
33 | typedef struct CPUARMState { | 67 | + PL2_RW = PL2_R | PL2_W, |
34 | /* Regs for current mode. */ | 68 | + PL1_RW = PL1_R | PL1_W, |
35 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 69 | + PL0_RW = PL0_R | PL0_W, |
36 | uint32_t aarch64; /* 1 if CPU is in aarch64 state; inverse of PSTATE.nRW */ | 70 | +} CPAccessRights; |
37 | 71 | ||
38 | /* Cached TBFLAGS state. See below for which bits are included. */ | 72 | typedef enum CPAccessResult { |
39 | - uint32_t hflags; | 73 | /* Access is permitted */ |
40 | + CPUARMTBFlags hflags; | 74 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { |
41 | 75 | /* Register type: ARM_CP_* bits/values */ | |
42 | /* Frequently accessed CPSR bits are stored separately for efficiency. | 76 | int type; |
43 | This contains all the other bits. Use cpsr_{read,write} to access | 77 | /* Access rights: PL*_[RW] */ |
44 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) | 78 | - int access; |
45 | * Helpers for using the above. | 79 | + CPAccessRights access; |
46 | */ | 80 | /* Security state: ARM_CP_SECSTATE_* bits/values */ |
47 | #define DP_TBFLAG_ANY(DST, WHICH, VAL) \ | 81 | int secure; |
48 | - (DST = FIELD_DP32(DST, TBFLAG_ANY, WHICH, VAL)) | 82 | /* |
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 | + | ||
95 | /* | ||
96 | * Enum for argument to fpstatus_ptr(). | ||
97 | */ | ||
98 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 83 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
99 | index XXXXXXX..XXXXXXX 100644 | 84 | index XXXXXXX..XXXXXXX 100644 |
100 | --- a/target/arm/helper.c | 85 | --- a/target/arm/helper.c |
101 | +++ b/target/arm/helper.c | 86 | +++ b/target/arm/helper.c |
102 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | 87 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
103 | } | 88 | * to encompass the generic architectural permission check. |
104 | #endif | 89 | */ |
105 | 90 | if (r->state != ARM_CP_STATE_AA32) { | |
106 | -static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | 91 | - int mask = 0; |
107 | - ARMMMUIdx mmu_idx, uint32_t flags) | 92 | + CPAccessRights mask; |
108 | +static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el, | 93 | switch (r->opc1) { |
109 | + ARMMMUIdx mmu_idx, | 94 | case 0: |
110 | + CPUARMTBFlags flags) | 95 | /* min_EL EL1, but some accessible to EL0 via kernel ABI */ |
111 | { | ||
112 | DP_TBFLAG_ANY(flags, FPEXC_EL, fp_el); | ||
113 | DP_TBFLAG_ANY(flags, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); | ||
114 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, | ||
115 | return flags; | ||
116 | } | ||
117 | |||
118 | -static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, | ||
119 | - ARMMMUIdx mmu_idx, uint32_t flags) | ||
120 | +static CPUARMTBFlags rebuild_hflags_common_32(CPUARMState *env, int fp_el, | ||
121 | + ARMMMUIdx mmu_idx, | ||
122 | + CPUARMTBFlags flags) | ||
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 | + | ||
192 | env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx); | ||
193 | } | ||
194 | |||
195 | @@ -XXX,XX +XXX,XX @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el) | ||
196 | static inline void assert_hflags_rebuild_correctly(CPUARMState *env) | ||
197 | { | ||
198 | #ifdef CONFIG_DEBUG_TCG | ||
199 | - uint32_t env_flags_current = env->hflags; | ||
200 | - uint32_t env_flags_rebuilt = rebuild_hflags_internal(env); | ||
201 | + CPUARMTBFlags c = env->hflags; | ||
202 | + CPUARMTBFlags r = rebuild_hflags_internal(env); | ||
203 | |||
204 | - if (unlikely(env_flags_current != env_flags_rebuilt)) { | ||
205 | + if (unlikely(c.flags != r.flags)) { | ||
206 | fprintf(stderr, "TCG hflags mismatch (current:0x%08x rebuilt:0x%08x)\n", | ||
207 | - env_flags_current, env_flags_rebuilt); | ||
208 | + c.flags, r.flags); | ||
209 | abort(); | ||
210 | } | ||
211 | #endif | ||
212 | @@ -XXX,XX +XXX,XX @@ static inline void assert_hflags_rebuild_correctly(CPUARMState *env) | ||
213 | void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
214 | target_ulong *cs_base, uint32_t *pflags) | ||
215 | { | ||
216 | - uint32_t flags = env->hflags; | ||
217 | + CPUARMTBFlags flags; | ||
218 | |||
219 | *cs_base = 0; | ||
220 | assert_hflags_rebuild_correctly(env); | ||
221 | + flags = env->hflags; | ||
222 | |||
223 | if (EX_TBFLAG_ANY(flags, AARCH64_STATE)) { | ||
224 | *pc = env->pc; | ||
225 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
226 | DP_TBFLAG_ANY(flags, PSTATE__SS, 1); | ||
227 | } | ||
228 | |||
229 | - *pflags = flags; | ||
230 | + *pflags = flags.flags; | ||
231 | } | ||
232 | |||
233 | #ifdef TARGET_AARCH64 | ||
234 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
235 | index XXXXXXX..XXXXXXX 100644 | ||
236 | --- a/target/arm/translate-a64.c | ||
237 | +++ b/target/arm/translate-a64.c | ||
238 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
239 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
240 | CPUARMState *env = cpu->env_ptr; | ||
241 | ARMCPU *arm_cpu = env_archcpu(env); | ||
242 | - uint32_t tb_flags = dc->base.tb->flags; | ||
243 | + CPUARMTBFlags tb_flags = arm_tbflags_from_tb(dc->base.tb); | ||
244 | int bound, core_mmu_idx; | ||
245 | |||
246 | dc->isar = &arm_cpu->isar; | ||
247 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
248 | index XXXXXXX..XXXXXXX 100644 | ||
249 | --- a/target/arm/translate.c | ||
250 | +++ b/target/arm/translate.c | ||
251 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
252 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
253 | CPUARMState *env = cs->env_ptr; | ||
254 | ARMCPU *cpu = env_archcpu(env); | ||
255 | - uint32_t tb_flags = dc->base.tb->flags; | ||
256 | + CPUARMTBFlags tb_flags = arm_tbflags_from_tb(dc->base.tb); | ||
257 | uint32_t condexec, core_mmu_idx; | ||
258 | |||
259 | dc->isar = &cpu->isar; | ||
260 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | ||
261 | { | ||
262 | DisasContext dc = { }; | ||
263 | const TranslatorOps *ops = &arm_translator_ops; | ||
264 | + CPUARMTBFlags tb_flags = arm_tbflags_from_tb(tb); | ||
265 | |||
266 | - if (EX_TBFLAG_AM32(tb->flags, THUMB)) { | ||
267 | + if (EX_TBFLAG_AM32(tb_flags, THUMB)) { | ||
268 | ops = &thumb_translator_ops; | ||
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 | -- | 96 | -- |
277 | 2.20.1 | 97 | 2.25.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 | Now that mte_check1 and mte_checkN have been merged, we can | 3 | Give this enum a name and use in ARMCPRegInfo, |
4 | merge sve_cont_ldst_mte_check1 and sve_cont_ldst_mte_checkN. | 4 | add_cpreg_to_hashtable and define_one_arm_cp_reg_with_opaque. |
5 | |||
6 | Which means that we can eliminate the function pointer into | ||
7 | sve_ldN_r and sve_stN_r, calling sve_cont_ldst_mte_check directly. | ||
8 | 5 | ||
9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20210416183106.1516563-9-richard.henderson@linaro.org | 9 | Message-id: 20220501055028.646596-9-richard.henderson@linaro.org |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | target/arm/sve_helper.c | 84 +++++++++++++---------------------------- | 12 | target/arm/cpregs.h | 6 +++--- |
15 | 1 file changed, 26 insertions(+), 58 deletions(-) | 13 | target/arm/helper.c | 6 ++++-- |
14 | 2 files changed, 7 insertions(+), 5 deletions(-) | ||
16 | 15 | ||
17 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/sve_helper.c | 18 | --- a/target/arm/cpregs.h |
20 | +++ b/target/arm/sve_helper.c | 19 | +++ b/target/arm/cpregs.h |
21 | @@ -XXX,XX +XXX,XX @@ static void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, | 20 | @@ -XXX,XX +XXX,XX @@ enum { |
22 | #endif | 21 | * Note that we rely on the values of these enums as we iterate through |
22 | * the various states in some places. | ||
23 | */ | ||
24 | -enum { | ||
25 | +typedef enum { | ||
26 | ARM_CP_STATE_AA32 = 0, | ||
27 | ARM_CP_STATE_AA64 = 1, | ||
28 | ARM_CP_STATE_BOTH = 2, | ||
29 | -}; | ||
30 | +} CPState; | ||
31 | |||
32 | /* | ||
33 | * ARM CP register secure state flags. These flags identify security state | ||
34 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { | ||
35 | uint8_t opc1; | ||
36 | uint8_t opc2; | ||
37 | /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
38 | - int state; | ||
39 | + CPState state; | ||
40 | /* Register type: ARM_CP_* bits/values */ | ||
41 | int type; | ||
42 | /* Access rights: PL*_[RW] */ | ||
43 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/helper.c | ||
46 | +++ b/target/arm/helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) | ||
23 | } | 48 | } |
24 | 49 | ||
25 | -typedef uint64_t mte_check_fn(CPUARMState *, uint32_t, uint64_t, uintptr_t); | 50 | static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
26 | - | 51 | - void *opaque, int state, int secstate, |
27 | -static inline QEMU_ALWAYS_INLINE | 52 | + void *opaque, CPState state, int secstate, |
28 | -void sve_cont_ldst_mte_check_int(SVEContLdSt *info, CPUARMState *env, | 53 | int crm, int opc1, int opc2, |
29 | - uint64_t *vg, target_ulong addr, int esize, | 54 | const char *name) |
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 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
37 | 57 | * bits; the ARM_CP_64BIT* flag applies only to the AArch32 view of | |
38 | @@ -XXX,XX +XXX,XX @@ void sve_cont_ldst_mte_check_int(SVEContLdSt *info, CPUARMState *env, | 58 | * the register, if any. |
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 | } | ||
58 | } | ||
59 | |||
60 | -typedef void sve_cont_ldst_mte_check_fn(SVEContLdSt *info, CPUARMState *env, | ||
61 | - uint64_t *vg, target_ulong addr, | ||
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 | { | ||
95 | const unsigned rd = simd_data(desc); | ||
96 | const intptr_t reg_max = simd_oprsz(desc); | ||
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 | */ | 59 | */ |
101 | - if (mte_check_fn && mtedesc) { | 60 | - int crm, opc1, opc2, state; |
102 | - mte_check_fn(&info, env, vg, addr, 1 << esz, N << msz, | 61 | + int crm, opc1, opc2; |
103 | - mtedesc, retaddr); | 62 | int crmmin = (r->crm == CP_ANY) ? 0 : r->crm; |
104 | + if (mtedesc) { | 63 | int crmmax = (r->crm == CP_ANY) ? 15 : r->crm; |
105 | + sve_cont_ldst_mte_check(&info, env, vg, addr, 1 << esz, N << msz, | 64 | int opc1min = (r->opc1 == CP_ANY) ? 0 : r->opc1; |
106 | + mtedesc, retaddr); | 65 | int opc1max = (r->opc1 == CP_ANY) ? 7 : r->opc1; |
107 | } | 66 | int opc2min = (r->opc2 == CP_ANY) ? 0 : r->opc2; |
108 | 67 | int opc2max = (r->opc2 == CP_ANY) ? 7 : r->opc2; | |
109 | flags = info.page[0].flags | info.page[1].flags; | 68 | + CPState state; |
110 | @@ -XXX,XX +XXX,XX @@ void sve_ldN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr, | 69 | + |
111 | mtedesc = 0; | 70 | /* 64 bit registers have only CRm and Opc1 fields */ |
112 | } | 71 | assert(!((r->type & ARM_CP_64BIT) && (r->opc2 || r->crn))); |
113 | 72 | /* op0 only exists in the AArch64 encodings */ | |
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 | -- | 73 | -- |
240 | 2.20.1 | 74 | 2.25.1 |
241 | 75 | ||
242 | 76 | 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 | Give this enum a name and use in ARMCPRegInfo and add_cpreg_to_hashtable. |
4 | the CPUARMTBFlags structure and populating the two TB fields | 4 | Add the enumerator ARM_CP_SECSTATE_BOTH to clarify how 0 |
5 | is relatively simple. | 5 | is handled in define_one_arm_cp_reg_with_opaque. |
6 | 6 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20210419202257.161730-7-richard.henderson@linaro.org | 9 | Message-id: 20220501055028.646596-10-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | target/arm/cpu.h | 49 ++++++++++++++++++++++++------------------ | 12 | target/arm/cpregs.h | 7 ++++--- |
13 | target/arm/translate.h | 2 +- | 13 | target/arm/helper.c | 7 +++++-- |
14 | target/arm/helper.c | 10 +++++---- | 14 | 2 files changed, 9 insertions(+), 5 deletions(-) |
15 | 3 files changed, 35 insertions(+), 26 deletions(-) | ||
16 | 15 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 18 | --- a/target/arm/cpregs.h |
20 | +++ b/target/arm/cpu.h | 19 | +++ b/target/arm/cpregs.h |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMPACKey { | 20 | @@ -XXX,XX +XXX,XX @@ typedef enum { |
22 | /* See the commentary above the TBFLAG field definitions. */ | 21 | * registered entry will only have one to identify whether the entry is secure |
23 | typedef struct CPUARMTBFlags { | 22 | * or non-secure. |
24 | uint32_t flags; | 23 | */ |
25 | + target_ulong flags2; | 24 | -enum { |
26 | } CPUARMTBFlags; | 25 | +typedef enum { |
27 | 26 | + ARM_CP_SECSTATE_BOTH = 0, /* define one cpreg for each secstate */ | |
28 | typedef struct CPUARMState { | 27 | ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ |
29 | @@ -XXX,XX +XXX,XX @@ typedef ARMCPU ArchCPU; | 28 | ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ |
30 | #include "exec/cpu-all.h" | 29 | -}; |
30 | +} CPSecureState; | ||
31 | 31 | ||
32 | /* | 32 | /* |
33 | - * Bit usage in the TB flags field: bit 31 indicates whether we are | 33 | * Access rights: |
34 | - * in 32 or 64 bit mode. The meaning of the other bits depends on that. | 34 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { |
35 | - * We put flags which are shared between 32 and 64 bit mode at the top | 35 | /* Access rights: PL*_[RW] */ |
36 | - * of the word, and flags which apply to only one mode at the bottom. | 36 | CPAccessRights access; |
37 | + * We have more than 32-bits worth of state per TB, so we split the data | 37 | /* Security state: ARM_CP_SECSTATE_* bits/values */ |
38 | + * between tb->flags and tb->cs_base, which is otherwise unused for ARM. | 38 | - int secure; |
39 | + * We collect these two parts in CPUARMTBFlags where they are named | 39 | + CPSecureState secure; |
40 | + * flags and flags2 respectively. | 40 | /* |
41 | * | 41 | * The opaque pointer passed to define_arm_cp_regs_with_opaque() when |
42 | - * 31 20 18 14 9 0 | 42 | * this register was defined: can be used to hand data through to the |
43 | - * +--------------+-----+-----+----------+--------------+ | ||
44 | - * | | | TBFLAG_A32 | | | ||
45 | - * | | +-----+----------+ TBFLAG_AM32 | | ||
46 | - * | TBFLAG_ANY | |TBFLAG_M32| | | ||
47 | - * | +-----------+----------+--------------| | ||
48 | - * | | TBFLAG_A64 | | ||
49 | - * +--------------+-------------------------------------+ | ||
50 | - * 31 20 0 | ||
51 | + * The flags that are shared between all execution modes, TBFLAG_ANY, | ||
52 | + * are stored in flags. The flags that are specific to a given mode | ||
53 | + * are stores in flags2. Since cs_base is sized on the configured | ||
54 | + * address size, flags2 always has 64-bits for A64, and a minimum of | ||
55 | + * 32-bits for A32 and M32. | ||
56 | + * | ||
57 | + * The bits for 32-bit A-profile and M-profile partially overlap: | ||
58 | + * | ||
59 | + * 18 9 0 | ||
60 | + * +----------------+--------------+ | ||
61 | + * | TBFLAG_A32 | | | ||
62 | + * +-----+----------+ TBFLAG_AM32 | | ||
63 | + * | |TBFLAG_M32| | | ||
64 | + * +-----+----------+--------------+ | ||
65 | + * 14 9 0 | ||
66 | * | ||
67 | * Unless otherwise noted, these bits are cached in env->hflags. | ||
68 | */ | ||
69 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) | ||
70 | #define DP_TBFLAG_ANY(DST, WHICH, VAL) \ | ||
71 | (DST.flags = FIELD_DP32(DST.flags, TBFLAG_ANY, WHICH, VAL)) | ||
72 | #define DP_TBFLAG_A64(DST, WHICH, VAL) \ | ||
73 | - (DST.flags = FIELD_DP32(DST.flags, TBFLAG_A64, WHICH, VAL)) | ||
74 | + (DST.flags2 = FIELD_DP32(DST.flags2, TBFLAG_A64, WHICH, VAL)) | ||
75 | #define DP_TBFLAG_A32(DST, WHICH, VAL) \ | ||
76 | - (DST.flags = FIELD_DP32(DST.flags, TBFLAG_A32, WHICH, VAL)) | ||
77 | + (DST.flags2 = FIELD_DP32(DST.flags2, TBFLAG_A32, WHICH, VAL)) | ||
78 | #define DP_TBFLAG_M32(DST, WHICH, VAL) \ | ||
79 | - (DST.flags = FIELD_DP32(DST.flags, TBFLAG_M32, WHICH, VAL)) | ||
80 | + (DST.flags2 = FIELD_DP32(DST.flags2, TBFLAG_M32, WHICH, VAL)) | ||
81 | #define DP_TBFLAG_AM32(DST, WHICH, VAL) \ | ||
82 | - (DST.flags = FIELD_DP32(DST.flags, TBFLAG_AM32, WHICH, VAL)) | ||
83 | + (DST.flags2 = FIELD_DP32(DST.flags2, TBFLAG_AM32, WHICH, VAL)) | ||
84 | |||
85 | #define EX_TBFLAG_ANY(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_ANY, WHICH) | ||
86 | -#define EX_TBFLAG_A64(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_A64, WHICH) | ||
87 | -#define EX_TBFLAG_A32(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_A32, WHICH) | ||
88 | -#define EX_TBFLAG_M32(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_M32, WHICH) | ||
89 | -#define EX_TBFLAG_AM32(IN, WHICH) FIELD_EX32(IN.flags, TBFLAG_AM32, WHICH) | ||
90 | +#define EX_TBFLAG_A64(IN, WHICH) FIELD_EX32(IN.flags2, TBFLAG_A64, WHICH) | ||
91 | +#define EX_TBFLAG_A32(IN, WHICH) FIELD_EX32(IN.flags2, TBFLAG_A32, WHICH) | ||
92 | +#define EX_TBFLAG_M32(IN, WHICH) FIELD_EX32(IN.flags2, TBFLAG_M32, WHICH) | ||
93 | +#define EX_TBFLAG_AM32(IN, WHICH) FIELD_EX32(IN.flags2, TBFLAG_AM32, WHICH) | ||
94 | |||
95 | /** | ||
96 | * cpu_mmu_index: | ||
97 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
98 | index XXXXXXX..XXXXXXX 100644 | ||
99 | --- a/target/arm/translate.h | ||
100 | +++ b/target/arm/translate.h | ||
101 | @@ -XXX,XX +XXX,XX @@ typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
102 | */ | ||
103 | static inline CPUARMTBFlags arm_tbflags_from_tb(const TranslationBlock *tb) | ||
104 | { | ||
105 | - return (CPUARMTBFlags){ tb->flags }; | ||
106 | + return (CPUARMTBFlags){ tb->flags, tb->cs_base }; | ||
107 | } | ||
108 | |||
109 | /* | ||
110 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 43 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
111 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
112 | --- a/target/arm/helper.c | 45 | --- a/target/arm/helper.c |
113 | +++ b/target/arm/helper.c | 46 | +++ b/target/arm/helper.c |
114 | @@ -XXX,XX +XXX,XX @@ static inline void assert_hflags_rebuild_correctly(CPUARMState *env) | 47 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) |
115 | CPUARMTBFlags c = env->hflags; | 48 | } |
116 | CPUARMTBFlags r = rebuild_hflags_internal(env); | 49 | |
117 | 50 | static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | |
118 | - if (unlikely(c.flags != r.flags)) { | 51 | - void *opaque, CPState state, int secstate, |
119 | - fprintf(stderr, "TCG hflags mismatch (current:0x%08x rebuilt:0x%08x)\n", | 52 | + void *opaque, CPState state, |
120 | - c.flags, r.flags); | 53 | + CPSecureState secstate, |
121 | + if (unlikely(c.flags != r.flags || c.flags2 != r.flags2)) { | 54 | int crm, int opc1, int opc2, |
122 | + fprintf(stderr, "TCG hflags mismatch " | 55 | const char *name) |
123 | + "(current:(0x%08x,0x" TARGET_FMT_lx ")" | ||
124 | + " rebuilt:(0x%08x,0x" TARGET_FMT_lx ")\n", | ||
125 | + c.flags, c.flags2, r.flags, r.flags2); | ||
126 | abort(); | ||
127 | } | ||
128 | #endif | ||
129 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
130 | { | 56 | { |
131 | CPUARMTBFlags flags; | 57 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
132 | 58 | r->secure, crm, opc1, opc2, | |
133 | - *cs_base = 0; | 59 | r->name); |
134 | assert_hflags_rebuild_correctly(env); | 60 | break; |
135 | flags = env->hflags; | 61 | - default: |
136 | 62 | + case ARM_CP_SECSTATE_BOTH: | |
137 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 63 | name = g_strdup_printf("%s_S", r->name); |
138 | } | 64 | add_cpreg_to_hashtable(cpu, r, opaque, state, |
139 | 65 | ARM_CP_SECSTATE_S, | |
140 | *pflags = flags.flags; | 66 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
141 | + *cs_base = flags.flags2; | 67 | ARM_CP_SECSTATE_NS, |
142 | } | 68 | crm, opc1, opc2, r->name); |
143 | 69 | break; | |
144 | #ifdef TARGET_AARCH64 | 70 | + default: |
71 | + g_assert_not_reached(); | ||
72 | } | ||
73 | } else { | ||
74 | /* AArch64 registers get mapped to non-secure instance | ||
145 | -- | 75 | -- |
146 | 2.20.1 | 76 | 2.25.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 | The new_key field is always non-zero -- drop the if. | ||
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: 20220501055028.646596-11-richard.henderson@linaro.org |
5 | Message-id: 20210419202257.161730-32-richard.henderson@linaro.org | 8 | [PMM: reinstated dropped PL3_RW mask] |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | target/arm/translate-sve.c | 2 +- | 11 | target/arm/helper.c | 23 +++++++++++------------ |
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 11 insertions(+), 12 deletions(-) |
10 | 13 | ||
11 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-sve.c | 16 | --- a/target/arm/helper.c |
14 | +++ b/target/arm/translate-sve.c | 17 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD1R_zpri(DisasContext *s, arg_rpri_load *a) | 18 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) |
16 | clean_addr = gen_mte_check1(s, temp, false, true, msz); | 19 | |
17 | 20 | for (i = 0; i < ARRAY_SIZE(aliases); i++) { | |
18 | tcg_gen_qemu_ld_i64(temp, clean_addr, get_mem_index(s), | 21 | const struct E2HAlias *a = &aliases[i]; |
19 | - s->be_data | dtype_mop[a->dtype]); | 22 | - ARMCPRegInfo *src_reg, *dst_reg; |
20 | + finalize_memop(s, dtype_mop[a->dtype])); | 23 | + ARMCPRegInfo *src_reg, *dst_reg, *new_reg; |
21 | 24 | + uint32_t *new_key; | |
22 | /* Broadcast to *all* elements. */ | 25 | + bool ok; |
23 | tcg_gen_gvec_dup_i64(esz, vec_full_reg_offset(s, a->rd), | 26 | |
27 | if (a->feature && !a->feature(&cpu->isar)) { | ||
28 | continue; | ||
29 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
30 | g_assert(src_reg->opaque == NULL); | ||
31 | |||
32 | /* Create alias before redirection so we dup the right data. */ | ||
33 | - if (a->new_key) { | ||
34 | - ARMCPRegInfo *new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); | ||
35 | - uint32_t *new_key = g_memdup(&a->new_key, sizeof(uint32_t)); | ||
36 | - bool ok; | ||
37 | + new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); | ||
38 | + new_key = g_memdup(&a->new_key, sizeof(uint32_t)); | ||
39 | |||
40 | - new_reg->name = a->new_name; | ||
41 | - new_reg->type |= ARM_CP_ALIAS; | ||
42 | - /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | ||
43 | - new_reg->access &= PL2_RW | PL3_RW; | ||
44 | + new_reg->name = a->new_name; | ||
45 | + new_reg->type |= ARM_CP_ALIAS; | ||
46 | + /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | ||
47 | + new_reg->access &= PL2_RW | PL3_RW; | ||
48 | |||
49 | - ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
50 | - g_assert(ok); | ||
51 | - } | ||
52 | + ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
53 | + g_assert(ok); | ||
54 | |||
55 | src_reg->opaque = dst_reg; | ||
56 | src_reg->orig_readfn = src_reg->readfn ?: raw_read; | ||
24 | -- | 57 | -- |
25 | 2.20.1 | 58 | 2.25.1 |
26 | |||
27 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The mte_check1 and mte_checkN functions are now identical. | 3 | Cast the uint32_t key into a gpointer directly, which |
4 | Drop mte_check1 and rename mte_checkN to mte_check. | 4 | allows us to avoid allocating storage for each key. |
5 | 5 | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Use g_hash_table_lookup when we already have a gpointer |
7 | (e.g. for callbacks like count_cpreg), or when using | ||
8 | get_arm_cp_reginfo would require casting away const. | ||
9 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210416183106.1516563-7-richard.henderson@linaro.org | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Message-id: 20220501055028.646596-12-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 14 | --- |
11 | target/arm/helper-a64.h | 3 +-- | 15 | target/arm/cpu.c | 4 ++-- |
12 | target/arm/internals.h | 5 +---- | 16 | target/arm/gdbstub.c | 2 +- |
13 | target/arm/mte_helper.c | 26 +++----------------------- | 17 | target/arm/helper.c | 41 ++++++++++++++++++----------------------- |
14 | target/arm/sve_helper.c | 14 +++++++------- | 18 | 3 files changed, 21 insertions(+), 26 deletions(-) |
15 | target/arm/translate-a64.c | 4 ++-- | ||
16 | 5 files changed, 14 insertions(+), 38 deletions(-) | ||
17 | 19 | ||
18 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h | 20 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
19 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper-a64.h | 22 | --- a/target/arm/cpu.c |
21 | +++ b/target/arm/helper-a64.h | 23 | +++ b/target/arm/cpu.c |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(autdb, TCG_CALL_NO_WG, i64, env, i64, i64) | 24 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) |
23 | DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64) | 25 | ARMCPU *cpu = ARM_CPU(obj); |
24 | DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64) | 26 | |
25 | 27 | cpu_set_cpustate_pointers(cpu); | |
26 | -DEF_HELPER_FLAGS_3(mte_check1, TCG_CALL_NO_WG, i64, env, i32, i64) | 28 | - cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal, |
27 | -DEF_HELPER_FLAGS_3(mte_checkN, TCG_CALL_NO_WG, i64, env, i32, i64) | 29 | - g_free, cpreg_hashtable_data_destroy); |
28 | +DEF_HELPER_FLAGS_3(mte_check, TCG_CALL_NO_WG, i64, env, i32, i64) | 30 | + cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
29 | DEF_HELPER_FLAGS_3(mte_check_zva, TCG_CALL_NO_WG, i64, env, i32, i64) | 31 | + NULL, cpreg_hashtable_data_destroy); |
30 | DEF_HELPER_FLAGS_3(irg, TCG_CALL_NO_RWG, i64, env, i64, i64) | 32 | |
31 | DEF_HELPER_FLAGS_4(addsubg, TCG_CALL_NO_RWG_SE, i64, env, i64, s32, i32) | 33 | QLIST_INIT(&cpu->pre_el_change_hooks); |
32 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 34 | QLIST_INIT(&cpu->el_change_hooks); |
35 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/target/arm/internals.h | 37 | --- a/target/arm/gdbstub.c |
35 | +++ b/target/arm/internals.h | 38 | +++ b/target/arm/gdbstub.c |
36 | @@ -XXX,XX +XXX,XX @@ FIELD(MTEDESC, WRITE, 8, 1) | 39 | @@ -XXX,XX +XXX,XX @@ static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, |
37 | FIELD(MTEDESC, SIZEM1, 9, SIMD_DATA_BITS - 9) /* size - 1 */ | 40 | static void arm_register_sysreg_for_xml(gpointer key, gpointer value, |
38 | 41 | gpointer p) | |
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 | { | 42 | { |
48 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | 43 | - uint32_t ri_key = *(uint32_t *)key; |
44 | + uint32_t ri_key = (uintptr_t)key; | ||
45 | ARMCPRegInfo *ri = value; | ||
46 | RegisterSysregXmlParam *param = (RegisterSysregXmlParam *)p; | ||
47 | GString *s = param->s; | ||
48 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/target/arm/mte_helper.c | 50 | --- a/target/arm/helper.c |
51 | +++ b/target/arm/mte_helper.c | 51 | +++ b/target/arm/helper.c |
52 | @@ -XXX,XX +XXX,XX @@ static int mte_probe_int(CPUARMState *env, uint32_t desc, uint64_t ptr, | 52 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_cpustate(ARMCPU *cpu) |
53 | return 0; | 53 | static void add_cpreg_to_list(gpointer key, gpointer opaque) |
54 | { | ||
55 | ARMCPU *cpu = opaque; | ||
56 | - uint64_t regidx; | ||
57 | - const ARMCPRegInfo *ri; | ||
58 | - | ||
59 | - regidx = *(uint32_t *)key; | ||
60 | - ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); | ||
61 | + uint32_t regidx = (uintptr_t)key; | ||
62 | + const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); | ||
63 | |||
64 | if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { | ||
65 | cpu->cpreg_indexes[cpu->cpreg_array_len] = cpreg_to_kvm_id(regidx); | ||
66 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_list(gpointer key, gpointer opaque) | ||
67 | static void count_cpreg(gpointer key, gpointer opaque) | ||
68 | { | ||
69 | ARMCPU *cpu = opaque; | ||
70 | - uint64_t regidx; | ||
71 | const ARMCPRegInfo *ri; | ||
72 | |||
73 | - regidx = *(uint32_t *)key; | ||
74 | - ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); | ||
75 | + ri = g_hash_table_lookup(cpu->cp_regs, key); | ||
76 | |||
77 | if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { | ||
78 | cpu->cpreg_array_len++; | ||
79 | @@ -XXX,XX +XXX,XX @@ static void count_cpreg(gpointer key, gpointer opaque) | ||
80 | |||
81 | static gint cpreg_key_compare(gconstpointer a, gconstpointer b) | ||
82 | { | ||
83 | - uint64_t aidx = cpreg_to_kvm_id(*(uint32_t *)a); | ||
84 | - uint64_t bidx = cpreg_to_kvm_id(*(uint32_t *)b); | ||
85 | + uint64_t aidx = cpreg_to_kvm_id((uintptr_t)a); | ||
86 | + uint64_t bidx = cpreg_to_kvm_id((uintptr_t)b); | ||
87 | |||
88 | if (aidx > bidx) { | ||
89 | return 1; | ||
90 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
91 | for (i = 0; i < ARRAY_SIZE(aliases); i++) { | ||
92 | const struct E2HAlias *a = &aliases[i]; | ||
93 | ARMCPRegInfo *src_reg, *dst_reg, *new_reg; | ||
94 | - uint32_t *new_key; | ||
95 | bool ok; | ||
96 | |||
97 | if (a->feature && !a->feature(&cpu->isar)) { | ||
98 | continue; | ||
99 | } | ||
100 | |||
101 | - src_reg = g_hash_table_lookup(cpu->cp_regs, &a->src_key); | ||
102 | - dst_reg = g_hash_table_lookup(cpu->cp_regs, &a->dst_key); | ||
103 | + src_reg = g_hash_table_lookup(cpu->cp_regs, | ||
104 | + (gpointer)(uintptr_t)a->src_key); | ||
105 | + dst_reg = g_hash_table_lookup(cpu->cp_regs, | ||
106 | + (gpointer)(uintptr_t)a->dst_key); | ||
107 | g_assert(src_reg != NULL); | ||
108 | g_assert(dst_reg != NULL); | ||
109 | |||
110 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
111 | |||
112 | /* Create alias before redirection so we dup the right data. */ | ||
113 | new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); | ||
114 | - new_key = g_memdup(&a->new_key, sizeof(uint32_t)); | ||
115 | |||
116 | new_reg->name = a->new_name; | ||
117 | new_reg->type |= ARM_CP_ALIAS; | ||
118 | /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | ||
119 | new_reg->access &= PL2_RW | PL3_RW; | ||
120 | |||
121 | - ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
122 | + ok = g_hash_table_insert(cpu->cp_regs, | ||
123 | + (gpointer)(uintptr_t)a->new_key, new_reg); | ||
124 | g_assert(ok); | ||
125 | |||
126 | src_reg->opaque = dst_reg; | ||
127 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
128 | /* Private utility function for define_one_arm_cp_reg_with_opaque(): | ||
129 | * add a single reginfo struct to the hash table. | ||
130 | */ | ||
131 | - uint32_t *key = g_new(uint32_t, 1); | ||
132 | + uint32_t key; | ||
133 | ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo)); | ||
134 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; | ||
135 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; | ||
136 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
137 | if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) { | ||
138 | r2->cp = CP_REG_ARM64_SYSREG_CP; | ||
139 | } | ||
140 | - *key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, | ||
141 | - r2->opc0, opc1, opc2); | ||
142 | + key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, | ||
143 | + r2->opc0, opc1, opc2); | ||
144 | } else { | ||
145 | - *key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); | ||
146 | + key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); | ||
147 | } | ||
148 | if (opaque) { | ||
149 | r2->opaque = opaque; | ||
150 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
151 | * requested. | ||
152 | */ | ||
153 | if (!(r->type & ARM_CP_OVERRIDE)) { | ||
154 | - ARMCPRegInfo *oldreg; | ||
155 | - oldreg = g_hash_table_lookup(cpu->cp_regs, key); | ||
156 | + const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); | ||
157 | if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) { | ||
158 | fprintf(stderr, "Register redefined: cp=%d %d bit " | ||
159 | "crn=%d crm=%d opc1=%d opc2=%d, " | ||
160 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
161 | g_assert_not_reached(); | ||
162 | } | ||
163 | } | ||
164 | - g_hash_table_insert(cpu->cp_regs, key, r2); | ||
165 | + g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2); | ||
54 | } | 166 | } |
55 | 167 | ||
56 | -uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | 168 | |
57 | - uint64_t ptr, uintptr_t ra) | 169 | @@ -XXX,XX +XXX,XX @@ void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, |
58 | +uint64_t mte_check(CPUARMState *env, uint32_t desc, uint64_t ptr, uintptr_t ra) | 170 | |
171 | const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp) | ||
59 | { | 172 | { |
60 | uint64_t fault; | 173 | - return g_hash_table_lookup(cpregs, &encoded_cp); |
61 | int ret = mte_probe_int(env, desc, ptr, ra, &fault); | 174 | + return g_hash_table_lookup(cpregs, (gpointer)(uintptr_t)encoded_cp); |
62 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
63 | return useronly_clean_ptr(ptr); | ||
64 | } | 175 | } |
65 | 176 | ||
66 | -uint64_t HELPER(mte_checkN)(CPUARMState *env, uint32_t desc, uint64_t ptr) | 177 | void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, |
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 | -- | 178 | -- |
183 | 2.20.1 | 179 | 2.25.1 |
184 | |||
185 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Create a finalize_memop function that computes alignment and | 3 | Simplify freeing cp_regs hash table entries by using a single |
4 | endianness and returns the final MemOp for the operation. | 4 | allocation for the entire value. |
5 | 5 | ||
6 | Split out gen_aa32_{ld,st}_internal_i32 which bypasses any special | 6 | This fixes a theoretical bug if we were to ever free the entire |
7 | handling of endianness or alignment. Adjust gen_aa32_{ld,st}_i32 | 7 | hash table, because we've been installing string literal constants |
8 | so that s->be_data is not added by the callers. | 8 | into the cpreg structure in define_arm_vh_e2h_redirects_aliases. |
9 | However, at present we only free entries created for AArch32 | ||
10 | wildcard cpregs which get overwritten by more specific cpregs, | ||
11 | so this bug is never exposed. | ||
9 | 12 | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 15 | Message-id: 20220501055028.646596-13-richard.henderson@linaro.org |
12 | Message-id: 20210419202257.161730-12-richard.henderson@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 17 | --- |
15 | target/arm/translate.h | 24 ++++++++ | 18 | target/arm/cpu.c | 16 +--------------- |
16 | target/arm/translate.c | 100 +++++++++++++++++--------------- | 19 | target/arm/helper.c | 10 ++++++++-- |
17 | target/arm/translate-neon.c.inc | 9 +-- | 20 | 2 files changed, 9 insertions(+), 17 deletions(-) |
18 | 3 files changed, 79 insertions(+), 54 deletions(-) | ||
19 | 21 | ||
20 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 22 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
21 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/translate.h | 24 | --- a/target/arm/cpu.c |
23 | +++ b/target/arm/translate.h | 25 | +++ b/target/arm/cpu.c |
24 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_ptr fpstatus_ptr(ARMFPStatusFlavour flavour) | 26 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) |
25 | return statusptr; | 27 | return (Aff1 << ARM_AFF1_SHIFT) | Aff0; |
26 | } | 28 | } |
27 | 29 | ||
28 | +/** | 30 | -static void cpreg_hashtable_data_destroy(gpointer data) |
29 | + * finalize_memop: | 31 | -{ |
30 | + * @s: DisasContext | 32 | - /* |
31 | + * @opc: size+sign+align of the memory operation | 33 | - * Destroy function for cpu->cp_regs hashtable data entries. |
32 | + * | 34 | - * We must free the name string because it was g_strdup()ed in |
33 | + * Build the complete MemOp for a memory operation, including alignment | 35 | - * add_cpreg_to_hashtable(). It's OK to cast away the 'const' |
34 | + * and endianness. | 36 | - * from r->name because we know we definitely allocated it. |
35 | + * | 37 | - */ |
36 | + * If (op & MO_AMASK) then the operation already contains the required | 38 | - ARMCPRegInfo *r = data; |
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 | - | 39 | - |
105 | - if (s->align_mem) { | 40 | - g_free((void *)r->name); |
106 | - opc |= MO_ALIGN; | 41 | - g_free(r); |
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 | -} | 42 | -} |
135 | - | 43 | - |
136 | -#define DO_GEN_LD(SUFF, OPC) \ | 44 | static void arm_cpu_initfn(Object *obj) |
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 | { | 45 | { |
158 | @@ -XXX,XX +XXX,XX @@ static bool op_load_rr(DisasContext *s, arg_ldst_rr *a, | 46 | ARMCPU *cpu = ARM_CPU(obj); |
159 | addr = op_addr_rr_pre(s, a); | 47 | |
160 | 48 | cpu_set_cpustate_pointers(cpu); | |
161 | tmp = tcg_temp_new_i32(); | 49 | cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
162 | - gen_aa32_ld_i32(s, tmp, addr, mem_idx, mop | s->be_data); | 50 | - NULL, cpreg_hashtable_data_destroy); |
163 | + gen_aa32_ld_i32(s, tmp, addr, mem_idx, mop); | 51 | + NULL, g_free); |
164 | disas_set_da_iss(s, mop, issinfo); | 52 | |
165 | 53 | QLIST_INIT(&cpu->pre_el_change_hooks); | |
166 | /* | 54 | QLIST_INIT(&cpu->el_change_hooks); |
167 | @@ -XXX,XX +XXX,XX @@ static bool op_store_rr(DisasContext *s, arg_ldst_rr *a, | 55 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
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 | 56 | index XXXXXXX..XXXXXXX 100644 |
288 | --- a/target/arm/translate-neon.c.inc | 57 | --- a/target/arm/helper.c |
289 | +++ b/target/arm/translate-neon.c.inc | 58 | +++ b/target/arm/helper.c |
290 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | 59 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
291 | addr = tcg_temp_new_i32(); | 60 | * add a single reginfo struct to the hash table. |
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 | */ | 61 | */ |
302 | for (reg = 0; reg < nregs; reg++) { | 62 | uint32_t key; |
303 | if (a->l) { | 63 | - ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo)); |
304 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), | 64 | + ARMCPRegInfo *r2; |
305 | - s->be_data | a->size); | 65 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; |
306 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), a->size); | 66 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; |
307 | neon_store_element(vd, a->reg_idx, a->size, tmp); | 67 | + size_t name_len; |
308 | } else { /* Store */ | 68 | + |
309 | neon_load_element(tmp, vd, a->reg_idx, a->size); | 69 | + /* Combine cpreg and name into one allocation. */ |
310 | - gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), | 70 | + name_len = strlen(name) + 1; |
311 | - s->be_data | a->size); | 71 | + r2 = g_malloc(sizeof(*r2) + name_len); |
312 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), a->size); | 72 | + *r2 = *r; |
313 | } | 73 | + r2->name = memcpy(r2 + 1, name, name_len); |
314 | vd += a->stride; | 74 | |
315 | tcg_gen_addi_i32(addr, addr, 1 << a->size); | 75 | - r2->name = g_strdup(name); |
76 | /* Reset the secure state to the specific incoming state. This is | ||
77 | * necessary as the register may have been defined with both states. | ||
78 | */ | ||
316 | -- | 79 | -- |
317 | 2.20.1 | 80 | 2.25.1 |
318 | |||
319 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Move the computation of key to the top of the function. | ||
4 | Hoist the resolution of cp as well, as an input to the | ||
5 | computation of key. | ||
6 | |||
7 | This will be required by a subsequent patch. | ||
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: 20220501055028.646596-14-richard.henderson@linaro.org |
5 | Message-id: 20210419202257.161730-24-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-neon.c.inc | 27 ++++++++++++++++++++++----- | 14 | target/arm/helper.c | 49 +++++++++++++++++++++++++-------------------- |
9 | 1 file changed, 22 insertions(+), 5 deletions(-) | 15 | 1 file changed, 27 insertions(+), 22 deletions(-) |
10 | 16 | ||
11 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-neon.c.inc | 19 | --- a/target/arm/helper.c |
14 | +++ b/target/arm/translate-neon.c.inc | 20 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | 21 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
16 | { | 22 | ARMCPRegInfo *r2; |
17 | /* Neon load/store multiple structures */ | 23 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; |
18 | int nregs, interleave, spacing, reg, n; | 24 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; |
19 | - MemOp endian = s->be_data; | 25 | + int cp = r->cp; |
20 | + MemOp mop, align, endian; | 26 | size_t name_len; |
21 | int mmu_idx = get_mem_index(s); | 27 | |
22 | int size = a->size; | 28 | + switch (state) { |
23 | TCGv_i64 tmp64; | 29 | + case ARM_CP_STATE_AA32: |
24 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | 30 | + /* We assume it is a cp15 register if the .cp field is left unset. */ |
25 | } | 31 | + if (cp == 0 && r->state == ARM_CP_STATE_BOTH) { |
26 | 32 | + cp = 15; | |
27 | /* For our purposes, bytes are always little-endian. */ | 33 | + } |
28 | + endian = s->be_data; | 34 | + key = ENCODE_CP_REG(cp, is64, ns, r->crn, crm, opc1, opc2); |
29 | if (size == 0) { | 35 | + break; |
30 | endian = MO_LE; | 36 | + case ARM_CP_STATE_AA64: |
31 | } | 37 | + /* |
32 | + | 38 | + * To allow abbreviation of ARMCPRegInfo definitions, we treat |
33 | + /* Enforce alignment requested by the instruction */ | 39 | + * cp == 0 as equivalent to the value for "standard guest-visible |
34 | + if (a->align) { | 40 | + * sysreg". STATE_BOTH definitions are also always "standard sysreg" |
35 | + align = pow2_align(a->align + 2); /* 4 ** a->align */ | 41 | + * in their AArch64 view (the .cp value may be non-zero for the |
36 | + } else { | 42 | + * benefit of the AArch32 view). |
37 | + align = s->align_mem ? MO_ALIGN : 0; | 43 | + */ |
44 | + if (cp == 0 || r->state == ARM_CP_STATE_BOTH) { | ||
45 | + cp = CP_REG_ARM64_SYSREG_CP; | ||
46 | + } | ||
47 | + key = ENCODE_AA64_CP_REG(cp, r->crn, crm, r->opc0, opc1, opc2); | ||
48 | + break; | ||
49 | + default: | ||
50 | + g_assert_not_reached(); | ||
38 | + } | 51 | + } |
39 | + | 52 | + |
40 | /* | 53 | /* Combine cpreg and name into one allocation. */ |
41 | * Consecutive little-endian elements from a single register | 54 | name_len = strlen(name) + 1; |
42 | * can be promoted to a larger little-endian operation. | 55 | r2 = g_malloc(sizeof(*r2) + name_len); |
43 | */ | 56 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
44 | if (interleave == 1 && endian == MO_LE) { | 57 | } |
45 | + /* Retain any natural alignment. */ | 58 | |
46 | + if (align == MO_ALIGN) { | 59 | if (r->state == ARM_CP_STATE_BOTH) { |
47 | + align = pow2_align(size); | 60 | - /* We assume it is a cp15 register if the .cp field is left unset. |
48 | + } | 61 | - */ |
49 | size = 3; | 62 | - if (r2->cp == 0) { |
50 | } | 63 | - r2->cp = 15; |
51 | + | 64 | - } |
52 | tmp64 = tcg_temp_new_i64(); | 65 | - |
53 | addr = tcg_temp_new_i32(); | 66 | #if HOST_BIG_ENDIAN |
54 | tmp = tcg_const_i32(1 << size); | 67 | if (r2->fieldoffset) { |
55 | load_reg_var(s, addr, a->rn); | 68 | r2->fieldoffset += sizeof(uint32_t); |
56 | + | 69 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
57 | + mop = endian | size | align; | 70 | #endif |
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 | } | 71 | } |
81 | } | 72 | } |
73 | - if (state == ARM_CP_STATE_AA64) { | ||
74 | - /* To allow abbreviation of ARMCPRegInfo | ||
75 | - * definitions, we treat cp == 0 as equivalent to | ||
76 | - * the value for "standard guest-visible sysreg". | ||
77 | - * STATE_BOTH definitions are also always "standard | ||
78 | - * sysreg" in their AArch64 view (the .cp value may | ||
79 | - * be non-zero for the benefit of the AArch32 view). | ||
80 | - */ | ||
81 | - if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) { | ||
82 | - r2->cp = CP_REG_ARM64_SYSREG_CP; | ||
83 | - } | ||
84 | - key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, | ||
85 | - r2->opc0, opc1, opc2); | ||
86 | - } else { | ||
87 | - key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); | ||
88 | - } | ||
89 | if (opaque) { | ||
90 | r2->opaque = opaque; | ||
91 | } | ||
92 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
93 | /* Make sure reginfo passed to helpers for wildcarded regs | ||
94 | * has the correct crm/opc1/opc2 for this reg, not CP_ANY: | ||
95 | */ | ||
96 | + r2->cp = cp; | ||
97 | r2->crm = crm; | ||
98 | r2->opc1 = opc1; | ||
99 | r2->opc2 = opc2; | ||
82 | -- | 100 | -- |
83 | 2.20.1 | 101 | 2.25.1 |
84 | |||
85 | 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 | Put most of the value writeback to the same place, |
4 | and this field name will be expanded using the bit definition of | 4 | and improve the comment that goes with them. |
5 | the same name, resulting in a token pasting error. | ||
6 | 5 | ||
7 | So SCTLR_B -> SCTLR__B in the 3 uses, and document it. | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | |||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20220501055028.646596-15-richard.henderson@linaro.org |
11 | Message-id: 20210419202257.161730-3-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/helper.c | 28 ++++++++++++---------------- |
15 | target/arm/helper.c | 2 +- | 12 | 1 file changed, 12 insertions(+), 16 deletions(-) |
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 | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/cpu.h | ||
22 | +++ b/target/arm/cpu.h | ||
23 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, VECSTRIDE, 12, 2) /* Not cached. */ | ||
24 | */ | ||
25 | FIELD(TBFLAG_A32, XSCALE_CPAR, 12, 2) | ||
26 | FIELD(TBFLAG_A32, VFPEN, 14, 1) /* Partially cached, minus FPEXC. */ | ||
27 | -FIELD(TBFLAG_A32, SCTLR_B, 15, 1) | ||
28 | +FIELD(TBFLAG_A32, SCTLR__B, 15, 1) /* Cannot overlap with SCTLR_B */ | ||
29 | FIELD(TBFLAG_A32, HSTR_ACTIVE, 16, 1) | ||
30 | /* | ||
31 | * Indicates whether cp register reads and writes by guest code should access | ||
32 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
33 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/target/arm/helper.c | 16 | --- a/target/arm/helper.c |
35 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/helper.c |
36 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, | 18 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
37 | bool sctlr_b = arm_sctlr_b(env); | 19 | *r2 = *r; |
38 | 20 | r2->name = memcpy(r2 + 1, name, name_len); | |
39 | if (sctlr_b) { | 21 | |
40 | - flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, 1); | 22 | - /* Reset the secure state to the specific incoming state. This is |
41 | + flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR__B, 1); | 23 | - * necessary as the register may have been defined with both states. |
24 | + /* | ||
25 | + * Update fields to match the instantiation, overwiting wildcards | ||
26 | + * such as CP_ANY, ARM_CP_STATE_BOTH, or ARM_CP_SECSTATE_BOTH. | ||
27 | */ | ||
28 | + r2->cp = cp; | ||
29 | + r2->crm = crm; | ||
30 | + r2->opc1 = opc1; | ||
31 | + r2->opc2 = opc2; | ||
32 | + r2->state = state; | ||
33 | r2->secure = secstate; | ||
34 | + if (opaque) { | ||
35 | + r2->opaque = opaque; | ||
36 | + } | ||
37 | |||
38 | if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { | ||
39 | /* Register is banked (using both entries in array). | ||
40 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
41 | #endif | ||
42 | } | ||
42 | } | 43 | } |
43 | if (arm_cpu_data_is_big_endian_a32(env, sctlr_b)) { | 44 | - if (opaque) { |
44 | flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); | 45 | - r2->opaque = opaque; |
45 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 46 | - } |
46 | index XXXXXXX..XXXXXXX 100644 | 47 | - /* reginfo passed to helpers is correct for the actual access, |
47 | --- a/target/arm/translate.c | 48 | - * and is never ARM_CP_STATE_BOTH: |
48 | +++ b/target/arm/translate.c | 49 | - */ |
49 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 50 | - r2->state = state; |
50 | FIELD_EX32(tb_flags, TBFLAG_ANY, BE_DATA) ? MO_BE : MO_LE; | 51 | - /* Make sure reginfo passed to helpers for wildcarded regs |
51 | dc->debug_target_el = | 52 | - * has the correct crm/opc1/opc2 for this reg, not CP_ANY: |
52 | FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | 53 | - */ |
53 | - dc->sctlr_b = FIELD_EX32(tb_flags, TBFLAG_A32, SCTLR_B); | 54 | - r2->cp = cp; |
54 | + dc->sctlr_b = FIELD_EX32(tb_flags, TBFLAG_A32, SCTLR__B); | 55 | - r2->crm = crm; |
55 | dc->hstr_active = FIELD_EX32(tb_flags, TBFLAG_A32, HSTR_ACTIVE); | 56 | - r2->opc1 = opc1; |
56 | dc->ns = FIELD_EX32(tb_flags, TBFLAG_A32, NS); | 57 | - r2->opc2 = opc2; |
57 | dc->vfp_enabled = FIELD_EX32(tb_flags, TBFLAG_A32, VFPEN); | 58 | + |
59 | /* By convention, for wildcarded registers only the first | ||
60 | * entry is used for migration; the others are marked as | ||
61 | * ALIAS so we don't try to transfer the register | ||
58 | -- | 62 | -- |
59 | 2.20.1 | 63 | 2.25.1 |
60 | |||
61 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Bool is a more appropriate type for these variables. | ||
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: 20220501055028.646596-16-richard.henderson@linaro.org |
5 | Message-id: 20210419202257.161730-17-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.c | 4 ++-- | 10 | target/arm/helper.c | 4 ++-- |
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | 11 | 1 file changed, 2 insertions(+), 2 deletions(-) |
10 | 12 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 15 | --- a/target/arm/helper.c |
14 | +++ b/target/arm/translate.c | 16 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ static bool op_stl(DisasContext *s, arg_STL *a, MemOp mop) | 17 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
16 | addr = load_reg(s, a->rn); | 18 | */ |
17 | tmp = load_reg(s, a->rt); | 19 | uint32_t key; |
18 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | 20 | ARMCPRegInfo *r2; |
19 | - gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), mop); | 21 | - int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; |
20 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), mop | MO_ALIGN); | 22 | - int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; |
21 | disas_set_da_iss(s, mop, a->rt | ISSIsAcqRel | ISSIsWrite); | 23 | + bool is64 = r->type & ARM_CP_64BIT; |
22 | 24 | + bool ns = secstate & ARM_CP_SECSTATE_NS; | |
23 | tcg_temp_free_i32(tmp); | 25 | int cp = r->cp; |
24 | @@ -XXX,XX +XXX,XX @@ static bool op_lda(DisasContext *s, arg_LDA *a, MemOp mop) | 26 | size_t name_len; |
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 | 27 | ||
33 | -- | 28 | -- |
34 | 2.20.1 | 29 | 2.25.1 |
35 | |||
36 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | For 128-bit load/store, use 16-byte alignment. This | 3 | Computing isbanked only once makes the code |
4 | requires that we perform the two operations in the | 4 | a bit easier to read. |
5 | correct order so that we generate the alignment fault | ||
6 | before modifying memory. | ||
7 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20220501055028.646596-17-richard.henderson@linaro.org |
10 | Message-id: 20210419202257.161730-27-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 10 | --- |
13 | target/arm/translate-a64.c | 42 +++++++++++++++++++++++--------------- | 11 | target/arm/helper.c | 6 ++++-- |
14 | 1 file changed, 26 insertions(+), 16 deletions(-) | 12 | 1 file changed, 4 insertions(+), 2 deletions(-) |
15 | 13 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 16 | --- a/target/arm/helper.c |
19 | +++ b/target/arm/translate-a64.c | 17 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void do_gpr_ld(DisasContext *s, TCGv_i64 dest, TCGv_i64 tcg_addr, | 18 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
21 | static void do_fp_st(DisasContext *s, int srcidx, TCGv_i64 tcg_addr, int size) | 19 | bool is64 = r->type & ARM_CP_64BIT; |
22 | { | 20 | bool ns = secstate & ARM_CP_SECSTATE_NS; |
23 | /* This writes the bottom N bits of a 128 bit wide vector to memory */ | 21 | int cp = r->cp; |
24 | - TCGv_i64 tmp = tcg_temp_new_i64(); | 22 | + bool isbanked; |
25 | - tcg_gen_ld_i64(tmp, cpu_env, fp_reg_offset(s, srcidx, MO_64)); | 23 | size_t name_len; |
26 | + TCGv_i64 tmplo = tcg_temp_new_i64(); | 24 | |
27 | + MemOp mop; | 25 | switch (state) { |
28 | + | 26 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
29 | + tcg_gen_ld_i64(tmplo, cpu_env, fp_reg_offset(s, srcidx, MO_64)); | 27 | r2->opaque = opaque; |
30 | + | ||
31 | if (size < 4) { | ||
32 | - tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), | ||
33 | - s->be_data + size); | ||
34 | + mop = finalize_memop(s, size); | ||
35 | + tcg_gen_qemu_st_i64(tmplo, tcg_addr, get_mem_index(s), mop); | ||
36 | } else { | ||
37 | bool be = s->be_data == MO_BE; | ||
38 | TCGv_i64 tcg_hiaddr = tcg_temp_new_i64(); | ||
39 | + TCGv_i64 tmphi = tcg_temp_new_i64(); | ||
40 | |||
41 | + tcg_gen_ld_i64(tmphi, cpu_env, fp_reg_hi_offset(s, srcidx)); | ||
42 | + | ||
43 | + mop = s->be_data | MO_Q; | ||
44 | + tcg_gen_qemu_st_i64(be ? tmphi : tmplo, tcg_addr, get_mem_index(s), | ||
45 | + mop | (s->align_mem ? MO_ALIGN_16 : 0)); | ||
46 | tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8); | ||
47 | - tcg_gen_qemu_st_i64(tmp, be ? tcg_hiaddr : tcg_addr, get_mem_index(s), | ||
48 | - s->be_data | MO_Q); | ||
49 | - tcg_gen_ld_i64(tmp, cpu_env, fp_reg_hi_offset(s, srcidx)); | ||
50 | - tcg_gen_qemu_st_i64(tmp, be ? tcg_addr : tcg_hiaddr, get_mem_index(s), | ||
51 | - s->be_data | MO_Q); | ||
52 | + tcg_gen_qemu_st_i64(be ? tmplo : tmphi, tcg_hiaddr, | ||
53 | + get_mem_index(s), mop); | ||
54 | + | ||
55 | tcg_temp_free_i64(tcg_hiaddr); | ||
56 | + tcg_temp_free_i64(tmphi); | ||
57 | } | 28 | } |
58 | 29 | ||
59 | - tcg_temp_free_i64(tmp); | 30 | - if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { |
60 | + tcg_temp_free_i64(tmplo); | 31 | + isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; |
61 | } | 32 | + if (isbanked) { |
62 | 33 | /* Register is banked (using both entries in array). | |
63 | /* | 34 | * Overwriting fieldoffset as the array is only used to define |
64 | @@ -XXX,XX +XXX,XX @@ static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size) | 35 | * banked registers but later only fieldoffset is used. |
65 | /* This always zero-extends and writes to a full 128 bit wide vector */ | 36 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
66 | TCGv_i64 tmplo = tcg_temp_new_i64(); | ||
67 | TCGv_i64 tmphi = NULL; | ||
68 | + MemOp mop; | ||
69 | |||
70 | if (size < 4) { | ||
71 | - MemOp memop = s->be_data + size; | ||
72 | - tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), memop); | ||
73 | + mop = finalize_memop(s, size); | ||
74 | + tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), mop); | ||
75 | } else { | ||
76 | bool be = s->be_data == MO_BE; | ||
77 | TCGv_i64 tcg_hiaddr; | ||
78 | @@ -XXX,XX +XXX,XX @@ static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size) | ||
79 | tmphi = tcg_temp_new_i64(); | ||
80 | tcg_hiaddr = tcg_temp_new_i64(); | ||
81 | |||
82 | + mop = s->be_data | MO_Q; | ||
83 | + tcg_gen_qemu_ld_i64(be ? tmphi : tmplo, tcg_addr, get_mem_index(s), | ||
84 | + mop | (s->align_mem ? MO_ALIGN_16 : 0)); | ||
85 | tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8); | ||
86 | - tcg_gen_qemu_ld_i64(tmplo, be ? tcg_hiaddr : tcg_addr, get_mem_index(s), | ||
87 | - s->be_data | MO_Q); | ||
88 | - tcg_gen_qemu_ld_i64(tmphi, be ? tcg_addr : tcg_hiaddr, get_mem_index(s), | ||
89 | - s->be_data | MO_Q); | ||
90 | + tcg_gen_qemu_ld_i64(be ? tmplo : tmphi, tcg_hiaddr, | ||
91 | + get_mem_index(s), mop); | ||
92 | tcg_temp_free_i64(tcg_hiaddr); | ||
93 | } | 37 | } |
94 | 38 | ||
39 | if (state == ARM_CP_STATE_AA32) { | ||
40 | - if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { | ||
41 | + if (isbanked) { | ||
42 | /* If the register is banked then we don't need to migrate or | ||
43 | * reset the 32-bit instance in certain cases: | ||
44 | * | ||
95 | -- | 45 | -- |
96 | 2.20.1 | 46 | 2.25.1 |
97 | |||
98 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Split out a helper function from mte_checkN to perform | 3 | Perform the override check early, so that it is still done |
4 | all of the checking and address manpulation. So far, | 4 | even when we decide to discard an unreachable cpreg. |
5 | just use this in mte_checkN itself. | ||
6 | 5 | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Use assert not printf+abort. |
7 | |||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20210416183106.1516563-3-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Message-id: 20220501055028.646596-18-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 12 | --- |
13 | target/arm/mte_helper.c | 52 +++++++++++++++++++++++++++++++---------- | 13 | target/arm/helper.c | 22 ++++++++-------------- |
14 | 1 file changed, 40 insertions(+), 12 deletions(-) | 14 | 1 file changed, 8 insertions(+), 14 deletions(-) |
15 | 15 | ||
16 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/mte_helper.c | 18 | --- a/target/arm/helper.c |
19 | +++ b/target/arm/mte_helper.c | 19 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static int checkN(uint8_t *mem, int odd, int cmp, int count) | 20 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
21 | return n; | 21 | g_assert_not_reached(); |
22 | } | ||
23 | |||
24 | -uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
25 | - uint64_t ptr, uintptr_t ra) | ||
26 | +/** | ||
27 | + * mte_probe_int() - helper for mte_probe and mte_check | ||
28 | + * @env: CPU environment | ||
29 | + * @desc: MTEDESC descriptor | ||
30 | + * @ptr: virtual address of the base of the access | ||
31 | + * @fault: return virtual address of the first check failure | ||
32 | + * | ||
33 | + * Internal routine for both mte_probe and mte_check. | ||
34 | + * Return zero on failure, filling in *fault. | ||
35 | + * Return negative on trivial success for tbi disabled. | ||
36 | + * Return positive on success with tbi enabled. | ||
37 | + */ | ||
38 | +static int mte_probe_int(CPUARMState *env, uint32_t desc, uint64_t ptr, | ||
39 | + uintptr_t ra, uint32_t total, uint64_t *fault) | ||
40 | { | ||
41 | int mmu_idx, ptr_tag, bit55; | ||
42 | uint64_t ptr_last, prev_page, next_page; | ||
43 | uint64_t tag_first, tag_last; | ||
44 | uint64_t tag_byte_first, tag_byte_last; | ||
45 | - uint32_t total, tag_count, tag_size, n, c; | ||
46 | + uint32_t tag_count, tag_size, n, c; | ||
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 | } | 22 | } |
58 | 23 | ||
59 | ptr_tag = allocation_tag_from_addr(ptr); | 24 | + /* Overriding of an existing definition must be explicitly requested. */ |
60 | 25 | + if (!(r->type & ARM_CP_OVERRIDE)) { | |
61 | if (tcma_check(desc, bit55, ptr_tag)) { | 26 | + const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); |
62 | - goto done; | 27 | + if (oldreg) { |
63 | + return 1; | 28 | + assert(oldreg->type & ARM_CP_OVERRIDE); |
64 | } | 29 | + } |
65 | |||
66 | mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX); | ||
67 | type = FIELD_EX32(desc, MTEDESC, WRITE) ? MMU_DATA_STORE : MMU_DATA_LOAD; | ||
68 | - total = FIELD_EX32(desc, MTEDESC, TSIZE); | ||
69 | |||
70 | /* Find the addr of the end of the access */ | ||
71 | ptr_last = ptr + total - 1; | ||
72 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
73 | mem1 = allocation_tag_mem(env, mmu_idx, ptr, type, total, | ||
74 | MMU_DATA_LOAD, tag_size, ra); | ||
75 | if (!mem1) { | ||
76 | - goto done; | ||
77 | + return 1; | ||
78 | } | ||
79 | /* Perform all of the comparisons. */ | ||
80 | n = checkN(mem1, ptr & TAG_GRANULE, ptr_tag, tag_count); | ||
81 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | ||
82 | } | ||
83 | if (n == c) { | ||
84 | if (!mem2) { | ||
85 | - goto done; | ||
86 | + return 1; | ||
87 | } | ||
88 | n += checkN(mem2, 0, ptr_tag, tag_count - c); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | + if (likely(n == tag_count)) { | ||
93 | + return 1; | ||
94 | + } | 30 | + } |
95 | + | 31 | + |
96 | /* | 32 | /* Combine cpreg and name into one allocation. */ |
97 | * If we failed, we know which granule. For the first granule, the | 33 | name_len = strlen(name) + 1; |
98 | * failure address is @ptr, the first byte accessed. Otherwise the | 34 | r2 = g_malloc(sizeof(*r2) + name_len); |
99 | * failure address is the first byte of the nth granule. | 35 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
100 | */ | 36 | assert(!raw_accessors_invalid(r2)); |
101 | - if (unlikely(n < tag_count)) { | ||
102 | - uint64_t fault = (n == 0 ? ptr : tag_first + n * TAG_GRANULE); | ||
103 | - mte_check_fail(env, desc, fault, ra); | ||
104 | + if (n > 0) { | ||
105 | + *fault = tag_first + n * TAG_GRANULE; | ||
106 | } | 37 | } |
107 | + return 0; | 38 | |
108 | +} | 39 | - /* Overriding of an existing definition must be explicitly |
109 | 40 | - * requested. | |
110 | - done: | 41 | - */ |
111 | +uint64_t mte_checkN(CPUARMState *env, uint32_t desc, | 42 | - if (!(r->type & ARM_CP_OVERRIDE)) { |
112 | + uint64_t ptr, uintptr_t ra) | 43 | - const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); |
113 | +{ | 44 | - if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) { |
114 | + uint64_t fault; | 45 | - fprintf(stderr, "Register redefined: cp=%d %d bit " |
115 | + uint32_t total = FIELD_EX32(desc, MTEDESC, TSIZE); | 46 | - "crn=%d crm=%d opc1=%d opc2=%d, " |
116 | + int ret = mte_probe_int(env, desc, ptr, ra, total, &fault); | 47 | - "was %s, now %s\n", r2->cp, 32 + 32 * is64, |
117 | + | 48 | - r2->crn, r2->crm, r2->opc1, r2->opc2, |
118 | + if (unlikely(ret == 0)) { | 49 | - oldreg->name, r2->name); |
119 | + mte_check_fail(env, desc, fault, ra); | 50 | - g_assert_not_reached(); |
120 | + } else if (ret < 0) { | 51 | - } |
121 | + return ptr; | 52 | - } |
122 | + } | 53 | g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2); |
123 | return useronly_clean_ptr(ptr); | ||
124 | } | 54 | } |
125 | 55 | ||
126 | -- | 56 | -- |
127 | 2.20.1 | 57 | 2.25.1 |
128 | |||
129 | 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 | 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 |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Put the block comments into the current coding style. | ||
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: 20220501055028.646596-19-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/helper.c | 24 +++++++++++++++--------- |
9 | target/arm/translate.c | 15 +++++++++++++ | 11 | 1 file changed, 15 insertions(+), 9 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/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.h | 15 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/translate.h | 16 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ void arm_test_cc(DisasCompare *cmp, int cc); | 17 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) |
18 | void arm_free_cc(DisasCompare *cmp); | 18 | return cpu_list; |
19 | void arm_jump_cc(DisasCompare *cmp, TCGLabel *label); | 19 | } |
20 | void arm_gen_test_cc(int cc, TCGLabel *label); | 20 | |
21 | +MemOp pow2_align(unsigned i); | 21 | +/* |
22 | 22 | + * Private utility function for define_one_arm_cp_reg_with_opaque(): | |
23 | /* Return state of Alternate Half-precision flag, caller frees result */ | 23 | + * add a single reginfo struct to the hash table. |
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 void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
26 | index XXXXXXX..XXXXXXX 100644 | 26 | void *opaque, CPState state, |
27 | --- a/target/arm/translate.c | 27 | CPSecureState secstate, |
28 | +++ b/target/arm/translate.c | 28 | int crm, int opc1, int opc2, |
29 | @@ -XXX,XX +XXX,XX @@ static inline void store_reg_from_load(DisasContext *s, int reg, TCGv_i32 var) | 29 | const char *name) |
30 | #define IS_USER_ONLY 0 | 30 | { |
31 | #endif | 31 | - /* Private utility function for define_one_arm_cp_reg_with_opaque(): |
32 | 32 | - * add a single reginfo struct to the hash table. | |
33 | +MemOp pow2_align(unsigned i) | 33 | - */ |
34 | +{ | 34 | uint32_t key; |
35 | + static const MemOp mop_align[] = { | 35 | ARMCPRegInfo *r2; |
36 | + 0, MO_ALIGN_2, MO_ALIGN_4, MO_ALIGN_8, MO_ALIGN_16, | 36 | bool is64 = r->type & ARM_CP_64BIT; |
37 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
38 | |||
39 | isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; | ||
40 | if (isbanked) { | ||
41 | - /* Register is banked (using both entries in array). | ||
37 | + /* | 42 | + /* |
38 | + * FIXME: TARGET_PAGE_BITS_MIN affects TLB_FLAGS_MASK such | 43 | + * Register is banked (using both entries in array). |
39 | + * that 256-bit alignment (MO_ALIGN_32) cannot be supported: | 44 | * Overwriting fieldoffset as the array is only used to define |
40 | + * see get_alignment_bits(). Enforce only 128-bit alignment for now. | 45 | * banked registers but later only fieldoffset is used. |
41 | + */ | 46 | */ |
42 | + MO_ALIGN_16 | 47 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
43 | + }; | 48 | |
44 | + g_assert(i < ARRAY_SIZE(mop_align)); | 49 | if (state == ARM_CP_STATE_AA32) { |
45 | + return mop_align[i]; | 50 | if (isbanked) { |
46 | +} | 51 | - /* If the register is banked then we don't need to migrate or |
47 | + | 52 | + /* |
48 | /* | 53 | + * If the register is banked then we don't need to migrate or |
49 | * Abstractions of "generate code to do a guest load/store for | 54 | * reset the 32-bit instance in certain cases: |
50 | * AArch32", where a vaddr is always 32 bits (and is zero | 55 | * |
51 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 56 | * 1) If the register has both 32-bit and 64-bit instances then we |
52 | index XXXXXXX..XXXXXXX 100644 | 57 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
53 | --- a/target/arm/translate-neon.c.inc | 58 | r2->type |= ARM_CP_ALIAS; |
54 | +++ b/target/arm/translate-neon.c.inc | 59 | } |
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | 60 | } else if ((secstate != r->secure) && !ns) { |
56 | int size = a->size; | 61 | - /* The register is not banked so we only want to allow migration of |
57 | int nregs = a->n + 1; | 62 | - * the non-secure instance. |
58 | TCGv_i32 addr, tmp; | 63 | + /* |
59 | + MemOp mop, align; | 64 | + * The register is not banked so we only want to allow migration |
60 | 65 | + * of the non-secure instance. | |
61 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 66 | */ |
62 | return false; | 67 | r2->type |= ARM_CP_ALIAS; |
63 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | 68 | } |
64 | return false; | 69 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
70 | } | ||
65 | } | 71 | } |
66 | 72 | ||
67 | + align = 0; | 73 | - /* By convention, for wildcarded registers only the first |
68 | if (size == 3) { | 74 | + /* |
69 | if (nregs != 4 || a->a == 0) { | 75 | + * By convention, for wildcarded registers only the first |
70 | return false; | 76 | * entry is used for migration; the others are marked as |
71 | } | 77 | * ALIAS so we don't try to transfer the register |
72 | /* For VLD4 size == 3 a == 1 means 32 bits at 16 byte alignment */ | 78 | * multiple times. Special registers (ie NOP/WFI) are |
73 | - size = 2; | 79 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
74 | - } | 80 | r2->type |= ARM_CP_ALIAS | ARM_CP_NO_GDB; |
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 | } | 81 | } |
102 | 82 | ||
103 | if (!vfp_access_check(s)) { | 83 | - /* Check that raw accesses are either forbidden or handled. Note that |
104 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | 84 | + /* |
85 | + * Check that raw accesses are either forbidden or handled. Note that | ||
86 | * we can't assert this earlier because the setup of fieldoffset for | ||
87 | * banked registers has to be done first. | ||
105 | */ | 88 | */ |
106 | stride = a->t ? 2 : 1; | ||
107 | vec_size = nregs == 1 ? stride * 8 : 8; | ||
108 | - | ||
109 | + mop = size | align; | ||
110 | tmp = tcg_temp_new_i32(); | ||
111 | addr = tcg_temp_new_i32(); | ||
112 | load_reg_var(s, addr, a->rn); | ||
113 | for (reg = 0; reg < nregs; reg++) { | ||
114 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), size); | ||
115 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), mop); | ||
116 | if ((vd & 1) && vec_size == 16) { | ||
117 | /* | ||
118 | * We cannot write 16 bytes at once because the | ||
119 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | ||
120 | } | ||
121 | tcg_gen_addi_i32(addr, addr, 1 << size); | ||
122 | vd += stride; | ||
123 | + | ||
124 | + /* Subsequent memory operations inherit alignment */ | ||
125 | + mop &= ~MO_AMASK; | ||
126 | } | ||
127 | tcg_temp_free_i32(tmp); | ||
128 | tcg_temp_free_i32(addr); | ||
129 | -- | 89 | -- |
130 | 2.20.1 | 90 | 2.25.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 | Since e03b56863d2bc, our host endian indicator is unconditionally | ||
4 | set, which means that we can use a normal C condition. | ||
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: 20220501055028.646596-20-richard.henderson@linaro.org |
5 | Message-id: 20210419202257.161730-25-richard.henderson@linaro.org | 9 | [PMM: quote correct git hash in commit message] |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | target/arm/translate-neon.c.inc | 48 ++++++++++++++++++++++++++++----- | 12 | target/arm/helper.c | 9 +++------ |
9 | 1 file changed, 42 insertions(+), 6 deletions(-) | 13 | 1 file changed, 3 insertions(+), 6 deletions(-) |
10 | 14 | ||
11 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-neon.c.inc | 17 | --- a/target/arm/helper.c |
14 | +++ b/target/arm/translate-neon.c.inc | 18 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | 19 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
16 | int nregs = a->n + 1; | 20 | r2->type |= ARM_CP_ALIAS; |
17 | int vd = a->vd; | 21 | } |
18 | TCGv_i32 addr, tmp; | 22 | |
19 | + MemOp mop; | 23 | - if (r->state == ARM_CP_STATE_BOTH) { |
20 | 24 | -#if HOST_BIG_ENDIAN | |
21 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 25 | - if (r2->fieldoffset) { |
22 | return false; | 26 | - r2->fieldoffset += sizeof(uint32_t); |
23 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | 27 | - } |
24 | return true; | 28 | -#endif |
29 | + if (HOST_BIG_ENDIAN && | ||
30 | + r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) { | ||
31 | + r2->fieldoffset += sizeof(uint32_t); | ||
32 | } | ||
25 | } | 33 | } |
26 | 34 | ||
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 | -- | 35 | -- |
89 | 2.20.1 | 36 | 2.25.1 |
90 | |||
91 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | |||
3 | Adjust the interface to match what has been done to the | ||
4 | TCGv_i32 load/store functions. | ||
5 | |||
6 | This is less obvious, because at present the only user of | ||
7 | these functions, trans_VLDST_multiple, also wants to manipulate | ||
8 | the endianness to speed up loading multiple bytes. Thus we | ||
9 | retain an "internal" interface which is identical to the | ||
10 | current gen_aa32_{ld,st}_i64 interface. | ||
11 | |||
12 | The "new" interface will gain users as we remove the legacy | ||
13 | interfaces, gen_aa32_ld64 and gen_aa32_st64. | ||
14 | 2 | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-id: 20210419202257.161730-15-richard.henderson@linaro.org | 5 | Message-id: 20220501055028.646596-24-richard.henderson@linaro.org |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 7 | --- |
20 | target/arm/translate.c | 78 +++++++++++++++++++-------------- | 8 | target/arm/cpu.h | 15 +++++++++++++++ |
21 | target/arm/translate-neon.c.inc | 6 ++- | 9 | 1 file changed, 15 insertions(+) |
22 | 2 files changed, 49 insertions(+), 35 deletions(-) | ||
23 | 10 | ||
24 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 11 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
25 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/translate.c | 13 | --- a/target/arm/cpu.h |
27 | +++ b/target/arm/translate.c | 14 | +++ b/target/arm/cpu.h |
28 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_internal_i32(DisasContext *s, TCGv_i32 val, | 15 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_ssbs(const ARMISARegisters *id) |
29 | tcg_temp_free(addr); | 16 | return FIELD_EX32(id->id_pfr2, ID_PFR2, SSBS) != 0; |
30 | } | 17 | } |
31 | 18 | ||
32 | +static void gen_aa32_ld_internal_i64(DisasContext *s, TCGv_i64 val, | 19 | +static inline bool isar_feature_aa32_debugv8p2(const ARMISARegisters *id) |
33 | + TCGv_i32 a32, int index, MemOp opc) | ||
34 | +{ | 20 | +{ |
35 | + TCGv addr = gen_aa32_addr(s, a32, opc); | 21 | + return FIELD_EX32(id->id_dfr0, ID_DFR0, COPDBG) >= 8; |
36 | + | ||
37 | + tcg_gen_qemu_ld_i64(val, addr, index, opc); | ||
38 | + | ||
39 | + /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
40 | + if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | ||
41 | + tcg_gen_rotri_i64(val, val, 32); | ||
42 | + } | ||
43 | + tcg_temp_free(addr); | ||
44 | +} | 22 | +} |
45 | + | 23 | + |
46 | +static void gen_aa32_st_internal_i64(DisasContext *s, TCGv_i64 val, | 24 | /* |
47 | + TCGv_i32 a32, int index, MemOp opc) | 25 | * 64-bit feature tests via id registers. |
26 | */ | ||
27 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) | ||
28 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; | ||
29 | } | ||
30 | |||
31 | +static inline bool isar_feature_aa64_debugv8p2(const ARMISARegisters *id) | ||
48 | +{ | 32 | +{ |
49 | + TCGv addr = gen_aa32_addr(s, a32, opc); | 33 | + return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, DEBUGVER) >= 8; |
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 | +} | 34 | +} |
62 | + | 35 | + |
63 | static void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 36 | static inline bool isar_feature_aa64_sve2(const ARMISARegisters *id) |
64 | int index, MemOp opc) | ||
65 | { | 37 | { |
66 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | 38 | return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SVEVER) != 0; |
67 | gen_aa32_st_internal_i32(s, val, a32, index, finalize_memop(s, opc)); | 39 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_tts2uxn(const ARMISARegisters *id) |
40 | return isar_feature_aa64_tts2uxn(id) || isar_feature_aa32_tts2uxn(id); | ||
68 | } | 41 | } |
69 | 42 | ||
70 | +static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | 43 | +static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id) |
71 | + int index, MemOp opc) | ||
72 | +{ | 44 | +{ |
73 | + gen_aa32_ld_internal_i64(s, val, a32, index, finalize_memop(s, opc)); | 45 | + return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id); |
74 | +} | 46 | +} |
75 | + | 47 | + |
76 | +static void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | 48 | /* |
77 | + int index, MemOp opc) | 49 | * Forward to the above feature tests given an ARMCPU pointer. |
78 | +{ | 50 | */ |
79 | + gen_aa32_st_internal_i64(s, val, a32, index, finalize_memop(s, opc)); | ||
80 | +} | ||
81 | + | ||
82 | #define DO_GEN_LD(SUFF, OPC) \ | ||
83 | static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val, \ | ||
84 | TCGv_i32 a32, int index) \ | ||
85 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
86 | gen_aa32_st_i32(s, val, a32, index, OPC); \ | ||
87 | } | ||
88 | |||
89 | -static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
90 | - int index, MemOp opc) | ||
91 | -{ | ||
92 | - TCGv addr = gen_aa32_addr(s, a32, opc); | ||
93 | - tcg_gen_qemu_ld_i64(val, addr, index, opc); | ||
94 | - | ||
95 | - /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
96 | - if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | ||
97 | - tcg_gen_rotri_i64(val, val, 32); | ||
98 | - } | ||
99 | - | ||
100 | - tcg_temp_free(addr); | ||
101 | -} | ||
102 | - | ||
103 | static inline void gen_aa32_ld64(DisasContext *s, TCGv_i64 val, | ||
104 | TCGv_i32 a32, int index) | ||
105 | { | ||
106 | - gen_aa32_ld_i64(s, val, a32, index, MO_Q | s->be_data); | ||
107 | -} | ||
108 | - | ||
109 | -static void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
110 | - int index, MemOp opc) | ||
111 | -{ | ||
112 | - TCGv addr = gen_aa32_addr(s, a32, opc); | ||
113 | - | ||
114 | - /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
115 | - if (!IS_USER_ONLY && s->sctlr_b && (opc & MO_SIZE) == MO_64) { | ||
116 | - TCGv_i64 tmp = tcg_temp_new_i64(); | ||
117 | - tcg_gen_rotri_i64(tmp, val, 32); | ||
118 | - tcg_gen_qemu_st_i64(tmp, addr, index, opc); | ||
119 | - tcg_temp_free_i64(tmp); | ||
120 | - } else { | ||
121 | - tcg_gen_qemu_st_i64(val, addr, index, opc); | ||
122 | - } | ||
123 | - tcg_temp_free(addr); | ||
124 | + gen_aa32_ld_i64(s, val, a32, index, MO_Q); | ||
125 | } | ||
126 | |||
127 | static inline void gen_aa32_st64(DisasContext *s, TCGv_i64 val, | ||
128 | TCGv_i32 a32, int index) | ||
129 | { | ||
130 | - gen_aa32_st_i64(s, val, a32, index, MO_Q | s->be_data); | ||
131 | + gen_aa32_st_i64(s, val, a32, index, MO_Q); | ||
132 | } | ||
133 | |||
134 | DO_GEN_LD(8u, MO_UB) | ||
135 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | ||
136 | index XXXXXXX..XXXXXXX 100644 | ||
137 | --- a/target/arm/translate-neon.c.inc | ||
138 | +++ b/target/arm/translate-neon.c.inc | ||
139 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | ||
140 | int tt = a->vd + reg + spacing * xs; | ||
141 | |||
142 | if (a->l) { | ||
143 | - gen_aa32_ld_i64(s, tmp64, addr, mmu_idx, endian | size); | ||
144 | + gen_aa32_ld_internal_i64(s, tmp64, addr, mmu_idx, | ||
145 | + endian | size); | ||
146 | neon_store_element64(tt, n, size, tmp64); | ||
147 | } else { | ||
148 | neon_load_element64(tmp64, tt, n, size); | ||
149 | - gen_aa32_st_i64(s, tmp64, addr, mmu_idx, endian | size); | ||
150 | + gen_aa32_st_internal_i64(s, tmp64, addr, mmu_idx, | ||
151 | + endian | size); | ||
152 | } | ||
153 | tcg_gen_add_i32(addr, addr, tmp); | ||
154 | } | ||
155 | -- | 51 | -- |
156 | 2.20.1 | 52 | 2.25.1 |
157 | |||
158 | 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 these bits have been moved out of tb->flags, | 3 | Add the aa64 predicate for detecting RAS support from id registers. |
4 | where TBFLAG_ANY was filling from the top, move AM32 | 4 | We already have the aa32 version from the M-profile work. |
5 | to fill from the top, and A32 and M32 to fill from the | 5 | Add the 'any' predicate for testing both aa64 and aa32. |
6 | bottom. This means fewer changes when adding new bits. | ||
7 | 6 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20210419202257.161730-9-richard.henderson@linaro.org | 9 | Message-id: 20220501055028.646596-34-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 | 42 +++++++++++++++++++++--------------------- | 12 | target/arm/cpu.h | 10 ++++++++++ |
14 | 1 file changed, 21 insertions(+), 21 deletions(-) | 13 | 1 file changed, 10 insertions(+) |
15 | 14 | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/cpu.h |
19 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/cpu.h |
20 | @@ -XXX,XX +XXX,XX @@ typedef ARMCPU ArchCPU; | 19 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_aa32_el1(const ARMISARegisters *id) |
21 | * | 20 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL1) >= 2; |
22 | * The bits for 32-bit A-profile and M-profile partially overlap: | 21 | } |
23 | * | 22 | |
24 | - * 18 9 0 | 23 | +static inline bool isar_feature_aa64_ras(const ARMISARegisters *id) |
25 | - * +----------------+--------------+ | 24 | +{ |
26 | - * | TBFLAG_A32 | | | 25 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) != 0; |
27 | - * +-----+----------+ TBFLAG_AM32 | | 26 | +} |
28 | - * | |TBFLAG_M32| | | 27 | + |
29 | - * +-----+----------+--------------+ | 28 | static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) |
30 | - * 14 9 0 | 29 | { |
31 | + * 31 23 11 10 0 | 30 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; |
32 | + * +-------------+----------+----------------+ | 31 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id) |
33 | + * | | | TBFLAG_A32 | | 32 | return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id); |
34 | + * | TBFLAG_AM32 | +-----+----------+ | 33 | } |
35 | + * | | |TBFLAG_M32| | 34 | |
36 | + * +-------------+----------------+----------+ | 35 | +static inline bool isar_feature_any_ras(const ARMISARegisters *id) |
37 | + * 31 23 5 4 0 | 36 | +{ |
38 | * | 37 | + return isar_feature_aa64_ras(id) || isar_feature_aa32_ras(id); |
39 | * Unless otherwise noted, these bits are cached in env->hflags. | 38 | +} |
39 | + | ||
40 | /* | ||
41 | * Forward to the above feature tests given an ARMCPU pointer. | ||
40 | */ | 42 | */ |
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 | -- | 43 | -- |
101 | 2.20.1 | 44 | 2.25.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 | This is the only caller. Adjust some commentary to talk | ||
4 | about SCTLR_B instead of the vanishing function. | ||
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-13-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/translate.c | 37 ++++++++++++++++--------------------- | ||
12 | 1 file changed, 16 insertions(+), 21 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate.c | ||
17 | +++ b/target/arm/translate.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
19 | gen_aa32_st_i32(s, val, a32, index, OPC); \ | ||
20 | } | ||
21 | |||
22 | -static inline void gen_aa32_frob64(DisasContext *s, TCGv_i64 val) | ||
23 | -{ | ||
24 | - /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
25 | - if (!IS_USER_ONLY && s->sctlr_b) { | ||
26 | - tcg_gen_rotri_i64(val, val, 32); | ||
27 | - } | ||
28 | -} | ||
29 | - | ||
30 | static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
31 | int index, MemOp opc) | ||
32 | { | ||
33 | TCGv addr = gen_aa32_addr(s, a32, opc); | ||
34 | tcg_gen_qemu_ld_i64(val, addr, index, opc); | ||
35 | - gen_aa32_frob64(s, val); | ||
36 | + | ||
37 | + /* Not needed for user-mode BE32, where we use MO_BE instead. */ | ||
38 | + if (!IS_USER_ONLY && s->sctlr_b) { | ||
39 | + tcg_gen_rotri_i64(val, val, 32); | ||
40 | + } | ||
41 | + | ||
42 | tcg_temp_free(addr); | ||
43 | } | ||
44 | |||
45 | @@ -XXX,XX +XXX,XX @@ static void gen_load_exclusive(DisasContext *s, int rt, int rt2, | ||
46 | TCGv_i32 tmp2 = tcg_temp_new_i32(); | ||
47 | TCGv_i64 t64 = tcg_temp_new_i64(); | ||
48 | |||
49 | - /* For AArch32, architecturally the 32-bit word at the lowest | ||
50 | + /* | ||
51 | + * For AArch32, architecturally the 32-bit word at the lowest | ||
52 | * address is always Rt and the one at addr+4 is Rt2, even if | ||
53 | * the CPU is big-endian. That means we don't want to do a | ||
54 | - * gen_aa32_ld_i64(), which invokes gen_aa32_frob64() as if | ||
55 | - * for an architecturally 64-bit access, but instead do a | ||
56 | - * 64-bit access using MO_BE if appropriate and then split | ||
57 | - * the two halves. | ||
58 | - * This only makes a difference for BE32 user-mode, where | ||
59 | - * frob64() must not flip the two halves of the 64-bit data | ||
60 | - * but this code must treat BE32 user-mode like BE32 system. | ||
61 | + * gen_aa32_ld_i64(), which checks SCTLR_B as if for an | ||
62 | + * architecturally 64-bit access, but instead do a 64-bit access | ||
63 | + * using MO_BE if appropriate and then split the two halves. | ||
64 | */ | ||
65 | TCGv taddr = gen_aa32_addr(s, addr, opc); | ||
66 | |||
67 | @@ -XXX,XX +XXX,XX @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2, | ||
68 | TCGv_i64 n64 = tcg_temp_new_i64(); | ||
69 | |||
70 | t2 = load_reg(s, rt2); | ||
71 | - /* For AArch32, architecturally the 32-bit word at the lowest | ||
72 | + | ||
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 | -- | ||
88 | 2.20.1 | ||
89 | |||
90 | 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-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 |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Alex Zuepke <alex.zuepke@tum.de> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | The ARMv8 manual defines that PMUSERENR_EL0.ER enables read-access |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | to both PMXEVCNTR_EL0 and PMEVCNTR<n>_EL0 registers, however, |
5 | Message-id: 20210419202257.161730-20-richard.henderson@linaro.org | 5 | we only use it for PMXEVCNTR_EL0. Extend to PMEVCNTR<n>_EL0 as well. |
6 | |||
7 | Signed-off-by: Alex Zuepke <alex.zuepke@tum.de> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220428132717.84190-1-alex.zuepke@tum.de | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | target/arm/translate.c | 4 ++-- | 12 | target/arm/helper.c | 4 ++-- |
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
10 | 14 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 17 | --- a/target/arm/helper.c |
14 | +++ b/target/arm/translate.c | 18 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | 19 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) |
16 | } | 20 | .crm = 8 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, |
17 | tcg_gen_addi_i32(addr, addr, offset); | 21 | .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, |
18 | tmp = load_reg(s, 14); | 22 | .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, |
19 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | 23 | - .accessfn = pmreg_access }, |
20 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | 24 | + .accessfn = pmreg_access_xevcntr }, |
21 | tcg_temp_free_i32(tmp); | 25 | { .name = pmevcntr_el0_name, .state = ARM_CP_STATE_AA64, |
22 | tmp = load_cpu_field(spsr); | 26 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 8 | (3 & (i >> 3)), |
23 | tcg_gen_addi_i32(addr, addr, 4); | 27 | - .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access, |
24 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | 28 | + .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access_xevcntr, |
25 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | 29 | .type = ARM_CP_IO, |
26 | tcg_temp_free_i32(tmp); | 30 | .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, |
27 | if (writeback) { | 31 | .raw_readfn = pmevcntr_rawread, |
28 | switch (amode) { | ||
29 | -- | 32 | -- |
30 | 2.20.1 | 33 | 2.25.1 |
31 | |||
32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210419202257.161730-21-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate-vfp.c.inc | 8 ++++---- | ||
9 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate-vfp.c.inc | ||
14 | +++ b/target/arm/translate-vfp.c.inc | ||
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) | ||
16 | for (i = 0; i < n; i++) { | ||
17 | if (a->l) { | ||
18 | /* load */ | ||
19 | - gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
20 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
21 | vfp_store_reg32(tmp, a->vd + i); | ||
22 | } else { | ||
23 | /* store */ | ||
24 | vfp_load_reg32(tmp, a->vd + i); | ||
25 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
26 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
27 | } | ||
28 | tcg_gen_addi_i32(addr, addr, offset); | ||
29 | } | ||
30 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) | ||
31 | for (i = 0; i < n; i++) { | ||
32 | if (a->l) { | ||
33 | /* load */ | ||
34 | - gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); | ||
35 | + gen_aa32_ld_i64(s, tmp, addr, get_mem_index(s), MO_Q | MO_ALIGN_4); | ||
36 | vfp_store_reg64(tmp, a->vd + i); | ||
37 | } else { | ||
38 | /* store */ | ||
39 | vfp_load_reg64(tmp, a->vd + i); | ||
40 | - gen_aa32_st64(s, tmp, addr, get_mem_index(s)); | ||
41 | + gen_aa32_st_i64(s, tmp, addr, get_mem_index(s), MO_Q | MO_ALIGN_4); | ||
42 | } | ||
43 | tcg_gen_addi_i32(addr, addr, offset); | ||
44 | } | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210419202257.161730-22-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate-vfp.c.inc | 12 ++++++------ | ||
9 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate-vfp.c.inc | ||
14 | +++ b/target/arm/translate-vfp.c.inc | ||
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_hp(DisasContext *s, arg_VLDR_VSTR_sp *a) | ||
16 | addr = add_reg_for_lit(s, a->rn, offset); | ||
17 | tmp = tcg_temp_new_i32(); | ||
18 | if (a->l) { | ||
19 | - gen_aa32_ld16u(s, tmp, addr, get_mem_index(s)); | ||
20 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), MO_UW | MO_ALIGN); | ||
21 | vfp_store_reg32(tmp, a->vd); | ||
22 | } else { | ||
23 | vfp_load_reg32(tmp, a->vd); | ||
24 | - gen_aa32_st16(s, tmp, addr, get_mem_index(s)); | ||
25 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UW | MO_ALIGN); | ||
26 | } | ||
27 | tcg_temp_free_i32(tmp); | ||
28 | tcg_temp_free_i32(addr); | ||
29 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) | ||
30 | addr = add_reg_for_lit(s, a->rn, offset); | ||
31 | tmp = tcg_temp_new_i32(); | ||
32 | if (a->l) { | ||
33 | - gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
34 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
35 | vfp_store_reg32(tmp, a->vd); | ||
36 | } else { | ||
37 | vfp_load_reg32(tmp, a->vd); | ||
38 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
39 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), MO_UL | MO_ALIGN); | ||
40 | } | ||
41 | tcg_temp_free_i32(tmp); | ||
42 | tcg_temp_free_i32(addr); | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a) | ||
44 | addr = add_reg_for_lit(s, a->rn, offset); | ||
45 | tmp = tcg_temp_new_i64(); | ||
46 | if (a->l) { | ||
47 | - gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); | ||
48 | + gen_aa32_ld_i64(s, tmp, addr, get_mem_index(s), MO_Q | MO_ALIGN_4); | ||
49 | vfp_store_reg64(tmp, a->vd); | ||
50 | } else { | ||
51 | vfp_load_reg64(tmp, a->vd); | ||
52 | - gen_aa32_st64(s, tmp, addr, get_mem_index(s)); | ||
53 | + gen_aa32_st_i64(s, tmp, addr, get_mem_index(s), MO_Q | MO_ALIGN_4); | ||
54 | } | ||
55 | tcg_temp_free_i64(tmp); | ||
56 | tcg_temp_free_i32(addr); | ||
57 | -- | ||
58 | 2.20.1 | ||
59 | |||
60 | diff view generated by jsdifflib |
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-29-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate-a64.c | 20 ++++++++++---------- | ||
9 | 1 file changed, 10 insertions(+), 10 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate-a64.c | ||
14 | +++ b/target/arm/translate-a64.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src, | ||
16 | |||
17 | /* Store from vector register to memory */ | ||
18 | static void do_vec_st(DisasContext *s, int srcidx, int element, | ||
19 | - TCGv_i64 tcg_addr, int size, MemOp endian) | ||
20 | + TCGv_i64 tcg_addr, MemOp mop) | ||
21 | { | ||
22 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | ||
23 | |||
24 | - read_vec_element(s, tcg_tmp, srcidx, element, size); | ||
25 | - tcg_gen_qemu_st_i64(tcg_tmp, tcg_addr, get_mem_index(s), endian | size); | ||
26 | + read_vec_element(s, tcg_tmp, srcidx, element, mop & MO_SIZE); | ||
27 | + tcg_gen_qemu_st_i64(tcg_tmp, tcg_addr, get_mem_index(s), mop); | ||
28 | |||
29 | tcg_temp_free_i64(tcg_tmp); | ||
30 | } | ||
31 | |||
32 | /* Load from memory to vector register */ | ||
33 | static void do_vec_ld(DisasContext *s, int destidx, int element, | ||
34 | - TCGv_i64 tcg_addr, int size, MemOp endian) | ||
35 | + TCGv_i64 tcg_addr, MemOp mop) | ||
36 | { | ||
37 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | ||
38 | |||
39 | - tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, get_mem_index(s), endian | size); | ||
40 | - write_vec_element(s, tcg_tmp, destidx, element, size); | ||
41 | + tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, get_mem_index(s), mop); | ||
42 | + write_vec_element(s, tcg_tmp, destidx, element, mop & MO_SIZE); | ||
43 | |||
44 | tcg_temp_free_i64(tcg_tmp); | ||
45 | } | ||
46 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
47 | for (xs = 0; xs < selem; xs++) { | ||
48 | int tt = (rt + r + xs) % 32; | ||
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 | -- | ||
71 | 2.20.1 | ||
72 | |||
73 | 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-31-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/translate-a64.c | 9 +++++---- | ||
9 | 1 file changed, 5 insertions(+), 4 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/translate-a64.c | ||
14 | +++ b/target/arm/translate-a64.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
16 | int index = is_q << 3 | S << 2 | size; | ||
17 | int xs, total; | ||
18 | TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; | ||
19 | + MemOp mop; | ||
20 | |||
21 | if (extract32(insn, 31, 1)) { | ||
22 | unallocated_encoding(s); | ||
23 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
24 | |||
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 | -- | ||
54 | 2.20.1 | ||
55 | |||
56 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cornelia Huck <cohuck@redhat.com> | ||
2 | 1 | ||
3 | Add 6.1 machine types for arm/i440fx/q35/s390x/spapr. | ||
4 | |||
5 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> | ||
6 | Acked-by: Greg Kurz <groug@kaod.org> | ||
7 | Message-id: 20210331111900.118274-1-cohuck@redhat.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/boards.h | 3 +++ | ||
12 | include/hw/i386/pc.h | 3 +++ | ||
13 | hw/arm/virt.c | 7 ++++++- | ||
14 | hw/core/machine.c | 3 +++ | ||
15 | hw/i386/pc.c | 3 +++ | ||
16 | hw/i386/pc_piix.c | 14 +++++++++++++- | ||
17 | hw/i386/pc_q35.c | 13 ++++++++++++- | ||
18 | hw/ppc/spapr.c | 17 ++++++++++++++--- | ||
19 | hw/s390x/s390-virtio-ccw.c | 14 +++++++++++++- | ||
20 | 9 files changed, 70 insertions(+), 7 deletions(-) | ||
21 | |||
22 | diff --git a/include/hw/boards.h b/include/hw/boards.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/include/hw/boards.h | ||
25 | +++ b/include/hw/boards.h | ||
26 | @@ -XXX,XX +XXX,XX @@ struct MachineState { | ||
27 | } \ | ||
28 | type_init(machine_initfn##_register_types) | ||
29 | |||
30 | +extern GlobalProperty hw_compat_6_0[]; | ||
31 | +extern const size_t hw_compat_6_0_len; | ||
32 | + | ||
33 | extern GlobalProperty hw_compat_5_2[]; | ||
34 | extern const size_t hw_compat_5_2_len; | ||
35 | |||
36 | diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/include/hw/i386/pc.h | ||
39 | +++ b/include/hw/i386/pc.h | ||
40 | @@ -XXX,XX +XXX,XX @@ bool pc_system_ovmf_table_find(const char *entry, uint8_t **data, | ||
41 | void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, | ||
42 | const CPUArchIdList *apic_ids, GArray *entry); | ||
43 | |||
44 | +extern GlobalProperty pc_compat_6_0[]; | ||
45 | +extern const size_t pc_compat_6_0_len; | ||
46 | + | ||
47 | extern GlobalProperty pc_compat_5_2[]; | ||
48 | extern const size_t pc_compat_5_2_len; | ||
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 | -- | ||
228 | 2.20.1 | ||
229 | |||
230 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Currently the gpex PCI controller implements no special behaviour for | ||
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 | 1 | ||
6 | Most host OSes expect "like an x86 PC" behaviour, where bad accesses | ||
7 | like this return -1 for reads and ignore writes. In the interests of | ||
8 | not being surprising, make host CPU accesses to these windows behave | ||
9 | as -1/discard where there's no mapped PCI device. | ||
10 | |||
11 | The old behaviour generally didn't cause any problems, because | ||
12 | almost always the guest OS will map the PCI devices and then only | ||
13 | access where it has mapped them. One corner case where you will see | ||
14 | this kind of access is if Linux attempts to probe legacy ISA | ||
15 | devices via a PIO window access. So far the only case where we've | ||
16 | seen this has been via the syzkaller fuzzer. | ||
17 | |||
18 | Reported-by: Dmitry Vyukov <dvyukov@google.com> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
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> | ||
25 | --- | ||
26 | include/hw/pci-host/gpex.h | 4 +++ | ||
27 | hw/core/machine.c | 4 ++- | ||
28 | hw/pci-host/gpex.c | 56 ++++++++++++++++++++++++++++++++++++-- | ||
29 | 3 files changed, 60 insertions(+), 4 deletions(-) | ||
30 | |||
31 | diff --git a/include/hw/pci-host/gpex.h b/include/hw/pci-host/gpex.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/include/hw/pci-host/gpex.h | ||
34 | +++ b/include/hw/pci-host/gpex.h | ||
35 | @@ -XXX,XX +XXX,XX @@ struct GPEXHost { | ||
36 | |||
37 | MemoryRegion io_ioport; | ||
38 | MemoryRegion io_mmio; | ||
39 | + MemoryRegion io_ioport_window; | ||
40 | + MemoryRegion io_mmio_window; | ||
41 | qemu_irq irq[GPEX_NUM_IRQS]; | ||
42 | int irq_num[GPEX_NUM_IRQS]; | ||
43 | + | ||
44 | + bool allow_unmapped_accesses; | ||
45 | }; | ||
46 | |||
47 | struct GPEXConfig { | ||
48 | diff --git a/hw/core/machine.c b/hw/core/machine.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/hw/core/machine.c | ||
51 | +++ b/hw/core/machine.c | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | #include "hw/virtio/virtio.h" | ||
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; | ||
69 | |||
70 | pcie_host_mmcfg_init(pex, PCIE_MMCFG_SIZE_MAX); | ||
71 | + sysbus_init_mmio(sbd, &pex->mmio); | ||
72 | + | ||
73 | + /* | ||
74 | + * Note that the MemoryRegions io_mmio and io_ioport that we pass | ||
75 | + * to pci_register_root_bus() are not the same as the | ||
76 | + * MemoryRegions io_mmio_window and io_ioport_window that we | ||
77 | + * expose as SysBus MRs. The difference is in the behaviour of | ||
78 | + * accesses to addresses where no PCI device has been mapped. | ||
79 | + * | ||
80 | + * io_mmio and io_ioport are the underlying PCI view of the PCI | ||
81 | + * address space, and when a PCI device does a bus master access | ||
82 | + * to a bad address this is reported back to it as a transaction | ||
83 | + * failure. | ||
84 | + * | ||
85 | + * io_mmio_window and io_ioport_window implement "unmapped | ||
86 | + * addresses read as -1 and ignore writes"; this is traditional | ||
87 | + * x86 PC behaviour, which is not mandated by the PCI spec proper | ||
88 | + * but expected by much PCI-using guest software, including Linux. | ||
89 | + * | ||
90 | + * In the interests of not being unnecessarily surprising, we | ||
91 | + * implement it in the gpex PCI host controller, by providing the | ||
92 | + * _window MRs, which are containers with io ops that implement | ||
93 | + * the 'background' behaviour and which hold the real PCI MRs as | ||
94 | + * subregions. | ||
95 | + */ | ||
96 | memory_region_init(&s->io_mmio, OBJECT(s), "gpex_mmio", UINT64_MAX); | ||
97 | memory_region_init(&s->io_ioport, OBJECT(s), "gpex_ioport", 64 * 1024); | ||
98 | |||
99 | - sysbus_init_mmio(sbd, &pex->mmio); | ||
100 | - sysbus_init_mmio(sbd, &s->io_mmio); | ||
101 | - sysbus_init_mmio(sbd, &s->io_ioport); | ||
102 | + if (s->allow_unmapped_accesses) { | ||
103 | + memory_region_init_io(&s->io_mmio_window, OBJECT(s), | ||
104 | + &unassigned_io_ops, OBJECT(s), | ||
105 | + "gpex_mmio_window", UINT64_MAX); | ||
106 | + memory_region_init_io(&s->io_ioport_window, OBJECT(s), | ||
107 | + &unassigned_io_ops, OBJECT(s), | ||
108 | + "gpex_ioport_window", 64 * 1024); | ||
109 | + | ||
110 | + memory_region_add_subregion(&s->io_mmio_window, 0, &s->io_mmio); | ||
111 | + memory_region_add_subregion(&s->io_ioport_window, 0, &s->io_ioport); | ||
112 | + sysbus_init_mmio(sbd, &s->io_mmio_window); | ||
113 | + sysbus_init_mmio(sbd, &s->io_ioport_window); | ||
114 | + } else { | ||
115 | + sysbus_init_mmio(sbd, &s->io_mmio); | ||
116 | + sysbus_init_mmio(sbd, &s->io_ioport); | ||
117 | + } | ||
118 | + | ||
119 | for (i = 0; i < GPEX_NUM_IRQS; i++) { | ||
120 | sysbus_init_irq(sbd, &s->irq[i]); | ||
121 | s->irq_num[i] = -1; | ||
122 | @@ -XXX,XX +XXX,XX @@ static const char *gpex_host_root_bus_path(PCIHostState *host_bridge, | ||
123 | return "0000:00"; | ||
124 | } | ||
125 | |||
126 | +static Property gpex_host_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 | -- | ||
148 | 2.20.1 | ||
149 | |||
150 | diff view generated by jsdifflib |