mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH 2/7] ARM: pass barebox base to mmu_early_enable()
Date: Fri, 13 Jun 2025 11:17:25 +0200	[thread overview]
Message-ID: <b9a21a09-fbaa-4c9e-9a0d-6c728a55a2e3@pengutronix.de> (raw)
In-Reply-To: <20250613-arm-mmu-xn-ro-v1-2-60f05c6e7b4b@pengutronix.de>

On 6/13/25 09:58, Sascha Hauer wrote:
> We'll need the barebox base in the next patches to map the barebox
> area differently.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  arch/arm/cpu/mmu_32.c      | 2 +-
>  arch/arm/cpu/mmu_64.c      | 2 +-
>  arch/arm/cpu/uncompress.c  | 9 ++++-----
>  arch/arm/include/asm/mmu.h | 2 +-
>  4 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm/cpu/mmu_32.c b/arch/arm/cpu/mmu_32.c
> index ec6bd27da4e161a96fd42497e1a54dafc9779937..2754bea88a514c2886e43ffc4dbf310d75055fca 100644
> --- a/arch/arm/cpu/mmu_32.c
> +++ b/arch/arm/cpu/mmu_32.c
> @@ -591,7 +591,7 @@ void *dma_alloc_writecombine(struct device *dev, size_t size, dma_addr_t *dma_ha
>  	return dma_alloc_map(dev, size, dma_handle, ARCH_MAP_WRITECOMBINE);
>  }
>  
> -void mmu_early_enable(unsigned long membase, unsigned long memsize)
> +void mmu_early_enable(unsigned long membase, unsigned long memsize, unsigned long barebox_start)
>  {
>  	uint32_t *ttb = (uint32_t *)arm_mem_ttb(membase + memsize);
>  
> diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
> index bc1a44d0a7b85af769ffa9c9bfbf70f274fc1aa5..65c6f1bb9f8ac2f4b55baf46c2af3d3714060088 100644
> --- a/arch/arm/cpu/mmu_64.c
> +++ b/arch/arm/cpu/mmu_64.c
> @@ -408,7 +408,7 @@ static void init_range(size_t total_level0_tables)
>  	}
>  }
>  
> -void mmu_early_enable(unsigned long membase, unsigned long memsize)
> +void mmu_early_enable(unsigned long membase, unsigned long memsize, unsigned long barebox_start)
>  {
>  	int el;
>  	u64 optee_membase;
> diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
> index 4657a4828e67e1b0acfa9dec3aef33bc4c525468..e24e754e0b16bda4974df0dd754936e87fe59d2d 100644
> --- a/arch/arm/cpu/uncompress.c
> +++ b/arch/arm/cpu/uncompress.c
> @@ -63,11 +63,6 @@ void __noreturn barebox_pbl_start(unsigned long membase, unsigned long memsize,
>  
>  	pr_debug("memory at 0x%08lx, size 0x%08lx\n", membase, memsize);
>  
> -	if (IS_ENABLED(CONFIG_MMU))
> -		mmu_early_enable(membase, memsize);
> -	else if (IS_ENABLED(CONFIG_ARMV7R_MPU))
> -		set_cr(get_cr() | CR_C);
> -
>  	/* Add handoff data now, so arm_mem_barebox_image takes it into account */
>  	if (boarddata)
>  		handoff_data_add_dt(boarddata);
> @@ -83,6 +78,10 @@ void __noreturn barebox_pbl_start(unsigned long membase, unsigned long memsize,
>  #ifdef DEBUG
>  	print_pbl_mem_layout(membase, endmem, barebox_base);
>  #endif
> +	if (IS_ENABLED(CONFIG_MMU))
> +		mmu_early_enable(membase, memsize, barebox_base);
> +	else if (IS_ENABLED(CONFIG_ARMV7R_MPU))
> +		set_cr(get_cr() | CR_C);
>  
>  	pr_debug("uncompressing barebox binary at 0x%p (size 0x%08x) to 0x%08lx (uncompressed size: 0x%08x)\n",
>  			pg_start, pg_len, barebox_base, uncompressed_len);
> diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
> index ebf1e096c68295858bc8f3e6ab0e6f2dd6512717..5538cd3558e8e6c069923f7f6ccfc38e7df87c9f 100644
> --- a/arch/arm/include/asm/mmu.h
> +++ b/arch/arm/include/asm/mmu.h
> @@ -64,7 +64,7 @@ void __dma_clean_range(unsigned long, unsigned long);
>  void __dma_flush_range(unsigned long, unsigned long);
>  void __dma_inv_range(unsigned long, unsigned long);
>  
> -void mmu_early_enable(unsigned long membase, unsigned long memsize);
> +void mmu_early_enable(unsigned long membase, unsigned long memsize, unsigned long barebox_base);
>  void mmu_early_disable(void);
>  
>  #endif /* __ASM_MMU_H */
> 

-- 
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 |




  reply	other threads:[~2025-06-13  9:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-13  7:58 [PATCH 0/7] ARM: Map sections RO/XN Sascha Hauer
2025-06-13  7:58 ` [PATCH 1/7] memory: request RO data section as separate region Sascha Hauer
2025-06-13  9:15   ` Ahmad Fatoum
2025-06-13  7:58 ` [PATCH 2/7] ARM: pass barebox base to mmu_early_enable() Sascha Hauer
2025-06-13  9:17   ` Ahmad Fatoum [this message]
2025-06-13  7:58 ` [PATCH 3/7] ARM: mmu: move ARCH_MAP_WRITECOMBINE to header Sascha Hauer
2025-06-13  9:18   ` Ahmad Fatoum
2025-06-13  7:58 ` [PATCH 4/7] ARM: MMU: map memory for barebox proper pagewise Sascha Hauer
2025-06-13  9:23   ` Ahmad Fatoum
2025-06-13  7:58 ` [PATCH 5/7] ARM: MMU: map text segment ro and data segments execute never Sascha Hauer
2025-06-13 10:12   ` Ahmad Fatoum
2025-06-13 10:36   ` Ahmad Fatoum
2025-06-13  7:58 ` [PATCH 6/7] ARM: MMU64: map memory for barebox proper pagewise Sascha Hauer
2025-06-13 10:29   ` Ahmad Fatoum
2025-06-13  7:58 ` [PATCH 7/7] ARM: MMU64: map text segment ro and data segments execute never Sascha Hauer
2025-06-13 10:40   ` Ahmad Fatoum
2025-06-13 12:44 ` [PATCH 0/7] ARM: Map sections RO/XN Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9a21a09-fbaa-4c9e-9a0d-6c728a55a2e3@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox