@@ -43,12 +43,11 @@ jobs:
4343 with :
4444 fetch-depth : 0
4545
46- - name : Prepare kernel source
46+ - name : Prepare kernel source (fresh)
4747 run : |
4848 set -euo pipefail
49- rm -rf kernel builds || true
50- mkdir -p builds
51- git clone --depth=1 --branch ${{ github.event.inputs.kernel_branch }} ${{ github.event.inputs.kernel_repo_url }} kernel
49+ rm -rf kernel modules || true
50+ git clone --depth=1 --branch "${{ github.event.inputs.kernel_branch }}" "${{ github.event.inputs.kernel_repo_url }}" kernel
5251 cd kernel
5352 git submodule update --init --recursive
5453
@@ -76,119 +75,142 @@ jobs:
7675 run : |
7776 set -euo pipefail
7877 git clone https://gitlab.com/simonpunk/susfs4ksu.git -b kernel-4.14 susfs_patches
79- cp susfs_patches/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch KernelSU/
80- cp susfs_patches/kernel_patches/50_add_susfs_in_kernel-4.14.patch .
81- cp susfs_patches/kernel_patches/fs/* ./fs/
82- cp susfs_patches/kernel_patches/include/linux/* ./include/linux/
83- cd KernelSU
84- patch -N -p1 -F 3 < 10_enable_susfs_for_ksu.patch || echo "Patch already applied or failed"
85- cd ..
86- patch -N -p1 -F 3 < 50_add_susfs_in_kernel-4.14.patch || echo "Patch already applied or failed"
87- find . -name "*.rej" -exec echo "Patch reject: {}" \; -exec cat {} \;
78+ cp susfs_patches/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch KernelSU/ || true
79+ cp susfs_patches/kernel_patches/50_add_susfs_in_kernel-4.14.patch . || true
80+ cp -r susfs_patches/kernel_patches/fs/* ./fs/ || true
81+ cp -r susfs_patches/kernel_patches/include/linux/* ./include/linux/ || true
82+ if [ -f KernelSU/10_enable_susfs_for_ksu.patch ]; then
83+ (cd KernelSU && patch -N -p1 -F3 < 10_enable_susfs_for_ksu.patch) || echo "KernelSU SUSFS patch already applied"
84+ fi
85+ if [ -f 50_add_susfs_in_kernel-4.14.patch ]; then
86+ patch -N -p1 -F3 < 50_add_susfs_in_kernel-4.14.patch || echo "Kernel core SUSFS patch already applied"
87+ fi
8888 if find . -name "*.rej" | grep -q .; then
89- echo "FAIL: Some SUSFS hunks failed. Check your kernel version/patches above for why." ;
89+ echo "SUSFS patch rejects found:"; find . -name "*.rej" -print -exec sed -n '1,120p' {} \; ;
9090 exit 1;
9191 fi
9292
9393 - name : Add SUSFS configs if enabled
9494 if : ${{ github.event.inputs.enable_susfs == 'true' }}
9595 working-directory : kernel
9696 run : |
97- echo "CONFIG_KSU=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
98- echo "CONFIG_KSU_SUSFS=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
99- echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
100- echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
101- echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
102- echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
103- echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
104- echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
105- echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
106- echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
107- echo "CONFIG_KSU_SUSFS_SUS_SU=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
108-
109- - name : Remove CONFIG_TASKSTATS and related (CI robust)
97+ conf="arch/arm64/configs/${{ github.event.inputs.defconfig_file }}"
98+ {
99+ echo "CONFIG_KSU=y"
100+ echo "CONFIG_KSU_SUSFS=y"
101+ echo "CONFIG_KSU_SUSFS_SUS_PATH=y"
102+ echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y"
103+ echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y"
104+ echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=y"
105+ echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y"
106+ echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y"
107+ echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y"
108+ echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y"
109+ echo "CONFIG_KSU_SUSFS_SUS_SU=y"
110+ } >> "$conf"
111+
112+ - name : Disable taskstats family (robust)
110113 working-directory : kernel
111114 run : |
112- set -euo pipefail
113- conf=arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
115+ set -e
116+ conf=" arch/arm64/configs/${{ github.event.inputs.defconfig_file }}"
114117 for opt in CONFIG_TASKSTATS CONFIG_TASK_DELAY_ACCT CONFIG_TASK_XACCT CONFIG_TASK_IO_ACCOUNTING; do
115- sed -i "/$opt/d" "$conf"
116- echo "$opt=n" >> "$conf"
118+ sed -i "/^ $opt[= ] /d" "$conf" || true
119+ echo "${ opt} =n" >> "$conf"
117120 done
121+ tail -n 20 "$conf" || true
118122
119- - name : Fix btrfs timespec/ timespec64 incompatibility (idempotent)
123+ - name : Patch btrfs to timespec64 (idempotent, safe )
120124 working-directory : kernel
121125 run : |
122126 set -e
123- FILE =fs/btrfs/inode.c
124- # Only change line if the unpatched line exists
125- if grep -qE "^\s*struct timespec now = current_time\(&parent_inode->vfs_inode\);" "$FILE "; then
126- sed -i 's|^\(\s*\)struct timespec now = current_time(&parent_inode->vfs_inode);|\1struct timespec64 now = current_time(&parent_inode->vfs_inode);|' "$FILE "
127- echo "✓ Patched btrfs timespec to timespec64"
127+ file =fs/btrfs/inode.c
128+ # Guard: only patch if exact unpatched line exists
129+ if grep -qE "^\s*struct timespec now = current_time\(&parent_inode->vfs_inode\);" "$file "; then
130+ sed -i 's|^\(\s*\)struct timespec now = current_time(&parent_inode->vfs_inode);|\1struct timespec64 now = current_time(&parent_inode->vfs_inode);|' "$file "
131+ echo "Patched btrfs timespec -> timespec64"
128132 else
129- echo "✓ btrfs already patched or not present"
133+ echo "Skip btrfs timespec patch (already patched or different source)"
134+ fi
135+ # Sanity: ensure no corrupted line remains
136+ if grep -n "struct timespec64 now = current_time(.*struct timespec" "$file"; then
137+ echo "Detected corruption in btrfs timespec line"; sed -n '6615,6640p' "$file"; exit 1;
130138 fi
131- # Show result for debugging
132- echo "--- btrfs/inode.c context after patch ---"
133- grep -A2 -B1 "timespec" "$FILE" || true
134139
135- - name : Fix try_to_unmap argument count in huge_memory.c (idempotent)
140+ - name : Patch try_to_unmap arg count (idempotent)
136141 working-directory : kernel
137142 run : |
138143 set -e
139- FILE =mm/huge_memory.c
140- if grep -q 'try_to_unmap(page, ttu_flags);' "$FILE "; then
141- sed -i 's|try_to_unmap(page, ttu_flags);|try_to_unmap(page, ttu_flags, NULL);|g' "$FILE "
142- echo "✓ Patched try_to_unmap with NULL argument "
144+ file =mm/huge_memory.c
145+ if grep -q 'try_to_unmap(page, ttu_flags);' "$file "; then
146+ sed -i 's|try_to_unmap(page, ttu_flags);|try_to_unmap(page, ttu_flags, NULL);|g' "$file "
147+ echo "Patched try_to_unmap 2->3 args "
143148 else
144- echo "✓ try_to_unmap already patched or not present "
149+ echo "Skip try_to_unmap patch ( already correct) "
145150 fi
146- echo "--- huge_memory.c context after patch ---"
147- grep -A1 -B1 "try_to_unmap" "$FILE" || true
151+ grep -n "try_to_unmap" "$file" || true
148152
149- - name : Fix hugetlbpage ptep allocation bug (idempotent)
153+ - name : Patch hugetlbpage ptep handling (idempotent)
150154 working-directory : kernel
151155 run : |
152156 set -e
153- FILE=arch/arm64/mm/hugetlbpage.c
154- if grep -q 'pte_t \*pte = NULL;' "$FILE" && ! grep -q 'pte_t \*ptep' "$FILE"; then
155- sed -i '/pte_t \*pte = NULL;/a\ pte_t *ptep = NULL;' "$FILE"
156- echo "✓ Added ptep declaration"
157- else
158- echo "✓ ptep already declared or not needed"
157+ file=arch/arm64/mm/hugetlbpage.c
158+ # Add ptep declaration near top of function if missing
159+ if grep -n "huge_pte_alloc" "$file" >/dev/null 2>&1; then
160+ # Insert ptep declaration only if not present in function
161+ if ! awk '/huge_pte_alloc/{f=1} f && /{/{print NR; exit}' "$file" | xargs -I{} sed -n '{},+80p' "$file" | grep -q "pte_t \*ptep"; then
162+ line=$(awk '/huge_pte_alloc/{f=1} f && /{/{print NR; exit}' "$file")
163+ if [ -n "$line" ]; then
164+ # Insert after opening brace of huge_pte_alloc
165+ ed -s "$file" <<'ED'
166+ /huge_pte_alloc/
167+ /{/+1
168+ a
169+ pte_t *ptep = NULL;
170+ .
171+ w
172+ q
173+ ED
174+ echo "Inserted ptep declaration in huge_pte_alloc"
175+ fi
176+ else
177+ echo "ptep already declared in huge_pte_alloc"
178+ fi
159179 fi
160- if grep -q 'ptep = huge_pmd_share(mm, vma, addr, pud);' "$FILE"; then
161- sed -i 's/ptep = huge_pmd_share(mm, vma, addr, pud);/if (!ptep) ptep = huge_pmd_share(mm, vma, addr, pud);/' "$FILE"
162- echo "✓ Added ptep null check"
180+ # Ensure guarded use of huge_pmd_share
181+ if grep -q 'ptep = huge_pmd_share(mm, vma, addr, pud);' "$file"; then
182+ sed -i 's/ptep = huge_pmd_share(mm, vma, addr, pud);/if (!ptep) ptep = huge_pmd_share(mm, vma, addr, pud);/' "$file"
183+ echo "Guarded huge_pmd_share assignment with null check"
163184 else
164- echo "✓ ptep null check already present "
185+ echo "huge_pmd_share assignment already guarded or absent "
165186 fi
187+ # Show context around the lines
188+ grep -n "huge_pte_alloc" "$file" || true
189+ grep -n "ptep = huge_pmd_share" "$file" || true
190+ sed -n '220,260p' "$file" || true
166191
167- - name : Remove mm_struct nr_ptes usage (idempotent)
192+ - name : Comment out mm-> nr_ptes usage (idempotent)
168193 working-directory : kernel
169194 run : |
170195 set -e
171- FILE=mm/khugepaged.c
172- if grep -q 'mm->nr_ptes' "$FILE"; then
173- # Comment out lines instead of deleting to avoid syntax breaks
174- sed -i 's/\(.*mm->nr_ptes.*\)/\/\* REMOVED_for_ARM64 \1 \*\//' "$FILE"
175- echo "✓ Commented out nr_ptes references"
196+ file=mm/khugepaged.c
197+ if grep -q 'mm->nr_ptes' "$file"; then
198+ sed -i 's/\(.*mm->nr_ptes.*\)/\/\* REMOVED_for_ARM64 \1 \*\//' "$file"
199+ echo "Commented mm->nr_ptes usage"
176200 else
177- echo "✓ nr_ptes already removed or not present "
201+ echo "nr_ptes usage not found (already handled) "
178202 fi
179- echo "--- khugepaged.c nr_ptes context after patch ---"
180- grep -n "nr_ptes\|REMOVED_for_ARM64" "$FILE" || true
203+ grep -n "nr_ptes\|REMOVED_for_ARM64" "$file" || true
181204
182- - name : Set NR_CPUS if not present
205+ - name : Ensure NR_CPUS
183206 working-directory : kernel
184207 run : |
185- set -euo pipefail
186- conf=arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
187- if ! grep -q '^CONFIG_NR_CPUS=' "$conf"; then
188- echo 'CONFIG_NR_CPUS=8' >> "$conf"
189- fi
208+ set -e
209+ conf="arch/arm64/configs/${{ github.event.inputs.defconfig_file }}"
210+ grep -q '^CONFIG_NR_CPUS=' "$conf" || echo 'CONFIG_NR_CPUS=8' >> "$conf"
211+ tail -n 5 "$conf" || true
190212
191- - name : Prepare kernel config (non-interactive)
213+ - name : Configure kernel (non-interactive)
192214 working-directory : kernel
193215 run : |
194216 set -euo pipefail
0 commit comments