Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2990375pxb; Mon, 16 Nov 2020 02:50:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyc4+vnyW4ZGR1fCQSn8bB6HUmpMFOuV0hgzHdvqKqRFIZMPT8yZSrHJjiEJPYPOA4PAsAp X-Received: by 2002:aa7:d2d9:: with SMTP id k25mr14477121edr.310.1605523841878; Mon, 16 Nov 2020 02:50:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605523841; cv=none; d=google.com; s=arc-20160816; b=YDSAb6aC9stm6Ssmy9GvJHu6rMzdiHGjNpPP6XQHCudHVQhaiUFLAkswUDYG9l/IgR KyG8i/3I0rpIp1XdPhwfD1oxkQZmkQ4jSUbgJkDKroecOAaQM5OHAQmwMhfe8EPY6QQC njY0SDOpsZiO973KoZS4nDpnOQKPyQpH0Kr0KcrRRvhTVxp+qSotVN4I/BQyUKaXFeWl PI+OivqxPxmi7hvXSBTACErRrbVcHXmsa3E7fK19EjhzSEzR34fsr/esmqNnjVvBudpI mDT+Fr8Jll9ORNwZtWjUBOTJb0qbCS6+VOmMtei+2tjSCsEfpsSPurV/LK4VYmxWchuB 5qyg== 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=QE1szO8OV1xDFKb+wSnyAiSU7kUqkqlMSoqIskMXHyg=; b=JyMLB2y1GElB2vR8xeedp2ckTO8/VwhrrvrVEVZvkczn14J/8r3qu5du5dRlxymBPZ IKgWVZffyf5su6YAIcTrc07VS/Bjv6o0Tk1yer9xE17N6bM1PCYMgk/nUr/Qgtej7FeF s5J/Nr5nTdUbRT6oI3bI6PHaiDSf4TspxPZtV80BCxIeWQ9OJh2K706xNvfiD5jEN2nG nE2v3nEePhr4u46cpOC3DNsVxHdBbbAFdK03v+iImkoJyi+Wh0SBJdBH2HRjAVE0cWxx NhcqhjbiTzobanOd3jB3TjANFAT3aIpPom2fEv8UmaG55vVVYuCvTgacvw5gAukI5bCH 8m8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qnzw6Uvl; 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 qu7si1507452ejb.217.2020.11.16.02.50.18; Mon, 16 Nov 2020 02:50: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=Qnzw6Uvl; 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 S1729505AbgKPKpR (ORCPT + 99 others); Mon, 16 Nov 2020 05:45:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:28554 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729478AbgKPKpQ (ORCPT ); Mon, 16 Nov 2020 05:45:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605523515; 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=QE1szO8OV1xDFKb+wSnyAiSU7kUqkqlMSoqIskMXHyg=; b=Qnzw6Uvla6Dz3r8NG4sy2JF+Nu0kZOG/WBso5KKBViXiY1Vt68VbNVeK0oWORcj5kHYJV/ cw9DiEZCguIdZmI2GqW33GnCfCtP5lc89FDphyO72yNHiHY4tpNf7HvhJAzZHwYpmr56gR bR3htK/0Hcob8os93eJhvQ0aeViHnTw= 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-34-BB4NcFKMM7Kq8NwwcPiiPQ-1; Mon, 16 Nov 2020 05:45:14 -0500 X-MC-Unique: BB4NcFKMM7Kq8NwwcPiiPQ-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 C06EC18BA281; Mon, 16 Nov 2020 10:45:11 +0000 (UTC) Received: from laptop.redhat.com (ovpn-113-230.ams2.redhat.com [10.36.113.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0F955C5AF; Mon, 16 Nov 2020 10:44:59 +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 Cc: jean-philippe@linaro.org, zhangfei.gao@linaro.org, zhangfei.gao@gmail.com, vivek.gautam@arm.com, shameerali.kolothum.thodi@huawei.com, alex.williamson@redhat.com, jacob.jun.pan@linux.intel.com, yi.l.liu@intel.com, tn@semihalf.com, nicoleotsuka@gmail.com Subject: [PATCH v12 15/15] iommu/smmuv3: Add PASID cache invalidation per PASID Date: Mon, 16 Nov 2020 11:43:16 +0100 Message-Id: <20201116104316.31816-16-eric.auger@redhat.com> In-Reply-To: <20201116104316.31816-1-eric.auger@redhat.com> References: <20201116104316.31816-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 --- 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 6549c3ee6af6..eb0e09936803 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3002,9 +3002,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