[Webkit-unassigned] [Bug 241588] General Protection Fault in WebKitWebProcess on 32bit CPUs

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jun 15 06:59:13 PDT 2022


https://bugs.webkit.org/show_bug.cgi?id=241588

--- Comment #2 from karogyoker2+webkit at gmail.com ---
> The proper solution would be to detect DAZ support. We can keep using the
> 0x8000 mask if there is SSE as it is now. But if there is DAZ as well, use
> 0x8040. This way we can get the most optimal performance on most CPUs.

Detecting DAZ can be done in run time:

#include <cstring>
#include <cinttypes>
// Precondition: SSE support, but we take that granted for i386
bool isDazSupported()
{
#if defined(__i386__)
#if defined(__x86_64__)
  return true;
#else
  struct fxsave_area_struct {
    uint8_t             before[28];
    uint32_t    mxcsr_mask;
    uint8_t             after[480];
  } __attribute__ ((aligned (16)));

  fxsave_area_struct regdata;
  memset(&regdata, 0, sizeof(fxsave_area_struct));
  asm volatile ("fxsave %0" : "=m" (regdata));
  return regdata.mxcsr_mask & 0x0040;
#endif
#else
  return false;
#endif
}

I don't know where should I put isDazSupported(). This function would be needed for WebRTC as well, because in its code the false assumption was made there as well that all x86 CPU supports DAZ.
Also, isDazSupported() should be called only once. In the past there was a run time check for SSE2 support, I can't find it now. I also don't know how the 32 bit WebKit build without SSE2 is being built currently on 64 bit systems. The DAZ support might be handled similarly.

We could have a simpler solution: Treat all 64 bit builds DAZ compatible and all 32 bit builds DAZ incompatible. In this case the drawback would be that 32 bit builds would have a performance degradation on all 64 bit CPUs and on some newer 32 bit Pentium 4 CPUs. 

In this case the fix in DenormalDisabler.h would be pretty straightforward.
#if CPU(X86_64)
        setCSR(m_savedCSR | 0x8040);
#else
        setCSR(m_savedCSR | 0x8000);
#endif

Then a similar fix could be done in denormal_disabler.cc.

// Control register bit mask to disable denormals on the hardware.
#if defined(WEBRTC_DENORMAL_DISABLER_X86_SUPPORTED)
#if defined(WEBRTC_ARCH_X86_64)
// On x86_64 two bits are used: flush-to-zero (FTZ) and denormals-are-zero (DAZ).
constexpr int kDenormalBitMask = 0x8040;
#else
// On x86 one bit is used: flush-to-zero (FTZ).
constexpr int kDenormalBitMask = 0x8000;
#endif
#elif defined(WEBRTC_ARCH_ARM_FAMILY)
// On ARM one bit is used: flush-to-zero (FTZ).
constexpr int kDenormalBitMask = 1 << 24;
#endif

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220615/46f67c5f/attachment.htm>


More information about the webkit-unassigned mailing list