Skip to content

Commit 5c519bc

Browse files
committed
Merge tag 'perf-tools-fixes-for-v6.6-1-2023-09-25' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools
Pull perf tools fixes from Namhyung Kim: "Build: - Update header files in the tools/**/include directory to sync with the kernel sources as usual. - Remove unused bpf-prologue files. While it's not strictly a fix, but the functionality was removed in this cycle so better to get rid of the code together. - Other minor build fixes. Misc: - Fix uninitialized memory access in PMU parsing code - Fix segfaults on software event" * tag 'perf-tools-fixes-for-v6.6-1-2023-09-25' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools: perf jevent: fix core dump on software events on s390 perf pmu: Ensure all alias variables are initialized perf jevents metric: Fix type of strcmp_cpuid_str perf trace: Avoid compile error wrt redefining bool perf bpf-prologue: Remove unused file tools headers UAPI: Update tools's copy of drm.h headers tools arch x86: Sync the msr-index.h copy with the kernel sources perf bench sched-seccomp-notify: Use the tools copy of seccomp.h UAPI tools headers UAPI: Copy seccomp.h to be able to build 'perf bench' in older systems tools headers UAPI: Sync files changed by new fchmodat2 and map_shadow_stack syscalls with the kernel sources perf tools: Update copy of libbpf's hashmap.c
2 parents 6465e26 + e47749f commit 5c519bc

16 files changed

Lines changed: 255 additions & 539 deletions

File tree

tools/arch/x86/include/asm/msr-index.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
#define MSR_IA32_PRED_CMD 0x00000049 /* Prediction Command */
5959
#define PRED_CMD_IBPB BIT(0) /* Indirect Branch Prediction Barrier */
60+
#define PRED_CMD_SBPB BIT(7) /* Selective Branch Prediction Barrier */
6061

6162
#define MSR_PPIN_CTL 0x0000004e
6263
#define MSR_PPIN 0x0000004f
@@ -155,6 +156,15 @@
155156
* Not susceptible to Post-Barrier
156157
* Return Stack Buffer Predictions.
157158
*/
159+
#define ARCH_CAP_GDS_CTRL BIT(25) /*
160+
* CPU is vulnerable to Gather
161+
* Data Sampling (GDS) and
162+
* has controls for mitigation.
163+
*/
164+
#define ARCH_CAP_GDS_NO BIT(26) /*
165+
* CPU is not vulnerable to Gather
166+
* Data Sampling (GDS).
167+
*/
158168

159169
#define ARCH_CAP_XAPIC_DISABLE BIT(21) /*
160170
* IA32_XAPIC_DISABLE_STATUS MSR
@@ -178,6 +188,8 @@
178188
#define RNGDS_MITG_DIS BIT(0) /* SRBDS support */
179189
#define RTM_ALLOW BIT(1) /* TSX development mode */
180190
#define FB_CLEAR_DIS BIT(3) /* CPU Fill buffer clear disable */
191+
#define GDS_MITG_DIS BIT(4) /* Disable GDS mitigation */
192+
#define GDS_MITG_LOCKED BIT(5) /* GDS mitigation locked */
181193

182194
#define MSR_IA32_SYSENTER_CS 0x00000174
183195
#define MSR_IA32_SYSENTER_ESP 0x00000175

tools/include/uapi/asm-generic/unistd.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,11 @@ __SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node)
820820
#define __NR_cachestat 451
821821
__SYSCALL(__NR_cachestat, sys_cachestat)
822822

823+
#define __NR_fchmodat2 452
824+
__SYSCALL(__NR_fchmodat2, sys_fchmodat2)
825+
823826
#undef __NR_syscalls
824-
#define __NR_syscalls 452
827+
#define __NR_syscalls 453
825828

826829
/*
827830
* 32 bit systems traditionally used different

tools/include/uapi/drm/drm.h

Lines changed: 69 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -673,22 +673,29 @@ struct drm_gem_open {
673673
* Bitfield of supported PRIME sharing capabilities. See &DRM_PRIME_CAP_IMPORT
674674
* and &DRM_PRIME_CAP_EXPORT.
675675
*
676-
* PRIME buffers are exposed as dma-buf file descriptors. See
677-
* Documentation/gpu/drm-mm.rst, section "PRIME Buffer Sharing".
676+
* Starting from kernel version 6.6, both &DRM_PRIME_CAP_IMPORT and
677+
* &DRM_PRIME_CAP_EXPORT are always advertised.
678+
*
679+
* PRIME buffers are exposed as dma-buf file descriptors.
680+
* See :ref:`prime_buffer_sharing`.
678681
*/
679682
#define DRM_CAP_PRIME 0x5
680683
/**
681684
* DRM_PRIME_CAP_IMPORT
682685
*
683686
* If this bit is set in &DRM_CAP_PRIME, the driver supports importing PRIME
684687
* buffers via the &DRM_IOCTL_PRIME_FD_TO_HANDLE ioctl.
688+
*
689+
* Starting from kernel version 6.6, this bit is always set in &DRM_CAP_PRIME.
685690
*/
686691
#define DRM_PRIME_CAP_IMPORT 0x1
687692
/**
688693
* DRM_PRIME_CAP_EXPORT
689694
*
690695
* If this bit is set in &DRM_CAP_PRIME, the driver supports exporting PRIME
691696
* buffers via the &DRM_IOCTL_PRIME_HANDLE_TO_FD ioctl.
697+
*
698+
* Starting from kernel version 6.6, this bit is always set in &DRM_CAP_PRIME.
692699
*/
693700
#define DRM_PRIME_CAP_EXPORT 0x2
694701
/**
@@ -756,15 +763,14 @@ struct drm_gem_open {
756763
/**
757764
* DRM_CAP_SYNCOBJ
758765
*
759-
* If set to 1, the driver supports sync objects. See
760-
* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects".
766+
* If set to 1, the driver supports sync objects. See :ref:`drm_sync_objects`.
761767
*/
762768
#define DRM_CAP_SYNCOBJ 0x13
763769
/**
764770
* DRM_CAP_SYNCOBJ_TIMELINE
765771
*
766772
* If set to 1, the driver supports timeline operations on sync objects. See
767-
* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects".
773+
* :ref:`drm_sync_objects`.
768774
*/
769775
#define DRM_CAP_SYNCOBJ_TIMELINE 0x14
770776

@@ -909,6 +915,27 @@ struct drm_syncobj_timeline_wait {
909915
__u32 pad;
910916
};
911917

918+
/**
919+
* struct drm_syncobj_eventfd
920+
* @handle: syncobj handle.
921+
* @flags: Zero to wait for the point to be signalled, or
922+
* &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE to wait for a fence to be
923+
* available for the point.
924+
* @point: syncobj timeline point (set to zero for binary syncobjs).
925+
* @fd: Existing eventfd to sent events to.
926+
* @pad: Must be zero.
927+
*
928+
* Register an eventfd to be signalled by a syncobj. The eventfd counter will
929+
* be incremented by one.
930+
*/
931+
struct drm_syncobj_eventfd {
932+
__u32 handle;
933+
__u32 flags;
934+
__u64 point;
935+
__s32 fd;
936+
__u32 pad;
937+
};
938+
912939

913940
struct drm_syncobj_array {
914941
__u64 handles;
@@ -1169,6 +1196,8 @@ extern "C" {
11691196
*/
11701197
#define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2)
11711198

1199+
#define DRM_IOCTL_SYNCOBJ_EVENTFD DRM_IOWR(0xCF, struct drm_syncobj_eventfd)
1200+
11721201
/*
11731202
* Device specific ioctls should only be in their respective headers
11741203
* The device specific ioctl range is from 0x40 to 0x9f.
@@ -1180,25 +1209,50 @@ extern "C" {
11801209
#define DRM_COMMAND_BASE 0x40
11811210
#define DRM_COMMAND_END 0xA0
11821211

1183-
/*
1184-
* Header for events written back to userspace on the drm fd. The
1185-
* type defines the type of event, the length specifies the total
1186-
* length of the event (including the header), and user_data is
1187-
* typically a 64 bit value passed with the ioctl that triggered the
1188-
* event. A read on the drm fd will always only return complete
1189-
* events, that is, if for example the read buffer is 100 bytes, and
1190-
* there are two 64 byte events pending, only one will be returned.
1212+
/**
1213+
* struct drm_event - Header for DRM events
1214+
* @type: event type.
1215+
* @length: total number of payload bytes (including header).
11911216
*
1192-
* Event types 0 - 0x7fffffff are generic drm events, 0x80000000 and
1193-
* up are chipset specific.
1217+
* This struct is a header for events written back to user-space on the DRM FD.
1218+
* A read on the DRM FD will always only return complete events: e.g. if the
1219+
* read buffer is 100 bytes large and there are two 64 byte events pending,
1220+
* only one will be returned.
1221+
*
1222+
* Event types 0 - 0x7fffffff are generic DRM events, 0x80000000 and
1223+
* up are chipset specific. Generic DRM events include &DRM_EVENT_VBLANK,
1224+
* &DRM_EVENT_FLIP_COMPLETE and &DRM_EVENT_CRTC_SEQUENCE.
11941225
*/
11951226
struct drm_event {
11961227
__u32 type;
11971228
__u32 length;
11981229
};
11991230

1231+
/**
1232+
* DRM_EVENT_VBLANK - vertical blanking event
1233+
*
1234+
* This event is sent in response to &DRM_IOCTL_WAIT_VBLANK with the
1235+
* &_DRM_VBLANK_EVENT flag set.
1236+
*
1237+
* The event payload is a struct drm_event_vblank.
1238+
*/
12001239
#define DRM_EVENT_VBLANK 0x01
1240+
/**
1241+
* DRM_EVENT_FLIP_COMPLETE - page-flip completion event
1242+
*
1243+
* This event is sent in response to an atomic commit or legacy page-flip with
1244+
* the &DRM_MODE_PAGE_FLIP_EVENT flag set.
1245+
*
1246+
* The event payload is a struct drm_event_vblank.
1247+
*/
12011248
#define DRM_EVENT_FLIP_COMPLETE 0x02
1249+
/**
1250+
* DRM_EVENT_CRTC_SEQUENCE - CRTC sequence event
1251+
*
1252+
* This event is sent in response to &DRM_IOCTL_CRTC_QUEUE_SEQUENCE.
1253+
*
1254+
* The event payload is a struct drm_event_crtc_sequence.
1255+
*/
12021256
#define DRM_EVENT_CRTC_SEQUENCE 0x03
12031257

12041258
struct drm_event_vblank {

tools/include/uapi/linux/seccomp.h

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
#ifndef _UAPI_LINUX_SECCOMP_H
3+
#define _UAPI_LINUX_SECCOMP_H
4+
5+
#include <linux/compiler.h>
6+
#include <linux/types.h>
7+
8+
9+
/* Valid values for seccomp.mode and prctl(PR_SET_SECCOMP, <mode>) */
10+
#define SECCOMP_MODE_DISABLED 0 /* seccomp is not in use. */
11+
#define SECCOMP_MODE_STRICT 1 /* uses hard-coded filter. */
12+
#define SECCOMP_MODE_FILTER 2 /* uses user-supplied filter. */
13+
14+
/* Valid operations for seccomp syscall. */
15+
#define SECCOMP_SET_MODE_STRICT 0
16+
#define SECCOMP_SET_MODE_FILTER 1
17+
#define SECCOMP_GET_ACTION_AVAIL 2
18+
#define SECCOMP_GET_NOTIF_SIZES 3
19+
20+
/* Valid flags for SECCOMP_SET_MODE_FILTER */
21+
#define SECCOMP_FILTER_FLAG_TSYNC (1UL << 0)
22+
#define SECCOMP_FILTER_FLAG_LOG (1UL << 1)
23+
#define SECCOMP_FILTER_FLAG_SPEC_ALLOW (1UL << 2)
24+
#define SECCOMP_FILTER_FLAG_NEW_LISTENER (1UL << 3)
25+
#define SECCOMP_FILTER_FLAG_TSYNC_ESRCH (1UL << 4)
26+
/* Received notifications wait in killable state (only respond to fatal signals) */
27+
#define SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV (1UL << 5)
28+
29+
/*
30+
* All BPF programs must return a 32-bit value.
31+
* The bottom 16-bits are for optional return data.
32+
* The upper 16-bits are ordered from least permissive values to most,
33+
* as a signed value (so 0x8000000 is negative).
34+
*
35+
* The ordering ensures that a min_t() over composed return values always
36+
* selects the least permissive choice.
37+
*/
38+
#define SECCOMP_RET_KILL_PROCESS 0x80000000U /* kill the process */
39+
#define SECCOMP_RET_KILL_THREAD 0x00000000U /* kill the thread */
40+
#define SECCOMP_RET_KILL SECCOMP_RET_KILL_THREAD
41+
#define SECCOMP_RET_TRAP 0x00030000U /* disallow and force a SIGSYS */
42+
#define SECCOMP_RET_ERRNO 0x00050000U /* returns an errno */
43+
#define SECCOMP_RET_USER_NOTIF 0x7fc00000U /* notifies userspace */
44+
#define SECCOMP_RET_TRACE 0x7ff00000U /* pass to a tracer or disallow */
45+
#define SECCOMP_RET_LOG 0x7ffc0000U /* allow after logging */
46+
#define SECCOMP_RET_ALLOW 0x7fff0000U /* allow */
47+
48+
/* Masks for the return value sections. */
49+
#define SECCOMP_RET_ACTION_FULL 0xffff0000U
50+
#define SECCOMP_RET_ACTION 0x7fff0000U
51+
#define SECCOMP_RET_DATA 0x0000ffffU
52+
53+
/**
54+
* struct seccomp_data - the format the BPF program executes over.
55+
* @nr: the system call number
56+
* @arch: indicates system call convention as an AUDIT_ARCH_* value
57+
* as defined in <linux/audit.h>.
58+
* @instruction_pointer: at the time of the system call.
59+
* @args: up to 6 system call arguments always stored as 64-bit values
60+
* regardless of the architecture.
61+
*/
62+
struct seccomp_data {
63+
int nr;
64+
__u32 arch;
65+
__u64 instruction_pointer;
66+
__u64 args[6];
67+
};
68+
69+
struct seccomp_notif_sizes {
70+
__u16 seccomp_notif;
71+
__u16 seccomp_notif_resp;
72+
__u16 seccomp_data;
73+
};
74+
75+
struct seccomp_notif {
76+
__u64 id;
77+
__u32 pid;
78+
__u32 flags;
79+
struct seccomp_data data;
80+
};
81+
82+
/*
83+
* Valid flags for struct seccomp_notif_resp
84+
*
85+
* Note, the SECCOMP_USER_NOTIF_FLAG_CONTINUE flag must be used with caution!
86+
* If set by the process supervising the syscalls of another process the
87+
* syscall will continue. This is problematic because of an inherent TOCTOU.
88+
* An attacker can exploit the time while the supervised process is waiting on
89+
* a response from the supervising process to rewrite syscall arguments which
90+
* are passed as pointers of the intercepted syscall.
91+
* It should be absolutely clear that this means that the seccomp notifier
92+
* _cannot_ be used to implement a security policy! It should only ever be used
93+
* in scenarios where a more privileged process supervises the syscalls of a
94+
* lesser privileged process to get around kernel-enforced security
95+
* restrictions when the privileged process deems this safe. In other words,
96+
* in order to continue a syscall the supervising process should be sure that
97+
* another security mechanism or the kernel itself will sufficiently block
98+
* syscalls if arguments are rewritten to something unsafe.
99+
*
100+
* Similar precautions should be applied when stacking SECCOMP_RET_USER_NOTIF
101+
* or SECCOMP_RET_TRACE. For SECCOMP_RET_USER_NOTIF filters acting on the
102+
* same syscall, the most recently added filter takes precedence. This means
103+
* that the new SECCOMP_RET_USER_NOTIF filter can override any
104+
* SECCOMP_IOCTL_NOTIF_SEND from earlier filters, essentially allowing all
105+
* such filtered syscalls to be executed by sending the response
106+
* SECCOMP_USER_NOTIF_FLAG_CONTINUE. Note that SECCOMP_RET_TRACE can equally
107+
* be overriden by SECCOMP_USER_NOTIF_FLAG_CONTINUE.
108+
*/
109+
#define SECCOMP_USER_NOTIF_FLAG_CONTINUE (1UL << 0)
110+
111+
struct seccomp_notif_resp {
112+
__u64 id;
113+
__s64 val;
114+
__s32 error;
115+
__u32 flags;
116+
};
117+
118+
#define SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP (1UL << 0)
119+
120+
/* valid flags for seccomp_notif_addfd */
121+
#define SECCOMP_ADDFD_FLAG_SETFD (1UL << 0) /* Specify remote fd */
122+
#define SECCOMP_ADDFD_FLAG_SEND (1UL << 1) /* Addfd and return it, atomically */
123+
124+
/**
125+
* struct seccomp_notif_addfd
126+
* @id: The ID of the seccomp notification
127+
* @flags: SECCOMP_ADDFD_FLAG_*
128+
* @srcfd: The local fd number
129+
* @newfd: Optional remote FD number if SETFD option is set, otherwise 0.
130+
* @newfd_flags: The O_* flags the remote FD should have applied
131+
*/
132+
struct seccomp_notif_addfd {
133+
__u64 id;
134+
__u32 flags;
135+
__u32 srcfd;
136+
__u32 newfd;
137+
__u32 newfd_flags;
138+
};
139+
140+
#define SECCOMP_IOC_MAGIC '!'
141+
#define SECCOMP_IO(nr) _IO(SECCOMP_IOC_MAGIC, nr)
142+
#define SECCOMP_IOR(nr, type) _IOR(SECCOMP_IOC_MAGIC, nr, type)
143+
#define SECCOMP_IOW(nr, type) _IOW(SECCOMP_IOC_MAGIC, nr, type)
144+
#define SECCOMP_IOWR(nr, type) _IOWR(SECCOMP_IOC_MAGIC, nr, type)
145+
146+
/* Flags for seccomp notification fd ioctl. */
147+
#define SECCOMP_IOCTL_NOTIF_RECV SECCOMP_IOWR(0, struct seccomp_notif)
148+
#define SECCOMP_IOCTL_NOTIF_SEND SECCOMP_IOWR(1, \
149+
struct seccomp_notif_resp)
150+
#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOW(2, __u64)
151+
/* On success, the return value is the remote process's added fd number */
152+
#define SECCOMP_IOCTL_NOTIF_ADDFD SECCOMP_IOW(3, \
153+
struct seccomp_notif_addfd)
154+
155+
#define SECCOMP_IOCTL_NOTIF_SET_FLAGS SECCOMP_IOW(4, __u64)
156+
157+
#endif /* _UAPI_LINUX_SECCOMP_H */

tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,4 @@
366366
449 n64 futex_waitv sys_futex_waitv
367367
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
368368
451 n64 cachestat sys_cachestat
369+
452 n64 fchmodat2 sys_fchmodat2

tools/perf/arch/powerpc/entry/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,3 +538,4 @@
538538
449 common futex_waitv sys_futex_waitv
539539
450 nospu set_mempolicy_home_node sys_set_mempolicy_home_node
540540
451 common cachestat sys_cachestat
541+
452 common fchmodat2 sys_fchmodat2

tools/perf/arch/s390/entry/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,3 +454,4 @@
454454
449 common futex_waitv sys_futex_waitv sys_futex_waitv
455455
450 common set_mempolicy_home_node sys_set_mempolicy_home_node sys_set_mempolicy_home_node
456456
451 common cachestat sys_cachestat sys_cachestat
457+
452 common fchmodat2 sys_fchmodat2 sys_fchmodat2

tools/perf/arch/x86/entry/syscalls/syscall_64.tbl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@
373373
449 common futex_waitv sys_futex_waitv
374374
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
375375
451 common cachestat sys_cachestat
376+
452 common fchmodat2 sys_fchmodat2
377+
453 64 map_shadow_stack sys_map_shadow_stack
376378

377379
#
378380
# Due to a historical design error, certain syscalls are numbered differently

tools/perf/bench/sched-seccomp-notify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <sys/syscall.h>
1010
#include <sys/ioctl.h>
1111
#include <linux/time64.h>
12-
#include <linux/seccomp.h>
12+
#include <uapi/linux/seccomp.h>
1313
#include <sys/prctl.h>
1414

1515
#include <unistd.h>

tools/perf/check-headers.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ FILES=(
2121
"include/uapi/linux/perf_event.h"
2222
"include/uapi/linux/prctl.h"
2323
"include/uapi/linux/sched.h"
24+
"include/uapi/linux/seccomp.h"
2425
"include/uapi/linux/stat.h"
2526
"include/uapi/linux/usbdevice_fs.h"
2627
"include/uapi/linux/vhost.h"

0 commit comments

Comments
 (0)