Search code examples
armmmu

Possible to set the ARM MMU to allow code execution, but not allow reading


I'd like to know if it's possible to set permissions on a page table entry for the ARM7 (Cortex A8 specifically) MMU such that code execution from the page is allowed, but reads are not allowed.

If the permissions are orthogonal you might think that if XN (execute never) is not set, that execution would be allowed regardless of if reading is allowed.

Of course, some ARM code reads from itself as it's executing (to get literals that are stored just beyond the end of the function for example), that code would be unlikely to work.

If the code you were trying to execute didn't do any reads from itself (more specifically, from the page with reading disabled), would the code execute as expected or would you get a data abort (or other) exception?


Solution

  • It would seem the answer is no.

    From ARM® Architecture Reference Manual ARMv7-A and ARMv7-R edition section B3.7.2

    A processor can execute instructions from a memory region only if the access permissions for its current state permit read access, and the XN bit is set to 0.