Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp43100ybt; Mon, 6 Jul 2020 03:40:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtlyRaKAPfr5QbQHKs2X5pDHJcc43xhbnCmBFnGIilp35t4v2sgQ9GZAMEc4vGkoIZH4j3 X-Received: by 2002:a17:906:7f90:: with SMTP id f16mr42103393ejr.507.1594032004904; Mon, 06 Jul 2020 03:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594032004; cv=none; d=google.com; s=arc-20160816; b=EIgsW7WzlikNmONPOVHxIwpFd53Gi6QcL5ujl0vsMddlaNa0EwYYRLZ6rKsHyooGQe Aly4791QZe0C6rTwvhVAuS34pdmUyJTTrO0QJIn2ZWPbVCPk2hpnXHLMtbQHy0yhVtTB tac4W8BB1XLC3bwqJ+dzfE0s6Nen8fUbrEsMk314nykgDx4DOKpQ/apS52GRXDXsNq9f if31AXyveV/OfTFlxJ5Me35TgLYp+ad+pNT/xzuQnbbBggLR24oMY6dX4NNcXXgeKJyl kwr9igMzLcR4+WVaEVa5vjAztP3OYBZWpa9qxIdK2fdTjrBHfY7ejkA2qFfPM0WhNpvl c37Q== 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=bgnGmr6YoaFNKwoM2eHV+2bomQ6S8w77Ix5AEQGG/so=; b=Knleug973DJU8HOD2VNx3yhIapYm359QSVK9tqMpoWvUxV3tnOkqbBAuJK/0Ov2Z3m rAgyG51+cpc9q6hvbCWin5OjQgUSUBIC0KEjQ4jDo2lADG1QFaFeeYaO7yLrUulUj9mN cp0OqTdI5u5K4lt4iXDYCFCigNJkmmZZMA7dLrw6wf1ADSpI/XC3eYFA4q9VpipYlU0t UySzuhGcbM2q16bzRq0IIfO+ZjkjPIrPEwjggLERd9C3AtY04BrIXpAsYr+Lp3qe+XZf 4rPOS/BYrlqttQ3jBdpWcWdtxhBjEK1gdBiUj6BjxvMnYQpspkZVw1e92PBwok1kUcxU X7zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cy+bQZJu; 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 ss14si12806230ejb.732.2020.07.06.03.39.41; Mon, 06 Jul 2020 03:40:04 -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=cy+bQZJu; 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 S1728861AbgGFKhU (ORCPT + 99 others); Mon, 6 Jul 2020 06:37:20 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54014 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728422AbgGFKhU (ORCPT ); Mon, 6 Jul 2020 06:37:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594031838; 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=bgnGmr6YoaFNKwoM2eHV+2bomQ6S8w77Ix5AEQGG/so=; b=cy+bQZJukRH70oGwL75Wl7dXOvYq/XI+cg1uzG7HfLefpQQAYWgPE6X94JoTeFvF3dTItY A0eKNpu/GLdLz2og0lM+qMghvzHh5cF36rC9qhO7dmWP9WUMQU/RYeUhaUu15xcHfT3oMm uq0J338wubwDMySWmxUHZkvhnRzMpTM= 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-452-w_y5Go2iN06qyf9u9pA5LQ-1; Mon, 06 Jul 2020 06:37:16 -0400 X-MC-Unique: w_y5Go2iN06qyf9u9pA5LQ-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 02D778015CE; Mon, 6 Jul 2020 10:37:13 +0000 (UTC) Received: from [10.36.113.241] (ovpn-113-241.ams2.redhat.com [10.36.113.241]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 47D835C1B2; Mon, 6 Jul 2020 10:37:03 +0000 (UTC) Subject: Re: [PATCH v4 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: <1593861989-35920-1-git-send-email-yi.l.liu@intel.com> <1593861989-35920-4-git-send-email-yi.l.liu@intel.com> From: Auger Eric Message-ID: Date: Mon, 6 Jul 2020 12:37:01 +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: <1593861989-35920-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 Hi Yi, Please add a commit message: instead of returning a boolean for DOMAIN_ATTR_NESTING, arm_smmu_domain_get_attr() returns a iommu_nesting_info handle. On 7/4/20 1:26 PM, Liu Yi L wrote: > 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 > --- > 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..0c45d4d 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; > + u32 size; > + > + if (!info || smmu_domain->stage != ARM_SMMU_DOMAIN_NESTED) > + return -ENODEV; > + > + size = sizeof(struct iommu_nesting_info); > + > + /* > + * if provided buffer size is not equal to the size, should > + * return 0 and also the expected buffer size to caller. > + */ > + if (info->size != size) { < size? > + info->size = size; > + return 0; > + } > + > + /* report an empty iommu_nesting_info for now */ > + memset(info, 0x0, size); > + info->size = size; For info, the current SMMU NESTED mode is not enabling any nesting. It just forces the usage of the 2st stage instead of stage1 for single stage translation. Thanks Eric > + 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..908607d 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; > + u32 size; > + > + if (!info || smmu_domain->stage != ARM_SMMU_DOMAIN_NESTED) > + return -ENODEV; > + > + size = sizeof(struct iommu_nesting_info); > + > + /* > + * if provided buffer size is not equal to the size, 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; > } >