IOMMU/x86: perform PV Dom0 mappings in batches
authorJan Beulich <jbeulich@suse.com>
Mon, 25 Jul 2022 13:32:59 +0000 (15:32 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 25 Jul 2022 13:32:59 +0000 (15:32 +0200)
commitc1e1564c8995d8a08891bd9313e4289bbe4662b4
tree20e4d23a26b7aa93c0a31399538a904533f56315
parentc519819ff5c61ae8b36509c9e8ed9d2a2fdac886
IOMMU/x86: perform PV Dom0 mappings in batches

For large page mappings to be easily usable (i.e. in particular without
un-shattering of smaller page mappings) and for mapping operations to
then also be more efficient, pass batches of Dom0 memory to iommu_map().
In dom0_construct_pv() and its helpers (covering strict mode) this
additionally requires establishing the type of those pages (albeit with
zero type references).

The earlier establishing of PGT_writable_page | PGT_validated requires
the existing places where this gets done (through get_page_and_type())
to be updated: For pages which actually have a mapping, the type
refcount needs to be 1.

There is actually a related bug that gets fixed here as a side effect:
Typically the last L1 table would get marked as such only after
get_page_and_type(..., PGT_writable_page). While this is fine as far as
refcounting goes, the page did remain mapped in the IOMMU in this case
(when "iommu=dom0-strict").

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
xen/arch/x86/pv/dom0_build.c
xen/drivers/passthrough/x86/iommu.c