From nobody Sun May 19 15:58:47 2024 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=1603214679; cv=none; d=zohomail.com; s=zohoarc; b=WkKW4LjpjmemV0JTlNFivWg8XJLcvUItr2Xh4TE1Bmir83CajeE3FNEwucBKJ9BBkgEin7Zzx9Gvm90mP+1CbBJLiArqf+Fx3EwUvSGRqXuKnpf67uyBBRwW5BJymZ/CAo5HkH3asIUHPmpTI+F6GdGItjUSjjUxHftCr9Nw7cQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214679; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=4W8kZsSKWJcjh8HqyDoLc1LkrTctt68co791MXFzTk8=; b=G8hlW5oqg6eATq/NiGV95swb4Eno6CWrkupYJUMm9sz+WhBorfRhqCNDd9KdUpb70ThDO8ljB2xT7n7+iKDpywcyDan1VWCy+D4ip3YxP8qULX+Jm1V3N+OZhG/I0mVA/559t9NEgSXFkPmqvV+YdKNtNWjuImidLDiU6pCnERE= 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 1603214679523674.8770435121198; Tue, 20 Oct 2020 10:24:39 -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-596-eT2UwLS8NvuZ62vMo-tqAQ-1; Tue, 20 Oct 2020 13:24:37 -0400 Received: by mail-wm1-f71.google.com with SMTP id r19so697161wmh.9 for ; Tue, 20 Oct 2020 10:24:37 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id p11sm3940667wrm.44.2020.10.20.10.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214678; 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=4W8kZsSKWJcjh8HqyDoLc1LkrTctt68co791MXFzTk8=; b=JmB8ykMD6NCbm0HEib2brv9/ZNcP4RvUPIjMilxuPsmHGim2OQwYG/S/8xKuXOlES/JM2Q RUrX7/tq8LnsYKNdUXkmrVMgb/gQmIWaP+pG/eejaIHnNOrOB3Wi0DOOpchllTtoskanaJ nXGTqKcUwBvPpdzYRbNYwPU9KCFwVY4= X-MC-Unique: eT2UwLS8NvuZ62vMo-tqAQ-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=4W8kZsSKWJcjh8HqyDoLc1LkrTctt68co791MXFzTk8=; b=lOiQL1PS1/3mkNU8DR8roi0gpIfv4C22UCBBjYlB6wJE4k6/Nkns7toKMakgoLMf8m Bl+hKII6Ee9K3jScFP1DZ6pSyAmTQbWeVSCRrczqJNtwDiiMUihYgujUUmC3bIZQAcZs JmdGQr2rHn9jhWTPaqgpD+s1Khw4AcXjZrQ6I6aYdOiFeg0Fvn/l/bUw1LWeidCOkTb7 l2Jp2zyOO+sLFBG05/iTcyvfoV65BGLJi6cOJ7F/p+VWof+3enNG1P6pI1mSUzYzJNXO 36cPFwc6Kwvb6fe92jCap1QLFWXbRT3YSt6PZMA3OmK6DblVN1EXXuA187ufnslvtKzl 6HIQ== X-Gm-Message-State: AOAM532lvo4hUxbEld7+CWJK61J/ge5/gylpmgIIuNLcTW8RCa8iJPcY pjgmN/iP2AC/ppX1FgPOim94pZiXk4zThMrTytT6WqI6lwMeMwqfV4+zY3vkfOSlONYDaTINRTz jp9arlWHmnh2TTA== X-Received: by 2002:adf:f305:: with SMTP id i5mr4694387wro.346.1603214676002; Tue, 20 Oct 2020 10:24:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5IauIUEXQk0ERMzuRpB8broMsmB1ex+OysnPFWe959gKhHsJWl3VqAf44vKZAZweBHakFAQ== X-Received: by 2002:adf:f305:: with SMTP id i5mr4694358wro.346.1603214675825; Tue, 20 Oct 2020 10:24:35 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eric Auger Subject: [PATCH 01/16] block/nvme: Correct minimum device page size Date: Tue, 20 Oct 2020 19:24:13 +0200 Message-Id: <20201020172428.2220726-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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) While trying to simplify the code using a macro, we forgot the 12-bit shift... Correct that. Fixes: fad1eb68862 ("block/nvme: Use register definitions from 'block/nvme.= h'") Reported-by: Eric Auger Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index b48f6f25881..029694975b9 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -724,7 +724,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, goto out; } =20 - s->page_size =3D MAX(4096, 1 << NVME_CAP_MPSMIN(cap)); + s->page_size =3D MAX(4096, 1u << (12 + NVME_CAP_MPSMIN(cap))); s->doorbell_scale =3D (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment =3D s->page_size; timeout_ms =3D MIN(500 * NVME_CAP_TO(cap), 30000); --=20 2.26.2 From nobody Sun May 19 15:58:47 2024 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=1603214687; cv=none; d=zohomail.com; s=zohoarc; b=Dg/kS6jUWXsgUKuKsP0ycOlCS22D+liVA/MmEjG8doYiuEWXZOTv+jmaDcLcuGf2/kz+d8W7XL2+kc4Gk1nYzxtDWPHv7YPRq2qH13dyt6hjlDGyEH4H7OjRqXTPwfaWfhTLLrKSMnNl4s8OmAEv2oxZHg2fFkwQYH1DeuKvtFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214687; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2wTH3wc2I2rRV2/wVEdRkSxgLY/gmXgNT0mExNm6R6I=; b=RS1YWBeDKbjo/QOgG3hoxuQAsaPSzDNt8khCDClGtcvseV8Cskc2XeAZTjtyb+xhfm7h5A8Her6aveG8u+uvEJDxGsq8Pq34t6uO+stwWcLSaJxZnMQmKwXwaYsY9NCnv9ALSv8SDBO0m5SZ5r+sYJRC6BcgFxmuhLGd52FpyO8= 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 1603214687644590.1251313040152; Tue, 20 Oct 2020 10:24:47 -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-382-2z5wZyYLPnqSTubYwPSnrA-1; Tue, 20 Oct 2020 13:24:42 -0400 Received: by mail-wm1-f69.google.com with SMTP id z7so702282wmi.3 for ; Tue, 20 Oct 2020 10:24:42 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id y185sm3676545wmb.29.2020.10.20.10.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214684; 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=FXn+604HCbVLxbVk0I8eM+rbX9txiBSyra9we7o6Mrva2qiqOJI6djaw5+keBZWkJzkBmv TcjZ01XDTGneJ7FBtsiw1nWWIEgem1FD8FRJMK6MsvRzTDyboXCYc9cu+tFP8qphPwM3Sq 6njpoN156BKMoz79CnvEP+HH0Zahwjg= X-MC-Unique: 2z5wZyYLPnqSTubYwPSnrA-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=RlhSXQLePamrzR2fQb+erjEXHg9jIsa2V23X5z7ak1jOXs3Qa6Lfrmdiz5sSpIX01h RFFs1v3FhjEDs1+B/A7dLW94ff6fxGmkjyUAm9bjNI/dKOa4hPMInxJ7IRDN/woyq88u wDkW6CGJkD9su5KMg6beqr9krLYzngVbNnc0bZ7+rrVhssxATVFdrCJFYJqMweQOFUD3 hZpgOjDR4WulV7Gaf/n+h60Wp6ZVr8N0U8rqUY6DuIEkwhTOIfYwO2Tyd/ljCCdntfbB HdqYNXnNoELrAXfGo0xmZhqZLHKp5GtZCLQXAIR0AGsRRL+M2xi98VphtGppAqs0GuKw yXFA== X-Gm-Message-State: AOAM533M9yzmRIvnTAJITS95Z00XeEEBXZLiU7CJhabEsCLjwufaZ7zS pyq+g+M974V2e+1f97oz/ujK9R7veFlBkbQSYHoZA9B9mLcVMmU+MYk5l1yM0QVzqJ1dFW+AUfM qAf18ITRAoDPXJg== X-Received: by 2002:adf:e412:: with SMTP id g18mr4641260wrm.211.1603214681014; Tue, 20 Oct 2020 10:24:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBNhKVmJ/kwz/H/9cX3uBa72fxsg1FHIIl+2JBiGA8x9BVJUC4kBEDX0YVj0zyn0Xb8jdImA== X-Received: by 2002:adf:e412:: with SMTP id g18mr4641246wrm.211.1603214680850; Tue, 20 Oct 2020 10:24:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 02/16] util/vfio-helpers: Improve reporting unsupported IOMMU type Date: Tue, 20 Oct 2020 19:24:14 +0200 Message-Id: <20201020172428.2220726-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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 Reviewed-by: Stefan Hajnoczi --- 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 Sun May 19 15:58:47 2024 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=1603214689; cv=none; d=zohomail.com; s=zohoarc; b=lXHUYk6jSj3k238xMKMqGy1qDUdWIzTajOoPbB4K/znjg8KXD69MUBRegIBpxNZq15YOChbpHrD9HPrgMuOYMMHwl/LfYDtjY8iwEJNI2W6FnOvE4cvxlmUfTHgdHYG4XHs3TwuBGXhHSx0llecWu/GRxlO/q5pdR1mAZ6pJ+nk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214689; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=RLSFcjIN9fsyM4mYIkd/q8ZNCzz/MCojLmiYxvbAHJQ=; b=d3t5A7RzWJKZ5FemQ0FrYrdD8146C9kHnA9KUljYVfOC15JvQWhNE+5qaXSIQbe8aNJvObL+n6wG5rkBktB0oxKg553WCrk91MKZzfQjUg6jnHQKAkG6DsXNV/TjM7Bc2aTy2ZrpLohSswCngjoQeIURl71d0Apq4MtqxXAFMtc= 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 1603214689988481.3099723517943; Tue, 20 Oct 2020 10:24:49 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-228-Zzhuez0gOFSek9T1O-MSzw-1; Tue, 20 Oct 2020 13:24:47 -0400 Received: by mail-wr1-f71.google.com with SMTP id n14so1082660wrp.1 for ; Tue, 20 Oct 2020 10:24:47 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id e5sm3846294wrw.93.2020.10.20.10.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214689; 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=RLSFcjIN9fsyM4mYIkd/q8ZNCzz/MCojLmiYxvbAHJQ=; b=dkCtmAshzKjyzCY3ZzDXJKrteLhQoOFEd+3OOjE6NRP5IF7Ioj0emwFR4549EusOoVhmCA 3wMTiY6ELF/PubWfWjQxN78rRehN8/2BrTRtrmBd66oRE4tOEPKmwaR09zYt1tjDgwOwgM Jp1S620ZSRZGgmFK61du+MRxfaWGZxQ= X-MC-Unique: Zzhuez0gOFSek9T1O-MSzw-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=RLSFcjIN9fsyM4mYIkd/q8ZNCzz/MCojLmiYxvbAHJQ=; b=VKGzcRjTlsWrv7QnaoCQFxZ1UeN9buDUqJ75fV2qNVBu3D0zaNP4c7uw/1JpBBu61q Q8vP+hEpHdsSxzl+8+2TN36uXo/u5iS3/5Z/1fF1Ib+XjBgkw+mEhsRlk8YIUEf8FABi Y2d+E1FoAbMTvut6gkkPTTUegzoYoZUW3/OTG/YpHayQgRQrA+/P4P1rLzoljzagE0dM VpP94ZwbQo6dP/l1aSFm85wZ5PVBNIJsWkKvwM31obFjc9UbrEotPGtzs/l16NwVL9/p tO0JVL+H8Sy5hLQD56Qog4I3seGpUxYfJsi6LwzKGDF3gvx5b+YGugwGstTqW2P7EPVi Yamw== X-Gm-Message-State: AOAM533ZpoUYJ1Rx4R2JB9a3z3vAcdarnK9tzpioUDyzheZg21iGLC+S COd4iqxK6HE3tHnecz+UUPv8fgROfVClZJGP0fqKeaaH1xEf2fO6rDAuktca8OSSt7f3cg9p8eB /tS146yaHjAQ/QA== X-Received: by 2002:a7b:c384:: with SMTP id s4mr4059809wmj.77.1603214686371; Tue, 20 Oct 2020 10:24:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtblf+EuY7iAK651HJztXrNpt21m7DLZ5Exq2EIzgtnesmNJ8R78rTO0MX31ZTDrbiuYeEWw== X-Received: by 2002:a7b:c384:: with SMTP id s4mr4059778wmj.77.1603214685932; Tue, 20 Oct 2020 10:24:45 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 03/16] util/vfio-helpers: Pass minimum page size to qemu_vfio_open_pci() Date: Tue, 20 Oct 2020 19:24:15 +0200 Message-Id: <20201020172428.2220726-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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 block driver asks for a minimum page size, but it might not match the minimum IOMMU requirement. In the next commit qemu_vfio_init_pci() will be able to report the minimum IOMMU page size back to the block driver. In preparation, pass the minimum page size as argument to qemu_vfio_open_pci(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/vfio-helpers.h | 3 ++- block/nvme.c | 5 +++-- util/vfio-helpers.c | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h index 4491c8e1a6e..5cb346d8e67 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -15,7 +15,8 @@ =20 typedef struct QEMUVFIOState QEMUVFIOState; =20 -QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp); +QEMUVFIOState *qemu_vfio_open_pci(const char *device, size_t *min_page_siz= e, + 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); diff --git a/block/nvme.c b/block/nvme.c index 029694975b9..8335f5d70dd 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -690,6 +690,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, uint64_t deadline, now; Error *local_err =3D NULL; volatile NvmeBar *regs =3D NULL; + size_t min_page_size =3D 4096; =20 qemu_co_mutex_init(&s->dma_map_lock); qemu_co_queue_init(&s->dma_flush_queue); @@ -702,7 +703,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, return ret; } =20 - s->vfio =3D qemu_vfio_open_pci(device, errp); + s->vfio =3D qemu_vfio_open_pci(device, &min_page_size, errp); if (!s->vfio) { ret =3D -EINVAL; goto out; @@ -724,7 +725,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, goto out; } =20 - s->page_size =3D MAX(4096, 1u << (12 + NVME_CAP_MPSMIN(cap))); + s->page_size =3D MAX(min_page_size, 1u << (12 + NVME_CAP_MPSMIN(cap))); s->doorbell_scale =3D (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment =3D s->page_size; timeout_ms =3D MIN(500 * NVME_CAP_TO(cap), 30000); diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 14a549510fe..a2b084c69c1 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -488,8 +488,14 @@ static void qemu_vfio_open_common(QEMUVFIOState *s) =20 /** * Open a PCI device, e.g. "0000:00:01.0". + * + * @min_page_size: Pointer holding the minimum page size requested + * + * If the IOMMU can not be configured with @min_page_size, the minimum + * page size is stored in @min_page_size and -EINVAL is returned. */ -QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp) +QEMUVFIOState *qemu_vfio_open_pci(const char *device, size_t *min_page_siz= e, + Error **errp) { int r; QEMUVFIOState *s =3D g_new0(QEMUVFIOState, 1); --=20 2.26.2 From nobody Sun May 19 15:58:47 2024 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=1603214695; cv=none; d=zohomail.com; s=zohoarc; b=iYyvZ4guQL3v7EjXQGJmE7OIW06M9wYidTmw5NyzX7f4EzPKTeUcO8ES21BJf8LRaonf//y/8AvbNiIewoKjErAV0mZNLqQp9SO06iMpKFxMHIi32GK48+wxv8V2SUopT4FZ2RK99FDPhz2ObJ9SUJfA6cUmDt1qkhsBmJKRsKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214695; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=5tWL17xtY4KbK/NCVI9WhU1DjcEuaI56sUEhUSi0l/w=; b=WWl4j6pDCEzBC4ahZEO7x1bRVgOZ5bHN1tSAqR/0oLE8AjOFSHydzaC1rNG63usLKL1L1vVWT8KQNMxtA96dfRmgUL6kk+jxPrtpC0QqfQjVB1ccxDX21kITIzZRth1vV5ZNyCpWjTeq/kIRuJJgka/jEdc/koPFy2wLpl2ZEEE= 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 1603214695074747.0986728869351; Tue, 20 Oct 2020 10:24:55 -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-175-3cVD_lriMZqMZv1VFbpXTA-1; Tue, 20 Oct 2020 13:24:52 -0400 Received: by mail-wr1-f70.google.com with SMTP id p6so1060729wrm.23 for ; Tue, 20 Oct 2020 10:24:52 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id m14sm4058942wro.43.2020.10.20.10.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214694; 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=5tWL17xtY4KbK/NCVI9WhU1DjcEuaI56sUEhUSi0l/w=; b=TM6uwLGgfqAWtejAChftcW5omGrXfUZJoFRvQhfhzF1AAcwAlfAZUKFqMV9MmY5K+4Z4E0 txBOWO9Y0G2EUClap5/A8OdKEm2ga6C2+wjbaji5TkEbsiEsw5aEA9vVA/MUCo3wRdheG7 jRAcxLoV81VBa93gAnT4hlm88QJBaJE= X-MC-Unique: 3cVD_lriMZqMZv1VFbpXTA-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=5tWL17xtY4KbK/NCVI9WhU1DjcEuaI56sUEhUSi0l/w=; b=uSqEwFY7uSYTWM2l8WcG/3r2v59NukyyuueUOd3ydsbAtvGzbBppR0PsLHTvaL2xND d9CC2gvzgJw7NAsEayjfXYWrI9iTbrH4pfLTidjGEZMeYFIc6T8z+C5z7F/UdPKrEfU8 1S8QuhI1opkJR6aK0jMZH5KxJ8CdqeuIMuvJ6RQoy12qG8AGsudLkIkf+UEXRB8pPjbb 5VzxuEVFOKHFacGWvmI63EW7R2ioDdIEwjpqhfXPiANfbEVQWMUuyL9XIqGZvBv8CXSW BDbLCp7pP+Q6OGiO4oj+LfhHfO/4btCxo3EaaMQLTU+58muoNF/fIiVYlm4C5A1HJKai tCgg== X-Gm-Message-State: AOAM533uFirtREEg5e5gh3UhFV652C+XaQA5qhqs4t0lxKN0seVONyh3 ZogXq6W5wVmasH4NYObk8CHDX8cVK+E+8IRdz3qk9u8jCQdsAeZ84SoaMdnwGhmg6+wfWBrgRyh VGixR6km5knDqPA== X-Received: by 2002:a5d:5387:: with SMTP id d7mr4648724wrv.224.1603214691182; Tue, 20 Oct 2020 10:24:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkr2NnhtZ8sFt+k39xD3IYZ6ad+P3a32ER6vfyb6CzWdVkw0gV8yUx+9GGe9yOoaqE3Eabfg== X-Received: by 2002:a5d:5387:: with SMTP id d7mr4648699wrv.224.1603214690988; Tue, 20 Oct 2020 10:24:50 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 04/16] util/vfio-helpers: Report error when IOMMU page size is not supported Date: Tue, 20 Oct 2020 19:24:16 +0200 Message-Id: <20201020172428.2220726-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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) This driver uses the host page size to align its memory regions, but this size is not always compatible with the IOMMU. Add a check if the size matches, and bails out providing a hint what is the minimum page size the driver should use. Suggested-by: Alex Williamson Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- util/vfio-helpers.c | 28 ++++++++++++++++++++++++++-- util/trace-events | 1 + 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index a2b084c69c1..bce2cdb2f3c 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -11,6 +11,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" #include #include #include "qapi/error.h" @@ -273,7 +274,7 @@ static void collect_usable_iova_ranges(QEMUVFIOState *s= , void *buf) } =20 static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, - Error **errp) + size_t *requested_page_size, Error **errp) { int ret; int i; @@ -284,6 +285,8 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const c= har *device, struct vfio_device_info device_info =3D { .argsz =3D sizeof(device_inf= o) }; char *group_file =3D NULL; =20 + assert(requested_page_size && is_power_of_2(*requested_page_size)); + s->usable_iova_ranges =3D NULL; =20 /* Create a new container */ @@ -358,6 +361,27 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const = char *device, ret =3D -errno; goto fail; } + if (!(iommu_info->flags & VFIO_IOMMU_INFO_PGSIZES)) { + error_setg(errp, "Failed to get IOMMU page size info"); + ret =3D -EINVAL; + goto fail; + } + trace_qemu_vfio_iommu_iova_pgsizes(iommu_info->iova_pgsizes); + if (!(iommu_info->iova_pgsizes & *requested_page_size)) { + g_autofree char *req_page_size_str =3D size_to_str(*requested_page= _size); + g_autofree char *min_page_size_str =3D NULL; + uint64_t pgsizes_masked; + + pgsizes_masked =3D MAKE_64BIT_MASK(0, ctz64(*requested_page_size)); + *requested_page_size =3D 1U << ctz64(iommu_info->iova_pgsizes + & ~pgsizes_masked); + min_page_size_str =3D size_to_str(*requested_page_size); + error_setg(errp, "Unsupported IOMMU page size: %s", req_page_size_= str); + error_append_hint(errp, "Minimum IOMMU page size: %s\n", + min_page_size_str); + ret =3D -EINVAL; + goto fail; + } =20 /* * if the kernel does not report usable IOVA regions, choose @@ -500,7 +524,7 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, s= ize_t *min_page_size, int r; QEMUVFIOState *s =3D g_new0(QEMUVFIOState, 1); =20 - r =3D qemu_vfio_init_pci(s, device, errp); + r =3D qemu_vfio_init_pci(s, device, min_page_size, errp); if (r) { g_free(s); return NULL; diff --git a/util/trace-events b/util/trace-events index 24c31803b01..19f03f14a33 100644 --- a/util/trace-events +++ b/util/trace-events @@ -85,3 +85,4 @@ 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_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitma= sk: 0x%08"PRIx64 --=20 2.26.2 From nobody Sun May 19 15:58:47 2024 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=1603214699; cv=none; d=zohomail.com; s=zohoarc; b=ZYKF7rgitu/zhkCVCnlZpZbGh9Hvpsme/eVv1/Y8EeBRNXmpApKasqVNxaXWdZhkwri0FEKkjf7zR/4FuAqkfHL7UWFvQ0DqZEpoctKuiP6SKMKcCQ5y0etn657UGa8zCaNGvBfh0EPtgEa3qf0sY1Spb8cWTHgouA6CHI4Mjlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214699; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2LI/wka4VE+L12Rc09SXXqxJoCU9ZXTyFpCDUD5ks9I=; b=Wuei+DJD3luuw2DcefTMyd9NmJQ7YPSriX99FlajbHVoz2NI8FFaEvqxxohhH/SfUn6//+XRiyYugrRc4X/58JNiUvzCit2Dx/T+qw1oQE6fz7DFkl0LeuIrpdJqMF0rkivEpkbfBEU9p/UiF26hALU0KPNqzGYLGp4uemn9Zbw= 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 1603214699890823.5510914170646; Tue, 20 Oct 2020 10:24:59 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-367-4DANXmSZMbOj5qtfY5-rIg-1; Tue, 20 Oct 2020 13:24:57 -0400 Received: by mail-wm1-f72.google.com with SMTP id s25so697636wmj.7 for ; Tue, 20 Oct 2020 10:24:57 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id v9sm3550439wmh.23.2020.10.20.10.24.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214699; 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=2LI/wka4VE+L12Rc09SXXqxJoCU9ZXTyFpCDUD5ks9I=; b=VLfqR1jNJ/9JtMKM1G4C29ZQCoB8ZzAhl4gd38VzwaUAJJtd6pYrW0ydfo3PUl81bRYz59 3l1gy0l026ZmIbKjq025DzJnkR93TebQs2cADukKyUQX9qwTxx6VOavHOAFcW7XPlrsRsU k4xtBpVHRz1/aLFLW+wVaA05kDm8KGQ= X-MC-Unique: 4DANXmSZMbOj5qtfY5-rIg-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=2LI/wka4VE+L12Rc09SXXqxJoCU9ZXTyFpCDUD5ks9I=; b=VEBf6l7J0KHQnrG5M/weI0/EDit8sgmdM34apaHk8jOJovhf1RnpliCyk33pAsq4rS AIhozudvhRTc0Kovskmfd5XwkXLKcgIvlkwXFFtOlwCcHdyKLLm9l3I7qmktqYQ+S0rG yBkVmXyrTozLpBKcKcSlEq/aDBU46f9d2SSQM9ItuJaj0H79PfLMy8bcFjq7IXjhR6Fl 5Qh4IHVjdtF6ZP4Iw3WLegLSYcPQkxfo71PLRMFqvpz9BW+jm9mikF8/V3skCP89eBAv QZLqQNN3AgDMaoD2twkS7j1+6yZW3ltZzanbZiM1fO0DYHxO/dHUNI2T26FW1Dw0tUo3 V1uw== X-Gm-Message-State: AOAM531jAwzlEwGMzwYOENzJJ7Hh+MlIw7f+y6icgxS8l8xZdD30qPd5 xAIXd/sCMHPMUismdL5VoexpEjb5Zh5j4Q0LhfnftxchOjFx/V73WVsuI7lF2KmjP5OikNGlzEf jBNRdGPdAZhS/Nw== X-Received: by 2002:a05:600c:296:: with SMTP id 22mr3943797wmk.134.1603214696116; Tue, 20 Oct 2020 10:24:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeIB4TYfcnfxJqfsuyXCCVmFl0lEuz5mTeZ2Scrwh2ag0Nbi1WMje8I8bII3WNJdYbqt9MuQ== X-Received: by 2002:a05:600c:296:: with SMTP id 22mr3943783wmk.134.1603214695879; Tue, 20 Oct 2020 10:24:55 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 05/16] util/vfio-helpers: Trace PCI I/O config accesses Date: Tue, 20 Oct 2020 19:24:17 +0200 Message-Id: <20201020172428.2220726-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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. Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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 bce2cdb2f3c..ac9cc20ce29 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -228,6 +228,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); @@ -238,6 +242,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 19f03f14a33..b697d2d5429 100644 --- a/util/trace-events +++ b/util/trace-events @@ -86,3 +86,5 @@ qemu_vfio_do_mapping(void *s, void *host, size_t size, ui= nt64_t iova) "s %p host 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_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitma= sk: 0x%08"PRIx64 +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 Sun May 19 15:58:47 2024 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=1603214707; cv=none; d=zohomail.com; s=zohoarc; b=LJMNvQLG4iSOe1cQJUjUH4JweId+eoD/lkzWja2ZGXuEtK/AaIe8T2roQPx+1CtgPIQJCAOJW4j2j2p9/1qI0h+wJq3V2wIijdG0ATzgSZAKomfHctsj7SOcJ47gRdOaHbgJ88zXoEXxYaVSNpMgs5e0u0xljayGJWWGAgI6Nxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214707; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=1vJfrvMuiaSUgd2BJasweCjCskoP5hMk59FTWXR5TQ4=; b=nY+h17Kr45S6WNJr4J/YZmm0CR4cUMqjnCLnZ4VKxfBa+iamQLJGwSSLi1dLCV1R5E0PmVROnLOQuuXtOzoX7gHCgsPZ+szwEGvfDGZIyx7zQYBIgdP/RjiRnovh+14Hfa401yVsGBOzmvGC42l2+/YdMyiO2ymZqeKKt3C8PBA= 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 1603214707302403.5564364474118; Tue, 20 Oct 2020 10:25:07 -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-37-S9hpqKNWNxeJd1bm3xDn6g-1; Tue, 20 Oct 2020 13:25:02 -0400 Received: by mail-wr1-f69.google.com with SMTP id t3so1090237wrq.2 for ; Tue, 20 Oct 2020 10:25:02 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id l26sm3581031wmi.41.2020.10.20.10.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214706; 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=1vJfrvMuiaSUgd2BJasweCjCskoP5hMk59FTWXR5TQ4=; b=ITdBGJeXCU8pUJJvOLqlYb2rV/e0VE1otSt4VsfbhYGgpIdgAZIs+Wcob3dUEmI118JAcz op0Hf5epJrTYFjqnzFL/0QFNNqJ4/ijUqKmXNn+otAHi4PZ8aUbevnidm+lVk8duVR8lCr B5i7ZC+ebRr5Hycqwq+y1pdPUharUck= X-MC-Unique: S9hpqKNWNxeJd1bm3xDn6g-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=1vJfrvMuiaSUgd2BJasweCjCskoP5hMk59FTWXR5TQ4=; b=KLQBq0oLDRW/K2GZtFHHsNfZbPKHMqZtCBqSJvV9TIqf/NksbtpBb3eGhq5adse6KX F8n36dTg+T7GwKzmklwxpiqkbYJUQdANXO8d6od64jjUkVu80n09XLvBXVBTYq6d73fD qXnTBLgAhf6av9HMvWEJ75YHVmo68EbVfTdAr9U6VgtN94T+4FzPkzBbQ/VFhoqwG5SF ly/w2cU+Z/rxPchItPpA1C8LZLl75z4zTVqY6OViVf0kyPuff+aWDs148IspCgtzIlJD wCwV4k8BMsnJ/a1wS3DkeBwjtT0ZPrZy9fhJpL6s6Nhj2UTx62YLeRVV/lIAvVmVbgzk Lekw== X-Gm-Message-State: AOAM5318t2DqGvO58OrqB2r4IKCtDf5c6hXtQanvwUN8YSqSfvJ52FEE 3kQMMUbaXzpP14eMObbK7uqP7yMln86mmZ3x6tYQQSBWTz2SQj7YWYn15QadaJuF9TM3vBM4cSA GmV9H+IFGoQFExg== X-Received: by 2002:a5d:488e:: with SMTP id g14mr4766421wrq.203.1603214701414; Tue, 20 Oct 2020 10:25:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrGZ9MDGoRqBGHFRk0ZNlxEhHddRkKL8Ap7VKPmsoVz9RPDVwRmBNME9hpiuX25IN5fb6r9w== X-Received: by 2002:a5d:488e:: with SMTP id g14mr4766405wrq.203.1603214701185; Tue, 20 Oct 2020 10:25:01 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 06/16] util/vfio-helpers: Trace PCI BAR region info Date: Tue, 20 Oct 2020 19:24:18 +0200 Message-Id: <20201020172428.2220726-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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. Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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 ac9cc20ce29..4204ce55445 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -137,6 +137,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, @@ -146,6 +147,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; } @@ -440,6 +445,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 b697d2d5429..a6a541270b7 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_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitma= sk: 0x%08"PRIx64 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 Sun May 19 15:58:47 2024 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=1603214710; cv=none; d=zohomail.com; s=zohoarc; b=LhQX8VwWWRbzqqq3Oe0s5gGQFfdBtcyMJLNMSw3OwAqaRtym6HcnI4/ccq1o9nPDVC7x00d/D70eGzMpqknz5osP3n8g+4LZmgqxLdHPjaa2JMOafCLOTskaUeT47OjIg4SJjmydiJM30aZ/sIKTo7n1XJY/HNw+eKSZyYisi9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214710; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=NPTgcsyGuNMaq1KpOvK5NDZDqqsXCSXk7ysr+MEn7o0=; b=fmxM5Wk3HkJnQG+blv6C5IGBBOSofV33ejCQP+preS9WSepd9F3xRRAUyj2xj4/DNyItSruZwyPQ++Mysktjrj4o7NMfwVRH9PydV4Yw0u+sx6ZlcG2wHClx7nnOmYcUJc1QoesXePKx3nDy51NXTFaPqdnwTAz4GcWedLgw8ug= 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 1603214710700771.2181719095832; Tue, 20 Oct 2020 10:25:10 -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-420--ejkk1QUPPyq9TRvbOINIA-1; Tue, 20 Oct 2020 13:25:07 -0400 Received: by mail-wm1-f71.google.com with SMTP id f191so626911wmf.9 for ; Tue, 20 Oct 2020 10:25:07 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id g5sm3666499wmi.4.2020.10.20.10.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214710; 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=NPTgcsyGuNMaq1KpOvK5NDZDqqsXCSXk7ysr+MEn7o0=; b=HG09D7G5pSIOhlhnynWXQoBP/GHcESgsnOyYKcdpgwOiRnj9va39SB327XTbi0aVwLvfya qpTDk1JQ/ioi2HFsvnQID0VG/pZbXhsJ5VcR5SnwGYv61DGdzM/KgRz8qk0NS75cXwbxRb zoo9xgguM+Ci0ZdlKV2oO1mBVMbfeCY= X-MC-Unique: -ejkk1QUPPyq9TRvbOINIA-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=NPTgcsyGuNMaq1KpOvK5NDZDqqsXCSXk7ysr+MEn7o0=; b=exnd3E+clpNHUex7stbB10OaL49YUhtjSe9xQINnUf122u9mSGooMHMNFr9j2e/IS/ anPpK2fAGC/Hcr9tNAu4FWB+AL4EK0DM8gaJkWdBIHiznBKhlwZPWcQVpBHvUPm3Q83B Jr3nwgd9A5Xt10Jk+KahKIDdHoV8fdBupQF3WxX+3Dp9MikYrduO5tdd6Xo56aPaCfbk N+FYt1Dpjap8cgkeKwP85XB9cSnA/cbw6EduvWcDlvlgmuLGrX5WBGl7jSHWeRhx9bMn rypDCmuEtTXR/RQvwmbkpQ8tJbTLmaxB31bfgN18hE+BJgK643obxiuYRDSgYSxR5MuV d3rw== X-Gm-Message-State: AOAM533tlyxvmDpWyFTI10BXYrjAWdG7PvajGUykp4VCP3bApZSXbYOf +GP0MbdZQ2OZx4nlyvuH+7xSvAolaKOYsrZhJM7zPit+Dfh5XCiQ+eTj4mLVdyjbfvbjLfSWC5N IgeljRaLf5OUsPg== X-Received: by 2002:a7b:cb13:: with SMTP id u19mr4116665wmj.89.1603214706533; Tue, 20 Oct 2020 10:25:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTIb+5q7yEKp72ydfo56l3zX8thjfJUADnjRhdHe2cneHegiiLrzVGYRd4QwCD8iu+XOFo4w== X-Received: by 2002:a7b:cb13:: with SMTP id u19mr4116643wmj.89.1603214706331; Tue, 20 Oct 2020 10:25:06 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 07/16] util/vfio-helpers: Trace where BARs are mapped Date: Tue, 20 Oct 2020 19:24:19 +0200 Message-Id: <20201020172428.2220726-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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. Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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 4204ce55445..95e010bed6d 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -167,6 +167,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 a6a541270b7..7c92f2f8c1a 100644 --- a/util/trace-events +++ b/util/trace-events @@ -89,3 +89,4 @@ qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iomm= u page size bitmask: 0x 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 Sun May 19 15:58:47 2024 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=1603214715; cv=none; d=zohomail.com; s=zohoarc; b=FpnIq0ETCKrvP/+IP5opX0gya2oISknhyDPglY0O2oVvdOIeC2CPZmSgy8LYiuf2u8OSY982Iknyoa6cfDNXRzqTVgvTmsueyv1HU0BuAtzkXZPRLMsznr7uVZtMzktydMQ3u+S5u6Sh2Qen3COaDk+1Co6gC/EclWcD+G27FIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214715; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=MW4hs5DRcbW11wvGN5ELRGGZ1et4xeNoJny0lCvYhm8=; b=NtYvZC2gZTwcN+Tm+V4ZObm9W1YAHxZeFfEjuCJP9az2BKiGuxjd/4rr0ITZJ6L+0Brhi2lhViFXewg6vg5KbzioCHs52d7RA5/hagu8O+yxbMn87jkmlD3EPpClXjssleivzQn3MwuCRfSz8ABf967KKJjbw2aH6HrUWuJQkIw= 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 1603214715821220.033263577728; Tue, 20 Oct 2020 10:25:15 -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-280-hO2dZOvjNsewriAu_GVCFw-1; Tue, 20 Oct 2020 13:25:13 -0400 Received: by mail-wr1-f72.google.com with SMTP id m20so1069165wrb.21 for ; Tue, 20 Oct 2020 10:25:12 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id t7sm3872736wrx.42.2020.10.20.10.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214715; 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=MW4hs5DRcbW11wvGN5ELRGGZ1et4xeNoJny0lCvYhm8=; b=iH0aNAQKftPI/hhlLu0dc7sL7ZI060+DM8toYEJtUP04FGRy8v59CQD9T8REJNDueJwoCF lg6a6FBqDFk0uMC4QgtINZw7WNY0cL/ro3FZqh7prLxb/HvuY49nm6ud2oprdyxlQ8uJ48 BCyI3AEHnsrZjcgFNSlK3AcllNHlWpo= X-MC-Unique: hO2dZOvjNsewriAu_GVCFw-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=MW4hs5DRcbW11wvGN5ELRGGZ1et4xeNoJny0lCvYhm8=; b=khkBUY6D7LR/xGzecP99SNw/xhZfMSuz2EbG+Ij3s4eALD9aZgTNjVjXD4X7pVB3gY +/oYL5HFsUG4olhFYz6+Rdv/0t00M7St8scMbeEWiWCFlg4S+pYsgXV1a/x+T/ttt2y8 bgg9PY/EJA+jn73IksKA1GtHlp45jv48NftjYlnTsDxe0MABglGMVm5VWPDv+Cx5K6+g vF7FOFiJCRcgm03JyDRYph5xOBZ2SilV7XljIqWHnn0SXrbFBLKJaPELy3o+8HO5Y6ST jL0IuazoFaymvFRCZTdbgOxtrmLXdEGqHEL0AyEsZ+jsZ1VvW7m2aEtiih2yBaY2Trtf iLjA== X-Gm-Message-State: AOAM532JWG0cyoelnPQowG64YuXz3gMFo3eV8ciDcBVWeaU7afaBcgbc 0DfQKMAayrVOmqwJiwc/59FRwV9pHK4d0PKpMgLzbPbo0EJH4Rko4UMxs8t7+LHSf9FkkuedY7o mOSF0wm591+QdCw== X-Received: by 2002:a7b:cb09:: with SMTP id u9mr4007536wmj.109.1603214711415; Tue, 20 Oct 2020 10:25:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLDDgRWubUohEK8dpkfSBjn0FTFvecDCkyxLXaVOvw6pSUm1kGfCvgn9OlAOMudFPTFLYD+w== X-Received: by 2002:a7b:cb09:: with SMTP id u9mr4007520wmj.109.1603214711246; Tue, 20 Oct 2020 10:25:11 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 08/16] util/vfio-helpers: Improve DMA trace events Date: Tue, 20 Oct 2020 19:24:20 +0200 Message-Id: <20201020172428.2220726-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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. Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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 95e010bed6d..98a377a01a8 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -657,7 +657,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)); @@ -813,6 +813,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 7c92f2f8c1a..c396ef4d622 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_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitma= sk: 0x%08"PRIx64 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")" --=20 2.26.2 From nobody Sun May 19 15:58:47 2024 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=1603214722; cv=none; d=zohomail.com; s=zohoarc; b=ctqOXAP045kwAloA5RzzfXs9hB5nnzMVQ9BTS8kj2ZpaLLfMF/D59g8Xraj+7aUmlajhOIsBqGlfEZME3YplO8Kbl3MWuAd3wCotFwpeM2zJuzk17mwX7NDuTy47oGt+vthZyeT9qncBrbcVRw/Y3QeSOp+ZtHFxK8Zc9WTDR0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214722; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=mi5DaGV/dUkNCqis66cfyN2SFYA8ra8zeOd97LUT8kU=; b=IIEuz7j4Gy6eHptGHzFQoE54/Q8OvL2HOlG6HKrRxCXb2oT2Eas19EMZlkaz4yqxh/ohAygXd7LH0ztP9URGLt7tAGnk9EYs9oTqfVnz1d8GNgzqHIcjMwUNLOuX1Bd64icIl+aNlxU+FcjKEFhBLcXejM8EDfOKhkqWYVTCl2Q= 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 1603214722113511.0130875076791; Tue, 20 Oct 2020 10:25:22 -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-376-zeycUr3mOgiP8s4_JNV4Cw-1; Tue, 20 Oct 2020 13:25:17 -0400 Received: by mail-wr1-f69.google.com with SMTP id 33so1057752wrf.22 for ; Tue, 20 Oct 2020 10:25:17 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id u15sm3424259wml.21.2020.10.20.10.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214721; 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=mi5DaGV/dUkNCqis66cfyN2SFYA8ra8zeOd97LUT8kU=; b=SV4xCyqdYawFeIKecED8HM0xKnj4vy8+WD5YBM/TeOFH/2wCk8Ou9F5rlGhefd1W6O+BIa pAgdtq7U0EYpv8x6NackK13j99k9Q2oFMLzv8kwAXaLNQm7zsqySumFpHA/WJp1FF2FFAW +GKX+XTnl7BcPCBVE3ctAleK+Knz4hI= X-MC-Unique: zeycUr3mOgiP8s4_JNV4Cw-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=mi5DaGV/dUkNCqis66cfyN2SFYA8ra8zeOd97LUT8kU=; b=MwZNiMIkTame8sg9Khxp/Rn1BzFeRvogKCt4wOiX2jmMZHCd6xohTCluSjJgs9mZrJ pFiCujiBdJpL7RBoYeuJ2cDgQp+cVuPHmyJrjSv2384hiDg6Yw0n7VK9fyOJkQbf8q4R RCH4rvLZ93g3XA/4HDXLVpePWI90Qd52qFd70dTo+os/ziuQakhAAXjwZ7UlcZdkaSpD rt3LXSqPrxtMt/LphtUDkNz9Wf3XU3+4jMl0ulqrlcBWhEKfZE8isDCpHqYjr1Rgewz5 9s0CcJMaKW5ZvijlYfNUcnlggj7Df5bq697FYv1xM4hZn5tCayMbRlV+L7t5E3EzgdYB wO7g== X-Gm-Message-State: AOAM530q2sX0rU9E4tdffXCpjcEOaQa8l02p8LcA/47+L194q3ZHCxeH wdqj/+qm78+9pl6oDm2gLbs4Kw1kNRKdtA0hH/uAh1vszzk+Ibt4SbrBvWjA4o18rgLsf9RtzWH 291QI3G2MwnjoOQ== X-Received: by 2002:a5d:424e:: with SMTP id s14mr5132810wrr.149.1603214716591; Tue, 20 Oct 2020 10:25:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG9hQMQCJr8oW3+wIRBf+VgqLQBPOtr895Dwm9KyVx/mzvfA40fqLkQga0OZhK2VjPwQnJZw== X-Received: by 2002:a5d:424e:: with SMTP id s14mr5132786wrr.149.1603214716352; Tue, 20 Oct 2020 10:25:16 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 09/16] util/vfio-helpers: Convert vfio_dump_mapping to trace events Date: Tue, 20 Oct 2020 19:24:21 +0200 Message-Id: <20201020172428.2220726-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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(). Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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 98a377a01a8..6a5100f4892 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -551,23 +551,12 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device,= size_t *min_page_size, 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 c396ef4d622..3c36def9f30 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 Sun May 19 15:58:47 2024 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=1603214728; cv=none; d=zohomail.com; s=zohoarc; b=WELNTVVzs0xlJPSdyVGc7prcJHOKaxP4sj9CC6E49LOYApxMtHkMj32Q5MgA08TeHQRPFnHwmkl1ZnPoJEKUON8mZOEmbwbuhNptfcVt9WrdE9blSv6ELyVmjdNk+glyqdSUWmg+bfFSW4c/ccsbgu051/qjc9WbKCVb6zpOpPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214728; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=MLOm46KfCEikq86Y3pgvNvo5u9OAutjap0o+dhD/k3Y=; b=MSi+54o2NLoXJDaLZRwkl8mdLLQVCAOvqdlfJ2XG4VgbALhaL0dq8jUjMxaPpKa8zS30yRpOIHRzPoYvI3AM7BJMHe5Ve95a/SIVxrubggt2RPz0iFfDePZyJq577/ugvuFM5kWLQp/mo2o59i8xcp8baR4IaFbCntuND8uWkP4= 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 1603214728013831.915510043727; Tue, 20 Oct 2020 10:25:28 -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-283-p2egXAHwM4OZMyFTZIfe-A-1; Tue, 20 Oct 2020 13:25:25 -0400 Received: by mail-wm1-f71.google.com with SMTP id u207so699729wmu.4 for ; Tue, 20 Oct 2020 10:25:25 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id y7sm3579711wmg.40.2020.10.20.10.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214727; 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=MLOm46KfCEikq86Y3pgvNvo5u9OAutjap0o+dhD/k3Y=; b=hkmZBmCWu1PaQyueKxe5e6tg9/H+SKaRgmzFTsjYYbutVGKmFyvgdKzFMwhx2vxetn2Uw7 tXFnvglVztsatauvlpJjiKRslTVzHNl3qQmEVD1LHx5iCQ2qtzmYTS9B82q8BFyQCb6QQI 7Z54rTwVfzfIq0q+PCcCu9UIQTSQFZs= X-MC-Unique: p2egXAHwM4OZMyFTZIfe-A-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=MLOm46KfCEikq86Y3pgvNvo5u9OAutjap0o+dhD/k3Y=; b=do4CvcRlzj/BD9wkgymIxgGqRvm01RI+TXZ9N7MBb9Yw2OwmVf/uS/9tNsjdPDsT9S UUNAm1kPAK3NyZvlgpFeiJPKAxpOqzcZcjovQLBntevDenJCJnV893C9G3LfS6r72uWr bXDtmy1zHtEPTvww0BiIKzbYoIZ8LHKcoKmEGIhNPFbyCA1uUTQS2FYaHPlG0KwZ4x7r +oe7qfzkEzVbdJq9vqYxsA6P44IygoDs62WWkOLSKkthjuP53iB9Y3XHzDVhXqEVbe0b xk62WXEJHZel5EmAEwGnbTFzxO4aeDTHnWQNokRew7nqSJ8HOWdF8pGab4sNbf2uP9Fd RsEw== X-Gm-Message-State: AOAM5314l9QAb1Px381aKmYQ/UifoG05TgOUe1/N8SCoLns75cg6ECAT PIynr3Kw1kCJvROvBo1b+DTwaszOSaddrB1pVWhzBA9L+Q2ejzCCDtN92rS7BqaDH3odGqJLJL7 RR74zZB8Bik4gUg== X-Received: by 2002:a7b:c341:: with SMTP id l1mr4171332wmj.80.1603214721817; Tue, 20 Oct 2020 10:25:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4BCYIdH3y+v314ecWJ7QzYvUGZoGOW233TZDHOfC4Nw0fGTCX6iw6Y2XUy6c9lI9/PzLQmQ== X-Received: by 2002:a7b:c341:: with SMTP id l1mr4171309wmj.80.1603214721583; Tue, 20 Oct 2020 10:25:21 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 10/16] util/vfio-helpers: Let qemu_vfio_dma_map() propagate Error Date: Tue, 20 Oct 2020 19:24:22 +0200 Message-Id: <20201020172428.2220726-11-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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. Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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 5cb346d8e67..4b97a904e93 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -19,7 +19,7 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, siz= e_t *min_page_size, 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 8335f5d70dd..428cda620df 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 @@ -990,7 +990,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); @@ -1437,7 +1437,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 6a5100f4892..8c075d9aae7 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -486,7 +486,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, @@ -501,6 +501,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; @@ -509,10 +510,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; } @@ -754,7 +756,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 Sun May 19 15:58:47 2024 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=1603214732; cv=none; d=zohomail.com; s=zohoarc; b=nNA/HI+yF6FfPhtXboTUX9wgrEnbUMgdn1BdrxF7/ULls4sO+iV39cXmLDlvrXBy018seuKa/M5Duc8gEJflfHCeuUEsJGhl6ZrCE4IagUPdvta7bOvfumDD6RYHR3pUTNcpIG+mrExKgGA6vvsdCOfIhD0KJdFuE/A7Iryky0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214732; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=7LYaPDykygFtAxF5+J+IEj33yA5rBInQCpCJf3vg5O0=; b=Hgrax3FOSinY3LCeX0sWHkWW8XN2DtP9f7XStb83YlI5RIyeimoJM2g+wmMqLjnwZHBu3Hkyz3sIGyeSt/Qzfoe3z5luSVYvSM9DDs5CudwfHSBeJjRbOTzLfucZ/cRQl2vpjYUd4iphjf/FI2U7O2C9/myrosVFV4ZfWMFFpG4= 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 1603214732522316.6249839824137; Tue, 20 Oct 2020 10:25:32 -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-293--plMQSKmMhGfcmm6G-up7w-1; Tue, 20 Oct 2020 13:25:28 -0400 Received: by mail-wm1-f71.google.com with SMTP id w23so629954wmi.1 for ; Tue, 20 Oct 2020 10:25:27 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id c130sm3589568wma.17.2020.10.20.10.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214731; 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=7LYaPDykygFtAxF5+J+IEj33yA5rBInQCpCJf3vg5O0=; b=V2g0z9c/3Wvlr7DWtOaJBFnNS+3BG7E41kTmXYmb/FLmvNkuQq9SIVll/nVtR14F+Uuqcx Ah+wNcZOrSbTVCNeVoNgMWaBZ5dp1dg3Hrt91Khj9frRYtSdd7DDwhjvYHC4CyKZhgTK4F IoiU9QS7W14wHUURB5tbJ1X4e3ehjfE= X-MC-Unique: -plMQSKmMhGfcmm6G-up7w-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=7LYaPDykygFtAxF5+J+IEj33yA5rBInQCpCJf3vg5O0=; b=EEU46okTAWbS3IsRJX6kxBx5TtbcNxafQOby7rRJ6PYTO7ox+EXud1TVWXUmaKq2oJ JzXfAAT1sgDRb/yr6oc5EK/IGaOPSWzwS1cLTX/OLbEfZgyysb32K07edOlOhZiX2s3X KBT8oWfs5N8HXsxAos1BE6nPsgFuHRgFwPflt8lQTmgXeBzm+ouEYiEcczR0DnqEvhil acVZYGpqeiEJd2qH4pw8FjszcvCzPJPLxMjLw2I8A2J8vX25IGCEdww7Cp/et2tYteik XjVUnEgCDilJLbpySUxyYNk5gEUDIE7UHDsQMhs526Ge94VNusP6cArzMzoRiGikgsEW VfOw== X-Gm-Message-State: AOAM530YxeYiZfoGZNgwBKyD5laMQEdBePAxuqxumz0Ka/QHHfmXSpXC ypjmsuL9qG+R73IzZX9ZOGsGfyqCcW1RtmX/fhxSMrxhC5hXGTzMn/p2lyImoB2lbNw43lF8kwV 5hzg9hfOD5UU/0g== X-Received: by 2002:adf:fd49:: with SMTP id h9mr4977127wrs.115.1603214726913; Tue, 20 Oct 2020 10:25:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8bH8yADkwParrzpk3HEb+VNDg6I537fQ5Ih2TTJxKFYwGhLQLS70gFcu/Hh5/9p+PagnMuA== X-Received: by 2002:adf:fd49:: with SMTP id h9mr4977099wrs.115.1603214726693; Tue, 20 Oct 2020 10:25:26 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 11/16] util/vfio-helpers: Let qemu_vfio_do_mapping() propagate Error Date: Tue, 20 Oct 2020 19:24:23 +0200 Message-Id: <20201020172428.2220726-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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(). Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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 8c075d9aae7..fb180becc4f 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -639,7 +639,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), @@ -651,7 +651,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; @@ -787,7 +787,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; @@ -798,7 +798,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 Sun May 19 15:58:47 2024 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=1603214735; cv=none; d=zohomail.com; s=zohoarc; b=id3gzQAX0xbq55HK0TPHB4vkEQ7Y/xFkXwFZrulm0tnD+0LhwbdKaIjeecFMhXhxg4RR65Tkk9TbWL9u7LVXr0uGoOXGBf0Rjo94VIxavRtnvI6ZomW8IpD43229Qd5D4O3qxuWWUIn4YG1lcGpNncL0lDCCIA2boAiRtnfj2z8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214735; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=5a5Qtly5s7u76u/yf9nlzhnNv2l8V+1UybhgW6H3apI=; b=XJ8sd/R0ynrLSSMnP0theI8TrKJupx3TzOt68c/u80soXjdWSoAcXjWeKvVu2D5bDtcrPwfTTY4HmfFgaegPfXn7vxuOFbhCLcgbob0CXNGp9AWnx8X19AjuF/aEnkzNeIhz0jrYCkyuvKXUiMaoaffnD2Q4UslKu1f3najcZ1k= 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 160321473551959.83532115453363; Tue, 20 Oct 2020 10:25:35 -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-327-7gi-s7OpO4S6OD9EwKV1wg-1; Tue, 20 Oct 2020 13:25:33 -0400 Received: by mail-wm1-f71.google.com with SMTP id v14so699273wmj.6 for ; Tue, 20 Oct 2020 10:25:32 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id 30sm4074936wrr.35.2020.10.20.10.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:25:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214734; 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=5a5Qtly5s7u76u/yf9nlzhnNv2l8V+1UybhgW6H3apI=; b=e8trDWWH2xVSsh324pzLP594Qmw60rxG2cJpTXu9QHDJGago67mi/6Kn+4b1dG6j++qCPw FMf2RQTbprZEbace7N2bkJyJsd7Q/4dy8kCUXve5pQgR0QPgoCuGFhbqum54+MLOPVzbyu KDC3D6WIqoLHK/77BmomvlUeouG0/bY= X-MC-Unique: 7gi-s7OpO4S6OD9EwKV1wg-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=5a5Qtly5s7u76u/yf9nlzhnNv2l8V+1UybhgW6H3apI=; b=MEXuBXpizJrsznuxORvCG+A6Tdry/aqTINd2iZMlHe37/spx0VMWMb9/qB2PnnBVAn D5gCro9rP7gcVZ3OpAE1bT4LzaFsGYQDtoti3ZNp63YH0NHDhw78XbZjOm5or0GL0o8h 3B5x+97JP9SJpv15XWAH7szJvbkKDlTV780KbA+1ACdn2Nqa8S3PBtqdwpCHavsKZj9l lCM20TDI0cVLUiTKlDElZFtWvyyMuSI9430C5hFA/X9qERO1iauREM3topsCBPWAj6au oK0DhIptev+9p6+/bgYNHG7s2mBVl779+7IF/LS6I0w2cak4PFgKIznsz+bqqv0qqWhg PLPg== X-Gm-Message-State: AOAM53358kjQ7BDfmR91MJeKU/4bnTkkniXpV7LRDduL74p+e2/Hueuf NzdWoXZ/+8KroJHwbza9eDNukdrwd1tstJz9MPD1rIyhnS5V+2PBjG56EIQC01cdDB8X2XhRd35 gE5LwAHQJ6OW7yA== X-Received: by 2002:a7b:cf13:: with SMTP id l19mr4006422wmg.74.1603214731953; Tue, 20 Oct 2020 10:25:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNO6zieAEOVpRkAAZXHzH2TRDOFEjvVim9G2bC4wnC7CtCOxOX4XTYh9uYJnJAzriwgN4DAQ== X-Received: by 2002:a7b:cf13:: with SMTP id l19mr4006409wmg.74.1603214731750; Tue, 20 Oct 2020 10:25:31 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 12/16] util/vfio-helpers: Let qemu_vfio_verify_mappings() use error_report() Date: Tue, 20 Oct 2020 19:24:24 +0200 Message-Id: <20201020172428.2220726-13-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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. Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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 fb180becc4f..874d76c2a2a 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -691,13 +691,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 From nobody Sun May 19 15:58:47 2024 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=1603214740; cv=none; d=zohomail.com; s=zohoarc; b=P/mt8tooKGFUPDGdBWPIENO1YhcpAvX2hf/eGlmpb4HDTOh9kTQ1oBfkwjbh6sAVXmkTUkIlZT+BjjgvLpuYx2LwH6EYnLa7CpPsMoJx1/7KpQsOWk+14TWp8qXV+W+Si5rq8Po++o1tGRFg/wsoHRBzkOZYJcBKvODh3g42NyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214740; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=eZkLlN89Iq0UKFZMaguSCtb5VglCsG6fVsQioou3iC0=; b=PAbd/Cfh4WVrfIRr2DfuAR0XMGDh8EAFjpsHq6OcYdj7eKXeSwmwWKwVztiU+PZEbrloIO3ljHIlgfUcKRl3PzKDxKyaDQqcVEz17SS4ikdDiIqH+IgN2YqSPApYQ+P4ooNJYOCLFF3mWNJt2qCfxQMIiWFgM57JYg6zhULeFKo= 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 1603214740723372.0254434786257; Tue, 20 Oct 2020 10:25:40 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-OgLiFS3dN6C-LBw5zolEEQ-1; Tue, 20 Oct 2020 13:25:38 -0400 Received: by mail-wm1-f72.google.com with SMTP id c204so700954wmd.5 for ; Tue, 20 Oct 2020 10:25:37 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id e15sm3828127wro.13.2020.10.20.10.25.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214740; 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=eZkLlN89Iq0UKFZMaguSCtb5VglCsG6fVsQioou3iC0=; b=dEpkEuTRklja18vWcyhPkhcNWeWUtSWwmDDDBEjxjPkW0Cqkklakfw8cemRJNhP5aNkU44 LmdqS9/4Mi4hT1ydvXRBIgRDxSvWVUpnyJ7iClO+NzTpmlrsd7ZBr6/dPQgrCQhBSRkzu0 fHnRTIXJq4v6GyOZvQAuWstBQsbrfRU= X-MC-Unique: OgLiFS3dN6C-LBw5zolEEQ-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=eZkLlN89Iq0UKFZMaguSCtb5VglCsG6fVsQioou3iC0=; b=BGHMo1nh1Co7eN3rsngeZfrmHKhBsDpVMwJlhLVw6bYz7P3KjniDlfFa11w9c8shq0 8kloNXV4TRsaippqjTZAiqePXIbbLnMhIQI/8niPZ7fS5zNCy6ZGAEgu8NJvZ5YUNlmV s/wlPUTDyPeUeeJCJ8dV5dkfsGe1KDnxC6idX1cGBvp9QvXUzIlyddirmn9aSvZXf4ce l2BOIoKzUWtdK+1T6mjO8Yz+8WCJs3xlccEkknfVw6wjxaXV7L0X6dB625gy3+ImfBy7 NtlAnCa6flDfEfm6lJB7CxdWgTync+So7H67FX+f2SqOcgf1Ie+vvPjVnfW/qKckox7S zk6g== X-Gm-Message-State: AOAM530CUz+ini/Vq0Y3SxuPPhsZ6CoFCSRM0/eItyGXbCsCg8G9y0rb pluO2KEI1okI1xuotGlq46AUWkK6tVSKnrH3fU7/bwgPcyFwbqg9nq07dayuGlfd1+bDC0PY3fS rzj0G4E9I7Mh8Kg== X-Received: by 2002:a1c:e256:: with SMTP id z83mr3840484wmg.37.1603214736949; Tue, 20 Oct 2020 10:25:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPxgxvry3qnSBWMW7op6uCVMPNxihKFgeJQxyemOnMBMpKHwypjEaeOeMvobG8NAq9yBqwBQ== X-Received: by 2002:a1c:e256:: with SMTP id z83mr3840453wmg.37.1603214736670; Tue, 20 Oct 2020 10:25:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 13/16] util/vfio-helpers: Introduce qemu_vfio_pci_msix_init_irqs() Date: Tue, 20 Oct 2020 19:24:25 +0200 Message-Id: <20201020172428.2220726-14-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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) qemu_vfio_pci_init_irq() allows us to initialize any type of IRQ, but only one. Introduce qemu_vfio_pci_msix_init_irqs() which is specific to MSIX IRQ type, and allow us to use multiple IRQs (thus passing multiple eventfd notifiers). All eventfd notifiers are initialized with the special '-1' value meaning "un-assigned". Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- include/qemu/vfio-helpers.h | 6 +++- util/vfio-helpers.c | 65 ++++++++++++++++++++++++++++++++++++- util/trace-events | 1 + 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h index 4b97a904e93..492072cba2f 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -1,11 +1,13 @@ /* * QEMU VFIO helpers * - * Copyright 2016 - 2018 Red Hat, Inc. + * Copyright 2016 - 2020 Red Hat, Inc. * * Authors: * Fam Zheng + * Philippe Mathieu-Daud=C3=A9 * + * SPDX-License-Identifier: GPL-2.0-or-later * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. */ @@ -29,5 +31,7 @@ void qemu_vfio_pci_unmap_bar(QEMUVFIOState *s, int index,= void *bar, uint64_t offset, uint64_t size); int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e, int irq_type, Error **errp); +int qemu_vfio_pci_msix_init_irqs(QEMUVFIOState *s, + unsigned *irq_count, Error **errp); =20 #endif diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 874d76c2a2a..d88e2c7dc1f 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -1,11 +1,13 @@ /* * VFIO utility * - * Copyright 2016 - 2018 Red Hat, Inc. + * Copyright 2016 - 2020 Red Hat, Inc. * * Authors: * Fam Zheng + * Philippe Mathieu-Daud=C3=A9 * + * SPDX-License-Identifier: GPL-2.0-or-later * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. */ @@ -230,6 +232,67 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNoti= fier *e, return 0; } =20 +/** + * Initialize device MSIX IRQs and register event notifiers. + * @irq_count: pointer to number of MSIX IRQs to initialize + * + * If the number of IRQs requested exceeds the available on the device, + * store the number of available IRQs in @irq_count and return -EOVERFLOW. + */ +int qemu_vfio_pci_msix_init_irqs(QEMUVFIOState *s, + unsigned *irq_count, Error **errp) +{ + int r; + size_t irq_set_size; + struct vfio_irq_set *irq_set; + struct vfio_irq_info irq_info =3D { + .argsz =3D sizeof(irq_info), + .index =3D VFIO_PCI_MSIX_IRQ_INDEX + }; + + if (ioctl(s->device, VFIO_DEVICE_GET_IRQ_INFO, &irq_info)) { + error_setg_errno(errp, errno, "Failed to get device interrupt info= "); + return -errno; + } + trace_qemu_vfio_msix_info_irqs(irq_info.count, *irq_count); + if (irq_info.count < *irq_count) { + error_setg(errp, "Not enough device interrupts available"); + *irq_count =3D irq_info.count; + return -EOVERFLOW; + } + if (!(irq_info.flags & VFIO_IRQ_INFO_EVENTFD)) { + error_setg(errp, "Device interrupt doesn't support eventfd"); + return -EINVAL; + } + + irq_set_size =3D sizeof(*irq_set) + *irq_count * sizeof(int32_t); + irq_set =3D g_malloc0(irq_set_size); + + /* Get to a known IRQ state */ + *irq_set =3D (struct vfio_irq_set) { + .argsz =3D irq_set_size, + .flags =3D VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, + .index =3D VFIO_PCI_MSIX_IRQ_INDEX, + .start =3D 0, + .count =3D *irq_count, + }; + + for (unsigned i =3D 0; i < *irq_count; i++) { + ((int32_t *)&irq_set->data)[i] =3D -1; /* un-assigned: skip */ + } + r =3D ioctl(s->device, VFIO_DEVICE_SET_IRQS, irq_set); + g_free(irq_set); + if (r < 0) { + error_setg_errno(errp, errno, "Failed to setup device interrupts"); + return -errno; + } else if (r > 0) { + error_setg(errp, "Not enough device interrupts available"); + *irq_count =3D r; + return -EOVERFLOW; + } + return 0; +} + static int qemu_vfio_pci_read_config(QEMUVFIOState *s, void *buf, int size, int ofs) { diff --git a/util/trace-events b/util/trace-events index 3c36def9f30..ec93578b125 100644 --- a/util/trace-events +++ b/util/trace-events @@ -87,6 +87,7 @@ qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, = size_t size) "s %p host 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_msix_info_irqs(uint32_t count, unsigned asked) "msix irqs %"PRIu= 32" (asked: %u)" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitma= sk: 0x%08"PRIx64 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 Sun May 19 15:58:47 2024 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=1603214745; cv=none; d=zohomail.com; s=zohoarc; b=FzsNDb03tVbQLt6xdibR31M5UY4rYjbxTpw2j2PqSZYPSmF1X0iCHvrj5/ANWKCH2PRuTIHfB92AHK6SLp9NVmuYYzdx6553FDiXqUytbtX6B1rAQzhPYafBAQHDLC1PfYA9gEnMgefeEUjZ9T1nX4WuIlrGLpbIKkf41xdQGF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214745; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=5HJ76d54/0AtdtuncdqQBgCT9XMbn0n9hcSFQu6+E4Y=; b=NW2uwWGmB8EqJf4GdPs8+23rzbItK91KpupQL7AZEJ+xNfEfAiTSKAHXSJekdJHD9hy8qR88C24Th4XC5w25oubS0HRV5JWuKBFStNT+0cZtMBnqD6BOkzNTlGS19sCwvGFokKsUQZW1P7HphcephtIaY0qK6wtDp3gH9ajN32U= 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 1603214745718450.03548747636205; Tue, 20 Oct 2020 10:25:45 -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-550-Xe_Y5qp_MuymaWKtYEBgAQ-1; Tue, 20 Oct 2020 13:25:43 -0400 Received: by mail-wm1-f71.google.com with SMTP id u5so629228wme.3 for ; Tue, 20 Oct 2020 10:25:43 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id x6sm3915111wmb.17.2020.10.20.10.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214745; 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=5HJ76d54/0AtdtuncdqQBgCT9XMbn0n9hcSFQu6+E4Y=; b=BU2me73iQfZwk6XJhPPKoiuVnJ4LMjM4DLpMaknL37m4fGfF206m0D6/2bAackXLG1hTmR r33w7uW4pu6DibnoljrW7KnMqGMUtavr4sZyz1kSD7WNK4pgz/+VMgrOskqfV442eT8R5f 1eyU0vN+k4FXtvQo5odcLkgp/rA911M= X-MC-Unique: Xe_Y5qp_MuymaWKtYEBgAQ-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=5HJ76d54/0AtdtuncdqQBgCT9XMbn0n9hcSFQu6+E4Y=; b=esSU3uxkv4DxJq3Mmiv0dww8KiewDg8VaHzpzhUGmdfFT9rJEQHz6bGQuF1lwfGSTr 23dQsLYaPhYsAodlOAraEY6jm6nAmxTvqq7fT40DXxLpV6jxOMGRY9777yU+t5F5tSOM CpGvG5GcYW2vvNygSBt8jfjhLXr59zT/6Gl1S0abZeGSNko1MT2qsUgsI9qESf6D2vEx LCCvcPPB8PJGsicqjQpUiR1mMy2DUEWunYPqgAtt7GFMXlWOgETGScNbNUtEeJdDmpJ+ lRaOCkXx/b+Scab32NfIcI22Oj+9FHUVTy8VTnMPM59DRP8yTdRbVMJmSFIs6HnKP/kH ikiA== X-Gm-Message-State: AOAM530tYTxdR5Vx9q0TkV6IY+UwrQsgae5GBASbllngSZYwDzs2GRxy qemObeM2YXBQKsK8thCplaOmuS+hKfdEeKv7kdND4YNsV2TNc44L0GnuHMaLCMvBuwwf+Wy1c6o BlYD5HEM2DY/dSw== X-Received: by 2002:a5d:4141:: with SMTP id c1mr4610260wrq.113.1603214742014; Tue, 20 Oct 2020 10:25:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3pj7tvpzRZVzk1YoArJIv86HBeIpS1HVT9E+PVCZPgHNJ/gM5CpjYzBYCdusHB9SskEdFiQ== X-Received: by 2002:a5d:4141:: with SMTP id c1mr4610231wrq.113.1603214741771; Tue, 20 Oct 2020 10:25:41 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 14/16] util/vfio-helpers: Introduce qemu_vfio_pci_msix_set_irq() Date: Tue, 20 Oct 2020 19:24:26 +0200 Message-Id: <20201020172428.2220726-15-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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) Introduce qemu_vfio_pci_msix_set_irq() to set the event notifier of a specific MSIX IRQ. All other registered IRQs are left unmodified. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- include/qemu/vfio-helpers.h | 2 ++ util/vfio-helpers.c | 35 +++++++++++++++++++++++++++++++++++ util/trace-events | 1 + 3 files changed, 38 insertions(+) diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h index 492072cba2f..4c06694e03a 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -33,5 +33,7 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifie= r *e, int irq_type, Error **errp); int qemu_vfio_pci_msix_init_irqs(QEMUVFIOState *s, unsigned *irq_count, Error **errp); +int qemu_vfio_pci_msix_set_irq(QEMUVFIOState *s, unsigned irq_index, + EventNotifier *notifier, Error **errp); =20 #endif diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index d88e2c7dc1f..18142e6be86 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -232,6 +232,41 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNoti= fier *e, return 0; } =20 +/** + * Initialize a MSIX IRQ and register its event notifier. + * @irq_index: MSIX IRQ index + * @notifier: notifier for the MSIX IRQ + */ +int qemu_vfio_pci_msix_set_irq(QEMUVFIOState *s, unsigned irq_index, + EventNotifier *notifier, Error **errp) +{ + int r; + int fd =3D event_notifier_get_fd(notifier); + size_t irq_set_size; + struct vfio_irq_set *irq_set; + + trace_qemu_vfio_pci_msix_set_irq(irq_index, fd); + irq_set_size =3D sizeof(*irq_set) + sizeof(int32_t); + irq_set =3D g_malloc0(irq_set_size); + /* Get to a known IRQ state */ + *irq_set =3D (struct vfio_irq_set) { + .argsz =3D irq_set_size, + .flags =3D VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, + .index =3D VFIO_PCI_MSIX_IRQ_INDEX, + .start =3D irq_index, + .count =3D 1, + }; + ((int32_t *)&irq_set->data)[0] =3D fd; + r =3D ioctl(s->device, VFIO_DEVICE_SET_IRQS, irq_set); + g_free(irq_set); + if (r) { + error_setg_errno(errp, errno, "Failed to setup device interrupt #%= u", + irq_index); + return -errno; + } + return 0; +} + /** * Initialize device MSIX IRQs and register event notifiers. * @irq_count: pointer to number of MSIX IRQs to initialize diff --git a/util/trace-events b/util/trace-events index ec93578b125..3a56c542a94 100644 --- a/util/trace-events +++ b/util/trace-events @@ -88,6 +88,7 @@ qemu_vfio_dma_map(void *s, void *host, size_t size, bool = temporary, uint64_t *io 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_msix_info_irqs(uint32_t count, unsigned asked) "msix irqs %"PRIu= 32" (asked: %u)" +qemu_vfio_pci_msix_set_irq(unsigned irq_index, int fd) "msix irq %u notifi= er_fd %d" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitma= sk: 0x%08"PRIx64 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 Sun May 19 15:58:47 2024 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=1603214752; cv=none; d=zohomail.com; s=zohoarc; b=VGuDrY3lK67nqodEwTAR8Db569PJ2m1U9Kotos83ZbBnQ/5HN1KjJnoS6Acs+N4Imxomofd5zFvgYGykMP+E03diDBpDfs5qSACczi6HHWFsLltFJazKroU1ASRo3WY/5m/v/V0zr/qktznl+3FfNMGNu2KsDdCeE02S5Q1tq70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214752; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Hs3zGfCdZlBKam4T/j2OWFCOhMeEDGMYaVQGrpVc+SE=; b=nJPMgPCVBq+Yatyh0PQ95D9w/0+H8M/7P5Ja9Zv3GUGPgQb+0pbZyhWzkI7pg3zA1NKJ9kNJYK8nL98BxMhN2Qr78nl42eoaQx4dDJRxrA52mQHNvOOBi8hxK+YUfXvrCdU2AtoIg0+RyQJK1p+g5D0eS0cy7hey7WXWi/nXlvs= 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 1603214752884858.3584994494707; Tue, 20 Oct 2020 10:25:52 -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-101-03_OTFWfMKOEz8SWi9oLjg-1; Tue, 20 Oct 2020 13:25:48 -0400 Received: by mail-wr1-f70.google.com with SMTP id h8so1081507wrt.9 for ; Tue, 20 Oct 2020 10:25:47 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id l6sm2603241wrt.7.2020.10.20.10.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214752; 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=Hs3zGfCdZlBKam4T/j2OWFCOhMeEDGMYaVQGrpVc+SE=; b=izc0EieR3vReheszrT8zAV1djTi0lQ/pxVtnmKa+v+p7vgafdL2LNMs4AKK2T3zZ9Blzcu FQfEadNOswyoLdlGRWnCSBJd59gq03NUrGya117wtc3vYoHNoTanWJUkp6FkEBAnkKjJ+J MMhdz4O6q6RHI9ifC97cQe+NaVlAZC8= X-MC-Unique: 03_OTFWfMKOEz8SWi9oLjg-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=Hs3zGfCdZlBKam4T/j2OWFCOhMeEDGMYaVQGrpVc+SE=; b=oteZbDWNzm2RmivCiy3TDpDXSuAP2UBX7lwhFv7XlwzmpHZmknpNbIEpc060DDy2Ra y1V1LoNr3/t4FzkomQGkxot7TqoKYwNJ0d/qlY6a2e5EsMJvuJ9P/IFPh3BxSM1JwCVe 7fdhidX7ZtRJ6Xk7SEI21cYyR5S6nHvpwkniXMDM50XDxYSpu9Xg3Wi4vKIEq+aJgCGw 8y4G0/7o6+9q1Jb7o/4+jv8NMcf/ScWvO5KHMuUejZWLIqw2qzaUPeEBC5d5YXfy8Fe3 4OTKxsGV+3L4Xl7fE9h4/XMzBB3tX2XwaSxHDDx/3ON1Tf1wpPoKvS8Zf1C+x36yyYFd RUZg== X-Gm-Message-State: AOAM532FM6WV+OXbiLixa5SLX2l178CpYdxcQbQkszNt2SOPr9sIBPU2 W0wBReySkUpOT08a9LTQGtf7MlnQkchRZDEySLNheSNSaU4Jt74/15bT0QvwJoZNLNs2KCjZgPd 9lNIxglFYhwteVA== X-Received: by 2002:adf:e681:: with SMTP id r1mr4520764wrm.181.1603214746949; Tue, 20 Oct 2020 10:25:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMj4E/AHJERHS9kwzdxk/tKIGBO/AsaNfcJhduQIrcKzhAhfvSBA1rgRSi61/Gk/T68DYdsA== X-Received: by 2002:adf:e681:: with SMTP id r1mr4520753wrm.181.1603214746804; Tue, 20 Oct 2020 10:25:46 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 15/16] block/nvme: Switch to using the MSIX API Date: Tue, 20 Oct 2020 19:24:27 +0200 Message-Id: <20201020172428.2220726-16-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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) In preparation of using multiple IRQs, switch to using the recently introduced MSIX API. Instead of allocating and assigning IRQ in a single step, we now have to use two distinct calls. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 428cda620df..a5518ad5bac 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -691,6 +691,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, Error *local_err =3D NULL; volatile NvmeBar *regs =3D NULL; size_t min_page_size =3D 4096; + unsigned irq_count =3D MSIX_IRQ_COUNT; =20 qemu_co_mutex_init(&s->dma_map_lock); qemu_co_queue_init(&s->dma_flush_queue); @@ -784,8 +785,17 @@ static int nvme_init(BlockDriverState *bs, const char = *device, int namespace, } } =20 - ret =3D qemu_vfio_pci_init_irq(s->vfio, s->irq_notifier, - VFIO_PCI_MSIX_IRQ_INDEX, errp); + ret =3D qemu_vfio_pci_msix_init_irqs(s->vfio, &irq_count, errp); + if (ret) { + if (ret =3D=3D -EOVERFLOW) { + error_append_hint(errp, "%u IRQs requested but only %u availab= le\n", + MSIX_IRQ_COUNT, irq_count); + } + goto out; + } + + ret =3D qemu_vfio_pci_msix_set_irq(s->vfio, MSIX_SHARED_IRQ_IDX, + s->irq_notifier, errp); if (ret) { goto out; } --=20 2.26.2 From nobody Sun May 19 15:58:47 2024 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=1603214755; cv=none; d=zohomail.com; s=zohoarc; b=I4/qBTr/z+6RHINUMy5eebE+GCx6pC0w1PLYThu+TogMcQmpSV7W7xhwLrgoEH0aEzVyhC+uRw6xDy1gbdM87N7aMevkyMzART2hArZNDL6fFCBKu5y2HE7qWcE4akszWMb1F8yAqHgzLMUL3mB2jV5TDfUfrOpTmXu8iQeLYW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603214755; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=8oqdstf17QDkdRiVc5f+XWE4kqpKFWIiKO1K+jCCJoE=; b=FfI21seHtEOFngWkJcQu67h7NrGKDNlsU83XkK7RU1SWsJiEHaMYobhKUjTCCziOhBn92us2VS4tObz7vBCdlGTkyvSGVSW2gQyfmCqupTeXWav7Cx4YwPSpsF6goqQJMP1EFXIfRuf3aJpt/C9n+Z90uyqtCMI1QsAi4NxfX8c= 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 1603214755612549.8870102730422; Tue, 20 Oct 2020 10:25:55 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-505-HDnsAFLLM-qQ1Wi5Idu6wQ-1; Tue, 20 Oct 2020 13:25:53 -0400 Received: by mail-wm1-f72.google.com with SMTP id z7so703288wmi.3 for ; Tue, 20 Oct 2020 10:25:53 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id 130sm3827184wmd.18.2020.10.20.10.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214754; 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=8oqdstf17QDkdRiVc5f+XWE4kqpKFWIiKO1K+jCCJoE=; b=KR2cjJuk279B2kEKGTOaljWETHwi43Z4ZGVy5O14fx78Tq65WpSv7KqqByEjldqnl4jjpY NWxHcDJaW20keo6+DInm890CE3go5I8ho0tBRm1rXkeV/JFdSmAzrFUjynpxGhsD3aNBeN Dbmw25sYwm9nVhCSV0OMtJCW/fDAjKg= X-MC-Unique: HDnsAFLLM-qQ1Wi5Idu6wQ-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=8oqdstf17QDkdRiVc5f+XWE4kqpKFWIiKO1K+jCCJoE=; b=cAbFAcEjbEhT0zrf8fzx33vKXsOLGPdZZJOdNM821mMIzfdXveRqlFUisAoiIU/QAB yR4TcLRs/NjHwiDfstdh8uwZAKHwl51CmWeQkktwA2K5r6CzeS2aa2Dt+ZL+u+5xy7SK T/k0UPyaAEd7W0qeni6JEdG3T88JwfaDieZh4foA878/o9BYJlpxslDHzaKxPf6SwkKb ascPng2fD95HRQrg9wkCHk1TaMTioed/eUhuFmJQfLmHu0rn5DwkCwuUAHWfF+C3K79L XfRZIopZ5bxt1ZWJo/ENWFFTT+PyHAfbfuRFSxNyP8hyMhi60ImlgL4ReYJxFIvth7Kb yCbQ== X-Gm-Message-State: AOAM5321FApVG5Kp9nFerY1Ip0CVH4k//Hbkh+eYrlv9m5JkH7EIXQCA OivQCW2wGNPN43DrLqHVfAyj2sfuhuug7LZn9taOkzBxRW1oG42Q2HhIHE1xZfEqHex2kwjBzRl JCx5jSjSopZi8iA== X-Received: by 2002:a1c:49c2:: with SMTP id w185mr3997332wma.70.1603214751974; Tue, 20 Oct 2020 10:25:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdcxOTOZoM/gU99BUW1BC35eAswqh/g0UQilPWU36+0grXfNSITkALfOWA2eGpPksUWVEXTw== X-Received: by 2002:a1c:49c2:: with SMTP id w185mr3997314wma.70.1603214751797; Tue, 20 Oct 2020 10:25:51 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alex Williamson , Stefan Hajnoczi , Max Reitz , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 16/16] util/vfio-helpers: Remove now unused qemu_vfio_pci_init_irq() Date: Tue, 20 Oct 2020 19:24:28 +0200 Message-Id: <20201020172428.2220726-17-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201020172428.2220726-1-philmd@redhat.com> References: <20201020172428.2220726-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) Our only user, the NVMe block driver, switched to the MSIX API. As this function is now unused, remove it. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- include/qemu/vfio-helpers.h | 2 -- util/vfio-helpers.c | 43 ------------------------------------- 2 files changed, 45 deletions(-) diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h index 4c06694e03a..f42371d25d6 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -29,8 +29,6 @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index, Error **errp); void qemu_vfio_pci_unmap_bar(QEMUVFIOState *s, int index, void *bar, uint64_t offset, uint64_t size); -int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e, - int irq_type, Error **errp); int qemu_vfio_pci_msix_init_irqs(QEMUVFIOState *s, unsigned *irq_count, Error **errp); int qemu_vfio_pci_msix_set_irq(QEMUVFIOState *s, unsigned irq_index, diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 18142e6be86..83d6eef13fb 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -189,49 +189,6 @@ void qemu_vfio_pci_unmap_bar(QEMUVFIOState *s, int ind= ex, void *bar, } } =20 -/** - * Initialize device IRQ with @irq_type and register an event notifier. - */ -int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e, - int irq_type, Error **errp) -{ - int r; - struct vfio_irq_set *irq_set; - size_t irq_set_size; - struct vfio_irq_info irq_info =3D { .argsz =3D sizeof(irq_info) }; - - irq_info.index =3D irq_type; - if (ioctl(s->device, VFIO_DEVICE_GET_IRQ_INFO, &irq_info)) { - error_setg_errno(errp, errno, "Failed to get device interrupt info= "); - return -errno; - } - if (!(irq_info.flags & VFIO_IRQ_INFO_EVENTFD)) { - error_setg(errp, "Device interrupt doesn't support eventfd"); - return -EINVAL; - } - - irq_set_size =3D sizeof(*irq_set) + sizeof(int); - irq_set =3D g_malloc0(irq_set_size); - - /* Get to a known IRQ state */ - *irq_set =3D (struct vfio_irq_set) { - .argsz =3D irq_set_size, - .flags =3D VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, - .index =3D irq_info.index, - .start =3D 0, - .count =3D 1, - }; - - *(int *)&irq_set->data =3D event_notifier_get_fd(e); - r =3D ioctl(s->device, VFIO_DEVICE_SET_IRQS, irq_set); - g_free(irq_set); - if (r) { - error_setg_errno(errp, errno, "Failed to setup device interrupt"); - return -errno; - } - return 0; -} - /** * Initialize a MSIX IRQ and register its event notifier. * @irq_index: MSIX IRQ index --=20 2.26.2