Skip to content

Commit 2eb2802

Browse files
Dapeng MiPeter Zijlstra
authored andcommitted
x86/cpu/intel: Define helper to get CPU core native ID
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Kan Liang <[email protected]> Tested-by: Yongwei Ma <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 79390db commit 2eb2802

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
@@ -32,6 +32,7 @@ extern bool handle_user_split_lock(struct pt_regs *regs, long error_code);
3232
extern bool handle_guest_split_lock(unsigned long ip);
3333
extern void handle_bus_lock(struct pt_regs *regs);
3434
u8 get_this_hybrid_cpu_type(void);
35+
u32 get_this_hybrid_cpu_native_id(void);
3536
#else
3637
static inline void __init sld_setup(struct cpuinfo_x86 *c) {}
3738
static inline bool handle_user_split_lock(struct pt_regs *regs, long error_code)
@@ -50,6 +51,11 @@ static inline u8 get_this_hybrid_cpu_type(void)
5051
{
5152
return 0;
5253
}
54+
55+
static inline u32 get_this_hybrid_cpu_native_id(void)
56+
{
57+
return 0;
58+
}
5359
#endif
5460
#ifdef CONFIG_IA32_FEAT_CTL
5561
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
@@ -1299,3 +1299,18 @@ u8 get_this_hybrid_cpu_type(void)
12991299

13001300
return cpuid_eax(0x0000001a) >> X86_HYBRID_CPU_TYPE_ID_SHIFT;
13011301
}
1302+
1303+
/**
1304+
* get_this_hybrid_cpu_native_id() - Get the native id of this hybrid CPU
1305+
*
1306+
* Returns the uarch native ID [23:0] of a CPU in a hybrid processor.
1307+
* If the processor is not hybrid, returns 0.
1308+
*/
1309+
u32 get_this_hybrid_cpu_native_id(void)
1310+
{
1311+
if (!cpu_feature_enabled(X86_FEATURE_HYBRID_CPU))
1312+
return 0;
1313+
1314+
return cpuid_eax(0x0000001a) &
1315+
(BIT_ULL(X86_HYBRID_CPU_TYPE_ID_SHIFT) - 1);
1316+
}

0 commit comments

Comments
 (0)