From owner-dev-commits-src-all@freebsd.org Mon Mar 29 15:06:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CAD1E57A32A; Mon, 29 Mar 2021 15:06:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F8GB52WJBz3mdD; Mon, 29 Mar 2021 15:06:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 707AF154ED; Mon, 29 Mar 2021 15:06:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12TF6JNI044342; Mon, 29 Mar 2021 15:06:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12TF6Juv044341; Mon, 29 Mar 2021 15:06:19 GMT (envelope-from git) Date: Mon, 29 Mar 2021 15:06:19 GMT Message-Id: <202103291506.12TF6Juv044341@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 5a2933d0bf9f - main - arm: implement kdb watchpoint functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5a2933d0bf9fb0018349b67a39fa85cbb3740779 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Mar 2021 15:06:22 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=5a2933d0bf9fb0018349b67a39fa85cbb3740779 commit 5a2933d0bf9fb0018349b67a39fa85cbb3740779 Author: Mitchell Horne AuthorDate: 2021-03-04 00:14:42 +0000 Commit: Mitchell Horne CommitDate: 2021-03-29 15:05:44 +0000 arm: implement kdb watchpoint functions Implement wrappers around the existing debug_monitor interface, to be consumed by MI kernel debugger code. For now, the various db_printf() calls in this code remain. In the future, they could be converted to printf() or removed altogether, to properly decouple the DDB and GDB options. Reviewed by: jhb, kib, markj MFC after: 3 weeks Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D29155 --- sys/arm/arm/debug_monitor.c | 37 ++++++++++++++++++++++++++++++++++--- sys/arm/include/kdb.h | 2 ++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/sys/arm/arm/debug_monitor.c b/sys/arm/arm/debug_monitor.c index ddf3e8e67b25..55b5f70b2397 100644 --- a/sys/arm/arm/debug_monitor.c +++ b/sys/arm/arm/debug_monitor.c @@ -326,6 +326,35 @@ kdb_cpu_clear_singlestep(void) } } +int +kdb_cpu_set_watchpoint(vm_offset_t addr, size_t size, int access) +{ + enum dbg_access_t dbg_access; + + switch (access) { + case KDB_DBG_ACCESS_R: + dbg_access = HW_WATCHPOINT_R; + break; + case KDB_DBG_ACCESS_W: + dbg_access = HW_WATCHPOINT_W; + break; + case KDB_DBG_ACCESS_RW: + dbg_access = HW_WATCHPOINT_RW; + break; + default: + return (EINVAL); + } + + return (dbg_setup_watchpoint(addr, size, (enum dbg_access_t)access)); +} + +int +kdb_cpu_clr_watchpoint(vm_offset_t addr, size_t size) +{ + + return (dbg_remove_watchpoint(addr, size)); +} + int dbg_setup_watchpoint(db_expr_t addr, db_expr_t size, enum dbg_access_t access) { @@ -624,7 +653,7 @@ dbg_setup_xpoint(struct dbg_wb_conf *conf) if (i == ~0U) { db_printf("Can not find slot for %s, max %d slots supported\n", typestr, dbg_watchpoint_num); - return (ENXIO); + return (EBUSY); } } @@ -645,7 +674,8 @@ dbg_setup_xpoint(struct dbg_wb_conf *conf) cr_size = DBG_WB_CTRL_LEN_8; break; default: - db_printf("Unsupported address size for %s\n", typestr); + db_printf("Unsupported address size for %s: %zu\n", typestr, + conf->size); return (EINVAL); } @@ -667,7 +697,8 @@ dbg_setup_xpoint(struct dbg_wb_conf *conf) cr_access = DBG_WB_CTRL_LOAD | DBG_WB_CTRL_STORE; break; default: - db_printf("Unsupported exception level for %s\n", typestr); + db_printf("Unsupported access type for %s: %d\n", + typestr, conf->access); return (EINVAL); } diff --git a/sys/arm/include/kdb.h b/sys/arm/include/kdb.h index 42677499ed78..728bf211dc62 100644 --- a/sys/arm/include/kdb.h +++ b/sys/arm/include/kdb.h @@ -41,6 +41,8 @@ extern void kdb_cpu_clear_singlestep(void); extern void kdb_cpu_set_singlestep(void); boolean_t kdb_cpu_pc_is_singlestep(db_addr_t); +int kdb_cpu_set_watchpoint(vm_offset_t addr, size_t size, int access); +int kdb_cpu_clr_watchpoint(vm_offset_t addr, size_t size); static __inline void kdb_cpu_sync_icache(unsigned char *addr, size_t size)