IOMMU/x86: disallow device assignment to PoD guests
authorJan Beulich <jbeulich@suse.com>
Mon, 2 May 2022 06:48:02 +0000 (08:48 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 2 May 2022 06:48:02 +0000 (08:48 +0200)
commitad4312d764e8b40a1e45b64aac6d840a60c59f13
treed2ba9f84867dcd5339c545cb7504b38795e80128
parentfe234237b6fc8afc5d8265850169ceeb3d2f81fd
IOMMU/x86: disallow device assignment to PoD guests

While it is okay for IOMMU page tables to be set up for guests starting
in PoD mode, actual device assignment may only occur once all PoD
entries have been removed from the P2M. So far this was enforced only
for boot-time assignment, and only in the tool stack.

Also use the new function to replace p2m_pod_entry_count(): Its unlocked
access to p2m->pod.entry_count wasn't really okay (irrespective of the
result being stale by the time the caller gets to see it). Nor was the
use of that function in line with the immediately preceding comment: A
PoD guest isn't just one with a non-zero entry count, but also one with
a non-empty cache (e.g. prior to actually launching the guest).

To allow the tool stack to see a consistent snapshot of PoD state, move
the tail of XENMEM_{get,set}_pod_target handling into a function, adding
proper locking there.

In libxl take the liberty to use the new local variable r also for a
pre-existing call into libxc.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/include/asm/p2m.h
xen/arch/x86/mm.c
xen/arch/x86/mm/p2m-pod.c
xen/common/vm_event.c
xen/drivers/passthrough/x86/iommu.c