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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6787FC4167D for ; Tue, 15 Feb 2022 09:13:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235702AbiBOJNN (ORCPT ); Tue, 15 Feb 2022 04:13:13 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233369AbiBOJNJ (ORCPT ); Tue, 15 Feb 2022 04:13:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E751224BC1; Tue, 15 Feb 2022 01:12:59 -0800 (PST) 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 637BE616C6; Tue, 15 Feb 2022 09:12:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5E00C34101; Tue, 15 Feb 2022 09:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644916378; bh=nPLs5v71E/xzzKRq/jdD2UxtX1DBSgxHKB2i8EHy1KY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=j3kUIfoQTYxq0nCVjg3xJUAdSTCwwH8temh7NFjmZfpkIjAXQ/i5eqNNYmAAO/ny1 Uhrqg321bjTbiL2bLfcsiw3L/YssCCJFSkB1FTV4deiCrv9oCd+WLuGBXT1JJy17rS k8cMdKEehveud6wTzU+zMEsNNO9j8HHxKx2E1NBNFWFufNsE2sT4ymojJeWA5L/d5h cw/DGlUHQEdW9cC4Q+y80YkhF8+ZZBz928QLF/gO6sphG+kkzt0wgVNEOYTAhGmy7s fFzb6USqyb2JRrGEB+Xy9zVF9/7CIibD5o8jjgMioj1JxGYIThdIqK2msRJNx3V5hb RhnYTF7LWjKEQ== Received: by mail-wr1-f53.google.com with SMTP id s10so17397971wrb.1; Tue, 15 Feb 2022 01:12:58 -0800 (PST) X-Gm-Message-State: AOAM5326jOU9poDd7nicGzGVYqcKXu6zBv1rw1GVFd7ne8SXkSFiRPjk 0nhHrMbsfN7Si6N9gM2CoMfhsBGks4+0R8nwRUE= 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 Cc: Linus Torvalds , Christoph Hellwig , linux-arch , Linux Memory Management List , Linux API , Arnd Bergmann , Linux Kernel Mailing List , Russell King , Will Deacon , Guo Ren , Brian Cain , Geert Uytterhoeven , Michal Simek , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Dinh Nguyen , Stafford Horne , Helge Deller , Michael Ellerman , Peter Zijlstra , Ingo Molnar , Mark Rutland , Heiko Carstens , Rich Felker , "David S. Miller" , Richard Weinberger , X86 ML , Max Filippov , "Eric W. Biederman" , Andrew Morton , alpha , "open list:SYNOPSYS ARC ARCHITECTURE" , Linux ARM , linux-csky@vger.kernel.org, "open list:QUALCOMM HEXAGON..." , linux-ia64@vger.kernel.org, linux-m68k , "open list:MIPS" , Openrisc , "open list:PARISC ARCHITECTURE" , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" , linux-riscv , "open list:S390" , Linux-sh list , "open list:SPARC + UltraSPARC (sparc/sparc64)" , linux-um , "open list:TENSILICA XTENSA PORT (xtensa)" , Robin Murphy Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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