Bug 252860 - arm64 PT_GETDBREGS does not expose watchpoint registers
Summary: arm64 PT_GETDBREGS does not expose watchpoint registers
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: arm64 Any
: --- Affects Only Me
Assignee: Mitchell Horne
URL: https://reviews.freebsd.org/D28415
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-20 12:46 UTC by Michał Górny
Modified: 2021-02-25 21:33 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny 2021-01-20 12:46:39 UTC
We're working on improving arm64/FreeBSD support in LLDB, and we've noticed that -- unless we're mistaken -- the kernel code responsible for PT_GETDBREGS and PT_SETDBREGS handles breakpoint registers only.

I'm specifically referring to the fill_dbregs() function at:

https://cgit.freebsd.org/src/tree/sys/arm64/arm64/machdep.c?id=5f66d5a313bf2b2254de92b2915e48e5cf528893#n320

It needs to be extended to include watchpoint registers if we're going to use hardware watchpoints on FreeBSD.  However, I'm not really sure how to do that without breaking the ABI -- though I'm not sure if anything is actually using it at this point.
Comment 1 commit-hook freebsd_committer 2021-02-17 16:09:55 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f2583be110ca3a5b32f0993f1464a5c69151c62f

commit f2583be110ca3a5b32f0993f1464a5c69151c62f
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2021-01-28 17:49:47 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2021-02-17 16:05:00 +0000

    arm64: extend struct db_reg to include watchpoint registers

    The motivation is to provide access to these registers from userspace
    via ptrace(2) requests PT_GETDBREGS and PT_SETDBREGS.

    This change breaks the ABI of these particular requests, but is
    justified by the fact that the intended consumers (debuggers) have not
    been taught to use them yet. Making this change now enables active
    upstream work on lldb to begin using this interface, and take advantage
    of the hardware debugging registers available on the platform.

    PR:             252860
    Reported by:    MichaŠGórny (mgorny@gentoo.org)
    Reviewed by:    andrew, markj (earlier version)
    Tested by:      MichaŠGórny (mgorny@gentoo.org)
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D28415

 sys/arm64/arm64/identcpu.c |  2 +-
 sys/arm64/arm64/machdep.c  | 71 ++++++++++++++++++++++++++++++++++++++--------
 sys/arm64/include/armreg.h | 22 ++++++++++++++
 sys/arm64/include/reg.h    | 13 +++++++--
 4 files changed, 92 insertions(+), 16 deletions(-)
Comment 2 commit-hook freebsd_committer 2021-02-24 15:03:43 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4786c8582c569a7245dadbdbb4638d1667c10d62

commit 4786c8582c569a7245dadbdbb4638d1667c10d62
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2021-01-28 17:49:47 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2021-02-24 14:58:43 +0000

    arm64: extend struct db_reg to include watchpoint registers

    The motivation is to provide access to these registers from userspace
    via ptrace(2) requests PT_GETDBREGS and PT_SETDBREGS.

    This change breaks the ABI of these particular requests, but is
    justified by the fact that the intended consumers (debuggers) have not
    been taught to use them yet. Making this change now enables active
    upstream work on lldb to begin using this interface, and take advantage
    of the hardware debugging registers available on the platform.

    PR:             252860
    Reported by:    MichaŠGórny (mgorny@gentoo.org)
    Reviewed by:    andrew, markj (earlier version)
    Tested by:      MichaŠGórny (mgorny@gentoo.org)
    Sponsored by:   The FreeBSD Foundation

    (cherry picked from commit f2583be110ca3a5b32f0993f1464a5c69151c62f)

 sys/arm64/arm64/identcpu.c |  2 +-
 sys/arm64/arm64/machdep.c  | 71 ++++++++++++++++++++++++++++++++++++++--------
 sys/arm64/include/armreg.h | 22 ++++++++++++++
 sys/arm64/include/reg.h    | 13 +++++++--
 4 files changed, 92 insertions(+), 16 deletions(-)
Comment 3 commit-hook freebsd_committer 2021-02-25 21:33:20 UTC
A commit in branch releng/13.0 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f1847ed16ebd16d91766934ff7c28e887fbd2846

commit f1847ed16ebd16d91766934ff7c28e887fbd2846
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2021-01-28 17:49:47 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2021-02-25 21:31:31 +0000

    arm64: extend struct db_reg to include watchpoint registers

    The motivation is to provide access to these registers from userspace
    via ptrace(2) requests PT_GETDBREGS and PT_SETDBREGS.

    This change breaks the ABI of these particular requests, but is
    justified by the fact that the intended consumers (debuggers) have not
    been taught to use them yet. Making this change now enables active
    upstream work on lldb to begin using this interface, and take advantage
    of the hardware debugging registers available on the platform.

    PR:             252860
    Reported by:    MichaŠGórny (mgorny@gentoo.org)
    Reviewed by:    andrew, markj (earlier version)
    Tested by:      MichaŠGórny (mgorny@gentoo.org)
    Sponsored by:   The FreeBSD Foundation
    Approved by:    re (gjb)

    (cherry picked from commit f2583be110ca3a5b32f0993f1464a5c69151c62f)
    (cherry picked from commit 4786c8582c569a7245dadbdbb4638d1667c10d62)

 sys/arm64/arm64/identcpu.c |  2 +-
 sys/arm64/arm64/machdep.c  | 71 ++++++++++++++++++++++++++++++++++++++--------
 sys/arm64/include/armreg.h | 22 ++++++++++++++
 sys/arm64/include/reg.h    | 13 +++++++--
 4 files changed, 92 insertions(+), 16 deletions(-)