[PTLsim-devel] Self-modifying code detection issues?
Edward Lee
Tue Mar 13 14:54:30 EDT 2007
I have a small test case that is triggering SMC checks -> flushing the
pipeline. I compile this on a 32bit machine and use PTLsim classic on
a 64bit machine.
int num;
int main() {
ptlcall_switch_to_sim();
num++;
ptlcall_switch_to_native();
return num;
}
The num++ is triggering the "store" side of SMC, and the instructions
following it is the "load" that triggers the SMC detect.
Here's some lines from ptlsim.log..
num++
0x80483fa: ldd tr0 = [zero,0x8049f44]
0x80483fa: addd tr0 = tr0,1 [zco]
0x80483fa: std. mem = [zero,0x8049f44],tr0
the instruction (*) immediately following num++
0x8048401: ldd tr0 = [zero,0x8049f3c]
(*) being fetched
3 fetch rip 0x8048401: ldd tr0 = [zero,0x8049f3c] (BB
0xf76c1000 uopid 3; SOM)
(*) detecting SMC
3 smcdet rob 3 : self-modifying code at rip 0x8048401 detected (mfn
was dirty); invalidate and retry [EOM #1]
The address that num++ modifies is 0x8049f44 and the rip of (*) is
0x8048401, so they're 6,979 bytes apart which is more than a PAGE_SIZE
(4096).
If I stick ".zero 4096" at the end of main in the asm file, it stops
detecting SMC.
--
Ed
More information about the PTLsim-devel mailing list