From 2d2bbc05d6259ff27a070fa4747e35e1a1a2489f Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Thu, 6 Jun 2024 14:35:05 -0700 Subject: [PATCH] kernel: mm: rename Z_VM_KERNEL to K_MEM_IS_VM_KERNEL This is part of a series to move memory management functions away from the z_ namespace and into its own namespace. Signed-off-by: Daniel Leung --- arch/x86/core/ia32/crt0.S | 8 ++++---- arch/x86/core/x86_mmu.c | 4 ++-- boards/qemu/x86/qemu_x86_tiny.ld | 6 +++--- include/zephyr/arch/x86/ia32/linker.ld | 2 +- include/zephyr/arch/x86/memory.ld | 4 ++-- include/zephyr/kernel/internal/mm.h | 5 ++++- include/zephyr/linker/linker-tool-gcc.h | 10 +++++----- 7 files changed, 21 insertions(+), 18 deletions(-) diff --git a/arch/x86/core/ia32/crt0.S b/arch/x86/core/ia32/crt0.S index b7d42d94f10..26500079a02 100644 --- a/arch/x86/core/ia32/crt0.S +++ b/arch/x86/core/ia32/crt0.S @@ -89,7 +89,7 @@ orl $(CR0_PG | CR0_WP), %eax movl %eax, %cr0 -#ifdef Z_VM_KERNEL +#ifdef K_MEM_IS_VM_KERNEL /* Jump to a virtual address, which works because the identity and * virtual mappings both are to the same physical address. */ @@ -98,7 +98,7 @@ vm_enter: /* We are now executing in virtual memory. We'll un-map the identity * mappings later once we are in the C domain */ -#endif /* Z_VM_KERNEL */ +#endif /* K_MEM_IS_VM_KERNEL */ #endif /* CONFIG_X86_MMU */ .endm @@ -244,7 +244,7 @@ __csSet: ltr %ax #endif -#ifdef Z_VM_KERNEL +#ifdef K_MEM_IS_VM_KERNEL /* Need to reset the stack to virtual address after * page table is loaded. */ @@ -255,7 +255,7 @@ __csSet: #else addl $CONFIG_ISR_STACK_SIZE, %esp #endif -#endif /* Z_VM_KERNEL */ +#endif /* K_MEM_IS_VM_KERNEL */ #ifdef CONFIG_THREAD_LOCAL_STORAGE pushl %esp diff --git a/arch/x86/core/x86_mmu.c b/arch/x86/core/x86_mmu.c index f1d3adab797..18ef47e1de6 100644 --- a/arch/x86/core/x86_mmu.c +++ b/arch/x86/core/x86_mmu.c @@ -1307,7 +1307,7 @@ void arch_mem_unmap(void *addr, size_t size) ARG_UNUSED(ret); } -#ifdef Z_VM_KERNEL +#ifdef K_MEM_IS_VM_KERNEL __boot_func static void identity_map_remove(uint32_t level) { @@ -1346,7 +1346,7 @@ static void identity_map_remove(uint32_t level) __boot_func void z_x86_mmu_init(void) { -#ifdef Z_VM_KERNEL +#ifdef K_MEM_IS_VM_KERNEL /* We booted with physical address space being identity mapped. * As we are now executing in virtual address space, * the identity map is no longer needed. So remove them. diff --git a/boards/qemu/x86/qemu_x86_tiny.ld b/boards/qemu/x86/qemu_x86_tiny.ld index 78170d2e741..c3188c6e891 100644 --- a/boards/qemu/x86/qemu_x86_tiny.ld +++ b/boards/qemu/x86/qemu_x86_tiny.ld @@ -25,7 +25,7 @@ * the same as its physical location, although an identity mapping for RAM * is still supported by setting CONFIG_KERNEL_VM_BASE=CONFIG_SRAM_BASE_ADDRESS. */ -#ifdef Z_VM_KERNEL +#ifdef K_MEM_IS_VM_KERNEL #define KERNEL_BASE_ADDR \ (CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) @@ -55,7 +55,7 @@ MEMORY { -#if defined(Z_VM_KERNEL) +#if defined(K_MEM_IS_VM_KERNEL) ROM (rx) : ORIGIN = PHYS_LOAD_ADDR, LENGTH = PHYS_RAM_AVAIL #endif RAM (wx) : ORIGIN = KERNEL_BASE_ADDR, LENGTH = KERNEL_RAM_SIZE @@ -75,7 +75,7 @@ MEMORY IDT_LIST : ORIGIN = 0xFFFF1000, LENGTH = 2K } -#if defined(Z_VM_KERNEL) +#if defined(K_MEM_IS_VM_KERNEL) #define ROMABLE_REGION ROM #define RAMABLE_REGION RAM #else diff --git a/include/zephyr/arch/x86/ia32/linker.ld b/include/zephyr/arch/x86/ia32/linker.ld index cdf004bc888..5994379eeef 100644 --- a/include/zephyr/arch/x86/ia32/linker.ld +++ b/include/zephyr/arch/x86/ia32/linker.ld @@ -44,7 +44,7 @@ #include -#if defined(CONFIG_XIP) || defined(Z_VM_KERNEL) +#if defined(CONFIG_XIP) || defined(K_MEM_IS_VM_KERNEL) #define ROMABLE_REGION ROM #define RAMABLE_REGION RAM #else diff --git a/include/zephyr/arch/x86/memory.ld b/include/zephyr/arch/x86/memory.ld index c9ede2b9d23..3e2c0b69352 100644 --- a/include/zephyr/arch/x86/memory.ld +++ b/include/zephyr/arch/x86/memory.ld @@ -39,7 +39,7 @@ * the same as its physical location, although an identity mapping for RAM * is still supported by setting CONFIG_KERNEL_VM_BASE=CONFIG_SRAM_BASE_ADDRESS. */ -#ifdef Z_VM_KERNEL +#ifdef K_MEM_IS_VM_KERNEL #define KERNEL_BASE_ADDR (CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) #define KERNEL_RAM_SIZE (CONFIG_KERNEL_VM_SIZE - CONFIG_KERNEL_VM_OFFSET) #define PHYS_RAM_AVAIL (PHYS_RAM_SIZE - CONFIG_SRAM_OFFSET) @@ -87,7 +87,7 @@ MEMORY * or copied into physical RAM by a loader (MMU) */ ROM (rx) : ORIGIN = PHYS_LOAD_ADDR, LENGTH = FLASH_ROM_SIZE -#elif defined(Z_VM_KERNEL) +#elif defined(K_MEM_IS_VM_KERNEL) ROM (rx) : ORIGIN = PHYS_LOAD_ADDR, LENGTH = PHYS_RAM_AVAIL #endif /* Linear address range to link the kernel. If non-XIP, everything is diff --git a/include/zephyr/kernel/internal/mm.h b/include/zephyr/kernel/internal/mm.h index d6f1d6841df..2b5a9330e54 100644 --- a/include/zephyr/kernel/internal/mm.h +++ b/include/zephyr/kernel/internal/mm.h @@ -67,7 +67,10 @@ #define K_MEM_VIRT_ADDR(phys) ((phys) + K_MEM_VIRT_OFFSET) #if K_MEM_VIRT_OFFSET != 0 -#define Z_VM_KERNEL 1 +/** + * @brief Kernel is mapped in virtual memory if defined. + */ +#define K_MEM_IS_VM_KERNEL 1 #ifdef CONFIG_XIP #error "XIP and a virtual memory kernel are not allowed" #endif diff --git a/include/zephyr/linker/linker-tool-gcc.h b/include/zephyr/linker/linker-tool-gcc.h index ab8a3ad7f9a..c2a004b8855 100644 --- a/include/zephyr/linker/linker-tool-gcc.h +++ b/include/zephyr/linker/linker-tool-gcc.h @@ -89,7 +89,7 @@ */ #if defined(CONFIG_ARCH_POSIX) #define GROUP_LINK_IN(where) -#elif !defined(Z_VM_KERNEL) +#elif !defined(K_MEM_IS_VM_KERNEL) #define GROUP_LINK_IN(where) > where #endif @@ -113,7 +113,7 @@ */ #if defined(CONFIG_ARCH_POSIX) #define GROUP_ROM_LINK_IN(vregion, lregion) -#elif defined(Z_VM_KERNEL) +#elif defined(K_MEM_IS_VM_KERNEL) #define GROUP_ROM_LINK_IN(vregion, lregion) > vregion AT > lregion #else #define GROUP_ROM_LINK_IN(vregion, lregion) > lregion @@ -133,7 +133,7 @@ */ #if defined(CONFIG_ARCH_POSIX) #define GROUP_DATA_LINK_IN(vregion, lregion) -#elif defined(CONFIG_XIP) || defined(Z_VM_KERNEL) +#elif defined(CONFIG_XIP) || defined(K_MEM_IS_VM_KERNEL) #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion #else #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion @@ -151,7 +151,7 @@ */ #if defined(CONFIG_ARCH_POSIX) #define GROUP_NOLOAD_LINK_IN(vregion, lregion) -#elif defined(Z_VM_KERNEL) +#elif defined(K_MEM_IS_VM_KERNEL) #define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > lregion #elif defined(CONFIG_XIP) #define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > vregion @@ -172,7 +172,7 @@ * @param align Alignment directives, such as SUBALIGN(). ALIGN() itself is * not allowed. May be blank. */ -#ifdef Z_VM_KERNEL +#ifdef K_MEM_IS_VM_KERNEL /* If we have a virtual memory map we need ALIGN_WITH_INPUT in all sections */ #define SECTION_PROLOGUE(name, options, align) \ name options : ALIGN_WITH_INPUT align