From patchwork Fri Nov 11 21:58:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 19017 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp988774wru; Fri, 11 Nov 2022 14:06:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf6oRtKBM0YDMCs0JJ3xV4weUd/9OkhmH5Y12J4V9Oo9I8UxxtqGLdosTK7T1UiZ9ec6z5DF X-Received: by 2002:a17:902:eb49:b0:179:e1f6:d24d with SMTP id i9-20020a170902eb4900b00179e1f6d24dmr4365338pli.91.1668204416527; Fri, 11 Nov 2022 14:06:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668204416; cv=none; d=google.com; s=arc-20160816; b=VUdikWKlF4PtgqFWz5H07LidZy7r1kfrfhl0mGCgLCDCJD3L6VkO7cyC1YeIKeWWWk YTf+8GcgoVFnkRRqebYQ8WsgVy4nzmlhi1yuwUCtKiYzu3vqqOaWkOrO54D+UNt1Ub1X y4KS7tYMTo6wYjkyxw7eGBA+946yzOy+aOWY6OHefpbE7SJFKn8xiqpgRLcDCtx7aNtI jQOqVovNgCLG8yJn0pO9n5ZxRKCxPD5umJWU9xINOnCnKBy7eCL3hWUPl5MFt0NpocvR NmujpZ8oo1wNLhvwkHEh2utB0tt6kQqCqHhpD93i3BR+/crs4uNC51w1WI6/r+k76o+L y3XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=pDeeVsMEi2ryM4iGk+ZXEHaTUbFi9DYpaP1tHe5U8Z0=; b=fRWYbqZx2XF6SQXWg9ml7qHULZzB9YCwi7rwStYgSIuami3HBayJTaSfdmRK9Q0he5 tlUkPxYeRsrt5j3ksrN3aAmS8USXb5pOLCzSYw90UaO6TwSQqHe1nLws9ytJRQr4ntTw RYSo3PzuLKFRF/KnF+uPhr9IDb6XhqOZuxRAfRAuCVBThe0UYaCUSAeqqJ1+fn48/cRR /D2QzqHNGK7IoD8fdsY3CF02Cbls3tjTed3DrJh7M2BsLQKJ+1AN5FPuJvSOw04lu6FQ dxgOoeJY9N6CSbFiovPfpXDDizvXZ2H5pSO8eCQTZTdC+Un8aZVoSH2T5whYmdcU5OJg QEtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AK1XW33m; dkim=neutral (no key) header.i=@linutronix.de header.b=rUJfJ24+; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c189-20020a6335c6000000b004704bae726asi3601045pga.47.2022.11.11.14.06.41; Fri, 11 Nov 2022 14:06:56 -0800 (PST) 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=@linutronix.de header.s=2020 header.b=AK1XW33m; dkim=neutral (no key) header.i=@linutronix.de header.b=rUJfJ24+; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234479AbiKKV7Z (ORCPT + 99 others); Fri, 11 Nov 2022 16:59:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234305AbiKKV6z (ORCPT ); Fri, 11 Nov 2022 16:58:55 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A989FDE9E; Fri, 11 Nov 2022 13:58:36 -0800 (PST) Date: Fri, 11 Nov 2022 21:58:34 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668203915; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pDeeVsMEi2ryM4iGk+ZXEHaTUbFi9DYpaP1tHe5U8Z0=; b=AK1XW33mCEWFc+AZm3azT5idFEkikX1rvVjRcbG1ihpNi048D48U1YQ78vWxGuWXbE8P27 BhcGcS0Myh6DgVIraSvISh1qKBcYX3JrpJtUdrh+FWm60kOlDUdD55TyLG06CN/6Pr2f5i ZpN6cTM/e+4ujsdp7weQ4j+vy/uhDOHEb3hzVoBUN8rHzPkxJ29S9iMQJ5u4qc9xaw1Ank KTU09xcyJYlYmq8/KM72+j0mCdkFdtBrv5OrfN4NJ/hl9XBk1YEUWhYJeslqxVYWX7XswY NXIyPhqRQ9GRkr/6rUobHp7E7vpYnOhDu6qZT/pSs+iresd1WnE2F9ZTRit7Lw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668203915; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pDeeVsMEi2ryM4iGk+ZXEHaTUbFi9DYpaP1tHe5U8Z0=; b=rUJfJ24+R7INuNxJ4vvAtMOBbJ6a+Utk5h3/iqSGN1+KuLfIzx/7jxey/WHW3ypIjR0uvA PFrwfgEyn7cPyBAw== From: "tip-bot2 for Kirill A. Shutemov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] x86: CPUID and CR3/CR4 flags for Linear Address Masking Cc: "Kirill A. Shutemov" , Dave Hansen , Alexander Potapenko , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <166820391410.4906.16419547072918874228.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749239113717840885?= X-GMAIL-MSGID: =?utf-8?q?1749239113717840885?= The following commit has been merged into the x86/mm branch of tip: Commit-ID: aa387b1b1e666cacffc0b7ac7e0949a68013b2d9 Gitweb: https://git.kernel.org/tip/aa387b1b1e666cacffc0b7ac7e0949a68013b2d9 Author: Kirill A. Shutemov AuthorDate: Wed, 09 Nov 2022 19:51:26 +03:00 Committer: Dave Hansen CommitterDate: Fri, 11 Nov 2022 13:28:06 -08:00 x86: CPUID and CR3/CR4 flags for Linear Address Masking Enumerate Linear Address Masking and provide defines for CR3 and CR4 flags. Signed-off-by: Kirill A. Shutemov Signed-off-by: Dave Hansen Reviewed-by: Alexander Potapenko Acked-by: Peter Zijlstra (Intel) Tested-by: Alexander Potapenko Link: https://lore.kernel.org/all/20221109165140.9137-3-kirill.shutemov%40linux.intel.com --- 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 b71f4f2..265805e 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 a7f3d91..d8cccad 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 c47cc7f..d898432 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