From nobody Wed Oct 02 16:45:04 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 4XJgdr4RfMz5XmD0; Wed, 02 Oct 2024 16:45:04 +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 4XJgdr3fx5z4C98; Wed, 2 Oct 2024 16:45:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727887504; 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=n6PR1t2AMof/MB8bj0HA2FJjr9/p9bfuj674TCTAySQ=; b=EoLP6D+nJF768Tnp8mgHHQ0QKGNA3AOu87+aCPY0BXKze3Koo/o62secHu8O7CvAFRWfFc WyNsuR6HTYn0P3LkIR975p6DZNdUxzl4kBRsMI86UjG5VaeKhvuFRn5Pn/9hzuiLyIOJYQ 3uRRnJZi0LMWCGOydYpzCDnE+b+UjNAdQ8wRa4VeBWDqN7vau49KjqIQfEl4RQgaKWOFk9 FREXjWzuLF8zrR3JcldYZZsDuRWKJsxhbNRfyg8rX/Ft3Z0XF2PDKvojgaG5JDxiDQGlf7 c3+sXR4pS2nIMADBrV8bMFhCOG+JDowcu7acBw3fk+p1xrvAt6bZYXjEpFVnWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727887504; 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=n6PR1t2AMof/MB8bj0HA2FJjr9/p9bfuj674TCTAySQ=; b=P2Z2Co6VmjvTynTalpwcadPxl04fT+m+q3SN16RvCCVy3Lix2eV+K0EUn4xG8XQV1oGf3e /d8czal+irBUB3ngCy6ir6oSymoIGrZWqjVhGJBhmQae9cssbzMZZvVd4jaX2KI7FVX6EF Imlq/agkU+kZgJ7CAobwJN9TkMnP2jabTrEA6QBPnb6JfpBcSqob01c3rjI6Ya/5VxIg4X TtUNHTKb4z6EhjrBqNkaTwdsmMhJljSJgnbfrBQ0KUGDCwbulwV55ZtFkru5T53GkdZX4Z emxVOvhW9vMyLrjfJVs6Hd3HYh990MotccRAcRsjJ1kJv6f8bqnA1UqChbTZRg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727887504; a=rsa-sha256; cv=none; b=MOvdiKTLuO7dFjVaRQjrlgG2vhoZVQQ8Ro9KNNMCh+q4BIB6TJmvSFMR2O6UbfESsPO4jZ N/8W8dFvKnJC6W0iV6XG81EoYg0P0BI6ZAPfJyxI9eLyHsHMcrTejUn8rEQT5oxHsb0po4 IhxrHhRKJ2IN4lzOLjg65n678bdbmsd1mdZUCRYF35fIECx+EFvppYUjMyiAZ1+09fof4B qrGaENR/A+fRMqEI+ouNuCXcXVInID3C8iUysd2KcHD1WhwDKM0BhufnHeh0FpTpzegFJI 1EhUFGNmFtRDveNsAVBQ9O9YbCKjwrnfHGsCtpCTEhaXG+06Z5Ge4M6mBs7GvA== 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 4XJgdr3FdxzF05; Wed, 2 Oct 2024 16:45:04 +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 492Gj4rG035942; Wed, 2 Oct 2024 16:45:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 492Gj4Sb035939; Wed, 2 Oct 2024 16:45:04 GMT (envelope-from git) Date: Wed, 2 Oct 2024 16:45:04 GMT Message-Id: <202410021645.492Gj4Sb035939@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bojan =?utf-8?Q?Novkovi=C4=87?= Subject: git: 51fda658baa3 - main - 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: bnovkov X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 51fda658baa3f80c9778f3a9873fbf67df87119b Auto-Submitted: auto-generated The branch main has been updated by bnovkov: URL: https://cgit.FreeBSD.org/src/commit/?id=51fda658baa3f80c9778f3a9873fbf67df87119b commit 51fda658baa3f80c9778f3a9873fbf67df87119b Author: Bojan Novković AuthorDate: 2024-09-29 11:10:10 +0000 Commit: Bojan Novković CommitDate: 2024-10-02 16:43:36 +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 --- 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 a2c2b342bee4..5484d71cefd2 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -1795,7 +1795,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) { @@ -1804,21 +1804,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); }