Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp123812rwr; Wed, 3 May 2023 23:52:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62LF+DhrjGXzC+7rDObBYJG/q4VXugqIWpsCnXnD5skbbHjLW/uQi95Y7gszpFTt5pa0HV X-Received: by 2002:a17:90a:8381:b0:247:944d:b75e with SMTP id i1-20020a17090a838100b00247944db75emr1253910pjn.12.1683183147497; Wed, 03 May 2023 23:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683183147; cv=none; d=google.com; s=arc-20160816; b=LHFPdMYNjX/jeL2CbP6gyJDHATi15YQZUu53VRLBVSnVPaMZ1+eU+mo5D0xyxm9c83 EwelRtC/ouoI8QGDnfIOXa3H9rGIfKvoN9cnnizW7E/5X2pAy0QTWYHJLe14KVACnCB5 QyvNqYWG3bHeOpQJMRNQNSNZD91/270gyRO7WeXraKoV4FmtBr+o7zlqWSP65MVvZBrR RjHu1w/KpzLWPWrLVNpxQb98bJyqkc73gHr9cBt1BfZ28/AAl2WLGgcNAvGuuBd1qMIf weE6WMGStbhSBANol+8p7NjLYPfnQaPyKOzXepqqA2Pb2PMUPkIaz2m+u8ILfVsqtQPD y/ZA== 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:feedback-id :dkim-signature:dkim-signature; bh=nTHXfZvsKH6NImQKdo/JKzYWy+5g9P8ww+u3FrTSJDk=; b=W6leIbvHQT7Hx2mK3N6OtvVKL0SxFvmiX4zWQQuTZaGZ/pvIT51Rz74CVFF6+xT5sz +tWBoV/+lsFgJdejPcVBymaIHIM43tWKy3befqVOuAeWGAtU3c/UMlaF/Jw7J2vdmy6C 2CLxjRpH4imngYaEK93rdc6+6belOO/StCW+TXaRPbx91OmcTvQ2jJg7UqLJFCLN5Wa8 tFLLWnqT8RNC6hbrgdETMtGEE26BUM9I2qrfzN2Y8JWccHYpkBZNW7Ed9fygl0nJ0Xxc pHmcJmWzM3fBXT5xrCTs3G5sRqDMHEFHTk9t/7VJRV63IOa1GUm8Av+H0ne366NuKyQE +9aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b="IjXgf9/j"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=VCJMS6hF; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mg24-20020a17090b371800b0024b3c34ca20si3286847pjb.55.2023.05.03.23.52.13; Wed, 03 May 2023 23:52:27 -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=@shutemov.name header.s=fm2 header.b="IjXgf9/j"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=VCJMS6hF; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229914AbjEDG2h (ORCPT + 99 others); Thu, 4 May 2023 02:28:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbjEDG2f (ORCPT ); Thu, 4 May 2023 02:28:35 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44224E65 for ; Wed, 3 May 2023 23:28:34 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 9967B5C0195; Thu, 4 May 2023 02:28:31 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 04 May 2023 02:28:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1683181711; x= 1683268111; bh=nTHXfZvsKH6NImQKdo/JKzYWy+5g9P8ww+u3FrTSJDk=; b=I jXgf9/jm5NzTWuGXad1eJ5T5bthKlUf/yVG2RTGHmQPa056XIB66TQqL8cU92wXg gfQm/K+x3Rg8iVx+RUBMawjqwveR8owUiOCMOiPVmCW1FqSQYjrBHB4wlg49l5/M i5eDkJGKVQ2pd72NCjnooIwOL0StargaYU63IKOUBLa+jT8uI0yzU58xD/nledTf tT0Acrfzkh8SjA7SS0S9UtaKc0uPxnWxbjV58svEBOxPLOYzu1ObWCZeY3TgkDvf Alp7M7Q5oJGxc+dpy31TEbmVGNPaE8rVNmLxQ4FvIRIEJ2a8Hj5DP6DXuOAL+ouJ QFdZUwAsc4glvn0bYSDIg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1683181711; x=1683268111; bh=nTHXfZvsKH6NI mQKdo/JKzYWy+5g9P8ww+u3FrTSJDk=; b=VCJMS6hFuG8G/ZmBGtXm++o+3HPSO TK1p6GGLtULE+zBeA9X6/erKexMYZjI4Dp95kKIu9+9tcUkWGvV8CbfPcyMgduey G/0k7kvHvDb69fdg7h2Qg8BQXSQl82bYawHLD6BGjblRSvCmFZ/kSaK943cvwcMU 9KfC8bOd6wn4F4QyU6CwfJ4wKYhrLXF0cVsWTNPuQDG+ujQaaZ8pqAe+1Gn4ZUxh Xgc7asc9QbEGO3mX9Q3/YOTNH3eeVvvPaN0XSYasC1tlBhp5jJqvj4tillro7/fZ z4ABkRgC4yWRj0ogsP3YYGtSSKxQFOOd6pChfrJQkv5uP5JPydMTluPsg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedvledguddtiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttddttddttddvnecuhfhrohhmpedfmfhi rhhilhhlucetrdcuufhhuhhtvghmohhvfdcuoehkihhrihhllhesshhhuhhtvghmohhvrd hnrghmvgeqnecuggftrfgrthhtvghrnhephfeigefhtdefhedtfedthefghedutddvueeh tedttdehjeeukeejgeeuiedvkedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepkhhirhhilhhlsehshhhuthgvmhhovhdrnhgrmhgv X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 May 2023 02:28:30 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id 2AF5010CE5A; Thu, 4 May 2023 09:28:27 +0300 (+03) Date: Thu, 4 May 2023 09:28:27 +0300 From: "Kirill A. Shutemov" To: Linus Torvalds Cc: Dave Hansen , Dave Hansen , x86@kernel.org, linux-kernel@vger.kernel.org, kirill.shutemov@linux.intel.com, Peter Zijlstra Subject: Re: [GIT PULL] x86/mm for 6.4 Message-ID: <20230504062827.algltnmlddtzmfz5@box.shutemov.name> References: <20230427225647.1101172-1-dave.hansen@linux.intel.com> <20230429003822.n3mglslg666j3npp@box.shutemov.name> <641a9348-a052-6bb5-e6c7-64acb6405328@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Wed, May 03, 2023 at 09:38:03AM -0700, Linus Torvalds wrote: > > Why does it do that "shift-by-63" game there, instead of making > > tlbstate_untag_mask just have bit #63 always set? > > And it turns out that bit #63 really _is_ always set, so I think the > solution to this all is to remove the sign games in untag_addr() > entirely. Untagging kernel pointer with LAM enabled will land it in the canonical hole which is safe as it leads to #GP on dereference. > Untagging a kernel address will "corrupt" it, but it will stay a > kernel address (well, it will stay a "high bit set" address), which is > all we care about anyway. The interesting case to consider is untagging kernel pointer when LAM_U48 is enabled (not part of current LAM enabling). LAM_U48 would make the untagging mask wider -- ~GENMASK(62, 48). With 5-level paging and LAM_SUP enabled (also not supported yet) untagging kernel may transform it to other valid kernel pointer. So we cannot rely on #GP as backstop here. The kernel has to exclude kernel pointer by other means. It can be fun to debug. Looks like you are not worried about this kind of corruption. Hm. Maybe it worth to indicate in the helper name that it is intended only for userspace addresses? Rename it to untagged_uaddr() or something? -- Kiryl Shutsemau / Kirill A. Shutemov