UPREDICTABLE instructions

Any idea about instructions marked as UNPREDICTABLE: can it then be UNDEFINED?

In other words: UNDEFINED REQUIRES the instruction to cause UND-exception, but

MAY UNPREDICTABLE do that, or does it have to execute normally except that the result may be whatever?

(I'm not yelling even if I used caps.)

I did as that same thing there Re: ARM/THUMB instructions that change execution path?

but I don't seem to get any answers. And this is probably more appropriate space anyway.

Parents
  • Hi turboscrew,

    This is defined pretty well in the documentation. From the ARMv7-A/R ARM:

    Means the behavior cannot be relied upon. UNPREDICTABLE behavior must not perform any function that cannot be

    performed at the current or a lower level of privilege using instructions that are not UNPREDICTABLE.

    UNPREDICTABLE behavior must not be documented or promoted as having a defined effect.

    An instruction that is UNPREDICTABLE can be implemented as UNDEFINED.

    ...

    Therefore the simple answer to your question is.. yes. Treating any UNPREDICTABLE instruction as UNDEFINED is a perfectly valid treatment. However it leaves implementation options open to do something else like silently place garbage result data into a register or do nothing at all.

    As an example, in the ARMv8 Architecture, any attempt to execute any code from a region marked as Device memory is UNPREDICTABLE. It is possible that this would be some kind of exception and the kind of exception would be similarly UNPREDICTABLE - perhaps an ESR_ELx.EC reporting unknown reason, or permissions fault, or an execution abort, and optionally set the ILLEGAL flag in the PSTATE, or none of those.

    It does turn out, however, that the Cortex-A53 and Cortex-A57 execute code just fine from Device memory. The moral is that you cannot and should never rely on the fact that just because one core does a very particular thing, that all other cores (or any other cores) will follow suit. This is all there to be sure that code written to the architectural specifications will port across implementations. In the example (and pretty much any other example I can think of), it would be considered a software development problem (i.e. programmer error) to map instruction memory with the Device memory type and less than sympathetic support.

    Ta,

    Matt Sealey

Reply
  • Hi turboscrew,

    This is defined pretty well in the documentation. From the ARMv7-A/R ARM:

    Means the behavior cannot be relied upon. UNPREDICTABLE behavior must not perform any function that cannot be

    performed at the current or a lower level of privilege using instructions that are not UNPREDICTABLE.

    UNPREDICTABLE behavior must not be documented or promoted as having a defined effect.

    An instruction that is UNPREDICTABLE can be implemented as UNDEFINED.

    ...

    Therefore the simple answer to your question is.. yes. Treating any UNPREDICTABLE instruction as UNDEFINED is a perfectly valid treatment. However it leaves implementation options open to do something else like silently place garbage result data into a register or do nothing at all.

    As an example, in the ARMv8 Architecture, any attempt to execute any code from a region marked as Device memory is UNPREDICTABLE. It is possible that this would be some kind of exception and the kind of exception would be similarly UNPREDICTABLE - perhaps an ESR_ELx.EC reporting unknown reason, or permissions fault, or an execution abort, and optionally set the ILLEGAL flag in the PSTATE, or none of those.

    It does turn out, however, that the Cortex-A53 and Cortex-A57 execute code just fine from Device memory. The moral is that you cannot and should never rely on the fact that just because one core does a very particular thing, that all other cores (or any other cores) will follow suit. This is all there to be sure that code written to the architectural specifications will port across implementations. In the example (and pretty much any other example I can think of), it would be considered a software development problem (i.e. programmer error) to map instruction memory with the Device memory type and less than sympathetic support.

    Ta,

    Matt Sealey

Children
More questions in this forum