[ASUS ROG Phone II ROMs, Kernels, Recoveries, & Oth] Freak07:
Kirisakura-Kernel for the Asus Rog Phone 2

Hello everyone,

I proudly present Kirisakura-Kernel made for the Asus Rog Phone 2 aka Yoda!

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

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

Kernel Control Flow Integrity (Kernel-CFI), which is achieved by linking the kernel with LLD and Link Time Optimization (LTO), more precisely ThinLTO, are quite unique security features. In fact this may be one of the only 4.14 msm kernels with a fully working Kernel-CFI implementation and CFI-Violations fixed on a smartphone.

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

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

Quick explanation of CAF-Upstream. CAF is short for Codeaurora-Forums. This is the place where development from Qualcomm for their SoCs happens. This includes the Snapdragon 855+ that´s built into the Asus Rog Phone 2.

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 others to provide the latest CAF-Updates merged in a regular manner, to provide updates, improvements and enhancements for SoC specific drivers and subsystems! This might take a while, because a lot of device specific testing is done on my end to ensure stability.

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

Many 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 Asus Stock Rom

- compiled with Clang 13.0.1 and built with -O3 speed optimizations

- Linux-Stable-Upstream included to 4.14.243

- CAF-Upstream merged

- Link the kernel with LLD and use KASLR

- include all important fixes/improvements from kernel/common

- F2FS implementation updated to latest state of kernel/common and kernel.org maintained by Jaegeuk Kim.

- Safety Net patches are included -> Kernel passes Safety Net

- Flashing the kernel will keep root!

- Sweep to sleep functionality

- Flashable via EXKM and FKM on a rooted system!

- specifically tuned EAS for the Asus Rog Phone 2

- removed nolog usage, remove rtb logging from the kernel

- remove selinux auditing from kernel for lower overhead

- remove IPC logging from the kernel

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

- option for 144hz refresh rate (Android 10 only)

- option to improve visibility in dark scenes

EAS related features:

- EAS implementation patched up to latest CAF state

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

- Dynamic Stune Boost to inflate task utilization and not overload cores on interaction (thanks to @RenderBroken and @joshuous )

- improved schedutil governor

- updates from kernel/common

CPU related features:

- Power saving workingqueues enabled by default

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

this complements EAS in general

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

- include cpuidle patches from CAF

- improvements to cpufreq/times/stats

- vDSO 32 patches to improve 32-bit performance

- arm64: lse: Prefetch operands to speed up atomic operations (thanks to @kdrag0n )

File System related features:

- F2FS implementation updated to latest state of kernel/common and F2FS-Mainline on kernel.org maintained by Jaegeuk Kim.

- Include rapid GC by @arter97 ( best thing is to read the commit description linked here. I compared GC on stock google f2fs, upstreamed f2fs and f2fs with rapid GC. Rapid GC is the most effective, followed by upstreamed f2fs.)

- adapt F2FS to be inline with Pixel 4s code from Google, which is also directly maintained by Jaegeuk Kim

- include a few F2FS fixes from the Pixel 4 kernel

- include optimizations to UFS-Driver from Pixel 4

- various improvements to FS-Performance from the Pixel 4

- f2fs fix to prevent data loss in case of sudden power failure

GPU related features:

- Update GPU driver to latest CAF state

- remove debugging and non-sd855+ specific code from the GPU driver

- introduce low priority worker thread to improve performance in UI-critical situations

Network related features:

- Wireguard Support (Details)

- advanced TCP algorithms enabled

- includes new bbr and bbr2

Memory related features:

- Speculative Page Faults (1. 2) (CAF default)

- enabled per process reclaim (CAF default)

- Fix various memory leaks in different subsystems

- improved mm with patches from latest mainline

- various other changes from mainline

- included zstd and lz0-rle as options for ZRAM-algorithm (lz4 is probably the best all around, so only change it if you know why and what you are doing)

- allow swappiness up to a value of 200

- remove unused mem regions to free more RAM (thanks to @kdrag0n )

Security related features:

- Control-Flow-Integration (CFI) andLink-Time-Optimization (LTO) ported from 4.14 kernel/common and Pixel 4 Kernel

- Shadow Call Stack ported from 4.14 kernel/common and Pixel 4 Kernel

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

Misc Features:

TCP Congestion Algorithms:

- advanced algorithms enabled

- 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

Other features:

- disable logging and debugging to make the kernel more lightweight in various places (includes binder, mm, vma, gpu, ipa etc)

- remove VLAs from the kernel (more info)

- add support for steam controller

- add support for nintendo switch controller

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

- updated binder section (responsible for interprocess communication)

- updated sdcardfs ; have a read about it here:

- fix CFI violations

- add ramoops/pstore support (thanks @luca020400)

Requirements

- unlocked Bootloader

- USB-Debugging in developer options enabled

- latest adb and fastboot binaries

- working adb and fastboot environment

- magisk root

- a backup of boot.img and dtbo.img to be able to restore to stock. you should be able to do this easily via TWRP.

How to flash the Kernel:

1. Download the latest kernel.zip and make sure you have properly updated to the latest Asus Firmware

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

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

3. Flash the kernel.zip via latest EXKM or FKM app, or TWRP (haven´t tested TWRP myself as I don´t need it) and do a full reboot.

4. Flash the kernel again. This step is needed because flashing the kernel disables verity on vendor in order to modify two files. Disabling verity takes a reboot. Flashing the second time allows the two files to be changed correctly. This step is necessary if you flashed a firmware update. (This step should not be necessary when updating my kernel, if you are already running it, but if you want to be on the safe side just flash it twice)

5. Reboot and profit. It will take around 15 seconds for the kernel and the system to execute all changes done by flashing the kernel.zip. After 15 seconds 120fps will kick in, if you use 120fps setting!

DOWNLOAD:

Download is located always in this folder:

https://www.androidfilehost.com/?w=files&flid=303784

Important: Read after Download

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

Changelog:

Android 9

1.0.0 Initial Release

1.0.2 https://xdaforums.com/showpost.php?p=81389411&postcount=33

Android 10

2.0.0 https://xdaforums.com/showpost.php?p=82238713&postcount=141

2.1.0 https://xdaforums.com/showpost.php?p=82317211&postcount=191

2.6.0 https://xdaforums.com/showpost.php?p=82495531&postcount=252

2.6.2 https://xdaforums.com/showpost.php?p=82560081&postcount=261

2.6.4 https://xdaforums.com/showpost.php?p=82602927&postcount=267

2.7.2 https://xdaforums.com/showpost.php?p=82834055&postcount=281

2.7.5 https://xdaforums.com/showpost.php?p=82837791&postcount=285

2.9.0 https://xdaforums.com/showpost.php?p=83100663&postcount=306

3.0.6 https://xdaforums.com/showpost.php?p=83526987&postcount=391

3.1.0 https://xdaforums.com/showpost.php?p=83606511&postcount=406

3.1.3 https://xdaforums.com/t/kernel-29-0...us-rog-phone-2-aka-yoda.4028237/post-84124933

3.1.5 https://xdaforums.com/t/kernel-17-1...us-rog-phone-2-aka-yoda.4028237/post-84617449

3.2.0 https://xdaforums.com/t/kernel-25-0...us-rog-phone-2-aka-yoda.4028237/post-84717691

3.2.1 https://xdaforums.com/t/kernel-25-0...us-rog-phone-2-aka-yoda.4028237/post-84799241

3.2.2 https://xdaforums.com/t/kernel-08-0...us-rog-phone-2-aka-yoda.4028237/post-85145887

3.2.3 https://xdaforums.com/t/kernel-07-0...us-rog-phone-2-aka-yoda.4028237/post-85431627

Android 11

1.0.0_R https://xdaforums.com/t/kernel-05-0...us-rog-phone-2-aka-yoda.4028237/post-86201183

Donations:

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

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

Credits:

Asus for the Rog Phone 2

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

@tbalden for being the best HTC wingman!

@LeeDroid for his awesome roms!

@Captain_Throwback for all the mentoring and guidance!

@Eliminater74 for bringing me into the game and the Inspiration

@nathanchance for his upstream guidance and assistance

@RenderBroken for helping me out

@flar2 for all his work

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

@arter97 for giving me advice

@kdrag0n for his help too

@topjohnwu for magisk!

@osm0sis for anykernel!

XDA:DevDB Information

Kirisakura Kernel, Kernel for the ASUS ROG Phone II

Contributors

Freak07

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