[CRIU] [PATCHv2 09/17] pie/vdso: add i386 trampoline
Dmitry Safonov
dsafonov at virtuozzo.com
Tue Apr 12 09:10:47 PDT 2016
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
criu/arch/x86/vdso-pie.c | 41 ++++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/criu/arch/x86/vdso-pie.c b/criu/arch/x86/vdso-pie.c
index b1e087cd8837..7f13915255a7 100644
--- a/criu/arch/x86/vdso-pie.c
+++ b/criu/arch/x86/vdso-pie.c
@@ -20,16 +20,34 @@ typedef struct {
u16 jmp_rax;
u32 guards;
} __packed jmp_t;
+#define IMMEDIATE(j) (j.imm64)
+
+jmp_t jmp = {
+ .movabs = 0xb848,
+ .jmp_rax = 0xe0ff,
+ .guards = 0xcccccccc,
+};
+
+#else /* CONFIG_X86_64 */
+typedef struct {
+ u8 movl;
+ u32 imm32;
+ u16 jmp_eax;
+ u32 guards;
+} __packed jmp_t;
+#define IMMEDIATE(j) (j.imm32)
+
+jmp_t jmp = {
+ .movl = 0xb8,
+ .jmp_eax = 0xe0ff,
+ .guards = 0xcccccccc,
+};
+#endif /* CONFIG_X86_64 */
int vdso_redirect_calls(unsigned long base_to, unsigned long base_from,
struct vdso_symtable *to,
struct vdso_symtable *from)
{
- jmp_t jmp = {
- .movabs = 0xb848,
- .jmp_rax = 0xe0ff,
- .guards = 0xcccccccc,
- };
unsigned int i;
for (i = 0; i < ARRAY_SIZE(to->symbols); i++) {
@@ -40,20 +58,9 @@ int vdso_redirect_calls(unsigned long base_to, unsigned long base_from,
base_from, from->symbols[i].offset,
base_to, to->symbols[i].offset, i);
- jmp.imm64 = base_to + to->symbols[i].offset;
+ IMMEDIATE(jmp) = base_to + to->symbols[i].offset;
builtin_memcpy((void *)(base_from + from->symbols[i].offset), &jmp, sizeof(jmp));
}
return 0;
}
-
-#else /* CONFIG_X86_64 */
-
-int vdso_redirect_calls(unsigned long base_to, unsigned long base_from,
- struct vdso_symtable *to,
- struct vdso_symtable *from)
-{
- return 0;
-}
-
-#endif /* CONFIG_X86_64 */
--
2.8.0
More information about the CRIU
mailing list