Add prebuilt kernel that supports loading modules

So far this kernel is based on GKI with some configs tweaked. Since it
will be only used for development, a locally built kernel image is
checked in.

The PRODUCT_AVF_KERNEL_MODULES_ENABLED build flag controls whether the
com.android.virt APEX should also include kernel that supports loading
modules.

Bug: 283822676
Bug: 278008256
Test: adb shell /apex/com.android.virt/bin/vm run-microdroid \
  --protected \
  --kernel=/apex/com.android.virt/etc/fs/microdroid_kernel_with_modules
Change-Id: I366fb54a3ffbb2f4a5025fa1f9d02d405a497e20
diff --git a/apex/Android.bp b/apex/Android.bp
index 1c4d357..2dc90d6 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -11,8 +11,14 @@
     name: "virt_apex",
     module_type: "apex",
     config_namespace: "ANDROID",
-    bool_variables: ["avf_enabled"],
-    properties: ["defaults"],
+    bool_variables: [
+        "avf_enabled",
+        "avf_kernel_modules_enabled",
+    ],
+    properties: [
+        "defaults",
+        "prebuilts",
+    ],
 }
 
 virt_apex {
@@ -24,6 +30,9 @@
                 defaults: ["com.android.virt_avf_disabled"],
             },
         },
+        avf_kernel_modules_enabled: {
+            prebuilts: ["microdroid_kernel_with_modules"],
+        },
     },
 }
 
diff --git a/microdroid/Android.bp b/microdroid/Android.bp
index 1092476..f3045b7 100644
--- a/microdroid/Android.bp
+++ b/microdroid/Android.bp
@@ -461,3 +461,34 @@
         },
     },
 }
+
+avb_add_hash_footer {
+    name: "microdroid_kernel_with_modules_signed",
+    src: ":empty_file",
+    filename: "microdroid_kernel_with_modules",
+    partition_name: "boot",
+    private_key: ":microdroid_sign_key",
+    salt: bootloader_salt,
+    enabled: false,
+    arch: {
+        arm64: {
+            src: ":microdroid_kernel_with_modules_prebuilts-6.1-arm64",
+            enabled: true,
+        },
+    },
+    include_descriptors_from_images: [
+        ":microdroid_initrd_normal_hashdesc",
+        ":microdroid_initrd_debug_hashdesc",
+    ],
+}
+
+prebuilt_etc {
+    name: "microdroid_kernel_with_modules",
+    src: ":empty_file",
+    relative_install_path: "fs",
+    arch: {
+        arm64: {
+            src: ":microdroid_kernel_with_modules_signed",
+        },
+    },
+}
diff --git a/microdroid/kernel/with-modules/Android.bp b/microdroid/kernel/with-modules/Android.bp
new file mode 100644
index 0000000..f1ec06e
--- /dev/null
+++ b/microdroid/kernel/with-modules/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2023 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+    default_applicable_licenses: ["microdroid_kernel_with_modules_prebuilts_6.1_arm64_license"],
+}
+
+// See: http://go/android-license-faq
+license {
+    name: "microdroid_kernel_with_modules_prebuilts_6.1_arm64_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-GPL-2.0-only",
+    ],
+    // large-scale-change unable to identify any license_text files
+}
+
+filegroup {
+    name: "microdroid_kernel_with_modules_prebuilts-6.1-arm64",
+    srcs: ["kernel_with_modules-6.1"],
+}
diff --git a/microdroid/kernel/with-modules/README.md b/microdroid/kernel/with-modules/README.md
new file mode 100644
index 0000000..46f6a59
--- /dev/null
+++ b/microdroid/kernel/with-modules/README.md
@@ -0,0 +1,10 @@
+# Microdroid kernel with modules
+
+This directory contains prebuilts of the Microdroid kernel with support for
+loading vendor modules. Only arm64 architecture is supported.
+
+NOTE: the prebuilt was generated on a local machine, and can only be used on
+development devices.
+
+NOTE: this feature is WIP and kernel is subject to change.
+
diff --git a/microdroid/kernel/with-modules/kernel_with_modules-6.1 b/microdroid/kernel/with-modules/kernel_with_modules-6.1
new file mode 100755
index 0000000..b732ce3
--- /dev/null
+++ b/microdroid/kernel/with-modules/kernel_with_modules-6.1
Binary files differ