From ad3c30528d190d713360a35b48c6a03f221e0a5c Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Mon, 9 Oct 2023 12:57:53 -0700 Subject: [PATCH] Skip stripping 16K GKI kernel modules GKI kernel modules are required to be signed, but curretnly we strip all 16K kernel modules. Use SYSTEM_DLKM_MODULE_PATTERNS to determine which modules are GKI, and skip stripping for these kernel modules. Test: boot using 16K boot image Bug: 303725887 Change-Id: I4cd71b39ceb75650d03744220ec4ddf4aeeda871 --- core/Makefile | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/core/Makefile b/core/Makefile index 03fc4cf762..ef4429b8f5 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1060,9 +1060,16 @@ TARGET_OUT_RAMDISK_16K := $(PRODUCT_OUT)/ramdisk_16k BUILT_RAMDISK_16K_TARGET := $(PRODUCT_OUT)/ramdisk_16k.img RAMDISK_16K_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_ramdisk_16k) +ifneq ($(BOARD_SYSTEM_KERNEL_MODULES),) +SYSTEM_DLKM_MODULE_PATTERNS := $(foreach path,$(BOARD_SYSTEM_KERNEL_MODULES),%/$(notdir $(path))) + +endif + +# For non-GKI modules, strip them before install. As debug symbols take up +# significant space. $(foreach \ file,\ - $(BOARD_KERNEL_MODULES_16K),\ + $(filter-out $(SYSTEM_DLKM_MODULE_PATTERNS),$(BOARD_KERNEL_MODULES_16K)),\ $(eval \ $(call copy-and-strip-kernel-module,\ $(file),\ @@ -1071,6 +1078,20 @@ $(foreach \ ) \ ) +# For GKI modules, copy as-is without stripping, because stripping would +# remove the signature of kernel modules, and GKI modules must be signed +# for kernel to load them. +$(foreach \ + file,\ + $(filter $(SYSTEM_DLKM_MODULE_PATTERNS),$(BOARD_KERNEL_MODULES_16K)),\ + $(eval \ + $(call copy-one-file,\ + $(file),\ + $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/$(notdir $(file)) \ + ) \ + ) \ +) + BOARD_VENDOR_RAMDISK_FRAGMENT.16K.PREBUILT := $(BUILT_RAMDISK_16K_TARGET) $(BUILT_RAMDISK_16K_TARGET): $(DEPMOD) $(MKBOOTFS) $(EXTRACT_KERNEL) $(COMPRESSION_COMMAND_DEPS)