[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Funny -m arguments can crash

From: Markus Armbruster
Subject: Re: [Qemu-devel] Funny -m arguments can crash
Date: Mon, 13 Aug 2012 15:41:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)

Avi Kivity <address@hidden> 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:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]