blob: 37d8ac94b70f7a859b4f519269928833a48f504a [file] [log] [blame]
Bob Badoure8af2842022-04-07 10:44:22 -07001package {
2 default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
Andrew Walbran68a8c162022-03-07 15:38:42 +00005rust_ffi_static {
6 name: "libpvmfw",
7 crate_name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +01008 defaults: ["vmbase_ffi_defaults"],
Andrew Walbran68a8c162022-03-07 15:38:42 +00009 srcs: ["src/main.rs"],
Pierre-Clément Tosie8726e42022-10-17 13:35:27 +010010 features: [
11 "legacy",
12 ],
Andrew Walbranf2594882022-03-15 17:32:53 +000013 rustlibs: [
Pierre-Clément Tosia8a4a202022-11-03 14:16:46 +000014 "libaarch64_paging",
Alice Wang947f3f72023-09-29 09:04:07 +000015 "libbssl_avf_nostd",
Pierre-Clément Tosi90cd4f12023-02-17 11:19:56 +000016 "libbssl_ffi_nostd",
Alan Stokesd1ee63e2023-04-24 16:17:39 +010017 "libciborium_nostd",
18 "libciborium_io_nostd",
Pierre-Clément Tosi1bf532b2023-11-13 11:06:20 +000019 "libcstr",
Alice Wangcb9d2f92023-02-06 10:29:00 +000020 "libdiced_open_dice_nostd",
Andrew Walbran730375d2022-12-21 14:04:34 +000021 "libfdtpci",
Alice Wang0bdc3f62023-03-15 10:46:12 +000022 "libhyp",
Pierre-Clément Tosia0934c12022-11-25 20:54:11 +000023 "liblibfdt",
Pierre-Clément Tosi37105a62022-10-18 12:21:48 +010024 "liblog_rust_nostd",
Andrew Walbranb398fc82023-01-24 14:45:46 +000025 "libonce_cell_nostd",
Pierre-Clément Tosi2d652982023-01-09 19:30:17 +000026 "libpvmfw_avb_nostd",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +010027 "libpvmfw_embedded_key",
Jiyong Park216793e2023-02-25 02:15:44 +090028 "libpvmfw_fdt_template",
Alice Wang12e4c862023-12-11 13:52:27 +000029 "libservice_vm_version",
Andrew Walbranf44f1602023-05-30 14:59:19 +000030 "libsmccc",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000031 "libstatic_assertions",
Pierre-Clément Tosi328dfb62022-11-25 18:20:42 +000032 "libtinyvec_nostd",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000033 "libuuid_nostd",
Andrew Walbrand1d03182022-12-09 18:20:01 +000034 "libvirtio_drivers",
Andrew Walbrandd74b902022-04-14 16:12:50 +000035 "libvmbase",
Alan Stokesa0e42962023-04-14 17:59:50 +010036 "libzerocopy_nostd",
Pierre-Clément Tosi8383c542022-11-01 14:07:29 +000037 "libzeroize_nostd",
Andrew Walbranf2594882022-03-15 17:32:53 +000038 ],
Andrew Walbran68a8c162022-03-07 15:38:42 +000039}
Andrew Walbran15068b02022-03-22 15:57:34 +000040
Alice Wang1c7e0eb2023-04-11 17:03:42 +000041// Generates an empty file.
42genrule {
43 name: "empty_file",
44 out: ["empty_file"],
45 cmd: "touch $(out)",
46}
47
Alan Stokesddb988c2023-11-27 11:13:06 +000048rust_defaults {
49 name: "libpvmfw.test.defaults",
Nikita Ioffeda1b2732023-09-04 13:46:56 +010050 defaults: ["avf_build_flags_rust"],
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090051 test_suites: ["general-tests"],
52 test_options: {
53 unit_test: true,
54 },
Alan Stokesddb988c2023-11-27 11:13:06 +000055 prefer_rlib: true,
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090056 rustlibs: [
Pierre-Clément Tosi1bf532b2023-11-13 11:06:20 +000057 "libcstr",
Alan Stokesddb988c2023-11-27 11:13:06 +000058 ],
59}
60
61rust_test {
62 name: "libpvmfw.bootargs.test",
63 host_supported: true,
64 // For now, only bootargs.rs is written to be conditionally compiled with std.
65 srcs: ["src/bootargs.rs"],
66 defaults: ["libpvmfw.test.defaults"],
67 rustlibs: [
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090068 "libzeroize",
69 ],
70}
71
Alan Stokesddb988c2023-11-27 11:13:06 +000072rust_test {
73 name: "libpvmfw.device_assignment.test",
74 srcs: ["src/device_assignment.rs"],
75 defaults: ["libpvmfw.test.defaults"],
76 rustlibs: [
Jaewan Kim52477ae2023-11-21 21:20:52 +090077 "libhyp",
Alan Stokesddb988c2023-11-27 11:13:06 +000078 "liblibfdt",
79 "liblog_rust",
80 "libpvmfw_fdt_template",
81 ],
82 data: [
83 ":test_pvmfw_devices_vm_dtbo",
84 ":test_pvmfw_devices_vm_dtbo_without_symbols",
85 ":test_pvmfw_devices_with_rng",
Alan Stokesddb988c2023-11-27 11:13:06 +000086 ":test_pvmfw_devices_with_multiple_devices_iommus",
87 ":test_pvmfw_devices_with_iommu_sharing",
88 ":test_pvmfw_devices_with_iommu_id_conflict",
Jaewan Kim52477ae2023-11-21 21:20:52 +090089 ":test_pvmfw_devices_without_device",
Jaewan Kima67e36a2023-11-29 16:50:23 +090090 ":test_pvmfw_devices_without_iommus",
Alan Stokesddb988c2023-11-27 11:13:06 +000091 ],
92 // To use libpvmfw_fdt_template for testing
93 enabled: false,
94 target: {
95 android_arm64: {
96 enabled: true,
97 },
98 },
99}
100
101rust_test {
102 name: "libpvmfw.dice.test",
103 srcs: ["src/dice.rs"],
104 defaults: ["libpvmfw.test.defaults"],
105 rustlibs: [
106 "libcbor_util",
107 "libciborium",
108 "libdiced_open_dice_nostd",
109 "libpvmfw_avb_nostd",
110 ],
111}
112
Jaewan Kimc6e023b2023-10-12 15:11:05 +0900113genrule {
114 name: "test_pvmfw_devices_vm_dtbo",
115 defaults: ["dts_to_dtb"],
116 srcs: ["testdata/test_pvmfw_devices_vm_dtbo.dts"],
117 out: ["test_pvmfw_devices_vm_dtbo.dtbo"],
118}
119
120genrule {
121 name: "test_pvmfw_devices_vm_dtbo_without_symbols",
122 defaults: ["dts_to_dtb"],
123 srcs: ["testdata/test_pvmfw_devices_vm_dtbo_without_symbols.dts"],
124 out: ["test_pvmfw_devices_vm_dtbo_without_symbols.dtbo"],
125}
126
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900127genrule_defaults {
128 name: "test_device_assignment_dts_to_dtb",
129 defaults: ["dts_to_dtb"],
130 srcs: ["testdata/test_crosvm_dt_base.dtsi"],
131}
132
Jaewan Kimc6e023b2023-10-12 15:11:05 +0900133genrule {
134 name: "test_pvmfw_devices_with_rng",
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900135 defaults: ["test_device_assignment_dts_to_dtb"],
Jaewan Kimc6e023b2023-10-12 15:11:05 +0900136 srcs: ["testdata/test_pvmfw_devices_with_rng.dts"],
137 out: ["test_pvmfw_devices_with_rng.dtb"],
138}
139
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900140genrule {
Jaewan Kima67e36a2023-11-29 16:50:23 +0900141 name: "test_pvmfw_devices_without_iommus",
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900142 defaults: ["test_device_assignment_dts_to_dtb"],
Jaewan Kima67e36a2023-11-29 16:50:23 +0900143 srcs: ["testdata/test_pvmfw_devices_without_iommus.dts"],
144 out: ["test_pvmfw_devices_without_iommus.dtb"],
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900145}
146
147genrule {
Jaewan Kim52477ae2023-11-21 21:20:52 +0900148 name: "test_pvmfw_devices_without_device",
149 defaults: ["test_device_assignment_dts_to_dtb"],
150 srcs: ["testdata/test_pvmfw_devices_without_device.dts"],
151 out: ["test_pvmfw_devices_without_device.dtb"],
152}
153
154genrule {
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900155 name: "test_pvmfw_devices_with_multiple_devices_iommus",
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900156 defaults: ["test_device_assignment_dts_to_dtb"],
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900157 srcs: ["testdata/test_pvmfw_devices_with_multiple_devices_iommus.dts"],
158 out: ["test_pvmfw_devices_with_multiple_devices_iommus.dtb"],
159}
160
161genrule {
162 name: "test_pvmfw_devices_with_iommu_sharing",
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900163 defaults: ["test_device_assignment_dts_to_dtb"],
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900164 srcs: ["testdata/test_pvmfw_devices_with_iommu_sharing.dts"],
165 out: ["test_pvmfw_devices_with_iommu_sharing.dtb"],
166}
167
168genrule {
169 name: "test_pvmfw_devices_with_iommu_id_conflict",
Jaewan Kimcb0d45d2023-11-30 15:40:12 +0900170 defaults: ["test_device_assignment_dts_to_dtb"],
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900171 srcs: ["testdata/test_pvmfw_devices_with_iommu_id_conflict.dts"],
172 out: ["test_pvmfw_devices_with_iommu_id_conflict.dtb"],
173}
174
Andrew Walbran15068b02022-03-22 15:57:34 +0000175cc_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +0100176 name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +0100177 defaults: ["vmbase_elf_defaults"],
Andrew Walbran15068b02022-03-22 15:57:34 +0000178 srcs: [
Andrew Walbran267f6c12022-03-24 11:26:36 +0000179 "idmap.S",
Andrew Walbran15068b02022-03-22 15:57:34 +0000180 ],
181 static_libs: [
182 "libpvmfw",
183 ],
Andrew Walbrana5b7af52022-07-06 15:06:20 +0000184 linker_scripts: [
185 "image.ld",
186 ":vmbase_sections",
187 ],
Jiyong Park17b8d752022-12-16 14:36:24 +0900188 // `installable: false` is inherited from vmbase_elf_defaults, and that
189 // hides this module from Make, which makes it impossible for the Make world
190 // to place the unstripped binary to the symbols directory. Marking back as
191 // installable exposes this module to the Make world again. Note that this
192 // module (pvmfw) still is NOT installed to any of the filesystem images. It
193 // is fed into pvmfw_bin and then into pvmfw_img to become a standalone
194 // partition image. This is just to package the unstripped file into the
195 // symbols zip file for debugging purpose.
196 installable: true,
Andrew Walbran15068b02022-03-22 15:57:34 +0000197}
David Brazdil05d4e072022-04-25 14:47:06 +0100198
199raw_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +0100200 name: "pvmfw_bin",
201 stem: "pvmfw.bin",
202 src: ":pvmfw",
David Brazdil05d4e072022-04-25 14:47:06 +0100203 enabled: false,
204 target: {
205 android_arm64: {
206 enabled: true,
207 },
208 },
209}
David Brazdilac216b52022-04-25 15:07:22 +0100210
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900211// Provide pvmfw.bin binary regardless of the architecture for building test.
212// Note that skipping tests on unsupported device is easy
213// while configuring server configuration to make such tests to run on working
214// devices.
215prebuilt_etc {
216 name: "pvmfw_test",
217 filename: "pvmfw_test.bin",
218 target: {
219 android_arm64: {
220 src: ":pvmfw_bin",
221 },
222 },
Alice Wang1c7e0eb2023-04-11 17:03:42 +0000223 src: ":empty_file",
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900224 installable: false,
225}
226
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100227prebuilt_etc {
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100228 name: "pvmfw_embedded_key",
229 src: ":avb_testkey_rsa4096_pub_bin",
230 installable: false,
231}
232
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100233genrule {
234 name: "pvmfw_embedded_key_rs",
235 srcs: [":pvmfw_embedded_key"],
236 out: ["lib.rs"],
237 cmd: "(" +
238 " echo '#![no_std]';" +
239 " echo '#![allow(missing_docs)]';" +
240 " echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
241 " xxd -i < $(in);" +
242 " echo '];';" +
243 ") > $(out)",
244}
245
246rust_library_rlib {
247 name: "libpvmfw_embedded_key",
Pierre-Clément Tosi4894b432023-06-27 14:02:26 +0000248 defaults: ["vmbase_rlib_defaults"],
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100249 srcs: [":pvmfw_embedded_key_rs"],
250 crate_name: "pvmfw_embedded_key",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100251}
252
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100253prebuilt_etc {
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100254 name: "pvmfw_sign_key",
255 src: ":avb_testkey_rsa4096",
256 installable: false,
257}
258
Jiyong Park9c1c8182023-05-25 15:40:11 +0900259// We need to rename *.dts into *.cpp as cc_object doesn't accept *.dts as an
260// input
Jiyong Park216793e2023-02-25 02:15:44 +0900261genrule {
Jiyong Park9c1c8182023-05-25 15:40:11 +0900262 name: "pvmfw_platform.dts.renamed",
263 srcs: ["platform.dts"],
264 out: ["out.cpp"],
265 cmd: "cp $(in) $(out)",
266 visibility: ["//visibility:private"],
267}
268
269// Then run the macro processor to replace symbols like GIC_SPI into actual
270// numbers defined in the ARM DT binding headers
271cc_object {
272 name: "pvmfw_platform.dts.preprocessed",
273 header_libs: ["arm_dt_bindings_headers"],
274 host_supported: true,
275 srcs: [":pvmfw_platform.dts.renamed"],
276 cflags: [
277 "-E",
278 "-P",
279 "-xassembler-with-cpp", // allow C preprocessor directives
Jiyong Park216793e2023-02-25 02:15:44 +0900280 ],
Jiyong Park9c1c8182023-05-25 15:40:11 +0900281 visibility: ["//visibility:private"],
282}
283
284// Compile the preprocessed dts into binary and create a rust library source
285// having the binary.
286cc_genrule {
287 name: "pvmfw_fdt_template_rs",
288 srcs: [":pvmfw_platform.dts.preprocessed"],
Jiyong Park216793e2023-02-25 02:15:44 +0900289 out: ["lib.rs"],
290 tools: ["dtc"],
Jaewan Kim96411e92023-11-13 15:54:02 +0900291 cmd: "$(location dtc) -@ -I dts -O dtb -o $(genDir)/compiled.dtbo $(in) && " +
Jiyong Park216793e2023-02-25 02:15:44 +0900292 "(" +
293 " echo '#![no_std]';" +
294 " echo '#![allow(missing_docs)]';" +
295 " echo 'pub const RAW: &[u8] = &[';" +
296 " xxd -i < $(genDir)/compiled.dtbo;" +
297 " echo '];';" +
298 ") > $(out)",
Jiyong Park9c1c8182023-05-25 15:40:11 +0900299 visibility: ["//visibility:private"],
Jiyong Park216793e2023-02-25 02:15:44 +0900300}
301
302rust_library_rlib {
303 name: "libpvmfw_fdt_template",
Pierre-Clément Tosi4894b432023-06-27 14:02:26 +0000304 defaults: ["vmbase_rlib_defaults"],
Jiyong Park216793e2023-02-25 02:15:44 +0900305 srcs: [":pvmfw_fdt_template_rs"],
306 crate_name: "pvmfw_fdt_template",
307}
308
David Brazdilac216b52022-04-25 15:07:22 +0100309bootimg {
310 name: "pvmfw_img",
311 stem: "pvmfw.img",
312 kernel_prebuilt: ":pvmfw_bin",
313 header_version: "3",
314 partition_name: "pvmfw",
315 enabled: false,
316 target: {
317 android_arm64: {
318 enabled: true,
319 },
320 },
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100321 use_avb: true,
322 avb_private_key: ":pvmfw_sign_key",
David Brazdilac216b52022-04-25 15:07:22 +0100323}