IOMMU/x86: perform PV Dom0 mappings in batches
authorJan Beulich <jbeulich@suse.com>
Wed, 8 Jun 2022 15:03:32 +0000 (17:03 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 8 Jun 2022 15:03:32 +0000 (17:03 +0200)
commitf3185c165d28901c3222becfc8be547263c53745
treea1535b905db2346466cc391e27d4e1a910953fd0
parent7158e80c887d8b451c8525b7fe32049742814e69
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>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/pv/dom0_build.c
xen/drivers/passthrough/x86/iommu.c