dragonboards: Enable system_dlkm partition support am: b0274055b8 am: c2014ed3b3
Original change: https://android-review.googlesource.com/c/device/linaro/dragonboard/+/2686346
Change-Id: I4d564334135c616e8616b93c9da6fdaf2e03fa6a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/db845c/BoardConfig.mk b/db845c/BoardConfig.mk
index 644f9a8..83db993 100644
--- a/db845c/BoardConfig.mk
+++ b/db845c/BoardConfig.mk
@@ -48,3 +48,6 @@
BOARD_DB_DYNAMIC_PARTITIONS_SIZE := 12433031168 # Reserve 4M for DAP metadata
BOARD_SUPER_PARTITION_METADATA_DEVICE := super
BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE := true
+# dlkm partition
+include device/linaro/dragonboard/shared/utils/dlkm_loader/BoardConfig.mk
+BOARD_SEPOLICY_DIRS += device/linaro/dragonboard/shared/utils/dlkm_loader/sepolicy/
diff --git a/db845c/device.mk b/db845c/device.mk
index 700e339..23f16a9 100644
--- a/db845c/device.mk
+++ b/db845c/device.mk
@@ -24,6 +24,11 @@
$(call inherit-product, $(SRC_TARGET_DIR)/product/virtual_ab_ota.mk)
endif
+# dlkm_loader
+include device/linaro/dragonboard/shared/utils/dlkm_loader/device.mk
+PRODUCT_COPY_FILES += \
+ device/linaro/dragonboard/shared/utils/dlkm_loader/dlkm_loader.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/dlkm_loader.rc
+
# Build generic Audio HAL
PRODUCT_PACKAGES += audio.primary.db845c
diff --git a/fstab.common b/fstab.common
index 8ad1f7b..e33062c 100644
--- a/fstab.common
+++ b/fstab.common
@@ -5,4 +5,5 @@
/devices/platform/soc@0/8804000.sdhci/mmc_host/mmc* auto auto defaults voldmanaged=sdcard1:auto
vendor /vendor erofs ro wait,logical,first_stage_mount,slotselect
system_ext /system_ext erofs ro wait,logical,first_stage_mount,slotselect
-product /product erofs ro wait,logical,first_stage_mount,slotselect
+product /product erofs ro wait,logical,first_stage_mount,slotselect
+system_dlkm /system_dlkm ext4 ro wait,logical,first_stage_mount,slotselect
diff --git a/rb5/BoardConfig.mk b/rb5/BoardConfig.mk
index 92f536b..ac26584 100644
--- a/rb5/BoardConfig.mk
+++ b/rb5/BoardConfig.mk
@@ -45,3 +45,6 @@
BOARD_DB_DYNAMIC_PARTITIONS_SIZE := 12433031168 # Reserve 4M for DAP metadata
BOARD_SUPER_PARTITION_METADATA_DEVICE := super
BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE := true
+# dlkm partition
+include device/linaro/dragonboard/shared/utils/dlkm_loader/BoardConfig.mk
+BOARD_SEPOLICY_DIRS += device/linaro/dragonboard/shared/utils/dlkm_loader/sepolicy/
diff --git a/rb5/device.mk b/rb5/device.mk
index 656b7aa..1366b4a 100644
--- a/rb5/device.mk
+++ b/rb5/device.mk
@@ -21,8 +21,12 @@
$(call inherit-product, $(SRC_TARGET_DIR)/product/virtual_ab_ota/launch_with_vendor_ramdisk.mk)
+# dlkm_loader
+include device/linaro/dragonboard/shared/utils/dlkm_loader/device.mk
+
PRODUCT_COPY_FILES := \
$(LOCAL_PATH)/mixer_paths.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths.xml \
+ device/linaro/dragonboard/shared/utils/dlkm_loader/dlkm_loader.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/dlkm_loader.rc
# Build generic Audio HAL
PRODUCT_PACKAGES += audio.primary.rb5
diff --git a/shared/utils/dlkm_loader/BoardConfig.mk b/shared/utils/dlkm_loader/BoardConfig.mk
new file mode 100644
index 0000000..9851776
--- /dev/null
+++ b/shared/utils/dlkm_loader/BoardConfig.mk
@@ -0,0 +1,5 @@
+# system_dlkm partition
+BOARD_USES_SYSTEM_DLKMIMAGE := true
+BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE := ext4 # system_dlkm.img prebuilt from ci.android.com is ext4
+TARGET_COPY_OUT_SYSTEM_DLKM := system_dlkm
+BOARD_DB_DYNAMIC_PARTITIONS_PARTITION_LIST := system vendor system_ext product system_dlkm
diff --git a/shared/utils/dlkm_loader/device.mk b/shared/utils/dlkm_loader/device.mk
new file mode 100644
index 0000000..a4db638
--- /dev/null
+++ b/shared/utils/dlkm_loader/device.mk
@@ -0,0 +1,2 @@
+AB_OTA_PARTITIONS += system_dlkm
+PRODUCT_PACKAGES += dlkm_loader
diff --git a/shared/utils/dlkm_loader/dlkm_loader.rc b/shared/utils/dlkm_loader/dlkm_loader.rc
new file mode 100644
index 0000000..7af8bac
--- /dev/null
+++ b/shared/utils/dlkm_loader/dlkm_loader.rc
@@ -0,0 +1,10 @@
+on early-init
+ # start module load in the background
+ start vendor.dlkm_loader
+
+service vendor.dlkm_loader /vendor/bin/dlkm_loader
+ class main
+ user root
+ group root system
+ disabled
+ oneshot
diff --git a/shared/utils/dlkm_loader/sepolicy/dlkm_loader.te b/shared/utils/dlkm_loader/sepolicy/dlkm_loader.te
new file mode 100644
index 0000000..be36f35
--- /dev/null
+++ b/shared/utils/dlkm_loader/sepolicy/dlkm_loader.te
@@ -0,0 +1,18 @@
+type dlkm_loader, domain;
+type dlkm_loader_exec, exec_type, vendor_file_type, file_type;
+init_daemon_domain(dlkm_loader)
+
+# Allow insmod on vendor, system and system_dlkm partitions
+allow dlkm_loader self:capability sys_module;
+allow dlkm_loader system_dlkm_file:dir r_dir_perms;
+allow dlkm_loader system_dlkm_file:file r_file_perms;
+allow dlkm_loader system_dlkm_file:system module_load;
+allow dlkm_loader system_file:system module_load;
+allow dlkm_loader vendor_file:system module_load;
+
+# needed for libmodprobe to read kernel commandline
+allow dlkm_loader proc_cmdline:file r_file_perms;
+allow dlkm_loader proc_bootconfig:file r_file_perms;
+
+# Allow writing to kernel log
+allow dlkm_loader kmsg_device:chr_file rw_file_perms;
diff --git a/shared/utils/dlkm_loader/sepolicy/file_contexts b/shared/utils/dlkm_loader/sepolicy/file_contexts
new file mode 100644
index 0000000..a345de9
--- /dev/null
+++ b/shared/utils/dlkm_loader/sepolicy/file_contexts
@@ -0,0 +1 @@
+/vendor/bin/dlkm_loader u:object_r:dlkm_loader_exec:s0