]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Convert cpu_regs_{sp,ss}() to being static inlines
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 17 May 2017 16:45:08 +0000 (17:45 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 19 May 2017 18:56:13 +0000 (19:56 +0100)
The 64bit case decomposes to a straight reads.  The 32bit case is likely less
overhead for the caller when inlined, but the compiler can always chose to
out-of-line the functions if it wants.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/include/arch/traps.h
arch/x86/traps.c

index a428630b6faad0819fd89dd233edd4c8e37581c3..4808b082eb3b03069cdce873150b63503c3aa871 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <xtf/compiler.h>
 #include <arch/regs.h>
+#include <arch/lib.h>
 #include <arch/page.h>
 
 /*
@@ -20,8 +21,33 @@ void __noreturn arch_crash_hard(void);
  * Return the correct %ss/%esp from an exception.  In 32bit if no stack switch
  * occurs, an exception frame doesn't contain this information.
  */
-unsigned long cpu_regs_sp(const struct cpu_regs *regs);
-unsigned int  cpu_regs_ss(const struct cpu_regs *regs);
+static inline unsigned long cpu_regs_sp(const struct cpu_regs *regs)
+{
+#ifdef __x86_64__
+    return regs->_sp;
+#else
+    unsigned int cs = read_cs();
+
+    if ( (regs->cs & 3) > (cs & 3) )
+        return regs->_sp;
+
+    return _u(regs) + offsetof(struct cpu_regs, _sp);
+#endif
+}
+
+static inline unsigned int cpu_regs_ss(const struct cpu_regs *regs)
+{
+#ifdef __x86_64__
+    return regs->_ss;
+#else
+    unsigned int cs = read_cs();
+
+    if ( (regs->cs & 3) > (cs & 3) )
+        return regs->_ss;
+
+    return read_ss();
+#endif
+}
 
 extern uint8_t boot_stack[3 * PAGE_SIZE];
 extern uint8_t user_stack[PAGE_SIZE];
index 318b405550802b57615887d01f68f01abaaf7eb4..f755d56230de6a1539c2d7063e4c4b91ca890a66 100644 (file)
@@ -55,34 +55,6 @@ static bool is_trap_or_interrupt(const struct cpu_regs *regs)
     return true;
 }
 
-unsigned long cpu_regs_sp(const struct cpu_regs *regs)
-{
-#ifdef __x86_64__
-    return regs->_sp;
-#else
-    unsigned int cs = read_cs();
-
-    if ( (regs->cs & 3) > (cs & 3) )
-        return regs->_sp;
-
-    return _u(regs) + offsetof(struct cpu_regs, _sp);
-#endif
-}
-
-unsigned int cpu_regs_ss(const struct cpu_regs *regs)
-{
-#ifdef __x86_64__
-    return regs->_ss;
-#else
-    unsigned int cs = read_cs();
-
-    if ( (regs->cs & 3) > (cs & 3) )
-        return regs->_ss;
-
-    return read_ss();
-#endif
-}
-
 /*
  * C entry-point for exceptions, after the per-environment stubs have suitably
  * adjusted the stack.