PowerPCTesting

From QEMU
Jump to: navigation, search

How to Test PowerPC Instructions Using Risu

Overview:
Risu is an instruction tester program. This version tests 32-bit PowerPC instructions. How it works is a copy of the program runs on a real PowerPC Macintosh and another copy runs in qemu-system-ppc. When started the two programs run a set of tests on various PowerPC instructions then compares the output (CPU registers and/or memory) to see if there are any differences. The copy that runs on the real PowerPC Macintosh is the master. The copy that runs in qemu-system-ppc is the host. Both copies of risu must use the same test file. This file is called ppc.out. It will contain machine code that will be ran. It only needs to be created once and can be made on an Intel-based Macintosh.

Download:
Risu

System Requirements:

  • PowerPC Macintosh running Mac OS X (Mac OS 10.4 or higher suggested)
  • Python 2.3 or higher (If using the front-end)
  • Perl (I used version 5.22.0)

Setup:
My setup was an x86 Macintosh running a QEMU VM that was running Mac OS 10.4 and a PowerPC Macintosh also running Mac OS 10.4. Both the x86 and PowerPC Macintoshes were on the same wifi network. You need a real PowerPC Macintosh to do the comparison, but you don't need an x86 Macintosh. You just need a computer that is on the same network as the PowerPC Macintosh and is running Mac OS X in qemu-system-ppc. This other computer could be a Windows PC.

Directions:
Copy the risu folder on both a PowerPC Macintosh running Mac OS X and a QEMU VM that is also running Mac OS X.

Generate the ppc.out file:
(Note: this file can take some time to generate. I suggest generating it on a newer computer. An x86 Macintosh will be fine.)
Enter in the "Number:" field the number of instructions you wish to test. A small number like 50 is a good start. Push the "Generate" button. Once this process is done copy the file ppc.out to the risu folder in both the PowerPC Macintosh and the QEMU VM.

Running the test:
The following instructions should be followed on both the PowerPC Macintosh and on the QEMU VM:
1. Open the terminal application.
2. cd to the risu folder.
3. Type "python frontend.py", then push the return key.

You should see this window:
Risu Front-End

On the PowerPC Macintosh select "master" in the "Test" section. An ip address appears in the ip address field. On the QEMU VM select "host" in the "Test" section. Enter the IP address you see on the master window into the same field in the host window. Push the start button on both the PowerPC Macintosh and the QEMU VM.

What happens next is the two risu instances will talk to each other to see how each executed instruction's output looks like.

Output:
If a problem happens during testing the test will end and you well see information on registers and info on the faulting instruction. The text "previous insn" will tell you the instruction that failed, but not in a easy to understand way. You will see a hex value. This hex value can be translated into a PowerPC instruction name using this website: https://onlinedisassembler.com. You would push the blue "START DISASSEMBLING!" button. Then push the read button labelled "Platform: i386". Enter these values into the form:

ARCH: powerpc:common
Base Address: 0x0
Endian: big
mode: 32
cpu: ppc32

The form should look like this:
Onlinedisassembler.png

This webpage is a little tricky. Once you enter these values into the form and paste the hex value into the bottom left text field, you will see an instruction on the right. This output will be incorrect. You have to select 64 from the Mode field, then select 32 again to make the right value appear.

As an exercise, the hex value eddda025 should result in the output "fdivs. f14, f29, f20".

Advanced Features:
If you only wanted to test out a few instructions, you would generate a test file with the "Only Instructions" field set to it or them. For example if you wanted to test the FADD and FSUB instructions, you would enter them like this: FADD,FSUB.

If you don't wish to test one or more instructions you can exclude them by entering them in the "Exclude Instructions:" field. For example if you wanted to exclude the ADD, ADDC, and ADDE instructions you would enter them like this: ADD,ADDC,ADDE.

If you want to exclude every instruction that begins with the letter F (basically the floating point instructions), then you would enter this: 'F.*'. You can enter the same thing to the "Only instructions" field if you wanted to only test the floating point instructions.

Checking the "Verbose testing" checkbox will show each encoded instruction as it is tested. It can be entertaining to watch.

For more information on risu's features please see the README file.

Current Results (12/2017):
Current testing indicates qemu-system-ppc does not correctly set the Floating Point Status and Control Register (FPSCR). I believe all the sound problems we see with Mac OS X are contributed to this issue.

Contact:
email me