Memory copy/set instructions (MOPS)

A MOPS memory copy/set operation consists of three consecutive CPY* or SET*instructions: a prologue, main and epilogue (for example: CPYP, CPYM, CPYE).

A main or epilogue instruction can take a MOPS exception for various reasons,for example when a task is migrated to a CPU with a different MOPSimplementation, or when the instruction’s alignment and size requirements arenot met. The software exception handler is then expected to reset the registersand restart execution from the prologue instruction. Normally this is handledby the kernel.

For more details refer to “D1.3.5.7 Memory Copy and Memory Set exceptions” inthe Arm Architecture Reference Manual DDI 0487K.a (Arm ARM).

Hypervisor requirements

A hypervisor running a Linux guest must handle all MOPS exceptions from theguest kernel, as Linux may not be able to handle the exception at all times.For example, a MOPS exception can be taken when the hypervisor migrates a vCPUto another physical CPU with a different MOPS implementation.

To do this, the hypervisor must:

  • Set HCRX_EL2.MCE2 to 1 so that the exception is taken to the hypervisor.

  • Have an exception handler that implements the algorithm from the Arm ARMrules CNTMJ and MWFQH.

  • Set the guest’s PSTATE.SS to 0 in the exception handler, to handle apotential step of the current instruction.

    Note: Clearing PSTATE.SS is needed so that a single step exception is takenon the next instruction (the prologue instruction). Otherwise prologuewould get silently stepped over and the single step exception taken on themain instruction. Note that if the guest instruction is not being steppedthen clearing PSTATE.SS has no effect.