<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Marcin Juszkiewicz - virtualization</title><link href="https://marcin.juszkiewicz.com.pl/" rel="alternate"/><link href="https://marcin.juszkiewicz.com.pl/tag/virtualization/feed/" rel="self"/><id>https://marcin.juszkiewicz.com.pl/</id><updated>2026-03-10T18:53:00+01:00</updated><entry><title>RISC-V is sloooow</title><link href="https://marcin.juszkiewicz.com.pl/2026/03/10/risc-v-is-sloooow/" rel="alternate"/><published>2026-03-10T18:53:00+01:00</published><updated>2026-03-10T18:53:00+01:00</updated><author><name>Marcin Juszkiewicz</name></author><id>tag:marcin.juszkiewicz.com.pl,2026-03-10:/2026/03/10/risc-v-is-sloooow/</id><summary type="html">143 vs 36 minutes is far too big&amp;nbsp;difference</summary><content type="html">&lt;p&gt;About 3 months ago &lt;a href="/2025/12/04/from-the-diary-of-aarch64-porter-risc-v/"&gt;I started working with &lt;span class="caps"&gt;RISC&lt;/span&gt;-V port of Fedora
Linux&lt;/a&gt;.
Many things happened during that&amp;nbsp;time.&lt;/p&gt;
&lt;!--MORE--&gt;

&lt;h3&gt;Triaging&lt;/h3&gt;
&lt;p&gt;I went through &lt;a href="https://abologna.gitlab.io/fedora-riscv-tracker/"&gt;the Fedora &lt;span class="caps"&gt;RISC&lt;/span&gt;-V tracker&lt;/a&gt;
entries, triaged most of them (at the moment 17 entries left in &lt;span class="caps"&gt;NEW&lt;/span&gt;) and tried
to handle whatever&amp;nbsp;possible.&lt;/p&gt;
&lt;h3&gt;Fedora&amp;nbsp;packaging&lt;/h3&gt;
&lt;p&gt;My usual way of working involves fetching sources of a Fedora package&amp;nbsp;(&lt;code&gt;fedpkg
clone -a&lt;/code&gt;) and then building it&amp;nbsp;(&lt;code&gt;fedpkg mockbuild -r fedora-43-riscv64&lt;/code&gt;). After
some time, I check did it built and if not then I go through build logs to find
out&amp;nbsp;why.&lt;/p&gt;
&lt;p&gt;Effect? At the moment,
&lt;a href="https://src.fedoraproject.org/user/hrw/requests"&gt;86 pull requests sent for Fedora packages&lt;/a&gt;.
From heavy packages like the &amp;#8220;llvm15&amp;#8221; to simple ones like the &amp;#8220;iyfct&amp;#8221; (some
simple game). At the moment most of them were merged, and most of these got
built for the Fedora 43. Then we can build them as well as we follow
&amp;#8216;f43-updates&amp;#8217; tag on the Fedora&amp;nbsp;koji.&lt;/p&gt;
&lt;h3&gt;Slowness&lt;/h3&gt;
&lt;p&gt;Work on packages brings the hard, sometimes controversial, topic: speed. Or
rather lack of&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;You see, the &lt;span class="caps"&gt;RISC&lt;/span&gt;-V hardware at the moment is slow. Which results in terrible
build times &amp;#8212; look at details of the binutils 2.45.1-4.fc43 package I took from
koji (&lt;a href="https://koji.fedoraproject.org/koji/buildinfo?buildID=2894403"&gt;Fedora&lt;/a&gt;
and &lt;a href="https://riscv-koji.fedoraproject.org/koji/buildinfo?buildID=60248"&gt;&lt;span class="caps"&gt;RISC&lt;/span&gt;-V Fedora&lt;/a&gt;):&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Architecture&lt;/th&gt;
&lt;th&gt;Cores&lt;/th&gt;
&lt;th&gt;Memory&lt;/th&gt;
&lt;th&gt;Build time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;aarch64&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;46 &lt;span class="caps"&gt;GB&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;36 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;i686&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;29 &lt;span class="caps"&gt;GB&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;25 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ppc64le&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;37 &lt;span class="caps"&gt;GB&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;46 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;riscv64&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;16 &lt;span class="caps"&gt;GB&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;143 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;s390x&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;45 &lt;span class="caps"&gt;GB&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;37 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;x86_64&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;29 &lt;span class="caps"&gt;GB&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;29 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;That was StarFive VisionFive 2 board, while it has other strengths (such as
upstreamed drivers), it is not the fastest available one. I asked around and one
of porters did a built on Milk-V Megrez &amp;#8212; it took 58&amp;nbsp;minutes.&lt;/p&gt;
&lt;p&gt;Also worth mentioning is that the current build of &lt;span class="caps"&gt;RISC&lt;/span&gt;-V Fedora port is done
with disabled &lt;span class="caps"&gt;LTO&lt;/span&gt;. To cut on memory usage and build&amp;nbsp;times.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;RISC&lt;/span&gt;-V builders have four or eight cores with 8, 16 or 32 &lt;span class="caps"&gt;GB&lt;/span&gt; of &lt;span class="caps"&gt;RAM&lt;/span&gt; (depending
on a board). And those cores are usually compared to Arm Cortex-A55 ones. The
lowest cpu cores in today&amp;#8217;s Arm&amp;nbsp;chips.&lt;/p&gt;
&lt;p&gt;The UltraRISC &lt;span class="caps"&gt;UR&lt;/span&gt;-&lt;span class="caps"&gt;DP1000&lt;/span&gt; SoC, present on the Milk-V Titan motherboard should
improve situation a bit (and can have 64 &lt;span class="caps"&gt;GB&lt;/span&gt; ram). Similar with SpacemiT K3-based
systems (but only 32 &lt;span class="caps"&gt;GB&lt;/span&gt; ram). Both will be an improvement, but not the final&amp;nbsp;solution.&lt;/p&gt;
&lt;h3&gt;Hardware needs for Fedora&amp;nbsp;inclusion&lt;/h3&gt;
&lt;p&gt;We need hardware capable of building above &amp;#8220;binutils&amp;#8221; package below one hour.
With &lt;span class="caps"&gt;LTO&lt;/span&gt; enabled system-wide etc. to be on par with the other architectures.
This is the speed-related&amp;nbsp;requirement.&lt;/p&gt;
&lt;p&gt;There is no point of going for inclusion with slow builders as this will make
package maintainers complain. You see, in Fedora build results are released into
repositories only when all architectures finish. And we had maintainers
complaining about lack of speed of AArch64 builders in the past. Some developers
may start excluding &lt;span class="caps"&gt;RISC&lt;/span&gt;-V architecture from their packages to not have to&amp;nbsp;wait.&lt;/p&gt;
&lt;p&gt;And any future builders need to be rackable and manageable like any other boring
server (put in a rack, connect cables, install, do not touch any more). Because
no one will go into a data centre to manually reboot an &lt;span class="caps"&gt;SBC&lt;/span&gt;-based&amp;nbsp;builder.&lt;/p&gt;
&lt;p&gt;Without systems fulfilling both requirements, we can not even plan for the
&lt;span class="caps"&gt;RISC&lt;/span&gt;-V 64-bit architecture to became one of official, primary architectures in
Fedora&amp;nbsp;Linux.&lt;/p&gt;
&lt;h3&gt;I still use &lt;span class="caps"&gt;QEMU&lt;/span&gt; for local&amp;nbsp;testing&lt;/h3&gt;
&lt;p&gt;Such long build times make my use of &lt;span class="caps"&gt;QEMU&lt;/span&gt; useful.
&lt;a href="/2025/06/27/bought-myself-an-ampere-altra-system/"&gt;My AArch64 desktop&lt;/a&gt; has 80
cores, so with the use of &lt;span class="caps"&gt;QEMU&lt;/span&gt; userspace riscv64 emulation, I can build the
packages without buying &lt;span class="caps"&gt;RISC&lt;/span&gt;-V hardware. Still, there are timed out tests
because single thread is slower than native&amp;nbsp;one.&lt;/p&gt;
&lt;figure id="__yafg-figure-1"&gt;
&lt;img alt="busy btop" src="/files/2026/03/btop-700x.jpg" title="btop shows 80 cores being busy"&gt;
&lt;figcaption&gt;btop shows 80 cores being busy&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;There are package (like &lt;span class="caps"&gt;LLVM&lt;/span&gt;) which make real use of both available cores and
memory. I am wondering how fast would it go on 192/384 cores of Ampere One-based&amp;nbsp;system.&lt;/p&gt;
&lt;p&gt;Still, I used &lt;span class="caps"&gt;QEMU&lt;/span&gt; for local builds/testing only. Fedora, like several other
distributions, does native builds&amp;nbsp;only.&lt;/p&gt;
&lt;h3&gt;Future&amp;nbsp;plans&lt;/h3&gt;
&lt;p&gt;We plan to start building Fedora Linux 44. If things go well, we will use the
same kernel image on all of our builders (the current ones use a mix of kernel
versions). &lt;span class="caps"&gt;LTO&lt;/span&gt; will still be&amp;nbsp;disabled.&lt;/p&gt;
&lt;p&gt;When it comes to lack of speed&amp;#8230; There are plans to bring new, faster builders.
And probably assign some heavier packages to&amp;nbsp;them.&lt;/p&gt;</content><category term="misc"/><category term="fedora"/><category term="risc-v"/><category term="development"/><category term="qemu"/><category term="virtualization"/></entry><entry><title>From the diary of AArch64 porter — RISC-V</title><link href="https://marcin.juszkiewicz.com.pl/2025/12/04/from-the-diary-of-aarch64-porter-risc-v/" rel="alternate"/><published>2025-12-04T18:47:00+01:00</published><updated>2025-12-04T18:47:00+01:00</updated><author><name>Marcin Juszkiewicz</name></author><id>tag:marcin.juszkiewicz.com.pl,2025-12-04:/2025/12/04/from-the-diary-of-aarch64-porter-risc-v/</id><summary type="html">I started working on Fedora packaging for the 64-bit &lt;span class="caps"&gt;RISC&lt;/span&gt;-V architecture&amp;nbsp;port.</summary><content type="html">&lt;p&gt;Wait, what? &lt;span class="caps"&gt;RISC&lt;/span&gt;-V? In &amp;#8216;the diary of &lt;strong&gt;AArch64&lt;/strong&gt; porter&amp;#8217;? &lt;span class="caps"&gt;WTH&lt;/span&gt;?&lt;/p&gt;
&lt;!--MORE--&gt;

&lt;p&gt;Yes, I started working on Fedora packaging for the 64-bit &lt;span class="caps"&gt;RISC&lt;/span&gt;-V architecture&amp;nbsp;port.&lt;/p&gt;
&lt;h3&gt;All started with discussion about&amp;nbsp;Mock&lt;/h3&gt;
&lt;p&gt;About a week ago, one of my work colleagues asked me about &lt;a href="/2016/04/15/how-to-speed-up-mock/"&gt;my old post about
speeding up Mock&lt;/a&gt;. We had a discussion, I
pointed him to the Mock documentation, and gave some&amp;nbsp;hints.&lt;/p&gt;
&lt;p&gt;It turned out that he was working on &lt;span class="caps"&gt;RISC&lt;/span&gt;-V related changes to Fedora packages.
As I had some spare cycles, I decided to take a look. And I&amp;nbsp;sank&amp;#8230;&lt;/p&gt;
&lt;h3&gt;State of the &lt;span class="caps"&gt;RISC&lt;/span&gt;-V Fedora&amp;nbsp;port&lt;/h3&gt;
&lt;p&gt;The 64-bit &lt;span class="caps"&gt;RISC&lt;/span&gt;-V port of Fedora Linux is going quite well. There are over 90%
of Fedora packages already built for that architecture. And there are several
packages with the riscv64 specific changes, such&amp;nbsp;as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;patches adding &lt;span class="caps"&gt;RISC&lt;/span&gt;-V&amp;nbsp;support&lt;/li&gt;
&lt;li&gt;disabling some parts of test&amp;nbsp;suites&lt;/li&gt;
&lt;li&gt;disabling some build options due to bootstrapping of some languages being in
  progress (like&amp;nbsp;Java)&lt;/li&gt;
&lt;li&gt;disabling of debug information due to some toolchain issues (there is a
  work-in-progress now to solve&amp;nbsp;them)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that these changes are temporary. There are people working on solving
toolchain issues, languages are being bootstrapped (there was a review of Java
changes earlier this week), patches are being integrated upstream and in Fedora,
and so&amp;nbsp;on.&lt;/p&gt;
&lt;p&gt;There is &lt;a href="https://abologna.gitlab.io/fedora-riscv-tracker/"&gt;the Fedora &lt;span class="caps"&gt;RISC&lt;/span&gt;-V tracker&lt;/a&gt;
website showing the progress of the&amp;nbsp;port:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;package&amp;nbsp;name&lt;/li&gt;
&lt;li&gt;current status (new, triaged, patch posted, patch merged,&amp;nbsp;done)&lt;/li&gt;
&lt;li&gt;version in &lt;span class="caps"&gt;RISC&lt;/span&gt;-V port&amp;nbsp;Koji&lt;/li&gt;
&lt;li&gt;version in Fedora Koji (F43 release is tracked&amp;nbsp;now)&lt;/li&gt;
&lt;li&gt;version in CentOS Stream&amp;nbsp;10&lt;/li&gt;
&lt;li&gt;notes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is a simple way to check what to work on. And there are several packages,
not built yet due to use of &amp;#8220;ExclusiveArch&amp;#8221; setting in&amp;nbsp;them.&lt;/p&gt;
&lt;h3&gt;My&amp;nbsp;work&lt;/h3&gt;
&lt;p&gt;The quick look at work needed reminded me of the 2012-2014 period, when I worked
on the same stuff but for AArch64 ports (OpenEmbedded, Debian/Ubuntu,
Fedora/&lt;span class="caps"&gt;RHEL&lt;/span&gt;). So I had a knowledge, I knew the tools and started&amp;nbsp;working.&lt;/p&gt;
&lt;p&gt;In the beginning, I went through entries in the tracker and tried to triage as
many packages as possible, so it will be more visible which ones need work and
which can be ignored (for now). The tracker went from seven to over eighty
triaged packages in a few&amp;nbsp;days.&lt;/p&gt;
&lt;p&gt;Then I looked at changes done by current porters. Which usually meant David
Abdurachmanov. I used his changes as a base for the changes needed for Fedora
packaging, while trying to minimise the amount of them to the minimum&amp;nbsp;required.&lt;/p&gt;
&lt;p&gt;I did over twenty pull requests to Fedora packages during a week of&amp;nbsp;work.&lt;/p&gt;
&lt;h3&gt;Hardware?&lt;/h3&gt;
&lt;p&gt;But which hardware did I use to run those hundreds of builds? Was it HiFive Premier
P550? Or maybe Milk-V Titan or another &lt;span class="caps"&gt;RISC&lt;/span&gt;-V &lt;abbr title="Seriously Broken Computer"&gt;&lt;span class="caps"&gt;SBC&lt;/span&gt;&lt;/abbr&gt;?&lt;/p&gt;
&lt;p&gt;Nope. I used my 80-core, Altra-based, AArch64 desktop to run all those builds.
With the &lt;span class="caps"&gt;QEMU&lt;/span&gt; userspace&amp;nbsp;helper.&lt;/p&gt;
&lt;p&gt;You see, Mock allows to run builds for foreign architectures &amp;#8212; all you need is
the&amp;nbsp;proper &lt;code&gt;qemu-user-static-*&lt;/code&gt; package and you are ready to&amp;nbsp;go:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ fedpkg mockbuild -r fedora-43-riscv64
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can extract the &amp;#8220;fedora-43-riscv64&amp;#8221; Mock config from the
&lt;a href="http://fedora.riscv.rocks:3000/rpms/mock-core-configs/src/branch/main-riscv64/mock-riscv64-configs.patch"&gt;mock-riscv64-configs.patch&lt;/a&gt;
hosted on Fedora &lt;span class="caps"&gt;RISC&lt;/span&gt;-V port forge. I hope that these configuration files may be
found in the &amp;#8220;mock-core-configs&amp;#8221; in Fedora&amp;nbsp;soon.&lt;/p&gt;
&lt;p&gt;At some point I had&amp;nbsp;337 &lt;code&gt;qemu-user-static-riscv&lt;/code&gt; processes running at same
time. And you know what? It was &lt;strong&gt;still faster than a native build on 64-bit
&lt;span class="caps"&gt;RISC&lt;/span&gt;-V hardware&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;But, to be honest, I only compared a few builds, so it may be better with other
builders. Fedora &lt;span class="caps"&gt;RISC&lt;/span&gt;-V Koji uses wide list of &lt;abbr title="Seriously Broken Computers"&gt;SBCs&lt;/abbr&gt; to build&amp;nbsp;on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Banana Pi &lt;span class="caps"&gt;BPI&lt;/span&gt;-F3&lt;/li&gt;
&lt;li&gt;Milk-V&amp;nbsp;Jupiter&lt;/li&gt;
&lt;li&gt;Milk-V&amp;nbsp;Megrez&lt;/li&gt;
&lt;li&gt;SiFive HiFive Premier&amp;nbsp;P550&lt;/li&gt;
&lt;li&gt;StarFive VisionFive&amp;nbsp;2&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also note that using &lt;span class="caps"&gt;QEMU&lt;/span&gt; is not a solution for building a distribution. I used
it only to check if package builds, and then scrap the&amp;nbsp;results.&lt;/p&gt;
&lt;h3&gt;Future&lt;/h3&gt;
&lt;p&gt;Will I continue working on the &lt;span class="caps"&gt;RISC&lt;/span&gt;-V port of Fedora Linux? Probably yes. And,
at some point, I will move to integrating those changes into CentOS Stream&amp;nbsp;10.&lt;/p&gt;
&lt;p&gt;For sure I do not want to invest in &lt;span class="caps"&gt;RISC&lt;/span&gt;-V hardware. Existing models are not
worth the money (in my opinion), incoming ones are still old (&lt;span class="caps"&gt;RVA20&lt;/span&gt;/&lt;span class="caps"&gt;RVA22&lt;/span&gt;) and
they are slow. Maybe in two, three years there will be something fast&amp;nbsp;enough.&lt;/p&gt;</content><category term="misc"/><category term="aarch64"/><category term="development"/><category term="fedora"/><category term="risc-v"/><category term="virtualization"/><category term="qemu"/></entry><entry><title>ConfigurationManager in EDK2: just say no</title><link href="https://marcin.juszkiewicz.com.pl/2024/04/16/configurationmanager-in-edk2-just-say-no/" rel="alternate"/><published>2024-04-16T09:44:00+02:00</published><updated>2024-04-16T09:44:00+02:00</updated><author><name>Marcin Juszkiewicz</name></author><id>tag:marcin.juszkiewicz.com.pl,2024-04-16:/2024/04/16/configurationmanager-in-edk2-just-say-no/</id><summary type="html">There are better things for thousand lines of&amp;nbsp;code.</summary><content type="html">&lt;p&gt;During my work on &lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform I have spent lot of time in firmware&amp;#8217;s
code. Which mostly meant Tianocore &lt;span class="caps"&gt;EDK2&lt;/span&gt; as Trusted Firmware is quite&amp;nbsp;small.&lt;/p&gt;
&lt;p&gt;Writing all those &lt;span class="caps"&gt;ACPI&lt;/span&gt; tables by hand takes time. So I checked
ConfigurationManager component which can do it for&amp;nbsp;me.&lt;/p&gt;
&lt;!--MORE--&gt;

&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;In 2018 Sami Mujawar from Arm contributed Dynamic Tables Framework to Tianocore
&lt;span class="caps"&gt;EDK2&lt;/span&gt; project. The goal was to have code which generates all &lt;span class="caps"&gt;ACPI&lt;/span&gt; tables from
all those data structs describing hardware which &lt;span class="caps"&gt;EDK2&lt;/span&gt; already&amp;nbsp;has.&lt;/p&gt;
&lt;p&gt;In 2023 I was writing code for &lt;span class="caps"&gt;IORT&lt;/span&gt; and &lt;span class="caps"&gt;GTDT&lt;/span&gt; tables to generate them from C. And
started wondering about use of&amp;nbsp;ConfigurationManager.&lt;/p&gt;
&lt;p&gt;Mailed edk2-devel &lt;span class="caps"&gt;ML&lt;/span&gt; for pointers, documentation, hints. Got nothing in return,
idea went to the&amp;nbsp;shelf.&lt;/p&gt;
&lt;h3&gt;&lt;span class="caps"&gt;SBSA&lt;/span&gt;-Ref and multiple &lt;span class="caps"&gt;PCI&lt;/span&gt; Express&amp;nbsp;buses&lt;/h3&gt;
&lt;p&gt;Last week I got &lt;span class="caps"&gt;SBSA&lt;/span&gt;-Ref system booting in &lt;span class="caps"&gt;NUMA&lt;/span&gt; configuration with three
separate &lt;span class="caps"&gt;PCI&lt;/span&gt; Express buses. And started working on getting &lt;span class="caps"&gt;EDK2&lt;/span&gt; firmware to
recognize them as&amp;nbsp;such.&lt;/p&gt;
&lt;p&gt;Took me a day&amp;nbsp;and &lt;code&gt;pci&lt;/code&gt; command listed cards&amp;nbsp;properly:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Shell&amp;gt; pci
   Seg  Bus  Dev  Func
   ---  ---  ---  ----
    00   00   00    00 ==&amp;gt; Bridge Device - Host/PCI bridge
             Vendor 1B36 Device 0008 Prog Interface 0
    00   00   01    00 ==&amp;gt; Network Controller - Ethernet controller
             Vendor 8086 Device 10D3 Prog Interface 0
    00   00   02    00 ==&amp;gt; Bridge Device - PCI/PCI bridge
             Vendor 1B36 Device 000C Prog Interface 0
    00   00   03    00 ==&amp;gt; Bridge Device - Host/PCI bridge
             Vendor 1B36 Device 000B Prog Interface 0
    00   00   04    00 ==&amp;gt; Bridge Device - Host/PCI bridge
             Vendor 1B36 Device 000B Prog Interface 0
    00   01   00    00 ==&amp;gt; Mass Storage Controller - Non-volatile memory subsystem
             Vendor 1B36 Device 0010 Prog Interface 2
    00   40   00    00 ==&amp;gt; Bridge Device - PCI/PCI bridge
             Vendor 1B36 Device 000C Prog Interface 0
    00   40   01    00 ==&amp;gt; Bridge Device - PCI/PCI bridge
             Vendor 1B36 Device 000C Prog Interface 0
    00   41   00    00 ==&amp;gt; Base System Peripherals - SD Host controller
             Vendor 1B36 Device 0007 Prog Interface 1
    00   42   00    00 ==&amp;gt; Display Controller - Other display controller
             Vendor 1234 Device 1111 Prog Interface 0
    00   80   00    00 ==&amp;gt; Bridge Device - PCI/PCI bridge
             Vendor 1B36 Device 000E Prog Interface 0
    00   80   01    00 ==&amp;gt; Bridge Device - PCI/PCI bridge
             Vendor 1B36 Device 000C Prog Interface 0
    00   81   09    00 ==&amp;gt; Multimedia Device - Audio device
             Vendor 1274 Device 5000 Prog Interface 0
    00   81   10    00 ==&amp;gt; Network Controller - Ethernet controller
             Vendor 8086 Device 100E Prog Interface 0
    00   82   00    00 ==&amp;gt; Mass Storage Controller - Serial ATA controller
             Vendor 8086 Device 2922 Prog Interface 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Three buses are: 0x00, 0x40 and 0x80. But then I had to tell Operating System
about those. Which meant playing with &lt;span class="caps"&gt;ACPI&lt;/span&gt; tables code in&amp;nbsp;C.&lt;/p&gt;
&lt;p&gt;So idea came &amp;#8220;what about trying&amp;nbsp;ConfigurationManager?&amp;#8221;.&lt;/p&gt;
&lt;h3&gt;Another&amp;nbsp;try&lt;/h3&gt;
&lt;p&gt;Mailed edk2-devel &lt;span class="caps"&gt;ML&lt;/span&gt; again for pointers, documentation hints. And then looked at
code written for &lt;span class="caps"&gt;N1SDP&lt;/span&gt; and started playing with&amp;nbsp;ConfigurationManager&amp;#8230;&lt;/p&gt;
&lt;p&gt;ConfigurationManager.c has EDKII_PLATFORM_REPOSITORY_INFO struct with
hundreds of lines of data (as another structs). From listing which &lt;span class="caps"&gt;ACPI&lt;/span&gt; tables I
want to have (&lt;span class="caps"&gt;FADT&lt;/span&gt;, &lt;span class="caps"&gt;GTDT&lt;/span&gt;, &lt;span class="caps"&gt;APIC&lt;/span&gt;, &lt;span class="caps"&gt;SPCR&lt;/span&gt;, &lt;span class="caps"&gt;DBG2&lt;/span&gt;, &lt;span class="caps"&gt;IORT&lt;/span&gt;, &lt;span class="caps"&gt;MCFG&lt;/span&gt;, &lt;span class="caps"&gt;SRAT&lt;/span&gt;, &lt;span class="caps"&gt;DSDT&lt;/span&gt;, &lt;span class="caps"&gt;PPTT&lt;/span&gt; etc.)
to listing all hardware details like &lt;span class="caps"&gt;GIC&lt;/span&gt;, PCIe, Timers, &lt;span class="caps"&gt;CPU&lt;/span&gt; and Memory&amp;nbsp;information.&lt;/p&gt;
&lt;p&gt;Then code for querying this struct. I thought that &lt;span class="caps"&gt;CM&lt;/span&gt;/&lt;span class="caps"&gt;DT&lt;/span&gt;
(ConfigurationManager/DynamicTables) framework will have those already in &lt;span class="caps"&gt;EDK2&lt;/span&gt;
code but no &amp;#8212; each platform has own set of functions. Another hundreds of lines
to&amp;nbsp;maintain.&lt;/p&gt;
&lt;p&gt;Took some time to get it built, then started filling proper data and compared
with &lt;span class="caps"&gt;ACPI&lt;/span&gt; tables I had previously. There were differences to sort out. But
digging more and more into code I saw that I go deeper and deeper into rabbit&amp;nbsp;hole&amp;#8230;&lt;/p&gt;
&lt;h3&gt;Dynamic systems do not fit &lt;span class="caps"&gt;CM&lt;/span&gt;?&lt;/h3&gt;
&lt;p&gt;For platforms with dynamic hardware configuration (like &lt;span class="caps"&gt;SBSA&lt;/span&gt;-Ref) I needed to
write code which would populate that struct with data on runtime. Check amount
of cpu cores and write cpu information (with topology, cache etc), create all
&lt;span class="caps"&gt;GIC&lt;/span&gt; structures and mappings. Then same for PCIe buses. Etc. Etc.&amp;nbsp;etc&amp;#8230;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;STATIC
EFI_STATUS
EFIAPI
InitializePlatformRepository (
  IN  EDKII_PLATFORM_REPOSITORY_INFO  * CONST PlatRepoInfo
  )
{
  GicInfo                 GicInfo;
  CM_ARM_GIC_REDIST_INFO *GicRedistInfo;
  CM_ARM_GIC_ITS_INFO    *GicItsInfo;
  CM_ARM_SMMUV3_NODE     *SmmuV3Info;

  GetGicDetails(&amp;amp;GicInfo);
  PlatRepoInfo-&amp;gt;GicDInfo.PhysicalBaseAddress = GicInfo.DistributorBase;

  GicRedistInfo = &amp;amp;PlatRepoInfo-&amp;gt;GicRedistInfo[0];

  GicRedistInfo-&amp;gt;DiscoveryRangeBaseAddress = GicInfo.RedistributorsBase;

  GicItsInfo = &amp;amp;PlatRepoInfo-&amp;gt;GicItsInfo[0];
  GicItsInfo-&amp;gt;PhysicalBaseAddress = GicInfo.ItsBase;

  SmmuV3Info = &amp;amp;PlatRepoInfo-&amp;gt;SmmuV3Info[0];
  SmmuV3Info-&amp;gt;BaseAddress = PcdGet64 (PcdSmmuBase);

  return EFI_SUCCESS;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which in my case can mean even more code written to populate &lt;span class="caps"&gt;CM&lt;/span&gt; struct of
structs than it would take to generate &lt;span class="caps"&gt;ACPI&lt;/span&gt; tables by&amp;nbsp;hand.&lt;/p&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;ConfigurationManager and DynamicTables frameworks look tempting. There may be
systems where it can be used with success. I know that I do not want to touch it
again. All those structs of structs may look good for someone familiar with &lt;span class="caps"&gt;LISP&lt;/span&gt;
or &lt;span class="caps"&gt;JSON&lt;/span&gt; but not for&amp;nbsp;me.&lt;/p&gt;</content><category term="misc"/><category term="aarch64"/><category term="edk2"/><category term="linaro"/><category term="virtualization"/></entry><entry><title>DT-free EDK2 on SBSA Reference Platform</title><link href="https://marcin.juszkiewicz.com.pl/2024/04/04/dt-free-edk2-on-sbsa-reference-platform/" rel="alternate"/><published>2024-04-04T13:26:00+02:00</published><updated>2024-04-04T13:26:00+02:00</updated><author><name>Marcin Juszkiewicz</name></author><id>tag:marcin.juszkiewicz.com.pl,2024-04-04:/2024/04/04/dt-free-edk2-on-sbsa-reference-platform/</id><summary type="html">Who needs DeviceTree on SystemReady &lt;span class="caps"&gt;SR&lt;/span&gt;?</summary><content type="html">&lt;p&gt;During last weeks we worked on getting rid of DeviceTree from &lt;span class="caps"&gt;EDK2&lt;/span&gt; on &lt;span class="caps"&gt;SBSA&lt;/span&gt;
Reference Platform. And finally we&amp;nbsp;managed!&lt;/p&gt;
&lt;p&gt;All code is merged into upstream &lt;span class="caps"&gt;EDK2&lt;/span&gt;&amp;nbsp;repository.&lt;/p&gt;
&lt;!--MORE--&gt;

&lt;h3&gt;What?&lt;/h3&gt;
&lt;p&gt;Someone may wonder where DeviceTree was in &lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform. Wasn&amp;#8217;t it
&lt;span class="caps"&gt;UEFI&lt;/span&gt; and &lt;span class="caps"&gt;ACPI&lt;/span&gt;&amp;nbsp;platform?&lt;/p&gt;
&lt;p&gt;Yes, from Operating System point of view it is &lt;span class="caps"&gt;UEFI&lt;/span&gt; and &lt;span class="caps"&gt;ACPI&lt;/span&gt;. But if you look
deeper you will see DeviceTree hidden inside our chain of software&amp;nbsp;components:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/dts-v1/;

/ {
        machine-version-minor = &amp;lt;0x03&amp;gt;;
        machine-version-major = &amp;lt;0x00&amp;gt;;
        #size-cells = &amp;lt;0x02&amp;gt;;
        #address-cells = &amp;lt;0x02&amp;gt;;
        compatible = &amp;quot;linux,sbsa-ref&amp;quot;;

        chosen {
        };

        memory@10000000000 {
                reg = &amp;lt;0x100 0x00 0x00 0x40000000&amp;gt;;
                device_type = &amp;quot;memory&amp;quot;;
        };

        intc {
                reg = &amp;lt;0x00 0x40060000 0x00 0x10000
                       0x00 0x40080000 0x00 0x4000000&amp;gt;;

                its {
                        reg = &amp;lt;0x00 0x44081000 0x00 0x20000&amp;gt;;
                };
        };

        cpus {
                #size-cells = &amp;lt;0x00&amp;gt;;
                #address-cells = &amp;lt;0x02&amp;gt;;

                cpu@0 {
                        reg = &amp;lt;0x00 0x00&amp;gt;;
                };

                cpu@1 {
                        reg = &amp;lt;0x00 0x01&amp;gt;;
                };

                cpu@2 {
                        reg = &amp;lt;0x00 0x02&amp;gt;;
                };

                cpu@3 {
                        reg = &amp;lt;0x00 0x03&amp;gt;;
                };
        };
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is very minimal one, providing us with only those information we need. It
does not even pass any compliance checks. For example for Linux, &lt;span class="caps"&gt;GIC&lt;/span&gt; node
(/intc/ one) should have gazillion of fields, but we only need&amp;nbsp;addresses.&lt;/p&gt;
&lt;p&gt;Trusted Firmware reads it, parses and provides information from it via Secure
Monitor Calls (&lt;span class="caps"&gt;SMC&lt;/span&gt;) to upper firmware level (&lt;span class="caps"&gt;EDK2&lt;/span&gt; in our case). DeviceTree is
provided too but we do not read it any&amp;nbsp;more.&lt;/p&gt;
&lt;h3&gt;Why?&lt;/h3&gt;
&lt;p&gt;Our goal is to treat software components a bit different then people may expect.
&lt;span class="caps"&gt;QEMU&lt;/span&gt; is &amp;#8220;virtual hardware&amp;#8221; layer, &lt;span class="caps"&gt;TF&lt;/span&gt;-A provides interface to &amp;#8220;embedded
controller&amp;#8221; (&lt;span class="caps"&gt;EC&lt;/span&gt;) layer and &lt;span class="caps"&gt;EDK2&lt;/span&gt; is firmware layer on&amp;nbsp;top.&lt;/p&gt;
&lt;p&gt;On physical hardware firmware assumes some parts and asks &lt;span class="caps"&gt;EC&lt;/span&gt; for the rest of
system information. &lt;span class="caps"&gt;QEMU&lt;/span&gt; does not give us that, while giving us a way to alter
system configuration more than it would be possible on most of hardware
platforms using a bunch of cli&amp;nbsp;arguments.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;EDK2&lt;/span&gt; asks for &lt;span class="caps"&gt;CPU&lt;/span&gt;, &lt;span class="caps"&gt;GIC&lt;/span&gt; and Memory. When there is no info about processors or
memory, it informs the user and shutdowns the system (such situation does not
have a chance of happening but it works as an&amp;nbsp;example).&lt;/p&gt;
&lt;h3&gt;Bonus stuff: &lt;span class="caps"&gt;NUMA&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Bonus part of this work was adding firmware support for &lt;span class="caps"&gt;NUMA&lt;/span&gt; configuration. When
&lt;span class="caps"&gt;QEMU&lt;/span&gt; is run with &lt;span class="caps"&gt;NUMA&lt;/span&gt; arguments then operating system gets whole memory and
proper configuration&amp;nbsp;information.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;QEMU&lt;/span&gt; arguments&amp;nbsp;used:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-smp 4,sockets=4,maxcpus=4
-m 4G,slots=2,maxmem=5G
-object memory-backend-ram,size=1G,id=m0
-object memory-backend-ram,size=3G,id=m1
-numa node,nodeid=0,cpus=0-1,memdev=m0
-numa node,nodeid=1,cpus=2,memdev=m1
-numa node,nodeid=2,cpus=3
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;How Operating System sees &lt;span class="caps"&gt;NUMA&lt;/span&gt;&amp;nbsp;information:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;root@sbsa-ref:~# numactl --hardware
available: 3 nodes (0-2)
node 0 cpus: 0 1
node 0 size: 975 MB
node 0 free: 840 MB
node 1 cpus: 2
node 1 size: 2950 MB
node 1 free: 2909 MB
node 2 cpus: 3
node 2 size: 0 MB
node 2 free: 0 MB
node distances:
node   0   1   2
  0:  10  20  20
  1:  20  10  20
  2:  20  20  10
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;What&amp;nbsp;next?&lt;/h3&gt;
&lt;p&gt;There is &lt;span class="caps"&gt;CPU&lt;/span&gt; topology information in review queue. All those sockets, clusters,
cores and threads. &lt;span class="caps"&gt;QEMU&lt;/span&gt; will pass it in DeviceTree, &lt;span class="caps"&gt;TF&lt;/span&gt;-A will give it via &lt;span class="caps"&gt;SMC&lt;/span&gt;
and then &lt;span class="caps"&gt;EDK2&lt;/span&gt; will put it in one of &lt;span class="caps"&gt;ACPI&lt;/span&gt; tables (&lt;span class="caps"&gt;PPTT&lt;/span&gt; == Processor Properties
Topology&amp;nbsp;Table).&lt;/p&gt;
&lt;p&gt;If someone decide to write own firmware for &lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform (like port
of U-Boot) then both DeviceTree and set of &lt;span class="caps"&gt;SMC&lt;/span&gt; calls will wait for them, ready
to be used to gather hardware&amp;nbsp;information.&lt;/p&gt;</content><category term="misc"/><category term="aarch64"/><category term="sbsa"/><category term="linaro"/><category term="virtualization"/></entry><entry><title>Running SBSA Reference Platform</title><link href="https://marcin.juszkiewicz.com.pl/2024/03/25/running-sbsa-reference-platform/" rel="alternate"/><published>2024-03-25T11:21:00+01:00</published><updated>2024-03-25T11:21:00+01:00</updated><author><name>Marcin Juszkiewicz</name></author><id>tag:marcin.juszkiewicz.com.pl,2024-03-25:/2024/03/25/running-sbsa-reference-platform/</id><summary type="html">sbsa-ref can be used for testing several things&amp;nbsp;:)</summary><content type="html">&lt;p&gt;Recently people asked me how to run &lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform for their own
testing and development. Which shows that I should write some&amp;nbsp;documentation.&lt;/p&gt;
&lt;p&gt;But first let me blog about&amp;nbsp;it&amp;#8230;&lt;/p&gt;
&lt;!--MORE--&gt;

&lt;h3&gt;Requirements&lt;/h3&gt;
&lt;p&gt;To run &lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform emulation you&amp;nbsp;need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class="caps"&gt;QEMU&lt;/span&gt; (8.2+&amp;nbsp;recommended)&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;EDK2&lt;/span&gt; firmware&amp;nbsp;files&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That&amp;#8217;s all. Sure, some hardware resources would be handy but everyone has some
kind of computer available,&amp;nbsp;right?&lt;/p&gt;
&lt;h4&gt;&lt;span class="caps"&gt;QEMU&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Nothing special is required as long as you&amp;nbsp;have &lt;code&gt;qemu-system-aarch64&lt;/code&gt; binary&amp;nbsp;available.&lt;/p&gt;
&lt;h4&gt;&lt;span class="caps"&gt;EDK2&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;We provide 
&lt;a href="https://artifacts.codelinaro.org/ui/native/linaro-419-sbsa-ref/"&gt;&lt;span class="caps"&gt;EDK2&lt;/span&gt; binaries&lt;/a&gt;
on CodeLinaro server. Go to &amp;#8220;latest/edk2&amp;#8221; directory, fetch both &amp;#8220;SBSA_FLASH*&amp;#8221;
files, unpack them and you are ready to go. You may compare checksums (before
unpacking) with values present in &amp;#8220;latest/&lt;span class="caps"&gt;README&lt;/span&gt;.txt&amp;#8221;&amp;nbsp;file.&lt;/p&gt;
&lt;p&gt;Those binaries are built from release versions of Trusted Firmware (&lt;span class="caps"&gt;TF&lt;/span&gt;-A) and
Tianocore &lt;span class="caps"&gt;EDK2&lt;/span&gt; plus latest &amp;#8220;edk2-platforms&amp;#8221; code (as this repo is not using&amp;nbsp;tags).&lt;/p&gt;
&lt;h5&gt;Building &lt;span class="caps"&gt;EDK2&lt;/span&gt;&lt;/h5&gt;
&lt;p&gt;If you decide to build &lt;span class="caps"&gt;EDK2&lt;/span&gt; on your own then we provide &lt;span class="caps"&gt;TF&lt;/span&gt;-A binaries in
&amp;#8220;edk2-non-osi&amp;#8221; repository. I update those when it is&amp;nbsp;needed.&lt;/p&gt;
&lt;p&gt;Instructions to build &lt;span class="caps"&gt;EDK2&lt;/span&gt; are provided in 
&lt;a href="https://github.com/tianocore/edk2-platforms/blob/master/Platform/Qemu/SbsaQemu/Readme.md"&gt;Qemu/SbsaQemu&lt;/a&gt;
directory of &amp;#8220;edk2-platforms&amp;#8221;&amp;nbsp;repository.&lt;/p&gt;
&lt;h3&gt;Running &lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform&amp;nbsp;emulation&lt;/h3&gt;
&lt;p&gt;Note that this machine is fully emulated. Even on AArch64 systems where
virtualization is&amp;nbsp;available.&lt;/p&gt;
&lt;p&gt;Let go through example &lt;span class="caps"&gt;QEMU&lt;/span&gt; command&amp;nbsp;line:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;qemu-system-aarch64
-machine sbsa-ref
-drive file=firmware/SBSA_FLASH0.fd,format=raw,if=pflash
-drive file=firmware/SBSA_FLASH1.fd,format=raw,if=pflash
-serial stdio
-device usb-kbd
-device usb-tablet
-cdrom disks/alpine-standard-3.19.1-aarch64.iso
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At first we select &amp;#8220;sbsa-ref&amp;#8221; machine (defaults to four Neoverse-N1 cpu cores
and &lt;span class="caps"&gt;1GB&lt;/span&gt; of ram). Then we point to firmware files (order of them is&amp;nbsp;important).&lt;/p&gt;
&lt;p&gt;Serial console is useful for diagnostic output, just remember to not press
Ctrl-C there unless you want to take whole emulation&amp;nbsp;down.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;USB&lt;/span&gt; devices are to have working keyboard and pointing device. &lt;span class="caps"&gt;USB&lt;/span&gt; tablet is more
useful that &lt;span class="caps"&gt;USB&lt;/span&gt; mouse&amp;nbsp;(&lt;code&gt;-device usb-mouse&lt;/code&gt; adds it). If you want to run *&lt;span class="caps"&gt;BSD&lt;/span&gt;
operating systems then I recommend to add &lt;span class="caps"&gt;USB&lt;/span&gt;&amp;nbsp;mouse.&lt;/p&gt;
&lt;p&gt;And the last entry adds Alpine 3.19.1 &lt;span class="caps"&gt;ISO&lt;/span&gt;&amp;nbsp;image.&lt;/p&gt;
&lt;p&gt;System boots to text console on graphical output. For some reason boot console
is on serial&amp;nbsp;port.&lt;/p&gt;
&lt;h4&gt;Adding hard&amp;nbsp;disk&lt;/h4&gt;
&lt;p&gt;If you want to add hard disk then adding&amp;nbsp;&amp;#8220;&lt;code&gt;-hdb disk.img&lt;/code&gt;&amp;#8221; is enough (&amp;#8220;hdb&amp;#8221; as
cdrom took 1st slot on the &lt;span class="caps"&gt;AHCI&lt;/span&gt;&amp;nbsp;controller).&lt;/p&gt;
&lt;p&gt;Handy thing is &amp;#8220;virtual &lt;span class="caps"&gt;FAT&lt;/span&gt; drive&amp;#8221; which allows to create guest&amp;#8217;s drive from
directory on the&amp;nbsp;host:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-drive if=ide,file=fat:ro:DIRECTORY_ON_HOST,format=raw
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is useful for running &lt;span class="caps"&gt;EFI&lt;/span&gt; binaries as this drive is visible in &lt;span class="caps"&gt;UEFI&lt;/span&gt;
environment. It is not present when operating system is&amp;nbsp;booted.&lt;/p&gt;
&lt;h4&gt;Adding &lt;span class="caps"&gt;NVME&lt;/span&gt;&amp;nbsp;drive&lt;/h4&gt;
&lt;p&gt;&lt;span class="caps"&gt;NVME&lt;/span&gt; is composed from two&amp;nbsp;things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;PCIe&amp;nbsp;device&lt;/li&gt;
&lt;li&gt;storage&amp;nbsp;drive&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So let add it in a nice way, using PCIe&amp;nbsp;root-port:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-device pcie-root-port,id=root_port_for_nvme1,chassis=2,slot=0
  -device nvme,serial=deadbeef,bus=root_port_for_nvme1,drive=nvme
     -drive file=disks/nvme.img,format=raw,id=nvme,if=none
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;Using &lt;span class="caps"&gt;NUMA&lt;/span&gt;&amp;nbsp;configuration&lt;/h4&gt;
&lt;p&gt;&lt;span class="caps"&gt;QEMU&lt;/span&gt; can emulate Non-Uniform Memory Access (&lt;span class="caps"&gt;NUMA&lt;/span&gt;) setup. This usually means
multisocket systems with memory available per cpu&amp;nbsp;socket.&lt;/p&gt;
&lt;p&gt;Example&amp;nbsp;config:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-smp 4,sockets=4,maxcpus=4
-m 4G,slots=2,maxmem=5G
-object memory-backend-ram,size=1G,id=m0
-object memory-backend-ram,size=3G,id=m1
-numa node,nodeid=0,cpus=0-1,memdev=m0
-numa node,nodeid=1,cpus=2,memdev=m1
-numa node,nodeid=2,cpus=3
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This adds four cpu sockets and &lt;span class="caps"&gt;4GB&lt;/span&gt; of memory. First node has 2 cpu cores and &lt;span class="caps"&gt;1GB&lt;/span&gt;
ram, second node has 1 cpu and &lt;span class="caps"&gt;3GB&lt;/span&gt; of ram and last node has 1 cpu without local&amp;nbsp;memory.&lt;/p&gt;
&lt;p&gt;Note that support for such setup in work in progress now (March 2024). We merged
required code into &lt;span class="caps"&gt;TF&lt;/span&gt;-A and have set of patches for &lt;span class="caps"&gt;EDK2&lt;/span&gt; in review. Without them
you will see resources only from the first &lt;span class="caps"&gt;NUMA&lt;/span&gt;&amp;nbsp;node.&lt;/p&gt;
&lt;h4&gt;Complex &lt;span class="caps"&gt;PCI&lt;/span&gt; Express&amp;nbsp;setup&lt;/h4&gt;
&lt;p&gt;Our platform has &lt;span class="caps"&gt;GIC&lt;/span&gt; &lt;span class="caps"&gt;ITS&lt;/span&gt; support so we can try some complex &lt;span class="caps"&gt;PCI&lt;/span&gt; Express&amp;nbsp;structures.&lt;/p&gt;
&lt;p&gt;This example uses PCIe switch to add more PCIe slots and then (to complicate
things) puts PCIe-to-&lt;span class="caps"&gt;PCI&lt;/span&gt; bridge into one of them to make use of old Intel e1000
network&amp;nbsp;card:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-device pcie-root-port,id=root_port_for_switch1,chassis=0,slot=0
  -device x3130-upstream,id=up_port1,bus=root_port_for_switch1
    -device xio3130-downstream,id=down_port1,bus=up_port1,chassis=1,slot=0
      -device ac97,bus=down_port1
    -device xio3130-downstream,id=down_port2,bus=up_port1,chassis=1,slot=1
   -device pcie-pci-bridge,id=pci1,bus=down_port2
     -device e1000,bus=pci1,addr=2
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Some helper&amp;nbsp;scripts&lt;/h3&gt;
&lt;p&gt;During last year I wrote some helper scripts for working with &lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference
Platform testing. They are stored in
&lt;a href="https://github.com/hrw/sbsa-ref-status"&gt;sbsa-ref-status&lt;/a&gt; repository on&amp;nbsp;GitHub.&lt;/p&gt;
&lt;p&gt;May lack up-to-date documentation but can show my way of using the&amp;nbsp;platform.&lt;/p&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;&lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform can be used for testing several things. From operating
systems to (S)&lt;span class="caps"&gt;BSA&lt;/span&gt; compliance of the platform. Or to check how some things are
emulated in &lt;span class="caps"&gt;QEMU&lt;/span&gt;. Or playing with PCIe setups (&lt;span class="caps"&gt;NUMA&lt;/span&gt; systems can have separate
&lt;span class="caps"&gt;PCI&lt;/span&gt; Express buses but we do not handle it yet in&amp;nbsp;firmware).&lt;/p&gt;
&lt;p&gt;Have&amp;nbsp;fun!&lt;/p&gt;</content><category term="misc"/><category term="sbsa-ref"/><category term="qemu"/><category term="virtualization"/><category term="aarch64"/><category term="linaro"/></entry><entry><title>Testing *BSD on SBSA Reference Platform</title><link href="https://marcin.juszkiewicz.com.pl/2023/10/03/testing-bsd-on-sbsa-reference-platform/" rel="alternate"/><published>2023-10-03T20:46:00+02:00</published><updated>2023-10-03T20:46:00+02:00</updated><author><name>Marcin Juszkiewicz</name></author><id>tag:marcin.juszkiewicz.com.pl,2023-10-03:/2023/10/03/testing-bsd-on-sbsa-reference-platform/</id><summary type="html">Testing with non-Linux systems is crucial for any hardware&amp;nbsp;platform.</summary><content type="html">&lt;p&gt;&lt;a href="https://developer.arm.com/documentation/den0109/latest/"&gt;SystemReady specification&lt;/a&gt;
mentions that system to be certified needs to be able to boot several operating&amp;nbsp;systems:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In addition, &lt;span class="caps"&gt;OS&lt;/span&gt; installation and boot logs are&amp;nbsp;required:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Windows &lt;span class="caps"&gt;PE&lt;/span&gt; boot log, from a &lt;span class="caps"&gt;GPT&lt;/span&gt; partitioned disk, is&amp;nbsp;required.&lt;/li&gt;
&lt;li&gt;VMware ESXi-Arm installation and boot logs are&amp;nbsp;recommended.&lt;/li&gt;
&lt;li&gt;Installation and boot logs from two of the Linux distros or BSDs are&amp;nbsp;required.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All logs must be submitted using the &lt;span class="caps"&gt;ES&lt;/span&gt;/&lt;span class="caps"&gt;SR&lt;/span&gt;&amp;nbsp;template.&lt;/p&gt;
&lt;p&gt;In choosing the Linux distros or BSDs, maximize the coverage by diversifying
the heritage. For example, the following shows the grouping of the&amp;nbsp;heritage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class="caps"&gt;RHEL&lt;/span&gt;/Fedora/CentOS/AlmaLinux/Rocky Linux/Oracle Linux/Anolis &lt;span class="caps"&gt;OS&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;SLES&lt;/span&gt;/openSUSE&lt;/li&gt;
&lt;li&gt;Ubuntu/Debian&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;CBL&lt;/span&gt;-Mariner&lt;/li&gt;
&lt;li&gt;NetBSD/OpenBSD/FreeBSD&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;So during last week I went through *&lt;span class="caps"&gt;BSD&lt;/span&gt;&amp;nbsp;ones.&lt;/p&gt;
&lt;!--MORE--&gt;

&lt;h3&gt;OpenBSD&lt;/h3&gt;
&lt;p&gt;Started with &amp;#8220;&lt;a href="https://www.openbsd.org/faq/faq4.html#Download"&gt;download OpenBSD&lt;/a&gt;&amp;#8221; page
and found out that there is no installation &lt;span class="caps"&gt;ISO&lt;/span&gt; for aarch64 architecture. Not&amp;nbsp;good.&lt;/p&gt;
&lt;p&gt;So I fetched miniroot73.img disk image instead and went on with&amp;nbsp;booting:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; OpenBSD/arm64 BOOTAA64 1.16
boot&amp;gt;
cannot open sd0a:/etc/random.seed: No such file or directory
booting sd0a:/bsd: 2798224+1058776+12709688+630920 [229059+91+651336+254968]=0x1
3ce628
FACP DBG2 MCFG SPCR APIC SSDT PPTT GTDT BGRT
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2023 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 7.3 (RAMDISK) #1941: Sat Mar 25 14:42:22 MDT 2023
    deraadt@arm64.openbsd.org:/usr/src/sys/arch/arm64/compile/RAMDISK
real mem  = 4287451136 (4088MB)
avail mem = 4073807872 (3885MB)
random: boothowto does not indicate good seed
mainbus0 at root: ACPI
psci0 at mainbus0: PSCI 1.1, SMCCC 1.2
cpu0 at mainbus0 mpidr 0: ARM Cortex-A57 r1p0
cpu0: 48KB 64b/line 3-way L1 PIPT I-cache, 32KB 64b/line 2-way L1 D-cache
cpu0: 2048KB 64b/line 16-way L2 cache
cpu0: CRC32,SHA2,SHA1,AES+PMULL,ASID16
efi0 at mainbus0: UEFI 2.7
efi0: EFI Development Kit II / SbsaQemu rev 0x10000
smbios0 at efi0: SMBIOS 3.4.0
smbios0: vendor EFI Development Kit II / SbsaQemu version &amp;quot;1.0&amp;quot; date 09/15/2023
smbios0: QEMU QEMU SBSA-REF Machine
agintc0 at mainbus0 shift 4:3 nirq 256 nredist 2: &amp;quot;interrupt-controller&amp;quot;
agtimer0 at mainbus0: 62500 kHz
acpi0 at mainbus0: ACPI 6.0
acpi0: tables DSDT FACP DBG2 MCFG SPCR APIC SSDT PPTT GTDT BGRT
acpimcfg0 at acpi0
acpimcfg0: addr 0xf0000000, bus 0-255
pluart0 at acpi0 COM0 addr 0x60000000/0x1000 irq 33
pluart0: console
ahci0 at acpi0 AHC0 addr 0x60100000/0x10000 irq 42: AHCI 1.0
ahci0: port 0: 1.5Gb/s
ahci0: port 1: 1.5Gb/s
scsibus0 at ahci0: 32 targets
sd0 at scsibus0 targ 0 lun 0: &amp;lt;ATA, QEMU HARDDISK, 2.5+&amp;gt; t10.ATA_QEMU_HARDDISK_QM00001_
sd0: 43MB, 512 bytes/sector, 88064 sectors, thin
sd1 at scsibus0 targ 1 lun 0: &amp;lt;ATA, QEMU HARDDISK, 2.5+&amp;gt; t10.ATA_QEMU_HARDDISK_QM00003_
sd1: 504MB, 512 bytes/sector, 1032192 sectors, thin
ehci0 at acpi0 USB0 addr 0x60110000/0x10000 irq 43panic: uvm_fault failed: ffffff800034c3e8 esr 96000050 far ffffff8066ef5048

The operating system has halted.
Please press any key to reboot.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see it hang on an attempt to initialize &lt;span class="caps"&gt;USB&lt;/span&gt; controller. Which shows
that our move from &lt;span class="caps"&gt;EHCI&lt;/span&gt; to &lt;span class="caps"&gt;XHCI&lt;/span&gt; was not properly tested&amp;nbsp;;(&lt;/p&gt;
&lt;p&gt;The problem was that our virtual hardware (&lt;span class="caps"&gt;QEMU&lt;/span&gt;) had &lt;span class="caps"&gt;XHCI&lt;/span&gt; (&lt;span class="caps"&gt;USB&lt;/span&gt; 3) controller on
non-discoverable platform bus. But firmware (&lt;span class="caps"&gt;EDK2&lt;/span&gt;) tells that it was &lt;span class="caps"&gt;EHCI&lt;/span&gt; (&lt;span class="caps"&gt;USB&lt;/span&gt; 2)&amp;nbsp;one.&lt;/p&gt;
&lt;p&gt;This got solved with Yuquan Wang&amp;#8217;s patch moving &lt;span class="caps"&gt;EDK2&lt;/span&gt; to initiate and describe
&lt;span class="caps"&gt;XHCI&lt;/span&gt; usb controller (change is already merged upstream). After rebuilding &lt;span class="caps"&gt;EDK2&lt;/span&gt;
OpenBSD booted fine right to the installation prompt (skipped previous&amp;nbsp;messages):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;xhci0 at acpi0 USB0 addr 0x60110000/0x10000 irq 43, xHCI 0.0
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 configuration 1 interface 0 &amp;quot;Generic xHCI root hub&amp;quot; rev 3.00/1.00 addr 1
acpipci0 at acpi0 PCI0
pci0 at acpipci0
0:1:0: rom address conflict 0xfffc0000/0x40000
0:2:0: rom address conflict 0xffff8000/0x8000
&amp;quot;Red Hat Host&amp;quot; rev 0x00 at pci0 dev 0 function 0 not configured
em0 at pci0 dev 1 function 0 &amp;quot;Intel 82574L&amp;quot; rev 0x00: msi, address 52:54:00:12:34:56
&amp;quot;Bochs VGA&amp;quot; rev 0x02 at pci0 dev 2 function 0 not configured
&amp;quot;ACPI0007&amp;quot; at acpi0 not configured
&amp;quot;ACPI0007&amp;quot; at acpi0 not configured
simplefb0 at mainbus0: 1280x800, 32bpp
wsdisplay0 at simplefb0 mux 1
wsdisplay0: screen 0 added (std, vt100 emulation)
uhidev0 at uhub0 port 1 configuration 1 interface 0 &amp;quot;QEMU QEMU USB Keyboard&amp;quot; rev 2.00/0.00 addr 2
uhidev0: iclass 3/1
ukbd0 at uhidev0
wskbd0 at ukbd0 mux 1
wskbd0: connecting to wsdisplay0
uhidev1 at uhub0 port 2 configuration 1 interface 0 &amp;quot;QEMU QEMU USB Tablet&amp;quot; rev 2.00/0.00 addr 3
uhidev1: iclass 3/0
uhid at uhidev1 not configured
softraid0 at root
scsibus1 at softraid0: 256 targets
root on rd0a swap on rd0b dump on rd0b
WARNING: CHECK AND RESET THE DATE!
erase ^?, werase ^W, kill ^U, intr ^C, status ^T

Welcome to the OpenBSD/arm64 7.3 installation program.
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell?
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After this I added booting OpenBSD to &lt;span class="caps"&gt;QEMU&lt;/span&gt; tests for &lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform to
make sure that we have something non-Linux based&amp;nbsp;there.&lt;/p&gt;
&lt;h3&gt;FreeBSD&lt;/h3&gt;
&lt;p&gt;The next one was FreeBSD. And here situation started to be&amp;nbsp;weird&amp;#8230;&lt;/p&gt;
&lt;p&gt;First I took 13.2 release. Used firmware with &lt;span class="caps"&gt;XHCI&lt;/span&gt; information and was greeted&amp;nbsp;with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Copyright (c) 1992-2021 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC arm64
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
VT(efifb): resolution 1280x800
module firmware already present!
real memory  = 4294967296 (4096 MB)
avail memory = 4160204800 (3967 MB)
Starting CPU 1 (1)
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
arc4random: WARNING: initial seeding bypassed the cryptographic random device because it was not yet seeded and the knob 'bypass_before_seeding' was enabled.
random: entropy device external interface
MAP 100fbdf0000 mode 2 pages 128
MAP 100fbe70000 mode 2 pages 160
MAP 100fbf10000 mode 2 pages 80
MAP 100fbfb0000 mode 2 pages 80
MAP 100ff500000 mode 2 pages 400
MAP 100ff690000 mode 2 pages 592
MAP 10000000 mode 0 pages 1728
MAP 60010000 mode 0 pages 1
kbd0 at kbdmux0
acpi0: &amp;lt;LINARO SBSAQEMU&amp;gt;
acpi0: Power Button (fixed)
acpi0: Sleep Button (fixed)
acpi0: Could not update all GPEs: AE_NOT_CONFIGURED
psci0: &amp;lt;ARM Power State Co-ordination Interface Driver&amp;gt; on acpi0
gic0: &amp;lt;ARM Generic Interrupt Controller v3.0&amp;gt; iomem 0x40060000-0x4007ffff,0x40080000-0x4407ffff on acpi0
its0: &amp;lt;ARM GIC Interrupt Translation Service&amp;gt; mem 0x44081000-0x440a0fff on gic0
generic_timer0: &amp;lt;ARM Generic Timer&amp;gt; irq 3,4,5 on acpi0
Timecounter &amp;quot;ARM MPCore Timecounter&amp;quot; frequency 62500000 Hz quality 1000
Event timer &amp;quot;ARM MPCore Eventtimer&amp;quot; frequency 62500000 Hz quality 1000
efirtc0: &amp;lt;EFI Realtime Clock&amp;gt;
efirtc0: registered as a time-of-day clock, resolution 1.000000s
uart0: &amp;lt;PrimeCell UART (PL011)&amp;gt; iomem 0x60000000-0x60000fff irq 0 on acpi0
uart0: console (115200,n,8,1)
ahci0: &amp;lt;AHCI SATA controller&amp;gt; iomem 0x60100000-0x6010ffff irq 1 on acpi0
ahci0: AHCI v1.00 with 6 1.5Gbps ports, Port Multiplier not supported
ahcich0: &amp;lt;AHCI channel&amp;gt; at channel 0 on ahci0
ahcich1: &amp;lt;AHCI channel&amp;gt; at channel 1 on ahci0
ahcich2: &amp;lt;AHCI channel&amp;gt; at channel 2 on ahci0
ahcich3: &amp;lt;AHCI channel&amp;gt; at channel 3 on ahci0
ahcich4: &amp;lt;AHCI channel&amp;gt; at channel 4 on ahci0
ahcich5: &amp;lt;AHCI channel&amp;gt; at channel 5 on ahci0
xhci0: &amp;lt;Generic USB 3.0 controller&amp;gt; iomem 0x60110000-0x6011ffff irq 2 on acpi0
xhci0: 32 bytes context size, 32-bit DMA
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And it hang&amp;nbsp;there&amp;#8230;&lt;/p&gt;
&lt;h4&gt;Let check newer&amp;nbsp;FreeBSD&lt;/h4&gt;
&lt;p&gt;Contacted people on #freebsd &lt;span class="caps"&gt;IRC&lt;/span&gt; channel and Mina Galić (meena on &lt;span class="caps"&gt;IRC&lt;/span&gt;) asked me
to boot FreeBSD 14 or 15 images. So I tried&amp;nbsp;both:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;xhci0: &amp;lt;Generic USB 3.0 controller&amp;gt; iomem 0x60110000-0x6011ffff irq 2 on acpi0
xhci0: 32 bytes context size, 64-bit DMA
usbus0 on xhci0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;System booted further. Note &amp;#8220;64-bit &lt;span class="caps"&gt;DMA&lt;/span&gt;&amp;#8221; information instead of &amp;#8220;32-bit &lt;span class="caps"&gt;DMA&lt;/span&gt;&amp;#8221;
from 13.2 release. Reported &lt;a href="https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274237"&gt;bug 274237&lt;/a&gt;
for it. On the same day required change was identified and marked for potential&amp;nbsp;backport.&lt;/p&gt;
&lt;h4&gt;&lt;span class="caps"&gt;AHCI&lt;/span&gt;&amp;nbsp;issue&lt;/h4&gt;
&lt;p&gt;But that was not the only problem. Turned out that none of &lt;span class="caps"&gt;AHCI&lt;/span&gt; devices were
found&amp;#8230; So no way to run an&amp;nbsp;installer:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ahci0: &amp;lt;AHCI SATA controller&amp;gt; iomem 0x60100000-0x6010ffff irq 1 on acpi0
ahci0: AHCI v1.00 with 6 1.5Gbps ports, Port Multiplier not supported
ahcich0: &amp;lt;AHCI channel&amp;gt; at channel 0 on ahci0
ahcich1: &amp;lt;AHCI channel&amp;gt; at channel 1 on ahci0
ahcich2: &amp;lt;AHCI channel&amp;gt; at channel 2 on ahci0
ahcich3: &amp;lt;AHCI channel&amp;gt; at channel 3 on ahci0
ahcich4: &amp;lt;AHCI channel&amp;gt; at channel 4 on ahci0
ahcich5: &amp;lt;AHCI channel&amp;gt; at channel 5 on ahci0
[..]
Release APs...done
Trying to mount root from cd9660:/dev/iso9660/13_2_RELEASE_AARCH64_BO [ro]...
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
Root mount waiting for: CAM
ahcich0: Poll timeout on slot 1 port 0
ahcich0: is 00000000 cs 00000002 ss 00000000 rs 00000002 tfd 170 serr 00000000 cmd 0000c017
(aprobe0:ahcich0:0:0:0): SOFT_RESET. ACB: 00 00 00 00 00 00 00 00 00 00 00 00
(aprobe0:ahcich0:0:0:0): CAM status: Command timeout
(aprobe0:ahcich0:0:0:0): Error 5, Retries exhausted
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I checked &lt;span class="caps"&gt;QEMU&lt;/span&gt; 7.2 (from Fedora package) and it booted fine. 8.0.5 failed, 8.0.0
booted. Hm&amp;#8230;  Started &amp;#8220;git bisect&amp;#8221; to find out which change broke it.  After
several rebuilds I found commit to&amp;nbsp;blame:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;commit 7bcd32128b227cee1fb39ff242d486ed9fff7648
Author: Niklas Cassel &amp;lt;niklas.cassel@wdc.com&amp;gt;
Date:   Fri Jun 9 16:08:40 2023 +0200

    hw/ide/ahci: simplify and document PxCI handling

    The AHCI spec states that:
    For NCQ, PxCI is cleared on command queued successfully.
&lt;/code&gt;&lt;/pre&gt;
&lt;h5&gt;Is it AArch64 only or&amp;nbsp;not?&lt;/h5&gt;
&lt;p&gt;The next step: checking is it global problem or only aarch64&amp;nbsp;one.&lt;/p&gt;
&lt;p&gt;I built x86-64 emulation component and checked Q35 machine (which also uses
&lt;span class="caps"&gt;AHCI&lt;/span&gt;). And FreeBSD failed exactly same way. This made bug reporting a lot easier
as there were several architectures and more users&amp;nbsp;affected.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://lore.kernel.org/qemu-devel/b7e00b36-2ac8-44fa-9847-b2025ebe05f6@linaro.org/"&gt;Mailed author and &lt;span class="caps"&gt;QEMU&lt;/span&gt; developers&lt;/a&gt;
about it. Described the problem, gave exact command line arguments for &lt;span class="caps"&gt;QEMU&lt;/span&gt; etc.
Niklas Cassel&amp;nbsp;replied:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I will have a look at&amp;nbsp;this.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So it will be&amp;nbsp;done.&lt;/p&gt;
&lt;h3&gt;NetBSD&lt;/h3&gt;
&lt;p&gt;Here situation was a bit similar to FreeBSD&amp;nbsp;one.&lt;/p&gt;
&lt;p&gt;Fetched &lt;a href="https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.3/evbarm-aarch64/binary/gzimg/arm64.img.gz"&gt;NetBSD 9.3 image&lt;/a&gt;
and booted just to see it hang (removed printk.time from&amp;nbsp;output):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
    2018, 2019, 2020, 2021, 2022
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 9.3 (GENERIC64) #0: Thu Aug  4 15:30:37 UTC 2022
 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/evbarm/compile/GENERIC64
total memory = 4075 MB
avail memory = 3929 MB
running cgd selftest aes-xts-256 aes-xts-512 done
armfdt0 (root)
simplebus0 at armfdt0: QEMU QEMU SBSA-REF Machine
simplebus1 at simplebus0
acpifdt0 at simplebus0
acpifdt0: using EFI runtime services for RTC
ACPI: RSDP 0x00000100FC020018 000024 (v02 LINARO)
ACPI: XSDT 0x00000100FC02FE98 00006C (v01 LINARO SBSAQEMU 20200810 LNRO 00000001)
ACPI: FACP 0x00000100FC02FB98 000114 (v06 LINARO SBSAQEMU 20200810 LNRO 00000001)
ACPI: DSDT 0x00000100FC02E998 000CD8 (v02 LINARO SBSAQEMU 20200810 INTL 20220331)
ACPI: DBG2 0x00000100FC02FA98 00005C (v00 LINARO SBSAQEMU 20200810 LNRO 00000001)
ACPI: MCFG 0x00000100FC02FE18 00003C (v01 LINARO SBSAQEMU 20200810 LNRO 00000001)
ACPI: SPCR 0x00000100FC02FF98 000050 (v02 LINARO SBSAQEMU 20200810 LNRO 00000001)
ACPI: IORT 0x00000100FC027518 0000DC (v00 LINARO SBSAQEMU 20200810 LNRO 00000001)
ACPI: APIC 0x00000100FC02E498 000108 (v04 LINARO SBSAQEMU 20200810 LNRO 00000001)
ACPI: SSDT 0x00000100FC02E898 000067 (v02 LINARO SBSAQEMU 20200810 LNRO 00000001)
ACPI: PPTT 0x00000100FC02FD18 0000B8 (v02 LINARO SBSAQEMU 20200810 LNRO 00000001)
ACPI: GTDT 0x00000100FC02E618 000084 (v03 LINARO SBSAQEMU 20200810 LNRO 00000001)
ACPI: 2 ACPI AML tables successfully acquired and loaded
acpi0 at acpifdt0: Intel ACPICA 20190405
cpu0 at acpi0: unknown CPU (ID = 0x411fd402)
cpu0: package 0, core 0, smt 0
cpu0: IC enabled, DC enabled, EL0/EL1 stack Alignment check enabled
cpu0: Cache Writeback Granule 16B, Exclusives Reservation Granule 16B
cpu0: Dcache line 64, Icache line 64
cpu0: L1 0KB/64B 4-way PIPT Instruction cache
cpu0: L1 0KB/64B 4-way PIPT Data cache
cpu0: L2 0KB/64B 8-way PIPT Unified cache
cpu0: revID=0x0, 4k table, 16k table, 64k table, 16bit ASID
cpu0: auxID=0x1011111110212120, GICv3, CRC32, SHA1, AES+PMULL, rounding, NaN propagation, denormals, 32x64bitRegs, Fused Multiply-Add
cpu1 at acpi0: unknown CPU (ID = 0x411fd402)
cpu1: package 0, core 1, smt 0
gicvthree0 at acpi0: GICv3
gicvthree0: ITS #0 at 0x44081000
gicvthree0: ITS [#0] Devices table @ 0x10009210000/0x80000, Cacheable WA WB, Inner shareable
gicvthree0: ITS [#1] Collections table @ 0x10009290000/0x10000, Cacheable WA WB, Inner shareable
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As 9.3 release is quite old I tested NetBSD&amp;nbsp;10-Beta:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;gicvthree0 at acpi0: GICv3
gicvthree0: ITS #0 at 0x44081000
gicvthree0: ITS [#0] Devices table @ 0x10008a60000/0x80000, Cacheable WA WB, Inner shareable
gicvthree0: ITS [#1] Collections table @ 0x10008ae0000/0x10000, Cacheable WA WB, Inner shareable
gtmr0 at acpi0: irq 27
armgtmr0 at gtmr0: Generic Timer (62500 kHz, virtual)
plcom0 at acpi0 (COM0, ARMH0011-0): mem 0x60000000-0x60000fff irq 33
plcom0: console
[..]
NetBSD-10.0_BETA Install System
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Went to #netbsd channel on &lt;span class="caps"&gt;IRC&lt;/span&gt; and started disussion. Michael van Elst (mlelstv
on irc) gave me a helping hand and debugged the problem. Looks like kernel went
into infinite loop on parsing &lt;span class="caps"&gt;GTDT&lt;/span&gt; table from &lt;span class="caps"&gt;ACPI&lt;/span&gt;. Newer branches of NetBSD
have additional check&amp;nbsp;there.&lt;/p&gt;
&lt;p&gt;Filled &lt;a href="https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57642"&gt;bug 57642&lt;/a&gt; 
for it. And, like in FreeBSD case, it looks like some backport to stable branch
is&amp;nbsp;needed.&lt;/p&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;Testing platforms for SystemReady compliance needs to include *&lt;span class="caps"&gt;BSD&lt;/span&gt; systems.
Linux and NetBSD were fine with our &lt;span class="caps"&gt;USB&lt;/span&gt; controller mess &amp;#8212; gave &amp;#8220;something is
wrong&amp;#8221; message and went on. FreeBSD and OpenBSD systems were complaining and
stopped booting&amp;nbsp;process.&lt;/p&gt;
&lt;p&gt;We also need to do more testing before merging big changes in future. This &lt;span class="caps"&gt;USB&lt;/span&gt;
controller mess could be avoided or done&amp;nbsp;better.&lt;/p&gt;</content><category term="misc"/><category term="aarch64"/><category term="linaro"/><category term="qemu"/><category term="sbsa-ref"/><category term="virtualization"/></entry><entry><title>SBSA Reference Platform update</title><link href="https://marcin.juszkiewicz.com.pl/2023/09/15/sbsa-reference-platform-update/" rel="alternate"/><published>2023-09-15T15:30:00+02:00</published><updated>2023-09-15T15:30:00+02:00</updated><author><name>Marcin Juszkiewicz</name></author><id>tag:marcin.juszkiewicz.com.pl,2023-09-15:/2023/09/15/sbsa-reference-platform-update/</id><summary type="html">Some updates about &lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform (sbsa-ref) in &lt;span class="caps"&gt;QEMU&lt;/span&gt;</summary><content type="html">&lt;p&gt;There were several changes done since &lt;a href="/2023/05/23/versioning-of-sbsa-ref-machine/"&gt;my previous post&lt;/a&gt;
on the topic. So after some discussions I decided to write a post about&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;There are improvements, fixes and even issues with &lt;span class="caps"&gt;BSA&lt;/span&gt;&amp;nbsp;specification.&lt;/p&gt;
&lt;!--MORE--&gt;

&lt;h3&gt;Versioning related&amp;nbsp;changes&lt;/h3&gt;
&lt;p&gt;&lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform (&amp;#8220;sbsa-ref&amp;#8221; in short) is now at version 0.3 one. Note
that this is internal number. Machine name is still the&amp;nbsp;same.&lt;/p&gt;
&lt;p&gt;First bump was adding &lt;span class="caps"&gt;GIC&lt;/span&gt; data into (minimalistic) device-tree so firmware can
configure it without using any magic numbers (as it was&amp;nbsp;before).&lt;/p&gt;
&lt;p&gt;Second update added &lt;span class="caps"&gt;GIC&lt;/span&gt; &lt;span class="caps"&gt;ITS&lt;/span&gt; (Interrupt Translation Services) support. Which
means that we can have &lt;span class="caps"&gt;MSI&lt;/span&gt;-X interrupts and complex &lt;span class="caps"&gt;PCI&lt;/span&gt; Express&amp;nbsp;setup.&lt;/p&gt;
&lt;p&gt;Third time we said goodbye to &lt;span class="caps"&gt;USB&lt;/span&gt; 2.0 (&lt;span class="caps"&gt;EHCI&lt;/span&gt;) host controller. It never worked
and only generated kernel warnings. &lt;span class="caps"&gt;XHCI&lt;/span&gt; (&lt;span class="caps"&gt;USB&lt;/span&gt; 3) controller is used instead now.
&lt;span class="caps"&gt;EDK2&lt;/span&gt; enablement is still work in&amp;nbsp;progress.&lt;/p&gt;
&lt;h3&gt;Firmware&amp;nbsp;improvements&lt;/h3&gt;
&lt;p&gt;Most of versioning updates involved firmware changes. Information about hardware
details gets passed from virtual hardware level to operating system via standard
defined&amp;nbsp;ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Trusted Firmware (&lt;span class="caps"&gt;TF&lt;/span&gt;-A) gets minimalistic Device-Tree from &lt;span class="caps"&gt;QEMU&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;UEFI&lt;/span&gt; (&lt;span class="caps"&gt;EDK2&lt;/span&gt;) uses Secure Monitor Calls to get information from &lt;span class="caps"&gt;TF&lt;/span&gt;-A&lt;/li&gt;
&lt;li&gt;operating system uses &lt;span class="caps"&gt;ACPI&lt;/span&gt;&amp;nbsp;tables&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This way we were able to get rid of part of &amp;#8220;magic numbers&amp;#8221; from firmware&amp;nbsp;components.&lt;/p&gt;
&lt;h3&gt;&lt;span class="caps"&gt;CPU&lt;/span&gt;&amp;nbsp;updates&lt;/h3&gt;
&lt;p&gt;We can use Neoverse V1 cpu core now. It uses Arm v8.4 architecture and brings
&lt;span class="caps"&gt;SVE&lt;/span&gt; and a bunch of other interesting features. You may need to update Trusted
Firmware to make use of&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;QEMU&lt;/span&gt; got Arm Cortex-A710 cpu core support. It is first Arm v9.0 core there. Due
to 2&lt;sup&gt;40&lt;/sup&gt; address space we cannot use it for sbsa-ref. But it prepares
code for Neoverse N2/V2&amp;nbsp;cores.&lt;/p&gt;
&lt;h3&gt;&lt;span class="caps"&gt;PCI&lt;/span&gt; Express changes and&amp;nbsp;disputes&lt;/h3&gt;
&lt;p&gt;&lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform passes most of &lt;span class="caps"&gt;BSA&lt;/span&gt; &lt;span class="caps"&gt;ACS&lt;/span&gt; tests from &lt;span class="caps"&gt;PCI&lt;/span&gt; Express&amp;nbsp;module:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;      *** Starting PCIe tests ***

Operating System View:
 801 : Check ECAM Presence                        : Result:  PASS
 802 : PE - ECAM Region accessibility check       : Result:  PASS
 803 : All EP/Sw under RP in same ECAM Region     : Result:  PASS
 804 : Check RootPort NP Memory Access            : Result:  PASS
 805 : Check RootPort P Memory Access             : Result:  PASS
 806 : Legacy int must be SPI &amp;amp; lvl-sensitive
       Checkpoint --  2                           : Result:  SKIPPED
 808 : Check all 1's for out of range             : Result:  PASS
 809 : Vendor specfic data are PCIe compliant     : Result:  PASS
 811 : Check RP Byte Enable Rules                 : Result:  PASS
 817 : Check Direct Transl P2P Support
       Checkpoint --  1                           : Result:  SKIPPED
 818 : Check RP Adv Error Report
       Checkpoint --  1                           : Result:  SKIPPED
 819 : RP must suprt ACS if P2P Txn are allow
       Checkpoint --  1                           : Result:  SKIPPED
 820 : Type 0/1 common config rule                : Result:  PASS
 821 : Type 0 config header rules                 : Result:  PASS
 822 : Check Type 1 config header rules
       BDF 0x400 : SLT attribute mismatch: 0xFF020100 instead of 0x20100
       BDF 0x500 : SLT attribute mismatch: 0xFF030300 instead of 0x30300
       BDF 0x600 : SLT attribute mismatch: 0xFF040400 instead of 0x40400
       BDF 0x700 : SLT attribute mismatch: 0xFF050500 instead of 0x50500
       BDF 0x800 : SLT attribute mismatch: 0xFF060600 instead of 0x60600
       BDF 0x900 : SLT attribute mismatch: 0xFF080700 instead of 0x80700
       BDF 0x10000 : SLT attribute mismatch: 0xFF020201 instead of 0x20201
       Failed on PE -    0
       Checkpoint --  7                           : Result:  FAIL
 824 : Device capabilities reg rule               : Result:  PASS
 825 : Device Control register rule               : Result:  PASS
 826 : Device cap 2 register rules                : Result:  PASS
 830 : Check Cmd Reg memory space enable
       BDF 400 MSE functionality failure
       Failed on PE -    0
       Checkpoint --  1                           : Result:  FAIL
 831 : Check Type0/1 BIST Register rule           : Result:  PASS
 832 : Check HDR CapPtr Register rule             : Result:  PASS
 833 : Check Max payload size supported           : Result:  PASS
 835 : Check Function level reset                 : Result:  PASS
 836 : Check ARI forwarding enable rule           : Result:  PASS
 837 : Check Config Txn for RP in HB              : Result:  PASS
 838 : Check all RP in HB is in same ECAM         : Result:  PASS
 839 : Check MSI support for PCIe dev             : Result:  PASS
 840 : PCIe RC,PE - Same Inr Shareable Domain     : Result:  PASS
 841 : NP type-1 PCIe supp 32-bit only
       NP type-1 pcie is not 32-bit mem type
       Failed on PE -    0
       Checkpoint --  1                           : Result:  FAIL
 842 : PASID support atleast 16 bits
       Checkpoint --  3                           : Result:  SKIPPED

      One or more PCIe tests failed or were skipped.

     -------------------------------------------------------
     Total Tests run  =   30  Tests Passed  =   22  Tests Failed =    3
     -------------------------------------------------------
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you see some of them require&amp;nbsp;work.&lt;/p&gt;
&lt;h4&gt;Root ports &lt;span class="caps"&gt;SLT&lt;/span&gt;&amp;nbsp;issue&lt;/h4&gt;
&lt;p&gt;I reported problem with test 822 to &lt;span class="caps"&gt;QEMU&lt;/span&gt; developers and turned out that it is a
bug there. I got patch from Michael S. Tsirkin (one of &lt;span class="caps"&gt;QEMU&lt;/span&gt; &lt;span class="caps"&gt;PCI&lt;/span&gt; maintainers) and
it made test pass. I hope it will be merged&amp;nbsp;soon.&lt;/p&gt;
&lt;h4&gt;PCIe to &lt;span class="caps"&gt;PCI&lt;/span&gt; bridge&amp;nbsp;issue&lt;/h4&gt;
&lt;p&gt;I wonder how many &lt;span class="caps"&gt;SBSA&lt;/span&gt; physical platforms will use one of those. Probably none,
but my testing setup has&amp;nbsp;one.&lt;/p&gt;
&lt;p&gt;And it makes test 841 fail. This time problem requires more discussion because
&lt;span class="caps"&gt;BSA&lt;/span&gt; specification writes (chapter E.2 &lt;span class="caps"&gt;PCI&lt;/span&gt; Express Memory&amp;nbsp;Space):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When &lt;span class="caps"&gt;PCI&lt;/span&gt; Express memory space is mapped as normal memory, the system must
support unaligned accesses to that region.  &lt;span class="caps"&gt;PCI&lt;/span&gt; Type 1 headers, used in
&lt;span class="caps"&gt;PCI&lt;/span&gt;-to-&lt;span class="caps"&gt;PCI&lt;/span&gt; bridges, and therefore in root ports and switches, have to be
programmed with the address space resources claimed by the given bridge.  For
non-prefetchable (&lt;span class="caps"&gt;NP&lt;/span&gt;) memory, Type 1 headers only support 32-bit addresses.
This implies that endpoints on the other end of a &lt;span class="caps"&gt;PCI&lt;/span&gt;-to-&lt;span class="caps"&gt;PCI&lt;/span&gt; bridge only
support 32-bit &lt;span class="caps"&gt;NP&lt;/span&gt;&amp;nbsp;BARs.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;On the other side we have &lt;span class="caps"&gt;PCI&lt;/span&gt; Express Base Specification Revision 6.0 which, in chapter 7.5.1.2.1, says that &lt;span class="caps"&gt;BAR&lt;/span&gt; can be either 32 or 64-bit&amp;nbsp;long:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Base Address registers that map into Memory Space can be 32 bits or 64 bits wide (to support mapping into a 64-bit address space) with bit 0 hardwired to 0b. For Memory Base Address registers, bits 2 and 1 have an encoded meaning as shown in Table 7-9. Bit 3 should be set to 1b if the data is prefetchable and set to 0b otherwise. A Function is permitted to mark a range as prefetchable if there are
no side effects on reads, the Function returns all bytes on reads regardless of the byte enables, and host bridges can merge processor writes into this range 150 without causing errors. Bits 3-0 are&amp;nbsp;read-only.&lt;/p&gt;
&lt;p&gt;Table 7-9 Memory Base Address Register Bits 2:1&amp;nbsp;Encoding&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Bits 2:1(b)&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;00&lt;/td&gt;
&lt;td&gt;Base register is 32 bits wide and can be mapped anywhere in the 32 address bit Memory Space.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;01&lt;/td&gt;
&lt;td&gt;Reserved&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;Base register is 64 bits wide and can be mapped anywhere in the 64 address bit Memory Space.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;td&gt;Reserved&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/blockquote&gt;
&lt;p&gt;And pcie-pci-bridge device in &lt;span class="caps"&gt;QEMU&lt;/span&gt; uses 64-bit &lt;span class="caps"&gt;BAR&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;I opened support ticket for it at Arm. Will see how it&amp;nbsp;ends.&lt;/p&gt;
&lt;h3&gt;Non-secure &lt;span class="caps"&gt;EL2&lt;/span&gt; virtual&amp;nbsp;timer&lt;/h3&gt;
&lt;p&gt;Arm v8.1 architecture brought Virtual Host Extension (&lt;span class="caps"&gt;VHE&lt;/span&gt; in short). And it
added one more timer: non-secure &lt;span class="caps"&gt;EL2&lt;/span&gt; virtual&amp;nbsp;timer.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;BSA&lt;/span&gt; &lt;span class="caps"&gt;ACS&lt;/span&gt; checks for it and we were&amp;nbsp;failing:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; 226 : Check NS EL2-Virt timer PPI Assignment         START

       NS EL2 Virtual timer interrupt 28 not received
       Failed on PE -    0
       B_PPI_02
       Checkpoint --  4                           : Result:  FAIL
         END
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Turned out that everything to make it pass was already present in &lt;span class="caps"&gt;QEMU&lt;/span&gt;. Except
code to enable it for our platform. Two lines of code were&amp;nbsp;enough.&lt;/p&gt;
&lt;p&gt;After I sent my small patch, Leif Lindholm extracted timer definitions to
separate include file and cleaned code around it to make it easier to compare
&lt;span class="caps"&gt;QEMU&lt;/span&gt; code with &lt;span class="caps"&gt;BSA&lt;/span&gt;&amp;nbsp;specification.&lt;/p&gt;
&lt;p&gt;Result? Test&amp;nbsp;passes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; 226 : Check NS EL2-Virt timer PPI Assignment         START

       Received vir el2 interrupt
       B_PPI_02
                                       : Result:  PASS
         END
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;&lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform in &lt;span class="caps"&gt;QEMU&lt;/span&gt; gets better and better with time. We can emulate
more complex systems, information about hardware details gets passed from
virtual hardware level to operating system via standard defined&amp;nbsp;ways. &lt;/p&gt;
&lt;p&gt;Still have test failures but less than it was in&amp;nbsp;past.&lt;/p&gt;</content><category term="misc"/><category term="linaro"/><category term="aarch64"/><category term="sbsa-ref"/><category term="qemu"/><category term="virtualization"/></entry><entry><title>Versioning of sbsa-ref machine</title><link href="https://marcin.juszkiewicz.com.pl/2023/05/23/versioning-of-sbsa-ref-machine/" rel="alternate"/><published>2023-05-23T12:43:00+02:00</published><updated>2023-05-23T12:43:00+02:00</updated><author><name>Marcin Juszkiewicz</name></author><id>tag:marcin.juszkiewicz.com.pl,2023-05-23:/2023/05/23/versioning-of-sbsa-ref-machine/</id><summary type="html">Cleanup of sbsa-ref is in&amp;nbsp;progress.</summary><content type="html">&lt;p&gt;&lt;span class="caps"&gt;QEMU&lt;/span&gt; has emulation of several machines. One of them is &amp;#8220;sbsa-ref&amp;#8221; which stands
for &lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform. The Arm server in simpler&amp;nbsp;words.&lt;/p&gt;
&lt;p&gt;In past I worked on it when my help was needed. We have &lt;span class="caps"&gt;CI&lt;/span&gt; jobs which run some
tests (&lt;span class="caps"&gt;SBSA&lt;/span&gt; &lt;span class="caps"&gt;ACS&lt;/span&gt;, &lt;span class="caps"&gt;BSA&lt;/span&gt; &lt;span class="caps"&gt;ACS&lt;/span&gt;) and do some checks to see how we are with &lt;span class="caps"&gt;SBSA&lt;/span&gt;&amp;nbsp;compliance.&lt;/p&gt;
&lt;h3&gt;Versioning?&lt;/h3&gt;
&lt;p&gt;One day there was discussion that we need a way to recognize variants of
&amp;#8220;sbsa-ref&amp;#8221; in some sane way. The idea was to get rid of most of hardcoded values
and provide a way to have data going from &lt;span class="caps"&gt;QEMU&lt;/span&gt; up to&amp;nbsp;firmware.&lt;/p&gt;
&lt;!--MORE--&gt;

&lt;p&gt;We started with adding &amp;#8220;platform version major/minor&amp;#8221; fields into DeviceTree.
Starting with &amp;#8220;0.0&amp;#8221; as value. And for some time nothing changed here as some
of people working on &lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform changed jobs and other worked on
other parts of&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;Note that this is different than other &lt;span class="caps"&gt;QEMU&lt;/span&gt; targets. We do not go
&amp;#8220;sbsa-ref-8.0&amp;#8221;, &amp;#8220;sbsa-ref-8.1&amp;#8221; way as this would add maintenance work without
any gain for&amp;nbsp;us.&lt;/p&gt;
&lt;p&gt;During last Linaro Connect we had some discussion on how we want to proceed.
And some after (as not everyone got there &amp;#8212; &lt;span class="caps"&gt;UK&lt;/span&gt; visa&amp;nbsp;issues).&lt;/p&gt;
&lt;h3&gt;The&amp;nbsp;plan&lt;/h3&gt;
&lt;p&gt;The plan is&amp;nbsp;simple:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class="caps"&gt;QEMU&lt;/span&gt; adds data into&amp;nbsp;DeviceTree&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;TF&lt;/span&gt;-A parses DeviceTree and extracts data from&amp;nbsp;it&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;TF&lt;/span&gt;-A provides Secure Monitor Calls (&lt;span class="caps"&gt;SMC&lt;/span&gt;) with data from &lt;span class="caps"&gt;DT&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;EDK2&lt;/span&gt; uses &lt;span class="caps"&gt;SMC&lt;/span&gt; to gather data from &lt;span class="caps"&gt;TF&lt;/span&gt;-A&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;EDK2&lt;/span&gt; creates &lt;span class="caps"&gt;ACPI&lt;/span&gt;&amp;nbsp;tables&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;OS&lt;/span&gt; uses &lt;span class="caps"&gt;ACPI&lt;/span&gt; to get hardware&amp;nbsp;information&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Implementation&lt;/h3&gt;
&lt;p&gt;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&amp;nbsp;ones.&lt;/p&gt;
&lt;h4&gt;0.0: Platform version &lt;span class="caps"&gt;SMC&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Trusted Firmware (&lt;span class="caps"&gt;TF&lt;/span&gt;-A) reads DeviceTree from &lt;span class="caps"&gt;QEMU&lt;/span&gt; and provides platform
version (&lt;span class="caps"&gt;PV&lt;/span&gt; from now on) up to firmware via &lt;span class="caps"&gt;SMC&lt;/span&gt;. &lt;span class="caps"&gt;EDK2&lt;/span&gt; reads it and does
nothing (as&amp;nbsp;expected).&lt;/p&gt;
&lt;h4&gt;0.1: &lt;span class="caps"&gt;GIC&lt;/span&gt; data &lt;span class="caps"&gt;SMC&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Firmware knows which platform version we are on so it can do something about
it. So we bump the value in &lt;span class="caps"&gt;QEMU&lt;/span&gt; and provide Arm &lt;span class="caps"&gt;GIC&lt;/span&gt; addresses via another&amp;nbsp;SMCs.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;TF&lt;/span&gt;-A uses those values instead of hardcoded ones to initialize &lt;span class="caps"&gt;GIC&lt;/span&gt;. Then &lt;span class="caps"&gt;EDK2&lt;/span&gt;
does the&amp;nbsp;same.&lt;/p&gt;
&lt;p&gt;If such firmware boots on older &lt;span class="caps"&gt;QEMU&lt;/span&gt; then hardcoded values are used and
machine is operational&amp;nbsp;still.&lt;/p&gt;
&lt;h4&gt;0.2: &lt;span class="caps"&gt;GIC&lt;/span&gt; &lt;span class="caps"&gt;ITS&lt;/span&gt; &lt;span class="caps"&gt;SMC&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Here things start to be more interesting. We add Interrupt Translation Service
support to &lt;span class="caps"&gt;GIC&lt;/span&gt;. Which means we have &lt;span class="caps"&gt;LPI&lt;/span&gt;, &lt;span class="caps"&gt;MSI&lt;/span&gt;(-X) etc. In other words: have
normal, working &lt;span class="caps"&gt;PCI&lt;/span&gt; Express with root ports, proper interrupts&amp;nbsp;etc.&lt;/p&gt;
&lt;p&gt;From code side it is like previous step: &lt;span class="caps"&gt;QEMU&lt;/span&gt; adds address to &lt;span class="caps"&gt;DT&lt;/span&gt;, &lt;span class="caps"&gt;TF&lt;/span&gt;-A reads
it and provides via &lt;span class="caps"&gt;SMC&lt;/span&gt; to &lt;span class="caps"&gt;EDK2&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;If such firmware boots on older &lt;span class="caps"&gt;QEMU&lt;/span&gt; then &lt;span class="caps"&gt;ITS&lt;/span&gt; is not initialized as it was not
present in &lt;span class="caps"&gt;PV&lt;/span&gt; 0.0&amp;nbsp;system.&lt;/p&gt;
&lt;h4&gt;0.x: PCIe &lt;span class="caps"&gt;SMC&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Normal &lt;span class="caps"&gt;PCI&lt;/span&gt; Express is present. So let get rid of hardcoded values. Similar
steps and behaviour like&amp;nbsp;above.&lt;/p&gt;
&lt;h4&gt;0.y: go&amp;nbsp;PCIe!&lt;/h4&gt;
&lt;p&gt;At this step we have normal, working &lt;span class="caps"&gt;PCI&lt;/span&gt; Express structure. So let get rid of
some platform devices and replace them with expansion&amp;nbsp;cards:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class="caps"&gt;AHCI&lt;/span&gt; (sata&amp;nbsp;storage)&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;EHCI&lt;/span&gt; (usb&amp;nbsp;2.0)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We can use &amp;#8220;ich9-ahci&amp;#8221; card instead of former and &amp;#8220;qemu-xhci&amp;#8221; for latter&amp;nbsp;one.&lt;/p&gt;
&lt;p&gt;This step is &lt;span class="caps"&gt;EDK2&lt;/span&gt; only as we do not touch those parts in &lt;span class="caps"&gt;TF&lt;/span&gt;-A. No real code
yet as it needs adding some conditions to existing &lt;span class="caps"&gt;ASL&lt;/span&gt; code so operating
system will not get information in &lt;span class="caps"&gt;DSDT&lt;/span&gt;&amp;nbsp;table.&lt;/p&gt;
&lt;p&gt;Again: if booted on lower &lt;span class="caps"&gt;PV&lt;/span&gt; then hardcoded values are&amp;nbsp;used.&lt;/p&gt;
&lt;h3&gt;Other&amp;nbsp;changes&lt;/h3&gt;
&lt;p&gt;Recently some additional changes to &amp;#8220;sbsa-ref&amp;#8221; were&amp;nbsp;merged. &lt;/p&gt;
&lt;p&gt;We exchanged graphics card from basic &lt;span class="caps"&gt;VGA&lt;/span&gt; one on legacy &lt;span class="caps"&gt;PCI&lt;/span&gt; bus to Bochs one
(which uses &lt;span class="caps"&gt;PCI&lt;/span&gt; Express). From firmware or &lt;span class="caps"&gt;OS&lt;/span&gt; view not much changed as both
were supported&amp;nbsp;already.&lt;/p&gt;
&lt;p&gt;Other change was default processor. &lt;span class="caps"&gt;QEMU&lt;/span&gt; 8.0 brought emulation of Arm
Neoverse-N1 cpu. It is enabled in &lt;span class="caps"&gt;TF&lt;/span&gt;-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&amp;nbsp;functionalities.&lt;/p&gt;
&lt;h3&gt;Future&lt;/h3&gt;
&lt;p&gt;The above steps are cleanup preparing &amp;#8220;sbsa-ref&amp;#8221; for future work. We want to
be able to change hardware definition more. For example to select exact &lt;span class="caps"&gt;GIC&lt;/span&gt;
model (like &lt;a href="https://developer.arm.com/documentation/100336/latest/"&gt;&lt;span class="caps"&gt;GIC&lt;/span&gt;-600&lt;/a&gt;)
instead of generic &amp;#8220;arm-gic-v3&amp;#8221;&amp;nbsp;one.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;SBSA&lt;/span&gt; Reference Platform is system where most of expansion is expected to
happen by adding &lt;span class="caps"&gt;PCI&lt;/span&gt; Express&amp;nbsp;cards.&lt;/p&gt;</content><category term="misc"/><category term="linaro"/><category term="aarch64"/><category term="qemu"/><category term="virtualization"/></entry></feed>