hw/arm/boot: Don't assume RAM starts at address zero
In the Arm kernel/initrd loading code, in some places we make the incorrect assumption that info->ram_size can be treated as the address of the end of RAM, as for instance when we calculate the available space for the initrd using "info->ram_size - info->initrd_start". This is wrong, because many Arm boards (including "virt") specify a non-zero info->loader_start to indicate that their RAM area starts at a non-zero physical address. Correct the places which make this incorrect assumption. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Tested-by: Mark Rutland <mark.rutland@arm.com> Message-id: 20190516144733.32399-2-peter.maydell@linaro.org
This commit is contained in:
		
							parent
							
								
									5d0e569447
								
							
						
					
					
						commit
						e70af24b42
					
				@ -977,6 +977,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
 | 
			
		||||
    int elf_machine;
 | 
			
		||||
    hwaddr entry;
 | 
			
		||||
    static const ARMInsnFixup *primary_loader;
 | 
			
		||||
    uint64_t ram_end = info->loader_start + info->ram_size;
 | 
			
		||||
 | 
			
		||||
    if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
 | 
			
		||||
        primary_loader = bootloader_aarch64;
 | 
			
		||||
@ -1048,8 +1049,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
 | 
			
		||||
        /* 32-bit ARM */
 | 
			
		||||
        entry = info->loader_start + KERNEL_LOAD_ADDR;
 | 
			
		||||
        kernel_size = load_image_targphys_as(info->kernel_filename, entry,
 | 
			
		||||
                                             info->ram_size - KERNEL_LOAD_ADDR,
 | 
			
		||||
                                             as);
 | 
			
		||||
                                             ram_end - KERNEL_LOAD_ADDR, as);
 | 
			
		||||
        is_linux = 1;
 | 
			
		||||
    }
 | 
			
		||||
    if (kernel_size < 0) {
 | 
			
		||||
@ -1063,12 +1063,11 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
 | 
			
		||||
        if (info->initrd_filename) {
 | 
			
		||||
            initrd_size = load_ramdisk_as(info->initrd_filename,
 | 
			
		||||
                                          info->initrd_start,
 | 
			
		||||
                                          info->ram_size - info->initrd_start,
 | 
			
		||||
                                          as);
 | 
			
		||||
                                          ram_end - info->initrd_start, as);
 | 
			
		||||
            if (initrd_size < 0) {
 | 
			
		||||
                initrd_size = load_image_targphys_as(info->initrd_filename,
 | 
			
		||||
                                                     info->initrd_start,
 | 
			
		||||
                                                     info->ram_size -
 | 
			
		||||
                                                     ram_end -
 | 
			
		||||
                                                     info->initrd_start,
 | 
			
		||||
                                                     as);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user