blob: ee77f14eec72942f9f300bf4c62f448104e0025a [file] [log] [blame]
Bob Badoure8af2842022-04-07 10:44:22 -07001package {
Aditya Choudhary53696172024-02-05 15:46:19 +00002 default_team: "trendy_team_virtualization",
Bob Badoure8af2842022-04-07 10:44:22 -07003 default_applicable_licenses: ["Android-Apache-2.0"],
4}
5
Andrew Walbran68a8c162022-03-07 15:38:42 +00006rust_ffi_static {
7 name: "libpvmfw",
8 crate_name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +01009 defaults: ["vmbase_ffi_defaults"],
Andrew Walbran68a8c162022-03-07 15:38:42 +000010 srcs: ["src/main.rs"],
Pierre-Clément Tosie8726e42022-10-17 13:35:27 +010011 features: [
12 "legacy",
13 ],
Andrew Walbranf2594882022-03-15 17:32:53 +000014 rustlibs: [
Pierre-Clément Tosia8a4a202022-11-03 14:16:46 +000015 "libaarch64_paging",
Alice Wang947f3f72023-09-29 09:04:07 +000016 "libbssl_avf_nostd",
Maurice Lam0322b8c2023-12-18 22:13:48 +000017 "libbssl_sys_nostd",
Alan Stokesd1ee63e2023-04-24 16:17:39 +010018 "libciborium_nostd",
19 "libciborium_io_nostd",
Pierre-Clément Tosi1bf532b2023-11-13 11:06:20 +000020 "libcstr",
Alice Wangcb9d2f92023-02-06 10:29:00 +000021 "libdiced_open_dice_nostd",
Andrew Walbran730375d2022-12-21 14:04:34 +000022 "libfdtpci",
Alice Wang0bdc3f62023-03-15 10:46:12 +000023 "libhyp",
Pierre-Clément Tosia0934c12022-11-25 20:54:11 +000024 "liblibfdt",
Pierre-Clément Tosi37105a62022-10-18 12:21:48 +010025 "liblog_rust_nostd",
Andrew Walbranb398fc82023-01-24 14:45:46 +000026 "libonce_cell_nostd",
Pierre-Clément Tosi2d652982023-01-09 19:30:17 +000027 "libpvmfw_avb_nostd",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +010028 "libpvmfw_embedded_key",
Jiyong Park216793e2023-02-25 02:15:44 +090029 "libpvmfw_fdt_template",
Alice Wang12e4c862023-12-11 13:52:27 +000030 "libservice_vm_version",
Andrew Walbranf44f1602023-05-30 14:59:19 +000031 "libsmccc",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000032 "libstatic_assertions",
Pierre-Clément Tosi328dfb62022-11-25 18:20:42 +000033 "libtinyvec_nostd",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000034 "libuuid_nostd",
Andrew Walbrand1d03182022-12-09 18:20:01 +000035 "libvirtio_drivers",
Andrew Walbrandd74b902022-04-14 16:12:50 +000036 "libvmbase",
Alan Stokesa0e42962023-04-14 17:59:50 +010037 "libzerocopy_nostd",
Pierre-Clément Tosi8383c542022-11-01 14:07:29 +000038 "libzeroize_nostd",
Andrew Walbranf2594882022-03-15 17:32:53 +000039 ],
Andrew Walbran68a8c162022-03-07 15:38:42 +000040}
Andrew Walbran15068b02022-03-22 15:57:34 +000041
Alice Wang1c7e0eb2023-04-11 17:03:42 +000042// Generates an empty file.
43genrule {
44 name: "empty_file",
45 out: ["empty_file"],
46 cmd: "touch $(out)",
47}
48
Alan Stokesddb988c2023-11-27 11:13:06 +000049rust_defaults {
50 name: "libpvmfw.test.defaults",
Nikita Ioffeda1b2732023-09-04 13:46:56 +010051 defaults: ["avf_build_flags_rust"],
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090052 test_suites: ["general-tests"],
53 test_options: {
54 unit_test: true,
55 },
Alan Stokesddb988c2023-11-27 11:13:06 +000056 prefer_rlib: true,
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090057 rustlibs: [
Pierre-Clément Tosi1bf532b2023-11-13 11:06:20 +000058 "libcstr",
Alan Stokesddb988c2023-11-27 11:13:06 +000059 ],
60}
61
62rust_test {
63 name: "libpvmfw.bootargs.test",
64 host_supported: true,
65 // For now, only bootargs.rs is written to be conditionally compiled with std.
66 srcs: ["src/bootargs.rs"],
67 defaults: ["libpvmfw.test.defaults"],
68 rustlibs: [
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090069 "libzeroize",
70 ],
71}
72
Alan Stokesddb988c2023-11-27 11:13:06 +000073rust_test {
74 name: "libpvmfw.device_assignment.test",
75 srcs: ["src/device_assignment.rs"],
76 defaults: ["libpvmfw.test.defaults"],
77 rustlibs: [
Jaewan Kim52477ae2023-11-21 21:20:52 +090078 "libhyp",
Alan Stokesddb988c2023-11-27 11:13:06 +000079 "liblibfdt",
80 "liblog_rust",
81 "libpvmfw_fdt_template",
82 ],
83 data: [
84 ":test_pvmfw_devices_vm_dtbo",
85 ":test_pvmfw_devices_vm_dtbo_without_symbols",
Jaewan Kim19b984f2023-12-04 15:16:50 +090086 ":test_pvmfw_devices_vm_dtbo_with_duplicated_iommus",
Alan Stokesddb988c2023-11-27 11:13:06 +000087 ":test_pvmfw_devices_with_rng",
Alan Stokesddb988c2023-11-27 11:13:06 +000088 ":test_pvmfw_devices_with_multiple_devices_iommus",
89 ":test_pvmfw_devices_with_iommu_sharing",
90 ":test_pvmfw_devices_with_iommu_id_conflict",
Jaewan Kim52477ae2023-11-21 21:20:52 +090091 ":test_pvmfw_devices_without_device",
Jaewan Kima67e36a2023-11-29 16:50:23 +090092 ":test_pvmfw_devices_without_iommus",
Jaewan Kim19b984f2023-12-04 15:16:50 +090093 ":test_pvmfw_devices_with_duplicated_pviommus",
94 ":test_pvmfw_devices_with_multiple_reg_iommus",
Alan Stokesddb988c2023-11-27 11:13:06 +000095 ],
96 // To use libpvmfw_fdt_template for testing
97 enabled: false,
98 target: {
99 android_arm64: {
100 enabled: true,
101 },
102 },
103}
104
105rust_test {
106 name: "libpvmfw.dice.test",
107 srcs: ["src/dice.rs"],
108 defaults: ["libpvmfw.test.defaults"],
109 rustlibs: [
110 "libcbor_util",
111 "libciborium",
112 "libdiced_open_dice_nostd",
113 "libpvmfw_avb_nostd",
114 ],
115}
116
Jaewan Kimc6e023b2023-10-12 15:11:05 +0900117genrule {
118 name: "test_pvmfw_devices_vm_dtbo",
119 defaults: ["dts_to_dtb"],
120 srcs: ["testdata/test_pvmfw_devices_vm_dtbo.dts"],
121 out: ["test_pvmfw_devices_vm_dtbo.dtbo"],
122}
123
124genrule {
125 name: "test_pvmfw_devices_vm_dtbo_without_symbols",
126 defaults: ["dts_to_dtb"],
127 srcs: ["testdata/test_pvmfw_devices_vm_dtbo_without_symbols.dts"],
128 out: ["test_pvmfw_devices_vm_dtbo_without_symbols.dtbo"],
129}
130
Jaewan Kim19b984f2023-12-04 15:16:50 +0900131genrule {
132 name: "test_pvmfw_devices_vm_dtbo_with_duplicated_iommus",
133 defaults: ["dts_to_dtb"],
134 srcs: ["testdata/test_pvmfw_devices_vm_dtbo_with_duplicated_iommus.dts"],
135 out: ["test_pvmfw_devices_vm_dtbo_with_duplicated_iommus.dtbo"],
136}
137
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900138genrule_defaults {
139 name: "test_device_assignment_dts_to_dtb",
140 defaults: ["dts_to_dtb"],
141 srcs: ["testdata/test_crosvm_dt_base.dtsi"],
142}
143
Jaewan Kimc6e023b2023-10-12 15:11:05 +0900144genrule {
145 name: "test_pvmfw_devices_with_rng",
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900146 defaults: ["test_device_assignment_dts_to_dtb"],
Jaewan Kimc6e023b2023-10-12 15:11:05 +0900147 srcs: ["testdata/test_pvmfw_devices_with_rng.dts"],
148 out: ["test_pvmfw_devices_with_rng.dtb"],
149}
150
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900151genrule {
Jaewan Kima67e36a2023-11-29 16:50:23 +0900152 name: "test_pvmfw_devices_without_iommus",
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900153 defaults: ["test_device_assignment_dts_to_dtb"],
Jaewan Kima67e36a2023-11-29 16:50:23 +0900154 srcs: ["testdata/test_pvmfw_devices_without_iommus.dts"],
155 out: ["test_pvmfw_devices_without_iommus.dtb"],
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900156}
157
158genrule {
Jaewan Kim52477ae2023-11-21 21:20:52 +0900159 name: "test_pvmfw_devices_without_device",
160 defaults: ["test_device_assignment_dts_to_dtb"],
161 srcs: ["testdata/test_pvmfw_devices_without_device.dts"],
162 out: ["test_pvmfw_devices_without_device.dtb"],
163}
164
165genrule {
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900166 name: "test_pvmfw_devices_with_multiple_devices_iommus",
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900167 defaults: ["test_device_assignment_dts_to_dtb"],
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900168 srcs: ["testdata/test_pvmfw_devices_with_multiple_devices_iommus.dts"],
169 out: ["test_pvmfw_devices_with_multiple_devices_iommus.dtb"],
170}
171
172genrule {
173 name: "test_pvmfw_devices_with_iommu_sharing",
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900174 defaults: ["test_device_assignment_dts_to_dtb"],
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900175 srcs: ["testdata/test_pvmfw_devices_with_iommu_sharing.dts"],
176 out: ["test_pvmfw_devices_with_iommu_sharing.dtb"],
177}
178
179genrule {
180 name: "test_pvmfw_devices_with_iommu_id_conflict",
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900181 defaults: ["test_device_assignment_dts_to_dtb"],
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900182 srcs: ["testdata/test_pvmfw_devices_with_iommu_id_conflict.dts"],
183 out: ["test_pvmfw_devices_with_iommu_id_conflict.dtb"],
184}
185
Jaewan Kim19b984f2023-12-04 15:16:50 +0900186genrule {
187 name: "test_pvmfw_devices_with_duplicated_pviommus",
188 defaults: ["test_device_assignment_dts_to_dtb"],
189 srcs: ["testdata/test_pvmfw_devices_with_duplicated_pviommus.dts"],
190 out: ["test_pvmfw_devices_with_duplicated_pviommus.dtb"],
191}
192
193genrule {
194 name: "test_pvmfw_devices_with_multiple_reg_iommus",
195 defaults: ["test_device_assignment_dts_to_dtb"],
196 srcs: ["testdata/test_pvmfw_devices_with_multiple_reg_iommus.dts"],
197 out: ["test_pvmfw_devices_with_multiple_reg_iommus.dtb"],
198}
199
Andrew Walbran15068b02022-03-22 15:57:34 +0000200cc_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +0100201 name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +0100202 defaults: ["vmbase_elf_defaults"],
Andrew Walbran15068b02022-03-22 15:57:34 +0000203 srcs: [
Andrew Walbran267f6c12022-03-24 11:26:36 +0000204 "idmap.S",
Andrew Walbran15068b02022-03-22 15:57:34 +0000205 ],
206 static_libs: [
207 "libpvmfw",
208 ],
Andrew Walbrana5b7af52022-07-06 15:06:20 +0000209 linker_scripts: [
210 "image.ld",
211 ":vmbase_sections",
212 ],
Jiyong Park17b8d752022-12-16 14:36:24 +0900213 // `installable: false` is inherited from vmbase_elf_defaults, and that
214 // hides this module from Make, which makes it impossible for the Make world
215 // to place the unstripped binary to the symbols directory. Marking back as
216 // installable exposes this module to the Make world again. Note that this
217 // module (pvmfw) still is NOT installed to any of the filesystem images. It
218 // is fed into pvmfw_bin and then into pvmfw_img to become a standalone
219 // partition image. This is just to package the unstripped file into the
220 // symbols zip file for debugging purpose.
221 installable: true,
Andrew Walbran15068b02022-03-22 15:57:34 +0000222}
David Brazdil05d4e072022-04-25 14:47:06 +0100223
224raw_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +0100225 name: "pvmfw_bin",
226 stem: "pvmfw.bin",
227 src: ":pvmfw",
David Brazdil05d4e072022-04-25 14:47:06 +0100228 enabled: false,
229 target: {
230 android_arm64: {
231 enabled: true,
232 },
233 },
234}
David Brazdilac216b52022-04-25 15:07:22 +0100235
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900236// Provide pvmfw.bin binary regardless of the architecture for building test.
237// Note that skipping tests on unsupported device is easy
238// while configuring server configuration to make such tests to run on working
239// devices.
240prebuilt_etc {
241 name: "pvmfw_test",
242 filename: "pvmfw_test.bin",
243 target: {
244 android_arm64: {
245 src: ":pvmfw_bin",
246 },
247 },
Alice Wang1c7e0eb2023-04-11 17:03:42 +0000248 src: ":empty_file",
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900249 installable: false,
250}
251
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100252prebuilt_etc {
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100253 name: "pvmfw_embedded_key",
254 src: ":avb_testkey_rsa4096_pub_bin",
255 installable: false,
256}
257
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100258genrule {
259 name: "pvmfw_embedded_key_rs",
260 srcs: [":pvmfw_embedded_key"],
261 out: ["lib.rs"],
262 cmd: "(" +
263 " echo '#![no_std]';" +
264 " echo '#![allow(missing_docs)]';" +
265 " echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
266 " xxd -i < $(in);" +
267 " echo '];';" +
268 ") > $(out)",
269}
270
271rust_library_rlib {
272 name: "libpvmfw_embedded_key",
Pierre-Clément Tosi4894b432023-06-27 14:02:26 +0000273 defaults: ["vmbase_rlib_defaults"],
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100274 srcs: [":pvmfw_embedded_key_rs"],
275 crate_name: "pvmfw_embedded_key",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100276}
277
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100278prebuilt_etc {
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100279 name: "pvmfw_sign_key",
280 src: ":avb_testkey_rsa4096",
281 installable: false,
282}
283
Jiyong Park9c1c8182023-05-25 15:40:11 +0900284// We need to rename *.dts into *.cpp as cc_object doesn't accept *.dts as an
285// input
Jiyong Park216793e2023-02-25 02:15:44 +0900286genrule {
Jiyong Park9c1c8182023-05-25 15:40:11 +0900287 name: "pvmfw_platform.dts.renamed",
288 srcs: ["platform.dts"],
289 out: ["out.cpp"],
290 cmd: "cp $(in) $(out)",
291 visibility: ["//visibility:private"],
292}
293
294// Then run the macro processor to replace symbols like GIC_SPI into actual
295// numbers defined in the ARM DT binding headers
296cc_object {
297 name: "pvmfw_platform.dts.preprocessed",
298 header_libs: ["arm_dt_bindings_headers"],
299 host_supported: true,
300 srcs: [":pvmfw_platform.dts.renamed"],
301 cflags: [
302 "-E",
303 "-P",
304 "-xassembler-with-cpp", // allow C preprocessor directives
Jiyong Park216793e2023-02-25 02:15:44 +0900305 ],
Jiyong Park9c1c8182023-05-25 15:40:11 +0900306 visibility: ["//visibility:private"],
307}
308
309// Compile the preprocessed dts into binary and create a rust library source
310// having the binary.
311cc_genrule {
312 name: "pvmfw_fdt_template_rs",
313 srcs: [":pvmfw_platform.dts.preprocessed"],
Jiyong Park216793e2023-02-25 02:15:44 +0900314 out: ["lib.rs"],
315 tools: ["dtc"],
Jaewan Kim96411e92023-11-13 15:54:02 +0900316 cmd: "$(location dtc) -@ -I dts -O dtb -o $(genDir)/compiled.dtbo $(in) && " +
Jiyong Park216793e2023-02-25 02:15:44 +0900317 "(" +
318 " echo '#![no_std]';" +
319 " echo '#![allow(missing_docs)]';" +
320 " echo 'pub const RAW: &[u8] = &[';" +
321 " xxd -i < $(genDir)/compiled.dtbo;" +
322 " echo '];';" +
323 ") > $(out)",
Jiyong Park9c1c8182023-05-25 15:40:11 +0900324 visibility: ["//visibility:private"],
Jiyong Park216793e2023-02-25 02:15:44 +0900325}
326
327rust_library_rlib {
328 name: "libpvmfw_fdt_template",
Pierre-Clément Tosi4894b432023-06-27 14:02:26 +0000329 defaults: ["vmbase_rlib_defaults"],
Jiyong Park216793e2023-02-25 02:15:44 +0900330 srcs: [":pvmfw_fdt_template_rs"],
331 crate_name: "pvmfw_fdt_template",
332}
333
David Brazdilac216b52022-04-25 15:07:22 +0100334bootimg {
335 name: "pvmfw_img",
336 stem: "pvmfw.img",
337 kernel_prebuilt: ":pvmfw_bin",
338 header_version: "3",
339 partition_name: "pvmfw",
340 enabled: false,
341 target: {
342 android_arm64: {
343 enabled: true,
344 },
345 },
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100346 use_avb: true,
347 avb_private_key: ":pvmfw_sign_key",
David Brazdilac216b52022-04-25 15:07:22 +0100348}