1 | Arm patch queue -- these are all bug fix patches but we might | 1 | Just a collection of bug fixes this time around... |
---|---|---|---|
2 | as well put them in to rc0... | ||
3 | 2 | ||
4 | thanks | 3 | thanks |
5 | -- PMM | 4 | -- PMM |
6 | 5 | ||
7 | The following changes since commit 2c8cfc0b52b5a4d123c26c0b5fdf941be24805be: | 6 | The following changes since commit 2a6ae69154542caa91dd17c40fd3f5ffbec300de: |
8 | 7 | ||
9 | Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2018-03-19 11:44:26 +0000) | 8 | Merge tag 'pull-maintainer-ominbus-030723-1' of https://gitlab.com/stsquad/qemu into staging (2023-07-04 08:36:44 +0200) |
10 | 9 | ||
11 | are available in the Git repository at: | 10 | are available in the Git repository at: |
12 | 11 | ||
13 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180319 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230704 |
14 | 13 | ||
15 | for you to fetch changes up to ff72cb6b46b95bb530787add5277c211af3d31c6: | 14 | for you to fetch changes up to 86a78272f094857b4eda79d721c116e93942aa9a: |
16 | 15 | ||
17 | hw/arm/raspi: Provide spin-loop code for AArch64 CPUs (2018-03-19 18:23:24 +0000) | 16 | target/xtensa: Assert that interrupt level is within bounds (2023-07-04 14:27:08 +0100) |
18 | 17 | ||
19 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
20 | target-arm queue: | 19 | target-arm queue: |
21 | * fsl-imx6: Fix incorrect Ethernet interrupt defines | 20 | * Add raw_writes ops for register whose write induce TLB maintenance |
22 | * dump: Update correct kdump phys_base field for AArch64 | 21 | * hw/arm/sbsa-ref: use XHCI to replace EHCI |
23 | * char: i.MX: Add support for "TX complete" interrupt | 22 | * Avoid splitting Zregs across lines in dump |
24 | * bcm2836/raspi: Fix various bugs resulting in panics trying | 23 | * Dump ZA[] when active |
25 | to boot a Debian Linux kernel on raspi3 | 24 | * Fix SME full tile indexing |
25 | * Handle IC IVAU to improve compatibility with JITs | ||
26 | * xlnx-canfd-test: Fix code coverity issues | ||
27 | * gdbstub: Guard M-profile code with CONFIG_TCG | ||
28 | * allwinner-sramc: Set class_size | ||
29 | * target/xtensa: Assert that interrupt level is within bounds | ||
26 | 30 | ||
27 | ---------------------------------------------------------------- | 31 | ---------------------------------------------------------------- |
28 | Andrey Smirnov (2): | 32 | Akihiko Odaki (1): |
29 | char: i.MX: Simplify imx_update() | 33 | hw: arm: allwinner-sramc: Set class_size |
30 | char: i.MX: Add support for "TX complete" interrupt | ||
31 | 34 | ||
32 | Guenter Roeck (1): | 35 | Eric Auger (1): |
33 | fsl-imx6: Swap Ethernet interrupt defines | 36 | target/arm: Add raw_writes ops for register whose write induce TLB maintenance |
34 | 37 | ||
35 | Peter Maydell (9): | 38 | Fabiano Rosas (1): |
36 | hw/arm/raspi: Don't do board-setup or secure-boot for raspi3 | 39 | target/arm: gdbstub: Guard M-profile code with CONFIG_TCG |
37 | hw/arm/boot: assert that secure_boot and secure_board_setup are false for AArch64 | ||
38 | hw/arm/boot: If booting a kernel in EL2, set SCR_EL3.HCE | ||
39 | hw/arm/bcm2386: Fix parent type of bcm2386 | ||
40 | hw/arm/bcm2836: Rename bcm2836 type/struct to bcm283x | ||
41 | hw/arm/bcm2836: Create proper bcm2837 device | ||
42 | hw/arm/bcm2836: Use correct affinity values for BCM2837 | ||
43 | hw/arm/bcm2836: Hardcode correct CPU type | ||
44 | hw/arm/raspi: Provide spin-loop code for AArch64 CPUs | ||
45 | 40 | ||
46 | Wei Huang (1): | 41 | John Högberg (2): |
47 | dump: Update correct kdump phys_base field for AArch64 | 42 | target/arm: Handle IC IVAU to improve compatibility with JITs |
43 | tests/tcg/aarch64: Add testcases for IC IVAU and dual-mapped code | ||
48 | 44 | ||
49 | include/hw/arm/bcm2836.h | 31 +++++++++++++--- | 45 | Peter Maydell (1): |
50 | include/hw/arm/fsl-imx6.h | 4 +- | 46 | target/xtensa: Assert that interrupt level is within bounds |
51 | include/hw/char/imx_serial.h | 3 ++ | ||
52 | dump.c | 14 +++++-- | ||
53 | hw/arm/bcm2836.c | 87 +++++++++++++++++++++++++++++++------------- | ||
54 | hw/arm/boot.c | 12 ++++++ | ||
55 | hw/arm/raspi.c | 77 +++++++++++++++++++++++++++++++-------- | ||
56 | hw/char/imx_serial.c | 44 ++++++++++++++++------ | ||
57 | hw/net/imx_fec.c | 28 +++++++++++++- | ||
58 | 9 files changed, 237 insertions(+), 63 deletions(-) | ||
59 | 47 | ||
48 | Richard Henderson (3): | ||
49 | target/arm: Avoid splitting Zregs across lines in dump | ||
50 | target/arm: Dump ZA[] when active | ||
51 | target/arm: Fix SME full tile indexing | ||
52 | |||
53 | Vikram Garhwal (1): | ||
54 | tests/qtest: xlnx-canfd-test: Fix code coverity issues | ||
55 | |||
56 | Yuquan Wang (1): | ||
57 | hw/arm/sbsa-ref: use XHCI to replace EHCI | ||
58 | |||
59 | docs/system/arm/sbsa.rst | 5 +- | ||
60 | hw/arm/sbsa-ref.c | 23 +++-- | ||
61 | hw/misc/allwinner-sramc.c | 1 + | ||
62 | target/arm/cpu.c | 65 ++++++++----- | ||
63 | target/arm/gdbstub.c | 4 + | ||
64 | target/arm/helper.c | 70 +++++++++++--- | ||
65 | target/arm/tcg/translate-sme.c | 24 +++-- | ||
66 | target/xtensa/exc_helper.c | 3 + | ||
67 | tests/qtest/xlnx-canfd-test.c | 33 +++---- | ||
68 | tests/tcg/aarch64/icivau.c | 189 ++++++++++++++++++++++++++++++++++++++ | ||
69 | tests/tcg/aarch64/sme-outprod1.c | 83 +++++++++++++++++ | ||
70 | hw/arm/Kconfig | 2 +- | ||
71 | tests/tcg/aarch64/Makefile.target | 13 ++- | ||
72 | 13 files changed, 436 insertions(+), 79 deletions(-) | ||
73 | create mode 100644 tests/tcg/aarch64/icivau.c | ||
74 | create mode 100644 tests/tcg/aarch64/sme-outprod1.c | ||
75 | diff view generated by jsdifflib |
1 | The TypeInfo and state struct for bcm2386 disagree about what the | 1 | From: Eric Auger <eric.auger@redhat.com> |
---|---|---|---|
2 | parent class is -- the TypeInfo says it's TYPE_SYS_BUS_DEVICE, | ||
3 | but the BCM2386State struct only defines the parent_obj field | ||
4 | as DeviceState. This would have caused problems if anything | ||
5 | actually tried to treat the object as a TYPE_SYS_BUS_DEVICE. | ||
6 | Fix the TypeInfo to use TYPE_DEVICE as the parent, since we don't | ||
7 | need any of the additional functionality TYPE_SYS_BUS_DEVICE | ||
8 | provides. | ||
9 | 2 | ||
3 | Some registers whose 'cooked' writefns induce TLB maintenance do | ||
4 | not have raw_writefn ops defined. If only the writefn ops is set | ||
5 | (ie. no raw_writefn is provided), it is assumed the cooked also | ||
6 | work as the raw one. For those registers it is not obvious the | ||
7 | tlb_flush works on KVM mode so better/safer setting the raw write. | ||
8 | |||
9 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
10 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20180313153458.26822-5-peter.maydell@linaro.org | ||
14 | --- | 13 | --- |
15 | hw/arm/bcm2836.c | 2 +- | 14 | target/arm/helper.c | 23 +++++++++++++---------- |
16 | 1 file changed, 1 insertion(+), 1 deletion(-) | 15 | 1 file changed, 13 insertions(+), 10 deletions(-) |
17 | 16 | ||
18 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/arm/bcm2836.c | 19 | --- a/target/arm/helper.c |
21 | +++ b/hw/arm/bcm2836.c | 20 | +++ b/target/arm/helper.c |
22 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data) | 21 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { |
23 | 22 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 0, | |
24 | static const TypeInfo bcm2836_type_info = { | 23 | .access = PL1_RW, .accessfn = access_tvm_trvm, |
25 | .name = TYPE_BCM2836, | 24 | .fgt = FGT_TTBR0_EL1, |
26 | - .parent = TYPE_SYS_BUS_DEVICE, | 25 | - .writefn = vmsa_ttbr_write, .resetvalue = 0, |
27 | + .parent = TYPE_DEVICE, | 26 | + .writefn = vmsa_ttbr_write, .resetvalue = 0, .raw_writefn = raw_write, |
28 | .instance_size = sizeof(BCM2836State), | 27 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s), |
29 | .instance_init = bcm2836_init, | 28 | offsetof(CPUARMState, cp15.ttbr0_ns) } }, |
30 | .class_init = bcm2836_class_init, | 29 | { .name = "TTBR1_EL1", .state = ARM_CP_STATE_BOTH, |
30 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 1, | ||
31 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
32 | .fgt = FGT_TTBR1_EL1, | ||
33 | - .writefn = vmsa_ttbr_write, .resetvalue = 0, | ||
34 | + .writefn = vmsa_ttbr_write, .resetvalue = 0, .raw_writefn = raw_write, | ||
35 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), | ||
36 | offsetof(CPUARMState, cp15.ttbr1_ns) } }, | ||
37 | { .name = "TCR_EL1", .state = ARM_CP_STATE_AA64, | ||
38 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = { | ||
39 | .type = ARM_CP_64BIT | ARM_CP_ALIAS, | ||
40 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s), | ||
41 | offsetof(CPUARMState, cp15.ttbr0_ns) }, | ||
42 | - .writefn = vmsa_ttbr_write, }, | ||
43 | + .writefn = vmsa_ttbr_write, .raw_writefn = raw_write }, | ||
44 | { .name = "TTBR1", .cp = 15, .crm = 2, .opc1 = 1, | ||
45 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
46 | .type = ARM_CP_64BIT | ARM_CP_ALIAS, | ||
47 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), | ||
48 | offsetof(CPUARMState, cp15.ttbr1_ns) }, | ||
49 | - .writefn = vmsa_ttbr_write, }, | ||
50 | + .writefn = vmsa_ttbr_write, .raw_writefn = raw_write }, | ||
51 | }; | ||
52 | |||
53 | static uint64_t aa64_fpcr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
54 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
55 | .type = ARM_CP_IO, | ||
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, | ||
31 | -- | 117 | -- |
32 | 2.16.2 | 118 | 2.34.1 |
33 | |||
34 | diff view generated by jsdifflib |
1 | Now we have separate types for BCM2386 and BCM2387, we might as well | 1 | From: Yuquan Wang <wangyuquan1236@phytium.com.cn> |
---|---|---|---|
2 | just hard-code the CPU type they use rather than having it passed | ||
3 | through as an object property. This then lets us put the initialization | ||
4 | of the CPU object in init rather than realize. | ||
5 | 2 | ||
6 | Note that this change means that it's no longer possible on | 3 | The current sbsa-ref cannot use EHCI controller which is only |
7 | the command line to use -cpu to ask for a different kind of | 4 | able to do 32-bit DMA, since sbsa-ref doesn't have RAM below 4GB. |
8 | CPU than the SoC supports. This was never a supported thing to | 5 | Hence, this uses XHCI to provide a usb controller with 64-bit |
9 | do anyway; we were just not sanity-checking the command line. | 6 | DMA capablity instead of EHCI. |
10 | 7 | ||
11 | This does require us to only build the bcm2837 object on | 8 | We bump the platform version to 0.3 with this change. Although the |
12 | TARGET_AARCH64 configs, since otherwise it won't instantiate | 9 | hardware at the USB controller address changes, the firmware and |
13 | due to the missing cortex-a53 device and "make check" will fail. | 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. | ||
14 | 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] | ||
21 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
17 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
18 | Message-id: 20180313153458.26822-9-peter.maydell@linaro.org | ||
19 | --- | 23 | --- |
20 | hw/arm/bcm2836.c | 24 +++++++++++++++--------- | 24 | docs/system/arm/sbsa.rst | 5 ++++- |
21 | hw/arm/raspi.c | 2 -- | 25 | hw/arm/sbsa-ref.c | 23 +++++++++++++---------- |
22 | 2 files changed, 15 insertions(+), 11 deletions(-) | 26 | hw/arm/Kconfig | 2 +- |
27 | 3 files changed, 18 insertions(+), 12 deletions(-) | ||
23 | 28 | ||
24 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | 29 | diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst |
25 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/arm/bcm2836.c | 31 | --- a/docs/system/arm/sbsa.rst |
27 | +++ b/hw/arm/bcm2836.c | 32 | +++ b/docs/system/arm/sbsa.rst |
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 | ||
28 | @@ -XXX,XX +XXX,XX @@ | 53 | @@ -XXX,XX +XXX,XX @@ |
29 | 54 | #include "hw/pci-host/gpex.h" | |
30 | struct BCM283XInfo { | 55 | #include "hw/qdev-properties.h" |
31 | const char *name; | 56 | #include "hw/usb.h" |
32 | + const char *cpu_type; | 57 | +#include "hw/usb/xhci.h" |
33 | int clusterid; | 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, | ||
34 | }; | 67 | }; |
35 | 68 | ||
36 | static const BCM283XInfo bcm283x_socs[] = { | 69 | struct SBSAMachineState { |
37 | { | 70 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry sbsa_ref_memmap[] = { |
38 | .name = TYPE_BCM2836, | 71 | [SBSA_SMMU] = { 0x60050000, 0x00020000 }, |
39 | + .cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"), | 72 | /* Space here reserved for more SMMUs */ |
40 | .clusterid = 0xf, | 73 | [SBSA_AHCI] = { 0x60100000, 0x00010000 }, |
41 | }, | 74 | - [SBSA_EHCI] = { 0x60110000, 0x00010000 }, |
42 | +#ifdef TARGET_AARCH64 | 75 | + [SBSA_XHCI] = { 0x60110000, 0x00010000 }, |
43 | { | 76 | /* Space here reserved for other devices */ |
44 | .name = TYPE_BCM2837, | 77 | [SBSA_PCIE_PIO] = { 0x7fff0000, 0x00010000 }, |
45 | + .cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"), | 78 | /* 32-bit address PCIE MMIO space */ |
46 | .clusterid = 0x0, | 79 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { |
47 | }, | 80 | [SBSA_SECURE_UART] = 8, |
48 | +#endif | 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, | ||
49 | }; | 87 | }; |
50 | 88 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms) | |
51 | static void bcm2836_init(Object *obj) | 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 | } | ||
99 | } | ||
100 | |||
101 | -static void create_ehci(const SBSAMachineState *sms) | ||
102 | +static void create_xhci(const SBSAMachineState *sms) | ||
52 | { | 103 | { |
53 | BCM283XState *s = BCM283X(obj); | 104 | - hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base; |
54 | + BCM283XClass *bc = BCM283X_GET_CLASS(obj); | 105 | - int irq = sbsa_ref_irqmap[SBSA_EHCI]; |
55 | + const BCM283XInfo *info = bc->info; | 106 | + hwaddr base = sbsa_ref_memmap[SBSA_XHCI].base; |
56 | + int n; | 107 | + int irq = sbsa_ref_irqmap[SBSA_XHCI]; |
57 | + | 108 | + DeviceState *dev = qdev_new(TYPE_XHCI_SYSBUS); |
58 | + for (n = 0; n < BCM283X_NCPUS; n++) { | 109 | |
59 | + object_initialize(&s->cpus[n], sizeof(s->cpus[n]), | 110 | - sysbus_create_simple("platform-ehci-usb", base, |
60 | + info->cpu_type); | 111 | - qdev_get_gpio_in(sms->gic, irq)); |
61 | + object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), | 112 | + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
62 | + &error_abort); | 113 | + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); |
63 | + } | 114 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(sms->gic, irq)); |
64 | |||
65 | object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL); | ||
66 | object_property_add_child(obj, "control", OBJECT(&s->control), NULL); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
68 | |||
69 | /* common peripherals from bcm2835 */ | ||
70 | |||
71 | - obj = OBJECT(dev); | ||
72 | - for (n = 0; n < BCM283X_NCPUS; n++) { | ||
73 | - object_initialize(&s->cpus[n], sizeof(s->cpus[n]), | ||
74 | - s->cpu_type); | ||
75 | - object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), | ||
76 | - &error_abort); | ||
77 | - } | ||
78 | - | ||
79 | obj = object_property_get_link(OBJECT(dev), "ram", &err); | ||
80 | if (obj == NULL) { | ||
81 | error_setg(errp, "%s: required ram link not found: %s", | ||
82 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
83 | } | 115 | } |
84 | 116 | ||
85 | static Property bcm2836_props[] = { | 117 | static void create_smmu(const SBSAMachineState *sms, PCIBus *bus) |
86 | - DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type), | 118 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) |
87 | DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, | 119 | |
88 | BCM283X_NCPUS), | 120 | create_ahci(sms); |
89 | DEFINE_PROP_END_OF_LIST() | 121 | |
90 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 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 | ||
91 | index XXXXXXX..XXXXXXX 100644 | 128 | index XXXXXXX..XXXXXXX 100644 |
92 | --- a/hw/arm/raspi.c | 129 | --- a/hw/arm/Kconfig |
93 | +++ b/hw/arm/raspi.c | 130 | +++ b/hw/arm/Kconfig |
94 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | 131 | @@ -XXX,XX +XXX,XX @@ config SBSA_REF |
95 | /* Setup the SOC */ | 132 | select PL011 # UART |
96 | object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), | 133 | select PL031 # RTC |
97 | &error_abort); | 134 | select PL061 # GPIO |
98 | - object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type", | 135 | - select USB_EHCI_SYSBUS |
99 | - &error_abort); | 136 | + select USB_XHCI_SYSBUS |
100 | object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus", | 137 | select WDT_SBSA |
101 | &error_abort); | 138 | select BOCHS_DISPLAY |
102 | int board_rev = version == 3 ? 0xa02082 : 0xa21041; | 139 | |
103 | -- | 140 | -- |
104 | 2.16.2 | 141 | 2.34.1 |
105 | |||
106 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add support for "TX complete"/TXDC interrupt generate by real HW since | 3 | Allow the line length to extend to 548 columns. While annoyingly wide, |
4 | it is needed to support guests other than Linux. | 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. | ||
5 | 6 | ||
6 | Based on the patch by Bill Paul as found here: | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | https://bugs.launchpad.net/qemu/+bug/1753314 | 8 | Message-id: 20230622151201.1578522-2-richard.henderson@linaro.org |
8 | |||
9 | Cc: qemu-devel@nongnu.org | ||
10 | Cc: qemu-arm@nongnu.org | ||
11 | Cc: Bill Paul <wpaul@windriver.com> | ||
12 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Bill Paul <wpaul@windriver.com> | ||
14 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
15 | Message-id: 20180315191141.6789-2-andrew.smirnov@gmail.com | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 11 | --- |
19 | include/hw/char/imx_serial.h | 3 +++ | 12 | target/arm/cpu.c | 36 ++++++++++++++---------------------- |
20 | hw/char/imx_serial.c | 20 +++++++++++++++++--- | 13 | 1 file changed, 14 insertions(+), 22 deletions(-) |
21 | 2 files changed, 20 insertions(+), 3 deletions(-) | ||
22 | 14 | ||
23 | diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h | 15 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
24 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/char/imx_serial.h | 17 | --- a/target/arm/cpu.c |
26 | +++ b/include/hw/char/imx_serial.h | 18 | +++ b/target/arm/cpu.c |
27 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
28 | #define UCR2_RXEN (1<<1) /* Receiver enable */ | 20 | ARMCPU *cpu = ARM_CPU(cs); |
29 | #define UCR2_SRST (1<<0) /* Reset complete */ | 21 | CPUARMState *env = &cpu->env; |
30 | 22 | uint32_t psr = pstate_read(env); | |
31 | +#define UCR4_TCEN BIT(3) /* TX complete interrupt enable */ | 23 | - int i; |
32 | + | 24 | + int i, j; |
33 | #define UTS1_TXEMPTY (1<<6) | 25 | int el = arm_current_el(env); |
34 | #define UTS1_RXEMPTY (1<<5) | 26 | const char *ns_status; |
35 | #define UTS1_TXFULL (1<<4) | 27 | bool sve; |
36 | @@ -XXX,XX +XXX,XX @@ typedef struct IMXSerialState { | 28 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
37 | uint32_t ubmr; | 29 | } |
38 | uint32_t ubrc; | 30 | |
39 | uint32_t ucr3; | 31 | if (sve) { |
40 | + uint32_t ucr4; | 32 | - int j, zcr_len = sve_vqm1_for_el(env, el); |
41 | 33 | + int zcr_len = sve_vqm1_for_el(env, el); | |
42 | qemu_irq irq; | 34 | |
43 | CharBackend chr; | 35 | for (i = 0; i <= FFR_PRED_NUM; i++) { |
44 | diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c | 36 | bool eol; |
45 | index XXXXXXX..XXXXXXX 100644 | 37 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
46 | --- a/hw/char/imx_serial.c | 38 | } |
47 | +++ b/hw/char/imx_serial.c | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | |||
50 | static const VMStateDescription vmstate_imx_serial = { | ||
51 | .name = TYPE_IMX_SERIAL, | ||
52 | - .version_id = 1, | ||
53 | - .minimum_version_id = 1, | ||
54 | + .version_id = 2, | ||
55 | + .minimum_version_id = 2, | ||
56 | .fields = (VMStateField[]) { | ||
57 | VMSTATE_INT32(readbuff, IMXSerialState), | ||
58 | VMSTATE_UINT32(usr1, IMXSerialState), | ||
59 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = { | ||
60 | VMSTATE_UINT32(ubmr, IMXSerialState), | ||
61 | VMSTATE_UINT32(ubrc, IMXSerialState), | ||
62 | VMSTATE_UINT32(ucr3, IMXSerialState), | ||
63 | + VMSTATE_UINT32(ucr4, IMXSerialState), | ||
64 | VMSTATE_END_OF_LIST() | ||
65 | }, | ||
66 | }; | ||
67 | @@ -XXX,XX +XXX,XX @@ static void imx_update(IMXSerialState *s) | ||
68 | * unfortunately. | ||
69 | */ | ||
70 | mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0; | ||
71 | + /* | ||
72 | + * TCEN and TXDC are both bit 3 | ||
73 | + */ | ||
74 | + mask |= s->ucr4 & UCR4_TCEN; | ||
75 | + | ||
76 | usr2 = s->usr2 & mask; | ||
77 | |||
78 | qemu_set_irq(s->irq, usr1 || usr2); | ||
79 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset, | ||
80 | return s->ucr3; | ||
81 | |||
82 | case 0x23: /* UCR4 */ | ||
83 | + return s->ucr4; | ||
84 | + | ||
85 | case 0x29: /* BRM Incremental */ | ||
86 | return 0x0; /* TODO */ | ||
87 | |||
88 | @@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset, | ||
89 | * qemu_chr_fe_write and background I/O callbacks */ | ||
90 | qemu_chr_fe_write_all(&s->chr, &ch, 1); | ||
91 | s->usr1 &= ~USR1_TRDY; | ||
92 | + s->usr2 &= ~USR2_TXDC; | ||
93 | imx_update(s); | ||
94 | s->usr1 |= USR1_TRDY; | ||
95 | + s->usr2 |= USR2_TXDC; | ||
96 | imx_update(s); | ||
97 | } | 39 | } |
98 | break; | 40 | |
99 | @@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset, | 41 | - for (i = 0; i < 32; i++) { |
100 | s->ucr3 = value & 0xffff; | 42 | - if (zcr_len == 0) { |
101 | break; | 43 | + if (zcr_len == 0) { |
102 | 44 | + /* | |
103 | - case 0x2d: /* UTS1 */ | 45 | + * With vl=16, there are only 37 columns per register, |
104 | case 0x23: /* UCR4 */ | 46 | + * so output two registers per line. |
105 | + s->ucr4 = value & 0xffff; | 47 | + */ |
106 | + imx_update(s); | 48 | + for (i = 0; i < 32; i++) { |
107 | + break; | 49 | qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s", |
108 | + | 50 | i, env->vfp.zregs[i].d[1], |
109 | + case 0x2d: /* UTS1 */ | 51 | env->vfp.zregs[i].d[0], i & 1 ? "\n" : " "); |
110 | qemu_log_mask(LOG_UNIMP, "[%s]%s: Unimplemented reg 0x%" | 52 | - } else if (zcr_len == 1) { |
111 | HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset); | 53 | - qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 |
112 | /* TODO */ | 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 | } | ||
113 | -- | 82 | -- |
114 | 2.16.2 | 83 | 2.34.1 |
115 | |||
116 | diff view generated by jsdifflib |
1 | The bcm2837 is pretty similar to the bcm2836, but it does have | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | some differences. Notably, the MPIDR affinity aff1 values it | ||
3 | sets for the CPUs are 0x0, rather than the 0xf that the bcm2836 | ||
4 | uses, and if this is wrong Linux will not boot. | ||
5 | 2 | ||
6 | Rather than trying to have one device with properties that | 3 | Always print each matrix row whole, one per line, so that we |
7 | configure it differently for the two cases, create two | 4 | get the entire matrix in the proper shape. |
8 | separate QOM devices for the two SoCs. We use the same approach | ||
9 | as hw/arm/aspeed_soc.c and share code and have a data table | ||
10 | that might differ per-SoC. For the moment the two types don't | ||
11 | actually have different behaviour. | ||
12 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20230622151201.1578522-3-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 20180313153458.26822-7-peter.maydell@linaro.org | ||
16 | --- | 10 | --- |
17 | include/hw/arm/bcm2836.h | 19 +++++++++++++++++++ | 11 | target/arm/cpu.c | 18 ++++++++++++++++++ |
18 | hw/arm/bcm2836.c | 37 ++++++++++++++++++++++++++++++++----- | 12 | 1 file changed, 18 insertions(+) |
19 | hw/arm/raspi.c | 3 ++- | ||
20 | 3 files changed, 53 insertions(+), 6 deletions(-) | ||
21 | 13 | ||
22 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h | 14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
23 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/include/hw/arm/bcm2836.h | 16 | --- a/target/arm/cpu.c |
25 | +++ b/include/hw/arm/bcm2836.h | 17 | +++ b/target/arm/cpu.c |
26 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
27 | 19 | i, q[1], q[0], (i & 1 ? "\n" : " ")); | |
28 | #define BCM283X_NCPUS 4 | 20 | } |
29 | 21 | } | |
30 | +/* These type names are for specific SoCs; other than instantiating | ||
31 | + * them, code using these devices should always handle them via the | ||
32 | + * BCM283x base class, so they have no BCM2836(obj) etc macros. | ||
33 | + */ | ||
34 | +#define TYPE_BCM2836 "bcm2836" | ||
35 | +#define TYPE_BCM2837 "bcm2837" | ||
36 | + | 22 | + |
37 | typedef struct BCM283XState { | 23 | + if (cpu_isar_feature(aa64_sme, cpu) && |
38 | /*< private >*/ | 24 | + FIELD_EX64(env->svcr, SVCR, ZA) && |
39 | DeviceState parent_obj; | 25 | + sme_exception_el(env, el) == 0) { |
40 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM283XState { | 26 | + int zcr_len = sve_vqm1_for_el_sm(env, el, true); |
41 | BCM2835PeripheralState peripherals; | 27 | + int svl = (zcr_len + 1) * 16; |
42 | } BCM283XState; | 28 | + int svl_lg10 = svl < 100 ? 2 : 3; |
43 | |||
44 | +typedef struct BCM283XInfo BCM283XInfo; | ||
45 | + | 29 | + |
46 | +typedef struct BCM283XClass { | 30 | + for (i = 0; i < svl; i++) { |
47 | + DeviceClass parent_class; | 31 | + qemu_fprintf(f, "ZA[%0*d]=", svl_lg10, i); |
48 | + const BCM283XInfo *info; | 32 | + for (j = zcr_len; j >= 0; --j) { |
49 | +} BCM283XClass; | 33 | + qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%c", |
50 | + | 34 | + env->zarray[i].d[2 * j + 1], |
51 | +#define BCM283X_CLASS(klass) \ | 35 | + env->zarray[i].d[2 * j], |
52 | + OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X) | 36 | + j ? ':' : '\n'); |
53 | +#define BCM283X_GET_CLASS(obj) \ | 37 | + } |
54 | + OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X) | 38 | + } |
55 | + | ||
56 | #endif /* BCM2836_H */ | ||
57 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/arm/bcm2836.c | ||
60 | +++ b/hw/arm/bcm2836.c | ||
61 | @@ -XXX,XX +XXX,XX @@ | ||
62 | /* "QA7" (Pi2) interrupt controller and mailboxes etc. */ | ||
63 | #define BCM2836_CONTROL_BASE 0x40000000 | ||
64 | |||
65 | +struct BCM283XInfo { | ||
66 | + const char *name; | ||
67 | +}; | ||
68 | + | ||
69 | +static const BCM283XInfo bcm283x_socs[] = { | ||
70 | + { | ||
71 | + .name = TYPE_BCM2836, | ||
72 | + }, | ||
73 | + { | ||
74 | + .name = TYPE_BCM2837, | ||
75 | + }, | ||
76 | +}; | ||
77 | + | ||
78 | static void bcm2836_init(Object *obj) | ||
79 | { | ||
80 | BCM283XState *s = BCM283X(obj); | ||
81 | @@ -XXX,XX +XXX,XX @@ static Property bcm2836_props[] = { | ||
82 | DEFINE_PROP_END_OF_LIST() | ||
83 | }; | ||
84 | |||
85 | -static void bcm2836_class_init(ObjectClass *oc, void *data) | ||
86 | +static void bcm283x_class_init(ObjectClass *oc, void *data) | ||
87 | { | ||
88 | DeviceClass *dc = DEVICE_CLASS(oc); | ||
89 | + BCM283XClass *bc = BCM283X_CLASS(oc); | ||
90 | |||
91 | - dc->props = bcm2836_props; | ||
92 | + bc->info = data; | ||
93 | dc->realize = bcm2836_realize; | ||
94 | + dc->props = bcm2836_props; | ||
95 | } | ||
96 | |||
97 | -static const TypeInfo bcm2836_type_info = { | ||
98 | +static const TypeInfo bcm283x_type_info = { | ||
99 | .name = TYPE_BCM283X, | ||
100 | .parent = TYPE_DEVICE, | ||
101 | .instance_size = sizeof(BCM283XState), | ||
102 | .instance_init = bcm2836_init, | ||
103 | - .class_init = bcm2836_class_init, | ||
104 | + .class_size = sizeof(BCM283XClass), | ||
105 | + .abstract = true, | ||
106 | }; | ||
107 | |||
108 | static void bcm2836_register_types(void) | ||
109 | { | ||
110 | - type_register_static(&bcm2836_type_info); | ||
111 | + int i; | ||
112 | + | ||
113 | + type_register_static(&bcm283x_type_info); | ||
114 | + for (i = 0; i < ARRAY_SIZE(bcm283x_socs); i++) { | ||
115 | + TypeInfo ti = { | ||
116 | + .name = bcm283x_socs[i].name, | ||
117 | + .parent = TYPE_BCM283X, | ||
118 | + .class_init = bcm283x_class_init, | ||
119 | + .class_data = (void *) &bcm283x_socs[i], | ||
120 | + }; | ||
121 | + type_register(&ti); | ||
122 | + } | 39 | + } |
123 | } | 40 | } |
124 | 41 | ||
125 | type_init(bcm2836_register_types) | 42 | #else |
126 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | ||
127 | index XXXXXXX..XXXXXXX 100644 | ||
128 | --- a/hw/arm/raspi.c | ||
129 | +++ b/hw/arm/raspi.c | ||
130 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | ||
131 | BusState *bus; | ||
132 | DeviceState *carddev; | ||
133 | |||
134 | - object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X); | ||
135 | + object_initialize(&s->soc, sizeof(s->soc), | ||
136 | + version == 3 ? TYPE_BCM2837 : TYPE_BCM2836); | ||
137 | object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), | ||
138 | &error_abort); | ||
139 | |||
140 | -- | 43 | -- |
141 | 2.16.2 | 44 | 2.34.1 |
142 | |||
143 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Code of imx_update() is slightly confusing since the "flags" variable | 3 | For the outer product set of insns, which take an entire matrix |
4 | doesn't really corespond to anything in real hardware and server as a | 4 | tile as output, the argument is not a combined tile+column. |
5 | kitchensink accumulating events normally reported via USR1 and USR2 | 5 | Therefore using get_tile_rowcol was incorrect, as we extracted |
6 | registers. | 6 | the tile number from itself. |
7 | 7 | ||
8 | Change the code to explicitly evaluate state of interrupts reported | 8 | The test case relies only on assembler support for SME, since |
9 | via USR1 and USR2 against corresponding masking bits and use the to | 9 | no release of GCC recognizes -march=armv9-a+sme yet. |
10 | detemine if IRQ line should be asserted or not. | 10 | |
11 | 11 | Cc: qemu-stable@nongnu.org | |
12 | NOTE: Check for UTS1_TXEMPTY being set has been dropped for two | 12 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1620 |
13 | reasons: | 13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
14 | 14 | Message-id: 20230622151201.1578522-5-richard.henderson@linaro.org | |
15 | 1. Emulation code implements a single character FIFO, so this flag | ||
16 | will always be set since characters are trasmitted as a part of | ||
17 | the code emulating "push" into the FIFO | ||
18 | |||
19 | 2. imx_update() is really just a function doing ORing and maksing | ||
20 | of reported events, so checking for UTS1_TXEMPTY should happen, | ||
21 | if it's ever really needed should probably happen outside of | ||
22 | it. | ||
23 | |||
24 | Cc: qemu-devel@nongnu.org | ||
25 | Cc: qemu-arm@nongnu.org | ||
26 | Cc: Bill Paul <wpaul@windriver.com> | ||
27 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
28 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
29 | Message-id: 20180315191141.6789-1-andrew.smirnov@gmail.com | ||
30 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
32 | --- | 17 | --- |
33 | hw/char/imx_serial.c | 24 ++++++++++++++++-------- | 18 | target/arm/tcg/translate-sme.c | 24 ++++++--- |
34 | 1 file changed, 16 insertions(+), 8 deletions(-) | 19 | tests/tcg/aarch64/sme-outprod1.c | 83 +++++++++++++++++++++++++++++++ |
35 | 20 | tests/tcg/aarch64/Makefile.target | 10 ++-- | |
36 | diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c | 21 | 3 files changed, 108 insertions(+), 9 deletions(-) |
22 | create mode 100644 tests/tcg/aarch64/sme-outprod1.c | ||
23 | |||
24 | diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/char/imx_serial.c | 26 | --- a/target/arm/tcg/translate-sme.c |
39 | +++ b/hw/char/imx_serial.c | 27 | +++ b/target/arm/tcg/translate-sme.c |
40 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = { | 28 | @@ -XXX,XX +XXX,XX @@ static TCGv_ptr get_tile_rowcol(DisasContext *s, int esz, int rs, |
41 | 29 | return addr; | |
42 | static void imx_update(IMXSerialState *s) | 30 | } |
31 | |||
32 | +/* | ||
33 | + * Resolve tile.size[0] to a host pointer. | ||
34 | + * Used by e.g. outer product insns where we require the entire tile. | ||
35 | + */ | ||
36 | +static TCGv_ptr get_tile(DisasContext *s, int esz, int tile) | ||
37 | +{ | ||
38 | + TCGv_ptr addr = tcg_temp_new_ptr(); | ||
39 | + int offset; | ||
40 | + | ||
41 | + offset = tile * sizeof(ARMVectorReg) + offsetof(CPUARMState, zarray); | ||
42 | + | ||
43 | + tcg_gen_addi_ptr(addr, cpu_env, offset); | ||
44 | + return addr; | ||
45 | +} | ||
46 | + | ||
47 | static bool trans_ZERO(DisasContext *s, arg_ZERO *a) | ||
43 | { | 48 | { |
44 | - uint32_t flags; | 49 | if (!dc_isar_feature(aa64_sme, s)) { |
45 | + uint32_t usr1; | 50 | @@ -XXX,XX +XXX,XX @@ static bool do_adda(DisasContext *s, arg_adda *a, MemOp esz, |
46 | + uint32_t usr2; | 51 | return true; |
47 | + uint32_t mask; | 52 | } |
48 | 53 | ||
49 | - flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY); | 54 | - /* Sum XZR+zad to find ZAd. */ |
50 | - if (s->ucr1 & UCR1_TXMPTYEN) { | 55 | - za = get_tile_rowcol(s, esz, 31, a->zad, false); |
51 | - flags |= (s->uts1 & UTS1_TXEMPTY); | 56 | + za = get_tile(s, esz, a->zad); |
52 | - } else { | 57 | zn = vec_full_reg_ptr(s, a->zn); |
53 | - flags &= ~USR1_TRDY; | 58 | pn = pred_full_reg_ptr(s, a->pn); |
54 | - } | 59 | pm = pred_full_reg_ptr(s, a->pm); |
55 | + /* | 60 | @@ -XXX,XX +XXX,XX @@ static bool do_outprod(DisasContext *s, arg_op *a, MemOp esz, |
56 | + * Lucky for us TRDY and RRDY has the same offset in both USR1 and | 61 | return true; |
57 | + * UCR1, so we can get away with something as simple as the | 62 | } |
58 | + * following: | 63 | |
59 | + */ | 64 | - /* Sum XZR+zad to find ZAd. */ |
60 | + usr1 = s->usr1 & s->ucr1 & (USR1_TRDY | USR1_RRDY); | 65 | - za = get_tile_rowcol(s, esz, 31, a->zad, false); |
61 | + /* | 66 | + za = get_tile(s, esz, a->zad); |
62 | + * Bits that we want in USR2 are not as conveniently laid out, | 67 | zn = vec_full_reg_ptr(s, a->zn); |
63 | + * unfortunately. | 68 | zm = vec_full_reg_ptr(s, a->zm); |
64 | + */ | 69 | pn = pred_full_reg_ptr(s, a->pn); |
65 | + mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0; | 70 | @@ -XXX,XX +XXX,XX @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz, |
66 | + usr2 = s->usr2 & mask; | 71 | return true; |
67 | 72 | } | |
68 | - qemu_set_irq(s->irq, !!flags); | 73 | |
69 | + qemu_set_irq(s->irq, usr1 || usr2); | 74 | - /* Sum XZR+zad to find ZAd. */ |
70 | } | 75 | - za = get_tile_rowcol(s, esz, 31, a->zad, false); |
71 | 76 | + za = get_tile(s, esz, a->zad); | |
72 | static void imx_serial_reset(IMXSerialState *s) | 77 | zn = vec_full_reg_ptr(s, a->zn); |
78 | zm = vec_full_reg_ptr(s, a->zm); | ||
79 | pn = pred_full_reg_ptr(s, a->pn); | ||
80 | diff --git a/tests/tcg/aarch64/sme-outprod1.c b/tests/tcg/aarch64/sme-outprod1.c | ||
81 | new file mode 100644 | ||
82 | index XXXXXXX..XXXXXXX | ||
83 | --- /dev/null | ||
84 | +++ b/tests/tcg/aarch64/sme-outprod1.c | ||
85 | @@ -XXX,XX +XXX,XX @@ | ||
86 | +/* | ||
87 | + * SME outer product, 1 x 1. | ||
88 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
89 | + */ | ||
90 | + | ||
91 | +#include <stdio.h> | ||
92 | + | ||
93 | +extern void foo(float *dst); | ||
94 | + | ||
95 | +asm( | ||
96 | +" .arch_extension sme\n" | ||
97 | +" .type foo, @function\n" | ||
98 | +"foo:\n" | ||
99 | +" stp x29, x30, [sp, -80]!\n" | ||
100 | +" mov x29, sp\n" | ||
101 | +" stp d8, d9, [sp, 16]\n" | ||
102 | +" stp d10, d11, [sp, 32]\n" | ||
103 | +" stp d12, d13, [sp, 48]\n" | ||
104 | +" stp d14, d15, [sp, 64]\n" | ||
105 | +" smstart\n" | ||
106 | +" ptrue p0.s, vl4\n" | ||
107 | +" fmov z0.s, #1.0\n" | ||
108 | +/* | ||
109 | + * An outer product of a vector of 1.0 by itself should be a matrix of 1.0. | ||
110 | + * Note that we are using tile 1 here (za1.s) rather than tile 0. | ||
111 | + */ | ||
112 | +" zero {za}\n" | ||
113 | +" fmopa za1.s, p0/m, p0/m, z0.s, z0.s\n" | ||
114 | +/* | ||
115 | + * Read the first 4x4 sub-matrix of elements from tile 1: | ||
116 | + * Note that za1h should be interchangable here. | ||
117 | + */ | ||
118 | +" mov w12, #0\n" | ||
119 | +" mova z0.s, p0/m, za1v.s[w12, #0]\n" | ||
120 | +" mova z1.s, p0/m, za1v.s[w12, #1]\n" | ||
121 | +" mova z2.s, p0/m, za1v.s[w12, #2]\n" | ||
122 | +" mova z3.s, p0/m, za1v.s[w12, #3]\n" | ||
123 | +/* | ||
124 | + * And store them to the input pointer (dst in the C code): | ||
125 | + */ | ||
126 | +" st1w {z0.s}, p0, [x0]\n" | ||
127 | +" add x0, x0, #16\n" | ||
128 | +" st1w {z1.s}, p0, [x0]\n" | ||
129 | +" add x0, x0, #16\n" | ||
130 | +" st1w {z2.s}, p0, [x0]\n" | ||
131 | +" add x0, x0, #16\n" | ||
132 | +" st1w {z3.s}, p0, [x0]\n" | ||
133 | +" smstop\n" | ||
134 | +" ldp d8, d9, [sp, 16]\n" | ||
135 | +" ldp d10, d11, [sp, 32]\n" | ||
136 | +" ldp d12, d13, [sp, 48]\n" | ||
137 | +" ldp d14, d15, [sp, 64]\n" | ||
138 | +" ldp x29, x30, [sp], 80\n" | ||
139 | +" ret\n" | ||
140 | +" .size foo, . - foo" | ||
141 | +); | ||
142 | + | ||
143 | +int main() | ||
144 | +{ | ||
145 | + float dst[16]; | ||
146 | + int i, j; | ||
147 | + | ||
148 | + foo(dst); | ||
149 | + | ||
150 | + for (i = 0; i < 16; i++) { | ||
151 | + if (dst[i] != 1.0f) { | ||
152 | + break; | ||
153 | + } | ||
154 | + } | ||
155 | + | ||
156 | + if (i == 16) { | ||
157 | + return 0; /* success */ | ||
158 | + } | ||
159 | + | ||
160 | + /* failure */ | ||
161 | + for (i = 0; i < 4; ++i) { | ||
162 | + for (j = 0; j < 4; ++j) { | ||
163 | + printf("%f ", (double)dst[i * 4 + j]); | ||
164 | + } | ||
165 | + printf("\n"); | ||
166 | + } | ||
167 | + return 1; | ||
168 | +} | ||
169 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
170 | index XXXXXXX..XXXXXXX 100644 | ||
171 | --- a/tests/tcg/aarch64/Makefile.target | ||
172 | +++ b/tests/tcg/aarch64/Makefile.target | ||
173 | @@ -XXX,XX +XXX,XX @@ config-cc.mak: Makefile | ||
174 | $(call cc-option,-march=armv8.5-a, CROSS_CC_HAS_ARMV8_5); \ | ||
175 | $(call cc-option,-mbranch-protection=standard, CROSS_CC_HAS_ARMV8_BTI); \ | ||
176 | $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE); \ | ||
177 | - $(call cc-option,-march=armv9-a+sme, CROSS_CC_HAS_ARMV9_SME)) 3> config-cc.mak | ||
178 | + $(call cc-option,-Wa$(COMMA)-march=armv9-a+sme, CROSS_AS_HAS_ARMV9_SME)) 3> config-cc.mak | ||
179 | -include config-cc.mak | ||
180 | |||
181 | ifneq ($(CROSS_CC_HAS_ARMV8_2),) | ||
182 | @@ -XXX,XX +XXX,XX @@ AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-5 mte-6 mte-7 | ||
183 | mte-%: CFLAGS += -march=armv8.5-a+memtag | ||
184 | endif | ||
185 | |||
186 | +ifneq ($(CROSS_AS_HAS_ARMV9_SME),) | ||
187 | +AARCH64_TESTS += sme-outprod1 | ||
188 | +endif | ||
189 | + | ||
190 | ifneq ($(CROSS_CC_HAS_SVE),) | ||
191 | # System Registers Tests | ||
192 | AARCH64_TESTS += sysregs | ||
193 | -ifneq ($(CROSS_CC_HAS_ARMV9_SME),) | ||
194 | -sysregs: CFLAGS+=-march=armv9-a+sme -DHAS_ARMV9_SME | ||
195 | +ifneq ($(CROSS_AS_HAS_ARMV9_SME),) | ||
196 | +sysregs: CFLAGS+=-Wa,-march=armv9-a+sme -DHAS_ARMV9_SME | ||
197 | else | ||
198 | sysregs: CFLAGS+=-march=armv8.1-a+sve | ||
199 | endif | ||
73 | -- | 200 | -- |
74 | 2.16.2 | 201 | 2.34.1 |
75 | |||
76 | diff view generated by jsdifflib |
1 | Our BCM2836 type is really a generic one that can be any of | 1 | From: John Högberg <john.hogberg@ericsson.com> |
---|---|---|---|
2 | the bcm283x family. Rename it accordingly. We change only | ||
3 | the names which are visible via the header file to the | ||
4 | rest of the QEMU code, leaving private function names | ||
5 | in bcm2836.c as they are. | ||
6 | 2 | ||
7 | This is a preliminary to making bcm283x be an abstract | 3 | Unlike architectures with precise self-modifying code semantics |
8 | parent class to specific types for the bcm2836 and bcm2837. | 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. | ||
9 | 8 | ||
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> | ||
30 | Reviewed-by: Richard Henderson <richard.henderson@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] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 35 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20180313153458.26822-6-peter.maydell@linaro.org | ||
14 | --- | 36 | --- |
15 | include/hw/arm/bcm2836.h | 12 ++++++------ | 37 | target/arm/cpu.c | 11 +++++++++++ |
16 | hw/arm/bcm2836.c | 17 +++++++++-------- | 38 | target/arm/helper.c | 47 ++++++++++++++++++++++++++++++++++++++++++--- |
17 | hw/arm/raspi.c | 16 ++++++++-------- | 39 | 2 files changed, 55 insertions(+), 3 deletions(-) |
18 | 3 files changed, 23 insertions(+), 22 deletions(-) | ||
19 | 40 | ||
20 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h | 41 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
21 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/arm/bcm2836.h | 43 | --- a/target/arm/cpu.c |
23 | +++ b/include/hw/arm/bcm2836.h | 44 | +++ b/target/arm/cpu.c |
24 | @@ -XXX,XX +XXX,XX @@ | 45 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
25 | #include "hw/arm/bcm2835_peripherals.h" | 46 | return; |
26 | #include "hw/intc/bcm2836_control.h" | 47 | } |
27 | 48 | ||
28 | -#define TYPE_BCM2836 "bcm2836" | 49 | +#ifdef CONFIG_USER_ONLY |
29 | -#define BCM2836(obj) OBJECT_CHECK(BCM2836State, (obj), TYPE_BCM2836) | 50 | + /* |
30 | +#define TYPE_BCM283X "bcm283x" | 51 | + * User mode relies on IC IVAU instructions to catch modification of |
31 | +#define BCM283X(obj) OBJECT_CHECK(BCM283XState, (obj), TYPE_BCM283X) | 52 | + * dual-mapped code. |
32 | 53 | + * | |
33 | -#define BCM2836_NCPUS 4 | 54 | + * Clear CTR_EL0.DIC to ensure that software that honors these flags uses |
34 | +#define BCM283X_NCPUS 4 | 55 | + * IC IVAU even if the emulated processor does not normally require it. |
35 | 56 | + */ | |
36 | -typedef struct BCM2836State { | 57 | + cpu->ctr = FIELD_DP64(cpu->ctr, CTR_EL0, DIC, 0); |
37 | +typedef struct BCM283XState { | 58 | +#endif |
38 | /*< private >*/ | 59 | + |
39 | DeviceState parent_obj; | 60 | if (arm_feature(env, ARM_FEATURE_AARCH64) && |
40 | /*< public >*/ | 61 | cpu->has_vfp != cpu->has_neon) { |
41 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2836State { | 62 | /* |
42 | char *cpu_type; | 63 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
43 | uint32_t enabled_cpus; | ||
44 | |||
45 | - ARMCPU cpus[BCM2836_NCPUS]; | ||
46 | + ARMCPU cpus[BCM283X_NCPUS]; | ||
47 | BCM2836ControlState control; | ||
48 | BCM2835PeripheralState peripherals; | ||
49 | -} BCM2836State; | ||
50 | +} BCM283XState; | ||
51 | |||
52 | #endif /* BCM2836_H */ | ||
53 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | 64 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/hw/arm/bcm2836.c | 65 | --- a/target/arm/helper.c |
56 | +++ b/hw/arm/bcm2836.c | 66 | +++ b/target/arm/helper.c |
57 | @@ -XXX,XX +XXX,XX @@ | 67 | @@ -XXX,XX +XXX,XX @@ static void mdcr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, |
58 | 68 | } | |
59 | static void bcm2836_init(Object *obj) | ||
60 | { | ||
61 | - BCM2836State *s = BCM2836(obj); | ||
62 | + BCM283XState *s = BCM283X(obj); | ||
63 | |||
64 | object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL); | ||
65 | object_property_add_child(obj, "control", OBJECT(&s->control), NULL); | ||
66 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj) | ||
67 | |||
68 | static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
69 | { | ||
70 | - BCM2836State *s = BCM2836(dev); | ||
71 | + BCM283XState *s = BCM283X(dev); | ||
72 | Object *obj; | ||
73 | Error *err = NULL; | ||
74 | int n; | ||
75 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
76 | /* common peripherals from bcm2835 */ | ||
77 | |||
78 | obj = OBJECT(dev); | ||
79 | - for (n = 0; n < BCM2836_NCPUS; n++) { | ||
80 | + for (n = 0; n < BCM283X_NCPUS; n++) { | ||
81 | object_initialize(&s->cpus[n], sizeof(s->cpus[n]), | ||
82 | s->cpu_type); | ||
83 | object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), | ||
84 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
85 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1, | ||
86 | qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); | ||
87 | |||
88 | - for (n = 0; n < BCM2836_NCPUS; n++) { | ||
89 | + for (n = 0; n < BCM283X_NCPUS; n++) { | ||
90 | /* Mirror bcm2836, which has clusterid set to 0xf | ||
91 | * TODO: this should be converted to a property of ARM_CPU | ||
92 | */ | ||
93 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
94 | } | 69 | } |
95 | 70 | ||
96 | static Property bcm2836_props[] = { | 71 | +#ifdef CONFIG_USER_ONLY |
97 | - DEFINE_PROP_STRING("cpu-type", BCM2836State, cpu_type), | 72 | +/* |
98 | - DEFINE_PROP_UINT32("enabled-cpus", BCM2836State, enabled_cpus, BCM2836_NCPUS), | 73 | + * `IC IVAU` is handled to improve compatibility with JITs that dual-map their |
99 | + DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type), | 74 | + * code to get around W^X restrictions, where one region is writable and the |
100 | + DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, | 75 | + * other is executable. |
101 | + BCM283X_NCPUS), | 76 | + * |
102 | DEFINE_PROP_END_OF_LIST() | 77 | + * Since the executable region is never written to we cannot detect code |
103 | }; | 78 | + * changes when running in user mode, and rely on the emulated JIT telling us |
104 | 79 | + * that the code has changed by executing this instruction. | |
105 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data) | 80 | + */ |
106 | } | 81 | +static void ic_ivau_write(CPUARMState *env, const ARMCPRegInfo *ri, |
107 | 82 | + uint64_t value) | |
108 | static const TypeInfo bcm2836_type_info = { | 83 | +{ |
109 | - .name = TYPE_BCM2836, | 84 | + uint64_t icache_line_mask, start_address, end_address; |
110 | + .name = TYPE_BCM283X, | 85 | + const ARMCPU *cpu; |
111 | .parent = TYPE_DEVICE, | 86 | + |
112 | - .instance_size = sizeof(BCM2836State), | 87 | + cpu = env_archcpu(env); |
113 | + .instance_size = sizeof(BCM283XState), | 88 | + |
114 | .instance_init = bcm2836_init, | 89 | + icache_line_mask = (4 << extract32(cpu->ctr, 0, 4)) - 1; |
115 | .class_init = bcm2836_class_init, | 90 | + start_address = value & ~icache_line_mask; |
116 | }; | 91 | + end_address = value | icache_line_mask; |
117 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 92 | + |
118 | index XXXXXXX..XXXXXXX 100644 | 93 | + mmap_lock(); |
119 | --- a/hw/arm/raspi.c | 94 | + |
120 | +++ b/hw/arm/raspi.c | 95 | + tb_invalidate_phys_range(start_address, end_address); |
121 | @@ -XXX,XX +XXX,XX @@ | 96 | + |
122 | static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44}; | 97 | + mmap_unlock(); |
123 | 98 | +} | |
124 | typedef struct RasPiState { | 99 | +#endif |
125 | - BCM2836State soc; | 100 | + |
126 | + BCM283XState soc; | 101 | static const ARMCPRegInfo v8_cp_reginfo[] = { |
127 | MemoryRegion ram; | 102 | /* |
128 | } RasPiState; | 103 | * Minimal set of EL0-visible registers. This will need to be expanded |
129 | 104 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | |
130 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | 105 | { .name = "CURRENTEL", .state = ARM_CP_STATE_AA64, |
131 | BusState *bus; | 106 | .opc0 = 3, .opc1 = 0, .opc2 = 2, .crn = 4, .crm = 2, |
132 | DeviceState *carddev; | 107 | .access = PL1_R, .type = ARM_CP_CURRENTEL }, |
133 | 108 | - /* Cache ops: all NOPs since we don't emulate caches */ | |
134 | - object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM2836); | 109 | + /* |
135 | + object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X); | 110 | + * Instruction cache ops. All of these except `IC IVAU` NOP because we |
136 | object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), | 111 | + * don't emulate caches. |
137 | &error_abort); | 112 | + */ |
138 | 113 | { .name = "IC_IALLUIS", .state = ARM_CP_STATE_AA64, | |
139 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc) | 114 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0, |
140 | mc->no_floppy = 1; | 115 | .access = PL1_W, .type = ARM_CP_NOP, |
141 | mc->no_cdrom = 1; | 116 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { |
142 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); | 117 | .accessfn = access_tocu }, |
143 | - mc->max_cpus = BCM2836_NCPUS; | 118 | { .name = "IC_IVAU", .state = ARM_CP_STATE_AA64, |
144 | - mc->min_cpus = BCM2836_NCPUS; | 119 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 5, .opc2 = 1, |
145 | - mc->default_cpus = BCM2836_NCPUS; | 120 | - .access = PL0_W, .type = ARM_CP_NOP, |
146 | + mc->max_cpus = BCM283X_NCPUS; | 121 | + .access = PL0_W, |
147 | + mc->min_cpus = BCM283X_NCPUS; | 122 | .fgt = FGT_ICIVAU, |
148 | + mc->default_cpus = BCM283X_NCPUS; | 123 | - .accessfn = access_tocu }, |
149 | mc->default_ram_size = 1024 * 1024 * 1024; | 124 | + .accessfn = access_tocu, |
150 | mc->ignore_memory_transaction_failures = true; | 125 | +#ifdef CONFIG_USER_ONLY |
151 | }; | 126 | + .type = ARM_CP_NO_RAW, |
152 | @@ -XXX,XX +XXX,XX @@ static void raspi3_machine_init(MachineClass *mc) | 127 | + .writefn = ic_ivau_write |
153 | mc->no_floppy = 1; | 128 | +#else |
154 | mc->no_cdrom = 1; | 129 | + .type = ARM_CP_NOP |
155 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"); | 130 | +#endif |
156 | - mc->max_cpus = BCM2836_NCPUS; | 131 | + }, |
157 | - mc->min_cpus = BCM2836_NCPUS; | 132 | + /* Cache ops: all NOPs since we don't emulate caches */ |
158 | - mc->default_cpus = BCM2836_NCPUS; | 133 | { .name = "DC_IVAC", .state = ARM_CP_STATE_AA64, |
159 | + mc->max_cpus = BCM283X_NCPUS; | 134 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, |
160 | + mc->min_cpus = BCM283X_NCPUS; | 135 | .access = PL1_W, .accessfn = aa64_cacheop_poc_access, |
161 | + mc->default_cpus = BCM283X_NCPUS; | ||
162 | mc->default_ram_size = 1024 * 1024 * 1024; | ||
163 | } | ||
164 | DEFINE_MACHINE("raspi3", raspi3_machine_init) | ||
165 | -- | 136 | -- |
166 | 2.16.2 | 137 | 2.34.1 |
167 | 138 | ||
168 | 139 | diff view generated by jsdifflib |
1 | From: Wei Huang <wei@redhat.com> | 1 | From: John Högberg <john.hogberg@ericsson.com> |
---|---|---|---|
2 | 2 | ||
3 | For guest kernel that supports KASLR, the load address can change every | 3 | https://gitlab.com/qemu-project/qemu/-/issues/1034 |
4 | time when guest VM runs. To find the physical base address correctly, | 4 | |
5 | current QEMU dump searches VMCOREINFO for the string "NUMBER(phys_base)=". | 5 | Signed-off-by: John Högberg <john.hogberg@ericsson.com> |
6 | However this string pattern is only available on x86_64. AArch64 uses a | 6 | Message-id: 168778890374.24232.3402138851538068785-2@git.sr.ht |
7 | different field, called "NUMBER(PHYS_OFFSET)=". This patch makes sure | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | QEMU dump uses the correct string on AArch64. | 8 | [PMM: fixed typo in comment] |
9 | |||
10 | Signed-off-by: Wei Huang <wei@redhat.com> | ||
11 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
12 | Message-id: 1520615003-20869-1-git-send-email-wei@redhat.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 10 | --- |
15 | dump.c | 14 +++++++++++--- | 11 | tests/tcg/aarch64/icivau.c | 189 ++++++++++++++++++++++++++++++ |
16 | 1 file changed, 11 insertions(+), 3 deletions(-) | 12 | tests/tcg/aarch64/Makefile.target | 3 +- |
17 | 13 | 2 files changed, 191 insertions(+), 1 deletion(-) | |
18 | diff --git a/dump.c b/dump.c | 14 | create mode 100644 tests/tcg/aarch64/icivau.c |
15 | |||
16 | diff --git a/tests/tcg/aarch64/icivau.c b/tests/tcg/aarch64/icivau.c | ||
17 | new file mode 100644 | ||
18 | index XXXXXXX..XXXXXXX | ||
19 | --- /dev/null | ||
20 | +++ b/tests/tcg/aarch64/icivau.c | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | +/* | ||
23 | + * Tests the IC IVAU-driven workaround for catching changes made to dual-mapped | ||
24 | + * code that would otherwise go unnoticed in user mode. | ||
25 | + * | ||
26 | + * Copyright (c) 2023 Ericsson AB | ||
27 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
28 | + */ | ||
29 | + | ||
30 | +#include <sys/mman.h> | ||
31 | +#include <sys/stat.h> | ||
32 | +#include <string.h> | ||
33 | +#include <stdint.h> | ||
34 | +#include <stdlib.h> | ||
35 | +#include <unistd.h> | ||
36 | +#include <fcntl.h> | ||
37 | + | ||
38 | +#define MAX_CODE_SIZE 128 | ||
39 | + | ||
40 | +typedef int (SelfModTest)(uint32_t, uint32_t*); | ||
41 | +typedef int (BasicTest)(int); | ||
42 | + | ||
43 | +static void mark_code_modified(const uint32_t *exec_data, size_t length) | ||
44 | +{ | ||
45 | + int dc_required, ic_required; | ||
46 | + unsigned long ctr_el0; | ||
47 | + | ||
48 | + /* | ||
49 | + * Clear the data/instruction cache, as indicated by the CTR_ELO.{DIC,IDC} | ||
50 | + * flags. | ||
51 | + * | ||
52 | + * For completeness we might be tempted to assert that we should fail when | ||
53 | + * the whole code update sequence is omitted, but that would make the test | ||
54 | + * flaky as it can succeed by coincidence on actual hardware. | ||
55 | + */ | ||
56 | + asm ("mrs %0, ctr_el0\n" : "=r"(ctr_el0)); | ||
57 | + | ||
58 | + /* CTR_EL0.IDC */ | ||
59 | + dc_required = !((ctr_el0 >> 28) & 1); | ||
60 | + | ||
61 | + /* CTR_EL0.DIC */ | ||
62 | + ic_required = !((ctr_el0 >> 29) & 1); | ||
63 | + | ||
64 | + if (dc_required) { | ||
65 | + size_t dcache_stride, i; | ||
66 | + | ||
67 | + /* | ||
68 | + * Step according to the minimum cache size, as the cache maintenance | ||
69 | + * instructions operate on the cache line of the given address. | ||
70 | + * | ||
71 | + * We assume that exec_data is properly aligned. | ||
72 | + */ | ||
73 | + dcache_stride = (4 << ((ctr_el0 >> 16) & 0xF)); | ||
74 | + | ||
75 | + for (i = 0; i < length; i += dcache_stride) { | ||
76 | + const char *dc_addr = &((const char *)exec_data)[i]; | ||
77 | + asm volatile ("dc cvau, %x[dc_addr]\n" | ||
78 | + : /* no outputs */ | ||
79 | + : [dc_addr] "r"(dc_addr) | ||
80 | + : "memory"); | ||
81 | + } | ||
82 | + | ||
83 | + asm volatile ("dmb ish\n"); | ||
84 | + } | ||
85 | + | ||
86 | + if (ic_required) { | ||
87 | + size_t icache_stride, i; | ||
88 | + | ||
89 | + icache_stride = (4 << (ctr_el0 & 0xF)); | ||
90 | + | ||
91 | + for (i = 0; i < length; i += icache_stride) { | ||
92 | + const char *ic_addr = &((const char *)exec_data)[i]; | ||
93 | + asm volatile ("ic ivau, %x[ic_addr]\n" | ||
94 | + : /* no outputs */ | ||
95 | + : [ic_addr] "r"(ic_addr) | ||
96 | + : "memory"); | ||
97 | + } | ||
98 | + | ||
99 | + asm volatile ("dmb ish\n"); | ||
100 | + } | ||
101 | + | ||
102 | + asm volatile ("isb sy\n"); | ||
103 | +} | ||
104 | + | ||
105 | +static int basic_test(uint32_t *rw_data, const uint32_t *exec_data) | ||
106 | +{ | ||
107 | + /* | ||
108 | + * As user mode only misbehaved for dual-mapped code when previously | ||
109 | + * translated code had been changed, we'll start off with this basic test | ||
110 | + * function to ensure that there's already some translated code at | ||
111 | + * exec_data before the next test. This should cause the next test to fail | ||
112 | + * if `mark_code_modified` fails to invalidate the code. | ||
113 | + * | ||
114 | + * Note that the payload is in binary form instead of inline assembler | ||
115 | + * because we cannot use __attribute__((naked)) on this platform and the | ||
116 | + * workarounds are at least as ugly as this is. | ||
117 | + */ | ||
118 | + static const uint32_t basic_payload[] = { | ||
119 | + 0xD65F03C0 /* 0x00: RET */ | ||
120 | + }; | ||
121 | + | ||
122 | + BasicTest *copied_ptr = (BasicTest *)exec_data; | ||
123 | + | ||
124 | + memcpy(rw_data, basic_payload, sizeof(basic_payload)); | ||
125 | + mark_code_modified(exec_data, sizeof(basic_payload)); | ||
126 | + | ||
127 | + return copied_ptr(1234) == 1234; | ||
128 | +} | ||
129 | + | ||
130 | +static int self_modification_test(uint32_t *rw_data, const uint32_t *exec_data) | ||
131 | +{ | ||
132 | + /* | ||
133 | + * This test is self-modifying in an attempt to cover an edge case where | ||
134 | + * the IC IVAU instruction invalidates itself. | ||
135 | + * | ||
136 | + * Note that the IC IVAU instruction is 16 bytes into the function, in what | ||
137 | + * will be the same cache line as the modified instruction on machines with | ||
138 | + * a cache line size >= 16 bytes. | ||
139 | + */ | ||
140 | + static const uint32_t self_mod_payload[] = { | ||
141 | + /* Overwrite the placeholder instruction with the new one. */ | ||
142 | + 0xB9001C20, /* 0x00: STR w0, [x1, 0x1C] */ | ||
143 | + | ||
144 | + /* Get the executable address of the modified instruction. */ | ||
145 | + 0x100000A8, /* 0x04: ADR x8, <0x1C> */ | ||
146 | + | ||
147 | + /* Mark the modified instruction as updated. */ | ||
148 | + 0xD50B7B28, /* 0x08: DC CVAU x8 */ | ||
149 | + 0xD5033BBF, /* 0x0C: DMB ISH */ | ||
150 | + 0xD50B7528, /* 0x10: IC IVAU x8 */ | ||
151 | + 0xD5033BBF, /* 0x14: DMB ISH */ | ||
152 | + 0xD5033FDF, /* 0x18: ISB */ | ||
153 | + | ||
154 | + /* Placeholder instruction, overwritten above. */ | ||
155 | + 0x52800000, /* 0x1C: MOV w0, 0 */ | ||
156 | + | ||
157 | + 0xD65F03C0 /* 0x20: RET */ | ||
158 | + }; | ||
159 | + | ||
160 | + SelfModTest *copied_ptr = (SelfModTest *)exec_data; | ||
161 | + int i; | ||
162 | + | ||
163 | + memcpy(rw_data, self_mod_payload, sizeof(self_mod_payload)); | ||
164 | + mark_code_modified(exec_data, sizeof(self_mod_payload)); | ||
165 | + | ||
166 | + for (i = 1; i < 10; i++) { | ||
167 | + /* Replace the placeholder instruction with `MOV w0, i` */ | ||
168 | + uint32_t new_instr = 0x52800000 | (i << 5); | ||
169 | + | ||
170 | + if (copied_ptr(new_instr, rw_data) != i) { | ||
171 | + return 0; | ||
172 | + } | ||
173 | + } | ||
174 | + | ||
175 | + return 1; | ||
176 | +} | ||
177 | + | ||
178 | +int main(int argc, char **argv) | ||
179 | +{ | ||
180 | + const char *shm_name = "qemu-test-tcg-aarch64-icivau"; | ||
181 | + int fd; | ||
182 | + | ||
183 | + fd = shm_open(shm_name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); | ||
184 | + | ||
185 | + if (fd < 0) { | ||
186 | + return EXIT_FAILURE; | ||
187 | + } | ||
188 | + | ||
189 | + /* Unlink early to avoid leaving garbage in case the test crashes. */ | ||
190 | + shm_unlink(shm_name); | ||
191 | + | ||
192 | + if (ftruncate(fd, MAX_CODE_SIZE) == 0) { | ||
193 | + const uint32_t *exec_data; | ||
194 | + uint32_t *rw_data; | ||
195 | + | ||
196 | + rw_data = mmap(0, MAX_CODE_SIZE, PROT_READ | PROT_WRITE, | ||
197 | + MAP_SHARED, fd, 0); | ||
198 | + exec_data = mmap(0, MAX_CODE_SIZE, PROT_READ | PROT_EXEC, | ||
199 | + MAP_SHARED, fd, 0); | ||
200 | + | ||
201 | + if (rw_data && exec_data) { | ||
202 | + if (basic_test(rw_data, exec_data) && | ||
203 | + self_modification_test(rw_data, exec_data)) { | ||
204 | + return EXIT_SUCCESS; | ||
205 | + } | ||
206 | + } | ||
207 | + } | ||
208 | + | ||
209 | + return EXIT_FAILURE; | ||
210 | +} | ||
211 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
19 | index XXXXXXX..XXXXXXX 100644 | 212 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/dump.c | 213 | --- a/tests/tcg/aarch64/Makefile.target |
21 | +++ b/dump.c | 214 | +++ b/tests/tcg/aarch64/Makefile.target |
22 | @@ -XXX,XX +XXX,XX @@ static void vmcoreinfo_update_phys_base(DumpState *s) | 215 | @@ -XXX,XX +XXX,XX @@ AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 |
23 | 216 | VPATH += $(AARCH64_SRC) | |
24 | lines = g_strsplit((char *)vmci, "\n", -1); | 217 | |
25 | for (i = 0; lines[i]; i++) { | 218 | # Base architecture tests |
26 | - if (g_str_has_prefix(lines[i], "NUMBER(phys_base)=")) { | 219 | -AARCH64_TESTS=fcvt pcalign-a64 |
27 | - if (qemu_strtou64(lines[i] + 18, NULL, 16, | 220 | +AARCH64_TESTS=fcvt pcalign-a64 icivau |
28 | + const char *prefix = NULL; | 221 | |
29 | + | 222 | fcvt: LDFLAGS+=-lm |
30 | + if (s->dump_info.d_machine == EM_X86_64) { | 223 | +icivau: LDFLAGS+=-lrt |
31 | + prefix = "NUMBER(phys_base)="; | 224 | |
32 | + } else if (s->dump_info.d_machine == EM_AARCH64) { | 225 | run-fcvt: fcvt |
33 | + prefix = "NUMBER(PHYS_OFFSET)="; | 226 | $(call run-test,$<,$(QEMU) $<, "$< on $(TARGET_NAME)") |
34 | + } | ||
35 | + | ||
36 | + if (prefix && g_str_has_prefix(lines[i], prefix)) { | ||
37 | + if (qemu_strtou64(lines[i] + strlen(prefix), NULL, 16, | ||
38 | &phys_base) < 0) { | ||
39 | - warn_report("Failed to read NUMBER(phys_base)="); | ||
40 | + warn_report("Failed to read %s", prefix); | ||
41 | } else { | ||
42 | s->dump_info.phys_base = phys_base; | ||
43 | } | ||
44 | -- | 227 | -- |
45 | 2.16.2 | 228 | 2.34.1 |
46 | 229 | ||
47 | 230 | diff view generated by jsdifflib |
1 | The raspi3 has AArch64 CPUs, which means that our smpboot | 1 | From: Vikram Garhwal <vikram.garhwal@amd.com> |
---|---|---|---|
2 | code for keeping the secondary CPUs in a pen needs to have | ||
3 | a version for A64 as well as A32. Without this, the | ||
4 | secondary CPUs go into an infinite loop of taking undefined | ||
5 | instruction exceptions. | ||
6 | 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> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-id: 20180313153458.26822-10-peter.maydell@linaro.org | ||
10 | --- | 12 | --- |
11 | hw/arm/raspi.c | 41 ++++++++++++++++++++++++++++++++++++++++- | 13 | tests/qtest/xlnx-canfd-test.c | 33 +++++++++++---------------------- |
12 | 1 file changed, 40 insertions(+), 1 deletion(-) | 14 | 1 file changed, 11 insertions(+), 22 deletions(-) |
13 | 15 | ||
14 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 16 | diff --git a/tests/qtest/xlnx-canfd-test.c b/tests/qtest/xlnx-canfd-test.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/raspi.c | 18 | --- a/tests/qtest/xlnx-canfd-test.c |
17 | +++ b/hw/arm/raspi.c | 19 | +++ b/tests/qtest/xlnx-canfd-test.c |
18 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ static void generate_random_data(uint32_t *buf_tx, bool is_canfd_frame) |
19 | #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */ | 21 | /* Generate random TX data for CANFD frame. */ |
20 | #define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */ | 22 | if (is_canfd_frame) { |
21 | #define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */ | 23 | for (int i = 0; i < CANFD_FRAME_SIZE - 2; i++) { |
22 | +#define SPINTABLE_ADDR 0xd8 /* Pi 3 bootloader spintable */ | 24 | - buf_tx[2 + i] = rand(); |
23 | 25 | + buf_tx[2 + i] = g_random_int(); | |
24 | /* Table of Linux board IDs for different Pi versions */ | 26 | } |
25 | static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44}; | 27 | } else { |
26 | @@ -XXX,XX +XXX,XX @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) | 28 | /* Generate random TX data for CAN frame. */ |
27 | info->smp_loader_start); | 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 | } | ||
28 | } | 34 | } |
29 | 35 | ||
30 | +static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info) | 36 | -static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx) |
31 | +{ | 37 | +static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx, |
32 | + /* Unlike the AArch32 version we don't need to call the board setup hook. | 38 | + uint32_t frame_size) |
33 | + * The mechanism for doing the spin-table is also entirely different. | ||
34 | + * We must have four 64-bit fields at absolute addresses | ||
35 | + * 0xd8, 0xe0, 0xe8, 0xf0 in RAM, which are the flag variables for | ||
36 | + * our CPUs, and which we must ensure are zero initialized before | ||
37 | + * the primary CPU goes into the kernel. We put these variables inside | ||
38 | + * a rom blob, so that the reset for ROM contents zeroes them for us. | ||
39 | + */ | ||
40 | + static const uint32_t smpboot[] = { | ||
41 | + 0xd2801b05, /* mov x5, 0xd8 */ | ||
42 | + 0xd53800a6, /* mrs x6, mpidr_el1 */ | ||
43 | + 0x924004c6, /* and x6, x6, #0x3 */ | ||
44 | + 0xd503205f, /* spin: wfe */ | ||
45 | + 0xf86678a4, /* ldr x4, [x5,x6,lsl #3] */ | ||
46 | + 0xb4ffffc4, /* cbz x4, spin */ | ||
47 | + 0xd2800000, /* mov x0, #0x0 */ | ||
48 | + 0xd2800001, /* mov x1, #0x0 */ | ||
49 | + 0xd2800002, /* mov x2, #0x0 */ | ||
50 | + 0xd2800003, /* mov x3, #0x0 */ | ||
51 | + 0xd61f0080, /* br x4 */ | ||
52 | + }; | ||
53 | + | ||
54 | + static const uint64_t spintables[] = { | ||
55 | + 0, 0, 0, 0 | ||
56 | + }; | ||
57 | + | ||
58 | + rom_add_blob_fixed("raspi_smpboot", smpboot, sizeof(smpboot), | ||
59 | + info->smp_loader_start); | ||
60 | + rom_add_blob_fixed("raspi_spintables", spintables, sizeof(spintables), | ||
61 | + SPINTABLE_ADDR); | ||
62 | +} | ||
63 | + | ||
64 | static void write_board_setup(ARMCPU *cpu, const struct arm_boot_info *info) | ||
65 | { | 39 | { |
66 | arm_write_secure_board_setup_dummy_smc(cpu, info, MVBAR_ADDR); | 40 | uint32_t int_status; |
67 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | 41 | uint32_t fifo_status_reg_value; |
68 | /* Pi2 and Pi3 requires SMP setup */ | 42 | /* At which RX FIFO the received data is stored. */ |
69 | if (version >= 2) { | 43 | uint8_t store_ind = 0; |
70 | binfo.smp_loader_start = SMPBOOT_ADDR; | 44 | - bool is_canfd_frame = false; |
71 | - binfo.write_secondary_boot = write_smpboot; | 45 | |
72 | + if (version == 2) { | 46 | /* Read the interrupt on CANFD rx. */ |
73 | + binfo.write_secondary_boot = write_smpboot; | 47 | int_status = qtest_readl(qts, can_base_addr + R_ISR_OFFSET) & ISR_RXOK; |
74 | + } else { | 48 | @@ -XXX,XX +XXX,XX @@ static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx) |
75 | + binfo.write_secondary_boot = write_smpboot64; | 49 | buf_rx[0] = qtest_readl(qts, can_base_addr + R_RX0_ID_OFFSET); |
76 | + } | 50 | buf_rx[1] = qtest_readl(qts, can_base_addr + R_RX0_DLC_OFFSET); |
77 | binfo.secondary_cpu_reset_hook = reset_secondary; | 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); | ||
78 | } | 65 | } |
79 | 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); | ||
80 | -- | 115 | -- |
81 | 2.16.2 | 116 | 2.34.1 |
82 | |||
83 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | The sabrelite machine model used by qemu-system-arm is based on the | 3 | This code is only relevant when TCG is present in the build. Building |
4 | Freescale/NXP i.MX6Q processor. This SoC has an on-board ethernet | 4 | with --disable-tcg --enable-xen on an x86 host we get: |
5 | controller which is supported in QEMU using the imx_fec.c module | ||
6 | (actually called imx.enet for this model.) | ||
7 | 5 | ||
8 | The include/hw/arm/fsm-imx6.h file defines the interrupt vectors for the | 6 | $ ../configure --target-list=x86_64-softmmu,aarch64-softmmu --disable-tcg --enable-xen |
9 | imx.enet device like this: | 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' | ||
10 | 12 | ||
11 | #define FSL_IMX6_ENET_MAC_1588_IRQ 118 | 13 | libqemu-aarch64-softmmu.fa.p/target_arm_gdbstub.c.o: in function `arm_gdb_get_m_systemreg': |
12 | #define FSL_IMX6_ENET_MAC_IRQ 119 | 14 | ../target/arm/gdbstub.c:405: undefined reference to `arm_v7m_mrs_control' |
13 | 15 | ||
14 | According to https://www.nxp.com/docs/en/reference-manual/IMX6DQRM.pdf, | 16 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
15 | page 225, in Table 3-1. ARM Cortex A9 domain interrupt summary, | 17 | Message-id: 20230628164821.16771-1-farosas@suse.de |
16 | interrupts are as follows. | ||
17 | |||
18 | 150 ENET MAC 0 IRQ | ||
19 | 151 ENET MAC 0 1588 Timer interrupt | ||
20 | |||
21 | where | ||
22 | |||
23 | 150 - 32 == 118 | ||
24 | 151 - 32 == 119 | ||
25 | |||
26 | In other words, the vector definitions in the fsl-imx6.h file are reversed. | ||
27 | |||
28 | Fixing the interrupts alone causes problems with older Linux kernels: | ||
29 | The Ethernet interface will fail to probe with Linux v4.9 and earlier. | ||
30 | Linux v4.1 and earlier will crash due to a bug in Ethernet driver probe | ||
31 | error handling. This is a Linux kernel problem, not a qemu problem: | ||
32 | the Linux kernel only worked by accident since it requested both interrupts. | ||
33 | |||
34 | For backward compatibility, generate the Ethernet interrupt on both interrupt | ||
35 | lines. This was shown to work from all Linux kernel releases starting with | ||
36 | v3.16. | ||
37 | |||
38 | Link: https://bugs.launchpad.net/qemu/+bug/1753309 | ||
39 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
40 | Message-id: 1520723090-22130-1-git-send-email-linux@roeck-us.net | ||
41 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
42 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
43 | --- | 20 | --- |
44 | include/hw/arm/fsl-imx6.h | 4 ++-- | 21 | target/arm/gdbstub.c | 4 ++++ |
45 | hw/net/imx_fec.c | 28 +++++++++++++++++++++++++++- | 22 | 1 file changed, 4 insertions(+) |
46 | 2 files changed, 29 insertions(+), 3 deletions(-) | ||
47 | 23 | ||
48 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h | 24 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
49 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/include/hw/arm/fsl-imx6.h | 26 | --- a/target/arm/gdbstub.c |
51 | +++ b/include/hw/arm/fsl-imx6.h | 27 | +++ b/target/arm/gdbstub.c |
52 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6State { | 28 | @@ -XXX,XX +XXX,XX @@ static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) |
53 | #define FSL_IMX6_HDMI_MASTER_IRQ 115 | 29 | return cpu->dyn_sysreg_xml.num; |
54 | #define FSL_IMX6_HDMI_CEC_IRQ 116 | 30 | } |
55 | #define FSL_IMX6_MLB150_LOW_IRQ 117 | 31 | |
56 | -#define FSL_IMX6_ENET_MAC_1588_IRQ 118 | 32 | +#ifdef CONFIG_TCG |
57 | -#define FSL_IMX6_ENET_MAC_IRQ 119 | 33 | typedef enum { |
58 | +#define FSL_IMX6_ENET_MAC_IRQ 118 | 34 | M_SYSREG_MSP, |
59 | +#define FSL_IMX6_ENET_MAC_1588_IRQ 119 | 35 | M_SYSREG_PSP, |
60 | #define FSL_IMX6_PCIE1_IRQ 120 | 36 | @@ -XXX,XX +XXX,XX @@ static int arm_gen_dynamic_m_secextreg_xml(CPUState *cs, int orig_base_reg) |
61 | #define FSL_IMX6_PCIE2_IRQ 121 | 37 | return cpu->dyn_m_secextreg_xml.num; |
62 | #define FSL_IMX6_PCIE3_IRQ 122 | 38 | } |
63 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 39 | #endif |
64 | index XXXXXXX..XXXXXXX 100644 | 40 | +#endif /* CONFIG_TCG */ |
65 | --- a/hw/net/imx_fec.c | 41 | |
66 | +++ b/hw/net/imx_fec.c | 42 | const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) |
67 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_write_bd(IMXENETBufDesc *bd, dma_addr_t addr) | ||
68 | |||
69 | static void imx_eth_update(IMXFECState *s) | ||
70 | { | 43 | { |
71 | - if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & ENET_INT_TS_TIMER) { | 44 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) |
72 | + /* | 45 | arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_regs), |
73 | + * Previous versions of qemu had the ENET_INT_MAC and ENET_INT_TS_TIMER | 46 | "system-registers.xml", 0); |
74 | + * interrupts swapped. This worked with older versions of Linux (4.14 | 47 | |
75 | + * and older) since Linux associated both interrupt lines with Ethernet | 48 | +#ifdef CONFIG_TCG |
76 | + * MAC interrupts. Specifically, | 49 | if (arm_feature(env, ARM_FEATURE_M) && tcg_enabled()) { |
77 | + * - Linux 4.15 and later have separate interrupt handlers for the MAC and | 50 | gdb_register_coprocessor(cs, |
78 | + * timer interrupts. Those versions of Linux fail with versions of QEMU | 51 | arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg, |
79 | + * with swapped interrupt assignments. | 52 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) |
80 | + * - In linux 4.14, both interrupt lines were registered with the Ethernet | 53 | } |
81 | + * MAC interrupt handler. As a result, all versions of qemu happen to | 54 | #endif |
82 | + * work, though that is accidental. | 55 | } |
83 | + * - In Linux 4.9 and older, the timer interrupt was registered directly | 56 | +#endif /* CONFIG_TCG */ |
84 | + * with the Ethernet MAC interrupt handler. The MAC interrupt was | 57 | } |
85 | + * redirected to a GPIO interrupt to work around erratum ERR006687. | ||
86 | + * This was implemented using the SOC's IOMUX block. In qemu, this GPIO | ||
87 | + * interrupt never fired since IOMUX is currently not supported in qemu. | ||
88 | + * Linux instead received MAC interrupts on the timer interrupt. | ||
89 | + * As a result, qemu versions with the swapped interrupt assignment work, | ||
90 | + * albeit accidentally, but qemu versions with the correct interrupt | ||
91 | + * assignment fail. | ||
92 | + * | ||
93 | + * To ensure that all versions of Linux work, generate ENET_INT_MAC | ||
94 | + * interrrupts on both interrupt lines. This should be changed if and when | ||
95 | + * qemu supports IOMUX. | ||
96 | + */ | ||
97 | + if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & | ||
98 | + (ENET_INT_MAC | ENET_INT_TS_TIMER)) { | ||
99 | qemu_set_irq(s->irq[1], 1); | ||
100 | } else { | ||
101 | qemu_set_irq(s->irq[1], 0); | ||
102 | -- | 58 | -- |
103 | 2.16.2 | 59 | 2.34.1 |
104 | |||
105 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | For the rpi1 and 2 we want to boot the Linux kernel via some | ||
2 | custom setup code that makes sure that the SMC instruction | ||
3 | acts as a no-op, because it's used for cache maintenance. | ||
4 | The rpi3 boots AArch64 kernels, which don't need SMC for | ||
5 | cache maintenance and always expect to be booted non-secure. | ||
6 | Don't fill in the aarch32-specific parts of the binfo struct. | ||
7 | 1 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20180313153458.26822-2-peter.maydell@linaro.org | ||
12 | --- | ||
13 | hw/arm/raspi.c | 17 +++++++++++++---- | ||
14 | 1 file changed, 13 insertions(+), 4 deletions(-) | ||
15 | |||
16 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/arm/raspi.c | ||
19 | +++ b/hw/arm/raspi.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
21 | binfo.board_id = raspi_boardid[version]; | ||
22 | binfo.ram_size = ram_size; | ||
23 | binfo.nb_cpus = smp_cpus; | ||
24 | - binfo.board_setup_addr = BOARDSETUP_ADDR; | ||
25 | - binfo.write_board_setup = write_board_setup; | ||
26 | - binfo.secure_board_setup = true; | ||
27 | - binfo.secure_boot = true; | ||
28 | + | ||
29 | + if (version <= 2) { | ||
30 | + /* The rpi1 and 2 require some custom setup code to run in Secure | ||
31 | + * mode before booting a kernel (to set up the SMC vectors so | ||
32 | + * that we get a no-op SMC; this is used by Linux to call the | ||
33 | + * firmware for some cache maintenance operations. | ||
34 | + * The rpi3 doesn't need this. | ||
35 | + */ | ||
36 | + binfo.board_setup_addr = BOARDSETUP_ADDR; | ||
37 | + binfo.write_board_setup = write_board_setup; | ||
38 | + binfo.secure_board_setup = true; | ||
39 | + binfo.secure_boot = true; | ||
40 | + } | ||
41 | |||
42 | /* Pi2 and Pi3 requires SMP setup */ | ||
43 | if (version >= 2) { | ||
44 | -- | ||
45 | 2.16.2 | ||
46 | |||
47 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Add some assertions that if we're about to boot an AArch64 kernel, | ||
2 | the board code has not mistakenly set either secure_boot or | ||
3 | secure_board_setup. It doesn't make sense to set secure_boot, | ||
4 | because all AArch64 kernels must be booted in non-secure mode. | ||
5 | 1 | ||
6 | It might in theory make sense to set secure_board_setup, but | ||
7 | we don't currently support that, because only the AArch32 | ||
8 | bootloader[] code calls this hook; bootloader_aarch64[] does not. | ||
9 | Since we don't have a current need for this functionality, just | ||
10 | assert that we don't try to use it. If it's needed we'll add | ||
11 | it later. | ||
12 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 20180313153458.26822-3-peter.maydell@linaro.org | ||
16 | --- | ||
17 | hw/arm/boot.c | 7 +++++++ | ||
18 | 1 file changed, 7 insertions(+) | ||
19 | |||
20 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/arm/boot.c | ||
23 | +++ b/hw/arm/boot.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | ||
25 | } else { | ||
26 | env->pstate = PSTATE_MODE_EL1h; | ||
27 | } | ||
28 | + /* AArch64 kernels never boot in secure mode */ | ||
29 | + assert(!info->secure_boot); | ||
30 | + /* This hook is only supported for AArch32 currently: | ||
31 | + * bootloader_aarch64[] will not call the hook, and | ||
32 | + * the code above has already dropped us into EL2 or EL1. | ||
33 | + */ | ||
34 | + assert(!info->secure_board_setup); | ||
35 | } | ||
36 | |||
37 | /* Set to non-secure if not a secure boot */ | ||
38 | -- | ||
39 | 2.16.2 | ||
40 | |||
41 | diff view generated by jsdifflib |
1 | The BCM2837 sets the Aff1 field of the MPIDR affinity values for the | 1 | From: Akihiko Odaki <akihiko.odaki@daynix.com> |
---|---|---|---|
2 | CPUs to 0, whereas the BCM2836 uses 0xf. Set this correctly, as it | ||
3 | is required for Linux to boot. | ||
4 | 2 | ||
3 | AwSRAMCClass is larger than SysBusDeviceClass so the class size must be | ||
4 | advertised accordingly. | ||
5 | |||
6 | Fixes: 05def917e1 ("hw: arm: allwinner-sramc: Add SRAM Controller support for R40") | ||
7 | Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20230628110905.38125-1-akihiko.odaki@daynix.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20180313153458.26822-8-peter.maydell@linaro.org | ||
9 | --- | 12 | --- |
10 | hw/arm/bcm2836.c | 11 +++++++---- | 13 | hw/misc/allwinner-sramc.c | 1 + |
11 | 1 file changed, 7 insertions(+), 4 deletions(-) | 14 | 1 file changed, 1 insertion(+) |
12 | 15 | ||
13 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | 16 | diff --git a/hw/misc/allwinner-sramc.c b/hw/misc/allwinner-sramc.c |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/bcm2836.c | 18 | --- a/hw/misc/allwinner-sramc.c |
16 | +++ b/hw/arm/bcm2836.c | 19 | +++ b/hw/misc/allwinner-sramc.c |
17 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo allwinner_sramc_info = { |
18 | 21 | .parent = TYPE_SYS_BUS_DEVICE, | |
19 | struct BCM283XInfo { | 22 | .instance_init = allwinner_sramc_init, |
20 | const char *name; | 23 | .instance_size = sizeof(AwSRAMCState), |
21 | + int clusterid; | 24 | + .class_size = sizeof(AwSRAMCClass), |
25 | .class_init = allwinner_sramc_class_init, | ||
22 | }; | 26 | }; |
23 | 27 | ||
24 | static const BCM283XInfo bcm283x_socs[] = { | ||
25 | { | ||
26 | .name = TYPE_BCM2836, | ||
27 | + .clusterid = 0xf, | ||
28 | }, | ||
29 | { | ||
30 | .name = TYPE_BCM2837, | ||
31 | + .clusterid = 0x0, | ||
32 | }, | ||
33 | }; | ||
34 | |||
35 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj) | ||
36 | static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
37 | { | ||
38 | BCM283XState *s = BCM283X(dev); | ||
39 | + BCM283XClass *bc = BCM283X_GET_CLASS(dev); | ||
40 | + const BCM283XInfo *info = bc->info; | ||
41 | Object *obj; | ||
42 | Error *err = NULL; | ||
43 | int n; | ||
44 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
45 | qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); | ||
46 | |||
47 | for (n = 0; n < BCM283X_NCPUS; n++) { | ||
48 | - /* Mirror bcm2836, which has clusterid set to 0xf | ||
49 | - * TODO: this should be converted to a property of ARM_CPU | ||
50 | - */ | ||
51 | - s->cpus[n].mp_affinity = 0xF00 | n; | ||
52 | + /* TODO: this should be converted to a property of ARM_CPU */ | ||
53 | + s->cpus[n].mp_affinity = (info->clusterid << 8) | n; | ||
54 | |||
55 | /* set periphbase/CBAR value for CPU-local registers */ | ||
56 | object_property_set_int(OBJECT(&s->cpus[n]), | ||
57 | -- | 28 | -- |
58 | 2.16.2 | 29 | 2.34.1 |
59 | 30 | ||
60 | 31 | diff view generated by jsdifflib |
1 | If we're directly booting a Linux kernel and the CPU supports both | 1 | In handle_interrupt() we use level as an index into the interrupt_vector[] |
---|---|---|---|
2 | EL3 and EL2, we start the kernel in EL2, as it expects. We must also | 2 | array. This is safe because we have checked it against env->config->nlevel, |
3 | set the SCR_EL3.HCE bit in this situation, so that the HVC | 3 | but Coverity can't see that (and it is only true because each CPU config |
4 | instruction is enabled rather than UNDEFing. Otherwise at least some | 4 | sets its XCHAL_NUM_INTLEVELS to something less than MAX_NLEVELS), so it |
5 | kernels will panic when trying to initialize KVM in the guest. | 5 | complains about a possible array overrun (CID 1507131) |
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. | ||
6 | 9 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20180313153458.26822-4-peter.maydell@linaro.org | 11 | Acked-by: Max Filippov <jcmvbkbc@gmail.com> |
12 | Message-id: 20230623154135.1930261-1-peter.maydell@linaro.org | ||
9 | --- | 13 | --- |
10 | hw/arm/boot.c | 5 +++++ | 14 | target/xtensa/exc_helper.c | 3 +++ |
11 | 1 file changed, 5 insertions(+) | 15 | 1 file changed, 3 insertions(+) |
12 | 16 | ||
13 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 17 | diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/boot.c | 19 | --- a/target/xtensa/exc_helper.c |
16 | +++ b/hw/arm/boot.c | 20 | +++ b/target/xtensa/exc_helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 21 | @@ -XXX,XX +XXX,XX @@ static void handle_interrupt(CPUXtensaState *env) |
18 | assert(!info->secure_board_setup); | 22 | CPUState *cs = env_cpu(env); |
19 | } | 23 | |
20 | 24 | if (level > 1) { | |
21 | + if (arm_feature(env, ARM_FEATURE_EL2)) { | 25 | + /* env->config->nlevel check should have ensured this */ |
22 | + /* If we have EL2 then Linux expects the HVC insn to work */ | 26 | + assert(level < sizeof(env->config->interrupt_vector)); |
23 | + env->cp15.scr_el3 |= SCR_HCE; | ||
24 | + } | ||
25 | + | 27 | + |
26 | /* Set to non-secure if not a secure boot */ | 28 | env->sregs[EPC1 + level - 1] = env->pc; |
27 | if (!info->secure_boot && | 29 | env->sregs[EPS2 + level - 2] = env->sregs[PS]; |
28 | (cs != first_cpu || !info->secure_board_setup)) { | 30 | env->sregs[PS] = |
29 | -- | 31 | -- |
30 | 2.16.2 | 32 | 2.34.1 |
31 | |||
32 | diff view generated by jsdifflib |