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.


Linux compatibility fixes
Kyle Hale [Fri, 25 Sep 2015 19:39:50 +0000 (14:39 -0500)]
This includes some changes for proc, vfs, and IOMMU code to account
for interfaces changes in Linux

linux_module/buddy.c
linux_module/iface-file.c
linux_module/iface-host-pci-hw.h
linux_module/main.c
linux_module/palacios.h

index 9cc89f1..ed692c8 100644 (file)
@@ -534,9 +534,9 @@ zone_mem_show(struct seq_file * s, void * v) {
 
 
 static int zone_proc_open(struct inode * inode, struct file * filp) {
-    struct proc_dir_entry * proc_entry = PDE(inode);
-    INFO("proc_entry at %p, data at %p\n", proc_entry, proc_entry->data);
-    return single_open(filp, zone_mem_show, proc_entry->data);
+    struct proc_dir_entry * proc_entry = PAL_PDE(inode);
+    INFO("proc_entry at %p, data at %p\n", proc_entry, PAL_PROC_GETDATA(inode));
+    return single_open(filp, zone_mem_show, PAL_PROC_GETDATA(inode));
 }
 
 
@@ -655,6 +655,8 @@ buddy_init(
 {
     struct buddy_memzone * zone = NULL;
     unsigned long i;
+       struct proc_dir_entry * zone_entry = NULL;
+       char proc_file_name[128];
 
     DEBUG("Initializing Memory zone with up to %lu bit blocks on Node %d\n", max_order, node_id);
 
@@ -705,23 +707,17 @@ buddy_init(
 
     INFO("Allocated zone at %p\n", zone);
 
-    {
-       struct proc_dir_entry * zone_entry = NULL;
-       char proc_file_name[128];
 
        memset(proc_file_name, 0, 128);
        snprintf(proc_file_name, 128, "v3-mem%u", zone->node_id);
 
-       zone_entry = create_proc_entry(proc_file_name, 0444, palacios_get_procdir());
-       if (zone_entry) {
-           zone_entry->proc_fops = &zone_proc_ops;
-           zone_entry->data = zone;
+    PAL_PROC_CREATE_DATA(zone_entry, proc_file_name, 0444, palacios_get_procdir(), &zone_proc_ops, zone);
+    if (zone_entry) {
            INFO("Successfully created /proc/v3vee/v3-mem%d\n", zone->node_id);
        } else {
            ERROR("Cannot create /proc/v3vee/v3-mem%d\n", zone->node_id);
        }
 
-    }
 
     return zone;
 }
index 67a4e73..6f69c3d 100644 (file)
@@ -20,6 +20,12 @@ static struct list_head global_files;
 
 #define isprint(a) ((a >= ' ') && (a <= '~'))
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+#define PAL_VFS_GETATTR(path, kstat) vfs_getattr(path.mnt, path.dentry, kstat)
+#else
+#define PAL_VFS_GETATTR(path, kstat) vfs_getattr(path, kstat)
+#endif
+
 struct palacios_file {
     struct file * filp;
 
@@ -276,7 +282,7 @@ static unsigned long long palacios_file_size(void * file_ptr) {
     struct kstat s;
     int ret;
     
-    ret = vfs_getattr(filp->f_path.mnt, filp->f_path.dentry, &s);
+    ret = PAL_VFS_GETATTR(filp->f_path, &s);
 
     if (ret != 0) {
        ERROR("Failed to fstat file\n");
index 66e6f45..36e3849 100644 (file)
 
 #define PCI_HDR_SIZE 256
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 43)
+#define IOMMU_FOUND()        iommu_present(&pci_bus_type)
+#define IOMMU_DOMAIN_ALLOC() iommu_domain_alloc(&pci_bus_type)
+#else
+#define IOMMU_FOUND()        iommu_found()
+#define IOMMU_DOMAIN_ALLOC() iommu_domain_alloc()
+#endif
+
+
 
 static int setup_hw_pci_dev(struct host_pci_device * host_dev) {
     int ret = 0;
@@ -136,7 +145,7 @@ static int setup_hw_pci_dev(struct host_pci_device * host_dev) {
 
 
     /* HARDCODED for now but this will need to depend on IOMMU support detection */
-    if (iommu_found()) {
+    if (IOMMU_FOUND()) {
        printk("Setting host PCI device (%s) as IOMMU\n", host_dev->name);
        v3_dev->iface = IOMMU;
     } else {
@@ -345,7 +354,7 @@ static int reserve_hw_pci_dev(struct host_pci_device * host_dev, void * v3_ctx)
        int flags = 0;
        uintptr_t gpa = 0;
 
-       host_dev->hw_dev.iommu_domain = iommu_domain_alloc();
+       host_dev->hw_dev.iommu_domain = IOMMU_DOMAIN_ALLOC();
 
        while (V3_get_guest_mem_region(v3_ctx, &region, gpa)) {
        
index f69b269..7b40e19 100644 (file)
@@ -493,14 +493,12 @@ static int read_guests(struct seq_file *s, void *v)
 
 static int guests_short_proc_open(struct inode * inode, struct file * filp) 
 {
-    struct proc_dir_entry * proc_entry = PDE(inode);
-    return single_open(filp, read_guests, proc_entry->data);
+    return single_open(filp, read_guests, PAL_PROC_GETDATA(inode));
 }
 
 static int guests_full_proc_open(struct inode * inode, struct file * filp) 
 {
-    struct proc_dir_entry * proc_entry = PDE(inode);
-    return single_open(filp, read_guests_details, proc_entry->data);
+    return single_open(filp, read_guests_details, PAL_PROC_GETDATA(inode));
 }
 
 
@@ -580,8 +578,7 @@ static int read_info(struct seq_file *s, void *v)
 
 static int info_proc_open(struct inode * inode, struct file * filp) 
 {
-    struct proc_dir_entry * proc_entry = PDE(inode);
-    return single_open(filp, read_info, proc_entry->data);
+    return single_open(filp, read_info, PAL_PROC_GETDATA(inode));
 }
 
 
@@ -684,31 +681,26 @@ static int __init v3_init(void) {
     {
        struct proc_dir_entry *entry;
 
-       entry = create_proc_entry("v3-guests", 0444, palacios_proc_dir);
-        if (entry) {
-           entry->proc_fops = &guest_short_proc_ops;
-           INFO("/proc/v3vee/v3-guests successfully created\n");
-       } else {
-           ERROR("Could not create proc entry\n");
-           goto failure6;
-       }
-       entry = create_proc_entry("v3-guests-details", 0444, palacios_proc_dir);
-        if (entry) {
-           entry->proc_fops = &guest_full_proc_ops;
-           INFO("/proc/v3vee/v3-guests-details successfully created\n");
-       } else {
-           ERROR("Could not create proc entry\n");
-           goto failure7;
-       }
+#define PALPROC(ent, success, error, out_target, fname, perm, parent, fops) \
+    PAL_PROC_CREATE(ent, fname, perm, parent, fops); \
+    if (ent) {                                    \
+        INFO(success);                            \
+    } else {                                      \
+        ERROR(error);                             \
+        goto out_target;                          \
+    }
 
-       entry = create_proc_entry("v3-info", 0444, palacios_proc_dir);
-        if (entry) {
-           entry->proc_fops = &info_proc_ops;
-           INFO("/proc/v3vee/v3-info successfully created\n");
-       } else {
-           ERROR("Could not create proc entry\n");
-           goto failure8;
-       }
+    PALPROC(entry, "/proc/v3vee/v3-guests succesfully created\n", 
+            "Could not create proc entry\n", failure6,
+            "v3-guests", 0444, palacios_proc_dir, &guest_short_proc_ops);
+
+    PALPROC(entry, "/proc/v3vee/v3-guests-details successfully created\n",
+            "Could not create proc entry\n", failure7, 
+            "v3-guests-details", 0444, palacios_proc_dir, &guest_full_proc_ops);
+
+    PALPROC(entry, "/proc/v3vee/v3-info successfully created\n", 
+            "Could not create proc entry\n", failure8, 
+            "v3-info", 0444, palacios_proc_dir, &info_proc_ops);
 
 
     }
index a546cb4..4694637 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/list.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/version.h>
 
 
 /* Global Control IOCTLs */
@@ -230,5 +231,35 @@ void  palacios_mutex_unlock_irqrestore(void *mutex, void *flags);
 #define INFO(fmt, args...) printk((KERN_INFO "palacios (pcore %u): " fmt), palacios_get_cpu(), ##args)
 #define DEBUG(fmt, args...) printk((KERN_DEBUG "palacios (pcore %u): " fmt), palacios_get_cpu(), ##args)
 
+/* Linux proc versioning */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+
+#define PAL_PROC_CREATE(ent, fname, perm, parent, fops) \
+    ent = proc_create(fname, perm, parent, fops); 
+
+#define PAL_PROC_CREATE_DATA(ent, fname, perm, parent, fops, data) \
+    ent = proc_create_data(fname, perm, parent, fops, data);
+
+#define PAL_PDE(inode) NULL
+#define PAL_PROC_GETDATA(inode) PDE_DATA((inode))
+
+#else
+
+#define PAL_PROC_CREATE(ent, fname, perm, parent, fops) \
+    ent = create_proc_entry(fname, perm, parent); \
+    if (ent) { \
+        ent->proc_fops = fops; \
+    }
+
+#define PAL_PROC_CREATE_DATA(ent, fname, perm, parent, fops, data) \
+    ent = proc_create_data(fname, perm, parent, fops, data);
+
+#define PAL_PDE(inode)          PDE((inode))
+#define PAL_PROC_GETDATA(inode) PDE((inode))->data
+
+#endif
+
+
+
 
 #endif