-
Notifications
You must be signed in to change notification settings - Fork 479
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
x86: cmpxchg instruction does not trigger memory callbacks #1119
Comments
Copying in discussion from Slack, I think the places we are missing instrumentation:
And
|
#1118 has been merged, so that pypanda script should demonstrate the problematic behavior you're trying to demonstrate on head of the dev branch now, for anyone else who is running it |
I did some spelunking through the source and various marcos to figure out what's going on here. I believe the relevant code locations are: target/i386/mem_helper.c: multiple helper function calls into cpu_stq_data_ra/cpu_ldq_data_ra and other load/store functions. include/exec/cpu_ldst.h: file which sets various parameters and then includes the file to define these load/store ops (see comment https://github.com/panda-re/panda/blob/dev/include/exec/cpu_ldst.h#L24-L41) include/exec/cpu_ldst_template.h: file which defines the load/store ops depending on the parameters set by cpu_ldst.h. The functions in cpu_ldst_template.h which define things like |
This issue has gone stale! If you believe it is still a problem, please comment on this issue or it will be closed in 30 days |
yes |
I have a draft PR that covers this. I will note that, as seen in the PR, this is a bug that covers more than the |
cmpxchg instructions on x86 (at least
cmpxchg16b
on x86_64) do not trigger mem_before_write callbacks.This can be reproduced as follows:
Then run the following PyPanda script (needs #1118 applied for working virtual memory hook):
Relevant part of the output is:
As you can see, the
test
variable from the C++ program is updated to 0x55555555, however there is not any write callback invoked for it. The last write callback is invoked for filling the variable with 0xdecafbad which is from beforecmpxchg16b
is invoked.I'm not too familiar with QEMU internals.
I've seen that in target/i386/mem_helper.c there are helper functions for cmpxchg instructions (maybe PANDA misses hooking these?), though I don't know if that's relevant.
The text was updated successfully, but these errors were encountered: