Re: [tip:x86/urgent] x86, efi: Delete efi_ioremap() and fix CONFIG_X86_32 oops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 22, 2012 at 7:32 PM, H. Peter Anvin <hpa@xxxxxxxxx> wrote:
> On 02/22/2012 06:20 PM, Yinghai Lu wrote:
>>
>> Why is MAXMEM used here?
>>
>> EFI reserved area could be above 4G?
>>
>> if that is the case, you will map all mmio hole below 4g.
>>
>
> OK, dropping this patch for now, at least from -urgent.
>
> We really need to restrict the memory types we map, at least without
> ioremap() called on them.  In theory, on x86-64, we could have a
> dedicated "1:1" address for each physical address, but there is no good
> reason we should ever map memory types other than RAM, ACPI and EFI by
> default -- with the possible exception of the low 1 MiB legacy area.

please check attach patch for tip/efi branch.

Thanks

       Yinghai
Subject: [PATCH] x86, efi: use e820_end_pfn_efi with low_pfn and max_pfn
From: Yinghai Lu <yinghai@xxxxxxxxxx>

So avoid to map mmio below 4g, if system have EFI range above 4g.

Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>

---
 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<<PAGE_SHIFT);
+						     end_pfn<<PAGE_SHIFT);
 		/* can we preseve max_low_pfn ?*/
 		max_low_pfn = max_pfn;
 	}

[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux