요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
===================================
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 MOPS
implementation, or when the instruction's alignment and size requirements are
not met. The software exception handler is then expected to reset the registers
and restart execution from the prologue instruction. Normally this is handled
by the kernel.
For more details refer to "D1.3.5.7 Memory Copy and Memory Set exceptions" in
the Arm Architecture Reference Manual DDI 0487K.a (Arm ARM).
.. _arm64_mops_hyp:
Hypervisor requirements
-----------------------
A hypervisor running a Linux guest must handle all MOPS exceptions from the
guest 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 vCPU
to 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 ARM
rules CNTMJ and MWFQH.
- Set the guest's PSTATE.SS to 0 in the exception handler, to handle a
potential step of the current instruction.
Note: Clearing PSTATE.SS is needed so that a single step exception is taken
on the next instruction (the prologue instruction). Otherwise prologue
would get silently stepped over and the single step exception taken on the
main instruction. Note that if the guest instruction is not being stepped
then clearing PSTATE.SS has no effect.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
MOPS 동작과 예외
1-21MOPS memory copy/set operation은 연속된 세 개의 `CPY*` 또는 `SET*` 명령으로 구성됩니다. 세 단계는 prologue, main, epilogue이며 `CPYP`, `CPYM`, `CPYE`가 한 예입니다.
Main 또는 epilogue 명령은 여러 이유로 MOPS exception을 일으킬 수 있습니다. Task가 서로 다른 MOPS 구현을 가진 CPU로 migration되거나 명령의 alignment와 size 요건을 만족하지 못하는 경우가 대표적입니다. Software exception handler는 register를 재설정하고 prologue 명령부터 실행을 다시 시작해야 하며, 보통 커널이 이를 처리합니다.
자세한 규칙은 Arm Architecture Reference Manual DDI 0487K.a(Arm ARM)의 `D1.3.5.7 Memory Copy and Memory Set exceptions`를 참조하십시오. Hypervisor 절의 Sphinx anchor는 `_arm64_mops_hyp`입니다.
Hypervisor 요구 사항
22-44Linux guest를 실행하는 hypervisor는 guest kernel에서 발생한 모든 MOPS exception을 처리해야 합니다. Linux가 모든 시점에 예외를 직접 처리할 수 있는 것은 아니기 때문입니다. 예를 들어 hypervisor가 vCPU를 다른 MOPS 구현의 physical CPU로 옮기면 예외가 발생할 수 있습니다.
- `HCRX_EL2.MCE2`를 `1`로 설정해 예외가 hypervisor로 전달되게 합니다.
- Arm ARM 규칙 `CNTMJ`와 `MWFQH`의 algorithm을 구현한 exception handler를 둡니다.
- 현재 명령의 잠재적인 single step을 올바르게 처리하도록 exception handler에서 guest의 `PSTATE.SS`를 `0`으로 설정합니다.
`PSTATE.SS`를 clear해야 다음 명령인 prologue에서 single-step exception이 발생합니다. Clear하지 않으면 prologue를 조용히 건너뛰고 main 명령에서 exception이 발생합니다. Guest 명령을 step 중이 아니라면 이 clear는 아무 효과도 내지 않습니다.
요약과 해설
mops.rst:1-44MOPS는 copy/set을 세 명령의 연속 operation으로 수행합니다. 중간에 CPU 구현이나 alignment 조건이 달라져 exception이 발생하면 register를 되돌리고 prologue부터 재실행해야 하므로, virtualization 환경에서는 hypervisor가 이 재시작 계약을 정확히 지켜야 합니다.
정상 경로와 exception 경로가 모두 prologue를 기준으로 정렬됩니다.
Guest kernel이 항상 직접 복구할 수 없으므로 EL2가 보장해야 하는 항목입니다.