aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/e820.c
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2009-03-13 01:36:01 -0400
committerIngo Molnar <mingo@elte.hu>2009-03-14 07:20:07 -0400
commit78a8b35bc7abf8b8333d6f625e08c0f7cc1c3742 (patch)
treec9fac06f56ada92aab36e36f190a41e2dd7900af /arch/x86/kernel/e820.c
parent773e673de27297d07d852e7e9bfd1a695cae1da2 (diff)
x86: make e820_update_range() handle small range update
Impact: enhance e820 code to handle more cases Try to handle new range which could be covered by one entry. Signed-off-by: Yinghai Lu <yinghai@kernel.org> Cc: jbeulich@novell.com LKML-Reference: <49B9F0C1.10402@kernel.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/e820.c')
-rw-r--r--arch/x86/kernel/e820.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 95b81c18b6bc..0c34ff49ff4d 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -427,6 +427,7 @@ static u64 __init __e820_update_range(struct e820map *e820x, u64 start,
427 u64 size, unsigned old_type, 427 u64 size, unsigned old_type,
428 unsigned new_type) 428 unsigned new_type)
429{ 429{
430 u64 end;
430 unsigned int i; 431 unsigned int i;
431 u64 real_updated_size = 0; 432 u64 real_updated_size = 0;
432 433
@@ -435,21 +436,35 @@ static u64 __init __e820_update_range(struct e820map *e820x, u64 start,
435 if (size > (ULLONG_MAX - start)) 436 if (size > (ULLONG_MAX - start))
436 size = ULLONG_MAX - start; 437 size = ULLONG_MAX - start;
437 438
439 end = start + size;
438 for (i = 0; i < e820x->nr_map; i++) { 440 for (i = 0; i < e820x->nr_map; i++) {
439 struct e820entry *ei = &e820x->map[i]; 441 struct e820entry *ei = &e820x->map[i];
440 u64 final_start, final_end; 442 u64 final_start, final_end;
443 u64 ei_end;
444
441 if (ei->type != old_type) 445 if (ei->type != old_type)
442 continue; 446 continue;
443 /* totally covered? */ 447
444 if (ei->addr >= start && 448 ei_end = ei->addr + ei->size;
445 (ei->addr + ei->size) <= (start + size)) { 449 /* totally covered by new range? */
450 if (ei->addr >= start && ei_end <= end) {
446 ei->type = new_type; 451 ei->type = new_type;
447 real_updated_size += ei->size; 452 real_updated_size += ei->size;
448 continue; 453 continue;
449 } 454 }
455
456 /* new range is totally covered? */
457 if (ei->addr < start && ei_end > end) {
458 __e820_add_region(e820x, start, size, new_type);
459 __e820_add_region(e820x, end, ei_end - end, ei->type);
460 ei->size = start - ei->addr;
461 real_updated_size += size;
462 continue;
463 }
464
450 /* partially covered */ 465 /* partially covered */
451 final_start = max(start, ei->addr); 466 final_start = max(start, ei->addr);
452 final_end = min(start + size, ei->addr + ei->size); 467 final_end = min(end, ei_end);
453 if (final_start >= final_end) 468 if (final_start >= final_end)
454 continue; 469 continue;
455 470