From: Andrew Cooper Date: Fri, 3 Mar 2017 16:23:18 +0000 (+0000) Subject: Implement exec_user() in C rather than asm X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=bb42c66c6a99651076778606937931a1294c13a8;p=people%2Fandrewcoop%2Fxen-test-framework.git Implement exec_user() in C rather than asm It is trivial to implement as a static inline wrapper around exec_user_param(), and avoids unnecessary stack manipulation in 32bit builds. Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/entry_32.S b/arch/x86/entry_32.S index 1329b47..08609e6 100644 --- a/arch/x86/entry_32.S +++ b/arch/x86/entry_32.S @@ -139,18 +139,6 @@ ENTRY(exec_user_param) ENDFUNC(exec_user_param) -ENTRY(exec_user) - /* - * 1*4(%esp) ulong (*fn)(ulong) - * 0*4(%esp) return address - */ - push $0xdead0000 /* Poison unused p1. */ - push (1+1)*4(%esp) /* Re-push fn for exec_user_param()'s call frame. */ - call exec_user_param - add $2*4, %esp /* Pop fn/p1. */ - ret -ENDFUNC(exec_user) - /* * Local variables: * tab-width: 8 diff --git a/arch/x86/entry_64.S b/arch/x86/entry_64.S index 59c1c55..8b70158 100644 --- a/arch/x86/entry_64.S +++ b/arch/x86/entry_64.S @@ -134,11 +134,6 @@ ENTRY(exec_user_param) /* ulong (*fn)(ulong), ulong p1 */ ENDFUNC(exec_user_param) -ENTRY(exec_user) /* ulong (*fn)(ulong) */ - mov $0xdead0000, %esi /* Poison unused p1. */ - jmp exec_user_param -ENDFUNC(exec_user) - /* * Local variables: * tab-width: 8 diff --git a/include/xtf/lib.h b/include/xtf/lib.h index 3441254..9d21a79 100644 --- a/include/xtf/lib.h +++ b/include/xtf/lib.h @@ -53,11 +53,20 @@ void heapsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *), void (*swap)(void *, void *)); +/** + * Execute fn(p1) at user privilege, passing its return value back. + */ +unsigned long exec_user_param(unsigned long (*fn)(unsigned long), + unsigned long p1); + /* - * Execute fn() at user privilege on the current stack, passing its return - * value back. + * Wrapper around exec_user_param(), calling a function which takes no + * parameters. p1 is poisioned to catch misuses. */ -unsigned long exec_user(unsigned long (*fn)(void)); +static inline unsigned long exec_user(unsigned long (*fn)(void)) +{ + return exec_user_param((void *)fn, 0xdead0000); +} /* * Wrapper around exec_user() which calls a void function. @@ -67,10 +76,6 @@ static inline void exec_user_void(void (*fn)(void)) exec_user((void *)fn); } -/* Execute fn(p1) at user privilege. */ -unsigned long exec_user_param(unsigned long (*fn)(unsigned long), - unsigned long p1); - /** * Probe for the SYSCTL_INTERFACE_VERSION in use by the hypervisor * @returns version, or -1 on failure.