-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix physical address truncation on 32-bit systems with addressing extensions #2139
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
Fix physical address truncation on 32-bit systems with addressing extensions #2139
Conversation
Looks good to me. Let's see if this broken any unit test in C. |
Could you also add a small test to here: https://github.com/unicorn-engine/unicorn/blob/master/tests/unit/test_arm.c ? |
Doing that would mean writing code that initializes the MMU and creates a page table. Since there aren't any existing tests that utilize the MMU for ARM that would mean writing them from scratch, and while I don't mind doing that, I won't have the time to do it until the weekend. Does this small fix really necessitate a test? |
As far as I see this can also be tested with |
It’s okay and takes your time.
The bug was introduced in #1746 and Unicorn is too complex so that even I could make mistakes and ignore such trivial errors. Therefore, writing a test can ensure your use case is guaranteed to work in our future releases, both beneficial to your project and Unicorn Engine in a long run. That said, I sincerely appreciate if you could write a test case or if you are really too busy, we can go as it is, but at a risk of breaking the code in the future. Take your time and feel free to make a choice, I’m not pushing you anyway, i.e. it’s optional. |
Considering you are using rust, it's also okay to add to https://github.com/unicorn-engine/unicorn/blob/master/tests/rust-tests/main.rs if you prefer to add a test. Our CI will run these tests for every commit. |
Here is a test for this using
edit: actually check a memory access |
Thanks @PhilippTakacs, I added your patch! |
Thanks for both of you =). |
While experimenting with Unicorn to emulate an ARMv7 system that heavily utilizes LPAE, I noticed Unicorn would translate the virtual addresses properly. However, the address got truncated to 32-bits somewhere in the pipeline, which rendered my emulator inoperable.
I tracked down the problem to a couple of types in the
CPUTLBEntry
struct and surrounding functions. I've changed them fromtarget_ulong
tohwaddr
(hopefully I didn't miss any).This change seems to work for my setup, I haven't tried other architectures (such as x86 with PAE) but if my understanding of the code is correct, the change should be architecture-angostic.
When running
cargo test
, all tests seem to pass. However, I have not added new ones for this scenario.