From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED46EC2D0A3 for ; Tue, 3 Nov 2020 21:11:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8F37206B5 for ; Tue, 3 Nov 2020 21:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437913; bh=tU6kxRf9+dN2AXSlCXXAwS2f6fw8WgQYfe3ryKtNfxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sEkziAb33fU/s6H+ugcmuQeJRnBd0Z4ch3OtA9PtyXvhybxW9lezAnLJxL+sJwOp+ EWmSW/4t12mWu2a5gzXqKpn+arbQh3PsJu1o76/c7knrrsyjPTb8m6qtL/QwbaybjT T7STyXL6YAJyINawxnKeq4gx72451ILCl9GwR5JM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388911AbgKCVLt (ORCPT ); Tue, 3 Nov 2020 16:11:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:53760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388921AbgKCVLs (ORCPT ); Tue, 3 Nov 2020 16:11:48 -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 7F001206B5; Tue, 3 Nov 2020 21:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437908; bh=tU6kxRf9+dN2AXSlCXXAwS2f6fw8WgQYfe3ryKtNfxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dn/h6lHC5AtQxruXsUQWcWuGAv1huzRjsT8P6uPgZUK0vCrv4Y0ygjD9hST3qo2Rx 2VbjnDFuXrrmm6LgFx97/Rn7KUOex2DvpJs+97C4MEKsomp2AP0zV8ShvTLqaSJVQ/ XdtOmatY+lx+LNl5zcFZcBabD7DtkASrHjJfbCJo= 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.14 083/125] drm/i915: Force VTd workarounds when running as a guest OS Date: Tue, 3 Nov 2020 21:37:40 +0100 Message-Id: <20201103203208.930684220@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203156.372184213@linuxfoundation.org> References: <20201103203156.372184213@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: stable@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 @@ -3141,7 +3143,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)