* [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches
@ 2021-12-13 8:16 Gerd Hoffmann
2021-12-13 8:16 ` [PATCH v3 1/5] OvmfPkg/Microvm/fdt: add device tree support Gerd Hoffmann
` (5 more replies)
0 siblings, 6 replies; 16+ messages in thread
From: Gerd Hoffmann @ 2021-12-13 8:16 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski,
Philippe Mathieu-Daudé, Gerd Hoffmann, Ard Biesheuvel
Adds support for virtio-mmio devices to microvm.
While being at it also add the README, the
patch somehow disappeared from the first batch.
v3:
- uncrustify & rebase to latest master
- pick up some review tags
- minor README updates.
v2:
- qemu changes needed for this are merged and will be
in the 6.2 release (dec 2021).
- more verbose commit messages.
Gerd Hoffmann (5):
OvmfPkg/Microvm/fdt: add device tree support
OvmfPkg/Microvm/fdt: load fdt from fw_cfg
OvmfPkg/Microvm/fdt: add empty fdt
OvmfPkg/Microvm/virtio: add virtio-mmio support
OvmfPkg/Microvm: add README
OvmfPkg/Microvm/MicrovmX64.dsc | 8 ++++
OvmfPkg/Microvm/MicrovmX64.fdf | 3 ++
OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
OvmfPkg/PlatformPei/Platform.c | 63 +++++++++++++++++++++++++++++
OvmfPkg/Microvm/README | 50 +++++++++++++++++++++++
5 files changed, 125 insertions(+)
create mode 100644 OvmfPkg/Microvm/README
--
2.33.1
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3 1/5] OvmfPkg/Microvm/fdt: add device tree support
2021-12-13 8:16 [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches Gerd Hoffmann
@ 2021-12-13 8:16 ` Gerd Hoffmann
2021-12-13 9:38 ` Philippe Mathieu-Daudé
2021-12-13 8:16 ` [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg Gerd Hoffmann
` (4 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Gerd Hoffmann @ 2021-12-13 8:16 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski,
Philippe Mathieu-Daudé, Gerd Hoffmann, Ard Biesheuvel
Add fdt parser from EmbeddedPkg (FdtLib and FdtClientDxe) to MicrovmX64.
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3689
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
OvmfPkg/Microvm/MicrovmX64.dsc | 6 ++++++
OvmfPkg/Microvm/MicrovmX64.fdf | 2 ++
2 files changed, 8 insertions(+)
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 5f4d9226791b..edddf6c29b32 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -232,6 +232,7 @@ [LibraryClasses.common]
VmgExitLib|OvmfPkg/Library/VmgExitLib/VmgExitLib.inf
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
+ FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
[LibraryClasses.common.SEC]
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf
@@ -739,6 +740,11 @@ [Components]
#
MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
+ #
+ # device tree
+ #
+ EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf
+
#
# SMBIOS Support
#
diff --git a/OvmfPkg/Microvm/MicrovmX64.fdf b/OvmfPkg/Microvm/MicrovmX64.fdf
index 4570bc866c9b..905d23b843d3 100644
--- a/OvmfPkg/Microvm/MicrovmX64.fdf
+++ b/OvmfPkg/Microvm/MicrovmX64.fdf
@@ -276,6 +276,8 @@ [FV.DXEFV]
INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf
+INF EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf
+
!if $(TOOL_CHAIN_TAG) != "XCODE5"
INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf
--
2.33.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg
2021-12-13 8:16 [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches Gerd Hoffmann
2021-12-13 8:16 ` [PATCH v3 1/5] OvmfPkg/Microvm/fdt: add device tree support Gerd Hoffmann
@ 2021-12-13 8:16 ` Gerd Hoffmann
2021-12-13 9:33 ` Philippe Mathieu-Daudé
2021-12-13 9:43 ` [edk2-devel] " Ard Biesheuvel
2021-12-13 8:16 ` [PATCH v3 3/5] OvmfPkg/Microvm/fdt: add empty fdt Gerd Hoffmann
` (3 subsequent siblings)
5 siblings, 2 replies; 16+ messages in thread
From: Gerd Hoffmann @ 2021-12-13 8:16 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski,
Philippe Mathieu-Daudé, Gerd Hoffmann, Ard Biesheuvel
Needed for hardware detection: virtio-mmio devices for now,
later also pcie root bridge.
Depends on patched qemu which actually provides an fdt:
https://gitlab.com/kraxel/qemu/-/commits/sirius/microvm-device-tree
https://bugzilla.tianocore.org/show_bug.cgi?id=3689
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
OvmfPkg/PlatformPei/Platform.c | 45 +++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
index 1c56ba275835..8ef404168c45 100644
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/PlatformPei/PlatformPei.inf
@@ -44,6 +44,7 @@ [Packages]
[Guids]
gEfiMemoryTypeInformationGuid
+ gFdtHobGuid
[LibraryClasses]
BaseLib
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 906f64615de7..c9ec1d7e99fb 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -321,6 +321,50 @@ PciExBarInitialization (
);
}
+VOID
+MicrovmInitialization (
+ VOID
+ )
+{
+ FIRMWARE_CONFIG_ITEM FdtItem;
+ UINTN FdtSize;
+ UINTN FdtPages;
+ EFI_STATUS Status;
+ UINT64 *FdtHobData;
+ VOID *NewBase;
+
+ Status = QemuFwCfgFindFile ("etc/fdt", &FdtItem, &FdtSize);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "%a: no etc/fdt found in fw_cfg\n", __FUNCTION__));
+ return;
+ }
+
+ FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
+ NewBase = AllocatePages (FdtPages);
+ if (NewBase == NULL) {
+ DEBUG ((DEBUG_INFO, "%a: AllocatePages failed\n", __FUNCTION__));
+ return;
+ }
+
+ QemuFwCfgSelectItem (FdtItem);
+ QemuFwCfgReadBytes (FdtSize, NewBase);
+
+ FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData));
+ if (FdtHobData == NULL) {
+ DEBUG ((DEBUG_INFO, "%a: BuildGuidHob failed\n", __FUNCTION__));
+ return;
+ }
+
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: fdt at 0x%x (size %d)\n",
+ __FUNCTION__,
+ NewBase,
+ FdtSize
+ ));
+ *FdtHobData = (UINTN)NewBase;
+}
+
VOID
MiscInitialization (
VOID
@@ -368,6 +412,7 @@ MiscInitialization (
break;
case 0xffff: /* microvm */
DEBUG ((DEBUG_INFO, "%a: microvm\n", __FUNCTION__));
+ MicrovmInitialization ();
PcdStatus = PcdSet16S (
PcdOvmfHostBridgePciDevId,
MICROVM_PSEUDO_DEVICE_ID
--
2.33.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 3/5] OvmfPkg/Microvm/fdt: add empty fdt
2021-12-13 8:16 [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches Gerd Hoffmann
2021-12-13 8:16 ` [PATCH v3 1/5] OvmfPkg/Microvm/fdt: add device tree support Gerd Hoffmann
2021-12-13 8:16 ` [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg Gerd Hoffmann
@ 2021-12-13 8:16 ` Gerd Hoffmann
2021-12-13 9:35 ` Philippe Mathieu-Daudé
2021-12-13 8:16 ` [PATCH v3 4/5] OvmfPkg/Microvm/virtio: add virtio-mmio support Gerd Hoffmann
` (2 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Gerd Hoffmann @ 2021-12-13 8:16 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski,
Philippe Mathieu-Daudé, Gerd Hoffmann, Ard Biesheuvel
FdtClient is unhappy without a device tree, so add an empty fdt
which we can use in case etc/fdt is not present in fw_cfg.
On ARM machines a device tree is mandatory for hardware detection,
thats why FdtClient fails hard.
On microvm the device tree is only used to detect virtio-mmio devices
(this patch series) and the pcie host (future series). So edk2 can
continue with limited functionality in case no device tree is present:
no storage, no network, but serial console and direct kernel boot
works.
qemu release 6.2 & newer will provide a device tree for microvm.
https://bugzilla.tianocore.org/show_bug.cgi?id=3689
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
---
OvmfPkg/PlatformPei/Platform.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index c9ec1d7e99fb..d0323c645162 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -16,6 +16,7 @@
//
// The Library classes this module consumes
//
+#include <Library/BaseMemoryLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
@@ -321,6 +322,18 @@ PciExBarInitialization (
);
}
+static const UINT8 EmptyFdt[] = {
+ 0xd0, 0x0d, 0xfe, 0xed, 0x00, 0x00, 0x00, 0x48,
+ 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x48,
+ 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09,
+};
+
VOID
MicrovmInitialization (
VOID
@@ -335,8 +348,9 @@ MicrovmInitialization (
Status = QemuFwCfgFindFile ("etc/fdt", &FdtItem, &FdtSize);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_INFO, "%a: no etc/fdt found in fw_cfg\n", __FUNCTION__));
- return;
+ DEBUG ((DEBUG_INFO, "%a: no etc/fdt found in fw_cfg, using dummy\n", __FUNCTION__));
+ FdtItem = 0;
+ FdtSize = sizeof (EmptyFdt);
}
FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
@@ -346,8 +360,12 @@ MicrovmInitialization (
return;
}
- QemuFwCfgSelectItem (FdtItem);
- QemuFwCfgReadBytes (FdtSize, NewBase);
+ if (FdtItem) {
+ QemuFwCfgSelectItem (FdtItem);
+ QemuFwCfgReadBytes (FdtSize, NewBase);
+ } else {
+ CopyMem (NewBase, EmptyFdt, FdtSize);
+ }
FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData));
if (FdtHobData == NULL) {
--
2.33.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 4/5] OvmfPkg/Microvm/virtio: add virtio-mmio support
2021-12-13 8:16 [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches Gerd Hoffmann
` (2 preceding siblings ...)
2021-12-13 8:16 ` [PATCH v3 3/5] OvmfPkg/Microvm/fdt: add empty fdt Gerd Hoffmann
@ 2021-12-13 8:16 ` Gerd Hoffmann
2021-12-13 9:38 ` Philippe Mathieu-Daudé
2021-12-13 8:16 ` [PATCH v3 5/5] OvmfPkg/Microvm: add README Gerd Hoffmann
2021-12-13 12:18 ` [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches Ard Biesheuvel
5 siblings, 1 reply; 16+ messages in thread
From: Gerd Hoffmann @ 2021-12-13 8:16 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski,
Philippe Mathieu-Daudé, Gerd Hoffmann, Ard Biesheuvel
Add virtio-mmio support (VirtioMmioDeviceLib and VirtioFdtDxe).
With this patch added and a new enough qemu version (6.2+) edk2
will detect virtio-mmio devices, so it is possible to boot from
storage (virtio-blk, virtio-scsi) or network (virtio-net).
https://bugzilla.tianocore.org/show_bug.cgi?id=3689
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
OvmfPkg/Microvm/MicrovmX64.dsc | 2 ++
OvmfPkg/Microvm/MicrovmX64.fdf | 1 +
2 files changed, 3 insertions(+)
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index edddf6c29b32..a78c8f3dd89f 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -233,6 +233,7 @@ [LibraryClasses.common]
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
+ VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
[LibraryClasses.common.SEC]
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf
@@ -744,6 +745,7 @@ [Components]
# device tree
#
EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf
+ OvmfPkg/Fdt/VirtioFdtDxe/VirtioFdtDxe.inf
#
# SMBIOS Support
diff --git a/OvmfPkg/Microvm/MicrovmX64.fdf b/OvmfPkg/Microvm/MicrovmX64.fdf
index 905d23b843d3..6999ac1a87b9 100644
--- a/OvmfPkg/Microvm/MicrovmX64.fdf
+++ b/OvmfPkg/Microvm/MicrovmX64.fdf
@@ -277,6 +277,7 @@ [FV.DXEFV]
INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf
INF EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf
+INF OvmfPkg/Fdt/VirtioFdtDxe/VirtioFdtDxe.inf
!if $(TOOL_CHAIN_TAG) != "XCODE5"
INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
--
2.33.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 5/5] OvmfPkg/Microvm: add README
2021-12-13 8:16 [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches Gerd Hoffmann
` (3 preceding siblings ...)
2021-12-13 8:16 ` [PATCH v3 4/5] OvmfPkg/Microvm/virtio: add virtio-mmio support Gerd Hoffmann
@ 2021-12-13 8:16 ` Gerd Hoffmann
2021-12-13 9:37 ` Philippe Mathieu-Daudé
2021-12-13 12:18 ` [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches Ard Biesheuvel
5 siblings, 1 reply; 16+ messages in thread
From: Gerd Hoffmann @ 2021-12-13 8:16 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski,
Philippe Mathieu-Daudé, Gerd Hoffmann, Ard Biesheuvel,
Jiewen Yao
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3599
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
---
OvmfPkg/Microvm/README | 50 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 OvmfPkg/Microvm/README
diff --git a/OvmfPkg/Microvm/README b/OvmfPkg/Microvm/README
new file mode 100644
index 000000000000..540d39f2ec21
--- /dev/null
+++ b/OvmfPkg/Microvm/README
@@ -0,0 +1,50 @@
+
+This is an *experimental* port of OVMF for the QEMU microvm
+machine type.
+
+microvm background info
+-----------------------
+
+microvm is designed for modern, virtio-based workloads. Most legacy
+lpc/isa devices like pit and pic can be turned off. virtio-mmio
+(i.e. '-device virtio-{blk,net,scsi,...}-device') is used for
+storage/network/etc.
+
+Optional pcie support is available and any pcie device supported by
+QEMU can be plugged in (including virtio-pci if you prefer that over
+virtio-mmio).
+
+https://qemu.readthedocs.io/en/latest/system/i386/microvm.html
+https://www.kraxel.org/blog/2020/10/qemu-microvm-acpi/
+
+design issues
+-------------
+
+Not fully clear yet how to do hardware detection best. Right now
+using device tree to find virtio-mmio devices and pcie host bridge,
+can reuse existing ArmVirtPkg code that way. Needs patched QEMU.
+
+features
+--------
+ [working] serial console
+ [working] direct kernel boot
+ [working] virtio-mmio support
+ [in progress] pcie support
+
+known limitations
+-----------------
+ * rtc=on is required for now.
+ * can't use separate code/vars (actually an microvm limitation,
+ there is no pflash support).
+ * transitional virtio-pci devices do not work. microvm doesn't
+ support ioports on pcie, and ovmf doesn't initialize pcie devices
+ with ioports if there is no address space for them (even though
+ pcie devices are required to be functional without ioports).
+
+usage
+-----
+qemu-system-x86_64 \
+ -nographic \
+ -machine microvm,acpi=on,pit=off,pic=off,rtc=on \
+ -bios /path/to/MICROVM.fd \
+ [ ... more args here ... ]
--
2.33.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg
2021-12-13 8:16 ` [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg Gerd Hoffmann
@ 2021-12-13 9:33 ` Philippe Mathieu-Daudé
2021-12-13 11:21 ` Gerd Hoffmann
2021-12-13 9:43 ` [edk2-devel] " Ard Biesheuvel
1 sibling, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-12-13 9:33 UTC (permalink / raw)
To: Gerd Hoffmann, devel
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski, Ard Biesheuvel
On 12/13/21 09:16, Gerd Hoffmann wrote:
> Needed for hardware detection: virtio-mmio devices for now,
> later also pcie root bridge.
>
> Depends on patched qemu which actually provides an fdt:
> https://gitlab.com/kraxel/qemu/-/commits/sirius/microvm-device-tree
Link returns 404.
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=3689
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
> OvmfPkg/PlatformPei/Platform.c | 45 +++++++++++++++++++++++++++++
> 2 files changed, 46 insertions(+)
>
> diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
> index 1c56ba275835..8ef404168c45 100644
> --- a/OvmfPkg/PlatformPei/PlatformPei.inf
> +++ b/OvmfPkg/PlatformPei/PlatformPei.inf
> @@ -44,6 +44,7 @@ [Packages]
>
> [Guids]
> gEfiMemoryTypeInformationGuid
> + gFdtHobGuid
>
> [LibraryClasses]
> BaseLib
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index 906f64615de7..c9ec1d7e99fb 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -321,6 +321,50 @@ PciExBarInitialization (
> );
> }
>
> +VOID
> +MicrovmInitialization (
> + VOID
> + )
> +{
> + FIRMWARE_CONFIG_ITEM FdtItem;
> + UINTN FdtSize;
> + UINTN FdtPages;
> + EFI_STATUS Status;
> + UINT64 *FdtHobData;
> + VOID *NewBase;
> +
> + Status = QemuFwCfgFindFile ("etc/fdt", &FdtItem, &FdtSize);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_INFO, "%a: no etc/fdt found in fw_cfg\n", __FUNCTION__));
> + return;
> + }
> +
> + FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
> + NewBase = AllocatePages (FdtPages);
> + if (NewBase == NULL) {
> + DEBUG ((DEBUG_INFO, "%a: AllocatePages failed\n", __FUNCTION__));
> + return;
> + }
> +
> + QemuFwCfgSelectItem (FdtItem);
> + QemuFwCfgReadBytes (FdtSize, NewBase);
> +
> + FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData));
> + if (FdtHobData == NULL) {
> + DEBUG ((DEBUG_INFO, "%a: BuildGuidHob failed\n", __FUNCTION__));
FreePages (NewBase)?
Otherwise:
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
> + return;
> + }
> +
> + DEBUG ((
> + DEBUG_INFO,
> + "%a: fdt at 0x%x (size %d)\n",
> + __FUNCTION__,
> + NewBase,
> + FdtSize
> + ));
> + *FdtHobData = (UINTN)NewBase;
> +}
> +
> VOID
> MiscInitialization (
> VOID
> @@ -368,6 +412,7 @@ MiscInitialization (
> break;
> case 0xffff: /* microvm */
> DEBUG ((DEBUG_INFO, "%a: microvm\n", __FUNCTION__));
> + MicrovmInitialization ();
> PcdStatus = PcdSet16S (
> PcdOvmfHostBridgePciDevId,
> MICROVM_PSEUDO_DEVICE_ID
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 3/5] OvmfPkg/Microvm/fdt: add empty fdt
2021-12-13 8:16 ` [PATCH v3 3/5] OvmfPkg/Microvm/fdt: add empty fdt Gerd Hoffmann
@ 2021-12-13 9:35 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-12-13 9:35 UTC (permalink / raw)
To: Gerd Hoffmann, devel
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski, Ard Biesheuvel
On 12/13/21 09:16, Gerd Hoffmann wrote:
> FdtClient is unhappy without a device tree, so add an empty fdt
> which we can use in case etc/fdt is not present in fw_cfg.
>
> On ARM machines a device tree is mandatory for hardware detection,
> thats why FdtClient fails hard.
"that's"
>
> On microvm the device tree is only used to detect virtio-mmio devices
> (this patch series) and the pcie host (future series). So edk2 can
> continue with limited functionality in case no device tree is present:
> no storage, no network, but serial console and direct kernel boot
> works.
>
> qemu release 6.2 & newer will provide a device tree for microvm.
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=3689
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
> ---
> OvmfPkg/PlatformPei/Platform.c | 26 ++++++++++++++++++++++----
> 1 file changed, 22 insertions(+), 4 deletions(-)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 5/5] OvmfPkg/Microvm: add README
2021-12-13 8:16 ` [PATCH v3 5/5] OvmfPkg/Microvm: add README Gerd Hoffmann
@ 2021-12-13 9:37 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-12-13 9:37 UTC (permalink / raw)
To: Gerd Hoffmann, devel
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski, Ard Biesheuvel
On 12/13/21 09:16, Gerd Hoffmann wrote:
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3599
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
> ---
> OvmfPkg/Microvm/README | 50 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
> create mode 100644 OvmfPkg/Microvm/README
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 4/5] OvmfPkg/Microvm/virtio: add virtio-mmio support
2021-12-13 8:16 ` [PATCH v3 4/5] OvmfPkg/Microvm/virtio: add virtio-mmio support Gerd Hoffmann
@ 2021-12-13 9:38 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-12-13 9:38 UTC (permalink / raw)
To: Gerd Hoffmann, devel
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski, Ard Biesheuvel
On 12/13/21 09:16, Gerd Hoffmann wrote:
> Add virtio-mmio support (VirtioMmioDeviceLib and VirtioFdtDxe).
>
> With this patch added and a new enough qemu version (6.2+) edk2
> will detect virtio-mmio devices, so it is possible to boot from
> storage (virtio-blk, virtio-scsi) or network (virtio-net).
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=3689
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> OvmfPkg/Microvm/MicrovmX64.dsc | 2 ++
> OvmfPkg/Microvm/MicrovmX64.fdf | 1 +
> 2 files changed, 3 insertions(+)
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 1/5] OvmfPkg/Microvm/fdt: add device tree support
2021-12-13 8:16 ` [PATCH v3 1/5] OvmfPkg/Microvm/fdt: add device tree support Gerd Hoffmann
@ 2021-12-13 9:38 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-12-13 9:38 UTC (permalink / raw)
To: Gerd Hoffmann, devel
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski, Ard Biesheuvel
On 12/13/21 09:16, Gerd Hoffmann wrote:
> Add fdt parser from EmbeddedPkg (FdtLib and FdtClientDxe) to MicrovmX64.
>
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3689
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> OvmfPkg/Microvm/MicrovmX64.dsc | 6 ++++++
> OvmfPkg/Microvm/MicrovmX64.fdf | 2 ++
> 2 files changed, 8 insertions(+)
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg
2021-12-13 8:16 ` [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg Gerd Hoffmann
2021-12-13 9:33 ` Philippe Mathieu-Daudé
@ 2021-12-13 9:43 ` Ard Biesheuvel
2021-12-13 11:26 ` Gerd Hoffmann
1 sibling, 1 reply; 16+ messages in thread
From: Ard Biesheuvel @ 2021-12-13 9:43 UTC (permalink / raw)
To: edk2-devel-groups-io, Gerd Hoffmann
Cc: Jordan Justen, Jiewen Yao, Pawel Polawski,
Philippe Mathieu-Daudé, Ard Biesheuvel
On Mon, 13 Dec 2021 at 09:17, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Needed for hardware detection: virtio-mmio devices for now,
> later also pcie root bridge.
>
> Depends on patched qemu which actually provides an fdt:
> https://gitlab.com/kraxel/qemu/-/commits/sirius/microvm-device-tree
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=3689
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
> OvmfPkg/PlatformPei/Platform.c | 45 +++++++++++++++++++++++++++++
> 2 files changed, 46 insertions(+)
>
> diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
> index 1c56ba275835..8ef404168c45 100644
> --- a/OvmfPkg/PlatformPei/PlatformPei.inf
> +++ b/OvmfPkg/PlatformPei/PlatformPei.inf
> @@ -44,6 +44,7 @@ [Packages]
>
> [Guids]
> gEfiMemoryTypeInformationGuid
> + gFdtHobGuid
>
> [LibraryClasses]
> BaseLib
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index 906f64615de7..c9ec1d7e99fb 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -321,6 +321,50 @@ PciExBarInitialization (
> );
> }
>
> +VOID
> +MicrovmInitialization (
> + VOID
> + )
> +{
> + FIRMWARE_CONFIG_ITEM FdtItem;
> + UINTN FdtSize;
> + UINTN FdtPages;
> + EFI_STATUS Status;
> + UINT64 *FdtHobData;
> + VOID *NewBase;
> +
> + Status = QemuFwCfgFindFile ("etc/fdt", &FdtItem, &FdtSize);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_INFO, "%a: no etc/fdt found in fw_cfg\n", __FUNCTION__));
> + return;
> + }
> +
> + FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
> + NewBase = AllocatePages (FdtPages);
> + if (NewBase == NULL) {
> + DEBUG ((DEBUG_INFO, "%a: AllocatePages failed\n", __FUNCTION__));
> + return;
> + }
> +
> + QemuFwCfgSelectItem (FdtItem);
> + QemuFwCfgReadBytes (FdtSize, NewBase);
> +
> + FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData));
> + if (FdtHobData == NULL) {
> + DEBUG ((DEBUG_INFO, "%a: BuildGuidHob failed\n", __FUNCTION__));
> + return;
> + }
> +
> + DEBUG ((
> + DEBUG_INFO,
> + "%a: fdt at 0x%x (size %d)\n",
> + __FUNCTION__,
> + NewBase,
> + FdtSize
> + ));
> + *FdtHobData = (UINTN)NewBase;
> +}
> +
> VOID
> MiscInitialization (
> VOID
> @@ -368,6 +412,7 @@ MiscInitialization (
> break;
> case 0xffff: /* microvm */
> DEBUG ((DEBUG_INFO, "%a: microvm\n", __FUNCTION__));
> + MicrovmInitialization ();
Is this the best spot for calling Microvm related init code that is
entirely unrelated to PCIe?
> PcdStatus = PcdSet16S (
> PcdOvmfHostBridgePciDevId,
> MICROVM_PSEUDO_DEVICE_ID
> --
> 2.33.1
>
>
>
>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg
2021-12-13 9:33 ` Philippe Mathieu-Daudé
@ 2021-12-13 11:21 ` Gerd Hoffmann
0 siblings, 0 replies; 16+ messages in thread
From: Gerd Hoffmann @ 2021-12-13 11:21 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: devel, Jordan Justen, Jiewen Yao, Pawel Polawski, Ard Biesheuvel
On Mon, Dec 13, 2021 at 10:33:55AM +0100, Philippe Mathieu-Daudé wrote:
> On 12/13/21 09:16, Gerd Hoffmann wrote:
> > Needed for hardware detection: virtio-mmio devices for now,
> > later also pcie root bridge.
> >
> > Depends on patched qemu which actually provides an fdt:
> > https://gitlab.com/kraxel/qemu/-/commits/sirius/microvm-device-tree
>
> Link returns 404.
Oh, need to fix the commit message. It's upstream in qemu 6.2+
meanwhile.
take care,
Gerd
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg
2021-12-13 9:43 ` [edk2-devel] " Ard Biesheuvel
@ 2021-12-13 11:26 ` Gerd Hoffmann
2021-12-13 11:30 ` Ard Biesheuvel
0 siblings, 1 reply; 16+ messages in thread
From: Gerd Hoffmann @ 2021-12-13 11:26 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: edk2-devel-groups-io, Jordan Justen, Jiewen Yao, Pawel Polawski,
Philippe Mathieu-Daudé, Ard Biesheuvel
Hi,
> > @@ -368,6 +412,7 @@ MiscInitialization (
> > break;
> > case 0xffff: /* microvm */
> > DEBUG ((DEBUG_INFO, "%a: microvm\n", __FUNCTION__));
> > + MicrovmInitialization ();
>
> Is this the best spot for calling Microvm related init code that is
> entirely unrelated to PCIe?
Looked like the best place to me. Various platform-specific
initialization happens there. And, yes, for 'pc' and 'q35'
qemu machines this includes pci host bridge setup.
Do you have a better suggestion?
take care,
Gerd
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg
2021-12-13 11:26 ` Gerd Hoffmann
@ 2021-12-13 11:30 ` Ard Biesheuvel
0 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2021-12-13 11:30 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: edk2-devel-groups-io, Jordan Justen, Jiewen Yao, Pawel Polawski,
Philippe Mathieu-Daudé, Ard Biesheuvel
On Mon, 13 Dec 2021 at 12:26, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Hi,
>
> > > @@ -368,6 +412,7 @@ MiscInitialization (
> > > break;
> > > case 0xffff: /* microvm */
> > > DEBUG ((DEBUG_INFO, "%a: microvm\n", __FUNCTION__));
> > > + MicrovmInitialization ();
> >
> > Is this the best spot for calling Microvm related init code that is
> > entirely unrelated to PCIe?
>
> Looked like the best place to me. Various platform-specific
> initialization happens there. And, yes, for 'pc' and 'q35'
> qemu machines this includes pci host bridge setup.
>
Fair enough. Given the comment that future changes will include DT
based PCIe host bridge probing, I think this is fine.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches
2021-12-13 8:16 [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches Gerd Hoffmann
` (4 preceding siblings ...)
2021-12-13 8:16 ` [PATCH v3 5/5] OvmfPkg/Microvm: add README Gerd Hoffmann
@ 2021-12-13 12:18 ` Ard Biesheuvel
5 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2021-12-13 12:18 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: edk2-devel-groups-io, Jordan Justen, Jiewen Yao, Pawel Polawski,
Philippe Mathieu-Daudé, Ard Biesheuvel
On Mon, 13 Dec 2021 at 09:17, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Adds support for virtio-mmio devices to microvm.
>
> While being at it also add the README, the
> patch somehow disappeared from the first batch.
>
> v3:
> - uncrustify & rebase to latest master
> - pick up some review tags
> - minor README updates.
>
> v2:
> - qemu changes needed for this are merged and will be
> in the 6.2 release (dec 2021).
> - more verbose commit messages.
>
> Gerd Hoffmann (5):
> OvmfPkg/Microvm/fdt: add device tree support
> OvmfPkg/Microvm/fdt: load fdt from fw_cfg
> OvmfPkg/Microvm/fdt: add empty fdt
> OvmfPkg/Microvm/virtio: add virtio-mmio support
> OvmfPkg/Microvm: add README
>
Merged as #2295
Thanks,
> OvmfPkg/Microvm/MicrovmX64.dsc | 8 ++++
> OvmfPkg/Microvm/MicrovmX64.fdf | 3 ++
> OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
> OvmfPkg/PlatformPei/Platform.c | 63 +++++++++++++++++++++++++++++
> OvmfPkg/Microvm/README | 50 +++++++++++++++++++++++
> 5 files changed, 125 insertions(+)
> create mode 100644 OvmfPkg/Microvm/README
>
> --
> 2.33.1
>
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2021-12-13 12:19 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-13 8:16 [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches Gerd Hoffmann
2021-12-13 8:16 ` [PATCH v3 1/5] OvmfPkg/Microvm/fdt: add device tree support Gerd Hoffmann
2021-12-13 9:38 ` Philippe Mathieu-Daudé
2021-12-13 8:16 ` [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg Gerd Hoffmann
2021-12-13 9:33 ` Philippe Mathieu-Daudé
2021-12-13 11:21 ` Gerd Hoffmann
2021-12-13 9:43 ` [edk2-devel] " Ard Biesheuvel
2021-12-13 11:26 ` Gerd Hoffmann
2021-12-13 11:30 ` Ard Biesheuvel
2021-12-13 8:16 ` [PATCH v3 3/5] OvmfPkg/Microvm/fdt: add empty fdt Gerd Hoffmann
2021-12-13 9:35 ` Philippe Mathieu-Daudé
2021-12-13 8:16 ` [PATCH v3 4/5] OvmfPkg/Microvm/virtio: add virtio-mmio support Gerd Hoffmann
2021-12-13 9:38 ` Philippe Mathieu-Daudé
2021-12-13 8:16 ` [PATCH v3 5/5] OvmfPkg/Microvm: add README Gerd Hoffmann
2021-12-13 9:37 ` Philippe Mathieu-Daudé
2021-12-13 12:18 ` [PATCH v3 0/5] OvmfPkg/Microvm: second batch of microvm patches Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox