mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 16:07:39 +00:00
No kernel repack if it isn't patched at all
It turns out that decompressing and recompressing the kernel is enough to break booting on many devices that use MT6763. Fix #5124, fix #6204, fix #6566 Co-authored-by: LoveSy <shana@zju.edu.cn> Co-authored-by: 南宫雪珊 <vvb2060@gmail.com>
This commit is contained in:
parent
79a85f5937
commit
ae34659b26
@ -601,6 +601,9 @@ void repack(const char *src_img, const char *out_img, bool skip_comp) {
|
|||||||
// zImage size shall remain the same
|
// zImage size shall remain the same
|
||||||
hdr->kernel_size() = boot.hdr->kernel_size();
|
hdr->kernel_size() = boot.hdr->kernel_size();
|
||||||
}
|
}
|
||||||
|
} else if (boot.hdr->kernel_size() != 0) {
|
||||||
|
xwrite(fd, boot.kernel, boot.hdr->kernel_size());
|
||||||
|
hdr->kernel_size() = boot.hdr->kernel_size();
|
||||||
}
|
}
|
||||||
if (boot.flags[ZIMAGE_KERNEL]) {
|
if (boot.flags[ZIMAGE_KERNEL]) {
|
||||||
// Copy zImage tail and adjust size accordingly
|
// Copy zImage tail and adjust size accordingly
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# Usage: boot_patch.sh <bootimage>
|
# Usage: boot_patch.sh <bootimage>
|
||||||
#
|
#
|
||||||
# The following flags can be set in environment variables:
|
# The following flags can be set in environment variables:
|
||||||
# KEEPVERITY, KEEPFORCEENCRYPT, PATCHVBMETAFLAG, RECOVERYMODE
|
# KEEPVERITY, KEEPFORCEENCRYPT, PATCHVBMETAFLAG, RECOVERYMODE, SYSTEM_ROOT
|
||||||
#
|
#
|
||||||
# This script should be placed in a directory with the following files:
|
# This script should be placed in a directory with the following files:
|
||||||
#
|
#
|
||||||
@ -73,6 +73,7 @@ fi
|
|||||||
[ -z $KEEPFORCEENCRYPT ] && KEEPFORCEENCRYPT=false
|
[ -z $KEEPFORCEENCRYPT ] && KEEPFORCEENCRYPT=false
|
||||||
[ -z $PATCHVBMETAFLAG ] && PATCHVBMETAFLAG=false
|
[ -z $PATCHVBMETAFLAG ] && PATCHVBMETAFLAG=false
|
||||||
[ -z $RECOVERYMODE ] && RECOVERYMODE=false
|
[ -z $RECOVERYMODE ] && RECOVERYMODE=false
|
||||||
|
[ -z $SYSTEM_ROOT ] && SYSTEM_ROOT=false
|
||||||
[ -z $ISENCRYPTED ] && ISENCRYPTED=false
|
[ -z $ISENCRYPTED ] && ISENCRYPTED=false
|
||||||
export KEEPVERITY
|
export KEEPVERITY
|
||||||
export KEEPFORCEENCRYPT
|
export KEEPFORCEENCRYPT
|
||||||
@ -203,21 +204,28 @@ for dt in dtb kernel_dtb extra; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ -f kernel ]; then
|
if [ -f kernel ]; then
|
||||||
|
PATCHEDKERNEL=false
|
||||||
# Remove Samsung RKP
|
# Remove Samsung RKP
|
||||||
./magiskboot hexpatch kernel \
|
./magiskboot hexpatch kernel \
|
||||||
49010054011440B93FA00F71E9000054010840B93FA00F7189000054001840B91FA00F7188010054 \
|
49010054011440B93FA00F71E9000054010840B93FA00F7189000054001840B91FA00F7188010054 \
|
||||||
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
|
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054 \
|
||||||
|
&& PATCHEDKERNEL=true
|
||||||
|
|
||||||
# Remove Samsung defex
|
# Remove Samsung defex
|
||||||
# Before: [mov w2, #-221] (-__NR_execve)
|
# Before: [mov w2, #-221] (-__NR_execve)
|
||||||
# After: [mov w2, #-32768]
|
# After: [mov w2, #-32768]
|
||||||
./magiskboot hexpatch kernel 821B8012 E2FF8F12
|
./magiskboot hexpatch kernel 821B8012 E2FF8F12 && PATCHEDKERNEL=true
|
||||||
|
|
||||||
# Force kernel to load rootfs
|
# Force kernel to load rootfs for legacy SAR devices
|
||||||
# skip_initramfs -> want_initramfs
|
# skip_initramfs -> want_initramfs
|
||||||
./magiskboot hexpatch kernel \
|
$SYSTEM_ROOT && ./magiskboot hexpatch kernel \
|
||||||
736B69705F696E697472616D667300 \
|
736B69705F696E697472616D667300 \
|
||||||
77616E745F696E697472616D667300
|
77616E745F696E697472616D667300 \
|
||||||
|
&& PATCHEDKERNEL=true
|
||||||
|
|
||||||
|
# If the kernel doesn't need to be patched at all,
|
||||||
|
# keep raw kernel to avoid bootloops on some weird devices
|
||||||
|
$PATCHEDKERNEL || rm -f kernel
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#################
|
#################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user