From c92ba0b82fe23d7f0565c5a0821db0fc6aabed06 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Thu, 28 Apr 2022 09:29:02 -0600
Subject: [PATCH] Do not enable OSXSAVE, Redox does not need it

---
 asm/x86-unknown-none/long_mode.asm | 4 ++--
 src/os/uefi/arch/x86_64.rs         | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/asm/x86-unknown-none/long_mode.asm b/asm/x86-unknown-none/long_mode.asm
index 3a01d21..e0adb04 100644
--- a/asm/x86-unknown-none/long_mode.asm
+++ b/asm/x86-unknown-none/long_mode.asm
@@ -14,9 +14,9 @@ long_mode:
     and eax, 0x7FFFFFFF
     mov cr0, eax
 
-    ; enable OSXSAVE, FXSAVE/FXRSTOR, Page Global, Page Address Extension, and Page Size Extension
+    ; enable FXSAVE/FXRSTOR, Page Global, Page Address Extension, and Page Size Extension
     mov eax, cr4
-    or eax, 1 << 18 | 1 << 9 | 1 << 7 | 1 << 5 | 1 << 4
+    or eax, 1 << 9 | 1 << 7 | 1 << 5 | 1 << 4
     mov cr4, eax
 
     ; load long mode GDT
diff --git a/src/os/uefi/arch/x86_64.rs b/src/os/uefi/arch/x86_64.rs
index ffc4ffd..6d25116 100644
--- a/src/os/uefi/arch/x86_64.rs
+++ b/src/os/uefi/arch/x86_64.rs
@@ -39,10 +39,9 @@ unsafe extern "C" fn kernel_entry(
     // Disable interrupts
     asm!("cli");
 
-    // Enable OSXSAVE, FXSAVE/FXRSTOR, Page Global, Page Address Extension, and Page Size Extension
+    // Enable FXSAVE/FXRSTOR, Page Global, Page Address Extension, and Page Size Extension
     let mut cr4 = controlregs::cr4();
-    cr4 |= Cr4::CR4_ENABLE_OS_XSAVE
-        | Cr4::CR4_ENABLE_SSE
+    cr4 |= Cr4::CR4_ENABLE_SSE
         | Cr4::CR4_ENABLE_GLOBAL_PAGES
         | Cr4::CR4_ENABLE_PAE
         | Cr4::CR4_ENABLE_PSE;
-- 
GitLab