use dalvik.vm.boot-dex2oat-threads inside microdroid
Previously, all dalvik.vm.* properties were not used / ignored in
Microdroid. However this change makes use of
dalvik.vm.boot-dex2oat-threads which controls the concurrency level of
dex2oat.
Specifically, on the host-side, the number of vCPUs in the compos VM is
configured from the system property having the same name. Then inside
the compos VM, compsvc which runs in the compos domain, sets the system
property to be the number of vCPUs in the VM. In other words, the system
properties get the same value both in the host and the guest VMs. Then
finally, the dex2oat process running inside the VM reads the system
property and configures its concurrency level accordingly.
Bug: 197358423
Test: run compos
Change-Id: I8d2394a7192a7b55a910f317e12e2b1f60b89636
diff --git a/microdroid/system/private/compos.te b/microdroid/system/private/compos.te
index 174eda3..4159abb 100644
--- a/microdroid/system/private/compos.te
+++ b/microdroid/system/private/compos.te
@@ -38,3 +38,6 @@
# TODO(b/209008712): Remove dex2oat once the migration is done.
domain_auto_trans(compos, odrefresh_exec, odrefresh)
domain_auto_trans(compos, dex2oat_exec, dex2oat)
+
+# Allow compos to set dalvik.vm.boot-dex2oat-threads
+set_prop(compos, dalvik_config_prop)
diff --git a/microdroid/system/private/dex2oat.te b/microdroid/system/private/dex2oat.te
index c7c53c2..d4d369a 100644
--- a/microdroid/system/private/dex2oat.te
+++ b/microdroid/system/private/dex2oat.te
@@ -28,7 +28,10 @@
# Allow dex2oat to read /apex/apex-info-list.xml
allow dex2oat apex_info_file:file r_file_perms;
+# dex2oat gets the concurrency level via this property which is set by compos
+get_prop(dex2oat, dalvik_config_prop)
+
# Don't audit because we don't configure the compiler through system properties
-# in the VM.
-dontaudit dex2oat dalvik_config_prop:file { open read getattr map };
+# in the VM except for dalvik.vm.boot-dex2oat-threads
+dontaudit dex2oat dalvik_config_ignored_prop:file { open read getattr map };
dontaudit dex2oat device_config_runtime_native_prop:file { open read getattr map };
diff --git a/microdroid/system/private/property.te b/microdroid/system/private/property.te
index 7911753..4bf99c9 100644
--- a/microdroid/system/private/property.te
+++ b/microdroid/system/private/property.te
@@ -1,4 +1,5 @@
# Declare ART properties for CompOS
+system_public_prop(dalvik_config_ignored_prop)
system_public_prop(dalvik_config_prop)
system_restricted_prop(device_config_runtime_native_prop)
diff --git a/microdroid/system/private/property_contexts b/microdroid/system/private/property_contexts
index 7b63cae..eb2b9e8 100644
--- a/microdroid/system/private/property_contexts
+++ b/microdroid/system/private/property_contexts
@@ -163,7 +163,8 @@
heapprofd.enable u:object_r:heapprofd_prop:s0 exact bool
# ART properties for CompOS
-dalvik.vm. u:object_r:dalvik_config_prop:s0 prefix
+dalvik.vm. u:object_r:dalvik_config_ignored_prop:s0 prefix
persist.device_config.runtime_native. u:object_r:device_config_runtime_native_prop:s0 prefix
+dalvik.vm.boot-dex2oat-threads u:object_r:dalvik_config_prop:s0 exact int
apexd.payload_metadata.path u:object_r:apexd_payload_metadata_prop:s0 exact string