Tuesday 25 May 2021

NetBSD/sparc 9.2 on QEMU - System Information

NetBSD

A member of the open source family of Berkeley Software Distribution (BSD) UNIX-like operating systems, along with FreeBSD and OpenBSD, NetBSD is available for a wide range of hardware platforms (Platforms supported by NetBSD), including support for many systems of historical interest.

QEMU and SPARC

The user-space and system emulator QEMU provides emulation of a number of 32-bit SPARC systems. The emulated Sun Microsystems machines are Mbus based 'sun4m' systems, which are widely supported by many operating systems. The first of the 'sun4m' systems, the SPARCserver 600MP series, was launched in 1991, with smaller servers and workstations following. The last of the 'sun4m' line left regular support from Sun back in 2000, but support remained in Solaris 9, which left support in 2014. As such these systems were in common use for well over a decade, and were sufficiently common to be used in control systems as well as in server rooms and as desktops.

The default 32-bit SPARC system emulated in QEMU is the Sun Microsystems SPARCstation 5 (Wikipedia), which is a mid-range UNIX workstation of the mid-1990s. The emulation provides:

  • CPU: microSPARC II
  • RAM: default 128 MiB, max. 256 MiB
  • Disk controller: SCSI Sun esp
  • Network controller: Sun LANCE ethernet (le)
  • Graphics: Sun tcx

For its time these specs are quite respectable, and the server emulations provide alternatives supporting more memory (up to 1,856 MiB in my tests) and additional processors. Since the emulation isn't subject the the limitations of the actual hardware and its connections, processor, disk and network performance often exceed that of the originals.

Note: it is easier to install NetBSD/sparc on QEMU when using the OpenBIOS firmware (QEMU default) than when using Sun's OpenBoot. This suggests that there may be some specific support in NetBSD and QEMU for this configuration.

QEMU Command

For those interested, the emulated system, using OpenBIOS, was started using the command:

$ qemu-system-sparc -machine 'SS-5' -m size=256M -hda hda_NetBSD_sparc.qcow2 -cdrom NetBSD-9.2-sparc.iso -boot c -net nic -net user -name 'NetBSD on SPARCstation 5'

For installation the firmware was told to boot from the installation ISO with -boot d instead of the boot from the system disk option (-boot c) used here.

System Information

So let's see what a current NetBSD release running on an emulated SPARCstation 5 can tell us about the system...

uname

Operating system, version release and platform information.

> uname -a
NetBSD qnetbsd9.home 9.2 NetBSD 9.2 (GENERIC) #0: Wed May 12 13:15:55 UTC 2021  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/sparc/compile/GENERIC sparc

So NetBSD release 9.2, version "NetBSD 9.2 (GENERIC) #0: Wed May 12 13:15:55 UTC 2021  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/sparc/compile/GENERIC" for the SPARC platform running on a node named "qnetbsd9.home".

dmesg

System log messages from boot.

> dmesg
[     1.000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
[     1.000000]     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
[     1.000000]     2018, 2019, 2020 The NetBSD Foundation, Inc.  All rights reserved.
[     1.000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
[     1.000000]     The Regents of the University of California.  All rights reserved.
[     1.000000] NetBSD 9.2 (GENERIC) #0: Wed May 12 13:15:55 UTC 2021
[     1.000000]         mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/sparc/compile/GENERIC
[     1.000000] total memory = 239 MB
[     1.000000] avail memory = 230 MB
[     1.000000] timecounter: Timecounters tick every 10.000 msec
[     1.000000] Kernelized RAIDframe activated
[     1.000000] bootpath: /iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@0,0
[     1.000000] mainbus0 (root): SUNW,SPARCstation-5: hostid 80123456
[     1.000000] cpu0 at mainbus0: FMI,MB86904 @ 170 MHz, MB86910 or WTL1164/5 FPU
[     1.000000] cpu0: 16K instruction (32 b/l), 8K data (16 b/l), 512K external (32 b/l): cache enabled
[     1.000000] obio0 at mainbus0
[     1.000000] clock0 at obio0 slot 0 offset 0x200000: mk48t08
[     1.000000] timer0 at obio0 slot 0 offset 0xd00000: delay constant 130, frequency = 2000000 Hz
[     1.000000] timecounter: Timecounter "timer-counter" frequency 2000000 Hz quality 100
[     1.000006] zs0 at obio0 slot 0 offset 0x100000 level 12 softpri 6
[     1.000006] zstty0 at zs0 channel 0
[     1.000006] zstty1 at zs0 channel 1
[     1.000006] zs1 at obio0 slot 0 offset 0x0 level 12 softpri 6
[     1.000006] zstty4 at zs1 channel 0
[     1.000006] kbd0 at zstty4 (console input)
[     1.000006] zstty5 at zs1 channel 1
[     1.000006] ms0 at zstty5
[     1.000006] wsmouse0 at ms0 mux 0
[     1.000006] fdc0 at obio0 slot 0 offset 0x400000 level 11 softpri 4: chip 82077
[     1.000006] fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
[     1.000006] auxreg0 at obio0 slot 0 offset 0x900000
[     1.000006] power0 at obio0 slot 0 offset 0x910000 level 2
[     1.000006] slavioconfig at obio0 slot 0 offset 0x800000 not configured
[     1.000006] iommu0 at mainbus0 addr 0x10000000: version 0x5/0x0, page-size 4096, range 64MB
[     1.000006] sbus0 at iommu0: clock = 21.250 MHz
[     1.000006] dma0 at sbus0 slot 5 offset 0x8400000: DMA rev 2
[     1.000006] esp0 at dma0 slot 5 offset 0x8800000 level 4: ESP200, 40MHz, SCSI ID 7
[     1.000006] scsibus0 at esp0: 8 targets, 8 luns per target
[     1.000006] ledma0 at sbus0 slot 5 offset 0x8400010: DMA rev 2
[     1.000006] le0 at ledma0 slot 5 offset 0x8c00000 level 6: address 52:54:00:12:34:56
[     1.000006] le0: 8 receive buffers, 2 transmit buffers
[     1.000006] tcx0 at sbus0 slot 3 offset 0x800000 level 5 (ipl 9) (8-bit only TCX)
[     1.000006] tcx0: SUNW,tcx, 1024 x 768
[     1.000006] tcx0: id 0, rev 0, sense 0
[     1.000006] tcx0: autoconfiguration error: (console)
[     1.000006] tcx0: attached to /dev/fb0
[     1.000006] wsdisplay0 at tcx0 kbdmux 1: console (default, vt100 emulation)
[     1.000006] wsmux1: connecting to wsdisplay0
[     1.000006] audiocs0 at sbus0 slot 4 offset 0xc000000 level 5 (ipl 9): CS4231A
[     1.000006] audio0 at audiocs0: playback, capture, full duplex
[     1.000006] audio0: slinear_be:16 -> slinear_le:16 2ch 48000Hz, blk 7680 bytes (40ms) for playback
[     1.000006] audio0: slinear_be:16 <- slinear_le:16 2ch 48000Hz, blk 7680 bytes (40ms) for recording
[     1.000006] power-management at sbus0 slot 4 offset 0xa000000 not configured
[     1.000006] timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
[     1.000006] scsibus0: waiting 2 seconds for devices to settle...
[     1.476555] wskbd0 at kbd0: console keyboard, using wsdisplay0
[     1.603154] kbd0: reset failed
[     3.472713] sd0 at scsibus0 target 0 lun 0: <QEMU, QEMU HARDDISK, 2.5+> disk fixed
[     3.484121] sd0: 9216 MB, 16383 cyl, 16 head, 72 sec, 512 bytes/sect x 18874368 sectors
[     3.502852] cd0 at scsibus0 target 2 lun 0: <QEMU, QEMU CD-ROM, 2.5+> cdrom removable
[     3.543028] WARNING: 1 error while detecting hardware; check system log.
[     3.554421] root on sd0a dumps on sd0b
[     3.573046] root file system type: ffs
[     3.587302] kern.module.path=/stand/sparc/9.2/modules
[     5.882790] esp0: !TC on DATA XFER [intr 18, stat 82, step 4] prevphase 2, resid 0
[     5.895876] esp0: !TC on DATA XFER [intr 10, stat 83, step 0] prevphase 2, resid 0
[     6.723303] esp0: !TC on DATA XFER [intr 18, stat 82, step 4] prevphase 2, resid 0
[     6.734766] esp0: !TC on DATA XFER [intr 10, stat 83, step 0] prevphase 2, resid 0
[     6.752915] esp0: !TC on DATA XFER [intr 18, stat 82, step 4] prevphase 2, resid 0
[     6.752915] esp0: !TC on DATA XFER [intr 10, stat 83, step 0] prevphase 2, resid 0
[    30.543964] esp0: !TC on DATA XFER [intr 18, stat 82, step 4] prevphase 2, resid 0
[    30.560971] esp0: !TC on DATA XFER [intr 10, stat 83, step 0] prevphase 2, resid 0

Lot of information here... some of the highlights are the system memory (256 MiB minus system allocations), the identification of the system as a Sun SPARCstation 5, and the CPU as a microSPARC II at 170 MHz, the SCSI adapter as an ESP200, the graphics as Sun tcx, the appearance of QEMU in the disk drive names, and a few errors from the SCSI bus (presumably an artifact in the emulation).

sysctl

A tool to manipulate system information variables in the kernel. Here I've limited the output to only the hardware related items.

> sysctl -a | grep '^hw'
hw.machine = sparc
hw.model = SUNW,SPARCstation-5 (FMI,MB86904 @ 170 MHz, MB86910 or WTL1164/5 FPU)
hw.ncpu = 1
hw.byteorder = 4321
hw.physmem = 251527168
hw.usermem = 241733632
hw.pagesize = 4096
hw.disknames = fd0 sd0 cd0
hw.machine_arch = sparc
hw.alignbytes = 7
hw.cnmagic = \x01\x4d
hw.physmem64 = 251527168
hw.usermem64 = 241733632
hw.iostatnames = fd0 sd0 cd0
hw.ncpuonline = 1
hw.wsevent.default_version = 1
hw.cpu0.name = FMI,MB86904
hw.cpu0.fpuname = MB86910 or WTL1164/5
hw.cpu0.mid = 0
hw.cpu0.clock_frequency = 170000000
hw.cpu0.psr_implementation = 0
hw.cpu0.psr_version = 4
hw.cpu0.mmu_implementation = 0
hw.cpu0.mmu_version = 4
hw.cpu0.mmu_nctx = 256
hw.audio0.blk_ms = 40
hw.audio0.multiuser = 0

These kernel variables tell us various things about the system. Since some of these values are those that appeared in the dmesg output, there is a bit of redundancy here, but there's also some extra stuff.

scsictl

SCSI device control and information. To ask about the specific devices, we need to know the names of the devices:

> sysctl hw.disknames
hw.disknames = fd0 sd0 cd0

These correspond to the floppy drive (fd0), the first hard-disk (sd0) and the CD-ROM drive (cd0). Of these sd0 and cd0 are SCSI devices so we can get a bit more information about those:

# scsictl sd0 identify
/dev/rsd0: scsibus0 target 0 lun 0 <QEMU, QEMU HARDDISK, 2.5+>
# scsictl cd0 identify
/dev/rcd0: scsibus0 target 2 lun 0 <QEMU, QEMU CD-ROM, 2.5+>

And we get some SCSI information about the devices and their manufacturer and device name. Since we're running in QEMU these disk devices are emulated and given the a manufacturer name and device name containing the "QEMU" string.

Benchmark

To get an idea of how well the emulation performs, lets try a benchmark with published results including instances of real hardware we can compare with.

BogoMips

BogoMips (Wikipedia) is a "busy doing nothing" pseudo benchmark, used in the Linux kernel, that happens to reflect processor clock speeds. So it seems like a good fit for working out how the emulated machine compares to real hardware, while addressing the processor frequency issue. The BogoMips mini-Howto contains a list of BogoMips results for various SPARC systems either running Linux (4.12. Sparc systems) or other operating systems (4.17. Non-Linux systems (reference only)) so we have some results to compare with.

Since we're not running Linux we'll use a portable implementation (bogo-1.2.tar.gz) of about the same era as most of the collected results. And to allow for variation we'll use a wrapper script to run the program 5 times:

Calibrating delay loop.. ok - 327.36 BogoMips
Calibrating delay loop.. ok - 329.36 BogoMips
Calibrating delay loop.. ok - 331.40 BogoMips
Calibrating delay loop.. ok - 329.36 BogoMips
Calibrating delay loop.. ok - 335.54 BogoMips

For the generation of SPARC processors that the microSPARC II belongs to, the BogoMips score is roughly equivalent to the clock speed. So these results suggest the emulated processor performance is between 325 and 336 MHz which is a bit more than the system claimed 170 MHz.

OpenSSL

The OpenSSL cryptographic method library provides an option that represents a workload. For comparison purposes a couple of the older cryptographic methods were chosen and the speed test provided by OpenSSL used:

qnetbsd9: {6} openssl speed md5
Doing md5 for 3s on 16 size blocks: 844274 md5's in 3.00s
Doing md5 for 3s on 64 size blocks: 660775 md5's in 3.00s
Doing md5 for 3s on 256 size blocks: 389812 md5's in 3.00s
Doing md5 for 3s on 1024 size blocks: 157584 md5's in 2.99s
Doing md5 for 3s on 8192 size blocks: 23772 md5's in 2.99s
Doing md5 for 3s on 16384 size blocks: 12078 md5's in 3.00s
OpenSSL 1.1.1k  25 Mar 2021
NetBSD 9.2
options:bn(32,32) rc4(int) des(long) aes(partial) idea(int) blowfish(ptr) 
gcc version 7.5.0 (NetBSD nb4 20200810) 
The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
md5               4502.79k    14096.53k    33263.96k    53968.57k    65130.51k    65961.98k
qnetbsd9: {8} openssl speed rsa
Doing 512 bits private rsa's for 10s: 1900 512 bits private RSA's in 9.94s
Doing 512 bits public rsa's for 10s: 24796 512 bits public RSA's in 9.97s
Doing 1024 bits private rsa's for 10s: 488 1024 bits private RSA's in 9.98s
Doing 1024 bits public rsa's for 10s: 11667 1024 bits public RSA's in 9.96s
Doing 2048 bits private rsa's for 10s: 102 2048 bits private RSA's in 10.07s
Doing 2048 bits public rsa's for 10s: 4317 2048 bits public RSA's in 9.98s
Doing 3072 bits private rsa's for 10s: 37 3072 bits private RSA's in 10.11s
Doing 3072 bits public rsa's for 10s: 2296 3072 bits public RSA's in 9.99s
Doing 4096 bits private rsa's for 10s: 18 4096 bits private RSA's in 10.10s
Doing 4096 bits public rsa's for 10s: 1357 4096 bits public RSA's in 9.94s
Doing 7680 bits private rsa's for 10s: 4 7680 bits private RSA's in 11.68s
Doing 7680 bits public rsa's for 10s: 413 7680 bits public RSA's in 9.96s
Doing 15360 bits private rsa's for 10s: 1 15360 bits private RSA's in 20.18s
Doing 15360 bits public rsa's for 10s: 123 15360 bits public RSA's in 9.98s
OpenSSL 1.1.1k  25 Mar 2021
NetBSD 9.2
options:bn(32,32) rc4(int) des(long) aes(partial) idea(int) blowfish(ptr) 
gcc version 7.5.0 (NetBSD nb4 20200810) 
                  sign    verify    sign/s verify/s
rsa  512 bits 0.005232s 0.000402s    191.1   2487.1
rsa 1024 bits 0.020451s 0.000854s     48.9   1171.4
rsa 2048 bits 0.098725s 0.002312s     10.1    432.6
rsa 3072 bits 0.273243s 0.004351s      3.7    229.8
rsa 4096 bits 0.561111s 0.007325s      1.8    136.5
rsa 7680 bits 2.920000s 0.024116s      0.3     41.5
rsa 15360 bits 20.180000s 0.081138s      0.0     12.3

Extracting the relevant benchmark figures:

  • OpenSSL speed MD5 8,192 bytes: 65,130.51k
  • OpenSSL speed RSA 4,096 bytes sign/s: 1.8
  • OpenSSL speed RSA 4,096 bytes verify/s: 136.5

They can be compared to the collection: OpenSSL Speed Results

Thoughts

Our emulated SPARCstation 5 looks like much like a real SPARCstation 5 when viewed through the information available via command in NetBSD. This is great, since it means that software built for the NetBSD on the real hardware will likely behave correctly on this emulated machine. The performance difference might be a problem for some software, but there were a a range of processor speeds used in the SPARCstation 5 and the other sun4m machines. A quick look at the Wikipedia page for these machines shows a range of processor speeds for sun4m machines of 33 Mhz to 200 Mhz, as well as variation in number of processors (1 to 4), so there was already a wide range of performance characteristics for these machines and software that was expected to run on more than one machine was going to have to allow for this.

Sources


No comments: