From f41ee9ffe672fd3183c938bcd15f6c6911e44af4 Mon Sep 17 00:00:00 2001 From: Daniel Mentz Date: Thu, 21 Jul 2022 14:45:34 -0700 Subject: [PATCH] Import prebuilt kernel modules like fips140.ko Add support for copying prebuilt kernel modules like fips140.ko into the vendor ramdisk. These kernel modules are different in the following ways: - They do not appear in vendor_boot.modules.load provided by the kernel build system. - We want to put their names at the very beginning of the output modules.load file to ensure that they are loaded prior to all other modules. We define a new Makefile variable named BOARD_PREBUILT_VENDOR_RAMDISK_KERNEL_MODULES. For every filename on this list, we verify that the file exists in $(KERNEL_MODULE_DIR), and if it does, we include its name in the modules.load for the vendor boot ramdisk. Bug: 194712883 Change-Id: Iff8923c2492296b8eb4d24ec94bbfccc19f4e8f5 --- BoardConfig-common.mk | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/BoardConfig-common.mk b/BoardConfig-common.mk index cb8072d7..0538b86c 100644 --- a/BoardConfig-common.mk +++ b/BoardConfig-common.mk @@ -352,11 +352,20 @@ KERNEL_MODULES := $(wildcard $(KERNEL_MODULE_DIR)/*.ko) BOARD_VENDOR_KERNEL_MODULES_BLOCKLIST_FILE := $(KERNEL_MODULE_DIR)/vendor_dlkm.modules.blocklist -BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD := $(strip $(shell cat $(KERNEL_MODULE_DIR)/vendor_boot.modules.load)) -ifndef BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD +# Prebuilt kernel modules that are *not* listed in vendor_boot.modules.load +BOARD_PREBUILT_VENDOR_RAMDISK_KERNEL_MODULES = fips140/fips140.ko +BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD_EXTRA = $(foreach k,$(BOARD_PREBUILT_VENDOR_RAMDISK_KERNEL_MODULES),$(if $(wildcard $(KERNEL_MODULE_DIR)/$(k)), $(k))) +KERNEL_MODULES += $(addprefix $(KERNEL_MODULE_DIR)/, $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD_EXTRA)) + +# Kernel modules that are listed in vendor_boot.modules.load +BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD_FILE := $(strip $(shell cat $(KERNEL_MODULE_DIR)/vendor_boot.modules.load)) +ifndef BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD_FILE $(error vendor_boot.modules.load not found or empty) endif -BOARD_VENDOR_RAMDISK_KERNEL_MODULES := $(addprefix $(KERNEL_MODULE_DIR)/, $(notdir $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD))) +BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD_EXTRA) +BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD_FILE) +BOARD_VENDOR_RAMDISK_KERNEL_MODULES := $(addprefix $(KERNEL_MODULE_DIR)/, $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD_EXTRA)) +BOARD_VENDOR_RAMDISK_KERNEL_MODULES += $(addprefix $(KERNEL_MODULE_DIR)/, $(notdir $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD_FILE))) BOARD_VENDOR_KERNEL_MODULES_LOAD := $(strip $(shell cat $(KERNEL_MODULE_DIR)/vendor_dlkm.modules.load)) ifndef BOARD_VENDOR_KERNEL_MODULES_LOAD