iommu/vt-d: Fix PASID table allocation
authorDavid Woodhouse <dwmw2@infradead.org>
Mon, 12 Sep 2016 02:49:11 +0000 (10:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Dec 2016 08:10:30 +0000 (09:10 +0100)
commit8b23f16343f6e1b7ffc3d4f2cd2239bcb97bfbb3
tree3c7f4c84ce1a1aae05f55e0465aa30bcb7b2ac1a
parent36bd5bfe43496f6bb9ab512af46c95b8d152ee99
iommu/vt-d: Fix PASID table allocation

commit 910170442944e1f8674fd5ddbeeb8ccd1877ea98 upstream.

Somehow I ended up with an off-by-three error in calculating the size of
the PASID and PASID State tables, which triggers allocations failures as
those tables unfortunately have to be physically contiguous.

In fact, even the *correct* maximum size of 8MiB is problematic and is
wont to lead to allocation failures. Since I have extracted a promise
that this *will* be fixed in hardware, I'm happy to limit it on the
current hardware to a maximum of 0x20000 PASIDs, which gives us 1MiB
tables — still not ideal, but better than before.

Reported by Mika Kuoppala <mika.kuoppala@linux.intel.com> and also by
Xunlei Pang <xlpang@redhat.com> who submitted a simpler patch to fix
only the allocation (and not the free) to the "correct" limit... which
was still problematic.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iommu/intel-svm.c
include/linux/intel-iommu.h