-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Using Unicorn with MIPS64 #2109
Comments
Or you have to use virtual TLB. |
I am mapping a memory address that is small enough that it would not be redirected by the MIPS TLB, which is the problem that all the linked issues ran into in the docs you mentioned (they all use 32-bit). The address, |
This might be helpful: When enabling the TLB_VIRTUAL mode, it throws an error and the resulting PC value has a different output address afterwards everytime: #!/usr/bin/env python3
from unicorn import *
from unicorn.mips_const import *
emu = Uc(UC_ARCH_MIPS, UC_MODE_64 | UC_MODE_BIG_ENDIAN)
emu.ctl_set_tlb_mode(UC_TLB_VIRTUAL)
def hook(uc, vaddr, a, b, c):
print(hex(vaddr), a, b, c)
return True
emu.hook_add(UC_HOOK_TLB_FILL, hook)
code = b'\x00\x00\x00\x00' * 2 # NOP instruction in MIPS
ADDRESS = 0x1000
emu.mem_map(ADDRESS, 4 * 1024)
emu.mem_write(ADDRESS, code)
try:
emu.emu_start(ADDRESS, 0, count=1)
except Exception as e:
print(e)
print(f"PC: {hex(emu.reg_read(UC_MIPS_REG_PC))}") Running this script multiple times, the resulting PC has the top portion different each time - might indicate something being cobbled internally.
This behavior does not appear in MIPS_32 |
Anything left for this? |
MIPS64 now works great with UC_VIRTUAL_TLB enabled. Without this enabled, high addresses will cause incorrect memory address lookups, and I'll make another issue to describe this in case future contributors need more accurate MIPS64 MMU logic. |
Made the issue here - #2119 |
Thanks for providing the details. I will have a look at the new issue and close this issue. |
I have been attempting to get Unicorn to execute 64-bit MIPS code, and couldn't find instances of its usage in the codebase. Upon starting the emulator in the MIPS setting with
UC_MODE_64
, it always throws anUC_ERR_EXCEPTION
immediately upon starting the emulator.Here is a simple program to test this.
Is there any guidance on setting up 64 bit MIPS in Unicorn?
On a quick search, MIPS seems to have a "Status Register" that has certain bits that enables 64-bit mode in certain scenarios - the flags are outlined in page 91 of this manual https://scc.ustc.edu.cn/_upload/article/files/c6/06/45556c084631b2855f0022175eaf/W020100308600770617815.pdf

However, setting the various bits of
CP0_STATUS
seem to have no effect.The text was updated successfully, but these errors were encountered: