On Sun, May 31, 2020 at 03:22:45PM +0200, Otto Moerbeek wrote: > On Sun, May 31, 2020 at 09:49:34AM +0100, Mark Cave-Ayland wrote: > > Thanks for the test case which enables me to reproduce the issue. With > > ?fcode-verbose > > enabled you see this at the end of the FCode execution: FWIW, on latest OpenBoot on machines such as the T4-2 there exists no other variable but fcode-debug?.
> > Now that 0x8a is completely wrong since according to > > https://github.com/openbsd/src/blob/master/sys/arch/sparc64/stand/bootblk/bootblk.fth > > the last instruction should be exit which is 0x33. > > > > Since the FCode itself is located at load-base (0x4000) it looks to me from > > the above > > debug that you're loading ofwboot at the same address, overwriting the > > FCode. Once > > do-boot has finished executing, the FCode interpreter returns to execute > > the exit > > word which has now been overwritten: so instead of returning to the updated > > client > > context via exit to execute ofwboot, it executes expect which asks for > > input from the > > keyboard and then crashes because the stack is incorrect. > > > > My recommendation would be to load ofwboot at 0x6000 instead of 0x4000 > > which I > > believe will fix the issue. It's interesting you mention that this works on > > real > > hardware, since it doesn't agree with my reading of the IEEE-1275 > > specification so > > you're certainly relying on some undocumented behaviour here. Neither Forth nor boot blocks are my area of good expertise, but your analysis reads fine to me. > Thanks, the following works indeed. I threw the diff (with minor crank) onto a guest domain on my T4-2 box that I'm currently using for CURRENT ofwboot testing and it continues to work just fine: {0} ok setenv fcode-debug? true fcode-debug? = true {0} ok boot -V NOTICE: Entering OpenBoot. NOTICE: Fetching Guest MD from HV. NOTICE: Starting additional cpus. NOTICE: Initializing LDC services. NOTICE: Probing PCI devices. NOTICE: Finished PCI probing. SPARC T4-2, No Keyboard Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. OpenBoot 4.38.16, 8.0000 GB memory available, Serial #xxx. Ethernet address xxx, Host ID: xxx. Boot device: /virtual-devices@100/channel-devices@200/disk@0 File and args: -V OpenBSD IEEE 1275 Bootblock 2.1 Booting from device /virtual-devices@100/channel-devices@200/disk@0 Try superblock read FFS v2 ufs-open complete .Looking for ofwboot in directory... . .. home tmp usr var bsd sys bsd.rd altroot bin dev etc mnt root sbin .cshrc .profile ofwboot Found it .Loading 1a398 bytes of file... Copying 4000 bytes to 6000 Copying 4000 bytes to a000 Copying 4000 bytes to e000 Copying 4000 bytes to 12000 Copying 4000 bytes to 16000 Copying 4000 bytes to 1a000 Copying 2800 bytes to 1e000 >> OpenBSD BOOT 1.21