From nobody Mon Apr 6 10:43:24 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE1902877C3 for ; Sun, 22 Mar 2026 01:45:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774143925; cv=none; b=R79/W6ptCOW0Oz3MtVDiiUbspswQLCc7MfDs54yqXnz/ON+1JpmreIx5z3ETA4OoAFP+wj4NUxThp+ml17dPPUSL1BpSkMybmOLV8ubvYDtxMTB3XtbQcJVzjYqP5d05a6tp/az03EM/mTreU8GuqWzCgZ2AT9zaqTO1SF84Foo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774143925; c=relaxed/simple; bh=UuAqXKcT5q6g2TiflwpZ5mdUuQS0bA73dzrBlncB7JA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jM+/qdmil+N8+dMKdXUOItKTJ798JbLxZHnQj3/393ONnoYQPyZLm06yfLs//zrcGdWVMe9zTz/wNuYTYYQ4KQqHu6MCskUp1yySkSKQiIlwEyVuSOG7No/BuJjpGUZCQbbXjvEOjdyWyFkaJ72KlcBHTxKszqzHWxxzsQmt7OA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Hawh6WI7; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Hawh6WI7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774143922; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PRFUJjfw8UMJDn1AP+nn88xxm2eq7v+YRmLLVNEOIyw=; b=Hawh6WI7hXb8S0TG+06Z45Td+HtpiygouzkBladTtgws5qQVQfHWpCkjppKYQkElZTfsuP +I1whJnLWRw4uTkkFYrOdUaLtmIfAsh36E5zh649TpS1UKstXDyVJhhQcoB5MKzwTXKnAa +QBkYStrRe+YEaH9ll24WIPNVb0zoMM= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-488-ffZhTjeJPqmBcyCxX4zRnQ-1; Sat, 21 Mar 2026 21:45:19 -0400 X-MC-Unique: ffZhTjeJPqmBcyCxX4zRnQ-1 X-Mimecast-MFC-AGG-ID: ffZhTjeJPqmBcyCxX4zRnQ_1774143917 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AA91E19560B4; Sun, 22 Mar 2026 01:45:16 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.72.112.22]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 287AF300019F; Sun, 22 Mar 2026 01:45:02 +0000 (UTC) From: Pingfan Liu To: linux-kernel@vger.kernel.org Cc: Pingfan Liu , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , Jeremy Linton , Catalin Marinas , Will Deacon , Ard Biesheuvel , Simon Horman , Gerd Hoffmann , Vitaly Kuznetsov , Philipp Rudo , Viktor Malik , Jan Hendrik Farr , Baoquan He , Dave Young , Andrew Morton , kexec@lists.infradead.org, bpf@vger.kernel.org, systemd-devel@lists.freedesktop.org Subject: [PATCHv7 03/13] lib/decompress: Keep decompressor when CONFIG_KEEP_DECOMPRESSOR Date: Sun, 22 Mar 2026 09:43:52 +0800 Message-ID: <20260322014402.8815-4-piliu@redhat.com> In-Reply-To: <20260322014402.8815-1-piliu@redhat.com> References: <20260322014402.8815-1-piliu@redhat.com> 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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" The KEXE PE format parser needs the kernel built-in decompressor to decompress the kernel image. So moving the decompressor out of __init sections. Signed-off-by: Pingfan Liu Cc: Andrew Morton To: linux-kernel@vger.kernel.org --- include/linux/decompress/mm.h | 8 ++++++++ lib/Kconfig | 6 ++++++ lib/decompress.c | 6 +++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h index ac862422df158..39df02bcbc661 100644 --- a/include/linux/decompress/mm.h +++ b/include/linux/decompress/mm.h @@ -81,6 +81,7 @@ MALLOC_VISIBLE void free(void *where) #include #include #include +#include =20 /* Use defines rather than static inline in order to avoid spurious * warnings when not needed (indeed large_malloc / large_free are not @@ -92,7 +93,14 @@ MALLOC_VISIBLE void free(void *where) #define large_malloc(a) vmalloc(a) #define large_free(a) vfree(a) =20 +#ifdef CONFIG_KEEP_DECOMPRESSOR +#define INIT +#define INITCONST +#else #define INIT __init +#define INITCONST __initconst +#endif + #define STATIC =20 #include diff --git a/lib/Kconfig b/lib/Kconfig index 0f2fb96106476..e91347da12906 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -165,6 +165,12 @@ config RANDOM32_SELFTEST # # compression support is select'ed if needed # +config KEEP_DECOMPRESSOR + bool "keeps the decompress routines after kernel initialization" + default n + help + This option keeps the decompress routines after kernel initialization + config 842_COMPRESS select CRC32 tristate diff --git a/lib/decompress.c b/lib/decompress.c index 7785471586c62..29d4c749f1fc4 100644 --- a/lib/decompress.c +++ b/lib/decompress.c @@ -6,7 +6,7 @@ */ =20 #include - +#include #include #include #include @@ -48,7 +48,7 @@ struct compress_format { decompress_fn decompressor; }; =20 -static const struct compress_format compressed_formats[] __initconst =3D { +static const struct compress_format compressed_formats[] INITCONST =3D { { .magic =3D {0x1f, 0x8b}, .name =3D "gzip", .decompressor =3D gunzip }, { .magic =3D {0x1f, 0x9e}, .name =3D "gzip", .decompressor =3D gunzip }, { .magic =3D {0x42, 0x5a}, .name =3D "bzip2", .decompressor =3D bunzip2 }, @@ -60,7 +60,7 @@ static const struct compress_format compressed_formats[] = __initconst =3D { { /* sentinel */ } }; =20 -decompress_fn __init decompress_method(const unsigned char *inbuf, long le= n, +decompress_fn INIT decompress_method(const unsigned char *inbuf, long len, const char **name) { const struct compress_format *cf; --=20 2.49.0