Saturday, October 1, 2016

QEMU sun4v/Niagara target went public

I’m publishing my work on the sun4v emulation on the GitHub site:

https://github.com/artyom-tarasenko/qemu/tree/sun4v-v0

Yes, I hope it’ll make it into the upstream soon, but those who like to boot Solaris 10/SPARC under QEMU can do it straight away.

It uses the firmware (hypervisor, machine definition and OpenBOOT) from the OpenSPARC T1 project. So in order to use it, download

http://download.oracle.com/technetwork/systems/opensparc/OpenSPARCT1_Arch.1.5.tar.bz2

$ tar xfj OpenSPARCT1_Arch.1.5.tar.bz2 ./S10image
$ cd path/to/qemu-sun4v

$ sparc64-softmmu/qemu-system-sparc64 -M Niagara -L /path/to/S10image/ -nographic -m 256 -drive if=pflash,readonly=on,file=/path/to/S10image/disk.s10hw2

Sun Fire T2000, No Keyboard
Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
OpenBoot 4.20.0, 256 MB memory available, Serial #1122867.
[mo23723 obp4.20.0 #0]
Ethernet address 0:80:3:de:ad:3, Host ID: 80112233.


ok boot –v
<…>
login: root

Enjoy!
In case you wonder why the path to drive image is not hard coded like all the paths to firmware components: it’s possible to specify a non-Solaris image, like HelenOS or NetBSD/sun4v (once it gets released).

Feel free to report me if you have more working OSes. :-)

 2016.11.04 Update: while the v0 version uses the name "Niagara", v1 and all subrequent ones will be using the lowercase name "niagara".

15 comments:

veganman said...

How much memory does it support?
Have you tried Solaris 11.3?

Anonymous said...

Wow! Thanks a lot for this fantastic work!

atar said...

RAM is tricky: the Sun firmware has 256MiB coded in the machine description. You can give QEMU more, but it won't be recognized unless you patch the machine description files.
1 GiB works for sure, haven't tested more.

Haven't tried Solsris 11 yet, but think it is not compatible with this firmware version.

It should be possible to compile a newer hypervisor version (the sources are released by Sun, I cloned their repo on my github page to be sure it's preserved) and OBP. AFAIK the build requires Solaris 9 and SunStudio.

veganman said...

So roughly I get this on my instance:

bash-3.00# time $(i=0; while (( i < 99999 )); do (( i ++ )); done)

real 0m14.766s
user 0m11.515s
sys 0m0.021s

emulated on "Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz" laptop (lenovo x1)

how does this compares to the real thing, just so I get an idea of the magnitude.

Jakub Jermář said...

This is absolute goodness. Thank you very much for all your work. HelenOS runs like a charm without modifications. Now let's get this thing merged into QEMU master.

atar said...

You are welcome. Do you know the exact reason why the 0.4.x and 0.6.0 isos don't boot?

Yeah, since I'm one of the mainaiers, merging should go easier. Things should go even faster once I have a chance to get to some key signing party with recognized officials.

atar said...

veganman, I don't have a real T1000/T2000 so I can't compare.

Jakub Jermář said...

We used to have problems with image sizes and the way we unpack the image.boot before it passes control to the kernel, but since the working mainline image.iso is quite bigger than the non working 0.6.0 image, I am not sure.

Anonymous said...

Which file in OpenSPARCT1_Arch.1.5 sets the amount of memory (256MB) available?

atar said...

In the machine description files.

Earl Aker said...

I'm getting a core dump

[root@bby1shost01 sparc64]# qemu/sparc64-softmmu/qemu-system-sparc64 -M Niagara -L /sparc64/S10image/ -nographic -m 256 -drive if=pflash,readonly=on,file=/sparc64/S10image/disk.s10hw2
Warning: Orphaned drive without device: id=pflash0,file=/sparc64/S10image/disk.s10hw2,if=pflash,bus=0,unit=0
qemu: fatal: Trap 0x0064 while trap level (6) >= MAXTL (6), Error state
pc: 0000000000004c80 npc: 0000000000004c84
%g0-3: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%g4-7: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%o0-3: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%o4-7: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%l0-3: 000000000ff00000 000001ff00000000 000001fff0080000 0000000000000000
%l4-7: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%i0-3: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%i4-7: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f00: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f08: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f24: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f32: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f40: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f48: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f56: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
pstate: 00000414 ccr: 44 (icc: -Z-- xcc: -Z--) asi: 00 tl: 6 pil: 0
cansave: 6 canrestore: 0 otherwin: 0 wstate: 0 cleanwin: 6 cwp: 7
fsr: 0000000000000000 y: 0000000000000000 fprs: 0000000000000000

Aborted (core dumped)
[root@bby1shost01 sparc64]#

Earl Aker said...

Setup was:

cd /sparc64
git clone git://github.com/artyom-tarasenko/qemu.git
wget http://download.oracle.com/technetwork/systems/opensparc/OpenSPARCT1_Arch.1.5.tar.bz2
tar xfj OpenSPARCT1_Arch.1.5.tar.bz2 ./S10image
cd qemu
./configure --target-list=sparc64-softmmu
make

atar said...

Before ./configure --target-list=sparc64-softmmu

please do
git checkout sun4v-v0

Earl Aker said...

Fantastic, that got me father! So the fact that trying to add a network card and failing (due to it saying there is no PCI adapter) means we'll need to wait to have it merged into the main branch?

atar said...

Sort of. Someone has to implement the niagara PCI adapter, and recompile the firmware to enable it. No pci devices till it happens.