From 0a1dd239ccc30170a071c9330040c15e694ba458 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Fri, 18 Aug 2023 11:02:19 -0700 Subject: [PATCH 1/2] Move 16K kernel modules to /lib/modules/`uname -r`_16k Store 16K kernel modules in separate directory. This allows us to store both 4k and 16k kernel modules in vendor_boot and have init load from the right path. Test: th Bug: 293313353 Change-Id: I55cd33404defc71dfbd350517d2aa51bebdb3d06 --- core/Makefile | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/core/Makefile b/core/Makefile index 07d705e8d7..af1f490a08 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1050,16 +1050,30 @@ 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) -$(BUILT_RAMDISK_16K_TARGET): $(DEPMOD) $(MKBOOTFS) -$(BUILT_RAMDISK_16K_TARGET): $(call copy-many-files,$(foreach file,$(BOARD_KERNEL_MODULES_16K),$(file):$(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/$(notdir $(file)))) +$(foreach \ + file,\ + $(BOARD_KERNEL_MODULES_16K),\ + $(eval \ + $(call copy-and-strip-kernel-module,\ + $(file),\ + $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/$(notdir $(file)) \ + ) \ + ) \ +) + +$(BUILT_RAMDISK_16K_TARGET): $(DEPMOD) $(MKBOOTFS) $(EXTRACT_KERNEL) $(COMPRESSION_COMMAND_DEPS) +$(BUILT_RAMDISK_16K_TARGET): $(foreach file,$(BOARD_KERNEL_MODULES_16K),$(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/$(notdir $(file))) $(DEPMOD) -b $(RAMDISK_16K_STAGING_DIR) 0.0 for MODULE in $(BOARD_KERNEL_MODULES_16K); do \ basename $$MODULE >> $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/modules.load ; \ done; - mkdir -p $(TARGET_OUT_RAMDISK_16K)/lib rm -rf $(TARGET_OUT_RAMDISK_16K)/lib/modules - cp -r $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0 $(TARGET_OUT_RAMDISK_16K)/lib/modules - $(MKBOOTFS) $(TARGET_OUT_RAMDISK_16K) > $@ + mkdir -p $(TARGET_OUT_RAMDISK_16K)/lib/modules + KERNEL_RELEASE=`$(EXTRACT_KERNEL) --input $(BOARD_KERNEL_PATH_16K) --output-release /dev/stdout` ;\ + IS_16K_KERNEL=`$(EXTRACT_KERNEL) --input $(BOARD_KERNEL_PATH_16K) --output-config /dev/stdout` ;\ + if [[ "$$IS_16K_KERNEL" == *"CONFIG_ARM64_16K_PAGES"* ]]; then SUFFIX=_16k; fi ;\ + cp -r $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0 $(TARGET_OUT_RAMDISK_16K)/lib/modules/$$KERNEL_RELEASE$$SUFFIX + $(MKBOOTFS) $(TARGET_OUT_RAMDISK_16K) | $(COMPRESSION_COMMAND) > $@ # Builds a ramdisk using modules defined in BOARD_KERNEL_MODULES_16K ramdisk_16k: $(BUILT_RAMDISK_16K_TARGET) From b71bc1bcde6f629331af17858907e18cc4fca07c Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Fri, 18 Aug 2023 11:09:06 -0700 Subject: [PATCH 2/2] Add 16K ramdisk to vendor_boot Store both 4K and 16K kernel modules in vendor_boot, this allows the device to switch between two kernels easily. Test: th Bug: 293313353 Change-Id: I2920d8b0fe762defe273912efa89bc1b5642fdb2 --- core/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/Makefile b/core/Makefile index af1f490a08..b616820f7d 100644 --- a/core/Makefile +++ b/core/Makefile @@ -363,6 +363,10 @@ $(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \ ) INTERNAL_VENDOR_RAMDISK_FRAGMENTS += $(BOARD_VENDOR_RAMDISK_FRAGMENTS) +ifneq ($(BOARD_KERNEL_MODULES_16K),) +INTERNAL_VENDOR_RAMDISK_FRAGMENTS += 16K +endif + # Strip the list in case of any whitespace. INTERNAL_VENDOR_RAMDISK_FRAGMENTS := \ $(strip $(INTERNAL_VENDOR_RAMDISK_FRAGMENTS)) @@ -1061,6 +1065,8 @@ $(foreach \ ) \ ) +BOARD_VENDOR_RAMDISK_FRAGMENT.16K.PREBUILT := $(BUILT_RAMDISK_16K_TARGET) + $(BUILT_RAMDISK_16K_TARGET): $(DEPMOD) $(MKBOOTFS) $(EXTRACT_KERNEL) $(COMPRESSION_COMMAND_DEPS) $(BUILT_RAMDISK_16K_TARGET): $(foreach file,$(BOARD_KERNEL_MODULES_16K),$(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/$(notdir $(file))) $(DEPMOD) -b $(RAMDISK_16K_STAGING_DIR) 0.0