요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
1
.. contents::
2
.. sectnum::
4
===================================================
5
BPF ABI Recommended Conventions and Guidelines v1.0
6
===================================================
8
This is version 1.0 of an informational document containing recommended
9
conventions and guidelines for producing portable BPF program binaries.
11
Registers and calling convention
12
================================
14
BPF has 10 general purpose registers and a read-only frame pointer register,
15
all of which are 64-bits wide.
17
The BPF calling convention is defined as:
19
* R0: return value from function calls, and exit value for BPF programs
20
* R1 - R5: arguments for function calls
21
* R6 - R9: callee saved registers that function calls will preserve
22
* R10: read-only frame pointer to access stack
24
R0 - R5 are scratch registers and BPF programs needs to spill/fill them if
25
necessary across calls.
27
The BPF program needs to store the return value into register R0 before doing an
28
``EXIT``.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
이식 가능한 BPF ABI 지침
1-10.. contents::
.. sectnum::
`BPF ABI Recommended Conventions and Guidelines v1.0`은 이식 가능한 `portable BPF program binaries`를 만들기 위한 권장 규약과 지침을 담은 정보성 문서의 버전 1.0입니다.
레지스터와 호출 규약
11-28BPF에는 10 general purpose registers와 read-only frame pointer register가 있으며 모두 64-bits wide입니다.
BPF 호출 규약은 다음과 같습니다.
- `R0`: 함수 호출의 반환값이자 BPF 프로그램의 종료 값
- `R1 - R5`: 함수 호출 인자
- `R6 - R9`: 함수 호출이 보존하는 callee saved registers
- `R10`: 스택 접근에 사용하는 read-only frame pointer
`R0 - R5`는 scratch registers이므로 호출을 가로질러 값이 필요하면 BPF 프로그램이 spill/fill해야 합니다.
BPF 프로그램은 `EXIT`를 실행하기 전에 반환값을 레지스터 `R0`에 저장해야 합니다.
요약과 해설
abi.rst:1-28BPF ABI는 `R0`을 반환값, `R1-R5`를 인자와 scratch, `R6-R9`를 callee-saved, `R10`을 읽기 전용 프레임 포인터로 사용합니다. 프로그램은 `EXIT` 전에 결과를 `R0`에 넣어야 합니다.