unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.33k stars 1.31k forks source link

fix: Use correct addresses during memory cow #1873

Closed mlgiraud closed 10 months ago

mlgiraud commented 10 months ago

Title is mostly self explanatory. There was an issue where performing snapshots with a non one to one mapping of virtual to physical addresses, resulting in an assertion failure in unicorn. I assume this commit fixes the issue. @PhilippTakacs should check if this is correct now.

wtdcode commented 10 months ago

I can understand the motivation and looks correct at first glance. Do you have a reproduction? So that I can make sure that the fix is correct.

mlgiraud commented 10 months ago

I don't have a reproduction script since this occurred in our emulator for which i unfortunately cannot yet share the code. I will see if i can write up something that reproduces this.

mlgiraud commented 10 months ago

I added a test that reproduces the issue. You can check by reverting the commit that fixes the issue.

wtdcode commented 10 months ago

I added a test that reproduces the issue. You can check by reverting the commit that fixes the issue.

I see. Will check and thanks!

PhilippTakacs commented 10 months ago

LGTM

mlgiraud commented 10 months ago

@wtdcode Can we merge this, or are there some changes that need to be made?

wtdcode commented 10 months ago

Sorry just busy on something else and I will have a look today or tomorrow.

wtdcode commented 10 months ago

I tested and it's the correct fix. Thanks and I appreciate your patience.