X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm_io.c;h=1406ee00d78155e020e05beaa4f3aa552beb39b9;hb=bf9d843e65ef72688da11ea6d1216909729395b3;hp=12610a1a7d686a8d1aca37e77ec91fb586b20bdd;hpb=cc6a2b14d3fdebb1c705b251e8818fa401786956;p=palacios.git diff --git a/palacios/src/palacios/svm_io.c b/palacios/src/palacios/svm_io.c index 12610a1..1406ee0 100644 --- a/palacios/src/palacios/svm_io.c +++ b/palacios/src/palacios/svm_io.c @@ -23,12 +23,38 @@ #include #include -#ifndef DEBUG_IO +#ifndef CONFIG_DEBUG_IO #undef PrintDebug #define PrintDebug(fmt, args...) #endif +static int update_map(struct guest_info * info, uint16_t port, int hook_read, int hook_write) { + uchar_t * bitmap = (uint8_t *)(info->io_map.arch_data);; + int major = port / 8; + int minor = port % 8; + + if ((hook_read == 0) && (hook_write == 0)) { + *(bitmap + major) &= ~(0x1 << minor); + } else { + *(bitmap + major) |= (0x1 << minor); + } + + return 0; +} + + +int v3_init_svm_io_map(struct guest_info * info) { + info->io_map.update_map = update_map; + + info->io_map.arch_data = V3_VAddr(V3_AllocPages(3)); + memset(info->io_map.arch_data, 0, PAGE_SIZE_4KB * 3); + + + v3_refresh_io_map(info); + + return 0; +} @@ -42,7 +68,7 @@ int v3_handle_svm_io_in(struct guest_info * info) { int read_size = 0; if (hook == NULL) { - PrintError("Hook Not present for in on port %x\n", io_info->port); + PrintError("Hook Not present for in on port 0x%x\n", io_info->port); // error, we should not have exited on this port return -1; } @@ -60,7 +86,7 @@ int v3_handle_svm_io_in(struct guest_info * info) { if (hook->read(io_info->port, &(info->vm_regs.rax), read_size, hook->priv_data) != read_size) { // not sure how we handle errors..... - PrintError("Read Failure for in on port %x\n", io_info->port); + PrintError("Read Failure for in on port 0x%x\n", io_info->port); return -1; } @@ -103,7 +129,7 @@ int v3_handle_svm_io_ins(struct guest_info * info) { if (hook == NULL) { - PrintError("Hook Not present for ins on port %x\n", io_info->port); + PrintError("Hook Not present for ins on port 0x%x\n", io_info->port); // error, we should not have exited on this port return -1; } @@ -194,7 +220,7 @@ int v3_handle_svm_io_ins(struct guest_info * info) { if (hook->read(io_info->port, (char *)host_addr, read_size, hook->priv_data) != read_size) { // not sure how we handle errors..... - PrintError("Read Failure for ins on port %x\n", io_info->port); + PrintError("Read Failure for ins on port 0x%x\n", io_info->port); return -1; } @@ -222,7 +248,7 @@ int v3_handle_svm_io_out(struct guest_info * info) { int write_size = 0; if (hook == NULL) { - PrintError("Hook Not present for out on port %x\n", io_info->port); + PrintError("Hook Not present for out on port 0x%x\n", io_info->port); // error, we should not have exited on this port return -1; } @@ -240,7 +266,7 @@ int v3_handle_svm_io_out(struct guest_info * info) { if (hook->write(io_info->port, &(info->vm_regs.rax), write_size, hook->priv_data) != write_size) { // not sure how we handle errors..... - PrintError("Write Failure for out on port %x\n", io_info->port); + PrintError("Write Failure for out on port 0x%x\n", io_info->port); return -1; } @@ -281,7 +307,7 @@ int v3_handle_svm_io_outs(struct guest_info * info) { if (hook == NULL) { - PrintError("Hook Not present for outs on port %x\n", io_info->port); + PrintError("Hook Not present for outs on port 0x%x\n", io_info->port); // error, we should not have exited on this port return -1; } @@ -367,7 +393,7 @@ int v3_handle_svm_io_outs(struct guest_info * info) { if (hook->write(io_info->port, (char*)host_addr, write_size, hook->priv_data) != write_size) { // not sure how we handle errors..... - PrintError("Write Failure for outs on port %x\n", io_info->port); + PrintError("Write Failure for outs on port 0x%x\n", io_info->port); return -1; }