Skip to content

virtio/mmio: move fw_cfg check into probe_mmio_slots()#948

Merged
stefano-garzarella merged 2 commits intococonut-svsm:mainfrom
stefano-garzarella:probe-check-fwcfg
Jan 27, 2026
Merged

virtio/mmio: move fw_cfg check into probe_mmio_slots()#948
stefano-garzarella merged 2 commits intococonut-svsm:mainfrom
stefano-garzarella:probe-check-fwcfg

Conversation

@stefano-garzarella
Copy link
Member

Move the fw_cfg availability check from svsm_init() into probe_mmio_slots(), which is the only place where fw_cfg is actually needed. Pass SvsmConfig as a parameter to probe_mmio_slots() to perform this check.

This prepares for future work where virtio MMIO addresses may be discovered via device tree instead of fw_cfg. By passing SvsmConfig, the probe function can internally decide how to discover devices without callers needing to know the details.

Also derive Default for MmioSlots to simplify returning empty slot collections.

Copy link
Collaborator

@luigix25 luigix25 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

When `virtio-drivers` feature is enabled, but `block` is not enabled
we have the current warnings:
  warning: unused variable: `slots`
     --> kernel/src/svsm.rs:166:13
      |
  166 |     let mut slots = probe_mmio_slots(config);
      |             ^^^^^ help: if this is intentional, prefix it with an underscore: `_slots`
      |
      = note: `#[warn(unused_variables)]` on by default

  warning: variable does not need to be mutable
     --> kernel/src/svsm.rs:166:9
      |
  166 |     let mut slots = probe_mmio_slots(config);
      |         ----^^^^^
      |         |
      |         help: remove this `mut`
      |
      = note: `#[warn(unused_mut)]` on by default

Move `probe_mmio_slots` under `block` feature for now.

Suggested-by: Jon Lange <jlange@microsoft.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Move the fw_cfg availability check from svsm_init() into
probe_mmio_slots(), which is the only place where fw_cfg is actually
needed. Pass `SvsmConfig` as a parameter to probe_mmio_slots() to
perform this check.

This prepares for future work where virtio MMIO addresses may be
discovered via device tree instead of fw_cfg. By passing `SvsmConfig`,
the probe function can internally decide how to discover devices
without callers needing to know the details.

Also derive Default for MmioSlots to simplify returning empty slot
collections.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
@stefano-garzarella
Copy link
Member Author

v2:

@stefano-garzarella stefano-garzarella merged commit 43e324d into coconut-svsm:main Jan 27, 2026
4 checks passed
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.

3 participants