swiotlb: Support aligned swiotlb buffers
authorDavid Stevens <stevensd@chromium.org>
Wed, 29 Sep 2021 02:32:59 +0000 (11:32 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:24:17 +0000 (14:24 +0200)
commit3e44e136560cb66dd5156889f811b870789b9499
treef5485dd39966d6d9f2e4334a10cfdc7e026a55e2
parent52d23f5f091509acda49b6b38edad96f175c06ff
swiotlb: Support aligned swiotlb buffers

commit e81e99bacc9f9347bda7808a949c1ce9fcc2bbf4 upstream.

Add an argument to swiotlb_tbl_map_single that specifies the desired
alignment of the allocated buffer. This is used by dma-iommu to ensure
the buffer is aligned to the iova granule size when using swiotlb with
untrusted sub-granule mappings. This addresses an issue where adjacent
slots could be exposed to the untrusted device if IO_TLB_SIZE < iova
granule < PAGE_SIZE.

Signed-off-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210929023300.335969-7-stevensd@google.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Cc: Mario Limonciello <Mario.Limonciello@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iommu/dma-iommu.c
drivers/xen/swiotlb-xen.c
include/linux/swiotlb.h
kernel/dma/swiotlb.c