On Thu, 20 Jan 2022 09:46:09 -0500 Godmar Back email@example.com wrote:
[this is a follow-up email; I took qemu-discuss and qemu-devel off the distribution list]
On Thu, Jan 20, 2022 at 4:04 AM Igor Mammedov firstname.lastname@example.org wrote:
Legacy MP table is not actively maintained part of the code, hence it's configuration which is not tested. However if someone is interested in maintaining this, one should contribute at least a testcase that will warn developers early if usecase is broken. We can't promise not breaking it ever but at least we would be able to document any breaking changes in release notes.
May I ask a clarification question? Is it correct that the only option to not use the MP tables and learn the CPU configuration would be to implement support for ACPI? For a small educational OS like xv6 or Pintos, we're aiming at keeping the codebase small, which is why so far we haven't taken this step. Is there a way to learn the CPU configuration without using ACPI that involves relatively little code?
I do see value from education point of view in legacy MP table, however I'd guess its support will continue to deteriorate over the time, as ACPI is what majority of mainstream operating systems currently use.
If you wish to use qemu-6.2 and later and MP tables you have 2 options to do this: 1) use 6.1 machine type (or any older one): qemu-system-i386 -M pc-i440fx-6.1 -smp 4 ... 2) use default (latest) machine type and define explicit cpu layout supported by SeaBIOS qemu-system-i386 -smp 4,sockets=4 ...
As for adding ACPI support to xv6, is not so difficult if you only use it for detecting CPUs. You only need to locate RSDP which points to a list of ACPI tables ((X)RSDT) and then jump and parse MADT table which is analog of MP table. It's all very well documented in ACPI spec and you can use SeaBIOS code for inspiration as well, look for RSDP_SIGNATURE as starting point (SeaBIOS does a lot more stuff with ACPI but you don't really need it (you can start with minimum of necessary code and then build up on top as needed)).
Alternative approach to discover present CPUs with ad-hock approach SeaBIOS use(s|d) to build its own MADT tables (note: since QEMU-1.7 it uses ACPI tables provided by QEMU). See smp_scan() + handle_smp() for an example.