From: Jack Lange Date: Thu, 6 May 2010 21:22:49 +0000 (-0500) Subject: symbiotic module fixes X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=4dbdf474c9eddfc402df451e021e4948a984289b;p=palacios.git symbiotic module fixes --- diff --git a/palacios/include/palacios/vmm_symmod.h b/palacios/include/palacios/vmm_symmod.h index 57ef01c..9433890 100644 --- a/palacios/include/palacios/vmm_symmod.h +++ b/palacios/include/palacios/vmm_symmod.h @@ -83,6 +83,8 @@ struct v3_sym_module * v3_get_sym_module(struct v3_vm_info * vm, char * name); + + #define register_module(name, start, end, flags) \ static char v3_module_name[] = name; \ static struct v3_sym_module _v3_module \ diff --git a/palacios/src/palacios/vmm_symmod.c b/palacios/src/palacios/vmm_symmod.c index e2becb9..20559a9 100644 --- a/palacios/src/palacios/vmm_symmod.c +++ b/palacios/src/palacios/vmm_symmod.c @@ -23,7 +23,12 @@ static struct hashtable * master_mod_table = NULL; - +/* + * This is a place holder to ensure that the _v3_modules section gets created + */ +static struct {} null_mod __attribute__((__used__)) \ + __attribute__((unused, __section__ ("_v3_modules"), \ + aligned(sizeof(addr_t)))); static uint_t mod_hash_fn(addr_t key) { char * name = (char *)key; @@ -45,13 +50,20 @@ int V3_init_symmod() { struct v3_sym_module * tmp_mod = __start__v3_modules; int i = 0; + if (tmp_mod == __stop__v3_modules) { + PrintDebug("No Symbiotic modules found\n"); + return 0; + } + 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, diff --git a/symmods/capsule/Makefile b/symmods/capsule/Makefile index eaae927..1dea03f 100644 --- a/symmods/capsule/Makefile +++ b/symmods/capsule/Makefile @@ -17,10 +17,11 @@ DEFS := -DMOD_NAME=$(MOD_NAME) \ # cpp -undef $(DEFS) binary.S -o $(MOD_DIR)/.tmp.binary.S # cpp $(DEFS) $(MOD_DIR)/.tmp.binary.S +CFLAGS := -fno-stack-protector -Wall -O -Werror -fPIC -mno-red-zone module: FORCE cpp -undef $(DEFS) binary.S -o $(MOD_DIR)/.tmp.binary.S - gcc $(DEFS) -c $(MOD_DIR)/.tmp.binary.S -o $(MOD_DIR)/$(MOD_NAME).vo + gcc $(CFLAGS) $(DEFS) -c $(MOD_DIR)/.tmp.binary.S -o $(MOD_DIR)/$(MOD_NAME).vo rm -f $(MOD_DIR)/.tmp.binary.S FORCE: diff --git a/symmods/capsule/binary.S b/symmods/capsule/binary.S index 4e4fa2f..e37a312 100644 --- a/symmods/capsule/binary.S +++ b/symmods/capsule/binary.S @@ -39,7 +39,7 @@ mod_name: .ascii MOD_NM(MOD_NAME) -.section "_v3_modules" +.section _v3_modules, "a" IDENT(#ifdef __x86_64__) .quad mod_name .quad mod_start diff --git a/symmods/linux/test/Makefile b/symmods/linux/test/Makefile index 757010d..0b4e233 100644 --- a/symmods/linux/test/Makefile +++ b/symmods/linux/test/Makefile @@ -17,9 +17,16 @@ else PALACIOSDIR := $(PWD)/../../capsule V3_MOD_TYPE := V3_LINUX_MOD -default: + +linux: FORCE $(MAKE) -C $(KERNELDIR) M=$(PWD) modules + +capsule: FORCE $(MAKE) -C $(PALACIOSDIR) MOD_NAME=$(V3_MOD_NAME) MOD_DIR=$(PWD) \ MOD_OBJ=$(V3_MOD_OBJ) MOD_TYPE=$(V3_MOD_TYPE) +default: linux capsule + +FORCE: + endif