1. 08 Jan, 2014 5 commits
    • Joseph Myers's avatar
      math-emu: fix floating-point to integer overflow detection · d06b3326
      Joseph Myers authored
      On overflow, the math-emu macro _FP_TO_INT_ROUND tries to saturate its
      result (subject to the value of rsigned specifying the desired
      overflow semantics).  However, if the rounding step has the effect of
      increasing the exponent so as to cause overflow (if the rounded result
      is 1 larger than the largest positive value with the given number of
      bits, allowing for signedness), the overflow does not get detected,
      meaning that for unsigned results 0 is produced instead of the maximum
      unsigned integer with the give number of bits, without an exception
      being raised for overflow, and that for signed results the minimum
      (negative) value is produced instead of the maximum (positive) value,
      again without an exception.  This patch makes the code check for
      rounding increasing the exponent and adjusts the exponent value as
      needed for the overflow check.
      Signed-off-by: default avatarJoseph Myers <joseph@codesourcery.com>
      Signed-off-by: default avatarScott Wood <scottwood@freescale.com>
      d06b3326
    • Joseph Myers's avatar
      math-emu: fix floating-point to integer unsigned saturation · 4f6db5ef
      Joseph Myers authored
      The math-emu macros _FP_TO_INT and _FP_TO_INT_ROUND are supposed to
      saturate their results for out-of-range arguments, except in the case
      rsigned == 2 (when instead the low bits of the result are taken).
      However, in the case rsigned == 0 (converting to unsigned integers),
      they mistakenly produce 0 for positive results and the maximum
      unsigned integer for negative results, the opposite of correct
      unsigned saturation.  This patch fixes the logic.
      Signed-off-by: default avatarJoseph Myers <joseph@codesourcery.com>
      Signed-off-by: default avatarScott Wood <scottwood@freescale.com>
      4f6db5ef
    • Joseph Myers's avatar
      powerpc: fix e500 SPE float rounding inexactness detection · 28414a6d
      Joseph Myers authored
      The e500 SPE floating-point emulation code for the rounding modes
      rounding to positive or negative infinity (which may not be
      implemented in hardware) tries to avoid emulating rounding if the
      result was inexact.  However, it tests inexactness using the sticky
      bit with the cumulative result of previous operations, rather than
      with the non-sticky bits relating to the operation that generated the
      interrupt.  Furthermore, when a vector operation generates the
      interrupt, it's possible that only one of the low and high parts is
      inexact, and so only that part should have rounding emulated.  This
      results in incorrect rounding of exact results in these modes when the
      sticky bit is set from a previous operation.
      
      (I'm not sure why the rounding interrupts are generated at all when
      the result is exact, but empirically the hardware does generate them.)
      
      This patch checks for inexactness using the correct bits of SPEFSCR,
      and ensures that rounding only occurs when the relevant part of the
      result was actually inexact.
      Signed-off-by: default avatarJoseph Myers <joseph@codesourcery.com>
      Signed-off-by: default avatarScott Wood <scottwood@freescale.com>
      28414a6d
    • Joseph Myers's avatar
      powerpc: fix exception clearing in e500 SPE float emulation · 640e9225
      Joseph Myers authored
      The e500 SPE floating-point emulation code clears existing exceptions
      (__FPU_FPSCR &= ~FP_EX_MASK;) before ORing in the exceptions from the
      emulated operation.  However, these exception bits are the "sticky",
      cumulative exception bits, and should only be cleared by the user
      program setting SPEFSCR, not implicitly by any floating-point
      instruction (whether executed purely by the hardware or emulated).
      The spurious clearing of these bits shows up as missing exceptions in
      glibc testing.
      
      Fixing this, however, is not as simple as just not clearing the bits,
      because while the bits may be from previous floating-point operations
      (in which case they should not be cleared), the processor can also set
      the sticky bits itself before the interrupt for an exception occurs,
      and this can happen in cases when IEEE 754 semantics are that the
      sticky bit should not be set.  Specifically, the "invalid" sticky bit
      is set in various cases with non-finite operands, where IEEE 754
      semantics do not involve raising such an exception, and the
      "underflow" sticky bit is set in cases of exact underflow, whereas
      IEEE 754 semantics are that this flag is set only for inexact
      underflow.  Thus, for correct emulation the kernel needs to know the
      setting of these two sticky bits before the instruction being
      emulated.
      
      When a floating-point operation raises an exception, the kernel can
      note the state of the sticky bits immediately afterwards.  Some
      <fenv.h> functions that affect the state of these bits, such as
      fesetenv and feholdexcept, need to use prctl with PR_GET_FPEXC and
      PR_SET_FPEXC anyway, and so it is natural to record the state of those
      bits during that call into the kernel and so avoid any need for a
      separate call into the kernel to inform it of a change to those bits.
      Thus, the interface I chose to use (in this patch and the glibc port)
      is that one of those prctl calls must be made after any userspace
      change to those sticky bits, other than through a floating-point
      operation that traps into the kernel anyway.  feclearexcept and
      fesetexceptflag duly make those calls, which would not be required
      were it not for this issue.
      
      The previous EGLIBC port, and the uClibc code copied from it, is
      fundamentally broken as regards any use of prctl for floating-point
      exceptions because it didn't use the PR_FP_EXC_SW_ENABLE bit in its
      prctl calls (and did various worse things, such as passing a pointer
      when prctl expected an integer).  If you avoid anything where prctl is
      used, the clearing of sticky bits still means it will never give
      anything approximating correct exception semantics with existing
      kernels.  I don't believe the patch makes things any worse for
      existing code that doesn't try to inform the kernel of changes to
      sticky bits - such code may get incorrect exceptions in some cases,
      but it would have done so anyway in other cases.
      Signed-off-by: default avatarJoseph Myers <joseph@codesourcery.com>
      Signed-off-by: default avatarScott Wood <scottwood@freescale.com>
      640e9225
    • Mihai Caraman's avatar
      powerpc/booke64: Add LRAT error exception handler · 228b1a47
      Mihai Caraman authored
      LRAT (Logical to Real Address Translation) present in MMU v2 provides hardware
      translation from a logical page number (LPN) to a real page number (RPN) when
      tlbwe is executed by a guest or when a page table translation occurs from a
      guest virtual address.
      
      Add LRAT error exception handler to Booke3E 64-bit kernel and the basic KVM
      handler to avoid build breakage. This is a prerequisite for KVM LRAT support
      that will follow.
      Signed-off-by: default avatarMihai Caraman <mihai.caraman@freescale.com>
      Signed-off-by: default avatarScott Wood <scottwood@freescale.com>
      228b1a47
  2. 30 Dec, 2013 15 commits
  3. 20 Dec, 2013 1 commit
  4. 18 Dec, 2013 1 commit
    • Gerhard Sittig's avatar
      powerpc/512x: dts: remove misplaced IRQ spec from 'soc' node (5125) · bbca4d39
      Gerhard Sittig authored
      the 'soc' node in the MPC5125 "tower" board .dts has an '#interrupt-cells'
      property although this node is not an interrupt controller
      
      remove this erroneously placed property because starting with v3.13-rc1
      lookup and resolution of 'interrupts' specs for peripherals gets misled
      (tries to use the 'soc' as the interrupt parent which fails), emits
      'no irq domain found' WARN() messages and breaks the boot process
      
      [ best viewed with 'git diff -U5' to have DT node names in the context ]
      
      Cc: Anatolij Gustschin <agust@denx.de>
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarGerhard Sittig <gsi@denx.de>
      Signed-off-by: default avatarAnatolij Gustschin <agust@denx.de>
      bbca4d39
  5. 13 Dec, 2013 10 commits
  6. 10 Dec, 2013 8 commits