From patchwork Tue Aug 30 01:00:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 12958584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D57EECAAD2 for ; Tue, 30 Aug 2022 01:01:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9BDC940009; Mon, 29 Aug 2022 21:01:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 999F694000A; Mon, 29 Aug 2022 21:01:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EC06940007; Mon, 29 Aug 2022 21:01:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5FE9D940008 for ; Mon, 29 Aug 2022 21:01:34 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 21612140B4C for ; Tue, 30 Aug 2022 01:01:34 +0000 (UTC) X-FDA: 79854456108.08.6812D86 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf02.hostedemail.com (Postfix) with ESMTP id 6703E8004C for ; Tue, 30 Aug 2022 01:01:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661821293; x=1693357293; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yXN+5JLX5zkyOdU6mDFL78amRIUnBbLZ8kI+mjwqWTM=; b=M1KeGQS2fQYIfoqBuJd1qxRYzuFn92xikLcxJOoIkBDZgTqYBfCdZHqt 1i42wYeHJBFyk7ZYH+VAV/FI6qUHI1w78HGy0Yr3fmu06Thaugs9aJCMa 6dGHLsOsCNjjZFOU7P2GSXt1rwnahS1UKFGDo0Qiz66x27Tl8FCY7G/bG JR0ZPNYUAdMV1dVb622QTz+vXfeGel+WgntvYD7SpRkqFWykUmIUH45yK /CsxOaAAl/Njz5s+Q/b2XgUELnHJ5VxwtXF0P/FJjsGjnn2gkYc+Hndm2 aqyc2D3uQ2Gw0lKQz9Ee6B7Am4TVW+SU+hHFS57nauhoUOlPnYLTfBgPH w==; X-IronPort-AV: E=McAfee;i="6500,9779,10454"; a="292622764" X-IronPort-AV: E=Sophos;i="5.93,273,1654585200"; d="scan'208";a="292622764" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2022 18:01:30 -0700 X-IronPort-AV: E=Sophos;i="5.93,273,1654585200"; d="scan'208";a="737549978" Received: from fpalamon-mobl.amr.corp.intel.com (HELO box.shutemov.name) ([10.252.54.23]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2022 18:01:26 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 6D7DC1040C3; Tue, 30 Aug 2022 04:01:24 +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: [PATCHv8 02/11] x86: CPUID and CR3/CR4 flags for Linear Address Masking Date: Tue, 30 Aug 2022 04:00:55 +0300 Message-Id: <20220830010104.1282-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220830010104.1282-1-kirill.shutemov@linux.intel.com> References: <20220830010104.1282-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661821293; a=rsa-sha256; cv=none; b=tD5DktqK5RAZRDvOxNp5XqJHxwgmyHNY1AmY3kFyUgmEpmQqDNyn0/dEf91agGHLQVXHDn 5tCpMnYLcx3K5AxcmVXRFaeof4Pe9B89ON2eaC87kS12/EY3DwBUvEFmkkWD3Qlm2FU4Xs ia8iq/4JYjoXpvkVSmXUwpyEcTeZDXw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=M1KeGQS2; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none); spf=none (imf02.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.93) smtp.mailfrom=kirill.shutemov@linux.intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661821293; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PeqbkaNgpUsZaiiO8skv1lk5XMXT8HIrdI5C04nNfV0=; b=LnOlMDpBhCICD2FRB4cRDTjPGvIAimIPc7YL/brtbkCYrvnbzuvo/JHrYGZK9fztjNr94a gxs/J4DGpBK06YAG5+/3xJIJCZEDCGmjjruorqy3hqCd0D8MgP37LSHXB38r2Ny9g+cAE1 HY2Qw85e5bvD3IgSBmEj+0sCwxjJ4nE= X-Rspam-User: X-Rspamd-Queue-Id: 6703E8004C X-Rspamd-Server: rspam03 X-Stat-Signature: auztqq6hbk6xzkcgcykknac7b1gtufpo Authentication-Results: imf02.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=M1KeGQS2; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none); spf=none (imf02.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.93) smtp.mailfrom=kirill.shutemov@linux.intel.com X-HE-Tag: 1661821293-766634 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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