Jakub Jelinek 79c245
--- valgrind/VEX/priv/guest_s390_helpers.c
Jakub Jelinek 79c245
+++ valgrind/VEX/priv/guest_s390_helpers.c
Jakub Jelinek 79c245
@@ -146,7 +146,6 @@
Jakub Jelinek 79c245
 Bool
Jakub Jelinek 79c245
 guest_s390x_state_requires_precise_mem_exns(Int minoff, Int maxoff)
Jakub Jelinek 79c245
 {
Jakub Jelinek 79c245
-  /* fixs390: not sure whether all of these are needed */
Jakub Jelinek 79c245
    Int lr_min = offsetof(VexGuestS390XState, guest_LR);
Jakub Jelinek 79c245
    Int lr_max = lr_min + 8 - 1;
Jakub Jelinek 79c245
    Int sp_min = offsetof(VexGuestS390XState, guest_SP);
Jakub Jelinek 79c245
--- valgrind/VEX/priv/guest_s390_toIR.c
Jakub Jelinek 79c245
+++ valgrind/VEX/priv/guest_s390_toIR.c
Jakub Jelinek 79c245
@@ -115,21 +115,6 @@
Jakub Jelinek 79c245
    dres.len        = insn_length;
Jakub Jelinek 79c245
    dres.continueAt = 0;
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
-   /* fixs390: special insn for test purposes only.  */
Jakub Jelinek 79c245
-   /* All other special insns are handled in s390_decode_and_irgen() */
Jakub Jelinek 79c245
-   {
Jakub Jelinek 79c245
-      if (byte == 0x0) {
Jakub Jelinek 79c245
-         /* There is no insn whose first byte is all zero. There never will be.
Jakub Jelinek 79c245
-            So we use that for testing purposes when we hand-feed a basic block
Jakub Jelinek 79c245
-            to VEX. We terminate such a basic block with 0x0000 which will then
Jakub Jelinek 79c245
-            cause the translation to stop. */
Jakub Jelinek 79c245
-         dres.whatNext = Dis_StopHere;
Jakub Jelinek 79c245
-         dres.len      = 2;
Jakub Jelinek 79c245
-         irsb->next    = mkaddr_expr(0x0);
Jakub Jelinek 79c245
-         return dres;
Jakub Jelinek 79c245
-      }
Jakub Jelinek 79c245
-   }
Jakub Jelinek 79c245
-
Jakub Jelinek 79c245
    /* fixs390: we should probably pass the resteer-function and the callback
Jakub Jelinek 79c245
       data. It's not needed for correctness but improves performance. */
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
--- valgrind/coregrind/m_sigframe/sigframe-s390x-linux.c
Jakub Jelinek 79c245
+++ valgrind/coregrind/m_sigframe/sigframe-s390x-linux.c
Jakub Jelinek 79c245
@@ -333,9 +333,10 @@
Jakub Jelinek 79c245
    Addr sp = sp_top_of_frame;
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
    vg_assert((flags & VKI_SA_SIGINFO) == 0);
Jakub Jelinek 79c245
+   vg_assert((sizeof(*frame) & 7) == 0);
Jakub Jelinek 79c245
+   vg_assert((sp & 7) == 0);
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
    sp -= sizeof(*frame);
Jakub Jelinek 79c245
-   sp = VG_ROUNDDN(sp, 16);
Jakub Jelinek 79c245
    frame = (struct sigframe *)sp;
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
    if (!extend(tst, sp, sizeof(*frame)))
Jakub Jelinek 79c245
@@ -392,8 +393,10 @@
Jakub Jelinek 79c245
    Int	sigNo = siginfo->si_signo;
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
    vg_assert((flags & VKI_SA_SIGINFO) != 0);
Jakub Jelinek 79c245
+   vg_assert((sizeof(*frame) & 7) == 0);
Jakub Jelinek 79c245
+   vg_assert((sp & 7) == 0);
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
    sp -= sizeof(*frame);
Jakub Jelinek 79c245
-   sp = VG_ROUNDDN(sp, 16);
Jakub Jelinek 79c245
    frame = (struct rt_sigframe *)sp;
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
    if (!extend(tst, sp, sizeof(*frame)))
Jakub Jelinek 79c245
@@ -545,6 +548,8 @@
Jakub Jelinek 79c245
    else
Jakub Jelinek 79c245
       size = restore_rt_sigframe(tst, (struct rt_sigframe *)sp, &sigNo);
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
+   /* same as for creation: we must announce the full memory (including
Jakub Jelinek 79c245
+      alignment), otherwise massif might fail on longjmp */
Jakub Jelinek 79c245
    VG_TRACK( die_mem_stack_signal, sp - VG_STACK_REDZONE_SZB,
Jakub Jelinek 79c245
              size + VG_STACK_REDZONE_SZB );
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
--- valgrind/memcheck/tests/partiallydefinedeq.stderr.exp3
Jakub Jelinek 79c245
+++ valgrind/memcheck/tests/partiallydefinedeq.stderr.exp3
Jakub Jelinek 79c245
@@ -0,0 +1,20 @@
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+On s390 we might see 2 or 3 errors.
Jakub Jelinek 79c245
+Conditional jump or move depends on uninitialised value(s)
Jakub Jelinek 79c245
+   at 0x........: foo (partiallydefinedeq.c:15)
Jakub Jelinek 79c245
+   by 0x........: main (partiallydefinedeq.c:37)
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+Conditional jump or move depends on uninitialised value(s)
Jakub Jelinek 79c245
+   at 0x........: foo (partiallydefinedeq.c:15)
Jakub Jelinek 79c245
+   by 0x........: main (partiallydefinedeq.c:52)
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+HEAP SUMMARY:
Jakub Jelinek 79c245
+    in use at exit: ... bytes in ... blocks
Jakub Jelinek 79c245
+  total heap usage: ... allocs, ... frees, ... bytes allocated
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+For a detailed leak analysis, rerun with: --leak-check=full
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+For counts of detected and suppressed errors, rerun with: -v
Jakub Jelinek 79c245
+Use --track-origins=yes to see where uninitialised values come from
Jakub Jelinek 79c245
+ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Jakub Jelinek 79c245
--- valgrind/memcheck/tests/partiallydefinedeq.stderr.exp4
Jakub Jelinek 79c245
+++ valgrind/memcheck/tests/partiallydefinedeq.stderr.exp4
Jakub Jelinek 79c245
@@ -0,0 +1,24 @@
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+On s390 we might see 2 or 3 errors.
Jakub Jelinek 79c245
+Conditional jump or move depends on uninitialised value(s)
Jakub Jelinek 79c245
+   at 0x........: foo (partiallydefinedeq.c:15)
Jakub Jelinek 79c245
+   by 0x........: main (partiallydefinedeq.c:37)
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+Conditional jump or move depends on uninitialised value(s)
Jakub Jelinek 79c245
+   at 0x........: foo (partiallydefinedeq.c:15)
Jakub Jelinek 79c245
+   by 0x........: main (partiallydefinedeq.c:45)
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+Conditional jump or move depends on uninitialised value(s)
Jakub Jelinek 79c245
+   at 0x........: foo (partiallydefinedeq.c:15)
Jakub Jelinek 79c245
+   by 0x........: main (partiallydefinedeq.c:52)
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+HEAP SUMMARY:
Jakub Jelinek 79c245
+    in use at exit: ... bytes in ... blocks
Jakub Jelinek 79c245
+  total heap usage: ... allocs, ... frees, ... bytes allocated
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+For a detailed leak analysis, rerun with: --leak-check=full
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
+For counts of detected and suppressed errors, rerun with: -v
Jakub Jelinek 79c245
+Use --track-origins=yes to see where uninitialised values come from
Jakub Jelinek 79c245
+ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
Jakub Jelinek 79c245
--- valgrind/VEX/auxprogs/genoffsets.c
Jakub Jelinek 79c245
+++ valgrind/VEX/auxprogs/genoffsets.c
Jakub Jelinek 79c245
@@ -157,28 +157,18 @@
Jakub Jelinek 79c245
    GENOFFSET(ARM,arm,R14);
Jakub Jelinek 79c245
    GENOFFSET(ARM,arm,R15T);
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
-   // fixs390 later: strip down to what is actually needed
Jakub Jelinek 79c245
-   GENOFFSET(S390X,s390x,r0);
Jakub Jelinek 79c245
-   GENOFFSET(S390X,s390x,r1);
Jakub Jelinek 79c245
+   // s390x
Jakub Jelinek 79c245
    GENOFFSET(S390X,s390x,r2);
Jakub Jelinek 79c245
    GENOFFSET(S390X,s390x,r3);
Jakub Jelinek 79c245
    GENOFFSET(S390X,s390x,r4);
Jakub Jelinek 79c245
    GENOFFSET(S390X,s390x,r5);
Jakub Jelinek 79c245
    GENOFFSET(S390X,s390x,r6);
Jakub Jelinek 79c245
    GENOFFSET(S390X,s390x,r7);
Jakub Jelinek 79c245
-   GENOFFSET(S390X,s390x,r8);
Jakub Jelinek 79c245
-   GENOFFSET(S390X,s390x,r9);
Jakub Jelinek 79c245
-   GENOFFSET(S390X,s390x,r10);
Jakub Jelinek 79c245
-   GENOFFSET(S390X,s390x,r11);
Jakub Jelinek 79c245
-   GENOFFSET(S390X,s390x,r12);
Jakub Jelinek 79c245
-   GENOFFSET(S390X,s390x,r13);
Jakub Jelinek 79c245
-   GENOFFSET(S390X,s390x,r14);
Jakub Jelinek 79c245
    GENOFFSET(S390X,s390x,r15);
Jakub Jelinek 79c245
    GENOFFSET(S390X,s390x,IA);
Jakub Jelinek 79c245
    GENOFFSET(S390X,s390x,SYSNO);
Jakub Jelinek 79c245
    GENOFFSET(S390X,s390x,IP_AT_SYSCALL);
Jakub Jelinek 79c245
    GENOFFSET(S390X,s390x,fpc);
Jakub Jelinek 79c245
-   GENOFFSET(S390X,s390x,counter);
Jakub Jelinek 79c245
 }
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
 /*--------------------------------------------------------------------*/
Jakub Jelinek 79c245
--- valgrind/coregrind/m_coredump/coredump-elf.c
Jakub Jelinek 79c245
+++ valgrind/coregrind/m_coredump/coredump-elf.c
Jakub Jelinek 79c245
@@ -237,7 +237,8 @@
Jakub Jelinek 79c245
    /* prs->pr_reg has struct type. Need to take address. */
Jakub Jelinek 79c245
    regs = (struct vki_user_regs_struct *)&(prs->pr_reg);
Jakub Jelinek 79c245
 #else
Jakub Jelinek 79c245
-   regs = (struct vki_user_regs_struct *)(prs->pr_reg);
Jakub Jelinek 79c245
+   regs = (struct vki_user_regs_struct *)prs->pr_reg;
Jakub Jelinek 79c245
+
Jakub Jelinek 79c245
    vg_assert(sizeof(*regs) == sizeof(prs->pr_reg));
Jakub Jelinek 79c245
 #endif
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
--- valgrind/coregrind/m_debuginfo/debuginfo.c
Jakub Jelinek 79c245
+++ valgrind/coregrind/m_debuginfo/debuginfo.c
Jakub Jelinek 79c245
@@ -1988,6 +1988,7 @@
Jakub Jelinek 79c245
             case Creg_IA_IP: return eec->uregs->ia;
Jakub Jelinek 79c245
             case Creg_IA_SP: return eec->uregs->sp;
Jakub Jelinek 79c245
             case Creg_IA_BP: return eec->uregs->fp;
Jakub Jelinek 79c245
+            case Creg_S390_R14: return eec->uregs->lr;
Jakub Jelinek 79c245
 #           elif defined(VGA_ppc32) || defined(VGA_ppc64)
Jakub Jelinek 79c245
 #           else
Jakub Jelinek 79c245
 #             error "Unsupported arch"
Jakub Jelinek 79c245
@@ -2384,14 +2385,9 @@
Jakub Jelinek 79c245
    COMPUTE(uregsPrev.r11, uregsHere->r11, cfsi->r11_how, cfsi->r11_off);
Jakub Jelinek 79c245
    COMPUTE(uregsPrev.r7,  uregsHere->r7,  cfsi->r7_how,  cfsi->r7_off);
Jakub Jelinek 79c245
 #  elif defined(VGA_s390x)
Jakub Jelinek 79c245
-   /* sepcial case for the first frame */
Jakub Jelinek 79c245
-   if (cfsi->ra_how == CFIR_UNKNOWN)
Jakub Jelinek 79c245
-      uregsPrev.ia = uregsHere->lr;
Jakub Jelinek 79c245
-   else
Jakub Jelinek 79c245
-      COMPUTE(uregsPrev.ia, uregsHere->ia, cfsi->ra_how, cfsi->ra_off);
Jakub Jelinek 79c245
+   COMPUTE(uregsPrev.ia, uregsHere->ia, cfsi->ra_how, cfsi->ra_off);
Jakub Jelinek 79c245
    COMPUTE(uregsPrev.sp, uregsHere->sp, cfsi->sp_how, cfsi->sp_off);
Jakub Jelinek 79c245
    COMPUTE(uregsPrev.fp, uregsHere->fp, cfsi->fp_how, cfsi->fp_off);
Jakub Jelinek 79c245
-   /* we only need R14 for the first time, no need to calculate further*/
Jakub Jelinek 79c245
 #  elif defined(VGA_ppc32) || defined(VGA_ppc64)
Jakub Jelinek 79c245
 #  else
Jakub Jelinek 79c245
 #    error "Unknown arch"
Jakub Jelinek 79c245
--- valgrind/coregrind/m_debuginfo/priv_storage.h
Jakub Jelinek 79c245
+++ valgrind/coregrind/m_debuginfo/priv_storage.h
Jakub Jelinek 79c245
@@ -245,7 +245,8 @@
Jakub Jelinek 79c245
       Creg_ARM_R13,
Jakub Jelinek 79c245
       Creg_ARM_R12,
Jakub Jelinek 79c245
       Creg_ARM_R15,
Jakub Jelinek 79c245
-      Creg_ARM_R14
Jakub Jelinek 79c245
+      Creg_ARM_R14,
Jakub Jelinek 79c245
+      Creg_S390_R14
Jakub Jelinek 79c245
    }
Jakub Jelinek 79c245
    CfiReg;
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
--- valgrind/coregrind/m_debuginfo/readdwarf.c
Jakub Jelinek 79c245
+++ valgrind/coregrind/m_debuginfo/readdwarf.c
Jakub Jelinek 79c245
@@ -2327,6 +2327,16 @@
Jakub Jelinek 79c245
       si->cfa_how = CFIC_IA_SPREL;
Jakub Jelinek 79c245
       si->cfa_off = 160;
Jakub Jelinek 79c245
    }
Jakub Jelinek 79c245
+   if (si->ra_how == CFIR_UNKNOWN) {
Jakub Jelinek 79c245
+      if (!debuginfo->cfsi_exprs)
Jakub Jelinek 79c245
+         debuginfo->cfsi_exprs = VG_(newXA)( ML_(dinfo_zalloc),
Jakub Jelinek 79c245
+                                             "di.ccCt.2a",
Jakub Jelinek 79c245
+                                             ML_(dinfo_free),
Jakub Jelinek 79c245
+                                             sizeof(CfiExpr) );
Jakub Jelinek 79c245
+      si->ra_how = CFIR_EXPR;
Jakub Jelinek 79c245
+      si->ra_off = ML_(CfiExpr_CfiReg)( debuginfo->cfsi_exprs,
Jakub Jelinek 79c245
+                                        Creg_S390_R14);
Jakub Jelinek 79c245
+   }
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
    /* knock out some obviously stupid cases */
Jakub Jelinek 79c245
    if (si->ra_how == CFIR_SAME)
Jakub Jelinek 79c245
--- valgrind/coregrind/m_machine.c
Jakub Jelinek 79c245
+++ valgrind/coregrind/m_machine.c
Jakub Jelinek 79c245
@@ -268,7 +268,6 @@
Jakub Jelinek 79c245
    (*f)(vex->guest_R13);
Jakub Jelinek 79c245
    (*f)(vex->guest_R14);
Jakub Jelinek 79c245
 #elif defined(VGA_s390x)
Jakub Jelinek 79c245
-/* fixs390: revisit once guest state is finalized */
Jakub Jelinek 79c245
    (*f)(vex->guest_r0);
Jakub Jelinek 79c245
    (*f)(vex->guest_r1);
Jakub Jelinek 79c245
    (*f)(vex->guest_r2);
Jakub Jelinek 79c245
--- valgrind/coregrind/m_redir.c
Jakub Jelinek 79c245
+++ valgrind/coregrind/m_redir.c
Jakub Jelinek 79c245
@@ -1066,7 +1066,7 @@
Jakub Jelinek 79c245
    }
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
 #  elif defined(VGP_s390x_linux)
Jakub Jelinek 79c245
-   /* fixs390 */
Jakub Jelinek 79c245
+   /* nothing so far */
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
 #  else
Jakub Jelinek 79c245
 #    error Unknown platform
Jakub Jelinek 79c245
--- valgrind/coregrind/m_syswrap/syswrap-main.c
Jakub Jelinek 79c245
+++ valgrind/coregrind/m_syswrap/syswrap-main.c
Jakub Jelinek 79c245
@@ -160,7 +160,8 @@
Jakub Jelinek 79c245
      x86:    Success(N) ==>  edx:eax = N, cc = 0
Jakub Jelinek 79c245
              Fail(N)    ==>  edx:eax = N, cc = 1
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
-     s390x:  fixs390 later: document it here
Jakub Jelinek 79c245
+     s390x:  Success(N) ==>  r2 = N
Jakub Jelinek 79c245
+             Fail(N)    ==>  r2 = -N
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
    * The post wrapper is called if:
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
--- valgrind/memcheck/tests/partiallydefinedeq.c
Jakub Jelinek 79c245
+++ valgrind/memcheck/tests/partiallydefinedeq.c
Jakub Jelinek 79c245
@@ -66,7 +66,14 @@
Jakub Jelinek 79c245
 // Hence also on ARM we get 3 errors, not 2.
Jakub Jelinek 79c245
+//
Jakub Jelinek 79c245
+// s390x is even more complicated: Depending on the architecture
Jakub Jelinek 79c245
+// level we have the 0x80808080 either in the literal pool (3 errors)
Jakub Jelinek 79c245
+// or with the extended immediate facility in an instruction (2 errors).
Jakub Jelinek 79c245
 static __attribute__((noinline)) void bar ( void )
Jakub Jelinek 79c245
 {
Jakub Jelinek 79c245
-#if defined(__powerpc__) || defined(__powerpc64__) || defined(__arm__) || defined(__s390x__)
Jakub Jelinek 79c245
-  fprintf(stderr, "Currently running on ppc32/64/arm/s390x: this test should give 3 errors, not 2.\n");
Jakub Jelinek 79c245
+#if defined(__powerpc__) || defined(__powerpc64__) || defined(__arm__)
Jakub Jelinek 79c245
+  fprintf(stderr, "Currently running on ppc32/64/arm: this test should give 3 errors, not 2.\n");
Jakub Jelinek 79c245
 #endif
Jakub Jelinek 79c245
+#if defined(__s390__)
Jakub Jelinek 79c245
+  fprintf(stderr, "On s390 we might see 2 or 3 errors.\n");
Jakub Jelinek 79c245
+#endif 
Jakub Jelinek 79c245
 }
Jakub Jelinek 79c245
--- valgrind/memcheck/tests/partiallydefinedeq.stderr.exp2
Jakub Jelinek 79c245
+++ valgrind/memcheck/tests/partiallydefinedeq.stderr.exp2
Jakub Jelinek 79c245
@@ -1,5 +1,5 @@
Jakub Jelinek 79c245
 
Jakub Jelinek 79c245
-Currently running on ppc32/64/arm/s390x: this test should give 3 errors, not 2.
Jakub Jelinek 79c245
+Currently running on ppc32/64/arm: this test should give 3 errors, not 2.
Jakub Jelinek 79c245
 Conditional jump or move depends on uninitialised value(s)
Jakub Jelinek 79c245
    at 0x........: foo (partiallydefinedeq.c:15)
Jakub Jelinek 79c245
    by 0x........: main (partiallydefinedeq.c:37)
Jakub Jelinek 79c245
--- valgrind/lackey/lk_main.c
Jakub Jelinek 79c245
+++ valgrind/lackey/lk_main.c
Jakub Jelinek 79c245
@@ -314,7 +314,8 @@ static Int type2index ( IRType ty )
Jakub Jelinek 79c245
       case Ity_I128:    return 5;
Jakub Jelinek 79c245
       case Ity_F32:     return 6;
Jakub Jelinek 79c245
       case Ity_F64:     return 7;
Jakub Jelinek 79c245
-      case Ity_V128:    return 8;
Jakub Jelinek 79c245
+      case Ity_F128:    return 8;
Jakub Jelinek 79c245
+      case Ity_V128:    return 9;
Jakub Jelinek 79c245
       default: tl_assert(0);
Jakub Jelinek 79c245
    }
Jakub Jelinek 79c245
 }
Jakub Jelinek 79c245
@@ -330,7 +331,8 @@ static HChar* nameOfTypeIndex ( Int i )
Jakub Jelinek 79c245
       case 5: return "I128"; break;
Jakub Jelinek 79c245
       case 6: return "F32";  break;
Jakub Jelinek 79c245
       case 7: return "F64";  break;
Jakub Jelinek 79c245
-      case 8: return "V128"; break;
Jakub Jelinek 79c245
+      case 8: return "F128";  break;
Jakub Jelinek 79c245
+      case 9: return "V128"; break;
Jakub Jelinek 79c245
       default: tl_assert(0);
Jakub Jelinek 79c245
    }
Jakub Jelinek 79c245
 }