Commit 32997598 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Andrei Vagin

x86/ia32: fix build with DEBUG=1

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: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 0f5e2217
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment