[tyndur-devel] [PATCH] SSE aktivieren, um #UD zu verhindern
Patrick Pokatilo ·
+ SSE wird während des init-Prozesses aktiviert, um etwaige #UD, die durch vom Compiler zur Optimierung oder zum Handling von 64 bit Integern eingefügte SSE Operation entstehen können, zu verhindern Signed-off-by: Patrick Pokatilo <shyxormz at asxsoft.de> --- src/kernel2/src/init.c | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/src/kernel2/src/init.c b/src/kernel2/src/init.c index a4d16d5..fc9bebd 100644 --- a/src/kernel2/src/init.c +++ b/src/kernel2/src/init.c @@ -174,7 +174,30 @@ void init(int multiboot_magic, struct multiboot_info *boot_info, bool bsp) static volatile uint32_t cpus_arrived = 0; locked_increment(&cpus_arrived); while (cpus_arrived < cpu_count) asm("nop"); - + + // SSE aktivieren + // TODO: Buildscripts fixen? + #if CONFIG_ARCH == ARCH_AMD64 + asm volatile( + "movq %cr0, %rax;" + "andq $0xfffffffffffffffb, %rax;" + "orq $2, %rax;" + "movq %rax, %cr0;" + "movq %cr4, %rax;" + "orq $0x600, %rax;" + "movq %rax, %cr4;" + ); + #else + asm volatile( + "movl %cr0, %eax;" + "andl $0xfffffffb, %eax;" + "orl $2, %eax;" + "movl %eax, %cr0;" + "movl %cr4, %eax;" + "orl $0x600, %eax;" + "movl %eax, %cr4;" + ); + #endif static volatile lock_t vmm_lock = LOCK_LOCKED; // ACHTUNG: Hier besteht ein kleines Problem: Da in vmm_init der APIC -- 1.7.0.4