From patchwork Tue Nov 3 20:36:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 316912 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 987ADC388F7 for ; Tue, 3 Nov 2020 21:30:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52211223C7 for ; Tue, 3 Nov 2020 21:30:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604439020; bh=pPSOsyEIt9vou/H7DplKGWdQoh0OKGg+V9QEwjSncp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lLNV8uSg9XoXECJrdKI6X2pOf0LfbVGLT2xXjlPy15KB7KdWgLKh1QRIRtJhZeZbD UTR1fOfOti3be21909lfvbjbqto//n9NxdH5Z1oM9parRIU5FZXMcTl0oincxBzM70 tx8b93XbBBprWmEGdCMfd5WuuKPC5+mIRzxHv2Is= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733097AbgKCVaQ (ORCPT ); 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 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 @@ -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)