Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Disallow startup with shadow paging + memory region outside 4GB boundary
[palacios.git] / palacios / src / palacios / svm_io.c
index e273466..ff85d09 100644 (file)
@@ -46,9 +46,19 @@ static int update_map(struct v3_vm_info * vm, uint16_t port, int hook_read, int
 
 
 int v3_init_svm_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(3));
+    temp = V3_AllocPages(3);
+    
+    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 * 3);
 
 
@@ -80,11 +90,10 @@ int v3_handle_svm_io_in(struct guest_info * core, struct svm_io_info * io_info)
     PrintDebug("IN of %d bytes on port %d (0x%x)\n", read_size, io_info->port, io_info->port);
 
     if (hook == NULL) {
-       PrintDebug("IN operation on unhooked IO port 0x%x\n", io_info->port);
+       PrintDebug("IN operation on unhooked IO port 0x%x - returning zero\n", io_info->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_info->port, &(core->vm_regs.rax), read_size, hook->priv_data) != read_size) {
            // not sure how we handle errors.....
@@ -207,10 +216,9 @@ int v3_handle_svm_io_ins(struct guest_info * core, struct svm_io_info * io_info)
        }
 
        if (hook == NULL) {
-           PrintDebug("INS operation on unhooked IO port 0x%x\n", io_info->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??? 
-            */     
+           PrintDebug("INS operation on unhooked IO port 0x%x - returning zeros\n", io_info->port);
+           memset((char*)host_addr,0,read_size);
+           
        } else {
            if (hook->read(core, io_info->port, (char *)host_addr, read_size, hook->priv_data) != read_size) {
                // not sure how we handle errors.....
@@ -246,7 +254,7 @@ int v3_handle_svm_io_out(struct guest_info * core, struct svm_io_info * io_info)
     PrintDebug("OUT of %d bytes on  port %d (0x%x)\n", write_size, io_info->port, io_info->port);
 
     if (hook == NULL) {
-       PrintDebug("OUT operation on unhooked IO port 0x%x\n", io_info->port);
+       PrintDebug("OUT operation on unhooked IO port 0x%x - ignored\n", io_info->port);
     } else {
        if (hook->write(core, io_info->port, &(core->vm_regs.rax), write_size, hook->priv_data) != write_size) {
            // not sure how we handle errors.....
@@ -365,7 +373,7 @@ int v3_handle_svm_io_outs(struct guest_info * core, struct svm_io_info * io_info
        }
 
        if (hook == NULL) {
-           PrintDebug("OUTS operation on unhooked IO port 0x%x\n", io_info->port);
+           PrintDebug("OUTS operation on unhooked IO port 0x%x - ignored\n", io_info->port);
        } else {
            if (hook->write(core, io_info->port, (char*)host_addr, write_size, hook->priv_data) != write_size) {
                // not sure how we handle errors.....