提交 3f535208 编写于 作者: Y Yang Qiang 提交者: guzitao

sw64: dtb: check address validity with physical address

Sunway inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5GE5X

--------------------------------

Due to sw64 ABI sepecification, a large kernel image may override
the data structures of UEFI BIOS.

To solve this problem, we have expanded UEFI BIOS to 1GB to make
sure that runtime service code and data structures reside in the
high address below 1GB which may be beyond ktext map. So fix it.
Signed-off-by: NYang Qiang <yangqiang@wxiat.com>
Signed-off-by: NGu Zitao <guzitao@wxiat.com>
上级 c1bf5440
...@@ -560,22 +560,20 @@ static void __init setup_machine_fdt(void) ...@@ -560,22 +560,20 @@ static void __init setup_machine_fdt(void)
#ifdef CONFIG_USE_OF #ifdef CONFIG_USE_OF
void *dt_virt; void *dt_virt;
const char *name; const char *name;
unsigned long phys_addr;
/* Give a chance to select kernel builtin DTB firstly */ /* Give a chance to select kernel builtin DTB firstly */
if (IS_ENABLED(CONFIG_SW64_BUILTIN_DTB)) if (IS_ENABLED(CONFIG_SW64_BUILTIN_DTB))
dt_virt = (void *)__dtb_start; dt_virt = (void *)__dtb_start;
else { else {
dt_virt = (void *)sunway_boot_params->dtb_start; dt_virt = (void *)sunway_boot_params->dtb_start;
if (dt_virt < (void *)__bss_stop) { if (virt_to_phys(dt_virt) < virt_to_phys(__bss_stop)) {
pr_emerg("BUG: DTB has been corrupted by kernel image!\n"); pr_emerg("BUG: DTB has been corrupted by kernel image!\n");
while (true) while (true)
cpu_relax(); cpu_relax();
} }
} }
phys_addr = __phys_addr((unsigned long)dt_virt); if (!phys_addr_valid(virt_to_phys(dt_virt)) ||
if (!phys_addr_valid(phys_addr) ||
!early_init_dt_scan(dt_virt)) { !early_init_dt_scan(dt_virt)) {
pr_crit("\n" pr_crit("\n"
"Error: invalid device tree blob at virtual address %px\n" "Error: invalid device tree blob at virtual address %px\n"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册