From patchwork Thu Mar 30 10:04:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Xiong Y" X-Patchwork-Id: 9653463 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 22B4C6034C for ; Thu, 30 Mar 2017 09:56:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C28F28585 for ; Thu, 30 Mar 2017 09:56:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10E2D2858A; Thu, 30 Mar 2017 09:56:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9097528585 for ; Thu, 30 Mar 2017 09:56:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D6C726E7F7; Thu, 30 Mar 2017 09:56:47 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id C2B9A6E2BC; Thu, 30 Mar 2017 09:56:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490867806; x=1522403806; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=grE5CW3rtiLGalJlpl17ls/CQL9dEMZwyhuZmtH2Q/s=; b=qTaKCG95NzYM08v3Xyu9ZsPS1+w1w5FLAQIW3DECAIVBIPLTZo157Ptp zVurVRV8zWnNKReH95KtLHncZgvPMg==; Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Mar 2017 02:56:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,246,1486454400"; d="scan'208";a="949739565" Received: from panda-dev.bj.intel.com ([10.238.135.63]) by orsmga003.jf.intel.com with ESMTP; 30 Mar 2017 02:56:43 -0700 From: Xiong Zhang To: intel-gfx@lists.freedesktop.org Date: Thu, 30 Mar 2017 18:04:24 +0800 Message-Id: <1490868264-29524-1-git-send-email-xiong.y.zhang@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490340204-21319-1-git-send-email-xiong.y.zhang@intel.com> References: <1490340204-21319-1-git-send-email-xiong.y.zhang@intel.com> Cc: intel-gvt-dev@lists.freedesktop.org, stable@vger.kernel.org Subject: [Intel-gfx] [PATCH V3] drm/i915: Enhanced disable access to stolen memory as a guest X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Stolen memroy is in RMRR and have identity mapping in iommu, so gt could access stolen memory in host OS. While RMRR isn't supported in kvm, both EPT and guest iommu domain lack of maaping for stolen memory, so both vcpu an gt couldn't access stolen memroy in guest. commit "04a68a3 drm/i915/gvt: Disable access to stolen memory as a guest" isn't enough in IGD passthrough environment where vgt code don't run. This patch detects i915 running as a guest through the existence of emulated ISA bridge. v2:GVT-g may run in non qemu (Zhenyu) References: c875d2c iommu/vt-d: Exclude devices using RMRRs from IOMMU API domains Link: https://access.redhat.com/sites/default/files/attachments/rmrr-wp1.pdf Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99028 Signed-off-by: Xiong Zhang Reviewed-by: Zhenyu Wang Cc: stable@vger.kernel.org --- drivers/gpu/drm/i915/i915_drv.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_stolen.c | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 03d9e45..8b807a9 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -223,6 +223,7 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv) PCI_SUBVENDOR_ID_REDHAT_QUMRANET && pch->subsystem_device == PCI_SUBDEVICE_ID_QEMU)) { + dev_priv->run_on_qemu = true; dev_priv->pch_type = intel_virt_detect_pch(dev_priv); } else diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a5947a4..ad95c87 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2145,6 +2145,7 @@ struct drm_i915_private { struct intel_uncore uncore; struct i915_virtual_gpu vgpu; + bool run_on_qemu; struct intel_gvt *gvt; diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index f3abdc2..6a011b0 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c @@ -409,8 +409,8 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv) mutex_init(&dev_priv->mm.stolen_lock); - if (intel_vgpu_active(dev_priv)) { - DRM_INFO("iGVT-g active, disabling use of stolen memory\n"); + if (dev_priv->run_on_qemu || intel_vgpu_active(dev_priv)) { + DRM_INFO("Running in guest, disabling use of stolen memory\n"); return 0; }