From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99C08C433F5 for ; Tue, 15 Feb 2022 09:13:51 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Jyb4F46Pwz3cDy for ; Tue, 15 Feb 2022 20:13:49 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=CLHePkmH; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2604:1380:4641:c500::1; helo=dfw.source.kernel.org; envelope-from=arnd@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=CLHePkmH; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Jyb3W6ZpRz2xKK for ; Tue, 15 Feb 2022 20:13:11 +1100 (AEDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3CA25616C4 for ; Tue, 15 Feb 2022 09:13:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9301C340F1 for ; Tue, 15 Feb 2022 09:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644916388; bh=nPLs5v71E/xzzKRq/jdD2UxtX1DBSgxHKB2i8EHy1KY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=CLHePkmHVvog2B9hZC9aG4LabFSm7MI26At0uDw7kKPNYpb3lXWOmUP31vrn/n3jp 21c83PolyTPYs5hRtHSTmetuMdjz8MVwbtB9QE4JUqwfDE9UaiWLco96WTCCiREXeo ierknOIrVYt+cFHPhwjyPUqaAdv+eYt2hib0l9mVhvFWKgaTt9gitGLgKmM8vAP2ER AePVXGloKhok6IjT1wO1H+WVX/SWPGV2/x59O7cRGdhpYbEJd41Qa4hwZk6q55miTE kziCS4wP1Lkxi5K05R+6K/1DypZ1QzcheN727Vb2P8JghtAuyZKDU7SLg9/rJcHwJ6 ZWZc1SanLSgow== Received: by mail-ed1-f41.google.com with SMTP id z13so12715958edc.12 for ; Tue, 15 Feb 2022 01:13:08 -0800 (PST) X-Gm-Message-State: AOAM5300Turh2fvH5+stutxN8aQYhBUmHyUvBJat1AjA/DTutxqr71l7 +0bp6WwlxFkML7N5lznYYetNELFX7xrCy8kHM1g= X-Google-Smtp-Source: ABdhPJwP302M1cXBE3IXsZS/v83gWi9XJR2q13sQJhY9b6tnSpJCd4099durtVh9QEm0yhQ4WeUq4MKNAAS9P/JPfzc= X-Received: by 2002:adf:f6ce:: with SMTP id y14mr2380558wrp.219.1644916376776; Tue, 15 Feb 2022 01:12:56 -0800 (PST) MIME-Version: 1.0 References: <20220214163452.1568807-1-arnd@kernel.org> <20220214163452.1568807-9-arnd@kernel.org> In-Reply-To: From: Arnd Bergmann Date: Tue, 15 Feb 2022 10:12:40 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 08/14] arm64: simplify access_ok() To: Ard Biesheuvel Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Rich Felker , linux-ia64@vger.kernel.org, Linux-sh list , Peter Zijlstra , "open list:MIPS" , Linux Memory Management List , Guo Ren , "open list:SPARC + UltraSPARC \(sparc/sparc64\)" , "open list:QUALCOMM HEXAGON..." , linux-riscv , Will Deacon , Christoph Hellwig , linux-arch , "open list:S390" , Brian Cain , Helge Deller , X86 ML , Russell King , linux-csky@vger.kernel.org, Ingo Molnar , Geert Uytterhoeven , "open list:SYNOPSYS ARC ARCHITECTURE" , Robin Murphy , "open list:TENSILICA XTENSA PORT \(xtensa\)" , Arnd Bergmann , Heiko Carstens , alpha , linux-um , "open list:LINUX FOR POWERPC \(32-BIT AND 64-BIT\)" , linux-m68k , Openrisc , Greentime Hu , Stafford Horne , Linux ARM , Michal Simek , Thomas Bogendoerfer , "open list:PARISC ARCHITECTURE" , Nick Hu , Max Filippov , Linux API , Linux Kernel Mailing List , Dinh Nguyen , "Eric W. Biederman" , Richard Weinberger , Andrew Morton , Linus Torvalds , "David S. Miller" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Tue, Feb 15, 2022 at 9:17 AM Ard Biesheuvel wrote: > On Mon, 14 Feb 2022 at 17:37, Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > 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. Arnd