Skip to content

Commit a3a9df9

Browse files
WangYuliopsiff
authored andcommitted
IEE: arm64: mmu: Improve IEE data segment mapping logic
Enhance the kernel data segment mapping logic in the map_kernel() function to properly handle IEE initialization data segments. Key improvements: *Add size validation for IEE data segments by calculating iee_data_size *Only create separate mappings when IEE init data is actually present *Add informative log message when no IEE init data exists *Fix code structure and conditional logic for better readability and correctness This change ensures that the kernel data mapping strategy is appropriately chosen based on the actual presence of IEE initialization data, avoiding unnecessary complexity when IEE data segments are empty while maintaining proper functionality when they are present. Tested-by: Jun Zhan <[email protected]> Co-developed-by: Jun Zhan <[email protected]> Signed-off-by: Jun Zhan <[email protected]> Signed-off-by: WangYuli <[email protected]>
1 parent a458534 commit a3a9df9

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

arch/arm64/mm/mmu.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,10 +791,18 @@ static void __init map_kernel(pgd_t *pgdp)
791791
&vmlinux_initdata, 0, VM_NO_GUARD);
792792
#ifdef CONFIG_IEE
793793
if (haoc_enabled) {
794-
map_kernel_segment(pgdp, _data, iee_init_data_end, PAGE_KERNEL,
795-
&vmlinux_iee_init_data, NO_CONT_MAPPINGS | NO_BLOCK_MAPPINGS, VM_NO_GUARD);
796-
map_kernel_segment(pgdp, iee_init_data_end, _end, PAGE_KERNEL, &vmlinux_data, 0, 0);
797-
} else
794+
unsigned long iee_data_size = (unsigned long)iee_init_data_end - (unsigned long)_data;
795+
796+
if (iee_data_size > 0) {
797+
// 只有当IEE数据段非空时才创建分离的映射
798+
map_kernel_segment(pgdp, _data, iee_init_data_end, PAGE_KERNEL,
799+
&vmlinux_iee_init_data, NO_CONT_MAPPINGS | NO_BLOCK_MAPPINGS, VM_NO_GUARD);
800+
map_kernel_segment(pgdp, iee_init_data_end, _end, PAGE_KERNEL, &vmlinux_data, 0, 0);
801+
} else {
802+
pr_info("IEE: No IEE init data, using standard data mapping\n");
803+
map_kernel_segment(pgdp, _data, _end, PAGE_KERNEL, &vmlinux_data, 0, 0);
804+
}
805+
} else
798806
map_kernel_segment(pgdp, _data, _end, PAGE_KERNEL, &vmlinux_data, 0, 0);
799807
#else
800808
map_kernel_segment(pgdp, _data, _end, PAGE_KERNEL, &vmlinux_data, 0, 0);

0 commit comments

Comments
 (0)