linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] riscv: make image compression configurable
@ 2024-05-04 19:34 Emil Renner Berthing
  2024-05-04 19:34 ` [PATCH v2 1/2] " Emil Renner Berthing
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Emil Renner Berthing @ 2024-05-04 19:34 UTC (permalink / raw)
  To: linux-riscv, linux-kernel, linux-kbuild
  Cc: Paul Walmsley, Palmer Dabbelt, Masahiro Yamada,
	Nathan Chancellor, Nicolas Schier, Nick Terrell

Masahiro's patch[1] made me wonder why we're not just using KBUILD_IMAGE
to determine which (possibly compressed) kernel image to use in 'make
tar-pkg' like other architectures do. It turns out we're always setting
KBUILD_IMAGE to the uncompressed Image file and then compressing it into
the Image.gz file afterwards.

This series fixes that so the compression method is configurable and
KBUILD_IMAGE is set to the chosen (possibly uncompressed) kernel image
which is then used by targets like 'make install' and 'make bindeb-pkg' and
'make tar-pkg'.

Changes in v2:
- Rebase on riscv/for-next
- Use boot-image-$(CONFIG_..) := assignments rather than ifeq train in
  patch 1
- Drop patch 3 already applied to kbuild/for-next

Emil Renner Berthing (2):
  riscv: make image compression configurable
  riscv: show help string for riscv-specific targets

 arch/riscv/Kconfig         |  7 +++++
 arch/riscv/Makefile        | 55 ++++++++++++++++++++++++--------------
 arch/riscv/boot/install.sh |  9 ++++---
 3 files changed, 48 insertions(+), 23 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] riscv: make image compression configurable
  2024-05-04 19:34 [PATCH v2 0/2] riscv: make image compression configurable Emil Renner Berthing
@ 2024-05-04 19:34 ` Emil Renner Berthing
  2024-05-07 12:34   ` Nicolas Schier
  2024-05-07 14:26   ` Masahiro Yamada
  2024-05-04 19:34 ` [PATCH v2 2/2] riscv: show help string for riscv-specific targets Emil Renner Berthing
  2024-05-15 13:40 ` [PATCH v2 0/2] riscv: make image compression configurable patchwork-bot+linux-riscv
  2 siblings, 2 replies; 7+ messages in thread
From: Emil Renner Berthing @ 2024-05-04 19:34 UTC (permalink / raw)
  To: linux-riscv, linux-kernel, linux-kbuild
  Cc: Paul Walmsley, Palmer Dabbelt, Masahiro Yamada,
	Nathan Chancellor, Nicolas Schier, Nick Terrell,
	Björn Töpel

Previously the build process would always set KBUILD_IMAGE to the
uncompressed Image file (unless XIP_KERNEL or EFI_ZBOOT was enabled) and
unconditionally compress it into Image.gz. However there are already
build targets for Image.bz2, Image.lz4, Image.lzma, Image.lzo and
Image.zstd, so let's make use of those, make the compression method
configurable and set KBUILD_IMAGE accordingly so that targets like
'make install' and 'make bindeb-pkg' will use the chosen image.

Tested-by: Björn Töpel <bjorn@rivosinc.com>
Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
---
Changes in v2:
- Rebase on riscv/for-next
- Use boot-image-$(CONFIG_..) := assignments rather than ifeq train
---
 arch/riscv/Kconfig         |  7 +++++++
 arch/riscv/Makefile        | 38 ++++++++++++++++++--------------------
 arch/riscv/boot/install.sh |  9 ++++++---
 3 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 6bec1bce6586..79e558397f41 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -140,6 +140,13 @@ config RISCV
 	select HAVE_GCC_PLUGINS
 	select HAVE_GENERIC_VDSO if MMU && 64BIT
 	select HAVE_IRQ_TIME_ACCOUNTING
+	select HAVE_KERNEL_BZIP2 if !XIP_KERNEL && !EFI_ZBOOT
+	select HAVE_KERNEL_GZIP if !XIP_KERNEL && !EFI_ZBOOT
+	select HAVE_KERNEL_LZ4 if !XIP_KERNEL && !EFI_ZBOOT
+	select HAVE_KERNEL_LZMA if !XIP_KERNEL && !EFI_ZBOOT
+	select HAVE_KERNEL_LZO if !XIP_KERNEL && !EFI_ZBOOT
+	select HAVE_KERNEL_UNCOMPRESSED if !XIP_KERNEL && !EFI_ZBOOT
+	select HAVE_KERNEL_ZSTD if !XIP_KERNEL && !EFI_ZBOOT
 	select HAVE_KPROBES if !XIP_KERNEL
 	select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL
 	select HAVE_KRETPROBES if !XIP_KERNEL
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 8b2ae27f1d98..07ff2f34f0dc 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -136,20 +136,20 @@ endif
 CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
 
 # Default target when executing plain make
-boot		:= arch/riscv/boot
-ifeq ($(CONFIG_XIP_KERNEL),y)
-KBUILD_IMAGE := $(boot)/xipImage
-else
-ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
-KBUILD_IMAGE := $(boot)/loader.bin
-else
-ifeq ($(CONFIG_EFI_ZBOOT),)
-KBUILD_IMAGE	:= $(boot)/Image.gz
-else
-KBUILD_IMAGE := $(boot)/vmlinuz.efi
-endif
-endif
+boot					:= arch/riscv/boot
+boot-image-y				:= Image
+boot-image-$(CONFIG_KERNEL_BZIP2)	:= Image.bz2
+boot-image-$(CONFIG_KERNEL_GZIP)	:= Image.gz
+boot-image-$(CONFIG_KERNEL_LZ4)		:= Image.lz4
+boot-image-$(CONFIG_KERNEL_LZMA)	:= Image.lzma
+boot-image-$(CONFIG_KERNEL_LZO)		:= Image.lzo
+boot-image-$(CONFIG_KERNEL_ZSTD)	:= Image.zst
+ifdef CONFIG_RISCV_M_MODE
+boot-image-$(CONFIG_ARCH_CANAAN)	:= loader.bin
 endif
+boot-image-$(CONFIG_EFI_ZBOOT)		:= vmlinuz.efi
+boot-image-$(CONFIG_XIP_KERNEL)		:= xipImage
+KBUILD_IMAGE				:= $(boot)/$(boot-image-y)
 
 libs-y += arch/riscv/lib/
 libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
@@ -168,21 +168,19 @@ endif
 vdso-install-y			+= arch/riscv/kernel/vdso/vdso.so.dbg
 vdso-install-$(CONFIG_COMPAT)	+= arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg
 
-BOOT_TARGETS := Image Image.gz loader loader.bin xipImage vmlinuz.efi
+BOOT_TARGETS := Image Image.gz Image.bz2 Image.lz4 Image.lzma Image.lzo Image.zst loader loader.bin xipImage vmlinuz.efi
 
 all:	$(notdir $(KBUILD_IMAGE))
 
 loader.bin: loader
-Image.gz loader vmlinuz.efi: Image
+Image.gz Image.bz2 Image.lz4 Image.lzma Image.lzo Image.zst loader xipImage vmlinuz.efi: Image
+
 $(BOOT_TARGETS): vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 	@$(kecho) '  Kernel: $(boot)/$@ is ready'
 
-Image.%: Image
-	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
-
-install: KBUILD_IMAGE := $(boot)/Image
-zinstall: KBUILD_IMAGE := $(boot)/Image.gz
+# the install target always installs KBUILD_IMAGE (which may be compressed)
+# but keep the zinstall target for compatibility with older releases
 install zinstall:
 	$(call cmd,install)
 
diff --git a/arch/riscv/boot/install.sh b/arch/riscv/boot/install.sh
index 4c63f3f0643d..a8df7591513a 100755
--- a/arch/riscv/boot/install.sh
+++ b/arch/riscv/boot/install.sh
@@ -17,15 +17,18 @@
 #   $3 - kernel map file
 #   $4 - default install path (blank if root directory)
 
-if [ "$(basename $2)" = "Image.gz" ]; then
+case "${2##*/}" in
 # Compressed install
+Image.*|vmlinuz.efi)
   echo "Installing compressed kernel"
   base=vmlinuz
-else
+  ;;
 # Normal install
+*)
   echo "Installing normal kernel"
   base=vmlinux
-fi
+  ;;
+esac
 
 if [ -f $4/$base-$1 ]; then
   mv $4/$base-$1 $4/$base-$1.old
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] riscv: show help string for riscv-specific targets
  2024-05-04 19:34 [PATCH v2 0/2] riscv: make image compression configurable Emil Renner Berthing
  2024-05-04 19:34 ` [PATCH v2 1/2] " Emil Renner Berthing
@ 2024-05-04 19:34 ` Emil Renner Berthing
  2024-05-07 14:26   ` Masahiro Yamada
  2024-05-15 13:40 ` [PATCH v2 0/2] riscv: make image compression configurable patchwork-bot+linux-riscv
  2 siblings, 1 reply; 7+ messages in thread
From: Emil Renner Berthing @ 2024-05-04 19:34 UTC (permalink / raw)
  To: linux-riscv, linux-kernel, linux-kbuild
  Cc: Paul Walmsley, Palmer Dabbelt, Masahiro Yamada,
	Nathan Chancellor, Nicolas Schier, Nick Terrell,
	Björn Töpel

Define the archhelp variable so that 'make ACRH=riscv help' will show
the targets specific to building a RISC-V kernel like other
architectures.

Tested-by: Björn Töpel <bjorn@rivosinc.com>
Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
---
 arch/riscv/Makefile | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 07ff2f34f0dc..ae51720199a3 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -201,3 +201,20 @@ rv32_defconfig:
 PHONY += rv32_nommu_virt_defconfig
 rv32_nommu_virt_defconfig:
 	$(Q)$(MAKE) -f $(srctree)/Makefile nommu_virt_defconfig 32-bit.config
+
+define archhelp
+  echo  '  Image		- Uncompressed kernel image (arch/riscv/boot/Image)'
+  echo  '  Image.gz	- Compressed kernel image (arch/riscv/boot/Image.gz)'
+  echo  '  Image.bz2	- Compressed kernel image (arch/riscv/boot/Image.bz2)'
+  echo  '  Image.lz4	- Compressed kernel image (arch/riscv/boot/Image.lz4)'
+  echo  '  Image.lzma	- Compressed kernel image (arch/riscv/boot/Image.lzma)'
+  echo  '  Image.lzo	- Compressed kernel image (arch/riscv/boot/Image.lzo)'
+  echo  '  Image.zst	- Compressed kernel image (arch/riscv/boot/Image.zst)'
+  echo  '  vmlinuz.efi	- Compressed EFI kernel image (arch/riscv/boot/vmlinuz.efi)'
+  echo  '		  Default when CONFIG_EFI_ZBOOT=y'
+  echo  '  xipImage	- Execute-in-place kernel image (arch/riscv/boot/xipImage)'
+  echo  '		  Default when CONFIG_XIP_KERNEL=y'
+  echo  '  install	- Install kernel using (your) ~/bin/$(INSTALLKERNEL) or'
+  echo  '		  (distribution) /sbin/$(INSTALLKERNEL) or install to '
+  echo  '		  $$(INSTALL_PATH)'
+endef
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] riscv: make image compression configurable
  2024-05-04 19:34 ` [PATCH v2 1/2] " Emil Renner Berthing
@ 2024-05-07 12:34   ` Nicolas Schier
  2024-05-07 14:26   ` Masahiro Yamada
  1 sibling, 0 replies; 7+ messages in thread
From: Nicolas Schier @ 2024-05-07 12:34 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: linux-riscv, linux-kernel, linux-kbuild, Paul Walmsley,
	Palmer Dabbelt, Masahiro Yamada, Nathan Chancellor, Nick Terrell,
	Björn Töpel

On Sat, May 04, 2024 at 09:34:38PM +0200, Emil Renner Berthing wrote:
> Previously the build process would always set KBUILD_IMAGE to the
> uncompressed Image file (unless XIP_KERNEL or EFI_ZBOOT was enabled) and
> unconditionally compress it into Image.gz. However there are already
> build targets for Image.bz2, Image.lz4, Image.lzma, Image.lzo and
> Image.zstd, so let's make use of those, make the compression method
> configurable and set KBUILD_IMAGE accordingly so that targets like
> 'make install' and 'make bindeb-pkg' will use the chosen image.
> 
> Tested-by: Björn Töpel <bjorn@rivosinc.com>
> Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
> ---
> Changes in v2:
> - Rebase on riscv/for-next
> - Use boot-image-$(CONFIG_..) := assignments rather than ifeq train
> ---

Looks good to me.

Reviewed-by: Nicolas Schier <n.schier@avm.de>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] riscv: make image compression configurable
  2024-05-04 19:34 ` [PATCH v2 1/2] " Emil Renner Berthing
  2024-05-07 12:34   ` Nicolas Schier
@ 2024-05-07 14:26   ` Masahiro Yamada
  1 sibling, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2024-05-07 14:26 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: linux-riscv, linux-kernel, linux-kbuild, Paul Walmsley,
	Palmer Dabbelt, Nathan Chancellor, Nicolas Schier, Nick Terrell,
	Björn Töpel

On Sun, May 5, 2024 at 4:34 AM Emil Renner Berthing
<emil.renner.berthing@canonical.com> wrote:
>
> Previously the build process would always set KBUILD_IMAGE to the
> uncompressed Image file (unless XIP_KERNEL or EFI_ZBOOT was enabled) and
> unconditionally compress it into Image.gz. However there are already
> build targets for Image.bz2, Image.lz4, Image.lzma, Image.lzo and
> Image.zstd, so let's make use of those, make the compression method
> configurable and set KBUILD_IMAGE accordingly so that targets like
> 'make install' and 'make bindeb-pkg' will use the chosen image.
>
> Tested-by: Björn Töpel <bjorn@rivosinc.com>
> Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>



Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>





-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] riscv: show help string for riscv-specific targets
  2024-05-04 19:34 ` [PATCH v2 2/2] riscv: show help string for riscv-specific targets Emil Renner Berthing
@ 2024-05-07 14:26   ` Masahiro Yamada
  0 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2024-05-07 14:26 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: linux-riscv, linux-kernel, linux-kbuild, Paul Walmsley,
	Palmer Dabbelt, Nathan Chancellor, Nicolas Schier, Nick Terrell,
	Björn Töpel

On Sun, May 5, 2024 at 4:34 AM Emil Renner Berthing
<emil.renner.berthing@canonical.com> wrote:
>
> Define the archhelp variable so that 'make ACRH=riscv help' will show
> the targets specific to building a RISC-V kernel like other
> architectures.
>
> Tested-by: Björn Töpel <bjorn@rivosinc.com>
> Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
> ---

Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] riscv: make image compression configurable
  2024-05-04 19:34 [PATCH v2 0/2] riscv: make image compression configurable Emil Renner Berthing
  2024-05-04 19:34 ` [PATCH v2 1/2] " Emil Renner Berthing
  2024-05-04 19:34 ` [PATCH v2 2/2] riscv: show help string for riscv-specific targets Emil Renner Berthing
@ 2024-05-15 13:40 ` patchwork-bot+linux-riscv
  2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-05-15 13:40 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: linux-riscv, linux-kernel, linux-kbuild, paul.walmsley, palmer,
	masahiroy, nathan, nicolas, terrelln

Hello:

This series was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Sat,  4 May 2024 21:34:37 +0200 you wrote:
> Masahiro's patch[1] made me wonder why we're not just using KBUILD_IMAGE
> to determine which (possibly compressed) kernel image to use in 'make
> tar-pkg' like other architectures do. It turns out we're always setting
> KBUILD_IMAGE to the uncompressed Image file and then compressing it into
> the Image.gz file afterwards.
> 
> This series fixes that so the compression method is configurable and
> KBUILD_IMAGE is set to the chosen (possibly uncompressed) kernel image
> which is then used by targets like 'make install' and 'make bindeb-pkg' and
> 'make tar-pkg'.
> 
> [...]

Here is the summary with links:
  - [v2,1/2] riscv: make image compression configurable
    https://git.kernel.org/riscv/c/c1f59d035966
  - [v2,2/2] riscv: show help string for riscv-specific targets
    https://git.kernel.org/riscv/c/5e3964ba8400

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-15 13:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-04 19:34 [PATCH v2 0/2] riscv: make image compression configurable Emil Renner Berthing
2024-05-04 19:34 ` [PATCH v2 1/2] " Emil Renner Berthing
2024-05-07 12:34   ` Nicolas Schier
2024-05-07 14:26   ` Masahiro Yamada
2024-05-04 19:34 ` [PATCH v2 2/2] riscv: show help string for riscv-specific targets Emil Renner Berthing
2024-05-07 14:26   ` Masahiro Yamada
2024-05-15 13:40 ` [PATCH v2 0/2] riscv: make image compression configurable patchwork-bot+linux-riscv

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).