From 64776335c06af73b03c750c11fb486e182f45ef6 Mon Sep 17 00:00:00 2001 From: Juan Yescas Date: Mon, 10 Jun 2024 20:50:31 -0700 Subject: [PATCH] toolbox/modprobe: Load modules from /lib/modules based on page size Load modules from /lib/modules for 4kb page size kernels when the -d option is not present. Do not do this for 16kb page size kernels due it will load the 4kb modules when PRODUCT_16K_DEVELOPER_OPTION is true. Depending on the value of PRODUCT_16K_DEVELOPER_OPTION, the kernel modules can be located in several directories: - true: There are 2 directories that contain the 4kb and 16kb modules. - 4kb modules are in /lib/modules - 16kb modules are in /lib/modules/_16k - false: There is only one directory that contains only one type of the kernel modules, either 4kb or 16kb. - /lib/modules This is a temporary fix for the 16kb developer option. This b/346659501 will track the proper fix. Test: Boot target husky-trunk_staging-userdebug with developer option. Test: Boot target husky_pgagnostic-next-userdebug without developer option. Bug: 345609905 Bug: 343971855 Change-Id: I9bab33d9f06743bd10ee804b20db8f39467fcc52 --- toolbox/modprobe.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/toolbox/modprobe.cpp b/toolbox/modprobe.cpp index 7fde4915e..13026ac30 100644 --- a/toolbox/modprobe.cpp +++ b/toolbox/modprobe.cpp @@ -245,8 +245,10 @@ extern "C" int modprobe_main(int argc, char** argv) { } free(kernel_dirs); - // Allow modules to be directly inside /lib/modules - mod_dirs.emplace_back(LIB_MODULES_PREFIX); + if (mod_dirs.empty() || getpagesize() == 4096) { + // Allow modules to be directly inside /lib/modules + mod_dirs.emplace_back(LIB_MODULES_PREFIX); + } } LOG(DEBUG) << "mode is " << mode;