[CRIU] [PATCH 06/24] x86: parasite -- Add call_daemon_thread and asm_trap helpers
Andrey Vagin
avagin at openvz.org
Wed May 22 16:08:07 EDT 2013
From: Cyrill Gorcunov <gorcunov at openvz.org>
call_daemon_thread will be needed to run thread daemon
with own stack, while asm_trap is just a wrap over trapping
instruction for portability sake.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
arch/x86/include/asm/parasite.h | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/arch/x86/include/asm/parasite.h b/arch/x86/include/asm/parasite.h
index 41f4a97..171e4ee 100644
--- a/arch/x86/include/asm/parasite.h
+++ b/arch/x86/include/asm/parasite.h
@@ -6,4 +6,30 @@ static inline u32 arch_get_tls()
return 0;
}
+/*
+ * Call thread daemon with new stack, the function must
+ * return the original stack pointer passed in argument
+ * argument 3
+ */
+#define CALL_DAEMON_THREAD(new_sp, args, s, func) \
+do { \
+ asm volatile ("movq %0, %%rax \n" \
+ "movq %1, %%rdi \n" \
+ "movq %2, %%rsi \n" \
+ "movq %%rsp, %%rdx \n" \
+ "movq %%rax, %%rsp \n" \
+ "call " #func " \n" \
+ "movq %%rax, %%rsp \n" \
+ : \
+ : "g"(new_sp), "g"(args), "g"(s) \
+ : "rax", "rdi", "rsi", "rdx", \
+ "rsp", "memory"); \
+} while (0)
+
+#define ASM_TRAP() \
+do { \
+ asm volatile("int3" ::); \
+ while (1) ; \
+} while (0)
+
#endif
--
1.8.2
More information about the CRIU
mailing list