From patchwork Wed Jun 22 16:22:24 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: 12891145 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 10C8EC43334 for ; Wed, 22 Jun 2022 16:24:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99B1F8E00CD; Wed, 22 Jun 2022 12:24:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94CAC8E00C9; Wed, 22 Jun 2022 12:24:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8139A8E00CD; Wed, 22 Jun 2022 12:24:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 724158E00C9 for ; Wed, 22 Jun 2022 12:24:29 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4951C20348 for ; Wed, 22 Jun 2022 16:24:29 +0000 (UTC) X-FDA: 79606394658.04.86993DF Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf01.hostedemail.com (Postfix) with ESMTP id 701734002F for ; Wed, 22 Jun 2022 16:24:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655915064; x=1687451064; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=95bhHx1Juu5Tt/MFhkDa/aMyBcRcrNVaIQO2CZMJjSk=; b=BCwA/6sZxacit4sgoHxTOWQkFNkrObfWtOKgHNABaQdc9c9ZplWcIKlB wveFYF6qewACRbsPXm9IBs2omxGiWKD3cuHHBqHXfQhCvOfHsLvcjfXZK bHk3wbsmboToh2/QgosM1yQKk7C9qZJ2KFBitMhDAK+/QdyoRaqt4UssC 64V7BTT9yIT5KgwdxtejeMQSOzhir+faYPv5Tep+jlT7smDWiiHUIVmlD Ke0AeSF+7rOHqj2yYhKIDz8mYEK5sfmuMCuX0m/6/10yVjDPOaWw4dyDx uXpTpgrwGwvnJO6l91opwggZPfU5onLF5mIZpWe2PKkImQCGFzey7cU34 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10386"; a="260286531" X-IronPort-AV: E=Sophos;i="5.92,212,1650956400"; d="scan'208";a="260286531" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2022 09:22:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,212,1650956400"; d="scan'208";a="690579459" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 22 Jun 2022 09:22:38 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 301CC199; Wed, 22 Jun 2022 19:22:43 +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 , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv4 2/8] x86: CPUID and CR3/CR4 flags for Linear Address Masking Date: Wed, 22 Jun 2022 19:22:24 +0300 Message-Id: <20220622162230.83474-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220622162230.83474-1-kirill.shutemov@linux.intel.com> References: <20220622162230.83474-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655915065; a=rsa-sha256; cv=none; b=kahQEoEgok0otAb1XrVkWf7WNkuXFCdeO9SQEGCO1r9qOt8hIvcF/QE+Ly2lcY2lS1CXbQ REv56ZUdT7RKx3gbFcdaLrLy1JHU0bz5pBTsBuOYlPKvOYO/jT1Rrba4nJa7HcdlabrNZX qe6LEPNByFzMCwbql96mHtypV0pZbxg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="BCwA/6sZ"; spf=none (imf01.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.136) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655915065; 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=Gb4J9gA3RCwe+H4n/j6bpgWyiEmyKQ+gRfeiAOgxhhU=; b=LX4PZ91HDDPYQlwIVkqCl1JlTIfyPNyWu5m0cFpMxxw0HEBVRd+5nD35Sr7VIDaVn7Dh7R k8NMoOR0j4qL0itk8KyDQTbK/FspO6Yo2e7zj7DXsY0H0mDDWFG8PYctLBcC4z20ZqxJoA 9X1nIp7Jy21jfr0kgjIAGfu79GRf1lg= X-Rspamd-Queue-Id: 701734002F X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="BCwA/6sZ"; spf=none (imf01.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.136) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam08 X-Stat-Signature: oxx9gci6chpops66uwoewrhq18i4xmzk X-HE-Tag: 1655915064-374617 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 --- 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