Enable FP Exception from userspace

Renato Benassato Riolino renato.riolino at eldorado.org.br
Tue Feb 11 16:54:43 UTC 2020


Hi all,

I'm working on a small patch on kernel to handle float point exception
to trigger a SIGFPE to the process.

Right now I'm stuck on how an userspace app could enable FPE on PPC?

Just calling feenableexcept(FE_ALL_EXCEPT) isn't enough. I need to set
FE0 or FE1 or both (imprecise non-recoverable, imprecise recoverable
and precise) on MSR, but I have no idea how to do so from userspace.

I was able to make it work using getcontext() and setcontext() but it
looked very hackish.

From PowerISA V2.07B, Book III-S, Chapter 6.5.9:

A Floating-Point Enabled Exception type Program interrupt is generated
when the value of the expression

(MSR FE0 | MSR FE1 ) & FPSCR FEX

is 1. FPSCR FEX is set to 1 by the execution of a floating-point
instruction that causes an enabled exception, including the case of a
Move To FPSCR instruction that causes an exception bit and the
corresponding enable bit both to be 1.


Thanks

Renato


More information about the freebsd-ppc mailing list