Date: Wed, 9 Sep 2020 21:44:59 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365516 - head/sys/vm Message-ID: <202009092144.089LixkA094838@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Wed Sep 9 21:44:59 2020 New Revision: 365516 URL: https://svnweb.freebsd.org/changeset/base/365516 Log: Add vm_map_find_aligned(9). Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D24652 Modified: head/sys/vm/vm_map.c head/sys/vm/vm_map.h Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Wed Sep 9 21:39:06 2020 (r365515) +++ head/sys/vm/vm_map.c Wed Sep 9 21:44:59 2020 (r365516) @@ -1980,6 +1980,19 @@ vm_map_alignspace(vm_map_t map, vm_object_t object, vm } } +int +vm_map_find_aligned(vm_map_t map, vm_offset_t *addr, vm_size_t length, + vm_offset_t max_addr, vm_offset_t alignment) +{ + /* XXXKIB ASLR eh ? */ + *addr = vm_map_findspace(map, *addr, length); + if (*addr + length > vm_map_max(map) || + (max_addr != 0 && *addr + length > max_addr)) + return (KERN_NO_SPACE); + return (vm_map_alignspace(map, NULL, 0, addr, length, max_addr, + alignment)); +} + /* * vm_map_find finds an unallocated region in the target address * map with the given length. The search is defined to be Modified: head/sys/vm/vm_map.h ============================================================================== --- head/sys/vm/vm_map.h Wed Sep 9 21:39:06 2020 (r365515) +++ head/sys/vm/vm_map.h Wed Sep 9 21:44:59 2020 (r365516) @@ -460,6 +460,8 @@ int vm_map_find(vm_map_t, vm_object_t, vm_ooffset_t, v vm_offset_t, int, vm_prot_t, vm_prot_t, int); int vm_map_find_min(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, vm_size_t, vm_offset_t, vm_offset_t, int, vm_prot_t, vm_prot_t, int); +int vm_map_find_aligned(vm_map_t map, vm_offset_t *addr, vm_size_t length, + vm_offset_t max_addr, vm_offset_t alignment); int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t, vm_prot_t, vm_prot_t, int); vm_offset_t vm_map_findspace(vm_map_t, vm_offset_t, vm_size_t);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009092144.089LixkA094838>