aboutsummaryrefslogtreecommitdiff
path: root/vm
Commit message (Collapse)AuthorAgeFilesLines
...
* sign-extend mask in vm_map() with 32-bit userspaceLuca Dariz2022-08-281-0/+5
| | | | | | | * vm/vm_user.c: sign-extend mask with USER32 Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-6-luca@orpolo.org>
* fix warnings for 32 bit buildsLuca Dariz2022-08-272-1/+2
| | | | | Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-13-luca@orpolo.org>
* gnumach: vm_allocate_contiguous: Allow small power 2 alignmentsDamien Zammit2022-08-211-0/+4
| | | | | | | | | | This allows contiguous allocations aligned to values smaller than one page, but still a power of 2, by forcing the alignment to be to the nearest page. This works because PAGE_SIZE is a power of two. Message-Id: <20220821065732.269573-1-damien@zamaudio.com>
* vm_object_page_map: update prototypeSamuel Thibault2022-02-181-1/+1
|
* vm_allocate_contiguous: fix checking the end of the allocationSamuel Thibault2022-02-171-1/+1
|
* mach_vm_object_pages: Print a warning if the physical address is beyond 4GiBSamuel Thibault2022-02-171-0/+2
| | | | vpi_offset is not currently large enough to store it.
* vm_allocate_contiguous: Make sure we enforce physical addresses contraintsSamuel Thibault2022-02-171-0/+3
|
* projected_buffer_*: Fix storing physical addressSamuel Thibault2022-02-171-3/+5
|
* vm_object: Fix vm_object_page_map map function prototypeSamuel Thibault2022-02-161-2/+2
| | | | The map function is supposed to return physical addresses, thus phys_addr_t.
* vm_wire: extend per-task wiring limit to 8MiBSamuel Thibault2021-12-161-1/+1
| | | | Like Linux just did.
* Fix rejecting the mapping of some pagesSamuel Thibault2021-11-282-4/+7
| | | | | | The memmmap method may reject some offsets (because it falls in non-device ranges), so device_map_page has to notice this and report the error. device_pager_data_request then has to notice as well and report.
* vm_region_get_proxy: rename to create_proxySergey Bugaev2021-11-071-4/+4
| | | | For coherency with memory_object_create_proxy.
* Memory proxies: Add support for anonymous mappingsSergey Bugaev2021-11-071-4/+17
| | | | | | | | * vm/vm_map.c (vm_region_get_proxy): - Return KERN_INVALID_ARGUMENT when the entry is a submap. - Create a pager for the vm_object when the entry doesn't have any yet, since it's an anonymous mapping. Message-Id: <20211106081333.10366-3-jlledom@mailfence.com>
* vm: vm_region_get_proxyJoan Lledó2021-11-072-0/+64
| | | | | | | | | To get a proxy to the region a given address belongs to, with protection and range limited to the region ones. * include/mach/mach4.defs: vm_region_get_proxy RPC declaration * vm/vm_map.c: vm_region_get_proxy implementation Message-Id: <20211106081333.10366-2-jlledom@mailfence.com>
* memory_object_create_proxy: Fix and check coherency with RPCSamuel Thibault2021-11-071-4/+5
| | | | | * vm/memory_object_proxy.c: Include kern/mach4.server.h. (memory_object_create_proxy): Drop const qualifiers.
* memory_object_create_proxy: Make len parameter vm_size_array_tSamuel Thibault2021-10-171-1/+1
| | | | | | | | | | | This is a no-op on i386. * i386/include/mach/i386/vm_types.h (vm_size_array_t): New type. * include/mach/mach4.defs (vm_size_array_t): New type. (memory_object_create_proxy): Turn len parameter from vm_offset_array_t to vm_size_array_t. * vm/memory_object_proxy.c (memory_object_create_proxy): Turn len parameter from const vm_offset_t * to const vm_size_t *.
* vm_page_grab: allow allocating in high memorySamuel Thibault2021-08-274-9/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | vm_page_grab was systematically using the VM_PAGE_SEL_DIRECTMAP selector to play safe with existing code. This adds a flags parameter to let callers of vm_page_grab specify their constraints. Linux drivers need 32bit dmas, Xen drivers use kvtophys to clear some data. Callers of kmem_pagealloc_physmem and vm_page_grab_phys_addr also use kvtophys. Otherwise allocations can go to highmem. This fixes the allocation jam in the directmap segment. * vm/vm_page.h (VM_PAGE_DMA, VM_PAGE_DMA32, VM_PAGE_DIRECTMAP, VM_PAGE_HIGHMEM): New macros. (vm_page_grab): Add flags parameter. * vm/vm_resident.c (vm_page_grab): Choose allocation selector according to flags parameter. (vm_page_convert, vm_page_alloc): Pass VM_PAGE_HIGHMEM to vm_page_grab. (vm_page_grab_phys_addr): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * vm/vm_fault.c (vm_fault_page): Pass VM_PAGE_HIGHMEM to vm_page_grab. * vm/vm_map.c (vm_map_copy_steal_pages): Pass VM_PAGE_HIGHMEM to vm_page_grab. * kern/slab.c (kmem_pagealloc_physmem): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * i386/intel/pmap.c (pmap_page_table_page_alloc): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * xen/block.c (device_read): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * linux/dev/glue/block.c (alloc_buffer): Pass VM_PAGE_DMA32 to vm_page_grab.
* db_show_vmstat: Show segment name rather than its numberSamuel Thibault2021-08-231-1/+1
|
* db_show_vmstat: Also show segment sizeSamuel Thibault2021-08-221-0/+2
| | | | * vm/vm_page.c (db_show_vmstat): Add printing the segment size.
* db_show_vmstat: Drop duplicate outputSamuel Thibault2021-08-221-3/+0
| | | | | * vm/vm_page.c (db_show_vmstat): Drop displaying cache numbers a second time.
* db show vmstat: also show segments statsSamuel Thibault2021-08-211-0/+23
| | | | * vm/vm_page.c (db_show_vmstat)
* db: Add show vmstat commandSamuel Thibault2021-08-212-0/+48
| | | | | | | | with an output similar to the userland vmstat command * vm/vm_page.c (db_show_vmstat): New function. * vm/vm_page.h (db_show_vmstat): New prototype. * ddb/db_command.c (db_show_cmds): Add vmstat command.
* memory_object_proxy: Deliver no-sender notifications on a separate portSamuel Thibault2021-08-091-4/+13
| | | | Otherwise userland can send spurious notifications.
* memory_object_proxy: Fix send port right leakSamuel Thibault2021-08-091-1/+2
| | | | On success we'd have to clean the port right. Just consume it.
* memory_object_proxy: Fix checking proxy lengthSamuel Thibault2021-08-091-1/+8
| | | | | We want to prevent subproxies from requesting larger sizes than what a proxy initially allowed.
* Memory object proxy: add support for ranges and nestingJoan Lledó2021-08-093-19/+38
|
* memory_object_proxy: release resources on no-send notificationSamuel Thibault2021-08-091-0/+6
|
* vm_map: Allow exagerated max_prot for nowSamuel Thibault2021-06-061-3/+3
| | | | | | | glibc's mmap implementation assumes that gnumach will cap the prot for it, so for now let's revert back to capping rather than rejecting. That fixes mmap(SHARED|READ) for read-only objects.
* Revert "vm_map: Allow passing the name of a memory object"Samuel Thibault2021-05-241-4/+2
| | | | This reverts commit af9f471b500bcd0c1023259c7577e074fe6d3ee5.
* vm_map: Fix proxy object protection checkSergey Bugaev2021-05-241-3/+12
| | | | | | | | | * If not making a copy, don't cap protection to the limit enforced by the proxy, and only require read access. This fixes mapping parts of read-only files MAP_ANON + PROT_READ|PROT_WRITE. * Instead of silently capping protection, return KERN_PROTECTION_FAILURE to the caller like the other vm_*() routines do.
* vm_map: Avoid linking gaps for vm_copy_tSamuel Thibault2021-01-043-20/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This does not make sense, and produces incorrect results (since vme_end is 0, etc.) * vm/vm_map.h (_vm_map_clip_start, _vm_map_clip_end): Add link_gap parameter. * vm/vm_map.c (_vm_map_entry_link): Add link_gap parameter, do not call vm_map_gap_insert if it is 0. (vm_map_entry_link): Set link_gap to 1 in _vm_map_entry_link call. (_vm_map_clip_start): Add link_gap parameter, pass it to _vm_map_entry_link call.. (vm_map_clip_start): Set link_gap_to 1 in _vm_map_clip_start call. (vm_map_copy_entry_link): Set link_gap to 0 in _vm_map_entry_link call. (vm_map_copy_clip_start): Set link_gap_to 0 in _vm_map_clip_start call. (_vm_map_entry_unlink): Add unlink_gap parameter, do not call vm_map_gap_remove if it is 0. (vm_map_entry_unlink): Set unlink_gap to 1 in _vm_map_entry_unlink call. (_vm_map_clip_end): Add link_gap parameter, pass it to _vm_map_entry_link call.. (vm_map_clip_end): Set link_gap_to 1 in _vm_map_clip_end call. (vm_map_copy_entry_unlink): Set unlink_gap to 0 in _vm_map_entry_unlink call. (vm_map_copy_clip_end): Set link_gap_to 0 in _vm_map_clip_end call. * vm/vm_kern.c (projected_buffer_deallocate): set link_gap to 1 in _vm_map_clip_start and _vm_map_clip_end calls.
* vm_map: print warning when max_size gets smaller than sizeSamuel Thibault2021-01-041-0/+2
| | | | | * vm/vm_map.c (vm_map_find_entry_anywhere): Print warning when max_size gets smaller than size.
* vm_map: Fix taking into account high bits in maskSamuel Thibault2020-12-201-2/+29
| | | | | | | | | | | glibc's sysdeps/mach/hurd/dl-sysdep.c has been wanting to use this for decades. * include/string.h (ffs): New declaration. * vm/vm_map.c: Include <string.h>. (vm_map_find_entry_anywhere): Separate out high bits from mask, to compute the maximum offset instead of map->max_offset. * doc/mach.texi (vm_map): Update documentation accordingly.
* vm_kern: Add kmem_alloc_aligned_tableAlmudena Garcia2020-08-122-0/+41
| | | | | | | | This function allows to map a table in a memory page, using its physical address,aligning the start of the page with the start of the table *vm/vm_kern.c (kmem_alloc_aligned_table): New function. Returns a reference for the virtual address of the table. *vm/vm_kern.h (kmem_alloc_aligned_table): New prototype
* Add vm_allocate_contiguous RPCSamuel Thibault2020-07-091-0/+126
| | | | | | | | | | | | | | | | | This allows privileged userland drivers to allocate buffers for e.g. DMA, and thus need them to be physically contiguous and get their physical address. Initial work by Zheng Da, reworked by Richard Braun, Damien Zammit, and myself. * doc/mach.texi (vm_allocate_contiguous): New RPC. * i386/include/mach/i386/machine_types.defs (rpc_phys_addr_t): New type. * i386/include/mach/i386/vm_types.h [!MACH_KERNEL] (phys_addr_t): Set type to 64bits. (rpc_phys_addr_t): New type, always 64bits. * include/mach/gnumach.defs (vm_allocate_contiguous):New RPC. * vm/vm_user.c (vm_allocate_contiguous): New function.
* vm_map: Allow passing the name of a memory objectSamuel Thibault2020-06-201-2/+4
| | | | | | | as is returned by vm_info. * vm/vm_user.c (vm_map): Before trying to vm_object_enter, try to simply lookup the name.
* kmem_alloc_wired: factorize with kmem_vallocSamuel Thibault2020-05-011-49/+3
| | | | * vm/vm_kern.c (kmem_alloc_wired): Factorize with kmem_valloc.
* Add kmem_vallocSamuel Thibault2020-05-012-0/+77
| | | | | | | | | | | Functions like vremap need to allocate some virtual addressing space before making their own mapping. kmem_alloc_wired can be used for that but that wastes memory. * vm/vm_kern.c (kmem_valloc): New function. * vm/vm_kern.h (kmem_valloc): New prototype. * linux/dev/glue/kmem.c (vremap): Call kmem_valloc instead of kmem_alloc_wired. Also check that `offset' is aligned on a page.
* 64bit: Fix vm_size_t sizeSamuel Thibault2020-03-291-2/+2
| | | | | | | | | | It needs to be able to hold > 4G size. * i386/include/mach/i386/vm_types.h (vm_size_t): Set type to unsigned long. * vm/vm_user.c (vm_read, vm_write): Fix type according to RPC. * i386/i386at/model_dep.c (c_boot_entry): Fix format. * device/dev_pager.c (device_pager_data_request): Fix format.
* vm_object_copy_call: Make sure vm_object_enter succeedsSamuel Thibault2020-03-151-0/+1
| | | | | | | Suggested by guy fleury iteriteka <gfleury@disroot.org> * vm/vm_object.c (ipc/mavm_object_copy_call): Make sure vm_object_enter call succeeds.
* satisfy 'werror=parantheses'.guy fleury iteriteka2019-08-311-1/+1
| | | | * vm/vm_map.c(vm_map_msync): explit group of first condition.
* Fix the pointer comparison of different type.guy fleury iteriteka2019-08-311-1/+1
| | | | | * vm/vm_map.c(vm_map_fork): use VM_MAP_NULL instead of PMAP_NULL when compare with new_map.
* fix return KERN_INVALID_ARGUMENT when the map is NULL.guy fleury iteriteka2019-08-301-2/+2
| | | | * vm/vm_map.c(vm_map_msync): Add missing return keyword.
* Fix allocation testSamuel Thibault2019-08-111-1/+1
| | | | | * vm/vm_map.c (vm_map_fork): Check for `new_map` being non-NULL, and not for `new_pmap` a second time.
* Add vm_object_sync supportSamuel Thibault2018-11-033-0/+87
| | | | | | | | | | | | | * include/mach/vm_sync.h: New file. * include/mach/mach_types.h: Include <mach/vm_sync.h> * Makefrag.am (include_mach_HEADERS): Add include/mach/vm_sync.h. * include/mach/mach_types.defs (vm_sync_t): Add type. * include/mach/gnumach.defs (vm_object_sync, vm_msync): Add RPCs. * vm/vm_map.h: Include <mach/vm_sync.h>. (vm_map_msync): New declaration. * vm/vm_map.c (vm_map_msync): New function. * vm/vm_user.c: Include <mach/vm_sync.h> and <kern/mach.server.h>. (vm_object_sync, vm_msync): New functions.
* vm_map: Fix bugs on huge masks parametersSamuel Thibault2018-04-221-2/+4
| | | | | * vm/vm_map.c (vm_map_find_entry_anywhere): Also check that (min + mask) & ~mask remains bigger than min.
* Fix warningSamuel Thibault2018-01-281-1/+1
| | | | * vm/vm_map.c (vm_map_copyout): Fix panic format.
* Drop the register qualifier.Justus Winter2017-10-231-1/+1
| | | | | | | | | * i386/intel/pmap.c: Drop the register qualifier. * ipc/ipc_kmsg.h: Likewise. * kern/bootstrap.c: Likewise. * kern/profile.c: Likewise. * kern/thread.c: Likewise. * vm/vm_object.c: Likewise.
* vm: Remove old memory manager remnants.Justus Winter2017-09-211-5/+0
| | | | | * vm/vm_object.c (vm_object_accept_old_init_protocol): Remove. (vm_object_enter): Adapt.
* vm: Improve error handling.Justus Winter2017-08-141-1/+5
| | | | | * vm/vm_map.c (vm_map_create): Gracefully handle resource exhaustion. (vm_map_fork): Likewise at the callsite.