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

i#3544 RV64: Implement tp, stolen reg and lr/sc sequence mangling #6419

Merged
merged 6 commits into from
Nov 11, 2023

Conversation

ksco
Copy link
Contributor

@ksco ksco commented Nov 7, 2023

This patch implements several mangling procedures for tp, stolen reg, and lr/sc sequences.

  1. For any instruction using tp or stolen register, we use a scratch register to hold the app value and mangle the instr to use that scratch register.
  2. For the lr/sc sequence, a similar approach to AARCHXX's exclusive monitor is adopted: mangling LR to a normal load, and SC to a compare-and-swap. The function name (mangle_exclusive_monitor_op) is kept unchanged for simplicity.

Note there are several places that are left unimplemented, they are rarely used in practice, so it should be okay to implement it later.

Issue: #3544

This patch implements several mangling procedures for tp, stored reg, and lr/sc sequences.

1. For any instruction using tp or stolen register, we use a scratch register to hold the app value, and mangling the instr to use that scratch register.
2. For the lr/sc sequence, a similar approach to AARCHXX's exclusive monitor is adopted: mangling LR to a normal load, and SC to a compare-and-swap. The function name (mangle_exclusive_monitor_op) is keeped unchanged for simplicity.

Note there are several places that are left unimplemented, they are rarely used in practice, so it should be okay to implement it later.
@ksco ksco requested a review from derekbruening November 7, 2023 11:04
core/arch/arch.h Outdated Show resolved Hide resolved
suite/tests/api/ir_riscv64.expect Show resolved Hide resolved
core/arch/riscv64/mangle.c Outdated Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Outdated Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Outdated Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Outdated Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
+ Enable -ldstex2cas
+ Add a new scratch register a4
+ More comments
+ Style
+ Asserts
+ Simplify
Copy link
Contributor Author

@ksco ksco left a comment

Choose a reason for hiding this comment

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

Thanks for the review! I've updated the PR as suggested.

core/arch/arch.h Outdated Show resolved Hide resolved
suite/tests/api/ir_riscv64.expect Show resolved Hide resolved
core/arch/riscv64/mangle.c Outdated Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Show resolved Hide resolved
core/arch/riscv64/mangle.c Outdated Show resolved Hide resolved
@ksco ksco requested a review from derekbruening November 9, 2023 09:30
core/arch/riscv64/mangle.c Show resolved Hide resolved
@ksco ksco merged commit e8f554f into DynamoRIO:master Nov 11, 2023
15 checks passed
@ksco ksco deleted the i3544-mangling branch November 11, 2023 15:25
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