Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6459830pxb; Tue, 15 Feb 2022 02:58:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnGM9KT9SZEAF3YIk4uc1CClu5wBWn3HB9L74ZCFSGLPs/c1ir9wqK+yjlmVBU0FBtkx45 X-Received: by 2002:a63:e70b:: with SMTP id b11mr3055651pgi.142.1644922732097; Tue, 15 Feb 2022 02:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644922732; cv=none; d=google.com; s=arc-20160816; b=bF/mKW39kTWzrfjwF1UY9BhrCWukoj/ZdYXtK2YbWSID0JufToU69pZf+VGenFsTcq 7fIGHdCsJjxgc+6DNQ32thFJBT+R/ZxkKZD1rtTv0wa+i2iBhJpYQ8gX+37m7C0huyx9 ecoQfk2MHSIteASls/6gxewgQqHu+i+fKYFyxwYM/88Cqb2SVeX4H/SDbvJsGYTzdHYo 6hKaHPb4ojggT5oi70y9J/+G4GncfPyVh4KdlxWUxyH0Kd2lzeJSrkGWWgcpJhAw+4pl +9/L+SxeE36mmZcE2kC0fLVntPhiaad1OO8tQiRG8/eZN36Ju8fn4AflF6CTgC6igmSg 7ZSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=gTqFxxdsYHPOGJ928R38Rk2B8qfjJNH55PMauVMgYKg=; b=aYW55dgZcTpMiMKGPTKcSFk7hWBfuryvXu0E9S4qL8HvLjYczhlxOX5tfwvvdwWxB6 Qu92XH3aWJPim35FwV3d5nMAN4kCRIkCDSI9liYVQvNp2KVPftMBduhUgvdLmdWzj50+ lSpm+J852ZH9kVZtnIcSg/5BKQOspIsA3V6Xq+k6bnIA3NTKHNp4WF/C8y9C6dWhzTm4 lxnbMZxyMANyS68w35qd4Cv0fdaOlLDtLxulQ2yfzgSrbfWtlp2jNd5GrK6HGhv4kYIc kCoNSsRcqG4/zIYFbRuEh2ZtAcxDEXXVuAtVnUIfGFSqJ6vZB8rknv6tU1STtr2ZHSbS iExw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RAHiiSoO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bj8si2624362pgb.745.2022.02.15.02.58.38; Tue, 15 Feb 2022 02:58:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RAHiiSoO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235812AbiBOJVp (ORCPT + 99 others); Tue, 15 Feb 2022 04:21:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231371AbiBOJVn (ORCPT ); Tue, 15 Feb 2022 04:21:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A231F13DFB; Tue, 15 Feb 2022 01:21:33 -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 ams.source.kernel.org (Postfix) with ESMTPS id 56034B81809; Tue, 15 Feb 2022 09:21:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14939C340F1; Tue, 15 Feb 2022 09:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644916891; bh=RZSvrBa9M+3bZFIsmIZDqZd7d5VDsf+KxZINLGmOa8g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RAHiiSoOT+qkGjStonZhYrYy/J3OZkS+nBm5D1plR6odf8spdLFI55sA0GVSG+gX1 FmPcCDRzKeNuLVHvCjfGJTHBTxbwgzR030DFU2LsjuGz8pZEhKbeR/hgIeCQIxEcqx HIj4CCTOLKxrGhK2W31aOh+D7o/B8cTcO951Ev77NRvhE6lAtkLsACcoUhM/z6tTLu qhTXBSD0ylFj48SjE2u2QLeEZrRNw+HEiuL8QU8JNZPpShvXVrQypqOZsWhDE9yRc2 D5rdiVAwgITkzu5kXiFsxejSLdB78l1bk+Ac3J6FFkDPU8n6d+5fZ9lqTH30MQ3R7+ eJDiITKNJvo0Q== Received: by mail-wr1-f53.google.com with SMTP id u1so17209940wrg.11; Tue, 15 Feb 2022 01:21:30 -0800 (PST) X-Gm-Message-State: AOAM533FzJSsT8a7w1ImWBVvt3HK9GnWvbMGEtf/XTO1+QttXjfyOpGP fFIXt+xpSAJIbkE0u6f2d3wLzhIDWQZ2eryvBuk= X-Received: by 2002:adf:da4c:: with SMTP id r12mr2454185wrl.550.1644916889390; Tue, 15 Feb 2022 01:21:29 -0800 (PST) MIME-Version: 1.0 References: <20220214163452.1568807-1-arnd@kernel.org> <20220214163452.1568807-9-arnd@kernel.org> In-Reply-To: From: Ard Biesheuvel Date: Tue, 15 Feb 2022 10:21:16 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 08/14] arm64: simplify access_ok() To: Arnd Bergmann 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" X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Feb 2022 at 10:13, Arnd Bergmann wrote: > > 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. > arm64 also has this leading up to the range check, and I think we'd no longer need it: if (IS_ENABLED(CONFIG_ARM64_TAGGED_ADDR_ABI) && (current->flags & PF_KTHREAD || test_thread_flag(TIF_TAGGED_ADDR))) addr = untagged_addr(addr); > 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