Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3080135ybt; Mon, 29 Jun 2020 14:49:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqfzxdcnJV9A9h/IGpNFJtNGqyu9Hv+Br1NatGeRt6S1vBBdJjON+q8Oxga1Dd+GIMy/vb X-Received: by 2002:a05:6402:1c0f:: with SMTP id ck15mr18951897edb.155.1593467360283; Mon, 29 Jun 2020 14:49:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593467360; cv=none; d=google.com; s=arc-20160816; b=wE1C0V3T/16eWnrJkHHBG4igyrOxxqak1j7srtUxoFDf/q+Eqhls6AvGfaiOUiAMda CBcaMXv++LijSR9rzoUCP3Qj7bZXR8AoPLm0iQRDMTH6eMsQtxhppbG6InRlHV2bycpq XYq08FtRn1ZYdDvi8x/aSvGE06nCPiaufbfjNc7+RLJD2vJCMkN1aveZECX3Px3XnqkH j9uJmufE+OSQeP2KuMEaaVJTdTMgppWOazpn8vHyRhjQkyTxdoeK8FP/XLdJxuHUOjtG HsVlpjbhdy1sCSHdEW/WWOWOqtOCLnqNbJOgSnEloebVOKjnuoxeGcABC5wFRB8kJ8tR b/1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eNjEBLizyIbZk1P32It4tCzgNKRaDtIQvVUxWjTh/Ko=; b=jXgi2nMhlGAqOpYD9zO4JaUTHyzzEhtVHOoSmxI64n+Cl5p4Qa8TybpHJ1Ii2a08tj 0dv4kkrIH4RlbLaM6PlAA4uixMEkVYFgPrOEm+SZUtdUoGG2bRBHCyayfuw4wNIYPwD7 5BdwO5KSW3eqx9vGyk4CeiUc7nzpwOI9JQfwBVA9RyShLfcH+N/hc9kTsHVWXuNZm1hg W4LhCIcr6T9HpHYt5I4+HoyBRdYTk5c8PUsSo/O8UmSPubL+WMB1G7sTEjVqvybs1SF8 yO5y8e16T1uxq1OZ595tW6BxuH85KdJMReKWgm3LQX6CqVsOKc628oKRMpQ33Kacdwif /wnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="0JL/hbwh"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si467321edr.244.2020.06.29.14.48.57; Mon, 29 Jun 2020 14:49:20 -0700 (PDT) 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=@kernel.org header.s=default header.b="0JL/hbwh"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391388AbgF2Vro (ORCPT + 99 others); Mon, 29 Jun 2020 17:47:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:56790 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726731AbgF2Sfn (ORCPT ); Mon, 29 Jun 2020 14:35:43 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 460C4246F2; Mon, 29 Jun 2020 15:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444037; bh=xad0Vf4y6tkQ6kiNJkH+zGRdUliz2elF3LQs9dqu5sM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0JL/hbwhrfaZLzNjeTDhr/+tr9u0enGwoiGfjUCXWfewKXrUp3hgqMUWDl2FsdC+G nATXQReLlMNgNU46vNYiPHvQU69UbPo+v3GSdjIq+tC+P5H++UhWfBjhqxGOWYY+iT jFhVBhUHLjTnlMjRlbx30Up/st07M4A2FzkZabfE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lu Baolu , Ashok Raj , Kevin Tian , Jacob Pan , Joerg Roedel , Sasha Levin Subject: [PATCH 5.7 144/265] iommu/vt-d: Update scalable mode paging structure coherency Date: Mon, 29 Jun 2020 11:16:17 -0400 Message-Id: <20200629151818.2493727-145-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629151818.2493727-1-sashal@kernel.org> References: <20200629151818.2493727-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.7.7-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.7.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.7.7-rc1 X-KernelTest-Deadline: 2020-07-01T15:14+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lu Baolu [ Upstream commit 04c00956ee3cd138fd38560a91452a804a8c5550 ] The Scalable-mode Page-walk Coherency (SMPWC) field in the VT-d extended capability register indicates the hardware coherency behavior on paging structures accessed through the pasid table entry. This is ignored in current code and using ECAP.C instead which is only valid in legacy mode. Fix this so that paging structure updates could be manually flushed from the cache line if hardware page walking is not snooped. Fixes: 765b6a98c1de3 ("iommu/vt-d: Enumerate the scalable mode capability") Signed-off-by: Lu Baolu Cc: Ashok Raj Cc: Kevin Tian Cc: Jacob Pan Link: https://lore.kernel.org/r/20200622231345.29722-6-baolu.lu@linux.intel.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/intel-iommu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index a0b9ea0805210..34b2ed91cf4d9 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -634,6 +634,12 @@ struct intel_iommu *domain_get_iommu(struct dmar_domain *domain) return g_iommus[iommu_id]; } +static inline bool iommu_paging_structure_coherency(struct intel_iommu *iommu) +{ + return sm_supported(iommu) ? + ecap_smpwc(iommu->ecap) : ecap_coherent(iommu->ecap); +} + static void domain_update_iommu_coherency(struct dmar_domain *domain) { struct dmar_drhd_unit *drhd; @@ -645,7 +651,7 @@ static void domain_update_iommu_coherency(struct dmar_domain *domain) for_each_domain_iommu(i, domain) { found = true; - if (!ecap_coherent(g_iommus[i]->ecap)) { + if (!iommu_paging_structure_coherency(g_iommus[i])) { domain->iommu_coherency = 0; break; } @@ -656,7 +662,7 @@ static void domain_update_iommu_coherency(struct dmar_domain *domain) /* No hardware attached; use lowest common denominator */ rcu_read_lock(); for_each_active_iommu(iommu, drhd) { - if (!ecap_coherent(iommu->ecap)) { + if (!iommu_paging_structure_coherency(iommu)) { domain->iommu_coherency = 0; break; } @@ -2177,7 +2183,8 @@ static int domain_context_mapping_one(struct dmar_domain *domain, context_set_fault_enable(context); context_set_present(context); - domain_flush_cache(domain, context, sizeof(*context)); + if (!ecap_coherent(iommu->ecap)) + clflush_cache_range(context, sizeof(*context)); /* * It's a non-present to present mapping. If hardware doesn't cache -- 2.25.1