xen/arm64: Don't blindly unmask interrupts on trap without a change of level
authorJulien Grall <julien.grall@arm.com>
Mon, 7 Oct 2019 17:10:56 +0000 (18:10 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 31 Oct 2019 15:22:55 +0000 (16:22 +0100)
commit3ed885a8874003f6011460f4f46d1d130dd6b2db
tree8b6ef8bbf506ac7847af409470dfb01ed8206464
parent61b683571f0abd12395b1454cd055f2ad9bb3a37
xen/arm64: Don't blindly unmask interrupts on trap without a change of level

Some of the traps without a change of the level (i.e. hypervisor ->
hypervisor) will unmask interrupts regardless the state of them in the
interrupted context.

One of the consequences is IRQ will be unmasked when receiving a
synchronous exception (used by WARN*()). This could result to unexpected
behavior such as deadlock (if a lock was shared with interrupts).

In a nutshell, interrupts should only be unmasked when it is safe to
do. Xen only unmask IRQ and Abort interrupts, so the logic can stay
simple:
    - hyp_error: All the interrupts are now kept masked. SError should
      be pretty rare and if ever happen then we most likely want to
      avoid any other interrupts to be generated. The potential main
      "caller" is during virtual SError synchronization on the exit
      path from the guest (see check_pending_vserror).

    - hyp_sync: The interrupts state is inherited from the interrupted
      context.

    - hyp_irq: All the interrupts but IRQ state are inherited from the
      interrupted context. IRQ is kept masked.

This is part of XSA-303.

Reported-by: Julien Grall <Julien.Grall@arm.com>
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
xen/arch/arm/arm64/entry.S