From nobody Mon Nov 23 04:34:26 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793976743; cv=none; d=zohomail.com; s=zohoarc; b=HarJxgLL/laTaWDtHUFHkX8o8XIGqlNTl0iyns8+YUbG/6ekMhdijZduCCsWFLKwtonE0qbr0euvS/jW2gvFmX/F6CRPP1cudEC/ieSiwzEh6RlYgg7WrB7fgK23kzEdMIWy1fkeQJijfafxOGGZDrdurPiyLLPgsvdgQTbqUMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793976743; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vznTLmH13jSN6b9wnsxqDutjisldxefqee0nkmHh/pg=; b=VnmUUAEN69iMuPn9dh5k09vvwMXXAduGPXCvmbyIPEFzxOiBwkddy7lNxowlotTXB4zklRycop8ABD+R/Zn1E9EnHUC5VqvxtSNdaNqiEq/69BczG/eitte5SUnaZ+DZmvUlfw9gPQRsgWjTS4r+JwJlZXBhiRsrU5CAu/UzJQE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793976743233646.4804375263261; Fri, 6 Nov 2026 06:52:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xPLIN-0002wH-1W; Fri, 06 Nov 2026 09:51:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xPLIL-0002vy-9n for qemu-devel@nongnu.org; Fri, 06 Nov 2026 09:51:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xPLIJ-0002Di-Hd for qemu-devel@nongnu.org; Fri, 06 Nov 2026 09:51:57 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-226-VscfiL02Mk6sRKqVoZywoQ-1; Fri, 06 Nov 2026 09:51:51 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 86C321955F08; Fri, 6 Nov 2026 14:51:49 +0000 (UTC) Received: from circe.redhat.com (unknown [10.44.32.31]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F3D321956087; Fri, 6 Nov 2026 14:51:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793976714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vznTLmH13jSN6b9wnsxqDutjisldxefqee0nkmHh/pg=; b=aKJsno1snXEEyey/ZBMKLJuB0U6CjtLMy2mXFq/oL8RetrY7YEXemiSeeUsPsui/uA4uS+ CrWBseDd7c5rnwxaLpxXa3999TelHr7QPpkNhfz/F8oFU9LP7Wh0v2E46qN9m/cLJHP3LN RIFcQrOfiVGEUGO/z5lMeMUw4dAeH5A= X-MC-Unique: VscfiL02Mk6sRKqVoZywoQ-1 X-Mimecast-MFC-AGG-ID: VscfiL02Mk6sRKqVoZywoQ_1793976710 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Shameer Kolothum , Nicolin Chen , Eric Auger Subject: [PATCH] vfio/region: Skip IOMMU mapping for BARs when dma-buf is unavailable Date: Fri, 6 Nov 2026 15:51:44 +0100 Message-ID: <20261106145144.1352917-1-clg@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793976744098158500 When the kernel does not support the VFIO_DEVICE_FEATURE_DMA_BUF feature (e.g. old kernel or out-of-tree vGPU driver), vfio_region_create_dma_buf() returns with a warning and no fd is assigned to the BAR RAMBlocks. Later, when the VFIO listener tries to DMA-map these BAR regions, the iommufd backend falls back to IOMMU_IOAS_MAP with a vaddr pointing at device MMIO. The kernel cannot pin device memory and fails with EFAULT on aarch64, producing these warnings: qemu-kvm: warning: VFIO dma-buf not supported in kernel, using mmap fallb= ack, P2P DMA will not work qemu-kvm: warning: IOMMU_IOAS_MAP failed: Bad address, PCI BAR? qemu-kvm: warning: vfio_container_dma_map(0xaaabb9621a90, 0x88400000000, = 0x10000, 0xfffe50100000) =3D -14 (Bad address) hostdev0: PCI peer-to-peer transactions on BARs are not supported. memory_region_set_skip_iommu_map() was recently introduced by commit 11b9798c7b52 ("memory: Allow RAM device regions to skip IOMMU mapping") for the Tegra CMDQV case. Use it to mark BAR mmap regions when dma-buf is unavailable so the VFIO listener skips them. This drops the last three messages and covers both the iommufd and legacy Type1 IOMMU backends. Cc: Shameer Kolothum Cc: Nicolin Chen Cc: Eric Auger Fixes: 8cfaf22668c7 ("hw/vfio/region: Create dmabuf for PCI BAR per region") Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/region.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/vfio/region.c b/hw/vfio/region.c index 996bc523edfe10bd256f5b09dec45cb5c9f543f0..4148d0ea8e35496e4c5a2bf97d1= ef6974df7ccbb 100644 --- a/hw/vfio/region.c +++ b/hw/vfio/region.c @@ -362,6 +362,9 @@ static bool vfio_region_create_dma_buf(VFIORegion *regi= on, Error **errp) if (ret =3D=3D -ENOTTY) { warn_report_once("VFIO dma-buf not supported in kernel, " "using mmap fallback, P2P DMA will not work"); + for (i =3D 0; i < region->nr_mmaps; i++) { + memory_region_set_skip_iommu_map(®ion->mmaps[i].mem, tr= ue); + } return true; } error_setg_errno(errp, -ret, "%s: dma-buf unavailable, " --=20 2.56.0