Opened 6 years ago

Closed 6 years ago

#11067 closed bug (fixed)

Kernel loaded to virtual address that overlaps with loader

Reported by: arvindsraj Owned by: axeld
Priority: normal Milestone: R1
Component: System/Boot Loader Version: R1/Development
Keywords: gsoc2014 Cc:
Blocked By: Blocking:
Platform: arm


Currently, the kernel gets loaded at the virtual address where loader is present; this will cause problem later on. The patch attached with this report moves the entire memory map to a higher memory address which prevents the loader from being overwritten.

Attachments (3)

Moved-entire-memory-to-higher-memory-location.patch (3.0 KB ) - added by arvindsraj 6 years ago.
Reserve-8MB-space-for-kernel-before-RAM_loader.patch (5.4 KB ) - added by arvindsraj 6 years ago.
Reserve-8MB-space-for-kernel-before-RAM_loader-2.patch (6.4 KB ) - added by arvindsraj 6 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by arvindsraj, 6 years ago

patch: 01

comment:2 by anevilyak, 6 years ago

Component: - GeneralSystem/Boot Loader
Owner: changed from nobody to axeld

comment:3 by arvindsraj, 6 years ago

Revised patch to reserve 8MB space for kernel just before RAM_loader instead of moving the entire memory map to a higher address.

comment:4 by pulkomandy, 6 years ago


These should be defined relative to HAIKU_BOARD_LOADER_BASE. This would allow a single common definition for all ARM targets.

	"RAM_stack", // stack 
 	kLoaderBaseAddress + 0x1200000, 
 	kLoaderBaseAddress + 0x1ffffff, 
        "RAM_initrd", // stack 
        kLoaderBaseAddress + 0x2000000, 
        kLoaderBaseAddress + 0x2500000, 

And these should be defined against HAIKU_BOARD_LOADER_UIBASE and HAIKU_BOARD_LOADER_STACK_BASE as defined in the Jamfile. These can be added to the CXXFLAGS if that's not already done, so we can use it from C++ sources. Also, please fix the " stack" comment for the initrd section, It does not contain the stack.

comment:5 by arvindsraj, 6 years ago

There's a small issue in setting value of HAIKU_BOARD_LOADER_ENTRY_NBSD relative to HAIKU_BOARD_LOADER_BASE. Jam doesn't support arithmetic which makes assigning a value to LOADER_ENTRY_NBSD slightly tricky. I tried invoking Add from build/jam/MathRules as


but that doesn't work because a hex value is passed to Add, which is classified as NaN by the rule Num. I don't think the other rules(AddNumAbs and AddNum) are meant to be invoked directly. One solution is to add a rule that accepts hex values but that might be too much work right now. Another solution is to perhaps perform all computations in sh using printf and bc perhaps. The problem is that this variable is passed directly to mkimage and thus should be a hex string.

comment:6 by pulkomandy, 6 years ago

You can use bc with hex numbers. To get hex input and output you use:

echo "obase=16;ibase=16;80800000+8" | bc

Be careful to set obase first, otherwise, you have to set the obase using the ibase previously configured:

echo "ibase=16;obase=10;80800000+8" | bc # Note obase is set to 0x10 here.

bc (with both obase and ibase) is part of POSIX, and should be safe to use on all our supported build platforms:

comment:7 by arvindsraj, 6 years ago

Changes in the new patch from previous one.

  • LOADER_ENTRY_RAW and LOADER_ENTRY_NBSD values are relative to LOADER_BASE.
  • Sections RAM_stack and RAM_initrd are defined relative to LOADER_STACK_BASE and LOADER_UIBASE. The latter two values are passed along with ASFLAGS, CCFLAGS and C++FLAGS defined in BoardSetup.

comment:8 by pulkomandy, 6 years ago

Resolution: fixed
Status: newclosed

Applied in hrev47653.

Note: See TracTickets for help on using tickets.