Re: "Boot this kernel once" functionality? (amd64)

2020-09-24 Thread John Nemeth
On Sep 24,  9:14am, Reinoud Zandijk wrote:
} Subject: Re: "Boot this kernel once" functionality? (amd64)
} On Wed, Sep 16, 2020 at 12:09:43PM +0200, Martin Husemann wrote:
} > On Wed, Sep 16, 2020 at 12:05:26PM +0200, Anthony Mallet wrote:
} > > I was also wondering if it would be possible to pass arguments to the
} > > primary or secondary bootloader via reboot(2) and the boothowto
} > > flags. But this doesn't seem doable. Right?
} > 
} > This works fine on e.g. sparc*; I can do: shutdown -b netbsd.t -r now
} > 
} > and it will pass "netbsd.t" as boot argument to the firmware, which passes
} > it on to the bootloader and then it boots /netbsd.t once.
} 
} In shutdown(8) I read that the arguments are passed to reboot(8) and that is
} mentioned in kloader(4) so I guess its using that mechanism.
} 
} As for amd64, it would be great if I could boot a kernel once. It could
} simplify testing out a new kernel. Not that a few lines of boot.cfg can't do
} that but still.
} 
} > I don't know if there is enough of a persistent environment for UEFI boots
} > (I would guess there is), and probably no easy way for BIOS boot.
} 
} I could imagine some BIOS/UEFI wiping all DRAM on reboot for security reasons.

 UEFI has the concept of persistent variable storage (key/value
store).  See Section 8.2 "Variable Services" of the UEFI spec.

}-- End of excerpt from Reinoud Zandijk



re: "Boot this kernel once" functionality? (amd64)

2020-09-24 Thread matthew green
Reinoud Zandijk writes:
> On Wed, Sep 16, 2020 at 12:09:43PM +0200, Martin Husemann wrote:
> > On Wed, Sep 16, 2020 at 12:05:26PM +0200, Anthony Mallet wrote:
> > > I was also wondering if it would be possible to pass arguments to the
> > > primary or secondary bootloader via reboot(2) and the boothowto
> > > flags. But this doesn't seem doable. Right?
> > 
> > This works fine on e.g. sparc*; I can do: shutdown -b netbsd.t -r now
> > 
> > and it will pass "netbsd.t" as boot argument to the firmware, which passes
> > it on to the bootloader and then it boots /netbsd.t once.
> 
> In shutdown(8) I read that the arguments are passed to reboot(8) and that is
> mentioned in kloader(4) so I guess its using that mechanism.

this does not use kloader(4), which appeared in netbsd 1.6.
the "pass boot args to loader" appeared in netbsd 1.3, and
it is implemented on sparc* by asking the firmware to reboot
with these arguments instead of the default.  it very much
relies upon this firmware feature.


.mrg.


Re: "Boot this kernel once" functionality? (amd64)

2020-09-24 Thread Reinoud Zandijk
On Wed, Sep 16, 2020 at 12:09:43PM +0200, Martin Husemann wrote:
> On Wed, Sep 16, 2020 at 12:05:26PM +0200, Anthony Mallet wrote:
> > I was also wondering if it would be possible to pass arguments to the
> > primary or secondary bootloader via reboot(2) and the boothowto
> > flags. But this doesn't seem doable. Right?
> 
> This works fine on e.g. sparc*; I can do: shutdown -b netbsd.t -r now
> 
> and it will pass "netbsd.t" as boot argument to the firmware, which passes
> it on to the bootloader and then it boots /netbsd.t once.

In shutdown(8) I read that the arguments are passed to reboot(8) and that is
mentioned in kloader(4) so I guess its using that mechanism.

As for amd64, it would be great if I could boot a kernel once. It could
simplify testing out a new kernel. Not that a few lines of boot.cfg can't do
that but still.

> I don't know if there is enough of a persistent environment for UEFI boots
> (I would guess there is), and probably no easy way for BIOS boot.

I could imagine some BIOS/UEFI wiping all DRAM on reboot for security reasons.

Reinoud



Re: "Boot this kernel once" functionality? (amd64)

2020-09-16 Thread Anthony Mallet
[I noticed that for some reason I was not subscribed anymore to
tech-kern, so I'm manually pasting some replies read from the
mail-index web :/]

Mouse wrote:
> kexec stuff?  I've occasionally wondered why more ports don't implement
> it.

Valery Ushakov wrote:
> As der Mouse mentioned upthread, kloader(4) would seem like a
> promising candidate to implement this.
> Of course that doesn't suit your immediate needs...

I was not aware of kloader(4), thanks!

I don't need an urgent solution, so this looks actually very
promising. I will try to read more about this and get familiar with
the code.

In the meantime, if you (Mouse) come up with something to test or just
draft ideas, I'd be happy to help.


Re: "Boot this kernel once" functionality? (amd64)

2020-09-16 Thread Valery Ushakov
On Wed, Sep 16, 2020 at 12:20:57 +0200, Anthony Mallet wrote:

> On Wednesday 16 Sep 2020, at 12:09, Martin Husemann wrote:
> > This works fine on e.g. sparc*; I can do: shutdown -b netbsd.t -r
> > now
> >
> > No state is modified on any disks, very convenient.
> 
> Right, not changing any state seems safer!
> 
> > I don't know if there is enough of a persistent environment for UEFI
> > boots (I would guess there is), and probably no easy way for BIOS
> > boot.
> 
> The machine in question is not UEFI, so I would be more interested in
> a pure BIOS solution.

As der Mouse mentioned upthread, kloader(4) would seem like a
promising candidate to implement this.  It doesn't support x86
currently, but existing kloader_machdep.c files are minuscule - the
non-boilerplate code is essentially just one function that is
essentially a bit more than a fancy memcpy.  The realy interesting
question is if NetBSD on a given platform leaves the machine in a
state that a newly booted kernel expects the machine to be in.  The
hpc* ports that support kloader do not expect anything much from the
initial state of the machine.

Of course that doesn't suit your immediate needs...

-uwe


Re: "Boot this kernel once" functionality? (amd64)

2020-09-16 Thread Mouse
>> I was wondering how easy that would be to add a "boot once" feature
> FWIW: the Amiga port had a /dev/reload in its very early days, where
> you could cp a kernel too, which would then be bootet.  I'm not sure
> this is easy to make on a PC platform.

kexec stuff?  I've occasionally wondered why more ports don't implement
it.  I ran into it on...hpcmips, maybe.  Something that had WinCE in
ROM and used it as a booter, I think, though those memories are pretty
fuzzy by now.

Certainly would speed up many reboots.  I may have a look at it; I was
recently reading early boot code and I don't recall anything that would
make it difficult.

/~\ The ASCII Mouse
\ / Ribbon Campaign
 X  Against HTMLmo...@rodents-montreal.org
/ \ Email!   7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Re: "Boot this kernel once" functionality? (amd64)

2020-09-16 Thread Hubert Feyrer



On Wed, 16 Sep 2020, Anthony Mallet wrote:

I was wondering how easy that would be to add a "boot once" feature to


FWIW: the Amiga port had a /dev/reload in its very early days, where you 
could cp a kernel too, which would then be bootet. I'm not sure this is 
easy to make on a PC platform.



 - Hubert


Re: "Boot this kernel once" functionality? (amd64)

2020-09-16 Thread Anthony Mallet
On Wednesday 16 Sep 2020, at 12:09, Martin Husemann wrote:
> This works fine on e.g. sparc*; I can do: shutdown -b netbsd.t -r
> now
>
> No state is modified on any disks, very convenient.

Right, not changing any state seems safer!

> I don't know if there is enough of a persistent environment for UEFI
> boots (I would guess there is), and probably no easy way for BIOS
> boot.

The machine in question is not UEFI, so I would be more interested in
a pure BIOS solution.


Re: "Boot this kernel once" functionality? (amd64)

2020-09-16 Thread Martin Husemann
On Wed, Sep 16, 2020 at 12:05:26PM +0200, Anthony Mallet wrote:
> I was also wondering if it would be possible to pass arguments to the
> primary or secondary bootloader via reboot(2) and the boothowto
> flags. But this doesn't seem doable. Right?

This works fine on e.g. sparc*; I can do: shutdown -b netbsd.t -r now

and it will pass "netbsd.t" as boot argument to the firmware, which passes
it on to the bootloader and then it boots /netbsd.t once.

No state is modified on any disks, very convenient.

I don't know if there is enough of a persistent environment for UEFI boots
(I would guess there is), and probably no easy way for BIOS boot.

Martin