← Documents Documentation/virt/kvm/arm/fw-pseudo-registers.rst GitHub 원문 ↗

Linux 6.18.37 · 가상화 / KVM / ARM

ARM firmware pseudo-register interface

PSCI version, SMCCC workaround와 hypercall feature bitmap을 migration 가능한 pseudo-register로 고정하는 ARM KVM interface입니다.

Source pathDocumentation/virt/kvm/arm/fw-pseudo-registers.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

fw-pseudo-registers.rst:1-151

PSCI version, SMCCC workaround와 hypercall feature bitmap을 migration 가능한 pseudo-register로 고정하는 ARM KVM interface입니다.

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

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 =======================================
4 ARM firmware pseudo-registers interface
5 =======================================
6
7 KVM handles the hypercall services as requested by the guests. New hypercall
8 services are regularly made available by the ARM specification or by KVM (as
9 vendor services) if they make sense from a virtualization point of view.
10
11 This means that a guest booted on two different versions of KVM can observe
12 two different "firmware" revisions. This could cause issues if a given guest
13 is tied to a particular version of a hypercall service, or if a migration
14 causes a different version to be exposed out of the blue to an unsuspecting
15 guest.
16
17 In order to remedy this situation, KVM exposes a set of "firmware
18 pseudo-registers" that can be manipulated using the GET/SET_ONE_REG
19 interface. These registers can be saved/restored by userspace, and set
20 to a convenient value as required.
21
22 The following registers are defined:
23
24 * KVM_REG_ARM_PSCI_VERSION:
25
26 KVM implements the PSCI (Power State Coordination Interface)
27 specification in order to provide services such as CPU on/off, reset
28 and power-off to the guest.
29
30 - Only valid if the vcpu has the KVM_ARM_VCPU_PSCI_0_2 feature set
31 (and thus has already been initialized)
32 - Returns the current PSCI version on GET_ONE_REG (defaulting to the
33 highest PSCI version implemented by KVM and compatible with v0.2)
34 - Allows any PSCI version implemented by KVM and compatible with
35 v0.2 to be set with SET_ONE_REG
36 - Affects the whole VM (even if the register view is per-vcpu)
37
38 * KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1:
39 Holds the state of the firmware support to mitigate CVE-2017-5715, as
40 offered by KVM to the guest via a HVC call. The workaround is described
41 under SMCCC_ARCH_WORKAROUND_1 in [1].
42
43 Accepted values are:
44
45 KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_AVAIL:
46 KVM does not offer
47 firmware support for the workaround. The mitigation status for the
48 guest is unknown.
49 KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_AVAIL:
50 The workaround HVC call is
51 available to the guest and required for the mitigation.
52 KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_REQUIRED:
53 The workaround HVC call
54 is available to the guest, but it is not needed on this VCPU.
55
56 * KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2:
57 Holds the state of the firmware support to mitigate CVE-2018-3639, as
58 offered by KVM to the guest via a HVC call. The workaround is described
59 under SMCCC_ARCH_WORKAROUND_2 in [1]_.
60
61 Accepted values are:
62
63 KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_AVAIL:
64 A workaround is not
65 available. KVM does not offer firmware support for the workaround.
66 KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN:
67 The workaround state is
68 unknown. KVM does not offer firmware support for the workaround.
69 KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_AVAIL:
70 The workaround is available,
71 and can be disabled by a vCPU. If
72 KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_ENABLED is set, it is active for
73 this vCPU.
74 KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED:
75 The workaround is always active on this vCPU or it is not needed.
76
77
78 Bitmap Feature Firmware Registers
79 ---------------------------------
80
81 Contrary to the above registers, the following registers exposes the
82 hypercall services in the form of a feature-bitmap to the userspace. This
83 bitmap is translated to the services that are available to the guest.
84 There is a register defined per service call owner and can be accessed via
85 GET/SET_ONE_REG interface.
86
87 By default, these registers are set with the upper limit of the features
88 that are supported. This way userspace can discover all the usable
89 hypercall services via GET_ONE_REG. The user-space can write-back the
90 desired bitmap back via SET_ONE_REG. The features for the registers that
91 are untouched, probably because userspace isn't aware of them, will be
92 exposed as is to the guest.
93
94 Note that KVM will not allow the userspace to configure the registers
95 anymore once any of the vCPUs has run at least once. Instead, it will
96 return a -EBUSY.
97
98 The pseudo-firmware bitmap register are as follows:
99
100 * KVM_REG_ARM_STD_BMAP:
101 Controls the bitmap of the ARM Standard Secure Service Calls.
102
103 The following bits are accepted:
104
105 Bit-0: KVM_REG_ARM_STD_BIT_TRNG_V1_0:
106 The bit represents the services offered under v1.0 of ARM True Random
107 Number Generator (TRNG) specification, ARM DEN0098.
108
109 * KVM_REG_ARM_STD_HYP_BMAP:
110 Controls the bitmap of the ARM Standard Hypervisor Service Calls.
111
112 The following bits are accepted:
113
114 Bit-0: KVM_REG_ARM_STD_HYP_BIT_PV_TIME:
115 The bit represents the Paravirtualized Time service as represented by
116 ARM DEN0057A.
117
118 * KVM_REG_ARM_VENDOR_HYP_BMAP:
119 Controls the bitmap of the Vendor specific Hypervisor Service Calls[0-63].
120
121 The following bits are accepted:
122
123 Bit-0: KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT
124 The bit represents the ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID
125 and ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID function-ids.
126
127 Bit-1: KVM_REG_ARM_VENDOR_HYP_BIT_PTP:
128 The bit represents the Precision Time Protocol KVM service.
129
130 * KVM_REG_ARM_VENDOR_HYP_BMAP_2:
131 Controls the bitmap of the Vendor specific Hypervisor Service Calls[64-127].
132
133 The following bits are accepted:
134
135 Bit-0: KVM_REG_ARM_VENDOR_HYP_BIT_DISCOVER_IMPL_VER
136 This represents the ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID
137 function-id. This is reset to 0.
138
139 Bit-1: KVM_REG_ARM_VENDOR_HYP_BIT_DISCOVER_IMPL_CPUS
140 This represents the ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_CPUS_FUNC_ID
141 function-id. This is reset to 0.
142
143 Errors:
144
145 ======= =============================================================
146 -ENOENT Unknown register accessed.
147 -EBUSY Attempt a 'write' to the register after the VM has started.
148 -EINVAL Invalid bitmap written to the register.
149 ======= =============================================================
150
151 .. [1] https://developer.arm.com/-/media/developer/pdf/ARM_DEN_0070A_Firmware_interfaces_for_mitigating_CVE-2017-5715.pdf
152

3. 한국어 전문 번역

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

Firmware revision과 PSCI·SMCCC workaround

1-77

KVM은 guest가 요청한 hypercall service를 처리합니다. ARM specification이나 virtualization 관점에서 유용한 KVM vendor service가 추가되면 서로 다른 KVM version에서 부팅한 guest가 서로 다른 firmware revision을 관찰할 수 있습니다.

특정 hypercall version에 의존하는 guest를 migration하면 destination에서 갑자기 다른 service version이 보일 수 있습니다. KVM은 이를 막기 위해 `GET_ONE_REG`와 `SET_ONE_REG`로 읽고 쓸 수 있는 firmware pseudo-register를 제공하며 userspace는 이 값을 migration state로 저장·복원할 수 있습니다.

`KVM_REG_ARM_PSCI_VERSION`은 CPU on/off, reset, power-off를 제공하는 PSCI version을 나타냅니다. `KVM_ARM_VCPU_PSCI_0_2` feature가 설정되고 vCPU가 초기화된 경우에만 유효합니다.

`GET_ONE_REG`의 기본값은 KVM이 구현하면서 PSCI v0.2와 호환되는 가장 높은 version입니다. `SET_ONE_REG`는 KVM이 구현한 v0.2 호환 version을 선택할 수 있으며 register view는 vCPU별이어도 효과는 VM 전체에 적용됩니다.

SMCCC speculation workaround pseudo-register
Register와 값의미
`KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_AVAIL`CVE-2017-5715 workaround firmware support를 제공하지 않으며 guest mitigation 상태는 unknown
`KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_AVAIL`Workaround HVC call을 제공하며 mitigation에 필요
`KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_REQUIRED`HVC call은 제공하지만 이 vCPU에서는 필요 없음
`KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_AVAIL`CVE-2018-3639 workaround를 사용할 수 없고 firmware support도 제공하지 않음
`KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN`Workaround 상태가 unknown이며 firmware support를 제공하지 않음
`KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_AVAIL`Workaround를 사용할 수 있고 vCPU가 disable 가능. `..._ENABLED`가 set이면 현재 활성
`KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED`항상 활성 상태이거나 이 vCPU에 필요 없음

Guest에 제공되는 firmware mitigation 상태를 고정해 migration 뒤에도 일관되게 노출합니다.

WORKAROUND_1은 CVE-2017-5715, WORKAROUND_2는 CVE-2018-3639를 완화하는 SMCCC firmware interface 상태입니다. Userspace는 host의 순간 상태를 재탐색해 guest ABI를 바꾸는 대신 pseudo-register 값을 migration해야 합니다.

.. SPDX-License-Identifier: GPL-2.0

=======================================
ARM firmware pseudo-registers interface
=======================================

KVM handles the hypercall services as requested by the guests. New hypercall
services are regularly made available by the ARM specification or by KVM (as
vendor services) if they make sense from a virtualization point of view.

This means that a guest booted on two different versions of KVM can observe
two different "firmware" revisions. This could cause issues if a given guest
is tied to a particular version of a hypercall service, or if a migration
causes a different version to be exposed out of the blue to an unsuspecting
guest.

In order to remedy this situation, KVM exposes a set of "firmware
pseudo-registers" that can be manipulated using the GET/SET_ONE_REG
interface. These registers can be saved/restored by userspace, and set
to a convenient value as required.

The following registers are defined:

* KVM_REG_ARM_PSCI_VERSION:

  KVM implements the PSCI (Power State Coordination Interface)
  specification in order to provide services such as CPU on/off, reset
  and power-off to the guest.

  - Only valid if the vcpu has the KVM_ARM_VCPU_PSCI_0_2 feature set
    (and thus has already been initialized)
  - Returns the current PSCI version on GET_ONE_REG (defaulting to the
    highest PSCI version implemented by KVM and compatible with v0.2)
  - Allows any PSCI version implemented by KVM and compatible with
    v0.2 to be set with SET_ONE_REG
  - Affects the whole VM (even if the register view is per-vcpu)

* KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1:
    Holds the state of the firmware support to mitigate CVE-2017-5715, as
    offered by KVM to the guest via a HVC call. The workaround is described
    under SMCCC_ARCH_WORKAROUND_1 in [1].

  Accepted values are:

    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_AVAIL:
      KVM does not offer
      firmware support for the workaround. The mitigation status for the
      guest is unknown.
    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_AVAIL:
      The workaround HVC call is
      available to the guest and required for the mitigation.
    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_REQUIRED:
      The workaround HVC call
      is available to the guest, but it is not needed on this VCPU.

* KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2:
    Holds the state of the firmware support to mitigate CVE-2018-3639, as
    offered by KVM to the guest via a HVC call. The workaround is described
    under SMCCC_ARCH_WORKAROUND_2 in [1]_.

  Accepted values are:

    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_AVAIL:
      A workaround is not
      available. KVM does not offer firmware support for the workaround.
    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN:
      The workaround state is
      unknown. KVM does not offer firmware support for the workaround.
    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_AVAIL:
      The workaround is available,
      and can be disabled by a vCPU. If
      KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_ENABLED is set, it is active for
      this vCPU.
    KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED:
      The workaround is always active on this vCPU or it is not needed.

Bitmap feature firmware register

78-151

Bitmap firmware register는 service-call owner별 hypercall 기능 집합을 userspace에 노출합니다. 기본값은 KVM이 지원하는 feature의 상한이므로 `GET_ONE_REG`로 사용 가능한 모든 service를 발견하고 `SET_ONE_REG`로 guest에 보여 줄 bitmap을 선택할 수 있습니다.

Userspace가 알지 못해 건드리지 않은 새 register는 기본 bitmap 그대로 guest에 노출됩니다. 하지만 VM의 어느 vCPU든 한 번 실행한 뒤에는 register를 다시 구성할 수 없으며 write 시 `-EBUSY`가 반환됩니다.

ARM firmware bitmap register
Register허용 bit
`KVM_REG_ARM_STD_BMAP`Bit 0 `KVM_REG_ARM_STD_BIT_TRNG_V1_0`: ARM DEN0098 TRNG v1.0 service
`KVM_REG_ARM_STD_HYP_BMAP`Bit 0 `KVM_REG_ARM_STD_HYP_BIT_PV_TIME`: ARM DEN0057A paravirtualized time service
`KVM_REG_ARM_VENDOR_HYP_BMAP`Bit 0 `...FUNC_FEAT`: KVM FEATURES와 Call UID function ID; bit 1 `...PTP`: KVM Precision Time Protocol service
`KVM_REG_ARM_VENDOR_HYP_BMAP_2`Bit 0 `...DISCOVER_IMPL_VER`, bit 1 `...DISCOVER_IMPL_CPUS`; 두 bit의 reset 값은 0

각 service-call owner의 지원 bit입니다.

Firmware bitmap 고정 순서
VM과 vCPU 초기화GET_ONE_REG로 지원 상한 조회Migration·machine type 정책에 맞게 bitmap 제한SET_ONE_REG로 선택값 기록첫 KVM_RUN 뒤 값 고정

VM 실행 전에 guest firmware ABI를 확정합니다.

Firmware bitmap error
Error조건
`-ENOENT`알 수 없는 register access
`-EBUSY`VM 시작 뒤 register write 시도
`-EINVAL`허용되지 않은 bitmap 기록

Register access 실패의 구체적 의미입니다.

Bitmap Feature Firmware Registers
---------------------------------

Contrary to the above registers, the following registers exposes the
hypercall services in the form of a feature-bitmap to the userspace. This
bitmap is translated to the services that are available to the guest.
There is a register defined per service call owner and can be accessed via
GET/SET_ONE_REG interface.

By default, these registers are set with the upper limit of the features
that are supported. This way userspace can discover all the usable
hypercall services via GET_ONE_REG. The user-space can write-back the
desired bitmap back via SET_ONE_REG. The features for the registers that
are untouched, probably because userspace isn't aware of them, will be
exposed as is to the guest.

Note that KVM will not allow the userspace to configure the registers
anymore once any of the vCPUs has run at least once. Instead, it will
return a -EBUSY.

The pseudo-firmware bitmap register are as follows:

* KVM_REG_ARM_STD_BMAP:
    Controls the bitmap of the ARM Standard Secure Service Calls.

  The following bits are accepted:

    Bit-0: KVM_REG_ARM_STD_BIT_TRNG_V1_0:
      The bit represents the services offered under v1.0 of ARM True Random
      Number Generator (TRNG) specification, ARM DEN0098.

* KVM_REG_ARM_STD_HYP_BMAP:
    Controls the bitmap of the ARM Standard Hypervisor Service Calls.

  The following bits are accepted:

    Bit-0: KVM_REG_ARM_STD_HYP_BIT_PV_TIME:
      The bit represents the Paravirtualized Time service as represented by
      ARM DEN0057A.

* KVM_REG_ARM_VENDOR_HYP_BMAP:
    Controls the bitmap of the Vendor specific Hypervisor Service Calls[0-63].

  The following bits are accepted:

    Bit-0: KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT
      The bit represents the ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID
      and ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID function-ids.

    Bit-1: KVM_REG_ARM_VENDOR_HYP_BIT_PTP:
      The bit represents the Precision Time Protocol KVM service.

* KVM_REG_ARM_VENDOR_HYP_BMAP_2:
    Controls the bitmap of the Vendor specific Hypervisor Service Calls[64-127].

  The following bits are accepted:

    Bit-0: KVM_REG_ARM_VENDOR_HYP_BIT_DISCOVER_IMPL_VER
      This represents the ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID
      function-id. This is reset to 0.

    Bit-1: KVM_REG_ARM_VENDOR_HYP_BIT_DISCOVER_IMPL_CPUS
      This represents the ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_CPUS_FUNC_ID
      function-id. This is reset to 0.

Errors:

    =======  =============================================================
    -ENOENT   Unknown register accessed.
    -EBUSY    Attempt a 'write' to the register after the VM has started.
    -EINVAL   Invalid bitmap written to the register.
    =======  =============================================================

.. [1] https://developer.arm.com/-/media/developer/pdf/ARM_DEN_0070A_Firmware_interfaces_for_mitigating_CVE-2017-5715.pdf