-
Notifications
You must be signed in to change notification settings - Fork 481
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
flush cache after mempatch #5295
base: develop
Are you sure you want to change the base?
Conversation
This adds code to flush cache after applying a hotpatch. While it's unlikely that a patched location will be in cache at the time we apply a patch, it is better to be safe than sorry Also fixed the spelling error in `setPermissions` while I was here
side comment: i did not implement this for MacOS |
sys/cachectl.h: No such file or directory |
any idea what it should be? that's what the documentation for nvm, found it (i think) |
apparently the documentation i found was... incomplete
library/Process-linux.cpp
Outdated
@@ -220,7 +219,8 @@ bool Process::setPermissions(const t_memrange & range,const t_memrange &trgrange | |||
|
|||
bool Process::flushCache(const void* target, size_t count) | |||
{ | |||
return cacheflush(target, count, BCACHE); | |||
__builtin___clear_cache((char*)target, (char*)target + count - 1); | |||
return false; /* assume always succeeds, as the builtin has no return type */ |
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.
Just verifying, you return false for success?
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.
yeah, following the unix standard of 0 (false) for success and non-zero for failure. this is used elsewhere in DFHack for OS API calls (see, e.g. PlugLoad
)
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.
let me be clear that i don't have a problem with returning true for success :)
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.
It seems to me that returning 0 for success makes sense when the return value is an int, but if it's a bool, then it should return true for success. If this matches the semantics of the surrounding functions and is consistent across the different implementations in Process-linux and Process-windows, though, I'm fine with it.
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.
switched, since tbh i prefer returning true
on success as well
This adds code to flush cache after applying a hotpatch. While it's unlikely that a patched location will be in cache at the time we apply a patch, it is better to be safe than sorry
Also fixed the spelling error in
setPermissions
while I was hereNo changelog; this is a fix to existing functionality to avoid a potential future bug instead of fixing a known existing one