[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <6D83E89737156549AEA25EF9ED712C5DDEF7@DEFTHW99EK1MSX.ww902.siemens.net>
Date: Mon, 29 Apr 2013 14:34:41 +0000
From: "Warlich, Christof" <christof.warlich@...mens.com>
To: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: X86 fpu registers in a signal handler's ucontext
Hi,
I want my signal handler to return from a SIGFPE and continue normal
execution right _after_ the instruction that caused the signal.
My first attempt workes quite well: I just modify the EIP register
though the ucontext pointer being passed to the signal handler:
void fpeHandler(int, siginfo_t *info, void *context) {
// The following function calculates the size of the instruction being pointed to.
int size = instructionSize((unsigned char *) info->si_addr);
((ucontext_t *) context)->uc_mcontext.gregs[REG_EIP] += size;
}
Doing this, my main program continues as expected as long as no other
floating point instructions are involved, but as the exception
condition is still active in the FP status register, any subsequent
and _valid_ floating point calculation cause another exception.
Thus, I tried to clear the exceptions in a similar way:
void fpeHandler(int, siginfo_t *info, void *context) {
// This function calculates the size of the instruction being poined to.
int size = instructionSize((unsigned char *) info->si_addr);
((ucontext_t *) context)->uc_mcontext.gregs[REG_EIP] += size;
((ucontext_t *) context)->uc_mcontext.fpregs->status &= ~FE_ALL_EXCEPT
}
But unfortunately, this doesn't work:
First, this link:
http://valgrind.10908.n7.nabble.com/need-FPU-and-SSE-state-in-sigcontext-ucontext-td19844.html
suggests that unlike the GPRs, the FP registers are _not_ restored after
returnung from the signal handler.
Second, only FP state seems to be available through ucontext_t, and I would
need to clear exceptions for SSE as well.
Can anyone give me some advice on how to I could proceed?
Thanks a lot,
Chris--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists