AMD/IOMMU: update live PTEs atomically
authorJan Beulich <jbeulich@suse.com>
Tue, 20 Oct 2020 12:39:41 +0000 (14:39 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Oct 2020 12:39:41 +0000 (14:39 +0200)
commitf7ab0c1a8ce47d6362134cc99354874bcad2fc12
tree755906bba6f7ea6cd540824a3564cf6fd6fd1cdb
parent7339975f552c99f74c73ee37073bac01a81825be
AMD/IOMMU: update live PTEs atomically

Updating a live PTE bitfield by bitfield risks the compiler re-ordering
the individual updates as well as splitting individual updates into
multiple memory writes. Construct the new entry fully in a local
variable, do the check to determine the flushing needs on the thus
established new entry, and then write the new entry by a single insn.

Similarly using memset() to clear a PTE is unsafe, as the order of
writes the function does is, at least in principle, undefined.

This is part of XSA-347.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
master commit: 3b055121c5410e2c3105d6d06aa24ca0d58868cd
master date: 2020-10-20 14:22:52 +0200
xen/drivers/passthrough/amd/iommu_map.c