From 2522590c406011cb8436d70b1da215458c6fa28f Mon Sep 17 00:00:00 2001 From: Martin Liu Date: Wed, 8 May 2024 03:46:22 +0000 Subject: [PATCH 1/3] allow powerhal to access PA_KILL knobs Bug: 322916612 Test: check avc logs Change-Id: I637c6ad454b668f807b8d0eb4f66a83ca26dfa18 Signed-off-by: Martin Liu --- performance/sepolicy/file.te | 1 + performance/sepolicy/genfs_contexts | 1 + performance/sepolicy/hal_power_default.te | 2 ++ 3 files changed, 4 insertions(+) create mode 100644 performance/sepolicy/file.te create mode 100644 performance/sepolicy/hal_power_default.te diff --git a/performance/sepolicy/file.te b/performance/sepolicy/file.te new file mode 100644 index 0000000..0357d51 --- /dev/null +++ b/performance/sepolicy/file.te @@ -0,0 +1 @@ +type sysfs_pakills, fs_type, sysfs_type; diff --git a/performance/sepolicy/genfs_contexts b/performance/sepolicy/genfs_contexts index 000c41b..07bcff9 100644 --- a/performance/sepolicy/genfs_contexts +++ b/performance/sepolicy/genfs_contexts @@ -1 +1,2 @@ genfscon proc /sys/kernel/sched_pelt_multiplier u:object_r:proc_sched:s0 +genfscon sysfs /kernel/vendor_mm/pa_kill u:object_r:sysfs_pakills:s0 diff --git a/performance/sepolicy/hal_power_default.te b/performance/sepolicy/hal_power_default.te new file mode 100644 index 0000000..763862d --- /dev/null +++ b/performance/sepolicy/hal_power_default.te @@ -0,0 +1,2 @@ +allow hal_power_default sysfs_pakills:file rw_file_perms; +allow hal_power_default sysfs_pakills:dir r_dir_perms; From 2dbfad9f6f9dd49c80068d0f58ed11d5b6c8b913 Mon Sep 17 00:00:00 2001 From: nischaljain Date: Thu, 9 May 2024 12:33:01 +0000 Subject: [PATCH 2/3] Limit maxGxpDebugDumps to 4 DSP multicore workload can run atmost on 4 cores(in case of amalthea) thus in case of crash we will need atmost 4 core dumps. Thus limiting maxGxpDebugDumps to 4 to make sure that we will be capturing all the required core dumps for the recent crash and at the same time not inflating the bugreport size. Bug: 338583087 Change-Id: I76c5b1199c0d89f2bd9a2720dc24a7c86d057b4c --- gxp/dump_gxp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gxp/dump_gxp.cpp b/gxp/dump_gxp.cpp index 518a44a..5d9f28a 100644 --- a/gxp/dump_gxp.cpp +++ b/gxp/dump_gxp.cpp @@ -17,7 +17,7 @@ #include #include -#define maxGxpDebugDumps 3 +#define maxGxpDebugDumps 4 int main() { /* TODO(b/277094681): Set default value to false around device beta milestone. */ From 99f848ed486b3698db398e63fb1613b9c17ec1b3 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Thu, 9 May 2024 16:45:02 +0000 Subject: [PATCH 3/3] Add a different implementation of insmod.sh Use soong namespace to branch a implementation of insmod.sh . The newly added implementation is only added to PRODUCT_PACKAGE for dev option enabled devices. The only change to the script is skip loading kernel modules from vendor|system_dlkm when under 16K mode. Test: Dev option works Bug: 319335586 This reverts commit 11eb02562d7e89037c67f5a22a142b110b303a30. Change-Id: I5f5d4ee79be7f872ec321e93f58f6516974d0cad --- insmod/16k/Android.bp | 14 ++++ insmod/{ => 16k}/init.module.rc | 0 insmod/16k/insmod.sh | 119 ++++++++++++++++++++++++++++++++ insmod/4k/Android.bp | 13 ++++ insmod/4k/init.module.rc | 10 +++ insmod/{ => 4k}/insmod.sh | 0 insmod/Android.bp | 7 -- insmod/insmod.mk | 6 ++ 8 files changed, 162 insertions(+), 7 deletions(-) create mode 100644 insmod/16k/Android.bp rename insmod/{ => 16k}/init.module.rc (100%) create mode 100644 insmod/16k/insmod.sh create mode 100644 insmod/4k/Android.bp create mode 100644 insmod/4k/init.module.rc rename insmod/{ => 4k}/insmod.sh (100%) diff --git a/insmod/16k/Android.bp b/insmod/16k/Android.bp new file mode 100644 index 0000000..975c5dc --- /dev/null +++ b/insmod/16k/Android.bp @@ -0,0 +1,14 @@ + +soong_namespace { +} + +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +sh_binary { + name: "insmod.sh", + src: "insmod.sh", + init_rc: ["init.module.rc"], + vendor: true, +} diff --git a/insmod/init.module.rc b/insmod/16k/init.module.rc similarity index 100% rename from insmod/init.module.rc rename to insmod/16k/init.module.rc diff --git a/insmod/16k/insmod.sh b/insmod/16k/insmod.sh new file mode 100644 index 0000000..8ec8199 --- /dev/null +++ b/insmod/16k/insmod.sh @@ -0,0 +1,119 @@ +#!/vendor/bin/sh + +############################################################# +### init.insmod.cfg format: ### +### ----------------------------------------------------- ### +### [insmod|setprop|enable/moprobe|wait] [path|prop name] ### +### ... ### +############################################################# + +modules_dir= +system_modules_dir= +vendor_modules_dir= + + +pagesize=$(getconf PAGESIZE) +# bootoption=$(getprop ro.product.build.16k_page.enabled) +# We do not need to check ro.product.build.16k_page.enabled , because this +# version of insmod.sh will only be used if PRODUCT_16K_DEVELOPER_OPTION +# is set to true + +if [ "$pagesize" != "4096" ] ; then + echo "Device has page size $pagesize , skip loading modules from vendor_dlkm/system_dlkm because all modules are stored on vendor_boot" + setprop vendor.common.modules.ready 1 + setprop vendor.device.modules.ready 1 + setprop vendor.all.modules.ready 1 + setprop vendor.all.devices.ready 1 + return 0 +fi + + +for dir in system vendor; do + for f in /${dir}/lib/modules/*/modules.dep /${dir}/lib/modules/modules.dep; do + if [[ -f "$f" ]]; then + if [[ "${dir}" == "system" ]]; then + system_modules_dir="$(dirname "$f")" + else + vendor_modules_dir="$(dirname "$f")" + modules_dir=${vendor_modules_dir} + fi + break + fi + done +done + +if [[ -z "${system_modules_dir}" ]]; then + echo "Unable to locate system kernel modules directory" 2>&1 +fi + +if [[ -z "${vendor_modules_dir}" ]]; then + echo "Unable to locate vendor kernel modules directory" 2>&1 + exit 1 +fi + +# imitates wait_for_file() in init +wait_for_file() +{ + filename="${1}" + timeout="${2:-5}" + + expiry=$(($(date "+%s")+timeout)) + while [[ ! -e "${filename}" ]] && [[ "$(date "+%s")" -le "${expiry}" ]] + do + sleep 0.01 + done +} + +if [ $# -eq 1 ]; then + cfg_file=$1 +else + # Set property even if there is no insmod config + # to unblock early-boot trigger + setprop vendor.common.modules.ready 1 + setprop vendor.device.modules.ready 1 + setprop vendor.all.modules.ready 1 + setprop vendor.all.devices.ready 1 + exit 1 +fi + +if [ -f $cfg_file ]; then + while IFS="|" read -r action arg + do + case $action in + "insmod") insmod $arg ;; + "setprop") setprop $arg 1 ;; + "enable") echo 1 > $arg ;; + "condinsmod") + prop=$(echo $arg | cut -d '|' -f 1) + module1=$(echo $arg | cut -d '|' -f 2) + module2=$(echo $arg | cut -d '|' -f 3) + value=$(getprop $prop) + if [[ ${value} == "true" ]]; then + insmod ${vendor_modules_dir}/${module1} + else + insmod ${vendor_modules_dir}/${module2} + fi + ;; + "modprobe") + case ${arg} in + "system -b *" | "system -b") + modules_dir=${system_modules_dir} + arg="-b --all=${system_modules_dir}/modules.load" ;; + "system *" | "system") + modules_dir=${system_modules_dir} + arg="--all=${system_modules_dir}/modules.load" ;; + "-b *" | "-b" | "vendor -b *" | "vendor -b") + modules_dir=${vendor_modules_dir} + arg="-b --all=${vendor_modules_dir}/modules.load" ;; + "*" | "" | "vendor *" | "vendor") + modules_dir=${vendor_modules_dir} + arg="--all=${vendor_modules_dir}/modules.load" ;; + esac + if [[ -d "${modules_dir}" ]]; then + modprobe -a -d "${modules_dir}" $arg + fi + ;; + "wait") wait_for_file $arg ;; + esac + done < $cfg_file +fi diff --git a/insmod/4k/Android.bp b/insmod/4k/Android.bp new file mode 100644 index 0000000..ddfec40 --- /dev/null +++ b/insmod/4k/Android.bp @@ -0,0 +1,13 @@ + +soong_namespace { +} +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +sh_binary { + name: "insmod.sh", + src: "insmod.sh", + init_rc: ["init.module.rc"], + vendor: true, +} diff --git a/insmod/4k/init.module.rc b/insmod/4k/init.module.rc new file mode 100644 index 0000000..de23b5b --- /dev/null +++ b/insmod/4k/init.module.rc @@ -0,0 +1,10 @@ +on init + # Loading common kernel modules in background + start insmod_sh + +service insmod_sh /vendor/bin/insmod.sh /vendor/etc/init.common.cfg + class main + user root + group root system + disabled + oneshot diff --git a/insmod/insmod.sh b/insmod/4k/insmod.sh similarity index 100% rename from insmod/insmod.sh rename to insmod/4k/insmod.sh diff --git a/insmod/Android.bp b/insmod/Android.bp index eed35ec..143e777 100644 --- a/insmod/Android.bp +++ b/insmod/Android.bp @@ -2,13 +2,6 @@ package { default_applicable_licenses: ["Android-Apache-2.0"], } -sh_binary { - name: "insmod.sh", - src: "insmod.sh", - init_rc: ["init.module.rc"], - vendor: true, -} - prebuilt_etc { name: "init.common.cfg", src: "init.common.cfg", diff --git a/insmod/insmod.mk b/insmod/insmod.mk index aa2261a..0d8da9e 100644 --- a/insmod/insmod.mk +++ b/insmod/insmod.mk @@ -1,3 +1,9 @@ +ifeq (true,$(PRODUCT_16K_DEVELOPER_OPTION)) +PRODUCT_SOONG_NAMESPACES += device/google/gs-common/insmod/16k +else +PRODUCT_SOONG_NAMESPACES += device/google/gs-common/insmod/4k +endif + BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/insmod/sepolicy PRODUCT_PACKAGES += \ insmod.sh \