Skip to contentSkip to conversation

accessing stacked FPU state in 32-bit SIGFPE handler?

DISCUSSION Mikael Pettersson 2 participants 3 messages May 7, 2016

lore
Share & tools
lore
#0 lore raw

What is the approved way of accessing the stacked FPU state from a SIGFPE handler (sigaction + SA_SIGINFO) in a 32-bit process? I need to update parts of that state.

The third parameter to the handler is a sigcontext pointer, but the struct ends just before the stacked fpu_save pointer. Also, the type that fpu_save points to doesn't appear to be defined by glibc's headers.

I could duplicate the kernel's types (32-bit __siginfo_fpu_t and struct rt_signal_frame), but that feels a bit unsafe unless there's a statement that they form a de-facto ABI.

#1 lore raw

From: Mikael Pettersson <[email protected]>
Date: Sat, 7 May 2016 17:50:32 +0200

Quoted 11 lines

What is the approved way of accessing the stacked FPU state from a SIGFPE handler (sigaction + SA_SIGINFO) in a 32-bit process? I need to update parts of that state.

The third parameter to the handler is a sigcontext pointer, but the struct ends just before the stacked fpu_save pointer. Also, the type that fpu_save points to doesn't appear to be defined by glibc's headers.

I could duplicate the kernel's types (32-bit __siginfo_fpu_t and struct rt_signal_frame), but that feels a bit unsafe unless there's a statement that they form a de-facto ABI.

You can be sure the on-stack signal saved state layout won't change, otherwise gdb, exception unwinding, and a host of other things would break.

#2 lore raw
In reply to Mikael Pettersson
Quoted 11 lines · David Miller

From: Mikael Pettersson <[email protected]>
Date: Sat, 7 May 2016 17:50:32 +0200

Quoted 8 lines

What is the approved way of accessing the stacked FPU state from a SIGFPE handler (sigaction + SA_SIGINFO) in a 32-bit process? I need to update parts of that state.

The third parameter to the handler is a sigcontext pointer, but the struct ends just before the stacked fpu_save pointer. Also, the type that fpu_save points to doesn't appear to be defined by glibc's headers.

Quoted 7 lines
Quoted 3 lines

I could duplicate the kernel's types (32-bit __siginfo_fpu_t and struct rt_signal_frame), but that feels a bit unsafe unless there's a statement that they form a de-facto ABI.

You can be sure the on-stack signal saved state layout won't change, otherwise gdb, exception unwinding, and a host of other things would break.

Thanks, that works for me.