mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
Kernel: Manually reset the XCR0 register
According to the Intel manual: "After reset, all bits (except bit 0) in XCR0 are cleared to zero; XCR0[0] is set to 1." Sadly we can't trust this, for example VirtualBox starts with bits 0-4 set, so let's do it ourselves. Fixes #5653
This commit is contained in:
parent
5265a2d23e
commit
368f78d03c
Notes:
sideshowbarker
2024-07-18 21:38:03 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/368f78d03c3 Pull-request: https://github.com/SerenityOS/serenity/pull/5684 Issue: https://github.com/SerenityOS/serenity/issues/5653
@ -1033,11 +1033,18 @@ UNMAP_AFTER_INIT void Processor::cpu_setup()
|
||||
write_cr4(read_cr4() | 0x4);
|
||||
}
|
||||
|
||||
if (has_feature(CPUFeature::XSAVE) && has_feature(CPUFeature::AVX)) {
|
||||
if (has_feature(CPUFeature::XSAVE)) {
|
||||
// Turn on CR4.OSXSAVE
|
||||
write_cr4(read_cr4() | 0x40000);
|
||||
// Turn on AVX flags
|
||||
write_xcr0(read_xcr0() | 0x7);
|
||||
|
||||
// According to the Intel manual: "After reset, all bits (except bit 0) in XCR0 are cleared to zero; XCR0[0] is set to 1."
|
||||
// Sadly we can't trust this, for example VirtualBox starts with bits 0-4 set, so let's do it ourselves.
|
||||
write_xcr0(0x1);
|
||||
|
||||
if (has_feature(CPUFeature::AVX)) {
|
||||
// Turn on SSE, AVX and x87 flags
|
||||
write_xcr0(read_xcr0() | 0x7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user