linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Pingfan Liu <kernelfans@gmail.com>
To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: Pingfan Liu <kernelfans@gmail.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	kexec@lists.infradead.org
Subject: [PATCH 4/6] lib/decompress: Keep decompress routines based on selection
Date: Mon,  6 Mar 2023 11:03:03 +0800	[thread overview]
Message-ID: <20230306030305.15595-5-kernelfans@gmail.com> (raw)
In-Reply-To: <20230306030305.15595-1-kernelfans@gmail.com>

At present, many decompressing routines in lib/decompress*.c are in
__section(".init.text"). But they are required to decompress the kernel
image when kexec file load compressed kernel.

To solve this issue, define 'INIT' conditional based on the macro
CONFIG_HAVE_KEXEC_DECOMPRESS. Also make lib/decompress.c adopt this way.

Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: kexec@lists.infradead.org
To: linux-kernel@vger.kernel.org
---
 include/linux/decompress/mm.h | 9 ++++++++-
 lib/decompress.c              | 5 +++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
index 9192986b1a73..33d8fd13a5c6 100644
--- a/include/linux/decompress/mm.h
+++ b/include/linux/decompress/mm.h
@@ -92,11 +92,18 @@ MALLOC_VISIBLE void free(void *where)
 #define large_malloc(a) vmalloc(a)
 #define large_free(a) vfree(a)
 
-#define INIT __init
 #define STATIC
 
 #include <linux/init.h>
 
+#ifndef CONFIG_HAVE_KEXEC_DECOMPRESS
+#define INIT __init
+#else
+#define INIT
+#undef __initconst
+#define __initconst
+#endif
+
 #endif /* STATIC */
 
 #endif /* DECOMPR_MM_H */
diff --git a/lib/decompress.c b/lib/decompress.c
index 8dd6f87e885f..33f097fe4b51 100644
--- a/lib/decompress.c
+++ b/lib/decompress.c
@@ -6,6 +6,7 @@
  */
 
 #include <linux/decompress/generic.h>
+#include <linux/decompress/mm.h>
 
 #include <linux/decompress/bunzip2.h>
 #include <linux/decompress/unlzma.h>
@@ -60,7 +61,7 @@ static const struct compress_format compressed_formats[] __initconst = {
 	{ {0, 0}, NULL, NULL }
 };
 
-decompress_fn __init decompress_method(const unsigned char *inbuf, long len,
+decompress_fn INIT decompress_method(const unsigned char *inbuf, long len,
 				const char **name)
 {
 	const struct compress_format *cf;
@@ -83,7 +84,7 @@ decompress_fn __init decompress_method(const unsigned char *inbuf, long len,
 	return cf->decompressor;
 }
 
-decompress_fn __init decompress_method_by_name(const unsigned char *name)
+decompress_fn INIT decompress_method_by_name(const unsigned char *name)
 {
 	const struct compress_format *cf;
 
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-03-06  3:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06  3:02 [PATCH 0/6] arm64: make kexec_file able to load zboot image Pingfan Liu
2023-03-06  3:03 ` [PATCH 1/6] arm64: kexec: Rename kexec_image.c to kexec_raw_image.c Pingfan Liu
2023-03-06  3:03 ` [PATCH 2/6] lib/decompress: Introduce decompress_method_by_name() Pingfan Liu
2023-03-06  3:03 ` [PATCH 3/6] arm64: Kconfig: Pick decompressing method for kexec file load Pingfan Liu
2023-03-06  3:03 ` Pingfan Liu [this message]
2023-03-06  3:03 ` [PATCH 5/6] arm64: kexec: Introduce zboot image loader Pingfan Liu
2023-03-06  3:03 ` [PATCH 6/6] init/Kconfig: Select decompressing method if compressing kernel Pingfan Liu
2023-03-06  8:08 ` [PATCH 0/6] arm64: make kexec_file able to load zboot image Ard Biesheuvel
2023-03-07  8:08   ` Pingfan Liu
2023-03-10  4:17     ` Pingfan Liu
2023-03-22  3:44       ` Dave Young
2023-03-23  3:40         ` Pingfan Liu
2023-03-10  8:57 ` Naresh Kamboju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230306030305.15595-5-kernelfans@gmail.com \
    --to=kernelfans@gmail.com \
    --cc=ardb@kernel.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).