Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7644197rwi; Mon, 24 Oct 2022 18:10:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4TkrGJhdQ17gZSh1wNw77GbWDqCnyBJseLRpTql2oRkLrFMejnLqvrGxXsfM2teJwTsOpa X-Received: by 2002:a17:907:1c98:b0:78d:3b06:dc8f with SMTP id nb24-20020a1709071c9800b0078d3b06dc8fmr29334337ejc.58.1666660258939; Mon, 24 Oct 2022 18:10:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666660258; cv=none; d=google.com; s=arc-20160816; b=Hpdu7xkaUZjSoayxbq3khxTVGj2ttQZCVfOQFLf40S4AgOC/o+qaNzgYwROZAVdc+T qTKU3uo7CRn8pLAoPcknzspurbn+Na26kl/nYHg3QcSukgLJfEJh0doSuIFJBrpY2v5v Yvl2h4q0qwpOF0B8jBHQhjwrcGWnaef2R3w0ODcreU5PMit/vj0y7pls9uoB/ACk4tcg WcX3DItBpAIt2/4EijTHYuoc1HhIDl1Du7Ef9FP/H+N4igf8QmbLFwXKpn8vjH9PVHnE UzNeimJ5szQ6VfkWPcxjhs8JUNaQMm/iUnTfuI6bWSH7raBPepyxLe/9xlyK1nxvaE7U cydQ== 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=ua/d+KkLZv0PaTb7Hq4TesrbnvHM12E/lwcQfI1JPRY=; b=l1gsTEgraDSdOy1WuRYt4K/7bZNu+E5q9zjhOlhmnrj75vlPydZ5RmcmaZKZO1IVw2 QVcWGUt0oCt6u8CXcWmJjY21bAN2stuFMgfa6XybujuLC4WUoidujsjd6mZy2o2RIIEc 6diXjzyXIwKkKyrmfVzEaPV/tAmGhoBT/By+7SjKJ6oXPWhMvxmbBHojGGF6BYsH6Ng3 /OX6rt8RB/yoC9CXZtX6ZkU5G/MhkTjJW6UlJ3sWDGsPienZTVsV52m6M66mCOYKYgST jW+BbsB+1xL9WmjkgAPlKcwsPWE/xplGvXBgclEt9MOAfvcnfyMxo2JcGzwvZddtcJRd /BsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cUYQkXQl; 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 i5-20020a05640242c500b00458ff6921e6si1703346edc.79.2022.10.24.18.10.33; Mon, 24 Oct 2022 18:10:58 -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=cUYQkXQl; 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 S230075AbiJYBIr (ORCPT + 99 others); Mon, 24 Oct 2022 21:08:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230468AbiJYBIP (ORCPT ); Mon, 24 Oct 2022 21:08:15 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AB96A3B77 for ; Mon, 24 Oct 2022 17:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666657053; x=1698193053; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7qeZVouD+LQqNvYdTdPAJZv4Un9wdAzppe5kV3GbELE=; b=cUYQkXQlzUoRBsczToTlyQ8RlaCGg9FpMCKyZkrQ2buxxZFNgo9ML4CU zXI9iU9ybD2PDAmM/aEAF8PjhfxdP9Z0ZHzzub/idLu3GqfmKiK5DxsGs 6vbTMi31Bp3dPZA7WbwGi8hXGnydTETHYmWKzEu+tqXIa3R2SDDCv514a BPlHF5eCELGHnbU3QTzKBnRFPzfVu4332dOZCwdYFuVUVVC5X21+NShYK 9kwoC5rhPcj4R8SmLB2TsrTKaVCwdae04TgUAH1nywTZ7m6Wezyc27tWB 8DIkXhnRG0gYaUah663aHqbQnr3fZhOysf0MXumuwpx+9RyxfJAdJDyMf A==; X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="309238819" X-IronPort-AV: E=Sophos;i="5.95,210,1661842800"; d="scan'208";a="309238819" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2022 17:17:32 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="582587460" X-IronPort-AV: E=Sophos;i="5.95,210,1661842800"; d="scan'208";a="582587460" Received: from ghoyler-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.249.39.118]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2022 17:17:28 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id B2A25106FF7; Tue, 25 Oct 2022 03:17:25 +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: [PATCHv11 02/16] x86: CPUID and CR3/CR4 flags for Linear Address Masking Date: Tue, 25 Oct 2022 03:17:08 +0300 Message-Id: <20221025001722.17466-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221025001722.17466-1-kirill.shutemov@linux.intel.com> References: <20221025001722.17466-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 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,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 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 b71f4f2ecdd5..265805e71806 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.38.0