xen/arm: Do not invalidate the P2M when the PT is shared with the IOMMU
authorStefano Stabellini <sstabellini@kernel.org>
Wed, 4 Aug 2021 20:57:07 +0000 (13:57 -0700)
committerStefano Stabellini <sstabellini@kernel.org>
Thu, 5 Aug 2021 23:27:52 +0000 (16:27 -0700)
commit2b45ff60301a988badec526846e77b538383ae63
tree8e43264b7ae02a7979de34f17c39fe3e11d25b67
parent2278d2cbb0b7c1b48b298c6c4c6a7de2271ac928
xen/arm: Do not invalidate the P2M when the PT is shared with the IOMMU

Set/Way flushes never work correctly in a virtualized environment.

Our current implementation is based on clearing the valid bit in the p2m
pagetable to track guest memory accesses. This technique doesn't work
when the IOMMU is enabled for the domain and the pagetable is shared
between IOMMU and MMU because it triggers IOMMU faults.

Specifically, p2m_invalidate_root causes IOMMU faults if
iommu_use_hap_pt returns true for the domain.

Add a check in p2m_set_way_flush: if a set/way instruction is used
and iommu_use_hap_pt returns true, rather than failing with obscure
IOMMU faults, inject an undef exception straight away into the guest,
and print a verbose error message to explain the problem.

Also add an ASSERT in p2m_invalidate_root to make sure we don't
inadvertently stumble across this problem again in the future.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
xen/arch/arm/arm64/vsysreg.c
xen/arch/arm/p2m.c
xen/arch/arm/vcpreg.c
xen/include/asm-arm/p2m.h