From ec21c0b92f0969c43205648cac56f4e9e32eebe5 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Fri, 12 Feb 2021 14:03:06 -0800 Subject: [PATCH] kernel: mmu: fix boot address translation macros The Z_BOOT_VIRT_TO_PHYS() and Z_BOOT_PHYS_TO_VIRT() address translation macros are flipped in their calculations. The calculation is supposed to be: virt = phys + ((KERNEL_VM_BASE + KERNEL_VM_OFFSET) - SRAM_BASE_ADDRESS) So fix the them. Signed-off-by: Daniel Leung --- kernel/include/mmu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/include/mmu.h b/kernel/include/mmu.h index 5b62b9f1efc..34b77fb9fa7 100644 --- a/kernel/include/mmu.h +++ b/kernel/include/mmu.h @@ -47,8 +47,8 @@ * been remapped or paged out. Never use this unless you know exactly what you * are doing. */ -#define Z_BOOT_VIRT_TO_PHYS(virt) ((uintptr_t)(((uint8_t *)virt) + Z_VM_OFFSET)) -#define Z_BOOT_PHYS_TO_VIRT(phys) ((uint8_t *)(((uintptr_t)phys) - Z_VM_OFFSET)) +#define Z_BOOT_VIRT_TO_PHYS(virt) ((uintptr_t)(((uint8_t *)virt) - Z_VM_OFFSET)) +#define Z_BOOT_PHYS_TO_VIRT(phys) ((uint8_t *)(((uintptr_t)phys) + Z_VM_OFFSET)) #ifdef CONFIG_ARCH_MAPS_ALL_RAM #define Z_FREE_VM_START Z_BOOT_PHYS_TO_VIRT(Z_PHYS_RAM_END)