]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
arm64: Clear the initial ID map correctly before remapping
authorZenghui Yu <yuzenghui@huawei.com>
Fri, 21 Jun 2024 09:28:09 +0000 (17:28 +0800)
committerWill Deacon <will@kernel.org>
Mon, 24 Jun 2024 11:37:46 +0000 (12:37 +0100)
In the attempt to clear and recreate the initial ID map for LPA2, we
wrongly use 'start - end' as the map size and make the memset() almost a
nop.

Fix it by passing the correct map size.

Fixes: 9684ec186f8f ("arm64: Enable LPA2 at boot if supported by the system")
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20240621092809.162-1-yuzenghui@huawei.com
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/pi/map_kernel.c

index 5fa08e13e17e524aba5ee92061c1ad3ebc3bedcb..f374a3e5a5fe10b0a0491edaf1a31a7f62602606 100644 (file)
@@ -173,7 +173,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_dir - (u64)init_idmap_pg_end);
+              (u64)init_idmap_pg_end - (u64)init_idmap_pg_dir);
 
        create_init_idmap(init_idmap_pg_dir, mask);
        dsb(ishst);