Skip to contentSkip to conversation

Fix wrong use of memparse in efi.c

PATCH In review Zou Nan hai 2 participants 3 messages Feb 7, 2006 EFI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix wrong use of memparse in efi.c

The check of (end != cp) after memparse in efi.c looks wrong to me. The result is that we can't use mem= and max_addr= kernel parameter at the same time.

The following patch removed the check just like other arches do.

arch/ia64/kernel/efi.c +3 -11
diff -Nraup a/arch/ia64/kernel/efi.c d/arch/ia64/kernel/efi.c
@@ -384,24 +384,16 @@ efi_init (void)
 	efi_config_table_t *config_tables;
 	efi_char16_t *c16;
 	u64 efi_desc_size;
-	char *cp, *end, vendor[100] = "unknown";
+	char *cp, vendor[100] = "unknown";
 	extern char saved_command_line[];
 	int i;
 
 	/* it's too early to be able to use the standard kernel command line support... */
 	for (cp = saved_command_line; *cp; ) {
 		if (memcmp(cp, "mem=", 4) = 0) {
-			cp += 4;
-			mem_limit = memparse(cp, &end);
-			if (end != cp)
-				break;
-			cp = end;
+			mem_limit = memparse(cp + 4, &cp);
 		} else if (memcmp(cp, "max_addr=", 9) = 0) {
-			cp += 9;
-			max_addr = GRANULEROUNDDOWN(memparse(cp, &end));
-			if (end != cp)
-				break;
-			cp = end;
+			max_addr = GRANULEROUNDDOWN(memparse(cp + 9, &cp));
 		} else {
 			while (*cp != ' ' && *cp)
 				++cp;
#1 lore raw

Zou Nan hai wrote on Monday, February 06, 2006 7:36 PM

Quoted 3 lines

The check of (end != cp) after memparse in efi.c looks wrong to me. The result is that we can't use mem= and max_addr= kernel parameter at the same time.

Why do you want to use both parameters at the same time? mem= limits maximum logical memory size while max_addr= limits maximum physical address used in the system. It sounds wired, but people are creative...

- Ken

#2 lore raw
In reply to Zou Nan hai

Actually I found this when add support to min_addr= support,
min_addr= + max_addr= is useful for a crashdumping kernel to limit its memory range.

Also I think use mem= and max_addr= at the same time could be useful when testing some configurations.

Zou Nan hai

Quoted 17 lines

-----Original Message-----
From: Chen, Kenneth W [mailto:[email protected]]
Sent: 2006Äê2ÔÂ7ÈÕ 14:33
To: Zou, Nanhai; [email protected]
Cc: Luck, Tony
Subject: RE: [PATCH]Fix wrong use of memparse in efi.c

Zou Nan hai wrote on Monday, February 06, 2006 7:36 PM

Quoted 3 lines

The check of (end != cp) after memparse in efi.c looks wrong to me. The result is that we can't use mem= and max_addr= kernel parameter at the same time.

Why do you want to use both parameters at the same time? mem= limits maximum logical memory size while max_addr= limits maximum physical address used in the system. It sounds wired, but people are creative...

- Ken