Skip to content

Commit 7eb9984

Browse files
mriesch-wvjoergroedel
authored andcommitted
iommu/rockchip: fix permission bits in page table entries v2
As pointed out in the corresponding downstream fix [0], the permission bits of the page table entries are compatible between v1 and v2 of the IOMMU. This is in contrast to the current mainline code that incorrectly assumes that the read and write permission bits are switched. Fix the permission bits by reusing the v1 bit defines. [0] rockchip-linux/kernel@e3bc123 Fixes: c55356c ("iommu: rockchip: Add support for iommu v2") Signed-off-by: Michael Riesch <[email protected]> Reviewed-by: Heiko Stuebner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 30a0b95 commit 7eb9984

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/iommu/rockchip-iommu.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,17 @@ static u32 rk_mk_pte(phys_addr_t page, int prot)
280280
* 11:9 - Page address bit 34:32
281281
* 8:4 - Page address bit 39:35
282282
* 3 - Security
283-
* 2 - Readable
284-
* 1 - Writable
283+
* 2 - Writable
284+
* 1 - Readable
285285
* 0 - 1 if Page @ Page address is valid
286286
*/
287-
#define RK_PTE_PAGE_READABLE_V2 BIT(2)
288-
#define RK_PTE_PAGE_WRITABLE_V2 BIT(1)
289287

290288
static u32 rk_mk_pte_v2(phys_addr_t page, int prot)
291289
{
292290
u32 flags = 0;
293291

294-
flags |= (prot & IOMMU_READ) ? RK_PTE_PAGE_READABLE_V2 : 0;
295-
flags |= (prot & IOMMU_WRITE) ? RK_PTE_PAGE_WRITABLE_V2 : 0;
292+
flags |= (prot & IOMMU_READ) ? RK_PTE_PAGE_READABLE : 0;
293+
flags |= (prot & IOMMU_WRITE) ? RK_PTE_PAGE_WRITABLE : 0;
296294

297295
return rk_mk_dte_v2(page) | flags;
298296
}

0 commit comments

Comments
 (0)