1 | target-arm queue: the big stuff here is the final part of | 1 | The following changes since commit 6d940eff4734bcb40b1a25f62d7cec5a396f994a: |
---|---|---|---|
2 | rth's patches for Cortex-A76 and Neoverse-N1 support; | ||
3 | also present are Gavin's NUMA series and a few other things. | ||
4 | 2 | ||
5 | thanks | 3 | Merge tag 'pull-tpm-2022-06-07-1' of https://github.com/stefanberger/qemu-tpm into staging (2022-06-07 19:22:18 -0700) |
6 | -- PMM | ||
7 | |||
8 | The following changes since commit 554623226f800acf48a2ed568900c1c968ec9a8b: | ||
9 | |||
10 | Merge tag 'qemu-sparc-20220508' of https://github.com/mcayland/qemu into staging (2022-05-08 17:03:26 -0500) | ||
11 | 4 | ||
12 | are available in the Git repository at: | 5 | are available in the Git repository at: |
13 | 6 | ||
14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220509 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220609 |
15 | 8 | ||
16 | for you to fetch changes up to ae9141d4a3265553503bf07d3574b40f84615a34: | 9 | for you to fetch changes up to 414c54d515dba16bfaef643a8acec200c05f229a: |
17 | 10 | ||
18 | hw/acpi/aml-build: Use existing CPU topology to build PPTT table (2022-05-09 11:47:55 +0100) | 11 | target/arm: Add ID_AA64SMFR0_EL1 (2022-06-08 19:38:59 +0100) |
19 | 12 | ||
20 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
21 | target-arm queue: | 14 | target-arm queue: |
22 | * MAINTAINERS/.mailmap: update email for Leif Lindholm | 15 | * target/arm: Declare support for FEAT_RASv1p1 |
23 | * hw/arm: add version information to sbsa-ref machine DT | 16 | * target/arm: Implement FEAT_DoubleFault |
24 | * Enable new features for -cpu max: | 17 | * Fix 'writeable' typos |
25 | FEAT_Debugv8p2, FEAT_Debugv8p4, FEAT_RAS (minimal version only), | 18 | * xlnx_dp: Implement vblank interrupt |
26 | FEAT_IESB, FEAT_CSV2, FEAT_CSV2_2, FEAT_CSV3, FEAT_DGH | 19 | * target/arm: Move page-table-walk code to ptw.c |
27 | * Emulate Cortex-A76 | 20 | * target/arm: Preparatory patches for SME support |
28 | * Emulate Neoverse-N1 | ||
29 | * Fix the virt board default NUMA topology | ||
30 | 21 | ||
31 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
32 | Gavin Shan (6): | 23 | Frederic Konrad (2): |
33 | qapi/machine.json: Add cluster-id | 24 | xlnx_dp: fix the wrong register size |
34 | qtest/numa-test: Specify CPU topology in aarch64_numa_cpu() | 25 | xlnx-zynqmp: fix the irq mapping for the display port and its dma |
35 | hw/arm/virt: Consider SMP configuration in CPU topology | ||
36 | qtest/numa-test: Correct CPU and NUMA association in aarch64_numa_cpu() | ||
37 | hw/arm/virt: Fix CPU's default NUMA node ID | ||
38 | hw/acpi/aml-build: Use existing CPU topology to build PPTT table | ||
39 | 26 | ||
40 | Leif Lindholm (2): | 27 | Peter Maydell (3): |
41 | MAINTAINERS/.mailmap: update email for Leif Lindholm | 28 | target/arm: Declare support for FEAT_RASv1p1 |
42 | hw/arm: add versioning to sbsa-ref machine DT | 29 | target/arm: Implement FEAT_DoubleFault |
30 | Fix 'writeable' typos | ||
43 | 31 | ||
44 | Richard Henderson (24): | 32 | Richard Henderson (48): |
45 | target/arm: Handle cpreg registration for missing EL | 33 | target/arm: Move stage_1_mmu_idx decl to internals.h |
46 | target/arm: Drop EL3 no EL2 fallbacks | 34 | target/arm: Move get_phys_addr to ptw.c |
47 | target/arm: Merge zcr reginfo | 35 | target/arm: Move get_phys_addr_v5 to ptw.c |
48 | target/arm: Adjust definition of CONTEXTIDR_EL2 | 36 | target/arm: Move get_phys_addr_v6 to ptw.c |
49 | target/arm: Move cortex impdef sysregs to cpu_tcg.c | 37 | target/arm: Move get_phys_addr_pmsav5 to ptw.c |
50 | target/arm: Update qemu-system-arm -cpu max to cortex-a57 | 38 | target/arm: Move get_phys_addr_pmsav7_default to ptw.c |
51 | target/arm: Set ID_DFR0.PerfMon for qemu-system-arm -cpu max | 39 | target/arm: Move get_phys_addr_pmsav7 to ptw.c |
52 | target/arm: Split out aa32_max_features | 40 | target/arm: Move get_phys_addr_pmsav8 to ptw.c |
53 | target/arm: Annotate arm_max_initfn with FEAT identifiers | 41 | target/arm: Move pmsav8_mpu_lookup to ptw.c |
54 | target/arm: Use field names for manipulating EL2 and EL3 modes | 42 | target/arm: Move pmsav7_use_background_region to ptw.c |
55 | target/arm: Enable FEAT_Debugv8p2 for -cpu max | 43 | target/arm: Move v8m_security_lookup to ptw.c |
56 | target/arm: Enable FEAT_Debugv8p4 for -cpu max | 44 | target/arm: Move m_is_{ppb,system}_region to ptw.c |
57 | target/arm: Add minimal RAS registers | 45 | target/arm: Move get_level1_table_address to ptw.c |
58 | target/arm: Enable SCR and HCR bits for RAS | 46 | target/arm: Move combine_cacheattrs and subroutines to ptw.c |
59 | target/arm: Implement virtual SError exceptions | 47 | target/arm: Move get_phys_addr_lpae to ptw.c |
60 | target/arm: Implement ESB instruction | 48 | target/arm: Move arm_{ldl,ldq}_ptw to ptw.c |
61 | target/arm: Enable FEAT_RAS for -cpu max | 49 | target/arm: Move {arm_s1_, }regime_using_lpae_format to tlb_helper.c |
62 | target/arm: Enable FEAT_IESB for -cpu max | 50 | target/arm: Move arm_pamax, pamax_map into ptw.c |
63 | target/arm: Enable FEAT_CSV2 for -cpu max | 51 | target/arm: Move get_S1prot, get_S2prot to ptw.c |
64 | target/arm: Enable FEAT_CSV2_2 for -cpu max | 52 | target/arm: Move check_s2_mmu_setup to ptw.c |
65 | target/arm: Enable FEAT_CSV3 for -cpu max | 53 | target/arm: Move aa32_va_parameters to ptw.c |
66 | target/arm: Enable FEAT_DGH for -cpu max | 54 | target/arm: Move ap_to_tw_prot etc to ptw.c |
67 | target/arm: Define cortex-a76 | 55 | target/arm: Move regime_is_user to ptw.c |
68 | target/arm: Define neoverse-n1 | 56 | target/arm: Move regime_ttbr to ptw.c |
57 | target/arm: Move regime_translation_disabled to ptw.c | ||
58 | target/arm: Move arm_cpu_get_phys_page_attrs_debug to ptw.c | ||
59 | target/arm: Move stage_1_mmu_idx, arm_stage1_mmu_idx to ptw.c | ||
60 | target/arm: Pass CPUARMState to arm_ld[lq]_ptw | ||
61 | target/arm: Rename TBFLAG_A64 ZCR_LEN to VL | ||
62 | linux-user/aarch64: Introduce sve_vq | ||
63 | target/arm: Remove route_to_el2 check from sve_exception_el | ||
64 | target/arm: Remove fp checks from sve_exception_el | ||
65 | target/arm: Add el_is_in_host | ||
66 | target/arm: Use el_is_in_host for sve_zcr_len_for_el | ||
67 | target/arm: Use el_is_in_host for sve_exception_el | ||
68 | target/arm: Hoist arm_is_el2_enabled check in sve_exception_el | ||
69 | target/arm: Do not use aarch64_sve_zcr_get_valid_len in reset | ||
70 | target/arm: Merge aarch64_sve_zcr_get_valid_len into caller | ||
71 | target/arm: Use uint32_t instead of bitmap for sve vq's | ||
72 | target/arm: Rename sve_zcr_len_for_el to sve_vqm1_for_el | ||
73 | target/arm: Split out load/store primitives to sve_ldst_internal.h | ||
74 | target/arm: Export sve contiguous ldst support functions | ||
75 | target/arm: Move expand_pred_b to vec_internal.h | ||
76 | target/arm: Use expand_pred_b in mve_helper.c | ||
77 | target/arm: Move expand_pred_h to vec_internal.h | ||
78 | target/arm: Export bfdotadd from vec_helper.c | ||
79 | target/arm: Add isar_feature_aa64_sme | ||
80 | target/arm: Add ID_AA64SMFR0_EL1 | ||
69 | 81 | ||
70 | docs/system/arm/emulation.rst | 10 + | 82 | Sai Pavan Boddu (2): |
71 | docs/system/arm/virt.rst | 2 + | 83 | xlnx_dp: Introduce a vblank signal |
72 | qapi/machine.json | 6 +- | 84 | xlnx_dp: Fix the interrupt disable logic |
73 | target/arm/cpregs.h | 11 + | 85 | |
74 | target/arm/cpu.h | 23 ++ | 86 | docs/interop/vhost-user.rst | 2 +- |
75 | target/arm/helper.h | 1 + | 87 | docs/specs/vmgenid.txt | 4 +- |
76 | target/arm/internals.h | 16 ++ | 88 | docs/system/arm/emulation.rst | 2 + |
77 | target/arm/syndrome.h | 5 + | 89 | hw/scsi/mfi.h | 2 +- |
78 | target/arm/a32.decode | 16 +- | 90 | include/hw/display/xlnx_dp.h | 12 +- |
79 | target/arm/t32.decode | 18 +- | 91 | linux-user/aarch64/target_prctl.h | 20 +- |
80 | hw/acpi/aml-build.c | 111 ++++---- | 92 | target/arm/cpu.h | 66 +- |
81 | hw/arm/sbsa-ref.c | 16 ++ | 93 | target/arm/internals.h | 45 +- |
82 | hw/arm/virt.c | 21 +- | 94 | target/arm/kvm_arm.h | 7 +- |
83 | hw/core/machine-hmp-cmds.c | 4 + | 95 | target/arm/sve_ldst_internal.h | 221 +++ |
84 | hw/core/machine.c | 16 ++ | 96 | target/arm/translate-a64.h | 2 +- |
85 | target/arm/cpu.c | 66 ++++- | 97 | target/arm/translate.h | 2 +- |
86 | target/arm/cpu64.c | 353 ++++++++++++++----------- | 98 | target/arm/vec_internal.h | 28 +- |
87 | target/arm/cpu_tcg.c | 227 +++++++++++----- | 99 | target/i386/hvf/vmcs.h | 2 +- |
88 | target/arm/helper.c | 600 +++++++++++++++++++++++++----------------- | 100 | target/i386/hvf/vmx.h | 2 +- |
89 | target/arm/op_helper.c | 43 +++ | 101 | accel/hvf/hvf-accel-ops.c | 4 +- |
90 | target/arm/translate-a64.c | 18 ++ | 102 | accel/kvm/kvm-all.c | 4 +- |
91 | target/arm/translate.c | 23 ++ | 103 | accel/tcg/user-exec.c | 6 +- |
92 | tests/qtest/numa-test.c | 19 +- | 104 | hw/acpi/ghes.c | 2 +- |
93 | .mailmap | 3 +- | 105 | hw/arm/xlnx-zynqmp.c | 4 +- |
94 | MAINTAINERS | 2 +- | 106 | hw/display/xlnx_dp.c | 49 +- |
95 | 25 files changed, 1068 insertions(+), 562 deletions(-) | 107 | hw/intc/arm_gicv3_cpuif.c | 2 +- |
108 | hw/intc/arm_gicv3_dist.c | 2 +- | ||
109 | hw/intc/arm_gicv3_redist.c | 4 +- | ||
110 | hw/intc/riscv_aclint.c | 2 +- | ||
111 | hw/intc/riscv_aplic.c | 2 +- | ||
112 | hw/pci/shpc.c | 2 +- | ||
113 | hw/sparc64/sun4u_iommu.c | 2 +- | ||
114 | hw/timer/sse-timer.c | 2 +- | ||
115 | linux-user/aarch64/signal.c | 4 +- | ||
116 | target/arm/arch_dump.c | 2 +- | ||
117 | target/arm/cpu.c | 5 +- | ||
118 | target/arm/cpu64.c | 120 +- | ||
119 | target/arm/gdbstub.c | 2 +- | ||
120 | target/arm/gdbstub64.c | 2 +- | ||
121 | target/arm/helper.c | 2742 ++----------------------------------- | ||
122 | target/arm/hvf/hvf.c | 4 +- | ||
123 | target/arm/kvm64.c | 47 +- | ||
124 | target/arm/mve_helper.c | 6 +- | ||
125 | target/arm/ptw.c | 2540 ++++++++++++++++++++++++++++++++++ | ||
126 | target/arm/sve_helper.c | 232 +--- | ||
127 | target/arm/tlb_helper.c | 26 + | ||
128 | target/arm/translate-a64.c | 2 +- | ||
129 | target/arm/translate-sve.c | 2 +- | ||
130 | target/arm/vec_helper.c | 28 +- | ||
131 | target/i386/cpu-sysemu.c | 2 +- | ||
132 | target/s390x/ioinst.c | 2 +- | ||
133 | python/qemu/machine/machine.py | 2 +- | ||
134 | target/arm/meson.build | 1 + | ||
135 | tests/tcg/x86_64/system/boot.S | 2 +- | ||
136 | 50 files changed, 3240 insertions(+), 3037 deletions(-) | ||
137 | create mode 100644 target/arm/sve_ldst_internal.h | ||
138 | create mode 100644 target/arm/ptw.c | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The architectural feature RASv1p1 introduces the following new |
---|---|---|---|
2 | features: | ||
3 | * new registers ERXPFGCDN_EL1, ERXPFGCTL_EL1 and ERXPFGF_EL1 | ||
4 | * new bits in the fine-grained trap registers that control traps | ||
5 | for these new registers | ||
6 | * new trap bits HCR_EL2.FIEN and SCR_EL3.FIEN that control traps | ||
7 | for ERXPFGCDN_EL1, ERXPFGCTL_EL1, ERXPFGP_EL1 | ||
8 | * a larger number of the ERXMISC<n>_EL1 registers | ||
9 | * the format of ERR<n>STATUS registers changes | ||
2 | 10 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | The architecture permits that if ERRIDR_EL1.NUM is 0 (as it is for |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | QEMU) then all these new registers may UNDEF, and the HCR_EL2.FIEN |
5 | Message-id: 20220506180242.216785-18-richard.henderson@linaro.org | 13 | and SCR_EL3.FIEN bits may be RES0. We don't have any ERR<n>STATUS |
14 | registers (again, because ERRIDR_EL1.NUM is 0). QEMU does not yet | ||
15 | implement the fine-grained-trap extension. So there is nothing we | ||
16 | need to implement to be compliant with the feature spec. Make the | ||
17 | 'max' CPU report the feature in its ID registers, and document it. | ||
18 | |||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20220531114258.855804-1-peter.maydell@linaro.org | ||
7 | --- | 22 | --- |
8 | docs/system/arm/emulation.rst | 1 + | 23 | docs/system/arm/emulation.rst | 1 + |
9 | target/arm/cpu64.c | 1 + | 24 | target/arm/cpu64.c | 1 + |
10 | target/arm/cpu_tcg.c | 1 + | 25 | 2 files changed, 2 insertions(+) |
11 | 3 files changed, 3 insertions(+) | ||
12 | 26 | ||
13 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 27 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
14 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/docs/system/arm/emulation.rst | 29 | --- a/docs/system/arm/emulation.rst |
16 | +++ b/docs/system/arm/emulation.rst | 30 | +++ b/docs/system/arm/emulation.rst |
17 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 31 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
18 | - FEAT_PMULL (PMULL, PMULL2 instructions) | ||
19 | - FEAT_PMUv3p1 (PMU Extensions v3.1) | 32 | - FEAT_PMUv3p1 (PMU Extensions v3.1) |
20 | - FEAT_PMUv3p4 (PMU Extensions v3.4) | 33 | - FEAT_PMUv3p4 (PMU Extensions v3.4) |
21 | +- FEAT_RAS (Reliability, availability, and serviceability) | 34 | - FEAT_RAS (Reliability, availability, and serviceability) |
35 | +- FEAT_RASv1p1 (RAS Extension v1.1) | ||
22 | - FEAT_RDM (Advanced SIMD rounding double multiply accumulate instructions) | 36 | - FEAT_RDM (Advanced SIMD rounding double multiply accumulate instructions) |
23 | - FEAT_RNG (Random number generator) | 37 | - FEAT_RNG (Random number generator) |
24 | - FEAT_SB (Speculation Barrier) | 38 | - FEAT_S2FWB (Stage 2 forced Write-Back) |
25 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 39 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
26 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/cpu64.c | 41 | --- a/target/arm/cpu64.c |
28 | +++ b/target/arm/cpu64.c | 42 | +++ b/target/arm/cpu64.c |
29 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 43 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
30 | t = cpu->isar.id_aa64pfr0; | 44 | * we do for EL2 with the virtualization=on property. |
31 | t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */ | 45 | */ |
32 | t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */ | 46 | t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ |
33 | + t = FIELD_DP64(t, ID_AA64PFR0, RAS, 1); /* FEAT_RAS */ | 47 | + t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 1); /* FEAT_RASv1p1 */ |
34 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | 48 | t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ |
35 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ | 49 | cpu->isar.id_aa64pfr1 = t; |
36 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ | 50 | |
37 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/cpu_tcg.c | ||
40 | +++ b/target/arm/cpu_tcg.c | ||
41 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
42 | |||
43 | t = cpu->isar.id_pfr0; | ||
44 | t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */ | ||
45 | + t = FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */ | ||
46 | cpu->isar.id_pfr0 = t; | ||
47 | |||
48 | t = cpu->isar.id_pfr2; | ||
49 | -- | 51 | -- |
50 | 2.25.1 | 52 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The FEAT_DoubleFault extension adds the following: |
---|---|---|---|
2 | 2 | ||
3 | There is no branch prediction in TCG, therefore there is no | 3 | * All external aborts on instruction fetches and translation table |
4 | need to actually include the context number into the predictor. | 4 | walks for instruction fetches must be synchronous. For QEMU this |
5 | Therefore all we need to do is add the state for SCXTNUM_ELx. | 5 | is already true. |
6 | 6 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | * SCR_EL3 has a new bit NMEA which disables the masking of SError |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | interrupts by PSTATE.A when the SError interrupt is taken to EL3. |
9 | Message-id: 20220506180242.216785-21-richard.henderson@linaro.org | 9 | For QEMU we only need to make the bit writable, because we have no |
10 | sources of SError interrupts. | ||
11 | |||
12 | * SCR_EL3 has a new bit EASE which causes synchronous external | ||
13 | aborts taken to EL3 to be taken at the same entry point as SError. | ||
14 | (Note that this does not mean that they are SErrors for purposes | ||
15 | of PSTATE.A masking or that the syndrome register reports them as | ||
16 | SErrors: it just means that the vector offset is different.) | ||
17 | |||
18 | * The existing SCTLR_EL3.IESB has an effective value of 1 when | ||
19 | SCR_EL3.NMEA is 1. For QEMU this is a no-op because we don't need | ||
20 | different behaviour based on IESB (we don't need to do anything to | ||
21 | ensure that error exceptions are synchronized). | ||
22 | |||
23 | So for QEMU the things we need to change are: | ||
24 | * Make SCR_EL3.{NMEA,EASE} writable | ||
25 | * When taking a synchronous external abort at EL3, adjust the | ||
26 | vector entry point if SCR_EL3.EASE is set | ||
27 | * Advertise the feature in the ID registers | ||
28 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
30 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
31 | Message-id: 20220531151431.949322-1-peter.maydell@linaro.org | ||
11 | --- | 32 | --- |
12 | docs/system/arm/emulation.rst | 3 ++ | 33 | docs/system/arm/emulation.rst | 1 + |
13 | target/arm/cpu.h | 16 +++++++++ | 34 | target/arm/cpu.h | 5 +++++ |
14 | target/arm/cpu.c | 5 +++ | 35 | target/arm/cpu64.c | 4 ++-- |
15 | target/arm/cpu64.c | 3 +- | 36 | target/arm/helper.c | 36 +++++++++++++++++++++++++++++++++++ |
16 | target/arm/helper.c | 61 ++++++++++++++++++++++++++++++++++- | 37 | 4 files changed, 44 insertions(+), 2 deletions(-) |
17 | 5 files changed, 86 insertions(+), 2 deletions(-) | ||
18 | 38 | ||
19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 39 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
20 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/docs/system/arm/emulation.rst | 41 | --- a/docs/system/arm/emulation.rst |
22 | +++ b/docs/system/arm/emulation.rst | 42 | +++ b/docs/system/arm/emulation.rst |
23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 43 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
24 | - FEAT_BF16 (AArch64 BFloat16 instructions) | ||
25 | - FEAT_BTI (Branch Target Identification) | ||
26 | - FEAT_CSV2 (Cache speculation variant 2) | ||
27 | +- FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) | ||
28 | +- FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) | ||
29 | +- FEAT_CSV2_2 (Cache speculation variant 2, version 2) | ||
30 | - FEAT_DIT (Data Independent Timing instructions) | ||
31 | - FEAT_DPB (DC CVAP instruction) | ||
32 | - FEAT_Debugv8p2 (Debug changes for v8.2) | 44 | - FEAT_Debugv8p2 (Debug changes for v8.2) |
45 | - FEAT_Debugv8p4 (Debug changes for v8.4) | ||
46 | - FEAT_DotProd (Advanced SIMD dot product instructions) | ||
47 | +- FEAT_DoubleFault (Double Fault Extension) | ||
48 | - FEAT_FCMA (Floating-point complex number instructions) | ||
49 | - FEAT_FHM (Floating-point half-precision multiplication instructions) | ||
50 | - FEAT_FP16 (Half-precision floating-point data processing) | ||
33 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 51 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
34 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/cpu.h | 53 | --- a/target/arm/cpu.h |
36 | +++ b/target/arm/cpu.h | 54 | +++ b/target/arm/cpu.h |
37 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | 55 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ras(const ARMISARegisters *id) |
38 | ARMPACKey apdb; | 56 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) != 0; |
39 | ARMPACKey apga; | ||
40 | } keys; | ||
41 | + | ||
42 | + uint64_t scxtnum_el[4]; | ||
43 | #endif | ||
44 | |||
45 | #if defined(CONFIG_USER_ONLY) | ||
46 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
47 | #define SCTLR_WXN (1U << 19) | ||
48 | #define SCTLR_ST (1U << 20) /* up to ??, RAZ in v6 */ | ||
49 | #define SCTLR_UWXN (1U << 20) /* v7 onward, AArch32 only */ | ||
50 | +#define SCTLR_TSCXT (1U << 20) /* FEAT_CSV2_1p2, AArch64 only */ | ||
51 | #define SCTLR_FI (1U << 21) /* up to v7, v8 RES0 */ | ||
52 | #define SCTLR_IESB (1U << 21) /* v8.2-IESB, AArch64 only */ | ||
53 | #define SCTLR_U (1U << 22) /* up to v6, RAO in v7 */ | ||
54 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) | ||
55 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0; | ||
56 | } | 57 | } |
57 | 58 | ||
58 | +static inline bool isar_feature_aa64_scxtnum(const ARMISARegisters *id) | 59 | +static inline bool isar_feature_aa64_doublefault(const ARMISARegisters *id) |
59 | +{ | 60 | +{ |
60 | + int key = FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, CSV2); | 61 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) >= 2; |
61 | + if (key >= 2) { | ||
62 | + return true; /* FEAT_CSV2_2 */ | ||
63 | + } | ||
64 | + if (key == 1) { | ||
65 | + key = FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, CSV2_FRAC); | ||
66 | + return key >= 2; /* FEAT_CSV2_1p2 */ | ||
67 | + } | ||
68 | + return false; | ||
69 | +} | 62 | +} |
70 | + | 63 | + |
71 | static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) | 64 | static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) |
72 | { | 65 | { |
73 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; | 66 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; |
74 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/target/arm/cpu.c | ||
77 | +++ b/target/arm/cpu.c | ||
78 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) | ||
79 | */ | ||
80 | env->cp15.gcr_el1 = 0x1ffff; | ||
81 | } | ||
82 | + /* | ||
83 | + * Disable access to SCXTNUM_EL0 from CSV2_1p2. | ||
84 | + * This is not yet exposed from the Linux kernel in any way. | ||
85 | + */ | ||
86 | + env->cp15.sctlr_el[1] |= SCTLR_TSCXT; | ||
87 | #else | ||
88 | /* Reset into the highest available EL */ | ||
89 | if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
90 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 67 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
91 | index XXXXXXX..XXXXXXX 100644 | 68 | index XXXXXXX..XXXXXXX 100644 |
92 | --- a/target/arm/cpu64.c | 69 | --- a/target/arm/cpu64.c |
93 | +++ b/target/arm/cpu64.c | 70 | +++ b/target/arm/cpu64.c |
94 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 71 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
72 | t = cpu->isar.id_aa64pfr0; | ||
73 | t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */ | ||
74 | t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */ | ||
75 | - t = FIELD_DP64(t, ID_AA64PFR0, RAS, 1); /* FEAT_RAS */ | ||
76 | + t = FIELD_DP64(t, ID_AA64PFR0, RAS, 2); /* FEAT_RASv1p1 + FEAT_DoubleFault */ | ||
95 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | 77 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); |
96 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ | 78 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ |
97 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ | 79 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ |
98 | - t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 1); /* FEAT_CSV2 */ | ||
99 | + t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */ | ||
100 | cpu->isar.id_aa64pfr0 = t; | ||
101 | |||
102 | t = cpu->isar.id_aa64pfr1; | ||
103 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 80 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
104 | * we do for EL2 with the virtualization=on property. | 81 | * we do for EL2 with the virtualization=on property. |
105 | */ | 82 | */ |
106 | t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ | 83 | t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ |
107 | + t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ | 84 | - t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 1); /* FEAT_RASv1p1 */ |
85 | + t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT_DoubleFault */ | ||
86 | t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ | ||
108 | cpu->isar.id_aa64pfr1 = t; | 87 | cpu->isar.id_aa64pfr1 = t; |
109 | 88 | ||
110 | t = cpu->isar.id_aa64mmfr0; | ||
111 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 89 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
112 | index XXXXXXX..XXXXXXX 100644 | 90 | index XXXXXXX..XXXXXXX 100644 |
113 | --- a/target/arm/helper.c | 91 | --- a/target/arm/helper.c |
114 | +++ b/target/arm/helper.c | 92 | +++ b/target/arm/helper.c |
115 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 93 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
116 | if (cpu_isar_feature(aa64_mte, cpu)) { | 94 | if (cpu_isar_feature(aa64_scxtnum, cpu)) { |
117 | valid_mask |= SCR_ATA; | 95 | valid_mask |= SCR_ENSCXT; |
118 | } | 96 | } |
119 | + if (cpu_isar_feature(aa64_scxtnum, cpu)) { | 97 | + if (cpu_isar_feature(aa64_doublefault, cpu)) { |
120 | + valid_mask |= SCR_ENSCXT; | 98 | + valid_mask |= SCR_EASE | SCR_NMEA; |
121 | + } | 99 | + } |
122 | } else { | 100 | } else { |
123 | valid_mask &= ~(SCR_RW | SCR_ST); | 101 | valid_mask &= ~(SCR_RW | SCR_ST); |
124 | if (cpu_isar_feature(aa32_ras, cpu)) { | 102 | if (cpu_isar_feature(aa32_ras, cpu)) { |
125 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | 103 | @@ -XXX,XX +XXX,XX @@ static uint32_t cpsr_read_for_spsr_elx(CPUARMState *env) |
126 | if (cpu_isar_feature(aa64_mte, cpu)) { | 104 | return ret; |
127 | valid_mask |= HCR_ATA | HCR_DCT | HCR_TID5; | 105 | } |
128 | } | 106 | |
129 | + if (cpu_isar_feature(aa64_scxtnum, cpu)) { | 107 | +static bool syndrome_is_sync_extabt(uint32_t syndrome) |
130 | + valid_mask |= HCR_ENSCXT; | 108 | +{ |
109 | + /* Return true if this syndrome value is a synchronous external abort */ | ||
110 | + switch (syn_get_ec(syndrome)) { | ||
111 | + case EC_INSNABORT: | ||
112 | + case EC_INSNABORT_SAME_EL: | ||
113 | + case EC_DATAABORT: | ||
114 | + case EC_DATAABORT_SAME_EL: | ||
115 | + /* Look at fault status code for all the synchronous ext abort cases */ | ||
116 | + switch (syndrome & 0x3f) { | ||
117 | + case 0x10: | ||
118 | + case 0x13: | ||
119 | + case 0x14: | ||
120 | + case 0x15: | ||
121 | + case 0x16: | ||
122 | + case 0x17: | ||
123 | + return true; | ||
124 | + default: | ||
125 | + return false; | ||
131 | + } | 126 | + } |
132 | } | 127 | + default: |
133 | 128 | + return false; | |
134 | /* Clear RES0 bits. */ | ||
135 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
136 | { K(3, 0, 5, 6, 0), K(3, 4, 5, 6, 0), K(3, 5, 5, 6, 0), | ||
137 | "TFSR_EL1", "TFSR_EL2", "TFSR_EL12", isar_feature_aa64_mte }, | ||
138 | |||
139 | + { K(3, 0, 13, 0, 7), K(3, 4, 13, 0, 7), K(3, 5, 13, 0, 7), | ||
140 | + "SCXTNUM_EL1", "SCXTNUM_EL2", "SCXTNUM_EL12", | ||
141 | + isar_feature_aa64_scxtnum }, | ||
142 | + | ||
143 | /* TODO: ARMv8.2-SPE -- PMSCR_EL2 */ | ||
144 | /* TODO: ARMv8.4-Trace -- TRFCR_EL2 */ | ||
145 | }; | ||
146 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
147 | }, | ||
148 | }; | ||
149 | |||
150 | -#endif | ||
151 | +static CPAccessResult access_scxtnum(CPUARMState *env, const ARMCPRegInfo *ri, | ||
152 | + bool isread) | ||
153 | +{ | ||
154 | + uint64_t hcr = arm_hcr_el2_eff(env); | ||
155 | + int el = arm_current_el(env); | ||
156 | + | ||
157 | + if (el == 0 && !((hcr & HCR_E2H) && (hcr & HCR_TGE))) { | ||
158 | + if (env->cp15.sctlr_el[1] & SCTLR_TSCXT) { | ||
159 | + if (hcr & HCR_TGE) { | ||
160 | + return CP_ACCESS_TRAP_EL2; | ||
161 | + } | ||
162 | + return CP_ACCESS_TRAP; | ||
163 | + } | ||
164 | + } else if (el < 2 && (env->cp15.sctlr_el[2] & SCTLR_TSCXT)) { | ||
165 | + return CP_ACCESS_TRAP_EL2; | ||
166 | + } | 129 | + } |
167 | + if (el < 2 && arm_is_el2_enabled(env) && !(hcr & HCR_ENSCXT)) { | ||
168 | + return CP_ACCESS_TRAP_EL2; | ||
169 | + } | ||
170 | + if (el < 3 | ||
171 | + && arm_feature(env, ARM_FEATURE_EL3) | ||
172 | + && !(env->cp15.scr_el3 & SCR_ENSCXT)) { | ||
173 | + return CP_ACCESS_TRAP_EL3; | ||
174 | + } | ||
175 | + return CP_ACCESS_OK; | ||
176 | +} | 130 | +} |
177 | + | 131 | + |
178 | +static const ARMCPRegInfo scxtnum_reginfo[] = { | 132 | /* Handle exception entry to a target EL which is using AArch64 */ |
179 | + { .name = "SCXTNUM_EL0", .state = ARM_CP_STATE_AA64, | 133 | static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
180 | + .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 7, | 134 | { |
181 | + .access = PL0_RW, .accessfn = access_scxtnum, | 135 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
182 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[0]) }, | 136 | switch (cs->exception_index) { |
183 | + { .name = "SCXTNUM_EL1", .state = ARM_CP_STATE_AA64, | 137 | case EXCP_PREFETCH_ABORT: |
184 | + .opc0 = 3, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 7, | 138 | case EXCP_DATA_ABORT: |
185 | + .access = PL1_RW, .accessfn = access_scxtnum, | 139 | + /* |
186 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[1]) }, | 140 | + * FEAT_DoubleFault allows synchronous external aborts taken to EL3 |
187 | + { .name = "SCXTNUM_EL2", .state = ARM_CP_STATE_AA64, | 141 | + * to be taken to the SError vector entrypoint. |
188 | + .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 7, | 142 | + */ |
189 | + .access = PL2_RW, .accessfn = access_scxtnum, | 143 | + if (new_el == 3 && (env->cp15.scr_el3 & SCR_EASE) && |
190 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[2]) }, | 144 | + syndrome_is_sync_extabt(env->exception.syndrome)) { |
191 | + { .name = "SCXTNUM_EL3", .state = ARM_CP_STATE_AA64, | 145 | + addr += 0x180; |
192 | + .opc0 = 3, .opc1 = 6, .crn = 13, .crm = 0, .opc2 = 7, | 146 | + } |
193 | + .access = PL3_RW, | 147 | env->cp15.far_el[new_el] = env->exception.vaddress; |
194 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[3]) }, | 148 | qemu_log_mask(CPU_LOG_INT, "...with FAR 0x%" PRIx64 "\n", |
195 | +}; | 149 | env->cp15.far_el[new_el]); |
196 | +#endif /* TARGET_AARCH64 */ | ||
197 | |||
198 | static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri, | ||
199 | bool isread) | ||
200 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
201 | define_arm_cp_regs(cpu, mte_tco_ro_reginfo); | ||
202 | define_arm_cp_regs(cpu, mte_el0_cacheop_reginfo); | ||
203 | } | ||
204 | + | ||
205 | + if (cpu_isar_feature(aa64_scxtnum, cpu)) { | ||
206 | + define_arm_cp_regs(cpu, scxtnum_reginfo); | ||
207 | + } | ||
208 | #endif | ||
209 | |||
210 | if (cpu_isar_feature(any_predinv, cpu)) { | ||
211 | -- | 150 | -- |
212 | 2.25.1 | 151 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | We have about 30 instances of the typo/variant spelling 'writeable', |
---|---|---|---|
2 | 2 | and over 500 of the more common 'writable'. Standardize on the | |
3 | The CPU topology isn't enabled on arm/virt machine yet, but we're | 3 | latter. |
4 | going to do it in next patch. After the CPU topology is enabled by | 4 | |
5 | next patch, "thread-id=1" becomes invalid because the CPU core is | 5 | Change produced with: |
6 | preferred on arm/virt machine. It means these two CPUs have 0/1 | 6 | |
7 | as their core IDs, but their thread IDs are all 0. It will trigger | 7 | sed -i -e 's/\([Ww][Rr][Ii][Tt]\)[Ee]\([Aa][Bb][Ll][Ee]\)/\1\2/g' $(git grep -il writeable) |
8 | test failure as the following message indicates: | 8 | |
9 | 9 | and then hand-undoing the instance in linux-headers/linux/kvm.h. | |
10 | [14/21 qemu:qtest+qtest-aarch64 / qtest-aarch64/numa-test ERROR | 10 | |
11 | 1.48s killed by signal 6 SIGABRT | 11 | Most of these changes are in comments or documentation; the |
12 | >>> G_TEST_DBUS_DAEMON=/home/gavin/sandbox/qemu.main/tests/dbus-vmstate-daemon.sh \ | 12 | exceptions are: |
13 | QTEST_QEMU_STORAGE_DAEMON_BINARY=./storage-daemon/qemu-storage-daemon \ | 13 | * a local variable in accel/hvf/hvf-accel-ops.c |
14 | QTEST_QEMU_BINARY=./qemu-system-aarch64 \ | 14 | * a local variable in accel/kvm/kvm-all.c |
15 | QTEST_QEMU_IMG=./qemu-img MALLOC_PERTURB_=83 \ | 15 | * the PMCR_WRITABLE_MASK macro in target/arm/internals.h |
16 | /home/gavin/sandbox/qemu.main/build/tests/qtest/numa-test --tap -k | 16 | * the EPT_VIOLATION_GPA_WRITABLE macro in target/i386/hvf/vmcs.h |
17 | ―――――――――――――――――――――――――――――――――――――――――――――― | 17 | (which is never used anywhere) |
18 | stderr: | 18 | * the AR_TYPE_WRITABLE_MASK macro in target/i386/hvf/vmx.h |
19 | qemu-system-aarch64: -numa cpu,node-id=0,thread-id=1: no match found | 19 | (which is never used anywhere) |
20 | 20 | ||
21 | This fixes the issue by providing comprehensive SMP configurations | ||
22 | in aarch64_numa_cpu(). The SMP configurations aren't used before | ||
23 | the CPU topology is enabled in next patch. | ||
24 | |||
25 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
26 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
27 | Message-id: 20220503140304.855514-3-gshan@redhat.com | ||
28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
23 | Reviewed-by: Stefan Weil <sw@weilnetz.de> | ||
24 | Message-id: 20220505095015.2714666-1-peter.maydell@linaro.org | ||
29 | --- | 25 | --- |
30 | tests/qtest/numa-test.c | 3 ++- | 26 | docs/interop/vhost-user.rst | 2 +- |
31 | 1 file changed, 2 insertions(+), 1 deletion(-) | 27 | docs/specs/vmgenid.txt | 4 ++-- |
32 | 28 | hw/scsi/mfi.h | 2 +- | |
33 | diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c | 29 | target/arm/internals.h | 4 ++-- |
34 | index XXXXXXX..XXXXXXX 100644 | 30 | target/i386/hvf/vmcs.h | 2 +- |
35 | --- a/tests/qtest/numa-test.c | 31 | target/i386/hvf/vmx.h | 2 +- |
36 | +++ b/tests/qtest/numa-test.c | 32 | accel/hvf/hvf-accel-ops.c | 4 ++-- |
37 | @@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data) | 33 | accel/kvm/kvm-all.c | 4 ++-- |
38 | QTestState *qts; | 34 | accel/tcg/user-exec.c | 6 +++--- |
39 | g_autofree char *cli = NULL; | 35 | hw/acpi/ghes.c | 2 +- |
40 | 36 | hw/intc/arm_gicv3_cpuif.c | 2 +- | |
41 | - cli = make_cli(data, "-machine smp.cpus=2 " | 37 | hw/intc/arm_gicv3_dist.c | 2 +- |
42 | + cli = make_cli(data, "-machine " | 38 | hw/intc/arm_gicv3_redist.c | 4 ++-- |
43 | + "smp.cpus=2,smp.sockets=1,smp.clusters=1,smp.cores=1,smp.threads=2 " | 39 | hw/intc/riscv_aclint.c | 2 +- |
44 | "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 " | 40 | hw/intc/riscv_aplic.c | 2 +- |
45 | "-numa cpu,node-id=1,thread-id=0 " | 41 | hw/pci/shpc.c | 2 +- |
46 | "-numa cpu,node-id=0,thread-id=1"); | 42 | hw/sparc64/sun4u_iommu.c | 2 +- |
43 | hw/timer/sse-timer.c | 2 +- | ||
44 | target/arm/gdbstub.c | 2 +- | ||
45 | target/arm/helper.c | 4 ++-- | ||
46 | target/arm/hvf/hvf.c | 4 ++-- | ||
47 | target/i386/cpu-sysemu.c | 2 +- | ||
48 | target/s390x/ioinst.c | 2 +- | ||
49 | python/qemu/machine/machine.py | 2 +- | ||
50 | tests/tcg/x86_64/system/boot.S | 2 +- | ||
51 | 25 files changed, 34 insertions(+), 34 deletions(-) | ||
52 | |||
53 | diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/docs/interop/vhost-user.rst | ||
56 | +++ b/docs/interop/vhost-user.rst | ||
57 | @@ -XXX,XX +XXX,XX @@ Virtio device config space | ||
58 | :size: a 32-bit configuration space access size in bytes | ||
59 | |||
60 | :flags: a 32-bit value: | ||
61 | - - 0: Vhost front-end messages used for writeable fields | ||
62 | + - 0: Vhost front-end messages used for writable fields | ||
63 | - 1: Vhost front-end messages used for live migration | ||
64 | |||
65 | :payload: Size bytes array holding the contents of the virtio | ||
66 | diff --git a/docs/specs/vmgenid.txt b/docs/specs/vmgenid.txt | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/docs/specs/vmgenid.txt | ||
69 | +++ b/docs/specs/vmgenid.txt | ||
70 | @@ -XXX,XX +XXX,XX @@ change the contents of the memory at runtime, specifically when starting a | ||
71 | backed-up or snapshotted image. In order to do this, QEMU must know the | ||
72 | address that has been allocated. | ||
73 | |||
74 | -The mechanism chosen for this memory sharing is writeable fw_cfg blobs. | ||
75 | +The mechanism chosen for this memory sharing is writable fw_cfg blobs. | ||
76 | These are data object that are visible to both QEMU and guests, and are | ||
77 | addressable as sequential files. | ||
78 | |||
79 | @@ -XXX,XX +XXX,XX @@ Two fw_cfg blobs are used in this case: | ||
80 | /etc/vmgenid_guid - contains the actual VM Generation ID GUID | ||
81 | - read-only to the guest | ||
82 | /etc/vmgenid_addr - contains the address of the downloaded vmgenid blob | ||
83 | - - writeable by the guest | ||
84 | + - writable by the guest | ||
85 | |||
86 | |||
87 | QEMU sends the following commands to the guest at startup: | ||
88 | diff --git a/hw/scsi/mfi.h b/hw/scsi/mfi.h | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/hw/scsi/mfi.h | ||
91 | +++ b/hw/scsi/mfi.h | ||
92 | @@ -XXX,XX +XXX,XX @@ struct mfi_ctrl_props { | ||
93 | * metadata and user data | ||
94 | * 1=5%, 2=10%, 3=15% and so on | ||
95 | */ | ||
96 | - uint8_t viewSpace; /* snapshot writeable VIEWs | ||
97 | + uint8_t viewSpace; /* snapshot writable VIEWs | ||
98 | * capacity as a % of source LD | ||
99 | * capacity. 0=READ only | ||
100 | * 1=5%, 2=10%, 3=15% and so on | ||
101 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/target/arm/internals.h | ||
104 | +++ b/target/arm/internals.h | ||
105 | @@ -XXX,XX +XXX,XX @@ enum MVEECIState { | ||
106 | #define PMCRP 0x2 | ||
107 | #define PMCRE 0x1 | ||
108 | /* | ||
109 | - * Mask of PMCR bits writeable by guest (not including WO bits like C, P, | ||
110 | + * Mask of PMCR bits writable by guest (not including WO bits like C, P, | ||
111 | * which can be written as 1 to trigger behaviour but which stay RAZ). | ||
112 | */ | ||
113 | -#define PMCR_WRITEABLE_MASK (PMCRLC | PMCRDP | PMCRX | PMCRD | PMCRE) | ||
114 | +#define PMCR_WRITABLE_MASK (PMCRLC | PMCRDP | PMCRX | PMCRD | PMCRE) | ||
115 | |||
116 | #define PMXEVTYPER_P 0x80000000 | ||
117 | #define PMXEVTYPER_U 0x40000000 | ||
118 | diff --git a/target/i386/hvf/vmcs.h b/target/i386/hvf/vmcs.h | ||
119 | index XXXXXXX..XXXXXXX 100644 | ||
120 | --- a/target/i386/hvf/vmcs.h | ||
121 | +++ b/target/i386/hvf/vmcs.h | ||
122 | @@ -XXX,XX +XXX,XX @@ | ||
123 | #define EPT_VIOLATION_DATA_WRITE (1UL << 1) | ||
124 | #define EPT_VIOLATION_INST_FETCH (1UL << 2) | ||
125 | #define EPT_VIOLATION_GPA_READABLE (1UL << 3) | ||
126 | -#define EPT_VIOLATION_GPA_WRITEABLE (1UL << 4) | ||
127 | +#define EPT_VIOLATION_GPA_WRITABLE (1UL << 4) | ||
128 | #define EPT_VIOLATION_GPA_EXECUTABLE (1UL << 5) | ||
129 | #define EPT_VIOLATION_GLA_VALID (1UL << 7) | ||
130 | #define EPT_VIOLATION_XLAT_VALID (1UL << 8) | ||
131 | diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/i386/hvf/vmx.h | ||
134 | +++ b/target/i386/hvf/vmx.h | ||
135 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cap2ctrl(uint64_t cap, uint64_t ctrl) | ||
136 | |||
137 | #define AR_TYPE_ACCESSES_MASK 1 | ||
138 | #define AR_TYPE_READABLE_MASK (1 << 1) | ||
139 | -#define AR_TYPE_WRITEABLE_MASK (1 << 2) | ||
140 | +#define AR_TYPE_WRITABLE_MASK (1 << 2) | ||
141 | #define AR_TYPE_CODE_MASK (1 << 3) | ||
142 | #define AR_TYPE_MASK 0x0f | ||
143 | #define AR_TYPE_BUSY_64_TSS 11 | ||
144 | diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c | ||
145 | index XXXXXXX..XXXXXXX 100644 | ||
146 | --- a/accel/hvf/hvf-accel-ops.c | ||
147 | +++ b/accel/hvf/hvf-accel-ops.c | ||
148 | @@ -XXX,XX +XXX,XX @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add) | ||
149 | { | ||
150 | hvf_slot *mem; | ||
151 | MemoryRegion *area = section->mr; | ||
152 | - bool writeable = !area->readonly && !area->rom_device; | ||
153 | + bool writable = !area->readonly && !area->rom_device; | ||
154 | hv_memory_flags_t flags; | ||
155 | uint64_t page_size = qemu_real_host_page_size(); | ||
156 | |||
157 | if (!memory_region_is_ram(area)) { | ||
158 | - if (writeable) { | ||
159 | + if (writable) { | ||
160 | return; | ||
161 | } else if (!memory_region_is_romd(area)) { | ||
162 | /* | ||
163 | diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/accel/kvm/kvm-all.c | ||
166 | +++ b/accel/kvm/kvm-all.c | ||
167 | @@ -XXX,XX +XXX,XX @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, | ||
168 | KVMSlot *mem; | ||
169 | int err; | ||
170 | MemoryRegion *mr = section->mr; | ||
171 | - bool writeable = !mr->readonly && !mr->rom_device; | ||
172 | + bool writable = !mr->readonly && !mr->rom_device; | ||
173 | hwaddr start_addr, size, slot_size, mr_offset; | ||
174 | ram_addr_t ram_start_offset; | ||
175 | void *ram; | ||
176 | |||
177 | if (!memory_region_is_ram(mr)) { | ||
178 | - if (writeable || !kvm_readonly_mem_allowed) { | ||
179 | + if (writable || !kvm_readonly_mem_allowed) { | ||
180 | return; | ||
181 | } else if (!mr->romd_mode) { | ||
182 | /* If the memory device is not in romd_mode, then we actually want | ||
183 | diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c | ||
184 | index XXXXXXX..XXXXXXX 100644 | ||
185 | --- a/accel/tcg/user-exec.c | ||
186 | +++ b/accel/tcg/user-exec.c | ||
187 | @@ -XXX,XX +XXX,XX @@ MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write) | ||
188 | * Return true if the write fault has been handled, and should be re-tried. | ||
189 | * | ||
190 | * Note that it is important that we don't call page_unprotect() unless | ||
191 | - * this is really a "write to nonwriteable page" fault, because | ||
192 | + * this is really a "write to nonwritable page" fault, because | ||
193 | * page_unprotect() assumes that if it is called for an access to | ||
194 | - * a page that's writeable this means we had two threads racing and | ||
195 | - * another thread got there first and already made the page writeable; | ||
196 | + * a page that's writable this means we had two threads racing and | ||
197 | + * another thread got there first and already made the page writable; | ||
198 | * so we will retry the access. If we were to call page_unprotect() | ||
199 | * for some other kind of fault that should really be passed to the | ||
200 | * guest, we'd end up in an infinite loop of retrying the faulting access. | ||
201 | diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c | ||
202 | index XXXXXXX..XXXXXXX 100644 | ||
203 | --- a/hw/acpi/ghes.c | ||
204 | +++ b/hw/acpi/ghes.c | ||
205 | @@ -XXX,XX +XXX,XX @@ void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *linker) | ||
206 | for (i = 0; i < ACPI_GHES_ERROR_SOURCE_COUNT; i++) { | ||
207 | /* | ||
208 | * Initialize the value of read_ack_register to 1, so GHES can be | ||
209 | - * writeable after (re)boot. | ||
210 | + * writable after (re)boot. | ||
211 | * ACPI 6.2: 18.3.2.8 Generic Hardware Error Source version 2 | ||
212 | * (GHESv2 - Type 10) | ||
213 | */ | ||
214 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
215 | index XXXXXXX..XXXXXXX 100644 | ||
216 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
217 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
218 | @@ -XXX,XX +XXX,XX @@ static void icc_ctlr_el3_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
219 | cs->icc_ctlr_el1[GICV3_S] |= ICC_CTLR_EL1_CBPR; | ||
220 | } | ||
221 | |||
222 | - /* The only bit stored in icc_ctlr_el3 which is writeable is EOIMODE_EL3: */ | ||
223 | + /* The only bit stored in icc_ctlr_el3 which is writable is EOIMODE_EL3: */ | ||
224 | mask = ICC_CTLR_EL3_EOIMODE_EL3; | ||
225 | |||
226 | cs->icc_ctlr_el3 &= ~mask; | ||
227 | diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c | ||
228 | index XXXXXXX..XXXXXXX 100644 | ||
229 | --- a/hw/intc/arm_gicv3_dist.c | ||
230 | +++ b/hw/intc/arm_gicv3_dist.c | ||
231 | @@ -XXX,XX +XXX,XX @@ static bool gicd_writel(GICv3State *s, hwaddr offset, | ||
232 | if (value & mask & GICD_CTLR_DS) { | ||
233 | /* We just set DS, so the ARE_NS and EnG1S bits are now RES0. | ||
234 | * Note that this is a one-way transition because if DS is set | ||
235 | - * then it's not writeable, so it can only go back to 0 with a | ||
236 | + * then it's not writable, so it can only go back to 0 with a | ||
237 | * hardware reset. | ||
238 | */ | ||
239 | s->gicd_ctlr &= ~(GICD_CTLR_EN_GRP1S | GICD_CTLR_ARE_NS); | ||
240 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
241 | index XXXXXXX..XXXXXXX 100644 | ||
242 | --- a/hw/intc/arm_gicv3_redist.c | ||
243 | +++ b/hw/intc/arm_gicv3_redist.c | ||
244 | @@ -XXX,XX +XXX,XX @@ static void gicr_write_vpendbaser(GICv3CPUState *cs, uint64_t newval) | ||
245 | |||
246 | /* | ||
247 | * The DIRTY bit is read-only and for us is always zero; | ||
248 | - * other fields are writeable. | ||
249 | + * other fields are writable. | ||
250 | */ | ||
251 | newval &= R_GICR_VPENDBASER_INNERCACHE_MASK | | ||
252 | R_GICR_VPENDBASER_SHAREABILITY_MASK | | ||
253 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset, | ||
254 | /* RAZ/WI for our implementation */ | ||
255 | return MEMTX_OK; | ||
256 | case GICR_WAKER: | ||
257 | - /* Only the ProcessorSleep bit is writeable. When the guest sets | ||
258 | + /* Only the ProcessorSleep bit is writable. When the guest sets | ||
259 | * it it requests that we transition the channel between the | ||
260 | * redistributor and the cpu interface to quiescent, and that | ||
261 | * we set the ChildrenAsleep bit once the inteface has reached the | ||
262 | diff --git a/hw/intc/riscv_aclint.c b/hw/intc/riscv_aclint.c | ||
263 | index XXXXXXX..XXXXXXX 100644 | ||
264 | --- a/hw/intc/riscv_aclint.c | ||
265 | +++ b/hw/intc/riscv_aclint.c | ||
266 | @@ -XXX,XX +XXX,XX @@ static void riscv_aclint_swi_realize(DeviceState *dev, Error **errp) | ||
267 | /* Claim software interrupt bits */ | ||
268 | for (i = 0; i < swi->num_harts; i++) { | ||
269 | RISCVCPU *cpu = RISCV_CPU(qemu_get_cpu(swi->hartid_base + i)); | ||
270 | - /* We don't claim mip.SSIP because it is writeable by software */ | ||
271 | + /* We don't claim mip.SSIP because it is writable by software */ | ||
272 | if (riscv_cpu_claim_interrupts(cpu, swi->sswi ? 0 : MIP_MSIP) < 0) { | ||
273 | error_report("MSIP already claimed"); | ||
274 | exit(1); | ||
275 | diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c | ||
276 | index XXXXXXX..XXXXXXX 100644 | ||
277 | --- a/hw/intc/riscv_aplic.c | ||
278 | +++ b/hw/intc/riscv_aplic.c | ||
279 | @@ -XXX,XX +XXX,XX @@ static void riscv_aplic_write(void *opaque, hwaddr addr, uint64_t value, | ||
280 | } | ||
281 | |||
282 | if (addr == APLIC_DOMAINCFG) { | ||
283 | - /* Only IE bit writeable at the moment */ | ||
284 | + /* Only IE bit writable at the moment */ | ||
285 | value &= APLIC_DOMAINCFG_IE; | ||
286 | aplic->domaincfg = value; | ||
287 | } else if ((APLIC_SOURCECFG_BASE <= addr) && | ||
288 | diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c | ||
289 | index XXXXXXX..XXXXXXX 100644 | ||
290 | --- a/hw/pci/shpc.c | ||
291 | +++ b/hw/pci/shpc.c | ||
292 | @@ -XXX,XX +XXX,XX @@ static int shpc_cap_add_config(PCIDevice *d, Error **errp) | ||
293 | pci_set_byte(config + SHPC_CAP_CxP, 0); | ||
294 | pci_set_long(config + SHPC_CAP_DWORD_DATA, 0); | ||
295 | d->shpc->cap = config_offset; | ||
296 | - /* Make dword select and data writeable. */ | ||
297 | + /* Make dword select and data writable. */ | ||
298 | pci_set_byte(d->wmask + config_offset + SHPC_CAP_DWORD_SELECT, 0xff); | ||
299 | pci_set_long(d->wmask + config_offset + SHPC_CAP_DWORD_DATA, 0xffffffff); | ||
300 | return 0; | ||
301 | diff --git a/hw/sparc64/sun4u_iommu.c b/hw/sparc64/sun4u_iommu.c | ||
302 | index XXXXXXX..XXXXXXX 100644 | ||
303 | --- a/hw/sparc64/sun4u_iommu.c | ||
304 | +++ b/hw/sparc64/sun4u_iommu.c | ||
305 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry sun4u_translate_iommu(IOMMUMemoryRegion *iommu, | ||
306 | } | ||
307 | |||
308 | if (tte & IOMMU_TTE_DATA_W) { | ||
309 | - /* Writeable */ | ||
310 | + /* Writable */ | ||
311 | ret.perm = IOMMU_RW; | ||
312 | } else { | ||
313 | ret.perm = IOMMU_RO; | ||
314 | diff --git a/hw/timer/sse-timer.c b/hw/timer/sse-timer.c | ||
315 | index XXXXXXX..XXXXXXX 100644 | ||
316 | --- a/hw/timer/sse-timer.c | ||
317 | +++ b/hw/timer/sse-timer.c | ||
318 | @@ -XXX,XX +XXX,XX @@ static void sse_timer_write(void *opaque, hwaddr offset, uint64_t value, | ||
319 | { | ||
320 | uint32_t old_ctl = s->cntp_aival_ctl; | ||
321 | |||
322 | - /* EN bit is writeable; CLR bit is write-0-to-clear, write-1-ignored */ | ||
323 | + /* EN bit is writable; CLR bit is write-0-to-clear, write-1-ignored */ | ||
324 | s->cntp_aival_ctl &= ~R_CNTP_AIVAL_CTL_EN_MASK; | ||
325 | s->cntp_aival_ctl |= value & R_CNTP_AIVAL_CTL_EN_MASK; | ||
326 | if (!(value & R_CNTP_AIVAL_CTL_CLR_MASK)) { | ||
327 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
328 | index XXXXXXX..XXXXXXX 100644 | ||
329 | --- a/target/arm/gdbstub.c | ||
330 | +++ b/target/arm/gdbstub.c | ||
331 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | ||
332 | /* | ||
333 | * Don't allow writing to XPSR.Exception as it can cause | ||
334 | * a transition into or out of handler mode (it's not | ||
335 | - * writeable via the MSR insn so this is a reasonable | ||
336 | + * writable via the MSR insn so this is a reasonable | ||
337 | * restriction). Other fields are safe to update. | ||
338 | */ | ||
339 | xpsr_write(env, tmp, ~XPSR_EXCP); | ||
340 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
341 | index XXXXXXX..XXXXXXX 100644 | ||
342 | --- a/target/arm/helper.c | ||
343 | +++ b/target/arm/helper.c | ||
344 | @@ -XXX,XX +XXX,XX @@ static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
345 | } | ||
346 | } | ||
347 | |||
348 | - env->cp15.c9_pmcr &= ~PMCR_WRITEABLE_MASK; | ||
349 | - env->cp15.c9_pmcr |= (value & PMCR_WRITEABLE_MASK); | ||
350 | + env->cp15.c9_pmcr &= ~PMCR_WRITABLE_MASK; | ||
351 | + env->cp15.c9_pmcr |= (value & PMCR_WRITABLE_MASK); | ||
352 | |||
353 | pmu_op_finish(env); | ||
354 | } | ||
355 | diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c | ||
356 | index XXXXXXX..XXXXXXX 100644 | ||
357 | --- a/target/arm/hvf/hvf.c | ||
358 | +++ b/target/arm/hvf/hvf.c | ||
359 | @@ -XXX,XX +XXX,XX @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t reg, uint64_t val) | ||
360 | } | ||
361 | } | ||
362 | |||
363 | - env->cp15.c9_pmcr &= ~PMCR_WRITEABLE_MASK; | ||
364 | - env->cp15.c9_pmcr |= (val & PMCR_WRITEABLE_MASK); | ||
365 | + env->cp15.c9_pmcr &= ~PMCR_WRITABLE_MASK; | ||
366 | + env->cp15.c9_pmcr |= (val & PMCR_WRITABLE_MASK); | ||
367 | |||
368 | pmu_op_finish(env); | ||
369 | break; | ||
370 | diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c | ||
371 | index XXXXXXX..XXXXXXX 100644 | ||
372 | --- a/target/i386/cpu-sysemu.c | ||
373 | +++ b/target/i386/cpu-sysemu.c | ||
374 | @@ -XXX,XX +XXX,XX @@ static void x86_cpu_to_dict(X86CPU *cpu, QDict *props) | ||
375 | |||
376 | /* Convert CPU model data from X86CPU object to a property dictionary | ||
377 | * that can recreate exactly the same CPU model, including every | ||
378 | - * writeable QOM property. | ||
379 | + * writable QOM property. | ||
380 | */ | ||
381 | static void x86_cpu_to_dict_full(X86CPU *cpu, QDict *props) | ||
382 | { | ||
383 | diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c | ||
384 | index XXXXXXX..XXXXXXX 100644 | ||
385 | --- a/target/s390x/ioinst.c | ||
386 | +++ b/target/s390x/ioinst.c | ||
387 | @@ -XXX,XX +XXX,XX @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb, | ||
388 | g_assert(!s390_is_pv()); | ||
389 | /* | ||
390 | * As operand exceptions have a lower priority than access exceptions, | ||
391 | - * we check whether the memory area is writeable (injecting the | ||
392 | + * we check whether the memory area is writable (injecting the | ||
393 | * access execption if it is not) first. | ||
394 | */ | ||
395 | if (!s390_cpu_virt_mem_check_write(cpu, addr, ar, sizeof(schib))) { | ||
396 | diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py | ||
397 | index XXXXXXX..XXXXXXX 100644 | ||
398 | --- a/python/qemu/machine/machine.py | ||
399 | +++ b/python/qemu/machine/machine.py | ||
400 | @@ -XXX,XX +XXX,XX @@ def _early_cleanup(self) -> None: | ||
401 | """ | ||
402 | # If we keep the console socket open, we may deadlock waiting | ||
403 | # for QEMU to exit, while QEMU is waiting for the socket to | ||
404 | - # become writeable. | ||
405 | + # become writable. | ||
406 | if self._console_socket is not None: | ||
407 | self._console_socket.close() | ||
408 | self._console_socket = None | ||
409 | diff --git a/tests/tcg/x86_64/system/boot.S b/tests/tcg/x86_64/system/boot.S | ||
410 | index XXXXXXX..XXXXXXX 100644 | ||
411 | --- a/tests/tcg/x86_64/system/boot.S | ||
412 | +++ b/tests/tcg/x86_64/system/boot.S | ||
413 | @@ -XXX,XX +XXX,XX @@ | ||
414 | * | ||
415 | * - `ebx`: contains the physical memory address where the loader has placed | ||
416 | * the boot start info structure. | ||
417 | - * - `cr0`: bit 0 (PE) must be set. All the other writeable bits are cleared. | ||
418 | + * - `cr0`: bit 0 (PE) must be set. All the other writable bits are cleared. | ||
419 | * - `cr4`: all bits are cleared. | ||
420 | * - `cs `: must be a 32-bit read/execute code segment with a base of ‘0’ | ||
421 | * and a limit of ‘0xFFFFFFFF’. The selector value is unspecified. | ||
47 | -- | 422 | -- |
48 | 2.25.1 | 423 | 2.25.1 |
49 | 424 | ||
50 | 425 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Frederic Konrad <fkonrad@amd.com> | ||
1 | 2 | ||
3 | The core and the vblend registers size are wrong, they should respectively be | ||
4 | 0x3B0 and 0x1E0 according to: | ||
5 | https://www.xilinx.com/htmldocs/registers/ug1087/ug1087-zynq-ultrascale-registers.html. | ||
6 | |||
7 | Let's fix that and use macros when creating the mmio region. | ||
8 | |||
9 | Fixes: 58ac482a66d ("introduce xlnx-dp") | ||
10 | Signed-off-by: Frederic Konrad <fkonrad@amd.com> | ||
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
12 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | Message-id: 20220601172353.3220232-2-fkonrad@xilinx.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | include/hw/display/xlnx_dp.h | 9 +++++++-- | ||
17 | hw/display/xlnx_dp.c | 17 ++++++++++------- | ||
18 | 2 files changed, 17 insertions(+), 9 deletions(-) | ||
19 | |||
20 | diff --git a/include/hw/display/xlnx_dp.h b/include/hw/display/xlnx_dp.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/include/hw/display/xlnx_dp.h | ||
23 | +++ b/include/hw/display/xlnx_dp.h | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | #define AUD_CHBUF_MAX_DEPTH (32 * KiB) | ||
26 | #define MAX_QEMU_BUFFER_SIZE (4 * KiB) | ||
27 | |||
28 | -#define DP_CORE_REG_ARRAY_SIZE (0x3AF >> 2) | ||
29 | +#define DP_CORE_REG_OFFSET (0x0000) | ||
30 | +#define DP_CORE_REG_ARRAY_SIZE (0x3B0 >> 2) | ||
31 | +#define DP_AVBUF_REG_OFFSET (0xB000) | ||
32 | #define DP_AVBUF_REG_ARRAY_SIZE (0x238 >> 2) | ||
33 | -#define DP_VBLEND_REG_ARRAY_SIZE (0x1DF >> 2) | ||
34 | +#define DP_VBLEND_REG_OFFSET (0xA000) | ||
35 | +#define DP_VBLEND_REG_ARRAY_SIZE (0x1E0 >> 2) | ||
36 | +#define DP_AUDIO_REG_OFFSET (0xC000) | ||
37 | #define DP_AUDIO_REG_ARRAY_SIZE (0x50 >> 2) | ||
38 | +#define DP_CONTAINER_SIZE (0xC050) | ||
39 | |||
40 | struct PixmanPlane { | ||
41 | pixman_format_code_t format; | ||
42 | diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/hw/display/xlnx_dp.c | ||
45 | +++ b/hw/display/xlnx_dp.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static void xlnx_dp_init(Object *obj) | ||
47 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
48 | XlnxDPState *s = XLNX_DP(obj); | ||
49 | |||
50 | - memory_region_init(&s->container, obj, TYPE_XLNX_DP, 0xC050); | ||
51 | + memory_region_init(&s->container, obj, TYPE_XLNX_DP, DP_CONTAINER_SIZE); | ||
52 | |||
53 | memory_region_init_io(&s->core_iomem, obj, &dp_ops, s, TYPE_XLNX_DP | ||
54 | - ".core", 0x3AF); | ||
55 | - memory_region_add_subregion(&s->container, 0x0000, &s->core_iomem); | ||
56 | + ".core", sizeof(s->core_registers)); | ||
57 | + memory_region_add_subregion(&s->container, DP_CORE_REG_OFFSET, | ||
58 | + &s->core_iomem); | ||
59 | |||
60 | memory_region_init_io(&s->vblend_iomem, obj, &vblend_ops, s, TYPE_XLNX_DP | ||
61 | - ".v_blend", 0x1DF); | ||
62 | - memory_region_add_subregion(&s->container, 0xA000, &s->vblend_iomem); | ||
63 | + ".v_blend", sizeof(s->vblend_registers)); | ||
64 | + memory_region_add_subregion(&s->container, DP_VBLEND_REG_OFFSET, | ||
65 | + &s->vblend_iomem); | ||
66 | |||
67 | memory_region_init_io(&s->avbufm_iomem, obj, &avbufm_ops, s, TYPE_XLNX_DP | ||
68 | - ".av_buffer_manager", 0x238); | ||
69 | - memory_region_add_subregion(&s->container, 0xB000, &s->avbufm_iomem); | ||
70 | + ".av_buffer_manager", sizeof(s->avbufm_registers)); | ||
71 | + memory_region_add_subregion(&s->container, DP_AVBUF_REG_OFFSET, | ||
72 | + &s->avbufm_iomem); | ||
73 | |||
74 | memory_region_init_io(&s->audio_iomem, obj, &audio_ops, s, TYPE_XLNX_DP | ||
75 | ".audio", sizeof(s->audio_registers)); | ||
76 | -- | ||
77 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> | ||
1 | 2 | ||
3 | Add a periodic timer which raises vblank at a frequency of 30Hz. | ||
4 | |||
5 | Note that this is a migration compatibility break for the | ||
6 | xlnx-zcu102 board type. | ||
7 | |||
8 | Signed-off-by: Sai Pavan Boddu <saipava@xilinx.com> | ||
9 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
10 | Signed-off-by: Frederic Konrad <fkonrad@amd.com> | ||
11 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
12 | Message-id: 20220601172353.3220232-3-fkonrad@xilinx.com | ||
13 | Changes by fkonrad: | ||
14 | - Switched to transaction-based ptimer API. | ||
15 | - Added the DP_INT_VBLNK_START macro. | ||
16 | Signed-off-by: Frederic Konrad <fkonrad@amd.com> | ||
17 | [PMM: bump vmstate version, add commit message note about | ||
18 | compat break] | ||
19 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | --- | ||
22 | include/hw/display/xlnx_dp.h | 3 +++ | ||
23 | hw/display/xlnx_dp.c | 30 ++++++++++++++++++++++++++---- | ||
24 | 2 files changed, 29 insertions(+), 4 deletions(-) | ||
25 | |||
26 | diff --git a/include/hw/display/xlnx_dp.h b/include/hw/display/xlnx_dp.h | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/include/hw/display/xlnx_dp.h | ||
29 | +++ b/include/hw/display/xlnx_dp.h | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | #include "hw/dma/xlnx_dpdma.h" | ||
32 | #include "audio/audio.h" | ||
33 | #include "qom/object.h" | ||
34 | +#include "hw/ptimer.h" | ||
35 | |||
36 | #define AUD_CHBUF_MAX_DEPTH (32 * KiB) | ||
37 | #define MAX_QEMU_BUFFER_SIZE (4 * KiB) | ||
38 | @@ -XXX,XX +XXX,XX @@ struct XlnxDPState { | ||
39 | */ | ||
40 | DPCDState *dpcd; | ||
41 | I2CDDCState *edid; | ||
42 | + | ||
43 | + ptimer_state *vblank; | ||
44 | }; | ||
45 | |||
46 | #define TYPE_XLNX_DP "xlnx.v-dp" | ||
47 | diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/display/xlnx_dp.c | ||
50 | +++ b/hw/display/xlnx_dp.c | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | #define DP_TX_N_AUD (0x032C >> 2) | ||
53 | #define DP_TX_AUDIO_EXT_DATA(n) ((0x0330 + 4 * n) >> 2) | ||
54 | #define DP_INT_STATUS (0x03A0 >> 2) | ||
55 | +#define DP_INT_VBLNK_START (1 << 13) | ||
56 | #define DP_INT_MASK (0x03A4 >> 2) | ||
57 | #define DP_INT_EN (0x03A8 >> 2) | ||
58 | #define DP_INT_DS (0x03AC >> 2) | ||
59 | @@ -XXX,XX +XXX,XX @@ typedef enum DPVideoFmt DPVideoFmt; | ||
60 | |||
61 | static const VMStateDescription vmstate_dp = { | ||
62 | .name = TYPE_XLNX_DP, | ||
63 | - .version_id = 1, | ||
64 | + .version_id = 2, | ||
65 | .fields = (VMStateField[]){ | ||
66 | VMSTATE_UINT32_ARRAY(core_registers, XlnxDPState, | ||
67 | DP_CORE_REG_ARRAY_SIZE), | ||
68 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_dp = { | ||
69 | DP_VBLEND_REG_ARRAY_SIZE), | ||
70 | VMSTATE_UINT32_ARRAY(audio_registers, XlnxDPState, | ||
71 | DP_AUDIO_REG_ARRAY_SIZE), | ||
72 | + VMSTATE_PTIMER(vblank, XlnxDPState), | ||
73 | VMSTATE_END_OF_LIST() | ||
74 | } | ||
75 | }; | ||
76 | |||
77 | +#define DP_VBLANK_PTIMER_POLICY (PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD | \ | ||
78 | + PTIMER_POLICY_CONTINUOUS_TRIGGER | \ | ||
79 | + PTIMER_POLICY_NO_IMMEDIATE_TRIGGER) | ||
80 | + | ||
81 | static void xlnx_dp_update_irq(XlnxDPState *s); | ||
82 | |||
83 | static uint64_t xlnx_dp_audio_read(void *opaque, hwaddr offset, unsigned size) | ||
84 | @@ -XXX,XX +XXX,XX @@ static void xlnx_dp_write(void *opaque, hwaddr offset, uint64_t value, | ||
85 | break; | ||
86 | case DP_TRANSMITTER_ENABLE: | ||
87 | s->core_registers[offset] = value & 0x01; | ||
88 | + ptimer_transaction_begin(s->vblank); | ||
89 | + if (value & 0x1) { | ||
90 | + ptimer_run(s->vblank, 0); | ||
91 | + } else { | ||
92 | + ptimer_stop(s->vblank); | ||
93 | + } | ||
94 | + ptimer_transaction_commit(s->vblank); | ||
95 | break; | ||
96 | case DP_FORCE_SCRAMBLER_RESET: | ||
97 | /* | ||
98 | @@ -XXX,XX +XXX,XX @@ static void xlnx_dp_update_display(void *opaque) | ||
99 | return; | ||
100 | } | ||
101 | |||
102 | - s->core_registers[DP_INT_STATUS] |= (1 << 13); | ||
103 | - xlnx_dp_update_irq(s); | ||
104 | - | ||
105 | xlnx_dpdma_trigger_vsync_irq(s->dpdma); | ||
106 | |||
107 | /* | ||
108 | @@ -XXX,XX +XXX,XX @@ static void xlnx_dp_finalize(Object *obj) | ||
109 | fifo8_destroy(&s->rx_fifo); | ||
110 | } | ||
111 | |||
112 | +static void vblank_hit(void *opaque) | ||
113 | +{ | ||
114 | + XlnxDPState *s = XLNX_DP(opaque); | ||
115 | + | ||
116 | + s->core_registers[DP_INT_STATUS] |= DP_INT_VBLNK_START; | ||
117 | + xlnx_dp_update_irq(s); | ||
118 | +} | ||
119 | + | ||
120 | static void xlnx_dp_realize(DeviceState *dev, Error **errp) | ||
121 | { | ||
122 | XlnxDPState *s = XLNX_DP(dev); | ||
123 | @@ -XXX,XX +XXX,XX @@ static void xlnx_dp_realize(DeviceState *dev, Error **errp) | ||
124 | &as); | ||
125 | AUD_set_volume_out(s->amixer_output_stream, 0, 255, 255); | ||
126 | xlnx_dp_audio_activate(s); | ||
127 | + s->vblank = ptimer_init(vblank_hit, s, DP_VBLANK_PTIMER_POLICY); | ||
128 | + ptimer_transaction_begin(s->vblank); | ||
129 | + ptimer_set_freq(s->vblank, 30); | ||
130 | + ptimer_transaction_commit(s->vblank); | ||
131 | } | ||
132 | |||
133 | static void xlnx_dp_reset(DeviceState *dev) | ||
134 | -- | ||
135 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> | ||
1 | 2 | ||
3 | Fix interrupt disable logic. Mask value 1 indicates that interrupts are | ||
4 | disabled. | ||
5 | |||
6 | Signed-off-by: Sai Pavan Boddu <saipava@xilinx.com> | ||
7 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
8 | Signed-off-by: Frederic Konrad <fkonrad@amd.com> | ||
9 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Message-id: 20220601172353.3220232-4-fkonrad@xilinx.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/display/xlnx_dp.c | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/display/xlnx_dp.c | ||
19 | +++ b/hw/display/xlnx_dp.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void xlnx_dp_write(void *opaque, hwaddr offset, uint64_t value, | ||
21 | xlnx_dp_update_irq(s); | ||
22 | break; | ||
23 | case DP_INT_DS: | ||
24 | - s->core_registers[DP_INT_MASK] |= ~value; | ||
25 | + s->core_registers[DP_INT_MASK] |= value; | ||
26 | xlnx_dp_update_irq(s); | ||
27 | break; | ||
28 | default: | ||
29 | -- | ||
30 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Frederic Konrad <fkonrad@amd.com> | ||
1 | 2 | ||
3 | When the display port has been initially implemented the device | ||
4 | driver wasn't using interrupts. Now that the display port driver | ||
5 | waits for vblank interrupt it has been noticed that the irq mapping | ||
6 | is wrong. So use the value from the linux device tree and the | ||
7 | ultrascale+ reference manual. | ||
8 | |||
9 | Signed-off-by: Frederic Konrad <fkonrad@amd.com> | ||
10 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
11 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
12 | Message-id: 20220601172353.3220232-5-fkonrad@xilinx.com | ||
13 | [PMM: refold lines in commit message] | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/arm/xlnx-zynqmp.c | 4 ++-- | ||
17 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/arm/xlnx-zynqmp.c | ||
22 | +++ b/hw/arm/xlnx-zynqmp.c | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | #define SERDES_SIZE 0x20000 | ||
25 | |||
26 | #define DP_ADDR 0xfd4a0000 | ||
27 | -#define DP_IRQ 113 | ||
28 | +#define DP_IRQ 0x77 | ||
29 | |||
30 | #define DPDMA_ADDR 0xfd4c0000 | ||
31 | -#define DPDMA_IRQ 116 | ||
32 | +#define DPDMA_IRQ 0x7a | ||
33 | |||
34 | #define APU_ADDR 0xfd5c0000 | ||
35 | #define APU_IRQ 153 | ||
36 | -- | ||
37 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Move the decl from ptw.h to internals.h. Provide an inline | ||
4 | version for user-only, just as we do for arm_stage1_mmu_idx. | ||
5 | Move an endif down to make the definition in helper.c be | ||
6 | system only. | ||
7 | |||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220604040607.269301-2-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/internals.h | 5 +++++ | ||
14 | target/arm/helper.c | 5 ++--- | ||
15 | 2 files changed, 7 insertions(+), 3 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/internals.h | ||
20 | +++ b/target/arm/internals.h | ||
21 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env); | ||
22 | * Return the ARMMMUIdx for the stage1 traversal for the current regime. | ||
23 | */ | ||
24 | #ifdef CONFIG_USER_ONLY | ||
25 | +static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) | ||
26 | +{ | ||
27 | + return ARMMMUIdx_Stage1_E0; | ||
28 | +} | ||
29 | static inline ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | ||
30 | { | ||
31 | return ARMMMUIdx_Stage1_E0; | ||
32 | } | ||
33 | #else | ||
34 | +ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx); | ||
35 | ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env); | ||
36 | #endif | ||
37 | |||
38 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/helper.c | ||
41 | +++ b/target/arm/helper.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
43 | } | ||
44 | } | ||
45 | |||
46 | -#endif /* !CONFIG_USER_ONLY */ | ||
47 | - | ||
48 | /* Convert a possible stage1+2 MMU index into the appropriate | ||
49 | * stage 1 MMU index | ||
50 | */ | ||
51 | -static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) | ||
52 | +ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) | ||
53 | { | ||
54 | switch (mmu_idx) { | ||
55 | case ARMMMUIdx_SE10_0: | ||
56 | @@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) | ||
57 | return mmu_idx; | ||
58 | } | ||
59 | } | ||
60 | +#endif /* !CONFIG_USER_ONLY */ | ||
61 | |||
62 | /* Return true if the translation regime is using LPAE format page tables */ | ||
63 | static inline bool regime_using_lpae_format(CPUARMState *env, | ||
64 | -- | ||
65 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Begin moving all of the page table walking functions | ||
4 | out of helper.c, starting with get_phys_addr(). | ||
5 | |||
6 | Create a temporary header file, "ptw.h", in which to | ||
7 | share declarations between the two C files while we | ||
8 | are moving functions. | ||
9 | |||
10 | Move a few declarations to "internals.h", which will | ||
11 | remain used by multiple C files. | ||
12 | |||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20220604040607.269301-3-richard.henderson@linaro.org | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | target/arm/internals.h | 18 ++- | ||
19 | target/arm/ptw.h | 51 ++++++ | ||
20 | target/arm/helper.c | 344 +++++------------------------------------ | ||
21 | target/arm/ptw.c | 267 ++++++++++++++++++++++++++++++++ | ||
22 | target/arm/meson.build | 1 + | ||
23 | 5 files changed, 372 insertions(+), 309 deletions(-) | ||
24 | create mode 100644 target/arm/ptw.h | ||
25 | create mode 100644 target/arm/ptw.c | ||
26 | |||
27 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/internals.h | ||
30 | +++ b/target/arm/internals.h | ||
31 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
32 | /* Return the MMU index for a v7M CPU in the specified security state */ | ||
33 | ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate); | ||
34 | |||
35 | -/* Return true if the stage 1 translation regime is using LPAE format page | ||
36 | - * tables */ | ||
37 | +/* Return true if the translation regime is using LPAE format page tables */ | ||
38 | +bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
39 | + | ||
40 | +/* | ||
41 | + * Return true if the stage 1 translation regime is using LPAE | ||
42 | + * format page tables | ||
43 | + */ | ||
44 | bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
45 | |||
46 | /* Raise a data fault alignment exception for the specified virtual address */ | ||
47 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
48 | } | ||
49 | } | ||
50 | |||
51 | +/* Return the SCTLR value which controls this address translation regime */ | ||
52 | +static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
53 | +{ | ||
54 | + return env->cp15.sctlr_el[regime_el(env, mmu_idx)]; | ||
55 | +} | ||
56 | + | ||
57 | /* Return the TCR controlling this translation regime */ | ||
58 | static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
59 | { | ||
60 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMVAParameters { | ||
61 | ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
62 | ARMMMUIdx mmu_idx, bool data); | ||
63 | |||
64 | +int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx); | ||
65 | +int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx); | ||
66 | + | ||
67 | static inline int exception_target_el(CPUARMState *env) | ||
68 | { | ||
69 | int target_el = MAX(1, arm_current_el(env)); | ||
70 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
71 | new file mode 100644 | ||
72 | index XXXXXXX..XXXXXXX | ||
73 | --- /dev/null | ||
74 | +++ b/target/arm/ptw.h | ||
75 | @@ -XXX,XX +XXX,XX @@ | ||
76 | +/* | ||
77 | + * ARM page table walking. | ||
78 | + * | ||
79 | + * This code is licensed under the GNU GPL v2 or later. | ||
80 | + * | ||
81 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
82 | + */ | ||
83 | + | ||
84 | +#ifndef TARGET_ARM_PTW_H | ||
85 | +#define TARGET_ARM_PTW_H | ||
86 | + | ||
87 | +#ifndef CONFIG_USER_ONLY | ||
88 | + | ||
89 | +bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
90 | +bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
91 | +ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
92 | + ARMCacheAttrs s1, ARMCacheAttrs s2); | ||
93 | + | ||
94 | +bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
95 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
96 | + hwaddr *phys_ptr, int *prot, | ||
97 | + target_ulong *page_size, | ||
98 | + ARMMMUFaultInfo *fi); | ||
99 | +bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
100 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
101 | + hwaddr *phys_ptr, int *prot, | ||
102 | + ARMMMUFaultInfo *fi); | ||
103 | +bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
104 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
105 | + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
106 | + target_ulong *page_size, ARMMMUFaultInfo *fi); | ||
107 | +bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
108 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
109 | + hwaddr *phys_ptr, int *prot, | ||
110 | + target_ulong *page_size, | ||
111 | + ARMMMUFaultInfo *fi); | ||
112 | +bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
113 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
114 | + hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
115 | + int *prot, target_ulong *page_size, | ||
116 | + ARMMMUFaultInfo *fi); | ||
117 | +bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
118 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
119 | + bool s1_is_el0, | ||
120 | + hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
121 | + target_ulong *page_size_ptr, | ||
122 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
123 | + __attribute__((nonnull)); | ||
124 | + | ||
125 | +#endif /* !CONFIG_USER_ONLY */ | ||
126 | +#endif /* TARGET_ARM_PTW_H */ | ||
127 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
128 | index XXXXXXX..XXXXXXX 100644 | ||
129 | --- a/target/arm/helper.c | ||
130 | +++ b/target/arm/helper.c | ||
131 | @@ -XXX,XX +XXX,XX @@ | ||
132 | #include "semihosting/common-semi.h" | ||
133 | #endif | ||
134 | #include "cpregs.h" | ||
135 | +#include "ptw.h" | ||
136 | |||
137 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ | ||
138 | |||
139 | -#ifndef CONFIG_USER_ONLY | ||
140 | - | ||
141 | -static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
142 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
143 | - bool s1_is_el0, | ||
144 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
145 | - target_ulong *page_size_ptr, | ||
146 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
147 | - __attribute__((nonnull)); | ||
148 | -#endif | ||
149 | - | ||
150 | static void switch_mode(CPUARMState *env, int mode); | ||
151 | -static int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx); | ||
152 | |||
153 | static uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
154 | { | ||
155 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_sctlr(CPUARMState *env, int el) | ||
156 | return env->cp15.sctlr_el[el]; | ||
157 | } | ||
158 | |||
159 | -/* Return the SCTLR value which controls this address translation regime */ | ||
160 | -static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
161 | -{ | ||
162 | - return env->cp15.sctlr_el[regime_el(env, mmu_idx)]; | ||
163 | -} | ||
164 | - | ||
165 | #ifndef CONFIG_USER_ONLY | ||
166 | |||
167 | /* Return true if the specified stage of address translation is disabled */ | ||
168 | -static inline bool regime_translation_disabled(CPUARMState *env, | ||
169 | - ARMMMUIdx mmu_idx) | ||
170 | +bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
171 | { | ||
172 | uint64_t hcr_el2; | ||
173 | |||
174 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) | ||
175 | #endif /* !CONFIG_USER_ONLY */ | ||
176 | |||
177 | /* Return true if the translation regime is using LPAE format page tables */ | ||
178 | -static inline bool regime_using_lpae_format(CPUARMState *env, | ||
179 | - ARMMMUIdx mmu_idx) | ||
180 | +bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
181 | { | ||
182 | int el = regime_el(env, mmu_idx); | ||
183 | if (el == 2 || arm_el_is_aa64(env, el)) { | ||
184 | @@ -XXX,XX +XXX,XX @@ bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
185 | } | ||
186 | |||
187 | #ifndef CONFIG_USER_ONLY | ||
188 | -static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
189 | +bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
190 | { | ||
191 | switch (mmu_idx) { | ||
192 | case ARMMMUIdx_SE10_0: | ||
193 | @@ -XXX,XX +XXX,XX @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
194 | return 0; | ||
195 | } | ||
196 | |||
197 | -static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
198 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
199 | - hwaddr *phys_ptr, int *prot, | ||
200 | - target_ulong *page_size, | ||
201 | - ARMMMUFaultInfo *fi) | ||
202 | +bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
203 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
204 | + hwaddr *phys_ptr, int *prot, | ||
205 | + target_ulong *page_size, | ||
206 | + ARMMMUFaultInfo *fi) | ||
207 | { | ||
208 | CPUState *cs = env_cpu(env); | ||
209 | int level = 1; | ||
210 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
211 | return true; | ||
212 | } | ||
213 | |||
214 | -static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
215 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
216 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
217 | - target_ulong *page_size, ARMMMUFaultInfo *fi) | ||
218 | +bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
219 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
220 | + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
221 | + target_ulong *page_size, ARMMMUFaultInfo *fi) | ||
222 | { | ||
223 | CPUState *cs = env_cpu(env); | ||
224 | ARMCPU *cpu = env_archcpu(env); | ||
225 | @@ -XXX,XX +XXX,XX @@ unsigned int arm_pamax(ARMCPU *cpu) | ||
226 | return pamax_map[parange]; | ||
227 | } | ||
228 | |||
229 | -static int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) | ||
230 | +int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) | ||
231 | { | ||
232 | if (regime_has_2_ranges(mmu_idx)) { | ||
233 | return extract64(tcr, 37, 2); | ||
234 | @@ -XXX,XX +XXX,XX @@ static int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) | ||
235 | } | ||
236 | } | ||
237 | |||
238 | -static int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx) | ||
239 | +int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx) | ||
240 | { | ||
241 | if (regime_has_2_ranges(mmu_idx)) { | ||
242 | return extract64(tcr, 51, 2); | ||
243 | @@ -XXX,XX +XXX,XX @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
244 | * @fi: set to fault info if the translation fails | ||
245 | * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | ||
246 | */ | ||
247 | -static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
248 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
249 | - bool s1_is_el0, | ||
250 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
251 | - target_ulong *page_size_ptr, | ||
252 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
253 | +bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
254 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
255 | + bool s1_is_el0, | ||
256 | + hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
257 | + target_ulong *page_size_ptr, | ||
258 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
259 | { | ||
260 | ARMCPU *cpu = env_archcpu(env); | ||
261 | CPUState *cs = CPU(cpu); | ||
262 | @@ -XXX,XX +XXX,XX @@ static inline bool m_is_system_region(CPUARMState *env, uint32_t address) | ||
263 | return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) == 0x7; | ||
264 | } | ||
265 | |||
266 | -static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
267 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
268 | - hwaddr *phys_ptr, int *prot, | ||
269 | - target_ulong *page_size, | ||
270 | - ARMMMUFaultInfo *fi) | ||
271 | +bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
272 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
273 | + hwaddr *phys_ptr, int *prot, | ||
274 | + target_ulong *page_size, | ||
275 | + ARMMMUFaultInfo *fi) | ||
276 | { | ||
277 | ARMCPU *cpu = env_archcpu(env); | ||
278 | int n; | ||
279 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
280 | } | ||
281 | |||
282 | |||
283 | -static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
284 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
285 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
286 | - int *prot, target_ulong *page_size, | ||
287 | - ARMMMUFaultInfo *fi) | ||
288 | +bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
289 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
290 | + hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
291 | + int *prot, target_ulong *page_size, | ||
292 | + ARMMMUFaultInfo *fi) | ||
293 | { | ||
294 | uint32_t secure = regime_is_secure(env, mmu_idx); | ||
295 | V8M_SAttributes sattrs = {}; | ||
296 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
297 | return ret; | ||
298 | } | ||
299 | |||
300 | -static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
301 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
302 | - hwaddr *phys_ptr, int *prot, | ||
303 | - ARMMMUFaultInfo *fi) | ||
304 | +bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
305 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
306 | + hwaddr *phys_ptr, int *prot, | ||
307 | + ARMMMUFaultInfo *fi) | ||
308 | { | ||
309 | int n; | ||
310 | uint32_t mask; | ||
311 | @@ -XXX,XX +XXX,XX @@ static uint8_t combined_attrs_fwb(CPUARMState *env, | ||
312 | * @s1: Attributes from stage 1 walk | ||
313 | * @s2: Attributes from stage 2 walk | ||
314 | */ | ||
315 | -static ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
316 | - ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
317 | +ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
318 | + ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
319 | { | ||
320 | ARMCacheAttrs ret; | ||
321 | bool tagged = false; | ||
322 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
323 | return ret; | ||
324 | } | ||
325 | |||
326 | - | ||
327 | -/* get_phys_addr - get the physical address for this virtual address | ||
328 | - * | ||
329 | - * Find the physical address corresponding to the given virtual address, | ||
330 | - * by doing a translation table walk on MMU based systems or using the | ||
331 | - * MPU state on MPU based systems. | ||
332 | - * | ||
333 | - * Returns false if the translation was successful. Otherwise, phys_ptr, attrs, | ||
334 | - * prot and page_size may not be filled in, and the populated fsr value provides | ||
335 | - * information on why the translation aborted, in the format of a | ||
336 | - * DFSR/IFSR fault register, with the following caveats: | ||
337 | - * * we honour the short vs long DFSR format differences. | ||
338 | - * * the WnR bit is never set (the caller must do this). | ||
339 | - * * for PSMAv5 based systems we don't bother to return a full FSR format | ||
340 | - * value. | ||
341 | - * | ||
342 | - * @env: CPUARMState | ||
343 | - * @address: virtual address to get physical address for | ||
344 | - * @access_type: 0 for read, 1 for write, 2 for execute | ||
345 | - * @mmu_idx: MMU index indicating required translation regime | ||
346 | - * @phys_ptr: set to the physical address corresponding to the virtual address | ||
347 | - * @attrs: set to the memory transaction attributes to use | ||
348 | - * @prot: set to the permissions for the page containing phys_ptr | ||
349 | - * @page_size: set to the size of the page containing phys_ptr | ||
350 | - * @fi: set to fault info if the translation fails | ||
351 | - * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | ||
352 | - */ | ||
353 | -bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
354 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
355 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
356 | - target_ulong *page_size, | ||
357 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
358 | -{ | ||
359 | - ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx); | ||
360 | - | ||
361 | - if (mmu_idx != s1_mmu_idx) { | ||
362 | - /* Call ourselves recursively to do the stage 1 and then stage 2 | ||
363 | - * translations if mmu_idx is a two-stage regime. | ||
364 | - */ | ||
365 | - if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
366 | - hwaddr ipa; | ||
367 | - int s2_prot; | ||
368 | - int ret; | ||
369 | - bool ipa_secure; | ||
370 | - ARMCacheAttrs cacheattrs2 = {}; | ||
371 | - ARMMMUIdx s2_mmu_idx; | ||
372 | - bool is_el0; | ||
373 | - | ||
374 | - ret = get_phys_addr(env, address, access_type, s1_mmu_idx, &ipa, | ||
375 | - attrs, prot, page_size, fi, cacheattrs); | ||
376 | - | ||
377 | - /* If S1 fails or S2 is disabled, return early. */ | ||
378 | - if (ret || regime_translation_disabled(env, ARMMMUIdx_Stage2)) { | ||
379 | - *phys_ptr = ipa; | ||
380 | - return ret; | ||
381 | - } | ||
382 | - | ||
383 | - ipa_secure = attrs->secure; | ||
384 | - if (arm_is_secure_below_el3(env)) { | ||
385 | - if (ipa_secure) { | ||
386 | - attrs->secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW); | ||
387 | - } else { | ||
388 | - attrs->secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW); | ||
389 | - } | ||
390 | - } else { | ||
391 | - assert(!ipa_secure); | ||
392 | - } | ||
393 | - | ||
394 | - s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; | ||
395 | - is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0; | ||
396 | - | ||
397 | - /* S1 is done. Now do S2 translation. */ | ||
398 | - ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, is_el0, | ||
399 | - phys_ptr, attrs, &s2_prot, | ||
400 | - page_size, fi, &cacheattrs2); | ||
401 | - fi->s2addr = ipa; | ||
402 | - /* Combine the S1 and S2 perms. */ | ||
403 | - *prot &= s2_prot; | ||
404 | - | ||
405 | - /* If S2 fails, return early. */ | ||
406 | - if (ret) { | ||
407 | - return ret; | ||
408 | - } | ||
409 | - | ||
410 | - /* Combine the S1 and S2 cache attributes. */ | ||
411 | - if (arm_hcr_el2_eff(env) & HCR_DC) { | ||
412 | - /* | ||
413 | - * HCR.DC forces the first stage attributes to | ||
414 | - * Normal Non-Shareable, | ||
415 | - * Inner Write-Back Read-Allocate Write-Allocate, | ||
416 | - * Outer Write-Back Read-Allocate Write-Allocate. | ||
417 | - * Do not overwrite Tagged within attrs. | ||
418 | - */ | ||
419 | - if (cacheattrs->attrs != 0xf0) { | ||
420 | - cacheattrs->attrs = 0xff; | ||
421 | - } | ||
422 | - cacheattrs->shareability = 0; | ||
423 | - } | ||
424 | - *cacheattrs = combine_cacheattrs(env, *cacheattrs, cacheattrs2); | ||
425 | - | ||
426 | - /* Check if IPA translates to secure or non-secure PA space. */ | ||
427 | - if (arm_is_secure_below_el3(env)) { | ||
428 | - if (ipa_secure) { | ||
429 | - attrs->secure = | ||
430 | - !(env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW)); | ||
431 | - } else { | ||
432 | - attrs->secure = | ||
433 | - !((env->cp15.vtcr_el2.raw_tcr & (VTCR_NSA | VTCR_NSW)) | ||
434 | - || (env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW))); | ||
435 | - } | ||
436 | - } | ||
437 | - return 0; | ||
438 | - } else { | ||
439 | - /* | ||
440 | - * For non-EL2 CPUs a stage1+stage2 translation is just stage 1. | ||
441 | - */ | ||
442 | - mmu_idx = stage_1_mmu_idx(mmu_idx); | ||
443 | - } | ||
444 | - } | ||
445 | - | ||
446 | - /* The page table entries may downgrade secure to non-secure, but | ||
447 | - * cannot upgrade an non-secure translation regime's attributes | ||
448 | - * to secure. | ||
449 | - */ | ||
450 | - attrs->secure = regime_is_secure(env, mmu_idx); | ||
451 | - attrs->user = regime_is_user(env, mmu_idx); | ||
452 | - | ||
453 | - /* Fast Context Switch Extension. This doesn't exist at all in v8. | ||
454 | - * In v7 and earlier it affects all stage 1 translations. | ||
455 | - */ | ||
456 | - if (address < 0x02000000 && mmu_idx != ARMMMUIdx_Stage2 | ||
457 | - && !arm_feature(env, ARM_FEATURE_V8)) { | ||
458 | - if (regime_el(env, mmu_idx) == 3) { | ||
459 | - address += env->cp15.fcseidr_s; | ||
460 | - } else { | ||
461 | - address += env->cp15.fcseidr_ns; | ||
462 | - } | ||
463 | - } | ||
464 | - | ||
465 | - if (arm_feature(env, ARM_FEATURE_PMSA)) { | ||
466 | - bool ret; | ||
467 | - *page_size = TARGET_PAGE_SIZE; | ||
468 | - | ||
469 | - if (arm_feature(env, ARM_FEATURE_V8)) { | ||
470 | - /* PMSAv8 */ | ||
471 | - ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx, | ||
472 | - phys_ptr, attrs, prot, page_size, fi); | ||
473 | - } else if (arm_feature(env, ARM_FEATURE_V7)) { | ||
474 | - /* PMSAv7 */ | ||
475 | - ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, | ||
476 | - phys_ptr, prot, page_size, fi); | ||
477 | - } else { | ||
478 | - /* Pre-v7 MPU */ | ||
479 | - ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx, | ||
480 | - phys_ptr, prot, fi); | ||
481 | - } | ||
482 | - qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32 | ||
483 | - " mmu_idx %u -> %s (prot %c%c%c)\n", | ||
484 | - access_type == MMU_DATA_LOAD ? "reading" : | ||
485 | - (access_type == MMU_DATA_STORE ? "writing" : "execute"), | ||
486 | - (uint32_t)address, mmu_idx, | ||
487 | - ret ? "Miss" : "Hit", | ||
488 | - *prot & PAGE_READ ? 'r' : '-', | ||
489 | - *prot & PAGE_WRITE ? 'w' : '-', | ||
490 | - *prot & PAGE_EXEC ? 'x' : '-'); | ||
491 | - | ||
492 | - return ret; | ||
493 | - } | ||
494 | - | ||
495 | - /* Definitely a real MMU, not an MPU */ | ||
496 | - | ||
497 | - if (regime_translation_disabled(env, mmu_idx)) { | ||
498 | - uint64_t hcr; | ||
499 | - uint8_t memattr; | ||
500 | - | ||
501 | - /* | ||
502 | - * MMU disabled. S1 addresses within aa64 translation regimes are | ||
503 | - * still checked for bounds -- see AArch64.TranslateAddressS1Off. | ||
504 | - */ | ||
505 | - if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) { | ||
506 | - int r_el = regime_el(env, mmu_idx); | ||
507 | - if (arm_el_is_aa64(env, r_el)) { | ||
508 | - int pamax = arm_pamax(env_archcpu(env)); | ||
509 | - uint64_t tcr = env->cp15.tcr_el[r_el].raw_tcr; | ||
510 | - int addrtop, tbi; | ||
511 | - | ||
512 | - tbi = aa64_va_parameter_tbi(tcr, mmu_idx); | ||
513 | - if (access_type == MMU_INST_FETCH) { | ||
514 | - tbi &= ~aa64_va_parameter_tbid(tcr, mmu_idx); | ||
515 | - } | ||
516 | - tbi = (tbi >> extract64(address, 55, 1)) & 1; | ||
517 | - addrtop = (tbi ? 55 : 63); | ||
518 | - | ||
519 | - if (extract64(address, pamax, addrtop - pamax + 1) != 0) { | ||
520 | - fi->type = ARMFault_AddressSize; | ||
521 | - fi->level = 0; | ||
522 | - fi->stage2 = false; | ||
523 | - return 1; | ||
524 | - } | ||
525 | - | ||
526 | - /* | ||
527 | - * When TBI is disabled, we've just validated that all of the | ||
528 | - * bits above PAMax are zero, so logically we only need to | ||
529 | - * clear the top byte for TBI. But it's clearer to follow | ||
530 | - * the pseudocode set of addrdesc.paddress. | ||
531 | - */ | ||
532 | - address = extract64(address, 0, 52); | ||
533 | - } | ||
534 | - } | ||
535 | - *phys_ptr = address; | ||
536 | - *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | ||
537 | - *page_size = TARGET_PAGE_SIZE; | ||
538 | - | ||
539 | - /* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */ | ||
540 | - hcr = arm_hcr_el2_eff(env); | ||
541 | - cacheattrs->shareability = 0; | ||
542 | - cacheattrs->is_s2_format = false; | ||
543 | - if (hcr & HCR_DC) { | ||
544 | - if (hcr & HCR_DCT) { | ||
545 | - memattr = 0xf0; /* Tagged, Normal, WB, RWA */ | ||
546 | - } else { | ||
547 | - memattr = 0xff; /* Normal, WB, RWA */ | ||
548 | - } | ||
549 | - } else if (access_type == MMU_INST_FETCH) { | ||
550 | - if (regime_sctlr(env, mmu_idx) & SCTLR_I) { | ||
551 | - memattr = 0xee; /* Normal, WT, RA, NT */ | ||
552 | - } else { | ||
553 | - memattr = 0x44; /* Normal, NC, No */ | ||
554 | - } | ||
555 | - cacheattrs->shareability = 2; /* outer sharable */ | ||
556 | - } else { | ||
557 | - memattr = 0x00; /* Device, nGnRnE */ | ||
558 | - } | ||
559 | - cacheattrs->attrs = memattr; | ||
560 | - return 0; | ||
561 | - } | ||
562 | - | ||
563 | - if (regime_using_lpae_format(env, mmu_idx)) { | ||
564 | - return get_phys_addr_lpae(env, address, access_type, mmu_idx, false, | ||
565 | - phys_ptr, attrs, prot, page_size, | ||
566 | - fi, cacheattrs); | ||
567 | - } else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) { | ||
568 | - return get_phys_addr_v6(env, address, access_type, mmu_idx, | ||
569 | - phys_ptr, attrs, prot, page_size, fi); | ||
570 | - } else { | ||
571 | - return get_phys_addr_v5(env, address, access_type, mmu_idx, | ||
572 | - phys_ptr, prot, page_size, fi); | ||
573 | - } | ||
574 | -} | ||
575 | - | ||
576 | hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, | ||
577 | MemTxAttrs *attrs) | ||
578 | { | ||
579 | @@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, | ||
580 | } | ||
581 | return phys_addr; | ||
582 | } | ||
583 | - | ||
584 | #endif | ||
585 | |||
586 | /* Note that signed overflow is undefined in C. The following routines are | ||
587 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
588 | new file mode 100644 | ||
589 | index XXXXXXX..XXXXXXX | ||
590 | --- /dev/null | ||
591 | +++ b/target/arm/ptw.c | ||
592 | @@ -XXX,XX +XXX,XX @@ | ||
593 | +/* | ||
594 | + * ARM page table walking. | ||
595 | + * | ||
596 | + * This code is licensed under the GNU GPL v2 or later. | ||
597 | + * | ||
598 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
599 | + */ | ||
600 | + | ||
601 | +#include "qemu/osdep.h" | ||
602 | +#include "qemu/log.h" | ||
603 | +#include "cpu.h" | ||
604 | +#include "internals.h" | ||
605 | +#include "ptw.h" | ||
606 | + | ||
607 | + | ||
608 | +/** | ||
609 | + * get_phys_addr - get the physical address for this virtual address | ||
610 | + * | ||
611 | + * Find the physical address corresponding to the given virtual address, | ||
612 | + * by doing a translation table walk on MMU based systems or using the | ||
613 | + * MPU state on MPU based systems. | ||
614 | + * | ||
615 | + * Returns false if the translation was successful. Otherwise, phys_ptr, attrs, | ||
616 | + * prot and page_size may not be filled in, and the populated fsr value provides | ||
617 | + * information on why the translation aborted, in the format of a | ||
618 | + * DFSR/IFSR fault register, with the following caveats: | ||
619 | + * * we honour the short vs long DFSR format differences. | ||
620 | + * * the WnR bit is never set (the caller must do this). | ||
621 | + * * for PSMAv5 based systems we don't bother to return a full FSR format | ||
622 | + * value. | ||
623 | + * | ||
624 | + * @env: CPUARMState | ||
625 | + * @address: virtual address to get physical address for | ||
626 | + * @access_type: 0 for read, 1 for write, 2 for execute | ||
627 | + * @mmu_idx: MMU index indicating required translation regime | ||
628 | + * @phys_ptr: set to the physical address corresponding to the virtual address | ||
629 | + * @attrs: set to the memory transaction attributes to use | ||
630 | + * @prot: set to the permissions for the page containing phys_ptr | ||
631 | + * @page_size: set to the size of the page containing phys_ptr | ||
632 | + * @fi: set to fault info if the translation fails | ||
633 | + * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | ||
634 | + */ | ||
635 | +bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
636 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
637 | + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
638 | + target_ulong *page_size, | ||
639 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
640 | +{ | ||
641 | + ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx); | ||
642 | + | ||
643 | + if (mmu_idx != s1_mmu_idx) { | ||
644 | + /* | ||
645 | + * Call ourselves recursively to do the stage 1 and then stage 2 | ||
646 | + * translations if mmu_idx is a two-stage regime. | ||
647 | + */ | ||
648 | + if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
649 | + hwaddr ipa; | ||
650 | + int s2_prot; | ||
651 | + int ret; | ||
652 | + bool ipa_secure; | ||
653 | + ARMCacheAttrs cacheattrs2 = {}; | ||
654 | + ARMMMUIdx s2_mmu_idx; | ||
655 | + bool is_el0; | ||
656 | + | ||
657 | + ret = get_phys_addr(env, address, access_type, s1_mmu_idx, &ipa, | ||
658 | + attrs, prot, page_size, fi, cacheattrs); | ||
659 | + | ||
660 | + /* If S1 fails or S2 is disabled, return early. */ | ||
661 | + if (ret || regime_translation_disabled(env, ARMMMUIdx_Stage2)) { | ||
662 | + *phys_ptr = ipa; | ||
663 | + return ret; | ||
664 | + } | ||
665 | + | ||
666 | + ipa_secure = attrs->secure; | ||
667 | + if (arm_is_secure_below_el3(env)) { | ||
668 | + if (ipa_secure) { | ||
669 | + attrs->secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW); | ||
670 | + } else { | ||
671 | + attrs->secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW); | ||
672 | + } | ||
673 | + } else { | ||
674 | + assert(!ipa_secure); | ||
675 | + } | ||
676 | + | ||
677 | + s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; | ||
678 | + is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0; | ||
679 | + | ||
680 | + /* S1 is done. Now do S2 translation. */ | ||
681 | + ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, is_el0, | ||
682 | + phys_ptr, attrs, &s2_prot, | ||
683 | + page_size, fi, &cacheattrs2); | ||
684 | + fi->s2addr = ipa; | ||
685 | + /* Combine the S1 and S2 perms. */ | ||
686 | + *prot &= s2_prot; | ||
687 | + | ||
688 | + /* If S2 fails, return early. */ | ||
689 | + if (ret) { | ||
690 | + return ret; | ||
691 | + } | ||
692 | + | ||
693 | + /* Combine the S1 and S2 cache attributes. */ | ||
694 | + if (arm_hcr_el2_eff(env) & HCR_DC) { | ||
695 | + /* | ||
696 | + * HCR.DC forces the first stage attributes to | ||
697 | + * Normal Non-Shareable, | ||
698 | + * Inner Write-Back Read-Allocate Write-Allocate, | ||
699 | + * Outer Write-Back Read-Allocate Write-Allocate. | ||
700 | + * Do not overwrite Tagged within attrs. | ||
701 | + */ | ||
702 | + if (cacheattrs->attrs != 0xf0) { | ||
703 | + cacheattrs->attrs = 0xff; | ||
704 | + } | ||
705 | + cacheattrs->shareability = 0; | ||
706 | + } | ||
707 | + *cacheattrs = combine_cacheattrs(env, *cacheattrs, cacheattrs2); | ||
708 | + | ||
709 | + /* Check if IPA translates to secure or non-secure PA space. */ | ||
710 | + if (arm_is_secure_below_el3(env)) { | ||
711 | + if (ipa_secure) { | ||
712 | + attrs->secure = | ||
713 | + !(env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW)); | ||
714 | + } else { | ||
715 | + attrs->secure = | ||
716 | + !((env->cp15.vtcr_el2.raw_tcr & (VTCR_NSA | VTCR_NSW)) | ||
717 | + || (env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW))); | ||
718 | + } | ||
719 | + } | ||
720 | + return 0; | ||
721 | + } else { | ||
722 | + /* | ||
723 | + * For non-EL2 CPUs a stage1+stage2 translation is just stage 1. | ||
724 | + */ | ||
725 | + mmu_idx = stage_1_mmu_idx(mmu_idx); | ||
726 | + } | ||
727 | + } | ||
728 | + | ||
729 | + /* | ||
730 | + * The page table entries may downgrade secure to non-secure, but | ||
731 | + * cannot upgrade an non-secure translation regime's attributes | ||
732 | + * to secure. | ||
733 | + */ | ||
734 | + attrs->secure = regime_is_secure(env, mmu_idx); | ||
735 | + attrs->user = regime_is_user(env, mmu_idx); | ||
736 | + | ||
737 | + /* | ||
738 | + * Fast Context Switch Extension. This doesn't exist at all in v8. | ||
739 | + * In v7 and earlier it affects all stage 1 translations. | ||
740 | + */ | ||
741 | + if (address < 0x02000000 && mmu_idx != ARMMMUIdx_Stage2 | ||
742 | + && !arm_feature(env, ARM_FEATURE_V8)) { | ||
743 | + if (regime_el(env, mmu_idx) == 3) { | ||
744 | + address += env->cp15.fcseidr_s; | ||
745 | + } else { | ||
746 | + address += env->cp15.fcseidr_ns; | ||
747 | + } | ||
748 | + } | ||
749 | + | ||
750 | + if (arm_feature(env, ARM_FEATURE_PMSA)) { | ||
751 | + bool ret; | ||
752 | + *page_size = TARGET_PAGE_SIZE; | ||
753 | + | ||
754 | + if (arm_feature(env, ARM_FEATURE_V8)) { | ||
755 | + /* PMSAv8 */ | ||
756 | + ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx, | ||
757 | + phys_ptr, attrs, prot, page_size, fi); | ||
758 | + } else if (arm_feature(env, ARM_FEATURE_V7)) { | ||
759 | + /* PMSAv7 */ | ||
760 | + ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, | ||
761 | + phys_ptr, prot, page_size, fi); | ||
762 | + } else { | ||
763 | + /* Pre-v7 MPU */ | ||
764 | + ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx, | ||
765 | + phys_ptr, prot, fi); | ||
766 | + } | ||
767 | + qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32 | ||
768 | + " mmu_idx %u -> %s (prot %c%c%c)\n", | ||
769 | + access_type == MMU_DATA_LOAD ? "reading" : | ||
770 | + (access_type == MMU_DATA_STORE ? "writing" : "execute"), | ||
771 | + (uint32_t)address, mmu_idx, | ||
772 | + ret ? "Miss" : "Hit", | ||
773 | + *prot & PAGE_READ ? 'r' : '-', | ||
774 | + *prot & PAGE_WRITE ? 'w' : '-', | ||
775 | + *prot & PAGE_EXEC ? 'x' : '-'); | ||
776 | + | ||
777 | + return ret; | ||
778 | + } | ||
779 | + | ||
780 | + /* Definitely a real MMU, not an MPU */ | ||
781 | + | ||
782 | + if (regime_translation_disabled(env, mmu_idx)) { | ||
783 | + uint64_t hcr; | ||
784 | + uint8_t memattr; | ||
785 | + | ||
786 | + /* | ||
787 | + * MMU disabled. S1 addresses within aa64 translation regimes are | ||
788 | + * still checked for bounds -- see AArch64.TranslateAddressS1Off. | ||
789 | + */ | ||
790 | + if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) { | ||
791 | + int r_el = regime_el(env, mmu_idx); | ||
792 | + if (arm_el_is_aa64(env, r_el)) { | ||
793 | + int pamax = arm_pamax(env_archcpu(env)); | ||
794 | + uint64_t tcr = env->cp15.tcr_el[r_el].raw_tcr; | ||
795 | + int addrtop, tbi; | ||
796 | + | ||
797 | + tbi = aa64_va_parameter_tbi(tcr, mmu_idx); | ||
798 | + if (access_type == MMU_INST_FETCH) { | ||
799 | + tbi &= ~aa64_va_parameter_tbid(tcr, mmu_idx); | ||
800 | + } | ||
801 | + tbi = (tbi >> extract64(address, 55, 1)) & 1; | ||
802 | + addrtop = (tbi ? 55 : 63); | ||
803 | + | ||
804 | + if (extract64(address, pamax, addrtop - pamax + 1) != 0) { | ||
805 | + fi->type = ARMFault_AddressSize; | ||
806 | + fi->level = 0; | ||
807 | + fi->stage2 = false; | ||
808 | + return 1; | ||
809 | + } | ||
810 | + | ||
811 | + /* | ||
812 | + * When TBI is disabled, we've just validated that all of the | ||
813 | + * bits above PAMax are zero, so logically we only need to | ||
814 | + * clear the top byte for TBI. But it's clearer to follow | ||
815 | + * the pseudocode set of addrdesc.paddress. | ||
816 | + */ | ||
817 | + address = extract64(address, 0, 52); | ||
818 | + } | ||
819 | + } | ||
820 | + *phys_ptr = address; | ||
821 | + *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | ||
822 | + *page_size = TARGET_PAGE_SIZE; | ||
823 | + | ||
824 | + /* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */ | ||
825 | + hcr = arm_hcr_el2_eff(env); | ||
826 | + cacheattrs->shareability = 0; | ||
827 | + cacheattrs->is_s2_format = false; | ||
828 | + if (hcr & HCR_DC) { | ||
829 | + if (hcr & HCR_DCT) { | ||
830 | + memattr = 0xf0; /* Tagged, Normal, WB, RWA */ | ||
831 | + } else { | ||
832 | + memattr = 0xff; /* Normal, WB, RWA */ | ||
833 | + } | ||
834 | + } else if (access_type == MMU_INST_FETCH) { | ||
835 | + if (regime_sctlr(env, mmu_idx) & SCTLR_I) { | ||
836 | + memattr = 0xee; /* Normal, WT, RA, NT */ | ||
837 | + } else { | ||
838 | + memattr = 0x44; /* Normal, NC, No */ | ||
839 | + } | ||
840 | + cacheattrs->shareability = 2; /* outer sharable */ | ||
841 | + } else { | ||
842 | + memattr = 0x00; /* Device, nGnRnE */ | ||
843 | + } | ||
844 | + cacheattrs->attrs = memattr; | ||
845 | + return 0; | ||
846 | + } | ||
847 | + | ||
848 | + if (regime_using_lpae_format(env, mmu_idx)) { | ||
849 | + return get_phys_addr_lpae(env, address, access_type, mmu_idx, false, | ||
850 | + phys_ptr, attrs, prot, page_size, | ||
851 | + fi, cacheattrs); | ||
852 | + } else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) { | ||
853 | + return get_phys_addr_v6(env, address, access_type, mmu_idx, | ||
854 | + phys_ptr, attrs, prot, page_size, fi); | ||
855 | + } else { | ||
856 | + return get_phys_addr_v5(env, address, access_type, mmu_idx, | ||
857 | + phys_ptr, prot, page_size, fi); | ||
858 | + } | ||
859 | +} | ||
860 | diff --git a/target/arm/meson.build b/target/arm/meson.build | ||
861 | index XXXXXXX..XXXXXXX 100644 | ||
862 | --- a/target/arm/meson.build | ||
863 | +++ b/target/arm/meson.build | ||
864 | @@ -XXX,XX +XXX,XX @@ arm_softmmu_ss.add(files( | ||
865 | 'machine.c', | ||
866 | 'monitor.c', | ||
867 | 'psci.c', | ||
868 | + 'ptw.c', | ||
869 | )) | ||
870 | |||
871 | subdir('hvf') | ||
872 | -- | ||
873 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-4-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 15 +++-- | ||
9 | target/arm/helper.c | 137 +++----------------------------------------- | ||
10 | target/arm/ptw.c | 123 +++++++++++++++++++++++++++++++++++++++ | ||
11 | 3 files changed, 140 insertions(+), 135 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | |||
19 | #ifndef CONFIG_USER_ONLY | ||
20 | |||
21 | +uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
22 | + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi); | ||
23 | +uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
24 | + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi); | ||
25 | + | ||
26 | bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
27 | bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
28 | ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
29 | ARMCacheAttrs s1, ARMCacheAttrs s2); | ||
30 | |||
31 | -bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
32 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
33 | - hwaddr *phys_ptr, int *prot, | ||
34 | - target_ulong *page_size, | ||
35 | - ARMMMUFaultInfo *fi); | ||
36 | +bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
37 | + uint32_t *table, uint32_t address); | ||
38 | +int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
39 | + int ap, int domain_prot); | ||
40 | + | ||
41 | bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
42 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
43 | hwaddr *phys_ptr, int *prot, | ||
44 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/helper.c | ||
47 | +++ b/target/arm/helper.c | ||
48 | @@ -XXX,XX +XXX,XX @@ bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
49 | * @ap: The 3-bit access permissions (AP[2:0]) | ||
50 | * @domain_prot: The 2-bit domain access permissions | ||
51 | */ | ||
52 | -static inline int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
53 | - int ap, int domain_prot) | ||
54 | +int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap, int domain_prot) | ||
55 | { | ||
56 | bool is_user = regime_is_user(env, mmu_idx); | ||
57 | |||
58 | @@ -XXX,XX +XXX,XX @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, | ||
59 | return prot_rw | PAGE_EXEC; | ||
60 | } | ||
61 | |||
62 | -static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
63 | - uint32_t *table, uint32_t address) | ||
64 | +bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
65 | + uint32_t *table, uint32_t address) | ||
66 | { | ||
67 | /* Note that we can only get here for an AArch32 PL0/PL1 lookup */ | ||
68 | TCR *tcr = regime_tcr(env, mmu_idx); | ||
69 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
70 | } | ||
71 | |||
72 | /* All loads done in the course of a page table walk go through here. */ | ||
73 | -static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
74 | - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) | ||
75 | +uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
76 | + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) | ||
77 | { | ||
78 | ARMCPU *cpu = ARM_CPU(cs); | ||
79 | CPUARMState *env = &cpu->env; | ||
80 | @@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | -static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
85 | - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) | ||
86 | +uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
87 | + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) | ||
88 | { | ||
89 | ARMCPU *cpu = ARM_CPU(cs); | ||
90 | CPUARMState *env = &cpu->env; | ||
91 | @@ -XXX,XX +XXX,XX @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | -bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
96 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
97 | - hwaddr *phys_ptr, int *prot, | ||
98 | - target_ulong *page_size, | ||
99 | - ARMMMUFaultInfo *fi) | ||
100 | -{ | ||
101 | - CPUState *cs = env_cpu(env); | ||
102 | - int level = 1; | ||
103 | - uint32_t table; | ||
104 | - uint32_t desc; | ||
105 | - int type; | ||
106 | - int ap; | ||
107 | - int domain = 0; | ||
108 | - int domain_prot; | ||
109 | - hwaddr phys_addr; | ||
110 | - uint32_t dacr; | ||
111 | - | ||
112 | - /* Pagetable walk. */ | ||
113 | - /* Lookup l1 descriptor. */ | ||
114 | - if (!get_level1_table_address(env, mmu_idx, &table, address)) { | ||
115 | - /* Section translation fault if page walk is disabled by PD0 or PD1 */ | ||
116 | - fi->type = ARMFault_Translation; | ||
117 | - goto do_fault; | ||
118 | - } | ||
119 | - desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
120 | - mmu_idx, fi); | ||
121 | - if (fi->type != ARMFault_None) { | ||
122 | - goto do_fault; | ||
123 | - } | ||
124 | - type = (desc & 3); | ||
125 | - domain = (desc >> 5) & 0x0f; | ||
126 | - if (regime_el(env, mmu_idx) == 1) { | ||
127 | - dacr = env->cp15.dacr_ns; | ||
128 | - } else { | ||
129 | - dacr = env->cp15.dacr_s; | ||
130 | - } | ||
131 | - domain_prot = (dacr >> (domain * 2)) & 3; | ||
132 | - if (type == 0) { | ||
133 | - /* Section translation fault. */ | ||
134 | - fi->type = ARMFault_Translation; | ||
135 | - goto do_fault; | ||
136 | - } | ||
137 | - if (type != 2) { | ||
138 | - level = 2; | ||
139 | - } | ||
140 | - if (domain_prot == 0 || domain_prot == 2) { | ||
141 | - fi->type = ARMFault_Domain; | ||
142 | - goto do_fault; | ||
143 | - } | ||
144 | - if (type == 2) { | ||
145 | - /* 1Mb section. */ | ||
146 | - phys_addr = (desc & 0xfff00000) | (address & 0x000fffff); | ||
147 | - ap = (desc >> 10) & 3; | ||
148 | - *page_size = 1024 * 1024; | ||
149 | - } else { | ||
150 | - /* Lookup l2 entry. */ | ||
151 | - if (type == 1) { | ||
152 | - /* Coarse pagetable. */ | ||
153 | - table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); | ||
154 | - } else { | ||
155 | - /* Fine pagetable. */ | ||
156 | - table = (desc & 0xfffff000) | ((address >> 8) & 0xffc); | ||
157 | - } | ||
158 | - desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
159 | - mmu_idx, fi); | ||
160 | - if (fi->type != ARMFault_None) { | ||
161 | - goto do_fault; | ||
162 | - } | ||
163 | - switch (desc & 3) { | ||
164 | - case 0: /* Page translation fault. */ | ||
165 | - fi->type = ARMFault_Translation; | ||
166 | - goto do_fault; | ||
167 | - case 1: /* 64k page. */ | ||
168 | - phys_addr = (desc & 0xffff0000) | (address & 0xffff); | ||
169 | - ap = (desc >> (4 + ((address >> 13) & 6))) & 3; | ||
170 | - *page_size = 0x10000; | ||
171 | - break; | ||
172 | - case 2: /* 4k page. */ | ||
173 | - phys_addr = (desc & 0xfffff000) | (address & 0xfff); | ||
174 | - ap = (desc >> (4 + ((address >> 9) & 6))) & 3; | ||
175 | - *page_size = 0x1000; | ||
176 | - break; | ||
177 | - case 3: /* 1k page, or ARMv6/XScale "extended small (4k) page" */ | ||
178 | - if (type == 1) { | ||
179 | - /* ARMv6/XScale extended small page format */ | ||
180 | - if (arm_feature(env, ARM_FEATURE_XSCALE) | ||
181 | - || arm_feature(env, ARM_FEATURE_V6)) { | ||
182 | - phys_addr = (desc & 0xfffff000) | (address & 0xfff); | ||
183 | - *page_size = 0x1000; | ||
184 | - } else { | ||
185 | - /* UNPREDICTABLE in ARMv5; we choose to take a | ||
186 | - * page translation fault. | ||
187 | - */ | ||
188 | - fi->type = ARMFault_Translation; | ||
189 | - goto do_fault; | ||
190 | - } | ||
191 | - } else { | ||
192 | - phys_addr = (desc & 0xfffffc00) | (address & 0x3ff); | ||
193 | - *page_size = 0x400; | ||
194 | - } | ||
195 | - ap = (desc >> 4) & 3; | ||
196 | - break; | ||
197 | - default: | ||
198 | - /* Never happens, but compiler isn't smart enough to tell. */ | ||
199 | - g_assert_not_reached(); | ||
200 | - } | ||
201 | - } | ||
202 | - *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); | ||
203 | - *prot |= *prot ? PAGE_EXEC : 0; | ||
204 | - if (!(*prot & (1 << access_type))) { | ||
205 | - /* Access permission fault. */ | ||
206 | - fi->type = ARMFault_Permission; | ||
207 | - goto do_fault; | ||
208 | - } | ||
209 | - *phys_ptr = phys_addr; | ||
210 | - return false; | ||
211 | -do_fault: | ||
212 | - fi->domain = domain; | ||
213 | - fi->level = level; | ||
214 | - return true; | ||
215 | -} | ||
216 | - | ||
217 | bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
218 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
219 | hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
220 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
221 | index XXXXXXX..XXXXXXX 100644 | ||
222 | --- a/target/arm/ptw.c | ||
223 | +++ b/target/arm/ptw.c | ||
224 | @@ -XXX,XX +XXX,XX @@ | ||
225 | #include "ptw.h" | ||
226 | |||
227 | |||
228 | +static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
229 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
230 | + hwaddr *phys_ptr, int *prot, | ||
231 | + target_ulong *page_size, | ||
232 | + ARMMMUFaultInfo *fi) | ||
233 | +{ | ||
234 | + CPUState *cs = env_cpu(env); | ||
235 | + int level = 1; | ||
236 | + uint32_t table; | ||
237 | + uint32_t desc; | ||
238 | + int type; | ||
239 | + int ap; | ||
240 | + int domain = 0; | ||
241 | + int domain_prot; | ||
242 | + hwaddr phys_addr; | ||
243 | + uint32_t dacr; | ||
244 | + | ||
245 | + /* Pagetable walk. */ | ||
246 | + /* Lookup l1 descriptor. */ | ||
247 | + if (!get_level1_table_address(env, mmu_idx, &table, address)) { | ||
248 | + /* Section translation fault if page walk is disabled by PD0 or PD1 */ | ||
249 | + fi->type = ARMFault_Translation; | ||
250 | + goto do_fault; | ||
251 | + } | ||
252 | + desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
253 | + mmu_idx, fi); | ||
254 | + if (fi->type != ARMFault_None) { | ||
255 | + goto do_fault; | ||
256 | + } | ||
257 | + type = (desc & 3); | ||
258 | + domain = (desc >> 5) & 0x0f; | ||
259 | + if (regime_el(env, mmu_idx) == 1) { | ||
260 | + dacr = env->cp15.dacr_ns; | ||
261 | + } else { | ||
262 | + dacr = env->cp15.dacr_s; | ||
263 | + } | ||
264 | + domain_prot = (dacr >> (domain * 2)) & 3; | ||
265 | + if (type == 0) { | ||
266 | + /* Section translation fault. */ | ||
267 | + fi->type = ARMFault_Translation; | ||
268 | + goto do_fault; | ||
269 | + } | ||
270 | + if (type != 2) { | ||
271 | + level = 2; | ||
272 | + } | ||
273 | + if (domain_prot == 0 || domain_prot == 2) { | ||
274 | + fi->type = ARMFault_Domain; | ||
275 | + goto do_fault; | ||
276 | + } | ||
277 | + if (type == 2) { | ||
278 | + /* 1Mb section. */ | ||
279 | + phys_addr = (desc & 0xfff00000) | (address & 0x000fffff); | ||
280 | + ap = (desc >> 10) & 3; | ||
281 | + *page_size = 1024 * 1024; | ||
282 | + } else { | ||
283 | + /* Lookup l2 entry. */ | ||
284 | + if (type == 1) { | ||
285 | + /* Coarse pagetable. */ | ||
286 | + table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); | ||
287 | + } else { | ||
288 | + /* Fine pagetable. */ | ||
289 | + table = (desc & 0xfffff000) | ((address >> 8) & 0xffc); | ||
290 | + } | ||
291 | + desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
292 | + mmu_idx, fi); | ||
293 | + if (fi->type != ARMFault_None) { | ||
294 | + goto do_fault; | ||
295 | + } | ||
296 | + switch (desc & 3) { | ||
297 | + case 0: /* Page translation fault. */ | ||
298 | + fi->type = ARMFault_Translation; | ||
299 | + goto do_fault; | ||
300 | + case 1: /* 64k page. */ | ||
301 | + phys_addr = (desc & 0xffff0000) | (address & 0xffff); | ||
302 | + ap = (desc >> (4 + ((address >> 13) & 6))) & 3; | ||
303 | + *page_size = 0x10000; | ||
304 | + break; | ||
305 | + case 2: /* 4k page. */ | ||
306 | + phys_addr = (desc & 0xfffff000) | (address & 0xfff); | ||
307 | + ap = (desc >> (4 + ((address >> 9) & 6))) & 3; | ||
308 | + *page_size = 0x1000; | ||
309 | + break; | ||
310 | + case 3: /* 1k page, or ARMv6/XScale "extended small (4k) page" */ | ||
311 | + if (type == 1) { | ||
312 | + /* ARMv6/XScale extended small page format */ | ||
313 | + if (arm_feature(env, ARM_FEATURE_XSCALE) | ||
314 | + || arm_feature(env, ARM_FEATURE_V6)) { | ||
315 | + phys_addr = (desc & 0xfffff000) | (address & 0xfff); | ||
316 | + *page_size = 0x1000; | ||
317 | + } else { | ||
318 | + /* | ||
319 | + * UNPREDICTABLE in ARMv5; we choose to take a | ||
320 | + * page translation fault. | ||
321 | + */ | ||
322 | + fi->type = ARMFault_Translation; | ||
323 | + goto do_fault; | ||
324 | + } | ||
325 | + } else { | ||
326 | + phys_addr = (desc & 0xfffffc00) | (address & 0x3ff); | ||
327 | + *page_size = 0x400; | ||
328 | + } | ||
329 | + ap = (desc >> 4) & 3; | ||
330 | + break; | ||
331 | + default: | ||
332 | + /* Never happens, but compiler isn't smart enough to tell. */ | ||
333 | + g_assert_not_reached(); | ||
334 | + } | ||
335 | + } | ||
336 | + *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); | ||
337 | + *prot |= *prot ? PAGE_EXEC : 0; | ||
338 | + if (!(*prot & (1 << access_type))) { | ||
339 | + /* Access permission fault. */ | ||
340 | + fi->type = ARMFault_Permission; | ||
341 | + goto do_fault; | ||
342 | + } | ||
343 | + *phys_ptr = phys_addr; | ||
344 | + return false; | ||
345 | +do_fault: | ||
346 | + fi->domain = domain; | ||
347 | + fi->level = level; | ||
348 | + return true; | ||
349 | +} | ||
350 | + | ||
351 | /** | ||
352 | * get_phys_addr - get the physical address for this virtual address | ||
353 | * | ||
354 | -- | ||
355 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-5-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 11 +-- | ||
9 | target/arm/helper.c | 161 +------------------------------------------- | ||
10 | target/arm/ptw.c | 153 +++++++++++++++++++++++++++++++++++++++++ | ||
11 | 3 files changed, 161 insertions(+), 164 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
18 | uint32_t *table, uint32_t address); | ||
19 | int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
20 | int ap, int domain_prot); | ||
21 | +int simple_ap_to_rw_prot_is_user(int ap, bool is_user); | ||
22 | + | ||
23 | +static inline int | ||
24 | +simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | ||
25 | +{ | ||
26 | + return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); | ||
27 | +} | ||
28 | |||
29 | bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
30 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
31 | hwaddr *phys_ptr, int *prot, | ||
32 | ARMMMUFaultInfo *fi); | ||
33 | -bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
34 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
35 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
36 | - target_ulong *page_size, ARMMMUFaultInfo *fi); | ||
37 | bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
38 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
39 | hwaddr *phys_ptr, int *prot, | ||
40 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/helper.c | ||
43 | +++ b/target/arm/helper.c | ||
44 | @@ -XXX,XX +XXX,XX @@ int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap, int domain_prot) | ||
45 | * @ap: The 2-bit simple AP (AP[2:1]) | ||
46 | * @is_user: TRUE if accessing from PL0 | ||
47 | */ | ||
48 | -static inline int simple_ap_to_rw_prot_is_user(int ap, bool is_user) | ||
49 | +int simple_ap_to_rw_prot_is_user(int ap, bool is_user) | ||
50 | { | ||
51 | switch (ap) { | ||
52 | case 0: | ||
53 | @@ -XXX,XX +XXX,XX @@ static inline int simple_ap_to_rw_prot_is_user(int ap, bool is_user) | ||
54 | } | ||
55 | } | ||
56 | |||
57 | -static inline int | ||
58 | -simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | ||
59 | -{ | ||
60 | - return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); | ||
61 | -} | ||
62 | - | ||
63 | /* Translate S2 section/page access permissions to protection flags | ||
64 | * | ||
65 | * @env: CPUARMState | ||
66 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | -bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
71 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
72 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
73 | - target_ulong *page_size, ARMMMUFaultInfo *fi) | ||
74 | -{ | ||
75 | - CPUState *cs = env_cpu(env); | ||
76 | - ARMCPU *cpu = env_archcpu(env); | ||
77 | - int level = 1; | ||
78 | - uint32_t table; | ||
79 | - uint32_t desc; | ||
80 | - uint32_t xn; | ||
81 | - uint32_t pxn = 0; | ||
82 | - int type; | ||
83 | - int ap; | ||
84 | - int domain = 0; | ||
85 | - int domain_prot; | ||
86 | - hwaddr phys_addr; | ||
87 | - uint32_t dacr; | ||
88 | - bool ns; | ||
89 | - | ||
90 | - /* Pagetable walk. */ | ||
91 | - /* Lookup l1 descriptor. */ | ||
92 | - if (!get_level1_table_address(env, mmu_idx, &table, address)) { | ||
93 | - /* Section translation fault if page walk is disabled by PD0 or PD1 */ | ||
94 | - fi->type = ARMFault_Translation; | ||
95 | - goto do_fault; | ||
96 | - } | ||
97 | - desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
98 | - mmu_idx, fi); | ||
99 | - if (fi->type != ARMFault_None) { | ||
100 | - goto do_fault; | ||
101 | - } | ||
102 | - type = (desc & 3); | ||
103 | - if (type == 0 || (type == 3 && !cpu_isar_feature(aa32_pxn, cpu))) { | ||
104 | - /* Section translation fault, or attempt to use the encoding | ||
105 | - * which is Reserved on implementations without PXN. | ||
106 | - */ | ||
107 | - fi->type = ARMFault_Translation; | ||
108 | - goto do_fault; | ||
109 | - } | ||
110 | - if ((type == 1) || !(desc & (1 << 18))) { | ||
111 | - /* Page or Section. */ | ||
112 | - domain = (desc >> 5) & 0x0f; | ||
113 | - } | ||
114 | - if (regime_el(env, mmu_idx) == 1) { | ||
115 | - dacr = env->cp15.dacr_ns; | ||
116 | - } else { | ||
117 | - dacr = env->cp15.dacr_s; | ||
118 | - } | ||
119 | - if (type == 1) { | ||
120 | - level = 2; | ||
121 | - } | ||
122 | - domain_prot = (dacr >> (domain * 2)) & 3; | ||
123 | - if (domain_prot == 0 || domain_prot == 2) { | ||
124 | - /* Section or Page domain fault */ | ||
125 | - fi->type = ARMFault_Domain; | ||
126 | - goto do_fault; | ||
127 | - } | ||
128 | - if (type != 1) { | ||
129 | - if (desc & (1 << 18)) { | ||
130 | - /* Supersection. */ | ||
131 | - phys_addr = (desc & 0xff000000) | (address & 0x00ffffff); | ||
132 | - phys_addr |= (uint64_t)extract32(desc, 20, 4) << 32; | ||
133 | - phys_addr |= (uint64_t)extract32(desc, 5, 4) << 36; | ||
134 | - *page_size = 0x1000000; | ||
135 | - } else { | ||
136 | - /* Section. */ | ||
137 | - phys_addr = (desc & 0xfff00000) | (address & 0x000fffff); | ||
138 | - *page_size = 0x100000; | ||
139 | - } | ||
140 | - ap = ((desc >> 10) & 3) | ((desc >> 13) & 4); | ||
141 | - xn = desc & (1 << 4); | ||
142 | - pxn = desc & 1; | ||
143 | - ns = extract32(desc, 19, 1); | ||
144 | - } else { | ||
145 | - if (cpu_isar_feature(aa32_pxn, cpu)) { | ||
146 | - pxn = (desc >> 2) & 1; | ||
147 | - } | ||
148 | - ns = extract32(desc, 3, 1); | ||
149 | - /* Lookup l2 entry. */ | ||
150 | - table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); | ||
151 | - desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
152 | - mmu_idx, fi); | ||
153 | - if (fi->type != ARMFault_None) { | ||
154 | - goto do_fault; | ||
155 | - } | ||
156 | - ap = ((desc >> 4) & 3) | ((desc >> 7) & 4); | ||
157 | - switch (desc & 3) { | ||
158 | - case 0: /* Page translation fault. */ | ||
159 | - fi->type = ARMFault_Translation; | ||
160 | - goto do_fault; | ||
161 | - case 1: /* 64k page. */ | ||
162 | - phys_addr = (desc & 0xffff0000) | (address & 0xffff); | ||
163 | - xn = desc & (1 << 15); | ||
164 | - *page_size = 0x10000; | ||
165 | - break; | ||
166 | - case 2: case 3: /* 4k page. */ | ||
167 | - phys_addr = (desc & 0xfffff000) | (address & 0xfff); | ||
168 | - xn = desc & 1; | ||
169 | - *page_size = 0x1000; | ||
170 | - break; | ||
171 | - default: | ||
172 | - /* Never happens, but compiler isn't smart enough to tell. */ | ||
173 | - g_assert_not_reached(); | ||
174 | - } | ||
175 | - } | ||
176 | - if (domain_prot == 3) { | ||
177 | - *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | ||
178 | - } else { | ||
179 | - if (pxn && !regime_is_user(env, mmu_idx)) { | ||
180 | - xn = 1; | ||
181 | - } | ||
182 | - if (xn && access_type == MMU_INST_FETCH) { | ||
183 | - fi->type = ARMFault_Permission; | ||
184 | - goto do_fault; | ||
185 | - } | ||
186 | - | ||
187 | - if (arm_feature(env, ARM_FEATURE_V6K) && | ||
188 | - (regime_sctlr(env, mmu_idx) & SCTLR_AFE)) { | ||
189 | - /* The simplified model uses AP[0] as an access control bit. */ | ||
190 | - if ((ap & 1) == 0) { | ||
191 | - /* Access flag fault. */ | ||
192 | - fi->type = ARMFault_AccessFlag; | ||
193 | - goto do_fault; | ||
194 | - } | ||
195 | - *prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1); | ||
196 | - } else { | ||
197 | - *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); | ||
198 | - } | ||
199 | - if (*prot && !xn) { | ||
200 | - *prot |= PAGE_EXEC; | ||
201 | - } | ||
202 | - if (!(*prot & (1 << access_type))) { | ||
203 | - /* Access permission fault. */ | ||
204 | - fi->type = ARMFault_Permission; | ||
205 | - goto do_fault; | ||
206 | - } | ||
207 | - } | ||
208 | - if (ns) { | ||
209 | - /* The NS bit will (as required by the architecture) have no effect if | ||
210 | - * the CPU doesn't support TZ or this is a non-secure translation | ||
211 | - * regime, because the attribute will already be non-secure. | ||
212 | - */ | ||
213 | - attrs->secure = false; | ||
214 | - } | ||
215 | - *phys_ptr = phys_addr; | ||
216 | - return false; | ||
217 | -do_fault: | ||
218 | - fi->domain = domain; | ||
219 | - fi->level = level; | ||
220 | - return true; | ||
221 | -} | ||
222 | - | ||
223 | /* | ||
224 | * check_s2_mmu_setup | ||
225 | * @cpu: ARMCPU | ||
226 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
227 | index XXXXXXX..XXXXXXX 100644 | ||
228 | --- a/target/arm/ptw.c | ||
229 | +++ b/target/arm/ptw.c | ||
230 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
231 | return true; | ||
232 | } | ||
233 | |||
234 | +static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
235 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
236 | + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
237 | + target_ulong *page_size, ARMMMUFaultInfo *fi) | ||
238 | +{ | ||
239 | + CPUState *cs = env_cpu(env); | ||
240 | + ARMCPU *cpu = env_archcpu(env); | ||
241 | + int level = 1; | ||
242 | + uint32_t table; | ||
243 | + uint32_t desc; | ||
244 | + uint32_t xn; | ||
245 | + uint32_t pxn = 0; | ||
246 | + int type; | ||
247 | + int ap; | ||
248 | + int domain = 0; | ||
249 | + int domain_prot; | ||
250 | + hwaddr phys_addr; | ||
251 | + uint32_t dacr; | ||
252 | + bool ns; | ||
253 | + | ||
254 | + /* Pagetable walk. */ | ||
255 | + /* Lookup l1 descriptor. */ | ||
256 | + if (!get_level1_table_address(env, mmu_idx, &table, address)) { | ||
257 | + /* Section translation fault if page walk is disabled by PD0 or PD1 */ | ||
258 | + fi->type = ARMFault_Translation; | ||
259 | + goto do_fault; | ||
260 | + } | ||
261 | + desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
262 | + mmu_idx, fi); | ||
263 | + if (fi->type != ARMFault_None) { | ||
264 | + goto do_fault; | ||
265 | + } | ||
266 | + type = (desc & 3); | ||
267 | + if (type == 0 || (type == 3 && !cpu_isar_feature(aa32_pxn, cpu))) { | ||
268 | + /* Section translation fault, or attempt to use the encoding | ||
269 | + * which is Reserved on implementations without PXN. | ||
270 | + */ | ||
271 | + fi->type = ARMFault_Translation; | ||
272 | + goto do_fault; | ||
273 | + } | ||
274 | + if ((type == 1) || !(desc & (1 << 18))) { | ||
275 | + /* Page or Section. */ | ||
276 | + domain = (desc >> 5) & 0x0f; | ||
277 | + } | ||
278 | + if (regime_el(env, mmu_idx) == 1) { | ||
279 | + dacr = env->cp15.dacr_ns; | ||
280 | + } else { | ||
281 | + dacr = env->cp15.dacr_s; | ||
282 | + } | ||
283 | + if (type == 1) { | ||
284 | + level = 2; | ||
285 | + } | ||
286 | + domain_prot = (dacr >> (domain * 2)) & 3; | ||
287 | + if (domain_prot == 0 || domain_prot == 2) { | ||
288 | + /* Section or Page domain fault */ | ||
289 | + fi->type = ARMFault_Domain; | ||
290 | + goto do_fault; | ||
291 | + } | ||
292 | + if (type != 1) { | ||
293 | + if (desc & (1 << 18)) { | ||
294 | + /* Supersection. */ | ||
295 | + phys_addr = (desc & 0xff000000) | (address & 0x00ffffff); | ||
296 | + phys_addr |= (uint64_t)extract32(desc, 20, 4) << 32; | ||
297 | + phys_addr |= (uint64_t)extract32(desc, 5, 4) << 36; | ||
298 | + *page_size = 0x1000000; | ||
299 | + } else { | ||
300 | + /* Section. */ | ||
301 | + phys_addr = (desc & 0xfff00000) | (address & 0x000fffff); | ||
302 | + *page_size = 0x100000; | ||
303 | + } | ||
304 | + ap = ((desc >> 10) & 3) | ((desc >> 13) & 4); | ||
305 | + xn = desc & (1 << 4); | ||
306 | + pxn = desc & 1; | ||
307 | + ns = extract32(desc, 19, 1); | ||
308 | + } else { | ||
309 | + if (cpu_isar_feature(aa32_pxn, cpu)) { | ||
310 | + pxn = (desc >> 2) & 1; | ||
311 | + } | ||
312 | + ns = extract32(desc, 3, 1); | ||
313 | + /* Lookup l2 entry. */ | ||
314 | + table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); | ||
315 | + desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
316 | + mmu_idx, fi); | ||
317 | + if (fi->type != ARMFault_None) { | ||
318 | + goto do_fault; | ||
319 | + } | ||
320 | + ap = ((desc >> 4) & 3) | ((desc >> 7) & 4); | ||
321 | + switch (desc & 3) { | ||
322 | + case 0: /* Page translation fault. */ | ||
323 | + fi->type = ARMFault_Translation; | ||
324 | + goto do_fault; | ||
325 | + case 1: /* 64k page. */ | ||
326 | + phys_addr = (desc & 0xffff0000) | (address & 0xffff); | ||
327 | + xn = desc & (1 << 15); | ||
328 | + *page_size = 0x10000; | ||
329 | + break; | ||
330 | + case 2: case 3: /* 4k page. */ | ||
331 | + phys_addr = (desc & 0xfffff000) | (address & 0xfff); | ||
332 | + xn = desc & 1; | ||
333 | + *page_size = 0x1000; | ||
334 | + break; | ||
335 | + default: | ||
336 | + /* Never happens, but compiler isn't smart enough to tell. */ | ||
337 | + g_assert_not_reached(); | ||
338 | + } | ||
339 | + } | ||
340 | + if (domain_prot == 3) { | ||
341 | + *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | ||
342 | + } else { | ||
343 | + if (pxn && !regime_is_user(env, mmu_idx)) { | ||
344 | + xn = 1; | ||
345 | + } | ||
346 | + if (xn && access_type == MMU_INST_FETCH) { | ||
347 | + fi->type = ARMFault_Permission; | ||
348 | + goto do_fault; | ||
349 | + } | ||
350 | + | ||
351 | + if (arm_feature(env, ARM_FEATURE_V6K) && | ||
352 | + (regime_sctlr(env, mmu_idx) & SCTLR_AFE)) { | ||
353 | + /* The simplified model uses AP[0] as an access control bit. */ | ||
354 | + if ((ap & 1) == 0) { | ||
355 | + /* Access flag fault. */ | ||
356 | + fi->type = ARMFault_AccessFlag; | ||
357 | + goto do_fault; | ||
358 | + } | ||
359 | + *prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1); | ||
360 | + } else { | ||
361 | + *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); | ||
362 | + } | ||
363 | + if (*prot && !xn) { | ||
364 | + *prot |= PAGE_EXEC; | ||
365 | + } | ||
366 | + if (!(*prot & (1 << access_type))) { | ||
367 | + /* Access permission fault. */ | ||
368 | + fi->type = ARMFault_Permission; | ||
369 | + goto do_fault; | ||
370 | + } | ||
371 | + } | ||
372 | + if (ns) { | ||
373 | + /* The NS bit will (as required by the architecture) have no effect if | ||
374 | + * the CPU doesn't support TZ or this is a non-secure translation | ||
375 | + * regime, because the attribute will already be non-secure. | ||
376 | + */ | ||
377 | + attrs->secure = false; | ||
378 | + } | ||
379 | + *phys_ptr = phys_addr; | ||
380 | + return false; | ||
381 | +do_fault: | ||
382 | + fi->domain = domain; | ||
383 | + fi->level = level; | ||
384 | + return true; | ||
385 | +} | ||
386 | + | ||
387 | /** | ||
388 | * get_phys_addr - get the physical address for this virtual address | ||
389 | * | ||
390 | -- | ||
391 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-6-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 4 --- | ||
9 | target/arm/helper.c | 85 --------------------------------------------- | ||
10 | target/arm/ptw.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ | ||
11 | 3 files changed, 85 insertions(+), 89 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | ||
18 | return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); | ||
19 | } | ||
20 | |||
21 | -bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
22 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
23 | - hwaddr *phys_ptr, int *prot, | ||
24 | - ARMMMUFaultInfo *fi); | ||
25 | bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
26 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
27 | hwaddr *phys_ptr, int *prot, | ||
28 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/helper.c | ||
31 | +++ b/target/arm/helper.c | ||
32 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
33 | return ret; | ||
34 | } | ||
35 | |||
36 | -bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
37 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
38 | - hwaddr *phys_ptr, int *prot, | ||
39 | - ARMMMUFaultInfo *fi) | ||
40 | -{ | ||
41 | - int n; | ||
42 | - uint32_t mask; | ||
43 | - uint32_t base; | ||
44 | - bool is_user = regime_is_user(env, mmu_idx); | ||
45 | - | ||
46 | - if (regime_translation_disabled(env, mmu_idx)) { | ||
47 | - /* MPU disabled. */ | ||
48 | - *phys_ptr = address; | ||
49 | - *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | ||
50 | - return false; | ||
51 | - } | ||
52 | - | ||
53 | - *phys_ptr = address; | ||
54 | - for (n = 7; n >= 0; n--) { | ||
55 | - base = env->cp15.c6_region[n]; | ||
56 | - if ((base & 1) == 0) { | ||
57 | - continue; | ||
58 | - } | ||
59 | - mask = 1 << ((base >> 1) & 0x1f); | ||
60 | - /* Keep this shift separate from the above to avoid an | ||
61 | - (undefined) << 32. */ | ||
62 | - mask = (mask << 1) - 1; | ||
63 | - if (((base ^ address) & ~mask) == 0) { | ||
64 | - break; | ||
65 | - } | ||
66 | - } | ||
67 | - if (n < 0) { | ||
68 | - fi->type = ARMFault_Background; | ||
69 | - return true; | ||
70 | - } | ||
71 | - | ||
72 | - if (access_type == MMU_INST_FETCH) { | ||
73 | - mask = env->cp15.pmsav5_insn_ap; | ||
74 | - } else { | ||
75 | - mask = env->cp15.pmsav5_data_ap; | ||
76 | - } | ||
77 | - mask = (mask >> (n * 4)) & 0xf; | ||
78 | - switch (mask) { | ||
79 | - case 0: | ||
80 | - fi->type = ARMFault_Permission; | ||
81 | - fi->level = 1; | ||
82 | - return true; | ||
83 | - case 1: | ||
84 | - if (is_user) { | ||
85 | - fi->type = ARMFault_Permission; | ||
86 | - fi->level = 1; | ||
87 | - return true; | ||
88 | - } | ||
89 | - *prot = PAGE_READ | PAGE_WRITE; | ||
90 | - break; | ||
91 | - case 2: | ||
92 | - *prot = PAGE_READ; | ||
93 | - if (!is_user) { | ||
94 | - *prot |= PAGE_WRITE; | ||
95 | - } | ||
96 | - break; | ||
97 | - case 3: | ||
98 | - *prot = PAGE_READ | PAGE_WRITE; | ||
99 | - break; | ||
100 | - case 5: | ||
101 | - if (is_user) { | ||
102 | - fi->type = ARMFault_Permission; | ||
103 | - fi->level = 1; | ||
104 | - return true; | ||
105 | - } | ||
106 | - *prot = PAGE_READ; | ||
107 | - break; | ||
108 | - case 6: | ||
109 | - *prot = PAGE_READ; | ||
110 | - break; | ||
111 | - default: | ||
112 | - /* Bad permission. */ | ||
113 | - fi->type = ARMFault_Permission; | ||
114 | - fi->level = 1; | ||
115 | - return true; | ||
116 | - } | ||
117 | - *prot |= PAGE_EXEC; | ||
118 | - return false; | ||
119 | -} | ||
120 | - | ||
121 | /* Combine either inner or outer cacheability attributes for normal | ||
122 | * memory, according to table D4-42 and pseudocode procedure | ||
123 | * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). | ||
124 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
125 | index XXXXXXX..XXXXXXX 100644 | ||
126 | --- a/target/arm/ptw.c | ||
127 | +++ b/target/arm/ptw.c | ||
128 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
129 | return true; | ||
130 | } | ||
131 | |||
132 | +static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
133 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
134 | + hwaddr *phys_ptr, int *prot, | ||
135 | + ARMMMUFaultInfo *fi) | ||
136 | +{ | ||
137 | + int n; | ||
138 | + uint32_t mask; | ||
139 | + uint32_t base; | ||
140 | + bool is_user = regime_is_user(env, mmu_idx); | ||
141 | + | ||
142 | + if (regime_translation_disabled(env, mmu_idx)) { | ||
143 | + /* MPU disabled. */ | ||
144 | + *phys_ptr = address; | ||
145 | + *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | ||
146 | + return false; | ||
147 | + } | ||
148 | + | ||
149 | + *phys_ptr = address; | ||
150 | + for (n = 7; n >= 0; n--) { | ||
151 | + base = env->cp15.c6_region[n]; | ||
152 | + if ((base & 1) == 0) { | ||
153 | + continue; | ||
154 | + } | ||
155 | + mask = 1 << ((base >> 1) & 0x1f); | ||
156 | + /* Keep this shift separate from the above to avoid an | ||
157 | + (undefined) << 32. */ | ||
158 | + mask = (mask << 1) - 1; | ||
159 | + if (((base ^ address) & ~mask) == 0) { | ||
160 | + break; | ||
161 | + } | ||
162 | + } | ||
163 | + if (n < 0) { | ||
164 | + fi->type = ARMFault_Background; | ||
165 | + return true; | ||
166 | + } | ||
167 | + | ||
168 | + if (access_type == MMU_INST_FETCH) { | ||
169 | + mask = env->cp15.pmsav5_insn_ap; | ||
170 | + } else { | ||
171 | + mask = env->cp15.pmsav5_data_ap; | ||
172 | + } | ||
173 | + mask = (mask >> (n * 4)) & 0xf; | ||
174 | + switch (mask) { | ||
175 | + case 0: | ||
176 | + fi->type = ARMFault_Permission; | ||
177 | + fi->level = 1; | ||
178 | + return true; | ||
179 | + case 1: | ||
180 | + if (is_user) { | ||
181 | + fi->type = ARMFault_Permission; | ||
182 | + fi->level = 1; | ||
183 | + return true; | ||
184 | + } | ||
185 | + *prot = PAGE_READ | PAGE_WRITE; | ||
186 | + break; | ||
187 | + case 2: | ||
188 | + *prot = PAGE_READ; | ||
189 | + if (!is_user) { | ||
190 | + *prot |= PAGE_WRITE; | ||
191 | + } | ||
192 | + break; | ||
193 | + case 3: | ||
194 | + *prot = PAGE_READ | PAGE_WRITE; | ||
195 | + break; | ||
196 | + case 5: | ||
197 | + if (is_user) { | ||
198 | + fi->type = ARMFault_Permission; | ||
199 | + fi->level = 1; | ||
200 | + return true; | ||
201 | + } | ||
202 | + *prot = PAGE_READ; | ||
203 | + break; | ||
204 | + case 6: | ||
205 | + *prot = PAGE_READ; | ||
206 | + break; | ||
207 | + default: | ||
208 | + /* Bad permission. */ | ||
209 | + fi->type = ARMFault_Permission; | ||
210 | + fi->level = 1; | ||
211 | + return true; | ||
212 | + } | ||
213 | + *prot |= PAGE_EXEC; | ||
214 | + return false; | ||
215 | +} | ||
216 | + | ||
217 | /** | ||
218 | * get_phys_addr - get the physical address for this virtual address | ||
219 | * | ||
220 | -- | ||
221 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-7-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 3 +++ | ||
9 | target/arm/helper.c | 41 ----------------------------------------- | ||
10 | target/arm/ptw.c | 41 +++++++++++++++++++++++++++++++++++++++++ | ||
11 | 3 files changed, 44 insertions(+), 41 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | ||
18 | return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); | ||
19 | } | ||
20 | |||
21 | +void get_phys_addr_pmsav7_default(CPUARMState *env, | ||
22 | + ARMMMUIdx mmu_idx, | ||
23 | + int32_t address, int *prot); | ||
24 | bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
25 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
26 | hwaddr *phys_ptr, int *prot, | ||
27 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/helper.c | ||
30 | +++ b/target/arm/helper.c | ||
31 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
32 | return true; | ||
33 | } | ||
34 | |||
35 | -static inline void get_phys_addr_pmsav7_default(CPUARMState *env, | ||
36 | - ARMMMUIdx mmu_idx, | ||
37 | - int32_t address, int *prot) | ||
38 | -{ | ||
39 | - if (!arm_feature(env, ARM_FEATURE_M)) { | ||
40 | - *prot = PAGE_READ | PAGE_WRITE; | ||
41 | - switch (address) { | ||
42 | - case 0xF0000000 ... 0xFFFFFFFF: | ||
43 | - if (regime_sctlr(env, mmu_idx) & SCTLR_V) { | ||
44 | - /* hivecs execing is ok */ | ||
45 | - *prot |= PAGE_EXEC; | ||
46 | - } | ||
47 | - break; | ||
48 | - case 0x00000000 ... 0x7FFFFFFF: | ||
49 | - *prot |= PAGE_EXEC; | ||
50 | - break; | ||
51 | - } | ||
52 | - } else { | ||
53 | - /* Default system address map for M profile cores. | ||
54 | - * The architecture specifies which regions are execute-never; | ||
55 | - * at the MPU level no other checks are defined. | ||
56 | - */ | ||
57 | - switch (address) { | ||
58 | - case 0x00000000 ... 0x1fffffff: /* ROM */ | ||
59 | - case 0x20000000 ... 0x3fffffff: /* SRAM */ | ||
60 | - case 0x60000000 ... 0x7fffffff: /* RAM */ | ||
61 | - case 0x80000000 ... 0x9fffffff: /* RAM */ | ||
62 | - *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | ||
63 | - break; | ||
64 | - case 0x40000000 ... 0x5fffffff: /* Peripheral */ | ||
65 | - case 0xa0000000 ... 0xbfffffff: /* Device */ | ||
66 | - case 0xc0000000 ... 0xdfffffff: /* Device */ | ||
67 | - case 0xe0000000 ... 0xffffffff: /* System */ | ||
68 | - *prot = PAGE_READ | PAGE_WRITE; | ||
69 | - break; | ||
70 | - default: | ||
71 | - g_assert_not_reached(); | ||
72 | - } | ||
73 | - } | ||
74 | -} | ||
75 | - | ||
76 | static bool pmsav7_use_background_region(ARMCPU *cpu, | ||
77 | ARMMMUIdx mmu_idx, bool is_user) | ||
78 | { | ||
79 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/target/arm/ptw.c | ||
82 | +++ b/target/arm/ptw.c | ||
83 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
84 | return false; | ||
85 | } | ||
86 | |||
87 | +void get_phys_addr_pmsav7_default(CPUARMState *env, | ||
88 | + ARMMMUIdx mmu_idx, | ||
89 | + int32_t address, int *prot) | ||
90 | +{ | ||
91 | + if (!arm_feature(env, ARM_FEATURE_M)) { | ||
92 | + *prot = PAGE_READ | PAGE_WRITE; | ||
93 | + switch (address) { | ||
94 | + case 0xF0000000 ... 0xFFFFFFFF: | ||
95 | + if (regime_sctlr(env, mmu_idx) & SCTLR_V) { | ||
96 | + /* hivecs execing is ok */ | ||
97 | + *prot |= PAGE_EXEC; | ||
98 | + } | ||
99 | + break; | ||
100 | + case 0x00000000 ... 0x7FFFFFFF: | ||
101 | + *prot |= PAGE_EXEC; | ||
102 | + break; | ||
103 | + } | ||
104 | + } else { | ||
105 | + /* Default system address map for M profile cores. | ||
106 | + * The architecture specifies which regions are execute-never; | ||
107 | + * at the MPU level no other checks are defined. | ||
108 | + */ | ||
109 | + switch (address) { | ||
110 | + case 0x00000000 ... 0x1fffffff: /* ROM */ | ||
111 | + case 0x20000000 ... 0x3fffffff: /* SRAM */ | ||
112 | + case 0x60000000 ... 0x7fffffff: /* RAM */ | ||
113 | + case 0x80000000 ... 0x9fffffff: /* RAM */ | ||
114 | + *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | ||
115 | + break; | ||
116 | + case 0x40000000 ... 0x5fffffff: /* Peripheral */ | ||
117 | + case 0xa0000000 ... 0xbfffffff: /* Device */ | ||
118 | + case 0xc0000000 ... 0xdfffffff: /* Device */ | ||
119 | + case 0xe0000000 ... 0xffffffff: /* System */ | ||
120 | + *prot = PAGE_READ | PAGE_WRITE; | ||
121 | + break; | ||
122 | + default: | ||
123 | + g_assert_not_reached(); | ||
124 | + } | ||
125 | + } | ||
126 | +} | ||
127 | + | ||
128 | /** | ||
129 | * get_phys_addr - get the physical address for this virtual address | ||
130 | * | ||
131 | -- | ||
132 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-8-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 10 +-- | ||
9 | target/arm/helper.c | 194 +------------------------------------------- | ||
10 | target/arm/ptw.c | 190 +++++++++++++++++++++++++++++++++++++++++++ | ||
11 | 3 files changed, 198 insertions(+), 196 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | ||
18 | return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); | ||
19 | } | ||
20 | |||
21 | +bool m_is_ppb_region(CPUARMState *env, uint32_t address); | ||
22 | +bool m_is_system_region(CPUARMState *env, uint32_t address); | ||
23 | + | ||
24 | void get_phys_addr_pmsav7_default(CPUARMState *env, | ||
25 | ARMMMUIdx mmu_idx, | ||
26 | int32_t address, int *prot); | ||
27 | -bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
28 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
29 | - hwaddr *phys_ptr, int *prot, | ||
30 | - target_ulong *page_size, | ||
31 | - ARMMMUFaultInfo *fi); | ||
32 | +bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_user); | ||
33 | + | ||
34 | bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
35 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
36 | hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
37 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/helper.c | ||
40 | +++ b/target/arm/helper.c | ||
41 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
42 | return true; | ||
43 | } | ||
44 | |||
45 | -static bool pmsav7_use_background_region(ARMCPU *cpu, | ||
46 | - ARMMMUIdx mmu_idx, bool is_user) | ||
47 | +bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_user) | ||
48 | { | ||
49 | /* Return true if we should use the default memory map as a | ||
50 | * "background" region if there are no hits against any MPU regions. | ||
51 | @@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, | ||
52 | } | ||
53 | } | ||
54 | |||
55 | -static inline bool m_is_ppb_region(CPUARMState *env, uint32_t address) | ||
56 | +bool m_is_ppb_region(CPUARMState *env, uint32_t address) | ||
57 | { | ||
58 | /* True if address is in the M profile PPB region 0xe0000000 - 0xe00fffff */ | ||
59 | return arm_feature(env, ARM_FEATURE_M) && | ||
60 | extract32(address, 20, 12) == 0xe00; | ||
61 | } | ||
62 | |||
63 | -static inline bool m_is_system_region(CPUARMState *env, uint32_t address) | ||
64 | +bool m_is_system_region(CPUARMState *env, uint32_t address) | ||
65 | { | ||
66 | /* True if address is in the M profile system region | ||
67 | * 0xe0000000 - 0xffffffff | ||
68 | @@ -XXX,XX +XXX,XX @@ static inline bool m_is_system_region(CPUARMState *env, uint32_t address) | ||
69 | return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) == 0x7; | ||
70 | } | ||
71 | |||
72 | -bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
73 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
74 | - hwaddr *phys_ptr, int *prot, | ||
75 | - target_ulong *page_size, | ||
76 | - ARMMMUFaultInfo *fi) | ||
77 | -{ | ||
78 | - ARMCPU *cpu = env_archcpu(env); | ||
79 | - int n; | ||
80 | - bool is_user = regime_is_user(env, mmu_idx); | ||
81 | - | ||
82 | - *phys_ptr = address; | ||
83 | - *page_size = TARGET_PAGE_SIZE; | ||
84 | - *prot = 0; | ||
85 | - | ||
86 | - if (regime_translation_disabled(env, mmu_idx) || | ||
87 | - m_is_ppb_region(env, address)) { | ||
88 | - /* MPU disabled or M profile PPB access: use default memory map. | ||
89 | - * The other case which uses the default memory map in the | ||
90 | - * v7M ARM ARM pseudocode is exception vector reads from the vector | ||
91 | - * table. In QEMU those accesses are done in arm_v7m_load_vector(), | ||
92 | - * which always does a direct read using address_space_ldl(), rather | ||
93 | - * than going via this function, so we don't need to check that here. | ||
94 | - */ | ||
95 | - get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); | ||
96 | - } else { /* MPU enabled */ | ||
97 | - for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) { | ||
98 | - /* region search */ | ||
99 | - uint32_t base = env->pmsav7.drbar[n]; | ||
100 | - uint32_t rsize = extract32(env->pmsav7.drsr[n], 1, 5); | ||
101 | - uint32_t rmask; | ||
102 | - bool srdis = false; | ||
103 | - | ||
104 | - if (!(env->pmsav7.drsr[n] & 0x1)) { | ||
105 | - continue; | ||
106 | - } | ||
107 | - | ||
108 | - if (!rsize) { | ||
109 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
110 | - "DRSR[%d]: Rsize field cannot be 0\n", n); | ||
111 | - continue; | ||
112 | - } | ||
113 | - rsize++; | ||
114 | - rmask = (1ull << rsize) - 1; | ||
115 | - | ||
116 | - if (base & rmask) { | ||
117 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
118 | - "DRBAR[%d]: 0x%" PRIx32 " misaligned " | ||
119 | - "to DRSR region size, mask = 0x%" PRIx32 "\n", | ||
120 | - n, base, rmask); | ||
121 | - continue; | ||
122 | - } | ||
123 | - | ||
124 | - if (address < base || address > base + rmask) { | ||
125 | - /* | ||
126 | - * Address not in this region. We must check whether the | ||
127 | - * region covers addresses in the same page as our address. | ||
128 | - * In that case we must not report a size that covers the | ||
129 | - * whole page for a subsequent hit against a different MPU | ||
130 | - * region or the background region, because it would result in | ||
131 | - * incorrect TLB hits for subsequent accesses to addresses that | ||
132 | - * are in this MPU region. | ||
133 | - */ | ||
134 | - if (ranges_overlap(base, rmask, | ||
135 | - address & TARGET_PAGE_MASK, | ||
136 | - TARGET_PAGE_SIZE)) { | ||
137 | - *page_size = 1; | ||
138 | - } | ||
139 | - continue; | ||
140 | - } | ||
141 | - | ||
142 | - /* Region matched */ | ||
143 | - | ||
144 | - if (rsize >= 8) { /* no subregions for regions < 256 bytes */ | ||
145 | - int i, snd; | ||
146 | - uint32_t srdis_mask; | ||
147 | - | ||
148 | - rsize -= 3; /* sub region size (power of 2) */ | ||
149 | - snd = ((address - base) >> rsize) & 0x7; | ||
150 | - srdis = extract32(env->pmsav7.drsr[n], snd + 8, 1); | ||
151 | - | ||
152 | - srdis_mask = srdis ? 0x3 : 0x0; | ||
153 | - for (i = 2; i <= 8 && rsize < TARGET_PAGE_BITS; i *= 2) { | ||
154 | - /* This will check in groups of 2, 4 and then 8, whether | ||
155 | - * the subregion bits are consistent. rsize is incremented | ||
156 | - * back up to give the region size, considering consistent | ||
157 | - * adjacent subregions as one region. Stop testing if rsize | ||
158 | - * is already big enough for an entire QEMU page. | ||
159 | - */ | ||
160 | - int snd_rounded = snd & ~(i - 1); | ||
161 | - uint32_t srdis_multi = extract32(env->pmsav7.drsr[n], | ||
162 | - snd_rounded + 8, i); | ||
163 | - if (srdis_mask ^ srdis_multi) { | ||
164 | - break; | ||
165 | - } | ||
166 | - srdis_mask = (srdis_mask << i) | srdis_mask; | ||
167 | - rsize++; | ||
168 | - } | ||
169 | - } | ||
170 | - if (srdis) { | ||
171 | - continue; | ||
172 | - } | ||
173 | - if (rsize < TARGET_PAGE_BITS) { | ||
174 | - *page_size = 1 << rsize; | ||
175 | - } | ||
176 | - break; | ||
177 | - } | ||
178 | - | ||
179 | - if (n == -1) { /* no hits */ | ||
180 | - if (!pmsav7_use_background_region(cpu, mmu_idx, is_user)) { | ||
181 | - /* background fault */ | ||
182 | - fi->type = ARMFault_Background; | ||
183 | - return true; | ||
184 | - } | ||
185 | - get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); | ||
186 | - } else { /* a MPU hit! */ | ||
187 | - uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3); | ||
188 | - uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1); | ||
189 | - | ||
190 | - if (m_is_system_region(env, address)) { | ||
191 | - /* System space is always execute never */ | ||
192 | - xn = 1; | ||
193 | - } | ||
194 | - | ||
195 | - if (is_user) { /* User mode AP bit decoding */ | ||
196 | - switch (ap) { | ||
197 | - case 0: | ||
198 | - case 1: | ||
199 | - case 5: | ||
200 | - break; /* no access */ | ||
201 | - case 3: | ||
202 | - *prot |= PAGE_WRITE; | ||
203 | - /* fall through */ | ||
204 | - case 2: | ||
205 | - case 6: | ||
206 | - *prot |= PAGE_READ | PAGE_EXEC; | ||
207 | - break; | ||
208 | - case 7: | ||
209 | - /* for v7M, same as 6; for R profile a reserved value */ | ||
210 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
211 | - *prot |= PAGE_READ | PAGE_EXEC; | ||
212 | - break; | ||
213 | - } | ||
214 | - /* fall through */ | ||
215 | - default: | ||
216 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
217 | - "DRACR[%d]: Bad value for AP bits: 0x%" | ||
218 | - PRIx32 "\n", n, ap); | ||
219 | - } | ||
220 | - } else { /* Priv. mode AP bits decoding */ | ||
221 | - switch (ap) { | ||
222 | - case 0: | ||
223 | - break; /* no access */ | ||
224 | - case 1: | ||
225 | - case 2: | ||
226 | - case 3: | ||
227 | - *prot |= PAGE_WRITE; | ||
228 | - /* fall through */ | ||
229 | - case 5: | ||
230 | - case 6: | ||
231 | - *prot |= PAGE_READ | PAGE_EXEC; | ||
232 | - break; | ||
233 | - case 7: | ||
234 | - /* for v7M, same as 6; for R profile a reserved value */ | ||
235 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
236 | - *prot |= PAGE_READ | PAGE_EXEC; | ||
237 | - break; | ||
238 | - } | ||
239 | - /* fall through */ | ||
240 | - default: | ||
241 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
242 | - "DRACR[%d]: Bad value for AP bits: 0x%" | ||
243 | - PRIx32 "\n", n, ap); | ||
244 | - } | ||
245 | - } | ||
246 | - | ||
247 | - /* execute never */ | ||
248 | - if (xn) { | ||
249 | - *prot &= ~PAGE_EXEC; | ||
250 | - } | ||
251 | - } | ||
252 | - } | ||
253 | - | ||
254 | - fi->type = ARMFault_Permission; | ||
255 | - fi->level = 1; | ||
256 | - return !(*prot & (1 << access_type)); | ||
257 | -} | ||
258 | - | ||
259 | static bool v8m_is_sau_exempt(CPUARMState *env, | ||
260 | uint32_t address, MMUAccessType access_type) | ||
261 | { | ||
262 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
263 | index XXXXXXX..XXXXXXX 100644 | ||
264 | --- a/target/arm/ptw.c | ||
265 | +++ b/target/arm/ptw.c | ||
266 | @@ -XXX,XX +XXX,XX @@ | ||
267 | |||
268 | #include "qemu/osdep.h" | ||
269 | #include "qemu/log.h" | ||
270 | +#include "qemu/range.h" | ||
271 | #include "cpu.h" | ||
272 | #include "internals.h" | ||
273 | #include "ptw.h" | ||
274 | @@ -XXX,XX +XXX,XX @@ void get_phys_addr_pmsav7_default(CPUARMState *env, | ||
275 | } | ||
276 | } | ||
277 | |||
278 | +static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
279 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
280 | + hwaddr *phys_ptr, int *prot, | ||
281 | + target_ulong *page_size, | ||
282 | + ARMMMUFaultInfo *fi) | ||
283 | +{ | ||
284 | + ARMCPU *cpu = env_archcpu(env); | ||
285 | + int n; | ||
286 | + bool is_user = regime_is_user(env, mmu_idx); | ||
287 | + | ||
288 | + *phys_ptr = address; | ||
289 | + *page_size = TARGET_PAGE_SIZE; | ||
290 | + *prot = 0; | ||
291 | + | ||
292 | + if (regime_translation_disabled(env, mmu_idx) || | ||
293 | + m_is_ppb_region(env, address)) { | ||
294 | + /* | ||
295 | + * MPU disabled or M profile PPB access: use default memory map. | ||
296 | + * The other case which uses the default memory map in the | ||
297 | + * v7M ARM ARM pseudocode is exception vector reads from the vector | ||
298 | + * table. In QEMU those accesses are done in arm_v7m_load_vector(), | ||
299 | + * which always does a direct read using address_space_ldl(), rather | ||
300 | + * than going via this function, so we don't need to check that here. | ||
301 | + */ | ||
302 | + get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); | ||
303 | + } else { /* MPU enabled */ | ||
304 | + for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) { | ||
305 | + /* region search */ | ||
306 | + uint32_t base = env->pmsav7.drbar[n]; | ||
307 | + uint32_t rsize = extract32(env->pmsav7.drsr[n], 1, 5); | ||
308 | + uint32_t rmask; | ||
309 | + bool srdis = false; | ||
310 | + | ||
311 | + if (!(env->pmsav7.drsr[n] & 0x1)) { | ||
312 | + continue; | ||
313 | + } | ||
314 | + | ||
315 | + if (!rsize) { | ||
316 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
317 | + "DRSR[%d]: Rsize field cannot be 0\n", n); | ||
318 | + continue; | ||
319 | + } | ||
320 | + rsize++; | ||
321 | + rmask = (1ull << rsize) - 1; | ||
322 | + | ||
323 | + if (base & rmask) { | ||
324 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
325 | + "DRBAR[%d]: 0x%" PRIx32 " misaligned " | ||
326 | + "to DRSR region size, mask = 0x%" PRIx32 "\n", | ||
327 | + n, base, rmask); | ||
328 | + continue; | ||
329 | + } | ||
330 | + | ||
331 | + if (address < base || address > base + rmask) { | ||
332 | + /* | ||
333 | + * Address not in this region. We must check whether the | ||
334 | + * region covers addresses in the same page as our address. | ||
335 | + * In that case we must not report a size that covers the | ||
336 | + * whole page for a subsequent hit against a different MPU | ||
337 | + * region or the background region, because it would result in | ||
338 | + * incorrect TLB hits for subsequent accesses to addresses that | ||
339 | + * are in this MPU region. | ||
340 | + */ | ||
341 | + if (ranges_overlap(base, rmask, | ||
342 | + address & TARGET_PAGE_MASK, | ||
343 | + TARGET_PAGE_SIZE)) { | ||
344 | + *page_size = 1; | ||
345 | + } | ||
346 | + continue; | ||
347 | + } | ||
348 | + | ||
349 | + /* Region matched */ | ||
350 | + | ||
351 | + if (rsize >= 8) { /* no subregions for regions < 256 bytes */ | ||
352 | + int i, snd; | ||
353 | + uint32_t srdis_mask; | ||
354 | + | ||
355 | + rsize -= 3; /* sub region size (power of 2) */ | ||
356 | + snd = ((address - base) >> rsize) & 0x7; | ||
357 | + srdis = extract32(env->pmsav7.drsr[n], snd + 8, 1); | ||
358 | + | ||
359 | + srdis_mask = srdis ? 0x3 : 0x0; | ||
360 | + for (i = 2; i <= 8 && rsize < TARGET_PAGE_BITS; i *= 2) { | ||
361 | + /* | ||
362 | + * This will check in groups of 2, 4 and then 8, whether | ||
363 | + * the subregion bits are consistent. rsize is incremented | ||
364 | + * back up to give the region size, considering consistent | ||
365 | + * adjacent subregions as one region. Stop testing if rsize | ||
366 | + * is already big enough for an entire QEMU page. | ||
367 | + */ | ||
368 | + int snd_rounded = snd & ~(i - 1); | ||
369 | + uint32_t srdis_multi = extract32(env->pmsav7.drsr[n], | ||
370 | + snd_rounded + 8, i); | ||
371 | + if (srdis_mask ^ srdis_multi) { | ||
372 | + break; | ||
373 | + } | ||
374 | + srdis_mask = (srdis_mask << i) | srdis_mask; | ||
375 | + rsize++; | ||
376 | + } | ||
377 | + } | ||
378 | + if (srdis) { | ||
379 | + continue; | ||
380 | + } | ||
381 | + if (rsize < TARGET_PAGE_BITS) { | ||
382 | + *page_size = 1 << rsize; | ||
383 | + } | ||
384 | + break; | ||
385 | + } | ||
386 | + | ||
387 | + if (n == -1) { /* no hits */ | ||
388 | + if (!pmsav7_use_background_region(cpu, mmu_idx, is_user)) { | ||
389 | + /* background fault */ | ||
390 | + fi->type = ARMFault_Background; | ||
391 | + return true; | ||
392 | + } | ||
393 | + get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); | ||
394 | + } else { /* a MPU hit! */ | ||
395 | + uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3); | ||
396 | + uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1); | ||
397 | + | ||
398 | + if (m_is_system_region(env, address)) { | ||
399 | + /* System space is always execute never */ | ||
400 | + xn = 1; | ||
401 | + } | ||
402 | + | ||
403 | + if (is_user) { /* User mode AP bit decoding */ | ||
404 | + switch (ap) { | ||
405 | + case 0: | ||
406 | + case 1: | ||
407 | + case 5: | ||
408 | + break; /* no access */ | ||
409 | + case 3: | ||
410 | + *prot |= PAGE_WRITE; | ||
411 | + /* fall through */ | ||
412 | + case 2: | ||
413 | + case 6: | ||
414 | + *prot |= PAGE_READ | PAGE_EXEC; | ||
415 | + break; | ||
416 | + case 7: | ||
417 | + /* for v7M, same as 6; for R profile a reserved value */ | ||
418 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
419 | + *prot |= PAGE_READ | PAGE_EXEC; | ||
420 | + break; | ||
421 | + } | ||
422 | + /* fall through */ | ||
423 | + default: | ||
424 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
425 | + "DRACR[%d]: Bad value for AP bits: 0x%" | ||
426 | + PRIx32 "\n", n, ap); | ||
427 | + } | ||
428 | + } else { /* Priv. mode AP bits decoding */ | ||
429 | + switch (ap) { | ||
430 | + case 0: | ||
431 | + break; /* no access */ | ||
432 | + case 1: | ||
433 | + case 2: | ||
434 | + case 3: | ||
435 | + *prot |= PAGE_WRITE; | ||
436 | + /* fall through */ | ||
437 | + case 5: | ||
438 | + case 6: | ||
439 | + *prot |= PAGE_READ | PAGE_EXEC; | ||
440 | + break; | ||
441 | + case 7: | ||
442 | + /* for v7M, same as 6; for R profile a reserved value */ | ||
443 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
444 | + *prot |= PAGE_READ | PAGE_EXEC; | ||
445 | + break; | ||
446 | + } | ||
447 | + /* fall through */ | ||
448 | + default: | ||
449 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
450 | + "DRACR[%d]: Bad value for AP bits: 0x%" | ||
451 | + PRIx32 "\n", n, ap); | ||
452 | + } | ||
453 | + } | ||
454 | + | ||
455 | + /* execute never */ | ||
456 | + if (xn) { | ||
457 | + *prot &= ~PAGE_EXEC; | ||
458 | + } | ||
459 | + } | ||
460 | + } | ||
461 | + | ||
462 | + fi->type = ARMFault_Permission; | ||
463 | + fi->level = 1; | ||
464 | + return !(*prot & (1 << access_type)); | ||
465 | +} | ||
466 | + | ||
467 | /** | ||
468 | * get_phys_addr - get the physical address for this virtual address | ||
469 | * | ||
470 | -- | ||
471 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-9-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 5 --- | ||
9 | target/arm/helper.c | 75 ------------------------------------------- | ||
10 | target/arm/ptw.c | 77 +++++++++++++++++++++++++++++++++++++++++++++ | ||
11 | 3 files changed, 77 insertions(+), 80 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ void get_phys_addr_pmsav7_default(CPUARMState *env, | ||
18 | int32_t address, int *prot); | ||
19 | bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_user); | ||
20 | |||
21 | -bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
22 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
23 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
24 | - int *prot, target_ulong *page_size, | ||
25 | - ARMMMUFaultInfo *fi); | ||
26 | bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
27 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
28 | bool s1_is_el0, | ||
29 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/helper.c | ||
32 | +++ b/target/arm/helper.c | ||
33 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
34 | return !(*prot & (1 << access_type)); | ||
35 | } | ||
36 | |||
37 | - | ||
38 | -bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
39 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
40 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
41 | - int *prot, target_ulong *page_size, | ||
42 | - ARMMMUFaultInfo *fi) | ||
43 | -{ | ||
44 | - uint32_t secure = regime_is_secure(env, mmu_idx); | ||
45 | - V8M_SAttributes sattrs = {}; | ||
46 | - bool ret; | ||
47 | - bool mpu_is_subpage; | ||
48 | - | ||
49 | - if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
50 | - v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs); | ||
51 | - if (access_type == MMU_INST_FETCH) { | ||
52 | - /* Instruction fetches always use the MMU bank and the | ||
53 | - * transaction attribute determined by the fetch address, | ||
54 | - * regardless of CPU state. This is painful for QEMU | ||
55 | - * to handle, because it would mean we need to encode | ||
56 | - * into the mmu_idx not just the (user, negpri) information | ||
57 | - * for the current security state but also that for the | ||
58 | - * other security state, which would balloon the number | ||
59 | - * of mmu_idx values needed alarmingly. | ||
60 | - * Fortunately we can avoid this because it's not actually | ||
61 | - * possible to arbitrarily execute code from memory with | ||
62 | - * the wrong security attribute: it will always generate | ||
63 | - * an exception of some kind or another, apart from the | ||
64 | - * special case of an NS CPU executing an SG instruction | ||
65 | - * in S&NSC memory. So we always just fail the translation | ||
66 | - * here and sort things out in the exception handler | ||
67 | - * (including possibly emulating an SG instruction). | ||
68 | - */ | ||
69 | - if (sattrs.ns != !secure) { | ||
70 | - if (sattrs.nsc) { | ||
71 | - fi->type = ARMFault_QEMU_NSCExec; | ||
72 | - } else { | ||
73 | - fi->type = ARMFault_QEMU_SFault; | ||
74 | - } | ||
75 | - *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE; | ||
76 | - *phys_ptr = address; | ||
77 | - *prot = 0; | ||
78 | - return true; | ||
79 | - } | ||
80 | - } else { | ||
81 | - /* For data accesses we always use the MMU bank indicated | ||
82 | - * by the current CPU state, but the security attributes | ||
83 | - * might downgrade a secure access to nonsecure. | ||
84 | - */ | ||
85 | - if (sattrs.ns) { | ||
86 | - txattrs->secure = false; | ||
87 | - } else if (!secure) { | ||
88 | - /* NS access to S memory must fault. | ||
89 | - * Architecturally we should first check whether the | ||
90 | - * MPU information for this address indicates that we | ||
91 | - * are doing an unaligned access to Device memory, which | ||
92 | - * should generate a UsageFault instead. QEMU does not | ||
93 | - * currently check for that kind of unaligned access though. | ||
94 | - * If we added it we would need to do so as a special case | ||
95 | - * for M_FAKE_FSR_SFAULT in arm_v7m_cpu_do_interrupt(). | ||
96 | - */ | ||
97 | - fi->type = ARMFault_QEMU_SFault; | ||
98 | - *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE; | ||
99 | - *phys_ptr = address; | ||
100 | - *prot = 0; | ||
101 | - return true; | ||
102 | - } | ||
103 | - } | ||
104 | - } | ||
105 | - | ||
106 | - ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr, | ||
107 | - txattrs, prot, &mpu_is_subpage, fi, NULL); | ||
108 | - *page_size = sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE; | ||
109 | - return ret; | ||
110 | -} | ||
111 | - | ||
112 | /* Combine either inner or outer cacheability attributes for normal | ||
113 | * memory, according to table D4-42 and pseudocode procedure | ||
114 | * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). | ||
115 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
116 | index XXXXXXX..XXXXXXX 100644 | ||
117 | --- a/target/arm/ptw.c | ||
118 | +++ b/target/arm/ptw.c | ||
119 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
120 | return !(*prot & (1 << access_type)); | ||
121 | } | ||
122 | |||
123 | +static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
124 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
125 | + hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
126 | + int *prot, target_ulong *page_size, | ||
127 | + ARMMMUFaultInfo *fi) | ||
128 | +{ | ||
129 | + uint32_t secure = regime_is_secure(env, mmu_idx); | ||
130 | + V8M_SAttributes sattrs = {}; | ||
131 | + bool ret; | ||
132 | + bool mpu_is_subpage; | ||
133 | + | ||
134 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
135 | + v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs); | ||
136 | + if (access_type == MMU_INST_FETCH) { | ||
137 | + /* | ||
138 | + * Instruction fetches always use the MMU bank and the | ||
139 | + * transaction attribute determined by the fetch address, | ||
140 | + * regardless of CPU state. This is painful for QEMU | ||
141 | + * to handle, because it would mean we need to encode | ||
142 | + * into the mmu_idx not just the (user, negpri) information | ||
143 | + * for the current security state but also that for the | ||
144 | + * other security state, which would balloon the number | ||
145 | + * of mmu_idx values needed alarmingly. | ||
146 | + * Fortunately we can avoid this because it's not actually | ||
147 | + * possible to arbitrarily execute code from memory with | ||
148 | + * the wrong security attribute: it will always generate | ||
149 | + * an exception of some kind or another, apart from the | ||
150 | + * special case of an NS CPU executing an SG instruction | ||
151 | + * in S&NSC memory. So we always just fail the translation | ||
152 | + * here and sort things out in the exception handler | ||
153 | + * (including possibly emulating an SG instruction). | ||
154 | + */ | ||
155 | + if (sattrs.ns != !secure) { | ||
156 | + if (sattrs.nsc) { | ||
157 | + fi->type = ARMFault_QEMU_NSCExec; | ||
158 | + } else { | ||
159 | + fi->type = ARMFault_QEMU_SFault; | ||
160 | + } | ||
161 | + *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE; | ||
162 | + *phys_ptr = address; | ||
163 | + *prot = 0; | ||
164 | + return true; | ||
165 | + } | ||
166 | + } else { | ||
167 | + /* | ||
168 | + * For data accesses we always use the MMU bank indicated | ||
169 | + * by the current CPU state, but the security attributes | ||
170 | + * might downgrade a secure access to nonsecure. | ||
171 | + */ | ||
172 | + if (sattrs.ns) { | ||
173 | + txattrs->secure = false; | ||
174 | + } else if (!secure) { | ||
175 | + /* | ||
176 | + * NS access to S memory must fault. | ||
177 | + * Architecturally we should first check whether the | ||
178 | + * MPU information for this address indicates that we | ||
179 | + * are doing an unaligned access to Device memory, which | ||
180 | + * should generate a UsageFault instead. QEMU does not | ||
181 | + * currently check for that kind of unaligned access though. | ||
182 | + * If we added it we would need to do so as a special case | ||
183 | + * for M_FAKE_FSR_SFAULT in arm_v7m_cpu_do_interrupt(). | ||
184 | + */ | ||
185 | + fi->type = ARMFault_QEMU_SFault; | ||
186 | + *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE; | ||
187 | + *phys_ptr = address; | ||
188 | + *prot = 0; | ||
189 | + return true; | ||
190 | + } | ||
191 | + } | ||
192 | + } | ||
193 | + | ||
194 | + ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr, | ||
195 | + txattrs, prot, &mpu_is_subpage, fi, NULL); | ||
196 | + *page_size = sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE; | ||
197 | + return ret; | ||
198 | +} | ||
199 | + | ||
200 | /** | ||
201 | * get_phys_addr - get the physical address for this virtual address | ||
202 | * | ||
203 | -- | ||
204 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | This is the final user of get_phys_addr_pmsav7_default | ||
4 | within helper.c, so make it static within ptw.c. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220604040607.269301-10-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/ptw.h | 3 - | ||
12 | target/arm/helper.c | 136 ----------------------------------------- | ||
13 | target/arm/ptw.c | 146 +++++++++++++++++++++++++++++++++++++++++++- | ||
14 | 3 files changed, 143 insertions(+), 142 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/ptw.h | ||
19 | +++ b/target/arm/ptw.h | ||
20 | @@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | ||
21 | bool m_is_ppb_region(CPUARMState *env, uint32_t address); | ||
22 | bool m_is_system_region(CPUARMState *env, uint32_t address); | ||
23 | |||
24 | -void get_phys_addr_pmsav7_default(CPUARMState *env, | ||
25 | - ARMMMUIdx mmu_idx, | ||
26 | - int32_t address, int *prot); | ||
27 | bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_user); | ||
28 | |||
29 | bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
30 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/helper.c | ||
33 | +++ b/target/arm/helper.c | ||
34 | @@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
35 | } | ||
36 | } | ||
37 | |||
38 | -bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
39 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
40 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
41 | - int *prot, bool *is_subpage, | ||
42 | - ARMMMUFaultInfo *fi, uint32_t *mregion) | ||
43 | -{ | ||
44 | - /* Perform a PMSAv8 MPU lookup (without also doing the SAU check | ||
45 | - * that a full phys-to-virt translation does). | ||
46 | - * mregion is (if not NULL) set to the region number which matched, | ||
47 | - * or -1 if no region number is returned (MPU off, address did not | ||
48 | - * hit a region, address hit in multiple regions). | ||
49 | - * We set is_subpage to true if the region hit doesn't cover the | ||
50 | - * entire TARGET_PAGE the address is within. | ||
51 | - */ | ||
52 | - ARMCPU *cpu = env_archcpu(env); | ||
53 | - bool is_user = regime_is_user(env, mmu_idx); | ||
54 | - uint32_t secure = regime_is_secure(env, mmu_idx); | ||
55 | - int n; | ||
56 | - int matchregion = -1; | ||
57 | - bool hit = false; | ||
58 | - uint32_t addr_page_base = address & TARGET_PAGE_MASK; | ||
59 | - uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1); | ||
60 | - | ||
61 | - *is_subpage = false; | ||
62 | - *phys_ptr = address; | ||
63 | - *prot = 0; | ||
64 | - if (mregion) { | ||
65 | - *mregion = -1; | ||
66 | - } | ||
67 | - | ||
68 | - /* Unlike the ARM ARM pseudocode, we don't need to check whether this | ||
69 | - * was an exception vector read from the vector table (which is always | ||
70 | - * done using the default system address map), because those accesses | ||
71 | - * are done in arm_v7m_load_vector(), which always does a direct | ||
72 | - * read using address_space_ldl(), rather than going via this function. | ||
73 | - */ | ||
74 | - if (regime_translation_disabled(env, mmu_idx)) { /* MPU disabled */ | ||
75 | - hit = true; | ||
76 | - } else if (m_is_ppb_region(env, address)) { | ||
77 | - hit = true; | ||
78 | - } else { | ||
79 | - if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) { | ||
80 | - hit = true; | ||
81 | - } | ||
82 | - | ||
83 | - for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) { | ||
84 | - /* region search */ | ||
85 | - /* Note that the base address is bits [31:5] from the register | ||
86 | - * with bits [4:0] all zeroes, but the limit address is bits | ||
87 | - * [31:5] from the register with bits [4:0] all ones. | ||
88 | - */ | ||
89 | - uint32_t base = env->pmsav8.rbar[secure][n] & ~0x1f; | ||
90 | - uint32_t limit = env->pmsav8.rlar[secure][n] | 0x1f; | ||
91 | - | ||
92 | - if (!(env->pmsav8.rlar[secure][n] & 0x1)) { | ||
93 | - /* Region disabled */ | ||
94 | - continue; | ||
95 | - } | ||
96 | - | ||
97 | - if (address < base || address > limit) { | ||
98 | - /* | ||
99 | - * Address not in this region. We must check whether the | ||
100 | - * region covers addresses in the same page as our address. | ||
101 | - * In that case we must not report a size that covers the | ||
102 | - * whole page for a subsequent hit against a different MPU | ||
103 | - * region or the background region, because it would result in | ||
104 | - * incorrect TLB hits for subsequent accesses to addresses that | ||
105 | - * are in this MPU region. | ||
106 | - */ | ||
107 | - if (limit >= base && | ||
108 | - ranges_overlap(base, limit - base + 1, | ||
109 | - addr_page_base, | ||
110 | - TARGET_PAGE_SIZE)) { | ||
111 | - *is_subpage = true; | ||
112 | - } | ||
113 | - continue; | ||
114 | - } | ||
115 | - | ||
116 | - if (base > addr_page_base || limit < addr_page_limit) { | ||
117 | - *is_subpage = true; | ||
118 | - } | ||
119 | - | ||
120 | - if (matchregion != -1) { | ||
121 | - /* Multiple regions match -- always a failure (unlike | ||
122 | - * PMSAv7 where highest-numbered-region wins) | ||
123 | - */ | ||
124 | - fi->type = ARMFault_Permission; | ||
125 | - fi->level = 1; | ||
126 | - return true; | ||
127 | - } | ||
128 | - | ||
129 | - matchregion = n; | ||
130 | - hit = true; | ||
131 | - } | ||
132 | - } | ||
133 | - | ||
134 | - if (!hit) { | ||
135 | - /* background fault */ | ||
136 | - fi->type = ARMFault_Background; | ||
137 | - return true; | ||
138 | - } | ||
139 | - | ||
140 | - if (matchregion == -1) { | ||
141 | - /* hit using the background region */ | ||
142 | - get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); | ||
143 | - } else { | ||
144 | - uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2); | ||
145 | - uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1); | ||
146 | - bool pxn = false; | ||
147 | - | ||
148 | - if (arm_feature(env, ARM_FEATURE_V8_1M)) { | ||
149 | - pxn = extract32(env->pmsav8.rlar[secure][matchregion], 4, 1); | ||
150 | - } | ||
151 | - | ||
152 | - if (m_is_system_region(env, address)) { | ||
153 | - /* System space is always execute never */ | ||
154 | - xn = 1; | ||
155 | - } | ||
156 | - | ||
157 | - *prot = simple_ap_to_rw_prot(env, mmu_idx, ap); | ||
158 | - if (*prot && !xn && !(pxn && !is_user)) { | ||
159 | - *prot |= PAGE_EXEC; | ||
160 | - } | ||
161 | - /* We don't need to look the attribute up in the MAIR0/MAIR1 | ||
162 | - * registers because that only tells us about cacheability. | ||
163 | - */ | ||
164 | - if (mregion) { | ||
165 | - *mregion = matchregion; | ||
166 | - } | ||
167 | - } | ||
168 | - | ||
169 | - fi->type = ARMFault_Permission; | ||
170 | - fi->level = 1; | ||
171 | - return !(*prot & (1 << access_type)); | ||
172 | -} | ||
173 | - | ||
174 | /* Combine either inner or outer cacheability attributes for normal | ||
175 | * memory, according to table D4-42 and pseudocode procedure | ||
176 | * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). | ||
177 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
178 | index XXXXXXX..XXXXXXX 100644 | ||
179 | --- a/target/arm/ptw.c | ||
180 | +++ b/target/arm/ptw.c | ||
181 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
182 | return false; | ||
183 | } | ||
184 | |||
185 | -void get_phys_addr_pmsav7_default(CPUARMState *env, | ||
186 | - ARMMMUIdx mmu_idx, | ||
187 | - int32_t address, int *prot) | ||
188 | +static void get_phys_addr_pmsav7_default(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
189 | + int32_t address, int *prot) | ||
190 | { | ||
191 | if (!arm_feature(env, ARM_FEATURE_M)) { | ||
192 | *prot = PAGE_READ | PAGE_WRITE; | ||
193 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
194 | return !(*prot & (1 << access_type)); | ||
195 | } | ||
196 | |||
197 | +bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
198 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
199 | + hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
200 | + int *prot, bool *is_subpage, | ||
201 | + ARMMMUFaultInfo *fi, uint32_t *mregion) | ||
202 | +{ | ||
203 | + /* | ||
204 | + * Perform a PMSAv8 MPU lookup (without also doing the SAU check | ||
205 | + * that a full phys-to-virt translation does). | ||
206 | + * mregion is (if not NULL) set to the region number which matched, | ||
207 | + * or -1 if no region number is returned (MPU off, address did not | ||
208 | + * hit a region, address hit in multiple regions). | ||
209 | + * We set is_subpage to true if the region hit doesn't cover the | ||
210 | + * entire TARGET_PAGE the address is within. | ||
211 | + */ | ||
212 | + ARMCPU *cpu = env_archcpu(env); | ||
213 | + bool is_user = regime_is_user(env, mmu_idx); | ||
214 | + uint32_t secure = regime_is_secure(env, mmu_idx); | ||
215 | + int n; | ||
216 | + int matchregion = -1; | ||
217 | + bool hit = false; | ||
218 | + uint32_t addr_page_base = address & TARGET_PAGE_MASK; | ||
219 | + uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1); | ||
220 | + | ||
221 | + *is_subpage = false; | ||
222 | + *phys_ptr = address; | ||
223 | + *prot = 0; | ||
224 | + if (mregion) { | ||
225 | + *mregion = -1; | ||
226 | + } | ||
227 | + | ||
228 | + /* | ||
229 | + * Unlike the ARM ARM pseudocode, we don't need to check whether this | ||
230 | + * was an exception vector read from the vector table (which is always | ||
231 | + * done using the default system address map), because those accesses | ||
232 | + * are done in arm_v7m_load_vector(), which always does a direct | ||
233 | + * read using address_space_ldl(), rather than going via this function. | ||
234 | + */ | ||
235 | + if (regime_translation_disabled(env, mmu_idx)) { /* MPU disabled */ | ||
236 | + hit = true; | ||
237 | + } else if (m_is_ppb_region(env, address)) { | ||
238 | + hit = true; | ||
239 | + } else { | ||
240 | + if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) { | ||
241 | + hit = true; | ||
242 | + } | ||
243 | + | ||
244 | + for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) { | ||
245 | + /* region search */ | ||
246 | + /* | ||
247 | + * Note that the base address is bits [31:5] from the register | ||
248 | + * with bits [4:0] all zeroes, but the limit address is bits | ||
249 | + * [31:5] from the register with bits [4:0] all ones. | ||
250 | + */ | ||
251 | + uint32_t base = env->pmsav8.rbar[secure][n] & ~0x1f; | ||
252 | + uint32_t limit = env->pmsav8.rlar[secure][n] | 0x1f; | ||
253 | + | ||
254 | + if (!(env->pmsav8.rlar[secure][n] & 0x1)) { | ||
255 | + /* Region disabled */ | ||
256 | + continue; | ||
257 | + } | ||
258 | + | ||
259 | + if (address < base || address > limit) { | ||
260 | + /* | ||
261 | + * Address not in this region. We must check whether the | ||
262 | + * region covers addresses in the same page as our address. | ||
263 | + * In that case we must not report a size that covers the | ||
264 | + * whole page for a subsequent hit against a different MPU | ||
265 | + * region or the background region, because it would result in | ||
266 | + * incorrect TLB hits for subsequent accesses to addresses that | ||
267 | + * are in this MPU region. | ||
268 | + */ | ||
269 | + if (limit >= base && | ||
270 | + ranges_overlap(base, limit - base + 1, | ||
271 | + addr_page_base, | ||
272 | + TARGET_PAGE_SIZE)) { | ||
273 | + *is_subpage = true; | ||
274 | + } | ||
275 | + continue; | ||
276 | + } | ||
277 | + | ||
278 | + if (base > addr_page_base || limit < addr_page_limit) { | ||
279 | + *is_subpage = true; | ||
280 | + } | ||
281 | + | ||
282 | + if (matchregion != -1) { | ||
283 | + /* | ||
284 | + * Multiple regions match -- always a failure (unlike | ||
285 | + * PMSAv7 where highest-numbered-region wins) | ||
286 | + */ | ||
287 | + fi->type = ARMFault_Permission; | ||
288 | + fi->level = 1; | ||
289 | + return true; | ||
290 | + } | ||
291 | + | ||
292 | + matchregion = n; | ||
293 | + hit = true; | ||
294 | + } | ||
295 | + } | ||
296 | + | ||
297 | + if (!hit) { | ||
298 | + /* background fault */ | ||
299 | + fi->type = ARMFault_Background; | ||
300 | + return true; | ||
301 | + } | ||
302 | + | ||
303 | + if (matchregion == -1) { | ||
304 | + /* hit using the background region */ | ||
305 | + get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); | ||
306 | + } else { | ||
307 | + uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2); | ||
308 | + uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1); | ||
309 | + bool pxn = false; | ||
310 | + | ||
311 | + if (arm_feature(env, ARM_FEATURE_V8_1M)) { | ||
312 | + pxn = extract32(env->pmsav8.rlar[secure][matchregion], 4, 1); | ||
313 | + } | ||
314 | + | ||
315 | + if (m_is_system_region(env, address)) { | ||
316 | + /* System space is always execute never */ | ||
317 | + xn = 1; | ||
318 | + } | ||
319 | + | ||
320 | + *prot = simple_ap_to_rw_prot(env, mmu_idx, ap); | ||
321 | + if (*prot && !xn && !(pxn && !is_user)) { | ||
322 | + *prot |= PAGE_EXEC; | ||
323 | + } | ||
324 | + /* | ||
325 | + * We don't need to look the attribute up in the MAIR0/MAIR1 | ||
326 | + * registers because that only tells us about cacheability. | ||
327 | + */ | ||
328 | + if (mregion) { | ||
329 | + *mregion = matchregion; | ||
330 | + } | ||
331 | + } | ||
332 | + | ||
333 | + fi->type = ARMFault_Permission; | ||
334 | + fi->level = 1; | ||
335 | + return !(*prot & (1 << access_type)); | ||
336 | +} | ||
337 | + | ||
338 | static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
339 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
340 | hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
341 | -- | ||
342 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-11-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 2 -- | ||
9 | target/arm/helper.c | 19 ------------------- | ||
10 | target/arm/ptw.c | 21 +++++++++++++++++++++ | ||
11 | 3 files changed, 21 insertions(+), 21 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | ||
18 | bool m_is_ppb_region(CPUARMState *env, uint32_t address); | ||
19 | bool m_is_system_region(CPUARMState *env, uint32_t address); | ||
20 | |||
21 | -bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_user); | ||
22 | - | ||
23 | bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
24 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
25 | bool s1_is_el0, | ||
26 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/helper.c | ||
29 | +++ b/target/arm/helper.c | ||
30 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
31 | return true; | ||
32 | } | ||
33 | |||
34 | -bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_user) | ||
35 | -{ | ||
36 | - /* Return true if we should use the default memory map as a | ||
37 | - * "background" region if there are no hits against any MPU regions. | ||
38 | - */ | ||
39 | - CPUARMState *env = &cpu->env; | ||
40 | - | ||
41 | - if (is_user) { | ||
42 | - return false; | ||
43 | - } | ||
44 | - | ||
45 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
46 | - return env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] | ||
47 | - & R_V7M_MPU_CTRL_PRIVDEFENA_MASK; | ||
48 | - } else { | ||
49 | - return regime_sctlr(env, mmu_idx) & SCTLR_BR; | ||
50 | - } | ||
51 | -} | ||
52 | - | ||
53 | bool m_is_ppb_region(CPUARMState *env, uint32_t address) | ||
54 | { | ||
55 | /* True if address is in the M profile PPB region 0xe0000000 - 0xe00fffff */ | ||
56 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/ptw.c | ||
59 | +++ b/target/arm/ptw.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static void get_phys_addr_pmsav7_default(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
61 | } | ||
62 | } | ||
63 | |||
64 | +static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
65 | + bool is_user) | ||
66 | +{ | ||
67 | + /* | ||
68 | + * Return true if we should use the default memory map as a | ||
69 | + * "background" region if there are no hits against any MPU regions. | ||
70 | + */ | ||
71 | + CPUARMState *env = &cpu->env; | ||
72 | + | ||
73 | + if (is_user) { | ||
74 | + return false; | ||
75 | + } | ||
76 | + | ||
77 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
78 | + return env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] | ||
79 | + & R_V7M_MPU_CTRL_PRIVDEFENA_MASK; | ||
80 | + } else { | ||
81 | + return regime_sctlr(env, mmu_idx) & SCTLR_BR; | ||
82 | + } | ||
83 | +} | ||
84 | + | ||
85 | static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
86 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
87 | hwaddr *phys_ptr, int *prot, | ||
88 | -- | ||
89 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | This function has one private helper, v8m_is_sau_exempt, | ||
4 | so move that at the same time. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220604040607.269301-12-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.c | 123 ------------------------------------------ | ||
12 | target/arm/ptw.c | 126 ++++++++++++++++++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 126 insertions(+), 123 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/helper.c | ||
18 | +++ b/target/arm/helper.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "qemu/osdep.h" | ||
21 | #include "qemu/units.h" | ||
22 | #include "qemu/log.h" | ||
23 | -#include "target/arm/idau.h" | ||
24 | #include "trace.h" | ||
25 | #include "cpu.h" | ||
26 | #include "internals.h" | ||
27 | @@ -XXX,XX +XXX,XX @@ bool m_is_system_region(CPUARMState *env, uint32_t address) | ||
28 | return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) == 0x7; | ||
29 | } | ||
30 | |||
31 | -static bool v8m_is_sau_exempt(CPUARMState *env, | ||
32 | - uint32_t address, MMUAccessType access_type) | ||
33 | -{ | ||
34 | - /* The architecture specifies that certain address ranges are | ||
35 | - * exempt from v8M SAU/IDAU checks. | ||
36 | - */ | ||
37 | - return | ||
38 | - (access_type == MMU_INST_FETCH && m_is_system_region(env, address)) || | ||
39 | - (address >= 0xe0000000 && address <= 0xe0002fff) || | ||
40 | - (address >= 0xe000e000 && address <= 0xe000efff) || | ||
41 | - (address >= 0xe002e000 && address <= 0xe002efff) || | ||
42 | - (address >= 0xe0040000 && address <= 0xe0041fff) || | ||
43 | - (address >= 0xe00ff000 && address <= 0xe00fffff); | ||
44 | -} | ||
45 | - | ||
46 | -void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
47 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
48 | - V8M_SAttributes *sattrs) | ||
49 | -{ | ||
50 | - /* Look up the security attributes for this address. Compare the | ||
51 | - * pseudocode SecurityCheck() function. | ||
52 | - * We assume the caller has zero-initialized *sattrs. | ||
53 | - */ | ||
54 | - ARMCPU *cpu = env_archcpu(env); | ||
55 | - int r; | ||
56 | - bool idau_exempt = false, idau_ns = true, idau_nsc = true; | ||
57 | - int idau_region = IREGION_NOTVALID; | ||
58 | - uint32_t addr_page_base = address & TARGET_PAGE_MASK; | ||
59 | - uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1); | ||
60 | - | ||
61 | - if (cpu->idau) { | ||
62 | - IDAUInterfaceClass *iic = IDAU_INTERFACE_GET_CLASS(cpu->idau); | ||
63 | - IDAUInterface *ii = IDAU_INTERFACE(cpu->idau); | ||
64 | - | ||
65 | - iic->check(ii, address, &idau_region, &idau_exempt, &idau_ns, | ||
66 | - &idau_nsc); | ||
67 | - } | ||
68 | - | ||
69 | - if (access_type == MMU_INST_FETCH && extract32(address, 28, 4) == 0xf) { | ||
70 | - /* 0xf0000000..0xffffffff is always S for insn fetches */ | ||
71 | - return; | ||
72 | - } | ||
73 | - | ||
74 | - if (idau_exempt || v8m_is_sau_exempt(env, address, access_type)) { | ||
75 | - sattrs->ns = !regime_is_secure(env, mmu_idx); | ||
76 | - return; | ||
77 | - } | ||
78 | - | ||
79 | - if (idau_region != IREGION_NOTVALID) { | ||
80 | - sattrs->irvalid = true; | ||
81 | - sattrs->iregion = idau_region; | ||
82 | - } | ||
83 | - | ||
84 | - switch (env->sau.ctrl & 3) { | ||
85 | - case 0: /* SAU.ENABLE == 0, SAU.ALLNS == 0 */ | ||
86 | - break; | ||
87 | - case 2: /* SAU.ENABLE == 0, SAU.ALLNS == 1 */ | ||
88 | - sattrs->ns = true; | ||
89 | - break; | ||
90 | - default: /* SAU.ENABLE == 1 */ | ||
91 | - for (r = 0; r < cpu->sau_sregion; r++) { | ||
92 | - if (env->sau.rlar[r] & 1) { | ||
93 | - uint32_t base = env->sau.rbar[r] & ~0x1f; | ||
94 | - uint32_t limit = env->sau.rlar[r] | 0x1f; | ||
95 | - | ||
96 | - if (base <= address && limit >= address) { | ||
97 | - if (base > addr_page_base || limit < addr_page_limit) { | ||
98 | - sattrs->subpage = true; | ||
99 | - } | ||
100 | - if (sattrs->srvalid) { | ||
101 | - /* If we hit in more than one region then we must report | ||
102 | - * as Secure, not NS-Callable, with no valid region | ||
103 | - * number info. | ||
104 | - */ | ||
105 | - sattrs->ns = false; | ||
106 | - sattrs->nsc = false; | ||
107 | - sattrs->sregion = 0; | ||
108 | - sattrs->srvalid = false; | ||
109 | - break; | ||
110 | - } else { | ||
111 | - if (env->sau.rlar[r] & 2) { | ||
112 | - sattrs->nsc = true; | ||
113 | - } else { | ||
114 | - sattrs->ns = true; | ||
115 | - } | ||
116 | - sattrs->srvalid = true; | ||
117 | - sattrs->sregion = r; | ||
118 | - } | ||
119 | - } else { | ||
120 | - /* | ||
121 | - * Address not in this region. We must check whether the | ||
122 | - * region covers addresses in the same page as our address. | ||
123 | - * In that case we must not report a size that covers the | ||
124 | - * whole page for a subsequent hit against a different MPU | ||
125 | - * region or the background region, because it would result | ||
126 | - * in incorrect TLB hits for subsequent accesses to | ||
127 | - * addresses that are in this MPU region. | ||
128 | - */ | ||
129 | - if (limit >= base && | ||
130 | - ranges_overlap(base, limit - base + 1, | ||
131 | - addr_page_base, | ||
132 | - TARGET_PAGE_SIZE)) { | ||
133 | - sattrs->subpage = true; | ||
134 | - } | ||
135 | - } | ||
136 | - } | ||
137 | - } | ||
138 | - break; | ||
139 | - } | ||
140 | - | ||
141 | - /* | ||
142 | - * The IDAU will override the SAU lookup results if it specifies | ||
143 | - * higher security than the SAU does. | ||
144 | - */ | ||
145 | - if (!idau_ns) { | ||
146 | - if (sattrs->ns || (!idau_nsc && sattrs->nsc)) { | ||
147 | - sattrs->ns = false; | ||
148 | - sattrs->nsc = idau_nsc; | ||
149 | - } | ||
150 | - } | ||
151 | -} | ||
152 | - | ||
153 | /* Combine either inner or outer cacheability attributes for normal | ||
154 | * memory, according to table D4-42 and pseudocode procedure | ||
155 | * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). | ||
156 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
157 | index XXXXXXX..XXXXXXX 100644 | ||
158 | --- a/target/arm/ptw.c | ||
159 | +++ b/target/arm/ptw.c | ||
160 | @@ -XXX,XX +XXX,XX @@ | ||
161 | #include "qemu/range.h" | ||
162 | #include "cpu.h" | ||
163 | #include "internals.h" | ||
164 | +#include "idau.h" | ||
165 | #include "ptw.h" | ||
166 | |||
167 | |||
168 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
169 | return !(*prot & (1 << access_type)); | ||
170 | } | ||
171 | |||
172 | +static bool v8m_is_sau_exempt(CPUARMState *env, | ||
173 | + uint32_t address, MMUAccessType access_type) | ||
174 | +{ | ||
175 | + /* | ||
176 | + * The architecture specifies that certain address ranges are | ||
177 | + * exempt from v8M SAU/IDAU checks. | ||
178 | + */ | ||
179 | + return | ||
180 | + (access_type == MMU_INST_FETCH && m_is_system_region(env, address)) || | ||
181 | + (address >= 0xe0000000 && address <= 0xe0002fff) || | ||
182 | + (address >= 0xe000e000 && address <= 0xe000efff) || | ||
183 | + (address >= 0xe002e000 && address <= 0xe002efff) || | ||
184 | + (address >= 0xe0040000 && address <= 0xe0041fff) || | ||
185 | + (address >= 0xe00ff000 && address <= 0xe00fffff); | ||
186 | +} | ||
187 | + | ||
188 | +void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
189 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
190 | + V8M_SAttributes *sattrs) | ||
191 | +{ | ||
192 | + /* | ||
193 | + * Look up the security attributes for this address. Compare the | ||
194 | + * pseudocode SecurityCheck() function. | ||
195 | + * We assume the caller has zero-initialized *sattrs. | ||
196 | + */ | ||
197 | + ARMCPU *cpu = env_archcpu(env); | ||
198 | + int r; | ||
199 | + bool idau_exempt = false, idau_ns = true, idau_nsc = true; | ||
200 | + int idau_region = IREGION_NOTVALID; | ||
201 | + uint32_t addr_page_base = address & TARGET_PAGE_MASK; | ||
202 | + uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1); | ||
203 | + | ||
204 | + if (cpu->idau) { | ||
205 | + IDAUInterfaceClass *iic = IDAU_INTERFACE_GET_CLASS(cpu->idau); | ||
206 | + IDAUInterface *ii = IDAU_INTERFACE(cpu->idau); | ||
207 | + | ||
208 | + iic->check(ii, address, &idau_region, &idau_exempt, &idau_ns, | ||
209 | + &idau_nsc); | ||
210 | + } | ||
211 | + | ||
212 | + if (access_type == MMU_INST_FETCH && extract32(address, 28, 4) == 0xf) { | ||
213 | + /* 0xf0000000..0xffffffff is always S for insn fetches */ | ||
214 | + return; | ||
215 | + } | ||
216 | + | ||
217 | + if (idau_exempt || v8m_is_sau_exempt(env, address, access_type)) { | ||
218 | + sattrs->ns = !regime_is_secure(env, mmu_idx); | ||
219 | + return; | ||
220 | + } | ||
221 | + | ||
222 | + if (idau_region != IREGION_NOTVALID) { | ||
223 | + sattrs->irvalid = true; | ||
224 | + sattrs->iregion = idau_region; | ||
225 | + } | ||
226 | + | ||
227 | + switch (env->sau.ctrl & 3) { | ||
228 | + case 0: /* SAU.ENABLE == 0, SAU.ALLNS == 0 */ | ||
229 | + break; | ||
230 | + case 2: /* SAU.ENABLE == 0, SAU.ALLNS == 1 */ | ||
231 | + sattrs->ns = true; | ||
232 | + break; | ||
233 | + default: /* SAU.ENABLE == 1 */ | ||
234 | + for (r = 0; r < cpu->sau_sregion; r++) { | ||
235 | + if (env->sau.rlar[r] & 1) { | ||
236 | + uint32_t base = env->sau.rbar[r] & ~0x1f; | ||
237 | + uint32_t limit = env->sau.rlar[r] | 0x1f; | ||
238 | + | ||
239 | + if (base <= address && limit >= address) { | ||
240 | + if (base > addr_page_base || limit < addr_page_limit) { | ||
241 | + sattrs->subpage = true; | ||
242 | + } | ||
243 | + if (sattrs->srvalid) { | ||
244 | + /* | ||
245 | + * If we hit in more than one region then we must report | ||
246 | + * as Secure, not NS-Callable, with no valid region | ||
247 | + * number info. | ||
248 | + */ | ||
249 | + sattrs->ns = false; | ||
250 | + sattrs->nsc = false; | ||
251 | + sattrs->sregion = 0; | ||
252 | + sattrs->srvalid = false; | ||
253 | + break; | ||
254 | + } else { | ||
255 | + if (env->sau.rlar[r] & 2) { | ||
256 | + sattrs->nsc = true; | ||
257 | + } else { | ||
258 | + sattrs->ns = true; | ||
259 | + } | ||
260 | + sattrs->srvalid = true; | ||
261 | + sattrs->sregion = r; | ||
262 | + } | ||
263 | + } else { | ||
264 | + /* | ||
265 | + * Address not in this region. We must check whether the | ||
266 | + * region covers addresses in the same page as our address. | ||
267 | + * In that case we must not report a size that covers the | ||
268 | + * whole page for a subsequent hit against a different MPU | ||
269 | + * region or the background region, because it would result | ||
270 | + * in incorrect TLB hits for subsequent accesses to | ||
271 | + * addresses that are in this MPU region. | ||
272 | + */ | ||
273 | + if (limit >= base && | ||
274 | + ranges_overlap(base, limit - base + 1, | ||
275 | + addr_page_base, | ||
276 | + TARGET_PAGE_SIZE)) { | ||
277 | + sattrs->subpage = true; | ||
278 | + } | ||
279 | + } | ||
280 | + } | ||
281 | + } | ||
282 | + break; | ||
283 | + } | ||
284 | + | ||
285 | + /* | ||
286 | + * The IDAU will override the SAU lookup results if it specifies | ||
287 | + * higher security than the SAU does. | ||
288 | + */ | ||
289 | + if (!idau_ns) { | ||
290 | + if (sattrs->ns || (!idau_nsc && sattrs->nsc)) { | ||
291 | + sattrs->ns = false; | ||
292 | + sattrs->nsc = idau_nsc; | ||
293 | + } | ||
294 | + } | ||
295 | +} | ||
296 | + | ||
297 | static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
298 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
299 | hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
300 | -- | ||
301 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-13-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 3 --- | ||
9 | target/arm/helper.c | 15 --------------- | ||
10 | target/arm/ptw.c | 16 ++++++++++++++++ | ||
11 | 3 files changed, 16 insertions(+), 18 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | ||
18 | return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); | ||
19 | } | ||
20 | |||
21 | -bool m_is_ppb_region(CPUARMState *env, uint32_t address); | ||
22 | -bool m_is_system_region(CPUARMState *env, uint32_t address); | ||
23 | - | ||
24 | bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
25 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
26 | bool s1_is_el0, | ||
27 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/helper.c | ||
30 | +++ b/target/arm/helper.c | ||
31 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
32 | return true; | ||
33 | } | ||
34 | |||
35 | -bool m_is_ppb_region(CPUARMState *env, uint32_t address) | ||
36 | -{ | ||
37 | - /* True if address is in the M profile PPB region 0xe0000000 - 0xe00fffff */ | ||
38 | - return arm_feature(env, ARM_FEATURE_M) && | ||
39 | - extract32(address, 20, 12) == 0xe00; | ||
40 | -} | ||
41 | - | ||
42 | -bool m_is_system_region(CPUARMState *env, uint32_t address) | ||
43 | -{ | ||
44 | - /* True if address is in the M profile system region | ||
45 | - * 0xe0000000 - 0xffffffff | ||
46 | - */ | ||
47 | - return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) == 0x7; | ||
48 | -} | ||
49 | - | ||
50 | /* Combine either inner or outer cacheability attributes for normal | ||
51 | * memory, according to table D4-42 and pseudocode procedure | ||
52 | * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). | ||
53 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/ptw.c | ||
56 | +++ b/target/arm/ptw.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static void get_phys_addr_pmsav7_default(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
58 | } | ||
59 | } | ||
60 | |||
61 | +static bool m_is_ppb_region(CPUARMState *env, uint32_t address) | ||
62 | +{ | ||
63 | + /* True if address is in the M profile PPB region 0xe0000000 - 0xe00fffff */ | ||
64 | + return arm_feature(env, ARM_FEATURE_M) && | ||
65 | + extract32(address, 20, 12) == 0xe00; | ||
66 | +} | ||
67 | + | ||
68 | +static bool m_is_system_region(CPUARMState *env, uint32_t address) | ||
69 | +{ | ||
70 | + /* | ||
71 | + * True if address is in the M profile system region | ||
72 | + * 0xe0000000 - 0xffffffff | ||
73 | + */ | ||
74 | + return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) == 0x7; | ||
75 | +} | ||
76 | + | ||
77 | static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
78 | bool is_user) | ||
79 | { | ||
80 | -- | ||
81 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-14-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 4 ++-- | ||
9 | target/arm/helper.c | 26 +------------------------- | ||
10 | target/arm/ptw.c | 23 +++++++++++++++++++++++ | ||
11 | 3 files changed, 26 insertions(+), 27 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
18 | |||
19 | bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
20 | bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
21 | +uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); | ||
22 | + | ||
23 | ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
24 | ARMCacheAttrs s1, ARMCacheAttrs s2); | ||
25 | |||
26 | -bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
27 | - uint32_t *table, uint32_t address); | ||
28 | int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
29 | int ap, int domain_prot); | ||
30 | int simple_ap_to_rw_prot_is_user(int ap, bool is_user); | ||
31 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/helper.c | ||
34 | +++ b/target/arm/helper.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static inline bool regime_translation_big_endian(CPUARMState *env, | ||
36 | } | ||
37 | |||
38 | /* Return the TTBR associated with this translation regime */ | ||
39 | -static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
40 | - int ttbrn) | ||
41 | +uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) | ||
42 | { | ||
43 | if (mmu_idx == ARMMMUIdx_Stage2) { | ||
44 | return env->cp15.vttbr_el2; | ||
45 | @@ -XXX,XX +XXX,XX @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, | ||
46 | return prot_rw | PAGE_EXEC; | ||
47 | } | ||
48 | |||
49 | -bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
50 | - uint32_t *table, uint32_t address) | ||
51 | -{ | ||
52 | - /* Note that we can only get here for an AArch32 PL0/PL1 lookup */ | ||
53 | - TCR *tcr = regime_tcr(env, mmu_idx); | ||
54 | - | ||
55 | - if (address & tcr->mask) { | ||
56 | - if (tcr->raw_tcr & TTBCR_PD1) { | ||
57 | - /* Translation table walk disabled for TTBR1 */ | ||
58 | - return false; | ||
59 | - } | ||
60 | - *table = regime_ttbr(env, mmu_idx, 1) & 0xffffc000; | ||
61 | - } else { | ||
62 | - if (tcr->raw_tcr & TTBCR_PD0) { | ||
63 | - /* Translation table walk disabled for TTBR0 */ | ||
64 | - return false; | ||
65 | - } | ||
66 | - *table = regime_ttbr(env, mmu_idx, 0) & tcr->base_mask; | ||
67 | - } | ||
68 | - *table |= (address >> 18) & 0x3ffc; | ||
69 | - return true; | ||
70 | -} | ||
71 | - | ||
72 | static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattrs) | ||
73 | { | ||
74 | /* | ||
75 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/arm/ptw.c | ||
78 | +++ b/target/arm/ptw.c | ||
79 | @@ -XXX,XX +XXX,XX @@ | ||
80 | #include "ptw.h" | ||
81 | |||
82 | |||
83 | +static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
84 | + uint32_t *table, uint32_t address) | ||
85 | +{ | ||
86 | + /* Note that we can only get here for an AArch32 PL0/PL1 lookup */ | ||
87 | + TCR *tcr = regime_tcr(env, mmu_idx); | ||
88 | + | ||
89 | + if (address & tcr->mask) { | ||
90 | + if (tcr->raw_tcr & TTBCR_PD1) { | ||
91 | + /* Translation table walk disabled for TTBR1 */ | ||
92 | + return false; | ||
93 | + } | ||
94 | + *table = regime_ttbr(env, mmu_idx, 1) & 0xffffc000; | ||
95 | + } else { | ||
96 | + if (tcr->raw_tcr & TTBCR_PD0) { | ||
97 | + /* Translation table walk disabled for TTBR0 */ | ||
98 | + return false; | ||
99 | + } | ||
100 | + *table = regime_ttbr(env, mmu_idx, 0) & tcr->base_mask; | ||
101 | + } | ||
102 | + *table |= (address >> 18) & 0x3ffc; | ||
103 | + return true; | ||
104 | +} | ||
105 | + | ||
106 | static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
107 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
108 | hwaddr *phys_ptr, int *prot, | ||
109 | -- | ||
110 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | There are a handful of helpers for combine_cacheattrs | ||
4 | that we can move at the same time as the main entry point. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220604040607.269301-15-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/ptw.h | 3 - | ||
12 | target/arm/helper.c | 218 ------------------------------------------- | ||
13 | target/arm/ptw.c | 221 ++++++++++++++++++++++++++++++++++++++++++++ | ||
14 | 3 files changed, 221 insertions(+), 221 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/ptw.h | ||
19 | +++ b/target/arm/ptw.h | ||
20 | @@ -XXX,XX +XXX,XX @@ bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
21 | bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
22 | uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); | ||
23 | |||
24 | -ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
25 | - ARMCacheAttrs s1, ARMCacheAttrs s2); | ||
26 | - | ||
27 | int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
28 | int ap, int domain_prot); | ||
29 | int simple_ap_to_rw_prot_is_user(int ap, bool is_user); | ||
30 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/helper.c | ||
33 | +++ b/target/arm/helper.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, | ||
35 | } | ||
36 | return true; | ||
37 | } | ||
38 | - | ||
39 | -/* Translate from the 4-bit stage 2 representation of | ||
40 | - * memory attributes (without cache-allocation hints) to | ||
41 | - * the 8-bit representation of the stage 1 MAIR registers | ||
42 | - * (which includes allocation hints). | ||
43 | - * | ||
44 | - * ref: shared/translation/attrs/S2AttrDecode() | ||
45 | - * .../S2ConvertAttrsHints() | ||
46 | - */ | ||
47 | -static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs) | ||
48 | -{ | ||
49 | - uint8_t hiattr = extract32(s2attrs, 2, 2); | ||
50 | - uint8_t loattr = extract32(s2attrs, 0, 2); | ||
51 | - uint8_t hihint = 0, lohint = 0; | ||
52 | - | ||
53 | - if (hiattr != 0) { /* normal memory */ | ||
54 | - if (arm_hcr_el2_eff(env) & HCR_CD) { /* cache disabled */ | ||
55 | - hiattr = loattr = 1; /* non-cacheable */ | ||
56 | - } else { | ||
57 | - if (hiattr != 1) { /* Write-through or write-back */ | ||
58 | - hihint = 3; /* RW allocate */ | ||
59 | - } | ||
60 | - if (loattr != 1) { /* Write-through or write-back */ | ||
61 | - lohint = 3; /* RW allocate */ | ||
62 | - } | ||
63 | - } | ||
64 | - } | ||
65 | - | ||
66 | - return (hiattr << 6) | (hihint << 4) | (loattr << 2) | lohint; | ||
67 | -} | ||
68 | #endif /* !CONFIG_USER_ONLY */ | ||
69 | |||
70 | /* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. */ | ||
71 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
72 | return true; | ||
73 | } | ||
74 | |||
75 | -/* Combine either inner or outer cacheability attributes for normal | ||
76 | - * memory, according to table D4-42 and pseudocode procedure | ||
77 | - * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). | ||
78 | - * | ||
79 | - * NB: only stage 1 includes allocation hints (RW bits), leading to | ||
80 | - * some asymmetry. | ||
81 | - */ | ||
82 | -static uint8_t combine_cacheattr_nibble(uint8_t s1, uint8_t s2) | ||
83 | -{ | ||
84 | - if (s1 == 4 || s2 == 4) { | ||
85 | - /* non-cacheable has precedence */ | ||
86 | - return 4; | ||
87 | - } else if (extract32(s1, 2, 2) == 0 || extract32(s1, 2, 2) == 2) { | ||
88 | - /* stage 1 write-through takes precedence */ | ||
89 | - return s1; | ||
90 | - } else if (extract32(s2, 2, 2) == 2) { | ||
91 | - /* stage 2 write-through takes precedence, but the allocation hint | ||
92 | - * is still taken from stage 1 | ||
93 | - */ | ||
94 | - return (2 << 2) | extract32(s1, 0, 2); | ||
95 | - } else { /* write-back */ | ||
96 | - return s1; | ||
97 | - } | ||
98 | -} | ||
99 | - | ||
100 | -/* | ||
101 | - * Combine the memory type and cacheability attributes of | ||
102 | - * s1 and s2 for the HCR_EL2.FWB == 0 case, returning the | ||
103 | - * combined attributes in MAIR_EL1 format. | ||
104 | - */ | ||
105 | -static uint8_t combined_attrs_nofwb(CPUARMState *env, | ||
106 | - ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
107 | -{ | ||
108 | - uint8_t s1lo, s2lo, s1hi, s2hi, s2_mair_attrs, ret_attrs; | ||
109 | - | ||
110 | - s2_mair_attrs = convert_stage2_attrs(env, s2.attrs); | ||
111 | - | ||
112 | - s1lo = extract32(s1.attrs, 0, 4); | ||
113 | - s2lo = extract32(s2_mair_attrs, 0, 4); | ||
114 | - s1hi = extract32(s1.attrs, 4, 4); | ||
115 | - s2hi = extract32(s2_mair_attrs, 4, 4); | ||
116 | - | ||
117 | - /* Combine memory type and cacheability attributes */ | ||
118 | - if (s1hi == 0 || s2hi == 0) { | ||
119 | - /* Device has precedence over normal */ | ||
120 | - if (s1lo == 0 || s2lo == 0) { | ||
121 | - /* nGnRnE has precedence over anything */ | ||
122 | - ret_attrs = 0; | ||
123 | - } else if (s1lo == 4 || s2lo == 4) { | ||
124 | - /* non-Reordering has precedence over Reordering */ | ||
125 | - ret_attrs = 4; /* nGnRE */ | ||
126 | - } else if (s1lo == 8 || s2lo == 8) { | ||
127 | - /* non-Gathering has precedence over Gathering */ | ||
128 | - ret_attrs = 8; /* nGRE */ | ||
129 | - } else { | ||
130 | - ret_attrs = 0xc; /* GRE */ | ||
131 | - } | ||
132 | - } else { /* Normal memory */ | ||
133 | - /* Outer/inner cacheability combine independently */ | ||
134 | - ret_attrs = combine_cacheattr_nibble(s1hi, s2hi) << 4 | ||
135 | - | combine_cacheattr_nibble(s1lo, s2lo); | ||
136 | - } | ||
137 | - return ret_attrs; | ||
138 | -} | ||
139 | - | ||
140 | -static uint8_t force_cacheattr_nibble_wb(uint8_t attr) | ||
141 | -{ | ||
142 | - /* | ||
143 | - * Given the 4 bits specifying the outer or inner cacheability | ||
144 | - * in MAIR format, return a value specifying Normal Write-Back, | ||
145 | - * with the allocation and transient hints taken from the input | ||
146 | - * if the input specified some kind of cacheable attribute. | ||
147 | - */ | ||
148 | - if (attr == 0 || attr == 4) { | ||
149 | - /* | ||
150 | - * 0 == an UNPREDICTABLE encoding | ||
151 | - * 4 == Non-cacheable | ||
152 | - * Either way, force Write-Back RW allocate non-transient | ||
153 | - */ | ||
154 | - return 0xf; | ||
155 | - } | ||
156 | - /* Change WriteThrough to WriteBack, keep allocation and transient hints */ | ||
157 | - return attr | 4; | ||
158 | -} | ||
159 | - | ||
160 | -/* | ||
161 | - * Combine the memory type and cacheability attributes of | ||
162 | - * s1 and s2 for the HCR_EL2.FWB == 1 case, returning the | ||
163 | - * combined attributes in MAIR_EL1 format. | ||
164 | - */ | ||
165 | -static uint8_t combined_attrs_fwb(CPUARMState *env, | ||
166 | - ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
167 | -{ | ||
168 | - switch (s2.attrs) { | ||
169 | - case 7: | ||
170 | - /* Use stage 1 attributes */ | ||
171 | - return s1.attrs; | ||
172 | - case 6: | ||
173 | - /* | ||
174 | - * Force Normal Write-Back. Note that if S1 is Normal cacheable | ||
175 | - * then we take the allocation hints from it; otherwise it is | ||
176 | - * RW allocate, non-transient. | ||
177 | - */ | ||
178 | - if ((s1.attrs & 0xf0) == 0) { | ||
179 | - /* S1 is Device */ | ||
180 | - return 0xff; | ||
181 | - } | ||
182 | - /* Need to check the Inner and Outer nibbles separately */ | ||
183 | - return force_cacheattr_nibble_wb(s1.attrs & 0xf) | | ||
184 | - force_cacheattr_nibble_wb(s1.attrs >> 4) << 4; | ||
185 | - case 5: | ||
186 | - /* If S1 attrs are Device, use them; otherwise Normal Non-cacheable */ | ||
187 | - if ((s1.attrs & 0xf0) == 0) { | ||
188 | - return s1.attrs; | ||
189 | - } | ||
190 | - return 0x44; | ||
191 | - case 0 ... 3: | ||
192 | - /* Force Device, of subtype specified by S2 */ | ||
193 | - return s2.attrs << 2; | ||
194 | - default: | ||
195 | - /* | ||
196 | - * RESERVED values (including RES0 descriptor bit [5] being nonzero); | ||
197 | - * arbitrarily force Device. | ||
198 | - */ | ||
199 | - return 0; | ||
200 | - } | ||
201 | -} | ||
202 | - | ||
203 | -/* Combine S1 and S2 cacheability/shareability attributes, per D4.5.4 | ||
204 | - * and CombineS1S2Desc() | ||
205 | - * | ||
206 | - * @env: CPUARMState | ||
207 | - * @s1: Attributes from stage 1 walk | ||
208 | - * @s2: Attributes from stage 2 walk | ||
209 | - */ | ||
210 | -ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
211 | - ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
212 | -{ | ||
213 | - ARMCacheAttrs ret; | ||
214 | - bool tagged = false; | ||
215 | - | ||
216 | - assert(s2.is_s2_format && !s1.is_s2_format); | ||
217 | - ret.is_s2_format = false; | ||
218 | - | ||
219 | - if (s1.attrs == 0xf0) { | ||
220 | - tagged = true; | ||
221 | - s1.attrs = 0xff; | ||
222 | - } | ||
223 | - | ||
224 | - /* Combine shareability attributes (table D4-43) */ | ||
225 | - if (s1.shareability == 2 || s2.shareability == 2) { | ||
226 | - /* if either are outer-shareable, the result is outer-shareable */ | ||
227 | - ret.shareability = 2; | ||
228 | - } else if (s1.shareability == 3 || s2.shareability == 3) { | ||
229 | - /* if either are inner-shareable, the result is inner-shareable */ | ||
230 | - ret.shareability = 3; | ||
231 | - } else { | ||
232 | - /* both non-shareable */ | ||
233 | - ret.shareability = 0; | ||
234 | - } | ||
235 | - | ||
236 | - /* Combine memory type and cacheability attributes */ | ||
237 | - if (arm_hcr_el2_eff(env) & HCR_FWB) { | ||
238 | - ret.attrs = combined_attrs_fwb(env, s1, s2); | ||
239 | - } else { | ||
240 | - ret.attrs = combined_attrs_nofwb(env, s1, s2); | ||
241 | - } | ||
242 | - | ||
243 | - /* | ||
244 | - * Any location for which the resultant memory type is any | ||
245 | - * type of Device memory is always treated as Outer Shareable. | ||
246 | - * Any location for which the resultant memory type is Normal | ||
247 | - * Inner Non-cacheable, Outer Non-cacheable is always treated | ||
248 | - * as Outer Shareable. | ||
249 | - * TODO: FEAT_XS adds another value (0x40) also meaning iNCoNC | ||
250 | - */ | ||
251 | - if ((ret.attrs & 0xf0) == 0 || ret.attrs == 0x44) { | ||
252 | - ret.shareability = 2; | ||
253 | - } | ||
254 | - | ||
255 | - /* TODO: CombineS1S2Desc does not consider transient, only WB, RWA. */ | ||
256 | - if (tagged && ret.attrs == 0xff) { | ||
257 | - ret.attrs = 0xf0; | ||
258 | - } | ||
259 | - | ||
260 | - return ret; | ||
261 | -} | ||
262 | - | ||
263 | hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, | ||
264 | MemTxAttrs *attrs) | ||
265 | { | ||
266 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
267 | index XXXXXXX..XXXXXXX 100644 | ||
268 | --- a/target/arm/ptw.c | ||
269 | +++ b/target/arm/ptw.c | ||
270 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
271 | return ret; | ||
272 | } | ||
273 | |||
274 | +/* | ||
275 | + * Translate from the 4-bit stage 2 representation of | ||
276 | + * memory attributes (without cache-allocation hints) to | ||
277 | + * the 8-bit representation of the stage 1 MAIR registers | ||
278 | + * (which includes allocation hints). | ||
279 | + * | ||
280 | + * ref: shared/translation/attrs/S2AttrDecode() | ||
281 | + * .../S2ConvertAttrsHints() | ||
282 | + */ | ||
283 | +static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs) | ||
284 | +{ | ||
285 | + uint8_t hiattr = extract32(s2attrs, 2, 2); | ||
286 | + uint8_t loattr = extract32(s2attrs, 0, 2); | ||
287 | + uint8_t hihint = 0, lohint = 0; | ||
288 | + | ||
289 | + if (hiattr != 0) { /* normal memory */ | ||
290 | + if (arm_hcr_el2_eff(env) & HCR_CD) { /* cache disabled */ | ||
291 | + hiattr = loattr = 1; /* non-cacheable */ | ||
292 | + } else { | ||
293 | + if (hiattr != 1) { /* Write-through or write-back */ | ||
294 | + hihint = 3; /* RW allocate */ | ||
295 | + } | ||
296 | + if (loattr != 1) { /* Write-through or write-back */ | ||
297 | + lohint = 3; /* RW allocate */ | ||
298 | + } | ||
299 | + } | ||
300 | + } | ||
301 | + | ||
302 | + return (hiattr << 6) | (hihint << 4) | (loattr << 2) | lohint; | ||
303 | +} | ||
304 | + | ||
305 | +/* | ||
306 | + * Combine either inner or outer cacheability attributes for normal | ||
307 | + * memory, according to table D4-42 and pseudocode procedure | ||
308 | + * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). | ||
309 | + * | ||
310 | + * NB: only stage 1 includes allocation hints (RW bits), leading to | ||
311 | + * some asymmetry. | ||
312 | + */ | ||
313 | +static uint8_t combine_cacheattr_nibble(uint8_t s1, uint8_t s2) | ||
314 | +{ | ||
315 | + if (s1 == 4 || s2 == 4) { | ||
316 | + /* non-cacheable has precedence */ | ||
317 | + return 4; | ||
318 | + } else if (extract32(s1, 2, 2) == 0 || extract32(s1, 2, 2) == 2) { | ||
319 | + /* stage 1 write-through takes precedence */ | ||
320 | + return s1; | ||
321 | + } else if (extract32(s2, 2, 2) == 2) { | ||
322 | + /* stage 2 write-through takes precedence, but the allocation hint | ||
323 | + * is still taken from stage 1 | ||
324 | + */ | ||
325 | + return (2 << 2) | extract32(s1, 0, 2); | ||
326 | + } else { /* write-back */ | ||
327 | + return s1; | ||
328 | + } | ||
329 | +} | ||
330 | + | ||
331 | +/* | ||
332 | + * Combine the memory type and cacheability attributes of | ||
333 | + * s1 and s2 for the HCR_EL2.FWB == 0 case, returning the | ||
334 | + * combined attributes in MAIR_EL1 format. | ||
335 | + */ | ||
336 | +static uint8_t combined_attrs_nofwb(CPUARMState *env, | ||
337 | + ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
338 | +{ | ||
339 | + uint8_t s1lo, s2lo, s1hi, s2hi, s2_mair_attrs, ret_attrs; | ||
340 | + | ||
341 | + s2_mair_attrs = convert_stage2_attrs(env, s2.attrs); | ||
342 | + | ||
343 | + s1lo = extract32(s1.attrs, 0, 4); | ||
344 | + s2lo = extract32(s2_mair_attrs, 0, 4); | ||
345 | + s1hi = extract32(s1.attrs, 4, 4); | ||
346 | + s2hi = extract32(s2_mair_attrs, 4, 4); | ||
347 | + | ||
348 | + /* Combine memory type and cacheability attributes */ | ||
349 | + if (s1hi == 0 || s2hi == 0) { | ||
350 | + /* Device has precedence over normal */ | ||
351 | + if (s1lo == 0 || s2lo == 0) { | ||
352 | + /* nGnRnE has precedence over anything */ | ||
353 | + ret_attrs = 0; | ||
354 | + } else if (s1lo == 4 || s2lo == 4) { | ||
355 | + /* non-Reordering has precedence over Reordering */ | ||
356 | + ret_attrs = 4; /* nGnRE */ | ||
357 | + } else if (s1lo == 8 || s2lo == 8) { | ||
358 | + /* non-Gathering has precedence over Gathering */ | ||
359 | + ret_attrs = 8; /* nGRE */ | ||
360 | + } else { | ||
361 | + ret_attrs = 0xc; /* GRE */ | ||
362 | + } | ||
363 | + } else { /* Normal memory */ | ||
364 | + /* Outer/inner cacheability combine independently */ | ||
365 | + ret_attrs = combine_cacheattr_nibble(s1hi, s2hi) << 4 | ||
366 | + | combine_cacheattr_nibble(s1lo, s2lo); | ||
367 | + } | ||
368 | + return ret_attrs; | ||
369 | +} | ||
370 | + | ||
371 | +static uint8_t force_cacheattr_nibble_wb(uint8_t attr) | ||
372 | +{ | ||
373 | + /* | ||
374 | + * Given the 4 bits specifying the outer or inner cacheability | ||
375 | + * in MAIR format, return a value specifying Normal Write-Back, | ||
376 | + * with the allocation and transient hints taken from the input | ||
377 | + * if the input specified some kind of cacheable attribute. | ||
378 | + */ | ||
379 | + if (attr == 0 || attr == 4) { | ||
380 | + /* | ||
381 | + * 0 == an UNPREDICTABLE encoding | ||
382 | + * 4 == Non-cacheable | ||
383 | + * Either way, force Write-Back RW allocate non-transient | ||
384 | + */ | ||
385 | + return 0xf; | ||
386 | + } | ||
387 | + /* Change WriteThrough to WriteBack, keep allocation and transient hints */ | ||
388 | + return attr | 4; | ||
389 | +} | ||
390 | + | ||
391 | +/* | ||
392 | + * Combine the memory type and cacheability attributes of | ||
393 | + * s1 and s2 for the HCR_EL2.FWB == 1 case, returning the | ||
394 | + * combined attributes in MAIR_EL1 format. | ||
395 | + */ | ||
396 | +static uint8_t combined_attrs_fwb(CPUARMState *env, | ||
397 | + ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
398 | +{ | ||
399 | + switch (s2.attrs) { | ||
400 | + case 7: | ||
401 | + /* Use stage 1 attributes */ | ||
402 | + return s1.attrs; | ||
403 | + case 6: | ||
404 | + /* | ||
405 | + * Force Normal Write-Back. Note that if S1 is Normal cacheable | ||
406 | + * then we take the allocation hints from it; otherwise it is | ||
407 | + * RW allocate, non-transient. | ||
408 | + */ | ||
409 | + if ((s1.attrs & 0xf0) == 0) { | ||
410 | + /* S1 is Device */ | ||
411 | + return 0xff; | ||
412 | + } | ||
413 | + /* Need to check the Inner and Outer nibbles separately */ | ||
414 | + return force_cacheattr_nibble_wb(s1.attrs & 0xf) | | ||
415 | + force_cacheattr_nibble_wb(s1.attrs >> 4) << 4; | ||
416 | + case 5: | ||
417 | + /* If S1 attrs are Device, use them; otherwise Normal Non-cacheable */ | ||
418 | + if ((s1.attrs & 0xf0) == 0) { | ||
419 | + return s1.attrs; | ||
420 | + } | ||
421 | + return 0x44; | ||
422 | + case 0 ... 3: | ||
423 | + /* Force Device, of subtype specified by S2 */ | ||
424 | + return s2.attrs << 2; | ||
425 | + default: | ||
426 | + /* | ||
427 | + * RESERVED values (including RES0 descriptor bit [5] being nonzero); | ||
428 | + * arbitrarily force Device. | ||
429 | + */ | ||
430 | + return 0; | ||
431 | + } | ||
432 | +} | ||
433 | + | ||
434 | +/* | ||
435 | + * Combine S1 and S2 cacheability/shareability attributes, per D4.5.4 | ||
436 | + * and CombineS1S2Desc() | ||
437 | + * | ||
438 | + * @env: CPUARMState | ||
439 | + * @s1: Attributes from stage 1 walk | ||
440 | + * @s2: Attributes from stage 2 walk | ||
441 | + */ | ||
442 | +static ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
443 | + ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
444 | +{ | ||
445 | + ARMCacheAttrs ret; | ||
446 | + bool tagged = false; | ||
447 | + | ||
448 | + assert(s2.is_s2_format && !s1.is_s2_format); | ||
449 | + ret.is_s2_format = false; | ||
450 | + | ||
451 | + if (s1.attrs == 0xf0) { | ||
452 | + tagged = true; | ||
453 | + s1.attrs = 0xff; | ||
454 | + } | ||
455 | + | ||
456 | + /* Combine shareability attributes (table D4-43) */ | ||
457 | + if (s1.shareability == 2 || s2.shareability == 2) { | ||
458 | + /* if either are outer-shareable, the result is outer-shareable */ | ||
459 | + ret.shareability = 2; | ||
460 | + } else if (s1.shareability == 3 || s2.shareability == 3) { | ||
461 | + /* if either are inner-shareable, the result is inner-shareable */ | ||
462 | + ret.shareability = 3; | ||
463 | + } else { | ||
464 | + /* both non-shareable */ | ||
465 | + ret.shareability = 0; | ||
466 | + } | ||
467 | + | ||
468 | + /* Combine memory type and cacheability attributes */ | ||
469 | + if (arm_hcr_el2_eff(env) & HCR_FWB) { | ||
470 | + ret.attrs = combined_attrs_fwb(env, s1, s2); | ||
471 | + } else { | ||
472 | + ret.attrs = combined_attrs_nofwb(env, s1, s2); | ||
473 | + } | ||
474 | + | ||
475 | + /* | ||
476 | + * Any location for which the resultant memory type is any | ||
477 | + * type of Device memory is always treated as Outer Shareable. | ||
478 | + * Any location for which the resultant memory type is Normal | ||
479 | + * Inner Non-cacheable, Outer Non-cacheable is always treated | ||
480 | + * as Outer Shareable. | ||
481 | + * TODO: FEAT_XS adds another value (0x40) also meaning iNCoNC | ||
482 | + */ | ||
483 | + if ((ret.attrs & 0xf0) == 0 || ret.attrs == 0x44) { | ||
484 | + ret.shareability = 2; | ||
485 | + } | ||
486 | + | ||
487 | + /* TODO: CombineS1S2Desc does not consider transient, only WB, RWA. */ | ||
488 | + if (tagged && ret.attrs == 0xff) { | ||
489 | + ret.attrs = 0xf0; | ||
490 | + } | ||
491 | + | ||
492 | + return ret; | ||
493 | +} | ||
494 | + | ||
495 | /** | ||
496 | * get_phys_addr - get the physical address for this virtual address | ||
497 | * | ||
498 | -- | ||
499 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-16-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 10 ++ | ||
9 | target/arm/helper.c | 416 +------------------------------------------- | ||
10 | target/arm/ptw.c | 411 +++++++++++++++++++++++++++++++++++++++++++ | ||
11 | 3 files changed, 429 insertions(+), 408 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | |||
19 | #ifndef CONFIG_USER_ONLY | ||
20 | |||
21 | +extern const uint8_t pamax_map[7]; | ||
22 | + | ||
23 | uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
24 | ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi); | ||
25 | uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
26 | @@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | ||
27 | return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); | ||
28 | } | ||
29 | |||
30 | +ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
31 | + ARMMMUIdx mmu_idx); | ||
32 | +bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, | ||
33 | + int inputsize, int stride, int outputsize); | ||
34 | +int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0); | ||
35 | +int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, | ||
36 | + int ap, int ns, int xn, int pxn); | ||
37 | + | ||
38 | bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
39 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
40 | bool s1_is_el0, | ||
41 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/helper.c | ||
44 | +++ b/target/arm/helper.c | ||
45 | @@ -XXX,XX +XXX,XX @@ int simple_ap_to_rw_prot_is_user(int ap, bool is_user) | ||
46 | * @xn: XN (execute-never) bits | ||
47 | * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0 | ||
48 | */ | ||
49 | -static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) | ||
50 | +int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) | ||
51 | { | ||
52 | int prot = 0; | ||
53 | |||
54 | @@ -XXX,XX +XXX,XX @@ static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) | ||
55 | * @xn: XN (execute-never) bit | ||
56 | * @pxn: PXN (privileged execute-never) bit | ||
57 | */ | ||
58 | -static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, | ||
59 | - int ap, int ns, int xn, int pxn) | ||
60 | +int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, | ||
61 | + int ap, int ns, int xn, int pxn) | ||
62 | { | ||
63 | bool is_user = regime_is_user(env, mmu_idx); | ||
64 | int prot_rw, user_rw; | ||
65 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
66 | * Returns true if the suggested S2 translation parameters are OK and | ||
67 | * false otherwise. | ||
68 | */ | ||
69 | -static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, | ||
70 | - int inputsize, int stride, int outputsize) | ||
71 | +bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, | ||
72 | + int inputsize, int stride, int outputsize) | ||
73 | { | ||
74 | const int grainsize = stride + 3; | ||
75 | int startsizecheck; | ||
76 | @@ -XXX,XX +XXX,XX @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, | ||
77 | #endif /* !CONFIG_USER_ONLY */ | ||
78 | |||
79 | /* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. */ | ||
80 | -static const uint8_t pamax_map[] = { | ||
81 | +const uint8_t pamax_map[] = { | ||
82 | [0] = 32, | ||
83 | [1] = 36, | ||
84 | [2] = 40, | ||
85 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
86 | } | ||
87 | |||
88 | #ifndef CONFIG_USER_ONLY | ||
89 | -static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
90 | - ARMMMUIdx mmu_idx) | ||
91 | +ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
92 | + ARMMMUIdx mmu_idx) | ||
93 | { | ||
94 | uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | ||
95 | uint32_t el = regime_el(env, mmu_idx); | ||
96 | @@ -XXX,XX +XXX,XX @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
97 | }; | ||
98 | } | ||
99 | |||
100 | -/** | ||
101 | - * get_phys_addr_lpae: perform one stage of page table walk, LPAE format | ||
102 | - * | ||
103 | - * Returns false if the translation was successful. Otherwise, phys_ptr, attrs, | ||
104 | - * prot and page_size may not be filled in, and the populated fsr value provides | ||
105 | - * information on why the translation aborted, in the format of a long-format | ||
106 | - * DFSR/IFSR fault register, with the following caveats: | ||
107 | - * * the WnR bit is never set (the caller must do this). | ||
108 | - * | ||
109 | - * @env: CPUARMState | ||
110 | - * @address: virtual address to get physical address for | ||
111 | - * @access_type: MMU_DATA_LOAD, MMU_DATA_STORE or MMU_INST_FETCH | ||
112 | - * @mmu_idx: MMU index indicating required translation regime | ||
113 | - * @s1_is_el0: if @mmu_idx is ARMMMUIdx_Stage2 (so this is a stage 2 page table | ||
114 | - * walk), must be true if this is stage 2 of a stage 1+2 walk for an | ||
115 | - * EL0 access). If @mmu_idx is anything else, @s1_is_el0 is ignored. | ||
116 | - * @phys_ptr: set to the physical address corresponding to the virtual address | ||
117 | - * @attrs: set to the memory transaction attributes to use | ||
118 | - * @prot: set to the permissions for the page containing phys_ptr | ||
119 | - * @page_size_ptr: set to the size of the page containing phys_ptr | ||
120 | - * @fi: set to fault info if the translation fails | ||
121 | - * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | ||
122 | - */ | ||
123 | -bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
124 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
125 | - bool s1_is_el0, | ||
126 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
127 | - target_ulong *page_size_ptr, | ||
128 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
129 | -{ | ||
130 | - ARMCPU *cpu = env_archcpu(env); | ||
131 | - CPUState *cs = CPU(cpu); | ||
132 | - /* Read an LPAE long-descriptor translation table. */ | ||
133 | - ARMFaultType fault_type = ARMFault_Translation; | ||
134 | - uint32_t level; | ||
135 | - ARMVAParameters param; | ||
136 | - uint64_t ttbr; | ||
137 | - hwaddr descaddr, indexmask, indexmask_grainsize; | ||
138 | - uint32_t tableattrs; | ||
139 | - target_ulong page_size; | ||
140 | - uint32_t attrs; | ||
141 | - int32_t stride; | ||
142 | - int addrsize, inputsize, outputsize; | ||
143 | - TCR *tcr = regime_tcr(env, mmu_idx); | ||
144 | - int ap, ns, xn, pxn; | ||
145 | - uint32_t el = regime_el(env, mmu_idx); | ||
146 | - uint64_t descaddrmask; | ||
147 | - bool aarch64 = arm_el_is_aa64(env, el); | ||
148 | - bool guarded = false; | ||
149 | - | ||
150 | - /* TODO: This code does not support shareability levels. */ | ||
151 | - if (aarch64) { | ||
152 | - int ps; | ||
153 | - | ||
154 | - param = aa64_va_parameters(env, address, mmu_idx, | ||
155 | - access_type != MMU_INST_FETCH); | ||
156 | - level = 0; | ||
157 | - | ||
158 | - /* | ||
159 | - * If TxSZ is programmed to a value larger than the maximum, | ||
160 | - * or smaller than the effective minimum, it is IMPLEMENTATION | ||
161 | - * DEFINED whether we behave as if the field were programmed | ||
162 | - * within bounds, or if a level 0 Translation fault is generated. | ||
163 | - * | ||
164 | - * With FEAT_LVA, fault on less than minimum becomes required, | ||
165 | - * so our choice is to always raise the fault. | ||
166 | - */ | ||
167 | - if (param.tsz_oob) { | ||
168 | - fault_type = ARMFault_Translation; | ||
169 | - goto do_fault; | ||
170 | - } | ||
171 | - | ||
172 | - addrsize = 64 - 8 * param.tbi; | ||
173 | - inputsize = 64 - param.tsz; | ||
174 | - | ||
175 | - /* | ||
176 | - * Bound PS by PARANGE to find the effective output address size. | ||
177 | - * ID_AA64MMFR0 is a read-only register so values outside of the | ||
178 | - * supported mappings can be considered an implementation error. | ||
179 | - */ | ||
180 | - ps = FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); | ||
181 | - ps = MIN(ps, param.ps); | ||
182 | - assert(ps < ARRAY_SIZE(pamax_map)); | ||
183 | - outputsize = pamax_map[ps]; | ||
184 | - } else { | ||
185 | - param = aa32_va_parameters(env, address, mmu_idx); | ||
186 | - level = 1; | ||
187 | - addrsize = (mmu_idx == ARMMMUIdx_Stage2 ? 40 : 32); | ||
188 | - inputsize = addrsize - param.tsz; | ||
189 | - outputsize = 40; | ||
190 | - } | ||
191 | - | ||
192 | - /* | ||
193 | - * We determined the region when collecting the parameters, but we | ||
194 | - * have not yet validated that the address is valid for the region. | ||
195 | - * Extract the top bits and verify that they all match select. | ||
196 | - * | ||
197 | - * For aa32, if inputsize == addrsize, then we have selected the | ||
198 | - * region by exclusion in aa32_va_parameters and there is no more | ||
199 | - * validation to do here. | ||
200 | - */ | ||
201 | - if (inputsize < addrsize) { | ||
202 | - target_ulong top_bits = sextract64(address, inputsize, | ||
203 | - addrsize - inputsize); | ||
204 | - if (-top_bits != param.select) { | ||
205 | - /* The gap between the two regions is a Translation fault */ | ||
206 | - fault_type = ARMFault_Translation; | ||
207 | - goto do_fault; | ||
208 | - } | ||
209 | - } | ||
210 | - | ||
211 | - if (param.using64k) { | ||
212 | - stride = 13; | ||
213 | - } else if (param.using16k) { | ||
214 | - stride = 11; | ||
215 | - } else { | ||
216 | - stride = 9; | ||
217 | - } | ||
218 | - | ||
219 | - /* Note that QEMU ignores shareability and cacheability attributes, | ||
220 | - * so we don't need to do anything with the SH, ORGN, IRGN fields | ||
221 | - * in the TTBCR. Similarly, TTBCR:A1 selects whether we get the | ||
222 | - * ASID from TTBR0 or TTBR1, but QEMU's TLB doesn't currently | ||
223 | - * implement any ASID-like capability so we can ignore it (instead | ||
224 | - * we will always flush the TLB any time the ASID is changed). | ||
225 | - */ | ||
226 | - ttbr = regime_ttbr(env, mmu_idx, param.select); | ||
227 | - | ||
228 | - /* Here we should have set up all the parameters for the translation: | ||
229 | - * inputsize, ttbr, epd, stride, tbi | ||
230 | - */ | ||
231 | - | ||
232 | - if (param.epd) { | ||
233 | - /* Translation table walk disabled => Translation fault on TLB miss | ||
234 | - * Note: This is always 0 on 64-bit EL2 and EL3. | ||
235 | - */ | ||
236 | - goto do_fault; | ||
237 | - } | ||
238 | - | ||
239 | - if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) { | ||
240 | - /* The starting level depends on the virtual address size (which can | ||
241 | - * be up to 48 bits) and the translation granule size. It indicates | ||
242 | - * the number of strides (stride bits at a time) needed to | ||
243 | - * consume the bits of the input address. In the pseudocode this is: | ||
244 | - * level = 4 - RoundUp((inputsize - grainsize) / stride) | ||
245 | - * where their 'inputsize' is our 'inputsize', 'grainsize' is | ||
246 | - * our 'stride + 3' and 'stride' is our 'stride'. | ||
247 | - * Applying the usual "rounded up m/n is (m+n-1)/n" and simplifying: | ||
248 | - * = 4 - (inputsize - stride - 3 + stride - 1) / stride | ||
249 | - * = 4 - (inputsize - 4) / stride; | ||
250 | - */ | ||
251 | - level = 4 - (inputsize - 4) / stride; | ||
252 | - } else { | ||
253 | - /* For stage 2 translations the starting level is specified by the | ||
254 | - * VTCR_EL2.SL0 field (whose interpretation depends on the page size) | ||
255 | - */ | ||
256 | - uint32_t sl0 = extract32(tcr->raw_tcr, 6, 2); | ||
257 | - uint32_t sl2 = extract64(tcr->raw_tcr, 33, 1); | ||
258 | - uint32_t startlevel; | ||
259 | - bool ok; | ||
260 | - | ||
261 | - /* SL2 is RES0 unless DS=1 & 4kb granule. */ | ||
262 | - if (param.ds && stride == 9 && sl2) { | ||
263 | - if (sl0 != 0) { | ||
264 | - level = 0; | ||
265 | - fault_type = ARMFault_Translation; | ||
266 | - goto do_fault; | ||
267 | - } | ||
268 | - startlevel = -1; | ||
269 | - } else if (!aarch64 || stride == 9) { | ||
270 | - /* AArch32 or 4KB pages */ | ||
271 | - startlevel = 2 - sl0; | ||
272 | - | ||
273 | - if (cpu_isar_feature(aa64_st, cpu)) { | ||
274 | - startlevel &= 3; | ||
275 | - } | ||
276 | - } else { | ||
277 | - /* 16KB or 64KB pages */ | ||
278 | - startlevel = 3 - sl0; | ||
279 | - } | ||
280 | - | ||
281 | - /* Check that the starting level is valid. */ | ||
282 | - ok = check_s2_mmu_setup(cpu, aarch64, startlevel, | ||
283 | - inputsize, stride, outputsize); | ||
284 | - if (!ok) { | ||
285 | - fault_type = ARMFault_Translation; | ||
286 | - goto do_fault; | ||
287 | - } | ||
288 | - level = startlevel; | ||
289 | - } | ||
290 | - | ||
291 | - indexmask_grainsize = MAKE_64BIT_MASK(0, stride + 3); | ||
292 | - indexmask = MAKE_64BIT_MASK(0, inputsize - (stride * (4 - level))); | ||
293 | - | ||
294 | - /* Now we can extract the actual base address from the TTBR */ | ||
295 | - descaddr = extract64(ttbr, 0, 48); | ||
296 | - | ||
297 | - /* | ||
298 | - * For FEAT_LPA and PS=6, bits [51:48] of descaddr are in [5:2] of TTBR. | ||
299 | - * | ||
300 | - * Otherwise, if the base address is out of range, raise AddressSizeFault. | ||
301 | - * In the pseudocode, this is !IsZero(baseregister<47:outputsize>), | ||
302 | - * but we've just cleared the bits above 47, so simplify the test. | ||
303 | - */ | ||
304 | - if (outputsize > 48) { | ||
305 | - descaddr |= extract64(ttbr, 2, 4) << 48; | ||
306 | - } else if (descaddr >> outputsize) { | ||
307 | - level = 0; | ||
308 | - fault_type = ARMFault_AddressSize; | ||
309 | - goto do_fault; | ||
310 | - } | ||
311 | - | ||
312 | - /* | ||
313 | - * We rely on this masking to clear the RES0 bits at the bottom of the TTBR | ||
314 | - * and also to mask out CnP (bit 0) which could validly be non-zero. | ||
315 | - */ | ||
316 | - descaddr &= ~indexmask; | ||
317 | - | ||
318 | - /* | ||
319 | - * For AArch32, the address field in the descriptor goes up to bit 39 | ||
320 | - * for both v7 and v8. However, for v8 the SBZ bits [47:40] must be 0 | ||
321 | - * or an AddressSize fault is raised. So for v8 we extract those SBZ | ||
322 | - * bits as part of the address, which will be checked via outputsize. | ||
323 | - * For AArch64, the address field goes up to bit 47, or 49 with FEAT_LPA2; | ||
324 | - * the highest bits of a 52-bit output are placed elsewhere. | ||
325 | - */ | ||
326 | - if (param.ds) { | ||
327 | - descaddrmask = MAKE_64BIT_MASK(0, 50); | ||
328 | - } else if (arm_feature(env, ARM_FEATURE_V8)) { | ||
329 | - descaddrmask = MAKE_64BIT_MASK(0, 48); | ||
330 | - } else { | ||
331 | - descaddrmask = MAKE_64BIT_MASK(0, 40); | ||
332 | - } | ||
333 | - descaddrmask &= ~indexmask_grainsize; | ||
334 | - | ||
335 | - /* Secure accesses start with the page table in secure memory and | ||
336 | - * can be downgraded to non-secure at any step. Non-secure accesses | ||
337 | - * remain non-secure. We implement this by just ORing in the NSTable/NS | ||
338 | - * bits at each step. | ||
339 | - */ | ||
340 | - tableattrs = regime_is_secure(env, mmu_idx) ? 0 : (1 << 4); | ||
341 | - for (;;) { | ||
342 | - uint64_t descriptor; | ||
343 | - bool nstable; | ||
344 | - | ||
345 | - descaddr |= (address >> (stride * (4 - level))) & indexmask; | ||
346 | - descaddr &= ~7ULL; | ||
347 | - nstable = extract32(tableattrs, 4, 1); | ||
348 | - descriptor = arm_ldq_ptw(cs, descaddr, !nstable, mmu_idx, fi); | ||
349 | - if (fi->type != ARMFault_None) { | ||
350 | - goto do_fault; | ||
351 | - } | ||
352 | - | ||
353 | - if (!(descriptor & 1) || | ||
354 | - (!(descriptor & 2) && (level == 3))) { | ||
355 | - /* Invalid, or the Reserved level 3 encoding */ | ||
356 | - goto do_fault; | ||
357 | - } | ||
358 | - | ||
359 | - descaddr = descriptor & descaddrmask; | ||
360 | - | ||
361 | - /* | ||
362 | - * For FEAT_LPA and PS=6, bits [51:48] of descaddr are in [15:12] | ||
363 | - * of descriptor. For FEAT_LPA2 and effective DS, bits [51:50] of | ||
364 | - * descaddr are in [9:8]. Otherwise, if descaddr is out of range, | ||
365 | - * raise AddressSizeFault. | ||
366 | - */ | ||
367 | - if (outputsize > 48) { | ||
368 | - if (param.ds) { | ||
369 | - descaddr |= extract64(descriptor, 8, 2) << 50; | ||
370 | - } else { | ||
371 | - descaddr |= extract64(descriptor, 12, 4) << 48; | ||
372 | - } | ||
373 | - } else if (descaddr >> outputsize) { | ||
374 | - fault_type = ARMFault_AddressSize; | ||
375 | - goto do_fault; | ||
376 | - } | ||
377 | - | ||
378 | - if ((descriptor & 2) && (level < 3)) { | ||
379 | - /* Table entry. The top five bits are attributes which may | ||
380 | - * propagate down through lower levels of the table (and | ||
381 | - * which are all arranged so that 0 means "no effect", so | ||
382 | - * we can gather them up by ORing in the bits at each level). | ||
383 | - */ | ||
384 | - tableattrs |= extract64(descriptor, 59, 5); | ||
385 | - level++; | ||
386 | - indexmask = indexmask_grainsize; | ||
387 | - continue; | ||
388 | - } | ||
389 | - /* | ||
390 | - * Block entry at level 1 or 2, or page entry at level 3. | ||
391 | - * These are basically the same thing, although the number | ||
392 | - * of bits we pull in from the vaddr varies. Note that although | ||
393 | - * descaddrmask masks enough of the low bits of the descriptor | ||
394 | - * to give a correct page or table address, the address field | ||
395 | - * in a block descriptor is smaller; so we need to explicitly | ||
396 | - * clear the lower bits here before ORing in the low vaddr bits. | ||
397 | - */ | ||
398 | - page_size = (1ULL << ((stride * (4 - level)) + 3)); | ||
399 | - descaddr &= ~(page_size - 1); | ||
400 | - descaddr |= (address & (page_size - 1)); | ||
401 | - /* Extract attributes from the descriptor */ | ||
402 | - attrs = extract64(descriptor, 2, 10) | ||
403 | - | (extract64(descriptor, 52, 12) << 10); | ||
404 | - | ||
405 | - if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { | ||
406 | - /* Stage 2 table descriptors do not include any attribute fields */ | ||
407 | - break; | ||
408 | - } | ||
409 | - /* Merge in attributes from table descriptors */ | ||
410 | - attrs |= nstable << 3; /* NS */ | ||
411 | - guarded = extract64(descriptor, 50, 1); /* GP */ | ||
412 | - if (param.hpd) { | ||
413 | - /* HPD disables all the table attributes except NSTable. */ | ||
414 | - break; | ||
415 | - } | ||
416 | - attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ | ||
417 | - /* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 | ||
418 | - * means "force PL1 access only", which means forcing AP[1] to 0. | ||
419 | - */ | ||
420 | - attrs &= ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] => AP[1] */ | ||
421 | - attrs |= extract32(tableattrs, 3, 1) << 5; /* APT[1] => AP[2] */ | ||
422 | - break; | ||
423 | - } | ||
424 | - /* Here descaddr is the final physical address, and attributes | ||
425 | - * are all in attrs. | ||
426 | - */ | ||
427 | - fault_type = ARMFault_AccessFlag; | ||
428 | - if ((attrs & (1 << 8)) == 0) { | ||
429 | - /* Access flag */ | ||
430 | - goto do_fault; | ||
431 | - } | ||
432 | - | ||
433 | - ap = extract32(attrs, 4, 2); | ||
434 | - | ||
435 | - if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { | ||
436 | - ns = mmu_idx == ARMMMUIdx_Stage2; | ||
437 | - xn = extract32(attrs, 11, 2); | ||
438 | - *prot = get_S2prot(env, ap, xn, s1_is_el0); | ||
439 | - } else { | ||
440 | - ns = extract32(attrs, 3, 1); | ||
441 | - xn = extract32(attrs, 12, 1); | ||
442 | - pxn = extract32(attrs, 11, 1); | ||
443 | - *prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); | ||
444 | - } | ||
445 | - | ||
446 | - fault_type = ARMFault_Permission; | ||
447 | - if (!(*prot & (1 << access_type))) { | ||
448 | - goto do_fault; | ||
449 | - } | ||
450 | - | ||
451 | - if (ns) { | ||
452 | - /* The NS bit will (as required by the architecture) have no effect if | ||
453 | - * the CPU doesn't support TZ or this is a non-secure translation | ||
454 | - * regime, because the attribute will already be non-secure. | ||
455 | - */ | ||
456 | - txattrs->secure = false; | ||
457 | - } | ||
458 | - /* When in aarch64 mode, and BTI is enabled, remember GP in the IOTLB. */ | ||
459 | - if (aarch64 && guarded && cpu_isar_feature(aa64_bti, cpu)) { | ||
460 | - arm_tlb_bti_gp(txattrs) = true; | ||
461 | - } | ||
462 | - | ||
463 | - if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { | ||
464 | - cacheattrs->is_s2_format = true; | ||
465 | - cacheattrs->attrs = extract32(attrs, 0, 4); | ||
466 | - } else { | ||
467 | - /* Index into MAIR registers for cache attributes */ | ||
468 | - uint8_t attrindx = extract32(attrs, 0, 3); | ||
469 | - uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; | ||
470 | - assert(attrindx <= 7); | ||
471 | - cacheattrs->is_s2_format = false; | ||
472 | - cacheattrs->attrs = extract64(mair, attrindx * 8, 8); | ||
473 | - } | ||
474 | - | ||
475 | - /* | ||
476 | - * For FEAT_LPA2 and effective DS, the SH field in the attributes | ||
477 | - * was re-purposed for output address bits. The SH attribute in | ||
478 | - * that case comes from TCR_ELx, which we extracted earlier. | ||
479 | - */ | ||
480 | - if (param.ds) { | ||
481 | - cacheattrs->shareability = param.sh; | ||
482 | - } else { | ||
483 | - cacheattrs->shareability = extract32(attrs, 6, 2); | ||
484 | - } | ||
485 | - | ||
486 | - *phys_ptr = descaddr; | ||
487 | - *page_size_ptr = page_size; | ||
488 | - return false; | ||
489 | - | ||
490 | -do_fault: | ||
491 | - fi->type = fault_type; | ||
492 | - fi->level = level; | ||
493 | - /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ | ||
494 | - fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2 || | ||
495 | - mmu_idx == ARMMMUIdx_Stage2_S); | ||
496 | - fi->s1ns = mmu_idx == ARMMMUIdx_Stage2; | ||
497 | - return true; | ||
498 | -} | ||
499 | - | ||
500 | hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, | ||
501 | MemTxAttrs *attrs) | ||
502 | { | ||
503 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
504 | index XXXXXXX..XXXXXXX 100644 | ||
505 | --- a/target/arm/ptw.c | ||
506 | +++ b/target/arm/ptw.c | ||
507 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
508 | return true; | ||
509 | } | ||
510 | |||
511 | +/** | ||
512 | + * get_phys_addr_lpae: perform one stage of page table walk, LPAE format | ||
513 | + * | ||
514 | + * Returns false if the translation was successful. Otherwise, phys_ptr, | ||
515 | + * attrs, prot and page_size may not be filled in, and the populated fsr | ||
516 | + * value provides information on why the translation aborted, in the format | ||
517 | + * of a long-format DFSR/IFSR fault register, with the following caveat: | ||
518 | + * the WnR bit is never set (the caller must do this). | ||
519 | + * | ||
520 | + * @env: CPUARMState | ||
521 | + * @address: virtual address to get physical address for | ||
522 | + * @access_type: MMU_DATA_LOAD, MMU_DATA_STORE or MMU_INST_FETCH | ||
523 | + * @mmu_idx: MMU index indicating required translation regime | ||
524 | + * @s1_is_el0: if @mmu_idx is ARMMMUIdx_Stage2 (so this is a stage 2 page | ||
525 | + * table walk), must be true if this is stage 2 of a stage 1+2 | ||
526 | + * walk for an EL0 access. If @mmu_idx is anything else, | ||
527 | + * @s1_is_el0 is ignored. | ||
528 | + * @phys_ptr: set to the physical address corresponding to the virtual address | ||
529 | + * @attrs: set to the memory transaction attributes to use | ||
530 | + * @prot: set to the permissions for the page containing phys_ptr | ||
531 | + * @page_size_ptr: set to the size of the page containing phys_ptr | ||
532 | + * @fi: set to fault info if the translation fails | ||
533 | + * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | ||
534 | + */ | ||
535 | +bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
536 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
537 | + bool s1_is_el0, | ||
538 | + hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
539 | + target_ulong *page_size_ptr, | ||
540 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
541 | +{ | ||
542 | + ARMCPU *cpu = env_archcpu(env); | ||
543 | + CPUState *cs = CPU(cpu); | ||
544 | + /* Read an LPAE long-descriptor translation table. */ | ||
545 | + ARMFaultType fault_type = ARMFault_Translation; | ||
546 | + uint32_t level; | ||
547 | + ARMVAParameters param; | ||
548 | + uint64_t ttbr; | ||
549 | + hwaddr descaddr, indexmask, indexmask_grainsize; | ||
550 | + uint32_t tableattrs; | ||
551 | + target_ulong page_size; | ||
552 | + uint32_t attrs; | ||
553 | + int32_t stride; | ||
554 | + int addrsize, inputsize, outputsize; | ||
555 | + TCR *tcr = regime_tcr(env, mmu_idx); | ||
556 | + int ap, ns, xn, pxn; | ||
557 | + uint32_t el = regime_el(env, mmu_idx); | ||
558 | + uint64_t descaddrmask; | ||
559 | + bool aarch64 = arm_el_is_aa64(env, el); | ||
560 | + bool guarded = false; | ||
561 | + | ||
562 | + /* TODO: This code does not support shareability levels. */ | ||
563 | + if (aarch64) { | ||
564 | + int ps; | ||
565 | + | ||
566 | + param = aa64_va_parameters(env, address, mmu_idx, | ||
567 | + access_type != MMU_INST_FETCH); | ||
568 | + level = 0; | ||
569 | + | ||
570 | + /* | ||
571 | + * If TxSZ is programmed to a value larger than the maximum, | ||
572 | + * or smaller than the effective minimum, it is IMPLEMENTATION | ||
573 | + * DEFINED whether we behave as if the field were programmed | ||
574 | + * within bounds, or if a level 0 Translation fault is generated. | ||
575 | + * | ||
576 | + * With FEAT_LVA, fault on less than minimum becomes required, | ||
577 | + * so our choice is to always raise the fault. | ||
578 | + */ | ||
579 | + if (param.tsz_oob) { | ||
580 | + fault_type = ARMFault_Translation; | ||
581 | + goto do_fault; | ||
582 | + } | ||
583 | + | ||
584 | + addrsize = 64 - 8 * param.tbi; | ||
585 | + inputsize = 64 - param.tsz; | ||
586 | + | ||
587 | + /* | ||
588 | + * Bound PS by PARANGE to find the effective output address size. | ||
589 | + * ID_AA64MMFR0 is a read-only register so values outside of the | ||
590 | + * supported mappings can be considered an implementation error. | ||
591 | + */ | ||
592 | + ps = FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); | ||
593 | + ps = MIN(ps, param.ps); | ||
594 | + assert(ps < ARRAY_SIZE(pamax_map)); | ||
595 | + outputsize = pamax_map[ps]; | ||
596 | + } else { | ||
597 | + param = aa32_va_parameters(env, address, mmu_idx); | ||
598 | + level = 1; | ||
599 | + addrsize = (mmu_idx == ARMMMUIdx_Stage2 ? 40 : 32); | ||
600 | + inputsize = addrsize - param.tsz; | ||
601 | + outputsize = 40; | ||
602 | + } | ||
603 | + | ||
604 | + /* | ||
605 | + * We determined the region when collecting the parameters, but we | ||
606 | + * have not yet validated that the address is valid for the region. | ||
607 | + * Extract the top bits and verify that they all match select. | ||
608 | + * | ||
609 | + * For aa32, if inputsize == addrsize, then we have selected the | ||
610 | + * region by exclusion in aa32_va_parameters and there is no more | ||
611 | + * validation to do here. | ||
612 | + */ | ||
613 | + if (inputsize < addrsize) { | ||
614 | + target_ulong top_bits = sextract64(address, inputsize, | ||
615 | + addrsize - inputsize); | ||
616 | + if (-top_bits != param.select) { | ||
617 | + /* The gap between the two regions is a Translation fault */ | ||
618 | + fault_type = ARMFault_Translation; | ||
619 | + goto do_fault; | ||
620 | + } | ||
621 | + } | ||
622 | + | ||
623 | + if (param.using64k) { | ||
624 | + stride = 13; | ||
625 | + } else if (param.using16k) { | ||
626 | + stride = 11; | ||
627 | + } else { | ||
628 | + stride = 9; | ||
629 | + } | ||
630 | + | ||
631 | + /* | ||
632 | + * Note that QEMU ignores shareability and cacheability attributes, | ||
633 | + * so we don't need to do anything with the SH, ORGN, IRGN fields | ||
634 | + * in the TTBCR. Similarly, TTBCR:A1 selects whether we get the | ||
635 | + * ASID from TTBR0 or TTBR1, but QEMU's TLB doesn't currently | ||
636 | + * implement any ASID-like capability so we can ignore it (instead | ||
637 | + * we will always flush the TLB any time the ASID is changed). | ||
638 | + */ | ||
639 | + ttbr = regime_ttbr(env, mmu_idx, param.select); | ||
640 | + | ||
641 | + /* | ||
642 | + * Here we should have set up all the parameters for the translation: | ||
643 | + * inputsize, ttbr, epd, stride, tbi | ||
644 | + */ | ||
645 | + | ||
646 | + if (param.epd) { | ||
647 | + /* | ||
648 | + * Translation table walk disabled => Translation fault on TLB miss | ||
649 | + * Note: This is always 0 on 64-bit EL2 and EL3. | ||
650 | + */ | ||
651 | + goto do_fault; | ||
652 | + } | ||
653 | + | ||
654 | + if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) { | ||
655 | + /* | ||
656 | + * The starting level depends on the virtual address size (which can | ||
657 | + * be up to 48 bits) and the translation granule size. It indicates | ||
658 | + * the number of strides (stride bits at a time) needed to | ||
659 | + * consume the bits of the input address. In the pseudocode this is: | ||
660 | + * level = 4 - RoundUp((inputsize - grainsize) / stride) | ||
661 | + * where their 'inputsize' is our 'inputsize', 'grainsize' is | ||
662 | + * our 'stride + 3' and 'stride' is our 'stride'. | ||
663 | + * Applying the usual "rounded up m/n is (m+n-1)/n" and simplifying: | ||
664 | + * = 4 - (inputsize - stride - 3 + stride - 1) / stride | ||
665 | + * = 4 - (inputsize - 4) / stride; | ||
666 | + */ | ||
667 | + level = 4 - (inputsize - 4) / stride; | ||
668 | + } else { | ||
669 | + /* | ||
670 | + * For stage 2 translations the starting level is specified by the | ||
671 | + * VTCR_EL2.SL0 field (whose interpretation depends on the page size) | ||
672 | + */ | ||
673 | + uint32_t sl0 = extract32(tcr->raw_tcr, 6, 2); | ||
674 | + uint32_t sl2 = extract64(tcr->raw_tcr, 33, 1); | ||
675 | + uint32_t startlevel; | ||
676 | + bool ok; | ||
677 | + | ||
678 | + /* SL2 is RES0 unless DS=1 & 4kb granule. */ | ||
679 | + if (param.ds && stride == 9 && sl2) { | ||
680 | + if (sl0 != 0) { | ||
681 | + level = 0; | ||
682 | + fault_type = ARMFault_Translation; | ||
683 | + goto do_fault; | ||
684 | + } | ||
685 | + startlevel = -1; | ||
686 | + } else if (!aarch64 || stride == 9) { | ||
687 | + /* AArch32 or 4KB pages */ | ||
688 | + startlevel = 2 - sl0; | ||
689 | + | ||
690 | + if (cpu_isar_feature(aa64_st, cpu)) { | ||
691 | + startlevel &= 3; | ||
692 | + } | ||
693 | + } else { | ||
694 | + /* 16KB or 64KB pages */ | ||
695 | + startlevel = 3 - sl0; | ||
696 | + } | ||
697 | + | ||
698 | + /* Check that the starting level is valid. */ | ||
699 | + ok = check_s2_mmu_setup(cpu, aarch64, startlevel, | ||
700 | + inputsize, stride, outputsize); | ||
701 | + if (!ok) { | ||
702 | + fault_type = ARMFault_Translation; | ||
703 | + goto do_fault; | ||
704 | + } | ||
705 | + level = startlevel; | ||
706 | + } | ||
707 | + | ||
708 | + indexmask_grainsize = MAKE_64BIT_MASK(0, stride + 3); | ||
709 | + indexmask = MAKE_64BIT_MASK(0, inputsize - (stride * (4 - level))); | ||
710 | + | ||
711 | + /* Now we can extract the actual base address from the TTBR */ | ||
712 | + descaddr = extract64(ttbr, 0, 48); | ||
713 | + | ||
714 | + /* | ||
715 | + * For FEAT_LPA and PS=6, bits [51:48] of descaddr are in [5:2] of TTBR. | ||
716 | + * | ||
717 | + * Otherwise, if the base address is out of range, raise AddressSizeFault. | ||
718 | + * In the pseudocode, this is !IsZero(baseregister<47:outputsize>), | ||
719 | + * but we've just cleared the bits above 47, so simplify the test. | ||
720 | + */ | ||
721 | + if (outputsize > 48) { | ||
722 | + descaddr |= extract64(ttbr, 2, 4) << 48; | ||
723 | + } else if (descaddr >> outputsize) { | ||
724 | + level = 0; | ||
725 | + fault_type = ARMFault_AddressSize; | ||
726 | + goto do_fault; | ||
727 | + } | ||
728 | + | ||
729 | + /* | ||
730 | + * We rely on this masking to clear the RES0 bits at the bottom of the TTBR | ||
731 | + * and also to mask out CnP (bit 0) which could validly be non-zero. | ||
732 | + */ | ||
733 | + descaddr &= ~indexmask; | ||
734 | + | ||
735 | + /* | ||
736 | + * For AArch32, the address field in the descriptor goes up to bit 39 | ||
737 | + * for both v7 and v8. However, for v8 the SBZ bits [47:40] must be 0 | ||
738 | + * or an AddressSize fault is raised. So for v8 we extract those SBZ | ||
739 | + * bits as part of the address, which will be checked via outputsize. | ||
740 | + * For AArch64, the address field goes up to bit 47, or 49 with FEAT_LPA2; | ||
741 | + * the highest bits of a 52-bit output are placed elsewhere. | ||
742 | + */ | ||
743 | + if (param.ds) { | ||
744 | + descaddrmask = MAKE_64BIT_MASK(0, 50); | ||
745 | + } else if (arm_feature(env, ARM_FEATURE_V8)) { | ||
746 | + descaddrmask = MAKE_64BIT_MASK(0, 48); | ||
747 | + } else { | ||
748 | + descaddrmask = MAKE_64BIT_MASK(0, 40); | ||
749 | + } | ||
750 | + descaddrmask &= ~indexmask_grainsize; | ||
751 | + | ||
752 | + /* | ||
753 | + * Secure accesses start with the page table in secure memory and | ||
754 | + * can be downgraded to non-secure at any step. Non-secure accesses | ||
755 | + * remain non-secure. We implement this by just ORing in the NSTable/NS | ||
756 | + * bits at each step. | ||
757 | + */ | ||
758 | + tableattrs = regime_is_secure(env, mmu_idx) ? 0 : (1 << 4); | ||
759 | + for (;;) { | ||
760 | + uint64_t descriptor; | ||
761 | + bool nstable; | ||
762 | + | ||
763 | + descaddr |= (address >> (stride * (4 - level))) & indexmask; | ||
764 | + descaddr &= ~7ULL; | ||
765 | + nstable = extract32(tableattrs, 4, 1); | ||
766 | + descriptor = arm_ldq_ptw(cs, descaddr, !nstable, mmu_idx, fi); | ||
767 | + if (fi->type != ARMFault_None) { | ||
768 | + goto do_fault; | ||
769 | + } | ||
770 | + | ||
771 | + if (!(descriptor & 1) || | ||
772 | + (!(descriptor & 2) && (level == 3))) { | ||
773 | + /* Invalid, or the Reserved level 3 encoding */ | ||
774 | + goto do_fault; | ||
775 | + } | ||
776 | + | ||
777 | + descaddr = descriptor & descaddrmask; | ||
778 | + | ||
779 | + /* | ||
780 | + * For FEAT_LPA and PS=6, bits [51:48] of descaddr are in [15:12] | ||
781 | + * of descriptor. For FEAT_LPA2 and effective DS, bits [51:50] of | ||
782 | + * descaddr are in [9:8]. Otherwise, if descaddr is out of range, | ||
783 | + * raise AddressSizeFault. | ||
784 | + */ | ||
785 | + if (outputsize > 48) { | ||
786 | + if (param.ds) { | ||
787 | + descaddr |= extract64(descriptor, 8, 2) << 50; | ||
788 | + } else { | ||
789 | + descaddr |= extract64(descriptor, 12, 4) << 48; | ||
790 | + } | ||
791 | + } else if (descaddr >> outputsize) { | ||
792 | + fault_type = ARMFault_AddressSize; | ||
793 | + goto do_fault; | ||
794 | + } | ||
795 | + | ||
796 | + if ((descriptor & 2) && (level < 3)) { | ||
797 | + /* | ||
798 | + * Table entry. The top five bits are attributes which may | ||
799 | + * propagate down through lower levels of the table (and | ||
800 | + * which are all arranged so that 0 means "no effect", so | ||
801 | + * we can gather them up by ORing in the bits at each level). | ||
802 | + */ | ||
803 | + tableattrs |= extract64(descriptor, 59, 5); | ||
804 | + level++; | ||
805 | + indexmask = indexmask_grainsize; | ||
806 | + continue; | ||
807 | + } | ||
808 | + /* | ||
809 | + * Block entry at level 1 or 2, or page entry at level 3. | ||
810 | + * These are basically the same thing, although the number | ||
811 | + * of bits we pull in from the vaddr varies. Note that although | ||
812 | + * descaddrmask masks enough of the low bits of the descriptor | ||
813 | + * to give a correct page or table address, the address field | ||
814 | + * in a block descriptor is smaller; so we need to explicitly | ||
815 | + * clear the lower bits here before ORing in the low vaddr bits. | ||
816 | + */ | ||
817 | + page_size = (1ULL << ((stride * (4 - level)) + 3)); | ||
818 | + descaddr &= ~(page_size - 1); | ||
819 | + descaddr |= (address & (page_size - 1)); | ||
820 | + /* Extract attributes from the descriptor */ | ||
821 | + attrs = extract64(descriptor, 2, 10) | ||
822 | + | (extract64(descriptor, 52, 12) << 10); | ||
823 | + | ||
824 | + if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { | ||
825 | + /* Stage 2 table descriptors do not include any attribute fields */ | ||
826 | + break; | ||
827 | + } | ||
828 | + /* Merge in attributes from table descriptors */ | ||
829 | + attrs |= nstable << 3; /* NS */ | ||
830 | + guarded = extract64(descriptor, 50, 1); /* GP */ | ||
831 | + if (param.hpd) { | ||
832 | + /* HPD disables all the table attributes except NSTable. */ | ||
833 | + break; | ||
834 | + } | ||
835 | + attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ | ||
836 | + /* | ||
837 | + * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 | ||
838 | + * means "force PL1 access only", which means forcing AP[1] to 0. | ||
839 | + */ | ||
840 | + attrs &= ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] => AP[1] */ | ||
841 | + attrs |= extract32(tableattrs, 3, 1) << 5; /* APT[1] => AP[2] */ | ||
842 | + break; | ||
843 | + } | ||
844 | + /* | ||
845 | + * Here descaddr is the final physical address, and attributes | ||
846 | + * are all in attrs. | ||
847 | + */ | ||
848 | + fault_type = ARMFault_AccessFlag; | ||
849 | + if ((attrs & (1 << 8)) == 0) { | ||
850 | + /* Access flag */ | ||
851 | + goto do_fault; | ||
852 | + } | ||
853 | + | ||
854 | + ap = extract32(attrs, 4, 2); | ||
855 | + | ||
856 | + if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { | ||
857 | + ns = mmu_idx == ARMMMUIdx_Stage2; | ||
858 | + xn = extract32(attrs, 11, 2); | ||
859 | + *prot = get_S2prot(env, ap, xn, s1_is_el0); | ||
860 | + } else { | ||
861 | + ns = extract32(attrs, 3, 1); | ||
862 | + xn = extract32(attrs, 12, 1); | ||
863 | + pxn = extract32(attrs, 11, 1); | ||
864 | + *prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); | ||
865 | + } | ||
866 | + | ||
867 | + fault_type = ARMFault_Permission; | ||
868 | + if (!(*prot & (1 << access_type))) { | ||
869 | + goto do_fault; | ||
870 | + } | ||
871 | + | ||
872 | + if (ns) { | ||
873 | + /* | ||
874 | + * The NS bit will (as required by the architecture) have no effect if | ||
875 | + * the CPU doesn't support TZ or this is a non-secure translation | ||
876 | + * regime, because the attribute will already be non-secure. | ||
877 | + */ | ||
878 | + txattrs->secure = false; | ||
879 | + } | ||
880 | + /* When in aarch64 mode, and BTI is enabled, remember GP in the IOTLB. */ | ||
881 | + if (aarch64 && guarded && cpu_isar_feature(aa64_bti, cpu)) { | ||
882 | + arm_tlb_bti_gp(txattrs) = true; | ||
883 | + } | ||
884 | + | ||
885 | + if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { | ||
886 | + cacheattrs->is_s2_format = true; | ||
887 | + cacheattrs->attrs = extract32(attrs, 0, 4); | ||
888 | + } else { | ||
889 | + /* Index into MAIR registers for cache attributes */ | ||
890 | + uint8_t attrindx = extract32(attrs, 0, 3); | ||
891 | + uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; | ||
892 | + assert(attrindx <= 7); | ||
893 | + cacheattrs->is_s2_format = false; | ||
894 | + cacheattrs->attrs = extract64(mair, attrindx * 8, 8); | ||
895 | + } | ||
896 | + | ||
897 | + /* | ||
898 | + * For FEAT_LPA2 and effective DS, the SH field in the attributes | ||
899 | + * was re-purposed for output address bits. The SH attribute in | ||
900 | + * that case comes from TCR_ELx, which we extracted earlier. | ||
901 | + */ | ||
902 | + if (param.ds) { | ||
903 | + cacheattrs->shareability = param.sh; | ||
904 | + } else { | ||
905 | + cacheattrs->shareability = extract32(attrs, 6, 2); | ||
906 | + } | ||
907 | + | ||
908 | + *phys_ptr = descaddr; | ||
909 | + *page_size_ptr = page_size; | ||
910 | + return false; | ||
911 | + | ||
912 | +do_fault: | ||
913 | + fi->type = fault_type; | ||
914 | + fi->level = level; | ||
915 | + /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ | ||
916 | + fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2 || | ||
917 | + mmu_idx == ARMMMUIdx_Stage2_S); | ||
918 | + fi->s1ns = mmu_idx == ARMMMUIdx_Stage2; | ||
919 | + return true; | ||
920 | +} | ||
921 | + | ||
922 | static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
923 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
924 | hwaddr *phys_ptr, int *prot, | ||
925 | -- | ||
926 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This adds cluster-id in CPU instance properties, which will be used | 3 | Move the ptw load functions, plus 3 common subroutines: |
4 | by arm/virt machine. Besides, the cluster-id is also verified or | 4 | S1_ptw_translate, ptw_attrs_are_device, and regime_translation_big_endian. |
5 | dumped in various spots: | 5 | This also allows get_phys_addr_lpae to become static again. |
6 | 6 | ||
7 | * hw/core/machine.c::machine_set_cpu_numa_node() to associate | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | CPU with its NUMA node. | 8 | Message-id: 20220604040607.269301-17-richard.henderson@linaro.org |
9 | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | |
10 | * hw/core/machine.c::machine_numa_finish_cpu_init() to record | ||
11 | CPU slots with no NUMA mapping set. | ||
12 | |||
13 | * hw/core/machine-hmp-cmds.c::hmp_hotpluggable_cpus() to dump | ||
14 | cluster-id. | ||
15 | |||
16 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
17 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
18 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
19 | Message-id: 20220503140304.855514-2-gshan@redhat.com | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 11 | --- |
22 | qapi/machine.json | 6 ++++-- | 12 | target/arm/ptw.h | 13 ---- |
23 | hw/core/machine-hmp-cmds.c | 4 ++++ | 13 | target/arm/helper.c | 141 -------------------------------------- |
24 | hw/core/machine.c | 16 ++++++++++++++++ | 14 | target/arm/ptw.c | 160 ++++++++++++++++++++++++++++++++++++++++++-- |
25 | 3 files changed, 24 insertions(+), 2 deletions(-) | 15 | 3 files changed, 154 insertions(+), 160 deletions(-) |
26 | 16 | ||
27 | diff --git a/qapi/machine.json b/qapi/machine.json | 17 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h |
28 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/qapi/machine.json | 19 | --- a/target/arm/ptw.h |
30 | +++ b/qapi/machine.json | 20 | +++ b/target/arm/ptw.h |
31 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ |
32 | # @node-id: NUMA node ID the CPU belongs to | 22 | |
33 | # @socket-id: socket number within node/board the CPU belongs to | 23 | extern const uint8_t pamax_map[7]; |
34 | # @die-id: die number within socket the CPU belongs to (since 4.1) | 24 | |
35 | -# @core-id: core number within die the CPU belongs to | 25 | -uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, |
36 | +# @cluster-id: cluster number within die the CPU belongs to (since 7.1) | 26 | - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi); |
37 | +# @core-id: core number within cluster the CPU belongs to | 27 | -uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, |
38 | # @thread-id: thread number within core the CPU belongs to | 28 | - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi); |
39 | # | 29 | - |
40 | -# Note: currently there are 5 properties that could be present | 30 | bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); |
41 | +# Note: currently there are 6 properties that could be present | 31 | bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); |
42 | # but management should be prepared to pass through other | 32 | uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); |
43 | # properties with device_add command to allow for future | 33 | @@ -XXX,XX +XXX,XX @@ int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0); |
44 | # interface extension. This also requires the filed names to be kept in | 34 | int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, |
35 | int ap, int ns, int xn, int pxn); | ||
36 | |||
37 | -bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
38 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
39 | - bool s1_is_el0, | ||
40 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
41 | - target_ulong *page_size_ptr, | ||
42 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
43 | - __attribute__((nonnull)); | ||
44 | - | ||
45 | #endif /* !CONFIG_USER_ONLY */ | ||
46 | #endif /* TARGET_ARM_PTW_H */ | ||
47 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/helper.c | ||
50 | +++ b/target/arm/helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
52 | return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0; | ||
53 | } | ||
54 | |||
55 | -static inline bool regime_translation_big_endian(CPUARMState *env, | ||
56 | - ARMMMUIdx mmu_idx) | ||
57 | -{ | ||
58 | - return (regime_sctlr(env, mmu_idx) & SCTLR_EE) != 0; | ||
59 | -} | ||
60 | - | ||
61 | /* Return the TTBR associated with this translation regime */ | ||
62 | uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) | ||
63 | { | ||
64 | @@ -XXX,XX +XXX,XX @@ int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, | ||
65 | return prot_rw | PAGE_EXEC; | ||
66 | } | ||
67 | |||
68 | -static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattrs) | ||
69 | -{ | ||
70 | - /* | ||
71 | - * For an S1 page table walk, the stage 1 attributes are always | ||
72 | - * some form of "this is Normal memory". The combined S1+S2 | ||
73 | - * attributes are therefore only Device if stage 2 specifies Device. | ||
74 | - * With HCR_EL2.FWB == 0 this is when descriptor bits [5:4] are 0b00, | ||
75 | - * ie when cacheattrs.attrs bits [3:2] are 0b00. | ||
76 | - * With HCR_EL2.FWB == 1 this is when descriptor bit [4] is 0, ie | ||
77 | - * when cacheattrs.attrs bit [2] is 0. | ||
78 | - */ | ||
79 | - assert(cacheattrs.is_s2_format); | ||
80 | - if (arm_hcr_el2_eff(env) & HCR_FWB) { | ||
81 | - return (cacheattrs.attrs & 0x4) == 0; | ||
82 | - } else { | ||
83 | - return (cacheattrs.attrs & 0xc) == 0; | ||
84 | - } | ||
85 | -} | ||
86 | - | ||
87 | -/* Translate a S1 pagetable walk through S2 if needed. */ | ||
88 | -static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
89 | - hwaddr addr, bool *is_secure, | ||
90 | - ARMMMUFaultInfo *fi) | ||
91 | -{ | ||
92 | - if (arm_mmu_idx_is_stage1_of_2(mmu_idx) && | ||
93 | - !regime_translation_disabled(env, ARMMMUIdx_Stage2)) { | ||
94 | - target_ulong s2size; | ||
95 | - hwaddr s2pa; | ||
96 | - int s2prot; | ||
97 | - int ret; | ||
98 | - ARMMMUIdx s2_mmu_idx = *is_secure ? ARMMMUIdx_Stage2_S | ||
99 | - : ARMMMUIdx_Stage2; | ||
100 | - ARMCacheAttrs cacheattrs = {}; | ||
101 | - MemTxAttrs txattrs = {}; | ||
102 | - | ||
103 | - ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, s2_mmu_idx, false, | ||
104 | - &s2pa, &txattrs, &s2prot, &s2size, fi, | ||
105 | - &cacheattrs); | ||
106 | - if (ret) { | ||
107 | - assert(fi->type != ARMFault_None); | ||
108 | - fi->s2addr = addr; | ||
109 | - fi->stage2 = true; | ||
110 | - fi->s1ptw = true; | ||
111 | - fi->s1ns = !*is_secure; | ||
112 | - return ~0; | ||
113 | - } | ||
114 | - if ((arm_hcr_el2_eff(env) & HCR_PTW) && | ||
115 | - ptw_attrs_are_device(env, cacheattrs)) { | ||
116 | - /* | ||
117 | - * PTW set and S1 walk touched S2 Device memory: | ||
118 | - * generate Permission fault. | ||
119 | - */ | ||
120 | - fi->type = ARMFault_Permission; | ||
121 | - fi->s2addr = addr; | ||
122 | - fi->stage2 = true; | ||
123 | - fi->s1ptw = true; | ||
124 | - fi->s1ns = !*is_secure; | ||
125 | - return ~0; | ||
126 | - } | ||
127 | - | ||
128 | - if (arm_is_secure_below_el3(env)) { | ||
129 | - /* Check if page table walk is to secure or non-secure PA space. */ | ||
130 | - if (*is_secure) { | ||
131 | - *is_secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW); | ||
132 | - } else { | ||
133 | - *is_secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW); | ||
134 | - } | ||
135 | - } else { | ||
136 | - assert(!*is_secure); | ||
137 | - } | ||
138 | - | ||
139 | - addr = s2pa; | ||
140 | - } | ||
141 | - return addr; | ||
142 | -} | ||
143 | - | ||
144 | -/* All loads done in the course of a page table walk go through here. */ | ||
145 | -uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
146 | - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) | ||
147 | -{ | ||
148 | - ARMCPU *cpu = ARM_CPU(cs); | ||
149 | - CPUARMState *env = &cpu->env; | ||
150 | - MemTxAttrs attrs = {}; | ||
151 | - MemTxResult result = MEMTX_OK; | ||
152 | - AddressSpace *as; | ||
153 | - uint32_t data; | ||
154 | - | ||
155 | - addr = S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi); | ||
156 | - attrs.secure = is_secure; | ||
157 | - as = arm_addressspace(cs, attrs); | ||
158 | - if (fi->s1ptw) { | ||
159 | - return 0; | ||
160 | - } | ||
161 | - if (regime_translation_big_endian(env, mmu_idx)) { | ||
162 | - data = address_space_ldl_be(as, addr, attrs, &result); | ||
163 | - } else { | ||
164 | - data = address_space_ldl_le(as, addr, attrs, &result); | ||
165 | - } | ||
166 | - if (result == MEMTX_OK) { | ||
167 | - return data; | ||
168 | - } | ||
169 | - fi->type = ARMFault_SyncExternalOnWalk; | ||
170 | - fi->ea = arm_extabort_type(result); | ||
171 | - return 0; | ||
172 | -} | ||
173 | - | ||
174 | -uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
175 | - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) | ||
176 | -{ | ||
177 | - ARMCPU *cpu = ARM_CPU(cs); | ||
178 | - CPUARMState *env = &cpu->env; | ||
179 | - MemTxAttrs attrs = {}; | ||
180 | - MemTxResult result = MEMTX_OK; | ||
181 | - AddressSpace *as; | ||
182 | - uint64_t data; | ||
183 | - | ||
184 | - addr = S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi); | ||
185 | - attrs.secure = is_secure; | ||
186 | - as = arm_addressspace(cs, attrs); | ||
187 | - if (fi->s1ptw) { | ||
188 | - return 0; | ||
189 | - } | ||
190 | - if (regime_translation_big_endian(env, mmu_idx)) { | ||
191 | - data = address_space_ldq_be(as, addr, attrs, &result); | ||
192 | - } else { | ||
193 | - data = address_space_ldq_le(as, addr, attrs, &result); | ||
194 | - } | ||
195 | - if (result == MEMTX_OK) { | ||
196 | - return data; | ||
197 | - } | ||
198 | - fi->type = ARMFault_SyncExternalOnWalk; | ||
199 | - fi->ea = arm_extabort_type(result); | ||
200 | - return 0; | ||
201 | -} | ||
202 | - | ||
203 | /* | ||
204 | * check_s2_mmu_setup | ||
205 | * @cpu: ARMCPU | ||
206 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
207 | index XXXXXXX..XXXXXXX 100644 | ||
208 | --- a/target/arm/ptw.c | ||
209 | +++ b/target/arm/ptw.c | ||
45 | @@ -XXX,XX +XXX,XX @@ | 210 | @@ -XXX,XX +XXX,XX @@ |
46 | 'data': { '*node-id': 'int', | 211 | #include "ptw.h" |
47 | '*socket-id': 'int', | 212 | |
48 | '*die-id': 'int', | 213 | |
49 | + '*cluster-id': 'int', | 214 | +static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, |
50 | '*core-id': 'int', | 215 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, |
51 | '*thread-id': 'int' | 216 | + bool s1_is_el0, hwaddr *phys_ptr, |
52 | } | 217 | + MemTxAttrs *txattrs, int *prot, |
53 | diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c | 218 | + target_ulong *page_size_ptr, |
54 | index XXXXXXX..XXXXXXX 100644 | 219 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) |
55 | --- a/hw/core/machine-hmp-cmds.c | 220 | + __attribute__((nonnull)); |
56 | +++ b/hw/core/machine-hmp-cmds.c | 221 | + |
57 | @@ -XXX,XX +XXX,XX @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict) | 222 | +static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_idx) |
58 | if (c->has_die_id) { | 223 | +{ |
59 | monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id); | 224 | + return (regime_sctlr(env, mmu_idx) & SCTLR_EE) != 0; |
60 | } | 225 | +} |
61 | + if (c->has_cluster_id) { | 226 | + |
62 | + monitor_printf(mon, " cluster-id: \"%" PRIu64 "\"\n", | 227 | +static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattrs) |
63 | + c->cluster_id); | 228 | +{ |
229 | + /* | ||
230 | + * For an S1 page table walk, the stage 1 attributes are always | ||
231 | + * some form of "this is Normal memory". The combined S1+S2 | ||
232 | + * attributes are therefore only Device if stage 2 specifies Device. | ||
233 | + * With HCR_EL2.FWB == 0 this is when descriptor bits [5:4] are 0b00, | ||
234 | + * ie when cacheattrs.attrs bits [3:2] are 0b00. | ||
235 | + * With HCR_EL2.FWB == 1 this is when descriptor bit [4] is 0, ie | ||
236 | + * when cacheattrs.attrs bit [2] is 0. | ||
237 | + */ | ||
238 | + assert(cacheattrs.is_s2_format); | ||
239 | + if (arm_hcr_el2_eff(env) & HCR_FWB) { | ||
240 | + return (cacheattrs.attrs & 0x4) == 0; | ||
241 | + } else { | ||
242 | + return (cacheattrs.attrs & 0xc) == 0; | ||
243 | + } | ||
244 | +} | ||
245 | + | ||
246 | +/* Translate a S1 pagetable walk through S2 if needed. */ | ||
247 | +static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
248 | + hwaddr addr, bool *is_secure, | ||
249 | + ARMMMUFaultInfo *fi) | ||
250 | +{ | ||
251 | + if (arm_mmu_idx_is_stage1_of_2(mmu_idx) && | ||
252 | + !regime_translation_disabled(env, ARMMMUIdx_Stage2)) { | ||
253 | + target_ulong s2size; | ||
254 | + hwaddr s2pa; | ||
255 | + int s2prot; | ||
256 | + int ret; | ||
257 | + ARMMMUIdx s2_mmu_idx = *is_secure ? ARMMMUIdx_Stage2_S | ||
258 | + : ARMMMUIdx_Stage2; | ||
259 | + ARMCacheAttrs cacheattrs = {}; | ||
260 | + MemTxAttrs txattrs = {}; | ||
261 | + | ||
262 | + ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, s2_mmu_idx, false, | ||
263 | + &s2pa, &txattrs, &s2prot, &s2size, fi, | ||
264 | + &cacheattrs); | ||
265 | + if (ret) { | ||
266 | + assert(fi->type != ARMFault_None); | ||
267 | + fi->s2addr = addr; | ||
268 | + fi->stage2 = true; | ||
269 | + fi->s1ptw = true; | ||
270 | + fi->s1ns = !*is_secure; | ||
271 | + return ~0; | ||
64 | + } | 272 | + } |
65 | if (c->has_core_id) { | 273 | + if ((arm_hcr_el2_eff(env) & HCR_PTW) && |
66 | monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id); | 274 | + ptw_attrs_are_device(env, cacheattrs)) { |
67 | } | 275 | + /* |
68 | diff --git a/hw/core/machine.c b/hw/core/machine.c | 276 | + * PTW set and S1 walk touched S2 Device memory: |
69 | index XXXXXXX..XXXXXXX 100644 | 277 | + * generate Permission fault. |
70 | --- a/hw/core/machine.c | 278 | + */ |
71 | +++ b/hw/core/machine.c | 279 | + fi->type = ARMFault_Permission; |
72 | @@ -XXX,XX +XXX,XX @@ void machine_set_cpu_numa_node(MachineState *machine, | 280 | + fi->s2addr = addr; |
73 | return; | 281 | + fi->stage2 = true; |
74 | } | 282 | + fi->s1ptw = true; |
75 | 283 | + fi->s1ns = !*is_secure; | |
76 | + if (props->has_cluster_id && !slot->props.has_cluster_id) { | 284 | + return ~0; |
77 | + error_setg(errp, "cluster-id is not supported"); | ||
78 | + return; | ||
79 | + } | 285 | + } |
80 | + | 286 | + |
81 | if (props->has_socket_id && !slot->props.has_socket_id) { | 287 | + if (arm_is_secure_below_el3(env)) { |
82 | error_setg(errp, "socket-id is not supported"); | 288 | + /* Check if page table walk is to secure or non-secure PA space. */ |
83 | return; | 289 | + if (*is_secure) { |
84 | @@ -XXX,XX +XXX,XX @@ void machine_set_cpu_numa_node(MachineState *machine, | 290 | + *is_secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW); |
85 | continue; | 291 | + } else { |
86 | } | 292 | + *is_secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW); |
87 | 293 | + } | |
88 | + if (props->has_cluster_id && | 294 | + } else { |
89 | + props->cluster_id != slot->props.cluster_id) { | 295 | + assert(!*is_secure); |
90 | + continue; | ||
91 | + } | 296 | + } |
92 | + | 297 | + |
93 | if (props->has_die_id && props->die_id != slot->props.die_id) { | 298 | + addr = s2pa; |
94 | continue; | 299 | + } |
95 | } | 300 | + return addr; |
96 | @@ -XXX,XX +XXX,XX @@ static char *cpu_slot_to_string(const CPUArchId *cpu) | 301 | +} |
97 | } | 302 | + |
98 | g_string_append_printf(s, "die-id: %"PRId64, cpu->props.die_id); | 303 | +/* All loads done in the course of a page table walk go through here. */ |
99 | } | 304 | +static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, |
100 | + if (cpu->props.has_cluster_id) { | 305 | + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) |
101 | + if (s->len) { | 306 | +{ |
102 | + g_string_append_printf(s, ", "); | 307 | + ARMCPU *cpu = ARM_CPU(cs); |
103 | + } | 308 | + CPUARMState *env = &cpu->env; |
104 | + g_string_append_printf(s, "cluster-id: %"PRId64, cpu->props.cluster_id); | 309 | + MemTxAttrs attrs = {}; |
105 | + } | 310 | + MemTxResult result = MEMTX_OK; |
106 | if (cpu->props.has_core_id) { | 311 | + AddressSpace *as; |
107 | if (s->len) { | 312 | + uint32_t data; |
108 | g_string_append_printf(s, ", "); | 313 | + |
314 | + addr = S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi); | ||
315 | + attrs.secure = is_secure; | ||
316 | + as = arm_addressspace(cs, attrs); | ||
317 | + if (fi->s1ptw) { | ||
318 | + return 0; | ||
319 | + } | ||
320 | + if (regime_translation_big_endian(env, mmu_idx)) { | ||
321 | + data = address_space_ldl_be(as, addr, attrs, &result); | ||
322 | + } else { | ||
323 | + data = address_space_ldl_le(as, addr, attrs, &result); | ||
324 | + } | ||
325 | + if (result == MEMTX_OK) { | ||
326 | + return data; | ||
327 | + } | ||
328 | + fi->type = ARMFault_SyncExternalOnWalk; | ||
329 | + fi->ea = arm_extabort_type(result); | ||
330 | + return 0; | ||
331 | +} | ||
332 | + | ||
333 | +static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
334 | + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) | ||
335 | +{ | ||
336 | + ARMCPU *cpu = ARM_CPU(cs); | ||
337 | + CPUARMState *env = &cpu->env; | ||
338 | + MemTxAttrs attrs = {}; | ||
339 | + MemTxResult result = MEMTX_OK; | ||
340 | + AddressSpace *as; | ||
341 | + uint64_t data; | ||
342 | + | ||
343 | + addr = S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi); | ||
344 | + attrs.secure = is_secure; | ||
345 | + as = arm_addressspace(cs, attrs); | ||
346 | + if (fi->s1ptw) { | ||
347 | + return 0; | ||
348 | + } | ||
349 | + if (regime_translation_big_endian(env, mmu_idx)) { | ||
350 | + data = address_space_ldq_be(as, addr, attrs, &result); | ||
351 | + } else { | ||
352 | + data = address_space_ldq_le(as, addr, attrs, &result); | ||
353 | + } | ||
354 | + if (result == MEMTX_OK) { | ||
355 | + return data; | ||
356 | + } | ||
357 | + fi->type = ARMFault_SyncExternalOnWalk; | ||
358 | + fi->ea = arm_extabort_type(result); | ||
359 | + return 0; | ||
360 | +} | ||
361 | + | ||
362 | static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
363 | uint32_t *table, uint32_t address) | ||
364 | { | ||
365 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
366 | * @fi: set to fault info if the translation fails | ||
367 | * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | ||
368 | */ | ||
369 | -bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
370 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
371 | - bool s1_is_el0, | ||
372 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
373 | - target_ulong *page_size_ptr, | ||
374 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
375 | +static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
376 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
377 | + bool s1_is_el0, hwaddr *phys_ptr, | ||
378 | + MemTxAttrs *txattrs, int *prot, | ||
379 | + target_ulong *page_size_ptr, | ||
380 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
381 | { | ||
382 | ARMCPU *cpu = env_archcpu(env); | ||
383 | CPUState *cs = CPU(cpu); | ||
109 | -- | 384 | -- |
110 | 2.25.1 | 385 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | These functions are used for both page table walking and for | ||
4 | deciding what format in which to deliver exception results. | ||
5 | Since ptw.c is only present for system mode, put the functions | ||
6 | into tlb_helper.c. | ||
7 | |||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220604040607.269301-18-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/helper.c | 24 ------------------------ | ||
14 | target/arm/tlb_helper.c | 26 ++++++++++++++++++++++++++ | ||
15 | 2 files changed, 26 insertions(+), 24 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/helper.c | ||
20 | +++ b/target/arm/helper.c | ||
21 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) | ||
22 | } | ||
23 | #endif /* !CONFIG_USER_ONLY */ | ||
24 | |||
25 | -/* Return true if the translation regime is using LPAE format page tables */ | ||
26 | -bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
27 | -{ | ||
28 | - int el = regime_el(env, mmu_idx); | ||
29 | - if (el == 2 || arm_el_is_aa64(env, el)) { | ||
30 | - return true; | ||
31 | - } | ||
32 | - if (arm_feature(env, ARM_FEATURE_LPAE) | ||
33 | - && (regime_tcr(env, mmu_idx)->raw_tcr & TTBCR_EAE)) { | ||
34 | - return true; | ||
35 | - } | ||
36 | - return false; | ||
37 | -} | ||
38 | - | ||
39 | -/* Returns true if the stage 1 translation regime is using LPAE format page | ||
40 | - * tables. Used when raising alignment exceptions, whose FSR changes depending | ||
41 | - * on whether the long or short descriptor format is in use. */ | ||
42 | -bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
43 | -{ | ||
44 | - mmu_idx = stage_1_mmu_idx(mmu_idx); | ||
45 | - | ||
46 | - return regime_using_lpae_format(env, mmu_idx); | ||
47 | -} | ||
48 | - | ||
49 | #ifndef CONFIG_USER_ONLY | ||
50 | bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
51 | { | ||
52 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/tlb_helper.c | ||
55 | +++ b/target/arm/tlb_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ | ||
57 | #include "exec/exec-all.h" | ||
58 | #include "exec/helper-proto.h" | ||
59 | |||
60 | + | ||
61 | +/* Return true if the translation regime is using LPAE format page tables */ | ||
62 | +bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
63 | +{ | ||
64 | + int el = regime_el(env, mmu_idx); | ||
65 | + if (el == 2 || arm_el_is_aa64(env, el)) { | ||
66 | + return true; | ||
67 | + } | ||
68 | + if (arm_feature(env, ARM_FEATURE_LPAE) | ||
69 | + && (regime_tcr(env, mmu_idx)->raw_tcr & TTBCR_EAE)) { | ||
70 | + return true; | ||
71 | + } | ||
72 | + return false; | ||
73 | +} | ||
74 | + | ||
75 | +/* | ||
76 | + * Returns true if the stage 1 translation regime is using LPAE format page | ||
77 | + * tables. Used when raising alignment exceptions, whose FSR changes depending | ||
78 | + * on whether the long or short descriptor format is in use. | ||
79 | + */ | ||
80 | +bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
81 | +{ | ||
82 | + mmu_idx = stage_1_mmu_idx(mmu_idx); | ||
83 | + return regime_using_lpae_format(env, mmu_idx); | ||
84 | +} | ||
85 | + | ||
86 | static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | ||
87 | unsigned int target_el, | ||
88 | bool same_el, bool ea, | ||
89 | -- | ||
90 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-19-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 2 -- | ||
9 | target/arm/helper.c | 25 ------------------------- | ||
10 | target/arm/ptw.c | 25 +++++++++++++++++++++++++ | ||
11 | 3 files changed, 25 insertions(+), 27 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | |||
19 | #ifndef CONFIG_USER_ONLY | ||
20 | |||
21 | -extern const uint8_t pamax_map[7]; | ||
22 | - | ||
23 | bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
24 | bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
25 | uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); | ||
26 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/helper.c | ||
29 | +++ b/target/arm/helper.c | ||
30 | @@ -XXX,XX +XXX,XX @@ bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, | ||
31 | } | ||
32 | #endif /* !CONFIG_USER_ONLY */ | ||
33 | |||
34 | -/* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. */ | ||
35 | -const uint8_t pamax_map[] = { | ||
36 | - [0] = 32, | ||
37 | - [1] = 36, | ||
38 | - [2] = 40, | ||
39 | - [3] = 42, | ||
40 | - [4] = 44, | ||
41 | - [5] = 48, | ||
42 | - [6] = 52, | ||
43 | -}; | ||
44 | - | ||
45 | -/* The cpu-specific constant value of PAMax; also used by hw/arm/virt. */ | ||
46 | -unsigned int arm_pamax(ARMCPU *cpu) | ||
47 | -{ | ||
48 | - unsigned int parange = | ||
49 | - FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); | ||
50 | - | ||
51 | - /* | ||
52 | - * id_aa64mmfr0 is a read-only register so values outside of the | ||
53 | - * supported mappings can be considered an implementation error. | ||
54 | - */ | ||
55 | - assert(parange < ARRAY_SIZE(pamax_map)); | ||
56 | - return pamax_map[parange]; | ||
57 | -} | ||
58 | - | ||
59 | int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) | ||
60 | { | ||
61 | if (regime_has_2_ranges(mmu_idx)) { | ||
62 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/target/arm/ptw.c | ||
65 | +++ b/target/arm/ptw.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
67 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
68 | __attribute__((nonnull)); | ||
69 | |||
70 | +/* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. */ | ||
71 | +static const uint8_t pamax_map[] = { | ||
72 | + [0] = 32, | ||
73 | + [1] = 36, | ||
74 | + [2] = 40, | ||
75 | + [3] = 42, | ||
76 | + [4] = 44, | ||
77 | + [5] = 48, | ||
78 | + [6] = 52, | ||
79 | +}; | ||
80 | + | ||
81 | +/* The cpu-specific constant value of PAMax; also used by hw/arm/virt. */ | ||
82 | +unsigned int arm_pamax(ARMCPU *cpu) | ||
83 | +{ | ||
84 | + unsigned int parange = | ||
85 | + FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); | ||
86 | + | ||
87 | + /* | ||
88 | + * id_aa64mmfr0 is a read-only register so values outside of the | ||
89 | + * supported mappings can be considered an implementation error. | ||
90 | + */ | ||
91 | + assert(parange < ARRAY_SIZE(pamax_map)); | ||
92 | + return pamax_map[parange]; | ||
93 | +} | ||
94 | + | ||
95 | static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
96 | { | ||
97 | return (regime_sctlr(env, mmu_idx) & SCTLR_EE) != 0; | ||
98 | -- | ||
99 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-20-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 3 -- | ||
9 | target/arm/helper.c | 128 -------------------------------------------- | ||
10 | target/arm/ptw.c | 128 ++++++++++++++++++++++++++++++++++++++++++++ | ||
11 | 3 files changed, 128 insertions(+), 131 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
18 | ARMMMUIdx mmu_idx); | ||
19 | bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, | ||
20 | int inputsize, int stride, int outputsize); | ||
21 | -int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0); | ||
22 | -int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, | ||
23 | - int ap, int ns, int xn, int pxn); | ||
24 | |||
25 | #endif /* !CONFIG_USER_ONLY */ | ||
26 | #endif /* TARGET_ARM_PTW_H */ | ||
27 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/helper.c | ||
30 | +++ b/target/arm/helper.c | ||
31 | @@ -XXX,XX +XXX,XX @@ int simple_ap_to_rw_prot_is_user(int ap, bool is_user) | ||
32 | } | ||
33 | } | ||
34 | |||
35 | -/* Translate S2 section/page access permissions to protection flags | ||
36 | - * | ||
37 | - * @env: CPUARMState | ||
38 | - * @s2ap: The 2-bit stage2 access permissions (S2AP) | ||
39 | - * @xn: XN (execute-never) bits | ||
40 | - * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0 | ||
41 | - */ | ||
42 | -int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) | ||
43 | -{ | ||
44 | - int prot = 0; | ||
45 | - | ||
46 | - if (s2ap & 1) { | ||
47 | - prot |= PAGE_READ; | ||
48 | - } | ||
49 | - if (s2ap & 2) { | ||
50 | - prot |= PAGE_WRITE; | ||
51 | - } | ||
52 | - | ||
53 | - if (cpu_isar_feature(any_tts2uxn, env_archcpu(env))) { | ||
54 | - switch (xn) { | ||
55 | - case 0: | ||
56 | - prot |= PAGE_EXEC; | ||
57 | - break; | ||
58 | - case 1: | ||
59 | - if (s1_is_el0) { | ||
60 | - prot |= PAGE_EXEC; | ||
61 | - } | ||
62 | - break; | ||
63 | - case 2: | ||
64 | - break; | ||
65 | - case 3: | ||
66 | - if (!s1_is_el0) { | ||
67 | - prot |= PAGE_EXEC; | ||
68 | - } | ||
69 | - break; | ||
70 | - default: | ||
71 | - g_assert_not_reached(); | ||
72 | - } | ||
73 | - } else { | ||
74 | - if (!extract32(xn, 1, 1)) { | ||
75 | - if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) { | ||
76 | - prot |= PAGE_EXEC; | ||
77 | - } | ||
78 | - } | ||
79 | - } | ||
80 | - return prot; | ||
81 | -} | ||
82 | - | ||
83 | -/* Translate section/page access permissions to protection flags | ||
84 | - * | ||
85 | - * @env: CPUARMState | ||
86 | - * @mmu_idx: MMU index indicating required translation regime | ||
87 | - * @is_aa64: TRUE if AArch64 | ||
88 | - * @ap: The 2-bit simple AP (AP[2:1]) | ||
89 | - * @ns: NS (non-secure) bit | ||
90 | - * @xn: XN (execute-never) bit | ||
91 | - * @pxn: PXN (privileged execute-never) bit | ||
92 | - */ | ||
93 | -int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, | ||
94 | - int ap, int ns, int xn, int pxn) | ||
95 | -{ | ||
96 | - bool is_user = regime_is_user(env, mmu_idx); | ||
97 | - int prot_rw, user_rw; | ||
98 | - bool have_wxn; | ||
99 | - int wxn = 0; | ||
100 | - | ||
101 | - assert(mmu_idx != ARMMMUIdx_Stage2); | ||
102 | - assert(mmu_idx != ARMMMUIdx_Stage2_S); | ||
103 | - | ||
104 | - user_rw = simple_ap_to_rw_prot_is_user(ap, true); | ||
105 | - if (is_user) { | ||
106 | - prot_rw = user_rw; | ||
107 | - } else { | ||
108 | - if (user_rw && regime_is_pan(env, mmu_idx)) { | ||
109 | - /* PAN forbids data accesses but doesn't affect insn fetch */ | ||
110 | - prot_rw = 0; | ||
111 | - } else { | ||
112 | - prot_rw = simple_ap_to_rw_prot_is_user(ap, false); | ||
113 | - } | ||
114 | - } | ||
115 | - | ||
116 | - if (ns && arm_is_secure(env) && (env->cp15.scr_el3 & SCR_SIF)) { | ||
117 | - return prot_rw; | ||
118 | - } | ||
119 | - | ||
120 | - /* TODO have_wxn should be replaced with | ||
121 | - * ARM_FEATURE_V8 || (ARM_FEATURE_V7 && ARM_FEATURE_EL2) | ||
122 | - * when ARM_FEATURE_EL2 starts getting set. For now we assume all LPAE | ||
123 | - * compatible processors have EL2, which is required for [U]WXN. | ||
124 | - */ | ||
125 | - have_wxn = arm_feature(env, ARM_FEATURE_LPAE); | ||
126 | - | ||
127 | - if (have_wxn) { | ||
128 | - wxn = regime_sctlr(env, mmu_idx) & SCTLR_WXN; | ||
129 | - } | ||
130 | - | ||
131 | - if (is_aa64) { | ||
132 | - if (regime_has_2_ranges(mmu_idx) && !is_user) { | ||
133 | - xn = pxn || (user_rw & PAGE_WRITE); | ||
134 | - } | ||
135 | - } else if (arm_feature(env, ARM_FEATURE_V7)) { | ||
136 | - switch (regime_el(env, mmu_idx)) { | ||
137 | - case 1: | ||
138 | - case 3: | ||
139 | - if (is_user) { | ||
140 | - xn = xn || !(user_rw & PAGE_READ); | ||
141 | - } else { | ||
142 | - int uwxn = 0; | ||
143 | - if (have_wxn) { | ||
144 | - uwxn = regime_sctlr(env, mmu_idx) & SCTLR_UWXN; | ||
145 | - } | ||
146 | - xn = xn || !(prot_rw & PAGE_READ) || pxn || | ||
147 | - (uwxn && (user_rw & PAGE_WRITE)); | ||
148 | - } | ||
149 | - break; | ||
150 | - case 2: | ||
151 | - break; | ||
152 | - } | ||
153 | - } else { | ||
154 | - xn = wxn = 0; | ||
155 | - } | ||
156 | - | ||
157 | - if (xn || (wxn && (prot_rw & PAGE_WRITE))) { | ||
158 | - return prot_rw; | ||
159 | - } | ||
160 | - return prot_rw | PAGE_EXEC; | ||
161 | -} | ||
162 | - | ||
163 | /* | ||
164 | * check_s2_mmu_setup | ||
165 | * @cpu: ARMCPU | ||
166 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/target/arm/ptw.c | ||
169 | +++ b/target/arm/ptw.c | ||
170 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
171 | return true; | ||
172 | } | ||
173 | |||
174 | +/* | ||
175 | + * Translate S2 section/page access permissions to protection flags | ||
176 | + * @env: CPUARMState | ||
177 | + * @s2ap: The 2-bit stage2 access permissions (S2AP) | ||
178 | + * @xn: XN (execute-never) bits | ||
179 | + * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0 | ||
180 | + */ | ||
181 | +static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) | ||
182 | +{ | ||
183 | + int prot = 0; | ||
184 | + | ||
185 | + if (s2ap & 1) { | ||
186 | + prot |= PAGE_READ; | ||
187 | + } | ||
188 | + if (s2ap & 2) { | ||
189 | + prot |= PAGE_WRITE; | ||
190 | + } | ||
191 | + | ||
192 | + if (cpu_isar_feature(any_tts2uxn, env_archcpu(env))) { | ||
193 | + switch (xn) { | ||
194 | + case 0: | ||
195 | + prot |= PAGE_EXEC; | ||
196 | + break; | ||
197 | + case 1: | ||
198 | + if (s1_is_el0) { | ||
199 | + prot |= PAGE_EXEC; | ||
200 | + } | ||
201 | + break; | ||
202 | + case 2: | ||
203 | + break; | ||
204 | + case 3: | ||
205 | + if (!s1_is_el0) { | ||
206 | + prot |= PAGE_EXEC; | ||
207 | + } | ||
208 | + break; | ||
209 | + default: | ||
210 | + g_assert_not_reached(); | ||
211 | + } | ||
212 | + } else { | ||
213 | + if (!extract32(xn, 1, 1)) { | ||
214 | + if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) { | ||
215 | + prot |= PAGE_EXEC; | ||
216 | + } | ||
217 | + } | ||
218 | + } | ||
219 | + return prot; | ||
220 | +} | ||
221 | + | ||
222 | +/* | ||
223 | + * Translate section/page access permissions to protection flags | ||
224 | + * @env: CPUARMState | ||
225 | + * @mmu_idx: MMU index indicating required translation regime | ||
226 | + * @is_aa64: TRUE if AArch64 | ||
227 | + * @ap: The 2-bit simple AP (AP[2:1]) | ||
228 | + * @ns: NS (non-secure) bit | ||
229 | + * @xn: XN (execute-never) bit | ||
230 | + * @pxn: PXN (privileged execute-never) bit | ||
231 | + */ | ||
232 | +static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, | ||
233 | + int ap, int ns, int xn, int pxn) | ||
234 | +{ | ||
235 | + bool is_user = regime_is_user(env, mmu_idx); | ||
236 | + int prot_rw, user_rw; | ||
237 | + bool have_wxn; | ||
238 | + int wxn = 0; | ||
239 | + | ||
240 | + assert(mmu_idx != ARMMMUIdx_Stage2); | ||
241 | + assert(mmu_idx != ARMMMUIdx_Stage2_S); | ||
242 | + | ||
243 | + user_rw = simple_ap_to_rw_prot_is_user(ap, true); | ||
244 | + if (is_user) { | ||
245 | + prot_rw = user_rw; | ||
246 | + } else { | ||
247 | + if (user_rw && regime_is_pan(env, mmu_idx)) { | ||
248 | + /* PAN forbids data accesses but doesn't affect insn fetch */ | ||
249 | + prot_rw = 0; | ||
250 | + } else { | ||
251 | + prot_rw = simple_ap_to_rw_prot_is_user(ap, false); | ||
252 | + } | ||
253 | + } | ||
254 | + | ||
255 | + if (ns && arm_is_secure(env) && (env->cp15.scr_el3 & SCR_SIF)) { | ||
256 | + return prot_rw; | ||
257 | + } | ||
258 | + | ||
259 | + /* TODO have_wxn should be replaced with | ||
260 | + * ARM_FEATURE_V8 || (ARM_FEATURE_V7 && ARM_FEATURE_EL2) | ||
261 | + * when ARM_FEATURE_EL2 starts getting set. For now we assume all LPAE | ||
262 | + * compatible processors have EL2, which is required for [U]WXN. | ||
263 | + */ | ||
264 | + have_wxn = arm_feature(env, ARM_FEATURE_LPAE); | ||
265 | + | ||
266 | + if (have_wxn) { | ||
267 | + wxn = regime_sctlr(env, mmu_idx) & SCTLR_WXN; | ||
268 | + } | ||
269 | + | ||
270 | + if (is_aa64) { | ||
271 | + if (regime_has_2_ranges(mmu_idx) && !is_user) { | ||
272 | + xn = pxn || (user_rw & PAGE_WRITE); | ||
273 | + } | ||
274 | + } else if (arm_feature(env, ARM_FEATURE_V7)) { | ||
275 | + switch (regime_el(env, mmu_idx)) { | ||
276 | + case 1: | ||
277 | + case 3: | ||
278 | + if (is_user) { | ||
279 | + xn = xn || !(user_rw & PAGE_READ); | ||
280 | + } else { | ||
281 | + int uwxn = 0; | ||
282 | + if (have_wxn) { | ||
283 | + uwxn = regime_sctlr(env, mmu_idx) & SCTLR_UWXN; | ||
284 | + } | ||
285 | + xn = xn || !(prot_rw & PAGE_READ) || pxn || | ||
286 | + (uwxn && (user_rw & PAGE_WRITE)); | ||
287 | + } | ||
288 | + break; | ||
289 | + case 2: | ||
290 | + break; | ||
291 | + } | ||
292 | + } else { | ||
293 | + xn = wxn = 0; | ||
294 | + } | ||
295 | + | ||
296 | + if (xn || (wxn && (prot_rw & PAGE_WRITE))) { | ||
297 | + return prot_rw; | ||
298 | + } | ||
299 | + return prot_rw | PAGE_EXEC; | ||
300 | +} | ||
301 | + | ||
302 | /** | ||
303 | * get_phys_addr_lpae: perform one stage of page table walk, LPAE format | ||
304 | * | ||
305 | -- | ||
306 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Check for and defer any pending virtual SError. | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | 4 | Message-id: 20220604040607.269301-21-richard.henderson@linaro.org | |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220506180242.216785-17-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 7 | --- |
10 | target/arm/helper.h | 1 + | 8 | target/arm/ptw.h | 2 -- |
11 | target/arm/a32.decode | 16 ++++++++------ | 9 | target/arm/helper.c | 70 --------------------------------------------- |
12 | target/arm/t32.decode | 18 ++++++++-------- | 10 | target/arm/ptw.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ |
13 | target/arm/op_helper.c | 43 ++++++++++++++++++++++++++++++++++++++ | 11 | 3 files changed, 70 insertions(+), 72 deletions(-) |
14 | target/arm/translate-a64.c | 17 +++++++++++++++ | ||
15 | target/arm/translate.c | 23 ++++++++++++++++++++ | ||
16 | 6 files changed, 103 insertions(+), 15 deletions(-) | ||
17 | 12 | ||
18 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h |
19 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper.h | 15 | --- a/target/arm/ptw.h |
21 | +++ b/target/arm/helper.h | 16 | +++ b/target/arm/ptw.h |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_1(wfe, void, env) | 17 | @@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) |
23 | DEF_HELPER_1(yield, void, env) | 18 | |
24 | DEF_HELPER_1(pre_hvc, void, env) | 19 | ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, |
25 | DEF_HELPER_2(pre_smc, void, env, i32) | 20 | ARMMMUIdx mmu_idx); |
26 | +DEF_HELPER_1(vesb, void, env) | 21 | -bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, |
27 | 22 | - int inputsize, int stride, int outputsize); | |
28 | DEF_HELPER_3(cpsr_write, void, env, i32, i32) | 23 | |
29 | DEF_HELPER_2(cpsr_write_eret, void, env, i32) | 24 | #endif /* !CONFIG_USER_ONLY */ |
30 | diff --git a/target/arm/a32.decode b/target/arm/a32.decode | 25 | #endif /* TARGET_ARM_PTW_H */ |
26 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/target/arm/a32.decode | 28 | --- a/target/arm/helper.c |
33 | +++ b/target/arm/a32.decode | 29 | +++ b/target/arm/helper.c |
34 | @@ -XXX,XX +XXX,XX @@ SMULTT .... 0001 0110 .... 0000 .... 1110 .... @rd0mn | 30 | @@ -XXX,XX +XXX,XX @@ int simple_ap_to_rw_prot_is_user(int ap, bool is_user) |
35 | 31 | g_assert_not_reached(); | |
36 | { | ||
37 | { | ||
38 | - YIELD ---- 0011 0010 0000 1111 ---- 0000 0001 | ||
39 | - WFE ---- 0011 0010 0000 1111 ---- 0000 0010 | ||
40 | - WFI ---- 0011 0010 0000 1111 ---- 0000 0011 | ||
41 | + [ | ||
42 | + YIELD ---- 0011 0010 0000 1111 ---- 0000 0001 | ||
43 | + WFE ---- 0011 0010 0000 1111 ---- 0000 0010 | ||
44 | + WFI ---- 0011 0010 0000 1111 ---- 0000 0011 | ||
45 | |||
46 | - # TODO: Implement SEV, SEVL; may help SMP performance. | ||
47 | - # SEV ---- 0011 0010 0000 1111 ---- 0000 0100 | ||
48 | - # SEVL ---- 0011 0010 0000 1111 ---- 0000 0101 | ||
49 | + # TODO: Implement SEV, SEVL; may help SMP performance. | ||
50 | + # SEV ---- 0011 0010 0000 1111 ---- 0000 0100 | ||
51 | + # SEVL ---- 0011 0010 0000 1111 ---- 0000 0101 | ||
52 | + | ||
53 | + ESB ---- 0011 0010 0000 1111 ---- 0001 0000 | ||
54 | + ] | ||
55 | |||
56 | # The canonical nop ends in 00000000, but the whole of the | ||
57 | # rest of the space executes as nop if otherwise unsupported. | ||
58 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/t32.decode | ||
61 | +++ b/target/arm/t32.decode | ||
62 | @@ -XXX,XX +XXX,XX @@ CLZ 1111 1010 1011 ---- 1111 .... 1000 .... @rdm | ||
63 | [ | ||
64 | # Hints, and CPS | ||
65 | { | ||
66 | - YIELD 1111 0011 1010 1111 1000 0000 0000 0001 | ||
67 | - WFE 1111 0011 1010 1111 1000 0000 0000 0010 | ||
68 | - WFI 1111 0011 1010 1111 1000 0000 0000 0011 | ||
69 | + [ | ||
70 | + YIELD 1111 0011 1010 1111 1000 0000 0000 0001 | ||
71 | + WFE 1111 0011 1010 1111 1000 0000 0000 0010 | ||
72 | + WFI 1111 0011 1010 1111 1000 0000 0000 0011 | ||
73 | |||
74 | - # TODO: Implement SEV, SEVL; may help SMP performance. | ||
75 | - # SEV 1111 0011 1010 1111 1000 0000 0000 0100 | ||
76 | - # SEVL 1111 0011 1010 1111 1000 0000 0000 0101 | ||
77 | + # TODO: Implement SEV, SEVL; may help SMP performance. | ||
78 | + # SEV 1111 0011 1010 1111 1000 0000 0000 0100 | ||
79 | + # SEVL 1111 0011 1010 1111 1000 0000 0000 0101 | ||
80 | |||
81 | - # For M-profile minimal-RAS ESB can be a NOP, which is the | ||
82 | - # default behaviour since it is in the hint space. | ||
83 | - # ESB 1111 0011 1010 1111 1000 0000 0001 0000 | ||
84 | + ESB 1111 0011 1010 1111 1000 0000 0001 0000 | ||
85 | + ] | ||
86 | |||
87 | # The canonical nop ends in 0000 0000, but the whole rest | ||
88 | # of the space is "reserved hint, behaves as nop". | ||
89 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/target/arm/op_helper.c | ||
92 | +++ b/target/arm/op_helper.c | ||
93 | @@ -XXX,XX +XXX,XX @@ void HELPER(probe_access)(CPUARMState *env, target_ulong ptr, | ||
94 | access_type, mmu_idx, ra); | ||
95 | } | 32 | } |
96 | } | 33 | } |
34 | - | ||
35 | -/* | ||
36 | - * check_s2_mmu_setup | ||
37 | - * @cpu: ARMCPU | ||
38 | - * @is_aa64: True if the translation regime is in AArch64 state | ||
39 | - * @startlevel: Suggested starting level | ||
40 | - * @inputsize: Bitsize of IPAs | ||
41 | - * @stride: Page-table stride (See the ARM ARM) | ||
42 | - * | ||
43 | - * Returns true if the suggested S2 translation parameters are OK and | ||
44 | - * false otherwise. | ||
45 | - */ | ||
46 | -bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, | ||
47 | - int inputsize, int stride, int outputsize) | ||
48 | -{ | ||
49 | - const int grainsize = stride + 3; | ||
50 | - int startsizecheck; | ||
51 | - | ||
52 | - /* | ||
53 | - * Negative levels are usually not allowed... | ||
54 | - * Except for FEAT_LPA2, 4k page table, 52-bit address space, which | ||
55 | - * begins with level -1. Note that previous feature tests will have | ||
56 | - * eliminated this combination if it is not enabled. | ||
57 | - */ | ||
58 | - if (level < (inputsize == 52 && stride == 9 ? -1 : 0)) { | ||
59 | - return false; | ||
60 | - } | ||
61 | - | ||
62 | - startsizecheck = inputsize - ((3 - level) * stride + grainsize); | ||
63 | - if (startsizecheck < 1 || startsizecheck > stride + 4) { | ||
64 | - return false; | ||
65 | - } | ||
66 | - | ||
67 | - if (is_aa64) { | ||
68 | - switch (stride) { | ||
69 | - case 13: /* 64KB Pages. */ | ||
70 | - if (level == 0 || (level == 1 && outputsize <= 42)) { | ||
71 | - return false; | ||
72 | - } | ||
73 | - break; | ||
74 | - case 11: /* 16KB Pages. */ | ||
75 | - if (level == 0 || (level == 1 && outputsize <= 40)) { | ||
76 | - return false; | ||
77 | - } | ||
78 | - break; | ||
79 | - case 9: /* 4KB Pages. */ | ||
80 | - if (level == 0 && outputsize <= 42) { | ||
81 | - return false; | ||
82 | - } | ||
83 | - break; | ||
84 | - default: | ||
85 | - g_assert_not_reached(); | ||
86 | - } | ||
87 | - | ||
88 | - /* Inputsize checks. */ | ||
89 | - if (inputsize > outputsize && | ||
90 | - (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { | ||
91 | - /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. */ | ||
92 | - return false; | ||
93 | - } | ||
94 | - } else { | ||
95 | - /* AArch32 only supports 4KB pages. Assert on that. */ | ||
96 | - assert(stride == 9); | ||
97 | - | ||
98 | - if (level == 0) { | ||
99 | - return false; | ||
100 | - } | ||
101 | - } | ||
102 | - return true; | ||
103 | -} | ||
104 | #endif /* !CONFIG_USER_ONLY */ | ||
105 | |||
106 | int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) | ||
107 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/target/arm/ptw.c | ||
110 | +++ b/target/arm/ptw.c | ||
111 | @@ -XXX,XX +XXX,XX @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, | ||
112 | return prot_rw | PAGE_EXEC; | ||
113 | } | ||
114 | |||
115 | +/* | ||
116 | + * check_s2_mmu_setup | ||
117 | + * @cpu: ARMCPU | ||
118 | + * @is_aa64: True if the translation regime is in AArch64 state | ||
119 | + * @startlevel: Suggested starting level | ||
120 | + * @inputsize: Bitsize of IPAs | ||
121 | + * @stride: Page-table stride (See the ARM ARM) | ||
122 | + * | ||
123 | + * Returns true if the suggested S2 translation parameters are OK and | ||
124 | + * false otherwise. | ||
125 | + */ | ||
126 | +static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, | ||
127 | + int inputsize, int stride, int outputsize) | ||
128 | +{ | ||
129 | + const int grainsize = stride + 3; | ||
130 | + int startsizecheck; | ||
97 | + | 131 | + |
98 | +/* | ||
99 | + * This function corresponds to AArch64.vESBOperation(). | ||
100 | + * Note that the AArch32 version is not functionally different. | ||
101 | + */ | ||
102 | +void HELPER(vesb)(CPUARMState *env) | ||
103 | +{ | ||
104 | + /* | 132 | + /* |
105 | + * The EL2Enabled() check is done inside arm_hcr_el2_eff, | 133 | + * Negative levels are usually not allowed... |
106 | + * and will return HCR_EL2.VSE == 0, so nothing happens. | 134 | + * Except for FEAT_LPA2, 4k page table, 52-bit address space, which |
135 | + * begins with level -1. Note that previous feature tests will have | ||
136 | + * eliminated this combination if it is not enabled. | ||
107 | + */ | 137 | + */ |
108 | + uint64_t hcr = arm_hcr_el2_eff(env); | 138 | + if (level < (inputsize == 52 && stride == 9 ? -1 : 0)) { |
109 | + bool enabled = !(hcr & HCR_TGE) && (hcr & HCR_AMO); | 139 | + return false; |
110 | + bool pending = enabled && (hcr & HCR_VSE); | 140 | + } |
111 | + bool masked = (env->daif & PSTATE_A); | ||
112 | + | 141 | + |
113 | + /* If VSE pending and masked, defer the exception. */ | 142 | + startsizecheck = inputsize - ((3 - level) * stride + grainsize); |
114 | + if (pending && masked) { | 143 | + if (startsizecheck < 1 || startsizecheck > stride + 4) { |
115 | + uint32_t syndrome; | 144 | + return false; |
145 | + } | ||
116 | + | 146 | + |
117 | + if (arm_el_is_aa64(env, 1)) { | 147 | + if (is_aa64) { |
118 | + /* Copy across IDS and ISS from VSESR. */ | 148 | + switch (stride) { |
119 | + syndrome = env->cp15.vsesr_el2 & 0x1ffffff; | 149 | + case 13: /* 64KB Pages. */ |
120 | + } else { | 150 | + if (level == 0 || (level == 1 && outputsize <= 42)) { |
121 | + ARMMMUFaultInfo fi = { .type = ARMFault_AsyncExternal }; | 151 | + return false; |
122 | + | ||
123 | + if (extended_addresses_enabled(env)) { | ||
124 | + syndrome = arm_fi_to_lfsc(&fi); | ||
125 | + } else { | ||
126 | + syndrome = arm_fi_to_sfsc(&fi); | ||
127 | + } | 152 | + } |
128 | + /* Copy across AET and ExT from VSESR. */ | 153 | + break; |
129 | + syndrome |= env->cp15.vsesr_el2 & 0xd000; | 154 | + case 11: /* 16KB Pages. */ |
155 | + if (level == 0 || (level == 1 && outputsize <= 40)) { | ||
156 | + return false; | ||
157 | + } | ||
158 | + break; | ||
159 | + case 9: /* 4KB Pages. */ | ||
160 | + if (level == 0 && outputsize <= 42) { | ||
161 | + return false; | ||
162 | + } | ||
163 | + break; | ||
164 | + default: | ||
165 | + g_assert_not_reached(); | ||
130 | + } | 166 | + } |
131 | + | 167 | + |
132 | + /* Set VDISR_EL2.A along with the syndrome. */ | 168 | + /* Inputsize checks. */ |
133 | + env->cp15.vdisr_el2 = syndrome | (1u << 31); | 169 | + if (inputsize > outputsize && |
170 | + (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { | ||
171 | + /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. */ | ||
172 | + return false; | ||
173 | + } | ||
174 | + } else { | ||
175 | + /* AArch32 only supports 4KB pages. Assert on that. */ | ||
176 | + assert(stride == 9); | ||
134 | + | 177 | + |
135 | + /* Clear pending virtual SError */ | 178 | + if (level == 0) { |
136 | + env->cp15.hcr_el2 &= ~HCR_VSE; | 179 | + return false; |
137 | + cpu_reset_interrupt(env_cpu(env), CPU_INTERRUPT_VSERR); | ||
138 | + } | ||
139 | +} | ||
140 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/target/arm/translate-a64.c | ||
143 | +++ b/target/arm/translate-a64.c | ||
144 | @@ -XXX,XX +XXX,XX @@ static void handle_hint(DisasContext *s, uint32_t insn, | ||
145 | gen_helper_autib(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
146 | } | ||
147 | break; | ||
148 | + case 0b10000: /* ESB */ | ||
149 | + /* Without RAS, we must implement this as NOP. */ | ||
150 | + if (dc_isar_feature(aa64_ras, s)) { | ||
151 | + /* | ||
152 | + * QEMU does not have a source of physical SErrors, | ||
153 | + * so we are only concerned with virtual SErrors. | ||
154 | + * The pseudocode in the ARM for this case is | ||
155 | + * if PSTATE.EL IN {EL0, EL1} && EL2Enabled() then | ||
156 | + * AArch64.vESBOperation(); | ||
157 | + * Most of the condition can be evaluated at translation time. | ||
158 | + * Test for EL2 present, and defer test for SEL2 to runtime. | ||
159 | + */ | ||
160 | + if (s->current_el <= 1 && arm_dc_feature(s, ARM_FEATURE_EL2)) { | ||
161 | + gen_helper_vesb(cpu_env); | ||
162 | + } | ||
163 | + } | ||
164 | + break; | ||
165 | case 0b11000: /* PACIAZ */ | ||
166 | if (s->pauth_active) { | ||
167 | gen_helper_pacia(cpu_X[30], cpu_env, cpu_X[30], | ||
168 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
169 | index XXXXXXX..XXXXXXX 100644 | ||
170 | --- a/target/arm/translate.c | ||
171 | +++ b/target/arm/translate.c | ||
172 | @@ -XXX,XX +XXX,XX @@ static bool trans_WFI(DisasContext *s, arg_WFI *a) | ||
173 | return true; | ||
174 | } | ||
175 | |||
176 | +static bool trans_ESB(DisasContext *s, arg_ESB *a) | ||
177 | +{ | ||
178 | + /* | ||
179 | + * For M-profile, minimal-RAS ESB can be a NOP. | ||
180 | + * Without RAS, we must implement this as NOP. | ||
181 | + */ | ||
182 | + if (!arm_dc_feature(s, ARM_FEATURE_M) && dc_isar_feature(aa32_ras, s)) { | ||
183 | + /* | ||
184 | + * QEMU does not have a source of physical SErrors, | ||
185 | + * so we are only concerned with virtual SErrors. | ||
186 | + * The pseudocode in the ARM for this case is | ||
187 | + * if PSTATE.EL IN {EL0, EL1} && EL2Enabled() then | ||
188 | + * AArch32.vESBOperation(); | ||
189 | + * Most of the condition can be evaluated at translation time. | ||
190 | + * Test for EL2 present, and defer test for SEL2 to runtime. | ||
191 | + */ | ||
192 | + if (s->current_el <= 1 && arm_dc_feature(s, ARM_FEATURE_EL2)) { | ||
193 | + gen_helper_vesb(cpu_env); | ||
194 | + } | 180 | + } |
195 | + } | 181 | + } |
196 | + return true; | 182 | + return true; |
197 | +} | 183 | +} |
198 | + | 184 | + |
199 | static bool trans_NOP(DisasContext *s, arg_NOP *a) | 185 | /** |
200 | { | 186 | * get_phys_addr_lpae: perform one stage of page table walk, LPAE format |
201 | return true; | 187 | * |
202 | -- | 188 | -- |
203 | 2.25.1 | 189 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220604040607.269301-22-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/ptw.h | 3 --- | ||
9 | target/arm/helper.c | 64 --------------------------------------------- | ||
10 | target/arm/ptw.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ | ||
11 | 3 files changed, 64 insertions(+), 67 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/ptw.h | ||
16 | +++ b/target/arm/ptw.h | ||
17 | @@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | ||
18 | return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); | ||
19 | } | ||
20 | |||
21 | -ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
22 | - ARMMMUIdx mmu_idx); | ||
23 | - | ||
24 | #endif /* !CONFIG_USER_ONLY */ | ||
25 | #endif /* TARGET_ARM_PTW_H */ | ||
26 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/helper.c | ||
29 | +++ b/target/arm/helper.c | ||
30 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
31 | } | ||
32 | |||
33 | #ifndef CONFIG_USER_ONLY | ||
34 | -ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
35 | - ARMMMUIdx mmu_idx) | ||
36 | -{ | ||
37 | - uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | ||
38 | - uint32_t el = regime_el(env, mmu_idx); | ||
39 | - int select, tsz; | ||
40 | - bool epd, hpd; | ||
41 | - | ||
42 | - assert(mmu_idx != ARMMMUIdx_Stage2_S); | ||
43 | - | ||
44 | - if (mmu_idx == ARMMMUIdx_Stage2) { | ||
45 | - /* VTCR */ | ||
46 | - bool sext = extract32(tcr, 4, 1); | ||
47 | - bool sign = extract32(tcr, 3, 1); | ||
48 | - | ||
49 | - /* | ||
50 | - * If the sign-extend bit is not the same as t0sz[3], the result | ||
51 | - * is unpredictable. Flag this as a guest error. | ||
52 | - */ | ||
53 | - if (sign != sext) { | ||
54 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
55 | - "AArch32: VTCR.S / VTCR.T0SZ[3] mismatch\n"); | ||
56 | - } | ||
57 | - tsz = sextract32(tcr, 0, 4) + 8; | ||
58 | - select = 0; | ||
59 | - hpd = false; | ||
60 | - epd = false; | ||
61 | - } else if (el == 2) { | ||
62 | - /* HTCR */ | ||
63 | - tsz = extract32(tcr, 0, 3); | ||
64 | - select = 0; | ||
65 | - hpd = extract64(tcr, 24, 1); | ||
66 | - epd = false; | ||
67 | - } else { | ||
68 | - int t0sz = extract32(tcr, 0, 3); | ||
69 | - int t1sz = extract32(tcr, 16, 3); | ||
70 | - | ||
71 | - if (t1sz == 0) { | ||
72 | - select = va > (0xffffffffu >> t0sz); | ||
73 | - } else { | ||
74 | - /* Note that we will detect errors later. */ | ||
75 | - select = va >= ~(0xffffffffu >> t1sz); | ||
76 | - } | ||
77 | - if (!select) { | ||
78 | - tsz = t0sz; | ||
79 | - epd = extract32(tcr, 7, 1); | ||
80 | - hpd = extract64(tcr, 41, 1); | ||
81 | - } else { | ||
82 | - tsz = t1sz; | ||
83 | - epd = extract32(tcr, 23, 1); | ||
84 | - hpd = extract64(tcr, 42, 1); | ||
85 | - } | ||
86 | - /* For aarch32, hpd0 is not enabled without t2e as well. */ | ||
87 | - hpd &= extract32(tcr, 6, 1); | ||
88 | - } | ||
89 | - | ||
90 | - return (ARMVAParameters) { | ||
91 | - .tsz = tsz, | ||
92 | - .select = select, | ||
93 | - .epd = epd, | ||
94 | - .hpd = hpd, | ||
95 | - }; | ||
96 | -} | ||
97 | - | ||
98 | hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, | ||
99 | MemTxAttrs *attrs) | ||
100 | { | ||
101 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/target/arm/ptw.c | ||
104 | +++ b/target/arm/ptw.c | ||
105 | @@ -XXX,XX +XXX,XX @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, | ||
106 | return prot_rw | PAGE_EXEC; | ||
107 | } | ||
108 | |||
109 | +static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
110 | + ARMMMUIdx mmu_idx) | ||
111 | +{ | ||
112 | + uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | ||
113 | + uint32_t el = regime_el(env, mmu_idx); | ||
114 | + int select, tsz; | ||
115 | + bool epd, hpd; | ||
116 | + | ||
117 | + assert(mmu_idx != ARMMMUIdx_Stage2_S); | ||
118 | + | ||
119 | + if (mmu_idx == ARMMMUIdx_Stage2) { | ||
120 | + /* VTCR */ | ||
121 | + bool sext = extract32(tcr, 4, 1); | ||
122 | + bool sign = extract32(tcr, 3, 1); | ||
123 | + | ||
124 | + /* | ||
125 | + * If the sign-extend bit is not the same as t0sz[3], the result | ||
126 | + * is unpredictable. Flag this as a guest error. | ||
127 | + */ | ||
128 | + if (sign != sext) { | ||
129 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
130 | + "AArch32: VTCR.S / VTCR.T0SZ[3] mismatch\n"); | ||
131 | + } | ||
132 | + tsz = sextract32(tcr, 0, 4) + 8; | ||
133 | + select = 0; | ||
134 | + hpd = false; | ||
135 | + epd = false; | ||
136 | + } else if (el == 2) { | ||
137 | + /* HTCR */ | ||
138 | + tsz = extract32(tcr, 0, 3); | ||
139 | + select = 0; | ||
140 | + hpd = extract64(tcr, 24, 1); | ||
141 | + epd = false; | ||
142 | + } else { | ||
143 | + int t0sz = extract32(tcr, 0, 3); | ||
144 | + int t1sz = extract32(tcr, 16, 3); | ||
145 | + | ||
146 | + if (t1sz == 0) { | ||
147 | + select = va > (0xffffffffu >> t0sz); | ||
148 | + } else { | ||
149 | + /* Note that we will detect errors later. */ | ||
150 | + select = va >= ~(0xffffffffu >> t1sz); | ||
151 | + } | ||
152 | + if (!select) { | ||
153 | + tsz = t0sz; | ||
154 | + epd = extract32(tcr, 7, 1); | ||
155 | + hpd = extract64(tcr, 41, 1); | ||
156 | + } else { | ||
157 | + tsz = t1sz; | ||
158 | + epd = extract32(tcr, 23, 1); | ||
159 | + hpd = extract64(tcr, 42, 1); | ||
160 | + } | ||
161 | + /* For aarch32, hpd0 is not enabled without t2e as well. */ | ||
162 | + hpd &= extract32(tcr, 6, 1); | ||
163 | + } | ||
164 | + | ||
165 | + return (ARMVAParameters) { | ||
166 | + .tsz = tsz, | ||
167 | + .select = select, | ||
168 | + .epd = epd, | ||
169 | + .hpd = hpd, | ||
170 | + }; | ||
171 | +} | ||
172 | + | ||
173 | /* | ||
174 | * check_s2_mmu_setup | ||
175 | * @cpu: ARMCPU | ||
176 | -- | ||
177 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add only the system registers required to implement zero error | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | records. This means that all values for ERRSELR are out of range, | 4 | Message-id: 20220604040607.269301-23-richard.henderson@linaro.org |
5 | which means that it and all of the indexed error record registers | ||
6 | need not be implemented. | ||
7 | |||
8 | Add the EL2 registers required for injecting virtual SError. | ||
9 | |||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20220506180242.216785-14-richard.henderson@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 7 | --- |
15 | target/arm/cpu.h | 5 +++ | 8 | target/arm/ptw.h | 10 ------ |
16 | target/arm/helper.c | 84 +++++++++++++++++++++++++++++++++++++++++++++ | 9 | target/arm/helper.c | 77 ------------------------------------------ |
17 | 2 files changed, 89 insertions(+) | 10 | target/arm/ptw.c | 81 +++++++++++++++++++++++++++++++++++++++++++++ |
11 | 3 files changed, 81 insertions(+), 87 deletions(-) | ||
18 | 12 | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h |
20 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 15 | --- a/target/arm/ptw.h |
22 | +++ b/target/arm/cpu.h | 16 | +++ b/target/arm/ptw.h |
23 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | 17 | @@ -XXX,XX +XXX,XX @@ bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); |
24 | uint64_t tfsr_el[4]; /* tfsre0_el1 is index 0. */ | 18 | bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); |
25 | uint64_t gcr_el1; | 19 | uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); |
26 | uint64_t rgsr_el1; | 20 | |
27 | + | 21 | -int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, |
28 | + /* Minimal RAS registers */ | 22 | - int ap, int domain_prot); |
29 | + uint64_t disr_el1; | 23 | -int simple_ap_to_rw_prot_is_user(int ap, bool is_user); |
30 | + uint64_t vdisr_el2; | 24 | - |
31 | + uint64_t vsesr_el2; | 25 | -static inline int |
32 | } cp15; | 26 | -simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) |
33 | 27 | -{ | |
34 | struct { | 28 | - return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); |
29 | -} | ||
30 | - | ||
31 | #endif /* !CONFIG_USER_ONLY */ | ||
32 | #endif /* TARGET_ARM_PTW_H */ | ||
35 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 33 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
36 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/target/arm/helper.c | 35 | --- a/target/arm/helper.c |
38 | +++ b/target/arm/helper.c | 36 | +++ b/target/arm/helper.c |
39 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | 37 | @@ -XXX,XX +XXX,XX @@ bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) |
40 | .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, | 38 | g_assert_not_reached(); |
41 | }; | 39 | } |
40 | } | ||
41 | - | ||
42 | -/* Translate section/page access permissions to page | ||
43 | - * R/W protection flags | ||
44 | - * | ||
45 | - * @env: CPUARMState | ||
46 | - * @mmu_idx: MMU index indicating required translation regime | ||
47 | - * @ap: The 3-bit access permissions (AP[2:0]) | ||
48 | - * @domain_prot: The 2-bit domain access permissions | ||
49 | - */ | ||
50 | -int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap, int domain_prot) | ||
51 | -{ | ||
52 | - bool is_user = regime_is_user(env, mmu_idx); | ||
53 | - | ||
54 | - if (domain_prot == 3) { | ||
55 | - return PAGE_READ | PAGE_WRITE; | ||
56 | - } | ||
57 | - | ||
58 | - switch (ap) { | ||
59 | - case 0: | ||
60 | - if (arm_feature(env, ARM_FEATURE_V7)) { | ||
61 | - return 0; | ||
62 | - } | ||
63 | - switch (regime_sctlr(env, mmu_idx) & (SCTLR_S | SCTLR_R)) { | ||
64 | - case SCTLR_S: | ||
65 | - return is_user ? 0 : PAGE_READ; | ||
66 | - case SCTLR_R: | ||
67 | - return PAGE_READ; | ||
68 | - default: | ||
69 | - return 0; | ||
70 | - } | ||
71 | - case 1: | ||
72 | - return is_user ? 0 : PAGE_READ | PAGE_WRITE; | ||
73 | - case 2: | ||
74 | - if (is_user) { | ||
75 | - return PAGE_READ; | ||
76 | - } else { | ||
77 | - return PAGE_READ | PAGE_WRITE; | ||
78 | - } | ||
79 | - case 3: | ||
80 | - return PAGE_READ | PAGE_WRITE; | ||
81 | - case 4: /* Reserved. */ | ||
82 | - return 0; | ||
83 | - case 5: | ||
84 | - return is_user ? 0 : PAGE_READ; | ||
85 | - case 6: | ||
86 | - return PAGE_READ; | ||
87 | - case 7: | ||
88 | - if (!arm_feature(env, ARM_FEATURE_V6K)) { | ||
89 | - return 0; | ||
90 | - } | ||
91 | - return PAGE_READ; | ||
92 | - default: | ||
93 | - g_assert_not_reached(); | ||
94 | - } | ||
95 | -} | ||
96 | - | ||
97 | -/* Translate section/page access permissions to page | ||
98 | - * R/W protection flags. | ||
99 | - * | ||
100 | - * @ap: The 2-bit simple AP (AP[2:1]) | ||
101 | - * @is_user: TRUE if accessing from PL0 | ||
102 | - */ | ||
103 | -int simple_ap_to_rw_prot_is_user(int ap, bool is_user) | ||
104 | -{ | ||
105 | - switch (ap) { | ||
106 | - case 0: | ||
107 | - return is_user ? 0 : PAGE_READ | PAGE_WRITE; | ||
108 | - case 1: | ||
109 | - return PAGE_READ | PAGE_WRITE; | ||
110 | - case 2: | ||
111 | - return is_user ? 0 : PAGE_READ; | ||
112 | - case 3: | ||
113 | - return PAGE_READ; | ||
114 | - default: | ||
115 | - g_assert_not_reached(); | ||
116 | - } | ||
117 | -} | ||
118 | #endif /* !CONFIG_USER_ONLY */ | ||
119 | |||
120 | int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) | ||
121 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/target/arm/ptw.c | ||
124 | +++ b/target/arm/ptw.c | ||
125 | @@ -XXX,XX +XXX,XX @@ static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
126 | return true; | ||
127 | } | ||
42 | 128 | ||
43 | +/* | 129 | +/* |
44 | + * Check for traps to RAS registers, which are controlled | 130 | + * Translate section/page access permissions to page R/W protection flags |
45 | + * by HCR_EL2.TERR and SCR_EL3.TERR. | 131 | + * @env: CPUARMState |
132 | + * @mmu_idx: MMU index indicating required translation regime | ||
133 | + * @ap: The 3-bit access permissions (AP[2:0]) | ||
134 | + * @domain_prot: The 2-bit domain access permissions | ||
46 | + */ | 135 | + */ |
47 | +static CPAccessResult access_terr(CPUARMState *env, const ARMCPRegInfo *ri, | 136 | +static int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, |
48 | + bool isread) | 137 | + int ap, int domain_prot) |
49 | +{ | 138 | +{ |
50 | + int el = arm_current_el(env); | 139 | + bool is_user = regime_is_user(env, mmu_idx); |
51 | + | 140 | + |
52 | + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_TERR)) { | 141 | + if (domain_prot == 3) { |
53 | + return CP_ACCESS_TRAP_EL2; | 142 | + return PAGE_READ | PAGE_WRITE; |
54 | + } | 143 | + } |
55 | + if (el < 3 && (env->cp15.scr_el3 & SCR_TERR)) { | 144 | + |
56 | + return CP_ACCESS_TRAP_EL3; | 145 | + switch (ap) { |
146 | + case 0: | ||
147 | + if (arm_feature(env, ARM_FEATURE_V7)) { | ||
148 | + return 0; | ||
149 | + } | ||
150 | + switch (regime_sctlr(env, mmu_idx) & (SCTLR_S | SCTLR_R)) { | ||
151 | + case SCTLR_S: | ||
152 | + return is_user ? 0 : PAGE_READ; | ||
153 | + case SCTLR_R: | ||
154 | + return PAGE_READ; | ||
155 | + default: | ||
156 | + return 0; | ||
157 | + } | ||
158 | + case 1: | ||
159 | + return is_user ? 0 : PAGE_READ | PAGE_WRITE; | ||
160 | + case 2: | ||
161 | + if (is_user) { | ||
162 | + return PAGE_READ; | ||
163 | + } else { | ||
164 | + return PAGE_READ | PAGE_WRITE; | ||
165 | + } | ||
166 | + case 3: | ||
167 | + return PAGE_READ | PAGE_WRITE; | ||
168 | + case 4: /* Reserved. */ | ||
169 | + return 0; | ||
170 | + case 5: | ||
171 | + return is_user ? 0 : PAGE_READ; | ||
172 | + case 6: | ||
173 | + return PAGE_READ; | ||
174 | + case 7: | ||
175 | + if (!arm_feature(env, ARM_FEATURE_V6K)) { | ||
176 | + return 0; | ||
177 | + } | ||
178 | + return PAGE_READ; | ||
179 | + default: | ||
180 | + g_assert_not_reached(); | ||
57 | + } | 181 | + } |
58 | + return CP_ACCESS_OK; | ||
59 | +} | 182 | +} |
60 | + | 183 | + |
61 | +static uint64_t disr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 184 | +/* |
185 | + * Translate section/page access permissions to page R/W protection flags. | ||
186 | + * @ap: The 2-bit simple AP (AP[2:1]) | ||
187 | + * @is_user: TRUE if accessing from PL0 | ||
188 | + */ | ||
189 | +static int simple_ap_to_rw_prot_is_user(int ap, bool is_user) | ||
62 | +{ | 190 | +{ |
63 | + int el = arm_current_el(env); | 191 | + switch (ap) { |
64 | + | 192 | + case 0: |
65 | + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_AMO)) { | 193 | + return is_user ? 0 : PAGE_READ | PAGE_WRITE; |
66 | + return env->cp15.vdisr_el2; | 194 | + case 1: |
195 | + return PAGE_READ | PAGE_WRITE; | ||
196 | + case 2: | ||
197 | + return is_user ? 0 : PAGE_READ; | ||
198 | + case 3: | ||
199 | + return PAGE_READ; | ||
200 | + default: | ||
201 | + g_assert_not_reached(); | ||
67 | + } | 202 | + } |
68 | + if (el < 3 && (env->cp15.scr_el3 & SCR_EA)) { | ||
69 | + return 0; /* RAZ/WI */ | ||
70 | + } | ||
71 | + return env->cp15.disr_el1; | ||
72 | +} | 203 | +} |
73 | + | 204 | + |
74 | +static void disr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t val) | 205 | +static int simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) |
75 | +{ | 206 | +{ |
76 | + int el = arm_current_el(env); | 207 | + return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); |
77 | + | ||
78 | + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_AMO)) { | ||
79 | + env->cp15.vdisr_el2 = val; | ||
80 | + return; | ||
81 | + } | ||
82 | + if (el < 3 && (env->cp15.scr_el3 & SCR_EA)) { | ||
83 | + return; /* RAZ/WI */ | ||
84 | + } | ||
85 | + env->cp15.disr_el1 = val; | ||
86 | +} | 208 | +} |
87 | + | 209 | + |
88 | +/* | 210 | static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, |
89 | + * Minimal RAS implementation with no Error Records. | 211 | MMUAccessType access_type, ARMMMUIdx mmu_idx, |
90 | + * Which means that all of the Error Record registers: | 212 | hwaddr *phys_ptr, int *prot, |
91 | + * ERXADDR_EL1 | ||
92 | + * ERXCTLR_EL1 | ||
93 | + * ERXFR_EL1 | ||
94 | + * ERXMISC0_EL1 | ||
95 | + * ERXMISC1_EL1 | ||
96 | + * ERXMISC2_EL1 | ||
97 | + * ERXMISC3_EL1 | ||
98 | + * ERXPFGCDN_EL1 (RASv1p1) | ||
99 | + * ERXPFGCTL_EL1 (RASv1p1) | ||
100 | + * ERXPFGF_EL1 (RASv1p1) | ||
101 | + * ERXSTATUS_EL1 | ||
102 | + * and | ||
103 | + * ERRSELR_EL1 | ||
104 | + * may generate UNDEFINED, which is the effect we get by not | ||
105 | + * listing them at all. | ||
106 | + */ | ||
107 | +static const ARMCPRegInfo minimal_ras_reginfo[] = { | ||
108 | + { .name = "DISR_EL1", .state = ARM_CP_STATE_BOTH, | ||
109 | + .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 1, .opc2 = 1, | ||
110 | + .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.disr_el1), | ||
111 | + .readfn = disr_read, .writefn = disr_write, .raw_writefn = raw_write }, | ||
112 | + { .name = "ERRIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
113 | + .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 3, .opc2 = 0, | ||
114 | + .access = PL1_R, .accessfn = access_terr, | ||
115 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
116 | + { .name = "VDISR_EL2", .state = ARM_CP_STATE_BOTH, | ||
117 | + .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 1, .opc2 = 1, | ||
118 | + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vdisr_el2) }, | ||
119 | + { .name = "VSESR_EL2", .state = ARM_CP_STATE_BOTH, | ||
120 | + .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 2, .opc2 = 3, | ||
121 | + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vsesr_el2) }, | ||
122 | +}; | ||
123 | + | ||
124 | /* Return the exception level to which exceptions should be taken | ||
125 | * via SVEAccessTrap. If an exception should be routed through | ||
126 | * AArch64.AdvSIMDFPAccessTrap, return 0; fp_exception_el should | ||
127 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
128 | if (cpu_isar_feature(aa64_ssbs, cpu)) { | ||
129 | define_one_arm_cp_reg(cpu, &ssbs_reginfo); | ||
130 | } | ||
131 | + if (cpu_isar_feature(any_ras, cpu)) { | ||
132 | + define_arm_cp_regs(cpu, minimal_ras_reginfo); | ||
133 | + } | ||
134 | |||
135 | if (cpu_isar_feature(aa64_vh, cpu) || | ||
136 | cpu_isar_feature(aa64_debugv8p2, cpu)) { | ||
137 | -- | 213 | -- |
138 | 2.25.1 | 214 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In aarch64_numa_cpu(), the CPU and NUMA association is something | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | like below. Two threads in the same core/cluster/socket are | 4 | Message-id: 20220604040607.269301-24-richard.henderson@linaro.org |
5 | associated with two individual NUMA nodes, which is unreal as | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Igor Mammedov mentioned. We don't expect the association to break | ||
7 | NUMA-to-socket boundary, which matches with the real world. | ||
8 | |||
9 | NUMA-node socket cluster core thread | ||
10 | ------------------------------------------ | ||
11 | 0 0 0 0 0 | ||
12 | 1 0 0 0 1 | ||
13 | |||
14 | This corrects the topology for CPUs and their association with | ||
15 | NUMA nodes. After this patch is applied, the CPU and NUMA | ||
16 | association becomes something like below, which looks real. | ||
17 | Besides, socket/cluster/core/thread IDs are all checked when | ||
18 | the NUMA node IDs are verified. It helps to check if the CPU | ||
19 | topology is properly populated or not. | ||
20 | |||
21 | NUMA-node socket cluster core thread | ||
22 | ------------------------------------------ | ||
23 | 0 1 0 0 0 | ||
24 | 1 0 0 0 0 | ||
25 | |||
26 | Suggested-by: Igor Mammedov <imammedo@redhat.com> | ||
27 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
28 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
29 | Message-id: 20220503140304.855514-5-gshan@redhat.com | ||
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
31 | --- | 7 | --- |
32 | tests/qtest/numa-test.c | 18 ++++++++++++------ | 8 | target/arm/ptw.h | 1 - |
33 | 1 file changed, 12 insertions(+), 6 deletions(-) | 9 | target/arm/helper.c | 24 ------------------------ |
10 | target/arm/ptw.c | 22 ++++++++++++++++++++++ | ||
11 | 3 files changed, 22 insertions(+), 25 deletions(-) | ||
34 | 12 | ||
35 | diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c | 13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h |
36 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/tests/qtest/numa-test.c | 15 | --- a/target/arm/ptw.h |
38 | +++ b/tests/qtest/numa-test.c | 16 | +++ b/target/arm/ptw.h |
39 | @@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data) | 17 | @@ -XXX,XX +XXX,XX @@ |
40 | g_autofree char *cli = NULL; | 18 | |
41 | 19 | #ifndef CONFIG_USER_ONLY | |
42 | cli = make_cli(data, "-machine " | 20 | |
43 | - "smp.cpus=2,smp.sockets=1,smp.clusters=1,smp.cores=1,smp.threads=2 " | 21 | -bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); |
44 | + "smp.cpus=2,smp.sockets=2,smp.clusters=1,smp.cores=1,smp.threads=1 " | 22 | bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); |
45 | "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 " | 23 | uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); |
46 | - "-numa cpu,node-id=1,thread-id=0 " | 24 | |
47 | - "-numa cpu,node-id=0,thread-id=1"); | 25 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
48 | + "-numa cpu,node-id=0,socket-id=1,cluster-id=0,core-id=0,thread-id=0 " | 26 | index XXXXXXX..XXXXXXX 100644 |
49 | + "-numa cpu,node-id=1,socket-id=0,cluster-id=0,core-id=0,thread-id=0"); | 27 | --- a/target/arm/helper.c |
50 | qts = qtest_init(cli); | 28 | +++ b/target/arm/helper.c |
51 | cpus = get_cpus(qts, &resp); | 29 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) |
52 | g_assert(cpus); | 30 | } |
53 | 31 | #endif /* !CONFIG_USER_ONLY */ | |
54 | while ((e = qlist_pop(cpus))) { | 32 | |
55 | QDict *cpu, *props; | 33 | -#ifndef CONFIG_USER_ONLY |
56 | - int64_t thread, node; | 34 | -bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) |
57 | + int64_t socket, cluster, core, thread, node; | 35 | -{ |
58 | 36 | - switch (mmu_idx) { | |
59 | cpu = qobject_to(QDict, e); | 37 | - case ARMMMUIdx_SE10_0: |
60 | g_assert(qdict_haskey(cpu, "props")); | 38 | - case ARMMMUIdx_E20_0: |
61 | @@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data) | 39 | - case ARMMMUIdx_SE20_0: |
62 | 40 | - case ARMMMUIdx_Stage1_E0: | |
63 | g_assert(qdict_haskey(props, "node-id")); | 41 | - case ARMMMUIdx_Stage1_SE0: |
64 | node = qdict_get_int(props, "node-id"); | 42 | - case ARMMMUIdx_MUser: |
65 | + g_assert(qdict_haskey(props, "socket-id")); | 43 | - case ARMMMUIdx_MSUser: |
66 | + socket = qdict_get_int(props, "socket-id"); | 44 | - case ARMMMUIdx_MUserNegPri: |
67 | + g_assert(qdict_haskey(props, "cluster-id")); | 45 | - case ARMMMUIdx_MSUserNegPri: |
68 | + cluster = qdict_get_int(props, "cluster-id"); | 46 | - return true; |
69 | + g_assert(qdict_haskey(props, "core-id")); | 47 | - default: |
70 | + core = qdict_get_int(props, "core-id"); | 48 | - return false; |
71 | g_assert(qdict_haskey(props, "thread-id")); | 49 | - case ARMMMUIdx_E10_0: |
72 | thread = qdict_get_int(props, "thread-id"); | 50 | - case ARMMMUIdx_E10_1: |
73 | 51 | - case ARMMMUIdx_E10_1_PAN: | |
74 | - if (thread == 0) { | 52 | - g_assert_not_reached(); |
75 | + if (socket == 0 && cluster == 0 && core == 0 && thread == 0) { | 53 | - } |
76 | g_assert_cmpint(node, ==, 1); | 54 | -} |
77 | - } else if (thread == 1) { | 55 | -#endif /* !CONFIG_USER_ONLY */ |
78 | + } else if (socket == 1 && cluster == 0 && core == 0 && thread == 0) { | 56 | - |
79 | g_assert_cmpint(node, ==, 0); | 57 | int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) |
80 | } else { | 58 | { |
81 | g_assert(false); | 59 | if (regime_has_2_ranges(mmu_idx)) { |
60 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/ptw.c | ||
63 | +++ b/target/arm/ptw.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
65 | return (regime_sctlr(env, mmu_idx) & SCTLR_EE) != 0; | ||
66 | } | ||
67 | |||
68 | +static bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
69 | +{ | ||
70 | + switch (mmu_idx) { | ||
71 | + case ARMMMUIdx_SE10_0: | ||
72 | + case ARMMMUIdx_E20_0: | ||
73 | + case ARMMMUIdx_SE20_0: | ||
74 | + case ARMMMUIdx_Stage1_E0: | ||
75 | + case ARMMMUIdx_Stage1_SE0: | ||
76 | + case ARMMMUIdx_MUser: | ||
77 | + case ARMMMUIdx_MSUser: | ||
78 | + case ARMMMUIdx_MUserNegPri: | ||
79 | + case ARMMMUIdx_MSUserNegPri: | ||
80 | + return true; | ||
81 | + default: | ||
82 | + return false; | ||
83 | + case ARMMMUIdx_E10_0: | ||
84 | + case ARMMMUIdx_E10_1: | ||
85 | + case ARMMMUIdx_E10_1_PAN: | ||
86 | + g_assert_not_reached(); | ||
87 | + } | ||
88 | +} | ||
89 | + | ||
90 | static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattrs) | ||
91 | { | ||
92 | /* | ||
82 | -- | 93 | -- |
83 | 2.25.1 | 94 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Currently, the SMP configuration isn't considered when the CPU | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | topology is populated. In this case, it's impossible to provide | 4 | Message-id: 20220604040607.269301-25-richard.henderson@linaro.org |
5 | the default CPU-to-NUMA mapping or association based on the socket | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | ID of the given CPU. | ||
7 | |||
8 | This takes account of SMP configuration when the CPU topology | ||
9 | is populated. The die ID for the given CPU isn't assigned since | ||
10 | it's not supported on arm/virt machine. Besides, the used SMP | ||
11 | configuration in qtest/numa-test/aarch64_numa_cpu() is corrcted | ||
12 | to avoid testing failure | ||
13 | |||
14 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
15 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
16 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
17 | Message-id: 20220503140304.855514-4-gshan@redhat.com | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 7 | --- |
20 | hw/arm/virt.c | 15 ++++++++++++++- | 8 | target/arm/ptw.h | 1 - |
21 | 1 file changed, 14 insertions(+), 1 deletion(-) | 9 | target/arm/helper.c | 16 ---------------- |
10 | target/arm/ptw.c | 16 ++++++++++++++++ | ||
11 | 3 files changed, 16 insertions(+), 17 deletions(-) | ||
22 | 12 | ||
23 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 13 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h |
24 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/arm/virt.c | 15 | --- a/target/arm/ptw.h |
26 | +++ b/hw/arm/virt.c | 16 | +++ b/target/arm/ptw.h |
27 | @@ -XXX,XX +XXX,XX @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) | 17 | @@ -XXX,XX +XXX,XX @@ |
28 | int n; | 18 | #ifndef CONFIG_USER_ONLY |
29 | unsigned int max_cpus = ms->smp.max_cpus; | 19 | |
30 | VirtMachineState *vms = VIRT_MACHINE(ms); | 20 | bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); |
31 | + MachineClass *mc = MACHINE_GET_CLASS(vms); | 21 | -uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); |
32 | 22 | ||
33 | if (ms->possible_cpus) { | 23 | #endif /* !CONFIG_USER_ONLY */ |
34 | assert(ms->possible_cpus->len == max_cpus); | 24 | #endif /* TARGET_ARM_PTW_H */ |
35 | @@ -XXX,XX +XXX,XX @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) | 25 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
36 | ms->possible_cpus->cpus[n].type = ms->cpu_type; | 26 | index XXXXXXX..XXXXXXX 100644 |
37 | ms->possible_cpus->cpus[n].arch_id = | 27 | --- a/target/arm/helper.c |
38 | virt_cpu_mp_affinity(vms, n); | 28 | +++ b/target/arm/helper.c |
29 | @@ -XXX,XX +XXX,XX @@ bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
30 | return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0; | ||
31 | } | ||
32 | |||
33 | -/* Return the TTBR associated with this translation regime */ | ||
34 | -uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) | ||
35 | -{ | ||
36 | - if (mmu_idx == ARMMMUIdx_Stage2) { | ||
37 | - return env->cp15.vttbr_el2; | ||
38 | - } | ||
39 | - if (mmu_idx == ARMMMUIdx_Stage2_S) { | ||
40 | - return env->cp15.vsttbr_el2; | ||
41 | - } | ||
42 | - if (ttbrn == 0) { | ||
43 | - return env->cp15.ttbr0_el[regime_el(env, mmu_idx)]; | ||
44 | - } else { | ||
45 | - return env->cp15.ttbr1_el[regime_el(env, mmu_idx)]; | ||
46 | - } | ||
47 | -} | ||
48 | - | ||
49 | /* Convert a possible stage1+2 MMU index into the appropriate | ||
50 | * stage 1 MMU index | ||
51 | */ | ||
52 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/ptw.c | ||
55 | +++ b/target/arm/ptw.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
57 | } | ||
58 | } | ||
59 | |||
60 | +/* Return the TTBR associated with this translation regime */ | ||
61 | +static uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) | ||
62 | +{ | ||
63 | + if (mmu_idx == ARMMMUIdx_Stage2) { | ||
64 | + return env->cp15.vttbr_el2; | ||
65 | + } | ||
66 | + if (mmu_idx == ARMMMUIdx_Stage2_S) { | ||
67 | + return env->cp15.vsttbr_el2; | ||
68 | + } | ||
69 | + if (ttbrn == 0) { | ||
70 | + return env->cp15.ttbr0_el[regime_el(env, mmu_idx)]; | ||
71 | + } else { | ||
72 | + return env->cp15.ttbr1_el[regime_el(env, mmu_idx)]; | ||
73 | + } | ||
74 | +} | ||
39 | + | 75 | + |
40 | + assert(!mc->smp_props.dies_supported); | 76 | static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattrs) |
41 | + ms->possible_cpus->cpus[n].props.has_socket_id = true; | 77 | { |
42 | + ms->possible_cpus->cpus[n].props.socket_id = | 78 | /* |
43 | + n / (ms->smp.clusters * ms->smp.cores * ms->smp.threads); | ||
44 | + ms->possible_cpus->cpus[n].props.has_cluster_id = true; | ||
45 | + ms->possible_cpus->cpus[n].props.cluster_id = | ||
46 | + (n / (ms->smp.cores * ms->smp.threads)) % ms->smp.clusters; | ||
47 | + ms->possible_cpus->cpus[n].props.has_core_id = true; | ||
48 | + ms->possible_cpus->cpus[n].props.core_id = | ||
49 | + (n / ms->smp.threads) % ms->smp.cores; | ||
50 | ms->possible_cpus->cpus[n].props.has_thread_id = true; | ||
51 | - ms->possible_cpus->cpus[n].props.thread_id = n; | ||
52 | + ms->possible_cpus->cpus[n].props.thread_id = | ||
53 | + n % ms->smp.threads; | ||
54 | } | ||
55 | return ms->possible_cpus; | ||
56 | } | ||
57 | -- | 79 | -- |
58 | 2.25.1 | 80 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When the PPTT table is built, the CPU topology is re-calculated, but | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | it's unecessary because the CPU topology has been populated in | 4 | Message-id: 20220604040607.269301-26-richard.henderson@linaro.org |
5 | virt_possible_cpu_arch_ids() on arm/virt machine. | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | |||
7 | This reworks build_pptt() to avoid by reusing the existing IDs in | ||
8 | ms->possible_cpus. Currently, the only user of build_pptt() is | ||
9 | arm/virt machine. | ||
10 | |||
11 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
12 | Tested-by: Yanan Wang <wangyanan55@huawei.com> | ||
13 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
14 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
15 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | ||
16 | Message-id: 20220503140304.855514-7-gshan@redhat.com | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 7 | --- |
19 | hw/acpi/aml-build.c | 111 +++++++++++++++++++------------------------- | 8 | target/arm/ptw.h | 17 ---------------- |
20 | 1 file changed, 48 insertions(+), 63 deletions(-) | 9 | target/arm/helper.c | 47 --------------------------------------------- |
10 | target/arm/ptw.c | 47 ++++++++++++++++++++++++++++++++++++++++++++- | ||
11 | 3 files changed, 46 insertions(+), 65 deletions(-) | ||
12 | delete mode 100644 target/arm/ptw.h | ||
21 | 13 | ||
22 | diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c | 14 | diff --git a/target/arm/ptw.h b/target/arm/ptw.h |
15 | deleted file mode 100644 | ||
16 | index XXXXXXX..XXXXXXX | ||
17 | --- a/target/arm/ptw.h | ||
18 | +++ /dev/null | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | -/* | ||
21 | - * ARM page table walking. | ||
22 | - * | ||
23 | - * This code is licensed under the GNU GPL v2 or later. | ||
24 | - * | ||
25 | - * SPDX-License-Identifier: GPL-2.0-or-later | ||
26 | - */ | ||
27 | - | ||
28 | -#ifndef TARGET_ARM_PTW_H | ||
29 | -#define TARGET_ARM_PTW_H | ||
30 | - | ||
31 | -#ifndef CONFIG_USER_ONLY | ||
32 | - | ||
33 | -bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
34 | - | ||
35 | -#endif /* !CONFIG_USER_ONLY */ | ||
36 | -#endif /* TARGET_ARM_PTW_H */ | ||
37 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/acpi/aml-build.c | 39 | --- a/target/arm/helper.c |
25 | +++ b/hw/acpi/aml-build.c | 40 | +++ b/target/arm/helper.c |
26 | @@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, | 41 | @@ -XXX,XX +XXX,XX @@ |
27 | const char *oem_id, const char *oem_table_id) | 42 | #include "semihosting/common-semi.h" |
28 | { | 43 | #endif |
29 | MachineClass *mc = MACHINE_GET_CLASS(ms); | 44 | #include "cpregs.h" |
30 | - GQueue *list = g_queue_new(); | 45 | -#include "ptw.h" |
31 | - guint pptt_start = table_data->len; | 46 | |
32 | - guint parent_offset; | 47 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ |
33 | - guint length, i; | 48 | |
34 | - int uid = 0; | 49 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_sctlr(CPUARMState *env, int el) |
35 | - int socket; | 50 | } |
36 | + CPUArchIdList *cpus = ms->possible_cpus; | 51 | |
37 | + int64_t socket_id = -1, cluster_id = -1, core_id = -1; | 52 | #ifndef CONFIG_USER_ONLY |
38 | + uint32_t socket_offset = 0, cluster_offset = 0, core_offset = 0; | 53 | - |
39 | + uint32_t pptt_start = table_data->len; | 54 | -/* Return true if the specified stage of address translation is disabled */ |
40 | + int n; | 55 | -bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx) |
41 | AcpiTable table = { .sig = "PPTT", .rev = 2, | 56 | -{ |
42 | .oem_id = oem_id, .oem_table_id = oem_table_id }; | 57 | - uint64_t hcr_el2; |
43 | 58 | - | |
44 | acpi_table_begin(&table, table_data); | 59 | - if (arm_feature(env, ARM_FEATURE_M)) { |
45 | 60 | - switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] & | |
46 | - for (socket = 0; socket < ms->smp.sockets; socket++) { | 61 | - (R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK)) { |
47 | - g_queue_push_tail(list, | 62 | - case R_V7M_MPU_CTRL_ENABLE_MASK: |
48 | - GUINT_TO_POINTER(table_data->len - pptt_start)); | 63 | - /* Enabled, but not for HardFault and NMI */ |
49 | - build_processor_hierarchy_node( | 64 | - return mmu_idx & ARM_MMU_IDX_M_NEGPRI; |
50 | - table_data, | 65 | - case R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK: |
51 | - /* | 66 | - /* Enabled for all cases */ |
52 | - * Physical package - represents the boundary | 67 | - return false; |
53 | - * of a physical package | 68 | - case 0: |
69 | - default: | ||
70 | - /* HFNMIENA set and ENABLE clear is UNPREDICTABLE, but | ||
71 | - * we warned about that in armv7m_nvic.c when the guest set it. | ||
54 | - */ | 72 | - */ |
55 | - (1 << 0), | 73 | - return true; |
56 | - 0, socket, NULL, 0); | 74 | - } |
57 | - } | 75 | - } |
58 | - | 76 | - |
59 | - if (mc->smp_props.clusters_supported) { | 77 | - hcr_el2 = arm_hcr_el2_eff(env); |
60 | - length = g_queue_get_length(list); | ||
61 | - for (i = 0; i < length; i++) { | ||
62 | - int cluster; | ||
63 | - | 78 | - |
64 | - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | 79 | - if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { |
65 | - for (cluster = 0; cluster < ms->smp.clusters; cluster++) { | 80 | - /* HCR.DC means HCR.VM behaves as 1 */ |
66 | - g_queue_push_tail(list, | 81 | - return (hcr_el2 & (HCR_DC | HCR_VM)) == 0; |
67 | - GUINT_TO_POINTER(table_data->len - pptt_start)); | ||
68 | - build_processor_hierarchy_node( | ||
69 | - table_data, | ||
70 | - (0 << 0), /* not a physical package */ | ||
71 | - parent_offset, cluster, NULL, 0); | ||
72 | - } | ||
73 | + /* | ||
74 | + * This works with the assumption that cpus[n].props.*_id has been | ||
75 | + * sorted from top to down levels in mc->possible_cpu_arch_ids(). | ||
76 | + * Otherwise, the unexpected and duplicated containers will be | ||
77 | + * created. | ||
78 | + */ | ||
79 | + for (n = 0; n < cpus->len; n++) { | ||
80 | + if (cpus->cpus[n].props.socket_id != socket_id) { | ||
81 | + assert(cpus->cpus[n].props.socket_id > socket_id); | ||
82 | + socket_id = cpus->cpus[n].props.socket_id; | ||
83 | + cluster_id = -1; | ||
84 | + core_id = -1; | ||
85 | + socket_offset = table_data->len - pptt_start; | ||
86 | + build_processor_hierarchy_node(table_data, | ||
87 | + (1 << 0), /* Physical package */ | ||
88 | + 0, socket_id, NULL, 0); | ||
89 | } | ||
90 | - } | 82 | - } |
91 | |||
92 | - length = g_queue_get_length(list); | ||
93 | - for (i = 0; i < length; i++) { | ||
94 | - int core; | ||
95 | - | 83 | - |
96 | - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | 84 | - if (hcr_el2 & HCR_TGE) { |
97 | - for (core = 0; core < ms->smp.cores; core++) { | 85 | - /* TGE means that NS EL0/1 act as if SCTLR_EL1.M is zero */ |
98 | - if (ms->smp.threads > 1) { | 86 | - if (!regime_is_secure(env, mmu_idx) && regime_el(env, mmu_idx) == 1) { |
99 | - g_queue_push_tail(list, | 87 | - return true; |
100 | - GUINT_TO_POINTER(table_data->len - pptt_start)); | 88 | - } |
101 | - build_processor_hierarchy_node( | ||
102 | - table_data, | ||
103 | - (0 << 0), /* not a physical package */ | ||
104 | - parent_offset, core, NULL, 0); | ||
105 | - } else { | ||
106 | - build_processor_hierarchy_node( | ||
107 | - table_data, | ||
108 | - (1 << 1) | /* ACPI Processor ID valid */ | ||
109 | - (1 << 3), /* Node is a Leaf */ | ||
110 | - parent_offset, uid++, NULL, 0); | ||
111 | + if (mc->smp_props.clusters_supported) { | ||
112 | + if (cpus->cpus[n].props.cluster_id != cluster_id) { | ||
113 | + assert(cpus->cpus[n].props.cluster_id > cluster_id); | ||
114 | + cluster_id = cpus->cpus[n].props.cluster_id; | ||
115 | + core_id = -1; | ||
116 | + cluster_offset = table_data->len - pptt_start; | ||
117 | + build_processor_hierarchy_node(table_data, | ||
118 | + (0 << 0), /* Not a physical package */ | ||
119 | + socket_offset, cluster_id, NULL, 0); | ||
120 | } | ||
121 | + } else { | ||
122 | + cluster_offset = socket_offset; | ||
123 | } | ||
124 | - } | 89 | - } |
125 | 90 | - | |
126 | - length = g_queue_get_length(list); | 91 | - if ((hcr_el2 & HCR_DC) && arm_mmu_idx_is_stage1_of_2(mmu_idx)) { |
127 | - for (i = 0; i < length; i++) { | 92 | - /* HCR.DC means SCTLR_EL1.M behaves as 0 */ |
128 | - int thread; | 93 | - return true; |
129 | + if (ms->smp.threads == 1) { | 94 | - } |
130 | + build_processor_hierarchy_node(table_data, | 95 | - |
131 | + (1 << 1) | /* ACPI Processor ID valid */ | 96 | - return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0; |
132 | + (1 << 3), /* Node is a Leaf */ | 97 | -} |
133 | + cluster_offset, n, NULL, 0); | 98 | - |
134 | + } else { | 99 | /* Convert a possible stage1+2 MMU index into the appropriate |
135 | + if (cpus->cpus[n].props.core_id != core_id) { | 100 | * stage 1 MMU index |
136 | + assert(cpus->cpus[n].props.core_id > core_id); | 101 | */ |
137 | + core_id = cpus->cpus[n].props.core_id; | 102 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
138 | + core_offset = table_data->len - pptt_start; | 103 | index XXXXXXX..XXXXXXX 100644 |
139 | + build_processor_hierarchy_node(table_data, | 104 | --- a/target/arm/ptw.c |
140 | + (0 << 0), /* Not a physical package */ | 105 | +++ b/target/arm/ptw.c |
141 | + cluster_offset, core_id, NULL, 0); | 106 | @@ -XXX,XX +XXX,XX @@ |
142 | + } | 107 | #include "cpu.h" |
143 | 108 | #include "internals.h" | |
144 | - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | 109 | #include "idau.h" |
145 | - for (thread = 0; thread < ms->smp.threads; thread++) { | 110 | -#include "ptw.h" |
146 | - build_processor_hierarchy_node( | 111 | |
147 | - table_data, | 112 | |
148 | + build_processor_hierarchy_node(table_data, | 113 | static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, |
149 | (1 << 1) | /* ACPI Processor ID valid */ | 114 | @@ -XXX,XX +XXX,XX @@ static uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) |
150 | (1 << 2) | /* Processor is a Thread */ | ||
151 | (1 << 3), /* Node is a Leaf */ | ||
152 | - parent_offset, uid++, NULL, 0); | ||
153 | + core_offset, n, NULL, 0); | ||
154 | } | ||
155 | } | 115 | } |
156 | |||
157 | - g_queue_free(list); | ||
158 | acpi_table_end(linker, &table); | ||
159 | } | 116 | } |
160 | 117 | ||
118 | +/* Return true if the specified stage of address translation is disabled */ | ||
119 | +static bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
120 | +{ | ||
121 | + uint64_t hcr_el2; | ||
122 | + | ||
123 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
124 | + switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] & | ||
125 | + (R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK)) { | ||
126 | + case R_V7M_MPU_CTRL_ENABLE_MASK: | ||
127 | + /* Enabled, but not for HardFault and NMI */ | ||
128 | + return mmu_idx & ARM_MMU_IDX_M_NEGPRI; | ||
129 | + case R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK: | ||
130 | + /* Enabled for all cases */ | ||
131 | + return false; | ||
132 | + case 0: | ||
133 | + default: | ||
134 | + /* | ||
135 | + * HFNMIENA set and ENABLE clear is UNPREDICTABLE, but | ||
136 | + * we warned about that in armv7m_nvic.c when the guest set it. | ||
137 | + */ | ||
138 | + return true; | ||
139 | + } | ||
140 | + } | ||
141 | + | ||
142 | + hcr_el2 = arm_hcr_el2_eff(env); | ||
143 | + | ||
144 | + if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { | ||
145 | + /* HCR.DC means HCR.VM behaves as 1 */ | ||
146 | + return (hcr_el2 & (HCR_DC | HCR_VM)) == 0; | ||
147 | + } | ||
148 | + | ||
149 | + if (hcr_el2 & HCR_TGE) { | ||
150 | + /* TGE means that NS EL0/1 act as if SCTLR_EL1.M is zero */ | ||
151 | + if (!regime_is_secure(env, mmu_idx) && regime_el(env, mmu_idx) == 1) { | ||
152 | + return true; | ||
153 | + } | ||
154 | + } | ||
155 | + | ||
156 | + if ((hcr_el2 & HCR_DC) && arm_mmu_idx_is_stage1_of_2(mmu_idx)) { | ||
157 | + /* HCR.DC means SCTLR_EL1.M behaves as 0 */ | ||
158 | + return true; | ||
159 | + } | ||
160 | + | ||
161 | + return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0; | ||
162 | +} | ||
163 | + | ||
164 | static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattrs) | ||
165 | { | ||
166 | /* | ||
161 | -- | 167 | -- |
162 | 2.25.1 | 168 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Leif Lindholm <quic_llindhol@quicinc.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The sbsa-ref machine is continuously evolving. Some of the changes we | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | want to make in the near future, to align with real components (e.g. | 4 | Message-id: 20220604040607.269301-27-richard.henderson@linaro.org |
5 | the GIC-700), will break compatibility for existing firmware. | ||
6 | |||
7 | Introduce two new properties to the DT generated on machine generation: | ||
8 | - machine-version-major | ||
9 | To be incremented when a platform change makes the machine | ||
10 | incompatible with existing firmware. | ||
11 | - machine-version-minor | ||
12 | To be incremented when functionality is added to the machine | ||
13 | without causing incompatibility with existing firmware. | ||
14 | to be reset to 0 when machine-version-major is incremented. | ||
15 | |||
16 | This versioning scheme is *neither*: | ||
17 | - A QEMU versioned machine type; a given version of QEMU will emulate | ||
18 | a given version of the platform. | ||
19 | - A reflection of level of SBSA (now SystemReady SR) support provided. | ||
20 | |||
21 | The version will increment on guest-visible functional changes only, | ||
22 | akin to a revision ID register found on a physical platform. | ||
23 | |||
24 | These properties are both introduced with the value 0. | ||
25 | (Hence, a machine where the DT is lacking these nodes is equivalent | ||
26 | to version 0.0.) | ||
27 | |||
28 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> | ||
29 | Message-id: 20220505113947.75714-1-quic_llindhol@quicinc.com | ||
30 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
31 | Cc: Radoslaw Biernacki <rad@semihalf.com> | ||
32 | Cc: Cédric Le Goater <clg@kaod.org> | ||
33 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
34 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
35 | --- | 7 | --- |
36 | hw/arm/sbsa-ref.c | 14 ++++++++++++++ | 8 | target/arm/helper.c | 26 -------------------------- |
37 | 1 file changed, 14 insertions(+) | 9 | target/arm/ptw.c | 24 ++++++++++++++++++++++++ |
10 | 2 files changed, 24 insertions(+), 26 deletions(-) | ||
38 | 11 | ||
39 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | 12 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
40 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/hw/arm/sbsa-ref.c | 14 | --- a/target/arm/helper.c |
42 | +++ b/hw/arm/sbsa-ref.c | 15 | +++ b/target/arm/helper.c |
43 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms) | 16 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, |
44 | qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2); | 17 | }; |
45 | qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2); | 18 | } |
46 | 19 | ||
47 | + /* | 20 | -#ifndef CONFIG_USER_ONLY |
48 | + * This versioning scheme is for informing platform fw only. It is neither: | 21 | -hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, |
49 | + * - A QEMU versioned machine type; a given version of QEMU will emulate | 22 | - MemTxAttrs *attrs) |
50 | + * a given version of the platform. | 23 | -{ |
51 | + * - A reflection of level of SBSA (now SystemReady SR) support provided. | 24 | - ARMCPU *cpu = ARM_CPU(cs); |
52 | + * | 25 | - CPUARMState *env = &cpu->env; |
53 | + * machine-version-major: updated when changes breaking fw compatibility | 26 | - hwaddr phys_addr; |
54 | + * are introduced. | 27 | - target_ulong page_size; |
55 | + * machine-version-minor: updated when features are added that don't break | 28 | - int prot; |
56 | + * fw compatibility. | 29 | - bool ret; |
57 | + */ | 30 | - ARMMMUFaultInfo fi = {}; |
58 | + qemu_fdt_setprop_cell(fdt, "/", "machine-version-major", 0); | 31 | - ARMMMUIdx mmu_idx = arm_mmu_idx(env); |
59 | + qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 0); | 32 | - ARMCacheAttrs cacheattrs = {}; |
33 | - | ||
34 | - *attrs = (MemTxAttrs) {}; | ||
35 | - | ||
36 | - ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &phys_addr, | ||
37 | - attrs, &prot, &page_size, &fi, &cacheattrs); | ||
38 | - | ||
39 | - if (ret) { | ||
40 | - return -1; | ||
41 | - } | ||
42 | - return phys_addr; | ||
43 | -} | ||
44 | -#endif | ||
45 | - | ||
46 | /* Note that signed overflow is undefined in C. The following routines are | ||
47 | careful to use unsigned types where modulo arithmetic is required. | ||
48 | Failure to do so _will_ break on newer gcc. */ | ||
49 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/ptw.c | ||
52 | +++ b/target/arm/ptw.c | ||
53 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
54 | phys_ptr, prot, page_size, fi); | ||
55 | } | ||
56 | } | ||
60 | + | 57 | + |
61 | if (ms->numa_state->have_numa_distance) { | 58 | +hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, |
62 | int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); | 59 | + MemTxAttrs *attrs) |
63 | uint32_t *matrix = g_malloc0(size); | 60 | +{ |
61 | + ARMCPU *cpu = ARM_CPU(cs); | ||
62 | + CPUARMState *env = &cpu->env; | ||
63 | + hwaddr phys_addr; | ||
64 | + target_ulong page_size; | ||
65 | + int prot; | ||
66 | + bool ret; | ||
67 | + ARMMMUFaultInfo fi = {}; | ||
68 | + ARMMMUIdx mmu_idx = arm_mmu_idx(env); | ||
69 | + ARMCacheAttrs cacheattrs = {}; | ||
70 | + | ||
71 | + *attrs = (MemTxAttrs) {}; | ||
72 | + | ||
73 | + ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &phys_addr, | ||
74 | + attrs, &prot, &page_size, &fi, &cacheattrs); | ||
75 | + | ||
76 | + if (ret) { | ||
77 | + return -1; | ||
78 | + } | ||
79 | + return phys_addr; | ||
80 | +} | ||
64 | -- | 81 | -- |
65 | 2.25.1 | 82 | 2.25.1 |
66 | |||
67 | diff view generated by jsdifflib |
1 | From: Leif Lindholm <quic_llindhol@quicinc.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | NUVIA was acquired by Qualcomm in March 2021, but kept functioning on | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | separate infrastructure for a transitional period. We've now switched | 4 | Message-id: 20220604040607.269301-28-richard.henderson@linaro.org |
5 | over to contributing as Qualcomm Innovation Center (quicinc), so update | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | my email address to reflect this. | ||
7 | |||
8 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> | ||
9 | Message-id: 20220505113740.75565-1-quic_llindhol@quicinc.com | ||
10 | Cc: Leif Lindholm <leif@nuviainc.com> | ||
11 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | [Fixed commit message typo] | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 7 | --- |
16 | .mailmap | 3 ++- | 8 | target/arm/helper.c | 32 -------------------------------- |
17 | MAINTAINERS | 2 +- | 9 | target/arm/ptw.c | 28 ++++++++++++++++++++++++++++ |
18 | 2 files changed, 3 insertions(+), 2 deletions(-) | 10 | 2 files changed, 28 insertions(+), 32 deletions(-) |
19 | 11 | ||
20 | diff --git a/.mailmap b/.mailmap | 12 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/.mailmap | 14 | --- a/target/arm/helper.c |
23 | +++ b/.mailmap | 15 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ Greg Kurz <groug@kaod.org> <gkurz@linux.vnet.ibm.com> | 16 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_sctlr(CPUARMState *env, int el) |
25 | Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com> | 17 | return env->cp15.sctlr_el[el]; |
26 | Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn> | 18 | } |
27 | James Hogan <jhogan@kernel.org> <james.hogan@imgtec.com> | 19 | |
28 | -Leif Lindholm <leif@nuviainc.com> <leif.lindholm@linaro.org> | 20 | -#ifndef CONFIG_USER_ONLY |
29 | +Leif Lindholm <quic_llindhol@quicinc.com> <leif.lindholm@linaro.org> | 21 | -/* Convert a possible stage1+2 MMU index into the appropriate |
30 | +Leif Lindholm <quic_llindhol@quicinc.com> <leif@nuviainc.com> | 22 | - * stage 1 MMU index |
31 | Radoslaw Biernacki <rad@semihalf.com> <radoslaw.biernacki@linaro.org> | 23 | - */ |
32 | Paul Burton <paulburton@kernel.org> <paul.burton@mips.com> | 24 | -ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) |
33 | Paul Burton <paulburton@kernel.org> <paul.burton@imgtec.com> | 25 | -{ |
34 | diff --git a/MAINTAINERS b/MAINTAINERS | 26 | - switch (mmu_idx) { |
27 | - case ARMMMUIdx_SE10_0: | ||
28 | - return ARMMMUIdx_Stage1_SE0; | ||
29 | - case ARMMMUIdx_SE10_1: | ||
30 | - return ARMMMUIdx_Stage1_SE1; | ||
31 | - case ARMMMUIdx_SE10_1_PAN: | ||
32 | - return ARMMMUIdx_Stage1_SE1_PAN; | ||
33 | - case ARMMMUIdx_E10_0: | ||
34 | - return ARMMMUIdx_Stage1_E0; | ||
35 | - case ARMMMUIdx_E10_1: | ||
36 | - return ARMMMUIdx_Stage1_E1; | ||
37 | - case ARMMMUIdx_E10_1_PAN: | ||
38 | - return ARMMMUIdx_Stage1_E1_PAN; | ||
39 | - default: | ||
40 | - return mmu_idx; | ||
41 | - } | ||
42 | -} | ||
43 | -#endif /* !CONFIG_USER_ONLY */ | ||
44 | - | ||
45 | int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) | ||
46 | { | ||
47 | if (regime_has_2_ranges(mmu_idx)) { | ||
48 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env) | ||
49 | return arm_mmu_idx_el(env, arm_current_el(env)); | ||
50 | } | ||
51 | |||
52 | -#ifndef CONFIG_USER_ONLY | ||
53 | -ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | ||
54 | -{ | ||
55 | - return stage_1_mmu_idx(arm_mmu_idx(env)); | ||
56 | -} | ||
57 | -#endif | ||
58 | - | ||
59 | static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el, | ||
60 | ARMMMUIdx mmu_idx, | ||
61 | CPUARMTBFlags flags) | ||
62 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | 63 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/MAINTAINERS | 64 | --- a/target/arm/ptw.c |
37 | +++ b/MAINTAINERS | 65 | +++ b/target/arm/ptw.c |
38 | @@ -XXX,XX +XXX,XX @@ F: include/hw/ssi/imx_spi.h | 66 | @@ -XXX,XX +XXX,XX @@ unsigned int arm_pamax(ARMCPU *cpu) |
39 | SBSA-REF | 67 | return pamax_map[parange]; |
40 | M: Radoslaw Biernacki <rad@semihalf.com> | 68 | } |
41 | M: Peter Maydell <peter.maydell@linaro.org> | 69 | |
42 | -R: Leif Lindholm <leif@nuviainc.com> | 70 | +/* |
43 | +R: Leif Lindholm <quic_llindhol@quicinc.com> | 71 | + * Convert a possible stage1+2 MMU index into the appropriate stage 1 MMU index |
44 | L: qemu-arm@nongnu.org | 72 | + */ |
45 | S: Maintained | 73 | +ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) |
46 | F: hw/arm/sbsa-ref.c | 74 | +{ |
75 | + switch (mmu_idx) { | ||
76 | + case ARMMMUIdx_SE10_0: | ||
77 | + return ARMMMUIdx_Stage1_SE0; | ||
78 | + case ARMMMUIdx_SE10_1: | ||
79 | + return ARMMMUIdx_Stage1_SE1; | ||
80 | + case ARMMMUIdx_SE10_1_PAN: | ||
81 | + return ARMMMUIdx_Stage1_SE1_PAN; | ||
82 | + case ARMMMUIdx_E10_0: | ||
83 | + return ARMMMUIdx_Stage1_E0; | ||
84 | + case ARMMMUIdx_E10_1: | ||
85 | + return ARMMMUIdx_Stage1_E1; | ||
86 | + case ARMMMUIdx_E10_1_PAN: | ||
87 | + return ARMMMUIdx_Stage1_E1_PAN; | ||
88 | + default: | ||
89 | + return mmu_idx; | ||
90 | + } | ||
91 | +} | ||
92 | + | ||
93 | +ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | ||
94 | +{ | ||
95 | + return stage_1_mmu_idx(arm_mmu_idx(env)); | ||
96 | +} | ||
97 | + | ||
98 | static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
99 | { | ||
100 | return (regime_sctlr(env, mmu_idx) & SCTLR_EE) != 0; | ||
47 | -- | 101 | -- |
48 | 2.25.1 | 102 | 2.25.1 |
49 | |||
50 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When CPU-to-NUMA association isn't explicitly provided by users, | 3 | The use of ARM_CPU to recover env from cs calls |
4 | the default one is given by mc->get_default_cpu_node_id(). However, | 4 | object_class_dynamic_cast, which shows up on the profile. |
5 | the CPU topology isn't fully considered in the default association | 5 | This is pointless, because all callers already have env, and |
6 | and this causes CPU topology broken warnings on booting Linux guest. | 6 | the reverse operation, env_cpu, is only pointer arithmetic. |
7 | 7 | ||
8 | For example, the following warning messages are observed when the | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Linux guest is booted with the following command lines. | 9 | Message-id: 20220604040607.269301-29-richard.henderson@linaro.org |
10 | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | |
11 | /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ | ||
12 | -accel kvm -machine virt,gic-version=host \ | ||
13 | -cpu host \ | ||
14 | -smp 6,sockets=2,cores=3,threads=1 \ | ||
15 | -m 1024M,slots=16,maxmem=64G \ | ||
16 | -object memory-backend-ram,id=mem0,size=128M \ | ||
17 | -object memory-backend-ram,id=mem1,size=128M \ | ||
18 | -object memory-backend-ram,id=mem2,size=128M \ | ||
19 | -object memory-backend-ram,id=mem3,size=128M \ | ||
20 | -object memory-backend-ram,id=mem4,size=128M \ | ||
21 | -object memory-backend-ram,id=mem4,size=384M \ | ||
22 | -numa node,nodeid=0,memdev=mem0 \ | ||
23 | -numa node,nodeid=1,memdev=mem1 \ | ||
24 | -numa node,nodeid=2,memdev=mem2 \ | ||
25 | -numa node,nodeid=3,memdev=mem3 \ | ||
26 | -numa node,nodeid=4,memdev=mem4 \ | ||
27 | -numa node,nodeid=5,memdev=mem5 | ||
28 | : | ||
29 | alternatives: patching kernel code | ||
30 | BUG: arch topology borken | ||
31 | the CLS domain not a subset of the MC domain | ||
32 | <the above error log repeats> | ||
33 | BUG: arch topology borken | ||
34 | the DIE domain not a subset of the NODE domain | ||
35 | |||
36 | With current implementation of mc->get_default_cpu_node_id(), | ||
37 | CPU#0 to CPU#5 are associated with NODE#0 to NODE#5 separately. | ||
38 | That's incorrect because CPU#0/1/2 should be associated with same | ||
39 | NUMA node because they're seated in same socket. | ||
40 | |||
41 | This fixes the issue by considering the socket ID when the default | ||
42 | CPU-to-NUMA association is provided in virt_possible_cpu_arch_ids(). | ||
43 | With this applied, no more CPU topology broken warnings are seen | ||
44 | from the Linux guest. The 6 CPUs are associated with NODE#0/1, but | ||
45 | there are no CPUs associated with NODE#2/3/4/5. | ||
46 | |||
47 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
48 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
49 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
50 | Message-id: 20220503140304.855514-6-gshan@redhat.com | ||
51 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
52 | --- | 12 | --- |
53 | hw/arm/virt.c | 4 +++- | 13 | target/arm/ptw.c | 23 +++++++++-------------- |
54 | 1 file changed, 3 insertions(+), 1 deletion(-) | 14 | 1 file changed, 9 insertions(+), 14 deletions(-) |
55 | 15 | ||
56 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 16 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
57 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
58 | --- a/hw/arm/virt.c | 18 | --- a/target/arm/ptw.c |
59 | +++ b/hw/arm/virt.c | 19 | +++ b/target/arm/ptw.c |
60 | @@ -XXX,XX +XXX,XX @@ virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) | 20 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, |
61 | 21 | } | |
62 | static int64_t virt_get_default_cpu_node_id(const MachineState *ms, int idx) | 22 | |
23 | /* All loads done in the course of a page table walk go through here. */ | ||
24 | -static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
25 | +static uint32_t arm_ldl_ptw(CPUARMState *env, hwaddr addr, bool is_secure, | ||
26 | ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) | ||
63 | { | 27 | { |
64 | - return idx % ms->numa_state->num_nodes; | 28 | - ARMCPU *cpu = ARM_CPU(cs); |
65 | + int64_t socket_id = ms->possible_cpus->cpus[idx].props.socket_id; | 29 | - CPUARMState *env = &cpu->env; |
66 | + | 30 | + CPUState *cs = env_cpu(env); |
67 | + return socket_id % ms->numa_state->num_nodes; | 31 | MemTxAttrs attrs = {}; |
32 | MemTxResult result = MEMTX_OK; | ||
33 | AddressSpace *as; | ||
34 | @@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, | ||
35 | return 0; | ||
68 | } | 36 | } |
69 | 37 | ||
70 | static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) | 38 | -static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, |
39 | +static uint64_t arm_ldq_ptw(CPUARMState *env, hwaddr addr, bool is_secure, | ||
40 | ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) | ||
41 | { | ||
42 | - ARMCPU *cpu = ARM_CPU(cs); | ||
43 | - CPUARMState *env = &cpu->env; | ||
44 | + CPUState *cs = env_cpu(env); | ||
45 | MemTxAttrs attrs = {}; | ||
46 | MemTxResult result = MEMTX_OK; | ||
47 | AddressSpace *as; | ||
48 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
49 | target_ulong *page_size, | ||
50 | ARMMMUFaultInfo *fi) | ||
51 | { | ||
52 | - CPUState *cs = env_cpu(env); | ||
53 | int level = 1; | ||
54 | uint32_t table; | ||
55 | uint32_t desc; | ||
56 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
57 | fi->type = ARMFault_Translation; | ||
58 | goto do_fault; | ||
59 | } | ||
60 | - desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
61 | + desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), | ||
62 | mmu_idx, fi); | ||
63 | if (fi->type != ARMFault_None) { | ||
64 | goto do_fault; | ||
65 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
66 | /* Fine pagetable. */ | ||
67 | table = (desc & 0xfffff000) | ((address >> 8) & 0xffc); | ||
68 | } | ||
69 | - desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
70 | + desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), | ||
71 | mmu_idx, fi); | ||
72 | if (fi->type != ARMFault_None) { | ||
73 | goto do_fault; | ||
74 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
75 | hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
76 | target_ulong *page_size, ARMMMUFaultInfo *fi) | ||
77 | { | ||
78 | - CPUState *cs = env_cpu(env); | ||
79 | ARMCPU *cpu = env_archcpu(env); | ||
80 | int level = 1; | ||
81 | uint32_t table; | ||
82 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
83 | fi->type = ARMFault_Translation; | ||
84 | goto do_fault; | ||
85 | } | ||
86 | - desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
87 | + desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), | ||
88 | mmu_idx, fi); | ||
89 | if (fi->type != ARMFault_None) { | ||
90 | goto do_fault; | ||
91 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
92 | ns = extract32(desc, 3, 1); | ||
93 | /* Lookup l2 entry. */ | ||
94 | table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); | ||
95 | - desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), | ||
96 | + desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), | ||
97 | mmu_idx, fi); | ||
98 | if (fi->type != ARMFault_None) { | ||
99 | goto do_fault; | ||
100 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
101 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
102 | { | ||
103 | ARMCPU *cpu = env_archcpu(env); | ||
104 | - CPUState *cs = CPU(cpu); | ||
105 | /* Read an LPAE long-descriptor translation table. */ | ||
106 | ARMFaultType fault_type = ARMFault_Translation; | ||
107 | uint32_t level; | ||
108 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
109 | descaddr |= (address >> (stride * (4 - level))) & indexmask; | ||
110 | descaddr &= ~7ULL; | ||
111 | nstable = extract32(tableattrs, 4, 1); | ||
112 | - descriptor = arm_ldq_ptw(cs, descaddr, !nstable, mmu_idx, fi); | ||
113 | + descriptor = arm_ldq_ptw(env, descaddr, !nstable, mmu_idx, fi); | ||
114 | if (fi->type != ARMFault_None) { | ||
115 | goto do_fault; | ||
116 | } | ||
71 | -- | 117 | -- |
72 | 2.25.1 | 118 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This extension concerns not merging memory access, which TCG does | 3 | With SME, the vector length does not only come from ZCR_ELx. |
4 | not implement. Thus we can trivially enable this feature. | 4 | Comment that this is either NVL or SVL, like the pseudocode. |
5 | Add a comment to handle_hint for the DGH instruction, but no code. | ||
6 | 5 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20220506180242.216785-23-richard.henderson@linaro.org | 8 | Message-id: 20220607203306.657998-2-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 | docs/system/arm/emulation.rst | 1 + | 11 | target/arm/cpu.h | 3 ++- |
13 | target/arm/cpu64.c | 1 + | 12 | target/arm/translate-a64.h | 2 +- |
14 | target/arm/translate-a64.c | 1 + | 13 | target/arm/translate.h | 2 +- |
15 | 3 files changed, 3 insertions(+) | 14 | target/arm/helper.c | 2 +- |
15 | target/arm/translate-a64.c | 2 +- | ||
16 | target/arm/translate-sve.c | 2 +- | ||
17 | 6 files changed, 7 insertions(+), 6 deletions(-) | ||
16 | 18 | ||
17 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
18 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/docs/system/arm/emulation.rst | 21 | --- a/target/arm/cpu.h |
20 | +++ b/docs/system/arm/emulation.rst | 22 | +++ b/target/arm/cpu.h |
21 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 23 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_M32, MVE_NO_PRED, 5, 1) /* Not cached. */ |
22 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) | 24 | */ |
23 | - FEAT_CSV2_2 (Cache speculation variant 2, version 2) | 25 | FIELD(TBFLAG_A64, TBII, 0, 2) |
24 | - FEAT_CSV3 (Cache speculation variant 3) | 26 | FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) |
25 | +- FEAT_DGH (Data gathering hint) | 27 | -FIELD(TBFLAG_A64, ZCR_LEN, 4, 4) |
26 | - FEAT_DIT (Data Independent Timing instructions) | 28 | +/* The current vector length, either NVL or SVL. */ |
27 | - FEAT_DPB (DC CVAP instruction) | 29 | +FIELD(TBFLAG_A64, VL, 4, 4) |
28 | - FEAT_Debugv8p2 (Debug changes for v8.2) | 30 | FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1) |
29 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 31 | FIELD(TBFLAG_A64, BT, 9, 1) |
32 | FIELD(TBFLAG_A64, BTYPE, 10, 2) /* Not cached. */ | ||
33 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/arm/cpu64.c | 35 | --- a/target/arm/translate-a64.h |
32 | +++ b/target/arm/cpu64.c | 36 | +++ b/target/arm/translate-a64.h |
33 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 37 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_ptr vec_full_reg_ptr(DisasContext *s, int regno) |
34 | t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); /* FEAT_SB */ | 38 | /* Return the byte size of the "whole" vector register, VL / 8. */ |
35 | t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); /* FEAT_SPECRES */ | 39 | static inline int vec_full_reg_size(DisasContext *s) |
36 | t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); /* FEAT_BF16 */ | 40 | { |
37 | + t = FIELD_DP64(t, ID_AA64ISAR1, DGH, 1); /* FEAT_DGH */ | 41 | - return s->sve_len; |
38 | t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); /* FEAT_I8MM */ | 42 | + return s->vl; |
39 | cpu->isar.id_aa64isar1 = t; | 43 | } |
40 | 44 | ||
45 | bool disas_sve(DisasContext *, uint32_t); | ||
46 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/translate.h | ||
49 | +++ b/target/arm/translate.h | ||
50 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
51 | bool ns; /* Use non-secure CPREG bank on access */ | ||
52 | int fp_excp_el; /* FP exception EL or 0 if enabled */ | ||
53 | int sve_excp_el; /* SVE exception EL or 0 if enabled */ | ||
54 | - int sve_len; /* SVE vector length in bytes */ | ||
55 | + int vl; /* current vector length in bytes */ | ||
56 | /* Flag indicating that exceptions from secure mode are routed to EL3. */ | ||
57 | bool secure_routed_to_el3; | ||
58 | bool vfp_enabled; /* FP enabled via FPSCR.EN */ | ||
59 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/arm/helper.c | ||
62 | +++ b/target/arm/helper.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
64 | zcr_len = sve_zcr_len_for_el(env, el); | ||
65 | } | ||
66 | DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); | ||
67 | - DP_TBFLAG_A64(flags, ZCR_LEN, zcr_len); | ||
68 | + DP_TBFLAG_A64(flags, VL, zcr_len); | ||
69 | } | ||
70 | |||
71 | sctlr = regime_sctlr(env, stage1); | ||
41 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 72 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
42 | index XXXXXXX..XXXXXXX 100644 | 73 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/target/arm/translate-a64.c | 74 | --- a/target/arm/translate-a64.c |
44 | +++ b/target/arm/translate-a64.c | 75 | +++ b/target/arm/translate-a64.c |
45 | @@ -XXX,XX +XXX,XX @@ static void handle_hint(DisasContext *s, uint32_t insn, | 76 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, |
46 | break; | 77 | dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); |
47 | case 0b00100: /* SEV */ | 78 | dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL); |
48 | case 0b00101: /* SEVL */ | 79 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); |
49 | + case 0b00110: /* DGH */ | 80 | - dc->sve_len = (EX_TBFLAG_A64(tb_flags, ZCR_LEN) + 1) * 16; |
50 | /* we treat all as NOP at least for now */ | 81 | + dc->vl = (EX_TBFLAG_A64(tb_flags, VL) + 1) * 16; |
51 | break; | 82 | dc->pauth_active = EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); |
52 | case 0b00111: /* XPACLRI */ | 83 | dc->bt = EX_TBFLAG_A64(tb_flags, BT); |
84 | dc->btype = EX_TBFLAG_A64(tb_flags, BTYPE); | ||
85 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/target/arm/translate-sve.c | ||
88 | +++ b/target/arm/translate-sve.c | ||
89 | @@ -XXX,XX +XXX,XX @@ static inline int pred_full_reg_offset(DisasContext *s, int regno) | ||
90 | /* Return the byte size of the whole predicate register, VL / 64. */ | ||
91 | static inline int pred_full_reg_size(DisasContext *s) | ||
92 | { | ||
93 | - return s->sve_len >> 3; | ||
94 | + return s->vl >> 3; | ||
95 | } | ||
96 | |||
97 | /* Round up the size of a register to a size allowed by | ||
53 | -- | 98 | -- |
54 | 2.25.1 | 99 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This extension concerns branch speculation, which TCG does | 3 | Add an interface function to extract the digested vector length |
4 | not implement. Thus we can trivially enable this feature. | 4 | rather than the raw zcr_el[1] value. This fixes an incorrect |
5 | return from do_prctl_set_vl where we didn't take into account | ||
6 | the set of vector lengths supported by the cpu. | ||
5 | 7 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220506180242.216785-20-richard.henderson@linaro.org | 10 | Message-id: 20220607203306.657998-3-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | docs/system/arm/emulation.rst | 1 + | 13 | linux-user/aarch64/target_prctl.h | 20 +++++++++++++------- |
12 | target/arm/cpu64.c | 1 + | 14 | target/arm/cpu.h | 11 +++++++++++ |
13 | target/arm/cpu_tcg.c | 1 + | 15 | linux-user/aarch64/signal.c | 4 ++-- |
14 | 3 files changed, 3 insertions(+) | 16 | 3 files changed, 26 insertions(+), 9 deletions(-) |
15 | 17 | ||
16 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 18 | diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/docs/system/arm/emulation.rst | 20 | --- a/linux-user/aarch64/target_prctl.h |
19 | +++ b/docs/system/arm/emulation.rst | 21 | +++ b/linux-user/aarch64/target_prctl.h |
20 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 22 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_get_vl(CPUArchState *env) |
21 | - FEAT_BBM at level 2 (Translation table break-before-make levels) | 23 | { |
22 | - FEAT_BF16 (AArch64 BFloat16 instructions) | 24 | ARMCPU *cpu = env_archcpu(env); |
23 | - FEAT_BTI (Branch Target Identification) | 25 | if (cpu_isar_feature(aa64_sve, cpu)) { |
24 | +- FEAT_CSV2 (Cache speculation variant 2) | 26 | - return ((cpu->env.vfp.zcr_el[1] & 0xf) + 1) * 16; |
25 | - FEAT_DIT (Data Independent Timing instructions) | 27 | + return sve_vq(env) * 16; |
26 | - FEAT_DPB (DC CVAP instruction) | 28 | } |
27 | - FEAT_Debugv8p2 (Debug changes for v8.2) | 29 | return -TARGET_EINVAL; |
28 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 30 | } |
31 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_set_vl(CPUArchState *env, abi_long arg2) | ||
32 | */ | ||
33 | if (cpu_isar_feature(aa64_sve, env_archcpu(env)) | ||
34 | && arg2 >= 0 && arg2 <= 512 * 16 && !(arg2 & 15)) { | ||
35 | - ARMCPU *cpu = env_archcpu(env); | ||
36 | uint32_t vq, old_vq; | ||
37 | |||
38 | - old_vq = (env->vfp.zcr_el[1] & 0xf) + 1; | ||
39 | - vq = MAX(arg2 / 16, 1); | ||
40 | - vq = MIN(vq, cpu->sve_max_vq); | ||
41 | + old_vq = sve_vq(env); | ||
42 | |||
43 | + /* | ||
44 | + * Bound the value of arg2, so that we know that it fits into | ||
45 | + * the 4-bit field in ZCR_EL1. Rely on the hflags rebuild to | ||
46 | + * sort out the length supported by the cpu. | ||
47 | + */ | ||
48 | + vq = MAX(arg2 / 16, 1); | ||
49 | + vq = MIN(vq, ARM_MAX_VQ); | ||
50 | + env->vfp.zcr_el[1] = vq - 1; | ||
51 | + arm_rebuild_hflags(env); | ||
52 | + | ||
53 | + vq = sve_vq(env); | ||
54 | if (vq < old_vq) { | ||
55 | aarch64_sve_narrow_vq(env, vq); | ||
56 | } | ||
57 | - env->vfp.zcr_el[1] = vq - 1; | ||
58 | - arm_rebuild_hflags(env); | ||
59 | return vq * 16; | ||
60 | } | ||
61 | return -TARGET_EINVAL; | ||
62 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
29 | index XXXXXXX..XXXXXXX 100644 | 63 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/cpu64.c | 64 | --- a/target/arm/cpu.h |
31 | +++ b/target/arm/cpu64.c | 65 | +++ b/target/arm/cpu.h |
32 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 66 | @@ -XXX,XX +XXX,XX @@ static inline int cpu_mmu_index(CPUARMState *env, bool ifetch) |
33 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | 67 | return EX_TBFLAG_ANY(env->hflags, MMUIDX); |
34 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ | 68 | } |
35 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ | 69 | |
36 | + t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 1); /* FEAT_CSV2 */ | 70 | +/** |
37 | cpu->isar.id_aa64pfr0 = t; | 71 | + * sve_vq |
38 | 72 | + * @env: the cpu context | |
39 | t = cpu->isar.id_aa64pfr1; | 73 | + * |
40 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 74 | + * Return the VL cached within env->hflags, in units of quadwords. |
75 | + */ | ||
76 | +static inline int sve_vq(CPUARMState *env) | ||
77 | +{ | ||
78 | + return EX_TBFLAG_A64(env->hflags, VL) + 1; | ||
79 | +} | ||
80 | + | ||
81 | static inline bool bswap_code(bool sctlr_b) | ||
82 | { | ||
83 | #ifdef CONFIG_USER_ONLY | ||
84 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | 85 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/target/arm/cpu_tcg.c | 86 | --- a/linux-user/aarch64/signal.c |
43 | +++ b/target/arm/cpu_tcg.c | 87 | +++ b/linux-user/aarch64/signal.c |
44 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | 88 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, |
45 | cpu->isar.id_mmfr4 = t; | 89 | |
46 | 90 | case TARGET_SVE_MAGIC: | |
47 | t = cpu->isar.id_pfr0; | 91 | if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { |
48 | + t = FIELD_DP32(t, ID_PFR0, CSV2, 2); /* FEAT_CVS2 */ | 92 | - vq = (env->vfp.zcr_el[1] & 0xf) + 1; |
49 | t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */ | 93 | + vq = sve_vq(env); |
50 | t = FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */ | 94 | sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16); |
51 | cpu->isar.id_pfr0 = t; | 95 | if (!sve && size == sve_size) { |
96 | sve = (struct target_sve_context *)ctx; | ||
97 | @@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka, | ||
98 | |||
99 | /* SVE state needs saving only if it exists. */ | ||
100 | if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { | ||
101 | - vq = (env->vfp.zcr_el[1] & 0xf) + 1; | ||
102 | + vq = sve_vq(env); | ||
103 | sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16); | ||
104 | sve_ofs = alloc_sigframe_space(sve_size, &layout); | ||
105 | } | ||
52 | -- | 106 | -- |
53 | 2.25.1 | 107 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This feature is AArch64 only, and applies to physical SErrors, | 3 | We handle this routing in raise_exception. Promoting the value early |
4 | which QEMU does not implement, thus the feature is a nop. | 4 | means that we can't directly compare FPEXC_EL and SVEEXC_EL. |
5 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220506180242.216785-19-richard.henderson@linaro.org | 8 | Message-id: 20220607203306.657998-4-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | docs/system/arm/emulation.rst | 1 + | 11 | target/arm/helper.c | 3 +-- |
12 | target/arm/cpu64.c | 1 + | 12 | 1 file changed, 1 insertion(+), 2 deletions(-) |
13 | 2 files changed, 2 insertions(+) | ||
14 | 13 | ||
15 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/docs/system/arm/emulation.rst | 16 | --- a/target/arm/helper.c |
18 | +++ b/docs/system/arm/emulation.rst | 17 | +++ b/target/arm/helper.c |
19 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 18 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) |
20 | - FEAT_FlagM2 (Enhancements to flag manipulation instructions) | 19 | /* fall through */ |
21 | - FEAT_HPDS (Hierarchical permission disables) | 20 | case 0: |
22 | - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) | 21 | case 2: |
23 | +- FEAT_IESB (Implicit error synchronization event) | 22 | - /* route_to_el2 */ |
24 | - FEAT_JSCVT (JavaScript conversion instructions) | 23 | - return hcr_el2 & HCR_TGE ? 2 : 1; |
25 | - FEAT_LOR (Limited ordering regions) | 24 | + return 1; |
26 | - FEAT_LPA (Large Physical Address space) | 25 | } |
27 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 26 | |
28 | index XXXXXXX..XXXXXXX 100644 | 27 | /* Check CPACR.FPEN. */ |
29 | --- a/target/arm/cpu64.c | ||
30 | +++ b/target/arm/cpu64.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
32 | t = cpu->isar.id_aa64mmfr2; | ||
33 | t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* FEAT_TTCNP */ | ||
34 | t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); /* FEAT_UAO */ | ||
35 | + t = FIELD_DP64(t, ID_AA64MMFR2, IESB, 1); /* FEAT_IESB */ | ||
36 | t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */ | ||
37 | t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* FEAT_TTST */ | ||
38 | t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ | ||
39 | -- | 28 | -- |
40 | 2.25.1 | 29 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This register is present for either VHE or Debugv8p2. | 3 | Instead of checking these bits in fp_exception_el and |
4 | also in sve_exception_el, document that we must compare | ||
5 | the results. The only place where we have not already | ||
6 | checked that FP EL is zero is in rebuild_hflags_a64. | ||
4 | 7 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20220506180242.216785-5-richard.henderson@linaro.org | 10 | Message-id: 20220607203306.657998-5-richard.henderson@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | target/arm/helper.c | 15 +++++++++++---- | 13 | target/arm/helper.c | 58 +++++++++++++++------------------------------ |
11 | 1 file changed, 11 insertions(+), 4 deletions(-) | 14 | 1 file changed, 19 insertions(+), 39 deletions(-) |
12 | 15 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 18 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/helper.c | 19 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo jazelle_regs[] = { | 20 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo minimal_ras_reginfo[] = { |
18 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | 21 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vsesr_el2) }, |
19 | }; | 22 | }; |
20 | 23 | ||
21 | +static const ARMCPRegInfo contextidr_el2 = { | 24 | -/* Return the exception level to which exceptions should be taken |
22 | + .name = "CONTEXTIDR_EL2", .state = ARM_CP_STATE_AA64, | 25 | - * via SVEAccessTrap. If an exception should be routed through |
23 | + .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 1, | 26 | - * AArch64.AdvSIMDFPAccessTrap, return 0; fp_exception_el should |
24 | + .access = PL2_RW, | 27 | - * take care of raising that exception. |
25 | + .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[2]) | 28 | - * C.f. the ARM pseudocode function CheckSVEEnabled. |
26 | +}; | 29 | +/* |
27 | + | 30 | + * Return the exception level to which exceptions should be taken |
28 | static const ARMCPRegInfo vhe_reginfo[] = { | 31 | + * via SVEAccessTrap. This excludes the check for whether the exception |
29 | - { .name = "CONTEXTIDR_EL2", .state = ARM_CP_STATE_AA64, | 32 | + * should be routed through AArch64.AdvSIMDFPAccessTrap. That can easily |
30 | - .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 1, | 33 | + * be found by testing 0 < fp_exception_el < sve_exception_el. |
31 | - .access = PL2_RW, | 34 | + * |
32 | - .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[2]) }, | 35 | + * C.f. the ARM pseudocode function CheckSVEEnabled. Note that the |
33 | { .name = "TTBR1_EL2", .state = ARM_CP_STATE_AA64, | 36 | + * pseudocode does *not* separate out the FP trap checks, but has them |
34 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 1, | 37 | + * all in one function. |
35 | .access = PL2_RW, .writefn = vmsa_tcr_ttbr_el2_write, | 38 | */ |
36 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 39 | int sve_exception_el(CPUARMState *env, int el) |
37 | define_one_arm_cp_reg(cpu, &ssbs_reginfo); | 40 | { |
41 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
42 | case 2: | ||
43 | return 1; | ||
44 | } | ||
45 | - | ||
46 | - /* Check CPACR.FPEN. */ | ||
47 | - switch (FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, FPEN)) { | ||
48 | - case 1: | ||
49 | - if (el != 0) { | ||
50 | - break; | ||
51 | - } | ||
52 | - /* fall through */ | ||
53 | - case 0: | ||
54 | - case 2: | ||
55 | - return 0; | ||
56 | - } | ||
38 | } | 57 | } |
39 | 58 | ||
40 | + if (cpu_isar_feature(aa64_vh, cpu) || | 59 | /* |
41 | + cpu_isar_feature(aa64_debugv8p2, cpu)) { | 60 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) |
42 | + define_one_arm_cp_reg(cpu, &contextidr_el2); | 61 | case 2: |
43 | + } | 62 | return 2; |
44 | if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { | 63 | } |
45 | define_arm_cp_regs(cpu, vhe_reginfo); | 64 | - |
65 | - switch (FIELD_EX32(env->cp15.cptr_el[2], CPTR_EL2, FPEN)) { | ||
66 | - case 1: | ||
67 | - if (el == 2 || !(hcr_el2 & HCR_TGE)) { | ||
68 | - break; | ||
69 | - } | ||
70 | - /* fall through */ | ||
71 | - case 0: | ||
72 | - case 2: | ||
73 | - return 0; | ||
74 | - } | ||
75 | } else if (arm_is_el2_enabled(env)) { | ||
76 | if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TZ)) { | ||
77 | return 2; | ||
78 | } | ||
79 | - if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TFP)) { | ||
80 | - return 0; | ||
81 | - } | ||
82 | } | ||
46 | } | 83 | } |
84 | |||
85 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
86 | |||
87 | if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { | ||
88 | int sve_el = sve_exception_el(env, el); | ||
89 | - uint32_t zcr_len; | ||
90 | |||
91 | /* | ||
92 | - * If SVE is disabled, but FP is enabled, | ||
93 | - * then the effective len is 0. | ||
94 | + * If either FP or SVE are disabled, translator does not need len. | ||
95 | + * If SVE EL > FP EL, FP exception has precedence, and translator | ||
96 | + * does not need SVE EL. Save potential re-translations by forcing | ||
97 | + * the unneeded data to zero. | ||
98 | */ | ||
99 | - if (sve_el != 0 && fp_el == 0) { | ||
100 | - zcr_len = 0; | ||
101 | - } else { | ||
102 | - zcr_len = sve_zcr_len_for_el(env, el); | ||
103 | + if (fp_el != 0) { | ||
104 | + if (sve_el > fp_el) { | ||
105 | + sve_el = 0; | ||
106 | + } | ||
107 | + } else if (sve_el == 0) { | ||
108 | + DP_TBFLAG_A64(flags, VL, sve_zcr_len_for_el(env, el)); | ||
109 | } | ||
110 | DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); | ||
111 | - DP_TBFLAG_A64(flags, VL, zcr_len); | ||
112 | } | ||
113 | |||
114 | sctlr = regime_sctlr(env, stage1); | ||
47 | -- | 115 | -- |
48 | 2.25.1 | 116 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Share the code to set AArch32 max features so that we no | 3 | This (newish) ARM pseudocode function is easier to work with |
4 | longer have code drift between qemu{-system,}-{arm,aarch64}. | 4 | than open-coded tests for HCR_E2H etc. Use of the function |
5 | will be staged into the code base in parts. | ||
5 | 6 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220506180242.216785-9-richard.henderson@linaro.org | 9 | Message-id: 20220607203306.657998-6-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | target/arm/internals.h | 2 + | 12 | target/arm/internals.h | 2 ++ |
12 | target/arm/cpu64.c | 50 +----------------- | 13 | target/arm/helper.c | 28 ++++++++++++++++++++++++++++ |
13 | target/arm/cpu_tcg.c | 114 ++++++++++++++++++++++------------------- | 14 | 2 files changed, 30 insertions(+) |
14 | 3 files changed, 65 insertions(+), 101 deletions(-) | ||
15 | 15 | ||
16 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 16 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/internals.h | 18 | --- a/target/arm/internals.h |
19 | +++ b/target/arm/internals.h | 19 | +++ b/target/arm/internals.h |
20 | @@ -XXX,XX +XXX,XX @@ static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } | 20 | @@ -XXX,XX +XXX,XX @@ static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } |
21 | void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); | 21 | void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | +void aa32_max_features(ARMCPU *cpu); | 24 | +bool el_is_in_host(CPUARMState *env, int el); |
25 | + | 25 | + |
26 | void aa32_max_features(ARMCPU *cpu); | ||
27 | |||
26 | #endif | 28 | #endif |
27 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 29 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
28 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/cpu64.c | 31 | --- a/target/arm/helper.c |
30 | +++ b/target/arm/cpu64.c | 32 | +++ b/target/arm/helper.c |
31 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 33 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_hcr_el2_eff(CPUARMState *env) |
32 | { | 34 | return ret; |
33 | ARMCPU *cpu = ARM_CPU(obj); | 35 | } |
34 | uint64_t t; | 36 | |
35 | - uint32_t u; | 37 | +/* |
36 | 38 | + * Corresponds to ARM pseudocode function ELIsInHost(). | |
37 | if (kvm_enabled() || hvf_enabled()) { | 39 | + */ |
38 | /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ | 40 | +bool el_is_in_host(CPUARMState *env, int el) |
39 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 41 | +{ |
40 | t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); | 42 | + uint64_t mask; |
41 | cpu->isar.id_aa64zfr0 = t; | ||
42 | |||
43 | - /* Replicate the same data to the 32-bit id registers. */ | ||
44 | - u = cpu->isar.id_isar5; | ||
45 | - u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */ | ||
46 | - u = FIELD_DP32(u, ID_ISAR5, SHA1, 1); | ||
47 | - u = FIELD_DP32(u, ID_ISAR5, SHA2, 1); | ||
48 | - u = FIELD_DP32(u, ID_ISAR5, CRC32, 1); | ||
49 | - u = FIELD_DP32(u, ID_ISAR5, RDM, 1); | ||
50 | - u = FIELD_DP32(u, ID_ISAR5, VCMA, 1); | ||
51 | - cpu->isar.id_isar5 = u; | ||
52 | - | ||
53 | - u = cpu->isar.id_isar6; | ||
54 | - u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1); | ||
55 | - u = FIELD_DP32(u, ID_ISAR6, DP, 1); | ||
56 | - u = FIELD_DP32(u, ID_ISAR6, FHM, 1); | ||
57 | - u = FIELD_DP32(u, ID_ISAR6, SB, 1); | ||
58 | - u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1); | ||
59 | - u = FIELD_DP32(u, ID_ISAR6, BF16, 1); | ||
60 | - u = FIELD_DP32(u, ID_ISAR6, I8MM, 1); | ||
61 | - cpu->isar.id_isar6 = u; | ||
62 | - | ||
63 | - u = cpu->isar.id_pfr0; | ||
64 | - u = FIELD_DP32(u, ID_PFR0, DIT, 1); | ||
65 | - cpu->isar.id_pfr0 = u; | ||
66 | - | ||
67 | - u = cpu->isar.id_pfr2; | ||
68 | - u = FIELD_DP32(u, ID_PFR2, SSBS, 1); | ||
69 | - cpu->isar.id_pfr2 = u; | ||
70 | - | ||
71 | - u = cpu->isar.id_mmfr3; | ||
72 | - u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
73 | - cpu->isar.id_mmfr3 = u; | ||
74 | - | ||
75 | - u = cpu->isar.id_mmfr4; | ||
76 | - u = FIELD_DP32(u, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
77 | - u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
78 | - u = FIELD_DP32(u, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
79 | - u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
80 | - cpu->isar.id_mmfr4 = u; | ||
81 | - | ||
82 | t = cpu->isar.id_aa64dfr0; | ||
83 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */ | ||
84 | cpu->isar.id_aa64dfr0 = t; | ||
85 | |||
86 | - u = cpu->isar.id_dfr0; | ||
87 | - u = FIELD_DP32(u, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
88 | - cpu->isar.id_dfr0 = u; | ||
89 | - | ||
90 | - u = cpu->isar.mvfr1; | ||
91 | - u = FIELD_DP32(u, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
92 | - u = FIELD_DP32(u, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
93 | - cpu->isar.mvfr1 = u; | ||
94 | + /* Replicate the same data to the 32-bit id registers. */ | ||
95 | + aa32_max_features(cpu); | ||
96 | |||
97 | #ifdef CONFIG_USER_ONLY | ||
98 | /* | ||
99 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/target/arm/cpu_tcg.c | ||
102 | +++ b/target/arm/cpu_tcg.c | ||
103 | @@ -XXX,XX +XXX,XX @@ | ||
104 | #endif | ||
105 | #include "cpregs.h" | ||
106 | |||
107 | + | 43 | + |
108 | +/* Share AArch32 -cpu max features with AArch64. */ | 44 | + /* |
109 | +void aa32_max_features(ARMCPU *cpu) | 45 | + * Since we only care about E2H and TGE, we can skip arm_hcr_el2_eff(). |
110 | +{ | 46 | + * Perform the simplest bit tests first, and validate EL2 afterward. |
111 | + uint32_t t; | 47 | + */ |
48 | + if (el & 1) { | ||
49 | + return false; /* EL1 or EL3 */ | ||
50 | + } | ||
112 | + | 51 | + |
113 | + /* Add additional features supported by QEMU */ | 52 | + /* |
114 | + t = cpu->isar.id_isar5; | 53 | + * Note that hcr_write() checks isar_feature_aa64_vh(), |
115 | + t = FIELD_DP32(t, ID_ISAR5, AES, 2); | 54 | + * aka HaveVirtHostExt(), in allowing HCR_E2H to be set. |
116 | + t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | 55 | + */ |
117 | + t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | 56 | + mask = el ? HCR_E2H : HCR_E2H | HCR_TGE; |
118 | + t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | 57 | + if ((env->cp15.hcr_el2 & mask) != mask) { |
119 | + t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | 58 | + return false; |
120 | + t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | 59 | + } |
121 | + cpu->isar.id_isar5 = t; | ||
122 | + | 60 | + |
123 | + t = cpu->isar.id_isar6; | 61 | + /* TGE and/or E2H set: double check those bits are currently legal. */ |
124 | + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | 62 | + return arm_is_el2_enabled(env) && arm_el_is_aa64(env, 2); |
125 | + t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
126 | + t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
127 | + t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
128 | + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
129 | + t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
130 | + t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
131 | + cpu->isar.id_isar6 = t; | ||
132 | + | ||
133 | + t = cpu->isar.mvfr1; | ||
134 | + t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
135 | + t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
136 | + cpu->isar.mvfr1 = t; | ||
137 | + | ||
138 | + t = cpu->isar.mvfr2; | ||
139 | + t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
140 | + t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
141 | + cpu->isar.mvfr2 = t; | ||
142 | + | ||
143 | + t = cpu->isar.id_mmfr3; | ||
144 | + t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
145 | + cpu->isar.id_mmfr3 = t; | ||
146 | + | ||
147 | + t = cpu->isar.id_mmfr4; | ||
148 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
149 | + t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
150 | + t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
151 | + t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
152 | + cpu->isar.id_mmfr4 = t; | ||
153 | + | ||
154 | + t = cpu->isar.id_pfr0; | ||
155 | + t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
156 | + cpu->isar.id_pfr0 = t; | ||
157 | + | ||
158 | + t = cpu->isar.id_pfr2; | ||
159 | + t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
160 | + cpu->isar.id_pfr2 = t; | ||
161 | + | ||
162 | + t = cpu->isar.id_dfr0; | ||
163 | + t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
164 | + cpu->isar.id_dfr0 = t; | ||
165 | +} | 63 | +} |
166 | + | 64 | + |
167 | #ifndef CONFIG_USER_ONLY | 65 | static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri, |
168 | static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 66 | uint64_t value) |
169 | { | 67 | { |
170 | @@ -XXX,XX +XXX,XX @@ static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
171 | static void arm_max_initfn(Object *obj) | ||
172 | { | ||
173 | ARMCPU *cpu = ARM_CPU(obj); | ||
174 | - uint32_t t; | ||
175 | |||
176 | /* aarch64_a57_initfn, advertising none of the aarch64 features */ | ||
177 | cpu->dtb_compatible = "arm,cortex-a57"; | ||
178 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
179 | cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */ | ||
180 | define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
181 | |||
182 | - /* Add additional features supported by QEMU */ | ||
183 | - t = cpu->isar.id_isar5; | ||
184 | - t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
185 | - t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
186 | - t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
187 | - t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
188 | - t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
189 | - t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
190 | - cpu->isar.id_isar5 = t; | ||
191 | - | ||
192 | - t = cpu->isar.id_isar6; | ||
193 | - t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
194 | - t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
195 | - t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
196 | - t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
197 | - t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
198 | - t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
199 | - t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
200 | - cpu->isar.id_isar6 = t; | ||
201 | - | ||
202 | - t = cpu->isar.mvfr1; | ||
203 | - t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
204 | - t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
205 | - cpu->isar.mvfr1 = t; | ||
206 | - | ||
207 | - t = cpu->isar.mvfr2; | ||
208 | - t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
209 | - t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
210 | - cpu->isar.mvfr2 = t; | ||
211 | - | ||
212 | - t = cpu->isar.id_mmfr3; | ||
213 | - t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
214 | - cpu->isar.id_mmfr3 = t; | ||
215 | - | ||
216 | - t = cpu->isar.id_mmfr4; | ||
217 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
218 | - t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
219 | - t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
220 | - t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
221 | - cpu->isar.id_mmfr4 = t; | ||
222 | - | ||
223 | - t = cpu->isar.id_pfr0; | ||
224 | - t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
225 | - cpu->isar.id_pfr0 = t; | ||
226 | - | ||
227 | - t = cpu->isar.id_pfr2; | ||
228 | - t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
229 | - cpu->isar.id_pfr2 = t; | ||
230 | - | ||
231 | - t = cpu->isar.id_dfr0; | ||
232 | - t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
233 | - cpu->isar.id_dfr0 = t; | ||
234 | + aa32_max_features(cpu); | ||
235 | |||
236 | #ifdef CONFIG_USER_ONLY | ||
237 | /* | ||
238 | -- | 68 | -- |
239 | 2.25.1 | 69 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Enable writes to the TERR and TEA bits when RAS is enabled. | 3 | The ARM pseudocode function NVL uses this predicate now, |
4 | These bits are otherwise RES0. | 4 | and I think it's a bit clearer. Simplify the pseudocode |
5 | condition by noting that IsInHost is always false for EL1. | ||
5 | 6 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220506180242.216785-15-richard.henderson@linaro.org | 9 | Message-id: 20220607203306.657998-7-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | target/arm/helper.c | 9 +++++++++ | 12 | target/arm/helper.c | 3 +-- |
12 | 1 file changed, 9 insertions(+) | 13 | 1 file changed, 1 insertion(+), 2 deletions(-) |
13 | 14 | ||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 17 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/helper.c | 18 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 19 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) |
19 | } | 20 | ARMCPU *cpu = env_archcpu(env); |
20 | valid_mask &= ~SCR_NET; | 21 | uint32_t zcr_len = cpu->sve_max_vq - 1; |
21 | 22 | ||
22 | + if (cpu_isar_feature(aa64_ras, cpu)) { | 23 | - if (el <= 1 && |
23 | + valid_mask |= SCR_TERR; | 24 | - (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { |
24 | + } | 25 | + if (el <= 1 && !el_is_in_host(env, el)) { |
25 | if (cpu_isar_feature(aa64_lor, cpu)) { | 26 | zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[1]); |
26 | valid_mask |= SCR_TLOR; | ||
27 | } | ||
28 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
29 | } | ||
30 | } else { | ||
31 | valid_mask &= ~(SCR_RW | SCR_ST); | ||
32 | + if (cpu_isar_feature(aa32_ras, cpu)) { | ||
33 | + valid_mask |= SCR_TERR; | ||
34 | + } | ||
35 | } | 27 | } |
36 | 28 | if (el <= 2 && arm_feature(env, ARM_FEATURE_EL2)) { | |
37 | if (!arm_feature(env, ARM_FEATURE_EL2)) { | ||
38 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
39 | if (cpu_isar_feature(aa64_vh, cpu)) { | ||
40 | valid_mask |= HCR_E2H; | ||
41 | } | ||
42 | + if (cpu_isar_feature(aa64_ras, cpu)) { | ||
43 | + valid_mask |= HCR_TERR | HCR_TEA; | ||
44 | + } | ||
45 | if (cpu_isar_feature(aa64_lor, cpu)) { | ||
46 | valid_mask |= HCR_TLOR; | ||
47 | } | ||
48 | -- | 29 | -- |
49 | 2.25.1 | 30 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Drop zcr_no_el2_reginfo and merge the 3 registers into one array, | 3 | The ARM pseudocode function CheckNormalSVEEnabled uses this |
4 | now that ZCR_EL2 can be squashed to RES0 and ZCR_EL3 dropped | 4 | predicate now, and I think it's a bit clearer. |
5 | while registering. | ||
6 | 5 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20220506180242.216785-4-richard.henderson@linaro.org | 8 | Message-id: 20220607203306.657998-8-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/helper.c | 55 ++++++++++++++------------------------------- | 11 | target/arm/helper.c | 5 ++--- |
13 | 1 file changed, 17 insertions(+), 38 deletions(-) | 12 | 1 file changed, 2 insertions(+), 3 deletions(-) |
14 | 13 | ||
15 | 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 |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper.c | 16 | --- a/target/arm/helper.c |
18 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/helper.c |
19 | @@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 18 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo minimal_ras_reginfo[] = { |
20 | } | 19 | int sve_exception_el(CPUARMState *env, int el) |
21 | } | 20 | { |
22 | 21 | #ifndef CONFIG_USER_ONLY | |
23 | -static const ARMCPRegInfo zcr_el1_reginfo = { | 22 | - uint64_t hcr_el2 = arm_hcr_el2_eff(env); |
24 | - .name = "ZCR_EL1", .state = ARM_CP_STATE_AA64, | ||
25 | - .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0, | ||
26 | - .access = PL1_RW, .type = ARM_CP_SVE, | ||
27 | - .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]), | ||
28 | - .writefn = zcr_write, .raw_writefn = raw_write | ||
29 | -}; | ||
30 | - | 23 | - |
31 | -static const ARMCPRegInfo zcr_el2_reginfo = { | 24 | - if (el <= 1 && (hcr_el2 & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { |
32 | - .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, | 25 | + if (el <= 1 && !el_is_in_host(env, el)) { |
33 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, | 26 | switch (FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, ZEN)) { |
34 | - .access = PL2_RW, .type = ARM_CP_SVE, | 27 | case 1: |
35 | - .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]), | 28 | if (el != 0) { |
36 | - .writefn = zcr_write, .raw_writefn = raw_write | 29 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) |
37 | -}; | 30 | * CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). |
38 | - | 31 | */ |
39 | -static const ARMCPRegInfo zcr_no_el2_reginfo = { | 32 | if (el <= 2) { |
40 | - .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, | 33 | + uint64_t hcr_el2 = arm_hcr_el2_eff(env); |
41 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, | 34 | if (hcr_el2 & HCR_E2H) { |
42 | - .access = PL2_RW, .type = ARM_CP_SVE, | 35 | switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, ZEN)) { |
43 | - .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore | 36 | case 1: |
44 | -}; | ||
45 | - | ||
46 | -static const ARMCPRegInfo zcr_el3_reginfo = { | ||
47 | - .name = "ZCR_EL3", .state = ARM_CP_STATE_AA64, | ||
48 | - .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0, | ||
49 | - .access = PL3_RW, .type = ARM_CP_SVE, | ||
50 | - .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]), | ||
51 | - .writefn = zcr_write, .raw_writefn = raw_write | ||
52 | +static const ARMCPRegInfo zcr_reginfo[] = { | ||
53 | + { .name = "ZCR_EL1", .state = ARM_CP_STATE_AA64, | ||
54 | + .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0, | ||
55 | + .access = PL1_RW, .type = ARM_CP_SVE, | ||
56 | + .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]), | ||
57 | + .writefn = zcr_write, .raw_writefn = raw_write }, | ||
58 | + { .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, | ||
59 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, | ||
60 | + .access = PL2_RW, .type = ARM_CP_SVE, | ||
61 | + .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]), | ||
62 | + .writefn = zcr_write, .raw_writefn = raw_write }, | ||
63 | + { .name = "ZCR_EL3", .state = ARM_CP_STATE_AA64, | ||
64 | + .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0, | ||
65 | + .access = PL3_RW, .type = ARM_CP_SVE, | ||
66 | + .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]), | ||
67 | + .writefn = zcr_write, .raw_writefn = raw_write }, | ||
68 | }; | ||
69 | |||
70 | void hw_watchpoint_update(ARMCPU *cpu, int n) | ||
71 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
72 | } | ||
73 | |||
74 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
75 | - define_one_arm_cp_reg(cpu, &zcr_el1_reginfo); | ||
76 | - if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
77 | - define_one_arm_cp_reg(cpu, &zcr_el2_reginfo); | ||
78 | - } else { | ||
79 | - define_one_arm_cp_reg(cpu, &zcr_no_el2_reginfo); | ||
80 | - } | ||
81 | - if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
82 | - define_one_arm_cp_reg(cpu, &zcr_el3_reginfo); | ||
83 | - } | ||
84 | + define_arm_cp_regs(cpu, zcr_reginfo); | ||
85 | } | ||
86 | |||
87 | #ifdef TARGET_AARCH64 | ||
88 | -- | 37 | -- |
89 | 2.25.1 | 38 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | More gracefully handle cpregs when EL2 and/or EL3 are missing. | 3 | This check is buried within arm_hcr_el2_eff(), but since we |
4 | If the reg is entirely inaccessible, do not register it at all. | 4 | have to have the explicit check for CPTR_EL2.TZ, we might as |
5 | If the reg is for EL2, and EL3 is present but EL2 is not, | 5 | well just check it once at the beginning of the block. |
6 | either discard, squash to res0, const, or keep unchanged. | ||
7 | 6 | ||
8 | Per rule RJFFP, mark the 4 aarch32 hypervisor access registers | 7 | Once this is done, we can test HCR_EL2.{E2H,TGE} directly, |
9 | with ARM_CP_EL3_NO_EL2_KEEP, and mark all of the EL2 address | 8 | rather than going through arm_hcr_el2_eff(). |
10 | translation and tlb invalidation "regs" ARM_CP_EL3_NO_EL2_UNDEF. | ||
11 | Mark the 2 virtualization processor id regs ARM_CP_EL3_NO_EL2_C_NZ. | ||
12 | |||
13 | This will simplify cpreg registration for conditional arm features. | ||
14 | 9 | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-id: 20220506180242.216785-2-richard.henderson@linaro.org | 12 | Message-id: 20220607203306.657998-9-richard.henderson@linaro.org |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 14 | --- |
20 | target/arm/cpregs.h | 11 +++ | 15 | target/arm/helper.c | 13 +++++-------- |
21 | target/arm/helper.c | 178 ++++++++++++++++++++++++++++++-------------- | 16 | 1 file changed, 5 insertions(+), 8 deletions(-) |
22 | 2 files changed, 133 insertions(+), 56 deletions(-) | ||
23 | 17 | ||
24 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/cpregs.h | ||
27 | +++ b/target/arm/cpregs.h | ||
28 | @@ -XXX,XX +XXX,XX @@ enum { | ||
29 | ARM_CP_SVE = 1 << 14, | ||
30 | /* Flag: Do not expose in gdb sysreg xml. */ | ||
31 | ARM_CP_NO_GDB = 1 << 15, | ||
32 | + /* | ||
33 | + * Flags: If EL3 but not EL2... | ||
34 | + * - UNDEF: discard the cpreg, | ||
35 | + * - KEEP: retain the cpreg as is, | ||
36 | + * - C_NZ: set const on the cpreg, but retain resetvalue, | ||
37 | + * - else: set const on the cpreg, zero resetvalue, aka RES0. | ||
38 | + * See rule RJFFP in section D1.1.3 of DDI0487H.a. | ||
39 | + */ | ||
40 | + ARM_CP_EL3_NO_EL2_UNDEF = 1 << 16, | ||
41 | + ARM_CP_EL3_NO_EL2_KEEP = 1 << 17, | ||
42 | + ARM_CP_EL3_NO_EL2_C_NZ = 1 << 18, | ||
43 | }; | ||
44 | |||
45 | /* | ||
46 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 18 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
47 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/target/arm/helper.c | 20 | --- a/target/arm/helper.c |
49 | +++ b/target/arm/helper.c | 21 | +++ b/target/arm/helper.c |
50 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | 22 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) |
51 | .access = PL1_RW, .readfn = spsel_read, .writefn = spsel_write }, | ||
52 | { .name = "FPEXC32_EL2", .state = ARM_CP_STATE_AA64, | ||
53 | .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 3, .opc2 = 0, | ||
54 | - .access = PL2_RW, .type = ARM_CP_ALIAS | ARM_CP_FPU, | ||
55 | + .access = PL2_RW, | ||
56 | + .type = ARM_CP_ALIAS | ARM_CP_FPU | ARM_CP_EL3_NO_EL2_KEEP, | ||
57 | .fieldoffset = offsetof(CPUARMState, vfp.xregs[ARM_VFP_FPEXC]) }, | ||
58 | { .name = "DACR32_EL2", .state = ARM_CP_STATE_AA64, | ||
59 | .opc0 = 3, .opc1 = 4, .crn = 3, .crm = 0, .opc2 = 0, | ||
60 | - .access = PL2_RW, .resetvalue = 0, | ||
61 | + .access = PL2_RW, .resetvalue = 0, .type = ARM_CP_EL3_NO_EL2_KEEP, | ||
62 | .writefn = dacr_write, .raw_writefn = raw_write, | ||
63 | .fieldoffset = offsetof(CPUARMState, cp15.dacr32_el2) }, | ||
64 | { .name = "IFSR32_EL2", .state = ARM_CP_STATE_AA64, | ||
65 | .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 0, .opc2 = 1, | ||
66 | - .access = PL2_RW, .resetvalue = 0, | ||
67 | + .access = PL2_RW, .resetvalue = 0, .type = ARM_CP_EL3_NO_EL2_KEEP, | ||
68 | .fieldoffset = offsetof(CPUARMState, cp15.ifsr32_el2) }, | ||
69 | { .name = "SPSR_IRQ", .state = ARM_CP_STATE_AA64, | ||
70 | .type = ARM_CP_ALIAS, | ||
71 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
72 | .writefn = tlbimva_hyp_is_write }, | ||
73 | { .name = "TLBI_ALLE2", .state = ARM_CP_STATE_AA64, | ||
74 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 0, | ||
75 | - .type = ARM_CP_NO_RAW, .access = PL2_W, | ||
76 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
77 | .writefn = tlbi_aa64_alle2_write }, | ||
78 | { .name = "TLBI_VAE2", .state = ARM_CP_STATE_AA64, | ||
79 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 1, | ||
80 | - .type = ARM_CP_NO_RAW, .access = PL2_W, | ||
81 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
82 | .writefn = tlbi_aa64_vae2_write }, | ||
83 | { .name = "TLBI_VALE2", .state = ARM_CP_STATE_AA64, | ||
84 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 5, | ||
85 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
86 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
87 | .writefn = tlbi_aa64_vae2_write }, | ||
88 | { .name = "TLBI_ALLE2IS", .state = ARM_CP_STATE_AA64, | ||
89 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 0, | ||
90 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
91 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
92 | .writefn = tlbi_aa64_alle2is_write }, | ||
93 | { .name = "TLBI_VAE2IS", .state = ARM_CP_STATE_AA64, | ||
94 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 1, | ||
95 | - .type = ARM_CP_NO_RAW, .access = PL2_W, | ||
96 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
97 | .writefn = tlbi_aa64_vae2is_write }, | ||
98 | { .name = "TLBI_VALE2IS", .state = ARM_CP_STATE_AA64, | ||
99 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 5, | ||
100 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
101 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
102 | .writefn = tlbi_aa64_vae2is_write }, | ||
103 | #ifndef CONFIG_USER_ONLY | ||
104 | /* Unlike the other EL2-related AT operations, these must | ||
105 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
106 | { .name = "AT_S1E2R", .state = ARM_CP_STATE_AA64, | ||
107 | .opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 0, | ||
108 | .access = PL2_W, .accessfn = at_s1e2_access, | ||
109 | - .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, .writefn = ats_write64 }, | ||
110 | + .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC | ARM_CP_EL3_NO_EL2_UNDEF, | ||
111 | + .writefn = ats_write64 }, | ||
112 | { .name = "AT_S1E2W", .state = ARM_CP_STATE_AA64, | ||
113 | .opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 1, | ||
114 | .access = PL2_W, .accessfn = at_s1e2_access, | ||
115 | - .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, .writefn = ats_write64 }, | ||
116 | + .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC | ARM_CP_EL3_NO_EL2_UNDEF, | ||
117 | + .writefn = ats_write64 }, | ||
118 | /* The AArch32 ATS1H* operations are CONSTRAINED UNPREDICTABLE | ||
119 | * if EL2 is not implemented; we choose to UNDEF. Behaviour at EL3 | ||
120 | * with SCR.NS == 0 outside Monitor mode is UNPREDICTABLE; we choose | ||
121 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { | ||
122 | { .name = "DBGVCR32_EL2", .state = ARM_CP_STATE_AA64, | ||
123 | .opc0 = 2, .opc1 = 4, .crn = 0, .crm = 7, .opc2 = 0, | ||
124 | .access = PL2_RW, .accessfn = access_tda, | ||
125 | - .type = ARM_CP_NOP }, | ||
126 | + .type = ARM_CP_NOP | ARM_CP_EL3_NO_EL2_KEEP }, | ||
127 | /* Dummy MDCCINT_EL1, since we don't implement the Debug Communications | ||
128 | * Channel but Linux may try to access this register. The 32-bit | ||
129 | * alias is DBGDCCINT. | ||
130 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
131 | .access = PL2_W, .type = ARM_CP_NOP }, | ||
132 | { .name = "TLBI_RVAE2IS", .state = ARM_CP_STATE_AA64, | ||
133 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 2, .opc2 = 1, | ||
134 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
135 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
136 | .writefn = tlbi_aa64_rvae2is_write }, | ||
137 | { .name = "TLBI_RVALE2IS", .state = ARM_CP_STATE_AA64, | ||
138 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 2, .opc2 = 5, | ||
139 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
140 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
141 | .writefn = tlbi_aa64_rvae2is_write }, | ||
142 | { .name = "TLBI_RIPAS2E1", .state = ARM_CP_STATE_AA64, | ||
143 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 2, | ||
144 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
145 | .access = PL2_W, .type = ARM_CP_NOP }, | ||
146 | { .name = "TLBI_RVAE2OS", .state = ARM_CP_STATE_AA64, | ||
147 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 5, .opc2 = 1, | ||
148 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
149 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
150 | .writefn = tlbi_aa64_rvae2is_write }, | ||
151 | { .name = "TLBI_RVALE2OS", .state = ARM_CP_STATE_AA64, | ||
152 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 5, .opc2 = 5, | ||
153 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
154 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
155 | .writefn = tlbi_aa64_rvae2is_write }, | ||
156 | { .name = "TLBI_RVAE2", .state = ARM_CP_STATE_AA64, | ||
157 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 6, .opc2 = 1, | ||
158 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
159 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
160 | .writefn = tlbi_aa64_rvae2_write }, | ||
161 | { .name = "TLBI_RVALE2", .state = ARM_CP_STATE_AA64, | ||
162 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 6, .opc2 = 5, | ||
163 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
164 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
165 | .writefn = tlbi_aa64_rvae2_write }, | ||
166 | { .name = "TLBI_RVAE3IS", .state = ARM_CP_STATE_AA64, | ||
167 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 2, .opc2 = 1, | ||
168 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = { | ||
169 | .writefn = tlbi_aa64_vae1is_write }, | ||
170 | { .name = "TLBI_ALLE2OS", .state = ARM_CP_STATE_AA64, | ||
171 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 0, | ||
172 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
173 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
174 | .writefn = tlbi_aa64_alle2is_write }, | ||
175 | { .name = "TLBI_VAE2OS", .state = ARM_CP_STATE_AA64, | ||
176 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 1, | ||
177 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
178 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
179 | .writefn = tlbi_aa64_vae2is_write }, | ||
180 | { .name = "TLBI_ALLE1OS", .state = ARM_CP_STATE_AA64, | ||
181 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 4, | ||
182 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = { | ||
183 | .writefn = tlbi_aa64_alle1is_write }, | ||
184 | { .name = "TLBI_VALE2OS", .state = ARM_CP_STATE_AA64, | ||
185 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 5, | ||
186 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
187 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
188 | .writefn = tlbi_aa64_vae2is_write }, | ||
189 | { .name = "TLBI_VMALLS12E1OS", .state = ARM_CP_STATE_AA64, | ||
190 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 6, | ||
191 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
192 | { .name = "VPIDR", .state = ARM_CP_STATE_AA32, | ||
193 | .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | ||
194 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
195 | - .resetvalue = cpu->midr, .type = ARM_CP_ALIAS, | ||
196 | + .resetvalue = cpu->midr, | ||
197 | + .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, | ||
198 | .fieldoffset = offsetoflow32(CPUARMState, cp15.vpidr_el2) }, | ||
199 | { .name = "VPIDR_EL2", .state = ARM_CP_STATE_AA64, | ||
200 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | ||
201 | .access = PL2_RW, .resetvalue = cpu->midr, | ||
202 | + .type = ARM_CP_EL3_NO_EL2_C_NZ, | ||
203 | .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, | ||
204 | { .name = "VMPIDR", .state = ARM_CP_STATE_AA32, | ||
205 | .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | ||
206 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
207 | - .resetvalue = vmpidr_def, .type = ARM_CP_ALIAS, | ||
208 | + .resetvalue = vmpidr_def, | ||
209 | + .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, | ||
210 | .fieldoffset = offsetoflow32(CPUARMState, cp15.vmpidr_el2) }, | ||
211 | { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_AA64, | ||
212 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | ||
213 | - .access = PL2_RW, | ||
214 | - .resetvalue = vmpidr_def, | ||
215 | + .access = PL2_RW, .resetvalue = vmpidr_def, | ||
216 | + .type = ARM_CP_EL3_NO_EL2_C_NZ, | ||
217 | .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, | ||
218 | }; | ||
219 | define_arm_cp_regs(cpu, vpidr_regs); | ||
220 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
221 | int crm, int opc1, int opc2, | ||
222 | const char *name) | ||
223 | { | ||
224 | + CPUARMState *env = &cpu->env; | ||
225 | uint32_t key; | ||
226 | ARMCPRegInfo *r2; | ||
227 | bool is64 = r->type & ARM_CP_64BIT; | ||
228 | bool ns = secstate & ARM_CP_SECSTATE_NS; | ||
229 | int cp = r->cp; | ||
230 | - bool isbanked; | ||
231 | size_t name_len; | ||
232 | + bool make_const; | ||
233 | |||
234 | switch (state) { | ||
235 | case ARM_CP_STATE_AA32: | ||
236 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
237 | } | 23 | } |
238 | } | 24 | } |
239 | 25 | ||
240 | + /* | 26 | - /* |
241 | + * Eliminate registers that are not present because the EL is missing. | 27 | - * CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). |
242 | + * Doing this here makes it easier to put all registers for a given | 28 | - */ |
243 | + * feature into the same ARMCPRegInfo array and define them all at once. | 29 | - if (el <= 2) { |
244 | + */ | 30 | - uint64_t hcr_el2 = arm_hcr_el2_eff(env); |
245 | + make_const = false; | 31 | - if (hcr_el2 & HCR_E2H) { |
246 | + if (arm_feature(env, ARM_FEATURE_EL3)) { | 32 | + if (el <= 2 && arm_is_el2_enabled(env)) { |
247 | + /* | 33 | + /* CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). */ |
248 | + * An EL2 register without EL2 but with EL3 is (usually) RES0. | 34 | + if (env->cp15.hcr_el2 & HCR_E2H) { |
249 | + * See rule RJFFP in section D1.1.3 of DDI0487H.a. | 35 | switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, ZEN)) { |
250 | + */ | 36 | case 1: |
251 | + int min_el = ctz32(r->access) / 2; | 37 | - if (el != 0 || !(hcr_el2 & HCR_TGE)) { |
252 | + if (min_el == 2 && !arm_feature(env, ARM_FEATURE_EL2)) { | 38 | + if (el != 0 || !(env->cp15.hcr_el2 & HCR_TGE)) { |
253 | + if (r->type & ARM_CP_EL3_NO_EL2_UNDEF) { | 39 | break; |
254 | + return; | 40 | } |
255 | + } | 41 | /* fall through */ |
256 | + make_const = !(r->type & ARM_CP_EL3_NO_EL2_KEEP); | 42 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) |
257 | + } | 43 | case 2: |
258 | + } else { | 44 | return 2; |
259 | + CPAccessRights max_el = (arm_feature(env, ARM_FEATURE_EL2) | ||
260 | + ? PL2_RW : PL1_RW); | ||
261 | + if ((r->access & max_el) == 0) { | ||
262 | + return; | ||
263 | + } | ||
264 | + } | ||
265 | + | ||
266 | /* Combine cpreg and name into one allocation. */ | ||
267 | name_len = strlen(name) + 1; | ||
268 | r2 = g_malloc(sizeof(*r2) + name_len); | ||
269 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
270 | r2->opaque = opaque; | ||
271 | } | ||
272 | |||
273 | - isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; | ||
274 | - if (isbanked) { | ||
275 | + if (make_const) { | ||
276 | + /* This should not have been a very special register to begin. */ | ||
277 | + int old_special = r2->type & ARM_CP_SPECIAL_MASK; | ||
278 | + assert(old_special == 0 || old_special == ARM_CP_NOP); | ||
279 | /* | ||
280 | - * Register is banked (using both entries in array). | ||
281 | - * Overwriting fieldoffset as the array is only used to define | ||
282 | - * banked registers but later only fieldoffset is used. | ||
283 | + * Set the special function to CONST, retaining the other flags. | ||
284 | + * This is important for e.g. ARM_CP_SVE so that we still | ||
285 | + * take the SVE trap if CPTR_EL3.EZ == 0. | ||
286 | */ | ||
287 | - r2->fieldoffset = r->bank_fieldoffsets[ns]; | ||
288 | - } | ||
289 | + r2->type = (r2->type & ~ARM_CP_SPECIAL_MASK) | ARM_CP_CONST; | ||
290 | + /* | ||
291 | + * Usually, these registers become RES0, but there are a few | ||
292 | + * special cases like VPIDR_EL2 which have a constant non-zero | ||
293 | + * value with writes ignored. | ||
294 | + */ | ||
295 | + if (!(r->type & ARM_CP_EL3_NO_EL2_C_NZ)) { | ||
296 | + r2->resetvalue = 0; | ||
297 | + } | ||
298 | + /* | ||
299 | + * ARM_CP_CONST has precedence, so removing the callbacks and | ||
300 | + * offsets are not strictly necessary, but it is potentially | ||
301 | + * less confusing to debug later. | ||
302 | + */ | ||
303 | + r2->readfn = NULL; | ||
304 | + r2->writefn = NULL; | ||
305 | + r2->raw_readfn = NULL; | ||
306 | + r2->raw_writefn = NULL; | ||
307 | + r2->resetfn = NULL; | ||
308 | + r2->fieldoffset = 0; | ||
309 | + r2->bank_fieldoffsets[0] = 0; | ||
310 | + r2->bank_fieldoffsets[1] = 0; | ||
311 | + } else { | ||
312 | + bool isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; | ||
313 | |||
314 | - if (state == ARM_CP_STATE_AA32) { | ||
315 | if (isbanked) { | ||
316 | /* | ||
317 | - * If the register is banked then we don't need to migrate or | ||
318 | - * reset the 32-bit instance in certain cases: | ||
319 | - * | ||
320 | - * 1) If the register has both 32-bit and 64-bit instances then we | ||
321 | - * can count on the 64-bit instance taking care of the | ||
322 | - * non-secure bank. | ||
323 | - * 2) If ARMv8 is enabled then we can count on a 64-bit version | ||
324 | - * taking care of the secure bank. This requires that separate | ||
325 | - * 32 and 64-bit definitions are provided. | ||
326 | + * Register is banked (using both entries in array). | ||
327 | + * Overwriting fieldoffset as the array is only used to define | ||
328 | + * banked registers but later only fieldoffset is used. | ||
329 | */ | ||
330 | - if ((r->state == ARM_CP_STATE_BOTH && ns) || | ||
331 | - (arm_feature(&cpu->env, ARM_FEATURE_V8) && !ns)) { | ||
332 | + r2->fieldoffset = r->bank_fieldoffsets[ns]; | ||
333 | + } | ||
334 | + if (state == ARM_CP_STATE_AA32) { | ||
335 | + if (isbanked) { | ||
336 | + /* | ||
337 | + * If the register is banked then we don't need to migrate or | ||
338 | + * reset the 32-bit instance in certain cases: | ||
339 | + * | ||
340 | + * 1) If the register has both 32-bit and 64-bit instances | ||
341 | + * then we can count on the 64-bit instance taking care | ||
342 | + * of the non-secure bank. | ||
343 | + * 2) If ARMv8 is enabled then we can count on a 64-bit | ||
344 | + * version taking care of the secure bank. This requires | ||
345 | + * that separate 32 and 64-bit definitions are provided. | ||
346 | + */ | ||
347 | + if ((r->state == ARM_CP_STATE_BOTH && ns) || | ||
348 | + (arm_feature(env, ARM_FEATURE_V8) && !ns)) { | ||
349 | + r2->type |= ARM_CP_ALIAS; | ||
350 | + } | ||
351 | + } else if ((secstate != r->secure) && !ns) { | ||
352 | + /* | ||
353 | + * The register is not banked so we only want to allow | ||
354 | + * migration of the non-secure instance. | ||
355 | + */ | ||
356 | r2->type |= ARM_CP_ALIAS; | ||
357 | } | 45 | } |
358 | - } else if ((secstate != r->secure) && !ns) { | 46 | - } else if (arm_is_el2_enabled(env)) { |
359 | - /* | 47 | + } else { |
360 | - * The register is not banked so we only want to allow migration | 48 | if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TZ)) { |
361 | - * of the non-secure instance. | 49 | return 2; |
362 | - */ | 50 | } |
363 | - r2->type |= ARM_CP_ALIAS; | ||
364 | - } | ||
365 | |||
366 | - if (HOST_BIG_ENDIAN && | ||
367 | - r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) { | ||
368 | - r2->fieldoffset += sizeof(uint32_t); | ||
369 | + if (HOST_BIG_ENDIAN && | ||
370 | + r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) { | ||
371 | + r2->fieldoffset += sizeof(uint32_t); | ||
372 | + } | ||
373 | } | ||
374 | } | ||
375 | |||
376 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
377 | * multiple times. Special registers (ie NOP/WFI) are | ||
378 | * never migratable and not even raw-accessible. | ||
379 | */ | ||
380 | - if (r->type & ARM_CP_SPECIAL_MASK) { | ||
381 | + if (r2->type & ARM_CP_SPECIAL_MASK) { | ||
382 | r2->type |= ARM_CP_NO_RAW; | ||
383 | } | ||
384 | if (((r->crm == CP_ANY) && crm != 0) || | ||
385 | -- | 51 | -- |
386 | 2.25.1 | 52 | 2.25.1 | 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 FIELD_DP{32,64} to manipulate id_pfr1 and id_aa64pfr0 | 3 | We don't need to constrain the value set in zcr_el[1], |
4 | during arm_cpu_realizefn. | 4 | because it will be done by sve_zcr_len_for_el. |
5 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220506180242.216785-11-richard.henderson@linaro.org | 8 | Message-id: 20220607203306.657998-10-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | target/arm/cpu.c | 22 +++++++++++++--------- | 11 | target/arm/cpu.c | 3 +-- |
12 | 1 file changed, 13 insertions(+), 9 deletions(-) | 12 | 1 file changed, 1 insertion(+), 2 deletions(-) |
13 | 13 | ||
14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 16 | --- a/target/arm/cpu.c |
17 | +++ b/target/arm/cpu.c | 17 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
19 | */ | 19 | CPACR_EL1, ZEN, 3); |
20 | unset_feature(env, ARM_FEATURE_EL3); | 20 | /* with reasonable vector length */ |
21 | 21 | if (cpu_isar_feature(aa64_sve, cpu)) { | |
22 | - /* Disable the security extension feature bits in the processor feature | 22 | - env->vfp.zcr_el[1] = |
23 | - * registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12]. | 23 | - aarch64_sve_zcr_get_valid_len(cpu, cpu->sve_default_vq - 1); |
24 | + /* | 24 | + env->vfp.zcr_el[1] = cpu->sve_default_vq - 1; |
25 | + * Disable the security extension feature bits in the processor | 25 | } |
26 | + * feature registers as well. | 26 | /* |
27 | */ | 27 | * Enable 48-bit address space (TODO: take reserved_va into account). |
28 | - cpu->isar.id_pfr1 &= ~0xf0; | ||
29 | - cpu->isar.id_aa64pfr0 &= ~0xf000; | ||
30 | + cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1, ID_PFR1, SECURITY, 0); | ||
31 | + cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0, | ||
32 | + ID_AA64PFR0, EL3, 0); | ||
33 | } | ||
34 | |||
35 | if (!cpu->has_el2) { | ||
36 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
37 | } | ||
38 | |||
39 | if (!arm_feature(env, ARM_FEATURE_EL2)) { | ||
40 | - /* Disable the hypervisor feature bits in the processor feature | ||
41 | - * registers if we don't have EL2. These are id_pfr1[15:12] and | ||
42 | - * id_aa64pfr0_el1[11:8]. | ||
43 | + /* | ||
44 | + * Disable the hypervisor feature bits in the processor feature | ||
45 | + * registers if we don't have EL2. | ||
46 | */ | ||
47 | - cpu->isar.id_aa64pfr0 &= ~0xf00; | ||
48 | - cpu->isar.id_pfr1 &= ~0xf000; | ||
49 | + cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0, | ||
50 | + ID_AA64PFR0, EL2, 0); | ||
51 | + cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1, | ||
52 | + ID_PFR1, VIRTUALIZATION, 0); | ||
53 | } | ||
54 | |||
55 | #ifndef CONFIG_USER_ONLY | ||
56 | -- | 28 | -- |
57 | 2.25.1 | 29 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Drop el3_no_el2_cp_reginfo, el3_no_el2_v8_cp_reginfo, and the local | 3 | This function is used only once, and will need modification |
4 | vpidr_regs definition, and rely on the squashing to ARM_CP_CONST | 4 | for Streaming SVE mode. |
5 | while registering for v8. | ||
6 | |||
7 | This is a behavior change for v7 cpus with Security Extensions and | ||
8 | without Virtualization Extensions, in that the virtualization cpregs | ||
9 | are now correctly not present. This would be a migration compatibility | ||
10 | break, except that we have an existing bug in which migration of 32-bit | ||
11 | cpus with Security Extensions enabled does not work. | ||
12 | 5 | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20220506180242.216785-3-richard.henderson@linaro.org | 8 | Message-id: 20220607203306.657998-11-richard.henderson@linaro.org |
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 10 | --- |
18 | target/arm/helper.c | 158 ++++---------------------------------------- | 11 | target/arm/internals.h | 11 ----------- |
19 | 1 file changed, 13 insertions(+), 145 deletions(-) | 12 | target/arm/helper.c | 30 +++++++++++------------------- |
13 | 2 files changed, 11 insertions(+), 30 deletions(-) | ||
20 | 14 | ||
15 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/internals.h | ||
18 | +++ b/target/arm/internals.h | ||
19 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void); | ||
20 | void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); | ||
21 | #endif /* CONFIG_TCG */ | ||
22 | |||
23 | -/** | ||
24 | - * aarch64_sve_zcr_get_valid_len: | ||
25 | - * @cpu: cpu context | ||
26 | - * @start_len: maximum len to consider | ||
27 | - * | ||
28 | - * Return the maximum supported sve vector length <= @start_len. | ||
29 | - * Note that both @start_len and the return value are in units | ||
30 | - * of ZCR_ELx.LEN, so the vector bit length is (x + 1) * 128. | ||
31 | - */ | ||
32 | -uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len); | ||
33 | - | ||
34 | enum arm_fprounding { | ||
35 | FPROUNDING_TIEEVEN, | ||
36 | FPROUNDING_POSINF, | ||
21 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 37 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
22 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/helper.c | 39 | --- a/target/arm/helper.c |
24 | +++ b/target/arm/helper.c | 40 | +++ b/target/arm/helper.c |
25 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | 41 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) |
26 | .fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) }, | 42 | return 0; |
27 | }; | 43 | } |
28 | 44 | ||
29 | -/* Used to describe the behaviour of EL2 regs when EL2 does not exist. */ | 45 | -uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) |
30 | -static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = { | 46 | -{ |
31 | - { .name = "VBAR_EL2", .state = ARM_CP_STATE_BOTH, | 47 | - uint32_t end_len; |
32 | - .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0, | ||
33 | - .access = PL2_RW, | ||
34 | - .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore }, | ||
35 | - { .name = "HCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
36 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, | ||
37 | - .access = PL2_RW, | ||
38 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
39 | - { .name = "HACR_EL2", .state = ARM_CP_STATE_BOTH, | ||
40 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 7, | ||
41 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
42 | - { .name = "ESR_EL2", .state = ARM_CP_STATE_BOTH, | ||
43 | - .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 2, .opc2 = 0, | ||
44 | - .access = PL2_RW, | ||
45 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
46 | - { .name = "CPTR_EL2", .state = ARM_CP_STATE_BOTH, | ||
47 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 2, | ||
48 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
49 | - { .name = "MAIR_EL2", .state = ARM_CP_STATE_BOTH, | ||
50 | - .opc0 = 3, .opc1 = 4, .crn = 10, .crm = 2, .opc2 = 0, | ||
51 | - .access = PL2_RW, .type = ARM_CP_CONST, | ||
52 | - .resetvalue = 0 }, | ||
53 | - { .name = "HMAIR1", .state = ARM_CP_STATE_AA32, | ||
54 | - .cp = 15, .opc1 = 4, .crn = 10, .crm = 2, .opc2 = 1, | ||
55 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
56 | - { .name = "AMAIR_EL2", .state = ARM_CP_STATE_BOTH, | ||
57 | - .opc0 = 3, .opc1 = 4, .crn = 10, .crm = 3, .opc2 = 0, | ||
58 | - .access = PL2_RW, .type = ARM_CP_CONST, | ||
59 | - .resetvalue = 0 }, | ||
60 | - { .name = "HAMAIR1", .state = ARM_CP_STATE_AA32, | ||
61 | - .cp = 15, .opc1 = 4, .crn = 10, .crm = 3, .opc2 = 1, | ||
62 | - .access = PL2_RW, .type = ARM_CP_CONST, | ||
63 | - .resetvalue = 0 }, | ||
64 | - { .name = "AFSR0_EL2", .state = ARM_CP_STATE_BOTH, | ||
65 | - .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 1, .opc2 = 0, | ||
66 | - .access = PL2_RW, .type = ARM_CP_CONST, | ||
67 | - .resetvalue = 0 }, | ||
68 | - { .name = "AFSR1_EL2", .state = ARM_CP_STATE_BOTH, | ||
69 | - .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 1, .opc2 = 1, | ||
70 | - .access = PL2_RW, .type = ARM_CP_CONST, | ||
71 | - .resetvalue = 0 }, | ||
72 | - { .name = "TCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
73 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 2, | ||
74 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
75 | - { .name = "VTCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
76 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 2, | ||
77 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
78 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
79 | - { .name = "VTTBR", .state = ARM_CP_STATE_AA32, | ||
80 | - .cp = 15, .opc1 = 6, .crm = 2, | ||
81 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
82 | - .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
83 | - { .name = "VTTBR_EL2", .state = ARM_CP_STATE_AA64, | ||
84 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 0, | ||
85 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
86 | - { .name = "SCTLR_EL2", .state = ARM_CP_STATE_BOTH, | ||
87 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 0, | ||
88 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
89 | - { .name = "TPIDR_EL2", .state = ARM_CP_STATE_BOTH, | ||
90 | - .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 2, | ||
91 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
92 | - { .name = "TTBR0_EL2", .state = ARM_CP_STATE_AA64, | ||
93 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 0, | ||
94 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
95 | - { .name = "HTTBR", .cp = 15, .opc1 = 4, .crm = 2, | ||
96 | - .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST, | ||
97 | - .resetvalue = 0 }, | ||
98 | - { .name = "CNTHCTL_EL2", .state = ARM_CP_STATE_BOTH, | ||
99 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 1, .opc2 = 0, | ||
100 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
101 | - { .name = "CNTVOFF_EL2", .state = ARM_CP_STATE_AA64, | ||
102 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 0, .opc2 = 3, | ||
103 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
104 | - { .name = "CNTVOFF", .cp = 15, .opc1 = 4, .crm = 14, | ||
105 | - .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST, | ||
106 | - .resetvalue = 0 }, | ||
107 | - { .name = "CNTHP_CVAL_EL2", .state = ARM_CP_STATE_AA64, | ||
108 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 2, | ||
109 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
110 | - { .name = "CNTHP_CVAL", .cp = 15, .opc1 = 6, .crm = 14, | ||
111 | - .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST, | ||
112 | - .resetvalue = 0 }, | ||
113 | - { .name = "CNTHP_TVAL_EL2", .state = ARM_CP_STATE_BOTH, | ||
114 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 0, | ||
115 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
116 | - { .name = "CNTHP_CTL_EL2", .state = ARM_CP_STATE_BOTH, | ||
117 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 1, | ||
118 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
119 | - { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
120 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1, | ||
121 | - .access = PL2_RW, .accessfn = access_tda, | ||
122 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
123 | - { .name = "HPFAR_EL2", .state = ARM_CP_STATE_BOTH, | ||
124 | - .opc0 = 3, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 4, | ||
125 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
126 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
127 | - { .name = "HSTR_EL2", .state = ARM_CP_STATE_BOTH, | ||
128 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3, | ||
129 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
130 | - { .name = "FAR_EL2", .state = ARM_CP_STATE_BOTH, | ||
131 | - .opc0 = 3, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 0, | ||
132 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
133 | - { .name = "HIFAR", .state = ARM_CP_STATE_AA32, | ||
134 | - .type = ARM_CP_CONST, | ||
135 | - .cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 2, | ||
136 | - .access = PL2_RW, .resetvalue = 0 }, | ||
137 | -}; | ||
138 | - | 48 | - |
139 | -/* Ditto, but for registers which exist in ARMv8 but not v7 */ | 49 | - start_len = MIN(start_len, ARM_MAX_VQ - 1); |
140 | -static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { | 50 | - end_len = start_len; |
141 | - { .name = "HCR2", .state = ARM_CP_STATE_AA32, | ||
142 | - .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, | ||
143 | - .access = PL2_RW, | ||
144 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
145 | -}; | ||
146 | - | 51 | - |
147 | static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | 52 | - if (!test_bit(start_len, cpu->sve_vq_map)) { |
53 | - end_len = find_last_bit(cpu->sve_vq_map, start_len); | ||
54 | - assert(end_len < start_len); | ||
55 | - } | ||
56 | - return end_len; | ||
57 | -} | ||
58 | - | ||
59 | /* | ||
60 | * Given that SVE is enabled, return the vector length for EL. | ||
61 | */ | ||
62 | uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) | ||
148 | { | 63 | { |
149 | ARMCPU *cpu = env_archcpu(env); | 64 | ARMCPU *cpu = env_archcpu(env); |
150 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 65 | - uint32_t zcr_len = cpu->sve_max_vq - 1; |
151 | define_arm_cp_regs(cpu, v8_idregs); | 66 | + uint32_t len = cpu->sve_max_vq - 1; |
152 | define_arm_cp_regs(cpu, v8_cp_reginfo); | 67 | + uint32_t end_len; |
68 | |||
69 | if (el <= 1 && !el_is_in_host(env, el)) { | ||
70 | - zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[1]); | ||
71 | + len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[1]); | ||
153 | } | 72 | } |
154 | - if (arm_feature(env, ARM_FEATURE_EL2)) { | 73 | if (el <= 2 && arm_feature(env, ARM_FEATURE_EL2)) { |
155 | + | 74 | - zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[2]); |
156 | + /* | 75 | + len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[2]); |
157 | + * Register the base EL2 cpregs. | ||
158 | + * Pre v8, these registers are implemented only as part of the | ||
159 | + * Virtualization Extensions (EL2 present). Beginning with v8, | ||
160 | + * if EL2 is missing but EL3 is enabled, mostly these become | ||
161 | + * RES0 from EL3, with some specific exceptions. | ||
162 | + */ | ||
163 | + if (arm_feature(env, ARM_FEATURE_EL2) | ||
164 | + || (arm_feature(env, ARM_FEATURE_EL3) | ||
165 | + && arm_feature(env, ARM_FEATURE_V8))) { | ||
166 | uint64_t vmpidr_def = mpidr_read_val(env); | ||
167 | ARMCPRegInfo vpidr_regs[] = { | ||
168 | { .name = "VPIDR", .state = ARM_CP_STATE_AA32, | ||
169 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
170 | }; | ||
171 | define_one_arm_cp_reg(cpu, &rvbar); | ||
172 | } | ||
173 | - } else { | ||
174 | - /* If EL2 is missing but higher ELs are enabled, we need to | ||
175 | - * register the no_el2 reginfos. | ||
176 | - */ | ||
177 | - if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
178 | - /* When EL3 exists but not EL2, VPIDR and VMPIDR take the value | ||
179 | - * of MIDR_EL1 and MPIDR_EL1. | ||
180 | - */ | ||
181 | - ARMCPRegInfo vpidr_regs[] = { | ||
182 | - { .name = "VPIDR_EL2", .state = ARM_CP_STATE_BOTH, | ||
183 | - .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | ||
184 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
185 | - .type = ARM_CP_CONST, .resetvalue = cpu->midr, | ||
186 | - .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, | ||
187 | - { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_BOTH, | ||
188 | - .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | ||
189 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
190 | - .type = ARM_CP_NO_RAW, | ||
191 | - .writefn = arm_cp_write_ignore, .readfn = mpidr_read }, | ||
192 | - }; | ||
193 | - define_arm_cp_regs(cpu, vpidr_regs); | ||
194 | - define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo); | ||
195 | - if (arm_feature(env, ARM_FEATURE_V8)) { | ||
196 | - define_arm_cp_regs(cpu, el3_no_el2_v8_cp_reginfo); | ||
197 | - } | ||
198 | - } | ||
199 | } | 76 | } |
200 | + | ||
201 | + /* Register the base EL3 cpregs. */ | ||
202 | if (arm_feature(env, ARM_FEATURE_EL3)) { | 77 | if (arm_feature(env, ARM_FEATURE_EL3)) { |
203 | define_arm_cp_regs(cpu, el3_cp_reginfo); | 78 | - zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); |
204 | ARMCPRegInfo el3_regs[] = { | 79 | + len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[3]); |
80 | } | ||
81 | |||
82 | - return aarch64_sve_zcr_get_valid_len(cpu, zcr_len); | ||
83 | + end_len = len; | ||
84 | + if (!test_bit(len, cpu->sve_vq_map)) { | ||
85 | + end_len = find_last_bit(cpu->sve_vq_map, len); | ||
86 | + assert(end_len < len); | ||
87 | + } | ||
88 | + return end_len; | ||
89 | } | ||
90 | |||
91 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
205 | -- | 92 | -- |
206 | 2.25.1 | 93 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Previously we were defining some of these in user-only mode, | 3 | The bitmap need only hold 15 bits; bitmap is over-complicated. |
4 | but none of them are accessible from user-only, therefore | 4 | We can simplify operations quite a bit with plain logical ops. |
5 | define them only in system mode. | ||
6 | 5 | ||
7 | This will shortly be used from cpu_tcg.c also. | 6 | The introduction of SVE_VQ_POW2_MAP eliminates the need for |
7 | looping in order to search for powers of two. Simply perform | ||
8 | the logical ops and use count leading or trailing zeros as | ||
9 | required to find the result. | ||
8 | 10 | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20220506180242.216785-6-richard.henderson@linaro.org | 13 | Message-id: 20220607203306.657998-12-richard.henderson@linaro.org |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 15 | --- |
14 | target/arm/internals.h | 6 ++++ | 16 | target/arm/cpu.h | 6 +-- |
15 | target/arm/cpu64.c | 64 +++--------------------------------------- | 17 | target/arm/internals.h | 5 ++ |
16 | target/arm/cpu_tcg.c | 59 ++++++++++++++++++++++++++++++++++++++ | 18 | target/arm/kvm_arm.h | 7 ++- |
17 | 3 files changed, 69 insertions(+), 60 deletions(-) | 19 | target/arm/cpu64.c | 117 ++++++++++++++++++++--------------------- |
20 | target/arm/helper.c | 9 +--- | ||
21 | target/arm/kvm64.c | 36 +++---------- | ||
22 | 6 files changed, 75 insertions(+), 105 deletions(-) | ||
18 | 23 | ||
24 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/cpu.h | ||
27 | +++ b/target/arm/cpu.h | ||
28 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | ||
29 | * Bits set in sve_vq_supported represent valid vector lengths for | ||
30 | * the CPU type. | ||
31 | */ | ||
32 | - DECLARE_BITMAP(sve_vq_map, ARM_MAX_VQ); | ||
33 | - DECLARE_BITMAP(sve_vq_init, ARM_MAX_VQ); | ||
34 | - DECLARE_BITMAP(sve_vq_supported, ARM_MAX_VQ); | ||
35 | + uint32_t sve_vq_map; | ||
36 | + uint32_t sve_vq_init; | ||
37 | + uint32_t sve_vq_supported; | ||
38 | |||
39 | /* Generic timer counter frequency, in Hz */ | ||
40 | uint64_t gt_cntfrq_hz; | ||
19 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 41 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
20 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/internals.h | 43 | --- a/target/arm/internals.h |
22 | +++ b/target/arm/internals.h | 44 | +++ b/target/arm/internals.h |
23 | @@ -XXX,XX +XXX,XX @@ int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg); | 45 | @@ -XXX,XX +XXX,XX @@ bool el_is_in_host(CPUARMState *env, int el); |
24 | int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg); | 46 | |
25 | #endif | 47 | void aa32_max_features(ARMCPU *cpu); |
26 | 48 | ||
27 | +#ifdef CONFIG_USER_ONLY | 49 | +/* Powers of 2 for sve_vq_map et al. */ |
28 | +static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } | 50 | +#define SVE_VQ_POW2_MAP \ |
29 | +#else | 51 | + ((1 << (1 - 1)) | (1 << (2 - 1)) | \ |
30 | +void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); | 52 | + (1 << (4 - 1)) | (1 << (8 - 1)) | (1 << (16 - 1))) |
31 | +#endif | ||
32 | + | 53 | + |
33 | #endif | 54 | #endif |
55 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/kvm_arm.h | ||
58 | +++ b/target/arm/kvm_arm.h | ||
59 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf); | ||
60 | /** | ||
61 | * kvm_arm_sve_get_vls: | ||
62 | * @cs: CPUState | ||
63 | - * @map: bitmap to fill in | ||
64 | * | ||
65 | * Get all the SVE vector lengths supported by the KVM host, setting | ||
66 | * the bits corresponding to their length in quadwords minus one | ||
67 | - * (vq - 1) in @map up to ARM_MAX_VQ. | ||
68 | + * (vq - 1) up to ARM_MAX_VQ. Return the resulting map. | ||
69 | */ | ||
70 | -void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map); | ||
71 | +uint32_t kvm_arm_sve_get_vls(CPUState *cs); | ||
72 | |||
73 | /** | ||
74 | * kvm_arm_set_cpu_features_from_host: | ||
75 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp) | ||
76 | g_assert_not_reached(); | ||
77 | } | ||
78 | |||
79 | -static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) | ||
80 | +static inline uint32_t kvm_arm_sve_get_vls(CPUState *cs) | ||
81 | { | ||
82 | g_assert_not_reached(); | ||
83 | } | ||
34 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 84 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
35 | index XXXXXXX..XXXXXXX 100644 | 85 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/cpu64.c | 86 | --- a/target/arm/cpu64.c |
37 | +++ b/target/arm/cpu64.c | 87 | +++ b/target/arm/cpu64.c |
38 | @@ -XXX,XX +XXX,XX @@ | 88 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) |
39 | #include "hvf_arm.h" | 89 | * any of the above. Finally, if SVE is not disabled, then at least one |
40 | #include "qapi/visitor.h" | 90 | * vector length must be enabled. |
41 | #include "hw/qdev-properties.h" | 91 | */ |
42 | -#include "cpregs.h" | 92 | - DECLARE_BITMAP(tmp, ARM_MAX_VQ); |
43 | +#include "internals.h" | 93 | - uint32_t vq, max_vq = 0; |
44 | 94 | + uint32_t vq_map = cpu->sve_vq_map; | |
45 | 95 | + uint32_t vq_init = cpu->sve_vq_init; | |
46 | -#ifndef CONFIG_USER_ONLY | 96 | + uint32_t vq_supported; |
47 | -static uint64_t a57_a53_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 97 | + uint32_t vq_mask = 0; |
48 | -{ | 98 | + uint32_t tmp, vq, max_vq = 0; |
49 | - ARMCPU *cpu = env_archcpu(env); | 99 | |
100 | /* | ||
101 | * CPU models specify a set of supported vector lengths which are | ||
102 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
103 | * in the supported bitmap results in an error. When KVM is enabled we | ||
104 | * fetch the supported bitmap from the host. | ||
105 | */ | ||
106 | - if (kvm_enabled() && kvm_arm_sve_supported()) { | ||
107 | - kvm_arm_sve_get_vls(CPU(cpu), cpu->sve_vq_supported); | ||
108 | - } else if (kvm_enabled()) { | ||
109 | - assert(!cpu_isar_feature(aa64_sve, cpu)); | ||
110 | + if (kvm_enabled()) { | ||
111 | + if (kvm_arm_sve_supported()) { | ||
112 | + cpu->sve_vq_supported = kvm_arm_sve_get_vls(CPU(cpu)); | ||
113 | + vq_supported = cpu->sve_vq_supported; | ||
114 | + } else { | ||
115 | + assert(!cpu_isar_feature(aa64_sve, cpu)); | ||
116 | + vq_supported = 0; | ||
117 | + } | ||
118 | + } else { | ||
119 | + vq_supported = cpu->sve_vq_supported; | ||
120 | } | ||
121 | |||
122 | /* | ||
123 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
124 | * From the properties, sve_vq_map<N> implies sve_vq_init<N>. | ||
125 | * Check first for any sve<N> enabled. | ||
126 | */ | ||
127 | - if (!bitmap_empty(cpu->sve_vq_map, ARM_MAX_VQ)) { | ||
128 | - max_vq = find_last_bit(cpu->sve_vq_map, ARM_MAX_VQ) + 1; | ||
129 | + if (vq_map != 0) { | ||
130 | + max_vq = 32 - clz32(vq_map); | ||
131 | + vq_mask = MAKE_64BIT_MASK(0, max_vq); | ||
132 | |||
133 | if (cpu->sve_max_vq && max_vq > cpu->sve_max_vq) { | ||
134 | error_setg(errp, "cannot enable sve%d", max_vq * 128); | ||
135 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
136 | * For KVM we have to automatically enable all supported unitialized | ||
137 | * lengths, even when the smaller lengths are not all powers-of-two. | ||
138 | */ | ||
139 | - bitmap_andnot(tmp, cpu->sve_vq_supported, cpu->sve_vq_init, max_vq); | ||
140 | - bitmap_or(cpu->sve_vq_map, cpu->sve_vq_map, tmp, max_vq); | ||
141 | + vq_map |= vq_supported & ~vq_init & vq_mask; | ||
142 | } else { | ||
143 | /* Propagate enabled bits down through required powers-of-two. */ | ||
144 | - for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { | ||
145 | - if (!test_bit(vq - 1, cpu->sve_vq_init)) { | ||
146 | - set_bit(vq - 1, cpu->sve_vq_map); | ||
147 | - } | ||
148 | - } | ||
149 | + vq_map |= SVE_VQ_POW2_MAP & ~vq_init & vq_mask; | ||
150 | } | ||
151 | } else if (cpu->sve_max_vq == 0) { | ||
152 | /* | ||
153 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
154 | |||
155 | if (kvm_enabled()) { | ||
156 | /* Disabling a supported length disables all larger lengths. */ | ||
157 | - for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { | ||
158 | - if (test_bit(vq - 1, cpu->sve_vq_init) && | ||
159 | - test_bit(vq - 1, cpu->sve_vq_supported)) { | ||
160 | - break; | ||
161 | - } | ||
162 | - } | ||
163 | + tmp = vq_init & vq_supported; | ||
164 | } else { | ||
165 | /* Disabling a power-of-two disables all larger lengths. */ | ||
166 | - for (vq = 1; vq <= ARM_MAX_VQ; vq <<= 1) { | ||
167 | - if (test_bit(vq - 1, cpu->sve_vq_init)) { | ||
168 | - break; | ||
169 | - } | ||
170 | - } | ||
171 | + tmp = vq_init & SVE_VQ_POW2_MAP; | ||
172 | } | ||
173 | + vq = ctz32(tmp) + 1; | ||
174 | |||
175 | max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; | ||
176 | - bitmap_andnot(cpu->sve_vq_map, cpu->sve_vq_supported, | ||
177 | - cpu->sve_vq_init, max_vq); | ||
178 | - if (max_vq == 0 || bitmap_empty(cpu->sve_vq_map, max_vq)) { | ||
179 | + vq_mask = MAKE_64BIT_MASK(0, max_vq); | ||
180 | + vq_map = vq_supported & ~vq_init & vq_mask; | ||
181 | + | ||
182 | + if (max_vq == 0 || vq_map == 0) { | ||
183 | error_setg(errp, "cannot disable sve%d", vq * 128); | ||
184 | error_append_hint(errp, "Disabling sve%d results in all " | ||
185 | "vector lengths being disabled.\n", | ||
186 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
187 | return; | ||
188 | } | ||
189 | |||
190 | - max_vq = find_last_bit(cpu->sve_vq_map, max_vq) + 1; | ||
191 | + max_vq = 32 - clz32(vq_map); | ||
192 | + vq_mask = MAKE_64BIT_MASK(0, max_vq); | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
197 | */ | ||
198 | if (cpu->sve_max_vq != 0) { | ||
199 | max_vq = cpu->sve_max_vq; | ||
200 | + vq_mask = MAKE_64BIT_MASK(0, max_vq); | ||
201 | |||
202 | - if (!test_bit(max_vq - 1, cpu->sve_vq_map) && | ||
203 | - test_bit(max_vq - 1, cpu->sve_vq_init)) { | ||
204 | + if (vq_init & ~vq_map & (1 << (max_vq - 1))) { | ||
205 | error_setg(errp, "cannot disable sve%d", max_vq * 128); | ||
206 | error_append_hint(errp, "The maximum vector length must be " | ||
207 | "enabled, sve-max-vq=%d (%d bits)\n", | ||
208 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
209 | } | ||
210 | |||
211 | /* Set all bits not explicitly set within sve-max-vq. */ | ||
212 | - bitmap_complement(tmp, cpu->sve_vq_init, max_vq); | ||
213 | - bitmap_or(cpu->sve_vq_map, cpu->sve_vq_map, tmp, max_vq); | ||
214 | + vq_map |= ~vq_init & vq_mask; | ||
215 | } | ||
216 | |||
217 | /* | ||
218 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
219 | * are clear, just in case anybody looks. | ||
220 | */ | ||
221 | assert(max_vq != 0); | ||
222 | - bitmap_clear(cpu->sve_vq_map, max_vq, ARM_MAX_VQ - max_vq); | ||
223 | + assert(vq_mask != 0); | ||
224 | + vq_map &= vq_mask; | ||
225 | |||
226 | /* Ensure the set of lengths matches what is supported. */ | ||
227 | - bitmap_xor(tmp, cpu->sve_vq_map, cpu->sve_vq_supported, max_vq); | ||
228 | - if (!bitmap_empty(tmp, max_vq)) { | ||
229 | - vq = find_last_bit(tmp, max_vq) + 1; | ||
230 | - if (test_bit(vq - 1, cpu->sve_vq_map)) { | ||
231 | + tmp = vq_map ^ (vq_supported & vq_mask); | ||
232 | + if (tmp) { | ||
233 | + vq = 32 - clz32(tmp); | ||
234 | + if (vq_map & (1 << (vq - 1))) { | ||
235 | if (cpu->sve_max_vq) { | ||
236 | error_setg(errp, "cannot set sve-max-vq=%d", cpu->sve_max_vq); | ||
237 | error_append_hint(errp, "This CPU does not support " | ||
238 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
239 | return; | ||
240 | } else { | ||
241 | /* Ensure all required powers-of-two are enabled. */ | ||
242 | - for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { | ||
243 | - if (!test_bit(vq - 1, cpu->sve_vq_map)) { | ||
244 | - error_setg(errp, "cannot disable sve%d", vq * 128); | ||
245 | - error_append_hint(errp, "sve%d is required as it " | ||
246 | - "is a power-of-two length smaller " | ||
247 | - "than the maximum, sve%d\n", | ||
248 | - vq * 128, max_vq * 128); | ||
249 | - return; | ||
250 | - } | ||
251 | + tmp = SVE_VQ_POW2_MAP & vq_mask & ~vq_map; | ||
252 | + if (tmp) { | ||
253 | + vq = 32 - clz32(tmp); | ||
254 | + error_setg(errp, "cannot disable sve%d", vq * 128); | ||
255 | + error_append_hint(errp, "sve%d is required as it " | ||
256 | + "is a power-of-two length smaller " | ||
257 | + "than the maximum, sve%d\n", | ||
258 | + vq * 128, max_vq * 128); | ||
259 | + return; | ||
260 | } | ||
261 | } | ||
262 | } | ||
263 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
264 | |||
265 | /* From now on sve_max_vq is the actual maximum supported length. */ | ||
266 | cpu->sve_max_vq = max_vq; | ||
267 | + cpu->sve_vq_map = vq_map; | ||
268 | } | ||
269 | |||
270 | static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name, | ||
271 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, | ||
272 | if (!cpu_isar_feature(aa64_sve, cpu)) { | ||
273 | value = false; | ||
274 | } else { | ||
275 | - value = test_bit(vq - 1, cpu->sve_vq_map); | ||
276 | + value = extract32(cpu->sve_vq_map, vq - 1, 1); | ||
277 | } | ||
278 | visit_type_bool(v, name, &value, errp); | ||
279 | } | ||
280 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
281 | return; | ||
282 | } | ||
283 | |||
284 | - if (value) { | ||
285 | - set_bit(vq - 1, cpu->sve_vq_map); | ||
286 | - } else { | ||
287 | - clear_bit(vq - 1, cpu->sve_vq_map); | ||
288 | - } | ||
289 | - set_bit(vq - 1, cpu->sve_vq_init); | ||
290 | + cpu->sve_vq_map = deposit32(cpu->sve_vq_map, vq - 1, 1, value); | ||
291 | + cpu->sve_vq_init |= 1 << (vq - 1); | ||
292 | } | ||
293 | |||
294 | static bool cpu_arm_get_sve(Object *obj, Error **errp) | ||
295 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
296 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
297 | #endif | ||
298 | |||
299 | - bitmap_fill(cpu->sve_vq_supported, ARM_MAX_VQ); | ||
300 | + cpu->sve_vq_supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); | ||
301 | |||
302 | aarch64_add_pauth_properties(obj); | ||
303 | aarch64_add_sve_properties(obj); | ||
304 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj) | ||
305 | cpu->gic_vprebits = 5; | ||
306 | cpu->gic_pribits = 5; | ||
307 | |||
308 | - /* Suppport of A64FX's vector length are 128,256 and 512bit only */ | ||
309 | + /* The A64FX supports only 128, 256 and 512 bit vector lengths */ | ||
310 | aarch64_add_sve_properties(obj); | ||
311 | - bitmap_zero(cpu->sve_vq_supported, ARM_MAX_VQ); | ||
312 | - set_bit(0, cpu->sve_vq_supported); /* 128bit */ | ||
313 | - set_bit(1, cpu->sve_vq_supported); /* 256bit */ | ||
314 | - set_bit(3, cpu->sve_vq_supported); /* 512bit */ | ||
315 | + cpu->sve_vq_supported = (1 << 0) /* 128bit */ | ||
316 | + | (1 << 1) /* 256bit */ | ||
317 | + | (1 << 3); /* 512bit */ | ||
318 | |||
319 | cpu->isar.reset_pmcr_el0 = 0x46014040; | ||
320 | |||
321 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
322 | index XXXXXXX..XXXXXXX 100644 | ||
323 | --- a/target/arm/helper.c | ||
324 | +++ b/target/arm/helper.c | ||
325 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) | ||
326 | { | ||
327 | ARMCPU *cpu = env_archcpu(env); | ||
328 | uint32_t len = cpu->sve_max_vq - 1; | ||
329 | - uint32_t end_len; | ||
330 | |||
331 | if (el <= 1 && !el_is_in_host(env, el)) { | ||
332 | len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[1]); | ||
333 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) | ||
334 | len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[3]); | ||
335 | } | ||
336 | |||
337 | - end_len = len; | ||
338 | - if (!test_bit(len, cpu->sve_vq_map)) { | ||
339 | - end_len = find_last_bit(cpu->sve_vq_map, len); | ||
340 | - assert(end_len < len); | ||
341 | - } | ||
342 | - return end_len; | ||
343 | + len = 31 - clz32(cpu->sve_vq_map & MAKE_64BIT_MASK(0, len + 1)); | ||
344 | + return len; | ||
345 | } | ||
346 | |||
347 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
348 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
349 | index XXXXXXX..XXXXXXX 100644 | ||
350 | --- a/target/arm/kvm64.c | ||
351 | +++ b/target/arm/kvm64.c | ||
352 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_steal_time_supported(void) | ||
353 | |||
354 | QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN != 1); | ||
355 | |||
356 | -void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) | ||
357 | +uint32_t kvm_arm_sve_get_vls(CPUState *cs) | ||
358 | { | ||
359 | /* Only call this function if kvm_arm_sve_supported() returns true. */ | ||
360 | static uint64_t vls[KVM_ARM64_SVE_VLS_WORDS]; | ||
361 | static bool probed; | ||
362 | uint32_t vq = 0; | ||
363 | - int i, j; | ||
50 | - | 364 | - |
51 | - /* Number of cores is in [25:24]; otherwise we RAZ */ | 365 | - bitmap_zero(map, ARM_MAX_VQ); |
52 | - return (cpu->core_count - 1) << 24; | 366 | + int i; |
53 | -} | 367 | |
54 | -#endif | 368 | /* |
369 | * KVM ensures all host CPUs support the same set of vector lengths. | ||
370 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) | ||
371 | if (vq > ARM_MAX_VQ) { | ||
372 | warn_report("KVM supports vector lengths larger than " | ||
373 | "QEMU can enable"); | ||
374 | + vls[0] &= MAKE_64BIT_MASK(0, ARM_MAX_VQ); | ||
375 | } | ||
376 | } | ||
377 | |||
378 | - for (i = 0; i < KVM_ARM64_SVE_VLS_WORDS; ++i) { | ||
379 | - if (!vls[i]) { | ||
380 | - continue; | ||
381 | - } | ||
382 | - for (j = 1; j <= 64; ++j) { | ||
383 | - vq = j + i * 64; | ||
384 | - if (vq > ARM_MAX_VQ) { | ||
385 | - return; | ||
386 | - } | ||
387 | - if (vls[i] & (1UL << (j - 1))) { | ||
388 | - set_bit(vq - 1, map); | ||
389 | - } | ||
390 | - } | ||
391 | - } | ||
392 | + return vls[0]; | ||
393 | } | ||
394 | |||
395 | static int kvm_arm_sve_set_vls(CPUState *cs) | ||
396 | { | ||
397 | - uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = {0}; | ||
398 | + ARMCPU *cpu = ARM_CPU(cs); | ||
399 | + uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq_map }; | ||
400 | struct kvm_one_reg reg = { | ||
401 | .id = KVM_REG_ARM64_SVE_VLS, | ||
402 | .addr = (uint64_t)&vls[0], | ||
403 | }; | ||
404 | - ARMCPU *cpu = ARM_CPU(cs); | ||
405 | - uint32_t vq; | ||
406 | - int i, j; | ||
407 | |||
408 | assert(cpu->sve_max_vq <= KVM_ARM64_SVE_VQ_MAX); | ||
409 | |||
410 | - for (vq = 1; vq <= cpu->sve_max_vq; ++vq) { | ||
411 | - if (test_bit(vq - 1, cpu->sve_vq_map)) { | ||
412 | - i = (vq - 1) / 64; | ||
413 | - j = (vq - 1) % 64; | ||
414 | - vls[i] |= 1UL << j; | ||
415 | - } | ||
416 | - } | ||
55 | - | 417 | - |
56 | -static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { | 418 | return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); |
57 | -#ifndef CONFIG_USER_ONLY | 419 | } |
58 | - { .name = "L2CTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
59 | - .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 2, | ||
60 | - .access = PL1_RW, .readfn = a57_a53_l2ctlr_read, | ||
61 | - .writefn = arm_cp_write_ignore }, | ||
62 | - { .name = "L2CTLR", | ||
63 | - .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 2, | ||
64 | - .access = PL1_RW, .readfn = a57_a53_l2ctlr_read, | ||
65 | - .writefn = arm_cp_write_ignore }, | ||
66 | -#endif | ||
67 | - { .name = "L2ECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
68 | - .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 3, | ||
69 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
70 | - { .name = "L2ECTLR", | ||
71 | - .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 3, | ||
72 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
73 | - { .name = "L2ACTLR", .state = ARM_CP_STATE_BOTH, | ||
74 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 0, .opc2 = 0, | ||
75 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
76 | - { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
77 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 0, | ||
78 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
79 | - { .name = "CPUACTLR", | ||
80 | - .cp = 15, .opc1 = 0, .crm = 15, | ||
81 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
82 | - { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
83 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 1, | ||
84 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
85 | - { .name = "CPUECTLR", | ||
86 | - .cp = 15, .opc1 = 1, .crm = 15, | ||
87 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
88 | - { .name = "CPUMERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
89 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 2, | ||
90 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
91 | - { .name = "CPUMERRSR", | ||
92 | - .cp = 15, .opc1 = 2, .crm = 15, | ||
93 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
94 | - { .name = "L2MERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
95 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 3, | ||
96 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
97 | - { .name = "L2MERRSR", | ||
98 | - .cp = 15, .opc1 = 3, .crm = 15, | ||
99 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
100 | -}; | ||
101 | - | ||
102 | static void aarch64_a57_initfn(Object *obj) | ||
103 | { | ||
104 | ARMCPU *cpu = ARM_CPU(obj); | ||
105 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
106 | cpu->gic_num_lrs = 4; | ||
107 | cpu->gic_vpribits = 5; | ||
108 | cpu->gic_vprebits = 5; | ||
109 | - define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
110 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
111 | } | ||
112 | |||
113 | static void aarch64_a53_initfn(Object *obj) | ||
114 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
115 | cpu->gic_num_lrs = 4; | ||
116 | cpu->gic_vpribits = 5; | ||
117 | cpu->gic_vprebits = 5; | ||
118 | - define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
119 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
120 | } | ||
121 | |||
122 | static void aarch64_a72_initfn(Object *obj) | ||
123 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
124 | cpu->gic_num_lrs = 4; | ||
125 | cpu->gic_vpribits = 5; | ||
126 | cpu->gic_vprebits = 5; | ||
127 | - define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
128 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
129 | } | ||
130 | |||
131 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
132 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
133 | index XXXXXXX..XXXXXXX 100644 | ||
134 | --- a/target/arm/cpu_tcg.c | ||
135 | +++ b/target/arm/cpu_tcg.c | ||
136 | @@ -XXX,XX +XXX,XX @@ | ||
137 | #endif | ||
138 | #include "cpregs.h" | ||
139 | |||
140 | +#ifndef CONFIG_USER_ONLY | ||
141 | +static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
142 | +{ | ||
143 | + ARMCPU *cpu = env_archcpu(env); | ||
144 | + | ||
145 | + /* Number of cores is in [25:24]; otherwise we RAZ */ | ||
146 | + return (cpu->core_count - 1) << 24; | ||
147 | +} | ||
148 | + | ||
149 | +static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { | ||
150 | + { .name = "L2CTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
151 | + .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 2, | ||
152 | + .access = PL1_RW, .readfn = l2ctlr_read, | ||
153 | + .writefn = arm_cp_write_ignore }, | ||
154 | + { .name = "L2CTLR", | ||
155 | + .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 2, | ||
156 | + .access = PL1_RW, .readfn = l2ctlr_read, | ||
157 | + .writefn = arm_cp_write_ignore }, | ||
158 | + { .name = "L2ECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
159 | + .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 3, | ||
160 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
161 | + { .name = "L2ECTLR", | ||
162 | + .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 3, | ||
163 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
164 | + { .name = "L2ACTLR", .state = ARM_CP_STATE_BOTH, | ||
165 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 0, .opc2 = 0, | ||
166 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
167 | + { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
168 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 0, | ||
169 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
170 | + { .name = "CPUACTLR", | ||
171 | + .cp = 15, .opc1 = 0, .crm = 15, | ||
172 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
173 | + { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
174 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 1, | ||
175 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
176 | + { .name = "CPUECTLR", | ||
177 | + .cp = 15, .opc1 = 1, .crm = 15, | ||
178 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
179 | + { .name = "CPUMERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
180 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 2, | ||
181 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
182 | + { .name = "CPUMERRSR", | ||
183 | + .cp = 15, .opc1 = 2, .crm = 15, | ||
184 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
185 | + { .name = "L2MERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
186 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 3, | ||
187 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
188 | + { .name = "L2MERRSR", | ||
189 | + .cp = 15, .opc1 = 3, .crm = 15, | ||
190 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
191 | +}; | ||
192 | + | ||
193 | +void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) | ||
194 | +{ | ||
195 | + define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
196 | +} | ||
197 | +#endif /* !CONFIG_USER_ONLY */ | ||
198 | + | ||
199 | /* CPU models. These are not needed for the AArch64 linux-user build. */ | ||
200 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
201 | 420 | ||
202 | -- | 421 | -- |
203 | 2.25.1 | 422 | 2.25.1 | 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 only portion of FEAT_Debugv8p2 that is relevant to QEMU | 3 | This will be used for both Normal and Streaming SVE, and the value |
4 | is CONTEXTIDR_EL2, which is also conditionally implemented | 4 | does not necessarily come from ZCR_ELx. While we're at it, emphasize |
5 | with FEAT_VHE. The rest of the debug extension concerns the | 5 | the units in which the value is returned. |
6 | External debug interface, which is outside the scope of QEMU. | 6 | |
7 | Patch produced by | ||
8 | git grep -l sve_zcr_len_for_el | \ | ||
9 | xargs -n1 sed -i 's/sve_zcr_len_for_el/sve_vqm1_for_el/g' | ||
10 | |||
11 | and then adding a function comment. | ||
7 | 12 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20220506180242.216785-12-richard.henderson@linaro.org | 15 | Message-id: 20220607203306.657998-13-richard.henderson@linaro.org |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 17 | --- |
13 | docs/system/arm/emulation.rst | 1 + | 18 | target/arm/cpu.h | 11 ++++++++++- |
14 | target/arm/cpu.c | 1 + | 19 | target/arm/arch_dump.c | 2 +- |
15 | target/arm/cpu64.c | 1 + | 20 | target/arm/cpu.c | 2 +- |
16 | target/arm/cpu_tcg.c | 2 ++ | 21 | target/arm/gdbstub64.c | 2 +- |
17 | 4 files changed, 5 insertions(+) | 22 | target/arm/helper.c | 12 ++++++------ |
23 | 5 files changed, 19 insertions(+), 10 deletions(-) | ||
18 | 24 | ||
19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 25 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
20 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/docs/system/arm/emulation.rst | 27 | --- a/target/arm/cpu.h |
22 | +++ b/docs/system/arm/emulation.rst | 28 | +++ b/target/arm/cpu.h |
23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 29 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env); |
24 | - FEAT_BTI (Branch Target Identification) | 30 | |
25 | - FEAT_DIT (Data Independent Timing instructions) | 31 | int fp_exception_el(CPUARMState *env, int cur_el); |
26 | - FEAT_DPB (DC CVAP instruction) | 32 | int sve_exception_el(CPUARMState *env, int cur_el); |
27 | +- FEAT_Debugv8p2 (Debug changes for v8.2) | 33 | -uint32_t sve_zcr_len_for_el(CPUARMState *env, int el); |
28 | - FEAT_DotProd (Advanced SIMD dot product instructions) | 34 | + |
29 | - FEAT_FCMA (Floating-point complex number instructions) | 35 | +/** |
30 | - FEAT_FHM (Floating-point half-precision multiplication instructions) | 36 | + * sve_vqm1_for_el: |
37 | + * @env: CPUARMState | ||
38 | + * @el: exception level | ||
39 | + * | ||
40 | + * Compute the current SVE vector length for @el, in units of | ||
41 | + * Quadwords Minus 1 -- the same scale used for ZCR_ELx.LEN. | ||
42 | + */ | ||
43 | +uint32_t sve_vqm1_for_el(CPUARMState *env, int el); | ||
44 | |||
45 | static inline bool is_a64(CPUARMState *env) | ||
46 | { | ||
47 | diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/arch_dump.c | ||
50 | +++ b/target/arm/arch_dump.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static off_t sve_fpcr_offset(uint32_t vq) | ||
52 | |||
53 | static uint32_t sve_current_vq(CPUARMState *env) | ||
54 | { | ||
55 | - return sve_zcr_len_for_el(env, arm_current_el(env)) + 1; | ||
56 | + return sve_vqm1_for_el(env, arm_current_el(env)) + 1; | ||
57 | } | ||
58 | |||
59 | static size_t sve_size_vq(uint32_t vq) | ||
31 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 60 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
32 | index XXXXXXX..XXXXXXX 100644 | 61 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/target/arm/cpu.c | 62 | --- a/target/arm/cpu.c |
34 | +++ b/target/arm/cpu.c | 63 | +++ b/target/arm/cpu.c |
35 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 64 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
36 | * feature registers as well. | 65 | vfp_get_fpcr(env), vfp_get_fpsr(env)); |
66 | |||
67 | if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) { | ||
68 | - int j, zcr_len = sve_zcr_len_for_el(env, el); | ||
69 | + int j, zcr_len = sve_vqm1_for_el(env, el); | ||
70 | |||
71 | for (i = 0; i <= FFR_PRED_NUM; i++) { | ||
72 | bool eol; | ||
73 | diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/arm/gdbstub64.c | ||
76 | +++ b/target/arm/gdbstub64.c | ||
77 | @@ -XXX,XX +XXX,XX @@ int arm_gdb_get_svereg(CPUARMState *env, GByteArray *buf, int reg) | ||
78 | * We report in Vector Granules (VG) which is 64bit in a Z reg | ||
79 | * while the ZCR works in Vector Quads (VQ) which is 128bit chunks. | ||
37 | */ | 80 | */ |
38 | cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1, ID_PFR1, SECURITY, 0); | 81 | - int vq = sve_zcr_len_for_el(env, arm_current_el(env)) + 1; |
39 | + cpu->isar.id_dfr0 = FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, COPSDBG, 0); | 82 | + int vq = sve_vqm1_for_el(env, arm_current_el(env)) + 1; |
40 | cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0, | 83 | return gdb_get_reg64(buf, vq * 2); |
41 | ID_AA64PFR0, EL3, 0); | ||
42 | } | 84 | } |
43 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 85 | default: |
86 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | 87 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/target/arm/cpu64.c | 88 | --- a/target/arm/helper.c |
46 | +++ b/target/arm/cpu64.c | 89 | +++ b/target/arm/helper.c |
47 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 90 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) |
48 | cpu->isar.id_aa64zfr0 = t; | 91 | /* |
49 | 92 | * Given that SVE is enabled, return the vector length for EL. | |
50 | t = cpu->isar.id_aa64dfr0; | 93 | */ |
51 | + t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 8); /* FEAT_Debugv8p2 */ | 94 | -uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) |
52 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */ | 95 | +uint32_t sve_vqm1_for_el(CPUARMState *env, int el) |
53 | cpu->isar.id_aa64dfr0 = t; | 96 | { |
54 | 97 | ARMCPU *cpu = env_archcpu(env); | |
55 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 98 | uint32_t len = cpu->sve_max_vq - 1; |
56 | index XXXXXXX..XXXXXXX 100644 | 99 | @@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
57 | --- a/target/arm/cpu_tcg.c | 100 | uint64_t value) |
58 | +++ b/target/arm/cpu_tcg.c | 101 | { |
59 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | 102 | int cur_el = arm_current_el(env); |
60 | cpu->isar.id_pfr2 = t; | 103 | - int old_len = sve_zcr_len_for_el(env, cur_el); |
61 | 104 | + int old_len = sve_vqm1_for_el(env, cur_el); | |
62 | t = cpu->isar.id_dfr0; | 105 | int new_len; |
63 | + t = FIELD_DP32(t, ID_DFR0, COPDBG, 8); /* FEAT_Debugv8p2 */ | 106 | |
64 | + t = FIELD_DP32(t, ID_DFR0, COPSDBG, 8); /* FEAT_Debugv8p2 */ | 107 | /* Bits other than [3:0] are RAZ/WI. */ |
65 | t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */ | 108 | @@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
66 | cpu->isar.id_dfr0 = t; | 109 | * Because we arrived here, we know both FP and SVE are enabled; |
67 | } | 110 | * otherwise we would have trapped access to the ZCR_ELn register. |
111 | */ | ||
112 | - new_len = sve_zcr_len_for_el(env, cur_el); | ||
113 | + new_len = sve_vqm1_for_el(env, cur_el); | ||
114 | if (new_len < old_len) { | ||
115 | aarch64_sve_narrow_vq(env, new_len + 1); | ||
116 | } | ||
117 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
118 | sve_el = 0; | ||
119 | } | ||
120 | } else if (sve_el == 0) { | ||
121 | - DP_TBFLAG_A64(flags, VL, sve_zcr_len_for_el(env, el)); | ||
122 | + DP_TBFLAG_A64(flags, VL, sve_vqm1_for_el(env, el)); | ||
123 | } | ||
124 | DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); | ||
125 | } | ||
126 | @@ -XXX,XX +XXX,XX @@ void aarch64_sve_change_el(CPUARMState *env, int old_el, | ||
127 | */ | ||
128 | old_a64 = old_el ? arm_el_is_aa64(env, old_el) : el0_a64; | ||
129 | old_len = (old_a64 && !sve_exception_el(env, old_el) | ||
130 | - ? sve_zcr_len_for_el(env, old_el) : 0); | ||
131 | + ? sve_vqm1_for_el(env, old_el) : 0); | ||
132 | new_a64 = new_el ? arm_el_is_aa64(env, new_el) : el0_a64; | ||
133 | new_len = (new_a64 && !sve_exception_el(env, new_el) | ||
134 | - ? sve_zcr_len_for_el(env, new_el) : 0); | ||
135 | + ? sve_vqm1_for_el(env, new_el) : 0); | ||
136 | |||
137 | /* When changing vector length, clear inaccessible state. */ | ||
138 | if (new_len < old_len) { | ||
68 | -- | 139 | -- |
69 | 2.25.1 | 140 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This extension concerns changes to the External Debug interface, | 3 | Begin creation of sve_ldst_internal.h by moving the primitives |
4 | with Secure and Non-secure access to the debug registers, and all | 4 | that access host and tlb memory. |
5 | of it is outside the scope of QEMU. Indicating support for this | ||
6 | is mandatory with FEAT_SEL2, which we do implement. | ||
7 | 5 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20220506180242.216785-13-richard.henderson@linaro.org | 8 | Message-id: 20220607203306.657998-14-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 | docs/system/arm/emulation.rst | 1 + | 11 | target/arm/sve_ldst_internal.h | 127 +++++++++++++++++++++++++++++++++ |
14 | target/arm/cpu64.c | 2 +- | 12 | target/arm/sve_helper.c | 107 +-------------------------- |
15 | target/arm/cpu_tcg.c | 4 ++-- | 13 | 2 files changed, 128 insertions(+), 106 deletions(-) |
16 | 3 files changed, 4 insertions(+), 3 deletions(-) | 14 | create mode 100644 target/arm/sve_ldst_internal.h |
17 | 15 | ||
18 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 16 | diff --git a/target/arm/sve_ldst_internal.h b/target/arm/sve_ldst_internal.h |
17 | new file mode 100644 | ||
18 | index XXXXXXX..XXXXXXX | ||
19 | --- /dev/null | ||
20 | +++ b/target/arm/sve_ldst_internal.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | +/* | ||
23 | + * ARM SVE Load/Store Helpers | ||
24 | + * | ||
25 | + * Copyright (c) 2018-2022 Linaro | ||
26 | + * | ||
27 | + * This library is free software; you can redistribute it and/or | ||
28 | + * modify it under the terms of the GNU Lesser General Public | ||
29 | + * License as published by the Free Software Foundation; either | ||
30 | + * version 2.1 of the License, or (at your option) any later version. | ||
31 | + * | ||
32 | + * This library is distributed in the hope that it will be useful, | ||
33 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
34 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
35 | + * Lesser General Public License for more details. | ||
36 | + * | ||
37 | + * You should have received a copy of the GNU Lesser General Public | ||
38 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
39 | + */ | ||
40 | + | ||
41 | +#ifndef TARGET_ARM_SVE_LDST_INTERNAL_H | ||
42 | +#define TARGET_ARM_SVE_LDST_INTERNAL_H | ||
43 | + | ||
44 | +#include "exec/cpu_ldst.h" | ||
45 | + | ||
46 | +/* | ||
47 | + * Load one element into @vd + @reg_off from @host. | ||
48 | + * The controlling predicate is known to be true. | ||
49 | + */ | ||
50 | +typedef void sve_ldst1_host_fn(void *vd, intptr_t reg_off, void *host); | ||
51 | + | ||
52 | +/* | ||
53 | + * Load one element into @vd + @reg_off from (@env, @vaddr, @ra). | ||
54 | + * The controlling predicate is known to be true. | ||
55 | + */ | ||
56 | +typedef void sve_ldst1_tlb_fn(CPUARMState *env, void *vd, intptr_t reg_off, | ||
57 | + target_ulong vaddr, uintptr_t retaddr); | ||
58 | + | ||
59 | +/* | ||
60 | + * Generate the above primitives. | ||
61 | + */ | ||
62 | + | ||
63 | +#define DO_LD_HOST(NAME, H, TYPEE, TYPEM, HOST) \ | ||
64 | +static inline void sve_##NAME##_host(void *vd, intptr_t reg_off, void *host) \ | ||
65 | +{ TYPEM val = HOST(host); *(TYPEE *)(vd + H(reg_off)) = val; } | ||
66 | + | ||
67 | +#define DO_ST_HOST(NAME, H, TYPEE, TYPEM, HOST) \ | ||
68 | +static inline void sve_##NAME##_host(void *vd, intptr_t reg_off, void *host) \ | ||
69 | +{ TYPEM val = *(TYPEE *)(vd + H(reg_off)); HOST(host, val); } | ||
70 | + | ||
71 | +#define DO_LD_TLB(NAME, H, TYPEE, TYPEM, TLB) \ | ||
72 | +static inline void sve_##NAME##_tlb(CPUARMState *env, void *vd, \ | ||
73 | + intptr_t reg_off, target_ulong addr, uintptr_t ra) \ | ||
74 | +{ \ | ||
75 | + TYPEM val = TLB(env, useronly_clean_ptr(addr), ra); \ | ||
76 | + *(TYPEE *)(vd + H(reg_off)) = val; \ | ||
77 | +} | ||
78 | + | ||
79 | +#define DO_ST_TLB(NAME, H, TYPEE, TYPEM, TLB) \ | ||
80 | +static inline void sve_##NAME##_tlb(CPUARMState *env, void *vd, \ | ||
81 | + intptr_t reg_off, target_ulong addr, uintptr_t ra) \ | ||
82 | +{ \ | ||
83 | + TYPEM val = *(TYPEE *)(vd + H(reg_off)); \ | ||
84 | + TLB(env, useronly_clean_ptr(addr), val, ra); \ | ||
85 | +} | ||
86 | + | ||
87 | +#define DO_LD_PRIM_1(NAME, H, TE, TM) \ | ||
88 | + DO_LD_HOST(NAME, H, TE, TM, ldub_p) \ | ||
89 | + DO_LD_TLB(NAME, H, TE, TM, cpu_ldub_data_ra) | ||
90 | + | ||
91 | +DO_LD_PRIM_1(ld1bb, H1, uint8_t, uint8_t) | ||
92 | +DO_LD_PRIM_1(ld1bhu, H1_2, uint16_t, uint8_t) | ||
93 | +DO_LD_PRIM_1(ld1bhs, H1_2, uint16_t, int8_t) | ||
94 | +DO_LD_PRIM_1(ld1bsu, H1_4, uint32_t, uint8_t) | ||
95 | +DO_LD_PRIM_1(ld1bss, H1_4, uint32_t, int8_t) | ||
96 | +DO_LD_PRIM_1(ld1bdu, H1_8, uint64_t, uint8_t) | ||
97 | +DO_LD_PRIM_1(ld1bds, H1_8, uint64_t, int8_t) | ||
98 | + | ||
99 | +#define DO_ST_PRIM_1(NAME, H, TE, TM) \ | ||
100 | + DO_ST_HOST(st1##NAME, H, TE, TM, stb_p) \ | ||
101 | + DO_ST_TLB(st1##NAME, H, TE, TM, cpu_stb_data_ra) | ||
102 | + | ||
103 | +DO_ST_PRIM_1(bb, H1, uint8_t, uint8_t) | ||
104 | +DO_ST_PRIM_1(bh, H1_2, uint16_t, uint8_t) | ||
105 | +DO_ST_PRIM_1(bs, H1_4, uint32_t, uint8_t) | ||
106 | +DO_ST_PRIM_1(bd, H1_8, uint64_t, uint8_t) | ||
107 | + | ||
108 | +#define DO_LD_PRIM_2(NAME, H, TE, TM, LD) \ | ||
109 | + DO_LD_HOST(ld1##NAME##_be, H, TE, TM, LD##_be_p) \ | ||
110 | + DO_LD_HOST(ld1##NAME##_le, H, TE, TM, LD##_le_p) \ | ||
111 | + DO_LD_TLB(ld1##NAME##_be, H, TE, TM, cpu_##LD##_be_data_ra) \ | ||
112 | + DO_LD_TLB(ld1##NAME##_le, H, TE, TM, cpu_##LD##_le_data_ra) | ||
113 | + | ||
114 | +#define DO_ST_PRIM_2(NAME, H, TE, TM, ST) \ | ||
115 | + DO_ST_HOST(st1##NAME##_be, H, TE, TM, ST##_be_p) \ | ||
116 | + DO_ST_HOST(st1##NAME##_le, H, TE, TM, ST##_le_p) \ | ||
117 | + DO_ST_TLB(st1##NAME##_be, H, TE, TM, cpu_##ST##_be_data_ra) \ | ||
118 | + DO_ST_TLB(st1##NAME##_le, H, TE, TM, cpu_##ST##_le_data_ra) | ||
119 | + | ||
120 | +DO_LD_PRIM_2(hh, H1_2, uint16_t, uint16_t, lduw) | ||
121 | +DO_LD_PRIM_2(hsu, H1_4, uint32_t, uint16_t, lduw) | ||
122 | +DO_LD_PRIM_2(hss, H1_4, uint32_t, int16_t, lduw) | ||
123 | +DO_LD_PRIM_2(hdu, H1_8, uint64_t, uint16_t, lduw) | ||
124 | +DO_LD_PRIM_2(hds, H1_8, uint64_t, int16_t, lduw) | ||
125 | + | ||
126 | +DO_ST_PRIM_2(hh, H1_2, uint16_t, uint16_t, stw) | ||
127 | +DO_ST_PRIM_2(hs, H1_4, uint32_t, uint16_t, stw) | ||
128 | +DO_ST_PRIM_2(hd, H1_8, uint64_t, uint16_t, stw) | ||
129 | + | ||
130 | +DO_LD_PRIM_2(ss, H1_4, uint32_t, uint32_t, ldl) | ||
131 | +DO_LD_PRIM_2(sdu, H1_8, uint64_t, uint32_t, ldl) | ||
132 | +DO_LD_PRIM_2(sds, H1_8, uint64_t, int32_t, ldl) | ||
133 | + | ||
134 | +DO_ST_PRIM_2(ss, H1_4, uint32_t, uint32_t, stl) | ||
135 | +DO_ST_PRIM_2(sd, H1_8, uint64_t, uint32_t, stl) | ||
136 | + | ||
137 | +DO_LD_PRIM_2(dd, H1_8, uint64_t, uint64_t, ldq) | ||
138 | +DO_ST_PRIM_2(dd, H1_8, uint64_t, uint64_t, stq) | ||
139 | + | ||
140 | +#undef DO_LD_TLB | ||
141 | +#undef DO_ST_TLB | ||
142 | +#undef DO_LD_HOST | ||
143 | +#undef DO_LD_PRIM_1 | ||
144 | +#undef DO_ST_PRIM_1 | ||
145 | +#undef DO_LD_PRIM_2 | ||
146 | +#undef DO_ST_PRIM_2 | ||
147 | + | ||
148 | +#endif /* TARGET_ARM_SVE_LDST_INTERNAL_H */ | ||
149 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | 150 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/docs/system/arm/emulation.rst | 151 | --- a/target/arm/sve_helper.c |
21 | +++ b/docs/system/arm/emulation.rst | 152 | +++ b/target/arm/sve_helper.c |
22 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 153 | @@ -XXX,XX +XXX,XX @@ |
23 | - FEAT_DIT (Data Independent Timing instructions) | 154 | #include "cpu.h" |
24 | - FEAT_DPB (DC CVAP instruction) | 155 | #include "internals.h" |
25 | - FEAT_Debugv8p2 (Debug changes for v8.2) | 156 | #include "exec/exec-all.h" |
26 | +- FEAT_Debugv8p4 (Debug changes for v8.4) | 157 | -#include "exec/cpu_ldst.h" |
27 | - FEAT_DotProd (Advanced SIMD dot product instructions) | 158 | #include "exec/helper-proto.h" |
28 | - FEAT_FCMA (Floating-point complex number instructions) | 159 | #include "tcg/tcg-gvec-desc.h" |
29 | - FEAT_FHM (Floating-point half-precision multiplication instructions) | 160 | #include "fpu/softfloat.h" |
30 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 161 | #include "tcg/tcg.h" |
31 | index XXXXXXX..XXXXXXX 100644 | 162 | #include "vec_internal.h" |
32 | --- a/target/arm/cpu64.c | 163 | +#include "sve_ldst_internal.h" |
33 | +++ b/target/arm/cpu64.c | 164 | |
34 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 165 | |
35 | cpu->isar.id_aa64zfr0 = t; | 166 | /* Return a value for NZCV as per the ARM PredTest pseudofunction. |
36 | 167 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_fcmla_zpzzz_d)(void *vd, void *vn, void *vm, void *va, | |
37 | t = cpu->isar.id_aa64dfr0; | 168 | * Load contiguous data, protected by a governing predicate. |
38 | - t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 8); /* FEAT_Debugv8p2 */ | 169 | */ |
39 | + t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */ | 170 | |
40 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */ | 171 | -/* |
41 | cpu->isar.id_aa64dfr0 = t; | 172 | - * Load one element into @vd + @reg_off from @host. |
42 | 173 | - * The controlling predicate is known to be true. | |
43 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 174 | - */ |
44 | index XXXXXXX..XXXXXXX 100644 | 175 | -typedef void sve_ldst1_host_fn(void *vd, intptr_t reg_off, void *host); |
45 | --- a/target/arm/cpu_tcg.c | 176 | - |
46 | +++ b/target/arm/cpu_tcg.c | 177 | -/* |
47 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | 178 | - * Load one element into @vd + @reg_off from (@env, @vaddr, @ra). |
48 | cpu->isar.id_pfr2 = t; | 179 | - * The controlling predicate is known to be true. |
49 | 180 | - */ | |
50 | t = cpu->isar.id_dfr0; | 181 | -typedef void sve_ldst1_tlb_fn(CPUARMState *env, void *vd, intptr_t reg_off, |
51 | - t = FIELD_DP32(t, ID_DFR0, COPDBG, 8); /* FEAT_Debugv8p2 */ | 182 | - target_ulong vaddr, uintptr_t retaddr); |
52 | - t = FIELD_DP32(t, ID_DFR0, COPSDBG, 8); /* FEAT_Debugv8p2 */ | 183 | - |
53 | + t = FIELD_DP32(t, ID_DFR0, COPDBG, 9); /* FEAT_Debugv8p4 */ | 184 | -/* |
54 | + t = FIELD_DP32(t, ID_DFR0, COPSDBG, 9); /* FEAT_Debugv8p4 */ | 185 | - * Generate the above primitives. |
55 | t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */ | 186 | - */ |
56 | cpu->isar.id_dfr0 = t; | 187 | - |
57 | } | 188 | -#define DO_LD_HOST(NAME, H, TYPEE, TYPEM, HOST) \ |
189 | -static void sve_##NAME##_host(void *vd, intptr_t reg_off, void *host) \ | ||
190 | -{ \ | ||
191 | - TYPEM val = HOST(host); \ | ||
192 | - *(TYPEE *)(vd + H(reg_off)) = val; \ | ||
193 | -} | ||
194 | - | ||
195 | -#define DO_ST_HOST(NAME, H, TYPEE, TYPEM, HOST) \ | ||
196 | -static void sve_##NAME##_host(void *vd, intptr_t reg_off, void *host) \ | ||
197 | -{ HOST(host, (TYPEM)*(TYPEE *)(vd + H(reg_off))); } | ||
198 | - | ||
199 | -#define DO_LD_TLB(NAME, H, TYPEE, TYPEM, TLB) \ | ||
200 | -static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off, \ | ||
201 | - target_ulong addr, uintptr_t ra) \ | ||
202 | -{ \ | ||
203 | - *(TYPEE *)(vd + H(reg_off)) = \ | ||
204 | - (TYPEM)TLB(env, useronly_clean_ptr(addr), ra); \ | ||
205 | -} | ||
206 | - | ||
207 | -#define DO_ST_TLB(NAME, H, TYPEE, TYPEM, TLB) \ | ||
208 | -static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off, \ | ||
209 | - target_ulong addr, uintptr_t ra) \ | ||
210 | -{ \ | ||
211 | - TLB(env, useronly_clean_ptr(addr), \ | ||
212 | - (TYPEM)*(TYPEE *)(vd + H(reg_off)), ra); \ | ||
213 | -} | ||
214 | - | ||
215 | -#define DO_LD_PRIM_1(NAME, H, TE, TM) \ | ||
216 | - DO_LD_HOST(NAME, H, TE, TM, ldub_p) \ | ||
217 | - DO_LD_TLB(NAME, H, TE, TM, cpu_ldub_data_ra) | ||
218 | - | ||
219 | -DO_LD_PRIM_1(ld1bb, H1, uint8_t, uint8_t) | ||
220 | -DO_LD_PRIM_1(ld1bhu, H1_2, uint16_t, uint8_t) | ||
221 | -DO_LD_PRIM_1(ld1bhs, H1_2, uint16_t, int8_t) | ||
222 | -DO_LD_PRIM_1(ld1bsu, H1_4, uint32_t, uint8_t) | ||
223 | -DO_LD_PRIM_1(ld1bss, H1_4, uint32_t, int8_t) | ||
224 | -DO_LD_PRIM_1(ld1bdu, H1_8, uint64_t, uint8_t) | ||
225 | -DO_LD_PRIM_1(ld1bds, H1_8, uint64_t, int8_t) | ||
226 | - | ||
227 | -#define DO_ST_PRIM_1(NAME, H, TE, TM) \ | ||
228 | - DO_ST_HOST(st1##NAME, H, TE, TM, stb_p) \ | ||
229 | - DO_ST_TLB(st1##NAME, H, TE, TM, cpu_stb_data_ra) | ||
230 | - | ||
231 | -DO_ST_PRIM_1(bb, H1, uint8_t, uint8_t) | ||
232 | -DO_ST_PRIM_1(bh, H1_2, uint16_t, uint8_t) | ||
233 | -DO_ST_PRIM_1(bs, H1_4, uint32_t, uint8_t) | ||
234 | -DO_ST_PRIM_1(bd, H1_8, uint64_t, uint8_t) | ||
235 | - | ||
236 | -#define DO_LD_PRIM_2(NAME, H, TE, TM, LD) \ | ||
237 | - DO_LD_HOST(ld1##NAME##_be, H, TE, TM, LD##_be_p) \ | ||
238 | - DO_LD_HOST(ld1##NAME##_le, H, TE, TM, LD##_le_p) \ | ||
239 | - DO_LD_TLB(ld1##NAME##_be, H, TE, TM, cpu_##LD##_be_data_ra) \ | ||
240 | - DO_LD_TLB(ld1##NAME##_le, H, TE, TM, cpu_##LD##_le_data_ra) | ||
241 | - | ||
242 | -#define DO_ST_PRIM_2(NAME, H, TE, TM, ST) \ | ||
243 | - DO_ST_HOST(st1##NAME##_be, H, TE, TM, ST##_be_p) \ | ||
244 | - DO_ST_HOST(st1##NAME##_le, H, TE, TM, ST##_le_p) \ | ||
245 | - DO_ST_TLB(st1##NAME##_be, H, TE, TM, cpu_##ST##_be_data_ra) \ | ||
246 | - DO_ST_TLB(st1##NAME##_le, H, TE, TM, cpu_##ST##_le_data_ra) | ||
247 | - | ||
248 | -DO_LD_PRIM_2(hh, H1_2, uint16_t, uint16_t, lduw) | ||
249 | -DO_LD_PRIM_2(hsu, H1_4, uint32_t, uint16_t, lduw) | ||
250 | -DO_LD_PRIM_2(hss, H1_4, uint32_t, int16_t, lduw) | ||
251 | -DO_LD_PRIM_2(hdu, H1_8, uint64_t, uint16_t, lduw) | ||
252 | -DO_LD_PRIM_2(hds, H1_8, uint64_t, int16_t, lduw) | ||
253 | - | ||
254 | -DO_ST_PRIM_2(hh, H1_2, uint16_t, uint16_t, stw) | ||
255 | -DO_ST_PRIM_2(hs, H1_4, uint32_t, uint16_t, stw) | ||
256 | -DO_ST_PRIM_2(hd, H1_8, uint64_t, uint16_t, stw) | ||
257 | - | ||
258 | -DO_LD_PRIM_2(ss, H1_4, uint32_t, uint32_t, ldl) | ||
259 | -DO_LD_PRIM_2(sdu, H1_8, uint64_t, uint32_t, ldl) | ||
260 | -DO_LD_PRIM_2(sds, H1_8, uint64_t, int32_t, ldl) | ||
261 | - | ||
262 | -DO_ST_PRIM_2(ss, H1_4, uint32_t, uint32_t, stl) | ||
263 | -DO_ST_PRIM_2(sd, H1_8, uint64_t, uint32_t, stl) | ||
264 | - | ||
265 | -DO_LD_PRIM_2(dd, H1_8, uint64_t, uint64_t, ldq) | ||
266 | -DO_ST_PRIM_2(dd, H1_8, uint64_t, uint64_t, stq) | ||
267 | - | ||
268 | -#undef DO_LD_TLB | ||
269 | -#undef DO_ST_TLB | ||
270 | -#undef DO_LD_HOST | ||
271 | -#undef DO_LD_PRIM_1 | ||
272 | -#undef DO_ST_PRIM_1 | ||
273 | -#undef DO_LD_PRIM_2 | ||
274 | -#undef DO_ST_PRIM_2 | ||
275 | - | ||
276 | /* | ||
277 | * Skip through a sequence of inactive elements in the guarding predicate @vg, | ||
278 | * beginning at @reg_off bounded by @reg_max. Return the offset of the active | ||
58 | -- | 279 | -- |
59 | 2.25.1 | 280 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This extension concerns cache speculation, which TCG does | 3 | Export all of the support functions for performing bulk |
4 | not implement. Thus we can trivially enable this feature. | 4 | fault analysis on a set of elements at contiguous addresses |
5 | controlled by a predicate. | ||
5 | 6 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220506180242.216785-22-richard.henderson@linaro.org | 9 | Message-id: 20220607203306.657998-15-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | docs/system/arm/emulation.rst | 1 + | 12 | target/arm/sve_ldst_internal.h | 94 ++++++++++++++++++++++++++++++++++ |
12 | target/arm/cpu64.c | 1 + | 13 | target/arm/sve_helper.c | 87 ++++++------------------------- |
13 | target/arm/cpu_tcg.c | 1 + | 14 | 2 files changed, 111 insertions(+), 70 deletions(-) |
14 | 3 files changed, 3 insertions(+) | ||
15 | 15 | ||
16 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 16 | diff --git a/target/arm/sve_ldst_internal.h b/target/arm/sve_ldst_internal.h |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/docs/system/arm/emulation.rst | 18 | --- a/target/arm/sve_ldst_internal.h |
19 | +++ b/docs/system/arm/emulation.rst | 19 | +++ b/target/arm/sve_ldst_internal.h |
20 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 20 | @@ -XXX,XX +XXX,XX @@ DO_ST_PRIM_2(dd, H1_8, uint64_t, uint64_t, stq) |
21 | - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) | 21 | #undef DO_LD_PRIM_2 |
22 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) | 22 | #undef DO_ST_PRIM_2 |
23 | - FEAT_CSV2_2 (Cache speculation variant 2, version 2) | 23 | |
24 | +- FEAT_CSV3 (Cache speculation variant 3) | 24 | +/* |
25 | - FEAT_DIT (Data Independent Timing instructions) | 25 | + * Resolve the guest virtual address to info->host and info->flags. |
26 | - FEAT_DPB (DC CVAP instruction) | 26 | + * If @nofault, return false if the page is invalid, otherwise |
27 | - FEAT_Debugv8p2 (Debug changes for v8.2) | 27 | + * exit via page fault exception. |
28 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 28 | + */ |
29 | + | ||
30 | +typedef struct { | ||
31 | + void *host; | ||
32 | + int flags; | ||
33 | + MemTxAttrs attrs; | ||
34 | +} SVEHostPage; | ||
35 | + | ||
36 | +bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env, | ||
37 | + target_ulong addr, int mem_off, MMUAccessType access_type, | ||
38 | + int mmu_idx, uintptr_t retaddr); | ||
39 | + | ||
40 | +/* | ||
41 | + * Analyse contiguous data, protected by a governing predicate. | ||
42 | + */ | ||
43 | + | ||
44 | +typedef enum { | ||
45 | + FAULT_NO, | ||
46 | + FAULT_FIRST, | ||
47 | + FAULT_ALL, | ||
48 | +} SVEContFault; | ||
49 | + | ||
50 | +typedef struct { | ||
51 | + /* | ||
52 | + * First and last element wholly contained within the two pages. | ||
53 | + * mem_off_first[0] and reg_off_first[0] are always set >= 0. | ||
54 | + * reg_off_last[0] may be < 0 if the first element crosses pages. | ||
55 | + * All of mem_off_first[1], reg_off_first[1] and reg_off_last[1] | ||
56 | + * are set >= 0 only if there are complete elements on a second page. | ||
57 | + * | ||
58 | + * The reg_off_* offsets are relative to the internal vector register. | ||
59 | + * The mem_off_first offset is relative to the memory address; the | ||
60 | + * two offsets are different when a load operation extends, a store | ||
61 | + * operation truncates, or for multi-register operations. | ||
62 | + */ | ||
63 | + int16_t mem_off_first[2]; | ||
64 | + int16_t reg_off_first[2]; | ||
65 | + int16_t reg_off_last[2]; | ||
66 | + | ||
67 | + /* | ||
68 | + * One element that is misaligned and spans both pages, | ||
69 | + * or -1 if there is no such active element. | ||
70 | + */ | ||
71 | + int16_t mem_off_split; | ||
72 | + int16_t reg_off_split; | ||
73 | + | ||
74 | + /* | ||
75 | + * The byte offset at which the entire operation crosses a page boundary. | ||
76 | + * Set >= 0 if and only if the entire operation spans two pages. | ||
77 | + */ | ||
78 | + int16_t page_split; | ||
79 | + | ||
80 | + /* TLB data for the two pages. */ | ||
81 | + SVEHostPage page[2]; | ||
82 | +} SVEContLdSt; | ||
83 | + | ||
84 | +/* | ||
85 | + * Find first active element on each page, and a loose bound for the | ||
86 | + * final element on each page. Identify any single element that spans | ||
87 | + * the page boundary. Return true if there are any active elements. | ||
88 | + */ | ||
89 | +bool sve_cont_ldst_elements(SVEContLdSt *info, target_ulong addr, uint64_t *vg, | ||
90 | + intptr_t reg_max, int esz, int msize); | ||
91 | + | ||
92 | +/* | ||
93 | + * Resolve the guest virtual addresses to info->page[]. | ||
94 | + * Control the generation of page faults with @fault. Return false if | ||
95 | + * there is no work to do, which can only happen with @fault == FAULT_NO. | ||
96 | + */ | ||
97 | +bool sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, | ||
98 | + CPUARMState *env, target_ulong addr, | ||
99 | + MMUAccessType access_type, uintptr_t retaddr); | ||
100 | + | ||
101 | +#ifdef CONFIG_USER_ONLY | ||
102 | +static inline void | ||
103 | +sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, uint64_t *vg, | ||
104 | + target_ulong addr, int esize, int msize, | ||
105 | + int wp_access, uintptr_t retaddr) | ||
106 | +{ } | ||
107 | +#else | ||
108 | +void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, | ||
109 | + uint64_t *vg, target_ulong addr, | ||
110 | + int esize, int msize, int wp_access, | ||
111 | + uintptr_t retaddr); | ||
112 | +#endif | ||
113 | + | ||
114 | +void sve_cont_ldst_mte_check(SVEContLdSt *info, CPUARMState *env, uint64_t *vg, | ||
115 | + target_ulong addr, int esize, int msize, | ||
116 | + uint32_t mtedesc, uintptr_t ra); | ||
117 | + | ||
118 | #endif /* TARGET_ARM_SVE_LDST_INTERNAL_H */ | ||
119 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | 120 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/cpu64.c | 121 | --- a/target/arm/sve_helper.c |
31 | +++ b/target/arm/cpu64.c | 122 | +++ b/target/arm/sve_helper.c |
32 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 123 | @@ -XXX,XX +XXX,XX @@ static intptr_t find_next_active(uint64_t *vg, intptr_t reg_off, |
33 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ | 124 | * exit via page fault exception. |
34 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ | 125 | */ |
35 | t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */ | 126 | |
36 | + t = FIELD_DP64(t, ID_AA64PFR0, CSV3, 1); /* FEAT_CSV3 */ | 127 | -typedef struct { |
37 | cpu->isar.id_aa64pfr0 = t; | 128 | - void *host; |
38 | 129 | - int flags; | |
39 | t = cpu->isar.id_aa64pfr1; | 130 | - MemTxAttrs attrs; |
40 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 131 | -} SVEHostPage; |
41 | index XXXXXXX..XXXXXXX 100644 | 132 | - |
42 | --- a/target/arm/cpu_tcg.c | 133 | -static bool sve_probe_page(SVEHostPage *info, bool nofault, |
43 | +++ b/target/arm/cpu_tcg.c | 134 | - CPUARMState *env, target_ulong addr, |
44 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | 135 | - int mem_off, MMUAccessType access_type, |
45 | cpu->isar.id_pfr0 = t; | 136 | - int mmu_idx, uintptr_t retaddr) |
46 | 137 | +bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env, | |
47 | t = cpu->isar.id_pfr2; | 138 | + target_ulong addr, int mem_off, MMUAccessType access_type, |
48 | + t = FIELD_DP32(t, ID_PFR2, CSV3, 1); /* FEAT_CSV3 */ | 139 | + int mmu_idx, uintptr_t retaddr) |
49 | t = FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */ | 140 | { |
50 | cpu->isar.id_pfr2 = t; | 141 | int flags; |
142 | |||
143 | @@ -XXX,XX +XXX,XX @@ static bool sve_probe_page(SVEHostPage *info, bool nofault, | ||
144 | return true; | ||
145 | } | ||
146 | |||
147 | - | ||
148 | -/* | ||
149 | - * Analyse contiguous data, protected by a governing predicate. | ||
150 | - */ | ||
151 | - | ||
152 | -typedef enum { | ||
153 | - FAULT_NO, | ||
154 | - FAULT_FIRST, | ||
155 | - FAULT_ALL, | ||
156 | -} SVEContFault; | ||
157 | - | ||
158 | -typedef struct { | ||
159 | - /* | ||
160 | - * First and last element wholly contained within the two pages. | ||
161 | - * mem_off_first[0] and reg_off_first[0] are always set >= 0. | ||
162 | - * reg_off_last[0] may be < 0 if the first element crosses pages. | ||
163 | - * All of mem_off_first[1], reg_off_first[1] and reg_off_last[1] | ||
164 | - * are set >= 0 only if there are complete elements on a second page. | ||
165 | - * | ||
166 | - * The reg_off_* offsets are relative to the internal vector register. | ||
167 | - * The mem_off_first offset is relative to the memory address; the | ||
168 | - * two offsets are different when a load operation extends, a store | ||
169 | - * operation truncates, or for multi-register operations. | ||
170 | - */ | ||
171 | - int16_t mem_off_first[2]; | ||
172 | - int16_t reg_off_first[2]; | ||
173 | - int16_t reg_off_last[2]; | ||
174 | - | ||
175 | - /* | ||
176 | - * One element that is misaligned and spans both pages, | ||
177 | - * or -1 if there is no such active element. | ||
178 | - */ | ||
179 | - int16_t mem_off_split; | ||
180 | - int16_t reg_off_split; | ||
181 | - | ||
182 | - /* | ||
183 | - * The byte offset at which the entire operation crosses a page boundary. | ||
184 | - * Set >= 0 if and only if the entire operation spans two pages. | ||
185 | - */ | ||
186 | - int16_t page_split; | ||
187 | - | ||
188 | - /* TLB data for the two pages. */ | ||
189 | - SVEHostPage page[2]; | ||
190 | -} SVEContLdSt; | ||
191 | - | ||
192 | /* | ||
193 | * Find first active element on each page, and a loose bound for the | ||
194 | * final element on each page. Identify any single element that spans | ||
195 | * the page boundary. Return true if there are any active elements. | ||
196 | */ | ||
197 | -static bool sve_cont_ldst_elements(SVEContLdSt *info, target_ulong addr, | ||
198 | - uint64_t *vg, intptr_t reg_max, | ||
199 | - int esz, int msize) | ||
200 | +bool sve_cont_ldst_elements(SVEContLdSt *info, target_ulong addr, uint64_t *vg, | ||
201 | + intptr_t reg_max, int esz, int msize) | ||
202 | { | ||
203 | const int esize = 1 << esz; | ||
204 | const uint64_t pg_mask = pred_esz_masks[esz]; | ||
205 | @@ -XXX,XX +XXX,XX @@ static bool sve_cont_ldst_elements(SVEContLdSt *info, target_ulong addr, | ||
206 | * Control the generation of page faults with @fault. Return false if | ||
207 | * there is no work to do, which can only happen with @fault == FAULT_NO. | ||
208 | */ | ||
209 | -static bool sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, | ||
210 | - CPUARMState *env, target_ulong addr, | ||
211 | - MMUAccessType access_type, uintptr_t retaddr) | ||
212 | +bool sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, | ||
213 | + CPUARMState *env, target_ulong addr, | ||
214 | + MMUAccessType access_type, uintptr_t retaddr) | ||
215 | { | ||
216 | int mmu_idx = cpu_mmu_index(env, false); | ||
217 | int mem_off = info->mem_off_first[0]; | ||
218 | @@ -XXX,XX +XXX,XX @@ static bool sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, | ||
219 | return have_work; | ||
220 | } | ||
221 | |||
222 | -static void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, | ||
223 | - uint64_t *vg, target_ulong addr, | ||
224 | - int esize, int msize, int wp_access, | ||
225 | - uintptr_t retaddr) | ||
226 | -{ | ||
227 | #ifndef CONFIG_USER_ONLY | ||
228 | +void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, | ||
229 | + uint64_t *vg, target_ulong addr, | ||
230 | + int esize, int msize, int wp_access, | ||
231 | + uintptr_t retaddr) | ||
232 | +{ | ||
233 | intptr_t mem_off, reg_off, reg_last; | ||
234 | int flags0 = info->page[0].flags; | ||
235 | int flags1 = info->page[1].flags; | ||
236 | @@ -XXX,XX +XXX,XX @@ static void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, | ||
237 | } while (reg_off & 63); | ||
238 | } while (reg_off <= reg_last); | ||
239 | } | ||
240 | -#endif | ||
241 | } | ||
242 | +#endif | ||
243 | |||
244 | -static void sve_cont_ldst_mte_check(SVEContLdSt *info, CPUARMState *env, | ||
245 | - uint64_t *vg, target_ulong addr, int esize, | ||
246 | - int msize, uint32_t mtedesc, uintptr_t ra) | ||
247 | +void sve_cont_ldst_mte_check(SVEContLdSt *info, CPUARMState *env, | ||
248 | + uint64_t *vg, target_ulong addr, int esize, | ||
249 | + int msize, uint32_t mtedesc, uintptr_t ra) | ||
250 | { | ||
251 | intptr_t mem_off, reg_off, reg_last; | ||
51 | 252 | ||
52 | -- | 253 | -- |
53 | 2.25.1 | 254 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Update the legacy feature names to the current names. | 3 | Put the inline function near the array declaration. |
4 | Provide feature names for id changes that were not marked. | ||
5 | Sort the field updates into increasing bitfield order. | ||
6 | 4 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20220506180242.216785-10-richard.henderson@linaro.org | 7 | Message-id: 20220607203306.657998-16-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | target/arm/cpu64.c | 100 +++++++++++++++++++++---------------------- | 10 | target/arm/vec_internal.h | 8 +++++++- |
13 | target/arm/cpu_tcg.c | 48 ++++++++++----------- | 11 | target/arm/sve_helper.c | 9 --------- |
14 | 2 files changed, 74 insertions(+), 74 deletions(-) | 12 | 2 files changed, 7 insertions(+), 10 deletions(-) |
15 | 13 | ||
16 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 14 | diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu64.c | 16 | --- a/target/arm/vec_internal.h |
19 | +++ b/target/arm/cpu64.c | 17 | +++ b/target/arm/vec_internal.h |
20 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 18 | @@ -XXX,XX +XXX,XX @@ |
21 | cpu->midr = t; | 19 | #define H8(x) (x) |
22 | 20 | #define H1_8(x) (x) | |
23 | t = cpu->isar.id_aa64isar0; | 21 | |
24 | - t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */ | 22 | -/* Data for expanding active predicate bits to bytes, for byte elements. */ |
25 | - t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); | 23 | +/* |
26 | - t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* SHA512 */ | 24 | + * Expand active predicate bits to bytes, for byte elements. |
27 | + t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */ | 25 | + */ |
28 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */ | 26 | extern const uint64_t expand_pred_b_data[256]; |
29 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */ | 27 | +static inline uint64_t expand_pred_b(uint8_t byte) |
30 | t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); | 28 | +{ |
31 | - t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); | 29 | + return expand_pred_b_data[byte]; |
32 | - t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); | 30 | +} |
33 | - t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); | 31 | |
34 | - t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1); | 32 | static inline void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) |
35 | - t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); | 33 | { |
36 | - t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); | 34 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c |
37 | - t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1); | ||
38 | - t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* v8.5-CondM */ | ||
39 | - t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */ | ||
40 | - t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1); | ||
41 | + t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); /* FEAT_LSE */ | ||
42 | + t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); /* FEAT_RDM */ | ||
43 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); /* FEAT_SHA3 */ | ||
44 | + t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1); /* FEAT_SM3 */ | ||
45 | + t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); /* FEAT_SM4 */ | ||
46 | + t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); /* FEAT_DotProd */ | ||
47 | + t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1); /* FEAT_FHM */ | ||
48 | + t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* FEAT_FlagM2 */ | ||
49 | + t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */ | ||
50 | + t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1); /* FEAT_RNG */ | ||
51 | cpu->isar.id_aa64isar0 = t; | ||
52 | |||
53 | t = cpu->isar.id_aa64isar1; | ||
54 | - t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); | ||
55 | - t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); | ||
56 | - t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); | ||
57 | - t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); | ||
58 | - t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); | ||
59 | - t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); | ||
60 | - t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1); | ||
61 | - t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* ARMv8.4-RCPC */ | ||
62 | - t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); | ||
63 | + t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); /* FEAT_DPB2 */ | ||
64 | + t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); /* FEAT_JSCVT */ | ||
65 | + t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); /* FEAT_FCMA */ | ||
66 | + t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* FEAT_LRCPC2 */ | ||
67 | + t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1); /* FEAT_FRINTTS */ | ||
68 | + t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); /* FEAT_SB */ | ||
69 | + t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); /* FEAT_SPECRES */ | ||
70 | + t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); /* FEAT_BF16 */ | ||
71 | + t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); /* FEAT_I8MM */ | ||
72 | cpu->isar.id_aa64isar1 = t; | ||
73 | |||
74 | t = cpu->isar.id_aa64pfr0; | ||
75 | + t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */ | ||
76 | + t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */ | ||
77 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | ||
78 | - t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); | ||
79 | - t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); | ||
80 | - t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); | ||
81 | - t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); | ||
82 | + t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ | ||
83 | + t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ | ||
84 | cpu->isar.id_aa64pfr0 = t; | ||
85 | |||
86 | t = cpu->isar.id_aa64pfr1; | ||
87 | - t = FIELD_DP64(t, ID_AA64PFR1, BT, 1); | ||
88 | - t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2); | ||
89 | + t = FIELD_DP64(t, ID_AA64PFR1, BT, 1); /* FEAT_BTI */ | ||
90 | + t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2); /* FEAT_SSBS2 */ | ||
91 | /* | ||
92 | * Begin with full support for MTE. This will be downgraded to MTE=0 | ||
93 | * during realize if the board provides no tag memory, much like | ||
94 | * we do for EL2 with the virtualization=on property. | ||
95 | */ | ||
96 | - t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); | ||
97 | + t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ | ||
98 | cpu->isar.id_aa64pfr1 = t; | ||
99 | |||
100 | t = cpu->isar.id_aa64mmfr0; | ||
101 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
102 | cpu->isar.id_aa64mmfr0 = t; | ||
103 | |||
104 | t = cpu->isar.id_aa64mmfr1; | ||
105 | - t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ | ||
106 | - t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); | ||
107 | - t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); | ||
108 | - t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */ | ||
109 | - t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */ | ||
110 | - t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* TTS2UXN */ | ||
111 | + t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ | ||
112 | + t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ | ||
113 | + t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */ | ||
114 | + t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */ | ||
115 | + t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* FEAT_PAN2 */ | ||
116 | + t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */ | ||
117 | cpu->isar.id_aa64mmfr1 = t; | ||
118 | |||
119 | t = cpu->isar.id_aa64mmfr2; | ||
120 | - t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); | ||
121 | - t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* TTCNP */ | ||
122 | - t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* TTST */ | ||
123 | - t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */ | ||
124 | - t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ | ||
125 | - t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */ | ||
126 | + t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* FEAT_TTCNP */ | ||
127 | + t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); /* FEAT_UAO */ | ||
128 | + t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */ | ||
129 | + t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* FEAT_TTST */ | ||
130 | + t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ | ||
131 | + t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */ | ||
132 | cpu->isar.id_aa64mmfr2 = t; | ||
133 | |||
134 | t = cpu->isar.id_aa64zfr0; | ||
135 | t = FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 1); | ||
136 | - t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* PMULL */ | ||
137 | - t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1); | ||
138 | - t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1); | ||
139 | - t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1); | ||
140 | - t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1); | ||
141 | - t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1); | ||
142 | - t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1); | ||
143 | - t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); | ||
144 | + t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* FEAT_SVE_PMULL128 */ | ||
145 | + t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1); /* FEAT_SVE_BitPerm */ | ||
146 | + t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1); /* FEAT_BF16 */ | ||
147 | + t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1); /* FEAT_SVE_SHA3 */ | ||
148 | + t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1); /* FEAT_SVE_SM4 */ | ||
149 | + t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1); /* FEAT_I8MM */ | ||
150 | + t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1); /* FEAT_F32MM */ | ||
151 | + t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); /* FEAT_F64MM */ | ||
152 | cpu->isar.id_aa64zfr0 = t; | ||
153 | |||
154 | t = cpu->isar.id_aa64dfr0; | ||
155 | - t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */ | ||
156 | + t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */ | ||
157 | cpu->isar.id_aa64dfr0 = t; | ||
158 | |||
159 | /* Replicate the same data to the 32-bit id registers. */ | ||
160 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
161 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
162 | --- a/target/arm/cpu_tcg.c | 36 | --- a/target/arm/sve_helper.c |
163 | +++ b/target/arm/cpu_tcg.c | 37 | +++ b/target/arm/sve_helper.c |
164 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | 38 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_predtest)(void *vd, void *vg, uint32_t words) |
165 | 39 | return flags; | |
166 | /* Add additional features supported by QEMU */ | ||
167 | t = cpu->isar.id_isar5; | ||
168 | - t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
169 | - t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
170 | - t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
171 | + t = FIELD_DP32(t, ID_ISAR5, AES, 2); /* FEAT_PMULL */ | ||
172 | + t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); /* FEAT_SHA1 */ | ||
173 | + t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); /* FEAT_SHA256 */ | ||
174 | t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
175 | - t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
176 | - t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
177 | + t = FIELD_DP32(t, ID_ISAR5, RDM, 1); /* FEAT_RDM */ | ||
178 | + t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); /* FEAT_FCMA */ | ||
179 | cpu->isar.id_isar5 = t; | ||
180 | |||
181 | t = cpu->isar.id_isar6; | ||
182 | - t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
183 | - t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
184 | - t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
185 | - t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
186 | - t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
187 | - t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
188 | - t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
189 | + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); /* FEAT_JSCVT */ | ||
190 | + t = FIELD_DP32(t, ID_ISAR6, DP, 1); /* Feat_DotProd */ | ||
191 | + t = FIELD_DP32(t, ID_ISAR6, FHM, 1); /* FEAT_FHM */ | ||
192 | + t = FIELD_DP32(t, ID_ISAR6, SB, 1); /* FEAT_SB */ | ||
193 | + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); /* FEAT_SPECRES */ | ||
194 | + t = FIELD_DP32(t, ID_ISAR6, BF16, 1); /* FEAT_AA32BF16 */ | ||
195 | + t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); /* FEAT_AA32I8MM */ | ||
196 | cpu->isar.id_isar6 = t; | ||
197 | |||
198 | t = cpu->isar.mvfr1; | ||
199 | - t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
200 | - t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
201 | + t = FIELD_DP32(t, MVFR1, FPHP, 3); /* FEAT_FP16 */ | ||
202 | + t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* FEAT_FP16 */ | ||
203 | cpu->isar.mvfr1 = t; | ||
204 | |||
205 | t = cpu->isar.mvfr2; | ||
206 | - t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
207 | - t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
208 | + t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
209 | + t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
210 | cpu->isar.mvfr2 = t; | ||
211 | |||
212 | t = cpu->isar.id_mmfr3; | ||
213 | - t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
214 | + t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* FEAT_PAN2 */ | ||
215 | cpu->isar.id_mmfr3 = t; | ||
216 | |||
217 | t = cpu->isar.id_mmfr4; | ||
218 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
219 | - t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
220 | - t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
221 | - t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
222 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* FEAT_AA32HPD */ | ||
223 | + t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
224 | + t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */ | ||
225 | + t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX*/ | ||
226 | cpu->isar.id_mmfr4 = t; | ||
227 | |||
228 | t = cpu->isar.id_pfr0; | ||
229 | - t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
230 | + t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */ | ||
231 | cpu->isar.id_pfr0 = t; | ||
232 | |||
233 | t = cpu->isar.id_pfr2; | ||
234 | - t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
235 | + t = FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */ | ||
236 | cpu->isar.id_pfr2 = t; | ||
237 | |||
238 | t = cpu->isar.id_dfr0; | ||
239 | - t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
240 | + t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */ | ||
241 | cpu->isar.id_dfr0 = t; | ||
242 | } | 40 | } |
243 | 41 | ||
42 | -/* | ||
43 | - * Expand active predicate bits to bytes, for byte elements. | ||
44 | - * (The data table itself is in vec_helper.c as MVE also needs it.) | ||
45 | - */ | ||
46 | -static inline uint64_t expand_pred_b(uint8_t byte) | ||
47 | -{ | ||
48 | - return expand_pred_b_data[byte]; | ||
49 | -} | ||
50 | - | ||
51 | /* Similarly for half-word elements. | ||
52 | * for (i = 0; i < 256; ++i) { | ||
53 | * unsigned long m = 0; | ||
244 | -- | 54 | -- |
245 | 2.25.1 | 55 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Instead of starting with cortex-a15 and adding v8 features to | 3 | Use the function instead of the array directly. |
4 | a v7 cpu, begin with a v8 cpu stripped of its aarch64 features. | 4 | |
5 | This fixes the long-standing to-do where we only enabled v8 | 5 | Because the function performs its own masking, via the uint8_t |
6 | features for user-only. | 6 | parameter, we need to do nothing extra within the users: the bits |
7 | above the first 2 (_uh) or 4 (_uw) will be discarded by assignment | ||
8 | to the local bmask variables, and of course _uq uses the entire | ||
9 | uint64_t result. | ||
7 | 10 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20220506180242.216785-7-richard.henderson@linaro.org | 13 | Message-id: 20220607203306.657998-17-richard.henderson@linaro.org |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 15 | --- |
13 | target/arm/cpu_tcg.c | 151 ++++++++++++++++++++++++++----------------- | 16 | target/arm/mve_helper.c | 6 +++--- |
14 | 1 file changed, 92 insertions(+), 59 deletions(-) | 17 | 1 file changed, 3 insertions(+), 3 deletions(-) |
15 | 18 | ||
16 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 19 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu_tcg.c | 21 | --- a/target/arm/mve_helper.c |
19 | +++ b/target/arm/cpu_tcg.c | 22 | +++ b/target/arm/mve_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void arm_v7m_class_init(ObjectClass *oc, void *data) | 23 | @@ -XXX,XX +XXX,XX @@ static void mergemask_sb(int8_t *d, int8_t r, uint16_t mask) |
21 | static void arm_max_initfn(Object *obj) | 24 | |
25 | static void mergemask_uh(uint16_t *d, uint16_t r, uint16_t mask) | ||
22 | { | 26 | { |
23 | ARMCPU *cpu = ARM_CPU(obj); | 27 | - uint16_t bmask = expand_pred_b_data[mask & 3]; |
24 | + uint32_t t; | 28 | + uint16_t bmask = expand_pred_b(mask); |
25 | 29 | *d = (*d & ~bmask) | (r & bmask); | |
26 | - cortex_a15_initfn(obj); | ||
27 | + /* aarch64_a57_initfn, advertising none of the aarch64 features */ | ||
28 | + cpu->dtb_compatible = "arm,cortex-a57"; | ||
29 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
30 | + set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
31 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
32 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
33 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
34 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
35 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
36 | + cpu->midr = 0x411fd070; | ||
37 | + cpu->revidr = 0x00000000; | ||
38 | + cpu->reset_fpsid = 0x41034070; | ||
39 | + cpu->isar.mvfr0 = 0x10110222; | ||
40 | + cpu->isar.mvfr1 = 0x12111111; | ||
41 | + cpu->isar.mvfr2 = 0x00000043; | ||
42 | + cpu->ctr = 0x8444c004; | ||
43 | + cpu->reset_sctlr = 0x00c50838; | ||
44 | + cpu->isar.id_pfr0 = 0x00000131; | ||
45 | + cpu->isar.id_pfr1 = 0x00011011; | ||
46 | + cpu->isar.id_dfr0 = 0x03010066; | ||
47 | + cpu->id_afr0 = 0x00000000; | ||
48 | + cpu->isar.id_mmfr0 = 0x10101105; | ||
49 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
50 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
51 | + cpu->isar.id_mmfr3 = 0x02102211; | ||
52 | + cpu->isar.id_isar0 = 0x02101110; | ||
53 | + cpu->isar.id_isar1 = 0x13112111; | ||
54 | + cpu->isar.id_isar2 = 0x21232042; | ||
55 | + cpu->isar.id_isar3 = 0x01112131; | ||
56 | + cpu->isar.id_isar4 = 0x00011142; | ||
57 | + cpu->isar.id_isar5 = 0x00011121; | ||
58 | + cpu->isar.id_isar6 = 0; | ||
59 | + cpu->isar.dbgdidr = 0x3516d000; | ||
60 | + cpu->clidr = 0x0a200023; | ||
61 | + cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ | ||
62 | + cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ | ||
63 | + cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */ | ||
64 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
65 | |||
66 | - /* old-style VFP short-vector support */ | ||
67 | - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
68 | + /* Add additional features supported by QEMU */ | ||
69 | + t = cpu->isar.id_isar5; | ||
70 | + t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
71 | + t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
72 | + t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
73 | + t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
74 | + t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
75 | + t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
76 | + cpu->isar.id_isar5 = t; | ||
77 | + | ||
78 | + t = cpu->isar.id_isar6; | ||
79 | + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
80 | + t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
81 | + t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
82 | + t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
83 | + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
84 | + t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
85 | + t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
86 | + cpu->isar.id_isar6 = t; | ||
87 | + | ||
88 | + t = cpu->isar.mvfr1; | ||
89 | + t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
90 | + t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
91 | + cpu->isar.mvfr1 = t; | ||
92 | + | ||
93 | + t = cpu->isar.mvfr2; | ||
94 | + t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
95 | + t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
96 | + cpu->isar.mvfr2 = t; | ||
97 | + | ||
98 | + t = cpu->isar.id_mmfr3; | ||
99 | + t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
100 | + cpu->isar.id_mmfr3 = t; | ||
101 | + | ||
102 | + t = cpu->isar.id_mmfr4; | ||
103 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
104 | + t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
105 | + t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
106 | + t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
107 | + cpu->isar.id_mmfr4 = t; | ||
108 | + | ||
109 | + t = cpu->isar.id_pfr0; | ||
110 | + t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
111 | + cpu->isar.id_pfr0 = t; | ||
112 | + | ||
113 | + t = cpu->isar.id_pfr2; | ||
114 | + t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
115 | + cpu->isar.id_pfr2 = t; | ||
116 | |||
117 | #ifdef CONFIG_USER_ONLY | ||
118 | /* | ||
119 | - * We don't set these in system emulation mode for the moment, | ||
120 | - * since we don't correctly set (all of) the ID registers to | ||
121 | - * advertise them. | ||
122 | + * Break with true ARMv8 and add back old-style VFP short-vector support. | ||
123 | + * Only do this for user-mode, where -cpu max is the default, so that | ||
124 | + * older v6 and v7 programs are more likely to work without adjustment. | ||
125 | */ | ||
126 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
127 | - { | ||
128 | - uint32_t t; | ||
129 | - | ||
130 | - t = cpu->isar.id_isar5; | ||
131 | - t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
132 | - t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
133 | - t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
134 | - t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
135 | - t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
136 | - t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
137 | - cpu->isar.id_isar5 = t; | ||
138 | - | ||
139 | - t = cpu->isar.id_isar6; | ||
140 | - t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
141 | - t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
142 | - t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
143 | - t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
144 | - t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
145 | - t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
146 | - t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
147 | - cpu->isar.id_isar6 = t; | ||
148 | - | ||
149 | - t = cpu->isar.mvfr1; | ||
150 | - t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
151 | - t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
152 | - cpu->isar.mvfr1 = t; | ||
153 | - | ||
154 | - t = cpu->isar.mvfr2; | ||
155 | - t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
156 | - t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
157 | - cpu->isar.mvfr2 = t; | ||
158 | - | ||
159 | - t = cpu->isar.id_mmfr3; | ||
160 | - t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
161 | - cpu->isar.id_mmfr3 = t; | ||
162 | - | ||
163 | - t = cpu->isar.id_mmfr4; | ||
164 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
165 | - t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
166 | - t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
167 | - t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
168 | - cpu->isar.id_mmfr4 = t; | ||
169 | - | ||
170 | - t = cpu->isar.id_pfr0; | ||
171 | - t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
172 | - cpu->isar.id_pfr0 = t; | ||
173 | - | ||
174 | - t = cpu->isar.id_pfr2; | ||
175 | - t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
176 | - cpu->isar.id_pfr2 = t; | ||
177 | - } | ||
178 | -#endif /* CONFIG_USER_ONLY */ | ||
179 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
180 | +#endif | ||
181 | } | 30 | } |
182 | #endif /* !TARGET_AARCH64 */ | 31 | |
32 | @@ -XXX,XX +XXX,XX @@ static void mergemask_sh(int16_t *d, int16_t r, uint16_t mask) | ||
33 | |||
34 | static void mergemask_uw(uint32_t *d, uint32_t r, uint16_t mask) | ||
35 | { | ||
36 | - uint32_t bmask = expand_pred_b_data[mask & 0xf]; | ||
37 | + uint32_t bmask = expand_pred_b(mask); | ||
38 | *d = (*d & ~bmask) | (r & bmask); | ||
39 | } | ||
40 | |||
41 | @@ -XXX,XX +XXX,XX @@ static void mergemask_sw(int32_t *d, int32_t r, uint16_t mask) | ||
42 | |||
43 | static void mergemask_uq(uint64_t *d, uint64_t r, uint16_t mask) | ||
44 | { | ||
45 | - uint64_t bmask = expand_pred_b_data[mask & 0xff]; | ||
46 | + uint64_t bmask = expand_pred_b(mask); | ||
47 | *d = (*d & ~bmask) | (r & bmask); | ||
48 | } | ||
183 | 49 | ||
184 | -- | 50 | -- |
185 | 2.25.1 | 51 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Enable the n1 for virt and sbsa board use. | 3 | Move the data to vec_helper.c and the inline to vec_internal.h. |
4 | 4 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20220506180242.216785-25-richard.henderson@linaro.org | 7 | Message-id: 20220607203306.657998-18-richard.henderson@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 9 | --- |
10 | docs/system/arm/virt.rst | 1 + | 10 | target/arm/vec_internal.h | 7 +++++++ |
11 | hw/arm/sbsa-ref.c | 1 + | 11 | target/arm/sve_helper.c | 29 ----------------------------- |
12 | hw/arm/virt.c | 1 + | 12 | target/arm/vec_helper.c | 26 ++++++++++++++++++++++++++ |
13 | target/arm/cpu64.c | 66 ++++++++++++++++++++++++++++++++++++++++ | 13 | 3 files changed, 33 insertions(+), 29 deletions(-) |
14 | 4 files changed, 69 insertions(+) | ||
15 | 14 | ||
16 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst | 15 | diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/docs/system/arm/virt.rst | 17 | --- a/target/arm/vec_internal.h |
19 | +++ b/docs/system/arm/virt.rst | 18 | +++ b/target/arm/vec_internal.h |
20 | @@ -XXX,XX +XXX,XX @@ Supported guest CPU types: | 19 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t expand_pred_b(uint8_t byte) |
21 | - ``cortex-a76`` (64-bit) | 20 | return expand_pred_b_data[byte]; |
22 | - ``a64fx`` (64-bit) | ||
23 | - ``host`` (with KVM only) | ||
24 | +- ``neoverse-n1`` (64-bit) | ||
25 | - ``max`` (same as ``host`` for KVM; best possible emulation with TCG) | ||
26 | |||
27 | Note that the default is ``cortex-a15``, so for an AArch64 guest you must | ||
28 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/hw/arm/sbsa-ref.c | ||
31 | +++ b/hw/arm/sbsa-ref.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static const char * const valid_cpus[] = { | ||
33 | ARM_CPU_TYPE_NAME("cortex-a57"), | ||
34 | ARM_CPU_TYPE_NAME("cortex-a72"), | ||
35 | ARM_CPU_TYPE_NAME("cortex-a76"), | ||
36 | + ARM_CPU_TYPE_NAME("neoverse-n1"), | ||
37 | ARM_CPU_TYPE_NAME("max"), | ||
38 | }; | ||
39 | |||
40 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/arm/virt.c | ||
43 | +++ b/hw/arm/virt.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = { | ||
45 | ARM_CPU_TYPE_NAME("cortex-a72"), | ||
46 | ARM_CPU_TYPE_NAME("cortex-a76"), | ||
47 | ARM_CPU_TYPE_NAME("a64fx"), | ||
48 | + ARM_CPU_TYPE_NAME("neoverse-n1"), | ||
49 | ARM_CPU_TYPE_NAME("host"), | ||
50 | ARM_CPU_TYPE_NAME("max"), | ||
51 | }; | ||
52 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/cpu64.c | ||
55 | +++ b/target/arm/cpu64.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a76_initfn(Object *obj) | ||
57 | cpu->isar.mvfr2 = 0x00000043; | ||
58 | } | 21 | } |
59 | 22 | ||
60 | +static void aarch64_neoverse_n1_initfn(Object *obj) | 23 | +/* Similarly for half-word elements. */ |
24 | +extern const uint64_t expand_pred_h_data[0x55 + 1]; | ||
25 | +static inline uint64_t expand_pred_h(uint8_t byte) | ||
61 | +{ | 26 | +{ |
62 | + ARMCPU *cpu = ARM_CPU(obj); | 27 | + return expand_pred_h_data[byte & 0x55]; |
63 | + | ||
64 | + cpu->dtb_compatible = "arm,neoverse-n1"; | ||
65 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
66 | + set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
67 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
68 | + set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
69 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
70 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
71 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
72 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
73 | + | ||
74 | + /* Ordered by B2.4 AArch64 registers by functional group */ | ||
75 | + cpu->clidr = 0x82000023; | ||
76 | + cpu->ctr = 0x8444c004; | ||
77 | + cpu->dcz_blocksize = 4; | ||
78 | + cpu->isar.id_aa64dfr0 = 0x0000000110305408ull; | ||
79 | + cpu->isar.id_aa64isar0 = 0x0000100010211120ull; | ||
80 | + cpu->isar.id_aa64isar1 = 0x0000000000100001ull; | ||
81 | + cpu->isar.id_aa64mmfr0 = 0x0000000000101125ull; | ||
82 | + cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; | ||
83 | + cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull; | ||
84 | + cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */ | ||
85 | + cpu->isar.id_aa64pfr1 = 0x0000000000000020ull; | ||
86 | + cpu->id_afr0 = 0x00000000; | ||
87 | + cpu->isar.id_dfr0 = 0x04010088; | ||
88 | + cpu->isar.id_isar0 = 0x02101110; | ||
89 | + cpu->isar.id_isar1 = 0x13112111; | ||
90 | + cpu->isar.id_isar2 = 0x21232042; | ||
91 | + cpu->isar.id_isar3 = 0x01112131; | ||
92 | + cpu->isar.id_isar4 = 0x00010142; | ||
93 | + cpu->isar.id_isar5 = 0x01011121; | ||
94 | + cpu->isar.id_isar6 = 0x00000010; | ||
95 | + cpu->isar.id_mmfr0 = 0x10201105; | ||
96 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
97 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
98 | + cpu->isar.id_mmfr3 = 0x02122211; | ||
99 | + cpu->isar.id_mmfr4 = 0x00021110; | ||
100 | + cpu->isar.id_pfr0 = 0x10010131; | ||
101 | + cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ | ||
102 | + cpu->isar.id_pfr2 = 0x00000011; | ||
103 | + cpu->midr = 0x414fd0c1; /* r4p1 */ | ||
104 | + cpu->revidr = 0; | ||
105 | + | ||
106 | + /* From B2.23 CCSIDR_EL1 */ | ||
107 | + cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */ | ||
108 | + cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */ | ||
109 | + cpu->ccsidr[2] = 0x70ffe03a; /* 1MB L2 cache */ | ||
110 | + | ||
111 | + /* From B2.98 SCTLR_EL3 */ | ||
112 | + cpu->reset_sctlr = 0x30c50838; | ||
113 | + | ||
114 | + /* From B4.23 ICH_VTR_EL2 */ | ||
115 | + cpu->gic_num_lrs = 4; | ||
116 | + cpu->gic_vpribits = 5; | ||
117 | + cpu->gic_vprebits = 5; | ||
118 | + | ||
119 | + /* From B5.1 AdvSIMD AArch64 register summary */ | ||
120 | + cpu->isar.mvfr0 = 0x10110222; | ||
121 | + cpu->isar.mvfr1 = 0x13211111; | ||
122 | + cpu->isar.mvfr2 = 0x00000043; | ||
123 | +} | 28 | +} |
124 | + | 29 | + |
125 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | 30 | static inline void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) |
126 | { | 31 | { |
127 | /* | 32 | uint64_t *d = vd + opr_sz; |
128 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { | 33 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c |
129 | { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, | 34 | index XXXXXXX..XXXXXXX 100644 |
130 | { .name = "cortex-a76", .initfn = aarch64_a76_initfn }, | 35 | --- a/target/arm/sve_helper.c |
131 | { .name = "a64fx", .initfn = aarch64_a64fx_initfn }, | 36 | +++ b/target/arm/sve_helper.c |
132 | + { .name = "neoverse-n1", .initfn = aarch64_neoverse_n1_initfn }, | 37 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_predtest)(void *vd, void *vg, uint32_t words) |
133 | { .name = "max", .initfn = aarch64_max_initfn }, | 38 | return flags; |
134 | #if defined(CONFIG_KVM) || defined(CONFIG_HVF) | 39 | } |
135 | { .name = "host", .initfn = aarch64_host_initfn }, | 40 | |
41 | -/* Similarly for half-word elements. | ||
42 | - * for (i = 0; i < 256; ++i) { | ||
43 | - * unsigned long m = 0; | ||
44 | - * if (i & 0xaa) { | ||
45 | - * continue; | ||
46 | - * } | ||
47 | - * for (j = 0; j < 8; j += 2) { | ||
48 | - * if ((i >> j) & 1) { | ||
49 | - * m |= 0xfffful << (j << 3); | ||
50 | - * } | ||
51 | - * } | ||
52 | - * printf("[0x%x] = 0x%016lx,\n", i, m); | ||
53 | - * } | ||
54 | - */ | ||
55 | -static inline uint64_t expand_pred_h(uint8_t byte) | ||
56 | -{ | ||
57 | - static const uint64_t word[] = { | ||
58 | - [0x01] = 0x000000000000ffff, [0x04] = 0x00000000ffff0000, | ||
59 | - [0x05] = 0x00000000ffffffff, [0x10] = 0x0000ffff00000000, | ||
60 | - [0x11] = 0x0000ffff0000ffff, [0x14] = 0x0000ffffffff0000, | ||
61 | - [0x15] = 0x0000ffffffffffff, [0x40] = 0xffff000000000000, | ||
62 | - [0x41] = 0xffff00000000ffff, [0x44] = 0xffff0000ffff0000, | ||
63 | - [0x45] = 0xffff0000ffffffff, [0x50] = 0xffffffff00000000, | ||
64 | - [0x51] = 0xffffffff0000ffff, [0x54] = 0xffffffffffff0000, | ||
65 | - [0x55] = 0xffffffffffffffff, | ||
66 | - }; | ||
67 | - return word[byte & 0x55]; | ||
68 | -} | ||
69 | - | ||
70 | /* Similarly for single word elements. */ | ||
71 | static inline uint64_t expand_pred_s(uint8_t byte) | ||
72 | { | ||
73 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/arm/vec_helper.c | ||
76 | +++ b/target/arm/vec_helper.c | ||
77 | @@ -XXX,XX +XXX,XX @@ const uint64_t expand_pred_b_data[256] = { | ||
78 | 0xffffffffffffffff, | ||
79 | }; | ||
80 | |||
81 | +/* | ||
82 | + * Similarly for half-word elements. | ||
83 | + * for (i = 0; i < 256; ++i) { | ||
84 | + * unsigned long m = 0; | ||
85 | + * if (i & 0xaa) { | ||
86 | + * continue; | ||
87 | + * } | ||
88 | + * for (j = 0; j < 8; j += 2) { | ||
89 | + * if ((i >> j) & 1) { | ||
90 | + * m |= 0xfffful << (j << 3); | ||
91 | + * } | ||
92 | + * } | ||
93 | + * printf("[0x%x] = 0x%016lx,\n", i, m); | ||
94 | + * } | ||
95 | + */ | ||
96 | +const uint64_t expand_pred_h_data[0x55 + 1] = { | ||
97 | + [0x01] = 0x000000000000ffff, [0x04] = 0x00000000ffff0000, | ||
98 | + [0x05] = 0x00000000ffffffff, [0x10] = 0x0000ffff00000000, | ||
99 | + [0x11] = 0x0000ffff0000ffff, [0x14] = 0x0000ffffffff0000, | ||
100 | + [0x15] = 0x0000ffffffffffff, [0x40] = 0xffff000000000000, | ||
101 | + [0x41] = 0xffff00000000ffff, [0x44] = 0xffff0000ffff0000, | ||
102 | + [0x45] = 0xffff0000ffffffff, [0x50] = 0xffffffff00000000, | ||
103 | + [0x51] = 0xffffffff0000ffff, [0x54] = 0xffffffffffff0000, | ||
104 | + [0x55] = 0xffffffffffffffff, | ||
105 | +}; | ||
106 | + | ||
107 | /* Signed saturating rounding doubling multiply-accumulate high half, 8-bit */ | ||
108 | int8_t do_sqrdmlah_b(int8_t src1, int8_t src2, int8_t src3, | ||
109 | bool neg, bool round) | ||
136 | -- | 110 | -- |
137 | 2.25.1 | 111 | 2.25.1 | 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 set this for qemu-system-aarch64, but failed to do so | 3 | We will need this over in sme_helper.c. |
4 | for the strictly 32-bit emulation. | ||
5 | 4 | ||
6 | Fixes: 3bec78447a9 ("target/arm: Provide ARMv8.4-PMU in '-cpu max'") | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20220506180242.216785-8-richard.henderson@linaro.org | 7 | Message-id: 20220607203306.657998-19-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | target/arm/cpu_tcg.c | 4 ++++ | 10 | target/arm/vec_internal.h | 13 +++++++++++++ |
13 | 1 file changed, 4 insertions(+) | 11 | target/arm/vec_helper.c | 2 +- |
12 | 2 files changed, 14 insertions(+), 1 deletion(-) | ||
14 | 13 | ||
15 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 14 | diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/cpu_tcg.c | 16 | --- a/target/arm/vec_internal.h |
18 | +++ b/target/arm/cpu_tcg.c | 17 | +++ b/target/arm/vec_internal.h |
19 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | 18 | @@ -XXX,XX +XXX,XX @@ uint64_t pmull_h(uint64_t op1, uint64_t op2); |
20 | t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | 19 | */ |
21 | cpu->isar.id_pfr2 = t; | 20 | uint64_t pmull_w(uint64_t op1, uint64_t op2); |
22 | 21 | ||
23 | + t = cpu->isar.id_dfr0; | 22 | +/** |
24 | + t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | 23 | + * bfdotadd: |
25 | + cpu->isar.id_dfr0 = t; | 24 | + * @sum: addend |
25 | + * @e1, @e2: multiplicand vectors | ||
26 | + * | ||
27 | + * BFloat16 2-way dot product of @e1 & @e2, accumulating with @sum. | ||
28 | + * The @e1 and @e2 operands correspond to the 32-bit source vector | ||
29 | + * slots and contain two Bfloat16 values each. | ||
30 | + * | ||
31 | + * Corresponds to the ARM pseudocode function BFDotAdd. | ||
32 | + */ | ||
33 | +float32 bfdotadd(float32 sum, uint32_t e1, uint32_t e2); | ||
26 | + | 34 | + |
27 | #ifdef CONFIG_USER_ONLY | 35 | #endif /* TARGET_ARM_VEC_INTERNAL_H */ |
28 | /* | 36 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c |
29 | * Break with true ARMv8 and add back old-style VFP short-vector support. | 37 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/target/arm/vec_helper.c | ||
39 | +++ b/target/arm/vec_helper.c | ||
40 | @@ -XXX,XX +XXX,XX @@ DO_MMLA_B(gvec_usmmla_b, do_usmmla_b) | ||
41 | * BFloat16 Dot Product | ||
42 | */ | ||
43 | |||
44 | -static float32 bfdotadd(float32 sum, uint32_t e1, uint32_t e2) | ||
45 | +float32 bfdotadd(float32 sum, uint32_t e1, uint32_t e2) | ||
46 | { | ||
47 | /* FPCR is ignored for BFDOT and BFMMLA. */ | ||
48 | float_status bf_status = { | ||
30 | -- | 49 | -- |
31 | 2.25.1 | 50 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Enable the a76 for virt and sbsa board use. | 3 | This will be used for implementing FEAT_SME. |
4 | 4 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20220506180242.216785-24-richard.henderson@linaro.org | 7 | Message-id: 20220607203306.657998-20-richard.henderson@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 9 | --- |
10 | docs/system/arm/virt.rst | 1 + | 10 | target/arm/cpu.h | 5 +++++ |
11 | hw/arm/sbsa-ref.c | 1 + | 11 | 1 file changed, 5 insertions(+) |
12 | hw/arm/virt.c | 1 + | ||
13 | target/arm/cpu64.c | 66 ++++++++++++++++++++++++++++++++++++++++ | ||
14 | 4 files changed, 69 insertions(+) | ||
15 | 12 | ||
16 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst | 13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
17 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/docs/system/arm/virt.rst | 15 | --- a/target/arm/cpu.h |
19 | +++ b/docs/system/arm/virt.rst | 16 | +++ b/target/arm/cpu.h |
20 | @@ -XXX,XX +XXX,XX @@ Supported guest CPU types: | 17 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_mte(const ARMISARegisters *id) |
21 | - ``cortex-a53`` (64-bit) | 18 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, MTE) >= 2; |
22 | - ``cortex-a57`` (64-bit) | ||
23 | - ``cortex-a72`` (64-bit) | ||
24 | +- ``cortex-a76`` (64-bit) | ||
25 | - ``a64fx`` (64-bit) | ||
26 | - ``host`` (with KVM only) | ||
27 | - ``max`` (same as ``host`` for KVM; best possible emulation with TCG) | ||
28 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/hw/arm/sbsa-ref.c | ||
31 | +++ b/hw/arm/sbsa-ref.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { | ||
33 | static const char * const valid_cpus[] = { | ||
34 | ARM_CPU_TYPE_NAME("cortex-a57"), | ||
35 | ARM_CPU_TYPE_NAME("cortex-a72"), | ||
36 | + ARM_CPU_TYPE_NAME("cortex-a76"), | ||
37 | ARM_CPU_TYPE_NAME("max"), | ||
38 | }; | ||
39 | |||
40 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/arm/virt.c | ||
43 | +++ b/hw/arm/virt.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = { | ||
45 | ARM_CPU_TYPE_NAME("cortex-a53"), | ||
46 | ARM_CPU_TYPE_NAME("cortex-a57"), | ||
47 | ARM_CPU_TYPE_NAME("cortex-a72"), | ||
48 | + ARM_CPU_TYPE_NAME("cortex-a76"), | ||
49 | ARM_CPU_TYPE_NAME("a64fx"), | ||
50 | ARM_CPU_TYPE_NAME("host"), | ||
51 | ARM_CPU_TYPE_NAME("max"), | ||
52 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/cpu64.c | ||
55 | +++ b/target/arm/cpu64.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
57 | define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
58 | } | 19 | } |
59 | 20 | ||
60 | +static void aarch64_a76_initfn(Object *obj) | 21 | +static inline bool isar_feature_aa64_sme(const ARMISARegisters *id) |
61 | +{ | 22 | +{ |
62 | + ARMCPU *cpu = ARM_CPU(obj); | 23 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SME) != 0; |
63 | + | ||
64 | + cpu->dtb_compatible = "arm,cortex-a76"; | ||
65 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
66 | + set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
67 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
68 | + set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
69 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
70 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
71 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
72 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
73 | + | ||
74 | + /* Ordered by B2.4 AArch64 registers by functional group */ | ||
75 | + cpu->clidr = 0x82000023; | ||
76 | + cpu->ctr = 0x8444C004; | ||
77 | + cpu->dcz_blocksize = 4; | ||
78 | + cpu->isar.id_aa64dfr0 = 0x0000000010305408ull; | ||
79 | + cpu->isar.id_aa64isar0 = 0x0000100010211120ull; | ||
80 | + cpu->isar.id_aa64isar1 = 0x0000000000100001ull; | ||
81 | + cpu->isar.id_aa64mmfr0 = 0x0000000000101122ull; | ||
82 | + cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; | ||
83 | + cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull; | ||
84 | + cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */ | ||
85 | + cpu->isar.id_aa64pfr1 = 0x0000000000000010ull; | ||
86 | + cpu->id_afr0 = 0x00000000; | ||
87 | + cpu->isar.id_dfr0 = 0x04010088; | ||
88 | + cpu->isar.id_isar0 = 0x02101110; | ||
89 | + cpu->isar.id_isar1 = 0x13112111; | ||
90 | + cpu->isar.id_isar2 = 0x21232042; | ||
91 | + cpu->isar.id_isar3 = 0x01112131; | ||
92 | + cpu->isar.id_isar4 = 0x00010142; | ||
93 | + cpu->isar.id_isar5 = 0x01011121; | ||
94 | + cpu->isar.id_isar6 = 0x00000010; | ||
95 | + cpu->isar.id_mmfr0 = 0x10201105; | ||
96 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
97 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
98 | + cpu->isar.id_mmfr3 = 0x02122211; | ||
99 | + cpu->isar.id_mmfr4 = 0x00021110; | ||
100 | + cpu->isar.id_pfr0 = 0x10010131; | ||
101 | + cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ | ||
102 | + cpu->isar.id_pfr2 = 0x00000011; | ||
103 | + cpu->midr = 0x414fd0b1; /* r4p1 */ | ||
104 | + cpu->revidr = 0; | ||
105 | + | ||
106 | + /* From B2.18 CCSIDR_EL1 */ | ||
107 | + cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */ | ||
108 | + cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */ | ||
109 | + cpu->ccsidr[2] = 0x707fe03a; /* 512KB L2 cache */ | ||
110 | + | ||
111 | + /* From B2.93 SCTLR_EL3 */ | ||
112 | + cpu->reset_sctlr = 0x30c50838; | ||
113 | + | ||
114 | + /* From B4.23 ICH_VTR_EL2 */ | ||
115 | + cpu->gic_num_lrs = 4; | ||
116 | + cpu->gic_vpribits = 5; | ||
117 | + cpu->gic_vprebits = 5; | ||
118 | + | ||
119 | + /* From B5.1 AdvSIMD AArch64 register summary */ | ||
120 | + cpu->isar.mvfr0 = 0x10110222; | ||
121 | + cpu->isar.mvfr1 = 0x13211111; | ||
122 | + cpu->isar.mvfr2 = 0x00000043; | ||
123 | +} | 24 | +} |
124 | + | 25 | + |
125 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | 26 | static inline bool isar_feature_aa64_pmu_8_1(const ARMISARegisters *id) |
126 | { | 27 | { |
127 | /* | 28 | return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >= 4 && |
128 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { | ||
129 | { .name = "cortex-a57", .initfn = aarch64_a57_initfn }, | ||
130 | { .name = "cortex-a53", .initfn = aarch64_a53_initfn }, | ||
131 | { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, | ||
132 | + { .name = "cortex-a76", .initfn = aarch64_a76_initfn }, | ||
133 | { .name = "a64fx", .initfn = aarch64_a64fx_initfn }, | ||
134 | { .name = "max", .initfn = aarch64_max_initfn }, | ||
135 | #if defined(CONFIG_KVM) || defined(CONFIG_HVF) | ||
136 | -- | 29 | -- |
137 | 2.25.1 | 30 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Virtual SError exceptions are raised by setting HCR_EL2.VSE, | 3 | This register is allocated from the existing block of id registers, |
4 | and are routed to EL1 just like other virtual exceptions. | 4 | so it is already RES0 for cpus that do not implement SME. |
5 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220506180242.216785-16-richard.henderson@linaro.org | 8 | Message-id: 20220607203306.657998-21-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | target/arm/cpu.h | 2 ++ | 11 | target/arm/cpu.h | 25 +++++++++++++++++++++++++ |
12 | target/arm/internals.h | 8 ++++++++ | 12 | target/arm/helper.c | 4 ++-- |
13 | target/arm/syndrome.h | 5 +++++ | 13 | target/arm/kvm64.c | 11 +++++++---- |
14 | target/arm/cpu.c | 38 +++++++++++++++++++++++++++++++++++++- | 14 | 3 files changed, 34 insertions(+), 6 deletions(-) |
15 | target/arm/helper.c | 40 +++++++++++++++++++++++++++++++++++++++- | ||
16 | 5 files changed, 91 insertions(+), 2 deletions(-) | ||
17 | 15 | ||
18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/cpu.h | 18 | --- a/target/arm/cpu.h |
21 | +++ b/target/arm/cpu.h | 19 | +++ b/target/arm/cpu.h |
22 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
23 | #define EXCP_LSERR 21 /* v8M LSERR SecureFault */ | 21 | uint64_t id_aa64dfr0; |
24 | #define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */ | 22 | uint64_t id_aa64dfr1; |
25 | #define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */ | 23 | uint64_t id_aa64zfr0; |
26 | +#define EXCP_VSERR 24 | 24 | + uint64_t id_aa64smfr0; |
27 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | 25 | uint64_t reset_pmcr_el0; |
28 | 26 | } isar; | |
29 | #define ARMV7M_EXCP_RESET 1 | 27 | uint64_t midr; |
30 | @@ -XXX,XX +XXX,XX @@ enum { | 28 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64ZFR0, I8MM, 44, 4) |
31 | #define CPU_INTERRUPT_FIQ CPU_INTERRUPT_TGT_EXT_1 | 29 | FIELD(ID_AA64ZFR0, F32MM, 52, 4) |
32 | #define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_EXT_2 | 30 | FIELD(ID_AA64ZFR0, F64MM, 56, 4) |
33 | #define CPU_INTERRUPT_VFIQ CPU_INTERRUPT_TGT_EXT_3 | 31 | |
34 | +#define CPU_INTERRUPT_VSERR CPU_INTERRUPT_TGT_INT_0 | 32 | +FIELD(ID_AA64SMFR0, F32F32, 32, 1) |
35 | 33 | +FIELD(ID_AA64SMFR0, B16F32, 34, 1) | |
36 | /* The usual mapping for an AArch64 system register to its AArch32 | 34 | +FIELD(ID_AA64SMFR0, F16F32, 35, 1) |
37 | * counterpart is for the 32 bit world to have access to the lower | 35 | +FIELD(ID_AA64SMFR0, I8I32, 36, 4) |
38 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 36 | +FIELD(ID_AA64SMFR0, F64F64, 48, 1) |
39 | index XXXXXXX..XXXXXXX 100644 | 37 | +FIELD(ID_AA64SMFR0, I16I64, 52, 4) |
40 | --- a/target/arm/internals.h | 38 | +FIELD(ID_AA64SMFR0, SMEVER, 56, 4) |
41 | +++ b/target/arm/internals.h | 39 | +FIELD(ID_AA64SMFR0, FA64, 63, 1) |
42 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu); | ||
43 | */ | ||
44 | void arm_cpu_update_vfiq(ARMCPU *cpu); | ||
45 | |||
46 | +/** | ||
47 | + * arm_cpu_update_vserr: Update CPU_INTERRUPT_VSERR bit | ||
48 | + * | ||
49 | + * Update the CPU_INTERRUPT_VSERR bit in cs->interrupt_request, | ||
50 | + * following a change to the HCR_EL2.VSE bit. | ||
51 | + */ | ||
52 | +void arm_cpu_update_vserr(ARMCPU *cpu); | ||
53 | + | 40 | + |
54 | /** | 41 | FIELD(ID_DFR0, COPDBG, 0, 4) |
55 | * arm_mmu_idx_el: | 42 | FIELD(ID_DFR0, COPSDBG, 4, 4) |
56 | * @env: The cpu environment | 43 | FIELD(ID_DFR0, MMAPDBG, 8, 4) |
57 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h | 44 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sve_f64mm(const ARMISARegisters *id) |
58 | index XXXXXXX..XXXXXXX 100644 | 45 | return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, F64MM) != 0; |
59 | --- a/target/arm/syndrome.h | ||
60 | +++ b/target/arm/syndrome.h | ||
61 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_pcalignment(void) | ||
62 | return (EC_PCALIGNMENT << ARM_EL_EC_SHIFT) | ARM_EL_IL; | ||
63 | } | 46 | } |
64 | 47 | ||
65 | +static inline uint32_t syn_serror(uint32_t extra) | 48 | +static inline bool isar_feature_aa64_sme_f64f64(const ARMISARegisters *id) |
66 | +{ | 49 | +{ |
67 | + return (EC_SERROR << ARM_EL_EC_SHIFT) | ARM_EL_IL | extra; | 50 | + return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, F64F64); |
68 | +} | 51 | +} |
69 | + | 52 | + |
70 | #endif /* TARGET_ARM_SYNDROME_H */ | 53 | +static inline bool isar_feature_aa64_sme_i16i64(const ARMISARegisters *id) |
71 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/cpu.c | ||
74 | +++ b/target/arm/cpu.c | ||
75 | @@ -XXX,XX +XXX,XX @@ static bool arm_cpu_has_work(CPUState *cs) | ||
76 | return (cpu->power_state != PSCI_OFF) | ||
77 | && cs->interrupt_request & | ||
78 | (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD | ||
79 | - | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ | ||
80 | + | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VSERR | ||
81 | | CPU_INTERRUPT_EXITTB); | ||
82 | } | ||
83 | |||
84 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
85 | return false; | ||
86 | } | ||
87 | return !(env->daif & PSTATE_I); | ||
88 | + case EXCP_VSERR: | ||
89 | + if (!(hcr_el2 & HCR_AMO) || (hcr_el2 & HCR_TGE)) { | ||
90 | + /* VIRQs are only taken when hypervized. */ | ||
91 | + return false; | ||
92 | + } | ||
93 | + return !(env->daif & PSTATE_A); | ||
94 | default: | ||
95 | g_assert_not_reached(); | ||
96 | } | ||
97 | @@ -XXX,XX +XXX,XX @@ static bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
98 | goto found; | ||
99 | } | ||
100 | } | ||
101 | + if (interrupt_request & CPU_INTERRUPT_VSERR) { | ||
102 | + excp_idx = EXCP_VSERR; | ||
103 | + target_el = 1; | ||
104 | + if (arm_excp_unmasked(cs, excp_idx, target_el, | ||
105 | + cur_el, secure, hcr_el2)) { | ||
106 | + /* Taking a virtual abort clears HCR_EL2.VSE */ | ||
107 | + env->cp15.hcr_el2 &= ~HCR_VSE; | ||
108 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR); | ||
109 | + goto found; | ||
110 | + } | ||
111 | + } | ||
112 | return false; | ||
113 | |||
114 | found: | ||
115 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_vfiq(ARMCPU *cpu) | ||
116 | } | ||
117 | } | ||
118 | |||
119 | +void arm_cpu_update_vserr(ARMCPU *cpu) | ||
120 | +{ | 54 | +{ |
121 | + /* | 55 | + return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, I16I64) == 0xf; |
122 | + * Update the interrupt level for VSERR, which is the HCR_EL2.VSE bit. | ||
123 | + */ | ||
124 | + CPUARMState *env = &cpu->env; | ||
125 | + CPUState *cs = CPU(cpu); | ||
126 | + | ||
127 | + bool new_state = env->cp15.hcr_el2 & HCR_VSE; | ||
128 | + | ||
129 | + if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VSERR) != 0)) { | ||
130 | + if (new_state) { | ||
131 | + cpu_interrupt(cs, CPU_INTERRUPT_VSERR); | ||
132 | + } else { | ||
133 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR); | ||
134 | + } | ||
135 | + } | ||
136 | +} | 56 | +} |
137 | + | 57 | + |
138 | #ifndef CONFIG_USER_ONLY | 58 | +static inline bool isar_feature_aa64_sme_fa64(const ARMISARegisters *id) |
139 | static void arm_cpu_set_irq(void *opaque, int irq, int level) | 59 | +{ |
140 | { | 60 | + return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, FA64); |
61 | +} | ||
62 | + | ||
63 | /* | ||
64 | * Feature tests for "does this exist in either 32-bit or 64-bit?" | ||
65 | */ | ||
141 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 66 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
142 | index XXXXXXX..XXXXXXX 100644 | 67 | index XXXXXXX..XXXXXXX 100644 |
143 | --- a/target/arm/helper.c | 68 | --- a/target/arm/helper.c |
144 | +++ b/target/arm/helper.c | 69 | +++ b/target/arm/helper.c |
145 | @@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 70 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
146 | } | 71 | .access = PL1_R, .type = ARM_CP_CONST, |
147 | } | 72 | .accessfn = access_aa64_tid3, |
148 | 73 | .resetvalue = cpu->isar.id_aa64zfr0 }, | |
149 | - /* External aborts are not possible in QEMU so A bit is always clear */ | 74 | - { .name = "ID_AA64PFR5_EL1_RESERVED", .state = ARM_CP_STATE_AA64, |
150 | + if (hcr_el2 & HCR_AMO) { | 75 | + { .name = "ID_AA64SMFR0_EL1", .state = ARM_CP_STATE_AA64, |
151 | + if (cs->interrupt_request & CPU_INTERRUPT_VSERR) { | 76 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 5, |
152 | + ret |= CPSR_A; | 77 | .access = PL1_R, .type = ARM_CP_CONST, |
153 | + } | 78 | .accessfn = access_aa64_tid3, |
154 | + } | 79 | - .resetvalue = 0 }, |
155 | + | 80 | + .resetvalue = cpu->isar.id_aa64smfr0 }, |
156 | return ret; | 81 | { .name = "ID_AA64PFR6_EL1_RESERVED", .state = ARM_CP_STATE_AA64, |
157 | } | 82 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 6, |
158 | 83 | .access = PL1_R, .type = ARM_CP_CONST, | |
159 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | 84 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c |
160 | g_assert(qemu_mutex_iothread_locked()); | 85 | index XXXXXXX..XXXXXXX 100644 |
161 | arm_cpu_update_virq(cpu); | 86 | --- a/target/arm/kvm64.c |
162 | arm_cpu_update_vfiq(cpu); | 87 | +++ b/target/arm/kvm64.c |
163 | + arm_cpu_update_vserr(cpu); | 88 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) |
164 | } | 89 | } else { |
165 | 90 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr1, | |
166 | static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 91 | ARM64_SYS_REG(3, 0, 0, 4, 1)); |
167 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs) | 92 | + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64smfr0, |
168 | [EXCP_LSERR] = "v8M LSERR UsageFault", | 93 | + ARM64_SYS_REG(3, 0, 0, 4, 5)); |
169 | [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | 94 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr0, |
170 | [EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault", | 95 | ARM64_SYS_REG(3, 0, 0, 5, 0)); |
171 | + [EXCP_VSERR] = "Virtual SERR", | 96 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr1, |
172 | }; | 97 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) |
173 | 98 | ahcf->isar.id_aa64pfr0 = t; | |
174 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | 99 | |
175 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs) | 100 | /* |
176 | mask = CPSR_A | CPSR_I | CPSR_F; | 101 | - * Before v5.1, KVM did not support SVE and did not expose |
177 | offset = 4; | 102 | - * ID_AA64ZFR0_EL1 even as RAZ. After v5.1, KVM still does |
178 | break; | 103 | - * not expose the register to "user" requests like this |
179 | + case EXCP_VSERR: | 104 | - * unless the host supports SVE. |
180 | + { | 105 | + * There is a range of kernels between kernel commit 73433762fcae |
181 | + /* | 106 | + * and f81cb2c3ad41 which have a bug where the kernel doesn't expose |
182 | + * Note that this is reported as a data abort, but the DFAR | 107 | + * SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the VM has enabled |
183 | + * has an UNKNOWN value. Construct the SError syndrome from | 108 | + * SVE support, so we only read it here, rather than together with all |
184 | + * AET and ExT fields. | 109 | + * the other ID registers earlier. |
185 | + */ | 110 | */ |
186 | + ARMMMUFaultInfo fi = { .type = ARMFault_AsyncExternal, }; | 111 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0, |
187 | + | 112 | ARM64_SYS_REG(3, 0, 0, 4, 4)); |
188 | + if (extended_addresses_enabled(env)) { | ||
189 | + env->exception.fsr = arm_fi_to_lfsc(&fi); | ||
190 | + } else { | ||
191 | + env->exception.fsr = arm_fi_to_sfsc(&fi); | ||
192 | + } | ||
193 | + env->exception.fsr |= env->cp15.vsesr_el2 & 0xd000; | ||
194 | + A32_BANKED_CURRENT_REG_SET(env, dfsr, env->exception.fsr); | ||
195 | + qemu_log_mask(CPU_LOG_INT, "...with IFSR 0x%x\n", | ||
196 | + env->exception.fsr); | ||
197 | + | ||
198 | + new_mode = ARM_CPU_MODE_ABT; | ||
199 | + addr = 0x10; | ||
200 | + mask = CPSR_A | CPSR_I; | ||
201 | + offset = 8; | ||
202 | + } | ||
203 | + break; | ||
204 | case EXCP_SMC: | ||
205 | new_mode = ARM_CPU_MODE_MON; | ||
206 | addr = 0x08; | ||
207 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | ||
208 | case EXCP_VFIQ: | ||
209 | addr += 0x100; | ||
210 | break; | ||
211 | + case EXCP_VSERR: | ||
212 | + addr += 0x180; | ||
213 | + /* Construct the SError syndrome from IDS and ISS fields. */ | ||
214 | + env->exception.syndrome = syn_serror(env->cp15.vsesr_el2 & 0x1ffffff); | ||
215 | + env->cp15.esr_el[new_el] = env->exception.syndrome; | ||
216 | + break; | ||
217 | default: | ||
218 | cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); | ||
219 | } | ||
220 | -- | 113 | -- |
221 | 2.25.1 | 114 | 2.25.1 | diff view generated by jsdifflib |