]> 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 13:48:26 +0000 (15:48 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Sep 2020 13:48:26 +0000 (15:48 +0200)
commitbeb54596cfdaf15f6a86d7b1bf84ca8a0b9c6b9b
tree7a4ecfa9c1d5ce37f439529e39e93efb387ec0d6
parentcb5e9730862ba0c99e81d3fbd8f65010707245e4
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