Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce fudge factor from shoehorn and strip elf files before loading #158

Merged
merged 4 commits into from
Feb 28, 2025

Conversation

kent-mcleod
Copy link
Member

Correct the calculated memory needed to load an elf image. Using only
the p_memsz value ignores gaps between segments; instead calculate the
first+last addresses using p_vaddr & p_memsz.

As get_memory_usage in elf_sift.py now can calculate correct memory
usage from a list of ELF segments, a more accurate upper bound on
memory usage for the loaded apps is possible and the old fudge
factor is no longer needed.

Thanks to @sleffler for the patch.

@kent-mcleod kent-mcleod added hw-build enable all sel4test hardware builds hw-test enable sel4test hardware builds + runs labels Mar 13, 2023
@kent-mcleod
Copy link
Member Author

There are some errors that I'll try and track down. The Elfloader is reporting that the loaded regions are all exclusive, however there appears to be consistent hanging before executing the kernel in some cases.

  ELF-loader started on CPU: ARM Ltd. Cortex-A53 r0p4
    paddr=[64b000..b5d117]
  No DTB passed in from boot loader.
  Looking for DTB in CPIO archive...found at 7c9528.
  Loaded DTB from 7c9528.
     paddr=[250000..254fff]
  ELF-loading image 'kernel' to 0
    paddr=[0..24ffff]
    vaddr=[ffffff8000000000..ffffff800024ffff]
    virt_entry=ffffff8000000000
  ELF-loading image 'sel4test-driver' to 255000
    paddr=[255000..64afff]
    vaddr=[400000..7f5fff]
    virt_entry=40e548
  Boot cpu id = 0x0, index=0
  
  [[Timeout]]
  None

@kent-mcleod kent-mcleod force-pushed the kent/fudge branch 8 times, most recently from e396746 to f438dbf Compare February 27, 2025 23:12
@kent-mcleod kent-mcleod changed the title Remove fudge factor from shoehorn Reduce fudge factor from shoehorn Feb 27, 2025
@kent-mcleod kent-mcleod changed the title Reduce fudge factor from shoehorn Reduce fudge factor from shoehorn and strip elf files before loading Feb 27, 2025
@@ -57,6 +57,13 @@ function(ApplyData61ElfLoaderSettings kernel_platform kernel_sel4_arch)
endif()
set(IMAGE_START_ADDR 0x10000000 CACHE INTERNAL "" FORCE)
endif()
if(KernelPlatformSpike OR KernelPlatformQEMURiscVVirt)
# Spike loads elfloader to either 0x80200000 or 0x80400000
# But the RISC-V kernel is currently loaded to a differen't
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# But the RISC-V kernel is currently loaded to a differen't
# But the RISC-V kernel is currently loaded to a different

Copy link
Member

@lsf37 lsf37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Should we close JIRA SELFOUR-2335?

sleffler and others added 4 commits February 28, 2025 15:22
Correct the calculated memory needed to load an elf image. Using only
the p_memsz value ignores gaps between segments; instead calculate the
first+last addresses using p_vaddr & p_memsz.

Signed-off-by: Kent McLeod <kent@kry10.com>
Strip out sections from kernel and rootserver elffiles before loading
them into the cpio archive.
Nothing makes use of this information at runtime and it causes the elf
binary to be larger than it needs to be.

Signed-off-by: Kent McLeod <kent@kry10.com>
As get_memory_usage in elf_sift.py now can calculate correct memory
usage from a list of ELF segments, a more accurate upper bound on
memory usage for the loaded apps is possible and the old fudge
factor is no longer needed.

We still need some gap to account for the size of the elfloader program
so that the elfloader ends up above itself in memory if loaded to the
lowest available address.

Signed-off-by: Kent McLeod <kent@kry10.com>
Shoehorn currently can't manage to pick a good load address.

Signed-off-by: Kent McLeod <kent@kry10.com>
@kent-mcleod kent-mcleod merged commit 4c52ef0 into seL4:master Feb 28, 2025
14 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hw-build enable all sel4test hardware builds hw-test enable sel4test hardware builds + runs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants