1 | Handful of bugfixes for rc2. None of these are particularly critical | 1 | Mostly just bug fixes. The important one here is |
---|---|---|---|
2 | or exciting. | 2 | hw/intc/arm_gic: Fix interrupt ID in GICD_SGIR register |
3 | which fixes a buffer overrun that's a security issue if you're running | ||
4 | KVM on Arm with kernel-irqchip=off (which hopefully nobody is doing in | ||
5 | a security context, because kernel-irqchip=on is the default and the | ||
6 | sensible choice for performance). | ||
3 | 7 | ||
4 | -- PMM | 8 | -- PMM |
5 | 9 | ||
6 | The following changes since commit 45a150aa2b3492acf6691c7bdbeb25a8545d8345: | 10 | The following changes since commit cf7ca7d5b9faca13f1f8e3ea92cfb2f741eb0c0e: |
7 | 11 | ||
8 | Merge remote-tracking branch 'remotes/ericb/tags/pull-bitmaps-2020-08-03' into staging (2020-08-03 15:13:49 +0100) | 12 | Merge remote-tracking branch 'remotes/stefanha-gitlab/tags/tracing-pull-request' into staging (2021-02-01 16:28:00 +0000) |
9 | 13 | ||
10 | are available in the Git repository at: | 14 | are available in the Git repository at: |
11 | 15 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200803 | 16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210202-1 |
13 | 17 | ||
14 | for you to fetch changes up to 13557fd392890cbd985bceba7f717e01efd674b8: | 18 | for you to fetch changes up to 14657850c9cc10948551fbb884c30eb5a3a7370a: |
15 | 19 | ||
16 | hw/timer/imx_epit: Avoid assertion when CR.SWR is written (2020-08-03 17:56:11 +0100) | 20 | hw/arm: Display CPU type in machine description (2021-02-02 17:53:44 +0000) |
17 | 21 | ||
18 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
19 | target-arm queue: | 23 | target-arm queue: |
20 | * hw/timer/imx_epit: Avoid assertion when CR.SWR is written | 24 | * hw/intc/arm_gic: Allow to use QTest without crashing |
21 | * netduino2, netduinoplus2, microbit: set system_clock_scale so that | 25 | * hw/char/exynos4210_uart: Fix buffer size reporting with FIFO disabled |
22 | SysTick running on the CPU clock works | 26 | * hw/char/exynos4210_uart: Fix missing call to report ready for input |
23 | * target/arm: Avoid maybe-uninitialized warning with gcc 4.9 | 27 | * hw/arm/smmuv3: Fix addr_mask for range-based invalidation |
24 | * target/arm: Fix AddPAC error indication | 28 | * hw/ssi/imx_spi: Fix various minor bugs |
25 | * Make AIRCR.SYSRESETREQ actually reset the system for the | 29 | * hw/intc/arm_gic: Fix interrupt ID in GICD_SGIR register |
26 | microbit, mps2-*, musca-*, netduino* boards | 30 | * hw/arm: Add missing Kconfig dependencies |
31 | * hw/arm: Display CPU type in machine description | ||
27 | 32 | ||
28 | ---------------------------------------------------------------- | 33 | ---------------------------------------------------------------- |
29 | Kaige Li (1): | 34 | Bin Meng (5): |
30 | target/arm: Avoid maybe-uninitialized warning with gcc 4.9 | 35 | hw/ssi: imx_spi: Use a macro for number of chip selects supported |
36 | hw/ssi: imx_spi: Remove imx_spi_update_irq() in imx_spi_reset() | ||
37 | hw/ssi: imx_spi: Round up the burst length to be multiple of 8 | ||
38 | hw/ssi: imx_spi: Correct the burst length > 32 bit transfer logic | ||
39 | hw/ssi: imx_spi: Correct tx and rx fifo endianness | ||
31 | 40 | ||
32 | Peter Maydell (6): | 41 | Iris Johnson (2): |
33 | hw/arm/netduino2, netduinoplus2: Set system_clock_scale | 42 | hw/char/exynos4210_uart: Fix buffer size reporting with FIFO disabled |
34 | include/hw/irq.h: New function qemu_irq_is_connected() | 43 | hw/char/exynos4210_uart: Fix missing call to report ready for input |
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 | 44 | ||
40 | Richard Henderson (1): | 45 | Philippe Mathieu-Daudé (12): |
41 | target/arm: Fix AddPAC error indication | 46 | hw/intc/arm_gic: Allow to use QTest without crashing |
47 | hw/ssi: imx_spi: Remove pointless variable initialization | ||
48 | hw/ssi: imx_spi: Rework imx_spi_reset() to keep CONREG register value | ||
49 | hw/ssi: imx_spi: Rework imx_spi_read() to handle block disabled | ||
50 | hw/ssi: imx_spi: Rework imx_spi_write() to handle block disabled | ||
51 | hw/intc/arm_gic: Fix interrupt ID in GICD_SGIR register | ||
52 | hw/arm/stm32f405_soc: Add missing dependency on OR_IRQ | ||
53 | hw/arm/exynos4210: Add missing dependency on OR_IRQ | ||
54 | hw/arm/xlnx-versal: Versal SoC requires ZDMA | ||
55 | hw/arm/xlnx-versal: Versal SoC requires ZynqMP peripherals | ||
56 | hw/net/can: ZynqMP CAN device requires PTIMER | ||
57 | hw/arm: Display CPU type in machine description | ||
42 | 58 | ||
43 | include/hw/arm/armv7m.h | 4 +++- | 59 | Xuzhou Cheng (1): |
44 | include/hw/irq.h | 18 ++++++++++++++++++ | 60 | hw/ssi: imx_spi: Disable chip selects when controller is disabled |
45 | hw/arm/msf2-soc.c | 11 ----------- | ||
46 | hw/arm/netduino2.c | 10 ++++++++++ | ||
47 | hw/arm/netduinoplus2.c | 10 ++++++++++ | ||
48 | hw/arm/nrf51_soc.c | 5 +++++ | ||
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 | 61 | ||
62 | Zenghui Yu (1): | ||
63 | hw/arm/smmuv3: Fix addr_mask for range-based invalidation | ||
64 | |||
65 | include/hw/ssi/imx_spi.h | 5 +- | ||
66 | hw/arm/digic_boards.c | 2 +- | ||
67 | hw/arm/microbit.c | 2 +- | ||
68 | hw/arm/netduino2.c | 2 +- | ||
69 | hw/arm/netduinoplus2.c | 2 +- | ||
70 | hw/arm/orangepi.c | 2 +- | ||
71 | hw/arm/smmuv3.c | 4 +- | ||
72 | hw/arm/stellaris.c | 4 +- | ||
73 | hw/char/exynos4210_uart.c | 7 ++- | ||
74 | hw/intc/arm_gic.c | 5 +- | ||
75 | hw/ssi/imx_spi.c | 153 +++++++++++++++++++++++++++++----------------- | ||
76 | hw/Kconfig | 1 + | ||
77 | hw/arm/Kconfig | 5 ++ | ||
78 | hw/dma/Kconfig | 3 + | ||
79 | hw/dma/meson.build | 2 +- | ||
80 | 15 files changed, 130 insertions(+), 69 deletions(-) | ||
81 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
1 | 2 | ||
3 | Alexander reported an issue in gic_get_current_cpu() using the | ||
4 | fuzzer. Yet another "deref current_cpu with QTest" bug, reproducible | ||
5 | doing: | ||
6 | |||
7 | $ echo readb 0xf03ff000 | qemu-system-arm -M npcm750-evb,accel=qtest -qtest stdio | ||
8 | [I 1611849440.651452] OPENED | ||
9 | [R +0.242498] readb 0xf03ff000 | ||
10 | hw/intc/arm_gic.c:63:29: runtime error: member access within null pointer of type 'CPUState' (aka 'struct CPUState') | ||
11 | SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior hw/intc/arm_gic.c:63:29 in | ||
12 | AddressSanitizer:DEADLYSIGNAL | ||
13 | ================================================================= | ||
14 | ==3719691==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000082a0 (pc 0x5618790ac882 bp 0x7ffca946f4f0 sp 0x7ffca946f4a0 T0) | ||
15 | ==3719691==The signal is caused by a READ memory access. | ||
16 | #0 0x5618790ac882 in gic_get_current_cpu hw/intc/arm_gic.c:63:29 | ||
17 | #1 0x5618790a8901 in gic_dist_readb hw/intc/arm_gic.c:955:11 | ||
18 | #2 0x5618790a7489 in gic_dist_read hw/intc/arm_gic.c:1158:17 | ||
19 | #3 0x56187adc573b in memory_region_read_with_attrs_accessor softmmu/memory.c:464:9 | ||
20 | #4 0x56187ad7903a in access_with_adjusted_size softmmu/memory.c:552:18 | ||
21 | #5 0x56187ad766d6 in memory_region_dispatch_read1 softmmu/memory.c:1426:16 | ||
22 | #6 0x56187ad758a8 in memory_region_dispatch_read softmmu/memory.c:1449:9 | ||
23 | #7 0x56187b09e84c in flatview_read_continue softmmu/physmem.c:2822:23 | ||
24 | #8 0x56187b0a0115 in flatview_read softmmu/physmem.c:2862:12 | ||
25 | #9 0x56187b09fc9e in address_space_read_full softmmu/physmem.c:2875:18 | ||
26 | #10 0x56187aa88633 in address_space_read include/exec/memory.h:2489:18 | ||
27 | #11 0x56187aa88633 in qtest_process_command softmmu/qtest.c:558:13 | ||
28 | #12 0x56187aa81881 in qtest_process_inbuf softmmu/qtest.c:797:9 | ||
29 | #13 0x56187aa80e02 in qtest_read softmmu/qtest.c:809:5 | ||
30 | |||
31 | current_cpu is NULL because QTest accelerator does not use CPU. | ||
32 | |||
33 | Fix by skipping the check and returning the first CPU index when | ||
34 | QTest accelerator is used, similarly to commit c781a2cc423 | ||
35 | ("hw/i386/vmport: Allow QTest use without crashing"). | ||
36 | |||
37 | Reported-by: Alexander Bulekov <alxndr@bu.edu> | ||
38 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
39 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> | ||
40 | Reviewed-by: Alexander Bulekov <alxndr@bu.edu> | ||
41 | Message-id: 20210128161417.3726358-1-philmd@redhat.com | ||
42 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
43 | --- | ||
44 | hw/intc/arm_gic.c | 3 ++- | ||
45 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
46 | |||
47 | diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/intc/arm_gic.c | ||
50 | +++ b/hw/intc/arm_gic.c | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | #include "qemu/module.h" | ||
53 | #include "trace.h" | ||
54 | #include "sysemu/kvm.h" | ||
55 | +#include "sysemu/qtest.h" | ||
56 | |||
57 | /* #define DEBUG_GIC */ | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ static const uint8_t gic_id_gicv2[] = { | ||
60 | |||
61 | static inline int gic_get_current_cpu(GICState *s) | ||
62 | { | ||
63 | - if (s->num_cpu > 1) { | ||
64 | + if (!qtest_enabled() && s->num_cpu > 1) { | ||
65 | return current_cpu->cpu_index; | ||
66 | } | ||
67 | return 0; | ||
68 | -- | ||
69 | 2.20.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Iris Johnson <iris@modwiz.com> | ||
1 | 2 | ||
3 | Currently the Exynos 4210 UART code always reports available FIFO space | ||
4 | when the backend checks for buffer space. When the FIFO is disabled this | ||
5 | is behavior causes the backend chardev code to replace the data before the | ||
6 | guest can read it. | ||
7 | |||
8 | This patch changes adds the logic to report the capacity properly when the | ||
9 | FIFO is not being used. | ||
10 | |||
11 | Buglink: https://bugs.launchpad.net/qemu/+bug/1913344 | ||
12 | Signed-off-by: Iris Johnson <iris@modwiz.com> | ||
13 | Message-id: 20210128033655.1029577-1-iris@modwiz.com | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/char/exynos4210_uart.c | 6 +++++- | ||
18 | 1 file changed, 5 insertions(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/char/exynos4210_uart.c | ||
23 | +++ b/hw/char/exynos4210_uart.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static int exynos4210_uart_can_receive(void *opaque) | ||
25 | { | ||
26 | Exynos4210UartState *s = (Exynos4210UartState *)opaque; | ||
27 | |||
28 | - return fifo_empty_elements_number(&s->rx); | ||
29 | + if (s->reg[I_(UFCON)] & UFCON_FIFO_ENABLE) { | ||
30 | + return fifo_empty_elements_number(&s->rx); | ||
31 | + } else { | ||
32 | + return !(s->reg[I_(UTRSTAT)] & UTRSTAT_Rx_BUFFER_DATA_READY); | ||
33 | + } | ||
34 | } | ||
35 | |||
36 | static void exynos4210_uart_receive(void *opaque, const uint8_t *buf, int size) | ||
37 | -- | ||
38 | 2.20.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Iris Johnson <iris@modwiz.com> | ||
1 | 2 | ||
3 | When the frontend device has no space for a read the fd is removed | ||
4 | from polling to allow time for the guest to read and clear the buffer. | ||
5 | Without the call to qemu_chr_fe_accept_input(), the poll will not be | ||
6 | broken out of when the guest has cleared the buffer causing significant | ||
7 | IO delays that get worse with smaller buffers. | ||
8 | |||
9 | Buglink: https://bugs.launchpad.net/qemu/+bug/1913341 | ||
10 | Signed-off-by: Iris Johnson <iris@modwiz.com> | ||
11 | Message-id: 20210130184016.1787097-1-iris@modwiz.com | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/char/exynos4210_uart.c | 1 + | ||
16 | 1 file changed, 1 insertion(+) | ||
17 | |||
18 | diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/char/exynos4210_uart.c | ||
21 | +++ b/hw/char/exynos4210_uart.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_uart_read(void *opaque, hwaddr offset, | ||
23 | s->reg[I_(UTRSTAT)] &= ~UTRSTAT_Rx_BUFFER_DATA_READY; | ||
24 | res = s->reg[I_(URXH)]; | ||
25 | } | ||
26 | + qemu_chr_fe_accept_input(&s->chr); | ||
27 | exynos4210_uart_update_dmabusy(s); | ||
28 | trace_exynos_uart_read(s->channel, offset, | ||
29 | exynos4210_uart_regname(offset), res); | ||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Zenghui Yu <yuzenghui@huawei.com> | ||
1 | 2 | ||
3 | When handling guest range-based IOTLB invalidation, we should decode the TG | ||
4 | field into the corresponding translation granule size so that we can pass | ||
5 | the correct invalidation range to backend. Set @granule to (tg * 2 + 10) to | ||
6 | properly emulate the architecture. | ||
7 | |||
8 | Fixes: d52915616c05 ("hw/arm/smmuv3: Get prepared for range invalidation") | ||
9 | Signed-off-by: Zenghui Yu <yuzenghui@huawei.com> | ||
10 | Acked-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Message-id: 20210130043220.1345-1-yuzenghui@huawei.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/smmuv3.c | 4 +++- | ||
15 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/arm/smmuv3.c | ||
20 | +++ b/hw/arm/smmuv3.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, | ||
22 | { | ||
23 | SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu); | ||
24 | IOMMUTLBEvent event; | ||
25 | - uint8_t granule = tg; | ||
26 | + uint8_t granule; | ||
27 | |||
28 | if (!tg) { | ||
29 | SMMUEventInfo event = {.inval_ste_allowed = true}; | ||
30 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, | ||
31 | return; | ||
32 | } | ||
33 | granule = tt->granule_sz; | ||
34 | + } else { | ||
35 | + granule = tg * 2 + 10; | ||
36 | } | ||
37 | |||
38 | event.type = IOMMU_NOTIFIER_UNMAP; | ||
39 | -- | ||
40 | 2.20.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
1 | The nrf51 SoC model wasn't setting the system_clock_scale | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
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 | 2 | ||
5 | Set the global to match the documented CPU clock speed for this SoC. | 3 | Avoid using a magic number (4) everywhere for the number of chip |
4 | selects supported. | ||
6 | 5 | ||
7 | This SoC in fact doesn't have a SysTick timer (which is the only thing | 6 | Signed-off-by: Bin Meng <bin.meng@windriver.com> |
8 | currently that cares about the system_clock_scale), because it's | 7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
9 | a configurable option in the Cortex-M0. However our Cortex-M0 and | 8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
10 | thus our nrf51 and our micro:bit board do provide a SysTick, so | 9 | Reviewed-by: Juan Quintela <quintela@redhat.com> |
11 | we ought to provide a functional one rather than a broken one. | 10 | Message-id: 20210129132323.30946-2-bmeng.cn@gmail.com |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | include/hw/ssi/imx_spi.h | 5 ++++- | ||
14 | hw/ssi/imx_spi.c | 4 ++-- | ||
15 | 2 files changed, 6 insertions(+), 3 deletions(-) | ||
12 | 16 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | diff --git a/include/hw/ssi/imx_spi.h b/include/hw/ssi/imx_spi.h |
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 | 18 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/nrf51_soc.c | 19 | --- a/include/hw/ssi/imx_spi.h |
23 | +++ b/hw/arm/nrf51_soc.c | 20 | +++ b/include/hw/ssi/imx_spi.h |
24 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ |
25 | 22 | ||
26 | #define BASE_TO_IRQ(base) ((base >> 12) & 0x1F) | 23 | #define EXTRACT(value, name) extract32(value, name##_SHIFT, name##_LENGTH) |
27 | 24 | ||
28 | +/* HCLK (the main CPU clock) on this SoC is always 16MHz */ | 25 | +/* number of chip selects supported */ |
29 | +#define HCLK_FRQ 16000000 | 26 | +#define ECSPI_NUM_CS 4 |
30 | + | 27 | + |
31 | static uint64_t clock_read(void *opaque, hwaddr addr, unsigned int size) | 28 | #define TYPE_IMX_SPI "imx.spi" |
32 | { | 29 | OBJECT_DECLARE_SIMPLE_TYPE(IMXSPIState, IMX_SPI) |
33 | qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n", | 30 | |
34 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | 31 | @@ -XXX,XX +XXX,XX @@ struct IMXSPIState { |
35 | return; | 32 | |
33 | qemu_irq irq; | ||
34 | |||
35 | - qemu_irq cs_lines[4]; | ||
36 | + qemu_irq cs_lines[ECSPI_NUM_CS]; | ||
37 | |||
38 | SSIBus *bus; | ||
39 | |||
40 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/ssi/imx_spi.c | ||
43 | +++ b/hw/ssi/imx_spi.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_write(void *opaque, hwaddr offset, uint64_t value, | ||
45 | |||
46 | /* We are in master mode */ | ||
47 | |||
48 | - for (i = 0; i < 4; i++) { | ||
49 | + for (i = 0; i < ECSPI_NUM_CS; i++) { | ||
50 | qemu_set_irq(s->cs_lines[i], | ||
51 | i == imx_spi_selected_channel(s) ? 0 : 1); | ||
52 | } | ||
53 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_realize(DeviceState *dev, Error **errp) | ||
54 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | ||
55 | sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); | ||
56 | |||
57 | - for (i = 0; i < 4; ++i) { | ||
58 | + for (i = 0; i < ECSPI_NUM_CS; ++i) { | ||
59 | sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->cs_lines[i]); | ||
36 | } | 60 | } |
37 | 61 | ||
38 | + system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ; | ||
39 | + | ||
40 | object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container), | ||
41 | &error_abort); | ||
42 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) { | ||
43 | -- | 62 | -- |
44 | 2.20.1 | 63 | 2.20.1 |
45 | 64 | ||
46 | 65 | diff view generated by jsdifflib |
1 | The imx_epit device has a software-controllable reset triggered by | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | setting the SWR bit in the CR register. An error in commit cc2722ec83ad9 | ||
3 | means that we will end up assert()ing if the guest does this, because | ||
4 | the code in imx_epit_write() starts ptimer transactions, and then | ||
5 | imx_epit_reset() also starts ptimer transactions, triggering | ||
6 | "ptimer_transaction_begin: Assertion `!s->in_transaction' failed". | ||
7 | 2 | ||
8 | The cleanest way to avoid this double-transaction is to move the | 3 | Usually the approach is that the device on the other end of the line |
9 | start-transaction for the CR write handling down below the check of | 4 | is going to reset its state anyway, so there's no need to actively |
10 | the SWR bit. | 5 | signal an irq line change during the reset hook. |
11 | 6 | ||
12 | Fixes: https://bugs.launchpad.net/qemu/+bug/1880424 | 7 | Move imx_spi_update_irq() out of imx_spi_reset(), to a new function |
13 | Fixes: cc2722ec83ad944505fe | 8 | imx_spi_soft_reset() that is called when the controller is disabled. |
9 | |||
10 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Message-id: 20210129132323.30946-3-bmeng.cn@gmail.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
16 | Message-id: 20200727154550.3409-1-peter.maydell@linaro.org | ||
17 | --- | 14 | --- |
18 | hw/timer/imx_epit.c | 13 ++++++++++--- | 15 | hw/ssi/imx_spi.c | 14 ++++++++++---- |
19 | 1 file changed, 10 insertions(+), 3 deletions(-) | 16 | 1 file changed, 10 insertions(+), 4 deletions(-) |
20 | 17 | ||
21 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c | 18 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c |
22 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/timer/imx_epit.c | 20 | --- a/hw/ssi/imx_spi.c |
24 | +++ b/hw/timer/imx_epit.c | 21 | +++ b/hw/ssi/imx_spi.c |
25 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | 22 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_reset(DeviceState *dev) |
26 | 23 | imx_spi_rxfifo_reset(s); | |
27 | switch (offset >> 2) { | 24 | imx_spi_txfifo_reset(s); |
28 | case 0: /* CR */ | 25 | |
29 | - ptimer_transaction_begin(s->timer_cmp); | 26 | - imx_spi_update_irq(s); |
30 | - ptimer_transaction_begin(s->timer_reload); | 27 | - |
31 | 28 | s->burst_length = 0; | |
32 | oldcr = s->cr; | 29 | } |
33 | s->cr = value & 0x03ffffff; | 30 | |
34 | if (s->cr & CR_SWR) { | 31 | +static void imx_spi_soft_reset(IMXSPIState *s) |
35 | /* handle the reset */ | 32 | +{ |
36 | imx_epit_reset(DEVICE(s)); | 33 | + imx_spi_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 | + | 34 | + |
44 | + ptimer_transaction_begin(s->timer_cmp); | 35 | + imx_spi_update_irq(s); |
45 | + ptimer_transaction_begin(s->timer_reload); | 36 | +} |
46 | + | 37 | + |
47 | + if (!(s->cr & CR_SWR)) { | 38 | static uint64_t imx_spi_read(void *opaque, hwaddr offset, unsigned size) |
48 | imx_epit_set_freq(s); | 39 | { |
40 | uint32_t value = 0; | ||
41 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_write(void *opaque, hwaddr offset, uint64_t value, | ||
42 | s->regs[ECSPI_CONREG] = value; | ||
43 | |||
44 | if (!imx_spi_is_enabled(s)) { | ||
45 | - /* device is disabled, so this is a reset */ | ||
46 | - imx_spi_reset(DEVICE(s)); | ||
47 | + /* device is disabled, so this is a soft reset */ | ||
48 | + imx_spi_soft_reset(s); | ||
49 | + | ||
50 | return; | ||
49 | } | 51 | } |
50 | 52 | ||
51 | -- | 53 | -- |
52 | 2.20.1 | 54 | 2.20.1 |
53 | 55 | ||
54 | 56 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | 'burst_length' is cleared in imx_spi_reset(), which is called | ||
4 | after imx_spi_realize(). Remove the initialization to simplify. | ||
5 | |||
6 | Reviewed-by: Juan Quintela <quintela@redhat.com> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Reviewed-by: Bin Meng <bin.meng@windriver.com> | ||
9 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
10 | Message-id: 20210129132323.30946-4-bmeng.cn@gmail.com | ||
11 | Message-Id: <20210115153049.3353008-3-f4bug@amsat.org> | ||
12 | Reviewed-by: Bin Meng <bin.meng@windriver.com> | ||
13 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/ssi/imx_spi.c | 2 -- | ||
17 | 1 file changed, 2 deletions(-) | ||
18 | |||
19 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/ssi/imx_spi.c | ||
22 | +++ b/hw/ssi/imx_spi.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_realize(DeviceState *dev, Error **errp) | ||
24 | sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->cs_lines[i]); | ||
25 | } | ||
26 | |||
27 | - s->burst_length = 0; | ||
28 | - | ||
29 | fifo32_create(&s->tx_fifo, ECSPI_FIFO_SIZE); | ||
30 | fifo32_create(&s->rx_fifo, ECSPI_FIFO_SIZE); | ||
31 | } | ||
32 | -- | ||
33 | 2.20.1 | ||
34 | |||
35 | diff view generated by jsdifflib |
1 | The NVIC provides an outbound qemu_irq "SYSRESETREQ" which it signals | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
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 | When the block is disabled, all registers are reset with the |
10 | actually connected to anything: use qemu_system_reset_request() to | 4 | exception of the ECSPI_CONREG. It is initialized to zero |
11 | perform a system reset. This will allow us to remove the | 5 | when the instance is created. |
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 | Ref: i.MX 6DQ Applications Processor Reference Manual (IMX6DQRM), |
17 | * mps2-an385 | 8 | chapter 21.7.3: Control Register (ECSPIx_CONREG) |
18 | * mps2-an505 | ||
19 | * mps2-an511 | ||
20 | * mps2-an521 | ||
21 | * musca-a | ||
22 | * musca-b1 | ||
23 | * netduino | ||
24 | * netduinoplus2 | ||
25 | 9 | ||
26 | We still allow the board to wire up the signal if it needs to, in case | 10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
27 | we need to model more complicated reset controller logic or to model | 11 | Signed-off-by: Bin Meng <bin.meng@windriver.com> |
28 | buggy SoC hardware which forgot to wire up the line itself. But | 12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
29 | defaulting to "reset the system" is more often going to be correct | 13 | Message-id: 20210129132323.30946-5-bmeng.cn@gmail.com |
30 | than defaulting to "do nothing". | 14 | [bmeng: add a 'common_reset' function that does most of reset operation] |
15 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | hw/ssi/imx_spi.c | 32 ++++++++++++++++++++++++-------- | ||
19 | 1 file changed, 24 insertions(+), 8 deletions(-) | ||
31 | 20 | ||
32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c |
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 | --- | ||
37 | include/hw/arm/armv7m.h | 4 +++- | ||
38 | hw/intc/armv7m_nvic.c | 17 ++++++++++++++++- | ||
39 | 2 files changed, 19 insertions(+), 2 deletions(-) | ||
40 | |||
41 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h | ||
42 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/include/hw/arm/armv7m.h | 23 | --- a/hw/ssi/imx_spi.c |
44 | +++ b/include/hw/arm/armv7m.h | 24 | +++ b/hw/ssi/imx_spi.c |
45 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 25 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) |
46 | 26 | fifo32_num_used(&s->tx_fifo), fifo32_num_used(&s->rx_fifo)); | |
47 | /* ARMv7M container object. | 27 | } |
48 | * + Unnamed GPIO input lines: external IRQ lines for the NVIC | 28 | |
49 | - * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ | 29 | -static void imx_spi_reset(DeviceState *dev) |
50 | + * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ. | 30 | +static void imx_spi_common_reset(IMXSPIState *s) |
51 | + * If this GPIO is not wired up then the NVIC will default to performing | 31 | { |
52 | + * a qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET). | 32 | - IMXSPIState *s = IMX_SPI(dev); |
53 | * + Property "cpu-type": CPU type to instantiate | 33 | + int i; |
54 | * + Property "num-irq": number of external IRQ lines | 34 | |
55 | * + Property "memory": MemoryRegion defining the physical address space | 35 | - DPRINTF("\n"); |
56 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 36 | - |
57 | index XXXXXXX..XXXXXXX 100644 | 37 | - memset(s->regs, 0, sizeof(s->regs)); |
58 | --- a/hw/intc/armv7m_nvic.c | 38 | - |
59 | +++ b/hw/intc/armv7m_nvic.c | 39 | - s->regs[ECSPI_STATREG] = 0x00000003; |
60 | @@ -XXX,XX +XXX,XX @@ | 40 | + for (i = 0; i < ARRAY_SIZE(s->regs); i++) { |
61 | #include "hw/intc/armv7m_nvic.h" | 41 | + switch (i) { |
62 | #include "hw/irq.h" | 42 | + case ECSPI_CONREG: |
63 | #include "hw/qdev-properties.h" | 43 | + /* CONREG is not updated on soft reset */ |
64 | +#include "sysemu/runstate.h" | 44 | + break; |
65 | #include "target/arm/cpu.h" | 45 | + case ECSPI_STATREG: |
66 | #include "exec/exec-all.h" | 46 | + s->regs[i] = 0x00000003; |
67 | #include "exec/memop.h" | 47 | + break; |
68 | @@ -XXX,XX +XXX,XX @@ static const uint8_t nvic_id[] = { | 48 | + default: |
69 | 0x00, 0xb0, 0x1b, 0x00, 0x0d, 0xe0, 0x05, 0xb1 | 49 | + s->regs[i] = 0; |
70 | }; | 50 | + break; |
71 | 51 | + } | |
72 | +static void signal_sysresetreq(NVICState *s) | 52 | + } |
53 | |||
54 | imx_spi_rxfifo_reset(s); | ||
55 | imx_spi_txfifo_reset(s); | ||
56 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_reset(DeviceState *dev) | ||
57 | |||
58 | static void imx_spi_soft_reset(IMXSPIState *s) | ||
59 | { | ||
60 | - imx_spi_reset(DEVICE(s)); | ||
61 | + imx_spi_common_reset(s); | ||
62 | |||
63 | imx_spi_update_irq(s); | ||
64 | } | ||
65 | |||
66 | +static void imx_spi_reset(DeviceState *dev) | ||
73 | +{ | 67 | +{ |
74 | + if (qemu_irq_is_connected(s->sysresetreq)) { | 68 | + IMXSPIState *s = IMX_SPI(dev); |
75 | + qemu_irq_pulse(s->sysresetreq); | 69 | + |
76 | + } else { | 70 | + imx_spi_common_reset(s); |
77 | + /* | 71 | + s->regs[ECSPI_CONREG] = 0; |
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 | +} | 72 | +} |
85 | + | 73 | + |
86 | static int nvic_pending_prio(NVICState *s) | 74 | static uint64_t imx_spi_read(void *opaque, hwaddr offset, unsigned size) |
87 | { | 75 | { |
88 | /* return the group priority of the current pending interrupt, | 76 | uint32_t value = 0; |
89 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
90 | if (value & R_V7M_AIRCR_SYSRESETREQ_MASK) { | ||
91 | if (attrs.secure || | ||
92 | !(cpu->env.v7m.aircr & R_V7M_AIRCR_SYSRESETREQS_MASK)) { | ||
93 | - qemu_irq_pulse(s->sysresetreq); | ||
94 | + signal_sysresetreq(s); | ||
95 | } | ||
96 | } | ||
97 | if (value & R_V7M_AIRCR_VECTCLRACTIVE_MASK) { | ||
98 | -- | 77 | -- |
99 | 2.20.1 | 78 | 2.20.1 |
100 | 79 | ||
101 | 80 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The definition of top_bit used in this function is one higher | 3 | When the block is disabled, it stay it is 'internal reset logic' |
4 | than that used in the Arm ARM psuedo-code, which put the error | 4 | (internal clocks are gated off). Reading any register returns |
5 | indication at top_bit - 1 at the wrong place, which meant that | 5 | its reset value. Only update this value if the device is enabled. |
6 | it wasn't visible to Auth. | ||
7 | 6 | ||
8 | Fixing the definition of top_bit requires more changes, because | 7 | Ref: i.MX 6DQ Applications Processor Reference Manual (IMX6DQRM), |
9 | its most common use is for the count of bits in top_bit:bot_bit, | 8 | chapter 21.7.3: Control Register (ECSPIx_CONREG) |
10 | which would then need to be computed as top_bit - bot_bit + 1. | ||
11 | 9 | ||
12 | For now, prefer the minimal fix to the error indication alone. | 10 | Reviewed-by: Juan Quintela <quintela@redhat.com> |
13 | 11 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | |
14 | Fixes: 63ff0ca94cb | 12 | Reviewed-by: Bin Meng <bin.meng@windriver.com> |
15 | Reported-by: Derrick McKee <derrick.mckee@gmail.com> | 13 | Signed-off-by: Bin Meng <bin.meng@windriver.com> |
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Message-id: 20210129132323.30946-6-bmeng.cn@gmail.com |
17 | Message-id: 20200728195706.11087-1-richard.henderson@linaro.org | 15 | Message-Id: <20210115153049.3353008-5-f4bug@amsat.org> |
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Reviewed-by: Bin Meng <bin.meng@windriver.com> |
19 | [PMM: added comment about the divergence from the pseudocode] | 17 | Signed-off-by: Bin Meng <bin.meng@windriver.com> |
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 19 | --- |
22 | target/arm/pauth_helper.c | 6 +++++- | 20 | hw/ssi/imx_spi.c | 60 +++++++++++++++++++++++------------------------- |
23 | tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++ | 21 | 1 file changed, 29 insertions(+), 31 deletions(-) |
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 | 22 | ||
28 | diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c | 23 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c |
29 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/pauth_helper.c | 25 | --- a/hw/ssi/imx_spi.c |
31 | +++ b/target/arm/pauth_helper.c | 26 | +++ b/hw/ssi/imx_spi.c |
32 | @@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, | 27 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx_spi_read(void *opaque, hwaddr offset, unsigned size) |
33 | */ | 28 | return 0; |
34 | test = sextract64(ptr, bot_bit, top_bit - bot_bit); | ||
35 | if (test != 0 && test != -1) { | ||
36 | - pac ^= MAKE_64BIT_MASK(top_bit - 1, 1); | ||
37 | + /* | ||
38 | + * Note that our top_bit is one greater than the pseudocode's | ||
39 | + * version, hence "- 2" here. | ||
40 | + */ | ||
41 | + pac ^= MAKE_64BIT_MASK(top_bit - 2, 1); | ||
42 | } | 29 | } |
43 | 30 | ||
44 | /* | 31 | - switch (index) { |
45 | diff --git a/tests/tcg/aarch64/pauth-5.c b/tests/tcg/aarch64/pauth-5.c | 32 | - case ECSPI_RXDATA: |
46 | new file mode 100644 | 33 | - if (!imx_spi_is_enabled(s)) { |
47 | index XXXXXXX..XXXXXXX | 34 | - value = 0; |
48 | --- /dev/null | 35 | - } else if (fifo32_is_empty(&s->rx_fifo)) { |
49 | +++ b/tests/tcg/aarch64/pauth-5.c | 36 | - /* value is undefined */ |
50 | @@ -XXX,XX +XXX,XX @@ | 37 | - value = 0xdeadbeef; |
51 | +#include <assert.h> | 38 | - } else { |
39 | - /* read from the RX FIFO */ | ||
40 | - value = fifo32_pop(&s->rx_fifo); | ||
41 | + value = s->regs[index]; | ||
52 | + | 42 | + |
53 | +static int x; | 43 | + if (imx_spi_is_enabled(s)) { |
44 | + switch (index) { | ||
45 | + case ECSPI_RXDATA: | ||
46 | + if (fifo32_is_empty(&s->rx_fifo)) { | ||
47 | + /* value is undefined */ | ||
48 | + value = 0xdeadbeef; | ||
49 | + } else { | ||
50 | + /* read from the RX FIFO */ | ||
51 | + value = fifo32_pop(&s->rx_fifo); | ||
52 | + } | ||
53 | + break; | ||
54 | + case ECSPI_TXDATA: | ||
55 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
56 | + "[%s]%s: Trying to read from TX FIFO\n", | ||
57 | + TYPE_IMX_SPI, __func__); | ||
54 | + | 58 | + |
55 | +int main() | 59 | + /* Reading from TXDATA gives 0 */ |
56 | +{ | 60 | + break; |
57 | + int *p0 = &x, *p1, *p2, *p3; | 61 | + case ECSPI_MSGDATA: |
58 | + unsigned long salt = 0; | 62 | + qemu_log_mask(LOG_GUEST_ERROR, |
59 | + | 63 | + "[%s]%s: Trying to read from MSG FIFO\n", |
60 | + /* | 64 | + TYPE_IMX_SPI, __func__); |
61 | + * With TBI enabled and a 48-bit VA, there are 7 bits of auth, and so | 65 | + /* Reading from MSGDATA gives 0 */ |
62 | + * a 1/128 chance of auth = pac(ptr,key,salt) producing zero. | 66 | + break; |
63 | + * Find a salt that creates auth != 0. | 67 | + default: |
64 | + */ | 68 | + break; |
65 | + do { | 69 | } |
66 | + salt++; | 70 | |
67 | + asm("pacda %0, %1" : "=r"(p1) : "r"(salt), "0"(p0)); | 71 | - break; |
68 | + } while (p0 == p1); | 72 | - case ECSPI_TXDATA: |
69 | + | 73 | - qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Trying to read from TX FIFO\n", |
70 | + /* | 74 | - TYPE_IMX_SPI, __func__); |
71 | + * This pac must fail, because the input pointer bears an encryption, | 75 | - |
72 | + * and so is not properly extended within bits [55:47]. This will | 76 | - /* Reading from TXDATA gives 0 */ |
73 | + * toggle bit 54 in the output... | 77 | - |
74 | + */ | 78 | - break; |
75 | + asm("pacda %0, %1" : "=r"(p2) : "r"(salt), "0"(p1)); | 79 | - case ECSPI_MSGDATA: |
76 | + | 80 | - qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Trying to read from MSG FIFO\n", |
77 | + /* ... so that the aut must fail, setting bit 53 in the output ... */ | 81 | - TYPE_IMX_SPI, __func__); |
78 | + asm("autda %0, %1" : "=r"(p3) : "r"(salt), "0"(p2)); | 82 | - |
79 | + | 83 | - /* Reading from MSGDATA gives 0 */ |
80 | + /* ... which means this equality must not hold. */ | 84 | - |
81 | + assert(p3 != p0); | 85 | - break; |
82 | + return 0; | 86 | - default: |
83 | +} | 87 | - value = s->regs[index]; |
84 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | 88 | - break; |
85 | index XXXXXXX..XXXXXXX 100644 | 89 | + imx_spi_update_irq(s); |
86 | --- a/tests/tcg/aarch64/Makefile.target | 90 | } |
87 | +++ b/tests/tcg/aarch64/Makefile.target | 91 | - |
88 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | 92 | DPRINTF("reg[%s] => 0x%" PRIx32 "\n", imx_spi_reg_name(index), value); |
89 | 93 | ||
90 | # Pauth Tests | 94 | - imx_spi_update_irq(s); |
91 | ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_3),) | 95 | - |
92 | -AARCH64_TESTS += pauth-1 pauth-2 pauth-4 | 96 | return (uint64_t)value; |
93 | +AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5 | 97 | } |
94 | pauth-%: CFLAGS += -march=armv8.3-a | 98 | |
95 | run-pauth-%: QEMU_OPTS += -cpu max | ||
96 | run-plugin-pauth-%: QEMU_OPTS += -cpu max | ||
97 | -- | 99 | -- |
98 | 2.20.1 | 100 | 2.20.1 |
99 | 101 | ||
100 | 102 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | When the block is disabled, only the ECSPI_CONREG register can | ||
4 | be modified. Setting the EN bit enabled the device, clearing it | ||
5 | "disables the block and resets the internal logic with the | ||
6 | exception of the ECSPI_CONREG" register. | ||
7 | |||
8 | Ignore all other registers write except ECSPI_CONREG when the | ||
9 | block is disabled. | ||
10 | |||
11 | Ref: i.MX 6DQ Applications Processor Reference Manual (IMX6DQRM), | ||
12 | chapter 21.7.3: Control Register (ECSPIx_CONREG) | ||
13 | |||
14 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Message-id: 20210129132323.30946-7-bmeng.cn@gmail.com | ||
18 | Message-Id: <20210115153049.3353008-6-f4bug@amsat.org> | ||
19 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
20 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | --- | ||
23 | hw/ssi/imx_spi.c | 13 +++++++++---- | ||
24 | 1 file changed, 9 insertions(+), 4 deletions(-) | ||
25 | |||
26 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/ssi/imx_spi.c | ||
29 | +++ b/hw/ssi/imx_spi.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_write(void *opaque, hwaddr offset, uint64_t value, | ||
31 | DPRINTF("reg[%s] <= 0x%" PRIx32 "\n", imx_spi_reg_name(index), | ||
32 | (uint32_t)value); | ||
33 | |||
34 | + if (!imx_spi_is_enabled(s)) { | ||
35 | + /* Block is disabled */ | ||
36 | + if (index != ECSPI_CONREG) { | ||
37 | + /* Ignore access */ | ||
38 | + return; | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | change_mask = s->regs[index] ^ value; | ||
43 | |||
44 | switch (index) { | ||
45 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_write(void *opaque, hwaddr offset, uint64_t value, | ||
46 | TYPE_IMX_SPI, __func__); | ||
47 | break; | ||
48 | case ECSPI_TXDATA: | ||
49 | - if (!imx_spi_is_enabled(s)) { | ||
50 | - /* Ignore writes if device is disabled */ | ||
51 | - break; | ||
52 | - } else if (fifo32_is_full(&s->tx_fifo)) { | ||
53 | + if (fifo32_is_full(&s->tx_fifo)) { | ||
54 | /* Ignore writes if queue is full */ | ||
55 | break; | ||
56 | } | ||
57 | -- | ||
58 | 2.20.1 | ||
59 | |||
60 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Xuzhou Cheng <xuzhou.cheng@windriver.com> | ||
1 | 2 | ||
3 | When a write to ECSPI_CONREG register to disable the SPI controller, | ||
4 | imx_spi_soft_reset() is called to reset the controller, but chip | ||
5 | select lines should have been disabled, otherwise the state machine | ||
6 | of any devices (e.g.: SPI flashes) connected to the SPI master is | ||
7 | stuck to its last state and responds incorrectly to any follow-up | ||
8 | commands. | ||
9 | |||
10 | Fixes: c906a3a01582 ("i.MX: Add the Freescale SPI Controller") | ||
11 | Signed-off-by: Xuzhou Cheng <xuzhou.cheng@windriver.com> | ||
12 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Message-id: 20210129132323.30946-8-bmeng.cn@gmail.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/ssi/imx_spi.c | 6 ++++++ | ||
18 | 1 file changed, 6 insertions(+) | ||
19 | |||
20 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/ssi/imx_spi.c | ||
23 | +++ b/hw/ssi/imx_spi.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_common_reset(IMXSPIState *s) | ||
25 | |||
26 | static void imx_spi_soft_reset(IMXSPIState *s) | ||
27 | { | ||
28 | + int i; | ||
29 | + | ||
30 | imx_spi_common_reset(s); | ||
31 | |||
32 | imx_spi_update_irq(s); | ||
33 | + | ||
34 | + for (i = 0; i < ECSPI_NUM_CS; i++) { | ||
35 | + qemu_set_irq(s->cs_lines[i], 1); | ||
36 | + } | ||
37 | } | ||
38 | |||
39 | static void imx_spi_reset(DeviceState *dev) | ||
40 | -- | ||
41 | 2.20.1 | ||
42 | |||
43 | diff view generated by jsdifflib |
1 | The MSF2 SoC model and the Stellaris board code both wire | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
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 | 2 | ||
3 | Current implementation of the imx spi controller expects the burst | ||
4 | length to be multiple of 8, which is the most common use case. | ||
5 | |||
6 | In case the burst length is not what we expect, log it to give user | ||
7 | a chance to notice it, and round it up to be multiple of 8. | ||
8 | |||
9 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
10 | Message-id: 20210129132323.30946-9-bmeng.cn@gmail.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | 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 | --- | 13 | --- |
12 | hw/arm/msf2-soc.c | 11 ----------- | 14 | hw/ssi/imx_spi.c | 17 ++++++++++++++++- |
13 | hw/arm/stellaris.c | 12 ------------ | 15 | 1 file changed, 16 insertions(+), 1 deletion(-) |
14 | 2 files changed, 23 deletions(-) | ||
15 | 16 | ||
16 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | 17 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c |
17 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/msf2-soc.c | 19 | --- a/hw/ssi/imx_spi.c |
19 | +++ b/hw/arm/msf2-soc.c | 20 | +++ b/hw/ssi/imx_spi.c |
20 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static uint8_t imx_spi_selected_channel(IMXSPIState *s) |
21 | #include "hw/irq.h" | 22 | |
22 | #include "hw/arm/msf2-soc.h" | 23 | static uint32_t imx_spi_burst_length(IMXSPIState *s) |
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 | { | 24 | { |
41 | MSF2State *s = MSF2_SOC(obj); | 25 | - return EXTRACT(s->regs[ECSPI_CONREG], ECSPI_CONREG_BURST_LENGTH) + 1; |
42 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | 26 | + uint32_t burst; |
43 | return; | 27 | + |
44 | } | 28 | + burst = EXTRACT(s->regs[ECSPI_CONREG], ECSPI_CONREG_BURST_LENGTH) + 1; |
45 | 29 | + if (burst % 8) { | |
46 | - qdev_connect_gpio_out_named(DEVICE(&s->armv7m.nvic), "SYSRESETREQ", 0, | 30 | + burst = ROUND_UP(burst, 8); |
47 | - qemu_allocate_irq(&do_sys_reset, NULL, 0)); | 31 | + } |
48 | - | 32 | + |
49 | system_clock_scale = NANOSECONDS_PER_SECOND / s->m3clk; | 33 | + return burst; |
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 | } | 34 | } |
67 | 35 | ||
68 | -static | 36 | static bool imx_spi_is_enabled(IMXSPIState *s) |
69 | -void do_sys_reset(void *opaque, int n, int level) | 37 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_write(void *opaque, hwaddr offset, uint64_t value, |
70 | -{ | 38 | IMXSPIState *s = opaque; |
71 | - if (level) { | 39 | uint32_t index = offset >> 2; |
72 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | 40 | uint32_t change_mask; |
73 | - } | 41 | + uint32_t burst; |
74 | -} | 42 | |
75 | - | 43 | if (index >= ECSPI_MAX) { |
76 | /* Board init. */ | 44 | qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%" |
77 | static stellaris_board_info stellaris_boards[] = { | 45 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_write(void *opaque, hwaddr offset, uint64_t value, |
78 | { "LM3S811EVB", | 46 | case ECSPI_CONREG: |
79 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | 47 | s->regs[ECSPI_CONREG] = value; |
80 | /* This will exit with an error if the user passed us a bad cpu_type */ | 48 | |
81 | sysbus_realize_and_unref(SYS_BUS_DEVICE(nvic), &error_fatal); | 49 | + burst = EXTRACT(s->regs[ECSPI_CONREG], ECSPI_CONREG_BURST_LENGTH) + 1; |
82 | 50 | + if (burst % 8) { | |
83 | - qdev_connect_gpio_out_named(nvic, "SYSRESETREQ", 0, | 51 | + qemu_log_mask(LOG_UNIMP, |
84 | - qemu_allocate_irq(&do_sys_reset, NULL, 0)); | 52 | + "[%s]%s: burst length %d not supported: rounding up to next multiple of 8\n", |
85 | - | 53 | + TYPE_IMX_SPI, __func__, burst); |
86 | if (board->dc1 & (1 << 16)) { | 54 | + } |
87 | dev = sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000, | 55 | + |
88 | qdev_get_gpio_in(nvic, 14), | 56 | if (!imx_spi_is_enabled(s)) { |
57 | /* device is disabled, so this is a soft reset */ | ||
58 | imx_spi_soft_reset(s); | ||
89 | -- | 59 | -- |
90 | 2.20.1 | 60 | 2.20.1 |
91 | 61 | ||
92 | 62 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Bin Meng <bin.meng@windriver.com> | ||
1 | 2 | ||
3 | For the ECSPIx_CONREG register BURST_LENGTH field, the manual says: | ||
4 | |||
5 | 0x020 A SPI burst contains the 1 LSB in first word and all 32 bits in second word. | ||
6 | 0x021 A SPI burst contains the 2 LSB in first word and all 32 bits in second word. | ||
7 | |||
8 | Current logic uses either s->burst_length or 32, whichever smaller, | ||
9 | to determine how many bits it should read from the tx fifo each time. | ||
10 | For example, for a 48 bit burst length, current logic transfers the | ||
11 | first 32 bit from the first word in the tx fifo, followed by a 16 | ||
12 | bit from the second word in the tx fifo, which is wrong. The correct | ||
13 | logic should be: transfer the first 16 bit from the first word in | ||
14 | the tx fifo, followed by a 32 bit from the second word in the tx fifo. | ||
15 | |||
16 | With this change, SPI flash can be successfully probed by U-Boot on | ||
17 | imx6 sabrelite board. | ||
18 | |||
19 | => sf probe | ||
20 | SF: Detected sst25vf016b with page size 256 Bytes, erase size 4 KiB, total 2 MiB | ||
21 | |||
22 | Fixes: c906a3a01582 ("i.MX: Add the Freescale SPI Controller") | ||
23 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
24 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
25 | Message-id: 20210129132323.30946-10-bmeng.cn@gmail.com | ||
26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | --- | ||
28 | hw/ssi/imx_spi.c | 2 +- | ||
29 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
30 | |||
31 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/ssi/imx_spi.c | ||
34 | +++ b/hw/ssi/imx_spi.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | ||
36 | |||
37 | DPRINTF("data tx:0x%08x\n", tx); | ||
38 | |||
39 | - tx_burst = MIN(s->burst_length, 32); | ||
40 | + tx_burst = (s->burst_length % 32) ? : 32; | ||
41 | |||
42 | rx = 0; | ||
43 | |||
44 | -- | ||
45 | 2.20.1 | ||
46 | |||
47 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Bin Meng <bin.meng@windriver.com> | ||
1 | 2 | ||
3 | The endianness of data exchange between tx and rx fifo is incorrect. | ||
4 | Earlier bytes are supposed to show up on MSB and later bytes on LSB, | ||
5 | ie: in big endian. The manual does not explicitly say this, but the | ||
6 | U-Boot and Linux driver codes have a swap on the data transferred | ||
7 | to tx fifo and from rx fifo. | ||
8 | |||
9 | With this change, U-Boot read from / write to SPI flash tests pass. | ||
10 | |||
11 | => sf test 1ff000 1000 | ||
12 | SPI flash test: | ||
13 | 0 erase: 0 ticks, 4096000 KiB/s 32768.000 Mbps | ||
14 | 1 check: 3 ticks, 1333 KiB/s 10.664 Mbps | ||
15 | 2 write: 235 ticks, 17 KiB/s 0.136 Mbps | ||
16 | 3 read: 2 ticks, 2000 KiB/s 16.000 Mbps | ||
17 | Test passed | ||
18 | 0 erase: 0 ticks, 4096000 KiB/s 32768.000 Mbps | ||
19 | 1 check: 3 ticks, 1333 KiB/s 10.664 Mbps | ||
20 | 2 write: 235 ticks, 17 KiB/s 0.136 Mbps | ||
21 | 3 read: 2 ticks, 2000 KiB/s 16.000 Mbps | ||
22 | |||
23 | Fixes: c906a3a01582 ("i.MX: Add the Freescale SPI Controller") | ||
24 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
26 | Message-id: 20210129132323.30946-11-bmeng.cn@gmail.com | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
28 | --- | ||
29 | hw/ssi/imx_spi.c | 7 ++----- | ||
30 | 1 file changed, 2 insertions(+), 5 deletions(-) | ||
31 | |||
32 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/hw/ssi/imx_spi.c | ||
35 | +++ b/hw/ssi/imx_spi.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | ||
37 | |||
38 | while (!fifo32_is_empty(&s->tx_fifo)) { | ||
39 | int tx_burst = 0; | ||
40 | - int index = 0; | ||
41 | |||
42 | if (s->burst_length <= 0) { | ||
43 | s->burst_length = imx_spi_burst_length(s); | ||
44 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | ||
45 | rx = 0; | ||
46 | |||
47 | while (tx_burst > 0) { | ||
48 | - uint8_t byte = tx & 0xff; | ||
49 | + uint8_t byte = tx >> (tx_burst - 8); | ||
50 | |||
51 | DPRINTF("writing 0x%02x\n", (uint32_t)byte); | ||
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | ||
54 | |||
55 | DPRINTF("0x%02x read\n", (uint32_t)byte); | ||
56 | |||
57 | - tx = tx >> 8; | ||
58 | - rx |= (byte << (index * 8)); | ||
59 | + rx = (rx << 8) | byte; | ||
60 | |||
61 | /* Remove 8 bits from the actual burst */ | ||
62 | tx_burst -= 8; | ||
63 | s->burst_length -= 8; | ||
64 | - index++; | ||
65 | } | ||
66 | |||
67 | DPRINTF("data rx:0x%08x\n", rx); | ||
68 | -- | ||
69 | 2.20.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
1 | From: Kaige Li <likaige@loongson.cn> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | GCC version 4.9.4 isn't clever enough to figure out that all | 3 | Per the ARM Generic Interrupt Controller Architecture specification |
4 | execution paths in disas_ldst() that use 'fn' will have initialized | 4 | (document "ARM IHI 0048B.b (ID072613)"), the SGIINTID field is 4 bit, |
5 | it first, and so it warns: | 5 | not 10: |
6 | 6 | ||
7 | /home/LiKaige/qemu/target/arm/translate-a64.c: In function ‘disas_ldst’: | 7 | - 4.3 Distributor register descriptions |
8 | /home/LiKaige/qemu/target/arm/translate-a64.c:3392:5: error: ‘fn’ may be used uninitialized in this function [-Werror=maybe-uninitialized] | 8 | - 4.3.15 Software Generated Interrupt Register, GICD_SG |
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 | 9 | ||
15 | Make it happy by initializing the variable to NULL. | 10 | - Table 4-21 GICD_SGIR bit assignments |
16 | 11 | ||
17 | Signed-off-by: Kaige Li <likaige@loongson.cn> | 12 | The Interrupt ID of the SGI to forward to the specified CPU |
18 | Message-id: 1596110248-7366-2-git-send-email-likaige@loongson.cn | 13 | interfaces. The value of this field is the Interrupt ID, in |
14 | the range 0-15, for example a value of 0b0011 specifies | ||
15 | Interrupt ID 3. | ||
16 | |||
17 | Correct the irq mask to fix an undefined behavior (which eventually | ||
18 | lead to a heap-buffer-overflow, see [Buglink]): | ||
19 | |||
20 | $ echo 'writel 0x8000f00 0xff4affb0' | qemu-system-aarch64 -M virt,accel=qtest -qtest stdio | ||
21 | [I 1612088147.116987] OPENED | ||
22 | [R +0.278293] writel 0x8000f00 0xff4affb0 | ||
23 | ../hw/intc/arm_gic.c:1498:13: runtime error: index 944 out of bounds for type 'uint8_t [16][8]' | ||
24 | SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../hw/intc/arm_gic.c:1498:13 | ||
25 | |||
26 | This fixes a security issue when running with KVM on Arm with | ||
27 | kernel-irqchip=off. (The default is kernel-irqchip=on, which is | ||
28 | unaffected, and which is also the correct choice for performance.) | ||
29 | |||
30 | Cc: qemu-stable@nongnu.org | ||
31 | Fixes: 9ee6e8bb853 ("ARMv7 support.") | ||
32 | Buglink: https://bugs.launchpad.net/qemu/+bug/1913916 | ||
33 | Buglink: https://bugs.launchpad.net/qemu/+bug/1913917 | ||
34 | Reported-by: Alexander Bulekov <alxndr@bu.edu> | ||
35 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
36 | Message-id: 20210131103401.217160-1-f4bug@amsat.org | ||
19 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 37 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
20 | [PMM: Clean up commit message and note which gcc version this was] | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 38 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 39 | --- |
23 | target/arm/translate-a64.c | 2 +- | 40 | hw/intc/arm_gic.c | 2 +- |
24 | 1 file changed, 1 insertion(+), 1 deletion(-) | 41 | 1 file changed, 1 insertion(+), 1 deletion(-) |
25 | 42 | ||
26 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 43 | diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c |
27 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/translate-a64.c | 45 | --- a/hw/intc/arm_gic.c |
29 | +++ b/target/arm/translate-a64.c | 46 | +++ b/hw/intc/arm_gic.c |
30 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | 47 | @@ -XXX,XX +XXX,XX @@ static void gic_dist_writel(void *opaque, hwaddr offset, |
31 | bool r = extract32(insn, 22, 1); | 48 | int target_cpu; |
32 | bool a = extract32(insn, 23, 1); | 49 | |
33 | TCGv_i64 tcg_rs, clean_addr; | 50 | cpu = gic_get_current_cpu(s); |
34 | - AtomicThreeOpFn *fn; | 51 | - irq = value & 0x3ff; |
35 | + AtomicThreeOpFn *fn = NULL; | 52 | + irq = value & 0xf; |
36 | 53 | switch ((value >> 24) & 3) { | |
37 | if (is_vector || !dc_isar_feature(aa64_atomics, s)) { | 54 | case 0: |
38 | unallocated_encoding(s); | 55 | mask = (value >> 16) & ALL_CPU_MASK; |
39 | -- | 56 | -- |
40 | 2.20.1 | 57 | 2.20.1 |
41 | 58 | ||
42 | 59 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | The STM32F405 SoC uses an OR gate on its ADC IRQs. | ||
4 | |||
5 | Fixes: 529fc5fd3e1 ("hw/arm: Add the STM32F4xx SoC") | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Message-id: 20210131184449.382425-2-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/arm/Kconfig | 1 + | ||
12 | 1 file changed, 1 insertion(+) | ||
13 | |||
14 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/arm/Kconfig | ||
17 | +++ b/hw/arm/Kconfig | ||
18 | @@ -XXX,XX +XXX,XX @@ config STM32F205_SOC | ||
19 | config STM32F405_SOC | ||
20 | bool | ||
21 | select ARM_V7M | ||
22 | + select OR_IRQ | ||
23 | select STM32F4XX_SYSCFG | ||
24 | select STM32F4XX_EXTI | ||
25 | |||
26 | -- | ||
27 | 2.20.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | The Exynos4210 SoC uses an OR gate on the PL330 IRQ lines. | ||
4 | |||
5 | Fixes: dab15fbe2ab ("hw/arm/exynos4210: Fix DMA initialization") | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Message-id: 20210131184449.382425-3-f4bug@amsat.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/arm/Kconfig | 1 + | ||
12 | 1 file changed, 1 insertion(+) | ||
13 | |||
14 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/arm/Kconfig | ||
17 | +++ b/hw/arm/Kconfig | ||
18 | @@ -XXX,XX +XXX,XX @@ config EXYNOS4 | ||
19 | select PTIMER | ||
20 | select SDHCI | ||
21 | select USB_EHCI_SYSBUS | ||
22 | + select OR_IRQ | ||
23 | |||
24 | config HIGHBANK | ||
25 | bool | ||
26 | -- | ||
27 | 2.20.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | The Versal SoC instantiates the TYPE_XLNX_ZDMA object in | ||
4 | versal_create_admas(). Introduce the XLNX_ZDMA configuration | ||
5 | and select it to fix: | ||
6 | |||
7 | $ qemu-system-aarch64 -M xlnx-versal-virt ... | ||
8 | qemu-system-aarch64: missing object type 'xlnx.zdma' | ||
9 | |||
10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
12 | Message-id: 20210131184449.382425-4-f4bug@amsat.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/arm/Kconfig | 2 ++ | ||
16 | hw/dma/Kconfig | 3 +++ | ||
17 | hw/dma/meson.build | 2 +- | ||
18 | 3 files changed, 6 insertions(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/arm/Kconfig | ||
23 | +++ b/hw/arm/Kconfig | ||
24 | @@ -XXX,XX +XXX,XX @@ config XLNX_ZYNQMP_ARM | ||
25 | select XILINX_AXI | ||
26 | select XILINX_SPIPS | ||
27 | select XLNX_ZYNQMP | ||
28 | + select XLNX_ZDMA | ||
29 | |||
30 | config XLNX_VERSAL | ||
31 | bool | ||
32 | @@ -XXX,XX +XXX,XX @@ config XLNX_VERSAL | ||
33 | select CADENCE | ||
34 | select VIRTIO_MMIO | ||
35 | select UNIMP | ||
36 | + select XLNX_ZDMA | ||
37 | |||
38 | config NPCM7XX | ||
39 | bool | ||
40 | diff --git a/hw/dma/Kconfig b/hw/dma/Kconfig | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/dma/Kconfig | ||
43 | +++ b/hw/dma/Kconfig | ||
44 | @@ -XXX,XX +XXX,XX @@ config ZYNQ_DEVCFG | ||
45 | bool | ||
46 | select REGISTER | ||
47 | |||
48 | +config XLNX_ZDMA | ||
49 | + bool | ||
50 | + | ||
51 | config STP2000 | ||
52 | bool | ||
53 | |||
54 | diff --git a/hw/dma/meson.build b/hw/dma/meson.build | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/dma/meson.build | ||
57 | +++ b/hw/dma/meson.build | ||
58 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ZYNQ_DEVCFG', if_true: files('xlnx-zynq-devcfg.c')) | ||
59 | softmmu_ss.add(when: 'CONFIG_ETRAXFS', if_true: files('etraxfs_dma.c')) | ||
60 | softmmu_ss.add(when: 'CONFIG_STP2000', if_true: files('sparc32_dma.c')) | ||
61 | softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx_dpdma.c')) | ||
62 | -softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zdma.c')) | ||
63 | +softmmu_ss.add(when: 'CONFIG_XLNX_ZDMA', if_true: files('xlnx-zdma.c')) | ||
64 | softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_dma.c', 'soc_dma.c')) | ||
65 | softmmu_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_dma.c')) | ||
66 | softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_dma.c')) | ||
67 | -- | ||
68 | 2.20.1 | ||
69 | |||
70 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | The Versal SoC instantiates the TYPE_XLNX_ZYNQMP_RTC object in | ||
4 | versal_create_rtc()(). Select CONFIG_XLNX_ZYNQMP to fix: | ||
5 | |||
6 | $ make check-qtest-aarch64 | ||
7 | ... | ||
8 | Running test qtest-aarch64/qom-test | ||
9 | qemu-system-aarch64: missing object type 'xlnx-zynmp.rtc' | ||
10 | Broken pipe | ||
11 | |||
12 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
14 | Message-id: 20210131184449.382425-5-f4bug@amsat.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/arm/Kconfig | 1 + | ||
18 | 1 file changed, 1 insertion(+) | ||
19 | |||
20 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/arm/Kconfig | ||
23 | +++ b/hw/arm/Kconfig | ||
24 | @@ -XXX,XX +XXX,XX @@ config XLNX_VERSAL | ||
25 | select VIRTIO_MMIO | ||
26 | select UNIMP | ||
27 | select XLNX_ZDMA | ||
28 | + select XLNX_ZYNQMP | ||
29 | |||
30 | config NPCM7XX | ||
31 | bool | ||
32 | -- | ||
33 | 2.20.1 | ||
34 | |||
35 | diff view generated by jsdifflib |
1 | Mostly devices don't need to care whether one of their output | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
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 | 2 | ||
7 | Provide a function qemu_irq_is_connected() that devices can use for | 3 | Add a dependency XLNX_ZYNQMP -> PTIMER to fix: |
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 | 4 | ||
5 | /usr/bin/ld: | ||
6 | libcommon.fa.p/hw_net_can_xlnx-zynqmp-can.c.o: in function `xlnx_zynqmp_can_realize': | ||
7 | hw/net/can/xlnx-zynqmp-can.c:1082: undefined reference to `ptimer_init' | ||
8 | hw/net/can/xlnx-zynqmp-can.c:1085: undefined reference to `ptimer_transaction_begin' | ||
9 | hw/net/can/xlnx-zynqmp-can.c:1087: undefined reference to `ptimer_set_freq' | ||
10 | hw/net/can/xlnx-zynqmp-can.c:1088: undefined reference to `ptimer_set_limit' | ||
11 | hw/net/can/xlnx-zynqmp-can.c:1089: undefined reference to `ptimer_run' | ||
12 | hw/net/can/xlnx-zynqmp-can.c:1090: undefined reference to `ptimer_transaction_commit' | ||
13 | libcommon.fa.p/hw_net_can_xlnx-zynqmp-can.c.o:(.data.rel+0x2c8): undefined reference to `vmstate_ptimer' | ||
14 | |||
15 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
16 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
17 | Message-id: 20210131184449.382425-6-f4bug@amsat.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | 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 | --- | 19 | --- |
17 | include/hw/irq.h | 18 ++++++++++++++++++ | 20 | hw/Kconfig | 1 + |
18 | 1 file changed, 18 insertions(+) | 21 | 1 file changed, 1 insertion(+) |
19 | 22 | ||
20 | diff --git a/include/hw/irq.h b/include/hw/irq.h | 23 | diff --git a/hw/Kconfig b/hw/Kconfig |
21 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/irq.h | 25 | --- a/hw/Kconfig |
23 | +++ b/include/hw/irq.h | 26 | +++ b/hw/Kconfig |
24 | @@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); | 27 | @@ -XXX,XX +XXX,XX @@ config XLNX_ZYNQMP |
25 | on an existing vector of qemu_irq. */ | 28 | bool |
26 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n); | 29 | select REGISTER |
27 | 30 | select CAN_BUS | |
28 | +/** | 31 | + select PTIMER |
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 | -- | 32 | -- |
48 | 2.20.1 | 33 | 2.20.1 |
49 | 34 | ||
50 | 35 | diff view generated by jsdifflib |
1 | The netduino2 and netduinoplus2 boards forgot to set the system_clock_scale | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
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 | 2 | ||
5 | Set the global to match the documented CPU clock speed of these boards. | 3 | Most of ARM machines display their CPU when QEMU list the available |
6 | Judging by the data sheet this is slightly simplistic because the | 4 | machines (-M help). Some machines do not. Fix to unify the help |
7 | SoC allows configuration of the SYSCLK source and frequency via the | 5 | output. |
8 | RCC (reset and clock control) module, but we don't model that. | ||
9 | 6 | ||
10 | Fixes: https://bugs.launchpad.net/qemu/+bug/1876187 | 7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Message-id: 20210131184449.382425-7-f4bug@amsat.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | 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 | --- | 13 | --- |
15 | hw/arm/netduino2.c | 10 ++++++++++ | 14 | hw/arm/digic_boards.c | 2 +- |
16 | hw/arm/netduinoplus2.c | 10 ++++++++++ | 15 | hw/arm/microbit.c | 2 +- |
17 | 2 files changed, 20 insertions(+) | 16 | hw/arm/netduino2.c | 2 +- |
17 | hw/arm/netduinoplus2.c | 2 +- | ||
18 | hw/arm/orangepi.c | 2 +- | ||
19 | hw/arm/stellaris.c | 4 ++-- | ||
20 | 6 files changed, 7 insertions(+), 7 deletions(-) | ||
18 | 21 | ||
22 | diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/hw/arm/digic_boards.c | ||
25 | +++ b/hw/arm/digic_boards.c | ||
26 | @@ -XXX,XX +XXX,XX @@ static void canon_a1100_init(MachineState *machine) | ||
27 | |||
28 | static void canon_a1100_machine_init(MachineClass *mc) | ||
29 | { | ||
30 | - mc->desc = "Canon PowerShot A1100 IS"; | ||
31 | + mc->desc = "Canon PowerShot A1100 IS (ARM946)"; | ||
32 | mc->init = &canon_a1100_init; | ||
33 | mc->ignore_memory_transaction_failures = true; | ||
34 | mc->default_ram_size = 64 * MiB; | ||
35 | diff --git a/hw/arm/microbit.c b/hw/arm/microbit.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/arm/microbit.c | ||
38 | +++ b/hw/arm/microbit.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void microbit_machine_class_init(ObjectClass *oc, void *data) | ||
40 | { | ||
41 | MachineClass *mc = MACHINE_CLASS(oc); | ||
42 | |||
43 | - mc->desc = "BBC micro:bit"; | ||
44 | + mc->desc = "BBC micro:bit (Cortex-M0)"; | ||
45 | mc->init = microbit_init; | ||
46 | mc->max_cpus = 1; | ||
47 | } | ||
19 | diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c | 48 | diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c |
20 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/netduino2.c | 50 | --- a/hw/arm/netduino2.c |
22 | +++ b/hw/arm/netduino2.c | 51 | +++ b/hw/arm/netduino2.c |
23 | @@ -XXX,XX +XXX,XX @@ | 52 | @@ -XXX,XX +XXX,XX @@ static void netduino2_init(MachineState *machine) |
24 | #include "hw/arm/stm32f205_soc.h" | 53 | |
25 | #include "hw/arm/boot.h" | 54 | static void netduino2_machine_init(MachineClass *mc) |
26 | |||
27 | +/* Main SYSCLK frequency in Hz (120MHz) */ | ||
28 | +#define SYSCLK_FRQ 120000000ULL | ||
29 | + | ||
30 | static void netduino2_init(MachineState *machine) | ||
31 | { | 55 | { |
32 | DeviceState *dev; | 56 | - mc->desc = "Netduino 2 Machine"; |
33 | 57 | + mc->desc = "Netduino 2 Machine (Cortex-M3)"; | |
34 | + /* | 58 | mc->init = netduino2_init; |
35 | + * TODO: ideally we would model the SoC RCC and let it handle | 59 | mc->ignore_memory_transaction_failures = true; |
36 | + * system_clock_scale, including its ability to define different | 60 | } |
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 | 61 | diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c |
45 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/hw/arm/netduinoplus2.c | 63 | --- a/hw/arm/netduinoplus2.c |
47 | +++ b/hw/arm/netduinoplus2.c | 64 | +++ b/hw/arm/netduinoplus2.c |
48 | @@ -XXX,XX +XXX,XX @@ | 65 | @@ -XXX,XX +XXX,XX @@ static void netduinoplus2_init(MachineState *machine) |
49 | #include "hw/arm/stm32f405_soc.h" | 66 | |
50 | #include "hw/arm/boot.h" | 67 | static void netduinoplus2_machine_init(MachineClass *mc) |
51 | |||
52 | +/* Main SYSCLK frequency in Hz (168MHz) */ | ||
53 | +#define SYSCLK_FRQ 168000000ULL | ||
54 | + | ||
55 | static void netduinoplus2_init(MachineState *machine) | ||
56 | { | 68 | { |
57 | DeviceState *dev; | 69 | - mc->desc = "Netduino Plus 2 Machine"; |
58 | 70 | + mc->desc = "Netduino Plus 2 Machine (Cortex-M4)"; | |
59 | + /* | 71 | mc->init = netduinoplus2_init; |
60 | + * TODO: ideally we would model the SoC RCC and let it handle | 72 | } |
61 | + * system_clock_scale, including its ability to define different | 73 | |
62 | + * possible SYSCLK sources. | 74 | diff --git a/hw/arm/orangepi.c b/hw/arm/orangepi.c |
63 | + */ | 75 | index XXXXXXX..XXXXXXX 100644 |
64 | + system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | 76 | --- a/hw/arm/orangepi.c |
65 | + | 77 | +++ b/hw/arm/orangepi.c |
66 | dev = qdev_new(TYPE_STM32F405_SOC); | 78 | @@ -XXX,XX +XXX,XX @@ static void orangepi_init(MachineState *machine) |
67 | qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); | 79 | |
68 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | 80 | static void orangepi_machine_init(MachineClass *mc) |
81 | { | ||
82 | - mc->desc = "Orange Pi PC"; | ||
83 | + mc->desc = "Orange Pi PC (Cortex-A7)"; | ||
84 | mc->init = orangepi_init; | ||
85 | mc->block_default_type = IF_SD; | ||
86 | mc->units_per_default_bus = 1; | ||
87 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/hw/arm/stellaris.c | ||
90 | +++ b/hw/arm/stellaris.c | ||
91 | @@ -XXX,XX +XXX,XX @@ static void lm3s811evb_class_init(ObjectClass *oc, void *data) | ||
92 | { | ||
93 | MachineClass *mc = MACHINE_CLASS(oc); | ||
94 | |||
95 | - mc->desc = "Stellaris LM3S811EVB"; | ||
96 | + mc->desc = "Stellaris LM3S811EVB (Cortex-M3)"; | ||
97 | mc->init = lm3s811evb_init; | ||
98 | mc->ignore_memory_transaction_failures = true; | ||
99 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m3"); | ||
100 | @@ -XXX,XX +XXX,XX @@ static void lm3s6965evb_class_init(ObjectClass *oc, void *data) | ||
101 | { | ||
102 | MachineClass *mc = MACHINE_CLASS(oc); | ||
103 | |||
104 | - mc->desc = "Stellaris LM3S6965EVB"; | ||
105 | + mc->desc = "Stellaris LM3S6965EVB (Cortex-M3)"; | ||
106 | mc->init = lm3s6965evb_init; | ||
107 | mc->ignore_memory_transaction_failures = true; | ||
108 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m3"); | ||
69 | -- | 109 | -- |
70 | 2.20.1 | 110 | 2.20.1 |
71 | 111 | ||
72 | 112 | diff view generated by jsdifflib |