]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Implement the getcpu vsyscall on amd64 by forwarding it to the real
authorTom Hughes <tom@compton.nu>
Thu, 9 Feb 2012 11:54:16 +0000 (11:54 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 9 Feb 2012 11:54:16 +0000 (11:54 +0000)
system call. Patch from Lénaïc Huard to fix BZ#187043.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12372

coregrind/m_redir.c
coregrind/m_trampoline.S
coregrind/pub_core_trampoline.h

index ab3ad296b5a4b6b2416b26808b30e4f81f152290..c996afb7235aaca4703e809e5dee5cfb7ebcce9a 100644 (file)
@@ -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
index a9acfa6922d55d8e035bdd33fd556716ed045f6e..73ef862597bf57be94ad8d706d38b54af66272bc 100644 (file)
@@ -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)
index 72b577e97639944b5a5ca00f1653bb6205ebd62c..4e8779226d5ab50ff62d464a9d34ec4447a5b80e 100644 (file)
@@ -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