* [PATCH] Revert "init/Kconfig: add option to disable kernel compression"
@ 2013-11-15 5:43 H. Peter Anvin
2013-11-15 16:51 ` [PATCH] [FIX] init/Kconfig: fix option to disable kernel compression Christian Ruppert
0 siblings, 1 reply; 15+ messages in thread
From: H. Peter Anvin @ 2013-11-15 5:43 UTC (permalink / raw)
To: Linus Torvalds
Cc: Linux Kernel Mailing List, Pavel Roskin, Ingo Molnar,
Thomas Gleixner, H. Peter Anvin, Christian Ruppert, Andrew Morton
From: "H. Peter Anvin" <hpa@zytor.com>
This reverts commit 69f0554ec261fd686ac7fa1c598cc9eb27b83a80.
This patch breaks randconfig on at least the x86-64 architecture, and
most likely on others. There is work underway to support uncompressed
kernels in a generic way, but it looks like it will amount to
rewriting the support from scratch; see the LKML thread in the Link:
for info.
Therefore, revert this change and wait for the fix.
Reported-by: Pavel Roskin <proski@gnu.org>
Cc: Christian Ruppert <christian.ruppert@abilis.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20131113113418.167b8ffd@IRBT4585
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
init/Kconfig | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/init/Kconfig b/init/Kconfig
index 5496f307988e..bc8911fab28e 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -118,6 +118,7 @@ config HAVE_KERNEL_LZ4
choice
prompt "Kernel compression mode"
default KERNEL_GZIP
+ depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4
help
The linux kernel is a kind of self-extracting executable.
Several compression algorithms are available, which differ
@@ -136,13 +137,6 @@ choice
If in doubt, select 'gzip'
-config KERNEL_UNCOMPRESSED
- bool "No compression"
- help
- No compression at all. The kernel is huge but the compression and
- decompression times are zero.
- This is usually not what you want.
-
config KERNEL_GZIP
bool "Gzip"
depends on HAVE_KERNEL_GZIP
--
1.8.3.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH] [FIX] init/Kconfig: fix option to disable kernel compression
2013-11-15 5:43 [PATCH] Revert "init/Kconfig: add option to disable kernel compression" H. Peter Anvin
@ 2013-11-15 16:51 ` Christian Ruppert
2013-11-16 9:42 ` Vineet Gupta
0 siblings, 1 reply; 15+ messages in thread
From: Christian Ruppert @ 2013-11-15 16:51 UTC (permalink / raw)
To: H. Peter Anvin, Linus Torvalds
Cc: Linux Kernel Mailing List, Pavel Roskin, Ingo Molnar,
Thomas Gleixner, Christian Ruppert, Andrew Morton, Sam Ravnborg,
Noam Camus, Joe Perches
Some architectures with self-decompressing kernel images did not compile
with commit 69f0554ec261fd686ac7fa1c598cc9eb27b83a80 because they don't
provide a non-decompression mechanism for uncompressed kernels.
Rectify this problem by allowing uncompressed kernels only for architectures
which explicitly state they support them.
Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com>
---
arch/arc/Kconfig | 2 ++
init/Kconfig | 5 +++++
2 files changed, 7 insertions(+)
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 2ee0c9b..15f4c3d 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -21,6 +21,8 @@ config ARC
select HAVE_ARCH_KGDB
select HAVE_ARCH_TRACEHOOK
select HAVE_IOREMAP_PROT
+ select HAVE_KERNEL_UNCOMPRESSED
+ select HAVE_KERNEL_GZIP
select HAVE_KPROBES
select HAVE_KRETPROBES
select HAVE_MEMBLOCK
diff --git a/init/Kconfig b/init/Kconfig
index 5496f30..d4baf2e 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -97,6 +97,9 @@ config LOCALVERSION_AUTO
which is done within the script "scripts/setlocalversion".)
+config HAVE_KERNEL_UNCOMPRESSED
+ bool
+
config HAVE_KERNEL_GZIP
bool
@@ -118,6 +121,7 @@ config HAVE_KERNEL_LZ4
choice
prompt "Kernel compression mode"
default KERNEL_GZIP
+ depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4 || HAVE_KERNEL_UNCOMPRESSED
help
The linux kernel is a kind of self-extracting executable.
Several compression algorithms are available, which differ
@@ -138,6 +142,7 @@ choice
config KERNEL_UNCOMPRESSED
bool "No compression"
+ depends on HAVE_KERNEL_UNCOMPRESSED
help
No compression at all. The kernel is huge but the compression and
decompression times are zero.
--
1.8.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] [FIX] init/Kconfig: fix option to disable kernel compression
2013-11-15 16:51 ` [PATCH] [FIX] init/Kconfig: fix option to disable kernel compression Christian Ruppert
@ 2013-11-16 9:42 ` Vineet Gupta
2013-11-18 9:48 ` Christian Ruppert
0 siblings, 1 reply; 15+ messages in thread
From: Vineet Gupta @ 2013-11-16 9:42 UTC (permalink / raw)
To: Christian Ruppert, H. Peter Anvin, Linus Torvalds
Cc: Linux Kernel Mailing List, Pavel Roskin, Ingo Molnar,
Thomas Gleixner, Andrew Morton, Sam Ravnborg, Noam Camus,
Joe Perches
On 11/15/2013 10:21 PM, Christian Ruppert wrote:
> Some architectures with self-decompressing kernel images did not compile
> with commit 69f0554ec261fd686ac7fa1c598cc9eb27b83a80 because they don't
> provide a non-decompression mechanism for uncompressed kernels.
>
> Rectify this problem by allowing uncompressed kernels only for architectures
> which explicitly state they support them.
>
> Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
> ---
> arch/arc/Kconfig | 2 ++
> init/Kconfig | 5 +++++
> 2 files changed, 7 insertions(+)
>
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index 2ee0c9b..15f4c3d 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -21,6 +21,8 @@ config ARC
> select HAVE_ARCH_KGDB
> select HAVE_ARCH_TRACEHOOK
> select HAVE_IOREMAP_PROT
> + select HAVE_KERNEL_UNCOMPRESSED
> + select HAVE_KERNEL_GZIP
> select HAVE_KPROBES
> select HAVE_KRETPROBES
> select HAVE_MEMBLOCK
> diff --git a/init/Kconfig b/init/Kconfig
> index 5496f30..d4baf2e 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -97,6 +97,9 @@ config LOCALVERSION_AUTO
>
> which is done within the script "scripts/setlocalversion".)
>
> +config HAVE_KERNEL_UNCOMPRESSED
> + bool
> +
> config HAVE_KERNEL_GZIP
> bool
>
> @@ -118,6 +121,7 @@ config HAVE_KERNEL_LZ4
> choice
> prompt "Kernel compression mode"
> default KERNEL_GZIP
> + depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4 || HAVE_KERNEL_UNCOMPRESSED
> help
> The linux kernel is a kind of self-extracting executable.
> Several compression algorithms are available, which differ
> @@ -138,6 +142,7 @@ choice
>
> config KERNEL_UNCOMPRESSED
> bool "No compression"
> + depends on HAVE_KERNEL_UNCOMPRESSED
> help
> No compression at all. The kernel is huge but the compression and
> decompression times are zero.
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] [FIX] init/Kconfig: fix option to disable kernel compression
2013-11-16 9:42 ` Vineet Gupta
@ 2013-11-18 9:48 ` Christian Ruppert
2013-11-18 9:51 ` [PATCH 1/2] init/Kconfig: add " Christian Ruppert
2013-11-18 9:51 ` [PATCH 2/2] x86: Add support for uncompressed kernel images Christian Ruppert
0 siblings, 2 replies; 15+ messages in thread
From: Christian Ruppert @ 2013-11-18 9:48 UTC (permalink / raw)
To: Vineet Gupta
Cc: H. Peter Anvin, Linus Torvalds, Linux Kernel Mailing List,
Pavel Roskin, Ingo Molnar, Thomas Gleixner, Andrew Morton,
Sam Ravnborg, Noam Camus, Joe Perches
On Sat, Nov 16, 2013 at 03:12:56PM +0530, Vineet Gupta wrote:
> On 11/15/2013 10:21 PM, Christian Ruppert wrote:
> > Some architectures with self-decompressing kernel images did not compile
> > with commit 69f0554ec261fd686ac7fa1c598cc9eb27b83a80 because they don't
> > provide a non-decompression mechanism for uncompressed kernels.
> >
> > Rectify this problem by allowing uncompressed kernels only for architectures
> > which explicitly state they support them.
> >
> > Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com>
> Acked-by: Vineet Gupta <vgupta@synopsys.com>
Looks like the revert was applied to main line (and not this fix). In
the follow-up the complete (fixed) patch set rebased on the latest main
line: First patch for Kconfig/ARC and as requested a cleaned up second
patch for x86. I could only test the second patch on one physical
machine and one VM so some more testing might be required on x86.
Greetings,
Christian
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/2] init/Kconfig: add option to disable kernel compression
2013-11-18 9:48 ` Christian Ruppert
@ 2013-11-18 9:51 ` Christian Ruppert
2013-11-18 9:51 ` [PATCH 2/2] x86: Add support for uncompressed kernel images Christian Ruppert
1 sibling, 0 replies; 15+ messages in thread
From: Christian Ruppert @ 2013-11-18 9:51 UTC (permalink / raw)
To: Vineet Gupta, H. Peter Anvin, Andrew Morton
Cc: Linus Torvalds, Linux Kernel Mailing List, Pavel Roskin,
Ingo Molnar, Thomas Gleixner, Sam Ravnborg, Noam Camus,
Joe Perches, Christian Ruppert
Some ARC users say they can boot faster with without kernel compression.
This probably depends on things like the FLASH chip they use etc.
Until now, kernel compression can only be disabled by removing "select
HAVE_<compression>" lines from the architecture Kconfig. So add the
Kconfig logic to permit disabling of kernel compression.
Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com>
---
arch/arc/Kconfig | 2 ++
init/Kconfig | 13 ++++++++++++-
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 2ee0c9b..15f4c3d 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -21,6 +21,8 @@ config ARC
select HAVE_ARCH_KGDB
select HAVE_ARCH_TRACEHOOK
select HAVE_IOREMAP_PROT
+ select HAVE_KERNEL_UNCOMPRESSED
+ select HAVE_KERNEL_GZIP
select HAVE_KPROBES
select HAVE_KRETPROBES
select HAVE_MEMBLOCK
diff --git a/init/Kconfig b/init/Kconfig
index 3fc8a2f..a21e94b 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -97,6 +97,9 @@ config LOCALVERSION_AUTO
which is done within the script "scripts/setlocalversion".)
+config HAVE_KERNEL_UNCOMPRESSED
+ bool
+
config HAVE_KERNEL_GZIP
bool
@@ -118,7 +121,7 @@ config HAVE_KERNEL_LZ4
choice
prompt "Kernel compression mode"
default KERNEL_GZIP
- depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4
+ depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4 || HAVE_KERNEL_UNCOMPRESSED
help
The linux kernel is a kind of self-extracting executable.
Several compression algorithms are available, which differ
@@ -137,6 +140,14 @@ choice
If in doubt, select 'gzip'
+config KERNEL_UNCOMPRESSED
+ bool "No compression"
+ depends on HAVE_KERNEL_UNCOMPRESSED
+ help
+ No compression at all. The kernel is huge but the compression and
+ decompression times are zero.
+ This is usually not what you want.
+
config KERNEL_GZIP
bool "Gzip"
depends on HAVE_KERNEL_GZIP
--
1.7.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/2] x86: Add support for uncompressed kernel images
2013-11-18 9:48 ` Christian Ruppert
2013-11-18 9:51 ` [PATCH 1/2] init/Kconfig: add " Christian Ruppert
@ 2013-11-18 9:51 ` Christian Ruppert
2013-11-18 11:25 ` Borislav Petkov
1 sibling, 1 reply; 15+ messages in thread
From: Christian Ruppert @ 2013-11-18 9:51 UTC (permalink / raw)
To: Vineet Gupta, H. Peter Anvin, Andrew Morton
Cc: Linus Torvalds, Linux Kernel Mailing List, Pavel Roskin,
Ingo Molnar, Thomas Gleixner, Sam Ravnborg, Noam Camus,
Joe Perches, Christian Ruppert
Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com>
---
arch/x86/Kconfig | 1 +
arch/x86/boot/compressed/Makefile | 14 ++++++------
arch/x86/boot/compressed/misc.c | 4 +++
lib/decompress_copy.c | 44 +++++++++++++++++++++++++++++++++++++
4 files changed, 56 insertions(+), 7 deletions(-)
create mode 100644 lib/decompress_copy.c
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index e903c71..009349f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -62,6 +62,7 @@ config X86
select USER_STACKTRACE_SUPPORT
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_DMA_API_DEBUG
+ select HAVE_KERNEL_UNCOMPRESSED
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_BZIP2
select HAVE_KERNEL_LZMA
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index dcd90df..f65e444 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -67,16 +67,16 @@ $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
$(call if_changed,lz4)
-suffix-$(CONFIG_KERNEL_GZIP) := gz
-suffix-$(CONFIG_KERNEL_BZIP2) := bz2
-suffix-$(CONFIG_KERNEL_LZMA) := lzma
-suffix-$(CONFIG_KERNEL_XZ) := xz
-suffix-$(CONFIG_KERNEL_LZO) := lzo
-suffix-$(CONFIG_KERNEL_LZ4) := lz4
+suffix-$(CONFIG_KERNEL_GZIP) := .gz
+suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
+suffix-$(CONFIG_KERNEL_LZMA) := .lzma
+suffix-$(CONFIG_KERNEL_XZ) := .xz
+suffix-$(CONFIG_KERNEL_LZO) := .lzo
+suffix-$(CONFIG_KERNEL_LZ4) := .lz4
quiet_cmd_mkpiggy = MKPIGGY $@
cmd_mkpiggy = $(obj)/mkpiggy $< > $@ || ( rm -f $@ ; false )
targets += piggy.S
-$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
+$(obj)/piggy.S: $(obj)/vmlinux.bin$(suffix-y) $(obj)/mkpiggy FORCE
$(call if_changed,mkpiggy)
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 434f077..c210314 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -149,6 +149,10 @@ static int lines, cols;
#include "../../../../lib/decompress_unlz4.c"
#endif
+#ifdef CONFIG_KERNEL_UNCOMPRESSED
+#include "../../../../lib/decompress_copy.c"
+#endif
+
static void scroll(void)
{
int i;
diff --git a/lib/decompress_copy.c b/lib/decompress_copy.c
new file mode 100644
index 0000000..109ef22
--- /dev/null
+++ b/lib/decompress_copy.c
@@ -0,0 +1,44 @@
+#include <linux/decompress/mm.h>
+
+#define NOZIP_BUFSZ (16 * 1024)
+STATIC int INIT nozip(unsigned char *buf, int len,
+ int(*fill)(void*, unsigned int),
+ int(*flush)(void*, unsigned int),
+ unsigned char *outbuf,
+ int *pos,
+ void(*error)(char *x))
+{
+ char *b;
+
+ if (buf)
+ b = buf;
+ else
+ b = malloc(NOZIP_BUFSZ);
+
+ if (!b) {
+ error("Out of memory while allocating buffer");
+ return -1;
+ }
+
+ if (flush) {
+ if (!len)
+ len = fill(b, NOZIP_BUFSZ);
+
+ len = flush(b, len);
+ } else {
+ if (!len)
+ len = fill(outbuf, NOZIP_BUFSZ);
+ else
+ memcpy(outbuf, b, len);
+ }
+
+ if (pos)
+ *pos = len;
+
+ if (!buf)
+ free(b);
+
+ return 0;
+}
+
+#define decompress nozip
--
1.7.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 2/2] x86: Add support for uncompressed kernel images
2013-11-18 9:51 ` [PATCH 2/2] x86: Add support for uncompressed kernel images Christian Ruppert
@ 2013-11-18 11:25 ` Borislav Petkov
2013-11-18 13:48 ` [PATCH 2/2 v2] " Christian Ruppert
0 siblings, 1 reply; 15+ messages in thread
From: Borislav Petkov @ 2013-11-18 11:25 UTC (permalink / raw)
To: Christian Ruppert
Cc: Vineet Gupta, H. Peter Anvin, Andrew Morton, Linus Torvalds,
Linux Kernel Mailing List, Pavel Roskin, Ingo Molnar,
Thomas Gleixner, Sam Ravnborg, Noam Camus, Joe Perches
On Mon, Nov 18, 2013 at 10:51:51AM +0100, Christian Ruppert wrote:
How about a commit message ... somewhere around here would be nice, for
example :)
> Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com>
> ---
> arch/x86/Kconfig | 1 +
> arch/x86/boot/compressed/Makefile | 14 ++++++------
> arch/x86/boot/compressed/misc.c | 4 +++
> lib/decompress_copy.c | 44 +++++++++++++++++++++++++++++++++++++
> 4 files changed, 56 insertions(+), 7 deletions(-)
> create mode 100644 lib/decompress_copy.c
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply [flat|nested] 15+ messages in thread* [PATCH 2/2 v2] x86: Add support for uncompressed kernel images
2013-11-18 11:25 ` Borislav Petkov
@ 2013-11-18 13:48 ` Christian Ruppert
2013-12-16 8:59 ` Christian Ruppert
0 siblings, 1 reply; 15+ messages in thread
From: Christian Ruppert @ 2013-11-18 13:48 UTC (permalink / raw)
To: Borislav Petkov, Vineet Gupta, H. Peter Anvin, Andrew Morton
Cc: Linus Torvalds, Linux Kernel Mailing List, Pavel Roskin,
Ingo Molnar, Thomas Gleixner, Sam Ravnborg, Noam Camus,
Joe Perches, Christian Ruppert
There seems to be some interest to enable uncompressed kernels also for x86
in addition to (embedded) ARC platforms.
Add the code to support uncompressed kernels to lib/, select the respective
Kconfig options for the x86 architecture and use this code in the x86 kernel
self-decompressor.
Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com>
---
arch/x86/Kconfig | 1 +
arch/x86/boot/compressed/Makefile | 14 ++++++------
arch/x86/boot/compressed/misc.c | 4 +++
lib/decompress_copy.c | 44 +++++++++++++++++++++++++++++++++++++
4 files changed, 56 insertions(+), 7 deletions(-)
create mode 100644 lib/decompress_copy.c
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index e903c71..009349f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -62,6 +62,7 @@ config X86
select USER_STACKTRACE_SUPPORT
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_DMA_API_DEBUG
+ select HAVE_KERNEL_UNCOMPRESSED
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_BZIP2
select HAVE_KERNEL_LZMA
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index dcd90df..f65e444 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -67,16 +67,16 @@ $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
$(call if_changed,lz4)
-suffix-$(CONFIG_KERNEL_GZIP) := gz
-suffix-$(CONFIG_KERNEL_BZIP2) := bz2
-suffix-$(CONFIG_KERNEL_LZMA) := lzma
-suffix-$(CONFIG_KERNEL_XZ) := xz
-suffix-$(CONFIG_KERNEL_LZO) := lzo
-suffix-$(CONFIG_KERNEL_LZ4) := lz4
+suffix-$(CONFIG_KERNEL_GZIP) := .gz
+suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
+suffix-$(CONFIG_KERNEL_LZMA) := .lzma
+suffix-$(CONFIG_KERNEL_XZ) := .xz
+suffix-$(CONFIG_KERNEL_LZO) := .lzo
+suffix-$(CONFIG_KERNEL_LZ4) := .lz4
quiet_cmd_mkpiggy = MKPIGGY $@
cmd_mkpiggy = $(obj)/mkpiggy $< > $@ || ( rm -f $@ ; false )
targets += piggy.S
-$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
+$(obj)/piggy.S: $(obj)/vmlinux.bin$(suffix-y) $(obj)/mkpiggy FORCE
$(call if_changed,mkpiggy)
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 434f077..c210314 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -149,6 +149,10 @@ static int lines, cols;
#include "../../../../lib/decompress_unlz4.c"
#endif
+#ifdef CONFIG_KERNEL_UNCOMPRESSED
+#include "../../../../lib/decompress_copy.c"
+#endif
+
static void scroll(void)
{
int i;
diff --git a/lib/decompress_copy.c b/lib/decompress_copy.c
new file mode 100644
index 0000000..109ef22
--- /dev/null
+++ b/lib/decompress_copy.c
@@ -0,0 +1,44 @@
+#include <linux/decompress/mm.h>
+
+#define NOZIP_BUFSZ (16 * 1024)
+STATIC int INIT nozip(unsigned char *buf, int len,
+ int(*fill)(void*, unsigned int),
+ int(*flush)(void*, unsigned int),
+ unsigned char *outbuf,
+ int *pos,
+ void(*error)(char *x))
+{
+ char *b;
+
+ if (buf)
+ b = buf;
+ else
+ b = malloc(NOZIP_BUFSZ);
+
+ if (!b) {
+ error("Out of memory while allocating buffer");
+ return -1;
+ }
+
+ if (flush) {
+ if (!len)
+ len = fill(b, NOZIP_BUFSZ);
+
+ len = flush(b, len);
+ } else {
+ if (!len)
+ len = fill(outbuf, NOZIP_BUFSZ);
+ else
+ memcpy(outbuf, b, len);
+ }
+
+ if (pos)
+ *pos = len;
+
+ if (!buf)
+ free(b);
+
+ return 0;
+}
+
+#define decompress nozip
--
1.7.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 2/2 v2] x86: Add support for uncompressed kernel images
2013-11-18 13:48 ` [PATCH 2/2 v2] " Christian Ruppert
@ 2013-12-16 8:59 ` Christian Ruppert
0 siblings, 0 replies; 15+ messages in thread
From: Christian Ruppert @ 2013-12-16 8:59 UTC (permalink / raw)
To: Borislav Petkov, Vineet Gupta, H. Peter Anvin, Andrew Morton
Cc: Linus Torvalds, Linux Kernel Mailing List, Pavel Roskin,
Ingo Molnar, Thomas Gleixner, Sam Ravnborg, Noam Camus,
Joe Perches
On Mon, Nov 18, 2013 at 02:48:30PM +0100, Christian Ruppert wrote:
> There seems to be some interest to enable uncompressed kernels also for x86
> in addition to (embedded) ARC platforms.
>
> Add the code to support uncompressed kernels to lib/, select the respective
> Kconfig options for the x86 architecture and use this code in the x86 kernel
> self-decompressor.
Any news on this? Was someone able to take a look at / test this patch?
I have given it some more testing and encountered no issues so far.
Greetings,
Christian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Uncompressed kernel doesn't build on x86_64
@ 2013-11-14 8:32 Christian Ruppert
2013-11-14 8:38 ` [PATCH 2/2] x86: Add support for uncompressed kernel images Christian Ruppert
0 siblings, 1 reply; 15+ messages in thread
From: Christian Ruppert @ 2013-11-14 8:32 UTC (permalink / raw)
To: Pavel Roskin
Cc: linux-kernel, Andrew Morton, H. Peter Anvin, Vineet Gupta,
Noam Camus
On Wed, Nov 13, 2013 at 11:34:18AM -0500, Pavel Roskin wrote:
> Hi Christian,
>
> Your recent patch enables uncompressed kernels, but selecting that
> option (CONFIG_KERNEL_UNCOMPRESSED) fails on x86_86:
> [...]
> arch/x86/boot/compressed/Makefile has no provision for uncompressed
> files. There is no definition for suffix-$(CONFIG_KERNEL_UNCOMPRESSED)
> so $(suffix-y) evaluates to an empty string and there is no rule to
> make vmlinuz.bin.$(suffix-y)
>
> I think the patch should be either reverted or fixed as soon as
> possible.
This is an interesting observation, thanks. Although this patch is
rather intended for embedded architectures than x86, it highlights
potential issues with self-decompressing images of all sorts. I have no
way of testing all architectures and so I'm sending two patches in the
follow-up:
1. A conservative version of the original patch which requires
architectures to explicitly enable uncompresed kernel images if they
support compression as well and falls back to previous behaviour if
nothing is specified. I have copied Vineet Gupta (maintainer of the
ARC platform) since I enabled GZIP and uncompressed kernels for ARC
by default.
2. A patch to enable uncompressed x86 kernels. As stated above, I don't
think this makes a lot of sense in itself but it might serve as an
example for people working on other platforms with self-extracting
kernels and the nozip not-decompression algorithm might be useful on
those platforms as well. I only had a single x86-64 machine available
to test this, however, so some more testing might be required.
> Any suggestions for uncompressed suffix? I'd go with "copy". Then the
> "compression" could be a symlink. Alternatively, the "." could be
> included in other suffixes, the uncompressed suffix would be empty and
> the compression would be an empty statement.
I followed H. Peter's suggestion and chose option 2 in patch 2.
Greetings,
Christian
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/2] x86: Add support for uncompressed kernel images
2013-11-14 8:32 Uncompressed kernel doesn't build on x86_64 Christian Ruppert
@ 2013-11-14 8:38 ` Christian Ruppert
2013-11-14 17:31 ` H. Peter Anvin
2013-11-14 17:45 ` H. Peter Anvin
0 siblings, 2 replies; 15+ messages in thread
From: Christian Ruppert @ 2013-11-14 8:38 UTC (permalink / raw)
To: Pavel Roskin, Andrew Morton
Cc: linux-kernel, H. Peter Anvin, Vineet Gupta, Noam Camus,
Christian Ruppert
Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com>
---
arch/x86/Kconfig | 1 +
arch/x86/boot/compressed/Makefile | 14 ++++++------
arch/x86/boot/compressed/misc.c | 4 ++++
lib/decompress_copy.c | 47 +++++++++++++++++++++++++++++++++++++++
4 files changed, 59 insertions(+), 7 deletions(-)
create mode 100644 lib/decompress_copy.c
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f67e839..2a32df9 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -61,6 +61,7 @@ config X86
select USER_STACKTRACE_SUPPORT
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_DMA_API_DEBUG
+ select HAVE_KERNEL_UNCOMPRESSED
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_BZIP2
select HAVE_KERNEL_LZMA
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index dcd90df..f65e444 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -67,16 +67,16 @@ $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
$(call if_changed,lz4)
-suffix-$(CONFIG_KERNEL_GZIP) := gz
-suffix-$(CONFIG_KERNEL_BZIP2) := bz2
-suffix-$(CONFIG_KERNEL_LZMA) := lzma
-suffix-$(CONFIG_KERNEL_XZ) := xz
-suffix-$(CONFIG_KERNEL_LZO) := lzo
-suffix-$(CONFIG_KERNEL_LZ4) := lz4
+suffix-$(CONFIG_KERNEL_GZIP) := .gz
+suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
+suffix-$(CONFIG_KERNEL_LZMA) := .lzma
+suffix-$(CONFIG_KERNEL_XZ) := .xz
+suffix-$(CONFIG_KERNEL_LZO) := .lzo
+suffix-$(CONFIG_KERNEL_LZ4) := .lz4
quiet_cmd_mkpiggy = MKPIGGY $@
cmd_mkpiggy = $(obj)/mkpiggy $< > $@ || ( rm -f $@ ; false )
targets += piggy.S
-$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
+$(obj)/piggy.S: $(obj)/vmlinux.bin$(suffix-y) $(obj)/mkpiggy FORCE
$(call if_changed,mkpiggy)
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 434f077..c210314 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -149,6 +149,10 @@ static int lines, cols;
#include "../../../../lib/decompress_unlz4.c"
#endif
+#ifdef CONFIG_KERNEL_UNCOMPRESSED
+#include "../../../../lib/decompress_copy.c"
+#endif
+
static void scroll(void)
{
int i;
diff --git a/lib/decompress_copy.c b/lib/decompress_copy.c
new file mode 100644
index 0000000..8a41090
--- /dev/null
+++ b/lib/decompress_copy.c
@@ -0,0 +1,47 @@
+#include <linux/decompress/mm.h>
+
+#define NOZIP_BUFSZ (16 * 1024)
+STATIC int INIT nozip(unsigned char *buf, int len,
+ int(*fill)(void*, unsigned int),
+ int(*flush)(void*, unsigned int),
+ unsigned char *outbuf,
+ int *pos,
+ void(*error)(char *x))
+{
+ char *b;
+
+ if (buf)
+ b = buf;
+ else
+ b = malloc(NOZIP_BUFSZ);
+
+ if (!b) {
+ error("Out of memory while allocating buffer");
+ return -1;
+ }
+
+ if (flush) {
+ if (!len)
+ len = fill(b, NOZIP_BUFSZ);
+
+ len = flush(b, len);
+ } else {
+ if (!len)
+ len = fill(outbuf, NOZIP_BUFSZ);
+ else {
+ int i;
+ for (i = 0; i < len; i++)
+ outbuf[i] = b[i];
+ }
+ }
+
+ if (pos)
+ *pos = len;
+
+ if (!buf)
+ free(b);
+
+ return 0;
+}
+
+#define decompress nozip
--
1.8.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 2/2] x86: Add support for uncompressed kernel images
2013-11-14 8:38 ` [PATCH 2/2] x86: Add support for uncompressed kernel images Christian Ruppert
@ 2013-11-14 17:31 ` H. Peter Anvin
2013-11-15 9:31 ` Christian Ruppert
2013-11-14 17:45 ` H. Peter Anvin
1 sibling, 1 reply; 15+ messages in thread
From: H. Peter Anvin @ 2013-11-14 17:31 UTC (permalink / raw)
To: Christian Ruppert, Pavel Roskin, Andrew Morton
Cc: linux-kernel, Vineet Gupta, Noam Camus
So it sounds like we're starting from the beginning - I presume that
means the patch currently in the kernel should be reverted first?
-hpa
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] x86: Add support for uncompressed kernel images
2013-11-14 8:38 ` [PATCH 2/2] x86: Add support for uncompressed kernel images Christian Ruppert
2013-11-14 17:31 ` H. Peter Anvin
@ 2013-11-14 17:45 ` H. Peter Anvin
2013-11-15 9:49 ` Christian Ruppert
1 sibling, 1 reply; 15+ messages in thread
From: H. Peter Anvin @ 2013-11-14 17:45 UTC (permalink / raw)
To: Christian Ruppert, Pavel Roskin, Andrew Morton
Cc: linux-kernel, Vineet Gupta, Noam Camus
On 11/14/2013 12:38 AM, Christian Ruppert wrote:
> diff --git a/lib/decompress_copy.c b/lib/decompress_copy.c
> new file mode 100644
> index 0000000..8a41090
> --- /dev/null
> +++ b/lib/decompress_copy.c
> @@ -0,0 +1,47 @@
> +#include <linux/decompress/mm.h>
> +
> +#define NOZIP_BUFSZ (16 * 1024)
> +STATIC int INIT nozip(unsigned char *buf, int len,
> + int(*fill)(void*, unsigned int),
> + int(*flush)(void*, unsigned int),
> + unsigned char *outbuf,
> + int *pos,
> + void(*error)(char *x))
> +{
> + char *b;
> +
> + if (buf)
> + b = buf;
> + else
> + b = malloc(NOZIP_BUFSZ);
> +
> + if (!b) {
> + error("Out of memory while allocating buffer");
> + return -1;
> + }
> +
> + if (flush) {
> + if (!len)
> + len = fill(b, NOZIP_BUFSZ);
> +
> + len = flush(b, len);
> + } else {
> + if (!len)
> + len = fill(outbuf, NOZIP_BUFSZ);
> + else {
> + int i;
> + for (i = 0; i < len; i++)
> + outbuf[i] = b[i];
Clever way of doing memcpy(). I know some other compression
implementations open-code memmove(), but using it for the entire data
set in the most common case is atrocious. If we need to get a default
implementation of memmove() we should just do that.
-hpa
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 2/2] x86: Add support for uncompressed kernel images
2013-11-14 17:45 ` H. Peter Anvin
@ 2013-11-15 9:49 ` Christian Ruppert
2013-11-15 10:06 ` H. Peter Anvin
0 siblings, 1 reply; 15+ messages in thread
From: Christian Ruppert @ 2013-11-15 9:49 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Pavel Roskin, Andrew Morton, linux-kernel, Vineet Gupta,
Noam Camus
On Thu, Nov 14, 2013 at 09:45:12AM -0800, H. Peter Anvin wrote:
> On 11/14/2013 12:38 AM, Christian Ruppert wrote:
> > diff --git a/lib/decompress_copy.c b/lib/decompress_copy.c
> > new file mode 100644
> > index 0000000..8a41090
> > --- /dev/null
> > +++ b/lib/decompress_copy.c
> > @@ -0,0 +1,47 @@
> > +#include <linux/decompress/mm.h>
> > +
> > +#define NOZIP_BUFSZ (16 * 1024)
> > +STATIC int INIT nozip(unsigned char *buf, int len,
> > + int(*fill)(void*, unsigned int),
> > + int(*flush)(void*, unsigned int),
> > + unsigned char *outbuf,
> > + int *pos,
> > + void(*error)(char *x))
> > +{
> > + char *b;
> > +
> > + if (buf)
> > + b = buf;
> > + else
> > + b = malloc(NOZIP_BUFSZ);
> > +
> > + if (!b) {
> > + error("Out of memory while allocating buffer");
> > + return -1;
> > + }
> > +
> > + if (flush) {
> > + if (!len)
> > + len = fill(b, NOZIP_BUFSZ);
> > +
> > + len = flush(b, len);
> > + } else {
> > + if (!len)
> > + len = fill(outbuf, NOZIP_BUFSZ);
> > + else {
> > + int i;
> > + for (i = 0; i < len; i++)
> > + outbuf[i] = b[i];
>
> Clever way of doing memcpy(). I know some other compression
> implementations open-code memmove(), but using it for the entire data
> set in the most common case is atrocious. If we need to get a default
> implementation of memmove() we should just do that.
Actually, the x86 architecture already contains a basic implementation
of memcpy in its self-decompressor. Correct me if I'm wrong but I guess
memmove is not required since I don't expect the output of a generic
decompression function to overlap with its input.
We can simply use that function if we agree that
. either nozip is x86 specific
. or every architecture using this code must bring along its own memcpy
implementation in its self-decompressor.
Do you think that would be OK?
Greetings,
Christian
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 2/2] x86: Add support for uncompressed kernel images
2013-11-15 9:49 ` Christian Ruppert
@ 2013-11-15 10:06 ` H. Peter Anvin
0 siblings, 0 replies; 15+ messages in thread
From: H. Peter Anvin @ 2013-11-15 10:06 UTC (permalink / raw)
To: Christian Ruppert
Cc: Pavel Roskin, Andrew Morton, linux-kernel, Vineet Gupta,
Noam Camus
On 11/15/2013 01:49 AM, Christian Ruppert wrote:
>
> Actually, the x86 architecture already contains a basic implementation
> of memcpy in its self-decompressor. Correct me if I'm wrong but I guess
> memmove is not required since I don't expect the output of a generic
> decompression function to overlap with its input.
>
> We can simply use that function if we agree that
> . either nozip is x86 specific
> . or every architecture using this code must bring along its own memcpy
> implementation in its self-decompressor.
>
> Do you think that would be OK?
>
I think all of them have memcpy().
-hpa
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2013-12-16 9:00 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-15 5:43 [PATCH] Revert "init/Kconfig: add option to disable kernel compression" H. Peter Anvin
2013-11-15 16:51 ` [PATCH] [FIX] init/Kconfig: fix option to disable kernel compression Christian Ruppert
2013-11-16 9:42 ` Vineet Gupta
2013-11-18 9:48 ` Christian Ruppert
2013-11-18 9:51 ` [PATCH 1/2] init/Kconfig: add " Christian Ruppert
2013-11-18 9:51 ` [PATCH 2/2] x86: Add support for uncompressed kernel images Christian Ruppert
2013-11-18 11:25 ` Borislav Petkov
2013-11-18 13:48 ` [PATCH 2/2 v2] " Christian Ruppert
2013-12-16 8:59 ` Christian Ruppert
-- strict thread matches above, loose matches on Subject: below --
2013-11-14 8:32 Uncompressed kernel doesn't build on x86_64 Christian Ruppert
2013-11-14 8:38 ` [PATCH 2/2] x86: Add support for uncompressed kernel images Christian Ruppert
2013-11-14 17:31 ` H. Peter Anvin
2013-11-15 9:31 ` Christian Ruppert
2013-11-14 17:45 ` H. Peter Anvin
2013-11-15 9:49 ` Christian Ruppert
2013-11-15 10:06 ` H. Peter Anvin
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).