Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4489314ivc; Tue, 3 Nov 2020 13:23:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8uEeEdlBnEVTZhBCCGQ6o8eD8mkVjAfqRCYuwAi2KlzzkQnS/PHg0cL7yG1fqig6AHHtN X-Received: by 2002:a05:6402:17ac:: with SMTP id j12mr23330737edy.31.1604438633687; Tue, 03 Nov 2020 13:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604438633; cv=none; d=google.com; s=arc-20160816; b=vNYQNSAxuwUOH5M/bxJ1Rgb68tOdBd91BqF3bnkHb9kuqhb8ZMiXeLnbSCPvcVVvRr UAXrhUkv05J5Lp+j7Tkhkz8KYHgrfhIaiByHrdTjXPZzkZuB7/chMg/SYDYnVqPdFQbV MOl00Fcci5HEL2VzyYwljFSplquPMHpPGzHH/j/rttn4aAXuq4Cg/BJunJpsi3ofwzYH R6NKFiiI9r0sNgI0k9jHX4yC90s5lveH9U5E/IVrIMpRWiK83fqlbA7tgkGKhwd2wh1y w0jgjmq554wYUp4Gsb6BEjViMpyRD2YVLEFObJf5Los3MNEWFHXSjG9xOSja/PUi/Bi2 AU0w== 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=ZuxJfqsAMS8lDdLxz3qtOOa1jYFAu4By//GXzvZG6sw=; b=Nd+IQr4upkCtB1FOKTFoh0970pTnNoRPKUAHyMHQIAz86h3g3R8nmDJQIk10vbvhTC ga5kRwa7VvyS19nGoG6MSBacoxYoxt5DFnpxvDk7C8yM2+t+mouJjUdnmaSixBB3OqFR bG7AiwZSUyu9zjvqWwC/PYC0vURIqarOqNgJP6i+M0LJKCuppnuJXNUthi6H3+miqxN8 W1RVirXJmuwWDVrpNNwwhEsBWNk079uUEFxRo2xbJsd+CdCk6MwxLRzmbsN9GhMlHJiy aBpAX3sHAhHSJ3lhp35KQgmnQHOexEBraWf07l8prJnFVpnnY+BSZXKzAWqw41uUP+/h XjkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A4lC+jBY; 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 i24si46913ejc.643.2020.11.03.13.23.30; Tue, 03 Nov 2020 13:23:53 -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=A4lC+jBY; 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 S2388175AbgKCVGe (ORCPT + 99 others); Tue, 3 Nov 2020 16:06:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:45476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388173AbgKCVGc (ORCPT ); Tue, 3 Nov 2020 16:06:32 -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 630A120658; Tue, 3 Nov 2020 21:06:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437591; bh=sN+tqHSXQ89aDEyAQLzAjoxXd0VmwnWxlC71/q/pbJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A4lC+jBYNPd/1QXghsZPOcTfgOAZRXbelQXo5UDgWxGob61mJwPPzABqhXd1f0+xl 0lgqKuDNJ4fHjMgfFFBEST+1ffrfgpOj9g6gOrNmUy7myloeTMcKVQQJs+4JZ+2ETO 2I3uGrPsMsGDVSVNTf85gKwg98XWfOJr5e9nH5jU= 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 4.19 143/191] drm/i915: Force VTd workarounds when running as a guest OS Date: Tue, 3 Nov 2020 21:37:15 +0100 Message-Id: <20201103203246.208082091@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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 @@ -2683,7 +2685,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)