Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: mops: Document requirements for hypervisors

Add a mops.rst document to clarify in more detail what hypervisors need
to do to run a Linux guest on a system with FEAT_MOPS.

Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com>
Link: https://lore.kernel.org/r/20241028185721.52852-1-kristina.martsenko@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Kristina Martsenko and committed by
Catalin Marinas
2cfdb799 ce6b5ff5

+47 -2
+2 -2
Documentation/arch/arm64/booting.rst
··· 385 385 386 386 - HCRX_EL2.MSCEn (bit 11) must be initialised to 0b1. 387 387 388 - - HCRX_EL2.MCE2 (bit 10) must be initialised to 0b1. The exception 389 - handler must set PSTATE.SS to 0b0. 388 + - HCRX_EL2.MCE2 (bit 10) must be initialised to 0b1 and the hypervisor 389 + must handle MOPS exceptions as described in :ref:`arm64_mops_hyp`. 390 390 391 391 For CPUs with the Extended Translation Control Register feature (FEAT_TCR2): 392 392
+1
Documentation/arch/arm64/index.rst
··· 20 20 legacy_instructions 21 21 memory 22 22 memory-tagging-extension 23 + mops 23 24 perf 24 25 pointer-authentication 25 26 ptdump
+44
Documentation/arch/arm64/mops.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + =================================== 4 + Memory copy/set instructions (MOPS) 5 + =================================== 6 + 7 + A MOPS memory copy/set operation consists of three consecutive CPY* or SET* 8 + instructions: a prologue, main and epilogue (for example: CPYP, CPYM, CPYE). 9 + 10 + A main or epilogue instruction can take a MOPS exception for various reasons, 11 + for example when a task is migrated to a CPU with a different MOPS 12 + implementation, or when the instruction's alignment and size requirements are 13 + not met. The software exception handler is then expected to reset the registers 14 + and restart execution from the prologue instruction. Normally this is handled 15 + by the kernel. 16 + 17 + For more details refer to "D1.3.5.7 Memory Copy and Memory Set exceptions" in 18 + the Arm Architecture Reference Manual DDI 0487K.a (Arm ARM). 19 + 20 + .. _arm64_mops_hyp: 21 + 22 + Hypervisor requirements 23 + ----------------------- 24 + 25 + A hypervisor running a Linux guest must handle all MOPS exceptions from the 26 + guest kernel, as Linux may not be able to handle the exception at all times. 27 + For example, a MOPS exception can be taken when the hypervisor migrates a vCPU 28 + to another physical CPU with a different MOPS implementation. 29 + 30 + To do this, the hypervisor must: 31 + 32 + - Set HCRX_EL2.MCE2 to 1 so that the exception is taken to the hypervisor. 33 + 34 + - Have an exception handler that implements the algorithm from the Arm ARM 35 + rules CNTMJ and MWFQH. 36 + 37 + - Set the guest's PSTATE.SS to 0 in the exception handler, to handle a 38 + potential step of the current instruction. 39 + 40 + Note: Clearing PSTATE.SS is needed so that a single step exception is taken 41 + on the next instruction (the prologue instruction). Otherwise prologue 42 + would get silently stepped over and the single step exception taken on the 43 + main instruction. Note that if the guest instruction is not being stepped 44 + then clearing PSTATE.SS has no effect.