요약·해설, 영어 원문, 전체 번역을 구분해 실었습니다. API 이름, 코드 심벌, 소스 경로는 원문 표기를 유지합니다.
1. 요약·해설
원문의 핵심 내용을 정리하고 커널 프로그래밍에 필요한 설명을 덧붙였습니다. 아래의 전체 번역과는 별도로 작성한 해설입니다.
2. 영어 원문 전체
번역에 사용한 Linux v6.18.37 원문입니다. 줄 번호는 해당 버전의 소스 파일을 기준으로 합니다.
원문 전체 펼치기
.. contents::
.. sectnum::
===================================================
BPF ABI Recommended Conventions and Guidelines v1.0
===================================================
This is version 1.0 of an informational document containing recommended
conventions and guidelines for producing portable BPF program binaries.
Registers and calling convention
================================
BPF has 10 general purpose registers and a read-only frame pointer register,
all of which are 64-bits wide.
The BPF calling convention is defined as:
* R0: return value from function calls, and exit value for BPF programs
* R1 - R5: arguments for function calls
* R6 - R9: callee saved registers that function calls will preserve
* R10: read-only frame pointer to access stack
R0 - R5 are scratch registers and BPF programs needs to spill/fill them if
necessary across calls.
The BPF program needs to store the return value into register R0 before doing an
``EXIT``.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미에 맞춰 전체 내용을 번역했습니다. 코드, 함수명, 코드 심벌, 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`에 넣어야 합니다.