-
Notifications
You must be signed in to change notification settings - Fork 881
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
Fix mcontrol6 mask low/high operations. #1771
Conversation
@YenHaoChen, can you review this? |
@aswaterman I think this change is good to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need reg_t(1)
.
(Sorry that I forget to submit the review.)
riscv/triggers.cc
Outdated
reg_t tdata2_low = tdata2 & ((1 << (xlen/2)) - 1); | ||
reg_t value_low = value & ((1 << (xlen/2)) - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need reg_t(1)
.
reg_t tdata2_low = tdata2 & ((reg_t(1) << (xlen/2)) - 1);
reg_t value_low = value & ((reg_t(1) << (xlen/2)) - 1);
riscv/triggers.cc
Outdated
reg_t mask = tdata2 >> (xlen/2); | ||
return ((value >> (xlen/2)) & mask) == (tdata2 & mask); | ||
reg_t tdata2_high = tdata2 >> (xlen/2); | ||
reg_t tdata2_low = tdata2 & ((1 << (xlen/2)) - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need reg_t(1)
.
reg_t tdata2_low = tdata2 & ((reg_t(1) << (xlen/2)) - 1);
I think @YenHaoChen is right about the out-of-bounds shifts by 32 when |
I doubt this code was ever tested, and this change isn't tested either, because OpenOCD doesn't use this trigger type. This problem was reported in riscv/riscv-debug-spec#1057
I've added reg_t() where necessary. Thanks. |
I doubt this code was ever tested, and this change isn't tested either, because OpenOCD doesn't use this trigger type.
This problem was reported in
riscv/riscv-debug-spec#1057