firecracker icon indicating copy to clipboard operation
firecracker copied to clipboard

Use 0x40000010 CPUID leaf to announce frequencies

Open cperciva opened this issue 11 months ago • 12 comments

The 0x40000010 CPUID leaf is used to announce TSC and local APIC frequencies to VM guests; this allows them to boot faster by bypassing clock calibration loops.

Changes

In x86_64 initialization, passes the TSC frequency to cpuid.normalize, which then (a) updates the 0x40000000 CPUID leaf to announce support for leaves up to 0x40000010, and (b) adds a 0x40000010 CPUID leaf to announce the TSC frequency and LAPIC frequency (which is always 10^6 in KVM).

Reason

Improve boot performance. This leaf is already used in most other hypervisors, including EC2.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check CONTRIBUTING.md.

PR Checklist

  • [N/A] If a specific issue led to this PR, this PR closes the issue.
  • [X] The description of changes is clear and encompassing.
  • [N/A] Any required documentation changes (code and docs) are included in this PR.
  • [N/A] API changes follow the Runbook for Firecracker API changes.
  • [N/A] User-facing changes are mentioned in CHANGELOG.md.
  • [ ] All added/changed functionality is tested.
  • [ ] New TODOs link to an issue.
  • [x] Commits meet contribution quality standards.

  • [x] This functionality cannot be added in rust-vmm.

cperciva avatar Jul 11 '23 00:07 cperciva