Merge "Update microdroid demo instruction"
diff --git a/apex/Android.bp b/apex/Android.bp
index 25cd480..f1eeed9 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -5,7 +5,6 @@
microdroid_filesystem_images = [
"microdroid_super",
"microdroid_boot-5.10",
- "microdroid_init_boot",
"microdroid_vendor_boot-5.10",
"microdroid_vbmeta",
"microdroid_vbmeta_bootconfig",
diff --git a/apex/sign_virt_apex.py b/apex/sign_virt_apex.py
index 9a0fe1a..153b5dd 100644
--- a/apex/sign_virt_apex.py
+++ b/apex/sign_virt_apex.py
@@ -282,8 +282,6 @@
boot_img = os.path.join(input_dir, 'etc', 'fs', 'microdroid_boot-5.10.img')
vendor_boot_img = os.path.join(
input_dir, 'etc', 'fs', 'microdroid_vendor_boot-5.10.img')
- init_boot_img = os.path.join(
- input_dir, 'etc', 'fs', 'microdroid_init_boot.img')
super_img = os.path.join(input_dir, 'etc', 'fs', 'microdroid_super.img')
vbmeta_img = os.path.join(input_dir, 'etc', 'fs', 'microdroid_vbmeta.img')
vbmeta_bootconfig_img = os.path.join(
@@ -299,11 +297,10 @@
# while it's okay to use different keys for other image files.
ReplaceBootloaderPubkey(args, key, bootloader, bootloader_pubkey)
- # re-sign bootloader, boot.img, vendor_boot.img, and init_boot.img
+ # re-sign bootloader, boot.img, vendor_boot.img
AddHashFooter(args, key, bootloader)
AddHashFooter(args, key, boot_img)
AddHashFooter(args, key, vendor_boot_img)
- AddHashFooter(args, key, init_boot_img)
# re-sign super.img
with TempDirectory() as work_dir:
@@ -323,12 +320,12 @@
# re-pack super.img
MakeSuperImage(args, partitions, super_img)
- # re-generate vbmeta from re-signed {boot, vendor_boot, init_boot, system_a, vendor_a}.img
+ # re-generate vbmeta from re-signed {boot, vendor_boot, system_a, vendor_a}.img
# Ideally, making VBmeta should be done out of TempDirectory block. But doing it here
# to avoid unpacking re-signed super.img for system/vendor images which are available
# in this block.
MakeVbmetaImage(args, key, vbmeta_img, images=[
- boot_img, vendor_boot_img, init_boot_img, system_a_img, vendor_a_img])
+ boot_img, vendor_boot_img, system_a_img, vendor_a_img])
# Re-sign bootconfigs with the same key
bootconfig_sign_key = key
diff --git a/authfs/src/main.rs b/authfs/src/main.rs
index 3bd96f4..18b7b51 100644
--- a/authfs/src/main.rs
+++ b/authfs/src/main.rs
@@ -269,6 +269,7 @@
Path::new("/system/framework/framework.jar"),
Path::new("/system/framework/ims-common.jar"),
Path::new("/system/framework/services.jar"),
+ Path::new("/system/framework/services.jar.prof"),
Path::new("/system/framework/telephony-common.jar"),
Path::new("/system/framework/voip-common.jar"),
Path::new("/system/etc/boot-image.prof"),
diff --git a/compos/aidl/com/android/compos/ICompOsService.aidl b/compos/aidl/com/android/compos/ICompOsService.aidl
index 1a28a18..e3e0317 100644
--- a/compos/aidl/com/android/compos/ICompOsService.aidl
+++ b/compos/aidl/com/android/compos/ICompOsService.aidl
@@ -45,10 +45,11 @@
* @param targetDirName The sub-directory of the output directory to which artifacts are to be
* written (e.g. dalvik-cache)
* @param zygoteArch The zygote architecture (ro.zygote)
+ * @param systemServerCompilerFilter The compiler filter used to compile system server
* @return odrefresh exit code
*/
byte odrefresh(int systemDirFd, int outputDirFd, int stagingDirFd, String targetDirName,
- String zygoteArch);
+ String zygoteArch, String systemServerCompilerFilter);
/**
* Run dex2oat command with provided args, in a context that may be specified in FdAnnotation,
diff --git a/compos/composd/src/odrefresh_task.rs b/compos/composd/src/odrefresh_task.rs
index 56b697e..330f0ab 100644
--- a/compos/composd/src/odrefresh_task.rs
+++ b/compos/composd/src/odrefresh_task.rs
@@ -131,12 +131,15 @@
let fd_server_raii = fd_server_config.into_fd_server()?;
let zygote_arch = system_properties::read("ro.zygote")?;
+ let system_server_compiler_filter =
+ system_properties::read("dalvik.vm.systemservercompilerfilter").unwrap_or_default();
let exit_code = service.odrefresh(
system_dir.as_raw_fd(),
output_dir.as_raw_fd(),
staging_dir.as_raw_fd(),
target_dir_name,
&zygote_arch,
+ &system_server_compiler_filter,
)?;
drop(fd_server_raii);
diff --git a/compos/src/compilation.rs b/compos/src/compilation.rs
index af7a9b4..50d79c1 100644
--- a/compos/src/compilation.rs
+++ b/compos/src/compilation.rs
@@ -70,6 +70,7 @@
staging_dir_fd: i32,
target_dir_name: &'a str,
zygote_arch: &'a str,
+ system_server_compiler_filter: &'a str,
}
impl<'a> OdrefreshContext<'a> {
@@ -79,11 +80,12 @@
staging_dir_fd: i32,
target_dir_name: &'a str,
zygote_arch: &'a str,
+ system_server_compiler_filter: &'a str,
) -> Result<Self> {
if system_dir_fd < 0 || output_dir_fd < 0 || staging_dir_fd < 0 {
bail!("The remote FDs are expected to be non-negative");
}
- if zygote_arch != "zygote64" && zygote_arch != "zygote64_32" {
+ if !matches!(zygote_arch, "zygote64" | "zygote64_32") {
bail!("Invalid zygote arch");
}
// Disallow any sort of path traversal
@@ -91,7 +93,20 @@
bail!("Invalid target directory {}", target_dir_name);
}
- Ok(Self { system_dir_fd, output_dir_fd, staging_dir_fd, target_dir_name, zygote_arch })
+ // We're not validating/allowlisting the compiler filter, and just assume the compiler will
+ // reject an invalid string. We need to accept "verify" filter anyway, and potential
+ // performance degration by the attacker is not currently in scope. This also allows ART to
+ // specify new compiler filter and configure through system property without change to
+ // CompOS.
+
+ Ok(Self {
+ system_dir_fd,
+ output_dir_fd,
+ staging_dir_fd,
+ target_dir_name,
+ zygote_arch,
+ system_server_compiler_filter,
+ })
}
}
@@ -134,14 +149,22 @@
set_classpaths(&android_root)?;
- let args = vec![
+ let mut args = vec![
"odrefresh".to_string(),
format!("--zygote-arch={}", context.zygote_arch),
format!("--dalvik-cache={}", context.target_dir_name),
- "--no-refresh".to_string(),
format!("--staging-dir={}", staging_dir.display()),
- "--force-compile".to_string(),
+ "--no-refresh".to_string(),
];
+
+ if !context.system_server_compiler_filter.is_empty() {
+ args.push(format!(
+ "--system-server-compiler-filter={}",
+ context.system_server_compiler_filter
+ ));
+ }
+ args.push("--force-compile".to_string());
+
debug!("Running odrefresh with args: {:?}", &args);
let jail = spawn_jailed_task(odrefresh_path, &args, Vec::new() /* fd_mapping */)
.context("Spawn odrefresh")?;
diff --git a/compos/src/compsvc.rs b/compos/src/compsvc.rs
index ef3ae2a..5a2c3ca 100644
--- a/compos/src/compsvc.rs
+++ b/compos/src/compsvc.rs
@@ -101,6 +101,7 @@
staging_dir_fd: i32,
target_dir_name: &str,
zygote_arch: &str,
+ system_server_compiler_filter: &str,
) -> BinderResult<i8> {
let context = to_binder_result(OdrefreshContext::new(
system_dir_fd,
@@ -108,6 +109,7 @@
staging_dir_fd,
target_dir_name,
zygote_arch,
+ system_server_compiler_filter,
))?;
let authfs_service = get_authfs_service()?;
diff --git a/compos/tests/java/android/compos/test/ComposTestCase.java b/compos/tests/java/android/compos/test/ComposTestCase.java
index 7b027de..1e439af 100644
--- a/compos/tests/java/android/compos/test/ComposTestCase.java
+++ b/compos/tests/java/android/compos/test/ComposTestCase.java
@@ -55,9 +55,20 @@
// Files that define the "test" instance of CompOS
private static final String COMPOS_TEST_ROOT = "/data/misc/apexdata/com.android.compos/test/";
+ private static final String SYSTEM_SERVER_COMPILER_FILTER_PROP_NAME =
+ "dalvik.vm.systemservercompilerfilter";
+ private String mBackupSystemServerCompilerFilter;
+
@Before
public void setUp() throws Exception {
testIfDeviceIsCapable(getDevice());
+
+ String value = getDevice().getProperty(SYSTEM_SERVER_COMPILER_FILTER_PROP_NAME);
+ if (value == null) {
+ mBackupSystemServerCompilerFilter = "";
+ } else {
+ mBackupSystemServerCompilerFilter = value;
+ }
}
@After
@@ -71,10 +82,28 @@
// And any artifacts generated by odrefresh
android.tryRun("rm", "-rf", ODREFRESH_OUTPUT_DIR);
+
+ if (mBackupSystemServerCompilerFilter != null) {
+ CLog.d("Restore dalvik.vm.systemservercompilerfilter to "
+ + mBackupSystemServerCompilerFilter);
+ getDevice().setProperty(SYSTEM_SERVER_COMPILER_FILTER_PROP_NAME,
+ mBackupSystemServerCompilerFilter);
+ }
}
@Test
- public void testOdrefresh() throws Exception {
+ public void testOdrefreshSpeed() throws Exception {
+ getDevice().setProperty(SYSTEM_SERVER_COMPILER_FILTER_PROP_NAME, "speed");
+ testOdrefresh();
+ }
+
+ @Test
+ public void testOdrefreshSpeedProfile() throws Exception {
+ getDevice().setProperty(SYSTEM_SERVER_COMPILER_FILTER_PROP_NAME, "speed-profile");
+ testOdrefresh();
+ }
+
+ private void testOdrefresh() throws Exception {
CommandRunner android = new CommandRunner(getDevice());
// Prepare the groundtruth. The compilation on Android should finish successfully.
diff --git a/microdroid/Android.bp b/microdroid/Android.bp
index 6c96cbf..3eaf124 100644
--- a/microdroid/Android.bp
+++ b/microdroid/Android.bp
@@ -221,6 +221,7 @@
bootimg {
name: "microdroid_boot-5.10",
+ ramdisk_module: "microdroid_ramdisk-5.10",
// We don't have kernel for arm and x86. But Soong demands one when it builds for
// arm or x86 target. Satisfy that by providing an empty file as the kernel.
kernel_prebuilt: "empty_kernel",
@@ -250,16 +251,6 @@
avb_private_key: ":microdroid_sign_key",
}
-bootimg {
- name: "microdroid_init_boot",
- ramdisk_module: "microdroid_ramdisk-5.10",
- kernel_prebuilt: "empty_kernel",
- header_version: "4",
- partition_name: "init_boot",
- use_avb: true,
- avb_private_key: ":microdroid_sign_key",
-}
-
android_filesystem {
name: "microdroid_ramdisk-5.10",
deps: [
@@ -560,7 +551,6 @@
"microdroid_vendor_boot-5.10",
"microdroid",
"microdroid_boot-5.10",
- "microdroid_init_boot",
],
}
diff --git a/microdroid/microdroid.json b/microdroid/microdroid.json
index 9e630f8..8496052 100644
--- a/microdroid/microdroid.json
+++ b/microdroid/microdroid.json
@@ -8,10 +8,6 @@
"path": "/apex/com.android.virt/etc/fs/microdroid_boot-5.10.img"
},
{
- "label": "init_boot_a",
- "path": "/apex/com.android.virt/etc/fs/microdroid_init_boot.img"
- },
- {
"label": "vendor_boot_a",
"path": "/apex/com.android.virt/etc/fs/microdroid_vendor_boot-5.10.img"
},