Messages in this thread | | | Date | Tue, 24 Jun 2008 13:21:44 -0700 | From | "Yinghai Lu" <> | Subject | Re: [PATCH 2/3] e820_update_range(): Allow specifying ULLONG_MAX |
| |
On Tue, Jun 24, 2008 at 1:01 PM, Yinghai Lu <yhlu.kernel@gmail.com> wrote: > On Tue, Jun 24, 2008 at 7:35 AM, Bernhard Walle <bwalle@suse.de> wrote: >> Allow the specifying of ULLONG_MAX to limit the whole E820 map from the >> specified start to the end. Without the patch, there would be integer >> overflows. >> >> >> Signed-off-by: Bernhard Walle <bwalle@suse.de> >> --- >> arch/x86/kernel/e820.c | 11 +++++++++-- >> 1 files changed, 9 insertions(+), 2 deletions(-) >> >> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c >> index e466073..7d1109b 100644 >> --- a/arch/x86/kernel/e820.c >> +++ b/arch/x86/kernel/e820.c >> @@ -397,6 +397,9 @@ int __init copy_e820_map(struct e820entry *biosmap, int nr_map) >> return __copy_e820_map(biosmap, nr_map); >> } >> >> +/* >> + * Pass size == ULLONG_MAX to update until the end. >> + */ >> u64 __init e820_update_range(u64 start, u64 size, unsigned old_type, >> unsigned new_type) >> { >> @@ -412,14 +415,18 @@ u64 __init e820_update_range(u64 start, u64 size, unsigned old_type, >> continue; >> /* totally covered? */ >> if (ei->addr >= start && >> - (ei->addr + ei->size) <= (start + size)) { >> + (((ei->addr + ei->size) <= (start + size)) || >> + (size == ULLONG_MAX))) { >> ei->type = new_type; >> real_updated_size += ei->size; >> continue; >> } >> /* partially covered */ >> final_start = max(start, ei->addr); >> - final_end = min(start + size, ei->addr + ei->size); >> + if (size == ULLONG_MAX) >> + final_end = ei->addr + ei->size; >> + else >> + final_end = min(start + size, ei->addr + ei->size); >> if (final_start >= final_end) >> continue; >> ei->size -= final_end - final_start; >> -- > > > it seems we should let the caller to use > e820_update_range(start, ULLONG_MAX - size,....) > > so you don't need to touch this func.
or add sanitary check before using size in this func like if (size > ULLONG_MAX - start) size = ULLONG_MAX - start;
e820_remove_range need to the same thing
YH
| |