save fpregs when to call sighandler

refs #50
This commit is contained in:
Tomoki Shirasawa
2016-07-05 15:26:00 +09:00
parent fc66556f9f
commit 5c190beb04
2 changed files with 65 additions and 4 deletions

View File

@@ -181,6 +181,7 @@ static void init_idt(void)
}
static int xsave_available = 0;
static int xsave_size = 0;
void init_fpu(void)
{
@@ -224,6 +225,14 @@ void init_fpu(void)
xsetbv(0, reg);
dkprintf("init_fpu(): AVX init: XCR0 = 0x%016lX\n", reg);
}
if(xsave_available){
unsigned long eax;
unsigned long ebx;
unsigned long ecx;
unsigned long edx;
asm volatile("cpuid" : "=a"(eax),"=b"(ebx),"=c"(ecx),"=d"(edx) : "a" (0x0d), "c" (0x00));
xsave_size = ecx;
}
/* TODO: set MSR_IA32_XSS to enable xsaves/xrstors */
@@ -234,6 +243,12 @@ void init_fpu(void)
asm volatile("finit");
}
int
get_xsave_size()
{
return xsave_size;
}
void reload_gdt(struct x86_desc_ptr *gdt_ptr)
{
asm volatile("pushq %1\n"