x86/dpci: do not remove pirqs from domain tree on unbind
authorRoger Pau Monné <roger.pau@citrix.com>
Thu, 21 Jan 2021 15:11:41 +0000 (16:11 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 21 Jan 2021 15:11:41 +0000 (16:11 +0100)
commit58427889f5a420cc5226f88524b3228f90b72a58
tree4d0b5d54e5db0e7cfcace0680d06835f563e1dce
parente8adbf680b56a3f4b9600c7bcc04fec1877a6213
x86/dpci: do not remove pirqs from domain tree on unbind

A fix for a previous issue removed the pirqs from the domain tree when
they are unbound in order to prevent shared pirqs from triggering a
BUG_ON in __pirq_guest_unbind if they are unbound multiple times. That
caused free_domain_pirqs to no longer unmap the pirqs because they
are gone from the domain pirq tree, thus leaving stale unbound pirqs
after domain destruction if the domain had mapped dpci pirqs after
shutdown.

Take a different approach to fix the original issue, instead of
removing the pirq from d->pirq_tree clear the flags of the dpci pirq
struct to signal that the pirq is now unbound. This prevents calling
pirq_guest_unbind multiple times for the same pirq without having to
remove it from the domain pirq tree.

This is XSA-360.

Fixes: 5b58dad089 ('x86/pass-through: avoid double IRQ unbind during domain cleanup')
Reported-by: Samuel Verschelde <samuel.verschelde@vates.fr>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/irq.c
xen/drivers/passthrough/x86/hvm.c
xen/include/asm-x86/hvm/irq.h