From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Srevo-00061C-4G for qemu-devel@nongnu.org; Wed, 18 Jul 2012 20:49:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Srevl-0000So-SU for qemu-devel@nongnu.org; Wed, 18 Jul 2012 20:49:28 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:34667) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Srevl-0000Sc-M2 for qemu-devel@nongnu.org; Wed, 18 Jul 2012 20:49:25 -0400 Received: by pbbro12 with SMTP id ro12so3454618pbb.4 for ; Wed, 18 Jul 2012 17:49:24 -0700 (PDT) Message-ID: <5007598F.7060505@ozlabs.ru> Date: Thu, 19 Jul 2012 10:49:19 +1000 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <500657F2.1080703@ozlabs.ru> <5006E5C4.2010201@weilnetz.de> In-Reply-To: <5006E5C4.2010201@weilnetz.de> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] qemu in full emulation on win32 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: qemu-devel@nongnu.org, David Gibson On 19/07/12 02:35, Stefan Weil wrote: > Am 18.07.2012 08:30, schrieb Alexey Kardashevskiy: >> Hi! >> >> Found 2 problems while I was debugging qemu/ppc64-softmmu/qemu-system-ppc64.exe >> WindowsXP SP3 Pro, 32bit, i686-pc-mingw32-gcc (GCC) 4.5.2. >> >> >> 1. The size of the following is 7 bytes on linux and 8 bytes on Windows: >> struct { >> uint32_t hi; >> uint64_t child; >> uint64_t parent; >> uint64_t size; >> } __attribute__((packed)) ranges[]; >> >> The structure is used between QEMU and Open Firmware (powerpc bios) so it is important. >> >> The Feature is described here: >> http://stackoverflow.com/questions/7789668/why-would-the-size-of-a-packed-structure-be-different-on-linux-and-windows-when >> Shortly there is packing and ms-packing and they are different :) >> >> The solutions are: >> 1. Add MS-specific #pragma pack(push,1) and #pragma pack(pop). >> 2. Add -mno-ms-bitfields (gcc >= 4.7.0) >> 3. Change the structure above to use only uint32_t. >> >> What is the common way of solving such problems in QEMU? > > Problem 1 is solved with solution 4 (your own patch) although > that patch does not change the structure size to 7 bytes :-) The weblink here is just for explanation :) My struct is 7 32bit values but on Windows it was 8 32bit values, 32->28 bytes. >> 2. QEMU cannot allocate 1024MB for the guest RAM. Literally, VirtualAlloc() fails on 1024MB BUT it does not if I allocate 1023MB and 64MB by 2 subsequent calls. We allocate RAM via memory_region_init_ram(). I am pretty sure this is not happening on 64bit Windows and I suspect that it is happening with qemu-system-x86.exe, is not it? >> >> Do we care that there is actually enough RAM and we could allocate it in several chunks? > > > Please try the patch which I'm going to send. > > On w64, VirtualAlloc() _can_ allocate large quantities of contiguous > virtual memory. > > On w32, it is normally restricted to the lower 2 GiB which are already > fragmented > by the code (executable, shared libraries) and data. Larger quantities > are available > when the executable is allowed to use the upper 2 GiB, too. That's what > my patch does. Looking forward, thanks. I am surprised nobody hit it before. -- Alexey