← Documents Documentation/virt/kvm/arm/pvtime.rst GitHub 원문 ↗

Linux 6.18.37 · 가상화 / KVM / ARM

arm64 paravirtualized time

DEN0057/A hypercall과 vCPU별 little-endian stolen-time 구조의 mapping·갱신 계약을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

pvtime.rst:1-82

DEN0057/A hypercall과 vCPU별 little-endian stolen-time 구조의 mapping·갱신 계약을 설명합니다.

API 이름, register, function ID, source path와 error code는 원문 표기를 유지했습니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 Paravirtualized time support for arm64
4 ======================================
5
6 Arm specification DEN0057/A defines a standard for paravirtualised time
7 support for AArch64 guests:
8
9 https://developer.arm.com/docs/den0057/a
10
11 KVM/arm64 implements the stolen time part of this specification by providing
12 some hypervisor service calls to support a paravirtualized guest obtaining a
13 view of the amount of time stolen from its execution.
14
15 Two new SMCCC compatible hypercalls are defined:
16
17 * PV_TIME_FEATURES: 0xC5000020
18 * PV_TIME_ST: 0xC5000021
19
20 These are only available in the SMC64/HVC64 calling convention as
21 paravirtualized time is not available to 32 bit Arm guests. The existence of
22 the PV_TIME_FEATURES hypercall should be probed using the SMCCC 1.1
23 ARCH_FEATURES mechanism before calling it.
24
25 PV_TIME_FEATURES
26
27 ============= ======== =================================================
28 Function ID: (uint32) 0xC5000020
29 PV_call_id: (uint32) The function to query for support.
30 Currently only PV_TIME_ST is supported.
31 Return value: (int64) NOT_SUPPORTED (-1) or SUCCESS (0) if the relevant
32 PV-time feature is supported by the hypervisor.
33 ============= ======== =================================================
34
35 PV_TIME_ST
36
37 ============= ======== ==============================================
38 Function ID: (uint32) 0xC5000021
39 Return value: (int64) IPA of the stolen time data structure for this
40 VCPU. On failure:
41 NOT_SUPPORTED (-1)
42 ============= ======== ==============================================
43
44 The IPA returned by PV_TIME_ST should be mapped by the guest as normal memory
45 with inner and outer write back caching attributes, in the inner shareable
46 domain. A total of 16 bytes from the IPA returned are guaranteed to be
47 meaningfully filled by the hypervisor (see structure below).
48
49 PV_TIME_ST returns the structure for the calling VCPU.
50
51 Stolen Time
52 -----------
53
54 The structure pointed to by the PV_TIME_ST hypercall is as follows:
55
56 +-------------+-------------+-------------+----------------------------+
57 | Field | Byte Length | Byte Offset | Description |
58 +=============+=============+=============+============================+
59 | Revision | 4 | 0 | Must be 0 for version 1.0 |
60 +-------------+-------------+-------------+----------------------------+
61 | Attributes | 4 | 4 | Must be 0 |
62 +-------------+-------------+-------------+----------------------------+
63 | Stolen time | 8 | 8 | Stolen time in unsigned |
64 | | | | nanoseconds indicating how |
65 | | | | much time this VCPU thread |
66 | | | | was involuntarily not |
67 | | | | running on a physical CPU. |
68 +-------------+-------------+-------------+----------------------------+
69
70 All values in the structure are stored little-endian.
71
72 The structure will be updated by the hypervisor prior to scheduling a VCPU. It
73 will be present within a reserved region of the normal memory given to the
74 guest. The guest should not attempt to write into this memory. There is a
75 structure per VCPU of the guest.
76
77 It is advisable that one or more 64k pages are set aside for the purpose of
78 these structures and not used for other purposes, this enables the guest to map
79 the region using 64k pages and avoids conflicting attributes with other memory.
80
81 For the user space interface see
82 :ref:`Documentation/virt/kvm/devices/vcpu.rst <kvm_arm_vcpu_pvtime_ctrl>`.

3. 한국어 전문 번역

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

PV_TIME feature와 stolen-time IPA

1-50

Arm DEN0057/A는 AArch64 guest의 paravirtualized time 표준을 정의합니다. KVM/arm64는 guest vCPU가 physical CPU에서 강제로 실행되지 못한 시간을 확인할 수 있도록 stolen-time service call을 구현합니다.

`PV_TIME_FEATURES (0xC5000020)`와 `PV_TIME_ST (0xC5000021)`는 SMC64/HVC64 calling convention에서만 제공됩니다. 32-bit Arm guest에는 paravirtualized time이 없으며 guest는 호출 전에 SMCCC 1.1 `ARCH_FEATURES`로 `PV_TIME_FEATURES` 존재를 probe해야 합니다.

PV time hypercall
Call계약
`PV_TIME_FEATURES``PV_call_id`로 기능 조회. 현재 `PV_TIME_ST`만 지원하며 R0=`SUCCESS (0)` 또는 `NOT_SUPPORTED (-1)`
`PV_TIME_ST`호출 vCPU의 stolen-time 구조 IPA 반환. 실패 시 `NOT_SUPPORTED (-1)`

지원 여부를 확인한 뒤 호출 vCPU의 data-structure IPA를 얻습니다.

Guest는 `PV_TIME_ST`가 반환한 IPA를 inner-shareable domain의 inner·outer write-back cacheable normal memory로 mapping해야 합니다. Hypervisor는 반환 IPA부터 최소 16 byte를 의미 있는 값으로 채웁니다.

.. SPDX-License-Identifier: GPL-2.0

Paravirtualized time support for arm64
======================================

Arm specification DEN0057/A defines a standard for paravirtualised time
support for AArch64 guests:

https://developer.arm.com/docs/den0057/a

KVM/arm64 implements the stolen time part of this specification by providing
some hypervisor service calls to support a paravirtualized guest obtaining a
view of the amount of time stolen from its execution.

Two new SMCCC compatible hypercalls are defined:

* PV_TIME_FEATURES: 0xC5000020
* PV_TIME_ST:       0xC5000021

These are only available in the SMC64/HVC64 calling convention as
paravirtualized time is not available to 32 bit Arm guests. The existence of
the PV_TIME_FEATURES hypercall should be probed using the SMCCC 1.1
ARCH_FEATURES mechanism before calling it.

PV_TIME_FEATURES

    ============= ========    =================================================
    Function ID:  (uint32)    0xC5000020
    PV_call_id:   (uint32)    The function to query for support.
                              Currently only PV_TIME_ST is supported.
    Return value: (int64)     NOT_SUPPORTED (-1) or SUCCESS (0) if the relevant
                              PV-time feature is supported by the hypervisor.
    ============= ========    =================================================

PV_TIME_ST

    ============= ========    ==============================================
    Function ID:  (uint32)    0xC5000021
    Return value: (int64)     IPA of the stolen time data structure for this
                              VCPU. On failure:
                              NOT_SUPPORTED (-1)
    ============= ========    ==============================================

The IPA returned by PV_TIME_ST should be mapped by the guest as normal memory
with inner and outer write back caching attributes, in the inner shareable
domain. A total of 16 bytes from the IPA returned are guaranteed to be
meaningfully filled by the hypervisor (see structure below).

PV_TIME_ST returns the structure for the calling VCPU.

Stolen-time data structure

51-82
Stolen-time 구조
Field길이·offset의미
Revision4 byte, offset 0Version 1.0에서는 0
Attributes4 byte, offset 40이어야 함
Stolen time8 byte, offset 8이 vCPU thread가 physical CPU에서 비자발적으로 실행되지 못한 누적 unsigned nanoseconds

모든 field는 little-endian이며 구조는 guest vCPU마다 하나씩 존재합니다.

Hypervisor는 vCPU를 schedule하기 전에 구조를 갱신합니다. 구조는 guest에 제공된 normal memory의 reserved region 안에 있고 guest는 이 memory에 write하면 안 됩니다.

구조 전용으로 하나 이상의 64KiB page를 따로 확보하는 것이 권장됩니다. 그러면 guest가 region을 64KiB page로 mapping할 수 있고 다른 memory와 cache attribute가 충돌하는 일을 피할 수 있습니다.

Userspace 측 구성은 `Documentation/virt/kvm/devices/vcpu.rst`의 `KVM_ARM_VCPU_PVTIME_CTRL` interface를 따릅니다.

Stolen Time
-----------

The structure pointed to by the PV_TIME_ST hypercall is as follows:

+-------------+-------------+-------------+----------------------------+
| Field       | Byte Length | Byte Offset | Description                |
+=============+=============+=============+============================+
| Revision    |      4      |      0      | Must be 0 for version 1.0  |
+-------------+-------------+-------------+----------------------------+
| Attributes  |      4      |      4      | Must be 0                  |
+-------------+-------------+-------------+----------------------------+
| Stolen time |      8      |      8      | Stolen time in unsigned    |
|             |             |             | nanoseconds indicating how |
|             |             |             | much time this VCPU thread |
|             |             |             | was involuntarily not      |
|             |             |             | running on a physical CPU. |
+-------------+-------------+-------------+----------------------------+

All values in the structure are stored little-endian.

The structure will be updated by the hypervisor prior to scheduling a VCPU. It
will be present within a reserved region of the normal memory given to the
guest. The guest should not attempt to write into this memory. There is a
structure per VCPU of the guest.

It is advisable that one or more 64k pages are set aside for the purpose of
these structures and not used for other purposes, this enables the guest to map
the region using 64k pages and avoids conflicting attributes with other memory.

For the user space interface see
:ref:`Documentation/virt/kvm/devices/vcpu.rst <kvm_arm_vcpu_pvtime_ctrl>`.