Ignore:
Timestamp:
Jun 28, 2006, 10:04:39 AM (13 years ago)
Author:
gb
Message:

FreeBSD doesn't do a good job of identifying the cause of XMM FP
exceptions. Try to do that by looking at MXCSR bits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lisp-kernel/x86-exceptions.c

    r4850 r4859  
    569569}
    570570
     571
     572#ifdef FREEBSD
     573static
     574char mxcsr_bit_to_fpe_code[] = {
     575  FPE_FLTINV,                   /* ie */
     576  0,                            /* de */
     577  FPE_FLTDIV,                   /* ze */
     578  FPE_FLTOVF,                   /* oe */
     579  FPE_FLTUND,                   /* ue */
     580  FPE_FLTRES                    /* pe */
     581};
     582
     583void
     584freebsd_decode_vector_fp_exception(siginfo_t *info, ExceptionInformation *xp)
     585{
     586  /* If the exception appears to be an XMM FP exception, try to
     587     determine what it was by looking at bits in the mxcsr.
     588  */
     589  if (info->si_code == 0) {
     590    struct savefpu *fpu = (struct savefpu *) &(xp->uc_mcontext.mc_fpstate);
     591    uint32_t mxcsr = fpu->sv_env.en_mxcsr;
     592    int xbit, maskbit;
     593   
     594    for (xbit = 0, maskbit = MXCSR_IM_BIT; xbit < 6; xbit++, maskbit++) {
     595      if ((mxcsr & (1 << xbit)) &&
     596          !(mxcsr & (1 << maskbit))) {
     597        info->si_code = mxcsr_bit_to_fpe_code[xbit];
     598        return;
     599      }
     600    }
     601  }
     602}
     603#endif
    571604
    572605Boolean
     
    648681   
    649682  case SIGFPE:
     683#ifdef FREEBSD
     684    /* As of 6.1, FreeBSD/AMD64 doesn't seem real comfortable
     685       with this newfangled XMM business (and therefore info->si_code
     686       is often 0 on an XMM FP exception.
     687       Try to figure out what really happened by decoding mxcsr
     688       bits.
     689    */
     690    freebsd_decode_vector_fp_exception(info,context);
     691#endif
    650692    return handle_floating_point_exception(tcr, context, info);
    651693
Note: See TracChangeset for help on using the changeset viewer.