From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0vUU-0003Y5-Hs for qemu-devel@nongnu.org; Mon, 13 Aug 2012 10:19:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T0vUS-0006SU-Tq for qemu-devel@nongnu.org; Mon, 13 Aug 2012 10:19:34 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:60015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0vUS-0006SO-Ov for qemu-devel@nongnu.org; Mon, 13 Aug 2012 10:19:32 -0400 Received: by obbta14 with SMTP id ta14so6605273obb.4 for ; Mon, 13 Aug 2012 07:19:32 -0700 (PDT) From: Anthony Liguori In-Reply-To: <87393qnc3t.fsf@blackfin.pond.sub.org> References: <87629cvz5b.fsf@blackfin.pond.sub.org> <87ipd8s7zs.fsf@blackfin.pond.sub.org> <87y5m1be5q.fsf@blackfin.pond.sub.org> <87wr1921rd.fsf@blackfin.pond.sub.org> <502235FA.6050903@redhat.com> <87393qnc3t.fsf@blackfin.pond.sub.org> Date: Mon, 13 Aug 2012 09:19:30 -0500 Message-ID: <87lihi50y5.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] Funny -m arguments can crash List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , Avi Kivity Cc: Blue Swirl , jan.kiszka@siemens.com, qemu-devel@nongnu.org, peter.maydell@linaro.org Markus Armbruster writes: > Avi Kivity writes: > >> On 08/08/2012 12:04 PM, Markus Armbruster wrote: >>>> >>>> Yes please, maybe with a notice to the user. >>> >>> Next problem: minimum RAM size. >>> >>> For instance, -M pc -m X, where X < 32KiB dies "qemu: fatal: Trying to >>> execute code outside RAM or ROM at [...] Aborted (core dumped)" with >>> TCG, and "KVM internal error. Suberror: 1" with KVM. >>> >>> Should a minimum RAM size be enforced? Board-specific? >>> >> >> It's really a BIOS bug causing a limitation of both kvm and tcg to be >> hit. The BIOS should recognize it doesn't have sufficient memory and >> hang gracefully (if you can picture that). It just assumes some low >> memory is available and tries to execute it with the results you got. > > SeaBIOS indeed assumes it got at least 1MiB of RAM. It doesn't bother > to check CMOS for a smaller RAM size. However, that bug / feature is > currently masked by a QEMU bug: we screw up CMOS contents when there's > less than 1 MiB of RAM. pc_cmos_init(): > > int val, nb, i; > [...] > /* memory size */ > val = 640; /* base memory in K */ > rtc_set_memory(s, 0x15, val); > rtc_set_memory(s, 0x16, val >> 8); > > val = (ram_size / 1024) - 1024; > if (val > 65535) > val = 65535; > rtc_set_memory(s, 0x17, val); > rtc_set_memory(s, 0x18, val >> 8); > > If ram_size < 1MiB, val goes negative. Oops. > > For instance, with -m 500k, we happily promise 640KiB base memory (CMOS > addr 0x15..16), almost 64MiB extended memory (0x17..18 and 0x30..31), > yet no memory above 16MiB (0x34..35). > > An easy way to fix this is to require 1MiB of RAM :) > > But if you like, I'll put sane values in CMOS instead. That'll expose > the SeaBIOS bug. > > Anthony, you're the PC maintainer, got a preference? > > SeaBIOS thread: > http://comments.gmane.org/gmane.comp.bios.coreboot.seabios/4341 I'd prefer fixing the CMOS values over limiting to 1MB of RAM. Having a 1MB limit is purely theoritical--not practical. There's no good reason for anyone to ask for < 1MB unless they know what they're doing. If it's truly a mistake, then asking for 2MB is just as much of a mistake because no real guest will run with 2MB of memory anyway (you can't even load a kernel). So if we're just going for theoritical correctness, we ought to do it the Right Way which is fixing the CMOS values and putting the check in SeaBIOS. Regards, Anthony Liguori