public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.19-rc5-git2]  EFI: mapping memory region of runtime services when using memmap kernel parameter
@ 2006-11-13  9:43 Myaskouvskey, Artiom
  2006-11-13 14:11 ` Andi Kleen
  0 siblings, 1 reply; 4+ messages in thread
From: Myaskouvskey, Artiom @ 2006-11-13  9:43 UTC (permalink / raw)
  To: davej, hpa; +Cc: linux-kernel, Satt, Shai

From: Artiom Myaskouvskey <artiom.myaskouvskey@intel.com>
 
When using memmap kernel parameter in EFI boot we should also map memory
regions of runtime services to enable their mapping later.

Signed-off-by: Artiom Myaskouvskey <artiom.myaskouvskey@intel.com>
---

diff -uprN linux-2.6.19-rc5-git2.orig/arch/i386/kernel/setup.c
linux-2.6.19-rc5-git2/arch/i386/kernel/setup.c
--- linux-2.6.19-rc5-git2.orig/arch/i386/kernel/setup.c	2006-11-13
11:15:17.000000000 +0200
+++ linux-2.6.19-rc5-git2/arch/i386/kernel/setup.c	2006-11-13
11:15:42.000000000 +0200
@@ -346,28 +346,44 @@ static void __init probe_roms(void)
 	}
 }
 
+extern int is_available_memory(efi_memory_desc_t * md);
+
 static void __init limit_regions(unsigned long long size)
 {
 	unsigned long long current_addr = 0;
-	int i;
+	int i , j;
 
-	if (efi_enabled) {
-		efi_memory_desc_t *md;
-		void *p;
+	if (efi_enabled) {		
+		efi_memory_desc_t *md, *next_md = 0;
+		void *p, *p1;
 
-		for (p = memmap.map, i = 0; p < memmap.map_end;
+		for (p = memmap.map, i = 0,j = 0, p1 = memmap.map; p <
memmap.map_end;
 			p += memmap.desc_size, i++) {
 			md = p;
+			next_md = p1;
 			current_addr = md->phys_addr + (md->num_pages <<
12);
-			if (md->type == EFI_CONVENTIONAL_MEMORY) {
-				if (current_addr >= size) {
-					md->num_pages -=
-						(((current_addr-size) +
PAGE_SIZE-1) >> PAGE_SHIFT);
-					memmap.nr_map = i + 1;
-					return;
+			if (is_available_memory(md)) {
+				if (md->phys_addr >= size) continue;
+				memcpy(next_md, md, memmap.desc_size);

+                                if (current_addr >= size) {
+					next_md->num_pages -=
(((current_addr-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
 				}
+				p1 += memmap.desc_size;
+				next_md = p1;
+				j++;
 			}
-		}
+			else if ((md->attribute & EFI_MEMORY_RUNTIME) ==
EFI_MEMORY_RUNTIME) {
+				/* In order to make runtime services
available we have to include runtime 
+				 * memory regions in memory map */
+				memcpy(next_md, md, memmap.desc_size);
+				p1 += memmap.desc_size;
+				next_md = p1;
+				j++;
+			}		
+		}
+		memmap.nr_map = j;
+		memmap.map_end = memmap.map + (memmap.nr_map *
memmap.desc_size);
+                return;
 	}
 	for (i = 0; i < e820.nr_map; i++) {
 		current_addr = e820.map[i].addr + e820.map[i].size;

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

* [PATCH 2.6.19-rc5-git2]  EFI: mapping memory region of runtime services when using memmap kernel parameter
@ 2006-11-13 11:08 Myaskouvskey, Artiom
  2006-11-13 16:59 ` Randy Dunlap
  0 siblings, 1 reply; 4+ messages in thread
From: Myaskouvskey, Artiom @ 2006-11-13 11:08 UTC (permalink / raw)
  To: davej@codemonkey.org.uk, hpa@zytor.com
  Cc: linux-kernel@vger.kernel.org, Satt, Shai

From: Artiom Myaskouvskey <artiom.myaskouvskey@intel.com>
 
When using memmap kernel parameter in EFI boot we should also add to memory map 
memory regions of runtime services to enable their mapping later.

Signed-off-by: Artiom Myaskouvskey <artiom.myaskouvskey@intel.com>
---

diff -uprN linux-2.6.19-rc5-git2.orig/arch/i386/kernel/setup.c linux-2.6.19-rc5-git2/arch/i386/kernel/setup.c
--- linux-2.6.19-rc5-git2.orig/arch/i386/kernel/setup.c	2006-11-13 11:15:17.000000000 +0200
+++ linux-2.6.19-rc5-git2/arch/i386/kernel/setup.c	2006-11-13 11:15:42.000000000 +0200
@@ -346,28 +346,44 @@ static void __init probe_roms(void)
 	}
 }
 
+extern int is_available_memory(efi_memory_desc_t * md);
+
 static void __init limit_regions(unsigned long long size)
 {
 	unsigned long long current_addr = 0;
-	int i;
+	int i , j;
 
-	if (efi_enabled) {
-		efi_memory_desc_t *md;
-		void *p;
+	if (efi_enabled) {		
+		efi_memory_desc_t *md, *next_md = 0;
+		void *p, *p1;
 
-		for (p = memmap.map, i = 0; p < memmap.map_end;
+		for (p = memmap.map, i = 0,j = 0, p1 = memmap.map; p < memmap.map_end;
 			p += memmap.desc_size, i++) {
 			md = p;
+			next_md = p1;
 			current_addr = md->phys_addr + (md->num_pages << 12);
-			if (md->type == EFI_CONVENTIONAL_MEMORY) {
-				if (current_addr >= size) {
-					md->num_pages -=
-						(((current_addr-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
-					memmap.nr_map = i + 1;
-					return;
+			if (is_available_memory(md)) {
+				if (md->phys_addr >= size) continue;
+				memcpy(next_md, md, memmap.desc_size);				
+                                if (current_addr >= size) {
+					next_md->num_pages -= (((current_addr-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
 				}
+				p1 += memmap.desc_size;
+				next_md = p1;
+				j++;
 			}
-		}
+			else if ((md->attribute & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {
+				/* In order to make runtime services available we have to include runtime 
+				 * memory regions in memory map */
+				memcpy(next_md, md, memmap.desc_size);
+				p1 += memmap.desc_size;
+				next_md = p1;
+				j++;
+			}		
+		}
+		memmap.nr_map = j;
+		memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size);
+                return;
 	}
 	for (i = 0; i < e820.nr_map; i++) {
 		current_addr = e820.map[i].addr + e820.map[i].size;

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

* Re: [PATCH 2.6.19-rc5-git2]  EFI: mapping memory region of runtime services when using memmap kernel parameter
  2006-11-13  9:43 [PATCH 2.6.19-rc5-git2] EFI: mapping memory region of runtime services when using memmap kernel parameter Myaskouvskey, Artiom
@ 2006-11-13 14:11 ` Andi Kleen
  0 siblings, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2006-11-13 14:11 UTC (permalink / raw)
  To: Myaskouvskey, Artiom; +Cc: linux-kernel, Satt, Shai

"Myaskouvskey, Artiom" <artiom.myaskouvskey@intel.com> writes:
>  
> +extern int is_available_memory(efi_memory_desc_t * md);

Never put externs into .c files

The whole approach of including the run time services into
the memory map seems bogus. How about ioremap()ing (or fixmaping) them
on demand instead?

-Andi

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

* Re: [PATCH 2.6.19-rc5-git2]  EFI: mapping memory region of runtime services when using memmap kernel parameter
  2006-11-13 11:08 Myaskouvskey, Artiom
@ 2006-11-13 16:59 ` Randy Dunlap
  0 siblings, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2006-11-13 16:59 UTC (permalink / raw)
  To: Myaskouvskey, Artiom; +Cc: davej, hpa, linux-kernel, shai.satt

On Mon, 13 Nov 2006 13:08:50 +0200 Myaskouvskey, Artiom wrote:

> From: Artiom Myaskouvskey <artiom.myaskouvskey@intel.com>
>  
> When using memmap kernel parameter in EFI boot we should also add to memory map 
> memory regions of runtime services to enable their mapping later.
> 
> Signed-off-by: Artiom Myaskouvskey <artiom.myaskouvskey@intel.com>
> ---

Much better (no line wrap), but still has problems with
a.  extern not in a header file
b.  lines > 80 columns
c.  trailing whitespace (in both EFI patches)


(sorry if you receive duplicates, my original was dropped or blocked;
oh, the email address strings were odd)
(third/final attempt)

> diff -uprN linux-2.6.19-rc5-git2.orig/arch/i386/kernel/setup.c linux-2.6.19-rc5-git2/arch/i386/kernel/setup.c
> --- linux-2.6.19-rc5-git2.orig/arch/i386/kernel/setup.c	2006-11-13 11:15:17.000000000 +0200
> +++ linux-2.6.19-rc5-git2/arch/i386/kernel/setup.c	2006-11-13 11:15:42.000000000 +0200
> @@ -346,28 +346,44 @@ static void __init probe_roms(void)
>  	}
>  }
>  
> +extern int is_available_memory(efi_memory_desc_t * md);
> +
>  static void __init limit_regions(unsigned long long size)
>  {
>  	unsigned long long current_addr = 0;
> -	int i;
> +	int i , j;
>  
> -	if (efi_enabled) {
> -		efi_memory_desc_t *md;
> -		void *p;
> +	if (efi_enabled) {		
> +		efi_memory_desc_t *md, *next_md = 0;
> +		void *p, *p1;
>  
> -		for (p = memmap.map, i = 0; p < memmap.map_end;
> +		for (p = memmap.map, i = 0,j = 0, p1 = memmap.map; p < memmap.map_end;
>  			p += memmap.desc_size, i++) {
>  			md = p;
> +			next_md = p1;
>  			current_addr = md->phys_addr + (md->num_pages << 12);
> -			if (md->type == EFI_CONVENTIONAL_MEMORY) {
> -				if (current_addr >= size) {
> -					md->num_pages -=
> -						(((current_addr-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
> -					memmap.nr_map = i + 1;
> -					return;
> +			if (is_available_memory(md)) {
> +				if (md->phys_addr >= size) continue;
> +				memcpy(next_md, md, memmap.desc_size);				
> +                                if (current_addr >= size) {
> +					next_md->num_pages -= (((current_addr-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
>  				}
> +				p1 += memmap.desc_size;
> +				next_md = p1;
> +				j++;
>  			}
> -		}
> +			else if ((md->attribute & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {
> +				/* In order to make runtime services available we have to include runtime 
> +				 * memory regions in memory map */
> +				memcpy(next_md, md, memmap.desc_size);
> +				p1 += memmap.desc_size;
> +				next_md = p1;
> +				j++;
> +			}		
> +		}
> +		memmap.nr_map = j;
> +		memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size);
> +                return;
>  	}
>  	for (i = 0; i < e820.nr_map; i++) {
>  		current_addr = e820.map[i].addr + e820.map[i].size;
> -

---
~Randy

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

end of thread, other threads:[~2006-11-13 16:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-13  9:43 [PATCH 2.6.19-rc5-git2] EFI: mapping memory region of runtime services when using memmap kernel parameter Myaskouvskey, Artiom
2006-11-13 14:11 ` Andi Kleen
  -- strict thread matches above, loose matches on Subject: below --
2006-11-13 11:08 Myaskouvskey, Artiom
2006-11-13 16:59 ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox