Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp15179pxb; Tue, 15 Feb 2022 04:42:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIG5KnxPSFtwe7pwAeAcd6jKWSppH28hDONp4948GwIHSzkAog2Q2riSLPINlpGTpFMd4h X-Received: by 2002:a17:907:9707:: with SMTP id jg7mr2118398ejc.705.1644928920139; Tue, 15 Feb 2022 04:42:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644928920; cv=none; d=google.com; s=arc-20160816; b=xMM7CuEpXu0wUKjGNnXQCf8S3AZ2NPJT7If7b8i2Nn1H9dXmS7vK2RTgiYkZgcQRwo nyNogj53v/sxdcQ+HUNXrGWFCut1UN9rQ1SnL6I6sRMqGXqN7R5+N4d8xmeVEE2rtq1b H+mdPZxMeM7r/Wqp683mxEdpXNn0q3HtrGVeEd6c4v2F4+awo9ohJTbUKO8MgrDByskJ aDBXMvczhNcpJLB6908Wi2j3zyHRFsK4N3/w0epgfT8m2VN6dOvpamqfk0Rv6ptc/xdO hg7JHvthlcaH69zJ8sawMKWTRExYLX3Uz7eYUOZZGR7XBfIrECeK+vtcsCR5YgrCjlrm zYaA== 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=xkAlKGF7idMrjRvIPaXbEJsfhvU5ArmygMbRDQgslYo=; b=JEBAbnlNYe+h671Ltwpi8GxXtW3ovBkl8m2V3YnCDPi81hXhmrSVk0NtAa2LQAt/Yu aukkyCvWQH8wcoNUMeLFzuknNROcl2HWx6Cw2JUOVkLrrGgKXMW3yqkGGYxEXUvLRARm iFlrPBtDlFM9DE2gIz+J/1g4+2sPf8wztjKi4XvKI5PgetD4wzolTotkHXuXcz4SeOR2 0TEaRSpEPZTd6sp9N/+nEEXqqagYF9xartWEVHkg3lW6tCL/HG6fO2HPYsqiaNqwsNAd NimAT3nlamttthVNH8IiekYxuRWm0NA54ulu6UvEjjwvU5p+NHsO7Z0qzZzU6cv4nvPs JICw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j3kUIfoQ; 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 g9si6409645ejt.520.2022.02.15.04.41.36; Tue, 15 Feb 2022 04:42:00 -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=j3kUIfoQ; 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 S235698AbiBOJNL (ORCPT + 99 others); Tue, 15 Feb 2022 04:13:11 -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-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" 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, 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