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 EE044C388F7 for ; Tue, 3 Nov 2020 20:47:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A820420719 for ; Tue, 3 Nov 2020 20:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436452; bh=t+tE0BjnMmEBd4y6LbwGhZqF/6zBkpZsFq0hol1C1hY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jhtSAPP9SHgTyuEGEbKvgY+te7RwFRZ25QMy/aRLSikUhGg0hRSgLIiEYLEQalWJ0 QqLsZcQlhxiW4O05LduJfmZPFD85sio4Je99NuvHzDCd9nDazeeK5o0JAgYWO9JdQU cFMWCJeCjjanE1vGZWi32kG1ECiDj/wbxcIrQYHI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730675AbgKCUrb (ORCPT ); Tue, 3 Nov 2020 15:47:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:37838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731341AbgKCUr2 (ORCPT ); Tue, 3 Nov 2020 15:47:28 -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 C2D8B22409; Tue, 3 Nov 2020 20:47:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436447; bh=t+tE0BjnMmEBd4y6LbwGhZqF/6zBkpZsFq0hol1C1hY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JNjXRl/vExgfvdrl4Jy4MnJygwGldl3xPuXw88fLOSk2IoCu5H5VkQjOcStoGm27R 8u6vmGQoVX3e0n1lP19KYAX/Rt4TVnh5rc5bRT1MX2k0/Typ5EiHFvRipgpMw7+AhD eTAW+apQY2LEFUAh/xw98+I6io+I/Cdc9MoJrFK4= 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.9 253/391] drm/i915: Force VTd workarounds when running as a guest OS Date: Tue, 3 Nov 2020 21:35:04 +0100 Message-Id: <20201103203404.092214029@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@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 @@ -1716,7 +1718,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)