Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3717842rwe; Mon, 29 Aug 2022 18:45:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR4UAAWsJds0pUzEwCMwnEmz/O0wxI5ZfYQs/VQ8YL7azLwhC/A83tRZvDdCjhRSoSJqc85A X-Received: by 2002:aa7:dbc5:0:b0:440:b0d6:7586 with SMTP id v5-20020aa7dbc5000000b00440b0d67586mr17899312edt.85.1661823929120; Mon, 29 Aug 2022 18:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661823929; cv=none; d=google.com; s=arc-20160816; b=AvTQHqF3QjLnYofPzzTLhJB/+fCHCnXuBCo3YdPPBX2Y723R1A7Vzh3wpg6zsyg4Qk IKU4GZ24+DOMGs1te1vSg31Qp8sqcp8TaNpFqIlBlrhw724lK7DmeS6ERqQIqok9tAet vK90qkJm/Zcc4Avf3K01PjPESQqXo74js7ykAtVZ+7RSvNFCiQAo/F8/Kl/rX4cRZ5MD F4ROpmkQEbe95ekRF1lJM9idq47rlN4+FK5a80796iKZVz8sxTvDPg/y0n9lON/uROtz r0TAmeFy1BTDzbT36qlmA17fBmAU1oFe5DZHA1JuxBd1lygaw2Uui67l6wvZHllF5GHS 7hAQ== 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=PeqbkaNgpUsZaiiO8skv1lk5XMXT8HIrdI5C04nNfV0=; b=wNzqN3pFHPUfrqyhrTmpCEQJdpfyNHQSXJkSDJts8J/ZvO6Jne0cjt/4ADP+A/Uev6 0xzpbw4Sn9oRx8fHSwXxz1V+yZEKxyxq1iSgQfzKsHHIjKdyowwOfFY0/WGm2sXAJj47 /2XnsnKfJjI3zWxlgYJhTfpM1uuqm4scTtNuDKsnXaAiYMoeb5uYuDvmFPM4/g04qauj IhHj1HJWruluD3CvOkrwSWaR8ZjlLLExEmAKg38nP8Ya+O9OxY+ghyQqkhzgdaJcjAeD UXFcvAj8xGoBPjskaU3+Ef30NK5AoFoLW5NzSkA4k3+VpJcNxpOHaSoTCKSiUjhyzPQt RX0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AGqyrkVK; 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 m12-20020a170906258c00b0073d1748a820si7137638ejb.199.2022.08.29.18.45.03; Mon, 29 Aug 2022 18:45:29 -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=AGqyrkVK; 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 S229636AbiH3BBi (ORCPT + 99 others); Mon, 29 Aug 2022 21:01:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbiH3BBf (ORCPT ); Mon, 29 Aug 2022 21:01:35 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 028EE9F771 for ; Mon, 29 Aug 2022 18:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661821291; x=1693357291; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yXN+5JLX5zkyOdU6mDFL78amRIUnBbLZ8kI+mjwqWTM=; b=AGqyrkVKk30g//FqPtrIq57tciW52dTp0e801pXjlD6cRQYBajzYO+DL yuRRARJT4ipIkC0ikn2YLWUtN3vDsGu7i09uZyzeoc7DeZFa3IU8fm8DM EX0Y8Hpju0W29qwPWOM4dek+dyhpsb/cI1T3abhEYQi/1LsIR9PO+9k+Y GMGYgKxbozOMQpF7kPMz3m4WBa5QEzgUlAZnpA/J3rjjS8hLfg/X0zW97 TlsHtfnZNqOvDPG2dgMgHR//bXKc7ujJuyTUVbm0KZmO7AdcEh0wN7+LH nWEm9qx7/8b2X5CZeMHDthqIHq2D6WRjs48K8idY3zBjihPG8wp1ZtDRJ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10454"; a="295826097" X-IronPort-AV: E=Sophos;i="5.93,273,1654585200"; d="scan'208";a="295826097" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 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 -- 2.35.1