Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release thay vì aosp-main để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Định cấu hình các tính năng của hạt nhân dưới dạng mô-đun GKI
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trang này trình bày cách định cấu hình một tính năng nhân mới dưới dạng mô-đun GKI hoặc định cấu hình một tính năng nhân tích hợp sẵn hiện có dưới dạng mô-đun GKI.
Định cấu hình một tính năng mới dưới dạng mô-đun GKI
Đối với tính năng mới, hãy chỉnh sửa gki_defconfig và đặt mục cấu hình của tính năng hạt nhân bắt buộc từ n thành m (=m). Đặt chế độ cài đặt này trong cả arch/arm64/configs/gki_defconfig và arch/x86/configs/gki_defconfig.
Thêm các tệp KO (.ko) được tạo cho tính năng này vào phần COMMON_GKI_MODULES_LIST của common/modules.bzl. Thêm các tệp theo thứ tự đã sắp xếp. Nếu bạn không chắc chắn về tất cả các tệp được tạo, thì bản dựng sẽ không thành công và liệt kê tất cả các tệp KO cần thiết để thêm vào danh sách.
Đối với Android 14, hãy thêm cùng một tập hợp tệp KO từ bước 2, được sắp xếp theo thứ tự tăng dần để tìm kiếm nhị phân trong thời gian chạy, vào common/android/gki_{ARCH}_protected_modules để chỉ định mô-đun này là mô-đun GKI được bảo vệ.
Đối với Android 14 và 15, hãy cập nhật danh sách các tệp xuất để bao gồm các tệp xuất mới thêm trong common/android/abi_gki_protected_exports_ARCHITECTURE. Ví dụ: để cập nhật danh sách, hãy chạy tools/bazel run //common:kernel_aarch64_abi_update_protected_exports cho aarch64.
Đảm bảo rằng các tệp KO mới thêm từ bước 2 được sao chép vào out/<androidX-Y.Z>/dist/system_dlkm.img và out/androidX-Y.Z/dist/system_dlkm_staging_archive.tar.gz của hạt nhân.
Bạn có thể dùng các mô-đun trong tệp lưu trữ system_dlkm_staging_archive.tar.gz làm dữ liệu đầu vào để tạo system_dlkm.img trong bản dựng nền tảng.
Gửi nội dung thay đổi để được xem xét. Mô-đun GKI là một tính năng hạt nhân chỉ dành cho Android, vì vậy, bạn không cần phải gửi các bản vá chuyển đổi mô-đun lên trên. Tuy nhiên, bạn phải tuân thủ các nguyên tắc khác để gửi bản vá Hạt nhân Android chung (ACK).
Định cấu hình tính năng tích hợp sẵn của hạt nhân dưới dạng mô-đun GKI
Đối với tính năng nhân tích hợp sẵn hiện có, hãy chỉnh sửa gki_defconfig và đặt mục cấu hình của tính năng nhân bắt buộc từ y thành m (=m). Đặt chế độ cài đặt này trong cả arch/arm64/configs/gki_defconfig và arch/x86/configs/gki_defconfig.
Thêm các tệp KO (.ko) được tạo cho tính năng này vào phần COMMON_GKI_MODULES_LIST của common/modules.bzl. Thêm các tệp theo thứ tự đã sắp xếp. Nếu bạn không chắc chắn về tất cả các tệp được tạo, thì bản dựng sẽ không thành công và liệt kê tất cả các tệp KO cần thiết để thêm vào danh sách.
Đối với Android 14, hãy thêm cùng một tập hợp tệp KO từ bước 2, được sắp xếp theo thứ tự tăng dần để tìm kiếm nhị phân trong thời gian chạy, vào common/android/gki_{ARCH}_protected_modules để chỉ định mô-đun này là mô-đun GKI được bảo vệ.
Đối với Android 14 và 15, hãy cập nhật danh sách các tệp xuất được bảo vệ để bao gồm cả các tệp xuất từ mô-đun mới thêm trong common/android/abi_gki_protected_exports_{ARCH} bằng cách sử dụng tools/bazel run
//common:kernel_aarch64_abi_update_protected_exports cho aarch64.
Đảm bảo rằng các tệp KO của mô-đun mới chuyển đổi từ bước 2 được sao chép vào out/<androidX-Y.Z>/dist/system_dlkm.img và out/androidX-Y.Z/dist/system_dlkm_staging_archive.tar.gz của hạt nhân.
Bạn có thể dùng các mô-đun trong tệp lưu trữ system_dlkm_staging_archive.tar.gz làm dữ liệu đầu vào để tạo system_dlkm.img trong bản dựng nền tảng.
Gửi nội dung thay đổi để được xem xét. Mô-đun GKI là một tính năng hạt nhân chỉ dành cho Android, vì vậy, bạn không cần phải gửi các bản vá chuyển đổi mô-đun lên trên. Tuy nhiên, bạn phải tuân thủ các nguyên tắc khác để gửi bản vá nhân hệ điều hành Android Common Kernel (ACK).
Chuyển đổi mô-đun GKI được bảo vệ thành mô-đun không được bảo vệ
Đối với Android 15 trở lên, hãy thêm mô-đun đang được chuyển đổi từ được bảo vệ sang không được bảo vệ vào danh sách COMMON_UNPROTECTED_MODULES_LIST trong tệp common/modules.bzl.
Đối với Android 14, hãy xoá mô-đun đang được chuyển đổi từ được bảo vệ sang không được bảo vệ khỏi danh sách mô-đun được bảo vệ tại common/android/gki_protected_modules.
Đối với Android 14 và 15, hãy cập nhật danh sách các tệp xuất được bảo vệ để loại trừ các tệp xuất từ mô-đun không được bảo vệ mới chuyển đổi trong common/android/abi_gki_protected_exports_{ARCH} bằng cách sử dụng tools/bazel run
//common:kernel_aarch64_abi_update_protected_exports cho aarch64.
Gửi nội dung thay đổi để được xem xét. Mô-đun GKI là một tính năng hạt nhân chỉ dành cho Android, vì vậy, bạn không cần phải gửi các bản vá chuyển đổi mô-đun lên trên. Tuy nhiên, bạn phải tuân thủ các nguyên tắc khác để gửi bản vá nhân hệ điều hành Android Common Kernel (ACK).
Hướng dẫn nhanh về cách giải quyết lỗi vi phạm biểu tượng mô-đun GKI
Khi các mô-đun chưa ký vi phạm biện pháp bảo vệ biểu tượng hiện có cho các mô-đun GKI, bạn có thể gặp phải hai loại lỗi trong quá trình tải mô-đun, dẫn đến lỗi.
Tệp module.ko là một mô-đun nhà cung cấp chưa ký và cố gắng phân giải biểu tượng some_kernel_function được xuất của mô-đun GKI trong quá trình tải mà không được liệt kê trong danh sách biểu tượng nhà cung cấp.
Cách giải quyết:
Nếu module.ko không phải là mô-đun GKI được bảo vệ, thì việc cập nhật danh sách biểu tượng sẽ giải quyết lỗi bằng cách đưa some_kernel_function vào danh sách biểu tượng của nhà cung cấp.
Ngoài ra, hãy sử dụng phiên bản GKI của module.ko.
2. Mô-đun chưa ký xuất biểu tượng được bảo vệ
Lỗi:
module: exports protected symbol some_kernel_function
Nguyên nhân:
Mô-đun xuất some_kernel_function là một mô-đun GKI được bảo vệ và module.ko có thể là một phiên bản tuỳ chỉnh chưa ký của mô-đun đó. Khi module.ko cố gắng xuất some_kernel_function (chỉ có thể được xuất bằng mô-đun GKI đã ký), quá trình tải sẽ không thành công kèm theo thông báo này.
Cách giải quyết:
Bạn có thể khắc phục vấn đề này bằng cách sử dụng phiên bản GKI của mô-đun xuất some_kernel_function, nếu mô-đun chưa ký là phiên bản tuỳ chỉnh.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# Configure kernel features as GKI modules\n\nThis page covers how to configure a new kernel feature as a GKI module or\nconfigure an existing built-in kernel feature as a GKI module.\n| **Note:** Changes that result in a new GKI module or that change the protection status of a GKI module must be approved by Google.\n\nConfigure a new feature as a GKI module\n---------------------------------------\n\n1. For the new feature, edit `gki_defconfig` and set the required kernel\n feature's config item from `n` to `m` (`=m`). Set this setting in both\n `arch/arm64/configs/gki_defconfig` and `arch/x86/configs/gki_defconfig`.\n\n2. Add the KO (`.ko`) files generated for the feature\n to the `COMMON_GKI_MODULES_LIST` section of `common/modules.bzl`. Add the\n files in a sorted order. If you're unsure of all the files generated,\n the build fails and lists all the necessary KO files to be added to the list.\n\n3. For Android 14, add the same set of KO files from step 2, sorted in ascending\n order for binary search at runtime, to\n `common/android/gki_{ARCH}_protected_modules` to designate the module as a\n protected GKI module.\n\n4. For Android 14 and 15, update the list of exports so that it includes the\n newly-added exports in `common/android/abi_gki_protected_exports_`\u003cvar translate=\"no\"\u003eARCHITECTURE\u003c/var\u003e. For example, to update the list, run\n `tools/bazel run //common:kernel_aarch64_abi_update_protected_exports` for\n `aarch64`.\n\n5. Make sure newly added KO files from step 2 are copied to the kernel's\n `out/\u003candroidX-Y.Z\u003e/dist/system_dlkm.img` and\n `out/`\u003cvar translate=\"no\"\u003eandroidX-Y.Z\u003c/var\u003e`/dist/system_dlkm_staging_archive.tar.gz`.\n Modules in the `system_dlkm_staging_archive.tar.gz` archive can be used as\n input to generate the `system_dlkm.img` in the platform build.\n\n6. Submit your changes for review. GKI modules are an Android-only kernel\n feature, so module conversion patches aren't required to be submitted\n upstream. However, you must follow other guidelines to submit\n [Android Common Kernel (ACK) patches](/docs/core/architecture/kernel/kernel-code#ack-patches).\n\nConfigure a kernel built-in feature as a GKI module\n---------------------------------------------------\n\n1. For an existing built-in kernel feature, edit `gki_defconfig` and set the\n required kernel feature's config item from `y` to `m` (`=m`). Set this\n setting in both `arch/arm64/configs/gki_defconfig` and\n `arch/x86/configs/gki_defconfig`.\n\n2. Add the KO (`.ko`) files generated for the feature to the\n `COMMON_GKI_MODULES_LIST` section of `common/modules.bzl`. Add the files\n in a sorted order. If you're unsure of all the files generated,\n the build fails and lists all the necessary KO files to be added to the list.\n\n3. For Android 14, add the same set of KO files from step 2, sorted in ascending\n order for binary search at runtime, to\n `common/android/gki_{ARCH}_protected_modules` to designate the module as a\n protected GKI module.\n\n4. For Android 14 and 15, update the list of exports that are protected to\n include ones from the newly added module in\n `common/android/abi_gki_protected_exports_{ARCH}` using `tools/bazel run\n //common:kernel_aarch64_abi_update_protected_exports` for `aarch64`.\n\n5. Make sure newly converted module KO files from step 2 are copied to the\n kernel's `out/\u003candroidX-Y.Z\u003e/dist/system_dlkm.img` and\n `out/`\u003cvar translate=\"no\"\u003eandroidX-Y.Z\u003c/var\u003e`/dist/system_dlkm_staging_archive.tar.gz`.\n Modules in the `system_dlkm_staging_archive.tar.gz` archive can be used as\n input to generate the `system_dlkm.img` in the platform build.\n\n6. Submit your changes for review. GKI modules are an Android-only kernel\n feature, so module conversion patches aren't required to be submitted\n upstream. However, you must follow the other guidelines to submit\n [Android Common Kernel (ACK)\n patches](/docs/core/architecture/kernel/kernel-code#ack-patches).\n\nConvert a protected GKI module to unprotected\n---------------------------------------------\n\n1. For Android 15 and higher, add the module being converted from protected to\n unprotected to the `COMMON_UNPROTECTED_MODULES_LIST` list in\n `common/modules.bzl` file.\n\n2. For Android 14, remove the module being converted from protected to\n unprotected from the list of protected modules at\n `common/android/gki_protected_modules`.\n\n3. For Android 14 and 15, update the list of exports that are protected to\n exclude ones from the newly converted unprotected module in the\n `common/android/abi_gki_protected_exports_{ARCH}` using `tools/bazel run\n //common:kernel_aarch64_abi_update_protected_exports` for `aarch64`.\n\n4. Submit your changes for review. GKI modules are an Android-only kernel\n feature, so module conversion patches aren't required to be submitted\n upstream. However, you must follow the other guidelines to submit\n [Android Common Kernel (ACK)\n patches](/docs/core/architecture/kernel/kernel-code#ack-patches).\n\nGKI modules symbol violation resolution quick guide\n---------------------------------------------------\n\nWhen unsigned modules violate the symbol protection in place for GKI modules,\ntwo types of errors may be encountered during module loading, resulting in\nfailure.\n\n### 1. Unsigned module using the protected symbol\n\n**Error:**\n\n`module: Protected symbol: some_kernel_function (err -13)`\n\n**Cause:**\n\nThe `module.ko` file is an unsigned vendor module and attempts to resolve the\nGKI module exported symbol `some_kernel_function` during loading, without\nbeing listed in the vendor symbol list.\n\n**Resolution:**\n\nIf `module.ko` is not a protected GKI module, updating the symbol list will\nresolve the error by including `some_kernel_function` in the vendor symbol list.\nAlternatively, use the GKI version of `module.ko`.\n\n### 2. Unsigned module exporting the protected symbol\n\n**Error:**\n\n`module: exports protected symbol some_kernel_function`\n\n**Cause:**\n\nThe module exporting the `some_kernel_function` is a protected GKI module, and\n`module.ko` is likely an unsigned custom version of that module. When\n`module.ko` tries to export `some_kernel_function`, which can only be exported\nby a signed GKI module, loading fails with this message.\n\n**Resolution:**\n\nThis can be corrected by using the GKI version of the module that exports\n`some_kernel_function`, if the unsigned module is a custom version."]]