new page
[libreriscv.git] / SFFS / qemu.mdwn
1 # Documentation on the process of patching QEMU to support SFFS
2
3 Useful Links:
4
5 * bugreport: <https://bugs.libre-soc.org/show_bug.cgi?id=1132>
6 * (External) [qemu source code](https://github.com/qemu/qemu)
7 * (External) [qemu cpu flags for x86*](https://www.linux-kvm.org/page/Tuning_KVM)
8
9 ## Reasoning:
10
11 Libre-SOC builds upon the OpenPOWER ISA v3.0 but does not include many
12 parts of the architecture typically found on production silicon, like
13 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.
14
15 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.
16
17 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.
18
19 ## Progress and setbacks
20
21 ### We have first tried using POWER7 which is available on QEMU
22
23 - POWER7 runs little endian without VSX, but is only ISA 2.06 compliant.
24 -- The assumption was that Any additions from ISA 3.0 would be emulated by the Linux kernel, that however did not work.
25 -- We tried booting [Gentoo SFFS](https://libre-soc.org/SFFS/gentoo_bootstrap/) with a kernel compiled for POWER9, POWER8, and POWER7, all seem to fail with a kernel panic due to missing instructions.
26 -- 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.
27
28 ### We have tried patching QEMU's definition for POWER9 to exclude VSX and AltiVec
29
30 - This did not work and needs considerable amounts of patching.
31 - The relevant files are `tcg/ppc/tcg-target.h` and `target/ppc/{compat.c,cpu.c,cpu.h,cpu_init.c,cpu_models.c,cpu_models.h,cpu-qom.h,cpu-param.h}` none worked.
32
33 ### We have researched in length if the CPU capabilities feature of QEMU is available on POWER
34
35 - It is not available and needs to be added in, unlike x86* and some other architectures that QEMU supports.
36 - 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.
37
38 ## Conclusion as of 25 Aug 2023:
39 This task will need a considerable amount of research and work