Title: [295652] trunk/Source/WebCore/platform/audio/DenormalDisabler.h
- Revision
- 295652
- Author
- commit-qu...@webkit.org
- Date
- 2022-06-17 17:15:50 -0700 (Fri, 17 Jun 2022)
Log Message
General Protection Fault in WebKitWebProcess on 32bit CPUs
Patch by Karo <karogyok...@gmail.com> on 2022-06-17
https://bugs.webkit.org/show_bug.cgi?id=241588
Reviewed by Yusuke Suzuki.
The DAZ flag is used unconditionally and that makes every 32 bit CPUs crash except newer steppings of Pentium 4.
* Source/WebCore/platform/audio/DenormalDisabler.h:
(WebCore::DenormalDisabler::DenormalDisabler):
(WebCore::DenormalDisabler::isDAZSupported):
Canonical link: https://commits.webkit.org/251657@main
Modified Paths
Diff
Modified: trunk/Source/WebCore/platform/audio/DenormalDisabler.h (295651 => 295652)
--- trunk/Source/WebCore/platform/audio/DenormalDisabler.h 2022-06-17 23:59:31 UTC (rev 295651)
+++ trunk/Source/WebCore/platform/audio/DenormalDisabler.h 2022-06-18 00:15:50 UTC (rev 295652)
@@ -26,6 +26,7 @@
#define DenormalDisabler_h
#include <wtf/MathExtras.h>
+#include <cinttypes>
namespace WebCore {
@@ -36,7 +37,7 @@
#define HAVE_DENORMAL
#endif
-#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+#if COMPILER(GCC_COMPATIBLE) && defined(__SSE__)
#define HAVE_DENORMAL
#endif
@@ -56,7 +57,7 @@
_controlfp_s(&unused, _DN_FLUSH, _MCW_DN);
#else
m_savedCSR = getCSR();
- setCSR(m_savedCSR | 0x8040);
+ setCSR(m_savedCSR | (isDAZSupported() ? 0x8040 : 0x8000));
#endif
}
@@ -83,7 +84,32 @@
#endif
}
private:
-#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+#if COMPILER(GCC_COMPATIBLE) && defined(__SSE__)
+ static inline bool isDAZSupported()
+ {
+#if CPU(X86_64)
+ return true;
+#else
+ static bool s_isInited = false;
+ static bool s_isSupported = false;
+ if (s_isInited)
+ return s_isSupported;
+
+ struct fxsaveResult {
+ uint8_t before[28];
+ uint32_t CSRMask;
+ uint8_t after[480];
+ } __attribute__ ((aligned (16)));
+
+ fxsaveResult registerData;
+ memset(®isterData, 0, sizeof(fxsaveResult));
+ asm volatile("fxsave %0" : "=m" (registerData));
+ s_isSupported = registerData.CSRMask & 0x0040;
+ s_isInited = true;
+ return s_isSupported;
+#endif
+ }
+
inline int getCSR()
{
int result;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes