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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <4A0199B8.76EA.0078.0@novell.com>
Date:	Wed, 06 May 2009 13:07:52 +0100
From:	"Jan Beulich" <jbeulich@...ell.com>
To:	<mingo@...e.hu>, <tglx@...utronix.de>, <hpa@...or.com>
Cc:	<linux-kernel@...r.kernel.org>
Subject: [PATCH] x86-64: improve e820_search_gap()

Impact: bug fix

Blindly putting the gap close after max_pfn is in conflict with that
same memory range potentially being used by hotplugged memory.

Also, make the function static to ensure there are no other users that
could depend on the previous behavior regarding the way start_addr gets
specified.

Signed-off-by: Jan Beulich <jbeulich@...ell.com>

---
 arch/x86/include/asm/e820.h |    2 --
 arch/x86/kernel/e820.c      |   11 +++++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

--- linux-2.6.30-rc4/arch/x86/include/asm/e820.h	2009-04-30 09:42:42.000000000 +0200
+++ 2.6.30-rc4-x86_64-e820-setup-gap/arch/x86/include/asm/e820.h	2009-04-27 12:03:48.000000000 +0200
@@ -79,8 +79,6 @@ extern u64 e820_remove_range(u64 start, 
 			     int checktype);
 extern void update_e820(void);
 extern void e820_setup_gap(void);
-extern int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
-			unsigned long start_addr, unsigned long long end_addr);
 struct setup_data;
 extern void parse_e820_ext(struct setup_data *data, unsigned long pa_data);
 
--- linux-2.6.30-rc4/arch/x86/kernel/e820.c	2009-04-30 09:42:42.000000000 +0200
+++ 2.6.30-rc4-x86_64-e820-setup-gap/arch/x86/kernel/e820.c	2009-04-27 12:03:48.000000000 +0200
@@ -574,13 +574,19 @@ static void __init update_e820_saved(voi
 /*
  * Search for a gap in the e820 memory space from start_addr to end_addr.
  */
-__init int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
+static int __init
+e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
 		unsigned long start_addr, unsigned long long end_addr)
 {
 	unsigned long long last;
 	int i = e820.nr_map;
 	int found = 0;
 
+#ifdef CONFIG_X86_64
+	if (start_addr >= MAX_GAP_END)
+		last = end_addr ?: (1UL << boot_cpu_data.x86_phys_bits);
+	else
+#endif
 	last = (end_addr && end_addr < MAX_GAP_END) ? end_addr : MAX_GAP_END;
 
 	while (--i >= 0) {
@@ -626,11 +632,12 @@ __init void e820_setup_gap(void)
 
 #ifdef CONFIG_X86_64
 	if (!found) {
-		gapstart = (max_pfn << PAGE_SHIFT) + 1024*1024;
 		printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit "
 		       "address range\n"
 		       KERN_ERR "PCI: Unassigned devices with 32bit resource "
 		       "registers may break!\n");
+		found = e820_search_gap(&gapstart, &gapsize, MAX_GAP_END, 0);
+		WARN_ON(!found);
 	}
 #endif
 



--
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