kernel: Handle GKI modules
All devices lauching with Android 13 (and above) must include a system_dlkm partition, where GKI modules should reside. Android 13 build system only supports providing prebuilt modules, by pointing BOARD_SYSTEM_DLKM_SRC to the modules source folder. Google will introduce BOARD_SYSTEM_KERNEL_MODULES for Android 14, so take a step forward and use that macro to exclude the listed modules from the usual vendor DLKM partition and place them into the GKI module partition. Note that the GKI modules are placed into lib/modules/androidX-Y.Z, as defined by Google and observed in system_dlkm_modprobe script. Change-Id: I2b1644479788cb5c9568cac738202b1d55fc28d7
This commit is contained in:
parent
53760b516c
commit
47931c121e
1 changed files with 36 additions and 13 deletions
|
@ -94,6 +94,7 @@ KERNEL_CONFIG := $(KERNEL_OUT)/.config
|
||||||
KERNEL_RELEASE := $(KERNEL_OUT)/include/config/kernel.release
|
KERNEL_RELEASE := $(KERNEL_OUT)/include/config/kernel.release
|
||||||
RECOVERY_KERNEL_CONFIG := $(RECOVERY_KERNEL_OUT)/.config
|
RECOVERY_KERNEL_CONFIG := $(RECOVERY_KERNEL_OUT)/.config
|
||||||
RECOVERY_KERNEL_RELEASE := $(RECOVERY_KERNEL_OUT)/include/config/kernel.release
|
RECOVERY_KERNEL_RELEASE := $(RECOVERY_KERNEL_OUT)/include/config/kernel.release
|
||||||
|
GKI_SUFFIX := $(shell echo android$(PLATFORM_VERSION)-$(TARGET_KERNEL_VERSION))
|
||||||
|
|
||||||
ifeq ($(KERNEL_ARCH),x86_64)
|
ifeq ($(KERNEL_ARCH),x86_64)
|
||||||
KERNEL_DEFCONFIG_ARCH := x86
|
KERNEL_DEFCONFIG_ARCH := x86
|
||||||
|
@ -347,20 +348,21 @@ endef
|
||||||
# $(3): mount point
|
# $(3): mount point
|
||||||
# $(4): staging dir
|
# $(4): staging dir
|
||||||
# $(5): module load list
|
# $(5): module load list
|
||||||
|
# $(6): suffix for output dir, needed for GKI modules usecase, empty otherwise
|
||||||
# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
|
# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
|
||||||
define build-image-kernel-modules-lineage
|
define build-image-kernel-modules-lineage
|
||||||
mkdir -p $(2)/lib/modules
|
mkdir -p $(2)/lib/modules$(6)
|
||||||
cp $(1) $(2)/lib/modules/
|
cp $(1) $(2)/lib/modules$(6)
|
||||||
rm -rf $(4)
|
rm -rf $(4)
|
||||||
mkdir -p $(4)/lib/modules/0.0/$(3)lib/modules
|
mkdir -p $(4)/lib/modules/0.0/$(3)lib/modules$(6)
|
||||||
cp $(1) $(4)/lib/modules/0.0/$(3)lib/modules
|
cp $(1) $(4)/lib/modules/0.0/$(3)lib/modules$(6)
|
||||||
$(DEPMOD) -b $(4) 0.0
|
$(DEPMOD) -b $(4) 0.0
|
||||||
sed -e 's/\(.*modules.*\):/\/\1:/g' -e 's/ \([^ ]*modules[^ ]*\)/ \/\1/g' $(4)/lib/modules/0.0/modules.dep > $(2)/lib/modules/modules.dep
|
sed -e 's/\(.*modules.*\):/\/\1:/g' -e 's/ \([^ ]*modules[^ ]*\)/ \/\1/g' $(4)/lib/modules/0.0/modules.dep > $(2)/lib/modules$(6)/modules.dep
|
||||||
cp $(4)/lib/modules/0.0/modules.softdep $(2)/lib/modules
|
cp $(4)/lib/modules/0.0/modules.softdep $(2)/lib/modules$(6)
|
||||||
cp $(4)/lib/modules/0.0/modules.alias $(2)/lib/modules
|
cp $(4)/lib/modules/0.0/modules.alias $(2)/lib/modules$(6)
|
||||||
rm -f $(2)/lib/modules/modules.load
|
rm -f $(2)/lib/modules$(6)/modules.load
|
||||||
for MODULE in $(5); do \
|
for MODULE in $(5); do \
|
||||||
basename $$MODULE >> $(2)/lib/modules/modules.load; \
|
basename $$MODULE >> $(2)/lib/modules$(6)/modules.load; \
|
||||||
done
|
done
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -393,6 +395,12 @@ KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-
|
||||||
KERNEL_MODULE_MOUNTPOINT := vendor
|
KERNEL_MODULE_MOUNTPOINT := vendor
|
||||||
$(INSTALLED_VENDORIMAGE_TARGET): $(TARGET_PREBUILT_INT_KERNEL)
|
$(INSTALLED_VENDORIMAGE_TARGET): $(TARGET_PREBUILT_INT_KERNEL)
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(BOARD_USES_SYSTEM_DLKMIMAGE),true)
|
||||||
|
SYSTEM_KERNEL_MODULES_OUT := $(TARGET_OUT_SYSTEM_DLKM)
|
||||||
|
SYSTEM_KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_system_dlkm)
|
||||||
|
SYSTEM_KERNEL_MODULE_MOUNTPOINT := system_dlkm
|
||||||
|
$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET): $(TARGET_PREBUILT_INT_KERNEL)
|
||||||
|
endif
|
||||||
MODULES_INTERMEDIATES := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,kernel_modules)
|
MODULES_INTERMEDIATES := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,kernel_modules)
|
||||||
|
|
||||||
ifneq (,$(filter dlkm,$(BOARD_VENDOR_RAMDISK_FRAGMENTS)))
|
ifneq (,$(filter dlkm,$(BOARD_VENDOR_RAMDISK_FRAGMENTS)))
|
||||||
|
@ -447,15 +455,30 @@ $(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_CONFIG) $(DEPMOD) $(DTC) $(PAHOLE)
|
||||||
$(foreach s, $(TARGET_MODULE_ALIASES),\
|
$(foreach s, $(TARGET_MODULE_ALIASES),\
|
||||||
$(eval p := $(subst :,$(space),$(s))) \
|
$(eval p := $(subst :,$(space),$(s))) \
|
||||||
; mv $$(find $$kernel_modules_dir -name $(word 1,$(p))) $$kernel_modules_dir/$(word 2,$(p))); \
|
; mv $$(find $$kernel_modules_dir -name $(word 1,$(p))) $$kernel_modules_dir/$(word 2,$(p))); \
|
||||||
modules=$$(find $$kernel_modules_dir -type f -name '*.ko'); \
|
all_modules=$$(find $$kernel_modules_dir -type f -name '*.ko'); \
|
||||||
($(call build-image-kernel-modules-lineage,$$modules,$(KERNEL_MODULES_OUT),$(KERNEL_MODULE_MOUNTPOINT)/,$(KERNEL_DEPMOD_STAGING_DIR),$(BOARD_VENDOR_KERNEL_MODULES_LOAD))); \
|
filtered_modules=""; \
|
||||||
|
$(if $(BOARD_SYSTEM_KERNEL_MODULES),\
|
||||||
|
gki_modules=$$(for m in $(BOARD_SYSTEM_KERNEL_MODULES); do \
|
||||||
|
p=$$(find $$kernel_modules_dir -type f -name $$m); \
|
||||||
|
if [ -n "$$p" ]; then echo $$p; else echo "ERROR: $$m from BOARD_SYSTEM_KERNEL_MODULES was not found" 1>&2 && exit 1; fi; \
|
||||||
|
done); \
|
||||||
|
[ $$? -ne 0 ] && exit 1; \
|
||||||
|
($(call build-image-kernel-modules-lineage,$$gki_modules,$(SYSTEM_KERNEL_MODULES_OUT),$(SYSTEM_KERNEL_MODULE_MOUNTPOINT)/,$(SYSTEM_KERNEL_DEPMOD_STAGING_DIR),$(BOARD_SYSTEM_KERNEL_MODULES_LOAD),/$(GKI_SUFFIX))); \
|
||||||
|
filtered_modules=$$(for n in $$all_modules; do \
|
||||||
|
module_name=$$(basename $$n); \
|
||||||
|
if [[ ! "$(BOARD_SYSTEM_KERNEL_MODULES)" =~ "$$module_name" ]]; then echo $$n; fi; \
|
||||||
|
done); \
|
||||||
|
($(call build-image-kernel-modules-lineage,$$filtered_modules,$(KERNEL_MODULES_OUT),$(KERNEL_MODULE_MOUNTPOINT)/,$(KERNEL_DEPMOD_STAGING_DIR),$(BOARD_VENDOR_KERNEL_MODULES_LOAD),/)); \
|
||||||
|
,\
|
||||||
|
($(call build-image-kernel-modules-lineage,$$all_modules,$(KERNEL_MODULES_OUT),$(KERNEL_MODULE_MOUNTPOINT)/,$(KERNEL_DEPMOD_STAGING_DIR),$(BOARD_VENDOR_KERNEL_MODULES_LOAD),/)); \
|
||||||
|
) \
|
||||||
$(if $(BOOT_KERNEL_MODULES),\
|
$(if $(BOOT_KERNEL_MODULES),\
|
||||||
vendor_boot_modules=$$(for m in $(BOOT_KERNEL_MODULES); do \
|
vendor_boot_modules=$$(for m in $(BOOT_KERNEL_MODULES); do \
|
||||||
p=$$(find $$kernel_modules_dir -type f -name $$m); \
|
p=$$(find $$kernel_modules_dir -type f -name $$m); \
|
||||||
if [ -n "$$p" ]; then echo $$p; else echo "ERROR: $$m from BOOT_KERNEL_MODULES was not found" 1>&2 && exit 1; fi; \
|
if [ -n "$$p" ]; then echo $$p; else echo "ERROR: $$m from BOOT_KERNEL_MODULES was not found" 1>&2 && exit 1; fi; \
|
||||||
done); \
|
done); \
|
||||||
[ $$? -ne 0 ] && exit 1; \
|
[ $$? -ne 0 ] && exit 1; \
|
||||||
($(call build-image-kernel-modules-lineage,$$vendor_boot_modules,$(KERNEL_VENDOR_RAMDISK_MODULES_OUT),/,$(KERNEL_VENDOR_RAMDISK_DEPMOD_STAGING_DIR),$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD))); \
|
($(call build-image-kernel-modules-lineage,$$vendor_boot_modules,$(KERNEL_VENDOR_RAMDISK_MODULES_OUT),/,$(KERNEL_VENDOR_RAMDISK_DEPMOD_STAGING_DIR),$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD),/)); \
|
||||||
) \
|
) \
|
||||||
$(if $(RECOVERY_KERNEL_MODULES),\
|
$(if $(RECOVERY_KERNEL_MODULES),\
|
||||||
recovery_modules=$$(for m in $(RECOVERY_KERNEL_MODULES); do \
|
recovery_modules=$$(for m in $(RECOVERY_KERNEL_MODULES); do \
|
||||||
|
@ -463,7 +486,7 @@ $(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_CONFIG) $(DEPMOD) $(DTC) $(PAHOLE)
|
||||||
if [ -n "$$p" ]; then echo $$p; else echo "ERROR: $$m from RECOVERY_KERNEL_MODULES was not found" 1>&2 && exit 1; fi; \
|
if [ -n "$$p" ]; then echo $$p; else echo "ERROR: $$m from RECOVERY_KERNEL_MODULES was not found" 1>&2 && exit 1; fi; \
|
||||||
done); \
|
done); \
|
||||||
[ $$? -ne 0 ] && exit 1; \
|
[ $$? -ne 0 ] && exit 1; \
|
||||||
($(call build-image-kernel-modules-lineage,$$recovery_modules,$(KERNEL_RECOVERY_MODULES_OUT),/,$(KERNEL_RECOVERY_DEPMOD_STAGING_DIR),$(BOARD_RECOVERY_RAMDISK_KERNEL_MODULES_LOAD))); \
|
($(call build-image-kernel-modules-lineage,$$recovery_modules,$(KERNEL_RECOVERY_MODULES_OUT),/,$(KERNEL_RECOVERY_DEPMOD_STAGING_DIR),$(BOARD_RECOVERY_RAMDISK_KERNEL_MODULES_LOAD),/)); \
|
||||||
) \
|
) \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue