2022-04-07 17:44:22 +00:00
|
|
|
package {
|
|
|
|
default_applicable_licenses: ["Android-Apache-2.0"],
|
|
|
|
}
|
|
|
|
|
2022-03-07 15:38:42 +00:00
|
|
|
rust_ffi_static {
|
|
|
|
name: "libpvmfw",
|
|
|
|
crate_name: "pvmfw",
|
2022-07-07 14:30:14 +00:00
|
|
|
defaults: ["vmbase_ffi_defaults"],
|
2022-03-07 15:38:42 +00:00
|
|
|
srcs: ["src/main.rs"],
|
|
|
|
edition: "2021",
|
2023-04-14 16:59:50 +00:00
|
|
|
// Require unsafe blocks for inside unsafe functions.
|
|
|
|
flags: ["-Dunsafe_op_in_unsafe_fn"],
|
2022-10-17 12:35:27 +00:00
|
|
|
features: [
|
|
|
|
"legacy",
|
|
|
|
],
|
2022-03-15 17:32:53 +00:00
|
|
|
rustlibs: [
|
2022-11-03 14:16:46 +00:00
|
|
|
"libaarch64_paging",
|
2023-02-17 11:19:56 +00:00
|
|
|
"libbssl_ffi_nostd",
|
2022-10-20 11:22:23 +00:00
|
|
|
"libbuddy_system_allocator",
|
2023-04-24 15:17:39 +00:00
|
|
|
"libciborium_nostd",
|
|
|
|
"libciborium_io_nostd",
|
2023-02-06 10:29:00 +00:00
|
|
|
"libdiced_open_dice_nostd",
|
2022-12-21 14:04:34 +00:00
|
|
|
"libfdtpci",
|
2023-03-15 10:46:12 +00:00
|
|
|
"libhyp",
|
2022-11-25 20:54:11 +00:00
|
|
|
"liblibfdt",
|
2022-10-18 11:21:48 +00:00
|
|
|
"liblog_rust_nostd",
|
2023-01-24 14:45:46 +00:00
|
|
|
"libonce_cell_nostd",
|
2023-04-17 14:26:23 +00:00
|
|
|
"libpsci",
|
2023-01-09 19:30:17 +00:00
|
|
|
"libpvmfw_avb_nostd",
|
2022-10-26 16:40:50 +00:00
|
|
|
"libpvmfw_embedded_key",
|
2023-02-24 17:15:44 +00:00
|
|
|
"libpvmfw_fdt_template",
|
pvmfw: Support instance.img for storing DICE salt
On boot, attempt to read the DICE hidden input (salt) from persistent
storage, in order to provide persistence of secrets across reboots of
the same kernel/ramdisk images. To ensure that the salt is only re-used
with the same preloaded images signed by the same authority, store the
other DICE inputs so that they can be verified to match on the next
boot.
Implement support for parsing GUID Partition Tables (GPT) on top of
virtio-blk, to locate, read from, and write to named partitions.
Implement support for the instance.img format, defined by the AVF team,
and conceptually acting as a filesystem within the GPT partition named
"vm-instance", where each stage of the pVM boot process owns an entry
(sometimes called a partition), identified through a UUID.
As the host is in charge of providing the file backing the virtual disk,
the content of the instance.img entry will be encrypted in a following
commit.
Bug: 262344886
Test: atest MicrodroidHostTests
Change-Id: Ic43bb7780b5e106002590f9c97cd900c3ff5e3d9
2023-02-02 11:09:18 +00:00
|
|
|
"libstatic_assertions",
|
2022-11-25 18:20:42 +00:00
|
|
|
"libtinyvec_nostd",
|
pvmfw: Support instance.img for storing DICE salt
On boot, attempt to read the DICE hidden input (salt) from persistent
storage, in order to provide persistence of secrets across reboots of
the same kernel/ramdisk images. To ensure that the salt is only re-used
with the same preloaded images signed by the same authority, store the
other DICE inputs so that they can be verified to match on the next
boot.
Implement support for parsing GUID Partition Tables (GPT) on top of
virtio-blk, to locate, read from, and write to named partitions.
Implement support for the instance.img format, defined by the AVF team,
and conceptually acting as a filesystem within the GPT partition named
"vm-instance", where each stage of the pVM boot process owns an entry
(sometimes called a partition), identified through a UUID.
As the host is in charge of providing the file backing the virtual disk,
the content of the instance.img entry will be encrypted in a following
commit.
Bug: 262344886
Test: atest MicrodroidHostTests
Change-Id: Ic43bb7780b5e106002590f9c97cd900c3ff5e3d9
2023-02-02 11:09:18 +00:00
|
|
|
"libuuid_nostd",
|
2022-12-09 18:20:01 +00:00
|
|
|
"libvirtio_drivers",
|
2022-04-14 16:12:50 +00:00
|
|
|
"libvmbase",
|
2023-04-14 16:59:50 +00:00
|
|
|
"libzerocopy_nostd",
|
2022-11-01 14:07:29 +00:00
|
|
|
"libzeroize_nostd",
|
2023-04-20 08:51:10 +00:00
|
|
|
"libspin_nostd",
|
2022-03-15 17:32:53 +00:00
|
|
|
],
|
2022-03-07 15:38:42 +00:00
|
|
|
}
|
2022-03-22 15:57:34 +00:00
|
|
|
|
2023-04-11 17:03:42 +00:00
|
|
|
// Generates an empty file.
|
|
|
|
genrule {
|
|
|
|
name: "empty_file",
|
|
|
|
out: ["empty_file"],
|
|
|
|
cmd: "touch $(out)",
|
|
|
|
}
|
|
|
|
|
2023-04-10 16:23:46 +00:00
|
|
|
rust_test {
|
|
|
|
name: "libpvmfw.bootargs.test",
|
|
|
|
host_supported: true,
|
|
|
|
// For now, only bootargs.rs is written to be conditionally compiled with std.
|
|
|
|
srcs: ["src/bootargs.rs"],
|
|
|
|
test_suites: ["general-tests"],
|
|
|
|
test_options: {
|
|
|
|
unit_test: true,
|
|
|
|
},
|
|
|
|
rustlibs: [
|
|
|
|
"libzeroize",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
2022-03-22 15:57:34 +00:00
|
|
|
cc_binary {
|
2022-09-09 10:01:06 +00:00
|
|
|
name: "pvmfw",
|
2022-07-07 14:30:14 +00:00
|
|
|
defaults: ["vmbase_elf_defaults"],
|
2022-03-22 15:57:34 +00:00
|
|
|
srcs: [
|
2022-03-24 11:26:36 +00:00
|
|
|
"idmap.S",
|
2022-03-22 15:57:34 +00:00
|
|
|
],
|
|
|
|
static_libs: [
|
|
|
|
"libpvmfw",
|
|
|
|
],
|
2022-07-06 15:06:20 +00:00
|
|
|
linker_scripts: [
|
|
|
|
"image.ld",
|
|
|
|
":vmbase_sections",
|
|
|
|
],
|
2022-12-16 05:36:24 +00:00
|
|
|
// `installable: false` is inherited from vmbase_elf_defaults, and that
|
|
|
|
// hides this module from Make, which makes it impossible for the Make world
|
|
|
|
// to place the unstripped binary to the symbols directory. Marking back as
|
|
|
|
// installable exposes this module to the Make world again. Note that this
|
|
|
|
// module (pvmfw) still is NOT installed to any of the filesystem images. It
|
|
|
|
// is fed into pvmfw_bin and then into pvmfw_img to become a standalone
|
|
|
|
// partition image. This is just to package the unstripped file into the
|
|
|
|
// symbols zip file for debugging purpose.
|
|
|
|
installable: true,
|
2023-03-13 21:18:40 +00:00
|
|
|
native_coverage: false,
|
2022-03-22 15:57:34 +00:00
|
|
|
}
|
2022-04-25 13:47:06 +00:00
|
|
|
|
|
|
|
raw_binary {
|
2022-09-09 10:01:06 +00:00
|
|
|
name: "pvmfw_bin",
|
|
|
|
stem: "pvmfw.bin",
|
|
|
|
src: ":pvmfw",
|
2022-04-25 13:47:06 +00:00
|
|
|
enabled: false,
|
|
|
|
target: {
|
|
|
|
android_arm64: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2022-04-25 14:07:22 +00:00
|
|
|
|
2023-02-09 16:35:47 +00:00
|
|
|
// Provide pvmfw.bin binary regardless of the architecture for building test.
|
|
|
|
// Note that skipping tests on unsupported device is easy
|
|
|
|
// while configuring server configuration to make such tests to run on working
|
|
|
|
// devices.
|
|
|
|
prebuilt_etc {
|
|
|
|
name: "pvmfw_test",
|
|
|
|
filename: "pvmfw_test.bin",
|
|
|
|
target: {
|
|
|
|
android_arm64: {
|
|
|
|
src: ":pvmfw_bin",
|
|
|
|
},
|
|
|
|
},
|
2023-04-11 17:03:42 +00:00
|
|
|
src: ":empty_file",
|
2023-02-09 16:35:47 +00:00
|
|
|
installable: false,
|
|
|
|
}
|
|
|
|
|
2022-10-26 14:14:45 +00:00
|
|
|
prebuilt_etc {
|
|
|
|
name: "pvmfw_embedded_key",
|
|
|
|
src: ":avb_testkey_rsa4096_pub_bin",
|
|
|
|
installable: false,
|
|
|
|
}
|
|
|
|
|
2022-10-26 16:40:50 +00:00
|
|
|
genrule {
|
|
|
|
name: "pvmfw_embedded_key_rs",
|
|
|
|
srcs: [":pvmfw_embedded_key"],
|
|
|
|
out: ["lib.rs"],
|
|
|
|
cmd: "(" +
|
|
|
|
" echo '#![no_std]';" +
|
|
|
|
" echo '#![allow(missing_docs)]';" +
|
|
|
|
" echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
|
|
|
|
" xxd -i < $(in);" +
|
|
|
|
" echo '];';" +
|
|
|
|
") > $(out)",
|
|
|
|
}
|
|
|
|
|
|
|
|
rust_library_rlib {
|
|
|
|
name: "libpvmfw_embedded_key",
|
|
|
|
defaults: ["vmbase_ffi_defaults"],
|
|
|
|
prefer_rlib: true,
|
|
|
|
srcs: [":pvmfw_embedded_key_rs"],
|
|
|
|
crate_name: "pvmfw_embedded_key",
|
|
|
|
apex_available: ["com.android.virt"],
|
|
|
|
}
|
|
|
|
|
2022-09-06 15:01:35 +00:00
|
|
|
prebuilt_etc {
|
|
|
|
name: "pvmfw_sign_key",
|
|
|
|
src: ":avb_testkey_rsa4096",
|
|
|
|
installable: false,
|
|
|
|
}
|
|
|
|
|
2023-02-24 17:15:44 +00:00
|
|
|
// platform.dts is passed to clang for macro preprocessing, and then compiled to dtbo using dtc.
|
|
|
|
// The raw content of the dtbo file is then written as a Rust byte array.
|
|
|
|
genrule {
|
|
|
|
name: "pvmfw_fdt_template_rs",
|
|
|
|
srcs: [
|
|
|
|
"platform.dts",
|
|
|
|
":arm_dt_bindings_headers", // implicit dependency
|
|
|
|
],
|
|
|
|
out: ["lib.rs"],
|
|
|
|
tools: ["dtc"],
|
2023-05-19 20:04:16 +00:00
|
|
|
cmd: "prebuilts/clang/host/linux-x86/clang-r487747c/bin/clang " + // UGLY!!!
|
2023-02-24 17:15:44 +00:00
|
|
|
"-E -P -x assembler-with-cpp -I external/arm-trusted-firmware/include " +
|
|
|
|
"-o $(genDir)/preprocessed.dts $(location platform.dts) && " +
|
|
|
|
"$(location dtc) -I dts -O dtb -o $(genDir)/compiled.dtbo $(genDir)/preprocessed.dts && " +
|
|
|
|
"(" +
|
|
|
|
" echo '#![no_std]';" +
|
|
|
|
" echo '#![allow(missing_docs)]';" +
|
|
|
|
" echo 'pub const RAW: &[u8] = &[';" +
|
|
|
|
" xxd -i < $(genDir)/compiled.dtbo;" +
|
|
|
|
" echo '];';" +
|
|
|
|
") > $(out)",
|
|
|
|
}
|
|
|
|
|
|
|
|
rust_library_rlib {
|
|
|
|
name: "libpvmfw_fdt_template",
|
|
|
|
defaults: ["vmbase_ffi_defaults"],
|
|
|
|
prefer_rlib: true,
|
|
|
|
srcs: [":pvmfw_fdt_template_rs"],
|
|
|
|
crate_name: "pvmfw_fdt_template",
|
|
|
|
}
|
|
|
|
|
2022-04-25 14:07:22 +00:00
|
|
|
bootimg {
|
|
|
|
name: "pvmfw_img",
|
|
|
|
stem: "pvmfw.img",
|
|
|
|
kernel_prebuilt: ":pvmfw_bin",
|
|
|
|
header_version: "3",
|
|
|
|
partition_name: "pvmfw",
|
|
|
|
enabled: false,
|
|
|
|
target: {
|
|
|
|
android_arm64: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
},
|
2022-09-06 15:01:35 +00:00
|
|
|
use_avb: true,
|
|
|
|
avb_private_key: ":pvmfw_sign_key",
|
2022-04-25 14:07:22 +00:00
|
|
|
}
|