Skip to content

Commit 3339914

Browse files
committed
Merge tag 'x86_platform_for_v6.1_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 platform update from Borislav Petkov: "A single x86/platform improvement when the kernel is running as an ACRN guest: - Get TSC and CPU frequency from CPUID leaf 0x40000010 when the kernel is running as a guest on the ACRN hypervisor" * tag 'x86_platform_for_v6.1_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/acrn: Set up timekeeping
2 parents bf76762 + 81a71f5 commit 3339914

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

arch/x86/include/asm/acrn.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
/* Bit 0 indicates whether guest VM is privileged */
1111
#define ACRN_FEATURE_PRIVILEGED_VM BIT(0)
1212

13+
/*
14+
* Timing Information.
15+
* This leaf returns the current TSC frequency in kHz.
16+
*
17+
* EAX: (Virtual) TSC frequency in kHz.
18+
* EBX, ECX, EDX: RESERVED (reserved fields are set to zero).
19+
*/
20+
#define ACRN_CPUID_TIMING_INFO 0x40000010
21+
1322
void acrn_setup_intr_handler(void (*handler)(void));
1423
void acrn_remove_intr_handler(void);
1524

@@ -21,6 +30,11 @@ static inline u32 acrn_cpuid_base(void)
2130
return 0;
2231
}
2332

33+
static inline unsigned long acrn_get_tsc_khz(void)
34+
{
35+
return cpuid_eax(ACRN_CPUID_TIMING_INFO);
36+
}
37+
2438
/*
2539
* Hypercalls for ACRN
2640
*

arch/x86/kernel/cpu/acrn.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ static void __init acrn_init_platform(void)
2828
{
2929
/* Setup the IDT for ACRN hypervisor callback */
3030
alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, asm_sysvec_acrn_hv_callback);
31+
32+
x86_platform.calibrate_tsc = acrn_get_tsc_khz;
33+
x86_platform.calibrate_cpu = acrn_get_tsc_khz;
3134
}
3235

3336
static bool acrn_x2apic_available(void)

0 commit comments

Comments
 (0)