This post is part 1 of the "SBSA Reference Platform in QEMU" series:
- Versioning of sbsa-ref machine
- SBSA Reference Platform update
- Testing *BSD on SBSA Reference Platform
- Running SBSA Reference Platform
- DT-free EDK2 on SBSA Reference Platform
- ConfigurationManager in EDK2: just say no
QEMU has emulation of several machines. One of them is “sbsa-ref” which stands for SBSA Reference Platform. The Arm server in simpler words.
In past I worked on it when my help was needed. We have CI jobs which run some tests (SBSA ACS, BSA ACS) and do some checks to see how we are with SBSA compliance.
Versioning?
One day there was discussion that we need a way to recognize variants of “sbsa-ref” in some sane way. The idea was to get rid of most of hardcoded values and provide a way to have data going from QEMU up to firmware.
We started with adding “platform version major/minor” fields into DeviceTree. Starting with “0.0” as value. And for some time nothing changed here as some of people working on SBSA Reference Platform changed jobs and other worked on other parts of it.
Note that this is different than other QEMU targets. We do not go “sbsa-ref-8.0”, “sbsa-ref-8.1” way as this would add maintenance work without any gain for us.
During last Linaro Connect we had some discussion on how we want to proceed. And some after (as not everyone got there — UK visa issues).
The plan
The plan is simple:
- QEMU adds data into DeviceTree
- TF-A parses DeviceTree and extracts data from it
- TF-A provides Secure Monitor Calls (SMC) with data from DT
- EDK2 uses SMC to gather data from TF-A
- EDK2 creates ACPI tables
- OS uses ACPI to get hardware information
Implementation
After setting the plan I created a bunch of Jira tickets and started writing code. Some changes were new, some were adapted from our work-in-progress ones.
0.0: Platform version SMC
Trusted Firmware (TF-A) reads DeviceTree from QEMU and provides platform version (PV from now on) up to firmware via SMC. EDK2 reads it and does nothing (as expected).
0.1: GIC data SMC
Firmware knows which platform version we are on so it can do something about it. So we bump the value in QEMU and provide Arm GIC addresses via another SMCs.
TF-A uses those values instead of hardcoded ones to initialize GIC. Then EDK2 does the same.
If such firmware boots on older QEMU then hardcoded values are used and machine is operational still.
0.2: GIC ITS SMC
Here things start to be more interesting. We add Interrupt Translation Service support to GIC. Which means we have LPI, MSI(-X) etc. In other words: have normal, working PCI Express with root ports, proper interrupts etc.
From code side it is like previous step: QEMU adds address to DT, TF-A reads it and provides via SMC to EDK2.
If such firmware boots on older QEMU then ITS is not initialized as it was not present in PV 0.0 system.
0.x: PCIe SMC
Normal PCI Express is present. So let get rid of hardcoded values. Similar steps and behaviour like above.
0.y: go PCIe!
At this step we have normal, working PCI Express structure. So let get rid of some platform devices and replace them with expansion cards:
- AHCI (sata storage)
- EHCI (usb 2.0)
We can use “ich9-ahci” card instead of former and “qemu-xhci” for latter one.
This step is EDK2 only as we do not touch those parts in TF-A. No real code yet as it needs adding some conditions to existing ASL code so operating system will not get information in DSDT table.
Again: if booted on lower PV then hardcoded values are used.
Other changes
Recently some additional changes to “sbsa-ref” were merged.
We exchanged graphics card from basic VGA one on legacy PCI bus to Bochs one (which uses PCI Express). From firmware or OS view not much changed as both were supported already.
Other change was default processor. QEMU 8.0 brought emulation of Arm Neoverse-N1 cpu. It is enabled in TF-A for a while so we switched to use it by default (instead of ancient Cortex-A57). With move from arm v8.0 to v8.2 we got several cpu features and functionalities.
Future
The above steps are cleanup preparing “sbsa-ref” for future work. We want to be able to change hardware definition more. For example to select exact GIC model (like GIC-600) instead of generic “arm-gic-v3” one.
SBSA Reference Platform is system where most of expansion is expected to happen by adding PCI Express cards.