add notes on 2024-01-23 meeting. terminated due to harrassment
[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
12 many parts of the architecture typically found on production silicon,
13 like AltiVec, VSX, and 128-bit hardware floating point. There are no
14 commercially available chips that support OpenPOWER ISA v3.0 SFFS without
15 VSX, AltiVec, and 128-bit hardware floating point.
16
17 Because of this, we are stuck in a chicken and egg problem where we need
18 the chip to test software, but we also need to test whether software
19 is compliant with SFFS by using such a chip. This is where QEMU as an
20 emulator can help us.
21
22 The goal is to add a CPU definition in QEMU that specifically emulates
23 an OpenPOWER ISA v3.0 SFFS chip that we can use to run tests and full
24 operating system images on.
25
26 ## Progress and setbacks
27
28 ### We have first tried using POWER7 which is available on QEMU
29
30 - POWER7 runs little endian without VSX, but is only ISA 2.06 compliant.
31 * The assumption was that Any additions from ISA 3.0 would be emulated
32 by the Linux kernel, that however did not work.
33 * We tried booting [[SFFS/gentoo_bootstrap]] with a kernel compiled
34 for POWER9, POWER8, and POWER7, all seem to fail with a kernel panic
35 due to missing instructions.
36 * The POWER9 instructions were VSX from the v3.0 ISA
37 * likewise the POWER8 but also including some v2.08 instructions deprecated in v3.0
38 * POWER7 included some v2.07 instructions definitely deprecated in v3.0
39 * We also tried booting it with a kernel built for all three POWER
40 versions mentioned earlier and also disabling VSX and/or AltiVec, still
41 fails with a kernel panic due to missing instructions.
42
43 ### We have tried patching QEMU's definition for POWER9 to exclude VSX and AltiVec
44
45 - This did not work and needs considerable amounts of patching.
46 * The relevant files are `tcg/ppc/tcg-target.h` and
47 `target/ppc/{compat.c,cpu.c,cpu.h,cpu_init.c,cpu_models.c,cpu_models.h,cpu-qom.h,cpu-param.h}`
48 none seemed to work when removing such features.
49
50 ### We have researched in length if the CPU capabilities feature of QEMU is available on POWER
51
52 * It is not available and needs to be added in, unlike x86 and some
53 other architectures that QEMU supports.
54 * However, it being a feature of QEMU to start means patching it in
55 will be simpler than adding a fresh feature that was not available in
56 the code before.
57
58 ## Conclusion as of 25 Aug 2023:
59
60 This task will need a considerable amount of additional research and work