xref: /linux/include/uapi/linux/user_events.h (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * Copyright (c) 2021-2022, Microsoft Corporation.
4  *
5  * Authors:
6  *   Beau Belgrave <beaub@linux.microsoft.com>
7  */
8 #ifndef _UAPI_LINUX_USER_EVENTS_H
9 #define _UAPI_LINUX_USER_EVENTS_H
10 
11 #include <linux/types.h>
12 #include <linux/ioctl.h>
13 
14 #define USER_EVENTS_SYSTEM "user_events"
15 #define USER_EVENTS_MULTI_SYSTEM "user_events_multi"
16 #define USER_EVENTS_PREFIX "u:"
17 
18 /* Create dynamic location entry within a 32-bit value */
19 #define DYN_LOC(offset, size) ((size) << 16 | (offset))
20 
21 /* List of supported registration flags */
22 enum user_reg_flag {
23 	/* Event will not delete upon last reference closing */
24 	USER_EVENT_REG_PERSIST		= 1U << 0,
25 
26 	/* Event will be allowed to have multiple formats */
27 	USER_EVENT_REG_MULTI_FORMAT	= 1U << 1,
28 
29 	/* This value or above is currently non-ABI */
30 	USER_EVENT_REG_MAX		= 1U << 2,
31 };
32 
33 /*
34  * Describes an event registration and stores the results of the registration.
35  * This structure is passed to the DIAG_IOCSREG ioctl, callers at a minimum
36  * must set the size and name_args before invocation.
37  */
38 struct user_reg {
39 
40 	/* Input: Size of the user_reg structure being used */
41 	__u32	size;
42 
43 	/* Input: Bit in enable address to use */
44 	__u8	enable_bit;
45 
46 	/* Input: Enable size in bytes at address */
47 	__u8	enable_size;
48 
49 	/* Input: Flags to use, if any */
50 	__u16	flags;
51 
52 	/* Input: Address to update when enabled */
53 	__u64	enable_addr;
54 
55 	/* Input: Pointer to string with event name, description and flags */
56 	__u64	name_args;
57 
58 	/* Output: Index of the event to use when writing data */
59 	__u32	write_index;
60 } __attribute__((__packed__));
61 
62 /*
63  * Describes an event unregister, callers must set the size, address and bit.
64  * This structure is passed to the DIAG_IOCSUNREG ioctl to disable bit updates.
65  */
66 struct user_unreg {
67 	/* Input: Size of the user_unreg structure being used */
68 	__u32	size;
69 
70 	/* Input: Bit to unregister */
71 	__u8	disable_bit;
72 
73 	/* Input: Reserved, set to 0 */
74 	__u8	__reserved;
75 
76 	/* Input: Reserved, set to 0 */
77 	__u16	__reserved2;
78 
79 	/* Input: Address to unregister */
80 	__u64	disable_addr;
81 } __attribute__((__packed__));
82 
83 #define DIAG_IOC_MAGIC '*'
84 
85 /* Request to register a user_event */
86 #define DIAG_IOCSREG _IOWR(DIAG_IOC_MAGIC, 0, struct user_reg *)
87 
88 /* Request to delete a user_event */
89 #define DIAG_IOCSDEL _IOW(DIAG_IOC_MAGIC, 1, char *)
90 
91 /* Requests to unregister a user_event */
92 #define DIAG_IOCSUNREG _IOW(DIAG_IOC_MAGIC, 2, struct user_unreg*)
93 
94 #endif /* _UAPI_LINUX_USER_EVENTS_H */
95