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_PREFIX "u:" 16 17 /* Create dynamic location entry within a 32-bit value */ 18 #define DYN_LOC(offset, size) ((size) << 16 | (offset)) 19 20 /* List of supported registration flags */ 21 enum user_reg_flag { 22 /* Event will not delete upon last reference closing */ 23 USER_EVENT_REG_PERSIST = 1U << 0, 24 25 /* This value or above is currently non-ABI */ 26 USER_EVENT_REG_MAX = 1U << 1, 27 }; 28 29 /* 30 * Describes an event registration and stores the results of the registration. 31 * This structure is passed to the DIAG_IOCSREG ioctl, callers at a minimum 32 * must set the size and name_args before invocation. 33 */ 34 struct user_reg { 35 36 /* Input: Size of the user_reg structure being used */ 37 __u32 size; 38 39 /* Input: Bit in enable address to use */ 40 __u8 enable_bit; 41 42 /* Input: Enable size in bytes at address */ 43 __u8 enable_size; 44 45 /* Input: Flags to use, if any */ 46 __u16 flags; 47 48 /* Input: Address to update when enabled */ 49 __u64 enable_addr; 50 51 /* Input: Pointer to string with event name, description and flags */ 52 __u64 name_args; 53 54 /* Output: Index of the event to use when writing data */ 55 __u32 write_index; 56 } __attribute__((__packed__)); 57 58 /* 59 * Describes an event unregister, callers must set the size, address and bit. 60 * This structure is passed to the DIAG_IOCSUNREG ioctl to disable bit updates. 61 */ 62 struct user_unreg { 63 /* Input: Size of the user_unreg structure being used */ 64 __u32 size; 65 66 /* Input: Bit to unregister */ 67 __u8 disable_bit; 68 69 /* Input: Reserved, set to 0 */ 70 __u8 __reserved; 71 72 /* Input: Reserved, set to 0 */ 73 __u16 __reserved2; 74 75 /* Input: Address to unregister */ 76 __u64 disable_addr; 77 } __attribute__((__packed__)); 78 79 #define DIAG_IOC_MAGIC '*' 80 81 /* Request to register a user_event */ 82 #define DIAG_IOCSREG _IOWR(DIAG_IOC_MAGIC, 0, struct user_reg *) 83 84 /* Request to delete a user_event */ 85 #define DIAG_IOCSDEL _IOW(DIAG_IOC_MAGIC, 1, char *) 86 87 /* Requests to unregister a user_event */ 88 #define DIAG_IOCSUNREG _IOW(DIAG_IOC_MAGIC, 2, struct user_unreg*) 89 90 #endif /* _UAPI_LINUX_USER_EVENTS_H */ 91