X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmx_io.c;h=1c33f115a479937d992b47db1ee5798076cc4802;hb=e3b62e7befa086a4fb320890952f54667ee46329;hp=9b02a0a4c26e3e6f46880f17097fd04855bfcf0d;hpb=5e5c8ee949fa45116d58b904fc11aab082f61607;p=palacios.git diff --git a/palacios/src/palacios/vmx_io.c b/palacios/src/palacios/vmx_io.c index 9b02a0a..1c33f11 100644 --- a/palacios/src/palacios/vmx_io.c +++ b/palacios/src/palacios/vmx_io.c @@ -33,7 +33,7 @@ /* Same as SVM */ static int update_map(struct v3_vm_info * vm, uint16_t port, int hook_read, int hook_write) { - uchar_t * bitmap = (uint8_t *)(vm->io_map.arch_data); + uint8_t * bitmap = (uint8_t *)(vm->io_map.arch_data); int major = port / 8; int minor = port % 8; @@ -47,9 +47,17 @@ static int update_map(struct v3_vm_info * vm, uint16_t port, int hook_read, int } int v3_init_vmx_io_map(struct v3_vm_info * vm) { + void *temp; + vm->io_map.update_map = update_map; - - vm->io_map.arch_data = V3_VAddr(V3_AllocPages(2)); + + temp = V3_AllocPages(2); + if (!temp) { + PrintError("Cannot allocate io bitmap\n"); + return -1; + } + + vm->io_map.arch_data = V3_VAddr(temp); memset(vm->io_map.arch_data, 0xff, PAGE_SIZE_4KB * 2); v3_refresh_io_map(vm); @@ -75,11 +83,10 @@ int v3_handle_vmx_io_in(struct guest_info * core, struct vmx_exit_info * exit_in PrintDebug("IN of %d bytes on port %d (0x%x)\n", read_size, io_qual.port, io_qual.port); if (hook == NULL) { - PrintDebug("IN operation on unhooked IO port 0x%x\n", io_qual.port); + PrintDebug("IN operation on unhooked IO port 0x%x - returning zeros\n", io_qual.port); + core->vm_regs.rax >>= 8*read_size; + core->vm_regs.rax <<= 8*read_size; - /* What are the HW semantics for an IN on an invalid port? - * Do we need to clear the register value or leave it untouched??? - */ } else { if (hook->read(core, io_qual.port, &(core->vm_regs.rax), read_size, hook->priv_data) != read_size) { PrintError("Read failure for IN on port %x\n", io_qual.port); @@ -100,7 +107,7 @@ int v3_handle_vmx_io_ins(struct guest_info * core, struct vmx_exit_info * exit_i addr_t guest_va = exit_info->guest_linear_addr; addr_t host_addr = 0; int rdi_change = 0; - ulong_t rep_num = 1; + uint32_t rep_num = 1; struct rflags * flags = (struct rflags *)&(core->ctrl_regs.rflags); hook = v3_get_io_hook(core->vm_info, io_qual.port); @@ -143,11 +150,10 @@ int v3_handle_vmx_io_ins(struct guest_info * core, struct vmx_exit_info * exit_i do { if (hook == NULL) { - PrintDebug("INS operation on unhooked IO port 0x%x\n", io_qual.port); + PrintDebug("INS operation on unhooked IO port 0x%x - returning zeros\n", io_qual.port); - /* What are the HW semantics for an INS on an invalid port? - * Do we need to clear the memory region or leave it untouched??? - */ + memset((char*)host_addr,0,read_size); + } else { if (hook->read(core, io_qual.port, (char *)host_addr, read_size, hook->priv_data) != read_size) { PrintError("Read Failure for INS on port 0x%x\n", io_qual.port); @@ -186,7 +192,7 @@ int v3_handle_vmx_io_out(struct guest_info * core, struct vmx_exit_info * exit_i PrintDebug("OUT of %d bytes on port %d (0x%x)\n", write_size, io_qual.port, io_qual.port); if (hook == NULL) { - PrintDebug("OUT operation on unhooked IO port 0x%x\n", io_qual.port); + PrintDebug("OUT operation on unhooked IO port 0x%x - ignored\n", io_qual.port); } else { if (hook->write(core, io_qual.port, &(core->vm_regs.rax), write_size, hook->priv_data) != write_size) { PrintError("Write failure for out on port %x\n",io_qual.port); @@ -208,7 +214,7 @@ int v3_handle_vmx_io_outs(struct guest_info * core, struct vmx_exit_info * exit_ addr_t guest_va = exit_info->guest_linear_addr; addr_t host_addr; int rsi_change; - ulong_t rep_num = 1; + uint32_t rep_num = 1; struct rflags * flags = (struct rflags *)&(core->ctrl_regs.rflags); hook = v3_get_io_hook(core->vm_info, io_qual.port); @@ -251,7 +257,7 @@ int v3_handle_vmx_io_outs(struct guest_info * core, struct vmx_exit_info * exit_ do { if (hook == NULL) { - PrintDebug("OUTS operation on unhooked IO port 0x%x\n", io_qual.port); + PrintDebug("OUTS operation on unhooked IO port 0x%x - ignored\n", io_qual.port); } else { if (hook->write(core, io_qual.port, (char *)host_addr, write_size, hook->priv_data) != write_size) { PrintError("Read failure for INS on port 0x%x\n", io_qual.port);