Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3788241rwb; Fri, 30 Sep 2022 08:19:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6NfTEfdUo7XOZD9srhmoU0DPDE9CIp3yTzADAzKCqb6VXZHfzW7tUDZcahKgCQfToa/5QR X-Received: by 2002:a17:907:25cd:b0:77b:9672:38e7 with SMTP id ae13-20020a17090725cd00b0077b967238e7mr7004135ejc.10.1664551154020; Fri, 30 Sep 2022 08:19:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664551154; cv=none; d=google.com; s=arc-20160816; b=Z7bHTgxG2gGaVUcW77KX/cP+1fLvHkx35AelbtAeM2uxDbdJhUEI1weFKse67FI2Yi crjejyqMSpHMaIdrmevb5naDyTAVDEchQVSfjBks2krR4PkPtTPB4kOF1HhxY8aUJWe8 +cysPFv81PqciJgi45Zdg9jMpvcjl/uUTiKxHHm8rR18XxBuWJQeUUsHIizAjYEMdXhx KcWULHClPTBhCv3ghcejuT7fLI2dHf4Hh0fb6CgJE1uR+tIdGgbMiabaQHK7B51Kgw6H /Q8qhwOBtFp7h6KfTlDZu0KGVHArkxIhgeR8LnktYB3exVGUTFfLIism8JRRFL6qOdWs UPXw== 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=PeqbkaNgpUsZaiiO8skv1lk5XMXT8HIrdI5C04nNfV0=; b=lg3c6aGaugztZz3A2E0wKoiMjh4qow5+dENH8lCLT64Nnti0sHj1OUdM9PAZnGF0/B dHTYmFyRG8eBxZlzKJRfHyTBz6e0bc9lYmivkpqz7jCHirKFZ0mHyiE5wMwVXMxEc36z JPb+Il5Y/zOgi3is068ePFsemHMkWrj7NYmr40ET1DIjDxq+04mwJwOJloarKe40n9Pm dsHA/NErx5M0El1q/9S2Yncowmr8+A8opq+Vo5bsYPnh3xNcOI6EbIAwjwWisHfzJckC Iz1lu8iOG1kDXmV0IZTLrBtwUYLDGbr4ImdeL5jt51NDhfFEiGfeb8hnUfmtGTH3izAH gV6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Cf1ZSDWo; 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 y18-20020a170906559200b0077d26491aa5si1720123ejp.315.2022.09.30.08.18.48; Fri, 30 Sep 2022 08:19:14 -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=Cf1ZSDWo; 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 S231562AbiI3OsR (ORCPT + 99 others); Fri, 30 Sep 2022 10:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231248AbiI3OsK (ORCPT ); Fri, 30 Sep 2022 10:48:10 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF06912B489 for ; Fri, 30 Sep 2022 07:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664549289; x=1696085289; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yXN+5JLX5zkyOdU6mDFL78amRIUnBbLZ8kI+mjwqWTM=; b=Cf1ZSDWoZ4Z2QdC5xqqoDR+nV2jFEnB/QuOqFccNs5RNjikiwY2sbqsB IZFunP5KWsO5O7g0pQ7mOsRsehJl8Z5XTIdh9MIOCqsnJCC+Ff/xZtSp+ auoGzmiPhrRHMtmftqDZ1vqktCw6ahduOQhcE1oZcUis6kkDi4LyEa3B1 hvCaMVkvjPq5LhqF6elIP+H2pGUeRhVhvJ9Y+tzwzwhubqFX1gw8F/7cs uLBUZ6OZVMEEusnrkEdp0HmdH4ll369eT9+K1yNIJRd4ysrDnfCuLOBhu joBOIoeRBooVBcd4dihHTFhS/SBGlKzp6OMRQIKfNBJJrphfpIFvtKQUh A==; X-IronPort-AV: E=McAfee;i="6500,9779,10486"; a="303116976" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="303116976" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2022 07:48:08 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10486"; a="691271765" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="691271765" Received: from herrerop-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.38.128]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2022 07:48:04 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 3E1F8104BDB; Fri, 30 Sep 2022 17:48:02 +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 , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv9 02/14] x86: CPUID and CR3/CR4 flags for Linear Address Masking Date: Fri, 30 Sep 2022 17:47:46 +0300 Message-Id: <20220930144758.30232-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220930144758.30232-1-kirill.shutemov@linux.intel.com> References: <20220930144758.30232-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 Tested-by: Alexander Potapenko Acked-by: Peter Zijlstra (Intel) --- 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 235dc85c91c3..73c0cf5bd8a1 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -308,6 +308,7 @@ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ #define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* AVX512 BFLOAT16 instructions */ +#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.35.1