Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2640102rwl; Mon, 26 Dec 2022 19:24:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXu2MbS3qAHJRncKWEMF8CYMTx8ikIrYlHiXFHMr40Jefgyp2gjogABItG6wx2nLAKsCBgGr X-Received: by 2002:a17:906:1c4e:b0:7c1:1c6:faea with SMTP id l14-20020a1709061c4e00b007c101c6faeamr23952053ejg.75.1672111456491; Mon, 26 Dec 2022 19:24:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672111456; cv=none; d=google.com; s=arc-20160816; b=cflyy2cELUj8/M0QiQ1rgNBC57axXj+gkrMFCwhIpCHNv9v9k0HqRQ4GPuD1ueA5vm 8MIpCvn6exKjl5G15SZsqAFSEraE+HrAvE+qkW2rajfoWmw0bYiyvMGPkBPz/4BtAZvb EP7MN+E5dc+TuJNifMKZuz2nJqpR9T0O2CPFFFPzXgWFm09LSVvLw5tl6jAUghqCfGVM EwYKSquL5/3wUp+KXPKAOZzvx5N7oeReHQtYhGIyoXTVGV2CwLXZUq0Zm8dUF6fXSuxS GMsVu2mrAOBfx/6kSAYO+60C8R5AvakEOtQYSD9espOlIf74xCJSl+cz90Fwt7pDHJpz NGSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HiQmt79j+yP5ckm1kw0E99dGcnfCgkwWTWtqPyabNRA=; b=WCDzAiTASBubNFyBMn8OUfLlwxJkti9zITkvBJTpCeNzQWUxYVUdSzrcvoIbpmPRW5 YDHU23PdeJBArXGwYONr7tvpL8XFlGChk8H5Twmx1zanudcXINYeFjnkUwUcvoH1UD8g ZCJJbIt4kY65J04fHbTb7XSJviEde43TExQT2YZveB7ITNC7v49KE83o+oq07ALeEpRW i9T3s9Ystt6/adLTfRGCQJBaxuVsrJEcjNVBmufi0/18Ga0NJ6yWApNAqBjqW/w3mbLx NQori4OxGxIUNjqKsHsQPvKrvV9x5dTA55C4N/IsKumshAAD/1X56XNSskJnm+JV8eO9 LeFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lmrozRjP; 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 la26-20020a170907781a00b007c1070653adsi7840210ejc.809.2022.12.26.19.24.01; Mon, 26 Dec 2022 19:24:16 -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=@intel.com header.s=Intel header.b=lmrozRjP; 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 S229724AbiL0DIs (ORCPT + 67 others); Mon, 26 Dec 2022 22:08:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbiL0DIo (ORCPT ); Mon, 26 Dec 2022 22:08:44 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 042F3EA5 for ; Mon, 26 Dec 2022 19:08:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672110523; x=1703646523; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gEzeHerPaWTs/tIk/qtNJxiWNCV7jnSRQjRqxLLucY8=; b=lmrozRjPyLdejz0lZR9AtOCd7P7L7iyEWEhkk+yomB75eVxMiPno0k63 IBASRkKKhn7uWMPFJk10CrNVzGGt/wC1CDfFcMx49sIRNp12vGo6hh60i lkktvLo//Lu1Tzy5iU/vI4+mmknO/Er+ZEoSYoKZ7+7f3etPZFV0bg1SH dP4igVPzo8EtZa/YXLPCpwtnIJx8p7Ia+9QzN/l6ErSYlIt5783DY/8yo Qah7p8H1mJKyicHF9W732RSxeAEPeAp+Gw6PpZMo+Cuk/UAshro/1L0RM DU16TQvEIEvzMVmO1sMDnyPJJI0yBlYuILRoX3FARtIJw0+k1jv3l8OZ3 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="300994650" X-IronPort-AV: E=Sophos;i="5.96,277,1665471600"; d="scan'208";a="300994650" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Dec 2022 19:08:43 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="741605192" X-IronPort-AV: E=Sophos;i="5.96,277,1665471600"; d="scan'208";a="741605192" Received: from ppogotov-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.62.152]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Dec 2022 19:08:39 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id 8FB6410BBAF; Tue, 27 Dec 2022 06:08:36 +0300 (+03) From: "Kirill A. Shutemov" To: Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: x86@kernel.org, Kostya Serebryany , Andrey Ryabinin , Andrey Konovalov , Alexander Potapenko , Taras Madan , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , Bharata B Rao , Jacob Pan , Ashok Raj , Linus Torvalds , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv13 02/16] x86: CPUID and CR3/CR4 flags for Linear Address Masking Date: Tue, 27 Dec 2022 06:08:15 +0300 Message-Id: <20221227030829.12508-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20221227030829.12508-1-kirill.shutemov@linux.intel.com> References: <20221227030829.12508-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 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 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 Enumerate Linear Address Masking and provide defines for CR3 and CR4 flags. Signed-off-by: Kirill A. Shutemov Reviewed-by: Alexander Potapenko Acked-by: Peter Zijlstra (Intel) Tested-by: Alexander Potapenko --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/processor-flags.h | 2 ++ arch/x86/include/uapi/asm/processor-flags.h | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 61012476d66e..bc662c80b99d 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -314,6 +314,7 @@ #define X86_FEATURE_CMPCCXADD (12*32+ 7) /* "" CMPccXADD instructions */ #define X86_FEATURE_AMX_FP16 (12*32+21) /* "" AMX fp16 Support */ #define X86_FEATURE_AVX_IFMA (12*32+23) /* "" Support for VPMADD52[H,L]UQ */ +#define X86_FEATURE_LAM (12*32+26) /* Linear Address Masking */ /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ diff --git a/arch/x86/include/asm/processor-flags.h b/arch/x86/include/asm/processor-flags.h index a7f3d9100adb..d8cccadc83a6 100644 --- a/arch/x86/include/asm/processor-flags.h +++ b/arch/x86/include/asm/processor-flags.h @@ -28,6 +28,8 @@ * On systems with SME, one bit (in a variable position!) is stolen to indicate * that the top-level paging structure is encrypted. * + * On systemms with LAM, bits 61 and 62 are used to indicate LAM mode. + * * All of the remaining bits indicate the physical address of the top-level * paging structure. * diff --git a/arch/x86/include/uapi/asm/processor-flags.h b/arch/x86/include/uapi/asm/processor-flags.h index c47cc7f2feeb..d898432947ff 100644 --- a/arch/x86/include/uapi/asm/processor-flags.h +++ b/arch/x86/include/uapi/asm/processor-flags.h @@ -82,6 +82,10 @@ #define X86_CR3_PCID_BITS 12 #define X86_CR3_PCID_MASK (_AC((1UL << X86_CR3_PCID_BITS) - 1, UL)) +#define X86_CR3_LAM_U57_BIT 61 /* Activate LAM for userspace, 62:57 bits masked */ +#define X86_CR3_LAM_U57 _BITULL(X86_CR3_LAM_U57_BIT) +#define X86_CR3_LAM_U48_BIT 62 /* Activate LAM for userspace, 62:48 bits masked */ +#define X86_CR3_LAM_U48 _BITULL(X86_CR3_LAM_U48_BIT) #define X86_CR3_PCID_NOFLUSH_BIT 63 /* Preserve old PCID */ #define X86_CR3_PCID_NOFLUSH _BITULL(X86_CR3_PCID_NOFLUSH_BIT) @@ -132,6 +136,8 @@ #define X86_CR4_PKE _BITUL(X86_CR4_PKE_BIT) #define X86_CR4_CET_BIT 23 /* enable Control-flow Enforcement Technology */ #define X86_CR4_CET _BITUL(X86_CR4_CET_BIT) +#define X86_CR4_LAM_SUP_BIT 28 /* LAM for supervisor pointers */ +#define X86_CR4_LAM_SUP _BITUL(X86_CR4_LAM_SUP_BIT) /* * x86-64 Task Priority Register, CR8 -- 2.38.2