qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: Paul Mackerras <paulus@ozlabs.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH qemu RFC 1/4] spapr: Allow changing kernel loading address
Date: Tue, 23 Jul 2019 15:36:00 +1000	[thread overview]
Message-ID: <c221f516-770e-6976-ee0b-c19c51af94f0@ozlabs.ru> (raw)
In-Reply-To: <20190723034908.GO25073@umbus.fritz.box>



On 23/07/2019 13:49, David Gibson wrote:
> On Sat, Jul 20, 2019 at 11:28:47AM +1000, Alexey Kardashevskiy wrote:
>> Useful for the debugging purposes.
> 
> Am I correct in understanding this isn't actually necessary for the
> rest of the series to work, just useful for debugging?


Correct. When I just started and used stepping in gdb stub, it helped to 
have the kernel at specific location. And since there is another 
property added in this patchset - "bios" - I did not really want to 
rebase (I will have to anyway if we decide to proceed). Thanks,


> 
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>>   include/hw/ppc/spapr.h |  1 +
>>   hw/ppc/spapr.c         | 33 +++++++++++++++++++++++++++------
>>   2 files changed, 28 insertions(+), 6 deletions(-)
>>
>> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
>> index 74e427b588fc..ff82bb8554e1 100644
>> --- a/include/hw/ppc/spapr.h
>> +++ b/include/hw/ppc/spapr.h
>> @@ -159,6 +159,7 @@ struct SpaprMachineState {
>>       void *fdt_blob;
>>       long kernel_size;
>>       bool kernel_le;
>> +    uint64_t kernel_addr;
>>       uint32_t initrd_base;
>>       long initrd_size;
>>       uint64_t rtc_offset; /* Now used only during incoming migration */
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index 7fad42350538..6d13d65d8996 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -1179,7 +1179,7 @@ static void spapr_dt_chosen(SpaprMachineState *spapr, void *fdt)
>>                             spapr->initrd_base + spapr->initrd_size));
>>   
>>       if (spapr->kernel_size) {
>> -        uint64_t kprop[2] = { cpu_to_be64(KERNEL_LOAD_ADDR),
>> +        uint64_t kprop[2] = { cpu_to_be64(spapr->kernel_addr),
>>                                 cpu_to_be64(spapr->kernel_size) };
>>   
>>           _FDT(fdt_setprop(fdt, chosen, "qemu,boot-kernel",
>> @@ -1365,7 +1365,7 @@ static void *spapr_build_fdt(SpaprMachineState *spapr)
>>   
>>       /* Build memory reserve map */
>>       if (spapr->kernel_size) {
>> -        _FDT((fdt_add_mem_rsv(fdt, KERNEL_LOAD_ADDR, spapr->kernel_size)));
>> +        _FDT((fdt_add_mem_rsv(fdt, spapr->kernel_addr, spapr->kernel_size)));
>>       }
>>       if (spapr->initrd_size) {
>>           _FDT((fdt_add_mem_rsv(fdt, spapr->initrd_base, spapr->initrd_size)));
>> @@ -1391,7 +1391,8 @@ static void *spapr_build_fdt(SpaprMachineState *spapr)
>>   
>>   static uint64_t translate_kernel_address(void *opaque, uint64_t addr)
>>   {
>> -    return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR;
>> +    SpaprMachineState *spapr = opaque;
>> +    return (addr & 0x0fffffff) + spapr->kernel_addr;
>>   }
>>   
>>   static void emulate_spapr_hypercall(PPCVirtualHypervisor *vhyp,
>> @@ -2995,12 +2996,12 @@ static void spapr_machine_init(MachineState *machine)
>>           uint64_t lowaddr = 0;
>>   
>>           spapr->kernel_size = load_elf(kernel_filename, NULL,
>> -                                      translate_kernel_address, NULL,
>> +                                      translate_kernel_address, spapr,
>>                                         NULL, &lowaddr, NULL, 1,
>>                                         PPC_ELF_MACHINE, 0, 0);
>>           if (spapr->kernel_size == ELF_LOAD_WRONG_ENDIAN) {
>>               spapr->kernel_size = load_elf(kernel_filename, NULL,
>> -                                          translate_kernel_address, NULL, NULL,
>> +                                          translate_kernel_address, spapr, NULL,
>>                                             &lowaddr, NULL, 0, PPC_ELF_MACHINE,
>>                                             0, 0);
>>               spapr->kernel_le = spapr->kernel_size > 0;
>> @@ -3016,7 +3017,7 @@ static void spapr_machine_init(MachineState *machine)
>>               /* Try to locate the initrd in the gap between the kernel
>>                * and the firmware. Add a bit of space just in case
>>                */
>> -            spapr->initrd_base = (KERNEL_LOAD_ADDR + spapr->kernel_size
>> +            spapr->initrd_base = (spapr->kernel_addr + spapr->kernel_size
>>                                     + 0x1ffff) & ~0xffff;
>>               spapr->initrd_size = load_image_targphys(initrd_filename,
>>                                                        spapr->initrd_base,
>> @@ -3253,6 +3254,18 @@ static void spapr_set_vsmt(Object *obj, Visitor *v, const char *name,
>>       visit_type_uint32(v, name, (uint32_t *)opaque, errp);
>>   }
>>   
>> +static void spapr_get_kernel_addr(Object *obj, Visitor *v, const char *name,
>> +                                  void *opaque, Error **errp)
>> +{
>> +    visit_type_uint64(v, name, (uint64_t *)opaque, errp);
>> +}
>> +
>> +static void spapr_set_kernel_addr(Object *obj, Visitor *v, const char *name,
>> +                                  void *opaque, Error **errp)
>> +{
>> +    visit_type_uint64(v, name, (uint64_t *)opaque, errp);
>> +}
>> +
>>   static char *spapr_get_ic_mode(Object *obj, Error **errp)
>>   {
>>       SpaprMachineState *spapr = SPAPR_MACHINE(obj);
>> @@ -3358,6 +3371,14 @@ static void spapr_instance_init(Object *obj)
>>       object_property_add_bool(obj, "vfio-no-msix-emulation",
>>                                spapr_get_msix_emulation, NULL, NULL);
>>   
>> +    object_property_add(obj, "kernel-addr", "uint64", spapr_get_kernel_addr,
>> +                        spapr_set_kernel_addr, NULL, &spapr->kernel_addr,
>> +                        &error_abort);
>> +    object_property_set_description(obj, "kernel-addr",
>> +                                    stringify(KERNEL_LOAD_ADDR)
>> +                                    " for -kernel is the default",
>> +                                    NULL);
>> +    spapr->kernel_addr = KERNEL_LOAD_ADDR;
>>       /* The machine class defines the default interrupt controller mode */
>>       spapr->irq = smc->irq;
>>       object_property_add_str(obj, "ic-mode", spapr_get_ic_mode,
> 

-- 
Alexey


  reply	other threads:[~2019-07-23  5:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-20  1:28 [Qemu-devel] [PATCH qemu RFC 0/4] spapr: Kexec style boot Alexey Kardashevskiy
2019-07-20  1:28 ` [Qemu-devel] [PATCH qemu RFC 1/4] spapr: Allow changing kernel loading address Alexey Kardashevskiy
2019-07-23  3:49   ` David Gibson
2019-07-23  5:36     ` Alexey Kardashevskiy [this message]
2019-07-20  1:28 ` [Qemu-devel] [PATCH qemu RFC 2/4] spapr: Allow bios-less configuration Alexey Kardashevskiy
2019-07-23  3:52   ` David Gibson
2019-07-23  5:43     ` Alexey Kardashevskiy
2019-07-20  1:28 ` [Qemu-devel] [PATCH qemu RFC 3/4] spapr: Advertise H_RTAS to the guest Alexey Kardashevskiy
2019-07-23  3:53   ` David Gibson
2019-07-23  5:48     ` Alexey Kardashevskiy
2019-07-23  6:14       ` David Gibson
2019-07-23  7:41         ` Alexey Kardashevskiy
2019-07-20  1:28 ` [Qemu-devel] [PATCH qemu RFC 4/4] spapr: Implement SLOF-less client_architecture_support Alexey Kardashevskiy
2019-07-28  6:09   ` David Gibson
2019-07-29  5:03     ` Alexey Kardashevskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c221f516-770e-6976-ee0b-c19c51af94f0@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@ozlabs.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).