1 | Handful of bugfixes for rc2. None of these are particularly critical | 1 | Nothing exciting here: two minor bug fixes, some fixes for |
---|---|---|---|
2 | or exciting. | 2 | running on a 32-bit host, and a docs tweak. |
3 | 3 | ||
4 | thanks | ||
4 | -- PMM | 5 | -- PMM |
5 | 6 | ||
6 | The following changes since commit 45a150aa2b3492acf6691c7bdbeb25a8545d8345: | 7 | The following changes since commit 6af9d12c88b9720f209912f6e4b01fefe5906d59: |
7 | 8 | ||
8 | Merge remote-tracking branch 'remotes/ericb/tags/pull-bitmaps-2020-08-03' into staging (2020-08-03 15:13:49 +0100) | 9 | Merge tag 'migration-20240331-pull-request' of https://gitlab.com/peterx/qemu into staging (2024-04-01 13:12:40 +0100) |
9 | 10 | ||
10 | are available in the Git repository at: | 11 | are available in the Git repository at: |
11 | 12 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200803 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240402 |
13 | 14 | ||
14 | for you to fetch changes up to 13557fd392890cbd985bceba7f717e01efd674b8: | 15 | for you to fetch changes up to 393770d7a02135e7468018f52da610712f151ec0: |
15 | 16 | ||
16 | hw/timer/imx_epit: Avoid assertion when CR.SWR is written (2020-08-03 17:56:11 +0100) | 17 | raspi4b: Reduce RAM to 1Gb on 32-bit hosts (2024-04-02 10:13:48 +0100) |
17 | 18 | ||
18 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
19 | target-arm queue: | 20 | target-arm queue: |
20 | * hw/timer/imx_epit: Avoid assertion when CR.SWR is written | 21 | * take HSTR traps of cp15 accesses to EL2, not EL1 |
21 | * netduino2, netduinoplus2, microbit: set system_clock_scale so that | 22 | * docs: sbsa: update specs, add dt note |
22 | SysTick running on the CPU clock works | 23 | * hw/intc/arm_gicv3: ICC_HPPIR* return SPURIOUS if int group is disabled |
23 | * target/arm: Avoid maybe-uninitialized warning with gcc 4.9 | 24 | * tests/qtest: Fix STM32L4x5 GPIO test on 32-bit |
24 | * target/arm: Fix AddPAC error indication | 25 | * raspi4b: Reduce RAM to 1Gb on 32-bit hosts |
25 | * Make AIRCR.SYSRESETREQ actually reset the system for the | ||
26 | microbit, mps2-*, musca-*, netduino* boards | ||
27 | 26 | ||
28 | ---------------------------------------------------------------- | 27 | ---------------------------------------------------------------- |
29 | Kaige Li (1): | 28 | Cédric Le Goater (2): |
30 | target/arm: Avoid maybe-uninitialized warning with gcc 4.9 | 29 | tests/qtest: Fix STM32L4x5 GPIO test on 32-bit |
30 | raspi4b: Reduce RAM to 1Gb on 32-bit hosts | ||
31 | 31 | ||
32 | Peter Maydell (6): | 32 | Marcin Juszkiewicz (1): |
33 | hw/arm/netduino2, netduinoplus2: Set system_clock_scale | 33 | docs: sbsa: update specs, add dt note |
34 | include/hw/irq.h: New function qemu_irq_is_connected() | ||
35 | hw/intc/armv7m_nvic: Provide default "reset the system" behaviour for SYSRESETREQ | ||
36 | msf2-soc, stellaris: Don't wire up SYSRESETREQ | ||
37 | hw/arm/nrf51_soc: Set system_clock_scale | ||
38 | hw/timer/imx_epit: Avoid assertion when CR.SWR is written | ||
39 | 34 | ||
40 | Richard Henderson (1): | 35 | Peter Maydell (2): |
41 | target/arm: Fix AddPAC error indication | 36 | target/arm: take HSTR traps of cp15 accesses to EL2, not EL1 |
37 | hw/intc/arm_gicv3: ICC_HPPIR* return SPURIOUS if int group is disabled | ||
42 | 38 | ||
43 | include/hw/arm/armv7m.h | 4 +++- | 39 | docs/system/arm/sbsa.rst | 35 +++++++++++++++++------ |
44 | include/hw/irq.h | 18 ++++++++++++++++++ | 40 | hw/arm/raspi4b.c | 4 +++ |
45 | hw/arm/msf2-soc.c | 11 ----------- | 41 | hw/intc/arm_gicv3_cpuif.c | 4 +-- |
46 | hw/arm/netduino2.c | 10 ++++++++++ | 42 | target/arm/tcg/translate.c | 2 +- |
47 | hw/arm/netduinoplus2.c | 10 ++++++++++ | 43 | tests/qtest/stm32l4x5_gpio-test.c | 59 +++++++++++++++++++++++---------------- |
48 | hw/arm/nrf51_soc.c | 5 +++++ | 44 | 5 files changed, 68 insertions(+), 36 deletions(-) |
49 | hw/arm/stellaris.c | 12 ------------ | ||
50 | hw/intc/armv7m_nvic.c | 17 ++++++++++++++++- | ||
51 | hw/timer/imx_epit.c | 13 ++++++++++--- | ||
52 | target/arm/pauth_helper.c | 6 +++++- | ||
53 | target/arm/translate-a64.c | 2 +- | ||
54 | tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++++ | ||
55 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
56 | 13 files changed, 112 insertions(+), 31 deletions(-) | ||
57 | create mode 100644 tests/tcg/aarch64/pauth-5.c | ||
58 | 45 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The netduino2 and netduinoplus2 boards forgot to set the system_clock_scale | ||
2 | global, which meant that if guest code used the systick timer in "use | ||
3 | the processor clock" mode it would hang because time never advances. | ||
4 | 1 | ||
5 | Set the global to match the documented CPU clock speed of these boards. | ||
6 | Judging by the data sheet this is slightly simplistic because the | ||
7 | SoC allows configuration of the SYSCLK source and frequency via the | ||
8 | RCC (reset and clock control) module, but we don't model that. | ||
9 | |||
10 | Fixes: https://bugs.launchpad.net/qemu/+bug/1876187 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | Message-id: 20200727162617.26227-1-peter.maydell@linaro.org | ||
14 | --- | ||
15 | hw/arm/netduino2.c | 10 ++++++++++ | ||
16 | hw/arm/netduinoplus2.c | 10 ++++++++++ | ||
17 | 2 files changed, 20 insertions(+) | ||
18 | |||
19 | diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/arm/netduino2.c | ||
22 | +++ b/hw/arm/netduino2.c | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | #include "hw/arm/stm32f205_soc.h" | ||
25 | #include "hw/arm/boot.h" | ||
26 | |||
27 | +/* Main SYSCLK frequency in Hz (120MHz) */ | ||
28 | +#define SYSCLK_FRQ 120000000ULL | ||
29 | + | ||
30 | static void netduino2_init(MachineState *machine) | ||
31 | { | ||
32 | DeviceState *dev; | ||
33 | |||
34 | + /* | ||
35 | + * TODO: ideally we would model the SoC RCC and let it handle | ||
36 | + * system_clock_scale, including its ability to define different | ||
37 | + * possible SYSCLK sources. | ||
38 | + */ | ||
39 | + system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | ||
40 | + | ||
41 | dev = qdev_new(TYPE_STM32F205_SOC); | ||
42 | qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3")); | ||
43 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
44 | diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/arm/netduinoplus2.c | ||
47 | +++ b/hw/arm/netduinoplus2.c | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | #include "hw/arm/stm32f405_soc.h" | ||
50 | #include "hw/arm/boot.h" | ||
51 | |||
52 | +/* Main SYSCLK frequency in Hz (168MHz) */ | ||
53 | +#define SYSCLK_FRQ 168000000ULL | ||
54 | + | ||
55 | static void netduinoplus2_init(MachineState *machine) | ||
56 | { | ||
57 | DeviceState *dev; | ||
58 | |||
59 | + /* | ||
60 | + * TODO: ideally we would model the SoC RCC and let it handle | ||
61 | + * system_clock_scale, including its ability to define different | ||
62 | + * possible SYSCLK sources. | ||
63 | + */ | ||
64 | + system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | ||
65 | + | ||
66 | dev = qdev_new(TYPE_STM32F405_SOC); | ||
67 | qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); | ||
68 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
69 | -- | ||
70 | 2.20.1 | ||
71 | |||
72 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Mostly devices don't need to care whether one of their output | ||
2 | qemu_irq lines is connected, because functions like qemu_set_irq() | ||
3 | silently do nothing if there is nothing on the other end. However | ||
4 | sometimes a device might want to implement default behaviour for the | ||
5 | case where the machine hasn't wired the line up to anywhere. | ||
6 | 1 | ||
7 | Provide a function qemu_irq_is_connected() that devices can use for | ||
8 | this purpose. (The test is trivial but encapsulating it in a | ||
9 | function makes it easier to see where we're doing it in case we need | ||
10 | to change the implementation later.) | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
15 | Message-id: 20200728103744.6909-2-peter.maydell@linaro.org | ||
16 | --- | ||
17 | include/hw/irq.h | 18 ++++++++++++++++++ | ||
18 | 1 file changed, 18 insertions(+) | ||
19 | |||
20 | diff --git a/include/hw/irq.h b/include/hw/irq.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/include/hw/irq.h | ||
23 | +++ b/include/hw/irq.h | ||
24 | @@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); | ||
25 | on an existing vector of qemu_irq. */ | ||
26 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n); | ||
27 | |||
28 | +/** | ||
29 | + * qemu_irq_is_connected: Return true if IRQ line is wired up | ||
30 | + * | ||
31 | + * If a qemu_irq has a device on the other (receiving) end of it, | ||
32 | + * return true; otherwise return false. | ||
33 | + * | ||
34 | + * Usually device models don't need to care whether the machine model | ||
35 | + * has wired up their outbound qemu_irq lines, because functions like | ||
36 | + * qemu_set_irq() silently do nothing if there is nothing on the other | ||
37 | + * end of the line. However occasionally a device model will want to | ||
38 | + * provide default behaviour if its output is left floating, and | ||
39 | + * it can use this function to identify when that is the case. | ||
40 | + */ | ||
41 | +static inline bool qemu_irq_is_connected(qemu_irq irq) | ||
42 | +{ | ||
43 | + return irq != NULL; | ||
44 | +} | ||
45 | + | ||
46 | #endif | ||
47 | -- | ||
48 | 2.20.1 | ||
49 | |||
50 | diff view generated by jsdifflib |
1 | The imx_epit device has a software-controllable reset triggered by | 1 | The HSTR_EL2 register allows the hypervisor to trap AArch32 EL1 and |
---|---|---|---|
2 | setting the SWR bit in the CR register. An error in commit cc2722ec83ad9 | 2 | EL0 accesses to cp15 registers. We incorrectly implemented this so |
3 | means that we will end up assert()ing if the guest does this, because | 3 | they trap to EL1 when we detect the need for a HSTR trap at code |
4 | the code in imx_epit_write() starts ptimer transactions, and then | 4 | generation time. (The check in access_check_cp_reg() which we do at |
5 | imx_epit_reset() also starts ptimer transactions, triggering | 5 | runtime to catch traps from EL0 is correctly routing them to EL2.) |
6 | "ptimer_transaction_begin: Assertion `!s->in_transaction' failed". | ||
7 | 6 | ||
8 | The cleanest way to avoid this double-transaction is to move the | 7 | Use the correct target EL when generating the code to take the trap. |
9 | start-transaction for the CR write handling down below the check of | ||
10 | the SWR bit. | ||
11 | 8 | ||
12 | Fixes: https://bugs.launchpad.net/qemu/+bug/1880424 | 9 | Cc: qemu-stable@nongnu.org |
13 | Fixes: cc2722ec83ad944505fe | 10 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2226 |
11 | Fixes: 049edada5e93df ("target/arm: Make HSTR_EL2 traps take priority over UNDEF-at-EL1") | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
16 | Message-id: 20200727154550.3409-1-peter.maydell@linaro.org | 14 | Message-id: 20240325133116.2075362-1-peter.maydell@linaro.org |
17 | --- | 15 | --- |
18 | hw/timer/imx_epit.c | 13 ++++++++++--- | 16 | target/arm/tcg/translate.c | 2 +- |
19 | 1 file changed, 10 insertions(+), 3 deletions(-) | 17 | 1 file changed, 1 insertion(+), 1 deletion(-) |
20 | 18 | ||
21 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c | 19 | diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c |
22 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/timer/imx_epit.c | 21 | --- a/target/arm/tcg/translate.c |
24 | +++ b/hw/timer/imx_epit.c | 22 | +++ b/target/arm/tcg/translate.c |
25 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | 23 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
26 | 24 | tcg_gen_andi_i32(t, t, 1u << maskbit); | |
27 | switch (offset >> 2) { | 25 | tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, over.label); |
28 | case 0: /* CR */ | 26 | |
29 | - ptimer_transaction_begin(s->timer_cmp); | 27 | - gen_exception_insn(s, 0, EXCP_UDEF, syndrome); |
30 | - ptimer_transaction_begin(s->timer_reload); | 28 | + gen_exception_insn_el(s, 0, EXCP_UDEF, syndrome, 2); |
31 | 29 | /* | |
32 | oldcr = s->cr; | 30 | * gen_exception_insn() will set is_jmp to DISAS_NORETURN, |
33 | s->cr = value & 0x03ffffff; | 31 | * but since we're conditionally branching over it, we want |
34 | if (s->cr & CR_SWR) { | ||
35 | /* handle the reset */ | ||
36 | imx_epit_reset(DEVICE(s)); | ||
37 | - } else { | ||
38 | + /* | ||
39 | + * TODO: could we 'break' here? following operations appear | ||
40 | + * to duplicate the work imx_epit_reset() already did. | ||
41 | + */ | ||
42 | + } | ||
43 | + | ||
44 | + ptimer_transaction_begin(s->timer_cmp); | ||
45 | + ptimer_transaction_begin(s->timer_reload); | ||
46 | + | ||
47 | + if (!(s->cr & CR_SWR)) { | ||
48 | imx_epit_set_freq(s); | ||
49 | } | ||
50 | |||
51 | -- | 32 | -- |
52 | 2.20.1 | 33 | 2.34.1 |
53 | |||
54 | diff view generated by jsdifflib |
1 | From: Kaige Li <likaige@loongson.cn> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | GCC version 4.9.4 isn't clever enough to figure out that all | 3 | Hardware of sbsa-ref board is nowadays defined by both BSA and SBSA |
4 | execution paths in disas_ldst() that use 'fn' will have initialized | 4 | specifications. Then BBR defines firmware interface. |
5 | it first, and so it warns: | ||
6 | 5 | ||
7 | /home/LiKaige/qemu/target/arm/translate-a64.c: In function ‘disas_ldst’: | 6 | Added note about DeviceTree data passed from QEMU to firmware. It is |
8 | /home/LiKaige/qemu/target/arm/translate-a64.c:3392:5: error: ‘fn’ may be used uninitialized in this function [-Werror=maybe-uninitialized] | 7 | very minimal and provides only data we use in firmware. |
9 | fn(cpu_reg(s, rt), clean_addr, tcg_rs, get_mem_index(s), | ||
10 | ^ | ||
11 | /home/LiKaige/qemu/target/arm/translate-a64.c:3318:22: note: ‘fn’ was declared here | ||
12 | AtomicThreeOpFn *fn; | ||
13 | ^ | ||
14 | 8 | ||
15 | Make it happy by initializing the variable to NULL. | 9 | Added NUMA information to list of things reported by DeviceTree. |
16 | 10 | ||
17 | Signed-off-by: Kaige Li <likaige@loongson.cn> | 11 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
18 | Message-id: 1596110248-7366-2-git-send-email-likaige@loongson.cn | 12 | Message-id: 20240328163851.1386176-1-marcin.juszkiewicz@linaro.org |
19 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com> |
20 | [PMM: Clean up commit message and note which gcc version this was] | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 15 | --- |
23 | target/arm/translate-a64.c | 2 +- | 16 | docs/system/arm/sbsa.rst | 35 ++++++++++++++++++++++++++--------- |
24 | 1 file changed, 1 insertion(+), 1 deletion(-) | 17 | 1 file changed, 26 insertions(+), 9 deletions(-) |
25 | 18 | ||
26 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 19 | diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst |
27 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/translate-a64.c | 21 | --- a/docs/system/arm/sbsa.rst |
29 | +++ b/target/arm/translate-a64.c | 22 | +++ b/docs/system/arm/sbsa.rst |
30 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | 23 | @@ -XXX,XX +XXX,XX @@ |
31 | bool r = extract32(insn, 22, 1); | 24 | Arm Server Base System Architecture Reference board (``sbsa-ref``) |
32 | bool a = extract32(insn, 23, 1); | 25 | ================================================================== |
33 | TCGv_i64 tcg_rs, clean_addr; | 26 | |
34 | - AtomicThreeOpFn *fn; | 27 | -While the ``virt`` board is a generic board platform that doesn't match |
35 | + AtomicThreeOpFn *fn = NULL; | 28 | -any real hardware the ``sbsa-ref`` board intends to look like real |
36 | 29 | -hardware. The `Server Base System Architecture | |
37 | if (is_vector || !dc_isar_feature(aa64_atomics, s)) { | 30 | -<https://developer.arm.com/documentation/den0029/latest>`_ defines a |
38 | unallocated_encoding(s); | 31 | -minimum base line of hardware support and importantly how the firmware |
32 | -reports that to any operating system. | ||
33 | +The ``sbsa-ref`` board intends to look like real hardware (while the ``virt`` | ||
34 | +board is a generic board platform that doesn't match any real hardware). | ||
35 | + | ||
36 | +The hardware part is defined by two specifications: | ||
37 | + | ||
38 | + - `Base System Architecture <https://developer.arm.com/documentation/den0094/>`__ (BSA) | ||
39 | + - `Server Base System Architecture <https://developer.arm.com/documentation/den0029/>`__ (SBSA) | ||
40 | + | ||
41 | +The `Arm Base Boot Requirements <https://developer.arm.com/documentation/den0044/>`__ (BBR) | ||
42 | +specification defines how the firmware reports that to any operating system. | ||
43 | |||
44 | It is intended to be a machine for developing firmware and testing | ||
45 | standards compliance with operating systems. | ||
46 | @@ -XXX,XX +XXX,XX @@ includes both internal hardware and parts affected by the qemu command line | ||
47 | (i.e. CPUs and memory). As a result it must have a firmware specifically built | ||
48 | to expect a certain hardware layout (as you would in a real machine). | ||
49 | |||
50 | +Note | ||
51 | +'''' | ||
52 | + | ||
53 | +QEMU provides the guest EL3 firmware with minimal information about hardware | ||
54 | +platform using minimalistic devicetree. This is not a Linux devicetree. It is | ||
55 | +not even a firmware devicetree. | ||
56 | + | ||
57 | +It is information passed from QEMU to describe the information a hardware | ||
58 | +platform would have other mechanisms to discover at runtime, that are affected | ||
59 | +by the QEMU command line. | ||
60 | + | ||
61 | +Ultimately this devicetree may be replaced by IPC calls to an emulated SCP. | ||
62 | + | ||
63 | DeviceTree information | ||
64 | '''''''''''''''''''''' | ||
65 | |||
66 | -The devicetree provided by the board model to the firmware is not intended | ||
67 | -to be a complete compliant DT. It currently reports: | ||
68 | +The devicetree reports: | ||
69 | |||
70 | - CPUs | ||
71 | - memory | ||
72 | - platform version | ||
73 | - GIC addresses | ||
74 | + - NUMA node id for CPUs and memory | ||
75 | |||
76 | Platform version | ||
77 | '''''''''''''''' | ||
78 | @@ -XXX,XX +XXX,XX @@ Platform version changes: | ||
79 | GIC ITS information is present in devicetree. | ||
80 | |||
81 | 0.3 | ||
82 | - The USB controller is an XHCI device, not EHCI | ||
83 | + The USB controller is an XHCI device, not EHCI. | ||
39 | -- | 84 | -- |
40 | 2.20.1 | 85 | 2.34.1 |
41 | |||
42 | diff view generated by jsdifflib |
1 | The nrf51 SoC model wasn't setting the system_clock_scale | 1 | If the group of the highest priority pending interrupt is disabled |
---|---|---|---|
2 | global.which meant that if guest code used the systick timer in "use | 2 | via ICC_IGRPEN*, the ICC_HPPIR* registers should return |
3 | the processor clock" mode it would hang because time never advances. | 3 | INTID_SPURIOUS, not the interrupt ID. (See the GIC architecture |
4 | specification pseudocode functions ICC_HPPIR1_EL1[] and | ||
5 | HighestPriorityPendingInterrupt().) | ||
4 | 6 | ||
5 | Set the global to match the documented CPU clock speed for this SoC. | 7 | Make HPPIR reads honour the group disable, the way we already do |
8 | when determining whether to preempt in icc_hppi_can_preempt(). | ||
6 | 9 | ||
7 | This SoC in fact doesn't have a SysTick timer (which is the only thing | 10 | Cc: qemu-stable@nongnu.org |
8 | currently that cares about the system_clock_scale), because it's | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | a configurable option in the Cortex-M0. However our Cortex-M0 and | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | thus our nrf51 and our micro:bit board do provide a SysTick, so | 13 | Message-id: 20240328153333.2522667-1-peter.maydell@linaro.org |
11 | we ought to provide a functional one rather than a broken one. | 14 | --- |
15 | hw/intc/arm_gicv3_cpuif.c | 4 ++-- | ||
16 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
12 | 17 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 20200727193458.31250-1-peter.maydell@linaro.org | ||
16 | --- | ||
17 | hw/arm/nrf51_soc.c | 5 +++++ | ||
18 | 1 file changed, 5 insertions(+) | ||
19 | |||
20 | diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/nrf51_soc.c | 20 | --- a/hw/intc/arm_gicv3_cpuif.c |
23 | +++ b/hw/arm/nrf51_soc.c | 21 | +++ b/hw/intc/arm_gicv3_cpuif.c |
24 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ static uint64_t icc_hppir0_value(GICv3CPUState *cs, CPUARMState *env) |
25 | 23 | */ | |
26 | #define BASE_TO_IRQ(base) ((base >> 12) & 0x1F) | 24 | bool irq_is_secure; |
27 | 25 | ||
28 | +/* HCLK (the main CPU clock) on this SoC is always 16MHz */ | 26 | - if (cs->hppi.prio == 0xff) { |
29 | +#define HCLK_FRQ 16000000 | 27 | + if (icc_no_enabled_hppi(cs)) { |
30 | + | 28 | return INTID_SPURIOUS; |
31 | static uint64_t clock_read(void *opaque, hwaddr addr, unsigned int size) | ||
32 | { | ||
33 | qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n", | ||
34 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | ||
35 | return; | ||
36 | } | 29 | } |
37 | 30 | ||
38 | + system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ; | 31 | @@ -XXX,XX +XXX,XX @@ static uint64_t icc_hppir1_value(GICv3CPUState *cs, CPUARMState *env) |
39 | + | 32 | */ |
40 | object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container), | 33 | bool irq_is_secure; |
41 | &error_abort); | 34 | |
42 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) { | 35 | - if (cs->hppi.prio == 0xff) { |
36 | + if (icc_no_enabled_hppi(cs)) { | ||
37 | return INTID_SPURIOUS; | ||
38 | } | ||
39 | |||
43 | -- | 40 | -- |
44 | 2.20.1 | 41 | 2.34.1 |
45 | |||
46 | diff view generated by jsdifflib |
1 | The NVIC provides an outbound qemu_irq "SYSRESETREQ" which it signals | 1 | From: Cédric Le Goater <clg@redhat.com> |
---|---|---|---|
2 | when the guest sets the SYSRESETREQ bit in the AIRCR register. This | ||
3 | matches the hardware design (where the CPU has a signal of this name | ||
4 | and it is up to the SoC to connect that up to an actual reset | ||
5 | mechanism), but in QEMU it mostly results in duplicated code in SoC | ||
6 | objects and bugs where SoC model implementors forget to wire up the | ||
7 | SYSRESETREQ line. | ||
8 | 2 | ||
9 | Provide a default behaviour for the case where SYSRESETREQ is not | 3 | The test mangles the GPIO address and the pin number in the |
10 | actually connected to anything: use qemu_system_reset_request() to | 4 | qtest_add_data_func data parameter. Doing so, it assumes that the host |
11 | perform a system reset. This will allow us to remove the | 5 | pointer size is always 64-bit, which breaks on 32-bit : |
12 | implementations of SYSRESETREQ handling from the boards where that's | ||
13 | exactly what it does, and also fixes the bugs in the board models | ||
14 | which forgot to wire up the signal: | ||
15 | 6 | ||
16 | * microbit | 7 | ../tests/qtest/stm32l4x5_gpio-test.c: In function ‘test_gpio_output_mode’: |
17 | * mps2-an385 | 8 | ../tests/qtest/stm32l4x5_gpio-test.c:272:25: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] |
18 | * mps2-an505 | 9 | 272 | unsigned int pin = ((uint64_t)data) & 0xF; |
19 | * mps2-an511 | 10 | | ^ |
20 | * mps2-an521 | 11 | ../tests/qtest/stm32l4x5_gpio-test.c:273:22: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] |
21 | * musca-a | 12 | 273 | uint32_t gpio = ((uint64_t)data) >> 32; |
22 | * musca-b1 | 13 | | ^ |
23 | * netduino | ||
24 | * netduinoplus2 | ||
25 | 14 | ||
26 | We still allow the board to wire up the signal if it needs to, in case | 15 | To fix, improve the mangling of the GPIO address and pin number fields |
27 | we need to model more complicated reset controller logic or to model | 16 | by using GPIO_SIZE so that the resulting value fits in a 32-bit pointer. |
28 | buggy SoC hardware which forgot to wire up the line itself. But | 17 | While at it, include some helpers to hide the details. |
29 | defaulting to "reset the system" is more often going to be correct | ||
30 | than defaulting to "do nothing". | ||
31 | 18 | ||
19 | Cc: Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
20 | Cc: Inès Varhol <ines.varhol@telecom-paris.fr> | ||
21 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
22 | Message-id: 20240329092747.298259-1-clg@redhat.com | ||
23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
33 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
34 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
35 | Message-id: 20200728103744.6909-3-peter.maydell@linaro.org | ||
36 | --- | 25 | --- |
37 | include/hw/arm/armv7m.h | 4 +++- | 26 | tests/qtest/stm32l4x5_gpio-test.c | 59 ++++++++++++++++++------------- |
38 | hw/intc/armv7m_nvic.c | 17 ++++++++++++++++- | 27 | 1 file changed, 35 insertions(+), 24 deletions(-) |
39 | 2 files changed, 19 insertions(+), 2 deletions(-) | ||
40 | 28 | ||
41 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h | 29 | diff --git a/tests/qtest/stm32l4x5_gpio-test.c b/tests/qtest/stm32l4x5_gpio-test.c |
42 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/include/hw/arm/armv7m.h | 31 | --- a/tests/qtest/stm32l4x5_gpio-test.c |
44 | +++ b/include/hw/arm/armv7m.h | 32 | +++ b/tests/qtest/stm32l4x5_gpio-test.c |
45 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 33 | @@ -XXX,XX +XXX,XX @@ const uint32_t idr_reset[NUM_GPIOS] = { |
46 | 34 | 0x00000000 | |
47 | /* ARMv7M container object. | ||
48 | * + Unnamed GPIO input lines: external IRQ lines for the NVIC | ||
49 | - * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ | ||
50 | + * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ. | ||
51 | + * If this GPIO is not wired up then the NVIC will default to performing | ||
52 | + * a qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET). | ||
53 | * + Property "cpu-type": CPU type to instantiate | ||
54 | * + Property "num-irq": number of external IRQ lines | ||
55 | * + Property "memory": MemoryRegion defining the physical address space | ||
56 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/hw/intc/armv7m_nvic.c | ||
59 | +++ b/hw/intc/armv7m_nvic.c | ||
60 | @@ -XXX,XX +XXX,XX @@ | ||
61 | #include "hw/intc/armv7m_nvic.h" | ||
62 | #include "hw/irq.h" | ||
63 | #include "hw/qdev-properties.h" | ||
64 | +#include "sysemu/runstate.h" | ||
65 | #include "target/arm/cpu.h" | ||
66 | #include "exec/exec-all.h" | ||
67 | #include "exec/memop.h" | ||
68 | @@ -XXX,XX +XXX,XX @@ static const uint8_t nvic_id[] = { | ||
69 | 0x00, 0xb0, 0x1b, 0x00, 0x0d, 0xe0, 0x05, 0xb1 | ||
70 | }; | 35 | }; |
71 | 36 | ||
72 | +static void signal_sysresetreq(NVICState *s) | 37 | +#define PIN_MASK 0xF |
38 | +#define GPIO_ADDR_MASK (~(GPIO_SIZE - 1)) | ||
39 | + | ||
40 | +static inline void *test_data(uint32_t gpio_addr, uint8_t pin) | ||
73 | +{ | 41 | +{ |
74 | + if (qemu_irq_is_connected(s->sysresetreq)) { | 42 | + return (void *)(uintptr_t)((gpio_addr & GPIO_ADDR_MASK) | (pin & PIN_MASK)); |
75 | + qemu_irq_pulse(s->sysresetreq); | ||
76 | + } else { | ||
77 | + /* | ||
78 | + * Default behaviour if the SoC doesn't need to wire up | ||
79 | + * SYSRESETREQ (eg to a system reset controller of some kind): | ||
80 | + * perform a system reset via the usual QEMU API. | ||
81 | + */ | ||
82 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
83 | + } | ||
84 | +} | 43 | +} |
85 | + | 44 | + |
86 | static int nvic_pending_prio(NVICState *s) | 45 | +#define test_gpio_addr(data) ((uintptr_t)(data) & GPIO_ADDR_MASK) |
46 | +#define test_pin(data) ((uintptr_t)(data) & PIN_MASK) | ||
47 | + | ||
48 | static uint32_t gpio_readl(unsigned int gpio, unsigned int offset) | ||
87 | { | 49 | { |
88 | /* return the group priority of the current pending interrupt, | 50 | return readl(gpio + offset); |
89 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | 51 | @@ -XXX,XX +XXX,XX @@ static void test_gpio_output_mode(const void *data) |
90 | if (value & R_V7M_AIRCR_SYSRESETREQ_MASK) { | 52 | * Additionally, it checks that values written to ODR |
91 | if (attrs.secure || | 53 | * when not in output mode are stored and not discarded. |
92 | !(cpu->env.v7m.aircr & R_V7M_AIRCR_SYSRESETREQS_MASK)) { | 54 | */ |
93 | - qemu_irq_pulse(s->sysresetreq); | 55 | - unsigned int pin = ((uint64_t)data) & 0xF; |
94 | + signal_sysresetreq(s); | 56 | - uint32_t gpio = ((uint64_t)data) >> 32; |
95 | } | 57 | + unsigned int pin = test_pin(data); |
96 | } | 58 | + uint32_t gpio = test_gpio_addr(data); |
97 | if (value & R_V7M_AIRCR_VECTCLRACTIVE_MASK) { | 59 | unsigned int gpio_id = get_gpio_id(gpio); |
60 | |||
61 | qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
62 | @@ -XXX,XX +XXX,XX @@ static void test_gpio_input_mode(const void *data) | ||
63 | * corresponding GPIO line high/low : it should set the | ||
64 | * right bit in IDR and send an irq to syscfg. | ||
65 | */ | ||
66 | - unsigned int pin = ((uint64_t)data) & 0xF; | ||
67 | - uint32_t gpio = ((uint64_t)data) >> 32; | ||
68 | + unsigned int pin = test_pin(data); | ||
69 | + uint32_t gpio = test_gpio_addr(data); | ||
70 | unsigned int gpio_id = get_gpio_id(gpio); | ||
71 | |||
72 | qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
73 | @@ -XXX,XX +XXX,XX @@ static void test_pull_up_pull_down(const void *data) | ||
74 | * Test that a floating pin with pull-up sets the pin | ||
75 | * high and vice-versa. | ||
76 | */ | ||
77 | - unsigned int pin = ((uint64_t)data) & 0xF; | ||
78 | - uint32_t gpio = ((uint64_t)data) >> 32; | ||
79 | + unsigned int pin = test_pin(data); | ||
80 | + uint32_t gpio = test_gpio_addr(data); | ||
81 | unsigned int gpio_id = get_gpio_id(gpio); | ||
82 | |||
83 | qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
84 | @@ -XXX,XX +XXX,XX @@ static void test_push_pull(const void *data) | ||
85 | * disconnects the pin, that the pin can't be set or reset | ||
86 | * externally afterwards. | ||
87 | */ | ||
88 | - unsigned int pin = ((uint64_t)data) & 0xF; | ||
89 | - uint32_t gpio = ((uint64_t)data) >> 32; | ||
90 | + unsigned int pin = test_pin(data); | ||
91 | + uint32_t gpio = test_gpio_addr(data); | ||
92 | uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
93 | |||
94 | qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
95 | @@ -XXX,XX +XXX,XX @@ static void test_open_drain(const void *data) | ||
96 | * However a pin set low externally shouldn't be disconnected, | ||
97 | * and it can be set low externally when in open-drain mode. | ||
98 | */ | ||
99 | - unsigned int pin = ((uint64_t)data) & 0xF; | ||
100 | - uint32_t gpio = ((uint64_t)data) >> 32; | ||
101 | + unsigned int pin = test_pin(data); | ||
102 | + uint32_t gpio = test_gpio_addr(data); | ||
103 | uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
104 | |||
105 | qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
106 | @@ -XXX,XX +XXX,XX @@ static void test_bsrr_brr(const void *data) | ||
107 | * has the desired effect on ODR. | ||
108 | * In BSRR, BSx has priority over BRx. | ||
109 | */ | ||
110 | - unsigned int pin = ((uint64_t)data) & 0xF; | ||
111 | - uint32_t gpio = ((uint64_t)data) >> 32; | ||
112 | + unsigned int pin = test_pin(data); | ||
113 | + uint32_t gpio = test_gpio_addr(data); | ||
114 | |||
115 | gpio_writel(gpio, BSRR, (1 << pin)); | ||
116 | g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
117 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
118 | * is problematic since the pin was already high. | ||
119 | */ | ||
120 | qtest_add_data_func("stm32l4x5/gpio/test_gpioc5_output_mode", | ||
121 | - (void *)((uint64_t)GPIO_C << 32 | 5), | ||
122 | + test_data(GPIO_C, 5), | ||
123 | test_gpio_output_mode); | ||
124 | qtest_add_data_func("stm32l4x5/gpio/test_gpioh3_output_mode", | ||
125 | - (void *)((uint64_t)GPIO_H << 32 | 3), | ||
126 | + test_data(GPIO_H, 3), | ||
127 | test_gpio_output_mode); | ||
128 | qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode1", | ||
129 | - (void *)((uint64_t)GPIO_D << 32 | 6), | ||
130 | + test_data(GPIO_D, 6), | ||
131 | test_gpio_input_mode); | ||
132 | qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode2", | ||
133 | - (void *)((uint64_t)GPIO_C << 32 | 10), | ||
134 | + test_data(GPIO_C, 10), | ||
135 | test_gpio_input_mode); | ||
136 | qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down1", | ||
137 | - (void *)((uint64_t)GPIO_B << 32 | 5), | ||
138 | + test_data(GPIO_B, 5), | ||
139 | test_pull_up_pull_down); | ||
140 | qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down2", | ||
141 | - (void *)((uint64_t)GPIO_F << 32 | 1), | ||
142 | + test_data(GPIO_F, 1), | ||
143 | test_pull_up_pull_down); | ||
144 | qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull1", | ||
145 | - (void *)((uint64_t)GPIO_G << 32 | 6), | ||
146 | + test_data(GPIO_G, 6), | ||
147 | test_push_pull); | ||
148 | qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull2", | ||
149 | - (void *)((uint64_t)GPIO_H << 32 | 3), | ||
150 | + test_data(GPIO_H, 3), | ||
151 | test_push_pull); | ||
152 | qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain1", | ||
153 | - (void *)((uint64_t)GPIO_C << 32 | 4), | ||
154 | + test_data(GPIO_C, 4), | ||
155 | test_open_drain); | ||
156 | qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain2", | ||
157 | - (void *)((uint64_t)GPIO_E << 32 | 11), | ||
158 | + test_data(GPIO_E, 11), | ||
159 | test_open_drain); | ||
160 | qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr1", | ||
161 | - (void *)((uint64_t)GPIO_A << 32 | 12), | ||
162 | + test_data(GPIO_A, 12), | ||
163 | test_bsrr_brr); | ||
164 | qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr2", | ||
165 | - (void *)((uint64_t)GPIO_D << 32 | 0), | ||
166 | + test_data(GPIO_D, 0), | ||
167 | test_bsrr_brr); | ||
168 | |||
169 | qtest_start("-machine b-l475e-iot01a"); | ||
98 | -- | 170 | -- |
99 | 2.20.1 | 171 | 2.34.1 |
100 | 172 | ||
101 | 173 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The MSF2 SoC model and the Stellaris board code both wire | ||
2 | SYSRESETREQ up to a function that just invokes | ||
3 | qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
4 | This is now the default action that the NVIC does if the line is | ||
5 | not connected, so we can delete the handling code. | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Message-id: 20200728103744.6909-4-peter.maydell@linaro.org | ||
11 | --- | ||
12 | hw/arm/msf2-soc.c | 11 ----------- | ||
13 | hw/arm/stellaris.c | 12 ------------ | ||
14 | 2 files changed, 23 deletions(-) | ||
15 | |||
16 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/arm/msf2-soc.c | ||
19 | +++ b/hw/arm/msf2-soc.c | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #include "hw/irq.h" | ||
22 | #include "hw/arm/msf2-soc.h" | ||
23 | #include "hw/misc/unimp.h" | ||
24 | -#include "sysemu/runstate.h" | ||
25 | #include "sysemu/sysemu.h" | ||
26 | |||
27 | #define MSF2_TIMER_BASE 0x40004000 | ||
28 | @@ -XXX,XX +XXX,XX @@ static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 }; | ||
29 | static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 }; | ||
30 | static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 }; | ||
31 | |||
32 | -static void do_sys_reset(void *opaque, int n, int level) | ||
33 | -{ | ||
34 | - if (level) { | ||
35 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
36 | - } | ||
37 | -} | ||
38 | - | ||
39 | static void m2sxxx_soc_initfn(Object *obj) | ||
40 | { | ||
41 | MSF2State *s = MSF2_SOC(obj); | ||
42 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | ||
43 | return; | ||
44 | } | ||
45 | |||
46 | - qdev_connect_gpio_out_named(DEVICE(&s->armv7m.nvic), "SYSRESETREQ", 0, | ||
47 | - qemu_allocate_irq(&do_sys_reset, NULL, 0)); | ||
48 | - | ||
49 | system_clock_scale = NANOSECONDS_PER_SECOND / s->m3clk; | ||
50 | |||
51 | for (i = 0; i < MSF2_NUM_UARTS; i++) { | ||
52 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/hw/arm/stellaris.c | ||
55 | +++ b/hw/arm/stellaris.c | ||
56 | @@ -XXX,XX +XXX,XX @@ | ||
57 | #include "hw/boards.h" | ||
58 | #include "qemu/log.h" | ||
59 | #include "exec/address-spaces.h" | ||
60 | -#include "sysemu/runstate.h" | ||
61 | #include "sysemu/sysemu.h" | ||
62 | #include "hw/arm/armv7m.h" | ||
63 | #include "hw/char/pl011.h" | ||
64 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_init(Object *obj) | ||
65 | qdev_init_gpio_in(dev, stellaris_adc_trigger, 1); | ||
66 | } | ||
67 | |||
68 | -static | ||
69 | -void do_sys_reset(void *opaque, int n, int level) | ||
70 | -{ | ||
71 | - if (level) { | ||
72 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
73 | - } | ||
74 | -} | ||
75 | - | ||
76 | /* Board init. */ | ||
77 | static stellaris_board_info stellaris_boards[] = { | ||
78 | { "LM3S811EVB", | ||
79 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
80 | /* This will exit with an error if the user passed us a bad cpu_type */ | ||
81 | sysbus_realize_and_unref(SYS_BUS_DEVICE(nvic), &error_fatal); | ||
82 | |||
83 | - qdev_connect_gpio_out_named(nvic, "SYSRESETREQ", 0, | ||
84 | - qemu_allocate_irq(&do_sys_reset, NULL, 0)); | ||
85 | - | ||
86 | if (board->dc1 & (1 << 16)) { | ||
87 | dev = sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000, | ||
88 | qdev_get_gpio_in(nvic, 14), | ||
89 | -- | ||
90 | 2.20.1 | ||
91 | |||
92 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | The definition of top_bit used in this function is one higher | 3 | Change the board revision number and RAM size to 1Gb on 32-bit hosts. |
4 | than that used in the Arm ARM psuedo-code, which put the error | 4 | On these systems, RAM has a 2047 MB limit and this breaks the tests. |
5 | indication at top_bit - 1 at the wrong place, which meant that | ||
6 | it wasn't visible to Auth. | ||
7 | 5 | ||
8 | Fixing the definition of top_bit requires more changes, because | 6 | Fixes: 7785e8ea2204 ("hw/arm: Introduce Raspberry PI 4 machine") |
9 | its most common use is for the count of bits in top_bit:bot_bit, | 7 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
10 | which would then need to be computed as top_bit - bot_bit + 1. | 8 | Message-id: 20240329150155.357043-1-clg@redhat.com |
11 | |||
12 | For now, prefer the minimal fix to the error indication alone. | ||
13 | |||
14 | Fixes: 63ff0ca94cb | ||
15 | Reported-by: Derrick McKee <derrick.mckee@gmail.com> | ||
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20200728195706.11087-1-richard.henderson@linaro.org | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
19 | [PMM: added comment about the divergence from the pseudocode] | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 11 | --- |
22 | target/arm/pauth_helper.c | 6 +++++- | 12 | hw/arm/raspi4b.c | 4 ++++ |
23 | tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++ | 13 | 1 file changed, 4 insertions(+) |
24 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
25 | 3 files changed, 39 insertions(+), 2 deletions(-) | ||
26 | create mode 100644 tests/tcg/aarch64/pauth-5.c | ||
27 | 14 | ||
28 | diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c | 15 | diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c |
29 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/pauth_helper.c | 17 | --- a/hw/arm/raspi4b.c |
31 | +++ b/target/arm/pauth_helper.c | 18 | +++ b/hw/arm/raspi4b.c |
32 | @@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, | 19 | @@ -XXX,XX +XXX,XX @@ static void raspi4b_machine_class_init(ObjectClass *oc, void *data) |
33 | */ | 20 | MachineClass *mc = MACHINE_CLASS(oc); |
34 | test = sextract64(ptr, bot_bit, top_bit - bot_bit); | 21 | RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc); |
35 | if (test != 0 && test != -1) { | 22 | |
36 | - pac ^= MAKE_64BIT_MASK(top_bit - 1, 1); | 23 | +#if HOST_LONG_BITS == 32 |
37 | + /* | 24 | + rmc->board_rev = 0xa03111; /* Revision 1.1, 1 Gb RAM */ |
38 | + * Note that our top_bit is one greater than the pseudocode's | 25 | +#else |
39 | + * version, hence "- 2" here. | 26 | rmc->board_rev = 0xb03115; /* Revision 1.5, 2 Gb RAM */ |
40 | + */ | 27 | +#endif |
41 | + pac ^= MAKE_64BIT_MASK(top_bit - 2, 1); | 28 | raspi_machine_class_common_init(mc, rmc->board_rev); |
42 | } | 29 | mc->init = raspi4b_machine_init; |
43 | 30 | } | |
44 | /* | ||
45 | diff --git a/tests/tcg/aarch64/pauth-5.c b/tests/tcg/aarch64/pauth-5.c | ||
46 | new file mode 100644 | ||
47 | index XXXXXXX..XXXXXXX | ||
48 | --- /dev/null | ||
49 | +++ b/tests/tcg/aarch64/pauth-5.c | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | +#include <assert.h> | ||
52 | + | ||
53 | +static int x; | ||
54 | + | ||
55 | +int main() | ||
56 | +{ | ||
57 | + int *p0 = &x, *p1, *p2, *p3; | ||
58 | + unsigned long salt = 0; | ||
59 | + | ||
60 | + /* | ||
61 | + * With TBI enabled and a 48-bit VA, there are 7 bits of auth, and so | ||
62 | + * a 1/128 chance of auth = pac(ptr,key,salt) producing zero. | ||
63 | + * Find a salt that creates auth != 0. | ||
64 | + */ | ||
65 | + do { | ||
66 | + salt++; | ||
67 | + asm("pacda %0, %1" : "=r"(p1) : "r"(salt), "0"(p0)); | ||
68 | + } while (p0 == p1); | ||
69 | + | ||
70 | + /* | ||
71 | + * This pac must fail, because the input pointer bears an encryption, | ||
72 | + * and so is not properly extended within bits [55:47]. This will | ||
73 | + * toggle bit 54 in the output... | ||
74 | + */ | ||
75 | + asm("pacda %0, %1" : "=r"(p2) : "r"(salt), "0"(p1)); | ||
76 | + | ||
77 | + /* ... so that the aut must fail, setting bit 53 in the output ... */ | ||
78 | + asm("autda %0, %1" : "=r"(p3) : "r"(salt), "0"(p2)); | ||
79 | + | ||
80 | + /* ... which means this equality must not hold. */ | ||
81 | + assert(p3 != p0); | ||
82 | + return 0; | ||
83 | +} | ||
84 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/tests/tcg/aarch64/Makefile.target | ||
87 | +++ b/tests/tcg/aarch64/Makefile.target | ||
88 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | ||
89 | |||
90 | # Pauth Tests | ||
91 | ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_3),) | ||
92 | -AARCH64_TESTS += pauth-1 pauth-2 pauth-4 | ||
93 | +AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5 | ||
94 | pauth-%: CFLAGS += -march=armv8.3-a | ||
95 | run-pauth-%: QEMU_OPTS += -cpu max | ||
96 | run-plugin-pauth-%: QEMU_OPTS += -cpu max | ||
97 | -- | 31 | -- |
98 | 2.20.1 | 32 | 2.34.1 |
99 | 33 | ||
100 | 34 | diff view generated by jsdifflib |