Bug 1347993 - HW watchpoints not set correctly on aarch64 #2
Summary: HW watchpoints not set correctly on aarch64 #2
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: gdb
Version: 7.2
Hardware: aarch64
OS: Linux
medium
medium
Target Milestone: rc
: 7.6
Assignee: Jan Kratochvil
QA Contact: Michal Kolar
Vladimír Slávik
URL:
Whiteboard:
Keywords:
Depends On: 1261564 1342821
Blocks: 1498541 1505884 1270165 1579522
TreeView+ depends on / blocked
 
Reported: 2016-06-19 19:17 UTC by Jan Kratochvil
Modified: 2018-10-30 08:10 UTC (History)
13 users (show)

(edit)
GDB registers unaligned watchpoint hits on the 64-bit ARM architecture

Previously, the *GDB* debugger provided only limited support for unaligned hardware watchpoints used by the "watch", "rwatch", and "awatch" *GDB* commands on the 64-bit ARM architecture. As a consequence, *GDB* running on such systems failed to register some watchpoint hits and subsequently did not stop the debugged program.

*GDB* has been extended to handle this situation. As a result, it can correctly handle any hardware watchpoints on the 64-bit ARM architecture, including unaligned ones.
Clone Of: 1261564
: 1579522 (view as bug list)
(edit)
Last Closed: 2018-10-30 08:09:58 UTC


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:3080 None None None 2018-10-30 08:10 UTC
Sourceware 19806 None None None 2019-02-15 09:04 UTC

Description Jan Kratochvil 2016-06-19 19:17:11 UTC
+++ This bug was initially created as a clone of Bug #1261564 +++

Description of problem:
ISTM that sometimes hardware watchpoints are not set correctly on armv8.


#1 - kernel Bug 1342821: aarch64: ptrace: BAS: Support any contiguous range
GDB can return false positive hardware watchpoints (rwatch+awatch)

TCMS 118567: /tools/gdb/Sanity/basic-smoke-test
  https://tcms.engineering.redhat.com/case/118567/

--- Additional comment from Martin Cermak on 2016-05-16 16:56:22 CEST ---

So I've been testing with gdb-7.6.1-91.el7.aarch64.

However, there is yet another QA testcase linked to this bug, which, I believe, originally spotted this bug: http://pkgs.devel.redhat.com/cgit/tests/gdb/tree/Sanity/basic-smoke-test.  This testcase still fails.  The scenario using the aforementioned files is as follows:

=======
gcc -o testcase testcase.c -g
export ARCH=${ARCH:-"`uname -n`"}
./use-case.exp
=======

--- Additional comment from Jan Kratochvil on 2016-05-25 00:11:21 CEST ---

FSF GDB trunk also does FAIL: GNU gdb (GDB) 7.11.50.20160524-git

The testcase
  http://pkgs.devel.redhat.com/cgit/tests/gdb/plain/Sanity/basic-smoke-test/use-case.exp
  http://pkgs.devel.redhat.com/cgit/tests/gdb/plain/Sanity/basic-smoke-test/testcase.c
has never been tested/ported to aarch64.  It needs:
  perl -pi-orig -e 's/&& \$arch!="ppc64le"/$& && \$arch!="aarch64"/' use-case.exp 

Although it correctly found out there is a hardware watchpoint bug on aarch64:
  Aarch64: watchpoints set on non-8-byte-aligned addresses are always missed
  https://sourceware.org/bugzilla/show_bug.cgi?id=19806

Without the 'perl' substitution above:
-=x86_64
+=aarch64

One can see it on:
 Hardware read watchpoint 6: r^M
 ^M
 Value = 8^M
-0x00000000004006bf in main () at testcase.c:60^M
-60       d=r;^M
+main () at testcase.c:59^M
+59       d=p;^M

x86_64 is right, aarch64 is wrong, there is no 'r' variable read to stop at line 59 (on line 58 variable 'r' is written to, not read from).

This can be reproduced in a simplified test reusing 'testcase.c':

cat >cmd2 <<EOH
set verbose
set pagination off
b 56
run
p &p
p &r
watch p
rwatch r
continue
#  delete 2
continue
EOH
gcc -o testcase testcase.c -g -Wall
gdb -x cmd2 ./testcase

$1 = (int *) 0x42002c <p>
$2 = (int *) 0x420028 <r>
Hardware watchpoint 2: p
Hardware read watchpoint 3: r
Hardware watchpoint 2: p
Old value = 1
New value = 2
main () at testcase.c:58
58        r=d;
Hardware read watchpoint 3: r
Value = 8
main () at testcase.c:59
59        d=p;
(gdb)

testcase.c:
      int p,r,d,e,l;
->
      long p,r,d,e,l;

$1 = (long *) 0x420040 <p>
$2 = (long *) 0x420038 <r>
Hardware watchpoint 2: p
Hardware read watchpoint 3: r
Hardware watchpoint 2: p
Old value = 1
New value = 2
main () at testcase.c:58
58        r=d;
Hardware read watchpoint 3: r
Value = 8
0x00000000004007cc in main () at testcase.c:60
60        d=r;
(gdb)

By changing int->long we workaround the GDB bug of a shared 8-byte aligned memory location by two variables 'p' and 'r' and so the false stopping at line 59 no longer occurs.

One can also workaround the bug affecting the 'r' watchpoint by deleting the 'p' watchpoint at that cmd2 line:
  #  delete 2


#2 - Upstream GDB Bug: 

GDB can miss a watchpoint (watch):
https://sourceware.org/ml/gdb-patches/2016-06/msg00315.html


Version-Release number of selected component (if applicable):
gdb-7.6.1-78.el7.aarch64
gdb-7.6.1-91.el7.aarch64
kernel-4.2.0-0.rc6.19.el7.aarch64

How reproducible:
always

Comment 2 Jan Kratochvil 2017-03-27 21:15:21 UTC
Posted upstream but not yet approved there so postponing to: RHEL-7.5

[patch] aarch64: PR 19806: watchpoints: false negatives + PR 20207 contiguous ones
https://sourceware.org/ml/gdb-patches/2017-03/msg00470.html
Message-ID: <20170327210753.GA29656@host1.jankratochvil.net>

Comment 3 Jan Kratochvil 2017-11-11 16:41:44 UTC
The post upstream is still not approved, therefore postponing it to: RHEL-7.6

Comment 10 Jan Kratochvil 2018-05-04 17:14:21 UTC
Approved now upstream:
  Re: [patch] aarch64: PR 19806: watchpoints: false negatives + PR 20207 contiguous ones
  https://sourceware.org/ml/gdb-patches/2018-05/msg00095.html

Comment 13 Fedora Update System 2018-05-05 17:34:28 UTC
gdb-8.1-15.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-2abc0d29f2

Comment 14 Fedora Update System 2018-05-06 10:09:24 UTC
gdb-8.1-15.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-2abc0d29f2

Comment 15 Fedora Update System 2018-05-09 21:25:36 UTC
gdb-8.1-15.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.

Comment 16 Michal Kolar 2018-06-01 09:51:59 UTC
Reproduced against gdb-7.6.1-110.el7 and verified against gdb-7.6.1-113.el7.

Comment 21 errata-xmlrpc 2018-10-30 08:09:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3080


Note You need to log in before you can comment on or make changes to this bug.