Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp137293imw; Tue, 12 Jul 2022 16:15:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tBZ7H/0s7dh4uQ3Ro9iDmY2RDj080vu5XuLS+UASFqF+4k7oxdRMKUC4a9SjTSvJLoAZfK X-Received: by 2002:a17:907:3daa:b0:72b:7656:d4d2 with SMTP id he42-20020a1709073daa00b0072b7656d4d2mr528050ejc.166.1657667752584; Tue, 12 Jul 2022 16:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657667752; cv=none; d=google.com; s=arc-20160816; b=wQbBxvB0c1TWKDY3+/o3/xminZBYDZyAqPAeic0N1gKeIlMjTd9wc2vUCpXf+CFpKv VH+U6kq12MqmkoaNMIoulPmdeQKG0FzWoALWdtO64GGPc8g0mr/FuO9DaIdZzfbfkshH cNRIyzkNWcL2S74xsN4x/2GAOH/HS5j8U8BZzsyvdMCMkvlK55J+hr52sDf1oqM05asz NlzRxte5X84TRq8MI8CFW1xoThXbfsJgu3k78b7M/0CK39NYhFt+sma2fR7lWTNrDh+I W3+aJ7wfdexZbwJaZYV+BLwa8odF++bKGnu9vJGJ61PEBamV91jxmfooo583dn9PGbZk n1lw== 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=Gb4J9gA3RCwe+H4n/j6bpgWyiEmyKQ+gRfeiAOgxhhU=; b=DBNYW/KICi2VbVtyb8iJZvy3pUpuBEd/WR6Hqlxf8ETnP6jzk4PIbPEDHLWd1Y/9T2 Bqv8MJIFIWgS8pko/4ce7U/6WoRZmtzPOq9q+3IZMuH8t3eb+hXT6Df8aja1jofn2Yr+ AYKRNEt+LPofL2Jt1g/PQPlXmHYQxflU3KoO8c4G/1lY5vjurvenFpIEsxLYO5GylxbG guDBZ0jwigfF8RdtQqOjhan6GOwushie1NKULp/3IoWjGpFQDobeQEqHSp496cHA58yy EjPBLLxvBEtGUHWjQwt6/LSUxbK8fdKo9T4OLI+Z14+5qixD8QEZkivpSqFW5hY7FjET 7NGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RYshQ6WR; 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 l22-20020a1709060e1600b0072b30e2e4a1si14205383eji.538.2022.07.12.16.15.27; Tue, 12 Jul 2022 16:15:52 -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=RYshQ6WR; 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 S233877AbiGLXNb (ORCPT + 99 others); Tue, 12 Jul 2022 19:13:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230041AbiGLXN0 (ORCPT ); Tue, 12 Jul 2022 19:13:26 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4977B3D4A for ; Tue, 12 Jul 2022 16:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657667605; x=1689203605; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=95bhHx1Juu5Tt/MFhkDa/aMyBcRcrNVaIQO2CZMJjSk=; b=RYshQ6WRl0XMa9KkGWsr5nBpazaqWJYcpRZfco+v9Jn7nt3bbMoqCVuk dCGAeogfXSgpNcYD0BXJF+O5EVzmfc1CqoXv9hx4l5VuFIyJ7deBYXf1H XuGAUYurmZlny2QMh8Cdn9JITp8ccv9Dl9ouetTLimjDFOoMrwdsksNLk jJl2xgC3wnyPAQemguufF2FECwKU8s4z+eP9Cc0RcK8TRKaAhnPPGVeX2 Dx34JDZmgvOETUDHZgHyx6UE0cUCdMtKrxIhIl7XUEkrmGvYtFVf5bFJS TnVJdktDJn1Le6hzG8Orw5wrESlNGfO5HbB4CMBzU5fZRnmW36eX5NQoM Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10406"; a="264852925" X-IronPort-AV: E=Sophos;i="5.92,266,1650956400"; d="scan'208";a="264852925" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2022 16:13:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,266,1650956400"; d="scan'208";a="663128842" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 12 Jul 2022 16:13:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id BE81516D; Wed, 13 Jul 2022 02:13:29 +0300 (EEST) 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 , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv5 02/13] x86: CPUID and CR3/CR4 flags for Linear Address Masking Date: Wed, 13 Jul 2022 02:13:17 +0300 Message-Id: <20220712231328.5294-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220712231328.5294-1-kirill.shutemov@linux.intel.com> References: <20220712231328.5294-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, 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 Enumerate Linear Address Masking and provide defines for CR3 and CR4 flags. Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/uapi/asm/processor-flags.h | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 03acc823838a..6ad5841e087f 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -300,6 +300,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/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