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

Linux 6.18.37 · Architecture

RISC-V Linux User ABI

/proc/cpuinfo ISA ordering, misaligned access와 userspace pointer masking ABI입니다.

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

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

1. 요약·해설

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

요약과 해설

uabi.rst:1-86

ISA string은 single-letter, Z standard, supervisor, machine, X non-standard 순으로 정렬됩니다. `isa`와 `hart isa`는 공통 capability와 hart별 capability를 구분하며, pointer masking은 `PR_PMLEN` lower-bound contract로 제어됩니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 RISC-V Linux User ABI
4 =====================
5
6 ISA string ordering in /proc/cpuinfo
7 ------------------------------------
8
9 The canonical order of ISA extension names in the ISA string is defined in
10 chapter 27 of the unprivileged specification.
11 The specification uses vague wording, such as should, when it comes to ordering,
12 so for our purposes the following rules apply:
13
14 #. Single-letter extensions come first, in canonical order.
15 The canonical order is "IMAFDQLCBKJTPVH".
16
17 #. All multi-letter extensions will be separated from other extensions by an
18 underscore.
19
20 #. Additional standard extensions (starting with 'Z') will be sorted after
21 single-letter extensions and before any higher-privileged extensions.
22
23 #. For additional standard extensions, the first letter following the 'Z'
24 conventionally indicates the most closely related alphabetical
25 extension category. If multiple 'Z' extensions are named, they will be
26 ordered first by category, in canonical order, as listed above, then
27 alphabetically within a category.
28
29 #. Standard supervisor-level extensions (starting with 'S') will be listed
30 after standard unprivileged extensions. If multiple supervisor-level
31 extensions are listed, they will be ordered alphabetically.
32
33 #. Standard machine-level extensions (starting with 'Zxm') will be listed
34 after any lower-privileged, standard extensions. If multiple machine-level
35 extensions are listed, they will be ordered alphabetically.
36
37 #. Non-standard extensions (starting with 'X') will be listed after all standard
38 extensions. If multiple non-standard extensions are listed, they will be
39 ordered alphabetically.
40
41 An example string following the order is::
42
43 rv64imadc_zifoo_zigoo_zafoo_sbar_scar_zxmbaz_xqux_xrux
44
45 "isa" and "hart isa" lines in /proc/cpuinfo
46 -------------------------------------------
47
48 The "isa" line in /proc/cpuinfo describes the lowest common denominator of
49 RISC-V ISA extensions recognized by the kernel and implemented on all harts. The
50 "hart isa" line, in contrast, describes the set of extensions recognized by the
51 kernel on the particular hart being described, even if those extensions may not
52 be present on all harts in the system.
53
54 In both lines, the presence of an extension guarantees only that the hardware
55 has the described capability. Additional kernel support or policy changes may be
56 required before an extension's capability is fully usable by userspace programs.
57 Similarly, for S-mode extensions, presence in one of these lines does not
58 guarantee that the kernel is taking advantage of the extension, or that the
59 feature will be visible in guest VMs managed by this kernel.
60
61 Inversely, the absence of an extension in these lines does not necessarily mean
62 the hardware does not support that feature. The running kernel may not recognize
63 the extension, or may have deliberately removed it from the listing.
64
65 Misaligned accesses
66 -------------------
67
68 Misaligned scalar accesses are supported in userspace, but they may perform
69 poorly. Misaligned vector accesses are only supported if the Zicclsm extension
70 is supported.
71
72 Pointer masking
73 ---------------
74
75 Support for pointer masking in userspace (the Supm extension) is provided via
76 the ``PR_SET_TAGGED_ADDR_CTRL`` and ``PR_GET_TAGGED_ADDR_CTRL`` ``prctl()``
77 operations. Pointer masking is disabled by default. To enable it, userspace
78 must call ``PR_SET_TAGGED_ADDR_CTRL`` with the ``PR_PMLEN`` field set to the
79 number of mask/tag bits needed by the application. ``PR_PMLEN`` is interpreted
80 as a lower bound; if the kernel is unable to satisfy the request, the
81 ``PR_SET_TAGGED_ADDR_CTRL`` operation will fail. The actual number of tag bits
82 is returned in ``PR_PMLEN`` by the ``PR_GET_TAGGED_ADDR_CTRL`` operation.
83
84 Additionally, when pointer masking is enabled (``PR_PMLEN`` is greater than 0),
85 a tagged address ABI is supported, with the same interface and behavior as
86 documented for AArch64 (Documentation/arch/arm64/tagged-address-abi.rst).
87

3. 한국어 전문 번역

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

/proc/cpuinfo ISA string ordering

1-12

RISC-V Linux User ABI에서 ISA string의 canonical extension-name 순서는 unprivileged specification chapter 27이 정의합니다. Specification의 `should` 같은 표현이 모호하므로 Linux는 다음 규칙을 적용합니다.

Canonical ordering 규칙

13-39
  • Single-letter extension을 canonical order `IMAFDQLCBKJTPVH`로 먼저 배치합니다.
  • 모든 multi-letter extension은 다른 extension과 underscore로 구분합니다.
  • `Z`로 시작하는 additional standard extension은 single-letter extension 뒤, higher-privileged extension 앞에 둡니다.
  • `Z` 다음 첫 letter가 관련 single-letter category를 나타냅니다. Category는 canonical order, 같은 category 안에서는 alphabetic order를 사용합니다.
  • `S`로 시작하는 supervisor-level extension은 standard unprivileged extension 뒤에 두고 여러 개면 alphabetic order로 정렬합니다.
  • `Zxm`으로 시작하는 machine-level extension은 lower-privileged standard extension 뒤에 두고 여러 개면 alphabetic order로 정렬합니다.
  • `X`로 시작하는 non-standard extension은 모든 standard extension 뒤에 두고 여러 개면 alphabetic order로 정렬합니다.
ISA string extension ordering
Single-letter`Z*` standard
Supervisor `S*`Machine `Zxm*`
Non-standard `X*`

Linux가 `/proc/cpuinfo` ISA string에 extension group을 배치하는 순서입니다.

Ordering example

40-44

위 순서를 따르는 ISA string 예입니다.

rv64imadc_zifoo_zigoo_zafoo_sbar_scar_zxmbaz_xqux_xrux

"isa"와 "hart isa" line

45-63

`/proc/cpuinfo`의 `isa` line은 kernel이 인식하고 모든 hart에 구현된 RISC-V ISA extension의 lowest common denominator를 설명합니다. `hart isa` line은 system의 다른 hart에 없어도 해당 hart에서 kernel이 인식한 extension set을 설명합니다.

두 line에 extension이 있다는 사실은 hardware capability만 보장합니다. Userspace가 완전히 사용하려면 추가 kernel support나 policy 변경이 필요할 수 있습니다. S-mode extension도 kernel이 실제로 사용하거나 guest VM에 노출한다는 보장은 없습니다.

반대로 extension이 line에 없다고 hardware가 지원하지 않는다는 뜻도 아닙니다. Running kernel이 extension을 인식하지 못하거나 의도적으로 listing에서 제거했을 수 있습니다.

Misaligned access

64-70

Userspace의 misaligned scalar access는 지원되지만 성능이 나쁠 수 있습니다. Misaligned vector access는 `Zicclsm` extension을 지원할 때만 지원됩니다.

Pointer masking

71-86

Userspace pointer masking인 `Supm` extension은 `PR_SET_TAGGED_ADDR_CTRL`과 `PR_GET_TAGGED_ADDR_CTRL` `prctl()` operation으로 제공합니다. Pointer masking은 default로 disable되어 있습니다.

Enable하려면 application이 필요한 mask/tag bit 수를 `PR_PMLEN` field에 넣어 `PR_SET_TAGGED_ADDR_CTRL`을 호출합니다. `PR_PMLEN`은 lower bound로 해석되며 kernel이 만족하지 못하면 operation은 실패합니다. 실제 tag bit 수는 `PR_GET_TAGGED_ADDR_CTRL`이 `PR_PMLEN`으로 반환합니다.

Pointer masking이 enable되어 `PR_PMLEN > 0`이면 AArch64와 같은 interface와 behavior의 tagged-address ABI도 지원합니다. 기준 문서는 `Documentation/arch/arm64/tagged-address-abi.rst`입니다.