From: Jack Lange Date: Fri, 12 Mar 2010 01:08:49 +0000 (-0600) Subject: symbiotic module updates X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=63fc27a4eedc44a349cf8fde14e4c1b2401b4100 symbiotic module updates --- diff --git a/modules/Kconfig b/modules/Kconfig index d888b18..11cdb34 100644 --- a/modules/Kconfig +++ b/modules/Kconfig @@ -1 +1,2 @@ source "./modules/linux_mods/Kconfig" +source "./modules/v3_mods/Kconfig" \ No newline at end of file diff --git a/modules/Makefile b/modules/Makefile index 303d52a..f5455c5 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -1,2 +1,4 @@ obj-$(CONFIG_LNX_MOD_32BIT) += linux_mods/i386/ #obj-$(CONFIG_LNX_MOD_64BIT) += linux_mods/x86_64/ +obj-$(CONFIG_V3_MOD_32BIT) += v3_mods/i386/ +#obj-$(CONFIG_V3_MOD_64BIT) += v3_mods/x86_64/ diff --git a/modules/linux_mods/i386/headers.c b/modules/linux_mods/i386/headers.c index f7061e0..83b5317 100644 --- a/modules/linux_mods/i386/headers.c +++ b/modules/linux_mods/i386/headers.c @@ -25,5 +25,5 @@ extern uint8_t v3_lnx_mod_32bit_test_start[]; extern uint8_t v3_lnx_mod_32bit_test_stop[]; -register_module("test_32", v3_lnx_mod_32bit_test_start, v3_lnx_mod_32bit_test_stop); +register_module("test_32", v3_lnx_mod_32bit_test_start, v3_lnx_mod_32bit_test_stop, V3_SYMMOD_LNX); #endif diff --git a/modules/v3_mods/Kconfig b/modules/v3_mods/Kconfig new file mode 100644 index 0000000..5003358 --- /dev/null +++ b/modules/v3_mods/Kconfig @@ -0,0 +1,31 @@ + + + +config V3_MODS + bool "V3VEE Symbiotic modules" + select V3_MOD_32BIT + select V3_MOD_64BIT + + + + + +config V3_MOD_32BIT + bool "32 bit modules" + depends on V3_MODS + +config V3_MOD_32BIT_TEST + bool "V3 Sym (i386) test module" + default y if SYMMOD + depends on V3_MOD_32BIT + help + This is a simple 32 bit test Symbiotic Module + + + + +config V3_MOD_64BIT + bool "64 bit modules" + depends on V3_MODS + default y + diff --git a/modules/v3_mods/i386/Kconfig b/modules/v3_mods/i386/Kconfig new file mode 100644 index 0000000..28ed4da --- /dev/null +++ b/modules/v3_mods/i386/Kconfig @@ -0,0 +1,20 @@ + + + +config LINUX_KERN_MODS + bool "Include Linux kernel modules" + depends on SYMMOD + +if LINUX_KERN_MODS + +config LINUX_TEST_MODULE + bool "Linux test module" + default y if SYMMOD + depends on SYMMOD + help + This is a simple test linux kernel module + + + + +endif diff --git a/modules/v3_mods/i386/Makefile b/modules/v3_mods/i386/Makefile new file mode 100644 index 0000000..cdcc933 --- /dev/null +++ b/modules/v3_mods/i386/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_LNX_MOD_32BIT) += binaries.o headers.o \ No newline at end of file diff --git a/modules/v3_mods/i386/binaries.S b/modules/v3_mods/i386/binaries.S new file mode 100644 index 0000000..90c2ea3 --- /dev/null +++ b/modules/v3_mods/i386/binaries.S @@ -0,0 +1,35 @@ +#; -*- fundamental -*- + +/* + * This file is part of the Palacios Virtual Machine Monitor developed + * by the V3VEE Project with funding from the United States National + * Science Foundation and the Department of Energy. + * + * The V3VEE Project is a joint project between Northwestern University + * and the University of New Mexico. You can find out more at + * http://www.v3vee.org + * + * Copyright (c) 2010, Jack Lange + * Copyright (c) 2010, The V3VEE Project + * All rights reserved. + * + * Author: Jack Lange + * + * This is free software. You are permitted to use, + * redistribute, and modify it as specified in the file "V3VEE_LICENSE". + */ + +.data + +#define TOSTR(str) #str +#define MOD_DIR(name) TOSTR(./modules/v3_mods/i386/binaries/name) + + +#ifdef CONFIG_V3_MOD_32BIT_TEST +.globl v3_mod_32bit_test_start +v3_mod_32bit_test_start: +.incbin MOD_DIR(test.vo) +.globl v3_mod_32bit_test_stop +v3_mod_32bit_test_stop: +#endif + diff --git a/modules/v3_mods/i386/headers.c b/modules/v3_mods/i386/headers.c new file mode 100644 index 0000000..e9daaa5 --- /dev/null +++ b/modules/v3_mods/i386/headers.c @@ -0,0 +1,29 @@ +/* + * This file is part of the Palacios Virtual Machine Monitor developed + * by the V3VEE Project with funding from the United States National + * Science Foundation and the Department of Energy. + * + * The V3VEE Project is a joint project between Northwestern University + * and the University of New Mexico. You can find out more at + * http://www.v3vee.org + * + * Copyright (c) 2010, Jack Lange + * Copyright (c) 2010, The V3VEE Project + * All rights reserved. + * + * Author: Jack Lange + * + * This is free software. You are permitted to use, + * redistribute, and modify it as specified in the file "V3VEE_LICENSE". + */ + +#include + + + +#ifdef CONFIG_V3_MOD_32BIT_TEST +extern uint8_t v3_mod_32bit_test_start[]; +extern uint8_t v3_mod_32bit_test_stop[]; + +register_module("v3_test_32", v3_mod_32bit_test_start, v3_mod_32bit_test_stop, V3_SYMMOD_MOD); +#endif diff --git a/palacios/include/palacios/vmm_hypercall.h b/palacios/include/palacios/vmm_hypercall.h index c9646fa..8a7fc5d 100644 --- a/palacios/include/palacios/vmm_hypercall.h +++ b/palacios/include/palacios/vmm_hypercall.h @@ -36,6 +36,15 @@ typedef enum { TEST_HCALL = 0x0001, SYMCALL_RET_HCALL = 0x0535, // args in GPRs SYMCALL_ERR_HCALL = 0x0536, // RBX: error code + + /* -- Symmod symbol table hypercall -- + * RBX: SymTable start + * RCX: SymTable size + * RDX: SymStrs start + * RSI: SymStrs size + */ + SYMMOD_SYMS_HCALL = 0x0600, + MEM_OFFSET_HCALL = 0x1000, // RBX: base addr(out) GUEST_INFO_HCALL = 0x3000, // no args TELEMETRY_HCALL = 0x3001, // no args diff --git a/palacios/include/palacios/vmm_list.h b/palacios/include/palacios/vmm_list.h index f44933a..f1e878f 100644 --- a/palacios/include/palacios/vmm_list.h +++ b/palacios/include/palacios/vmm_list.h @@ -263,6 +263,21 @@ static inline void list_splice_init(struct list_head *list, +/** + * list_next_entry -- get the struct for the next entry in a list + * @ptr: current list entry + * @type: type of the struct this is embedded in + * @member: name of the list struct within the struct + */ +#define list_next_entry(node, type, member) \ + ({ \ + type * next = NULL; \ + if ((node)->next != (node)) { \ + next = list_entry((node)->next, type, member); \ + } \ + next; \ + }) + /** * list_for_each - iterate over a list diff --git a/palacios/include/palacios/vmm_symmod.h b/palacios/include/palacios/vmm_symmod.h index d46ad11..b6d3745 100644 --- a/palacios/include/palacios/vmm_symmod.h +++ b/palacios/include/palacios/vmm_symmod.h @@ -36,38 +36,49 @@ struct v3_symmod_state { struct v3_symmod_loader_ops * loader_ops; void * loader_data; - struct hashtable * module_table; }; +#define V3_SYMMOD_INV (0x00000000) +#define V3_SYMMOD_LNX (0x00000001) +#define V3_SYMMOD_MOD (0x00000002) +#define V3_SYMMOD_SEC (0x00000003) +union v3_symmod_flags { + uint32_t flags; + struct { + uint8_t type; + } __attribute__((packed)); +} __attribute__((packed)); + struct v3_sym_module { char * name; void * start_addr; void * end_addr; + uint32_t flags; // see 'struct v3_symmod_flags' } __attribute__((packed)); + + int v3_set_symmod_loader(struct v3_vm_info * vm, struct v3_symmod_loader_ops * ops, void * priv_data); int v3_load_sym_module(struct v3_vm_info * vm, char * mod_name); - int v3_init_symmod_vm(struct v3_vm_info * vm, v3_cfg_tree_t * cfg); - struct v3_sym_module * v3_get_sym_module(struct v3_vm_info * vm, char * name); -#define register_module(name, start, end) \ +#define register_module(name, start, end, flags) \ static char v3_module_name[] = name; \ static struct v3_sym_module _v3_module \ __attribute__((__used__)) \ __attribute__((unused, __section__ ("_v3_modules"), \ aligned(sizeof(addr_t)))) \ - = {v3_module_name, start, end}; + = {v3_module_name, start, end, flags}; int V3_init_symmod(); diff --git a/palacios/src/devices/lnx_virtio_symmod.c b/palacios/src/devices/lnx_virtio_symmod.c index d3bae18..d6df7a7 100644 --- a/palacios/src/devices/lnx_virtio_symmod.c +++ b/palacios/src/devices/lnx_virtio_symmod.c @@ -406,7 +406,7 @@ static int virtio_load_module(struct v3_vm_info * vm, char * name, int mod_size, } - if (q->cur_avail_idx < q->avail->index) { + if (q->cur_avail_idx != q->avail->index) { uint16_t notifier_idx = q->avail->ring[q->cur_avail_idx % q->queue_size]; struct symmod_hdr * notifier = NULL; struct vring_desc * notifier_desc = NULL; diff --git a/palacios/src/palacios/vmm_symmod.c b/palacios/src/palacios/vmm_symmod.c index a311ae1..193f511 100644 --- a/palacios/src/palacios/vmm_symmod.c +++ b/palacios/src/palacios/vmm_symmod.c @@ -47,13 +47,10 @@ int V3_init_symmod() { master_mod_table = v3_create_htable(0, mod_hash_fn, mod_eq_fn); while (tmp_mod != __stop__v3_modules) { - if (v3_htable_search(master_mod_table, (addr_t)(tmp_mod->name))) { PrintError("Multiple instances of Module (%s)\n", tmp_mod->name); return -1; - } - - + } PrintDebug("Registering Symbiotic Module (%s)\n", tmp_mod->name); if (v3_htable_insert(master_mod_table, @@ -62,12 +59,9 @@ int V3_init_symmod() { PrintError("Could not insert module %s to master list\n", tmp_mod->name); return -1; } - - tmp_mod = &(__start__v3_modules[++i]); } - return 0; } @@ -112,7 +106,6 @@ int v3_load_sym_module(struct v3_vm_info * vm, char * mod_name) { struct v3_sym_module * v3_get_sym_module(struct v3_vm_info * vm, char * name) { struct v3_sym_module * mod = (struct v3_sym_module *)v3_htable_search(master_mod_table, (addr_t)name); - if (!mod) { PrintError("Could not find module %s\n", name); return NULL;