@@ -758,14 +758,26 @@ int main(int argc, char **argv, char **envp)
if ((fp = fopen("/proc/sys/vm/mmap_min_addr", "r")) != NULL) {
unsigned long tmp;
- if (fscanf(fp, "%lu", &tmp) == 1) {
+ if (fscanf(fp, "%lu", &tmp) == 1 && tmp != 0) {
mmap_min_addr = tmp;
- qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx\n", mmap_min_addr);
+ qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx\n",
+ mmap_min_addr);
}
fclose(fp);
}
}
+ /*
+ * We prefer to not make NULL pointers accessible to QEMU.
+ * If we're in a chroot with no /proc, fall back to 1 page.
+ */
+ if (mmap_min_addr == 0) {
+ mmap_min_addr = qemu_host_page_size;
+ qemu_log_mask(CPU_LOG_PAGE,
+ "host mmap_min_addr=0x%lx (fallback)\n",
+ mmap_min_addr);
+ }
+
/*
* Prepare copy of argv vector for target.
*/