aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-10-21 07:09:18 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-10-21 07:09:18 -0400
commita2ab5fc41533c952706ebdfaa378bb746e535cc1 (patch)
tree9fb86bb4e9ecb67f7e651d284c2f12c6c5d4378f /tools
parenta380f2edef65b2447a043251bb3c00a9d2153a8b (diff)
parent0e708fc602531b8355b5de6ea7c98f09129b223f (diff)
Merge branch 'pm-sleep' into pm-core
Diffstat (limited to 'tools')
-rw-r--r--tools/arch/s390/include/uapi/asm/kvm.h6
-rw-r--r--tools/arch/x86/include/asm/cpufeatures.h2
-rw-r--r--tools/arch/x86/include/asm/disabled-features.h4
-rw-r--r--tools/include/asm-generic/hugetlb_encode.h34
-rw-r--r--tools/include/uapi/asm-generic/mman-common.h14
-rw-r--r--tools/include/uapi/drm/drm.h22
-rw-r--r--tools/include/uapi/drm/i915_drm.h51
-rw-r--r--tools/include/uapi/linux/bpf.h32
-rw-r--r--tools/include/uapi/linux/kvm.h3
-rw-r--r--tools/include/uapi/linux/mman.h24
-rw-r--r--tools/objtool/arch/x86/decode.c11
-rw-r--r--tools/perf/MANIFEST87
-rw-r--r--tools/perf/arch/s390/util/Build1
-rw-r--r--tools/perf/arch/s390/util/sym-handling.c29
-rw-r--r--tools/perf/util/callchain.c35
-rw-r--r--tools/perf/util/evsel.c7
-rw-r--r--tools/perf/util/symbol-elf.c8
-rw-r--r--tools/perf/util/symbol.h3
-rw-r--r--tools/perf/util/syscalltbl.c2
-rw-r--r--tools/testing/selftests/Makefile18
-rw-r--r--tools/testing/selftests/bpf/bpf_util.h17
-rw-r--r--tools/testing/selftests/breakpoints/Makefile8
-rw-r--r--tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc2
-rw-r--r--tools/testing/selftests/futex/Makefile9
-rw-r--r--tools/testing/selftests/intel_pstate/Makefile2
-rwxr-xr-xtools/testing/selftests/intel_pstate/run.sh11
-rw-r--r--tools/testing/selftests/lib.mk48
-rwxr-xr-x[-rw-r--r--]tools/testing/selftests/memfd/run_tests.sh0
-rw-r--r--tools/testing/selftests/mqueue/Makefile4
-rw-r--r--tools/testing/selftests/net/.gitignore1
-rw-r--r--tools/testing/selftests/net/Makefile6
-rw-r--r--tools/testing/selftests/net/msg_zerocopy.c2
-rwxr-xr-xtools/testing/selftests/net/netdevice.sh2
-rw-r--r--tools/testing/selftests/net/reuseaddr_conflict.c114
-rw-r--r--tools/testing/selftests/seccomp/seccomp_bpf.c18
-rw-r--r--tools/testing/selftests/sigaltstack/sas.c4
-rw-r--r--tools/testing/selftests/sync/Makefile24
-rw-r--r--tools/testing/selftests/timers/set-timer-lat.c13
-rw-r--r--tools/testing/selftests/watchdog/Makefile7
39 files changed, 448 insertions, 237 deletions
diff --git a/tools/arch/s390/include/uapi/asm/kvm.h b/tools/arch/s390/include/uapi/asm/kvm.h
index 69d09c39bbcd..cd7359e23d86 100644
--- a/tools/arch/s390/include/uapi/asm/kvm.h
+++ b/tools/arch/s390/include/uapi/asm/kvm.h
@@ -88,6 +88,12 @@ struct kvm_s390_io_adapter_req {
88/* kvm attributes for KVM_S390_VM_TOD */ 88/* kvm attributes for KVM_S390_VM_TOD */
89#define KVM_S390_VM_TOD_LOW 0 89#define KVM_S390_VM_TOD_LOW 0
90#define KVM_S390_VM_TOD_HIGH 1 90#define KVM_S390_VM_TOD_HIGH 1
91#define KVM_S390_VM_TOD_EXT 2
92
93struct kvm_s390_vm_tod_clock {
94 __u8 epoch_idx;
95 __u64 tod;
96};
91 97
92/* kvm attributes for KVM_S390_VM_CPU_MODEL */ 98/* kvm attributes for KVM_S390_VM_CPU_MODEL */
93/* processor related attributes are r/w */ 99/* processor related attributes are r/w */
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index 8ea315a11fe0..2519c6c801c9 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -196,6 +196,7 @@
196 196
197#define X86_FEATURE_HW_PSTATE ( 7*32+ 8) /* AMD HW-PState */ 197#define X86_FEATURE_HW_PSTATE ( 7*32+ 8) /* AMD HW-PState */
198#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */ 198#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */
199#define X86_FEATURE_SME ( 7*32+10) /* AMD Secure Memory Encryption */
199 200
200#define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory Number */ 201#define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory Number */
201#define X86_FEATURE_INTEL_PT ( 7*32+15) /* Intel Processor Trace */ 202#define X86_FEATURE_INTEL_PT ( 7*32+15) /* Intel Processor Trace */
@@ -287,6 +288,7 @@
287#define X86_FEATURE_PFTHRESHOLD (15*32+12) /* pause filter threshold */ 288#define X86_FEATURE_PFTHRESHOLD (15*32+12) /* pause filter threshold */
288#define X86_FEATURE_AVIC (15*32+13) /* Virtual Interrupt Controller */ 289#define X86_FEATURE_AVIC (15*32+13) /* Virtual Interrupt Controller */
289#define X86_FEATURE_V_VMSAVE_VMLOAD (15*32+15) /* Virtual VMSAVE VMLOAD */ 290#define X86_FEATURE_V_VMSAVE_VMLOAD (15*32+15) /* Virtual VMSAVE VMLOAD */
291#define X86_FEATURE_VGIF (15*32+16) /* Virtual GIF */
290 292
291/* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 16 */ 293/* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 16 */
292#define X86_FEATURE_AVX512VBMI (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/ 294#define X86_FEATURE_AVX512VBMI (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/
diff --git a/tools/arch/x86/include/asm/disabled-features.h b/tools/arch/x86/include/asm/disabled-features.h
index 5dff775af7cd..c10c9128f54e 100644
--- a/tools/arch/x86/include/asm/disabled-features.h
+++ b/tools/arch/x86/include/asm/disabled-features.h
@@ -21,11 +21,13 @@
21# define DISABLE_K6_MTRR (1<<(X86_FEATURE_K6_MTRR & 31)) 21# define DISABLE_K6_MTRR (1<<(X86_FEATURE_K6_MTRR & 31))
22# define DISABLE_CYRIX_ARR (1<<(X86_FEATURE_CYRIX_ARR & 31)) 22# define DISABLE_CYRIX_ARR (1<<(X86_FEATURE_CYRIX_ARR & 31))
23# define DISABLE_CENTAUR_MCR (1<<(X86_FEATURE_CENTAUR_MCR & 31)) 23# define DISABLE_CENTAUR_MCR (1<<(X86_FEATURE_CENTAUR_MCR & 31))
24# define DISABLE_PCID 0
24#else 25#else
25# define DISABLE_VME 0 26# define DISABLE_VME 0
26# define DISABLE_K6_MTRR 0 27# define DISABLE_K6_MTRR 0
27# define DISABLE_CYRIX_ARR 0 28# define DISABLE_CYRIX_ARR 0
28# define DISABLE_CENTAUR_MCR 0 29# define DISABLE_CENTAUR_MCR 0
30# define DISABLE_PCID (1<<(X86_FEATURE_PCID & 31))
29#endif /* CONFIG_X86_64 */ 31#endif /* CONFIG_X86_64 */
30 32
31#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS 33#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
@@ -49,7 +51,7 @@
49#define DISABLED_MASK1 0 51#define DISABLED_MASK1 0
50#define DISABLED_MASK2 0 52#define DISABLED_MASK2 0
51#define DISABLED_MASK3 (DISABLE_CYRIX_ARR|DISABLE_CENTAUR_MCR|DISABLE_K6_MTRR) 53#define DISABLED_MASK3 (DISABLE_CYRIX_ARR|DISABLE_CENTAUR_MCR|DISABLE_K6_MTRR)
52#define DISABLED_MASK4 0 54#define DISABLED_MASK4 (DISABLE_PCID)
53#define DISABLED_MASK5 0 55#define DISABLED_MASK5 0
54#define DISABLED_MASK6 0 56#define DISABLED_MASK6 0
55#define DISABLED_MASK7 0 57#define DISABLED_MASK7 0
diff --git a/tools/include/asm-generic/hugetlb_encode.h b/tools/include/asm-generic/hugetlb_encode.h
new file mode 100644
index 000000000000..e4732d3c2998
--- /dev/null
+++ b/tools/include/asm-generic/hugetlb_encode.h
@@ -0,0 +1,34 @@
1#ifndef _ASM_GENERIC_HUGETLB_ENCODE_H_
2#define _ASM_GENERIC_HUGETLB_ENCODE_H_
3
4/*
5 * Several system calls take a flag to request "hugetlb" huge pages.
6 * Without further specification, these system calls will use the
7 * system's default huge page size. If a system supports multiple
8 * huge page sizes, the desired huge page size can be specified in
9 * bits [26:31] of the flag arguments. The value in these 6 bits
10 * will encode the log2 of the huge page size.
11 *
12 * The following definitions are associated with this huge page size
13 * encoding in flag arguments. System call specific header files
14 * that use this encoding should include this file. They can then
15 * provide definitions based on these with their own specific prefix.
16 * for example:
17 * #define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT
18 */
19
20#define HUGETLB_FLAG_ENCODE_SHIFT 26
21#define HUGETLB_FLAG_ENCODE_MASK 0x3f
22
23#define HUGETLB_FLAG_ENCODE_64KB (16 << HUGETLB_FLAG_ENCODE_SHIFT)
24#define HUGETLB_FLAG_ENCODE_512KB (19 << HUGETLB_FLAG_ENCODE_SHIFT)
25#define HUGETLB_FLAG_ENCODE_1MB (20 << HUGETLB_FLAG_ENCODE_SHIFT)
26#define HUGETLB_FLAG_ENCODE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT)
27#define HUGETLB_FLAG_ENCODE_8MB (23 << HUGETLB_FLAG_ENCODE_SHIFT)
28#define HUGETLB_FLAG_ENCODE_16MB (24 << HUGETLB_FLAG_ENCODE_SHIFT)
29#define HUGETLB_FLAG_ENCODE_256MB (28 << HUGETLB_FLAG_ENCODE_SHIFT)
30#define HUGETLB_FLAG_ENCODE_1GB (30 << HUGETLB_FLAG_ENCODE_SHIFT)
31#define HUGETLB_FLAG_ENCODE_2GB (31 << HUGETLB_FLAG_ENCODE_SHIFT)
32#define HUGETLB_FLAG_ENCODE_16GB (34 << HUGETLB_FLAG_ENCODE_SHIFT)
33
34#endif /* _ASM_GENERIC_HUGETLB_ENCODE_H_ */
diff --git a/tools/include/uapi/asm-generic/mman-common.h b/tools/include/uapi/asm-generic/mman-common.h
index 8c27db0c5c08..203268f9231e 100644
--- a/tools/include/uapi/asm-generic/mman-common.h
+++ b/tools/include/uapi/asm-generic/mman-common.h
@@ -58,20 +58,12 @@
58 overrides the coredump filter bits */ 58 overrides the coredump filter bits */
59#define MADV_DODUMP 17 /* Clear the MADV_DONTDUMP flag */ 59#define MADV_DODUMP 17 /* Clear the MADV_DONTDUMP flag */
60 60
61#define MADV_WIPEONFORK 18 /* Zero memory on fork, child only */
62#define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */
63
61/* compatibility flags */ 64/* compatibility flags */
62#define MAP_FILE 0 65#define MAP_FILE 0
63 66
64/*
65 * When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size.
66 * This gives us 6 bits, which is enough until someone invents 128 bit address
67 * spaces.
68 *
69 * Assume these are all power of twos.
70 * When 0 use the default page size.
71 */
72#define MAP_HUGE_SHIFT 26
73#define MAP_HUGE_MASK 0x3f
74
75#define PKEY_DISABLE_ACCESS 0x1 67#define PKEY_DISABLE_ACCESS 0x1
76#define PKEY_DISABLE_WRITE 0x2 68#define PKEY_DISABLE_WRITE 0x2
77#define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\ 69#define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\
diff --git a/tools/include/uapi/drm/drm.h b/tools/include/uapi/drm/drm.h
index 101593ab10ac..97677cd6964d 100644
--- a/tools/include/uapi/drm/drm.h
+++ b/tools/include/uapi/drm/drm.h
@@ -700,6 +700,7 @@ struct drm_prime_handle {
700 700
701struct drm_syncobj_create { 701struct drm_syncobj_create {
702 __u32 handle; 702 __u32 handle;
703#define DRM_SYNCOBJ_CREATE_SIGNALED (1 << 0)
703 __u32 flags; 704 __u32 flags;
704}; 705};
705 706
@@ -718,6 +719,24 @@ struct drm_syncobj_handle {
718 __u32 pad; 719 __u32 pad;
719}; 720};
720 721
722#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)
723#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)
724struct drm_syncobj_wait {
725 __u64 handles;
726 /* absolute timeout */
727 __s64 timeout_nsec;
728 __u32 count_handles;
729 __u32 flags;
730 __u32 first_signaled; /* only valid when not waiting all */
731 __u32 pad;
732};
733
734struct drm_syncobj_array {
735 __u64 handles;
736 __u32 count_handles;
737 __u32 pad;
738};
739
721#if defined(__cplusplus) 740#if defined(__cplusplus)
722} 741}
723#endif 742#endif
@@ -840,6 +859,9 @@ extern "C" {
840#define DRM_IOCTL_SYNCOBJ_DESTROY DRM_IOWR(0xC0, struct drm_syncobj_destroy) 859#define DRM_IOCTL_SYNCOBJ_DESTROY DRM_IOWR(0xC0, struct drm_syncobj_destroy)
841#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct drm_syncobj_handle) 860#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct drm_syncobj_handle)
842#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle) 861#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle)
862#define DRM_IOCTL_SYNCOBJ_WAIT DRM_IOWR(0xC3, struct drm_syncobj_wait)
863#define DRM_IOCTL_SYNCOBJ_RESET DRM_IOWR(0xC4, struct drm_syncobj_array)
864#define DRM_IOCTL_SYNCOBJ_SIGNAL DRM_IOWR(0xC5, struct drm_syncobj_array)
843 865
844/** 866/**
845 * Device specific ioctls should only be in their respective headers 867 * Device specific ioctls should only be in their respective headers
diff --git a/tools/include/uapi/drm/i915_drm.h b/tools/include/uapi/drm/i915_drm.h
index 7ccbd6a2bbe0..6598fb76d2c2 100644
--- a/tools/include/uapi/drm/i915_drm.h
+++ b/tools/include/uapi/drm/i915_drm.h
@@ -260,6 +260,8 @@ typedef struct _drm_i915_sarea {
260#define DRM_I915_GEM_CONTEXT_GETPARAM 0x34 260#define DRM_I915_GEM_CONTEXT_GETPARAM 0x34
261#define DRM_I915_GEM_CONTEXT_SETPARAM 0x35 261#define DRM_I915_GEM_CONTEXT_SETPARAM 0x35
262#define DRM_I915_PERF_OPEN 0x36 262#define DRM_I915_PERF_OPEN 0x36
263#define DRM_I915_PERF_ADD_CONFIG 0x37
264#define DRM_I915_PERF_REMOVE_CONFIG 0x38
263 265
264#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) 266#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
265#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) 267#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -315,6 +317,8 @@ typedef struct _drm_i915_sarea {
315#define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param) 317#define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param)
316#define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param) 318#define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param)
317#define DRM_IOCTL_I915_PERF_OPEN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param) 319#define DRM_IOCTL_I915_PERF_OPEN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param)
320#define DRM_IOCTL_I915_PERF_ADD_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_ADD_CONFIG, struct drm_i915_perf_oa_config)
321#define DRM_IOCTL_I915_PERF_REMOVE_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_REMOVE_CONFIG, __u64)
318 322
319/* Allow drivers to submit batchbuffers directly to hardware, relying 323/* Allow drivers to submit batchbuffers directly to hardware, relying
320 * on the security mechanisms provided by hardware. 324 * on the security mechanisms provided by hardware.
@@ -431,6 +435,11 @@ typedef struct drm_i915_irq_wait {
431 */ 435 */
432#define I915_PARAM_HAS_EXEC_BATCH_FIRST 48 436#define I915_PARAM_HAS_EXEC_BATCH_FIRST 48
433 437
438/* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of
439 * drm_i915_gem_exec_fence structures. See I915_EXEC_FENCE_ARRAY.
440 */
441#define I915_PARAM_HAS_EXEC_FENCE_ARRAY 49
442
434typedef struct drm_i915_getparam { 443typedef struct drm_i915_getparam {
435 __s32 param; 444 __s32 param;
436 /* 445 /*
@@ -812,6 +821,17 @@ struct drm_i915_gem_exec_object2 {
812 __u64 rsvd2; 821 __u64 rsvd2;
813}; 822};
814 823
824struct drm_i915_gem_exec_fence {
825 /**
826 * User's handle for a drm_syncobj to wait on or signal.
827 */
828 __u32 handle;
829
830#define I915_EXEC_FENCE_WAIT (1<<0)
831#define I915_EXEC_FENCE_SIGNAL (1<<1)
832 __u32 flags;
833};
834
815struct drm_i915_gem_execbuffer2 { 835struct drm_i915_gem_execbuffer2 {
816 /** 836 /**
817 * List of gem_exec_object2 structs 837 * List of gem_exec_object2 structs
@@ -826,7 +846,11 @@ struct drm_i915_gem_execbuffer2 {
826 __u32 DR1; 846 __u32 DR1;
827 __u32 DR4; 847 __u32 DR4;
828 __u32 num_cliprects; 848 __u32 num_cliprects;
829 /** This is a struct drm_clip_rect *cliprects */ 849 /**
850 * This is a struct drm_clip_rect *cliprects if I915_EXEC_FENCE_ARRAY
851 * is not set. If I915_EXEC_FENCE_ARRAY is set, then this is a
852 * struct drm_i915_gem_exec_fence *fences.
853 */
830 __u64 cliprects_ptr; 854 __u64 cliprects_ptr;
831#define I915_EXEC_RING_MASK (7<<0) 855#define I915_EXEC_RING_MASK (7<<0)
832#define I915_EXEC_DEFAULT (0<<0) 856#define I915_EXEC_DEFAULT (0<<0)
@@ -927,7 +951,14 @@ struct drm_i915_gem_execbuffer2 {
927 * element). 951 * element).
928 */ 952 */
929#define I915_EXEC_BATCH_FIRST (1<<18) 953#define I915_EXEC_BATCH_FIRST (1<<18)
930#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_BATCH_FIRST<<1)) 954
955/* Setting I915_FENCE_ARRAY implies that num_cliprects and cliprects_ptr
956 * define an array of i915_gem_exec_fence structures which specify a set of
957 * dma fences to wait upon or signal.
958 */
959#define I915_EXEC_FENCE_ARRAY (1<<19)
960
961#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_ARRAY<<1))
931 962
932#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff) 963#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
933#define i915_execbuffer2_set_context_id(eb2, context) \ 964#define i915_execbuffer2_set_context_id(eb2, context) \
@@ -1467,6 +1498,22 @@ enum drm_i915_perf_record_type {
1467 DRM_I915_PERF_RECORD_MAX /* non-ABI */ 1498 DRM_I915_PERF_RECORD_MAX /* non-ABI */
1468}; 1499};
1469 1500
1501/**
1502 * Structure to upload perf dynamic configuration into the kernel.
1503 */
1504struct drm_i915_perf_oa_config {
1505 /** String formatted like "%08x-%04x-%04x-%04x-%012x" */
1506 char uuid[36];
1507
1508 __u32 n_mux_regs;
1509 __u32 n_boolean_regs;
1510 __u32 n_flex_regs;
1511
1512 __u64 __user mux_regs_ptr;
1513 __u64 __user boolean_regs_ptr;
1514 __u64 __user flex_regs_ptr;
1515};
1516
1470#if defined(__cplusplus) 1517#if defined(__cplusplus)
1471} 1518}
1472#endif 1519#endif
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 461811e57140..43ab5c402f98 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -143,12 +143,6 @@ enum bpf_attach_type {
143 143
144#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE 144#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
145 145
146enum bpf_sockmap_flags {
147 BPF_SOCKMAP_UNSPEC,
148 BPF_SOCKMAP_STRPARSER,
149 __MAX_BPF_SOCKMAP_FLAG
150};
151
152/* If BPF_F_ALLOW_OVERRIDE flag is used in BPF_PROG_ATTACH command 146/* If BPF_F_ALLOW_OVERRIDE flag is used in BPF_PROG_ATTACH command
153 * to the given target_fd cgroup the descendent cgroup will be able to 147 * to the given target_fd cgroup the descendent cgroup will be able to
154 * override effective bpf program that was inherited from this cgroup 148 * override effective bpf program that was inherited from this cgroup
@@ -368,9 +362,20 @@ union bpf_attr {
368 * int bpf_redirect(ifindex, flags) 362 * int bpf_redirect(ifindex, flags)
369 * redirect to another netdev 363 * redirect to another netdev
370 * @ifindex: ifindex of the net device 364 * @ifindex: ifindex of the net device
371 * @flags: bit 0 - if set, redirect to ingress instead of egress 365 * @flags:
372 * other bits - reserved 366 * cls_bpf:
373 * Return: TC_ACT_REDIRECT 367 * bit 0 - if set, redirect to ingress instead of egress
368 * other bits - reserved
369 * xdp_bpf:
370 * all bits - reserved
371 * Return: cls_bpf: TC_ACT_REDIRECT on success or TC_ACT_SHOT on error
372 * xdp_bfp: XDP_REDIRECT on success or XDP_ABORT on error
373 * int bpf_redirect_map(map, key, flags)
374 * redirect to endpoint in map
375 * @map: pointer to dev map
376 * @key: index in map to lookup
377 * @flags: --
378 * Return: XDP_REDIRECT on success or XDP_ABORT on error
374 * 379 *
375 * u32 bpf_get_route_realm(skb) 380 * u32 bpf_get_route_realm(skb)
376 * retrieve a dst's tclassid 381 * retrieve a dst's tclassid
@@ -632,7 +637,7 @@ union bpf_attr {
632 FN(skb_adjust_room), \ 637 FN(skb_adjust_room), \
633 FN(redirect_map), \ 638 FN(redirect_map), \
634 FN(sk_redirect_map), \ 639 FN(sk_redirect_map), \
635 FN(sock_map_update), 640 FN(sock_map_update), \
636 641
637/* integer value in 'imm' field of BPF_CALL instruction selects which helper 642/* integer value in 'imm' field of BPF_CALL instruction selects which helper
638 * function eBPF program intends to call 643 * function eBPF program intends to call
@@ -753,20 +758,23 @@ struct bpf_sock {
753 __u32 family; 758 __u32 family;
754 __u32 type; 759 __u32 type;
755 __u32 protocol; 760 __u32 protocol;
761 __u32 mark;
762 __u32 priority;
756}; 763};
757 764
758#define XDP_PACKET_HEADROOM 256 765#define XDP_PACKET_HEADROOM 256
759 766
760/* User return codes for XDP prog type. 767/* User return codes for XDP prog type.
761 * A valid XDP program must return one of these defined values. All other 768 * A valid XDP program must return one of these defined values. All other
762 * return codes are reserved for future use. Unknown return codes will result 769 * return codes are reserved for future use. Unknown return codes will
763 * in packet drop. 770 * result in packet drops and a warning via bpf_warn_invalid_xdp_action().
764 */ 771 */
765enum xdp_action { 772enum xdp_action {
766 XDP_ABORTED = 0, 773 XDP_ABORTED = 0,
767 XDP_DROP, 774 XDP_DROP,
768 XDP_PASS, 775 XDP_PASS,
769 XDP_TX, 776 XDP_TX,
777 XDP_REDIRECT,
770}; 778};
771 779
772/* user accessible metadata for XDP packet hook 780/* user accessible metadata for XDP packet hook
diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h
index 6cd63c18708a..838887587411 100644
--- a/tools/include/uapi/linux/kvm.h
+++ b/tools/include/uapi/linux/kvm.h
@@ -711,7 +711,8 @@ struct kvm_ppc_one_seg_page_size {
711struct kvm_ppc_smmu_info { 711struct kvm_ppc_smmu_info {
712 __u64 flags; 712 __u64 flags;
713 __u32 slb_size; 713 __u32 slb_size;
714 __u32 pad; 714 __u16 data_keys; /* # storage keys supported for data */
715 __u16 instr_keys; /* # storage keys supported for instructions */
715 struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; 716 struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
716}; 717};
717 718
diff --git a/tools/include/uapi/linux/mman.h b/tools/include/uapi/linux/mman.h
index 81d8edf11789..a937480d7cd3 100644
--- a/tools/include/uapi/linux/mman.h
+++ b/tools/include/uapi/linux/mman.h
@@ -1,7 +1,8 @@
1#ifndef _UAPI_LINUX_MMAN_H 1#ifndef _UAPI_LINUX_MMAN_H
2#define _UAPI_LINUX_MMAN_H 2#define _UAPI_LINUX_MMAN_H
3 3
4#include <uapi/asm/mman.h> 4#include <asm/mman.h>
5#include <asm-generic/hugetlb_encode.h>
5 6
6#define MREMAP_MAYMOVE 1 7#define MREMAP_MAYMOVE 1
7#define MREMAP_FIXED 2 8#define MREMAP_FIXED 2
@@ -10,4 +11,25 @@
10#define OVERCOMMIT_ALWAYS 1 11#define OVERCOMMIT_ALWAYS 1
11#define OVERCOMMIT_NEVER 2 12#define OVERCOMMIT_NEVER 2
12 13
14/*
15 * Huge page size encoding when MAP_HUGETLB is specified, and a huge page
16 * size other than the default is desired. See hugetlb_encode.h.
17 * All known huge page size encodings are provided here. It is the
18 * responsibility of the application to know which sizes are supported on
19 * the running system. See mmap(2) man page for details.
20 */
21#define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT
22#define MAP_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK
23
24#define MAP_HUGE_64KB HUGETLB_FLAG_ENCODE_64KB
25#define MAP_HUGE_512KB HUGETLB_FLAG_ENCODE_512KB
26#define MAP_HUGE_1MB HUGETLB_FLAG_ENCODE_1MB
27#define MAP_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB
28#define MAP_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB
29#define MAP_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB
30#define MAP_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB
31#define MAP_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB
32#define MAP_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB
33#define MAP_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB
34
13#endif /* _UAPI_LINUX_MMAN_H */ 35#endif /* _UAPI_LINUX_MMAN_H */
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index 0f22768c0d4d..34a579f806e3 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -284,11 +284,16 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
284 case 0x8d: 284 case 0x8d:
285 if (sib == 0x24 && rex_w && !rex_b && !rex_x) { 285 if (sib == 0x24 && rex_w && !rex_b && !rex_x) {
286 286
287 /* lea disp(%rsp), reg */
288 *type = INSN_STACK; 287 *type = INSN_STACK;
289 op->src.type = OP_SRC_ADD; 288 if (!insn.displacement.value) {
289 /* lea (%rsp), reg */
290 op->src.type = OP_SRC_REG;
291 } else {
292 /* lea disp(%rsp), reg */
293 op->src.type = OP_SRC_ADD;
294 op->src.offset = insn.displacement.value;
295 }
290 op->src.reg = CFI_SP; 296 op->src.reg = CFI_SP;
291 op->src.offset = insn.displacement.value;
292 op->dest.type = OP_DEST_REG; 297 op->dest.type = OP_DEST_REG;
293 op->dest.reg = op_to_cfi_reg[modrm_reg][rex_r]; 298 op->dest.reg = op_to_cfi_reg[modrm_reg][rex_r];
294 299
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index 62072822dc85..627b7cada144 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -1,34 +1,8 @@
1tools/perf 1tools/perf
2tools/arch/alpha/include/asm/barrier.h 2tools/arch
3tools/arch/arm/include/asm/barrier.h
4tools/arch/arm64/include/asm/barrier.h
5tools/arch/ia64/include/asm/barrier.h
6tools/arch/mips/include/asm/barrier.h
7tools/arch/powerpc/include/asm/barrier.h
8tools/arch/s390/include/asm/barrier.h
9tools/arch/sh/include/asm/barrier.h
10tools/arch/sparc/include/asm/barrier.h
11tools/arch/sparc/include/asm/barrier_32.h
12tools/arch/sparc/include/asm/barrier_64.h
13tools/arch/tile/include/asm/barrier.h
14tools/arch/x86/include/asm/barrier.h
15tools/arch/x86/include/asm/cmpxchg.h
16tools/arch/x86/include/asm/cpufeatures.h
17tools/arch/x86/include/asm/disabled-features.h
18tools/arch/x86/include/asm/required-features.h
19tools/arch/x86/include/uapi/asm/svm.h
20tools/arch/x86/include/uapi/asm/vmx.h
21tools/arch/x86/include/uapi/asm/kvm.h
22tools/arch/x86/include/uapi/asm/kvm_perf.h
23tools/arch/x86/lib/memcpy_64.S
24tools/arch/x86/lib/memset_64.S
25tools/arch/s390/include/uapi/asm/kvm_perf.h
26tools/arch/s390/include/uapi/asm/sie.h
27tools/arch/xtensa/include/asm/barrier.h
28tools/scripts 3tools/scripts
29tools/build 4tools/build
30tools/arch/x86/include/asm/atomic.h 5tools/include
31tools/arch/x86/include/asm/rmwcc.h
32tools/lib/traceevent 6tools/lib/traceevent
33tools/lib/api 7tools/lib/api
34tools/lib/bpf 8tools/lib/bpf
@@ -42,60 +16,3 @@ tools/lib/find_bit.c
42tools/lib/bitmap.c 16tools/lib/bitmap.c
43tools/lib/str_error_r.c 17tools/lib/str_error_r.c
44tools/lib/vsprintf.c 18tools/lib/vsprintf.c
45tools/include/asm/alternative-asm.h
46tools/include/asm/atomic.h
47tools/include/asm/barrier.h
48tools/include/asm/bug.h
49tools/include/asm-generic/atomic-gcc.h
50tools/include/asm-generic/barrier.h
51tools/include/asm-generic/bitops/arch_hweight.h
52tools/include/asm-generic/bitops/atomic.h
53tools/include/asm-generic/bitops/const_hweight.h
54tools/include/asm-generic/bitops/__ffs.h
55tools/include/asm-generic/bitops/__ffz.h
56tools/include/asm-generic/bitops/__fls.h
57tools/include/asm-generic/bitops/find.h
58tools/include/asm-generic/bitops/fls64.h
59tools/include/asm-generic/bitops/fls.h
60tools/include/asm-generic/bitops/hweight.h
61tools/include/asm-generic/bitops.h
62tools/include/linux/atomic.h
63tools/include/linux/bitops.h
64tools/include/linux/compiler.h
65tools/include/linux/compiler-gcc.h
66tools/include/linux/coresight-pmu.h
67tools/include/linux/bug.h
68tools/include/linux/filter.h
69tools/include/linux/hash.h
70tools/include/linux/kernel.h
71tools/include/linux/list.h
72tools/include/linux/log2.h
73tools/include/uapi/asm-generic/fcntl.h
74tools/include/uapi/asm-generic/ioctls.h
75tools/include/uapi/asm-generic/mman-common.h
76tools/include/uapi/asm-generic/mman.h
77tools/include/uapi/drm/drm.h
78tools/include/uapi/drm/i915_drm.h
79tools/include/uapi/linux/bpf.h
80tools/include/uapi/linux/bpf_common.h
81tools/include/uapi/linux/fcntl.h
82tools/include/uapi/linux/hw_breakpoint.h
83tools/include/uapi/linux/kvm.h
84tools/include/uapi/linux/mman.h
85tools/include/uapi/linux/perf_event.h
86tools/include/uapi/linux/sched.h
87tools/include/uapi/linux/stat.h
88tools/include/uapi/linux/vhost.h
89tools/include/uapi/sound/asound.h
90tools/include/linux/poison.h
91tools/include/linux/rbtree.h
92tools/include/linux/rbtree_augmented.h
93tools/include/linux/refcount.h
94tools/include/linux/string.h
95tools/include/linux/stringify.h
96tools/include/linux/types.h
97tools/include/linux/err.h
98tools/include/linux/bitmap.h
99tools/include/linux/time64.h
100tools/arch/*/include/uapi/asm/mman.h
101tools/arch/*/include/uapi/asm/perf_regs.h
diff --git a/tools/perf/arch/s390/util/Build b/tools/perf/arch/s390/util/Build
index bd518b623d7a..5bd7b9260cc0 100644
--- a/tools/perf/arch/s390/util/Build
+++ b/tools/perf/arch/s390/util/Build
@@ -1,5 +1,4 @@
1libperf-y += header.o 1libperf-y += header.o
2libperf-y += sym-handling.o
3libperf-y += kvm-stat.o 2libperf-y += kvm-stat.o
4 3
5libperf-$(CONFIG_DWARF) += dwarf-regs.o 4libperf-$(CONFIG_DWARF) += dwarf-regs.o
diff --git a/tools/perf/arch/s390/util/sym-handling.c b/tools/perf/arch/s390/util/sym-handling.c
deleted file mode 100644
index e103f6e46afe..000000000000
--- a/tools/perf/arch/s390/util/sym-handling.c
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Architecture specific ELF symbol handling and relocation mapping.
3 *
4 * Copyright 2017 IBM Corp.
5 * Author(s): Thomas Richter <tmricht@linux.vnet.ibm.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License (version 2 only)
9 * as published by the Free Software Foundation.
10 */
11
12#include "symbol.h"
13
14#ifdef HAVE_LIBELF_SUPPORT
15bool elf__needs_adjust_symbols(GElf_Ehdr ehdr)
16{
17 if (ehdr.e_type == ET_EXEC)
18 return false;
19 return ehdr.e_type == ET_REL || ehdr.e_type == ET_DYN;
20}
21
22void arch__adjust_sym_map_offset(GElf_Sym *sym,
23 GElf_Shdr *shdr __maybe_unused,
24 struct map *map)
25{
26 if (map->type == MAP__FUNCTION)
27 sym->st_value += map->start;
28}
29#endif
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 510b513e0f01..be09d77cade0 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -65,8 +65,6 @@ static int parse_callchain_mode(const char *value)
65 callchain_param.mode = CHAIN_FOLDED; 65 callchain_param.mode = CHAIN_FOLDED;
66 return 0; 66 return 0;
67 } 67 }
68
69 pr_err("Invalid callchain mode: %s\n", value);
70 return -1; 68 return -1;
71} 69}
72 70
@@ -82,8 +80,6 @@ static int parse_callchain_order(const char *value)
82 callchain_param.order_set = true; 80 callchain_param.order_set = true;
83 return 0; 81 return 0;
84 } 82 }
85
86 pr_err("Invalid callchain order: %s\n", value);
87 return -1; 83 return -1;
88} 84}
89 85
@@ -105,8 +101,6 @@ static int parse_callchain_sort_key(const char *value)
105 callchain_param.branch_callstack = 1; 101 callchain_param.branch_callstack = 1;
106 return 0; 102 return 0;
107 } 103 }
108
109 pr_err("Invalid callchain sort key: %s\n", value);
110 return -1; 104 return -1;
111} 105}
112 106
@@ -124,8 +118,6 @@ static int parse_callchain_value(const char *value)
124 callchain_param.value = CCVAL_COUNT; 118 callchain_param.value = CCVAL_COUNT;
125 return 0; 119 return 0;
126 } 120 }
127
128 pr_err("Invalid callchain config key: %s\n", value);
129 return -1; 121 return -1;
130} 122}
131 123
@@ -319,12 +311,27 @@ int perf_callchain_config(const char *var, const char *value)
319 311
320 return ret; 312 return ret;
321 } 313 }
322 if (!strcmp(var, "print-type")) 314 if (!strcmp(var, "print-type")){
323 return parse_callchain_mode(value); 315 int ret;
324 if (!strcmp(var, "order")) 316 ret = parse_callchain_mode(value);
325 return parse_callchain_order(value); 317 if (ret == -1)
326 if (!strcmp(var, "sort-key")) 318 pr_err("Invalid callchain mode: %s\n", value);
327 return parse_callchain_sort_key(value); 319 return ret;
320 }
321 if (!strcmp(var, "order")){
322 int ret;
323 ret = parse_callchain_order(value);
324 if (ret == -1)
325 pr_err("Invalid callchain order: %s\n", value);
326 return ret;
327 }
328 if (!strcmp(var, "sort-key")){
329 int ret;
330 ret = parse_callchain_sort_key(value);
331 if (ret == -1)
332 pr_err("Invalid callchain sort key: %s\n", value);
333 return ret;
334 }
328 if (!strcmp(var, "threshold")) { 335 if (!strcmp(var, "threshold")) {
329 callchain_param.min_percent = strtod(value, &endptr); 336 callchain_param.min_percent = strtod(value, &endptr);
330 if (value == endptr) { 337 if (value == endptr) {
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 4bb89373eb52..0dccdb89572c 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -271,12 +271,17 @@ struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx)
271 return evsel; 271 return evsel;
272} 272}
273 273
274static bool perf_event_can_profile_kernel(void)
275{
276 return geteuid() == 0 || perf_event_paranoid() == -1;
277}
278
274struct perf_evsel *perf_evsel__new_cycles(bool precise) 279struct perf_evsel *perf_evsel__new_cycles(bool precise)
275{ 280{
276 struct perf_event_attr attr = { 281 struct perf_event_attr attr = {
277 .type = PERF_TYPE_HARDWARE, 282 .type = PERF_TYPE_HARDWARE,
278 .config = PERF_COUNT_HW_CPU_CYCLES, 283 .config = PERF_COUNT_HW_CPU_CYCLES,
279 .exclude_kernel = geteuid() != 0, 284 .exclude_kernel = !perf_event_can_profile_kernel(),
280 }; 285 };
281 struct perf_evsel *evsel; 286 struct perf_evsel *evsel;
282 287
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 5c39f420111e..9cf781f0d8a2 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -810,12 +810,6 @@ static u64 ref_reloc(struct kmap *kmap)
810void __weak arch__sym_update(struct symbol *s __maybe_unused, 810void __weak arch__sym_update(struct symbol *s __maybe_unused,
811 GElf_Sym *sym __maybe_unused) { } 811 GElf_Sym *sym __maybe_unused) { }
812 812
813void __weak arch__adjust_sym_map_offset(GElf_Sym *sym, GElf_Shdr *shdr,
814 struct map *map __maybe_unused)
815{
816 sym->st_value -= shdr->sh_addr - shdr->sh_offset;
817}
818
819int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, 813int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
820 struct symsrc *runtime_ss, int kmodule) 814 struct symsrc *runtime_ss, int kmodule)
821{ 815{
@@ -996,7 +990,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
996 990
997 /* Adjust symbol to map to file offset */ 991 /* Adjust symbol to map to file offset */
998 if (adjust_kernel_syms) 992 if (adjust_kernel_syms)
999 arch__adjust_sym_map_offset(&sym, &shdr, map); 993 sym.st_value -= shdr.sh_addr - shdr.sh_offset;
1000 994
1001 if (strcmp(section_name, 995 if (strcmp(section_name,
1002 (curr_dso->short_name + 996 (curr_dso->short_name +
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 2bd6a1f01a1c..aad99e7e179b 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -344,9 +344,6 @@ int setup_intlist(struct intlist **list, const char *list_str,
344#ifdef HAVE_LIBELF_SUPPORT 344#ifdef HAVE_LIBELF_SUPPORT
345bool elf__needs_adjust_symbols(GElf_Ehdr ehdr); 345bool elf__needs_adjust_symbols(GElf_Ehdr ehdr);
346void arch__sym_update(struct symbol *s, GElf_Sym *sym); 346void arch__sym_update(struct symbol *s, GElf_Sym *sym);
347void arch__adjust_sym_map_offset(GElf_Sym *sym,
348 GElf_Shdr *shdr __maybe_unused,
349 struct map *map __maybe_unused);
350#endif 347#endif
351 348
352#define SYMBOL_A 0 349#define SYMBOL_A 0
diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
index 19e5db90394c..6eea7cff3d4e 100644
--- a/tools/perf/util/syscalltbl.c
+++ b/tools/perf/util/syscalltbl.c
@@ -15,9 +15,9 @@
15 15
16#include "syscalltbl.h" 16#include "syscalltbl.h"
17#include <stdlib.h> 17#include <stdlib.h>
18#include <linux/compiler.h>
18 19
19#ifdef HAVE_SYSCALL_TABLE 20#ifdef HAVE_SYSCALL_TABLE
20#include <linux/compiler.h>
21#include <string.h> 21#include <string.h>
22#include "string2.h" 22#include "string2.h"
23#include "util.h" 23#include "util.h"
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 26ce4f7168be..ff805643b5f7 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -52,6 +52,10 @@ override LDFLAGS =
52override MAKEFLAGS = 52override MAKEFLAGS =
53endif 53endif
54 54
55ifneq ($(KBUILD_SRC),)
56override LDFLAGS =
57endif
58
55BUILD := $(O) 59BUILD := $(O)
56ifndef BUILD 60ifndef BUILD
57 BUILD := $(KBUILD_OUTPUT) 61 BUILD := $(KBUILD_OUTPUT)
@@ -62,32 +66,32 @@ endif
62 66
63export BUILD 67export BUILD
64all: 68all:
65 for TARGET in $(TARGETS); do \ 69 @for TARGET in $(TARGETS); do \
66 BUILD_TARGET=$$BUILD/$$TARGET; \ 70 BUILD_TARGET=$$BUILD/$$TARGET; \
67 mkdir $$BUILD_TARGET -p; \ 71 mkdir $$BUILD_TARGET -p; \
68 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\ 72 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
69 done; 73 done;
70 74
71run_tests: all 75run_tests: all
72 for TARGET in $(TARGETS); do \ 76 @for TARGET in $(TARGETS); do \
73 BUILD_TARGET=$$BUILD/$$TARGET; \ 77 BUILD_TARGET=$$BUILD/$$TARGET; \
74 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\ 78 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
75 done; 79 done;
76 80
77hotplug: 81hotplug:
78 for TARGET in $(TARGETS_HOTPLUG); do \ 82 @for TARGET in $(TARGETS_HOTPLUG); do \
79 BUILD_TARGET=$$BUILD/$$TARGET; \ 83 BUILD_TARGET=$$BUILD/$$TARGET; \
80 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\ 84 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
81 done; 85 done;
82 86
83run_hotplug: hotplug 87run_hotplug: hotplug
84 for TARGET in $(TARGETS_HOTPLUG); do \ 88 @for TARGET in $(TARGETS_HOTPLUG); do \
85 BUILD_TARGET=$$BUILD/$$TARGET; \ 89 BUILD_TARGET=$$BUILD/$$TARGET; \
86 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\ 90 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
87 done; 91 done;
88 92
89clean_hotplug: 93clean_hotplug:
90 for TARGET in $(TARGETS_HOTPLUG); do \ 94 @for TARGET in $(TARGETS_HOTPLUG); do \
91 BUILD_TARGET=$$BUILD/$$TARGET; \ 95 BUILD_TARGET=$$BUILD/$$TARGET; \
92 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ 96 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
93 done; 97 done;
@@ -103,7 +107,7 @@ install:
103ifdef INSTALL_PATH 107ifdef INSTALL_PATH
104 @# Ask all targets to install their files 108 @# Ask all targets to install their files
105 mkdir -p $(INSTALL_PATH) 109 mkdir -p $(INSTALL_PATH)
106 for TARGET in $(TARGETS); do \ 110 @for TARGET in $(TARGETS); do \
107 BUILD_TARGET=$$BUILD/$$TARGET; \ 111 BUILD_TARGET=$$BUILD/$$TARGET; \
108 make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \ 112 make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
109 done; 113 done;
@@ -128,7 +132,7 @@ else
128endif 132endif
129 133
130clean: 134clean:
131 for TARGET in $(TARGETS); do \ 135 @for TARGET in $(TARGETS); do \
132 BUILD_TARGET=$$BUILD/$$TARGET; \ 136 BUILD_TARGET=$$BUILD/$$TARGET; \
133 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ 137 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
134 done; 138 done;
diff --git a/tools/testing/selftests/bpf/bpf_util.h b/tools/testing/selftests/bpf/bpf_util.h
index 20ecbaa0d85d..6c53a8906eff 100644
--- a/tools/testing/selftests/bpf/bpf_util.h
+++ b/tools/testing/selftests/bpf/bpf_util.h
@@ -12,6 +12,7 @@ static inline unsigned int bpf_num_possible_cpus(void)
12 unsigned int start, end, possible_cpus = 0; 12 unsigned int start, end, possible_cpus = 0;
13 char buff[128]; 13 char buff[128];
14 FILE *fp; 14 FILE *fp;
15 int n;
15 16
16 fp = fopen(fcpu, "r"); 17 fp = fopen(fcpu, "r");
17 if (!fp) { 18 if (!fp) {
@@ -20,17 +21,17 @@ static inline unsigned int bpf_num_possible_cpus(void)
20 } 21 }
21 22
22 while (fgets(buff, sizeof(buff), fp)) { 23 while (fgets(buff, sizeof(buff), fp)) {
23 if (sscanf(buff, "%u-%u", &start, &end) == 2) { 24 n = sscanf(buff, "%u-%u", &start, &end);
24 possible_cpus = start == 0 ? end + 1 : 0; 25 if (n == 0) {
25 break; 26 printf("Failed to retrieve # possible CPUs!\n");
27 exit(1);
28 } else if (n == 1) {
29 end = start;
26 } 30 }
31 possible_cpus = start == 0 ? end + 1 : 0;
32 break;
27 } 33 }
28
29 fclose(fp); 34 fclose(fp);
30 if (!possible_cpus) {
31 printf("Failed to retrieve # possible CPUs!\n");
32 exit(1);
33 }
34 35
35 return possible_cpus; 36 return possible_cpus;
36} 37}
diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
index 6b214b7b10fb..247b0a1899d7 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -2,14 +2,14 @@
2uname_M := $(shell uname -m 2>/dev/null || echo not) 2uname_M := $(shell uname -m 2>/dev/null || echo not)
3ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) 3ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
4 4
5TEST_GEN_PROGS := step_after_suspend_test
6
5ifeq ($(ARCH),x86) 7ifeq ($(ARCH),x86)
6TEST_GEN_PROGS := breakpoint_test 8TEST_GEN_PROGS += breakpoint_test
7endif 9endif
8ifneq (,$(filter $(ARCH),aarch64 arm64)) 10ifneq (,$(filter $(ARCH),aarch64 arm64))
9TEST_GEN_PROGS := breakpoint_test_arm64 11TEST_GEN_PROGS += breakpoint_test_arm64
10endif 12endif
11 13
12TEST_GEN_PROGS += step_after_suspend_test
13
14include ../lib.mk 14include ../lib.mk
15 15
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
index 2a1cb9908746..a4fd4c851a5b 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
@@ -1,6 +1,8 @@
1#!/bin/sh 1#!/bin/sh
2# description: Register/unregister many kprobe events 2# description: Register/unregister many kprobe events
3 3
4[ -f kprobe_events ] || exit_unsupported # this is configurable
5
4# ftrace fentry skip size depends on the machine architecture. 6# ftrace fentry skip size depends on the machine architecture.
5# Currently HAVE_KPROBES_ON_FTRACE defined on x86 and powerpc64le 7# Currently HAVE_KPROBES_ON_FTRACE defined on x86 and powerpc64le
6case `uname -m` in 8case `uname -m` in
diff --git a/tools/testing/selftests/futex/Makefile b/tools/testing/selftests/futex/Makefile
index 7c647f619d63..f0c0369ccb79 100644
--- a/tools/testing/selftests/futex/Makefile
+++ b/tools/testing/selftests/futex/Makefile
@@ -7,14 +7,17 @@ TEST_PROGS := run.sh
7include ../lib.mk 7include ../lib.mk
8 8
9all: 9all:
10 for DIR in $(SUBDIRS); do \ 10 @for DIR in $(SUBDIRS); do \
11 BUILD_TARGET=$(OUTPUT)/$$DIR; \ 11 BUILD_TARGET=$(OUTPUT)/$$DIR; \
12 mkdir $$BUILD_TARGET -p; \ 12 mkdir $$BUILD_TARGET -p; \
13 make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ 13 make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
14 if [ -e $$DIR/$(TEST_PROGS) ]; then
15 rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/;
16 fi
14 done 17 done
15 18
16override define RUN_TESTS 19override define RUN_TESTS
17 $(OUTPUT)/run.sh 20 @cd $(OUTPUT); ./run.sh
18endef 21endef
19 22
20override define INSTALL_RULE 23override define INSTALL_RULE
@@ -33,7 +36,7 @@ override define EMIT_TESTS
33endef 36endef
34 37
35override define CLEAN 38override define CLEAN
36 for DIR in $(SUBDIRS); do \ 39 @for DIR in $(SUBDIRS); do \
37 BUILD_TARGET=$(OUTPUT)/$$DIR; \ 40 BUILD_TARGET=$(OUTPUT)/$$DIR; \
38 mkdir $$BUILD_TARGET -p; \ 41 mkdir $$BUILD_TARGET -p; \
39 make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ 42 make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
diff --git a/tools/testing/selftests/intel_pstate/Makefile b/tools/testing/selftests/intel_pstate/Makefile
index 849a90ffe8dd..a97e24edde39 100644
--- a/tools/testing/selftests/intel_pstate/Makefile
+++ b/tools/testing/selftests/intel_pstate/Makefile
@@ -1,7 +1,9 @@
1CFLAGS := $(CFLAGS) -Wall -D_GNU_SOURCE 1CFLAGS := $(CFLAGS) -Wall -D_GNU_SOURCE
2LDLIBS := $(LDLIBS) -lm 2LDLIBS := $(LDLIBS) -lm
3 3
4ifeq (,$(filter $(ARCH),x86))
4TEST_GEN_FILES := msr aperf 5TEST_GEN_FILES := msr aperf
6endif
5 7
6TEST_PROGS := run.sh 8TEST_PROGS := run.sh
7 9
diff --git a/tools/testing/selftests/intel_pstate/run.sh b/tools/testing/selftests/intel_pstate/run.sh
index 7868c106b8b1..d3ab48f91cd6 100755
--- a/tools/testing/selftests/intel_pstate/run.sh
+++ b/tools/testing/selftests/intel_pstate/run.sh
@@ -29,13 +29,12 @@
29 29
30EVALUATE_ONLY=0 30EVALUATE_ONLY=0
31 31
32max_cpus=$(($(nproc)-1)) 32if ! uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ | grep -q x86; then
33 echo "$0 # Skipped: Test can only run on x86 architectures."
34 exit 0
35fi
33 36
34# compile programs 37max_cpus=$(($(nproc)-1))
35gcc aperf.c -Wall -D_GNU_SOURCE -o aperf -lm
36[ $? -ne 0 ] && echo "Problem compiling aperf.c." && exit 1
37gcc -o msr msr.c -lm
38[ $? -ne 0 ] && echo "Problem compiling msr.c." && exit 1
39 38
40function run_test () { 39function run_test () {
41 40
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 693616651da5..f65886af7c0c 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -6,7 +6,14 @@ ifeq (0,$(MAKELEVEL))
6OUTPUT := $(shell pwd) 6OUTPUT := $(shell pwd)
7endif 7endif
8 8
9# The following are built by lib.mk common compile rules.
10# TEST_CUSTOM_PROGS should be used by tests that require
11# custom build rule and prevent common build rule use.
12# TEST_PROGS are for test shell scripts.
13# TEST_CUSTOM_PROGS and TEST_PROGS will be run by common run_tests
14# and install targets. Common clean doesn't touch them.
9TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) 15TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
16TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
10TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) 17TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
11 18
12all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) 19all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
@@ -20,17 +27,28 @@ define RUN_TESTS
20 test_num=`echo $$test_num+1 | bc`; \ 27 test_num=`echo $$test_num+1 | bc`; \
21 echo "selftests: $$BASENAME_TEST"; \ 28 echo "selftests: $$BASENAME_TEST"; \
22 echo "========================================"; \ 29 echo "========================================"; \
23 if [ ! -x $$BASENAME_TEST ]; then \ 30 if [ ! -x $$TEST ]; then \
24 echo "selftests: Warning: file $$BASENAME_TEST is not executable, correct this.";\ 31 echo "selftests: Warning: file $$BASENAME_TEST is not executable, correct this.";\
25 echo "not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; \ 32 echo "not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; \
26 else \ 33 else \
27 cd `dirname $$TEST` > /dev/null; (./$$BASENAME_TEST && echo "ok 1..$$test_num selftests: $$BASENAME_TEST [PASS]") || echo "not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; cd - > /dev/null;\ 34 cd `dirname $$TEST` > /dev/null; (./$$BASENAME_TEST > /tmp/$$BASENAME_TEST 2>&1 && echo "ok 1..$$test_num selftests: $$BASENAME_TEST [PASS]") || echo "not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; cd - > /dev/null;\
28 fi; \ 35 fi; \
29 done; 36 done;
30endef 37endef
31 38
32run_tests: all 39run_tests: all
33 $(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_PROGS)) 40ifneq ($(KBUILD_SRC),)
41 @if [ "X$(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)" != "X" ]; then
42 @rsync -aq $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(OUTPUT)
43 fi
44 @if [ "X$(TEST_PROGS)" != "X" ]; then
45 $(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(OUTPUT)/$(TEST_PROGS))
46 else
47 $(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS))
48 fi
49else
50 $(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS))
51endif
34 52
35define INSTALL_RULE 53define INSTALL_RULE
36 @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \ 54 @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \
@@ -38,10 +56,10 @@ define INSTALL_RULE
38 echo "rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \ 56 echo "rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \
39 rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/; \ 57 rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/; \
40 fi 58 fi
41 @if [ "X$(TEST_GEN_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then \ 59 @if [ "X$(TEST_GEN_PROGS)$(TEST_CUSTOM_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then \
42 mkdir -p ${INSTALL_PATH}; \ 60 mkdir -p ${INSTALL_PATH}; \
43 echo "rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/"; \ 61 echo "rsync -a $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/"; \
44 rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/; \ 62 rsync -a $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/; \
45 fi 63 fi
46endef 64endef
47 65
@@ -53,15 +71,20 @@ else
53endif 71endif
54 72
55define EMIT_TESTS 73define EMIT_TESTS
56 @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \ 74 @for TEST in $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS); do \
57 BASENAME_TEST=`basename $$TEST`; \ 75 BASENAME_TEST=`basename $$TEST`; \
58 echo "(./$$BASENAME_TEST && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \ 76 echo "(./$$BASENAME_TEST > /tmp/$$BASENAME_TEST 2>&1 && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \
59 done; 77 done;
60endef 78endef
61 79
62emit_tests: 80emit_tests:
63 $(EMIT_TESTS) 81 $(EMIT_TESTS)
64 82
83# define if isn't already. It is undefined in make O= case.
84ifeq ($(RM),)
85RM := rm -f
86endif
87
65define CLEAN 88define CLEAN
66 $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN) 89 $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
67endef 90endef
@@ -69,6 +92,15 @@ endef
69clean: 92clean:
70 $(CLEAN) 93 $(CLEAN)
71 94
95# When make O= with kselftest target from main level
96# the following aren't defined.
97#
98ifneq ($(KBUILD_SRC),)
99LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
100COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
101LINK.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
102endif
103
72$(OUTPUT)/%:%.c 104$(OUTPUT)/%:%.c
73 $(LINK.c) $^ $(LDLIBS) -o $@ 105 $(LINK.c) $^ $(LDLIBS) -o $@
74 106
diff --git a/tools/testing/selftests/memfd/run_tests.sh b/tools/testing/selftests/memfd/run_tests.sh
index daabb350697c..daabb350697c 100644..100755
--- a/tools/testing/selftests/memfd/run_tests.sh
+++ b/tools/testing/selftests/memfd/run_tests.sh
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
index 79a664aeb8d7..0f5e347b068d 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -5,8 +5,8 @@ TEST_GEN_PROGS := mq_open_tests mq_perf_tests
5include ../lib.mk 5include ../lib.mk
6 6
7override define RUN_TESTS 7override define RUN_TESTS
8 @./mq_open_tests /test1 || echo "selftests: mq_open_tests [FAIL]" 8 $(OUTPUT)/mq_open_tests /test1 || echo "selftests: mq_open_tests [FAIL]"
9 @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" 9 $(OUTPUT)//mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
10endef 10endef
11 11
12override define EMIT_TESTS 12override define EMIT_TESTS
diff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore
index 9801253e4802..c612d6e38c62 100644
--- a/tools/testing/selftests/net/.gitignore
+++ b/tools/testing/selftests/net/.gitignore
@@ -6,3 +6,4 @@ reuseport_bpf
6reuseport_bpf_cpu 6reuseport_bpf_cpu
7reuseport_bpf_numa 7reuseport_bpf_numa
8reuseport_dualstack 8reuseport_dualstack
9reuseaddr_conflict
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index de1f5772b878..d86bca991f45 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -5,9 +5,9 @@ CFLAGS += -I../../../../usr/include/
5 5
6TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh rtnetlink.sh 6TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh rtnetlink.sh
7TEST_GEN_FILES = socket 7TEST_GEN_FILES = socket
8TEST_GEN_FILES += psock_fanout psock_tpacket 8TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy
9TEST_GEN_FILES += reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa 9TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
10TEST_GEN_FILES += reuseport_dualstack msg_zerocopy 10TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict
11 11
12include ../lib.mk 12include ../lib.mk
13 13
diff --git a/tools/testing/selftests/net/msg_zerocopy.c b/tools/testing/selftests/net/msg_zerocopy.c
index 40232af5b023..3ab6ec403905 100644
--- a/tools/testing/selftests/net/msg_zerocopy.c
+++ b/tools/testing/selftests/net/msg_zerocopy.c
@@ -55,7 +55,7 @@
55#include <unistd.h> 55#include <unistd.h>
56 56
57#ifndef SO_EE_ORIGIN_ZEROCOPY 57#ifndef SO_EE_ORIGIN_ZEROCOPY
58#define SO_EE_ORIGIN_ZEROCOPY SO_EE_ORIGIN_UPAGE 58#define SO_EE_ORIGIN_ZEROCOPY 5
59#endif 59#endif
60 60
61#ifndef SO_ZEROCOPY 61#ifndef SO_ZEROCOPY
diff --git a/tools/testing/selftests/net/netdevice.sh b/tools/testing/selftests/net/netdevice.sh
index 4e00568d70c2..90cb903c3381 100755
--- a/tools/testing/selftests/net/netdevice.sh
+++ b/tools/testing/selftests/net/netdevice.sh
@@ -178,7 +178,7 @@ if [ "$(id -u)" -ne 0 ];then
178 exit 0 178 exit 0
179fi 179fi
180 180
181ip -Version 2>/dev/null >/dev/null 181ip link show 2>/dev/null >/dev/null
182if [ $? -ne 0 ];then 182if [ $? -ne 0 ];then
183 echo "SKIP: Could not run test without the ip tool" 183 echo "SKIP: Could not run test without the ip tool"
184 exit 0 184 exit 0
diff --git a/tools/testing/selftests/net/reuseaddr_conflict.c b/tools/testing/selftests/net/reuseaddr_conflict.c
new file mode 100644
index 000000000000..7c5b12664b03
--- /dev/null
+++ b/tools/testing/selftests/net/reuseaddr_conflict.c
@@ -0,0 +1,114 @@
1/*
2 * Test for the regression introduced by
3 *
4 * b9470c27607b ("inet: kill smallest_size and smallest_port")
5 *
6 * If we open an ipv4 socket on a port with reuseaddr we shouldn't reset the tb
7 * when we open the ipv6 conterpart, which is what was happening previously.
8 */
9#include <errno.h>
10#include <error.h>
11#include <arpa/inet.h>
12#include <netinet/in.h>
13#include <stdbool.h>
14#include <stdio.h>
15#include <sys/socket.h>
16#include <sys/types.h>
17#include <unistd.h>
18
19#define PORT 9999
20
21int open_port(int ipv6, int any)
22{
23 int fd = -1;
24 int reuseaddr = 1;
25 int v6only = 1;
26 int addrlen;
27 int ret = -1;
28 struct sockaddr *addr;
29 int family = ipv6 ? AF_INET6 : AF_INET;
30
31 struct sockaddr_in6 addr6 = {
32 .sin6_family = AF_INET6,
33 .sin6_port = htons(PORT),
34 .sin6_addr = in6addr_any
35 };
36 struct sockaddr_in addr4 = {
37 .sin_family = AF_INET,
38 .sin_port = htons(PORT),
39 .sin_addr.s_addr = any ? htonl(INADDR_ANY) : inet_addr("127.0.0.1"),
40 };
41
42
43 if (ipv6) {
44 addr = (struct sockaddr*)&addr6;
45 addrlen = sizeof(addr6);
46 } else {
47 addr = (struct sockaddr*)&addr4;
48 addrlen = sizeof(addr4);
49 }
50
51 if ((fd = socket(family, SOCK_STREAM, IPPROTO_TCP)) < 0) {
52 perror("socket");
53 goto out;
54 }
55
56 if (ipv6 && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&v6only,
57 sizeof(v6only)) < 0) {
58 perror("setsockopt IPV6_V6ONLY");
59 goto out;
60 }
61
62 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr,
63 sizeof(reuseaddr)) < 0) {
64 perror("setsockopt SO_REUSEADDR");
65 goto out;
66 }
67
68 if (bind(fd, addr, addrlen) < 0) {
69 perror("bind");
70 goto out;
71 }
72
73 if (any)
74 return fd;
75
76 if (listen(fd, 1) < 0) {
77 perror("listen");
78 goto out;
79 }
80 return fd;
81out:
82 close(fd);
83 return ret;
84}
85
86int main(void)
87{
88 int listenfd;
89 int fd1, fd2;
90
91 fprintf(stderr, "Opening 127.0.0.1:%d\n", PORT);
92 listenfd = open_port(0, 0);
93 if (listenfd < 0)
94 error(1, errno, "Couldn't open listen socket");
95 fprintf(stderr, "Opening INADDR_ANY:%d\n", PORT);
96 fd1 = open_port(0, 1);
97 if (fd1 >= 0)
98 error(1, 0, "Was allowed to create an ipv4 reuseport on a already bound non-reuseport socket");
99 fprintf(stderr, "Opening in6addr_any:%d\n", PORT);
100 fd1 = open_port(1, 1);
101 if (fd1 < 0)
102 error(1, errno, "Couldn't open ipv6 reuseport");
103 fprintf(stderr, "Opening INADDR_ANY:%d\n", PORT);
104 fd2 = open_port(0, 1);
105 if (fd2 >= 0)
106 error(1, 0, "Was allowed to create an ipv4 reuseport on a already bound non-reuseport socket");
107 close(fd1);
108 fprintf(stderr, "Opening INADDR_ANY:%d after closing ipv6 socket\n", PORT);
109 fd1 = open_port(0, 1);
110 if (fd1 >= 0)
111 error(1, 0, "Was allowed to create an ipv4 reuseport on an already bound non-reuseport socket with no ipv6");
112 fprintf(stderr, "Success");
113 return 0;
114}
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 67c3e2764303..24dbf634e2dd 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -6,10 +6,18 @@
6 */ 6 */
7 7
8#include <sys/types.h> 8#include <sys/types.h>
9#include <asm/siginfo.h> 9
10#define __have_siginfo_t 1 10/*
11#define __have_sigval_t 1 11 * glibc 2.26 and later have SIGSYS in siginfo_t. Before that,
12#define __have_sigevent_t 1 12 * we need to use the kernel's siginfo.h file and trick glibc
13 * into accepting it.
14 */
15#if !__GLIBC_PREREQ(2, 26)
16# include <asm/siginfo.h>
17# define __have_siginfo_t 1
18# define __have_sigval_t 1
19# define __have_sigevent_t 1
20#endif
13 21
14#include <errno.h> 22#include <errno.h>
15#include <linux/filter.h> 23#include <linux/filter.h>
@@ -884,7 +892,7 @@ TEST_F_SIGNAL(TRAP, ign, SIGSYS)
884 syscall(__NR_getpid); 892 syscall(__NR_getpid);
885} 893}
886 894
887static struct siginfo TRAP_info; 895static siginfo_t TRAP_info;
888static volatile int TRAP_nr; 896static volatile int TRAP_nr;
889static void TRAP_action(int nr, siginfo_t *info, void *void_context) 897static void TRAP_action(int nr, siginfo_t *info, void *void_context)
890{ 898{
diff --git a/tools/testing/selftests/sigaltstack/sas.c b/tools/testing/selftests/sigaltstack/sas.c
index 7d406c3973ba..97bb150837df 100644
--- a/tools/testing/selftests/sigaltstack/sas.c
+++ b/tools/testing/selftests/sigaltstack/sas.c
@@ -39,7 +39,11 @@ void my_usr1(int sig, siginfo_t *si, void *u)
39 stack_t stk; 39 stack_t stk;
40 struct stk_data *p; 40 struct stk_data *p;
41 41
42#if __s390x__
43 register unsigned long sp asm("%15");
44#else
42 register unsigned long sp asm("sp"); 45 register unsigned long sp asm("sp");
46#endif
43 47
44 if (sp < (unsigned long)sstack || 48 if (sp < (unsigned long)sstack ||
45 sp >= (unsigned long)sstack + SIGSTKSZ) { 49 sp >= (unsigned long)sstack + SIGSTKSZ) {
diff --git a/tools/testing/selftests/sync/Makefile b/tools/testing/selftests/sync/Makefile
index 4981c6b6d050..8e04d0afcbd7 100644
--- a/tools/testing/selftests/sync/Makefile
+++ b/tools/testing/selftests/sync/Makefile
@@ -2,12 +2,16 @@ CFLAGS += -O2 -g -std=gnu89 -pthread -Wall -Wextra
2CFLAGS += -I../../../../usr/include/ 2CFLAGS += -I../../../../usr/include/
3LDFLAGS += -pthread 3LDFLAGS += -pthread
4 4
5TEST_PROGS = sync_test 5.PHONY: all clean
6
7all: $(TEST_PROGS)
8 6
9include ../lib.mk 7include ../lib.mk
10 8
9# lib.mk TEST_CUSTOM_PROGS var is for custom tests that need special
10# build rules. lib.mk will run and install them.
11
12TEST_CUSTOM_PROGS := $(OUTPUT)/sync_test
13all: $(TEST_CUSTOM_PROGS)
14
11OBJS = sync_test.o sync.o 15OBJS = sync_test.o sync.o
12 16
13TESTS += sync_alloc.o 17TESTS += sync_alloc.o
@@ -18,6 +22,16 @@ TESTS += sync_stress_parallelism.o
18TESTS += sync_stress_consumer.o 22TESTS += sync_stress_consumer.o
19TESTS += sync_stress_merge.o 23TESTS += sync_stress_merge.o
20 24
21sync_test: $(OBJS) $(TESTS) 25OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS))
26TESTS := $(patsubst %,$(OUTPUT)/%,$(TESTS))
27
28$(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS)
29 $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS)
30
31$(OBJS): $(OUTPUT)/%.o: %.c
32 $(CC) -c $^ -o $@
33
34$(TESTS): $(OUTPUT)/%.o: %.c
35 $(CC) -c $^ -o $@
22 36
23EXTRA_CLEAN := sync_test $(OBJS) $(TESTS) 37EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS)
diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing/selftests/timers/set-timer-lat.c
index 9c92b7bd5641..50da45437daa 100644
--- a/tools/testing/selftests/timers/set-timer-lat.c
+++ b/tools/testing/selftests/timers/set-timer-lat.c
@@ -143,7 +143,8 @@ int setup_timer(int clock_id, int flags, int interval, timer_t *tm1)
143 printf("%-22s %s missing CAP_WAKE_ALARM? : [UNSUPPORTED]\n", 143 printf("%-22s %s missing CAP_WAKE_ALARM? : [UNSUPPORTED]\n",
144 clockstring(clock_id), 144 clockstring(clock_id),
145 flags ? "ABSTIME":"RELTIME"); 145 flags ? "ABSTIME":"RELTIME");
146 return 0; 146 /* Indicate timer isn't set, so caller doesn't wait */
147 return 1;
147 } 148 }
148 printf("%s - timer_create() failed\n", clockstring(clock_id)); 149 printf("%s - timer_create() failed\n", clockstring(clock_id));
149 return -1; 150 return -1;
@@ -213,8 +214,9 @@ int do_timer(int clock_id, int flags)
213 int err; 214 int err;
214 215
215 err = setup_timer(clock_id, flags, interval, &tm1); 216 err = setup_timer(clock_id, flags, interval, &tm1);
217 /* Unsupported case - return 0 to not fail the test */
216 if (err) 218 if (err)
217 return err; 219 return err == 1 ? 0 : err;
218 220
219 while (alarmcount < 5) 221 while (alarmcount < 5)
220 sleep(1); 222 sleep(1);
@@ -228,18 +230,17 @@ int do_timer_oneshot(int clock_id, int flags)
228 timer_t tm1; 230 timer_t tm1;
229 const int interval = 0; 231 const int interval = 0;
230 struct timeval timeout; 232 struct timeval timeout;
231 fd_set fds;
232 int err; 233 int err;
233 234
234 err = setup_timer(clock_id, flags, interval, &tm1); 235 err = setup_timer(clock_id, flags, interval, &tm1);
236 /* Unsupported case - return 0 to not fail the test */
235 if (err) 237 if (err)
236 return err; 238 return err == 1 ? 0 : err;
237 239
238 memset(&timeout, 0, sizeof(timeout)); 240 memset(&timeout, 0, sizeof(timeout));
239 timeout.tv_sec = 5; 241 timeout.tv_sec = 5;
240 FD_ZERO(&fds);
241 do { 242 do {
242 err = select(FD_SETSIZE, &fds, NULL, NULL, &timeout); 243 err = select(0, NULL, NULL, NULL, &timeout);
243 } while (err == -1 && errno == EINTR); 244 } while (err == -1 && errno == EINTR);
244 245
245 timer_delete(tm1); 246 timer_delete(tm1);
diff --git a/tools/testing/selftests/watchdog/Makefile b/tools/testing/selftests/watchdog/Makefile
index f863c664e3d1..ee068511fd0b 100644
--- a/tools/testing/selftests/watchdog/Makefile
+++ b/tools/testing/selftests/watchdog/Makefile
@@ -1,8 +1,3 @@
1TEST_PROGS := watchdog-test 1TEST_GEN_PROGS := watchdog-test
2
3all: $(TEST_PROGS)
4 2
5include ../lib.mk 3include ../lib.mk
6
7clean:
8 rm -fr $(TEST_PROGS)