amd/iommu: fix flush checks
authorRoger Pau Monné <roger.pau@citrix.com>
Tue, 20 Nov 2018 14:29:40 +0000 (15:29 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Nov 2018 14:29:40 +0000 (15:29 +0100)
commit086a9dded27eb39a74f1d51ca19c0e14a0cab277
treede64ef178095dc5e136a305feb43390f87ab7ee6
parentdea9fc0e02d92f5e6d46680aa0a52fa758eca9c4
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>
master commit: 1a7ffe466cd057daaef245b0a1ab6b82588e4c01
master date: 2018-11-20 14:52:12 +0100
xen/drivers/passthrough/amd/iommu_map.c