From nobody Sat Apr 5 07:15:18 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738244680; cv=none; d=zohomail.com; s=zohoarc; b=XhqkSgbjpe3EVdhRMNUPEv9Pwchv/vlWE82nsx0S8NOa8Ie3ug6sJTtkzd1d4qL926bef99BFf29rrF0OCDKwVESFspNSmr2Q4yXP38L+RwDA7nY9C7bwjLiaFRQdiSZJgIC+7t53bXwPulVyd9KNvgo5DRpah3fdQApOiAeW9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738244680; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=55ZBXel4IZrwYGquIHw+t8dMmO4wIp7lp1UiZQ+QE78=; b=OY44Cg2Lpm+1pcMEIJYWuYOR2+9DF9hCloBlfXXK6Y/0ZT7fTVqAr7Qt9zospA8xJ0A94bv7+VmB2tmzdna7bxXK2uZgOvmaRZiY7PIWIsFkMcqYGV45lFNmLF2KGQM/FP0r4BCW9giXEanteI56uSd2L2fMREH3C+CYOKKj18U= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738244680870780.2393971993349; Thu, 30 Jan 2025 05:44:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tdUpt-0000iQ-OM; Thu, 30 Jan 2025 08:44:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUpp-0000gx-Tr for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:43: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 1tdUpo-0003ON-IV for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:43:57 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-vXgtBc1dOdCa0Tsc2YXOgQ-1; Thu, 30 Jan 2025 08:43:54 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 304C71801F19 for ; Thu, 30 Jan 2025 13:43:53 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.105]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BF5A0180095D; Thu, 30 Jan 2025 13:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738244635; 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: in-reply-to:in-reply-to:references:references; bh=55ZBXel4IZrwYGquIHw+t8dMmO4wIp7lp1UiZQ+QE78=; b=PD8pA13fWVJlPiGdAPEaLmNTFLDMMuJi685WUur0mhqbGQd7owS7WsIPlsC+QxuTsaknYR ZbV1U1cWu/eO768bn56C6c69V+5PmUOedg/feIWHbMjIZdDF6W5QjRaH1H3sUlbJjdzrK5 4ZruzdxA7Q/ohwcpHqK5BEpsZl4la4E= X-MC-Unique: vXgtBc1dOdCa0Tsc2YXOgQ-1 X-Mimecast-MFC-AGG-ID: vXgtBc1dOdCa0Tsc2YXOgQ From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Markus Armbruster Subject: [PATCH v2 1/9] util/error: Introduce warn_report_once_err() Date: Thu, 30 Jan 2025 14:43:38 +0100 Message-ID: <20250130134346.1754143-2-clg@redhat.com> In-Reply-To: <20250130134346.1754143-1-clg@redhat.com> References: <20250130134346.1754143-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.4.1 on 10.30.177.111 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=170.10.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.3, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1738244682056019000 Depending on the configuration, a passthrough device may produce recurring DMA mapping errors at runtime and produce a lot of output. It is useful to report only once. Cc: Markus Armbruster Signed-off-by: C=C3=A9dric Le Goater --- include/qapi/error.h | 5 +++++ util/error.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/include/qapi/error.h b/include/qapi/error.h index 71f8fb2c50eee9a544992d0c05263c9793956fe1..b6ea274882b9788b64d4bb213c3= 458d7c674a881 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -448,6 +448,11 @@ void error_free_or_abort(Error **errp); */ void warn_report_err(Error *err); =20 +/* + * Convenience function to call warn_report_err() once. + */ +void warn_report_once_err(Error *err); + /* * Convenience function to error_report() and free @err. * The report includes hints added with error_append_hint(). diff --git a/util/error.c b/util/error.c index e5e247209a9e0796074a9794f5598325f22f8d35..b8a211cccaa609a93091b863161= 44a0ad0a02662 100644 --- a/util/error.c +++ b/util/error.c @@ -247,6 +247,15 @@ void warn_report_err(Error *err) error_free(err); } =20 +void warn_report_once_err(Error *err) +{ + static bool print_once_; + if (!print_once_) { + warn_report_err(err); + print_once_ =3D true; + } +} + void error_reportf_err(Error *err, const char *fmt, ...) { va_list ap; --=20 2.48.1 From nobody Sat Apr 5 07:15:18 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738244680; cv=none; d=zohomail.com; s=zohoarc; b=YMwf+SrrnO5kv/m0EjLBuTtVZmLqVERnhrOkRUvXbpmJgxurbO1XIYWofyAOeviHggvntT4jmiFE1gfTjUyAdLhP0Eoxp3wyqV3GjBFaoYEPZK/b0VbxEd6ABjJmdMVXDSyl/HpGCWk6fkLiOqof+AtLm7jBTFFZhKOYHjoNu/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738244680; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dhIXdP5ewttDRmMW/3WbMTREMdAne2w8TJDIC/YRI2o=; b=RVnnFexGp5tLspIOhOYIW/WEpRagH9+zbYL0e0T8ZpJiWnZdEeZsx2USOMAPMfRNu2hItt0pquFnRJIgtTfSmAnaozsg7m5CwvGP962IY+H6AENfMwgfPC/cC04P2RmhqXgNnN1anr2Q6xOyiwNagKqf+54G2xTEODA/P2kykwo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173824468083181.66526451243703; Thu, 30 Jan 2025 05:44:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tdUpu-0000iT-4k; Thu, 30 Jan 2025 08:44:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUps-0000hk-38 for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:00 -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 1tdUpq-0003Ok-H5 for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:43:59 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-338-u806i-7wOI2X6etd53TN5g-1; Thu, 30 Jan 2025 08:43:55 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CEF1318009D1 for ; Thu, 30 Jan 2025 13:43:54 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.105]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9C9681800951; Thu, 30 Jan 2025 13:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738244638; 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: in-reply-to:in-reply-to:references:references; bh=dhIXdP5ewttDRmMW/3WbMTREMdAne2w8TJDIC/YRI2o=; b=Uso09BTJ8Pk4+f3aiacDaR4FwyQviGkcYMnTf0HYF12/80FVv4WpQNQlGDvpUC++3mLH5i 7ESSuX7PqDu06zrjqPj+MJ76dj+jM/BtMfzEhJr3DZ0HSqMiSiW7vn8FBsjbbItAVsYA3y QtqmQiIl6jsYQT1+f6rNhJGRQsQMGdQ= X-MC-Unique: u806i-7wOI2X6etd53TN5g-1 X-Mimecast-MFC-AGG-ID: u806i-7wOI2X6etd53TN5g From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 2/9] vfio/pci: Replace "iommu_device" by "vIOMMU" Date: Thu, 30 Jan 2025 14:43:39 +0100 Message-ID: <20250130134346.1754143-3-clg@redhat.com> In-Reply-To: <20250130134346.1754143-1-clg@redhat.com> References: <20250130134346.1754143-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.4.1 on 10.30.177.111 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=170.10.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.3, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1738244681994019000 This is to be consistent with other reported errors related to vIOMMU devices. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/vfio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 1b90c78c5a1927b1553c59de7a470544bc07788a..90570e9e4ee571d3ec5a7f7b302= b1e7e7f0c9a33 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3116,7 +3116,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) =20 if (!vbasedev->mdev && !pci_device_set_iommu_device(pdev, vbasedev->hiod, errp)) { - error_prepend(errp, "Failed to set iommu_device: "); + error_prepend(errp, "Failed to set vIOMMU: "); goto out_teardown; } =20 --=20 2.48.1 From nobody Sat Apr 5 07:15:18 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738244753; cv=none; d=zohomail.com; s=zohoarc; b=AtllWWK54zPuoV5EVBdLYrfJOJPICT12Got/Tna/sSQuzlldtauMPkzluOOEuo/wcfgRqO9Hh0M5J55ZPeZSX3j63QBL7ywPTfkAXmdjTyGh+hhclGtXE3337z5wTUpwQOgNQFKlmnTRSzVElPTUGNhY4tpYyplo5ITF8EHHKbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738244753; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=08fbyKhZ36Cf9CIMyEWusAbI9TdQnp+cgrMz0jjM9ZM=; b=YmAe35jyNvBlRecL8HkDsQDun2bywrP8XkpAT6YCtTZlmRVaOZBFgy/tYJllQtXNTaeguV8dLr5I6VRy00tz3Vzvb750tPrZdOEycZGrooKOz/+F7guc1cw7L6qfI/zFUYWPnS3St1278V0eg7lEdNB4BqUNhP+XiyHVA3pNXe0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738244749530826.6457853594292; Thu, 30 Jan 2025 05:45:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tdUpv-0000j7-0Q; Thu, 30 Jan 2025 08:44:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUps-0000iB-Ql for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUpr-0003Or-CZ for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:00 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-445-qrhIDAVkM62v1XSG83Q1JQ-1; Thu, 30 Jan 2025 08:43:57 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6F4F8180034D for ; Thu, 30 Jan 2025 13:43:56 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.105]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 46F981800965; Thu, 30 Jan 2025 13:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738244638; 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: in-reply-to:in-reply-to:references:references; bh=08fbyKhZ36Cf9CIMyEWusAbI9TdQnp+cgrMz0jjM9ZM=; b=Xa02KnfBQIaz2C4kJhyl6x6bUjLCQ3wHWdhx/iVVUSFxUWHyTt6PV8di7brSlsIIGwmwIZ j+aCv1VTbDj8QsWaaT0m8UWSEDjozL6wcvBVR1USXLkxPnccZnlX56mCqBHZTnjIKxlloW JIyeUtZe4kzfqJPC7afBPuEYjfxBv/0= X-MC-Unique: qrhIDAVkM62v1XSG83Q1JQ-1 X-Mimecast-MFC-AGG-ID: qrhIDAVkM62v1XSG83Q1JQ From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 3/9] vfio: Rephrase comment in vfio_listener_region_add() error path Date: Thu, 30 Jan 2025 14:43:40 +0100 Message-ID: <20250130134346.1754143-4-clg@redhat.com> In-Reply-To: <20250130134346.1754143-1-clg@redhat.com> References: <20250130134346.1754143-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.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.3, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1738244756728019000 Rephrase a bit the ending comment about how errors are handled depending on the phase in which vfio_listener_region_add() is called. Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/common.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index f7499a9b7447a7593198e1523c50858b70a8bd85..62af1216fc5a9089fc718c2afe3= a405d9381db32 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -683,12 +683,13 @@ fail: error_reportf_err(err, "PCI p2p may not work: "); return; } - /* - * On the initfn path, store the first error in the container so we - * can gracefully fail. Runtime, there's not much we can do other - * than throw a hardware error. - */ + if (!bcontainer->initialized) { + /* + * At machine init time or when the device is attached to the + * VM, store the first error in the container so we can + * gracefully fail the device realize routine. + */ if (!bcontainer->error) { error_propagate_prepend(&bcontainer->error, err, "Region %s: ", @@ -697,6 +698,10 @@ fail: error_free(err); } } else { + /* + * At runtime, there's not much we can do other than throw a + * hardware error. + */ error_report_err(err); hw_error("vfio: DMA mapping failed, unable to continue"); } --=20 2.48.1 From nobody Sat Apr 5 07:15:18 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738244707; cv=none; d=zohomail.com; s=zohoarc; b=kYXYBnwhCFoEUjMZeuyZn4uzkBiEQVYaX0k9rZeG3tVzZp4kGrbDKFbivKIMcbRoxQbMCpSwdgyIXnliG9NuiNjADoAD3JpXDDNuhO7OF5PMCNPM9V9O79eVs9bJCOZfUpLcSJ3iP6GGnmB1Sj+9xMANFLdx3UIUJSjRl2IXqxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738244707; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Q3oJ/f2lYBy+mVYg+gP8Eo/xbAj6TYb489HgxZY98qM=; b=K2+FG4GnqeTUqLpRpUI6SiAFLGePJc1fjgEituEafAGeoc2Q5r6QbDlN/xcArNeEI96Bd1KP3j/XhnOsMOE+rhQOlrDuvNFujSzRiAs/7kzY34ZmL4JetNrpVLS7t3FJoo4BcN7lBeoubXkwWfTP7ryK1w2vT45nCWpK5c8Alf4= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738244707182306.25559385195857; Thu, 30 Jan 2025 05:45:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tdUq5-0000n5-1i; Thu, 30 Jan 2025 08:44:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUq4-0000mO-Bh for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUpv-0003PH-8R for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:12 -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-553-YmdxIYXZP2aBWhXDPmbUxg-1; Thu, 30 Jan 2025 08:43:58 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 10EB11956080 for ; Thu, 30 Jan 2025 13:43:58 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.105]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DBBFD1800955; Thu, 30 Jan 2025 13:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738244642; 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: in-reply-to:in-reply-to:references:references; bh=Q3oJ/f2lYBy+mVYg+gP8Eo/xbAj6TYb489HgxZY98qM=; b=XMTdlCcF+m84gYqj7UhPBg+viNlgzRAketvb5CtRQ80hWuUpGI1ZGjei4/NTSprLU0sKKT JPAX4SMkdn7LOYzW895QKxfYgzRiVvCuOwqIV3V/ghwcZ/kjspz8fsEhjSMaSZXJLY6tnk IQHxoZCV5RPu+Crut9nb3j+U1BMtI7I= X-MC-Unique: YmdxIYXZP2aBWhXDPmbUxg-1 X-Mimecast-MFC-AGG-ID: YmdxIYXZP2aBWhXDPmbUxg From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 4/9] vfio: Introduce vfio_get_vfio_device() Date: Thu, 30 Jan 2025 14:43:41 +0100 Message-ID: <20250130134346.1754143-5-clg@redhat.com> In-Reply-To: <20250130134346.1754143-1-clg@redhat.com> References: <20250130134346.1754143-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.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.3, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1738244710247019000 This helper will be useful in the listener handlers to extract the VFIO device from a memory region using memory_region_owner(). At the moment, we only care for PCI passthrough devices. If the need arises, we will add more. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 1 + hw/vfio/helpers.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 0c60be5b15c70168f4f94ad7054d9bd750a162d3..ac35136a11051b079cd9d04e6be= cd344a0e0f7e7 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -252,6 +252,7 @@ bool vfio_device_hiod_realize(VFIODevice *vbasedev, Err= or **errp); bool vfio_attach_device(char *name, VFIODevice *vbasedev, AddressSpace *as, Error **errp); void vfio_detach_device(VFIODevice *vbasedev); +VFIODevice *vfio_get_vfio_device(Object *obj); =20 int vfio_kvm_device_add_fd(int fd, Error **errp); int vfio_kvm_device_del_fd(int fd, Error **errp); diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 913796f437f84eece8711cb4b4b654a44040d17c..4b255d4f3a9e81f55df00c68fc7= 1da769fd5bd04 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -23,6 +23,7 @@ #include =20 #include "hw/vfio/vfio-common.h" +#include "hw/vfio/pci.h" #include "hw/hw.h" #include "trace.h" #include "qapi/error.h" @@ -728,3 +729,12 @@ bool vfio_device_hiod_realize(VFIODevice *vbasedev, Er= ror **errp) =20 return HOST_IOMMU_DEVICE_GET_CLASS(hiod)->realize(hiod, vbasedev, errp= ); } + +VFIODevice *vfio_get_vfio_device(Object *obj) +{ + if (object_dynamic_cast(obj, TYPE_VFIO_PCI)) { + return &VFIO_PCI(obj)->vbasedev; + } else { + return NULL; + } +} --=20 2.48.1 From nobody Sat Apr 5 07:15:18 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738244723; cv=none; d=zohomail.com; s=zohoarc; b=WnEm3CUaiNSefvcJp+1J4G/tEfwIAhCZjCIehDx2KDEfUrfFRz6cxap0oBM8TAStF7E2DLDgznUXMTah/Dmig1x92bTJrGfnfUtgi857nb8X396IIT85RgidfDMdfnykuiKF1NblVBVq3Nry2Uu/lncoMP7oII4GmqQitTWGB5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738244723; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LhYwL2n7iaraT9zUn/a63GO+IkCmCBew8nfdwsIZCkg=; b=T9TQY3zZREILNrR7dQKZPBinvqzk2BdDcTex8LvQ3GLX7T62uScNRJ6SaKu+ag4zyJhVtQ4LGR6gM0pxlmq7mA8xeQ95wTt9OiQGwPELqUBrR3FTKqk9vyEiOkf6NYWtq9rb9FSHX1MR+wALlhTOTDeEY/00Y3t8Mltp8tbEKn4= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738244723805167.52040642594648; Thu, 30 Jan 2025 05:45:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tdUpy-0000ke-2W; Thu, 30 Jan 2025 08:44:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUpw-0000jq-Em for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:04 -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 1tdUpu-0003PF-V9 for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:04 -0500 Received: from mx-prod-mc-01.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-404-84Dtiu2wNemYculPZyky3Q-1; Thu, 30 Jan 2025 08:44:00 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BE34019560B8 for ; Thu, 30 Jan 2025 13:43:59 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.105]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 95329180035D; Thu, 30 Jan 2025 13:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738244642; 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: in-reply-to:in-reply-to:references:references; bh=LhYwL2n7iaraT9zUn/a63GO+IkCmCBew8nfdwsIZCkg=; b=jBfH/daZb4DkosGZB7+Mr5Ptf5pHfi8zOXStKx8z8qnfju51kEvkwbG8ka5JOc4egM5RYt UHlfTE2ICck37SBl+yUrFQ5fS8SFthxHbskWNl6BTh31Yq8584dRIGXMjfo+Kiyoh6MVnf UNS/6qsTZOP49tEGDQsfyyemvlQb6Kk= X-MC-Unique: 84Dtiu2wNemYculPZyky3Q-1 X-Mimecast-MFC-AGG-ID: 84Dtiu2wNemYculPZyky3Q From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 5/9] vfio: Improve error reporting when MMIO region mapping fails Date: Thu, 30 Jan 2025 14:43:42 +0100 Message-ID: <20250130134346.1754143-6-clg@redhat.com> In-Reply-To: <20250130134346.1754143-1-clg@redhat.com> References: <20250130134346.1754143-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.4.1 on 10.30.177.111 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=170.10.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.3, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1738244724407019000 When the IOMMU address space width is smaller than the physical address width, a MMIO region of a device can fail to map because the region is outside the supported IOVA ranges of the VM. In this case, PCI peer-to-peer transactions on BARs are not supported. This can occur with the 39-bit IOMMU address space width, as can be the case on some consumer processors or when using a vIOMMU device with default settings. The current error message is unclear, also change the error report to a warning because it is a non fatal condition for the VM. Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/common.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 62af1216fc5a9089fc718c2afe3a405d9381db32..5c9d8657d746ce30af5ae8f9122= 101e086a61ef5 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -555,6 +555,18 @@ static bool vfio_get_section_iova_range(VFIOContainerB= ase *bcontainer, return true; } =20 +static void vfio_device_error_append(VFIODevice *vbasedev, Error **errp) +{ + /* + * MMIO region mapping failures are not fatal but in this case PCI + * peer-to-peer transactions are broken. + */ + if (vbasedev && vbasedev->type =3D=3D VFIO_DEVICE_TYPE_PCI) { + error_append_hint(errp, "%s: PCI peer-to-peer transactions " + "on BARs are not supported.\n", vbasedev->name); + } +} + static void vfio_listener_region_add(MemoryListener *listener, MemoryRegionSection *section) { @@ -670,7 +682,10 @@ static void vfio_listener_region_add(MemoryListener *l= istener, strerror(-ret)); if (memory_region_is_ram_device(section->mr)) { /* Allow unexpected mappings not to be fatal for RAM devices */ - error_report_err(err); + VFIODevice *vbasedev =3D + vfio_get_vfio_device(memory_region_owner(section->mr)); + vfio_device_error_append(vbasedev, &err); + warn_report_once_err(err); return; } goto fail; --=20 2.48.1 From nobody Sat Apr 5 07:15:18 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738244673; cv=none; d=zohomail.com; s=zohoarc; b=Vp/wX+CBlEggck0NLBZL1H0kb+WbHaXVm/N9jWkZQWEtWwl4yzpZh2EFxJLxkT3PN0qx5KT5yNprFMekPigfhhjytVxWGG7+vttOgpNN2uU+jxEWa6qlxuG3rxe2plKPCqpROUMjnHYNtDG8+oZbIgI+cLEwTfED1tdpWgcah3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738244673; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Bwhtrf/IqVukYzy60jBSosvRZjQVAPipjIn+1Rn7vhk=; b=d9kRTUG6G+S+OZACf3vefdjwHHG5jiCZk6iWe6pJbe/VsNCvRQhEJDXpN4u3GiSqFJAplFNET2LlS+1ljpuNY2HqW1tJPjGmRPNsjJNcA0QgiIn9HMQruFdr06EgaiGaGMAsxKDHocWIYwcrxelPORF8EmBWqlEXSsUf7tx/PME= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738244673849761.4802434982388; Thu, 30 Jan 2025 05:44:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tdUq2-0000m1-DE; Thu, 30 Jan 2025 08:44:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUq0-0000lE-Pk for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:08 -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 1tdUpz-0003Pd-8X for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:08 -0500 Received: from mx-prod-mc-02.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-556-DRnqIdWfNS2wYzw0yqAGZQ-1; Thu, 30 Jan 2025 08:44:03 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 603201955F2D for ; Thu, 30 Jan 2025 13:44:01 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.105]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3564C1800951; Thu, 30 Jan 2025 13:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738244646; 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: in-reply-to:in-reply-to:references:references; bh=Bwhtrf/IqVukYzy60jBSosvRZjQVAPipjIn+1Rn7vhk=; b=F69vXlyMSaevK5Dbfvhh/Pnhx6SWYkLaC62CPqJTpyHCCD3Hh8yPOKdnwF9oAr8nbXDwRs qC0SZ3Ci8TDW7i66I76tRzw+fUGG1YNQfV8+btOwjTF9OrNtxFuZpGIsjobSDOWeX0VxMw i0Wrp39Sdq6aSRfqYRY2ELPg87s+QG0= X-MC-Unique: DRnqIdWfNS2wYzw0yqAGZQ-1 X-Mimecast-MFC-AGG-ID: DRnqIdWfNS2wYzw0yqAGZQ From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 6/9] vfio: Remove reports of DMA mapping errors in backends Date: Thu, 30 Jan 2025 14:43:43 +0100 Message-ID: <20250130134346.1754143-7-clg@redhat.com> In-Reply-To: <20250130134346.1754143-1-clg@redhat.com> References: <20250130134346.1754143-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.4.1 on 10.30.177.111 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=170.10.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.3, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1738244676569019000 Currently, the IOMMU backend, VFIO IOMMU Type 1 aka. legacy and IOMMUFD, mapping handlers return an errno and also report an error. This can produce a lot of output at runtime for recurring DMA mapping errors and is redundant with the errors reported by the callers in vfio_container_dma_un/map() routines. Simply remove to let the callers handle the error. The mapping handler of the IOMMUFD backend has a comment suggesting MMIO region mapping failures return EFAULT. I am not sure this is entirely true, so keep the EFAULT case until the conditions are clarified. Signed-off-by: C=C3=A9dric Le Goater --- backends/iommufd.c | 3 --- hw/vfio/container.c | 2 -- 2 files changed, 5 deletions(-) diff --git a/backends/iommufd.c b/backends/iommufd.c index 7b4fc8ec460ef635b9ed5ac7b201f124476b512a..d57da44755be3d7fdba74f7dbec= fe6d1c89921ba 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -167,8 +167,6 @@ int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_= t ioas_id, hwaddr iova, /* TODO: Not support mapping hardware PCI BAR region for now. */ if (errno =3D=3D EFAULT) { warn_report("IOMMU_IOAS_MAP failed: %m, PCI BAR?"); - } else { - error_report("IOMMU_IOAS_MAP failed: %m"); } } return ret; @@ -203,7 +201,6 @@ int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint3= 2_t ioas_id, =20 if (ret) { ret =3D -errno; - error_report("IOMMU_IOAS_UNMAP failed: %m"); } return ret; } diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 4ebb5268088d0a2006e0ed04afec0ee746ed2c1d..7c57bdd27b72731db5cf4f9446d= 954e143b4747e 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -159,7 +159,6 @@ static int vfio_legacy_dma_unmap(const VFIOContainerBas= e *bcontainer, unmap.size -=3D 1ULL << ctz64(bcontainer->pgsizes); continue; } - error_report("VFIO_UNMAP_DMA failed: %s", strerror(errno)); return -errno; } =20 @@ -204,7 +203,6 @@ static int vfio_legacy_dma_map(const VFIOContainerBase = *bcontainer, hwaddr iova, return 0; } =20 - error_report("VFIO_MAP_DMA failed: %s", strerror(errno)); return -errno; } =20 --=20 2.48.1 From nobody Sat Apr 5 07:15:18 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738246141; cv=none; d=zohomail.com; s=zohoarc; b=TkEiVXW33LdOP8de9WBsGz+c9EF5krvxPljkpAE3twA8tCwqDq0YyvQrh82HGJnLITSzdA+wnM9+P7DurMvbzI6rF0fJcl+Z2iU0aFOeKwAi2bDDdcRhfItVvL2t3542+MeY7nTebDmdGOdA38SDbxOsjkeLMxeOlGKUFZAu9BE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738246141; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uc9G9aeAGfHn2OUicVdP0JeeDtL9D3T72qdTSgdZmY8=; b=CZxB5S/+zf2u/Q0RnTySS6TV5TA6Ero17YhPDdv8rbKMwcF1fTvzzxX9h0GJ1t6teMqMyMjowIo+KTfElEiFlfobmDNH5WAhKkpieRYQ7f3BVap8JECGLhJ5Z5At10A75isWYDUBfnpj8WGgukT1ZExKnuuBGPrmxspN4Zot9yI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738246138323204.46060073111005; Thu, 30 Jan 2025 06:08:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tdUq6-0000o3-K3; Thu, 30 Jan 2025 08:44:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUq4-0000mb-Si for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUq2-0003Qk-3E for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:12 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-473-V1reARLCP1eQPGxQZu_a4Q-1; Thu, 30 Jan 2025 08:44:06 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B737E18009D5; Thu, 30 Jan 2025 13:44:04 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.105]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CAE961800951; Thu, 30 Jan 2025 13:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738244649; 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: in-reply-to:in-reply-to:references:references; bh=uc9G9aeAGfHn2OUicVdP0JeeDtL9D3T72qdTSgdZmY8=; b=f8gRZsP/dRla5TTy4UU+k9Vjq+GKnv2KPzrVp2PtIn4hssxu4IFAhfO5qMZHb+mnTbGWFZ 1ygUngbTTb5RsP9Ybcu4GxOEMEUN+EfD6kVQYl1hsPpbWxjuukC+jbE85BMn6x/gaqgbbB x+ULDWH4wti4xx5HTeFOMcMdnHNn4QA= X-MC-Unique: V1reARLCP1eQPGxQZu_a4Q-1 X-Mimecast-MFC-AGG-ID: V1reARLCP1eQPGxQZu_a4Q From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Richard Henderson , Paolo Bonzini , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Zhao Liu Subject: [PATCH v2 7/9] cpu: Introduce cpu_get_phys_bits() Date: Thu, 30 Jan 2025 14:43:44 +0100 Message-ID: <20250130134346.1754143-8-clg@redhat.com> In-Reply-To: <20250130134346.1754143-1-clg@redhat.com> References: <20250130134346.1754143-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.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.3, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1738246144917019000 The Intel CPU has a complex history regarding setting of the physical address space width on KVM. A 'phys_bits' field and a "phys-bits" property were added by commit af45907a1328 ("target-i386: Allow physical address bits to be set") to tune this value. In certain circumstances, it is interesting to know this value to check that all the conditions are met for optimal operation. For instance, when the system has a 39-bit IOMMU address space width and a larger CPU physical address space, we expect issues when mapping the MMIO regions of passthrough devices and it would good to report to the user. These hybrid HW configs can be found on some consumer grade processors or when using a vIOMMU device with default settings. For this purpose, add an helper routine and a CPUClass callback to return the physical address space width of a CPU. Cc: Richard Henderson Cc: Paolo Bonzini Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: "Philippe Mathieu-Daud=C3=A9" Cc: Yanan Wang Cc: Zhao Liu Signed-off-by: C=C3=A9dric Le Goater --- include/hw/core/cpu.h | 9 +++++++++ include/hw/core/sysemu-cpu-ops.h | 6 ++++++ cpu-target.c | 5 +++++ hw/core/cpu-system.c | 11 +++++++++++ target/i386/cpu.c | 6 ++++++ 5 files changed, 37 insertions(+) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index fb397cdfc53d12d40d3e4e7f86251fc31c48b9f6..1b3eead102ce62fcee55ab0ed5e= 0dff327fa2fc5 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -748,6 +748,14 @@ int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs att= rs); */ bool cpu_virtio_is_big_endian(CPUState *cpu); =20 +/** + * cpu_get_phys_bits: + * @cpu: CPU + * + * Return the physical address space width of the CPU @cpu. + */ +uint32_t cpu_get_phys_bits(const CPUState *cpu); + #endif /* CONFIG_USER_ONLY */ =20 /** @@ -1168,6 +1176,7 @@ void cpu_exec_unrealizefn(CPUState *cpu); void cpu_exec_reset_hold(CPUState *cpu); =20 const char *target_name(void); +uint32_t target_phys_bits(void); =20 #ifdef COMPILING_PER_TARGET =20 diff --git a/include/hw/core/sysemu-cpu-ops.h b/include/hw/core/sysemu-cpu-= ops.h index 0df5b058f50073e47d2a6b8286be5204776520d2..210b3ed57985525795b81559e41= e0085969210d5 100644 --- a/include/hw/core/sysemu-cpu-ops.h +++ b/include/hw/core/sysemu-cpu-ops.h @@ -81,6 +81,12 @@ typedef struct SysemuCPUOps { */ bool (*virtio_is_big_endian)(CPUState *cpu); =20 + /** + * @get_phys_bits: Callback to return the physical address space + * width of a CPU. + */ + uint32_t (*get_phys_bits)(const CPUState *cpu); + /** * @legacy_vmsd: Legacy state for migration. * Do not use in new targets, use #DeviceClass::vmsd ins= tead. diff --git a/cpu-target.c b/cpu-target.c index 667688332c929aa53782c94343def34571272d5f..88158272c06cc42424d435b9701= e33735f080239 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -472,3 +472,8 @@ const char *target_name(void) { return TARGET_NAME; } + +uint32_t target_phys_bits(void) +{ + return TARGET_PHYS_ADDR_SPACE_BITS; +} diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c index 6aae28a349a7a377d010ff9dcab5ebc29e1126ca..05067d84f4258facf4252216f17= 729e390d38eae 100644 --- a/hw/core/cpu-system.c +++ b/hw/core/cpu-system.c @@ -60,6 +60,17 @@ hwaddr cpu_get_phys_page_attrs_debug(CPUState *cpu, vadd= r addr, return cc->sysemu_ops->get_phys_page_debug(cpu, addr); } =20 +uint32_t cpu_get_phys_bits(const CPUState *cpu) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + if (cc->sysemu_ops->get_phys_bits) { + return cc->sysemu_ops->get_phys_bits(cpu); + } + + return target_phys_bits(); +} + hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr) { MemTxAttrs attrs =3D {}; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b5dd60d2812e0c3d13c1743fd485a9068ab29c4f..01cf9a44963710a415c755c1758= 2730f75233143 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -8393,6 +8393,11 @@ static bool x86_cpu_get_paging_enabled(const CPUStat= e *cs) =20 return cpu->env.cr[0] & CR0_PG_MASK; } + +static uint32_t x86_cpu_get_phys_bits(const CPUState *cs) +{ + return X86_CPU(cs)->phys_bits; +} #endif /* !CONFIG_USER_ONLY */ =20 static void x86_cpu_set_pc(CPUState *cs, vaddr value) @@ -8701,6 +8706,7 @@ static const struct SysemuCPUOps i386_sysemu_ops =3D { .get_memory_mapping =3D x86_cpu_get_memory_mapping, .get_paging_enabled =3D x86_cpu_get_paging_enabled, .get_phys_page_attrs_debug =3D x86_cpu_get_phys_page_attrs_debug, + .get_phys_bits =3D x86_cpu_get_phys_bits, .asidx_from_attrs =3D x86_asidx_from_attrs, .get_crash_info =3D x86_cpu_get_crash_info, .write_elf32_note =3D x86_cpu_write_elf32_note, --=20 2.48.1 From nobody Sat Apr 5 07:15:18 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738244702; cv=none; d=zohomail.com; s=zohoarc; b=flf1BrdcqPlVLHUbaTQ7HgfstXzCuT1EF2MYUjhJ6E5V1zB1cQsGsyrk2eh9CxFzJ9MYHyZCar9CKbZfj3LE1jSMgtt5QiXsyuB3s+qKieoLOG2/2ORamOIv4NPe8Co9hwkEMegptkQF86NhzFTZ1DA5qqP6CuuqZKdMBHg/UfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738244702; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FM1aV6MzsAqHFjNF3oHXP4B1XEDixjmcvXIfFMNaGSU=; b=O21UCFW5WX1pEf2MQnOXrn62xSyKl6X8ynkSuAGFXMRLdkDl6T0lkmZBR0TpBj6PsT2hhDbjI8p4HThuWymULAaf8+74uJH6L5k7EmCQQNONhQX15pBFE95qaD/fgW6bzGbe5z0YgVjz6nzWz0e3mRjjJXL+4oxK0iGk/MXFvQc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738244702963555.0687637522302; Thu, 30 Jan 2025 05:45:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tdUq5-0000nb-R3; Thu, 30 Jan 2025 08:44:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUq3-0000mF-G7 for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:11 -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 1tdUq1-0003Qi-SL for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:11 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-DhHiTB77M7myqCZuTRfLqA-1; Thu, 30 Jan 2025 08:44:07 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 745D81801F0E for ; Thu, 30 Jan 2025 13:44:06 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.105]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2E834180096D; Thu, 30 Jan 2025 13:44:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738244649; 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: in-reply-to:in-reply-to:references:references; bh=FM1aV6MzsAqHFjNF3oHXP4B1XEDixjmcvXIfFMNaGSU=; b=IhgtTR+S5ogZ7eP8uhvN9AJr0Dz60GzPpjNsgFqBgyai3a9rYPI90JsHUpAnld+ID8SZ46 5ma/Majr6QpDCFykklunWGRvAuG+xjjR2Lqg9VAfyCdz4/45MbjqLWK20YwHsxBRGzU2V0 gWK0cP7okPjUEPHgFwhb0Zof6nb5bZ0= X-MC-Unique: DhHiTB77M7myqCZuTRfLqA-1 X-Mimecast-MFC-AGG-ID: DhHiTB77M7myqCZuTRfLqA From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 8/9] vfio: Check compatibility of CPU and IOMMU address space width Date: Thu, 30 Jan 2025 14:43:45 +0100 Message-ID: <20250130134346.1754143-9-clg@redhat.com> In-Reply-To: <20250130134346.1754143-1-clg@redhat.com> References: <20250130134346.1754143-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.4.1 on 10.30.177.111 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=170.10.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.3, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1738244704206019000 Print a warning if IOMMU address space width is smaller than the physical address width. In this case, PCI peer-to-peer transactions on BARs are not supported and failures of device MMIO regions are to be expected. This can occur with the 39-bit IOMMU address space width as found on consumer grade processors or when using a vIOMMU device with default settings. Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/common.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 5c9d8657d746ce30af5ae8f9122101e086a61ef5..e5ef93c589b2bed68f790608868= ec3c7779d4cb8 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -44,6 +44,8 @@ #include "migration/qemu-file.h" #include "system/tpm.h" =20 +#include "hw/core/cpu.h" + VFIODeviceList vfio_device_list =3D QLIST_HEAD_INITIALIZER(vfio_device_list); static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces =3D @@ -1546,12 +1548,28 @@ retry: return info; } =20 +static bool vfio_device_check_address_space(VFIODevice *vbasedev, Error **= errp) +{ + uint32_t cpu_aw_bits =3D cpu_get_phys_bits(first_cpu); + uint32_t iommu_aw_bits =3D vfio_device_get_aw_bits(vbasedev); + + if (cpu_aw_bits && cpu_aw_bits > iommu_aw_bits) { + error_setg(errp, "Host physical address space (%u) is larger than " + "the host IOMMU address space (%u).", cpu_aw_bits, + iommu_aw_bits); + vfio_device_error_append(vbasedev, errp); + return false; + } + return true; +} + bool vfio_attach_device(char *name, VFIODevice *vbasedev, AddressSpace *as, Error **errp) { const VFIOIOMMUClass *ops =3D VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_LEGACY)); HostIOMMUDevice *hiod =3D NULL; + Error *local_err =3D NULL; =20 if (vbasedev->iommufd) { ops =3D VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_IOMM= UFD)); @@ -1571,6 +1589,9 @@ bool vfio_attach_device(char *name, VFIODevice *vbase= dev, return false; } =20 + if (!vfio_device_check_address_space(vbasedev, &local_err)) { + warn_report_err(local_err); + } return true; } =20 --=20 2.48.1 From nobody Sat Apr 5 07:15:18 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738244674; cv=none; d=zohomail.com; s=zohoarc; b=RHIDGNJPbFB2rm8NfAixbMpUQXfChqwIOWV8Xa0prkTqocpZHnFEvjT0RDfp88G7LJxfZDijD+IDYzOq0G0fljXkxTZ6etJkQQ3BKYggI26l/maXXeEVersGSPj5AV7O07jqY/VjvaBMBpIH08W5Vrpx9nYi47j6LqY6Cxl7ZPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738244674; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4JzKQP+z7UT5WLxFZKHl4zYT8jR/qLB35PIiTfHTQ3M=; b=c8aT8TId3lNNpRC/j4Luk64exszOZ83ivuc3FeQVOpwzSEJR2HX9ISoqaOnVySPc3zxD8YiFCICU8Tskd660aQagDUEWGdeRRqR2uxcUaTtMxNGVz9xIIGK+J7kAsGM7jTqFt+1fdVwhLcgn8d3WFURNZ04rhGBBz6BuUp1ySvA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738244674275268.7125645662435; Thu, 30 Jan 2025 05:44:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tdUq9-0000oi-VM; Thu, 30 Jan 2025 08:44:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tdUq6-0000ns-47 for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:14 -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 1tdUq4-0003R0-Kx for qemu-devel@nongnu.org; Thu, 30 Jan 2025 08:44:13 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-3f3e0viiNRSqQCixAy59pA-1; Thu, 30 Jan 2025 08:44:09 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DDC0C1800266; Thu, 30 Jan 2025 13:44:08 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.105]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C4CFE1800969; Thu, 30 Jan 2025 13:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738244652; 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: in-reply-to:in-reply-to:references:references; bh=4JzKQP+z7UT5WLxFZKHl4zYT8jR/qLB35PIiTfHTQ3M=; b=Fw8iqLfXrjBYHc4ei1Ry17juUrHCK97Qq4jvkX8xl7I0DLKEDwL6LD3B7LYEJAxWJ9aIqc nCeaTQD8q606rkja9aFeMmKVqQejXQvrBtgQLv6CrUSZd/m5tU8QgQSM0OSEfCuI8MNcxX 75dCe7rPDC1BvUMPkh15M/JOHEH0+JU= X-MC-Unique: 3f3e0viiNRSqQCixAy59pA-1 X-Mimecast-MFC-AGG-ID: 3f3e0viiNRSqQCixAy59pA From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Harsh Prateek Bora , Shivaprasad G Bhat Subject: [PATCH v2 9/9] vfio: Remove superfluous error report in vfio_listener_region_add() Date: Thu, 30 Jan 2025 14:43:46 +0100 Message-ID: <20250130134346.1754143-10-clg@redhat.com> In-Reply-To: <20250130134346.1754143-1-clg@redhat.com> References: <20250130134346.1754143-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.4.1 on 10.30.177.111 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=170.10.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.3, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1738244676568019000 For pseries machines, commit 567b5b309abe ("vfio/pci: Relax DMA map errors for MMIO regions") introduced 2 error reports to notify the user of MMIO mapping errors. Consolidate both code paths under one. Cc: Harsh Prateek Bora Cc: Shivaprasad G Bhat Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/common.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index e5ef93c589b2bed68f790608868ec3c7779d4cb8..f87214d6439ace74e3a8b2e8120= 7d5a266d5238f 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -596,8 +596,9 @@ static void vfio_listener_region_add(MemoryListener *li= stener, return; } =20 + /* PPC64/pseries machine only */ if (!vfio_container_add_section_window(bcontainer, section, &err)) { - goto fail; + goto mmio_dma_error; } =20 memory_region_ref(section->mr); @@ -682,6 +683,7 @@ static void vfio_listener_region_add(MemoryListener *li= stener, "0x%"HWADDR_PRIx", %p) =3D %d (%s)", bcontainer, iova, int128_get64(llsize), vaddr, ret, strerror(-ret)); + mmio_dma_error: if (memory_region_is_ram_device(section->mr)) { /* Allow unexpected mappings not to be fatal for RAM devices */ VFIODevice *vbasedev =3D @@ -696,11 +698,6 @@ static void vfio_listener_region_add(MemoryListener *l= istener, return; =20 fail: - if (memory_region_is_ram_device(section->mr)) { - error_reportf_err(err, "PCI p2p may not work: "); - return; - } - if (!bcontainer->initialized) { /* * At machine init time or when the device is attached to the @@ -808,6 +805,7 @@ static void vfio_listener_region_del(MemoryListener *li= stener, =20 memory_region_unref(section->mr); =20 + /* PPC64/pseries machine only */ vfio_container_del_section_window(bcontainer, section); } =20 --=20 2.48.1