From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YR6y6-0003qT-Ip for qemu-devel@nongnu.org; Thu, 26 Feb 2015 17:31:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YR6y1-0004aE-KN for qemu-devel@nongnu.org; Thu, 26 Feb 2015 17:31:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YR6y1-0004a7-Ax for qemu-devel@nongnu.org; Thu, 26 Feb 2015 17:31:37 -0500 Message-ID: <54EF9EC6.3030407@redhat.com> Date: Thu, 26 Feb 2015 17:31:34 -0500 From: John Snow MIME-Version: 1.0 References: <20150226144504.GA23124@stefanha-thinkpad.redhat.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] ahci: map memory via device's address space instead of address_space_memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jordan Hargrave Cc: Stefan Hajnoczi , qemu-devel@nongnu.org (Please don't top-post on qemu-devel: gmail is kind of awful about this, but if you expand the conversation while in-reply, you can edit beneath the quote instead of above.) On 02/26/2015 04:31 PM, Jordan Hargrave wrote: > The problem is the FIS registers have stale data. > > SeaBIOS initialization leaves the registers: > PORT_FIS_ADDR = 0x7fae0000 > PORT_FIS_ADDR_HI = 0x0 > > My OS initializes DMAR page tables and then enables the IOMMU translation. > Then OS initializes AHCI driver. Writes VIRTUAL DMA to FIS registers. > eg. FIS DMA address is 0x10000 (maps to some hardware physical address > via iommu) > > The OS writes 0x00 PORT_FIS_ADDR_HI -> qemu calls map_page (0x00 << 32) > | 0x7fae0000... 0x7fae0000 is stale, and is not in the IOMMU page map. > Causes a non-recoverable IOMMU fault. > > OK, I see. We can probably fix this by delaying the map and having it map on-demand before first access, setting a dirty flag if the registers have changed since last use. It might be an AHCI spec violation to change this register once the FIS Receive Engine is active, too, so it might not be too hard of a change; perhaps we can just map the FIS Receive Buffer once the FRE is started. Did you want to send a patch, or should I? --js > > On Thu, Feb 26, 2015 at 8:45 AM, Stefan Hajnoczi > wrote: > > On Wed, Feb 25, 2015 at 11:13:09PM -0600, Jordan Hargrave wrote: > > Referencing this old thread: > > > https://lists.nongnu.org/archive/html/qemu-devel/2014-07/msg00606.html > > > > I've run into an issue recently with testing q35 DMAR/intel iommu > with ahci > > driver. My ahci driver writes the upper-32 bits > (PORT_FIS_ADDR_HI) first > > then the lower 32-bits (PORT_FIS_ADDR). > > > > The contents of PORT_FIS_ADDR therefore are stale when the > PORT_FIS_ADDR_HI > > write calls map_page(). DMAR translation fails at this point as > the old > > stale address (from SEABIOS initialization) is not in the DMAR > page table. > > The AHCI device tries to map on register writes to both the base and > upper 32-bit registers. So it should work for a driver that writes > PORT_FIS_ADDR_HI before PORT_FIS_ADDR. > > Does the iommu failure pose a problem? > > Stefan > >