qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH qemu v20] spapr: Implement Open Firmware client interface
Date: Sun, 23 May 2021 13:24:26 +0200 (CEST)	[thread overview]
Message-ID: <8c712d-a369-4db-177e-2a5e63836af4@eik.bme.hu> (raw)
In-Reply-To: <8e2d201d-a6a3-72bc-5d0f-5226930f1cbc@ozlabs.ru>

[-- Attachment #1: Type: text/plain, Size: 5109 bytes --]

On Sun, 23 May 2021, Alexey Kardashevskiy wrote:
> On 23/05/2021 01:02, BALATON Zoltan wrote:
>> On Sat, 22 May 2021, BALATON Zoltan wrote:
>>> On Sat, 22 May 2021, Alexey Kardashevskiy wrote:
>>>> VOF itself does not prints anything in this patch.
>>> 
>>> However it seems to be needed for linux as the first thing it does seems 
>>> to be getting /chosen/stdout and calls exit if it returns nothing. So I'll 
>>> need this at least for linux. (I think MorphOS may also query it to print 
>>> a banner or some messages but not sure it needs it, at least it does not 
>>> abort right away if not found.)
>>> 
>>>>> but to see Linux output do I need a stdout in VOF or it will just open 
>>>>> the serial with its own driver and use that?
>>>>> So I'm not sure what's the stdout parts in the current vof patch does 
>>>>> and if I need that for anything. I'll try to experiment with it some 
>>>>> more but fixing the ld and Kconfig seems to be enough to get it work for 
>>>>> me.
>>>> 
>>>> So for the client to print something, /chosen/stdout needs to have a 
>>>> valid ihandle.
>>>> The only way to get a valid ihandle is having a valid phandle which 
>>>> vof_client_open() can open.
>>>> A valid phandle is a phandle of any node in the device tree. On spapr we 
>>>> pick some spapr-vty, open it and store in /chosen/stdout.
>>>> 
>>>> From this point output from the client can be seen via a tracepoint.
>> 
>> I've got it now. Looking at the original firmware device tree dump:
>> 
>> https://osdn.net/projects/qmiga/wiki/SubprojectPegasos2/attach/PegasosII_OFW-Dump.txt 
>> 
>> I see that /chosen/stdout points to "screen" which is an alias to 
>> /bootconsole. Just adding an empty /bootconsole node in the device tree and 
>> vof_client_open_store() that as /chosen/stdout works and I get output via 
>> vof_write traces so this is enough for now to test Linux. Properly 
>> connecting a serial backend can thus be postponed.
>> 
>> So with this the Linux kernel does not abort on the first device tree 
>> access but starts to decompress itself then the embedded initrd and crashes 
>> at calling setprop:
>> 
>> [...]
>> vof_client_handle: setprop
>> 
>> Thread 4 "qemu-system-ppc" received signal SIGSEGV, Segmentation fault.
>> (gdb) bt
>> #0  0x0000000000000000 in  ()
>> #1  0x0000555555a5c2bf in vof_setprop
>>      (vof=0x7ffff48e9420, vallen=4, valaddr=<optimized out>, 
>> pname=<optimized out>, nodeph=8, fdt=0x7fff8aaff010, ms=0x5555564f8800)
>>      at ../hw/ppc/vof.c:308
>> #2  0x0000555555a5c2bf in vof_client_handle
>>      (nrets=1, rets=0x7ffff48e93f0, nargs=4, args=0x7ffff48e93c0, 
>> service=0x7ffff48e9460 "setprop",
>>       vof=0x7ffff48e9420, fdt=0x7fff8aaff010, ms=0x5555564f8800) at 
>> ../hw/ppc/vof.c:842
>> #3  0x0000555555a5c2bf in vof_client_call
>>      (ms=0x5555564f8800, vof=vof@entry=0x55555662a3d0, 
>> fdt=fdt@entry=0x7fff8aaff010, args_real=args_real@entry=23580472)
>>      at ../hw/ppc/vof.c:935
>> 
>> loooks like it's trying to set /chosen/linux,initrd-start:
>
> It is not horribly clear why it crashed though.

It crashed becuase I had TYPE_VOF_MACHINE_IF but did not set a setprop 
callback and it tried to call that here. Adding a {return true;} empty 
callback avoids this.

>> (gdb) up
>> #1  0x0000555555a5c2bf in vof_setprop (vof=0x7ffff48e9420, vallen=4, 
>> valaddr=<optimized out>, pname=<optimized out>, nodeph=8,
>>      fdt=0x7fff8aaff010, ms=0x5555564f8800) at ../hw/ppc/vof.c:308
>> 308            if (!vmc->setprop(ms, nodepath, propname, val, vallen)) {
>> (gdb) p nodepath
>> $1 = "/chosen\000\060/rPC,750CXE/", '\000' <repeats 234 times>
>> (gdb) p propname
>> $2 = 
>> "linux,initrd-start\000linux,initrd-end\000linux,cmdline-timeout\000bootarg" 
>> (gdb) p val
>> $3 = <optimized out>
>> 
>> I think I need the callback for setprop in TYPE_VOF_MACHINE_IF. I can copy 
>> spapr_vof_setprop() but some explanation on why that's needed might help. 
>> Ciould I just do fdt_setprop in my callback as vof_setprop() would do 
>> without a machine callback or is there some special handling needed for 
>> these properties?
>
> The short answer is yes, you do not need TYPE_VOF_MACHINE_IF.
>
> The long answer is that we build the FDT on spapr twice:
> 1. at the reset time and
> 2. after "ibm,client-arhitecture-support" (early in the boot the spapr 
> paravirtual client says what it supports - ISA level, MMU features, etc)
>
> Between 1 and 2 the kernel moves initrd and we do not update the QEMU's 
> version of its location, the tree at 2) will have the old values.
>
> So for that reason I have TYPE_VOF_MACHINE_IF. You most definitely do not 
> need it.

I need TYPE_VOF_MACHINE_IF because that has the quiesce callback that I 
need to shut VOF down when the guest is finished with it otherwise it 
would crash later (more on this in next message). But since I shut down 
VOF here I don't need to remember changes to the FDT so I can just use an 
empty setprop callback. (I wouldn't even need that if VOF would check that 
a callback is non-NULL before calling it.)

Regards,
BALATON Zoltan

  reply	other threads:[~2021-05-23 11:25 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20  9:05 [PATCH qemu v20] spapr: Implement Open Firmware client interface Alexey Kardashevskiy
2021-05-20 21:59 ` BALATON Zoltan
2021-05-21  0:25   ` Alexey Kardashevskiy
2021-05-21  9:05     ` BALATON Zoltan
2021-05-21 19:57       ` BALATON Zoltan
2021-05-22  6:39         ` Alexey Kardashevskiy
2021-05-22 13:08           ` BALATON Zoltan
2021-05-23  3:47             ` Alexey Kardashevskiy
2021-05-23 12:12               ` BALATON Zoltan
2021-05-22  6:22       ` Alexey Kardashevskiy
2021-05-22 13:01         ` BALATON Zoltan
2021-05-22 15:02           ` BALATON Zoltan
2021-05-22 16:46             ` BALATON Zoltan
2021-05-23  3:41               ` Alexey Kardashevskiy
2021-05-23 12:02                 ` BALATON Zoltan
2021-05-23  3:31             ` Alexey Kardashevskiy
2021-05-23 11:24               ` BALATON Zoltan [this message]
2021-05-24  4:26                 ` Alexey Kardashevskiy
2021-05-24  5:40                   ` David Gibson
2021-05-24 11:56                     ` BALATON Zoltan
2021-05-23  3:20           ` Alexey Kardashevskiy
2021-05-23 11:19             ` BALATON Zoltan
2021-05-23 17:09               ` BALATON Zoltan
2021-05-24  6:01                 ` David Gibson
2021-05-24 10:55                   ` BALATON Zoltan
2021-05-24 12:46                     ` Alexey Kardashevskiy
2021-05-24 22:34                       ` BALATON Zoltan
2021-05-25  5:24                       ` David Gibson
2021-05-25  5:23                     ` David Gibson
2021-05-25 10:08                       ` BALATON Zoltan
2021-05-27  5:34                         ` David Gibson
2021-05-27 12:42                           ` BALATON Zoltan
2021-06-02  7:57                             ` David Gibson
2021-06-02 12:29                               ` BALATON Zoltan
2021-06-04  6:29                                 ` David Gibson
2021-06-04 13:59                                   ` BALATON Zoltan
2021-06-07  3:30                                     ` David Gibson
2021-06-07 22:54                                       ` BALATON Zoltan
2021-06-09  5:51                                         ` Alexey Kardashevskiy
2021-06-09 10:19                                           ` BALATON Zoltan
2021-06-06 22:21                                   ` BALATON Zoltan
2021-06-07  3:37                                     ` David Gibson
2021-06-07 22:20                                       ` BALATON Zoltan
2021-05-24 12:42                   ` BALATON Zoltan
2021-05-25  5:29                     ` David Gibson
2021-05-25  9:55                       ` BALATON Zoltan
2021-05-27  5:31                         ` David Gibson
2021-05-24  5:23   ` David Gibson
2021-05-24  9:57     ` BALATON Zoltan
2021-05-24 10:50       ` David Gibson
2021-05-29 18:10 ` BALATON Zoltan
2021-05-30 17:33 ` BALATON Zoltan
2021-05-31 13:07   ` BALATON Zoltan
2021-06-01 12:02     ` Alexey Kardashevskiy
2021-06-01 14:12       ` BALATON Zoltan
2021-06-04  6:21         ` David Gibson
2021-06-04 13:27           ` BALATON Zoltan
2021-06-07  3:02             ` David Gibson
2021-06-04  6:19   ` David Gibson
2021-06-04 13:50     ` BALATON Zoltan
2021-06-04 14:34       ` BALATON Zoltan
2021-06-07  3:05       ` David Gibson
2021-06-09  6:13         ` 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=8c712d-a369-4db-177e-2a5e63836af4@eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --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).