Hi,
On 1/6/26 1:53 PM, Sascha Hauer wrote:
> Add PBL-specific memory remapping function that always uses page-wise
> mapping (ARCH_MAP_FLAG_PAGEWISE) for fine-grained permissions on
> adjacent ELF segments with different protection requirements.
>
> Wraps arch-specific __arch_remap_range() for ARMv7 (4KB pages) and
> ARMv8 (page tables with BBM). Needed for ELF segment permission setup.
>
> Signed-off-by: Sascha Hauer <[email protected]>
The verdict was that we shouldn't need PAGEWISE here and in that case,
we could just use normal remap_range function, right?
Thanks,
Ahmad
> ---
> arch/arm/cpu/mmu_32.c | 7 +++++++
> arch/arm/cpu/mmu_64.c | 8 ++++++++
> include/mmu.h | 3 +++
> 3 files changed, 18 insertions(+)
>
> diff --git a/arch/arm/cpu/mmu_32.c b/arch/arm/cpu/mmu_32.c
> index
> 71ead41c3d274548c9427c1ce9833de309114c4d..54371e3e5973c9fe98cadef63499105134e09539
> 100644
> --- a/arch/arm/cpu/mmu_32.c
> +++ b/arch/arm/cpu/mmu_32.c
> @@ -435,6 +435,13 @@ static void early_remap_range(u32 addr, size_t size,
> maptype_t map_type)
> __arch_remap_range((void *)addr, addr, size, map_type);
> }
>
> +void pbl_remap_range(void *virt_addr, phys_addr_t phys_addr, size_t size,
> + maptype_t map_type)
> +{
> + __arch_remap_range(virt_addr, phys_addr, size,
> + map_type | ARCH_MAP_FLAG_PAGEWISE);
> +}
> +
> static bool pte_is_cacheable(uint32_t pte, int level)
> {
> return (level == 2 && (pte & PTE_CACHEABLE)) ||
> diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
> index
> ddf1373ec0a801baad043146187d7f4c3eac6a2a..d4d6d1a849ba9b8666f4dcb4bd80247a70bdce1a
> 100644
> --- a/arch/arm/cpu/mmu_64.c
> +++ b/arch/arm/cpu/mmu_64.c
> @@ -282,6 +282,14 @@ static void early_remap_range(uint64_t addr, size_t
> size, maptype_t map_type)
> __arch_remap_range(addr, addr, size, map_type, false);
> }
>
> +void pbl_remap_range(void *virt_addr, phys_addr_t phys_addr, size_t size,
> + maptype_t map_type)
> +{
> + __arch_remap_range((uint64_t)virt_addr, phys_addr,
> + (uint64_t)size, map_type | ARCH_MAP_FLAG_PAGEWISE,
> + true);
> +}
> +
> int arch_remap_range(void *virt_addr, phys_addr_t phys_addr, size_t size,
> maptype_t map_type)
> {
> map_type = arm_mmu_maybe_skip_permissions(map_type);
> diff --git a/include/mmu.h b/include/mmu.h
> index
> 9f582f25e1de14d47cfe2eff64f9cce81c4e492d..32d9a7aca3b9a61d542bf3e21e27f1ac51f43ee2
> 100644
> --- a/include/mmu.h
> +++ b/include/mmu.h
> @@ -65,6 +65,9 @@ static inline bool arch_can_remap(void)
> }
> #endif
>
> +void pbl_remap_range(void *virt_addr, phys_addr_t phys_addr, size_t size,
> + maptype_t map_type);
> +
> static inline int remap_range(void *start, size_t size, maptype_t map_type)
> {
> return arch_remap_range(start, virt_to_phys(start), size, map_type);
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |