Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp60318ybg; Mon, 27 Jul 2020 23:25:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+Dq3tNPog927rXDR9nprTgwZdgodJU3maaGVn3J5EtgKKZ2LOI6TEul7PIXwmm7fxTeUd X-Received: by 2002:a05:6402:22fc:: with SMTP id dn28mr10478018edb.381.1595917538969; Mon, 27 Jul 2020 23:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595917538; cv=none; d=google.com; s=arc-20160816; b=sLLQ1UeCQVHR44CmMp3R4D6GNqb/XXiEBalTByK/IBX4RWBjrGxBWfjJRqrp1vm046 GJtJ5IMSt1K5UarxGgSBd5vy7tUAZHKYHigXjJFmnhfveEjrd9/0k2shjEpUSyuxq9wL poHlBQeveedocs+F9lgyJhpJu9XCo5lt2dkFdnDp3X2nU5y7+TS5/PMBgZeXAF/8ug8J iJ2Wr1Szb5NxOE+whu/fQOAo3Qmg28jNvjT/t8LSJWGp5WZZkGs6zCNx+QLl+ZckHLdU hCl/HkqwEpR1qDt3wo4gXrGxUDkDB55mAKSUL+SNfkoXrxzsUn8y/2nbD0i/viALopjN E9Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=fgFpf6rNtrvG1FSx+A9DSNFjB8i9nnq+QRcxdgQjOYs=; b=ulofp3fRGRtsTrEz5pZhHL/j3yIJwMMF3BUS5c1GZlaiTh3+D2y1gUd4U1tqbm5i75 Zy3OQR1Fzjq5ab3v838WlJpvCSWAF6vHV4b7YOU7dgPhueFmlNmrXHoYK2DCpj6uKHOK Hmmndgd0tnNDEPaaCnLtGqoMfUVaxZSFN84sdZyssVDY1nykTI7NATqxIuWP8Z/PD+nW pxcz4+JvMABOvGYuot5GPlKaLi+2ffoULIXBrcs3/sdx8Clpu7vl5cd/WBTHdy3wHx93 8os8EI+4D2RomKgVEnlKwmg5rF9gS5+20m356kfiuJK9Mb/8EzomtVIm5ZrCWlQRuq4e 4Yyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j21si5876622edh.20.2020.07.27.23.25.16; Mon, 27 Jul 2020 23:25:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727813AbgG1GU7 (ORCPT + 99 others); Tue, 28 Jul 2020 02:20:59 -0400 Received: from mga06.intel.com ([134.134.136.31]:26362 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727087AbgG1GU5 (ORCPT ); Tue, 28 Jul 2020 02:20:57 -0400 IronPort-SDR: MrjbY7M+Am5TJgcPZAfNYZYEtfVedJWYDkEShFvpbate5Vk/9CUoZDMM7ZC4dqb8oEEjBsGLA0 p8pd+AVdGaJA== X-IronPort-AV: E=McAfee;i="6000,8403,9695"; a="212681238" X-IronPort-AV: E=Sophos;i="5.75,405,1589266800"; d="scan'208";a="212681238" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2020 23:20:55 -0700 IronPort-SDR: FdetQ7pJX1vBwEWxMioDORW1sMLGf3G1G+2QwRHnLuTHtAKD7fop8b58T+v2E27JYezdazCnpL Pjz2f6s+6Bbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,405,1589266800"; d="scan'208";a="320274388" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga008.jf.intel.com with ESMTP; 27 Jul 2020 23:20:55 -0700 From: Liu Yi L To: alex.williamson@redhat.com, eric.auger@redhat.com, baolu.lu@linux.intel.com, joro@8bytes.org Cc: kevin.tian@intel.com, jacob.jun.pan@linux.intel.com, ashok.raj@intel.com, yi.l.liu@intel.com, jun.j.tian@intel.com, yi.y.sun@intel.com, jean-philippe@linaro.org, peterx@redhat.com, hao.wu@intel.com, stefanha@gmail.com, iommu@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Will Deacon , Robin Murphy Subject: [PATCH v6 03/15] iommu/smmu: Report empty domain nesting info Date: Mon, 27 Jul 2020 23:27:32 -0700 Message-Id: <1595917664-33276-4-git-send-email-yi.l.liu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595917664-33276-1-git-send-email-yi.l.liu@intel.com> References: <1595917664-33276-1-git-send-email-yi.l.liu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is added as instead of returning a boolean for DOMAIN_ATTR_NESTING, iommu_domain_get_attr() should return an iommu_nesting_info handle. For now, return an empty nesting info struct for now as true nesting is not yet supported by the SMMUs. Cc: Will Deacon Cc: Robin Murphy Cc: Eric Auger Cc: Jean-Philippe Brucker Reviewed-by: Eric Auger Suggested-by: Jean-Philippe Brucker Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- v5 -> v6: *) add review-by from Eric Auger. v4 -> v5: *) address comments from Eric Auger. --- drivers/iommu/arm-smmu-v3.c | 29 +++++++++++++++++++++++++++-- drivers/iommu/arm-smmu.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index f578677..c702ef9 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -3019,6 +3019,32 @@ static struct iommu_group *arm_smmu_device_group(struct device *dev) return group; } +static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain, + void *data) +{ + struct iommu_nesting_info *info = (struct iommu_nesting_info *)data; + unsigned int size; + + if (!info || smmu_domain->stage != ARM_SMMU_DOMAIN_NESTED) + return -ENODEV; + + size = sizeof(struct iommu_nesting_info); + + /* + * if provided buffer size is smaller than expected, should + * return 0 and also the expected buffer size to caller. + */ + if (info->argsz < size) { + info->argsz = size; + return 0; + } + + /* report an empty iommu_nesting_info for now */ + memset(info, 0x0, size); + info->argsz = size; + return 0; +} + static int arm_smmu_domain_get_attr(struct iommu_domain *domain, enum iommu_attr attr, void *data) { @@ -3028,8 +3054,7 @@ static int arm_smmu_domain_get_attr(struct iommu_domain *domain, case IOMMU_DOMAIN_UNMANAGED: switch (attr) { case DOMAIN_ATTR_NESTING: - *(int *)data = (smmu_domain->stage == ARM_SMMU_DOMAIN_NESTED); - return 0; + return arm_smmu_domain_nesting_info(smmu_domain, data); default: return -ENODEV; } diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 243bc4c..2bd58f4 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1506,6 +1506,32 @@ static struct iommu_group *arm_smmu_device_group(struct device *dev) return group; } +static int arm_smmu_domain_nesting_info(struct arm_smmu_domain *smmu_domain, + void *data) +{ + struct iommu_nesting_info *info = (struct iommu_nesting_info *)data; + unsigned int size; + + if (!info || smmu_domain->stage != ARM_SMMU_DOMAIN_NESTED) + return -ENODEV; + + size = sizeof(struct iommu_nesting_info); + + /* + * if provided buffer size is smaller than expected, should + * return 0 and also the expected buffer size to caller. + */ + if (info->argsz < size) { + info->argsz = size; + return 0; + } + + /* report an empty iommu_nesting_info for now */ + memset(info, 0x0, size); + info->argsz = size; + return 0; +} + static int arm_smmu_domain_get_attr(struct iommu_domain *domain, enum iommu_attr attr, void *data) { @@ -1515,8 +1541,7 @@ static int arm_smmu_domain_get_attr(struct iommu_domain *domain, case IOMMU_DOMAIN_UNMANAGED: switch (attr) { case DOMAIN_ATTR_NESTING: - *(int *)data = (smmu_domain->stage == ARM_SMMU_DOMAIN_NESTED); - return 0; + return arm_smmu_domain_nesting_info(smmu_domain, data); default: return -ENODEV; } -- 2.7.4