Revert^2 "Boot VM without bootloader - using init ramdisk"

Remove ABL from the boot flow of VMs. Virtualization service uses
microdroid.json to construct the appropriate vm_config.

Partitions:
1. Boot related partitions (boot/init_boot/vendor_boot) are no more
   required. kernel & init ramdisk is directly passed via crosvm command
   line.
2. uboot_env is obsolete without ABL
3. bootconfig partition is no more required because we are attaching the
   bootconfigs to initrd image.

This reverts commit 0f71596bd5333f08d07ed33dbb5425390dd8aa79

Bug: 240235424
Test: atest MicrodroidTestCase
Change-Id: I1b4c3ec792db9898093c4ccd3c037657c50a934f
diff --git a/apex/Android.bp b/apex/Android.bp
index fade6c5..52f4384 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -69,6 +69,7 @@
         "microdroid.json",
         "microdroid_bootloader",
         "microdroid_bootloader.avbpubkey",
+        "microdroid_kernel",
     ],
     file_contexts: ":com.android.virt-file_contexts",
     canned_fs_config: "canned_fs_config",
diff --git a/microdroid/Android.bp b/microdroid/Android.bp
index 7b28ad2..1a9a217 100644
--- a/microdroid/Android.bp
+++ b/microdroid/Android.bp
@@ -573,3 +573,32 @@
     name: "microdroid_bootconfig_normal_src",
     srcs: ["bootconfig.normal"],
 }
+
+prebuilt_etc {
+    name: "microdroid_kernel_unsigned",
+    src: "empty_kernel",
+    filename: "microdroid_kernel_unsigned",
+    arch: {
+        arm64: {
+            src: ":microdroid_kernel_prebuilts-5.15-arm64",
+        },
+        x86_64: {
+            src: ":microdroid_kernel_prebuilts-5.15-x86_64",
+        },
+    },
+}
+
+avb_add_hash_footer {
+    name: "microdroid_kernel_signed",
+    src: ":microdroid_kernel_unsigned",
+    filename: "microdroid_kernel",
+    partition_name: "bootloader",
+    private_key: ":microdroid_sign_key",
+    salt: bootloader_salt,
+}
+
+prebuilt_etc {
+    name: "microdroid_kernel",
+    src: ":microdroid_kernel_signed",
+    relative_install_path: "fs",
+}
diff --git a/microdroid/microdroid.json b/microdroid/microdroid.json
index f02dcbf..00cedc8 100644
--- a/microdroid/microdroid.json
+++ b/microdroid/microdroid.json
@@ -1,21 +1,9 @@
 {
-  "bootloader": "/apex/com.android.virt/etc/fs/microdroid_bootloader",
+  "kernel": "/apex/com.android.virt/etc/fs/microdroid_kernel",
   "disks": [
     {
       "partitions": [
         {
-          "label": "boot_a",
-          "path": "/apex/com.android.virt/etc/fs/microdroid_boot.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.img"
-        },
-        {
           "label": "vbmeta_a",
           "path": "/apex/com.android.virt/etc/fs/microdroid_vbmeta.img"
         },
@@ -25,16 +13,6 @@
         }
       ],
       "writable": false
-    },
-    {
-      "partitions": [
-        {
-          "label": "uboot_env",
-          "path": "/apex/com.android.virt/etc/fs/uboot_env.img",
-          "writable": false
-        }
-      ],
-      "writable": true
     }
   ],
   "memory_mib": 256,
diff --git a/virtualizationservice/src/aidl.rs b/virtualizationservice/src/aidl.rs
index 3b75df9..b35f8da 100644
--- a/virtualizationservice/src/aidl.rs
+++ b/virtualizationservice/src/aidl.rs
@@ -632,7 +632,7 @@
     vm_config.numCpus = config.numCpus;
     vm_config.taskProfiles = config.taskProfiles.clone();
 
-    // Microdroid requires an additional payload disk image and the bootconfig partition.
+    // Microdroid requires an additional init ramdisk & payload disk image
     if os_name == "microdroid" {
         add_microdroid_images(
             config,
diff --git a/virtualizationservice/src/payload.rs b/virtualizationservice/src/payload.rs
index 675ca50..06b9716 100644
--- a/virtualizationservice/src/payload.rs
+++ b/virtualizationservice/src/payload.rs
@@ -360,6 +360,21 @@
     vm_payload_config: &VmPayloadConfig,
     vm_config: &mut VirtualMachineRawConfig,
 ) -> Result<()> {
+    let debug_suffix = match config.debugLevel {
+        DebugLevel::NONE => "normal",
+        DebugLevel::APP_ONLY => "app_debuggable",
+        DebugLevel::FULL => "full_debuggable",
+        _ => return Err(anyhow!("unsupported debug level: {:?}", config.debugLevel)),
+    };
+    let initrd = format!("/apex/com.android.virt/etc/microdroid_initrd_{}.img", debug_suffix);
+    vm_config.initrd = Some(open_parcel_file(Path::new(&initrd), false)?);
+
+    let instance_img = Partition {
+        label: "vm-instance".to_owned(),
+        image: Some(ParcelFileDescriptor::new(instance_file)),
+        writable: true,
+    };
+    vm_config.disks.push(DiskImage { image: None, partitions: vec![instance_img], writable: true });
     vm_config.disks.push(make_payload_disk(
         config,
         apk_file,
@@ -368,34 +383,6 @@
         temporary_directory,
     )?);
 
-    vm_config.disks[1].partitions.push(Partition {
-        label: "vbmeta".to_owned(),
-        image: Some(open_parcel_file(
-            Path::new("/apex/com.android.virt/etc/fs/microdroid_vbmeta_bootconfig.img"),
-            false,
-        )?),
-        writable: false,
-    });
-    let bootconfig_image = "/apex/com.android.virt/etc/fs/microdroid_bootconfig.".to_owned()
-        + match config.debugLevel {
-            DebugLevel::NONE => "normal",
-            DebugLevel::APP_ONLY => "app_debuggable",
-            DebugLevel::FULL => "full_debuggable",
-            _ => return Err(anyhow!("unsupported debug level: {:?}", config.debugLevel)),
-        };
-    vm_config.disks[1].partitions.push(Partition {
-        label: "bootconfig".to_owned(),
-        image: Some(open_parcel_file(Path::new(&bootconfig_image), false)?),
-        writable: false,
-    });
-
-    // instance image is at the second partition in the second disk.
-    vm_config.disks[1].partitions.push(Partition {
-        label: "vm-instance".to_owned(),
-        image: Some(ParcelFileDescriptor::new(instance_file)),
-        writable: true,
-    });
-
     Ok(())
 }