Skip to content

Commit 2cfdb79

Browse files
kristina-martsenkoctmarinas
authored andcommitted
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>
1 parent ce6b5ff commit 2cfdb79

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

Documentation/arch/arm64/booting.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ Before jumping into the kernel, the following conditions must be met:
385385

386386
- HCRX_EL2.MSCEn (bit 11) must be initialised to 0b1.
387387

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`.
390390

391391
For CPUs with the Extended Translation Control Register feature (FEAT_TCR2):
392392

Documentation/arch/arm64/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ARM64 Architecture
2020
legacy_instructions
2121
memory
2222
memory-tagging-extension
23+
mops
2324
perf
2425
pointer-authentication
2526
ptdump

Documentation/arch/arm64/mops.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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.

0 commit comments

Comments
 (0)