-
Notifications
You must be signed in to change notification settings - Fork 1
Fix/ecsm address bound air executor #913
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
Open
jotabulacios
wants to merge
6
commits into
main
Choose a base branch
from
fix/ecsm-address-bound-air-executor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ef9ba73
Match the ECSM executor bound to the AIR
jotabulacios a2bbb1d
Give ECSM operand accesses their own address column
jotabulacios d30fee1
Apply the multi-agent review of the ECSM fix
jotabulacios aff127e
Reject wrapped ECSM operands at trace build
jotabulacios b128308
Validate the ECSM operand span before any access
jotabulacios 2701114
Fix comments the removed ECSM guard invalidated
jotabulacios File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| .attribute 5, "rv64i2p1_m2p0_zmmul1p0" | ||
| .globl main | ||
| main: | ||
| # xR is written at low limb 0xFFFF_FFFC, so the DERIVED doubleword bases carry into | ||
| # the high limb: addr[0] = 0x0_FFFF_FFFC, addr[1] = 0x1_0000_0004, addr[2] = | ||
| # 0x1_0000_000C, addr[3] = 0x1_0000_0014. Only the per-access address columns can | ||
| # express that — the old `ADDR_*_0 + 8i` derivation would put a non-canonical low | ||
| # limb on the Memory bus for i = 1..3 and the trace would not balance. Byte carries | ||
| # inside a doubleword are exercised too: bytes 4..7 of addr[0] land past 2^32. | ||
| # | ||
| # Stack layout (96 bytes): xG at sp+0, k at sp+32, read-back buffer at sp+64. | ||
| addi sp, sp, -96 | ||
|
|
||
| # xG = secp256k1 Gx, little-endian. | ||
| li t0, 0x59F2815B16F81798 | ||
| sd t0, 0(sp) | ||
| li t0, 0x029BFCDB2DCE28D9 | ||
| sd t0, 8(sp) | ||
| li t0, 0x55A06295CE870B07 | ||
| sd t0, 16(sp) | ||
| li t0, 0x79BE667EF9DCBBAC | ||
| sd t0, 24(sp) | ||
|
|
||
| # k = 5. | ||
| li t0, 5 | ||
| sd t0, 32(sp) | ||
| sd zero, 40(sp) | ||
| sd zero, 48(sp) | ||
| sd zero, 56(sp) | ||
|
|
||
| # t1 = 2^32 - 4 = 0xFFFF_FFFC. | ||
| li t1, 1 | ||
| slli t1, t1, 32 | ||
| addi t1, t1, -4 | ||
|
|
||
| # ECSM ecall: a0 = &xR (bases carry), a1 = &xG, a2 = &k, a7 = -11. | ||
| addi a0, t1, 0 | ||
| addi a1, sp, 0 | ||
| addi a2, sp, 32 | ||
| li a7, -11 | ||
| ecall | ||
|
|
||
| # Read xR back and stage it where the commit syscall can reach it. | ||
| ld t2, 0(t1) | ||
| sd t2, 64(sp) | ||
| ld t2, 8(t1) | ||
| sd t2, 72(sp) | ||
| ld t2, 16(t1) | ||
| sd t2, 80(sp) | ||
| ld t2, 24(t1) | ||
| sd t2, 88(sp) | ||
|
|
||
| li a0, 1 | ||
| addi a1, sp, 64 | ||
| li a2, 32 | ||
| li a7, 64 | ||
| ecall | ||
|
|
||
| addi sp, sp, 96 | ||
| li a0, 0 | ||
| li a7, 93 | ||
| ecall | ||
| .Lfunc_end1: | ||
| .size main, .Lfunc_end1-main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| .attribute 5, "rv64i2p1_m2p0_zmmul1p0" | ||
| .globl main | ||
| main: | ||
| # xR is written at low limb 0xFFFF_FFE1 (high limb 0), so its last doubleword | ||
| # starts at +24 = 0xFFFF_FFF9 and its trailing bytes cross 2^32. Every base the | ||
| # ECSM AIR derives stays inside the limb; MEMW's carry columns place the crossing | ||
| # bytes at 0x1_0000_0000. Reading them back proves they landed there. | ||
| # | ||
| # Stack layout (96 bytes): xG at sp+0, k at sp+32, read-back buffer at sp+64. | ||
| addi sp, sp, -96 | ||
|
|
||
| # xG = secp256k1 Gx, little-endian. | ||
| li t0, 0x59F2815B16F81798 | ||
| sd t0, 0(sp) | ||
| li t0, 0x029BFCDB2DCE28D9 | ||
| sd t0, 8(sp) | ||
| li t0, 0x55A06295CE870B07 | ||
| sd t0, 16(sp) | ||
| li t0, 0x79BE667EF9DCBBAC | ||
| sd t0, 24(sp) | ||
|
|
||
| # k = 5. | ||
| li t0, 5 | ||
| sd t0, 32(sp) | ||
| sd zero, 40(sp) | ||
| sd zero, 48(sp) | ||
| sd zero, 56(sp) | ||
|
|
||
| # t1 = 2^32 - 31 = 0xFFFF_FFE1. | ||
| li t1, 1 | ||
| slli t1, t1, 32 | ||
| addi t1, t1, -31 | ||
|
|
||
| # ECSM ecall: a0 = &xR (crossing), a1 = &xG, a2 = &k, a7 = -11. | ||
| addi a0, t1, 0 | ||
| addi a1, sp, 0 | ||
| addi a2, sp, 32 | ||
| li a7, -11 | ||
| ecall | ||
|
|
||
| # Padding so the continuation test's epoch boundary falls between the ECSM write and | ||
| # the read-back: at epoch_size_log2 = 5 the ecall sits at instruction 48 and without | ||
| # this the loads land at 49..55, i.e. the same epoch, and the crossing page is never | ||
| # carried into an epoch that reads it. Sixteen nops push the loads past cycle 64. | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
| nop | ||
|
|
||
| # Read xR back from the crossing address into the stack buffer. The last load | ||
| # spans 0xFFFF_FFF9..0x1_0000_0000. | ||
| ld t2, 0(t1) | ||
| sd t2, 64(sp) | ||
| ld t2, 8(t1) | ||
| sd t2, 72(sp) | ||
| ld t2, 16(t1) | ||
| sd t2, 80(sp) | ||
| ld t2, 24(t1) | ||
| sd t2, 88(sp) | ||
|
|
||
| # Commit the read-back bytes so the test can compare them against x(5G). | ||
| li a0, 1 | ||
| addi a1, sp, 64 | ||
| li a2, 32 | ||
| li a7, 64 | ||
| ecall | ||
|
|
||
| addi sp, sp, 96 | ||
| li a0, 0 | ||
| li a7, 93 | ||
| ecall | ||
| .Lfunc_end1: | ||
| .size main, .Lfunc_end1-main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.