Skip to content

Commit

Permalink
NetBSD specific changes:
Browse files Browse the repository at this point in the history
- NetBSD overcommits
- When mapping pages, use the maximum of the alignment requested and the
  compiled-in PAGE constant which might be greater than the current kernel
  pagesize, since we compile binaries with the maximum page size supported
  by the architecture (so that they work with all kernels).
  • Loading branch information
zoulasc authored and davidtgoldblatt committed Feb 3, 2020
1 parent 974222c commit 536ea68
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/pages.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include <vm/vm_param.h>
#endif
#endif
#ifdef __NetBSD__
#include <sys/bitops.h> /* ilog2 */
#endif

/******************************************************************************/
/* Data. */
Expand Down Expand Up @@ -74,6 +77,18 @@ os_pages_map(void *addr, size_t size, size_t alignment, bool *commit) {
* of existing mappings, and we only want to create new mappings.
*/
{
#ifdef __NetBSD__
/*
* On NetBSD PAGE for a platform is defined to the
* maximum page size of all machine architectures
* for that platform, so that we can use the same
* binaries across all machine architectures.
*/
if (alignment > os_page || PAGE > os_page) {
unsigned int a = ilog2(MAX(alignment, PAGE));
mmap_flags |= MAP_ALIGNED(a);
}
#endif
int prot = *commit ? PAGES_PROT_COMMIT : PAGES_PROT_DECOMMIT;

ret = mmap(addr, size, prot, mmap_flags, -1, 0);
Expand Down Expand Up @@ -622,6 +637,8 @@ pages_boot(void) {
mmap_flags |= MAP_NORESERVE;
}
# endif
#elif defined(__NetBSD__)
os_overcommits = true;
#else
os_overcommits = false;
#endif
Expand Down

0 comments on commit 536ea68

Please sign in to comment.