git: 6393594b0362 - main - copyin tests: Use the KERN_PROC_VM_LAYOUT sysctl to fetch layout info
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 17 Jan 2022 21:13:11 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6393594b0362432de937e432908ea6dae79ae0a9 commit 6393594b0362432de937e432908ea6dae79ae0a9 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2022-01-17 16:43:43 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2022-01-17 21:12:43 +0000 copyin tests: Use the KERN_PROC_VM_LAYOUT sysctl to fetch layout info ... rather than using the KERN_PROC_PS_STRINGS value to derive the top of the user address space. Reviewed by: kib MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33708 --- tests/sys/kern/kern_copyin.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tests/sys/kern/kern_copyin.c b/tests/sys/kern/kern_copyin.c index eb1fea315b5a..de12753c8dcd 100644 --- a/tests/sys/kern/kern_copyin.c +++ b/tests/sys/kern/kern_copyin.c @@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/exec.h> #include <sys/sysctl.h> +#include <sys/user.h> + #include <errno.h> #include <fcntl.h> #include <limits.h> @@ -74,27 +76,20 @@ copyin_checker2(uintptr_t uaddr) static uintptr_t get_maxuser_address(void) { + struct kinfo_vm_layout kvm; size_t len; - uintptr_t psstrings; int error, mib[4]; mib[0] = CTL_KERN; mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PS_STRINGS; + mib[2] = KERN_PROC_VM_LAYOUT; mib[3] = getpid(); - len = sizeof(psstrings); - error = sysctl(mib, nitems(mib), &psstrings, &len, NULL, 0); + len = sizeof(kvm); + error = sysctl(mib, nitems(mib), &kvm, &len, NULL, 0); if (error != 0) return (0); - if (psstrings == PS_STRINGS_LA57) - return (VM_MAXUSER_ADDRESS_LA57); - if (psstrings == PS_STRINGS_LA48) - return (VM_MAXUSER_ADDRESS_LA48); - /* AMD LA48 with clipped UVA */ - if (psstrings == PS_STRINGS_LA48 - PAGE_SIZE) - return (VM_MAXUSER_ADDRESS_LA48 - PAGE_SIZE); - return (0); + return (kvm.kvm_max_user_addr); } #endif