Skip to content

Use bottom-up ELF placement policy - #1395

Merged
Sangho Lee (sangho2) merged 3 commits into
mainfrom
sanghle/bottom_up_elf_placement
Sep 23, 2026
Merged

Sangho Lee (sangho2) merged 3 commits into
mainfrom
sanghle/bottom_up_elf_placement

Conversation

@sangho2

Copy link
Copy Markdown
Contributor

This PR replaces the Linux shim loader's top-down fallback placement policy with a bottom-up policy. Currently, if placement of the main ELF at DEFAULT_LOW_ADDR fails, the loader searches downward from TASK_ADDR_MAX for a suitable gap without accounting for trampoline allocation or brk-based heap growth. Instead, this PR places the ELF in the first suitable gap at or above DEFAULT_LOW_ADDR.

@sangho2

Sangho Lee (sangho2) commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Since now both Linux and OP-TEE shims require bottom-up page placement, the core litebox crate might need to provide an API for it for performance.

@sangho2
Sangho Lee (sangho2) marked this pull request as draft September 18, 2026 22:31
@sangho2
Sangho Lee (sangho2) marked this pull request as ready for review September 18, 2026 22:59
@sangho2 Sangho Lee (sangho2) changed the title Add bottom-up ELF placement policy Use bottom-up ELF placement policy Sep 19, 2026

@wdcui Weidong Cui (wdcui) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks.

@CvvT

Copy link
Copy Markdown
Contributor

Since now both Linux and OP-TEE shims require bottom-up page placement, the core litebox crate might need to provide an API for it for performance.

litebox_shim_windows also needs this. I'm working on it.

@sangho2
Sangho Lee (sangho2) added this pull request to the merge queue Sep 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 22, 2026
@sangho2
Sangho Lee (sangho2) force-pushed the sanghle/bottom_up_elf_placement branch from 35aa07f to 003f199 Compare September 22, 2026 23:54
@sangho2
Sangho Lee (sangho2) force-pushed the sanghle/bottom_up_elf_placement branch from 003f199 to e472443 Compare September 23, 2026 00:13
@github-actions

Copy link
Copy Markdown

🤖 SemverChecks 🤖 No breaking API changes detected

Note: this does not mean API is unchanged, or even that there are no breaking changes; simply, none of the detections triggered.

@sangho2
Sangho Lee (sangho2) added this pull request to the merge queue Sep 23, 2026
Merged via the queue into main with commit fcad93e Sep 23, 2026
15 checks passed
@sangho2
Sangho Lee (sangho2) deleted the sanghle/bottom_up_elf_placement branch September 23, 2026 00:30
dywongcloud added a commit to dywongcloud/litebox that referenced this pull request Sep 25, 2026
Bring in the two upstream commits on top of 4964033:

- df162a1 Relocate page management into dedicated modules (microsoft#1415)
- fcad93e Use bottom-up ELF placement policy (microsoft#1395)

Resolution:

- litebox::mm::linux is now litebox::mm::vmem; every path on our side
  (including the macOS platform and the shims) follows the rename.
- The Linux and Windows userland platforms move prot_flags and their
  PageManagementProvider impl, with helpers and page tests, into
  page_mgmt.rs. Our Windows additions (the virtual-memory mutation
  lock, RecommitCommitted, allocation rollback) move with them
  unchanged.
- The mm test backend gains upstream's Windows TASK_ADDR bounds next to
  our Apple ones.
- Bottom-up ELF placement is ported onto our loader: the main image is
  claimed from default_low_addr() (which honours the platform's
  TASK_ADDR_MIN) with MAP_FIXED_NOREPLACE and retried past racing
  mappings, the interpreter stays top-down, and do_mmap is pub(crate).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants