← Documents Documentation/arch/arm64/tagged-pointers.rst GitHub 원문 ↗

Linux 6.18.37 · Architecture

Tagged Virtual Addresses in AArch64 Linux

TTBR0 top-byte-ignore, kernel 전달 제한, signal fault address의 tag 보존 규칙을 설명합니다.

Source pathDocumentation/arch/arm64/tagged-pointers.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약과 해설

tagged-pointers.rst:1-89

AArch64는 userspace address의 bit 63:56을 translation에서 무시하지만 kernel ABI는 별도 opt-in 전에는 tag 0을 전제로 합니다. Signal interface도 `SA_EXPOSE_TAGBITS`, MTE FAR 지원, fault 종류에 따라 tag 보존 범위가 다릅니다.

Top-byte tag의 경로
Pointer bit 63:56`TTBR0` translation에서 무시Userspace memory accessSyscall 경계Tagged Address ABI 검사

Application tag가 hardware translation과 kernel ABI를 통과하는 과정입니다.

Signal tag 노출
위치조건결과
`si_addr``SA_EXPOSE_TAGBITS`일반 tag 보존
`SEGV_MTESERR` bit 63:60`HWCAP3_MTE_FAR`유효한 FAR tag
Watchpoint항상Tag 보존
`fault_address`조건 없음Tag 제거

Fault 정보가 tag를 유지하는 조건입니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 =========================================
2 Tagged virtual addresses in AArch64 Linux
3 =========================================
4
5 Author: Will Deacon <will.deacon@arm.com>
6
7 Date : 12 June 2013
8
9 This document briefly describes the provision of tagged virtual
10 addresses in the AArch64 translation system and their potential uses
11 in AArch64 Linux.
12
13 The kernel configures the translation tables so that translations made
14 via TTBR0 (i.e. userspace mappings) have the top byte (bits 63:56) of
15 the virtual address ignored by the translation hardware. This frees up
16 this byte for application use.
17
18
19 Passing tagged addresses to the kernel
20 --------------------------------------
21
22 All interpretation of userspace memory addresses by the kernel assumes
23 an address tag of 0x00, unless the application enables the AArch64
24 Tagged Address ABI explicitly
25 (Documentation/arch/arm64/tagged-address-abi.rst).
26
27 This includes, but is not limited to, addresses found in:
28
29 - pointer arguments to system calls, including pointers in structures
30 passed to system calls,
31
32 - the stack pointer (sp), e.g. when interpreting it to deliver a
33 signal,
34
35 - the frame pointer (x29) and frame records, e.g. when interpreting
36 them to generate a backtrace or call graph.
37
38 Using non-zero address tags in any of these locations when the
39 userspace application did not enable the AArch64 Tagged Address ABI may
40 result in an error code being returned, a (fatal) signal being raised,
41 or other modes of failure.
42
43 For these reasons, when the AArch64 Tagged Address ABI is disabled,
44 passing non-zero address tags to the kernel via system calls is
45 forbidden, and using a non-zero address tag for sp is strongly
46 discouraged.
47
48 Programs maintaining a frame pointer and frame records that use non-zero
49 address tags may suffer impaired or inaccurate debug and profiling
50 visibility.
51
52
53 Preserving tags
54 ---------------
55
56 When delivering signals, non-zero tags are not preserved in
57 siginfo.si_addr unless the flag SA_EXPOSE_TAGBITS was set in
58 sigaction.sa_flags when the signal handler was installed. This means
59 that signal handlers in applications making use of tags cannot rely
60 on the tag information for user virtual addresses being maintained
61 in these fields unless the flag was set.
62
63 If FEAT_MTE_TAGGED_FAR (Armv8.9) is supported, bits 63:60 of the fault address
64 are preserved in response to synchronous tag check faults (SEGV_MTESERR)
65 otherwise not preserved even if SA_EXPOSE_TAGBITS was set.
66 Applications should interpret the values of these bits based on
67 the support for the HWCAP3_MTE_FAR. If the support is not present,
68 the values of these bits should be considered as undefined otherwise valid.
69
70 For signals raised in response to watchpoint debug exceptions, the
71 tag information will be preserved regardless of the SA_EXPOSE_TAGBITS
72 flag setting.
73
74 Non-zero tags are never preserved in sigcontext.fault_address
75 regardless of the SA_EXPOSE_TAGBITS flag setting.
76
77 The architecture prevents the use of a tagged PC, so the upper byte will
78 be set to a sign-extension of bit 55 on exception return.
79
80 This behaviour is maintained when the AArch64 Tagged Address ABI is
81 enabled.
82
83
84 Other considerations
85 --------------------
86
87 Special care should be taken when using tagged pointers, since it is
88 likely that C compilers will not hazard two virtual addresses differing
89 only in the upper byte.
90

3. 한국어 전문 번역

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

Tagged virtual address 배치

1-18

저자: Will Deacon, 2013-06-12. 이 문서는 AArch64 translation system의 tagged virtual address 제공 방식과 Linux에서의 잠재적 용도를 설명합니다.

Kernel은 `TTBR0`, 즉 userspace mapping의 translation에서 virtual address top byte(bit 63:56)를 hardware가 무시하도록 table을 설정합니다. 따라서 application이 이 byte를 tag 용도로 사용할 수 있습니다.

Kernel에 tagged address 전달

19-52

Application이 `Documentation/arch/arm64/tagged-address-abi.rst`의 AArch64 Tagged Address ABI를 명시적으로 enable하지 않으면 kernel은 모든 userspace memory address의 tag를 `0x00`으로 가정합니다.

주소 위치Kernel이 해석하는 예
System-call pointer직접 argument와 syscall structure 안의 pointer
Stack pointer `sp`Signal 전달을 위해 stack을 해석할 때
Frame pointer `x29`와 frame recordBacktrace나 call graph 생성

ABI를 enable하지 않은 상태에서 이 위치에 non-zero tag를 쓰면 error, fatal signal 또는 다른 실패가 가능합니다. 따라서 syscall로 전달하는 것은 금지되고 `sp`에 쓰는 것도 강하게 권장되지 않습니다. Frame pointer와 frame record에 tag를 쓰면 debugging·profiling 가시성이 손상되거나 부정확할 수 있습니다.

Signal에서 tag 보존

53-83
경로Tag 보존 규칙
`siginfo.si_addr`Handler 설치 시 `sigaction.sa_flags`에 `SA_EXPOSE_TAGBITS`가 있어야 non-zero tag 보존
`SEGV_MTESERR``FEAT_MTE_TAGGED_FAR`(Armv8.9)와 `HWCAP3_MTE_FAR`가 있으면 fault address bit 63:60 유효, 없으면 undefined
Watchpoint debug exception`SA_EXPOSE_TAGBITS`와 무관하게 tag 보존
`sigcontext.fault_address``SA_EXPOSE_TAGBITS`와 무관하게 non-zero tag를 절대 보존하지 않음

Architecture는 tagged PC를 허용하지 않으므로 exception return 때 upper byte를 bit 55의 sign extension으로 설정합니다. 이 규칙은 Tagged Address ABI를 enable해도 유지됩니다.

기타 고려 사항

84-89

Tagged pointer를 사용할 때는 각별히 주의해야 합니다. C compiler가 upper byte만 다른 두 virtual address 사이의 hazard를 인식한다고 기대하기 어렵기 때문입니다.