Skip to contentSkip to conversation

Increase number of e820 entries hard limit from 32 to 128

PATCH In review Venkatesh Pallipadi 5 participants 7 messages Apr 23, 2005 – Jun 6, 2005 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Increase number of e820 entries hard limit from 32 to 128

The specifications that talk about E820 map doesn't have an upper limit on the number of E820 entries. But, today's kernel has a hard limit of 32. With increase in memory size, we are seeing the number of E820 entries reaching close to 32. Patch below bumps the number upto 128.

Patch does it for both i386 and x86-64.

Side-effect:
bss increases by ~ 2K and init.data increases by ~7.5K on all systems, due to increase in size of static arrays.

Documentation/i386/zero-page.txt renamed from Documentation/i386/zero-page.txt.orig +3 -3
diff -purN  linux-2.6.11/Documentation/i386/zero-page.txt.orig linux-2.6.11/Documentation/i386/zero-page.txt
@@ -79,6 +79,6 @@ Offset	Type		Description
 0x22c   unsigned long	ramdisk_max
 0x230   16 bytes 	trampoline
 0x290 - 0x2cf		EDD_MBR_SIG_BUFFER (edd.S)
-0x2d0 - 0x600		E820MAP
-0x600 - 0x7ff		EDDBUF (edd.S) for disk signature read sector
-0x600 - 0x7eb		EDDBUF (edd.S) for edd data
+0x2d0 - 0xd00		E820MAP
+0xd00 - 0xeff		EDDBUF (edd.S) for disk signature read sector
+0xd00 - 0xeeb		EDDBUF (edd.S) for edd data
include/linux/edd.h renamed from include/linux/edd.h.orig +1 -1
diff -purN  linux-2.6.11/include/linux/edd.h.orig linux-2.6.11/include/linux/edd.h
@@ -32,7 +32,7 @@
 
 #define EDDNR 0x1e9		/* addr of number of edd_info structs at EDDBUF
 				   in boot_params - treat this as 1 byte  */
-#define EDDBUF	0x600		/* addr of edd_info structs in boot_params */
+#define EDDBUF	0xd00		/* addr of edd_info structs in boot_params */
 #define EDDMAXNR 6		/* number of edd_info structs starting at EDDBUF  */
 #define EDDEXTSIZE 8		/* change these if you muck with the structures */
 #define EDDPARMSIZE 74
include/asm-i386/e820.h renamed from include/asm-i386/e820.h.orig +1 -1
diff -purN  linux-2.6.11/include/asm-i386/e820.h.orig linux-2.6.11/include/asm-i386/e820.h
@@ -13,7 +13,7 @@
 #define __E820_HEADER
 
 #define E820MAP	0x2d0		/* our map */
-#define E820MAX	32		/* number of entries in E820MAP */
+#define E820MAX	128		/* number of entries in E820MAP */
 #define E820NR	0x1e8		/* # entries in E820MAP */
 
 #define E820_RAM	1
include/asm-i386/setup.h renamed from include/asm-i386/setup.h.orig +1 -1
diff -purN  linux-2.6.11/include/asm-i386/setup.h.orig linux-2.6.11/include/asm-i386/setup.h
@@ -16,7 +16,7 @@
 #define MAXMEM_PFN	PFN_DOWN(MAXMEM)
 #define MAX_NONPAE_PFN	(1 << 20)
 
-#define PARAM_SIZE 2048
+#define PARAM_SIZE 4096
 #define COMMAND_LINE_SIZE 256
 
 #define OLD_CL_MAGIC_ADDR	0x90020
arch/i386/boot/setup.S renamed from arch/i386/boot/setup.S.orig +3 -3
diff -purN  linux-2.6.11/arch/i386/boot/setup.S.orig linux-2.6.11/arch/i386/boot/setup.S
@@ -164,7 +164,7 @@ ramdisk_max:	.long (-__PAGE_OFFSET-(512 
 trampoline:	call	start_of_setup
 		.align 16
 					# The offset at this point is 0x240
-		.space	(0x7ff-0x240+1) # E820 & EDD space (ending at 0x7ff)
+		.space	(0xeff-0x240+1) # E820 & EDD space (ending at 0xeff)
 # End of setup header #####################################################
 
 start_of_setup:
@@ -333,9 +333,9 @@ jmpe820:
 	# sizeof(e820rec).
 	#
 good820:
-	movb	(E820NR), %al			# up to 32 entries
+	movb	(E820NR), %al			# up to 128 entries
 	cmpb	$E820MAX, %al
-	jnl	bail820
+	jae	bail820
 
 	incb	(E820NR)
 	movw	%di, %ax
include/asm-x86_64/e820.h renamed from include/asm-x86_64/e820.h.orig +1 -1
diff -purN  linux-2.6.11/include/asm-x86_64/e820.h.orig linux-2.6.11/include/asm-x86_64/e820.h
@@ -14,7 +14,7 @@
 #include <linux/mmzone.h>
 
 #define E820MAP	0x2d0		/* our map */
-#define E820MAX	32		/* number of entries in E820MAP */
+#define E820MAX	128		/* number of entries in E820MAP */
 #define E820NR	0x1e8		/* # entries in E820MAP */
 
 #define E820_RAM	1
include/asm-x86_64/bootsetup.h renamed from include/asm-x86_64/bootsetup.h.orig +2 -1
diff -purN  linux-2.6.11/include/asm-x86_64/bootsetup.h.orig linux-2.6.11/include/asm-x86_64/bootsetup.h
@@ -2,7 +2,8 @@
 #ifndef _X86_64_BOOTSETUP_H
 #define _X86_64_BOOTSETUP_H 1
 
-extern char x86_boot_params[2048];
+#define BOOT_PARAM_SIZE		4096
+extern char x86_boot_params[BOOT_PARAM_SIZE];
 
 /*
  * This is set up by the setup-routine at boot-time
arch/x86_64/boot/setup.S renamed from arch/x86_64/boot/setup.S.orig +3 -3
diff -purN  linux-2.6.11/arch/x86_64/boot/setup.S.orig linux-2.6.11/arch/x86_64/boot/setup.S
@@ -160,7 +160,7 @@ ramdisk_max:	.long 0xffffffff
 trampoline:	call	start_of_setup
 		.align 16
 					# The offset at this point is 0x240
-		.space  (0x7ff-0x240+1)	# E820 & EDD space (ending at 0x7ff)
+		.space  (0xeff-0x240+1)	# E820 & EDD space (ending at 0xeff)
 # End of setup header #####################################################
 
 start_of_setup:
@@ -412,9 +412,9 @@ jmpe820:
 	# sizeof(e820rec).
 	#
 good820:
-	movb	(E820NR), %al			# up to 32 entries
+	movb	(E820NR), %al			# up to 128 entries
 	cmpb	$E820MAX, %al
-	jnl	bail820
+	jae	bail820
 
 	incb	(E820NR)
 	movw	%di, %ax
arch/x86_64/kernel/setup64.c renamed from arch/x86_64/kernel/setup64.c.orig +2 -1
diff -purN  linux-2.6.11/arch/x86_64/kernel/setup64.c.orig linux-2.6.11/arch/x86_64/kernel/setup64.c
@@ -12,6 +12,7 @@
 #include <linux/string.h>
 #include <linux/bootmem.h>
 #include <linux/bitops.h>
+#include <asm/bootsetup.h>
 #include <asm/pda.h>
 #include <asm/pgtable.h>
 #include <asm/processor.h>
@@ -26,7 +27,7 @@
 #include <asm/mman.h>
 #include <asm/numa.h>
 
-char x86_boot_params[2048] __initdata = {0,};
+char x86_boot_params[BOOT_PARAM_SIZE] __initdata = {0,};
 
 cpumask_t cpu_initialized __initdata = CPU_MASK_NONE;
 
arch/x86_64/kernel/head64.c renamed from arch/x86_64/kernel/head64.c.orig +1 -3
diff -purN  linux-2.6.11/arch/x86_64/kernel/head64.c.orig linux-2.6.11/arch/x86_64/kernel/head64.c
@@ -29,8 +29,6 @@ static void __init clear_bss(void)
 	       (unsigned long) __bss_end - (unsigned long) __bss_start);
 }
 
-extern char x86_boot_params[2048];
-
 #define NEW_CL_POINTER		0x228	/* Relative to real mode data */
 #define OLD_CL_MAGIC_ADDR	0x90020
 #define OLD_CL_MAGIC            0xA33F
@@ -44,7 +42,7 @@ static void __init copy_bootdata(char *r
 	int new_data;
 	char * command_line;
 
-	memcpy(x86_boot_params, real_mode_data, 2048); 
+	memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE); 
 	new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
 	if (!new_data) {
 		if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
#1 lore raw

This is a very good idea.

Jeff

Quoted 183 lines · Venkatesh Pallipadi

The specifications that talk about E820 map doesn't have an upper limit on the number of E820 entries. But, today's kernel has a hard limit of 32. With increase in memory size, we are seeing the number of E820 entries reaching close to 32. Patch below bumps the number upto 128.

Patch does it for both i386 and x86-64.

Side-effect: bss increases by ~ 2K and init.data increases by ~7.5K on all systems, due to increase in size of static arrays.

diff -purN linux-2.6.11/Documentation/i386/zero-page.txt.orig linux-2.6.11/Documentation/i386/zero-page.txt

Documentation/i386/zero-page.txt renamed from Documentation/i386/zero-page.txt.orig +0 -0
@@ -79,6 +79,6 @@ Offset	Type		Description

0x22c unsigned long ramdisk_max
0x230 16 bytes trampoline
0x290 - 0x2cf EDD_MBR_SIG_BUFFER (edd.S)
-0x2d0 - 0x600 E820MAP
-0x600 - 0x7ff EDDBUF (edd.S) for disk signature read sector
-0x600 - 0x7eb EDDBUF (edd.S) for edd data
+0x2d0 - 0xd00 E820MAP
+0xd00 - 0xeff EDDBUF (edd.S) for disk signature read sector
+0xd00 - 0xeeb EDDBUF (edd.S) for edd data
diff -purN linux-2.6.11/include/linux/edd.h.orig linux-2.6.11/include/linux/edd.h

include/linux/edd.h renamed from include/linux/edd.h.orig +1 -1
@@ -32,7 +32,7 @@
 
 #define EDDNR 0x1e9		/* addr of number of edd_info structs at EDDBUF
 				   in boot_params - treat this as 1 byte  */
-#define EDDBUF	0x600		/* addr of edd_info structs in boot_params */
+#define EDDBUF	0xd00		/* addr of edd_info structs in boot_params */
 #define EDDMAXNR 6		/* number of edd_info structs starting at EDDBUF  */
 #define EDDEXTSIZE 8		/* change these if you muck with the structures */
 #define EDDPARMSIZE 74

diff -purN linux-2.6.11/include/asm-i386/e820.h.orig linux-2.6.11/include/asm-i386/e820.h

include/asm-i386/e820.h renamed from include/asm-i386/e820.h.orig +1 -1
@@ -13,7 +13,7 @@
 #define __E820_HEADER
 
 #define E820MAP	0x2d0		/* our map */
-#define E820MAX	32		/* number of entries in E820MAP */
+#define E820MAX	128		/* number of entries in E820MAP */
 #define E820NR	0x1e8		/* # entries in E820MAP */
 
 #define E820_RAM	1

diff -purN linux-2.6.11/include/asm-i386/setup.h.orig linux-2.6.11/include/asm-i386/setup.h

include/asm-i386/setup.h renamed from include/asm-i386/setup.h.orig +1 -1
@@ -16,7 +16,7 @@
 #define MAXMEM_PFN	PFN_DOWN(MAXMEM)
 #define MAX_NONPAE_PFN	(1 << 20)
 
-#define PARAM_SIZE 2048
+#define PARAM_SIZE 4096
 #define COMMAND_LINE_SIZE 256
 
 #define OLD_CL_MAGIC_ADDR	0x90020

diff -purN linux-2.6.11/arch/i386/boot/setup.S.orig linux-2.6.11/arch/i386/boot/setup.S

arch/i386/boot/setup.S renamed from arch/i386/boot/setup.S.orig +0 -0
@@ -164,7 +164,7 @@ ramdisk_max:	.long (-__PAGE_OFFSET-(512 

trampoline: call start_of_setup

		.align 16
					# The offset at this point is 0x240
arch/i386/boot/setup.S renamed from arch/i386/boot/setup.S.orig +1 -1
-		.space	(0x7ff-0x240+1) # E820 & EDD space (ending at 0x7ff)
+		.space	(0xeff-0x240+1) # E820 & EDD space (ending at 0xeff)

# End of setup header #####################################################

start_of_setup:

arch/i386/boot/setup.S renamed from arch/i386/boot/setup.S.orig +0 -0
@@ -333,9 +333,9 @@ jmpe820:
 	# sizeof(e820rec).
 	#

good820:

arch/i386/boot/setup.S renamed from arch/i386/boot/setup.S.orig +1 -1
-	movb	(E820NR), %al			# up to 32 entries
+	movb	(E820NR), %al			# up to 128 entries
	cmpb	$E820MAX, %al
arch/i386/boot/setup.S renamed from arch/i386/boot/setup.S.orig +1 -1
-	jnl	bail820
+	jae	bail820
	incb	(E820NR)
	movw	%di, %ax

diff -purN linux-2.6.11/include/asm-x86_64/e820.h.orig linux-2.6.11/include/asm-x86_64/e820.h

include/asm-x86_64/e820.h renamed from include/asm-x86_64/e820.h.orig +1 -1
@@ -14,7 +14,7 @@
 #include <linux/mmzone.h>
 
 #define E820MAP	0x2d0		/* our map */
-#define E820MAX	32		/* number of entries in E820MAP */
+#define E820MAX	128		/* number of entries in E820MAP */
 #define E820NR	0x1e8		/* # entries in E820MAP */
 
 #define E820_RAM	1

diff -purN linux-2.6.11/include/asm-x86_64/bootsetup.h.orig linux-2.6.11/include/asm-x86_64/bootsetup.h

include/asm-x86_64/bootsetup.h renamed from include/asm-x86_64/bootsetup.h.orig +2 -1
@@ -2,7 +2,8 @@
 #ifndef _X86_64_BOOTSETUP_H
 #define _X86_64_BOOTSETUP_H 1
 
-extern char x86_boot_params[2048];
+#define BOOT_PARAM_SIZE		4096
+extern char x86_boot_params[BOOT_PARAM_SIZE];
 
 /*
 * This is set up by the setup-routine at boot-time

diff -purN linux-2.6.11/arch/x86_64/boot/setup.S.orig linux-2.6.11/arch/x86_64/boot/setup.S

arch/x86_64/boot/setup.S renamed from arch/x86_64/boot/setup.S.orig +0 -0
@@ -160,7 +160,7 @@ ramdisk_max:	.long 0xffffffff

trampoline: call start_of_setup

		.align 16
					# The offset at this point is 0x240
arch/x86_64/boot/setup.S renamed from arch/x86_64/boot/setup.S.orig +1 -1
-		.space  (0x7ff-0x240+1)	# E820 & EDD space (ending at 0x7ff)
+		.space  (0xeff-0x240+1)	# E820 & EDD space (ending at 0xeff)

# End of setup header #####################################################

start_of_setup:

arch/x86_64/boot/setup.S renamed from arch/x86_64/boot/setup.S.orig +0 -0
@@ -412,9 +412,9 @@ jmpe820:
 	# sizeof(e820rec).
 	#

good820:

arch/x86_64/boot/setup.S renamed from arch/x86_64/boot/setup.S.orig +1 -1
-	movb	(E820NR), %al			# up to 32 entries
+	movb	(E820NR), %al			# up to 128 entries
	cmpb	$E820MAX, %al
arch/x86_64/boot/setup.S renamed from arch/x86_64/boot/setup.S.orig +1 -1
-	jnl	bail820
+	jae	bail820
	incb	(E820NR)
	movw	%di, %ax

diff -purN linux-2.6.11/arch/x86_64/kernel/setup64.c.orig linux-2.6.11/arch/x86_64/kernel/setup64.c

arch/x86_64/kernel/setup64.c renamed from arch/x86_64/kernel/setup64.c.orig +2 -1
@@ -12,6 +12,7 @@
 #include <linux/string.h>
 #include <linux/bootmem.h>
 #include <linux/bitops.h>
+#include <asm/bootsetup.h>
 #include <asm/pda.h>
 #include <asm/pgtable.h>
 #include <asm/processor.h>
@@ -26,7 +27,7 @@
 #include <asm/mman.h>
 #include <asm/numa.h>
 
-char x86_boot_params[2048] __initdata = {0,};
+char x86_boot_params[BOOT_PARAM_SIZE] __initdata = {0,};
 
 cpumask_t cpu_initialized __initdata = CPU_MASK_NONE;
 

diff -purN linux-2.6.11/arch/x86_64/kernel/head64.c.orig linux-2.6.11/arch/x86_64/kernel/head64.c

arch/x86_64/kernel/head64.c renamed from arch/x86_64/kernel/head64.c.orig +1 -4
@@ -29,8 +29,6 @@ static void __init clear_bss(void)
 	       (unsigned long) __bss_end - (unsigned long) __bss_start);
 }
 
-extern char x86_boot_params[2048];
-
 #define NEW_CL_POINTER		0x228	/* Relative to real mode data */
 #define OLD_CL_MAGIC_ADDR	0x90020
 #define OLD_CL_MAGIC            0xA33F
@@ -44,7 +42,7 @@ static void __init copy_bootdata(char *r
 	int new_data;
 	char * command_line;
 
-	memcpy(x86_boot_params, real_mode_data, 2048); 
+	memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE); 
 	new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
 	if (!new_data) {
 		if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
-

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

#2 lore raw
In reply to Venkatesh Pallipadi
Quoted 5 lines · Venkatesh Pallipadi

The specifications that talk about E820 map doesn't have an upper limit on the number of E820 entries. But, today's kernel has a hard limit of 32. With increase in memory size, we are seeing the number of E820 entries reaching close to 32. Patch below bumps the number upto 128.

Hmm. Anything that changes setup.S tends to have bootloader dependencies. I worry whether this one does too..

Linus

#3 lore raw
Quoted 9 lines · Linus Torvalds
Quoted 4 lines · Venkatesh Pallipadi

The specifications that talk about E820 map doesn't have an upper limit on the number of E820 entries. But, today's kernel has a hard limit of 32. With increase in memory size, we are seeing the number of E820 entries reaching close to 32. Patch below bumps the number upto 128.

Hmm. Anything that changes setup.S tends to have bootloader dependencies. I worry whether this one does too..

The setup.S change in this patch should be OK. As it is adding to the existing zero-page and keeping it within one page. I tested it on systems with grub, adding some dummy E820 entries and it worked fine.

However, there is another place that needs to be changed. Boot loaders also calls E820 while booting directly with vmlinux (instead of usual bzImage - which is handled by this patch) and that needs to change to incorporate more E820 entries. But, there we may need more changes, to the boot protocol version and the like. On a side note, looking at the grub source, it seems to have a limit of 50 entries today, which doesn't agree with current 32 entry limit in the kernel. Not sure why grub has this different limit though.

Thanks,
Venki

#4 lore raw
Quoted 7 lines · Venkatesh Pallipadi
Quoted 6 lines · Linus Torvalds
Quoted 4 lines · Venkatesh Pallipadi

The specifications that talk about E820 map doesn't have an upper limit on the number of E820 entries. But, today's kernel has a hard limit of 32. With increase in memory size, we are seeing the number of E820 entries reaching close to 32. Patch below bumps the number upto 128.

Quoted 7 lines
Quoted 3 lines

Hmm. Anything that changes setup.S tends to have bootloader dependencies. I worry whether this one does too..

The setup.S change in this patch should be OK. As it is adding to the existing zero-page and keeping it within one page. I tested it on systems with grub, adding some dummy E820 entries and it worked fine.

The last time I tried to extend the zero page (with a longer command line) it broke lilo on systems with EDID support and CONFIG_EDID enabled. Make sure you test that case.

-Andi

#5 lore raw
Quoted 12 lines · Andi Kleen
Quoted 11 lines · Venkatesh Pallipadi
Quoted 9 lines · Linus Torvalds
Quoted 4 lines · Venkatesh Pallipadi

The specifications that talk about E820 map doesn't have an upper limit on the number of E820 entries. But, today's kernel has a hard limit of 32. With increase in memory size, we are seeing the number of E820 entries reaching close to 32. Patch below bumps the number upto 128.

Hmm. Anything that changes setup.S tends to have bootloader dependencies. I worry whether this one does too..

Quoted 8 lines
Quoted 3 lines

The setup.S change in this patch should be OK. As it is adding to the existing zero-page and keeping it within one page. I tested it on systems with grub, adding some dummy E820 entries and it worked fine.

The last time I tried to extend the zero page (with a longer command line) it broke lilo on systems with EDID support and CONFIG_EDID enabled. Make sure you test that case.

Tested this patch with some more configuration and I did not see any breakage.
- LILO with EDID enabled
- pxeboot

And in the current zero-page, EDID info is at a lower address (before E820MAP). So, there should not be any issues with EDID info. Only field (other than E820) that is changing in zero page is EDDBUF (that comes after E820MAP). The patch changes the reference to EDDBUF inside kernel to new position in zero page. And I don't see EDDBUF being used by boot loader anywhere. So, we should be OK with that change.

Thanks,
Venki

#6 lore raw

Boot problems & zero page Was: [PATCH] Increase number of e820 entries hard limit from 32 to 128

In reply to Andi Kleen
Quoted 3 lines · Andi Kleen <ak <at> suse.de> writes:

The last time I tried to extend the zero page (with a longer command line) it broke lilo on systems with EDID support and CONFIG_EDID enabled. Make sure you test that case.

Hi!

I (and other) had problems, that may be related to this. Can you look into it ?

What happened was :
linux boot had a delay of 10..30..90..infinite seconds, depending on command line length and certain disk related BIOS settings.
GRUB was the loader. The delay went away after disabling CONFIG_EDD. It was also "fixed" by downgrading the BIOS version.

It would be really cool if you could inject some wisdom in the issue ;-)

For details, see the LKML archives :

"EDD code causes long boot delay"
<http://marc.theaimsgroup.com/?t=108788699100001&r=1&w=2>

"[PATCH 2.6.9-rc3-mm2] EDD: use EXTENDED READ command, add CONFIG_EDD_SKIP_MBR"
<http://lkml.org/lkml/2004/10/4/239>

"[PATCH 2.6] EDD: add edd=off and edd=skipmbr options"
<http://lkml.org/lkml/2004/11/23/293>

Kind regards,
David Balazic