/linux-6.14.4/rust/kernel/ |
D | miscdevice.rs | 34 // SAFETY: All zeros is valid for this C type. in into_raw() 56 // SAFETY: It is allowed to call `misc_deregister` on a different thread from where you called 59 // SAFETY: All `&self` methods on this type are written to ensure that it is safe to call them in 68 // SAFETY: The initializer can write to the provided `slot`. in register() 71 // SAFETY: We just wrote the misc device options to the slot. The miscdevice will in register() 89 // SAFETY: This can only be called after a successful register(), which always in device() 101 // SAFETY: We know that the device is registered by the type invariants. in drop() 189 // SAFETY: All zeros is a valid value for `bindings::file_operations`. in create_vtable() 197 /// # Safety 205 // SAFETY: The pointers are valid and for a file being opened. in fops_open() [all …]
|
D | list.rs | 43 // SAFETY: This is a container of `ListArc<T, ID>`, and access to the container allows the same 51 // SAFETY: This is a container of `ListArc<T, ID>`, and access to the container allows the same 62 /// # Safety 79 /// # Safety 93 /// # Safety 109 /// # Safety 126 /// # Safety 152 // SAFETY: The only way to access/modify the pointers inside of `ListLinks<ID>` is via holding the 156 // SAFETY: The type is opaque so immutable references to a ListLinks are useless. Therefore, it's 173 /// # Safety [all …]
|
D | transmute.rs | 12 /// # Safety 19 // SAFETY: Safety comments written in the macro invocation. 25 // SAFETY: All bit patterns are acceptable values of the types below. 29 // SAFETY: If all bit patterns are acceptable for individual values in an array, then all bit 44 /// this is a correctness requirement, but not a safety requirement. 46 /// # Safety 54 // SAFETY: Safety comments written in the macro invocation. 60 // SAFETY: Instances of the following types have no uninitialized portions. 67 // SAFETY: If individual values in an array have no uninitialized portions, then the array
|
D | pci.rs | 26 // SAFETY: A call to `unregister` for a given instance of `RegType` is guaranteed to be valid if 36 // SAFETY: It's safe to set the fields of `struct pci_driver` on initialization. in register() 44 // SAFETY: `pdrv` is guaranteed to be a valid `RegType`. in register() 51 // SAFETY: `pdrv` is guaranteed to be a valid `RegType`. in unregister() 61 // SAFETY: The PCI bus only ever calls the probe callback with a valid pointer to a in probe_callback() 64 // SAFETY: `dev` is guaranteed to be embedded in a valid `struct pci_dev` by the call in probe_callback() 68 // SAFETY: `DeviceId` is a `#[repr(transparent)` wrapper of `struct pci_device_id` and in probe_callback() 76 // SAFETY: By the type invariant `pdev.as_raw` returns a valid pointer to a in probe_callback() 87 // SAFETY: The PCI bus only ever calls the remove callback with a valid pointer to a in remove_callback() 91 // SAFETY: `remove_callback` is only ever called after a successful call to in remove_callback() [all …]
|
D | cred.rs | 34 // SAFETY: 39 // SAFETY: It's OK to access `Credential` through shared references from other threads because 46 /// # Safety 51 // SAFETY: The safety requirements guarantee the validity of the dereference, while the in from_ptr() 59 // SAFETY: The invariants of this type ensures that the pointer is valid. in get_secid() 66 // SAFETY: By the type invariant, we know that `self.0` is valid. Furthermore, the `euid` in euid() 73 // SAFETY: The type invariants guarantee that `Credential` is always ref-counted. 76 // SAFETY: The existence of a shared reference means that the refcount is nonzero. in inc_ref() 81 // SAFETY: The safety requirements guarantee that the refcount is nonzero. The cast is okay in dec_ref()
|
D | task.rs | 34 // SAFETY: Deref + addr-of below create a temporary `TaskRef` that cannot outlive the 44 // SAFETY: Deref + addr-of below create a temporary `PidNamespaceRef` that cannot outlive 97 // SAFETY: By design, the only way to access a `Task` is via the `current` function or via an 103 // SAFETY: It's OK to access `Task` through shared references from other threads because we're 123 // SAFETY: Getting the current pointer is always safe. in current_raw() 132 /// # Safety 151 // SAFETY: If the current thread is still running, the current task is valid. Given in current() 166 /// # Safety 237 // SAFETY: The current task's pid namespace is valid as long as the current task is running. in current_pid_ns() 240 // SAFETY: If the current thread is still running, the current task and its associated in current_pid_ns() [all …]
|
D | pid_namespace.rs | 35 /// # Safety 40 // SAFETY: The safety requirements guarantee the validity of the dereference, while the in from_ptr() 46 // SAFETY: Instances of `PidNamespace` are always reference-counted. 50 // SAFETY: The existence of a shared reference means that the refcount is nonzero. in inc_ref() 56 // SAFETY: The safety requirements guarantee that the refcount is non-zero. in dec_ref() 61 // SAFETY: 66 // SAFETY: It's OK to access `PidNamespace` through shared references from other threads because
|
D | workqueue.rs | 158 // SAFETY: Accesses to workqueues used by [`Queue`] are thread-safe. 160 // SAFETY: Accesses to workqueues used by [`Queue`] are thread-safe. 166 /// # Safety 171 // SAFETY: The `Queue` type is `#[repr(transparent)]`, so the pointer cast is valid. The in from_raw() 187 // SAFETY: We only return `false` if the `work_struct` is already in a workqueue. The other in enqueue() 239 // SAFETY: The `func` field is not structurally pinned. in project() 267 /// # Safety 287 /// # Safety 311 /// # Safety 321 /// # Safety [all …]
|
D | rbtree.rs | 176 // SAFETY: An [`RBTree`] allows the same kinds of access to its values that a struct allows to its 180 // SAFETY: An [`RBTree`] allows the same kinds of access to its values that a struct allows to its 202 // SAFETY: by the invariants, all pointers are valid. in iter() 217 // SAFETY: by the invariants, all pointers are valid. in iter_mut() 242 // SAFETY: `self.root` is always a valid root node in cursor_front() 257 // SAFETY: `self.root` is always a valid root node in cursor_back() 327 // SAFETY: `raw_self` is a valid pointer to the `RBTree` (created from `self` above). in raw_entry() 331 // SAFETY: All links fields we create are in a `Node<K, V>`. in raw_entry() 334 // SAFETY: `node` is a non-null node so it is valid by the type invariants. in raw_entry() 336 // SAFETY: `curr` is a non-null node so it is valid by the type invariants. in raw_entry() [all …]
|
D | device.rs | 50 /// # Safety 59 // SAFETY: By the safety requirements ptr is valid in get_device() 70 /// # Safety 77 // SAFETY: Guaranteed by the safety requirements of the function. in as_ref() 87 // SAFETY: `klevel` is null-terminated, uses one of the kernel constants. in pr_emerg() 97 // SAFETY: `klevel` is null-terminated, uses one of the kernel constants. in pr_alert() 107 // SAFETY: `klevel` is null-terminated, uses one of the kernel constants. in pr_crit() 117 // SAFETY: `klevel` is null-terminated, uses one of the kernel constants. in pr_err() 127 // SAFETY: `klevel` is null-terminated, uses one of the kernel constants. in pr_warn() 137 // SAFETY: `klevel` is null-terminated, uses one of the kernel constants. in pr_notice() [all …]
|
D | page.rs | 42 // SAFETY: Pages have no logic that relies on them staying on a given thread, so moving them across 46 // SAFETY: Pages have no logic that relies on them not being accessed concurrently, so accessing 73 // SAFETY: Depending on the value of `gfp_flags`, this call may sleep. Other than that, it in alloc_page() 104 // SAFETY: `page` is valid due to the type invariants on `Page`. in with_page_mapped() 111 // SAFETY: Since this API takes the user code as a closure, it can only be used in a manner in with_page_mapped() 154 // SAFETY: The `off` integer is at most `PAGE_SIZE`, so this pointer offset will in with_pointer_into_page() 168 /// # Safety 175 // SAFETY: If `with_pointer_into_page` calls into this closure, then in read_raw() 190 /// # Safety 197 // SAFETY: If `with_pointer_into_page` calls into this closure, then it has performed a in write_raw() [all …]
|
D | revocable.rs | 71 // SAFETY: `Revocable` is `Send` if the wrapped object is also `Send`. This is because while the 76 // SAFETY: `Revocable` is `Sync` if the wrapped object is both `Send` and `Sync`. We require `Send` 118 // SAFETY: Since `self.is_available` is true, data is initialised and has to remain in try_access_with_guard() 126 /// # Safety 132 // SAFETY: Just an FFI call, there are no further requirements. in revoke_internal() 136 // SAFETY: We know `self.data` is valid because only one CPU can succeed the in revoke_internal() 147 /// # Safety 151 // SAFETY: By the safety requirement of this function, the caller ensures that nobody is in revoke_nosync() 165 // SAFETY: By passing `true` we ask `revoke_internal` to wait for the grace period to in revoke() 176 // SAFETY: We are not moving out of `p`, only dropping in place in drop() [all …]
|
/linux-6.14.4/rust/kernel/alloc/ |
D | kbox.rs | 102 // SAFETY: `Box` is `Send` if `T` is `Send` because the `Box` owns a `T`. 110 // SAFETY: `Box` is `Sync` if `T` is `Sync` because the `Box` owns a `T`. 125 /// # Safety 134 // INVARIANT: Validity of `raw` is guaranteed by the safety preconditions of this function. in from_raw() 135 // SAFETY: By the safety preconditions of this function, `raw` is not a NULL pointer. in from_raw() 150 /// // SAFETY: `ptr` comes from a previous call to `KBox::into_raw`. 166 // SAFETY: `Box::into_raw` always returns a properly aligned and dereferenceable pointer in leak() 181 /// # Safety 187 // SAFETY: `raw` comes from a previous call to `Box::into_raw`. By the safety requirements in assume_init() 197 // SAFETY: We've just initialized `b`'s value. in write() [all …]
|
D | allocator.rs | 74 /// # Safety 76 /// This method has the same safety requirements as [`Allocator::realloc`]. 102 // SAFETY: in call() 105 // - `ptr` is either NULL or valid by the safety requirements of this function. in call() 125 // SAFETY: `realloc` delegates to `ReallocFunc::call`, which guarantees that 137 // SAFETY: `ReallocFunc::call` has the same safety requirements as `Allocator::realloc`. in realloc() 142 // SAFETY: `realloc` delegates to `ReallocFunc::call`, which guarantees that 160 // SAFETY: If not `None`, `ptr` is guaranteed to point to valid memory, which was previously in realloc() 166 // SAFETY: `realloc` delegates to `ReallocFunc::call`, which guarantees that 184 // SAFETY: If not `None`, `ptr` is guaranteed to point to valid memory, which was previously in realloc()
|
/linux-6.14.4/rust/kernel/sync/ |
D | lock.rs | 29 /// # Safety 51 /// # Safety 63 /// # Safety 71 /// # Safety 78 /// # Safety 85 /// # Safety 90 // SAFETY: The safety requirements ensure that the lock is initialised. in relock() 96 /// # Safety 123 // SAFETY: `Lock` can be transferred across thread boundaries iff the data it protects can. 126 // SAFETY: `Lock` serialises the interior mutability it provides, so it is `Sync` as long as the [all …]
|
D | arc.rs | 153 /// # Safety 159 // SAFETY: The caller guarantees that the pointer is valid. in container_of() 161 // SAFETY: We're computing the layout of a real struct that existed when compiling this in container_of() 172 // SAFETY: The pointer is in-bounds of an allocation both before and after offsetting the in container_of() 177 // SAFETY: The pointer can't be null since you can't have an `ArcInner<T>` value at the null in container_of() 192 // SAFETY: It is safe to send `Arc<T>` to another thread when the underlying `T` is `Sync` because 198 // SAFETY: It is safe to send `&Arc<T>` to another thread when the underlying `T` is `Sync` 210 // SAFETY: There are no safety requirements for this FFI call. in new() 218 // SAFETY: We just created `inner` with a reference count of 1, which is owned by the new in new() 227 /// # Safety [all …]
|
/linux-6.14.4/Documentation/translations/zh_CN/rust/ |
D | coding-guidelines.rst | 53 此外,就像文档一样,注释在句子的开头要大写,并以句号结束(即使是单句)。这包括 ``// SAFETY:``, 80 一种特殊的注释是 ``// SAFETY:`` 注释。这些注释必须出现在每个 ``unsafe`` 块之前,它们 85 // SAFETY: `p` is valid by the safety requirements. 88 ``// SAFETY:`` 注释不能与代码文档中的 ``# Safety`` 部分相混淆。 ``# Safety`` 部 90 ``// SAFETY:`` 注释显示了为什么一个(函数)调用者或(特性)实现者实际上尊重了 91 ``# Safety`` 部分或语言参考中的前提条件。 111 /// # Safety 127 // SAFETY: The safety contract must be upheld by the caller. 137 - 不安全的函数必须在 ``# Safety`` 部分记录其安全前提条件。 150 - 任何 ``unsafe`` 的代码块都必须在前面加上一个 ``// SAFETY:`` 的注释,描述里面
|
/linux-6.14.4/rust/kernel/list/ |
D | impl_list_item_mod.rs | 15 /// # Safety 26 /// # Safety 35 // SAFETY: The caller promises that the pointer is valid. The implementer promises that the in raw_get_list_links() 49 // SAFETY: The implementation of `raw_get_list_links` only compiles if the field has the 61 // SAFETY: The caller promises that the pointer is not dangling. We know that this 73 /// # Safety 91 // SAFETY: The implementation of `raw_get_list_links` only compiles if the field has the 104 // SAFETY: The caller promises that the pointer is not dangling. 127 // SAFETY: See GUARANTEES comment on each method. 135 // SAFETY: The caller guarantees that `me` points at a valid value of type `Self`. [all …]
|
D | arc.rs | 26 /// safety issues. 39 /// # Safety 46 /// # Safety 54 /// # Safety 101 // SAFETY: This field is structurally pinned as per the above assertion. 105 // SAFETY: The caller promises that there is no `ListArc`. 111 // SAFETY: The caller promises that there is no `ListArc` reference, and also 220 // SAFETY: We have a `UniqueArc`, so there is no `ListArc`. in from() 223 // SAFETY: We just called `on_create_list_arc_from_unique` on an arc without a `ListArc`, in from() 256 // SAFETY: We have a `UniqueArc`, so there is no `ListArc`. in pair_from_pin_unique() [all …]
|
/linux-6.14.4/rust/kernel/block/mq/ |
D | operations.rs | 59 /// # Safety 76 // SAFETY: `bd.rq` is valid as required by the safety requirement for in queue_rq_callback() 83 // SAFETY: in queue_rq_callback() 85 // - By the safety requirements of this function, `request` is a valid in queue_rq_callback() 91 // SAFETY: We have exclusive access and we just set the refcount above. in queue_rq_callback() 96 // SAFETY: `bd` is valid as required by the safety requirement for in queue_rq_callback() 111 /// # Safety 121 /// # Safety 129 /// # Safety 142 /// # Safety [all …]
|
D | request.rs | 61 /// # Safety 69 // INVARIANT: By the safety requirements of this function, invariants are upheld. in aref_from_raw() 70 // SAFETY: By the safety requirement of this function, we own a in aref_from_raw() 81 /// # Safety 86 // SAFETY: By type invariant, `self.0` is a valid `struct request` and in start_unchecked() 124 // SAFETY: By type invariant, `this.0` was a valid `struct request`. The in end_ok() 136 /// # Safety 142 // SAFETY: By safety requirements for this function, `this` is a in wrapper_ptr() 146 // SAFETY: By C API contract, wrapper_ptr points to a valid allocation in wrapper_ptr() 154 // SAFETY: By type invariant, `self.0` is a valid allocation. Further, in wrapper_ref() [all …]
|
/linux-6.14.4/rust/kernel/init/ |
D | __internal.rs | 20 /// It is unsafe to create this type, since the closure needs to fulfill the same safety 24 // SAFETY: While constructing the `InitClosure`, the user promised that it upholds the 36 // SAFETY: While constructing the `InitClosure`, the user promised that it upholds the 51 /// # Safety 63 /// # Safety 81 /// # Safety 93 /// # Safety 118 // SAFETY: TODO. 123 // SAFETY: TODO. 148 // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is in drop() [all …]
|
/linux-6.14.4/rust/kernel/net/ |
D | phy.rs | 79 /// # Safety 89 // SAFETY: by the function requirements the pointer is valid and we have unique access for in from_raw() 97 // SAFETY: The struct invariant ensures that we may access in phy_id() 105 // SAFETY: The struct invariant ensures that we may access in state() 130 // SAFETY: The struct invariant ensures that we may access in is_link_up() 142 // SAFETY: The struct invariant ensures that we may access in is_autoneg_enabled() 155 // SAFETY: The struct invariant ensures that we may access in is_autoneg_completed() 164 // SAFETY: The struct invariant ensures that we may access in set_speed() 177 // SAFETY: The struct invariant ensures that we may access in set_duplex() 196 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in read_paged() [all …]
|
/linux-6.14.4/rust/kernel/fs/ |
D | file.rs | 183 // SAFETY: This file is known to not have any active `fdget_pos` calls that did not take the 187 // SAFETY: This file is known to not have any active `fdget_pos` calls that did not take the 191 // SAFETY: The type invariants guarantee that `File` is always ref-counted. This implementation 196 // SAFETY: The existence of a shared reference means that the refcount is nonzero. in inc_ref() 202 // SAFETY: To call this method, the caller passes us ownership of a normal refcount, so we in dec_ref() 226 // SAFETY: The type invariants guarantee that `LocalFile` is always ref-counted. This implementation 231 // SAFETY: The existence of a shared reference means that the refcount is nonzero. in inc_ref() 237 // SAFETY: To call this method, the caller passes us ownership of a normal refcount, so we in dec_ref() 254 // SAFETY: FFI call, there are no requirements on `fd`. in fget() 257 // SAFETY: `bindings::fget` created a refcount, and we pass ownership of it to the `ARef`. in fget() [all …]
|
/linux-6.14.4/rust/kernel/sync/lock/ |
D | global.rs | 42 /// # Safety 58 /// # Safety 62 // SAFETY: The pointer to `state` is valid for the duration of this call, and both `name` in init() 122 // SAFETY: The same thread-safety rules as `LockedBy` apply to `GlobalLockedBy`. 131 // SAFETY: The same thread-safety rules as `LockedBy` apply to `GlobalLockedBy`. 157 // SAFETY: The lock is globally unique, so there can only be one guard. in as_ref() 165 // SAFETY: The lock is globally unique, so there can only be one guard. in as_mut() 191 /// // SAFETY: Initialized in module initializer before first use. 203 /// // SAFETY: Called exactly once. 221 /// // SAFETY: Initialized in module initializer before first use. [all …]
|