[ASUS ZenFone 6 (2019) ROMs, Kernels, Recoveries, &] Freak07:
Kirisakura-Kernel for the Asus Zenfone 6

Hello everyone,

After rising to the most popular Kernel on Pixel 3/XL, here it is for the Asus Zenfone 6!

Kirisakura - Kernel is designed to bring a handful of beneficial features to the device, while ensuring excellent performance and smoothness to get you safely through the day!

This project aims to keep most of the subsystems updated, way ahead of the stock kernel, thereby improving security and performance, while keeping stability as the foucs during testing! This includes Linux-Stable, CAF-Upstream and kernel/common.

Kernel Control Flow Integrity (Kernel-CFI), which is achieved by linking the kernel with LLD and Link Time Optimization (LTO), more precisely ThinLTO, are quite unique security features. In fact this, alongside Kirisakura-Kernel for the OnePlus 8 Pro, may be (and probably is) the first 4.19 msm kernel with a fully working Kernel-CFI implementation and CFI-Violations fixed on a smartphone.

The only kernels made by OEMs offering this security feature are the ones for the Pixel 3, 4 and 5 devices.

The recently released Kirisakura-Kernel for the OnePlus 8 Pro was featured on the XDA-Portal due to the inclusion of CFI. The featured article explains CFI in great details, is easy to understand and definitely worth to read.

Another security feature is Shadow Call Stack (SCS). Similar to CFI, only the Pixel 3, 4 and 5 kernels use this security feature.

SCS is another security patchset that is aimed at preventing attacks via return oriented programming (ROP).

ROP is a technique where the attacker gains control of the kernel stack to overwrite function return addresses and redirect execution to carefully selected parts of existing kernel code.

If you´re interested here are a few good links:

Google Security Blog explaining SCS.

LLVM doc about SCS

Android DOCs documenting SCS

If reading about upstream in the paragraph above got you curious,have a read about Linux-Stable and why it is important here. The stable-process is not the same for every subsystem, but the general idea, rule of thumb and benefits are applicable for other subsystems as well.

Quick explanation of CAF-Upstream. CAF is short for Codeaurora-Forums. This is the place where development from Qualcomm for their SoCs happens. This includes the Snapdragon 855/+ that´s built into the different SKUs of the Zenfone 6.

The kernel-bases available on the Codeaurora-Forums, are basically the foundations OEMs use, to build their own kernel additions on top for devices featuring Qualcomm SoCs.

The Qualcomm developers push regular updates to the bases of the different SoCs, a bit similar to how Linux-Upstream works. OEMs usually stop updating the initial base after the phone is released.

This kernel focuses amongst the other features to provide the latest CAF-Updates merged in a regular manner, to provide updates, improvements and enhancements for SoC specific drivers and subsystems! This might take a while, because a lot of device specific testing is done on my end to ensure stability.

The kernel includes a lot of improvements and contributions from other developers as well. Without this kernel would not exist.

Many of the improvements originate from @arter97´s, @kdrag0n´s and @Sultanxda´s work. Many others contributed in some way or another to this kernel.

A big thanks to all of them at this place!

Now lets continue with a list of features in the next paragraph!

Main Features:

- Based on latest kernel sources from Asus for Android 11

- Upstreamed against latest CAF

- Linux-Stable-Upstream included to latest 4.14.220

- compiled with Clang 11.0.1 prebuilt from Google

- Link-Time-Optimization (LTO)

- Kernel Control-Flow-Integration (CFI) and Link-Time-Optimization (LTO) ported from 4.19 kernel/common

- Shadow Call Stack (SCS) Security-Feature

- Use ThinLTO which was first used in the Pixel 4 XL Android R-Preview Kernel instead of full LTO for full program visibility (needed by CFI)

- fix CFI-Violations found in various subsystems like Asus/device specific drivers and qualcomm drivers

- Link the kernel with LLD and use RELR-Relocation

- include important fixes/improvements from kernel/common

- Flashing the kernel will keep root!

- Anykernel zip is based on the all new Anykernel3 release from @osm0sis

- include vDSO 32 patches to improve 32-bit performance

- disable various debugging configs, that are not needed in a perf build kernel according to google.

- disable selinux auditing (we don´t have to adress selinux denials running a stock rom)

EAS related features:

- backported scheduler from sd865

- disable autogroups and use cgroups for more efficient task placement!

- disable core_ctl for improved task placement and load balancing

- updates from kernel/common

- scheduler updates from Googles Pixel kernel

CPU related features:

- Power saving workingqueues enabled by default (toggleable in EXKM)

have a read here: https://lwn.net/Articles/731052/

this complements EAS in general

- Change various drivers ( MM, audio) to user power efficient workingqueues. This should work well in conjunction with EAS

- include cpuidle patches from CAF

- improvements to cpufreq/times/stats

- improve memory allocations in binder driver

- vdso32 patches as found on Google Pixel devices (brief documentation here)

File System related features:

- Set the bio REQ_NOENCRYPT flag (When lower layers such as dm-crypt observe the REQ_NOENCRYPT flag, it helps the I/O stack avoid redundant encryption, improving performance and power utilization. ) (CAF default)

- improve memory allocations in sdcardfs

- improve eventpoll logging to stop indicting timerfd (improves kernel wakelock readability)

- improve memory allocations in kernfs

- writeback: hardcode dirty_expire_centisecs=3000 based on this commit

- ufs improvements from pixel 4/ pixel 5 kernel

GPU related features:

- KCAL to control the display

- KLAPSE integrated

- KCAL/KLAPSE: changes safety measures -> allow completely disabling two RGB values (this was requested to, for example, only have red values on night dimming)

Network related features:

- Wireguard Support (Details)

- advanced TCP algorithms enabled

- includes new bbr and bbrv2

Memory related features:

- Memory Management patches from mainline kernel

- Speculative Page Faults (1. 2)

- Fix various memory leaks in different subsystems

- Reap memory of a task that receives sigkill

- enabled per process reclaim

- allow ZRAM to use higher swappiness values than 100

- possibility to use lzo-rle as default ZRAM compression algorithm (more information here and there )

Security related features:

- Control-Flow-Integration (CFI) and Link-Time-Optimization (LTO) ported from 4.19 kernel/common and Pixel 4/XL Kernel

- Use ThinLTO which was first used in the Pixel 4 XL Android R-Kernel instead of full LTO

- Shadow Call Stack (SCS) Security-Feature

- fix various CFI-Violations found in various subsystems like Asus/device specific drivers and qualcomm drivers

- enable init_on_alloc for even more security, more information can be found in the commit message

WLAN Driver

- use CAF wlan driver and compile it inline, the only way to ensure working wlan with this kernel

- the kernel cannot even force load prebuild WLAN module as the kernel base is way to far from stock!

- do no longer rely on the pre compiled wlan driver module

- completely removed qcom_rx wakelock in the wlan driver

- removed debugging from wlan driver

- removed logging from wlan driver

Magisk Companion Module

- set kernel settings like I intend them to be :)

Misc Features:

Wakelock Blocker:

- advanced wakelock blocker with the ability to block any wakelocks (dangerous, use with caution)

- please read [URL="https://arstechnica.com/gadgets/2018/08/p-is-for-power-how-google-tests-tracks-and-improves-android-battery-life/"]this for further info

- blocking a kernel wakelock should only be done in case of firmware incompatabilities (WiFi network at work (can´t be changed) causes deep sleep to not work on the phone.) That´s the only use case I see for this feature. The kernel does not features this to improve battery life!

Other features:

- disable logging to make the kernel more lightweight in various places

- fix several coding issues detected by newer Clang-Toolchains

- add support for steam controller

- add support for nintendo switch controller

- ufs improvements from pixel 4/ pixel 5 kernel

- gpu/kgsl improvements from pixel 4/pixel 5 kernel

Feature section for the "non visible" but perceptible improvements:

- updated binder section (responsible for interprocess communication)

- updated sdcardfs ; have a read about it here:

Requirements

- unlocked Bootloader

- USB-Debugging in developer options enabled

- latest adb and fastboot binaries

- working adb and fastboot environment

- magisk root

How to flash the Kernel:

1. Download the latest kernel.zip

1a. Optional: While it may not be necessary all times, you may want to restore stock boot.img, re-root with magisk and optionally install twrp.zip if coming from another kernel. Before reporting issues make sure you do that! Thank you!

2. Make sure to use latest Magisk stable. (not the latest canary!)

3. Flash the kernel.zip via latest EXKM or FKM app. Alternatively via TWRP.

4. Reboot and profit.

DOWNLOAD:

Download is located always in this folder:

Downloads for : -Android- Generic Device/Other | AndroidFileHost.com | Download GApps, Roms, Kernels, Themes, Firmware and more. Free file hosting for all Android developers.

Download GApps, Roms, Kernels, Themes, Firmware, and more. Free file hosting for all Android developers.

androidfilehost.com

Important: Read after Download

Please take a look at the second post after flashing the kernel!

Changelog:

Android 9/Pie

1.0.0 Initial Release

1.3.0 https://xdaforums.com/showpost.php?p=79852192&postcount=21

1.5.0 https://xdaforums.com/showpost.php?p=79948337&postcount=36

1.6.0 https://xdaforums.com/showpost.php?p=80037776&postcount=46

1.8.1 https://xdaforums.com/showpost.php?p=80275065&postcount=58

3.0.0 https://xdaforums.com/showpost.php?p=80712703&postcount=66

Android 10/Q

1.0.0_Q https://xdaforums.com/showpost.php?p=81368413&postcount=73

1.0.3_Q https://xdaforums.com/showpost.php?p=82387237&postcount=86

1.2.0_Q https://xdaforums.com/showpost.php?p=83920653&postcount=92

Android 11/R

1.0.1_R https://xdaforums.com/t/kernel-andr...sus-zenfone-6-aka-kirin.3940178/post-84526765

Donations:

Donations are not mandatory but very welcome if you want to support development or just buy me a coffee :)

If you like my work: http://paypal.me/freak07

Credits:

Asus for the Zenfone 6!

@osm0sis for all his work, including the ak2 installer!

@tbalden for being the best HTC wingman!

@LeeDroid for his awesome roms!

@Captain_Throwback for all the mentoring and guidance!

@Eliminater74 for bringing me into the game and the Inspiration

@nathanchance for his upstream guidance and assistance

@RenderBroken for helping me out

@flar2 for all his work

@joshuous for all the help he provided to me in the past!

@arter97 for giving me advice

@topjohnwu for magisk!

@osm0sis for anykernel!

XDA:DevDB Information

Kirisakura-Kernel, Kernel for the ASUS ZenFone 6 (2019)

Contributors

Freak07

Source Code: https://github.com/freak07/Kirisakura_Kirin

Version Information

Status: Stable