Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp586081pxb; Tue, 15 Feb 2022 22:57:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1RRW/poEO07FBdyjWtoiu7xH4U0bX2jpklv2H/1JopbxRM579hpBcoarelEKPX8VXMvWu X-Received: by 2002:a17:90b:1b0b:b0:1b9:bfa8:89a5 with SMTP id nu11-20020a17090b1b0b00b001b9bfa889a5mr164202pjb.211.1644994677254; Tue, 15 Feb 2022 22:57:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644994677; cv=none; d=google.com; s=arc-20160816; b=XLTPWV9Dej6cz704QIH21dVicul9yolpB08Ra2kWjrPshMfptEfGMNFOIxMwMCTIZ3 hwsEm0kjBsQuysllqGNjAH0nXGxeJFbYqr6MMvQQrEd73wqZWSDSXqNg2ey76YVkO/0p 8BTmcz1Q5tQCp0N/DSPx4C0aSDjo0OzubtbxPoPwNH47wAqstmsbRy1Uuc0M7p3kaTH9 gQgxm4K1MX/RC1b3RGKKgvMenzPGFBwxByl+XANGcya39f/zqMXC7BgkJbToNL5iaxrM VoBQ5Q5GsrJ7aP+BpuRSD6IPBhGeD9n1k+Cf9Zb9AI9pkjJYOvewydmJpxyDZ+zUCfCT sfxw== 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=rJNcvnIvfUNmsgHtbpVXKNJCG6L/rzFL5KZZloILW34=; b=E5JqlI/FgbUncIyocilYkey6wFMZMmgzP+5jHVe/Wx36kmjInCQBPoAAeMiMGxvpBB /Taw2sI1r4ORIkO5hjKWCUDEAl2jZvsOQH+2MRdbm0FcNsBpLFWA0dV0Kjj36VOMAQbp aKznXfR9ksThqkMbO2x8bclQUtsZ3lHEHGHfcxYd+YhEIs1qJ0bVgL9HCHqOk2iG2x2R 8F8zgCieI4THGvL5UNUK8wpy6/gnZb+CqHzHw3MDLz8aIWFTBA7gtzEnWWsPerQBI2y+ fTV8dC4AKH4VcZRSwe1nW76Xdd00Dm7vDKgpuOkTN0r0CBUwF3tkRymwYye4NbOliEl5 USqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qgz5FlPp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t7si17249845plz.412.2022.02.15.22.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:57:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qgz5FlPp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 299B32311BB; Tue, 15 Feb 2022 22:40:03 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235969AbiBOJkS (ORCPT + 99 others); Tue, 15 Feb 2022 04:40:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234609AbiBOJkR (ORCPT ); Tue, 15 Feb 2022 04:40:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48CECE3881; Tue, 15 Feb 2022 01:40:07 -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 D11C2B8185C; Tue, 15 Feb 2022 09:40:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D751C340F9; Tue, 15 Feb 2022 09:40:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644918004; bh=hv8AUuEMkapI1zY2x6Wj+fHd7ew8TaKYgsOBPTPrxmw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Qgz5FlPpKWsWGCSKlOreQeA49RzB47Yb61DpdQGkSqCvpQXhd/1xrVzA6HxgVkOAv HM/bWEouCkOrFRfLVSWs2TAF8Lvnm82Q7ljXZwaQBoSUgr63Phu8Xh5sdVnTyJI/ON lHIubRtLqY287IV/RrnG/iEcxILMQsa62F1uuyYy08GpnMfCYeG+01yyQZZn7UnJv7 021LqbfWi1zld4k8/8Wmx6fnGfR5no+iR4l8Y+N7e700ePaO67g4IaN0y0Orgs7STR gYOAdpNAvnxBHFJPJ1WrXSLgaxHaPAb+pRZVWsShzWY/LNUX3cgIy9+U52JoF4j03G HEN4j4yjmnzVQ== Received: by mail-wm1-f49.google.com with SMTP id j9-20020a05600c190900b0037bff8a24ebso1024782wmq.4; Tue, 15 Feb 2022 01:40:04 -0800 (PST) X-Gm-Message-State: AOAM531J5BbA2tq+ZrO2lMXu1GyShx/RoveGKKoSQ3d4y/40vJp0pF5k 5RSVmhlT3A9RLcg1FrOEAGhO7GBLSr55OHQcjeQ= X-Received: by 2002:a05:600c:1d27:b0:37c:74bb:2b4d with SMTP id l39-20020a05600c1d2700b0037c74bb2b4dmr2314325wms.82.1644918002508; Tue, 15 Feb 2022 01:40:02 -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:39:46 +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=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 10:21 AM Ard Biesheuvel wrote: > On Tue, 15 Feb 2022 at 10:13, Arnd Bergmann wrote: > > 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); I suspect the expensive part here is checking the two flags, as untagged_addr() seems to always just add a sbfx instruction. Would this work? #ifdef CONFIG_ARM64_TAGGED_ADDR_ABI #define access_ok(ptr, size) __access_ok(untagged_addr(ptr), (size)) #else // the else path is the default, this can be left out. #define access_ok(ptr, size) __access_ok((ptr), (size)) #endif Arnd