NVlabs / NVBit

198 stars 18 forks source link

How to flush instruction cache? #106

Open zz-Malfurion opened 1 year ago

zz-Malfurion commented 1 year ago

I'm trying to modify some instrumented instructions after nvbit_enable_instrumented. For example, if the replaced instruction is exit, there is no need to restore the saved context.

The implementation is a litter bit hack. I first find the trampoline code region inserted by nvbit, and then manually replace some instructions.

However, I found that if a kernel has been already executed, the instructions are cached in the instruction cache. Unless I run many other kernels to replace the cache, the modified instructions cannot be detected.

I have tried some other methods, e.g., unmap and remap the virtual address via cuMemUnmap/cuMemMap. But none of the methods worked.

Is there any elegant way to flush the instruction cache?

Thanks.

joannahuadu commented 6 months ago

Hi, could you give some details about how to replace the original 'exit' instruction with some new instructions? I've been trying this recently.