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.


various fixes
Jack Lange [Tue, 24 Apr 2012 21:16:44 +0000 (17:16 -0400)]
linux_module/iface-file.c
palacios/include/interfaces/vmm_file.h
palacios/src/devices/filedisk.c
palacios/src/devices/ide.c
palacios/src/devices/pci.c
palacios/src/palacios/svm_handler.c
palacios/src/palacios/vmm_shadow_paging.c

index be31f16..091c773 100644 (file)
@@ -243,7 +243,7 @@ static int palacios_file_close(void * file_ptr) {
     return 0;
 }
 
-static long long palacios_file_size(void * file_ptr) {
+static unsigned long long palacios_file_size(void * file_ptr) {
     struct palacios_file * pfile = (struct palacios_file *)file_ptr;
     struct file * filp = pfile->filp;
     struct kstat s;
@@ -259,7 +259,7 @@ static long long palacios_file_size(void * file_ptr) {
     return s.size;
 }
 
-static long long palacios_file_read(void * file_ptr, void * buffer, long long length, long long offset){
+static unsigned long long palacios_file_read(void * file_ptr, void * buffer, unsigned long long length, unsigned long long offset){
     struct palacios_file * pfile = (struct palacios_file *)file_ptr;
     struct file * filp = pfile->filp;
     ssize_t ret;
@@ -273,14 +273,14 @@ static long long palacios_file_read(void * file_ptr, void * buffer, long long le
     set_fs(old_fs);
        
     if (ret <= 0) {
-       printk("sys_read of %p for %lld bytes failed\n", filp, length);         
+       printk("sys_read of %p for %lld bytes at offset %llu failed (ret=%ld)\n", filp, length, offset, ret);
     }
        
     return ret;
 }
 
 
-static long long palacios_file_write(void * file_ptr, void * buffer, long long length, long long offset) {
+static unsigned long long palacios_file_write(void * file_ptr, void * buffer, unsigned long long length, unsigned long long offset) {
     struct palacios_file * pfile = (struct palacios_file *)file_ptr;
     struct file * filp = pfile->filp;
     mm_segment_t old_fs;
@@ -295,7 +295,7 @@ static long long palacios_file_write(void * file_ptr, void * buffer, long long l
 
  
     if (ret <= 0) {
-       printk("sys_write failed\n");           
+       printk("sys_write for %llu bytes at offset %llu failed (ret=%ld)\n", length, offset, ret);              
     }
        
     return ret;
index 69b78d8..421c73e 100644 (file)
@@ -49,11 +49,11 @@ struct v3_file_hooks {
     void * (*open)(const char * path, int mode, void * host_data);
     int (*close)(void * fd);
 
-    long long (*size)(void * fd);
+    unsigned long long (*size)(void * fd);
 
     // blocking reads and writes
-    long long (*read)(void * fd, void * buffer, long long length, long long offset);
-    long long (*write)(void * fd, void * buffer, long long length, long long offset);
+    unsigned long long (*read)(void * fd, void * buffer, unsigned long long length, unsigned long long offset);
+    unsigned long long (*write)(void * fd, void * buffer, unsigned long long length, unsigned long long offset);
 
 };
 
index bf1aaf8..9625d3b 100644 (file)
@@ -36,10 +36,10 @@ struct disk_state {
 
 
 
-static int write_all(v3_file_t fd, char * buf, int offset, int length) {
-    int bytes_written = 0;
+static int write_all(v3_file_t fd, char * buf, uint64_t offset, uint64_t length) {
+    uint64_t bytes_written = 0;
     
-    PrintDebug("Writing %d bytes\n", length - bytes_written);
+    PrintDebug("Writing %llu bytes\n", length - bytes_written);
     while (bytes_written < length) {
        int tmp_bytes = v3_file_write(fd, buf + bytes_written, length - bytes_written, offset + bytes_written);
        PrintDebug("Wrote %d bytes\n", tmp_bytes);
@@ -56,10 +56,10 @@ static int write_all(v3_file_t fd, char * buf, int offset, int length) {
 }
 
 
-static int read_all(v3_file_t fd, char * buf, int offset, int length) {
-    int bytes_read = 0;
+static int read_all(v3_file_t fd, char * buf, uint64_t offset, uint64_t length) {
+    uint64_t bytes_read = 0;
     
-    PrintDebug("Reading %d bytes\n", length - bytes_read);
+    PrintDebug("Reading %llu bytes\n", length - bytes_read);
     while (bytes_read < length) {
        int tmp_bytes = v3_file_read(fd, buf + bytes_read, length - bytes_read, offset + bytes_read);
        PrintDebug("Read %d bytes\n", tmp_bytes);
@@ -78,7 +78,7 @@ static int read_all(v3_file_t fd, char * buf, int offset, int length) {
 static int read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) {
     struct disk_state * disk = (struct disk_state *)private_data;
 
-    PrintDebug("Reading %d bytes from %p to %p\n", (uint32_t)num_bytes, (uint8_t *)(disk->disk_image + lba), buf);
+    PrintDebug("Reading %llu bytes from %p to %p\n", num_bytes, (uint8_t *)(disk->disk_image + lba), buf);
 
     if (lba + num_bytes > disk->capacity) {
        PrintError("Out of bounds read: lba=%llu, num_bytes=%llu, capacity=%llu\n",
@@ -93,7 +93,7 @@ static int read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_
 static int write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) {
     struct disk_state * disk = (struct disk_state *)private_data;
 
-    PrintDebug("Writing %d bytes from %p to %p\n", (uint32_t)num_bytes,  buf, (uint8_t *)(disk->disk_image + lba));
+    PrintDebug("Writing %llu bytes from %p to %p\n", num_bytes,  buf, (uint8_t *)(disk->disk_image + lba));
 
     if (lba + num_bytes > disk->capacity) {
        PrintError("Out of bounds read: lba=%llu, num_bytes=%llu, capacity=%llu\n",
@@ -109,8 +109,7 @@ static int write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private
 static uint64_t get_capacity(void * private_data) {
     struct disk_state * disk = (struct disk_state *)private_data;
 
-    PrintDebug("Querying FILEDISK capacity %d\n", 
-              (uint32_t)(disk->capacity));
+    PrintDebug("Querying FILEDISK capacity %llu\n", disk->capacity);
 
     return disk->capacity;
 }
@@ -183,8 +182,8 @@ static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
 
     disk->capacity = v3_file_size(disk->fd);
 
-    PrintDebug("Registering FILEDISK %s (path=%s, fd=%lu, size=%lu)\n",
-              dev_id, path, file->fd, file->capacity);
+    V3_Print("Registering FILEDISK %s (path=%s, fd=%lu, size=%llu)\n",
+            dev_id, path, (addr_t)disk->fd, disk->capacity);
 
 
     if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"), 
index e949fcb..206a8ef 100644 (file)
@@ -366,12 +366,12 @@ static int dma_write(struct guest_info * core, struct ide_internal * ide, struct
 #include "ata.h"
 
 
-#ifdef V3_CONFIG_DEBUG_IDE
+
 static void print_prd_table(struct ide_internal * ide, struct ide_channel * channel) {
     struct ide_dma_prd prd_entry;
     int index = 0;
 
-    PrintDebug("Dumping PRD table\n");
+    V3_Print("Dumping PRD table\n");
 
     while (1) {
        uint32_t prd_entry_addr = channel->dma_prd_addr + (sizeof(struct ide_dma_prd) * index);
@@ -384,7 +384,7 @@ static void print_prd_table(struct ide_internal * ide, struct ide_channel * chan
            return;
        }
 
-       PrintDebug("\tPRD Addr: %x, PRD Len: %d, EOT: %d\n", 
+       V3_Print("\tPRD Addr: %x, PRD Len: %d, EOT: %d\n", 
                   prd_entry.base_addr, 
                   (prd_entry.size == 0) ? 0x10000 : prd_entry.size, 
                   prd_entry.end_of_table);
@@ -398,7 +398,7 @@ static void print_prd_table(struct ide_internal * ide, struct ide_channel * chan
 
     return;
 }
-#endif
+
 
 /* IO Operations */
 static int dma_read(struct guest_info * core, struct ide_internal * ide, struct ide_channel * channel) {
@@ -604,7 +604,13 @@ static int dma_write(struct guest_info * core, struct ide_internal * ide, struct
        PrintDebug("PRD Addr: %x, PRD Len: %d, EOT: %d\n", 
                   prd_entry.base_addr, prd_entry.size, prd_entry.end_of_table);
 
-       prd_bytes_left = prd_entry.size;
+
+       if (prd_entry.size == 0) {
+           // a size of 0 means 64k
+           prd_bytes_left = 0x10000;
+       } else {
+           prd_bytes_left = prd_entry.size;
+       }
 
        while (prd_bytes_left > 0) {
            uint_t bytes_to_write = 0;
@@ -645,6 +651,12 @@ static int dma_write(struct guest_info * core, struct ide_internal * ide, struct
 
        if ((prd_entry.end_of_table == 1) && (bytes_left > 0)) {
            PrintError("DMA table not large enough for data transfer...\n");
+           PrintError("\t(bytes_left=%u) (transfer_length=%u)...\n", 
+                      bytes_left, drive->transfer_length);
+           PrintError("PRD Addr: %x, PRD Len: %d, EOT: %d\n", 
+                      prd_entry.base_addr, prd_entry.size, prd_entry.end_of_table);
+
+           print_prd_table(ide, channel);
            return -1;
        }
     }
index 1e617f6..f9a2f9b 100644 (file)
@@ -1396,6 +1396,8 @@ int v3_pci_raise_acked_irq(struct vm_device * pci_bus, struct pci_device * dev,
 
        memset(&ipi, 0, sizeof(struct v3_gen_ipi));
 
+       // decode MSI fields into IPI
+
        ipi.vector = data->vector + vec.irq;
        ipi.mode = data->del_mode;
        ipi.logical = addr->dst_mode;
@@ -1403,9 +1405,6 @@ int v3_pci_raise_acked_irq(struct vm_device * pci_bus, struct pci_device * dev,
        ipi.dst_shorthand = 0;
        ipi.dst = addr->dst_id;
        
-       // decode MSI fields into IPI
-
-       V3_Print("Decode MSI\n");
 
        v3_apic_send_ipi(dev->vm, &ipi, dev->apic_dev);
 
@@ -1436,6 +1435,7 @@ int v3_pci_raise_acked_irq(struct vm_device * pci_bus, struct pci_device * dev,
        data = &(msix_table->entries[vec.irq].data);
        addr = &(msix_table->entries[vec.irq].addr);;
        
+       // decode MSIX fields into IPI
        ipi.vector = data->vector + vec.irq;
        ipi.mode = data->del_mode;
        ipi.logical = addr->dst_mode;
@@ -1443,7 +1443,7 @@ int v3_pci_raise_acked_irq(struct vm_device * pci_bus, struct pci_device * dev,
        ipi.dst_shorthand = 0;
        ipi.dst = addr->dst_id;
        
-       // decode MSIX fields into IPI
+
 
        V3_Print("Decode MSIX\n");
 
index 1fc0b7c..96fcaa1 100644 (file)
@@ -56,7 +56,8 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i
 #endif
 
 
-    //PrintDebug("SVM Returned: Exit Code: %x\n",exit_code); 
+
+    //    PrintDebug("SVM Returned: Exit Code: %p\n", (void *)exit_code); 
 
     switch (exit_code) {
        case VMEXIT_IOIO: {
@@ -309,10 +310,10 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i
            PrintError("SVM Returned: Exit Code: %p\n", (void *)(addr_t)exit_code); 
            
            PrintError("io_info1 low = 0x%.8x\n", *(uint_t*)&(exit_info1));
-           PrintError("io_info1 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(exit_info1)) + 4));
+           PrintError("io_info1 high = 0x%.8x\n", *(uint_t *)(((uint8_t *)&(exit_info1)) + 4));
            
            PrintError("io_info2 low = 0x%.8x\n", *(uint_t*)&(exit_info2));
-           PrintError("io_info2 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(exit_info2)) + 4));
+           PrintError("io_info2 high = 0x%.8x\n", *(uint_t *)(((uint8_t *)&(exit_info2)) + 4));
            
            
            if (info->shdw_pg_mode == SHADOW_PAGING) {
index f57ddda..d3e4c93 100644 (file)
@@ -197,6 +197,11 @@ int v3_init_shdw_impl(struct v3_vm_info * vm) {
 int v3_deinit_shdw_impl(struct v3_vm_info * vm) {
     struct v3_shdw_pg_impl * impl = vm->shdw_impl.current_impl;
 
+    if (impl == NULL) {
+       // Shadow paging not implemented
+       return 0;
+    }
+
     if (impl->deinit(vm) == -1) {
        PrintError("Error deinitializing shadow paging implementation\n");
        return -1;