All of lore.kernel.org
 help / color / mirror / Atom feed
From: Don Zickus <dzickus@redhat.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: fastboot@osdl.org, Horms <horms@verge.net.au>,
	Jan Kratochvil <lace@jankratochvil.net>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Magnus Damm <magnus.damm@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [Fastboot] [CFT] ELF Relocatable x86 and x86_64 bzImages
Date: Tue, 8 Aug 2006 15:36:34 -0400	[thread overview]
Message-ID: <20060808193634.GN16231@redhat.com> (raw)
In-Reply-To: <m1ejvrakhq.fsf@ebiederm.dsl.xmission.com>

On Mon, Aug 07, 2006 at 11:01:53PM -0600, Eric W. Biederman wrote:
> Don Zickus <dzickus@redhat.com> writes:
> 
> >> >> >
> >> >> >> 
> >> >> >> The error is the uncompressed length does not math the stored length
> >> >> >> of the data before from before we compressed it.  Now what is
> >> >> >> fascinating is that our crc's match (as that check is performed first).
> >> >> >> 
> >> >> >> Something is very slightly off and I don't see what it is.
> >> >> >
> >> >> > I printed out orig_len -> 5910532 (which matches vmlinux.bin)
> >> >> >              bytes_out -> 5910531
> >> >> >
> >> >> >> 
> >> > It seems to be an AMD64 vs EM64T problem.  AMD chipsets work but Intel
> >> > chipsets don't.  
> >> >
> >> > I also blindly incremented bytes_out (as a really cheap hack), it didn't
> >> > work until I added some random putstr's below it (timing??).  Then the
> >> > kernel booted. 
> >> >
> >> > Still looking into things.  
> >> 
> >> Odd.  I wonder if I'm missing a serializing instruction somewhere,
> >> to ensure the effects of ``self modifying code'' aren't a problem.
> >> As I read Intels Documentation if you have a jump before you get
> >> to the code there shouldn't be a problem.
> >> 
> >> Still that doesn't really explain bytes_out.
> >> 
> >
> > So I narrowed down the problem but it isn't obvious to me why this problem
> > exists.  Basically, even though bytes_out is supposed to be initialized to
> > 0, it becomes -1 before entering decompress_kernel().  Of course, the
> > fallout is in flush_window() bytes_out wounds up being one less than
> > outcnt and hence my original problem.
> >
> > Any thoughts on how to debug where this could be getting corrupted?  
> 
> Looking at my build it appears bytes_out is being placed in the .bss.
> A little odd since it is zero initialized but no big deal.
> Could you confirm that bytes_out is being placed in the .bss section 
> by inspecting arch/x86_64/boot/compresssed/misc.o and
> arch/x86_64/boot_compressed/vmlinux.   "readelf -a $file" and then
> looking up the section number and looking at the section table to see
> which section it is was my technique.

Yes bytes_out is in the .bss for both files.  

> 
> If bytes_out is in the .bss for you then I suspect something is not
> correctly zeroing the .bss.  Or else the .bss is being stomped.
> 
> I'm not certain how rep stosb can be done wrong but some bad pointer
> math could have done it.

Even worse, from the time the .bss is cleared to the time gunzip() is
called inside decompress_kernel(), there is very little code to do some
stomping.  

So I am stuck trying to debug this.  This code seems very fragile.  The
more debug code I add (ie putstr) the more the length is off (varies from
-32 to +1).  Makes me scratch my head as to what is really going on here.  

I created a really pathetic patch to get the thing to boot but even that
doesn't make sense.  


diff --git a/arch/x86_64/boot/compressed/misc.c b/arch/x86_64/boot/compressed/misc.c
index 0e6c4b7..614416e 100644
--- a/arch/x86_64/boot/compressed/misc.c
+++ b/arch/x86_64/boot/compressed/misc.c
@@ -183,6 +183,7 @@ #define OLD_CL_MAGIC 0xA33F
 extern unsigned char input_data[];
 extern int input_len;
 
+static long dummy;
 static long bytes_out = 0;
 
 static void *malloc(int size);
@@ -594,6 +595,7 @@ asmlinkage void decompress_kernel(void *
 	if ((ulg)output >= 0xffffffffffUL)
 		error("Destination address too large");
 
+	bytes_out = 0;
 	makecrc();
 	putstr(".\nDecompressing Linux...");
 	gunzip();

And yes, the 'dummy' variable needs to be there.  
I am trying to use gdb on vmlinux to fish for clues.  But I am at a loss
right now.  

Cheers,
Don

> 
> Eric

  reply	other threads:[~2006-08-08 19:34 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <aec7e5c30606300145p441d8d0xd89fab5e87de5a22@mail.gmail.com>
     [not found] ` <20060705222448.GC992@in.ibm.com>
     [not found]   ` <aec7e5c30607051932r49bbcc7eh2c190daa06859dcc@mail.gmail.com>
     [not found]     ` <20060706081520.GB28225@host0.dyn.jankratochvil.net>
     [not found]       ` <aec7e5c30607070147g657d2624qa93a145dd4515484@mail.gmail.com>
     [not found]         ` <20060707133518.GA15810@in.ibm.com>
     [not found]           ` <20060707143519.GB13097@host0.dyn.jankratochvil.net>
     [not found]             ` <20060710233219.GF16215@in.ibm.com>
     [not found]               ` <20060711010815.GB1021@host0.dyn.jankratochvil.net>
     [not found]                 ` <m1d5c92yv4.fsf@ebiederm.dsl.xmission.com>
2006-07-31 16:19                   ` [CFT] ELF Relocatable x86 and x86_64 bzImages Eric W. Biederman
2006-07-31 20:25                     ` Vivek Goyal
2006-07-31 21:00                       ` [Fastboot] " Vivek Goyal
2006-08-01  2:31                         ` Eric W. Biederman
2006-08-01  2:34                           ` H. Peter Anvin
2006-08-01  3:44                             ` Eric W. Biederman
2006-08-01  4:25                           ` Jan Kratochvil
2006-08-01  9:09                             ` Eric W. Biederman
2006-08-01  9:43                               ` Jan Kratochvil
2006-08-01 11:28                                 ` Eric W. Biederman
2006-08-04 21:08                     ` Don Zickus
2006-08-04 21:25                       ` Eric W. Biederman
2006-08-04 23:43                         ` Don Zickus
2006-08-05  7:49                           ` Eric W. Biederman
2006-08-05 16:07                           ` Eric W. Biederman
2006-08-07 17:44                             ` Don Zickus
2006-08-07 18:08                               ` Eric W. Biederman
2006-08-07 23:57                                 ` Don Zickus
2006-08-08  5:01                                   ` Eric W. Biederman
2006-08-08 19:36                                     ` Don Zickus [this message]
2006-08-09 20:06                                     ` Don Zickus
2006-08-10  6:09                                       ` Eric W. Biederman
2006-08-10 13:13                                         ` Vivek Goyal
2006-08-10 17:05                                           ` Eric W. Biederman
2006-08-10 18:18                                             ` Vivek Goyal
2006-08-10 20:09                                               ` Eric W. Biederman
2006-08-11 21:25                                                 ` Don Zickus
2006-08-12  7:20                                                   ` Eric W. Biederman
2006-08-12 15:25                                                     ` Don Zickus
2006-08-12 19:41                                                       ` Eric W. Biederman
2006-08-13 20:06                                                     ` Andi Kleen
2006-08-13 21:44                                                       ` Eric W. Biederman
2006-08-14 16:51                                                 ` [Fastboot] " Vivek Goyal
2006-08-14 17:04                                                   ` H. Peter Anvin
2006-08-14 18:11                                                     ` Vivek Goyal
2006-08-14 19:32                                                       ` H. Peter Anvin
2006-08-14 19:42                                                         ` Vivek Goyal
2006-08-14 19:45                                                           ` H. Peter Anvin
2006-08-14 19:57                                                             ` Vivek Goyal
2006-08-14 20:10                                                             ` Eric W. Biederman
2006-08-14 20:59                                                               ` Vivek Goyal
2006-08-14 21:15                                                                 ` Eric W. Biederman
2006-08-14 20:00                                                     ` Eric W. Biederman
2006-08-08 23:36                                   ` Andi Kleen
2006-08-25 20:16                     ` Vivek Goyal
2006-08-25 20:16                       ` Vivek Goyal
     [not found] <6EIOG-2xY-31@gated-at.bofh.it>
     [not found] ` <6EIOG-2xY-33@gated-at.bofh.it>
     [not found]   ` <6EIOG-2xY-35@gated-at.bofh.it>
     [not found]     ` <6EIOG-2xY-37@gated-at.bofh.it>
     [not found]       ` <6EIOG-2xY-39@gated-at.bofh.it>
     [not found]         ` <6EIOG-2xY-19@gated-at.bofh.it>
     [not found]           ` <6Gf5M-2zt-23@gated-at.bofh.it>
     [not found]             ` <6Gfpt-30C-49@gated-at.bofh.it>
     [not found]               ` <6GhAA-6bP-19@gated-at.bofh.it>
     [not found]                 ` <6Gx2C-436-5@gated-at.bofh.it>
     [not found]                   ` <6HhoT-5E7-33@gated-at.bofh.it>
     [not found]                     ` <6HhRQ-6uk-3@gated-at.bofh.it>
2006-08-09 12:40                       ` [Fastboot] " Bodo Eggert

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=20060808193634.GN16231@redhat.com \
    --to=dzickus@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=fastboot@osdl.org \
    --cc=horms@verge.net.au \
    --cc=hpa@zytor.com \
    --cc=lace@jankratochvil.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.