|
@@ -519,29 +519,45 @@ u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type,
|
|
printk(KERN_DEBUG "e820 remove range: %016Lx - %016Lx ",
|
|
printk(KERN_DEBUG "e820 remove range: %016Lx - %016Lx ",
|
|
(unsigned long long) start,
|
|
(unsigned long long) start,
|
|
(unsigned long long) end);
|
|
(unsigned long long) end);
|
|
- e820_print_type(old_type);
|
|
|
|
|
|
+ if (checktype)
|
|
|
|
+ e820_print_type(old_type);
|
|
printk(KERN_CONT "\n");
|
|
printk(KERN_CONT "\n");
|
|
|
|
|
|
for (i = 0; i < e820.nr_map; i++) {
|
|
for (i = 0; i < e820.nr_map; i++) {
|
|
struct e820entry *ei = &e820.map[i];
|
|
struct e820entry *ei = &e820.map[i];
|
|
u64 final_start, final_end;
|
|
u64 final_start, final_end;
|
|
|
|
+ u64 ei_end;
|
|
|
|
|
|
if (checktype && ei->type != old_type)
|
|
if (checktype && ei->type != old_type)
|
|
continue;
|
|
continue;
|
|
|
|
+
|
|
|
|
+ ei_end = ei->addr + ei->size;
|
|
/* totally covered? */
|
|
/* totally covered? */
|
|
- if (ei->addr >= start &&
|
|
|
|
- (ei->addr + ei->size) <= (start + size)) {
|
|
|
|
|
|
+ if (ei->addr >= start && ei_end <= end) {
|
|
real_removed_size += ei->size;
|
|
real_removed_size += ei->size;
|
|
memset(ei, 0, sizeof(struct e820entry));
|
|
memset(ei, 0, sizeof(struct e820entry));
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /* new range is totally covered? */
|
|
|
|
+ if (ei->addr < start && ei_end > end) {
|
|
|
|
+ e820_add_region(end, ei_end - end, ei->type);
|
|
|
|
+ ei->size = start - ei->addr;
|
|
|
|
+ real_removed_size += size;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
/* partially covered */
|
|
/* partially covered */
|
|
final_start = max(start, ei->addr);
|
|
final_start = max(start, ei->addr);
|
|
- final_end = min(start + size, ei->addr + ei->size);
|
|
|
|
|
|
+ final_end = min(end, ei_end);
|
|
if (final_start >= final_end)
|
|
if (final_start >= final_end)
|
|
continue;
|
|
continue;
|
|
real_removed_size += final_end - final_start;
|
|
real_removed_size += final_end - final_start;
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * left range could be head or tail, so need to update
|
|
|
|
+ * size at first.
|
|
|
|
+ */
|
|
ei->size -= final_end - final_start;
|
|
ei->size -= final_end - final_start;
|
|
if (ei->addr < final_start)
|
|
if (ei->addr < final_start)
|
|
continue;
|
|
continue;
|