lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <44CDBFC4.3030808@ed-soft.at>
Date:	Mon, 31 Jul 2006 10:31:00 +0200
From:	Edgar Hucek <hostmaster@...soft.at>
To:	LKML <linux-kernel@...r.kernel.org>,
	Linus Torvalds <torvalds@...l.org>,
	Andrew Morton <akpm@...l.org>
Subject: [PATCH 3/3] add-efi-e820-memory-mapping-on-x86.patch

This Patch add an efi e820 memory mapping.

Signed-off-by: Edgar Hucek <hostmaster@...soft.at>


diff -uNr linux-2.6.18-rc3/arch/i386/kernel/setup.c linux-2.6.18-rc3.mactel/arch/i386/kernel/setup.c
--- linux-2.6.18-rc3/arch/i386/kernel/setup.c	2006-07-31 09:24:20.000000000 +0200
+++ linux-2.6.18-rc3.mactel/arch/i386/kernel/setup.c	2006-07-31 09:26:19.000000000 +0200
@@ -414,19 +414,17 @@
 {
 	int x;
 
-	if (!efi_enabled) {
-       		x = e820.nr_map;
+	x = e820.nr_map;
 
-		if (x == E820MAX) {
-		    printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
-		    return;
-		}
-
-		e820.map[x].addr = start;
-		e820.map[x].size = size;
-		e820.map[x].type = type;
-		e820.nr_map++;
+	if (x == E820MAX) {
+	    printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
+	    return;
 	}
+
+	e820.map[x].addr = start;
+	e820.map[x].size = size;
+	e820.map[x].type = type;
+	e820.nr_map++;
 } /* add_memory_region */
 
 #define E820_DEBUG	1
@@ -1430,6 +1428,64 @@
 static void set_mca_bus(int x) { }
 #endif
 
+#ifdef CONFIG_EFI
+/*
+ * Make a e820 memory map
+ */
+void __init efi_init_e820_map(void)
+{
+	efi_memory_desc_t *md;
+	unsigned long long start = 0;
+	unsigned long long end = 0;
+	unsigned long long size = 0;
+	void *p;
+
+	e820.nr_map = 0;
+
+	for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
+		md = p;
+		switch (md->type) {
+		case EFI_ACPI_RECLAIM_MEMORY:
+			add_memory_region(md->phys_addr,
+				md->num_pages << EFI_PAGE_SHIFT, E820_ACPI);
+			break;
+		case EFI_RUNTIME_SERVICES_CODE:
+		case EFI_RUNTIME_SERVICES_DATA:
+		case EFI_RESERVED_TYPE:
+		case EFI_MEMORY_MAPPED_IO:
+		case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
+		case EFI_UNUSABLE_MEMORY:
+			add_memory_region(md->phys_addr,
+				md->num_pages << EFI_PAGE_SHIFT, E820_RESERVED);
+			break;
+		case EFI_LOADER_CODE:
+		case EFI_LOADER_DATA:
+		case EFI_BOOT_SERVICES_CODE:
+		case EFI_BOOT_SERVICES_DATA:
+		case EFI_CONVENTIONAL_MEMORY:
+			start = md->phys_addr;
+			size = md->num_pages << EFI_PAGE_SHIFT;
+			end = start + size;
+			if (start < 0x100000ULL && end > 0xA0000ULL) {
+				if (start < 0xA0000ULL)
+					add_memory_region(start,
+						0xA0000ULL-start, E820_RAM);
+				if (end <= 0x100000ULL)
+					continue;
+				start = 0x100000ULL;
+				size = end - start;
+			}
+			add_memory_region(start, size, E820_RAM);
+			break;
+		case EFI_ACPI_MEMORY_NVS:
+			add_memory_region(md->phys_addr,
+				md->num_pages << EFI_PAGE_SHIFT, E820_NVS);
+			break;
+		}
+	}
+}
+#endif
+
 /*
  * 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
@@ -1478,9 +1534,11 @@
 	rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
 #endif
 	ARCH_SETUP
-	if (efi_enabled)
+	if (efi_enabled) {
 		efi_init();
-	else {
+		efi_init_e820_map();
+		print_memory_map("BIOS-EFI");
+	} else {
 		printk(KERN_INFO "BIOS-provided physical RAM map:\n");
 		print_memory_map(machine_specific_memory_setup());
 	}


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ