From e239cd942e41d5d601bace6a445ab7abbb9a7e46 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Fri, 4 Nov 2022 15:04:19 +0200 Subject: [PATCH] mpfs/mpfs_mm_init: Fix the section align mask checks The boundary-1 mask needs to be tested, not the alignment boundary --- arch/risc-v/src/common/riscv_mmu.h | 3 ++- arch/risc-v/src/mpfs/mpfs_mm_init.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/risc-v/src/common/riscv_mmu.h b/arch/risc-v/src/common/riscv_mmu.h index 4242367dac..e67fadc276 100644 --- a/arch/risc-v/src/common/riscv_mmu.h +++ b/arch/risc-v/src/common/riscv_mmu.h @@ -110,7 +110,8 @@ /* Minimum alignment requirement for any section of memory is 2MB */ -#define RV_MMU_SECTION_ALIGN (RV_MMU_L2_PAGE_SIZE) +#define RV_MMU_SECTION_ALIGN (RV_MMU_L2_PAGE_SIZE) +#define RV_MMU_SECTION_ALIGN_MASK (RV_MMU_SECTION_ALIGN - 1) #else #error "Unsupported RISC-V MMU implementation selected" #endif /* CONFIG_ARCH_MMU_TYPE_SV39 */ diff --git a/arch/risc-v/src/mpfs/mpfs_mm_init.c b/arch/risc-v/src/mpfs/mpfs_mm_init.c index 7737f3be3d..90f69b33fe 100644 --- a/arch/risc-v/src/mpfs/mpfs_mm_init.c +++ b/arch/risc-v/src/mpfs/mpfs_mm_init.c @@ -215,9 +215,9 @@ void mpfs_kernel_mappings(void) * handle unaligned L3 sections. */ - ASSERT((KFLASH_START & RV_MMU_SECTION_ALIGN) == 0); - ASSERT((KSRAM_START & RV_MMU_SECTION_ALIGN) == 0); - ASSERT((PGPOOL_START & RV_MMU_SECTION_ALIGN) == 0); + ASSERT((KFLASH_START & RV_MMU_SECTION_ALIGN_MASK) == 0); + ASSERT((KSRAM_START & RV_MMU_SECTION_ALIGN_MASK) == 0); + ASSERT((PGPOOL_START & RV_MMU_SECTION_ALIGN_MASK) == 0); /* Check that the L3 table is of sufficient size */