about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-09-08 10:35:09 +0200
committerRalf Jung <post@ralfj.de>2023-10-15 17:41:50 +0200
commit69b62ecc69ce42967eefb08c40d59c6b6f4a6d5a (patch)
tree0b1e695e4bc45f5b612e734811a9077e43b64470
parent07b8c10ed89c64d7cb03e16cf9f61509100a3a2b (diff)
downloadrust-69b62ecc69ce42967eefb08c40d59c6b6f4a6d5a.tar.gz
rust-69b62ecc69ce42967eefb08c40d59c6b6f4a6d5a.zip
define 'read-only memory'
-rw-r--r--library/core/src/sync/atomic.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs
index b3f277654a7..6adf199a763 100644
--- a/library/core/src/sync/atomic.rs
+++ b/library/core/src/sync/atomic.rs
@@ -81,12 +81,19 @@
 //!
 //! # Atomic accesses to read-only memory
 //!
-//! In general, atomic accesses on read-only memory are Undefined Behavior. For instance, attempting
+//! In general, *all* atomic accesses on read-only memory are Undefined Behavior. For instance, attempting
 //! to do a `compare_exchange` that will definitely fail (making it conceptually a read-only
 //! operation) can still cause a page fault if the underlying memory page is mapped read-only. Since
 //! atomic `load`s might be implemented using compare-exchange operations, even a `load` can fault
 //! on read-only memory.
 //!
+//! For the purpose of this section, "read-only memory" is defined as memory that is read-only in
+//! the underlying target, i.e., the pages are mapped with a read-only flag and any attempt to write
+//! will cause a page fault. In particular, an `&u128` reference that points to memory that is
+//! read-write mapped is *not* considered to point to "read-only memory". In Rust, almost all memory
+//! is read-write; the only exceptions are memory created by `const` items or `static` items without
+//! interior mutability.
+//!
 //! However, as an exception from this general rule, Rust guarantees that "sufficiently small"
 //! atomic loads are implemented in a way that works on read-only memory. This threshold of
 //! "sufficiently small" depends on the architecture: