From 70de321de3f93585ba13e6d24665b60134946e20 Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Wed, 11 Jan 2023 13:56:59 +0400 Subject: [PATCH] arch/Kconfig: remove virtual memory allocator dependency from MM_SHM The dependency should be vice versa; the MM_SHM should depend on the existence of the virtual memory range allocator. Create a new CONFIG flag CONFIG_ARCH_VMA_MAPPING, which will define that there is a virtual memory range allocator. Make MM_SHM select that flag Signed-off-by: Jukka Laitinen --- arch/Kconfig | 10 +++++++--- arch/arm/include/arch.h | 6 +++--- arch/arm/src/armv7-a/Make.defs | 2 +- arch/arm/src/armv7-a/arm_addrenv.c | 6 +++--- arch/arm/src/armv7-a/arm_addrenv_shm.c | 4 ++-- arch/arm/src/armv7-a/pgalloc.h | 2 +- arch/arm64/include/arch.h | 4 ++-- arch/arm64/src/common/Make.defs | 2 +- arch/or1k/include/arch.h | 6 +++--- arch/risc-v/src/common/riscv_addrenv_shm.c | 2 +- binfmt/binfmt_execmodule.c | 2 +- include/nuttx/addrenv.h | 2 +- include/nuttx/arch.h | 4 ++-- mm/Kconfig | 1 + 14 files changed, 29 insertions(+), 24 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 6ac116d4f3..5cbc2927f3 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -534,9 +534,13 @@ config ARCH_HEAP_VBASE ---help--- The virtual address of the beginning of the heap region. +config ARCH_VMA_MAPPING + bool "Support runtime memory mapping into SHM area" + default n + config ARCH_SHM_VBASE hex "Shared memory base" - depends on MM_SHM + depends on ARCH_VMA_MAPPING ---help--- The virtual address of the beginning of the shared memory region. @@ -564,7 +568,7 @@ config ARCH_HEAP_NPAGES This, along with knowledge of the page size, determines the size of the heap virtual address space. Default is 1. -if MM_SHM +if ARCH_VMA_MAPPING config ARCH_SHM_MAXREGIONS int "Max shared memory regions" @@ -592,7 +596,7 @@ config ARCH_SHM_NPAGES maximum number of pages per region, and the configured size of each page. -endif # MM_SHM +endif # ARCH_VMA_MAPPING config ARCH_STACK_DYNAMIC bool "Dynamic user stack" diff --git a/arch/arm/include/arch.h b/arch/arm/include/arch.h index bec81e41af..ae9b30b4e5 100644 --- a/arch/arm/include/arch.h +++ b/arch/arm/include/arch.h @@ -95,7 +95,7 @@ do { \ # define ARCH_DATA_NSECTS ARCH_PG2SECT(CONFIG_ARCH_DATA_NPAGES) # define ARCH_HEAP_NSECTS ARCH_PG2SECT(CONFIG_ARCH_HEAP_NPAGES) -# ifdef CONFIG_MM_SHM +# ifdef CONFIG_ARCH_VMA_MAPPING # define ARCH_SHM_NSECTS ARCH_PG2SECT(ARCH_SHM_MAXPAGES) # endif @@ -138,7 +138,7 @@ struct group_addrenv_s uintptr_t *data[ARCH_DATA_NSECTS]; #ifdef CONFIG_BUILD_KERNEL uintptr_t *heap[ARCH_HEAP_NSECTS]; -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING uintptr_t *shm[ARCH_SHM_NSECTS]; #endif @@ -169,7 +169,7 @@ struct save_addrenv_s uint32_t data[ARCH_DATA_NSECTS]; #ifdef CONFIG_BUILD_KERNEL uint32_t heap[ARCH_HEAP_NSECTS]; -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING uint32_t shm[ARCH_SHM_NSECTS]; #endif #endif diff --git a/arch/arm/src/armv7-a/Make.defs b/arch/arm/src/armv7-a/Make.defs index 791275125d..bfd992bb09 100644 --- a/arch/arm/src/armv7-a/Make.defs +++ b/arch/arm/src/armv7-a/Make.defs @@ -71,7 +71,7 @@ ifeq ($(CONFIG_ARCH_ADDRENV),y) ifeq ($(CONFIG_ARCH_KERNEL_STACK),y) CMN_CSRCS += arm_addrenv_kstack.c endif - ifeq ($(CONFIG_MM_SHM),y) + ifeq ($(CONFIG_ARCH_VMA_MAPPING),y) CMN_CSRCS += arm_addrenv_shm.c endif endif diff --git a/arch/arm/src/armv7-a/arm_addrenv.c b/arch/arm/src/armv7-a/arm_addrenv.c index a4e633879e..0fef2c3767 100644 --- a/arch/arm/src/armv7-a/arm_addrenv.c +++ b/arch/arm/src/armv7-a/arm_addrenv.c @@ -346,7 +346,7 @@ int up_addrenv_destroy(group_addrenv_t *addrenv) arm_addrenv_destroy_region(addrenv->heap, ARCH_HEAP_NSECTS, CONFIG_ARCH_HEAP_VBASE, false); -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING /* Destroy the shared memory region (without freeing the physical page * data). */ @@ -592,7 +592,7 @@ int up_addrenv_select(const group_addrenv_t *addrenv, } } -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING for (vaddr = CONFIG_ARCH_SHM_VBASE, i = 0; i < ARCH_SHM_NSECTS; vaddr += SECTION_SIZE, i++) @@ -676,7 +676,7 @@ int up_addrenv_restore(const save_addrenv_t *oldenv) mmu_l1_restore(vaddr, oldenv->heap[i]); } -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING for (vaddr = CONFIG_ARCH_SHM_VBASE, i = 0; i < ARCH_SHM_NSECTS; vaddr += SECTION_SIZE, i++) diff --git a/arch/arm/src/armv7-a/arm_addrenv_shm.c b/arch/arm/src/armv7-a/arm_addrenv_shm.c index b53822402b..884c0e3224 100644 --- a/arch/arm/src/armv7-a/arm_addrenv_shm.c +++ b/arch/arm/src/armv7-a/arm_addrenv_shm.c @@ -38,7 +38,7 @@ #include "addrenv.h" #include "pgalloc.h" -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_SHM) +#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_ARCH_VMA_MAPPING) /**************************************************************************** * Public Functions @@ -269,4 +269,4 @@ int up_shmdt(uintptr_t vaddr, unsigned int npages) return OK; } -#endif /* CONFIG_BUILD_KERNEL && CONFIG_MM_SHM */ +#endif /* CONFIG_BUILD_KERNEL && CONFIG_ARCH_VMA_MAPPING */ diff --git a/arch/arm/src/armv7-a/pgalloc.h b/arch/arm/src/armv7-a/pgalloc.h index 611f7de6fe..e3579080dc 100644 --- a/arch/arm/src/armv7-a/pgalloc.h +++ b/arch/arm/src/armv7-a/pgalloc.h @@ -92,7 +92,7 @@ static inline bool arm_uservaddr(uintptr_t vaddr) #ifdef CONFIG_ARCH_STACK_DYNAMIC || (vaddr >= CONFIG_ARCH_STACK_VBASE && vaddr < ARCH_STACK_VEND) #endif -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING || (vaddr >= CONFIG_ARCH_SHM_VBASE && vaddr < ARCH_SHM_VEND) #endif ); diff --git a/arch/arm64/include/arch.h b/arch/arm64/include/arch.h index d8673a12e0..322942fdc6 100644 --- a/arch/arm64/include/arch.h +++ b/arch/arm64/include/arch.h @@ -75,7 +75,7 @@ struct group_addrenv_s uintptr_t *data[ARCH_DATA_NSECTS]; #ifdef CONFIG_BUILD_KERNEL uintptr_t *heap[ARCH_HEAP_NSECTS]; -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING uintptr_t *shm[ARCH_SHM_NSECTS]; #endif @@ -106,7 +106,7 @@ struct save_addrenv_s uint32_t data[ARCH_DATA_NSECTS]; #ifdef CONFIG_BUILD_KERNEL uint32_t heap[ARCH_HEAP_NSECTS]; -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING uint32_t shm[ARCH_SHM_NSECTS]; #endif #endif diff --git a/arch/arm64/src/common/Make.defs b/arch/arm64/src/common/Make.defs index 507e8e57dd..e076f888dd 100644 --- a/arch/arm64/src/common/Make.defs +++ b/arch/arm64/src/common/Make.defs @@ -74,7 +74,7 @@ endif ifeq ($(CONFIG_ARCH_KERNEL_STACK),y) CMN_CSRCS += arm64_addrenv_kstack.c endif -ifeq ($(CONFIG_MM_SHM),y) +ifeq ($(CONFIG_ARCH_VMA_MAPPING),y) CMN_CSRCS += arm64_addrenv_shm.c endif endif diff --git a/arch/or1k/include/arch.h b/arch/or1k/include/arch.h index d60ae6e515..63b326d924 100644 --- a/arch/or1k/include/arch.h +++ b/arch/or1k/include/arch.h @@ -57,7 +57,7 @@ # define ARCH_DATA_NSECTS ARCH_PG2SECT(CONFIG_ARCH_DATA_NPAGES) # define ARCH_HEAP_NSECTS ARCH_PG2SECT(CONFIG_ARCH_HEAP_NPAGES) -# ifdef CONFIG_MM_SHM +# ifdef CONFIG_ARCH_VMA_MAPPING # define ARCH_SHM_NSECTS ARCH_PG2SECT(ARCH_SHM_MAXPAGES) # endif @@ -89,7 +89,7 @@ struct group_addrenv_s uintptr_t *data[ARCH_DATA_NSECTS]; #ifdef CONFIG_BUILD_KERNEL uintptr_t *heap[ARCH_HEAP_NSECTS]; -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING uintptr_t *shm[ARCH_SHM_NSECTS]; #endif @@ -120,7 +120,7 @@ struct save_addrenv_s uint32_t data[ARCH_DATA_NSECTS]; #ifdef CONFIG_BUILD_KERNEL uint32_t heap[ARCH_HEAP_NSECTS]; -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING uint32_t shm[ARCH_SHM_NSECTS]; #endif #endif diff --git a/arch/risc-v/src/common/riscv_addrenv_shm.c b/arch/risc-v/src/common/riscv_addrenv_shm.c index f850c3051a..3d81d5ad18 100644 --- a/arch/risc-v/src/common/riscv_addrenv_shm.c +++ b/arch/risc-v/src/common/riscv_addrenv_shm.c @@ -39,7 +39,7 @@ #include "pgalloc.h" #include "riscv_mmu.h" -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_SHM) +#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_ARCH_VMA_MAPPING) /**************************************************************************** * Public Functions diff --git a/binfmt/binfmt_execmodule.c b/binfmt/binfmt_execmodule.c index ed4a7046f6..e1f5cda385 100644 --- a/binfmt/binfmt_execmodule.c +++ b/binfmt/binfmt_execmodule.c @@ -298,7 +298,7 @@ int exec_module(FAR const struct binary_s *binp, return (int)pid; -#if defined(CONFIG_ARCH_ADDRENV) || defined(CONFIG_MM_SHM) +#if defined(CONFIG_ARCH_ADDRENV) || defined(CONFIG_ARCH_VMA_MAPPING) errout_with_tcbinit: tcb->cmn.stack_alloc_ptr = NULL; nxsched_release_tcb(&tcb->cmn, TCB_FLAG_TTYPE_TASK); diff --git a/include/nuttx/addrenv.h b/include/nuttx/addrenv.h index 43a0ea92ce..9d1a5b53f0 100644 --- a/include/nuttx/addrenv.h +++ b/include/nuttx/addrenv.h @@ -164,7 +164,7 @@ /* Shared memory regions */ -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING # ifndef CONFIG_ARCH_SHM_VBASE # error CONFIG_ARCH_SHM_VBASE not defined # define CONFIG_ARCH_SHM_VBASE __ARCH_SHM_VBASE diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 4217790605..bf230d2850 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -1346,7 +1346,7 @@ uintptr_t up_addrenv_va_to_pa(FAR void *va); * ****************************************************************************/ -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING int up_shmat(FAR uintptr_t *pages, unsigned int npages, uintptr_t vaddr); #endif @@ -1367,7 +1367,7 @@ int up_shmat(FAR uintptr_t *pages, unsigned int npages, uintptr_t vaddr); * ****************************************************************************/ -#ifdef CONFIG_MM_SHM +#ifdef CONFIG_ARCH_VMA_MAPPING int up_shmdt(uintptr_t vaddr, unsigned int npages); #endif diff --git a/mm/Kconfig b/mm/Kconfig index ddeaf1d41b..389aa32362 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -162,6 +162,7 @@ config MM_SHM bool "Shared memory support" default n depends on MM_PGALLOC && BUILD_KERNEL + select ARCH_VMA_MAPPING ---help--- Build in support for the shared memory interfaces shmget(), shmat(), shmctl(), and shmdt().