From nobody Sun Feb 8 19:59:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=me.com ARC-Seal: i=1; a=rsa-sha256; t=1627746131; cv=none; d=zohomail.com; s=zohoarc; b=C4u6oqfF+f1uYPf25LBOprhjczomlIsQJBMBOIlVWOPcmN44vYmTv9IP2fdhGHpZP+um42aCib1ulVx1RYRD3+jjH9noD2GCN8bwV0eFx8sATOiW6G/ly1evJEKk5vGkmKPwanFx6KA6hwB6yb0wIzLu+BArwT/aHMt7IbJn84A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627746131; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=31N1n9LDYN9v8O9cW+bYHTEiBlg9kNEUFPw10SV46Ag=; b=WCtGj4w+xiKL1/cXv5FRizFiRZmxFmfHGZDZIrddWtM8i4zlzemkskTm6IBvO+6x8xohopBgrPzP4KcZI6KNKf5pHwJsi5Kmm//SdlLPpr0r4+EUrZTXMo8N1QiFamhgjbULJKbkRG18+caA1N/26ir48nrz7j11gr5I/u2cBMw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1627746131010214.66865177851946; Sat, 31 Jul 2021 08:42:11 -0700 (PDT) Received: from localhost ([::1]:34770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9r7p-0003zv-09 for importer@patchew.org; Sat, 31 Jul 2021 11:42:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9r78-0003KG-9I for qemu-devel@nongnu.org; Sat, 31 Jul 2021 11:41:26 -0400 Received: from pv34p98im-ztdg02172101.me.com ([17.143.234.142]:56597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9r76-0005uF-O8 for qemu-devel@nongnu.org; Sat, 31 Jul 2021 11:41:26 -0400 Received: from smtpclient.apple (c-67-180-181-196.hsd1.ca.comcast.net [67.180.181.196]) by pv34p98im-ztdg02172101.me.com (Postfix) with ESMTPSA id 125615400D9 for ; Sat, 31 Jul 2021 15:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1627746078; bh=31N1n9LDYN9v8O9cW+bYHTEiBlg9kNEUFPw10SV46Ag=; h=From:Content-Type:Mime-Version:Subject:Message-Id:Date:To; b=L2NW/lwJlh/qdnQYoMKEv1YcHbafefWHS5jbYLbelImYdX2ZoBzL8c4mNS7bjlMr2 xJklueGVl1cTetgyKcEQt1141Vqe5+LFy8+Zh6eAuPkHK9ix/McHfSY2mo7i4JG/mM snbXFaVoewDYWFKAej5vcgJ29yC8QzRsYZCisXYpTlD9lRGBEuYIaxNXpDcQkAPGgt MWU1etTMsslgtNOOtQHVwpxUMk76Um1rRuN5thgtgtF5Lp4QS2kdWQerTCf7xyTftb MoseB9drKQJVFQz4IDsarAe+GQy5UFuu3nX17PgN+gFDHFhqu5W7ADjS+78aUwHMOU KILzon3TKQI/Q== From: Jason Thorpe Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3690.0.1\)) Subject: Please help me understand VIRTIO_F_IOMMU_PLATFORM Message-Id: Date: Sat, 31 Jul 2021 08:41:17 -0700 To: qemu-devel@nongnu.org X-Mailer: Apple Mail (2.3690.0.1) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-31_05:2021-07-30, 2021-07-31 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=317 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2009150000 definitions=main-2107310088 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=17.143.234.142; envelope-from=thorpej@me.com; helo=pv34p98im-ztdg02172101.me.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @me.com) X-ZM-MESSAGEID: 1627746132006100001 Content-Type: text/plain; charset="utf-8" Hey folks =E2=80=94 I=E2=80=99d like to be able to use VirtIO with qemu-system-alpha but, at le= ast on a NetBSD x86_64 host, it does not currently work. This is because v= irtio_bus_device_plugged() in hw/virtio/virtio-bus.c ends up picking addres= s_space_memory as the DMA address space for the VirtIODevice. This does no= t work for alpha because the CPU and PCI have different views of system mem= ory. All that=E2=80=99s needed to fix it is for virtio_bus_device_plugged(= ) to call klass->get_dma_as(qbus->parent), but the code only does that if: bool has_iommu =3D virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);=20 So, obviously, VIRTIO_F_IOMMU_PLATFORM is not getting set for an emulated a= lpha system, despite the alpha platform having one[*]. But it=E2=80=99s no= t clear to me that it=E2=80=99s appropriate for alpha to use VIRTIO_F_IOMMU= _PLATFORM, at least from my reading of how it=E2=80=99s used. In any case, the following extremely simple change allows me to use VirtIO = devices in qemu-system-alpha with a NetBSD/alpha guest (and I=E2=80=99m tol= d this also fixes using VirtIO devices in qemu-system-sparc64 for a NetBSD/= sparc64 guest): diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index 859978d248..c083e8d737 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -85,6 +85,8 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error = **errp) if (klass->get_dma_as !=3D NULL && has_iommu) { virtio_add_feature(&vdev->host_features, VIRTIO_F_IOMMU_PLATFORM); vdev->dma_as =3D klass->get_dma_as(qbus->parent); + } else if (klass->get_dma_as !=3D NULL) { + vdev->dma_as =3D klass->get_dma_as(qbus->parent); } else { vdev->dma_as =3D &address_space_memory; } So, VirtIO experts, please weigh in on the correctness of this change=E2=80= =A6 if it is, I=E2=80=99ll post the patch formally. [*] The way the alpha platform works is that the IOMMU is used if the PCI d= evice performs a memory access to a DMA window where SGMAPs are enabled. I= f SGMAPs are not enabled in the DMA window the PCI device is accessing, the= translation is performed directly by subtracting the address from the wind= ow=E2=80=99s Window Base and appending the result to the window=E2=80=99s T= ranslated Base. A typical alpha PCI platform has a 1GB DMA window at 1GB f= rom the PCI=E2=80=99s perspective, which maps to 0-1GB in the system addres= s map, and an alpha system with 1GB or less of RAM would thus not need to u= se the IOMMU, but the translation take place regardless. -- thorpej