From nobody Sat Mar 09 04:40:47 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 4Ts9Mh6ZHZz5CqHq; Sat, 9 Mar 2024 04:40:48 +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 4Ts9Mh0k6xz4nRQ; Sat, 9 Mar 2024 04:40:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709959248; 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=2S5sdo4NHln5awe57UbAFARLWpwvUIS7GiivJrT9Yxg=; b=tJleLAB7Ye4dNC2VIxeEf74Mz6SfiOu2JZgyY5dVTVTXsrE/rauPaIz8vQGS63Fdd+ALf8 zMhO5PN16PNAr/TaRcTzdI0rW3TPGVW3/lFaa+C75qLpQqidTE/vK1u3/WoYA6uNu1lMBn 1o9TvGdeaarzlVaayLMibFBz/YkrJgI87Hiktli2n01BpksRG5ND7PCouREhD+LdflyG1Q fWgzdD+bB+YzMSTZB1/RVV/pslLFfQqqNcCVOe8SXPCmZhj47k61DTxV+Nnot6fS2AC0id aSBaXZYxOgMT6vrR2FcZMjqwTq1ee0oUeIERfY7/ad35BkpWT7n0f0FbGTyzaw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709959248; a=rsa-sha256; cv=none; b=Gq6u1CMlJWQvZQ6rS4eBOzjZRQakDW6BtoTwbiXPCwXk2GQ8Y3wV5Wh+IskALywRgHQLFF iPKiuzFViLmqgfHAE9RdkqiwBS7iMduD/QxHxAqHeiYwGBk7M2aMgNepS1kVaq/OJxV49/ J793VN85b9LdO/jJxKfZQziY7OUtz5UuuB+0oCLvNuNH/vejZYQCZ98dV2YFqIjNT0BiEq aLoTOw+SqQ3LXWA6bKNvs9vXuPON88iww7NU14ngROSTur4Xu8kqMbTxRnC0vSo/NID51T q49hdWCxvr26+CEg3yo58zBuy6qgN0PGO/7YbFimxGPbQ4oiU6TmgfXvL/U7Zg== 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=1709959248; 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=2S5sdo4NHln5awe57UbAFARLWpwvUIS7GiivJrT9Yxg=; b=ECnNTgsDhPgrK+9nvtTzGuomfoIiBdcCoxYMcuxZEWUnHBXgtCyTgn+PkMElPneJWk+2Io ok43o8Lsjfe2RZ6oTTcbVsSlGMk7Dug+/SSxW764hgY43eXBAVL4ybJmUPOZ9UU18RdQ2a 11+S6YnK/T02HfiSQtZQXeFRmxBj7k/StLhYj0ShSFapqLDmQVQ0iEjrH6i3Cvjud27qug 5gwsAtvhthvRqx+I9PyDOKXWcxoGxBbCG5l8XsM5IwN6RX2KGaeDvcB/7vt9pKkkWVUBrs E5VBNtVZC3o9u7ZIpWe/JG37DtJidQE1OR7S8o6e5e44drDdkBx2+EINlkqMXA== 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 4Ts9Mh0L9gzp5d; Sat, 9 Mar 2024 04:40:48 +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 4294elXa030947; Sat, 9 Mar 2024 04:40:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4294elfi030944; Sat, 9 Mar 2024 04:40:47 GMT (envelope-from git) Date: Sat, 9 Mar 2024 04:40:47 GMT Message-Id: <202403090440.4294elfi030944@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: a0f02252c417 - stable/14 - vmm: Expose more registers to VM_GET_REGISTER 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: a0f02252c4175b5336c215cc7774c3ea08873476 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a0f02252c4175b5336c215cc7774c3ea08873476 commit a0f02252c4175b5336c215cc7774c3ea08873476 Author: Mark Johnston AuthorDate: 2024-02-07 13:47:24 +0000 Commit: Mark Johnston CommitDate: 2024-03-09 04:28:39 +0000 vmm: Expose more registers to VM_GET_REGISTER In a follow-up revision the gdb stub will support sending an XML target description to gdb, which lets us send additional registers, including the ones added in this patch. Reviewed by: jhb MFC after: 1 month Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D43665 (cherry picked from commit f493ea650e6137ba657dfa0627da1e8bb4a985e9) --- sys/amd64/include/vmm.h | 4 ++++ sys/amd64/vmm/amd/vmcb.c | 17 +++++++++++++++++ sys/amd64/vmm/intel/vmcs.c | 5 ++++- sys/amd64/vmm/intel/vmx.c | 10 +++++++++- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/sys/amd64/include/vmm.h b/sys/amd64/include/vmm.h index 273a1a46ba04..7d5d13678122 100644 --- a/sys/amd64/include/vmm.h +++ b/sys/amd64/include/vmm.h @@ -98,6 +98,10 @@ enum vm_reg_name { VM_REG_GUEST_DR3, VM_REG_GUEST_DR6, VM_REG_GUEST_ENTRY_INST_LENGTH, + VM_REG_GUEST_FS_BASE, + VM_REG_GUEST_GS_BASE, + VM_REG_GUEST_KGS_BASE, + VM_REG_GUEST_TPR, VM_REG_LAST }; diff --git a/sys/amd64/vmm/amd/vmcb.c b/sys/amd64/vmm/amd/vmcb.c index ce05c912fc6a..4bd2fae9f821 100644 --- a/sys/amd64/vmm/amd/vmcb.c +++ b/sys/amd64/vmm/amd/vmcb.c @@ -39,6 +39,7 @@ #include "vmm_ktr.h" +#include "vlapic.h" #include "vmcb.h" #include "svm.h" #include "svm_softc.h" @@ -231,6 +232,22 @@ vmcb_read(struct svm_vcpu *vcpu, int ident, uint64_t *retval) *retval = seg->selector; break; + case VM_REG_GUEST_FS_BASE: + case VM_REG_GUEST_GS_BASE: + seg = vmcb_segptr(vmcb, ident == VM_REG_GUEST_FS_BASE ? + VM_REG_GUEST_FS : VM_REG_GUEST_GS); + KASSERT(seg != NULL, ("%s: unable to get segment %d from VMCB", + __func__, ident)); + *retval = seg->base; + break; + case VM_REG_GUEST_KGS_BASE: + *retval = state->kernelgsbase; + break; + + case VM_REG_GUEST_TPR: + *retval = vlapic_get_cr8(vm_lapic(vcpu->vcpu)); + break; + case VM_REG_GUEST_GDTR: case VM_REG_GUEST_IDTR: /* GDTR and IDTR don't have segment selectors */ diff --git a/sys/amd64/vmm/intel/vmcs.c b/sys/amd64/vmm/intel/vmcs.c index 53ed5fbfc9ba..1a7626f7a65d 100644 --- a/sys/amd64/vmm/intel/vmcs.c +++ b/sys/amd64/vmm/intel/vmcs.c @@ -120,10 +120,13 @@ vmcs_field_encoding(int ident) return (VMCS_GUEST_PDPTE3); case VM_REG_GUEST_ENTRY_INST_LENGTH: return (VMCS_ENTRY_INST_LENGTH); + case VM_REG_GUEST_FS_BASE: + return (VMCS_GUEST_FS_BASE); + case VM_REG_GUEST_GS_BASE: + return (VMCS_GUEST_GS_BASE); default: return (-1); } - } static int diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c index 317ed7e5d7fb..3fe20986ec8d 100644 --- a/sys/amd64/vmm/intel/vmx.c +++ b/sys/amd64/vmm/intel/vmx.c @@ -3404,8 +3404,16 @@ vmx_getreg(void *vcpui, int reg, uint64_t *retval) panic("vmx_getreg: %s%d is running", vm_name(vmx->vm), vcpu->vcpuid); - if (reg == VM_REG_GUEST_INTR_SHADOW) + switch (reg) { + case VM_REG_GUEST_INTR_SHADOW: return (vmx_get_intr_shadow(vcpu, running, retval)); + case VM_REG_GUEST_KGS_BASE: + *retval = vcpu->guest_msrs[IDX_MSR_KGSBASE]; + return (0); + case VM_REG_GUEST_TPR: + *retval = vlapic_get_cr8(vm_lapic(vcpu->vcpu)); + return (0); + } if (vmxctx_getreg(&vcpu->ctx, reg, retval) == 0) return (0);