From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1Ysr-0004Zp-Ub for qemu-devel@nongnu.org; Wed, 15 Aug 2012 04:23:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T1Ysq-0002Q1-Ub for qemu-devel@nongnu.org; Wed, 15 Aug 2012 04:23:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59199) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1Ysq-0002Pw-M9 for qemu-devel@nongnu.org; Wed, 15 Aug 2012 04:23:20 -0400 From: Markus Armbruster References: <1344945535-2774-1-git-send-email-armbru@redhat.com> <1344945535-2774-3-git-send-email-armbru@redhat.com> Date: Wed, 15 Aug 2012 10:23:16 +0200 In-Reply-To: (Blue Swirl's message of "Tue, 14 Aug 2012 18:31:44 +0000") Message-ID: <87d32so96z.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 2/2] pc: Fix RTC CMOS info on RAM for ram_size < 1MiB List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: anthony@codemonkey.ws, qemu-devel@nongnu.org, gleb@redhat.com, avi@redhat.com Blue Swirl writes: > On Tue, Aug 14, 2012 at 11:58 AM, Markus Armbruster wrote: >> pc_cmos_init() always claims 640KiB base memory, and ram_size - 1MiB >> extended memory. The latter can underflow to "lots of extended >> memory". Fix both, and clean up some. >> >> Note: SeaBIOS currently requires 1MiB of RAM, and doesn't check >> whether it got enough. >> >> Signed-off-by: Markus Armbruster >> --- >> hw/pc.c | 27 +++++++++++++++------------ >> 1 file changed, 15 insertions(+), 12 deletions(-) >> >> diff --git a/hw/pc.c b/hw/pc.c >> index e8bcfc0..1597fe6 100644 >> --- a/hw/pc.c >> +++ b/hw/pc.c >> @@ -337,32 +337,35 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, >> /* various important CMOS locations needed by PC/Bochs bios */ >> >> /* memory size */ >> - val = 640; /* base memory in K */ >> + /* base memory (first MiB) */ >> + val = MIN(ram_size / 1024, 640); >> rtc_set_memory(s, 0x15, val); >> rtc_set_memory(s, 0x16, val >> 8); >> - >> - val = (ram_size / 1024) - 1024; >> + /* extended memory (next 64MiB) */ >> + if (ram_size > 1024 * 1024) > > Please add braces. Done in v2. [...]