From patchwork Wed Jun 6 00:09:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin O'Connor X-Patchwork-Id: 163209 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DAF31B6F9F for ; Wed, 6 Jun 2012 10:15:03 +1000 (EST) Received: from localhost ([::1]:56501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc3tt-0004Sl-La for incoming@patchwork.ozlabs.org; Tue, 05 Jun 2012 20:15:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc3pa-0002SD-2u for qemu-devel@nongnu.org; Tue, 05 Jun 2012 20:14:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sc3oV-0007lk-Ln for qemu-devel@nongnu.org; Tue, 05 Jun 2012 20:10:33 -0400 Received: from mail-qa0-f52.google.com ([209.85.216.52]:33278) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc3oV-0007kw-GD for qemu-devel@nongnu.org; Tue, 05 Jun 2012 20:09:27 -0400 Received: by qabj34 with SMTP id j34so3144894qab.11 for ; Tue, 05 Jun 2012 17:09:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent :x-gm-message-state; bh=ue4lkQ035iZOeJeUxTJ7nykTPKT6vpFHzWVlQ05wqWs=; b=SK9izJywUGIdssbQ7UOGC3ZuCia5lmf4Okz8spuVHMEzwZofOm3yY9nSC7hLDzYQEj 0xu1GqAgyeDdsoV3Jfjp/wUh+aG2++j8vlMB+YWycC5c7Hb1g7jABLZgU4utzJ8m3y2O ejgWcudBffYrelPGZKm9Iy2JWkv7o43cGeSMZ5ExUjOUG8VIYvXGLSzfad9WlLVW9Mam HtgxAHJfQXeA6G8qwL+34KE5f15bX3vSp+lbNkBPVhy5lpcBdBZP9LCiNdEM6OabngIF Simfp6wOWoZ2tb/iKfU3aFq/c1PvQS2BPFVBWu/rfuTIOUyf9GZ01w+lZjge3Yc0t1gL gPGw== Received: by 10.224.220.204 with SMTP id hz12mr19586423qab.60.1338941364662; Tue, 05 Jun 2012 17:09:24 -0700 (PDT) Received: from localhost (207-172-165-101.c3-0.avec-ubr1.nyr-avec.ny.cable.rcn.com. [207.172.165.101]) by mx.google.com with ESMTPS id gw2sm338151qab.10.2012.06.05.17.09.21 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Jun 2012 17:09:22 -0700 (PDT) Date: Tue, 5 Jun 2012 20:09:21 -0400 From: Kevin O'Connor To: Jason Baron Message-ID: <20120606000921.GA32725@morn.localdomain> References: <201206051609.q55G9ImZ019474@int-mx09.intmail.prod.int.phx2.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <201206051609.q55G9ImZ019474@int-mx09.intmail.prod.int.phx2.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQlytWWQxjQrAmc4VQB0SWhSO89DDLZ0DRsu3+70Z5kwYk7l8m2/yto/vDbkwcwS2zpaHQ1Y X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.216.52 Cc: seabios@seabios.org, qemu-devel@nongnu.org, mst@redhat.com Subject: Re: [Qemu-devel] [PATCH] seabios: correct setting of datalow_base for large rom images X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Tue, Jun 05, 2012 at 12:09:18PM -0400, Jason Baron wrote: > I've been creating 256kb rom images with larger acpi tables for second level > buses. After a recent re-base, my rom images no longer built. Bisected to: > > commit 46b82624c95b951e8825fab117d9352faeae0ec8 > Author: Kevin O'Connor > Date: Sun May 13 12:10:30 2012 -0400 > > Add mechanism to declare variables as "low mem" and use for extra stack. > > > Where sec32low_top is greater than datalow_base. Currently, datalow_base is > calculated by subtracting a 64kb offset. Updating it to 128kb, resolved this > issue for me, while still continuing to create smaller rom images as expected. Thanks. The problem causing the build to fail is that negative numbers aren't encoded properly. That's easy to fix, but it quickly uncovers a problem with relocations. Some of the 16bit code has 16bit relocations and those wont be handled right if the integer wraps. I put together a fix (see below) but it's a bit ugly. > --- a/tools/layoutrom.py > +++ b/tools/layoutrom.py > @@ -219,10 +219,10 @@ def doLayout(sections, genreloc): > li.sections32low = getSectionsCategory(sections, '32low') > if genreloc: > sec32low_top = li.sec32init_start > - datalow_base = min(BUILD_BIOS_ADDR, li.sec32flat_start) - 64*1024 > + datalow_base = min(BUILD_BIOS_ADDR, li.sec32flat_start) - 128*1024 Unfortunately this will just break other areas. The datalow_base can only be 64K in size because a real-mode segment can only see 64K. -Kevin diff --git a/src/biosvar.h b/src/biosvar.h index fd2f1bf..0da5a27 100644 --- a/src/biosvar.h +++ b/src/biosvar.h @@ -254,8 +254,8 @@ extern u8 _datalow_seg, _datalow_base[]; #define SEG_LOW ((u32)&_datalow_seg) #if MODESEGMENT -#define GET_LOW(var) GET_FARVAR(SEG_LOW, (var)) -#define SET_LOW(var, val) SET_FARVAR(SEG_LOW, (var), (val)) +#define GET_LOW(var) __GET_FARVAR("addr32 ", SEG_LOW, (var)) +#define SET_LOW(var, val) __SET_FARVAR("addr32 ", SEG_LOW, (var), (val)) #define LOWFLAT2LOW(var) ((typeof(var))((void*)(var) - (u32)_datalow_base)) #else #define GET_LOW(var) (var) diff --git a/src/farptr.h b/src/farptr.h index 3a85c6b..3a6130b 100644 --- a/src/farptr.h +++ b/src/farptr.h @@ -106,13 +106,13 @@ DECL_SEGFUNCS(SS) // Macros for accessing a variable in another segment. (They // automatically update the %es segment and then make the appropriate // access.) -#define __GET_FARVAR(seg, var) ({ \ +#define __GET_FARVAR(prefix, seg, var) ({ \ SET_SEG(ES, (seg)); \ - GET_VAR(ES, (var)); }) -#define __SET_FARVAR(seg, var, val) do { \ - typeof(var) __sfv_val = (val); \ - SET_SEG(ES, (seg)); \ - SET_VAR(ES, (var), __sfv_val); \ + __GET_VAR(prefix, ES, (var)); }) +#define __SET_FARVAR(prefix, seg, var, val) do { \ + typeof(var) __sfv_val = (val); \ + SET_SEG(ES, (seg)); \ + __SET_VAR(prefix, ES, (var), __sfv_val); \ } while (0) // Macros for accesssing a 32bit flat mode pointer from 16bit real @@ -139,8 +139,8 @@ DECL_SEGFUNCS(SS) #if MODESEGMENT == 1 // Definitions when using segmented mode. -#define GET_FARVAR(seg, var) __GET_FARVAR((seg), (var)) -#define SET_FARVAR(seg, var, val) __SET_FARVAR((seg), (var), (val)) +#define GET_FARVAR(seg, var) __GET_FARVAR("", (seg), (var)) +#define SET_FARVAR(seg, var, val) __SET_FARVAR("", (seg), (var), (val)) #define GET_VAR(seg, var) __GET_VAR("", seg, (var)) #define SET_VAR(seg, var, val) __SET_VAR("", seg, (var), (val)) #define SET_SEG(SEG, value) __SET_SEG(SEG, (value)) diff --git a/src/romlayout.S b/src/romlayout.S index 8125277..67b0cc2 100644 --- a/src/romlayout.S +++ b/src/romlayout.S @@ -398,7 +398,7 @@ irqentry_extrastack: pushl %eax movl $_datalow_seg, %eax movl %eax, %ds - movl StackPos, %eax + addr32 movl StackPos, %eax subl $24, %eax popl 0(%eax) // Backup %eax, %ds, %es, %ecx, %edx popw 4(%eax) diff --git a/src/stacks.c b/src/stacks.c index 9381729..890fb58 100644 --- a/src/stacks.c +++ b/src/stacks.c @@ -40,7 +40,7 @@ stack_hop(u32 eax, u32 edx, void *func) // Copy stack seg to %ds/%ss and set %esp "movw %w6, %%ds\n" "movw %w6, %%ss\n" - "movl %5, %%esp\n" + "addr32 movl %5, %%esp\n" "pushl %3\n" "pushl %4\n" // Call func @@ -68,9 +68,9 @@ stack_hop_back(u32 eax, u32 edx, void *func) u32 bkup_stack_pos, temp; asm volatile( // Backup stack_pos and current %ss/%esp - "movl %6, %4\n" + "addr32 movl %6, %4\n" "movw %%ss, %w3\n" - "movl %%esp, %6\n" + "addr32 movl %%esp, %6\n" // Restore original callers' %ss/%esp "movl -4(%4), %5\n" "movl %5, %%ss\n" @@ -81,8 +81,8 @@ stack_hop_back(u32 eax, u32 edx, void *func) // Restore %ss/%esp and stack_pos "movw %w3, %%ds\n" "movw %w3, %%ss\n" - "movl %6, %%esp\n" - "movl %4, %6" + "addr32 movl %6, %%esp\n" + "addr32 movl %4, %6" : "+a" (eax), "+d" (edx), "+c" (func), "=&r" (bkup_ss) , "=&r" (bkup_stack_pos), "=&r" (temp), "+m" (StackPos) : diff --git a/tools/layoutrom.py b/tools/layoutrom.py index 74b410f..c6025ae 100755 --- a/tools/layoutrom.py +++ b/tools/layoutrom.py @@ -48,8 +48,6 @@ def setSectionsStart(sections, endaddr, minalign=1, segoffset=0): totspace = alignpos(totspace, section.align) + section.size startaddr = (endaddr - totspace) / minalign * minalign curaddr = startaddr - # out = [(addr, sectioninfo), ...] - out = [] for section in sections: curaddr = alignpos(curaddr, section.align) section.finalloc = curaddr @@ -261,7 +259,8 @@ def outXRefs(sections, useseg=0): loc = symbol.section.finalloc if useseg: loc = symbol.section.finalsegloc - out += "%s = 0x%x ;\n" % (reloc.symbolname, loc + symbol.offset) + out += "%s = 0x%x ;\n" % ( + reloc.symbolname, (loc + symbol.offset) & 0xffffffff) return out # Write LD script includes for the given sections using relative offsets