[tyndur-devel] [PATCH] kernel2: auf Vorhandensein von SSE prüfen vor dem versuch es zu aktivieren ;)
Stefan Linke ·
! auf älteren CPUs ohne sse hatte der init code einen GP gebaut wegen nicht vorhandenen Bits in cr4. Check für Vorhandensein davor eingebaut Signed-off-by: Stefan Linke <particleflux at googlemail.com> --- src/kernel2/src/init.c | 48 ++++++++++++++++++++++++++---------------------- 1 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/kernel2/src/init.c b/src/kernel2/src/init.c index 08c0a71..37bc60e 100644 --- a/src/kernel2/src/init.c +++ b/src/kernel2/src/init.c @@ -219,28 +219,32 @@ void init(int multiboot_magic, struct multiboot_info *boot_info, bool bsp) // 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 - + uint32_t edx=0; + asm volatile("cpuid": "=d" (edx) : "a" (1) : "ebx", "ecx"); + if ((edx & (1 << 24)) && (edx & (1 << 25))) { // check if FXSR and SSE bits are set + #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 // gemappt wird, kann nicht mehr darauf zugegriffen werden, bis Paging -- 1.7.8.6