Index: sys/arm64/arm64/trap.c =================================================================== --- sys/arm64/arm64/trap.c +++ sys/arm64/arm64/trap.c @@ -429,6 +429,29 @@ printf("spsr: %8x\n", frame->tf_spsr); } +#ifdef VFP +static void +do_fpe_trap(struct thread *td, void *addr, uint32_t exception) +{ + int code; + + code = FPE_FLTIDO; + if (exception & ISS_DATA_TFV) { + if (exception & ISS_DATA_TFV_IOF) + code = FPE_FLTINV; + else if (exception & ISS_DATA_TFV_DZF) + code = FPE_FLTDIV; + else if (exception & ISS_DATA_TFV_OFF) + code = FPE_FLTOVF; + else if (exception & ISS_DATA_TFV_UFF) + code = FPE_FLTUND; + else if (exception & ISS_DATA_TFV_IXF) + code = FPE_FLTRES; + } + call_trapsignal(td, SIGFPE, code, addr, exception); +} +#endif + void do_el1h_sync(struct thread *td, struct trapframe *frame) { @@ -574,9 +597,17 @@ switch (exception) { case EXCP_FP_SIMD: +#ifdef VFP + vfp_restore_state(); +#else + panic("VFP exception in userland"); +#endif + break; case EXCP_TRAP_FP: #ifdef VFP vfp_restore_state(); + do_fpe_trap(td, (void *)frame->tf_elr, esr); + userret(td, frame); #else panic("VFP exception in userland"); #endif Index: sys/arm64/include/armreg.h =================================================================== --- sys/arm64/include/armreg.h +++ sys/arm64/include/armreg.h @@ -296,6 +296,14 @@ #define ISS_DATA_ISV_SHIFT 24 #define ISS_DATA_ISV (0x01 << ISS_DATA_ISV_SHIFT) +#define ISS_DATA_TFV_SHIFT 23 +#define ISS_DATA_TFV (0x01 << ISS_DATA_TFV_SHIFT) +#define ISS_DATA_TFV_IOF 0x01 +#define ISS_DATA_TFV_DZF 0x02 +#define ISS_DATA_TFV_OFF 0x04 +#define ISS_DATA_TFV_UFF 0x08 +#define ISS_DATA_TFV_IXF 0x10 +#define ISS_DATA_TFV_IDF 0x80 #define ISS_DATA_SAS_SHIFT 22 #define ISS_DATA_SAS_MASK (0x03 << ISS_DATA_SAS_SHIFT) #define ISS_DATA_SSE_SHIFT 21 Index: sys/sys/signal.h =================================================================== --- sys/sys/signal.h +++ sys/sys/signal.h @@ -339,6 +339,7 @@ #define FPE_FLTRES 6 /* Floating point inexact result. */ #define FPE_FLTINV 7 /* Invalid floating point operation. */ #define FPE_FLTSUB 8 /* Subscript out of range. */ +#define FPE_FLTIDO 9 /* Input denormal operation */ /* codes for SIGTRAP */ #define TRAP_BRKPT 1 /* Process breakpoint. */