]> xenbits.xensource.com Git - xen.git/commit
x86/MSI-X: restrict reading of table/PBA bases from BARs
authorJan Beulich <jbeulich@suse.com>
Tue, 22 Sep 2020 15:17:47 +0000 (17:17 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Sep 2020 15:17:47 +0000 (17:17 +0200)
commit2fe163d70f3ae88c10f50d70a50513e395326a77
tree71a8e19e37f08f0d96517a8e9fa93a5704f02917
parent2031bd3f421d4923679121092a414adfcea16a95
x86/MSI-X: restrict reading of table/PBA bases from BARs

When assigned to less trusted or un-trusted guests, devices may change
state behind our backs (they may e.g. get reset by means we may not know
about). Therefore we should avoid reading BARs from hardware once a
device is no longer owned by Dom0. Furthermore when we can't read a BAR,
or when we read zero, we shouldn't instead use the caller provided
address unless that caller can be trusted.

Re-arrange the logic in msix_capability_init() such that only Dom0 (and
only if the device isn't DomU-owned yet) or calls through
PHYSDEVOP_prepare_msix will actually result in the reading of the
respective BAR register(s). Additionally do so only as long as in-use
table entries are known (note that invocation of PHYSDEVOP_prepare_msix
counts as a "pseudo" entry). In all other uses the value already
recorded will get used instead.

Clear the recorded values in _pci_cleanup_msix() as well as on the one
affected error path. (Adjust this error path to also avoid blindly
disabling MSI-X when it was enabled on entry to the function.)

While moving around variable declarations (in many cases to reduce their
scopes), also adjust some of their types.

This is part of XSA-337.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/msi.c