mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
Kernel: Fix mmap with specific address for file backed mappings
This commit is contained in:
parent
79818bbf8e
commit
d64d0451e5
Notes:
sideshowbarker
2024-07-19 00:37:45 +09:00
Author: https://github.com/itamar8910 Commit: https://github.com/SerenityOS/serenity/commit/d64d0451e56
1 changed files with 10 additions and 6 deletions
|
@ -133,18 +133,22 @@ void* Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> user_params)
|
|||
return (void*)-EINVAL;
|
||||
|
||||
Region* region = nullptr;
|
||||
|
||||
auto range = allocate_range(VirtualAddress(addr), size, alignment);
|
||||
if (!range.is_valid())
|
||||
return (void*)-ENOMEM;
|
||||
Optional<Range> range;
|
||||
if (map_purgeable || map_anonymous) {
|
||||
range = allocate_range(VirtualAddress(addr), size, alignment);
|
||||
if (!range.value().is_valid())
|
||||
return (void*)-ENOMEM;
|
||||
}
|
||||
|
||||
if (map_purgeable) {
|
||||
|
||||
auto vmobject = PurgeableVMObject::create_with_size(size);
|
||||
region = allocate_region_with_vmobject(range, vmobject, 0, !name.is_null() ? name : "mmap (purgeable)", prot);
|
||||
region = allocate_region_with_vmobject(range.value(), vmobject, 0, !name.is_null() ? name : "mmap (purgeable)", prot);
|
||||
if (!region && (!map_fixed && addr != 0))
|
||||
region = allocate_region_with_vmobject({}, size, vmobject, 0, !name.is_null() ? name : "mmap (purgeable)", prot);
|
||||
} else if (map_anonymous) {
|
||||
region = allocate_region(range, !name.is_null() ? name : "mmap", prot, false);
|
||||
|
||||
region = allocate_region(range.value(), !name.is_null() ? name : "mmap", prot, false);
|
||||
if (!region && (!map_fixed && addr != 0))
|
||||
region = allocate_region(allocate_range({}, size), !name.is_null() ? name : "mmap", prot, false);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue