blob: 103619fe786246ee2e8427e17b1cacef1d8df0e4 [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",
Andrew Walbranf44f1602023-05-30 14:59:19 +000029 "libsmccc",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000030 "libstatic_assertions",
Pierre-Clément Tosi328dfb62022-11-25 18:20:42 +000031 "libtinyvec_nostd",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000032 "libuuid_nostd",
Andrew Walbrand1d03182022-12-09 18:20:01 +000033 "libvirtio_drivers",
Andrew Walbrandd74b902022-04-14 16:12:50 +000034 "libvmbase",
Alan Stokesa0e42962023-04-14 17:59:50 +010035 "libzerocopy_nostd",
Pierre-Clément Tosi8383c542022-11-01 14:07:29 +000036 "libzeroize_nostd",
Jakob Vukalovic85a00d72023-04-20 09:51:10 +010037 "libspin_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
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090048rust_test {
49 name: "libpvmfw.bootargs.test",
50 host_supported: true,
51 // For now, only bootargs.rs is written to be conditionally compiled with std.
52 srcs: ["src/bootargs.rs"],
Nikita Ioffeda1b2732023-09-04 13:46:56 +010053 defaults: ["avf_build_flags_rust"],
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090054 test_suites: ["general-tests"],
55 test_options: {
56 unit_test: true,
57 },
58 rustlibs: [
Pierre-Clément Tosi1bf532b2023-11-13 11:06:20 +000059 "libcstr",
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090060 "libzeroize",
61 ],
62}
63
Jaewan Kimc6e023b2023-10-12 15:11:05 +090064genrule {
65 name: "test_pvmfw_devices_vm_dtbo",
66 defaults: ["dts_to_dtb"],
67 srcs: ["testdata/test_pvmfw_devices_vm_dtbo.dts"],
68 out: ["test_pvmfw_devices_vm_dtbo.dtbo"],
69}
70
71genrule {
72 name: "test_pvmfw_devices_vm_dtbo_without_symbols",
73 defaults: ["dts_to_dtb"],
74 srcs: ["testdata/test_pvmfw_devices_vm_dtbo_without_symbols.dts"],
75 out: ["test_pvmfw_devices_vm_dtbo_without_symbols.dtbo"],
76}
77
78genrule {
79 name: "test_pvmfw_devices_with_rng",
80 defaults: ["dts_to_dtb"],
81 srcs: ["testdata/test_pvmfw_devices_with_rng.dts"],
82 out: ["test_pvmfw_devices_with_rng.dtb"],
83}
84
Jaewan Kim51ccfed2023-11-08 13:51:58 +090085genrule {
86 name: "test_pvmfw_devices_with_rng_iommu",
87 defaults: ["dts_to_dtb"],
88 srcs: ["testdata/test_pvmfw_devices_with_rng_iommu.dts"],
89 out: ["test_pvmfw_devices_with_rng_iommu.dtb"],
90}
91
92genrule {
93 name: "test_pvmfw_devices_with_multiple_devices_iommus",
94 defaults: ["dts_to_dtb"],
95 srcs: ["testdata/test_pvmfw_devices_with_multiple_devices_iommus.dts"],
96 out: ["test_pvmfw_devices_with_multiple_devices_iommus.dtb"],
97}
98
99genrule {
100 name: "test_pvmfw_devices_with_iommu_sharing",
101 defaults: ["dts_to_dtb"],
102 srcs: ["testdata/test_pvmfw_devices_with_iommu_sharing.dts"],
103 out: ["test_pvmfw_devices_with_iommu_sharing.dtb"],
104}
105
106genrule {
107 name: "test_pvmfw_devices_with_iommu_id_conflict",
108 defaults: ["dts_to_dtb"],
109 srcs: ["testdata/test_pvmfw_devices_with_iommu_id_conflict.dts"],
110 out: ["test_pvmfw_devices_with_iommu_id_conflict.dtb"],
111}
112
Jaewan Kimc6e023b2023-10-12 15:11:05 +0900113rust_test {
114 name: "libpvmfw.device_assignment.test",
115 srcs: ["src/device_assignment.rs"],
116 defaults: ["avf_build_flags_rust"],
117 test_suites: ["general-tests"],
118 test_options: {
119 unit_test: true,
120 },
121 prefer_rlib: true,
122 rustlibs: [
Pierre-Clément Tosi1bf532b2023-11-13 11:06:20 +0000123 "libcstr",
Jaewan Kimc6e023b2023-10-12 15:11:05 +0900124 "liblibfdt",
125 "liblog_rust",
126 "libpvmfw_fdt_template",
127 ],
128 data: [
129 ":test_pvmfw_devices_vm_dtbo",
130 ":test_pvmfw_devices_vm_dtbo_without_symbols",
131 ":test_pvmfw_devices_with_rng",
Jaewan Kim51ccfed2023-11-08 13:51:58 +0900132 ":test_pvmfw_devices_with_rng_iommu",
133 ":test_pvmfw_devices_with_multiple_devices_iommus",
134 ":test_pvmfw_devices_with_iommu_sharing",
135 ":test_pvmfw_devices_with_iommu_id_conflict",
Jaewan Kimc6e023b2023-10-12 15:11:05 +0900136 ],
137 // To use libpvmfw_fdt_template for testing
138 enabled: false,
139 target: {
140 android_arm64: {
141 enabled: true,
142 },
143 },
144}
145
Andrew Walbran15068b02022-03-22 15:57:34 +0000146cc_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +0100147 name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +0100148 defaults: ["vmbase_elf_defaults"],
Andrew Walbran15068b02022-03-22 15:57:34 +0000149 srcs: [
Andrew Walbran267f6c12022-03-24 11:26:36 +0000150 "idmap.S",
Andrew Walbran15068b02022-03-22 15:57:34 +0000151 ],
152 static_libs: [
153 "libpvmfw",
154 ],
Andrew Walbrana5b7af52022-07-06 15:06:20 +0000155 linker_scripts: [
156 "image.ld",
157 ":vmbase_sections",
158 ],
Jiyong Park17b8d752022-12-16 14:36:24 +0900159 // `installable: false` is inherited from vmbase_elf_defaults, and that
160 // hides this module from Make, which makes it impossible for the Make world
161 // to place the unstripped binary to the symbols directory. Marking back as
162 // installable exposes this module to the Make world again. Note that this
163 // module (pvmfw) still is NOT installed to any of the filesystem images. It
164 // is fed into pvmfw_bin and then into pvmfw_img to become a standalone
165 // partition image. This is just to package the unstripped file into the
166 // symbols zip file for debugging purpose.
167 installable: true,
Andrew Walbran15068b02022-03-22 15:57:34 +0000168}
David Brazdil05d4e072022-04-25 14:47:06 +0100169
170raw_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +0100171 name: "pvmfw_bin",
172 stem: "pvmfw.bin",
173 src: ":pvmfw",
David Brazdil05d4e072022-04-25 14:47:06 +0100174 enabled: false,
175 target: {
176 android_arm64: {
177 enabled: true,
178 },
179 },
180}
David Brazdilac216b52022-04-25 15:07:22 +0100181
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900182// Provide pvmfw.bin binary regardless of the architecture for building test.
183// Note that skipping tests on unsupported device is easy
184// while configuring server configuration to make such tests to run on working
185// devices.
186prebuilt_etc {
187 name: "pvmfw_test",
188 filename: "pvmfw_test.bin",
189 target: {
190 android_arm64: {
191 src: ":pvmfw_bin",
192 },
193 },
Alice Wang1c7e0eb2023-04-11 17:03:42 +0000194 src: ":empty_file",
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900195 installable: false,
196}
197
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100198prebuilt_etc {
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100199 name: "pvmfw_embedded_key",
200 src: ":avb_testkey_rsa4096_pub_bin",
201 installable: false,
202}
203
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100204genrule {
205 name: "pvmfw_embedded_key_rs",
206 srcs: [":pvmfw_embedded_key"],
207 out: ["lib.rs"],
208 cmd: "(" +
209 " echo '#![no_std]';" +
210 " echo '#![allow(missing_docs)]';" +
211 " echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
212 " xxd -i < $(in);" +
213 " echo '];';" +
214 ") > $(out)",
215}
216
217rust_library_rlib {
218 name: "libpvmfw_embedded_key",
Pierre-Clément Tosi4894b432023-06-27 14:02:26 +0000219 defaults: ["vmbase_rlib_defaults"],
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100220 srcs: [":pvmfw_embedded_key_rs"],
221 crate_name: "pvmfw_embedded_key",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100222}
223
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100224prebuilt_etc {
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100225 name: "pvmfw_sign_key",
226 src: ":avb_testkey_rsa4096",
227 installable: false,
228}
229
Jiyong Park9c1c8182023-05-25 15:40:11 +0900230// We need to rename *.dts into *.cpp as cc_object doesn't accept *.dts as an
231// input
Jiyong Park216793e2023-02-25 02:15:44 +0900232genrule {
Jiyong Park9c1c8182023-05-25 15:40:11 +0900233 name: "pvmfw_platform.dts.renamed",
234 srcs: ["platform.dts"],
235 out: ["out.cpp"],
236 cmd: "cp $(in) $(out)",
237 visibility: ["//visibility:private"],
238}
239
240// Then run the macro processor to replace symbols like GIC_SPI into actual
241// numbers defined in the ARM DT binding headers
242cc_object {
243 name: "pvmfw_platform.dts.preprocessed",
244 header_libs: ["arm_dt_bindings_headers"],
245 host_supported: true,
246 srcs: [":pvmfw_platform.dts.renamed"],
247 cflags: [
248 "-E",
249 "-P",
250 "-xassembler-with-cpp", // allow C preprocessor directives
Jiyong Park216793e2023-02-25 02:15:44 +0900251 ],
Jiyong Park9c1c8182023-05-25 15:40:11 +0900252 visibility: ["//visibility:private"],
253}
254
255// Compile the preprocessed dts into binary and create a rust library source
256// having the binary.
257cc_genrule {
258 name: "pvmfw_fdt_template_rs",
259 srcs: [":pvmfw_platform.dts.preprocessed"],
Jiyong Park216793e2023-02-25 02:15:44 +0900260 out: ["lib.rs"],
261 tools: ["dtc"],
Jaewan Kim96411e92023-11-13 15:54:02 +0900262 cmd: "$(location dtc) -@ -I dts -O dtb -o $(genDir)/compiled.dtbo $(in) && " +
Jiyong Park216793e2023-02-25 02:15:44 +0900263 "(" +
264 " echo '#![no_std]';" +
265 " echo '#![allow(missing_docs)]';" +
266 " echo 'pub const RAW: &[u8] = &[';" +
267 " xxd -i < $(genDir)/compiled.dtbo;" +
268 " echo '];';" +
269 ") > $(out)",
Jiyong Park9c1c8182023-05-25 15:40:11 +0900270 visibility: ["//visibility:private"],
Jiyong Park216793e2023-02-25 02:15:44 +0900271}
272
273rust_library_rlib {
274 name: "libpvmfw_fdt_template",
Pierre-Clément Tosi4894b432023-06-27 14:02:26 +0000275 defaults: ["vmbase_rlib_defaults"],
Jiyong Park216793e2023-02-25 02:15:44 +0900276 srcs: [":pvmfw_fdt_template_rs"],
277 crate_name: "pvmfw_fdt_template",
278}
279
David Brazdilac216b52022-04-25 15:07:22 +0100280bootimg {
281 name: "pvmfw_img",
282 stem: "pvmfw.img",
283 kernel_prebuilt: ":pvmfw_bin",
284 header_version: "3",
285 partition_name: "pvmfw",
286 enabled: false,
287 target: {
288 android_arm64: {
289 enabled: true,
290 },
291 },
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100292 use_avb: true,
293 avb_private_key: ":pvmfw_sign_key",
David Brazdilac216b52022-04-25 15:07:22 +0100294}