From nobody Thu Dec 07 23:17:16 2023 X-Original-To: dev-commits-src-main@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 4SmVXr5nGLz53mpx; Thu, 7 Dec 2023 23:17:16 +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 4SmVXr4lJqz3WpR; Thu, 7 Dec 2023 23:17:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701991036; 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=fEvYWnoAWCiIw+aeC0AftnjNhiHAebBIKOADLzcUg80=; b=PqRg1lLCcmOfmAg5k5k9ugZz3lgYedlVbtzFVOGLvi7As8+kfq9tlsvBgnECF1Elu3VqLu 4xMTilJtrTiDJoS0oRaPNpMGPy6Qbzlogh8TXmb8RoMJenahR12flK6kVjyGeGBuvD3qC5 21cljBNZZDzKahHL8jZMPJXBtTWX8L9DnEctZBfsT441BcCIRj0jgyOMaGnLiTy2YfzbAm OIEmeAaxMjevFYl6FRFy/KBHh/533VqachRoJT0BqTihnR/eZ9pHhvRa27EtbAKvNa0r2l vqVrbFNsQBKuNH4PK0tlLDaszOIKC+AHHU0IYzUWBMCZldNVP0E50e0+1IV+xw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701991036; a=rsa-sha256; cv=none; b=GMFOKZ3BDFgPiiMQZ6T0FKzHDeFVuLeZNQ0QKuz5dahpplB0OD5Hj7ddqWP9KS778/wWZl +xD9AynIx7McgqVBOty+P1+mvaE8Uee6Vy7US6raQ5uIlWFJ4R3OpN/JiKc6DStEnUIvD6 kINMg5Urt83gGfQeFMM4kE5RAsl+MH/t1sRIXXn6ZxsSuarYJdgebg3KbSxBQ2i1eeYUDu NQwQpRZqLENDywoaQ4I+FiKA6orkw9mXP2n0gc7rvge6LmiW78URUtgS9IV2oi1qo6B2Sj zv5kKDWdHEjQmw24BhcZOT/mYyRJEVG1ApBE5bt09mN9/j0bsWabqH6qkoA9oA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701991036; 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=fEvYWnoAWCiIw+aeC0AftnjNhiHAebBIKOADLzcUg80=; b=azEFNbcL8B0d2QimlZ1BPxR8T4Yy08sIU70Xj75djdepbUfHVv5BP0/ATAK2HKqNb8UWIm PjkrPGDMijl4Zm1e7Sb0NgKTei3bHfLfBn8siZCTMzV9i4xYjEPu+GFD1QE33DNf5J8GXL gjjgfqLIG6S8CcTIgmsX3kSbG3SP6sBqild5cK74lUnUJg2NEQ6nBny+KirT8d5yIigXRu n2G9K4eI2z0Y0TnvNPS8eNa52wwDrZUNTuxyWJlvkITnKNsM2OarrOswrVR5mj7Eugmh9u s+RksaUbWLqlA9PsORzDCmphMtYVIlZu8Lvtwr+tABXKAKvMkp75mKuNnDDtvg== 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 4SmVXr3jJvzwjq; Thu, 7 Dec 2023 23:17:16 +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 3B7NHGuu026691; Thu, 7 Dec 2023 23:17:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3B7NHGd2026688; Thu, 7 Dec 2023 23:17:16 GMT (envelope-from git) Date: Thu, 7 Dec 2023 23:17:16 GMT Message-Id: <202312072317.3B7NHGd2026688@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 231eee17d290 - main - vmm: enable software breakpoints for AMD CPUs List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 231eee17d2905682014b71d1f01719003b13bd91 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=231eee17d2905682014b71d1f01719003b13bd91 commit 231eee17d2905682014b71d1f01719003b13bd91 Author: Bojan Novković AuthorDate: 2023-12-07 22:46:31 +0000 Commit: John Baldwin CommitDate: 2023-12-07 23:10:56 +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 --- 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;