Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] The new helper function `tsc_register_calibration_routines` is missing 
the `__init` attribute.
--

commit ac711dd28fcd18f28a56325512fc567fdd7d6098
Author: Sean Christopherson <[email protected]>

x86/tsc: Add helper to register CPU and TSC freq calibration routines

Add a helper to register non-native CPU and TSC frequency calibration routines.
This consolidates handling of common TSC properties forced by hypervisors
and guards against overriding a TSC calibration routine with a less trusted one.

> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> index f92236f40cbcc..7e639c0a94a21 100644
> --- a/arch/x86/kernel/tsc.c
> +++ b/arch/x86/kernel/tsc.c
> @@ -1281,6 +1281,23 @@ static void __init check_system_tsc_reliable(void)
>               tsc_disable_clocksource_watchdog();
>  }
>  
> +/*
> + * TODO: Disentangle AMD_MEM_ENCRYPT and make SEV guest support depend on
> + *    HYPERVISOR_GUEST.
> + */
> +#if defined(CONFIG_HYPERVISOR_GUEST) || defined(CONFIG_AMD_MEM_ENCRYPT)
> +void tsc_register_calibration_routines(unsigned long (*calibrate_tsc)(void),
> +                                    unsigned long (*calibrate_cpu)(void))

This isn't a bug, but should tsc_register_calibration_routines() be marked
with the __init attribute?

Since all callers such as kvmclock_init(), snp_secure_tsc_init(), and
ms_hyperv_init_platform() are __init routines, and this function writes to
the x86_platform structure which is typically __ro_after_init, adding the
__init annotation would allow it to be discarded after the boot process
completes.

> +{
> +     if (WARN_ON_ONCE(!calibrate_tsc))
> +             return;
> +
> +     x86_platform.calibrate_tsc = calibrate_tsc;
> +     if (calibrate_cpu)
> +             x86_platform.calibrate_cpu = calibrate_cpu;
> +}
> +#endif

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=2

Reply via email to