Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2103871rwb; Sun, 14 Aug 2022 21:33:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR6RKHoSOq44jxfs0fzIBnw2qmDVGiVb9H1422jIXWkjQcvR+x3Ijlw6PcTDbsYYv8KG8YT3 X-Received: by 2002:a05:6402:5ca:b0:43b:6e01:482c with SMTP id n10-20020a05640205ca00b0043b6e01482cmr13262832edx.189.1660538000792; Sun, 14 Aug 2022 21:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660538000; cv=none; d=google.com; s=arc-20160816; b=Zi7RxO1mMYrMHV17wmsV9IpnWqYTybjS76r4nvuhV3QAQi6m/qFT7Aoq+MSADpD5Zd vfDipCVdJWcg0l1wo/g3rb1nvb0+bF0MkSAqQEN1JuKQG6HYrx+lH7j15bf6Z/GvspuO kSZlp3DrLHicgbxZjdcv1C8idafkIcp2kLuLrrYZHX/iw0lvHwGGuHsTRdGqEu597v8c rNkDBfa5wRtuFGgJ5a2/oD0lsh78zurqkOB2mL7S8CtPzWx76fLPeEXusfpQwM/o46A7 a6dwBFOWdE6mkHInaVTn5tE2DN6YcHLj/Doo8U9zAnL3L81mdsY5aVsaBIdgwQV+Wl7r GaOw== 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=trQrxyG+49Eh8NhRqc0hUMYod4kG3ZLjO6ndXzyW3Ik=; b=HhooZC70y/UXKgKs52BgZrnQoNiWLYvuzipubXvgC2JCI03+r6pWzNjaxCGi0apbbU QHWbInoGtdxATbqS5JkPFO/HR8ovYHGoYu7W92Fdh1HVnY3TwbqyDcDqYxXBhKFI07ni JHxNaZxEy1YcsKbwAW2a4Hf0w3pjPu5sVGQwzVO27hJ2VYR4mk2I8pO/DkoXP7W33+w1 nYrzWe1WCTLiWKDQkVJ5CP5fEfwBATftf9lCwAjOsi2bkoqgtNn+pPa829VHfT/a946a VPbidfOgpIUildfeTqWRry3V1y2ObSbko8sziuKOfjbIi1oWJS3TYLBrx+3Ly8nA2A/T 8iVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="NbM/OlfK"; 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 du20-20020a17090772d400b0072af6e1fff0si7746187ejc.330.2022.08.14.21.32.55; Sun, 14 Aug 2022 21:33:20 -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="NbM/OlfK"; 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 S240385AbiHOEPJ (ORCPT + 99 others); Mon, 15 Aug 2022 00:15:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232332AbiHOEPG (ORCPT ); Mon, 15 Aug 2022 00:15:06 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AEA01401B for ; Sun, 14 Aug 2022 21:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660536905; x=1692072905; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+Rvd/xrgf0B0RTbzc+Lnz5LTd3QpoAfiklT1FBTqlT4=; b=NbM/OlfKOabkmUR3228TVR3y+/OFryVXBVfXs9M74xP8V6YfEGhCakf5 77CehFhJel2VDcDoWXBycCI1akVdafE9wZNkEqKZ8mPhhFyCpaCnmGRyu 1WEx85nc2xDbQBFReJoQld1rWua99awY96yoZW6quX5TSkA1A8j6ulSt9 grvqwLidls0KqUWSzhhC+yEEWZTELbTxB5MpikyUbRhZ8cITTcQC9H9Sn /LP4aHjdHP9aZ0nAgzt6zMir7pFhDSDuB9tf0SNOwvL/qNW5m3tR1d4s/ PBhlqZvxVtMWGLWxmHHHbW5Mhp2mZhzb+lkMR7kd+gLOmYac1i8R+yoVA g==; X-IronPort-AV: E=McAfee;i="6400,9594,10439"; a="290639847" X-IronPort-AV: E=Sophos;i="5.93,237,1654585200"; d="scan'208";a="290639847" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2022 21:15:05 -0700 X-IronPort-AV: E=Sophos;i="5.93,237,1654585200"; d="scan'208";a="606530103" Received: from dmalka-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.249.42.26]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2022 21:15:01 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 413D1104A65; Mon, 15 Aug 2022 07:18:04 +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 , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv6 02/11] x86: CPUID and CR3/CR4 flags for Linear Address Masking Date: Mon, 15 Aug 2022 07:17:54 +0300 Message-Id: <20220815041803.17954-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220815041803.17954-1-kirill.shutemov@linux.intel.com> References: <20220815041803.17954-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,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 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 --- 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