Skip to content

UC_ERR_ARG when attempting to write to c1_c0_2 arm register #1510

@wr3nchsr

Description

@wr3nchsr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions