blob: 4df260f77fcf2f1f634a8708800bfbb711e2de78 [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",
Alice Wangcb9d2f92023-02-06 10:29:00 +000019 "libdiced_open_dice_nostd",
Andrew Walbran730375d2022-12-21 14:04:34 +000020 "libfdtpci",
Alice Wang0bdc3f62023-03-15 10:46:12 +000021 "libhyp",
Pierre-Clément Tosia0934c12022-11-25 20:54:11 +000022 "liblibfdt",
Pierre-Clément Tosi37105a62022-10-18 12:21:48 +010023 "liblog_rust_nostd",
Andrew Walbranb398fc82023-01-24 14:45:46 +000024 "libonce_cell_nostd",
Pierre-Clément Tosi2d652982023-01-09 19:30:17 +000025 "libpvmfw_avb_nostd",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +010026 "libpvmfw_embedded_key",
Jiyong Park216793e2023-02-25 02:15:44 +090027 "libpvmfw_fdt_template",
Andrew Walbranf44f1602023-05-30 14:59:19 +000028 "libsmccc",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000029 "libstatic_assertions",
Pierre-Clément Tosi328dfb62022-11-25 18:20:42 +000030 "libtinyvec_nostd",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000031 "libuuid_nostd",
Andrew Walbrand1d03182022-12-09 18:20:01 +000032 "libvirtio_drivers",
Andrew Walbrandd74b902022-04-14 16:12:50 +000033 "libvmbase",
Alan Stokesa0e42962023-04-14 17:59:50 +010034 "libzerocopy_nostd",
Pierre-Clément Tosi8383c542022-11-01 14:07:29 +000035 "libzeroize_nostd",
Jakob Vukalovic85a00d72023-04-20 09:51:10 +010036 "libspin_nostd",
Andrew Walbranf2594882022-03-15 17:32:53 +000037 ],
Andrew Walbran68a8c162022-03-07 15:38:42 +000038}
Andrew Walbran15068b02022-03-22 15:57:34 +000039
Alice Wang1c7e0eb2023-04-11 17:03:42 +000040// Generates an empty file.
41genrule {
42 name: "empty_file",
43 out: ["empty_file"],
44 cmd: "touch $(out)",
45}
46
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090047rust_test {
48 name: "libpvmfw.bootargs.test",
49 host_supported: true,
50 // For now, only bootargs.rs is written to be conditionally compiled with std.
51 srcs: ["src/bootargs.rs"],
Nikita Ioffeda1b2732023-09-04 13:46:56 +010052 defaults: ["avf_build_flags_rust"],
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090053 test_suites: ["general-tests"],
54 test_options: {
55 unit_test: true,
56 },
57 rustlibs: [
58 "libzeroize",
59 ],
60}
61
Jaewan Kimc6e023b2023-10-12 15:11:05 +090062genrule {
63 name: "test_pvmfw_devices_vm_dtbo",
64 defaults: ["dts_to_dtb"],
65 srcs: ["testdata/test_pvmfw_devices_vm_dtbo.dts"],
66 out: ["test_pvmfw_devices_vm_dtbo.dtbo"],
67}
68
69genrule {
70 name: "test_pvmfw_devices_vm_dtbo_without_symbols",
71 defaults: ["dts_to_dtb"],
72 srcs: ["testdata/test_pvmfw_devices_vm_dtbo_without_symbols.dts"],
73 out: ["test_pvmfw_devices_vm_dtbo_without_symbols.dtbo"],
74}
75
76genrule {
77 name: "test_pvmfw_devices_with_rng",
78 defaults: ["dts_to_dtb"],
79 srcs: ["testdata/test_pvmfw_devices_with_rng.dts"],
80 out: ["test_pvmfw_devices_with_rng.dtb"],
81}
82
Jaewan Kim51ccfed2023-11-08 13:51:58 +090083genrule {
84 name: "test_pvmfw_devices_with_rng_iommu",
85 defaults: ["dts_to_dtb"],
86 srcs: ["testdata/test_pvmfw_devices_with_rng_iommu.dts"],
87 out: ["test_pvmfw_devices_with_rng_iommu.dtb"],
88}
89
90genrule {
91 name: "test_pvmfw_devices_with_multiple_devices_iommus",
92 defaults: ["dts_to_dtb"],
93 srcs: ["testdata/test_pvmfw_devices_with_multiple_devices_iommus.dts"],
94 out: ["test_pvmfw_devices_with_multiple_devices_iommus.dtb"],
95}
96
97genrule {
98 name: "test_pvmfw_devices_with_iommu_sharing",
99 defaults: ["dts_to_dtb"],
100 srcs: ["testdata/test_pvmfw_devices_with_iommu_sharing.dts"],
101 out: ["test_pvmfw_devices_with_iommu_sharing.dtb"],
102}
103
104genrule {
105 name: "test_pvmfw_devices_with_iommu_id_conflict",
106 defaults: ["dts_to_dtb"],
107 srcs: ["testdata/test_pvmfw_devices_with_iommu_id_conflict.dts"],
108 out: ["test_pvmfw_devices_with_iommu_id_conflict.dtb"],
109}
110
Jaewan Kimc6e023b2023-10-12 15:11:05 +0900111rust_test {
112 name: "libpvmfw.device_assignment.test",
113 srcs: ["src/device_assignment.rs"],
114 defaults: ["avf_build_flags_rust"],
115 test_suites: ["general-tests"],
116 test_options: {
117 unit_test: true,
118 },
119 prefer_rlib: true,
120 rustlibs: [
121 "liblibfdt",
122 "liblog_rust",
123 "libpvmfw_fdt_template",
124 ],
125 data: [
126 ":test_pvmfw_devices_vm_dtbo",
127 ":test_pvmfw_devices_vm_dtbo_without_symbols",
128 ":test_pvmfw_devices_with_rng",
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900129 ":test_pvmfw_devices_with_rng_iommu",
130 ":test_pvmfw_devices_with_multiple_devices_iommus",
131 ":test_pvmfw_devices_with_iommu_sharing",
132 ":test_pvmfw_devices_with_iommu_id_conflict",
Jaewan Kimc6e023b2023-10-12 15:11:05 +0900133 ],
134 // To use libpvmfw_fdt_template for testing
135 enabled: false,
136 target: {
137 android_arm64: {
138 enabled: true,
139 },
140 },
141}
142
Andrew Walbran15068b02022-03-22 15:57:34 +0000143cc_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +0100144 name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +0100145 defaults: ["vmbase_elf_defaults"],
Andrew Walbran15068b02022-03-22 15:57:34 +0000146 srcs: [
Andrew Walbran267f6c12022-03-24 11:26:36 +0000147 "idmap.S",
Andrew Walbran15068b02022-03-22 15:57:34 +0000148 ],
149 static_libs: [
150 "libpvmfw",
151 ],
Andrew Walbrana5b7af52022-07-06 15:06:20 +0000152 linker_scripts: [
153 "image.ld",
154 ":vmbase_sections",
155 ],
Jiyong Park17b8d752022-12-16 14:36:24 +0900156 // `installable: false` is inherited from vmbase_elf_defaults, and that
157 // hides this module from Make, which makes it impossible for the Make world
158 // to place the unstripped binary to the symbols directory. Marking back as
159 // installable exposes this module to the Make world again. Note that this
160 // module (pvmfw) still is NOT installed to any of the filesystem images. It
161 // is fed into pvmfw_bin and then into pvmfw_img to become a standalone
162 // partition image. This is just to package the unstripped file into the
163 // symbols zip file for debugging purpose.
164 installable: true,
Andrew Walbran15068b02022-03-22 15:57:34 +0000165}
David Brazdil05d4e072022-04-25 14:47:06 +0100166
167raw_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +0100168 name: "pvmfw_bin",
169 stem: "pvmfw.bin",
170 src: ":pvmfw",
David Brazdil05d4e072022-04-25 14:47:06 +0100171 enabled: false,
172 target: {
173 android_arm64: {
174 enabled: true,
175 },
176 },
177}
David Brazdilac216b52022-04-25 15:07:22 +0100178
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900179// Provide pvmfw.bin binary regardless of the architecture for building test.
180// Note that skipping tests on unsupported device is easy
181// while configuring server configuration to make such tests to run on working
182// devices.
183prebuilt_etc {
184 name: "pvmfw_test",
185 filename: "pvmfw_test.bin",
186 target: {
187 android_arm64: {
188 src: ":pvmfw_bin",
189 },
190 },
Alice Wang1c7e0eb2023-04-11 17:03:42 +0000191 src: ":empty_file",
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900192 installable: false,
193}
194
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100195prebuilt_etc {
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100196 name: "pvmfw_embedded_key",
197 src: ":avb_testkey_rsa4096_pub_bin",
198 installable: false,
199}
200
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100201genrule {
202 name: "pvmfw_embedded_key_rs",
203 srcs: [":pvmfw_embedded_key"],
204 out: ["lib.rs"],
205 cmd: "(" +
206 " echo '#![no_std]';" +
207 " echo '#![allow(missing_docs)]';" +
208 " echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
209 " xxd -i < $(in);" +
210 " echo '];';" +
211 ") > $(out)",
212}
213
214rust_library_rlib {
215 name: "libpvmfw_embedded_key",
Pierre-Clément Tosi4894b432023-06-27 14:02:26 +0000216 defaults: ["vmbase_rlib_defaults"],
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100217 srcs: [":pvmfw_embedded_key_rs"],
218 crate_name: "pvmfw_embedded_key",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100219}
220
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100221prebuilt_etc {
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100222 name: "pvmfw_sign_key",
223 src: ":avb_testkey_rsa4096",
224 installable: false,
225}
226
Jiyong Park9c1c8182023-05-25 15:40:11 +0900227// We need to rename *.dts into *.cpp as cc_object doesn't accept *.dts as an
228// input
Jiyong Park216793e2023-02-25 02:15:44 +0900229genrule {
Jiyong Park9c1c8182023-05-25 15:40:11 +0900230 name: "pvmfw_platform.dts.renamed",
231 srcs: ["platform.dts"],
232 out: ["out.cpp"],
233 cmd: "cp $(in) $(out)",
234 visibility: ["//visibility:private"],
235}
236
237// Then run the macro processor to replace symbols like GIC_SPI into actual
238// numbers defined in the ARM DT binding headers
239cc_object {
240 name: "pvmfw_platform.dts.preprocessed",
241 header_libs: ["arm_dt_bindings_headers"],
242 host_supported: true,
243 srcs: [":pvmfw_platform.dts.renamed"],
244 cflags: [
245 "-E",
246 "-P",
247 "-xassembler-with-cpp", // allow C preprocessor directives
Jiyong Park216793e2023-02-25 02:15:44 +0900248 ],
Jiyong Park9c1c8182023-05-25 15:40:11 +0900249 visibility: ["//visibility:private"],
250}
251
252// Compile the preprocessed dts into binary and create a rust library source
253// having the binary.
254cc_genrule {
255 name: "pvmfw_fdt_template_rs",
256 srcs: [":pvmfw_platform.dts.preprocessed"],
Jiyong Park216793e2023-02-25 02:15:44 +0900257 out: ["lib.rs"],
258 tools: ["dtc"],
Jaewan Kim96411e92023-11-13 15:54:02 +0900259 cmd: "$(location dtc) -@ -I dts -O dtb -o $(genDir)/compiled.dtbo $(in) && " +
Jiyong Park216793e2023-02-25 02:15:44 +0900260 "(" +
261 " echo '#![no_std]';" +
262 " echo '#![allow(missing_docs)]';" +
263 " echo 'pub const RAW: &[u8] = &[';" +
264 " xxd -i < $(genDir)/compiled.dtbo;" +
265 " echo '];';" +
266 ") > $(out)",
Jiyong Park9c1c8182023-05-25 15:40:11 +0900267 visibility: ["//visibility:private"],
Jiyong Park216793e2023-02-25 02:15:44 +0900268}
269
270rust_library_rlib {
271 name: "libpvmfw_fdt_template",
Pierre-Clément Tosi4894b432023-06-27 14:02:26 +0000272 defaults: ["vmbase_rlib_defaults"],
Jiyong Park216793e2023-02-25 02:15:44 +0900273 srcs: [":pvmfw_fdt_template_rs"],
274 crate_name: "pvmfw_fdt_template",
275}
276
David Brazdilac216b52022-04-25 15:07:22 +0100277bootimg {
278 name: "pvmfw_img",
279 stem: "pvmfw.img",
280 kernel_prebuilt: ":pvmfw_bin",
281 header_version: "3",
282 partition_name: "pvmfw",
283 enabled: false,
284 target: {
285 android_arm64: {
286 enabled: true,
287 },
288 },
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100289 use_avb: true,
290 avb_private_key: ":pvmfw_sign_key",
David Brazdilac216b52022-04-25 15:07:22 +0100291}