From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Arnd Bergmann <arnd@arndb.de>, Stefan Wahren <wahrenst@gmx.net>,
Kees Cook <keescook@chromium.org>,
linux-arm-kernel@lists.infradead.org,
Catalin Marinas <catalin.marinas@arm.com>
Subject: Re: [PATCH v3 4/4] ARM: Implement PAN for LPAE by TTBR0 page table walks disablement
Date: Wed, 15 May 2024 09:48:38 +0100 [thread overview]
Message-ID: <ZkR25mhjZ0z5XsmM@shell.armlinux.org.uk> (raw)
In-Reply-To: <CAMj1kXE34s2pSBT8q1G-xrMVCuvDbdKFwhM2bW60cA0_nX_GzQ@mail.gmail.com>
On Wed, May 15, 2024 at 10:36:48AM +0200, Ard Biesheuvel wrote:
> On Tue, 14 May 2024 at 22:34, Florian Fainelli <f.fainelli@gmail.com> wrote:
> >
> > On 5/14/24 13:33, Linus Walleij wrote:
> > > On Tue, May 14, 2024 at 8:26 PM Florian Fainelli <f.fainelli@gmail.com> wrote:
> > >> On 5/14/24 10:03, Russell King (Oracle) wrote:
> > >
> > >>> I would imagine that the problem is cpu_set_ttbcr(). Please try adding
> > >>> a "memory" clobber to the asm() instruction in there.
> > >>>
> > >>
> > >> I can confirm that with CONFIG_CC_OPTIMIZE_FOR_SIZE=y and the hunk below:
> > >>
> > >> diff --git a/arch/arm/include/asm/proc-fns.h
> > >> b/arch/arm/include/asm/proc-fns.h
> > >> index 9b3105a2a5e0..1087bd2af433 100644
> > >> --- a/arch/arm/include/asm/proc-fns.h
> > >> +++ b/arch/arm/include/asm/proc-fns.h
> > >> @@ -187,7 +187,7 @@ static inline unsigned int cpu_get_ttbcr(void)
> > >>
> > >> static inline void cpu_set_ttbcr(unsigned int ttbcr)
> > >> {
> > >> - asm("mcr p15, 0, %0, c2, c0, 2" : : "r" (ttbcr));
> > >> + asm("mcr p15, 0, %0, c2, c0, 2" : : "r" (ttbcr) : "memory");
> > >> }
> > >>
> > >> #else /*!CONFIG_MMU */
> > >>
> > >> my Raspberry Pi 4B in AArch32 mode boots and runs user-space properly.
> > >>
> > >> Thanks a lot Russell!
> > >
> > > Second that, very nicely pinpointed Russell!
> > >
> > > Florian, do you want to send a patch or should I?
> >
> > I was wondering if Russell was able to fold this directly into patch #2
> > where cpu_set_ttbr() is added, so as to not break functionality across
> > bisection.
>
> Sadly, I can still reproduce this with the above fix.
>
> I included TTBCR in the DEBUG_USER output, and (as expected), it has
> A1, EPD0 and T0SZ set to the 'uaccess disabled' values.
>
> Using __always_inline on uaccess_save_and_enable() and
> uaccess_restore() (as the CONFIG_CPU_SW_DOMAIN_PAN does) seems to work
> around it. The "memory" clobber seems unnecessary in my case, but it
> is needed for correctness in any case.
>
> It is unclear to me why placing these helpers out of line should make
> any difference, and I am not convinced it is a problem in the code
> (IIRC we've had other issues with -Os in the past)
Time to start comparing compilers / compiler versions?
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
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:[~2024-05-15 8:49 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 12:52 [PATCH v3 0/4] PAN for ARM32 using LPAE Linus Walleij
2024-03-12 12:52 ` [PATCH v3 1/4] ARM: Add TTBCR_* definitions to pgtable-3level-hwdef.h Linus Walleij
2024-03-12 12:52 ` [PATCH v3 2/4] ARM: Move asm statements accessing TTBCR into C functions Linus Walleij
2024-03-12 12:52 ` [PATCH v3 3/4] ARM: Reduce the number of #ifdef CONFIG_CPU_SW_DOMAIN_PAN Linus Walleij
2024-03-12 12:52 ` [PATCH v3 4/4] ARM: Implement PAN for LPAE by TTBR0 page table walks disablement Linus Walleij
2024-05-07 13:10 ` Geert Uytterhoeven
2024-05-13 19:23 ` Linus Walleij
2024-05-13 19:58 ` Geert Uytterhoeven
2024-05-13 20:29 ` Linus Walleij
2024-05-14 3:56 ` Florian Fainelli
2024-05-14 8:14 ` Russell King (Oracle)
2024-05-14 11:22 ` Geert Uytterhoeven
2024-05-14 11:33 ` Russell King (Oracle)
2024-05-14 12:32 ` Geert Uytterhoeven
2024-05-14 12:38 ` Russell King (Oracle)
2024-05-14 15:03 ` Catalin Marinas
2024-05-14 6:41 ` Geert Uytterhoeven
2024-05-14 7:46 ` Linus Walleij
2024-05-14 7:59 ` Ard Biesheuvel
2024-05-14 8:04 ` Geert Uytterhoeven
2024-05-14 8:25 ` Ard Biesheuvel
2024-05-14 9:22 ` Russell King (Oracle)
2024-05-14 11:40 ` Linus Walleij
2024-05-14 11:28 ` Geert Uytterhoeven
2024-05-14 16:06 ` Geert Uytterhoeven
2024-05-14 16:54 ` Florian Fainelli
2024-05-14 17:03 ` Russell King (Oracle)
2024-05-14 18:26 ` Florian Fainelli
2024-05-14 20:33 ` Linus Walleij
2024-05-14 20:34 ` Florian Fainelli
2024-05-15 8:36 ` Ard Biesheuvel
2024-05-15 8:45 ` Geert Uytterhoeven
2024-05-15 8:49 ` Ard Biesheuvel
2024-05-15 9:21 ` Geert Uytterhoeven
2024-05-15 9:39 ` Ard Biesheuvel
2024-05-15 11:58 ` Linus Walleij
2024-05-15 14:05 ` Geert Uytterhoeven
2024-05-15 8:48 ` Russell King (Oracle) [this message]
2024-05-15 8:53 ` Ard Biesheuvel
2024-05-15 12:27 ` Russell King (Oracle)
2024-05-15 15:41 ` Ard Biesheuvel
2024-05-15 16:18 ` Russell King (Oracle)
2024-05-15 16:36 ` Ard Biesheuvel
2024-05-15 21:51 ` Arnd Bergmann
2024-05-15 8:10 ` Geert Uytterhoeven
2024-05-14 7:37 ` Linus Walleij
2024-05-14 14:39 ` Catalin Marinas
2024-03-12 17:45 ` [PATCH v3 0/4] PAN for ARM32 using LPAE Florian Fainelli
2024-03-13 8:13 ` Linus Walleij
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=ZkR25mhjZ0z5XsmM@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=f.fainelli@gmail.com \
--cc=geert@linux-m68k.org \
--cc=keescook@chromium.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=wahrenst@gmx.net \
/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).