From nobody Wed Feb 21 13:24:32 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Tfxnr42Shz5CBKw; Wed, 21 Feb 2024 13:24:32 +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 4Tfxnr375Tz4YmL; Wed, 21 Feb 2024 13:24:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708521872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=55/N8biJUXWNfWZ6a0plToUgGW3D7WDGR1H5cgavSCE=; b=BreRGoQD9DGAVH4FrsilxlYqG5Sd84Qq2TPx8AywQBfbkj0ir0/gIN5oqt9BSUIM4OykkQ gCcMVBgVDO7lpBUQFK1oVsqkXm5pP/5OmZ0OLc6Y0NjM0eYI9qflbQSp7aEUegfqra2gFe KE/ELL2M/gIm79oKNFJU17PzoUgFEoOGO2svdu+PHE8D+WPgcN0QYq8TbdKlIhtR3kn0OK PjgadeScmgfEbJ5R+rkQMaO3QzPyXXRtupO0SU8hpsocnyRZRg72QIeR+kEDsaSsOJjTBa rV4e8c1+Im7pREDe2lPYXBEe2UnAnt649ECPL6qJLZMP/cNPRDeOuftPAjHoKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708521872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=55/N8biJUXWNfWZ6a0plToUgGW3D7WDGR1H5cgavSCE=; b=LwOa3mCPWzzxCAFNjYlb/Hi9Dchxln3lxCxWkWG9R2G8EJi/Tn6Q0l+afwA9lAi69zQ94N B4Hlisx0TfutQWNRa8eFmpOUxKgjgjg5TswR/CCE4KJmCHCC8I1CRwidX55OdFGBe0thCS D+XKXbiU8AMT/g2BC5Oo2H2JZT5kopxM5lZiw9LZcTUipNbUPTmnW8IMP0AMIb7YHh+D2K kaHSmb6JbX2D7IWMWmEIFjZecy0aG6G2P+/Ubn6HZCvvssoLV23MsHBkz57yI4gASRK1Nc HF8cGOpZ6qXU0J8fXk/RQUZvovCSy8/M46KzLW4dMRdGuT+lhgVrbZ8SVntRYA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708521872; a=rsa-sha256; cv=none; b=d9eYrjLaXhEQrXcSd6stQkZM6p1c5S0ItXx6q/PXB08spa1NVix+K0brO3ddMlELP98GZD ej/3/yt9a3sFwEJnN1Q8VclEw6tK9llZysxtzJLI6vfqeRZu8DmIo6AD21bCGhBZp8XkVu S9uWEZWxrba4OlhRbUjWG4WULEMNnYoz1cJVo0zamkhAQmulBSryN3ojs0qHuN2TYzDurR Eavkvuk4YZv2X3niAnQqBOAdF0w2pPgFZKNfQ00djg7qEZPWvGXTAP7Ic/BK8m3JcsTiiP FDt9CpTIQq+pcrCZQIfHDatgdS3Mvm2Fu25a6Kari4uasMfnXSBQyK0vzVEBCw== 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 4Tfxnr20XSz145k; Wed, 21 Feb 2024 13:24:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41LDOWCm015473; Wed, 21 Feb 2024 13:24:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41LDOWbh015470; Wed, 21 Feb 2024 13:24:32 GMT (envelope-from git) Date: Wed, 21 Feb 2024 13:24:32 GMT Message-Id: <202402211324.41LDOWbh015470@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: c5f972e7fced - stable/14 - bhyve: Add support for the 'p' query List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: c5f972e7fced3aa1825564d70b05e58c88fac678 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c5f972e7fced3aa1825564d70b05e58c88fac678 commit c5f972e7fced3aa1825564d70b05e58c88fac678 Author: Mark Johnston AuthorDate: 2024-02-07 13:46:59 +0000 Commit: Mark Johnston CommitDate: 2024-02-21 13:16:12 +0000 bhyve: Add support for the 'p' query This lets gdb query individual registers. It's easy to implement and is used by gdb when attaching to a CHERI target, so let's support it. Sponsored by: Innovate UK Reviewed by: corvink, jhb MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D43664 (cherry picked from commit e6516294f4c7afa9da40a39caab86a5cd2aeb35a) --- usr.sbin/bhyve/gdb.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bhyve/gdb.c b/usr.sbin/bhyve/gdb.c index f2976622c79a..6bdfbc5e8536 100644 --- a/usr.sbin/bhyve/gdb.c +++ b/usr.sbin/bhyve/gdb.c @@ -1036,6 +1036,29 @@ gdb_read_regs(void) finish_packet(); } +static void +gdb_read_one_reg(const uint8_t *data, size_t len) +{ + uint64_t regval; + uintmax_t reg; + + reg = parse_integer(data, len); + if (reg >= nitems(gdb_regset)) { + send_error(EINVAL); + return; + } + + if (vm_get_register(vcpus[cur_vcpu], gdb_regset[reg].id, ®val) == + -1) { + send_error(errno); + return; + } + + start_packet(); + append_unsigned_native(regval, gdb_regset[reg].size); + finish_packet(); +} + static void gdb_read_mem(const uint8_t *data, size_t len) { @@ -1598,10 +1621,12 @@ handle_command(const uint8_t *data, size_t len) /* TODO: Resume any stopped CPUs. */ break; - case 'g': { + case 'g': gdb_read_regs(); break; - } + case 'p': + gdb_read_one_reg(data + 1, len - 1); + break; case 'H': { int tid; @@ -1673,7 +1698,6 @@ handle_command(const uint8_t *data, size_t len) case 'v': /* Handle 'vCont' */ /* 'vCtrlC' */ - case 'p': /* TODO */ case 'P': /* TODO */ case 'Q': /* TODO */ case 't': /* TODO */