From: "Xin Li (Intel)" <xin@zytor.com>
To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
will@kernel.org, peterz@infradead.org, yury.norov@gmail.com,
akpm@linux-foundation.org, acme@kernel.org, namhyung@kernel.org,
brgerst@gmail.com, andrew.cooper3@citrix.com,
nik.borisov@suse.com
Subject: [PATCH v5 5/5] x86/cpufeatures: Add the CPU feature bit for MSR immediate form instructions
Date: Sun, 5 Jan 2025 23:07:27 -0800 [thread overview]
Message-ID: <20250106070727.3211006-6-xin@zytor.com> (raw)
In-Reply-To: <20250106070727.3211006-1-xin@zytor.com>
The immediate form of MSR access instructions are primarily motivated by
performance, not code size: by having the MSR number in an immediate, it
is available *much* earlier in the pipeline, which allows the hardware
much more leeway about how a particular MSR is handled.
Add a new CPU feature word for CPUID.7.1.ECX and then the CPU feature bit
for MSR immediate form.
Signed-off-by: Xin Li (Intel) <xin@zytor.com>
---
arch/x86/include/asm/cpufeature.h | 1 +
arch/x86/include/asm/cpufeatures.h | 5 ++++-
arch/x86/kernel/cpu/common.c | 1 +
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index b829a12eda8a..9a2991e7b21b 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -35,6 +35,7 @@ enum cpuid_leafs
CPUID_8000_001F_EAX,
CPUID_8000_0021_EAX,
CPUID_LNX_5,
+ CPUID_7_1_ECX,
NR_CPUID_WORDS,
};
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index d5985e8eef29..59aa04915032 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -5,7 +5,7 @@
/*
* Defines x86 CPU feature bits
*/
-#define NCAPINTS 22 /* N 32-bit words worth of info */
+#define NCAPINTS 23 /* N 32-bit words worth of info */
#define NBUGINTS 2 /* N 32-bit bug flags */
/*
@@ -476,6 +476,9 @@
#define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6) /* Heterogeneous Core Topology */
#define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32 + 7) /* Workload Classification */
+/* Intel-defined CPU features, CPUID level 0x00000007:1 (ECX), word 22 */
+#define X86_FEATURE_MSR_IMM (22*32+ 5) /* "msr_imm" MSR immediate form instructions */
+
/*
* BUG word(s)
*/
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 7cce91b19fb2..13d270eabd09 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -997,6 +997,7 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
if (eax >= 1) {
cpuid_count(0x00000007, 1, &eax, &ebx, &ecx, &edx);
c->x86_capability[CPUID_7_1_EAX] = eax;
+ c->x86_capability[CPUID_7_1_ECX] = ecx;
}
}
--
2.47.1
next prev parent reply other threads:[~2025-01-06 7:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-06 7:07 [PATCH v5 0/5] x86/cpufeatures: Automatically generate required and disabled feature masks Xin Li (Intel)
2025-01-06 7:07 ` [PATCH v5 1/5] x86/cpufeatures: Add {required,disabled} feature configs Xin Li (Intel)
2025-02-14 21:58 ` Borislav Petkov
2025-02-15 10:12 ` H. Peter Anvin
2025-02-15 14:20 ` Borislav Petkov
2025-02-15 14:27 ` H. Peter Anvin
2025-02-15 14:30 ` Borislav Petkov
2025-02-15 14:35 ` H. Peter Anvin
2025-02-15 14:44 ` Borislav Petkov
2025-01-06 7:07 ` [PATCH v5 2/5] x86/cpufeatures: Generate a feature mask header based on build config Xin Li (Intel)
2025-01-06 7:07 ` [PATCH v5 3/5] x86/cpufeatures: Remove {disabled,required}-features.h Xin Li (Intel)
2025-01-06 7:07 ` [PATCH v5 4/5] x86/cpufeatures: Use AWK to generate {REQUIRED|DISABLED}_MASK_BIT_SET Xin Li (Intel)
2025-01-06 7:07 ` Xin Li (Intel) [this message]
2025-02-22 16:30 ` [PATCH v5 5/5] x86/cpufeatures: Add the CPU feature bit for MSR immediate form instructions Borislav Petkov
2025-02-22 18:12 ` Borislav Petkov
2025-02-24 7:30 ` Xin Li
2025-02-24 17:27 ` H. Peter Anvin
2025-02-11 2:25 ` [PATCH v5 0/5] x86/cpufeatures: Automatically generate required and disabled feature masks Xin Li
2025-02-23 10:27 ` Borislav Petkov
2025-02-25 17:10 ` Xin Li
2025-02-25 17:49 ` Borislav Petkov
2025-02-25 17:54 ` Nikolay Borisov
2025-02-25 18:00 ` Borislav Petkov
2025-02-25 18:10 ` H. Peter Anvin
2025-02-25 18:15 ` Borislav Petkov
2025-02-25 18:37 ` Xin Li
2025-02-25 20:30 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250106070727.3211006-6-xin@zytor.com \
--to=xin@zytor.com \
--cc=acme@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andrew.cooper3@citrix.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=nik.borisov@suse.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox