amd/iommu: fix flush checks
authorRoger Pau Monné <roger.pau@citrix.com>
Tue, 20 Nov 2018 13:52:12 +0000 (14:52 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Nov 2018 13:52:12 +0000 (14:52 +0100)
commit1a7ffe466cd057daaef245b0a1ab6b82588e4c01
tree648d95542b66c8184645d65b250398ec6a4362f1
parent39611fdee5d138d4d39dc997051c3a7dd23b6df9
amd/iommu: fix flush checks

Flush checking for AMD IOMMU didn't check whether the previous entry
was present, or whether the flags (writable/readable) changed in order
to decide whether a flush should be executed.

Fix this by taking the writable/readable/next-level fields into account,
together with the present bit.

Along these lines the flushing in amd_iommu_map_page() must not be
omitted for PV domains. The comment there was simply wrong: Mappings may
very well change, both their addresses and their permissions. Ultimately
this should honor iommu_dont_flush_iotlb, but to achieve this
amd_iommu_ops first needs to gain an .iotlb_flush hook.

Also make clear_iommu_pte_present() static, to demonstrate there's no
caller omitting the (subsequent) flush.

This is part of XSA-275.

Reported-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen/drivers/passthrough/amd/iommu_map.c