1 | Hi; this pullreq contains mainly a chunk of RTH's refactoring | 1 | The following changes since commit 8f6330a807f2642dc2a3cdf33347aa28a4c00a87: |
---|---|---|---|
2 | of the Arm pagetable walk code, plus a series from me fixing | ||
3 | configure checkpatch warnings, and some old patches to various | ||
4 | files all over the tree getting rid of dynamic stack allocation. | ||
5 | 2 | ||
6 | thanks | 3 | Merge tag 'pull-maintainer-updates-060324-1' of https://gitlab.com/stsquad/qemu into staging (2024-03-06 16:56:20 +0000) |
7 | -- PMM | ||
8 | |||
9 | The following changes since commit 6338c30111d596d955e6bc933a82184a0b910c43: | ||
10 | |||
11 | Merge tag 'm68k-for-7.2-pull-request' of https://github.com/vivier/qemu-m68k into staging (2022-09-21 13:12:36 -0400) | ||
12 | 4 | ||
13 | are available in the Git repository at: | 5 | are available in the Git repository at: |
14 | 6 | ||
15 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220922 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240308 |
16 | 8 | ||
17 | for you to fetch changes up to b3b5472db0ab7a53499441c1fe1dedec05b1e285: | 9 | for you to fetch changes up to bbf6c6dbead82292a20951eb1204442a6b838de9: |
18 | 10 | ||
19 | configure: Avoid use of 'local' as it is non-POSIX (2022-09-22 16:38:29 +0100) | 11 | target/arm: Move v7m-related code from cpu32.c into a separate file (2024-03-08 14:45:03 +0000) |
20 | 12 | ||
21 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
22 | target-arm queue: | 14 | target-arm queue: |
23 | * hw/net/can: fix Xilinx ZynqMP CAN RX FIFO logic | 15 | * Implement FEAT_ECV |
24 | * Fix alignment for Neon VLD4.32 | 16 | * STM32L4x5: Implement GPIO device |
25 | * Refactoring of page-table-walk code | 17 | * Fix 32-bit SMOPA |
26 | * hw/acpi: Add ospm_status hook implementation for acpi-ged | 18 | * Refactor v7m related code from cpu32.c into its own file |
27 | * hw/net/lan9118: Signal TSFL_INT flag when TX FIFO reaches specified level | 19 | * hw/rtc/sun4v-rtc: Relicense to GPLv2-or-later |
28 | * chardev/baum: avoid variable-length arrays | ||
29 | * io/channel-websock: avoid variable-length arrays | ||
30 | * hw/net/e1000e_core: Use definition to avoid dynamic stack allocation | ||
31 | * hw/ppc/pnv: Avoid dynamic stack allocation | ||
32 | * hw/intc/xics: Avoid dynamic stack allocation | ||
33 | * hw/i386/multiboot: Avoid dynamic stack allocation | ||
34 | * hw/usb/hcd-ohci: Use definition to avoid dynamic stack allocation | ||
35 | * ui/curses: Avoid dynamic stack allocation | ||
36 | * tests/unit/test-vmstate: Avoid dynamic stack allocation | ||
37 | * configure: fix various shellcheck-spotted issues and nits | ||
38 | 20 | ||
39 | ---------------------------------------------------------------- | 21 | ---------------------------------------------------------------- |
40 | Anton Kochkov (1): | 22 | Inès Varhol (3): |
41 | hw/net/can: fix Xilinx ZynqMP CAN RX FIFO logic | 23 | hw/gpio: Implement STM32L4x5 GPIO |
24 | hw/arm: Connect STM32L4x5 GPIO to STM32L4x5 SoC | ||
25 | tests/qtest: Add STM32L4x5 GPIO QTest testcase | ||
42 | 26 | ||
43 | Clément Chigot (1): | 27 | Peter Maydell (9): |
44 | target/arm: Fix alignment for VLD4.32 | 28 | target/arm: Move some register related defines to internals.h |
29 | target/arm: Timer _EL02 registers UNDEF for E2H == 0 | ||
30 | target/arm: use FIELD macro for CNTHCTL bit definitions | ||
31 | target/arm: Don't allow RES0 CNTHCTL_EL2 bits to be written | ||
32 | target/arm: Implement new FEAT_ECV trap bits | ||
33 | target/arm: Define CNTPCTSS_EL0 and CNTVCTSS_EL0 | ||
34 | target/arm: Implement FEAT_ECV CNTPOFF_EL2 handling | ||
35 | target/arm: Enable FEAT_ECV for 'max' CPU | ||
36 | hw/rtc/sun4v-rtc: Relicense to GPLv2-or-later | ||
45 | 37 | ||
46 | Keqian Zhu (1): | 38 | Richard Henderson (1): |
47 | hw/acpi: Add ospm_status hook implementation for acpi-ged | 39 | target/arm: Fix 32-bit SMOPA |
48 | 40 | ||
49 | Lucas Dietrich (1): | 41 | Thomas Huth (1): |
50 | hw/net/lan9118: Signal TSFL_INT flag when TX FIFO reaches specified level | 42 | target/arm: Move v7m-related code from cpu32.c into a separate file |
51 | 43 | ||
52 | Peter Maydell (7): | 44 | MAINTAINERS | 1 + |
53 | configure: Remove unused python_version variable | 45 | docs/system/arm/b-l475e-iot01a.rst | 2 +- |
54 | configure: Remove unused meson_args variable | 46 | docs/system/arm/emulation.rst | 1 + |
55 | configure: Add missing quoting for some easy cases | 47 | include/hw/arm/stm32l4x5_soc.h | 2 + |
56 | configure: Add './' on front of glob of */config-devices.mak.d | 48 | include/hw/gpio/stm32l4x5_gpio.h | 71 +++++ |
57 | configure: Remove use of backtick `...` syntax | 49 | include/hw/misc/stm32l4x5_syscfg.h | 3 +- |
58 | configure: Check mkdir result directly, not via $? | 50 | include/hw/rtc/sun4v-rtc.h | 2 +- |
59 | configure: Avoid use of 'local' as it is non-POSIX | 51 | target/arm/cpu-features.h | 10 + |
52 | target/arm/cpu.h | 129 +-------- | ||
53 | target/arm/internals.h | 151 ++++++++++ | ||
54 | hw/arm/stm32l4x5_soc.c | 71 ++++- | ||
55 | hw/gpio/stm32l4x5_gpio.c | 477 ++++++++++++++++++++++++++++++++ | ||
56 | hw/misc/stm32l4x5_syscfg.c | 1 + | ||
57 | hw/rtc/sun4v-rtc.c | 2 +- | ||
58 | target/arm/helper.c | 189 ++++++++++++- | ||
59 | target/arm/tcg/cpu-v7m.c | 290 +++++++++++++++++++ | ||
60 | target/arm/tcg/cpu32.c | 261 ------------------ | ||
61 | target/arm/tcg/cpu64.c | 1 + | ||
62 | target/arm/tcg/sme_helper.c | 77 +++--- | ||
63 | tests/qtest/stm32l4x5_gpio-test.c | 551 +++++++++++++++++++++++++++++++++++++ | ||
64 | tests/tcg/aarch64/sme-smopa-1.c | 47 ++++ | ||
65 | tests/tcg/aarch64/sme-smopa-2.c | 54 ++++ | ||
66 | hw/arm/Kconfig | 3 +- | ||
67 | hw/gpio/Kconfig | 3 + | ||
68 | hw/gpio/meson.build | 1 + | ||
69 | hw/gpio/trace-events | 6 + | ||
70 | target/arm/meson.build | 3 + | ||
71 | target/arm/tcg/meson.build | 3 + | ||
72 | target/arm/trace-events | 1 + | ||
73 | tests/qtest/meson.build | 3 +- | ||
74 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
75 | 31 files changed, 1962 insertions(+), 456 deletions(-) | ||
76 | create mode 100644 include/hw/gpio/stm32l4x5_gpio.h | ||
77 | create mode 100644 hw/gpio/stm32l4x5_gpio.c | ||
78 | create mode 100644 target/arm/tcg/cpu-v7m.c | ||
79 | create mode 100644 tests/qtest/stm32l4x5_gpio-test.c | ||
80 | create mode 100644 tests/tcg/aarch64/sme-smopa-1.c | ||
81 | create mode 100644 tests/tcg/aarch64/sme-smopa-2.c | ||
60 | 82 | ||
61 | Philippe Mathieu-Daudé (11): | ||
62 | chardev/baum: Replace magic values by X_MAX / Y_MAX definitions | ||
63 | chardev/baum: Use definitions to avoid dynamic stack allocation | ||
64 | chardev/baum: Avoid dynamic stack allocation | ||
65 | io/channel-websock: Replace strlen(const_str) by sizeof(const_str) - 1 | ||
66 | hw/net/e1000e_core: Use definition to avoid dynamic stack allocation | ||
67 | hw/ppc/pnv: Avoid dynamic stack allocation | ||
68 | hw/intc/xics: Avoid dynamic stack allocation | ||
69 | hw/i386/multiboot: Avoid dynamic stack allocation | ||
70 | hw/usb/hcd-ohci: Use definition to avoid dynamic stack allocation | ||
71 | ui/curses: Avoid dynamic stack allocation | ||
72 | tests/unit/test-vmstate: Avoid dynamic stack allocation | ||
73 | |||
74 | Richard Henderson (17): | ||
75 | target/arm: Create GetPhysAddrResult | ||
76 | target/arm: Use GetPhysAddrResult in get_phys_addr_lpae | ||
77 | target/arm: Use GetPhysAddrResult in get_phys_addr_v6 | ||
78 | target/arm: Use GetPhysAddrResult in get_phys_addr_v5 | ||
79 | target/arm: Use GetPhysAddrResult in get_phys_addr_pmsav5 | ||
80 | target/arm: Use GetPhysAddrResult in get_phys_addr_pmsav7 | ||
81 | target/arm: Use GetPhysAddrResult in get_phys_addr_pmsav8 | ||
82 | target/arm: Use GetPhysAddrResult in pmsav8_mpu_lookup | ||
83 | target/arm: Remove is_subpage argument to pmsav8_mpu_lookup | ||
84 | target/arm: Add is_secure parameter to v8m_security_lookup | ||
85 | target/arm: Add secure parameter to pmsav8_mpu_lookup | ||
86 | target/arm: Add is_secure parameter to get_phys_addr_v5 | ||
87 | target/arm: Add is_secure parameter to get_phys_addr_v6 | ||
88 | target/arm: Add secure parameter to get_phys_addr_pmsav8 | ||
89 | target/arm: Add is_secure parameter to pmsav7_use_background_region | ||
90 | target/arm: Add secure parameter to get_phys_addr_pmsav7 | ||
91 | target/arm: Add is_secure parameter to get_phys_addr_pmsav5 | ||
92 | |||
93 | configure | 82 +++++----- | ||
94 | target/arm/internals.h | 26 +-- | ||
95 | chardev/baum.c | 22 ++- | ||
96 | hw/acpi/generic_event_device.c | 8 + | ||
97 | hw/i386/multiboot.c | 5 +- | ||
98 | hw/intc/xics.c | 2 +- | ||
99 | hw/net/can/xlnx-zynqmp-can.c | 32 ++-- | ||
100 | hw/net/e1000e_core.c | 7 +- | ||
101 | hw/net/lan9118.c | 8 + | ||
102 | hw/ppc/pnv.c | 4 +- | ||
103 | hw/ppc/spapr.c | 8 +- | ||
104 | hw/ppc/spapr_pci_nvlink2.c | 2 +- | ||
105 | hw/usb/hcd-ohci.c | 7 +- | ||
106 | io/channel-websock.c | 2 +- | ||
107 | target/arm/helper.c | 27 ++- | ||
108 | target/arm/m_helper.c | 78 ++++----- | ||
109 | target/arm/ptw.c | 364 +++++++++++++++++++---------------------- | ||
110 | target/arm/tlb_helper.c | 22 +-- | ||
111 | target/arm/translate-neon.c | 6 +- | ||
112 | tests/unit/test-vmstate.c | 7 +- | ||
113 | ui/curses.c | 2 +- | ||
114 | 21 files changed, 347 insertions(+), 374 deletions(-) | ||
115 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Anton Kochkov <anton.kochkov@proton.me> | ||
2 | 1 | ||
3 | For consistency, function "update_rx_fifo()" should use the RX FIFO | ||
4 | register field names, not the TX FIFO ones, even if they refer to the | ||
5 | same bit positions in the register. | ||
6 | |||
7 | Signed-off-by: Anton Kochkov <anton.kochkov@proton.me> | ||
8 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
9 | Message-id: 20220817141754.2105981-1-anton.kochkov@proton.me | ||
10 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1123 | ||
11 | [PMM: tweaked commit message] | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/net/can/xlnx-zynqmp-can.c | 32 ++++++++++++++++---------------- | ||
15 | 1 file changed, 16 insertions(+), 16 deletions(-) | ||
16 | |||
17 | diff --git a/hw/net/can/xlnx-zynqmp-can.c b/hw/net/can/xlnx-zynqmp-can.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/net/can/xlnx-zynqmp-can.c | ||
20 | +++ b/hw/net/can/xlnx-zynqmp-can.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void update_rx_fifo(XlnxZynqMPCANState *s, const qemu_can_frame *frame) | ||
22 | timestamp)); | ||
23 | |||
24 | /* First 32 bit of the data. */ | ||
25 | - fifo32_push(&s->rx_fifo, deposit32(0, R_TXFIFO_DATA1_DB3_SHIFT, | ||
26 | - R_TXFIFO_DATA1_DB3_LENGTH, | ||
27 | + fifo32_push(&s->rx_fifo, deposit32(0, R_RXFIFO_DATA1_DB3_SHIFT, | ||
28 | + R_RXFIFO_DATA1_DB3_LENGTH, | ||
29 | frame->data[0]) | | ||
30 | - deposit32(0, R_TXFIFO_DATA1_DB2_SHIFT, | ||
31 | - R_TXFIFO_DATA1_DB2_LENGTH, | ||
32 | + deposit32(0, R_RXFIFO_DATA1_DB2_SHIFT, | ||
33 | + R_RXFIFO_DATA1_DB2_LENGTH, | ||
34 | frame->data[1]) | | ||
35 | - deposit32(0, R_TXFIFO_DATA1_DB1_SHIFT, | ||
36 | - R_TXFIFO_DATA1_DB1_LENGTH, | ||
37 | + deposit32(0, R_RXFIFO_DATA1_DB1_SHIFT, | ||
38 | + R_RXFIFO_DATA1_DB1_LENGTH, | ||
39 | frame->data[2]) | | ||
40 | - deposit32(0, R_TXFIFO_DATA1_DB0_SHIFT, | ||
41 | - R_TXFIFO_DATA1_DB0_LENGTH, | ||
42 | + deposit32(0, R_RXFIFO_DATA1_DB0_SHIFT, | ||
43 | + R_RXFIFO_DATA1_DB0_LENGTH, | ||
44 | frame->data[3])); | ||
45 | /* Last 32 bit of the data. */ | ||
46 | - fifo32_push(&s->rx_fifo, deposit32(0, R_TXFIFO_DATA2_DB7_SHIFT, | ||
47 | - R_TXFIFO_DATA2_DB7_LENGTH, | ||
48 | + fifo32_push(&s->rx_fifo, deposit32(0, R_RXFIFO_DATA2_DB7_SHIFT, | ||
49 | + R_RXFIFO_DATA2_DB7_LENGTH, | ||
50 | frame->data[4]) | | ||
51 | - deposit32(0, R_TXFIFO_DATA2_DB6_SHIFT, | ||
52 | - R_TXFIFO_DATA2_DB6_LENGTH, | ||
53 | + deposit32(0, R_RXFIFO_DATA2_DB6_SHIFT, | ||
54 | + R_RXFIFO_DATA2_DB6_LENGTH, | ||
55 | frame->data[5]) | | ||
56 | - deposit32(0, R_TXFIFO_DATA2_DB5_SHIFT, | ||
57 | - R_TXFIFO_DATA2_DB5_LENGTH, | ||
58 | + deposit32(0, R_RXFIFO_DATA2_DB5_SHIFT, | ||
59 | + R_RXFIFO_DATA2_DB5_LENGTH, | ||
60 | frame->data[6]) | | ||
61 | - deposit32(0, R_TXFIFO_DATA2_DB4_SHIFT, | ||
62 | - R_TXFIFO_DATA2_DB4_LENGTH, | ||
63 | + deposit32(0, R_RXFIFO_DATA2_DB4_SHIFT, | ||
64 | + R_RXFIFO_DATA2_DB4_LENGTH, | ||
65 | frame->data[7])); | ||
66 | |||
67 | ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOK, 1); | ||
68 | -- | ||
69 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Clément Chigot <chigot@adacore.com> | ||
2 | 1 | ||
3 | When requested, the alignment for VLD4.32 is 8 and not 16. | ||
4 | |||
5 | See ARM documentation about VLD4 encoding: | ||
6 | ebytes = 1 << UInt(size); | ||
7 | if size == '10' then | ||
8 | alignment = if a == '0' then 1 else 8; | ||
9 | else | ||
10 | alignment = if a == '0' then 1 else 4*ebytes; | ||
11 | |||
12 | Signed-off-by: Clément Chigot <chigot@adacore.com> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20220914105058.2787404-1-chigot@adacore.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | target/arm/translate-neon.c | 6 +++++- | ||
18 | 1 file changed, 5 insertions(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/translate-neon.c | ||
23 | +++ b/target/arm/translate-neon.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | ||
25 | case 3: | ||
26 | return false; | ||
27 | case 4: | ||
28 | - align = pow2_align(size + 2); | ||
29 | + if (size == 2) { | ||
30 | + align = pow2_align(3); | ||
31 | + } else { | ||
32 | + align = pow2_align(size + 2); | ||
33 | + } | ||
34 | break; | ||
35 | default: | ||
36 | g_assert_not_reached(); | ||
37 | -- | ||
38 | 2.25.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | cpu.h has a lot of #defines relating to CPU register fields. |
---|---|---|---|
2 | Most of these aren't actually used outside target/arm code, | ||
3 | so there's no point in cluttering up the cpu.h file with them. | ||
4 | Move some easy ones to internals.h. | ||
2 | 5 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20220822152741.1617527-10-richard.henderson@linaro.org | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20240301183219.2424889-2-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | target/arm/internals.h | 11 +++++------ | 11 | target/arm/cpu.h | 128 ----------------------------------------- |
10 | target/arm/m_helper.c | 16 +++++++--------- | 12 | target/arm/internals.h | 128 +++++++++++++++++++++++++++++++++++++++++ |
11 | target/arm/ptw.c | 20 +++++++++----------- | 13 | 2 files changed, 128 insertions(+), 128 deletions(-) |
12 | 3 files changed, 21 insertions(+), 26 deletions(-) | ||
13 | 14 | ||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMGenericTimer { | ||
20 | uint64_t ctl; /* Timer Control register */ | ||
21 | } ARMGenericTimer; | ||
22 | |||
23 | -#define VTCR_NSW (1u << 29) | ||
24 | -#define VTCR_NSA (1u << 30) | ||
25 | -#define VSTCR_SW VTCR_NSW | ||
26 | -#define VSTCR_SA VTCR_NSA | ||
27 | - | ||
28 | /* Define a maximum sized vector register. | ||
29 | * For 32-bit, this is a 128-bit NEON/AdvSIMD register. | ||
30 | * For 64-bit, this is a 2048-bit SVE register. | ||
31 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
32 | #define SCTLR_SPINTMASK (1ULL << 62) /* FEAT_NMI */ | ||
33 | #define SCTLR_TIDCP (1ULL << 63) /* FEAT_TIDCP1 */ | ||
34 | |||
35 | -/* Bit definitions for CPACR (AArch32 only) */ | ||
36 | -FIELD(CPACR, CP10, 20, 2) | ||
37 | -FIELD(CPACR, CP11, 22, 2) | ||
38 | -FIELD(CPACR, TRCDIS, 28, 1) /* matches CPACR_EL1.TTA */ | ||
39 | -FIELD(CPACR, D32DIS, 30, 1) /* up to v7; RAZ in v8 */ | ||
40 | -FIELD(CPACR, ASEDIS, 31, 1) | ||
41 | - | ||
42 | -/* Bit definitions for CPACR_EL1 (AArch64 only) */ | ||
43 | -FIELD(CPACR_EL1, ZEN, 16, 2) | ||
44 | -FIELD(CPACR_EL1, FPEN, 20, 2) | ||
45 | -FIELD(CPACR_EL1, SMEN, 24, 2) | ||
46 | -FIELD(CPACR_EL1, TTA, 28, 1) /* matches CPACR.TRCDIS */ | ||
47 | - | ||
48 | -/* Bit definitions for HCPTR (AArch32 only) */ | ||
49 | -FIELD(HCPTR, TCP10, 10, 1) | ||
50 | -FIELD(HCPTR, TCP11, 11, 1) | ||
51 | -FIELD(HCPTR, TASE, 15, 1) | ||
52 | -FIELD(HCPTR, TTA, 20, 1) | ||
53 | -FIELD(HCPTR, TAM, 30, 1) /* matches CPTR_EL2.TAM */ | ||
54 | -FIELD(HCPTR, TCPAC, 31, 1) /* matches CPTR_EL2.TCPAC */ | ||
55 | - | ||
56 | -/* Bit definitions for CPTR_EL2 (AArch64 only) */ | ||
57 | -FIELD(CPTR_EL2, TZ, 8, 1) /* !E2H */ | ||
58 | -FIELD(CPTR_EL2, TFP, 10, 1) /* !E2H, matches HCPTR.TCP10 */ | ||
59 | -FIELD(CPTR_EL2, TSM, 12, 1) /* !E2H */ | ||
60 | -FIELD(CPTR_EL2, ZEN, 16, 2) /* E2H */ | ||
61 | -FIELD(CPTR_EL2, FPEN, 20, 2) /* E2H */ | ||
62 | -FIELD(CPTR_EL2, SMEN, 24, 2) /* E2H */ | ||
63 | -FIELD(CPTR_EL2, TTA, 28, 1) | ||
64 | -FIELD(CPTR_EL2, TAM, 30, 1) /* matches HCPTR.TAM */ | ||
65 | -FIELD(CPTR_EL2, TCPAC, 31, 1) /* matches HCPTR.TCPAC */ | ||
66 | - | ||
67 | -/* Bit definitions for CPTR_EL3 (AArch64 only) */ | ||
68 | -FIELD(CPTR_EL3, EZ, 8, 1) | ||
69 | -FIELD(CPTR_EL3, TFP, 10, 1) | ||
70 | -FIELD(CPTR_EL3, ESM, 12, 1) | ||
71 | -FIELD(CPTR_EL3, TTA, 20, 1) | ||
72 | -FIELD(CPTR_EL3, TAM, 30, 1) | ||
73 | -FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
74 | - | ||
75 | -#define MDCR_MTPME (1U << 28) | ||
76 | -#define MDCR_TDCC (1U << 27) | ||
77 | -#define MDCR_HLP (1U << 26) /* MDCR_EL2 */ | ||
78 | -#define MDCR_SCCD (1U << 23) /* MDCR_EL3 */ | ||
79 | -#define MDCR_HCCD (1U << 23) /* MDCR_EL2 */ | ||
80 | -#define MDCR_EPMAD (1U << 21) | ||
81 | -#define MDCR_EDAD (1U << 20) | ||
82 | -#define MDCR_TTRF (1U << 19) | ||
83 | -#define MDCR_STE (1U << 18) /* MDCR_EL3 */ | ||
84 | -#define MDCR_SPME (1U << 17) /* MDCR_EL3 */ | ||
85 | -#define MDCR_HPMD (1U << 17) /* MDCR_EL2 */ | ||
86 | -#define MDCR_SDD (1U << 16) | ||
87 | -#define MDCR_SPD (3U << 14) | ||
88 | -#define MDCR_TDRA (1U << 11) | ||
89 | -#define MDCR_TDOSA (1U << 10) | ||
90 | -#define MDCR_TDA (1U << 9) | ||
91 | -#define MDCR_TDE (1U << 8) | ||
92 | -#define MDCR_HPME (1U << 7) | ||
93 | -#define MDCR_TPM (1U << 6) | ||
94 | -#define MDCR_TPMCR (1U << 5) | ||
95 | -#define MDCR_HPMN (0x1fU) | ||
96 | - | ||
97 | -/* Not all of the MDCR_EL3 bits are present in the 32-bit SDCR */ | ||
98 | -#define SDCR_VALID_MASK (MDCR_MTPME | MDCR_TDCC | MDCR_SCCD | \ | ||
99 | - MDCR_EPMAD | MDCR_EDAD | MDCR_TTRF | \ | ||
100 | - MDCR_STE | MDCR_SPME | MDCR_SPD) | ||
101 | - | ||
102 | #define CPSR_M (0x1fU) | ||
103 | #define CPSR_T (1U << 5) | ||
104 | #define CPSR_F (1U << 6) | ||
105 | @@ -XXX,XX +XXX,XX @@ FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
106 | #define XPSR_NZCV CPSR_NZCV | ||
107 | #define XPSR_IT CPSR_IT | ||
108 | |||
109 | -#define TTBCR_N (7U << 0) /* TTBCR.EAE==0 */ | ||
110 | -#define TTBCR_T0SZ (7U << 0) /* TTBCR.EAE==1 */ | ||
111 | -#define TTBCR_PD0 (1U << 4) | ||
112 | -#define TTBCR_PD1 (1U << 5) | ||
113 | -#define TTBCR_EPD0 (1U << 7) | ||
114 | -#define TTBCR_IRGN0 (3U << 8) | ||
115 | -#define TTBCR_ORGN0 (3U << 10) | ||
116 | -#define TTBCR_SH0 (3U << 12) | ||
117 | -#define TTBCR_T1SZ (3U << 16) | ||
118 | -#define TTBCR_A1 (1U << 22) | ||
119 | -#define TTBCR_EPD1 (1U << 23) | ||
120 | -#define TTBCR_IRGN1 (3U << 24) | ||
121 | -#define TTBCR_ORGN1 (3U << 26) | ||
122 | -#define TTBCR_SH1 (1U << 28) | ||
123 | -#define TTBCR_EAE (1U << 31) | ||
124 | - | ||
125 | -FIELD(VTCR, T0SZ, 0, 6) | ||
126 | -FIELD(VTCR, SL0, 6, 2) | ||
127 | -FIELD(VTCR, IRGN0, 8, 2) | ||
128 | -FIELD(VTCR, ORGN0, 10, 2) | ||
129 | -FIELD(VTCR, SH0, 12, 2) | ||
130 | -FIELD(VTCR, TG0, 14, 2) | ||
131 | -FIELD(VTCR, PS, 16, 3) | ||
132 | -FIELD(VTCR, VS, 19, 1) | ||
133 | -FIELD(VTCR, HA, 21, 1) | ||
134 | -FIELD(VTCR, HD, 22, 1) | ||
135 | -FIELD(VTCR, HWU59, 25, 1) | ||
136 | -FIELD(VTCR, HWU60, 26, 1) | ||
137 | -FIELD(VTCR, HWU61, 27, 1) | ||
138 | -FIELD(VTCR, HWU62, 28, 1) | ||
139 | -FIELD(VTCR, NSW, 29, 1) | ||
140 | -FIELD(VTCR, NSA, 30, 1) | ||
141 | -FIELD(VTCR, DS, 32, 1) | ||
142 | -FIELD(VTCR, SL2, 33, 1) | ||
143 | - | ||
144 | /* Bit definitions for ARMv8 SPSR (PSTATE) format. | ||
145 | * Only these are valid when in AArch64 mode; in | ||
146 | * AArch32 mode SPSRs are basically CPSR-format. | ||
147 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | ||
148 | #define HCR_TWEDEN (1ULL << 59) | ||
149 | #define HCR_TWEDEL MAKE_64BIT_MASK(60, 4) | ||
150 | |||
151 | -#define HCRX_ENAS0 (1ULL << 0) | ||
152 | -#define HCRX_ENALS (1ULL << 1) | ||
153 | -#define HCRX_ENASR (1ULL << 2) | ||
154 | -#define HCRX_FNXS (1ULL << 3) | ||
155 | -#define HCRX_FGTNXS (1ULL << 4) | ||
156 | -#define HCRX_SMPME (1ULL << 5) | ||
157 | -#define HCRX_TALLINT (1ULL << 6) | ||
158 | -#define HCRX_VINMI (1ULL << 7) | ||
159 | -#define HCRX_VFNMI (1ULL << 8) | ||
160 | -#define HCRX_CMOW (1ULL << 9) | ||
161 | -#define HCRX_MCE2 (1ULL << 10) | ||
162 | -#define HCRX_MSCEN (1ULL << 11) | ||
163 | - | ||
164 | -#define HPFAR_NS (1ULL << 63) | ||
165 | - | ||
166 | #define SCR_NS (1ULL << 0) | ||
167 | #define SCR_IRQ (1ULL << 1) | ||
168 | #define SCR_FIQ (1ULL << 2) | ||
169 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | ||
170 | #define SCR_GPF (1ULL << 48) | ||
171 | #define SCR_NSE (1ULL << 62) | ||
172 | |||
173 | -#define HSTR_TTEE (1 << 16) | ||
174 | -#define HSTR_TJDBX (1 << 17) | ||
175 | - | ||
176 | -#define CNTHCTL_CNTVMASK (1 << 18) | ||
177 | -#define CNTHCTL_CNTPMASK (1 << 19) | ||
178 | - | ||
179 | /* Return the current FPSCR value. */ | ||
180 | uint32_t vfp_get_fpscr(CPUARMState *env); | ||
181 | void vfp_set_fpscr(CPUARMState *env, uint32_t val); | ||
14 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 182 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
15 | index XXXXXXX..XXXXXXX 100644 | 183 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/internals.h | 184 | --- a/target/arm/internals.h |
17 | +++ b/target/arm/internals.h | 185 | +++ b/target/arm/internals.h |
18 | @@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address, | 186 | @@ -XXX,XX +XXX,XX @@ FIELD(DBGWCR, WT, 20, 1) |
19 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 187 | FIELD(DBGWCR, MASK, 24, 5) |
20 | V8M_SAttributes *sattrs); | 188 | FIELD(DBGWCR, SSCE, 29, 1) |
21 | 189 | ||
22 | -bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | 190 | +#define VTCR_NSW (1u << 29) |
23 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | 191 | +#define VTCR_NSA (1u << 30) |
24 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, | 192 | +#define VSTCR_SW VTCR_NSW |
25 | - int *prot, bool *is_subpage, | 193 | +#define VSTCR_SA VTCR_NSA |
26 | - ARMMMUFaultInfo *fi, uint32_t *mregion); | 194 | + |
27 | - | 195 | +/* Bit definitions for CPACR (AArch32 only) */ |
28 | /* Cacheability and shareability attributes for a memory access */ | 196 | +FIELD(CPACR, CP10, 20, 2) |
29 | typedef struct ARMCacheAttrs { | 197 | +FIELD(CPACR, CP11, 22, 2) |
30 | /* | 198 | +FIELD(CPACR, TRCDIS, 28, 1) /* matches CPACR_EL1.TTA */ |
31 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | 199 | +FIELD(CPACR, D32DIS, 30, 1) /* up to v7; RAZ in v8 */ |
32 | GetPhysAddrResult *result, ARMMMUFaultInfo *fi) | 200 | +FIELD(CPACR, ASEDIS, 31, 1) |
33 | __attribute__((nonnull)); | 201 | + |
34 | 202 | +/* Bit definitions for CPACR_EL1 (AArch64 only) */ | |
35 | +bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | 203 | +FIELD(CPACR_EL1, ZEN, 16, 2) |
36 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | 204 | +FIELD(CPACR_EL1, FPEN, 20, 2) |
37 | + GetPhysAddrResult *result, bool *is_subpage, | 205 | +FIELD(CPACR_EL1, SMEN, 24, 2) |
38 | + ARMMMUFaultInfo *fi, uint32_t *mregion); | 206 | +FIELD(CPACR_EL1, TTA, 28, 1) /* matches CPACR.TRCDIS */ |
39 | + | 207 | + |
40 | void arm_log_exception(CPUState *cs); | 208 | +/* Bit definitions for HCPTR (AArch32 only) */ |
41 | 209 | +FIELD(HCPTR, TCP10, 10, 1) | |
42 | #endif /* !CONFIG_USER_ONLY */ | 210 | +FIELD(HCPTR, TCP11, 11, 1) |
43 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 211 | +FIELD(HCPTR, TASE, 15, 1) |
44 | index XXXXXXX..XXXXXXX 100644 | 212 | +FIELD(HCPTR, TTA, 20, 1) |
45 | --- a/target/arm/m_helper.c | 213 | +FIELD(HCPTR, TAM, 30, 1) /* matches CPTR_EL2.TAM */ |
46 | +++ b/target/arm/m_helper.c | 214 | +FIELD(HCPTR, TCPAC, 31, 1) /* matches CPTR_EL2.TCPAC */ |
47 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 215 | + |
48 | V8M_SAttributes sattrs = {}; | 216 | +/* Bit definitions for CPTR_EL2 (AArch64 only) */ |
49 | uint32_t tt_resp; | 217 | +FIELD(CPTR_EL2, TZ, 8, 1) /* !E2H */ |
50 | bool r, rw, nsr, nsrw, mrvalid; | 218 | +FIELD(CPTR_EL2, TFP, 10, 1) /* !E2H, matches HCPTR.TCP10 */ |
51 | - int prot; | 219 | +FIELD(CPTR_EL2, TSM, 12, 1) /* !E2H */ |
52 | - ARMMMUFaultInfo fi = {}; | 220 | +FIELD(CPTR_EL2, ZEN, 16, 2) /* E2H */ |
53 | - MemTxAttrs attrs = {}; | 221 | +FIELD(CPTR_EL2, FPEN, 20, 2) /* E2H */ |
54 | - hwaddr phys_addr; | 222 | +FIELD(CPTR_EL2, SMEN, 24, 2) /* E2H */ |
55 | ARMMMUIdx mmu_idx; | 223 | +FIELD(CPTR_EL2, TTA, 28, 1) |
56 | uint32_t mregion; | 224 | +FIELD(CPTR_EL2, TAM, 30, 1) /* matches HCPTR.TAM */ |
57 | bool targetpriv; | 225 | +FIELD(CPTR_EL2, TCPAC, 31, 1) /* matches HCPTR.TCPAC */ |
58 | bool targetsec = env->v7m.secure; | 226 | + |
59 | - bool is_subpage; | 227 | +/* Bit definitions for CPTR_EL3 (AArch64 only) */ |
60 | 228 | +FIELD(CPTR_EL3, EZ, 8, 1) | |
61 | /* | 229 | +FIELD(CPTR_EL3, TFP, 10, 1) |
62 | * Work out what the security state and privilege level we're | 230 | +FIELD(CPTR_EL3, ESM, 12, 1) |
63 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 231 | +FIELD(CPTR_EL3, TTA, 20, 1) |
64 | * inspecting the other MPU state. | 232 | +FIELD(CPTR_EL3, TAM, 30, 1) |
65 | */ | 233 | +FIELD(CPTR_EL3, TCPAC, 31, 1) |
66 | if (arm_current_el(env) != 0 || alt) { | 234 | + |
67 | + GetPhysAddrResult res = {}; | 235 | +#define MDCR_MTPME (1U << 28) |
68 | + ARMMMUFaultInfo fi = {}; | 236 | +#define MDCR_TDCC (1U << 27) |
69 | + bool is_subpage; | 237 | +#define MDCR_HLP (1U << 26) /* MDCR_EL2 */ |
70 | + | 238 | +#define MDCR_SCCD (1U << 23) /* MDCR_EL3 */ |
71 | /* We can ignore the return value as prot is always set */ | 239 | +#define MDCR_HCCD (1U << 23) /* MDCR_EL2 */ |
72 | pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, | 240 | +#define MDCR_EPMAD (1U << 21) |
73 | - &phys_addr, &attrs, &prot, &is_subpage, | 241 | +#define MDCR_EDAD (1U << 20) |
74 | - &fi, &mregion); | 242 | +#define MDCR_TTRF (1U << 19) |
75 | + &res, &is_subpage, &fi, &mregion); | 243 | +#define MDCR_STE (1U << 18) /* MDCR_EL3 */ |
76 | if (mregion == -1) { | 244 | +#define MDCR_SPME (1U << 17) /* MDCR_EL3 */ |
77 | mrvalid = false; | 245 | +#define MDCR_HPMD (1U << 17) /* MDCR_EL2 */ |
78 | mregion = 0; | 246 | +#define MDCR_SDD (1U << 16) |
79 | } else { | 247 | +#define MDCR_SPD (3U << 14) |
80 | mrvalid = true; | 248 | +#define MDCR_TDRA (1U << 11) |
81 | } | 249 | +#define MDCR_TDOSA (1U << 10) |
82 | - r = prot & PAGE_READ; | 250 | +#define MDCR_TDA (1U << 9) |
83 | - rw = prot & PAGE_WRITE; | 251 | +#define MDCR_TDE (1U << 8) |
84 | + r = res.prot & PAGE_READ; | 252 | +#define MDCR_HPME (1U << 7) |
85 | + rw = res.prot & PAGE_WRITE; | 253 | +#define MDCR_TPM (1U << 6) |
86 | } else { | 254 | +#define MDCR_TPMCR (1U << 5) |
87 | r = false; | 255 | +#define MDCR_HPMN (0x1fU) |
88 | rw = false; | 256 | + |
89 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | 257 | +/* Not all of the MDCR_EL3 bits are present in the 32-bit SDCR */ |
90 | index XXXXXXX..XXXXXXX 100644 | 258 | +#define SDCR_VALID_MASK (MDCR_MTPME | MDCR_TDCC | MDCR_SCCD | \ |
91 | --- a/target/arm/ptw.c | 259 | + MDCR_EPMAD | MDCR_EDAD | MDCR_TTRF | \ |
92 | +++ b/target/arm/ptw.c | 260 | + MDCR_STE | MDCR_SPME | MDCR_SPD) |
93 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | 261 | + |
94 | 262 | +#define TTBCR_N (7U << 0) /* TTBCR.EAE==0 */ | |
95 | bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | 263 | +#define TTBCR_T0SZ (7U << 0) /* TTBCR.EAE==1 */ |
96 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 264 | +#define TTBCR_PD0 (1U << 4) |
97 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, | 265 | +#define TTBCR_PD1 (1U << 5) |
98 | - int *prot, bool *is_subpage, | 266 | +#define TTBCR_EPD0 (1U << 7) |
99 | + GetPhysAddrResult *result, bool *is_subpage, | 267 | +#define TTBCR_IRGN0 (3U << 8) |
100 | ARMMMUFaultInfo *fi, uint32_t *mregion) | 268 | +#define TTBCR_ORGN0 (3U << 10) |
101 | { | 269 | +#define TTBCR_SH0 (3U << 12) |
102 | /* | 270 | +#define TTBCR_T1SZ (3U << 16) |
103 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | 271 | +#define TTBCR_A1 (1U << 22) |
104 | uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1); | 272 | +#define TTBCR_EPD1 (1U << 23) |
105 | 273 | +#define TTBCR_IRGN1 (3U << 24) | |
106 | *is_subpage = false; | 274 | +#define TTBCR_ORGN1 (3U << 26) |
107 | - *phys_ptr = address; | 275 | +#define TTBCR_SH1 (1U << 28) |
108 | - *prot = 0; | 276 | +#define TTBCR_EAE (1U << 31) |
109 | + result->phys = address; | 277 | + |
110 | + result->prot = 0; | 278 | +FIELD(VTCR, T0SZ, 0, 6) |
111 | if (mregion) { | 279 | +FIELD(VTCR, SL0, 6, 2) |
112 | *mregion = -1; | 280 | +FIELD(VTCR, IRGN0, 8, 2) |
113 | } | 281 | +FIELD(VTCR, ORGN0, 10, 2) |
114 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | 282 | +FIELD(VTCR, SH0, 12, 2) |
115 | 283 | +FIELD(VTCR, TG0, 14, 2) | |
116 | if (matchregion == -1) { | 284 | +FIELD(VTCR, PS, 16, 3) |
117 | /* hit using the background region */ | 285 | +FIELD(VTCR, VS, 19, 1) |
118 | - get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); | 286 | +FIELD(VTCR, HA, 21, 1) |
119 | + get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot); | 287 | +FIELD(VTCR, HD, 22, 1) |
120 | } else { | 288 | +FIELD(VTCR, HWU59, 25, 1) |
121 | uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2); | 289 | +FIELD(VTCR, HWU60, 26, 1) |
122 | uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1); | 290 | +FIELD(VTCR, HWU61, 27, 1) |
123 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | 291 | +FIELD(VTCR, HWU62, 28, 1) |
124 | xn = 1; | 292 | +FIELD(VTCR, NSW, 29, 1) |
125 | } | 293 | +FIELD(VTCR, NSA, 30, 1) |
126 | 294 | +FIELD(VTCR, DS, 32, 1) | |
127 | - *prot = simple_ap_to_rw_prot(env, mmu_idx, ap); | 295 | +FIELD(VTCR, SL2, 33, 1) |
128 | - if (*prot && !xn && !(pxn && !is_user)) { | 296 | + |
129 | - *prot |= PAGE_EXEC; | 297 | +#define HCRX_ENAS0 (1ULL << 0) |
130 | + result->prot = simple_ap_to_rw_prot(env, mmu_idx, ap); | 298 | +#define HCRX_ENALS (1ULL << 1) |
131 | + if (result->prot && !xn && !(pxn && !is_user)) { | 299 | +#define HCRX_ENASR (1ULL << 2) |
132 | + result->prot |= PAGE_EXEC; | 300 | +#define HCRX_FNXS (1ULL << 3) |
133 | } | 301 | +#define HCRX_FGTNXS (1ULL << 4) |
134 | /* | 302 | +#define HCRX_SMPME (1ULL << 5) |
135 | * We don't need to look the attribute up in the MAIR0/MAIR1 | 303 | +#define HCRX_TALLINT (1ULL << 6) |
136 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | 304 | +#define HCRX_VINMI (1ULL << 7) |
137 | 305 | +#define HCRX_VFNMI (1ULL << 8) | |
138 | fi->type = ARMFault_Permission; | 306 | +#define HCRX_CMOW (1ULL << 9) |
139 | fi->level = 1; | 307 | +#define HCRX_MCE2 (1ULL << 10) |
140 | - return !(*prot & (1 << access_type)); | 308 | +#define HCRX_MSCEN (1ULL << 11) |
141 | + return !(result->prot & (1 << access_type)); | 309 | + |
142 | } | 310 | +#define HPFAR_NS (1ULL << 63) |
143 | 311 | + | |
144 | static bool v8m_is_sau_exempt(CPUARMState *env, | 312 | +#define HSTR_TTEE (1 << 16) |
145 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | 313 | +#define HSTR_TJDBX (1 << 17) |
146 | } | 314 | + |
147 | 315 | +#define CNTHCTL_CNTVMASK (1 << 18) | |
148 | ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, | 316 | +#define CNTHCTL_CNTPMASK (1 << 19) |
149 | - &result->phys, &result->attrs, &result->prot, | 317 | + |
150 | - &mpu_is_subpage, fi, NULL); | 318 | /* We use a few fake FSR values for internal purposes in M profile. |
151 | + result, &mpu_is_subpage, fi, NULL); | 319 | * M profile cores don't have A/R format FSRs, but currently our |
152 | result->page_size = | 320 | * get_phys_addr() code assumes A/R profile and reports failures via |
153 | sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE; | ||
154 | return ret; | ||
155 | -- | 321 | -- |
156 | 2.25.1 | 322 | 2.34.1 |
157 | 323 | ||
158 | 324 | diff view generated by jsdifflib |
1 | There's only one place in configure where we use `...` to execute a | 1 | The timer _EL02 registers should UNDEF for invalid accesses from EL2 |
---|---|---|---|
2 | command and capture the result. Switch to $() to match the rest of | 2 | or EL3 when HCR_EL2.E2H == 0, not take a cp access trap. We were |
3 | the script. This silences a shellcheck warning. | 3 | delivering the exception to EL2 with the wrong syndrome. |
4 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Message-id: 20240301183219.2424889-3-peter.maydell@linaro.org |
8 | Message-id: 20220825150703.4074125-6-peter.maydell@linaro.org | ||
9 | --- | 8 | --- |
10 | configure | 2 +- | 9 | target/arm/helper.c | 2 +- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 10 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 11 | ||
13 | diff --git a/configure b/configure | 12 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100755 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/configure | 14 | --- a/target/arm/helper.c |
16 | +++ b/configure | 15 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ LINKS="$LINKS python" | 16 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, |
18 | LINKS="$LINKS contrib/plugins/Makefile " | 17 | return CP_ACCESS_OK; |
19 | for f in $LINKS ; do | 18 | } |
20 | if [ -e "$source_path/$f" ]; then | 19 | if (!(arm_hcr_el2_eff(env) & HCR_E2H)) { |
21 | - mkdir -p `dirname ./$f` | 20 | - return CP_ACCESS_TRAP; |
22 | + mkdir -p "$(dirname ./"$f")" | 21 | + return CP_ACCESS_TRAP_UNCATEGORIZED; |
23 | symlink "$source_path/$f" "$f" | 22 | } |
24 | fi | 23 | return CP_ACCESS_OK; |
25 | done | 24 | } |
26 | -- | 25 | -- |
27 | 2.25.1 | 26 | 2.34.1 |
28 | |||
29 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | We prefer the FIELD macro over ad-hoc #defines for register bits; |
---|---|---|---|
2 | switch CNTHCTL to that style before we add any more bits. | ||
2 | 3 | ||
3 | Remove the use of regime_is_secure from v8m_security_lookup, | ||
4 | passing the new parameter to the lookup instead. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220822152741.1617527-12-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20240301183219.2424889-4-peter.maydell@linaro.org | ||
11 | --- | 8 | --- |
12 | target/arm/internals.h | 2 +- | 9 | target/arm/internals.h | 27 +++++++++++++++++++++++++-- |
13 | target/arm/m_helper.c | 9 ++++++--- | 10 | target/arm/helper.c | 9 ++++----- |
14 | target/arm/ptw.c | 9 +++++---- | 11 | 2 files changed, 29 insertions(+), 7 deletions(-) |
15 | 3 files changed, 12 insertions(+), 8 deletions(-) | ||
16 | 12 | ||
17 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 13 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/internals.h | 15 | --- a/target/arm/internals.h |
20 | +++ b/target/arm/internals.h | 16 | +++ b/target/arm/internals.h |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct V8M_SAttributes { | 17 | @@ -XXX,XX +XXX,XX @@ FIELD(VTCR, SL2, 33, 1) |
22 | 18 | #define HSTR_TTEE (1 << 16) | |
23 | void v8m_security_lookup(CPUARMState *env, uint32_t address, | 19 | #define HSTR_TJDBX (1 << 17) |
24 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 20 | |
25 | - V8M_SAttributes *sattrs); | 21 | -#define CNTHCTL_CNTVMASK (1 << 18) |
26 | + bool secure, V8M_SAttributes *sattrs); | 22 | -#define CNTHCTL_CNTPMASK (1 << 19) |
27 | 23 | +/* | |
28 | /* Cacheability and shareability attributes for a memory access */ | 24 | + * Depending on the value of HCR_EL2.E2H, bits 0 and 1 |
29 | typedef struct ARMCacheAttrs { | 25 | + * have different bit definitions, and EL1PCTEN might be |
30 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 26 | + * bit 0 or bit 10. We use _E2H1 and _E2H0 suffixes to |
27 | + * disambiguate if necessary. | ||
28 | + */ | ||
29 | +FIELD(CNTHCTL, EL0PCTEN_E2H1, 0, 1) | ||
30 | +FIELD(CNTHCTL, EL0VCTEN_E2H1, 1, 1) | ||
31 | +FIELD(CNTHCTL, EL1PCTEN_E2H0, 0, 1) | ||
32 | +FIELD(CNTHCTL, EL1PCEN_E2H0, 1, 1) | ||
33 | +FIELD(CNTHCTL, EVNTEN, 2, 1) | ||
34 | +FIELD(CNTHCTL, EVNTDIR, 3, 1) | ||
35 | +FIELD(CNTHCTL, EVNTI, 4, 4) | ||
36 | +FIELD(CNTHCTL, EL0VTEN, 8, 1) | ||
37 | +FIELD(CNTHCTL, EL0PTEN, 9, 1) | ||
38 | +FIELD(CNTHCTL, EL1PCTEN_E2H1, 10, 1) | ||
39 | +FIELD(CNTHCTL, EL1PTEN, 11, 1) | ||
40 | +FIELD(CNTHCTL, ECV, 12, 1) | ||
41 | +FIELD(CNTHCTL, EL1TVT, 13, 1) | ||
42 | +FIELD(CNTHCTL, EL1TVCT, 14, 1) | ||
43 | +FIELD(CNTHCTL, EL1NVPCT, 15, 1) | ||
44 | +FIELD(CNTHCTL, EL1NVVCT, 16, 1) | ||
45 | +FIELD(CNTHCTL, EVNTIS, 17, 1) | ||
46 | +FIELD(CNTHCTL, CNTVMASK, 18, 1) | ||
47 | +FIELD(CNTHCTL, CNTPMASK, 19, 1) | ||
48 | |||
49 | /* We use a few fake FSR values for internal purposes in M profile. | ||
50 | * M profile cores don't have A/R format FSRs, but currently our | ||
51 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/target/arm/m_helper.c | 53 | --- a/target/arm/helper.c |
33 | +++ b/target/arm/m_helper.c | 54 | +++ b/target/arm/helper.c |
34 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, | 55 | @@ -XXX,XX +XXX,XX @@ static void gt_update_irq(ARMCPU *cpu, int timeridx) |
35 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | 56 | * It is RES0 in Secure and NonSecure state. |
36 | V8M_SAttributes sattrs = {}; | 57 | */ |
37 | 58 | if ((ss == ARMSS_Root || ss == ARMSS_Realm) && | |
38 | - v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, &sattrs); | 59 | - ((timeridx == GTIMER_VIRT && (cnthctl & CNTHCTL_CNTVMASK)) || |
39 | + v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, | 60 | - (timeridx == GTIMER_PHYS && (cnthctl & CNTHCTL_CNTPMASK)))) { |
40 | + targets_secure, &sattrs); | 61 | + ((timeridx == GTIMER_VIRT && (cnthctl & R_CNTHCTL_CNTVMASK_MASK)) || |
41 | if (sattrs.ns) { | 62 | + (timeridx == GTIMER_PHYS && (cnthctl & R_CNTHCTL_CNTPMASK_MASK)))) { |
42 | attrs.secure = false; | 63 | irqstate = 0; |
43 | } else if (!targets_secure) { | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
45 | ARMMMUFaultInfo fi = {}; | ||
46 | MemTxResult txres; | ||
47 | |||
48 | - v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, &sattrs); | ||
49 | + v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, | ||
50 | + regime_is_secure(env, mmu_idx), &sattrs); | ||
51 | if (!sattrs.nsc || sattrs.ns) { | ||
52 | /* | ||
53 | * This must be the second half of the insn, and it straddles a | ||
54 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
55 | } | 64 | } |
56 | 65 | ||
57 | if (env->v7m.secure) { | 66 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, |
58 | - v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, &sattrs); | 67 | { |
59 | + v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, | 68 | ARMCPU *cpu = env_archcpu(env); |
60 | + targetsec, &sattrs); | 69 | uint32_t oldval = env->cp15.cnthctl_el2; |
61 | nsr = sattrs.ns && r; | 70 | - |
62 | nsrw = sattrs.ns && rw; | 71 | raw_write(env, ri, value); |
63 | } else { | 72 | |
64 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | 73 | - if ((oldval ^ value) & CNTHCTL_CNTVMASK) { |
65 | index XXXXXXX..XXXXXXX 100644 | 74 | + if ((oldval ^ value) & R_CNTHCTL_CNTVMASK_MASK) { |
66 | --- a/target/arm/ptw.c | 75 | gt_update_irq(cpu, GTIMER_VIRT); |
67 | +++ b/target/arm/ptw.c | 76 | - } else if ((oldval ^ value) & CNTHCTL_CNTPMASK) { |
68 | @@ -XXX,XX +XXX,XX @@ static bool v8m_is_sau_exempt(CPUARMState *env, | 77 | + } else if ((oldval ^ value) & R_CNTHCTL_CNTPMASK_MASK) { |
78 | gt_update_irq(cpu, GTIMER_PHYS); | ||
79 | } | ||
69 | } | 80 | } |
70 | |||
71 | void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
72 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
73 | - V8M_SAttributes *sattrs) | ||
74 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
75 | + bool is_secure, V8M_SAttributes *sattrs) | ||
76 | { | ||
77 | /* | ||
78 | * Look up the security attributes for this address. Compare the | ||
79 | @@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
80 | } | ||
81 | |||
82 | if (idau_exempt || v8m_is_sau_exempt(env, address, access_type)) { | ||
83 | - sattrs->ns = !regime_is_secure(env, mmu_idx); | ||
84 | + sattrs->ns = !is_secure; | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
89 | bool ret; | ||
90 | |||
91 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
92 | - v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs); | ||
93 | + v8m_security_lookup(env, address, access_type, mmu_idx, | ||
94 | + secure, &sattrs); | ||
95 | if (access_type == MMU_INST_FETCH) { | ||
96 | /* | ||
97 | * Instruction fetches always use the MMU bank and the | ||
98 | -- | 81 | -- |
99 | 2.25.1 | 82 | 2.34.1 |
100 | 83 | ||
101 | 84 | diff view generated by jsdifflib |
1 | We use the non-POSIX 'local' keyword in just two places in configure; | 1 | Don't allow the guest to write CNTHCTL_EL2 bits which don't exist. |
---|---|---|---|
2 | rewrite to avoid it. | 2 | This is not strictly architecturally required, but it is how we've |
3 | tended to implement registers more recently. | ||
3 | 4 | ||
4 | In do_compiler(), just drop the 'local' keyword. The variable | 5 | In particular, bits [19:18] are only present with FEAT_RME, |
5 | 'compiler' is only used elsewhere in the do_compiler_werror() | 6 | and bits [17:12] will only be present with FEAT_ECV. |
6 | function, which already uses the variable as a normal non-local one. | ||
7 | |||
8 | In probe_target_compiler(), $try and $t are both local; make them | ||
9 | normal variables and use a more obviously distinct variable name | ||
10 | for $t. | ||
11 | 7 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 10 | Message-id: 20240301183219.2424889-5-peter.maydell@linaro.org |
15 | Message-id: 20220825150703.4074125-8-peter.maydell@linaro.org | ||
16 | --- | 11 | --- |
17 | configure | 7 +++---- | 12 | target/arm/helper.c | 18 ++++++++++++++++++ |
18 | 1 file changed, 3 insertions(+), 4 deletions(-) | 13 | 1 file changed, 18 insertions(+) |
19 | 14 | ||
20 | diff --git a/configure b/configure | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100755 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/configure | 17 | --- a/target/arm/helper.c |
23 | +++ b/configure | 18 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ error_exit() { | 19 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, |
25 | do_compiler() { | 20 | { |
26 | # Run the compiler, capturing its output to the log. First argument | 21 | ARMCPU *cpu = env_archcpu(env); |
27 | # is compiler binary to execute. | 22 | uint32_t oldval = env->cp15.cnthctl_el2; |
28 | - local compiler="$1" | 23 | + uint32_t valid_mask = |
29 | + compiler="$1" | 24 | + R_CNTHCTL_EL0PCTEN_E2H1_MASK | |
30 | shift | 25 | + R_CNTHCTL_EL0VCTEN_E2H1_MASK | |
31 | if test -n "$BASH_VERSION"; then eval ' | 26 | + R_CNTHCTL_EVNTEN_MASK | |
32 | echo >>config.log " | 27 | + R_CNTHCTL_EVNTDIR_MASK | |
33 | @@ -XXX,XX +XXX,XX @@ probe_target_compiler() { | 28 | + R_CNTHCTL_EVNTI_MASK | |
34 | : ${container_cross_strip:=${container_cross_prefix}strip} | 29 | + R_CNTHCTL_EL0VTEN_MASK | |
35 | done | 30 | + R_CNTHCTL_EL0PTEN_MASK | |
36 | 31 | + R_CNTHCTL_EL1PCTEN_E2H1_MASK | | |
37 | - local t try | 32 | + R_CNTHCTL_EL1PTEN_MASK; |
38 | try=cross | 33 | + |
39 | case "$target_arch:$cpu" in | 34 | + if (cpu_isar_feature(aa64_rme, cpu)) { |
40 | aarch64_be:aarch64 | \ | 35 | + valid_mask |= R_CNTHCTL_CNTVMASK_MASK | R_CNTHCTL_CNTPMASK_MASK; |
41 | @@ -XXX,XX +XXX,XX @@ probe_target_compiler() { | 36 | + } |
42 | try='native cross' ;; | 37 | + |
43 | esac | 38 | + /* Clear RES0 bits */ |
44 | eval "target_cflags=\${cross_cc_cflags_$target_arch}" | 39 | + value &= valid_mask; |
45 | - for t in $try; do | 40 | + |
46 | - case $t in | 41 | raw_write(env, ri, value); |
47 | + for thistry in $try; do | 42 | |
48 | + case $thistry in | 43 | if ((oldval ^ value) & R_CNTHCTL_CNTVMASK_MASK) { |
49 | native) | ||
50 | target_cc=$cc | ||
51 | target_ccas=$ccas | ||
52 | -- | 44 | -- |
53 | 2.25.1 | 45 | 2.34.1 |
54 | |||
55 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The functionality defined by ID_AA64MMFR0_EL1.ECV == 1 is: |
---|---|---|---|
2 | * four new trap bits for various counter and timer registers | ||
3 | * the CNTHCTL_EL2.EVNTIS and CNTKCTL_EL1.EVNTIS bits which control | ||
4 | scaling of the event stream. This is a no-op for us, because we don't | ||
5 | implement the event stream (our WFE is a NOP): all we need to do is | ||
6 | allow CNTHCTL_EL2.ENVTIS to be read and written. | ||
7 | * extensions to PMSCR_EL1.PCT, PMSCR_EL2.PCT, TRFCR_EL1.TS and | ||
8 | TRFCR_EL2.TS: these are all no-ops for us, because we don't implement | ||
9 | FEAT_SPE or FEAT_TRF. | ||
10 | * new registers CNTPCTSS_EL0 and NCTVCTSS_EL0 which are | ||
11 | "self-sychronizing" views of the CNTPCT_EL0 and CNTVCT_EL0, meaning | ||
12 | that no barriers are needed around their accesses. For us these | ||
13 | are just the same as the normal views, because all our sysregs are | ||
14 | inherently self-sychronizing. | ||
2 | 15 | ||
3 | Combine 5 output pointer arguments from get_phys_addr | 16 | In this commit we implement the trap handling and permit the new |
4 | into a single struct. Adjust all callers. | 17 | CNTHCTL_EL2 bits to be written. |
5 | 18 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220822152741.1617527-2-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20240301183219.2424889-6-peter.maydell@linaro.org | ||
10 | --- | 22 | --- |
11 | target/arm/internals.h | 13 ++++- | 23 | target/arm/cpu-features.h | 5 ++++ |
12 | target/arm/helper.c | 27 ++++----- | 24 | target/arm/helper.c | 51 +++++++++++++++++++++++++++++++++++---- |
13 | target/arm/m_helper.c | 52 ++++++----------- | 25 | 2 files changed, 51 insertions(+), 5 deletions(-) |
14 | target/arm/ptw.c | 120 +++++++++++++++++++++------------------- | ||
15 | target/arm/tlb_helper.c | 22 +++----- | ||
16 | 5 files changed, 109 insertions(+), 125 deletions(-) | ||
17 | 26 | ||
18 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 27 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
19 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/internals.h | 29 | --- a/target/arm/cpu-features.h |
21 | +++ b/target/arm/internals.h | 30 | +++ b/target/arm/cpu-features.h |
22 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMCacheAttrs { | 31 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fgt(const ARMISARegisters *id) |
23 | bool is_s2_format:1; | 32 | return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, FGT) != 0; |
24 | } ARMCacheAttrs; | 33 | } |
25 | 34 | ||
26 | +/* Fields that are valid upon success. */ | 35 | +static inline bool isar_feature_aa64_ecv_traps(const ARMISARegisters *id) |
27 | +typedef struct GetPhysAddrResult { | 36 | +{ |
28 | + hwaddr phys; | 37 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 0; |
29 | + target_ulong page_size; | 38 | +} |
30 | + int prot; | ||
31 | + MemTxAttrs attrs; | ||
32 | + ARMCacheAttrs cacheattrs; | ||
33 | +} GetPhysAddrResult; | ||
34 | + | 39 | + |
35 | bool get_phys_addr(CPUARMState *env, target_ulong address, | 40 | static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) |
36 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 41 | { |
37 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | 42 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; |
38 | - target_ulong *page_size, | ||
39 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
40 | + GetPhysAddrResult *result, ARMMMUFaultInfo *fi) | ||
41 | __attribute__((nonnull)); | ||
42 | |||
43 | void arm_log_exception(CPUState *cs); | ||
44 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 43 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
45 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/target/arm/helper.c | 45 | --- a/target/arm/helper.c |
47 | +++ b/target/arm/helper.c | 46 | +++ b/target/arm/helper.c |
48 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri, | 47 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx, |
49 | static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | 48 | : !extract32(env->cp15.cnthctl_el2, 0, 1))) { |
50 | MMUAccessType access_type, ARMMMUIdx mmu_idx) | 49 | return CP_ACCESS_TRAP_EL2; |
51 | { | ||
52 | - hwaddr phys_addr; | ||
53 | - target_ulong page_size; | ||
54 | - int prot; | ||
55 | bool ret; | ||
56 | uint64_t par64; | ||
57 | bool format64 = false; | ||
58 | - MemTxAttrs attrs = {}; | ||
59 | ARMMMUFaultInfo fi = {}; | ||
60 | - ARMCacheAttrs cacheattrs = {}; | ||
61 | + GetPhysAddrResult res = {}; | ||
62 | |||
63 | - ret = get_phys_addr(env, value, access_type, mmu_idx, &phys_addr, &attrs, | ||
64 | - &prot, &page_size, &fi, &cacheattrs); | ||
65 | + ret = get_phys_addr(env, value, access_type, mmu_idx, &res, &fi); | ||
66 | |||
67 | /* | ||
68 | * ATS operations only do S1 or S1+S2 translations, so we never | ||
69 | * have to deal with the ARMCacheAttrs format for S2 only. | ||
70 | */ | ||
71 | - assert(!cacheattrs.is_s2_format); | ||
72 | + assert(!res.cacheattrs.is_s2_format); | ||
73 | |||
74 | if (ret) { | ||
75 | /* | ||
76 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | ||
77 | /* Create a 64-bit PAR */ | ||
78 | par64 = (1 << 11); /* LPAE bit always set */ | ||
79 | if (!ret) { | ||
80 | - par64 |= phys_addr & ~0xfffULL; | ||
81 | - if (!attrs.secure) { | ||
82 | + par64 |= res.phys & ~0xfffULL; | ||
83 | + if (!res.attrs.secure) { | ||
84 | par64 |= (1 << 9); /* NS */ | ||
85 | } | ||
86 | - par64 |= (uint64_t)cacheattrs.attrs << 56; /* ATTR */ | ||
87 | - par64 |= cacheattrs.shareability << 7; /* SH */ | ||
88 | + par64 |= (uint64_t)res.cacheattrs.attrs << 56; /* ATTR */ | ||
89 | + par64 |= res.cacheattrs.shareability << 7; /* SH */ | ||
90 | } else { | ||
91 | uint32_t fsr = arm_fi_to_lfsc(&fi); | ||
92 | |||
93 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | ||
94 | */ | ||
95 | if (!ret) { | ||
96 | /* We do not set any attribute bits in the PAR */ | ||
97 | - if (page_size == (1 << 24) | ||
98 | + if (res.page_size == (1 << 24) | ||
99 | && arm_feature(env, ARM_FEATURE_V7)) { | ||
100 | - par64 = (phys_addr & 0xff000000) | (1 << 1); | ||
101 | + par64 = (res.phys & 0xff000000) | (1 << 1); | ||
102 | } else { | ||
103 | - par64 = phys_addr & 0xfffff000; | ||
104 | + par64 = res.phys & 0xfffff000; | ||
105 | } | ||
106 | - if (!attrs.secure) { | ||
107 | + if (!res.attrs.secure) { | ||
108 | par64 |= (1 << 9); /* NS */ | ||
109 | } | ||
110 | } else { | ||
111 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/target/arm/m_helper.c | ||
114 | +++ b/target/arm/m_helper.c | ||
115 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | ||
116 | { | ||
117 | CPUState *cs = CPU(cpu); | ||
118 | CPUARMState *env = &cpu->env; | ||
119 | - MemTxAttrs attrs = {}; | ||
120 | MemTxResult txres; | ||
121 | - target_ulong page_size; | ||
122 | - hwaddr physaddr; | ||
123 | - int prot; | ||
124 | + GetPhysAddrResult res = {}; | ||
125 | ARMMMUFaultInfo fi = {}; | ||
126 | - ARMCacheAttrs cacheattrs = {}; | ||
127 | bool secure = mmu_idx & ARM_MMU_IDX_M_S; | ||
128 | int exc; | ||
129 | bool exc_secure; | ||
130 | |||
131 | - if (get_phys_addr(env, addr, MMU_DATA_STORE, mmu_idx, &physaddr, | ||
132 | - &attrs, &prot, &page_size, &fi, &cacheattrs)) { | ||
133 | + if (get_phys_addr(env, addr, MMU_DATA_STORE, mmu_idx, &res, &fi)) { | ||
134 | /* MPU/SAU lookup failed */ | ||
135 | if (fi.type == ARMFault_QEMU_SFault) { | ||
136 | if (mode == STACK_LAZYFP) { | ||
137 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | ||
138 | } | 50 | } |
139 | goto pend_fault; | 51 | + if (has_el2 && timeridx == GTIMER_VIRT) { |
52 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1TVCT)) { | ||
53 | + return CP_ACCESS_TRAP_EL2; | ||
54 | + } | ||
55 | + } | ||
56 | break; | ||
140 | } | 57 | } |
141 | - address_space_stl_le(arm_addressspace(cs, attrs), physaddr, value, | 58 | return CP_ACCESS_OK; |
142 | - attrs, &txres); | 59 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_timer_access(CPUARMState *env, int timeridx, |
143 | + address_space_stl_le(arm_addressspace(cs, res.attrs), res.phys, value, | ||
144 | + res.attrs, &txres); | ||
145 | if (txres != MEMTX_OK) { | ||
146 | /* BusFault trying to write the data */ | ||
147 | if (mode == STACK_LAZYFP) { | ||
148 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr, | ||
149 | { | ||
150 | CPUState *cs = CPU(cpu); | ||
151 | CPUARMState *env = &cpu->env; | ||
152 | - MemTxAttrs attrs = {}; | ||
153 | MemTxResult txres; | ||
154 | - target_ulong page_size; | ||
155 | - hwaddr physaddr; | ||
156 | - int prot; | ||
157 | + GetPhysAddrResult res = {}; | ||
158 | ARMMMUFaultInfo fi = {}; | ||
159 | - ARMCacheAttrs cacheattrs = {}; | ||
160 | bool secure = mmu_idx & ARM_MMU_IDX_M_S; | ||
161 | int exc; | ||
162 | bool exc_secure; | ||
163 | uint32_t value; | ||
164 | |||
165 | - if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &physaddr, | ||
166 | - &attrs, &prot, &page_size, &fi, &cacheattrs)) { | ||
167 | + if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi)) { | ||
168 | /* MPU/SAU lookup failed */ | ||
169 | if (fi.type == ARMFault_QEMU_SFault) { | ||
170 | qemu_log_mask(CPU_LOG_INT, | ||
171 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr, | ||
172 | goto pend_fault; | ||
173 | } | ||
174 | |||
175 | - value = address_space_ldl(arm_addressspace(cs, attrs), physaddr, | ||
176 | - attrs, &txres); | ||
177 | + value = address_space_ldl(arm_addressspace(cs, res.attrs), res.phys, | ||
178 | + res.attrs, &txres); | ||
179 | if (txres != MEMTX_OK) { | ||
180 | /* BusFault trying to read the data */ | ||
181 | qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.UNSTKERR\n"); | ||
182 | @@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
183 | CPUState *cs = CPU(cpu); | ||
184 | CPUARMState *env = &cpu->env; | ||
185 | V8M_SAttributes sattrs = {}; | ||
186 | - MemTxAttrs attrs = {}; | ||
187 | + GetPhysAddrResult res = {}; | ||
188 | ARMMMUFaultInfo fi = {}; | ||
189 | - ARMCacheAttrs cacheattrs = {}; | ||
190 | MemTxResult txres; | ||
191 | - target_ulong page_size; | ||
192 | - hwaddr physaddr; | ||
193 | - int prot; | ||
194 | |||
195 | v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, &sattrs); | ||
196 | if (!sattrs.nsc || sattrs.ns) { | ||
197 | @@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
198 | "...really SecureFault with SFSR.INVEP\n"); | ||
199 | return false; | ||
200 | } | ||
201 | - if (get_phys_addr(env, addr, MMU_INST_FETCH, mmu_idx, &physaddr, | ||
202 | - &attrs, &prot, &page_size, &fi, &cacheattrs)) { | ||
203 | + if (get_phys_addr(env, addr, MMU_INST_FETCH, mmu_idx, &res, &fi)) { | ||
204 | /* the MPU lookup failed */ | ||
205 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK; | ||
206 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM, env->v7m.secure); | ||
207 | qemu_log_mask(CPU_LOG_INT, "...really MemManage with CFSR.IACCVIOL\n"); | ||
208 | return false; | ||
209 | } | ||
210 | - *insn = address_space_lduw_le(arm_addressspace(cs, attrs), physaddr, | ||
211 | - attrs, &txres); | ||
212 | + *insn = address_space_lduw_le(arm_addressspace(cs, res.attrs), res.phys, | ||
213 | + res.attrs, &txres); | ||
214 | if (txres != MEMTX_OK) { | ||
215 | env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK; | ||
216 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); | ||
217 | @@ -XXX,XX +XXX,XX @@ static bool v7m_read_sg_stack_word(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
218 | */ | ||
219 | CPUState *cs = CPU(cpu); | ||
220 | CPUARMState *env = &cpu->env; | ||
221 | - MemTxAttrs attrs = {}; | ||
222 | MemTxResult txres; | ||
223 | - target_ulong page_size; | ||
224 | - hwaddr physaddr; | ||
225 | - int prot; | ||
226 | + GetPhysAddrResult res = {}; | ||
227 | ARMMMUFaultInfo fi = {}; | ||
228 | - ARMCacheAttrs cacheattrs = {}; | ||
229 | uint32_t value; | ||
230 | |||
231 | - if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &physaddr, | ||
232 | - &attrs, &prot, &page_size, &fi, &cacheattrs)) { | ||
233 | + if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi)) { | ||
234 | /* MPU/SAU lookup failed */ | ||
235 | if (fi.type == ARMFault_QEMU_SFault) { | ||
236 | qemu_log_mask(CPU_LOG_INT, | ||
237 | @@ -XXX,XX +XXX,XX @@ static bool v7m_read_sg_stack_word(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
238 | } | ||
239 | return false; | ||
240 | } | ||
241 | - value = address_space_ldl(arm_addressspace(cs, attrs), physaddr, | ||
242 | - attrs, &txres); | ||
243 | + value = address_space_ldl(arm_addressspace(cs, res.attrs), res.phys, | ||
244 | + res.attrs, &txres); | ||
245 | if (txres != MEMTX_OK) { | ||
246 | /* BusFault trying to read the data */ | ||
247 | qemu_log_mask(CPU_LOG_INT, | ||
248 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
249 | index XXXXXXX..XXXXXXX 100644 | ||
250 | --- a/target/arm/ptw.c | ||
251 | +++ b/target/arm/ptw.c | ||
252 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(CPUARMState *env, | ||
253 | * @address: virtual address to get physical address for | ||
254 | * @access_type: 0 for read, 1 for write, 2 for execute | ||
255 | * @mmu_idx: MMU index indicating required translation regime | ||
256 | - * @phys_ptr: set to the physical address corresponding to the virtual address | ||
257 | - * @attrs: set to the memory transaction attributes to use | ||
258 | - * @prot: set to the permissions for the page containing phys_ptr | ||
259 | - * @page_size: set to the size of the page containing phys_ptr | ||
260 | + * @result: set on translation success. | ||
261 | * @fi: set to fault info if the translation fails | ||
262 | - * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | ||
263 | */ | ||
264 | bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
265 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
266 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
267 | - target_ulong *page_size, | ||
268 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
269 | + GetPhysAddrResult *result, ARMMMUFaultInfo *fi) | ||
270 | { | ||
271 | ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx); | ||
272 | |||
273 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
274 | */ | ||
275 | if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
276 | hwaddr ipa; | ||
277 | - int s2_prot; | ||
278 | + int s1_prot; | ||
279 | int ret; | ||
280 | bool ipa_secure; | ||
281 | - ARMCacheAttrs cacheattrs2 = {}; | ||
282 | + ARMCacheAttrs cacheattrs1; | ||
283 | ARMMMUIdx s2_mmu_idx; | ||
284 | bool is_el0; | ||
285 | |||
286 | - ret = get_phys_addr(env, address, access_type, s1_mmu_idx, &ipa, | ||
287 | - attrs, prot, page_size, fi, cacheattrs); | ||
288 | + ret = get_phys_addr(env, address, access_type, s1_mmu_idx, | ||
289 | + result, fi); | ||
290 | |||
291 | /* If S1 fails or S2 is disabled, return early. */ | ||
292 | if (ret || regime_translation_disabled(env, ARMMMUIdx_Stage2)) { | ||
293 | - *phys_ptr = ipa; | ||
294 | return ret; | ||
295 | } | ||
296 | |||
297 | - ipa_secure = attrs->secure; | ||
298 | + ipa = result->phys; | ||
299 | + ipa_secure = result->attrs.secure; | ||
300 | if (arm_is_secure_below_el3(env)) { | ||
301 | if (ipa_secure) { | ||
302 | - attrs->secure = !(env->cp15.vstcr_el2 & VSTCR_SW); | ||
303 | + result->attrs.secure = !(env->cp15.vstcr_el2 & VSTCR_SW); | ||
304 | } else { | ||
305 | - attrs->secure = !(env->cp15.vtcr_el2 & VTCR_NSW); | ||
306 | + result->attrs.secure = !(env->cp15.vtcr_el2 & VTCR_NSW); | ||
307 | } | 60 | } |
308 | } else { | ||
309 | assert(!ipa_secure); | ||
310 | } | ||
311 | |||
312 | - s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; | ||
313 | + s2_mmu_idx = (result->attrs.secure | ||
314 | + ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2); | ||
315 | is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0; | ||
316 | |||
317 | - /* S1 is done. Now do S2 translation. */ | ||
318 | + /* | ||
319 | + * S1 is done, now do S2 translation. | ||
320 | + * Save the stage1 results so that we may merge | ||
321 | + * prot and cacheattrs later. | ||
322 | + */ | ||
323 | + s1_prot = result->prot; | ||
324 | + cacheattrs1 = result->cacheattrs; | ||
325 | + memset(result, 0, sizeof(*result)); | ||
326 | + | ||
327 | ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, is_el0, | ||
328 | - phys_ptr, attrs, &s2_prot, | ||
329 | - page_size, fi, &cacheattrs2); | ||
330 | + &result->phys, &result->attrs, | ||
331 | + &result->prot, &result->page_size, | ||
332 | + fi, &result->cacheattrs); | ||
333 | fi->s2addr = ipa; | ||
334 | + | ||
335 | /* Combine the S1 and S2 perms. */ | ||
336 | - *prot &= s2_prot; | ||
337 | + result->prot &= s1_prot; | ||
338 | |||
339 | /* If S2 fails, return early. */ | ||
340 | if (ret) { | ||
341 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
342 | * Outer Write-Back Read-Allocate Write-Allocate. | ||
343 | * Do not overwrite Tagged within attrs. | ||
344 | */ | ||
345 | - if (cacheattrs->attrs != 0xf0) { | ||
346 | - cacheattrs->attrs = 0xff; | ||
347 | + if (cacheattrs1.attrs != 0xf0) { | ||
348 | + cacheattrs1.attrs = 0xff; | ||
349 | } | ||
350 | - cacheattrs->shareability = 0; | ||
351 | + cacheattrs1.shareability = 0; | ||
352 | } | ||
353 | - *cacheattrs = combine_cacheattrs(env, *cacheattrs, cacheattrs2); | ||
354 | + result->cacheattrs = combine_cacheattrs(env, cacheattrs1, | ||
355 | + result->cacheattrs); | ||
356 | |||
357 | /* Check if IPA translates to secure or non-secure PA space. */ | ||
358 | if (arm_is_secure_below_el3(env)) { | ||
359 | if (ipa_secure) { | ||
360 | - attrs->secure = | ||
361 | + result->attrs.secure = | ||
362 | !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)); | ||
363 | } else { | ||
364 | - attrs->secure = | ||
365 | + result->attrs.secure = | ||
366 | !((env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW)) | ||
367 | || (env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW))); | ||
368 | } | ||
369 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
370 | * cannot upgrade an non-secure translation regime's attributes | ||
371 | * to secure. | ||
372 | */ | ||
373 | - attrs->secure = regime_is_secure(env, mmu_idx); | ||
374 | - attrs->user = regime_is_user(env, mmu_idx); | ||
375 | + result->attrs.secure = regime_is_secure(env, mmu_idx); | ||
376 | + result->attrs.user = regime_is_user(env, mmu_idx); | ||
377 | |||
378 | /* | ||
379 | * Fast Context Switch Extension. This doesn't exist at all in v8. | ||
380 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
381 | |||
382 | if (arm_feature(env, ARM_FEATURE_PMSA)) { | ||
383 | bool ret; | ||
384 | - *page_size = TARGET_PAGE_SIZE; | ||
385 | + result->page_size = TARGET_PAGE_SIZE; | ||
386 | |||
387 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
388 | /* PMSAv8 */ | ||
389 | ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx, | ||
390 | - phys_ptr, attrs, prot, page_size, fi); | ||
391 | + &result->phys, &result->attrs, | ||
392 | + &result->prot, &result->page_size, fi); | ||
393 | } else if (arm_feature(env, ARM_FEATURE_V7)) { | ||
394 | /* PMSAv7 */ | ||
395 | ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, | ||
396 | - phys_ptr, prot, page_size, fi); | ||
397 | + &result->phys, &result->prot, | ||
398 | + &result->page_size, fi); | ||
399 | } else { | ||
400 | /* Pre-v7 MPU */ | ||
401 | ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx, | ||
402 | - phys_ptr, prot, fi); | ||
403 | + &result->phys, &result->prot, fi); | ||
404 | } | ||
405 | qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32 | ||
406 | " mmu_idx %u -> %s (prot %c%c%c)\n", | ||
407 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
408 | (access_type == MMU_DATA_STORE ? "writing" : "execute"), | ||
409 | (uint32_t)address, mmu_idx, | ||
410 | ret ? "Miss" : "Hit", | ||
411 | - *prot & PAGE_READ ? 'r' : '-', | ||
412 | - *prot & PAGE_WRITE ? 'w' : '-', | ||
413 | - *prot & PAGE_EXEC ? 'x' : '-'); | ||
414 | + result->prot & PAGE_READ ? 'r' : '-', | ||
415 | + result->prot & PAGE_WRITE ? 'w' : '-', | ||
416 | + result->prot & PAGE_EXEC ? 'x' : '-'); | ||
417 | |||
418 | return ret; | ||
419 | } | ||
420 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
421 | address = extract64(address, 0, 52); | ||
422 | } | 61 | } |
423 | } | 62 | } |
424 | - *phys_ptr = address; | 63 | + if (has_el2 && timeridx == GTIMER_VIRT) { |
425 | - *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | 64 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1TVT)) { |
426 | - *page_size = TARGET_PAGE_SIZE; | 65 | + return CP_ACCESS_TRAP_EL2; |
427 | + result->phys = address; | 66 | + } |
428 | + result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | 67 | + } |
429 | + result->page_size = TARGET_PAGE_SIZE; | 68 | break; |
430 | |||
431 | /* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */ | ||
432 | hcr = arm_hcr_el2_eff(env); | ||
433 | - cacheattrs->shareability = 0; | ||
434 | - cacheattrs->is_s2_format = false; | ||
435 | + result->cacheattrs.shareability = 0; | ||
436 | + result->cacheattrs.is_s2_format = false; | ||
437 | if (hcr & HCR_DC) { | ||
438 | if (hcr & HCR_DCT) { | ||
439 | memattr = 0xf0; /* Tagged, Normal, WB, RWA */ | ||
440 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
441 | } else { | ||
442 | memattr = 0x44; /* Normal, NC, No */ | ||
443 | } | ||
444 | - cacheattrs->shareability = 2; /* outer sharable */ | ||
445 | + result->cacheattrs.shareability = 2; /* outer sharable */ | ||
446 | } else { | ||
447 | memattr = 0x00; /* Device, nGnRnE */ | ||
448 | } | ||
449 | - cacheattrs->attrs = memattr; | ||
450 | + result->cacheattrs.attrs = memattr; | ||
451 | return 0; | ||
452 | } | 69 | } |
453 | 70 | return CP_ACCESS_OK; | |
454 | if (regime_using_lpae_format(env, mmu_idx)) { | 71 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, |
455 | return get_phys_addr_lpae(env, address, access_type, mmu_idx, false, | 72 | if (cpu_isar_feature(aa64_rme, cpu)) { |
456 | - phys_ptr, attrs, prot, page_size, | 73 | valid_mask |= R_CNTHCTL_CNTVMASK_MASK | R_CNTHCTL_CNTPMASK_MASK; |
457 | - fi, cacheattrs); | ||
458 | + &result->phys, &result->attrs, | ||
459 | + &result->prot, &result->page_size, | ||
460 | + fi, &result->cacheattrs); | ||
461 | } else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) { | ||
462 | return get_phys_addr_v6(env, address, access_type, mmu_idx, | ||
463 | - phys_ptr, attrs, prot, page_size, fi); | ||
464 | + &result->phys, &result->attrs, | ||
465 | + &result->prot, &result->page_size, fi); | ||
466 | } else { | ||
467 | return get_phys_addr_v5(env, address, access_type, mmu_idx, | ||
468 | - phys_ptr, prot, page_size, fi); | ||
469 | + &result->phys, &result->prot, | ||
470 | + &result->page_size, fi); | ||
471 | } | 74 | } |
75 | + if (cpu_isar_feature(aa64_ecv_traps, cpu)) { | ||
76 | + valid_mask |= | ||
77 | + R_CNTHCTL_EL1TVT_MASK | | ||
78 | + R_CNTHCTL_EL1TVCT_MASK | | ||
79 | + R_CNTHCTL_EL1NVPCT_MASK | | ||
80 | + R_CNTHCTL_EL1NVVCT_MASK | | ||
81 | + R_CNTHCTL_EVNTIS_MASK; | ||
82 | + } | ||
83 | |||
84 | /* Clear RES0 bits */ | ||
85 | value &= valid_mask; | ||
86 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
87 | { | ||
88 | if (arm_current_el(env) == 1) { | ||
89 | /* This must be a FEAT_NV access */ | ||
90 | - /* TODO: FEAT_ECV will need to check CNTHCTL_EL2 here */ | ||
91 | return CP_ACCESS_OK; | ||
92 | } | ||
93 | if (!(arm_hcr_el2_eff(env) & HCR_E2H)) { | ||
94 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
95 | return CP_ACCESS_OK; | ||
472 | } | 96 | } |
473 | 97 | ||
474 | @@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, | 98 | +static CPAccessResult access_el1nvpct(CPUARMState *env, const ARMCPRegInfo *ri, |
99 | + bool isread) | ||
100 | +{ | ||
101 | + if (arm_current_el(env) == 1) { | ||
102 | + /* This must be a FEAT_NV access with NVx == 101 */ | ||
103 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1NVPCT)) { | ||
104 | + return CP_ACCESS_TRAP_EL2; | ||
105 | + } | ||
106 | + } | ||
107 | + return e2h_access(env, ri, isread); | ||
108 | +} | ||
109 | + | ||
110 | +static CPAccessResult access_el1nvvct(CPUARMState *env, const ARMCPRegInfo *ri, | ||
111 | + bool isread) | ||
112 | +{ | ||
113 | + if (arm_current_el(env) == 1) { | ||
114 | + /* This must be a FEAT_NV access with NVx == 101 */ | ||
115 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1NVVCT)) { | ||
116 | + return CP_ACCESS_TRAP_EL2; | ||
117 | + } | ||
118 | + } | ||
119 | + return e2h_access(env, ri, isread); | ||
120 | +} | ||
121 | + | ||
122 | /* Test if system register redirection is to occur in the current state. */ | ||
123 | static bool redirect_for_e2h(CPUARMState *env) | ||
475 | { | 124 | { |
476 | ARMCPU *cpu = ARM_CPU(cs); | 125 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { |
477 | CPUARMState *env = &cpu->env; | 126 | { .name = "CNTP_CTL_EL02", .state = ARM_CP_STATE_AA64, |
478 | - hwaddr phys_addr; | 127 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 2, .opc2 = 1, |
479 | - target_ulong page_size; | 128 | .type = ARM_CP_IO | ARM_CP_ALIAS, |
480 | - int prot; | 129 | - .access = PL2_RW, .accessfn = e2h_access, |
481 | - bool ret; | 130 | + .access = PL2_RW, .accessfn = access_el1nvpct, |
482 | + GetPhysAddrResult res = {}; | 131 | .nv2_redirect_offset = 0x180 | NV2_REDIR_NO_NV1, |
483 | ARMMMUFaultInfo fi = {}; | 132 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_PHYS].ctl), |
484 | ARMMMUIdx mmu_idx = arm_mmu_idx(env); | 133 | .writefn = gt_phys_ctl_write, .raw_writefn = raw_write }, |
485 | - ARMCacheAttrs cacheattrs = {}; | 134 | { .name = "CNTV_CTL_EL02", .state = ARM_CP_STATE_AA64, |
486 | + bool ret; | 135 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 3, .opc2 = 1, |
487 | 136 | .type = ARM_CP_IO | ARM_CP_ALIAS, | |
488 | - *attrs = (MemTxAttrs) {}; | 137 | - .access = PL2_RW, .accessfn = e2h_access, |
489 | - | 138 | + .access = PL2_RW, .accessfn = access_el1nvvct, |
490 | - ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &phys_addr, | 139 | .nv2_redirect_offset = 0x170 | NV2_REDIR_NO_NV1, |
491 | - attrs, &prot, &page_size, &fi, &cacheattrs); | 140 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_VIRT].ctl), |
492 | + ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi); | 141 | .writefn = gt_virt_ctl_write, .raw_writefn = raw_write }, |
493 | + *attrs = res.attrs; | 142 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { |
494 | 143 | .type = ARM_CP_IO | ARM_CP_ALIAS, | |
495 | if (ret) { | 144 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_PHYS].cval), |
496 | return -1; | 145 | .nv2_redirect_offset = 0x178 | NV2_REDIR_NO_NV1, |
497 | } | 146 | - .access = PL2_RW, .accessfn = e2h_access, |
498 | - return phys_addr; | 147 | + .access = PL2_RW, .accessfn = access_el1nvpct, |
499 | + return res.phys; | 148 | .writefn = gt_phys_cval_write, .raw_writefn = raw_write }, |
500 | } | 149 | { .name = "CNTV_CVAL_EL02", .state = ARM_CP_STATE_AA64, |
501 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c | 150 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 3, .opc2 = 2, |
502 | index XXXXXXX..XXXXXXX 100644 | 151 | .type = ARM_CP_IO | ARM_CP_ALIAS, |
503 | --- a/target/arm/tlb_helper.c | 152 | .nv2_redirect_offset = 0x168 | NV2_REDIR_NO_NV1, |
504 | +++ b/target/arm/tlb_helper.c | 153 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_VIRT].cval), |
505 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | 154 | - .access = PL2_RW, .accessfn = e2h_access, |
506 | { | 155 | + .access = PL2_RW, .accessfn = access_el1nvvct, |
507 | ARMCPU *cpu = ARM_CPU(cs); | 156 | .writefn = gt_virt_cval_write, .raw_writefn = raw_write }, |
508 | ARMMMUFaultInfo fi = {}; | 157 | #endif |
509 | - hwaddr phys_addr; | 158 | }; |
510 | - target_ulong page_size; | ||
511 | - int prot, ret; | ||
512 | - MemTxAttrs attrs = {}; | ||
513 | - ARMCacheAttrs cacheattrs = {}; | ||
514 | + GetPhysAddrResult res = {}; | ||
515 | + int ret; | ||
516 | |||
517 | /* | ||
518 | * Walk the page table and (if the mapping exists) add the page | ||
519 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
520 | */ | ||
521 | ret = get_phys_addr(&cpu->env, address, access_type, | ||
522 | core_to_arm_mmu_idx(&cpu->env, mmu_idx), | ||
523 | - &phys_addr, &attrs, &prot, &page_size, | ||
524 | - &fi, &cacheattrs); | ||
525 | + &res, &fi); | ||
526 | if (likely(!ret)) { | ||
527 | /* | ||
528 | * Map a single [sub]page. Regions smaller than our declared | ||
529 | * target page size are handled specially, so for those we | ||
530 | * pass in the exact addresses. | ||
531 | */ | ||
532 | - if (page_size >= TARGET_PAGE_SIZE) { | ||
533 | - phys_addr &= TARGET_PAGE_MASK; | ||
534 | + if (res.page_size >= TARGET_PAGE_SIZE) { | ||
535 | + res.phys &= TARGET_PAGE_MASK; | ||
536 | address &= TARGET_PAGE_MASK; | ||
537 | } | ||
538 | /* Notice and record tagged memory. */ | ||
539 | - if (cpu_isar_feature(aa64_mte, cpu) && cacheattrs.attrs == 0xf0) { | ||
540 | - arm_tlb_mte_tagged(&attrs) = true; | ||
541 | + if (cpu_isar_feature(aa64_mte, cpu) && res.cacheattrs.attrs == 0xf0) { | ||
542 | + arm_tlb_mte_tagged(&res.attrs) = true; | ||
543 | } | ||
544 | |||
545 | - tlb_set_page_with_attrs(cs, address, phys_addr, attrs, | ||
546 | - prot, mmu_idx, page_size); | ||
547 | + tlb_set_page_with_attrs(cs, address, res.phys, res.attrs, | ||
548 | + res.prot, mmu_idx, res.page_size); | ||
549 | return true; | ||
550 | } else if (probe) { | ||
551 | return false; | ||
552 | -- | 159 | -- |
553 | 2.25.1 | 160 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20220822152741.1617527-4-richard.henderson@linaro.org | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | target/arm/ptw.c | 69 ++++++++++++++++++------------------------------ | ||
10 | 1 file changed, 26 insertions(+), 43 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/ptw.c | ||
15 | +++ b/target/arm/ptw.c | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | |||
18 | static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
19 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
20 | - bool s1_is_el0, hwaddr *phys_ptr, | ||
21 | - MemTxAttrs *txattrs, int *prot, | ||
22 | - target_ulong *page_size_ptr, | ||
23 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
24 | + bool s1_is_el0, GetPhysAddrResult *result, | ||
25 | + ARMMMUFaultInfo *fi) | ||
26 | __attribute__((nonnull)); | ||
27 | |||
28 | /* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. */ | ||
29 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
30 | { | ||
31 | if (arm_mmu_idx_is_stage1_of_2(mmu_idx) && | ||
32 | !regime_translation_disabled(env, ARMMMUIdx_Stage2)) { | ||
33 | - target_ulong s2size; | ||
34 | - hwaddr s2pa; | ||
35 | - int s2prot; | ||
36 | - int ret; | ||
37 | ARMMMUIdx s2_mmu_idx = *is_secure ? ARMMMUIdx_Stage2_S | ||
38 | : ARMMMUIdx_Stage2; | ||
39 | - ARMCacheAttrs cacheattrs = {}; | ||
40 | - MemTxAttrs txattrs = {}; | ||
41 | + GetPhysAddrResult s2 = {}; | ||
42 | + int ret; | ||
43 | |||
44 | ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, s2_mmu_idx, false, | ||
45 | - &s2pa, &txattrs, &s2prot, &s2size, fi, | ||
46 | - &cacheattrs); | ||
47 | + &s2, fi); | ||
48 | if (ret) { | ||
49 | assert(fi->type != ARMFault_None); | ||
50 | fi->s2addr = addr; | ||
51 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
52 | return ~0; | ||
53 | } | ||
54 | if ((arm_hcr_el2_eff(env) & HCR_PTW) && | ||
55 | - ptw_attrs_are_device(env, cacheattrs)) { | ||
56 | + ptw_attrs_are_device(env, s2.cacheattrs)) { | ||
57 | /* | ||
58 | * PTW set and S1 walk touched S2 Device memory: | ||
59 | * generate Permission fault. | ||
60 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
61 | assert(!*is_secure); | ||
62 | } | ||
63 | |||
64 | - addr = s2pa; | ||
65 | + addr = s2.phys; | ||
66 | } | ||
67 | return addr; | ||
68 | } | ||
69 | @@ -XXX,XX +XXX,XX @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, | ||
70 | * table walk), must be true if this is stage 2 of a stage 1+2 | ||
71 | * walk for an EL0 access. If @mmu_idx is anything else, | ||
72 | * @s1_is_el0 is ignored. | ||
73 | - * @phys_ptr: set to the physical address corresponding to the virtual address | ||
74 | - * @attrs: set to the memory transaction attributes to use | ||
75 | - * @prot: set to the permissions for the page containing phys_ptr | ||
76 | - * @page_size_ptr: set to the size of the page containing phys_ptr | ||
77 | + * @result: set on translation success, | ||
78 | * @fi: set to fault info if the translation fails | ||
79 | - * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | ||
80 | */ | ||
81 | static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
82 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
83 | - bool s1_is_el0, hwaddr *phys_ptr, | ||
84 | - MemTxAttrs *txattrs, int *prot, | ||
85 | - target_ulong *page_size_ptr, | ||
86 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
87 | + bool s1_is_el0, GetPhysAddrResult *result, | ||
88 | + ARMMMUFaultInfo *fi) | ||
89 | { | ||
90 | ARMCPU *cpu = env_archcpu(env); | ||
91 | /* Read an LPAE long-descriptor translation table. */ | ||
92 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
93 | if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { | ||
94 | ns = mmu_idx == ARMMMUIdx_Stage2; | ||
95 | xn = extract32(attrs, 11, 2); | ||
96 | - *prot = get_S2prot(env, ap, xn, s1_is_el0); | ||
97 | + result->prot = get_S2prot(env, ap, xn, s1_is_el0); | ||
98 | } else { | ||
99 | ns = extract32(attrs, 3, 1); | ||
100 | xn = extract32(attrs, 12, 1); | ||
101 | pxn = extract32(attrs, 11, 1); | ||
102 | - *prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); | ||
103 | + result->prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); | ||
104 | } | ||
105 | |||
106 | fault_type = ARMFault_Permission; | ||
107 | - if (!(*prot & (1 << access_type))) { | ||
108 | + if (!(result->prot & (1 << access_type))) { | ||
109 | goto do_fault; | ||
110 | } | ||
111 | |||
112 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
113 | * the CPU doesn't support TZ or this is a non-secure translation | ||
114 | * regime, because the attribute will already be non-secure. | ||
115 | */ | ||
116 | - txattrs->secure = false; | ||
117 | + result->attrs.secure = false; | ||
118 | } | ||
119 | /* When in aarch64 mode, and BTI is enabled, remember GP in the IOTLB. */ | ||
120 | if (aarch64 && guarded && cpu_isar_feature(aa64_bti, cpu)) { | ||
121 | - arm_tlb_bti_gp(txattrs) = true; | ||
122 | + arm_tlb_bti_gp(&result->attrs) = true; | ||
123 | } | ||
124 | |||
125 | if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { | ||
126 | - cacheattrs->is_s2_format = true; | ||
127 | - cacheattrs->attrs = extract32(attrs, 0, 4); | ||
128 | + result->cacheattrs.is_s2_format = true; | ||
129 | + result->cacheattrs.attrs = extract32(attrs, 0, 4); | ||
130 | } else { | ||
131 | /* Index into MAIR registers for cache attributes */ | ||
132 | uint8_t attrindx = extract32(attrs, 0, 3); | ||
133 | uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; | ||
134 | assert(attrindx <= 7); | ||
135 | - cacheattrs->is_s2_format = false; | ||
136 | - cacheattrs->attrs = extract64(mair, attrindx * 8, 8); | ||
137 | + result->cacheattrs.is_s2_format = false; | ||
138 | + result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8); | ||
139 | } | ||
140 | |||
141 | /* | ||
142 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, | ||
143 | * that case comes from TCR_ELx, which we extracted earlier. | ||
144 | */ | ||
145 | if (param.ds) { | ||
146 | - cacheattrs->shareability = param.sh; | ||
147 | + result->cacheattrs.shareability = param.sh; | ||
148 | } else { | ||
149 | - cacheattrs->shareability = extract32(attrs, 6, 2); | ||
150 | + result->cacheattrs.shareability = extract32(attrs, 6, 2); | ||
151 | } | ||
152 | |||
153 | - *phys_ptr = descaddr; | ||
154 | - *page_size_ptr = page_size; | ||
155 | + result->phys = descaddr; | ||
156 | + result->page_size = page_size; | ||
157 | return false; | ||
158 | |||
159 | do_fault: | ||
160 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
161 | cacheattrs1 = result->cacheattrs; | ||
162 | memset(result, 0, sizeof(*result)); | ||
163 | |||
164 | - ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, is_el0, | ||
165 | - &result->phys, &result->attrs, | ||
166 | - &result->prot, &result->page_size, | ||
167 | - fi, &result->cacheattrs); | ||
168 | + ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, | ||
169 | + is_el0, result, fi); | ||
170 | fi->s2addr = ipa; | ||
171 | |||
172 | /* Combine the S1 and S2 perms. */ | ||
173 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
174 | |||
175 | if (regime_using_lpae_format(env, mmu_idx)) { | ||
176 | return get_phys_addr_lpae(env, address, access_type, mmu_idx, false, | ||
177 | - &result->phys, &result->attrs, | ||
178 | - &result->prot, &result->page_size, | ||
179 | - fi, &result->cacheattrs); | ||
180 | + result, fi); | ||
181 | } else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) { | ||
182 | return get_phys_addr_v6(env, address, access_type, mmu_idx, | ||
183 | &result->phys, &result->attrs, | ||
184 | -- | ||
185 | 2.25.1 | ||
186 | |||
187 | diff view generated by jsdifflib |
1 | Shellcheck warns that we have one place where we run a command and | 1 | For FEAT_ECV, new registers CNTPCTSS_EL0 and CNTVCTSS_EL0 are |
---|---|---|---|
2 | then check if it failed using $?; this is better written to simply | 2 | defined, which are "self-synchronized" views of the physical and |
3 | check the command in the 'if' statement directly. | 3 | virtual counts as seen in the CNTPCT_EL0 and CNTVCT_EL0 registers |
4 | (meaning that no barriers are needed around accesses to them to | ||
5 | ensure that reads of them do not occur speculatively and out-of-order | ||
6 | with other instructions). | ||
7 | |||
8 | For QEMU, all our system registers are self-synchronized, so we can | ||
9 | simply copy the existing implementation of CNTPCT_EL0 and CNTVCT_EL0 | ||
10 | to the new register encodings. | ||
11 | |||
12 | This means we now implement all the functionality required for | ||
13 | ID_AA64MMFR0_EL1.ECV == 0b0001. | ||
4 | 14 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 17 | Message-id: 20240301183219.2424889-7-peter.maydell@linaro.org |
8 | Message-id: 20220825150703.4074125-7-peter.maydell@linaro.org | ||
9 | --- | 18 | --- |
10 | configure | 3 +-- | 19 | target/arm/helper.c | 43 +++++++++++++++++++++++++++++++++++++++++++ |
11 | 1 file changed, 1 insertion(+), 2 deletions(-) | 20 | 1 file changed, 43 insertions(+) |
12 | 21 | ||
13 | diff --git a/configure b/configure | 22 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100755 | 23 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/configure | 24 | --- a/target/arm/helper.c |
16 | +++ b/configure | 25 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ fi | 26 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
18 | # it when configure exits.) | 27 | }, |
19 | TMPDIR1="config-temp" | 28 | }; |
20 | rm -rf "${TMPDIR1}" | 29 | |
21 | -mkdir -p "${TMPDIR1}" | 30 | +/* |
22 | -if [ $? -ne 0 ]; then | 31 | + * FEAT_ECV adds extra views of CNTVCT_EL0 and CNTPCT_EL0 which |
23 | +if ! mkdir -p "${TMPDIR1}"; then | 32 | + * are "self-synchronizing". For QEMU all sysregs are self-synchronizing, |
24 | echo "ERROR: failed to create temporary directory" | 33 | + * so our implementations here are identical to the normal registers. |
25 | exit 1 | 34 | + */ |
26 | fi | 35 | +static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { |
36 | + { .name = "CNTVCTSS", .cp = 15, .crm = 14, .opc1 = 9, | ||
37 | + .access = PL0_R, .type = ARM_CP_64BIT | ARM_CP_NO_RAW | ARM_CP_IO, | ||
38 | + .accessfn = gt_vct_access, | ||
39 | + .readfn = gt_virt_cnt_read, .resetfn = arm_cp_reset_ignore, | ||
40 | + }, | ||
41 | + { .name = "CNTVCTSS_EL0", .state = ARM_CP_STATE_AA64, | ||
42 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 6, | ||
43 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
44 | + .accessfn = gt_vct_access, .readfn = gt_virt_cnt_read, | ||
45 | + }, | ||
46 | + { .name = "CNTPCTSS", .cp = 15, .crm = 14, .opc1 = 8, | ||
47 | + .access = PL0_R, .type = ARM_CP_64BIT | ARM_CP_NO_RAW | ARM_CP_IO, | ||
48 | + .accessfn = gt_pct_access, | ||
49 | + .readfn = gt_cnt_read, .resetfn = arm_cp_reset_ignore, | ||
50 | + }, | ||
51 | + { .name = "CNTPCTSS_EL0", .state = ARM_CP_STATE_AA64, | ||
52 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 5, | ||
53 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
54 | + .accessfn = gt_pct_access, .readfn = gt_cnt_read, | ||
55 | + }, | ||
56 | +}; | ||
57 | + | ||
58 | #else | ||
59 | |||
60 | /* | ||
61 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
62 | }, | ||
63 | }; | ||
64 | |||
65 | +/* | ||
66 | + * CNTVCTSS_EL0 has the same trap conditions as CNTVCT_EL0, so it also | ||
67 | + * is exposed to userspace by Linux. | ||
68 | + */ | ||
69 | +static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { | ||
70 | + { .name = "CNTVCTSS_EL0", .state = ARM_CP_STATE_AA64, | ||
71 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 6, | ||
72 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
73 | + .readfn = gt_virt_cnt_read, | ||
74 | + }, | ||
75 | +}; | ||
76 | + | ||
77 | #endif | ||
78 | |||
79 | static void par_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
80 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
81 | if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { | ||
82 | define_arm_cp_regs(cpu, generic_timer_cp_reginfo); | ||
83 | } | ||
84 | + if (cpu_isar_feature(aa64_ecv_traps, cpu)) { | ||
85 | + define_arm_cp_regs(cpu, gen_timer_ecv_cp_reginfo); | ||
86 | + } | ||
87 | if (arm_feature(env, ARM_FEATURE_VAPA)) { | ||
88 | ARMCPRegInfo vapa_cp_reginfo[] = { | ||
89 | { .name = "PAR", .cp = 15, .crn = 7, .crm = 4, .opc1 = 0, .opc2 = 0, | ||
27 | -- | 90 | -- |
28 | 2.25.1 | 91 | 2.34.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | From: Keqian Zhu <zhukeqian1@huawei.com> | 1 | When ID_AA64MMFR0_EL1.ECV is 0b0010, a new register CNTPOFF_EL2 is |
---|---|---|---|
2 | implemented. This is similar to the existing CNTVOFF_EL2, except | ||
3 | that it controls a hypervisor-adjustable offset made to the physical | ||
4 | counter and timer. | ||
2 | 5 | ||
3 | Setup an ARM virtual machine of machine virt and execute qmp "query-acpi-ospm-status" | 6 | Implement the handling for this register, which includes control/trap |
4 | causes segmentation fault with following dumpstack: | 7 | bits in SCR_EL3 and CNTHCTL_EL2. |
5 | #1 0x0000aaaaab64235c in qmp_query_acpi_ospm_status (errp=errp@entry=0xfffffffff030) at ../monitor/qmp-cmds.c:312 | ||
6 | #2 0x0000aaaaabfc4e20 in qmp_marshal_query_acpi_ospm_status (args=<optimized out>, ret=0xffffea4ffe90, errp=0xffffea4ffe88) at qapi/qapi-commands-acpi.c:63 | ||
7 | #3 0x0000aaaaabff8ba0 in do_qmp_dispatch_bh (opaque=0xffffea4ffe98) at ../qapi/qmp-dispatch.c:128 | ||
8 | #4 0x0000aaaaac02e594 in aio_bh_call (bh=0xffffe0004d80) at ../util/async.c:150 | ||
9 | #5 aio_bh_poll (ctx=ctx@entry=0xaaaaad0f6040) at ../util/async.c:178 | ||
10 | #6 0x0000aaaaac00bd40 in aio_dispatch (ctx=ctx@entry=0xaaaaad0f6040) at ../util/aio-posix.c:421 | ||
11 | #7 0x0000aaaaac02e010 in aio_ctx_dispatch (source=0xaaaaad0f6040, callback=<optimized out>, user_data=<optimized out>) at ../util/async.c:320 | ||
12 | #8 0x0000fffff76f6884 in g_main_context_dispatch () at /usr/lib64/libglib-2.0.so.0 | ||
13 | #9 0x0000aaaaac0452d4 in glib_pollfds_poll () at ../util/main-loop.c:297 | ||
14 | #10 os_host_main_loop_wait (timeout=0) at ../util/main-loop.c:320 | ||
15 | #11 main_loop_wait (nonblocking=nonblocking@entry=0) at ../util/main-loop.c:596 | ||
16 | #12 0x0000aaaaab5c9e50 in qemu_main_loop () at ../softmmu/runstate.c:734 | ||
17 | #13 0x0000aaaaab185370 in qemu_main (argc=argc@entry=47, argv=argv@entry=0xfffffffff518, envp=envp@entry=0x0) at ../softmmu/main.c:38 | ||
18 | #14 0x0000aaaaab16f99c in main (argc=47, argv=0xfffffffff518) at ../softmmu/main.c:47 | ||
19 | 8 | ||
20 | Fixes: ebb62075021a ("hw/acpi: Add ACPI Generic Event Device Support") | ||
21 | Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com> | ||
22 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
23 | Message-id: 20220816094957.31700-1-zhukeqian1@huawei.com | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20240301183219.2424889-8-peter.maydell@linaro.org | ||
25 | --- | 12 | --- |
26 | hw/acpi/generic_event_device.c | 8 ++++++++ | 13 | target/arm/cpu-features.h | 5 +++ |
27 | 1 file changed, 8 insertions(+) | 14 | target/arm/cpu.h | 1 + |
15 | target/arm/helper.c | 68 +++++++++++++++++++++++++++++++++++++-- | ||
16 | target/arm/trace-events | 1 + | ||
17 | 4 files changed, 73 insertions(+), 2 deletions(-) | ||
28 | 18 | ||
29 | diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c | 19 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
30 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/hw/acpi/generic_event_device.c | 21 | --- a/target/arm/cpu-features.h |
32 | +++ b/hw/acpi/generic_event_device.c | 22 | +++ b/target/arm/cpu-features.h |
33 | @@ -XXX,XX +XXX,XX @@ static void acpi_ged_unplug_cb(HotplugHandler *hotplug_dev, | 23 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ecv_traps(const ARMISARegisters *id) |
34 | } | 24 | return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 0; |
35 | } | 25 | } |
36 | 26 | ||
37 | +static void acpi_ged_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list) | 27 | +static inline bool isar_feature_aa64_ecv(const ARMISARegisters *id) |
38 | +{ | 28 | +{ |
39 | + AcpiGedState *s = ACPI_GED(adev); | 29 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 1; |
40 | + | ||
41 | + acpi_memory_ospm_status(&s->memhp_state, list); | ||
42 | +} | 30 | +} |
43 | + | 31 | + |
44 | static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) | 32 | static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) |
45 | { | 33 | { |
46 | AcpiGedState *s = ACPI_GED(adev); | 34 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; |
47 | @@ -XXX,XX +XXX,XX @@ static void acpi_ged_class_init(ObjectClass *class, void *data) | 35 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
48 | hc->unplug_request = acpi_ged_unplug_request_cb; | 36 | index XXXXXXX..XXXXXXX 100644 |
49 | hc->unplug = acpi_ged_unplug_cb; | 37 | --- a/target/arm/cpu.h |
50 | 38 | +++ b/target/arm/cpu.h | |
51 | + adevc->ospm_status = acpi_ged_ospm_status; | 39 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
52 | adevc->send_event = acpi_ged_send_event; | 40 | uint64_t c14_cntkctl; /* Timer Control register */ |
41 | uint64_t cnthctl_el2; /* Counter/Timer Hyp Control register */ | ||
42 | uint64_t cntvoff_el2; /* Counter Virtual Offset register */ | ||
43 | + uint64_t cntpoff_el2; /* Counter Physical Offset register */ | ||
44 | ARMGenericTimer c14_timer[NUM_GTIMERS]; | ||
45 | uint32_t c15_cpar; /* XScale Coprocessor Access Register */ | ||
46 | uint32_t c15_ticonfig; /* TI925T configuration byte. */ | ||
47 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/helper.c | ||
50 | +++ b/target/arm/helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
52 | if (cpu_isar_feature(aa64_rme, cpu)) { | ||
53 | valid_mask |= SCR_NSE | SCR_GPF; | ||
54 | } | ||
55 | + if (cpu_isar_feature(aa64_ecv, cpu)) { | ||
56 | + valid_mask |= SCR_ECVEN; | ||
57 | + } | ||
58 | } else { | ||
59 | valid_mask &= ~(SCR_RW | SCR_ST); | ||
60 | if (cpu_isar_feature(aa32_ras, cpu)) { | ||
61 | @@ -XXX,XX +XXX,XX @@ void gt_rme_post_el_change(ARMCPU *cpu, void *ignored) | ||
62 | gt_update_irq(cpu, GTIMER_PHYS); | ||
53 | } | 63 | } |
54 | 64 | ||
65 | +static uint64_t gt_phys_raw_cnt_offset(CPUARMState *env) | ||
66 | +{ | ||
67 | + if ((env->cp15.scr_el3 & SCR_ECVEN) && | ||
68 | + FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, ECV) && | ||
69 | + arm_is_el2_enabled(env) && | ||
70 | + (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | ||
71 | + return env->cp15.cntpoff_el2; | ||
72 | + } | ||
73 | + return 0; | ||
74 | +} | ||
75 | + | ||
76 | +static uint64_t gt_phys_cnt_offset(CPUARMState *env) | ||
77 | +{ | ||
78 | + if (arm_current_el(env) >= 2) { | ||
79 | + return 0; | ||
80 | + } | ||
81 | + return gt_phys_raw_cnt_offset(env); | ||
82 | +} | ||
83 | + | ||
84 | static void gt_recalc_timer(ARMCPU *cpu, int timeridx) | ||
85 | { | ||
86 | ARMGenericTimer *gt = &cpu->env.cp15.c14_timer[timeridx]; | ||
87 | @@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) | ||
88 | * reset timer to when ISTATUS next has to change | ||
89 | */ | ||
90 | uint64_t offset = timeridx == GTIMER_VIRT ? | ||
91 | - cpu->env.cp15.cntvoff_el2 : 0; | ||
92 | + cpu->env.cp15.cntvoff_el2 : gt_phys_raw_cnt_offset(&cpu->env); | ||
93 | uint64_t count = gt_get_countervalue(&cpu->env); | ||
94 | /* Note that this must be unsigned 64 bit arithmetic: */ | ||
95 | int istatus = count - offset >= gt->cval; | ||
96 | @@ -XXX,XX +XXX,XX @@ static void gt_timer_reset(CPUARMState *env, const ARMCPRegInfo *ri, | ||
97 | |||
98 | static uint64_t gt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
99 | { | ||
100 | - return gt_get_countervalue(env); | ||
101 | + return gt_get_countervalue(env) - gt_phys_cnt_offset(env); | ||
102 | } | ||
103 | |||
104 | static uint64_t gt_virt_cnt_offset(CPUARMState *env) | ||
105 | @@ -XXX,XX +XXX,XX @@ static uint64_t gt_tval_read(CPUARMState *env, const ARMCPRegInfo *ri, | ||
106 | case GTIMER_HYPVIRT: | ||
107 | offset = gt_virt_cnt_offset(env); | ||
108 | break; | ||
109 | + case GTIMER_PHYS: | ||
110 | + offset = gt_phys_cnt_offset(env); | ||
111 | + break; | ||
112 | } | ||
113 | |||
114 | return (uint32_t)(env->cp15.c14_timer[timeridx].cval - | ||
115 | @@ -XXX,XX +XXX,XX @@ static void gt_tval_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
116 | case GTIMER_HYPVIRT: | ||
117 | offset = gt_virt_cnt_offset(env); | ||
118 | break; | ||
119 | + case GTIMER_PHYS: | ||
120 | + offset = gt_phys_cnt_offset(env); | ||
121 | + break; | ||
122 | } | ||
123 | |||
124 | trace_arm_gt_tval_write(timeridx, value); | ||
125 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
126 | R_CNTHCTL_EL1NVVCT_MASK | | ||
127 | R_CNTHCTL_EVNTIS_MASK; | ||
128 | } | ||
129 | + if (cpu_isar_feature(aa64_ecv, cpu)) { | ||
130 | + valid_mask |= R_CNTHCTL_ECV_MASK; | ||
131 | + } | ||
132 | |||
133 | /* Clear RES0 bits */ | ||
134 | value &= valid_mask; | ||
135 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { | ||
136 | }, | ||
137 | }; | ||
138 | |||
139 | +static CPAccessResult gt_cntpoff_access(CPUARMState *env, | ||
140 | + const ARMCPRegInfo *ri, | ||
141 | + bool isread) | ||
142 | +{ | ||
143 | + if (arm_current_el(env) == 2 && !(env->cp15.scr_el3 & SCR_ECVEN)) { | ||
144 | + return CP_ACCESS_TRAP_EL3; | ||
145 | + } | ||
146 | + return CP_ACCESS_OK; | ||
147 | +} | ||
148 | + | ||
149 | +static void gt_cntpoff_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
150 | + uint64_t value) | ||
151 | +{ | ||
152 | + ARMCPU *cpu = env_archcpu(env); | ||
153 | + | ||
154 | + trace_arm_gt_cntpoff_write(value); | ||
155 | + raw_write(env, ri, value); | ||
156 | + gt_recalc_timer(cpu, GTIMER_PHYS); | ||
157 | +} | ||
158 | + | ||
159 | +static const ARMCPRegInfo gen_timer_cntpoff_reginfo = { | ||
160 | + .name = "CNTPOFF_EL2", .state = ARM_CP_STATE_AA64, | ||
161 | + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 0, .opc2 = 6, | ||
162 | + .access = PL2_RW, .type = ARM_CP_IO, .resetvalue = 0, | ||
163 | + .accessfn = gt_cntpoff_access, .writefn = gt_cntpoff_write, | ||
164 | + .nv2_redirect_offset = 0x1a8, | ||
165 | + .fieldoffset = offsetof(CPUARMState, cp15.cntpoff_el2), | ||
166 | +}; | ||
167 | #else | ||
168 | |||
169 | /* | ||
170 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
171 | if (cpu_isar_feature(aa64_ecv_traps, cpu)) { | ||
172 | define_arm_cp_regs(cpu, gen_timer_ecv_cp_reginfo); | ||
173 | } | ||
174 | +#ifndef CONFIG_USER_ONLY | ||
175 | + if (cpu_isar_feature(aa64_ecv, cpu)) { | ||
176 | + define_one_arm_cp_reg(cpu, &gen_timer_cntpoff_reginfo); | ||
177 | + } | ||
178 | +#endif | ||
179 | if (arm_feature(env, ARM_FEATURE_VAPA)) { | ||
180 | ARMCPRegInfo vapa_cp_reginfo[] = { | ||
181 | { .name = "PAR", .cp = 15, .crn = 7, .crm = 4, .opc1 = 0, .opc2 = 0, | ||
182 | diff --git a/target/arm/trace-events b/target/arm/trace-events | ||
183 | index XXXXXXX..XXXXXXX 100644 | ||
184 | --- a/target/arm/trace-events | ||
185 | +++ b/target/arm/trace-events | ||
186 | @@ -XXX,XX +XXX,XX @@ arm_gt_tval_write(int timer, uint64_t value) "gt_tval_write: timer %d value 0x%" | ||
187 | arm_gt_ctl_write(int timer, uint64_t value) "gt_ctl_write: timer %d value 0x%" PRIx64 | ||
188 | arm_gt_imask_toggle(int timer) "gt_ctl_write: timer %d IMASK toggle" | ||
189 | arm_gt_cntvoff_write(uint64_t value) "gt_cntvoff_write: value 0x%" PRIx64 | ||
190 | +arm_gt_cntpoff_write(uint64_t value) "gt_cntpoff_write: value 0x%" PRIx64 | ||
191 | arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" | ||
192 | |||
193 | # kvm.c | ||
55 | -- | 194 | -- |
56 | 2.25.1 | 195 | 2.34.1 | diff view generated by jsdifflib |
1 | Shellcheck warns that in | 1 | Enable all FEAT_ECV features on the 'max' CPU. |
---|---|---|---|
2 | rm -f */config-devices.mak.d | ||
3 | the glob might expand to something with a '-' in it, which would | ||
4 | then be misinterpreted as an option to rm. Fix this by adding './'. | ||
5 | 2 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | 4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20220825150703.4074125-5-peter.maydell@linaro.org | 6 | Message-id: 20240301183219.2424889-9-peter.maydell@linaro.org |
10 | --- | 7 | --- |
11 | configure | 2 +- | 8 | docs/system/arm/emulation.rst | 1 + |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 9 | target/arm/tcg/cpu64.c | 1 + |
10 | 2 files changed, 2 insertions(+) | ||
13 | 11 | ||
14 | diff --git a/configure b/configure | 12 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
15 | index XXXXXXX..XXXXXXX 100755 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/configure | 14 | --- a/docs/system/arm/emulation.rst |
17 | +++ b/configure | 15 | +++ b/docs/system/arm/emulation.rst |
18 | @@ -XXX,XX +XXX,XX @@ exit 0 | 16 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
19 | fi | 17 | - FEAT_DotProd (Advanced SIMD dot product instructions) |
20 | 18 | - FEAT_DoubleFault (Double Fault Extension) | |
21 | # Remove old dependency files to make sure that they get properly regenerated | 19 | - FEAT_E0PD (Preventing EL0 access to halves of address maps) |
22 | -rm -f */config-devices.mak.d | 20 | +- FEAT_ECV (Enhanced Counter Virtualization) |
23 | +rm -f ./*/config-devices.mak.d | 21 | - FEAT_EPAC (Enhanced pointer authentication) |
24 | 22 | - FEAT_ETS (Enhanced Translation Synchronization) | |
25 | if test -z "$python" | 23 | - FEAT_EVT (Enhanced Virtualization Traps) |
26 | then | 24 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/tcg/cpu64.c | ||
27 | +++ b/target/arm/tcg/cpu64.c | ||
28 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) | ||
29 | t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN64_2, 2); /* 64k stage2 supported */ | ||
30 | t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 2); /* 4k stage2 supported */ | ||
31 | t = FIELD_DP64(t, ID_AA64MMFR0, FGT, 1); /* FEAT_FGT */ | ||
32 | + t = FIELD_DP64(t, ID_AA64MMFR0, ECV, 2); /* FEAT_ECV */ | ||
33 | cpu->isar.id_aa64mmfr0 = t; | ||
34 | |||
35 | t = cpu->isar.id_aa64mmfr1; | ||
27 | -- | 36 | -- |
28 | 2.25.1 | 37 | 2.34.1 |
29 | 38 | ||
30 | 39 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 3 | Features supported : |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | - the 8 STM32L4x5 GPIOs are initialized with their reset values |
5 | Message-id: 20220822152741.1617527-5-richard.henderson@linaro.org | 5 | (except IDR, see below) |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | - input mode : setting a pin in input mode "externally" (using input |
7 | irqs) results in an out irq (transmitted to SYSCFG) | ||
8 | - output mode : setting a bit in ODR sets the corresponding out irq | ||
9 | (if this line is configured in output mode) | ||
10 | - pull-up, pull-down | ||
11 | - push-pull, open-drain | ||
12 | |||
13 | Difference with the real GPIOs : | ||
14 | - Alternate Function and Analog mode aren't implemented : | ||
15 | pins in AF/Analog behave like pins in input mode | ||
16 | - floating pins stay at their last value | ||
17 | - register IDR reset values differ from the real one : | ||
18 | values are coherent with the other registers reset values | ||
19 | and the fact that AF/Analog modes aren't implemented | ||
20 | - setting I/O output speed isn't supported | ||
21 | - locking port bits isn't supported | ||
22 | - ADC function isn't supported | ||
23 | - GPIOH has 16 pins instead of 2 pins | ||
24 | - writing to registers LCKR, AFRL, AFRH and ASCR is ineffective | ||
25 | |||
26 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
27 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | ||
28 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
29 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
30 | Message-id: 20240305210444.310665-2-ines.varhol@telecom-paris.fr | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 32 | --- |
9 | target/arm/ptw.c | 30 ++++++++++++++---------------- | 33 | MAINTAINERS | 1 + |
10 | 1 file changed, 14 insertions(+), 16 deletions(-) | 34 | docs/system/arm/b-l475e-iot01a.rst | 2 +- |
35 | include/hw/gpio/stm32l4x5_gpio.h | 70 +++++ | ||
36 | hw/gpio/stm32l4x5_gpio.c | 477 +++++++++++++++++++++++++++++ | ||
37 | hw/gpio/Kconfig | 3 + | ||
38 | hw/gpio/meson.build | 1 + | ||
39 | hw/gpio/trace-events | 6 + | ||
40 | 7 files changed, 559 insertions(+), 1 deletion(-) | ||
41 | create mode 100644 include/hw/gpio/stm32l4x5_gpio.h | ||
42 | create mode 100644 hw/gpio/stm32l4x5_gpio.c | ||
11 | 43 | ||
12 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | 44 | diff --git a/MAINTAINERS b/MAINTAINERS |
13 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/ptw.c | 46 | --- a/MAINTAINERS |
15 | +++ b/target/arm/ptw.c | 47 | +++ b/MAINTAINERS |
16 | @@ -XXX,XX +XXX,XX @@ do_fault: | 48 | @@ -XXX,XX +XXX,XX @@ F: hw/arm/stm32l4x5_soc.c |
17 | 49 | F: hw/misc/stm32l4x5_exti.c | |
18 | static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | 50 | F: hw/misc/stm32l4x5_syscfg.c |
19 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 51 | F: hw/misc/stm32l4x5_rcc.c |
20 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | 52 | +F: hw/gpio/stm32l4x5_gpio.c |
21 | - target_ulong *page_size, ARMMMUFaultInfo *fi) | 53 | F: include/hw/*/stm32l4x5_*.h |
22 | + GetPhysAddrResult *result, ARMMMUFaultInfo *fi) | 54 | |
23 | { | 55 | B-L475E-IOT01A IoT Node |
24 | ARMCPU *cpu = env_archcpu(env); | 56 | diff --git a/docs/system/arm/b-l475e-iot01a.rst b/docs/system/arm/b-l475e-iot01a.rst |
25 | int level = 1; | 57 | index XXXXXXX..XXXXXXX 100644 |
26 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | 58 | --- a/docs/system/arm/b-l475e-iot01a.rst |
27 | phys_addr = (desc & 0xff000000) | (address & 0x00ffffff); | 59 | +++ b/docs/system/arm/b-l475e-iot01a.rst |
28 | phys_addr |= (uint64_t)extract32(desc, 20, 4) << 32; | 60 | @@ -XXX,XX +XXX,XX @@ Currently B-L475E-IOT01A machine's only supports the following devices: |
29 | phys_addr |= (uint64_t)extract32(desc, 5, 4) << 36; | 61 | - STM32L4x5 EXTI (Extended interrupts and events controller) |
30 | - *page_size = 0x1000000; | 62 | - STM32L4x5 SYSCFG (System configuration controller) |
31 | + result->page_size = 0x1000000; | 63 | - STM32L4x5 RCC (Reset and clock control) |
32 | } else { | 64 | +- STM32L4x5 GPIOs (General-purpose I/Os) |
33 | /* Section. */ | 65 | |
34 | phys_addr = (desc & 0xfff00000) | (address & 0x000fffff); | 66 | Missing devices |
35 | - *page_size = 0x100000; | 67 | """"""""""""""" |
36 | + result->page_size = 0x100000; | 68 | @@ -XXX,XX +XXX,XX @@ Missing devices |
37 | } | 69 | The B-L475E-IOT01A does *not* support the following devices: |
38 | ap = ((desc >> 10) & 3) | ((desc >> 13) & 4); | 70 | |
39 | xn = desc & (1 << 4); | 71 | - Serial ports (UART) |
40 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | 72 | -- General-purpose I/Os (GPIO) |
41 | case 1: /* 64k page. */ | 73 | - Analog to Digital Converter (ADC) |
42 | phys_addr = (desc & 0xffff0000) | (address & 0xffff); | 74 | - SPI controller |
43 | xn = desc & (1 << 15); | 75 | - Timer controller (TIMER) |
44 | - *page_size = 0x10000; | 76 | diff --git a/include/hw/gpio/stm32l4x5_gpio.h b/include/hw/gpio/stm32l4x5_gpio.h |
45 | + result->page_size = 0x10000; | 77 | new file mode 100644 |
46 | break; | 78 | index XXXXXXX..XXXXXXX |
47 | case 2: case 3: /* 4k page. */ | 79 | --- /dev/null |
48 | phys_addr = (desc & 0xfffff000) | (address & 0xfff); | 80 | +++ b/include/hw/gpio/stm32l4x5_gpio.h |
49 | xn = desc & 1; | 81 | @@ -XXX,XX +XXX,XX @@ |
50 | - *page_size = 0x1000; | 82 | +/* |
51 | + result->page_size = 0x1000; | 83 | + * STM32L4x5 GPIO (General Purpose Input/Ouput) |
52 | break; | 84 | + * |
53 | default: | 85 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
54 | /* Never happens, but compiler isn't smart enough to tell. */ | 86 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> |
55 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | 87 | + * |
56 | } | 88 | + * SPDX-License-Identifier: GPL-2.0-or-later |
57 | } | 89 | + * |
58 | if (domain_prot == 3) { | 90 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
59 | - *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | 91 | + * See the COPYING file in the top-level directory. |
60 | + result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | 92 | + */ |
61 | } else { | 93 | + |
62 | if (pxn && !regime_is_user(env, mmu_idx)) { | 94 | +/* |
63 | xn = 1; | 95 | + * The reference used is the STMicroElectronics RM0351 Reference manual |
64 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | 96 | + * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs. |
65 | fi->type = ARMFault_AccessFlag; | 97 | + * https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html |
66 | goto do_fault; | 98 | + */ |
67 | } | 99 | + |
68 | - *prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1); | 100 | +#ifndef HW_STM32L4X5_GPIO_H |
69 | + result->prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1); | 101 | +#define HW_STM32L4X5_GPIO_H |
70 | } else { | 102 | + |
71 | - *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); | 103 | +#include "hw/sysbus.h" |
72 | + result->prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); | 104 | +#include "qom/object.h" |
73 | } | 105 | + |
74 | - if (*prot && !xn) { | 106 | +#define TYPE_STM32L4X5_GPIO "stm32l4x5-gpio" |
75 | - *prot |= PAGE_EXEC; | 107 | +OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5GpioState, STM32L4X5_GPIO) |
76 | + if (result->prot && !xn) { | 108 | + |
77 | + result->prot |= PAGE_EXEC; | 109 | +#define GPIO_NUM_PINS 16 |
78 | } | 110 | + |
79 | - if (!(*prot & (1 << access_type))) { | 111 | +struct Stm32l4x5GpioState { |
80 | + if (!(result->prot & (1 << access_type))) { | 112 | + SysBusDevice parent_obj; |
81 | /* Access permission fault. */ | 113 | + |
82 | fi->type = ARMFault_Permission; | 114 | + MemoryRegion mmio; |
83 | goto do_fault; | 115 | + |
84 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | 116 | + /* GPIO registers */ |
85 | * the CPU doesn't support TZ or this is a non-secure translation | 117 | + uint32_t moder; |
86 | * regime, because the attribute will already be non-secure. | 118 | + uint32_t otyper; |
87 | */ | 119 | + uint32_t ospeedr; |
88 | - attrs->secure = false; | 120 | + uint32_t pupdr; |
89 | + result->attrs.secure = false; | 121 | + uint32_t idr; |
90 | } | 122 | + uint32_t odr; |
91 | - *phys_ptr = phys_addr; | 123 | + uint32_t lckr; |
92 | + result->phys = phys_addr; | 124 | + uint32_t afrl; |
93 | return false; | 125 | + uint32_t afrh; |
94 | do_fault: | 126 | + uint32_t ascr; |
95 | fi->domain = domain; | 127 | + |
96 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | 128 | + /* GPIO registers reset values */ |
97 | result, fi); | 129 | + uint32_t moder_reset; |
98 | } else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) { | 130 | + uint32_t ospeedr_reset; |
99 | return get_phys_addr_v6(env, address, access_type, mmu_idx, | 131 | + uint32_t pupdr_reset; |
100 | - &result->phys, &result->attrs, | 132 | + |
101 | - &result->prot, &result->page_size, fi); | 133 | + /* |
102 | + result, fi); | 134 | + * External driving of pins. |
103 | } else { | 135 | + * The pins can be set externally through the device |
104 | return get_phys_addr_v5(env, address, access_type, mmu_idx, | 136 | + * anonymous input GPIOs lines under certain conditions. |
105 | &result->phys, &result->prot, | 137 | + * The pin must not be in push-pull output mode, |
138 | + * and can't be set high in open-drain mode. | ||
139 | + * Pins driven externally and configured to | ||
140 | + * output mode will in general be "disconnected" | ||
141 | + * (see `get_gpio_pinmask_to_disconnect()`) | ||
142 | + */ | ||
143 | + uint16_t disconnected_pins; | ||
144 | + uint16_t pins_connected_high; | ||
145 | + | ||
146 | + char *name; | ||
147 | + Clock *clk; | ||
148 | + qemu_irq pin[GPIO_NUM_PINS]; | ||
149 | +}; | ||
150 | + | ||
151 | +#endif | ||
152 | diff --git a/hw/gpio/stm32l4x5_gpio.c b/hw/gpio/stm32l4x5_gpio.c | ||
153 | new file mode 100644 | ||
154 | index XXXXXXX..XXXXXXX | ||
155 | --- /dev/null | ||
156 | +++ b/hw/gpio/stm32l4x5_gpio.c | ||
157 | @@ -XXX,XX +XXX,XX @@ | ||
158 | +/* | ||
159 | + * STM32L4x5 GPIO (General Purpose Input/Ouput) | ||
160 | + * | ||
161 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
162 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
163 | + * | ||
164 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
165 | + * | ||
166 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
167 | + * See the COPYING file in the top-level directory. | ||
168 | + */ | ||
169 | + | ||
170 | +/* | ||
171 | + * The reference used is the STMicroElectronics RM0351 Reference manual | ||
172 | + * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs. | ||
173 | + * https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html | ||
174 | + */ | ||
175 | + | ||
176 | +#include "qemu/osdep.h" | ||
177 | +#include "qemu/log.h" | ||
178 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
179 | +#include "hw/irq.h" | ||
180 | +#include "hw/qdev-clock.h" | ||
181 | +#include "hw/qdev-properties.h" | ||
182 | +#include "qapi/visitor.h" | ||
183 | +#include "qapi/error.h" | ||
184 | +#include "migration/vmstate.h" | ||
185 | +#include "trace.h" | ||
186 | + | ||
187 | +#define GPIO_MODER 0x00 | ||
188 | +#define GPIO_OTYPER 0x04 | ||
189 | +#define GPIO_OSPEEDR 0x08 | ||
190 | +#define GPIO_PUPDR 0x0C | ||
191 | +#define GPIO_IDR 0x10 | ||
192 | +#define GPIO_ODR 0x14 | ||
193 | +#define GPIO_BSRR 0x18 | ||
194 | +#define GPIO_LCKR 0x1C | ||
195 | +#define GPIO_AFRL 0x20 | ||
196 | +#define GPIO_AFRH 0x24 | ||
197 | +#define GPIO_BRR 0x28 | ||
198 | +#define GPIO_ASCR 0x2C | ||
199 | + | ||
200 | +/* 0b11111111_11111111_00000000_00000000 */ | ||
201 | +#define RESERVED_BITS_MASK 0xFFFF0000 | ||
202 | + | ||
203 | +static void update_gpio_idr(Stm32l4x5GpioState *s); | ||
204 | + | ||
205 | +static bool is_pull_up(Stm32l4x5GpioState *s, unsigned pin) | ||
206 | +{ | ||
207 | + return extract32(s->pupdr, 2 * pin, 2) == 1; | ||
208 | +} | ||
209 | + | ||
210 | +static bool is_pull_down(Stm32l4x5GpioState *s, unsigned pin) | ||
211 | +{ | ||
212 | + return extract32(s->pupdr, 2 * pin, 2) == 2; | ||
213 | +} | ||
214 | + | ||
215 | +static bool is_output(Stm32l4x5GpioState *s, unsigned pin) | ||
216 | +{ | ||
217 | + return extract32(s->moder, 2 * pin, 2) == 1; | ||
218 | +} | ||
219 | + | ||
220 | +static bool is_open_drain(Stm32l4x5GpioState *s, unsigned pin) | ||
221 | +{ | ||
222 | + return extract32(s->otyper, pin, 1) == 1; | ||
223 | +} | ||
224 | + | ||
225 | +static bool is_push_pull(Stm32l4x5GpioState *s, unsigned pin) | ||
226 | +{ | ||
227 | + return extract32(s->otyper, pin, 1) == 0; | ||
228 | +} | ||
229 | + | ||
230 | +static void stm32l4x5_gpio_reset_hold(Object *obj) | ||
231 | +{ | ||
232 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); | ||
233 | + | ||
234 | + s->moder = s->moder_reset; | ||
235 | + s->otyper = 0x00000000; | ||
236 | + s->ospeedr = s->ospeedr_reset; | ||
237 | + s->pupdr = s->pupdr_reset; | ||
238 | + s->idr = 0x00000000; | ||
239 | + s->odr = 0x00000000; | ||
240 | + s->lckr = 0x00000000; | ||
241 | + s->afrl = 0x00000000; | ||
242 | + s->afrh = 0x00000000; | ||
243 | + s->ascr = 0x00000000; | ||
244 | + | ||
245 | + s->disconnected_pins = 0xFFFF; | ||
246 | + s->pins_connected_high = 0x0000; | ||
247 | + update_gpio_idr(s); | ||
248 | +} | ||
249 | + | ||
250 | +static void stm32l4x5_gpio_set(void *opaque, int line, int level) | ||
251 | +{ | ||
252 | + Stm32l4x5GpioState *s = opaque; | ||
253 | + /* | ||
254 | + * The pin isn't set if line is configured in output mode | ||
255 | + * except if level is 0 and the output is open-drain. | ||
256 | + * This way there will be no short-circuit prone situations. | ||
257 | + */ | ||
258 | + if (is_output(s, line) && !(is_open_drain(s, line) && (level == 0))) { | ||
259 | + qemu_log_mask(LOG_GUEST_ERROR, "Line %d can't be driven externally\n", | ||
260 | + line); | ||
261 | + return; | ||
262 | + } | ||
263 | + | ||
264 | + s->disconnected_pins &= ~(1 << line); | ||
265 | + if (level) { | ||
266 | + s->pins_connected_high |= (1 << line); | ||
267 | + } else { | ||
268 | + s->pins_connected_high &= ~(1 << line); | ||
269 | + } | ||
270 | + trace_stm32l4x5_gpio_pins(s->name, s->disconnected_pins, | ||
271 | + s->pins_connected_high); | ||
272 | + update_gpio_idr(s); | ||
273 | +} | ||
274 | + | ||
275 | + | ||
276 | +static void update_gpio_idr(Stm32l4x5GpioState *s) | ||
277 | +{ | ||
278 | + uint32_t new_idr_mask = 0; | ||
279 | + uint32_t new_idr = s->odr; | ||
280 | + uint32_t old_idr = s->idr; | ||
281 | + int new_pin_state, old_pin_state; | ||
282 | + | ||
283 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { | ||
284 | + if (is_output(s, i)) { | ||
285 | + if (is_push_pull(s, i)) { | ||
286 | + new_idr_mask |= (1 << i); | ||
287 | + } else if (!(s->odr & (1 << i))) { | ||
288 | + /* open-drain ODR 0 */ | ||
289 | + new_idr_mask |= (1 << i); | ||
290 | + /* open-drain ODR 1 */ | ||
291 | + } else if (!(s->disconnected_pins & (1 << i)) && | ||
292 | + !(s->pins_connected_high & (1 << i))) { | ||
293 | + /* open-drain ODR 1 with pin connected low */ | ||
294 | + new_idr_mask |= (1 << i); | ||
295 | + new_idr &= ~(1 << i); | ||
296 | + /* open-drain ODR 1 with unactive pin */ | ||
297 | + } else if (is_pull_up(s, i)) { | ||
298 | + new_idr_mask |= (1 << i); | ||
299 | + } else if (is_pull_down(s, i)) { | ||
300 | + new_idr_mask |= (1 << i); | ||
301 | + new_idr &= ~(1 << i); | ||
302 | + } | ||
303 | + /* | ||
304 | + * The only case left is for open-drain ODR 1 | ||
305 | + * with unactive pin without pull-up or pull-down : | ||
306 | + * the value is floating. | ||
307 | + */ | ||
308 | + /* input or analog mode with connected pin */ | ||
309 | + } else if (!(s->disconnected_pins & (1 << i))) { | ||
310 | + if (s->pins_connected_high & (1 << i)) { | ||
311 | + /* pin high */ | ||
312 | + new_idr_mask |= (1 << i); | ||
313 | + new_idr |= (1 << i); | ||
314 | + } else { | ||
315 | + /* pin low */ | ||
316 | + new_idr_mask |= (1 << i); | ||
317 | + new_idr &= ~(1 << i); | ||
318 | + } | ||
319 | + /* input or analog mode with disconnected pin */ | ||
320 | + } else { | ||
321 | + if (is_pull_up(s, i)) { | ||
322 | + /* pull-up */ | ||
323 | + new_idr_mask |= (1 << i); | ||
324 | + new_idr |= (1 << i); | ||
325 | + } else if (is_pull_down(s, i)) { | ||
326 | + /* pull-down */ | ||
327 | + new_idr_mask |= (1 << i); | ||
328 | + new_idr &= ~(1 << i); | ||
329 | + } | ||
330 | + /* | ||
331 | + * The only case left is for a disconnected pin | ||
332 | + * without pull-up or pull-down : | ||
333 | + * the value is floating. | ||
334 | + */ | ||
335 | + } | ||
336 | + } | ||
337 | + | ||
338 | + s->idr = (old_idr & ~new_idr_mask) | (new_idr & new_idr_mask); | ||
339 | + trace_stm32l4x5_gpio_update_idr(s->name, old_idr, s->idr); | ||
340 | + | ||
341 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { | ||
342 | + if (new_idr_mask & (1 << i)) { | ||
343 | + new_pin_state = (new_idr & (1 << i)) > 0; | ||
344 | + old_pin_state = (old_idr & (1 << i)) > 0; | ||
345 | + if (new_pin_state > old_pin_state) { | ||
346 | + qemu_irq_raise(s->pin[i]); | ||
347 | + } else if (new_pin_state < old_pin_state) { | ||
348 | + qemu_irq_lower(s->pin[i]); | ||
349 | + } | ||
350 | + } | ||
351 | + } | ||
352 | +} | ||
353 | + | ||
354 | +/* | ||
355 | + * Return mask of pins that are both configured in output | ||
356 | + * mode and externally driven (except pins in open-drain | ||
357 | + * mode externally set to 0). | ||
358 | + */ | ||
359 | +static uint32_t get_gpio_pinmask_to_disconnect(Stm32l4x5GpioState *s) | ||
360 | +{ | ||
361 | + uint32_t pins_to_disconnect = 0; | ||
362 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { | ||
363 | + /* for each connected pin in output mode */ | ||
364 | + if (!(s->disconnected_pins & (1 << i)) && is_output(s, i)) { | ||
365 | + /* if either push-pull or high level */ | ||
366 | + if (is_push_pull(s, i) || s->pins_connected_high & (1 << i)) { | ||
367 | + pins_to_disconnect |= (1 << i); | ||
368 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
369 | + "Line %d can't be driven externally\n", | ||
370 | + i); | ||
371 | + } | ||
372 | + } | ||
373 | + } | ||
374 | + return pins_to_disconnect; | ||
375 | +} | ||
376 | + | ||
377 | +/* | ||
378 | + * Set field `disconnected_pins` and call `update_gpio_idr()` | ||
379 | + */ | ||
380 | +static void disconnect_gpio_pins(Stm32l4x5GpioState *s, uint16_t lines) | ||
381 | +{ | ||
382 | + s->disconnected_pins |= lines; | ||
383 | + trace_stm32l4x5_gpio_pins(s->name, s->disconnected_pins, | ||
384 | + s->pins_connected_high); | ||
385 | + update_gpio_idr(s); | ||
386 | +} | ||
387 | + | ||
388 | +static void disconnected_pins_set(Object *obj, Visitor *v, | ||
389 | + const char *name, void *opaque, Error **errp) | ||
390 | +{ | ||
391 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); | ||
392 | + uint16_t value; | ||
393 | + if (!visit_type_uint16(v, name, &value, errp)) { | ||
394 | + return; | ||
395 | + } | ||
396 | + disconnect_gpio_pins(s, value); | ||
397 | +} | ||
398 | + | ||
399 | +static void disconnected_pins_get(Object *obj, Visitor *v, | ||
400 | + const char *name, void *opaque, Error **errp) | ||
401 | +{ | ||
402 | + visit_type_uint16(v, name, (uint16_t *)opaque, errp); | ||
403 | +} | ||
404 | + | ||
405 | +static void clock_freq_get(Object *obj, Visitor *v, | ||
406 | + const char *name, void *opaque, Error **errp) | ||
407 | +{ | ||
408 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); | ||
409 | + uint32_t clock_freq_hz = clock_get_hz(s->clk); | ||
410 | + visit_type_uint32(v, name, &clock_freq_hz, errp); | ||
411 | +} | ||
412 | + | ||
413 | +static void stm32l4x5_gpio_write(void *opaque, hwaddr addr, | ||
414 | + uint64_t val64, unsigned int size) | ||
415 | +{ | ||
416 | + Stm32l4x5GpioState *s = opaque; | ||
417 | + | ||
418 | + uint32_t value = val64; | ||
419 | + trace_stm32l4x5_gpio_write(s->name, addr, val64); | ||
420 | + | ||
421 | + switch (addr) { | ||
422 | + case GPIO_MODER: | ||
423 | + s->moder = value; | ||
424 | + disconnect_gpio_pins(s, get_gpio_pinmask_to_disconnect(s)); | ||
425 | + qemu_log_mask(LOG_UNIMP, | ||
426 | + "%s: Analog and AF modes aren't supported\n\ | ||
427 | + Analog and AF mode behave like input mode\n", | ||
428 | + __func__); | ||
429 | + return; | ||
430 | + case GPIO_OTYPER: | ||
431 | + s->otyper = value & ~RESERVED_BITS_MASK; | ||
432 | + disconnect_gpio_pins(s, get_gpio_pinmask_to_disconnect(s)); | ||
433 | + return; | ||
434 | + case GPIO_OSPEEDR: | ||
435 | + qemu_log_mask(LOG_UNIMP, | ||
436 | + "%s: Changing I/O output speed isn't supported\n\ | ||
437 | + I/O speed is already maximal\n", | ||
438 | + __func__); | ||
439 | + s->ospeedr = value; | ||
440 | + return; | ||
441 | + case GPIO_PUPDR: | ||
442 | + s->pupdr = value; | ||
443 | + update_gpio_idr(s); | ||
444 | + return; | ||
445 | + case GPIO_IDR: | ||
446 | + qemu_log_mask(LOG_UNIMP, | ||
447 | + "%s: GPIO->IDR is read-only\n", | ||
448 | + __func__); | ||
449 | + return; | ||
450 | + case GPIO_ODR: | ||
451 | + s->odr = value & ~RESERVED_BITS_MASK; | ||
452 | + update_gpio_idr(s); | ||
453 | + return; | ||
454 | + case GPIO_BSRR: { | ||
455 | + uint32_t bits_to_reset = (value & RESERVED_BITS_MASK) >> GPIO_NUM_PINS; | ||
456 | + uint32_t bits_to_set = value & ~RESERVED_BITS_MASK; | ||
457 | + /* If both BSx and BRx are set, BSx has priority.*/ | ||
458 | + s->odr &= ~bits_to_reset; | ||
459 | + s->odr |= bits_to_set; | ||
460 | + update_gpio_idr(s); | ||
461 | + return; | ||
462 | + } | ||
463 | + case GPIO_LCKR: | ||
464 | + qemu_log_mask(LOG_UNIMP, | ||
465 | + "%s: Locking port bits configuration isn't supported\n", | ||
466 | + __func__); | ||
467 | + s->lckr = value & ~RESERVED_BITS_MASK; | ||
468 | + return; | ||
469 | + case GPIO_AFRL: | ||
470 | + qemu_log_mask(LOG_UNIMP, | ||
471 | + "%s: Alternate functions aren't supported\n", | ||
472 | + __func__); | ||
473 | + s->afrl = value; | ||
474 | + return; | ||
475 | + case GPIO_AFRH: | ||
476 | + qemu_log_mask(LOG_UNIMP, | ||
477 | + "%s: Alternate functions aren't supported\n", | ||
478 | + __func__); | ||
479 | + s->afrh = value; | ||
480 | + return; | ||
481 | + case GPIO_BRR: { | ||
482 | + uint32_t bits_to_reset = value & ~RESERVED_BITS_MASK; | ||
483 | + s->odr &= ~bits_to_reset; | ||
484 | + update_gpio_idr(s); | ||
485 | + return; | ||
486 | + } | ||
487 | + case GPIO_ASCR: | ||
488 | + qemu_log_mask(LOG_UNIMP, | ||
489 | + "%s: ADC function isn't supported\n", | ||
490 | + __func__); | ||
491 | + s->ascr = value & ~RESERVED_BITS_MASK; | ||
492 | + return; | ||
493 | + default: | ||
494 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
495 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
496 | + } | ||
497 | +} | ||
498 | + | ||
499 | +static uint64_t stm32l4x5_gpio_read(void *opaque, hwaddr addr, | ||
500 | + unsigned int size) | ||
501 | +{ | ||
502 | + Stm32l4x5GpioState *s = opaque; | ||
503 | + | ||
504 | + trace_stm32l4x5_gpio_read(s->name, addr); | ||
505 | + | ||
506 | + switch (addr) { | ||
507 | + case GPIO_MODER: | ||
508 | + return s->moder; | ||
509 | + case GPIO_OTYPER: | ||
510 | + return s->otyper; | ||
511 | + case GPIO_OSPEEDR: | ||
512 | + return s->ospeedr; | ||
513 | + case GPIO_PUPDR: | ||
514 | + return s->pupdr; | ||
515 | + case GPIO_IDR: | ||
516 | + return s->idr; | ||
517 | + case GPIO_ODR: | ||
518 | + return s->odr; | ||
519 | + case GPIO_BSRR: | ||
520 | + return 0; | ||
521 | + case GPIO_LCKR: | ||
522 | + return s->lckr; | ||
523 | + case GPIO_AFRL: | ||
524 | + return s->afrl; | ||
525 | + case GPIO_AFRH: | ||
526 | + return s->afrh; | ||
527 | + case GPIO_BRR: | ||
528 | + return 0; | ||
529 | + case GPIO_ASCR: | ||
530 | + return s->ascr; | ||
531 | + default: | ||
532 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
533 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
534 | + return 0; | ||
535 | + } | ||
536 | +} | ||
537 | + | ||
538 | +static const MemoryRegionOps stm32l4x5_gpio_ops = { | ||
539 | + .read = stm32l4x5_gpio_read, | ||
540 | + .write = stm32l4x5_gpio_write, | ||
541 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
542 | + .impl = { | ||
543 | + .min_access_size = 4, | ||
544 | + .max_access_size = 4, | ||
545 | + .unaligned = false, | ||
546 | + }, | ||
547 | + .valid = { | ||
548 | + .min_access_size = 4, | ||
549 | + .max_access_size = 4, | ||
550 | + .unaligned = false, | ||
551 | + }, | ||
552 | +}; | ||
553 | + | ||
554 | +static void stm32l4x5_gpio_init(Object *obj) | ||
555 | +{ | ||
556 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); | ||
557 | + | ||
558 | + memory_region_init_io(&s->mmio, obj, &stm32l4x5_gpio_ops, s, | ||
559 | + TYPE_STM32L4X5_GPIO, 0x400); | ||
560 | + | ||
561 | + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | ||
562 | + | ||
563 | + qdev_init_gpio_out(DEVICE(obj), s->pin, GPIO_NUM_PINS); | ||
564 | + qdev_init_gpio_in(DEVICE(obj), stm32l4x5_gpio_set, GPIO_NUM_PINS); | ||
565 | + | ||
566 | + s->clk = qdev_init_clock_in(DEVICE(s), "clk", NULL, s, 0); | ||
567 | + | ||
568 | + object_property_add(obj, "disconnected-pins", "uint16", | ||
569 | + disconnected_pins_get, disconnected_pins_set, | ||
570 | + NULL, &s->disconnected_pins); | ||
571 | + object_property_add(obj, "clock-freq-hz", "uint32", | ||
572 | + clock_freq_get, NULL, NULL, NULL); | ||
573 | +} | ||
574 | + | ||
575 | +static void stm32l4x5_gpio_realize(DeviceState *dev, Error **errp) | ||
576 | +{ | ||
577 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(dev); | ||
578 | + if (!clock_has_source(s->clk)) { | ||
579 | + error_setg(errp, "GPIO: clk input must be connected"); | ||
580 | + return; | ||
581 | + } | ||
582 | +} | ||
583 | + | ||
584 | +static const VMStateDescription vmstate_stm32l4x5_gpio = { | ||
585 | + .name = TYPE_STM32L4X5_GPIO, | ||
586 | + .version_id = 1, | ||
587 | + .minimum_version_id = 1, | ||
588 | + .fields = (VMStateField[]){ | ||
589 | + VMSTATE_UINT32(moder, Stm32l4x5GpioState), | ||
590 | + VMSTATE_UINT32(otyper, Stm32l4x5GpioState), | ||
591 | + VMSTATE_UINT32(ospeedr, Stm32l4x5GpioState), | ||
592 | + VMSTATE_UINT32(pupdr, Stm32l4x5GpioState), | ||
593 | + VMSTATE_UINT32(idr, Stm32l4x5GpioState), | ||
594 | + VMSTATE_UINT32(odr, Stm32l4x5GpioState), | ||
595 | + VMSTATE_UINT32(lckr, Stm32l4x5GpioState), | ||
596 | + VMSTATE_UINT32(afrl, Stm32l4x5GpioState), | ||
597 | + VMSTATE_UINT32(afrh, Stm32l4x5GpioState), | ||
598 | + VMSTATE_UINT32(ascr, Stm32l4x5GpioState), | ||
599 | + VMSTATE_UINT16(disconnected_pins, Stm32l4x5GpioState), | ||
600 | + VMSTATE_UINT16(pins_connected_high, Stm32l4x5GpioState), | ||
601 | + VMSTATE_END_OF_LIST() | ||
602 | + } | ||
603 | +}; | ||
604 | + | ||
605 | +static Property stm32l4x5_gpio_properties[] = { | ||
606 | + DEFINE_PROP_STRING("name", Stm32l4x5GpioState, name), | ||
607 | + DEFINE_PROP_UINT32("mode-reset", Stm32l4x5GpioState, moder_reset, 0), | ||
608 | + DEFINE_PROP_UINT32("ospeed-reset", Stm32l4x5GpioState, ospeedr_reset, 0), | ||
609 | + DEFINE_PROP_UINT32("pupd-reset", Stm32l4x5GpioState, pupdr_reset, 0), | ||
610 | + DEFINE_PROP_END_OF_LIST(), | ||
611 | +}; | ||
612 | + | ||
613 | +static void stm32l4x5_gpio_class_init(ObjectClass *klass, void *data) | ||
614 | +{ | ||
615 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
616 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
617 | + | ||
618 | + device_class_set_props(dc, stm32l4x5_gpio_properties); | ||
619 | + dc->vmsd = &vmstate_stm32l4x5_gpio; | ||
620 | + dc->realize = stm32l4x5_gpio_realize; | ||
621 | + rc->phases.hold = stm32l4x5_gpio_reset_hold; | ||
622 | +} | ||
623 | + | ||
624 | +static const TypeInfo stm32l4x5_gpio_types[] = { | ||
625 | + { | ||
626 | + .name = TYPE_STM32L4X5_GPIO, | ||
627 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
628 | + .instance_size = sizeof(Stm32l4x5GpioState), | ||
629 | + .instance_init = stm32l4x5_gpio_init, | ||
630 | + .class_init = stm32l4x5_gpio_class_init, | ||
631 | + }, | ||
632 | +}; | ||
633 | + | ||
634 | +DEFINE_TYPES(stm32l4x5_gpio_types) | ||
635 | diff --git a/hw/gpio/Kconfig b/hw/gpio/Kconfig | ||
636 | index XXXXXXX..XXXXXXX 100644 | ||
637 | --- a/hw/gpio/Kconfig | ||
638 | +++ b/hw/gpio/Kconfig | ||
639 | @@ -XXX,XX +XXX,XX @@ config GPIO_PWR | ||
640 | |||
641 | config SIFIVE_GPIO | ||
642 | bool | ||
643 | + | ||
644 | +config STM32L4X5_GPIO | ||
645 | + bool | ||
646 | diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build | ||
647 | index XXXXXXX..XXXXXXX 100644 | ||
648 | --- a/hw/gpio/meson.build | ||
649 | +++ b/hw/gpio/meson.build | ||
650 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_RASPI', if_true: files( | ||
651 | 'bcm2835_gpio.c', | ||
652 | 'bcm2838_gpio.c' | ||
653 | )) | ||
654 | +system_ss.add(when: 'CONFIG_STM32L4X5_SOC', if_true: files('stm32l4x5_gpio.c')) | ||
655 | system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_gpio.c')) | ||
656 | system_ss.add(when: 'CONFIG_SIFIVE_GPIO', if_true: files('sifive_gpio.c')) | ||
657 | diff --git a/hw/gpio/trace-events b/hw/gpio/trace-events | ||
658 | index XXXXXXX..XXXXXXX 100644 | ||
659 | --- a/hw/gpio/trace-events | ||
660 | +++ b/hw/gpio/trace-events | ||
661 | @@ -XXX,XX +XXX,XX @@ sifive_gpio_update_output_irq(int64_t line, int64_t value) "line %" PRIi64 " val | ||
662 | # aspeed_gpio.c | ||
663 | aspeed_gpio_read(uint64_t offset, uint64_t value) "offset: 0x%" PRIx64 " value 0x%" PRIx64 | ||
664 | aspeed_gpio_write(uint64_t offset, uint64_t value) "offset: 0x%" PRIx64 " value 0x%" PRIx64 | ||
665 | + | ||
666 | +# stm32l4x5_gpio.c | ||
667 | +stm32l4x5_gpio_read(char *gpio, uint64_t addr) "GPIO%s addr: 0x%" PRIx64 " " | ||
668 | +stm32l4x5_gpio_write(char *gpio, uint64_t addr, uint64_t data) "GPIO%s addr: 0x%" PRIx64 " val: 0x%" PRIx64 "" | ||
669 | +stm32l4x5_gpio_update_idr(char *gpio, uint32_t old_idr, uint32_t new_idr) "GPIO%s from: 0x%x to: 0x%x" | ||
670 | +stm32l4x5_gpio_pins(char *gpio, uint16_t disconnected, uint16_t high) "GPIO%s disconnected pins: 0x%x levels: 0x%x" | ||
106 | -- | 671 | -- |
107 | 2.25.1 | 672 | 2.34.1 |
108 | 673 | ||
109 | 674 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 3 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
5 | Message-id: 20220822152741.1617527-9-richard.henderson@linaro.org | 5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Acked-by: Alistair Francis <alistair.francis@wdc.com> |
7 | Message-id: 20240305210444.310665-3-ines.varhol@telecom-paris.fr | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 9 | --- |
9 | target/arm/ptw.c | 28 ++++++++++++++-------------- | 10 | include/hw/arm/stm32l4x5_soc.h | 2 + |
10 | 1 file changed, 14 insertions(+), 14 deletions(-) | 11 | include/hw/gpio/stm32l4x5_gpio.h | 1 + |
11 | 12 | include/hw/misc/stm32l4x5_syscfg.h | 3 +- | |
12 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | 13 | hw/arm/stm32l4x5_soc.c | 71 +++++++++++++++++++++++------- |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | hw/misc/stm32l4x5_syscfg.c | 1 + |
14 | --- a/target/arm/ptw.c | 15 | hw/arm/Kconfig | 3 +- |
15 | +++ b/target/arm/ptw.c | 16 | 6 files changed, 63 insertions(+), 18 deletions(-) |
16 | @@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address, | 17 | |
17 | 18 | diff --git a/include/hw/arm/stm32l4x5_soc.h b/include/hw/arm/stm32l4x5_soc.h | |
18 | static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | 19 | index XXXXXXX..XXXXXXX 100644 |
19 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 20 | --- a/include/hw/arm/stm32l4x5_soc.h |
20 | - hwaddr *phys_ptr, MemTxAttrs *txattrs, | 21 | +++ b/include/hw/arm/stm32l4x5_soc.h |
21 | - int *prot, target_ulong *page_size, | 22 | @@ -XXX,XX +XXX,XX @@ |
22 | + GetPhysAddrResult *result, | 23 | #include "hw/misc/stm32l4x5_syscfg.h" |
23 | ARMMMUFaultInfo *fi) | 24 | #include "hw/misc/stm32l4x5_exti.h" |
25 | #include "hw/misc/stm32l4x5_rcc.h" | ||
26 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
27 | #include "qom/object.h" | ||
28 | |||
29 | #define TYPE_STM32L4X5_SOC "stm32l4x5-soc" | ||
30 | @@ -XXX,XX +XXX,XX @@ struct Stm32l4x5SocState { | ||
31 | OrIRQState exti_or_gates[NUM_EXTI_OR_GATES]; | ||
32 | Stm32l4x5SyscfgState syscfg; | ||
33 | Stm32l4x5RccState rcc; | ||
34 | + Stm32l4x5GpioState gpio[NUM_GPIOS]; | ||
35 | |||
36 | MemoryRegion sram1; | ||
37 | MemoryRegion sram2; | ||
38 | diff --git a/include/hw/gpio/stm32l4x5_gpio.h b/include/hw/gpio/stm32l4x5_gpio.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/include/hw/gpio/stm32l4x5_gpio.h | ||
41 | +++ b/include/hw/gpio/stm32l4x5_gpio.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | #define TYPE_STM32L4X5_GPIO "stm32l4x5-gpio" | ||
44 | OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5GpioState, STM32L4X5_GPIO) | ||
45 | |||
46 | +#define NUM_GPIOS 8 | ||
47 | #define GPIO_NUM_PINS 16 | ||
48 | |||
49 | struct Stm32l4x5GpioState { | ||
50 | diff --git a/include/hw/misc/stm32l4x5_syscfg.h b/include/hw/misc/stm32l4x5_syscfg.h | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/include/hw/misc/stm32l4x5_syscfg.h | ||
53 | +++ b/include/hw/misc/stm32l4x5_syscfg.h | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | |||
56 | #include "hw/sysbus.h" | ||
57 | #include "qom/object.h" | ||
58 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
59 | |||
60 | #define TYPE_STM32L4X5_SYSCFG "stm32l4x5-syscfg" | ||
61 | OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5SyscfgState, STM32L4X5_SYSCFG) | ||
62 | |||
63 | -#define NUM_GPIOS 8 | ||
64 | -#define GPIO_NUM_PINS 16 | ||
65 | #define SYSCFG_NUM_EXTICR 4 | ||
66 | |||
67 | struct Stm32l4x5SyscfgState { | ||
68 | diff --git a/hw/arm/stm32l4x5_soc.c b/hw/arm/stm32l4x5_soc.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/arm/stm32l4x5_soc.c | ||
71 | +++ b/hw/arm/stm32l4x5_soc.c | ||
72 | @@ -XXX,XX +XXX,XX @@ | ||
73 | #include "sysemu/sysemu.h" | ||
74 | #include "hw/or-irq.h" | ||
75 | #include "hw/arm/stm32l4x5_soc.h" | ||
76 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
77 | #include "hw/qdev-clock.h" | ||
78 | #include "hw/misc/unimp.h" | ||
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ static const int exti_or_gate1_lines_in[EXTI_OR_GATE1_NUM_LINES_IN] = { | ||
81 | 16, 35, 36, 37, 38, | ||
82 | }; | ||
83 | |||
84 | +static const struct { | ||
85 | + uint32_t addr; | ||
86 | + uint32_t moder_reset; | ||
87 | + uint32_t ospeedr_reset; | ||
88 | + uint32_t pupdr_reset; | ||
89 | +} stm32l4x5_gpio_cfg[NUM_GPIOS] = { | ||
90 | + { 0x48000000, 0xABFFFFFF, 0x0C000000, 0x64000000 }, | ||
91 | + { 0x48000400, 0xFFFFFEBF, 0x00000000, 0x00000100 }, | ||
92 | + { 0x48000800, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
93 | + { 0x48000C00, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
94 | + { 0x48001000, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
95 | + { 0x48001400, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
96 | + { 0x48001800, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
97 | + { 0x48001C00, 0x0000000F, 0x00000000, 0x00000000 }, | ||
98 | +}; | ||
99 | + | ||
100 | static void stm32l4x5_soc_initfn(Object *obj) | ||
24 | { | 101 | { |
25 | uint32_t secure = regime_is_secure(env, mmu_idx); | 102 | Stm32l4x5SocState *s = STM32L4X5_SOC(obj); |
26 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | 103 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_initfn(Object *obj) |
27 | } else { | 104 | } |
28 | fi->type = ARMFault_QEMU_SFault; | 105 | object_initialize_child(obj, "syscfg", &s->syscfg, TYPE_STM32L4X5_SYSCFG); |
29 | } | 106 | object_initialize_child(obj, "rcc", &s->rcc, TYPE_STM32L4X5_RCC); |
30 | - *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE; | 107 | + |
31 | - *phys_ptr = address; | 108 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { |
32 | - *prot = 0; | 109 | + g_autofree char *name = g_strdup_printf("gpio%c", 'a' + i); |
33 | + result->page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE; | 110 | + object_initialize_child(obj, name, &s->gpio[i], TYPE_STM32L4X5_GPIO); |
34 | + result->phys = address; | 111 | + } |
35 | + result->prot = 0; | 112 | } |
36 | return true; | 113 | |
37 | } | 114 | static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) |
38 | } else { | 115 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) |
39 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | 116 | Stm32l4x5SocState *s = STM32L4X5_SOC(dev_soc); |
40 | * might downgrade a secure access to nonsecure. | 117 | const Stm32l4x5SocClass *sc = STM32L4X5_SOC_GET_CLASS(dev_soc); |
41 | */ | 118 | MemoryRegion *system_memory = get_system_memory(); |
42 | if (sattrs.ns) { | 119 | - DeviceState *armv7m; |
43 | - txattrs->secure = false; | 120 | + DeviceState *armv7m, *dev; |
44 | + result->attrs.secure = false; | 121 | SysBusDevice *busdev; |
45 | } else if (!secure) { | 122 | + uint32_t pin_index; |
46 | /* | 123 | |
47 | * NS access to S memory must fault. | 124 | if (!memory_region_init_rom(&s->flash, OBJECT(dev_soc), "flash", |
48 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | 125 | sc->flash_size, errp)) { |
49 | * for M_FAKE_FSR_SFAULT in arm_v7m_cpu_do_interrupt(). | 126 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) |
50 | */ | 127 | return; |
51 | fi->type = ARMFault_QEMU_SFault; | 128 | } |
52 | - *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE; | 129 | |
53 | - *phys_ptr = address; | 130 | + /* GPIOs */ |
54 | - *prot = 0; | 131 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { |
55 | + result->page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE; | 132 | + g_autofree char *name = g_strdup_printf("%c", 'A' + i); |
56 | + result->phys = address; | 133 | + dev = DEVICE(&s->gpio[i]); |
57 | + result->prot = 0; | 134 | + qdev_prop_set_string(dev, "name", name); |
58 | return true; | 135 | + qdev_prop_set_uint32(dev, "mode-reset", |
59 | } | 136 | + stm32l4x5_gpio_cfg[i].moder_reset); |
137 | + qdev_prop_set_uint32(dev, "ospeed-reset", | ||
138 | + stm32l4x5_gpio_cfg[i].ospeedr_reset); | ||
139 | + qdev_prop_set_uint32(dev, "pupd-reset", | ||
140 | + stm32l4x5_gpio_cfg[i].pupdr_reset); | ||
141 | + busdev = SYS_BUS_DEVICE(&s->gpio[i]); | ||
142 | + g_free(name); | ||
143 | + name = g_strdup_printf("gpio%c-out", 'a' + i); | ||
144 | + qdev_connect_clock_in(DEVICE(&s->gpio[i]), "clk", | ||
145 | + qdev_get_clock_out(DEVICE(&(s->rcc)), name)); | ||
146 | + if (!sysbus_realize(busdev, errp)) { | ||
147 | + return; | ||
148 | + } | ||
149 | + sysbus_mmio_map(busdev, 0, stm32l4x5_gpio_cfg[i].addr); | ||
150 | + } | ||
151 | + | ||
152 | /* System configuration controller */ | ||
153 | busdev = SYS_BUS_DEVICE(&s->syscfg); | ||
154 | if (!sysbus_realize(busdev, errp)) { | ||
155 | return; | ||
156 | } | ||
157 | sysbus_mmio_map(busdev, 0, SYSCFG_ADDR); | ||
158 | - /* | ||
159 | - * TODO: when the GPIO device is implemented, connect it | ||
160 | - * to SYCFG using `qdev_connect_gpio_out`, NUM_GPIOS and | ||
161 | - * GPIO_NUM_PINS. | ||
162 | - */ | ||
163 | + | ||
164 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { | ||
165 | + for (unsigned j = 0; j < GPIO_NUM_PINS; j++) { | ||
166 | + pin_index = GPIO_NUM_PINS * i + j; | ||
167 | + qdev_connect_gpio_out(DEVICE(&s->gpio[i]), j, | ||
168 | + qdev_get_gpio_in(DEVICE(&s->syscfg), | ||
169 | + pin_index)); | ||
170 | + } | ||
171 | + } | ||
172 | |||
173 | /* EXTI device */ | ||
174 | busdev = SYS_BUS_DEVICE(&s->exti); | ||
175 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
60 | } | 176 | } |
61 | } | 177 | } |
62 | 178 | ||
63 | - ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr, | 179 | - for (unsigned i = 0; i < 16; i++) { |
64 | - txattrs, prot, &mpu_is_subpage, fi, NULL); | 180 | + for (unsigned i = 0; i < GPIO_NUM_PINS; i++) { |
65 | - *page_size = sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE; | 181 | qdev_connect_gpio_out(DEVICE(&s->syscfg), i, |
66 | + ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, | 182 | qdev_get_gpio_in(DEVICE(&s->exti), i)); |
67 | + &result->phys, &result->attrs, &result->prot, | 183 | } |
68 | + &mpu_is_subpage, fi, NULL); | 184 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) |
69 | + result->page_size = | 185 | /* RESERVED: 0x40024400, 0x7FDBC00 */ |
70 | + sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE; | 186 | |
71 | return ret; | 187 | /* AHB2 BUS */ |
72 | } | 188 | - create_unimplemented_device("GPIOA", 0x48000000, 0x400); |
73 | 189 | - create_unimplemented_device("GPIOB", 0x48000400, 0x400); | |
74 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | 190 | - create_unimplemented_device("GPIOC", 0x48000800, 0x400); |
75 | if (arm_feature(env, ARM_FEATURE_V8)) { | 191 | - create_unimplemented_device("GPIOD", 0x48000C00, 0x400); |
76 | /* PMSAv8 */ | 192 | - create_unimplemented_device("GPIOE", 0x48001000, 0x400); |
77 | ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx, | 193 | - create_unimplemented_device("GPIOF", 0x48001400, 0x400); |
78 | - &result->phys, &result->attrs, | 194 | - create_unimplemented_device("GPIOG", 0x48001800, 0x400); |
79 | - &result->prot, &result->page_size, fi); | 195 | - create_unimplemented_device("GPIOH", 0x48001C00, 0x400); |
80 | + result, fi); | 196 | /* RESERVED: 0x48002000, 0x7FDBC00 */ |
81 | } else if (arm_feature(env, ARM_FEATURE_V7)) { | 197 | create_unimplemented_device("OTG_FS", 0x50000000, 0x40000); |
82 | /* PMSAv7 */ | 198 | create_unimplemented_device("ADC", 0x50040000, 0x400); |
83 | ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, | 199 | diff --git a/hw/misc/stm32l4x5_syscfg.c b/hw/misc/stm32l4x5_syscfg.c |
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/hw/misc/stm32l4x5_syscfg.c | ||
202 | +++ b/hw/misc/stm32l4x5_syscfg.c | ||
203 | @@ -XXX,XX +XXX,XX @@ | ||
204 | #include "hw/irq.h" | ||
205 | #include "migration/vmstate.h" | ||
206 | #include "hw/misc/stm32l4x5_syscfg.h" | ||
207 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
208 | |||
209 | #define SYSCFG_MEMRMP 0x00 | ||
210 | #define SYSCFG_CFGR1 0x04 | ||
211 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
212 | index XXXXXXX..XXXXXXX 100644 | ||
213 | --- a/hw/arm/Kconfig | ||
214 | +++ b/hw/arm/Kconfig | ||
215 | @@ -XXX,XX +XXX,XX @@ config STM32L4X5_SOC | ||
216 | bool | ||
217 | select ARM_V7M | ||
218 | select OR_IRQ | ||
219 | - select STM32L4X5_SYSCFG | ||
220 | select STM32L4X5_EXTI | ||
221 | + select STM32L4X5_SYSCFG | ||
222 | select STM32L4X5_RCC | ||
223 | + select STM32L4X5_GPIO | ||
224 | |||
225 | config XLNX_ZYNQMP_ARM | ||
226 | bool | ||
84 | -- | 227 | -- |
85 | 2.25.1 | 228 | 2.34.1 |
86 | 229 | ||
87 | 230 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 3 | The testcase contains : |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | - `test_idr_reset_value()` : |
5 | Message-id: 20220822152741.1617527-8-richard.henderson@linaro.org | 5 | Checks the reset values of MODER, OTYPER, PUPDR, ODR and IDR. |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | - `test_gpio_output_mode()` : |
7 | Checks that writing a bit in register ODR results in the corresponding | ||
8 | pin rising or lowering, if this pin is configured in output mode. | ||
9 | - `test_gpio_input_mode()` : | ||
10 | Checks that a input pin set high or low externally results | ||
11 | in the pin rising and lowering. | ||
12 | - `test_pull_up_pull_down()` : | ||
13 | Checks that a floating pin in pull-up/down mode is actually high/down. | ||
14 | - `test_push_pull()` : | ||
15 | Checks that a pin set externally is disconnected when configured in | ||
16 | push-pull output mode, and can't be set externally while in this mode. | ||
17 | - `test_open_drain()` : | ||
18 | Checks that a pin set externally high is disconnected when configured | ||
19 | in open-drain output mode, and can't be set high while in this mode. | ||
20 | - `test_bsrr_brr()` : | ||
21 | Checks that writing to BSRR and BRR has the desired result in ODR. | ||
22 | - `test_clock_enable()` : | ||
23 | Checks that GPIO clock is at the right frequency after enabling it. | ||
24 | |||
25 | Acked-by: Thomas Huth <thuth@redhat.com> | ||
26 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
27 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | ||
28 | Message-id: 20240305210444.310665-4-ines.varhol@telecom-paris.fr | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 30 | --- |
9 | target/arm/ptw.c | 36 +++++++++++++++++------------------- | 31 | tests/qtest/stm32l4x5_gpio-test.c | 551 ++++++++++++++++++++++++++++++ |
10 | 1 file changed, 17 insertions(+), 19 deletions(-) | 32 | tests/qtest/meson.build | 3 +- |
33 | 2 files changed, 553 insertions(+), 1 deletion(-) | ||
34 | create mode 100644 tests/qtest/stm32l4x5_gpio-test.c | ||
11 | 35 | ||
12 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | 36 | diff --git a/tests/qtest/stm32l4x5_gpio-test.c b/tests/qtest/stm32l4x5_gpio-test.c |
37 | new file mode 100644 | ||
38 | index XXXXXXX..XXXXXXX | ||
39 | --- /dev/null | ||
40 | +++ b/tests/qtest/stm32l4x5_gpio-test.c | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | +/* | ||
43 | + * QTest testcase for STM32L4x5_GPIO | ||
44 | + * | ||
45 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
46 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
47 | + * | ||
48 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
49 | + * See the COPYING file in the top-level directory. | ||
50 | + */ | ||
51 | + | ||
52 | +#include "qemu/osdep.h" | ||
53 | +#include "libqtest-single.h" | ||
54 | + | ||
55 | +#define GPIO_BASE_ADDR 0x48000000 | ||
56 | +#define GPIO_SIZE 0x400 | ||
57 | +#define NUM_GPIOS 8 | ||
58 | +#define NUM_GPIO_PINS 16 | ||
59 | + | ||
60 | +#define GPIO_A 0x48000000 | ||
61 | +#define GPIO_B 0x48000400 | ||
62 | +#define GPIO_C 0x48000800 | ||
63 | +#define GPIO_D 0x48000C00 | ||
64 | +#define GPIO_E 0x48001000 | ||
65 | +#define GPIO_F 0x48001400 | ||
66 | +#define GPIO_G 0x48001800 | ||
67 | +#define GPIO_H 0x48001C00 | ||
68 | + | ||
69 | +#define MODER 0x00 | ||
70 | +#define OTYPER 0x04 | ||
71 | +#define PUPDR 0x0C | ||
72 | +#define IDR 0x10 | ||
73 | +#define ODR 0x14 | ||
74 | +#define BSRR 0x18 | ||
75 | +#define BRR 0x28 | ||
76 | + | ||
77 | +#define MODER_INPUT 0 | ||
78 | +#define MODER_OUTPUT 1 | ||
79 | + | ||
80 | +#define PUPDR_NONE 0 | ||
81 | +#define PUPDR_PULLUP 1 | ||
82 | +#define PUPDR_PULLDOWN 2 | ||
83 | + | ||
84 | +#define OTYPER_PUSH_PULL 0 | ||
85 | +#define OTYPER_OPEN_DRAIN 1 | ||
86 | + | ||
87 | +const uint32_t moder_reset[NUM_GPIOS] = { | ||
88 | + 0xABFFFFFF, | ||
89 | + 0xFFFFFEBF, | ||
90 | + 0xFFFFFFFF, | ||
91 | + 0xFFFFFFFF, | ||
92 | + 0xFFFFFFFF, | ||
93 | + 0xFFFFFFFF, | ||
94 | + 0xFFFFFFFF, | ||
95 | + 0x0000000F | ||
96 | +}; | ||
97 | + | ||
98 | +const uint32_t pupdr_reset[NUM_GPIOS] = { | ||
99 | + 0x64000000, | ||
100 | + 0x00000100, | ||
101 | + 0x00000000, | ||
102 | + 0x00000000, | ||
103 | + 0x00000000, | ||
104 | + 0x00000000, | ||
105 | + 0x00000000, | ||
106 | + 0x00000000 | ||
107 | +}; | ||
108 | + | ||
109 | +const uint32_t idr_reset[NUM_GPIOS] = { | ||
110 | + 0x0000A000, | ||
111 | + 0x00000010, | ||
112 | + 0x00000000, | ||
113 | + 0x00000000, | ||
114 | + 0x00000000, | ||
115 | + 0x00000000, | ||
116 | + 0x00000000, | ||
117 | + 0x00000000 | ||
118 | +}; | ||
119 | + | ||
120 | +static uint32_t gpio_readl(unsigned int gpio, unsigned int offset) | ||
121 | +{ | ||
122 | + return readl(gpio + offset); | ||
123 | +} | ||
124 | + | ||
125 | +static void gpio_writel(unsigned int gpio, unsigned int offset, uint32_t value) | ||
126 | +{ | ||
127 | + writel(gpio + offset, value); | ||
128 | +} | ||
129 | + | ||
130 | +static void gpio_set_bit(unsigned int gpio, unsigned int reg, | ||
131 | + unsigned int pin, uint32_t value) | ||
132 | +{ | ||
133 | + uint32_t mask = 0xFFFFFFFF & ~(0x1 << pin); | ||
134 | + gpio_writel(gpio, reg, (gpio_readl(gpio, reg) & mask) | value << pin); | ||
135 | +} | ||
136 | + | ||
137 | +static void gpio_set_2bits(unsigned int gpio, unsigned int reg, | ||
138 | + unsigned int pin, uint32_t value) | ||
139 | +{ | ||
140 | + uint32_t offset = 2 * pin; | ||
141 | + uint32_t mask = 0xFFFFFFFF & ~(0x3 << offset); | ||
142 | + gpio_writel(gpio, reg, (gpio_readl(gpio, reg) & mask) | value << offset); | ||
143 | +} | ||
144 | + | ||
145 | +static unsigned int get_gpio_id(uint32_t gpio_addr) | ||
146 | +{ | ||
147 | + return (gpio_addr - GPIO_BASE_ADDR) / GPIO_SIZE; | ||
148 | +} | ||
149 | + | ||
150 | +static void gpio_set_irq(unsigned int gpio, int num, int level) | ||
151 | +{ | ||
152 | + g_autofree char *name = g_strdup_printf("/machine/soc/gpio%c", | ||
153 | + get_gpio_id(gpio) + 'a'); | ||
154 | + qtest_set_irq_in(global_qtest, name, NULL, num, level); | ||
155 | +} | ||
156 | + | ||
157 | +static void disconnect_all_pins(unsigned int gpio) | ||
158 | +{ | ||
159 | + g_autofree char *path = g_strdup_printf("/machine/soc/gpio%c", | ||
160 | + get_gpio_id(gpio) + 'a'); | ||
161 | + QDict *r; | ||
162 | + | ||
163 | + r = qtest_qmp(global_qtest, "{ 'execute': 'qom-set', 'arguments': " | ||
164 | + "{ 'path': %s, 'property': 'disconnected-pins', 'value': %d } }", | ||
165 | + path, 0xFFFF); | ||
166 | + g_assert_false(qdict_haskey(r, "error")); | ||
167 | + qobject_unref(r); | ||
168 | +} | ||
169 | + | ||
170 | +static uint32_t get_disconnected_pins(unsigned int gpio) | ||
171 | +{ | ||
172 | + g_autofree char *path = g_strdup_printf("/machine/soc/gpio%c", | ||
173 | + get_gpio_id(gpio) + 'a'); | ||
174 | + uint32_t disconnected_pins = 0; | ||
175 | + QDict *r; | ||
176 | + | ||
177 | + r = qtest_qmp(global_qtest, "{ 'execute': 'qom-get', 'arguments':" | ||
178 | + " { 'path': %s, 'property': 'disconnected-pins'} }", path); | ||
179 | + g_assert_false(qdict_haskey(r, "error")); | ||
180 | + disconnected_pins = qdict_get_int(r, "return"); | ||
181 | + qobject_unref(r); | ||
182 | + return disconnected_pins; | ||
183 | +} | ||
184 | + | ||
185 | +static uint32_t reset(uint32_t gpio, unsigned int offset) | ||
186 | +{ | ||
187 | + switch (offset) { | ||
188 | + case MODER: | ||
189 | + return moder_reset[get_gpio_id(gpio)]; | ||
190 | + case PUPDR: | ||
191 | + return pupdr_reset[get_gpio_id(gpio)]; | ||
192 | + case IDR: | ||
193 | + return idr_reset[get_gpio_id(gpio)]; | ||
194 | + } | ||
195 | + return 0x0; | ||
196 | +} | ||
197 | + | ||
198 | +static void system_reset(void) | ||
199 | +{ | ||
200 | + QDict *r; | ||
201 | + r = qtest_qmp(global_qtest, "{'execute': 'system_reset'}"); | ||
202 | + g_assert_false(qdict_haskey(r, "error")); | ||
203 | + qobject_unref(r); | ||
204 | +} | ||
205 | + | ||
206 | +static void test_idr_reset_value(void) | ||
207 | +{ | ||
208 | + /* | ||
209 | + * Checks that the values in MODER, OTYPER, PUPDR and ODR | ||
210 | + * after reset are correct, and that the value in IDR is | ||
211 | + * coherent. | ||
212 | + * Since AF and analog modes aren't implemented, IDR reset | ||
213 | + * values aren't the same as with a real board. | ||
214 | + * | ||
215 | + * Register IDR contains the actual values of all GPIO pins. | ||
216 | + * Its value depends on the pins' configuration | ||
217 | + * (intput/output/analog : register MODER, push-pull/open-drain : | ||
218 | + * register OTYPER, pull-up/pull-down/none : register PUPDR) | ||
219 | + * and on the values stored in register ODR | ||
220 | + * (in case the pin is in output mode). | ||
221 | + */ | ||
222 | + | ||
223 | + gpio_writel(GPIO_A, MODER, 0xDEADBEEF); | ||
224 | + gpio_writel(GPIO_A, ODR, 0xDEADBEEF); | ||
225 | + gpio_writel(GPIO_A, OTYPER, 0xDEADBEEF); | ||
226 | + gpio_writel(GPIO_A, PUPDR, 0xDEADBEEF); | ||
227 | + | ||
228 | + gpio_writel(GPIO_B, MODER, 0xDEADBEEF); | ||
229 | + gpio_writel(GPIO_B, ODR, 0xDEADBEEF); | ||
230 | + gpio_writel(GPIO_B, OTYPER, 0xDEADBEEF); | ||
231 | + gpio_writel(GPIO_B, PUPDR, 0xDEADBEEF); | ||
232 | + | ||
233 | + gpio_writel(GPIO_C, MODER, 0xDEADBEEF); | ||
234 | + gpio_writel(GPIO_C, ODR, 0xDEADBEEF); | ||
235 | + gpio_writel(GPIO_C, OTYPER, 0xDEADBEEF); | ||
236 | + gpio_writel(GPIO_C, PUPDR, 0xDEADBEEF); | ||
237 | + | ||
238 | + gpio_writel(GPIO_H, MODER, 0xDEADBEEF); | ||
239 | + gpio_writel(GPIO_H, ODR, 0xDEADBEEF); | ||
240 | + gpio_writel(GPIO_H, OTYPER, 0xDEADBEEF); | ||
241 | + gpio_writel(GPIO_H, PUPDR, 0xDEADBEEF); | ||
242 | + | ||
243 | + system_reset(); | ||
244 | + | ||
245 | + uint32_t moder = gpio_readl(GPIO_A, MODER); | ||
246 | + uint32_t odr = gpio_readl(GPIO_A, ODR); | ||
247 | + uint32_t otyper = gpio_readl(GPIO_A, OTYPER); | ||
248 | + uint32_t pupdr = gpio_readl(GPIO_A, PUPDR); | ||
249 | + uint32_t idr = gpio_readl(GPIO_A, IDR); | ||
250 | + /* 15: AF, 14: AF, 13: AF, 12: Analog ... */ | ||
251 | + /* here AF is the same as Analog and Input mode */ | ||
252 | + g_assert_cmphex(moder, ==, reset(GPIO_A, MODER)); | ||
253 | + g_assert_cmphex(odr, ==, reset(GPIO_A, ODR)); | ||
254 | + g_assert_cmphex(otyper, ==, reset(GPIO_A, OTYPER)); | ||
255 | + /* 15: pull-up, 14: pull-down, 13: pull-up, 12: neither ... */ | ||
256 | + g_assert_cmphex(pupdr, ==, reset(GPIO_A, PUPDR)); | ||
257 | + /* 15 : 1, 14: 0, 13: 1, 12 : reset value ... */ | ||
258 | + g_assert_cmphex(idr, ==, reset(GPIO_A, IDR)); | ||
259 | + | ||
260 | + moder = gpio_readl(GPIO_B, MODER); | ||
261 | + odr = gpio_readl(GPIO_B, ODR); | ||
262 | + otyper = gpio_readl(GPIO_B, OTYPER); | ||
263 | + pupdr = gpio_readl(GPIO_B, PUPDR); | ||
264 | + idr = gpio_readl(GPIO_B, IDR); | ||
265 | + /* ... 5: Analog, 4: AF, 3: AF, 2: Analog ... */ | ||
266 | + /* here AF is the same as Analog and Input mode */ | ||
267 | + g_assert_cmphex(moder, ==, reset(GPIO_B, MODER)); | ||
268 | + g_assert_cmphex(odr, ==, reset(GPIO_B, ODR)); | ||
269 | + g_assert_cmphex(otyper, ==, reset(GPIO_B, OTYPER)); | ||
270 | + /* ... 5: neither, 4: pull-up, 3: neither ... */ | ||
271 | + g_assert_cmphex(pupdr, ==, reset(GPIO_B, PUPDR)); | ||
272 | + /* ... 5 : reset value, 4 : 1, 3 : reset value ... */ | ||
273 | + g_assert_cmphex(idr, ==, reset(GPIO_B, IDR)); | ||
274 | + | ||
275 | + moder = gpio_readl(GPIO_C, MODER); | ||
276 | + odr = gpio_readl(GPIO_C, ODR); | ||
277 | + otyper = gpio_readl(GPIO_C, OTYPER); | ||
278 | + pupdr = gpio_readl(GPIO_C, PUPDR); | ||
279 | + idr = gpio_readl(GPIO_C, IDR); | ||
280 | + /* Analog, same as Input mode*/ | ||
281 | + g_assert_cmphex(moder, ==, reset(GPIO_C, MODER)); | ||
282 | + g_assert_cmphex(odr, ==, reset(GPIO_C, ODR)); | ||
283 | + g_assert_cmphex(otyper, ==, reset(GPIO_C, OTYPER)); | ||
284 | + /* no pull-up or pull-down */ | ||
285 | + g_assert_cmphex(pupdr, ==, reset(GPIO_C, PUPDR)); | ||
286 | + /* reset value */ | ||
287 | + g_assert_cmphex(idr, ==, reset(GPIO_C, IDR)); | ||
288 | + | ||
289 | + moder = gpio_readl(GPIO_H, MODER); | ||
290 | + odr = gpio_readl(GPIO_H, ODR); | ||
291 | + otyper = gpio_readl(GPIO_H, OTYPER); | ||
292 | + pupdr = gpio_readl(GPIO_H, PUPDR); | ||
293 | + idr = gpio_readl(GPIO_H, IDR); | ||
294 | + /* Analog, same as Input mode */ | ||
295 | + g_assert_cmphex(moder, ==, reset(GPIO_H, MODER)); | ||
296 | + g_assert_cmphex(odr, ==, reset(GPIO_H, ODR)); | ||
297 | + g_assert_cmphex(otyper, ==, reset(GPIO_H, OTYPER)); | ||
298 | + /* no pull-up or pull-down */ | ||
299 | + g_assert_cmphex(pupdr, ==, reset(GPIO_H, PUPDR)); | ||
300 | + /* reset value */ | ||
301 | + g_assert_cmphex(idr, ==, reset(GPIO_H, IDR)); | ||
302 | +} | ||
303 | + | ||
304 | +static void test_gpio_output_mode(const void *data) | ||
305 | +{ | ||
306 | + /* | ||
307 | + * Checks that setting a bit in ODR sets the corresponding | ||
308 | + * GPIO line high : it should set the right bit in IDR | ||
309 | + * and send an irq to syscfg. | ||
310 | + * Additionally, it checks that values written to ODR | ||
311 | + * when not in output mode are stored and not discarded. | ||
312 | + */ | ||
313 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
314 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
315 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
316 | + | ||
317 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
318 | + | ||
319 | + /* Set a bit in ODR and check nothing happens */ | ||
320 | + gpio_set_bit(gpio, ODR, pin, 1); | ||
321 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
322 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
323 | + | ||
324 | + /* Configure the relevant line as output and check the pin is high */ | ||
325 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
326 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
327 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
328 | + | ||
329 | + /* Reset the bit in ODR and check the pin is low */ | ||
330 | + gpio_set_bit(gpio, ODR, pin, 0); | ||
331 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
332 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
333 | + | ||
334 | + /* Clean the test */ | ||
335 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
336 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
337 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
338 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
339 | +} | ||
340 | + | ||
341 | +static void test_gpio_input_mode(const void *data) | ||
342 | +{ | ||
343 | + /* | ||
344 | + * Test that setting a line high/low externally sets the | ||
345 | + * corresponding GPIO line high/low : it should set the | ||
346 | + * right bit in IDR and send an irq to syscfg. | ||
347 | + */ | ||
348 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
349 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
350 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
351 | + | ||
352 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
353 | + | ||
354 | + /* Configure a line as input, raise it, and check that the pin is high */ | ||
355 | + gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); | ||
356 | + gpio_set_irq(gpio, pin, 1); | ||
357 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
358 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
359 | + | ||
360 | + /* Lower the line and check that the pin is low */ | ||
361 | + gpio_set_irq(gpio, pin, 0); | ||
362 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
363 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
364 | + | ||
365 | + /* Clean the test */ | ||
366 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
367 | + disconnect_all_pins(gpio); | ||
368 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
369 | +} | ||
370 | + | ||
371 | +static void test_pull_up_pull_down(const void *data) | ||
372 | +{ | ||
373 | + /* | ||
374 | + * Test that a floating pin with pull-up sets the pin | ||
375 | + * high and vice-versa. | ||
376 | + */ | ||
377 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
378 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
379 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
380 | + | ||
381 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
382 | + | ||
383 | + /* Configure a line as input with pull-up, check the line is set high */ | ||
384 | + gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); | ||
385 | + gpio_set_2bits(gpio, PUPDR, pin, PUPDR_PULLUP); | ||
386 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
387 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
388 | + | ||
389 | + /* Configure the line with pull-down, check the line is low */ | ||
390 | + gpio_set_2bits(gpio, PUPDR, pin, PUPDR_PULLDOWN); | ||
391 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
392 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
393 | + | ||
394 | + /* Clean the test */ | ||
395 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
396 | + gpio_writel(gpio, PUPDR, reset(gpio, PUPDR)); | ||
397 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
398 | +} | ||
399 | + | ||
400 | +static void test_push_pull(const void *data) | ||
401 | +{ | ||
402 | + /* | ||
403 | + * Test that configuring a line in push-pull output mode | ||
404 | + * disconnects the pin, that the pin can't be set or reset | ||
405 | + * externally afterwards. | ||
406 | + */ | ||
407 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
408 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
409 | + uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
410 | + | ||
411 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
412 | + | ||
413 | + /* Setting a line high externally, configuring it in push-pull output */ | ||
414 | + /* And checking the pin was disconnected */ | ||
415 | + gpio_set_irq(gpio, pin, 1); | ||
416 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
417 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
418 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
419 | + | ||
420 | + /* Setting a line low externally, configuring it in push-pull output */ | ||
421 | + /* And checking the pin was disconnected */ | ||
422 | + gpio_set_irq(gpio2, pin, 0); | ||
423 | + gpio_set_bit(gpio2, ODR, pin, 1); | ||
424 | + gpio_set_2bits(gpio2, MODER, pin, MODER_OUTPUT); | ||
425 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF); | ||
426 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR) | (1 << pin)); | ||
427 | + | ||
428 | + /* Trying to set a push-pull output pin, checking it doesn't work */ | ||
429 | + gpio_set_irq(gpio, pin, 1); | ||
430 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
431 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
432 | + | ||
433 | + /* Trying to reset a push-pull output pin, checking it doesn't work */ | ||
434 | + gpio_set_irq(gpio2, pin, 0); | ||
435 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF); | ||
436 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR) | (1 << pin)); | ||
437 | + | ||
438 | + /* Clean the test */ | ||
439 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
440 | + gpio_writel(gpio2, ODR, reset(gpio2, ODR)); | ||
441 | + gpio_writel(gpio2, MODER, reset(gpio2, MODER)); | ||
442 | +} | ||
443 | + | ||
444 | +static void test_open_drain(const void *data) | ||
445 | +{ | ||
446 | + /* | ||
447 | + * Test that configuring a line in open-drain output mode | ||
448 | + * disconnects a pin set high externally and that the pin | ||
449 | + * can't be set high externally while configured in open-drain. | ||
450 | + * | ||
451 | + * However a pin set low externally shouldn't be disconnected, | ||
452 | + * and it can be set low externally when in open-drain mode. | ||
453 | + */ | ||
454 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
455 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
456 | + uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
457 | + | ||
458 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
459 | + | ||
460 | + /* Setting a line high externally, configuring it in open-drain output */ | ||
461 | + /* And checking the pin was disconnected */ | ||
462 | + gpio_set_irq(gpio, pin, 1); | ||
463 | + gpio_set_bit(gpio, OTYPER, pin, OTYPER_OPEN_DRAIN); | ||
464 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
465 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
466 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
467 | + | ||
468 | + /* Setting a line low externally, configuring it in open-drain output */ | ||
469 | + /* And checking the pin wasn't disconnected */ | ||
470 | + gpio_set_irq(gpio2, pin, 0); | ||
471 | + gpio_set_bit(gpio2, ODR, pin, 1); | ||
472 | + gpio_set_bit(gpio2, OTYPER, pin, OTYPER_OPEN_DRAIN); | ||
473 | + gpio_set_2bits(gpio2, MODER, pin, MODER_OUTPUT); | ||
474 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF & ~(1 << pin)); | ||
475 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, | ||
476 | + reset(gpio2, IDR) & ~(1 << pin)); | ||
477 | + | ||
478 | + /* Trying to set a open-drain output pin, checking it doesn't work */ | ||
479 | + gpio_set_irq(gpio, pin, 1); | ||
480 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
481 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
482 | + | ||
483 | + /* Trying to reset a open-drain output pin, checking it works */ | ||
484 | + gpio_set_bit(gpio, ODR, pin, 1); | ||
485 | + gpio_set_irq(gpio, pin, 0); | ||
486 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF & ~(1 << pin)); | ||
487 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, | ||
488 | + reset(gpio2, IDR) & ~(1 << pin)); | ||
489 | + | ||
490 | + /* Clean the test */ | ||
491 | + disconnect_all_pins(gpio2); | ||
492 | + gpio_writel(gpio2, OTYPER, reset(gpio2, OTYPER)); | ||
493 | + gpio_writel(gpio2, ODR, reset(gpio2, ODR)); | ||
494 | + gpio_writel(gpio2, MODER, reset(gpio2, MODER)); | ||
495 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR)); | ||
496 | + disconnect_all_pins(gpio); | ||
497 | + gpio_writel(gpio, OTYPER, reset(gpio, OTYPER)); | ||
498 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
499 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
500 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
501 | +} | ||
502 | + | ||
503 | +static void test_bsrr_brr(const void *data) | ||
504 | +{ | ||
505 | + /* | ||
506 | + * Test that writing a '1' in BSS and BSRR | ||
507 | + * has the desired effect on ODR. | ||
508 | + * In BSRR, BSx has priority over BRx. | ||
509 | + */ | ||
510 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
511 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
512 | + | ||
513 | + gpio_writel(gpio, BSRR, (1 << pin)); | ||
514 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
515 | + | ||
516 | + gpio_writel(gpio, BSRR, (1 << (pin + NUM_GPIO_PINS))); | ||
517 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
518 | + | ||
519 | + gpio_writel(gpio, BSRR, (1 << pin)); | ||
520 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
521 | + | ||
522 | + gpio_writel(gpio, BRR, (1 << pin)); | ||
523 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
524 | + | ||
525 | + /* BSx should have priority over BRx */ | ||
526 | + gpio_writel(gpio, BSRR, (1 << pin) | (1 << (pin + NUM_GPIO_PINS))); | ||
527 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
528 | + | ||
529 | + gpio_writel(gpio, BRR, (1 << pin)); | ||
530 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
531 | + | ||
532 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
533 | +} | ||
534 | + | ||
535 | +int main(int argc, char **argv) | ||
536 | +{ | ||
537 | + int ret; | ||
538 | + | ||
539 | + g_test_init(&argc, &argv, NULL); | ||
540 | + g_test_set_nonfatal_assertions(); | ||
541 | + qtest_add_func("stm32l4x5/gpio/test_idr_reset_value", | ||
542 | + test_idr_reset_value); | ||
543 | + /* | ||
544 | + * The inputs for the tests (gpio and pin) can be changed, | ||
545 | + * but the tests don't work for pins that are high at reset | ||
546 | + * (GPIOA15, GPIO13 and GPIOB5). | ||
547 | + * Specifically, rising the pin then checking `get_irq()` | ||
548 | + * is problematic since the pin was already high. | ||
549 | + */ | ||
550 | + qtest_add_data_func("stm32l4x5/gpio/test_gpioc5_output_mode", | ||
551 | + (void *)((uint64_t)GPIO_C << 32 | 5), | ||
552 | + test_gpio_output_mode); | ||
553 | + qtest_add_data_func("stm32l4x5/gpio/test_gpioh3_output_mode", | ||
554 | + (void *)((uint64_t)GPIO_H << 32 | 3), | ||
555 | + test_gpio_output_mode); | ||
556 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode1", | ||
557 | + (void *)((uint64_t)GPIO_D << 32 | 6), | ||
558 | + test_gpio_input_mode); | ||
559 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode2", | ||
560 | + (void *)((uint64_t)GPIO_C << 32 | 10), | ||
561 | + test_gpio_input_mode); | ||
562 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down1", | ||
563 | + (void *)((uint64_t)GPIO_B << 32 | 5), | ||
564 | + test_pull_up_pull_down); | ||
565 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down2", | ||
566 | + (void *)((uint64_t)GPIO_F << 32 | 1), | ||
567 | + test_pull_up_pull_down); | ||
568 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull1", | ||
569 | + (void *)((uint64_t)GPIO_G << 32 | 6), | ||
570 | + test_push_pull); | ||
571 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull2", | ||
572 | + (void *)((uint64_t)GPIO_H << 32 | 3), | ||
573 | + test_push_pull); | ||
574 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain1", | ||
575 | + (void *)((uint64_t)GPIO_C << 32 | 4), | ||
576 | + test_open_drain); | ||
577 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain2", | ||
578 | + (void *)((uint64_t)GPIO_E << 32 | 11), | ||
579 | + test_open_drain); | ||
580 | + qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr1", | ||
581 | + (void *)((uint64_t)GPIO_A << 32 | 12), | ||
582 | + test_bsrr_brr); | ||
583 | + qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr2", | ||
584 | + (void *)((uint64_t)GPIO_D << 32 | 0), | ||
585 | + test_bsrr_brr); | ||
586 | + | ||
587 | + qtest_start("-machine b-l475e-iot01a"); | ||
588 | + ret = g_test_run(); | ||
589 | + qtest_end(); | ||
590 | + | ||
591 | + return ret; | ||
592 | +} | ||
593 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
13 | index XXXXXXX..XXXXXXX 100644 | 594 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/ptw.c | 595 | --- a/tests/qtest/meson.build |
15 | +++ b/target/arm/ptw.c | 596 | +++ b/tests/qtest/meson.build |
16 | @@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, | 597 | @@ -XXX,XX +XXX,XX @@ qtests_aspeed = \ |
17 | 598 | qtests_stm32l4x5 = \ | |
18 | static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | 599 | ['stm32l4x5_exti-test', |
19 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 600 | 'stm32l4x5_syscfg-test', |
20 | - hwaddr *phys_ptr, int *prot, | 601 | - 'stm32l4x5_rcc-test'] |
21 | - target_ulong *page_size, | 602 | + 'stm32l4x5_rcc-test', |
22 | + GetPhysAddrResult *result, | 603 | + 'stm32l4x5_gpio-test'] |
23 | ARMMMUFaultInfo *fi) | 604 | |
24 | { | 605 | qtests_arm = \ |
25 | ARMCPU *cpu = env_archcpu(env); | 606 | (config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \ |
26 | int n; | ||
27 | bool is_user = regime_is_user(env, mmu_idx); | ||
28 | |||
29 | - *phys_ptr = address; | ||
30 | - *page_size = TARGET_PAGE_SIZE; | ||
31 | - *prot = 0; | ||
32 | + result->phys = address; | ||
33 | + result->page_size = TARGET_PAGE_SIZE; | ||
34 | + result->prot = 0; | ||
35 | |||
36 | if (regime_translation_disabled(env, mmu_idx) || | ||
37 | m_is_ppb_region(env, address)) { | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
39 | * which always does a direct read using address_space_ldl(), rather | ||
40 | * than going via this function, so we don't need to check that here. | ||
41 | */ | ||
42 | - get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); | ||
43 | + get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot); | ||
44 | } else { /* MPU enabled */ | ||
45 | for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) { | ||
46 | /* region search */ | ||
47 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
48 | if (ranges_overlap(base, rmask, | ||
49 | address & TARGET_PAGE_MASK, | ||
50 | TARGET_PAGE_SIZE)) { | ||
51 | - *page_size = 1; | ||
52 | + result->page_size = 1; | ||
53 | } | ||
54 | continue; | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
57 | continue; | ||
58 | } | ||
59 | if (rsize < TARGET_PAGE_BITS) { | ||
60 | - *page_size = 1 << rsize; | ||
61 | + result->page_size = 1 << rsize; | ||
62 | } | ||
63 | break; | ||
64 | } | ||
65 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
66 | fi->type = ARMFault_Background; | ||
67 | return true; | ||
68 | } | ||
69 | - get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); | ||
70 | + get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot); | ||
71 | } else { /* a MPU hit! */ | ||
72 | uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3); | ||
73 | uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1); | ||
74 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
75 | case 5: | ||
76 | break; /* no access */ | ||
77 | case 3: | ||
78 | - *prot |= PAGE_WRITE; | ||
79 | + result->prot |= PAGE_WRITE; | ||
80 | /* fall through */ | ||
81 | case 2: | ||
82 | case 6: | ||
83 | - *prot |= PAGE_READ | PAGE_EXEC; | ||
84 | + result->prot |= PAGE_READ | PAGE_EXEC; | ||
85 | break; | ||
86 | case 7: | ||
87 | /* for v7M, same as 6; for R profile a reserved value */ | ||
88 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
89 | - *prot |= PAGE_READ | PAGE_EXEC; | ||
90 | + result->prot |= PAGE_READ | PAGE_EXEC; | ||
91 | break; | ||
92 | } | ||
93 | /* fall through */ | ||
94 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
95 | case 1: | ||
96 | case 2: | ||
97 | case 3: | ||
98 | - *prot |= PAGE_WRITE; | ||
99 | + result->prot |= PAGE_WRITE; | ||
100 | /* fall through */ | ||
101 | case 5: | ||
102 | case 6: | ||
103 | - *prot |= PAGE_READ | PAGE_EXEC; | ||
104 | + result->prot |= PAGE_READ | PAGE_EXEC; | ||
105 | break; | ||
106 | case 7: | ||
107 | /* for v7M, same as 6; for R profile a reserved value */ | ||
108 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
109 | - *prot |= PAGE_READ | PAGE_EXEC; | ||
110 | + result->prot |= PAGE_READ | PAGE_EXEC; | ||
111 | break; | ||
112 | } | ||
113 | /* fall through */ | ||
114 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
115 | |||
116 | /* execute never */ | ||
117 | if (xn) { | ||
118 | - *prot &= ~PAGE_EXEC; | ||
119 | + result->prot &= ~PAGE_EXEC; | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | |||
124 | fi->type = ARMFault_Permission; | ||
125 | fi->level = 1; | ||
126 | - return !(*prot & (1 << access_type)); | ||
127 | + return !(result->prot & (1 << access_type)); | ||
128 | } | ||
129 | |||
130 | bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
131 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
132 | } else if (arm_feature(env, ARM_FEATURE_V7)) { | ||
133 | /* PMSAv7 */ | ||
134 | ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, | ||
135 | - &result->phys, &result->prot, | ||
136 | - &result->page_size, fi); | ||
137 | + result, fi); | ||
138 | } else { | ||
139 | /* Pre-v7 MPU */ | ||
140 | ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx, | ||
141 | -- | 607 | -- |
142 | 2.25.1 | 608 | 2.34.1 |
143 | 609 | ||
144 | 610 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Remove the use of regime_is_secure from get_phys_addr_v5, | 3 | While the 8-bit input elements are sequential in the input vector, |
4 | passing the new parameter to the lookup instead. | 4 | the 32-bit output elements are not sequential in the output matrix. |
5 | 5 | Do not attempt to compute 2 32-bit outputs at the same time. | |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 6 | |
7 | Cc: qemu-stable@nongnu.org | ||
8 | Fixes: 23a5e3859f5 ("target/arm: Implement SME integer outer product") | ||
9 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2083 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | [PMM: Folded in definition of local is_secure in get_phys_addr(), | 11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | since I dropped the earlier patch that would have provided it] | 12 | Message-id: 20240305163931.242795-1-richard.henderson@linaro.org |
10 | Message-id: 20220822152741.1617527-14-richard.henderson@linaro.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 14 | --- |
14 | target/arm/ptw.c | 14 +++++++------- | 15 | target/arm/tcg/sme_helper.c | 77 ++++++++++++++++++------------- |
15 | 1 file changed, 7 insertions(+), 7 deletions(-) | 16 | tests/tcg/aarch64/sme-smopa-1.c | 47 +++++++++++++++++++ |
16 | 17 | tests/tcg/aarch64/sme-smopa-2.c | 54 ++++++++++++++++++++++ | |
17 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | 18 | tests/tcg/aarch64/Makefile.target | 2 +- |
19 | 4 files changed, 147 insertions(+), 33 deletions(-) | ||
20 | create mode 100644 tests/tcg/aarch64/sme-smopa-1.c | ||
21 | create mode 100644 tests/tcg/aarch64/sme-smopa-2.c | ||
22 | |||
23 | diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/ptw.c | 25 | --- a/target/arm/tcg/sme_helper.c |
20 | +++ b/target/arm/ptw.c | 26 | +++ b/target/arm/tcg/sme_helper.c |
21 | @@ -XXX,XX +XXX,XX @@ static int simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | 27 | @@ -XXX,XX +XXX,XX @@ void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn, |
22 | |||
23 | static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
24 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
25 | - GetPhysAddrResult *result, ARMMMUFaultInfo *fi) | ||
26 | + bool is_secure, GetPhysAddrResult *result, | ||
27 | + ARMMMUFaultInfo *fi) | ||
28 | { | ||
29 | int level = 1; | ||
30 | uint32_t table; | ||
31 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
32 | fi->type = ARMFault_Translation; | ||
33 | goto do_fault; | ||
34 | } | ||
35 | - desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), | ||
36 | - mmu_idx, fi); | ||
37 | + desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi); | ||
38 | if (fi->type != ARMFault_None) { | ||
39 | goto do_fault; | ||
40 | } | ||
41 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
42 | /* Fine pagetable. */ | ||
43 | table = (desc & 0xfffff000) | ((address >> 8) & 0xffc); | ||
44 | } | ||
45 | - desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), | ||
46 | - mmu_idx, fi); | ||
47 | + desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi); | ||
48 | if (fi->type != ARMFault_None) { | ||
49 | goto do_fault; | ||
50 | } | ||
51 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
52 | GetPhysAddrResult *result, ARMMMUFaultInfo *fi) | ||
53 | { | ||
54 | ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx); | ||
55 | + bool is_secure = regime_is_secure(env, mmu_idx); | ||
56 | |||
57 | if (mmu_idx != s1_mmu_idx) { | ||
58 | /* | ||
59 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
60 | * cannot upgrade an non-secure translation regime's attributes | ||
61 | * to secure. | ||
62 | */ | ||
63 | - result->attrs.secure = regime_is_secure(env, mmu_idx); | ||
64 | + result->attrs.secure = is_secure; | ||
65 | result->attrs.user = regime_is_user(env, mmu_idx); | ||
66 | |||
67 | /* | ||
68 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
69 | result, fi); | ||
70 | } else { | ||
71 | return get_phys_addr_v5(env, address, access_type, mmu_idx, | ||
72 | - result, fi); | ||
73 | + is_secure, result, fi); | ||
74 | } | 28 | } |
75 | } | 29 | } |
76 | 30 | ||
31 | -typedef uint64_t IMOPFn(uint64_t, uint64_t, uint64_t, uint8_t, bool); | ||
32 | +typedef uint32_t IMOPFn32(uint32_t, uint32_t, uint32_t, uint8_t, bool); | ||
33 | +static inline void do_imopa_s(uint32_t *za, uint32_t *zn, uint32_t *zm, | ||
34 | + uint8_t *pn, uint8_t *pm, | ||
35 | + uint32_t desc, IMOPFn32 *fn) | ||
36 | +{ | ||
37 | + intptr_t row, col, oprsz = simd_oprsz(desc) / 4; | ||
38 | + bool neg = simd_data(desc); | ||
39 | |||
40 | -static inline void do_imopa(uint64_t *za, uint64_t *zn, uint64_t *zm, | ||
41 | - uint8_t *pn, uint8_t *pm, | ||
42 | - uint32_t desc, IMOPFn *fn) | ||
43 | + for (row = 0; row < oprsz; ++row) { | ||
44 | + uint8_t pa = (pn[H1(row >> 1)] >> ((row & 1) * 4)) & 0xf; | ||
45 | + uint32_t *za_row = &za[tile_vslice_index(row)]; | ||
46 | + uint32_t n = zn[H4(row)]; | ||
47 | + | ||
48 | + for (col = 0; col < oprsz; ++col) { | ||
49 | + uint8_t pb = pm[H1(col >> 1)] >> ((col & 1) * 4); | ||
50 | + uint32_t *a = &za_row[H4(col)]; | ||
51 | + | ||
52 | + *a = fn(n, zm[H4(col)], *a, pa & pb, neg); | ||
53 | + } | ||
54 | + } | ||
55 | +} | ||
56 | + | ||
57 | +typedef uint64_t IMOPFn64(uint64_t, uint64_t, uint64_t, uint8_t, bool); | ||
58 | +static inline void do_imopa_d(uint64_t *za, uint64_t *zn, uint64_t *zm, | ||
59 | + uint8_t *pn, uint8_t *pm, | ||
60 | + uint32_t desc, IMOPFn64 *fn) | ||
61 | { | ||
62 | intptr_t row, col, oprsz = simd_oprsz(desc) / 8; | ||
63 | bool neg = simd_data(desc); | ||
64 | @@ -XXX,XX +XXX,XX @@ static inline void do_imopa(uint64_t *za, uint64_t *zn, uint64_t *zm, | ||
65 | } | ||
66 | |||
67 | #define DEF_IMOP_32(NAME, NTYPE, MTYPE) \ | ||
68 | -static uint64_t NAME(uint64_t n, uint64_t m, uint64_t a, uint8_t p, bool neg) \ | ||
69 | +static uint32_t NAME(uint32_t n, uint32_t m, uint32_t a, uint8_t p, bool neg) \ | ||
70 | { \ | ||
71 | - uint32_t sum0 = 0, sum1 = 0; \ | ||
72 | + uint32_t sum = 0; \ | ||
73 | /* Apply P to N as a mask, making the inactive elements 0. */ \ | ||
74 | n &= expand_pred_b(p); \ | ||
75 | - sum0 += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \ | ||
76 | - sum0 += (NTYPE)(n >> 8) * (MTYPE)(m >> 8); \ | ||
77 | - sum0 += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \ | ||
78 | - sum0 += (NTYPE)(n >> 24) * (MTYPE)(m >> 24); \ | ||
79 | - sum1 += (NTYPE)(n >> 32) * (MTYPE)(m >> 32); \ | ||
80 | - sum1 += (NTYPE)(n >> 40) * (MTYPE)(m >> 40); \ | ||
81 | - sum1 += (NTYPE)(n >> 48) * (MTYPE)(m >> 48); \ | ||
82 | - sum1 += (NTYPE)(n >> 56) * (MTYPE)(m >> 56); \ | ||
83 | - if (neg) { \ | ||
84 | - sum0 = (uint32_t)a - sum0, sum1 = (uint32_t)(a >> 32) - sum1; \ | ||
85 | - } else { \ | ||
86 | - sum0 = (uint32_t)a + sum0, sum1 = (uint32_t)(a >> 32) + sum1; \ | ||
87 | - } \ | ||
88 | - return ((uint64_t)sum1 << 32) | sum0; \ | ||
89 | + sum += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \ | ||
90 | + sum += (NTYPE)(n >> 8) * (MTYPE)(m >> 8); \ | ||
91 | + sum += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \ | ||
92 | + sum += (NTYPE)(n >> 24) * (MTYPE)(m >> 24); \ | ||
93 | + return neg ? a - sum : a + sum; \ | ||
94 | } | ||
95 | |||
96 | #define DEF_IMOP_64(NAME, NTYPE, MTYPE) \ | ||
97 | @@ -XXX,XX +XXX,XX @@ DEF_IMOP_64(umopa_d, uint16_t, uint16_t) | ||
98 | DEF_IMOP_64(sumopa_d, int16_t, uint16_t) | ||
99 | DEF_IMOP_64(usmopa_d, uint16_t, int16_t) | ||
100 | |||
101 | -#define DEF_IMOPH(NAME) \ | ||
102 | - void HELPER(sme_##NAME)(void *vza, void *vzn, void *vzm, void *vpn, \ | ||
103 | - void *vpm, uint32_t desc) \ | ||
104 | - { do_imopa(vza, vzn, vzm, vpn, vpm, desc, NAME); } | ||
105 | +#define DEF_IMOPH(NAME, S) \ | ||
106 | + void HELPER(sme_##NAME##_##S)(void *vza, void *vzn, void *vzm, \ | ||
107 | + void *vpn, void *vpm, uint32_t desc) \ | ||
108 | + { do_imopa_##S(vza, vzn, vzm, vpn, vpm, desc, NAME##_##S); } | ||
109 | |||
110 | -DEF_IMOPH(smopa_s) | ||
111 | -DEF_IMOPH(umopa_s) | ||
112 | -DEF_IMOPH(sumopa_s) | ||
113 | -DEF_IMOPH(usmopa_s) | ||
114 | -DEF_IMOPH(smopa_d) | ||
115 | -DEF_IMOPH(umopa_d) | ||
116 | -DEF_IMOPH(sumopa_d) | ||
117 | -DEF_IMOPH(usmopa_d) | ||
118 | +DEF_IMOPH(smopa, s) | ||
119 | +DEF_IMOPH(umopa, s) | ||
120 | +DEF_IMOPH(sumopa, s) | ||
121 | +DEF_IMOPH(usmopa, s) | ||
122 | + | ||
123 | +DEF_IMOPH(smopa, d) | ||
124 | +DEF_IMOPH(umopa, d) | ||
125 | +DEF_IMOPH(sumopa, d) | ||
126 | +DEF_IMOPH(usmopa, d) | ||
127 | diff --git a/tests/tcg/aarch64/sme-smopa-1.c b/tests/tcg/aarch64/sme-smopa-1.c | ||
128 | new file mode 100644 | ||
129 | index XXXXXXX..XXXXXXX | ||
130 | --- /dev/null | ||
131 | +++ b/tests/tcg/aarch64/sme-smopa-1.c | ||
132 | @@ -XXX,XX +XXX,XX @@ | ||
133 | +#include <stdio.h> | ||
134 | +#include <string.h> | ||
135 | + | ||
136 | +int main() | ||
137 | +{ | ||
138 | + static const int cmp[4][4] = { | ||
139 | + { 110, 134, 158, 182 }, | ||
140 | + { 390, 478, 566, 654 }, | ||
141 | + { 670, 822, 974, 1126 }, | ||
142 | + { 950, 1166, 1382, 1598 } | ||
143 | + }; | ||
144 | + int dst[4][4]; | ||
145 | + int *tmp = &dst[0][0]; | ||
146 | + | ||
147 | + asm volatile( | ||
148 | + ".arch armv8-r+sme\n\t" | ||
149 | + "smstart\n\t" | ||
150 | + "index z0.b, #0, #1\n\t" | ||
151 | + "movprfx z1, z0\n\t" | ||
152 | + "add z1.b, z1.b, #16\n\t" | ||
153 | + "ptrue p0.b\n\t" | ||
154 | + "smopa za0.s, p0/m, p0/m, z0.b, z1.b\n\t" | ||
155 | + "ptrue p0.s, vl4\n\t" | ||
156 | + "mov w12, #0\n\t" | ||
157 | + "st1w { za0h.s[w12, #0] }, p0, [%0]\n\t" | ||
158 | + "add %0, %0, #16\n\t" | ||
159 | + "st1w { za0h.s[w12, #1] }, p0, [%0]\n\t" | ||
160 | + "add %0, %0, #16\n\t" | ||
161 | + "st1w { za0h.s[w12, #2] }, p0, [%0]\n\t" | ||
162 | + "add %0, %0, #16\n\t" | ||
163 | + "st1w { za0h.s[w12, #3] }, p0, [%0]\n\t" | ||
164 | + "smstop" | ||
165 | + : "+r"(tmp) : : "memory"); | ||
166 | + | ||
167 | + if (memcmp(cmp, dst, sizeof(dst)) == 0) { | ||
168 | + return 0; | ||
169 | + } | ||
170 | + | ||
171 | + /* See above for correct results. */ | ||
172 | + for (int i = 0; i < 4; ++i) { | ||
173 | + for (int j = 0; j < 4; ++j) { | ||
174 | + printf("%6d", dst[i][j]); | ||
175 | + } | ||
176 | + printf("\n"); | ||
177 | + } | ||
178 | + return 1; | ||
179 | +} | ||
180 | diff --git a/tests/tcg/aarch64/sme-smopa-2.c b/tests/tcg/aarch64/sme-smopa-2.c | ||
181 | new file mode 100644 | ||
182 | index XXXXXXX..XXXXXXX | ||
183 | --- /dev/null | ||
184 | +++ b/tests/tcg/aarch64/sme-smopa-2.c | ||
185 | @@ -XXX,XX +XXX,XX @@ | ||
186 | +#include <stdio.h> | ||
187 | +#include <string.h> | ||
188 | + | ||
189 | +int main() | ||
190 | +{ | ||
191 | + static const long cmp[4][4] = { | ||
192 | + { 110, 134, 158, 182 }, | ||
193 | + { 390, 478, 566, 654 }, | ||
194 | + { 670, 822, 974, 1126 }, | ||
195 | + { 950, 1166, 1382, 1598 } | ||
196 | + }; | ||
197 | + long dst[4][4]; | ||
198 | + long *tmp = &dst[0][0]; | ||
199 | + long svl; | ||
200 | + | ||
201 | + /* Validate that we have a wide enough vector for 4 elements. */ | ||
202 | + asm(".arch armv8-r+sme-i64\n\trdsvl %0, #1" : "=r"(svl)); | ||
203 | + if (svl < 32) { | ||
204 | + return 0; | ||
205 | + } | ||
206 | + | ||
207 | + asm volatile( | ||
208 | + "smstart\n\t" | ||
209 | + "index z0.h, #0, #1\n\t" | ||
210 | + "movprfx z1, z0\n\t" | ||
211 | + "add z1.h, z1.h, #16\n\t" | ||
212 | + "ptrue p0.b\n\t" | ||
213 | + "smopa za0.d, p0/m, p0/m, z0.h, z1.h\n\t" | ||
214 | + "ptrue p0.d, vl4\n\t" | ||
215 | + "mov w12, #0\n\t" | ||
216 | + "st1d { za0h.d[w12, #0] }, p0, [%0]\n\t" | ||
217 | + "add %0, %0, #32\n\t" | ||
218 | + "st1d { za0h.d[w12, #1] }, p0, [%0]\n\t" | ||
219 | + "mov w12, #2\n\t" | ||
220 | + "add %0, %0, #32\n\t" | ||
221 | + "st1d { za0h.d[w12, #0] }, p0, [%0]\n\t" | ||
222 | + "add %0, %0, #32\n\t" | ||
223 | + "st1d { za0h.d[w12, #1] }, p0, [%0]\n\t" | ||
224 | + "smstop" | ||
225 | + : "+r"(tmp) : : "memory"); | ||
226 | + | ||
227 | + if (memcmp(cmp, dst, sizeof(dst)) == 0) { | ||
228 | + return 0; | ||
229 | + } | ||
230 | + | ||
231 | + /* See above for correct results. */ | ||
232 | + for (int i = 0; i < 4; ++i) { | ||
233 | + for (int j = 0; j < 4; ++j) { | ||
234 | + printf("%6ld", dst[i][j]); | ||
235 | + } | ||
236 | + printf("\n"); | ||
237 | + } | ||
238 | + return 1; | ||
239 | +} | ||
240 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
241 | index XXXXXXX..XXXXXXX 100644 | ||
242 | --- a/tests/tcg/aarch64/Makefile.target | ||
243 | +++ b/tests/tcg/aarch64/Makefile.target | ||
244 | @@ -XXX,XX +XXX,XX @@ endif | ||
245 | |||
246 | # SME Tests | ||
247 | ifneq ($(CROSS_AS_HAS_ARMV9_SME),) | ||
248 | -AARCH64_TESTS += sme-outprod1 | ||
249 | +AARCH64_TESTS += sme-outprod1 sme-smopa-1 sme-smopa-2 | ||
250 | endif | ||
251 | |||
252 | # System Registers Tests | ||
77 | -- | 253 | -- |
78 | 2.25.1 | 254 | 2.34.1 |
79 | 255 | ||
80 | 256 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The sun4v RTC device model added under commit a0e893039cf2ce0 in 2016 |
---|---|---|---|
2 | was unfortunately added with a license of GPL-v3-or-later, which is | ||
3 | not compatible with other QEMU code which has a GPL-v2-only license. | ||
2 | 4 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 5 | Relicense the code in the .c and the .h file to GPL-v2-or-later, |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | to make it compatible with the rest of QEMU. |
5 | Message-id: 20220822152741.1617527-6-richard.henderson@linaro.org | 7 | |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Cc: qemu-stable@nongnu.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Paolo Bonzini (for Red Hat) <pbonzini@redhat.com> | ||
11 | Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com> | ||
12 | Signed-off-by: Markus Armbruster <armbru@redhat.com> | ||
13 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
15 | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> | ||
16 | Acked-by: Alex Bennée <alex.bennee@linaro.org> | ||
17 | Message-id: 20240223161300.938542-1-peter.maydell@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 19 | --- |
9 | target/arm/ptw.c | 25 +++++++++++-------------- | 20 | include/hw/rtc/sun4v-rtc.h | 2 +- |
10 | 1 file changed, 11 insertions(+), 14 deletions(-) | 21 | hw/rtc/sun4v-rtc.c | 2 +- |
22 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
11 | 23 | ||
12 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | 24 | diff --git a/include/hw/rtc/sun4v-rtc.h b/include/hw/rtc/sun4v-rtc.h |
13 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/ptw.c | 26 | --- a/include/hw/rtc/sun4v-rtc.h |
15 | +++ b/target/arm/ptw.c | 27 | +++ b/include/hw/rtc/sun4v-rtc.h |
16 | @@ -XXX,XX +XXX,XX @@ static int simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | 28 | @@ -XXX,XX +XXX,XX @@ |
17 | 29 | * | |
18 | static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | 30 | * Copyright (c) 2016 Artyom Tarasenko |
19 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 31 | * |
20 | - hwaddr *phys_ptr, int *prot, | 32 | - * This code is licensed under the GNU GPL v3 or (at your option) any later |
21 | - target_ulong *page_size, | 33 | + * This code is licensed under the GNU GPL v2 or (at your option) any later |
22 | - ARMMMUFaultInfo *fi) | 34 | * version. |
23 | + GetPhysAddrResult *result, ARMMMUFaultInfo *fi) | 35 | */ |
24 | { | 36 | |
25 | int level = 1; | 37 | diff --git a/hw/rtc/sun4v-rtc.c b/hw/rtc/sun4v-rtc.c |
26 | uint32_t table; | 38 | index XXXXXXX..XXXXXXX 100644 |
27 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | 39 | --- a/hw/rtc/sun4v-rtc.c |
28 | /* 1Mb section. */ | 40 | +++ b/hw/rtc/sun4v-rtc.c |
29 | phys_addr = (desc & 0xfff00000) | (address & 0x000fffff); | 41 | @@ -XXX,XX +XXX,XX @@ |
30 | ap = (desc >> 10) & 3; | 42 | * |
31 | - *page_size = 1024 * 1024; | 43 | * Copyright (c) 2016 Artyom Tarasenko |
32 | + result->page_size = 1024 * 1024; | 44 | * |
33 | } else { | 45 | - * This code is licensed under the GNU GPL v3 or (at your option) any later |
34 | /* Lookup l2 entry. */ | 46 | + * This code is licensed under the GNU GPL v2 or (at your option) any later |
35 | if (type == 1) { | 47 | * version. |
36 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | 48 | */ |
37 | case 1: /* 64k page. */ | ||
38 | phys_addr = (desc & 0xffff0000) | (address & 0xffff); | ||
39 | ap = (desc >> (4 + ((address >> 13) & 6))) & 3; | ||
40 | - *page_size = 0x10000; | ||
41 | + result->page_size = 0x10000; | ||
42 | break; | ||
43 | case 2: /* 4k page. */ | ||
44 | phys_addr = (desc & 0xfffff000) | (address & 0xfff); | ||
45 | ap = (desc >> (4 + ((address >> 9) & 6))) & 3; | ||
46 | - *page_size = 0x1000; | ||
47 | + result->page_size = 0x1000; | ||
48 | break; | ||
49 | case 3: /* 1k page, or ARMv6/XScale "extended small (4k) page" */ | ||
50 | if (type == 1) { | ||
51 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
52 | if (arm_feature(env, ARM_FEATURE_XSCALE) | ||
53 | || arm_feature(env, ARM_FEATURE_V6)) { | ||
54 | phys_addr = (desc & 0xfffff000) | (address & 0xfff); | ||
55 | - *page_size = 0x1000; | ||
56 | + result->page_size = 0x1000; | ||
57 | } else { | ||
58 | /* | ||
59 | * UNPREDICTABLE in ARMv5; we choose to take a | ||
60 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
61 | } | ||
62 | } else { | ||
63 | phys_addr = (desc & 0xfffffc00) | (address & 0x3ff); | ||
64 | - *page_size = 0x400; | ||
65 | + result->page_size = 0x400; | ||
66 | } | ||
67 | ap = (desc >> 4) & 3; | ||
68 | break; | ||
69 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
70 | g_assert_not_reached(); | ||
71 | } | ||
72 | } | ||
73 | - *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); | ||
74 | - *prot |= *prot ? PAGE_EXEC : 0; | ||
75 | - if (!(*prot & (1 << access_type))) { | ||
76 | + result->prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); | ||
77 | + result->prot |= result->prot ? PAGE_EXEC : 0; | ||
78 | + if (!(result->prot & (1 << access_type))) { | ||
79 | /* Access permission fault. */ | ||
80 | fi->type = ARMFault_Permission; | ||
81 | goto do_fault; | ||
82 | } | ||
83 | - *phys_ptr = phys_addr; | ||
84 | + result->phys = phys_addr; | ||
85 | return false; | ||
86 | do_fault: | ||
87 | fi->domain = domain; | ||
88 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
89 | result, fi); | ||
90 | } else { | ||
91 | return get_phys_addr_v5(env, address, access_type, mmu_idx, | ||
92 | - &result->phys, &result->prot, | ||
93 | - &result->page_size, fi); | ||
94 | + result, fi); | ||
95 | } | ||
96 | } | ||
97 | 49 | ||
98 | -- | 50 | -- |
99 | 2.25.1 | 51 | 2.34.1 |
100 | 52 | ||
101 | 53 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 3 | Move the code to a separate file so that we do not have to compile |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | it anymore if CONFIG_ARM_V7M is not set. |
5 | Message-id: 20220822152741.1617527-7-richard.henderson@linaro.org | 5 | |
6 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
7 | Message-id: 20240308141051.536599-2-thuth@redhat.com | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | target/arm/ptw.c | 24 ++++++++++++------------ | 11 | target/arm/tcg/cpu-v7m.c | 290 +++++++++++++++++++++++++++++++++++++ |
10 | 1 file changed, 12 insertions(+), 12 deletions(-) | 12 | target/arm/tcg/cpu32.c | 261 --------------------------------- |
13 | target/arm/meson.build | 3 + | ||
14 | target/arm/tcg/meson.build | 3 + | ||
15 | 4 files changed, 296 insertions(+), 261 deletions(-) | ||
16 | create mode 100644 target/arm/tcg/cpu-v7m.c | ||
11 | 17 | ||
12 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | 18 | diff --git a/target/arm/tcg/cpu-v7m.c b/target/arm/tcg/cpu-v7m.c |
19 | new file mode 100644 | ||
20 | index XXXXXXX..XXXXXXX | ||
21 | --- /dev/null | ||
22 | +++ b/target/arm/tcg/cpu-v7m.c | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | +/* | ||
25 | + * QEMU ARMv7-M TCG-only CPUs. | ||
26 | + * | ||
27 | + * Copyright (c) 2012 SUSE LINUX Products GmbH | ||
28 | + * | ||
29 | + * This code is licensed under the GNU GPL v2 or later. | ||
30 | + * | ||
31 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
32 | + */ | ||
33 | + | ||
34 | +#include "qemu/osdep.h" | ||
35 | +#include "cpu.h" | ||
36 | +#include "hw/core/tcg-cpu-ops.h" | ||
37 | +#include "internals.h" | ||
38 | + | ||
39 | +#if !defined(CONFIG_USER_ONLY) | ||
40 | + | ||
41 | +#include "hw/intc/armv7m_nvic.h" | ||
42 | + | ||
43 | +static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
44 | +{ | ||
45 | + CPUClass *cc = CPU_GET_CLASS(cs); | ||
46 | + ARMCPU *cpu = ARM_CPU(cs); | ||
47 | + CPUARMState *env = &cpu->env; | ||
48 | + bool ret = false; | ||
49 | + | ||
50 | + /* | ||
51 | + * ARMv7-M interrupt masking works differently than -A or -R. | ||
52 | + * There is no FIQ/IRQ distinction. Instead of I and F bits | ||
53 | + * masking FIQ and IRQ interrupts, an exception is taken only | ||
54 | + * if it is higher priority than the current execution priority | ||
55 | + * (which depends on state like BASEPRI, FAULTMASK and the | ||
56 | + * currently active exception). | ||
57 | + */ | ||
58 | + if (interrupt_request & CPU_INTERRUPT_HARD | ||
59 | + && (armv7m_nvic_can_take_pending_exception(env->nvic))) { | ||
60 | + cs->exception_index = EXCP_IRQ; | ||
61 | + cc->tcg_ops->do_interrupt(cs); | ||
62 | + ret = true; | ||
63 | + } | ||
64 | + return ret; | ||
65 | +} | ||
66 | + | ||
67 | +#endif /* !CONFIG_USER_ONLY */ | ||
68 | + | ||
69 | +static void cortex_m0_initfn(Object *obj) | ||
70 | +{ | ||
71 | + ARMCPU *cpu = ARM_CPU(obj); | ||
72 | + set_feature(&cpu->env, ARM_FEATURE_V6); | ||
73 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
74 | + | ||
75 | + cpu->midr = 0x410cc200; | ||
76 | + | ||
77 | + /* | ||
78 | + * These ID register values are not guest visible, because | ||
79 | + * we do not implement the Main Extension. They must be set | ||
80 | + * to values corresponding to the Cortex-M0's implemented | ||
81 | + * features, because QEMU generally controls its emulation | ||
82 | + * by looking at ID register fields. We use the same values as | ||
83 | + * for the M3. | ||
84 | + */ | ||
85 | + cpu->isar.id_pfr0 = 0x00000030; | ||
86 | + cpu->isar.id_pfr1 = 0x00000200; | ||
87 | + cpu->isar.id_dfr0 = 0x00100000; | ||
88 | + cpu->id_afr0 = 0x00000000; | ||
89 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
90 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
91 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
92 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
93 | + cpu->isar.id_isar0 = 0x01141110; | ||
94 | + cpu->isar.id_isar1 = 0x02111000; | ||
95 | + cpu->isar.id_isar2 = 0x21112231; | ||
96 | + cpu->isar.id_isar3 = 0x01111110; | ||
97 | + cpu->isar.id_isar4 = 0x01310102; | ||
98 | + cpu->isar.id_isar5 = 0x00000000; | ||
99 | + cpu->isar.id_isar6 = 0x00000000; | ||
100 | +} | ||
101 | + | ||
102 | +static void cortex_m3_initfn(Object *obj) | ||
103 | +{ | ||
104 | + ARMCPU *cpu = ARM_CPU(obj); | ||
105 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
106 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
107 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
108 | + cpu->midr = 0x410fc231; | ||
109 | + cpu->pmsav7_dregion = 8; | ||
110 | + cpu->isar.id_pfr0 = 0x00000030; | ||
111 | + cpu->isar.id_pfr1 = 0x00000200; | ||
112 | + cpu->isar.id_dfr0 = 0x00100000; | ||
113 | + cpu->id_afr0 = 0x00000000; | ||
114 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
115 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
116 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
117 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
118 | + cpu->isar.id_isar0 = 0x01141110; | ||
119 | + cpu->isar.id_isar1 = 0x02111000; | ||
120 | + cpu->isar.id_isar2 = 0x21112231; | ||
121 | + cpu->isar.id_isar3 = 0x01111110; | ||
122 | + cpu->isar.id_isar4 = 0x01310102; | ||
123 | + cpu->isar.id_isar5 = 0x00000000; | ||
124 | + cpu->isar.id_isar6 = 0x00000000; | ||
125 | +} | ||
126 | + | ||
127 | +static void cortex_m4_initfn(Object *obj) | ||
128 | +{ | ||
129 | + ARMCPU *cpu = ARM_CPU(obj); | ||
130 | + | ||
131 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
132 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
133 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
134 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
135 | + cpu->midr = 0x410fc240; /* r0p0 */ | ||
136 | + cpu->pmsav7_dregion = 8; | ||
137 | + cpu->isar.mvfr0 = 0x10110021; | ||
138 | + cpu->isar.mvfr1 = 0x11000011; | ||
139 | + cpu->isar.mvfr2 = 0x00000000; | ||
140 | + cpu->isar.id_pfr0 = 0x00000030; | ||
141 | + cpu->isar.id_pfr1 = 0x00000200; | ||
142 | + cpu->isar.id_dfr0 = 0x00100000; | ||
143 | + cpu->id_afr0 = 0x00000000; | ||
144 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
145 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
146 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
147 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
148 | + cpu->isar.id_isar0 = 0x01141110; | ||
149 | + cpu->isar.id_isar1 = 0x02111000; | ||
150 | + cpu->isar.id_isar2 = 0x21112231; | ||
151 | + cpu->isar.id_isar3 = 0x01111110; | ||
152 | + cpu->isar.id_isar4 = 0x01310102; | ||
153 | + cpu->isar.id_isar5 = 0x00000000; | ||
154 | + cpu->isar.id_isar6 = 0x00000000; | ||
155 | +} | ||
156 | + | ||
157 | +static void cortex_m7_initfn(Object *obj) | ||
158 | +{ | ||
159 | + ARMCPU *cpu = ARM_CPU(obj); | ||
160 | + | ||
161 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
162 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
163 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
164 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
165 | + cpu->midr = 0x411fc272; /* r1p2 */ | ||
166 | + cpu->pmsav7_dregion = 8; | ||
167 | + cpu->isar.mvfr0 = 0x10110221; | ||
168 | + cpu->isar.mvfr1 = 0x12000011; | ||
169 | + cpu->isar.mvfr2 = 0x00000040; | ||
170 | + cpu->isar.id_pfr0 = 0x00000030; | ||
171 | + cpu->isar.id_pfr1 = 0x00000200; | ||
172 | + cpu->isar.id_dfr0 = 0x00100000; | ||
173 | + cpu->id_afr0 = 0x00000000; | ||
174 | + cpu->isar.id_mmfr0 = 0x00100030; | ||
175 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
176 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
177 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
178 | + cpu->isar.id_isar0 = 0x01101110; | ||
179 | + cpu->isar.id_isar1 = 0x02112000; | ||
180 | + cpu->isar.id_isar2 = 0x20232231; | ||
181 | + cpu->isar.id_isar3 = 0x01111131; | ||
182 | + cpu->isar.id_isar4 = 0x01310132; | ||
183 | + cpu->isar.id_isar5 = 0x00000000; | ||
184 | + cpu->isar.id_isar6 = 0x00000000; | ||
185 | +} | ||
186 | + | ||
187 | +static void cortex_m33_initfn(Object *obj) | ||
188 | +{ | ||
189 | + ARMCPU *cpu = ARM_CPU(obj); | ||
190 | + | ||
191 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
192 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
193 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
194 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
195 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
196 | + cpu->midr = 0x410fd213; /* r0p3 */ | ||
197 | + cpu->pmsav7_dregion = 16; | ||
198 | + cpu->sau_sregion = 8; | ||
199 | + cpu->isar.mvfr0 = 0x10110021; | ||
200 | + cpu->isar.mvfr1 = 0x11000011; | ||
201 | + cpu->isar.mvfr2 = 0x00000040; | ||
202 | + cpu->isar.id_pfr0 = 0x00000030; | ||
203 | + cpu->isar.id_pfr1 = 0x00000210; | ||
204 | + cpu->isar.id_dfr0 = 0x00200000; | ||
205 | + cpu->id_afr0 = 0x00000000; | ||
206 | + cpu->isar.id_mmfr0 = 0x00101F40; | ||
207 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
208 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
209 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
210 | + cpu->isar.id_isar0 = 0x01101110; | ||
211 | + cpu->isar.id_isar1 = 0x02212000; | ||
212 | + cpu->isar.id_isar2 = 0x20232232; | ||
213 | + cpu->isar.id_isar3 = 0x01111131; | ||
214 | + cpu->isar.id_isar4 = 0x01310132; | ||
215 | + cpu->isar.id_isar5 = 0x00000000; | ||
216 | + cpu->isar.id_isar6 = 0x00000000; | ||
217 | + cpu->clidr = 0x00000000; | ||
218 | + cpu->ctr = 0x8000c000; | ||
219 | +} | ||
220 | + | ||
221 | +static void cortex_m55_initfn(Object *obj) | ||
222 | +{ | ||
223 | + ARMCPU *cpu = ARM_CPU(obj); | ||
224 | + | ||
225 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
226 | + set_feature(&cpu->env, ARM_FEATURE_V8_1M); | ||
227 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
228 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
229 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
230 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
231 | + cpu->midr = 0x410fd221; /* r0p1 */ | ||
232 | + cpu->revidr = 0; | ||
233 | + cpu->pmsav7_dregion = 16; | ||
234 | + cpu->sau_sregion = 8; | ||
235 | + /* These are the MVFR* values for the FPU + full MVE configuration */ | ||
236 | + cpu->isar.mvfr0 = 0x10110221; | ||
237 | + cpu->isar.mvfr1 = 0x12100211; | ||
238 | + cpu->isar.mvfr2 = 0x00000040; | ||
239 | + cpu->isar.id_pfr0 = 0x20000030; | ||
240 | + cpu->isar.id_pfr1 = 0x00000230; | ||
241 | + cpu->isar.id_dfr0 = 0x10200000; | ||
242 | + cpu->id_afr0 = 0x00000000; | ||
243 | + cpu->isar.id_mmfr0 = 0x00111040; | ||
244 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
245 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
246 | + cpu->isar.id_mmfr3 = 0x00000011; | ||
247 | + cpu->isar.id_isar0 = 0x01103110; | ||
248 | + cpu->isar.id_isar1 = 0x02212000; | ||
249 | + cpu->isar.id_isar2 = 0x20232232; | ||
250 | + cpu->isar.id_isar3 = 0x01111131; | ||
251 | + cpu->isar.id_isar4 = 0x01310132; | ||
252 | + cpu->isar.id_isar5 = 0x00000000; | ||
253 | + cpu->isar.id_isar6 = 0x00000000; | ||
254 | + cpu->clidr = 0x00000000; /* caches not implemented */ | ||
255 | + cpu->ctr = 0x8303c003; | ||
256 | +} | ||
257 | + | ||
258 | +static const TCGCPUOps arm_v7m_tcg_ops = { | ||
259 | + .initialize = arm_translate_init, | ||
260 | + .synchronize_from_tb = arm_cpu_synchronize_from_tb, | ||
261 | + .debug_excp_handler = arm_debug_excp_handler, | ||
262 | + .restore_state_to_opc = arm_restore_state_to_opc, | ||
263 | + | ||
264 | +#ifdef CONFIG_USER_ONLY | ||
265 | + .record_sigsegv = arm_cpu_record_sigsegv, | ||
266 | + .record_sigbus = arm_cpu_record_sigbus, | ||
267 | +#else | ||
268 | + .tlb_fill = arm_cpu_tlb_fill, | ||
269 | + .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt, | ||
270 | + .do_interrupt = arm_v7m_cpu_do_interrupt, | ||
271 | + .do_transaction_failed = arm_cpu_do_transaction_failed, | ||
272 | + .do_unaligned_access = arm_cpu_do_unaligned_access, | ||
273 | + .adjust_watchpoint_address = arm_adjust_watchpoint_address, | ||
274 | + .debug_check_watchpoint = arm_debug_check_watchpoint, | ||
275 | + .debug_check_breakpoint = arm_debug_check_breakpoint, | ||
276 | +#endif /* !CONFIG_USER_ONLY */ | ||
277 | +}; | ||
278 | + | ||
279 | +static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
280 | +{ | ||
281 | + ARMCPUClass *acc = ARM_CPU_CLASS(oc); | ||
282 | + CPUClass *cc = CPU_CLASS(oc); | ||
283 | + | ||
284 | + acc->info = data; | ||
285 | + cc->tcg_ops = &arm_v7m_tcg_ops; | ||
286 | + cc->gdb_core_xml_file = "arm-m-profile.xml"; | ||
287 | +} | ||
288 | + | ||
289 | +static const ARMCPUInfo arm_v7m_cpus[] = { | ||
290 | + { .name = "cortex-m0", .initfn = cortex_m0_initfn, | ||
291 | + .class_init = arm_v7m_class_init }, | ||
292 | + { .name = "cortex-m3", .initfn = cortex_m3_initfn, | ||
293 | + .class_init = arm_v7m_class_init }, | ||
294 | + { .name = "cortex-m4", .initfn = cortex_m4_initfn, | ||
295 | + .class_init = arm_v7m_class_init }, | ||
296 | + { .name = "cortex-m7", .initfn = cortex_m7_initfn, | ||
297 | + .class_init = arm_v7m_class_init }, | ||
298 | + { .name = "cortex-m33", .initfn = cortex_m33_initfn, | ||
299 | + .class_init = arm_v7m_class_init }, | ||
300 | + { .name = "cortex-m55", .initfn = cortex_m55_initfn, | ||
301 | + .class_init = arm_v7m_class_init }, | ||
302 | +}; | ||
303 | + | ||
304 | +static void arm_v7m_cpu_register_types(void) | ||
305 | +{ | ||
306 | + size_t i; | ||
307 | + | ||
308 | + for (i = 0; i < ARRAY_SIZE(arm_v7m_cpus); ++i) { | ||
309 | + arm_cpu_register(&arm_v7m_cpus[i]); | ||
310 | + } | ||
311 | +} | ||
312 | + | ||
313 | +type_init(arm_v7m_cpu_register_types) | ||
314 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | 315 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/ptw.c | 316 | --- a/target/arm/tcg/cpu32.c |
15 | +++ b/target/arm/ptw.c | 317 | +++ b/target/arm/tcg/cpu32.c |
16 | @@ -XXX,XX +XXX,XX @@ do_fault: | 318 | @@ -XXX,XX +XXX,XX @@ |
17 | 319 | #include "hw/boards.h" | |
18 | static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | 320 | #endif |
19 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 321 | #include "cpregs.h" |
20 | - hwaddr *phys_ptr, int *prot, | 322 | -#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) |
21 | + GetPhysAddrResult *result, | 323 | -#include "hw/intc/armv7m_nvic.h" |
22 | ARMMMUFaultInfo *fi) | 324 | -#endif |
325 | |||
326 | |||
327 | /* Share AArch32 -cpu max features with AArch64. */ | ||
328 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
329 | /* CPU models. These are not needed for the AArch64 linux-user build. */ | ||
330 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
331 | |||
332 | -#if !defined(CONFIG_USER_ONLY) | ||
333 | -static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
334 | -{ | ||
335 | - CPUClass *cc = CPU_GET_CLASS(cs); | ||
336 | - ARMCPU *cpu = ARM_CPU(cs); | ||
337 | - CPUARMState *env = &cpu->env; | ||
338 | - bool ret = false; | ||
339 | - | ||
340 | - /* | ||
341 | - * ARMv7-M interrupt masking works differently than -A or -R. | ||
342 | - * There is no FIQ/IRQ distinction. Instead of I and F bits | ||
343 | - * masking FIQ and IRQ interrupts, an exception is taken only | ||
344 | - * if it is higher priority than the current execution priority | ||
345 | - * (which depends on state like BASEPRI, FAULTMASK and the | ||
346 | - * currently active exception). | ||
347 | - */ | ||
348 | - if (interrupt_request & CPU_INTERRUPT_HARD | ||
349 | - && (armv7m_nvic_can_take_pending_exception(env->nvic))) { | ||
350 | - cs->exception_index = EXCP_IRQ; | ||
351 | - cc->tcg_ops->do_interrupt(cs); | ||
352 | - ret = true; | ||
353 | - } | ||
354 | - return ret; | ||
355 | -} | ||
356 | -#endif /* !CONFIG_USER_ONLY */ | ||
357 | - | ||
358 | static void arm926_initfn(Object *obj) | ||
23 | { | 359 | { |
24 | int n; | 360 | ARMCPU *cpu = ARM_CPU(obj); |
25 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | 361 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) |
26 | 362 | define_arm_cp_regs(cpu, cortexa15_cp_reginfo); | |
27 | if (regime_translation_disabled(env, mmu_idx)) { | ||
28 | /* MPU disabled. */ | ||
29 | - *phys_ptr = address; | ||
30 | - *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | ||
31 | + result->phys = address; | ||
32 | + result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | ||
33 | return false; | ||
34 | } | ||
35 | |||
36 | - *phys_ptr = address; | ||
37 | + result->phys = address; | ||
38 | for (n = 7; n >= 0; n--) { | ||
39 | base = env->cp15.c6_region[n]; | ||
40 | if ((base & 1) == 0) { | ||
41 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
42 | fi->level = 1; | ||
43 | return true; | ||
44 | } | ||
45 | - *prot = PAGE_READ | PAGE_WRITE; | ||
46 | + result->prot = PAGE_READ | PAGE_WRITE; | ||
47 | break; | ||
48 | case 2: | ||
49 | - *prot = PAGE_READ; | ||
50 | + result->prot = PAGE_READ; | ||
51 | if (!is_user) { | ||
52 | - *prot |= PAGE_WRITE; | ||
53 | + result->prot |= PAGE_WRITE; | ||
54 | } | ||
55 | break; | ||
56 | case 3: | ||
57 | - *prot = PAGE_READ | PAGE_WRITE; | ||
58 | + result->prot = PAGE_READ | PAGE_WRITE; | ||
59 | break; | ||
60 | case 5: | ||
61 | if (is_user) { | ||
62 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
63 | fi->level = 1; | ||
64 | return true; | ||
65 | } | ||
66 | - *prot = PAGE_READ; | ||
67 | + result->prot = PAGE_READ; | ||
68 | break; | ||
69 | case 6: | ||
70 | - *prot = PAGE_READ; | ||
71 | + result->prot = PAGE_READ; | ||
72 | break; | ||
73 | default: | ||
74 | /* Bad permission. */ | ||
75 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
76 | fi->level = 1; | ||
77 | return true; | ||
78 | } | ||
79 | - *prot |= PAGE_EXEC; | ||
80 | + result->prot |= PAGE_EXEC; | ||
81 | return false; | ||
82 | } | 363 | } |
83 | 364 | ||
84 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | 365 | -static void cortex_m0_initfn(Object *obj) |
85 | } else { | 366 | -{ |
86 | /* Pre-v7 MPU */ | 367 | - ARMCPU *cpu = ARM_CPU(obj); |
87 | ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx, | 368 | - set_feature(&cpu->env, ARM_FEATURE_V6); |
88 | - &result->phys, &result->prot, fi); | 369 | - set_feature(&cpu->env, ARM_FEATURE_M); |
89 | + result, fi); | 370 | - |
90 | } | 371 | - cpu->midr = 0x410cc200; |
91 | qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32 | 372 | - |
92 | " mmu_idx %u -> %s (prot %c%c%c)\n", | 373 | - /* |
374 | - * These ID register values are not guest visible, because | ||
375 | - * we do not implement the Main Extension. They must be set | ||
376 | - * to values corresponding to the Cortex-M0's implemented | ||
377 | - * features, because QEMU generally controls its emulation | ||
378 | - * by looking at ID register fields. We use the same values as | ||
379 | - * for the M3. | ||
380 | - */ | ||
381 | - cpu->isar.id_pfr0 = 0x00000030; | ||
382 | - cpu->isar.id_pfr1 = 0x00000200; | ||
383 | - cpu->isar.id_dfr0 = 0x00100000; | ||
384 | - cpu->id_afr0 = 0x00000000; | ||
385 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
386 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
387 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
388 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
389 | - cpu->isar.id_isar0 = 0x01141110; | ||
390 | - cpu->isar.id_isar1 = 0x02111000; | ||
391 | - cpu->isar.id_isar2 = 0x21112231; | ||
392 | - cpu->isar.id_isar3 = 0x01111110; | ||
393 | - cpu->isar.id_isar4 = 0x01310102; | ||
394 | - cpu->isar.id_isar5 = 0x00000000; | ||
395 | - cpu->isar.id_isar6 = 0x00000000; | ||
396 | -} | ||
397 | - | ||
398 | -static void cortex_m3_initfn(Object *obj) | ||
399 | -{ | ||
400 | - ARMCPU *cpu = ARM_CPU(obj); | ||
401 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
402 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
403 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
404 | - cpu->midr = 0x410fc231; | ||
405 | - cpu->pmsav7_dregion = 8; | ||
406 | - cpu->isar.id_pfr0 = 0x00000030; | ||
407 | - cpu->isar.id_pfr1 = 0x00000200; | ||
408 | - cpu->isar.id_dfr0 = 0x00100000; | ||
409 | - cpu->id_afr0 = 0x00000000; | ||
410 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
411 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
412 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
413 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
414 | - cpu->isar.id_isar0 = 0x01141110; | ||
415 | - cpu->isar.id_isar1 = 0x02111000; | ||
416 | - cpu->isar.id_isar2 = 0x21112231; | ||
417 | - cpu->isar.id_isar3 = 0x01111110; | ||
418 | - cpu->isar.id_isar4 = 0x01310102; | ||
419 | - cpu->isar.id_isar5 = 0x00000000; | ||
420 | - cpu->isar.id_isar6 = 0x00000000; | ||
421 | -} | ||
422 | - | ||
423 | -static void cortex_m4_initfn(Object *obj) | ||
424 | -{ | ||
425 | - ARMCPU *cpu = ARM_CPU(obj); | ||
426 | - | ||
427 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
428 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
429 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
430 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
431 | - cpu->midr = 0x410fc240; /* r0p0 */ | ||
432 | - cpu->pmsav7_dregion = 8; | ||
433 | - cpu->isar.mvfr0 = 0x10110021; | ||
434 | - cpu->isar.mvfr1 = 0x11000011; | ||
435 | - cpu->isar.mvfr2 = 0x00000000; | ||
436 | - cpu->isar.id_pfr0 = 0x00000030; | ||
437 | - cpu->isar.id_pfr1 = 0x00000200; | ||
438 | - cpu->isar.id_dfr0 = 0x00100000; | ||
439 | - cpu->id_afr0 = 0x00000000; | ||
440 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
441 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
442 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
443 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
444 | - cpu->isar.id_isar0 = 0x01141110; | ||
445 | - cpu->isar.id_isar1 = 0x02111000; | ||
446 | - cpu->isar.id_isar2 = 0x21112231; | ||
447 | - cpu->isar.id_isar3 = 0x01111110; | ||
448 | - cpu->isar.id_isar4 = 0x01310102; | ||
449 | - cpu->isar.id_isar5 = 0x00000000; | ||
450 | - cpu->isar.id_isar6 = 0x00000000; | ||
451 | -} | ||
452 | - | ||
453 | -static void cortex_m7_initfn(Object *obj) | ||
454 | -{ | ||
455 | - ARMCPU *cpu = ARM_CPU(obj); | ||
456 | - | ||
457 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
458 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
459 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
460 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
461 | - cpu->midr = 0x411fc272; /* r1p2 */ | ||
462 | - cpu->pmsav7_dregion = 8; | ||
463 | - cpu->isar.mvfr0 = 0x10110221; | ||
464 | - cpu->isar.mvfr1 = 0x12000011; | ||
465 | - cpu->isar.mvfr2 = 0x00000040; | ||
466 | - cpu->isar.id_pfr0 = 0x00000030; | ||
467 | - cpu->isar.id_pfr1 = 0x00000200; | ||
468 | - cpu->isar.id_dfr0 = 0x00100000; | ||
469 | - cpu->id_afr0 = 0x00000000; | ||
470 | - cpu->isar.id_mmfr0 = 0x00100030; | ||
471 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
472 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
473 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
474 | - cpu->isar.id_isar0 = 0x01101110; | ||
475 | - cpu->isar.id_isar1 = 0x02112000; | ||
476 | - cpu->isar.id_isar2 = 0x20232231; | ||
477 | - cpu->isar.id_isar3 = 0x01111131; | ||
478 | - cpu->isar.id_isar4 = 0x01310132; | ||
479 | - cpu->isar.id_isar5 = 0x00000000; | ||
480 | - cpu->isar.id_isar6 = 0x00000000; | ||
481 | -} | ||
482 | - | ||
483 | -static void cortex_m33_initfn(Object *obj) | ||
484 | -{ | ||
485 | - ARMCPU *cpu = ARM_CPU(obj); | ||
486 | - | ||
487 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
488 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
489 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
490 | - set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
491 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
492 | - cpu->midr = 0x410fd213; /* r0p3 */ | ||
493 | - cpu->pmsav7_dregion = 16; | ||
494 | - cpu->sau_sregion = 8; | ||
495 | - cpu->isar.mvfr0 = 0x10110021; | ||
496 | - cpu->isar.mvfr1 = 0x11000011; | ||
497 | - cpu->isar.mvfr2 = 0x00000040; | ||
498 | - cpu->isar.id_pfr0 = 0x00000030; | ||
499 | - cpu->isar.id_pfr1 = 0x00000210; | ||
500 | - cpu->isar.id_dfr0 = 0x00200000; | ||
501 | - cpu->id_afr0 = 0x00000000; | ||
502 | - cpu->isar.id_mmfr0 = 0x00101F40; | ||
503 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
504 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
505 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
506 | - cpu->isar.id_isar0 = 0x01101110; | ||
507 | - cpu->isar.id_isar1 = 0x02212000; | ||
508 | - cpu->isar.id_isar2 = 0x20232232; | ||
509 | - cpu->isar.id_isar3 = 0x01111131; | ||
510 | - cpu->isar.id_isar4 = 0x01310132; | ||
511 | - cpu->isar.id_isar5 = 0x00000000; | ||
512 | - cpu->isar.id_isar6 = 0x00000000; | ||
513 | - cpu->clidr = 0x00000000; | ||
514 | - cpu->ctr = 0x8000c000; | ||
515 | -} | ||
516 | - | ||
517 | -static void cortex_m55_initfn(Object *obj) | ||
518 | -{ | ||
519 | - ARMCPU *cpu = ARM_CPU(obj); | ||
520 | - | ||
521 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
522 | - set_feature(&cpu->env, ARM_FEATURE_V8_1M); | ||
523 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
524 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
525 | - set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
526 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
527 | - cpu->midr = 0x410fd221; /* r0p1 */ | ||
528 | - cpu->revidr = 0; | ||
529 | - cpu->pmsav7_dregion = 16; | ||
530 | - cpu->sau_sregion = 8; | ||
531 | - /* These are the MVFR* values for the FPU + full MVE configuration */ | ||
532 | - cpu->isar.mvfr0 = 0x10110221; | ||
533 | - cpu->isar.mvfr1 = 0x12100211; | ||
534 | - cpu->isar.mvfr2 = 0x00000040; | ||
535 | - cpu->isar.id_pfr0 = 0x20000030; | ||
536 | - cpu->isar.id_pfr1 = 0x00000230; | ||
537 | - cpu->isar.id_dfr0 = 0x10200000; | ||
538 | - cpu->id_afr0 = 0x00000000; | ||
539 | - cpu->isar.id_mmfr0 = 0x00111040; | ||
540 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
541 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
542 | - cpu->isar.id_mmfr3 = 0x00000011; | ||
543 | - cpu->isar.id_isar0 = 0x01103110; | ||
544 | - cpu->isar.id_isar1 = 0x02212000; | ||
545 | - cpu->isar.id_isar2 = 0x20232232; | ||
546 | - cpu->isar.id_isar3 = 0x01111131; | ||
547 | - cpu->isar.id_isar4 = 0x01310132; | ||
548 | - cpu->isar.id_isar5 = 0x00000000; | ||
549 | - cpu->isar.id_isar6 = 0x00000000; | ||
550 | - cpu->clidr = 0x00000000; /* caches not implemented */ | ||
551 | - cpu->ctr = 0x8303c003; | ||
552 | -} | ||
553 | - | ||
554 | static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | ||
555 | /* Dummy the TCM region regs for the moment */ | ||
556 | { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, | ||
557 | @@ -XXX,XX +XXX,XX @@ static void pxa270c5_initfn(Object *obj) | ||
558 | cpu->reset_sctlr = 0x00000078; | ||
559 | } | ||
560 | |||
561 | -static const TCGCPUOps arm_v7m_tcg_ops = { | ||
562 | - .initialize = arm_translate_init, | ||
563 | - .synchronize_from_tb = arm_cpu_synchronize_from_tb, | ||
564 | - .debug_excp_handler = arm_debug_excp_handler, | ||
565 | - .restore_state_to_opc = arm_restore_state_to_opc, | ||
566 | - | ||
567 | -#ifdef CONFIG_USER_ONLY | ||
568 | - .record_sigsegv = arm_cpu_record_sigsegv, | ||
569 | - .record_sigbus = arm_cpu_record_sigbus, | ||
570 | -#else | ||
571 | - .tlb_fill = arm_cpu_tlb_fill, | ||
572 | - .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt, | ||
573 | - .do_interrupt = arm_v7m_cpu_do_interrupt, | ||
574 | - .do_transaction_failed = arm_cpu_do_transaction_failed, | ||
575 | - .do_unaligned_access = arm_cpu_do_unaligned_access, | ||
576 | - .adjust_watchpoint_address = arm_adjust_watchpoint_address, | ||
577 | - .debug_check_watchpoint = arm_debug_check_watchpoint, | ||
578 | - .debug_check_breakpoint = arm_debug_check_breakpoint, | ||
579 | -#endif /* !CONFIG_USER_ONLY */ | ||
580 | -}; | ||
581 | - | ||
582 | -static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
583 | -{ | ||
584 | - ARMCPUClass *acc = ARM_CPU_CLASS(oc); | ||
585 | - CPUClass *cc = CPU_CLASS(oc); | ||
586 | - | ||
587 | - acc->info = data; | ||
588 | - cc->tcg_ops = &arm_v7m_tcg_ops; | ||
589 | - cc->gdb_core_xml_file = "arm-m-profile.xml"; | ||
590 | -} | ||
591 | - | ||
592 | #ifndef TARGET_AARCH64 | ||
593 | /* | ||
594 | * -cpu max: a CPU with as many features enabled as our emulation supports. | ||
595 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { | ||
596 | { .name = "cortex-a8", .initfn = cortex_a8_initfn }, | ||
597 | { .name = "cortex-a9", .initfn = cortex_a9_initfn }, | ||
598 | { .name = "cortex-a15", .initfn = cortex_a15_initfn }, | ||
599 | - { .name = "cortex-m0", .initfn = cortex_m0_initfn, | ||
600 | - .class_init = arm_v7m_class_init }, | ||
601 | - { .name = "cortex-m3", .initfn = cortex_m3_initfn, | ||
602 | - .class_init = arm_v7m_class_init }, | ||
603 | - { .name = "cortex-m4", .initfn = cortex_m4_initfn, | ||
604 | - .class_init = arm_v7m_class_init }, | ||
605 | - { .name = "cortex-m7", .initfn = cortex_m7_initfn, | ||
606 | - .class_init = arm_v7m_class_init }, | ||
607 | - { .name = "cortex-m33", .initfn = cortex_m33_initfn, | ||
608 | - .class_init = arm_v7m_class_init }, | ||
609 | - { .name = "cortex-m55", .initfn = cortex_m55_initfn, | ||
610 | - .class_init = arm_v7m_class_init }, | ||
611 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, | ||
612 | { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, | ||
613 | { .name = "cortex-r52", .initfn = cortex_r52_initfn }, | ||
614 | diff --git a/target/arm/meson.build b/target/arm/meson.build | ||
615 | index XXXXXXX..XXXXXXX 100644 | ||
616 | --- a/target/arm/meson.build | ||
617 | +++ b/target/arm/meson.build | ||
618 | @@ -XXX,XX +XXX,XX @@ arm_system_ss.add(files( | ||
619 | 'ptw.c', | ||
620 | )) | ||
621 | |||
622 | +arm_user_ss = ss.source_set() | ||
623 | + | ||
624 | subdir('hvf') | ||
625 | |||
626 | if 'CONFIG_TCG' in config_all_accel | ||
627 | @@ -XXX,XX +XXX,XX @@ endif | ||
628 | |||
629 | target_arch += {'arm': arm_ss} | ||
630 | target_system_arch += {'arm': arm_system_ss} | ||
631 | +target_user_arch += {'arm': arm_user_ss} | ||
632 | diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build | ||
633 | index XXXXXXX..XXXXXXX 100644 | ||
634 | --- a/target/arm/tcg/meson.build | ||
635 | +++ b/target/arm/tcg/meson.build | ||
636 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files( | ||
637 | arm_system_ss.add(files( | ||
638 | 'psci.c', | ||
639 | )) | ||
640 | + | ||
641 | +arm_system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('cpu-v7m.c')) | ||
642 | +arm_user_ss.add(when: 'TARGET_AARCH64', if_false: files('cpu-v7m.c')) | ||
93 | -- | 643 | -- |
94 | 2.25.1 | 644 | 2.34.1 |
95 | |||
96 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | This can be made redundant with result->page_size, by moving the basic | ||
4 | set of page_size from get_phys_addr_pmsav8. We still need to overwrite | ||
5 | page_size when v8m_security_lookup signals a subpage. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220822152741.1617527-11-richard.henderson@linaro.org | ||
9 | [PMM: Update a comment that used to refer to is_subpage] | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/internals.h | 4 ++-- | ||
14 | target/arm/m_helper.c | 3 +-- | ||
15 | target/arm/ptw.c | 23 ++++++++++++----------- | ||
16 | 3 files changed, 15 insertions(+), 15 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/internals.h | ||
21 | +++ b/target/arm/internals.h | ||
22 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
23 | |||
24 | bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
25 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
26 | - GetPhysAddrResult *result, bool *is_subpage, | ||
27 | - ARMMMUFaultInfo *fi, uint32_t *mregion); | ||
28 | + GetPhysAddrResult *result, ARMMMUFaultInfo *fi, | ||
29 | + uint32_t *mregion); | ||
30 | |||
31 | void arm_log_exception(CPUState *cs); | ||
32 | |||
33 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/m_helper.c | ||
36 | +++ b/target/arm/m_helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
38 | if (arm_current_el(env) != 0 || alt) { | ||
39 | GetPhysAddrResult res = {}; | ||
40 | ARMMMUFaultInfo fi = {}; | ||
41 | - bool is_subpage; | ||
42 | |||
43 | /* We can ignore the return value as prot is always set */ | ||
44 | pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, | ||
45 | - &res, &is_subpage, &fi, &mregion); | ||
46 | + &res, &fi, &mregion); | ||
47 | if (mregion == -1) { | ||
48 | mrvalid = false; | ||
49 | mregion = 0; | ||
50 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/ptw.c | ||
53 | +++ b/target/arm/ptw.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
55 | |||
56 | bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
57 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
58 | - GetPhysAddrResult *result, bool *is_subpage, | ||
59 | - ARMMMUFaultInfo *fi, uint32_t *mregion) | ||
60 | + GetPhysAddrResult *result, ARMMMUFaultInfo *fi, | ||
61 | + uint32_t *mregion) | ||
62 | { | ||
63 | /* | ||
64 | * Perform a PMSAv8 MPU lookup (without also doing the SAU check | ||
65 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
66 | * mregion is (if not NULL) set to the region number which matched, | ||
67 | * or -1 if no region number is returned (MPU off, address did not | ||
68 | * hit a region, address hit in multiple regions). | ||
69 | - * We set is_subpage to true if the region hit doesn't cover the | ||
70 | - * entire TARGET_PAGE the address is within. | ||
71 | + * If the region hit doesn't cover the entire TARGET_PAGE the address | ||
72 | + * is within, then we set the result page_size to 1 to force the | ||
73 | + * memory system to use a subpage. | ||
74 | */ | ||
75 | ARMCPU *cpu = env_archcpu(env); | ||
76 | bool is_user = regime_is_user(env, mmu_idx); | ||
77 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
78 | uint32_t addr_page_base = address & TARGET_PAGE_MASK; | ||
79 | uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1); | ||
80 | |||
81 | - *is_subpage = false; | ||
82 | + result->page_size = TARGET_PAGE_SIZE; | ||
83 | result->phys = address; | ||
84 | result->prot = 0; | ||
85 | if (mregion) { | ||
86 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
87 | ranges_overlap(base, limit - base + 1, | ||
88 | addr_page_base, | ||
89 | TARGET_PAGE_SIZE)) { | ||
90 | - *is_subpage = true; | ||
91 | + result->page_size = 1; | ||
92 | } | ||
93 | continue; | ||
94 | } | ||
95 | |||
96 | if (base > addr_page_base || limit < addr_page_limit) { | ||
97 | - *is_subpage = true; | ||
98 | + result->page_size = 1; | ||
99 | } | ||
100 | |||
101 | if (matchregion != -1) { | ||
102 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
103 | uint32_t secure = regime_is_secure(env, mmu_idx); | ||
104 | V8M_SAttributes sattrs = {}; | ||
105 | bool ret; | ||
106 | - bool mpu_is_subpage; | ||
107 | |||
108 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
109 | v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs); | ||
110 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
111 | } | ||
112 | |||
113 | ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, | ||
114 | - result, &mpu_is_subpage, fi, NULL); | ||
115 | - result->page_size = | ||
116 | - sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE; | ||
117 | + result, fi, NULL); | ||
118 | + if (sattrs.subpage) { | ||
119 | + result->page_size = 1; | ||
120 | + } | ||
121 | return ret; | ||
122 | } | ||
123 | |||
124 | -- | ||
125 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Remove the use of regime_is_secure from pmsav8_mpu_lookup, | ||
4 | passing the new parameter to the lookup instead. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220822152741.1617527-13-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/internals.h | 4 ++-- | ||
13 | target/arm/m_helper.c | 2 +- | ||
14 | target/arm/ptw.c | 7 +++---- | ||
15 | 3 files changed, 6 insertions(+), 7 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/internals.h | ||
20 | +++ b/target/arm/internals.h | ||
21 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
22 | |||
23 | bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
24 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
25 | - GetPhysAddrResult *result, ARMMMUFaultInfo *fi, | ||
26 | - uint32_t *mregion); | ||
27 | + bool is_secure, GetPhysAddrResult *result, | ||
28 | + ARMMMUFaultInfo *fi, uint32_t *mregion); | ||
29 | |||
30 | void arm_log_exception(CPUState *cs); | ||
31 | |||
32 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/m_helper.c | ||
35 | +++ b/target/arm/m_helper.c | ||
36 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
37 | ARMMMUFaultInfo fi = {}; | ||
38 | |||
39 | /* We can ignore the return value as prot is always set */ | ||
40 | - pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, | ||
41 | + pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, targetsec, | ||
42 | &res, &fi, &mregion); | ||
43 | if (mregion == -1) { | ||
44 | mrvalid = false; | ||
45 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/ptw.c | ||
48 | +++ b/target/arm/ptw.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
50 | |||
51 | bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
52 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
53 | - GetPhysAddrResult *result, ARMMMUFaultInfo *fi, | ||
54 | - uint32_t *mregion) | ||
55 | + bool secure, GetPhysAddrResult *result, | ||
56 | + ARMMMUFaultInfo *fi, uint32_t *mregion) | ||
57 | { | ||
58 | /* | ||
59 | * Perform a PMSAv8 MPU lookup (without also doing the SAU check | ||
60 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
61 | */ | ||
62 | ARMCPU *cpu = env_archcpu(env); | ||
63 | bool is_user = regime_is_user(env, mmu_idx); | ||
64 | - uint32_t secure = regime_is_secure(env, mmu_idx); | ||
65 | int n; | ||
66 | int matchregion = -1; | ||
67 | bool hit = false; | ||
68 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
69 | } | ||
70 | } | ||
71 | |||
72 | - ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, | ||
73 | + ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, secure, | ||
74 | result, fi, NULL); | ||
75 | if (sattrs.subpage) { | ||
76 | result->page_size = 1; | ||
77 | -- | ||
78 | 2.25.1 | ||
79 | |||
80 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Remove the use of regime_is_secure from get_phys_addr_v6, | ||
4 | passing the new parameter to the lookup instead. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220822152741.1617527-15-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/ptw.c | 11 +++++------ | ||
13 | 1 file changed, 5 insertions(+), 6 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/ptw.c | ||
18 | +++ b/target/arm/ptw.c | ||
19 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
20 | |||
21 | static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
22 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
23 | - GetPhysAddrResult *result, ARMMMUFaultInfo *fi) | ||
24 | + bool is_secure, GetPhysAddrResult *result, | ||
25 | + ARMMMUFaultInfo *fi) | ||
26 | { | ||
27 | ARMCPU *cpu = env_archcpu(env); | ||
28 | int level = 1; | ||
29 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
30 | fi->type = ARMFault_Translation; | ||
31 | goto do_fault; | ||
32 | } | ||
33 | - desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), | ||
34 | - mmu_idx, fi); | ||
35 | + desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi); | ||
36 | if (fi->type != ARMFault_None) { | ||
37 | goto do_fault; | ||
38 | } | ||
39 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
40 | ns = extract32(desc, 3, 1); | ||
41 | /* Lookup l2 entry. */ | ||
42 | table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); | ||
43 | - desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), | ||
44 | - mmu_idx, fi); | ||
45 | + desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi); | ||
46 | if (fi->type != ARMFault_None) { | ||
47 | goto do_fault; | ||
48 | } | ||
49 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
50 | result, fi); | ||
51 | } else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) { | ||
52 | return get_phys_addr_v6(env, address, access_type, mmu_idx, | ||
53 | - result, fi); | ||
54 | + is_secure, result, fi); | ||
55 | } else { | ||
56 | return get_phys_addr_v5(env, address, access_type, mmu_idx, | ||
57 | is_secure, result, fi); | ||
58 | -- | ||
59 | 2.25.1 | ||
60 | |||
61 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Remove the use of regime_is_secure from get_phys_addr_pmsav8. | ||
4 | Since we already had a local variable named secure, use that. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220822152741.1617527-16-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/ptw.c | 5 ++--- | ||
13 | 1 file changed, 2 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/ptw.c | ||
18 | +++ b/target/arm/ptw.c | ||
19 | @@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
20 | |||
21 | static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
22 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
23 | - GetPhysAddrResult *result, | ||
24 | + bool secure, GetPhysAddrResult *result, | ||
25 | ARMMMUFaultInfo *fi) | ||
26 | { | ||
27 | - uint32_t secure = regime_is_secure(env, mmu_idx); | ||
28 | V8M_SAttributes sattrs = {}; | ||
29 | bool ret; | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
32 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
33 | /* PMSAv8 */ | ||
34 | ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx, | ||
35 | - result, fi); | ||
36 | + is_secure, result, fi); | ||
37 | } else if (arm_feature(env, ARM_FEATURE_V7)) { | ||
38 | /* PMSAv7 */ | ||
39 | ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, | ||
40 | -- | ||
41 | 2.25.1 | ||
42 | |||
43 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Remove the use of regime_is_secure from pmsav7_use_background_region, | ||
4 | using the new parameter instead. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220822152741.1617527-17-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/ptw.c | 10 +++++----- | ||
13 | 1 file changed, 5 insertions(+), 5 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/ptw.c | ||
18 | +++ b/target/arm/ptw.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static bool m_is_system_region(CPUARMState *env, uint32_t address) | ||
20 | } | ||
21 | |||
22 | static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
23 | - bool is_user) | ||
24 | + bool is_secure, bool is_user) | ||
25 | { | ||
26 | /* | ||
27 | * Return true if we should use the default memory map as a | ||
28 | @@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
29 | } | ||
30 | |||
31 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
32 | - return env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] | ||
33 | - & R_V7M_MPU_CTRL_PRIVDEFENA_MASK; | ||
34 | + return env->v7m.mpu_ctrl[is_secure] & R_V7M_MPU_CTRL_PRIVDEFENA_MASK; | ||
35 | } else { | ||
36 | return regime_sctlr(env, mmu_idx) & SCTLR_BR; | ||
37 | } | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
39 | { | ||
40 | ARMCPU *cpu = env_archcpu(env); | ||
41 | int n; | ||
42 | + bool secure = regime_is_secure(env, mmu_idx); | ||
43 | bool is_user = regime_is_user(env, mmu_idx); | ||
44 | |||
45 | result->phys = address; | ||
46 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
47 | } | ||
48 | |||
49 | if (n == -1) { /* no hits */ | ||
50 | - if (!pmsav7_use_background_region(cpu, mmu_idx, is_user)) { | ||
51 | + if (!pmsav7_use_background_region(cpu, mmu_idx, secure, is_user)) { | ||
52 | /* background fault */ | ||
53 | fi->type = ARMFault_Background; | ||
54 | return true; | ||
55 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
56 | } else if (m_is_ppb_region(env, address)) { | ||
57 | hit = true; | ||
58 | } else { | ||
59 | - if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) { | ||
60 | + if (pmsav7_use_background_region(cpu, mmu_idx, secure, is_user)) { | ||
61 | hit = true; | ||
62 | } | ||
63 | |||
64 | -- | ||
65 | 2.25.1 | ||
66 | |||
67 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Remove the use of regime_is_secure from get_phys_addr_pmsav7, | ||
4 | using the new parameter instead. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220822152741.1617527-19-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/ptw.c | 5 ++--- | ||
13 | 1 file changed, 2 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/ptw.c | ||
18 | +++ b/target/arm/ptw.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
20 | |||
21 | static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, | ||
22 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
23 | - GetPhysAddrResult *result, | ||
24 | + bool secure, GetPhysAddrResult *result, | ||
25 | ARMMMUFaultInfo *fi) | ||
26 | { | ||
27 | ARMCPU *cpu = env_archcpu(env); | ||
28 | int n; | ||
29 | - bool secure = regime_is_secure(env, mmu_idx); | ||
30 | bool is_user = regime_is_user(env, mmu_idx); | ||
31 | |||
32 | result->phys = address; | ||
33 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
34 | } else if (arm_feature(env, ARM_FEATURE_V7)) { | ||
35 | /* PMSAv7 */ | ||
36 | ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, | ||
37 | - result, fi); | ||
38 | + is_secure, result, fi); | ||
39 | } else { | ||
40 | /* Pre-v7 MPU */ | ||
41 | ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx, | ||
42 | -- | ||
43 | 2.25.1 | ||
44 | |||
45 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Remove the use of regime_is_secure from get_phys_addr_pmsav5. | ||
4 | |||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220822152741.1617527-21-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/ptw.c | 4 ++-- | ||
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/ptw.c | ||
17 | +++ b/target/arm/ptw.c | ||
18 | @@ -XXX,XX +XXX,XX @@ do_fault: | ||
19 | |||
20 | static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, | ||
21 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
22 | - GetPhysAddrResult *result, | ||
23 | + bool is_secure, GetPhysAddrResult *result, | ||
24 | ARMMMUFaultInfo *fi) | ||
25 | { | ||
26 | int n; | ||
27 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
28 | } else { | ||
29 | /* Pre-v7 MPU */ | ||
30 | ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx, | ||
31 | - result, fi); | ||
32 | + is_secure, result, fi); | ||
33 | } | ||
34 | qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32 | ||
35 | " mmu_idx %u -> %s (prot %c%c%c)\n", | ||
36 | -- | ||
37 | 2.25.1 | ||
38 | |||
39 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Lucas Dietrich <ld.adecy@gmail.com> | ||
2 | 1 | ||
3 | The LAN9118 allows the guest to specify a level for both the TX and | ||
4 | RX FIFOs at which an interrupt will be generated. We implement the | ||
5 | RSFL_INT interrupt for the RX FIFO but are missing the handling of | ||
6 | the equivalent TSFL_INT for the TX FIFO. Add the missing test to set | ||
7 | the interrupt if the TX FIFO has exceeded the guest-specified level. | ||
8 | |||
9 | This flag is required for Micrium lan911x ethernet driver to work. | ||
10 | |||
11 | Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com> | ||
12 | [PMM: Tweaked commit message and comment] | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/net/lan9118.c | 8 ++++++++ | ||
17 | 1 file changed, 8 insertions(+) | ||
18 | |||
19 | diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/net/lan9118.c | ||
22 | +++ b/hw/net/lan9118.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void do_tx_packet(lan9118_state *s) | ||
24 | n = (s->tx_status_fifo_head + s->tx_status_fifo_used) & 511; | ||
25 | s->tx_status_fifo[n] = status; | ||
26 | s->tx_status_fifo_used++; | ||
27 | + | ||
28 | + /* | ||
29 | + * Generate TSFL interrupt if TX FIFO level exceeds the level | ||
30 | + * specified in the FIFO_INT TX Status Level field. | ||
31 | + */ | ||
32 | + if (s->tx_status_fifo_used > ((s->fifo_int >> 16) & 0xff)) { | ||
33 | + s->int_sts |= TSFL_INT; | ||
34 | + } | ||
35 | if (s->tx_status_fifo_used == 512) { | ||
36 | s->int_sts |= TSFF_INT; | ||
37 | /* TODO: Stop transmission. */ | ||
38 | -- | ||
39 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Replace '84' magic value by the X_MAX definition, and '1' by Y_MAX. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
6 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
7 | Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20220819153931.3147384-2-peter.maydell@linaro.org | ||
10 | --- | ||
11 | chardev/baum.c | 11 +++++++---- | ||
12 | 1 file changed, 7 insertions(+), 4 deletions(-) | ||
13 | |||
14 | diff --git a/chardev/baum.c b/chardev/baum.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/chardev/baum.c | ||
17 | +++ b/chardev/baum.c | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | |||
20 | #define BUF_SIZE 256 | ||
21 | |||
22 | +#define X_MAX 84 | ||
23 | +#define Y_MAX 1 | ||
24 | + | ||
25 | struct BaumChardev { | ||
26 | Chardev parent; | ||
27 | |||
28 | @@ -XXX,XX +XXX,XX @@ static int baum_deferred_init(BaumChardev *baum) | ||
29 | brlapi_perror("baum: brlapi__getDisplaySize"); | ||
30 | return 0; | ||
31 | } | ||
32 | - if (baum->y > 1) { | ||
33 | - baum->y = 1; | ||
34 | + if (baum->y > Y_MAX) { | ||
35 | + baum->y = Y_MAX; | ||
36 | } | ||
37 | - if (baum->x > 84) { | ||
38 | - baum->x = 84; | ||
39 | + if (baum->x > X_MAX) { | ||
40 | + baum->x = X_MAX; | ||
41 | } | ||
42 | |||
43 | con = qemu_console_lookup_by_index(0); | ||
44 | -- | ||
45 | 2.25.1 | ||
46 | |||
47 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | We know 'x * y' will be at most 'X_MAX * Y_MAX' (which is not | ||
4 | a big value, it is actually 84). Instead of having the compiler | ||
5 | use variable-length array, declare an array able to hold the | ||
6 | maximum 'x * y'. | ||
7 | |||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
10 | Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Message-id: 20220819153931.3147384-3-peter.maydell@linaro.org | ||
13 | --- | ||
14 | chardev/baum.c | 8 ++++---- | ||
15 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
16 | |||
17 | diff --git a/chardev/baum.c b/chardev/baum.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/chardev/baum.c | ||
20 | +++ b/chardev/baum.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len) | ||
22 | switch (req) { | ||
23 | case BAUM_REQ_DisplayData: | ||
24 | { | ||
25 | - uint8_t cells[baum->x * baum->y], c; | ||
26 | - uint8_t text[baum->x * baum->y]; | ||
27 | - uint8_t zero[baum->x * baum->y]; | ||
28 | + uint8_t cells[X_MAX * Y_MAX], c; | ||
29 | + uint8_t text[X_MAX * Y_MAX]; | ||
30 | + uint8_t zero[X_MAX * Y_MAX]; | ||
31 | int cursor = BRLAPI_CURSOR_OFF; | ||
32 | int i; | ||
33 | |||
34 | @@ -XXX,XX +XXX,XX @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len) | ||
35 | } | ||
36 | timer_del(baum->cellCount_timer); | ||
37 | |||
38 | - memset(zero, 0, sizeof(zero)); | ||
39 | + memset(zero, 0, baum->x * baum->y); | ||
40 | |||
41 | brlapi_writeArguments_t wa = { | ||
42 | .displayNumber = BRLAPI_DISPLAY_DEFAULT, | ||
43 | -- | ||
44 | 2.25.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Use autofree heap allocation instead of variable-length | ||
4 | array on the stack. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
8 | Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20220819153931.3147384-4-peter.maydell@linaro.org | ||
11 | --- | ||
12 | chardev/baum.c | 3 ++- | ||
13 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/chardev/baum.c b/chardev/baum.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/chardev/baum.c | ||
18 | +++ b/chardev/baum.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void baum_chr_accept_input(struct Chardev *chr) | ||
20 | static void baum_write_packet(BaumChardev *baum, const uint8_t *buf, int len) | ||
21 | { | ||
22 | Chardev *chr = CHARDEV(baum); | ||
23 | - uint8_t io_buf[1 + 2 * len], *cur = io_buf; | ||
24 | + g_autofree uint8_t *io_buf = g_malloc(1 + 2 * len); | ||
25 | + uint8_t *cur = io_buf; | ||
26 | int room; | ||
27 | *cur++ = ESC; | ||
28 | while (len--) | ||
29 | -- | ||
30 | 2.25.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | The combined_key[... QIO_CHANNEL_WEBSOCK_GUID_LEN ...] array in | ||
4 | qio_channel_websock_handshake_send_res_ok() expands to a call | ||
5 | to strlen(QIO_CHANNEL_WEBSOCK_GUID), and the compiler doesn't | ||
6 | realize the string is const, so consider combined_key[] being | ||
7 | a variable-length array. | ||
8 | |||
9 | To remove the variable-length array, we provide it a hint to | ||
10 | the compiler by using sizeof() - 1 instead of strlen(). | ||
11 | |||
12 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
13 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Message-id: 20220819153931.3147384-5-peter.maydell@linaro.org | ||
16 | --- | ||
17 | io/channel-websock.c | 2 +- | ||
18 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/io/channel-websock.c b/io/channel-websock.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/io/channel-websock.c | ||
23 | +++ b/io/channel-websock.c | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | |||
26 | #define QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN 24 | ||
27 | #define QIO_CHANNEL_WEBSOCK_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" | ||
28 | -#define QIO_CHANNEL_WEBSOCK_GUID_LEN strlen(QIO_CHANNEL_WEBSOCK_GUID) | ||
29 | +#define QIO_CHANNEL_WEBSOCK_GUID_LEN (sizeof(QIO_CHANNEL_WEBSOCK_GUID) - 1) | ||
30 | |||
31 | #define QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL "sec-websocket-protocol" | ||
32 | #define QIO_CHANNEL_WEBSOCK_HEADER_VERSION "sec-websocket-version" | ||
33 | -- | ||
34 | 2.25.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | The compiler isn't clever enough to figure 'min_buf_size' | ||
4 | is a constant, so help it by using a definitions instead. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Acked-by: Jason Wang <jasowang@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20220819153931.3147384-6-peter.maydell@linaro.org | ||
11 | --- | ||
12 | hw/net/e1000e_core.c | 7 ++++--- | ||
13 | 1 file changed, 4 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/net/e1000e_core.c | ||
18 | +++ b/hw/net/e1000e_core.c | ||
19 | @@ -XXX,XX +XXX,XX @@ e1000e_rx_fix_l4_csum(E1000ECore *core, struct NetRxPkt *pkt) | ||
20 | } | ||
21 | } | ||
22 | |||
23 | +/* Min. octets in an ethernet frame sans FCS */ | ||
24 | +#define MIN_BUF_SIZE 60 | ||
25 | + | ||
26 | ssize_t | ||
27 | e1000e_receive_iov(E1000ECore *core, const struct iovec *iov, int iovcnt) | ||
28 | { | ||
29 | static const int maximum_ethernet_hdr_len = (14 + 4); | ||
30 | - /* Min. octets in an ethernet frame sans FCS */ | ||
31 | - static const int min_buf_size = 60; | ||
32 | |||
33 | uint32_t n = 0; | ||
34 | - uint8_t min_buf[min_buf_size]; | ||
35 | + uint8_t min_buf[MIN_BUF_SIZE]; | ||
36 | struct iovec min_iov; | ||
37 | uint8_t *filter_buf; | ||
38 | size_t size, orig_size; | ||
39 | -- | ||
40 | 2.25.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Use autofree heap allocation instead of variable-length | ||
4 | array on the stack. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Acked-by: David Gibson <david@gibson.dropbear.id.au> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> | ||
11 | Message-id: 20220819153931.3147384-7-peter.maydell@linaro.org | ||
12 | --- | ||
13 | hw/ppc/pnv.c | 4 ++-- | ||
14 | hw/ppc/spapr.c | 8 ++++---- | ||
15 | hw/ppc/spapr_pci_nvlink2.c | 2 +- | ||
16 | 3 files changed, 7 insertions(+), 7 deletions(-) | ||
17 | |||
18 | diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/ppc/pnv.c | ||
21 | +++ b/hw/ppc/pnv.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, void *fdt) | ||
23 | int smt_threads = CPU_CORE(pc)->nr_threads; | ||
24 | CPUPPCState *env = &cpu->env; | ||
25 | PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); | ||
26 | - uint32_t servers_prop[smt_threads]; | ||
27 | + g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads); | ||
28 | int i; | ||
29 | uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40), | ||
30 | 0xffffffff, 0xffffffff}; | ||
31 | @@ -XXX,XX +XXX,XX @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, void *fdt) | ||
32 | servers_prop[i] = cpu_to_be32(pc->pir + i); | ||
33 | } | ||
34 | _FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", | ||
35 | - servers_prop, sizeof(servers_prop)))); | ||
36 | + servers_prop, sizeof(*servers_prop) * smt_threads))); | ||
37 | } | ||
38 | |||
39 | static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir, | ||
40 | diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/ppc/spapr.c | ||
43 | +++ b/hw/ppc/spapr.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, | ||
45 | int smt_threads) | ||
46 | { | ||
47 | int i, ret = 0; | ||
48 | - uint32_t servers_prop[smt_threads]; | ||
49 | - uint32_t gservers_prop[smt_threads * 2]; | ||
50 | + g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads); | ||
51 | + g_autofree uint32_t *gservers_prop = g_new(uint32_t, smt_threads * 2); | ||
52 | int index = spapr_get_vcpu_id(cpu); | ||
53 | |||
54 | if (cpu->compat_pvr) { | ||
55 | @@ -XXX,XX +XXX,XX @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, | ||
56 | gservers_prop[i*2 + 1] = 0; | ||
57 | } | ||
58 | ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", | ||
59 | - servers_prop, sizeof(servers_prop)); | ||
60 | + servers_prop, sizeof(*servers_prop) * smt_threads); | ||
61 | if (ret < 0) { | ||
62 | return ret; | ||
63 | } | ||
64 | ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-gserver#s", | ||
65 | - gservers_prop, sizeof(gservers_prop)); | ||
66 | + gservers_prop, sizeof(*gservers_prop) * smt_threads * 2); | ||
67 | |||
68 | return ret; | ||
69 | } | ||
70 | diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/hw/ppc/spapr_pci_nvlink2.c | ||
73 | +++ b/hw/ppc/spapr_pci_nvlink2.c | ||
74 | @@ -XXX,XX +XXX,XX @@ void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev, void *fdt, int offset, | ||
75 | continue; | ||
76 | } | ||
77 | if (dev == nvslot->gpdev) { | ||
78 | - uint32_t npus[nvslot->linknum]; | ||
79 | + g_autofree uint32_t *npus = g_new(uint32_t, nvslot->linknum); | ||
80 | |||
81 | for (j = 0; j < nvslot->linknum; ++j) { | ||
82 | PCIDevice *npdev = nvslot->links[j].npdev; | ||
83 | -- | ||
84 | 2.25.1 | ||
85 | |||
86 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Use autofree heap allocation instead of variable-length | ||
4 | array on the stack. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Acked-by: David Gibson <david@gibson.dropbear.id.au> | ||
8 | Reviewed-by: Greg Kurz <groug@kaod.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20220819153931.3147384-8-peter.maydell@linaro.org | ||
11 | --- | ||
12 | hw/intc/xics.c | 2 +- | ||
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/hw/intc/xics.c b/hw/intc/xics.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/intc/xics.c | ||
18 | +++ b/hw/intc/xics.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void ics_reset_irq(ICSIRQState *irq) | ||
20 | static void ics_reset(DeviceState *dev) | ||
21 | { | ||
22 | ICSState *ics = ICS(dev); | ||
23 | + g_autofree uint8_t *flags = g_malloc(ics->nr_irqs); | ||
24 | int i; | ||
25 | - uint8_t flags[ics->nr_irqs]; | ||
26 | |||
27 | for (i = 0; i < ics->nr_irqs; i++) { | ||
28 | flags[i] = ics->irqs[i].flags; | ||
29 | -- | ||
30 | 2.25.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Use autofree heap allocation instead of variable-length array on | ||
4 | the stack. Replace the snprintf() call by g_strdup_printf(). | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20220819153931.3147384-9-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/i386/multiboot.c | 5 ++--- | ||
12 | 1 file changed, 2 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/i386/multiboot.c | ||
17 | +++ b/hw/i386/multiboot.c | ||
18 | @@ -XXX,XX +XXX,XX @@ int load_multiboot(X86MachineState *x86ms, | ||
19 | uint8_t *mb_bootinfo_data; | ||
20 | uint32_t cmdline_len; | ||
21 | GList *mods = NULL; | ||
22 | + g_autofree char *kcmdline = NULL; | ||
23 | |||
24 | /* Ok, let's see if it is a multiboot image. | ||
25 | The header is 12x32bit long, so the latest entry may be 8192 - 48. */ | ||
26 | @@ -XXX,XX +XXX,XX @@ int load_multiboot(X86MachineState *x86ms, | ||
27 | } | ||
28 | |||
29 | /* Commandline support */ | ||
30 | - char kcmdline[strlen(kernel_filename) + strlen(kernel_cmdline) + 2]; | ||
31 | - snprintf(kcmdline, sizeof(kcmdline), "%s %s", | ||
32 | - kernel_filename, kernel_cmdline); | ||
33 | + kcmdline = g_strdup_printf("%s %s", kernel_filename, kernel_cmdline); | ||
34 | stl_p(bootinfo + MBI_CMDLINE, mb_add_cmdline(&mbs, kcmdline)); | ||
35 | |||
36 | stl_p(bootinfo + MBI_BOOTLOADER, mb_add_bootloader(&mbs, bootloader_name)); | ||
37 | -- | ||
38 | 2.25.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | The compiler isn't clever enough to figure 'width' is a constant, | ||
4 | so help it by using a definitions instead. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20220819153931.3147384-10-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/usb/hcd-ohci.c | 7 ++++--- | ||
12 | 1 file changed, 4 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/usb/hcd-ohci.c | ||
17 | +++ b/hw/usb/hcd-ohci.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed) | ||
19 | return 1; | ||
20 | } | ||
21 | |||
22 | +#define HEX_CHAR_PER_LINE 16 | ||
23 | + | ||
24 | static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len) | ||
25 | { | ||
26 | bool print16; | ||
27 | bool printall; | ||
28 | - const int width = 16; | ||
29 | int i; | ||
30 | - char tmp[3 * width + 1]; | ||
31 | + char tmp[3 * HEX_CHAR_PER_LINE + 1]; | ||
32 | char *p = tmp; | ||
33 | |||
34 | print16 = !!trace_event_get_state_backends(TRACE_USB_OHCI_TD_PKT_SHORT); | ||
35 | @@ -XXX,XX +XXX,XX @@ static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len) | ||
36 | } | ||
37 | |||
38 | for (i = 0; ; i++) { | ||
39 | - if (i && (!(i % width) || (i == len))) { | ||
40 | + if (i && (!(i % HEX_CHAR_PER_LINE) || (i == len))) { | ||
41 | if (!printall) { | ||
42 | trace_usb_ohci_td_pkt_short(msg, tmp); | ||
43 | break; | ||
44 | -- | ||
45 | 2.25.1 | ||
46 | |||
47 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Use autofree heap allocation instead of variable-length | ||
4 | array on the stack. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20220819153931.3147384-11-peter.maydell@linaro.org | ||
10 | --- | ||
11 | ui/curses.c | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/ui/curses.c b/ui/curses.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/ui/curses.c | ||
17 | +++ b/ui/curses.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void curses_update(DisplayChangeListener *dcl, | ||
19 | int x, int y, int w, int h) | ||
20 | { | ||
21 | console_ch_t *line; | ||
22 | - cchar_t curses_line[width]; | ||
23 | + g_autofree cchar_t *curses_line = g_new(cchar_t, width); | ||
24 | wchar_t wch[CCHARW_MAX]; | ||
25 | attr_t attrs; | ||
26 | short colors; | ||
27 | -- | ||
28 | 2.25.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Use autofree heap allocation instead of variable-length | ||
4 | array on the stack. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20220819153931.3147384-12-peter.maydell@linaro.org | ||
10 | --- | ||
11 | tests/unit/test-vmstate.c | 7 +++---- | ||
12 | 1 file changed, 3 insertions(+), 4 deletions(-) | ||
13 | |||
14 | diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/unit/test-vmstate.c | ||
17 | +++ b/tests/unit/test-vmstate.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void save_buffer(const uint8_t *buf, size_t buf_size) | ||
19 | static void compare_vmstate(const uint8_t *wire, size_t size) | ||
20 | { | ||
21 | QEMUFile *f = open_test_file(false); | ||
22 | - uint8_t result[size]; | ||
23 | + g_autofree uint8_t *result = g_malloc(size); | ||
24 | |||
25 | /* read back as binary */ | ||
26 | |||
27 | - g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), ==, | ||
28 | - sizeof(result)); | ||
29 | + g_assert_cmpint(qemu_get_buffer(f, result, size), ==, size); | ||
30 | g_assert(!qemu_file_get_error(f)); | ||
31 | |||
32 | /* Compare that what is on the file is the same that what we | ||
33 | expected to be there */ | ||
34 | - SUCCESS(memcmp(result, wire, sizeof(result))); | ||
35 | + SUCCESS(memcmp(result, wire, size)); | ||
36 | |||
37 | /* Must reach EOF */ | ||
38 | qemu_get_byte(f); | ||
39 | -- | ||
40 | 2.25.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Shellcheck correctly reports that we set python_version and never use | ||
2 | it. This is a leftover from commit f9332757898a7: we used to use | ||
3 | python_version purely to as part of the summary information printed | ||
4 | at the end of a configure run, and that commit changed to printing | ||
5 | the information from meson (which looks up the python version | ||
6 | itself). Remove the unused variable. | ||
7 | 1 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20220825150703.4074125-2-peter.maydell@linaro.org | ||
12 | --- | ||
13 | configure | 3 --- | ||
14 | 1 file changed, 3 deletions(-) | ||
15 | |||
16 | diff --git a/configure b/configure | ||
17 | index XXXXXXX..XXXXXXX 100755 | ||
18 | --- a/configure | ||
19 | +++ b/configure | ||
20 | @@ -XXX,XX +XXX,XX @@ if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then | ||
21 | "Use --python=/path/to/python to specify a supported Python." | ||
22 | fi | ||
23 | |||
24 | -# Preserve python version since some functionality is dependent on it | ||
25 | -python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null) | ||
26 | - | ||
27 | # Suppress writing compiled files | ||
28 | python="$python -B" | ||
29 | |||
30 | -- | ||
31 | 2.25.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The meson_args variable was added in commit 3b4da13293482134b, but | ||
2 | was not used in that commit and isn't used today. Delete the | ||
3 | unnecessary assignment. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20220825150703.4074125-3-peter.maydell@linaro.org | ||
9 | --- | ||
10 | configure | 1 - | ||
11 | 1 file changed, 1 deletion(-) | ||
12 | |||
13 | diff --git a/configure b/configure | ||
14 | index XXXXXXX..XXXXXXX 100755 | ||
15 | --- a/configure | ||
16 | +++ b/configure | ||
17 | @@ -XXX,XX +XXX,XX @@ pie="" | ||
18 | coroutine="" | ||
19 | plugins="$default_feature" | ||
20 | meson="" | ||
21 | -meson_args="" | ||
22 | ninja="" | ||
23 | bindir="bin" | ||
24 | skip_meson=no | ||
25 | -- | ||
26 | 2.25.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This commit adds quotes in some places which: | ||
2 | * are spotted by shellcheck | ||
3 | * are obviously incorrect | ||
4 | * are easy to fix just by adding the quotes | ||
5 | 1 | ||
6 | It doesn't attempt fix all of the places shellcheck finds errors, | ||
7 | or even all the ones which are easy to fix. It's just a random | ||
8 | sampling which is hopefully easy to review and which cuts | ||
9 | down the size of the problem for next time somebody wants to | ||
10 | try to look at shellcheck errors. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 20220825150703.4074125-4-peter.maydell@linaro.org | ||
16 | --- | ||
17 | configure | 64 +++++++++++++++++++++++++++---------------------------- | ||
18 | 1 file changed, 32 insertions(+), 32 deletions(-) | ||
19 | |||
20 | diff --git a/configure b/configure | ||
21 | index XXXXXXX..XXXXXXX 100755 | ||
22 | --- a/configure | ||
23 | +++ b/configure | ||
24 | @@ -XXX,XX +XXX,XX @@ GNUmakefile: ; | ||
25 | |||
26 | EOF | ||
27 | cd build | ||
28 | - exec $source_path/configure "$@" | ||
29 | + exec "$source_path/configure" "$@" | ||
30 | fi | ||
31 | |||
32 | # Temporary directory used for files created while | ||
33 | @@ -XXX,XX +XXX,XX @@ meson_option_build_array() { | ||
34 | printf ']\n' | ||
35 | } | ||
36 | |||
37 | -. $source_path/scripts/meson-buildoptions.sh | ||
38 | +. "$source_path/scripts/meson-buildoptions.sh" | ||
39 | |||
40 | meson_options= | ||
41 | meson_option_add() { | ||
42 | @@ -XXX,XX +XXX,XX @@ for opt do | ||
43 | case "$opt" in | ||
44 | --help|-h) show_help=yes | ||
45 | ;; | ||
46 | - --version|-V) exec cat $source_path/VERSION | ||
47 | + --version|-V) exec cat "$source_path/VERSION" | ||
48 | ;; | ||
49 | --prefix=*) prefix="$optarg" | ||
50 | ;; | ||
51 | @@ -XXX,XX +XXX,XX @@ default_target_list="" | ||
52 | mak_wilds="" | ||
53 | |||
54 | if [ "$linux_user" != no ]; then | ||
55 | - if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then | ||
56 | + if [ "$targetos" = linux ] && [ -d "$source_path/linux-user/include/host/$cpu" ]; then | ||
57 | linux_user=yes | ||
58 | elif [ "$linux_user" = yes ]; then | ||
59 | error_exit "linux-user not supported on this architecture" | ||
60 | @@ -XXX,XX +XXX,XX @@ if [ "$bsd_user" != no ]; then | ||
61 | if [ "$bsd_user" = "" ]; then | ||
62 | test $targetos = freebsd && bsd_user=yes | ||
63 | fi | ||
64 | - if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then | ||
65 | + if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then | ||
66 | error_exit "bsd-user not supported on this host OS" | ||
67 | fi | ||
68 | fi | ||
69 | @@ -XXX,XX +XXX,XX @@ python="$python -B" | ||
70 | if test -z "$meson"; then | ||
71 | if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then | ||
72 | meson=meson | ||
73 | - elif test $git_submodules_action != 'ignore' ; then | ||
74 | + elif test "$git_submodules_action" != 'ignore' ; then | ||
75 | meson=git | ||
76 | elif test -e "${source_path}/meson/meson.py" ; then | ||
77 | meson=internal | ||
78 | @@ -XXX,XX +XXX,XX @@ esac | ||
79 | container="no" | ||
80 | if test $use_containers = "yes"; then | ||
81 | if has "docker" || has "podman"; then | ||
82 | - container=$($python $source_path/tests/docker/docker.py probe) | ||
83 | + container=$($python "$source_path"/tests/docker/docker.py probe) | ||
84 | fi | ||
85 | fi | ||
86 | |||
87 | @@ -XXX,XX +XXX,XX @@ if test "$QEMU_GA_DISTRO" = ""; then | ||
88 | QEMU_GA_DISTRO=Linux | ||
89 | fi | ||
90 | if test "$QEMU_GA_VERSION" = ""; then | ||
91 | - QEMU_GA_VERSION=$(cat $source_path/VERSION) | ||
92 | + QEMU_GA_VERSION=$(cat "$source_path"/VERSION) | ||
93 | fi | ||
94 | |||
95 | |||
96 | @@ -XXX,XX +XXX,XX @@ fi | ||
97 | for target in $target_list; do | ||
98 | target_dir="$target" | ||
99 | target_name=$(echo $target | cut -d '-' -f 1)$EXESUF | ||
100 | - mkdir -p $target_dir | ||
101 | + mkdir -p "$target_dir" | ||
102 | case $target in | ||
103 | *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; | ||
104 | *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; | ||
105 | @@ -XXX,XX +XXX,XX @@ for target in $target_list; do | ||
106 | config_target_mak=tests/tcg/config-$target.mak | ||
107 | |||
108 | echo "# Automatically generated by configure - do not modify" > $config_target_mak | ||
109 | - echo "TARGET_NAME=$arch" >> $config_target_mak | ||
110 | + echo "TARGET_NAME=$arch" >> "$config_target_mak" | ||
111 | case $target in | ||
112 | xtensa*-linux-user) | ||
113 | # the toolchain is not complete with headers, only build softmmu tests | ||
114 | continue | ||
115 | ;; | ||
116 | *-softmmu) | ||
117 | - test -f $source_path/tests/tcg/$arch/Makefile.softmmu-target || continue | ||
118 | + test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue | ||
119 | qemu="qemu-system-$arch" | ||
120 | ;; | ||
121 | *-linux-user|*-bsd-user) | ||
122 | @@ -XXX,XX +XXX,XX @@ for target in $target_list; do | ||
123 | # compilers is a requirememt for adding a new test that needs a | ||
124 | # compiler feature. | ||
125 | |||
126 | - echo "BUILD_STATIC=$build_static" >> $config_target_mak | ||
127 | - write_target_makefile >> $config_target_mak | ||
128 | + echo "BUILD_STATIC=$build_static" >> "$config_target_mak" | ||
129 | + write_target_makefile >> "$config_target_mak" | ||
130 | case $target in | ||
131 | aarch64-*) | ||
132 | if do_compiler "$target_cc" $target_cflags \ | ||
133 | -march=armv8.1-a+sve -o $TMPE $TMPC; then | ||
134 | - echo "CROSS_CC_HAS_SVE=y" >> $config_target_mak | ||
135 | + echo "CROSS_CC_HAS_SVE=y" >> "$config_target_mak" | ||
136 | fi | ||
137 | if do_compiler "$target_cc" $target_cflags \ | ||
138 | -march=armv8.1-a+sve2 -o $TMPE $TMPC; then | ||
139 | - echo "CROSS_CC_HAS_SVE2=y" >> $config_target_mak | ||
140 | + echo "CROSS_CC_HAS_SVE2=y" >> "$config_target_mak" | ||
141 | fi | ||
142 | if do_compiler "$target_cc" $target_cflags \ | ||
143 | -march=armv8.3-a -o $TMPE $TMPC; then | ||
144 | - echo "CROSS_CC_HAS_ARMV8_3=y" >> $config_target_mak | ||
145 | + echo "CROSS_CC_HAS_ARMV8_3=y" >> "$config_target_mak" | ||
146 | fi | ||
147 | if do_compiler "$target_cc" $target_cflags \ | ||
148 | -mbranch-protection=standard -o $TMPE $TMPC; then | ||
149 | - echo "CROSS_CC_HAS_ARMV8_BTI=y" >> $config_target_mak | ||
150 | + echo "CROSS_CC_HAS_ARMV8_BTI=y" >> "$config_target_mak" | ||
151 | fi | ||
152 | if do_compiler "$target_cc" $target_cflags \ | ||
153 | -march=armv8.5-a+memtag -o $TMPE $TMPC; then | ||
154 | - echo "CROSS_CC_HAS_ARMV8_MTE=y" >> $config_target_mak | ||
155 | + echo "CROSS_CC_HAS_ARMV8_MTE=y" >> "$config_target_mak" | ||
156 | fi | ||
157 | ;; | ||
158 | ppc*) | ||
159 | if do_compiler "$target_cc" $target_cflags \ | ||
160 | -mpower8-vector -o $TMPE $TMPC; then | ||
161 | - echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> $config_target_mak | ||
162 | + echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> "$config_target_mak" | ||
163 | fi | ||
164 | if do_compiler "$target_cc" $target_cflags \ | ||
165 | -mpower10 -o $TMPE $TMPC; then | ||
166 | - echo "CROSS_CC_HAS_POWER10=y" >> $config_target_mak | ||
167 | + echo "CROSS_CC_HAS_POWER10=y" >> "$config_target_mak" | ||
168 | fi | ||
169 | ;; | ||
170 | i386-linux-user) | ||
171 | if do_compiler "$target_cc" $target_cflags \ | ||
172 | -Werror -fno-pie -o $TMPE $TMPC; then | ||
173 | - echo "CROSS_CC_HAS_I386_NOPIE=y" >> $config_target_mak | ||
174 | + echo "CROSS_CC_HAS_I386_NOPIE=y" >> "$config_target_mak" | ||
175 | fi | ||
176 | ;; | ||
177 | esac | ||
178 | elif test -n "$container_image"; then | ||
179 | echo "build-tcg-tests-$target: docker-image-$container_image" >> $makefile | ||
180 | - echo "BUILD_STATIC=y" >> $config_target_mak | ||
181 | - write_container_target_makefile >> $config_target_mak | ||
182 | + echo "BUILD_STATIC=y" >> "$config_target_mak" | ||
183 | + write_container_target_makefile >> "$config_target_mak" | ||
184 | case $target in | ||
185 | aarch64-*) | ||
186 | - echo "CROSS_CC_HAS_SVE=y" >> $config_target_mak | ||
187 | - echo "CROSS_CC_HAS_SVE2=y" >> $config_target_mak | ||
188 | - echo "CROSS_CC_HAS_ARMV8_3=y" >> $config_target_mak | ||
189 | - echo "CROSS_CC_HAS_ARMV8_BTI=y" >> $config_target_mak | ||
190 | - echo "CROSS_CC_HAS_ARMV8_MTE=y" >> $config_target_mak | ||
191 | + echo "CROSS_CC_HAS_SVE=y" >> "$config_target_mak" | ||
192 | + echo "CROSS_CC_HAS_SVE2=y" >> "$config_target_mak" | ||
193 | + echo "CROSS_CC_HAS_ARMV8_3=y" >> "$config_target_mak" | ||
194 | + echo "CROSS_CC_HAS_ARMV8_BTI=y" >> "$config_target_mak" | ||
195 | + echo "CROSS_CC_HAS_ARMV8_MTE=y" >> "$config_target_mak" | ||
196 | ;; | ||
197 | ppc*) | ||
198 | - echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> $config_target_mak | ||
199 | - echo "CROSS_CC_HAS_POWER10=y" >> $config_target_mak | ||
200 | + echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> "$config_target_mak" | ||
201 | + echo "CROSS_CC_HAS_POWER10=y" >> "$config_target_mak" | ||
202 | ;; | ||
203 | i386-linux-user) | ||
204 | - echo "CROSS_CC_HAS_I386_NOPIE=y" >> $config_target_mak | ||
205 | + echo "CROSS_CC_HAS_I386_NOPIE=y" >> "$config_target_mak" | ||
206 | ;; | ||
207 | esac | ||
208 | got_cross_cc=yes | ||
209 | fi | ||
210 | if test $got_cross_cc = yes; then | ||
211 | mkdir -p tests/tcg/$target | ||
212 | - echo "QEMU=$PWD/$qemu" >> $config_target_mak | ||
213 | + echo "QEMU=$PWD/$qemu" >> "$config_target_mak" | ||
214 | echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> $makefile | ||
215 | tcg_tests_targets="$tcg_tests_targets $target" | ||
216 | fi | ||
217 | -- | ||
218 | 2.25.1 | ||
219 | |||
220 | diff view generated by jsdifflib |