Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3658pxb; Tue, 23 Feb 2021 16:15:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyagBqneFdvwxJvFP72SQTTf2nctOGYz2Sge2o0UgQkOhV4guPP1krsX7Ky1+TsIu9Kj2Qe X-Received: by 2002:a17:906:e91:: with SMTP id p17mr5070041ejf.399.1614125741362; Tue, 23 Feb 2021 16:15:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614125741; cv=none; d=google.com; s=arc-20160816; b=B07Zc/TD1NpwdA/mfvYoIUFM5Ef/MFtGwOxc7Z+L5cQryIHUoEHxjTKV5AS1GtMeeY dnVCXFz2oYmNoB60WluWmNkQlnR8fXai8UIjsauQPXEizUooOvJyiD9qy/9adXDdCEm+ 3YYgdl6u1JNJikfgOJmw1c2uZ1/7Y9V9gl/zy4s2TNYxBM60O+oOitvUoWYe8sdUBItC Vz0pa9rExb0tpwpE0qAdIS5ZjtkR6uXpjYXi9fkMSEd/43R8wl08NWAxx4fv3bhK3RKf 8rZhpmawLcc/MY2mbT62XMpYjrUJf7C4qfjxZtsiaioYaZDTfBqlNo3LW11jcU7o0p5R xLqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kOG5ouxkHwJB92685qf8wFfHRaVUmiy9Jy0UpVAA4qk=; b=UG9pfEer6aNHB5EVJbaR0ATdMUvQmNJFfR3c2W5BmsIsIm1JlXWGQVxRrFsDZ82+be 35NrDXq3dXDpeH+GbYfJloZl5ZeBTPHTQgoOofq0zLY8gsPACHYt9zWSVLIbUFv76ucQ lrn0yDslDNAWHZNxvPNFcWsAH7rjllH9wWy5MqJQQNOC58fEh3KoY9GM0WI7sOmYKpyh VCFKnltTC4OQnhAEl3LO1z5PD8XxPoifMD8lW1Mn2FxRIuamrFb26rDDpcgisNbfpXBs 1PcR/6/DAauiHlt2QajMAkdm0SnF1Hau29Eld/6sQJd8v03H4aneEsA1ZLmV6Ut3tRxi LBvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eF0kOdpS; 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 gg25si85672ejb.693.2021.02.23.16.14.08; Tue, 23 Feb 2021 16:15:41 -0800 (PST) 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=eF0kOdpS; 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 S233919AbhBWVDM (ORCPT + 99 others); Tue, 23 Feb 2021 16:03:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39854 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233632AbhBWVBY (ORCPT ); Tue, 23 Feb 2021 16:01:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614113998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kOG5ouxkHwJB92685qf8wFfHRaVUmiy9Jy0UpVAA4qk=; b=eF0kOdpScii++pOTxUKRmwb+5HeD+/VK8Y3FZU7Ej8kpfcjx+HZGgS5lh6LQVBByTDMzLt mOOSkbf+iZalDYBFkapT0iW6ZCdZfa7B41e06z2VAvv3DukQZcUhS8jaxUwF36MgEbjsLx +K4hMjKHkHjRd+sRTkHh8UvKee6zEZg= 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-336-b6LrOC1WOhKPQ2PX5vTztw-1; Tue, 23 Feb 2021 15:59:20 -0500 X-MC-Unique: b6LrOC1WOhKPQ2PX5vTztw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 88AFE107ACFC; Tue, 23 Feb 2021 20:59:17 +0000 (UTC) Received: from laptop.redhat.com (ovpn-114-34.ams2.redhat.com [10.36.114.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8D605D9D0; Tue, 23 Feb 2021 20:59:01 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, will@kernel.org, maz@kernel.org, robin.murphy@arm.com, joro@8bytes.org, alex.williamson@redhat.com, tn@semihalf.com, zhukeqian1@huawei.com Cc: jacob.jun.pan@linux.intel.com, yi.l.liu@intel.com, wangxingang5@huawei.com, jiangkunkun@huawei.com, jean-philippe@linaro.org, zhangfei.gao@linaro.org, zhangfei.gao@gmail.com, vivek.gautam@arm.com, shameerali.kolothum.thodi@huawei.com, yuzenghui@huawei.com, nicoleotsuka@gmail.com, lushenming@huawei.com, vsethi@nvidia.com Subject: [PATCH v14 13/13] iommu/smmuv3: Accept configs with more than one context descriptor Date: Tue, 23 Feb 2021 21:56:34 +0100 Message-Id: <20210223205634.604221-14-eric.auger@redhat.com> In-Reply-To: <20210223205634.604221-1-eric.auger@redhat.com> References: <20210223205634.604221-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for vSVA, let's accept userspace provided configs with more than one CD. We check the max CD against the host iommu capability and also the format (linear versus 2 level). Signed-off-by: Eric Auger Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 332d31c0680f..ab74a0289893 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3038,14 +3038,17 @@ static int arm_smmu_attach_pasid_table(struct iommu_domain *domain, if (smmu_domain->s1_cfg.set) goto out; - /* - * we currently support a single CD so s1fmt and s1dss - * fields are also ignored - */ - if (cfg->pasid_bits) + list_for_each_entry(master, &smmu_domain->devices, domain_head) { + if (cfg->pasid_bits > master->ssid_bits) + goto out; + } + if (cfg->vendor_data.smmuv3.s1fmt == STRTAB_STE_0_S1FMT_64K_L2 && + !(smmu->features & ARM_SMMU_FEAT_2_LVL_CDTAB)) goto out; smmu_domain->s1_cfg.cdcfg.cdtab_dma = cfg->base_ptr; + smmu_domain->s1_cfg.s1cdmax = cfg->pasid_bits; + smmu_domain->s1_cfg.s1fmt = cfg->vendor_data.smmuv3.s1fmt; smmu_domain->s1_cfg.set = true; smmu_domain->abort = false; break; -- 2.26.2