From: Peter Dinda Date: Sun, 12 Jul 2015 21:50:03 +0000 (-0500) Subject: Cleanup of linkage issues for non-Linux hosts X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=2cb41f7db5b9f89113432d6b3daff4807ba8e5f2 Cleanup of linkage issues for non-Linux hosts - minor asm fixes to allow -fPIC - elimination of unneeded global - conditional compilation of assorted string functions --- diff --git a/Kconfig.stdlibs b/Kconfig.stdlibs index 2d0dfb2..5c0c053 100644 --- a/Kconfig.stdlibs +++ b/Kconfig.stdlibs @@ -128,6 +128,12 @@ config BUILT_IN_ATOI help This enables Palacios' internal implementation of atoi +config BUILT_IN_ATOX + bool "atox()" + depends on BUILT_IN_STDLIB + help + This enables Palacios' internal implementation of atox + config BUILT_IN_STRCHR bool "strchr()" default n @@ -149,6 +155,34 @@ config BUILT_IN_STRPBRK help This enables Palacios' internal implementation of strpbrk +config BUILT_IN_STR_TOLOWER + bool "str_tolower()" + default n + depends on BUILT_IN_STDLIB + help + This enables Palacios' internal implementation of str_tolower + +config BUILT_IN_STR_TOUPPER + bool "str_toupper()" + default n + depends on BUILT_IN_STDLIB + help + This enables Palacios' internal implementation of str_toupper + +config BUILT_IN_STRTOI + bool "strtoi()" + default n + depends on BUILT_IN_STDLIB + help + This enables Palacios' internal implementation of strtoi + +config BUILT_IN_STRTOX + bool "strtox()" + default n + depends on BUILT_IN_STDLIB + help + This enables Palacios' internal implementation of strtox + config BUILT_IN_STDIO bool "Enable Built in versions of stdio functions" diff --git a/palacios/include/palacios/vmm_lowlevel.h b/palacios/include/palacios/vmm_lowlevel.h index af1f820..eec0d91 100644 --- a/palacios/include/palacios/vmm_lowlevel.h +++ b/palacios/include/palacios/vmm_lowlevel.h @@ -70,9 +70,14 @@ static void __inline__ v3_cpuid(uint32_t target, uint32_t * eax, uint32_t * ebx, uint32_t * ecx, uint32_t * edx) { #ifdef __V3_64BIT__ + // avoid rbx on -FPIC - gcc likes to own rbx even on 64 bit PIC code __asm__ __volatile__ ( + "pushq %%rbx\n\t" + "movq %%rdi, %%rbx\n\t" "cpuid\n\t" - : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) + "movq %%rbx, %%rdi\n\t" + "popq %%rbx\n\t" + : "=a" (*eax), "=D" (*ebx), "=c" (*ecx), "=d" (*edx) : "0" (target), "2" (*ecx) ); #elif __V3_32BIT__ diff --git a/palacios/include/palacios/vmx_lowlevel.h b/palacios/include/palacios/vmx_lowlevel.h index fd63406..713875f 100644 --- a/palacios/include/palacios/vmx_lowlevel.h +++ b/palacios/include/palacios/vmx_lowlevel.h @@ -205,22 +205,22 @@ static inline int vmx_off() { static inline int enable_vmx() { #ifdef __V3_64BIT__ __asm__ __volatile__ ( - "movq %%cr4, %%rbx;" - "orq $0x00002000, %%rbx;" - "movq %%rbx, %%cr4;" + "movq %%cr4, %%rcx;" + "orq $0x00002000, %%rcx;" + "movq %%rcx, %%cr4;" : : - : "%rbx" + : "%rcx" ); __asm__ __volatile__ ( - "movq %%cr0, %%rbx; " - "orq $0x00000020,%%rbx; " - "movq %%rbx, %%cr0;" + "movq %%cr0, %%rcx; " + "orq $0x00000020,%%rcx; " + "movq %%rcx, %%cr0;" : : - : "%rbx" + : "%rcx" ); #elif __V3_32BIT__ __asm__ __volatile__ ( diff --git a/palacios/src/palacios/vmm_hashtable.c b/palacios/src/palacios/vmm_hashtable.c index 8400416..4d05215 100644 --- a/palacios/src/palacios/vmm_hashtable.c +++ b/palacios/src/palacios/vmm_hashtable.c @@ -197,7 +197,7 @@ static const uint_t load_factors[] = { 32715575, 65431158, 130862298, 261724573, 523449198, 1046898282 }; -const uint_t prime_table_length = sizeof(primes) / sizeof(primes[0]); +static const uint_t prime_table_length = sizeof(primes) / sizeof(primes[0]); diff --git a/palacios/src/palacios/vmm_string.c b/palacios/src/palacios/vmm_string.c index 01c408c..7950934 100644 --- a/palacios/src/palacios/vmm_string.c +++ b/palacios/src/palacios/vmm_string.c @@ -320,6 +320,7 @@ int atoi(const char * buf) { #endif +#ifdef V3_CONFIG_BUILT_IN_STRTOI int strtoi(const char * nptr, char ** endptr) { int ret = 0; char * buf = (char *)nptr; @@ -337,7 +338,9 @@ int strtoi(const char * nptr, char ** endptr) { return ret; } +#endif +#ifdef V3_CONFIG_BUILT_IN_ATOX uint64_t atox(const char * buf) { uint64_t ret = 0; @@ -359,7 +362,9 @@ uint64_t atox(const char * buf) { return ret; } +#endif +#ifdef V3_CONFIG_BUILT_IN_STRTOX uint64_t strtox(const char * nptr, char ** endptr) { uint64_t ret = 0; char * buf = (char *)nptr; @@ -387,7 +392,7 @@ uint64_t strtox(const char * nptr, char ** endptr) { return ret; } - +#endif #ifdef V3_CONFIG_BUILT_IN_STRCHR @@ -505,7 +510,7 @@ char *strstr(const char *haystack, const char *needle) } #endif - +#ifdef V3_CONFIG_BUILT_IN_STR_TOLOWER void str_tolower(char * s) { while (isalpha(*s)) { if (!islower(*s)) { @@ -514,8 +519,9 @@ void str_tolower(char * s) { s++; } } +#endif - +#ifdef V3_CONFIG_BUILT_IN_STR_TOUPPER void str_toupper(char * s) { while (isalpha(*s)) { if (!isupper(*s)) { @@ -524,3 +530,4 @@ void str_toupper(char * s) { s++; } } +#endif