Skip to content

feat: legacy XADD and correct JIT code buffer sizing#145

Merged
qmonnet merged 2 commits into
qmonnet:mainfrom
sakateka:xadd
Jun 3, 2026
Merged

feat: legacy XADD and correct JIT code buffer sizing#145
qmonnet merged 2 commits into
qmonnet:mainfrom
sakateka:xadd

Conversation

@sakateka

@sakateka sakateka commented May 6, 2026

Copy link
Copy Markdown
Contributor

Hi, and thanks for a great project.

I hit a wall: my program uses atomic operations and wouldn’t run- it was hitting unimplemented. After digging through the code, adding support for the legacy XADD instructions looked straightforward, so I went ahead and implemented it.

I might come back later with full atomic support, but for now I’d like to get this merged.

Thanks!

@sakateka

Copy link
Copy Markdown
Contributor Author

Hi, @qmonnet! Could you please take a look at this PR when you have a moment? Thanks!

@qmonnet

qmonnet commented May 27, 2026

Copy link
Copy Markdown
Owner

Yep sorry, it's been a busy few weeks, but this is still on my list. I'll try to take a deeper look at it soon.

@qmonnet qmonnet left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, and apologies again for the delay.

It looks good overall, but I've got two comments:

  • Can you please adjust the verifier check to keep rejecting newer atomic operations (see comment below)?
  • Could you please make the JIT allocation fix a separate commit? It would make it easier to look at it again in the future, if necessary.

There's also test_jit_xadd_w_dw() which currently doesn't pass with --no-default-features ("Error: No custom executable memory set, call set_jit_exec_memory() to set one").

Comment thread src/verifier.rs Outdated
sakateka added 2 commits May 31, 2026 12:31
Add non-fetch ST_W_XADD/ST_DW_XADD so eBPF programs that use atomic
add-to-memory can run in the interpreter, x86_64 JIT, and Cranelift;
extend the verifier and tests accordingly.

Signed-off-by: Sergey Kacheev <s.kacheev@gmail.com>
Fix JIT allocation by sizing the executable buffer with a dry run
before emitting code, instead of assuming a single fixed page.

Signed-off-by: Sergey Kacheev <s.kacheev@gmail.com>
@sakateka

Copy link
Copy Markdown
Contributor Author

Thanks for the hints and explanations!
I split the changes into separate commits, fixed the failing test, and also tried to improve coverage.

@qmonnet qmonnet left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks good now, much better with two commits. Thank you!

@qmonnet qmonnet merged commit e312815 into qmonnet:main Jun 3, 2026
8 checks passed
@sakateka sakateka deleted the xadd branch June 4, 2026 07:09
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.

2 participants