-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add writeable holders for executable memory #53934
Conversation
This change adds holders for writeable mappings for executable memory. It is the largest part of the W^X support. The ExecutableWriterHolder implementation is dummy in this change, but it was fully tested with coreclr / libraries tests on Windows arm, arm64, x64 and x86 with the real double memory mapping. There are few concepts / conventions used: * When the writeable pointer isn't known at a place where it is needed and also not at the caller, the ExecutableWriterHolder instance is created. * When a callee needs writeable pointer to executable memory and caller knows RW and RX, the argument is doubled with RX and RW suffixes. For constructors and member methods when "this" is the RW one, we pass just extra RX argument. * Locals holding RW pointer use RW suffix. * Locals holding RX pointer usually have no suffix to minimize number of changes, but in some cases they have a RX suffix where I felt like it was better to make things clear.
cc: @mangod9 |
|
||
#include "utilcode.h" | ||
#include "ex.h" | ||
#include <intrin.h> |
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.
Does this file really need intrin.h ?
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 doesn't, it is a remainder of other changes I have in the branch with the complete set of W^X changes. But it is used only for logging stuff that will go away.
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.
LGTM
// nop | ||
m_code[1] = 0xbf00; | ||
pThisRW->m_code[1] = 0xbf00; |
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.
not part of your change, but aren't there constants defined for standard opcodes?
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 am not aware of such a thing in our codebase.
There was a code that got writeable mapping to an address, but then referenced data below that address in the GC stress C implementation for ARM.
This change adds holders for writeable mappings for executable memory.
It is the largest part of the W^X support. The ExecutableWriterHolder
implementation is dummy in this change, but it was fully tested with
coreclr / libraries tests on Windows arm, arm64, x64 and x86 with the
real double memory mapping.
There are few concepts / conventions used:
and also not at the caller, the ExecutableWriterHolder instance is
created.
knows RW and RX, the argument is doubled with RX and RW suffixes. For
constructors and member methods when "this" is the RW one, we pass just
extra RX argument.
changes, but in some cases they have a RX suffix
where I felt like it was better to make things clear.
Contributes to #50391