From nobody Fri Jan 05 00:28:17 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 4T5knt1QHcz55ftx; Fri, 5 Jan 2024 00:28:18 +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 4T5knt0xWTz4hn7; Fri, 5 Jan 2024 00:28:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704414498; 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=OXcVnwbQVK2eG8eJ/cb/XG2ByJoUjKnnhhDy4PPHdQI=; b=cyTtxRu9mrW+uYzkChLj0gkbJqwIqWJtnzY4WyucV0cYYTAQpAYpW9H6MEvOUnKNXEZIJ8 CPIS+XtA06p5NyRZyEbZ93fbgP9yeMI5cfkQg7ZZifx2/XVB9nTk+XUVhCq8I25+VN1yWx maUEcGO4wwhQ0SG5I+6G0R5g4Po3m7nOHeJABW8yAZ5ZxbirmTiIsBbqSxunN15dUBWEmx il6ab6yx2sJ6xpmunXNrMR/3qhR/3O5S8YOFy1CqUrZfd+UN0x4sg+08dI6UcWThabrqPE 9cBEfoOMyGWIu5ab30LTYk0AMG1IEvOKIPaoTwhKVy5OsTKtXzQ4Ywr5Xtn/Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704414498; 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=OXcVnwbQVK2eG8eJ/cb/XG2ByJoUjKnnhhDy4PPHdQI=; b=er6eI7iA0luugnhkqzSpfdbreOXlfyrU/iTqWBIx610tnSxF74oxrSzOhp5eeKHDb8bUAn C2R30cQlDSvcebAqdKeGpNeqV6UtSfNpWTcgYPJii1wfFrhAiS8PX1dje3Z3eNXxs9vyfH +GaeS+MA4TWe6XMVBQVsGoOEZDNyjFoZ8I1oL3Qe0WGPVS+9iY0pX10BmqbdHjsxGYkKHp 2Ph4JiwAyTfLCQ7Fz+48f8xCTl1crYC3I0FBTrh1M/Si5qNyqdLOazaAAF9c/0ScZdHSSf sbkGpAGiVK0rFb9jQhKJpddHnXRrG96EElP9NHffWoqf7Zf7caSxYlPTvAE/2Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704414498; a=rsa-sha256; cv=none; b=l8qqg76jcOL1QXvFAfF4WnIJYZFN+7iG1UK3fXBTaNDD7un9Msl9zksWfPAKKXV1lHQgaD S0qN0AgvYWSC75dYik2c4H0k75Qka7xrpAKFuprC5ihHPOYTp1pmsERpCaTIEmwLbtROSD oZFYEKiTFPWZ1Hwh0uSf8k2P55pR1cw/JdOqidlnE5AVcMzsvPy49Pa3SkhHykGUQBR/Bu LX8TYAkRcI/AudVfbsEA9gRrHseTj7KsWf9epq77NBkfQerkcZ75CRR928TtGpp91FAr0B dVihSRX7UrZP9AJ+AUtSOlyv2q5cErz6XPnp+T4gFzReMdotK9Mboc+kuMeSSA== 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 4T5kns75cjzbsY; Fri, 5 Jan 2024 00:28:17 +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 4050SHXC026690; Fri, 5 Jan 2024 00:28:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4050SHhs026687; Fri, 5 Jan 2024 00:28:17 GMT (envelope-from git) Date: Fri, 5 Jan 2024 00:28:17 GMT Message-Id: <202401050028.4050SHhs026687@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 3613a2806667 - stable/14 - vmm: enable software breakpoints for AMD CPUs 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 3613a28066674aead5487d67952d50c6b228578b Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=3613a28066674aead5487d67952d50c6b228578b commit 3613a28066674aead5487d67952d50c6b228578b Author: Bojan Novković AuthorDate: 2023-12-07 22:46:31 +0000 Commit: John Baldwin CommitDate: 2024-01-05 00:25:22 +0000 vmm: enable software breakpoints for AMD CPUs This patch adds support for software breakpoint vmexits on AMD SVM. It implements the VM_CAP_BPT_EXIT used to enable software breakpoints. When enabled, breakpoint vmexits are passed to userspace where they are handled by the GDB stub. Reviewed by: jhb Sponsored by: Google, Inc. (GSoC 2022) Differential Revision: https://reviews.freebsd.org/D42295 (cherry picked from commit 231eee17d2905682014b71d1f01719003b13bd91) --- sys/amd64/vmm/amd/svm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/amd64/vmm/amd/svm.c b/sys/amd64/vmm/amd/svm.c index a502632f6ed6..ec0cde31aaad 100644 --- a/sys/amd64/vmm/amd/svm.c +++ b/sys/amd64/vmm/amd/svm.c @@ -1421,6 +1421,12 @@ svm_vmexit(struct svm_softc *svm_sc, struct svm_vcpu *vcpu, break; case IDT_BP: + vmexit->exitcode = VM_EXITCODE_BPT; + vmexit->u.bpt.inst_length = vmexit->inst_length; + vmexit->inst_length = 0; + + reflect = 0; + break; case IDT_OF: case IDT_BR: /* @@ -2333,6 +2339,9 @@ svm_setcap(void *vcpui, int type, int val) if (val == 0) error = EINVAL; break; + case VM_CAP_BPT_EXIT: + svm_set_intercept(vcpu, VMCB_EXC_INTCPT, BIT(IDT_BP), val); + break; case VM_CAP_IPI_EXIT: vlapic = vm_lapic(vcpu->vcpu); vlapic->ipi_exit = val; @@ -2366,6 +2375,9 @@ svm_getcap(void *vcpui, int type, int *retval) case VM_CAP_UNRESTRICTED_GUEST: *retval = 1; /* unrestricted guest is always enabled */ break; + case VM_CAP_BPT_EXIT: + *retval = svm_get_intercept(vcpu, VMCB_EXC_INTCPT, BIT(IDT_BP)); + break; case VM_CAP_IPI_EXIT: vlapic = vm_lapic(vcpu->vcpu); *retval = vlapic->ipi_exit;