Subject: [PATCH] x86, efi: use e820_end_pfn_efi with low_pfn and max_pfn From: Yinghai Lu So avoid to map mmio below 4g, if system have EFI range above 4g. Signed-off-by: Yinghai Lu --- arch/x86/kernel/setup.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) Index: linux-2.6/arch/x86/kernel/setup.c =================================================================== --- linux-2.6.orig/arch/x86/kernel/setup.c +++ linux-2.6/arch/x86/kernel/setup.c @@ -681,6 +681,27 @@ static int __init parse_reservelow(char early_param("reservelow", parse_reservelow); +static unsigned long __init e820_end_pfn_efi(unsigned long end_pfn, + unsigned long limit_pfn) +{ +#ifdef CONFIG_X86_64 + /* + * There may be regions after the last E820_RAM region that we + * want to include in the kernel direct mapping because their + * contents are needed at runtime. + */ + if (efi_enabled) { + unsigned long efi_end; + + efi_end = e820_end_pfn(limit_pfn, E820_RESERVED_EFI); + if (efi_end > end_pfn) + end_pfn = efi_end; + } +#endif + + return end_pfn; +} + /* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -934,30 +955,15 @@ void __init setup_arch(char **cmdline_p) init_gbpages(); /* max_pfn_mapped is updated here */ - end_pfn = max_low_pfn; - -#ifdef CONFIG_X86_64 - /* - * There may be regions after the last E820_RAM region that we - * want to include in the kernel direct mapping because their - * contents are needed at runtime. - */ - if (efi_enabled) { - unsigned long efi_end; - - efi_end = e820_end_pfn(MAXMEM>>PAGE_SHIFT, E820_RESERVED_EFI); - if (efi_end > end_pfn) - end_pfn = efi_end; - } -#endif - + end_pfn = e820_end_pfn_efi(max_low_pfn, 1UL<<(32-PAGE_SHIFT)); max_low_pfn_mapped = init_memory_mapping(0, end_pfn << PAGE_SHIFT); max_pfn_mapped = max_low_pfn_mapped; #ifdef CONFIG_X86_64 if (max_pfn > max_low_pfn) { + end_pfn = e820_end_pfn_efi(max_pfn, MAXMEM>>PAGE_SHIFT); max_pfn_mapped = init_memory_mapping(1UL<<32, - max_pfn<