]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Implement exec_user() in C rather than asm
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 3 Mar 2017 16:23:18 +0000 (16:23 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 6 Mar 2017 10:55:40 +0000 (10:55 +0000)
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 <andrew.cooper3@citrix.com>
arch/x86/entry_32.S
arch/x86/entry_64.S
include/xtf/lib.h

index 1329b478b8732b0b8317e4be698802a41c620b63..08609e6a91827b8e048bd67bd631a561dcd2365c 100644 (file)
@@ -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
index 59c1c55d6bc64aecca07383d969d39373c5a37b3..8b70158d3142b37be36242916a7016fc9df390fe 100644 (file)
@@ -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
index 3441254655868c8237b5f5be2268d3d2d2d490a9..9d21a79e40337d6ef107154578c7bbc6a7d3d9d1 100644 (file)
@@ -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.