From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com ([134.134.136.65]:6949 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbdDMFoW (ORCPT ); Thu, 13 Apr 2017 01:44:22 -0400 From: "Zhang, Xiong Y" To: Alex Williamson CC: "joonas.lahtinen@linux.intel.com" , "daniel@ffwll.ch" , "zhenyuw@linux.intel.com" , "jani.nikula@linux.intel.com" , "intel-gfx@lists.freedesktop.org" , "intel-gvt-dev@lists.freedesktop.org" , "stable@vger.kernel.org" , "Zhang, Xiong Y" Subject: RE: [Intel-gfx] [PATCH V5] drm/i915: Disable stolen memory when i915 runs on qemu Date: Thu, 13 Apr 2017 05:44:18 +0000 Message-ID: <8082FF9BCB2B054996454E47167FF4EC1C4BDCC8@SHSMSX104.ccr.corp.intel.com> References: <1491358106-26329-1-git-send-email-xiong.y.zhang@intel.com> <1491999600-4406-1-git-send-email-xiong.y.zhang@intel.com> <20170412120159.03765ea7@t450s.home> In-Reply-To: <20170412120159.03765ea7@t450s.home> Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: > On Wed, 12 Apr 2017 20:20:00 +0800 > Xiong Zhang wrote: > > > Stolen memory isn't a standard pci resource and exists in RMRR which has > > identity mapping in iommu table, IGD could access stolen memory in host > OS. > > While according to 'commit c875d2c1b808 ("iommu/vt-d: Exclude devices > using > > RMRRs from IOMMU API domains")',RMRR isn't supported by kvm, then > both EPT > > and guest iommu domain table lack of maaping for stolen memory in kvm > IGD > > passthrough environment. If IGD access stolen memory in such environment, > > many iommu exceptions exist in host dmesg and gpu hang exists also. > > DMAR: [DMA Read] Request device [00:02.0] fault addr da012000 > > [fault reason 05] PTE Write access is not set > > DMAR: [DMA Read] Request device [00:02.0] fault addr da2df000 > > [fault reason 06] PTE Read access is not set > > > > So stolen memory should be disabled in KVM IGD passthrough environment, > > this patch detects such environment through the existence of qemu > emulated > > isa bridge. > > > > When the real ISA bridge is also passed through to guest, guest will have > > two isa bridges: emulated and real. Qemu guarantees the busnum:devnum. > > funcnum of emulated isa bridge is always less than the real one. Then > > emulated isa bridge is always detected first by pci_get_class(ISA). So > > stolen memory will be disabled in this case also. > > Where does QEMU make this guarantee or any sort of guarantee wrt the > ISA bridge? Thanks, > > Alex > [Zhang, Xiong Y] In my guest environment I always see emulated devices are at head of pci device list, the passed through devices are at tail. Even if I want to assign the passed IGD to 00:02.0, the qemu tell me 00:02.0 has already occupied by emulated graphic card. If I pass through real ISA bridge to guest, the emulated ISA bridge is at 00:01.0, While real ISA bridge is at 00:04.0. Then I checked the code: emulated devices are created in pc_init1() function, it creates host_bridge firstly, create isa_bridge secondly, create all other devices following. So I think Qemu could guarantee. Now I'm suspect it, and need your coach. thanks