Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp244175pxb; Wed, 18 Nov 2020 03:28:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfQG22JvhWjDrMrx44bm8j1TCLPe9WGoxBPVIz2Q7MKCwoFv6I0vXdgMvTH4XDjQSO9xhP X-Received: by 2002:a17:906:3187:: with SMTP id 7mr23614986ejy.225.1605698926210; Wed, 18 Nov 2020 03:28:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605698926; cv=none; d=google.com; s=arc-20160816; b=wIfAoekcCTT7ZHEPraBv4qcQ+9luJMHLMrsexr7VMHeZPtdOXx4MLhLyWdUsFrUfSF Nf9RfkhejvqR44Jtdl65qBl+WhvvVlNpau4njwbnN+iiurGuBScAWrzCvb6qLGZpXpLw FuAcznooL2haAGmSmwzudmnbdcB9FS9wkTknPMy9tnomka+J7Hz0hPcgdDo3UE3mfZYr NHFTBW4x31xqy8GB0zsdm3Xm7PubcJ+n9/VIi+Vr6ZO9z7Myd/MZgoxiGp9NSnyacMJM DQC5c7u6oUOiC+n3ggJqdbKOaEU1ffe7Ni9hnPwfhzpUx8ckJ1XNqjAoY1+X6rATWMQZ FQ2Q== 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=spwbm5vXoHiQvJQpWqgCh2lkcvbGNw23B7J3IRmsnBU=; b=odffyahLSGaxEZoejRuxhR0j9oL93iseCslPSHl5W/b3Tn20IoQnyfT5wAbYGtSTLz 32LFS5ushkYfBvemve+8aZWjhCXSGGbjaJeaugRy7BWM7tWLquKs+AXAKw0T3BTrdKin zQOdMikkY8K6ZQ8fZx4BL2kSJ6Ks4CXhiRXPek3ZpLfz239DoqqYuAljReOIjZCdqju6 oMKiUwCnsttqNFR3zZuNUNZF1ZroMFTmCTWQPKyRDEPFIzrTlVwKosjrYmSl13xMntoa m+o1c6njfm9QiWcYjpHPzbjVijWaegyz4UnoIx64TAFp3QqY1lVo3V5S53CV0Uh3axhL jw8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="bBo/Alpu"; 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 k17si8558249edj.560.2020.11.18.03.28.23; Wed, 18 Nov 2020 03:28:46 -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="bBo/Alpu"; 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 S1727998AbgKRLYG (ORCPT + 99 others); Wed, 18 Nov 2020 06:24:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56238 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727925AbgKRLYF (ORCPT ); Wed, 18 Nov 2020 06:24:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605698644; 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=spwbm5vXoHiQvJQpWqgCh2lkcvbGNw23B7J3IRmsnBU=; b=bBo/AlpuwqmJtENzMuYPDy7yuvyp82dh+Gg+1XTqLSRchefXqYBC/IjvzPVo1hWQg3whJn yJtwDw/GQgyo+kVS0JYYd3hI5CKfzI7468vUinjdKafqLwBgjvumoYQHFX0IQiFbvtatYb HK+AWxx1iV1Vssthd7W9Iw3cwnU8WkE= 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-6-s9rX9rIWNOun08cCpJpc1w-1; Wed, 18 Nov 2020 06:24:02 -0500 X-MC-Unique: s9rX9rIWNOun08cCpJpc1w-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 3EF9C1017DC6; Wed, 18 Nov 2020 11:24:00 +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 84FEC5B4BC; Wed, 18 Nov 2020 11:23:55 +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 15/15] iommu/smmuv3: Add PASID cache invalidation per PASID Date: Wed, 18 Nov 2020 12:21:51 +0100 Message-Id: <20201118112151.25412-16-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 order to cascade guest CFGI_CD, let's add PASID cache invalidation per PASID. Signed-off-by: Eric Auger --- v12 -> v13: - Fix !(info->flags & IOMMU_INV_PASID_FLAGS_PASID) check --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 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 ed64699a4a0d..45adfe4da11b 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2999,9 +2999,19 @@ arm_smmu_cache_invalidate(struct iommu_domain *domain, struct device *dev, } else { return -EINVAL; } - } - if (inv_info->cache & IOMMU_CACHE_INV_TYPE_PASID || - inv_info->cache & IOMMU_CACHE_INV_TYPE_DEV_IOTLB) { + } else if (inv_info->cache & IOMMU_CACHE_INV_TYPE_PASID) { + if (inv_info->granularity == IOMMU_INV_GRANU_PASID) { + struct iommu_inv_pasid_info *info = + &inv_info->granu.pasid_info; + + if (!(info->flags & IOMMU_INV_PASID_FLAGS_PASID)) + return -EINVAL; + + arm_smmu_sync_cd(smmu_domain, info->pasid, true); + } else { + return -ENOENT; + } + } else { /* IOMMU_CACHE_INV_TYPE_DEV_IOTLB */ return -ENOENT; } return 0; -- 2.21.3