← Documents Documentation/arch/riscv/hwprobe.rst GitHub 원문 ↗

Linux 6.18.37 · Architecture

RISC-V Hardware Probing Interface

CPU set 전체의 공통 RISC-V hardware capability를 조회하거나 조건에 맞는 CPU를 역으로 선택하는 userspace ABI입니다.

Source pathDocumentation/arch/riscv/hwprobe.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약과 해설

hwprobe.rst:1-372

`sys_riscv_hwprobe()`는 key-value pair와 CPU set을 함께 받아 identity value, base behavior, ISA·vendor extension bitmask, misaligned access 성능을 반환합니다. `RISCV_HWPROBE_WHICH_CPUS`는 같은 ABI를 역으로 사용해 요청 capability를 모두 만족하는 CPU set을 구합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 RISC-V Hardware Probing Interface
4 ---------------------------------
5
6 The RISC-V hardware probing interface is based around a single syscall, which
7 is defined in <asm/hwprobe.h>::
8
9 struct riscv_hwprobe {
10 __s64 key;
11 __u64 value;
12 };
13
14 long sys_riscv_hwprobe(struct riscv_hwprobe *pairs, size_t pair_count,
15 size_t cpusetsize, cpu_set_t *cpus,
16 unsigned int flags);
17
18 The arguments are split into three groups: an array of key-value pairs, a CPU
19 set, and some flags. The key-value pairs are supplied with a count. Userspace
20 must prepopulate the key field for each element, and the kernel will fill in the
21 value if the key is recognized. If a key is unknown to the kernel, its key field
22 will be cleared to -1, and its value set to 0. The CPU set is defined by
23 CPU_SET(3) with size ``cpusetsize`` bytes. For value-like keys (eg. vendor,
24 arch, impl), the returned value will only be valid if all CPUs in the given set
25 have the same value. Otherwise -1 will be returned. For boolean-like keys, the
26 value returned will be a logical AND of the values for the specified CPUs.
27 Usermode can supply NULL for ``cpus`` and 0 for ``cpusetsize`` as a shortcut for
28 all online CPUs. The currently supported flags are:
29
30 * :c:macro:`RISCV_HWPROBE_WHICH_CPUS`: This flag basically reverses the behavior
31 of sys_riscv_hwprobe(). Instead of populating the values of keys for a given
32 set of CPUs, the values of each key are given and the set of CPUs is reduced
33 by sys_riscv_hwprobe() to only those which match each of the key-value pairs.
34 How matching is done depends on the key type. For value-like keys, matching
35 means to be the exact same as the value. For boolean-like keys, matching
36 means the result of a logical AND of the pair's value with the CPU's value is
37 exactly the same as the pair's value. Additionally, when ``cpus`` is an empty
38 set, then it is initialized to all online CPUs which fit within it, i.e. the
39 CPU set returned is the reduction of all the online CPUs which can be
40 represented with a CPU set of size ``cpusetsize``.
41
42 All other flags are reserved for future compatibility and must be zero.
43
44 On success 0 is returned, on failure a negative error code is returned.
45
46 The following keys are defined:
47
48 * :c:macro:`RISCV_HWPROBE_KEY_MVENDORID`: Contains the value of ``mvendorid``,
49 as defined by the RISC-V privileged architecture specification.
50
51 * :c:macro:`RISCV_HWPROBE_KEY_MARCHID`: Contains the value of ``marchid``, as
52 defined by the RISC-V privileged architecture specification.
53
54 * :c:macro:`RISCV_HWPROBE_KEY_MIMPID`: Contains the value of ``mimpid``, as
55 defined by the RISC-V privileged architecture specification.
56
57 * :c:macro:`RISCV_HWPROBE_KEY_BASE_BEHAVIOR`: A bitmask containing the base
58 user-visible behavior that this kernel supports. The following base user ABIs
59 are defined:
60
61 * :c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: Support for rv32ima or
62 rv64ima, as defined by version 2.2 of the user ISA and version 1.10 of the
63 privileged ISA, with the following known exceptions (more exceptions may be
64 added, but only if it can be demonstrated that the user ABI is not broken):
65
66 * The ``fence.i`` instruction cannot be directly executed by userspace
67 programs (it may still be executed in userspace via a
68 kernel-controlled mechanism such as the vDSO).
69
70 * :c:macro:`RISCV_HWPROBE_KEY_IMA_EXT_0`: A bitmask containing the extensions
71 that are compatible with the :c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`:
72 base system behavior.
73
74 * :c:macro:`RISCV_HWPROBE_IMA_FD`: The F and D extensions are supported, as
75 defined by commit cd20cee ("FMIN/FMAX now implement
76 minimumNumber/maximumNumber, not minNum/maxNum") of the RISC-V ISA manual.
77
78 * :c:macro:`RISCV_HWPROBE_IMA_C`: The C extension is supported, as defined
79 by version 2.2 of the RISC-V ISA manual.
80
81 * :c:macro:`RISCV_HWPROBE_IMA_V`: The V extension is supported, as defined by
82 version 1.0 of the RISC-V Vector extension manual.
83
84 * :c:macro:`RISCV_HWPROBE_EXT_ZBA`: The Zba address generation extension is
85 supported, as defined in version 1.0 of the Bit-Manipulation ISA
86 extensions.
87
88 * :c:macro:`RISCV_HWPROBE_EXT_ZBB`: The Zbb extension is supported, as defined
89 in version 1.0 of the Bit-Manipulation ISA extensions.
90
91 * :c:macro:`RISCV_HWPROBE_EXT_ZBS`: The Zbs extension is supported, as defined
92 in version 1.0 of the Bit-Manipulation ISA extensions.
93
94 * :c:macro:`RISCV_HWPROBE_EXT_ZICBOZ`: The Zicboz extension is supported, as
95 ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs.
96
97 * :c:macro:`RISCV_HWPROBE_EXT_ZBC` The Zbc extension is supported, as defined
98 in version 1.0 of the Bit-Manipulation ISA extensions.
99
100 * :c:macro:`RISCV_HWPROBE_EXT_ZBKB` The Zbkb extension is supported, as
101 defined in version 1.0 of the Scalar Crypto ISA extensions.
102
103 * :c:macro:`RISCV_HWPROBE_EXT_ZBKC` The Zbkc extension is supported, as
104 defined in version 1.0 of the Scalar Crypto ISA extensions.
105
106 * :c:macro:`RISCV_HWPROBE_EXT_ZBKX` The Zbkx extension is supported, as
107 defined in version 1.0 of the Scalar Crypto ISA extensions.
108
109 * :c:macro:`RISCV_HWPROBE_EXT_ZKND` The Zknd extension is supported, as
110 defined in version 1.0 of the Scalar Crypto ISA extensions.
111
112 * :c:macro:`RISCV_HWPROBE_EXT_ZKNE` The Zkne extension is supported, as
113 defined in version 1.0 of the Scalar Crypto ISA extensions.
114
115 * :c:macro:`RISCV_HWPROBE_EXT_ZKNH` The Zknh extension is supported, as
116 defined in version 1.0 of the Scalar Crypto ISA extensions.
117
118 * :c:macro:`RISCV_HWPROBE_EXT_ZKSED` The Zksed extension is supported, as
119 defined in version 1.0 of the Scalar Crypto ISA extensions.
120
121 * :c:macro:`RISCV_HWPROBE_EXT_ZKSH` The Zksh extension is supported, as
122 defined in version 1.0 of the Scalar Crypto ISA extensions.
123
124 * :c:macro:`RISCV_HWPROBE_EXT_ZKT` The Zkt extension is supported, as defined
125 in version 1.0 of the Scalar Crypto ISA extensions.
126
127 * :c:macro:`RISCV_HWPROBE_EXT_ZVBB`: The Zvbb extension is supported as
128 defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
129
130 * :c:macro:`RISCV_HWPROBE_EXT_ZVBC`: The Zvbc extension is supported as
131 defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
132
133 * :c:macro:`RISCV_HWPROBE_EXT_ZVKB`: The Zvkb extension is supported as
134 defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
135
136 * :c:macro:`RISCV_HWPROBE_EXT_ZVKG`: The Zvkg extension is supported as
137 defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
138
139 * :c:macro:`RISCV_HWPROBE_EXT_ZVKNED`: The Zvkned extension is supported as
140 defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
141
142 * :c:macro:`RISCV_HWPROBE_EXT_ZVKNHA`: The Zvknha extension is supported as
143 defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
144
145 * :c:macro:`RISCV_HWPROBE_EXT_ZVKNHB`: The Zvknhb extension is supported as
146 defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
147
148 * :c:macro:`RISCV_HWPROBE_EXT_ZVKSED`: The Zvksed extension is supported as
149 defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
150
151 * :c:macro:`RISCV_HWPROBE_EXT_ZVKSH`: The Zvksh extension is supported as
152 defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
153
154 * :c:macro:`RISCV_HWPROBE_EXT_ZVKT`: The Zvkt extension is supported as
155 defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
156
157 * :c:macro:`RISCV_HWPROBE_EXT_ZFH`: The Zfh extension version 1.0 is supported
158 as defined in the RISC-V ISA manual.
159
160 * :c:macro:`RISCV_HWPROBE_EXT_ZFHMIN`: The Zfhmin extension version 1.0 is
161 supported as defined in the RISC-V ISA manual.
162
163 * :c:macro:`RISCV_HWPROBE_EXT_ZIHINTNTL`: The Zihintntl extension version 1.0
164 is supported as defined in the RISC-V ISA manual.
165
166 * :c:macro:`RISCV_HWPROBE_EXT_ZVFH`: The Zvfh extension is supported as
167 defined in the RISC-V Vector manual starting from commit e2ccd0548d6c
168 ("Remove draft warnings from Zvfh[min]").
169
170 * :c:macro:`RISCV_HWPROBE_EXT_ZVFHMIN`: The Zvfhmin extension is supported as
171 defined in the RISC-V Vector manual starting from commit e2ccd0548d6c
172 ("Remove draft warnings from Zvfh[min]").
173
174 * :c:macro:`RISCV_HWPROBE_EXT_ZFA`: The Zfa extension is supported as
175 defined in the RISC-V ISA manual starting from commit 056b6ff467c7
176 ("Zfa is ratified").
177
178 * :c:macro:`RISCV_HWPROBE_EXT_ZTSO`: The Ztso extension is supported as
179 defined in the RISC-V ISA manual starting from commit 5618fb5a216b
180 ("Ztso is now ratified.")
181
182 * :c:macro:`RISCV_HWPROBE_EXT_ZACAS`: The Zacas extension is supported as
183 defined in the Atomic Compare-and-Swap (CAS) instructions manual starting
184 from commit 5059e0ca641c ("update to ratified").
185
186 * :c:macro:`RISCV_HWPROBE_EXT_ZICNTR`: The Zicntr extension version 2.0
187 is supported as defined in the RISC-V ISA manual.
188
189 * :c:macro:`RISCV_HWPROBE_EXT_ZICOND`: The Zicond extension is supported as
190 defined in the RISC-V Integer Conditional (Zicond) operations extension
191 manual starting from commit 95cf1f9 ("Add changes requested by Ved
192 during signoff")
193
194 * :c:macro:`RISCV_HWPROBE_EXT_ZIHINTPAUSE`: The Zihintpause extension is
195 supported as defined in the RISC-V ISA manual starting from commit
196 d8ab5c78c207 ("Zihintpause is ratified").
197
198 * :c:macro:`RISCV_HWPROBE_EXT_ZIHPM`: The Zihpm extension version 2.0
199 is supported as defined in the RISC-V ISA manual.
200
201 * :c:macro:`RISCV_HWPROBE_EXT_ZVE32X`: The Vector sub-extension Zve32x is
202 supported, as defined by version 1.0 of the RISC-V Vector extension manual.
203
204 * :c:macro:`RISCV_HWPROBE_EXT_ZVE32F`: The Vector sub-extension Zve32f is
205 supported, as defined by version 1.0 of the RISC-V Vector extension manual.
206
207 * :c:macro:`RISCV_HWPROBE_EXT_ZVE64X`: The Vector sub-extension Zve64x is
208 supported, as defined by version 1.0 of the RISC-V Vector extension manual.
209
210 * :c:macro:`RISCV_HWPROBE_EXT_ZVE64F`: The Vector sub-extension Zve64f is
211 supported, as defined by version 1.0 of the RISC-V Vector extension manual.
212
213 * :c:macro:`RISCV_HWPROBE_EXT_ZVE64D`: The Vector sub-extension Zve64d is
214 supported, as defined by version 1.0 of the RISC-V Vector extension manual.
215
216 * :c:macro:`RISCV_HWPROBE_EXT_ZIMOP`: The Zimop May-Be-Operations extension is
217 supported as defined in the RISC-V ISA manual starting from commit
218 58220614a5f ("Zimop is ratified/1.0").
219
220 * :c:macro:`RISCV_HWPROBE_EXT_ZCA`: The Zca extension part of Zc* standard
221 extensions for code size reduction, as ratified in commit 8be3419c1c0
222 ("Zcf doesn't exist on RV64 as it contains no instructions") of
223 riscv-code-size-reduction.
224
225 * :c:macro:`RISCV_HWPROBE_EXT_ZCB`: The Zcb extension part of Zc* standard
226 extensions for code size reduction, as ratified in commit 8be3419c1c0
227 ("Zcf doesn't exist on RV64 as it contains no instructions") of
228 riscv-code-size-reduction.
229
230 * :c:macro:`RISCV_HWPROBE_EXT_ZCD`: The Zcd extension part of Zc* standard
231 extensions for code size reduction, as ratified in commit 8be3419c1c0
232 ("Zcf doesn't exist on RV64 as it contains no instructions") of
233 riscv-code-size-reduction.
234
235 * :c:macro:`RISCV_HWPROBE_EXT_ZCF`: The Zcf extension part of Zc* standard
236 extensions for code size reduction, as ratified in commit 8be3419c1c0
237 ("Zcf doesn't exist on RV64 as it contains no instructions") of
238 riscv-code-size-reduction.
239
240 * :c:macro:`RISCV_HWPROBE_EXT_ZCMOP`: The Zcmop May-Be-Operations extension is
241 supported as defined in the RISC-V ISA manual starting from commit
242 c732a4f39a4 ("Zcmop is ratified/1.0").
243
244 * :c:macro:`RISCV_HWPROBE_EXT_ZAWRS`: The Zawrs extension is supported as
245 ratified in commit 98918c844281 ("Merge pull request #1217 from
246 riscv/zawrs") of riscv-isa-manual.
247
248 * :c:macro:`RISCV_HWPROBE_EXT_ZAAMO`: The Zaamo extension is supported as
249 defined in the in the RISC-V ISA manual starting from commit e87412e621f1
250 ("integrate Zaamo and Zalrsc text (#1304)").
251
252 * :c:macro:`RISCV_HWPROBE_EXT_ZALRSC`: The Zalrsc extension is supported as
253 defined in the in the RISC-V ISA manual starting from commit e87412e621f1
254 ("integrate Zaamo and Zalrsc text (#1304)").
255
256 * :c:macro:`RISCV_HWPROBE_EXT_SUPM`: The Supm extension is supported as
257 defined in version 1.0 of the RISC-V Pointer Masking extensions.
258
259 * :c:macro:`RISCV_HWPROBE_EXT_ZFBFMIN`: The Zfbfmin extension is supported as
260 defined in the RISC-V ISA manual starting from commit 4dc23d6229de
261 ("Added Chapter title to BF16").
262
263 * :c:macro:`RISCV_HWPROBE_EXT_ZVFBFMIN`: The Zvfbfmin extension is supported as
264 defined in the RISC-V ISA manual starting from commit 4dc23d6229de
265 ("Added Chapter title to BF16").
266
267 * :c:macro:`RISCV_HWPROBE_EXT_ZVFBFWMA`: The Zvfbfwma extension is supported as
268 defined in the RISC-V ISA manual starting from commit 4dc23d6229de
269 ("Added Chapter title to BF16").
270
271 * :c:macro:`RISCV_HWPROBE_EXT_ZICBOM`: The Zicbom extension is supported, as
272 ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs.
273
274 * :c:macro:`RISCV_HWPROBE_EXT_ZABHA`: The Zabha extension is supported as
275 ratified in commit 49f49c842ff9 ("Update to Rafified state") of
276 riscv-zabha.
277
278 * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: Deprecated. Returns similar values to
279 :c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`, but the key was
280 mistakenly classified as a bitmask rather than a value.
281
282 * :c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`: An enum value describing
283 the performance of misaligned scalar native word accesses on the selected set
284 of processors.
285
286 * :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN`: The performance of
287 misaligned scalar accesses is unknown.
288
289 * :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED`: Misaligned scalar
290 accesses are emulated via software, either in or below the kernel. These
291 accesses are always extremely slow.
292
293 * :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_SLOW`: Misaligned scalar native
294 word sized accesses are slower than the equivalent quantity of byte
295 accesses. Misaligned accesses may be supported directly in hardware, or
296 trapped and emulated by software.
297
298 * :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_FAST`: Misaligned scalar native
299 word sized accesses are faster than the equivalent quantity of byte
300 accesses.
301
302 * :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_UNSUPPORTED`: Misaligned scalar
303 accesses are not supported at all and will generate a misaligned address
304 fault.
305
306 * :c:macro:`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`: An unsigned int which
307 represents the size of the Zicboz block in bytes.
308
309 * :c:macro:`RISCV_HWPROBE_KEY_HIGHEST_VIRT_ADDRESS`: An unsigned long which
310 represent the highest userspace virtual address usable.
311
312 * :c:macro:`RISCV_HWPROBE_KEY_TIME_CSR_FREQ`: Frequency (in Hz) of `time CSR`.
313
314 * :c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_VECTOR_PERF`: An enum value describing the
315 performance of misaligned vector accesses on the selected set of processors.
316
317 * :c:macro:`RISCV_HWPROBE_MISALIGNED_VECTOR_UNKNOWN`: The performance of misaligned
318 vector accesses is unknown.
319
320 * :c:macro:`RISCV_HWPROBE_MISALIGNED_VECTOR_SLOW`: 32-bit misaligned accesses using vector
321 registers are slower than the equivalent quantity of byte accesses via vector registers.
322 Misaligned accesses may be supported directly in hardware, or trapped and emulated by software.
323
324 * :c:macro:`RISCV_HWPROBE_MISALIGNED_VECTOR_FAST`: 32-bit misaligned accesses using vector
325 registers are faster than the equivalent quantity of byte accesses via vector registers.
326
327 * :c:macro:`RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED`: Misaligned vector accesses are
328 not supported at all and will generate a misaligned address fault.
329
330 * :c:macro:`RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0`: A bitmask containing the
331 mips vendor extensions that are compatible with the
332 :c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: base system behavior.
333
334 * MIPS
335
336 * :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL`: The xmipsexectl vendor
337 extension is supported in the MIPS ISA extensions spec.
338
339 * :c:macro:`RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0`: A bitmask containing the
340 thead vendor extensions that are compatible with the
341 :c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: base system behavior.
342
343 * T-HEAD
344
345 * :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XTHEADVECTOR`: The xtheadvector vendor
346 extension is supported in the T-Head ISA extensions spec starting from
347 commit a18c801634 ("Add T-Head VECTOR vendor extension. ").
348
349 * :c:macro:`RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE`: An unsigned int which
350 represents the size of the Zicbom block in bytes.
351
352 * :c:macro:`RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0`: A bitmask containing the
353 sifive vendor extensions that are compatible with the
354 :c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: base system behavior.
355
356 * SIFIVE
357
358 * :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCDOD`: The Xsfqmaccdod vendor
359 extension is supported in version 1.1 of SiFive Int8 Matrix Multiplication
360 Extensions Specification.
361
362 * :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCQOQ`: The Xsfqmaccqoq vendor
363 extension is supported in version 1.1 of SiFive Int8 Matrix Multiplication
364 Instruction Extensions Specification.
365
366 * :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVFNRCLIPXFQF`: The Xsfvfnrclipxfqf
367 vendor extension is supported in version 1.0 of SiFive FP32-to-int8 Ranged
368 Clip Instructions Extensions Specification.
369
370 * :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVFWMACCQQQ`: The Xsfvfwmaccqqq
371 vendor extension is supported in version 1.0 of Matrix Multiply Accumulate
372 Instruction Extensions Specification.

3. 한국어 전문 번역

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

Hardware probing syscall

1-17

RISC-V hardware probing interface는 `<asm/hwprobe.h>`에 정의된 단일 syscall을 중심으로 구성됩니다. `riscv_hwprobe` pair는 signed 64-bit `key`와 unsigned 64-bit `value`를 담습니다.

struct riscv_hwprobe {
    __s64 key;
    __u64 value;
};

long sys_riscv_hwprobe(struct riscv_hwprobe *pairs, size_t pair_count,
                       size_t cpusetsize, cpu_set_t *cpus,
                       unsigned int flags);

Pair와 CPU set semantics

18-29

Argument는 key-value pair array, CPU set, flags 세 그룹입니다. Userspace는 `pair_count`만큼의 element에서 `key`를 미리 채우고 kernel은 인식한 key의 `value`를 채웁니다. Kernel이 모르는 key는 `key=-1`, `value=0`으로 바뀝니다.

CPU set은 `CPU_SET(3)` 형식이며 `cpusetsize` byte입니다. Vendor·architecture·implementation 같은 value-like key는 지정된 모든 CPU가 같은 값을 가질 때만 유효하고 그렇지 않으면 `-1`을 반환합니다. Boolean-like key는 지정 CPU 값의 logical AND를 반환합니다.

Userspace가 `cpus=NULL`, `cpusetsize=0`을 전달하면 모든 online CPU를 뜻하는 shortcut입니다.

hwprobe value query
Userspace key arrayCPU set`sys_riscv_hwprobe()`
Value-like key모든 CPU 값 비교같으면 value, 다르면 -1
Boolean-like keyCPU별 bitmaskLogical AND

미리 채운 key와 CPU set을 kernel이 공통 value로 변환합니다.

RISCV_HWPROBE_WHICH_CPUS

30-45

`RISCV_HWPROBE_WHICH_CPUS`는 `sys_riscv_hwprobe()`의 동작을 뒤집습니다. CPU set에서 key value를 조회하는 대신 userspace가 key-value pair를 주고, syscall은 모든 pair와 일치하는 CPU만 남기도록 set을 축소합니다.

Value-like key는 정확히 같은 값이어야 합니다. Boolean-like key는 pair value와 CPU value를 AND한 결과가 pair value와 정확히 같아야 하므로 요청한 bit가 모두 존재해야 합니다.

`cpus`가 empty set이면 `cpusetsize`로 표현할 수 있는 모든 online CPU로 초기화한 뒤 조건에 맞는 CPU만 반환합니다. 그 밖의 flag는 future compatibility를 위해 reserved이며 반드시 0이어야 합니다.

성공하면 0, 실패하면 negative error code를 반환합니다.

WHICH_CPUS reverse query
Requested key-value pairsInput CPU set 또는 empty set
Exact value matchRequested boolean bits 포함
Reduced matching CPU set

원하는 capability를 만족하는 CPU set을 얻는 역방향 query입니다.

Identity와 base behavior key

46-69
Macro반환 의미
`RISCV_HWPROBE_KEY_MVENDORID`RISC-V privileged architecture specification의 `mvendorid` 값
`RISCV_HWPROBE_KEY_MARCHID`RISC-V privileged architecture specification의 `marchid` 값
`RISCV_HWPROBE_KEY_MIMPID`RISC-V privileged architecture specification의 `mimpid` 값
`RISCV_HWPROBE_KEY_BASE_BEHAVIOR`Kernel이 지원하는 기본 userspace-visible behavior bitmask
`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`User ISA 2.2와 privileged ISA 1.10의 rv32ima/rv64ima ABI
`RISCV_HWPROBE_KEY_IMA_EXT_0``RISCV_HWPROBE_BASE_BEHAVIOR_IMA`와 호환되는 extension bitmask

`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`는 user ISA version 2.2와 privileged ISA version 1.10의 rv32ima 또는 rv64ima를 지원합니다. User ABI를 깨지 않는다고 입증되는 예외는 추가될 수 있습니다.

현재 알려진 예외로 userspace program은 `fence.i` instruction을 직접 실행할 수 없습니다. 다만 vDSO 같은 kernel-controlled mechanism을 통해 userspace에서 실행할 수는 있습니다.

IMA·bit-manipulation·scalar crypto extensions

70-125

`RISCV_HWPROBE_KEY_IMA_EXT_0` bitmask의 다음 bit들은 IMA base behavior와 호환되는 floating-point, compressed, vector, bit-manipulation, scalar-cryptography extension 지원을 나타냅니다.

MacroExtension기준 specification
`RISCV_HWPROBE_IMA_FD`F/DRISC-V ISA manual commit `cd20cee` (`FMIN/FMAX now implement minimumNumber/maximumNumber, not minNum/maxNum`)
`RISCV_HWPROBE_IMA_C`CRISC-V ISA manual version 2.2
`RISCV_HWPROBE_IMA_V`VRISC-V Vector extension manual version 1.0
`RISCV_HWPROBE_EXT_ZBA`ZbaBit-Manipulation ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZBB`ZbbBit-Manipulation ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZBS`ZbsBit-Manipulation ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZICBOZ`Zicbozriscv-CMOs commit `3dd606f` (`Create cmobase-v1.0.pdf`)
`RISCV_HWPROBE_EXT_ZBC`ZbcBit-Manipulation ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZBKB`ZbkbScalar Crypto ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZBKC`ZbkcScalar Crypto ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZBKX`ZbkxScalar Crypto ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZKND`ZkndScalar Crypto ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZKNE`ZkneScalar Crypto ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZKNH`ZknhScalar Crypto ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZKSED`ZksedScalar Crypto ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZKSH`ZkshScalar Crypto ISA extensions version 1.0
`RISCV_HWPROBE_EXT_ZKT`ZktScalar Crypto ISA extensions version 1.0

Vector crypto와 floating-point extensions

126-180

다음 bit들은 vector cryptography, half-precision floating point, non-temporal locality hint, additional floating-point, total-store-order extension 지원을 나타냅니다.

MacroExtension기준 specification
`RISCV_HWPROBE_EXT_ZVBB`ZvbbRISC-V Cryptography Extensions Volume II version 1.0
`RISCV_HWPROBE_EXT_ZVBC`ZvbcRISC-V Cryptography Extensions Volume II version 1.0
`RISCV_HWPROBE_EXT_ZVKB`ZvkbRISC-V Cryptography Extensions Volume II version 1.0
`RISCV_HWPROBE_EXT_ZVKG`ZvkgRISC-V Cryptography Extensions Volume II version 1.0
`RISCV_HWPROBE_EXT_ZVKNED`ZvknedRISC-V Cryptography Extensions Volume II version 1.0
`RISCV_HWPROBE_EXT_ZVKNHA`ZvknhaRISC-V Cryptography Extensions Volume II version 1.0
`RISCV_HWPROBE_EXT_ZVKNHB`ZvknhbRISC-V Cryptography Extensions Volume II version 1.0
`RISCV_HWPROBE_EXT_ZVKSED`ZvksedRISC-V Cryptography Extensions Volume II version 1.0
`RISCV_HWPROBE_EXT_ZVKSH`ZvkshRISC-V Cryptography Extensions Volume II version 1.0
`RISCV_HWPROBE_EXT_ZVKT`ZvktRISC-V Cryptography Extensions Volume II version 1.0
`RISCV_HWPROBE_EXT_ZFH`ZfhRISC-V ISA manual version 1.0
`RISCV_HWPROBE_EXT_ZFHMIN`ZfhminRISC-V ISA manual version 1.0
`RISCV_HWPROBE_EXT_ZIHINTNTL`ZihintntlRISC-V ISA manual version 1.0
`RISCV_HWPROBE_EXT_ZVFH`ZvfhRISC-V Vector manual commit `e2ccd0548d6c` (`Remove draft warnings from Zvfh[min]`)
`RISCV_HWPROBE_EXT_ZVFHMIN`ZvfhminRISC-V Vector manual commit `e2ccd0548d6c` (`Remove draft warnings from Zvfh[min]`)
`RISCV_HWPROBE_EXT_ZFA`ZfaRISC-V ISA manual commit `056b6ff467c7` (`Zfa is ratified`)
`RISCV_HWPROBE_EXT_ZTSO`ZtsoRISC-V ISA manual commit `5618fb5a216b` (`Ztso is now ratified.`)

Atomic·counter·vector subset·code-size extensions

181-238

다음 bit들은 compare-and-swap, counter, conditional operation, pause hint, performance monitor, embedded vector subset, may-be-operation, Zc* code-size-reduction extension 지원을 나타냅니다.

MacroExtension기준 specification
`RISCV_HWPROBE_EXT_ZACAS`ZacasAtomic Compare-and-Swap manual commit `5059e0ca641c` (`update to ratified`)
`RISCV_HWPROBE_EXT_ZICNTR`ZicntrRISC-V ISA manual version 2.0
`RISCV_HWPROBE_EXT_ZICOND`ZicondInteger Conditional operations manual commit `95cf1f9` (`Add changes requested by Ved during signoff`)
`RISCV_HWPROBE_EXT_ZIHINTPAUSE`ZihintpauseRISC-V ISA manual commit `d8ab5c78c207` (`Zihintpause is ratified`)
`RISCV_HWPROBE_EXT_ZIHPM`ZihpmRISC-V ISA manual version 2.0
`RISCV_HWPROBE_EXT_ZVE32X`Zve32xRISC-V Vector extension manual version 1.0
`RISCV_HWPROBE_EXT_ZVE32F`Zve32fRISC-V Vector extension manual version 1.0
`RISCV_HWPROBE_EXT_ZVE64X`Zve64xRISC-V Vector extension manual version 1.0
`RISCV_HWPROBE_EXT_ZVE64F`Zve64fRISC-V Vector extension manual version 1.0
`RISCV_HWPROBE_EXT_ZVE64D`Zve64dRISC-V Vector extension manual version 1.0
`RISCV_HWPROBE_EXT_ZIMOP`ZimopRISC-V ISA manual commit `58220614a5f` (`Zimop is ratified/1.0`)
`RISCV_HWPROBE_EXT_ZCA`Zcariscv-code-size-reduction commit `8be3419c1c0` (`Zcf doesn't exist on RV64 as it contains no instructions`)
`RISCV_HWPROBE_EXT_ZCB`Zcbriscv-code-size-reduction commit `8be3419c1c0` (`Zcf doesn't exist on RV64 as it contains no instructions`)
`RISCV_HWPROBE_EXT_ZCD`Zcdriscv-code-size-reduction commit `8be3419c1c0` (`Zcf doesn't exist on RV64 as it contains no instructions`)
`RISCV_HWPROBE_EXT_ZCF`Zcfriscv-code-size-reduction commit `8be3419c1c0` (`Zcf doesn't exist on RV64 as it contains no instructions`)

추가 ratified extensions

239-277

다음 bit들은 Zcmop, wait-on-reservation-set, split atomic, pointer masking, bfloat16, cache-block management, byte/halfword atomic extension 지원을 나타냅니다.

MacroExtension기준 specification
`RISCV_HWPROBE_EXT_ZCMOP`ZcmopRISC-V ISA manual commit `c732a4f39a4` (`Zcmop is ratified/1.0`)
`RISCV_HWPROBE_EXT_ZAWRS`Zawrsriscv-isa-manual commit `98918c844281` (`Merge pull request #1217 from riscv/zawrs`)
`RISCV_HWPROBE_EXT_ZAAMO`ZaamoRISC-V ISA manual commit `e87412e621f1` (`integrate Zaamo and Zalrsc text (#1304)`)
`RISCV_HWPROBE_EXT_ZALRSC`ZalrscRISC-V ISA manual commit `e87412e621f1` (`integrate Zaamo and Zalrsc text (#1304)`)
`RISCV_HWPROBE_EXT_SUPM`SupmRISC-V Pointer Masking extensions version 1.0
`RISCV_HWPROBE_EXT_ZFBFMIN`ZfbfminRISC-V ISA manual commit `4dc23d6229de` (`Added Chapter title to BF16`)
`RISCV_HWPROBE_EXT_ZVFBFMIN`ZvfbfminRISC-V ISA manual commit `4dc23d6229de` (`Added Chapter title to BF16`)
`RISCV_HWPROBE_EXT_ZVFBFWMA`ZvfbfwmaRISC-V ISA manual commit `4dc23d6229de` (`Added Chapter title to BF16`)
`RISCV_HWPROBE_EXT_ZICBOM`Zicbomriscv-CMOs commit `3dd606f` (`Create cmobase-v1.0.pdf`)
`RISCV_HWPROBE_EXT_ZABHA`Zabhariscv-zabha commit `49f49c842ff9` (`Update to Rafified state`)

Misaligned scalar performance

278-304

`RISCV_HWPROBE_KEY_CPUPERF_0`은 deprecated입니다. `RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`와 비슷한 값을 반환하지만 value가 아니라 bitmask로 잘못 분류되었습니다.

`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`는 선택한 processor set에서 native word 크기 misaligned scalar access의 성능을 설명하는 enum입니다.

Enum의미
`RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN`Misaligned scalar access 성능을 알 수 없음
`RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED`Kernel 내부 또는 하위 layer의 software emulation이며 항상 매우 느림
`RISCV_HWPROBE_MISALIGNED_SCALAR_SLOW`Native word access가 같은 양의 byte access보다 느림. Hardware 처리 또는 trap/emulation일 수 있음
`RISCV_HWPROBE_MISALIGNED_SCALAR_FAST`Native word access가 같은 양의 byte access보다 빠름
`RISCV_HWPROBE_MISALIGNED_SCALAR_UNSUPPORTED`지원하지 않으며 misaligned address fault 발생

Block size, address, time과 vector performance

305-329
Key반환 의미
`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`Byte 단위 Zicboz block size를 나타내는 unsigned int
`RISCV_HWPROBE_KEY_HIGHEST_VIRT_ADDRESS`Userspace가 사용할 수 있는 가장 높은 virtual address를 나타내는 unsigned long
`RISCV_HWPROBE_KEY_TIME_CSR_FREQ``time CSR` frequency, 단위 Hz
`RISCV_HWPROBE_KEY_MISALIGNED_VECTOR_PERF`선택한 processor set의 misaligned vector access 성능 enum

`RISCV_HWPROBE_KEY_MISALIGNED_VECTOR_PERF`는 선택한 processor set의 misaligned vector access 성능을 다음 enum으로 분류합니다. Slow와 fast 비교는 vector register를 통한 32-bit misaligned access와 같은 양의 vector byte access를 기준으로 합니다. Slow는 hardware 지원 또는 trap/software emulation일 수 있습니다.

Enum의미
`RISCV_HWPROBE_MISALIGNED_VECTOR_UNKNOWN`Misaligned vector access 성능을 알 수 없음
`RISCV_HWPROBE_MISALIGNED_VECTOR_SLOW`Vector register의 32-bit misaligned access가 같은 양의 vector byte access보다 느림
`RISCV_HWPROBE_MISALIGNED_VECTOR_FAST`Vector register의 32-bit misaligned access가 같은 양의 vector byte access보다 빠름
`RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED`지원하지 않으며 misaligned address fault 발생
Misaligned access performance classes
UNKNOWN성능 미확인
EMULATED 또는 SLOWSoftware emulation 또는 byte access보다 느림
FASTByte access보다 빠름
UNSUPPORTEDMisaligned address fault

Scalar와 vector key가 공통적으로 제공하는 성능 분류입니다.

Vendor extensions와 Zicbom block size

330-372

`RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0`, `RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0`, `RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0`은 각각 IMA base behavior와 호환되는 vendor extension bitmask입니다.

MacroVendor지원 의미
`RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0`MIPS`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`와 호환되는 MIPS vendor-extension bitmask
`RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL`MIPSMIPS ISA extensions specification의 xmipsexectl
`RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0`T-HEAD`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`와 호환되는 T-HEAD vendor-extension bitmask
`RISCV_HWPROBE_VENDOR_EXT_XTHEADVECTOR`T-HEADT-Head ISA extensions commit `a18c801634` (`Add T-Head VECTOR vendor extension. `)부터의 xtheadvector
`RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0`SiFive`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`와 호환되는 SiFive vendor-extension bitmask
`RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCDOD`SiFiveSiFive Int8 Matrix Multiplication Extensions Specification version 1.1의 Xsfqmaccdod
`RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCQOQ`SiFiveSiFive Int8 Matrix Multiplication Instruction Extensions Specification version 1.1의 Xsfqmaccqoq
`RISCV_HWPROBE_VENDOR_EXT_XSFVFNRCLIPXFQF`SiFiveSiFive FP32-to-int8 Ranged Clip Instructions Extensions Specification version 1.0의 Xsfvfnrclipxfqf
`RISCV_HWPROBE_VENDOR_EXT_XSFVFWMACCQQQ`SiFiveMatrix Multiply Accumulate Instruction Extensions Specification version 1.0의 Xsfvfwmaccqqq

`RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE`는 byte 단위 Zicbom block size를 반환하는 unsigned int입니다.