The default INSTALL_MOD_DIR of using the /lib/modules/$(uname -r)/extra directory for external modules assumes distributions will have something like /etc/depmod.d/dist.conf with: search updates extra built-in However, only some Red Hat releases have and use the "extra" stuff for years now. Meanwhile, the depmod.c tool in kmod has *forever* used the "updates" directory as part of the search path by default *if* your distribution does not have any depmod.d configuration. If you compile and install an external module today, even upstream kernel mock drivers (tools/testing/cxl) the modules_install target will pick up the new drivers but will not allow override of drivers from updates to override built-in ones. Since module-init-tools was deprecated over 11 years ago and now kmod has since its inception used the "updates" directory as part of its default search path to allow overrides, and since the "extra" stuff was in practice only used by Red Hat stuff, use the more distro agnostic override path "updates" to allow external modules to also override proper production kernel modules. This would allow mocking drivers tools to not have to muck with depmod.d config files or assume that your distro will have extra on a configuration file over built-in. With today's default you end up actually *crashing* Linux when trying to load cxl_test with the default "extra" [0] directory being used. This fixes that and allows other mocking drivers to do less work. [0] https://lkml.kernel.org/r/20221209062919.1096779-1-mcgrof@kernel.org Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Acked-by: Dan Williams <dan.j.williams@intel.com> Acked-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
115 lines
2.5 KiB
Makefile
115 lines
2.5 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
# ==========================================================================
|
|
# Installing modules
|
|
# ==========================================================================
|
|
|
|
PHONY := __modinst
|
|
__modinst:
|
|
|
|
include include/config/auto.conf
|
|
include $(srctree)/scripts/Kbuild.include
|
|
|
|
modules := $(call read-file, $(MODORDER))
|
|
|
|
ifeq ($(KBUILD_EXTMOD),)
|
|
dst := $(MODLIB)/kernel
|
|
else
|
|
INSTALL_MOD_DIR ?= updates
|
|
dst := $(MODLIB)/$(INSTALL_MOD_DIR)
|
|
endif
|
|
|
|
$(foreach x, % :, $(if $(findstring $x, $(dst)), \
|
|
$(error module installation path cannot contain '$x')))
|
|
|
|
suffix-y :=
|
|
suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz
|
|
suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz
|
|
suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst
|
|
|
|
modules := $(patsubst $(extmod_prefix)%.o, $(dst)/%.ko$(suffix-y), $(modules))
|
|
|
|
__modinst: $(modules)
|
|
@:
|
|
|
|
#
|
|
# Installation
|
|
#
|
|
quiet_cmd_install = INSTALL $@
|
|
cmd_install = mkdir -p $(dir $@); cp $< $@
|
|
|
|
# Strip
|
|
#
|
|
# INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they
|
|
# are installed. If INSTALL_MOD_STRIP is '1', then the default option
|
|
# --strip-debug will be used. Otherwise, INSTALL_MOD_STRIP value will be used
|
|
# as the options to the strip command.
|
|
ifdef INSTALL_MOD_STRIP
|
|
|
|
ifeq ($(INSTALL_MOD_STRIP),1)
|
|
strip-option := --strip-debug
|
|
else
|
|
strip-option := $(INSTALL_MOD_STRIP)
|
|
endif
|
|
|
|
quiet_cmd_strip = STRIP $@
|
|
cmd_strip = $(STRIP) $(strip-option) $@
|
|
|
|
else
|
|
|
|
quiet_cmd_strip =
|
|
cmd_strip = :
|
|
|
|
endif
|
|
|
|
#
|
|
# Signing
|
|
# Don't stop modules_install even if we can't sign external modules.
|
|
#
|
|
ifeq ($(CONFIG_MODULE_SIG_ALL),y)
|
|
sig-key := $(if $(wildcard $(CONFIG_MODULE_SIG_KEY)),,$(srctree)/)$(CONFIG_MODULE_SIG_KEY)
|
|
quiet_cmd_sign = SIGN $@
|
|
cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(sig-key) certs/signing_key.x509 $@ \
|
|
$(if $(KBUILD_EXTMOD),|| true)
|
|
else
|
|
quiet_cmd_sign :=
|
|
cmd_sign := :
|
|
endif
|
|
|
|
ifeq ($(modules_sign_only),)
|
|
|
|
$(dst)/%.ko: $(extmod_prefix)%.ko FORCE
|
|
$(call cmd,install)
|
|
$(call cmd,strip)
|
|
$(call cmd,sign)
|
|
|
|
else
|
|
|
|
$(dst)/%.ko: FORCE
|
|
$(call cmd,sign)
|
|
|
|
endif
|
|
|
|
#
|
|
# Compression
|
|
#
|
|
quiet_cmd_gzip = GZIP $@
|
|
cmd_gzip = $(KGZIP) -n -f $<
|
|
quiet_cmd_xz = XZ $@
|
|
cmd_xz = $(XZ) --lzma2=dict=2MiB -f $<
|
|
quiet_cmd_zstd = ZSTD $@
|
|
cmd_zstd = $(ZSTD) -T0 --rm -f -q $<
|
|
|
|
$(dst)/%.ko.gz: $(dst)/%.ko FORCE
|
|
$(call cmd,gzip)
|
|
|
|
$(dst)/%.ko.xz: $(dst)/%.ko FORCE
|
|
$(call cmd,xz)
|
|
|
|
$(dst)/%.ko.zst: $(dst)/%.ko FORCE
|
|
$(call cmd,zstd)
|
|
|
|
PHONY += FORCE
|
|
FORCE:
|
|
|
|
.PHONY: $(PHONY)
|