diff options
| author | Michael Brown | 2025-05-22 12:58:11 +0200 |
|---|---|---|
| committer | Michael Brown | 2025-05-22 17:28:15 +0200 |
| commit | 11e01f0652daaf198317e2e13c8bb1d19f664ce9 (patch) | |
| tree | 40d35c4ccd2d1a3dbae5517fc82e871cf1c68926 /src/image | |
| parent | [uheap] Prevent allocation of blocks with zero physical addresses (diff) | |
| download | ipxe-11e01f0652daaf198317e2e13c8bb1d19f664ce9.tar.gz ipxe-11e01f0652daaf198317e2e13c8bb1d19f664ce9.tar.xz ipxe-11e01f0652daaf198317e2e13c8bb1d19f664ce9.zip | |
[uheap] Expose external heap region directly
We currently rely on implicit detection of the external heap region.
The INT 15 memory map mangler relies on examining the corresponding
in-use memory region, and the initrd reshuffler relies on performing a
separate detection of the largest free memory block after startup has
completed.
Replace these with explicit public symbols to describe the external
heap region.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/image')
| -rw-r--r-- | src/image/initrd.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/src/image/initrd.c b/src/image/initrd.c index 71634324d..511f95f10 100644 --- a/src/image/initrd.c +++ b/src/image/initrd.c @@ -28,8 +28,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include <ipxe/image.h> #include <ipxe/uaccess.h> #include <ipxe/init.h> -#include <ipxe/memmap.h> #include <ipxe/cpio.h> +#include <ipxe/uheap.h> #include <ipxe/initrd.h> /** @file @@ -41,9 +41,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Maximum address available for initrd */ static physaddr_t initrd_top; -/** Minimum address available for initrd */ -static physaddr_t initrd_bottom; - /** * Squash initrds as high as possible in memory * @@ -236,9 +233,8 @@ void initrd_reshuffle ( physaddr_t bottom ) { size_t free_len; /* Calculate limits of available space for initrds */ - top = initrd_top; - if ( initrd_bottom > bottom ) - bottom = initrd_bottom; + top = ( initrd_top ? initrd_top : uheap_end ); + assert ( bottom >= uheap_limit ); /* Debug */ DBGC ( &images, "INITRD region [%#08lx,%#08lx)\n", bottom, top ); @@ -270,9 +266,8 @@ int initrd_reshuffle_check ( size_t len, physaddr_t bottom ) { size_t available; /* Calculate limits of available space for initrds */ - top = initrd_top; - if ( initrd_bottom > bottom ) - bottom = initrd_bottom; + top = ( initrd_top ? initrd_top : uheap_end ); + assert ( bottom >= uheap_limit ); available = ( top - bottom ); /* Allow for a sensible minimum amount of free space */ @@ -287,19 +282,19 @@ int initrd_reshuffle_check ( size_t len, physaddr_t bottom ) { * */ static void initrd_startup ( void ) { - size_t len; - /* Record largest memory block available. Do this after any - * allocations made during driver startup (e.g. large host - * memory blocks for Infiniband devices, which may still be in - * use at the time of rearranging if a SAN device is hooked) - * but before any allocations for downloaded images (which we - * can safely reuse when rearranging). + /* Record address above which reshuffling cannot take place. + * If any external heap allocations have been made during + * driver startup (e.g. large host memory blocks for + * Infiniband devices, which may still be in use at the time + * of rearranging if a SAN device is hooked), then we must not + * overwrite these allocations during reshuffling. */ - len = memmap_largest ( &initrd_bottom ); - initrd_top = ( initrd_bottom + len ); - DBGC ( &images, "INITRD largest memory block is [%#08lx,%#08lx)\n", - initrd_bottom, initrd_top ); + initrd_top = uheap_start; + if ( initrd_top ) { + DBGC ( &images, "INITRD limiting reshuffling to below " + "%#08lx\n", initrd_top ); + } } /** initrd startup function */ |
