qemu/hw/char
Chung-Yi Chen 70fe5ae121 hw/char/bcm2835_aux: Fix incorrect interrupt ID when RX disabled
Fix a misconfiguration issue in the read implementation of the
AUX_MU_IIR_REG register. This issue can lead to a transmit interrupt
being incorrectly interpreted as a receive interrupt when the receive
interrupt is disabled and the receive FIFO holds valid bytes.

The AUX_MU_IIR_REG register (interrupt ID bits [2:1]) indicates the
status of mini UART interrupts:

    - 00: No interrupts
    - 01: Transmit FIFO is empty
    - 10: Receive FIFO is not empty
    - 11: <Not possible>

When the transmit interrupt is enabled and the receive interrupt is
disabled, the original code incorrectly sets the interrupt ID bits.
Specifically:

    1. Transmit FIFO empty, receive FIFO empty
        - Expected 0b01, returned 0b01 (correct)
    2. Transmit FIFO empty, receive FIFO not empty
        - Expected 0b01, returned 0b10 (incorrect)

In the second case, the code sets the interrupt ID to 0b10 (receive FIFO
is not empty) even if the receive interrupt is disabled.

To fix this, the patch adds additional condition for setting the
interrupt ID bits to also check if the receive interrupt is enabled.

Reference: BCM2835 ARM Peripherals, page 13. Available on
https://datasheets.raspberrypi.com/bcm2835/bcm2835-peripherals.pdf

Fixes: 97398d900c ("bcm2835_aux: add emulation of BCM2835 AUX (aka  UART1) block")
Signed-off-by: Chung-Yi Chen <yeechen0207@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250328123725.94176-1-yeechen0207@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2025-03-31 21:32:43 +02:00
..
avr_usart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
bcm2835_aux.c hw/char/bcm2835_aux: Fix incorrect interrupt ID when RX disabled 2025-03-31 21:32:43 +02:00
cadence_uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
cmsdk-apb-uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
debugcon.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
digic-uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
diva-gsp.c hw/char: Add emulation of Diva GSP PCI management boards 2025-02-04 22:57:34 +01:00
escc.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
exynos4210_uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
goldfish_tty.c Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
grlib_apbuart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
ibex_uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
imx_serial.c hw/char/imx_serial: Really use RX FIFO depth 2025-03-04 14:45:34 +01:00
ipoctal232.c hw/ipack: Remove legacy qemu_allocate_irqs() use 2025-01-31 19:36:44 +01:00
Kconfig rust: Kconfig: Factor out whether PL011 is Rust or C 2025-03-20 09:23:18 +01:00
mcf_uart.c hw/char/mcf_uart: Really use RX FIFO depth 2025-03-04 14:45:34 +01:00
mchp_pfsoc_mmuart.c hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
meson.build rust: Kconfig: Factor out whether PL011 is Rust or C 2025-03-20 09:23:18 +01:00
nrf51_uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
omap_uart.c * pc: Add a description for the i8042 property 2024-10-04 19:28:37 +01:00
parallel-isa.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
parallel.c Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
pl011.c Revert "hw/char/pl011: Warn when using disabled receiver" 2025-03-14 12:54:33 +00:00
renesas_sci.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
riscv_htif.c hw/char/riscv_htif: Convert HTIF_DEBUG() to trace events 2025-01-19 09:44:35 +10:00
sclpconsole-lm.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
sclpconsole.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
serial-isa.c Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
serial-mm.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
serial-pci-multi.c hw/char/pci-multi: Convert legacy qemu_allocate_irqs to qemu_init_irq 2025-01-31 19:36:44 +01:00
serial-pci.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
serial.c Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
sh_serial.c hw/char/sh_serial: Return correct number of empty RX FIFO elements 2025-03-04 14:45:34 +01:00
shakti_uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
sifive_uart.c hw/char/sifive_uart: Free fifo on unrealize 2025-03-04 14:45:34 +01:00
spapr_vty.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
stm32f2xx_usart.c hw/char/stm32f2xx_usart: replace print with trace 2025-01-13 17:16:04 +01:00
stm32l4x5_usart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
terminal3270.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
trace-events hw/char/pl011: Improve RX flow tracing events 2025-03-04 14:45:34 +01:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
virtio-console.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
virtio-serial-bus.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
xen_console.c hw/xen: Fix errp handling in xen_console 2025-01-15 17:09:11 +00:00
xilinx_uartlite.c hw/char/xilinx_uartlite: Make device endianness configurable 2025-02-16 14:34:51 +01:00