linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Dev Jain <dev.jain@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, will@kernel.org,
	ardb@kernel.org, ryan.roberts@arm.com, mark.rutland@arm.com,
	suzuki.poulose@arm.com, broonie@kernel.org, James.Morse@arm.com,
	Anshuman.Khandual@arm.com
Subject: Re: [PATCH] arm64: kernel: Replace manual computation with macro
Date: Fri, 17 May 2024 16:31:12 +0100	[thread overview]
Message-ID: <Zkd4QCmkr97ilsRs@arm.com> (raw)
In-Reply-To: <20240517132421.285667-1-dev.jain@arm.com>

On Fri, May 17, 2024 at 06:54:21PM +0530, Dev Jain wrote:
> diff --git a/arch/arm64/kernel/pi/map_range.c b/arch/arm64/kernel/pi/map_range.c
> index 5410b2cac590..4b145be7f846 100644
> --- a/arch/arm64/kernel/pi/map_range.c
> +++ b/arch/arm64/kernel/pi/map_range.c
> @@ -31,14 +31,14 @@ void __init map_range(u64 *pte, u64 start, u64 end, u64 pa, pgprot_t prot,
>  {
>  	u64 cmask = (level == 3) ? CONT_PTE_SIZE - 1 : U64_MAX;
>  	u64 protval = pgprot_val(prot) & ~PTE_TYPE_MASK;
> -	int lshift = (3 - level) * (PAGE_SHIFT - 3);
> -	u64 lmask = (PAGE_SIZE << lshift) - 1;
> +	int lshift = ARM64_HW_PGTABLE_LEVEL_SHIFT(level);
> +	u64 lmask = ((u64)1 << lshift) - 1;

Nitpick: you can use 1UL instead of (u64)1.

>  
>  	start	&= PAGE_MASK;
>  	pa	&= PAGE_MASK;
>  
>  	/* Advance tbl to the entry that covers start */
> -	tbl += (start >> (lshift + PAGE_SHIFT)) % PTRS_PER_PTE;
> +	tbl += (start >> lshift) % PTRS_PER_PTE;

I did the maths as well my own way and the change is correct:

	lshift + PAGE_SHIT == ARM64_HW_PGTABLE_LEVEL_SHIFT(level)

It probably is easier to read this way, so:

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-05-17 15:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-17 13:24 [PATCH] arm64: kernel: Replace manual computation with macro Dev Jain
2024-05-17 15:31 ` Catalin Marinas [this message]
2024-05-23 13:02   ` Dave Martin
2024-05-23 16:59     ` Catalin Marinas

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=Zkd4QCmkr97ilsRs@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=Anshuman.Khandual@arm.com \
    --cc=James.Morse@arm.com \
    --cc=ardb@kernel.org \
    --cc=broonie@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=ryan.roberts@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.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;
as well as URLs for NNTP newsgroup(s).