diff options
| author | Michael Brown | 2025-05-22 15:12:12 +0200 |
|---|---|---|
| committer | Michael Brown | 2025-05-22 17:28:15 +0200 |
| commit | 11929389e4298bbe4b7dce09ef2f2c4368c009c1 (patch) | |
| tree | aae7b975ff480b9337b40967afb633ff486e1623 /src/image | |
| parent | [initrd] Rename bzimage_align() to initrd_align() (diff) | |
| download | ipxe-11929389e4298bbe4b7dce09ef2f2c4368c009c1.tar.gz ipxe-11929389e4298bbe4b7dce09ef2f2c4368c009c1.tar.xz ipxe-11929389e4298bbe4b7dce09ef2f2c4368c009c1.zip | |
[initrd] Allow for images straddling the top of the reshuffle region
It is hypothetically possible for external heap memory allocated
during driver startup to have been freed before an image was
downloaded, which could therefore leave an image straddling the
address recorded as the top of the reshuffle region.
Allow for this possibility by skipping squashing for any images
already straddling (or touching) the top of the reshuffle region.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/image')
| -rw-r--r-- | src/image/initrd.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/image/initrd.c b/src/image/initrd.c index 5e8735518..5ba8c473d 100644 --- a/src/image/initrd.c +++ b/src/image/initrd.c @@ -68,8 +68,15 @@ static void initrd_squash_high ( physaddr_t top ) { if ( ! highest ) break; - /* Move this image to its final position */ + /* Calculate final position */ current -= initrd_align ( highest->len ); + if ( current <= virt_to_phys ( highest->data ) ) { + /* Already at (or crossing) top of region */ + current = virt_to_phys ( highest->data ); + continue; + } + + /* Move this image to its final position */ DBGC ( &images, "INITRD squashing %s [%#08lx,%#08lx)->" "[%#08lx,%#08lx)\n", highest->name, virt_to_phys ( highest->data ), |
