Skip to content
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

UC_ERR_ARG when attempting to write to c1_c0_2 arm register #1510

Open
wr3nchsr opened this issue Nov 14, 2024 · 1 comment
Open

UC_ERR_ARG when attempting to write to c1_c0_2 arm register #1510

wr3nchsr opened this issue Nov 14, 2024 · 1 comment

Comments

@wr3nchsr
Copy link

Describe the bug
The c1_c0_2 register in arm raises an Invalid argument (UC_ERR_ARG) error when writing to it.
This was tested with qiling version 1.4.6 and unicorn version 2.1.1

Sample Code
Run the example hello_arm_linux_debug.py or the following code:

ql = Qiling(code=bytes(1000), archtype=QL_ARCH.ARM, ostype=QL_OS.LINUX)

This will call the enable_vfp function from QlArchARM which will attempt to write to c1_c0_2 and raise the error.

Screenshots
Screenshot 2024-11-14 at 12 02 55 PM

Additional context
This is caused because of this unicorn commit which changed the default return value of reg_write function from UC_ERR_OK to UC_ERR_ARG.
Screenshot 2024-11-14 at 11 39 58 AM

Furthermore, the switch case handling register UC_ARM_REG_C1_C0_2 in the reg_write function is commented out as shown here which causes the function to return the default return value.
Screenshot 2024-11-14 at 11 55 33 AM

and the register UC_ARM_REG_C1_C0_2 is commented as depreciated and should be replaced with UC_ARM_REG_CP_REG here.

@elicn
Copy link
Member

elicn commented Nov 14, 2024

Unicorn upgrade to version 2.1.1 broke Qiling which has not adapted yet, however that is to be resolved soon. Currently there are three options to work around this:

  1. Wait for Qiling to catch up with latest Unicorn changes
  2. Apply pending changes in Qiling (Adjust Qiling to comply with latest changed in Unicorn 2.1.2 #1499) and adjust your code accordingly. That is, using the newly introduced methods ql.arch.cpr.read and ql.arch.cpr.write (see commit 3c5ff2d for examples of how to use it)
  3. Revert Unicorn to version 2.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants