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.


Merge branch 'devel' of ssh://newskysaw.cs.northwestern.edu//home/palacios/palacios...
Jack Lange [Thu, 16 Jun 2011 19:04:53 +0000 (15:04 -0400)]
palacios/src/devices/atapi.h
palacios/src/devices/generic.c
palacios/src/palacios/svm.c
palacios/src/palacios/svm_wbinvd.c

index 7d68c90..f32ed8d 100644 (file)
@@ -148,7 +148,7 @@ static int atapi_update_data_buf(struct ide_internal * ide, struct ide_channel *
        case 0x28: // read(10)
        case 0xa8: // read(12)
 
-           // Update lba address to point to next block
+           // Update lba address to point to next block  
            drive->current_lba++;
 
            // read the next block
@@ -170,7 +170,7 @@ static int atapi_read10(struct guest_info * core,
     uint32_t lba =  be_to_le_32(cmd->lba);
     uint16_t xfer_len = be_to_le_16(cmd->xfer_len);
 
-    PrintDebug("READ10: XferLen=%d\n", xfer_len);
+    PrintDebug("READ10: XferLen=%d ; LBA=%x \n", xfer_len, lba );
 
     /* Check if cd is ready
      * if not: atapi_cmd_error(... ATAPI_SEN_NOT_RDY, ASC_MEDIA_NOT_PRESENT)
index 8fd525c..9c9b290 100644 (file)
@@ -565,7 +565,7 @@ static int add_mem_range(struct vm_device * dev, addr_t start, addr_t end, gener
                return -1;
            }
            break;
-
+           
        case  GENERIC_IGNORE:
            if (v3_hook_full_mem(dev->vm, V3_MEM_CORE_ANY, start, end+1, 
                                 &generic_read_mem_ignore, 
@@ -578,10 +578,51 @@ static int add_mem_range(struct vm_device * dev, addr_t start, addr_t end, gener
            PrintError("generic (%s): huh?\n",state->name);
            break;
     }
+    
+    return 0;
+}
+
+
+#if 1
+
+//This is a hack for host device testing and will be removed
+
+static int osdebug_hcall(struct guest_info *core, uint_t hcall_id, void * priv_data) 
+{
+    struct generic_internal * state = (struct generic_internal *)priv_data;
+
+    int msg_len = core->vm_regs.rcx;
+    addr_t msg_gpa = core->vm_regs.rbx;
+    int buf_is_va = core->vm_regs.rdx;
+    int i;
+    uint8_t c;
+
+    PrintDebug("generic (%s): handling hypercall (len=%d) as sequence of port writes\n",
+              state->name, msg_len);
+
+
+    for (i=0;i<msg_len;i++) { 
+       if (buf_is_va == 1) {
+           if (v3_read_gva_memory(core, msg_gpa+i, 1, &c) != 1) {
+               PrintError("generic (%s): could not read debug message\n",state->name);
+               return -1;
+           }
+       } else {
+           if (v3_read_gpa_memory(core, msg_gpa+i, 1, &c) != 1) { 
+               PrintError("generic (%s): Could not read debug message\n",state->name);
+               return -1;
+           }
+       }
+       if (generic_write_port_print_and_passthrough(core,0xc0c0,&c,1,priv_data)!=1) { 
+           PrintError("generic (%s): write port passthrough failed\n",state->name);
+           return -1;
+       }
+    }  
 
     return 0;
 }
 
+#endif
 
 
 /*
@@ -759,6 +800,14 @@ static int generic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
 
        mem_cfg = v3_cfg_next_branch(port_cfg);
     }
+
+#if 1
+    // hack for os debug testing
+    if (strcasecmp(state->name,"os debug")==0) { 
+       PrintDebug("generic (%s): adding hypercall for os debug device\n", state->name);
+       v3_register_hypercall(vm,0xc0c0,osdebug_hcall,state);
+    }
+#endif
     
     PrintDebug("generic (%s): initialization complete\n", state->name);
 
index 7d7b43c..d23c56d 100644 (file)
@@ -569,10 +569,14 @@ int v3_svm_enter(struct guest_info * info) {
     // Conditionally yield the CPU if the timeslice has expired
     v3_yield_cond(info);
 
-    if (v3_handle_svm_exit(info, exit_code, exit_info1, exit_info2) != 0) {
-       PrintError("Error in SVM exit handler\n");
-       PrintError("  last exit was %d\n", v3_last_exit);
-       return -1;
+    {
+       int ret = v3_handle_svm_exit(info, exit_code, exit_info1, exit_info2);
+       
+       if (ret != 0) {
+           PrintError("Error in SVM exit handler (ret=%d)\n", ret);
+           PrintError("  last Exit was %d (exit code=0x%llx)\n", v3_last_exit, (uint64_t) exit_code);
+           return -1;
+       }
     }
 
 
@@ -756,11 +760,11 @@ int v3_is_svm_capable() {
 
 static int has_svm_nested_paging() {
     uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
-
+    
     v3_cpuid(CPUID_SVM_REV_AND_FEATURE_IDS, &eax, &ebx, &ecx, &edx);
-
+    
     //PrintDebug("CPUID_EXT_FEATURE_IDS_edx=0x%x\n", edx);
-
+    
     if ((edx & CPUID_SVM_REV_AND_FEATURE_IDS_edx_np) == 0) {
        V3_Print("SVM Nested Paging not supported\n");
        return 0;
@@ -768,8 +772,8 @@ static int has_svm_nested_paging() {
        V3_Print("SVM Nested Paging supported\n");
        return 1;
     }
-}
-
+ }
 
 
 void v3_init_svm_cpu(int cpu_id) {
index c8c11e6..eb8a35f 100644 (file)
@@ -35,7 +35,7 @@ int v3_handle_svm_wbinvd(struct guest_info * info) {
        v3_raise_exception(info, GPF_EXCEPTION);
     } else {
        info->rip += 2;
-       asm("wbinvd");
+       asm volatile ("wbinvd" ::: "memory");
     }
 
     return 0;