Skip to content

Device Tree Support#31

Merged
stefano-garzarella merged 8 commits into
coconut-svsm:svsm-igvmfrom
luigix25:dtc_rebase
Jun 15, 2026
Merged

Device Tree Support#31
stefano-garzarella merged 8 commits into
coconut-svsm:svsm-igvmfrom
luigix25:dtc_rebase

Conversation

@luigix25

@luigix25 luigix25 commented Mar 18, 2026

Copy link
Copy Markdown
Collaborator

Introduce device tree support.

This series is based on #32 that rebased our fork to latest master.

"qdev: Add plane property" and "hw/core/machine: Add device-plane property" are cherry-picked from the planes branch.

This series adds two new parameters:

  • "-device-plane" to the machine type that specifies the default plane where all the devices are attached to
  • "plane" property of each device, that overrides default value for each device.

The generated device tree for the PC machine is not complete: it exposes:

  • virtio-mmio
  • isa-serial
  • fw-cfg
  • isa-debug exit

SVSM PR: coconut-svsm/svsm#1006

@luigix25

Copy link
Copy Markdown
Collaborator Author

@kraxel

kraxel commented Mar 26, 2026

Copy link
Copy Markdown

I think the design here should roughly follow the principles we use in other places, specifically the memory map today (and possibly MADT in the future): The SVSM gets /all/ information (i.e. the complete device tree), removes the resources it uses itself (i.e. a chunk of memory in case of the memory map, or specific devices in case of the device tree), and passes on that updated information to edk2 firmware.

For the pc/q35 machine types this does not matter much because there is no device tree used for hardware detection today. On aarch64 device trees are rather essential though, and CCA is coming. The x86 microvm machine type also uses device trees to pass hardware information from qemu to firmware. So IMHO the design should consider the case that edk2 needs a device tree too.

We'll need some kind of hint in the device tree for the svsm which devices are meant for the svsm to use. Adding some qdev device property for that certainly makes sense. That hint needs to be added to the device three though, so svsm can do the filtering itself (as described above) instead of depending on getting a filtered device tree from qemu.

[note: discusses this with luigi already in private, adding here for reference]

@luigix25 luigix25 changed the base branch from master to qemu_11 May 12, 2026 21:07
@luigix25 luigix25 changed the base branch from qemu_11 to master May 12, 2026 21:07
@luigix25 luigix25 changed the base branch from master to svsm-igvm May 14, 2026 08:58
@luigix25 luigix25 marked this pull request as ready for review May 14, 2026 08:59
@luigix25

luigix25 commented May 14, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed @kraxel comments:

  • Now the DT exposes all the devices, regardless of their device plane. For the PC machine it will just expose virtio-mmio and serial ports.
  • Added plane property to microvm DT
  • Rebased to QEMU 11.0

@kraxel @stefano-garzarella @joergroedel @osteffenrh PTAL!

@stefano-garzarella

Copy link
Copy Markdown
Member

@luigix25 about commit cc43764 and 3799726 from @joergroedel are those the same included in the latest RFC sent upstream?

@stefano-garzarella stefano-garzarella left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments that can be fixed later upstream.

Comment thread hw/i386/x86_dt_common.c
Comment thread hw/i386/x86_dt_common.c Outdated
Comment thread hw/i386/x86_dt_common.c
Comment thread hw/i386/Kconfig
@luigix25

Copy link
Copy Markdown
Collaborator Author

@luigix25 about commit cc43764 and 3799726 from @joergroedel are those the same included in the latest RFC sent upstream?

@stefano-garzarella:

they are basically the same, @joergroedel squashed "qdev: Set default plane property" into "qdev: Add plane property"

My idea is to cherry-pick the new version so we have less changes from the upstream.
Also, I'm upstreaming DT support (just for microvm), and the patch is a little bit different from the one we have here.
So I'll cherry-pick that as well.

I also need to swap two commits for bisectability.

I hope I can do it by the end of the week.

Thanks for the review!

joergroedel and others added 7 commits June 11, 2026 14:32
Add a property to the QEMU MachineState to specify the default plane
to send device interrupts to.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Add a property to track the plane into which the qdev needs to inject
IRQs.

Co-developed-by: Luigi Leonardi <leonardi@redhat.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
The device-plane check depends on accel_nr_planes(), which requires
the full planes API that is not yet available. This causes a build
failure.

Remove the check until the accelerator planes API is implemented.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Generate a flattened device tree describing virtio-mmio devices on
the PC machine. This FDT is consumed by Coconut SVSM firmware,
which uses it to discover devices assigned to the firmware plane
via IGVM parameters instead of relying on fw_cfg.

The device tree is intentionally incomplete: CPUs and memory are
not included as firmware obtains that information through other
channels.

Add FDT/DEVICE_TREE dependency to the PC Kconfig.
The implementation is based on hw/i386/microvm-dt.c.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Extend the x86 device tree to include ISA serial devices found on
the ISA bus, so the firmware can discover serial ports assigned to
its plane.

Note that ISA serial addresses are well-known and cannot be hidden
from the guest OS.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
These devices use well-known I/O port addresses but there is no easy
way for firmware to detect their presence at runtime.

Expose them through the device tree so that consumers, like SVSM, can
discover and use them without hardcoding assumptions about the
platform configuration.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Add the plane property to all microvm device tree nodes so firmware
can identify which plane each device is assigned to.

This is needed by Coconut SVSM to filter devices by plane assignment
and discover which devices belong to the firmware plane.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
@luigix25

Copy link
Copy Markdown
Collaborator Author
  • Cherry picked "qdev: Add plane property" from latest RFC sent.
  • Swapped Add plane property and Add device-plane property to keep bisectability
  • Added fw-cfg and isa-debug-exit to device tree
  • Cherry-picked DT support in igvm from the latest version sent upstream (not merged)

Comment thread backends/igvm.c
Coconut SVSM, with the upcoming device tree support [1], will use
the IGVM device tree parameter to discover virtio-mmio and ISA serial
devices instead of relying on the fw_cfg interface, which is
QEMU-specific.

The device tree is packed before copying into the IGVM parameter area
to reduce its size, since IGVM files can define tighter memory
constraints for parameter areas. Packing is done in the generic IGVM
backend rather than in per-architecture device tree setup code, so
that each architecture does not need to handle it individually.

[1] coconut-svsm/svsm#1006

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
@stefano-garzarella stefano-garzarella merged commit 0055104 into coconut-svsm:svsm-igvm Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants