Date: Fri, 10 Jul 2015 17:19:23 GMT From: mihai@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r288193 - soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyveloadarm Message-ID: <201507101719.t6AHJN8N045021@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mihai Date: Fri Jul 10 17:19:22 2015 New Revision: 288193 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=288193 Log: soc2015: mihai: bhyve: usr.sbin: bhyveloadarm: fix mmap bug - map ony readonly the file Modified: soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyveloadarm/bhyveloadarm.c Modified: soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyveloadarm/bhyveloadarm.c ============================================================================== --- soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyveloadarm/bhyveloadarm.c Fri Jul 10 16:05:24 2015 (r288192) +++ soc2015/mihai/bhyve-on-arm-head/usr.sbin/bhyveloadarm/bhyveloadarm.c Fri Jul 10 17:19:22 2015 (r288193) @@ -41,7 +41,6 @@ guest_copyin(const void *from, uint64_t to, size_t size) { char *ptr; - ptr = vm_map_gpa(ctx, to, size); if (ptr == NULL) return (EFAULT); @@ -96,12 +95,14 @@ char kernel_image_name[KERNEL_IMAGE_NAME_LEN]; struct stat st; void *addr; + char test[4]; progname = basename(argv[0]); mem_size = 128 * MB; kernel_load_address = 0xc0000000; memory_base_address = 0xc0000000; + strncpy(kernel_image_name, "wfi.out", KERNEL_IMAGE_NAME_LEN); while ((opt = getopt(argc, argv, "k:l:b:m:")) != -1) { switch (opt) { @@ -154,20 +155,23 @@ exit(1); } - error = fstat(kernel_image_fd, &st); if (error) { perror("fstat"); exit(1); } - addr = mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, kernel_image_fd, 0); - if (!addr) { + addr = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, kernel_image_fd, 0); + if (addr == MAP_FAILED) { perror("mmap kernel_image_fd"); exit(1); } - guest_copyin(addr, kernel_load_address, st.st_size); + if (guest_copyin(addr, kernel_load_address - memory_base_address, st.st_size)) { + perror("guest_copyin"); + exit(1); + } + munmap(addr, st.st_size); guest_setreg(VM_REG_GUEST_PC, kernel_load_address);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507101719.t6AHJN8N045021>