← Documents Documentation/virt/kvm/loongarch/hypercalls.rst GitHub 원문 ↗

Linux 6.18.37 · 가상화 / KVM

LoongArch paravirtual interface

LoongArch KVM 탐지, HVCL 하이퍼콜 ABI와 최대 128개 목적지를 지원하는 PV IPI를 정의합니다.

Source pathDocumentation/virt/kvm/loongarch/hypercalls.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

hypercalls.rst:1-89

LoongArch KVM 탐지, HVCL 하이퍼콜 ABI와 최대 128개 목적지를 지원하는 PV IPI를 정의합니다.

원문 기호, 함수명, 경로, 레지스터와 줄 좌표를 유지하면서 동작 순서와 경쟁 조건을 한국어로 풀어 설명합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ===================================
4 The LoongArch paravirtual interface
5 ===================================
6
7 KVM hypercalls use the HVCL instruction with code 0x100 and the hypercall
8 number is put in a0. Up to five arguments may be placed in registers a1 - a5.
9 The return value is placed in v0 (an alias of a0).
10
11 Source code for this interface can be found in arch/loongarch/kvm*.
12
13 Querying for existence
14 ======================
15
16 To determine if the host is running on KVM, we can utilize the cpucfg()
17 function at index CPUCFG_KVM_BASE (0x40000000).
18
19 The CPUCFG_KVM_BASE range, spanning from 0x40000000 to 0x400000FF, The
20 CPUCFG_KVM_BASE range between 0x40000000 - 0x400000FF is marked as reserved.
21 Consequently, all current and future processors will not implement any
22 feature within this range.
23
24 On a KVM-virtualized Linux system, a read operation on cpucfg() at index
25 CPUCFG_KVM_BASE (0x40000000) returns the magic string 'KVM\0'.
26
27 Once you have determined that your host is running on a paravirtualization-
28 capable KVM, you may now use hypercalls as described below.
29
30 KVM hypercall ABI
31 =================
32
33 The KVM hypercall ABI is simple, with one scratch register a0 (v0) and at most
34 five generic registers (a1 - a5) used as input parameters. The FP (Floating-
35 point) and vector registers are not utilized as input registers and must
36 remain unmodified during a hypercall.
37
38 Hypercall functions can be inlined as it only uses one scratch register.
39
40 The parameters are as follows:
41
42 ======== ================= ================
43 Register IN OUT
44 ======== ================= ================
45 a0 function number Return code
46 a1 1st parameter -
47 a2 2nd parameter -
48 a3 3rd parameter -
49 a4 4th parameter -
50 a5 5th parameter -
51 ======== ================= ================
52
53 The return codes may be one of the following:
54
55 ==== =========================
56 Code Meaning
57 ==== =========================
58 0 Success
59 -1 Hypercall not implemented
60 -2 Bad Hypercall parameter
61 ==== =========================
62
63 KVM Hypercalls Documentation
64 ============================
65
66 The template for each hypercall is as follows:
67
68 1. Hypercall name
69 2. Purpose
70
71 1. KVM_HCALL_FUNC_IPI
72 ------------------------
73
74 :Purpose: Send IPIs to multiple vCPUs.
75
76 - a0: KVM_HCALL_FUNC_IPI
77 - a1: Lower part of the bitmap for destination physical CPUIDs
78 - a2: Higher part of the bitmap for destination physical CPUIDs
79 - a3: The lowest physical CPUID in the bitmap
80
81 The hypercall lets a guest send multiple IPIs (Inter-Process Interrupts) with
82 at most 128 destinations per hypercall. The destinations are represented in a
83 bitmap contained in the first two input registers (a1 and a2).
84
85 Bit 0 of a1 corresponds to the physical CPUID in the third input register (a3)
86 and bit 1 corresponds to the physical CPUID in a3+1, and so on.
87
88 PV IPI on LoongArch includes both PV IPI multicast sending and PV IPI receiving,
89 and SWI is used for PV IPI inject since there is no VM-exits accessing SWI registers.
90

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

KVM 탐지와 호출 명령

1-36

LoongArch 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-70

ABI는 scratch 레지스터 `a0 (v0)` 하나와 일반 입력 레지스터 `a1`부터 `a5`까지를 사용합니다. 부동소수점과 벡터 레지스터는 입력으로 사용하지 않으며 하이퍼콜 동안 변경되어서도 안 됩니다. scratch 레지스터 하나만 쓰므로 호출 함수를 인라인할 수 있습니다.

LoongArch 하이퍼콜 레지스터
레지스터입력출력
`a0`함수 번호반환 코드(`v0` 별칭)
`a1`첫 번째 인자-
`a2`두 번째 인자-
`a3`세 번째 인자-
`a4`네 번째 인자-
`a5`다섯 번째 인자-

입력 인자와 반환 코드의 배치입니다.

하이퍼콜 반환 코드
코드의미
0성공
-1하이퍼콜이 구현되지 않음
-2잘못된 하이퍼콜 인자

모든 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입니다.

PV IPI 인자
레지스터
`a0``KVM_HCALL_FUNC_IPI`
`a1`목적지 물리 CPUID 비트맵 하위 부분
`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.