On 10/10/22 17:53, Warner Losh wrote:
On Mon, Oct 10, 2022 at 10:56 AM Warner Losh <i...@bsdimp.com> wrote:

I know what's causing this problem. I'll resolve.

tl/dr: _pv_entry.h depends on sys/param.h being included before its use.


https://reviews.freebsd.org/D36927 fixes it by making sys/_pv_entry.h more
self-contained and less reliant on param.h pollution. The kernel includes
that
everywhere it's used, but userland is more hit or miss because
machine/pmap.h
isn't a well defined interface, but is needed for some things sometimes.


I am not sure where this is related, however, there is a change in QEMU:


https://github.com/qemu/qemu/commit/a4a9a4432e2bf280a989ca344466d7375db7993f


Which seems to provide a way around some really long ISA cpu name data that gets caught in sys/riscv/riscv/identcpu.c at around line 113 or
so :


#ifdef FDT
/*
* The ISA string is made up of a small prefix (e.g. rv64) and up to 26 letters * indicating the presence of the 26 possible standard extensions. Therefore 32
 * characters will be sufficient.
 */
#define ISA_NAME_MAXLEN         32
#define ISA_PREFIX              ("rv" __XSTRING(__riscv_xlen))
#define ISA_PREFIX_LEN          (sizeof(ISA_PREFIX) - 1)


So if a person did not know about the new boolean
thingy "short-isa-string" then any attempt to boot
FreeBSD 14.0 on rv64imafdc ends up with a neato
little messy KASSERT :

sedna$
sedna$ uname -apKU
FreeBSD sedna 13.1-RELEASE-p2 FreeBSD 13.1-RELEASE-p2 GENERIC amd64 amd64 1301000 1301000
sedna$ /usr/local/bin/qemu-system-riscv64 --version
QEMU emulator version 7.1.0
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
sedna$
sedna$
sedna$ /usr/local/bin/qemu-system-riscv64 \
> -machine virt -m 32768M -smp 8 -nographic \
> -bios /usr/local/share/opensbi/lp64/generic/firmware/fw_jump.elf \
> -kernel /usr/local/share/u-boot/u-boot-qemu-riscv64/u-boot.bin \
> -drive file=/opt/qemu/riscv/fbsd14/fbsd14_rv64imafdc.qcow2,format=qcow2,id=hd0 \
> -device virtio-blk-device,drive=hd0 \
> -object rng-random,filename=/dev/urandom,id=rng0 \
> -device virtio-rng-device,rng=rng0 \
> -device virtio-net-device,netdev=usernet \
> -netdev user,id=usernet,hostfwd=tcp::10000-:22

OpenSBI v1.1
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 8
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 352 KB
Runtime SBI Version       : 1.0

Domain0 Name              : root
Domain0 Boot HART         : 7
Domain0 HARTs             : 0*,1*,2*,3*,4*,5*,6*,7*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008007ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000082200000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 7
Boot HART Domain          : root
Boot HART Priv Version    : v1.12
Boot HART Base ISA        : rv64imafdch
Boot HART ISA Extensions  : time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 16
Boot HART MIDELEG         : 0x0000000000001666
Boot HART MEDELEG         : 0x0000000000f0b509


U-Boot 2022.04 (Sep 06 2022 - 07:24:53 +0000)

CPU:   rv64imafdch_zicsr_zifencei_zba_zbb_zbc_zbs
Model: riscv-virtio,qemu
DRAM:  32 GiB
Core:  19 devices, 10 uclasses, devicetree: board
Flash: 32 MiB
Loading Environment from nowhere... OK
In:    uart@10000000
Consoles: EFI console
    Reading loader env vars from /efi/freebsd/loader.env
Setting currdev to disk0p1:
FreeBSD/riscv EFI loader, Revision 1.1
(Fri Oct  7 04:52:01 UTC 2022 r...@releng1.nyi.freebsd.org)

   Command line arguments: l
   Image base: 0xfe669000
   EFI version: 2.90
/  ______               ____   _____ _____
  |  ____|             |  _ \ / ____|  __ \
  | |___ _ __ ___  ___ | |_) | (___ | |  | |
  |  ___| '__/ _ \/ _ \|  _ < \___ \| |  | |
  | |   | | |  __/  __/| |_) |____) | |__| |
  | |   | | |    |    ||     |      |      |
|_| |_| \___|\___||____/|_____/|_____/ ``` ` s` `.....---.......--.``` -/ +---------- Welcome to FreeBSD -----------+ +o .--` /y:` +. | | yo`:. :o `+- | 1. Boot Multi user [Enter] | y/ -/` -o/ | 2. Boot Single user | .- ::/sy+:. | 3. Escape to loader prompt | / `-- / | 4. Reboot | `: :` | 5. Cons: Video | `: :` | | / / | Options: | .- -. | 6. Kernel: default/kernel (1 of 1) | -- -.
 |  7. Boot Options                        |       `:`                  `:`
 |                                         |         .--             `--.
 |                                         |            .---.....----.
 +-----------------------------------------+
   Autoboot in 0 seconds. [Space] to pause
Loading kernel...
/boot/kernel/kernel text=0x5b3a88 text=0x175c2c data=0xf4208 data=0x1f74+0x2738dc 0x8+0x1f46fb8+0x8+0xf3f1e
Loading configured modules...
can't find '/etc/hostid'
can't find '/boot/entropy'
Using DTB provided by EFI at 0x87efb000.
Kernel entry at 0xf680002e...
Kernel args: (null)
---<<BOOT>>---
GDB: no debug ports present
KDB: debugger backends: ddb
KDB: current backend: ddb
Copyright (c) 1992-2022 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 14.0-CURRENT #0 main-n258483-b05b1ecbef0: Fri Oct 7 05:52:47 UTC 2022

r...@releng1.nyi.freebsd.org:/usr/obj/usr/src/riscv.riscv64/sys/GENERIC riscv FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
WARNING: WITNESS option enabled, expect reduced performance.
VT: init without driver.
SBI: OpenSBI v1.1
SBI Specification Version: 1.0
CPU(0): Unknown Implementer Unknown Processor
real memory  = 34359738368 (32768 MB)
avail memory = 33401937920 (31854 MB)
Starting CPU 1 (hart 0)
Starting CPU 2 (hart 1)
Starting CPU 3 (hart 2)
Starting CPU 4 (hart 3)
Starting CPU 5 (hart 4)
Starting CPU 6 (hart 5)
Starting CPU 7 (hart 6)
FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs
panic: ISA string truncated
cpuid = 0
time = 1
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_trace_self_wrapper() at db_trace_self_wrapper+0x38
kdb_backtrace() at kdb_backtrace+0x2c
vpanic() at vpanic+0x126
panic() at panic+0x2a
fill_elf_hwcap() at fill_elf_hwcap+0x220
mi_startup() at mi_startup+0x1d2
va() at va+0x7e
KDB: enter: panic
[ thread pid 0 tid 0 ]
Stopped at      kdb_enter+0x4a: sd      zero,0(s1)
db> halt
qemu-system-riscv64: terminating on signal 1 from pid 2765 (csh)
sedna$

due to :

        /*
         * Iterate through the CPUs and examine their ISA string. While we
         * could assign elf_hwcap to be whatever the boot CPU supports, to
         * handle the (unusual) case of running a system with hetergeneous
         * ISAs, keep only the extension bits that are common to all harts.
         */
        for (node = OF_child(node); node > 0; node = OF_peer(node)) {
                /* Skip any non-CPU nodes, such as cpu-map. */
                if (!ofw_bus_node_is_compatible(node, "riscv"))
                        continue;

                len = OF_getprop(node, "riscv,isa", isa, sizeof(isa));
                KASSERT(len <= ISA_NAME_MAXLEN, ("ISA string truncated"));
                if (len == -1) {
                        if (bootverbose)
                                printf("fill_elf_hwcap: "
                                    "Can't find riscv,isa property\n");
                        return;
                } else if (strncmp(isa, ISA_PREFIX, ISA_PREFIX_LEN) != 0) {
                        if (bootverbose)
                                printf("fill_elf_hwcap: "
                                    "Unsupported ISA string: %s\n", isa);
                        return;
                }


again in sys/riscv/riscv/identcpu.c

However this seems to work :

sedna$ /usr/local/bin/qemu-system-riscv64 \
> -machine virt -m 32768M -smp 8 -cpu rv64,short-isa-string=on \
> -nographic \
> -bios /usr/local/share/opensbi/lp64/generic/firmware/fw_jump.elf \
> -kernel /usr/local/share/u-boot/u-boot-qemu-riscv64/u-boot.bin \
> -drive file=/opt/qemu/riscv/fbsd14/fbsd14_rv64imafdc.qcow2,format=qcow2,id=hd0 \
> -device virtio-blk-device,drive=hd0 \
> -object rng-random,filename=/dev/urandom,id=rng0 \
> -device virtio-rng-device,rng=rng0 \
> -device virtio-net-device,netdev=usernet \
> -netdev user,id=usernet,hostfwd=tcp::10000-:22


OpenSBI v1.1
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 8
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 352 KB
Runtime SBI Version       : 1.0

Domain0 Name              : root
Domain0 Boot HART         : 7
Domain0 HARTs             : 0*,1*,2*,3*,4*,5*,6*,7*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008007ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000082200000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 7
Boot HART Domain          : root
Boot HART Priv Version    : v1.12
Boot HART Base ISA        : rv64imafdch
Boot HART ISA Extensions  : time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 16
Boot HART MIDELEG         : 0x0000000000001666
Boot HART MEDELEG         : 0x0000000000f0b509


U-Boot 2022.04 (Sep 06 2022 - 07:24:53 +0000)

CPU:   rv64imafdch
Model: riscv-virtio,qemu
DRAM:  32 GiB
Core:  19 devices, 10 uclasses, devicetree: board
Flash: 32 MiB
Loading Environment from nowhere... OK
In:    uart@10000000
Consoles: EFI console
    Reading loader env vars from /efi/freebsd/loader.env
Setting currdev to disk0p1:
FreeBSD/riscv EFI loader, Revision 1.1
(Fri Oct  7 04:52:01 UTC 2022 r...@releng1.nyi.freebsd.org)

   Command line arguments: l
   Image base: 0xfe669000
   EFI version: 2.90
   ______               ____   _____ _____
  |  ____|             |  _ \ / ____|  __ \
  | |___ _ __ ___  ___ | |_) | (___ | |  | |
  |  ___| '__/ _ \/ _ \|  _ < \___ \| |  | |
  | |   | | |  __/  __/| |_) |____) | |__| |
  | |   | | |    |    ||     |      |      |
|_| |_| \___|\___||____/|_____/|_____/ ``` ` s` `.....---.......--.``` -/ +---------- Welcome to FreeBSD -----------+ +o .--` /y:` +. | | yo`:. :o `+- | 1. Boot Single user [Enter] | y/ -/` -o/ | 2. Boot Multi user | .- ::/sy+:. | 3. Escape to loader prompt | / `-- / | 4. Reboot | `: :` | 5. Cons: Video | `: :` | | / / | Options: | .- -. | 6. Kernel: default/kernel (1 of 1) | -- -.
 |  7. Boot Options                        |       `:`                  `:`
 |                                         |         .--             `--.
 |                                         |            .---.....----.
 +-----------------------------------------+

Loading kernel...
/boot/kernel/kernel text=0x5b3a88 text=0x175c2c data=0xf4208 data=0x1f74+0x2738dc 0x8+0x1f46fb8+0x8+0xf3f1e
Loading configured modules...
can't find '/etc/hostid'
can't find '/boot/entropy'
Using DTB provided by EFI at 0x87efb000.
Kernel entry at 0xf680002e...
Kernel args: (null)
---<<BOOT>>---
GDB: no debug ports present
KDB: debugger backends: ddb
KDB: current backend: ddb
Copyright (c) 1992-2022 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 14.0-CURRENT #0 main-n258483-b05b1ecbef0: Fri Oct 7 05:52:47 UTC 2022

r...@releng1.nyi.freebsd.org:/usr/obj/usr/src/riscv.riscv64/sys/GENERIC riscv FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
WARNING: WITNESS option enabled, expect reduced performance.
VT: init without driver.
SBI: OpenSBI v1.1
SBI Specification Version: 1.0
CPU(0): Unknown Implementer Unknown Processor
real memory  = 34359738368 (32768 MB)
avail memory = 33401909248 (31854 MB)
Starting CPU 1 (hart 0)
Starting CPU 2 (hart 1)
Starting CPU 3 (hart 2)
Starting CPU 4 (hart 3)
Starting CPU 5 (hart 4)
Starting CPU 6 (hart 5)
Starting CPU 7 (hart 6)
FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs
arc4random: WARNING: initial seeding bypassed the cryptographic random device because it was not yet seeded and the knob 'bypass_before_seeding' was enabled.
random: entropy device external interface
kbd0 at kbdmux0
ofwbus0: <Open Firmware Device Tree>
simplebus0: <Flattened device tree simple bus> on ofwbus0
simplebus1: <Flattened device tree simple bus> on ofwbus0
plic0: <RISC-V PLIC> mem 0xc000000-0xc5fffff irq 10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25 on simplebus1
timer0: <RISC-V Timer>
Timecounter "RISC-V Timecounter" frequency 10000000 Hz quality 1000
Event timer "RISC-V Eventtimer" frequency 10000000 Hz quality 1000
riscv_syscon0: <RISC-V syscon> mem 0x100000-0x100fff on simplebus1
rcons0: <RISC-V console>
cpulist0: <Open Firmware CPU Group> on ofwbus0
cpu0: <Open Firmware CPU> on cpulist0
cpu1: <Open Firmware CPU> on cpulist0
cpu2: <Open Firmware CPU> on cpulist0
cpu3: <Open Firmware CPU> on cpulist0
cpu4: <Open Firmware CPU> on cpulist0
cpu5: <Open Firmware CPU> on cpulist0
cpu6: <Open Firmware CPU> on cpulist0
cpu7: <Open Firmware CPU> on cpulist0
goldfish_rtc0: <Goldfish RTC> mem 0x101000-0x101fff irq 0 on simplebus1
goldfish_rtc0: registered as a time-of-day clock, resolution 1.000000s
uart0: <16550 or compatible> mem 0x10000000-0x100000ff irq 1 on simplebus1
uart0: console (115200,n,8,1)
syscon_power0: <Syscon poweroff> on simplebus1
syscon_power1: <Syscon reboot> on simplebus1
pcib0: <Generic PCI host controller> mem 0x30000000-0x3fffffff on simplebus1
pci0: <PCI bus> on pcib0
virtio_mmio0: <VirtIO MMIO adapter> mem 0x10008000-0x10008fff irq 2 on simplebus1
vtblk0: <VirtIO Block Adapter> on virtio_mmio0
vtblk0: 6176MB (12649600 512 byte sectors)
virtio_mmio1: <VirtIO MMIO adapter> mem 0x10007000-0x10007fff irq 3 on simplebus1 virtio_mmio2: <VirtIO MMIO adapter> mem 0x10006000-0x10006fff irq 4 on simplebus1
vtnet0: <VirtIO Networking Adapter> on virtio_mmio2
vtnet0: Ethernet address: 52:54:00:12:34:56
Timecounters tick every 1.000 msec
usb_needs_explore_all: no devclass
Trying to mount root from ufs:/dev/gpt/rootfs [rw]...
Release APs
WARNING: WITNESS option enabled, expect reduced performance.
random: unblocking device.
Enter full pathname of shell or RETURN for /bin/sh:
root@:/ # uname -apKU
FreeBSD 14.0-CURRENT FreeBSD 14.0-CURRENT #0 main-n258483-b05b1ecbef0: Fri Oct 7 05:52:47 UTC 2022 r...@releng1.nyi.freebsd.org:/usr/obj/usr/src/riscv.riscv64/sys/GENERIC riscv riscv64 1400072 1400072
root@:/ # sysctl hw.ncpu
hw.ncpu: 8
root@:/ # sysctl hw.model
sysctl: unknown oid 'hw.model'
root@:/ # sysctl hw.physmem
hw.physmem: 34312138752
root@:/ # shutdown -p 'now'
Shutdown NOW!
shutdown: [pid 22]
root@:/ # wall: can't open temporary file: Read-only file system
2022-10-11T04:17:08.354519+00:00 - shutdown 22 - - power-down by root:

System shutdown time has arrived
Waiting (max 60 seconds) for system process `vnlru' to stop... done
Waiting (max 60 seconds) for system process `syncer' to stop...
Syncing disks, vnodes remaining... 0 0 0 0 0 0 0 0 0 0 done
All buffers synced.
Uptime: 56s
sedna$


Sort of makes me wonder if perhaps a longer cpu ISA name string would
be of any benefit?  I am curious what the string was that tossed the
KASSERT myself.  Also funny that sysctl hw.model returns nothing useful.


--
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional






Reply via email to