diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2020-12-06 18:13:16 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2020-12-06 18:13:16 +0000 |
commit | d40706b91c35c6bb0d7bb8293564a489e6bd6fcf (patch) | |
tree | 56abca2ad3ea263c9b7359c3bff8bfc93ff4994e /lib | |
parent | 99300dfeff93a081242207c848c6f5a3acbd4beb (diff) |
On i386 setjmp(3) should store the FPU state and longjmp(3) restore
it. There is enough space in jmp_buf to save MXCSR and CW register.
Idea taken from amd64. This fixes regress/lib/libc/setjmp-fpu .
OK kettenis@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/arch/i386/gen/_setjmp.S | 6 | ||||
-rw-r--r-- | lib/libc/arch/i386/gen/setjmp.S | 6 | ||||
-rw-r--r-- | lib/libc/arch/i386/gen/sigsetjmp.S | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/lib/libc/arch/i386/gen/_setjmp.S b/lib/libc/arch/i386/gen/_setjmp.S index 8f77112e7db..f1f5d99fd71 100644 --- a/lib/libc/arch/i386/gen/_setjmp.S +++ b/lib/libc/arch/i386/gen/_setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: _setjmp.S,v 1.7 2020/12/06 15:31:30 bluhm Exp $ */ +/* $OpenBSD: _setjmp.S,v 1.8 2020/12/06 18:13:15 bluhm Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -63,6 +63,8 @@ ENTRY(_setjmp) movl %ecx,(_JB_EBP * 4)(%eax) movl %esi,(_JB_ESI * 4)(%eax) movl %edi,(_JB_EDI * 4)(%eax) + stmxcsr (_JB_MXCSR * 4)(%eax) + fnstcw (_JB_FCW * 4)(%eax) xorl %eax,%eax ret END(_setjmp) @@ -73,6 +75,8 @@ ENTRY(_longjmp) addl $__jmpxor-1b,%ecx # load cookie address movl 4(%esp),%edx # parameter, pointer to env movl 8(%esp),%eax # parameter, val + ldmxcsr (_JB_MXCSR * 4)(%edx) + fldcw (_JB_FCW * 4)(%edx) movl (_JB_EBX * 4)(%edx),%ebx movl (_JB_ESP * 4)(%edx),%esi xorl 4(%ecx),%esi # use esp cookie diff --git a/lib/libc/arch/i386/gen/setjmp.S b/lib/libc/arch/i386/gen/setjmp.S index 6e4cb37b0c3..47104a3c8b8 100644 --- a/lib/libc/arch/i386/gen/setjmp.S +++ b/lib/libc/arch/i386/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.12 2020/12/06 15:31:30 bluhm Exp $ */ +/* $OpenBSD: setjmp.S,v 1.13 2020/12/06 18:13:15 bluhm Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -78,6 +78,8 @@ ENTRY(setjmp) movl 8(%edx),%edx # load eip cookie over cookie address xorl 0(%esp),%edx # caller address movl %edx,(_JB_EIP * 4)(%ecx) + stmxcsr (_JB_MXCSR * 4)(%ecx) + fnstcw (_JB_FCW * 4)(%ecx) xorl %eax,%eax ret END(setjmp) @@ -95,6 +97,8 @@ ENTRY(longjmp) movl 4(%esp),%edx # parameter, pointer to env movl 8(%esp),%eax # parameter, val + ldmxcsr (_JB_MXCSR * 4)(%edx) + fldcw (_JB_FCW * 4)(%edx) movl (_JB_EBX * 4)(%edx),%ebx movl (_JB_ESP * 4)(%edx),%esi xorl 0(%ecx),%esi # use esp cookie diff --git a/lib/libc/arch/i386/gen/sigsetjmp.S b/lib/libc/arch/i386/gen/sigsetjmp.S index 8ab77e636e9..935d1514230 100644 --- a/lib/libc/arch/i386/gen/sigsetjmp.S +++ b/lib/libc/arch/i386/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.11 2020/12/06 15:31:30 bluhm Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.12 2020/12/06 18:13:15 bluhm Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -67,6 +67,8 @@ ENTRY(sigsetjmp) movl 4(%edx),%edx # load eip cookie over cookie address xorl 0(%esp),%edx movl %edx,(_JB_EIP * 4)(%ecx) + stmxcsr (_JB_MXCSR * 4)(%ecx) + fnstcw (_JB_FCW * 4)(%ecx) xorl %eax,%eax ret END(sigsetjmp) @@ -89,6 +91,8 @@ ENTRY(siglongjmp) movl 4(%esp),%edx # reload in case sigprocmask failed movl 8(%esp),%eax # parameter, val + ldmxcsr (_JB_MXCSR * 4)(%edx) + fldcw (_JB_FCW * 4)(%edx) movl (_JB_EBX * 4)(%edx),%ebx movl (_JB_ESP * 4)(%edx),%esi xorl 8(%ecx),%esi # use esp cookie |