From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.223.172.38 with SMTP id v35csp4845392wrc; Wed, 27 Sep 2017 08:41:18 -0700 (PDT) X-Google-Smtp-Source: AOwi7QD+qrj37K8jJpyXVn6cHuzOfHZIHyMlYYNOYHV6EuXMYWZJhTisaJw+oDR91jYEXy1NzfQM X-Received: by 10.200.46.146 with SMTP id h18mr2584830qta.100.1506526878359; Wed, 27 Sep 2017 08:41:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506526878; cv=none; d=google.com; s=arc-20160816; b=PasIoafL4JcydhlZfJX7Kh8HnrpEK4qkxZoNtAYLK4Osy0KdGNUJGVze05Ne8t6HPj M/x3InIHJasfk/OIFpCD4Cnt1MEOMDdIma/hFU0i690+yOhA2c6vo1cz7p3DcyGQHP1H A6IM69JyTcdgM4ZF3FCL4fkWdOTiw6NCeXTK2aORKkj4tVIBwbeBMx/s622KyF0bjq6L 02eQcTRWhy+ziELlieDMDos/+TrvJvWh9ihpHA7UbZu/YO0fzXfWkQ+7TX8Cq36o6IV0 4RGnbq0Ptj4Nu9oEpHNhjcC+dNjdONGNKWQK6YLaLa9uZtiw/s7yGJ8DFU6TrssAwRMc RvLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:dmarc-filter :arc-authentication-results; bh=JX9BCj3umnUi/Gjq4HHaed3Hm07TK4j6OsGYYG/+dUg=; b=n0JXYWz2sPA9I+hSTxcCLBee1KOhLuExRTwy4l/Oow32633JQL0BK+bjHh3Hnvt4xC 0vGEEvkNP9EGSqjBNFT3GDr7pwmVm9Vn85JJF+aS/84LzXo+FPgGRJcgP+Skg7RPL2yp NJ0FAwoRHdlTIkK7RiuoDOv21nZpTv6iszBKrAzoZ9xdzVF64ENiwbDgeCjYWHYiXKHH vzYG7PsA8m1J4U9rcbN82KX2AAtXpYCkTDAA4FMKr3szKIbxH2ASMgZwExAXnkt/yENn xbMpM6NDgCyG8qmEwzAbeD+rx4DvGtfjNjbMVQETtvxR8+i0YyjnbgedMnnGsjH9PEJX ow2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o4si11570763qko.17.2017.09.27.08.41.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Sep 2017 08:41:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:55285 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxESa-000086-3l for alex.bennee@linaro.org; Wed, 27 Sep 2017 11:41:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxESQ-00006D-L6 for qemu-arm@nongnu.org; Wed, 27 Sep 2017 11:41:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxESN-00059U-A1 for qemu-arm@nongnu.org; Wed, 27 Sep 2017 11:41:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50090) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxESN-000592-2C; Wed, 27 Sep 2017 11:41:03 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EBE0C6B23A; Wed, 27 Sep 2017 15:41:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EBE0C6B23A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eric.auger@redhat.com Received: from localhost.localdomain (ovpn-116-163.ams2.redhat.com [10.36.116.163]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 385FD5ED20; Wed, 27 Sep 2017 15:40:44 +0000 (UTC) To: Tomasz Nowicki , eric.auger.pro@gmail.com, peter.maydell@linaro.org, alex.williamson@redhat.com, mst@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org, jean-philippe.brucker@arm.com References: <1505807208-9063-1-git-send-email-eric.auger@redhat.com> <1505807208-9063-11-git-send-email-eric.auger@redhat.com> <4cecfa75-c97a-586b-aadf-9b0bfd168960@caviumnetworks.com> From: Auger Eric Message-ID: <3213d48c-c2ec-5728-bc39-d46c60c4e028@redhat.com> Date: Wed, 27 Sep 2017 17:40:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <4cecfa75-c97a-586b-aadf-9b0bfd168960@caviumnetworks.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 27 Sep 2017 15:41:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-arm] [Qemu-devel] [RFC v4 10/16] virtio-iommu: Implement probe request X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevin.tian@intel.com, marc.zyngier@arm.com, will.deacon@arm.com, drjones@redhat.com, peterx@redhat.com, linuc.decode@gmail.com, bharat.bhushan@nxp.com, christoffer.dall@linaro.org Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: Ev4mUdeobY6r Hi Tomasz, On 27/09/2017 12:53, Tomasz Nowicki wrote: > Hi Eric, > > On 19.09.2017 09:46, Eric Auger wrote: >> This patch implements the PROBE request. At the moment, >> no reserved regions are returned. >> >> At the moment reserved regions are stored per device. >> >> Signed-off-by: Eric Auger >> >> --- >> > > [...] > >> + >> +static int virtio_iommu_fill_property(int devid, int type, >> + viommu_property_buffer *bufstate) >> +{ >> + int ret = -ENOSPC; >> + >> + if (bufstate->filled + 4 >= VIOMMU_PROBE_SIZE) { >> + bufstate->error = true; >> + goto out; >> + } >> + >> + switch (type) { >> + case VIRTIO_IOMMU_PROBE_T_NONE: >> + ret = virtio_iommu_fill_none_prop(bufstate); >> + break; >> + case VIRTIO_IOMMU_PROBE_T_RESV_MEM: >> + { >> + viommu_dev *dev = bufstate->dev; >> + >> + g_tree_foreach(dev->reserved_regions, >> + virtio_iommu_fill_resv_mem_prop, >> + bufstate); >> + if (!bufstate->error) { >> + ret = 0; >> + } >> + break; >> + } >> + default: >> + ret = -ENOENT; >> + break; >> + } >> +out: >> + if (ret) { >> + error_report("%s property of type=%d could not be filled (%d)," >> + " remaining size = 0x%lx", >> + __func__, type, ret, bufstate->filled); >> + } >> + return ret; >> +} >> + >> +static int virtio_iommu_probe(VirtIOIOMMU *s, >> + struct virtio_iommu_req_probe *req, >> + uint8_t *buf) >> +{ >> + uint32_t devid = le32_to_cpu(req->device); >> + int16_t prop_types = SUPPORTED_PROBE_PROPERTIES, type; >> + viommu_property_buffer bufstate; >> + viommu_dev *dev; >> + int ret; >> + >> + dev = g_tree_lookup(s->devices, GUINT_TO_POINTER(devid)); >> + if (!dev) { >> + return -EINVAL; >> + } >> + >> + bufstate.start = buf; >> + bufstate.filled = 0; >> + bufstate.dev = dev; > > bufstate.error is not initialized which may cause false alarm in > virtio_iommu_fill_property() thanks for spotting that. I owe you several fixes in both vsmmuv3 and virtio-iommu. Thank you for testing, again! Best Regards Eric > >> + >> + while ((type = ctz32(prop_types)) != 32) { >> + ret = virtio_iommu_fill_property(devid, 1 << type, &bufstate); >> + if (ret) { >> + break; >> + } >> + prop_types &= ~(1 << type); >> + } >> + virtio_iommu_fill_property(devid, VIRTIO_IOMMU_PROBE_T_NONE, >> &bufstate); >> + >> + return VIRTIO_IOMMU_S_OK; >> +} >> + >> #define get_payload_size(req) (\ >> sizeof((req)) - sizeof(struct virtio_iommu_req_tail)) >> @@ -433,6 +567,24 @@ static int >> virtio_iommu_handle_unmap(VirtIOIOMMU *s, >> return virtio_iommu_unmap(s, &req); >> } > > Thanks, > Tomasz >