evtchn: arrange for preemption in evtchn_destroy()
authorJan Beulich <jbeulich@suse.com>
Tue, 22 Sep 2020 13:52:36 +0000 (15:52 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Sep 2020 13:52:36 +0000 (15:52 +0200)
commit8fe7b5f9960f4d9ec46787af394d180c39c6b2db
treee7949a05706b2693f68c7f8a8ad4436bcef30dcd
parente045199c7c9c5433d7f1461a741ed539a75cbfad
evtchn: arrange for preemption in evtchn_destroy()

Especially closing of fully established interdomain channels can take
quite some time, due to the locking involved. Therefore we shouldn't
assume we can clean up still active ports all in one go. Besides adding
the necessary preemption check, also avoid pointlessly starting from
(or now really ending at) 0; 1 is the lowest numbered port which may
need closing.

Since we're now reducing ->valid_evtchns, free_xen_event_channel(),
and (at least to be on the safe side) notify_via_xen_event_channel()
need to cope with attempts to close / unbind from / send through already
closed (and no longer valid, as per port_is_valid()) ports.

This is part of XSA-344.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/common/domain.c
xen/common/event_channel.c
xen/include/xen/sched.h