![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 0002 #ifndef _UAPI_LINUX_RSEQ_H 0003 #define _UAPI_LINUX_RSEQ_H 0004 0005 /* 0006 * linux/rseq.h 0007 * 0008 * Restartable sequences system call API 0009 * 0010 * Copyright (c) 2015-2018 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> 0011 */ 0012 0013 #include <linux/types.h> 0014 #include <asm/byteorder.h> 0015 0016 enum rseq_cpu_id_state { 0017 RSEQ_CPU_ID_UNINITIALIZED = -1, 0018 RSEQ_CPU_ID_REGISTRATION_FAILED = -2, 0019 }; 0020 0021 enum rseq_flags { 0022 RSEQ_FLAG_UNREGISTER = (1 << 0), 0023 }; 0024 0025 enum rseq_cs_flags_bit { 0026 RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT_BIT = 0, 0027 RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL_BIT = 1, 0028 RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT = 2, 0029 }; 0030 0031 enum rseq_cs_flags { 0032 RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT = 0033 (1U << RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT_BIT), 0034 RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL = 0035 (1U << RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL_BIT), 0036 RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE = 0037 (1U << RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT), 0038 }; 0039 0040 /* 0041 * struct rseq_cs is aligned on 4 * 8 bytes to ensure it is always 0042 * contained within a single cache-line. It is usually declared as 0043 * link-time constant data. 0044 */ 0045 struct rseq_cs { 0046 /* Version of this structure. */ 0047 __u32 version; 0048 /* enum rseq_cs_flags */ 0049 __u32 flags; 0050 __u64 start_ip; 0051 /* Offset from start_ip. */ 0052 __u64 post_commit_offset; 0053 __u64 abort_ip; 0054 } __attribute__((aligned(4 * sizeof(__u64)))); 0055 0056 /* 0057 * struct rseq is aligned on 4 * 8 bytes to ensure it is always 0058 * contained within a single cache-line. 0059 * 0060 * A single struct rseq per thread is allowed. 0061 */ 0062 struct rseq { 0063 /* 0064 * Restartable sequences cpu_id_start field. Updated by the 0065 * kernel. Read by user-space with single-copy atomicity 0066 * semantics. This field should only be read by the thread which 0067 * registered this data structure. Aligned on 32-bit. Always 0068 * contains a value in the range of possible CPUs, although the 0069 * value may not be the actual current CPU (e.g. if rseq is not 0070 * initialized). This CPU number value should always be compared 0071 * against the value of the cpu_id field before performing a rseq 0072 * commit or returning a value read from a data structure indexed 0073 * using the cpu_id_start value. 0074 */ 0075 __u32 cpu_id_start; 0076 /* 0077 * Restartable sequences cpu_id field. Updated by the kernel. 0078 * Read by user-space with single-copy atomicity semantics. This 0079 * field should only be read by the thread which registered this 0080 * data structure. Aligned on 32-bit. Values 0081 * RSEQ_CPU_ID_UNINITIALIZED and RSEQ_CPU_ID_REGISTRATION_FAILED 0082 * have a special semantic: the former means "rseq uninitialized", 0083 * and latter means "rseq initialization failed". This value is 0084 * meant to be read within rseq critical sections and compared 0085 * with the cpu_id_start value previously read, before performing 0086 * the commit instruction, or read and compared with the 0087 * cpu_id_start value before returning a value loaded from a data 0088 * structure indexed using the cpu_id_start value. 0089 */ 0090 __u32 cpu_id; 0091 /* 0092 * Restartable sequences rseq_cs field. 0093 * 0094 * Contains NULL when no critical section is active for the current 0095 * thread, or holds a pointer to the currently active struct rseq_cs. 0096 * 0097 * Updated by user-space, which sets the address of the currently 0098 * active rseq_cs at the beginning of assembly instruction sequence 0099 * block, and set to NULL by the kernel when it restarts an assembly 0100 * instruction sequence block, as well as when the kernel detects that 0101 * it is preempting or delivering a signal outside of the range 0102 * targeted by the rseq_cs. Also needs to be set to NULL by user-space 0103 * before reclaiming memory that contains the targeted struct rseq_cs. 0104 * 0105 * Read and set by the kernel. Set by user-space with single-copy 0106 * atomicity semantics. This field should only be updated by the 0107 * thread which registered this data structure. Aligned on 64-bit. 0108 * 0109 * 32-bit architectures should update the low order bits of the 0110 * rseq_cs field, leaving the high order bits initialized to 0. 0111 */ 0112 __u64 rseq_cs; 0113 0114 /* 0115 * Restartable sequences flags field. 0116 * 0117 * This field should only be updated by the thread which 0118 * registered this data structure. Read by the kernel. 0119 * Mainly used for single-stepping through rseq critical sections 0120 * with debuggers. 0121 * 0122 * - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT 0123 * Inhibit instruction sequence block restart on preemption 0124 * for this thread. 0125 * - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL 0126 * Inhibit instruction sequence block restart on signal 0127 * delivery for this thread. 0128 * - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE 0129 * Inhibit instruction sequence block restart on migration for 0130 * this thread. 0131 */ 0132 __u32 flags; 0133 } __attribute__((aligned(4 * sizeof(__u64)))); 0134 0135 #endif /* _UAPI_LINUX_RSEQ_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |