|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] x86: clone Linux'es ASM_CALL_CONSTRAINT
commit e28e639f5d2a541435b871d4e3af0c09b15a5d00
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri May 17 14:35:52 2019 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri May 17 14:35:52 2019 +0200
x86: clone Linux'es ASM_CALL_CONSTRAINT
While we don't mean to run their objtool over our generated code, it
still seems desirable to avoid calls to further functions before a
function's frame pointer is set up.
Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
xen/arch/x86/efi/stub.c | 8 +++++---
xen/arch/x86/extable.c | 2 +-
xen/arch/x86/x86_emulate/x86_emulate.c | 3 ++-
xen/include/asm-x86/asm_defns.h | 13 +++++++++++++
xen/include/asm-x86/guest/hypercall.h | 6 ++++--
5 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/efi/stub.c b/xen/arch/x86/efi/stub.c
index 0c481e3235..c578bffc71 100644
--- a/xen/arch/x86/efi/stub.c
+++ b/xen/arch/x86/efi/stub.c
@@ -2,8 +2,9 @@
#include <xen/errno.h>
#include <xen/init.h>
#include <xen/lib.h>
-#include <asm/page.h>
+#include <asm/asm_defns.h>
#include <asm/efibind.h>
+#include <asm/page.h>
#include <efi/efidef.h>
#include <efi/eficapsule.h>
#include <efi/eficon.h>
@@ -34,10 +35,11 @@ void __init noreturn efi_multiboot2(EFI_HANDLE ImageHandle,
* not be directly supported by C compiler.
*/
asm volatile(
- " call *%3 \n"
+ " call *%[outstr] \n"
"0: hlt \n"
" jmp 0b \n"
- : "+c" (StdErr), "=d" (StdErr) : "1" (err), "rm" (StdErr->OutputString)
+ : "+c" (StdErr), "=d" (StdErr) ASM_CALL_CONSTRAINT
+ : "1" (err), [outstr] "rm" (StdErr->OutputString)
: "rax", "r8", "r9", "r10", "r11", "memory");
unreachable();
diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index a6430a6d8d..70972f1085 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -168,7 +168,7 @@ static int __init stub_selftest(void)
"jmp .Lret%=\n\t"
".popsection\n\t"
_ASM_EXTABLE(.Lret%=, .Lfix%=)
- : [exn] "+m" (res)
+ : [exn] "+m" (res) ASM_CALL_CONSTRAINT
: [stb] "r" (addr), "a" (tests[i].rax));
if ( res.raw != tests[i].res.raw )
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c
b/xen/arch/x86/x86_emulate/x86_emulate.c
index f5989f3071..75ce0172dc 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1122,7 +1122,8 @@ static inline int mkec(uint8_t e, int32_t ec, ...)
"jmp .Lret%=\n\t" \
".popsection\n\t" \
_ASM_EXTABLE(.Lret%=, .Lfix%=) \
- : [exn] "+g" (stub_exn.info), constraints, \
+ : [exn] "+g" (stub_exn.info) ASM_CALL_CONSTRAINT, \
+ constraints, \
[stub] "r" (stub.func), \
"m" (*(uint8_t(*)[MAX_INST_LEN + 1])stub.ptr) ); \
if ( unlikely(~stub_exn.info.raw) ) \
diff --git a/xen/include/asm-x86/asm_defns.h b/xen/include/asm-x86/asm_defns.h
index e688cf1c16..4fe5556a34 100644
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -25,6 +25,19 @@ asm ( "\t.equ CONFIG_INDIRECT_THUNK, "
#ifndef __ASSEMBLY__
void ret_from_intr(void);
+
+/*
+ * This output constraint should be used for any inline asm which has a "call"
+ * instruction. Otherwise the asm may be inserted before the frame pointer
+ * gets set up by the containing function.
+ */
+#ifdef CONFIG_FRAME_POINTER
+register unsigned long current_stack_pointer asm("rsp");
+# define ASM_CALL_CONSTRAINT , "+r" (current_stack_pointer)
+#else
+# define ASM_CALL_CONSTRAINT
+#endif
+
#endif
#ifndef NDEBUG
diff --git a/xen/include/asm-x86/guest/hypercall.h
b/xen/include/asm-x86/guest/hypercall.h
index e9e626b474..d548816b30 100644
--- a/xen/include/asm-x86/guest/hypercall.h
+++ b/xen/include/asm-x86/guest/hypercall.h
@@ -40,7 +40,7 @@
long res, tmp__; \
asm volatile ( \
"call hypercall_page + %c[offset]" \
- : "=a" (res), "=D" (tmp__) \
+ : "=a" (res), "=D" (tmp__) ASM_CALL_CONSTRAINT \
: [offset] "i" (hcall * 32), \
"1" ((long)(a1)) \
: "memory" ); \
@@ -53,6 +53,7 @@
asm volatile ( \
"call hypercall_page + %c[offset]" \
: "=a" (res), "=D" (tmp__), "=S" (tmp__) \
+ ASM_CALL_CONSTRAINT \
: [offset] "i" (hcall * 32), \
"1" ((long)(a1)), "2" ((long)(a2)) \
: "memory" ); \
@@ -65,6 +66,7 @@
asm volatile ( \
"call hypercall_page + %c[offset]" \
: "=a" (res), "=D" (tmp__), "=S" (tmp__), "=d" (tmp__) \
+ ASM_CALL_CONSTRAINT \
: [offset] "i" (hcall * 32), \
"1" ((long)(a1)), "2" ((long)(a2)), "3" ((long)(a3)) \
: "memory" ); \
@@ -78,7 +80,7 @@
asm volatile ( \
"call hypercall_page + %c[offset]" \
: "=a" (res), "=D" (tmp__), "=S" (tmp__), "=d" (tmp__), \
- "=&r" (tmp__) \
+ "=&r" (tmp__) ASM_CALL_CONSTRAINT \
: [offset] "i" (hcall * 32), \
"1" ((long)(a1)), "2" ((long)(a2)), "3" ((long)(a3)), \
"4" (_a4) \
--
generated by git-patchbot for /home/xen/git/xen.git#staging
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |