[U-Boot] [PATCH 0/2] Enable booting from VirtIO PCI connected storage

Fedora/RISCV uses OpenSBI + U-Boot setup which loads extlinux configuration file from boot media and then continues booting Linux kernel.
pcie-root-port was finally enabled for RISC-V in QEMU 4.0.0. PCI is now default instead of MMIO starting libvirt v5.3.0 with QEMU 4.0.0 or newer. Simply put this means that devices are connected over VirtIO PCI (incl. storage, i.e. boot media).
Andrea Bolognani (Red Hat, Virtualization) noticed that Fedora/RISCV doesn't boot using libvirt. This is due to U-Boot not detecting boot media.
These two small patches address the issue (tested by me and Andrea).
Cc: Bin Meng bmeng.cn@gmail.com Cc: Andrea Bolognani abologna@redhat.com Cc: Richard W.M. Jones rjones@redhat.com Cc: Palmer Dabbelt palmer@sifive.com
David Abdurachmanov (2): qemu-riscv: enable VIRTIO_PCI distro_bootcmd: refactor virtio to support PCI block devices
board/emulation/qemu-riscv/Kconfig | 1 + include/config_distro_bootcmd.h | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-)

libvirt v.5.3.0 with QEMU 4.0.0 or above uses PCI automatically and thus devices (network, storage, etc) are connected via PCI.
Signed-off-by: David Abdurachmanov david.abdurachmanov@sifive.com --- board/emulation/qemu-riscv/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 7f9a74dd48..6cc7c31dc6 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -24,6 +24,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIRTIO_MMIO imply VIRTIO_NET imply VIRTIO_BLK + imply VIRTIO_PCI imply CMD_PING imply CMD_FS_GENERIC imply DOS_PARTITION

On Wed, Jul 3, 2019 at 8:51 PM David Abdurachmanov david.abdurachmanov@gmail.com wrote:
libvirt v.5.3.0 with QEMU 4.0.0 or above uses PCI automatically and
nits: v5.3.0 or just 5.3.0
thus devices (network, storage, etc) are connected via PCI.
Signed-off-by: David Abdurachmanov david.abdurachmanov@sifive.com
board/emulation/qemu-riscv/Kconfig | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Bin Meng bmeng.cn@gmail.com

On Wed, Jul 03, 2019 at 03:50:44PM +0300, David Abdurachmanov wrote:
libvirt v.5.3.0 with QEMU 4.0.0 or above uses PCI automatically and thus devices (network, storage, etc) are connected via PCI.
Signed-off-by: David Abdurachmanov david.abdurachmanov@sifive.com Reviewed-by: Bin Meng bmeng.cn@gmail.com
Applied to u-boot/master, thanks!

libvirt v5.3.0 with QEMU 4.0.0 use PCI automatically and thus storage is connected via PCI, which is not visible to U-Boot automatically. Refactor to do "pci enum" followed by "virtio scan" to see PCI connected storage.
Tested with Fedora/RISCV using the latest releases: libvirt 5.4.0, QEMU 4.0.0 and U-Boot 2019.07 RC4.
Signed-off-by: David Abdurachmanov david.abdurachmanov@sifive.com --- include/config_distro_bootcmd.h | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 26e61ef196..3570a32dff 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -254,11 +254,11 @@ #endif
#if defined(CONFIG_DM_PCI) -#define BOOTENV_RUN_NET_PCI_ENUM "run boot_net_pci_enum; " +#define BOOTENV_RUN_PCI_ENUM "run boot_pci_enum; " #define BOOTENV_SHARED_PCI \ - "boot_net_pci_enum=pci enum\0" + "boot_pci_enum=pci enum\0" #else -#define BOOTENV_RUN_NET_PCI_ENUM +#define BOOTENV_RUN_PCI_ENUM #define BOOTENV_SHARED_PCI #endif
@@ -281,10 +281,24 @@ #endif
#ifdef CONFIG_CMD_VIRTIO -#define BOOTENV_SHARED_VIRTIO BOOTENV_SHARED_BLKDEV(virtio) +#define BOOTENV_RUN_VIRTIO_INIT "run virtio_init; " +#define BOOTENV_SET_VIRTIO_NEED_INIT "virtio_need_init=; " +#define BOOTENV_SHARED_VIRTIO \ + "virtio_init=" \ + "if ${virtio_need_init}; then " \ + "virtio_need_init=false; " \ + "virtio scan; " \ + "fi\0" \ + \ + "virtio_boot=" \ + BOOTENV_RUN_PCI_ENUM \ + BOOTENV_RUN_VIRTIO_INIT \ + BOOTENV_SHARED_BLKDEV_BODY(virtio) #define BOOTENV_DEV_VIRTIO BOOTENV_DEV_BLKDEV #define BOOTENV_DEV_NAME_VIRTIO BOOTENV_DEV_NAME_BLKDEV #else +#define BOOTENV_RUN_VIRTIO_INIT +#define BOOTENV_SET_VIRTIO_NEED_INIT #define BOOTENV_SHARED_VIRTIO #define BOOTENV_DEV_VIRTIO \ BOOT_TARGET_DEVICES_references_VIRTIO_without_CONFIG_CMD_VIRTIO @@ -350,7 +364,7 @@ #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \ "bootcmd_dhcp=" \ BOOTENV_RUN_NET_USB_START \ - BOOTENV_RUN_NET_PCI_ENUM \ + BOOTENV_RUN_PCI_ENUM \ "if dhcp ${scriptaddr} ${boot_script_dhcp}; then " \ "source ${scriptaddr}; " \ "fi;" \ @@ -369,7 +383,7 @@ #define BOOTENV_DEV_PXE(devtypeu, devtypel, instance) \ "bootcmd_pxe=" \ BOOTENV_RUN_NET_USB_START \ - BOOTENV_RUN_NET_PCI_ENUM \ + BOOTENV_RUN_PCI_ENUM \ "dhcp; " \ "if pxe get; then " \ "pxe boot; " \ @@ -465,6 +479,7 @@ "distro_bootcmd=" BOOTENV_SET_SCSI_NEED_INIT \ BOOTENV_SET_NVME_NEED_INIT \ BOOTENV_SET_IDE_NEED_INIT \ + BOOTENV_SET_VIRTIO_NEED_INIT \ "for target in ${boot_targets}; do " \ "run bootcmd_${target}; " \ "done\0"

Hi David,
On Wed, Jul 3, 2019 at 8:52 PM David Abdurachmanov david.abdurachmanov@gmail.com wrote:
libvirt v5.3.0 with QEMU 4.0.0 use PCI automatically and thus storage
nits: 5.3.0 or 5.4.0?
is connected via PCI, which is not visible to U-Boot automatically. Refactor to do "pci enum" followed by "virtio scan" to see PCI connected storage.
Tested with Fedora/RISCV using the latest releases: libvirt 5.4.0,
Here mentions 5.4.0
QEMU 4.0.0 and U-Boot 2019.07 RC4.
Signed-off-by: David Abdurachmanov david.abdurachmanov@sifive.com
include/config_distro_bootcmd.h | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 26e61ef196..3570a32dff 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -254,11 +254,11 @@ #endif
#if defined(CONFIG_DM_PCI) -#define BOOTENV_RUN_NET_PCI_ENUM "run boot_net_pci_enum; " +#define BOOTENV_RUN_PCI_ENUM "run boot_pci_enum; " #define BOOTENV_SHARED_PCI \
"boot_net_pci_enum=pci enum\0"
"boot_pci_enum=pci enum\0"
#else -#define BOOTENV_RUN_NET_PCI_ENUM +#define BOOTENV_RUN_PCI_ENUM #define BOOTENV_SHARED_PCI #endif
@@ -281,10 +281,24 @@ #endif
#ifdef CONFIG_CMD_VIRTIO -#define BOOTENV_SHARED_VIRTIO BOOTENV_SHARED_BLKDEV(virtio) +#define BOOTENV_RUN_VIRTIO_INIT "run virtio_init; " +#define BOOTENV_SET_VIRTIO_NEED_INIT "virtio_need_init=; " +#define BOOTENV_SHARED_VIRTIO \
"virtio_init=" \
"if ${virtio_need_init}; then " \
"virtio_need_init=false; " \
"virtio scan; " \
"fi\0" \
\
"virtio_boot=" \
BOOTENV_RUN_PCI_ENUM \
BOOTENV_RUN_VIRTIO_INIT \
BOOTENV_SHARED_BLKDEV_BODY(virtio)
The changes should be surrounded by "#if defined(CONFIG_DM_PCI)".
#define BOOTENV_DEV_VIRTIO BOOTENV_DEV_BLKDEV #define BOOTENV_DEV_NAME_VIRTIO BOOTENV_DEV_NAME_BLKDEV #else +#define BOOTENV_RUN_VIRTIO_INIT +#define BOOTENV_SET_VIRTIO_NEED_INIT #define BOOTENV_SHARED_VIRTIO #define BOOTENV_DEV_VIRTIO \ BOOT_TARGET_DEVICES_references_VIRTIO_without_CONFIG_CMD_VIRTIO @@ -350,7 +364,7 @@ #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \ "bootcmd_dhcp=" \ BOOTENV_RUN_NET_USB_START \
BOOTENV_RUN_NET_PCI_ENUM \
BOOTENV_RUN_PCI_ENUM \ "if dhcp ${scriptaddr} ${boot_script_dhcp}; then " \ "source ${scriptaddr}; " \ "fi;" \
@@ -369,7 +383,7 @@ #define BOOTENV_DEV_PXE(devtypeu, devtypel, instance) \ "bootcmd_pxe=" \ BOOTENV_RUN_NET_USB_START \
BOOTENV_RUN_NET_PCI_ENUM \
BOOTENV_RUN_PCI_ENUM \ "dhcp; " \ "if pxe get; then " \ "pxe boot; " \
@@ -465,6 +479,7 @@ "distro_bootcmd=" BOOTENV_SET_SCSI_NEED_INIT \ BOOTENV_SET_NVME_NEED_INIT \ BOOTENV_SET_IDE_NEED_INIT \
BOOTENV_SET_VIRTIO_NEED_INIT \ "for target in ${boot_targets}; do " \ "run bootcmd_${target}; " \ "done\0"
--
Regards, Bin
participants (3)
-
Bin Meng
-
David Abdurachmanov
-
Tom Rini