On 12/30/2024 4:59 PM, Borislav Petkov wrote: > On Tue, Dec 03, 2024 at 02:30:41PM +0530, Nikunj A Dadhania wrote: >> Subject: Re: [PATCH v15 09/13] tsc: Use the GUEST_TSC_FREQ MSR for... > > The tip tree preferred format for patch subject prefixes is > 'subsys/component:', e.g. 'x86/apic:', 'x86/mm/fault:', 'sched/fair:', > 'genirq/core:'. Please do not use file names or complete file paths as > prefix. 'git log path/to/file' should give you a reasonable hint in most > cases. > > Audit your whole set pls. > Sure, will update >> +void __init snp_secure_tsc_init(void) >> +{ >> + x86_platform.calibrate_cpu = securetsc_get_tsc_khz; >> + x86_platform.calibrate_tsc = securetsc_get_tsc_khz; > > The fact that you assign the same function to two different function ptrs > already hints at some sort of improper functionality split. As kvm-clock would have set the callbacks, I need to point them to securetsc_get_tsc_khz(). arch/x86/kernel/kvmclock.c: x86_platform.calibrate_tsc = kvm_get_tsc_khz; arch/x86/kernel/kvmclock.c: x86_platform.calibrate_cpu = kvm_get_tsc_khz; For virtualized environments, I see that all of them are assigning the same functions to different function ptrs. arch/x86/kernel/cpu/mshyperv.c: x86_platform.calibrate_tsc = hv_get_tsc_khz; arch/x86/kernel/cpu/mshyperv.c: x86_platform.calibrate_cpu = hv_get_tsc_khz; arch/x86/kernel/cpu/vmware.c: x86_platform.calibrate_tsc = vmware_get_tsc_khz; arch/x86/kernel/cpu/vmware.c: x86_platform.calibrate_cpu = vmware_get_tsc_khz; arch/x86/kernel/jailhouse.c: x86_platform.calibrate_cpu = jailhouse_get_tsc; arch/x86/kernel/jailhouse.c: x86_platform.calibrate_tsc = jailhouse_get_tsc; > >> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c >> index 67aeaba4ba9c..c0eef924b84e 100644 >> --- a/arch/x86/kernel/tsc.c >> +++ b/arch/x86/kernel/tsc.c >> @@ -30,6 +30,7 @@ >> #include <asm/i8259.h> >> #include <asm/topology.h> >> #include <asm/uv/uv.h> >> +#include <asm/sev.h> >> >> unsigned int __read_mostly cpu_khz; /* TSC clocks / usec, not used here */ >> EXPORT_SYMBOL(cpu_khz); >> @@ -1515,6 +1516,10 @@ void __init tsc_early_init(void) >> /* Don't change UV TSC multi-chassis synchronization */ >> if (is_early_uv_system()) >> return; >> + >> + if (cc_platform_has(CC_ATTR_GUEST_SNP_SECURE_TSC)) >> + snp_secure_tsc_init(); > > diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c > index aac066d798ef..24e7c6cf3e29 100644 > --- a/arch/x86/coco/sev/core.c > +++ b/arch/x86/coco/sev/core.c > @@ -3287,6 +3287,9 @@ static unsigned long securetsc_get_tsc_khz(void) > > void __init snp_secure_tsc_init(void) > { > + if (!cc_platform_has(CC_ATTR_GUEST_SNP_SECURE_TSC)) > + return; > + > x86_platform.calibrate_cpu = securetsc_get_tsc_khz; > x86_platform.calibrate_tsc = securetsc_get_tsc_khz; > } > diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c > index c0eef924b84e..0864b314c26a 100644 > --- a/arch/x86/kernel/tsc.c > +++ b/arch/x86/kernel/tsc.c > @@ -1517,8 +1517,7 @@ void __init tsc_early_init(void) > if (is_early_uv_system()) > return; > > - if (cc_platform_has(CC_ATTR_GUEST_SNP_SECURE_TSC)) > - snp_secure_tsc_init(); > + snp_secure_tsc_init(); > > if (!determine_cpu_tsc_frequencies(true)) > return; > Sure will update. Regards, Nikunj