요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
AT_SYSINFO_EHDR와 symbol versioning
vdso:20-28Program entry의 auxiliary vector에서 vDSO 주소를 찾고 기대하는 version을 지정해 symbol을 조회합니다.
Symbol ABI 안정성 범위
vdso:30-37별도 언급이 없으면 특정 version의 symbol 집합과 ABI는 stable하지만 architecture에 따라 달라질 수 있습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
What: vDSO
Date: July 2011
KernelVersion: 3.0
Contact: Andy Lutomirski <luto@kernel.org>
Description:
On some architectures, when the kernel loads any userspace program it
maps an ELF DSO into that program's address space. This DSO is called
the vDSO and it often contains useful and highly-optimized alternatives
to real syscalls.
These functions are called according to your platform's ABI. On many
platforms they are called just like ordinary C function. On other platforms
(ex: powerpc) they are called with the same convention as system calls which
is different from ordinary C functions. Call them from a sensible context.
(For example, if you set CS on x86 to something strange, the vDSO functions are
within their rights to crash.) In addition, if you pass a bad
pointer to a vDSO function, you might get SIGSEGV instead of -EFAULT.
To find the DSO, parse the auxiliary vector passed to the program's
entry point. The AT_SYSINFO_EHDR entry will point to the vDSO.
The vDSO uses symbol versioning; whenever you request a symbol from the
vDSO, specify the version you are expecting.
Programs that dynamically link to glibc will use the vDSO automatically.
Otherwise, you can use the reference parser in
tools/testing/selftests/vDSO/parse_vdso.c.
Unless otherwise noted, the set of symbols with any given version and the
ABI of those symbols is considered stable. It may vary across architectures,
though.
Note:
As of this writing, this ABI documentation as been confirmed for x86_64.
The maintainers of the other vDSO-using architectures should confirm
that it is correct for their architecture.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Userspace address space에 매핑되는 vDSO
1-10| 항목 | 내용 |
|---|---|
| What | vDSO |
| Date | 2011년 7월 |
| KernelVersion | 3.0 |
| Contact | Andy Lutomirski <luto@kernel.org> |
일부 architecture에서는 kernel이 userspace program을 load할 때 ELF DSO 하나를 그 program의 address space에 매핑한다. 이 DSO를 vDSO라고 하며, 실제 syscall을 대신할 수 있는 유용하고 고도로 최적화된 구현을 자주 포함한다.
Platform ABI에 따른 호출 규약과 오류 차이
12-18이 함수들은 platform ABI에 따라 호출한다. 많은 platform에서는 일반 C 함수처럼 호출한다. PowerPC 같은 다른 platform에서는 일반 C 함수와 다른 system call 호출 규약을 사용한다.
따라서 적절한 context에서 호출해야 한다. 예를 들어 x86에서 CS를 비정상적인 값으로 설정했다면 vDSO 함수가 crash하더라도 ABI 위반이 아니다. 또한 vDSO 함수에 잘못된 pointer를 넘기면 `-EFAULT` 대신 `SIGSEGV`를 받을 수 있다.
Auxiliary vector에서 vDSO 찾기
20-28DSO를 찾으려면 program entry point에 전달된 auxiliary vector를 parse한다. `AT_SYSINFO_EHDR` entry가 vDSO를 가리킨다.
vDSO는 symbol versioning을 사용한다. vDSO에서 symbol을 요청할 때는 기대하는 version을 지정해야 한다.
glibc에 동적으로 link한 program은 vDSO를 자동으로 사용한다. 그렇지 않은 경우 `tools/testing/selftests/vDSO/parse_vdso.c`의 reference parser를 사용할 수 있다.
Program이 auxiliary vector를 출발점으로 vDSO ELF image를 찾고 원하는 version의 symbol을 호출하는 순서이다.
Architecture별 symbol ABI 안정성
30-37별도로 언급하지 않는 한, 주어진 version에 속하는 symbol 집합과 그 symbol의 ABI는 stable한 것으로 간주한다. 다만 그 집합과 ABI는 architecture마다 다를 수 있다.
이 원문이 작성된 시점에는 이 ABI 문서가 x86_64에서 확인되었다. vDSO를 사용하는 다른 architecture의 maintainer는 해당 architecture에서도 내용이 정확한지 확인해야 한다.
vDSO mapping과 platform ABI 호출
vdso:1-18일부 architecture는 syscall의 고도로 최적화된 대안을 담은 ELF DSO를 program address space에 매핑하며, 함수는 platform ABI에 맞게 호출해야 합니다.