Date: Tue, 08 Jan 2013 08:48:06 +0000 From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r246360 - in soc2012/syuu/bhyve-bios: lib/libbiosemul usr.sbin/bhyve Message-ID: <20130108085115.5CAFFB6F@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: syuu Date: Tue Jan 8 08:48:05 2013 New Revision: 246360 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=246360 Log: register copy bug fix, ignore vga ram mmap, try_boot fail handling Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.c soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.h soc2012/syuu/bhyve-bios/lib/libbiosemul/port.c soc2012/syuu/bhyve-bios/lib/libbiosemul/tty.c soc2012/syuu/bhyve-bios/usr.sbin/bhyve/fbsdrun.c Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.c Tue Jan 8 07:32:38 2013 (r246359) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.c Tue Jan 8 08:48:05 2013 (r246360) @@ -68,7 +68,7 @@ int xmode = 0; int quietmode = 0; int booting = 0; -int raw_kbd = 0; +int raw_kbd = 1; int timer_disable = 0; struct timeval boot_time; u_int32_t *ivec; @@ -122,14 +122,15 @@ regcontext_t *saved_regcontext; /* lobotomise */ -void biosemul_init(struct vmctx *ctx, int vcpu, char *lomem) +int biosemul_init(struct vmctx *ctx, int vcpu, char *lomem) { lomem_addr = lomem; ivec = (u_int32_t *)lomem_addr; init_ints(); - debugf = stderr; +// debugf = stderr; + debugf = fopen("biosemul.log", "w"); /* Call init functions */ if (raw_kbd) @@ -137,7 +138,8 @@ init_io_port_handlers(); bios_init(); init_hdisk(2, HDISK_CYL, HDISK_HEAD, HDISK_TRACK, HDISK_FILE, NULL); - try_boot(booting = 2); /* try C: */ + if (try_boot(booting = 2) < 0) /* try C: */ + return -1; cpu_init(); kbd_init(); kbd_bios_init(); @@ -155,6 +157,7 @@ #if 0 gettimeofday(&boot_time, 0); #endif + return 0; } #if 0 @@ -797,7 +800,7 @@ if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_ES, ®s->r.es.r_rx)) != 0) goto done; - if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_DS, ®s->r.es.r_rx)) != 0) + if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_DS, ®s->r.ds.r_rx)) != 0) goto done; if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RDI, ®s->r.edi.r_rx)) != 0) @@ -845,82 +848,82 @@ int error = 0; if ((orig->r.gs.r_rx != modified->r.gs.r_rx) && - fprintf(stderr, "%s gs:%lx\n", __func__, modified->r.gs.r_rx) && + fprintf(debugf, "%s gs:%lx\n", __func__, modified->r.gs.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_GS, modified->r.gs.r_rx)) != 0) goto done; if ((orig->r.fs.r_rx != modified->r.fs.r_rx) && - fprintf(stderr, "%s fs:%lx\n", __func__, modified->r.fs.r_rx) && + fprintf(debugf, "%s fs:%lx\n", __func__, modified->r.fs.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_FS, modified->r.fs.r_rx)) != 0) goto done; if ((orig->r.es.r_rx != modified->r.es.r_rx) && - fprintf(stderr, "%s es:%lx\n", __func__, modified->r.es.r_rx) && + fprintf(debugf, "%s es:%lx\n", __func__, modified->r.es.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_ES, modified->r.es.r_rx)) != 0) goto done; if ((orig->r.ds.r_rx != modified->r.ds.r_rx) && - fprintf(stderr, "%s ds:%lx\n", __func__, modified->r.ds.r_rx) && - (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_DS, modified->r.es.r_rx)) != 0) + fprintf(debugf, "%s ds:%lx\n", __func__, modified->r.ds.r_rx) && + (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_DS, modified->r.ds.r_rx)) != 0) goto done; if ((orig->r.edi.r_rx != modified->r.edi.r_rx) && - fprintf(stderr, "%s edi:%lx\n", __func__, modified->r.edi.r_rx) && + fprintf(debugf, "%s edi:%lx\n", __func__, modified->r.edi.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RDI, modified->r.edi.r_rx)) != 0) goto done; if ((orig->r.esi.r_rx != modified->r.esi.r_rx) && - fprintf(stderr, "%s esi:%lx\n", __func__, modified->r.esi.r_rx) && + fprintf(debugf, "%s esi:%lx\n", __func__, modified->r.esi.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RSI, modified->r.esi.r_rx)) != 0) goto done; if ((orig->r.ebp.r_rx != modified->r.ebp.r_rx) && - fprintf(stderr, "%s ebp:%lx\n", __func__, modified->r.ebp.r_rx) && + fprintf(debugf, "%s ebp:%lx\n", __func__, modified->r.ebp.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RBP, modified->r.ebp.r_rx)) != 0) goto done; if ((orig->r.ebx.r_rx != modified->r.ebx.r_rx) && - fprintf(stderr, "%s ebx:%lx\n", __func__, modified->r.ebx.r_rx) && + fprintf(debugf, "%s ebx:%lx\n", __func__, modified->r.ebx.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RBX, modified->r.ebx.r_rx)) != 0) goto done; if ((orig->r.edx.r_rx != modified->r.edx.r_rx) && - fprintf(stderr, "%s edx:%lx\n", __func__, modified->r.edx.r_rx) && + fprintf(debugf, "%s edx:%lx\n", __func__, modified->r.edx.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RDX, modified->r.edx.r_rx)) != 0) goto done; if ((orig->r.ecx.r_rx != modified->r.ecx.r_rx) && - fprintf(stderr, "%s ecx:%lx\n", __func__, modified->r.ecx.r_rx) && + fprintf(debugf, "%s ecx:%lx\n", __func__, modified->r.ecx.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RCX, modified->r.ecx.r_rx)) != 0) goto done; if ((orig->r.eax.r_rx != modified->r.eax.r_rx) && - fprintf(stderr, "%s eax:%lx\n", __func__, modified->r.eax.r_rx) && + fprintf(debugf, "%s eax:%lx\n", __func__, modified->r.eax.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, modified->r.eax.r_rx)) != 0) goto done; if ((orig->r.esp.r_rx != modified->r.esp.r_rx) && - fprintf(stderr, "%s esp:%lx\n", __func__, modified->r.esp.r_rx) && + fprintf(debugf, "%s esp:%lx\n", __func__, modified->r.esp.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RSP, modified->r.esp.r_rx)) != 0) goto done; if ((orig->r.ss.r_rx != modified->r.ss.r_rx) && - fprintf(stderr, "%s ss:%lx\n", __func__, modified->r.ss.r_rx) && + fprintf(debugf, "%s ss:%lx\n", __func__, modified->r.ss.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_SS, modified->r.ss.r_rx)) != 0) goto done; if ((orig->r.eip.r_rx != modified->r.eip.r_rx) && - fprintf(stderr, "%s eip:%lx\n", __func__, modified->r.eip.r_rx) && + fprintf(debugf, "%s eip:%lx\n", __func__, modified->r.eip.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, modified->r.eip.r_rx)) != 0) goto done; if ((orig->r.cs.r_rx != modified->r.cs.r_rx) && - fprintf(stderr, "%s cs:%lx\n", __func__, modified->r.cs.r_rx) && + fprintf(debugf, "%s cs:%lx\n", __func__, modified->r.cs.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_CS, modified->r.cs.r_rx)) != 0) goto done; if ((orig->r.efl.r_rx != modified->r.efl.r_rx) && - fprintf(stderr, "%s eflags:%lx\n", __func__, modified->r.efl.r_rx) && + fprintf(debugf, "%s eflags:%lx\n", __func__, modified->r.efl.r_rx) && (error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, modified->r.efl.r_rx)) != 0) goto done; done: @@ -938,6 +941,7 @@ regcontext_t *REGS = &modified; get_all_regs(ctx, vcpu, &orig); +#if 0 { u_int16_t *sp, eip, cs, efl; @@ -948,7 +952,9 @@ fprintf(stderr, "%s eip:%x cs:%x efl:%x\n", __func__, eip, cs, efl); } +#endif modified = orig; +#if 0 fprintf(stderr, "%s orig RAX=%lx EAX=%x AX=%x AL=%x AH=%x\n", __func__, orig.r.eax.r_rx, @@ -977,9 +983,12 @@ modified.r.ebx.r_w.r_x, modified.r.ebx.r_b.r_l, modified.r.ebx.r_b.r_h); +#endif callback_t func = find_callback(MAKEVEC(R_CS, R_IP)); +#if 0 fprintf(stderr, "%s R_CS:%x R_IP:%x MAKEVEC(R_CS, R_IP):%x func:%p\n", __func__, R_CS, R_IP, MAKEVEC(R_CS, R_IP), func); +#endif if (func) func(&modified); Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.h ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.h Tue Jan 8 07:32:38 2013 (r246359) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.h Tue Jan 8 08:48:05 2013 (r246360) @@ -6,7 +6,7 @@ #include <machine/vmm.h> #include <vmmapi.h> -void biosemul_init(struct vmctx *ctx, int vcpu, char *lomem); +int biosemul_init(struct vmctx *ctx, int vcpu, char *lomem); int biosemul_call(struct vmctx *ctx, int vcpu, int intno); bool biosemul_inout_registered(int in, int port); int biosemul_inout(struct vmctx *ctx, int vcpu, int in, int port, int bytes, Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/port.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/port.c Tue Jan 8 07:32:38 2013 (r246359) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/port.c Tue Jan 8 08:48:05 2013 (r246360) @@ -232,8 +232,6 @@ void define_input_port_handler(int port, unsigned char (*p_inb)(int port)) { - fprintf(stderr, "%s port:%d func:%p\n", - __func__, port, p_inb); if ((port >= MINPORT) && (port < MAXPORT)) { portsw[port].p_inb = p_inb; } else @@ -243,8 +241,6 @@ void define_output_port_handler(int port, void (*p_outb)(int port, unsigned char byte)) { - fprintf(stderr, "%s port:%d func:%p\n", - __func__, port, p_outb); if ((port >= MINPORT) && (port < MAXPORT)) { portsw[port].p_outb = p_outb; } else Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/tty.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/tty.c Tue Jan 8 07:32:38 2013 (r246359) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/tty.c Tue Jan 8 08:48:05 2013 (r246360) @@ -266,12 +266,15 @@ console_init() { int fd; +#if 0 caddr_t addr; +#endif if ((fd = open(_PATH_DEV "vga", 2)) < 0) { perror(_PATH_DEV "vga"); quit(1); } +#if 0 addr = mmap((caddr_t)(lomem_addr + 0xA0000), 5 * 64 * 1024, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_FILE | MAP_FIXED | MAP_SHARED, @@ -280,7 +283,7 @@ perror("mmap"); quit(1); } - +#endif #if 0 addr = mmap((caddr_t)0x100000 - 0x1000, 0x1000, PROT_EXEC | PROT_READ | PROT_WRITE, Modified: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/fbsdrun.c ============================================================================== --- soc2012/syuu/bhyve-bios/usr.sbin/bhyve/fbsdrun.c Tue Jan 8 07:32:38 2013 (r246359) +++ soc2012/syuu/bhyve-bios/usr.sbin/bhyve/fbsdrun.c Tue Jan 8 08:48:05 2013 (r246360) @@ -763,7 +763,8 @@ if (bios_mode != 0) { vm_set_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, 1); - biosemul_init(ctx, 0, lomem_addr); + error = biosemul_init(ctx, 0, lomem_addr); + assert(error == 0); } init_inout();
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130108085115.5CAFFB6F>