mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH master] ARM: mmu: align size of remapped region to page size
Date: Tue, 5 Dec 2023 09:24:36 +0100	[thread overview]
Message-ID: <20231205082436.GU1057032@pengutronix.de> (raw)
In-Reply-To: <20231205081247.4148947-1-a.fatoum@pengutronix.de>

On Tue, Dec 05, 2023 at 09:12:47AM +0100, Ahmad Fatoum wrote:
> Currently, barebox ARM arch_remap_range() will hang in an infinite loop,
> when called with a size that's not aligned to a page boundary.
> Its Linux equivalent, ioremap(), will just rounds up to page size and
> work correctly. Adopt the Linux behavior to make porting code easier,
> e.g. when calling devm_ioremap().
> 
> The only other arch_remap_range() in barebox, is PowerPC's. That one
> wouldn't loop indefinitely if the size isn't page aligned, so nothing to
> do there.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  arch/arm/cpu/mmu_32.c | 3 +++
>  arch/arm/cpu/mmu_64.c | 3 +++
>  2 files changed, 6 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/cpu/mmu_32.c b/arch/arm/cpu/mmu_32.c
> index d0ada5866f05..c6eecf9c9d2d 100644
> --- a/arch/arm/cpu/mmu_32.c
> +++ b/arch/arm/cpu/mmu_32.c
> @@ -18,6 +18,7 @@
>  #include <memory.h>
>  #include <asm/system_info.h>
>  #include <asm/sections.h>
> +#include <linux/pagemap.h>
>  
>  #include "mmu_32.h"
>  
> @@ -253,6 +254,8 @@ static void __arch_remap_range(void *_virt_addr, phys_addr_t phys_addr, size_t s
>  	pte_flags = get_pte_flags(map_type);
>  	pmd_flags = pte_flags_to_pmd(pte_flags);
>  
> +	size = PAGE_ALIGN(size);
> +
>  	while (size) {
>  		const bool pgdir_size_aligned = IS_ALIGNED(virt_addr, PGDIR_SIZE);
>  		u32 *pgd = (u32 *)&ttb[pgd_index(virt_addr)];
> diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
> index 12c4dc90b392..c6ea63e655ad 100644
> --- a/arch/arm/cpu/mmu_64.c
> +++ b/arch/arm/cpu/mmu_64.c
> @@ -19,6 +19,7 @@
>  #include <asm/cache.h>
>  #include <memory.h>
>  #include <asm/system_info.h>
> +#include <linux/pagemap.h>
>  
>  #include "mmu_64.h"
>  
> @@ -132,6 +133,8 @@ static void create_sections(uint64_t virt, uint64_t phys, uint64_t size,
>  
>  	attr &= ~PTE_TYPE_MASK;
>  
> +	size = PAGE_ALIGN(size);
> +
>  	while (size) {
>  		table = ttb;
>  		for (level = 0; level < 4; level++) {
> -- 
> 2.39.2
> 
> 
> 

-- 
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:[~2023-12-05  8:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05  8:12 Ahmad Fatoum
2023-12-05  8:24 ` Sascha Hauer [this message]

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=20231205082436.GU1057032@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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