At the last Linux Plumbers 2021 conference, Googleabout the success of the initiative to move the Android platform to use a regular Linux kernel instead of using its own version of the kernel, which includes changes specific to the Android platform.
The most important development change was theto move after 2023 to the “Upstream First” model, which implies the development of all new kernel features required in the Android platform directly in the main Linux kernel, and not in its separate branches (functionality will be promoted to the main kernel, and then used in Android, and not vice versa). In 2023 and 2024, it is also planned to transfer to the main core of all remaining in the Android Common Kernel branch.
As for the near future, for the Android 12 platform expected in early October, assemblies of the Generic Kernel Image (GKI) kernel will be offered, as close as possible to the usual 5.10 kernel. For these assemblies, a regular release of updates will be provided, which will be placed in the ci.android.com repository. In the GKI kernel, Android-specific additions, as well as hardware-related handlers from OEMs, are moved into separate kernel modules. These modules are not tied to the main kernel version and can be developed separately, which greatly simplifies the maintenance and transfer of devices to new kernel branches.
The interfaces necessary for device manufacturers are implemented in the form of hooks that allow you to change the behavior of the kernel without making changes to the code. In total, the android12-5.10 kernel offers 194 conventional hooks similar to tracepoints, and 107 specialized hooks that allow you to run handlers in a non-atomic context. In the GKI kernel, hardware manufacturers are prohibited from applying specific patches to the main kernel, and components for supporting hardware must be supplied by vendors only in the form of additional kernel modules, in which compatibility with the main kernel must be ensured.
Recall that the Android platform develops its own kernel branch – the, on the basis of which separate specific assemblies are formed for each device. Each Android branch provides manufacturers with multiple kernel layouts for their devices. For example, Android 11 offered a choice of three base kernels at once – 4.14, 4.19 and 5.4, and for Android 12, the base kernels 4.19, 5.4 and 5.10 will be offered. Variant 5.10 is designed as a Generic Kernel Image, in which the capabilities necessary for OEMs are transferred to the upstream, moved to modules or transferred to the Android Common Kernel.
Before the advent of GKI, the core for Android went through several stages of preparation:
- On the basis of the main LTS kernels (3.18, 4.4, 4.9, 4.14, 4.19, 5.4), a fork of the ” ” was created, into which patches specific to Android were transferred (previously, the size of changes reached several million lines).
- Based on the Android Common Kernel, chip makers such as Qualcomm, Samsung, and MediaTek have formed the SoC Kernel, which includes add-ons to support hardware.
- Based on the “SoC Kernel”, device manufacturers created the “Device Kernel”, including changes related to support for additional equipment, screens, cameras, sound systems, etc.
This approach significantly complicated the delivery of updates with the elimination of vulnerabilities and the transition to new branches of the kernel. While Google regularly releases updates to its Android Common Kernel, vendors are often slow to ship these updates, or use a single kernel altogether throughout the device’s lifecycle.