haiku/headers/private/kernel/arch/x86/64/iframe.h
Paweł Dziepak 396b74228e kernel/x86_64: save fpu state at interrupts
The kernel is allowed to use fpu anywhere so we must make sure that
user state is not clobbered by saving fpu state at interrupt entry.
There is no need to do that in case of system calls since all fpu
data registers are caller saved.

We do not need, though, to save the whole fpu state at task swich
(again, thanks to calling convention). Only status and control
registers are preserved. This patch actually adds xmm0-15 register
to clobber list of task swich code, but the only reason of that is
to make sure that nothing bad happens inside the function that
executes that task swich. Inspection of the generated code shows
that no xmm registers are actually saved.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2014-09-14 19:16:52 +02:00

50 lines
799 B
C

/*
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_X86_64_IFRAME_H
#define _KERNEL_ARCH_X86_64_IFRAME_H
struct iframe {
uint64 type;
void* fpu;
uint64 r15;
uint64 r14;
uint64 r13;
uint64 r12;
uint64 r11;
uint64 r10;
uint64 r9;
uint64 r8;
uint64 bp;
uint64 si;
uint64 di;
uint64 dx;
uint64 cx;
uint64 bx;
uint64 ax;
uint64 orig_rax;
uint64 vector;
uint64 error_code;
uint64 ip;
uint64 cs;
uint64 flags;
// SP and SS are unconditionally present on x86_64, make both names
// available.
union {
uint64 sp;
uint64 user_sp;
};
union {
uint64 ss;
uint64 user_ss;
};
} _PACKED;
#define IFRAME_IS_USER(f) (((f)->cs & DPL_USER) == DPL_USER)
#endif /* _KERNEL_ARCH_X86_64_IFRAME_H */