From nobody Mon Jun 8 15:41:35 2026 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C74EB3A4539 for ; Thu, 28 May 2026 09:41:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961310; cv=none; b=eaJZJxfaXQ4+pgNbLVtkeHeIWJUPhGmnagGiRgf7DZDySQZNk5dR3MrY1knoufTSth7UUO40+gCVkRcnpXoRyCUOKVQbbSsQeRntBybbs7Zqm7zlYYIZDdB51Rz91a69JvEkzPom/bGffA3Wz59v/HoSE3lQAFxB9dR4alTbHsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961310; c=relaxed/simple; bh=MUL158TIarDsv3txrX32xNfRGNKHiG1GhJq8gii1TLo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=auc7x1NX9LEz0Syt/OpT0IQ6u0FV47dVNDW87FU9He2YwKxiGHB1mSvVtYzzLUmdsOxNZAGNLyHLjU5+PohriLg1VLIkA9b/BZ5o6zbjEqh69+C5uJqKFNzBoYPKbOhBbyo/0CeFKfyT9nT1CI+k3Ub6u4SrQA2oX7nlJ2L0s/E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f193.google.com with SMTP id 41be03b00d2f7-c80167f56cdso5414922a12.3 for ; Thu, 28 May 2026 02:41:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779961307; x=1780566107; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4Va/8UHj/muCxXwz4cRtoHIipkT2i9Y/gR+pknqm6No=; b=Mffw5IB4oEj5NjZlOmf7NknkMlViHoaPpX7fY5QlNVb+B2RGaCbiantRK6Hp3dZPLT sOGifBSd7t6lT4PMPqawRvVj8d0B9ahzyiO71IsJhFyjC928GmF4brysgCQrn699+bli 4wq5PsZO0DJ0CV2xgreusYLyL2HHB4cNS1gV3avVeoaQdnAar3GQyPs1N4udbc3F3GIb +Od9k5KPzxt1tC/QFS/AzNHEFSYM2H6in9FmmX/K2AAnE9cnZ1fL4M7Hxxok+5ZGxWWo sIlmvvVsxAYTFeIVYX1EWoqbSztq6JZcpvBUQ1RFtLxd0FPAZ6r/u9X5Et4Te7l3gnin Am0A== X-Forwarded-Encrypted: i=1; AFNElJ99tRGdUBFCOl32hwvgX9cxLoWmM76gjCZ3m2cFMAf0zq+wlg8FrhUeJIYJxqVs0rJvD/hvYhZkz/JadAY=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7CaD4kP9eKtAbI8b+bJHL7XgPx14RebQDfn+ggcaFnet4jC6z wfWh05nL2NPAfeV5Cri/V3zKoNzpYXYbLOdx+4lD0wWglFUGu6AwA4su X-Gm-Gg: Acq92OFVuHXCmFsmotMXBuLwHeBI/s3bZ+FAw7ZcLkKi4RPgbhlmI9t5wtFcCqqsxz6 lLlYioHRgrN5gBU/O5rMPqhu29ft1HooLheQTloLNMLaNjgWx6PTP/kGRTJhnQcDYMYqT2djR2D KjUVwfza7YHPJTy4UsvuQysPr/vsSHKDO9SyeDdGzfIL62tIB3USPcDSoP6WQ3cm1N56YmTISFJ JFF5rKbQpaBg+0cwtmugfjib0OTP/7KfIgavkNgnMM5Nwz49mI1kFN7GNKtt0GUq6v0gVtsC7Ot 3XYMjtwG1VWeUDXj1DlAue7MQpkYY/zWerq+KyLk/SqkjKlYT+IzNaBLO5zTkg6ValtG2DLYCal Mr9ER4UsAWWrsLKugLSfKesRSmEEFXU9BfnkERg5CWOKnrAqrIT87PTSWZohYgXZaLBplg25Meb pcTLVwoRUn1nHj1ipfBmi556PDQz32wggrBte1nDw/XT15a6kHNpWukHk= X-Received: by 2002:a05:6a20:d486:b0:3a8:7fb:ca0e with SMTP id adf61e73a8af0-3b328ce50f0mr28880426637.23.1779961307007; Thu, 28 May 2026 02:41:47 -0700 (PDT) Received: from kylin-XiaoXinPro-16-AHP9.. ([116.128.244.171]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-841d70f1ed8sm5468915b3a.43.2026.05.28.02.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 02:41:46 -0700 (PDT) From: Xueqin Luo To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Xueqin Luo , xiongxin Subject: [PATCH -next] initramfs: Add CRC32 debugging mechanism for unpack failures Date: Thu, 28 May 2026 17:41:37 +0800 Message-ID: <20260528094137.200674-1-luoxueqin@kylinos.cn> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some motherboards report high probability unpack initramfs failed, resulting in the system cannot start normally. The error is as follows: [ 9.400739][ 0] [ T11] Trying to unpack rootfs image as initramfs... [ 9.408430][ 5] [ T1] calling register_arm64_panic_block+0x0/0x40 @ 1 [ 9.417144][ 0] [ T11] Initramfs unpacking failed: junk at the end of = compressed archive Initramfs unpacking failures can be difficult to diagnose because it is often unclear whether the initrd image was corrupted before unpacking or whether the decompressor failed while processing a valid image. Add an optional debugging mode that computes and prints a CRC32 checksum of the external initrd before unpacking. Comparing the CRC32 value across multiple boot attempts may help distinguish between corrupted initrd contents and decompression failures. This patch does not change the default boot behavior unless explicitly enabled through the "initramfs_debug=3D1" kernel command-line parameter. Co-developed-by: xiongxin Signed-off-by: xiongxin Signed-off-by: Xueqin Luo --- init/initramfs.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/init/initramfs.c b/init/initramfs.c index 20a18fcda48e..4809065aed29 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -21,6 +21,7 @@ #include #include #include +#include =20 #include =20 @@ -30,6 +31,9 @@ static __initdata bool csum_present; static __initdata u32 io_csum; =20 +static bool initramfs_debug; +core_param(initramfs_debug, initramfs_debug, bool, 0400); + static ssize_t __init xwrite(struct file *file, const unsigned char *p, size_t count, loff_t *pos) { @@ -716,6 +720,20 @@ static void __init populate_initrd_image(char *err) } #endif /* CONFIG_BLK_DEV_RAM */ =20 +/* + * Record a CRC32 checksum of the initrd contents for diagnostics. + */ +static void debug_initrd_crc32(const void *data, size_t len) +{ + u32 crc; + + pr_info("initramfs: integrity diagnostics enabled\n"); + + crc =3D crc32_le(~0, data, len); + + pr_info("initramfs: external initrd CRC32 checksum: %08x\n", crc); +} + static void __init do_populate_rootfs(void *unused, async_cookie_t cookie) { /* Load the built in initramfs */ @@ -726,6 +744,10 @@ static void __init do_populate_rootfs(void *unused, as= ync_cookie_t cookie) if (!initrd_start || IS_ENABLED(CONFIG_INITRAMFS_FORCE)) goto done; =20 + if (initramfs_debug) + debug_initrd_crc32((char *)initrd_start, + initrd_end - initrd_start); + if (IS_ENABLED(CONFIG_BLK_DEV_RAM)) printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n"); else --=20 2.43.0