[Samsung Galaxy M12] SpacingBat3:
About​

The published (linux) kernel is mostly unmodified – some changes were done to integrate KernelSU with our kernel, fix some compile errors and warnings. Outside of this, these are key modifications done via custom defconfig:

Added more governors: ondemand, powersave, conservative, performance

Add HAFM P-state driver for Exynos CPUs (it might not work with our SoC, but I've added it just to test that).

Add support for CD-ROM in kernel: devices (/dev/block/sr0) and filesystems (ISO9660, UDF).

Enable BTRFS filesystem support in kernel.

Enable write support for NTFS filesystem in kernel (might be experimental).

Generic (non-Samsung) kernel hardenings.

Disable known Samsung security modules and make DEFEX kernel-only.

Enable more compression algorithms (crypto, kernel).

Enable /proc/kcore.

More thermal governors (fair share, power allocator).

ConfigFS: more gadgets, enabled other related features.

More DEVFREQ governors.

Enable OSS sound subsystem in kernel.

…and some other experimental features I've enabled just to test them.

NOTE: Some modifications done to kernel might be useless for some/most users (e.g. enabling OSS sound subsystem, CD/DVD support), some might not even affect Android at all, but I've enabled these to experiment with kernel possibilities and a bit for Termux/Linux integrations.

How to install​

Using unpack_bootimg and mkbootimg binaries.​

Install/download/build android-tools for your platform.

Get a boot image from somewhere (e.g. firmware download sites, software to download it from Samsung servers directly) for your phone.

Use unpack_bootimg on original boot.img:

unpack_bootimg --boot_img original_boot.img --out out_dir --format=mkbootimg > mkbootimg_args.txt

Replace out_dir/kernel with the kernel image you've downloaded.

Repack with mkbootimg:

On

Linux

:

sh -c "mkbootimg $(cat mkbootimg_args.txt) --out repacked_boot.img"

On

Windows

(copy content of mkbootimg_args.txt and paste it instead of <flags>):

mkbootimg <flags> --out repacked_boot.img

Flash the repacked_boot.img image.

Supported devices​

Only Samsung Galaxy M12 model M127F (OneUI 5.1) is supported – M127G and others might not work with this kernel.

Kernel source code​

kernel: https://github.com/SpacingBat3/android_kernel_samsung-m127f_a13

branch: 4.19.111-samsung+kernelsu

defconfig: exynos850-m12nsxx-spacingbat3_defconfig

Changelog (for prebuilt kernel)​

2023-04-23 – Initial build, for OneUI 5 (most likely was broken).

2023-05-07 – Build for OneUI 5.1.

2023-07-16 – Rebuilt for KSU v0.6.2. Still at M127FXXU4DWC4.

2023-11-03 – Rebuilt for KSU v0.7.0 and kernel base M127FXXU5DWE1. Still lagging one release behind of the kernel (AFAIK), since Samsung did not publish new kernel sources yet.

Currently known issues​

KernelSU seems to be a bit unstable and enters Safe Mode after a longer use; I currently have no idea if this is on kernel side (and I should be fixing it), issue caused by modules or instability in KernelSU. There are however no visual crashes, it happens in the background and is barely noticeable. UPDATE: You might also be able to manage modules while KSU is at Safe Mode by using third-party module managers that are compatible with KernelSU as a workaround. KernelSU haven't entered the Safe Mode since the update to OneUI 5.1, so it is highly probable this issue is gone. Seems that Samsung has fixed it?

Plans / TODO​

I might try fixing compile errors with KVM in kernel and overall enable it, hopefully that'll be enough to get stable VM acceleration in QEMU (Limbo on Android). I'm not sure if I'm skilled enough to do so through, but at least I'll give it a try if I'll be able to share some time for that.

I'll try cherry-picking various commits for KPROBE from upstream in order to fix it for KernelSU. This was not enough for me to fix KPROBES, guess the issue is not outdated KPROBES, so it will take much more effort to fix it, maybe even not worth it.