Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp243310pxb; Wed, 18 Nov 2020 03:27:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRJH2aWLahOXsFtqEDiv+MPT9AHU92FERp9KnK078embxucN/vPTmlhLQbvy/Yw4HZvO2w X-Received: by 2002:a17:906:13d4:: with SMTP id g20mr23074132ejc.206.1605698836444; Wed, 18 Nov 2020 03:27:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605698836; cv=none; d=google.com; s=arc-20160816; b=EiFaRAnsOg9EtjoWup8rsbOM1MhlaELGSMiYYARaqpSEoKrSrSGgwFKHfAeZ9igcqo ZiYu11/EgnhQDtuvWYDMOw2Kr/7GL3V8AsENJSko5XTTKU6JPQQd3k5hPtxVUo9d+ThU i8HMywUxh8GQ74fXdq1LVWEXwlNdSLawTQr6SbM1dk95uTtbH42q3Lc84sWmxioOJiS8 /0Qlq7+rP69ouV01VDqdVrkyZrV7xx8/QdHy26H0DsG5pM6BjiWXpmljKp8YtsmZZnh0 n3gVhiE+VdzdPH1JYjzev6t83bvu0qt/O4sua2nl3nW6Sm06Y0A5B7F+1+AFO07RSwRg 6FFQ== 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=PMV1y86LEZa3kYwZ8iP5D6nppr21q5lgJ0OynKLwxhg=; b=zuWMGk7+0mOAQPnQPTpKu9q3vd1e9VfzxU8fWTorhHt/BflDcxzBidc8rEq8BK/kKs DRSWxrUcOfyCz2ttnuUU+Zzbp8BM6EIqkMiMLo5VnzD0dGXdqdNq5G6umWk4ATEOlxOy Ihb0b8fO+kUlDk8XCuIZxj+8UCMODqu6w/moT/COcq4zkltDF71Bs2G3zp//6k80Ck7L +vE0z2ZFcZmx2zRQKkM+mdEeQ6+7nUA8ZPxTbvU1rt1VSGGL1//fQ/0fgzY14nZfAFFe jeNg3/xQyAjN+svlJtpkrxbL9hblZt1voOVCpT+tHC/o6U9inEeK9/D2cfHA0c2Ksg8u EtqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Xq+E3vVr; 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 s3si8684771ejd.148.2020.11.18.03.26.54; Wed, 18 Nov 2020 03:27:16 -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=Xq+E3vVr; 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 S1727987AbgKRLYC (ORCPT + 99 others); Wed, 18 Nov 2020 06:24:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:43441 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727925AbgKRLYB (ORCPT ); Wed, 18 Nov 2020 06:24:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605698640; 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=PMV1y86LEZa3kYwZ8iP5D6nppr21q5lgJ0OynKLwxhg=; b=Xq+E3vVrSatiwtD/9KCOTSha80m5wH/x4wY4cMK/BE3tEzvyMs9EOzLwtjtD3i+eN9JUoO 03+WshSDVLpKKV3wie9A+qHz8IzNolA3ozrZL8lR+xaZMy4iB5P5sigVlyI1WGd+8g6f7r cRdCi86QfnnyXN15+Cwq8Vtr4STvw/Y= 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-364-ARgRYGBNPxCWe6YeN5iJ6Q-1; Wed, 18 Nov 2020 06:23:56 -0500 X-MC-Unique: ARgRYGBNPxCWe6YeN5iJ6Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2BE05873115; Wed, 18 Nov 2020 11:23:54 +0000 (UTC) Received: from laptop.redhat.com (ovpn-115-104.ams2.redhat.com [10.36.115.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17EEE51512; Wed, 18 Nov 2020 11:23:40 +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, joro@8bytes.org, maz@kernel.org, robin.murphy@arm.com, alex.williamson@redhat.com Cc: jean-philippe@linaro.org, zhangfei.gao@linaro.org, zhangfei.gao@gmail.com, vivek.gautam@arm.com, shameerali.kolothum.thodi@huawei.com, jacob.jun.pan@linux.intel.com, yi.l.liu@intel.com, tn@semihalf.com, nicoleotsuka@gmail.com, yuzenghui@huawei.com Subject: [PATCH v13 14/15] iommu/smmuv3: Accept configs with more than one context descriptor Date: Wed, 18 Nov 2020 12:21:50 +0100 Message-Id: <20201118112151.25412-15-eric.auger@redhat.com> In-Reply-To: <20201118112151.25412-1-eric.auger@redhat.com> References: <20201118112151.25412-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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 977c22d08612..ed64699a4a0d 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2905,14 +2905,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.21.3