summaryrefslogtreecommitdiff
path: root/bundled
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2021-02-19 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2021-02-19 08:00:00 +0000
commit1dd2472f89b5e18575003344914598735d1d56b8 (patch)
tree44a9b283e50558fa0904fb893b3c1177c570f1ef /bundled
parenta51323a5090cff0db729a62238bb6ee9bdf69e15 (diff)
downloadstrace-1dd2472f89b5e18575003344914598735d1d56b8.tar.gz
Switch to use bundled <linux/memfd.h> and <asm-generic/hugetlb_encode.h>
* bundled/linux/include/uapi/linux/memfd.h: New file, copied from headers_install'ed Linux kernel v5.11. * bundled/linux/include/uapi/asm-generic/hugetlb_encode.h: Likewise. * bundled/Makefile.am (EXTRA_DIST): Add them. * configure.ac (AC_CHECK_HEADERS): Remove linux/memfd.h. * src/memfd.c: Include <linux/memfd.h> unconditionally, assume it provides all necessary constants. * tests/memfd.c: Likewise. * src/xlat/memfd_create_flags.in: Add #unconditional, remove fallback definitions.
Diffstat (limited to 'bundled')
-rw-r--r--bundled/Makefile.am2
-rw-r--r--bundled/linux/include/uapi/asm-generic/hugetlb_encode.h37
-rw-r--r--bundled/linux/include/uapi/linux/memfd.h35
3 files changed, 74 insertions, 0 deletions
diff --git a/bundled/Makefile.am b/bundled/Makefile.am
index 48df683f1..f7259146d 100644
--- a/bundled/Makefile.am
+++ b/bundled/Makefile.am
@@ -19,6 +19,7 @@ EXTRA_DIST = \
linux/arch/powerpc/include/uapi/asm/fcntl.h \
linux/arch/sparc/include/uapi/asm/fcntl.h \
linux/include/uapi/asm-generic/fcntl.h \
+ linux/include/uapi/asm-generic/hugetlb_encode.h \
linux/include/uapi/linux/bsg.h \
linux/include/uapi/linux/btrfs.h \
linux/include/uapi/linux/btrfs_tree.h \
@@ -46,6 +47,7 @@ EXTRA_DIST = \
linux/include/uapi/linux/kcmp.h \
linux/include/uapi/linux/libc-compat.h \
linux/include/uapi/linux/loop.h \
+ linux/include/uapi/linux/memfd.h \
linux/include/uapi/linux/mmtimer.h \
linux/include/uapi/linux/mount.h \
linux/include/uapi/linux/neighbour.h \
diff --git a/bundled/linux/include/uapi/asm-generic/hugetlb_encode.h b/bundled/linux/include/uapi/asm-generic/hugetlb_encode.h
new file mode 100644
index 000000000..4f3d5aaa1
--- /dev/null
+++ b/bundled/linux/include/uapi/asm-generic/hugetlb_encode.h
@@ -0,0 +1,37 @@
+#ifndef _ASM_GENERIC_HUGETLB_ENCODE_H_
+#define _ASM_GENERIC_HUGETLB_ENCODE_H_
+
+/*
+ * Several system calls take a flag to request "hugetlb" huge pages.
+ * Without further specification, these system calls will use the
+ * system's default huge page size. If a system supports multiple
+ * huge page sizes, the desired huge page size can be specified in
+ * bits [26:31] of the flag arguments. The value in these 6 bits
+ * will encode the log2 of the huge page size.
+ *
+ * The following definitions are associated with this huge page size
+ * encoding in flag arguments. System call specific header files
+ * that use this encoding should include this file. They can then
+ * provide definitions based on these with their own specific prefix.
+ * for example:
+ * #define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT
+ */
+
+#define HUGETLB_FLAG_ENCODE_SHIFT 26
+#define HUGETLB_FLAG_ENCODE_MASK 0x3f
+
+#define HUGETLB_FLAG_ENCODE_16KB (14 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_64KB (16 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_512KB (19 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_1MB (20 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_8MB (23 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_16MB (24 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_32MB (25 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_256MB (28 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_512MB (29 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_1GB (30 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_2GB (31 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_16GB (34 << HUGETLB_FLAG_ENCODE_SHIFT)
+
+#endif /* _ASM_GENERIC_HUGETLB_ENCODE_H_ */
diff --git a/bundled/linux/include/uapi/linux/memfd.h b/bundled/linux/include/uapi/linux/memfd.h
new file mode 100644
index 000000000..39ed783fa
--- /dev/null
+++ b/bundled/linux/include/uapi/linux/memfd.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _LINUX_MEMFD_H
+#define _LINUX_MEMFD_H
+
+#include <asm-generic/hugetlb_encode.h>
+
+/* flags for memfd_create(2) (unsigned int) */
+#define MFD_CLOEXEC 0x0001U
+#define MFD_ALLOW_SEALING 0x0002U
+#define MFD_HUGETLB 0x0004U
+
+/*
+ * Huge page size encoding when MFD_HUGETLB is specified, and a huge page
+ * size other than the default is desired. See hugetlb_encode.h.
+ * All known huge page size encodings are provided here. It is the
+ * responsibility of the application to know which sizes are supported on
+ * the running system. See mmap(2) man page for details.
+ */
+#define MFD_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT
+#define MFD_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK
+
+#define MFD_HUGE_64KB HUGETLB_FLAG_ENCODE_64KB
+#define MFD_HUGE_512KB HUGETLB_FLAG_ENCODE_512KB
+#define MFD_HUGE_1MB HUGETLB_FLAG_ENCODE_1MB
+#define MFD_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB
+#define MFD_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB
+#define MFD_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB
+#define MFD_HUGE_32MB HUGETLB_FLAG_ENCODE_32MB
+#define MFD_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB
+#define MFD_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB
+#define MFD_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB
+#define MFD_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB
+#define MFD_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB
+
+#endif /* _LINUX_MEMFD_H */