Blog.nechutny.net

Blog o webu a IT.

Work on KVM/ARM unit tests

(Skip these boring to technical things...). A few weeks before the end of semester I have started looking for a job. The main reason was increasing my skills and gaining more experience. I rejected an offer from IBM for PHP programming as I would like something more challenging and interesting. I've found offers on faculty Q labs page with interesting work subjects, so I chose Open source software testing, entered my email address and waited...

In couple of hours there was an answer and I arranged a meeting with Ing. Petr Müller. Meeting was friendly and he suggested work on KVM Unit tests. I was still busy with the semester finals but about month later I have received an email with a question if I would be still interested. So I have arranged a meeting with Andrew Jones from Red Hat. Andrew explained to me what the work would be like, which was about the same as I imagined, and how we could cooperate and also scared me when he said, that there are going to be tests for KVM on ARM and AArch64. I have expected writing in an assembler, but in x86 assembler, which I know from school, not arm. But it's okay; I can learn it overnight :-).

The technical things

The same day I have received an email from Andrew steps he advised me to follow. Because I am developing a KVM/ARM unit test on x86_64, then i need Qemu for emulating ARM Cortex-a15 processor. A patched Qemu is needed for testing, so I had to get a source, patch file etc. Next step was installing cross compilers, clonning kvm unit test from repo and configuring it for tests.

That email also contained links for ARM specifications and manuals from infocenter.arm.com. I was a little scared, when some of them had more than 5 thousands pages, but now I don’t think I would mind if they had more. At Columbia university's page (PDF) I found a good summary of what KVM/ARM is and basically how it works. After that I read more about ARM architecture and especially about ARM assembler. Conditional execution for most of instructions looks like a good idea, optional affecting status registers too... ARM assembler is nice :-).

Because I am testing VFP from C and I'm using inline assembler, the next problem was searching for constraints. After spying on Google and Stackowerflow I have found ARM inline asm secrets. GCC hasn't it documented well, yet, but this article contains all important and "secret" things.

Good source for understanding VFP was ARM appendix B. It describes IEEE 754 standard for floating point, VFP's status register, flags and most of instructions.

While writing tests I have also found some mistakes in ARM manuals. For example for FMRS and FMSR instructions there was a mismatched usage description. fmrs is for copying from Rd to Sn, not Sn to Rd and vice versa. I have reported all found mistakes, so they can correct them.

Update: It's not bug, it's just my stupid mistake. After about 30 tests I have found a first bug in fdiv[ds] instruction. Test file is available at my Github fork. It set bad flags in FPSCR. For example dividing 1.0 by 1.0 set Dividing by zero flag and Inexact Flag. I've tested it on my Raspberry Pi and reported it to Andrew. Now I am trying fix this bug.