adding-syscalls.txt 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. Adding a New System Call
  2. ========================
  3. This document describes what's involved in adding a new system call to the
  4. Linux kernel, over and above the normal submission advice in
  5. Documentation/SubmittingPatches.
  6. System Call Alternatives
  7. ------------------------
  8. The first thing to consider when adding a new system call is whether one of
  9. the alternatives might be suitable instead. Although system calls are the
  10. most traditional and most obvious interaction points between userspace and the
  11. kernel, there are other possibilities -- choose what fits best for your
  12. interface.
  13. - If the operations involved can be made to look like a filesystem-like
  14. object, it may make more sense to create a new filesystem or device. This
  15. also makes it easier to encapsulate the new functionality in a kernel module
  16. rather than requiring it to be built into the main kernel.
  17. - If the new functionality involves operations where the kernel notifies
  18. userspace that something has happened, then returning a new file
  19. descriptor for the relevant object allows userspace to use
  20. poll/select/epoll to receive that notification.
  21. - However, operations that don't map to read(2)/write(2)-like operations
  22. have to be implemented as ioctl(2) requests, which can lead to a
  23. somewhat opaque API.
  24. - If you're just exposing runtime system information, a new node in sysfs
  25. (see Documentation/filesystems/sysfs.txt) or the /proc filesystem may be
  26. more appropriate. However, access to these mechanisms requires that the
  27. relevant filesystem is mounted, which might not always be the case (e.g.
  28. in a namespaced/sandboxed/chrooted environment). Avoid adding any API to
  29. debugfs, as this is not considered a 'production' interface to userspace.
  30. - If the operation is specific to a particular file or file descriptor, then
  31. an additional fcntl(2) command option may be more appropriate. However,
  32. fcntl(2) is a multiplexing system call that hides a lot of complexity, so
  33. this option is best for when the new function is closely analogous to
  34. existing fcntl(2) functionality, or the new functionality is very simple
  35. (for example, getting/setting a simple flag related to a file descriptor).
  36. - If the operation is specific to a particular task or process, then an
  37. additional prctl(2) command option may be more appropriate. As with
  38. fcntl(2), this system call is a complicated multiplexor so is best reserved
  39. for near-analogs of existing prctl() commands or getting/setting a simple
  40. flag related to a process.
  41. Designing the API: Planning for Extension
  42. -----------------------------------------
  43. A new system call forms part of the API of the kernel, and has to be supported
  44. indefinitely. As such, it's a very good idea to explicitly discuss the
  45. interface on the kernel mailing list, and it's important to plan for future
  46. extensions of the interface.
  47. (The syscall table is littered with historical examples where this wasn't done,
  48. together with the corresponding follow-up system calls -- eventfd/eventfd2,
  49. dup2/dup3, inotify_init/inotify_init1, pipe/pipe2, renameat/renameat2 -- so
  50. learn from the history of the kernel and plan for extensions from the start.)
  51. For simpler system calls that only take a couple of arguments, the preferred
  52. way to allow for future extensibility is to include a flags argument to the
  53. system call. To make sure that userspace programs can safely use flags
  54. between kernel versions, check whether the flags value holds any unknown
  55. flags, and reject the system call (with EINVAL) if it does:
  56. if (flags & ~(THING_FLAG1 | THING_FLAG2 | THING_FLAG3))
  57. return -EINVAL;
  58. (If no flags values are used yet, check that the flags argument is zero.)
  59. For more sophisticated system calls that involve a larger number of arguments,
  60. it's preferred to encapsulate the majority of the arguments into a structure
  61. that is passed in by pointer. Such a structure can cope with future extension
  62. by including a size argument in the structure:
  63. struct xyzzy_params {
  64. u32 size; /* userspace sets p->size = sizeof(struct xyzzy_params) */
  65. u32 param_1;
  66. u64 param_2;
  67. u64 param_3;
  68. };
  69. As long as any subsequently added field, say param_4, is designed so that a
  70. zero value gives the previous behaviour, then this allows both directions of
  71. version mismatch:
  72. - To cope with a later userspace program calling an older kernel, the kernel
  73. code should check that any memory beyond the size of the structure that it
  74. expects is zero (effectively checking that param_4 == 0).
  75. - To cope with an older userspace program calling a newer kernel, the kernel
  76. code can zero-extend a smaller instance of the structure (effectively
  77. setting param_4 = 0).
  78. See perf_event_open(2) and the perf_copy_attr() function (in
  79. kernel/events/core.c) for an example of this approach.
  80. Designing the API: Other Considerations
  81. ---------------------------------------
  82. If your new system call allows userspace to refer to a kernel object, it
  83. should use a file descriptor as the handle for that object -- don't invent a
  84. new type of userspace object handle when the kernel already has mechanisms and
  85. well-defined semantics for using file descriptors.
  86. If your new xyzzy(2) system call does return a new file descriptor, then the
  87. flags argument should include a value that is equivalent to setting O_CLOEXEC
  88. on the new FD. This makes it possible for userspace to close the timing
  89. window between xyzzy() and calling fcntl(fd, F_SETFD, FD_CLOEXEC), where an
  90. unexpected fork() and execve() in another thread could leak a descriptor to
  91. the exec'ed program. (However, resist the temptation to re-use the actual value
  92. of the O_CLOEXEC constant, as it is architecture-specific and is part of a
  93. numbering space of O_* flags that is fairly full.)
  94. If your system call returns a new file descriptor, you should also consider
  95. what it means to use the poll(2) family of system calls on that file
  96. descriptor. Making a file descriptor ready for reading or writing is the
  97. normal way for the kernel to indicate to userspace that an event has
  98. occurred on the corresponding kernel object.
  99. If your new xyzzy(2) system call involves a filename argument:
  100. int sys_xyzzy(const char __user *path, ..., unsigned int flags);
  101. you should also consider whether an xyzzyat(2) version is more appropriate:
  102. int sys_xyzzyat(int dfd, const char __user *path, ..., unsigned int flags);
  103. This allows more flexibility for how userspace specifies the file in question;
  104. in particular it allows userspace to request the functionality for an
  105. already-opened file descriptor using the AT_EMPTY_PATH flag, effectively giving
  106. an fxyzzy(3) operation for free:
  107. - xyzzyat(AT_FDCWD, path, ..., 0) is equivalent to xyzzy(path,...)
  108. - xyzzyat(fd, "", ..., AT_EMPTY_PATH) is equivalent to fxyzzy(fd, ...)
  109. (For more details on the rationale of the *at() calls, see the openat(2) man
  110. page; for an example of AT_EMPTY_PATH, see the statat(2) man page.)
  111. If your new xyzzy(2) system call involves a parameter describing an offset
  112. within a file, make its type loff_t so that 64-bit offsets can be supported
  113. even on 32-bit architectures.
  114. If your new xyzzy(2) system call involves privileged functionality, it needs
  115. to be governed by the appropriate Linux capability bit (checked with a call to
  116. capable()), as described in the capabilities(7) man page. Choose an existing
  117. capability bit that governs related functionality, but try to avoid combining
  118. lots of only vaguely related functions together under the same bit, as this
  119. goes against capabilities' purpose of splitting the power of root. In
  120. particular, avoid adding new uses of the already overly-general CAP_SYS_ADMIN
  121. capability.
  122. If your new xyzzy(2) system call manipulates a process other than the calling
  123. process, it should be restricted (using a call to ptrace_may_access()) so that
  124. only a calling process with the same permissions as the target process, or
  125. with the necessary capabilities, can manipulate the target process.
  126. Finally, be aware that some non-x86 architectures have an easier time if
  127. system call parameters that are explicitly 64-bit fall on odd-numbered
  128. arguments (i.e. parameter 1, 3, 5), to allow use of contiguous pairs of 32-bit
  129. registers. (This concern does not apply if the arguments are part of a
  130. structure that's passed in by pointer.)
  131. Proposing the API
  132. -----------------
  133. To make new system calls easy to review, it's best to divide up the patchset
  134. into separate chunks. These should include at least the following items as
  135. distinct commits (each of which is described further below):
  136. - The core implementation of the system call, together with prototypes,
  137. generic numbering, Kconfig changes and fallback stub implementation.
  138. - Wiring up of the new system call for one particular architecture, usually
  139. x86 (including all of x86_64, x86_32 and x32).
  140. - A demonstration of the use of the new system call in userspace via a
  141. selftest in tools/testing/selftests/.
  142. - A draft man-page for the new system call, either as plain text in the
  143. cover letter, or as a patch to the (separate) man-pages repository.
  144. New system call proposals, like any change to the kernel's API, should always
  145. be cc'ed to linux-api@vger.kernel.org.
  146. Generic System Call Implementation
  147. ----------------------------------
  148. The main entry point for your new xyzzy(2) system call will be called
  149. sys_xyzzy(), but you add this entry point with the appropriate
  150. SYSCALL_DEFINEn() macro rather than explicitly. The 'n' indicates the number
  151. of arguments to the system call, and the macro takes the system call name
  152. followed by the (type, name) pairs for the parameters as arguments. Using
  153. this macro allows metadata about the new system call to be made available for
  154. other tools.
  155. The new entry point also needs a corresponding function prototype, in
  156. include/linux/syscalls.h, marked as asmlinkage to match the way that system
  157. calls are invoked:
  158. asmlinkage long sys_xyzzy(...);
  159. Some architectures (e.g. x86) have their own architecture-specific syscall
  160. tables, but several other architectures share a generic syscall table. Add your
  161. new system call to the generic list by adding an entry to the list in
  162. include/uapi/asm-generic/unistd.h:
  163. #define __NR_xyzzy 292
  164. __SYSCALL(__NR_xyzzy, sys_xyzzy)
  165. Also update the __NR_syscalls count to reflect the additional system call, and
  166. note that if multiple new system calls are added in the same merge window,
  167. your new syscall number may get adjusted to resolve conflicts.
  168. The file kernel/sys_ni.c provides a fallback stub implementation of each system
  169. call, returning -ENOSYS. Add your new system call here too:
  170. cond_syscall(sys_xyzzy);
  171. Your new kernel functionality, and the system call that controls it, should
  172. normally be optional, so add a CONFIG option (typically to init/Kconfig) for
  173. it. As usual for new CONFIG options:
  174. - Include a description of the new functionality and system call controlled
  175. by the option.
  176. - Make the option depend on EXPERT if it should be hidden from normal users.
  177. - Make any new source files implementing the function dependent on the CONFIG
  178. option in the Makefile (e.g. "obj-$(CONFIG_XYZZY_SYSCALL) += xyzzy.c").
  179. - Double check that the kernel still builds with the new CONFIG option turned
  180. off.
  181. To summarize, you need a commit that includes:
  182. - CONFIG option for the new function, normally in init/Kconfig
  183. - SYSCALL_DEFINEn(xyzzy, ...) for the entry point
  184. - corresponding prototype in include/linux/syscalls.h
  185. - generic table entry in include/uapi/asm-generic/unistd.h
  186. - fallback stub in kernel/sys_ni.c
  187. x86 System Call Implementation
  188. ------------------------------
  189. To wire up your new system call for x86 platforms, you need to update the
  190. master syscall tables. Assuming your new system call isn't special in some
  191. way (see below), this involves a "common" entry (for x86_64 and x32) in
  192. arch/x86/entry/syscalls/syscall_64.tbl:
  193. 333 common xyzzy sys_xyzzy
  194. and an "i386" entry in arch/x86/entry/syscalls/syscall_32.tbl:
  195. 380 i386 xyzzy sys_xyzzy
  196. Again, these numbers are liable to be changed if there are conflicts in the
  197. relevant merge window.
  198. Compatibility System Calls (Generic)
  199. ------------------------------------
  200. For most system calls the same 64-bit implementation can be invoked even when
  201. the userspace program is itself 32-bit; even if the system call's parameters
  202. include an explicit pointer, this is handled transparently.
  203. However, there are a couple of situations where a compatibility layer is
  204. needed to cope with size differences between 32-bit and 64-bit.
  205. The first is if the 64-bit kernel also supports 32-bit userspace programs, and
  206. so needs to parse areas of (__user) memory that could hold either 32-bit or
  207. 64-bit values. In particular, this is needed whenever a system call argument
  208. is:
  209. - a pointer to a pointer
  210. - a pointer to a struct containing a pointer (e.g. struct iovec __user *)
  211. - a pointer to a varying sized integral type (time_t, off_t, long, ...)
  212. - a pointer to a struct containing a varying sized integral type.
  213. The second situation that requires a compatibility layer is if one of the
  214. system call's arguments has a type that is explicitly 64-bit even on a 32-bit
  215. architecture, for example loff_t or __u64. In this case, a value that arrives
  216. at a 64-bit kernel from a 32-bit application will be split into two 32-bit
  217. values, which then need to be re-assembled in the compatibility layer.
  218. (Note that a system call argument that's a pointer to an explicit 64-bit type
  219. does *not* need a compatibility layer; for example, splice(2)'s arguments of
  220. type loff_t __user * do not trigger the need for a compat_ system call.)
  221. The compatibility version of the system call is called compat_sys_xyzzy(), and
  222. is added with the COMPAT_SYSCALL_DEFINEn() macro, analogously to
  223. SYSCALL_DEFINEn. This version of the implementation runs as part of a 64-bit
  224. kernel, but expects to receive 32-bit parameter values and does whatever is
  225. needed to deal with them. (Typically, the compat_sys_ version converts the
  226. values to 64-bit versions and either calls on to the sys_ version, or both of
  227. them call a common inner implementation function.)
  228. The compat entry point also needs a corresponding function prototype, in
  229. include/linux/compat.h, marked as asmlinkage to match the way that system
  230. calls are invoked:
  231. asmlinkage long compat_sys_xyzzy(...);
  232. If the system call involves a structure that is laid out differently on 32-bit
  233. and 64-bit systems, say struct xyzzy_args, then the include/linux/compat.h
  234. header file should also include a compat version of the structure (struct
  235. compat_xyzzy_args) where each variable-size field has the appropriate compat_
  236. type that corresponds to the type in struct xyzzy_args. The
  237. compat_sys_xyzzy() routine can then use this compat_ structure to parse the
  238. arguments from a 32-bit invocation.
  239. For example, if there are fields:
  240. struct xyzzy_args {
  241. const char __user *ptr;
  242. __kernel_long_t varying_val;
  243. u64 fixed_val;
  244. /* ... */
  245. };
  246. in struct xyzzy_args, then struct compat_xyzzy_args would have:
  247. struct compat_xyzzy_args {
  248. compat_uptr_t ptr;
  249. compat_long_t varying_val;
  250. u64 fixed_val;
  251. /* ... */
  252. };
  253. The generic system call list also needs adjusting to allow for the compat
  254. version; the entry in include/uapi/asm-generic/unistd.h should use
  255. __SC_COMP rather than __SYSCALL:
  256. #define __NR_xyzzy 292
  257. __SC_COMP(__NR_xyzzy, sys_xyzzy, compat_sys_xyzzy)
  258. To summarize, you need:
  259. - a COMPAT_SYSCALL_DEFINEn(xyzzy, ...) for the compat entry point
  260. - corresponding prototype in include/linux/compat.h
  261. - (if needed) 32-bit mapping struct in include/linux/compat.h
  262. - instance of __SC_COMP not __SYSCALL in include/uapi/asm-generic/unistd.h
  263. Compatibility System Calls (x86)
  264. --------------------------------
  265. To wire up the x86 architecture of a system call with a compatibility version,
  266. the entries in the syscall tables need to be adjusted.
  267. First, the entry in arch/x86/entry/syscalls/syscall_32.tbl gets an extra
  268. column to indicate that a 32-bit userspace program running on a 64-bit kernel
  269. should hit the compat entry point:
  270. 380 i386 xyzzy sys_xyzzy compat_sys_xyzzy
  271. Second, you need to figure out what should happen for the x32 ABI version of
  272. the new system call. There's a choice here: the layout of the arguments
  273. should either match the 64-bit version or the 32-bit version.
  274. If there's a pointer-to-a-pointer involved, the decision is easy: x32 is
  275. ILP32, so the layout should match the 32-bit version, and the entry in
  276. arch/x86/entry/syscalls/syscall_64.tbl is split so that x32 programs hit the
  277. compatibility wrapper:
  278. 333 64 xyzzy sys_xyzzy
  279. ...
  280. 555 x32 xyzzy compat_sys_xyzzy
  281. If no pointers are involved, then it is preferable to re-use the 64-bit system
  282. call for the x32 ABI (and consequently the entry in
  283. arch/x86/entry/syscalls/syscall_64.tbl is unchanged).
  284. In either case, you should check that the types involved in your argument
  285. layout do indeed map exactly from x32 (-mx32) to either the 32-bit (-m32) or
  286. 64-bit (-m64) equivalents.
  287. System Calls Returning Elsewhere
  288. --------------------------------
  289. For most system calls, once the system call is complete the user program
  290. continues exactly where it left off -- at the next instruction, with the
  291. stack the same and most of the registers the same as before the system call,
  292. and with the same virtual memory space.
  293. However, a few system calls do things differently. They might return to a
  294. different location (rt_sigreturn) or change the memory space (fork/vfork/clone)
  295. or even architecture (execve/execveat) of the program.
  296. To allow for this, the kernel implementation of the system call may need to
  297. save and restore additional registers to the kernel stack, allowing complete
  298. control of where and how execution continues after the system call.
  299. This is arch-specific, but typically involves defining assembly entry points
  300. that save/restore additional registers and invoke the real system call entry
  301. point.
  302. For x86_64, this is implemented as a stub_xyzzy entry point in
  303. arch/x86/entry/entry_64.S, and the entry in the syscall table
  304. (arch/x86/entry/syscalls/syscall_64.tbl) is adjusted to match:
  305. 333 common xyzzy stub_xyzzy
  306. The equivalent for 32-bit programs running on a 64-bit kernel is normally
  307. called stub32_xyzzy and implemented in arch/x86/entry/entry_64_compat.S,
  308. with the corresponding syscall table adjustment in
  309. arch/x86/entry/syscalls/syscall_32.tbl:
  310. 380 i386 xyzzy sys_xyzzy stub32_xyzzy
  311. If the system call needs a compatibility layer (as in the previous section)
  312. then the stub32_ version needs to call on to the compat_sys_ version of the
  313. system call rather than the native 64-bit version. Also, if the x32 ABI
  314. implementation is not common with the x86_64 version, then its syscall
  315. table will also need to invoke a stub that calls on to the compat_sys_
  316. version.
  317. For completeness, it's also nice to set up a mapping so that user-mode Linux
  318. still works -- its syscall table will reference stub_xyzzy, but the UML build
  319. doesn't include arch/x86/entry/entry_64.S implementation (because UML
  320. simulates registers etc). Fixing this is as simple as adding a #define to
  321. arch/x86/um/sys_call_table_64.c:
  322. #define stub_xyzzy sys_xyzzy
  323. Other Details
  324. -------------
  325. Most of the kernel treats system calls in a generic way, but there is the
  326. occasional exception that may need updating for your particular system call.
  327. The audit subsystem is one such special case; it includes (arch-specific)
  328. functions that classify some special types of system call -- specifically
  329. file open (open/openat), program execution (execve/exeveat) or socket
  330. multiplexor (socketcall) operations. If your new system call is analogous to
  331. one of these, then the audit system should be updated.
  332. More generally, if there is an existing system call that is analogous to your
  333. new system call, it's worth doing a kernel-wide grep for the existing system
  334. call to check there are no other special cases.
  335. Testing
  336. -------
  337. A new system call should obviously be tested; it is also useful to provide
  338. reviewers with a demonstration of how user space programs will use the system
  339. call. A good way to combine these aims is to include a simple self-test
  340. program in a new directory under tools/testing/selftests/.
  341. For a new system call, there will obviously be no libc wrapper function and so
  342. the test will need to invoke it using syscall(); also, if the system call
  343. involves a new userspace-visible structure, the corresponding header will need
  344. to be installed to compile the test.
  345. Make sure the selftest runs successfully on all supported architectures. For
  346. example, check that it works when compiled as an x86_64 (-m64), x86_32 (-m32)
  347. and x32 (-mx32) ABI program.
  348. For more extensive and thorough testing of new functionality, you should also
  349. consider adding tests to the Linux Test Project, or to the xfstests project
  350. for filesystem-related changes.
  351. - https://linux-test-project.github.io/
  352. - git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git
  353. Man Page
  354. --------
  355. All new system calls should come with a complete man page, ideally using groff
  356. markup, but plain text will do. If groff is used, it's helpful to include a
  357. pre-rendered ASCII version of the man page in the cover email for the
  358. patchset, for the convenience of reviewers.
  359. The man page should be cc'ed to linux-man@vger.kernel.org
  360. For more details, see https://www.kernel.org/doc/man-pages/patches.html
  361. References and Sources
  362. ----------------------
  363. - LWN article from Michael Kerrisk on use of flags argument in system calls:
  364. https://lwn.net/Articles/585415/
  365. - LWN article from Michael Kerrisk on how to handle unknown flags in a system
  366. call: https://lwn.net/Articles/588444/
  367. - LWN article from Jake Edge describing constraints on 64-bit system call
  368. arguments: https://lwn.net/Articles/311630/
  369. - Pair of LWN articles from David Drysdale that describe the system call
  370. implementation paths in detail for v3.14:
  371. - https://lwn.net/Articles/604287/
  372. - https://lwn.net/Articles/604515/
  373. - Architecture-specific requirements for system calls are discussed in the
  374. syscall(2) man-page:
  375. http://man7.org/linux/man-pages/man2/syscall.2.html#NOTES
  376. - Collated emails from Linus Torvalds discussing the problems with ioctl():
  377. http://yarchive.net/comp/linux/ioctl.html
  378. - "How to not invent kernel interfaces", Arnd Bergmann,
  379. http://www.ukuug.org/events/linux2007/2007/papers/Bergmann.pdf
  380. - LWN article from Michael Kerrisk on avoiding new uses of CAP_SYS_ADMIN:
  381. https://lwn.net/Articles/486306/
  382. - Recommendation from Andrew Morton that all related information for a new
  383. system call should come in the same email thread:
  384. https://lkml.org/lkml/2014/7/24/641
  385. - Recommendation from Michael Kerrisk that a new system call should come with
  386. a man page: https://lkml.org/lkml/2014/6/13/309
  387. - Suggestion from Thomas Gleixner that x86 wire-up should be in a separate
  388. commit: https://lkml.org/lkml/2014/11/19/254
  389. - Suggestion from Greg Kroah-Hartman that it's good for new system calls to
  390. come with a man-page & selftest: https://lkml.org/lkml/2014/3/19/710
  391. - Discussion from Michael Kerrisk of new system call vs. prctl(2) extension:
  392. https://lkml.org/lkml/2014/6/3/411
  393. - Suggestion from Ingo Molnar that system calls that involve multiple
  394. arguments should encapsulate those arguments in a struct, which includes a
  395. size field for future extensibility: https://lkml.org/lkml/2015/7/30/117
  396. - Numbering oddities arising from (re-)use of O_* numbering space flags:
  397. - commit 75069f2b5bfb ("vfs: renumber FMODE_NONOTIFY and add to uniqueness
  398. check")
  399. - commit 12ed2e36c98a ("fanotify: FMODE_NONOTIFY and __O_SYNC in sparc
  400. conflict")
  401. - commit bb458c644a59 ("Safer ABI for O_TMPFILE")
  402. - Discussion from Matthew Wilcox about restrictions on 64-bit arguments:
  403. https://lkml.org/lkml/2008/12/12/187
  404. - Recommendation from Greg Kroah-Hartman that unknown flags should be
  405. policed: https://lkml.org/lkml/2014/7/17/577
  406. - Recommendation from Linus Torvalds that x32 system calls should prefer
  407. compatibility with 64-bit versions rather than 32-bit versions:
  408. https://lkml.org/lkml/2011/8/31/244