Commit 22c4719d authored by Charlie Jacobsen's avatar Charlie Jacobsen Committed by Vikram Narayanan
Browse files

lcd-create-v2: Re-factor klcd create with modules.

Not much changed here.
parent 2410a51f
......@@ -215,6 +215,12 @@ void lcd_destroy_create_ctx(struct lcd_create_ctx *ctx);
*
* Obviously, isolated code cannot create a klcd, so this function
* fails for isolated code.
*
* IMPORTANT: Unlike the isolated LCD version, you must call
* lcd_destroy_module_klcd to kill the kLCD (this tells the kLCD
* thread to stop, waits for it to exit, and then it unloads the
* kernel module). If instead you just do lcd_cap_delete on the klcd
* capability, the module would remain loaded in the host.
*/
int lcd_create_module_klcd(char *mdir, char *mname, cptr_t *klcd);
......
/*
* internal.h
*
* Some kliblcd-internal definitions.
*
*/
#ifndef KLIBLCD_INTERNAL_H
#define KLIBLCD_INTERNAL_H
#include <linux/module.h>
int __kliblcd_module_host_load(char *mdir, char *module_name,
struct module **m_out);
void __kliblcd_module_host_unload(char *module_name);
#endif /* KLIBLCD_INTERNAL_H */
/*
* module_create_klcd.c
*
* Load a kernel module and run it using
* a dedicated thread. The dedicated thread
* will run in "LCD mode".
*/
#include <lcd-domains/liblcd.h>
#include "internal.h"
int lcd_create_module_klcd(char *mdir, char *mname, cptr_t *klcd_out)
{
cptr_t klcd;
int ret;
struct module *m;
/*
* Load kernel module in host
*/
ret = __kliblcd_module_host_load(mdir, mname, &m);
if (ret) {
LIBLCD_ERR("module load failed");
goto fail1;
}
/*
* Create "empty" kLCD
*/
ret = lcd_create_klcd(&klcd);
if (ret) {
LIBLCD_ERR("klcd create failed");
goto fail2;
}
/*
* Configure kLCD thread to run the module's init
*
* We pass null values for most arguments, as these aren't
* used for kLCDs.
*/
ret = lcd_config(klcd,
__gva(hva_val(va2hva(m->init))),
__gva(0),
__gpa(0),
__gpa(0));
if (ret) {
LCD_ERR("failed to config klcd");
goto fail3;
}
*klcd_out = klcd;
return 0;
fail3:
lcd_cap_delete(klcd);
fail2:
__kliblcd_module_host_unload(mname);
fail1:
return ret;
}
void lcd_destroy_module_klcd(cptr_t klcd, char *mname)
{
/*
* We *must* delete the klcd first before unloading the module.
* Otherwise, if the klcd is still running, it will use the freed
* module pages.
*/
lcd_cap_delete(klcd);
__kliblcd_module_host_unload(mname);
}
/* EXPORTS -------------------------------------------------- */
EXPORT_SYMBOL(lcd_create_module_klcd);
EXPORT_SYMBOL(lcd_destroy_module_klcd);
......@@ -76,7 +76,7 @@ int __kliblcd_module_host_load(char *mdir, char *module_name,
kfree(mpath);
return ret;
return 0;
fail3:
ret = do_sys_delete_module(module_name, 0, 1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment