From patchwork Tue Oct 20 17:24:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 270862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ADF1C4363A for ; Tue, 20 Oct 2020 17:26:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 85A262222D for ; Tue, 20 Oct 2020 17:26:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NpHj5u5n" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85A262222D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvPS-0000ds-FY for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:26:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvNU-000661-Dj for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:24:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvNI-0007t6-BD for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:24:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214679; 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=NpHj5u5nzFmogoDmzMfDX1XZGeVGgZgUvCEl3u9lUsol6cxNb63n6h/3xeDDz5xOe3Tj7E fcmrsVOwFmqKa3Sk+SOHGaEg4gLGS1JliHSQZHFFKolwXeBXpyBw1XWCwdJYAxpvKH9hz0 KrpUKtUunGPoPm2i1EByHfJ5GZCd6Qo= 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-381-I9rNd_PFOt2U18-NRSigeQ-1; Tue, 20 Oct 2020 13:24:37 -0400 X-MC-Unique: I9rNd_PFOt2U18-NRSigeQ-1 Received: by mail-wm1-f69.google.com with SMTP id w23so629563wmi.1 for ; Tue, 20 Oct 2020 10:24:37 -0700 (PDT) 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=naIiiN9JB42wHinG6c7c16nkaXk1z9trCx7NunV+zqpHi65dV1ogQoGIpFCnD/FFQR eCuN2k1ePnp7PwHLw1Clc+2jpSQ30hrnPXrjyXrLp7FkeSFezx1R6i3UnNKVzJJ8ypZG KzK9F8SD1LPNGKCN38M9j6hhT95vsUj0Een582FtYxgZ3y02ortlE3drSKVAVuu3w+GZ Sr179y+Le1EKaqgh87vTI8rAjm77k+MHVPIP19VaIJSTVuOSnSeHxOEkLGRywnr/bb/z lJ2fhtReqZ2SHjnftJvbJ2Uz5Pjfxbpn2ya20O2XTir0/oR51d25fhEvEmpYhTHX9rfX tzRA== X-Gm-Message-State: AOAM532PEs6hsrbMaoziJ76inp3cpw9hc/HYPucQ1RQINEoWEL/zGIbJ Q78sgx9I7fpfs7GwiAfIQY4kLFqYXKCRJ48/raexyiASYVYU6qP30zi0H5gcHI2DVp9diOHDi/8 j/X2RPxyIqQa8tLY= X-Received: by 2002:adf:f305:: with SMTP id i5mr4694389wro.346.1603214676003; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:16:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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; } - s->page_size = MAX(4096, 1 << NVME_CAP_MPSMIN(cap)); + s->page_size = MAX(4096, 1u << (12 + NVME_CAP_MPSMIN(cap))); s->doorbell_scale = (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment = s->page_size; timeout_ms = MIN(500 * NVME_CAP_TO(cap), 30000); From patchwork Tue Oct 20 17:24:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A56BC4363A for ; Tue, 20 Oct 2020 17:27:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DE4AF2222D for ; Tue, 20 Oct 2020 17:27:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WyZU4Qkw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE4AF2222D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvPj-00010g-RY for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:27:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvNW-00066p-HG for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:24:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47143) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvNU-0007tt-9I for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:24:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214683; 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=WyZU4Qkwh2mre6b0n34ps3+93EyzuaWEmVDLZfMP4ukMP4Ft81i63z6I/eVOnPXCQZe7K7 u9qKS3+mLRt6xRbWMWydKUJXgwmg8zanHhL+BL96JNKznHrUEMISF1l0BId2jUoyKwIIYO GUQePMy9Md9WGiy1BUl5EFiy8iAI/xA= 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-101-c-KoPa7xMj6f4N_FrVrq0w-1; Tue, 20 Oct 2020 13:24:42 -0400 X-MC-Unique: c-KoPa7xMj6f4N_FrVrq0w-1 Received: by mail-wm1-f69.google.com with SMTP id w23so629618wmi.1 for ; Tue, 20 Oct 2020 10:24:42 -0700 (PDT) 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=rEavoYqAoA/GIVJdXwsp/pnoPBxMC47Bh1WgVPMMKdl06CqXd8lJoWcAOaqg+YuX1m yiJbRK7dOCAVccE9bvjm27NDNDle7g8OD/cWHXMNkWOA72s2E0wOzEh5oZuF3PAVS7SA 7HdgqRx3QqDkpuxI0rA1d6Fa/XojTFeUl8ni1M0FcLw9sDy8pAjT1GwYZkINSAeErmo/ 9IyfimABwkxnxackC/39VNFV0E6pMM+aaVfK/u+snR0LWeDTZ2crrPZAwbLV/leG82Bh k4K5iUZrAY8QrNx7N9LBg8zueCYMm0xLNOxEgdUISvvtxRwcXswMBWJgjkE9uG6t10JW 9nCQ== X-Gm-Message-State: AOAM533+0WzL+8/xQpHgy2AO98E5RjfhK0IdBlsRIoVGK5TTpkbbdlfz DsrJU9mEjRKJ3h6bRMYTWLjJtjaHQPYwrkcSIVWxQKU45M+lbERb2n1AYH9pT2Va80W+KR8qk3B eJFXJULgYIrFdvAo= X-Received: by 2002:adf:e412:: with SMTP id g18mr4641262wrm.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:16:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw qemu-system-ppc64: -drive if=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw: VFIO IOMMU Type1 is not supported Suggested-by: Alex Williamson Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daudé 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 char *device, } 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 = -EINVAL; goto fail_container; } From patchwork Tue Oct 20 17:24:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C2D4C4363A for ; Tue, 20 Oct 2020 17:26:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5D7C2222D for ; Tue, 20 Oct 2020 17:26:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WSVgmUKJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5D7C2222D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvPD-0008Qa-LP for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:26:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvNa-0006A9-Sp for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvNU-0007uV-A8 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:24:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214690; 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=WSVgmUKJD3uOU0NzYT5SadSMVZZSpynSLhK7jAyqy6ijPjbVJUUMm8AQ3AbiB0TYNNU8O5 ZcGnl/LgC/7mRPh0z6aramWO9hvBUa+0MEcv/HrL4mHjMrDDjZfbijDN4qpMLps1Hzko3O HVLrhmY7/nIz8tVrv8gY5NSIaIXKStQ= 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-162-ZUmhjPJZN2Kg7NtrtIFeAw-1; Tue, 20 Oct 2020 13:24:47 -0400 X-MC-Unique: ZUmhjPJZN2Kg7NtrtIFeAw-1 Received: by mail-wr1-f72.google.com with SMTP id m20so1068814wrb.21 for ; Tue, 20 Oct 2020 10:24:47 -0700 (PDT) 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=XnYoVK45a9K7oz1MlE5FXQ3gDMEiiAxM9/2nHxmO8YakV1chKOhp8Oo/0egA3m/uan CA9qZrgLL6jWkzonGDuKzPcMhk7ad14cbkG16/gOyzb6O1Wenp8Iv6FQB1dMzTvYUhJc wtaAILKDaE8YeiiMQOqkQP8k48LUp4FQAEOkcAULqRh/oF3iATc6lWzkaFWGpFgEhfta QZkaqYO2Det0+S1BwQzRdkyWKEKll60QyrmePRa2mkrmtLbXwHxDtRpN111XdG5FAlDj BzHs06V0KeUiBHrO78UTHuZ8g8KGYSOUvY7F7cQRpohOOgUleIhms1I5gw6DWh4NW4/3 Zi7w== X-Gm-Message-State: AOAM532/idDPuw4k1XgI54fzVCZmhk4M9EekD6h4/0Vj5CYRlrbiFMsU Dd6vGac6CoDHE5ZcVu/o/ctIYQdadwi41hlY+8//7sZjZYqVjqhTv+VxWJbW1VZKyo2QBin4AB+ lupVjyrWYcKUSY5U= X-Received: by 2002:a7b:c384:: with SMTP id s4mr4059799wmj.77.1603214686177; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:15:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 @@ typedef struct QEMUVFIOState QEMUVFIOState; -QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp); +QEMUVFIOState *qemu_vfio_open_pci(const char *device, size_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); 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 = NULL; volatile NvmeBar *regs = NULL; + size_t min_page_size = 4096; 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; } - s->vfio = qemu_vfio_open_pci(device, errp); + s->vfio = qemu_vfio_open_pci(device, &min_page_size, errp); if (!s->vfio) { ret = -EINVAL; goto out; @@ -724,7 +725,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, goto out; } - s->page_size = MAX(4096, 1u << (12 + NVME_CAP_MPSMIN(cap))); + s->page_size = MAX(min_page_size, 1u << (12 + NVME_CAP_MPSMIN(cap))); s->doorbell_scale = (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment = s->page_size; timeout_ms = 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) /** * 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_size, + Error **errp) { int r; QEMUVFIOState *s = g_new0(QEMUVFIOState, 1); From patchwork Tue Oct 20 17:24:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 270861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97440C4363A for ; Tue, 20 Oct 2020 17:29:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C5EFD2222D for ; Tue, 20 Oct 2020 17:29:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dTUtH8i2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5EFD2222D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvRX-0003nC-Po for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:29:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvNd-0006Cq-AT for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvNY-0007vM-4V for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214695; 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=dTUtH8i2FWIpnzrSy2Q8YFdeHrBr9MoSapIhjNp5FkD1g+hJz9myrO0LosGwkR4xsSPfGc ELkj6oJFJndHc+kGRf2+vMb4D7rkmX430Z6P6b4C1yN6Jt/7qr4pxTl3Pl3FlmjyqyRL3J +Xj84fvh6lY+hMBowEzx8EvuXpK/h9E= 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-535-NhqtAEFnMQ2IlyQtLaKxjg-1; Tue, 20 Oct 2020 13:24:53 -0400 X-MC-Unique: NhqtAEFnMQ2IlyQtLaKxjg-1 Received: by mail-wm1-f72.google.com with SMTP id l22so628081wmi.4 for ; Tue, 20 Oct 2020 10:24:52 -0700 (PDT) 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=iPzQjJ+66fne23H5nwxoNImksNcm6FGodwhcI5PE2/gR871pgSdz/Yls66URBGIElx AS3uXpz3ZhgVqp6I4wM3jfG5NZidkioQlT9BfNAHR5JHcqOUxzmwoxtrfsT/ZX9TkCaD qrwi9XVf9Syg/HxwwLQiAoIQflRegKqDUOiB1+22gr74BQg52A5v/N72ZHMUCMRBmkwX MWbJyT8eHoO61FCDYMkeiCvm+AnQ22iqZx4lq+mbyvWtE7s2VMT0a+rVIunZ0TL2Bzkv kkV62H1kXVlMCT6F0snYr/zHpWkx46EYhgURFGn3dULxEoPdPxb2R3Vmw3uv7v4TLAY2 i2Xw== X-Gm-Message-State: AOAM531KS7iSgiJEYqNEwbjAekv23nTUae1oxt+HqT1Yofr0uBHh84QN k37vXLJJAqUOOaz+aSbotzHfTnnxc++7Zl3Cjpfj892vfSpKNGutdv1oubE6uC67FLOHqG7ODPA 73aKTwZ3QCX8mmIk= X-Received: by 2002:a5d:5387:: with SMTP id d7mr4648723wrv.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:16:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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 @@ */ #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) } 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 char *device, struct vfio_device_info device_info = { .argsz = sizeof(device_info) }; char *group_file = NULL; + assert(requested_page_size && is_power_of_2(*requested_page_size)); + s->usable_iova_ranges = NULL; /* Create a new container */ @@ -358,6 +361,27 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, ret = -errno; goto fail; } + if (!(iommu_info->flags & VFIO_IOMMU_INFO_PGSIZES)) { + error_setg(errp, "Failed to get IOMMU page size info"); + ret = -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 = size_to_str(*requested_page_size); + g_autofree char *min_page_size_str = NULL; + uint64_t pgsizes_masked; + + pgsizes_masked = MAKE_64BIT_MASK(0, ctz64(*requested_page_size)); + *requested_page_size = 1U << ctz64(iommu_info->iova_pgsizes + & ~pgsizes_masked); + min_page_size_str = 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 = -EINVAL; + goto fail; + } /* * if the kernel does not report usable IOVA regions, choose @@ -500,7 +524,7 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, size_t *min_page_size, int r; QEMUVFIOState *s = g_new0(QEMUVFIOState, 1); - r = qemu_vfio_init_pci(s, device, errp); + r = 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, int 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 bitmask: 0x%08"PRIx64 From patchwork Tue Oct 20 17:24:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 270860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12ED5C4363A for ; Tue, 20 Oct 2020 17:29:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4099D2222D for ; Tue, 20 Oct 2020 17:29:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VLfqR1jN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4099D2222D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvSO-00058y-UO for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:29:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvNe-0006FX-CY for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:53365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvNc-0007xK-LV for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:01 -0400 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= 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-584-dleu-RyHMY2FhpRBJlTWBA-1; Tue, 20 Oct 2020 13:24:57 -0400 X-MC-Unique: dleu-RyHMY2FhpRBJlTWBA-1 Received: by mail-wm1-f69.google.com with SMTP id 13so707464wmf.0 for ; Tue, 20 Oct 2020 10:24:57 -0700 (PDT) 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=ev2MUjEQmpT7oGA7WDWF1exugG27X2U9V8l60vf3fupjzqpIw5TYiQ71Hy5/FWLD77 8osiiLtLg+XjB0tcSLddqAXhjJzop0fHahP6wxFnmPur1WAzDv8YRrkBo8WsPyDi7QST PyzPQoBxuNDebVyoBKXSPnLyrA+LOva1UHFQaURvA+OprwhHU3S4ROhI07+TtADm7qxq N55jJnSIQlB1d/pLHiyb+/54LmbbcaMFyWAmPamdg3YurBscwfxObkS5tNiRS4whMM8+ wKHhIG+Mlwr8LHJ0edEqFxWQUffRadaOzy0BsJy8QFqkKwyM67pp4AUx9dvGd7rshWJ9 4YOw== X-Gm-Message-State: AOAM533P1s6Q20rXasSvn2BjvokI/fZ39EaDzEmzzE93gnNlxOpT3PQD 0bG2UJCxbAHwvQ5am7OYvikAak+kC6zDOLnij4pFg8AHW8hZ0EXifwITo+yiL/vT+WbdTh7KWt2 uCtJPuHvqWJ2aqGk= X-Received: by 2002:a05:600c:296:: with SMTP id 22mr3943800wmk.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:15:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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; + 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 = pread(s->device, buf, size, s->config_region_info.offset + ofs); } while (ret == -1 && errno == EINTR); @@ -238,6 +242,10 @@ static int qemu_vfio_pci_write_config(QEMUVFIOState *s, void *buf, int size, int { int ret; + 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 = pwrite(s->device, buf, size, s->config_region_info.offset + ofs); } while (ret == -1 && errno == 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, uint64_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 bitmask: 0x%08"PRIx64 +qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, 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_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" From patchwork Tue Oct 20 17:24:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29F60C4363A for ; Tue, 20 Oct 2020 17:32:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 575A821D7F for ; Tue, 20 Oct 2020 17:32:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ITdBGJeX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 575A821D7F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvUv-000812-8r for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:32:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvNl-0006Xr-5i for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvNj-0007zY-By for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:08 -0400 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= 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-489-E1KUOwycNfSYAJqq3vU9Lg-1; Tue, 20 Oct 2020 13:25:02 -0400 X-MC-Unique: E1KUOwycNfSYAJqq3vU9Lg-1 Received: by mail-wm1-f69.google.com with SMTP id u207so699377wmu.4 for ; Tue, 20 Oct 2020 10:25:02 -0700 (PDT) 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=H+VDtiSQoQqIbEZhK96CcXG5Mlv0MZymLbOktyoRHT6jF97/D4UNWKHmfXo61gQEwc MI98ZP8KaBmAcHcBPdLQh2Ug3yrO86FjjB2VoFSZXs8zFvxo5odBqFl6ca7qeuiX9+q6 i09PkQkQkXxFHr1qMF0DBdMA0qLfD9s13zsFSQEy9qXdOYf6RhLm1jqLBEfpMUa7ADK5 QB+/dRnLB7xrCOaY0fHqONwcu+HoW6IrKY3blC5vXO7MZtYuqiSdG2Vsa56RAd0QqOXU cYFiQmB889ZP3F4Iou+DLe9RMaGei0YNPwDxI/b8XXiA8flBzEfKwxfqWocCRcQ9icVQ Mjww== X-Gm-Message-State: AOAM531Fvbh3QRCK875rCrJPf4rD9+pICNJ02RXe92P/yfudNCszc+0z fbMuKSZUX2Gjk3IeaCk94K0gprc5l5EgGFnCOITSPMvmP1WVK8tko8QxAWpx+2yoKSWl+sfIrXW KKp7nnMJP9jvz88M= X-Received: by 2002:a5d:488e:: with SMTP id g14mr4766423wrq.203.1603214701415; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:16:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For debug purpose, trace BAR regions info. Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daudé 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) static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, int index, Error **errp) { + g_autofree char *barname = NULL; assert_bar_index_valid(s, index); s->bar_region_info[index] = (struct vfio_region_info) { .index = VFIO_PCI_BAR0_REGION_INDEX + index, @@ -146,6 +147,10 @@ static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, int index, Error **errp) error_setg_errno(errp, errno, "Failed to get BAR region info"); return -errno; } + barname = 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); return 0; } @@ -440,6 +445,9 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, ret = -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); for (i = 0; i < ARRAY_SIZE(s->bar_region_info); i++) { ret = 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 bitmask: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, 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_ofs, 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, uint32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PRId32 From patchwork Tue Oct 20 17:24:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 270858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E46F6C388F7 for ; Tue, 20 Oct 2020 17:33:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4889F2222D for ; Tue, 20 Oct 2020 17:33:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="caLNDZQL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4889F2222D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvVh-0000wZ-5c for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:33:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvNo-0006fI-FH for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30486) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvNm-0007zz-I4 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214709; 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=caLNDZQL+VS2JPqtnqUUSmNR0TWLEwUfgl4Gk5mLmJSjR+kg02YKO+3wWehrQzpD61a0Zl XOZmFNLE1SlpqyqemD3QvJ57reu3rC8qLfXsLW/Ze7Fl+iKcTYL7Xpx1sDlja1XS5/pYSF 4jSPqcGjAU88x2c7sgSp2D2pHFDb6DY= 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-59-AmDWGNjCNei632n_vBxEog-1; Tue, 20 Oct 2020 13:25:07 -0400 X-MC-Unique: AmDWGNjCNei632n_vBxEog-1 Received: by mail-wr1-f72.google.com with SMTP id n14so1082959wrp.1 for ; Tue, 20 Oct 2020 10:25:07 -0700 (PDT) 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=GVs0ii4URPo6YZYS7wINmMJOg5Ggz92HgePdnUC+U+kGOibAvmP/w52CPMi9U+KRgl mvQ+CNEilGFgWr5Q8ET8RjFTjQIqyrMS/VYZoO86+fJOzMJGhw65KcI9mjmlj5+ZpB5a tGgS00usTxHOCVolh+RybTBlbXe1O+zg4yjTJO2g/dRkr2LDJusQsSAaxzK7mQoEXShw 97MWtOO9ZDj5Dpo8m5DneA3k286W1WirEUjRoRKpaxRfxQAHUHJB9vq5VARKODS6Ufnc o7T6/aveLO0G1a5TD+VDfTQ2zDqPLQ3n2BaBFPSc6rb0gO3FcM9cJrkagzajgMa74GAe /6dg== X-Gm-Message-State: AOAM531QQBOdjFj2Oel2KH3lovSG9yND6uP1wyXG7NhW2N+WV9mi+85/ QnWp251nJ67AuqpqJUdIh9WYbvf2KjyaSARlx4dxymp3AGnigzfGNGFWZn9uo03VH3AxRr4vP15 3/4Ho2ILy0z5nAhA= X-Received: by 2002:a7b:cb13:: with SMTP id u19mr4116671wmj.89.1603214706560; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:16:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For debugging purpose, trace where a BAR is mapped. Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daudé 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 = 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 == MAP_FAILED) { error_setg_errno(errp, errno, "Failed to map BAR region"); p = 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) "iommu page size bitmask: 0x qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, 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_ofs, 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, uint32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PRId32 +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" ofs %d host %p" From patchwork Tue Oct 20 17:24:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 270856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1047FC388F7 for ; Tue, 20 Oct 2020 17:35:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 559252224A for ; Tue, 20 Oct 2020 17:35:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iH0aNAQK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 559252224A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvY8-00055o-A1 for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:35:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvNv-0006uO-QB for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50503) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvNr-00081G-Vr for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:19 -0400 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= 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-189-xOPL4GsTN1OBMhOgI4MU8g-1; Tue, 20 Oct 2020 13:25:13 -0400 X-MC-Unique: xOPL4GsTN1OBMhOgI4MU8g-1 Received: by mail-wr1-f69.google.com with SMTP id 47so1071417wrc.19 for ; Tue, 20 Oct 2020 10:25:12 -0700 (PDT) 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=YviIslMQkZvyILf4aquhsZP/00vO8EhDEg+sZFZG6hgco5xi/Zl+tG+UdMgQA03aEJ fXrtXxHgKfO/EG2Z7N66k1mQFU4/E1XyfdEed68LV8Le7ZTVwYPR5L5a/fH6lWaiO03F ASyUb1aX4vJrpPBhg3LHDc7/daz/c/51xU19TDkYKByYWZ07UCNInzQupuuccnKcPkO6 Mhb3qDcWaEaVxSNIXbYrdK+5Q0PDC+rSAVp7WkD9Fn32p/wIIu8w2+Lz34km6+ru47E4 IQGnbD4nf1z7DNdu101s55aZzk2uKZLiUDDj07a5XogMoYkG8hrwrjkkgEqEkc/T/gCp Wl3Q== X-Gm-Message-State: AOAM533+kC/ifme0K5N79JAt5/vChh/a2uhLOEMPI1SDhRkNzyjXQomZ ZwRdcBpK4FLdtQc1eZTrSDf+hqagirMowibB20OnNN3MQIucGJtQ/tgNclEYKel0CTV/KXknfD7 3BBOM8BwmZ3Zs30U= X-Received: by 2002:a7b:cb09:: with SMTP id u9mr4007541wmj.109.1603214711416; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:16:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For debugging purpose, trace where DMA regions are mapped. Reviewed-by: Fam Zheng Signed-off-by: Philippe Mathieu-Daudé 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 = (uintptr_t)host, .size = size, }; - trace_qemu_vfio_do_mapping(s, host, size, iova); + trace_qemu_vfio_do_mapping(s, host, iova, size); 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, size_t size, } } } + trace_qemu_vfio_dma_mapped(s, host, iova0, size); if (iova) { *iova = 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 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, 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 bitmask: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" From patchwork Tue Oct 20 17:24:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9312AC4363A for ; Tue, 20 Oct 2020 17:35:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0592F2222D for ; Tue, 20 Oct 2020 17:35:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AqCg/DVe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0592F2222D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvXO-0003jn-02 for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:35:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvNy-0006yV-V1 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvNx-00085g-6g for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214719; 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=AqCg/DVe1FCJjuS4VXLl+QTTiifsPY/yU4xxdeTpYdPuu7zfErWteTl6B4KZn9aQO1F4Iu DVNA5bD7cltWkyjbb/9YNRXbFLdILQ6baXqgtPdfsX0jcX08OKyBvdhKPvDnjPQw7OtgJJ e0JV3mL9UJRCvEYek0yzkcn+7W+0/20= 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-505-AeKxyWpEP1CdsQmUUa6dZw-1; Tue, 20 Oct 2020 13:25:18 -0400 X-MC-Unique: AeKxyWpEP1CdsQmUUa6dZw-1 Received: by mail-wr1-f70.google.com with SMTP id x16so1071088wrg.7 for ; Tue, 20 Oct 2020 10:25:17 -0700 (PDT) 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=I4Xtp7cVIAlfCh1NGNvZOHECb1vxCEDObNoubuDU4CTTOhAsuVWP1kHn9xFvYVw+9K MoB5VuBEj4QG2MFcPiTbHDSHwBec1PF2txBwsWbb64Ne+GXf9dYFOdnVbZhKk1w0D74Q jARlAOwP1F2cE5ncX17Aq8QGik/6y9P6CZUAqRiP0nGTBQPln/LjU6480h/hMa0ubSEx G4KSZmkN3LwF3XLw9bmGnp0mp6LuKl1Sm2O6wat/YiWfHllxP2Sue/blX9rAA1CjpdtB pRKVARNss3I/uJKHCZKH9WmdDthr95HFanj6BLoBxaN4il9Ol+H3jb1ElDBVTCU7fe5I GmYA== X-Gm-Message-State: AOAM530N7CKPsg4X1Q1/T3KVDxmY07lTakj5Jg9VYwMmFJtyz5ObC4EU Une6p4O1ZAYyakJ2n0xetZ6CfojYyX25lG2zyb8UFS1NDWpJxZcQ5kl3d2DhfwpnqYDDlJtUEru p0enk3OvyJtjfzHY= X-Received: by 2002:a5d:424e:: with SMTP id s14mr5132806wrr.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:16:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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; } -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 = 0; i < s->nr_mappings; ++i) { - qemu_vfio_dump_mapping(&s->mappings[i]); - } + for (int i = 0; i < s->nr_mappings; ++i) { + trace_qemu_vfio_dump_mapping(s->mappings[i].host, + s->mappings[i].iova, + s->mappings[i].size); } } 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 int 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 size 0x%zx" qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p size 0x%zx" +qemu_vfio_dump_mapping(void *host, uint64_t iova, size_t size) "vfio mapping %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" From patchwork Tue Oct 20 17:24:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE1B9C4363A for ; Tue, 20 Oct 2020 17:37:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D637A2080D for ; Tue, 20 Oct 2020 17:37:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bVOidU16" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D637A2080D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvZf-0007GL-6Z for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:37:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvO5-000721-8K for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:33393) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvO2-00086w-FN for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214724; 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=bVOidU16IldnhHLQjGk+L2d5IKQYnnW4X+PmQ67lfK2E8WrF8LUyELfreEjpVKdZa0pPXd lUrIz1PxXrIjutpGcOmGaAHnUAmcJZH0O2OexAnpCtS8wgnLuxe1HcmnpkacwAr+0HLs96 l0EqMNUaoJCDzPjAJq8ypVAVjumaKr8= 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-114-QzpgvYIKPfO_IkjCWEt5TA-1; Tue, 20 Oct 2020 13:25:23 -0400 X-MC-Unique: QzpgvYIKPfO_IkjCWEt5TA-1 Received: by mail-wr1-f72.google.com with SMTP id 2so1076716wrd.14 for ; Tue, 20 Oct 2020 10:25:23 -0700 (PDT) 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=J26tlQfLO+wT2gzem04c8toBjrtxzDej1ymNEope7W1Fjubj1vUXbxDbkO0W+r9KAk l7vRgDjspi/UBZbKonV4K3DuLoypLmHWJ2vMTeQPf+4sqAsmPTAsQRf4lNQeCQHm8+YN fR9ftvI4MuHzwQPNUiCeY1U5VeRoiytlQmdfOiTHFD3Wjxg9ZooQpPeIbFAazNq7JvSW 7v/EHcv6f1GupvDmIGNwCP8ogtqEYiKYXBkM/+sGveTJRJ/KF2PhHcn2ptWGue3HIJsE DwnJDQRNnLSinDtKGAwq1uaVizGJOYoaz7o4uvqJI6F45o/LQRiFvdIxaC79Sb0Jk7OZ szMg== X-Gm-Message-State: AOAM533ABGDgQ1yIwx7K0EmUyQ2P8h1paEfEQVyX+0SN3xLAwqTbVcDM StCwm7pjWv7mbCSHd0EGORGeZDWSCvCxuWi/pAFVc99aB0N1/JQhNVaipSHzx/vA8SJoKMko/o7 +lMr6JcvCBUOcxX0= X-Received: by 2002:a7b:c341:: with SMTP id l1mr4171329wmj.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:15:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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, size_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 = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); + r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova, errp); if (r) { - error_setg(errp, "Cannot map queue"); + error_prepend(errp, "Cannot map queue: "); } } @@ -223,7 +223,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, q->completion_bh = aio_bh_new(aio_context, nvme_process_completion_bh, q); r = 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 namespace, Error **errp) error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } - r = qemu_vfio_dma_map(s->vfio, id, sizeof(*id), true, &iova); + r = 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; } @@ -990,7 +990,7 @@ try_map: r = qemu_vfio_dma_map(s->vfio, qiov->iov[i].iov_base, qiov->iov[i].iov_len, - true, &iova); + true, &iova, NULL); if (r == -ENOMEM && retry) { retry = false; trace_nvme_dma_flush_queue_wait(s); @@ -1437,7 +1437,7 @@ static void nvme_register_buf(BlockDriverState *bs, void *host, size_t size) int ret; BDRVNVMeState *s = bs->opaque; - ret = qemu_vfio_dma_map(s->vfio, host, size, false, NULL); + ret = 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_unmap 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 = 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); } static void qemu_vfio_ram_block_removed(RAMBlockNotifier *n, @@ -501,6 +501,7 @@ static void qemu_vfio_ram_block_removed(RAMBlockNotifier *n, static int qemu_vfio_init_ramblock(RAMBlock *rb, void *opaque) { + Error *local_err = NULL; void *host_addr = qemu_ram_get_host_addr(rb); ram_addr_t length = 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 = qemu_vfio_dma_map(s, host_addr, length, false, NULL); + ret = qemu_vfio_dma_map(s, host_addr, length, false, NULL, &local_err); 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 = 0; int index; From patchwork Tue Oct 20 17:24:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD563C4363A for ; Tue, 20 Oct 2020 17:29:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 43CEB2222D for ; Tue, 20 Oct 2020 17:29:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JN0rsd+D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 43CEB2222D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvSL-0004xJ-3R for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:29:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvOB-00078y-On for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44998) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvO9-00087d-S9 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214733; 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=JN0rsd+DGjdM4R+PKKL0+R4Q9qSM1dcPbUgI/vPe51rDi4MiUCL6JH16xP9H1UjLnFw2I1 auRZygSf+2JXcx/qNpXM2RqtDTO7fRowhQ36JdfIWL9BsnYJcqHQ0Nliz0hQNvcFgAcQDR eSrTNL7VyjuCi/eQXzstrAHLSaz7DjE= 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-15-jOij0cnGOU-VtARh4vFRDg-1; Tue, 20 Oct 2020 13:25:28 -0400 X-MC-Unique: jOij0cnGOU-VtARh4vFRDg-1 Received: by mail-wr1-f71.google.com with SMTP id t3so1090608wrq.2 for ; Tue, 20 Oct 2020 10:25:28 -0700 (PDT) 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=G+PH8Cu2y+J377xwUMj/fTge2xNMCYZMz+UwOjFxVJZX+Rh16Q20y/4ZvydBus6rEo PFrToBlKxnBOT1sGqbUIiw6SoxxxfkcZqu09yfzazHC0L/lFcT6XHs4c3pI96uaMjYka i/nK3jSJEGlD1k4VK62QVS3B7KGIFYpGKNxsM4A83df9uzM0/qlfZwKRNRq5y2UYgaUF jbwVTfkA8mpF/kodY7RAsfBopRH9MqYJXg5m5xlIQwT8C+jQI9YzcVgAmgKlYv5bJDRQ uBd3hcaj9ilvTKfFC9sObb7/h+QJJMa688djsP5l4MAt/vf9o/HCBhdcFlM+xissC0cs 5enw== X-Gm-Message-State: AOAM530rhj4hhwL05QSHP02J21CL3I91bl+PAid5efryzJHrNLUUFGbD DwL6PqYq3cQKBM3huBH9TBpFfQq8nxSlKDhZiJRP8trpaUL+4evrJ6OLjcf7n0Y3awqggjllgGp NW8vwOjT/HoCsSgo= X-Received: by 2002:adf:fd49:: with SMTP id h9mr4977129wrs.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:16:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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, /* 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 = { .argsz = 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); 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, size_t size, goto out; } assert(qemu_vfio_verify_mappings(s)); - ret = qemu_vfio_do_mapping(s, host, size, iova0); + ret = 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, size_t size, ret = -ENOMEM; goto out; } - ret = qemu_vfio_do_mapping(s, host, size, iova0); + ret = qemu_vfio_do_mapping(s, host, size, iova0, errp); if (ret) { goto out; } From patchwork Tue Oct 20 17:24:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50F95C4363A for ; Tue, 20 Oct 2020 17:40:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8483921D6C for ; Tue, 20 Oct 2020 17:40:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZjJNKNCX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8483921D6C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvcm-0002FH-A1 for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:40:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvOE-0007FI-0B for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:53308) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvOC-00087k-5J for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214735; 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=ZjJNKNCXxLJHU7tt9yJJ4KYluMOYKMwitTGtE5/dIdFMn2cIkvD5QziKDAgIDLFbk86KTa wstTw8sGmh/6chfKmYQXazlsGo9SOEKibvDHyo8pM7KDLbmB+4bPMXKOdZB9+JtmVsL94b 61stGm2ZcaeTBwRYg3gu7+zV+hhHfIw= 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-190-nr8dZpi_PZCkXP98sp8NVA-1; Tue, 20 Oct 2020 13:25:33 -0400 X-MC-Unique: nr8dZpi_PZCkXP98sp8NVA-1 Received: by mail-wr1-f69.google.com with SMTP id t17so1076623wrm.13 for ; Tue, 20 Oct 2020 10:25:33 -0700 (PDT) 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=Zz8+hsEYCO6CwsnF1YpOxieRvB8usRx3r3h9X/EHA5PnTmAz6+AhZshBdAYsdIW/st /EM9V8Gx14/Omg6yaLeHCo0FjX1LdV6YsYyGiqIR0LoRBrgJonz8PJhqPIiCTiyIJpXH POO5V6Hx+nbAGoZqS6zV3he73XvhWSLSAk3Sg4uhIYtf7WMVuB6cVTs+qXw4C0I9wOYU Qh01t/ljZhWwlzqK2DAzz4ukKrmnjBVeeiC2hqyDib37BBbl0i44XGlyD+amZVqzX/ME /6JvK339TmZy7Siu/jfGfAoIz6FlTSWy0wqBEXwjUkoMQrjylwonQNKJr9ClMuc4lqh/ Xdmw== X-Gm-Message-State: AOAM532An5SW6tn8BYa5FSKgySo82CIyl9oRyWZGJEAIrg2zRMAkdvr3 /5v3qqn1e0xbdCtCMas7y5fN4GLCzXb2jZ0ftpdrYQC6gQ0x6Z6mN/NBJvtFcimn6i9IBFA3zZP fBzWOtdeVXkgiQUA= X-Received: by 2002:a7b:cf13:: with SMTP id l19mr4006428wmg.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:15:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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 = 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 <= 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; } From patchwork Tue Oct 20 17:24:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 270859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8E1AC4363A for ; Tue, 20 Oct 2020 17:33:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5AD382222D for ; Tue, 20 Oct 2020 17:33:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dEpkEuTR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AD382222D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvVb-0000nK-9A for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:33:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvOK-0007VF-7V for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvOH-0008As-0I for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:43 -0400 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= 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-362-xM54AHgSMN-PEw2DQKfGhg-1; Tue, 20 Oct 2020 13:25:38 -0400 X-MC-Unique: xM54AHgSMN-PEw2DQKfGhg-1 Received: by mail-wm1-f71.google.com with SMTP id z7so703098wmi.3 for ; Tue, 20 Oct 2020 10:25:38 -0700 (PDT) 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=DykplQSsDkUVvQ4myn9LMtP34qJy8AAfc1L5Qth52w/wBE91LBFKi0Ke/jHx9P28Mh Pe0fYXzUsRD2XYc87HKq3GnRFs0m/vE522+Fvrp0Msw1aQ8rhgNlPCKfEJOvHdWQf1fy 0mkVGluhdEQl+0d0ubBzGUc5eMegGuzUD0zU8GKTMqD6hWVr0IVhhuVcsa1ukG8PHWgd N9XOQFxCn561q91E6/MPV8/767AGIamyLqAM+XDx4glRZ5/l/w97ElQF/Gv8gX8Qb+0g MX65sArM2mHm8HyjhZhjjXyeWNteB21/eL7G6U7fKZSRVya8Q2fdYE13MOcj269vq08n 1pkg== X-Gm-Message-State: AOAM531fcAeBZabV19erz/DfoK5KyR8raUQts+9OA40ArTmUc9pmT4Hk UoX7cruOvP/UkjUidSWt+9O6cLmf0GWk7VjPWPFdxO1pdXxsApwE+LVlZMv5FUsveRRgR7xzmvW MGd54tEp1o68usG8= X-Received: by 2002:a1c:e256:: with SMTP id z83mr3840482wmg.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:15:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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é * + * SPDX-License-Identifier: GPL-2.0-or-later * This work is licensed under the terms of the GNU GPL, version 2 or later. * 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); #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é * + * SPDX-License-Identifier: GPL-2.0-or-later * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ @@ -230,6 +232,67 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e, return 0; } +/** + * 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 = { + .argsz = sizeof(irq_info), + .index = 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 = 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 = sizeof(*irq_set) + *irq_count * sizeof(int32_t); + irq_set = g_malloc0(irq_set_size); + + /* Get to a known IRQ state */ + *irq_set = (struct vfio_irq_set) { + .argsz = irq_set_size, + .flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, + .index = VFIO_PCI_MSIX_IRQ_INDEX, + .start = 0, + .count = *irq_count, + }; + + for (unsigned i = 0; i < *irq_count; i++) { + ((int32_t *)&irq_set->data)[i] = -1; /* un-assigned: skip */ + } + r = 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 = 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 %"PRIu32" (asked: %u)" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, 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_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" From patchwork Tue Oct 20 17:24:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F1EBC4363A for ; Tue, 20 Oct 2020 17:44:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6251521D6C for ; Tue, 20 Oct 2020 17:44:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ha+9WOqp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6251521D6C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvg5-0006Dl-2R for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:44:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvOS-0007ex-QY for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvOQ-0008Eq-0N for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214749; 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=Ha+9WOqp6f/WJcpa+fmKjWZ8boTWC3Ocd/vNPDPpQRG6uDrP5XqNdsE3T6slypVuim+U+q OT21dD1G/XHZ9HOdBAeeIcWCBEMeDk+TLmjaWT5Gi2lhQsi4qITlseyY3rvpbUjgMwu5cJ 34Qp4wKL6eUTnje5SR70ZyD8bfHDnlo= 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-285-wRoXjro3OFyeSF8bEHGZzg-1; Tue, 20 Oct 2020 13:25:43 -0400 X-MC-Unique: wRoXjro3OFyeSF8bEHGZzg-1 Received: by mail-wr1-f72.google.com with SMTP id 91so1064641wrk.20 for ; Tue, 20 Oct 2020 10:25:43 -0700 (PDT) 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=FN/biRCBl22MOlZXt2WZ0NGvQ0CZvVorM33/DHPibVUMrlEpPSzdmJ9gjBB8DDUAXU aBLlNVI6u4rCP/qt2OgMit/WXXwumxw/gK4u3f3gJIrEIOvWV6X1m/E+aKrGv8XHPb+N DZqX2LHhZO4dEp7Tk8anSNfVV8lMdKXmNcPYqyviWd9S+K0aERI2UHq9axzke9ugdXLZ j/VW+CK6pSeP2aXfIq7QIHquiklg2vBJTNBRtk7JmG+GoRBkB38mymj54AMY4c+Hq7E8 kpMzXshubakIBlr30JZLNeFXOz9LeF5WWMxdawOCfX+LsMDH0ik/nNDDNcecHPd1/i3s Cj+Q== X-Gm-Message-State: AOAM531XE+Km2l8pAXr4bU4Tj3UNq4tzKmv2zuywRz7cAttAvd58++VQ HofbbUTiIzgmBlWr3L5wA4ENjlXGayVK1YcyG0e7X+C1o6VC7TaFYREvzKVnktVn6tmL0IlEbWt rlShba/GKQH8dXiM= X-Received: by 2002:a5d:4141:: with SMTP id c1mr4610259wrq.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:16:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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, 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, + EventNotifier *notifier, Error **errp); #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, EventNotifier *e, return 0; } +/** + * 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 = 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 = sizeof(*irq_set) + sizeof(int32_t); + irq_set = g_malloc0(irq_set_size); + /* Get to a known IRQ state */ + *irq_set = (struct vfio_irq_set) { + .argsz = irq_set_size, + .flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, + .index = VFIO_PCI_MSIX_IRQ_INDEX, + .start = irq_index, + .count = 1, + }; + ((int32_t *)&irq_set->data)[0] = fd; + r = 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 %"PRIu32" (asked: %u)" +qemu_vfio_pci_msix_set_irq(unsigned irq_index, int fd) "msix irq %u notifier_fd %d" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, 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_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" From patchwork Tue Oct 20 17:24:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302455 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B087C4363A for ; Tue, 20 Oct 2020 17:46:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C547B21D6C for ; Tue, 20 Oct 2020 17:46:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AVhVIRYB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C547B21D6C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvhx-0001Bg-Ni for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:46:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvOT-0007fo-Ke for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:53476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvOQ-0008F6-PV for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214749; 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=AVhVIRYB05D/ptEWkFK64Z3i2s04TCZ1LT0kReGbUUonFl9ZfxmXFlKpTo3Kn4otwDtCTL pa0YTQ646IO+JnPvxWUjeo6uszDjLJwLh4+rY+AdjKRjTaDegVaMtzRe9EZd7tlwbLr0eV ZRe5dKV20vdF8hV2wt1oU+imu6r/5Xg= 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-202-eg6HDhJGNiKMNu6EjTQ37A-1; Tue, 20 Oct 2020 13:25:48 -0400 X-MC-Unique: eg6HDhJGNiKMNu6EjTQ37A-1 Received: by mail-wr1-f71.google.com with SMTP id f11so1068351wro.15 for ; Tue, 20 Oct 2020 10:25:48 -0700 (PDT) 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=CtLJSxUnqsAD7qQmd22bbSLAJ0Vxbfyczu11rWOsjW8DOx44xTgOK+9ABMtXBzigQ9 BCOyrehK5LMBba+H4WaJWr+XdTcAez0/B8VCLZDa5BtmtPFj3eOLOV6WPqiSvOQGOiHu Ly9MBteiElcFNut+XHkMmqpdlZAmGY3z7qqcvpLI7m1ONUxxZ6nrr3ykXaUe1piRZKuU oP4avx6jB0t0bhwoAhBz3413GwaxgJot1lLxpnR3XLj28YE8JZEBfTUbWsX917LJfabd w99NUCpcm5Hi28SD6QR3c0My8S2zz2atJnH4j+oDAyfMcvJoo5yxgspo8GidAK1xFKyu V4Aw== X-Gm-Message-State: AOAM531Cq+MCZShAwZmFydwCD4FnRAPtv+T9AGn8m2PJjN6rwNIThUrR Axfc3dJAcMU2oVTFm1O+RQsUVbLtGsG7Hq9cSraUIk5NmrPoroVMp1HSE++2Sksskw7i5697bhe bh8ubHQTTveObQCY= X-Received: by 2002:adf:e681:: with SMTP id r1mr4520766wrm.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:15:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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 = NULL; volatile NvmeBar *regs = NULL; size_t min_page_size = 4096; + unsigned irq_count = MSIX_IRQ_COUNT; 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, } } - ret = qemu_vfio_pci_init_irq(s->vfio, s->irq_notifier, - VFIO_PCI_MSIX_IRQ_INDEX, errp); + ret = qemu_vfio_pci_msix_init_irqs(s->vfio, &irq_count, errp); + if (ret) { + if (ret == -EOVERFLOW) { + error_append_hint(errp, "%u IRQs requested but only %u available\n", + MSIX_IRQ_COUNT, irq_count); + } + goto out; + } + + ret = qemu_vfio_pci_msix_set_irq(s->vfio, MSIX_SHARED_IRQ_IDX, + s->irq_notifier, errp); if (ret) { goto out; } From patchwork Tue Oct 20 17:24:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 270857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCEFEC4363A for ; Tue, 20 Oct 2020 17:35:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E95B2222D for ; Tue, 20 Oct 2020 17:35:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JYKTD/tj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E95B2222D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUvXy-0004cR-48 for qemu-devel@archiver.kernel.org; Tue, 20 Oct 2020 13:35:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUvOZ-0007iB-LL for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:26:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26119) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUvOX-0008Fe-KS for qemu-devel@nongnu.org; Tue, 20 Oct 2020 13:25:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603214755; 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=JYKTD/tjiM9FuKFAk4HfTRtSr/7aUWUCRlQSKIOCbzX6BdfaxLGSKRAa+mrZbGy8Wyt4RR EVkeTKLQjBG4WACOI5tAdkCO2/LwLpaXaqC+/3HHJFToV948ItUY456b2l+QWb4lIcvaKo 4N/gE5XUCUbxSypzLlWADp/ZjpRi4UE= 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-466-YC6a1lQfMu-Eb_Wlsz8i7w-1; Tue, 20 Oct 2020 13:25:53 -0400 X-MC-Unique: YC6a1lQfMu-Eb_Wlsz8i7w-1 Received: by mail-wm1-f69.google.com with SMTP id s12so398507wmj.0 for ; Tue, 20 Oct 2020 10:25:53 -0700 (PDT) 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=dP3LBA4z57rmHIvY2BvMH175IywFjrUZbwV5XKETpyUGFsTXlMBn5/MhIYQScvNPag GHPPPYLUEvJb+4ARrqKpF+6p2l+2VyEC50v4WwGqEEZe3UtPc8/y1kvp/uRNZDzrjmXh jg0IwZJibyX06QxFz8s+PbZqtK8GcskXgNWjXdkMsxkVqOgihC68IGrUG5j0uUagsK/S AldHMNNVRa3MS4WXcIXCzELDFFbQReqh4ZGV+LErU0Y3ykeIvSZAODWxbInmiiX/6gLK SMcUPgtJp/g+IPHL3qxl2fp+F/Hhbp13uJhx2j2tDeaM8jdJfjhWrBM2pdk3uG2MmmA+ GtMw== X-Gm-Message-State: AOAM533VbH9W7oVYiui0y7wZvTjeIKZ6Vz8R8t9sytGuIgtDYVaHEtIy CL8RTw0BzvsANfbMUjpN+pIA5r+L4D/ldINMUu0FEeL6CCTVrkp6gwUbk4Rzq5Z3sfYAPCsOmbr WuCzsifQPjCfCuWY= X-Received: by 2002:a1c:49c2:: with SMTP id w185mr3997336wma.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 01:15:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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 index, void *bar, } } -/** - * 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 = { .argsz = sizeof(irq_info) }; - - irq_info.index = 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 = sizeof(*irq_set) + sizeof(int); - irq_set = g_malloc0(irq_set_size); - - /* Get to a known IRQ state */ - *irq_set = (struct vfio_irq_set) { - .argsz = irq_set_size, - .flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, - .index = irq_info.index, - .start = 0, - .count = 1, - }; - - *(int *)&irq_set->data = event_notifier_get_fd(e); - r = 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