qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH 2/2] spapr: -kernel: allow linking with spec


From: Thomas Huth
Subject: Re: [Qemu-devel] [RFC PATCH 2/2] spapr: -kernel: allow linking with specified addr
Date: Mon, 20 Jul 2015 08:47:53 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

On 20/07/15 07:01, David Gibson wrote:
> On Fri, Jul 17, 2015 at 01:56:40PM +0200, Andrew Jones wrote:
>> I've started playing with adding ppc support to kvm-unit-tests,
>> using spapr for the machine model. I wanted to link the unit test
>> at 0x400000 to match qemu's load address, making the unit test
>> startup code simpler, but ended up with 0x800000 instead, due to
>> how translate_kernel_address works. The translation makes sense
>> for how Linux kernels are linked (always at 0xc0000000 or
>> 0xc000000000000000), but for the unit test case we need to avoid
>> adding the offset.
>>
>> Signed-off-by: Andrew Jones <address@hidden>
>> ---
>> Big RFC because I don't know if the "always at 0xc..." statement
>> is 100% true for Linux, nor if this patch would break other stuff...
> 
> Yeah, I'm pretty dubious about this too, especially since I don't
> entirely grasp what the load_elf() translation function is all about
> anyway.

Well, AFAIK it's used to modify the addresses before the ELF loader uses
the address for loading. For example if your ELF binary is linked at
address 0x1000, the translate function would move your binary to
0x401000 instead so that it does not interfere with the SLOF firmware
(which is loaded to address 0 IIRC).

So I also think your fix here is wrong, Andrew. E.g. when you have a
binary that is linked to address 0x1000, you don't want to bypass the
translation step here since it then would clash with the firmware.

> That said, I suspect making your unit test assume a fixed load address
> may not be the best idea - qemu or SLOF could change in future to move
> things about, so it might be more robust to have your test copy itself
> to address it wants to be at before executing.

+1

... or you could try to get the elf_reloc code working for POWER, too
(see include/hw/elf_ops.h). That way QEMU would take care of relocating
your program. (you can peek at elf_apply_rela64() in
 https://github.com/aik/SLOF/blob/master/lib/libelf/elf64.c
if you want to know what basically has to be done for POWER relocations).

 Thomas


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]