[haiku-commits] Re: BRANCH xyzzy-github.x86_64 - src/system/kernel/arch/x86_64 src/system/boot/loader headers/private/kernel/util src/system/boot/platform src/system/kernel/debug

  • From: Alex Smith <alex@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 25 Jun 2012 10:54:15 +0100

On 25 June 2012 01:49, Ingo Weinhold <ingo_weinhold@xxxxxx> wrote:

> xyzzy-github.x86_64 wrote:
> >
> ############################################################################
> >
> > Commit: 035825cdfcf0f778a4e87c7a216c14ab5e9b8116
> >
> > Author: Alex Smith <alex@xxxxxxxxxxxxxxxx>
> > Date: Sun Jun 24 16:19:48 2012 UTC
> >
> > Align the start of the kernel .data to a 2MB boundary, prevents ld from
> merging the text and data PHDRs.
> >
> >
> ----------------------------------------------------------------------------
> >
> > diff --git a/src/system/ldscripts/x86_64/kernel.ld
> b/src/system/ldscripts/x86_64/kernel.ld
> > index 0703792..1496cc7 100644
> > --- a/src/system/ldscripts/x86_64/kernel.ld
> > +++ b/src/system/ldscripts/x86_64/kernel.ld
> > @@ -28,8 +28,8 @@ SECTIONS
> >
> >   .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
> >
> > - /* writable data */
> > - . = ALIGN(0x1000);
> > + /* writable data */
> > + . = ALIGN (0x200000);
> >   __data_start = .;
> >   .data : { *(.data .data.* .gnu.linkonce.d.*) }
>
> This sounds a bit like a linker bug or misconfiguration. We don't use
> large pages (yet?), so aligning to a small page should be sufficient. I
> don't know whether it can even result in other problems, if the code is
> compiled and linked under the impression that large pages are used, but
> small pages are actually used.
>
>
> >
> ############################################################################
> >
> > Commit: c2656eb9bd735878c33f979c273ba59a1f96cc09
> >
> > Author: Alex Smith <alex@xxxxxxxxxxxxxxxx>
> > Date: Sun Jun 24 16:51:05 2012 UTC
> >
> > Improved elf_load_image() a bit.
> >
> > After enabling BOOT_SUPPORT_ELF64 on x86 the x86 kernel could no longer
> be
> > booted because too many kernel_args allocations were taking place and
> filling
> > kernel_args_ranges. This was because for each image load it would check
> if
> > the image is ELF64, fail and fall back to ELF32 (each ELF64 check
> allocated
> > a preloaded_image). Changed elf_load_image() so that it only tries both
> when
> > loading the kernel image, and then for modules it will only try the same
> ELF
> > class as the kernel image.
> >
> >
> ----------------------------------------------------------------------------
> >
> > diff --git a/src/system/boot/loader/elf.cpp
> b/src/system/boot/loader/elf.cpp
> > index f54e96b..1e1d7a4 100644
> > --- a/src/system/boot/loader/elf.cpp
> > +++ b/src/system/boot/loader/elf.cpp
> > @@ -222,7 +222,7 @@ ELFLoader<Class>::Load(int fd, preloaded_image*
> _image)
> >   // inbetween.
> >   totalSize = secondRegion->start + secondRegion->size -
> firstRegion->start;
> >   if (totalSize > image->text_region.size + image->data_region.size
> > - + 8 * 1024) {
> > + + 0x200000) {
>
> This is only a not really important sanity check anyway, but you should be
> consistent and use the page size for comparison. Moreover the rounding
> operations for the segment area's start and size should also use the actual
> page size. So, if you're going to use large pages for the kernel you should
> consistently use the size of the large pages for the kernel. However, for
> kernel modules using large pages would waste a lot of memory, so those
> should continue to use small pages. I would recommend to keep it simple and
> stick to small pages for both, though.
>

The default behaviour on x86_64 is to align segments to 2MB, not aligning
to that results in ld merging the text and data PHDRs. I could turn this
behaviour off when linking the kernel instead with -z max-page-size=0x1000.
Probably better for now as I don't intend to map the kernel with large
pages for the moment.

Thanks,
Alex

Other related posts: