aboutsummaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/io_uring/mini_liburing.h59
-rw-r--r--tools/include/linux/args.h4
-rw-r--r--tools/include/linux/bitfield.h1
-rw-r--r--tools/include/linux/bitmap.h46
-rw-r--r--tools/include/linux/build_bug.h4
-rw-r--r--tools/include/linux/compiler-context-analysis.h42
-rw-r--r--tools/include/linux/compiler_types.h40
-rw-r--r--tools/include/linux/coresight-pmu.h24
-rw-r--r--tools/include/linux/gfp.h4
-rw-r--r--tools/include/linux/gfp_types.h9
-rw-r--r--tools/include/linux/list.h10
-rw-r--r--tools/include/linux/mm.h4
-rw-r--r--tools/include/linux/overflow.h19
-rw-r--r--tools/include/linux/slab.h9
-rw-r--r--tools/include/linux/unaligned.h4
-rw-r--r--tools/include/nolibc/Makefile20
-rw-r--r--tools/include/nolibc/arch-arm.h14
-rw-r--r--tools/include/nolibc/arch-arm64.h14
-rw-r--r--tools/include/nolibc/arch-loongarch.h14
-rw-r--r--tools/include/nolibc/arch-m68k.h14
-rw-r--r--tools/include/nolibc/arch-mips.h33
-rw-r--r--tools/include/nolibc/arch-powerpc.h14
-rw-r--r--tools/include/nolibc/arch-riscv.h14
-rw-r--r--tools/include/nolibc/arch-s390.h39
-rw-r--r--tools/include/nolibc/arch-sh.h14
-rw-r--r--tools/include/nolibc/arch-sparc.h26
-rw-r--r--tools/include/nolibc/arch-x86.h68
-rw-r--r--tools/include/nolibc/byteswap.h21
-rw-r--r--tools/include/nolibc/compiler.h43
-rw-r--r--tools/include/nolibc/crt.h31
-rw-r--r--tools/include/nolibc/dirent.h4
-rw-r--r--tools/include/nolibc/endian.h32
-rw-r--r--tools/include/nolibc/err.h87
-rw-r--r--tools/include/nolibc/errno.h4
-rw-r--r--tools/include/nolibc/fcntl.h12
-rw-r--r--tools/include/nolibc/nolibc.h14
-rw-r--r--tools/include/nolibc/poll.h18
-rw-r--r--tools/include/nolibc/sched.h12
-rw-r--r--tools/include/nolibc/signal.h2
-rw-r--r--tools/include/nolibc/stackprotector.h8
-rw-r--r--tools/include/nolibc/std.h4
-rw-r--r--tools/include/nolibc/stddef.h2
-rw-r--r--tools/include/nolibc/stdio.h618
-rw-r--r--tools/include/nolibc/stdlib.h175
-rw-r--r--tools/include/nolibc/sys.h302
-rw-r--r--tools/include/nolibc/sys/ioctl.h6
-rw-r--r--tools/include/nolibc/sys/mman.h24
-rw-r--r--tools/include/nolibc/sys/mount.h8
-rw-r--r--tools/include/nolibc/sys/prctl.h8
-rw-r--r--tools/include/nolibc/sys/ptrace.h33
-rw-r--r--tools/include/nolibc/sys/random.h6
-rw-r--r--tools/include/nolibc/sys/reboot.h6
-rw-r--r--tools/include/nolibc/sys/resource.h10
-rw-r--r--tools/include/nolibc/sys/select.h31
-rw-r--r--tools/include/nolibc/sys/stat.h17
-rw-r--r--tools/include/nolibc/sys/syscall.h11
-rw-r--r--tools/include/nolibc/sys/sysmacros.h25
-rw-r--r--tools/include/nolibc/sys/time.h14
-rw-r--r--tools/include/nolibc/sys/timerfd.h48
-rw-r--r--tools/include/nolibc/sys/uio.h12
-rw-r--r--tools/include/nolibc/sys/utsname.h6
-rw-r--r--tools/include/nolibc/sys/wait.h6
-rw-r--r--tools/include/nolibc/time.h146
-rw-r--r--tools/include/nolibc/types.h17
-rw-r--r--tools/include/nolibc/unistd.h12
-rw-r--r--tools/include/uapi/asm-generic/errno.h2
-rw-r--r--tools/include/uapi/asm-generic/unistd.h5
-rw-r--r--tools/include/uapi/drm/drm.h1491
-rw-r--r--tools/include/uapi/drm/i915_drm.h3916
-rw-r--r--tools/include/uapi/linux/bpf.h32
-rw-r--r--tools/include/uapi/linux/btf.h12
-rw-r--r--tools/include/uapi/linux/fadvise.h22
-rw-r--r--tools/include/uapi/linux/kvm.h34
-rw-r--r--tools/include/uapi/linux/module_signature.h41
-rw-r--r--tools/include/uapi/linux/mount.h14
-rw-r--r--tools/include/uapi/linux/netdev.h11
-rw-r--r--tools/include/uapi/linux/perf_event.h27
-rw-r--r--tools/include/uapi/linux/taskstats.h291
-rw-r--r--tools/include/vdso/unaligned.h41
79 files changed, 2061 insertions, 6276 deletions
diff --git a/tools/include/io_uring/mini_liburing.h b/tools/include/io_uring/mini_liburing.h
index 9ccb16074eb5..44be4446feda 100644
--- a/tools/include/io_uring/mini_liburing.h
+++ b/tools/include/io_uring/mini_liburing.h
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <sys/uio.h>
struct io_sq_ring {
unsigned int *head;
@@ -55,6 +56,7 @@ struct io_uring {
struct io_uring_sq sq;
struct io_uring_cq cq;
int ring_fd;
+ unsigned flags;
};
#if defined(__x86_64) || defined(__i386__)
@@ -72,7 +74,14 @@ static inline int io_uring_mmap(int fd, struct io_uring_params *p,
void *ptr;
int ret;
- sq->ring_sz = p->sq_off.array + p->sq_entries * sizeof(unsigned int);
+ if (p->flags & IORING_SETUP_NO_SQARRAY) {
+ sq->ring_sz = p->cq_off.cqes;
+ sq->ring_sz += p->cq_entries * sizeof(struct io_uring_cqe);
+ } else {
+ sq->ring_sz = p->sq_off.array;
+ sq->ring_sz += p->sq_entries * sizeof(unsigned int);
+ }
+
ptr = mmap(0, sq->ring_sz, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE, fd, IORING_OFF_SQ_RING);
if (ptr == MAP_FAILED)
@@ -83,7 +92,8 @@ static inline int io_uring_mmap(int fd, struct io_uring_params *p,
sq->kring_entries = ptr + p->sq_off.ring_entries;
sq->kflags = ptr + p->sq_off.flags;
sq->kdropped = ptr + p->sq_off.dropped;
- sq->array = ptr + p->sq_off.array;
+ if (!(p->flags & IORING_SETUP_NO_SQARRAY))
+ sq->array = ptr + p->sq_off.array;
size = p->sq_entries * sizeof(struct io_uring_sqe);
sq->sqes = mmap(0, size, PROT_READ | PROT_WRITE,
@@ -126,28 +136,39 @@ static inline int io_uring_enter(int fd, unsigned int to_submit,
flags, sig, _NSIG / 8);
}
-static inline int io_uring_queue_init(unsigned int entries,
- struct io_uring *ring,
- unsigned int flags)
+static inline int io_uring_queue_init_params(unsigned int entries,
+ struct io_uring *ring,
+ struct io_uring_params *p)
{
- struct io_uring_params p;
int fd, ret;
memset(ring, 0, sizeof(*ring));
- memset(&p, 0, sizeof(p));
- p.flags = flags;
- fd = io_uring_setup(entries, &p);
+ fd = io_uring_setup(entries, p);
if (fd < 0)
return fd;
- ret = io_uring_mmap(fd, &p, &ring->sq, &ring->cq);
- if (!ret)
+ ret = io_uring_mmap(fd, p, &ring->sq, &ring->cq);
+ if (!ret) {
ring->ring_fd = fd;
- else
+ ring->flags = p->flags;
+ } else {
close(fd);
+ }
return ret;
}
+static inline int io_uring_queue_init(unsigned int entries,
+ struct io_uring *ring,
+ unsigned int flags)
+{
+ struct io_uring_params p;
+
+ memset(&p, 0, sizeof(p));
+ p.flags = flags;
+
+ return io_uring_queue_init_params(entries, ring, &p);
+}
+
/* Get a sqe */
static inline struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring)
{
@@ -199,10 +220,18 @@ static inline int io_uring_submit(struct io_uring *ring)
ktail = *sq->ktail;
to_submit = sq->sqe_tail - sq->sqe_head;
- for (submitted = 0; submitted < to_submit; submitted++) {
- read_barrier();
- sq->array[ktail++ & mask] = sq->sqe_head++ & mask;
+
+ if (!(ring->flags & IORING_SETUP_NO_SQARRAY)) {
+ for (submitted = 0; submitted < to_submit; submitted++) {
+ read_barrier();
+ sq->array[ktail++ & mask] = sq->sqe_head++ & mask;
+ }
+ } else {
+ ktail += to_submit;
+ sq->sqe_head += to_submit;
+ submitted = to_submit;
}
+
if (!submitted)
return 0;
diff --git a/tools/include/linux/args.h b/tools/include/linux/args.h
index 2e8e65d975c7..14b268f2389a 100644
--- a/tools/include/linux/args.h
+++ b/tools/include/linux/args.h
@@ -22,7 +22,11 @@
#define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
/* Concatenate two parameters, but allow them to be expanded beforehand. */
+#ifndef __CONCAT
#define __CONCAT(a, b) a ## b
+#endif
+#ifndef CONCATENATE
#define CONCATENATE(a, b) __CONCAT(a, b)
+#endif
#endif /* _LINUX_ARGS_H */
diff --git a/tools/include/linux/bitfield.h b/tools/include/linux/bitfield.h
index 6093fa6db260..ddf81f24956b 100644
--- a/tools/include/linux/bitfield.h
+++ b/tools/include/linux/bitfield.h
@@ -8,6 +8,7 @@
#define _LINUX_BITFIELD_H
#include <linux/build_bug.h>
+#include <linux/kernel.h>
#include <asm/byteorder.h>
/*
diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h
index 0d992245c600..5cb4f3942fd3 100644
--- a/tools/include/linux/bitmap.h
+++ b/tools/include/linux/bitmap.h
@@ -24,6 +24,12 @@ void __bitmap_set(unsigned long *map, unsigned int start, int len);
void __bitmap_clear(unsigned long *map, unsigned int start, int len);
bool __bitmap_intersects(const unsigned long *bitmap1,
const unsigned long *bitmap2, unsigned int bits);
+bool __bitmap_subset(const unsigned long *bitmap1,
+ const unsigned long *bitmap2, unsigned int nbits);
+bool __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
+ const unsigned long *bitmap2, unsigned int nbits);
+void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
+ const unsigned long *bitmap2, unsigned int nbits);
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
@@ -49,6 +55,17 @@ static inline void bitmap_fill(unsigned long *dst, unsigned int nbits)
dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits);
}
+static __always_inline
+void bitmap_copy(unsigned long *dst, const unsigned long *src, unsigned int nbits)
+{
+ unsigned int len = bitmap_size(nbits);
+
+ if (small_const_nbits(nbits))
+ *dst = *src;
+ else
+ memcpy(dst, src, len);
+}
+
static inline bool bitmap_empty(const unsigned long *src, unsigned int nbits)
{
if (small_const_nbits(nbits))
@@ -81,6 +98,15 @@ static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
__bitmap_or(dst, src1, src2, nbits);
}
+static __always_inline
+bool bitmap_andnot(unsigned long *dst, const unsigned long *src1,
+ const unsigned long *src2, unsigned int nbits)
+{
+ if (small_const_nbits(nbits))
+ return (*dst = *src1 & ~(*src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0;
+ return __bitmap_andnot(dst, src1, src2, nbits);
+}
+
static inline unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags __maybe_unused)
{
return malloc(bitmap_size(nbits));
@@ -157,6 +183,15 @@ static inline bool bitmap_intersects(const unsigned long *src1,
return __bitmap_intersects(src1, src2, nbits);
}
+static __always_inline
+bool bitmap_subset(const unsigned long *src1, const unsigned long *src2, unsigned int nbits)
+{
+ if (small_const_nbits(nbits))
+ return ! ((*src1 & ~(*src2)) & BITMAP_LAST_WORD_MASK(nbits));
+ else
+ return __bitmap_subset(src1, src2, nbits);
+}
+
static inline void bitmap_set(unsigned long *map, unsigned int start, unsigned int nbits)
{
if (__builtin_constant_p(nbits) && nbits == 1)
@@ -187,4 +222,15 @@ static inline void bitmap_clear(unsigned long *map, unsigned int start,
else
__bitmap_clear(map, start, nbits);
}
+
+static __always_inline
+void bitmap_xor(unsigned long *dst, const unsigned long *src1,
+ const unsigned long *src2, unsigned int nbits)
+{
+ if (small_const_nbits(nbits))
+ *dst = *src1 ^ *src2;
+ else
+ __bitmap_xor(dst, src1, src2, nbits);
+}
+
#endif /* _TOOLS_LINUX_BITMAP_H */
diff --git a/tools/include/linux/build_bug.h b/tools/include/linux/build_bug.h
index ab2aa97bd8ce..406923bd4846 100644
--- a/tools/include/linux/build_bug.h
+++ b/tools/include/linux/build_bug.h
@@ -32,7 +32,8 @@
/**
* BUILD_BUG_ON_MSG - break compile if a condition is true & emit supplied
* error message.
- * @condition: the condition which the compiler should know is false.
+ * @cond: the condition which the compiler should know is false.
+ * @msg: build-time error message
*
* See BUILD_BUG_ON for description.
*/
@@ -60,6 +61,7 @@
/**
* static_assert - check integer constant expression at build time
+ * @expr: expression to be checked
*
* static_assert() is a wrapper for the C11 _Static_assert, with a
* little macro magic to make the message optional (defaulting to the
diff --git a/tools/include/linux/compiler-context-analysis.h b/tools/include/linux/compiler-context-analysis.h
new file mode 100644
index 000000000000..13a9115e9e58
--- /dev/null
+++ b/tools/include/linux/compiler-context-analysis.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TOOLS_LINUX_COMPILER_CONTEXT_ANALYSIS_H
+#define _TOOLS_LINUX_COMPILER_CONTEXT_ANALYSIS_H
+
+/*
+ * Macros and attributes for compiler-based static context analysis.
+ * No-op stubs for tools.
+ */
+
+#define __guarded_by(...)
+#define __pt_guarded_by(...)
+
+#define context_lock_struct(name, ...) struct __VA_ARGS__ name
+
+#define __no_context_analysis
+#define __context_unsafe(comment)
+#define context_unsafe(...) ({ __VA_ARGS__; })
+#define context_unsafe_alias(p)
+#define disable_context_analysis()
+#define enable_context_analysis()
+
+#define __must_hold(...)
+#define __must_not_hold(...)
+#define __acquires(...)
+#define __cond_acquires(ret, x)
+#define __releases(...)
+#define __acquire(x) (void)0
+#define __release(x) (void)0
+
+#define __must_hold_shared(...)
+#define __acquires_shared(...)
+#define __cond_acquires_shared(ret, x)
+#define __releases_shared(...)
+#define __acquire_shared(x) (void)0
+#define __release_shared(x) (void)0
+
+#define __acquire_ret(call, expr) (call)
+#define __acquire_shared_ret(call, expr) (call)
+#define __acquires_ret
+#define __acquires_shared_ret
+
+#endif /* _TOOLS_LINUX_COMPILER_CONTEXT_ANALYSIS_H */
diff --git a/tools/include/linux/compiler_types.h b/tools/include/linux/compiler_types.h
index d09f9dc172a4..b3adbf5682f0 100644
--- a/tools/include/linux/compiler_types.h
+++ b/tools/include/linux/compiler_types.h
@@ -13,23 +13,7 @@
#define __has_builtin(x) (0)
#endif
-#ifdef __CHECKER__
-/* context/locking */
-# define __must_hold(x) __attribute__((context(x,1,1)))
-# define __acquires(x) __attribute__((context(x,0,1)))
-# define __releases(x) __attribute__((context(x,1,0)))
-# define __acquire(x) __context__(x,1)
-# define __release(x) __context__(x,-1)
-# define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
-#else /* __CHECKER__ */
-/* context/locking */
-# define __must_hold(x)
-# define __acquires(x)
-# define __releases(x)
-# define __acquire(x) (void)0
-# define __release(x) (void)0
-# define __cond_lock(x,c) (c)
-#endif /* __CHECKER__ */
+#include <linux/compiler-context-analysis.h>
/* Compiler specific macros. */
#ifdef __GNUC__
@@ -40,4 +24,26 @@
#define asm_goto_output(x...) asm goto(x)
#endif
+/*
+ * __unqual_scalar_typeof(x) - Declare an unqualified scalar type, leaving
+ * non-scalar types unchanged.
+ */
+/*
+ * Prefer C11 _Generic for better compile-times and simpler code. Note: 'char'
+ * is not type-compatible with 'signed char', and we define a separate case.
+ */
+#define __scalar_type_to_expr_cases(type) \
+ unsigned type: (unsigned type)0, \
+ signed type: (signed type)0
+
+#define __unqual_scalar_typeof(x) typeof( \
+ _Generic((x), \
+ char: (char)0, \
+ __scalar_type_to_expr_cases(char), \
+ __scalar_type_to_expr_cases(short), \
+ __scalar_type_to_expr_cases(int), \
+ __scalar_type_to_expr_cases(long), \
+ __scalar_type_to_expr_cases(long long), \
+ default: (x)))
+
#endif /* __LINUX_COMPILER_TYPES_H */
diff --git a/tools/include/linux/coresight-pmu.h b/tools/include/linux/coresight-pmu.h
index 89b0ac0014b0..2e179abe472a 100644
--- a/tools/include/linux/coresight-pmu.h
+++ b/tools/include/linux/coresight-pmu.h
@@ -22,30 +22,6 @@
#define CORESIGHT_LEGACY_CPU_TRACE_ID(cpu) (0x10 + (cpu * 2))
/*
- * Below are the definition of bit offsets for perf option, and works as
- * arbitrary values for all ETM versions.
- *
- * Most of them are orignally from ETMv3.5/PTM's ETMCR config, therefore,
- * ETMv3.5/PTM doesn't define ETMCR config bits with prefix "ETM3_" and
- * directly use below macros as config bits.
- */
-#define ETM_OPT_BRANCH_BROADCAST 8
-#define ETM_OPT_CYCACC 12
-#define ETM_OPT_CTXTID 14
-#define ETM_OPT_CTXTID2 15
-#define ETM_OPT_TS 28
-#define ETM_OPT_RETSTK 29
-
-/* ETMv4 CONFIGR programming bits for the ETM OPTs */
-#define ETM4_CFG_BIT_BB 3
-#define ETM4_CFG_BIT_CYCACC 4
-#define ETM4_CFG_BIT_CTXTID 6
-#define ETM4_CFG_BIT_VMID 7
-#define ETM4_CFG_BIT_TS 11
-#define ETM4_CFG_BIT_RETSTK 12
-#define ETM4_CFG_BIT_VMID_OPT 15
-
-/*
* Interpretation of the PERF_RECORD_AUX_OUTPUT_HW_ID payload.
* Used to associate a CPU with the CoreSight Trace ID.
* [07:00] - Trace ID - uses 8 bits to make value easy to read in file.
diff --git a/tools/include/linux/gfp.h b/tools/include/linux/gfp.h
index 6a10ff5f5be9..9e957b57b694 100644
--- a/tools/include/linux/gfp.h
+++ b/tools/include/linux/gfp.h
@@ -5,6 +5,10 @@
#include <linux/types.h>
#include <linux/gfp_types.h>
+/* Helper macro to avoid gfp flags if they are the default one */
+#define __default_gfp(a,...) a
+#define default_gfp(...) __default_gfp(__VA_ARGS__ __VA_OPT__(,) GFP_KERNEL)
+
static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
{
return !!(gfp_flags & __GFP_DIRECT_RECLAIM);
diff --git a/tools/include/linux/gfp_types.h b/tools/include/linux/gfp_types.h
index 3de43b12209e..6c75df30a281 100644
--- a/tools/include/linux/gfp_types.h
+++ b/tools/include/linux/gfp_types.h
@@ -139,6 +139,8 @@ enum {
* %__GFP_ACCOUNT causes the allocation to be accounted to kmemcg.
*
* %__GFP_NO_OBJ_EXT causes slab allocation to have no object extension.
+ * mark_obj_codetag_empty() should be called upon freeing for objects allocated
+ * with this flag to indicate that their NULL tags are expected and normal.
*/
#define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE)
#define __GFP_WRITE ((__force gfp_t)___GFP_WRITE)
@@ -309,8 +311,10 @@ enum {
*
* %GFP_ATOMIC users can not sleep and need the allocation to succeed. A lower
* watermark is applied to allow access to "atomic reserves".
- * The current implementation doesn't support NMI and few other strict
- * non-preemptive contexts (e.g. raw_spin_lock). The same applies to %GFP_NOWAIT.
+ * The current implementation doesn't support NMI, nor contexts that disable
+ * preemption under PREEMPT_RT. This includes raw_spin_lock() and plain
+ * preempt_disable() - see "Memory allocation" in
+ * Documentation/core-api/real-time/differences.rst for more info.
*
* %GFP_KERNEL is typical for kernel-internal allocations. The caller requires
* %ZONE_NORMAL or a lower zone for direct access but can direct reclaim.
@@ -321,6 +325,7 @@ enum {
* %GFP_NOWAIT is for kernel allocations that should not stall for direct