2024-05-02 11:16:28

by Emil Renner Berthing

[permalink] [raw]
Subject: [PATCH v1 0/3] riscv: make image compression configurable

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

Patch 3/3 depends on the previously mentioned patch below.

[1]: https://lore.kernel.org/r/[email protected]

Emil Renner Berthing (3):
riscv: make image compression configurable
riscv: show help string for riscv-specific targets
kbuild: buildtar: install riscv compressed images as vmlinuz

arch/riscv/Kconfig | 7 +++++
arch/riscv/Makefile | 60 +++++++++++++++++++++++++-------------
arch/riscv/boot/install.sh | 9 ++++--
scripts/package/buildtar | 18 +++++-------
4 files changed, 61 insertions(+), 33 deletions(-)

--
2.43.0



2024-05-02 11:17:10

by Emil Renner Berthing

[permalink] [raw]
Subject: [PATCH v1 3/3] kbuild: buildtar: install riscv compressed images as vmlinuz

Use the KBUILD_IMAGE variable to determine the right kernel image to
install and install compressed images to /boot/vmlinuz-$version like the
'make install' target already does.

Signed-off-by: Emil Renner Berthing <[email protected]>
---
This patch depends on Masahiro's patch at
https://lore.kernel.org/r/[email protected]
---
scripts/package/buildtar | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index ed8d9b496305..fa9bd0795d22 100755
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -54,9 +54,8 @@ cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
# Install arch-specific kernel image(s)
#
# Note:
-# mips, arm64, and riscv copy the first image found. This may not produce
-# the desired outcome because it may pick up a stale file remaining in the
-# build tree.
+# mips and arm64 copy the first image found. This may not produce the desired
+# outcome because it may pick up a stale file remaining in the build tree.
#
case "${ARCH}" in
x86|i386|x86_64)
@@ -101,13 +100,12 @@ case "${ARCH}" in
done
;;
riscv)
- # Please note the following code may copy a stale file.
- for i in Image.bz2 Image.gz Image; do
- if [ -f "${objtree}/arch/riscv/boot/${i}" ] ; then
- cp -v -- "${objtree}/arch/riscv/boot/${i}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
- break
- fi
- done
+ case "${KBUILD_IMAGE##*/}" in
+ Image.*|vmlinuz.efi)
+ cp -v -- "$KBUILD_IMAGE" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}";;
+ *)
+ cp -v -- "$KBUILD_IMAGE" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}";;
+ esac
;;
*)
cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
--
2.43.0


2024-05-02 11:21:54

by Emil Renner Berthing

[permalink] [raw]
Subject: [PATCH v1 2/3] riscv: show help string for riscv-specific targets

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

Signed-off-by: Emil Renner Berthing <[email protected]>
---
arch/riscv/Makefile | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 29be676415d6..024482c68835 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -202,3 +202,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


2024-05-02 11:21:58

by Emil Renner Berthing

[permalink] [raw]
Subject: [PATCH v1 1/3] riscv: make image compression configurable

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.

Signed-off-by: Emil Renner Berthing <[email protected]>
---
arch/riscv/Kconfig | 7 +++++++
arch/riscv/Makefile | 43 ++++++++++++++++++++------------------
arch/riscv/boot/install.sh | 9 +++++---
3 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index be09c8836d56..6c092d1ea7db 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -138,6 +138,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 5b3115a19852..29be676415d6 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -129,11 +129,27 @@ endif
CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)

# Default target when executing plain make
-boot := arch/riscv/boot
+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),y)
+KBUILD_IMAGE := $(boot)/vmlinuz.efi
+else ifeq ($(CONFIG_KERNEL_GZIP),y)
+KBUILD_IMAGE := $(boot)/Image.gz
+else ifeq ($(CONFIG_KERNEL_BZIP2),y)
+KBUILD_IMAGE := $(boot)/Image.bz2
+else ifeq ($(CONFIG_KERNEL_LZ4),y)
+KBUILD_IMAGE := $(boot)/Image.lz4
+else ifeq ($(CONFIG_KERNEL_LZMA),y)
+KBUILD_IMAGE := $(boot)/Image.lzma
+else ifeq ($(CONFIG_KERNEL_LZO),y)
+KBUILD_IMAGE := $(boot)/Image.lzo
+else ifeq ($(CONFIG_KERNEL_ZSTD),y)
+KBUILD_IMAGE := $(boot)/Image.zst
else
-KBUILD_IMAGE := $(boot)/Image.gz
+KBUILD_IMAGE := $(boot)/Image
endif

libs-y += arch/riscv/lib/
@@ -153,32 +169,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

-ifneq ($(CONFIG_XIP_KERNEL),y)
-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
-endif
-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


2024-05-02 13:03:53

by Björn Töpel

[permalink] [raw]
Subject: Re: [PATCH v1 0/3] riscv: make image compression configurable

Emil Renner Berthing <[email protected]> writes:

> 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'.
>
> Patch 3/3 depends on the previously mentioned patch below.

Nice!

Tested-by: Björn Töpel <[email protected]>

2024-05-02 13:05:36

by Björn Töpel

[permalink] [raw]
Subject: Re: [PATCH v1 1/3] riscv: make image compression configurable

Emil Renner Berthing <[email protected]> writes:

> 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.
>
> Signed-off-by: Emil Renner Berthing <[email protected]>
> ---
> arch/riscv/Kconfig | 7 +++++++
> arch/riscv/Makefile | 43 ++++++++++++++++++++------------------
> arch/riscv/boot/install.sh | 9 +++++---
> 3 files changed, 36 insertions(+), 23 deletions(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index be09c8836d56..6c092d1ea7db 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -138,6 +138,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 5b3115a19852..29be676415d6 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -129,11 +129,27 @@ endif
> CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
>
> # Default target when executing plain make
> -boot := arch/riscv/boot
> +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),y)
> +KBUILD_IMAGE := $(boot)/vmlinuz.efi
> +else ifeq ($(CONFIG_KERNEL_GZIP),y)
> +KBUILD_IMAGE := $(boot)/Image.gz
> +else ifeq ($(CONFIG_KERNEL_BZIP2),y)
> +KBUILD_IMAGE := $(boot)/Image.bz2
> +else ifeq ($(CONFIG_KERNEL_LZ4),y)
> +KBUILD_IMAGE := $(boot)/Image.lz4
> +else ifeq ($(CONFIG_KERNEL_LZMA),y)
> +KBUILD_IMAGE := $(boot)/Image.lzma
> +else ifeq ($(CONFIG_KERNEL_LZO),y)
> +KBUILD_IMAGE := $(boot)/Image.lzo
> +else ifeq ($(CONFIG_KERNEL_ZSTD),y)
> +KBUILD_IMAGE := $(boot)/Image.zst
> else
> -KBUILD_IMAGE := $(boot)/Image.gz
> +KBUILD_IMAGE := $(boot)/Image
> endif

Really a nit/change if you want, but maybe doing something like
arch/s390/boot/Makefile does is easier to read:

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 024482c68835..70f08e9999b4 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -128,6 +128,14 @@ endif
# arch specific predefines for sparse
CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)

+suffix-$(CONFIG_KERNEL_GZIP) := .gz
+suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
+suffix-$(CONFIG_KERNEL_LZ4) := .lz4
+suffix-$(CONFIG_KERNEL_LZMA) := .lzma
+suffix-$(CONFIG_KERNEL_LZO) := .lzo
+suffix-$(CONFIG_KERNEL_XZ) := .xz
+suffix-$(CONFIG_KERNEL_ZSTD) := .zst
+
# Default target when executing plain make
boot := arch/riscv/boot
ifeq ($(CONFIG_XIP_KERNEL),y)
@@ -136,20 +144,8 @@ else ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
KBUILD_IMAGE := $(boot)/loader.bin
else ifeq ($(CONFIG_EFI_ZBOOT),y)
KBUILD_IMAGE := $(boot)/vmlinuz.efi
-else ifeq ($(CONFIG_KERNEL_GZIP),y)
-KBUILD_IMAGE := $(boot)/Image.gz
-else ifeq ($(CONFIG_KERNEL_BZIP2),y)
-KBUILD_IMAGE := $(boot)/Image.bz2
-else ifeq ($(CONFIG_KERNEL_LZ4),y)
-KBUILD_IMAGE := $(boot)/Image.lz4
-else ifeq ($(CONFIG_KERNEL_LZMA),y)
-KBUILD_IMAGE := $(boot)/Image.lzma
-else ifeq ($(CONFIG_KERNEL_LZO),y)
-KBUILD_IMAGE := $(boot)/Image.lzo
-else ifeq ($(CONFIG_KERNEL_ZSTD),y)
-KBUILD_IMAGE := $(boot)/Image.zst
else
-KBUILD_IMAGE := $(boot)/Image
+KBUILD_IMAGE := $(boot)/Image$(suffix-y)
endif



Björn

2024-05-04 12:50:30

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH v1 1/3] riscv: make image compression configurable

On Thu, May 2, 2024 at 10:05 PM Björn Töpel <bjorn@kernelorg> wrote:
>
> Emil Renner Berthing <[email protected]> writes:
>
> > 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.
> >
> > Signed-off-by: Emil Renner Berthing <[email protected]>
> > ---
> > arch/riscv/Kconfig | 7 +++++++
> > arch/riscv/Makefile | 43 ++++++++++++++++++++------------------
> > arch/riscv/boot/install.sh | 9 +++++---
> > 3 files changed, 36 insertions(+), 23 deletions(-)
> >
> > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > index be09c8836d56..6c092d1ea7db 100644
> > --- a/arch/riscv/Kconfig
> > +++ b/arch/riscv/Kconfig
> > @@ -138,6 +138,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 5b3115a19852..29be676415d6 100644
> > --- a/arch/riscv/Makefile
> > +++ b/arch/riscv/Makefile
> > @@ -129,11 +129,27 @@ endif
> > CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
> >
> > # Default target when executing plain make
> > -boot := arch/riscv/boot
> > +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),y)
> > +KBUILD_IMAGE := $(boot)/vmlinuz.efi
> > +else ifeq ($(CONFIG_KERNEL_GZIP),y)
> > +KBUILD_IMAGE := $(boot)/Image.gz
> > +else ifeq ($(CONFIG_KERNEL_BZIP2),y)
> > +KBUILD_IMAGE := $(boot)/Image.bz2
> > +else ifeq ($(CONFIG_KERNEL_LZ4),y)
> > +KBUILD_IMAGE := $(boot)/Image.lz4
> > +else ifeq ($(CONFIG_KERNEL_LZMA),y)
> > +KBUILD_IMAGE := $(boot)/Image.lzma
> > +else ifeq ($(CONFIG_KERNEL_LZO),y)
> > +KBUILD_IMAGE := $(boot)/Image.lzo
> > +else ifeq ($(CONFIG_KERNEL_ZSTD),y)
> > +KBUILD_IMAGE := $(boot)/Image.zst
> > else
> > -KBUILD_IMAGE := $(boot)/Image.gz
> > +KBUILD_IMAGE := $(boot)/Image
> > endif
>
> Really a nit/change if you want, but maybe doing something like
> arch/s390/boot/Makefile does is easier to read:
>
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 024482c68835..70f08e9999b4 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -128,6 +128,14 @@ endif
> # arch specific predefines for sparse
> CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
>
> +suffix-$(CONFIG_KERNEL_GZIP) := .gz
> +suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
> +suffix-$(CONFIG_KERNEL_LZ4) := .lz4
> +suffix-$(CONFIG_KERNEL_LZMA) := .lzma
> +suffix-$(CONFIG_KERNEL_LZO) := .lzo
> +suffix-$(CONFIG_KERNEL_XZ) := .xz
> +suffix-$(CONFIG_KERNEL_ZSTD) := .zst
> +
> # Default target when executing plain make
> boot := arch/riscv/boot
> ifeq ($(CONFIG_XIP_KERNEL),y)
> @@ -136,20 +144,8 @@ else ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
> KBUILD_IMAGE := $(boot)/loader.bin
> else ifeq ($(CONFIG_EFI_ZBOOT),y)
> KBUILD_IMAGE := $(boot)/vmlinuz.efi
> -else ifeq ($(CONFIG_KERNEL_GZIP),y)
> -KBUILD_IMAGE := $(boot)/Image.gz
> -else ifeq ($(CONFIG_KERNEL_BZIP2),y)
> -KBUILD_IMAGE := $(boot)/Image.bz2
> -else ifeq ($(CONFIG_KERNEL_LZ4),y)
> -KBUILD_IMAGE := $(boot)/Image.lz4
> -else ifeq ($(CONFIG_KERNEL_LZMA),y)
> -KBUILD_IMAGE := $(boot)/Image.lzma
> -else ifeq ($(CONFIG_KERNEL_LZO),y)
> -KBUILD_IMAGE := $(boot)/Image.lzo
> -else ifeq ($(CONFIG_KERNEL_ZSTD),y)
> -KBUILD_IMAGE := $(boot)/Image.zst
> else
> -KBUILD_IMAGE := $(boot)/Image
> +KBUILD_IMAGE := $(boot)/Image$(suffix-y)
> endif




Good idea.


If you avoid the 'else ifeq' chain completely,
you also could do like this:



boot-image-$(CONFIG_KERNEL_GZIP) := Image.gz
...
boot-image-$(CONFIG_KERNEL_ZSTD) := Image.zst
boot-image-$(CONFIG_KERNEL_UNCOMPRESSED) := Image
boot-image-$(CONFIG_RISCV_M_MODE) := loader.bin
boot-image-$(CONFIG_ARCH_CANAAN) := loader.bin
boot-image-$(CONFIG_EFI_ZBOOT) := vmlinuz.efi
boot-image-$(CONFIG_XIP_KERNEL) := xipImage

KBUILD_IMAGE := $(boot)/$(boot-image-y)



Emil's current patch will work, of course.




BTW, this patch will conflict with
3b938e231b660a278de2988ee77b832d665c5326
It lands in riscv subsystem.


--
Best Regards
Masahiro Yamada

2024-05-04 12:58:54

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH v1 3/3] kbuild: buildtar: install riscv compressed images as vmlinuz

On Thu, May 2, 2024 at 8:16 PM Emil Renner Berthing
<[email protected]> wrote:
>
> Use the KBUILD_IMAGE variable to determine the right kernel image to
> install and install compressed images to /boot/vmlinuz-$version like the
> 'make install' target already does.
>
> Signed-off-by: Emil Renner Berthing <[email protected]>
> ---
> This patch depends on Masahiro's patch at
> https://lore.kernel.org/r/[email protected]

Thank you for fixing the issue for riscv.
Only the question I have is how this patch series gets in.
If it waits for the next development cycle, it will be
cleanly applicable.

Anyway,

Acked-by: Masahiro Yamada <[email protected]>




--
Best Regards
Masahiro Yamada

2024-05-04 13:54:56

by Emil Renner Berthing

[permalink] [raw]
Subject: Re: [PATCH v1 1/3] riscv: make image compression configurable

Masahiro Yamada wrote:
> On Thu, May 2, 2024 at 10:05 PM Björn Töpel <[email protected]> wrote:
> >
> > Emil Renner Berthing <[email protected]> writes:
> >
> > > 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.
> > >
> > > Signed-off-by: Emil Renner Berthing <[email protected]>
> > > ---
> > > arch/riscv/Kconfig | 7 +++++++
> > > arch/riscv/Makefile | 43 ++++++++++++++++++++------------------
> > > arch/riscv/boot/install.sh | 9 +++++---
> > > 3 files changed, 36 insertions(+), 23 deletions(-)
> > >
> > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > index be09c8836d56..6c092d1ea7db 100644
> > > --- a/arch/riscv/Kconfig
> > > +++ b/arch/riscv/Kconfig
> > > @@ -138,6 +138,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 5b3115a19852..29be676415d6 100644
> > > --- a/arch/riscv/Makefile
> > > +++ b/arch/riscv/Makefile
> > > @@ -129,11 +129,27 @@ endif
> > > CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
> > >
> > > # Default target when executing plain make
> > > -boot := arch/riscv/boot
> > > +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),y)
> > > +KBUILD_IMAGE := $(boot)/vmlinuz.efi
> > > +else ifeq ($(CONFIG_KERNEL_GZIP),y)
> > > +KBUILD_IMAGE := $(boot)/Image.gz
> > > +else ifeq ($(CONFIG_KERNEL_BZIP2),y)
> > > +KBUILD_IMAGE := $(boot)/Image.bz2
> > > +else ifeq ($(CONFIG_KERNEL_LZ4),y)
> > > +KBUILD_IMAGE := $(boot)/Image.lz4
> > > +else ifeq ($(CONFIG_KERNEL_LZMA),y)
> > > +KBUILD_IMAGE := $(boot)/Image.lzma
> > > +else ifeq ($(CONFIG_KERNEL_LZO),y)
> > > +KBUILD_IMAGE := $(boot)/Image.lzo
> > > +else ifeq ($(CONFIG_KERNEL_ZSTD),y)
> > > +KBUILD_IMAGE := $(boot)/Image.zst
> > > else
> > > -KBUILD_IMAGE := $(boot)/Image.gz
> > > +KBUILD_IMAGE := $(boot)/Image
> > > endif
> >
> > Really a nit/change if you want, but maybe doing something like
> > arch/s390/boot/Makefile does is easier to read:
> >
> > diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> > index 024482c68835..70f08e9999b4 100644
> > --- a/arch/riscv/Makefile
> > +++ b/arch/riscv/Makefile
> > @@ -128,6 +128,14 @@ endif
> > # arch specific predefines for sparse
> > CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
> >
> > +suffix-$(CONFIG_KERNEL_GZIP) := .gz
> > +suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
> > +suffix-$(CONFIG_KERNEL_LZ4) := .lz4
> > +suffix-$(CONFIG_KERNEL_LZMA) := .lzma
> > +suffix-$(CONFIG_KERNEL_LZO) := .lzo
> > +suffix-$(CONFIG_KERNEL_XZ) := .xz
> > +suffix-$(CONFIG_KERNEL_ZSTD) := .zst
> > +
> > # Default target when executing plain make
> > boot := arch/riscv/boot
> > ifeq ($(CONFIG_XIP_KERNEL),y)
> > @@ -136,20 +144,8 @@ else ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
> > KBUILD_IMAGE := $(boot)/loader.bin
> > else ifeq ($(CONFIG_EFI_ZBOOT),y)
> > KBUILD_IMAGE := $(boot)/vmlinuz.efi
> > -else ifeq ($(CONFIG_KERNEL_GZIP),y)
> > -KBUILD_IMAGE := $(boot)/Image.gz
> > -else ifeq ($(CONFIG_KERNEL_BZIP2),y)
> > -KBUILD_IMAGE := $(boot)/Image.bz2
> > -else ifeq ($(CONFIG_KERNEL_LZ4),y)
> > -KBUILD_IMAGE := $(boot)/Image.lz4
> > -else ifeq ($(CONFIG_KERNEL_LZMA),y)
> > -KBUILD_IMAGE := $(boot)/Image.lzma
> > -else ifeq ($(CONFIG_KERNEL_LZO),y)
> > -KBUILD_IMAGE := $(boot)/Image.lzo
> > -else ifeq ($(CONFIG_KERNEL_ZSTD),y)
> > -KBUILD_IMAGE := $(boot)/Image.zst
> > else
> > -KBUILD_IMAGE := $(boot)/Image
> > +KBUILD_IMAGE := $(boot)/Image$(suffix-y)
> > endif
>
>
>
>
> Good idea.
>
>
> If you avoid the 'else ifeq' chain completely,
> you also could do like this:
>
>
>
> boot-image-$(CONFIG_KERNEL_GZIP) := Image.gz
> ...
> boot-image-$(CONFIG_KERNEL_ZSTD) := Image.zst
> boot-image-$(CONFIG_KERNEL_UNCOMPRESSED) := Image
> boot-image-$(CONFIG_RISCV_M_MODE) := loader.bin
> boot-image-$(CONFIG_ARCH_CANAAN) := loader.bin
> boot-image-$(CONFIG_EFI_ZBOOT) := vmlinuz.efi
> boot-image-$(CONFIG_XIP_KERNEL) := xipImage
>
> KBUILD_IMAGE := $(boot)/$(boot-image-y)

Hi Masahiro and Björn.

I like this approach. But I think it doesn't quite do the same when fx.
CONFIG_RISCV_M_MODE=n but CONFIG_ARCH_CANAAN=y which I think is a valid
configuration for the new Kendryte K230 support. In this case boot-image-y
would be overwritten with the loader.bin value even for S-mode kernels.

To keep the previous behaviour we'd need something like

boot-image-$(CONFIG_RISCV_M_MODE *and* CONFIG_ARCH_CANAAN) := loader.bin

Maybe just

ifeq ($(CONFIG_RISCV_M_MODE),y)
boot-image-$(CONFIG_ARCH_CANAAN) := loader.bin
endif

Do you guys have a better solution?

/Emil

>
>
>
> Emil's current patch will work, of course.
>
>
>
>
> BTW, this patch will conflict with
> 3b938e231b660a278de2988ee77b832d665c5326
> It lands in riscv subsystem.

Oh, you're right. I'll rebase on that for v2, thanks.

/Emil

2024-05-04 14:02:12

by Emil Renner Berthing

[permalink] [raw]
Subject: Re: [PATCH v1 3/3] kbuild: buildtar: install riscv compressed images as vmlinuz

Masahiro Yamada wrote:
> On Thu, May 2, 2024 at 8:16 PM Emil Renner Berthing
> <[email protected]> wrote:
> >
> > Use the KBUILD_IMAGE variable to determine the right kernel image to
> > install and install compressed images to /boot/vmlinuz-$version like the
> > 'make install' target already does.
> >
> > Signed-off-by: Emil Renner Berthing <[email protected]>
> > ---
> > This patch depends on Masahiro's patch at
> > https://lore.kernel.org/r/[email protected]
>
> Thank you for fixing the issue for riscv.
> Only the question I have is how this patch series gets in.
> If it waits for the next development cycle, it will be
> cleanly applicable.

I'm ok with waiting, but otherwise Palmer could take patch 1 and 2 and you
could take patch 3. The worst that can happen is that a bisect lands on your
branch that will only package the uncompressed Image in the tarballs even if
Image.gz or Image.bz2 exist. CONFIG_EFI_ZBOOT=y and CONFIG_XIP_KERNEL=y_kernels
will also be fine with only patch 3 applied.

> Anyway,
>
> Acked-by: Masahiro Yamada <[email protected]>

Thanks!

/Emil
>
>
>
>
> --
> Best Regards
> Masahiro Yamada
>
> _______________________________________________
> linux-riscv mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-riscv

2024-05-04 14:47:55

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH v1 3/3] kbuild: buildtar: install riscv compressed images as vmlinuz

On Sat, May 4, 2024 at 11:02 PM Emil Renner Berthing
<[email protected]> wrote:
>
> Masahiro Yamada wrote:
> > On Thu, May 2, 2024 at 8:16 PM Emil Renner Berthing
> > <[email protected]> wrote:
> > >
> > > Use the KBUILD_IMAGE variable to determine the right kernel image to
> > > install and install compressed images to /boot/vmlinuz-$version like the
> > > 'make install' target already does.
> > >
> > > Signed-off-by: Emil Renner Berthing <[email protected]>
> > > ---
> > > This patch depends on Masahiro's patch at
> > > https://lore.kernel.org/r/[email protected]
> >
> > Thank you for fixing the issue for riscv.
> > Only the question I have is how this patch series gets in.
> > If it waits for the next development cycle, it will be
> > cleanly applicable.
>
> I'm ok with waiting, but otherwise Palmer could take patch 1 and 2 and you
> could take patch 3. The worst that can happen is that a bisect lands on your
> branch that will only package the uncompressed Image in the tarballs even if
> Image.gz or Image.bz2 exist. CONFIG_EFI_ZBOOT=y and CONFIG_XIP_KERNEL=y_kernels
> will also be fine with only patch 3 applied.


Ah, OK. 3/3 is independently applicable.

I applied this to linux-kbuild now. Thanks.
(I added braces around KBUILD_IMAGE to keep consistency)


I leave the first two patches to Palmer.






--
Best Regards
Masahiro Yamada

2024-05-04 15:00:07

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH v1 1/3] riscv: make image compression configurable

On Sat, May 4, 2024 at 10:54 PM Emil Renner Berthing
<[email protected]> wrote:
>
> Masahiro Yamada wrote:
> > On Thu, May 2, 2024 at 10:05 PM Björn Töpel <[email protected]> wrote:
> > >
> > > Emil Renner Berthing <[email protected]> writes:
> > >
> > > > 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.
> > > >
> > > > Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonicalcom>
> > > > ---
> > > > arch/riscv/Kconfig | 7 +++++++
> > > > arch/riscv/Makefile | 43 ++++++++++++++++++++------------------
> > > > arch/riscv/boot/install.sh | 9 +++++---
> > > > 3 files changed, 36 insertions(+), 23 deletions(-)
> > > >
> > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > > index be09c8836d56..6c092d1ea7db 100644
> > > > --- a/arch/riscv/Kconfig
> > > > +++ b/arch/riscv/Kconfig
> > > > @@ -138,6 +138,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 5b3115a19852..29be676415d6 100644
> > > > --- a/arch/riscv/Makefile
> > > > +++ b/arch/riscv/Makefile
> > > > @@ -129,11 +129,27 @@ endif
> > > > CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
> > > >
> > > > # Default target when executing plain make
> > > > -boot := arch/riscv/boot
> > > > +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),y)
> > > > +KBUILD_IMAGE := $(boot)/vmlinuz.efi
> > > > +else ifeq ($(CONFIG_KERNEL_GZIP),y)
> > > > +KBUILD_IMAGE := $(boot)/Image.gz
> > > > +else ifeq ($(CONFIG_KERNEL_BZIP2),y)
> > > > +KBUILD_IMAGE := $(boot)/Image.bz2
> > > > +else ifeq ($(CONFIG_KERNEL_LZ4),y)
> > > > +KBUILD_IMAGE := $(boot)/Image.lz4
> > > > +else ifeq ($(CONFIG_KERNEL_LZMA),y)
> > > > +KBUILD_IMAGE := $(boot)/Image.lzma
> > > > +else ifeq ($(CONFIG_KERNEL_LZO),y)
> > > > +KBUILD_IMAGE := $(boot)/Image.lzo
> > > > +else ifeq ($(CONFIG_KERNEL_ZSTD),y)
> > > > +KBUILD_IMAGE := $(boot)/Image.zst
> > > > else
> > > > -KBUILD_IMAGE := $(boot)/Image.gz
> > > > +KBUILD_IMAGE := $(boot)/Image
> > > > endif
> > >
> > > Really a nit/change if you want, but maybe doing something like
> > > arch/s390/boot/Makefile does is easier to read:
> > >
> > > diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> > > index 024482c68835..70f08e9999b4 100644
> > > --- a/arch/riscv/Makefile
> > > +++ b/arch/riscv/Makefile
> > > @@ -128,6 +128,14 @@ endif
> > > # arch specific predefines for sparse
> > > CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
> > >
> > > +suffix-$(CONFIG_KERNEL_GZIP) := .gz
> > > +suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
> > > +suffix-$(CONFIG_KERNEL_LZ4) := .lz4
> > > +suffix-$(CONFIG_KERNEL_LZMA) := .lzma
> > > +suffix-$(CONFIG_KERNEL_LZO) := .lzo
> > > +suffix-$(CONFIG_KERNEL_XZ) := .xz
> > > +suffix-$(CONFIG_KERNEL_ZSTD) := .zst
> > > +
> > > # Default target when executing plain make
> > > boot := arch/riscv/boot
> > > ifeq ($(CONFIG_XIP_KERNEL),y)
> > > @@ -136,20 +144,8 @@ else ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
> > > KBUILD_IMAGE := $(boot)/loader.bin
> > > else ifeq ($(CONFIG_EFI_ZBOOT),y)
> > > KBUILD_IMAGE := $(boot)/vmlinuz.efi
> > > -else ifeq ($(CONFIG_KERNEL_GZIP),y)
> > > -KBUILD_IMAGE := $(boot)/Image.gz
> > > -else ifeq ($(CONFIG_KERNEL_BZIP2),y)
> > > -KBUILD_IMAGE := $(boot)/Image.bz2
> > > -else ifeq ($(CONFIG_KERNEL_LZ4),y)
> > > -KBUILD_IMAGE := $(boot)/Image.lz4
> > > -else ifeq ($(CONFIG_KERNEL_LZMA),y)
> > > -KBUILD_IMAGE := $(boot)/Image.lzma
> > > -else ifeq ($(CONFIG_KERNEL_LZO),y)
> > > -KBUILD_IMAGE := $(boot)/Image.lzo
> > > -else ifeq ($(CONFIG_KERNEL_ZSTD),y)
> > > -KBUILD_IMAGE := $(boot)/Image.zst
> > > else
> > > -KBUILD_IMAGE := $(boot)/Image
> > > +KBUILD_IMAGE := $(boot)/Image$(suffix-y)
> > > endif
> >
> >
> >
> >
> > Good idea.
> >
> >
> > If you avoid the 'else ifeq' chain completely,
> > you also could do like this:
> >
> >
> >
> > boot-image-$(CONFIG_KERNEL_GZIP) := Image.gz
> > ...
> > boot-image-$(CONFIG_KERNEL_ZSTD) := Image.zst
> > boot-image-$(CONFIG_KERNEL_UNCOMPRESSED) := Image
> > boot-image-$(CONFIG_RISCV_M_MODE) := loader.bin
> > boot-image-$(CONFIG_ARCH_CANAAN) := loader.bin
> > boot-image-$(CONFIG_EFI_ZBOOT) := vmlinuz.efi
> > boot-image-$(CONFIG_XIP_KERNEL) := xipImage
> >
> > KBUILD_IMAGE := $(boot)/$(boot-image-y)
>
> Hi Masahiro and Björn.
>
> I like this approach. But I think it doesn't quite do the same when fx.
> CONFIG_RISCV_M_MODE=n but CONFIG_ARCH_CANAAN=y which I think is a valid
> configuration for the new Kendryte K230 support. In this case boot-image-y
> would be overwritten with the loader.bin value even for S-mode kernels.
>
> To keep the previous behaviour we'd need something like
>
> boot-image-$(CONFIG_RISCV_M_MODE *and* CONFIG_ARCH_CANAAN) := loader.bin
>
> Maybe just
>
> ifeq ($(CONFIG_RISCV_M_MODE),y)
> boot-image-$(CONFIG_ARCH_CANAAN) := loader.bin
> endif
>
> Do you guys have a better solution?


Hi Emil, sorry I misunderstood AND and OR.


ifdef CONFIG_RISCV_M_MODE
boot-image-$(CONFIG_ARCH_CANAAN) := loader.bin
endif

is slightly shorter.



boot-image-$(and $(CONFIG_RISCV_M_MODE),$(CONFIG_ARCH_CANAAN)) := loader.bin

is also possible, but the line is a bit long.


Otherwise, I do not have a better idea.




I am fine with any form.
I leave it to you and Palmer.





--
Best Regards
Masahiro Yamada