KVM: PPC: Book3S: Fix matching of hardware and emulated TCE tables
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Wed, 20 Jun 2018 08:42:58 +0000 (18:42 +1000)
committerPaul Mackerras <paulus@ozlabs.org>
Wed, 18 Jul 2018 05:14:45 +0000 (15:14 +1000)
commit76346cd93a5eca33700f82685d56172dd65d4c0a
tree7e7480d4e20f5bc7943067d2899f4938a30a470a
parent4eeb85568e5653c71d901f7593d3f3e7e2a5414f
KVM: PPC: Book3S: Fix matching of hardware and emulated TCE tables

When attaching a hardware table to LIOBN in KVM, we match table parameters
such as page size, table offset and table size. However the tables are
created via very different paths - VFIO and KVM - and the VFIO path goes
through the platform code which has minimum TCE page size requirement
(which is 4K but since we allocate memory by pages and cannot avoid
alignment anyway, we align to 64k pages for powernv_defconfig).

So when we match the tables, one might be bigger that the other which
means the hardware table cannot get attached to LIOBN and DMA mapping
fails.

This removes the table size alignment from the guest visible table.
This does not affect the memory allocation which is still aligned -
kvmppc_tce_pages() takes care of this.

This relaxes the check we do when attaching tables to allow the hardware
table be bigger than the guest visible table.

Ideally we want the KVM table to cover the same space as the hardware
table does but since the hardware table may use multiple levels, and
all levels must use the same table size (IODA2 design), the area it can
actually cover might get very different from the window size which
the guest requested, even though the guest won't map it all.

Fixes: ca1fc489cf "KVM: PPC: Book3S: Allow backing bigger guest IOMMU pages with smaller physical pages"
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/kvm/book3s_64_vio.c