git: df696a2fb640 - main - Have the coredump_phnum test ask for the page size
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 07 Apr 2022 14:59:53 UTC
The branch main has been updated by andrew:
URL: https://cgit.FreeBSD.org/src/commit/?id=df696a2fb640aee06b38ff487985209f97b944aa
commit df696a2fb640aee06b38ff487985209f97b944aa
Author: Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2022-04-07 14:59:32 +0000
Commit: Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2022-04-07 14:59:32 +0000
Have the coredump_phnum test ask for the page size
The page size may be dynamically selected on boot. Have the
coredump_phnum test helper ask the kernel for the correct value.
Sponsored by: The FreeBSD Foundation
---
tests/sys/kern/coredump_phnum_helper.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tests/sys/kern/coredump_phnum_helper.c b/tests/sys/kern/coredump_phnum_helper.c
index 0dff59b918d9..1cdd4a4a09ec 100644
--- a/tests/sys/kern/coredump_phnum_helper.c
+++ b/tests/sys/kern/coredump_phnum_helper.c
@@ -33,6 +33,7 @@
#include <err.h>
#include <stdint.h>
#include <stdlib.h>
+#include <unistd.h>
/*
* This program is intended to create a bunch of segment mappings, then dump
@@ -42,10 +43,11 @@ int
main(int argc __unused, char **argv __unused)
{
void *v;
- size_t i, pages;
+ size_t i, pages, page_size;
+ page_size = getpagesize();
pages = UINT16_MAX + 1000;
- v = mmap(NULL, pages * PAGE_SIZE, PROT_READ | PROT_WRITE,
+ v = mmap(NULL, pages * page_size, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE, -1, 0);
if (v == NULL)
err(1, "mmap");
@@ -54,7 +56,7 @@ main(int argc __unused, char **argv __unused)
* Alternate protections to interleave RW and R PT_LOAD
* segments.
*/
- if (mprotect((char *)v + i * PAGE_SIZE, PAGE_SIZE,
+ if (mprotect((char *)v + i * page_size, page_size,
PROT_READ) != 0)
err(1, "mprotect");
}