hw/arm/virt: Wire up non-secure EL2 virtual timer IRQ
commit1ec896fe7ca938276aea8cadc677263f7a3264bb
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 22 Jan 2024 14:35:36 +0000 (22 14:35 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 15 Feb 2024 11:31:52 +0000 (15 11:31 +0000)
treee7f619a00c464a195a06de0319a1b15412264758
parent6c1c2e912fcf915bfaf04ef42cbfe593c2df352f
hw/arm/virt: Wire up non-secure EL2 virtual timer IRQ

Armv8.1+ CPUs have the Virtual Host Extension (VHE) which adds a
non-secure EL2 virtual timer.  We implemented the timer itself in the
CPU model, but never wired up its IRQ line to the GIC.

Wire up the IRQ line (this is always safe whether the CPU has the
interrupt or not, since it always creates the outbound IRQ line).
Report it to the guest via dtb and ACPI if the CPU has the feature.

The DTB binding is documented in the kernel's
Documentation/devicetree/bindings/timer/arm\,arch_timer.yaml
and the ACPI table entries are documented in the ACPI specification
version 6.3 or later.

Because the IRQ line ACPI binding is new in 6.3, we need to bump the
FADT table rev to show that we might be using 6.3 features.

Note that exposing this IRQ in the DTB will trigger a bug in EDK2
versions prior to edk2-stable202311, for users who use the virt board
with 'virtualization=on' to enable EL2 emulation and are booting an
EDK2 guest BIOS, if that EDK2 has assertions enabled.  The effect is
that EDK2 will assert on bootup:

 ASSERT [ArmTimerDxe] /home/kraxel/projects/qemu/roms/edk2/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c(72): PropSize == 36 || PropSize == 48

If you see that assertion you should do one of:
 * update your EDK2 binaries to edk2-stable202311 or newer
 * use the 'virt-8.2' versioned machine type
 * not use 'virtualization=on'

(The versions shipped with QEMU itself have the fix.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Message-id: 20240122143537.233498-3-peter.maydell@linaro.org
hw/arm/virt-acpi-build.c
hw/arm/virt.c
include/hw/arm/virt.h