qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: peter.maydell@linaro.org, jan.kiszka@siemens.com,
	Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org, Blue Swirl <blauwirbel@gmail.com>,
	Anthony Liguori <anthony@codemonkey.ws>
Subject: Re: [Qemu-devel] Funny -m arguments can crash
Date: Mon, 13 Aug 2012 17:02:32 +0300	[thread overview]
Message-ID: <20120813140232.GA11194@redhat.com> (raw)
In-Reply-To: <502907A5.6070302@redhat.com>

On Mon, Aug 13, 2012 at 04:56:53PM +0300, Avi Kivity wrote:
> On 08/13/2012 04:41 PM, Markus Armbruster wrote:
> > Avi Kivity <avi@redhat.com> 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.
> 
> IMO we need to fix CMOS reporting.
> 
> (technically we shouldn't touch CMOS NVRAM at all; seabios should
> discover memory size via fwcfg and program it itself.  But it's
> pointless to change it now)
> 
Chipset we emulate does not support all those crazy memory values you
can give to -m.

--
			Gleb.

  reply	other threads:[~2012-08-13 14:02 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-25 11:49 [Qemu-devel] Funny -m arguments can crash Markus Armbruster
2012-07-27 19:00 ` Blue Swirl
2012-07-28  6:41   ` Markus Armbruster
2012-07-28  8:29     ` Blue Swirl
2012-07-30 12:56       ` Markus Armbruster
2012-07-30 15:05         ` Blue Swirl
2012-08-08  9:04           ` Markus Armbruster
2012-08-08  9:16             ` Peter Maydell
2012-08-08 10:02               ` Markus Armbruster
2012-08-08  9:48             ` Avi Kivity
2012-08-13 13:41               ` Markus Armbruster
2012-08-13 13:56                 ` Avi Kivity
2012-08-13 14:02                   ` Gleb Natapov [this message]
2012-08-13 14:04                     ` Avi Kivity
2012-08-13 14:10                       ` Gleb Natapov
2012-08-13 20:35                         ` Blue Swirl
2012-08-19 19:26                   ` Kevin O'Connor
2012-08-13 14:19                 ` Anthony Liguori
2012-08-13 14:46                   ` Markus Armbruster
2012-08-14  8:44                   ` Markus Armbruster
2012-08-14 10:20                     ` Avi Kivity
2012-08-14 10:44                       ` Jan Kiszka
2012-08-14 10:51                         ` Avi Kivity
2012-08-14 11:01                           ` Jan Kiszka
2012-08-14 13:16                             ` Avi Kivity
2012-08-14 13:25                               ` Jan Kiszka
2012-08-14 13:42                                 ` Avi Kivity
2012-08-14 11:12                       ` Markus Armbruster
2012-08-14 13:25                         ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120813140232.GA11194@redhat.com \
    --to=gleb@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=armbru@redhat.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).