Re: [PATCH 08/14] arm64: simplify access_ok()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Arnd Bergmann <arnd@xxxxxxxxxx>, Ard Biesheuvel <ardb@xxxxxxxxxx>
- Subject: Re: [PATCH 08/14] arm64: simplify access_ok()
- From: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
- Date: Wed, 16 Feb 2022 19:43:22 +0000
- Accept-language: fr-FR, en-US
- Cc: Mark Rutland <mark.rutland@xxxxxxx>, Rich Felker <dalias@xxxxxxxx>, "linux-ia64@xxxxxxxxxxxxxxx" <linux-ia64@xxxxxxxxxxxxxxx>, Linux-sh list <linux-sh@xxxxxxxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, "open list:MIPS" <linux-mips@xxxxxxxxxxxxxxx>, Linux Memory Management List <linux-mm@xxxxxxxxx>, Guo Ren <guoren@xxxxxxxxxx>, "open list:SPARC + UltraSPARC (sparc/sparc64)" <sparclinux@xxxxxxxxxxxxxxx>, "open list:QUALCOMM HEXAGON..." <linux-hexagon@xxxxxxxxxxxxxxx>, linux-riscv <linux-riscv@xxxxxxxxxxxxxxxxxxx>, Will Deacon <will@xxxxxxxxxx>, Christoph Hellwig <hch@xxxxxx>, linux-arch <linux-arch@xxxxxxxxxxxxxxx>, "open list:S390" <linux-s390@xxxxxxxxxxxxxxx>, Brian Cain <bcain@xxxxxxxxxxxxxx>, Helge Deller <deller@xxxxxx>, X86 ML <x86@xxxxxxxxxx>, Russell King <linux@xxxxxxxxxxxxxxx>, "linux-csky@xxxxxxxxxxxxxxx" <linux-csky@xxxxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>, "open list:SYNOPSYS ARC ARCHITECTURE" <linux-snps-arc@xxxxxxxxxxxxxxxxxxx>, Robin Murphy <robin.murphy@xxxxxxx>, "open list:TENSILICA XTENSA PORT (xtensa)" <linux-xtensa@xxxxxxxxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, Heiko Carstens <hca@xxxxxxxxxxxxx>, alpha <linux-alpha@xxxxxxxxxxxxxxx>, linux-um <linux-um@xxxxxxxxxxxxxxxxxxx>, "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" <linuxppc-dev@xxxxxxxxxxxxxxxx>, linux-m68k <linux-m68k@xxxxxxxxxxxxxxx>, Openrisc <openrisc@xxxxxxxxxxxxxxxxxxxx>, Greentime Hu <green.hu@xxxxxxxxx>, Stafford Horne <shorne@xxxxxxxxx>, Linux ARM <linux-arm-kernel@xxxxxxxxxxxxxxxxxxx>, Michal Simek <monstr@xxxxxxxxx>, Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>, "open list:PARISC ARCHITECTURE" <linux-parisc@xxxxxxxxxxxxxxx>, Nick Hu <nickhu@xxxxxxxxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, Linux API <linux-api@xxxxxxxxxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Dinh Nguyen <dinguyen@xxxxxxxxxx>, "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>, Richard Weinberger <richard@xxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxxxxx>
- In-reply-to: <CAK8P3a2VfvDkueaJNTA9SiB+PFsi_Q17AX+aL46ueooW2ahmQw@mail.gmail.com>
- References: <20220214163452.1568807-1-arnd@kernel.org> <20220214163452.1568807-9-arnd@kernel.org> <CAMj1kXHixUFjV=4m3tzfGz7AiRWc-VczymbKuZq7dyZZNuLKxQ@mail.gmail.com> <CAK8P3a2VfvDkueaJNTA9SiB+PFsi_Q17AX+aL46ueooW2ahmQw@mail.gmail.com>
- User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0
Le 15/02/2022 à 10:12, Arnd Bergmann a écrit :
> On Tue, Feb 15, 2022 at 9:17 AM Ard Biesheuvel <ardb@xxxxxxxxxx> wrote:
>> On Mon, 14 Feb 2022 at 17:37, Arnd Bergmann <arnd@xxxxxxxxxx> wrote:
>>> From: Arnd Bergmann <arnd@xxxxxxxx>
>>>
>>
>> With set_fs() out of the picture, wouldn't it be sufficient to check
>> that bit #55 is clear? (the bit that selects between TTBR0 and TTBR1)
>> That would also remove the need to strip the tag from the address.
>>
>> Something like
>>
>> asm goto("tbnz %0, #55, %2 \n"
>> "tbnz %1, #55, %2 \n"
>> :: "r"(addr), "r"(addr + size - 1) :: notok);
>> return 1;
>> notok:
>> return 0;
>>
>> with an additional sanity check on the size which the compiler could
>> eliminate for compile-time constant values.
>
> That should work, but I don't see it as a clear enough advantage to
> have a custom implementation. For the constant-size case, it probably
> isn't better than a compiler-scheduled comparison against a
> constant limit, but it does hurt maintainability when the next person
> wants to change the behavior of access_ok() globally.
>
> If we want to get into micro-optimizing uaccess, I think a better target
> would be a CONFIG_CC_HAS_ASM_GOTO_OUTPUT version
> of __get_user()/__put_user as we have on x86 and powerpc.
>
There is also the user block accesses with
user_access_begin()/user_access_end() together with unsafe_put_user()
and unsafe_get_user() which allowed us to optimise user accesses on
powerpc, especially in the signal code.
Christophe
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]