Skip to content

Conversation

@dpgao
Copy link
Contributor

@dpgao dpgao commented Nov 19, 2025

Revert two commits that made function pointer wrapping the default: It turned out that this knob was quite useful for performance evaluation.

These fast paths check if the compartment transition is a self-transition and if so, jump directly to the target without modifying the trusted stack.

Calls through the PLT continue to use the old slow path as self-transitions can already be ruled out when relocating jump slots.

Introduce the LD_COMPARTMENT_NO_FAST_PATH environment variable which forces all trampolines to use the slow path.

@jrtc27
Copy link
Member

jrtc27 commented Nov 19, 2025

I really don't like the idea of the option being reintroduced in-tree; it adds a bunch of complexity and ugly hacks, but also it's an option that is fundamentally unsound, and will become especially broken with compartmentalised TLS. What you really need is a way to profile trampolines and be able to count cycles spent specifically in function pointer ones.

@dpgao dpgao force-pushed the c18n-fast-path branch 3 times, most recently from ba44210 to 55b81ef Compare November 24, 2025 15:48
@dpgao dpgao changed the title [WIP] c18n: Introduce fast path in trampolines c18n: Introduce fast path in trampolines Nov 25, 2025
@dpgao dpgao requested a review from jrtc27 November 25, 2025 12:29
@dpgao
Copy link
Contributor Author

dpgao commented Nov 25, 2025

@jrtc27 I made some further changes to fix trampoline reflection when the fast path is disabled through the environment variable. The patch is tested on Morello with KDE and everything seems to be working fine.

PATCH_POINT(tramp_push_frame, n_rets, 7b)
PATCH_POINT(tramp_push_frame, target, 8b)

.section .rodata
Copy link
Member

Choose a reason for hiding this comment

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

Um this doesn't restore the section afterwards for what follows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The TRAMP macro always sets the section so this is fine.


.section .rodata
.globl c18n_tramp_entry_slow_offset
.align 3
Copy link
Member

Choose a reason for hiding this comment

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

.balign 8, .align is an abomination that's either .p2align or .balign depending on the architecture, and nobody ever wants to have to remember which...

@dpgao dpgao force-pushed the c18n-fast-path branch 2 times, most recently from 87c793c to 235e52e Compare December 5, 2025 18:09
@dpgao dpgao requested a review from jrtc27 December 8, 2025 14:04
These fast paths check if the compartment transition is a
self-transition and if so, jump directly to the target without modifying
the trusted stack.

Calls through the PLT continue to use the old slow path as
self-transitions can already be ruled out when relocating jump slots.

Introduce the LD_COMPARTMENT_NO_FAST_PATH environment variable which
forces all trampolines to use the slow path.
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