From nobody Sun Oct 06 15:01:45 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 4XM58p0dpgz5YB6W; Sun, 06 Oct 2024 15:01:46 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XM58n6B8Gz485Z; Sun, 6 Oct 2024 15:01:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728226905; 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=ymX9h/KemfA6h7KKE7S0Zlb3iDvUacH0iDDOJNB0yd8=; b=x8Ce6iOsoVq5NurDIDha4WwbtZC8pHCmBu9oXE5imobwHk3oM9eFqja5ghykr3YSgw0UZs sL6pb2tlzI6KkhSFSIxHOTGMmUcfF38BMpUEz9cLr8ecY9otJuWEzJ7eaYBnrJ8IT7fCPy TdMGJWUtnqhqh+zIsA2q80vnrU9ZJrnr+5SdFLLJiapHLESLgnTKraXh/kLkTj8+decCyH /kHwOBCs540CYRxq/yBqwiL+HnmGXqqW7Mstp204krB95upTs9nvbKoz+npkLfDE280+X3 wMYvuYODcVtFgGFOl/Hp1onkjDPE7CLQMeyvCeEpTuQCpNdyvUJRUY129tbJrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728226905; 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=ymX9h/KemfA6h7KKE7S0Zlb3iDvUacH0iDDOJNB0yd8=; b=QAx4qjsPVe7YKbPMW9KroJ3Qez+Hj2G7tOXyoK9WufuPFvyVuFlnG+36O1saqDjDfJrD8O ZRhwwfhOfpIcUc8LcLDgAvxySS/OKg7siO99jYgowmkmdSHGU5rlw9nn/UGu61EBD/PsoG CZgwH4eS6n9FQG6O0QqzGub6lCQLfNt6XpmJtlH+S075Vmj2opJqVATlzm5QekS9azLf1h fOMS2yM3KZsCrN9UlGaV8NSKogNFWHXdjqNDxCB1LVmlGsPFir45CCGSAQwZHEHi+OhHYv p1aPRNKLBDNVsRHDblVv9FvWs3H3QVUbutCZjK6Fo+0Yw5bRRpG1InFT76sNRw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728226905; a=rsa-sha256; cv=none; b=kJV7oAc5+E1XCB9Jyerk2YE71b8vHg4j+VEG0bBMswU2uZhYSuFgrHqdw6ahcCUJa91K3i 59MAVSguMq7x3goov5v+Jo3CZcvhb2M6dCWmf0septqOLvADyNv/i3SGsTQPBY2PaZdSUD 2ogEDtmZ8mU/F6jEMNpgJ/EF5Czg+WtMeir54xAhjiyOxQWH0SwaVPdjpPnRWC0kXpBFZq HUYcAgGhDe2Ww0YaA5vH6Hz4VJcQCRxIs9Awk+NIUJ2hTiSksLvC/dUVfkpQIkBUzCcFFH IjM7TqfZ3+VbtZtxSXec7ky+JmvdoBVSL+mszo8UopNMWTNB87n/66y80Ouwgw== 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 4XM58n5g5nz15pk; Sun, 6 Oct 2024 15:01:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 496F1jDS046879; Sun, 6 Oct 2024 15:01:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 496F1j5j046876; Sun, 6 Oct 2024 15:01:45 GMT (envelope-from git) Date: Sun, 6 Oct 2024 15:01:45 GMT Message-Id: <202410061501.496F1j5j046876@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 2dea4de8e0f0 - stable/14 - vmm: Properly handle writes spanning across two pages in vm_handle_db 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 2dea4de8e0f0ee886cf46a5ceddabd4192843445 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=2dea4de8e0f0ee886cf46a5ceddabd4192843445 commit 2dea4de8e0f0ee886cf46a5ceddabd4192843445 Author: Bojan Novković AuthorDate: 2024-09-29 11:10:10 +0000 Commit: Ed Maste CommitDate: 2024-10-06 15:01:24 +0000 vmm: Properly handle writes spanning across two pages in vm_handle_db The vm_handle_db function is responsible for writing correct status register values into memory when a guest VM is being single-stepped using the RFLAGS.TF mechanism. However, it currently does not properly handle an edge case where the resulting write spans across two pages. This commit fixes this by making vm_handle_db use two vm_copy_info structs. Security: HYP-09 Reviewed by: markj (cherry picked from commit 51fda658baa3f80c9778f3a9873fbf67df87119b) --- sys/amd64/vmm/vmm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index f399f876717d..ef4c7a9af2ea 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -1771,7 +1771,7 @@ vm_handle_db(struct vcpu *vcpu, struct vm_exit *vme, bool *retu) int error, fault; uint64_t rsp; uint64_t rflags; - struct vm_copyinfo copyinfo; + struct vm_copyinfo copyinfo[2]; *retu = true; if (!vme->u.dbg.pushf_intercept || vme->u.dbg.tf_shadow_val != 0) { @@ -1780,21 +1780,21 @@ vm_handle_db(struct vcpu *vcpu, struct vm_exit *vme, bool *retu) vm_get_register(vcpu, VM_REG_GUEST_RSP, &rsp); error = vm_copy_setup(vcpu, &vme->u.dbg.paging, rsp, sizeof(uint64_t), - VM_PROT_RW, ©info, 1, &fault); + VM_PROT_RW, copyinfo, nitems(copyinfo), &fault); if (error != 0 || fault != 0) { *retu = false; return (EINVAL); } /* Read pushed rflags value from top of stack. */ - vm_copyin(©info, &rflags, sizeof(uint64_t)); + vm_copyin(copyinfo, &rflags, sizeof(uint64_t)); /* Clear TF bit. */ rflags &= ~(PSL_T); /* Write updated value back to memory. */ - vm_copyout(&rflags, ©info, sizeof(uint64_t)); - vm_copy_teardown(©info, 1); + vm_copyout(&rflags, copyinfo, sizeof(uint64_t)); + vm_copy_teardown(copyinfo, nitems(copyinfo)); return (0); }