#include "palacios.h"
#include "mm.h"
#include "vm.h"
+#include "allow_devmem.h"
+#include "memcheck.h"
+#include "lockcheck.h"
#include "linux-exts.h"
-
MODULE_LICENSE("GPL");
// Module parameter
module_param_array(cpu_list, int, &cpu_list_len, 0644);
MODULE_PARM_DESC(cpu_list, "Comma-delimited list of CPUs that Palacios will run on");
+static int allow_devmem = 0;
+module_param(allow_devmem, int, 0);
+MODULE_PARM_DESC(allow_devmem, "Allow general user-space /dev/mem access even if kernel is strict");
+
+// Palacios options parameter
+static char *options;
+module_param(options, charp, 0);
+MODULE_PARM_DESC(options, "Generic options to internal Palacios modules");
+
+
int mod_allocs = 0;
int mod_frees = 0;
-
static int v3_major_num = 0;
static struct v3_guest * guest_map[MAX_VMS] = {[0 ... MAX_VMS - 1] = 0};
-static struct proc_dir_entry *dir = 0;
+struct proc_dir_entry * palacios_proc_dir = NULL;
struct class * v3_class = NULL;
static struct cdev ctrl_dev;
guest->img_size = user_image.size;
DEBUG("Palacios: Allocating kernel memory for guest image (%llu bytes)\n", user_image.size);
- guest->img = vmalloc(guest->img_size);
+ guest->img = palacios_valloc(guest->img_size);
if (IS_ERR(guest->img)) {
ERROR("Palacios Error: Could not allocate space for guest image\n");
out_err2:
- vfree(guest->img);
+ palacios_vfree(guest->img);
out_err1:
guest_map[vm_minor] = NULL;
out_err:
struct proc_dir_entry *palacios_get_procdir(void)
{
- return dir;
+ return palacios_proc_dir;
}
return len;
}
-static int show_mem(char * buf, char ** start, off_t off, int count,
- int * eof, void * data)
-{
- int len = 0;
-
- len = snprintf(buf,count, "%p\n", (void *)get_palacios_base_addr());
- len += snprintf(buf+len,count-len, "%lld\n", get_palacios_num_pages());
-
- return len;
-}
+
+
static int __init v3_init(void) {
+
dev_t dev = MKDEV(0, 0); // We dynamicallly assign the major number
int ret = 0;
+ LOCKCHECK_INIT();
+ MEMCHECK_INIT();
palacios_init_mm();
+ if (allow_devmem) {
+ palacios_allow_devmem();
+ }
+
// Initialize Palacios
- palacios_vmm_init();
+ palacios_vmm_init(options);
// initialize extensions
goto failure1;
}
- dir = proc_mkdir("v3vee", NULL);
- if(dir) {
+ palacios_proc_dir = proc_mkdir("v3vee", NULL);
+ if (palacios_proc_dir) {
struct proc_dir_entry *entry;
- entry = create_proc_read_entry("v3-guests", 0444, dir,
+ entry = create_proc_read_entry("v3-guests", 0444, palacios_proc_dir,
read_guests, NULL);
if (entry) {
INFO("/proc/v3vee/v3-guests successfully created\n");
goto failure1;
}
- entry = create_proc_read_entry("v3-mem", 0444, dir,
- show_mem, NULL);
- if (entry) {
- INFO("/proc/v3vee/v3-mem successfully added\n");
- } else {
- ERROR("Could not create proc entry\n");
- goto failure1;
- }
} else {
ERROR("Could not create proc entry\n");
goto failure1;
extern u32 pg_frees;
extern u32 mallocs;
extern u32 frees;
+ extern u32 vmallocs;
+ extern u32 vfrees;
int i = 0;
struct v3_guest * guest;
dev_t dev;
palacios_vmm_exit();
DEBUG("Palacios Mallocs = %d, Frees = %d\n", mallocs, frees);
+ DEBUG("Palacios Vmallocs = %d, Vfrees = %d\n", vmallocs, vfrees);
DEBUG("Palacios Page Allocs = %d, Page Frees = %d\n", pg_allocs, pg_frees);
unregister_chrdev_region(MKDEV(v3_major_num, 0), MAX_VMS + 1);
deinit_lnx_extensions();
+ if (allow_devmem) {
+ palacios_restore_devmem();
+ }
+
palacios_deinit_mm();
- remove_proc_entry("v3-guests", dir);
- remove_proc_entry("v3-mem", dir);
+ remove_proc_entry("v3-guests", palacios_proc_dir);
remove_proc_entry("v3vee", NULL);
DEBUG("Palacios Module Mallocs = %d, Frees = %d\n", mod_allocs, mod_frees);
+
+ MEMCHECK_DEINIT();
+ LOCKCHECK_DEINIT();
}
void * addr = NULL;
mod_allocs++;
- addr = kmalloc(size, flags);
+ addr = palacios_alloc_extended(size, flags);
return addr;
}
void trace_free(const void * objp) {
mod_frees++;
- kfree(objp);
+ palacios_free((void*)objp);
}