From b4987345ff1f97d529cc23b03ca73b58ff7a7e1b Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Thu, 21 Sep 2023 15:52:19 -0700 Subject: [PATCH] Only skip _16k/_64k kernel modules dirs on 4K builds The initramfs.img from kernel builds do not store kernel modules under _16k directory. Currently, init is programmed to only load kernel modules from _16k dir if running on 16K page size kernel. Relax this restriction so that booting on custom 16K kernel would work without going through platform rebuild. Test: th Bug: 293313353 Bug: 300184677 Change-Id: I9ee3c74066ad9ec5127f1e8662f7c1273445994c --- init/first_stage_init.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp index c6a287ab6..e48fa1554 100644 --- a/init/first_stage_init.cpp +++ b/init/first_stage_init.cpp @@ -239,8 +239,12 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel module_dirs.emplace_back(entry->d_name); break; } - // Ignore _16k/_64k module dirs on 4K kernels - if (GetPageSizeSuffix(entry->d_name) != page_size_suffix) { + // Is a directory does not have page size suffix, it does not mean this directory is for 4K + // kernels. Certain 16K kernel builds put all modules in /lib/modules/`uname -r` without any + // suffix. Therefore, only ignore a directory if it has _16k/_64k suffix and the suffix does + // not match system page size. + const auto dir_page_size_suffix = GetPageSizeSuffix(entry->d_name); + if (!dir_page_size_suffix.empty() && dir_page_size_suffix != page_size_suffix) { continue; } int dir_major = 0, dir_minor = 0;