diff --git a/Kernel/Memory/Region.h b/Kernel/Memory/Region.h index f2807a4cbe6..a3d947de2ee 100644 --- a/Kernel/Memory/Region.h +++ b/Kernel/Memory/Region.h @@ -43,9 +43,6 @@ public: Read = 1, Write = 2, Execute = 4, - HasBeenReadable = 16, - HasBeenWritable = 32, - HasBeenExecutable = 64, ReadOnly = Read, ReadWrite = Read | Write, ReadWriteExecute = Read | Write | Execute, @@ -69,9 +66,9 @@ public: [[nodiscard]] bool is_writable() const { return (m_access & Access::Write) == Access::Write; } [[nodiscard]] bool is_executable() const { return (m_access & Access::Execute) == Access::Execute; } - [[nodiscard]] bool has_been_readable() const { return (m_access & Access::HasBeenReadable) == Access::HasBeenReadable; } - [[nodiscard]] bool has_been_writable() const { return (m_access & Access::HasBeenWritable) == Access::HasBeenWritable; } - [[nodiscard]] bool has_been_executable() const { return (m_access & Access::HasBeenExecutable) == Access::HasBeenExecutable; } + [[nodiscard]] bool has_been_readable() const { return m_has_been_readable.was_set(); } + [[nodiscard]] bool has_been_writable() const { return m_has_been_writable.was_set(); } + [[nodiscard]] bool has_been_executable() const { return m_has_been_executable.was_set(); } [[nodiscard]] bool is_cacheable() const { return m_cacheable; } [[nodiscard]] StringView name() const { return m_name ? m_name->view() : StringView {}; } @@ -188,9 +185,24 @@ public: [[nodiscard]] size_t cow_pages() const; - void set_readable(bool b) { set_access_bit(Access::Read, b); } - void set_writable(bool b) { set_access_bit(Access::Write, b); } - void set_executable(bool b) { set_access_bit(Access::Execute, b); } + void set_readable(bool b) + { + set_access_bit(Access::Read, b); + if (b) + m_has_been_readable.set(); + } + void set_writable(bool b) + { + set_access_bit(Access::Write, b); + if (b) + m_has_been_writable.set(); + } + void set_executable(bool b) + { + set_access_bit(Access::Execute, b); + if (b) + m_has_been_executable.set(); + } void unsafe_clear_access() { m_access = Region::None; } @@ -224,7 +236,7 @@ private: void set_access_bit(Access access, bool b) { if (b) - m_access |= access | (access << 4); + m_access |= access; else m_access &= ~access; } @@ -254,6 +266,9 @@ private: SetOnce m_immutable; SetOnce m_initially_loaded_executable_segment; + SetOnce m_has_been_readable; + SetOnce m_has_been_writable; + SetOnce m_has_been_executable; IntrusiveRedBlackTreeNode> m_tree_node; IntrusiveListNode m_vmobject_list_node;