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".

20 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.

jermar 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.

jermar 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.

Unknown 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]#

Unknown 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

Unknown 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.

the great quux said...

Please add networking support for niagara to the wishlist. :) All the talk recently of the very probably death of both Solaris and SPARC has me hoping that the emulation in QEMU can be "finished" to the point where anyone who needs 64-bit Solaris 10 applications will eventually be able to rely on it. (We are finally able to move over the old 32-bit apps we've got using the complete sun4m emulation which is awesome... reading about what it took to change a signed into an unsigned int in the code to get Solaris finally booting all the way was amazing.)

ZiVo said...

2 years late but here we go veganman:

System Configuration: Sun Microsystems sun4v Sun Fire T2000
System clock frequency: 200 MHz
Memory size: 16376 Megabytes

================================ Virtual CPUs ================================


CPU ID Frequency Implementation Status
------ --------- ---------------------- -------
0 1000 MHz SUNW,UltraSPARC-T1 on-line
1 1000 MHz SUNW,UltraSPARC-T1 on-line
2 1000 MHz SUNW,UltraSPARC-T1 on-line
3 1000 MHz SUNW,UltraSPARC-T1 on-line
4 1000 MHz SUNW,UltraSPARC-T1 on-line
5 1000 MHz SUNW,UltraSPARC-T1 on-line
6 1000 MHz SUNW,UltraSPARC-T1 on-line
7 1000 MHz SUNW,UltraSPARC-T1 on-line
8 1000 MHz SUNW,UltraSPARC-T1 on-line
9 1000 MHz SUNW,UltraSPARC-T1 on-line
10 1000 MHz SUNW,UltraSPARC-T1 on-line
11 1000 MHz SUNW,UltraSPARC-T1 on-line
12 1000 MHz SUNW,UltraSPARC-T1 on-line
13 1000 MHz SUNW,UltraSPARC-T1 on-line
14 1000 MHz SUNW,UltraSPARC-T1 on-line
15 1000 MHz SUNW,UltraSPARC-T1 on-line


time $(i=0; while (( i < 99999 )); do (( i ++ )); done)

real 0m8.971s
user 0m8.965s
sys 0m0.006s

atar said...

Thanks, ZiVo. I think "late" is not applicable to such vintage systems... :-) It's never too late.

crmstafford said...

As my Ultra60 recently died which I occasionally use to build software releases, I really hope that either the niagara networking be added (if it isn't already) or someone can give me a complete & workable set of instructions on how to start qemu-system-sparc64 such that it can connect to the outside world. All my searches and efforts so far have come to nought. (P.S. I am running it on Fedora 27.

Alex said...

Could you indicate the exact name of the file to modify the ram, please.