doc: update mem= option's spec
Subsystems (2)
PATCH 1/2 doc: update mem= option's spec
Current mem= implementation seems buggy because specification and implementation doesn't match. Current mem= has been working for many years and it's not buggy, it works as expected. So we should update the specification.
--- Documentation/kernel-parameters.txt | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
Documentation/kernel-parameters.txt +4 -3
@@ -1471,9 +1471,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted. mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory Amount of memory to be used when the kernel is not able to see the whole system memory or for test. - [X86-32] Use together with memmap= to avoid physical - address space collisions. Without memmap= PCI devices - could be placed at addresses belonging to unused RAM. + [X86-32] Work as limiting max address. Use together + with memmap= to avoid physical address space collisions. + Without memmap= PCI devices could be placed at addresses + belonging to unused RAM. mem=nopentium [BUGS=X86-32] Disable usage of 4MB pages for kernel memory.
Signature · 1 line
1.7.1
PATCH 2/2 x86: reimplement mem boot option
Current mem boot option only can work for non efi environment. If the user specifies add_efi_memmap, it cannot work for efi environment. In the efi environment, we call e820_add_region() to add the memory map. So we can modify __e820_add_region() and the mem boot option can work for efi environment.
--- arch/x86/kernel/e820.c | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-)
arch/x86/kernel/e820.c +25 -4
@@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;#ifdef CONFIG_PCI EXPORT_SYMBOL (pci_mem_start);#endif +static u64 mem_limit = ~0ULL ;/* * This function checks if any part of the range <start,end> is mapped
@@ -119,6 +120,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,return ; } +if (start >= mem_limit) { +printk (KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n" , + (unsigned long long )start, + (unsigned long long )(start + size -1 )); +return ; + } + +if (mem_limit - start < size) { +printk (KERN_ERR "e820: ingoring [mem %#010llx-%#010llx]\n" , + (unsigned long long )mem_limit, + (unsigned long long )(start + size -1 )); + size = mem_limit - start; + } + e820x->map[x].addr = start; e820x->map[x].size = size; e820x->map[x].type = type;
@@ -809,7 +824,7 @@ static int userdef __initdata;/* "mem=nopentium" disables the 4MB page tables. */ static int __init parse_memopt (char *p) { -u64 mem_size; +char *oldp;if (!p)return -EINVAL ;
@@ -825,11 +840,11 @@ static int __init parse_memopt(char *p) } userdef =1 ; - mem_size =memparse (p, &p); + oldp = p; + mem_limit =memparse (p, &p);/* don't remove all of memory when handling "mem={invalid}" param */ -if (mem_size ==0 ) +if (mem_limit ==0 || p == oldp)return -EINVAL ; -e820_remove_range (mem_size,ULLONG_MAX - mem_size,E820_RAM ,1 );return 0 ; }
@@ -881,6 +896,12 @@ early_param("memmap", parse_memmap_opt);void __init finish_e820_parsing (void ) { +if (mem_limit != ~0ULL ) { + userdef =1 ; +e820_remove_range (mem_limit,ULLONG_MAX - mem_limit, +E820_RAM ,1 ); + } +if (userdef) {u32 nr = e820.nr_map;
Signature · 1 line
1.7.1
Re: [PATCH 2/2] x86: reimplement mem boot option
Pin......
At 06/14/2012 04:12 PM, Wen Congyang Wrote:
Quoted 81 lines
Current mem boot option only can work for non efi environment. If the user specifies
add_efi_memmap, it cannot work for efi environment. In the efi environment, we calle820_add_region()to add the memory map. So we can modify__e820_add_region()and the mem boot option can work for efi environment.Signed-off-by Wen Congyang <[email protected]>--- arch/x86/kernel/e820.c | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-)arch/x86/kernel/e820.c +25
-4@@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;#ifdef CONFIG_PCI EXPORT_SYMBOL (pci_mem_start);#endif +static u64 mem_limit = ~0ULL ;/* * This function checks if any part of the range <start,end> is mapped @@ -119,6 +120,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,return ; } +if (start >= mem_limit) { +printk (KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n" , + (unsigned long long )start, + (unsigned long long )(start + size -1 )); +return ; + } + +if (mem_limit - start < size) { +printk (KERN_ERR "e820: ingoring [mem %#010llx-%#010llx]\n" , + (unsigned long long )mem_limit, + (unsigned long long )(start + size -1 )); + size = mem_limit - start; + } + e820x->map[x].addr = start; e820x->map[x].size = size; e820x->map[x].type = type;@@ -809,7 +824,7 @@ static int userdef __initdata;/* "mem=nopentium" disables the 4MB page tables. */ static int __init parse_memopt (char *p) { -u64 mem_size; +char *oldp;if (!p)return -EINVAL ;@@ -825,11 +840,11 @@ static int __init parse_memopt(char *p) } userdef =1 ; - mem_size =memparse (p, &p); + oldp = p; + mem_limit =memparse (p, &p);/* don't remove all of memory when handling "mem={invalid}" param */ -if (mem_size ==0 ) +if (mem_limit ==0 || p == oldp)return -EINVAL ; -e820_remove_range (mem_size,ULLONG_MAX - mem_size,E820_RAM ,1 );return 0 ; }@@ -881,6 +896,12 @@ early_param("memmap", parse_memmap_opt);void __init finish_e820_parsing (void ) { +if (mem_limit != ~0ULL ) { + userdef =1 ; +e820_remove_range (mem_limit,ULLONG_MAX - mem_limit, +E820_RAM ,1 ); + } +if (userdef) {u32 nr = e820.nr_map;
Re: [PATCH 2/2] x86: reimplement mem boot option
At 06/28/2012 09:29 AM, Wen Congyang Wrote:
Quoted 1 line
Pin......
Ping again........
Quoted 90 lines
At 06/14/2012 04:12 PM, Wen Congyang Wrote:
Quoted 71 lines
Current mem boot option only can work for non efi environment. If the user specifies
add_efi_memmap, it cannot work for efi environment. In the efi environment, we calle820_add_region()to add the memory map. So we can modify__e820_add_region()and the mem boot option can work for efi environment.Signed-off-by Wen Congyang <[email protected]>--- arch/x86/kernel/e820.c | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-)arch/x86/kernel/e820.c +19
-4@@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;#ifdef CONFIG_PCI EXPORT_SYMBOL (pci_mem_start);#endif +static u64 mem_limit = ~0ULL ;/* * This function checks if any part of the range <start,end> is mapped @@ -119,6 +120,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,return ; } +if (start >= mem_limit) { +printk (KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n" , + (unsigned long long )start, + (unsigned long long )(start + size -1 )); +return ; + } + +if (mem_limit - start < size) { +printk (KERN_ERR "e820: ingoring [mem %#010llx-%#010llx]\n" , + (unsigned long long )mem_limit, + (unsigned long long )(start + size -1 )); + size = mem_limit - start; + } + e820x->map[x].addr = start; e820x->map[x].size = size; e820x->map[x].type = type;@@ -809,7 +824,7 @@ static int userdef __initdata;/* "mem=nopentium" disables the 4MB page tables. */ static int __init parse_memopt (char *p) { -u64 mem_size; +char *oldp;if (!p)return -EINVAL ;@@ -825,11 +840,11 @@ static int __init parse_memopt(char *p) } userdef =1 ; - mem_size =memparse (p, &p); + oldp = p; + mem_limit =memparse (p, &p);/* don't remove all of memory when handling "mem={invalid}" param */ -if (mem_size ==0 ) +if (mem_limit ==0 || p == oldp)return -EINVAL ; -e820_remove_range (mem_size,ULLONG_MAX - mem_size,E820_RAM ,1 );return 0 ; }@@ -881,6 +896,12 @@ early_param("memmap", parse_memmap_opt);void __init finish_e820_parsing (void )arch/x86/kernel/e820.c early_param("memmap", parse_memmap_opt); · line 907
Quoted 10 lines
arch/x86/kernel/e820.c +6
-0{ +if (mem_limit != ~0ULL ) { + userdef =1 ; +e820_remove_range (mem_limit,ULLONG_MAX - mem_limit, +E820_RAM ,1 ); + } +if (userdef) {u32 nr = e820.nr_map;--
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/
Re: [PATCH 2/2] x86: reimplement mem boot option
Quoted 4 lines · Wen Congyang
At 06/28/2012 09:29 AM, Wen Congyang Wrote:
Quoted 1 line
Pin......
Ping again........
I guess when hpa gets back from the road he'll have a look.
Thanks,
Ingo
PATCH v2 2/2 x86: reimplement mem boot option
In reply to Wen CongyangCurrent mem boot option only can work for non efi environment. If the user specifies add_efi_memmap, it cannot work for efi environment. In the efi environment, we call e820_add_region() to add the memory map. So we can modify __e820_add_region() and the mem boot option can work for efi environment.
--- arch/x86/kernel/e820.c | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-)
arch/x86/kernel/e820.c +25 -4
@@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;#ifdef CONFIG_PCI EXPORT_SYMBOL (pci_mem_start);#endif +static u64 mem_limit = ~0ULL ;/* * This function checks if any part of the range <start,end> is mapped
@@ -119,6 +120,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,return ; } +if (start >= mem_limit) { +printk (KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n" , + (unsigned long long )start, + (unsigned long long )(start + size -1 )); +return ; + } + +if (mem_limit - start < size) { +printk (KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n" , + (unsigned long long )mem_limit, + (unsigned long long )(start + size -1 )); + size = mem_limit - start; + } + e820x->map[x].addr = start; e820x->map[x].size = size; e820x->map[x].type = type;
@@ -809,7 +824,7 @@ static int userdef __initdata;/* "mem=nopentium" disables the 4MB page tables. */ static int __init parse_memopt (char *p) { -u64 mem_size; +char *oldp;if (!p)return -EINVAL ;
@@ -825,11 +840,11 @@ static int __init parse_memopt(char *p) } userdef =1 ; - mem_size =memparse (p, &p); + oldp = p; + mem_limit =memparse (p, &p);/* don't remove all of memory when handling "mem={invalid}" param */ -if (mem_size ==0 ) +if (mem_limit ==0 || p == oldp)return -EINVAL ; -e820_remove_range (mem_size,ULLONG_MAX - mem_size,E820_RAM ,1 );return 0 ; }
@@ -881,6 +896,12 @@ early_param("memmap", parse_memmap_opt);void __init finish_e820_parsing (void ) { +if (mem_limit != ~0ULL ) { + userdef =1 ; +e820_remove_range (mem_limit,ULLONG_MAX - mem_limit, +E820_RAM ,1 ); + } +if (userdef) {u32 nr = e820.nr_map;
Signature · 1 line
1.7.1
Re: [PATCH v2 2/2] x86: reimplement mem boot option
Hi, H. Peter Anvin
Do you have time to review this patch?
Thanks
Wen Congyang
At 08/21/2012 04:11 PM, Wen Congyang Wrote:
Quoted 81 lines
Current mem boot option only can work for non efi environment. If the user specifies
add_efi_memmap, it cannot work for efi environment. In the efi environment, we calle820_add_region()to add the memory map. So we can modify__e820_add_region()and the mem boot option can work for efi environment.Signed-off-by Wen Congyang <[email protected]>--- arch/x86/kernel/e820.c | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-)arch/x86/kernel/e820.c +25
-4@@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;#ifdef CONFIG_PCI EXPORT_SYMBOL (pci_mem_start);#endif +static u64 mem_limit = ~0ULL ;/* * This function checks if any part of the range <start,end> is mapped @@ -119,6 +120,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,return ; } +if (start >= mem_limit) { +printk (KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n" , + (unsigned long long )start, + (unsigned long long )(start + size -1 )); +return ; + } + +if (mem_limit - start < size) { +printk (KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n" , + (unsigned long long )mem_limit, + (unsigned long long )(start + size -1 )); + size = mem_limit - start; + } + e820x->map[x].addr = start; e820x->map[x].size = size; e820x->map[x].type = type;@@ -809,7 +824,7 @@ static int userdef __initdata;/* "mem=nopentium" disables the 4MB page tables. */ static int __init parse_memopt (char *p) { -u64 mem_size; +char *oldp;if (!p)return -EINVAL ;@@ -825,11 +840,11 @@ static int __init parse_memopt(char *p) } userdef =1 ; - mem_size =memparse (p, &p); + oldp = p; + mem_limit =memparse (p, &p);/* don't remove all of memory when handling "mem={invalid}" param */ -if (mem_size ==0 ) +if (mem_limit ==0 || p == oldp)return -EINVAL ; -e820_remove_range (mem_size,ULLONG_MAX - mem_size,E820_RAM ,1 );return 0 ; }@@ -881,6 +896,12 @@ early_param("memmap", parse_memmap_opt);void __init finish_e820_parsing (void ) { +if (mem_limit != ~0ULL ) { + userdef =1 ; +e820_remove_range (mem_limit,ULLONG_MAX - mem_limit, +E820_RAM ,1 ); + } +if (userdef) {u32 nr = e820.nr_map;
Quoted 18 lines · Wen Congyang
Current mem= implementation seems buggy because specification and implementation doesn't match. Current mem= has been working for many years and it's not buggy, it works as expected. So we should update the specification.
Signed-off-by Wen Congyang <[email protected]>--- Documentation/kernel-parameters.txt | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)Documentation/kernel-parameters.txt +0
-0@@ -1471,9 +1471,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted. mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory Amount of memory to be used when the kernel is not able to see the whole system memory or for test.
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 1480
Quoted 10 lines
Documentation/kernel-parameters.txt +4
-3- [X86-32] Use together with memmap= to avoid physical - address space collisions. Without memmap= PCI devices - could be placed at addresses belonging to unused RAM. + [X86-32] Work as limiting max address. Use together + with memmap= to avoid physical address space collisions. + Without memmap= PCI devices could be placed at addresses + belonging to unused RAM. mem=nopentium [BUGS=X86-32] Disable usage of 4MB pages for kernel memory.
I have no objection to this but can't confirm it's true or not without an awful lot more digging through the code I don't have time for right now. (All the x86-32 machines I've used just had the 640k->1m hole and the rest was contiguous memory, so the behavior would be the same either way...)
Rob
Signature · 2 lines
GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code. Either it's "mere aggregation", or a license violation. Pick one.