Re: [RFC PATCH 2/3] kbuild: Make sure to generate config file

From: Tiezhu Yang

Date: Wed Jan 21 2026 - 20:16:44 EST


On 2026/1/22 上午7:47, Nathan Chancellor wrote:
Hi Tiezhu,

On Tue, Jan 20, 2026 at 08:37:29PM +0800, Tiezhu Yang wrote:
After commit 75cffd392bfa ("LoongArch: Using generic scripts/install.sh
in `make install`"), arch/loongarch/boot/install.sh is usually not used,
either /root/bin/installkernel or /sbin/installkernel is used if found.

Then it can not generate the config file in most cases, just copy it to
the installation path. Otherwise there may be an error when testing bpf,
for example.

$ ./test_verifier
gzopen /boot/config-6.19.0-rc6: No such file or directorg

This could also be resolved by enabling CONFIG_IKCONFIG_PROC.

Currently, CONFIG_IKCONFIG_PROC is set by default on LoongArch,
the above error still exists, it checks /boot/config-* first,
here is the related code:

tools/testing/selftests/bpf/unpriv_helpers.c:
static gzFile open_config(void)
{
struct utsname uts;
char buf[PATH_MAX];
gzFile config;

if (uname(&uts)) {
perror("uname");
goto config_gz;
}

snprintf(buf, sizeof(buf), "/boot/config-%s", uts.release);
config = gzopen(buf, "rb");
if (config)
return config;
fprintf(stderr, "gzopen %s: %s\n", buf, strerror(errno));

config_gz:
config = gzopen("/proc/config.gz", "rb");
if (!config)
perror("gzopen /proc/config.gz");
return config;
}

Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
scripts/install.sh | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/scripts/install.sh b/scripts/install.sh
index 05d62ac513ee..ecf354d8f4f1 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -34,6 +34,12 @@ do
continue
fi
+ # Install kernel config file
+ if [ -f ${INSTALL_PATH}/config-${KERNELRELEASE} ]; then
+ mv ${INSTALL_PATH}/config-${KERNELRELEASE} ${INSTALL_PATH}/config-${KERNELRELEASE}.old
+ fi
+ cp .config ${INSTALL_PATH}/config-${KERNELRELEASE}
+

I am a little hesistant to change the generic install logic to handle
these files, especially since the map file should be handled by
installkernel like you mention in patch 3 (but I am open to other
opinions/arguments) and the configuration can be made available via
CONFIG_IKCONFIG_PROC as I mention above.

If LoongArch wants this behavior as part of its install process, why not
just bring back the lines of 75cffd392bfa after $(cmd,install)

install:
$(call cmd,install)
$(Q)install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE)
$(Q)install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE)

# installkernel(8) says the parameters are like follows:
#
# installkernel version zImage System.map [directory]

Yes, this works well for LoongArch. If there is no need to do this for
all archs, I will only touch arch/loongarch files.

By the way, I do not know why it can not generate System.map by the
installkernel in practice, could you please check it?

Thanks,
Tiezhu