|
8 | 8 |
|
9 | 9 | #define pr_fmt(fmt) "OF: fdt: " fmt |
10 | 10 |
|
| 11 | +#include <linux/acpi.h> |
11 | 12 | #include <linux/crash_dump.h> |
12 | 13 | #include <linux/crc32.h> |
13 | 14 | #include <linux/kernel.h> |
|
32 | 33 |
|
33 | 34 | #include "of_private.h" |
34 | 35 |
|
| 36 | +/* |
| 37 | + * __dtb_empty_root_begin[] and __dtb_empty_root_end[] magically created by |
| 38 | + * cmd_dt_S_dtb in scripts/Makefile.lib |
| 39 | + */ |
| 40 | +extern uint8_t __dtb_empty_root_begin[]; |
| 41 | +extern uint8_t __dtb_empty_root_end[]; |
| 42 | + |
35 | 43 | /* |
36 | 44 | * of_fdt_limit_memory - limit the number of regions in the /memory node |
37 | 45 | * @limit: maximum entries |
@@ -1343,7 +1351,29 @@ static void *__init copy_device_tree(void *fdt) |
1343 | 1351 | */ |
1344 | 1352 | void __init unflatten_device_tree(void) |
1345 | 1353 | { |
1346 | | - __unflatten_device_tree(initial_boot_params, NULL, &of_root, |
| 1354 | + void *fdt = initial_boot_params; |
| 1355 | + |
| 1356 | + /* Don't use the bootloader provided DTB if ACPI is enabled */ |
| 1357 | + if (!acpi_disabled) |
| 1358 | + fdt = NULL; |
| 1359 | + |
| 1360 | + /* |
| 1361 | + * Populate an empty root node when ACPI is enabled or bootloader |
| 1362 | + * doesn't provide one. |
| 1363 | + */ |
| 1364 | + if (!fdt) { |
| 1365 | + fdt = (void *) __dtb_empty_root_begin; |
| 1366 | + /* fdt_totalsize() will be used for copy size */ |
| 1367 | + if (fdt_totalsize(fdt) > |
| 1368 | + __dtb_empty_root_end - __dtb_empty_root_begin) { |
| 1369 | + pr_err("invalid size in dtb_empty_root\n"); |
| 1370 | + return; |
| 1371 | + } |
| 1372 | + of_fdt_crc32 = crc32_be(~0, fdt, fdt_totalsize(fdt)); |
| 1373 | + fdt = copy_device_tree(fdt); |
| 1374 | + } |
| 1375 | + |
| 1376 | + __unflatten_device_tree(fdt, NULL, &of_root, |
1347 | 1377 | early_init_dt_alloc_memory_arch, false); |
1348 | 1378 |
|
1349 | 1379 | /* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */ |
|
0 commit comments