Page MenuHomeFreeBSD

x86/tsc: fetch frequency from CPUID when running on Xen
ClosedPublic

Authored by royger on Mar 16 2022, 4:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 8 2024, 2:45 PM
Unknown Object (File)
Mar 8 2024, 2:45 PM
Unknown Object (File)
Mar 7 2024, 6:44 PM
Unknown Object (File)
Feb 26 2024, 5:18 PM
Unknown Object (File)
Feb 26 2024, 12:42 AM
Unknown Object (File)
Jan 11 2024, 6:37 PM
Unknown Object (File)
Dec 20 2023, 5:23 AM
Unknown Object (File)
Dec 13 2023, 5:02 PM
Subscribers

Details

Summary

Introduce a helper to fetch the TSC frequency from CPUID when running
under Xen.

Sponsored by: Citrix Systems R&D

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/x86/x86/tsc.c
157

Since this routine is using virtualized cpuid leaf to obtain a fequency value, why not simply inline it into tsc_freq_cpuid_vm() or call this routine from there?

sys/x86/x86/tsc.c
157

I was mostly following what's done for tsc_freq_vmware(), but I could see about unifying all those into a single helper if that's preferred.

This needs to be rebased on top of 075e2779aca7cbd8f201ce0e1bb60318d0cbd8b8 .

sys/x86/x86/tsc.c
157

Ok, on second thought your approach seems good. The probe_tsc_freq() helpers are a bit inconsistent (e.g., whether or not they assign to tsc_freq directly or not, whether they emit the bootverbose message or not) and could maybe benefit from some refactoring, but that's a separate change.

159

Should we verify hv_high >= 0x40000003 first?

sys/x86/x86/tsc.c
159

It's a non-optional leaf so not having it would mean something has gone very wrong. I had a KASSERT originally, but ended up removing it. I can add it.

  • Rebase over changes in tsc.c.
  • Add KASSERT.
  • Call tsc_init from Xen PVH early_clock_source_init hook.

It might be better to pull tsc_init() call out of the hook implementation, now that all of them call it anyway.

Pull out tsc_init calls from the early_clock_source_init() handlers.

This revision is now accepted and ready to land.Mar 17 2022, 2:42 PM