public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] S390: Fix for inadvertently setting 24-bit mode in fill_gregset
@ 2015-05-07 16:15 Andreas Arnez
  2015-05-08  8:58 ` Ulrich Weigand
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Arnez @ 2015-05-07 16:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Ulrich Weigand, Sergio Durigan Junior

On 64-bit S390 platforms, for programs compiled with -m31, it could
happen that GDB inadvertently cleared the inferior's 31-bit addressing
mode bit and left the inferior running in 24-bit addressing mode.  In
particular this occurred with checkpoint.exp, when the "restore"
command needed to create a new regcache copy: At the time when the
PSWM register was copied over, the addressing mode bit was taken from
the PSWA register, which was still zero since it had not been copied
yet.  And when the PSWA register was copied, the addressing mode was
not updated again.

The fix affects fill_gregset, where the bits "belonging" to each of
the PSWA and PSWM registers are now carefully separated.  The
addressing mode bit is no longer touched when writing PSWM, and --
more importantly -- it *is* written when writing PSWA.

gdb/ChangeLog:

  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	* s390-linux-nat.c (fill_gregset): Avoid relying on the PSWA
	register in the regcache when treating the PSWM register, and vice
	versa.
---
 gdb/s390-linux-nat.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index 9298bcc..4cd3192 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -156,19 +156,29 @@ fill_gregset (const struct regcache *regcache, gregset_t *regp, int regno)
 	  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 	  ULONGEST pswa, pswm;
 	  gdb_byte buf[4];
+	  gdb_byte *pswm_p = (gdb_byte *) regp + S390_PSWM_OFFSET;
+	  gdb_byte *pswa_p = (gdb_byte *) regp + S390_PSWA_OFFSET;
 
-	  regcache_raw_collect (regcache, S390_PSWM_REGNUM, buf);
-	  pswm = extract_unsigned_integer (buf, 4, byte_order);
-	  regcache_raw_collect (regcache, S390_PSWA_REGNUM, buf);
-	  pswa = extract_unsigned_integer (buf, 4, byte_order);
+	  pswm = extract_unsigned_integer (pswm_p, 8, byte_order);
 
 	  if (regno == -1 || regno == S390_PSWM_REGNUM)
-	    store_unsigned_integer ((gdb_byte *) regp + S390_PSWM_OFFSET, 8,
-				    byte_order, ((pswm & 0xfff7ffff) << 32) |
-				    (pswa & 0x80000000));
+	    {
+	      pswm &= 0x80000000;
+	      regcache_raw_collect (regcache, S390_PSWM_REGNUM, buf);
+	      pswm |= (extract_unsigned_integer (buf, 4, byte_order)
+		       & 0xfff7ffff) << 32;
+	    }
+
 	  if (regno == -1 || regno == S390_PSWA_REGNUM)
-	    store_unsigned_integer ((gdb_byte *) regp + S390_PSWA_OFFSET, 8,
-				    byte_order, pswa & 0x7fffffff);
+	    {
+	      regcache_raw_collect (regcache, S390_PSWA_REGNUM, buf);
+	      pswa = extract_unsigned_integer (buf, 4, byte_order);
+	      pswm ^= (pswm ^ pswa) & 0x80000000;
+	      pswa &= 0x7fffffff;
+	      store_unsigned_integer (pswa_p, 8, byte_order, pswa);
+	    }
+
+	  store_unsigned_integer (pswm_p, 8, byte_order, pswm);
 	}
       return;
     }
-- 
1.9.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] S390: Fix for inadvertently setting 24-bit mode in fill_gregset
  2015-05-07 16:15 [PATCH] S390: Fix for inadvertently setting 24-bit mode in fill_gregset Andreas Arnez
@ 2015-05-08  8:58 ` Ulrich Weigand
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Weigand @ 2015-05-08  8:58 UTC (permalink / raw)
  To: Andreas Arnez; +Cc: gdb-patches, Sergio Durigan Junior

Andreas Arnez wrote:

>   Andreas Arnez  <arnez@linux.vnet.ibm.com>
> 
> 	* s390-linux-nat.c (fill_gregset): Avoid relying on the PSWA
> 	register in the regcache when treating the PSWM register, and vice
> 	versa.

This is OK.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-08  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-07 16:15 [PATCH] S390: Fix for inadvertently setting 24-bit mode in fill_gregset Andreas Arnez
2015-05-08  8:58 ` Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).