1package { 2 default_applicable_licenses: ["Android-Apache-2.0"], 3} 4 5rust_ffi_static { 6 name: "librialto", 7 crate_name: "rialto", 8 srcs: ["src/main.rs"], 9 defaults: ["vmbase_ffi_defaults"], 10 rustlibs: [ 11 "libbssl_avf_nostd", 12 "libciborium_io_nostd", 13 "libciborium_nostd", 14 "libdiced_open_dice_nostd", 15 "libhypervisor_backends", 16 "liblibfdt_nostd", 17 "liblog_rust_nostd", 18 "libservice_vm_comm_nostd", 19 "libservice_vm_fake_chain_nostd", 20 "libservice_vm_requests_nostd", 21 "libtinyvec_nostd", 22 "libvirtio_drivers", 23 "libvmbase", 24 ], 25 target: { 26 android_arm64: { 27 rustlibs: [ 28 "libaarch64_paging", 29 ], 30 }, 31 }, 32} 33 34cc_binary { 35 name: "rialto_elf", 36 stem: "rialto", 37 defaults: ["vmbase_elf_defaults"], 38 srcs: [ 39 "idmap.S", 40 ], 41 static_libs: [ 42 "librialto", 43 "libvmbase_dice_clear_memory", 44 ], 45 linker_scripts: [ 46 "image.ld", 47 ":vmbase_sections", 48 ], 49} 50 51raw_binary { 52 name: "rialto_unsigned", 53 src: ":rialto_elf", 54 enabled: false, 55 target: { 56 android_arm64: { 57 enabled: true, 58 }, 59 }, 60} 61 62// python -c "import hashlib; print(hashlib.sha256(b'rialto_salt').hexdigest())" 63rialto_salt = "ea9d8c3ae1785396884d0c16c7652921874e2b8703f336ff23760f2049ee9e29" 64 65filegroup { 66 name: "rialto_sign_key", 67 srcs: [":avb_testkey_rsa4096"], 68} 69 70// Both SERVICE_VM_VERSION and SERVICE_VM_VERSION_STRING should represent the 71// same version number for the service VM. 72SERVICE_VM_VERSION = 2 73SERVICE_VM_VERSION_STRING = "2" 74 75genrule { 76 name: "service_vm_version_rs", 77 out: ["lib.rs"], 78 cmd: "(" + 79 " echo '#![no_std]';" + 80 " echo '#![allow(missing_docs)]';" + 81 " echo 'pub const VERSION: u64 = " + SERVICE_VM_VERSION_STRING + ";'" + 82 ") > $(out)", 83} 84 85rust_library_rlib { 86 name: "libservice_vm_version", 87 crate_name: "service_vm_version", 88 defaults: ["vmbase_rlib_defaults"], 89 srcs: [":service_vm_version_rs"], 90} 91 92avb_add_hash_footer { 93 name: "rialto_signed", 94 src: ":empty_file", 95 filename: "rialto", 96 partition_name: "boot", 97 private_key: ":rialto_sign_key", 98 salt: rialto_salt, 99 rollback_index: SERVICE_VM_VERSION, 100 props: [ 101 { 102 name: "com.android.virt.cap", 103 value: "remote_attest", 104 }, 105 ], 106 enabled: false, 107 arch: { 108 arm64: { 109 src: ":rialto_unsigned", 110 enabled: true, 111 }, 112 }, 113} 114 115prebuilt_etc { 116 // rialto_bin is a prebuilt target wrapping the signed bare-metal service VM. 117 name: "rialto_bin", 118 filename: "rialto.bin", 119 target: { 120 android_arm64: { 121 src: ":rialto_signed", 122 }, 123 }, 124 src: ":empty_file", 125 installable: false, 126} 127 128rust_test { 129 name: "rialto_test", 130 crate_name: "rialto_test", 131 defaults: ["avf_build_flags_rust"], 132 srcs: ["tests/test.rs"], 133 prefer_rlib: true, 134 edition: "2021", 135 rustlibs: [ 136 "android.system.virtualizationservice-rust", 137 "libandroid_logger", 138 "libanyhow", 139 "libbssl_avf_nostd", 140 "libclient_vm_csr", 141 "libcoset", 142 "liblibc", 143 "liblog_rust", 144 "libhwtrust", 145 "libhypervisor_props", 146 "libservice_vm_comm", 147 "libservice_vm_fake_chain", 148 "libservice_vm_manager", 149 "libvmclient", 150 "libx509_cert_nostd", 151 ], 152 data: [ 153 ":rialto_unsigned", 154 ":test_rkp_cert_chain", 155 ], 156 test_suites: ["general-tests"], 157 enabled: false, 158 target: { 159 android_arm64: { 160 enabled: true, 161 }, 162 }, 163} 164