From nobody Wed Mar 30 15:49:34 2022 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 4829A1A53D3A; Wed, 30 Mar 2022 15:49:35 +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 4KT9q318XBz3kBY; Wed, 30 Mar 2022 15:49:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648655375; 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=mZXOQcUiOUFtLMNEaXKE3BvrjfmzV0b9BL3EVlrnnu4=; b=bgz/pbzUQLagKyOElB9fu9Mjqg+lKjxifXqvokr1otiLU6TpqlI9bk23Mr2+zDNEktunx2 KlDNIMLXVJqDzT9hv9BRNq6NrinRQI6EZ/rsDpjUHlQfeP+WS131bVVcsn64vDgxQwkmws 7y3p6L+TCIk15qPq1Rx13Ts7zr2A569VKA9GRnXSih7dHn8fE4xXw779C8EJD62NK+Z+6A NvtB2a/+2nJjYW0cqEmUb/YzAF7/bcG6rR22otlF6BtW0L42kZryN4j5bJdl1Aw3qn/g5s gN7noX3Y47rtTuj36X5SrdfBcgHqKrgTI+gLcY+fqLAHtH2RpXZtkOsR+kU2rQ== 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 0821516114; Wed, 30 Mar 2022 15:49:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22UFnYmD019053; Wed, 30 Mar 2022 15:49:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22UFnYVM019052; Wed, 30 Mar 2022 15:49:34 GMT (envelope-from git) Date: Wed, 30 Mar 2022 15:49:34 GMT Message-Id: <202203301549.22UFnYVM019052@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 1c6abf864ecd - releng/13.1 - bhyve: Do not remove guest physical addresses from IOMMU host domain 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: bz X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.1 X-Git-Reftype: branch X-Git-Commit: 1c6abf864ecd3bbf07ace2018f9aab45b6406ce2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648655375; 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=mZXOQcUiOUFtLMNEaXKE3BvrjfmzV0b9BL3EVlrnnu4=; b=Ta5XMXL5+qY+FMauzeH8H3dJtsbX/Ef8S3VeDJbUR5sj/ne1o8T1KKzl5zABfJQ7YkWGGY XJOmmoEJRYFTi3bFW3173HbUe60cqbUvAggQKDx/yMH/wSiSUudx8ucMsfPEIeXENCUDpD E8afX0phJUgooupzjuzjGksJ66GRjxO/k5AZZ698/KOFz/s18PvCE7wzO4WppluzqY/tDQ WZjaiAqlLERLAxX1S/x1iq/1qLLqPCpsBIHcRjpX46EvwRlQWgxHxy6WmWB7FEwYKNk6nd XNI9uTaoYUQM3MP7+Wa4Oi0igHRU3HX6GGdf20O8jNeRGMOOh28gVt4PQbyBkg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648655375; a=rsa-sha256; cv=none; b=lpJ3AfHLpmYH1P6thi2GCkHVUkFWNiOzSfrdf0nKBjbzzXjfUxLh/cRFhzP2ytVeDto3NU SEwB3hR3FajJEQPuIR2mC5u4phjblyOWysWTi6qva1/0zdBHBzETuu7D4tm8fK6+jGW4c5 sXUxckhreq9X0bI1DbNep/vehF5LrALcTnFZukIextBov2CVQlDuAMt9DOVyKOeagA/IK6 +MiJOt/eVYf3Su2OpfOyWISk6f66LBTg7ZJaigB0jbOeyxoLq2eIoFmrPYCsBx6WmMgtME R4ExvcH/e6kBafcO5OOuwK0QUVZjq2/cofGgOXJPbCa87hPaqr1NHeg9O1X3TA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.1 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=1c6abf864ecd3bbf07ace2018f9aab45b6406ce2 commit 1c6abf864ecd3bbf07ace2018f9aab45b6406ce2 Author: Bjoern A. Zeeb AuthorDate: 2022-03-18 20:39:06 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-03-30 15:33:47 +0000 bhyve: Do not remove guest physical addresses from IOMMU host domain This permits I/O devices on the host to directly access wired memory dedicated to guests using passthru devices. Note that wired memory belonging to guests that do not use passthru devices has always been accessible by I/O devices on the host. bhyve maps guest physical addresses into the user address space of the bhyve process by mmap'ing /dev/vmm/. Device models pass pointers derived from this mapping directly to system calls such as preadv() to minimize copies when emulating DMA. If the backing store for a device model is a raw host device (e.g. when exporting a raw disk device such as /dev/ada as a drive in the guest), the host device driver (e.g. ahci for /dev/ada) can itself use DMA on the host directly to the guest's memory. However, if the guest's memory is not present in the host IOMMU domain, these DMA requests by the host device will fail without raising an error visible to the host device driver or to the guest resulting in non-working I/O in the guest. It is unclear why guest addresses were removed from the IOMMU host domain initially, especially only for VM's with a passthru device as the host IOMMU domain does not affect the permissions of passthru devices, only devices on the host. A considered alternative was using bounce buffers instead (D34535 is a proof of concept), but that adds additional overhead for unclear benefit. This solves a long-standing problem when using passthru devices and physical disks in the same VM. Approved by: re (gjb) Thanks to: grehan (patience and help) Thanks to: jhb (for improving the commit message) PR: 260178, 215740 Reviewed by: grehan, jhb Differential Revision: https://reviews.freebsd.org/D34607 (cherry picked from commit 246c398145674e4a9337fd933a6e6da7f160118e) (cherry picked from commit dd113f67dfb5bdaf5d8b3a87bb19924ad447494c) --- sys/amd64/vmm/vmm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index f0674784903f..5a5744a3fb16 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -938,10 +938,8 @@ vm_iommu_modify(struct vm *vm, bool map) hpa = DMAP_TO_PHYS((uintptr_t)vp); if (map) { iommu_create_mapping(vm->iommu, gpa, hpa, sz); - iommu_remove_mapping(host_domain, hpa, sz); } else { iommu_remove_mapping(vm->iommu, gpa, sz); - iommu_create_mapping(host_domain, hpa, hpa, sz); } gpa += PAGE_SIZE;