From owner-svn-soc-all@FreeBSD.ORG Sun Jan 6 14:16:58 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 4D8D8AB5 for ; Sun, 6 Jan 2013 14:16:57 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 06 Jan 2013 14:13:54 +0000 Date: Sun, 06 Jan 2013 14:13:54 +0000 From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r246300 - in soc2012/syuu/bhyve-bios: etc/mtree lib/libbiosemul lib/libudis86 usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20130106141657.4D8D8AB5@hub.freebsd.org> X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jan 2013 14:16:58 -0000 Author: syuu Date: Sun Jan 6 14:13:53 2013 New Revision: 246300 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=246300 Log: revert instruction level tracer Deleted: soc2012/syuu/bhyve-bios/lib/libudis86/ Modified: soc2012/syuu/bhyve-bios/etc/mtree/BSD.include.dist soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.c soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.h soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.c soc2012/syuu/bhyve-bios/lib/libbiosemul/cpu.c soc2012/syuu/bhyve-bios/lib/libbiosemul/port.c soc2012/syuu/bhyve-bios/lib/libbiosemul/register.h soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile soc2012/syuu/bhyve-bios/usr.sbin/bhyve/fbsdrun.c Modified: soc2012/syuu/bhyve-bios/etc/mtree/BSD.include.dist ============================================================================== --- soc2012/syuu/bhyve-bios/etc/mtree/BSD.include.dist Sun Jan 6 07:14:04 2013 (r246299) +++ soc2012/syuu/bhyve-bios/etc/mtree/BSD.include.dist Sun Jan 6 14:13:53 2013 (r246300) @@ -321,8 +321,6 @@ .. sys .. - udis86 - .. ufs ffs .. Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.c Sun Jan 6 07:14:04 2013 (r246299) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.c Sun Jan 6 14:13:53 2013 (r246300) @@ -57,7 +57,6 @@ #endif #include #include -#include #include "doscmd.h" #include "tty.h" @@ -121,10 +120,9 @@ #define HDISK_FILE "/home/syuu/test.img" regcontext_t *saved_regcontext; -int trace_mode; /* lobotomise */ -void biosemul_init(struct vmctx *ctx, int vcpu, char *lomem, int trace) +void biosemul_init(struct vmctx *ctx, int vcpu, char *lomem) { lomem_addr = lomem; ivec = (u_int32_t *)lomem_addr; @@ -157,18 +155,6 @@ #if 0 gettimeofday(&boot_time, 0); #endif - - trace_mode = trace; - if (trace_mode) { - uint64_t rflags; - int error; - - error = vm_get_register(ctx, 0, VM_REG_GUEST_RFLAGS, &rflags); - assert(error == 0); - rflags |= 0x100; /* Trap Flag */ - error = vm_set_register(ctx, 0, VM_REG_GUEST_RFLAGS, rflags); - assert(error == 0); - } } #if 0 @@ -849,9 +835,6 @@ if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, ®s->r.efl.r_rx)) != 0) goto done; - - if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_CR0, ®s->r.cr0.r_rx)) != 0) - goto done; done: return (error); } @@ -862,106 +845,144 @@ 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(stderr, "%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(stderr, "%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(stderr, "%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) && + 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) 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(stderr, "%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(stderr, "%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(stderr, "%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(stderr, "%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(stderr, "%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(stderr, "%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(stderr, "%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(stderr, "%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(stderr, "%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(stderr, "%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(stderr, "%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(stderr, "%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: - + return (error); } -extern u_int32_t vec01; +extern void int13(regcontext_t *REGS); + int -biosemul_call(struct vmctx *ctx, int vcpu) +biosemul_call(struct vmctx *ctx, int vcpu, int intno) { int ret = 0; regcontext_t orig, modified; regcontext_t *REGS = &modified; - callback_t func; get_all_regs(ctx, vcpu, &orig); + { + u_int16_t *sp, eip, cs, efl; + + sp = (uint16_t *)(lomem_addr + orig.r.esp.r_rx); + eip = *sp; + cs = *(--sp); + efl = *(--sp); + fprintf(stderr, "%s eip:%x cs:%x efl:%x\n", + __func__, eip, cs, efl); + } modified = orig; - func = find_callback(MAKEVEC(R_CS, R_IP)); + fprintf(stderr, "%s orig RAX=%lx EAX=%x AX=%x AL=%x AH=%x\n", + __func__, + orig.r.eax.r_rx, + orig.r.eax.r_dw.r_ex, + orig.r.eax.r_w.r_x, + orig.r.eax.r_b.r_l, + orig.r.eax.r_b.r_h); + fprintf(stderr, "%s orig RBX=%lx EBX=%x BX=%x BL=%x BH=%x\n", + __func__, + orig.r.ebx.r_rx, + orig.r.ebx.r_dw.r_ex, + orig.r.ebx.r_w.r_x, + orig.r.ebx.r_b.r_l, + orig.r.ebx.r_b.r_h); + fprintf(stderr, "%s modified RAX=%lx EAX=%x AX=%x AL=%x AH=%x\n", + __func__, + modified.r.eax.r_rx, + modified.r.eax.r_dw.r_ex, + modified.r.eax.r_w.r_x, + modified.r.eax.r_b.r_l, + modified.r.eax.r_b.r_h); + fprintf(stderr, "%s modified RBX=%lx EBX=%x BX=%x BL=%x BH=%x\n", + __func__, + modified.r.ebx.r_rx, + modified.r.ebx.r_dw.r_ex, + modified.r.ebx.r_w.r_x, + modified.r.ebx.r_b.r_l, + modified.r.ebx.r_b.r_h); + callback_t func = find_callback(MAKEVEC(R_CS, R_IP)); + 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); if (func) func(&modified); - if (trace_mode && MAKEVEC(R_CS, R_IP) != vec01) - R_EFLAGS |= 0x100; set_modified_regs(ctx, vcpu, &orig, &modified); return (ret); @@ -981,6 +1002,9 @@ modified = orig; saved_regcontext = &modified; + fprintf(stderr, "%s in:%d port:%x bytes:%d eax:%x strict:%d\n", + __func__, in, port, bytes, *eax, strict); + if (in) inb(&modified, port); else Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.h ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.h Sun Jan 6 07:14:04 2013 (r246299) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.h Sun Jan 6 14:13:53 2013 (r246300) @@ -6,8 +6,8 @@ #include #include -void biosemul_init(struct vmctx *ctx, int vcpu, char *lomem, int trace_mode); -int biosemul_call(struct vmctx *ctx, int vcpu); +void 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, uint32_t *eax, int strict); Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.c Sun Jan 6 07:14:04 2013 (r246299) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.c Sun Jan 6 14:13:53 2013 (r246300) @@ -43,7 +43,6 @@ /* ** Find a handler for (vec) */ -extern u_int32_t vec01; callback_t find_callback(u_int32_t vec) { @@ -55,8 +54,7 @@ if (elm->vec == vec) break; if (elm) { - if (vec != vec01) - debug(D_TRAPS2, "callback %s\n", elm->name); + debug(D_TRAPS2, "callback %s\n", elm->name); return (elm->func); } else return ((callback_t)0); Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/cpu.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/cpu.c Sun Jan 6 07:14:04 2013 (r246299) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/cpu.c Sun Jan 6 14:13:53 2013 (r246300) @@ -27,12 +27,7 @@ #include __FBSDID("$FreeBSD: projects/doscmd/cpu.c,v 1.8 2002/05/10 10:37:57 tg Exp $"); -#include -#include -#include -#include #include "doscmd.h" -#include #include "video.h" static u_int32_t decode_modrm(u_int8_t *, u_int16_t, @@ -56,50 +51,10 @@ exit(1); } -extern char *lomem_addr; - void -int01(regcontext_t *REGS) +int01(regcontext_t *REGS __unused) { - ud_t ud_obj; - - ud_init(&ud_obj); - ud_set_syntax(&ud_obj, UD_SYN_ATT); - ud_set_vendor(&ud_obj, UD_VENDOR_INTEL); - - if (R_CR0 & CR0_PE) { - u_int32_t *sp, eip, eflags; - - sp = (uint32_t *)(lomem_addr + R_ESP); - eip = *sp; - --sp; /* CS */ - --sp; /* EFLAGS */ - eflags = *sp; - *sp |= 0x100; - ud_set_mode(&ud_obj, 32); - ud_set_pc(&ud_obj, eip); - ud_set_input_buffer(&ud_obj, lomem_addr + eip, 16); - - fprintf(stderr, "[trace] 32bit eip:%x eflags:%x", eip, eflags); - }else{ - u_int16_t *sp, eip, eflags; - - sp = (uint16_t *)(lomem_addr + R_ESP); - eip = *sp; - --sp; /* CS */ - --sp; /* EFLAGS */ - eflags = *sp; - *sp |= 0x100; - ud_set_mode(&ud_obj, 16); - ud_set_pc(&ud_obj, eip); - ud_set_input_buffer(&ud_obj, lomem_addr + eip, 16); - - fprintf(stderr, "[trace] 16bit eip:%x eflags:%x", eip, eflags); - } - ud_disassemble(&ud_obj); - fprintf(stderr, " insn:%s", ud_insn_asm(&ud_obj)); - fprintf(stderr, " eax:%x ebx:%x ecx:%x edx:%x\n", - R_EAX, R_EBX, R_ECX, R_EDX); + debug(D_ALWAYS, "INT 1 with no handler! (single-step/debug)\n"); } void @@ -114,7 +69,6 @@ debug(D_ALWAYS, "IRQ5 with no handler!\n"); } -u_int32_t vec01; void cpu_init(void) { @@ -124,9 +78,9 @@ ivec[0x00] = vec; register_callback(vec, int00, "int 00"); - vec01 = insert_hardint_trampoline(); - ivec[0x01] = vec01; - register_callback(vec01, int01, "int 01"); + vec = insert_softint_trampoline(); + ivec[0x01] = vec; + register_callback(vec, int01, "int 01"); vec = insert_softint_trampoline(); ivec[0x03] = vec; Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/port.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/port.c Sun Jan 6 07:14:04 2013 (r246299) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/port.c Sun Jan 6 14:13:53 2013 (r246300) @@ -232,6 +232,8 @@ 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 @@ -241,6 +243,8 @@ 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/register.h ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/register.h Sun Jan 6 07:14:04 2013 (r246299) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/register.h Sun Jan 6 14:13:53 2013 (r246300) @@ -84,7 +84,6 @@ reg86_t efl; reg86_t esp; reg86_t ss; - reg86_t cr0; } registers_t; typedef union @@ -140,7 +139,6 @@ #define R_GS (REGS->r.gs.r_w.r_x) #define R_EFS (REGS->r.fs.r_dw.r_ex) #define R_FS (REGS->r.fs.r_w.r_x) -#define R_CR0 (REGS->r.cr0.r_dw.r_ex) #endif Modified: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile ============================================================================== --- soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile Sun Jan 6 07:14:04 2013 (r246299) +++ soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile Sun Jan 6 14:13:53 2013 (r246300) @@ -11,8 +11,8 @@ NO_MAN= -DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBPTHREAD} ${LIBBIOSEMUL} ${LIBUDIS86} -LDADD= -lvmmapi -lmd -lpthread -lbiosemul -ludis86 +DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBPTHREAD} ${LIBBIOSEMUL} +LDADD= -lvmmapi -lmd -lpthread -lbiosemul WARNS?= 2 Modified: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/fbsdrun.c ============================================================================== --- soc2012/syuu/bhyve-bios/usr.sbin/bhyve/fbsdrun.c Sun Jan 6 07:14:04 2013 (r246299) +++ soc2012/syuu/bhyve-bios/usr.sbin/bhyve/fbsdrun.c Sun Jan 6 14:13:53 2013 (r246300) @@ -102,7 +102,6 @@ static int oem_tbl_size; static int bios_mode; -static int trace_mode; static void vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip); @@ -131,7 +130,7 @@ { fprintf(stderr, - "Usage: %s [-ehBHPbT][-g ][-z ][-s ][-p pincpu]" + "Usage: %s [-ehBHPb][-g ][-z ][-s ][-p pincpu]" "[-n ][-m lowmem][-M highmem] \n" " -g: gdb port (default is %d and 0 means don't open)\n" " -c: # cpus (default 1)\n" @@ -149,8 +148,7 @@ " -M: highmem in MB\n" " -x: mux vcpus to 1 hcpu\n" " -t: mux vcpu timeslice hz (default %d)\n" - " -b: BIOS compatible mode\n" - " -T: Trace mode\n", + " -b: BIOS compatible mode\n", progname, DEFAULT_GDB_PORT, DEFAULT_GUEST_HZ, DEFAULT_GUEST_TSLICE); exit(code); @@ -442,15 +440,17 @@ static int vmexit_hypercall(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) { + int intno = (vmexit->rip - 0x400) / 0x4; + if (!bios_mode) { fprintf(stderr, "Failed to handle hypercall at 0x%lx\n", vmexit->rip); return (VMEXIT_ABORT); } - if (biosemul_call(ctx, *pvcpu) != 0) { - fprintf(stderr, "Failed to emulate INT at 0x%lx\n", - vmexit->rip); + if (biosemul_call(ctx, *pvcpu, intno) != 0) { + fprintf(stderr, "Failed to emulate INT %x at 0x%lx\n", + intno, vmexit->rip); return (VMEXIT_ABORT); } @@ -560,7 +560,7 @@ gdb_port = DEFAULT_GDB_PORT; guest_ncpus = 1; - while ((c = getopt(argc, argv, "ehBHPxbTp:g:c:z:s:S:n:m:M:")) != -1) { + while ((c = getopt(argc, argv, "ehBHPxbp:g:c:z:s:S:n:m:M:")) != -1) { switch (c) { case 'B': inject_bkpt = 1; @@ -610,9 +610,6 @@ case 'b': bios_mode = 1; break; - case 'T': - trace_mode = 1; - break; case 'h': usage(0); default: @@ -681,10 +678,7 @@ if (bios_mode != 0) { vm_set_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, 1); - biosemul_init(ctx, 0, lomem_addr, trace_mode); - } else if (trace_mode != 0) { - fprintf(stderr, "Trace mode only works with BIOS emulation mode\n"); - return (-1); + biosemul_init(ctx, 0, lomem_addr); } init_inout(); From owner-svn-soc-all@FreeBSD.ORG Mon Jan 7 01:57:08 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 5592C569 for ; Mon, 7 Jan 2013 01:57:06 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 07 Jan 2013 01:54:02 +0000 Date: Mon, 07 Jan 2013 01:54:02 +0000 From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r246319 - in soc2012/syuu/bhyve-bios: etc/mtree lib lib/libudis86 lib/libvmmapi sys/amd64/include sys/amd64/vmm sys/amd64/vmm/intel usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20130107015706.5592C569@hub.freebsd.org> X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jan 2013 01:57:08 -0000 Author: syuu Date: Mon Jan 7 01:54:01 2013 New Revision: 246319 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=246319 Log: tracer for biosemul Added: soc2012/syuu/bhyve-bios/lib/libudis86/ soc2012/syuu/bhyve-bios/lib/libudis86/Makefile soc2012/syuu/bhyve-bios/lib/libudis86/decode.c soc2012/syuu/bhyve-bios/lib/libudis86/decode.h soc2012/syuu/bhyve-bios/lib/libudis86/extern.h soc2012/syuu/bhyve-bios/lib/libudis86/input.c soc2012/syuu/bhyve-bios/lib/libudis86/input.h soc2012/syuu/bhyve-bios/lib/libudis86/itab.c soc2012/syuu/bhyve-bios/lib/libudis86/itab.h soc2012/syuu/bhyve-bios/lib/libudis86/opgen.py soc2012/syuu/bhyve-bios/lib/libudis86/syn-att.c soc2012/syuu/bhyve-bios/lib/libudis86/syn-intel.c soc2012/syuu/bhyve-bios/lib/libudis86/syn.c soc2012/syuu/bhyve-bios/lib/libudis86/syn.h soc2012/syuu/bhyve-bios/lib/libudis86/types.h soc2012/syuu/bhyve-bios/lib/libudis86/udis86.c soc2012/syuu/bhyve-bios/lib/libudis86/udis86.h Modified: soc2012/syuu/bhyve-bios/etc/mtree/BSD.include.dist soc2012/syuu/bhyve-bios/lib/Makefile soc2012/syuu/bhyve-bios/lib/libvmmapi/vmmapi.c soc2012/syuu/bhyve-bios/lib/libvmmapi/vmmapi.h soc2012/syuu/bhyve-bios/sys/amd64/include/vmm.h soc2012/syuu/bhyve-bios/sys/amd64/include/vmm_dev.h soc2012/syuu/bhyve-bios/sys/amd64/vmm/intel/vmcs.c soc2012/syuu/bhyve-bios/sys/amd64/vmm/intel/vmcs.h soc2012/syuu/bhyve-bios/sys/amd64/vmm/intel/vmx.c soc2012/syuu/bhyve-bios/sys/amd64/vmm/vmm.c soc2012/syuu/bhyve-bios/sys/amd64/vmm/vmm_dev.c soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile soc2012/syuu/bhyve-bios/usr.sbin/bhyve/fbsdrun.c Modified: soc2012/syuu/bhyve-bios/etc/mtree/BSD.include.dist ============================================================================== --- soc2012/syuu/bhyve-bios/etc/mtree/BSD.include.dist Mon Jan 7 00:49:29 2013 (r246318) +++ soc2012/syuu/bhyve-bios/etc/mtree/BSD.include.dist Mon Jan 7 01:54:01 2013 (r246319) @@ -321,6 +321,8 @@ .. sys .. + udis86 + .. ufs ffs .. Modified: soc2012/syuu/bhyve-bios/lib/Makefile ============================================================================== --- soc2012/syuu/bhyve-bios/lib/Makefile Mon Jan 7 00:49:29 2013 (r246318) +++ soc2012/syuu/bhyve-bios/lib/Makefile Mon Jan 7 01:54:01 2013 (r246319) @@ -115,6 +115,7 @@ ${_libusb} \ ${_libvgl} \ ${_libvmmapi} \ + ${_libudis86} \ libwrap \ liby \ libz \ @@ -195,6 +196,7 @@ .if ${MACHINE_CPUARCH} == "amd64" _libvmmapi= libvmmapi +_libudis86= libudis86 .endif .if ${MACHINE_CPUARCH} == "ia64" Added: soc2012/syuu/bhyve-bios/lib/libudis86/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/lib/libudis86/Makefile Mon Jan 7 01:54:01 2013 (r246319) @@ -0,0 +1,11 @@ +# from BSDI Makefile,v 2.6 1996/04/08 20:06:40 bostic Exp +# +# $FreeBSD: projects/doscmd/Makefile,v 1.39 2004/03/30 17:10:01 des Exp $ + +LIB= udis86 +WARNS?= 2 +SRCS= itab.c input.c decode.c syn.c syn-intel.c syn-att.c udis86.c +INCS= udis86.h types.h extern.h itab.h +INCSDIR= ${INCLUDEDIR}/udis86 + +.include Added: soc2012/syuu/bhyve-bios/lib/libudis86/decode.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/lib/libudis86/decode.c Mon Jan 7 01:54:01 2013 (r246319) @@ -0,0 +1,1193 @@ +/* ----------------------------------------------------------------------------- + * decode.c + * + * Copyright (c) 2005, 2006, Vivek Mohan + * All rights reserved. See LICENSE + * ----------------------------------------------------------------------------- + */ + +#include +#include + +#include "types.h" +#include "itab.h" +#include "input.h" +#include "decode.h" + +/* The max number of prefixes to an instruction */ +#define MAX_PREFIXES 15 + +static struct ud_itab_entry ie_invalid = { UD_Iinvalid, O_NONE, O_NONE, O_NONE, P_none }; +static struct ud_itab_entry ie_pause = { UD_Ipause, O_NONE, O_NONE, O_NONE, P_none }; +static struct ud_itab_entry ie_nop = { UD_Inop, O_NONE, O_NONE, O_NONE, P_none }; + + +/* Looks up mnemonic code in the mnemonic string table + * Returns NULL if the mnemonic code is invalid + */ +const char * ud_lookup_mnemonic( enum ud_mnemonic_code c ) +{ + if ( c < UD_Id3vil ) + return ud_mnemonics_str[ c ]; + return NULL; +} + + +/* Extracts instruction prefixes. + */ +static int get_prefixes( struct ud* u ) +{ + unsigned int have_pfx = 1; + unsigned int i; + uint8_t curr; + + /* if in error state, bail out */ + if ( u->error ) + return -1; + + /* keep going as long as there are prefixes available */ + for ( i = 0; have_pfx ; ++i ) { + + /* Get next byte. */ + inp_next(u); + if ( u->error ) + return -1; + curr = inp_curr( u ); + + /* rex prefixes in 64bit mode */ + if ( u->dis_mode == 64 && ( curr & 0xF0 ) == 0x40 ) { + u->pfx_rex = curr; + } else { + switch ( curr ) + { + case 0x2E : + u->pfx_seg = UD_R_CS; + u->pfx_rex = 0; + break; + case 0x36 : + u->pfx_seg = UD_R_SS; + u->pfx_rex = 0; + break; + case 0x3E : + u->pfx_seg = UD_R_DS; + u->pfx_rex = 0; + break; + case 0x26 : + u->pfx_seg = UD_R_ES; + u->pfx_rex = 0; + break; + case 0x64 : + u->pfx_seg = UD_R_FS; + u->pfx_rex = 0; + break; + case 0x65 : + u->pfx_seg = UD_R_GS; + u->pfx_rex = 0; + break; + case 0x67 : /* adress-size override prefix */ + u->pfx_adr = 0x67; + u->pfx_rex = 0; + break; + case 0xF0 : + u->pfx_lock = 0xF0; + u->pfx_rex = 0; + break; + case 0x66: + /* the 0x66 sse prefix is only effective if no other sse prefix + * has already been specified. + */ + if ( !u->pfx_insn ) u->pfx_insn = 0x66; + u->pfx_opr = 0x66; + u->pfx_rex = 0; + break; + case 0xF2: + u->pfx_insn = 0xF2; + u->pfx_repne = 0xF2; + u->pfx_rex = 0; + break; + case 0xF3: + u->pfx_insn = 0xF3; + u->pfx_rep = 0xF3; + u->pfx_repe = 0xF3; + u->pfx_rex = 0; + break; + default : + /* No more prefixes */ + have_pfx = 0; + break; + } + } + + /* check if we reached max instruction length */ + if ( i + 1 == MAX_INSN_LENGTH ) { + u->error = 1; + break; + } + } + + /* return status */ + if ( u->error ) + return -1; + + /* rewind back one byte in stream, since the above loop + * stops with a non-prefix byte. + */ + inp_back(u); + + /* speculatively determine the effective operand mode, + * based on the prefixes and the current disassembly + * mode. This may be inaccurate, but useful for mode + * dependent decoding. + */ + if ( u->dis_mode == 64 ) { + u->opr_mode = REX_W( u->pfx_rex ) ? 64 : ( ( u->pfx_opr ) ? 16 : 32 ) ; + u->adr_mode = ( u->pfx_adr ) ? 32 : 64; + } else if ( u->dis_mode == 32 ) { + u->opr_mode = ( u->pfx_opr ) ? 16 : 32; + u->adr_mode = ( u->pfx_adr ) ? 16 : 32; + } else if ( u->dis_mode == 16 ) { + u->opr_mode = ( u->pfx_opr ) ? 32 : 16; + u->adr_mode = ( u->pfx_adr ) ? 32 : 16; + } + + return 0; +} + + +/* Searches the instruction tables for the right entry. + */ +static int search_itab( struct ud * u ) +{ + struct ud_itab_entry * e = NULL; + enum ud_itab_index table; + uint8_t peek; + uint8_t did_peek = 0; + uint8_t curr; + uint8_t index; + + /* if in state of error, return */ + if ( u->error ) + return -1; + + /* get first byte of opcode. */ + inp_next(u); + if ( u->error ) + return -1; + curr = inp_curr(u); + + /* resolve xchg, nop, pause crazyness */ + if ( 0x90 == curr ) { + if ( !( u->dis_mode == 64 && REX_B( u->pfx_rex ) ) ) { + if ( u->pfx_rep ) { + u->pfx_rep = 0; + e = & ie_pause; + } else { + e = & ie_nop; + } + goto found_entry; + } + } + + /* get top-level table */ + if ( 0x0F == curr ) { + table = ITAB__0F; + curr = inp_next(u); + if ( u->error ) + return -1; + + /* 2byte opcodes can be modified by 0x66, F3, and F2 prefixes */ + if ( 0x66 == u->pfx_insn ) { + if ( ud_itab_list[ ITAB__PFX_SSE66__0F ][ curr ].mnemonic != UD_Iinvalid ) { + table = ITAB__PFX_SSE66__0F; + u->pfx_opr = 0; + } + } else if ( 0xF2 == u->pfx_insn ) { + if ( ud_itab_list[ ITAB__PFX_SSEF2__0F ][ curr ].mnemonic != UD_Iinvalid ) { + table = ITAB__PFX_SSEF2__0F; + u->pfx_repne = 0; + } + } else if ( 0xF3 == u->pfx_insn ) { + if ( ud_itab_list[ ITAB__PFX_SSEF3__0F ][ curr ].mnemonic != UD_Iinvalid ) { + table = ITAB__PFX_SSEF3__0F; + u->pfx_repe = 0; + u->pfx_rep = 0; + } + } + /* pick an instruction from the 1byte table */ + } else { + table = ITAB__1BYTE; + } + + index = curr; + +search: + + e = & ud_itab_list[ table ][ index ]; + + /* if mnemonic constant is a standard instruction constant + * our search is over. + */ + + if ( e->mnemonic < UD_Id3vil ) { + if ( e->mnemonic == UD_Iinvalid ) { + if ( did_peek ) { + inp_next( u ); if ( u->error ) return -1; + } + goto found_entry; + } + goto found_entry; + } + + table = e->prefix; + + switch ( e->mnemonic ) + { + case UD_Igrp_reg: + peek = inp_peek( u ); + did_peek = 1; + index = MODRM_REG( peek ); + break; + + case UD_Igrp_mod: + peek = inp_peek( u ); + did_peek = 1; + index = MODRM_MOD( peek ); + if ( index == 3 ) + index = ITAB__MOD_INDX__11; + else + index = ITAB__MOD_INDX__NOT_11; + break; + + case UD_Igrp_rm: + curr = inp_next( u ); + did_peek = 0; + if ( u->error ) + return -1; + index = MODRM_RM( curr ); + break; + + case UD_Igrp_x87: + curr = inp_next( u ); + did_peek = 0; + if ( u->error ) + return -1; + index = curr - 0xC0; + break; + + case UD_Igrp_osize: + if ( u->opr_mode == 64 ) + index = ITAB__MODE_INDX__64; + else if ( u->opr_mode == 32 ) + index = ITAB__MODE_INDX__32; + else + index = ITAB__MODE_INDX__16; + break; + + case UD_Igrp_asize: + if ( u->adr_mode == 64 ) + index = ITAB__MODE_INDX__64; + else if ( u->adr_mode == 32 ) + index = ITAB__MODE_INDX__32; + else + index = ITAB__MODE_INDX__16; + break; + + case UD_Igrp_mode: + if ( u->dis_mode == 64 ) + index = ITAB__MODE_INDX__64; + else if ( u->dis_mode == 32 ) + index = ITAB__MODE_INDX__32; + else + index = ITAB__MODE_INDX__16; + break; + + case UD_Igrp_vendor: + if ( u->vendor == UD_VENDOR_INTEL ) + index = ITAB__VENDOR_INDX__INTEL; + else if ( u->vendor == UD_VENDOR_AMD ) + index = ITAB__VENDOR_INDX__AMD; + else + assert( !"unrecognized vendor id" ); + break; + + case UD_Id3vil: + assert( !"invalid instruction mnemonic constant Id3vil" ); + break; + + default: + assert( !"invalid instruction mnemonic constant" ); + break; + } + + goto search; + +found_entry: + + u->itab_entry = e; + u->mnemonic = u->itab_entry->mnemonic; + + return 0; +} + + +static unsigned int resolve_operand_size( const struct ud * u, unsigned int s ) +{ + switch ( s ) + { + case SZ_V: + return ( u->opr_mode ); + case SZ_Z: + return ( u->opr_mode == 16 ) ? 16 : 32; + case SZ_P: + return ( u->opr_mode == 16 ) ? SZ_WP : SZ_DP; + case SZ_MDQ: + return ( u->opr_mode == 16 ) ? 32 : u->opr_mode; + case SZ_RDQ: + return ( u->dis_mode == 64 ) ? 64 : 32; + default: + return s; + } +} + + +static int resolve_mnemonic( struct ud* u ) +{ + /* far/near flags */ + u->br_far = 0; + u->br_near = 0; + /* readjust operand sizes for call/jmp instrcutions */ + if ( u->mnemonic == UD_Icall || u->mnemonic == UD_Ijmp ) { + /* WP: 16bit pointer */ + if ( u->operand[ 0 ].size == SZ_WP ) { + u->operand[ 0 ].size = 16; + u->br_far = 1; + u->br_near= 0; + /* DP: 32bit pointer */ + } else if ( u->operand[ 0 ].size == SZ_DP ) { + u->operand[ 0 ].size = 32; + u->br_far = 1; + u->br_near= 0; + } else { + u->br_far = 0; + u->br_near= 1; + } + /* resolve 3dnow weirdness. */ + } else if ( u->mnemonic == UD_I3dnow ) { + u->mnemonic = ud_itab_list[ ITAB__3DNOW ][ inp_curr( u ) ].mnemonic; + } + /* SWAPGS is only valid in 64bits mode */ + if ( u->mnemonic == UD_Iswapgs && u->dis_mode != 64 ) { + u->error = 1; + return -1; + } + + return 0; +} + + +/* ----------------------------------------------------------------------------- + * decode_a()- Decodes operands of the type seg:offset + * ----------------------------------------------------------------------------- + */ +static void +decode_a(struct ud* u, struct ud_operand *op) +{ + if (u->opr_mode == 16) { + /* seg16:off16 */ + op->type = UD_OP_PTR; + op->size = 32; + op->lval.ptr.off = inp_uint16(u); + op->lval.ptr.seg = inp_uint16(u); + } else { + /* seg16:off32 */ + op->type = UD_OP_PTR; + op->size = 48; + op->lval.ptr.off = inp_uint32(u); + op->lval.ptr.seg = inp_uint16(u); + } +} + +/* ----------------------------------------------------------------------------- + * decode_gpr() - Returns decoded General Purpose Register + * ----------------------------------------------------------------------------- + */ +static enum ud_type +decode_gpr(register struct ud* u, unsigned int s, unsigned char rm) +{ + s = resolve_operand_size(u, s); + + switch (s) { + case 64: + return UD_R_RAX + rm; + case SZ_DP: + case 32: + return UD_R_EAX + rm; + case SZ_WP: + case 16: + return UD_R_AX + rm; + case 8: + if (u->dis_mode == 64 && u->pfx_rex) { + if (rm >= 4) + return UD_R_SPL + (rm-4); + return UD_R_AL + rm; + } else return UD_R_AL + rm; + default: + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * resolve_gpr64() - 64bit General Purpose Register-Selection. + * ----------------------------------------------------------------------------- + */ +static enum ud_type +resolve_gpr64(struct ud* u, enum ud_operand_code gpr_op) +{ + if (gpr_op >= OP_rAXr8 && gpr_op <= OP_rDIr15) + gpr_op = (gpr_op - OP_rAXr8) | (REX_B(u->pfx_rex) << 3); + else gpr_op = (gpr_op - OP_rAX); + + if (u->opr_mode == 16) + return gpr_op + UD_R_AX; + if (u->dis_mode == 32 || + (u->opr_mode == 32 && ! (REX_W(u->pfx_rex) || u->default64))) { + return gpr_op + UD_R_EAX; + } + + return gpr_op + UD_R_RAX; +} + +/* ----------------------------------------------------------------------------- + * resolve_gpr32 () - 32bit General Purpose Register-Selection. + * ----------------------------------------------------------------------------- + */ +static enum ud_type +resolve_gpr32(struct ud* u, enum ud_operand_code gpr_op) +{ + gpr_op = gpr_op - OP_eAX; + + if (u->opr_mode == 16) + return gpr_op + UD_R_AX; + + return gpr_op + UD_R_EAX; +} + +/* ----------------------------------------------------------------------------- + * resolve_reg() - Resolves the register type + * ----------------------------------------------------------------------------- + */ +static enum ud_type +resolve_reg(struct ud* u, unsigned int type, unsigned char i) +{ + switch (type) { + case T_MMX : return UD_R_MM0 + (i & 7); + case T_XMM : return UD_R_XMM0 + i; + case T_CRG : return UD_R_CR0 + i; + case T_DBG : return UD_R_DR0 + i; + case T_SEG : return UD_R_ES + (i & 7); + case T_NONE: + default: return UD_NONE; + } +} + +/* ----------------------------------------------------------------------------- + * decode_imm() - Decodes Immediate values. + * ----------------------------------------------------------------------------- + */ +static void +decode_imm(struct ud* u, unsigned int s, struct ud_operand *op) +{ + op->size = resolve_operand_size(u, s); + op->type = UD_OP_IMM; + + switch (op->size) { + case 8: op->lval.sbyte = inp_uint8(u); break; + case 16: op->lval.uword = inp_uint16(u); break; + case 32: op->lval.udword = inp_uint32(u); break; + case 64: op->lval.uqword = inp_uint64(u); break; + default: return; + } +} + +/* ----------------------------------------------------------------------------- + * decode_modrm() - Decodes ModRM Byte + * ----------------------------------------------------------------------------- + */ +static void +decode_modrm(struct ud* u, struct ud_operand *op, unsigned int s, + unsigned char rm_type, struct ud_operand *opreg, + unsigned char reg_size, unsigned char reg_type) +{ + unsigned char mod, rm, reg; + + inp_next(u); + + /* get mod, r/m and reg fields */ + mod = MODRM_MOD(inp_curr(u)); + rm = (REX_B(u->pfx_rex) << 3) | MODRM_RM(inp_curr(u)); + reg = (REX_R(u->pfx_rex) << 3) | MODRM_REG(inp_curr(u)); + + op->size = resolve_operand_size(u, s); + + /* if mod is 11b, then the UD_R_m specifies a gpr/mmx/sse/control/debug */ + if (mod == 3) { + op->type = UD_OP_REG; + if (rm_type == T_GPR) + op->base = decode_gpr(u, op->size, rm); + else op->base = resolve_reg(u, rm_type, (REX_B(u->pfx_rex) << 3) | (rm&7)); + } + /* else its memory addressing */ + else { + op->type = UD_OP_MEM; + + /* 64bit addressing */ + if (u->adr_mode == 64) { + + op->base = UD_R_RAX + rm; + + /* get offset type */ + if (mod == 1) + op->offset = 8; + else if (mod == 2) + op->offset = 32; + else if (mod == 0 && (rm & 7) == 5) { + op->base = UD_R_RIP; + op->offset = 32; + } else op->offset = 0; + + /* Scale-Index-Base (SIB) */ + if ((rm & 7) == 4) { + inp_next(u); + + op->scale = (1 << SIB_S(inp_curr(u))) & ~1; + op->index = UD_R_RAX + (SIB_I(inp_curr(u)) | (REX_X(u->pfx_rex) << 3)); + op->base = UD_R_RAX + (SIB_B(inp_curr(u)) | (REX_B(u->pfx_rex) << 3)); + + /* special conditions for base reference */ + if (op->index == UD_R_RSP) { + op->index = UD_NONE; + op->scale = UD_NONE; + } + + if (op->base == UD_R_RBP || op->base == UD_R_R13) { + if (mod == 0) + op->base = UD_NONE; + if (mod == 1) + op->offset = 8; + else op->offset = 32; + } + } + } + + /* 32-Bit addressing mode */ + else if (u->adr_mode == 32) { + + /* get base */ + op->base = UD_R_EAX + rm; + + /* get offset type */ + if (mod == 1) + op->offset = 8; + else if (mod == 2) + op->offset = 32; + else if (mod == 0 && rm == 5) { + op->base = UD_NONE; + op->offset = 32; + } else op->offset = 0; + + /* Scale-Index-Base (SIB) */ + if ((rm & 7) == 4) { + inp_next(u); + + op->scale = (1 << SIB_S(inp_curr(u))) & ~1; + op->index = UD_R_EAX + (SIB_I(inp_curr(u)) | (REX_X(u->pfx_rex) << 3)); + op->base = UD_R_EAX + (SIB_B(inp_curr(u)) | (REX_B(u->pfx_rex) << 3)); + + if (op->index == UD_R_ESP) { + op->index = UD_NONE; + op->scale = UD_NONE; + } + + /* special condition for base reference */ + if (op->base == UD_R_EBP) { + if (mod == 0) + op->base = UD_NONE; + if (mod == 1) + op->offset = 8; + else op->offset = 32; + } + } + } + + /* 16bit addressing mode */ + else { + switch (rm) { + case 0: op->base = UD_R_BX; op->index = UD_R_SI; break; + case 1: op->base = UD_R_BX; op->index = UD_R_DI; break; + case 2: op->base = UD_R_BP; op->index = UD_R_SI; break; + case 3: op->base = UD_R_BP; op->index = UD_R_DI; break; + case 4: op->base = UD_R_SI; break; + case 5: op->base = UD_R_DI; break; + case 6: op->base = UD_R_BP; break; + case 7: op->base = UD_R_BX; break; + } + + if (mod == 0 && rm == 6) { + op->offset= 16; + op->base = UD_NONE; + } + else if (mod == 1) + op->offset = 8; + else if (mod == 2) + op->offset = 16; + } + } + + /* extract offset, if any */ + switch(op->offset) { + case 8 : op->lval.ubyte = inp_uint8(u); break; + case 16: op->lval.uword = inp_uint16(u); break; + case 32: op->lval.udword = inp_uint32(u); break; + case 64: op->lval.uqword = inp_uint64(u); break; + default: break; + } + + /* resolve register encoded in reg field */ + if (opreg) { + opreg->type = UD_OP_REG; + opreg->size = resolve_operand_size(u, reg_size); + if (reg_type == T_GPR) + opreg->base = decode_gpr(u, opreg->size, reg); + else opreg->base = resolve_reg(u, reg_type, reg); + } +} + +/* ----------------------------------------------------------------------------- + * decode_o() - Decodes offset + * ----------------------------------------------------------------------------- + */ +static void +decode_o(struct ud* u, unsigned int s, struct ud_operand *op) +{ + switch (u->adr_mode) { + case 64: + op->offset = 64; + op->lval.uqword = inp_uint64(u); + break; + case 32: + op->offset = 32; + op->lval.udword = inp_uint32(u); + break; + case 16: + op->offset = 16; + op->lval.uword = inp_uint16(u); + break; + default: + return; + } + op->type = UD_OP_MEM; + op->size = resolve_operand_size(u, s); +} + +/* ----------------------------------------------------------------------------- + * disasm_operands() - Disassembles Operands. + * ----------------------------------------------------------------------------- + */ +static int disasm_operands(register struct ud* u) +{ + + + /* mopXt = map entry, operand X, type; */ + enum ud_operand_code mop1t = u->itab_entry->operand1.type; + enum ud_operand_code mop2t = u->itab_entry->operand2.type; + enum ud_operand_code mop3t = u->itab_entry->operand3.type; + + /* mopXs = map entry, operand X, size */ + unsigned int mop1s = u->itab_entry->operand1.size; + unsigned int mop2s = u->itab_entry->operand2.size; + unsigned int mop3s = u->itab_entry->operand3.size; + + /* iop = instruction operand */ + register struct ud_operand* iop = u->operand; + + switch(mop1t) { + + case OP_A : + decode_a(u, &(iop[0])); + break; + + /* M[b] ... */ + case OP_M : + if (MODRM_MOD(inp_peek(u)) == 3) + u->error= 1; + /* E, G/P/V/I/CL/1/S */ + case OP_E : + if (mop2t == OP_G) { + decode_modrm(u, &(iop[0]), mop1s, T_GPR, &(iop[1]), mop2s, T_GPR); + if (mop3t == OP_I) + decode_imm(u, mop3s, &(iop[2])); + else if (mop3t == OP_CL) { + iop[2].type = UD_OP_REG; + iop[2].base = UD_R_CL; + iop[2].size = 8; + } + } + else if (mop2t == OP_P) + decode_modrm(u, &(iop[0]), mop1s, T_GPR, &(iop[1]), mop2s, T_MMX); + else if (mop2t == OP_V) + decode_modrm(u, &(iop[0]), mop1s, T_GPR, &(iop[1]), mop2s, T_XMM); + else if (mop2t == OP_S) + decode_modrm(u, &(iop[0]), mop1s, T_GPR, &(iop[1]), mop2s, T_SEG); + else { + decode_modrm(u, &(iop[0]), mop1s, T_GPR, NULL, 0, T_NONE); + if (mop2t == OP_CL) { + iop[1].type = UD_OP_REG; + iop[1].base = UD_R_CL; + iop[1].size = 8; + } else if (mop2t == OP_I1) { + iop[1].type = UD_OP_CONST; + u->operand[1].lval.udword = 1; + } else if (mop2t == OP_I) { + decode_imm(u, mop2s, &(iop[1])); + } + } + break; + + /* G, E/PR[,I]/VR */ + case OP_G : + if (mop2t == OP_M) { + if (MODRM_MOD(inp_peek(u)) == 3) + u->error= 1; + decode_modrm(u, &(iop[1]), mop2s, T_GPR, &(iop[0]), mop1s, T_GPR); + } else if (mop2t == OP_E) { + decode_modrm(u, &(iop[1]), mop2s, T_GPR, &(iop[0]), mop1s, T_GPR); + if (mop3t == OP_I) + decode_imm(u, mop3s, &(iop[2])); + } else if (mop2t == OP_PR) { + decode_modrm(u, &(iop[1]), mop2s, T_MMX, &(iop[0]), mop1s, T_GPR); + if (mop3t == OP_I) + decode_imm(u, mop3s, &(iop[2])); + } else if (mop2t == OP_VR) { + if (MODRM_MOD(inp_peek(u)) != 3) + u->error = 1; + decode_modrm(u, &(iop[1]), mop2s, T_XMM, &(iop[0]), mop1s, T_GPR); + } else if (mop2t == OP_W) + decode_modrm(u, &(iop[1]), mop2s, T_XMM, &(iop[0]), mop1s, T_GPR); + break; + + /* AL..BH, I/O/DX */ + case OP_AL : case OP_CL : case OP_DL : case OP_BL : + case OP_AH : case OP_CH : case OP_DH : case OP_BH : + + iop[0].type = UD_OP_REG; + iop[0].base = UD_R_AL + (mop1t - OP_AL); + iop[0].size = 8; + + if (mop2t == OP_I) + decode_imm(u, mop2s, &(iop[1])); + else if (mop2t == OP_DX) { + iop[1].type = UD_OP_REG; + iop[1].base = UD_R_DX; + iop[1].size = 16; + } + else if (mop2t == OP_O) + decode_o(u, mop2s, &(iop[1])); + break; + + /* rAX[r8]..rDI[r15], I/rAX..rDI/O */ + case OP_rAXr8 : case OP_rCXr9 : case OP_rDXr10 : case OP_rBXr11 : + case OP_rSPr12: case OP_rBPr13: case OP_rSIr14 : case OP_rDIr15 : + case OP_rAX : case OP_rCX : case OP_rDX : case OP_rBX : + case OP_rSP : case OP_rBP : case OP_rSI : case OP_rDI : + + iop[0].type = UD_OP_REG; + iop[0].base = resolve_gpr64(u, mop1t); + + if (mop2t == OP_I) + decode_imm(u, mop2s, &(iop[1])); + else if (mop2t >= OP_rAX && mop2t <= OP_rDI) { + iop[1].type = UD_OP_REG; + iop[1].base = resolve_gpr64(u, mop2t); + } + else if (mop2t == OP_O) { + decode_o(u, mop2s, &(iop[1])); + iop[0].size = resolve_operand_size(u, mop2s); + } + break; + + /* AL[r8b]..BH[r15b], I */ + case OP_ALr8b : case OP_CLr9b : case OP_DLr10b : case OP_BLr11b : + case OP_AHr12b: case OP_CHr13b: case OP_DHr14b : case OP_BHr15b : + { + ud_type_t gpr = (mop1t - OP_ALr8b) + UD_R_AL + + (REX_B(u->pfx_rex) << 3); + if (UD_R_AH <= gpr && u->pfx_rex) + gpr = gpr + 4; + iop[0].type = UD_OP_REG; + iop[0].base = gpr; + if (mop2t == OP_I) + decode_imm(u, mop2s, &(iop[1])); + break; + } + + /* eAX..eDX, DX/I */ + case OP_eAX : case OP_eCX : case OP_eDX : case OP_eBX : + case OP_eSP : case OP_eBP : case OP_eSI : case OP_eDI : + iop[0].type = UD_OP_REG; + iop[0].base = resolve_gpr32(u, mop1t); + if (mop2t == OP_DX) { + iop[1].type = UD_OP_REG; + iop[1].base = UD_R_DX; + iop[1].size = 16; + } else if (mop2t == OP_I) + decode_imm(u, mop2s, &(iop[1])); + break; + + /* ES..GS */ + case OP_ES : case OP_CS : case OP_DS : + case OP_SS : case OP_FS : case OP_GS : + + /* in 64bits mode, only fs and gs are allowed */ + if (u->dis_mode == 64) + if (mop1t != OP_FS && mop1t != OP_GS) + u->error= 1; + iop[0].type = UD_OP_REG; + iop[0].base = (mop1t - OP_ES) + UD_R_ES; + iop[0].size = 16; + + break; + + /* J */ + case OP_J : + decode_imm(u, mop1s, &(iop[0])); + iop[0].type = UD_OP_JIMM; + break ; + + /* PR, I */ + case OP_PR: + if (MODRM_MOD(inp_peek(u)) != 3) + u->error = 1; + decode_modrm(u, &(iop[0]), mop1s, T_MMX, NULL, 0, T_NONE); + if (mop2t == OP_I) + decode_imm(u, mop2s, &(iop[1])); + break; + + /* VR, I */ + case OP_VR: + if (MODRM_MOD(inp_peek(u)) != 3) + u->error = 1; + decode_modrm(u, &(iop[0]), mop1s, T_XMM, NULL, 0, T_NONE); + if (mop2t == OP_I) + decode_imm(u, mop2s, &(iop[1])); + break; + + /* P, Q[,I]/W/E[,I],VR */ + case OP_P : + if (mop2t == OP_Q) { + decode_modrm(u, &(iop[1]), mop2s, T_MMX, &(iop[0]), mop1s, T_MMX); + if (mop3t == OP_I) + decode_imm(u, mop3s, &(iop[2])); + } else if (mop2t == OP_W) { + decode_modrm(u, &(iop[1]), mop2s, T_XMM, &(iop[0]), mop1s, T_MMX); + } else if (mop2t == OP_VR) { + if (MODRM_MOD(inp_peek(u)) != 3) + u->error = 1; + decode_modrm(u, &(iop[1]), mop2s, T_XMM, &(iop[0]), mop1s, T_MMX); + } else if (mop2t == OP_E) { + decode_modrm(u, &(iop[1]), mop2s, T_GPR, &(iop[0]), mop1s, T_MMX); + if (mop3t == OP_I) + decode_imm(u, mop3s, &(iop[2])); + } + break; + + /* R, C/D */ + case OP_R : + if (mop2t == OP_C) + decode_modrm(u, &(iop[0]), mop1s, T_GPR, &(iop[1]), mop2s, T_CRG); + else if (mop2t == OP_D) + decode_modrm(u, &(iop[0]), mop1s, T_GPR, &(iop[1]), mop2s, T_DBG); + break; + + /* C, R */ + case OP_C : + decode_modrm(u, &(iop[1]), mop2s, T_GPR, &(iop[0]), mop1s, T_CRG); + break; + + /* D, R */ + case OP_D : + decode_modrm(u, &(iop[1]), mop2s, T_GPR, &(iop[0]), mop1s, T_DBG); + break; + + /* Q, P */ + case OP_Q : + decode_modrm(u, &(iop[0]), mop1s, T_MMX, &(iop[1]), mop2s, T_MMX); + break; + + /* S, E */ + case OP_S : + decode_modrm(u, &(iop[1]), mop2s, T_GPR, &(iop[0]), mop1s, T_SEG); + break; + + /* W, V */ + case OP_W : + decode_modrm(u, &(iop[0]), mop1s, T_XMM, &(iop[1]), mop2s, T_XMM); + break; + + /* V, W[,I]/Q/M/E */ + case OP_V : + if (mop2t == OP_W) { + /* special cases for movlps and movhps */ + if (MODRM_MOD(inp_peek(u)) == 3) { + if (u->mnemonic == UD_Imovlps) + u->mnemonic = UD_Imovhlps; + else + if (u->mnemonic == UD_Imovhps) + u->mnemonic = UD_Imovlhps; + } + decode_modrm(u, &(iop[1]), mop2s, T_XMM, &(iop[0]), mop1s, T_XMM); + if (mop3t == OP_I) + decode_imm(u, mop3s, &(iop[2])); + } else if (mop2t == OP_Q) + decode_modrm(u, &(iop[1]), mop2s, T_MMX, &(iop[0]), mop1s, T_XMM); + else if (mop2t == OP_M) { + if (MODRM_MOD(inp_peek(u)) == 3) + u->error= 1; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Tue Jan 8 08:51:16 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 5CAFFB6F for ; Tue, 8 Jan 2013 08:51:15 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 08 Jan 2013 08:48:06 +0000 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20130108085115.5CAFFB6F@hub.freebsd.org> X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 08:51:16 -0000 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 #include -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();