[CRIU] [PATCH] x86/ia32: fix build with DEBUG=1
Dmitry Safonov
dsafonov at virtuozzo.com
Mon May 29 05:59:08 PDT 2017
GCC isn't happy if we use %rbp as register for local variable
with -ggdb3 option.
Which resulted in the following build error for `make DEBUG=1`:
> In file included from criu/arch/x86/crtools.c:10:0:
> criu/arch/x86/include/asm/compat.h: In function ‘do_full_int80’:
> criu/arch/x86/include/asm/compat.h:50:1: error: bp cannot be used in asm here
Fix it by saving/restoring %rbp around 32-bit syscall manually.
Just while at it - add a comment about r8-r11 clobbers.
Reported-by: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
criu/arch/x86/include/asm/compat.h | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/criu/arch/x86/include/asm/compat.h b/criu/arch/x86/include/asm/compat.h
index cad5d0ff7059..dce28adf67f9 100644
--- a/criu/arch/x86/include/asm/compat.h
+++ b/criu/arch/x86/include/asm/compat.h
@@ -40,13 +40,24 @@ struct syscall_args32 {
static inline void do_full_int80(struct syscall_args32 *args)
{
- register unsigned long bp asm("bp") = args->arg5;
- asm volatile ("int $0x80"
+ /*
+ * r8-r11 registers are cleared during returning to userspace
+ * from syscall - that's x86_64 ABI to avoid leaking kernel
+ * pointers.
+ *
+ * Other than that - we can't use %rbp in clobbers as GCC's inline
+ * assembly doesn't allow to do so. So, here is explicitly saving
+ * %rbp before syscall and restoring it's value afterward.
+ */
+ asm volatile ("pushq %%rbp\n\t"
+ "mov %6, %%ebp\n\t"
+ "int $0x80\n\t"
+ "mov %%ebp, %6\n\t"
+ "popq %%rbp\n\t"
: "+a" (args->nr),
"+b" (args->arg0), "+c" (args->arg1), "+d" (args->arg2),
- "+S" (args->arg3), "+D" (args->arg4), "+r" (bp)
+ "+S" (args->arg3), "+D" (args->arg4), "+g" (args->arg5)
: : "r8", "r9", "r10", "r11");
- args->arg5 = bp;
}
--
2.12.2
More information about the CRIU
mailing list