~mozillateam/firefox/firefox-beta.trusty

« back to all changes in this revision

Viewing changes to debian/patches/armhf-disable-unaligned-fp-access-emulation.patch

  • Committer: Rico Tzschichholz
  • Date: 2019-03-27 10:53:57 UTC
  • Revision ID: ricotz@ubuntu.com-20190327105357-p3plc4yy9ow41d69
* New upstream release from the beta channel (FIREFOX_67_0b5_BUILD1)
* Update patches
  - debian/patches/partially-revert-google-search-update.patch
  - debian/patches/mark-distribution-search-engines-as-read-only.patch
  - debian/patches/support-coinstallable-trunk-build.patch
  - debian/patches/cleanup-old-distribution-search-engines.patch
  - debian/patches/ubuntu-ua-string-changes.patch
  - debian/patches/armhf-disable-unaligned-fp-access-emulation.patch
* Bump build-dep on rustc >= 1.32.0 and cargo >= 0.33
* Update cbindgen to 0.8.2
  - debian/build/create-tarball.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# HG changeset patch
2
 
# User Lars T Hansen <lhansen@mozilla.com>
3
 
# Date 1550043288 -3600
4
 
# Node ID 322de2cc80194c4fe859989738f7c3c2b70b98a4
5
 
# Parent  3b1b94e39795d5af17da5908ad8d05e7cefb89e5
6
 
Bug 1526653 - Document some ARM Linux compile problems.  r=luke
7
 
 
8
 
Not every ARM Linux distro (all of them tier-3 apart from Android) has
9
 
a sys/user.h that provides the necessary structures for us to emulate
10
 
unaligned FP accesses.  Raspbian is a case in point; the only user.h
11
 
on the system is some generic glibc thing that is completely wrong for
12
 
ARM.
13
 
 
14
 
We can't really hope to #ifdef our way out of this -- for example,
15
 
there does not seem to be a reliable preprocessor name for Raspbian,
16
 
nor is there a canonical preprocessor name that sys/user.h exports
17
 
when the desired structures are defined.
18
 
 
19
 
Therefore, add some comments to explain the problem and introduce a
20
 
choke point that tier-3 porters can use if they run into the problem.
21
 
 
22
 
Differential Revision: https://phabricator.services.mozilla.com/D19637
23
 
 
24
 
diff --git a/js/src/wasm/WasmSignalHandlers.cpp b/js/src/wasm/WasmSignalHandlers.cpp
25
 
--- a/js/src/wasm/WasmSignalHandlers.cpp
26
 
+++ b/js/src/wasm/WasmSignalHandlers.cpp
27
 
@@ -208,17 +208,35 @@ using mozilla::DebugOnly;
28
 
 #  define R11_sig(p) ((p)->thread.__r[11])
29
 
 #  define R13_sig(p) ((p)->thread.__sp)
30
 
 #  define R14_sig(p) ((p)->thread.__lr)
31
 
 #  define R15_sig(p) ((p)->thread.__pc)
32
 
 #else
33
 
 #  error "Don't know how to read/write to the thread state via the mcontext_t."
34
 
 #endif
35
 
 
36
 
+// On ARM Linux, including Android, unaligned FP accesses that were not flagged
37
 
+// as unaligned will tend to trap (with SIGBUS) and will need to be emulated.
38
 
+//
39
 
+// We can only perform this emulation if the system header files provide access
40
 
+// to the FP registers.  In particular, <sys/user.h> must have definitions of
41
 
+// `struct user_vfp` and `struct user_vfp_exc`, as it does on Android.
42
 
+//
43
 
+// Those definitions are however not present in the headers of every Linux
44
 
+// distro - Raspbian is known to be a problem, for example.  However those
45
 
+// distros are tier-3 platforms.
46
 
+//
47
 
+// If you run into compile problems on a tier-3 platform, you can disable the
48
 
+// emulation here.
49
 
+
50
 
 #if defined(__linux__) && defined(__arm__)
51
 
+#  define WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS
52
 
+#endif
53
 
+
54
 
+#ifdef WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS
55
 
 #  include <sys/user.h>
56
 
 #endif
57
 
 
58
 
 #if defined(ANDROID)
59
 
 // Not all versions of the Android NDK define ucontext_t or mcontext_t.
60
 
 // Detect this and provide custom but compatible definitions. Note that these
61
 
 // follow the GLibc naming convention to access register values from
62
 
 // mcontext_t.
63
 
@@ -436,17 +454,17 @@ struct AutoHandlingTrap {
64
 
   }
65
 
 
66
 
   ~AutoHandlingTrap() {
67
 
     MOZ_ASSERT(sAlreadyHandlingTrap.get());
68
 
     sAlreadyHandlingTrap.set(false);
69
 
   }
70
 
 };
71
 
 
72
 
-#if defined(__linux__) && defined(__arm__)
73
 
+#ifdef WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS
74
 
 
75
 
 // Code to handle SIGBUS for unaligned floating point accesses on 32-bit ARM.
76
 
 
77
 
 static uintptr_t ReadGPR(CONTEXT* context, uint32_t rn) {
78
 
   switch (rn) {
79
 
     case 0:
80
 
       return context->uc_mcontext.arm_r0;
81
 
     case 1:
82
 
@@ -636,22 +654,22 @@ static bool HandleUnalignedTrap(CONTEXT*
83
 
   }
84
 
 
85
 
 #  ifdef DEBUG
86
 
   MOZ_CRASH(
87
 
       "SIGBUS handler could not access FP register, incompatible kernel?");
88
 
 #  endif
89
 
   return false;
90
 
 }
91
 
-#else   // __linux__ && __arm__
92
 
+#else   // WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS
93
 
 static bool HandleUnalignedTrap(CONTEXT* context, uint8_t* pc,
94
 
                                 Instance* instance) {
95
 
   return false;
96
 
 }
97
 
-#endif  // __linux__ && __arm__
98
 
+#endif  // WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS
99
 
 
100
 
 static MOZ_MUST_USE bool HandleTrap(CONTEXT* context,
101
 
                                     bool isUnalignedSignal = false,
102
 
                                     JSContext* assertCx = nullptr) {
103
 
   MOZ_ASSERT(sAlreadyHandlingTrap.get());
104
 
 
105
 
   uint8_t* pc = ContextToPC(context);
106
 
   const CodeSegment* codeSegment = LookupCodeSegment(pc);
107
 
@@ -1165,8 +1183,10 @@ bool wasm::HandleIllegalInstruction(cons
108
 
     return false;
109
 
   }
110
 
 
111
 
   jit::JitActivation* activation = TlsContext.get()->activation()->asJit();
112
 
   activation->startWasmTrap(trap, bytecode.offset(), regs);
113
 
   *newPC = segment.trapCode();
114
 
   return true;
115
 
 }
116
 
+
117
 
+#undef WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS
118
 
 
119
1
Description: disable unaligned FP accesses emulation on armhf, as Ubuntu does
120
2
 not have definitions for `struct user_vfp` and `struct user_vfp_exc`.
121
3
Author: Olivier Tilloy <olivier.tilloy@canonical.com>