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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1257DC433F5 for ; Tue, 15 Feb 2022 09:21:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77C336B0078; Tue, 15 Feb 2022 04:21:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 72C426B007B; Tue, 15 Feb 2022 04:21:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CC896B007D; Tue, 15 Feb 2022 04:21:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id 4AC426B0078 for ; Tue, 15 Feb 2022 04:21:34 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 015ED8249980 for ; Tue, 15 Feb 2022 09:21:34 +0000 (UTC) X-FDA: 79144471308.13.A1E1C55 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id 69980C0002 for ; Tue, 15 Feb 2022 09:21:33 +0000 (UTC) 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 BF96660AFD for ; Tue, 15 Feb 2022 09:21:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20453C340F8 for ; 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-f41.google.com with SMTP id d27so30967485wrc.6 for ; Tue, 15 Feb 2022 01:21:30 -0800 (PST) X-Gm-Message-State: AOAM532mTcQIkMrSzF5FHEJBwIxAJlxllcB7WluCHggm10tESY4gXz2P es4ZBrrVhMrUEpMojDHQ2s9T6eleOiuFjldk2E4= X-Google-Smtp-Source: ABdhPJxTZ3T3Abm/GIU6+FEpYkuoBAl5nS/ZOniPodztANRfoa0z/A0V8x7uBN46c9isaaDTdlBbvvwdEiVYUyGe5DM= 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-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 69980C0002 X-Stat-Signature: 7p9q3p59xtyr14uoozu9c1ig16xsmoh7 X-Rspam-User: Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RAHiiSoO; spf=pass (imf10.hostedemail.com: domain of ardb@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=ardb@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1644916893-748830 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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