From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Steve Capper <Steve.Capper@arm.com>
Cc: Mark Rutland <Mark.Rutland@arm.com>,
Catalin Marinas <Catalin.Marinas@arm.com>, Qian Cai <cai@lca.pw>,
Andrey Konovalov <andreyknvl@google.com>,
Geert Uytterhoeven <geert@linux-m68k.org>, nd <nd@arm.com>,
Will Deacon <will@kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 1/8] arm64: memory: Fix virt_addr_valid() using __is_lm_address()
Date: Tue, 13 Aug 2019 22:25:14 +0300 [thread overview]
Message-ID: <CAKv+Gu-VBwXH+n7A0vr9xXm43HmFqsHOazQA-BuJKSqNhngR2A@mail.gmail.com> (raw)
In-Reply-To: <20190813191124.GA21406@capper-ampere.manchester.arm.com>
On Tue, 13 Aug 2019 at 22:11, Steve Capper <Steve.Capper@arm.com> wrote:
>
> Hi Ard,
>
> On Tue, Aug 13, 2019 at 09:09:16PM +0300, Ard Biesheuvel wrote:
> > On Tue, 13 Aug 2019 at 20:02, Will Deacon <will@kernel.org> wrote:
> > >
> > > virt_addr_valid() is intended to test whether or not the passed address
> > > is a valid linear map address. Unfortunately, it relies on
> > > _virt_addr_is_linear() which is broken because it assumes the linear
> > > map is at the top of the address space, which it no longer is.
> > >
> > > Reimplement virt_addr_valid() using __is_lm_address() and remove
> > > _virt_addr_is_linear() entirely. At the same time, ensure we evaluate
> > > the macro parameter only once and move it within the __ASSEMBLY__ block.
> > >
> > > Reported-by: Qian Cai <cai@lca.pw>
> > > Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > > Fixes: 14c127c957c1 ("arm64: mm: Flip kernel VA space")
> > > Signed-off-by: Will Deacon <will@kernel.org>
> > > ---
> > > arch/arm64/include/asm/memory.h | 14 +++++++-------
> > > 1 file changed, 7 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> > > index afaf512c0e1b..442ab861cab8 100644
> > > --- a/arch/arm64/include/asm/memory.h
> > > +++ b/arch/arm64/include/asm/memory.h
> > > @@ -244,9 +244,9 @@ static inline const void *__tag_set(const void *addr, u8 tag)
> > > /*
> > > * The linear kernel range starts in the middle of the virtual adddress
> > > * space.
> >
> > This is no longer true either.
> >
>
> Whoops agreed.
>
> > > Testing the top bit for the start of the region is a
> > > - * sufficient check.
> > > + * sufficient check and avoids having to worry about the tag.
> > > */
> > > -#define __is_lm_address(addr) (!((addr) & BIT(vabits_actual - 1)))
> > > +#define __is_lm_address(addr) (!(((u64)addr) & BIT(vabits_actual - 1)))
> > >
> >
> > ... and this assumes that the VA space is split evenly between linear
> > and vmalloc/vmemmap/etc, which is no longer true when running with
> > 52-bit VAs
> >
>
> For 52-bit VAs we have two possibilities:
> Start End Size Use
> -----------------------------------------------------------------------
> 0000000000000000 000fffffffffffff 4PB user
> fff0000000000000 fff7ffffffffffff 2PB kernel logical memory map
> fff8000000000000 fffd9fffffffffff 1440TB [gap]
Right. I missed the part where we throw away 1/3 of the VA space:
IIRC, the idea was that keeping the size of the upper half of the
48-bit VA space fixed for 52-bit not only allowed compile time
constant addresses to be used for many of the things that populate it,
it also makes a lot more VA space available to the linear region,
which is where we need it the most.
> fffda00000000000 ffff9fffffffffff 512TB kasan shadow region
>
> and
> Start End Size Use
> -----------------------------------------------------------------------
> 0000000000000000 0000ffffffffffff 256TB user
> ffff000000000000 ffff7fffffffffff 128TB kernel logical memory map
> ffff800000000000 ffff9fffffffffff 32TB kasan shadow region
> ffffa00000000000 ffffa00007ffffff 128MB bpf jit region
>
> IIUC the definition for __is_lm_address is correct for these cases?
> (it's based off vabits_actual).
>
With the gap taken into account, it is correct. But throwing away 1440
TB of address space seems suboptimal to me.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-08-13 19:25 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-13 17:01 [PATCH 0/8] Fix issues with 52-bit kernel virtual addressing Will Deacon
2019-08-13 17:01 ` [PATCH 1/8] arm64: memory: Fix virt_addr_valid() using __is_lm_address() Will Deacon
2019-08-13 18:09 ` Ard Biesheuvel
2019-08-13 19:11 ` Steve Capper
2019-08-13 19:25 ` Ard Biesheuvel [this message]
2019-08-13 20:34 ` Steve Capper
2019-08-14 15:17 ` Ard Biesheuvel
2019-08-14 8:32 ` Will Deacon
2019-08-13 18:53 ` Steve Capper
2019-08-14 9:19 ` Catalin Marinas
2019-08-14 9:48 ` Will Deacon
2019-08-14 10:40 ` Catalin Marinas
2019-08-14 12:02 ` Will Deacon
2019-08-13 17:01 ` [PATCH 2/8] arm64: memory: Ensure address tag is masked in conversion macros Will Deacon
2019-08-13 18:54 ` Steve Capper
2019-08-14 9:23 ` Catalin Marinas
2019-08-13 17:01 ` [PATCH 3/8] arm64: memory: Rewrite default page_to_virt()/virt_to_page() Will Deacon
2019-08-13 18:54 ` Steve Capper
2019-08-14 9:30 ` Catalin Marinas
2019-08-14 9:41 ` Will Deacon
2019-08-14 10:56 ` Mark Rutland
2019-08-14 11:17 ` Will Deacon
2019-08-14 11:26 ` Mark Rutland
2019-08-13 17:01 ` [PATCH 4/8] arm64: memory: Simplify virt_to_page() implementation Will Deacon
2019-08-13 18:55 ` Steve Capper
2019-08-14 9:32 ` Catalin Marinas
2019-08-13 17:01 ` [PATCH 5/8] arm64: memory: Simplify _VA_START and _PAGE_OFFSET definitions Will Deacon
2019-08-13 18:55 ` Steve Capper
2019-08-14 9:33 ` Catalin Marinas
2019-08-14 11:23 ` Mark Rutland
2019-08-14 12:00 ` Will Deacon
2019-08-14 13:18 ` Mark Rutland
2019-08-13 17:01 ` [PATCH 6/8] arm64: memory: Implement __tag_set() as common function Will Deacon
2019-08-13 18:56 ` Steve Capper
2019-08-14 9:34 ` Catalin Marinas
2019-08-13 17:01 ` [PATCH 7/8] arm64: memory: Add comments to end of non-trivial #ifdef blocks Will Deacon
2019-08-13 18:57 ` Steve Capper
2019-08-14 9:35 ` Catalin Marinas
2019-08-13 17:01 ` [PATCH 8/8] arm64: memory: Cosmetic cleanups Will Deacon
2019-08-13 18:57 ` Steve Capper
2019-08-14 9:35 ` Catalin Marinas
2019-08-13 18:53 ` [PATCH 0/8] Fix issues with 52-bit kernel virtual addressing Steve Capper
2019-08-14 8:01 ` Geert Uytterhoeven
2019-08-14 11:29 ` Mark Rutland
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=CAKv+Gu-VBwXH+n7A0vr9xXm43HmFqsHOazQA-BuJKSqNhngR2A@mail.gmail.com \
--to=ard.biesheuvel@linaro.org \
--cc=Catalin.Marinas@arm.com \
--cc=Mark.Rutland@arm.com \
--cc=Steve.Capper@arm.com \
--cc=andreyknvl@google.com \
--cc=cai@lca.pw \
--cc=geert@linux-m68k.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=nd@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).