IOMMU/x86: disallow device assignment to PoD guests
authorJan Beulich <jbeulich@suse.com>
Tue, 7 Jun 2022 12:03:20 +0000 (14:03 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 7 Jun 2022 12:03:20 +0000 (14:03 +0200)
commit838f6c211f7f05f107e1acdfb0977ab61ec0bf2e
tree304f18567d335c01ed4edd719bada76a9e53c0a8
parent4cf9a7c7bdb9d544fbac81105bbc1059ba3dd932
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>
master commit: ad4312d764e8b40a1e45b64aac6d840a60c59f13
master date: 2022-05-02 08:48:02 +0200
xen/arch/x86/mm.c
xen/arch/x86/mm/p2m-pod.c
xen/common/vm_event.c
xen/drivers/passthrough/x86/iommu.c
xen/include/asm-x86/p2m.h