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

Use RS3d as temp_regd parameter for CHECK_WRITE macro #373

Merged

Conversation

mohanson
Copy link
Collaborator

CHECK_WRITE macro use the TEMP1 register as an internal temporary register, if we pass the TEMP1 register as the temp_regd parameter, there will be some logic errors here.

#define CHECK_WRITE(address_reg, temp_regd, length) \

movzbl CKB_VM_ASM_ASM_CORE_MACHINE_OFFSET_FLAGS(MACHINE, TEMP1), temp_regd; \
mov temp_regd, TEMP2d; \
and $CKB_VM_ASM_MEMORY_FLAG_WXORX_BIT, temp_regd; \
cmp $CKB_VM_ASM_MEMORY_FLAG_WRITABLE, temp_regd; \
jne .exit_invalid_permission; \
or $CKB_VM_ASM_MEMORY_FLAG_DIRTY, TEMP2b; \
movb TEMP2b, CKB_VM_ASM_ASM_CORE_MACHINE_OFFSET_FLAGS(MACHINE, TEMP1); \
movq TEMP1, TEMP2; \
shr $CKB_VM_ASM_MEMORY_FRAME_PAGE_SHIFTS, TEMP1; \
movzbl CKB_VM_ASM_ASM_CORE_MACHINE_OFFSET_FRAMES(MACHINE, TEMP1), temp_regd; \

@mohanson mohanson requested a review from xxuejie August 21, 2023 23:17
@mohanson mohanson merged commit b1f7e3f into nervosnetwork:develop Aug 22, 2023
12 checks passed
@mohanson mohanson deleted the fix_temp_regd_in_check_write branch August 22, 2023 03:39
mohanson added a commit to libraries/ckb-vm that referenced this pull request Aug 22, 2023
)

* Use RS3d as temp_regd for CHECK_WRITE

* Append the negative test case
mohanson added a commit to libraries/ckb-vm that referenced this pull request Aug 22, 2023
)

* Use RS3d as temp_regd for CHECK_WRITE

* Append the negative test case
mohanson added a commit that referenced this pull request Aug 22, 2023
* Use RS3d as temp_regd for CHECK_WRITE

* Append the negative test case
mohanson added a commit that referenced this pull request Aug 22, 2023
* Use RS3d as temp_regd for CHECK_WRITE

* Append the negative test case
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.

None yet

2 participants