Od 27 marca 2025 r. zalecamy używanie android-latest-release
zamiast aosp-main
do kompilowania i wspołtworzenia AOSP. Więcej informacji znajdziesz w artykule o zmianach w AOSP.
Utrzymywanie stabilnego interfejsu modułu jądra
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Ważne jest, aby zapewnić stabilny interfejs modułu jądra (KMI) dla modułów dostawców. Rdzeń GKI jest tworzony i dostarczany w postaci binarnej, a moduły ładowane przez dostawcę są tworzone w osobnym drzewie. Powstałe moduły rdzenia i moduły dostawców GKI muszą działać tak, jakby zostały utworzone razem.
Ogólnie społeczność Linuksa nie zgadza się z koncepcją stabilności ABI w jądrze w przypadku głównego jądra. Ze względu na różne zestawy narzędzi, konfiguracje i stale rozwijane jądro główne Linuksa nie jest możliwe utrzymanie stabilnego KMI w głównym systemie. Można jednak utrzymać stabilny współczynnik KMI w wyjątkowo ograniczonym środowisku GKI, stosując te ograniczenia:
Do kompilacji jądra można użyć tylko jednej konfiguracji, gki_defconfig
.
KMI jest stabilny tylko w przypadku tej samej wersji jądra LTS i Androida, np. android14-6.1
, android15-6.6
lub android16-6.12
.
- Stabilność KMI nie jest utrzymywana w przypadku
android-mainline
.
Do kompilowania jądra i modułów służy tylko określona łańcuch narzędzi Clang dostarczony w AOSP i zdefiniowany dla odpowiedniej gałęzi.
Stabilność i oznaczenie jako symboli KMI podlegają tylko te symbole, które są używane przez moduły zgodnie z listą symboli.
- Oznacza to, że moduły dostawców mogą używać tylko symboli KMI. To ograniczenie jest egzekwowane przez nieudane wczytywanie modułów, jeśli wymagane są symbole inne niż KMI.
Po zamrożeniu gałęzi KMI można wprowadzić zmiany, ale nie mogą one naruszać KMI.
Te zmiany obejmują:
- Zmiany w konfiguracji
- Zmiany w kodzie jądra
- zmiany w ekosystemie narzędzi (w tym aktualizacje);
Używanie hermetycznego procesu kompilacji i łańcucha narzędzi LLVM
Proces hermetycznego kompilowania zapewnia stabilność KMI dzięki temu, że pliki manifestu repo
w kernel/manifest
dokładnie opisują środowisko kompilacji. Na przykład plik manifestu dla android16-6.12
zawiera zestaw narzędzi, system kompilacji i wszystko inne, co jest wymagane do skompilowania obrazu jądra Generic Kernel Image (GKI). Konfiguracja kompilacji, głównie BUILD.bazel
, zapewnia prawidłowe używanie dołączonych narzędzi w celu generowania spójnych wyników kompilacji.
Użycie hermetycznego procesu kompilacji zapewnia też spójność opisu ABI dla drzewa niezależnie od tego, czy został wygenerowany przez Google (np.
gki/aarch64/abi.stg
w przypadku android16-6.12
) czy w drzewie lokalnym, które zawiera moduły dostawcy. Narzędzia do tworzenia i porównywania opisu ABI interfejsu Kernel Module Interface (KMI) są również dostępne w repozytorium opisanym w pliku manifestu.
Zestaw narzędzi używany do kompilowania rdzenia GKI musi być w pełni zgodny z zestawem narzędzi używanym do kompilowania modułów dostawców. Od Androida 10 wszystkie jądra Androida muszą być kompilowane za pomocą zestawu narzędzi LLVM. W przypadku GKI łańcuch narzędzi LLVM używany do kompilowania jąder produktów i modułów dostawców musi generować ten sam interfejs ABI co łańcuch narzędzi LLVM z AOSP, a partnerzy muszą zadbać o to, aby KMI był zgodny z jądrem GKI.
Zalecamy korzystanie z dostępnych narzędzi do kompilacji, ponieważ zapewniają one najlepszą zgodność.
Co dalej?
Instrukcje dotyczące kompilowania jądra za pomocą hermetycznego procesu kompilacji i zestawu narzędzi LLVM znajdziesz w artykule Kompilowanie jąder.
Instrukcje monitorowania ABI i rozwiązywania problemów znajdziesz w artykule Monitorowanie ABI jądra Androida.
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-27 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-27 UTC."],[],[],null,["# Maintain a stable kernel module interface\n\nIt's critical to maintain a stable kernel module interface (KMI) for vendor\nmodules. The GKI kernel is\nbuilt and shipped in binary form and vendor-loadable modules are built in a\nseparate tree. The resulting GKI kernel and vendor modules must work as\nthough they were built together.\n\nGenerally, the Linux community has\n[frowned on the notion of in-kernel ABI\nstability](https://www.kernel.org/doc/Documentation/process/stable-api-nonsense.rst)\nfor the mainline kernel. In the face of different toolchains, configurations,\nand an ever-evolving Linux mainline kernel, it isn't feasible to maintain a\nstable KMI in mainline. However, it's possible to maintain a stable KMI in\nthe highly-constrained GKI environment with these constraints:\n\n- Only a single configuration, `gki_defconfig`, can be used to build the\n kernel.\n\n- The KMI is only stable within the same LTS and Android version of a kernel,\n such as `android14-6.1`, `android15-6.6` or `android16-6.12`.\n\n - No KMI stability is maintained for `android-mainline`.\n- Only the specific *Clang* toolchain supplied in AOSP and defined for the\n corresponding branch is used for building kernel and modules.\n\n- Only symbols known to be used by modules as specified in a symbol list are\n monitored for stability and considered KMI symbols.\n\n - The corollary is that vendor modules must use only KMI symbols. This constraint is enforced by failing module loads if non-KMI-symbols are required.\n- After the KMI branch is frozen, changes are allowed but can't break the KMI.\n These changes include the following:\n\n - Config changes\n - Kernel code changes\n - Toolchain changes (including updates)\n\nUse the hermetic build process and LLVM toolchain\n-------------------------------------------------\n\nThe hermetic build process ensures a stable KMI by having `repo` manifests in\n`kernel/manifest` completely describe the build environment. For example, the\n[manifest for `android16-6.12`](https://android.googlesource.com/kernel/manifest/+/refs/heads/common-android16-6.12/default.xml)\nincludes the toolchain, build system, and everything else required to build the\nGeneric Kernel Image (GKI) kernel. The build configuration, primarily\n[`BUILD.bazel`](https://android.googlesource.com/kernel/common/+/refs/heads/android16-6.12/BUILD.bazel),\nensures that the included tools are used correctly to generate consistent build\nresults.\n\nUsing a hermetic build process also ensures that the ABI description for the\ntree is consistent whether generated by Google (for example,\n[`gki/aarch64/abi.stg`](https://android.googlesource.com/kernel/common/+/refs/heads/android16-6.12/gki/aarch64/abi.stg)\nfor `android16-6.12`) or generated in a local tree that includes the vendor\nmodules. The\n[tools to create and compare the ABI description](https://android.googlesource.com/kernel/build/+/refs/heads/main-kernel/abi/)\nfor the Kernel Module Interface (KMI) are also provided as part of the repo\ndescribed by the manifest.\n\nThe toolchain used to build the GKI kernel must be completely compatible with\nthe toolchain used to build vendor modules. As of Android\n10, all Android kernels must be built\nwith an LLVM toolchain. With GKI, the LLVM toolchain used to build product\nkernels and vendor modules must generate the same ABI as the LLVM toolchain from\nAOSP and partners must ensure that the KMI is compatible with the GKI kernel.\nUsing the provided build tools is strongly encouraged as they provide the\nbest compatibility.\n\nWhat's next?\n------------\n\n- For instructions on building the kernel using the hermetic build process and\n LLVM toolchain, refer to refer to\n [Build kernels](/docs/setup/build/building-kernels).\n\n- For instructions on how to monitor the ABI and fix issues, refer to\n [Android Kernel ABI Monitoring](/docs/core/architecture/kernel/abi-monitor)"]]