From 09d83bf60b2fcb3c581a387bf773b0ada2c8bd6c Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 9 Feb 2012 11:54:16 +0000 Subject: [PATCH] =?utf8?q?Implement=20the=20getcpu=20vsyscall=20on=20amd64?= =?utf8?q?=20by=20forwarding=20it=20to=20the=20real=20system=20call.=20Pat?= =?utf8?q?ch=20from=20L=C3=A9na=C3=AFc=20Huard=20to=20fix=20BZ#187043.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12372 --- coregrind/m_redir.c | 11 ++++++++--- coregrind/m_trampoline.S | 25 ++++++++++++++++++++++--- coregrind/pub_core_trampoline.h | 1 + 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c index ab3ad296b5..c996afb723 100644 --- a/coregrind/m_redir.c +++ b/coregrind/m_redir.c @@ -731,6 +731,7 @@ static void maybe_add_active ( Active act ) # if defined(VGP_amd64_linux) && act.from_addr != 0xFFFFFFFFFF600000ULL && act.from_addr != 0xFFFFFFFFFF600400ULL + && act.from_addr != 0xFFFFFFFFFF600800ULL # endif ) { what = "redirection from-address is in non-executable area"; @@ -1089,11 +1090,15 @@ void VG_(redir_initialise) ( void ) /* Redirect vsyscalls to local versions */ add_hardwired_active( 0xFFFFFFFFFF600000ULL, - (Addr)&VG_(amd64_linux_REDIR_FOR_vgettimeofday) + (Addr)&VG_(amd64_linux_REDIR_FOR_vgettimeofday) ); - add_hardwired_active( + add_hardwired_active( 0xFFFFFFFFFF600400ULL, - (Addr)&VG_(amd64_linux_REDIR_FOR_vtime) + (Addr)&VG_(amd64_linux_REDIR_FOR_vtime) + ); + add_hardwired_active( + 0xFFFFFFFFFF600800ULL, + (Addr)&VG_(amd64_linux_REDIR_FOR_vgetcpu) ); /* If we're using memcheck, use these intercepts right from diff --git a/coregrind/m_trampoline.S b/coregrind/m_trampoline.S index a9acfa6922..73ef862597 100644 --- a/coregrind/m_trampoline.S +++ b/coregrind/m_trampoline.S @@ -189,6 +189,16 @@ VG_(amd64_linux_REDIR_FOR_vtime): .LfnE3: .size VG_(amd64_linux_REDIR_FOR_vtime), .-.LfnB3 +.global VG_(amd64_linux_REDIR_FOR_vgetcpu) +.type VG_(amd64_linux_REDIR_FOR_vgetcpu), @function +VG_(amd64_linux_REDIR_FOR_vgetcpu): +.LfnB4: + movq $__NR_getcpu, %rax + syscall + ret +.LfnE4: +.size VG_(amd64_linux_REDIR_FOR_vgetcpu), .-.LfnB4 + /* There's no particular reason that this needs to be handwritten assembly, but since that's what this file contains, here's a simple strlen implementation (written in C and compiled by gcc.) @@ -196,7 +206,7 @@ VG_(amd64_linux_REDIR_FOR_vtime): .global VG_(amd64_linux_REDIR_FOR_strlen) .type VG_(amd64_linux_REDIR_FOR_strlen), @function VG_(amd64_linux_REDIR_FOR_strlen): -.LfnB4: +.LfnB5: xorl %eax, %eax cmpb $0, (%rdi) movq %rdi, %rdx @@ -207,11 +217,11 @@ VG_(amd64_linux_REDIR_FOR_strlen): movq %rdx, %rax subq %rdi, %rax .L41: ret -.LfnE4: +.LfnE5: .size VG_(amd64_linux_REDIR_FOR_strlen), .-VG_(amd64_linux_REDIR_FOR_strlen) -/* A CIE for the above three functions, followed by their FDEs */ +/* A CIE for the above four functions, followed by their FDEs */ .section .eh_frame,"a",@progbits .Lframe1: .long .LEcie1-.LScie1 @@ -258,6 +268,15 @@ VG_(amd64_linux_REDIR_FOR_strlen): .uleb128 0x0 .align 8 .LEfde4: +.LSfde5: + .long .LEfde5-.LASfde5 +.LASfde5: + .long .LASfde5-.Lframe1 + .long .LfnB5 + .long .LfnE5-.LfnB5 + .uleb128 0x0 + .align 8 +.LEfde5: .previous .global VG_(trampoline_stuff_end) diff --git a/coregrind/pub_core_trampoline.h b/coregrind/pub_core_trampoline.h index 72b577e976..4e8779226d 100644 --- a/coregrind/pub_core_trampoline.h +++ b/coregrind/pub_core_trampoline.h @@ -67,6 +67,7 @@ extern UInt VG_(x86_linux_REDIR_FOR_strlen)( void* ); extern Addr VG_(amd64_linux_SUBST_FOR_rt_sigreturn); extern Addr VG_(amd64_linux_REDIR_FOR_vgettimeofday); extern Addr VG_(amd64_linux_REDIR_FOR_vtime); +extern Addr VG_(amd64_linux_REDIR_FOR_vgetcpu); extern UInt VG_(amd64_linux_REDIR_FOR_strlen)( void* ); #endif -- 2.47.2