Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4304643pxu; Tue, 1 Dec 2020 01:23:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNzA9rjYJxt3NQV6rQ6PoXKcoB8BdHGD646jLPljh3Xf3+RIftbVebIvXIEQCVO++xzRWf X-Received: by 2002:a17:906:b003:: with SMTP id v3mr2078476ejy.290.1606814615811; Tue, 01 Dec 2020 01:23:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606814615; cv=none; d=google.com; s=arc-20160816; b=dOuxMzYk5yg0uedAJG2lxM9wtje8HLLlJ27sLav4SydMyRhz7dECnFym0ZbPSE/heP 0htlVuBRsNHauvJ8OIcMVQfMhTpkBJyTSm9a4lECThLP/NsQpZQPTzKB36qh7x3IgxpP RJOh2pSWiuzu+okPlQ4fI2wdGA2FxZSo5qCwlG6skhLSi6dGKXypX7mJ7AGBBGS3CrkI n4D+eEmHqOIQuho+t7tNzb1lWWbGOQs36NT4Cu9p4v2lN/CZhESPF7Fbg01OJvue3eWT fCMyEYnCVuBcKfkRa/TLF0PCaD6S/EhwocTDf0GuOqqz9971K5IfQCw0NzpT9XUxa/DC wTRQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/8YJZ1QCl1y/u2vZ99070mYk0sVZM8bIIThHPV1OxD4=; b=kOMN0Kvvd1kbbu4IZdH0SIaGaJj4erI37JCno3P8f2Ryj3FY4+gZmDwVzp3j+8CwmX OoP50uKO2mYdIYE8g9fiRtTaSo1ecv9r2D0QPJhGTCfZndvl/YQvCXTXeD6zZ5vtu+cP I1EU/TOwuAMn/fdJiqwPrDs+U3sLZRnnPtJZXXzu8kThmo3olNVST2G+LvMUHdZapEZM RcnvDUzE2pPbd7G70bBxlVPqGx/Xug//bplTEEhAV7mtLO+77DUtUQkp54miuZJLXPE3 sWcI+CnjUgMKwKNlH2EvxyV/hYdTi2d5VFNJxJYdu+qp8eacHmCmEE5IiVABzCUQPzh7 3H0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="NrUsUf/w"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p62si757727edd.213.2020.12.01.01.23.12; Tue, 01 Dec 2020 01:23:35 -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=@linuxfoundation.org header.s=korg header.b="NrUsUf/w"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389484AbgLAJJb (ORCPT + 99 others); Tue, 1 Dec 2020 04:09:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:45376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389224AbgLAJI0 (ORCPT ); Tue, 1 Dec 2020 04:08:26 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E40B920656; Tue, 1 Dec 2020 09:08:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813690; bh=U4DM5UEjmLYd3d1w/doEcRmwgiqhXB+Fp4BzzWtfBfw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NrUsUf/w7Sd9rIsF0yBSAhOBiUICNxnrZ4vvFwzBWuUGbJ6iO19AvzkZx20yspNjr D0ajQ9550xonoR/CYsks3vBaTgW1/TfYyU5drrntfUKnMztzhpA4a0Ac22WetQl9A5 kcJ4wjfAwyRYY3VBworJQ17P0RV2Bnw6kECVnr+Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Woodhouse , Liu Yi L , Lu Baolu , Will Deacon Subject: [PATCH 5.9 026/152] iommu/vt-d: Dont read VCCAP register unless it exists Date: Tue, 1 Dec 2020 09:52:21 +0100 Message-Id: <20201201084715.313869297@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084711.707195422@linuxfoundation.org> References: <20201201084711.707195422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Woodhouse commit d76b42e92780c3587c1a998a3a943b501c137553 upstream. My virtual IOMMU implementation is whining that the guest is reading a register that doesn't exist. Only read the VCCAP_REG if the corresponding capability is set in ECAP_REG to indicate that it actually exists. Fixes: 3375303e8287 ("iommu/vt-d: Add custom allocator for IOASID") Signed-off-by: David Woodhouse Reviewed-by: Liu Yi L Cc: stable@vger.kernel.org # v5.7+ Acked-by: Lu Baolu Link: https://lore.kernel.org/r/de32b150ffaa752e0cff8571b17dfb1213fbe71c.camel@infradead.org Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- drivers/iommu/intel/dmar.c | 3 ++- drivers/iommu/intel/iommu.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -964,7 +964,8 @@ static int map_iommu(struct intel_iommu warn_invalid_dmar(phys_addr, " returns all ones"); goto unmap; } - iommu->vccap = dmar_readq(iommu->reg + DMAR_VCCAP_REG); + if (ecap_vcs(iommu->ecap)) + iommu->vccap = dmar_readq(iommu->reg + DMAR_VCCAP_REG); /* the registers might be more than one page */ map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap), --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -1798,7 +1798,7 @@ static void free_dmar_iommu(struct intel if (ecap_prs(iommu->ecap)) intel_svm_finish_prq(iommu); } - if (ecap_vcs(iommu->ecap) && vccap_pasid(iommu->vccap)) + if (vccap_pasid(iommu->vccap)) ioasid_unregister_allocator(&iommu->pasid_allocator); #endif @@ -3177,7 +3177,7 @@ static void register_pasid_allocator(str * is active. All vIOMMU allocators will eventually be calling the same * host allocator. */ - if (!ecap_vcs(iommu->ecap) || !vccap_pasid(iommu->vccap)) + if (!vccap_pasid(iommu->vccap)) return; pr_info("Register custom PASID allocator\n");