linux/drivers/iommu/amd
Jason Gunthorpe a95387d8f5 iommu/amd: Fix corruption when mapping large pages from 0
[ Upstream commit e3a682eaf2 ]

If a page is mapped starting at 0 that is equal to or larger than can fit
in the current mode (number of table levels) it results in corrupting the
mapping as the following logic assumes the mode is correct for the page
size being requested.

There are two issues here, the check if the address fits within the table
uses the start address, it should use the last address to ensure that last
byte of the mapping fits within the current table mode.

The second is if the mapping is exactly the size of the full page table it
has to add another level to instead hold a single IOPTE for the large
size.

Since both corner cases require a 0 IOVA to be hit and doesn't start until
a page size of 2^48 it is unlikely to ever hit in a real system.

Reported-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/0-v1-27ab08d646a1+29-amd_0map_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2024-12-14 20:04:00 +01:00
..
amd_iommu.h iommu/amd: Add kernel parameters to limit V1 page-sizes 2024-09-10 11:48:57 +02:00
amd_iommu_types.h iommu/amd: Add kernel parameters to limit V1 page-sizes 2024-09-10 11:48:57 +02:00
debugfs.c iommu/amd: Move AMD IOMMU driver into subdirectory 2020-06-10 17:46:42 +02:00
init.c iommu/amd: Add kernel parameters to limit V1 page-sizes 2024-09-10 11:48:57 +02:00
io_pgtable.c iommu/amd: Fix corruption when mapping large pages from 0 2024-12-14 20:04:00 +01:00
io_pgtable_v2.c iommu/amd/pgtbl_v2: Take protection domain lock before invalidating TLB 2024-12-05 14:02:06 +01:00
iommu.c Merge branches 'fixes', 'arm/smmu', 'intel/vt-d', 'amd/amd-vi' and 'core' into next 2024-09-13 12:53:05 +02:00
Kconfig iommu/amd: Fix compilation error 2024-05-03 12:12:16 +02:00
Makefile iommu/amd: Initial SVA support for AMD IOMMU 2024-04-26 12:16:05 +02:00
pasid.c iommu/amd: Store the nid in io_pgtable_cfg instead of the domain 2024-09-04 11:38:34 +02:00
ppr.c iommu/amd: Fix Invalid wait context issue 2024-06-04 14:00:59 +02:00
quirks.c iommu/amd: Include PCI segment ID when initialize IOMMU 2022-07-07 09:37:51 +02:00