]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
arm64: mm: Cast start/end markers to char *, not u64
authorSam Edwards <cfsworks@gmail.com>
Thu, 4 Sep 2025 00:52:07 +0000 (17:52 -0700)
committerWill Deacon <will@kernel.org>
Tue, 16 Sep 2025 19:39:49 +0000 (20:39 +0100)
There are a few memset() calls in map_kernel.c that cast marker-symbol
addresses to u64 in order to perform pointer subtraction (range size
computation).

Cast them with (char *) instead, aligning with idiomatic C pointer
arithmetic.

This patch provably has no effect at runtime: I have verified that
.text of vmlinux is identical after this change.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/pi/map_kernel.c

index 0f4bd77718590c970710f132aaca42f3790f01ef..2b30478602307364b5aa06c410f6ed03b7caefa0 100644 (file)
@@ -179,7 +179,7 @@ static void __init remap_idmap_for_lpa2(void)
         * Don't bother with the FDT, we no longer need it after this.
         */
        memset(init_idmap_pg_dir, 0,
-              (u64)init_idmap_pg_end - (u64)init_idmap_pg_dir);
+              (char *)init_idmap_pg_end - (char *)init_idmap_pg_dir);
 
        create_init_idmap(init_idmap_pg_dir, mask);
        dsb(ishst);
@@ -188,7 +188,7 @@ static void __init remap_idmap_for_lpa2(void)
        set_ttbr0_for_lpa2((u64)init_idmap_pg_dir);
 
        /* wipe the temporary ID map from memory */
-       memset(init_pg_dir, 0, (u64)init_pg_end - (u64)init_pg_dir);
+       memset(init_pg_dir, 0, (char *)init_pg_end - (char *)init_pg_dir);
 }
 
 static void __init map_fdt(u64 fdt)
@@ -242,7 +242,7 @@ asmlinkage void __init early_map_kernel(u64 boot_status, void *fdt)
        map_fdt((u64)fdt);
 
        /* Clear BSS and the initial page tables */
-       memset(__bss_start, 0, (u64)init_pg_end - (u64)__bss_start);
+       memset(__bss_start, 0, (char *)init_pg_end - (char *)__bss_start);
 
        /* Parse the command line for CPU feature overrides */
        chosen = fdt_path_offset(fdt, chosen_str);