From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=marvell.com ARC-Seal: i=1; a=rsa-sha256; t=1584526394; cv=none; d=zohomail.com; s=zohoarc; b=DvNFoY3e7HAfKkgmV1GKnsVZss4tUsoHmAWHMFEsQy8lmnQo99hy12dWBGJYVdDdaDzpxiyIgap8upWQg08fGEL4zP1Xa0WHOoxIA/ixnuNAsYsqmj0+9fGpY6b4qgPidljgHofXUMGXc5HmyDwg/35SZvchM4mZ8A25AO/XXYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584526394; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qEAv6IpogbV7YHyhj2l6c6UjHVFT5rsptczJTs+HL8c=; b=nNM6TQ0dGmIocTezzVj7MllSFLOgmnXlNCmsM4IzELlFs2Q2MdW1xbyFQe7qckM8wPtdAlokScKPlfjHYyabmTMB+DrIQn409i9Sr6c5opYC9w0Q3FuKz2Ll3ag297HmT828pgUaIfjZ6TT/lEqNatQNMVpr9kWkRq99C6InaHA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584526394459373.0426989246515; Wed, 18 Mar 2020 03:13:14 -0700 (PDT) Received: from localhost ([::1]:47974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVhJ-00034m-CO for importer@patchew.org; Wed, 18 Mar 2020 06:13:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37006) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVgQ-0001dB-KQ for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEVgP-0004RF-Li for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:18 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:3770) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEVgP-0004Qb-Gx; Wed, 18 Mar 2020 06:12:17 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02IABKBd030363; Wed, 18 Mar 2020 03:12:15 -0700 Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2yu9rp9tu2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 03:12:15 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 03:12:13 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 03:12:12 -0700 Received: from bbhushan2.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 18 Mar 2020 03:12:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=qEAv6IpogbV7YHyhj2l6c6UjHVFT5rsptczJTs+HL8c=; b=ns/NwjO0nE9iSeLin2teH9SCLcryvgjctFejuiUiwH/OpqNkqFvGMmrGJsaaA6VVkG5N TwZ6ADR/CYqgvGG3PRS/eDwZSLbQ4O15loy3tDc7ErwM1CDppyOo3nQM3XvC7qwUBeuR Q2UpeQ38E2UxV7Mf/JD2eRMagC8uFrxSSd3ZxXzGWoRKwxM+mF2yxFX4sIWygoamwMqX bTG9KfsNDrpOFyet9d5rKXi8oZry7P+PQRuqxyXsDrKJ/pnGf7T14ZJkIMOdHs395o6R P3jmliRXv50xH+2xDZI6uKrXrZw73QbdI53WNPu8flqoGiZKSdDwb1VTyvmSMqauMp5Z 7Q== From: Bharat Bhushan To: , , , , , , , , , , , , , Subject: [PATCH v8 1/8] hw/vfio/common: Remove error print on mmio region translation by viommu Date: Wed, 18 Mar 2020 15:41:52 +0530 Message-ID: <20200318101159.8767-2-bbhushan2@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318101159.8767-1-bbhushan2@marvell.com> References: <20200318101159.8767-1-bbhushan2@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-18_04:2020-03-18, 2020-03-18 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 67.231.156.173 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: Eric Auger , Bharat Bhushan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On ARM, the MSI doorbell is translated by the virtual IOMMU. As such address_space_translate() returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter. Signed-off-by: Eric Auger Signed-off-by: Bharat Bhushan --- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 5ca11488d6..c586edf47a 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void *= *vaddr, &xlat, &len, writable, MEMTXATTRS_UNSPECIFIED); if (!memory_region_is_ram(mr)) { - error_report("iommu map to non memory area %"HWADDR_PRIx"", - xlat); return false; } =20 --=20 2.17.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=marvell.com ARC-Seal: i=1; a=rsa-sha256; t=1584526480; cv=none; d=zohomail.com; s=zohoarc; b=le33cb4hGLA1oQGiPbtsil8wr0sm6BSfX35sMwwXQsuNGNvIGyTXwY4bEb4zpkNORb8X7mjGqyZpRk6SGUm54vGMDOYGRM29GetOI6QJDhkUE/nLp0wVc9L1H0WKETfx9VRsbz08IfTQkV7luM6LQ5HrKkREdpNnq1WLDF2Zpao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584526480; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vF13sRjgV2iwHWGieK2LuMmHy7/+wnZoyF7KV4TjITI=; b=k20d+kzqUK3Bmntq9qVI7cvgCPdoa5Ik0ZEzDasN3fultdpCG0H+MbSK8F4b3vGOwZ63asVUXJ+dLBysaHNmJznHbD9YexirAMLvfhvdSrJU3f50/9mCVjCbSpn626nGDQwb5JlYqjipq51oHMCUsEvyQm10OMGTjsTDoE9nz18= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158452648022838.2612633964452; Wed, 18 Mar 2020 03:14:40 -0700 (PDT) Received: from localhost ([::1]:48028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVih-0005lX-72 for importer@patchew.org; Wed, 18 Mar 2020 06:14:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37090) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVgW-0001qG-La for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEVgV-0004XH-Eh for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:24 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:37546) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEVgV-0004Ww-9u; Wed, 18 Mar 2020 06:12:23 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02IABn5X030628; Wed, 18 Mar 2020 03:12:20 -0700 Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2yu9rp9tug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 03:12:20 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 03:12:18 -0700 Received: from bbhushan2.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 18 Mar 2020 03:12:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=vF13sRjgV2iwHWGieK2LuMmHy7/+wnZoyF7KV4TjITI=; b=ip71e/3DsV06eWrfRqBaWDDVw5Aqlz6vlDOLTe/TVRXp26o3h3Jl/IHfayLbtM/UmECX wmAMf10H6RDrgU8cMbwAgaycDfAVErWJBpUcXKjYE+6YE3jWYkp+oDKNuNLw0ti5Vl9F 1pzQD8jF9oDgSwprrgkItBeE3K4D+yZCdNiyEkVOvDzwFMQag7uWyatpGaTt1uailz7y 8NDQWhx2ImXePtdKFLfSvmc38f7CHghOwfnbSXYFeuWSy2h6cLQnQ9tiBKOmtFEWQ8v9 rnBZoMhOsbkCMedDQkCFTyYeBXmRHlJMr5YuivMAfEw6VVqnZGtjFJzHDD4NAUINJgA/ Vw== From: Bharat Bhushan To: , , , , , , , , , , , , , Subject: [PATCH v8 2/8] memory: Add interface to set iommu page size mask Date: Wed, 18 Mar 2020 15:41:53 +0530 Message-ID: <20200318101159.8767-3-bbhushan2@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318101159.8767-1-bbhushan2@marvell.com> References: <20200318101159.8767-1-bbhushan2@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-18_04:2020-03-18, 2020-03-18 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 67.231.156.173 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: Bharat Bhushan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @marvell.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow to set page size mask to be supported by iommu. This is required to expose page size mask compatible with host with virtio-iommu. Signed-off-by: Bharat Bhushan --- v7->v8: - new patch include/exec/memory.h | 20 ++++++++++++++++++++ memory.c | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index e85b7de99a..063c424854 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -355,6 +355,16 @@ typedef struct IOMMUMemoryRegionClass { * @iommu: the IOMMUMemoryRegion */ int (*num_indexes)(IOMMUMemoryRegion *iommu); + + /* + * Set supported IOMMU page size + * + * Optional method: if this is supported then set page size that + * can be supported by IOMMU. This is called to set supported page + * size as per host Linux. + */ + void (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu, + uint64_t page_size_mask); } IOMMUMemoryRegionClass; =20 typedef struct CoalescedMemoryRange CoalescedMemoryRange; @@ -1363,6 +1373,16 @@ int memory_region_iommu_attrs_to_index(IOMMUMemoryRe= gion *iommu_mr, */ int memory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr); =20 +/** + * memory_region_iommu_set_page_size_mask: set the supported pages + * size by iommu. + * + * @iommu_mr: the memory region + * @page_size_mask: supported page size mask + */ +void memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr, + uint64_t page_size_mask); + /** * memory_region_name: get a memory region's name * diff --git a/memory.c b/memory.c index aeaa8dcc9e..14c8783084 100644 --- a/memory.c +++ b/memory.c @@ -1833,6 +1833,16 @@ static int memory_region_update_iommu_notify_flags(I= OMMUMemoryRegion *iommu_mr, return ret; } =20 +void memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr, + uint64_t page_size_mask) +{ + IOMMUMemoryRegionClass *imrc =3D IOMMU_MEMORY_REGION_GET_CLASS(iommu_m= r); + + if (imrc->iommu_set_page_size_mask) { + imrc->iommu_set_page_size_mask(iommu_mr, page_size_mask); + } +} + int memory_region_register_iommu_notifier(MemoryRegion *mr, IOMMUNotifier *n, Error **errp) { --=20 2.17.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=marvell.com ARC-Seal: i=1; a=rsa-sha256; t=1584526477; cv=none; d=zohomail.com; s=zohoarc; b=my6bWJyCM8a5VNBVJh80kD/NwlWKKMwxyPji8Z+2wQuC7TjDXuw9/hXk7+IEYroq9wxH9SW2u6UWwQmnj8T+xJEWbmfAz7DOqLehHuSDuUWFp8vTzviRh1Woo5d4z8smSLVG9/KYbKeplVct77XnxrAg63SK/BpA29RHucgEqRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584526477; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FbEgKzpeFw4OscqegPpPMFTJgFQvhUCCZhKzMe/ZA1w=; b=eOikmU4NUQcDkePFFI1hbZOl+NM2BSK1tGaj91A6l+RdciSmqrhtMkjE0QSsjf9uRlZMja6Zd6fJ210Lihx2vWBGUpnMPi6+txfaFGzLGLa483ONq0eH3FGbGfNhbRnsuzeScmb7gjKD3NkP9WGPOPuIa+7iyah8xbeJFKfxFg8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584526477057427.70079075296655; Wed, 18 Mar 2020 03:14:37 -0700 (PDT) Received: from localhost ([::1]:48022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVic-0005ei-AO for importer@patchew.org; Wed, 18 Mar 2020 06:14:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37156) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVgb-00021J-2C for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEVga-0004au-5Q for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:28 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:43926) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEVga-0004aY-0T; Wed, 18 Mar 2020 06:12:28 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02IABKBe030363; Wed, 18 Mar 2020 03:12:26 -0700 Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 2yu9rp9tur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 03:12:26 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 03:12:23 -0700 Received: from bbhushan2.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 18 Mar 2020 03:12:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=FbEgKzpeFw4OscqegPpPMFTJgFQvhUCCZhKzMe/ZA1w=; b=S8kUj1rP7r46a3n7d0DFqDR3T/eB5PHPtcaCVxCb7JY2nZ3REtiUDpVkDtMXLfDwsxc8 aqv3VRKXOo+GDxJ3pxGRB6ZVJcoIqD9ObBdyRUC6zRIDxHEmYUL5UWH5zBgH+cuvnlgK g1ctP7Rse+QpdCGIaPEM6E3YtYxjOCwXKQXehETDCycMkQN+ujH8k/12H+FRSQXm46bg VMxw/cIh9J+zI9+dJBxRQFavmITCTM7uqkb6c9qhUMxK2uO+GRHcfNnU1aI4J5qq9KIo TeIp15UvkUNPA/sOAtLh7/G10h2qTte/y3GUxA1l2fcLPONxLqDNzO1Pj3WXT4U9nnmp iQ== From: Bharat Bhushan To: , , , , , , , , , , , , , Subject: [PATCH v8 3/8] vfio: set iommu page size as per host supported page size Date: Wed, 18 Mar 2020 15:41:54 +0530 Message-ID: <20200318101159.8767-4-bbhushan2@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318101159.8767-1-bbhushan2@marvell.com> References: <20200318101159.8767-1-bbhushan2@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-18_04:2020-03-18, 2020-03-18 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 67.231.156.173 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: Bharat Bhushan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @marvell.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Set iommu supported page size mask same as host Linux supported page size mask. Signed-off-by: Bharat Bhushan --- v7->v8: - new patch hw/vfio/common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index c586edf47a..6ea50d696f 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -635,6 +635,9 @@ static void vfio_listener_region_add(MemoryListener *li= stener, int128_get64(llend), iommu_idx); =20 + memory_region_iommu_set_page_size_mask(giommu->iommu, + container->pgsizes); + ret =3D memory_region_register_iommu_notifier(section->mr, &giommu= ->n, &err); if (ret) { --=20 2.17.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=marvell.com ARC-Seal: i=1; a=rsa-sha256; t=1584526413; cv=none; d=zohomail.com; s=zohoarc; b=U3Mzfj8izezEORGqh8bWmknula0IGvSu7lsypeEnloCZiuje9w2G24yJvyYNZjyrUw/iNDXgBSlPqe443Vu+SM9NzE7ziCnbEuWmWxxb3QrK+KjACtExAuoH3NDb4qLVda9CrOxTuTRVvFimTDPwYub5Bo4P7QjZso/HUsi/Dhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584526413; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w1PjheBBbpwXuVOh06nYaUHWFHP75aU7PlNsOsBVK/M=; b=BC4fmhChPUfymeRROQ1b56BCzCku239JSqV/1rXt2pE9Z5VRxoJf3D/nP4oVskdVryZf6ksm/CwfJ0ChI4jsBsZlikWgRGsEwZm6UPOlgs6ZPefH5RIQ0w4ltvrWgtKerkf5GME01HRN2/bEBMtGXbrPontT7WkJoE7k0euKmOg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584526413968218.44900362078965; Wed, 18 Mar 2020 03:13:33 -0700 (PDT) Received: from localhost ([::1]:47988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVhc-0003gO-S4 for importer@patchew.org; Wed, 18 Mar 2020 06:13:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37225) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVgg-0002FD-Q6 for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEVgf-0004g6-Pf for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:34 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:12606) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEVgf-0004fj-Kg; Wed, 18 Mar 2020 06:12:33 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02IABnOe030625; Wed, 18 Mar 2020 03:12:31 -0700 Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2yu9rp9tv2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 03:12:31 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 03:12:29 -0700 Received: from bbhushan2.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 18 Mar 2020 03:12:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=w1PjheBBbpwXuVOh06nYaUHWFHP75aU7PlNsOsBVK/M=; b=UiwThwlRdc9P2BQsawOW/7Ikty4/+xO0V7mNB9v4f0nP9lXVaAAyr8RVLArJ13swtCZZ 7MZUn3U579LjiGc5MUrj/wz183R7j+PzWmss9Hr/UHWxpjCa1QNC8X2sp7uxx2QPgbvf MU38AUTb2/dEWLfwQiC4DL0Gkmwkrd/h7oVz8/H1+ZTqcMeBJ8UMhZbLLJQw6vWilFn6 gpKzUaiP8lsakrhVgKJb/VoaKPwXMC9wgZPsS0RI93NVh/H5dojssfTnbJ7BIcPofoBD TICb5KM9o/OkhoLqjl2B+IuCVMxeNGunE71mUfyUhslng2JXoMO0OwKV341q2a5YwBOM 3g== From: Bharat Bhushan To: , , , , , , , , , , , , , Subject: [PATCH v8 4/8] virtio-iommu: set supported page size mask Date: Wed, 18 Mar 2020 15:41:55 +0530 Message-ID: <20200318101159.8767-5-bbhushan2@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318101159.8767-1-bbhushan2@marvell.com> References: <20200318101159.8767-1-bbhushan2@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-18_04:2020-03-18, 2020-03-18 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 67.231.156.173 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: Bharat Bhushan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @marvell.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add optional interface to set page size mask. Currently this is set global configuration and not per endpoint. Signed-off-by: Bharat Bhushan --- v7->v8: - new patch hw/virtio/virtio-iommu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 4cee8083bc..c00a55348d 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -650,6 +650,15 @@ static gint int_cmp(gconstpointer a, gconstpointer b, = gpointer user_data) return (ua > ub) - (ua < ub); } =20 +static void virtio_iommu_set_page_size_mask(IOMMUMemoryRegion *mr, + uint64_t page_size_mask) +{ + IOMMUDevice *sdev =3D container_of(mr, IOMMUDevice, iommu_mr); + VirtIOIOMMU *s =3D sdev->viommu; + + s->config.page_size_mask =3D page_size_mask; +} + static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -865,6 +874,7 @@ static void virtio_iommu_memory_region_class_init(Objec= tClass *klass, IOMMUMemoryRegionClass *imrc =3D IOMMU_MEMORY_REGION_CLASS(klass); =20 imrc->translate =3D virtio_iommu_translate; + imrc->iommu_set_page_size_mask =3D virtio_iommu_set_page_size_mask; } =20 static const TypeInfo virtio_iommu_info =3D { --=20 2.17.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=marvell.com ARC-Seal: i=1; a=rsa-sha256; t=1584526591; cv=none; d=zohomail.com; s=zohoarc; b=nm+S1chhZSrHjm/BWSKM+CPdDRm4CNh+gUkg/w31RNptkByd+lc1p+tnMqM/SqDtaGorWoSfnYEwDSmfexTmcckKTaVTMm9LqhL7wqVZzEMD1QjpVcvOLS5MmwYBwmHKO57Bf6zExFXfDweihZMBJWu6niiPX4KGKc0qdJX0kNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584526591; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XN0LjRF171QI39m3Xi7A3dpjV78hP1L4kv6vlWXZQ1s=; b=c6/NN8JS3EAkCMg8LUM7ZZOASHvzm7wE0v4WVMW7HyZL0059DYxdbj4GEf1mFIX3m3b5reMTMs+R66X5inbeFNb6IxAuTkdFZhLy01PlgIz61zN9YdijA5JxVfgznxQgPzidMu7tdHIadh5Ed4WKXN6ZyMkvsANWk1qpicSPLvg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584526591257465.65183590685797; Wed, 18 Mar 2020 03:16:31 -0700 (PDT) Received: from localhost ([::1]:48092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVkT-0008QH-TC for importer@patchew.org; Wed, 18 Mar 2020 06:16:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37357) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVgs-0002gi-IE for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEVgr-0004vs-4Z for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:46 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:34020 helo=mx0b-0016f401.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEVgn-0004pz-Tq; Wed, 18 Mar 2020 06:12:42 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02IAAjAF008560; Wed, 18 Mar 2020 03:12:38 -0700 Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 2yu8pqj4pj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 03:12:38 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 03:12:36 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 03:12:36 -0700 Received: from bbhushan2.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 18 Mar 2020 03:12:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=XN0LjRF171QI39m3Xi7A3dpjV78hP1L4kv6vlWXZQ1s=; b=kAWHuSTFuGBqDl+qT7hAMZwLkcamCRIKJP79gBKaXX6Q77wZdgoFverwikGTSh8rNmpZ vJDZz4FAZlL/uCOwKj9EQckZy90NTLhJkIV69JQsXvO3+llKh4osvJSrRcW3OrkL9lui 0Ud8gfEYZ2OjYUQXhRivsLQKHmjIT87X/somwVC+rcpfXh8FNdyk1lBY7Rzr8GR2p+oz tPaS7Y2CHuxlmPbr9OLRT0iKi/iGbABywckQK3Em4Bv5ouTiqJ+wrnrzU5gSsok2vcIz tH6JNU+exbuz2lGDLK1ceYlaHhMmkjbK21Kr3yuHNfGByEFG/cFXsBPMUnWMprkrnSgU Yw== From: Bharat Bhushan To: , , , , , , , , , , , , , Subject: [PATCH v8 5/8] virtio-iommu: Add iommu notifier for map/unmap Date: Wed, 18 Mar 2020 15:41:56 +0530 Message-ID: <20200318101159.8767-6-bbhushan2@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318101159.8767-1-bbhushan2@marvell.com> References: <20200318101159.8767-1-bbhushan2@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-18_04:2020-03-18, 2020-03-18 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 67.231.148.174 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: Eric Auger , Bharat Bhushan , Bharat Bhushan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch extends VIRTIO_IOMMU_T_MAP/UNMAP request to notify registered iommu-notifier. Which will call vfio notifier to map/unmap region in iommu. Signed-off-by: Bharat Bhushan Signed-off-by: Eric Auger --- include/hw/virtio/virtio-iommu.h | 2 + hw/virtio/virtio-iommu.c | 67 +++++++++++++++++++++++++++++++- hw/virtio/trace-events | 2 + 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-io= mmu.h index 6f67f1020a..65ad3bf4ee 100644 --- a/include/hw/virtio/virtio-iommu.h +++ b/include/hw/virtio/virtio-iommu.h @@ -37,6 +37,7 @@ typedef struct IOMMUDevice { int devfn; IOMMUMemoryRegion iommu_mr; AddressSpace as; + QLIST_ENTRY(IOMMUDevice) next; } IOMMUDevice; =20 typedef struct IOMMUPciBus { @@ -56,6 +57,7 @@ typedef struct VirtIOIOMMU { GTree *domains; QemuMutex mutex; GTree *endpoints; + QLIST_HEAD(, IOMMUDevice) notifiers_list; } VirtIOIOMMU; =20 #endif diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index c00a55348d..623b477b9c 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -123,6 +123,38 @@ static gint interval_cmp(gconstpointer a, gconstpointe= r b, gpointer user_data) } } =20 +static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr iova, + hwaddr paddr, hwaddr size) +{ + IOMMUTLBEntry entry; + + entry.target_as =3D &address_space_memory; + entry.addr_mask =3D size - 1; + + entry.iova =3D iova; + trace_virtio_iommu_notify_map(mr->parent_obj.name, iova, paddr, size); + entry.perm =3D IOMMU_RW; + entry.translated_addr =3D paddr; + + memory_region_notify_iommu(mr, 0, entry); +} + +static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr iova, + hwaddr size) +{ + IOMMUTLBEntry entry; + + entry.target_as =3D &address_space_memory; + entry.addr_mask =3D size - 1; + + entry.iova =3D iova; + trace_virtio_iommu_notify_unmap(mr->parent_obj.name, iova, size); + entry.perm =3D IOMMU_NONE; + entry.translated_addr =3D 0; + + memory_region_notify_iommu(mr, 0, entry); +} + static void virtio_iommu_detach_endpoint_from_domain(VirtIOIOMMUEndpoint *= ep) { if (!ep->domain) { @@ -307,9 +339,12 @@ static int virtio_iommu_map(VirtIOIOMMU *s, uint64_t virt_start =3D le64_to_cpu(req->virt_start); uint64_t virt_end =3D le64_to_cpu(req->virt_end); uint32_t flags =3D le32_to_cpu(req->flags); + hwaddr size =3D virt_end - virt_start + 1; VirtIOIOMMUDomain *domain; VirtIOIOMMUInterval *interval; VirtIOIOMMUMapping *mapping; + VirtIOIOMMUEndpoint *ep; + IOMMUDevice *sdev; =20 if (flags & ~VIRTIO_IOMMU_MAP_F_MASK) { return VIRTIO_IOMMU_S_INVAL; @@ -339,9 +374,38 @@ static int virtio_iommu_map(VirtIOIOMMU *s, =20 g_tree_insert(domain->mappings, interval, mapping); =20 + /* All devices in an address-space share mapping */ + QLIST_FOREACH(sdev, &s->notifiers_list, next) { + QLIST_FOREACH(ep, &domain->endpoint_list, next) { + if (ep->id =3D=3D sdev->devfn) { + virtio_iommu_notify_map(&sdev->iommu_mr, + virt_start, phys_start, size); + } + } + } + return VIRTIO_IOMMU_S_OK; } =20 +static void virtio_iommu_remove_mapping(VirtIOIOMMU *s, + VirtIOIOMMUDomain *domain, + VirtIOIOMMUInterval *interval) +{ + VirtIOIOMMUEndpoint *ep; + IOMMUDevice *sdev; + + QLIST_FOREACH(sdev, &s->notifiers_list, next) { + QLIST_FOREACH(ep, &domain->endpoint_list, next) { + if (ep->id =3D=3D sdev->devfn) { + virtio_iommu_notify_unmap(&sdev->iommu_mr, + interval->low, + interval->high - interval->low += 1); + } + } + } + g_tree_remove(domain->mappings, (gpointer)(interval)); +} + static int virtio_iommu_unmap(VirtIOIOMMU *s, struct virtio_iommu_req_unmap *req) { @@ -368,7 +432,7 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s, uint64_t current_high =3D iter_key->high; =20 if (interval.low <=3D current_low && interval.high >=3D current_hi= gh) { - g_tree_remove(domain->mappings, iter_key); + virtio_iommu_remove_mapping(s, domain, iter_key); trace_virtio_iommu_unmap_done(domain_id, current_low, current_= high); } else { ret =3D VIRTIO_IOMMU_S_RANGE; @@ -664,6 +728,7 @@ static void virtio_iommu_device_realize(DeviceState *de= v, Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOIOMMU *s =3D VIRTIO_IOMMU(dev); =20 + QLIST_INIT(&s->notifiers_list); virtio_init(vdev, "virtio-iommu", VIRTIO_ID_IOMMU, sizeof(struct virtio_iommu_config)); =20 diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index e83500bee9..d94a1cd8a3 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -73,3 +73,5 @@ virtio_iommu_get_domain(uint32_t domain_id) "Alloc domain= =3D%d" virtio_iommu_put_domain(uint32_t domain_id) "Free domain=3D%d" virtio_iommu_translate_out(uint64_t virt_addr, uint64_t phys_addr, uint32_= t sid) "0x%"PRIx64" -> 0x%"PRIx64 " for sid=3D%d" virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoin= t, uint64_t addr) "FAULT reason=3D%d flags=3D%d endpoint=3D%d address =3D0x= %"PRIx64 +virtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, u= int64_t map_size) "mr=3D%s iova=3D0x%"PRIx64" pa=3D0x%" PRIx64" size=3D0x%"= PRIx64 +virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_si= ze) "mr=3D%s iova=3D0x%"PRIx64" size=3D0x%"PRIx64 --=20 2.17.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=marvell.com ARC-Seal: i=1; a=rsa-sha256; t=1584526695; cv=none; d=zohomail.com; s=zohoarc; b=UfATsfAW9iWUUX6P7i8/X5qb8Lt20pJFCMWDouzgH07qlb7PQz8RLk9u4CTtHFEh11D+149a0VyVIY0FC19r9wN68GWho+0ZRLfBKv6qVW2oFH5repsGvCalVsPL6V1OCzprKHufeUB+1Khh9GeYHDGVH3iWqDec6589hPcxjJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584526695; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EPTWRH4j/7+vQYg4JTRs7Id0RV8zi4mhxOYnQxamw9E=; b=WAGLPqwEteFOHxDmJKweI2FzFJDW3uUmf1sIohHF3GbNraxO6bMjFAKrYae9g/k+gXytZBKBK1gD3aiWoVI0ZxNvNXm7Y01YaUID59srGvH9h/kwPPa3Yh9xwB4ufcHisDJlMVBvlzc9ZNp8iiF66cyIp6aAzgnCXQaYoz7GSG4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584526695970238.2493298298815; Wed, 18 Mar 2020 03:18:15 -0700 (PDT) Received: from localhost ([::1]:48128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVm9-0002S3-1h for importer@patchew.org; Wed, 18 Mar 2020 06:18:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37401) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVgw-0002pP-7G for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEVgu-00055w-VP for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:50 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:50972) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEVgu-00055J-QP; Wed, 18 Mar 2020 06:12:48 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02IABn5a030628; Wed, 18 Mar 2020 03:12:46 -0700 Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2yu9rp9tvp-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 03:12:46 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 03:12:41 -0700 Received: from bbhushan2.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 18 Mar 2020 03:12:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=EPTWRH4j/7+vQYg4JTRs7Id0RV8zi4mhxOYnQxamw9E=; b=WknkTaD9KiEVbj4ysm+kpXckxeLvVwT+/C1G9Ww3cj2J8pu0BwQpnfIO6xHIv2hiYNXq TVbO4nhjq6MZszgcvV+aWbL1yDWyXEir3VoESYKga3dLOGIMeu0YKipRgYN404nJVJmu 0vVaNm6DML6J/HtxXV4UIjRxfZ1Nt4mPVjq+/sU7dmp1u4uRbTCB6IKcHunS8x7TFMUU kSo7H+zB9Ld8o3/zQAXGVZtLqh2RoM5COwbLKTeMPZyPfi3kQHk3OC1XnoGekiiKRis0 sudlzQd3QSwOZB5b64B1cGMgI2I6RurEPkfAW4LfekeMtgcIp6KjsZSpH4Yr3CB3NDAt rQ== From: Bharat Bhushan To: , , , , , , , , , , , , , Subject: [PATCH v8 6/8] virtio-iommu: Call iommu notifier for attach/detach Date: Wed, 18 Mar 2020 15:41:57 +0530 Message-ID: <20200318101159.8767-7-bbhushan2@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318101159.8767-1-bbhushan2@marvell.com> References: <20200318101159.8767-1-bbhushan2@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-18_04:2020-03-18, 2020-03-18 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 67.231.156.173 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: Bharat Bhushan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @marvell.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" iommu-notifier are called when a device is attached or detached to as address-space. This is needed for VFIO. Signed-off-by: Bharat Bhushan --- hw/virtio/virtio-iommu.c | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 623b477b9c..4d522a636a 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -49,6 +49,7 @@ typedef struct VirtIOIOMMUEndpoint { uint32_t id; VirtIOIOMMUDomain *domain; QLIST_ENTRY(VirtIOIOMMUEndpoint) next; + VirtIOIOMMU *viommu; } VirtIOIOMMUEndpoint; =20 typedef struct VirtIOIOMMUInterval { @@ -155,11 +156,48 @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegi= on *mr, hwaddr iova, memory_region_notify_iommu(mr, 0, entry); } =20 +static gboolean virtio_iommu_mapping_unmap(gpointer key, gpointer value, + gpointer data) +{ + VirtIOIOMMUInterval *interval =3D (VirtIOIOMMUInterval *) key; + IOMMUMemoryRegion *mr =3D (IOMMUMemoryRegion *) data; + + virtio_iommu_notify_unmap(mr, interval->low, + interval->high - interval->low + 1); + + return false; +} + +static gboolean virtio_iommu_mapping_map(gpointer key, gpointer value, + gpointer data) +{ + VirtIOIOMMUMapping *mapping =3D (VirtIOIOMMUMapping *) value; + VirtIOIOMMUInterval *interval =3D (VirtIOIOMMUInterval *) key; + IOMMUMemoryRegion *mr =3D (IOMMUMemoryRegion *) data; + + virtio_iommu_notify_map(mr, interval->low, mapping->phys_addr, + interval->high - interval->low + 1); + + return false; +} + static void virtio_iommu_detach_endpoint_from_domain(VirtIOIOMMUEndpoint *= ep) { + VirtIOIOMMU *s =3D ep->viommu; + VirtIOIOMMUDomain *domain =3D ep->domain; + IOMMUDevice *sdev; + if (!ep->domain) { return; } + + QLIST_FOREACH(sdev, &s->notifiers_list, next) { + if (ep->id =3D=3D sdev->devfn) { + g_tree_foreach(domain->mappings, virtio_iommu_mapping_unmap, + &sdev->iommu_mr); + } + } + QLIST_REMOVE(ep, next); ep->domain =3D NULL; } @@ -178,6 +216,7 @@ static VirtIOIOMMUEndpoint *virtio_iommu_get_endpoint(V= irtIOIOMMU *s, } ep =3D g_malloc0(sizeof(*ep)); ep->id =3D ep_id; + ep->viommu =3D s; trace_virtio_iommu_get_endpoint(ep_id); g_tree_insert(s->endpoints, GUINT_TO_POINTER(ep_id), ep); return ep; @@ -274,6 +313,7 @@ static int virtio_iommu_attach(VirtIOIOMMU *s, uint32_t ep_id =3D le32_to_cpu(req->endpoint); VirtIOIOMMUDomain *domain; VirtIOIOMMUEndpoint *ep; + IOMMUDevice *sdev; =20 trace_virtio_iommu_attach(domain_id, ep_id); =20 @@ -299,6 +339,14 @@ static int virtio_iommu_attach(VirtIOIOMMU *s, =20 ep->domain =3D domain; =20 + /* Replay domain mappings on the associated memory region */ + QLIST_FOREACH(sdev, &s->notifiers_list, next) { + if (ep_id =3D=3D sdev->devfn) { + g_tree_foreach(domain->mappings, virtio_iommu_mapping_map, + &sdev->iommu_mr); + } + } + return VIRTIO_IOMMU_S_OK; } =20 @@ -873,6 +921,7 @@ static gboolean reconstruct_endpoints(gpointer key, gpo= inter value, =20 QLIST_FOREACH(iter, &d->endpoint_list, next) { iter->domain =3D d; + iter->viommu =3D s; g_tree_insert(s->endpoints, GUINT_TO_POINTER(iter->id), iter); } return false; /* continue the domain traversal */ --=20 2.17.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=marvell.com ARC-Seal: i=1; a=rsa-sha256; t=1584526577; cv=none; d=zohomail.com; s=zohoarc; b=YhCu6+/3BL2lEOvnw/7xHQ9Z7Ss+V08zRhXYcUkAascohbm6RoKJJEM5SkpgJnZ8+uy0qFQ94xbKqxLACzHb7SQoA3IE8xcsqBsZoniyqoxfT/FRAGZLpeh1I1A1qKMjV5CMCENt/mu2XnslhOoFGCfi/9bk7aw7uFR16nZ2wME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584526577; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=H70ira2xI4tp3d4NOT3PQrNRuE9cpJhM0WachNeWQc4=; b=a4Bo0+t91i0wKpSKU6CVQE9+v3lqGTaeOS8HLXs+MACkm6mg9JiDNixRb8J2fb5eKOuqQFM7AGxhy6h5LzNn5MTnMII+GLkszaDt/YVFQZW1GlVSx1ZdhHX/QKQYgBDuCTs79wG9xjMqCTxldynk/jiX9lE3R/gpz2uV6ovSTXo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584526577787681.8710486122902; Wed, 18 Mar 2020 03:16:17 -0700 (PDT) Received: from localhost ([::1]:48088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVkG-00086B-9Z for importer@patchew.org; Wed, 18 Mar 2020 06:16:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37454) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVgz-0002wn-PX for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEVgy-0005Cy-AK for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:12:53 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:7028) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEVgy-0005AF-4k; Wed, 18 Mar 2020 06:12:52 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02IACGVT031196; Wed, 18 Mar 2020 03:12:49 -0700 Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2yu9rp9tw1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 03:12:49 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 03:12:47 -0700 Received: from bbhushan2.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 18 Mar 2020 03:12:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=H70ira2xI4tp3d4NOT3PQrNRuE9cpJhM0WachNeWQc4=; b=RMqK6DZROWHvl415vE9qM1Y3H+cAuz51UAMzxajdb3zmL3iA5DLt6h7B2zzruLgio+Ka Tb8/SF2BUf3ZN+uKta38tThj+LXPz2VMpe9lO0Vgyts3+u5gBGW/E0aXy1cAHoMrNEmS HsTggBaKXxZT4CuIISSLyMcErku15DTadEUyA6FCmCgc06bUKLYd7nHaK2DSxH05odHY 3XuD9Uc0V8ga+JLawhBWI67iXbAa+CNxsfKn8j28VsL/lAfh5fS4B9M9UAsPsOh9Td6q Yl6rFWsVtMmAbX2Q1MSWs2sDGjnQajT4ajCiZSroteArRaIRxBg1wNHJQ44nrrs0z1Jw KA== From: Bharat Bhushan To: , , , , , , , , , , , , , Subject: [PATCH v8 7/8] virtio-iommu: add iommu replay Date: Wed, 18 Mar 2020 15:41:58 +0530 Message-ID: <20200318101159.8767-8-bbhushan2@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318101159.8767-1-bbhushan2@marvell.com> References: <20200318101159.8767-1-bbhushan2@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-18_04:2020-03-18, 2020-03-18 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 67.231.156.173 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: Bharat Bhushan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @marvell.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Default replay does not work with virtio-iommu, so this patch provide virtio-iommu replay functionality. Signed-off-by: Bharat Bhushan --- hw/virtio/virtio-iommu.c | 44 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/trace-events | 1 + 2 files changed, 45 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 4d522a636a..b68644f7c3 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -771,6 +771,49 @@ static void virtio_iommu_set_page_size_mask(IOMMUMemor= yRegion *mr, s->config.page_size_mask =3D page_size_mask; } =20 +static gboolean virtio_iommu_remap(gpointer key, gpointer value, gpointer = data) +{ + VirtIOIOMMUMapping *mapping =3D (VirtIOIOMMUMapping *) value; + VirtIOIOMMUInterval *interval =3D (VirtIOIOMMUInterval *) key; + IOMMUMemoryRegion *mr =3D (IOMMUMemoryRegion *) data; + + trace_virtio_iommu_remap(interval->low, mapping->phys_addr, + interval->high - interval->low + 1); + /* unmap previous entry and map again */ + virtio_iommu_notify_unmap(mr, interval->low, + interval->high - interval->low + 1); + + virtio_iommu_notify_map(mr, interval->low, mapping->phys_addr, + interval->high - interval->low + 1); + return false; +} + +static void virtio_iommu_replay(IOMMUMemoryRegion *mr, IOMMUNotifier *n) +{ + IOMMUDevice *sdev =3D container_of(mr, IOMMUDevice, iommu_mr); + VirtIOIOMMU *s =3D sdev->viommu; + uint32_t sid; + VirtIOIOMMUEndpoint *ep; + + sid =3D virtio_iommu_get_bdf(sdev); + + qemu_mutex_lock(&s->mutex); + + if (!s->endpoints) { + goto unlock; + } + + ep =3D g_tree_lookup(s->endpoints, GUINT_TO_POINTER(sid)); + if (!ep || !ep->domain) { + goto unlock; + } + + g_tree_foreach(ep->domain->mappings, virtio_iommu_remap, mr); + +unlock: + qemu_mutex_unlock(&s->mutex); +} + static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -989,6 +1032,7 @@ static void virtio_iommu_memory_region_class_init(Obje= ctClass *klass, =20 imrc->translate =3D virtio_iommu_translate; imrc->iommu_set_page_size_mask =3D virtio_iommu_set_page_size_mask; + imrc->replay =3D virtio_iommu_replay; } =20 static const TypeInfo virtio_iommu_info =3D { diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index d94a1cd8a3..8bae651191 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -75,3 +75,4 @@ virtio_iommu_translate_out(uint64_t virt_addr, uint64_t p= hys_addr, uint32_t sid) virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoin= t, uint64_t addr) "FAULT reason=3D%d flags=3D%d endpoint=3D%d address =3D0x= %"PRIx64 virtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, u= int64_t map_size) "mr=3D%s iova=3D0x%"PRIx64" pa=3D0x%" PRIx64" size=3D0x%"= PRIx64 virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_si= ze) "mr=3D%s iova=3D0x%"PRIx64" size=3D0x%"PRIx64 +virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size) "iova=3D0x%"= PRIx64" pa=3D0x%" PRIx64" size=3D0x%"PRIx64"" --=20 2.17.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=marvell.com ARC-Seal: i=1; a=rsa-sha256; t=1584526679; cv=none; d=zohomail.com; s=zohoarc; b=QwHgenFqhDq9uq0LZGTgDdTy4VyQfYO4Pj/zV46BvatZmipu7dZsNjXFehLIOZA1iyJO8YL2C9kks23ehmT0ufg5uOBkSwUy8ZzyHtqkHCDSnH7CVw01xMuJjFjTfqQjdDtjckGQymMcII9etf6zSX4Ea+a704g7cuJYPySeZP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584526679; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b/xFgYePXPIX12aaAGxsXGPT9CqkwDZHYIS0r7ZTW0U=; b=VEXU4eYckVKN5WBJ9hTtEaINIz3BZvJ6XNAGpDZiciNROg5GqmMnf0niXQUwMY9XCQp1l6fOjocWJewpYxl8Ax+52Y7GdsGwLNe8aUc9ZxpiQw5OI/3qL1I7HsQZQrSJEqZXSM9JK3dYoADFSG0NYEo7tBg6ICYj4qvFwFJTfqw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584526679326761.2060887402772; Wed, 18 Mar 2020 03:17:59 -0700 (PDT) Received: from localhost ([::1]:48124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVlt-0001xp-TF for importer@patchew.org; Wed, 18 Mar 2020 06:17:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37524) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEVh7-0003Fw-QA for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:13:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEVh6-0005Uc-Eq for qemu-devel@nongnu.org; Wed, 18 Mar 2020 06:13:01 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:26454) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEVh4-0005Py-0j; Wed, 18 Mar 2020 06:12:58 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02IABnOg030625; Wed, 18 Mar 2020 03:12:55 -0700 Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2yu9rp9tw8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 03:12:55 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 03:12:54 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 03:12:53 -0700 Received: from bbhushan2.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 18 Mar 2020 03:12:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=b/xFgYePXPIX12aaAGxsXGPT9CqkwDZHYIS0r7ZTW0U=; b=VeCzmd+6ZI6MCKt9Hit8BdNR4+pYplmI9iihYkvkau//8osJb0goh3S0uoIcqGHVc1tp hsaTgvxtfMNwT9qa37H/T1VboZFSEERC5PjKPl0sfyvFa39kYeXBiJNXh4Yb3HT6KOJA 2JrngrMGmOzmIvRtW5evinqpl6dd+8f7cTrxlPjsOhYOV5nEC5zob4hzkOulo2Z5VdVw iViLcJaN99oJGQEhso/56au+GMSQGvZY74P6tCKbwxGNtbxnlinnTz/LEQyZ0ILLE+Qw iLxwPzK8YvclSEiXRCYyuVtyoyTOft+aa0j4dJNP6Wfk59f3qcfqzn2A6REv14z/zAiQ 2Q== From: Bharat Bhushan To: , , , , , , , , , , , , , Subject: [PATCH v8 8/8] virtio-iommu: add iommu notifier memory-region Date: Wed, 18 Mar 2020 15:41:59 +0530 Message-ID: <20200318101159.8767-9-bbhushan2@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318101159.8767-1-bbhushan2@marvell.com> References: <20200318101159.8767-1-bbhushan2@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-18_04:2020-03-18, 2020-03-18 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 67.231.156.173 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: Bharat Bhushan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @marvell.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Finally add notify_flag_changed() to for memory-region access flag iommu flag change notifier Finally add the memory notifier Signed-off-by: Bharat Bhushan --- hw/virtio/virtio-iommu.c | 22 ++++++++++++++++++++++ hw/virtio/trace-events | 2 ++ 2 files changed, 24 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index b68644f7c3..515c965e3c 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -814,6 +814,27 @@ unlock: qemu_mutex_unlock(&s->mutex); } =20 +static int virtio_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu_mr, + IOMMUNotifierFlag old, + IOMMUNotifierFlag new, + Error **errp) +{ + IOMMUDevice *sdev =3D container_of(iommu_mr, IOMMUDevice, iommu_mr); + VirtIOIOMMU *s =3D sdev->viommu; + + if (old =3D=3D IOMMU_NOTIFIER_NONE) { + trace_virtio_iommu_notify_flag_add(iommu_mr->parent_obj.name); + QLIST_INSERT_HEAD(&s->notifiers_list, sdev, next); + return 0; + } + + if (new =3D=3D IOMMU_NOTIFIER_NONE) { + trace_virtio_iommu_notify_flag_del(iommu_mr->parent_obj.name); + QLIST_REMOVE(sdev, next); + } + return 0; +} + static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -1033,6 +1054,7 @@ static void virtio_iommu_memory_region_class_init(Obj= ectClass *klass, imrc->translate =3D virtio_iommu_translate; imrc->iommu_set_page_size_mask =3D virtio_iommu_set_page_size_mask; imrc->replay =3D virtio_iommu_replay; + imrc->notify_flag_changed =3D virtio_iommu_notify_flag_changed; } =20 static const TypeInfo virtio_iommu_info =3D { diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 8bae651191..a486adcf6d 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -76,3 +76,5 @@ virtio_iommu_report_fault(uint8_t reason, uint32_t flags,= uint32_t endpoint, uin virtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, u= int64_t map_size) "mr=3D%s iova=3D0x%"PRIx64" pa=3D0x%" PRIx64" size=3D0x%"= PRIx64 virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_si= ze) "mr=3D%s iova=3D0x%"PRIx64" size=3D0x%"PRIx64 virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size) "iova=3D0x%"= PRIx64" pa=3D0x%" PRIx64" size=3D0x%"PRIx64"" +virtio_iommu_notify_flag_add(const char *iommu) "Add virtio-iommu notifier= node for memory region %s" +virtio_iommu_notify_flag_del(const char *iommu) "Del virtio-iommu notifier= node for memory region %s" --=20 2.17.1