요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
===================================
The LoongArch paravirtual interface
===================================
KVM hypercalls use the HVCL instruction with code 0x100 and the hypercall
number is put in a0. Up to five arguments may be placed in registers a1 - a5.
The return value is placed in v0 (an alias of a0).
Source code for this interface can be found in arch/loongarch/kvm*.
Querying for existence
======================
To determine if the host is running on KVM, we can utilize the cpucfg()
function at index CPUCFG_KVM_BASE (0x40000000).
The CPUCFG_KVM_BASE range, spanning from 0x40000000 to 0x400000FF, The
CPUCFG_KVM_BASE range between 0x40000000 - 0x400000FF is marked as reserved.
Consequently, all current and future processors will not implement any
feature within this range.
On a KVM-virtualized Linux system, a read operation on cpucfg() at index
CPUCFG_KVM_BASE (0x40000000) returns the magic string 'KVM\0'.
Once you have determined that your host is running on a paravirtualization-
capable KVM, you may now use hypercalls as described below.
KVM hypercall ABI
=================
The KVM hypercall ABI is simple, with one scratch register a0 (v0) and at most
five generic registers (a1 - a5) used as input parameters. The FP (Floating-
point) and vector registers are not utilized as input registers and must
remain unmodified during a hypercall.
Hypercall functions can be inlined as it only uses one scratch register.
The parameters are as follows:
======== ================= ================
Register IN OUT
======== ================= ================
a0 function number Return code
a1 1st parameter -
a2 2nd parameter -
a3 3rd parameter -
a4 4th parameter -
a5 5th parameter -
======== ================= ================
The return codes may be one of the following:
==== =========================
Code Meaning
==== =========================
0 Success
-1 Hypercall not implemented
-2 Bad Hypercall parameter
==== =========================
KVM Hypercalls Documentation
============================
The template for each hypercall is as follows:
1. Hypercall name
2. Purpose
1. KVM_HCALL_FUNC_IPI
------------------------
:Purpose: Send IPIs to multiple vCPUs.
- a0: KVM_HCALL_FUNC_IPI
- a1: Lower part of the bitmap for destination physical CPUIDs
- a2: Higher part of the bitmap for destination physical CPUIDs
- a3: The lowest physical CPUID in the bitmap
The hypercall lets a guest send multiple IPIs (Inter-Process Interrupts) with
at most 128 destinations per hypercall. The destinations are represented in a
bitmap contained in the first two input registers (a1 and a2).
Bit 0 of a1 corresponds to the physical CPUID in the third input register (a3)
and bit 1 corresponds to the physical CPUID in a3+1, and so on.
PV IPI on LoongArch includes both PV IPI multicast sending and PV IPI receiving,
and SWI is used for PV IPI inject since there is no VM-exits accessing SWI registers.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
KVM 탐지와 호출 명령
1-36LoongArch KVM 하이퍼콜은 코드 `0x100`인 HVCL 명령을 사용합니다. 하이퍼콜 번호는 `a0`, 최대 다섯 인자는 `a1`부터 `a5`에 넣고 반환값은 `a0`의 별칭인 `v0`로 받습니다. 구현 소스는 `arch/loongarch/kvm*`에 있습니다.
호스트가 KVM인지 확인하려면 `cpucfg()`를 `CPUCFG_KVM_BASE (0x40000000)` 인덱스로 읽습니다. KVM에서 실행되는 Linux는 이 읽기에 매직 문자열 `'KVM '`을 반환합니다.
`0x40000000`부터 `0x400000FF`까지의 CPUCFG 범위는 예약되어 있어 현재와 미래 프로세서가 다른 기능을 구현하지 않습니다. 따라서 매직 값을 확인한 뒤에만 아래 하이퍼콜 ABI를 사용해야 합니다.
.. SPDX-License-Identifier: GPL-2.0
===================================
The LoongArch paravirtual interface
===================================
KVM hypercalls use the HVCL instruction with code 0x100 and the hypercall
number is put in a0. Up to five arguments may be placed in registers a1 - a5.
The return value is placed in v0 (an alias of a0).
Source code for this interface can be found in arch/loongarch/kvm*.
Querying for existence
======================
To determine if the host is running on KVM, we can utilize the cpucfg()
function at index CPUCFG_KVM_BASE (0x40000000).
The CPUCFG_KVM_BASE range, spanning from 0x40000000 to 0x400000FF, The
CPUCFG_KVM_BASE range between 0x40000000 - 0x400000FF is marked as reserved.
Consequently, all current and future processors will not implement any
feature within this range.
On a KVM-virtualized Linux system, a read operation on cpucfg() at index
CPUCFG_KVM_BASE (0x40000000) returns the magic string 'KVM\0'.
Once you have determined that your host is running on a paravirtualization-
capable KVM, you may now use hypercalls as described below.
KVM hypercall ABI
=================
The KVM hypercall ABI is simple, with one scratch register a0 (v0) and at most
five generic registers (a1 - a5) used as input parameters. The FP (Floating-
point) and vector registers are not utilized as input registers and must
remain unmodified during a hypercall.
KVM 하이퍼콜 ABI
37-70ABI는 scratch 레지스터 `a0 (v0)` 하나와 일반 입력 레지스터 `a1`부터 `a5`까지를 사용합니다. 부동소수점과 벡터 레지스터는 입력으로 사용하지 않으며 하이퍼콜 동안 변경되어서도 안 됩니다. scratch 레지스터 하나만 쓰므로 호출 함수를 인라인할 수 있습니다.
입력 인자와 반환 코드의 배치입니다.
모든 KVM 하이퍼콜이 사용하는 기본 결과입니다.
각 하이퍼콜 설명은 이름과 목적을 먼저 제시한 뒤 레지스터별 인자를 정의합니다.
Hypercall functions can be inlined as it only uses one scratch register.
The parameters are as follows:
======== ================= ================
Register IN OUT
======== ================= ================
a0 function number Return code
a1 1st parameter -
a2 2nd parameter -
a3 3rd parameter -
a4 4th parameter -
a5 5th parameter -
======== ================= ================
The return codes may be one of the following:
==== =========================
Code Meaning
==== =========================
0 Success
-1 Hypercall not implemented
-2 Bad Hypercall parameter
==== =========================
KVM Hypercalls Documentation
============================
The template for each hypercall is as follows:
1. Hypercall name
2. Purpose
KVM_HCALL_FUNC_IPI
71-89`KVM_HCALL_FUNC_IPI`는 여러 vCPU에 프로세서 간 인터럽트(IPI)를 보냅니다. `a1`과 `a2`는 목적지 물리 CPUID 비트맵의 하위와 상위 부분이고, `a3`는 비트맵에서 가장 낮은 물리 CPUID입니다.
한 호출에서 최대 128개 목적지를 표현합니다.
`a1`의 bit 0은 `a3`에 든 물리 CPUID, bit 1은 `a3+1`에 대응하며 이후 비트도 같은 방식으로 이어집니다. LoongArch PV IPI는 멀티캐스트 송신과 수신을 모두 포함합니다.
SWI 레지스터 접근은 VM exit를 만들지 않으므로 PV IPI 주입에는 SWI를 사용합니다.
1. KVM_HCALL_FUNC_IPI
------------------------
:Purpose: Send IPIs to multiple vCPUs.
- a0: KVM_HCALL_FUNC_IPI
- a1: Lower part of the bitmap for destination physical CPUIDs
- a2: Higher part of the bitmap for destination physical CPUIDs
- a3: The lowest physical CPUID in the bitmap
The hypercall lets a guest send multiple IPIs (Inter-Process Interrupts) with
at most 128 destinations per hypercall. The destinations are represented in a
bitmap contained in the first two input registers (a1 and a2).
Bit 0 of a1 corresponds to the physical CPUID in the third input register (a3)
and bit 1 corresponds to the physical CPUID in a3+1, and so on.
PV IPI on LoongArch includes both PV IPI multicast sending and PV IPI receiving,
and SWI is used for PV IPI inject since there is no VM-exits accessing SWI registers.
요약·해설
hypercalls.rst:1-89LoongArch KVM 탐지, HVCL 하이퍼콜 ABI와 최대 128개 목적지를 지원하는 PV IPI를 정의합니다.
원문 기호, 함수명, 경로, 레지스터와 줄 좌표를 유지하면서 동작 순서와 경쟁 조건을 한국어로 풀어 설명합니다.