diff options
| -rw-r--r-- | arch/x86/xen/setup.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index a4790bf22c59..ead85576d54a 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c | |||
| @@ -157,25 +157,24 @@ static unsigned long __init xen_populate_chunk( | |||
| 157 | unsigned long dest_pfn; | 157 | unsigned long dest_pfn; |
| 158 | 158 | ||
| 159 | for (i = 0, entry = list; i < map_size; i++, entry++) { | 159 | for (i = 0, entry = list; i < map_size; i++, entry++) { |
| 160 | unsigned long credits = credits_left; | ||
| 161 | unsigned long s_pfn; | 160 | unsigned long s_pfn; |
| 162 | unsigned long e_pfn; | 161 | unsigned long e_pfn; |
| 163 | unsigned long pfns; | 162 | unsigned long pfns; |
| 164 | long capacity; | 163 | long capacity; |
| 165 | 164 | ||
| 166 | if (credits <= 0) | 165 | if (credits_left <= 0) |
| 167 | break; | 166 | break; |
| 168 | 167 | ||
| 169 | if (entry->type != E820_RAM) | 168 | if (entry->type != E820_RAM) |
| 170 | continue; | 169 | continue; |
| 171 | 170 | ||
| 172 | e_pfn = PFN_UP(entry->addr + entry->size); | 171 | e_pfn = PFN_DOWN(entry->addr + entry->size); |
| 173 | 172 | ||
| 174 | /* We only care about E820 after the xen_start_info->nr_pages */ | 173 | /* We only care about E820 after the xen_start_info->nr_pages */ |
| 175 | if (e_pfn <= max_pfn) | 174 | if (e_pfn <= max_pfn) |
| 176 | continue; | 175 | continue; |
| 177 | 176 | ||
| 178 | s_pfn = PFN_DOWN(entry->addr); | 177 | s_pfn = PFN_UP(entry->addr); |
| 179 | /* If the E820 falls within the nr_pages, we want to start | 178 | /* If the E820 falls within the nr_pages, we want to start |
| 180 | * at the nr_pages PFN. | 179 | * at the nr_pages PFN. |
| 181 | * If that would mean going past the E820 entry, skip it | 180 | * If that would mean going past the E820 entry, skip it |
| @@ -184,23 +183,19 @@ static unsigned long __init xen_populate_chunk( | |||
| 184 | capacity = e_pfn - max_pfn; | 183 | capacity = e_pfn - max_pfn; |
| 185 | dest_pfn = max_pfn; | 184 | dest_pfn = max_pfn; |
| 186 | } else { | 185 | } else { |
| 187 | /* last_pfn MUST be within E820_RAM regions */ | ||
| 188 | if (*last_pfn && e_pfn >= *last_pfn) | ||
| 189 | s_pfn = *last_pfn; | ||
| 190 | capacity = e_pfn - s_pfn; | 186 | capacity = e_pfn - s_pfn; |
| 191 | dest_pfn = s_pfn; | 187 | dest_pfn = s_pfn; |
| 192 | } | 188 | } |
| 193 | /* If we had filled this E820_RAM entry, go to the next one. */ | ||
| 194 | if (capacity <= 0) | ||
| 195 | continue; | ||
| 196 | 189 | ||
| 197 | if (credits > capacity) | 190 | if (credits_left < capacity) |
| 198 | credits = capacity; | 191 | capacity = credits_left; |
| 199 | 192 | ||
| 200 | pfns = xen_do_chunk(dest_pfn, dest_pfn + credits, false); | 193 | pfns = xen_do_chunk(dest_pfn, dest_pfn + capacity, false); |
| 201 | done += pfns; | 194 | done += pfns; |
| 202 | credits_left -= pfns; | ||
| 203 | *last_pfn = (dest_pfn + pfns); | 195 | *last_pfn = (dest_pfn + pfns); |
| 196 | if (pfns < capacity) | ||
| 197 | break; | ||
| 198 | credits_left -= pfns; | ||
| 204 | } | 199 | } |
| 205 | return done; | 200 | return done; |
| 206 | } | 201 | } |
