LoongArch architecture development
 help / color / mirror / Atom feed
* qemu direct kernel boot on LoongArch
@ 2023-10-09 20:13 Thomas Weißschuh
  2023-10-10  1:12 ` maobibo
  0 siblings, 1 reply; 19+ messages in thread
From: Thomas Weißschuh @ 2023-10-09 20:13 UTC (permalink / raw)
  To: loongarch

Hi,

I'm trying to boot a LoongArch Linux via the direct kernel mode of qemu.
( qemu -kernel vmlinux -append "verbose" )
This doesn't work so well.

A few problems I encoutered:

* Linux reads the cmdline from $a1 during boot, but qemu doesn't place it there.
* Qemu puts a FDT at 1MiB but Linux doesn't use it.
* Qemu does not put the cmdline into the FDT.
* Linux panics in memory_present() because memblock_init() in
  arch/loongarch/kernel/mem.c did not set up any memblocks.
* Qemu has no support for initrds in direct kernel mode on LoongArch.

(All observations based on current git versions)

For the other architectures I'm using Linux/qemu with the direct kernel
mode works nicely including cmdline and initrds.

Are these restrictions by design/intentional or is it just for somebody
to do the necessary legwork?

The direct kernel mode is nice because it does not require the
installation of the additional EFI binary.


Thanks,
Thomas

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2023-10-09 20:13 qemu direct kernel boot on LoongArch Thomas Weißschuh
@ 2023-10-10  1:12 ` maobibo
  2024-09-05  3:12   ` Jason A. Donenfeld
  0 siblings, 1 reply; 19+ messages in thread
From: maobibo @ 2023-10-10  1:12 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: loongarch, qemu-devel

Thomas,

Thanks for reporting this issue.

It is the problem of QEMU for LoongArch system, QEMU does not support 
booting vmlinux with elf format without UEFI bios now. We will add 
support to boot vmlinux directly on QEMU LoongArch side.

Regards
Bibo Mao

在 2023/10/10 上午4:13, Thomas Weißschuh 写道:
> Hi,
> 
> I'm trying to boot a LoongArch Linux via the direct kernel mode of qemu.
> ( qemu -kernel vmlinux -append "verbose" )
> This doesn't work so well.
> 
> A few problems I encoutered:
> 
> * Linux reads the cmdline from $a1 during boot, but qemu doesn't place it there.
> * Qemu puts a FDT at 1MiB but Linux doesn't use it.
> * Qemu does not put the cmdline into the FDT.
> * Linux panics in memory_present() because memblock_init() in
>    arch/loongarch/kernel/mem.c did not set up any memblocks.
> * Qemu has no support for initrds in direct kernel mode on LoongArch.
> 
> (All observations based on current git versions)
> 
> For the other architectures I'm using Linux/qemu with the direct kernel
> mode works nicely including cmdline and initrds.
> 
> Are these restrictions by design/intentional or is it just for somebody
> to do the necessary legwork?
> 
> The direct kernel mode is nice because it does not require the
> installation of the additional EFI binary.
> 
> 
> Thanks,
> Thomas
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2023-10-10  1:12 ` maobibo
@ 2024-09-05  3:12   ` Jason A. Donenfeld
  2024-09-05  3:45     ` maobibo
  0 siblings, 1 reply; 19+ messages in thread
From: Jason A. Donenfeld @ 2024-09-05  3:12 UTC (permalink / raw)
  To: maobibo; +Cc: Thomas Weißschuh, loongarch, qemu-devel, xry111

On Tue, Oct 10, 2023 at 09:12:46AM +0800, maobibo wrote:
> Thomas,
> 
> Thanks for reporting this issue.
> 
> It is the problem of QEMU for LoongArch system, QEMU does not support 
> booting vmlinux with elf format without UEFI bios now. We will add 
> support to boot vmlinux directly on QEMU LoongArch side.

I ran into this same issue when trying to boot my test kernel for
Ruoyao's recent vDSO getrandom work. Is this something that was ever
addressed on the QEMU side?

Jason

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05  3:12   ` Jason A. Donenfeld
@ 2024-09-05  3:45     ` maobibo
  2024-09-05  4:04       ` Jason A. Donenfeld
  0 siblings, 1 reply; 19+ messages in thread
From: maobibo @ 2024-09-05  3:45 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: Thomas Weißschuh, loongarch, qemu-devel, xry111

Jason,

With the latest qemu 9.1 version, elf format booting is supported. Qemu 
9.0 does not support it still, here is example command line.

./qemu-system-loongarch64  -m 4G -smp 2 --cpu la464 --machine virt 
-serial stdio   -monitor telnet:localhost:4495,server,nowait -kernel 
/root/linux_larch/vmlinux -initrd ramdisk  -append "root=/dev/ram 
rdinit=/sbin/init console=ttyS0,115200" --nographic

Regards
Bibo Mao

On 2024/9/5 上午11:12, Jason A. Donenfeld wrote:
> On Tue, Oct 10, 2023 at 09:12:46AM +0800, maobibo wrote:
>> Thomas,
>>
>> Thanks for reporting this issue.
>>
>> It is the problem of QEMU for LoongArch system, QEMU does not support
>> booting vmlinux with elf format without UEFI bios now. We will add
>> support to boot vmlinux directly on QEMU LoongArch side.
> 
> I ran into this same issue when trying to boot my test kernel for
> Ruoyao's recent vDSO getrandom work. Is this something that was ever
> addressed on the QEMU side?
> 
> Jason
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05  3:45     ` maobibo
@ 2024-09-05  4:04       ` Jason A. Donenfeld
  2024-09-05  5:25         ` Thomas Weißschuh
  0 siblings, 1 reply; 19+ messages in thread
From: Jason A. Donenfeld @ 2024-09-05  4:04 UTC (permalink / raw)
  To: maobibo; +Cc: Thomas Weißschuh, loongarch, qemu-devel, xry111

On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
>
> Jason,
>
> With the latest qemu 9.1 version, elf format booting is supported.

Thanks, I just figured this out too, about 4 minutes ago. Excellent.
And the 1G minimum ram limit is gone too.

Now working on how to trigger resets.

Jason

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05  4:04       ` Jason A. Donenfeld
@ 2024-09-05  5:25         ` Thomas Weißschuh
  2024-09-05  6:11           ` maobibo
  2024-09-05 14:53           ` Jason A. Donenfeld
  0 siblings, 2 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2024-09-05  5:25 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: maobibo, loongarch, qemu-devel, xry111

On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
> On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
> >
> > Jason,
> >
> > With the latest qemu 9.1 version, elf format booting is supported.
> 
> Thanks, I just figured this out too, about 4 minutes ago. Excellent.
> And the 1G minimum ram limit is gone too.
> 
> Now working on how to trigger resets.

With "reset" do you mean normal (non-panic) system shutdown/poweroff?
Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
that in a cross-architecture way.


Thomas

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05  5:25         ` Thomas Weißschuh
@ 2024-09-05  6:11           ` maobibo
  2024-09-05 14:54             ` Jason A. Donenfeld
  2024-09-05 14:53           ` Jason A. Donenfeld
  1 sibling, 1 reply; 19+ messages in thread
From: maobibo @ 2024-09-05  6:11 UTC (permalink / raw)
  To: Thomas Weißschuh, Jason A. Donenfeld; +Cc: loongarch, qemu-devel, xry111



On 2024/9/5 下午1:25, Thomas Weißschuh wrote:
> On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
>> On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
>>>
>>> Jason,
>>>
>>> With the latest qemu 9.1 version, elf format booting is supported.
>>
>> Thanks, I just figured this out too, about 4 minutes ago. Excellent.
>> And the 1G minimum ram limit is gone too.
>>
>> Now working on how to trigger resets.
> 
> With "reset" do you mean normal (non-panic) system shutdown/poweroff?
> Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
> that in a cross-architecture way.
LoongArch uses acpi GED device to reboot machine. Now there is no FDT 
table description and FDT driver for acpi GED device :(

We will investigate pvpanic method.

Regards
Bibo Mao
> 
> 
> Thomas
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05  5:25         ` Thomas Weißschuh
  2024-09-05  6:11           ` maobibo
@ 2024-09-05 14:53           ` Jason A. Donenfeld
  2024-09-05 15:05             ` Thomas Weißschuh
  1 sibling, 1 reply; 19+ messages in thread
From: Jason A. Donenfeld @ 2024-09-05 14:53 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: maobibo, loongarch, qemu-devel, xry111

On Thu, Sep 05, 2024 at 07:25:05AM +0200, Thomas Weißschuh wrote:
> On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
> > On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
> > >
> > > Jason,
> > >
> > > With the latest qemu 9.1 version, elf format booting is supported.
> > 
> > Thanks, I just figured this out too, about 4 minutes ago. Excellent.
> > And the 1G minimum ram limit is gone too.
> > 
> > Now working on how to trigger resets.
> 
> With "reset" do you mean normal (non-panic) system shutdown/poweroff?
> Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
> that in a cross-architecture way.

What I mean is that I need for userspace calling `reboot(RB_AUTOBOOT);`
to actually result in QEMU being told to reboot the system. Sounds like
that's not possible (yet?) in 9.1?

The last hurdle I'm having, in addition to that one, is getting the
second serial port working. The kernel test suite that I'm running in CI
for /dev/urandom development and wireguard development does `-serial
stdio -serial chardev:result`, where the first serial is the normal
output for logging, and the second one is the test result, so I can get
that from the VM via a clean channel. This works well on other
architectures, but on loongarch, it's failing to open /dev/ttyS1 the
same way that it can open /dev/ttyS0.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05  6:11           ` maobibo
@ 2024-09-05 14:54             ` Jason A. Donenfeld
  2024-09-05 15:49               ` Jason A. Donenfeld
  0 siblings, 1 reply; 19+ messages in thread
From: Jason A. Donenfeld @ 2024-09-05 14:54 UTC (permalink / raw)
  To: maobibo; +Cc: Thomas Weißschuh, loongarch, qemu-devel, xry111

On Thu, Sep 05, 2024 at 02:11:32PM +0800, maobibo wrote:
> 
> 
> On 2024/9/5 下午1:25, Thomas Weißschuh wrote:
> > On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
> >> On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
> >>>
> >>> Jason,
> >>>
> >>> With the latest qemu 9.1 version, elf format booting is supported.
> >>
> >> Thanks, I just figured this out too, about 4 minutes ago. Excellent.
> >> And the 1G minimum ram limit is gone too.
> >>
> >> Now working on how to trigger resets.
> > 
> > With "reset" do you mean normal (non-panic) system shutdown/poweroff?
> > Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
> > that in a cross-architecture way.
> LoongArch uses acpi GED device to reboot machine. Now there is no FDT 
> table description and FDT driver for acpi GED device :(

So you mean that QEMU exposes it via ACPI, but not via FDT, and the
kernel doesn't know how to recognize it, even with ACPI?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05 14:53           ` Jason A. Donenfeld
@ 2024-09-05 15:05             ` Thomas Weißschuh
  2024-09-05 15:07               ` Jason A. Donenfeld
  0 siblings, 1 reply; 19+ messages in thread
From: Thomas Weißschuh @ 2024-09-05 15:05 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: maobibo, loongarch, qemu-devel, xry111

On 2024-09-05 16:53:55+0000, Jason A. Donenfeld wrote:
> On Thu, Sep 05, 2024 at 07:25:05AM +0200, Thomas Weißschuh wrote:
> > On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
> > > On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
> > > >
> > > > Jason,
> > > >
> > > > With the latest qemu 9.1 version, elf format booting is supported.
> > > 
> > > Thanks, I just figured this out too, about 4 minutes ago. Excellent.
> > > And the 1G minimum ram limit is gone too.
> > > 
> > > Now working on how to trigger resets.
> > 
> > With "reset" do you mean normal (non-panic) system shutdown/poweroff?
> > Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
> > that in a cross-architecture way.
> 
> What I mean is that I need for userspace calling `reboot(RB_AUTOBOOT);`
> to actually result in QEMU being told to reboot the system. Sounds like
> that's not possible (yet?) in 9.1?

With reboot(RB_POWER_OFF) this is indeed the exact usecase for pvpanic
shutdown support. Reboot is not supported, but maybe -action
shutdown=reboot works and is enough. It would also be trivial to extend
pvpanic for reboot support.

Use -device pvpanic-pci for QEMU and CONFIG_PVPANIC_PCI=y for Linux.
(That should work for most architectures)

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05 15:05             ` Thomas Weißschuh
@ 2024-09-05 15:07               ` Jason A. Donenfeld
  2024-09-05 15:16                 ` Thomas Weißschuh
  0 siblings, 1 reply; 19+ messages in thread
From: Jason A. Donenfeld @ 2024-09-05 15:07 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: maobibo, loongarch, qemu-devel, xry111

On Thu, Sep 5, 2024 at 5:05 PM Thomas Weißschuh <thomas@t-8ch.de> wrote:
>
> On 2024-09-05 16:53:55+0000, Jason A. Donenfeld wrote:
> > On Thu, Sep 05, 2024 at 07:25:05AM +0200, Thomas Weißschuh wrote:
> > > On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
> > > > On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
> > > > >
> > > > > Jason,
> > > > >
> > > > > With the latest qemu 9.1 version, elf format booting is supported.
> > > >
> > > > Thanks, I just figured this out too, about 4 minutes ago. Excellent.
> > > > And the 1G minimum ram limit is gone too.
> > > >
> > > > Now working on how to trigger resets.
> > >
> > > With "reset" do you mean normal (non-panic) system shutdown/poweroff?
> > > Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
> > > that in a cross-architecture way.
> >
> > What I mean is that I need for userspace calling `reboot(RB_AUTOBOOT);`
> > to actually result in QEMU being told to reboot the system. Sounds like
> > that's not possible (yet?) in 9.1?
>
> With reboot(RB_POWER_OFF) this is indeed the exact usecase for pvpanic

I'm actually using reboot(RB_AUTOBOOT) wth QEMU's -no-reboot, because
that tends to be far more compatible with a greater number of
platforms, for example, x86 without acpi. Shucks.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05 15:07               ` Jason A. Donenfeld
@ 2024-09-05 15:16                 ` Thomas Weißschuh
  2024-09-05 15:18                   ` Jason A. Donenfeld
  0 siblings, 1 reply; 19+ messages in thread
From: Thomas Weißschuh @ 2024-09-05 15:16 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: maobibo, loongarch, qemu-devel, xry111

On 2024-09-05 17:07:22+0000, Jason A. Donenfeld wrote:
> On Thu, Sep 5, 2024 at 5:05 PM Thomas Weißschuh <thomas@t-8ch.de> wrote:
> >
> > On 2024-09-05 16:53:55+0000, Jason A. Donenfeld wrote:
> > > On Thu, Sep 05, 2024 at 07:25:05AM +0200, Thomas Weißschuh wrote:
> > > > On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
> > > > > On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
> > > > > >
> > > > > > Jason,
> > > > > >
> > > > > > With the latest qemu 9.1 version, elf format booting is supported.
> > > > >
> > > > > Thanks, I just figured this out too, about 4 minutes ago. Excellent.
> > > > > And the 1G minimum ram limit is gone too.
> > > > >
> > > > > Now working on how to trigger resets.
> > > >
> > > > With "reset" do you mean normal (non-panic) system shutdown/poweroff?
> > > > Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
> > > > that in a cross-architecture way.
> > >
> > > What I mean is that I need for userspace calling `reboot(RB_AUTOBOOT);`
> > > to actually result in QEMU being told to reboot the system. Sounds like
> > > that's not possible (yet?) in 9.1?
> >
> > With reboot(RB_POWER_OFF) this is indeed the exact usecase for pvpanic
> 
> I'm actually using reboot(RB_AUTOBOOT) wth QEMU's -no-reboot, because
> that tends to be far more compatible with a greater number of
> platforms, for example, x86 without acpi. Shucks.

You can check that both QEMU and the kernel support pvpanic shutdown
through sysfs and if so use reboot(RB_POWER_OFF); and
reboot(RB_AUTOBOOT) otherwise.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05 15:16                 ` Thomas Weißschuh
@ 2024-09-05 15:18                   ` Jason A. Donenfeld
  2024-09-05 16:03                     ` Thomas Weißschuh
  0 siblings, 1 reply; 19+ messages in thread
From: Jason A. Donenfeld @ 2024-09-05 15:18 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: maobibo, loongarch, qemu-devel, xry111

On Thu, Sep 5, 2024 at 5:16 PM Thomas Weißschuh <thomas@t-8ch.de> wrote:
>
> On 2024-09-05 17:07:22+0000, Jason A. Donenfeld wrote:
> > On Thu, Sep 5, 2024 at 5:05 PM Thomas Weißschuh <thomas@t-8ch.de> wrote:
> > >
> > > On 2024-09-05 16:53:55+0000, Jason A. Donenfeld wrote:
> > > > On Thu, Sep 05, 2024 at 07:25:05AM +0200, Thomas Weißschuh wrote:
> > > > > On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
> > > > > > On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
> > > > > > >
> > > > > > > Jason,
> > > > > > >
> > > > > > > With the latest qemu 9.1 version, elf format booting is supported.
> > > > > >
> > > > > > Thanks, I just figured this out too, about 4 minutes ago. Excellent.
> > > > > > And the 1G minimum ram limit is gone too.
> > > > > >
> > > > > > Now working on how to trigger resets.
> > > > >
> > > > > With "reset" do you mean normal (non-panic) system shutdown/poweroff?
> > > > > Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
> > > > > that in a cross-architecture way.
> > > >
> > > > What I mean is that I need for userspace calling `reboot(RB_AUTOBOOT);`
> > > > to actually result in QEMU being told to reboot the system. Sounds like
> > > > that's not possible (yet?) in 9.1?
> > >
> > > With reboot(RB_POWER_OFF) this is indeed the exact usecase for pvpanic
> >
> > I'm actually using reboot(RB_AUTOBOOT) wth QEMU's -no-reboot, because
> > that tends to be far more compatible with a greater number of
> > platforms, for example, x86 without acpi. Shucks.
>
> You can check that both QEMU and the kernel support pvpanic shutdown
> through sysfs and if so use reboot(RB_POWER_OFF); and
> reboot(RB_AUTOBOOT) otherwise.

I guess. But the whole idea is to bloat the code as little as possible
and use one interface for everything. Pushing that all up into
userspace is pretty icky.

It sounds like LoongArch already supports this via ACPI GED, but
there's some plumbing that needs to be done still. So maybe I'll just
wait for that.

Meanwhile, any idea about adding a second serial to the platform? I've
been futzing with it for a bit now to no avail.

Jason

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05 14:54             ` Jason A. Donenfeld
@ 2024-09-05 15:49               ` Jason A. Donenfeld
  2024-09-06  1:09                 ` maobibo
  0 siblings, 1 reply; 19+ messages in thread
From: Jason A. Donenfeld @ 2024-09-05 15:49 UTC (permalink / raw)
  To: maobibo; +Cc: Thomas Weißschuh, loongarch, qemu-devel, xry111

On Thu, Sep 05, 2024 at 04:54:41PM +0200, Jason A. Donenfeld wrote:
> On Thu, Sep 05, 2024 at 02:11:32PM +0800, maobibo wrote:
> > 
> > 
> > On 2024/9/5 下午1:25, Thomas Weißschuh wrote:
> > > On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
> > >> On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
> > >>>
> > >>> Jason,
> > >>>
> > >>> With the latest qemu 9.1 version, elf format booting is supported.
> > >>
> > >> Thanks, I just figured this out too, about 4 minutes ago. Excellent.
> > >> And the 1G minimum ram limit is gone too.
> > >>
> > >> Now working on how to trigger resets.
> > > 
> > > With "reset" do you mean normal (non-panic) system shutdown/poweroff?
> > > Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
> > > that in a cross-architecture way.
> > LoongArch uses acpi GED device to reboot machine. Now there is no FDT 
> > table description and FDT driver for acpi GED device :(
> 
> So you mean that QEMU exposes it via ACPI, but not via FDT, and the
> kernel doesn't know how to recognize it, even with ACPI?

Ahh, it looks like QEMU exposes it via ACPI, but ACPI is broken (?) when
booting directly from ELF. So it needs to be exposed via FDT instead? Or
ACPI needs to be fixed with direct ELF boot?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05 15:18                   ` Jason A. Donenfeld
@ 2024-09-05 16:03                     ` Thomas Weißschuh
  2024-09-06  1:14                       ` maobibo
  0 siblings, 1 reply; 19+ messages in thread
From: Thomas Weißschuh @ 2024-09-05 16:03 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: maobibo, loongarch, qemu-devel, xry111

On 2024-09-05 17:18:07+0000, Jason A. Donenfeld wrote:
> On Thu, Sep 5, 2024 at 5:16 PM Thomas Weißschuh <thomas@t-8ch.de> wrote:
> >
> > On 2024-09-05 17:07:22+0000, Jason A. Donenfeld wrote:
> > > On Thu, Sep 5, 2024 at 5:05 PM Thomas Weißschuh <thomas@t-8ch.de> wrote:
> > > >
> > > > On 2024-09-05 16:53:55+0000, Jason A. Donenfeld wrote:
> > > > > On Thu, Sep 05, 2024 at 07:25:05AM +0200, Thomas Weißschuh wrote:
> > > > > > On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
> > > > > > > On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
> > > > > > > >
> > > > > > > > Jason,
> > > > > > > >
> > > > > > > > With the latest qemu 9.1 version, elf format booting is supported.
> > > > > > >
> > > > > > > Thanks, I just figured this out too, about 4 minutes ago. Excellent.
> > > > > > > And the 1G minimum ram limit is gone too.
> > > > > > >
> > > > > > > Now working on how to trigger resets.
> > > > > >
> > > > > > With "reset" do you mean normal (non-panic) system shutdown/poweroff?
> > > > > > Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
> > > > > > that in a cross-architecture way.
> > > > >
> > > > > What I mean is that I need for userspace calling `reboot(RB_AUTOBOOT);`
> > > > > to actually result in QEMU being told to reboot the system. Sounds like
> > > > > that's not possible (yet?) in 9.1?
> > > >
> > > > With reboot(RB_POWER_OFF) this is indeed the exact usecase for pvpanic
> > >
> > > I'm actually using reboot(RB_AUTOBOOT) wth QEMU's -no-reboot, because
> > > that tends to be far more compatible with a greater number of
> > > platforms, for example, x86 without acpi. Shucks.
> >
> > You can check that both QEMU and the kernel support pvpanic shutdown
> > through sysfs and if so use reboot(RB_POWER_OFF); and
> > reboot(RB_AUTOBOOT) otherwise.
> 
> I guess. But the whole idea is to bloat the code as little as possible
> and use one interface for everything. Pushing that all up into
> userspace is pretty icky.

If it works through ACPI everywhere then sure.

> It sounds like LoongArch already supports this via ACPI GED, but
> there's some plumbing that needs to be done still. So maybe I'll just
> wait for that.

Also sounds reasonable.

> Meanwhile, any idea about adding a second serial to the platform? I've
> been futzing with it for a bit now to no avail.

No idea, sorry.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05 15:49               ` Jason A. Donenfeld
@ 2024-09-06  1:09                 ` maobibo
  0 siblings, 0 replies; 19+ messages in thread
From: maobibo @ 2024-09-06  1:09 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: Thomas Weißschuh, loongarch, qemu-devel, xry111



On 2024/9/5 下午11:49, Jason A. Donenfeld wrote:
> On Thu, Sep 05, 2024 at 04:54:41PM +0200, Jason A. Donenfeld wrote:
>> On Thu, Sep 05, 2024 at 02:11:32PM +0800, maobibo wrote:
>>>
>>>
>>> On 2024/9/5 下午1:25, Thomas Weißschuh wrote:
>>>> On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
>>>>> On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
>>>>>>
>>>>>> Jason,
>>>>>>
>>>>>> With the latest qemu 9.1 version, elf format booting is supported.
>>>>>
>>>>> Thanks, I just figured this out too, about 4 minutes ago. Excellent.
>>>>> And the 1G minimum ram limit is gone too.
>>>>>
>>>>> Now working on how to trigger resets.
>>>>
>>>> With "reset" do you mean normal (non-panic) system shutdown/poweroff?
>>>> Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
>>>> that in a cross-architecture way.
>>> LoongArch uses acpi GED device to reboot machine. Now there is no FDT
>>> table description and FDT driver for acpi GED device :(
>>
>> So you mean that QEMU exposes it via ACPI, but not via FDT, and the
>> kernel doesn't know how to recognize it, even with ACPI?
> 
> Ahh, it looks like QEMU exposes it via ACPI, but ACPI is broken (?) when
> booting directly from ELF. So it needs to be exposed via FDT instead? Or
> ACPI needs to be fixed with direct ELF boot?
We plant to expose ACPI GED via FDT interface with syscon method, and 
the reboot driver in linux kernel side is
drivers/power/reset/syscon-reboot.c.

The only difference is that ACPI GED register is accessed with 
byte-mode, it seems that it works well with draft version.

Regards
Bibo Mao
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-05 16:03                     ` Thomas Weißschuh
@ 2024-09-06  1:14                       ` maobibo
  2024-09-06  4:04                         ` Jason A. Donenfeld
  0 siblings, 1 reply; 19+ messages in thread
From: maobibo @ 2024-09-06  1:14 UTC (permalink / raw)
  To: Thomas Weißschuh, Jason A. Donenfeld; +Cc: loongarch, qemu-devel, xry111



On 2024/9/6 上午12:03, Thomas Weißschuh wrote:
> On 2024-09-05 17:18:07+0000, Jason A. Donenfeld wrote:
>> On Thu, Sep 5, 2024 at 5:16 PM Thomas Weißschuh <thomas@t-8ch.de> wrote:
>>>
>>> On 2024-09-05 17:07:22+0000, Jason A. Donenfeld wrote:
>>>> On Thu, Sep 5, 2024 at 5:05 PM Thomas Weißschuh <thomas@t-8ch.de> wrote:
>>>>>
>>>>> On 2024-09-05 16:53:55+0000, Jason A. Donenfeld wrote:
>>>>>> On Thu, Sep 05, 2024 at 07:25:05AM +0200, Thomas Weißschuh wrote:
>>>>>>> On 2024-09-05 06:04:12+0000, Jason A. Donenfeld wrote:
>>>>>>>> On Thu, Sep 5, 2024 at 5:45 AM maobibo <maobibo@loongson.cn> wrote:
>>>>>>>>>
>>>>>>>>> Jason,
>>>>>>>>>
>>>>>>>>> With the latest qemu 9.1 version, elf format booting is supported.
>>>>>>>>
>>>>>>>> Thanks, I just figured this out too, about 4 minutes ago. Excellent.
>>>>>>>> And the 1G minimum ram limit is gone too.
>>>>>>>>
>>>>>>>> Now working on how to trigger resets.
>>>>>>>
>>>>>>> With "reset" do you mean normal (non-panic) system shutdown/poweroff?
>>>>>>> Since QEMU 9.1 and a recent kernel you can use the pvpanic device for
>>>>>>> that in a cross-architecture way.
>>>>>>
>>>>>> What I mean is that I need for userspace calling `reboot(RB_AUTOBOOT);`
>>>>>> to actually result in QEMU being told to reboot the system. Sounds like
>>>>>> that's not possible (yet?) in 9.1?
>>>>>
>>>>> With reboot(RB_POWER_OFF) this is indeed the exact usecase for pvpanic
>>>>
>>>> I'm actually using reboot(RB_AUTOBOOT) wth QEMU's -no-reboot, because
>>>> that tends to be far more compatible with a greater number of
>>>> platforms, for example, x86 without acpi. Shucks.
>>>
>>> You can check that both QEMU and the kernel support pvpanic shutdown
>>> through sysfs and if so use reboot(RB_POWER_OFF); and
>>> reboot(RB_AUTOBOOT) otherwise.
>>
>> I guess. But the whole idea is to bloat the code as little as possible
>> and use one interface for everything. Pushing that all up into
>> userspace is pretty icky.
> 
> If it works through ACPI everywhere then sure.
> 
>> It sounds like LoongArch already supports this via ACPI GED, but
>> there's some plumbing that needs to be done still. So maybe I'll just
>> wait for that.
> 
> Also sounds reasonable.
yeap, will submit a patch to expose ACPI GED pm interface with FDT method.

> 
>> Meanwhile, any idea about adding a second serial to the platform? I've
>> been futzing with it for a bit now to no avail.
> 
> No idea, sorry.
Will investigate the second serial method.

Regards
Bibo Mao


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-06  1:14                       ` maobibo
@ 2024-09-06  4:04                         ` Jason A. Donenfeld
  2024-09-06  4:48                           ` Jason A. Donenfeld
  0 siblings, 1 reply; 19+ messages in thread
From: Jason A. Donenfeld @ 2024-09-06  4:04 UTC (permalink / raw)
  To: maobibo; +Cc: Thomas Weißschuh, loongarch, qemu-devel, xry111

On Fri, Sep 6, 2024 at 3:14 AM maobibo <maobibo@loongson.cn> wrote:
> yeap, will submit a patch to expose ACPI GED pm interface with FDT method.

Clever trick. Works well.

>
> >
> >> Meanwhile, any idea about adding a second serial to the platform? I've
> >> been futzing with it for a bit now to no avail.
> >
> > No idea, sorry.
> Will investigate the second serial method.

Thank you very much.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu direct kernel boot on LoongArch
  2024-09-06  4:04                         ` Jason A. Donenfeld
@ 2024-09-06  4:48                           ` Jason A. Donenfeld
  0 siblings, 0 replies; 19+ messages in thread
From: Jason A. Donenfeld @ 2024-09-06  4:48 UTC (permalink / raw)
  To: maobibo; +Cc: Thomas Weißschuh, loongarch, qemu-devel, xry111

On Fri, Sep 06, 2024 at 06:04:25AM +0200, Jason A. Donenfeld wrote:
> On Fri, Sep 6, 2024 at 3:14 AM maobibo <maobibo@loongson.cn> wrote:
> > yeap, will submit a patch to expose ACPI GED pm interface with FDT method.
> 
> Clever trick. Works well.
> 
> >
> > >
> > >> Meanwhile, any idea about adding a second serial to the platform? I've
> > >> been futzing with it for a bit now to no avail.
> > >
> > > No idea, sorry.
> > Will investigate the second serial method.
> 
> Thank you very much.

I did it. I'll send a patch.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-09-06  4:49 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-09 20:13 qemu direct kernel boot on LoongArch Thomas Weißschuh
2023-10-10  1:12 ` maobibo
2024-09-05  3:12   ` Jason A. Donenfeld
2024-09-05  3:45     ` maobibo
2024-09-05  4:04       ` Jason A. Donenfeld
2024-09-05  5:25         ` Thomas Weißschuh
2024-09-05  6:11           ` maobibo
2024-09-05 14:54             ` Jason A. Donenfeld
2024-09-05 15:49               ` Jason A. Donenfeld
2024-09-06  1:09                 ` maobibo
2024-09-05 14:53           ` Jason A. Donenfeld
2024-09-05 15:05             ` Thomas Weißschuh
2024-09-05 15:07               ` Jason A. Donenfeld
2024-09-05 15:16                 ` Thomas Weißschuh
2024-09-05 15:18                   ` Jason A. Donenfeld
2024-09-05 16:03                     ` Thomas Weißschuh
2024-09-06  1:14                       ` maobibo
2024-09-06  4:04                         ` Jason A. Donenfeld
2024-09-06  4:48                           ` Jason A. Donenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox