On x86, the TSC is readable by userspace and you can easily derive its frequency by reading the relevant CPUID leafs. However, in some environments (e.g. virtualisation), those CPUID leafs won't always be enumerated and you won't be able to derive the TSC frequency in userspace.
However, the kernel measures the TSC frequency at boot with the PIT, then exposes it as a BootInfo entry. We should add a way to patch this information into certain PDs to make it easier to use the TSC as a fast and accurate clock source (e.g. for userspace timer drivers or VMMs).
It could look like this:
<system>
<protection_domain name="timer_driver" priority="200" >
<program_image path="timer.elf" />
<setvar x86_tsc_freq_symbol="tsc_freq" />
</protection_domain>
</system>
On x86, the TSC is readable by userspace and you can easily derive its frequency by reading the relevant CPUID leafs. However, in some environments (e.g. virtualisation), those CPUID leafs won't always be enumerated and you won't be able to derive the TSC frequency in userspace.
However, the kernel measures the TSC frequency at boot with the PIT, then exposes it as a BootInfo entry. We should add a way to patch this information into certain PDs to make it easier to use the TSC as a fast and accurate clock source (e.g. for userspace timer drivers or VMMs).
It could look like this: