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));
}
{
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);
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;
}
#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;
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");
#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;
/* 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 {
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, ®ion, gpa)) {
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));
}
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));
}
{
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);
}
#include <linux/list.h>
#include <linux/sched.h>
#include <linux/slab.h>
+#include <linux/version.h>
/* Global Control IOCTLs */
#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