요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
RISC-V Linux User ABI
=====================
ISA string ordering in /proc/cpuinfo
------------------------------------
The canonical order of ISA extension names in the ISA string is defined in
chapter 27 of the unprivileged specification.
The specification uses vague wording, such as should, when it comes to ordering,
so for our purposes the following rules apply:
#. Single-letter extensions come first, in canonical order.
The canonical order is "IMAFDQLCBKJTPVH".
#. All multi-letter extensions will be separated from other extensions by an
underscore.
#. Additional standard extensions (starting with 'Z') will be sorted after
single-letter extensions and before any higher-privileged extensions.
#. For additional standard extensions, the first letter following the 'Z'
conventionally indicates the most closely related alphabetical
extension category. If multiple 'Z' extensions are named, they will be
ordered first by category, in canonical order, as listed above, then
alphabetically within a category.
#. Standard supervisor-level extensions (starting with 'S') will be listed
after standard unprivileged extensions. If multiple supervisor-level
extensions are listed, they will be ordered alphabetically.
#. Standard machine-level extensions (starting with 'Zxm') will be listed
after any lower-privileged, standard extensions. If multiple machine-level
extensions are listed, they will be ordered alphabetically.
#. Non-standard extensions (starting with 'X') will be listed after all standard
extensions. If multiple non-standard extensions are listed, they will be
ordered alphabetically.
An example string following the order is::
rv64imadc_zifoo_zigoo_zafoo_sbar_scar_zxmbaz_xqux_xrux
"isa" and "hart isa" lines in /proc/cpuinfo
-------------------------------------------
The "isa" line in /proc/cpuinfo describes the lowest common denominator of
RISC-V ISA extensions recognized by the kernel and implemented on all harts. The
"hart isa" line, in contrast, describes the set of extensions recognized by the
kernel on the particular hart being described, even if those extensions may not
be present on all harts in the system.
In both lines, the presence of an extension guarantees only that the hardware
has the described capability. Additional kernel support or policy changes may be
required before an extension's capability is fully usable by userspace programs.
Similarly, for S-mode extensions, presence in one of these lines does not
guarantee that the kernel is taking advantage of the extension, or that the
feature will be visible in guest VMs managed by this kernel.
Inversely, the absence of an extension in these lines does not necessarily mean
the hardware does not support that feature. The running kernel may not recognize
the extension, or may have deliberately removed it from the listing.
Misaligned accesses
-------------------
Misaligned scalar accesses are supported in userspace, but they may perform
poorly. Misaligned vector accesses are only supported if the Zicclsm extension
is supported.
Pointer masking
---------------
Support for pointer masking in userspace (the Supm extension) is provided via
the ``PR_SET_TAGGED_ADDR_CTRL`` and ``PR_GET_TAGGED_ADDR_CTRL`` ``prctl()``
operations. Pointer masking is disabled by default. To enable it, userspace
must call ``PR_SET_TAGGED_ADDR_CTRL`` with the ``PR_PMLEN`` field set to the
number of mask/tag bits needed by the application. ``PR_PMLEN`` is interpreted
as a lower bound; if the kernel is unable to satisfy the request, the
``PR_SET_TAGGED_ADDR_CTRL`` operation will fail. The actual number of tag bits
is returned in ``PR_PMLEN`` by the ``PR_GET_TAGGED_ADDR_CTRL`` operation.
Additionally, when pointer masking is enabled (``PR_PMLEN`` is greater than 0),
a tagged address ABI is supported, with the same interface and behavior as
documented for AArch64 (Documentation/arch/arm64/tagged-address-abi.rst).
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
/proc/cpuinfo ISA string ordering
1-12RISC-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로 정렬합니다.
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-70Userspace의 misaligned scalar access는 지원되지만 성능이 나쁠 수 있습니다. Misaligned vector access는 `Zicclsm` extension을 지원할 때만 지원됩니다.
Pointer masking
71-86Userspace 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`입니다.
요약과 해설
uabi.rst:1-86ISA string은 single-letter, Z standard, supervisor, machine, X non-standard 순으로 정렬됩니다. `isa`와 `hart isa`는 공통 capability와 hart별 capability를 구분하며, pointer masking은 `PR_PMLEN` lower-bound contract로 제어됩니다.