From patchwork Wed Nov 18 11:21:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 11914871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E000C6379D for ; Wed, 18 Nov 2020 11:24:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC9D32075A for ; Wed, 18 Nov 2020 11:24:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="c3LdtTUZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbgKRLYJ (ORCPT ); Wed, 18 Nov 2020 06:24:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59245 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727925AbgKRLYH (ORCPT ); Wed, 18 Nov 2020 06:24:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605698646; 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=c3LdtTUZtolA9KNWFL4TuB9Cq7nw7+aaNfn5mA8/Wokr2E6ze57K8TvaeS1jUAvokd+nOH 3s27tIyyZRbiEJIHPqkU7GEK8GmZH0OK9pn9j1tYVLZHgZkWOsRyPvbA0ftfHDkjAm+VOT gwVtY2JutPxc1aOXuqRKlI2zOZrKSB4= 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 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: kvm@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;