hw: enable FPU during CPU startup on x86

Also disable TS (task switch) flag in cr0 during kernel initialization,
so FPU faults are not raised. This became necessary since GCC lately
aggressively generates FPU instructions at arbitrary places and also at
early kernel-bootstrapping stages.

fixes #3365
This commit is contained in:
Sebastian Sumpf 2019-05-21 16:17:39 +02:00 committed by Christian Helmuth
parent e60b597af5
commit f18285205c
2 changed files with 23 additions and 1 deletions

View File

@ -157,6 +157,23 @@ __gdt:
movq (%rax), %rsp
addq %rcx, %rsp
/*
* Enable paging and FPU:
* PE, MP, NE, WP, PG
*/
mov $0x80010023, %rax
mov %rax, %cr0
/*
* OSFXSR and OSXMMEXCPT for SSE FPU support
*/
mov %cr4, %rax
bts $9, %rax
bts $10, %rax
mov %rax, %cr4
fninit
/* kernel-initialization */
call init

View File

@ -21,7 +21,12 @@ void Genode::Fpu::init()
Cpu::Cr0::Mp::set(cr0_value);
Cpu::Cr0::Em::clear(cr0_value);
Cpu::Cr0::Ts::set(cr0_value);
/*
* Clear task switched so we do not gnerate FPU faults during kernel
* initialisation, it will be turned on by Fpu::disable
*/
Cpu::Cr0::Ts::clear(cr0_value);
Cpu::Cr0::Ne::set(cr0_value);
Cpu::Cr0::write(cr0_value);