• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

[Kernel][23.07.2021][Android 11] Kirisakura 1.2.0 for Asus Zenfone 7/Pro aka Tequila

Search This thread

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
4,931
15,760
Kirisakura-Kernel for the Asus Zenfone 7/Pro

Hello everyone,

To keep it short: Here is Kirisakura - Kernel for the Asus Zenfone 7/Pro aka Tequila. The Zenfone line- up internal codenames are derived from alcoholic drinks, last year the Zenfone 6 bore the title Kirin.
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. Instead there is an option called battery saver in the options of your phone.
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.
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.

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 865/+ that´s built into the different SKUs of the Zenfone 7/Pro.
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 11 and intended for use on the latest Asus Stock-Firmware (currently 30.41.69.51)
- compiled with Clang 12.0.6 and built with -O3 speed optimizations
- Linux-Stable-Upstream included to 4.19.198
- CAF base for the Snapdragon 865/+ (SD865/+) updated to upstream CAF
- Kernel Control-Flow-Integration (CFI) andLink-Time-Optimization (LTO) ported from 4.19 kernel/common and Pixel 5/4/XL Kernel
- 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!
- Flashable via EXKM, FKM or TWRP on a rooted system!
- Anykernel zip is based on the Anykernel3 release from @osm0sis
- 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)
- display tweaks to reduce power consumption on statically rendered images
- option to limit max cpu frequency (3 levels) also to cpu boosting during input, without enabling powersaver mode that restricts background data sometimes killing notifications

EAS related features:
- EAS implementation patched up to latest CAF state
- disable autogroups and use cgroups for more efficient task placement!
- updates from kernel/common
- scheduler updates from Googles Pixel kernel
- tune scheduler for improved jitter and less jank frames
- scheduler updates for RT tasks
- scheduler updates from sd888/ 5.4 kernel
- mainline scheduler updates for better load balancing on sched_idle cpus

CPU related features:
- Change various drivers (WLAN, MM, audio, charger, power, thermal, glink etc) to user power efficient workingqueues. This compliments EAS
- improvements to cpufreq/times/stats
- improve memory allocations in binder driver
- vdso32 patches as found on Google Pixel devices (brief documentation here)
- arm64: lse: Prefetch operands to speed up atomic operations, thanks @kdrag0n
- implement fast refcount checking
- remove RTB logging to reduce overhead
- remove event debug logging

GPU related features:
- GPU driver updated to latest CAF-State
- remove POPP functionality from GPU driver to avoid constant fight about downscaling with msm-adreno-tz
- don´t wake the gpu on touch input, instead wake when receiving an ioctl
- don´t copy fence names by default to save a bit of cpu-time (explanation)
- msm: kgsl: Stop slab shrinker when no more pages can be reclaimed
- 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:
- 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
- default IO scheduler to CFQ and readahead to 128
- improve GC as to not interfere while user interaction is happening and prevent possible jitter or latency spikes

UI/UX/Usability:
- Backlight Dimmer (reduce minimal brightness on a solid white background from 2,3 lux to 1,6 lux)
- sweep to sleep
- touch sampling override option (set stock touchsampling rate from 120hz to 200hz for reduced touch latency)

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 and bbr2

Memory related features:
- Speculative Page Faults left enabled (1. 2) (CAF default)
- various fixes for PSI-Monitor, which is used by the userspace lowmemorykiller-daemon
- Fix various memory leaks in different subsystems
- improved mm with patches from mainline
- various other changes from mainline
- included zstd as an option for ZRAM-algorithm (lz4 is probably the best all around, so only change it if you know why and what you are doing)
- improve memory allocations in various subsystems
- Backport to enable CONFIG_HAVE_MOVE_PMD (see here) , thanks @arter97
- Backport to enable CONFIG_HAVE_MOVE_PUD (commit here) , thanks @arter97
- allow max swappiness over 100, to favor swapping instead of dropping the cache
- free more RAM by removing unused reserved memory regions

Security related features:
- Control-Flow-Integration (CFI) and Link-Time-Optimization (LTO) ported from 4.19 kernel/common and Pixel 5 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
- Backport mainline Selinux commits for improved performance in the selinux subsystem, thanks @arter97 (you must be on magisk 21.0 or higher, otherwise the kernel won´t boot)


Misc Features:

TCP Congestion Algorithms:
- advanced algorithms enabled, enable them with your favorite kernel manager
- use bbr as default TCP congestion algorithm (fasted algo according to this excellent research from @kdrag0n found here )
- includes new bbr2

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 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
- implement ramoops functionality to be able to easily debug kernel panics

Feature section for the "non visible" but perceptible improvements:
- updated binder section (responsible for interprocess communication)


Flashing Guide, Download and Changelog

Requirements:
- unlocked Bootloader
- USB-Debugging in developer options enabled
- latest adb and fastboot binaries
- working adb and fastboot environment
- magisk root (magisk 22.0 or higher), usually magisk stable works best
- a backup of stock boot.img and dtbo.img so you can go back to stock conditions (simplest way is TWRP)

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 7/Pro receives an 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, make sure you have a backup ready!

2. Flash the kernel.zip via latest TWRP, 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.1.3 https://forum.xda-developers.com/t/...nfone-7-pro-aka-tequila.4269677/post-85018787
1.2.0 https://forum.xda-developers.com/t/...nfone-7-pro-aka-tequila.4269677/post-85369449

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_TEQUILA_Zenfone_7
 
Last edited:

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
4,931
15,760
FAQ

F.A.Q:

Question:
Why does the kernel version show as "unavailable" in settings after flashing it.
Answer: Asus does not allow for custom kernel names in their settings. Use a kernel manager to check the kernel version.

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 as well as dtbo.img from matching firmware you are on and flash the extracted boot.img and dtbo.img via fastboot. If you want to keep root flash back the magisk_patched_boot.img. Or dirty flash your rom.

Question: Why is having Magisk installed mandatory for this kernel?
Answer: Android 10s changes to partitions, doesn´t allow files in system/ and vendor/ to be replaced. This kernel is very far from the stock kernel. To account for this I can´t force load the stock kernel-modules for certain drivers as it happens on kernels that are closer to stock.
Instead we use Magisks function to overlay certain files during boot. Without a working Magisk environment the kernel cannot function.

Question: I have a phone that is converted from CN to WW and now there´s a warning from hardwarestub. Can I hide it?
Answer: Yes, I created a Magisk Module for those that want to hide the notification, so nobody needs to rely on paid apps.
The Magisk module can be found attached to this post.
Please note that refresh rate can´t be changed when the module is flashed. To able to change refresh rate or to remove the module, simple remove it in Magisk Manager and do a full reboot. I´ll attach it to the third post on this thread. There will be no support for this module from my side and no other support for converted devices.

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!
 
  • Like
Reactions: TheEndHK

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
4,931
15,760
  • Like
Reactions: tombbb

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
4,931
15,760
Thank you for this! The phone is much faster, but also warmer in daily use. DeepSleep is perfect.
My phone runs on the same temperature compared to stock kernel.
Whats your ambient temperature? Maybe it's related to that.
Or it's coincidence and an app is stuck in background or got recently an update. Give it a reboot or maybe a few days. (y)
 
  • Like
Reactions: Seosam

Seosam

Senior Member
Jul 13, 2016
152
59
Germany
ASUS ZenFone 7/7 Pro
My phone runs on the same temperature compared to stock kernel.
Whats your ambient temperature? Maybe it's related to that.
Or it's coincidence and an app is stuck in background or got recently an update. Give it a reboot or maybe a few days. (y)
I think this is due to the higher boost from the kernel compared to stock. There is also only a 4-5 degree Celsius difference. And only when using apps. You can feel it a little in your hand.
Reboot was carried out, of course. As I said, I think it's simply due to the higher frequencies overall and is completely within the limits.
 

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
4,931
15,760
I think this is due to the higher boost from the kernel compared to stock. There is also only a 4-5 degree Celsius difference. And only when using apps. You can feel it a little in your hand.
Reboot was carried out, of course. As I said, I think it's simply due to the higher frequencies overall and is completely within the limits.

The kernel doesn´t boost anything higher than stock. The powerhal and all boosts on input are unchanged compared to stock. Improved UI performance isn´t due to higher boosting.
Might be that some of the scheduler changes, paired with your unique usage lead to overall higher used freqs and the mild temperature increase.
Interesting that it seems to be the case for you.
Temps are basically the same on my end also during benchmarks, because I monitored temps while verifying the improved UI performance.

Thanks for the report! There is still more to come :) (also for the scheduler)
 
  • Like
Reactions: Seosam

gui3gui

Senior Member
Sep 26, 2013
72
12
Thanks for your work, but I noticed than the consumption of the battery was high.

How can I flash the original kernel, I'm always on the stock a11 rom but I will flash soon the omnirom.
 

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
4,931
15,760
Ok but perhaps, can you provide this file ?
No, it's best if you extract them yourself.

If you followed the instructions in the OP you should have a backup from boot.img and dtbo.img made via TWRP. (y)

If you don't have them download the full firmware and extract them via payload extractor. You will be able to find that on XDA.


Edit: to flash Omni you need to have stock rom on both slots anyway. So just flash stock rom twice (that will restore original boot.img and dtbo.img anyway) and follow the Omni instructions! :)
 
Last edited:

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
4,931
15,760
Update to 1.1.3_R

Hey guys and girls,

I hope everyone is having a good weekend or is starting into one. here´s the next update.
It includes quite a few nice additions and fixes.
Latest Linux-Stable Upstream is merged as well as CAF-Upstream.

There was a driver missing that´s being built out of tree on the stock kernel. Since it´s not included in the kernel source that Asus pushes, but publicly available on the qcom git I forgot to include it in the first release.
After booting this caused the prime core to be sometimes stuck at highest freq for a few minutes, depending on the network connection/condition. The same could randomly happen during daily usage. My guess it´s that it´s triggered by some sort of network condition that´s not controlled by the kernel, but rather the modem, but affects the kernel.
Either way the kernel behaves now the same as on stock in that regard. Maybe this is what @Seosam reported in this post here. Additionally this driver is supposed to boost 5G speeds.

Sweep to Sleep
A simple sweep to sleep driver is introduced in this release. You can control it via EXKM to your preference. It´s disabled by default.

Touch Sampling Override
An option was added to force a higher touch sampling rate during non gaming usage. This forces the sampling rate to be 200HZ instead of 120HZ. It´s easily noticable when scrolling as the content sticks closer to your finger. If that´s something you´re after you can set it by setting
sys/module/focaltech_ex_fun/parameters/sampling_override to either "1" or "Y".
An easy way to do this is either via a script manager or in EXKM with user settings.
I used this on a daily basis and didn´t notice a big impact on battery life.
Screenshots showing the path for the sysfs here:

1621074801666.png



CPU-Frequency Limiting
Another option is CPU-Freq Limiting. You can now limit the CPU frequency to a few different levels with a sysfs interface. Original implementation is from @tbalden, I only changed it to be accessible via traditional root methods.
Main Switch:
sys/module/cpufreq/parameters/batterysaver
Set this option to "1" to enable the feature

Max-Frequency Selection (Input boosts, such as scrolling boost or app launching boosts will still apply)
sys/module/cpufreq/parameters/batterysaver_level
Set this to "1" to restrict the max CPU-Freqs to 1,8GHZ/2,0GHZ/2,4GHZ
Set this to "2" to restrict the max CPU-Freqs to 1,5GHZ/1,6GHZ/1,6GHZ
Set this to "3" to restrict the max CPU-Freqs to 1,1GHZ/1,1GHZ/1,2GHZ

Touch-Boost Restriction
sys/module/cpufreq/parameters/batterysaver_touch limiting
Set this to "1" to restrict the powerhal from boosting over the limit defined in batterysaver_level
Set this to "0" to allow the powerhal to boost above the values defined in batterysaver_level, but only during interaction with the Phone!

Screenshots:
1621076204384.png
1621076219469.png
1621076241915.png



This is for example very useful during gaming to prevent additional heat, if not the highest performance from the CPU is required.
Another very useful tool while doing video calls or navigation with google maps to preserve battery or keep the phone from heating.
This is a very easy way to preserve battery or reduce heat without toggling the battery save mode in settings as that restricts background data usage, which can lead to delayed notifications.

More changes in the Changelog below:


Changelog:
- Linux-Stable Upstream to 4.19.190
- Caf-Upstream
- add techpack/data-kernel submodule
- display tweaks to reduce power consumption
- scheduler updates for RT tasks
- scheduler updates from sd888/ 5.4 kernel
- mainline scheduler updates for better load balancing on sched_idle cpus
- convert several drivers to use power efficient workingqueues
- improve bluetooth performance
- cpuidle (deepsleep) improvements
- disable more debugging for lower overhead
- introduce CPU freq limiting feature (useful for restricting highest CPU freqs- extended navigation sessions for example) (original implementation from @tbalden, big thanks to him! )
- introduce option to use higher touch sampling rate to reduce touch latency
- provide option for s2s over navigation area to shut the screen off.




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
 
Last edited:

TheEndHK

Senior Member
Apr 25, 2011
2,668
808

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
4,931
15,760
Hi,

I'm considering to get a zenfone 7 Pro but I would like to know do your kernel support permissive mode with fully /system write?
That's not related to the kernel any longer.

Permissive selinux can be set via terminal or a script.

Read/write is difficult on devices with dynamic partitions. Magisk modules are the easiest solution for this. They allow to systemlessly replace files during bootup.



However there are solutions like this:

I'd be very cautious of stuff like this, it has the potential to mess up the device completely, so it can be only restored by wiping everything including all data on the device.
 
  • Like
Reactions: TheEndHK

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    Update to 1.2.0_R

    Hey guys and girls,


    I hope everyone had good week or is starting into the weekend already. here´s the next update.
    It includes the source code merged for the update zenfone7_zs670ks.mr2.4-30.41.69.78.

    Link to the full firmware file below:

    More changes in the Changelog below:


    Changelog:
    - Merge Source Code Update from zenfone7_zs670ks.mr2.4-30.41.69.78
    - Linux-Stable Upstream to 4.19.198
    - merge a big part of f2fs-stable
    - improve GC (garbage collection) done by f2fs





    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
    1
    Hi,

    I'm considering to get a zenfone 7 Pro but I would like to know do your kernel support permissive mode with fully /system write?
    That's not related to the kernel any longer.

    Permissive selinux can be set via terminal or a script.

    Read/write is difficult on devices with dynamic partitions. Magisk modules are the easiest solution for this. They allow to systemlessly replace files during bootup.



    However there are solutions like this:

    I'd be very cautious of stuff like this, it has the potential to mess up the device completely, so it can be only restored by wiping everything including all data on the device.
    1
    有新的更新嗎? 78 降低手機上,內核不會讓我上的頻率。
    謝謝
    I am currently using 30.41.69.78 firmware, it is no problem to change this kernel... You try to re-flash magisk. Check the kernel and try it. Prohibit unnecessary application startup
    Screenshot_20210718-002759510.jpg
  • 8
    Kirisakura-Kernel for the Asus Zenfone 7/Pro

    Hello everyone,

    To keep it short: Here is Kirisakura - Kernel for the Asus Zenfone 7/Pro aka Tequila. The Zenfone line- up internal codenames are derived from alcoholic drinks, last year the Zenfone 6 bore the title Kirin.
    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. Instead there is an option called battery saver in the options of your phone.
    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.
    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.

    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 865/+ that´s built into the different SKUs of the Zenfone 7/Pro.
    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 11 and intended for use on the latest Asus Stock-Firmware (currently 30.41.69.51)
    - compiled with Clang 12.0.6 and built with -O3 speed optimizations
    - Linux-Stable-Upstream included to 4.19.198
    - CAF base for the Snapdragon 865/+ (SD865/+) updated to upstream CAF
    - Kernel Control-Flow-Integration (CFI) andLink-Time-Optimization (LTO) ported from 4.19 kernel/common and Pixel 5/4/XL Kernel
    - 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!
    - Flashable via EXKM, FKM or TWRP on a rooted system!
    - Anykernel zip is based on the Anykernel3 release from @osm0sis
    - 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)
    - display tweaks to reduce power consumption on statically rendered images
    - option to limit max cpu frequency (3 levels) also to cpu boosting during input, without enabling powersaver mode that restricts background data sometimes killing notifications

    EAS related features:
    - EAS implementation patched up to latest CAF state
    - disable autogroups and use cgroups for more efficient task placement!
    - updates from kernel/common
    - scheduler updates from Googles Pixel kernel
    - tune scheduler for improved jitter and less jank frames
    - scheduler updates for RT tasks
    - scheduler updates from sd888/ 5.4 kernel
    - mainline scheduler updates for better load balancing on sched_idle cpus

    CPU related features:
    - Change various drivers (WLAN, MM, audio, charger, power, thermal, glink etc) to user power efficient workingqueues. This compliments EAS
    - improvements to cpufreq/times/stats
    - improve memory allocations in binder driver
    - vdso32 patches as found on Google Pixel devices (brief documentation here)
    - arm64: lse: Prefetch operands to speed up atomic operations, thanks @kdrag0n
    - implement fast refcount checking
    - remove RTB logging to reduce overhead
    - remove event debug logging

    GPU related features:
    - GPU driver updated to latest CAF-State
    - remove POPP functionality from GPU driver to avoid constant fight about downscaling with msm-adreno-tz
    - don´t wake the gpu on touch input, instead wake when receiving an ioctl
    - don´t copy fence names by default to save a bit of cpu-time (explanation)
    - msm: kgsl: Stop slab shrinker when no more pages can be reclaimed
    - 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:
    - 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
    - default IO scheduler to CFQ and readahead to 128
    - improve GC as to not interfere while user interaction is happening and prevent possible jitter or latency spikes

    UI/UX/Usability:
    - Backlight Dimmer (reduce minimal brightness on a solid white background from 2,3 lux to 1,6 lux)
    - sweep to sleep
    - touch sampling override option (set stock touchsampling rate from 120hz to 200hz for reduced touch latency)

    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 and bbr2

    Memory related features:
    - Speculative Page Faults left enabled (1. 2) (CAF default)
    - various fixes for PSI-Monitor, which is used by the userspace lowmemorykiller-daemon
    - Fix various memory leaks in different subsystems
    - improved mm with patches from mainline
    - various other changes from mainline
    - included zstd as an option for ZRAM-algorithm (lz4 is probably the best all around, so only change it if you know why and what you are doing)
    - improve memory allocations in various subsystems
    - Backport to enable CONFIG_HAVE_MOVE_PMD (see here) , thanks @arter97
    - Backport to enable CONFIG_HAVE_MOVE_PUD (commit here) , thanks @arter97
    - allow max swappiness over 100, to favor swapping instead of dropping the cache
    - free more RAM by removing unused reserved memory regions

    Security related features:
    - Control-Flow-Integration (CFI) and Link-Time-Optimization (LTO) ported from 4.19 kernel/common and Pixel 5 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
    - Backport mainline Selinux commits for improved performance in the selinux subsystem, thanks @arter97 (you must be on magisk 21.0 or higher, otherwise the kernel won´t boot)


    Misc Features:

    TCP Congestion Algorithms:
    - advanced algorithms enabled, enable them with your favorite kernel manager
    - use bbr as default TCP congestion algorithm (fasted algo according to this excellent research from @kdrag0n found here )
    - includes new bbr2

    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 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
    - implement ramoops functionality to be able to easily debug kernel panics

    Feature section for the "non visible" but perceptible improvements:
    - updated binder section (responsible for interprocess communication)


    Flashing Guide, Download and Changelog

    Requirements:
    - unlocked Bootloader
    - USB-Debugging in developer options enabled
    - latest adb and fastboot binaries
    - working adb and fastboot environment
    - magisk root (magisk 22.0 or higher), usually magisk stable works best
    - a backup of stock boot.img and dtbo.img so you can go back to stock conditions (simplest way is TWRP)

    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 7/Pro receives an 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, make sure you have a backup ready!

    2. Flash the kernel.zip via latest TWRP, 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.1.3 https://forum.xda-developers.com/t/...nfone-7-pro-aka-tequila.4269677/post-85018787
    1.2.0 https://forum.xda-developers.com/t/...nfone-7-pro-aka-tequila.4269677/post-85369449

    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_TEQUILA_Zenfone_7
    6
    Update to 1.1.3_R

    Hey guys and girls,

    I hope everyone is having a good weekend or is starting into one. here´s the next update.
    It includes quite a few nice additions and fixes.
    Latest Linux-Stable Upstream is merged as well as CAF-Upstream.

    There was a driver missing that´s being built out of tree on the stock kernel. Since it´s not included in the kernel source that Asus pushes, but publicly available on the qcom git I forgot to include it in the first release.
    After booting this caused the prime core to be sometimes stuck at highest freq for a few minutes, depending on the network connection/condition. The same could randomly happen during daily usage. My guess it´s that it´s triggered by some sort of network condition that´s not controlled by the kernel, but rather the modem, but affects the kernel.
    Either way the kernel behaves now the same as on stock in that regard. Maybe this is what @Seosam reported in this post here. Additionally this driver is supposed to boost 5G speeds.

    Sweep to Sleep
    A simple sweep to sleep driver is introduced in this release. You can control it via EXKM to your preference. It´s disabled by default.

    Touch Sampling Override
    An option was added to force a higher touch sampling rate during non gaming usage. This forces the sampling rate to be 200HZ instead of 120HZ. It´s easily noticable when scrolling as the content sticks closer to your finger. If that´s something you´re after you can set it by setting
    sys/module/focaltech_ex_fun/parameters/sampling_override to either "1" or "Y".
    An easy way to do this is either via a script manager or in EXKM with user settings.
    I used this on a daily basis and didn´t notice a big impact on battery life.
    Screenshots showing the path for the sysfs here:

    1621074801666.png



    CPU-Frequency Limiting
    Another option is CPU-Freq Limiting. You can now limit the CPU frequency to a few different levels with a sysfs interface. Original implementation is from @tbalden, I only changed it to be accessible via traditional root methods.
    Main Switch:
    sys/module/cpufreq/parameters/batterysaver
    Set this option to "1" to enable the feature

    Max-Frequency Selection (Input boosts, such as scrolling boost or app launching boosts will still apply)
    sys/module/cpufreq/parameters/batterysaver_level
    Set this to "1" to restrict the max CPU-Freqs to 1,8GHZ/2,0GHZ/2,4GHZ
    Set this to "2" to restrict the max CPU-Freqs to 1,5GHZ/1,6GHZ/1,6GHZ
    Set this to "3" to restrict the max CPU-Freqs to 1,1GHZ/1,1GHZ/1,2GHZ

    Touch-Boost Restriction
    sys/module/cpufreq/parameters/batterysaver_touch limiting
    Set this to "1" to restrict the powerhal from boosting over the limit defined in batterysaver_level
    Set this to "0" to allow the powerhal to boost above the values defined in batterysaver_level, but only during interaction with the Phone!

    Screenshots:
    1621076204384.png
    1621076219469.png
    1621076241915.png



    This is for example very useful during gaming to prevent additional heat, if not the highest performance from the CPU is required.
    Another very useful tool while doing video calls or navigation with google maps to preserve battery or keep the phone from heating.
    This is a very easy way to preserve battery or reduce heat without toggling the battery save mode in settings as that restricts background data usage, which can lead to delayed notifications.

    More changes in the Changelog below:


    Changelog:
    - Linux-Stable Upstream to 4.19.190
    - Caf-Upstream
    - add techpack/data-kernel submodule
    - display tweaks to reduce power consumption
    - scheduler updates for RT tasks
    - scheduler updates from sd888/ 5.4 kernel
    - mainline scheduler updates for better load balancing on sched_idle cpus
    - convert several drivers to use power efficient workingqueues
    - improve bluetooth performance
    - cpuidle (deepsleep) improvements
    - disable more debugging for lower overhead
    - introduce CPU freq limiting feature (useful for restricting highest CPU freqs- extended navigation sessions for example) (original implementation from @tbalden, big thanks to him! )
    - introduce option to use higher touch sampling rate to reduce touch latency
    - provide option for s2s over navigation area to shut the screen off.




    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
    3
    Hey everybody,
    I was a bit busy. Regarding new firmware update:
    all changes from the 30.41.69.66 were already present in my kernel by merging CAF-Upstream.

    So just flash away on the new firmware, link is here:
    2
    Update to 1.2.0_R

    Hey guys and girls,


    I hope everyone had good week or is starting into the weekend already. here´s the next update.
    It includes the source code merged for the update zenfone7_zs670ks.mr2.4-30.41.69.78.

    Link to the full firmware file below:

    More changes in the Changelog below:


    Changelog:
    - Merge Source Code Update from zenfone7_zs670ks.mr2.4-30.41.69.78
    - Linux-Stable Upstream to 4.19.198
    - merge a big part of f2fs-stable
    - improve GC (garbage collection) done by f2fs





    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
    1
    FAQ

    F.A.Q:

    Question:
    Why does the kernel version show as "unavailable" in settings after flashing it.
    Answer: Asus does not allow for custom kernel names in their settings. Use a kernel manager to check the kernel version.

    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 as well as dtbo.img from matching firmware you are on and flash the extracted boot.img and dtbo.img via fastboot. If you want to keep root flash back the magisk_patched_boot.img. Or dirty flash your rom.

    Question: Why is having Magisk installed mandatory for this kernel?
    Answer: Android 10s changes to partitions, doesn´t allow files in system/ and vendor/ to be replaced. This kernel is very far from the stock kernel. To account for this I can´t force load the stock kernel-modules for certain drivers as it happens on kernels that are closer to stock.
    Instead we use Magisks function to overlay certain files during boot. Without a working Magisk environment the kernel cannot function.

    Question: I have a phone that is converted from CN to WW and now there´s a warning from hardwarestub. Can I hide it?
    Answer: Yes, I created a Magisk Module for those that want to hide the notification, so nobody needs to rely on paid apps.
    The Magisk module can be found attached to this post.
    Please note that refresh rate can´t be changed when the module is flashed. To able to change refresh rate or to remove the module, simple remove it in Magisk Manager and do a full reboot. I´ll attach it to the third post on this thread. There will be no support for this module from my side and no other support for converted devices.

    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!