From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTEiV-0000QO-Ac for qemu-devel@nongnu.org; Wed, 04 Mar 2015 14:12:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTEiQ-0001gv-8U for qemu-devel@nongnu.org; Wed, 04 Mar 2015 14:12:23 -0500 Received: from host217-34-137-81.in-addr.btopenworld.com ([217.34.137.81]:44451 helo=external.sentinel2) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTEiQ-0001fc-2R for qemu-devel@nongnu.org; Wed, 04 Mar 2015 14:12:18 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 04 Mar 2015 19:12:10 +0000 From: Gordan Bobic In-Reply-To: <1425475231.8389.63.camel@nilsson.home.kraxel.org> References: <97fd6e025b9dfa941ea0d7677b52f66c@mail.shatteredsilicon.net> <1425475231.8389.63.camel@nilsson.home.kraxel.org> Message-ID: <9779520a9ba5544750f4eb570ce3bf8c@mail.shatteredsilicon.net> Subject: Re: [Qemu-devel] =?utf-8?q?QEMU_etc/e820_and_fw=5Fcfg?= List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org On 2015-03-04 13:20, Gerd Hoffmann wrote: > On Di, 2015-03-03 at 10:32 +0000, Gordan Bobic wrote: >> I need to pass a custom e820 map to a virtual machine for >> troubleshooting purposes and working around IOMMU hardware >> bugs. >> >> I have found references to a custom map being providable >> via an external file, mentioned as "etc/e820" and "fw_cfg". > > That is the (filesystem-like) interface between qemu and firmware > (seabios usually), it doesn't refer to a on-disk file. > >> Unfortunately, I have not found any documentation that >> explains how to use this from userspace when invoking >> qemu. > > You can't. > > Passing a different e820 map requires patching qemu (or seabios, which > mangles the e820 table to add reservations for acpi etc). > > What exactly do you need? Thank you for responding. The situation I have is that my PCIe bridges are buggy and they seem to bypass the upstream PCIe hub IOMMU. The problem with this is that when the guest accesses RAM within it's emulated address space that overlaps with PCI I/O memory ranges in the host's address space, what should have ended up in RAM in the guest ends up trampling over the IOMEM on the host. This typically results in crashing the host (or worse, if it happens to trample any IOMEM regions mapped to disk controllers). The solution seems to be to prevent the guest from accessing the areas of memory that are mapped as something other than RAM on the host. So what I need to be able to do is set a bseline e820 map that marks all areas as reserved if they are not marked as usable on the host. I wrote a prototype patch (an ugly bodge not for public consumption) for Xen to test the theory of whether this would fix the problem, and it did. But I would like to use KVM now instead. I tried using the max-ram-below-4g option to --machine, and that fixes a part of the problem, but because it doesn't mark the memory between the set value and 4GB as reserved, it ends up mapping the PCI devices passed through to the guest into that area, which similarly ends up trampling over the host's IOMEM area and crashing the machine. So I need a way to explicitly reserve certain memory ranges in the map. What is the most sensible way to do this with QEMU? Gordan