qemu/hw
Jan Klötzke 110684c9a6 hw/intc/arm_gic: fix spurious level triggered interrupts
On GICv2 and later, level triggered interrupts are pending when either
the interrupt line is asserted or the interrupt was made pending by a
GICD_ISPENDRn write. Making a level triggered interrupt pending by
software persists until either the interrupt is acknowledged or cleared
by writing GICD_ICPENDRn. As long as the interrupt line is asserted,
the interrupt is pending in any case.

This logic is transparently implemented in gic_test_pending() for
GICv1 and GICv2.  The function combines the "pending" irq_state flag
(used for edge triggered interrupts and software requests) and the
line status (tracked in the "level" field).  However, we also
incorrectly set the pending flag on a guest write to GICD_ISENABLERn
if the line of a level triggered interrupt was asserted.  This keeps
the interrupt pending even if the line is de-asserted after some
time.

This incorrect logic is a leftover of the initial 11MPCore GIC
implementation.  That handles things slightly differently to the
architected GICv1 and GICv2.  The 11MPCore TRM does not give a lot of
detail on the corner cases of its GIC's behaviour, and historically
we have not wanted to investigate exactly what it does in reality, so
QEMU's GIC model takes the approach of "retain our existing behaviour
for 11MPCore, and implement the architectural standard for later GIC
revisions".

On that basis, commit 8d999995e4 in 2013 is where we added the
"level-triggered interrupt with the line asserted" handling to
gic_test_pending(), and we deliberately kept the old behaviour of
gic_test_pending() for REV_11MPCORE.  That commit should have added
the "only if 11MPCore" condition to the setting of the pending bit on
writes to GICD_ISENABLERn, but forgot it.

Add the missing "if REV_11MPCORE" condition, so that our behaviour
on GICv1 and GICv2 matches the GIC architecture requirements.

Cc: qemu-stable@nongnu.org
Fixes: 8d999995e4 ("arm_gic: Fix GIC pending behavior")
Signed-off-by: Jan Klötzke <jan.kloetzke@kernkonzept.com>
Message-id: 20240911114826.3558302-1-jan.kloetzke@kernkonzept.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: expanded comment a little and converted to coding-style form;
 expanded commit message with the historical backstory]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-09-13 15:31:50 +01:00
..
9pfs hw/xen: Make XenDevOps structures const 2024-06-04 11:53:43 +02:00
acpi hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
adc hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
alpha alpha: switch boards to "default y" 2024-05-03 15:47:47 +02:00
arm hvf: arm: Implement and use hvf_get_physical_address_range 2024-09-13 15:31:47 +01:00
audio hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
avr avr: switch boards to "default y" 2024-05-03 15:47:47 +02:00
block hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
char hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
core hw/core/resettable: Remove transitional_function machinery 2024-09-13 15:31:46 +01:00
cpu hw: Add a Kconfig switch for the TYPE_CPU_CLUSTER device 2024-04-25 12:48:12 +02:00
cris cris: switch boards to "default y" 2024-05-03 15:47:47 +02:00
cxl hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
display hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
dma hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
fsi hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
gpio hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
hppa hw/hppa/machine: Replace g_memdup() by g_memdup2() 2024-05-08 19:42:45 +02:00
hyperv hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
i2c hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
i386 hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
ide hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
input hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
intc hw/intc/arm_gic: fix spurious level triggered interrupts 2024-09-13 15:31:50 +01:00
ipack hw/ipack: Constify VMState 2023-12-29 11:17:30 +11:00
ipmi hw/ipmi: Constify VMState 2023-12-29 11:17:30 +11:00
isa hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
loongarch hw/loongarch: Add acpi SPCR table support 2024-09-12 20:57:54 +08:00
m68k hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
mem hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
microblaze microblaze: switch boards to "default y" 2024-05-03 15:47:47 +02:00
mips hw/mips/loongson3_virt: Fix condition of IPI IOCSR connection 2024-08-20 00:28:24 +02:00
misc hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
net hw/net/can/xlnx-versal-canfd: Fix FIFO issues 2024-09-13 15:31:49 +01:00
nubus hw/nubus/nubus-device: Range check 'slot' property 2024-09-08 11:49:49 +02:00
nvme hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
nvram hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
openrisc kconfig: express dependency of individual boards on libfdt 2024-05-10 15:45:15 +02:00
pci hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci' 2024-09-11 09:46:04 -04:00
pci-bridge hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
pci-host hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
pcmcia
ppc hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
remote hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
riscv Revert "hw/riscv/virt.c: imsics DT: add '#msi-cells'" 2024-08-19 14:34:49 +10:00
rtc hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
rx kconfig: express dependency of individual boards on libfdt 2024-05-10 15:45:15 +02:00
s390x hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
scsi hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
sd hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
sensor hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
sh4 hw/sh4: Remove newline character in trace events 2024-06-10 13:05:27 -04:00
smbios smbios: make memory device size configurable per Machine 2024-07-22 20:15:41 -04:00
sparc hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
sparc64 hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
ssi hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
timer hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
tpm hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
tricore hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
ufs hw/ufs: minor bug fixes related to ufs-test 2024-09-06 18:04:16 +09:00
usb hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
vfio hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
virtio hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
watchdog hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
xen hw/xen: pvh-common: Add support for creating PCIe/GPEX 2024-09-04 16:50:43 +02:00
xenpv hw/xen: Register framebuffer backend via xen_backend_init() 2024-06-04 11:53:43 +02:00
xtensa hw/xtensa: require libfdt 2024-05-10 15:45:15 +02:00
Kconfig hw: Fix problem with the A*MPCORE switches in the Kconfig files 2024-04-25 12:48:12 +02:00
meson.build hw/rdma: Remove deprecated pvrdma device and rdmacm-mux helper 2024-04-24 16:03:38 +02:00