iommu/iova: Avoid over-allocating when size-aligned
authorRobin Murphy <robin.murphy@arm.com>
Thu, 16 Jul 2015 18:40:12 +0000 (19:40 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Tue, 28 Jul 2015 14:47:56 +0000 (15:47 +0100)
Currently, allocating a size-aligned IOVA region quietly adjusts the
actual allocation size in the process, returning a rounded-up
power-of-two-sized allocation. This results in mismatched behaviour in
the IOMMU driver if the original size was not a power of two, where the
original size is mapped, but the rounded-up IOVA size is unmapped.

Whilst some IOMMUs will happily unmap already-unmapped pages, others
consider this an error, so fix it by computing the necessary alignment
padding without altering the actual allocation size. Also clean up by
making pad_size unsigned, since its callers always pass unsigned values
and negative padding makes little sense here anyway.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/iommu/intel-iommu.c
drivers/iommu/iova.c

Simple merge
Simple merge