Skip to content
Snippets Groups Projects
Verified Commit 45e1eb7b authored by Jacob Lorentzon's avatar Jacob Lorentzon
Browse files

Set IA32_TSC_AUX if present.

parent 303c9649
No related branches found
No related tags found
1 merge request!245Set IA32_TSC_AUX and add a logical CPU ID newtype
use x86::controlregs::Cr4;
use x86::cpuid::ExtendedFeatures;
pub unsafe fn init() {
let has_ext_feat = |feat: fn(ExtendedFeatures) -> bool| crate::cpuid::cpuid_always().get_extended_feature_info().map_or(false, feat);
use crate::cpuid::cpuid_always;
pub unsafe fn init(cpu_id: usize) {
let has_ext_feat = |feat: fn(ExtendedFeatures) -> bool| {
cpuid_always()
.get_extended_feature_info()
.map_or(false, feat)
};
if has_ext_feat(|feat| feat.has_umip()) {
// UMIP (UserMode Instruction Prevention) forbids userspace from calling SGDT, SIDT, SLDT,
......@@ -25,4 +31,8 @@ pub unsafe fn init() {
// Clear CLAC in (the probably unlikely) case the bootloader set it earlier.
x86::bits64::rflags::clac();
}
if let Some(feats) = cpuid_always().get_extended_processor_and_feature_identifiers() && feats.has_rdtscp() {
x86::msr::wrmsr(x86::msr::IA32_TSC_AUX, cpu_id as u64);
}
}
......@@ -155,7 +155,7 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! {
log::init();
// Initialize miscellaneous processor features
misc::init();
misc::init(0);
// Initialize devices
device::init();
......@@ -234,7 +234,7 @@ pub unsafe extern fn kstart_ap(args_ptr: *const KernelArgsAp) -> ! {
interrupt::syscall::init();
// Initialize miscellaneous processor features
misc::init();
misc::init(cpu_id);
// Initialize devices (for AP)
device::init_ap();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment