Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1618044iog; Thu, 16 Jun 2022 10:00:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tSg/pinfO5n/x8w87FIMvkR/jwvaADkrVpPk7j+OdWVyvG6UeSgaH311gwG5MWkN7hMSYl X-Received: by 2002:a05:6a00:2291:b0:51b:e4c5:627 with SMTP id f17-20020a056a00229100b0051be4c50627mr5712303pfe.20.1655398841511; Thu, 16 Jun 2022 10:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655398841; cv=none; d=google.com; s=arc-20160816; b=m5s//HBNv/Ssp8VxkuLmsuvTEU4YuhVEDCXZzqsly+sAcooEg1fVvv6moJeaGGc6AZ mWSYOJWqTFnk1WNP+NrOZh+KwtdjDTNqnnwupG6FM6AHXX5GrrP7nVhCJsdaRvgq6qcl kk2ZZQpRlOhNVqYkpljnmWUrEpiph0LSF6aAibpgzSq+o8jR29LHMO0uNI/7F7FoO8Pc GQCk/3dkZBtco2YbagstZWeuyytknUc5aBYZmZFJTlmlBfEEKobJDRn1wuy9Nk3reebq ZR1Ox4C/LMDHBOKhHP77tM16qulNGvStvXPfxUlCvHOepKU6oF9H2UwIdqNhNTDkq6fp 0gXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=E+hUADyS7A1YxlHY7IKJmNZGE5eWubzR/pZENls0C+I=; b=tswCoBpUzWkWy675+gFzkpdBZMCW4ZQi0T7wFzQscR6Rxz/jzPw8vRyHOBLXGj4RJc /x0Ii8GFk1zRUycsMN11Z5yonz6vaHz2Tj8z5fTE6D7MeaDDLGyAaMy5pmB3dRWyTN2J xvV0wLu2UIi2Q190taL3dUgb7cm81vW+59Tst7z06QOOTeB7Ob3PgBB31yoxyu7yxYwm EmN12smOv33rPRyQxDj0elGH5TmQWYN+Ld8idpyaP0GQULfGzo3Mo/hn7vc7JSqjDNPj Mov68Rcrv7z2Bjl+ZvfOVgtiGc4EtHojmYttIcKLnwqK3odzziLIcDl00ennCOLf9I55 5yZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=g48Keobn; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 186-20020a6308c3000000b00403f98eb964si2943680pgi.202.2022.06.16.10.00.29; Thu, 16 Jun 2022 10:00:41 -0700 (PDT) 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=@intel.com header.s=Intel header.b=g48Keobn; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378238AbiFPQtI (ORCPT + 99 others); Thu, 16 Jun 2022 12:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378048AbiFPQsz (ORCPT ); Thu, 16 Jun 2022 12:48:55 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A78B42E3 for ; Thu, 16 Jun 2022 09:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655398134; x=1686934134; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=SqLD6j6CK4H0MlXRyMIS5Rw1htjMR+a33Z1guh6Ibgk=; b=g48Keobn3QFaPdkiSpOAOpzzAGedybT8HJHtfdKA4PBHqehc813rAm+J XJ5k/J3CvHk8g4zBj21nxmLOjTNXfff6w2kuPMrt6FIqzwmiCvzuSRoNX Wjm/80L33riVuQRiQDnvaQDRMZ6+NYkcn54Dau++Ne7GFz6ZqGRaqTA8q 9Pyjh9JVMygaDijhYh9iKZleYYnQRq7xhLKyGaeAz6N3IchcASQ19Ldq8 kA6GqEMpE4zTP0VqT7d+xcbH89sZtYZtDlQ0gxiUdjVx+ijbL/WkT+G7A hOXwAhRwxO6sJ7VcryfojhMZeV0G+QzkkJAp00Ji7qsoRVeuaEjNj/QpS A==; X-IronPort-AV: E=McAfee;i="6400,9594,10380"; a="340948418" X-IronPort-AV: E=Sophos;i="5.92,305,1650956400"; d="scan'208";a="340948418" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2022 09:48:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,305,1650956400"; d="scan'208";a="575334770" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 16 Jun 2022 09:48:50 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 348DD109; Thu, 16 Jun 2022 19:48:54 +0300 (EEST) Date: Thu, 16 Jun 2022 19:48:54 +0300 From: "Kirill A. Shutemov" To: Peter Zijlstra Cc: Dave Hansen , Andy Lutomirski , x86@kernel.org, Kostya Serebryany , Andrey Ryabinin , Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv3 5/8] x86/uaccess: Provide untagged_addr() and remove tags before address check Message-ID: <20220616164854.oyvfpl3tzqj54rd6@black.fi.intel.com> References: <20220610143527.22974-1-kirill.shutemov@linux.intel.com> <20220610143527.22974-6-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 Thu, Jun 16, 2022 at 12:02:16PM +0200, Peter Zijlstra wrote: > On Fri, Jun 10, 2022 at 05:35:24PM +0300, Kirill A. Shutemov wrote: > > +#ifdef CONFIG_X86_64 > > +/* > > + * Mask out tag bits from the address. > > + * > > + * Magic with the 'sign' allows to untag userspace pointer without any branches > > + * while leaving kernel addresses intact. > > + */ > > +#define untagged_addr(mm, addr) ({ \ > > + u64 __addr = (__force u64)(addr); \ > > + s64 sign = (s64)__addr >> 63; \ > > + __addr ^= sign; \ > > + __addr &= (mm)->context.untag_mask; \ > > + __addr ^= sign; \ > > + (__force __typeof__(addr))__addr; \ > > +}) > > Can't we make that mask a constant and *always* unmask U57 irrespective > of LAM being on? We can do this if we give up on LAM_U48. It would also needlessly relax canonical check. I'm not sure it is a good idea. -- Kirill A. Shutemov