]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix 197259 Unsupported arch_prtctl PR_SET_GS option
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 17 Dec 2014 00:00:11 +0000 (00:00 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 17 Dec 2014 00:00:11 +0000 (00:00 +0000)
(valgrind side).
In summary: we were counting somewhat on the luck for FS,
we now similarly count on luch for GS
See VEX commit log r3043 for more details.

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

NEWS
coregrind/m_gdbserver/valgrind-low-amd64.c
coregrind/m_syswrap/syswrap-amd64-linux.c
coregrind/m_syswrap/syswrap-darwin.c
coregrind/m_translate.c
memcheck/mc_machine.c

diff --git a/NEWS b/NEWS
index 7ac55fca16a97fe9affa0294480c26c2553769c0..3ea2c08e71cf6d5ba17d44147fd4fbc2441ffae6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,7 @@ where XXXXXX is the bug number as listed below.
 
 116002  VG_(printf): Problems with justification of strings and integers
 155125  avoid cutting away file:lineno after long function name
+197259  Unsupported arch_prtctl PR_SET_GS option
 211926  Avoid compilation warnings in valgrind.h with -pedantic
 226609  Crediting upstream authors in man page
 269360  s390x: Fix addressing mode selection for compare-and-swap
index 36f3b5d3b85b6b1f2567cd627ecfbf1a2d592e0f..630a3b03a0cd7ef1642d767ae02ecb35b6cd41de 100644 (file)
@@ -198,7 +198,7 @@ void transfer_register (ThreadId tid, int abs_regno, void * buf,
    case 20: *mod = False; break; //GDBTD VG_(transfer) (&amd64->guest_DS, buf, dir, size, mod);
    case 21: *mod = False; break; //GDBTD VG_(transfer) (&amd64->guest_ES, buf, dir, size, mod);
    case 22: *mod = False; break; //GDBTD VG_(transfer) (&amd64->guest_FS, buf, dir, size, mod);
-   case 23: VG_(transfer) (&amd64->guest_GS_0x60, buf, dir, size, mod); break;
+   case 23: VG_(transfer) (&amd64->guest_GS_CONST, buf, dir, size, mod); break;
    case 24:
    case 25:
    case 26:
@@ -349,7 +349,7 @@ const char* target_xml (Bool shadow_mode)
 static CORE_ADDR** target_get_dtv (ThreadState *tst)
 {
    VexGuestAMD64State* amd64 = (VexGuestAMD64State*)&tst->arch.vex;
-   return (CORE_ADDR**)((CORE_ADDR)amd64->guest_FS_ZERO + 0x8);
+   return (CORE_ADDR**)((CORE_ADDR)amd64->guest_FS_CONST + 0x8);
 }
 
 static struct valgrind_target_ops low_target = {
index 364a8bb9cffda047ebd823b6ef74d50fc8648b36..ae696b1c30b3ae780cc6fb40154c588c9d64e747 100644 (file)
@@ -275,7 +275,7 @@ static SysRes do_clone ( ThreadId ptid,
    if (flags & VKI_CLONE_SETTLS) {
       if (debug)
         VG_(printf)("clone child has SETTLS: tls at %#lx\n", tlsaddr);
-      ctst->arch.vex.guest_FS_ZERO = tlsaddr;
+      ctst->arch.vex.guest_FS_CONST = tlsaddr;
    }
 
    flags &= ~VKI_CLONE_SETTLS;
@@ -506,21 +506,31 @@ PRE(sys_arch_prctl)
    /* "do" the syscall ourselves; the kernel never sees it */
    if (ARG1 == VKI_ARCH_SET_FS) {
       tst = VG_(get_ThreadState)(tid);
-      tst->arch.vex.guest_FS_ZERO = ARG2;
+      tst->arch.vex.guest_FS_CONST = ARG2;
    }
    else if (ARG1 == VKI_ARCH_GET_FS) {
       PRE_MEM_WRITE("arch_prctl(addr)", ARG2, sizeof(unsigned long));
       tst = VG_(get_ThreadState)(tid);
-      *(unsigned long *)ARG2 = tst->arch.vex.guest_FS_ZERO;
+      *(unsigned long *)ARG2 = tst->arch.vex.guest_FS_CONST;
+      POST_MEM_WRITE(ARG2, sizeof(unsigned long));
+   }
+   else if (ARG1 == VKI_ARCH_SET_GS) {
+      tst = VG_(get_ThreadState)(tid);
+      tst->arch.vex.guest_GS_CONST = ARG2;
+   }
+   else if (ARG1 == VKI_ARCH_GET_GS) {
+      PRE_MEM_WRITE("arch_prctl(addr)", ARG2, sizeof(unsigned long));
+      tst = VG_(get_ThreadState)(tid);
+      *(unsigned long *)ARG2 = tst->arch.vex.guest_GS_CONST;
       POST_MEM_WRITE(ARG2, sizeof(unsigned long));
    }
    else {
-      VG_(core_panic)("Unsupported arch_prtctl option");
+      VG_(core_panic)("Unsupported arch_prctl option");
    }
 
    /* Note; the Status writeback to guest state that happens after
-      this wrapper returns does not change guest_FS_ZERO; hence that
-      direct assignment to the guest state is safe here. */
+      this wrapper returns does not change guest_FS_CONST or guest_GS_CONST;
+      hence that direct assignment to the guest state is safe here. */
    SET_STATUS_Success( 0 );
 }
 
index 9249e4f16a9ca2bf52d8939ae9b6ce6164bb4a00..25b5275ed9a9bdbd185de1798f231d38f90d3f47 100644 (file)
@@ -8636,7 +8636,7 @@ PRE(thread_fast_set_cthread_self)
    {
       ThreadState *tst = VG_(get_ThreadState)(tid);
       tst->os_state.pthread = ARG1;
-      tst->arch.vex.guest_GS_0x60 = ARG1;
+      tst->arch.vex.guest_GS_CONST = ARG1;
       // SET_STATUS_Success(0x60);
       // see comments on x86 case just above
       SET_STATUS_from_SysRes(
index 816b5f2652302ac036350e448c792df852e04746..225113859ab6e18db5bdd220ea16d3a81d70ab93 100644 (file)
@@ -1585,10 +1585,11 @@ Bool VG_(translate) ( ThreadId tid,
    vex_abiinfo.guest_stack_redzone_size = VG_STACK_REDZONE_SZB;
 
 #  if defined(VGP_amd64_linux)
-   vex_abiinfo.guest_amd64_assume_fs_is_zero  = True;
+   vex_abiinfo.guest_amd64_assume_fs_is_const = True;
+   vex_abiinfo.guest_amd64_assume_gs_is_const = True;
 #  endif
 #  if defined(VGP_amd64_darwin)
-   vex_abiinfo.guest_amd64_assume_gs_is_0x60  = True;
+   vex_abiinfo.guest_amd64_assume_gs_is_const = True;
 #  endif
 #  if defined(VGP_ppc32_linux)
    vex_abiinfo.guest_ppc_zap_RZ_at_blr        = False;
index 732835734a32ffbffcf7ae661402a133fb5f597e..429ff4fec7005b70b0b2a2c1d6f5b2e7d95443b5 100644 (file)
@@ -564,8 +564,8 @@ static Int get_otrack_shadow_offset_wrk ( Int offset, Int szB )
    if (o == GOF(IP_AT_SYSCALL) && sz == 8) return -1; /* slot unused */
    if (o == GOF(IDFLAG)  && sz == 8) return -1; /* slot used for %DH */
    if (o == GOF(ACFLAG)  && sz == 8) return -1; /* slot unused */
-   if (o == GOF(FS_ZERO) && sz == 8) return -1; /* slot unused */
-   if (o == GOF(GS_0x60) && sz == 8) return -1; /* slot unused */
+   if (o == GOF(FS_CONST) && sz == 8) return -1; /* slot unused */
+   if (o == GOF(GS_CONST) && sz == 8) return -1; /* slot unused */
    if (o == GOF(CMSTART) && sz == 8) return -1; /* slot unused */
    if (o == GOF(CMLEN)   && sz == 8) return -1; /* slot unused */
    if (o == GOF(NRADDR)  && sz == 8) return -1; /* slot unused */