From owner-svn-src-all@freebsd.org Sat Aug 12 18:42:56 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 582D9DC4E57; Sat, 12 Aug 2017 18:42:56 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3433E6CC34; Sat, 12 Aug 2017 18:42:56 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7CIgtQ6021492; Sat, 12 Aug 2017 18:42:55 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7CIgtJA021488; Sat, 12 Aug 2017 18:42:55 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201708121842.v7CIgtJA021488@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sat, 12 Aug 2017 18:42:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322437 - in head/sys/arm64: arm64 include X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head/sys/arm64: arm64 include X-SVN-Commit-Revision: 322437 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Aug 2017 18:42:56 -0000 Author: jhb Date: Sat Aug 12 18:42:54 2017 New Revision: 322437 URL: https://svnweb.freebsd.org/changeset/base/322437 Log: Reliably enable debug exceptions on all CPUs. Previously, debug exceptions were only enabled on the boot CPU if DDB was enabled in the dbg_monitor_init() function. APs also called this function, but since mp_machdep.c doesn't include opt_ddb.h, the APs ended up calling an empty stub defined in instead of the real function. Also, if DDB was not enabled in the kernel, the boot CPU would not enable debug exceptions. Fix this by adding a new dbg_init() function that always clears the OS lock to enable debug exceptions which the boot CPU and the APs call. This function also calls dbg_monitor_init() to enable hardware breakpoints from DDB on all CPUs if DDB is enabled. Eventually base support for hardware breakpoints/watchpoints will need to move out of the DDB-only debug_monitor.c for use by userland debuggers. Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D12001 Modified: head/sys/arm64/arm64/debug_monitor.c head/sys/arm64/arm64/machdep.c head/sys/arm64/arm64/mp_machdep.c head/sys/arm64/include/machdep.h Modified: head/sys/arm64/arm64/debug_monitor.c ============================================================================== --- head/sys/arm64/arm64/debug_monitor.c Sat Aug 12 18:38:18 2017 (r322436) +++ head/sys/arm64/arm64/debug_monitor.c Sat Aug 12 18:42:54 2017 (r322437) @@ -453,15 +453,12 @@ dbg_monitor_init(void) { u_int i; - /* Clear OS lock */ - WRITE_SPECIALREG(OSLAR_EL1, 0); - /* Find out many breakpoints and watchpoints we can use */ dbg_watchpoint_num = ((READ_SPECIALREG(ID_AA64DFR0_EL1) >> 20) & 0xf) + 1; dbg_breakpoint_num = ((READ_SPECIALREG(ID_AA64DFR0_EL1) >> 12) & 0xf) + 1; if (bootverbose && PCPU_GET(cpuid) == 0) { - db_printf("%d watchpoints and %d breakpoints supported\n", + printf("%d watchpoints and %d breakpoints supported\n", dbg_watchpoint_num, dbg_breakpoint_num); } Modified: head/sys/arm64/arm64/machdep.c ============================================================================== --- head/sys/arm64/arm64/machdep.c Sat Aug 12 18:38:18 2017 (r322436) +++ head/sys/arm64/arm64/machdep.c Sat Aug 12 18:42:54 2017 (r322437) @@ -1051,11 +1051,24 @@ initarm(struct arm64_bootparams *abp) mutex_init(); init_param2(physmem); - dbg_monitor_init(); + dbg_init(); kdb_init(); pan_enable(); early_boot = 0; +} + +void +dbg_init(void) +{ + + /* Clear OS lock */ + WRITE_SPECIALREG(OSLAR_EL1, 0); + + /* This permits DDB to use debug registers for watchpoints. */ + dbg_monitor_init(); + + /* TODO: Eventually will need to initialize debug registers here. */ } #ifdef DDB Modified: head/sys/arm64/arm64/mp_machdep.c ============================================================================== --- head/sys/arm64/arm64/mp_machdep.c Sat Aug 12 18:38:18 2017 (r322436) +++ head/sys/arm64/arm64/mp_machdep.c Sat Aug 12 18:42:54 2017 (r322437) @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include @@ -272,7 +271,7 @@ init_secondary(uint64_t cpu) vfp_init(); #endif - dbg_monitor_init(); + dbg_init(); pan_enable(); /* Enable interrupts */ Modified: head/sys/arm64/include/machdep.h ============================================================================== --- head/sys/arm64/include/machdep.h Sat Aug 12 18:38:18 2017 (r322436) +++ head/sys/arm64/include/machdep.h Sat Aug 12 18:42:54 2017 (r322437) @@ -48,6 +48,7 @@ extern enum arm64_bus arm64_bus_method; extern vm_paddr_t physmap[]; extern u_int physmap_idx; +void dbg_init(void); void initarm(struct arm64_bootparams *); extern void (*pagezero)(void *);