Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5855336rwi; Tue, 18 Oct 2022 05:12:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HIeC7gLRIXfdJgZZW3h1HVb9M+YtyK4k1Zngd78dFXJOAmAcO3/5CvQxyHx4QFejOZ1rg X-Received: by 2002:a17:902:f791:b0:17c:c1dd:a3b5 with SMTP id q17-20020a170902f79100b0017cc1dda3b5mr2625335pln.141.1666095177214; Tue, 18 Oct 2022 05:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666095177; cv=none; d=google.com; s=arc-20160816; b=ZrJceMPuVz8WhxAyV5JpEEa8lX4nwJ3Jd4LqcqMnAvfynAjK7dB0OhFGwqWHmFrAUs G7DZbWX6yZsvnWXYVgrUYryi9ocGmpbxXiwbMS4Guv4qpMq2zwDBAXHA29hwT9snclxB TpYgJxg0O13DUA5Xc+52wdiAx8ypodnJVglwNZtNULhrf8sbC0376wHB8SCx5QsSJx/b vvHTPluq2qr5rRYAILysoEineaABM9Dvl6SKFOuwi3+Llen6fiRUdLI1T5wHqF39srMS P8FPdHF7hCvM2yu+EzZGutUwk/JlgHw+eXuhSFdFWctRwEjbByUOy3E7wV6xpRqmeexe SZ6w== 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=ua/d+KkLZv0PaTb7Hq4TesrbnvHM12E/lwcQfI1JPRY=; b=ucjFF9lOJFqEEQ+AYwpaejiEYs05sh/ZqCY4LS7Zd5GZbW214OgIFL9mBhbhxx1w54 wiXvzfKI1ANn9xn5eJz8XeQcpW+KxfhesfvZAwlC+s921cYnS640H1Wblu9S2UoyynAz ns5jMjh1pcdnNP2dOeeW6R8/Upx58fcpCsvWDLfNzyQ6vWnruua/cs5WwQ08PcZXn41E 1gw4u/+MgAzPEwm292Cmfp2PNIhYfas0uvdzFVPMvJyTxvnSdVdLTiyoEtlVKU+1lPpH jOf3oSPU/X+PQDOLf/oSjEOhWy0OCTtcLPE6ybzerFcQdOokBs/Yf4m2qc2YRmLyuL/s /bnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ftu7jpDF; 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 c5-20020a170902f30500b00183baaecf95si12790965ple.562.2022.10.18.05.12.43; Tue, 18 Oct 2022 05:12:57 -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=ftu7jpDF; 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 S230288AbiJRLhd (ORCPT + 99 others); Tue, 18 Oct 2022 07:37:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbiJRLha (ORCPT ); Tue, 18 Oct 2022 07:37:30 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2AAFBBE20 for ; Tue, 18 Oct 2022 04:37: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=1666093025; x=1697629025; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7qeZVouD+LQqNvYdTdPAJZv4Un9wdAzppe5kV3GbELE=; b=ftu7jpDFhwJyvT/jiqamwVXex080M6OCvEtzVJpe/MIGgWa9ugpgjvUz kTJSE8X10GafU3byJ65uNBCmiNtswaO4xAZ5dQ89gHrilideEChmbhzPb Shor+OlrwABuhwCm3v3S1QfY2s4M56fLXEyLj0Pu/LVcGkMe+ghXdbCfQ 6xsFyxRjDBjwwDbUX9PmPhQwEd285os0q41wk3ZJQ0OuPQlDiJtv5HGK6 SoN2bAW035CVp76jn8Fo6RclgTBF5vI6VwVhWZ5kT5l/rxIUdLwwCTD2W PlC/REdWUFIYdwO0anY/QVHpAdQ2cyXPPSpMrZbzovuhSo5mSbcGWBrFs w==; X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="332620547" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="332620547" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 04:34:11 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="661861121" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="661861121" Received: from vhavel-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.51.115]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 04:34:06 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 04B111046BF; Tue, 18 Oct 2022 14:34: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 , Bharata B Rao , Jacob Pan , Ashok Raj , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv10 02/15] x86: CPUID and CR3/CR4 flags for Linear Address Masking Date: Tue, 18 Oct 2022 14:33:45 +0300 Message-Id: <20221018113358.7833-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221018113358.7833-1-kirill.shutemov@linux.intel.com> References: <20221018113358.7833-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 b71f4f2ecdd5..265805e71806 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.38.0