Skip to content

Commit 511af16

Browse files
committed
x86/cpu/intel: Define helper to get CPU core native ID
JIRA: https://issues.redhat.com/browse/RHEL-20094 upstream ======== commit 2eb2802 Author: Dapeng Mi <dapeng1.mi@linux.intel.com> Date: Tue Aug 20 07:38:51 2024 +0000 description =========== Define helper get_this_hybrid_cpu_native_id() to return the CPU core native ID. This core native ID combining with core type can be used to figure out the CPU core uarch uniquely. Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Tested-by: Yongwei Ma <yongwei.ma@intel.com> Link: https://lkml.kernel.org/r/20240820073853.1974746-3-dapeng1.mi@linux.intel.com Signed-off-by: Michael Petlan <mpetlan@redhat.com>
1 parent 457b61e commit 511af16

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

arch/x86/include/asm/cpu.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ extern bool handle_user_split_lock(struct pt_regs *regs, long error_code);
3636
extern bool handle_guest_split_lock(unsigned long ip);
3737
extern void handle_bus_lock(struct pt_regs *regs);
3838
u8 get_this_hybrid_cpu_type(void);
39+
u32 get_this_hybrid_cpu_native_id(void);
3940
#else
4041
static inline void __init sld_setup(struct cpuinfo_x86 *c) {}
4142
static inline bool handle_user_split_lock(struct pt_regs *regs, long error_code)
@@ -54,6 +55,11 @@ static inline u8 get_this_hybrid_cpu_type(void)
5455
{
5556
return 0;
5657
}
58+
59+
static inline u32 get_this_hybrid_cpu_native_id(void)
60+
{
61+
return 0;
62+
}
5763
#endif
5864
#ifdef CONFIG_IA32_FEAT_CTL
5965
void init_ia32_feat_ctl(struct cpuinfo_x86 *c);

arch/x86/kernel/cpu/intel.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,3 +1348,18 @@ u8 get_this_hybrid_cpu_type(void)
13481348

13491349
return cpuid_eax(0x0000001a) >> X86_HYBRID_CPU_TYPE_ID_SHIFT;
13501350
}
1351+
1352+
/**
1353+
* get_this_hybrid_cpu_native_id() - Get the native id of this hybrid CPU
1354+
*
1355+
* Returns the uarch native ID [23:0] of a CPU in a hybrid processor.
1356+
* If the processor is not hybrid, returns 0.
1357+
*/
1358+
u32 get_this_hybrid_cpu_native_id(void)
1359+
{
1360+
if (!cpu_feature_enabled(X86_FEATURE_HYBRID_CPU))
1361+
return 0;
1362+
1363+
return cpuid_eax(0x0000001a) &
1364+
(BIT_ULL(X86_HYBRID_CPU_TYPE_ID_SHIFT) - 1);
1365+
}

0 commit comments

Comments
 (0)