aboutsummaryrefslogtreecommitdiff
path: root/hw/loader.c
AgeCommit message (Collapse)AuthorFilesLines
2012-05-21use an uint64_t for the max_sz parameter in load_image_targphysMark Langsdorf1-1/+1
Allow load_image_targphys to load files on systems with more than 2G of emulated memory by changing the max_sz parameter from an int to an uint64_t. Reviewed-by: Andreas F=E4rber <afaerber@suse.de> Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Mark Langsdorf <mark.langsdorf@calxeda.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-21load_image_targphys() should enforce the max sizeBenjamin Herrenschmidt1-1/+5
load_image_targphys() gets passed a max size for the file, but doesn't enforce it at all. Add a check and return -1 (error) if the file is too big, without loading it. Fix the bracing style in the function while we're at it. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
2011-12-20loader: remove calls to cpu_get_physical_page_desc()Avi Kivity1-4/+5
cpu_get_physical_page_desc() is tied into the memory core's innards, replace it with uses of the API. Signed-off-by: Avi Kivity <avi@redhat.com>
2011-11-19loader: Fix read_targphys() to behave when read() failsMarkus Armbruster1-4/+5
Happily passes (size_t)-1 to rom_add_blob_fixed(), which promptly dies attempting to malloc that much. Spotted by Coverity. Bonus fix for ROMs larger than INT_MAX bytes: return ssize_t instead of int. Bug can't bite, because the only user load_aout() limits ROM size to an int value. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-16Remove blanks before \n in output stringsStefan Weil1-2/+2
Those blanks violate the coding conventions, see scripts/checkpatch.pl. Blanks missing after colons in the changed lines were added. This patch does not try to fix tabs, long lines and other problems in the changed lines, therefore checkpatch.pl reports many violations. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-24/+24
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-01-12loader: fix a file descriptor leakBlue Swirl1-2/+3
Fix a file descriptor leak, reported by cppcheck: [/src/qemu/hw/loader.c:311]: (error) Resource leak: fd Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-12-11Add bootindex for option roms.Gleb Natapov1-5/+11
Extend -option-rom command to have additional parameter ,bootindex=. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-12-11Change fw_cfg_add_file() to get full file path as a parameter.Gleb Natapov1-2/+14
Change fw_cfg_add_file() to get full file path as a parameter instead of building one internally. Two reasons for that. First caller may need to know how file is named. Second this moves policy of file naming out from fw_cfg. Platform may want to use more then two levels of directories for instance. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-07-30remove dead code from hw/loader.cJoel Schopp1-5/+0
Removing dead code. Above we already continued when rom->addr + valuegreaterthan0 < addr so this condition is always false. Signed-off-by: Joel Schopp <jschopp@austin.ibm.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-16load_elf: replace the address addend by a translation functionAurelien Jarno1-7/+7
A few machines need to translate the ELF header addresses into physical addresses. Currently the only possibility is to add a value to the addresses. This patch replaces the addend argument by and a translation function and an opaque passed to the function. A NULL function does not translate the address. The patch also convert all machines that have an addend, simplify the PowerPC kernel loading and fix the MIPS kernel loading using this new feature. Other machines may benefit from this feature. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-14Remove conditional rom loading supportBlue Swirl1-5/+0
Commit c2039bd0ffce8807e0eaac55254fde790825fa92 made rom loading automatic for non-PC architectures. Remove now mostly unused conditional rom loading support. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-11roms: rework rom loading via fwGerd Hoffmann1-10/+5
This patch changes the way rom loading via fw_cfg is handled. Instead of having pc_init1() call a function which passed all roms to the firmware config we simply pass a pointer to fw_cfg to the rom loader. Advantage: loading roms via firmware works also for devices which are initialized after pc_init1(), i.e. everyting added via -device. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-11roms: minor fixes and cleanups.Gerd Hoffmann1-15/+23
Changes: - Drop extra file argument from rom_add_file(). - Drop fw_dir check in do_info_roms, we allways have a dir name. - code style fixes. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-24loader: more ignores for rom intended to be loaded by the biosAurelien Jarno1-0/+6
Similarly to what has been done in e405a2ba91b68817cae2a428de55fe9616a4cf37, ignore rom intended to be loaded by the bios in find_rom() and rom_copy(). Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-24Don't load options roms intended to be loaded by the bios in qemuAvi Kivity1-1/+7
The first such option rom will load at address 0, which isn't very nice, and the second will report a conflict and abort, which is horrible. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19Multiboot support: Fix rom_copyKevin Wolf1-2/+5
ROMs need to be loaded if they are anywhere in the requested area, not only at the very beginning. This fixes Multiboot with ELF kernels that have more than one program header. Signed-off-by: Kevin Wolf <mail@kevin-wolf.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19roms: allow roms to be loaded at address 0Aurelien Jarno1-8/+0
It was possible to load roms at address 0, but commit 632cf034b401cdd01dae253a8b577fe518e37654 started to forbid that, which broke at least ARM versatile. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-18roms: remove option rom packing logicGerd Hoffmann1-57/+46
Now that we load the option roms via fw_cfg, we can stop copying them to the 0xc000 -> 0xe000. The patch does just that. Also the rom loader gets simplified as all remaining users of the rom loader load the bits at a fixed address so the packing and aligning logic can go away. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-18roms: use new fw_cfg file xfer support.Gerd Hoffmann1-3/+22
roms: use fw_cfg for vgabios and option rom loading, additionally to deploying them the traditional way (copy to 0xc0000 -> 0xe0000 range). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-18Check rom_load_all() return value.Gerd Hoffmann1-1/+1
Check rom_load_all() return value. Also don't make option rom loading failure fatal. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-18Fix loading of ELF multiboot kernelsKevin Wolf1-2/+0
The multiboot implementation assumed that there is only one program header (which contains the entry point) and that the entry point is at the start of the code. This doesn't hold true generally and caused too little data to be loaded. Fix the loading code to pass the whole loaded data to the Multiboot Option ROM. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-17Introduce rom_copyAlexander Graf1-0/+38
We have several rom helpers currently, but none of them can get us code that spans several roms into a pointer. This patch introduces a function that copies over rom contents. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-11Reject late rom loadingPaul Brook1-0/+7
rom_+add_file/rom_add_blob only work correctly if called before load_all_roms. Enforce this rather than silently accepting and putting the rom in the wrong place at reset. Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-11-07sparc32 (mostly): remove unneeded calls to device resetBlue Swirl1-1/+0
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-10-30rom loader: make vga+rom loading configurable.Gerd Hoffmann1-0/+15
The rom_add_vga() and rom_add_option() macros are transformed into functions. They look at the new rom_enable_driver_roms variable and only do something if it is set to non-zero, making vga+option rom loading runtime option. pc_init() sets rom_enable_driver_roms to 1. With this in place we can move the rom loading calls from pc.c to the individual drivers. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30rom loader: use qemu_strdup.Gerd Hoffmann1-1/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-12rom loader: also try filename as-is.Gerd Hoffmann1-2/+1
In case qemu_find_file fails try to open the file as-is. Patchworks-ID: 35263 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-12rom loader: fix sparc -kernel boot.Gerd Hoffmann1-6/+32
Changes: (1) register pstrcpy_targphys() in rom list, it is used for kernel command lines by a number of architectures. (2) add rom_ptr() function to get a pointer for applying changes to loaded images. Needed for example to tell the linux kernel where it finds the initrd image by updating the header. (3) make sparc use rom_ptr for initrd setup. booting sparc-test works now, and 'info roms' shows this: (qemu) info roms addr=0000000000000000 size=0x2a3828 mem=ram name="phdr #0: vmlinux-2.6.11+tcx" addr=00000000007ff000 size=0x00000e mem=ram name="cmdline" addr=0000000000800000 size=0x400000 mem=ram name="/root/qemu-test/sparc-test/linux.img" addr=0000000070000000 size=0x0e4000 mem=rom name="phdr #0: /home/kraxel/projects/qemu/build-zfull/pc-bios/openbios-sparc32" reboot via 'system_reset' works too. Patchworks-ID: 35262 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-10Fix Windows host breakage by 45a50b1668822c23afc2a89f724654e176518bc4 (TeLeMan)malc1-1/+1
Signed-off-by: malc <av1474@comtv.ru>
2009-10-06Reorganize option rom (+linux kernel) loading.Gerd Hoffmann1-57/+197
This patch adds infrastructure to maintain memory regions which must be restored on reset. That includes roms (vga bios and option roms on pc), but is also used when loading linux kernels directly. Features: - loading files is supported. - passing blobs is supported. - target address range is supported (for optionrom area). - fixed target memory address is supported (linux kernel). New in v2: - writes to ROM are done only at initial boot. - also handle aout and uimage loaders. - drop unused fread_targphys() function. The final memory layout is created once all memory regions are registered. The option roms get addresses assigned and the registered regions are checked against overlaps. Finally all data is copyed to the guest memory. Advantages: (1) Filling memory on initial boot and on reset takes the same code path, making reset more robust. (2) The need to keep track of the option rom load address is gone. (3) Due to (2) option roms can be loaded outside pc_init(). This allows to move the pxe rom loading into the nic drivers for example. Additional bonus: There is a 'info roms' monitor command now. The patch also switches over pc.c and removes the option_rom_setup_reset() and load_option_rom() functions. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-01Revert "Get rid of _t suffix"Anthony Liguori1-15/+15
In the very least, a change like this requires discussion on the list. The naming convention is goofy and it causes a massive merge problem. Something like this _must_ be presented on the list first so people can provide input and cope with it. This reverts commit 99a0949b720a0936da2052cb9a46db04ffc6db29. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-01Get rid of _t suffixmalc1-15/+15
Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
2009-09-20Compile loader only onceBlue Swirl1-0/+546
Callers must pass ELF machine, byte swapping and symbol LSB clearing information to ELF loader. A.out loader needs page size information, pass that too as a parameter. Extract prototypes to a separate file. Move loader.[ch] and elf_ops.h under hw. Adjust callers. Also use target_phys_addr_t instead of target_ulong for addresses: loader addresses aren't virtual. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>