From nobody Fri Nov 14 16:58:17 2025 Delivered-To: importer@patchew.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=nvidia.com ARC-Seal: i=1; a=rsa-sha256; t=1588635018; cv=none; d=zohomail.com; s=zohoarc; b=ktfdq8Kx6rcMrZNbcXD/ujuJofolbZXdASX0lHog3UWOPXtkhIgJJHCd+Xw9urpV9RXRllskKhmLdxLwBlx/tSTMJfyJhzMWd7OnTv/98aqBTJ8pU1rP/fL3f3BLDFVRr1Cll9Z8mNcjFYS45cwl+BpcCQ3zmgdJyp6aKR0vumc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588635018; 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=O9XV7D5FxmOFBmprNRbpwsU4to7+MGZBhc9zVXWkdKk=; b=fQ91KrfjJOAk918ewLkyrPUBqgzFp/gsl2mzErthx5B0Tgq/3nW9HExkdUn04eMEcJUWAk/9EBUvDocToDbs2V8CQ+tEEjXTBh9q/pkk3jRlhyrOsQLTfKT1nPVHTPppOsrESUeTdsUpB8b4fQA5l/GVAteDAPR/ivmddH9B+7U= 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 1588635018608289.71915926305303; Mon, 4 May 2020 16:30:18 -0700 (PDT) Received: from localhost ([::1]:58216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVkXR-0000Hp-3T for importer@patchew.org; Mon, 04 May 2020 19:30:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVkNA-0002Dk-V3 for qemu-devel@nongnu.org; Mon, 04 May 2020 19:19:40 -0400 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:5558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVkN7-00082T-LS for qemu-devel@nongnu.org; Mon, 04 May 2020 19:19:40 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 04 May 2020 16:19:23 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 04 May 2020 16:19:35 -0700 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 4 May 2020 23:19:35 +0000 Received: from kwankhede-dev.nvidia.com (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 4 May 2020 23:19:28 +0000 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 04 May 2020 16:19:35 -0700 From: Kirti Wankhede To: , Subject: [PATCH v18 QEMU 11/18] iommu: add callback to get address limit IOMMU supports Date: Tue, 5 May 2020 04:14:46 +0530 Message-ID: <1588632293-18932-12-git-send-email-kwankhede@nvidia.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1588632293-18932-1-git-send-email-kwankhede@nvidia.com> References: <1588632293-18932-1-git-send-email-kwankhede@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1588634363; bh=O9XV7D5FxmOFBmprNRbpwsU4to7+MGZBhc9zVXWkdKk=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=WqXbfirPqU4OtM5t8sLxbiG00sBgWtJQRmrAa6ypGcAiiom0jFE2Nxdz2FZCtFOdg +lSjOgXN8a4WaM+ZRP71ndwmqqa2aq1AfgI/B61zTTFS2hfcbQVnygToy8eCoiFHQO UoBLux277YZFVvWtxt8S95Q8tXkcsPXUwJAFztgVJXY+bfmmNIvlbMLmjzP+8U8b5+ apVYcIqDmhzVV5FVqPIHT6ocuY0a0+fq+5eZw431iAGKWevRdeyYeBGhoVpDniercB 8WOj1JDZPvUKsNx4RKmWTmnNLfXcmyUD0WGZGHcLMbFV7Jy1JdWFgAp7JhCXQ2Cz1t SRHcge+6uYeMg== 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; Received-SPF: pass client-ip=216.228.121.65; envelope-from=kwankhede@nvidia.com; helo=hqnvemgate26.nvidia.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/04 19:18:18 X-ACL-Warn: Detected OS = Windows 7 or 8 [fuzzy] X-Spam_score_int: -70 X-Spam_score: -7.1 X-Spam_bar: ------- X-Spam_report: (-7.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_HI=-5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: cohuck@redhat.com, aik@ozlabs.ru, Zhengxiao.zx@Alibaba-inc.com, shuangtai.tst@alibaba-inc.com, qemu-devel@nongnu.org, peterx@redhat.com, Kirti Wankhede , eauger@redhat.com, yi.l.liu@intel.com, quintela@redhat.com, ziye.yang@intel.com, armbru@redhat.com, mlevitsk@redhat.com, pasic@linux.ibm.com, felipe@nutanix.com, zhi.a.wang@intel.com, kevin.tian@intel.com, yan.y.zhao@intel.com, dgilbert@redhat.com, changpeng.liu@intel.com, eskultet@redhat.com, Ken.Xue@amd.com, jonathan.davies@nutanix.com, pbonzini@redhat.com 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" Add optional method to get address limit IOMMU supports Signed-off-by: Kirti Wankhede --- hw/i386/intel_iommu.c | 9 +++++++++ include/exec/memory.h | 18 ++++++++++++++++++ memory.c | 11 +++++++++++ 3 files changed, 38 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index df7ad254ac15..d0b88c20c31e 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3577,6 +3577,14 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iomm= u_mr, IOMMUNotifier *n) return; } =20 +static hwaddr vtd_iommu_get_address_limit(IOMMUMemoryRegion *iommu_mr) +{ + VTDAddressSpace *vtd_as =3D container_of(iommu_mr, VTDAddressSpace, io= mmu); + IntelIOMMUState *s =3D vtd_as->iommu_state; + + return VTD_ADDRESS_SIZE(s->aw_bits) - 1; +} + /* Do the initialization. It will also be called when reset, so pay * attention when adding new initialization stuff. */ @@ -3878,6 +3886,7 @@ static void vtd_iommu_memory_region_class_init(Object= Class *klass, imrc->translate =3D vtd_iommu_translate; imrc->notify_flag_changed =3D vtd_iommu_notify_flag_changed; imrc->replay =3D vtd_iommu_replay; + imrc->get_address_limit =3D vtd_iommu_get_address_limit; } =20 static const TypeInfo vtd_iommu_memory_region_info =3D { diff --git a/include/exec/memory.h b/include/exec/memory.h index e000bd2f97b2..2d0cbd46d2a6 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); + + /* + * Return address limit this IOMMU supports. + * + * Optional method: if this method is not provided, then + * memory_region_iommu_get_address_limit() will return 0. + * + * @iommu: the IOMMUMemoryRegion + */ + hwaddr (*get_address_limit)(IOMMUMemoryRegion *iommu); } IOMMUMemoryRegionClass; =20 typedef struct CoalescedMemoryRange CoalescedMemoryRange; @@ -1364,6 +1374,14 @@ int memory_region_iommu_attrs_to_index(IOMMUMemoryRe= gion *iommu_mr, int memory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr); =20 /** + * memory_region_iommu_get_address_limit : return the maximum address limit + * that this IOMMU supports. + * + * @iommu_mr: the memory region + */ +hwaddr memory_region_iommu_get_address_limit(IOMMUMemoryRegion *iommu_mr); + +/** * memory_region_name: get a memory region's name * * Returns the string that was used to initialize the memory region. diff --git a/memory.c b/memory.c index 601b74990620..52f1a4cd37f0 100644 --- a/memory.c +++ b/memory.c @@ -1887,6 +1887,17 @@ void memory_region_iommu_replay(IOMMUMemoryRegion *i= ommu_mr, IOMMUNotifier *n) } } =20 +hwaddr memory_region_iommu_get_address_limit(IOMMUMemoryRegion *iommu_mr) +{ + IOMMUMemoryRegionClass *imrc =3D IOMMU_MEMORY_REGION_GET_CLASS(iommu_m= r); + + if (imrc->get_address_limit) { + return imrc->get_address_limit(iommu_mr); + } + + return 0; +} + void memory_region_unregister_iommu_notifier(MemoryRegion *mr, IOMMUNotifier *n) { --=20 2.7.0