From patchwork Tue Jul 12 23:13:17 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: 12915796 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 07518CCA481 for ; Tue, 12 Jul 2022 23:13:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E5D29400DC; Tue, 12 Jul 2022 19:13:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 19370940063; Tue, 12 Jul 2022 19:13:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 012EC9400DD; Tue, 12 Jul 2022 19:13:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CA343940063 for ; Tue, 12 Jul 2022 19:13:28 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A531A34309 for ; Tue, 12 Jul 2022 23:13:28 +0000 (UTC) X-FDA: 79680001296.10.381D578 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf18.hostedemail.com (Postfix) with ESMTP id 5C9231C0097 for ; Tue, 12 Jul 2022 23:13:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657667607; x=1689203607; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=95bhHx1Juu5Tt/MFhkDa/aMyBcRcrNVaIQO2CZMJjSk=; b=iXCgBpHOxd7J0q11SmI41evHWVbpkdGQ49NG/VIMtBnLXrp/2Q0msJm+ VkHgtuPQcOkLpl+BJEK0gh7bxW1FhFpusYHI1oTKrNMqJnABflNEVze2f qaU3bdUNRaoSaJVfZ8jxQc5+LR5YLYC2F9PGaWQWkrjE1GL3vePf0vCs+ t/zdR4fVzjAckkaaDOTAlQ6mzCtHVxNsqXbpOxNg+yjEDVwn2cAFjTg4k v7WRXJaeHPYWccT+dB2A0ULinmATeuk2q/iUl0kSy6Qz+7ch4GczJojDj KC0e0pJNgtgn8jCU5rBbEI+tX2CnUsrMR+De8puTZh0oI3OLHd3l8aWg9 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10406"; a="282616872" X-IronPort-AV: E=Sophos;i="5.92,266,1650956400"; d="scan'208";a="282616872" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657667608; a=rsa-sha256; cv=none; b=Oox/QZdjMWlBdT7JRXQ7dUKu0dwj1nVJ2H2kp5Wef+7zxdfWu00gAvUJmIoEh25Se5seks cGirKOH6I9y1znMO//cpTip2ZyRa0QHQLJrAQwGz6EpzFoR13w9vHosXWGn0Pi+VJgZCDW q0yuSNdSXfMcvyWSOxilEWkOiONeze0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=iXCgBpHO; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf18.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=1657667608; 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=JUlO7LcsZmJ/r8GnGlr2JDB/sBv+HYE9VhCsnrYYYfGN5NfTArM61fJzFun28k6kHb/517 eLVc12vPRvSm9WgIqidezdLRnP6SzOAkpt5roodHs1Z1ibfhjs/PM6D32zXIkIqMwmNAzq 1aL1s72id3ycBBcYMGziQQ2ZM9XIznQ= X-Rspam-User: X-Stat-Signature: 1z7ct61z48cjuxs8pe6gnq4z56etirx7 X-Rspamd-Queue-Id: 5C9231C0097 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=iXCgBpHO; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf18.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-Rspamd-Server: rspam03 X-HE-Tag: 1657667607-31436 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 --- 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