Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2147725ybh; Fri, 17 Jul 2020 10:22:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYH6Iyctq++By940xyVuRZf3WGHCSgNRWEOZYXLP1FHZMWHs+EojI0k7j0457oaZBaXNKG X-Received: by 2002:a17:906:c30b:: with SMTP id s11mr9775698ejz.263.1595006520419; Fri, 17 Jul 2020 10:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595006520; cv=none; d=google.com; s=arc-20160816; b=hb3NMTODrReSCTweZDp7mxWiMm2snrP/2cDSHRzYR/VYmbWTCFAt2FaJmYF+DfQ6j7 wThU4FZTyLpXkDRGhxbX0AzxG9yyQ/UM7BzbITKkbqFxYidSvT4a6yZiaANfpoV2xyv8 e3wzwC7sUO/RhJpcbuIR6ewNE+DddqJiXhbPQjfRkeRqiK26aOq7xdIZVGazeepyEGt8 V+Xl2764iKjbgHwuJleBYK6KuJUN9gSv/vYy4UAu4hxFLhtmXWLO1xASseJgAqTVpJM+ bw+pHJNNJap/opEzhWMOfBW2H7tdmkvF+ZeAmewkQJh9fweQbklgrLlKhCQNltgVG0+r CElw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=gpEKoCVUb0H9sRGX33KH+Wdr5W7X+RwCM8FI3G3gcaI=; b=pDwSn9rOXR938ha7Jlwx9lAJoP4vr+fQKYJnZrLOfkDmQuf4SscsFq37BFc+EWeUnK PovdNKFG3I7fTRPF1yBKgIG8sMJMK8rQNIZ7TLAioqno/2dtTkXSbjr7Fmstev2Cn+Eh 5k6+CaCmB/VcpqclR2g4rsYMcZyQQJBNtKzUXqHuQbojrbPoSiXNXKXd7nONT/6kENsr FPW814mePCp7Ti2VZWzLxIkvC4vjhPspal5W+cvGL9VUSy8d/jDosjvsTguu07I+8CuX DULGy8hXtmtT7akx1U6rHQmm1zc7wz8DiY4WAzNqp9mb4XFzK1hc076QCwfKMA3dPUd2 ULqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Dh6x2VRv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si5648072edp.98.2020.07.17.10.21.37; Fri, 17 Jul 2020 10:22:00 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Dh6x2VRv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726635AbgGQRSg (ORCPT + 99 others); Fri, 17 Jul 2020 13:18:36 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:25836 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726293AbgGQRSf (ORCPT ); Fri, 17 Jul 2020 13:18:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595006313; 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=gpEKoCVUb0H9sRGX33KH+Wdr5W7X+RwCM8FI3G3gcaI=; b=Dh6x2VRvE8ReYD/NwYO6oLsky1iu2gAnsEBZRmvKiTvZQyz4KiWZCLSko1bZKVOPlptAuj DcA6ID/mjqZyWFpbVD0XlYx84Acu+Fbcs6WOULi2ZS7ssaIVd2O0q8rzZi/yMxgBqocc3q VI0mjsYeYKXMfGe3AS9ryx6I6kwvifk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-34-gw8k3hR8OzK81GZ112l71Q-1; Fri, 17 Jul 2020 13:18:29 -0400 X-MC-Unique: gw8k3hR8OzK81GZ112l71Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39F2C8005B0; Fri, 17 Jul 2020 17:18:27 +0000 (UTC) Received: from [10.36.115.54] (ovpn-115-54.ams2.redhat.com [10.36.115.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 924B75C1D4; Fri, 17 Jul 2020 17:18:17 +0000 (UTC) Subject: Re: [PATCH v5 03/15] iommu/smmu: Report empty domain nesting info To: Liu Yi L , alex.williamson@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, 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 References: <1594552870-55687-1-git-send-email-yi.l.liu@intel.com> <1594552870-55687-4-git-send-email-yi.l.liu@intel.com> From: Auger Eric Message-ID: <5ee6b661-9c46-20ee-332a-1a449b6f3a43@redhat.com> Date: Fri, 17 Jul 2020 19:18:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <1594552870-55687-4-git-send-email-yi.l.liu@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Yi, On 7/12/20 1:20 PM, Liu Yi L wrote: > 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. you may add in the commit message you return an empty nesting info struct for now as true nesting is not yet supported by the SMMUs. Besides: Reviewed-by: Eric Auger Thanks Eric > > Cc: Will Deacon > Cc: Robin Murphy > Cc: Eric Auger > Cc: Jean-Philippe Brucker > Suggested-by: Jean-Philippe Brucker > Signed-off-by: Liu Yi L > Signed-off-by: Jacob Pan > --- > 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..ec815d7 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->size < size) { > + info->size = size; > + return 0; > + } > + > + /* report an empty iommu_nesting_info for now */ > + memset(info, 0x0, size); > + info->size = 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..09e2f1b 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->size < size) { > + info->size = size; > + return 0; > + } > + > + /* report an empty iommu_nesting_info for now */ > + memset(info, 0x0, size); > + info->size = 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; > } >