Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting ILL_ILLOPC (illegal opcode) when trying to execute MRC or MCR instructions on Android

I'm using ARM Assembly trying to access several coprocessor registers. Whenever I have something like

mcr p15, #1, r1, c1, c0

or

mrc p15, #0, r0, c1, c0

I get signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 80400d00 error, which means that something is getting an illegal (non-existent, I assume) operation code (instruction). There are several possibilities. The mrc and mcr instructions themselves might be illegal, but the code compiles with no complaints. If this were a privileged mode issue, I'd expect to see a ILL_PRVOPC SIGILL instead.

Another possibility is that the opcode that is a part of mrc and mcr (syntax is MRC{2}<c><q> <coproc>, #<opc1>, <Rt>, <CRn>, <CRm>) might be illegal. I've tried possible opcodes, but I'm still getting the same error and the same stack dump.

Does Android generally allow there instructions or is it something I'm doing that's wrong? Anything else I should be looking at to debug?

like image 866
Phonon Avatar asked Oct 07 '11 18:10

Phonon


1 Answers

It is indeed due to insufficient provileges. You cannot do that from user-mode, it causes an Undefined Instruction exception that gets translated into SIGILL/ILL_ILLOPC. grep -Hr PRVOPC <path-to-linux-kernel>/arch/arm yields nothing, while doing the same for ILLOPC will land you at do_undefinstr().

like image 178
ninjalj Avatar answered Nov 09 '22 01:11

ninjalj