From: Yinghai Lu <yinghai@kernel.org>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
yinghai@kernel.org, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:x86/mm] x86: fix e820_update_range()
Date: Fri, 13 Mar 2009 04:39:33 GMT [thread overview]
Message-ID: <tip-773e673de27297d07d852e7e9bfd1a695cae1da2@git.kernel.org> (raw)
In-Reply-To: <49B9E286.502@kernel.org>
Commit-ID: 773e673de27297d07d852e7e9bfd1a695cae1da2
Gitweb: http://git.kernel.org/tip/773e673de27297d07d852e7e9bfd1a695cae1da2
Author: Yinghai Lu <yinghai@kernel.org>
AuthorDate: Thu, 12 Mar 2009 21:35:18 -0700
Commit: Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 13 Mar 2009 05:38:29 +0100
x86: fix e820_update_range()
Impact: fix left range size on head
| commit 5c0e6f035df983210e4d22213aed624ced502d3d
| x86: fix code paths used by update_mptable
| Impact: fix crashes under Xen due to unrobust e820 code
fixes one e820 bug, but introduces another bug.
Need to update size for left range at first in case it is header.
also add __e820_add_region take more parameter.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: jbeulich@novell.com
LKML-Reference: <49B9E286.502@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/e820.c | 45 ++++++++++++++++++++++++---------------------
1 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 3cf6681..95b81c1 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -110,19 +110,25 @@ int __init e820_all_mapped(u64 start, u64 end, unsigned type)
/*
* Add a memory region to the kernel e820 map.
*/
-void __init e820_add_region(u64 start, u64 size, int type)
+static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
+ int type)
{
- int x = e820.nr_map;
+ int x = e820x->nr_map;
- if (x == ARRAY_SIZE(e820.map)) {
+ if (x == ARRAY_SIZE(e820x->map)) {
printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
return;
}
- e820.map[x].addr = start;
- e820.map[x].size = size;
- e820.map[x].type = type;
- e820.nr_map++;
+ e820x->map[x].addr = start;
+ e820x->map[x].size = size;
+ e820x->map[x].type = type;
+ e820x->nr_map++;
+}
+
+void __init e820_add_region(u64 start, u64 size, int type)
+{
+ __e820_add_region(&e820, start, size, type);
}
void __init e820_print_map(char *who)
@@ -417,11 +423,11 @@ static int __init append_e820_map(struct e820entry *biosmap, int nr_map)
return __append_e820_map(biosmap, nr_map);
}
-static u64 __init e820_update_range_map(struct e820map *e820x, u64 start,
+static u64 __init __e820_update_range(struct e820map *e820x, u64 start,
u64 size, unsigned old_type,
unsigned new_type)
{
- unsigned int i, x;
+ unsigned int i;
u64 real_updated_size = 0;
BUG_ON(old_type == new_type);
@@ -447,22 +453,19 @@ static u64 __init e820_update_range_map(struct e820map *e820x, u64 start,
if (final_start >= final_end)
continue;
- x = e820x->nr_map;
- if (x == ARRAY_SIZE(e820x->map)) {
- printk(KERN_ERR "Too many memory map entries!\n");
- break;
- }
- e820x->map[x].addr = final_start;
- e820x->map[x].size = final_end - final_start;
- e820x->map[x].type = new_type;
- e820x->nr_map++;
+ __e820_add_region(e820x, final_start, final_end - final_start,
+ new_type);
real_updated_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;
if (ei->addr < final_start)
continue;
ei->addr = final_end;
- ei->size -= final_end - final_start;
}
return real_updated_size;
}
@@ -470,13 +473,13 @@ static u64 __init e820_update_range_map(struct e820map *e820x, u64 start,
u64 __init e820_update_range(u64 start, u64 size, unsigned old_type,
unsigned new_type)
{
- return e820_update_range_map(&e820, start, size, old_type, new_type);
+ return __e820_update_range(&e820, start, size, old_type, new_type);
}
static u64 __init e820_update_range_saved(u64 start, u64 size,
unsigned old_type, unsigned new_type)
{
- return e820_update_range_map(&e820_saved, start, size, old_type,
+ return __e820_update_range(&e820_saved, start, size, old_type,
new_type);
}
next prev parent reply other threads:[~2009-03-13 4:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-12 12:57 [PATCH] x86: clean up output resulting from update_mptable option Jan Beulich
2009-03-13 2:34 ` [tip:x86/mm] " Jan Beulich
2009-03-13 4:35 ` [PATCH] x86: fix e820_update_range() Yinghai Lu
2009-03-13 4:39 ` Yinghai Lu [this message]
2009-03-13 5:36 ` [PATCH] x86: make e820_update_range to handle small range update Yinghai Lu
2009-03-14 11:39 ` [tip:x86/mm] x86: make e820_update_range() " Yinghai Lu
2009-03-14 12:17 ` Ingo Molnar
2009-03-14 18:21 ` Yinghai Lu
2009-03-14 18:40 ` Ingo Molnar
2009-03-14 21:32 ` Yinghai Lu
2009-03-15 6:04 ` Ingo Molnar
2009-03-15 6:20 ` Yinghai Lu
2009-03-15 6:25 ` Ingo Molnar
2009-03-15 6:12 ` [tip:x86/mm] x86: fix 64k corruption-check Yinghai Lu
2009-03-13 7:57 ` [PATCH] x86: fix e820_update_range() Jan Beulich
2009-03-13 11:13 ` Ingo Molnar
2009-03-13 18:22 ` Yinghai Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-773e673de27297d07d852e7e9bfd1a695cae1da2@git.kernel.org \
--to=yinghai@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox