From nobody Sat Feb 7 17:19:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602676385; cv=none; d=zohomail.com; s=zohoarc; b=RLtrOcZvpK31NZKkBKqY57v9nUmcgzQha+p6yavGkuJeudRN37cNYJi3PynvwODRnI6v+HT2Ojfzgmg6eNMbH4LQ3g+Ye7f8BmBLE1UcazYGApHirMy9hpoEP0kkdBgxAhIpYm3DlKH+2iXxAUlBJO1iUgg/tpJJVjHMcxX82qc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602676385; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2wTH3wc2I2rRV2/wVEdRkSxgLY/gmXgNT0mExNm6R6I=; b=V4Kpc+bcBYq7J8kJ0Q9Rkke1LUBE6HvNwn+pUyLgiOMTcuN2Sjr4iMYbFuLse1qsf38H6keyUZoFUSdZUtZlUKs7VJ3NdsxfoNjzXsHlDV6CPPMgomoAAVND7n53sUiajO0qejgwjVNROF93VeFAZkmPjK/a7oUbY5q5hu8ebaQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602676385814154.40355925545146; Wed, 14 Oct 2020 04:53:05 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-244-4RHCl71nOZ68iLsch-8HAQ-1; Wed, 14 Oct 2020 07:53:02 -0400 Received: by mail-wr1-f70.google.com with SMTP id t11so309242wrv.10 for ; Wed, 14 Oct 2020 04:53:01 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id n3sm3468979wmn.28.2020.10.14.04.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 04:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602676384; 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=2wTH3wc2I2rRV2/wVEdRkSxgLY/gmXgNT0mExNm6R6I=; b=Dsh/piE8n9WfNI8SEt/58k9x5xC2MbrYxLvxsoC9aivFVPFv+BnBsCEwVhFSXKaXkRiGGt 7de3YSt3w7DAZcq0mEjMbRZCOEmyxKuhMJmWY6YwI1wpM+h+5Tgts3LtyjEmN20mawgnDR a+K2q4j4pu3ZA2XKsSjsMQp7aJbGzjk= X-MC-Unique: 4RHCl71nOZ68iLsch-8HAQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2wTH3wc2I2rRV2/wVEdRkSxgLY/gmXgNT0mExNm6R6I=; b=GS5yGrCRBlwXnbFTyYRSxHMMtbaCe7p2RIvdQI/NfncOSJgto7W+d1fmCsReNAhXkB sLeFNv1/EOO2plfXIaIWIM69kKNiR75VprVYSiQjcSgeGqFd/pCMaZ2TZUKgGmxxSi2O 97GThLlv6wvhBoaqL9BWytaQYE6OunipfXxeTEZgsU1R7ywSSqVb76uHVmzF3Mo2jbhA FHBWFo0EGpwv+4FjvZl49qMXauJZPV3v1sw2pv7Em2bjNICFovvFqaubB3bCD+ozoi4P ql3NN+yy2ve9pSDVSPzdnUAtBaRNYORk88rp38k6Hj5rHcicAqLF9wQvc4YArS2wBtM+ hfuQ== X-Gm-Message-State: AOAM532MY8TLny2TcHXWMaceBQKHvqU7PNp3hw2Yv26PngqusSmoeQ1T xP7QVciXz37FkC7N4sE7YhfO/IU1+PeMb9Rmbc/5ajBigkHoyjiiaKTtaLo7BvkqSDfBsbw6o1/ lINVPDr8aaGhnLw== X-Received: by 2002:adf:f2c1:: with SMTP id d1mr5434777wrp.179.1602676380914; Wed, 14 Oct 2020 04:53:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0U1ZK9ta+Epay7AuhvWvB4Ol2G6irIn8WjV4FZZx1WacWHGo3jYExAPVw7Y/2g7p1s8/lMQ== X-Received: by 2002:adf:f2c1:: with SMTP id d1mr5434757wrp.179.1602676380696; Wed, 14 Oct 2020 04:53:00 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Max Reitz , Fam Zheng , qemu-block@nongnu.org, Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/9] util/vfio-helpers: Improve reporting unsupported IOMMU type Date: Wed, 14 Oct 2020 13:52:45 +0200 Message-Id: <20201014115253.25276-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014115253.25276-1-philmd@redhat.com> References: <20201014115253.25276-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Change the confuse "VFIO IOMMU check failed" error message by the explicit "VFIO IOMMU Type1 is not supported" once. Example on POWER: $ qemu-system-ppc64 -drive if=3Dnone,id=3Dnvme0,file=3Dnvme://0001:01:00.0= /1,format=3Draw qemu-system-ppc64: -drive if=3Dnone,id=3Dnvme0,file=3Dnvme://0001:01:00.0/= 1,format=3Draw: VFIO IOMMU Type1 is not supported Suggested-by: Alex Williamson Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- util/vfio-helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index c469beb0616..14a549510fe 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -300,7 +300,7 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const c= har *device, } =20 if (!ioctl(s->container, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) { - error_setg_errno(errp, errno, "VFIO IOMMU check failed"); + error_setg_errno(errp, errno, "VFIO IOMMU Type1 is not supported"); ret =3D -EINVAL; goto fail_container; } --=20 2.26.2 From nobody Sat Feb 7 17:19:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602676389; cv=none; d=zohomail.com; s=zohoarc; b=RqTKoILUAH9Vxvt6xlO+M4huKIwFe6JeVx/tNp9K6hXSSHzds9EJij4bU6tioAUTomrCRRHdmFZAMqU7F5eOUK8iNRb5K+ewUC6vK0uWkU0xj3dmgrV3vH16ZwrLdRiiN3FYc0L4VaVFtt3KSzgwsGh6y8a0gE6Xri0VS+GXbTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602676389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=gTNC5KDCZBOSstHZx3wGQ1e/sNtfzzFYB9WbTAF5Fvs=; b=bH52AZO3K49wFkcRJABs0OBIlDspb3Z2KGqk3fw25GbQjei/1jk5glPsDDxTqMe4IT6Onq3U1XsWImRN2QPB66uWl3SXdbd2IS8T0K6t2/15yQv4pJ78VIalrrwnivQY0a684TcPHGJRgOjX6UyYjCcEhrWwO8hsvfpa4IqtrGQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602676389602446.74768145115024; Wed, 14 Oct 2020 04:53:09 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-260-heDzaIfvOkOHx3WSmROh4w-1; Wed, 14 Oct 2020 07:53:07 -0400 Received: by mail-wr1-f72.google.com with SMTP id j15so1170060wrd.16 for ; Wed, 14 Oct 2020 04:53:06 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id h1sm4545855wrx.33.2020.10.14.04.53.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 04:53:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602676388; 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=gTNC5KDCZBOSstHZx3wGQ1e/sNtfzzFYB9WbTAF5Fvs=; b=UINg/XuUVBP/wNAdWFPXjR/kGLMN3unMZkxkRkzH13cPsncb94v0IhCOUUVFwAurE6ByfU jqVpJw4rNQpbG36e+RgPewKRHyE1OIDOk/zP77E3Pudte6wx52QPmcgUXLhIcWmZYsBOWQ uzDJNP5clprmjWDPHdiZ3OqHKO/GgOA= X-MC-Unique: heDzaIfvOkOHx3WSmROh4w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gTNC5KDCZBOSstHZx3wGQ1e/sNtfzzFYB9WbTAF5Fvs=; b=bfJFMUNU9GXfiDOvo0+ruTVKfXknX5PN6Ds9JFYjvUhFcrSpw5kaiHvx9a++tqYD3O kHg2gkdYzWrBUibgfv4jfG2cEzeWaXhlww4HpyfFZVe645UQKXsQ9sRaqHYBmZB7usGJ P5SVmCvB16rducqo1+E0gcN58bXdeCbkHnH+m9vif+JACW6+7CllUtA8tUIcWKRoVbvD QcpGjEkSltqefVcRnhfRJoKszPyy4qcVeVFh4SmWvd/mch3H9P28mlRoaQshyn8u3ibx QOZK7k4JdL5+9uJo7aKh1YdejvQW9jEFZ7aUJ7imYoRfG9E+Uf39E2fz5X3vv1pks9yM cw1A== X-Gm-Message-State: AOAM530aHI88eV1RRqpRyrztidUV1q7Rt5aqsD/b3g2lSDIkBkfQL78h W6qsCyeD//0nBKr5944KJOwwcT9UxAqzYOWTMUp4YABt8XYnsO5Uu7iHN3wJ9ssGthACJpjOQoO LQxWI1AUpNyMNmA== X-Received: by 2002:adf:ec0e:: with SMTP id x14mr5601827wrn.204.1602676385733; Wed, 14 Oct 2020 04:53:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtMH37I8lZRZav7+vZdgO3zaCYTYyHCZYU182Mm+8xVjmCgVz7lIIPWGObro4DGLBVEZpmDQ== X-Received: by 2002:adf:ec0e:: with SMTP id x14mr5601808wrn.204.1602676385567; Wed, 14 Oct 2020 04:53:05 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Max Reitz , Fam Zheng , qemu-block@nongnu.org, Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 2/9] util/vfio-helpers: Trace PCI I/O config accesses Date: Wed, 14 Oct 2020 13:52:46 +0200 Message-Id: <20201014115253.25276-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014115253.25276-1-philmd@redhat.com> References: <20201014115253.25276-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We sometime get kernel panic with some devices on Aarch64 hosts. Alex Williamson suggests it might be broken PCIe root complex. Add trace event to record the latest I/O access before crashing. In case, assert our accesses are aligned. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fam Zheng --- Cc: Alex Williamson --- util/vfio-helpers.c | 8 ++++++++ util/trace-events | 2 ++ 2 files changed, 10 insertions(+) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 14a549510fe..1d4efafcaa4 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -227,6 +227,10 @@ static int qemu_vfio_pci_read_config(QEMUVFIOState *s,= void *buf, { int ret; =20 + trace_qemu_vfio_pci_read_config(buf, ofs, size, + s->config_region_info.offset, + s->config_region_info.size); + assert(QEMU_IS_ALIGNED(s->config_region_info.offset + ofs, size)); do { ret =3D pread(s->device, buf, size, s->config_region_info.offset += ofs); } while (ret =3D=3D -1 && errno =3D=3D EINTR); @@ -237,6 +241,10 @@ static int qemu_vfio_pci_write_config(QEMUVFIOState *s= , void *buf, int size, int { int ret; =20 + trace_qemu_vfio_pci_write_config(buf, ofs, size, + s->config_region_info.offset, + s->config_region_info.size); + assert(QEMU_IS_ALIGNED(s->config_region_info.offset + ofs, size)); do { ret =3D pwrite(s->device, buf, size, s->config_region_info.offset = + ofs); } while (ret =3D=3D -1 && errno =3D=3D EINTR); diff --git a/util/trace-events b/util/trace-events index 24c31803b01..c048f85f828 100644 --- a/util/trace-events +++ b/util/trace-events @@ -85,3 +85,5 @@ qemu_vfio_new_mapping(void *s, void *host, size_t size, i= nt index, uint64_t iova qemu_vfio_do_mapping(void *s, void *host, size_t size, uint64_t iova) "s %= p host %p size 0x%zx iova 0x%"PRIx64 qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64= _t *iova) "s %p host %p size 0x%zx temporary %d iova %p" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" +qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_of= s, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"= PRIx64" size %"PRId64")" +qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_o= fs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x= %"PRIx64" size %"PRId64")" --=20 2.26.2 From nobody Sat Feb 7 17:19:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602676394; cv=none; d=zohomail.com; s=zohoarc; b=HRoHkew6JsBFwY9hwm9xGaTSy68AhaiH6NJ5Ubw9uLCa+mcPYBMSlqBrZxZP3kcm2OoGUiCfZ1pwpGF2guvc4751MgwZIYTC0YvumUsX0c6uBOJXLf0XXn0ceJC3DL6yrn/EOex5fCTFT23Y6fYB5qP5S5FvThHrEpbIFZppamg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602676394; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=s0nQOcSXgGeFKLC8eBLeMm+CVlg7cM+j+4WzFi+JgNU=; b=hlzcAaEa+kSGX6UDe3cT3uvc7ePOw/3RDNGRdPp4LjbN7lSGocr/JkU3df2PHO91sFRw7yBDScO0tcn6H0mmwUxPrLWPXmIvZpByT7WpijQ0/539VgM2WokP2AFu3X42eYITlCRB3Ee5MclrPeQs02/yG5t2TQ9CnINSckrgi7k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602676394266259.49492373889404; Wed, 14 Oct 2020 04:53:14 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-YtVGu76XOnyy7y-mHbNHgw-1; Wed, 14 Oct 2020 07:53:11 -0400 Received: by mail-wm1-f71.google.com with SMTP id r19so522380wmh.9 for ; Wed, 14 Oct 2020 04:53:11 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id q9sm4759658wrd.57.2020.10.14.04.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 04:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602676393; 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=s0nQOcSXgGeFKLC8eBLeMm+CVlg7cM+j+4WzFi+JgNU=; b=IjtmLw19mcFdze/Pdho2vc+EsJArzaG/Dz0azzQMsqqTLGAz7Mkyow2sw8lyKVZ1cWefZY fiV0jDcP+id2kKl6p8qHw7q9eOMQNhfEjKx9JEWPjpTGLsIQuovly1OF+oM+roirD64EjX 1U0A4+cMEIOqQGc4zFEDkBbv80dLLOQ= X-MC-Unique: YtVGu76XOnyy7y-mHbNHgw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s0nQOcSXgGeFKLC8eBLeMm+CVlg7cM+j+4WzFi+JgNU=; b=QfVlFSq4vru6R/qYngxJkGsG66Mas/anZ+xUmjBzk6ziHgIBXzORPHqTNgLTvEMfFR UifkgUBVQOMxnoRWWNaX4t6uCsgYmd97iFDAcPWermu0XIAKvH59U4mcjPvdTd8kaGRy oUPueC9W8hLd44e3iR6i9zsQEbBzhAqZEcEZ4nXEaowRYXawTVTxrpcIoQPXBit/W24o 5kL5hvxJK7qtGCyWzHX1WaiPeK9Dv5+yK0jnL9bkIUp337TpA28ZHi7dafa/u2GaBYGN Albg+QRNWt0qnIZfgK+ALZLEaDGkJ+jhHhkulXW03+marDmlkNAY7znpVMgcOeYnQQTC t2Og== X-Gm-Message-State: AOAM5300ZHqXk5+CqCMKOykTqQsmtVBCzPXdEIBWN8VkaZA60utuMrla aqKRTZrDho10HuiISO/A7tPIURWB/HfD7sM8EIh/S06xnzD7d1c7EBFqRayVj7ZtoAYkj39nC4h oooy2wbjtbPlcHA== X-Received: by 2002:adf:fb0d:: with SMTP id c13mr5135580wrr.19.1602676390430; Wed, 14 Oct 2020 04:53:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNpBqJ3zXQsezdDi+f724BoFg593jbXlwPGhLcc/apofSvYXfqyG6eLyZJlm+ggWdBiv49CQ== X-Received: by 2002:adf:fb0d:: with SMTP id c13mr5135566wrr.19.1602676390275; Wed, 14 Oct 2020 04:53:10 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Max Reitz , Fam Zheng , qemu-block@nongnu.org, Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 3/9] util/vfio-helpers: Trace PCI BAR region info Date: Wed, 14 Oct 2020 13:52:47 +0200 Message-Id: <20201014115253.25276-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014115253.25276-1-philmd@redhat.com> References: <20201014115253.25276-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) For debug purpose, trace BAR regions info. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fam Zheng --- util/vfio-helpers.c | 8 ++++++++ util/trace-events | 1 + 2 files changed, 9 insertions(+) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 1d4efafcaa4..cd6287c3a98 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -136,6 +136,7 @@ static inline void assert_bar_index_valid(QEMUVFIOState= *s, int index) =20 static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, int index, Error **err= p) { + g_autofree char *barname =3D NULL; assert_bar_index_valid(s, index); s->bar_region_info[index] =3D (struct vfio_region_info) { .index =3D VFIO_PCI_BAR0_REGION_INDEX + index, @@ -145,6 +146,10 @@ static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, in= t index, Error **errp) error_setg_errno(errp, errno, "Failed to get BAR region info"); return -errno; } + barname =3D g_strdup_printf("bar[%d]", index); + trace_qemu_vfio_region_info(barname, s->bar_region_info[index].offset, + s->bar_region_info[index].size, + s->bar_region_info[index].cap_offset); =20 return 0; } @@ -416,6 +421,9 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const c= har *device, ret =3D -errno; goto fail; } + trace_qemu_vfio_region_info("config", s->config_region_info.offset, + s->config_region_info.size, + s->config_region_info.cap_offset); =20 for (i =3D 0; i < ARRAY_SIZE(s->bar_region_info); i++) { ret =3D qemu_vfio_pci_init_bar(s, i, errp); diff --git a/util/trace-events b/util/trace-events index c048f85f828..4d40c74a21f 100644 --- a/util/trace-events +++ b/util/trace-events @@ -87,3 +87,4 @@ qemu_vfio_dma_map(void *s, void *host, size_t size, bool = temporary, uint64_t *io qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_of= s, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"= PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_o= fs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x= %"PRIx64" size %"PRId64")" +qemu_vfio_region_info(const char *desc, uint64_t offset, uint64_t size, ui= nt32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PR= Id32 --=20 2.26.2 From nobody Sat Feb 7 17:19:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602676399; cv=none; d=zohomail.com; s=zohoarc; b=Zi0ceCwFMVr6SzguXBrkIljvFQY8iDCDJVG77dRPE2ZqpInCo1bpyUKmm7DTVWb0OrRPElJu8iiubL3yZonKCs4Sepv2omJp1m1VOxeLSO3XNTvti8t+Uukj0RMRP3XbnyWEP0rByPoaNZuV+ej1TNgXD/052XVanCz2sGKRLtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602676399; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=fcXE6uNqT5zarSCdiyYz+Zw4SYDb1bSV+Wf41cxg400=; b=TePc5eBrXs7nwTLLENFT7gvkRnaki1thEDr0AUNX70R8yjBzqRCkkJZQXG0GBuBOqmmbHykYUStHUJK+Gp4FATafEjdaUcyiOT9CT5rpBi3FMQ54c1m1Hxi5/7XqxvglILkE0DSGWLGVgv0tjDHSUMFdDax3syLMvPC6+yQHG14= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602676399158428.3486717565306; Wed, 14 Oct 2020 04:53:19 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-359-svjCjDi3Oe2TlTUH7o8Trw-1; Wed, 14 Oct 2020 07:53:16 -0400 Received: by mail-wr1-f70.google.com with SMTP id t3so1191092wrq.2 for ; Wed, 14 Oct 2020 04:53:16 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id u202sm3624238wmu.23.2020.10.14.04.53.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 04:53:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602676398; 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=fcXE6uNqT5zarSCdiyYz+Zw4SYDb1bSV+Wf41cxg400=; b=LGf/1spu+c/PUsdjoXHexau3x410TO+l76WHtHeQ1xDa1kQlFON29xLMKJcWQavRUnxJMh DO4EVbbbbguDTSibFbCd33A325D0ZelNTV5UhHpOIgYuko7e+Ab9QHuY1Ra6fbQ2uiZmSD ZSfNceLOtVbMrrRNiqX8HuPqSHUL740= X-MC-Unique: svjCjDi3Oe2TlTUH7o8Trw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fcXE6uNqT5zarSCdiyYz+Zw4SYDb1bSV+Wf41cxg400=; b=dG8EmHx0NuUBo67suk9Bm4Dp420Rl3qH3v9YvvgMeTneq0MIUk+XTeJLvdFJ6mPkjD rWPXdbvfRj/rzvwECLbyBdpqX6Pld8+7OQQE01zbQOl6wJsfZ+nwhsCUpDUXXWjh4JQB ib2kO1Dkmjy/D2YkIcNGxeAFnjo0fIvkY5alxOjAc0xLxAmgPdxcIHyd1ELMhGzCQWGp JigRO94GACb4iy3kmADX+KY8lvxq46ZXde4fGKECMGqxqrqDS36G8po9TpJIdzVBBla0 +Iig7oSnaZZttnCn4nXeH+dwLe7CRTLxrPZoVfBW7/O4gWNk1eCsoHnUvCrAxBsTsEpX fM4A== X-Gm-Message-State: AOAM533J0SU+g0O7fgp8xBnCPsDC+tpzQ0o3MxHomM6/+JX8FS1K5w+z kT7KaVTltfQTnBilGYsK8bI+KWejdgCLLe32OJx7QlNTuRB0k74B96KMnQTo8b/bVZndCVyyusE YV50F4EkGYjYm1Q== X-Received: by 2002:adf:e6c4:: with SMTP id y4mr5284751wrm.423.1602676395233; Wed, 14 Oct 2020 04:53:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTgo4v/FSt9mSGD+KFD2dC/8duzlFdXCK8/kUP4osNTTHueQC1g5n6SbB5Xh9X8IY8TLOTHw== X-Received: by 2002:adf:e6c4:: with SMTP id y4mr5284728wrm.423.1602676395088; Wed, 14 Oct 2020 04:53:15 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Max Reitz , Fam Zheng , qemu-block@nongnu.org, Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 4/9] util/vfio-helpers: Trace where BARs are mapped Date: Wed, 14 Oct 2020 13:52:48 +0200 Message-Id: <20201014115253.25276-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014115253.25276-1-philmd@redhat.com> References: <20201014115253.25276-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) For debugging purpose, trace where a BAR is mapped. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fam Zheng --- util/vfio-helpers.c | 2 ++ util/trace-events | 1 + 2 files changed, 3 insertions(+) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index cd6287c3a98..278c54902e7 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -166,6 +166,8 @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index, p =3D mmap(NULL, MIN(size, s->bar_region_info[index].size - offset), prot, MAP_SHARED, s->device, s->bar_region_info[index].offset + offset); + trace_qemu_vfio_pci_map_bar(index, s->bar_region_info[index].offset , + size, offset, p); if (p =3D=3D MAP_FAILED) { error_setg_errno(errp, errno, "Failed to map BAR region"); p =3D NULL; diff --git a/util/trace-events b/util/trace-events index 4d40c74a21f..50652761a58 100644 --- a/util/trace-events +++ b/util/trace-events @@ -88,3 +88,4 @@ qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_of= s, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"= PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_o= fs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x= %"PRIx64" size %"PRId64")" qemu_vfio_region_info(const char *desc, uint64_t offset, uint64_t size, ui= nt32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PR= Id32 +qemu_vfio_pci_map_bar(int index, uint64_t region_ofs, uint64_t region_size= , int ofs, void *host) "map region bar#%d ofs 0x%"PRIx64" size %"PRId64" of= s %d host %p" --=20 2.26.2 From nobody Sat Feb 7 17:19:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602676404; cv=none; d=zohomail.com; s=zohoarc; b=CZGp6CKXHiviPmq16nhzg1q3S1QzwYMAheba6ZTTnfgBsK2jh8qB+a10VMpQVxXyVQZVwDykaHMBhA9+x6mJD2jd83UqvHH7DADfrixJZ+39t/hSNw+lwb+CiI5e16ao7VUIdaswV0YQIYszpp8gV16+aPMFy0FMelQnJBUKea0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602676404; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=yU8Zjc6YZ5nx4LM/74Erv9vHPc2KWWJeVlpqQoMWffM=; b=DE55gzA77EbbIJxC5zzj2WZAq8xPYjrWw81aDhmptM193y2L0mmalz+9U5kVq30YWJ7HVxmGnGuo03elc3Kr0RcS4+Hui/MjN5PjLNLIXH/TVuqfd5x8e0o1aNEChoN7u/QMGEkRcpDyzHvKUM6cIf4x+vE1H3mL6kxLkwJeOn8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 160267640433781.99615979308817; Wed, 14 Oct 2020 04:53:24 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-286-9lmGnUWqOxigBkDtmvsR1g-1; Wed, 14 Oct 2020 07:53:21 -0400 Received: by mail-wm1-f71.google.com with SMTP id 13so540229wmf.0 for ; Wed, 14 Oct 2020 04:53:21 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id x21sm4391584wmi.3.2020.10.14.04.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 04:53:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602676403; 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=yU8Zjc6YZ5nx4LM/74Erv9vHPc2KWWJeVlpqQoMWffM=; b=L6neLUZLLI2MWm1rTGNja3pdREFn9ePW54yqWmC98BWWsJrj5TLt35aId/l82dHVri6xsb JKBQdZpPBWmptrN7EudX+zwzrxUssUPRnDxnggGEKQEBJYGtTccbZdfqi8PgGruxr0O5W3 3yfiuA77qmJrB3T8IOcuJQHmmYf0SPc= X-MC-Unique: 9lmGnUWqOxigBkDtmvsR1g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yU8Zjc6YZ5nx4LM/74Erv9vHPc2KWWJeVlpqQoMWffM=; b=uZZTH4ryFl+JvwiOZ6Ynx+/rqEybd62S5vr68fEOKs0tLMlvrQfcxIGJOm2WNeYbfd CnSnc8R3FjCeHYNiXhAEYw9KqRnJ1BPqi4ZRcKNflExtLk3+we1jXCU6RVEdmu1f5FZY D1FEPK6Lh1URUXldcXJpyqhVRJTR3d/FmWawC+FOeeOvX5ehBqpeWU9YGCrhaXyT7IzS RPS0aqvE248byg5gT0JBJ6FjRkoNuSD+gai0+9YMv9MSdnomC7UYy0Pds7MPSPr4dXbp 4CCrwrwdOT7a7AYYfP6vrBJjvjF8r7DTh6kPSOYIS7nfgsHOGmnljRNwl9swz0D3PY+l cvcw== X-Gm-Message-State: AOAM533LwUh/kueWg3zmXBQu16Ih+YOc9osvg7sqVpacmShWJ/R54eGL cBRxZHMbp4FA4g1+mTfi2Fn7XzlnSOK0/DSpFac4Rxq5CByu8QIj/YQFbA66/t/x1ultSyL9ERF qD/DkyK0JDCV+LA== X-Received: by 2002:a5d:4c85:: with SMTP id z5mr5324220wrs.9.1602676400642; Wed, 14 Oct 2020 04:53:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzT8YsjA/gYaG7S3t36BTM7n0091rf6FNRXvH7t9hIx4Al4509z7KYzcCXX3v5BiCRG6kmvVg== X-Received: by 2002:a5d:4c85:: with SMTP id z5mr5324201wrs.9.1602676400476; Wed, 14 Oct 2020 04:53:20 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Max Reitz , Fam Zheng , qemu-block@nongnu.org, Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 5/9] util/vfio-helpers: Improve DMA trace events Date: Wed, 14 Oct 2020 13:52:49 +0200 Message-Id: <20201014115253.25276-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014115253.25276-1-philmd@redhat.com> References: <20201014115253.25276-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) For debugging purpose, trace where DMA regions are mapped. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fam Zheng --- util/vfio-helpers.c | 3 ++- util/trace-events | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 278c54902e7..c24a510df82 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -627,7 +627,7 @@ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void = *host, size_t size, .vaddr =3D (uintptr_t)host, .size =3D size, }; - trace_qemu_vfio_do_mapping(s, host, size, iova); + trace_qemu_vfio_do_mapping(s, host, iova, size); =20 if (ioctl(s->container, VFIO_IOMMU_MAP_DMA, &dma_map)) { error_report("VFIO_MAP_DMA failed: %s", strerror(errno)); @@ -783,6 +783,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, siz= e_t size, } } } + trace_qemu_vfio_dma_mapped(s, host, iova0, size); if (iova) { *iova =3D iova0; } diff --git a/util/trace-events b/util/trace-events index 50652761a58..8598066acdb 100644 --- a/util/trace-events +++ b/util/trace-events @@ -82,8 +82,9 @@ qemu_vfio_ram_block_added(void *s, void *p, size_t size) = "s %p host %p size 0x%z qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p s= ize 0x%zx" qemu_vfio_find_mapping(void *s, void *p) "s %p host %p" qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_= t iova) "s %p host %p size 0x%zx index %d iova 0x%"PRIx64 -qemu_vfio_do_mapping(void *s, void *host, size_t size, uint64_t iova) "s %= p host %p size 0x%zx iova 0x%"PRIx64 -qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64= _t *iova) "s %p host %p size 0x%zx temporary %d iova %p" +qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %= p host %p <-> iova 0x%"PRIx64 " size 0x%zx" +qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64= _t *iova) "s %p host %p size 0x%zx temporary %d &iova %p" +qemu_vfio_dma_mapped(void *s, void *host, uint64_t iova, size_t size) "s %= p host %p <-> iova 0x%"PRIx64" size 0x%zx" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_of= s, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"= PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_o= fs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x= %"PRIx64" size %"PRId64")" --=20 2.26.2 From nobody Sat Feb 7 17:19:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602676410; cv=none; d=zohomail.com; s=zohoarc; b=c75S8Ss+AcXe3Q6ox49tZTtpnAvUbwc4KwpDKyfkrRCJhRCRnUoYLVifmeDPfl9Dpqia2tcRC3DjZT6Y0EuPPska2vBnHcYQkn1Xx4kSFFfgEVdw+Ey8Ul6atb4KJXUtKe9JpcBwNhaTxC0Jx3Q28r3QRwetcbLgjnNXYxpwYc8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602676410; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=NZRNchyf6KqIGqa3qU7RafRDqVFOV3THBQqMLA8r2rk=; b=VU0d2TitZouupE8pxIwRPAe/RXdBSll5X7TA4TmefppIvk/mx+pC+RO+Vbu2QfxTQncQjihDedAFvDfbDc+6JE8gbSCdPGTR6F2dfuv2sZowbquqrW79KoWpXQbls5ntjijUDhMkEtOU2rsZfcSs3//kLkNZp0+6EmZ9aNBm1s0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 16026764106761010.1588959904769; Wed, 14 Oct 2020 04:53:30 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-502-o5UygzvGOD--xfMVOg-KJA-1; Wed, 14 Oct 2020 07:53:27 -0400 Received: by mail-wm1-f69.google.com with SMTP id z7so524640wme.8 for ; Wed, 14 Oct 2020 04:53:26 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 71sm4912323wrm.20.2020.10.14.04.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 04:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602676409; 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=NZRNchyf6KqIGqa3qU7RafRDqVFOV3THBQqMLA8r2rk=; b=TCrCwrdOBwCXYU3tmqgO64CcdGA4Zu4aQX03ECiQOJGz7sYcD9Sg2muF91ExPNlQsih7MR mfh+aop6LFZLob2c4yP6yU4bzodP9Eg0K/UEfAbSSzSHqDc1It5AW6Dvi7sdP/j+Vm6RDa qfHqRP7k5GxCppMZfgg0i7ga77XyZ0g= X-MC-Unique: o5UygzvGOD--xfMVOg-KJA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NZRNchyf6KqIGqa3qU7RafRDqVFOV3THBQqMLA8r2rk=; b=NsYutD0dHHKIHSCn+/42RfW2lgmbnCHAKiDvTsAnQgTkrmdhC9jSD3ocEy0/6iSGqA qxnyj6VihrvwugJTsnELjvNzks87dLNHyu3cg1jMxU6TDTkYzQK7GP1wLcnH7+MFzQCG qk6v/xI1jQ7bPtqQEOoDVPUHSZoZIhsHeNOuDWFzi8wQJ29EjWBLm7wRL3YaZIE94ItX 3rKf21oIweOwJSODl3Ust2AWCpkpCHx2oE0OMy8fImdQCh0SJiHCjQH4FJ9haTwUqNUH Qvxkqb32bza+SN2B+GPkgTqLji0TMuLQione/qmNyhB57dSH+EuvCxPdsa++AHxT4EWS a2ew== X-Gm-Message-State: AOAM533PlfHSNBbKNXe6WBCvLsqOcw5OAzIhu2vfPVdbjxrD+gOSgT6A yTrRP8kf/Q6XG4DgKfXvuarzcgXCMWqtGoKOs4/MvO3QfF/2KjNQ2TNBqslVNyAZ9C4RdRNOVUz jB2clZl+8UOdncw== X-Received: by 2002:adf:fe09:: with SMTP id n9mr5290304wrr.144.1602676405570; Wed, 14 Oct 2020 04:53:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg5JvYw9Ikt1i2TBNxCpLvTcvfsn2s1ANx5vtPbSfyN3FzTJMj6EJUgvtZqLhXOksiVF2MWA== X-Received: by 2002:adf:fe09:: with SMTP id n9mr5290282wrr.144.1602676405322; Wed, 14 Oct 2020 04:53:25 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Max Reitz , Fam Zheng , qemu-block@nongnu.org, Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 6/9] util/vfio-helpers: Convert vfio_dump_mapping to trace events Date: Wed, 14 Oct 2020 13:52:50 +0200 Message-Id: <20201014115253.25276-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014115253.25276-1-philmd@redhat.com> References: <20201014115253.25276-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The QEMU_VFIO_DEBUG definition is only modifiable at build-time. Trace events can be enabled at run-time. As we prefer the latter, convert qemu_vfio_dump_mappings() to use trace events instead of fprintf(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fam Zheng --- util/vfio-helpers.c | 19 ++++--------------- util/trace-events | 1 + 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index c24a510df82..73f7bfa7540 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -521,23 +521,12 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device,= Error **errp) return s; } =20 -static void qemu_vfio_dump_mapping(IOVAMapping *m) -{ - if (QEMU_VFIO_DEBUG) { - printf(" vfio mapping %p %" PRIx64 " to %" PRIx64 "\n", m->host, - (uint64_t)m->size, (uint64_t)m->iova); - } -} - static void qemu_vfio_dump_mappings(QEMUVFIOState *s) { - int i; - - if (QEMU_VFIO_DEBUG) { - printf("vfio mappings\n"); - for (i =3D 0; i < s->nr_mappings; ++i) { - qemu_vfio_dump_mapping(&s->mappings[i]); - } + for (int i =3D 0; i < s->nr_mappings; ++i) { + trace_qemu_vfio_dump_mapping(s->mappings[i].host, + s->mappings[i].iova, + s->mappings[i].size); } } =20 diff --git a/util/trace-events b/util/trace-events index 8598066acdb..7faad2a718c 100644 --- a/util/trace-events +++ b/util/trace-events @@ -80,6 +80,7 @@ qemu_mutex_unlock(void *mutex, const char *file, const in= t line) "released mutex qemu_vfio_dma_reset_temporary(void *s) "s %p" qemu_vfio_ram_block_added(void *s, void *p, size_t size) "s %p host %p siz= e 0x%zx" qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p s= ize 0x%zx" +qemu_vfio_dump_mapping(void *host, uint64_t iova, size_t size) "vfio mappi= ng %p to iova 0x%08" PRIx64 " size 0x%zx" qemu_vfio_find_mapping(void *s, void *p) "s %p host %p" qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_= t iova) "s %p host %p size 0x%zx index %d iova 0x%"PRIx64 qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %= p host %p <-> iova 0x%"PRIx64 " size 0x%zx" --=20 2.26.2 From nobody Sat Feb 7 17:19:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602676414; cv=none; d=zohomail.com; s=zohoarc; b=MBSL2ngXc5ND1yb8CIuZRFuBNbMOKTQl2Xo622TMBHhXFQtRxQucMVHfDYdefLTcNkWrjv5APX7FAHdbO5/+TktpSKQqLds8p7zT32Zg/NPUGz7j8MuS6TvSbYg0blgl3uq1SZ8DabxC2RnXZqFz4j8M+yXhIkJAfXG4d+fi0PQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602676414; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=BqUWIcl1+s/J+AI32uFx4TtTEZjgsGuxMtiBzoIGs5Q=; b=AmhkcM1OHUHrfQTWAjyNeuL3UoLthXiHw3TdloizQzZ2FbEIe3A3jD5MA4epqbhJTGxQDo4saPcLtNYzo6H0XhtqlxHwiqvUhrdpis4Wv7pT8v3mAlDAG/QM4wka80u3Rf291Z7CN6OfO+EavwvAO4HcscPbLK/rBc9eahRxVP8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160267641461255.38474961426982; Wed, 14 Oct 2020 04:53:34 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-437-qBaol5MSPAuJq8kqLZR-IA-1; Wed, 14 Oct 2020 07:53:32 -0400 Received: by mail-wm1-f69.google.com with SMTP id v14so529662wmj.6 for ; Wed, 14 Oct 2020 04:53:32 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id f14sm4741927wrt.53.2020.10.14.04.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 04:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602676413; 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=BqUWIcl1+s/J+AI32uFx4TtTEZjgsGuxMtiBzoIGs5Q=; b=cE2fLl7wlpCTRLVl481/c4XIqYPBxHjhRLAPwfl8riVxyVIh9dHevEIQlDwVsgKW0TQUoW 1Bsg8sSYn991sJ1flH/W067sXIt51ePCdfG+1x6pCRd+fs6m1YXbDHJSQpeIm65R0CyMHJ OsHASL0T8EQrAhkQsc4+kRsXaFkypOM= X-MC-Unique: qBaol5MSPAuJq8kqLZR-IA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BqUWIcl1+s/J+AI32uFx4TtTEZjgsGuxMtiBzoIGs5Q=; b=Lx47pSq76CJnMoz8muF6JmiYSpjnf8OzHp21kExBic4dtE3aK4F8yS4Yynao53d7My EaW04YRf8vUU17GXMUU5UfVdMzw67Ysa45UA3C1YujWN+iQkDKzmpjqyDZ4yXSGGi7N1 zy6pNZJsFCw/VzeXETDjgIZYGm45eiun9Hl0/ZRaDEEh5KabkE+s6eo2yynjfcp8HAq8 KfKtu1bvhLO2oJ2Bz4R230QT4oDmdBsDrNzy7APuRJtbUrp/nEKFb5Uz060Az8nFX0x/ aO9VyE0y8ybNyXbgMSPH2opEn36qUY8ZtuDtH7VEMSTdtjnhGw2oiO9Znm/EXsmAAeIF N8SQ== X-Gm-Message-State: AOAM5304ss+qvwUrNGxHxeNZEVgno3KBkvDNkdMBCeJOBNaMgVgloNx/ BJ3O3VldxGfVZKa5uEvzwf88pS3Yb+6YH3JoWVbj+7SJedg/O0L4D6IStLe96oCdQ8/pRhhOO2T F1yZcb9i7YwBsjA== X-Received: by 2002:a7b:c1d6:: with SMTP id a22mr3008674wmj.105.1602676410264; Wed, 14 Oct 2020 04:53:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI5lz+MJLGHChn+/frNS3OooBPBdp6BppIKUGD4T2EOIdCPk8Nx6L8MmsQVkBiqNAEh12L+w== X-Received: by 2002:a7b:c1d6:: with SMTP id a22mr3008654wmj.105.1602676410077; Wed, 14 Oct 2020 04:53:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Max Reitz , Fam Zheng , qemu-block@nongnu.org, Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 7/9] util/vfio-helpers: Let qemu_vfio_dma_map() propagate Error Date: Wed, 14 Oct 2020 13:52:51 +0200 Message-Id: <20201014115253.25276-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014115253.25276-1-philmd@redhat.com> References: <20201014115253.25276-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Currently qemu_vfio_dma_map() displays errors on stderr. When using management interface, this information is simply lost. Pass qemu_vfio_dma_map() an Error* argument so it can propagate the error to callers. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fam Zheng --- include/qemu/vfio-helpers.h | 2 +- block/nvme.c | 14 +++++++------- util/vfio-helpers.c | 12 +++++++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h index 4491c8e1a6e..bde9495b254 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -18,7 +18,7 @@ typedef struct QEMUVFIOState QEMUVFIOState; QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp); void qemu_vfio_close(QEMUVFIOState *s); int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, - bool temporary, uint64_t *iova_list); + bool temporary, uint64_t *iova_list, Error **errp); int qemu_vfio_dma_reset_temporary(QEMUVFIOState *s); void qemu_vfio_dma_unmap(QEMUVFIOState *s, void *host); void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index, diff --git a/block/nvme.c b/block/nvme.c index b48f6f25881..5f662c55bbe 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -167,9 +167,9 @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue= *q, return; } memset(q->queue, 0, bytes); - r =3D qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); + r =3D qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova, err= p); if (r) { - error_setg(errp, "Cannot map queue"); + error_prepend(errp, "Cannot map queue: "); } } =20 @@ -223,7 +223,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeSt= ate *s, q->completion_bh =3D aio_bh_new(aio_context, nvme_process_completion_b= h, q); r =3D qemu_vfio_dma_map(s->vfio, q->prp_list_pages, s->page_size * NVME_NUM_REQS, - false, &prp_list_iova); + false, &prp_list_iova, errp); if (r) { goto fail; } @@ -514,9 +514,9 @@ static void nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } - r =3D qemu_vfio_dma_map(s->vfio, id, sizeof(*id), true, &iova); + r =3D qemu_vfio_dma_map(s->vfio, id, sizeof(*id), true, &iova, errp); if (r) { - error_setg(errp, "Cannot map buffer for DMA"); + error_prepend(errp, "Cannot map buffer for DMA: "); goto out; } =20 @@ -989,7 +989,7 @@ try_map: r =3D qemu_vfio_dma_map(s->vfio, qiov->iov[i].iov_base, qiov->iov[i].iov_len, - true, &iova); + true, &iova, NULL); if (r =3D=3D -ENOMEM && retry) { retry =3D false; trace_nvme_dma_flush_queue_wait(s); @@ -1436,7 +1436,7 @@ static void nvme_register_buf(BlockDriverState *bs, v= oid *host, size_t size) int ret; BDRVNVMeState *s =3D bs->opaque; =20 - ret =3D qemu_vfio_dma_map(s->vfio, host, size, false, NULL); + ret =3D qemu_vfio_dma_map(s->vfio, host, size, false, NULL, NULL); if (ret) { /* FIXME: we may run out of IOVA addresses after repeated * bdrv_register_buf/bdrv_unregister_buf, because nvme_vfio_dma_un= map diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 73f7bfa7540..c03fe0b7156 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -462,7 +462,7 @@ static void qemu_vfio_ram_block_added(RAMBlockNotifier = *n, { QEMUVFIOState *s =3D container_of(n, QEMUVFIOState, ram_notifier); trace_qemu_vfio_ram_block_added(s, host, size); - qemu_vfio_dma_map(s, host, size, false, NULL); + qemu_vfio_dma_map(s, host, size, false, NULL, NULL); } =20 static void qemu_vfio_ram_block_removed(RAMBlockNotifier *n, @@ -477,6 +477,7 @@ static void qemu_vfio_ram_block_removed(RAMBlockNotifie= r *n, =20 static int qemu_vfio_init_ramblock(RAMBlock *rb, void *opaque) { + Error *local_err =3D NULL; void *host_addr =3D qemu_ram_get_host_addr(rb); ram_addr_t length =3D qemu_ram_get_used_length(rb); int ret; @@ -485,10 +486,11 @@ static int qemu_vfio_init_ramblock(RAMBlock *rb, void= *opaque) if (!host_addr) { return 0; } - ret =3D qemu_vfio_dma_map(s, host_addr, length, false, NULL); + ret =3D qemu_vfio_dma_map(s, host_addr, length, false, NULL, &local_er= r); if (ret) { - fprintf(stderr, "qemu_vfio_init_ramblock: failed %p %" PRId64 "\n", - host_addr, (uint64_t)length); + error_reportf_err(local_err, + "qemu_vfio_init_ramblock: failed %p %" PRId64 ":= ", + host_addr, (uint64_t)length); } return 0; } @@ -724,7 +726,7 @@ qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size,= uint64_t *iova) * mapping status within this area is not allowed). */ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, - bool temporary, uint64_t *iova) + bool temporary, uint64_t *iova, Error **errp) { int ret =3D 0; int index; --=20 2.26.2 From nobody Sat Feb 7 17:19:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602676419; cv=none; d=zohomail.com; s=zohoarc; b=kmP3eHauJfHXi/qpG0T6+NnOiRuANFyMaS/ckPutDn5KbH85lXLfKgpD38bNDW7hxnJU521+qNvLWdUPrxrTZSjBVGDJcr2+CgrXSpr8psibC6iTaxmLf8smNl7oi2Jyf1mD174Kx8jvu/+bO2p9fTHTCf1j3DMi4I0Tq8zWw9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602676419; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=+MF6CELc3HUdf4Q8Rj0ad0iLARqM18cYceZFctPs7+I=; b=FV+7/1biKemoJmRI/ItUVikI4+9ddpt8zUhfezdLe15VFBoO/IGavdTAmah8VPLcApH1ofg/vWmWJE6eJqPSpvM9hDX8JgCuf5DFkHBF+XrBFUjqgHMXbU1VqwU7A3539IlLmCybcho0gE86Kjy0gqfrgtIldgDFNeCC9p4KMFo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602676419035430.521253298087; Wed, 14 Oct 2020 04:53:39 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-547-tv-vfTLyPryZMsWF9atpsQ-1; Wed, 14 Oct 2020 07:53:36 -0400 Received: by mail-wm1-f69.google.com with SMTP id 73so446532wma.5 for ; Wed, 14 Oct 2020 04:53:36 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id z11sm4503433wrh.70.2020.10.14.04.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 04:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602676418; 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=+MF6CELc3HUdf4Q8Rj0ad0iLARqM18cYceZFctPs7+I=; b=GBoxdOYYwhi6AWrImA7568HYOtlMgvR7M9zC+7Q4NCw3W1TGkRop2RRGXivpSZIyhNcbBJ 3VAtf2NspW/spk2nNWEruzGWtxOdYaiNQYObO9a+eA1C4AYCSCyniK5osL4eLJH1tUMKWs mMKyhE/YRewOQvvKAK66uxXR9plpZl0= X-MC-Unique: tv-vfTLyPryZMsWF9atpsQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+MF6CELc3HUdf4Q8Rj0ad0iLARqM18cYceZFctPs7+I=; b=Cp4iUIGU7tYdTGB2iKImT6adcsBmuJPD5MxmNQqwrksX4dAGNtd/3UFI6RapzqPcio xKykNwzeZ3tZJLuWtufI3Bm4m2eecKJsh5IqAQT+47CYdJflOCVOgVtwjUEoJnLCL3mC IDMBeuPGasEKoOHyifncK2BLiSOl0witDu4z4V4OaE6Bpz9EeWr8LG928jphGHJE6IEB zEo6n53eHlKLYBgXa1J0OYrygS8f9KHX5pekRlqkUNrD+jTiZRp1PRXT5roSbXtSA+L3 LiLjAQXok4tqPTepwuMPMMd3JK3lKkO2DrYwgCuRC6r6KvbRXDHfQdLcG+d6fl16O7Is ZUcw== X-Gm-Message-State: AOAM533lOfjVg0gaA9l3lep4vKzgcQGXhnujWK4j0hPt4hjdOgm+xcHK DCx73j1pSfzS71xetsIS0LA0ZjQyRtPeeVIBWdYJXIvYkIOquO9o0sGpFBdVgYCLn9BNfBijH+F WJ1KzRBiXMvtMQQ== X-Received: by 2002:adf:e8cb:: with SMTP id k11mr5067242wrn.91.1602676415203; Wed, 14 Oct 2020 04:53:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL2e9IVbFz59KuTP2nwDmqI5XVzLoDSQqKHOW3W0u3Sy/zE9IC6aSMNJOLvMUQa6Yu11m1mA== X-Received: by 2002:adf:e8cb:: with SMTP id k11mr5067223wrn.91.1602676414996; Wed, 14 Oct 2020 04:53:34 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Max Reitz , Fam Zheng , qemu-block@nongnu.org, Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 8/9] util/vfio-helpers: Let qemu_vfio_do_mapping() propagate Error Date: Wed, 14 Oct 2020 13:52:52 +0200 Message-Id: <20201014115253.25276-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014115253.25276-1-philmd@redhat.com> References: <20201014115253.25276-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Pass qemu_vfio_do_mapping() an Error* argument so it can propagate any error to callers. Replace error_report() which only report to the monitor by the more generic error_setg_errno(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fam Zheng --- util/vfio-helpers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index c03fe0b7156..2c4598d7faa 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -609,7 +609,7 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState= *s, =20 /* Do the DMA mapping with VFIO. */ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size, - uint64_t iova) + uint64_t iova, Error **errp) { struct vfio_iommu_type1_dma_map dma_map =3D { .argsz =3D sizeof(dma_map), @@ -621,7 +621,7 @@ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void = *host, size_t size, trace_qemu_vfio_do_mapping(s, host, iova, size); =20 if (ioctl(s->container, VFIO_IOMMU_MAP_DMA, &dma_map)) { - error_report("VFIO_MAP_DMA failed: %s", strerror(errno)); + error_setg_errno(errp, errno, "VFIO_MAP_DMA failed"); return -errno; } return 0; @@ -757,7 +757,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, siz= e_t size, goto out; } assert(qemu_vfio_verify_mappings(s)); - ret =3D qemu_vfio_do_mapping(s, host, size, iova0); + ret =3D qemu_vfio_do_mapping(s, host, size, iova0, errp); if (ret) { qemu_vfio_undo_mapping(s, mapping, NULL); goto out; @@ -768,7 +768,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, siz= e_t size, ret =3D -ENOMEM; goto out; } - ret =3D qemu_vfio_do_mapping(s, host, size, iova0); + ret =3D qemu_vfio_do_mapping(s, host, size, iova0, errp); if (ret) { goto out; } --=20 2.26.2 From nobody Sat Feb 7 17:19:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602676423; cv=none; d=zohomail.com; s=zohoarc; b=WypGnf2pMB7qC2DRhCGm5r5zyumhT0cl9tF5z9H6dwj577jAXcJIhKPTKHePKM4sKLhqD9YyIKbu11JqkhSogYv4bGxM//uURkwamXvm8daLo+bNcBY8ktTL9RxUOaonKCRw+Pf7M3XR2+bhNtVy+1OoOXa8U646V8q4YyCtKfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602676423; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=uTVh2AtSozqPFxInc/ksQHh3UVKG/5ht671RHOKC4pA=; b=JPOTLevp2kpuz9KY0gVzAOXCDj7FdotpdmsoO+JLiKTEmDauaYEZ+fAA7+zPxi6wXH6vcRlTl/QHs8A9zoqg8a9JM09mGybiHCHiLCH09daG0nBDxpOlZvU6vWOoAmynJu7D7rgO6sw7RqmfNjRRinJpQdWI59QO+S83X/y+nWA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602676423698520.7289085650623; Wed, 14 Oct 2020 04:53:43 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-461-DL8HXYsEODmBgyZoTlClZw-1; Wed, 14 Oct 2020 07:53:41 -0400 Received: by mail-wr1-f69.google.com with SMTP id f11so1169236wro.15 for ; Wed, 14 Oct 2020 04:53:40 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id f14sm4742637wrt.53.2020.10.14.04.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 04:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602676422; 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=uTVh2AtSozqPFxInc/ksQHh3UVKG/5ht671RHOKC4pA=; b=DHyBFkhY2Wpl+NaaAJpjF58I4KldH6jQBWKRR+HqwHzgzqMgA2aX1eFkdwGqMr/xHNB5lm JlnvUnw6nHrzDqniaR+lijppbI39w43DCVE2F10nHGxF1SdHss0AWUy46S0B0oP2jxkPiI kZBsAtMvbxdTAZCujUHVKI3wowOOBwk= X-MC-Unique: DL8HXYsEODmBgyZoTlClZw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uTVh2AtSozqPFxInc/ksQHh3UVKG/5ht671RHOKC4pA=; b=qpVbNPBqbSUDfvDazNxh2/ZLa6MlHfnq+ev0Lv5FxTbITOxjoGjFKcaDq7k1VHPwds jT+gd2kUziQdnb0G2r93eFjW15zcDZVs+ozeYdHUc7ciGgo3PYHzBZswPGpCH+mmvNcT DhKSRwmYfLUMguUrMTq2yNiyPZUB3dxXVK3jIRVfYKzd82VRk/EABva+XNQnuZP4d2lj PQEuqlUafAbwmAeSOey+tVx44eFv/Byyn+aJtXkSpvaTIwHRWIUb/cjJGPIflZBhRpjg 3By+N/bd9Qpk74//WYl+jwF62EnusJeGn6upqmc1IejlzUorwHV1ConjU8bl6fasOowc cJ4w== X-Gm-Message-State: AOAM533X1pxHfMsEFWJxM2aNYeALMWCfnWiPoaBGbQHcebkBENoW/88H 5w4m9hFd/mwkNllbXM69BPFhrs4db0Ee7NBSHWum1p30dZLXeJD3bUFacV1Uw1mklcnEQaikV/L l/Ua8NVLjN0qWOg== X-Received: by 2002:a5d:40cb:: with SMTP id b11mr5507276wrq.254.1602676419948; Wed, 14 Oct 2020 04:53:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZTq3DOuNlD4CjLYuFd9cTUF2hAZlueRat6xzS8TZp5RX2oIrBnEpKOMREHnmI2CSqIK2tWQ== X-Received: by 2002:a5d:40cb:: with SMTP id b11mr5507251wrq.254.1602676419740; Wed, 14 Oct 2020 04:53:39 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Max Reitz , Fam Zheng , qemu-block@nongnu.org, Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 9/9] util/vfio-helpers: Let qemu_vfio_verify_mappings() use error_report() Date: Wed, 14 Oct 2020 13:52:53 +0200 Message-Id: <20201014115253.25276-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014115253.25276-1-philmd@redhat.com> References: <20201014115253.25276-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Instead of displaying the error on stderr, use error_report() which also report to the monitor. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fam Zheng --- util/vfio-helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 2c4598d7faa..488ddfca2a9 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -661,13 +661,13 @@ static bool qemu_vfio_verify_mappings(QEMUVFIOState *= s) if (QEMU_VFIO_DEBUG) { for (i =3D 0; i < s->nr_mappings - 1; ++i) { if (!(s->mappings[i].host < s->mappings[i + 1].host)) { - fprintf(stderr, "item %d not sorted!\n", i); + error_report("item %d not sorted!", i); qemu_vfio_dump_mappings(s); return false; } if (!(s->mappings[i].host + s->mappings[i].size <=3D s->mappings[i + 1].host)) { - fprintf(stderr, "item %d overlap with next!\n", i); + error_report("item %d overlap with next!", i); qemu_vfio_dump_mappings(s); return false; } --=20 2.26.2