bootloader: Translate kernel args before adding them to kernel_args_range.
Chunks may be physically contiguous, but virtually disjoint. Adding physical addresses may cause ranges to be merged incorrectly. Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
This commit is contained in:
parent
21e3ac6cf5
commit
82dcc31606
@ -28,6 +28,8 @@ extern status_t platform_init_heap(struct stage2_args *args, void **_base, void
|
|||||||
extern status_t platform_allocate_region(void **_virtualAddress, size_t size,
|
extern status_t platform_allocate_region(void **_virtualAddress, size_t size,
|
||||||
uint8 protection, bool exactAddress);
|
uint8 protection, bool exactAddress);
|
||||||
extern status_t platform_free_region(void *address, size_t size);
|
extern status_t platform_free_region(void *address, size_t size);
|
||||||
|
extern status_t platform_bootloader_address_to_kernel_address(void *address, uint64_t *_result);
|
||||||
|
extern status_t platform_kernel_address_to_bootloader_address(uint64_t address, void **_result);
|
||||||
|
|
||||||
/* boot options */
|
/* boot options */
|
||||||
#define BOOT_OPTION_MENU 1
|
#define BOOT_OPTION_MENU 1
|
||||||
|
@ -101,15 +101,6 @@ typedef ELFLoader<ELF32Class> ELF32Loader;
|
|||||||
|
|
||||||
|
|
||||||
#ifdef BOOT_SUPPORT_ELF64
|
#ifdef BOOT_SUPPORT_ELF64
|
||||||
|
|
||||||
#ifdef _BOOT_PLATFORM_EFI
|
|
||||||
extern "C" status_t
|
|
||||||
platform_bootloader_address_to_kernel_address(void *address, uint64_t *_result);
|
|
||||||
extern "C" status_t
|
|
||||||
platform_kernel_address_to_bootloader_address(uint64_t address, void **_result);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
struct ELF64Class {
|
struct ELF64Class {
|
||||||
static const uint8 kIdentClass = ELFCLASS64;
|
static const uint8 kIdentClass = ELFCLASS64;
|
||||||
|
|
||||||
|
@ -370,7 +370,13 @@ kernel_args_malloc(size_t size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _BOOT_PLATFORM_EFI
|
||||||
|
uint64 translated_block;
|
||||||
|
platform_bootloader_address_to_kernel_address(block, &translated_block);
|
||||||
|
if (add_kernel_args_range((void *)translated_block, size) != B_OK)
|
||||||
|
#else
|
||||||
if (add_kernel_args_range(block, size) != B_OK)
|
if (add_kernel_args_range(block, size) != B_OK)
|
||||||
|
#endif
|
||||||
panic("kernel_args max range too low!\n");
|
panic("kernel_args max range too low!\n");
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
@ -385,7 +391,13 @@ kernel_args_malloc(size_t size)
|
|||||||
sFirstFree = (void*)((addr_t)block + size);
|
sFirstFree = (void*)((addr_t)block + size);
|
||||||
sLast = block;
|
sLast = block;
|
||||||
sFree = kChunkSize - size;
|
sFree = kChunkSize - size;
|
||||||
|
#ifdef _BOOT_PLATFORM_EFI
|
||||||
|
uint64 translated_block;
|
||||||
|
platform_bootloader_address_to_kernel_address(block, &translated_block);
|
||||||
|
if (add_kernel_args_range((void *)translated_block, kChunkSize) != B_OK)
|
||||||
|
#else
|
||||||
if (add_kernel_args_range(block, kChunkSize) != B_OK)
|
if (add_kernel_args_range(block, kChunkSize) != B_OK)
|
||||||
|
#endif
|
||||||
panic("kernel_args max range too low!\n");
|
panic("kernel_args max range too low!\n");
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
|
@ -122,16 +122,6 @@ convert_kernel_args()
|
|||||||
image = next;
|
image = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set correct kernel args range addresses.
|
|
||||||
dprintf("kernel args ranges:\n");
|
|
||||||
for (uint32 i = 0; i < gKernelArgs.num_kernel_args_ranges; i++) {
|
|
||||||
gKernelArgs.kernel_args_range[i].start = fix_address(
|
|
||||||
gKernelArgs.kernel_args_range[i].start);
|
|
||||||
dprintf(" base %#018" B_PRIx64 ", length %#018" B_PRIx64 "\n",
|
|
||||||
gKernelArgs.kernel_args_range[i].start,
|
|
||||||
gKernelArgs.kernel_args_range[i].size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fix driver settings files.
|
// Fix driver settings files.
|
||||||
driver_settings_file* file = gKernelArgs.driver_settings;
|
driver_settings_file* file = gKernelArgs.driver_settings;
|
||||||
fix_address(gKernelArgs.driver_settings);
|
fix_address(gKernelArgs.driver_settings);
|
||||||
|
Loading…
Reference in New Issue
Block a user