All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Will Deacon <will@kernel.org>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/2] arm64: Use simpler arithmetics for the linear map macros
Date: Tue, 2 Feb 2021 12:40:36 +0100	[thread overview]
Message-ID: <CAMj1kXFmCpK=Dk6G0TUJbzLLtXSXjf9XpnBUewXHcOpGwmm=4A@mail.gmail.com> (raw)
In-Reply-To: <20210202113609.GA26895@gaia>

On Tue, 2 Feb 2021 at 12:36, Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> On Tue, Feb 02, 2021 at 12:05:10AM +0100, Ard Biesheuvel wrote:
> > On Mon, 1 Feb 2021 at 20:06, Catalin Marinas <catalin.marinas@arm.com> wrote:
> > > Because of the tagged addresses, the __is_lm_address() and
> > > __lm_to_phys() macros grew to some harder to understand bitwise
> > > operations using PAGE_OFFSET. Since these macros only accept untagged
> > > addresses, use a simple subtract operation.
> > >
> > > Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> > > Cc: Will Deacon <will@kernel.org>
> > > Cc: Ard Biesheuvel <ardb@kernel.org>
> > > Cc: Mark Rutland <mark.rutland@arm.com>
> > > ---
> > >  arch/arm64/include/asm/memory.h | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> > > index 3c1aaa522cbd..ff4732785c32 100644
> > > --- a/arch/arm64/include/asm/memory.h
> > > +++ b/arch/arm64/include/asm/memory.h
> > > @@ -251,9 +251,9 @@ static inline const void *__tag_set(const void *addr, u8 tag)
> > >   * lives in the [PAGE_OFFSET, PAGE_END) interval at the bottom of the
> > >   * kernel's TTBR1 address range.
> > >   */
> > > -#define __is_lm_address(addr)  (((u64)(addr) ^ PAGE_OFFSET) < (PAGE_END - PAGE_OFFSET))
> > > +#define __is_lm_address(addr)  (((u64)(addr) - PAGE_OFFSET) < (PAGE_END - PAGE_OFFSET))
> >
> > Why still subtract PAGE_OFFSET on both sides of the comparison here?
>
> Not sure what you mean (Linus replied on the local variable aspect).
>
> With signed arithmetics, the above would be equivalent to addr < PAGE_END
> but it wouldn't cover the addr < PAGE_OFFSET case. So we rely on the
> unsigned wrap-around to detect this.
>

Never mind, I just got confused. These changes look fine.

For the series,

Acled-by: Ard Biesheuvel <ardb@kernel.org>

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

  reply	other threads:[~2021-02-02 11:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 19:06 [PATCH 0/2] arm64: Further fixes to the linear address checking Catalin Marinas
2021-02-01 19:06 ` [PATCH 1/2] arm64: Do not pass tagged addresses to __is_lm_address() Catalin Marinas
2021-02-01 19:06   ` Catalin Marinas
2021-02-01 19:06 ` [PATCH 2/2] arm64: Use simpler arithmetics for the linear map macros Catalin Marinas
2021-02-01 23:05   ` Ard Biesheuvel
2021-02-01 23:17     ` Linus Torvalds
2021-02-02 11:36     ` Catalin Marinas
2021-02-02 11:40       ` Ard Biesheuvel [this message]
2021-02-01 19:33 ` [PATCH 0/2] arm64: Further fixes to the linear address checking Linus Torvalds
2021-02-02 17:46 ` 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='CAMj1kXFmCpK=Dk6G0TUJbzLLtXSXjf9XpnBUewXHcOpGwmm=4A@mail.gmail.com' \
    --to=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vincenzo.frascino@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.