Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp824215pxb; Tue, 3 Nov 2020 13:35:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzs/ujllEmraxU+KoYNqswp9vgBrpWtRHt2xUyn3mB13un7evYbwjk1GUZjWGTFxqap9CT X-Received: by 2002:a50:da8d:: with SMTP id q13mr24363281edj.370.1604439310794; Tue, 03 Nov 2020 13:35:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439310; cv=none; d=google.com; s=arc-20160816; b=QU2CbF0OUDnqHdblAtoBphYDgHaIP0BTUGkhl8nyR8NI8UyNm8HA5V8o8dUT/XbhZ0 lkWKljvTjjCrD5cKrXSqW570lOor2nIEogTjvwLoSx6Ak9c6j6MKCDrKJ526FF6jQq3O Lym9alguYzzVLS4AeaDUAsv2XE1V9Tw1jHR2xk+aBdRUZnCKAD8kynbANbngw0lMk4po mn4tHfPJBDp69G+T6fwvxHZHEzna2o4T9hm4ybq90w6wZ8wCh4yZZx9zBkkBvSrZ3laR ZHQc79wseUlo6okBTB7yahXoCYyfE+ZrxmC91DcEc5xfsS98LgYdIpffYin0YDoRuRaz E+5w== 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=+mtN3jX4dEkPq/5XFtYq3lejkIQujt8KKAa/kJ3ZIdw=; b=Ez+UlpUuD8QmJ+fHzyCgGtWD9/HMwtifjnYSG0QEuopGWscJ3MjbzdxoBiIqZGVAVM xBnURcDzm2lyivKOuptGfZuZC3uL+yLHc5G6YFVlOwBj7rctltvXqDKOvT5vKXnNxbnd +ij2Pvkbp9gqTLKX622C2oIsshilrH4IvZ+NoviikrmsQ0OsPiwgto9rKxLqjQ7fRNYH /SZedHqJh6vRDRxS0znMaCA5JkDGbcZRMKC4CsxAkXmW+HxA35V01Lh0y2983ePscIkn 5xX4mEL/B1VStL+BoQ0mCCgh5uWmR63jfVXfF+lU80UebvhVUqdblBgmunfKwDzwwyvw +UPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b5LlFbS+; 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=fail (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 e2si14143161edc.604.2020.11.03.13.34.47; Tue, 03 Nov 2020 13:35:10 -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=@kernel.org header.s=default header.b=b5LlFbS+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387505AbgKCVaQ (ORCPT + 99 others); Tue, 3 Nov 2020 16:30:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:60906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732945AbgKCU6T (ORCPT ); Tue, 3 Nov 2020 15:58:19 -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 3986C22226; Tue, 3 Nov 2020 20:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437097; bh=pPSOsyEIt9vou/H7DplKGWdQoh0OKGg+V9QEwjSncp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b5LlFbS+4yUKylKq5NxrLANRQKbSNLKKXf1QOI9H3x1MQwTYpktl0HVOy00rkQAmD hpJ3lIm13ECkC348zz4Ho5fyAGpXuMqZtC2x7XHVxoCjb0HlGrvzceqtk9PTfkgGb6 +fJSZoSCwRFc1DKMuSy2rN8nDF9yAw+6VVkJPXeI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Fritsch , Chris Wilson , Zhenyu Wang , Joonas Lahtinen , Rodrigo Vivi Subject: [PATCH 5.4 144/214] drm/i915: Force VTd workarounds when running as a guest OS Date: Tue, 3 Nov 2020 21:36:32 +0100 Message-Id: <20201103203304.315586015@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@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: Chris Wilson commit 8195400f7ea95399f721ad21f4d663a62c65036f upstream. If i915.ko is being used as a passthrough device, it does not know if the host is using intel_iommu. Mixing the iommu and gfx causes a few issues (such as scanout overfetch) which we need to workaround inside the driver, so if we detect we are running under a hypervisor, also assume the device access is being virtualised. Reported-by: Stefan Fritsch Suggested-by: Stefan Fritsch Signed-off-by: Chris Wilson Cc: Zhenyu Wang Cc: Joonas Lahtinen Cc: Stefan Fritsch Cc: stable@vger.kernel.org Tested-by: Stefan Fritsch Reviewed-by: Zhenyu Wang Link: https://patchwork.freedesktop.org/patch/msgid/20201019101523.4145-1-chris@chris-wilson.co.uk (cherry picked from commit f566fdcd6cc49a9d5b5d782f56e3e7cb243f01b8) Signed-off-by: Rodrigo Vivi Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/i915_drv.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -33,6 +33,8 @@ #include #include +#include + #include #include #include @@ -2197,7 +2199,9 @@ static inline bool intel_vtd_active(void if (intel_iommu_gfx_mapped) return true; #endif - return false; + + /* Running as a guest, we assume the host is enforcing VT'd */ + return !hypervisor_is_type(X86_HYPER_NATIVE); } static inline bool intel_scanout_needs_vtd_wa(struct drm_i915_private *dev_priv)