自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
一般核心映像檔 (GKI) 專案
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁面說明通用核心映像檔 (GKI) 專案,以及該專案如何提升 Android 穩定性和安全性。
記錄
每部 Android 裝置都需要正式版核心。在 GKI 推出之前,核心是自訂的,並以 Android 通用核心 (ACK) 為基礎,晶片系統 (SoC) 供應商和原始設備製造商 (OEM) 會針對裝置做出特定變更。
這項自訂設定可能會導致高達 50% 的核心程式碼為非樹狀結構程式碼,而非來自上游 Linux 核心或 ACK。因此,GKI 前核心的自訂性質導致核心碎片化情形嚴重。
分散式架構的成本
核心分散化會對 Android 社群造成多項負面影響。
安全性更新耗費人力
Android 安全性公告 (ASB) 中提及的安全性修補程式必須回移至各個裝置核心。不過,由於核心分散,因此要將安全性修補程式傳播至現有 Android 裝置,成本過高。
難以合併長期支援的更新
長期支援 (LTS) 版本包含安全性修正項目和其他重要錯誤修正項目。持續更新 LTS 版本,已證明是提供安全性修正程式的最有效方式。我們發現,在 Pixel 裝置上,凡是持續保持在最新狀態的裝置,其中 90% 的核心安全性問題都已在 ASB 中回報。
不過,由於裝置核心有許多自訂修改項目,因此很難將 LTS 修正項目合併至裝置核心。
由於系統分散,因此在實地環境中,很難將需要修改核心的 Android 新功能新增至裝置。Android 架構程式碼必須考量不同的核心變化版本,且無法依賴在核心中實作的 Android 新功能,這會減緩創新速度,並導致程式碼大小和複雜度增加。
很難將 kernel 變更內容貢獻回上游 Linux
由於修補程式在正式版核心中採用的做法過於零散,因此從 LTS 版本在上游推出到在裝置中推出,這段時間的延遲長達 18 個月。由於上游核心版本與產品之間的延遲時間過長,Android 社群很難將所需功能和驅動程式提供給上游核心。當使用者提交改善建議時,程式碼集已變更,因此很難顯示修補程式碼的相關性。
修正分散現象:通用核心映像檔
通用核心映像檔 (GKI) 專案會統一核心核心,並將 SoC 和主機板支援移出核心核心,轉移至可載入的供應商模組,以解決核心分散的問題。GKI 也為供應商模組提供穩定的核心模組介面 (KMI),因此模組和核心可以獨立更新。GKI 核心的部分特性如下:
- GKI 核心是使用 ACK 來源建構而成。
- GKI 核心是單一核心二進位檔,以及每個 LTS 版本的每個架構相關可載入模組。
- 我們會使用所有 Android 平台版本測試 GKI 核心,這些版本支援相關的 ACK。GKI 核心版本的生命週期不會淘汰任何功能。
- GKI 核心會向特定 LTS 中的驅動程式公開穩定的 KMI。
- GKI 核心不含 SoC 專屬或板卡專屬程式碼。
如需 GKI 架構的圖片,請參閱核心總覽。
常見圖片
從 Android 12 開始,搭載 5.10 以上核心版本的裝置必須搭載 GKI 核心。通用核心映像檔 (GKI) 版本的構建作業會定期更新,並定期更新 LTS 和重大錯誤修正。由於 KMI 可維持二進位檔穩定性,您可以安裝這些啟動映像檔,而無須變更供應商映像檔。GKI 專案的目標如下:
- 將產品核心取代為 GKI 核心時,請勿引入重大效能或電源回歸現象。
- 讓合作夥伴在不必仰賴供應商的情況下,提供核心安全性修正和錯誤修正。
- 降低為裝置升級主要核心版本的成本。
- 透過更新核心版本,並提供明確的升級程序,為每個架構維護單一 GKI 核心二進位檔。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Generic Kernel Image (GKI) project\n\nThis page describes the Generic Kernel Image (GKI) project\nand how it increases Android stability and improves security.\n\nHistory\n-------\n\nEvery Android-powered device needs a production kernel. Prior to GKI, kernels\nwere custom and based on the Android Common Kernel (ACK), with device-specific\nchanges made by system on chip (SoC) vendors and OEMs.\n\nThis customization could result in as much as 50% of kernel\ncode being out-of-tree code and not from upstream Linux kernels or ACKs.\nAs such, the custom nature of pre-GKI kernels resulted in\nsignificant kernel fragmentation.\n\nCosts of fragmentation\n----------------------\n\nKernel fragmentation has several negative effects on the Android community.\n\n### Security updates are labor intensive\n\nSecurity patches cited in the\n[Android Security Bulletin (ASB)](/docs/security/bulletin)\nmust be backported into each of the device kernels. However, due to kernel\nfragmentation, it's prohibitively expensive to propagate security fixes to\nAndroid devices in the field.\n\n### Difficult to merge Long-Term Supported updates\n\nThe *Long-Term Supported (LTS)* releases include security fixes and\nother critical bug fixes. Staying up to date with LTS releases has proven\nto be the\nmost effective way to provide security fixes. On Pixel devices, it was\ndiscovered that 90% of the kernel security issues reported in the ASB had\nalready been fixed for devices that stay up to date.\n\nHowever, with all of the custom modifications in the device kernels, it's\ndifficult to just merge the LTS fixes into device kernels.\n\n### Inhibit Android platform release upgrades\n\nFragmentation makes it difficult for new Android features requiring\nkernel changes to be added to devices in the field. Android Framework\ncode had to account for the different kernel variations and couldn't\nrely on new Android features being implemented in the kernel\nThis slowed down innovation and caused increased code size and\ncomplexity.\n\n### Difficult to contribute kernel changes back to upstream Linux\n\nThe fragmented way of pulling patches into the production kernels caused a\ndelay of up to 18 months from the point where an LTS release was available\nupstream, to when it was in a device.\nThis long delay between upstream kernel release and products makes it difficult\nfor the Android community to feed needed features and drivers into the\nupstream kernels. By the time a user submitted suggestions for improvements, the\ncodebase had changed, making it hard to show the relevance\nof the patch.\n\nFix the fragmentation: Generic Kernel Image\n-------------------------------------------\n\nThe **Generic Kernel Image (GKI) project** addresses kernel fragmentation by\nunifying the core kernel and moving SoC and board support out of the core kernel\ninto loadable vendor modules. GKI also presents a stable Kernel Module\nInterface (KMI) for vendor modules, so modules and kernel can be updated\nindependently. Some characteristics of the GKI kernel are:\n\n- The GKI kernel is built from the ACK sources.\n- The GKI kernel is a single-kernel binary plus associated loadable modules per architecture, per LTS release.\n- The GKI kernel is tested with all Android Platform releases that are supported for the associated ACK. There's no feature deprecation for the lifetime of a GKI kernel version.\n- The GKI kernel exposes a stable KMI to drivers within a given LTS.\n- The GKI kernel doesn't contain SoC-specific or board-specific code.\n\nFor an image of GKI architecture, refer to the\n[Kernel overview](/docs/core/architecture/kernel).\n\n### Common Image\n\nBeginning with Android 12, devices shipping with kernel version 5.10 or higher\nmust ship with the GKI kernel. [Generic Kernel Image (GKI) release\nbuilds](/docs/core/architecture/kernel/gki-release-builds) are updated regularly\nand updated regularly with LTS and critical bug fixes.\nBecause binary stability is maintained for the KMI, you can install these boot\nimages without making changes to vendor images. The GKI project has these goals:\n\n- Don't introduce significant performance or power regressions when replacing the product kernel with the GKI kernel.\n- Enable partners to deliver kernel security fixes and bug fixes without vendor involvement.\n- Reduce the cost of upreving the major kernel version for devices.\n- Maintain a single GKI kernel binary per architecture by updating kernel versions with a clear process for upgrading."]]