Development [Kernel][11.06.2023][Android 13] Kirisakura 3.0.2_T for Asus Zenfone 8 aka "Sake"

Search This thread

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
6,432
22,999
Kirisakura-Kernel for the Asus Zenfone 8

Hello everyone,

To keep it short: Here is Kirisakura - Kernel for the Asus Zenfone 8 aka Sake. The Zenfone line-up internal codenames are traditionally derived from alcoholic drinks. Two years ago the Zenfone 6 bore the title "Kirin". The Zenfone 7 was codenamed "Tequila".
I would appreciate if everybody that flashes the kernel, reads at least once through this opening post and the following ones.

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!
If you expect a custom kernel to magically improve your devices battery life manifold and this is your only priority then this might not be the right place for you.
However the kernel is built to keep battery life close to the same as you would experience the on stock kernel while being tuned to perform better in various UI related benchmarks. The same benches are used by google to verify and ensure UI smoothness on the Pixel devices. The scheduler is tuned to yield lower jitter and reduce jank frames.
If that got your curious, I welcome you to continue reading if you´re still interested!


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.


A very positive development. Google pushed for CFI and SCS to be enabled by default in the android-common kernel. In this years generation ( 5.4 linux kernel base/ SD 888 ) CFI and SCS are enabled by default. It was a lot of work to get these features working nicely on the kernel I did the years back. So it´s nice to see this is now there by default in everybody can profit from it.
I put the explanations and links in hide tags here.

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.
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.
If possible the latest Kirisakura-Kernel releases for various devices aim to include CFI in enforcing mode so users can benefit from this security features.

Another security feature is Shadow Call Stack (SCS).
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.
Read more about the Release-Model following this link.
This conversation on the LKML mailing list also shows the power of Linux-Stable and why it´s very beneficial to not just say it´s not worth and a potentiol source for bugs:
Starting with the Initial Message , the following reply and a good summarizing statement.



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 888 that´s built into the different SKUs of the Zenfone 8.
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.
A big part of 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 13 and intended to be used on the latest Asus Stock-Firmware
- compiled with Clang 14.0.7 and built with -O3 speed optimizations
- Linux-Stable-Upstream included to 5.4.231
- upstreamed CAF base for the Snapdragon 888 (qcoms internal codename "lahaina")
- include important fixes/improvements from kernel/common
- tune scheduler for improved jitter and less jank frames
- reduce power consumption during deep sleep
- remove logging while device is suspended
- remove sleep debugging from Asus for release build
- disable various debugging mechanisms for drivers which are not needed on a perf build (for example touchscreen, fingerprint reader, display, binder)
- disable various debugging configs, that are not needed in a perf kernel build according to google.
- disable selinux auditing (we don´t have to adress selinux denials running a stock rom)
- display tweaks to reduce power consumption on statically rendered images
- disable unnecessary CPU errata for our specific SoC
- disable per cgroup pressure tracking to reduce overhead
- SSG IO scheduler for reduced overhead and less CPU cycles (more lightweight and android optimized)
- free up RAM by removing reserved mem regions used only for debugging
- implement LRNG (thanks @arter97, see arter kernel OP for more info )
- Flashing the kernel will keep root!
- Flashable via EXKM, FKM or TWRP (if available) on a rooted system!
- Anykernel zip is based on the Anykernel3 release from @osm0sis


EAS related features:
- Implement dynamic WALT-Window size depending on current FPS, collecting information about CPU-Load to provide more precise information for the scheduler
- EAS implementation patched up to latest CAF state
- updates from kernel/common
- scheduler updates from sd888/ 5.4 kernel
- scheduler update from sony xperia 1 III kernel aiming to improve WALT

CPU related features:
- Power saving workingqueues enabled by default (toggleable in EXKM)
- Change various drivers (WLAN, MM, audio, charger, power, thermal, glink etc) to use power efficient workingqueues. This compliments EAS in general
- improvements to cpufreq/times/stats
- vdso32 patches as found on Google Pixel devices (brief documentation here) (CAF 5.4 default, keep for documentation)
- remove event debug logging
- disable broken irq detection, disable debugmon
- improve suspend/resume from audio driver (caf-upstream for audio-kernel)
- cpuidle: wake only cpus for which qos has changed (this allows cores to keep idle states better)
- disable debugging during sleep states as per qcom recommendation
- remove RTB logging to reduce overhead
- disable trace_printk as it shouldn´t be used on production/perf kernel builds
- enable suspend_skip_sync to save power during suspend/resume
- disable edac and coresight (following google on the pixel kernels)
- disable jtagv8 debugging as recommended by qcom for perf builds to avoid potential power, performance and memory penalty
- disable s2idle in favor of deep idle state -> improves deep sleep drain (google initially used 2idle for improved suspend/resume latency on pixel 3 and pixel 4, but disabled it on pixel 5. qcom followed suit for sd 888, but apparently didn´t see google reverting it on pixel 5. Other OEMs such as Xiaomi or OnePlus already disabled s2idle on their SD888 devices in favor of deep- read more about s2idle vs deep here)

GPU related features:
- GPU driver updated to latest CAF-State
- gpu/kgsl improvements from pixel 4/pixel 5 kernel
- add low_prio_worker thread for gpu driver (Improves performance when tearing down processes (eg, via LMK) and not blocking currently running UI from submitting work to the GPU

File System related features:
- upstream BFQ-MQ to latest state in linux-mainline and default to 128KB readahead
- improve memory allocations in kernfs
- ufs improvements from pixel 4/ pixel 5 kernel
- improve GC as to not interfere while user interaction is happening and prevent possible jitter or latency spikes

UI/UX/Usability related features from CleanSlate:
- CleanSlate features made by @tbalden
- Disclaimer: All CleanSlate features can be controlled via the free companion and config app found on CleanSlate thread here on the Zenfone 8 Forums on XDA. Please consider buying the premium versions if you enjoy using the CleanSlate features, to give a little something back to @tbalden.

Network related features:
- Wireguard Support (Details)
- advanced TCP algorithms enabled
- use bbr as default TCP congestion algorithm (fasted algo according to this excellent research from @kdrag0n found here )
- includes new bbr
- improved networking drivers from caf-upstream (especially wifi)
- remove unnecessary wakelock from WLAN driver to reduce thousands of very short wakeups during a 7 hour deep sleep period
- improved bluetooth performance (¹, ²)
- Enable support for TTL spoofing

Memory related features:
- Speculative Page Faults left enabled (1. 2) (CAF 5.4 default, keep for documentation)
- Fix various memory leaks in different subsystems
- improved mm with patches from mainline
- patches from kernel/common
- improve memory allocations in various subsystems, video encode/decode, kernfs, cgroup
- Backport to enable CONFIG_HAVE_MOVE_PMD (see here) , thanks @arter97
- Backport to enable CONFIG_HAVE_MOVE_PUD (commit here) , thanks @arter97
- free more RAM by removing unused reserved memory regions
- mm: Micro-optimize PID map reads for arm64 (improves game performance, especially unity based games such as genshin impact)
- MGLRU added (info here and here

Security related features:
- Control-Flow-Integration (CFI) and Link-Time-Optimization (LTO) (CAF 5.4 default, keep for documentation)
- Use ThinLTO which was first used in the Pixel 4 XL Android R-Kernel instead of full LTO (CAF 5.4 default, keep for documentation)
- Shadow Call Stack (SCS) Security-Feature ( 5.4 default, keep for documentation)
- enable init_on_alloc for even more security, more information can be found in the commit message (CAF 5.4 default, keep for documentation)


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:
- clean up asus drivers and fix a few warnings in kernel log
- disable logging and debugging to make the kernel more lightweight in various places (includes binder, mm, vma, gpu, ipa etc)
- fix several coding issues detected by newer Clang-Toolchains
- enlarge dmesg size to ease debugging


Flashing Guide, Download and Changelog

Requirements:
- unlocked Bootloader (this will void warranty and kill future OTA updates on all asus phones at the moment)
- USB-Debugging in developer options enabled
- latest adb and fastboot binaries
- working adb and fastboot environment
- magisk root
- a backup of stock boot.img, vendor_boot.img and dtbo.img so you can go back to stock conditions (simplest way is TWRP or to extract from stock firmware)

How to flash the Kernel:
1. Download the latest kernel.zip and make sure you have properly updated to the latest matching Asus Stock-Firmware. When the Zenfone 8 receives an OTA update it takes Asus a while to release the source code for the new OS and me a while to build a new kernel. If you don´t want to face any issues, wait until I either release an updated kernel or give green light because there were no kernel changes.
Always make sure to run the firmware the kernel is built for!
If you feel adventurous and try in advance, make sure you have a backup ready!

2. Flash the kernel.zip via latest TWRP (if available), EXKM or FKM app and do a full reboot.

3. Reboot and profit.


DOWNLOAD:
Download is located always in this folder:

Important: Read after Download
Please take a look at the second post after flashing the kernel!

Changelog:
Android 11

1.0.0 Initial Release
1.0.3 https://xdaforums.com/t/kernel-22-0...asus-zenfone-8-aka-sake.4295287/post-85230887
1.1.8 https://xdaforums.com/t/kernel-24-0...asus-zenfone-8-aka-sake.4295287/post-85369421
1.3.1 https://xdaforums.com/t/kernel-23-0...asus-zenfone-8-aka-sake.4295287/post-85471991
1.4.7 https://xdaforums.com/t/kernel-13-0...asus-zenfone-8-aka-sake.4295287/post-85580815
1.5.1 https://xdaforums.com/t/kernel-04-0...asus-zenfone-8-aka-sake.4295287/post-85708459
1.7.5 https://xdaforums.com/t/kernel-30-0...asus-zenfone-8-aka-sake.4295287/post-85845707
1.7.8 https://xdaforums.com/t/kernel-28-1...asus-zenfone-8-aka-sake.4295287/post-85845707
1.7.9 https://xdaforums.com/t/kernel-25-1...asus-zenfone-8-aka-sake.4295287/post-86004361

Android 12
1.0.0 https://xdaforums.com/t/kernel-26-1...asus-zenfone-8-aka-sake.4295287/post-86200913
1.0.1 https://xdaforums.com/t/kernel-04-0...asus-zenfone-8-aka-sake.4295287/post-86219239
1.0.2 https://xdaforums.com/t/kernel-07-0...asus-zenfone-8-aka-sake.4295287/post-86221081
1.0.8 https://xdaforums.com/t/kernel-07-0...asus-zenfone-8-aka-sake.4295287/post-86546997

2.0.0 https://xdaforums.com/t/kernel-07-0...asus-zenfone-8-aka-sake.4295287/post-86856077
2.0.1 https://xdaforums.com/t/kernel-07-0...asus-zenfone-8-aka-sake.4295287/post-87005047
2.0.2 https://xdaforums.com/t/kernel-10-0...asus-zenfone-8-aka-sake.4295287/post-87053951
2.0.8 https://xdaforums.com/t/kernel-21-0...asus-zenfone-8-aka-sake.4295287/post-87244107
2.0.10 https://xdaforums.com/t/kernel-05-0...asus-zenfone-8-aka-sake.4295287/post-87432111
2.0.12 https://xdaforums.com/t/kernel-14-0...asus-zenfone-8-aka-sake.4295287/post-87641841
2.0.15 https://xdaforums.com/t/kernel-28-1...asus-zenfone-8-aka-sake.4295287/post-87944971

Android 13
3.0.0 https://xdaforums.com/t/kernel-04-0...asus-zenfone-8-aka-sake.4295287/post-88195025
3.0.1 https://xdaforums.com/t/kernel-23-0...asus-zenfone-8-aka-sake.4295287/post-88326835
3.0.2 https://xdaforums.com/t/kernel-24-0...asus-zenfone-8-aka-sake.4295287/post-88632657


Donations:
Donations are not mandatory but very welcome if you want to support development or just buy me a coffee/tea :)
If you like my work: http://paypal.me/freak07

Credits:
Asus for the development device, giving me the opportunity to create this project!
@osm0sis for all his work, including the ak3 installer!
@tbalden for being the best HTC, Pixel, OnePlus and now Asus wingman!
@LeeDroid and @mwilky for their awesome roms and work I used on multiple devices!
@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
@kdrag0n for his help and advices!
@topjohnwu for magisk!


Source Code: https://github.com/freak07/Kirisakura_SAKE_Zenfone_8
 
Last edited:

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
6,432
22,999
F.A.Q:

Question:
Is root preserved when flashing this kernel?
Answer: Yes, the AnyKernel.zip will detect root and keep it.

Question: How do I return back to stock or another kernel.
Answer: Extract boot.img, vendor_boot.img as well as dtbo.img from matching firmware you are on and flash them via fastboot. If you want to keep root flash back the magisk_patched_boot.img. Or dirty flash your rom and re-root.

Question: Why is having Magisk installed mandatory for this kernel?
Answer: The kernel uses a ramdisk overlay to apply some settings after boot. If you are not rooted these settings will not get applied and you miss some of the optimizations.

Question: How to report bugs properly?
Answer: Have a look at post #3 in the linked thread. The linked guide is a pretty good starting point.
Before reporting any bug make sure you´re running on a stock configuration. That´s means you´re not using any mods, tweaks in kernel managers or other root tweaks , magisk modules, scripts or other modifications that alter various functions like sound mods, data traffic, sleeping behaviour, scheduler, magical battery tweaks etc.
Try to describe the issue as detailed as possible! Give your exact setup, like rom, magisk version, kernel version.
Is the issue reproducible? Does it happen frequently?
Provide logs, otherwise debugging is a lot harder. If you can already reproduce the issue and provide logs it greatly limits the amount of time I have to spent until I figure out how to reproduce it.

If the device force reboots/randomly reboots (that means you see the bootloader unlocked screen!) provide a .zip of /asdf.
Easiest way is immediately after booting up, with a root explorer navigate to /asdf. Copy the contents to your internal storage, zip it up and send it to me.

If the issue happens while the device is running provide a dmesg plus a logcat that you take while/shortly after the issue happens. This will log what´s running in the current session. Try to be as detailed as possible what´s happening when the issue appears. It will also help me in reading the log!
 
Last edited:

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
6,432
22,999
Update to 1.0.3

Hey guys and girls,


I hope everyone is having a good day or starting into one. Here´s the next update.
The kernel is updated for the latest firmware:
30.11.51.67. Make sure to update to the latest firmware before flashing the kernel to have no compatibility issues.

The link to the firmware can be found here:

md5sum: 0f30d5e043f4a675e7db3250d5218125


More changes in the Changelog below:


Changelog:
- Import zenfone8_zs590ks.MR0.4-30.11.51.67 source code
- Linux-Stable Upstream to 5.4.128
- bump clang to latest prebuilt clang by google (12.0.7)




Download:



Instructions can be found in the OP!
But look at this post too :)

Have fun, enjoy the kernel and your phone.

Donations are not mandatory but very welcome.
If you like my work and want to buy me a coffee/green tea to keep development going: http://paypal.me/freak07
 

a7lanov

Member
Mar 13, 2015
17
9
Update to 1.0.3

Hey guys and girls,


I hope everyone is having a good day or starting into one. Here´s the next update.
The kernel is updated for the latest firmware:
30.11.51.67. Make sure to update to the latest firmware before flashing the kernel to have no compatibility issues.

The link to the firmware can be found here:

md5sum: 0f30d5e043f4a675e7db3250d5218125


More changes in the Changelog below:


Changelog:
- Import zenfone8_zs590ks.MR0.4-30.11.51.67 source code
- Linux-Stable Upstream to 5.4.128
- bump clang to latest prebuilt clang by google (12.0.7)




Download:



Instructions can be found in the OP!
But look at this post too :)

Have fun, enjoy the kernel and your phone.

Donations are not mandatory but very welcome.
If you like my work and want to buy me a coffee/green tea to keep development going: http://paypal.me/freak07
Hello. I tried this kernel recently. But now I want to return to the stock core. But when I flash boot.img and dtbo.img, the settings stop working for me. There are also no items in Quick Settings. What am I doing wrong?
 

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
6,432
22,999
Hello. I tried this kernel recently. But now I want to return to the stock core. But when I flash boot.img and dtbo.img, the settings stop working for me. There are also no items in Quick Settings. What am I doing wrong?
Hey,


I forgot to mention to restore vendor_boot.img as well.
Sorry for the inconvenience, I adjusted the OP and the FAQ already.

So to get back to stock, extract boot.img, vendor_boot.img and dtbo.img from the matching stock firmware.zip. make sure you extract from the same firmware you're currently running.

Then flash these via fastboot.

If it doesn't work afterwards your problem lies elsewhere.
 

a7lanov

Member
Mar 13, 2015
17
9
Hey,


I forgot to mention to restore vendor_boot.img as well.
Sorry for the inconvenience, I adjusted the OP and the FAQ already.

So to get back to stock, extract boot.img, vendor_boot.img and dtbo.img from the matching stock firmware.zip. make sure you extract from the same firmware you're currently running.

Then flash these via fastboot.

If it doesn't work afterwards your problem lies elsewhere.
Thank you. Today I will also try to flash the vendor_boot.img
 
  • Like
Reactions: Freak07

assasss

Member
Jun 14, 2012
44
13
Google Pixel
Google Pixel 3
Hi @Freak07 ,

Thanks a lot for your effort and time that you invested into developing this kernel.

However, as is the case with other custom kernels, I would like to know what kind of battery life benefits I can expect from using this kernel on my device?

Unlocking the bootloader on Asus phones right now means a bit more hassle with the updates, also rooting the phone means a bit more hassle with using some apps (safety net etc),so I would really like to know what are the benefits in terms of battery life.
 

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
6,432
22,999
Update to 1.1.8

Hey guys and girls,


I hope everyone is having a good day or starting into one. Here´s the next update.
The kernel is updated for the latest firmware:
30.11.51.83. Make sure to update to the latest firmware before flashing the kernel to have no compatibility issues.

The link to the firmware can be found here:

md5sum: 0f30d5e043f4a675e7db3250d5218125


More changes in the Changelog below:


Changelog:
- Import zenfone8_zs590ks.MR0.5-30.11.51.83 source code
- Linux-Stable Upstream to 5.4.134
- bump clang to latest prebuilt clang by google
- Merge CAF (QCOM) upstream
- enable ddr cooling device
- raise lto inlining limit
- other improvements please take a look at github




Download:



Instructions can be found in the OP!
But look at this post too :)

Have fun, enjoy the kernel and your phone.

Donations are not mandatory but very welcome.
If you like my work and want to buy me a coffee/green tea to keep development going: http://paypal.me/freak07
 

a7lanov

Member
Mar 13, 2015
17
9
Update to 1.1.8

Hey guys and girls,


I hope everyone is having a good day or starting into one. Here´s the next update.
The kernel is updated for the latest firmware:
30.11.51.83. Make sure to update to the latest firmware before flashing the kernel to have no compatibility issues.

The link to the firmware can be found here:

md5sum: 0f30d5e043f4a675e7db3250d5218125


More changes in the Changelog below:


Changelog:
- Import zenfone8_zs590ks.MR0.5-30.11.51.83 source code
- Linux-Stable Upstream to 5.4.134
- bump clang to latest prebuilt clang by google
- Merge CAF (QCOM) upstream
- enable ddr cooling device
- raise lto inlining limit
- other improvements please take a look at github




Download:



Instructions can be found in the OP!
But look at this post too :)

Have fun, enjoy the kernel and your phone.

Donations are not mandatory but very welcome.
If you like my work and want to buy me a coffee/green tea to keep development going: http://paypal.me/freak07
Hi. Thanks. And I have a question. I noticed through the Kernel Adiutor that big and prime cpu do not sleep when there is no load, they work at low frequency (original kernel). Is this a hotplug problem? Should they not go to Offline? Do they sleep in your kernel?
 

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
6,432
22,999
Hi. Thanks. And I have a question. I noticed through the Kernel Adiutor that big and prime cpu do not sleep when there is no load, they work at low frequency (original kernel). Is this a hotplug problem? Should they not go to Offline? Do they sleep in your kernel?
That´s expected behaviour on the few last gens of QCOM SoCs. and you´re also fooled by the ui of the app. :)

if there are no tasks/work the clusters go into idle c-states, but kernel managers/monitors will show you the frequency that you described.
depeding which battery mode you chose in settings, minfreqs for the clusters will be higher or lower.
dynamic should be at 300mhz for little cluster, 710mhz for big cores and and 844mhz for the prime core.
 
  • Like
Reactions: dron39 and a7lanov

Top Liked Posts

  • There are no posts matching your filters.
  • 23
    Kirisakura-Kernel for the Asus Zenfone 8

    Hello everyone,

    To keep it short: Here is Kirisakura - Kernel for the Asus Zenfone 8 aka Sake. The Zenfone line-up internal codenames are traditionally derived from alcoholic drinks. Two years ago the Zenfone 6 bore the title "Kirin". The Zenfone 7 was codenamed "Tequila".
    I would appreciate if everybody that flashes the kernel, reads at least once through this opening post and the following ones.

    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!
    If you expect a custom kernel to magically improve your devices battery life manifold and this is your only priority then this might not be the right place for you.
    However the kernel is built to keep battery life close to the same as you would experience the on stock kernel while being tuned to perform better in various UI related benchmarks. The same benches are used by google to verify and ensure UI smoothness on the Pixel devices. The scheduler is tuned to yield lower jitter and reduce jank frames.
    If that got your curious, I welcome you to continue reading if you´re still interested!


    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.


    A very positive development. Google pushed for CFI and SCS to be enabled by default in the android-common kernel. In this years generation ( 5.4 linux kernel base/ SD 888 ) CFI and SCS are enabled by default. It was a lot of work to get these features working nicely on the kernel I did the years back. So it´s nice to see this is now there by default in everybody can profit from it.
    I put the explanations and links in hide tags here.

    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.
    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.
    If possible the latest Kirisakura-Kernel releases for various devices aim to include CFI in enforcing mode so users can benefit from this security features.

    Another security feature is Shadow Call Stack (SCS).
    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.
    Read more about the Release-Model following this link.
    This conversation on the LKML mailing list also shows the power of Linux-Stable and why it´s very beneficial to not just say it´s not worth and a potentiol source for bugs:
    Starting with the Initial Message , the following reply and a good summarizing statement.



    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 888 that´s built into the different SKUs of the Zenfone 8.
    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.
    A big part of 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 13 and intended to be used on the latest Asus Stock-Firmware
    - compiled with Clang 14.0.7 and built with -O3 speed optimizations
    - Linux-Stable-Upstream included to 5.4.231
    - upstreamed CAF base for the Snapdragon 888 (qcoms internal codename "lahaina")
    - include important fixes/improvements from kernel/common
    - tune scheduler for improved jitter and less jank frames
    - reduce power consumption during deep sleep
    - remove logging while device is suspended
    - remove sleep debugging from Asus for release build
    - disable various debugging mechanisms for drivers which are not needed on a perf build (for example touchscreen, fingerprint reader, display, binder)
    - disable various debugging configs, that are not needed in a perf kernel build according to google.
    - disable selinux auditing (we don´t have to adress selinux denials running a stock rom)
    - display tweaks to reduce power consumption on statically rendered images
    - disable unnecessary CPU errata for our specific SoC
    - disable per cgroup pressure tracking to reduce overhead
    - SSG IO scheduler for reduced overhead and less CPU cycles (more lightweight and android optimized)
    - free up RAM by removing reserved mem regions used only for debugging
    - implement LRNG (thanks @arter97, see arter kernel OP for more info )
    - Flashing the kernel will keep root!
    - Flashable via EXKM, FKM or TWRP (if available) on a rooted system!
    - Anykernel zip is based on the Anykernel3 release from @osm0sis


    EAS related features:
    - Implement dynamic WALT-Window size depending on current FPS, collecting information about CPU-Load to provide more precise information for the scheduler
    - EAS implementation patched up to latest CAF state
    - updates from kernel/common
    - scheduler updates from sd888/ 5.4 kernel
    - scheduler update from sony xperia 1 III kernel aiming to improve WALT

    CPU related features:
    - Power saving workingqueues enabled by default (toggleable in EXKM)
    - Change various drivers (WLAN, MM, audio, charger, power, thermal, glink etc) to use power efficient workingqueues. This compliments EAS in general
    - improvements to cpufreq/times/stats
    - vdso32 patches as found on Google Pixel devices (brief documentation here) (CAF 5.4 default, keep for documentation)
    - remove event debug logging
    - disable broken irq detection, disable debugmon
    - improve suspend/resume from audio driver (caf-upstream for audio-kernel)
    - cpuidle: wake only cpus for which qos has changed (this allows cores to keep idle states better)
    - disable debugging during sleep states as per qcom recommendation
    - remove RTB logging to reduce overhead
    - disable trace_printk as it shouldn´t be used on production/perf kernel builds
    - enable suspend_skip_sync to save power during suspend/resume
    - disable edac and coresight (following google on the pixel kernels)
    - disable jtagv8 debugging as recommended by qcom for perf builds to avoid potential power, performance and memory penalty
    - disable s2idle in favor of deep idle state -> improves deep sleep drain (google initially used 2idle for improved suspend/resume latency on pixel 3 and pixel 4, but disabled it on pixel 5. qcom followed suit for sd 888, but apparently didn´t see google reverting it on pixel 5. Other OEMs such as Xiaomi or OnePlus already disabled s2idle on their SD888 devices in favor of deep- read more about s2idle vs deep here)

    GPU related features:
    - GPU driver updated to latest CAF-State
    - gpu/kgsl improvements from pixel 4/pixel 5 kernel
    - add low_prio_worker thread for gpu driver (Improves performance when tearing down processes (eg, via LMK) and not blocking currently running UI from submitting work to the GPU

    File System related features:
    - upstream BFQ-MQ to latest state in linux-mainline and default to 128KB readahead
    - improve memory allocations in kernfs
    - ufs improvements from pixel 4/ pixel 5 kernel
    - improve GC as to not interfere while user interaction is happening and prevent possible jitter or latency spikes

    UI/UX/Usability related features from CleanSlate:
    - CleanSlate features made by @tbalden
    - Disclaimer: All CleanSlate features can be controlled via the free companion and config app found on CleanSlate thread here on the Zenfone 8 Forums on XDA. Please consider buying the premium versions if you enjoy using the CleanSlate features, to give a little something back to @tbalden.

    Network related features:
    - Wireguard Support (Details)
    - advanced TCP algorithms enabled
    - use bbr as default TCP congestion algorithm (fasted algo according to this excellent research from @kdrag0n found here )
    - includes new bbr
    - improved networking drivers from caf-upstream (especially wifi)
    - remove unnecessary wakelock from WLAN driver to reduce thousands of very short wakeups during a 7 hour deep sleep period
    - improved bluetooth performance (¹, ²)
    - Enable support for TTL spoofing

    Memory related features:
    - Speculative Page Faults left enabled (1. 2) (CAF 5.4 default, keep for documentation)
    - Fix various memory leaks in different subsystems
    - improved mm with patches from mainline
    - patches from kernel/common
    - improve memory allocations in various subsystems, video encode/decode, kernfs, cgroup
    - Backport to enable CONFIG_HAVE_MOVE_PMD (see here) , thanks @arter97
    - Backport to enable CONFIG_HAVE_MOVE_PUD (commit here) , thanks @arter97
    - free more RAM by removing unused reserved memory regions
    - mm: Micro-optimize PID map reads for arm64 (improves game performance, especially unity based games such as genshin impact)
    - MGLRU added (info here and here

    Security related features:
    - Control-Flow-Integration (CFI) and Link-Time-Optimization (LTO) (CAF 5.4 default, keep for documentation)
    - Use ThinLTO which was first used in the Pixel 4 XL Android R-Kernel instead of full LTO (CAF 5.4 default, keep for documentation)
    - Shadow Call Stack (SCS) Security-Feature ( 5.4 default, keep for documentation)
    - enable init_on_alloc for even more security, more information can be found in the commit message (CAF 5.4 default, keep for documentation)


    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:
    - clean up asus drivers and fix a few warnings in kernel log
    - disable logging and debugging to make the kernel more lightweight in various places (includes binder, mm, vma, gpu, ipa etc)
    - fix several coding issues detected by newer Clang-Toolchains
    - enlarge dmesg size to ease debugging


    Flashing Guide, Download and Changelog

    Requirements:
    - unlocked Bootloader (this will void warranty and kill future OTA updates on all asus phones at the moment)
    - USB-Debugging in developer options enabled
    - latest adb and fastboot binaries
    - working adb and fastboot environment
    - magisk root
    - a backup of stock boot.img, vendor_boot.img and dtbo.img so you can go back to stock conditions (simplest way is TWRP or to extract from stock firmware)

    How to flash the Kernel:
    1. Download the latest kernel.zip and make sure you have properly updated to the latest matching Asus Stock-Firmware. When the Zenfone 8 receives an OTA update it takes Asus a while to release the source code for the new OS and me a while to build a new kernel. If you don´t want to face any issues, wait until I either release an updated kernel or give green light because there were no kernel changes.
    Always make sure to run the firmware the kernel is built for!
    If you feel adventurous and try in advance, make sure you have a backup ready!

    2. Flash the kernel.zip via latest TWRP (if available), EXKM or FKM app and do a full reboot.

    3. Reboot and profit.


    DOWNLOAD:
    Download is located always in this folder:

    Important: Read after Download
    Please take a look at the second post after flashing the kernel!

    Changelog:
    Android 11

    1.0.0 Initial Release
    1.0.3 https://xdaforums.com/t/kernel-22-0...asus-zenfone-8-aka-sake.4295287/post-85230887
    1.1.8 https://xdaforums.com/t/kernel-24-0...asus-zenfone-8-aka-sake.4295287/post-85369421
    1.3.1 https://xdaforums.com/t/kernel-23-0...asus-zenfone-8-aka-sake.4295287/post-85471991
    1.4.7 https://xdaforums.com/t/kernel-13-0...asus-zenfone-8-aka-sake.4295287/post-85580815
    1.5.1 https://xdaforums.com/t/kernel-04-0...asus-zenfone-8-aka-sake.4295287/post-85708459
    1.7.5 https://xdaforums.com/t/kernel-30-0...asus-zenfone-8-aka-sake.4295287/post-85845707
    1.7.8 https://xdaforums.com/t/kernel-28-1...asus-zenfone-8-aka-sake.4295287/post-85845707
    1.7.9 https://xdaforums.com/t/kernel-25-1...asus-zenfone-8-aka-sake.4295287/post-86004361

    Android 12
    1.0.0 https://xdaforums.com/t/kernel-26-1...asus-zenfone-8-aka-sake.4295287/post-86200913
    1.0.1 https://xdaforums.com/t/kernel-04-0...asus-zenfone-8-aka-sake.4295287/post-86219239
    1.0.2 https://xdaforums.com/t/kernel-07-0...asus-zenfone-8-aka-sake.4295287/post-86221081
    1.0.8 https://xdaforums.com/t/kernel-07-0...asus-zenfone-8-aka-sake.4295287/post-86546997

    2.0.0 https://xdaforums.com/t/kernel-07-0...asus-zenfone-8-aka-sake.4295287/post-86856077
    2.0.1 https://xdaforums.com/t/kernel-07-0...asus-zenfone-8-aka-sake.4295287/post-87005047
    2.0.2 https://xdaforums.com/t/kernel-10-0...asus-zenfone-8-aka-sake.4295287/post-87053951
    2.0.8 https://xdaforums.com/t/kernel-21-0...asus-zenfone-8-aka-sake.4295287/post-87244107
    2.0.10 https://xdaforums.com/t/kernel-05-0...asus-zenfone-8-aka-sake.4295287/post-87432111
    2.0.12 https://xdaforums.com/t/kernel-14-0...asus-zenfone-8-aka-sake.4295287/post-87641841
    2.0.15 https://xdaforums.com/t/kernel-28-1...asus-zenfone-8-aka-sake.4295287/post-87944971

    Android 13
    3.0.0 https://xdaforums.com/t/kernel-04-0...asus-zenfone-8-aka-sake.4295287/post-88195025
    3.0.1 https://xdaforums.com/t/kernel-23-0...asus-zenfone-8-aka-sake.4295287/post-88326835
    3.0.2 https://xdaforums.com/t/kernel-24-0...asus-zenfone-8-aka-sake.4295287/post-88632657


    Donations:
    Donations are not mandatory but very welcome if you want to support development or just buy me a coffee/tea :)
    If you like my work: http://paypal.me/freak07

    Credits:
    Asus for the development device, giving me the opportunity to create this project!
    @osm0sis for all his work, including the ak3 installer!
    @tbalden for being the best HTC, Pixel, OnePlus and now Asus wingman!
    @LeeDroid and @mwilky for their awesome roms and work I used on multiple devices!
    @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
    @kdrag0n for his help and advices!
    @topjohnwu for magisk!


    Source Code: https://github.com/freak07/Kirisakura_SAKE_Zenfone_8
    9
    Update to 1.7.5

    Hey guys and girls,


    I hope everyone is having a good day or starting into one. Here´s the next update.
    The kernel is updated for the latest firmware:
    30.12.112.36. Make sure to update to the latest firmware before flashing the kernel to have no compatibility issues.

    The link to the firmware can be found here:


    More changes in the Changelog below:


    Changelog:
    - Import zenfone8_zs590ks.MR1-30.12.112.36 source code
    - Linux-Stable Upstream to 5.4.155
    - Merge CAF (QCOM) upstream
    - remove logging while device is suspended
    - improvements to deep sleep power consumption (ufs driver, auto hibernate)
    - reduce auto suspend delay in various other drivers
    - improvements on various subsystem like memory management, bluetooth, display, gpu etc
    - implement LRNG (thanks @arter97, see arter kernel OP for more info )
    - updates from kernel common for several subsystems
    - updated ak3 zip, thanks to @osm0sis


    Download:



    Instructions can be found in the OP!
    But look at this post too :)

    Have fun, enjoy the kernel and your phone.

    Donations are not mandatory but very welcome.
    If you like my work and want to buy me a coffee/green tea to keep development going: http://paypal.me/freak07
    8
    Update to 1.0.8

    Hey guys and girls,


    Alright so here´s the next update. The asus source for the new updates didn´t contain anything that we didn´t already have by merging CAF and linux-stable upstream.

    However it was time for an update.

    After flashing the kernel.zip there will be a magisk module in magisk manager called AK3 Helper Module. Do not delete it.

    The link to the latest firmware can be found here:
    [/URL]


    More changes in the Changelog below:


    Changelog:
    - Linux-Stable upstream bumped to 5.4.182
    - use prebuilt clang 14.0.2
    - CAF-Upstream
    - wifi driver updated with caf-upstream
    - update f2fs fsck spoof


    Download:



    Instructions can be found in the OP!
    But look at this post too :)

    Have fun, enjoy the kernel and your phone.

    Donations are not mandatory but very welcome.
    If you like my work and want to buy me a coffee/green tea to keep development going: http://paypal.me/freak07
    8
    Check out who's back :)

    Screenshot_20230222-125323895.jpg


    PXL_20230220_111557416.jpg
    8
    Update to 2.0.8

    Hey guys and girls,


    Here´s the next update.
    Source was updated for 31.1010.0411.113.
    Details in the changelog below.

    The link to the latest firmware can be found following this link.


    More changes in the Changelog below:


    Changelog:
    - Import kernel source from 31.1010.0411.113
    - Linux-Stable upstream bumped to 5.4.209
    - merge latest CAF-Upstream
    - import SSG IO scheduler from samsung galaxy s22 and set as default option
    1. -> asus switched to mq-deadline, which doesn´t work that well under load
    2. -> default google/qcom mq-bfq is a pretty gigantic driver
    3. -> ssg was developed by samsung to fit android needs, be compact should reduce overhead compared to the other two options and reduce cpu cycles
    - implement display change, that might lead to reduced power consumption
    - use prebuilt clang 14.0.7
    - update f2fs fsck spoof
    - other improvements and tweaks please check github


    Download:



    Instructions can be found in the OP!
    But look at this post too :)

    Have fun, enjoy the kernel and your phone.

    Donations are not mandatory but very welcome.
    If you like my work and want to buy me a coffee/green tea to keep development going: http://paypal.me/freak07