Use the fpu_lock to do the work of saving and restoring

Signed-off-by: Benoît Canet <[email protected]>
---
 arch/x64/entry.S | 2 +-
 linux.cc         | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x64/entry.S b/arch/x64/entry.S
index dda7358..cd23cec 100644
--- a/arch/x64/entry.S
+++ b/arch/x64/entry.S
@@ -217,7 +217,6 @@ syscall_entry:
     # From 
http://stackoverflow.com/questions/2535989/what-are-the-calling-conventions-for-unix-linux-system-calls-on-x86-64:
     # "User-level applications use as integer registers for passing the 
sequence %rdi, %rsi, %rdx, %rcx, %r8 and %r9. The kernel interface uses %rdi, 
%rsi, %rdx, %r10, %r8 and %r9"
 
-    # FIXME: fpu
     pushq_cfi %rbx
     pushq_cfi %rdx
     pushq_cfi %rsi
@@ -250,6 +249,7 @@ syscall_entry:
     # Because we pushed an even number of 8 bytes after aligning the stack,
     # it is still 16-byte aligned and we don't need to adjust it here.
 
+    # FPU save/restore is done inside the wrapper
     callq syscall_wrapper
 
     popq_cfi %r9
diff --git a/linux.cc b/linux.cc
index 4ab88f3..63377c1 100644
--- a/linux.cc
+++ b/linux.cc
@@ -311,6 +311,10 @@ static int sys_exit(int ret)
 
 long syscall(long number, ...)
 {
+    // Save FPU state and restore it at the end of this function
+    sched::fpu_lock fpu;
+    SCOPE_LOCK(fpu);
+
     switch (number) {
     SYSCALL2(open, const char *, int);
     SYSCALL3(read, int, char *, size_t);
-- 
2.7.4

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to