1 | target-arm queue: nothing major here, but no point | 1 | Changes v1->v2 (fixing CI failures in v1, added a couple of |
---|---|---|---|
2 | sitting on them waiting for more stuff to come along. | 2 | extra patches in an attempt to avoid having to do a last |
3 | minute arm pullreq next week): | ||
4 | * new patch to hopefully fix the build issue with the SVE/SME sysregs test | ||
5 | * dropped the IC IVAU test case patch | ||
6 | * new patch: fix over-length shift | ||
7 | * new patches: define neoverse-v1 | ||
3 | 8 | ||
4 | thanks | 9 | thanks |
5 | -- PMM | 10 | -- PMM |
6 | 11 | ||
7 | The following changes since commit 1329132d28bf14b9508f7a1f04a2c63422bc3f99: | 12 | The following changes since commit 2a6ae69154542caa91dd17c40fd3f5ffbec300de: |
8 | 13 | ||
9 | Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2019-09-26 16:14:03 +0100) | 14 | Merge tag 'pull-maintainer-ominbus-030723-1' of https://gitlab.com/stsquad/qemu into staging (2023-07-04 08:36:44 +0200) |
10 | 15 | ||
11 | are available in the Git repository at: | 16 | are available in the Git repository at: |
12 | 17 | ||
13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190927 | 18 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230706 |
14 | 19 | ||
15 | for you to fetch changes up to e4e34855e658b78ecac50a651cc847662ff02cfd: | 20 | for you to fetch changes up to c41077235168140cdd4a34fce9bd95c3d30efe9c: |
16 | 21 | ||
17 | hw/arm/boot: Use the IEC binary prefix definitions (2019-09-27 11:44:39 +0100) | 22 | target/arm: Avoid over-length shift in arm_cpu_sve_finalize() error case (2023-07-06 13:36:51 +0100) |
18 | 23 | ||
19 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
20 | target-arm queue: | 25 | target-arm queue: |
21 | * Fix the CBAR register implementation for Cortex-A53, | 26 | * Add raw_writes ops for register whose write induce TLB maintenance |
22 | Cortex-A57, Cortex-A72 | 27 | * hw/arm/sbsa-ref: use XHCI to replace EHCI |
23 | * Fix direct booting of Linux kernels on emulated CPUs | 28 | * Avoid splitting Zregs across lines in dump |
24 | which have an AArch32 EL3 (incorrect NSACR settings | 29 | * Dump ZA[] when active |
25 | meant they could not access the FPU) | 30 | * Fix SME full tile indexing |
26 | * semihosting cleanup: do more work at translate time | 31 | * Handle IC IVAU to improve compatibility with JITs |
27 | and less work at runtime | 32 | * xlnx-canfd-test: Fix code coverity issues |
33 | * gdbstub: Guard M-profile code with CONFIG_TCG | ||
34 | * allwinner-sramc: Set class_size | ||
35 | * target/xtensa: Assert that interrupt level is within bounds | ||
36 | * Avoid over-length shift in arm_cpu_sve_finalize() error case | ||
37 | * Define new 'neoverse-v1' CPU type | ||
28 | 38 | ||
29 | ---------------------------------------------------------------- | 39 | ---------------------------------------------------------------- |
30 | Alex Bennée (6): | 40 | Akihiko Odaki (1): |
31 | tests/tcg: clean-up some comments after the de-tangling | 41 | hw: arm: allwinner-sramc: Set class_size |
32 | target/arm: handle M-profile semihosting at translate time | ||
33 | target/arm: handle A-profile semihosting at translate time | ||
34 | target/arm: remove run time semihosting checks | ||
35 | target/arm: remove run-time semihosting checks for linux-user | ||
36 | tests/tcg: add linux-user semihosting smoke test for ARM | ||
37 | 42 | ||
38 | Luc Michel (1): | 43 | Eric Auger (1): |
39 | target/arm: fix CBAR register for AArch64 CPUs | 44 | target/arm: Add raw_writes ops for register whose write induce TLB maintenance |
40 | 45 | ||
41 | Peter Maydell (1): | 46 | Fabiano Rosas (1): |
42 | hw/arm/boot.c: Set NSACR.{CP11,CP10} for NS kernel boots | 47 | target/arm: gdbstub: Guard M-profile code with CONFIG_TCG |
43 | 48 | ||
44 | Philippe Mathieu-Daudé (1): | 49 | John Högberg (1): |
45 | hw/arm/boot: Use the IEC binary prefix definitions | 50 | target/arm: Handle IC IVAU to improve compatibility with JITs |
46 | 51 | ||
47 | tests/tcg/Makefile.target | 7 ++- | 52 | Peter Maydell (5): |
48 | tests/tcg/aarch64/Makefile.target | 8 ++- | 53 | tests/tcg/aarch64/sysregs.c: Use S syntax for id_aa64zfr0_el1 and id_aa64smfr0_el1 |
49 | tests/tcg/arm/Makefile.target | 20 ++++--- | 54 | target/xtensa: Assert that interrupt level is within bounds |
50 | linux-user/arm/target_syscall.h | 3 - | 55 | target/arm: Suppress more TCG unimplemented features in ID registers |
51 | hw/arm/boot.c | 12 ++-- | 56 | target/arm: Define neoverse-v1 |
52 | linux-user/arm/cpu_loop.c | 3 - | 57 | target/arm: Avoid over-length shift in arm_cpu_sve_finalize() error case |
53 | target/arm/helper.c | 115 +++++++++++++------------------------- | ||
54 | target/arm/m_helper.c | 18 ++---- | ||
55 | target/arm/translate.c | 30 ++++++++-- | ||
56 | tests/tcg/arm/semihosting.c | 45 +++++++++++++++ | ||
57 | 10 files changed, 146 insertions(+), 115 deletions(-) | ||
58 | create mode 100644 tests/tcg/arm/semihosting.c | ||
59 | 58 | ||
59 | Richard Henderson (3): | ||
60 | target/arm: Avoid splitting Zregs across lines in dump | ||
61 | target/arm: Dump ZA[] when active | ||
62 | target/arm: Fix SME full tile indexing | ||
63 | |||
64 | Vikram Garhwal (1): | ||
65 | tests/qtest: xlnx-canfd-test: Fix code coverity issues | ||
66 | |||
67 | Yuquan Wang (1): | ||
68 | hw/arm/sbsa-ref: use XHCI to replace EHCI | ||
69 | |||
70 | docs/system/arm/sbsa.rst | 5 +- | ||
71 | docs/system/arm/virt.rst | 1 + | ||
72 | hw/arm/sbsa-ref.c | 24 ++++--- | ||
73 | hw/arm/virt.c | 1 + | ||
74 | hw/misc/allwinner-sramc.c | 1 + | ||
75 | target/arm/cpu.c | 98 +++++++++++++++++++++-------- | ||
76 | target/arm/cpu64.c | 4 +- | ||
77 | target/arm/gdbstub.c | 4 ++ | ||
78 | target/arm/helper.c | 70 +++++++++++++++++---- | ||
79 | target/arm/tcg/cpu64.c | 128 ++++++++++++++++++++++++++++++++++++++ | ||
80 | target/arm/tcg/translate-sme.c | 24 +++++-- | ||
81 | target/xtensa/exc_helper.c | 3 + | ||
82 | tests/qtest/xlnx-canfd-test.c | 33 ++++------ | ||
83 | tests/tcg/aarch64/sme-outprod1.c | 83 ++++++++++++++++++++++++ | ||
84 | tests/tcg/aarch64/sysregs.c | 11 ++-- | ||
85 | hw/arm/Kconfig | 2 +- | ||
86 | tests/tcg/aarch64/Makefile.target | 16 ++--- | ||
87 | 17 files changed, 415 insertions(+), 93 deletions(-) | ||
88 | create mode 100644 tests/tcg/aarch64/sme-outprod1.c | ||
89 | diff view generated by jsdifflib |
1 | From: Luc Michel <luc.michel@greensocs.com> | 1 | From: Eric Auger <eric.auger@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | For AArch64 CPUs with a CBAR register, we have two views for it: | 3 | Some registers whose 'cooked' writefns induce TLB maintenance do |
4 | - in AArch64 state, the CBAR_EL1 register (S3_1_C15_C3_0), returns the | 4 | not have raw_writefn ops defined. If only the writefn ops is set |
5 | full 64 bits CBAR value | 5 | (ie. no raw_writefn is provided), it is assumed the cooked also |
6 | - in AArch32 state, the CBAR register (cp15, opc1=1, CRn=15, CRm=3, opc2=0) | 6 | work as the raw one. For those registers it is not obvious the |
7 | returns a 32 bits view such that: | 7 | tlb_flush works on KVM mode so better/safer setting the raw write. |
8 | CBAR = CBAR_EL1[31:18] 0..0 CBAR_EL1[43:32] | ||
9 | 8 | ||
10 | This commit fixes the current implementation where: | 9 | Signed-off-by: Eric Auger <eric.auger@redhat.com> |
11 | - CBAR_EL1 was returning the 32 bits view instead of the full 64 bits | 10 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> |
12 | value, | ||
13 | - CBAR was returning a truncated 32 bits version of the full 64 bits | ||
14 | one, instead of the 32 bits view | ||
15 | - CBAR was declared as cp15, opc1=4, CRn=15, CRm=0, opc2=0, which is | ||
16 | the CBAR register found in the ARMv7 Cortex-Ax CPUs, but not in | ||
17 | ARMv8 CPUs. | ||
18 | |||
19 | Signed-off-by: Luc Michel <luc.michel@greensocs.com> | ||
20 | Message-id: 20190912110103.1417887-1-luc.michel@greensocs.com | ||
21 | [PMM: Added a comment about the two different kinds of CBAR] | ||
22 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | --- | 13 | --- |
25 | target/arm/helper.c | 19 ++++++++++++++++--- | 14 | target/arm/helper.c | 23 +++++++++++++---------- |
26 | 1 file changed, 16 insertions(+), 3 deletions(-) | 15 | 1 file changed, 13 insertions(+), 10 deletions(-) |
27 | 16 | ||
28 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
29 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/helper.c | 19 | --- a/target/arm/helper.c |
31 | +++ b/target/arm/helper.c | 20 | +++ b/target/arm/helper.c |
32 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 21 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { |
33 | } | 22 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 0, |
34 | 23 | .access = PL1_RW, .accessfn = access_tvm_trvm, | |
35 | if (arm_feature(env, ARM_FEATURE_CBAR)) { | 24 | .fgt = FGT_TTBR0_EL1, |
36 | + /* | 25 | - .writefn = vmsa_ttbr_write, .resetvalue = 0, |
37 | + * CBAR is IMPDEF, but common on Arm Cortex-A implementations. | 26 | + .writefn = vmsa_ttbr_write, .resetvalue = 0, .raw_writefn = raw_write, |
38 | + * There are two flavours: | 27 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s), |
39 | + * (1) older 32-bit only cores have a simple 32-bit CBAR | 28 | offsetof(CPUARMState, cp15.ttbr0_ns) } }, |
40 | + * (2) 64-bit cores have a 64-bit CBAR visible to AArch64, plus a | 29 | { .name = "TTBR1_EL1", .state = ARM_CP_STATE_BOTH, |
41 | + * 32-bit register visible to AArch32 at a different encoding | 30 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 1, |
42 | + * to the "flavour 1" register and with the bits rearranged to | 31 | .access = PL1_RW, .accessfn = access_tvm_trvm, |
43 | + * be able to squash a 64-bit address into the 32-bit view. | 32 | .fgt = FGT_TTBR1_EL1, |
44 | + * We distinguish the two via the ARM_FEATURE_AARCH64 flag, but | 33 | - .writefn = vmsa_ttbr_write, .resetvalue = 0, |
45 | + * in future if we support AArch32-only configs of some of the | 34 | + .writefn = vmsa_ttbr_write, .resetvalue = 0, .raw_writefn = raw_write, |
46 | + * AArch64 cores we might need to add a specific feature flag | 35 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), |
47 | + * to indicate cores with "flavour 2" CBAR. | 36 | offsetof(CPUARMState, cp15.ttbr1_ns) } }, |
48 | + */ | 37 | { .name = "TCR_EL1", .state = ARM_CP_STATE_AA64, |
49 | if (arm_feature(env, ARM_FEATURE_AARCH64)) { | 38 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = { |
50 | /* 32 bit view is [31:18] 0...0 [43:32]. */ | 39 | .type = ARM_CP_64BIT | ARM_CP_ALIAS, |
51 | uint32_t cbar32 = (extract64(cpu->reset_cbar, 18, 14) << 18) | 40 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s), |
52 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 41 | offsetof(CPUARMState, cp15.ttbr0_ns) }, |
53 | ARMCPRegInfo cbar_reginfo[] = { | 42 | - .writefn = vmsa_ttbr_write, }, |
54 | { .name = "CBAR", | 43 | + .writefn = vmsa_ttbr_write, .raw_writefn = raw_write }, |
55 | .type = ARM_CP_CONST, | 44 | { .name = "TTBR1", .cp = 15, .crm = 2, .opc1 = 1, |
56 | - .cp = 15, .crn = 15, .crm = 0, .opc1 = 4, .opc2 = 0, | 45 | .access = PL1_RW, .accessfn = access_tvm_trvm, |
57 | - .access = PL1_R, .resetvalue = cpu->reset_cbar }, | 46 | .type = ARM_CP_64BIT | ARM_CP_ALIAS, |
58 | + .cp = 15, .crn = 15, .crm = 3, .opc1 = 1, .opc2 = 0, | 47 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), |
59 | + .access = PL1_R, .resetvalue = cbar32 }, | 48 | offsetof(CPUARMState, cp15.ttbr1_ns) }, |
60 | { .name = "CBAR_EL1", .state = ARM_CP_STATE_AA64, | 49 | - .writefn = vmsa_ttbr_write, }, |
61 | .type = ARM_CP_CONST, | 50 | + .writefn = vmsa_ttbr_write, .raw_writefn = raw_write }, |
62 | .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 0, | 51 | }; |
63 | - .access = PL1_R, .resetvalue = cbar32 }, | 52 | |
64 | + .access = PL1_R, .resetvalue = cpu->reset_cbar }, | 53 | static uint64_t aa64_fpcr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
65 | REGINFO_SENTINEL | 54 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { |
66 | }; | 55 | .type = ARM_CP_IO, |
67 | /* We don't implement a r/w 64 bit CBAR currently */ | 56 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, |
57 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), | ||
58 | - .writefn = hcr_write }, | ||
59 | + .writefn = hcr_write, .raw_writefn = raw_write }, | ||
60 | { .name = "HCR", .state = ARM_CP_STATE_AA32, | ||
61 | .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
62 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, | ||
63 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
64 | { .name = "TCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
65 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 2, | ||
66 | .access = PL2_RW, .writefn = vmsa_tcr_el12_write, | ||
67 | + .raw_writefn = raw_write, | ||
68 | .fieldoffset = offsetof(CPUARMState, cp15.tcr_el[2]) }, | ||
69 | { .name = "VTCR", .state = ARM_CP_STATE_AA32, | ||
70 | .cp = 15, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 2, | ||
71 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
72 | .type = ARM_CP_64BIT | ARM_CP_ALIAS, | ||
73 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
74 | .fieldoffset = offsetof(CPUARMState, cp15.vttbr_el2), | ||
75 | - .writefn = vttbr_write }, | ||
76 | + .writefn = vttbr_write, .raw_writefn = raw_write }, | ||
77 | { .name = "VTTBR_EL2", .state = ARM_CP_STATE_AA64, | ||
78 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 0, | ||
79 | - .access = PL2_RW, .writefn = vttbr_write, | ||
80 | + .access = PL2_RW, .writefn = vttbr_write, .raw_writefn = raw_write, | ||
81 | .fieldoffset = offsetof(CPUARMState, cp15.vttbr_el2) }, | ||
82 | { .name = "SCTLR_EL2", .state = ARM_CP_STATE_BOTH, | ||
83 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 0, | ||
84 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
85 | .fieldoffset = offsetof(CPUARMState, cp15.tpidr_el[2]) }, | ||
86 | { .name = "TTBR0_EL2", .state = ARM_CP_STATE_AA64, | ||
87 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 0, | ||
88 | - .access = PL2_RW, .resetvalue = 0, .writefn = vmsa_tcr_ttbr_el2_write, | ||
89 | + .access = PL2_RW, .resetvalue = 0, | ||
90 | + .writefn = vmsa_tcr_ttbr_el2_write, .raw_writefn = raw_write, | ||
91 | .fieldoffset = offsetof(CPUARMState, cp15.ttbr0_el[2]) }, | ||
92 | { .name = "HTTBR", .cp = 15, .opc1 = 4, .crm = 2, | ||
93 | .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_ALIAS, | ||
94 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_cp_reginfo[] = { | ||
95 | { .name = "SCR_EL3", .state = ARM_CP_STATE_AA64, | ||
96 | .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 1, .opc2 = 0, | ||
97 | .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.scr_el3), | ||
98 | - .resetfn = scr_reset, .writefn = scr_write }, | ||
99 | + .resetfn = scr_reset, .writefn = scr_write, .raw_writefn = raw_write }, | ||
100 | { .name = "SCR", .type = ARM_CP_ALIAS | ARM_CP_NEWEL, | ||
101 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 0, | ||
102 | .access = PL1_RW, .accessfn = access_trap_aa32s_el1, | ||
103 | .fieldoffset = offsetoflow32(CPUARMState, cp15.scr_el3), | ||
104 | - .writefn = scr_write }, | ||
105 | + .writefn = scr_write, .raw_writefn = raw_write }, | ||
106 | { .name = "SDER32_EL3", .state = ARM_CP_STATE_AA64, | ||
107 | .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 1, .opc2 = 1, | ||
108 | .access = PL3_RW, .resetvalue = 0, | ||
109 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { | ||
110 | { .name = "TTBR1_EL2", .state = ARM_CP_STATE_AA64, | ||
111 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 1, | ||
112 | .access = PL2_RW, .writefn = vmsa_tcr_ttbr_el2_write, | ||
113 | + .raw_writefn = raw_write, | ||
114 | .fieldoffset = offsetof(CPUARMState, cp15.ttbr1_el[2]) }, | ||
115 | #ifndef CONFIG_USER_ONLY | ||
116 | { .name = "CNTHV_CVAL_EL2", .state = ARM_CP_STATE_AA64, | ||
68 | -- | 117 | -- |
69 | 2.20.1 | 118 | 2.34.1 |
70 | |||
71 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Yuquan Wang <wangyuquan1236@phytium.com.cn> |
---|---|---|---|
2 | 2 | ||
3 | As for the other semihosting calls we can resolve this at translate | 3 | The current sbsa-ref cannot use EHCI controller which is only |
4 | time. | 4 | able to do 32-bit DMA, since sbsa-ref doesn't have RAM below 4GB. |
5 | Hence, this uses XHCI to provide a usb controller with 64-bit | ||
6 | DMA capablity instead of EHCI. | ||
5 | 7 | ||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 8 | We bump the platform version to 0.3 with this change. Although the |
9 | hardware at the USB controller address changes, the firmware and | ||
10 | Linux can both cope with this -- on an older non-XHCI-aware | ||
11 | firmware/kernel setup the probe routine simply fails and the guest | ||
12 | proceeds without any USB. (This isn't a loss of functionality, | ||
13 | because the old USB controller never worked in the first place.) So | ||
14 | we can call this a backwards-compatible change and only bump the | ||
15 | minor version. | ||
16 | |||
17 | Signed-off-by: Yuquan Wang <wangyuquan1236@phytium.com.cn> | ||
18 | Message-id: 20230621103847.447508-2-wangyuquan1236@phytium.com.cn | ||
19 | [PMM: tweaked commit message; add line to docs about what | ||
20 | changes in platform version 0.3] | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20190913151845.12582-4-alex.bennee@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 23 | --- |
11 | target/arm/translate.c | 19 +++++++++++++++---- | 24 | docs/system/arm/sbsa.rst | 5 ++++- |
12 | 1 file changed, 15 insertions(+), 4 deletions(-) | 25 | hw/arm/sbsa-ref.c | 23 +++++++++++++---------- |
26 | hw/arm/Kconfig | 2 +- | ||
27 | 3 files changed, 18 insertions(+), 12 deletions(-) | ||
13 | 28 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 29 | diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 31 | --- a/docs/system/arm/sbsa.rst |
17 | +++ b/target/arm/translate.c | 32 | +++ b/docs/system/arm/sbsa.rst |
18 | @@ -XXX,XX +XXX,XX @@ static bool trans_CBZ(DisasContext *s, arg_CBZ *a) | 33 | @@ -XXX,XX +XXX,XX @@ The ``sbsa-ref`` board supports: |
34 | - A configurable number of AArch64 CPUs | ||
35 | - GIC version 3 | ||
36 | - System bus AHCI controller | ||
37 | - - System bus EHCI controller | ||
38 | + - System bus XHCI controller | ||
39 | - CDROM and hard disc on AHCI bus | ||
40 | - E1000E ethernet card on PCIe bus | ||
41 | - Bochs display adapter on PCIe bus | ||
42 | @@ -XXX,XX +XXX,XX @@ Platform version changes: | ||
43 | |||
44 | 0.2 | ||
45 | GIC ITS information is present in devicetree. | ||
46 | + | ||
47 | +0.3 | ||
48 | + The USB controller is an XHCI device, not EHCI | ||
49 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/hw/arm/sbsa-ref.c | ||
52 | +++ b/hw/arm/sbsa-ref.c | ||
53 | @@ -XXX,XX +XXX,XX @@ | ||
54 | #include "hw/pci-host/gpex.h" | ||
55 | #include "hw/qdev-properties.h" | ||
56 | #include "hw/usb.h" | ||
57 | +#include "hw/usb/xhci.h" | ||
58 | #include "hw/char/pl011.h" | ||
59 | #include "hw/watchdog/sbsa_gwdt.h" | ||
60 | #include "net/net.h" | ||
61 | @@ -XXX,XX +XXX,XX @@ enum { | ||
62 | SBSA_SECURE_UART_MM, | ||
63 | SBSA_SECURE_MEM, | ||
64 | SBSA_AHCI, | ||
65 | - SBSA_EHCI, | ||
66 | + SBSA_XHCI, | ||
67 | }; | ||
68 | |||
69 | struct SBSAMachineState { | ||
70 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry sbsa_ref_memmap[] = { | ||
71 | [SBSA_SMMU] = { 0x60050000, 0x00020000 }, | ||
72 | /* Space here reserved for more SMMUs */ | ||
73 | [SBSA_AHCI] = { 0x60100000, 0x00010000 }, | ||
74 | - [SBSA_EHCI] = { 0x60110000, 0x00010000 }, | ||
75 | + [SBSA_XHCI] = { 0x60110000, 0x00010000 }, | ||
76 | /* Space here reserved for other devices */ | ||
77 | [SBSA_PCIE_PIO] = { 0x7fff0000, 0x00010000 }, | ||
78 | /* 32-bit address PCIE MMIO space */ | ||
79 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { | ||
80 | [SBSA_SECURE_UART] = 8, | ||
81 | [SBSA_SECURE_UART_MM] = 9, | ||
82 | [SBSA_AHCI] = 10, | ||
83 | - [SBSA_EHCI] = 11, | ||
84 | + [SBSA_XHCI] = 11, | ||
85 | [SBSA_SMMU] = 12, /* ... to 15 */ | ||
86 | [SBSA_GWDT_WS0] = 16, | ||
87 | }; | ||
88 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms) | ||
89 | * fw compatibility. | ||
90 | */ | ||
91 | qemu_fdt_setprop_cell(fdt, "/", "machine-version-major", 0); | ||
92 | - qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 2); | ||
93 | + qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 3); | ||
94 | |||
95 | if (ms->numa_state->have_numa_distance) { | ||
96 | int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); | ||
97 | @@ -XXX,XX +XXX,XX @@ static void create_ahci(const SBSAMachineState *sms) | ||
98 | } | ||
19 | } | 99 | } |
20 | 100 | ||
21 | /* | 101 | -static void create_ehci(const SBSAMachineState *sms) |
22 | - * Supervisor call | 102 | +static void create_xhci(const SBSAMachineState *sms) |
23 | + * Supervisor call - both T32 & A32 come here so we need to check | ||
24 | + * which mode we are in when checking for semihosting. | ||
25 | */ | ||
26 | |||
27 | static bool trans_SVC(DisasContext *s, arg_SVC *a) | ||
28 | { | 103 | { |
29 | - gen_set_pc_im(s, s->base.pc_next); | 104 | - hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base; |
30 | - s->svc_imm = a->imm; | 105 | - int irq = sbsa_ref_irqmap[SBSA_EHCI]; |
31 | - s->base.is_jmp = DISAS_SWI; | 106 | + hwaddr base = sbsa_ref_memmap[SBSA_XHCI].base; |
32 | + const uint32_t semihost_imm = s->thumb ? 0xab : 0x123456; | 107 | + int irq = sbsa_ref_irqmap[SBSA_XHCI]; |
33 | + | 108 | + DeviceState *dev = qdev_new(TYPE_XHCI_SYSBUS); |
34 | + if (!arm_dc_feature(s, ARM_FEATURE_M) && semihosting_enabled() && | 109 | |
35 | +#ifndef CONFIG_USER_ONLY | 110 | - sysbus_create_simple("platform-ehci-usb", base, |
36 | + !IS_USER(s) && | 111 | - qdev_get_gpio_in(sms->gic, irq)); |
37 | +#endif | 112 | + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
38 | + (a->imm == semihost_imm)) { | 113 | + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); |
39 | + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); | 114 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(sms->gic, irq)); |
40 | + } else { | ||
41 | + gen_set_pc_im(s, s->base.pc_next); | ||
42 | + s->svc_imm = a->imm; | ||
43 | + s->base.is_jmp = DISAS_SWI; | ||
44 | + } | ||
45 | return true; | ||
46 | } | 115 | } |
47 | 116 | ||
117 | static void create_smmu(const SBSAMachineState *sms, PCIBus *bus) | ||
118 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
119 | |||
120 | create_ahci(sms); | ||
121 | |||
122 | - create_ehci(sms); | ||
123 | + create_xhci(sms); | ||
124 | |||
125 | create_pcie(sms); | ||
126 | |||
127 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
128 | index XXXXXXX..XXXXXXX 100644 | ||
129 | --- a/hw/arm/Kconfig | ||
130 | +++ b/hw/arm/Kconfig | ||
131 | @@ -XXX,XX +XXX,XX @@ config SBSA_REF | ||
132 | select PL011 # UART | ||
133 | select PL031 # RTC | ||
134 | select PL061 # GPIO | ||
135 | - select USB_EHCI_SYSBUS | ||
136 | + select USB_XHCI_SYSBUS | ||
137 | select WDT_SBSA | ||
138 | select BOCHS_DISPLAY | ||
139 | |||
48 | -- | 140 | -- |
49 | 2.20.1 | 141 | 2.34.1 |
50 | |||
51 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | Some assemblers will complain about attempts to access |
---|---|---|---|
2 | id_aa64zfr0_el1 and id_aa64smfr0_el1 by name if the test | ||
3 | binary isn't built for the right processor type: | ||
2 | 4 | ||
3 | We already use semihosting for the system stuff so this is a simple | 5 | /tmp/ccASXpLo.s:782: Error: selected processor does not support system register name 'id_aa64zfr0_el1' |
4 | smoke test to ensure we are working OK on linux-user. | 6 | /tmp/ccASXpLo.s:829: Error: selected processor does not support system register name 'id_aa64smfr0_el1' |
5 | 7 | ||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 8 | However, these registers are in the ID space and are guaranteed to |
7 | Message-id: 20190913151845.12582-7-alex.bennee@linaro.org | 9 | read-as-zero on older CPUs, so the access is both safe and sensible. |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Switch to using the S syntax, as we already do for ID_AA64ISAR2_EL1 |
11 | and ID_AA64MMFR2_EL1. This allows us to drop the HAS_ARMV9_SME check | ||
12 | and the makefile machinery to adjust the CFLAGS for this test, so we | ||
13 | don't rely on having a sufficiently new compiler to be able to check | ||
14 | these registers. | ||
15 | |||
16 | This means we're actually testing the SME ID register: no released | ||
17 | GCC yet recognizes -march=armv9-a+sme, so that was always skipped. | ||
18 | It also avoids a future problem if we try to switch the "do we have | ||
19 | SME support in the toolchain" check from "in the compiler" to "in the | ||
20 | assembler" (at which point we would otherwise run into the above | ||
21 | errors). | ||
22 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 24 | --- |
11 | tests/tcg/aarch64/Makefile.target | 5 ++++ | 25 | tests/tcg/aarch64/sysregs.c | 11 +++++++---- |
12 | tests/tcg/arm/Makefile.target | 5 ++++ | 26 | tests/tcg/aarch64/Makefile.target | 7 +------ |
13 | tests/tcg/arm/semihosting.c | 45 +++++++++++++++++++++++++++++++ | 27 | 2 files changed, 8 insertions(+), 10 deletions(-) |
14 | 3 files changed, 55 insertions(+) | ||
15 | create mode 100644 tests/tcg/arm/semihosting.c | ||
16 | 28 | ||
29 | diff --git a/tests/tcg/aarch64/sysregs.c b/tests/tcg/aarch64/sysregs.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/tests/tcg/aarch64/sysregs.c | ||
32 | +++ b/tests/tcg/aarch64/sysregs.c | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | /* | ||
35 | * Older assemblers don't recognize newer system register names, | ||
36 | * but we can still access them by the Sn_n_Cn_Cn_n syntax. | ||
37 | + * This also means we don't need to specifically request that the | ||
38 | + * assembler enables whatever architectural features the ID registers | ||
39 | + * syntax might be gated behind. | ||
40 | */ | ||
41 | #define SYS_ID_AA64ISAR2_EL1 S3_0_C0_C6_2 | ||
42 | #define SYS_ID_AA64MMFR2_EL1 S3_0_C0_C7_2 | ||
43 | +#define SYS_ID_AA64ZFR0_EL1 S3_0_C0_C4_4 | ||
44 | +#define SYS_ID_AA64SMFR0_EL1 S3_0_C0_C4_5 | ||
45 | |||
46 | int failed_bit_count; | ||
47 | |||
48 | @@ -XXX,XX +XXX,XX @@ int main(void) | ||
49 | /* all hidden, DebugVer fixed to 0x6 (ARMv8 debug architecture) */ | ||
50 | get_cpu_reg_check_mask(id_aa64dfr0_el1, _m(0000,0000,0000,0006)); | ||
51 | get_cpu_reg_check_zero(id_aa64dfr1_el1); | ||
52 | - get_cpu_reg_check_mask(id_aa64zfr0_el1, _m(0ff0,ff0f,00ff,00ff)); | ||
53 | -#ifdef HAS_ARMV9_SME | ||
54 | - get_cpu_reg_check_mask(id_aa64smfr0_el1, _m(80f1,00fd,0000,0000)); | ||
55 | -#endif | ||
56 | + get_cpu_reg_check_mask(SYS_ID_AA64ZFR0_EL1, _m(0ff0,ff0f,00ff,00ff)); | ||
57 | + get_cpu_reg_check_mask(SYS_ID_AA64SMFR0_EL1, _m(80f1,00fd,0000,0000)); | ||
58 | |||
59 | get_cpu_reg_check_zero(id_aa64afr0_el1); | ||
60 | get_cpu_reg_check_zero(id_aa64afr1_el1); | ||
17 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | 61 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target |
18 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/tests/tcg/aarch64/Makefile.target | 63 | --- a/tests/tcg/aarch64/Makefile.target |
20 | +++ b/tests/tcg/aarch64/Makefile.target | 64 | +++ b/tests/tcg/aarch64/Makefile.target |
21 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | 65 | @@ -XXX,XX +XXX,XX @@ AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-5 mte-6 mte-7 |
22 | AARCH64_TESTS += pauth-1 pauth-2 | 66 | mte-%: CFLAGS += -march=armv8.5-a+memtag |
23 | run-pauth-%: QEMU_OPTS += -cpu max | 67 | endif |
24 | 68 | ||
25 | +# Semihosting smoke test for linux-user | 69 | -ifneq ($(CROSS_CC_HAS_SVE),) |
26 | +AARCH64_TESTS += semihosting | 70 | # System Registers Tests |
27 | +run-semihosting: semihosting | 71 | AARCH64_TESTS += sysregs |
28 | + $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") | 72 | -ifneq ($(CROSS_CC_HAS_ARMV9_SME),) |
29 | + | 73 | -sysregs: CFLAGS+=-march=armv9-a+sme -DHAS_ARMV9_SME |
30 | TESTS += $(AARCH64_TESTS) | 74 | -else |
31 | diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target | 75 | -sysregs: CFLAGS+=-march=armv8.1-a+sve |
32 | index XXXXXXX..XXXXXXX 100644 | 76 | -endif |
33 | --- a/tests/tcg/arm/Makefile.target | 77 | |
34 | +++ b/tests/tcg/arm/Makefile.target | 78 | +ifneq ($(CROSS_CC_HAS_SVE),) |
35 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | 79 | # SVE ioctl test |
36 | $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") | 80 | AARCH64_TESTS += sve-ioctls |
37 | $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) | 81 | sve-ioctls: CFLAGS+=-march=armv8.1-a+sve |
38 | |||
39 | +# Semihosting smoke test for linux-user | ||
40 | +ARM_TESTS += semihosting | ||
41 | +run-semihosting: semihosting | ||
42 | + $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") | ||
43 | + | ||
44 | TESTS += $(ARM_TESTS) | ||
45 | |||
46 | # On ARM Linux only supports 4k pages | ||
47 | diff --git a/tests/tcg/arm/semihosting.c b/tests/tcg/arm/semihosting.c | ||
48 | new file mode 100644 | ||
49 | index XXXXXXX..XXXXXXX | ||
50 | --- /dev/null | ||
51 | +++ b/tests/tcg/arm/semihosting.c | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | +/* | ||
54 | + * linux-user semihosting checks | ||
55 | + * | ||
56 | + * Copyright (c) 2019 | ||
57 | + * Written by Alex Bennée <alex.bennee@linaro.org> | ||
58 | + * | ||
59 | + * SPDX-License-Identifier: GPL-3.0-or-later | ||
60 | + */ | ||
61 | + | ||
62 | +#include <stdint.h> | ||
63 | + | ||
64 | +#define SYS_WRITE0 0x04 | ||
65 | +#define SYS_REPORTEXC 0x18 | ||
66 | + | ||
67 | +void __semi_call(uintptr_t type, uintptr_t arg0) | ||
68 | +{ | ||
69 | +#if defined(__arm__) | ||
70 | + register uintptr_t t asm("r0") = type; | ||
71 | + register uintptr_t a0 asm("r1") = arg0; | ||
72 | + asm("svc 0xab" | ||
73 | + : /* no return */ | ||
74 | + : "r" (t), "r" (a0)); | ||
75 | +#else | ||
76 | + register uintptr_t t asm("x0") = type; | ||
77 | + register uintptr_t a0 asm("x1") = arg0; | ||
78 | + asm("hlt 0xf000" | ||
79 | + : /* no return */ | ||
80 | + : "r" (t), "r" (a0)); | ||
81 | +#endif | ||
82 | +} | ||
83 | + | ||
84 | +int main(int argc, char *argv[argc]) | ||
85 | +{ | ||
86 | +#if defined(__arm__) | ||
87 | + uintptr_t exit_code = 0x20026; | ||
88 | +#else | ||
89 | + uintptr_t exit_block[2] = {0x20026, 0}; | ||
90 | + uintptr_t exit_code = (uintptr_t) &exit_block; | ||
91 | +#endif | ||
92 | + | ||
93 | + __semi_call(SYS_WRITE0, (uintptr_t) "Hello World"); | ||
94 | + __semi_call(SYS_REPORTEXC, exit_code); | ||
95 | + /* if we get here we failed */ | ||
96 | + return -1; | ||
97 | +} | ||
98 | -- | 82 | -- |
99 | 2.20.1 | 83 | 2.34.1 |
100 | |||
101 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Allow the line length to extend to 548 columns. While annoyingly wide, | ||
4 | it's still less confusing than the continuations we print. Also, the | ||
5 | default VL used by Linux (and max for A64FX) uses only 140 columns. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20230622151201.1578522-2-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.c | 36 ++++++++++++++---------------------- | ||
13 | 1 file changed, 14 insertions(+), 22 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.c | ||
18 | +++ b/target/arm/cpu.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
20 | ARMCPU *cpu = ARM_CPU(cs); | ||
21 | CPUARMState *env = &cpu->env; | ||
22 | uint32_t psr = pstate_read(env); | ||
23 | - int i; | ||
24 | + int i, j; | ||
25 | int el = arm_current_el(env); | ||
26 | const char *ns_status; | ||
27 | bool sve; | ||
28 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
29 | } | ||
30 | |||
31 | if (sve) { | ||
32 | - int j, zcr_len = sve_vqm1_for_el(env, el); | ||
33 | + int zcr_len = sve_vqm1_for_el(env, el); | ||
34 | |||
35 | for (i = 0; i <= FFR_PRED_NUM; i++) { | ||
36 | bool eol; | ||
37 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
38 | } | ||
39 | } | ||
40 | |||
41 | - for (i = 0; i < 32; i++) { | ||
42 | - if (zcr_len == 0) { | ||
43 | + if (zcr_len == 0) { | ||
44 | + /* | ||
45 | + * With vl=16, there are only 37 columns per register, | ||
46 | + * so output two registers per line. | ||
47 | + */ | ||
48 | + for (i = 0; i < 32; i++) { | ||
49 | qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s", | ||
50 | i, env->vfp.zregs[i].d[1], | ||
51 | env->vfp.zregs[i].d[0], i & 1 ? "\n" : " "); | ||
52 | - } else if (zcr_len == 1) { | ||
53 | - qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 | ||
54 | - ":%016" PRIx64 ":%016" PRIx64 "\n", | ||
55 | - i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2], | ||
56 | - env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]); | ||
57 | - } else { | ||
58 | + } | ||
59 | + } else { | ||
60 | + for (i = 0; i < 32; i++) { | ||
61 | + qemu_fprintf(f, "Z%02d=", i); | ||
62 | for (j = zcr_len; j >= 0; j--) { | ||
63 | - bool odd = (zcr_len - j) % 2 != 0; | ||
64 | - if (j == zcr_len) { | ||
65 | - qemu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1); | ||
66 | - } else if (!odd) { | ||
67 | - if (j > 0) { | ||
68 | - qemu_fprintf(f, " [%x-%x]=", j, j - 1); | ||
69 | - } else { | ||
70 | - qemu_fprintf(f, " [%x]=", j); | ||
71 | - } | ||
72 | - } | ||
73 | qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s", | ||
74 | env->vfp.zregs[i].d[j * 2 + 1], | ||
75 | - env->vfp.zregs[i].d[j * 2], | ||
76 | - odd || j == 0 ? "\n" : ":"); | ||
77 | + env->vfp.zregs[i].d[j * 2 + 0], | ||
78 | + j ? ":" : "\n"); | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | -- | ||
83 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We do this for other semihosting calls so we might as well do it for | 3 | Always print each matrix row whole, one per line, so that we |
4 | M-profile as well. | 4 | get the entire matrix in the proper shape. |
5 | 5 | ||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Message-id: 20230622151201.1578522-3-richard.henderson@linaro.org |
8 | Message-id: 20190913151845.12582-3-alex.bennee@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@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/m_helper.c | 18 ++++++------------ | 11 | target/arm/cpu.c | 18 ++++++++++++++++++ |
13 | target/arm/translate.c | 11 ++++++++++- | 12 | 1 file changed, 18 insertions(+) |
14 | 2 files changed, 16 insertions(+), 13 deletions(-) | ||
15 | 13 | ||
16 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/m_helper.c | 16 | --- a/target/arm/cpu.c |
19 | +++ b/target/arm/m_helper.c | 17 | +++ b/target/arm/cpu.c |
20 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 18 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
21 | break; | 19 | i, q[1], q[0], (i & 1 ? "\n" : " ")); |
22 | } | 20 | } |
23 | break; | ||
24 | + case EXCP_SEMIHOST: | ||
25 | + qemu_log_mask(CPU_LOG_INT, | ||
26 | + "...handling as semihosting call 0x%x\n", | ||
27 | + env->regs[0]); | ||
28 | + env->regs[0] = do_arm_semihosting(env); | ||
29 | + return; | ||
30 | case EXCP_BKPT: | ||
31 | - if (semihosting_enabled()) { | ||
32 | - int nr; | ||
33 | - nr = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff; | ||
34 | - if (nr == 0xab) { | ||
35 | - env->regs[15] += 2; | ||
36 | - qemu_log_mask(CPU_LOG_INT, | ||
37 | - "...handling as semihosting call 0x%x\n", | ||
38 | - env->regs[0]); | ||
39 | - env->regs[0] = do_arm_semihosting(env); | ||
40 | - return; | ||
41 | - } | ||
42 | - } | ||
43 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false); | ||
44 | break; | ||
45 | case EXCP_IRQ: | ||
46 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/translate.c | ||
49 | +++ b/target/arm/translate.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static bool trans_BKPT(DisasContext *s, arg_BKPT *a) | ||
51 | if (!ENABLE_ARCH_5) { | ||
52 | return false; | ||
53 | } | 21 | } |
54 | - gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, false)); | 22 | + |
55 | + if (arm_dc_feature(s, ARM_FEATURE_M) && | 23 | + if (cpu_isar_feature(aa64_sme, cpu) && |
56 | + semihosting_enabled() && | 24 | + FIELD_EX64(env->svcr, SVCR, ZA) && |
57 | +#ifndef CONFIG_USER_ONLY | 25 | + sme_exception_el(env, el) == 0) { |
58 | + !IS_USER(s) && | 26 | + int zcr_len = sve_vqm1_for_el_sm(env, el, true); |
59 | +#endif | 27 | + int svl = (zcr_len + 1) * 16; |
60 | + (a->imm == 0xab)) { | 28 | + int svl_lg10 = svl < 100 ? 2 : 3; |
61 | + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); | 29 | + |
62 | + } else { | 30 | + for (i = 0; i < svl; i++) { |
63 | + gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, false)); | 31 | + qemu_fprintf(f, "ZA[%0*d]=", svl_lg10, i); |
32 | + for (j = zcr_len; j >= 0; --j) { | ||
33 | + qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%c", | ||
34 | + env->zarray[i].d[2 * j + 1], | ||
35 | + env->zarray[i].d[2 * j], | ||
36 | + j ? ':' : '\n'); | ||
37 | + } | ||
38 | + } | ||
64 | + } | 39 | + } |
65 | return true; | ||
66 | } | 40 | } |
67 | 41 | ||
42 | #else | ||
68 | -- | 43 | -- |
69 | 2.20.1 | 44 | 2.34.1 |
70 | |||
71 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | These were missed in the recent de-tangling so have been updated to be | 3 | For the outer product set of insns, which take an entire matrix |
4 | more actuate. I've also built up ARM_TESTS in a manner similar to | 4 | tile as output, the argument is not a combined tile+column. |
5 | AARCH64_TESTS for better consistency. | 5 | Therefore using get_tile_rowcol was incorrect, as we extracted |
6 | the tile number from itself. | ||
6 | 7 | ||
7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 8 | The test case relies only on assembler support for SME, since |
9 | no release of GCC recognizes -march=armv9-a+sme yet. | ||
10 | |||
11 | Cc: qemu-stable@nongnu.org | ||
12 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1620 | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20230622151201.1578522-5-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20190913151845.12582-2-alex.bennee@linaro.org | 16 | [PMM: dropped now-unneeded changes to sysregs CFLAGS] |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 18 | --- |
12 | tests/tcg/Makefile.target | 7 +++++-- | 19 | target/arm/tcg/translate-sme.c | 24 ++++++--- |
13 | tests/tcg/aarch64/Makefile.target | 3 ++- | 20 | tests/tcg/aarch64/sme-outprod1.c | 83 +++++++++++++++++++++++++++++++ |
14 | tests/tcg/arm/Makefile.target | 15 ++++++++------- | 21 | tests/tcg/aarch64/Makefile.target | 7 ++- |
15 | 3 files changed, 15 insertions(+), 10 deletions(-) | 22 | 3 files changed, 107 insertions(+), 7 deletions(-) |
23 | create mode 100644 tests/tcg/aarch64/sme-outprod1.c | ||
16 | 24 | ||
17 | diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target | 25 | diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c |
18 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/tests/tcg/Makefile.target | 27 | --- a/target/arm/tcg/translate-sme.c |
20 | +++ b/tests/tcg/Makefile.target | 28 | +++ b/target/arm/tcg/translate-sme.c |
21 | @@ -XXX,XX +XXX,XX @@ TIMEOUT=15 | 29 | @@ -XXX,XX +XXX,XX @@ static TCGv_ptr get_tile_rowcol(DisasContext *s, int esz, int rs, |
22 | endif | 30 | return addr; |
23 | 31 | } | |
24 | ifdef CONFIG_USER_ONLY | 32 | |
25 | -# The order we include is important. We include multiarch, base arch | 33 | +/* |
26 | -# and finally arch if it's not the same as base arch. | 34 | + * Resolve tile.size[0] to a host pointer. |
27 | +# The order we include is important. We include multiarch first and | 35 | + * Used by e.g. outer product insns where we require the entire tile. |
28 | +# then the target. If there are common tests shared between | 36 | + */ |
29 | +# sub-targets (e.g. ARM & AArch64) then it is up to | 37 | +static TCGv_ptr get_tile(DisasContext *s, int esz, int tile) |
30 | +# $(TARGET_NAME)/Makefile.target to include the common parent | 38 | +{ |
31 | +# architecture in its VPATH. | 39 | + TCGv_ptr addr = tcg_temp_new_ptr(); |
32 | -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target | 40 | + int offset; |
33 | -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target | 41 | + |
34 | 42 | + offset = tile * sizeof(ARMVectorReg) + offsetof(CPUARMState, zarray); | |
43 | + | ||
44 | + tcg_gen_addi_ptr(addr, cpu_env, offset); | ||
45 | + return addr; | ||
46 | +} | ||
47 | + | ||
48 | static bool trans_ZERO(DisasContext *s, arg_ZERO *a) | ||
49 | { | ||
50 | if (!dc_isar_feature(aa64_sme, s)) { | ||
51 | @@ -XXX,XX +XXX,XX @@ static bool do_adda(DisasContext *s, arg_adda *a, MemOp esz, | ||
52 | return true; | ||
53 | } | ||
54 | |||
55 | - /* Sum XZR+zad to find ZAd. */ | ||
56 | - za = get_tile_rowcol(s, esz, 31, a->zad, false); | ||
57 | + za = get_tile(s, esz, a->zad); | ||
58 | zn = vec_full_reg_ptr(s, a->zn); | ||
59 | pn = pred_full_reg_ptr(s, a->pn); | ||
60 | pm = pred_full_reg_ptr(s, a->pm); | ||
61 | @@ -XXX,XX +XXX,XX @@ static bool do_outprod(DisasContext *s, arg_op *a, MemOp esz, | ||
62 | return true; | ||
63 | } | ||
64 | |||
65 | - /* Sum XZR+zad to find ZAd. */ | ||
66 | - za = get_tile_rowcol(s, esz, 31, a->zad, false); | ||
67 | + za = get_tile(s, esz, a->zad); | ||
68 | zn = vec_full_reg_ptr(s, a->zn); | ||
69 | zm = vec_full_reg_ptr(s, a->zm); | ||
70 | pn = pred_full_reg_ptr(s, a->pn); | ||
71 | @@ -XXX,XX +XXX,XX @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz, | ||
72 | return true; | ||
73 | } | ||
74 | |||
75 | - /* Sum XZR+zad to find ZAd. */ | ||
76 | - za = get_tile_rowcol(s, esz, 31, a->zad, false); | ||
77 | + za = get_tile(s, esz, a->zad); | ||
78 | zn = vec_full_reg_ptr(s, a->zn); | ||
79 | zm = vec_full_reg_ptr(s, a->zm); | ||
80 | pn = pred_full_reg_ptr(s, a->pn); | ||
81 | diff --git a/tests/tcg/aarch64/sme-outprod1.c b/tests/tcg/aarch64/sme-outprod1.c | ||
82 | new file mode 100644 | ||
83 | index XXXXXXX..XXXXXXX | ||
84 | --- /dev/null | ||
85 | +++ b/tests/tcg/aarch64/sme-outprod1.c | ||
86 | @@ -XXX,XX +XXX,XX @@ | ||
87 | +/* | ||
88 | + * SME outer product, 1 x 1. | ||
89 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
90 | + */ | ||
91 | + | ||
92 | +#include <stdio.h> | ||
93 | + | ||
94 | +extern void foo(float *dst); | ||
95 | + | ||
96 | +asm( | ||
97 | +" .arch_extension sme\n" | ||
98 | +" .type foo, @function\n" | ||
99 | +"foo:\n" | ||
100 | +" stp x29, x30, [sp, -80]!\n" | ||
101 | +" mov x29, sp\n" | ||
102 | +" stp d8, d9, [sp, 16]\n" | ||
103 | +" stp d10, d11, [sp, 32]\n" | ||
104 | +" stp d12, d13, [sp, 48]\n" | ||
105 | +" stp d14, d15, [sp, 64]\n" | ||
106 | +" smstart\n" | ||
107 | +" ptrue p0.s, vl4\n" | ||
108 | +" fmov z0.s, #1.0\n" | ||
109 | +/* | ||
110 | + * An outer product of a vector of 1.0 by itself should be a matrix of 1.0. | ||
111 | + * Note that we are using tile 1 here (za1.s) rather than tile 0. | ||
112 | + */ | ||
113 | +" zero {za}\n" | ||
114 | +" fmopa za1.s, p0/m, p0/m, z0.s, z0.s\n" | ||
115 | +/* | ||
116 | + * Read the first 4x4 sub-matrix of elements from tile 1: | ||
117 | + * Note that za1h should be interchangable here. | ||
118 | + */ | ||
119 | +" mov w12, #0\n" | ||
120 | +" mova z0.s, p0/m, za1v.s[w12, #0]\n" | ||
121 | +" mova z1.s, p0/m, za1v.s[w12, #1]\n" | ||
122 | +" mova z2.s, p0/m, za1v.s[w12, #2]\n" | ||
123 | +" mova z3.s, p0/m, za1v.s[w12, #3]\n" | ||
124 | +/* | ||
125 | + * And store them to the input pointer (dst in the C code): | ||
126 | + */ | ||
127 | +" st1w {z0.s}, p0, [x0]\n" | ||
128 | +" add x0, x0, #16\n" | ||
129 | +" st1w {z1.s}, p0, [x0]\n" | ||
130 | +" add x0, x0, #16\n" | ||
131 | +" st1w {z2.s}, p0, [x0]\n" | ||
132 | +" add x0, x0, #16\n" | ||
133 | +" st1w {z3.s}, p0, [x0]\n" | ||
134 | +" smstop\n" | ||
135 | +" ldp d8, d9, [sp, 16]\n" | ||
136 | +" ldp d10, d11, [sp, 32]\n" | ||
137 | +" ldp d12, d13, [sp, 48]\n" | ||
138 | +" ldp d14, d15, [sp, 64]\n" | ||
139 | +" ldp x29, x30, [sp], 80\n" | ||
140 | +" ret\n" | ||
141 | +" .size foo, . - foo" | ||
142 | +); | ||
143 | + | ||
144 | +int main() | ||
145 | +{ | ||
146 | + float dst[16]; | ||
147 | + int i, j; | ||
148 | + | ||
149 | + foo(dst); | ||
150 | + | ||
151 | + for (i = 0; i < 16; i++) { | ||
152 | + if (dst[i] != 1.0f) { | ||
153 | + break; | ||
154 | + } | ||
155 | + } | ||
156 | + | ||
157 | + if (i == 16) { | ||
158 | + return 0; /* success */ | ||
159 | + } | ||
160 | + | ||
161 | + /* failure */ | ||
162 | + for (i = 0; i < 4; ++i) { | ||
163 | + for (j = 0; j < 4; ++j) { | ||
164 | + printf("%f ", (double)dst[i * 4 + j]); | ||
165 | + } | ||
166 | + printf("\n"); | ||
167 | + } | ||
168 | + return 1; | ||
169 | +} | ||
35 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | 170 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target |
36 | index XXXXXXX..XXXXXXX 100644 | 171 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/tests/tcg/aarch64/Makefile.target | 172 | --- a/tests/tcg/aarch64/Makefile.target |
38 | +++ b/tests/tcg/aarch64/Makefile.target | 173 | +++ b/tests/tcg/aarch64/Makefile.target |
39 | @@ -XXX,XX +XXX,XX @@ VPATH += $(ARM_SRC) | 174 | @@ -XXX,XX +XXX,XX @@ config-cc.mak: Makefile |
40 | AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 | 175 | $(call cc-option,-march=armv8.5-a, CROSS_CC_HAS_ARMV8_5); \ |
41 | VPATH += $(AARCH64_SRC) | 176 | $(call cc-option,-mbranch-protection=standard, CROSS_CC_HAS_ARMV8_BTI); \ |
42 | 177 | $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE); \ | |
43 | -# we don't build any other ARM test | 178 | - $(call cc-option,-march=armv9-a+sme, CROSS_CC_HAS_ARMV9_SME)) 3> config-cc.mak |
44 | +# Float-convert Tests | 179 | + $(call cc-option,-Wa$(COMMA)-march=armv9-a+sme, CROSS_AS_HAS_ARMV9_SME)) 3> config-cc.mak |
45 | AARCH64_TESTS=fcvt | 180 | -include config-cc.mak |
46 | 181 | ||
47 | fcvt: LDFLAGS+=-lm | 182 | ifneq ($(CROSS_CC_HAS_ARMV8_2),) |
48 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | 183 | @@ -XXX,XX +XXX,XX @@ AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-5 mte-6 mte-7 |
49 | $(call run-test,$<,$(QEMU) $<, "$< on $(TARGET_NAME)") | 184 | mte-%: CFLAGS += -march=armv8.5-a+memtag |
50 | $(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref) | 185 | endif |
51 | 186 | ||
52 | +# Pauth Tests | 187 | +# SME Tests |
53 | AARCH64_TESTS += pauth-1 pauth-2 | 188 | +ifneq ($(CROSS_AS_HAS_ARMV9_SME),) |
54 | run-pauth-%: QEMU_OPTS += -cpu max | 189 | +AARCH64_TESTS += sme-outprod1 |
55 | 190 | +endif | |
56 | diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/tests/tcg/arm/Makefile.target | ||
59 | +++ b/tests/tcg/arm/Makefile.target | ||
60 | @@ -XXX,XX +XXX,XX @@ ARM_SRC=$(SRC_PATH)/tests/tcg/arm | ||
61 | # Set search path for all sources | ||
62 | VPATH += $(ARM_SRC) | ||
63 | |||
64 | -ARM_TESTS=hello-arm test-arm-iwmmxt | ||
65 | - | ||
66 | -TESTS += $(ARM_TESTS) fcvt | ||
67 | - | ||
68 | +# Basic Hello World | ||
69 | +ARM_TESTS = hello-arm | ||
70 | hello-arm: CFLAGS+=-marm -ffreestanding | ||
71 | hello-arm: LDFLAGS+=-nostdlib | ||
72 | |||
73 | +# IWMXT floating point extensions | ||
74 | +ARM_TESTS += test-arm-iwmmxt | ||
75 | test-arm-iwmmxt: CFLAGS+=-marm -march=iwmmxt -mabi=aapcs -mfpu=fpv4-sp-d16 | ||
76 | test-arm-iwmmxt: test-arm-iwmmxt.S | ||
77 | $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) | ||
78 | |||
79 | -ifeq ($(TARGET_NAME), arm) | ||
80 | +# Float-convert Tests | ||
81 | +ARM_TESTS += fcvt | ||
82 | fcvt: LDFLAGS+=-lm | ||
83 | # fcvt: CFLAGS+=-march=armv8.2-a+fp16 -mfpu=neon-fp-armv8 | ||
84 | - | ||
85 | run-fcvt: fcvt | ||
86 | $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") | ||
87 | $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) | ||
88 | -endif | ||
89 | + | 191 | + |
90 | +TESTS += $(ARM_TESTS) | 192 | # System Registers Tests |
91 | 193 | AARCH64_TESTS += sysregs | |
92 | # On ARM Linux only supports 4k pages | 194 | |
93 | EXTRA_RUNS+=run-test-mmap-4096 | ||
94 | -- | 195 | -- |
95 | 2.20.1 | 196 | 2.34.1 |
96 | |||
97 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: John Högberg <john.hogberg@ericsson.com> |
---|---|---|---|
2 | 2 | ||
3 | Now we do all our checking and use a common EXCP_SEMIHOST for | 3 | Unlike architectures with precise self-modifying code semantics |
4 | semihosting operations we can make helper code a lot simpler. | 4 | (e.g. x86) ARM processors do not maintain coherency for instruction |
5 | execution and memory, requiring an instruction synchronization | ||
6 | barrier on every core that will execute the new code, and on many | ||
7 | models also the explicit use of cache management instructions. | ||
5 | 8 | ||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 9 | While this is required to make JITs work on actual hardware, QEMU |
10 | has gotten away with not handling this since it does not emulate | ||
11 | caches, and unconditionally invalidates code whenever the softmmu | ||
12 | or the user-mode page protection logic detects that code has been | ||
13 | modified. | ||
14 | |||
15 | Unfortunately the latter does not work in the face of dual-mapped | ||
16 | code (a common W^X workaround), where one page is executable and | ||
17 | the other is writable: user-mode has no way to connect one with the | ||
18 | other as that is only known to the kernel and the emulated | ||
19 | application. | ||
20 | |||
21 | This commit works around the issue by telling software that | ||
22 | instruction cache invalidation is required by clearing the | ||
23 | CPR_EL0.DIC flag (regardless of whether the emulated processor | ||
24 | needs it), and then invalidating code in IC IVAU instructions. | ||
25 | |||
26 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1034 | ||
27 | |||
28 | Co-authored-by: Richard Henderson <richard.henderson@linaro.org> | ||
29 | Signed-off-by: John Högberg <john.hogberg@ericsson.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 30 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20190913151845.12582-5-alex.bennee@linaro.org | 31 | Message-id: 168778890374.24232.3402138851538068785-1@git.sr.ht |
32 | [PMM: removed unnecessary AArch64 feature check; moved | ||
33 | "clear CTR_EL1.DIC" code up a bit so it's not in the middle | ||
34 | of the vfp/neon related tests] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 35 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 36 | --- |
11 | target/arm/helper.c | 96 +++++++++++---------------------------------- | 37 | target/arm/cpu.c | 11 +++++++++++ |
12 | 1 file changed, 22 insertions(+), 74 deletions(-) | 38 | target/arm/helper.c | 47 ++++++++++++++++++++++++++++++++++++++++++--- |
39 | 2 files changed, 55 insertions(+), 3 deletions(-) | ||
13 | 40 | ||
41 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/cpu.c | ||
44 | +++ b/target/arm/cpu.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
46 | return; | ||
47 | } | ||
48 | |||
49 | +#ifdef CONFIG_USER_ONLY | ||
50 | + /* | ||
51 | + * User mode relies on IC IVAU instructions to catch modification of | ||
52 | + * dual-mapped code. | ||
53 | + * | ||
54 | + * Clear CTR_EL0.DIC to ensure that software that honors these flags uses | ||
55 | + * IC IVAU even if the emulated processor does not normally require it. | ||
56 | + */ | ||
57 | + cpu->ctr = FIELD_DP64(cpu->ctr, CTR_EL0, DIC, 0); | ||
58 | +#endif | ||
59 | + | ||
60 | if (arm_feature(env, ARM_FEATURE_AARCH64) && | ||
61 | cpu->has_vfp != cpu->has_neon) { | ||
62 | /* | ||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 63 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 64 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 65 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/helper.c | 66 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | 67 | @@ -XXX,XX +XXX,XX @@ static void mdcr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, |
19 | new_el, env->pc, pstate_read(env)); | 68 | } |
20 | } | 69 | } |
21 | 70 | ||
22 | -static inline bool check_for_semihosting(CPUState *cs) | 71 | +#ifdef CONFIG_USER_ONLY |
23 | -{ | ||
24 | +/* | 72 | +/* |
25 | + * Do semihosting call and set the appropriate return value. All the | 73 | + * `IC IVAU` is handled to improve compatibility with JITs that dual-map their |
26 | + * permission and validity checks have been done at translate time. | 74 | + * code to get around W^X restrictions, where one region is writable and the |
75 | + * other is executable. | ||
27 | + * | 76 | + * |
28 | + * We only see semihosting exceptions in TCG only as they are not | 77 | + * Since the executable region is never written to we cannot detect code |
29 | + * trapped to the hypervisor in KVM. | 78 | + * changes when running in user mode, and rely on the emulated JIT telling us |
79 | + * that the code has changed by executing this instruction. | ||
30 | + */ | 80 | + */ |
31 | #ifdef CONFIG_TCG | 81 | +static void ic_ivau_write(CPUARMState *env, const ARMCPRegInfo *ri, |
32 | - /* Check whether this exception is a semihosting call; if so | 82 | + uint64_t value) |
33 | - * then handle it and return true; otherwise return false. | ||
34 | - */ | ||
35 | +static void handle_semihosting(CPUState *cs) | ||
36 | +{ | 83 | +{ |
37 | ARMCPU *cpu = ARM_CPU(cs); | 84 | + uint64_t icache_line_mask, start_address, end_address; |
38 | CPUARMState *env = &cpu->env; | 85 | + const ARMCPU *cpu; |
39 | 86 | + | |
40 | if (is_a64(env)) { | 87 | + cpu = env_archcpu(env); |
41 | - if (cs->exception_index == EXCP_SEMIHOST) { | 88 | + |
42 | - /* This is always the 64-bit semihosting exception. | 89 | + icache_line_mask = (4 << extract32(cpu->ctr, 0, 4)) - 1; |
43 | - * The "is this usermode" and "is semihosting enabled" | 90 | + start_address = value & ~icache_line_mask; |
44 | - * checks have been done at translate time. | 91 | + end_address = value | icache_line_mask; |
45 | - */ | 92 | + |
46 | - qemu_log_mask(CPU_LOG_INT, | 93 | + mmap_lock(); |
47 | - "...handling as semihosting call 0x%" PRIx64 "\n", | 94 | + |
48 | - env->xregs[0]); | 95 | + tb_invalidate_phys_range(start_address, end_address); |
49 | - env->xregs[0] = do_arm_semihosting(env); | 96 | + |
50 | - return true; | 97 | + mmap_unlock(); |
51 | - } | 98 | +} |
52 | - return false; | ||
53 | + qemu_log_mask(CPU_LOG_INT, | ||
54 | + "...handling as semihosting call 0x%" PRIx64 "\n", | ||
55 | + env->xregs[0]); | ||
56 | + env->xregs[0] = do_arm_semihosting(env); | ||
57 | } else { | ||
58 | - uint32_t imm; | ||
59 | - | ||
60 | - /* Only intercept calls from privileged modes, to provide some | ||
61 | - * semblance of security. | ||
62 | - */ | ||
63 | - if (cs->exception_index != EXCP_SEMIHOST && | ||
64 | - (!semihosting_enabled() || | ||
65 | - ((env->uncached_cpsr & CPSR_M) == ARM_CPU_MODE_USR))) { | ||
66 | - return false; | ||
67 | - } | ||
68 | - | ||
69 | - switch (cs->exception_index) { | ||
70 | - case EXCP_SEMIHOST: | ||
71 | - /* This is always a semihosting call; the "is this usermode" | ||
72 | - * and "is semihosting enabled" checks have been done at | ||
73 | - * translate time. | ||
74 | - */ | ||
75 | - break; | ||
76 | - case EXCP_SWI: | ||
77 | - /* Check for semihosting interrupt. */ | ||
78 | - if (env->thumb) { | ||
79 | - imm = arm_lduw_code(env, env->regs[15] - 2, arm_sctlr_b(env)) | ||
80 | - & 0xff; | ||
81 | - if (imm == 0xab) { | ||
82 | - break; | ||
83 | - } | ||
84 | - } else { | ||
85 | - imm = arm_ldl_code(env, env->regs[15] - 4, arm_sctlr_b(env)) | ||
86 | - & 0xffffff; | ||
87 | - if (imm == 0x123456) { | ||
88 | - break; | ||
89 | - } | ||
90 | - } | ||
91 | - return false; | ||
92 | - case EXCP_BKPT: | ||
93 | - /* See if this is a semihosting syscall. */ | ||
94 | - if (env->thumb) { | ||
95 | - imm = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) | ||
96 | - & 0xff; | ||
97 | - if (imm == 0xab) { | ||
98 | - env->regs[15] += 2; | ||
99 | - break; | ||
100 | - } | ||
101 | - } | ||
102 | - return false; | ||
103 | - default: | ||
104 | - return false; | ||
105 | - } | ||
106 | - | ||
107 | qemu_log_mask(CPU_LOG_INT, | ||
108 | "...handling as semihosting call 0x%x\n", | ||
109 | env->regs[0]); | ||
110 | env->regs[0] = do_arm_semihosting(env); | ||
111 | - return true; | ||
112 | } | ||
113 | -#else | ||
114 | - return false; | ||
115 | -#endif | ||
116 | } | ||
117 | +#endif | 99 | +#endif |
118 | 100 | + | |
119 | /* Handle a CPU exception for A and R profile CPUs. | 101 | static const ARMCPRegInfo v8_cp_reginfo[] = { |
120 | * Do any appropriate logging, handle PSCI calls, and then hand off | 102 | /* |
121 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) | 103 | * Minimal set of EL0-visible registers. This will need to be expanded |
122 | return; | 104 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { |
123 | } | 105 | { .name = "CURRENTEL", .state = ARM_CP_STATE_AA64, |
124 | 106 | .opc0 = 3, .opc1 = 0, .opc2 = 2, .crn = 4, .crm = 2, | |
125 | - /* Semihosting semantics depend on the register width of the | 107 | .access = PL1_R, .type = ARM_CP_CURRENTEL }, |
126 | - * code that caused the exception, not the target exception level, | 108 | - /* Cache ops: all NOPs since we don't emulate caches */ |
127 | - * so must be handled here. | ||
128 | + /* | 109 | + /* |
129 | + * Semihosting semantics depend on the register width of the code | 110 | + * Instruction cache ops. All of these except `IC IVAU` NOP because we |
130 | + * that caused the exception, not the target exception level, so | 111 | + * don't emulate caches. |
131 | + * must be handled here. | 112 | + */ |
132 | */ | 113 | { .name = "IC_IALLUIS", .state = ARM_CP_STATE_AA64, |
133 | - if (check_for_semihosting(cs)) { | 114 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0, |
134 | +#ifdef CONFIG_TCG | 115 | .access = PL1_W, .type = ARM_CP_NOP, |
135 | + if (cs->exception_index == EXCP_SEMIHOST) { | 116 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { |
136 | + handle_semihosting(cs); | 117 | .accessfn = access_tocu }, |
137 | return; | 118 | { .name = "IC_IVAU", .state = ARM_CP_STATE_AA64, |
138 | } | 119 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 5, .opc2 = 1, |
120 | - .access = PL0_W, .type = ARM_CP_NOP, | ||
121 | + .access = PL0_W, | ||
122 | .fgt = FGT_ICIVAU, | ||
123 | - .accessfn = access_tocu }, | ||
124 | + .accessfn = access_tocu, | ||
125 | +#ifdef CONFIG_USER_ONLY | ||
126 | + .type = ARM_CP_NO_RAW, | ||
127 | + .writefn = ic_ivau_write | ||
128 | +#else | ||
129 | + .type = ARM_CP_NOP | ||
139 | +#endif | 130 | +#endif |
140 | 131 | + }, | |
141 | /* Hooks may change global state so BQL should be held, also the | 132 | + /* Cache ops: all NOPs since we don't emulate caches */ |
142 | * BQL needs to be held for any modification of | 133 | { .name = "DC_IVAC", .state = ARM_CP_STATE_AA64, |
134 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, | ||
135 | .access = PL1_W, .accessfn = aa64_cacheop_poc_access, | ||
143 | -- | 136 | -- |
144 | 2.20.1 | 137 | 2.34.1 |
145 | 138 | ||
146 | 139 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Vikram Garhwal <vikram.garhwal@amd.com> | ||
1 | 2 | ||
3 | Following are done to fix the coverity issues: | ||
4 | 1. Change read_data to fix the CID 1512899: Out-of-bounds access (OVERRUN) | ||
5 | 2. Fix match_rx_tx_data to fix CID 1512900: Logically dead code (DEADCODE) | ||
6 | 3. Replace rand() in generate_random_data() with g_rand_int() | ||
7 | |||
8 | Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com> | ||
9 | Message-id: 20230628202758.16398-1-vikram.garhwal@amd.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | tests/qtest/xlnx-canfd-test.c | 33 +++++++++++---------------------- | ||
14 | 1 file changed, 11 insertions(+), 22 deletions(-) | ||
15 | |||
16 | diff --git a/tests/qtest/xlnx-canfd-test.c b/tests/qtest/xlnx-canfd-test.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/tests/qtest/xlnx-canfd-test.c | ||
19 | +++ b/tests/qtest/xlnx-canfd-test.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void generate_random_data(uint32_t *buf_tx, bool is_canfd_frame) | ||
21 | /* Generate random TX data for CANFD frame. */ | ||
22 | if (is_canfd_frame) { | ||
23 | for (int i = 0; i < CANFD_FRAME_SIZE - 2; i++) { | ||
24 | - buf_tx[2 + i] = rand(); | ||
25 | + buf_tx[2 + i] = g_random_int(); | ||
26 | } | ||
27 | } else { | ||
28 | /* Generate random TX data for CAN frame. */ | ||
29 | for (int i = 0; i < CAN_FRAME_SIZE - 2; i++) { | ||
30 | - buf_tx[2 + i] = rand(); | ||
31 | + buf_tx[2 + i] = g_random_int(); | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | |||
36 | -static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx) | ||
37 | +static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx, | ||
38 | + uint32_t frame_size) | ||
39 | { | ||
40 | uint32_t int_status; | ||
41 | uint32_t fifo_status_reg_value; | ||
42 | /* At which RX FIFO the received data is stored. */ | ||
43 | uint8_t store_ind = 0; | ||
44 | - bool is_canfd_frame = false; | ||
45 | |||
46 | /* Read the interrupt on CANFD rx. */ | ||
47 | int_status = qtest_readl(qts, can_base_addr + R_ISR_OFFSET) & ISR_RXOK; | ||
48 | @@ -XXX,XX +XXX,XX @@ static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx) | ||
49 | buf_rx[0] = qtest_readl(qts, can_base_addr + R_RX0_ID_OFFSET); | ||
50 | buf_rx[1] = qtest_readl(qts, can_base_addr + R_RX0_DLC_OFFSET); | ||
51 | |||
52 | - is_canfd_frame = (buf_rx[1] >> DLC_FD_BIT_SHIFT) & 1; | ||
53 | - | ||
54 | - if (is_canfd_frame) { | ||
55 | - for (int i = 0; i < CANFD_FRAME_SIZE - 2; i++) { | ||
56 | - buf_rx[i + 2] = qtest_readl(qts, | ||
57 | - can_base_addr + R_RX0_DATA1_OFFSET + 4 * i); | ||
58 | - } | ||
59 | - } else { | ||
60 | - buf_rx[2] = qtest_readl(qts, can_base_addr + R_RX0_DATA1_OFFSET); | ||
61 | - buf_rx[3] = qtest_readl(qts, can_base_addr + R_RX0_DATA2_OFFSET); | ||
62 | + for (int i = 0; i < frame_size - 2; i++) { | ||
63 | + buf_rx[i + 2] = qtest_readl(qts, | ||
64 | + can_base_addr + R_RX0_DATA1_OFFSET + 4 * i); | ||
65 | } | ||
66 | |||
67 | /* Clear the RX interrupt. */ | ||
68 | @@ -XXX,XX +XXX,XX @@ static void match_rx_tx_data(const uint32_t *buf_tx, const uint32_t *buf_rx, | ||
69 | g_assert_cmpint((buf_rx[size] & DLC_FD_BIT_MASK), ==, | ||
70 | (buf_tx[size] & DLC_FD_BIT_MASK)); | ||
71 | } else { | ||
72 | - if (!is_canfd_frame && size == 4) { | ||
73 | - break; | ||
74 | - } | ||
75 | - | ||
76 | g_assert_cmpint(buf_rx[size], ==, buf_tx[size]); | ||
77 | } | ||
78 | |||
79 | @@ -XXX,XX +XXX,XX @@ static void test_can_data_transfer(void) | ||
80 | write_data(qts, CANFD0_BASE_ADDR, buf_tx, false); | ||
81 | |||
82 | send_data(qts, CANFD0_BASE_ADDR); | ||
83 | - read_data(qts, CANFD1_BASE_ADDR, buf_rx); | ||
84 | + read_data(qts, CANFD1_BASE_ADDR, buf_rx, CAN_FRAME_SIZE); | ||
85 | match_rx_tx_data(buf_tx, buf_rx, false); | ||
86 | |||
87 | qtest_quit(qts); | ||
88 | @@ -XXX,XX +XXX,XX @@ static void test_canfd_data_transfer(void) | ||
89 | write_data(qts, CANFD0_BASE_ADDR, buf_tx, true); | ||
90 | |||
91 | send_data(qts, CANFD0_BASE_ADDR); | ||
92 | - read_data(qts, CANFD1_BASE_ADDR, buf_rx); | ||
93 | + read_data(qts, CANFD1_BASE_ADDR, buf_rx, CANFD_FRAME_SIZE); | ||
94 | match_rx_tx_data(buf_tx, buf_rx, true); | ||
95 | |||
96 | qtest_quit(qts); | ||
97 | @@ -XXX,XX +XXX,XX @@ static void test_can_loopback(void) | ||
98 | write_data(qts, CANFD0_BASE_ADDR, buf_tx, true); | ||
99 | |||
100 | send_data(qts, CANFD0_BASE_ADDR); | ||
101 | - read_data(qts, CANFD0_BASE_ADDR, buf_rx); | ||
102 | + read_data(qts, CANFD0_BASE_ADDR, buf_rx, CANFD_FRAME_SIZE); | ||
103 | match_rx_tx_data(buf_tx, buf_rx, true); | ||
104 | |||
105 | generate_random_data(buf_tx, true); | ||
106 | @@ -XXX,XX +XXX,XX @@ static void test_can_loopback(void) | ||
107 | write_data(qts, CANFD1_BASE_ADDR, buf_tx, true); | ||
108 | |||
109 | send_data(qts, CANFD1_BASE_ADDR); | ||
110 | - read_data(qts, CANFD1_BASE_ADDR, buf_rx); | ||
111 | + read_data(qts, CANFD1_BASE_ADDR, buf_rx, CANFD_FRAME_SIZE); | ||
112 | match_rx_tx_data(buf_tx, buf_rx, true); | ||
113 | |||
114 | qtest_quit(qts); | ||
115 | -- | ||
116 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Fabiano Rosas <farosas@suse.de> | ||
1 | 2 | ||
3 | This code is only relevant when TCG is present in the build. Building | ||
4 | with --disable-tcg --enable-xen on an x86 host we get: | ||
5 | |||
6 | $ ../configure --target-list=x86_64-softmmu,aarch64-softmmu --disable-tcg --enable-xen | ||
7 | $ make -j$(nproc) | ||
8 | ... | ||
9 | libqemu-aarch64-softmmu.fa.p/target_arm_gdbstub.c.o: in function `m_sysreg_ptr': | ||
10 | ../target/arm/gdbstub.c:358: undefined reference to `arm_v7m_get_sp_ptr' | ||
11 | ../target/arm/gdbstub.c:361: undefined reference to `arm_v7m_get_sp_ptr' | ||
12 | |||
13 | libqemu-aarch64-softmmu.fa.p/target_arm_gdbstub.c.o: in function `arm_gdb_get_m_systemreg': | ||
14 | ../target/arm/gdbstub.c:405: undefined reference to `arm_v7m_mrs_control' | ||
15 | |||
16 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
17 | Message-id: 20230628164821.16771-1-farosas@suse.de | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | target/arm/gdbstub.c | 4 ++++ | ||
22 | 1 file changed, 4 insertions(+) | ||
23 | |||
24 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/gdbstub.c | ||
27 | +++ b/target/arm/gdbstub.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) | ||
29 | return cpu->dyn_sysreg_xml.num; | ||
30 | } | ||
31 | |||
32 | +#ifdef CONFIG_TCG | ||
33 | typedef enum { | ||
34 | M_SYSREG_MSP, | ||
35 | M_SYSREG_PSP, | ||
36 | @@ -XXX,XX +XXX,XX @@ static int arm_gen_dynamic_m_secextreg_xml(CPUState *cs, int orig_base_reg) | ||
37 | return cpu->dyn_m_secextreg_xml.num; | ||
38 | } | ||
39 | #endif | ||
40 | +#endif /* CONFIG_TCG */ | ||
41 | |||
42 | const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) | ||
43 | { | ||
44 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) | ||
45 | arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_regs), | ||
46 | "system-registers.xml", 0); | ||
47 | |||
48 | +#ifdef CONFIG_TCG | ||
49 | if (arm_feature(env, ARM_FEATURE_M) && tcg_enabled()) { | ||
50 | gdb_register_coprocessor(cs, | ||
51 | arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg, | ||
52 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) | ||
53 | } | ||
54 | #endif | ||
55 | } | ||
56 | +#endif /* CONFIG_TCG */ | ||
57 | } | ||
58 | -- | ||
59 | 2.34.1 | diff view generated by jsdifflib |
1 | If we're booting a Linux kernel directly into Non-Secure | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | state on a CPU which has Secure state, then make sure we | ||
3 | set the NSACR CP11 and CP10 bits, so that Non-Secure is allowed | ||
4 | to access the FPU. Otherwise an AArch32 kernel will UNDEF as | ||
5 | soon as it tries to use the FPU. | ||
6 | 2 | ||
7 | It used to not matter that we didn't do this until commit | 3 | AwSRAMCClass is larger than SysBusDeviceClass so the class size must be |
8 | fc1120a7f5f2d4b6, where we implemented actually honouring | 4 | advertised accordingly. |
9 | these NSACR bits. | ||
10 | 5 | ||
11 | The problem only exists for CPUs where EL3 is AArch32; the | 6 | Fixes: 05def917e1 ("hw: arm: allwinner-sramc: Add SRAM Controller support for R40") |
12 | equivalent AArch64 trap bits are in CPTR_EL3 and are "0 to | 7 | Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
13 | not trap, 1 to trap", so the reset value of the register | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
14 | permits NS access, unlike NSACR. | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20230628110905.38125-1-akihiko.odaki@daynix.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/misc/allwinner-sramc.c | 1 + | ||
14 | 1 file changed, 1 insertion(+) | ||
15 | 15 | ||
16 | Fixes: fc1120a7f5 | 16 | diff --git a/hw/misc/allwinner-sramc.c b/hw/misc/allwinner-sramc.c |
17 | Fixes: https://bugs.launchpad.net/qemu/+bug/1844597 | ||
18 | Cc: qemu-stable@nongnu.org | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20190920174039.3916-1-peter.maydell@linaro.org | ||
22 | --- | ||
23 | hw/arm/boot.c | 2 ++ | ||
24 | 1 file changed, 2 insertions(+) | ||
25 | |||
26 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/arm/boot.c | 18 | --- a/hw/misc/allwinner-sramc.c |
29 | +++ b/hw/arm/boot.c | 19 | +++ b/hw/misc/allwinner-sramc.c |
30 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 20 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo allwinner_sramc_info = { |
31 | (cs != first_cpu || !info->secure_board_setup)) { | 21 | .parent = TYPE_SYS_BUS_DEVICE, |
32 | /* Linux expects non-secure state */ | 22 | .instance_init = allwinner_sramc_init, |
33 | env->cp15.scr_el3 |= SCR_NS; | 23 | .instance_size = sizeof(AwSRAMCState), |
34 | + /* Set NSACR.{CP11,CP10} so NS can access the FPU */ | 24 | + .class_size = sizeof(AwSRAMCClass), |
35 | + env->cp15.nsacr |= 3 << 10; | 25 | .class_init = allwinner_sramc_class_init, |
36 | } | 26 | }; |
37 | } | ||
38 | 27 | ||
39 | -- | 28 | -- |
40 | 2.20.1 | 29 | 2.34.1 |
41 | 30 | ||
42 | 31 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In handle_interrupt() we use level as an index into the interrupt_vector[] | ||
2 | array. This is safe because we have checked it against env->config->nlevel, | ||
3 | but Coverity can't see that (and it is only true because each CPU config | ||
4 | sets its XCHAL_NUM_INTLEVELS to something less than MAX_NLEVELS), so it | ||
5 | complains about a possible array overrun (CID 1507131) | ||
1 | 6 | ||
7 | Add an assert() which will make Coverity happy and catch the unlikely | ||
8 | case of a mis-set XCHAL_NUM_INTLEVELS in future. | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Acked-by: Max Filippov <jcmvbkbc@gmail.com> | ||
12 | Message-id: 20230623154135.1930261-1-peter.maydell@linaro.org | ||
13 | --- | ||
14 | target/xtensa/exc_helper.c | 3 +++ | ||
15 | 1 file changed, 3 insertions(+) | ||
16 | |||
17 | diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/xtensa/exc_helper.c | ||
20 | +++ b/target/xtensa/exc_helper.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void handle_interrupt(CPUXtensaState *env) | ||
22 | CPUState *cs = env_cpu(env); | ||
23 | |||
24 | if (level > 1) { | ||
25 | + /* env->config->nlevel check should have ensured this */ | ||
26 | + assert(level < sizeof(env->config->interrupt_vector)); | ||
27 | + | ||
28 | env->sregs[EPC1 + level - 1] = env->pc; | ||
29 | env->sregs[EPS2 + level - 2] = env->sregs[PS]; | ||
30 | env->sregs[PS] = | ||
31 | -- | ||
32 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | We already squash the ID register field for FEAT_SPE (the Statistical |
---|---|---|---|
2 | Profiling Extension) because TCG does not implement it and if we | ||
3 | advertise it to the guest the guest will crash trying to look at | ||
4 | non-existent system registers. Do the same for some other features | ||
5 | which a real hardware Neoverse-V1 implements but which TCG doesn't: | ||
6 | * FEAT_TRF (Self-hosted Trace Extension) | ||
7 | * Trace Macrocell system register access | ||
8 | * Memory mapped trace | ||
9 | * FEAT_AMU (Activity Monitors Extension) | ||
10 | * FEAT_MPAM (Memory Partitioning and Monitoring Extension) | ||
11 | * FEAT_NV (Nested Virtualization) | ||
2 | 12 | ||
3 | IEC binary prefixes ease code review: the unit is explicit. | 13 | Most of these, like FEAT_SPE, are "introspection/trace" type features |
14 | which QEMU is unlikely to ever implement. The odd-one-out here is | ||
15 | FEAT_NV -- we could implement that and at some point we probably | ||
16 | will. | ||
4 | 17 | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Message-id: 20230704130647.2842917-2-peter.maydell@linaro.org | ||
20 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> | ||
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190923131108.21459-1-philmd@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | 22 | --- |
12 | hw/arm/boot.c | 10 +++++----- | 23 | target/arm/cpu.c | 33 +++++++++++++++++++++++++++++---- |
13 | 1 file changed, 5 insertions(+), 5 deletions(-) | 24 | 1 file changed, 29 insertions(+), 4 deletions(-) |
14 | 25 | ||
15 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 26 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
16 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/boot.c | 28 | --- a/target/arm/cpu.c |
18 | +++ b/hw/arm/boot.c | 29 | +++ b/target/arm/cpu.c |
19 | @@ -XXX,XX +XXX,XX @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, | 30 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
20 | goto fail; | 31 | |
32 | if (tcg_enabled()) { | ||
33 | /* | ||
34 | - * Don't report the Statistical Profiling Extension in the ID | ||
35 | - * registers, because TCG doesn't implement it yet (not even a | ||
36 | - * minimal stub version) and guests will fall over when they | ||
37 | - * try to access the non-existent system registers for it. | ||
38 | + * Don't report some architectural features in the ID registers | ||
39 | + * where TCG does not yet implement it (not even a minimal | ||
40 | + * stub version). This avoids guests falling over when they | ||
41 | + * try to access the non-existent system registers for them. | ||
42 | */ | ||
43 | + /* FEAT_SPE (Statistical Profiling Extension) */ | ||
44 | cpu->isar.id_aa64dfr0 = | ||
45 | FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, PMSVER, 0); | ||
46 | + /* FEAT_TRF (Self-hosted Trace Extension) */ | ||
47 | + cpu->isar.id_aa64dfr0 = | ||
48 | + FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEFILT, 0); | ||
49 | + cpu->isar.id_dfr0 = | ||
50 | + FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, TRACEFILT, 0); | ||
51 | + /* Trace Macrocell system register access */ | ||
52 | + cpu->isar.id_aa64dfr0 = | ||
53 | + FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEVER, 0); | ||
54 | + cpu->isar.id_dfr0 = | ||
55 | + FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, COPTRC, 0); | ||
56 | + /* Memory mapped trace */ | ||
57 | + cpu->isar.id_dfr0 = | ||
58 | + FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, MMAPTRC, 0); | ||
59 | + /* FEAT_AMU (Activity Monitors Extension) */ | ||
60 | + cpu->isar.id_aa64pfr0 = | ||
61 | + FIELD_DP64(cpu->isar.id_aa64pfr0, ID_AA64PFR0, AMU, 0); | ||
62 | + cpu->isar.id_pfr0 = | ||
63 | + FIELD_DP32(cpu->isar.id_pfr0, ID_PFR0, AMU, 0); | ||
64 | + /* FEAT_MPAM (Memory Partitioning and Monitoring Extension) */ | ||
65 | + cpu->isar.id_aa64pfr0 = | ||
66 | + FIELD_DP64(cpu->isar.id_aa64pfr0, ID_AA64PFR0, MPAM, 0); | ||
67 | + /* FEAT_NV (Nested Virtualization) */ | ||
68 | + cpu->isar.id_aa64mmfr2 = | ||
69 | + FIELD_DP64(cpu->isar.id_aa64mmfr2, ID_AA64MMFR2, NV, 0); | ||
21 | } | 70 | } |
22 | 71 | ||
23 | - if (scells < 2 && binfo->ram_size >= (1ULL << 32)) { | 72 | /* MPU can be configured out of a PMSA CPU either by setting has-mpu |
24 | + if (scells < 2 && binfo->ram_size >= 4 * GiB) { | ||
25 | /* This is user error so deserves a friendlier error message | ||
26 | * than the failure of setprop_sized_cells would provide | ||
27 | */ | ||
28 | @@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, | ||
29 | * we might still make a bad choice here. | ||
30 | */ | ||
31 | info->initrd_start = info->loader_start + | ||
32 | - MIN(info->ram_size / 2, 128 * 1024 * 1024); | ||
33 | + MIN(info->ram_size / 2, 128 * MiB); | ||
34 | if (image_high_addr) { | ||
35 | info->initrd_start = MAX(info->initrd_start, image_high_addr); | ||
36 | } | ||
37 | @@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, | ||
38 | * | ||
39 | * Let's play safe and prealign it to 2MB to give us some space. | ||
40 | */ | ||
41 | - align = 2 * 1024 * 1024; | ||
42 | + align = 2 * MiB; | ||
43 | } else { | ||
44 | /* | ||
45 | * Some 32bit kernels will trash anything in the 4K page the | ||
46 | * initrd ends in, so make sure the DTB isn't caught up in that. | ||
47 | */ | ||
48 | - align = 4096; | ||
49 | + align = 4 * KiB; | ||
50 | } | ||
51 | |||
52 | /* Place the DTB after the initrd in memory with alignment. */ | ||
53 | @@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, | ||
54 | info->loader_start + KERNEL_ARGS_ADDR; | ||
55 | fixupcontext[FIXUP_ARGPTR_HI] = | ||
56 | (info->loader_start + KERNEL_ARGS_ADDR) >> 32; | ||
57 | - if (info->ram_size >= (1ULL << 32)) { | ||
58 | + if (info->ram_size >= 4 * GiB) { | ||
59 | error_report("RAM size must be less than 4GB to boot" | ||
60 | " Linux kernel using ATAGS (try passing a device tree" | ||
61 | " using -dtb)"); | ||
62 | -- | 73 | -- |
63 | 2.20.1 | 74 | 2.34.1 |
64 | 75 | ||
65 | 76 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | Now that we have implemented support for FEAT_LSE2, we can define | |
2 | a CPU model for the Neoverse-V1, and enable it for the virt and | ||
3 | sbsa-ref boards. | ||
4 | |||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Message-id: 20230704130647.2842917-3-peter.maydell@linaro.org | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | docs/system/arm/virt.rst | 1 + | ||
11 | hw/arm/sbsa-ref.c | 1 + | ||
12 | hw/arm/virt.c | 1 + | ||
13 | target/arm/tcg/cpu64.c | 128 +++++++++++++++++++++++++++++++++++++++ | ||
14 | 4 files changed, 131 insertions(+) | ||
15 | |||
16 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/docs/system/arm/virt.rst | ||
19 | +++ b/docs/system/arm/virt.rst | ||
20 | @@ -XXX,XX +XXX,XX @@ Supported guest CPU types: | ||
21 | - ``a64fx`` (64-bit) | ||
22 | - ``host`` (with KVM only) | ||
23 | - ``neoverse-n1`` (64-bit) | ||
24 | +- ``neoverse-v1`` (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("neoverse-n1"), | ||
36 | + ARM_CPU_TYPE_NAME("neoverse-v1"), | ||
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-a76"), | ||
46 | ARM_CPU_TYPE_NAME("a64fx"), | ||
47 | ARM_CPU_TYPE_NAME("neoverse-n1"), | ||
48 | + ARM_CPU_TYPE_NAME("neoverse-v1"), | ||
49 | #endif | ||
50 | ARM_CPU_TYPE_NAME("cortex-a53"), | ||
51 | ARM_CPU_TYPE_NAME("cortex-a57"), | ||
52 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/tcg/cpu64.c | ||
55 | +++ b/target/arm/tcg/cpu64.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu) | ||
57 | define_arm_cp_regs(cpu, neoverse_n1_cp_reginfo); | ||
58 | } | ||
59 | |||
60 | +static const ARMCPRegInfo neoverse_v1_cp_reginfo[] = { | ||
61 | + { .name = "CPUECTLR2_EL1", .state = ARM_CP_STATE_AA64, | ||
62 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 5, | ||
63 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
64 | + { .name = "CPUPPMCR_EL3", .state = ARM_CP_STATE_AA64, | ||
65 | + .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 2, .opc2 = 0, | ||
66 | + .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
67 | + { .name = "CPUPPMCR2_EL3", .state = ARM_CP_STATE_AA64, | ||
68 | + .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 2, .opc2 = 1, | ||
69 | + .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
70 | + { .name = "CPUPPMCR3_EL3", .state = ARM_CP_STATE_AA64, | ||
71 | + .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 2, .opc2 = 6, | ||
72 | + .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
73 | +}; | ||
74 | + | ||
75 | +static void define_neoverse_v1_cp_reginfo(ARMCPU *cpu) | ||
76 | +{ | ||
77 | + /* | ||
78 | + * The Neoverse V1 has all of the Neoverse N1's IMPDEF | ||
79 | + * registers and a few more of its own. | ||
80 | + */ | ||
81 | + define_arm_cp_regs(cpu, neoverse_n1_cp_reginfo); | ||
82 | + define_arm_cp_regs(cpu, neoverse_v1_cp_reginfo); | ||
83 | +} | ||
84 | + | ||
85 | static void aarch64_neoverse_n1_initfn(Object *obj) | ||
86 | { | ||
87 | ARMCPU *cpu = ARM_CPU(obj); | ||
88 | @@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_n1_initfn(Object *obj) | ||
89 | define_neoverse_n1_cp_reginfo(cpu); | ||
90 | } | ||
91 | |||
92 | +static void aarch64_neoverse_v1_initfn(Object *obj) | ||
93 | +{ | ||
94 | + ARMCPU *cpu = ARM_CPU(obj); | ||
95 | + | ||
96 | + cpu->dtb_compatible = "arm,neoverse-v1"; | ||
97 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
98 | + set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
99 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
100 | + set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
101 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
102 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
103 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
104 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
105 | + | ||
106 | + /* Ordered by 3.2.4 AArch64 registers by functional group */ | ||
107 | + cpu->clidr = 0x82000023; | ||
108 | + cpu->ctr = 0xb444c004; /* With DIC and IDC set */ | ||
109 | + cpu->dcz_blocksize = 4; | ||
110 | + cpu->id_aa64afr0 = 0x00000000; | ||
111 | + cpu->id_aa64afr1 = 0x00000000; | ||
112 | + cpu->isar.id_aa64dfr0 = 0x000001f210305519ull; | ||
113 | + cpu->isar.id_aa64dfr1 = 0x00000000; | ||
114 | + cpu->isar.id_aa64isar0 = 0x1011111110212120ull; /* with FEAT_RNG */ | ||
115 | + cpu->isar.id_aa64isar1 = 0x0111000001211032ull; | ||
116 | + cpu->isar.id_aa64mmfr0 = 0x0000000000101125ull; | ||
117 | + cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; | ||
118 | + cpu->isar.id_aa64mmfr2 = 0x0220011102101011ull; | ||
119 | + cpu->isar.id_aa64pfr0 = 0x1101110120111112ull; /* GIC filled in later */ | ||
120 | + cpu->isar.id_aa64pfr1 = 0x0000000000000020ull; | ||
121 | + cpu->id_afr0 = 0x00000000; | ||
122 | + cpu->isar.id_dfr0 = 0x15011099; | ||
123 | + cpu->isar.id_isar0 = 0x02101110; | ||
124 | + cpu->isar.id_isar1 = 0x13112111; | ||
125 | + cpu->isar.id_isar2 = 0x21232042; | ||
126 | + cpu->isar.id_isar3 = 0x01112131; | ||
127 | + cpu->isar.id_isar4 = 0x00010142; | ||
128 | + cpu->isar.id_isar5 = 0x11011121; | ||
129 | + cpu->isar.id_isar6 = 0x01100111; | ||
130 | + cpu->isar.id_mmfr0 = 0x10201105; | ||
131 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
132 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
133 | + cpu->isar.id_mmfr3 = 0x02122211; | ||
134 | + cpu->isar.id_mmfr4 = 0x01021110; | ||
135 | + cpu->isar.id_pfr0 = 0x21110131; | ||
136 | + cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ | ||
137 | + cpu->isar.id_pfr2 = 0x00000011; | ||
138 | + cpu->midr = 0x411FD402; /* r1p2 */ | ||
139 | + cpu->revidr = 0; | ||
140 | + | ||
141 | + /* | ||
142 | + * The Neoverse-V1 r1p2 TRM lists 32-bit format CCSIDR_EL1 values, | ||
143 | + * but also says it implements CCIDX, which means they should be | ||
144 | + * 64-bit format. So we here use values which are based on the textual | ||
145 | + * information in chapter 2 of the TRM (and on the fact that | ||
146 | + * sets * associativity * linesize == cachesize). | ||
147 | + * | ||
148 | + * The 64-bit CCSIDR_EL1 format is: | ||
149 | + * [55:32] number of sets - 1 | ||
150 | + * [23:3] associativity - 1 | ||
151 | + * [2:0] log2(linesize) - 4 | ||
152 | + * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc | ||
153 | + * | ||
154 | + * L1: 4-way set associative 64-byte line size, total size 64K, | ||
155 | + * so sets is 256. | ||
156 | + * | ||
157 | + * L2: 8-way set associative, 64 byte line size, either 512K or 1MB. | ||
158 | + * We pick 1MB, so this has 2048 sets. | ||
159 | + * | ||
160 | + * L3: No L3 (this matches the CLIDR_EL1 value). | ||
161 | + */ | ||
162 | + cpu->ccsidr[0] = 0x000000ff0000001aull; /* 64KB L1 dcache */ | ||
163 | + cpu->ccsidr[1] = 0x000000ff0000001aull; /* 64KB L1 icache */ | ||
164 | + cpu->ccsidr[2] = 0x000007ff0000003aull; /* 1MB L2 cache */ | ||
165 | + | ||
166 | + /* From 3.2.115 SCTLR_EL3 */ | ||
167 | + cpu->reset_sctlr = 0x30c50838; | ||
168 | + | ||
169 | + /* From 3.4.8 ICC_CTLR_EL3 and 3.4.23 ICH_VTR_EL2 */ | ||
170 | + cpu->gic_num_lrs = 4; | ||
171 | + cpu->gic_vpribits = 5; | ||
172 | + cpu->gic_vprebits = 5; | ||
173 | + cpu->gic_pribits = 5; | ||
174 | + | ||
175 | + /* From 3.5.1 AdvSIMD AArch64 register summary */ | ||
176 | + cpu->isar.mvfr0 = 0x10110222; | ||
177 | + cpu->isar.mvfr1 = 0x13211111; | ||
178 | + cpu->isar.mvfr2 = 0x00000043; | ||
179 | + | ||
180 | + /* From 3.7.5 ID_AA64ZFR0_EL1 */ | ||
181 | + cpu->isar.id_aa64zfr0 = 0x0000100000100000; | ||
182 | + cpu->sve_vq.supported = (1 << 0) /* 128bit */ | ||
183 | + | (1 << 1); /* 256bit */ | ||
184 | + | ||
185 | + /* From 5.5.1 AArch64 PMU register summary */ | ||
186 | + cpu->isar.reset_pmcr_el0 = 0x41213000; | ||
187 | + | ||
188 | + define_neoverse_v1_cp_reginfo(cpu); | ||
189 | + | ||
190 | + aarch64_add_pauth_properties(obj); | ||
191 | + aarch64_add_sve_properties(obj); | ||
192 | +} | ||
193 | + | ||
194 | /* | ||
195 | * -cpu max: a CPU with as many features enabled as our emulation supports. | ||
196 | * The version of '-cpu max' for qemu-system-arm is defined in cpu32.c; | ||
197 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { | ||
198 | { .name = "cortex-a76", .initfn = aarch64_a76_initfn }, | ||
199 | { .name = "a64fx", .initfn = aarch64_a64fx_initfn }, | ||
200 | { .name = "neoverse-n1", .initfn = aarch64_neoverse_n1_initfn }, | ||
201 | + { .name = "neoverse-v1", .initfn = aarch64_neoverse_v1_initfn }, | ||
202 | }; | ||
203 | |||
204 | static void aarch64_cpu_register_types(void) | ||
205 | -- | ||
206 | 2.34.1 | ||
207 | |||
208 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | If you build QEMU with the clang sanitizer enabled, you can see it |
---|---|---|---|
2 | fire when running the arm-cpu-features test: | ||
2 | 3 | ||
3 | Now we do all our checking at translate time we can make cpu_loop a | 4 | $ QTEST_QEMU_BINARY=./build/arm-clang/qemu-system-aarch64 ./build/arm-clang/tests/qtest/arm-cpu-features |
4 | little bit simpler. We also introduce a simple linux-user semihosting | 5 | [...] |
5 | test case to defend the functionality. The out-of-tree softmmu based | 6 | ../../target/arm/cpu64.c:125:19: runtime error: shift exponent 64 is too large for 64-bit type 'unsigned long long' |
6 | semihosting tests are still more comprehensive. | 7 | [...] |
7 | 8 | ||
8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 9 | This happens because the user can specify some incorrect SVE |
9 | Message-id: 20190913151845.12582-6-alex.bennee@linaro.org | 10 | properties that result in our calculating a max_vq of 0. We catch |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | this and error out, but before we do that we calculate |
12 | |||
13 | vq_mask = MAKE_64BIT_MASK(0, max_vq);$ | ||
14 | |||
15 | and the MAKE_64BIT_MASK() call is only valid for lengths that are | ||
16 | greater than zero, so we hit the undefined behaviour. | ||
17 | |||
18 | Change the logic so that if max_vq is 0 we specifically set vq_mask | ||
19 | to 0 without going via MAKE_64BIT_MASK(). This lets us drop the | ||
20 | max_vq check from the error-exit logic, because if max_vq is 0 then | ||
21 | vq_map must now be 0. | ||
22 | |||
23 | The UB only happens in the case where the user passed us an incorrect | ||
24 | set of SVE properties, so it's not a big problem in practice. | ||
25 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
27 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
28 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
29 | Message-id: 20230704154332.3014896-1-peter.maydell@linaro.org | ||
12 | --- | 30 | --- |
13 | linux-user/arm/target_syscall.h | 3 --- | 31 | target/arm/cpu64.c | 4 ++-- |
14 | linux-user/arm/cpu_loop.c | 3 --- | 32 | 1 file changed, 2 insertions(+), 2 deletions(-) |
15 | 2 files changed, 6 deletions(-) | ||
16 | 33 | ||
17 | diff --git a/linux-user/arm/target_syscall.h b/linux-user/arm/target_syscall.h | 34 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
18 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/linux-user/arm/target_syscall.h | 36 | --- a/target/arm/cpu64.c |
20 | +++ b/linux-user/arm/target_syscall.h | 37 | +++ b/target/arm/cpu64.c |
21 | @@ -XXX,XX +XXX,XX @@ struct target_pt_regs { | 38 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) |
22 | #define ARM_NR_set_tls (ARM_NR_BASE + 5) | 39 | vq = ctz32(tmp) + 1; |
23 | #define ARM_NR_get_tls (ARM_NR_BASE + 6) | 40 | |
24 | 41 | max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; | |
25 | -#define ARM_NR_semihosting 0x123456 | 42 | - vq_mask = MAKE_64BIT_MASK(0, max_vq); |
26 | -#define ARM_NR_thumb_semihosting 0xAB | 43 | + vq_mask = max_vq > 0 ? MAKE_64BIT_MASK(0, max_vq) : 0; |
27 | - | 44 | vq_map = vq_supported & ~vq_init & vq_mask; |
28 | #if defined(TARGET_WORDS_BIGENDIAN) | 45 | |
29 | #define UNAME_MACHINE "armv5teb" | 46 | - if (max_vq == 0 || vq_map == 0) { |
30 | #else | 47 | + if (vq_map == 0) { |
31 | diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c | 48 | error_setg(errp, "cannot disable sve%d", vq * 128); |
32 | index XXXXXXX..XXXXXXX 100644 | 49 | error_append_hint(errp, "Disabling sve%d results in all " |
33 | --- a/linux-user/arm/cpu_loop.c | 50 | "vector lengths being disabled.\n", |
34 | +++ b/linux-user/arm/cpu_loop.c | ||
35 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) | ||
36 | |||
37 | if (n == ARM_NR_cacheflush) { | ||
38 | /* nop */ | ||
39 | - } else if (n == ARM_NR_semihosting | ||
40 | - || n == ARM_NR_thumb_semihosting) { | ||
41 | - env->regs[0] = do_arm_semihosting (env); | ||
42 | } else if (n == 0 || n >= ARM_SYSCALL_BASE || env->thumb) { | ||
43 | /* linux syscall */ | ||
44 | if (env->thumb || n == 0) { | ||
45 | -- | 51 | -- |
46 | 2.20.1 | 52 | 2.34.1 |
47 | 53 | ||
48 | 54 | diff view generated by jsdifflib |