All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86-64: improve e820_search_gap()
@ 2009-05-06 12:07 Jan Beulich
  2009-05-08  4:59 ` H. Peter Anvin
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Beulich @ 2009-05-06 12:07 UTC (permalink / raw)
  To: mingo, tglx, hpa; +Cc: linux-kernel

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@novell.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
 




^ permalink raw reply	[flat|nested] 16+ messages in thread
* [PATCH] x86-64: improve e820_search_gap()
@ 2009-03-12 10:45 Jan Beulich
  2009-03-12 11:02 ` Ingo Molnar
  2009-03-13 17:37 ` Jeremy Fitzhardinge
  0 siblings, 2 replies; 16+ messages in thread
From: Jan Beulich @ 2009-03-12 10:45 UTC (permalink / raw)
  To: mingo, tglx, hpa; +Cc: jeremy.fitzhardinge, linux-kernel

Blindly putting the gap close after max_pfn might be fine for native
(though even there I'm uncertain regarding memory hotplug), but will
certainly present a problem on Xen. And properly searching for a gap
above 4Gb shouldn't hurt native.

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@novell.com>
Cc: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

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

--- linux-2.6.29-rc7/arch/x86/include/asm/e820.h	2009-03-11 17:52:10.000000000 +0100
+++ 2.6.29-rc7-x86_64-e820-setup-gap-64bit/arch/x86/include/asm/e820.h	2009-03-06 11:25:35.000000000 +0100
@@ -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.29-rc7/arch/x86/kernel/e820.c	2009-03-11 17:52:10.000000000 +0100
+++ 2.6.29-rc7-x86_64-e820-setup-gap-64bit/arch/x86/kernel/e820.c	2009-03-06 11:24:34.000000000 +0100
@@ -533,13 +533,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) {
@@ -585,11 +591,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);
+		BUG_ON(!found);
 	}
 #endif
 




^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2009-05-10 17:57 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-06 12:07 [PATCH] x86-64: improve e820_search_gap() Jan Beulich
2009-05-08  4:59 ` H. Peter Anvin
2009-05-08  6:40   ` Jan Beulich
2009-05-08 16:52     ` H. Peter Anvin
2009-05-08 19:22     ` Andi Kleen
2009-05-08 20:15       ` H. Peter Anvin
2009-05-08 20:53         ` Andi Kleen
2009-05-08 20:52           ` H. Peter Anvin
2009-05-09 10:00             ` Andi Kleen
2009-05-10  6:43               ` H. Peter Anvin
2009-05-10 15:18                 ` Andi Kleen
2009-05-10 17:56                   ` H. Peter Anvin
  -- strict thread matches above, loose matches on Subject: below --
2009-03-12 10:45 Jan Beulich
2009-03-12 11:02 ` Ingo Molnar
2009-03-12 11:31   ` Jan Beulich
2009-03-13 17:37 ` Jeremy Fitzhardinge

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.