VT-d: free all-empty page tables
authorJan Beulich <jbeulich@suse.com>
Mon, 25 Jul 2022 13:40:41 +0000 (15:40 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 25 Jul 2022 13:40:41 +0000 (15:40 +0200)
commit00c400edd7f5fed59f109b38522a47cae9943b22
treeaa3799f056691e70cbc2e5f25a3b9ff019626594
parent2d1bb66d87c2bec712643593584821d056e3b97e
VT-d: free all-empty page tables

When a page table ends up with no present entries left, it can be
replaced by a non-present entry at the next higher level. The page table
itself can then be scheduled for freeing.

Note that while its output isn't used there yet,
pt_update_contig_markers() right away needs to be called in all places
where entries get updated, not just the one where entries get cleared.

Note further that while pt_update_contig_markers() updates perhaps
several PTEs within the table, since these are changes to "avail" bits
only I do not think that cache flushing would be needed afterwards. Such
cache flushing (of entire pages, unless adding yet more logic to me more
selective) would be quite noticable performance-wise (very prominent
during Dom0 boot).

Also note that cache sync-ing is likely more strict than necessary. This
is both to be on the safe side as well as to maintain the pattern of all
updates of (potentially) live tables being accompanied by a flush (if so
needed).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
xen/drivers/passthrough/vtd/iommu.c