#include "cell.h"
#include "jailhouse.h"
+#include "main.h"
#include "pci.h"
#include <jailhouse/header.h>
#endif
MODULE_VERSION(JAILHOUSE_VERSION);
+DEFINE_MUTEX(jailhouse_lock);
+bool jailhouse_enabled;
+
static struct device *jailhouse_dev;
-static DEFINE_MUTEX(lock);
-static bool enabled;
static void *hypervisor_mem;
static unsigned long hv_core_and_percpu_size;
static cpumask_t offlined_cpus;
if (max_cpus > UINT_MAX)
return -EINVAL;
- if (mutex_lock_interruptible(&lock) != 0)
+ if (mutex_lock_interruptible(&jailhouse_lock) != 0)
return -EINTR;
err = -EBUSY;
- if (enabled || !try_module_get(THIS_MODULE))
+ if (jailhouse_enabled || !try_module_get(THIS_MODULE))
goto error_unlock;
err = request_firmware(&hypervisor, fw_name, jailhouse_dev);
release_firmware(hypervisor);
- enabled = true;
+ jailhouse_enabled = true;
root_cell->id = 0;
register_cell(root_cell);
- mutex_unlock(&lock);
+ mutex_unlock(&jailhouse_lock);
pr_info("The Jailhouse is opening.\n");
module_put(THIS_MODULE);
error_unlock:
- mutex_unlock(&lock);
+ mutex_unlock(&jailhouse_lock);
return err;
}
unsigned int cpu;
int err;
- if (mutex_lock_interruptible(&lock) != 0)
+ if (mutex_lock_interruptible(&jailhouse_lock) != 0)
return -EINTR;
- if (!enabled) {
+ if (!jailhouse_enabled) {
err = -EINVAL;
goto unlock_out;
}
list_for_each_entry_safe(cell, tmp, &cells, entry)
delete_cell(cell);
- enabled = false;
+ jailhouse_enabled = false;
module_put(THIS_MODULE);
pr_info("The Jailhouse was closed.\n");
unlock_out:
- mutex_unlock(&lock);
+ mutex_unlock(&jailhouse_lock);
return err;
}
}
config->name[JAILHOUSE_CELL_NAME_MAXLEN] = 0;
- if (mutex_lock_interruptible(&lock) != 0) {
+ if (mutex_lock_interruptible(&jailhouse_lock) != 0) {
err = -EINTR;
goto kfree_config_out;
}
- if (!enabled) {
+ if (!jailhouse_enabled) {
err = -EINVAL;
goto unlock_out;
}
pr_info("Created Jailhouse cell \"%s\"\n", config->name);
unlock_out:
- mutex_unlock(&lock);
+ mutex_unlock(&jailhouse_lock);
kfree_config_out:
kfree(config);
{
cell_id->name[JAILHOUSE_CELL_ID_NAMELEN] = 0;
- if (mutex_lock_interruptible(&lock) != 0)
+ if (mutex_lock_interruptible(&jailhouse_lock) != 0)
return -EINTR;
- if (!enabled) {
- mutex_unlock(&lock);
+ if (!jailhouse_enabled) {
+ mutex_unlock(&jailhouse_lock);
return -EINVAL;
}
*cell_ptr = find_cell(cell_id);
if (*cell_ptr == NULL) {
- mutex_unlock(&lock);
+ mutex_unlock(&jailhouse_lock);
return -ENOENT;
}
return 0;
}
unlock_out:
- mutex_unlock(&lock);
+ mutex_unlock(&jailhouse_lock);
return err;
}
err = jailhouse_call_arg1(JAILHOUSE_HC_CELL_START, cell->id);
- mutex_unlock(&lock);
+ mutex_unlock(&jailhouse_lock);
return err;
}
delete_cell(cell);
unlock_out:
- mutex_unlock(&lock);
+ mutex_unlock(&jailhouse_lock);
return err;
}
static ssize_t enabled_show(struct device *dev, struct device_attribute *attr,
char *buffer)
{
- return sprintf(buffer, "%d\n", enabled);
+ return sprintf(buffer, "%d\n", jailhouse_enabled);
}
static ssize_t info_show(struct device *dev, char *buffer, unsigned int type)
ssize_t result;
long val = 0;
- if (mutex_lock_interruptible(&lock) != 0)
+ if (mutex_lock_interruptible(&jailhouse_lock) != 0)
return -EINTR;
- if (enabled)
+ if (jailhouse_enabled)
val = jailhouse_call_arg1(JAILHOUSE_HC_HYPERVISOR_GET_INFO,
type);
if (val >= 0)
else
result = val;
- mutex_unlock(&lock);
+ mutex_unlock(&jailhouse_lock);
return result;
}