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

Add support for decoding ENDBR32/64 instructions #1416

Merged
merged 1 commit into from
Nov 28, 2024
Merged

Conversation

rafaelroquetto
Copy link
Contributor

@rafaelroquetto rafaelroquetto commented Nov 27, 2024

The ENDBR32 and ENDBR64 (collectively ENDBRANCH) are two new instructions that are used to mark valid indirect CALL/JMP target locations in the program. This instruction is a NOP on legacy processors for backward compatibility.

The processor implements a state machine that tracks indirect JMP and CALL instructions. When one of these instructions is seen, the state machine moves from IDLE to WAIT_​FOR_​ENDBRANCH state. In WAIT_​FOR_​ENDBRANCH state the next instruction in the program stream must be an ENDBRANCH. If an ENDBRANCH is not seen the processor causes a control protection fault (#CP), otherwise the state machine moves back to IDLE state.

(Source)

At this time, https://pkg.go.dev/golang.org/x/arch/x86/x86asm does not support decoding these instructions. We add a workaround that manually skips over them until proper support is added.

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.90%. Comparing base (9efc255) to head (c35a5a8).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1416      +/-   ##
==========================================
+ Coverage   72.41%   80.90%   +8.49%     
==========================================
  Files         145      146       +1     
  Lines       14868    14891      +23     
==========================================
+ Hits        10766    12048    +1282     
+ Misses       3389     2252    -1137     
+ Partials      713      591     -122     
Flag Coverage Δ
integration-test 59.10% <78.57%> (-0.03%) ⬇️
k8s-integration-test 60.01% <78.57%> (-0.01%) ⬇️
oats-test 34.00% <78.57%> (+0.11%) ⬆️
unittests 51.56% <78.57%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@grcevski grcevski left a comment

Choose a reason for hiding this comment

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

LGTM! Awesome!

@rafaelroquetto rafaelroquetto merged commit a380cd0 into main Nov 28, 2024
13 checks passed
@rafaelroquetto rafaelroquetto deleted the endbr64 branch November 28, 2024 00:18
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