common-user: Initialize mmap_min_addr for FreeBSD
Use sysctl to fetch the vm layout of the current process. Reviewed-by: Helge Deller <deller@gmx.de> Reviewed-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "user/mmap-min-addr.h"
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/user.h>
|
||||
#endif
|
||||
|
||||
uintptr_t mmap_min_addr;
|
||||
|
||||
@@ -31,6 +35,15 @@ static void __attribute__((constructor)) init(void)
|
||||
fclose(fp);
|
||||
}
|
||||
mmap_min_addr = min_addr;
|
||||
#elif defined(__FreeBSD__)
|
||||
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_VM_LAYOUT, getpid() };
|
||||
struct kinfo_vm_layout info;
|
||||
size_t info_len = sizeof(info);
|
||||
|
||||
mmap_min_addr =
|
||||
(sysctl(mib, ARRAY_SIZE(mib), &info, &info_len, NULL, 0) < 0
|
||||
? qemu_real_host_page_size()
|
||||
: info.kvm_min_user_addr);
|
||||
#else
|
||||
# error
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user