diff options
-rw-r--r-- | Kernel/Syscalls/fork.cpp | 2 | ||||
-rw-r--r-- | Kernel/VM/Region.cpp | 15 | ||||
-rw-r--r-- | Kernel/VM/Region.h | 8 | ||||
-rw-r--r-- | Kernel/VM/Space.cpp | 6 |
4 files changed, 10 insertions, 21 deletions
diff --git a/Kernel/Syscalls/fork.cpp b/Kernel/Syscalls/fork.cpp index 7ae623c039..f924756498 100644 --- a/Kernel/Syscalls/fork.cpp +++ b/Kernel/Syscalls/fork.cpp @@ -96,7 +96,7 @@ KResultOr<FlatPtr> Process::sys$fork(RegisterState& regs) ScopedSpinLock lock(space().get_lock()); for (auto& region : space().regions()) { dbgln_if(FORK_DEBUG, "fork: cloning Region({}) '{}' @ {}", region, region->name(), region->vaddr()); - auto region_clone = region->clone(*child); + auto region_clone = region->clone(); if (!region_clone) { dbgln("fork: Cannot clone region, insufficient memory"); // TODO: tear down new process? diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp index 6c37f2b029..2a32f7de62 100644 --- a/Kernel/VM/Region.cpp +++ b/Kernel/VM/Region.cpp @@ -52,7 +52,7 @@ Region::~Region() MM.unregister_region(*this); } -OwnPtr<Region> Region::clone(Process& new_owner) +OwnPtr<Region> Region::clone() { VERIFY(Process::current()); @@ -65,7 +65,7 @@ OwnPtr<Region> Region::clone(Process& new_owner) // Create a new region backed by the same VMObject. auto region = Region::try_create_user_accessible( - &new_owner, m_range, m_vmobject, m_offset_in_vmobject, m_name ? m_name->try_clone() : OwnPtr<KString> {}, access(), m_cacheable ? Cacheable::Yes : Cacheable::No, m_shared); + m_range, m_vmobject, m_offset_in_vmobject, m_name ? m_name->try_clone() : OwnPtr<KString> {}, access(), m_cacheable ? Cacheable::Yes : Cacheable::No, m_shared); if (!region) { dbgln("Region::clone: Unable to allocate new Region"); return nullptr; @@ -86,7 +86,7 @@ OwnPtr<Region> Region::clone(Process& new_owner) // Set up a COW region. The parent (this) region becomes COW as well! remap(); auto clone_region = Region::try_create_user_accessible( - &new_owner, m_range, vmobject_clone.release_nonnull(), m_offset_in_vmobject, m_name ? m_name->try_clone() : OwnPtr<KString> {}, access(), m_cacheable ? Cacheable::Yes : Cacheable::No, m_shared); + m_range, vmobject_clone.release_nonnull(), m_offset_in_vmobject, m_name ? m_name->try_clone() : OwnPtr<KString> {}, access(), m_cacheable ? Cacheable::Yes : Cacheable::No, m_shared); if (!clone_region) { dbgln("Region::clone: Unable to allocate new Region for COW"); return nullptr; @@ -147,13 +147,11 @@ size_t Region::amount_shared() const return bytes; } -OwnPtr<Region> Region::try_create_user_accessible(Process* owner, Range const& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, OwnPtr<KString> name, Region::Access access, Cacheable cacheable, bool shared) +OwnPtr<Region> Region::try_create_user_accessible(Range const& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, OwnPtr<KString> name, Region::Access access, Cacheable cacheable, bool shared) { auto region = adopt_own_if_nonnull(new (nothrow) Region(range, move(vmobject), offset_in_vmobject, move(name), access, cacheable, shared)); if (!region) return nullptr; - if (owner) - region->m_owner = owner->make_weak_ptr(); return region; } @@ -463,9 +461,4 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region) return PageFaultResponse::Continue; } -RefPtr<Process> Region::get_owner() -{ - return m_owner.strong_ref(); -} - } diff --git a/Kernel/VM/Region.h b/Kernel/VM/Region.h index af680e6185..d6f0326d01 100644 --- a/Kernel/VM/Region.h +++ b/Kernel/VM/Region.h @@ -8,7 +8,6 @@ #include <AK/EnumBits.h> #include <AK/IntrusiveList.h> -#include <AK/WeakPtr.h> #include <AK/Weakable.h> #include <Kernel/Arch/x86/PageFault.h> #include <Kernel/Forward.h> @@ -47,7 +46,7 @@ public: Yes, }; - static OwnPtr<Region> try_create_user_accessible(Process*, Range const&, NonnullRefPtr<VMObject>, size_t offset_in_vmobject, OwnPtr<KString> name, Region::Access access, Cacheable, bool shared); + static OwnPtr<Region> try_create_user_accessible(Range const&, NonnullRefPtr<VMObject>, size_t offset_in_vmobject, OwnPtr<KString> name, Region::Access access, Cacheable, bool shared); static OwnPtr<Region> try_create_kernel_only(Range const&, NonnullRefPtr<VMObject>, size_t offset_in_vmobject, OwnPtr<KString> name, Region::Access access, Cacheable = Cacheable::Yes); ~Region(); @@ -88,7 +87,7 @@ public: PageFaultResponse handle_fault(PageFault const&); - OwnPtr<Region> clone(Process&); + OwnPtr<Region> clone(); bool contains(VirtualAddress vaddr) const { @@ -205,8 +204,6 @@ public: OutOfMemory }; - RefPtr<Process> get_owner(); - bool is_syscall_region() const { return m_syscall_region; } void set_syscall_region(bool b) { m_syscall_region = b; } @@ -241,7 +238,6 @@ private: bool m_stack : 1 { false }; bool m_mmap : 1 { false }; bool m_syscall_region : 1 { false }; - WeakPtr<Process> m_owner; IntrusiveListNode<Region> m_memory_manager_list_node; IntrusiveListNode<Region> m_vmobject_list_node; diff --git a/Kernel/VM/Space.cpp b/Kernel/VM/Space.cpp index c116285c2b..50764ea362 100644 --- a/Kernel/VM/Space.cpp +++ b/Kernel/VM/Space.cpp @@ -149,7 +149,7 @@ Optional<Range> Space::allocate_range(VirtualAddress vaddr, size_t size, size_t KResultOr<Region*> Space::try_allocate_split_region(Region const& source_region, Range const& range, size_t offset_in_vmobject) { auto new_region = Region::try_create_user_accessible( - m_process, range, source_region.vmobject(), offset_in_vmobject, KString::try_create(source_region.name()), source_region.access(), source_region.is_cacheable() ? Region::Cacheable::Yes : Region::Cacheable::No, source_region.is_shared()); + range, source_region.vmobject(), offset_in_vmobject, KString::try_create(source_region.name()), source_region.access(), source_region.is_cacheable() ? Region::Cacheable::Yes : Region::Cacheable::No, source_region.is_shared()); if (!new_region) return ENOMEM; auto* region = add_region(new_region.release_nonnull()); @@ -172,7 +172,7 @@ KResultOr<Region*> Space::allocate_region(Range const& range, StringView name, i auto vmobject = AnonymousVMObject::try_create_with_size(range.size(), strategy); if (!vmobject) return ENOMEM; - auto region = Region::try_create_user_accessible(m_process, range, vmobject.release_nonnull(), 0, KString::try_create(name), prot_to_region_access_flags(prot), Region::Cacheable::Yes, false); + auto region = Region::try_create_user_accessible(range, vmobject.release_nonnull(), 0, KString::try_create(name), prot_to_region_access_flags(prot), Region::Cacheable::Yes, false); if (!region) return ENOMEM; if (!region->map(page_directory())) @@ -200,7 +200,7 @@ KResultOr<Region*> Space::allocate_region_with_vmobject(Range const& range, Nonn return EINVAL; } offset_in_vmobject &= PAGE_MASK; - auto region = Region::try_create_user_accessible(m_process, range, move(vmobject), offset_in_vmobject, KString::try_create(name), prot_to_region_access_flags(prot), Region::Cacheable::Yes, shared); + auto region = Region::try_create_user_accessible(range, move(vmobject), offset_in_vmobject, KString::try_create(name), prot_to_region_access_flags(prot), Region::Cacheable::Yes, shared); if (!region) { dbgln("allocate_region_with_vmobject: Unable to allocate Region"); return ENOMEM; |