Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3284032rwb; Mon, 5 Sep 2022 09:05:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR45r1P4BOnnvibJ7TLzXt2fpBiGm7mgmJALIoO9+jraHgZd719jYryHg5iothcvrUC1dN4d X-Received: by 2002:a17:90b:164a:b0:200:93cb:3c3a with SMTP id il10-20020a17090b164a00b0020093cb3c3amr176841pjb.28.1662393936371; Mon, 05 Sep 2022 09:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662393936; cv=none; d=google.com; s=arc-20160816; b=VLCyzZK8nsAUry4e9dO41QbJsVWGoQ0yNzGcigcEfTxWu1hsxOW5jxNzx+0U5TLepv ZAmi1jW8oVK5fODZIC/iqore2Tya/PILa59KYl4c1EbuVCSRGx0mGg91kE0/jPAvUobM +gfOuN6KpTLqyeETWJvO+qbYOIdNVOfxLLDrWkoo+sjq9lmH/fHJght1OIANCxgRMk4h uTrucAakPi7ZyrLxtvOTJzGFF9p1yJTqZ5bw1ADHDMzGIECaxiDVwOWF1CdGWE4L5Y+M 3KdEpMVSudU94Sb1B4Jjqi6mSJRGVBQvfppO4sXOOgjpzAsVWTXr6mtPa+y2GK7vpzz/ ZGtQ== 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=fg+XnDXSnqRCu9Mai3sCVJ/hy6+I8T4qZe1klnldH0E=; b=ZQ8nACAXbD5bqJmgWGcuzMu+/umfG+PwVa7OB5IqGftcKB91fEfXGEYEqVBN1Igf0h CjVV/m6HywzxEyI5CbjLt9sKHCZUHkZVsLAy98fdJ84md/1u3uu+kjbD7O0T3BxUYj4d aSWJHtcmNXxuhRfRmr802+98zYerX2psLj7jYwXEv625Gv7FC6j/dJicbYnH808EsoBt 08Zpon+jNO7iVXPbnLb03rfq4C78Dfm+/7Lpb1M7B+G1uYsROzKOiDozbRUc7jfVLDlw EycBdJoFddOY2X/J2FBxjDsVSX7PpJTvgudFNb7vtjbGfkdKId7C6r6oqQoPXhhKRHSr 9a2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="O/HtuUvV"; 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 w69-20020a638248000000b0042bd92a3593si10489630pgd.174.2022.09.05.09.05.23; Mon, 05 Sep 2022 09:05:36 -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=@infradead.org header.s=desiato.20200630 header.b="O/HtuUvV"; 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 S238421AbiIEPrL (ORCPT + 99 others); Mon, 5 Sep 2022 11:47:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238119AbiIEPrK (ORCPT ); Mon, 5 Sep 2022 11:47:10 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AD3648C88 for ; Mon, 5 Sep 2022 08:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=fg+XnDXSnqRCu9Mai3sCVJ/hy6+I8T4qZe1klnldH0E=; b=O/HtuUvV3KD/LNUQwARMDwjHJV dPFQsqg/DhExbykZiQfU+NspxB4AFyTc8AHX+wzXnMVbSCG9Rl6mEZ2aXoy4xYNS2LHisCdY3AClj jqIV9t2+PE6K+T5ECBOZm90//MvD9HqEvYhpaDqUeko1plcLPoijv3QB4rUrzjXHSPocnGMI0mZLU okdZsfdTCcBAoSHE9NUNdTjv62EZuCiPUYIT3rWHDL/1lVCFe97j9dUAMO4hOeQMONJrZR9BdaUnu vNW2npHJiSGDmg3t/HzVcumUIL/nHPOBffW5SodeCmQ7yrC3ATLxM1m5MAwfjk+7Qz7jQ690HDUkA 9NmoiTMA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVEJH-009meN-CX; Mon, 05 Sep 2022 15:46:51 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id AC0E430030F; Mon, 5 Sep 2022 17:46:49 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 906012B972612; Mon, 5 Sep 2022 17:46:49 +0200 (CEST) Date: Mon, 5 Sep 2022 17:46:49 +0200 From: Peter Zijlstra To: "Kirill A. Shutemov" Cc: Bharata B Rao , ananth.narayan@amd.com, "Kirill A. Shutemov" , Dave Hansen , Andy Lutomirski , x86@kernel.org, Kostya Serebryany , Andrey Ryabinin , Andrey Konovalov , Alexander Potapenko , Taras Madan , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv8 00/11] Linear Address Masking enabling Message-ID: References: <20220830010104.1282-1-kirill.shutemov@linux.intel.com> <20220904010001.knlcejmw4lg2uzy3@box.shutemov.name> <64519d0b-b696-db47-52c2-303451e10c09@amd.com> <20220905134457.a2f7uluq42frsgwe@box.shutemov.name> <20220905153517.k6ctaqqtkcyu2zmn@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220905153517.k6ctaqqtkcyu2zmn@box.shutemov.name> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 Mon, Sep 05, 2022 at 06:35:17PM +0300, Kirill A. Shutemov wrote: > What about something like this? > > diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h > index 803241dfc473..868d2730884b 100644 > --- a/arch/x86/include/asm/uaccess.h > +++ b/arch/x86/include/asm/uaccess.h > @@ -30,8 +30,10 @@ static inline bool pagefault_disabled(void); > */ > #define untagged_addr(mm, addr) ({ \ > u64 __addr = (__force u64)(addr); \ > - s64 sign = (s64)__addr >> 63; \ > - __addr &= (mm)->context.untag_mask | sign; \ > + if (static_cpu_has(X86_FEATURE_LAM)) { \ > + s64 sign = (s64)__addr >> 63; \ > + __addr &= (mm)->context.untag_mask | sign; \ > + } \ > (__force __typeof__(addr))__addr; \ > }) Well, if you go throught the trouble of adding it, might as well use a regular static branch and only enable it once there's an actual user, no?