Documentation on the process of patching QEMU to support SFFS
Useful Links:
- bugreport: https://bugs.libre-soc.org/show_bug.cgi?id=1132
- (External) qemu source code
- (External) qemu cpu flags for x86
Reasoning:
Libre-SOC builds upon the OpenPOWER ISA v3.0 but does not include many parts of the architecture typically found on production silicon, like AltiVec, VSX, and 128-bit hardware floating point. There are no commercially available chips that support OpenPOWER ISA v3.0 SFFS without VSX, AltiVec, and 128-bit hardware floating point.
Because of this, we are stuck in a chicken and egg problem where we need the chip to test software, but we also need to test whether software is compliant with SFFS by using such a chip. This is where QEMU as an emulator can help us.
The goal is to add a CPU definition in QEMU that specifically emulates an OpenPOWER ISA v3.0 SFFS chip that we can use to run tests and full operating system images on.
Progress and setbacks
We have first tried using POWER7 which is available on QEMU
- POWER7 runs little endian without VSX, but is only ISA 2.06 compliant.
- The assumption was that Any additions from ISA 3.0 would be emulated by the Linux kernel, that however did not work.
- We tried booting gentoo bootstrap with a kernel compiled
for POWER9, POWER8, and POWER7, all seem to fail with a kernel panic
due to missing instructions.
- The POWER9 instructions were VSX from the v3.0 ISA
- likewise the POWER8 but also including some v2.08 instructions deprecated in v3.0
- POWER7 included some v2.07 instructions definitely deprecated in v3.0
- We also tried booting it with a kernel built for all three POWER versions mentioned earlier and also disabling VSX and/or AltiVec, still fails with a kernel panic due to missing instructions.
We have tried patching QEMU's definition for POWER9 to exclude VSX and AltiVec
- This did not work and needs considerable amounts of patching.
- The relevant files are
tcg/ppc/tcg-target.h
andtarget/ppc/{compat.c,cpu.c,cpu.h,cpu_init.c,cpu_models.c,cpu_models.h,cpu-qom.h,cpu-param.h}
none seemed to work when removing such features.
We have researched in length if the CPU capabilities feature of QEMU is available on POWER
- It is not available and needs to be added in, unlike x86 and some other architectures that QEMU supports.
- However, it being a feature of QEMU to start means patching it in will be simpler than adding a fresh feature that was not available in the code before.
Conclusion as of 25 Aug 2023:
This task will need a considerable amount of additional research and work