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
F101984761: D34581.diff
Wed, Nov 6, 4:37 AM
Unknown Object (File)
Mon, Oct 7, 1:52 PM
Unknown Object (File)
Oct 1 2024, 6:24 PM
Unknown Object (File)
Sep 30 2024, 11:04 PM
Unknown Object (File)
Sep 28 2024, 2:19 PM
Unknown Object (File)
Sep 28 2024, 9:06 AM
Unknown Object (File)
Sep 19 2024, 7:44 AM
Unknown Object (File)
Sep 19 2024, 4:13 AM
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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 44807
Build 41695: arc lint + arc unit

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