> -----Original Message-----
> From: Magnus Damm [mailto:[EMAIL PROTECTED]
> Sent: 2006年11月22日 12:53
> To: [EMAIL PROTECTED]
> Cc: Magnus Damm; fastboot@lists.osdl.org; Horms; [EMAIL PROTECTED]; Zou,
> Nanhai
> Subject: Re: [PATCH 005/013] kexec-tools: Make use of
> crash_create_elf64_headers() (x86_64)
> 
> Hi Vivek and Nan hai,
> 
> On 11/22/06, Vivek Goyal <[EMAIL PROTECTED]> wrote:
> > On Tue, Nov 21, 2006 at 02:56:23PM +0900, Magnus Damm wrote:
> > [..]
> > > >>
> > > >> +static struct crash_elf_info elf_info =
> > > >> +{
> > > >> +     class: ELFCLASS64,
> > > >> +     data: ELFDATA2LSB,
> > > >> +     machine: EM_X86_64,
> > > >> +     alignment: 1024,
> > > >
> > > >This alignment thing is confusing me. Can you give some more details
> > > >please?
> > >
> > > Well, I only put it in because the original code had some alignment code:
> > >
> > > @@ -734,7 +615,6 @@ int load_crashdump_segments(struct kexec
> > >       void *tmp;
> > >       unsigned long sz, elfcorehdr;
> > >       int nr_ranges, align = 1024, i;
> > > -       long int nr_cpus = 0;
> > >       struct memory_range *mem_range, *memmap_p;
> > >
> > >       if (get_kernel_paddr(info))
> > > @@ -764,20 +644,9 @@ int load_crashdump_segments(struct kexec
> > >               return -1;
> > >
> > >       /* Create elf header segment and store crash image data. */
> > > -       nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
> > > -       if (nr_cpus < 0) {
> > > -               fprintf(stderr,"kexec_load (elf header segment)"
> > > -                       " failed: %s\n", strerror(errno));
> > > -               return -1;
> > > -       }
> > > -       sz =    sizeof(Elf64_Ehdr) + nr_cpus * sizeof(Elf64_Phdr) +
> > > -                       nr_ranges * sizeof(Elf64_Phdr);
> > > -       sz = (sz + align - 1) & ~(align -1);
> > > -       tmp = xmalloc(sz);
> > > -       memset(tmp, 0, sz);
> > > -
> > > -       /* Prepare ELF64 core heaers. */
> > > -       if (prepare_crash_memory_elf64_headers(info, tmp, sz) < 0)
> > > +       if (crash_create_elf64_headers(info, &elf_info,
> > > +                                      crash_memory_range, nr_ranges,
> > > +                                      &tmp, &sz) < 0)
> > >               return -1;
> > >
> > > Have a look at the align variable above? It is set to 1024. So I just
> > > broke out the alignment number and put it into the elf_info structure
> > > to make it per-arch.
> > >
> > > I don't know why the number of bytes allocated are rounded to an even
> > > 1024. It is probably because the data that follows the headers should
> > > be aligned. Word-size aligment I understand, but 1024 I don't. 1024
> > > was probably a handy value that happened to work regardless of 32 or
> > > 64 bit elf format...
> > >
> >
> >
> > Ok. Now I remember. I had put this alignment to make sure elf header
> > segment is atleast 1K aligned. And the reason behind that is when we
> > prepare the memmap= options to pass to second kernel, we can pass the
> > memory only with a granularity of KB and not less than that.
> >
> > So I need to remove the elf core header segment from the list of memory
> > regions which second kernel can use. I used delete_memmap() function to
> > do that and create a new list. If segments/memory regions I am handling
> > are at least 1K aligned, it becomes easier to handle them. Otherwise
> > its chaos.
> 
> That explains the alignment. Thank you! Always aligning to 1K makes sense 
> then.
> 
> Nan hai, you align to EFI_PAGE_SIZE instead of 1K on ia64. Do you have
> any special reason for doing so?
> 
> Right now I assume it is a "copy-and-paste-o" so my patches use
> 1K-alignment instead.
> 
  ELF spec says, loadable process segments should be aligned to page size.
  But for core dump data, I guess 1k might be ok. But why not align them to 
page size?
  Thanks
   Zou Nan hai

> > So I guess, its fine to continue with this alignment thing. Though
> > a small comment might help to future code writers.
> 
> I see this as an improvement or clarification for the existing code.
> So I'll cook up a separate patch with the comment next week when I'm
> back from a few days vacation.
> 
> Thanks!
> 
> / magnus

_______________________________________________
fastboot mailing list
fastboot@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/fastboot

Reply via email to