]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
lib/logic_iomem: Fix operation on 32-bit
authorJohannes Berg <johannes.berg@intel.com>
Wed, 15 Sep 2021 18:30:22 +0000 (20:30 +0200)
committerPaolo Pisati <paolo.pisati@canonical.com>
Fri, 28 Jan 2022 09:59:39 +0000 (10:59 +0100)
BugLink: https://bugs.launchpad.net/bugs/1959376
[ Upstream commit 4e8a5edac5010820e7c5303fc96f5a262e096bb6 ]

On 32-bit, the first entry might be at 0/NULL, but that's
strange and leads to issues, e.g. where we check "if (ret)".
Use a IOREMAP_BIAS/IOREMAP_MASK of 0x80000000UL to avoid
this. This then requires reducing the number of areas (via
MAX_AREAS), but we still have 128 areas, which is enough.

Fixes: ca2e334232b6 ("lib: add iomem emulation (logic_iomem)")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
lib/logic_iomem.c

index 54fa601f3300b68de041fc53ff5f682b011ae6fa..549b22d4bcde1a1f5d0933a8df954c99847dfc91 100644 (file)
@@ -21,15 +21,15 @@ struct logic_iomem_area {
 
 #define AREA_SHIFT     24
 #define MAX_AREA_SIZE  (1 << AREA_SHIFT)
-#define MAX_AREAS      ((1ULL<<32) / MAX_AREA_SIZE)
+#define MAX_AREAS      ((1U << 31) / MAX_AREA_SIZE)
 #define AREA_BITS      ((MAX_AREAS - 1) << AREA_SHIFT)
 #define AREA_MASK      (MAX_AREA_SIZE - 1)
 #ifdef CONFIG_64BIT
 #define IOREMAP_BIAS   0xDEAD000000000000UL
 #define IOREMAP_MASK   0xFFFFFFFF00000000UL
 #else
-#define IOREMAP_BIAS   0
-#define IOREMAP_MASK   0
+#define IOREMAP_BIAS   0x80000000UL
+#define IOREMAP_MASK   0x80000000UL
 #endif
 
 static DEFINE_MUTEX(regions_mtx);