* Running OVMF on crosvm
@ 2022-06-16 23:29 Mike Gerow
2022-06-16 23:45 ` [edk2-devel] " Andrew Fish
2022-06-17 0:06 ` Pedro Falcato
0 siblings, 2 replies; 4+ messages in thread
From: Mike Gerow @ 2022-06-16 23:29 UTC (permalink / raw)
To: devel
[-- Attachment #1.1: Type: text/plain, Size: 2014 bytes --]
Hi Folks,
For the last few months I've been using OVMF with crosvm ( https://chromium.googlesource.com/chromiumos/platform/crosvm/+/HEAD/README.md#:~:text=crosvm%20is%20a%20virtual%20machine,on%20the%20Chrome%20OS%20platform. ) to give it the ability to boot a UEFI OS image in a UEFI environment, and it's been working fantastically! Eventually I'd like to get secure boot working, but I haven't fully begun exploring that yet. I just wanted to post here to figure out how I might go about making crosvm properly supported within OVMF.
As you might guess, OVMF didn't boot out of the box and I had to do quite a few hacks to get it to work. All the changes are attached as a diff, but I'll list the main points out here:
* Switch TimerLib from the ACPI-based ones like OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf to MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf since crosvm doesn't provide these methods
* Hack out the RTC dependency completely, since for reasons I haven't yet figured out crosvm hangs OVMF tries to access it
* Disable bus enumeration since crosvm doesn't support moving PCI BARs around, which causes it to hang
* Remove VirtioFsDxe dependency as crosvm seems to choke on certain things it's doing too
* Manually searching for ACPI tables instead of using PVH
And one major theme of some of the other changes: removing conditionals that checked if we're cloud-hypervisor and just doing things the cloud-hypervisor way (which happens to work under crosvm, for reasons that are readily apparent given the nature of cloud-hypervisor and crosvm).
Clearly this isn't upstreamable at this point, but I'd like eventually go that direction. I think a lot of these are just bugs in crosvm that'll need to be fixed, but for the cloud-hypervisor conditionals case I'd need to teach OVMF to detect when we're running under crosvm and act appropriately.
In either case, I appreciate your attention and any feedback you might have on what I'm trying to do here.
[-- Attachment #1.2: Type: text/html, Size: 2133 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ovmf-crosvm.diff --]
[-- Type: text/x-patch; name="ovmf-crosvm.diff", Size: 17563 bytes --]
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c
index 3fe02940ed..765cb131c2 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c
@@ -31,7 +31,8 @@ EFI_CORE_PROTOCOL_NOTIFY_ENTRY mArchProtocols[] = {
{ &gEfiCapsuleArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiMonotonicCounterArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiResetArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
- { &gEfiRealTimeClockArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
+ // TODO(b/235855065): get the RTC working properly
+ //{ &gEfiRealTimeClockArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ NULL, (VOID **)NULL, NULL, NULL, FALSE }
};
diff --git a/MdePkg/Include/Protocol/SimpleTextIn.h b/MdePkg/Include/Protocol/SimpleTextIn.h
index 838fae279e..6d15e237b3 100644
--- a/MdePkg/Include/Protocol/SimpleTextIn.h
+++ b/MdePkg/Include/Protocol/SimpleTextIn.h
@@ -42,8 +42,9 @@ typedef struct {
//
#define CHAR_BACKSPACE 0x0008
#define CHAR_TAB 0x0009
-#define CHAR_LINEFEED 0x000A
-#define CHAR_CARRIAGE_RETURN 0x000D
+// TODO(b/236185272): Figure out why we need to swap CR and LF.
+#define CHAR_LINEFEED 0x000D
+#define CHAR_CARRIAGE_RETURN 0x000A
//
// EFI Scan codes
diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c
index fcfb9703bd..c9e0aa84d5 100644
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c
+++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c
@@ -28,15 +28,7 @@ InstallAcpiTables (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable
)
{
- EFI_STATUS Status;
- UINT16 HostBridgeDevId;
-
- HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);
- if (HostBridgeDevId == CLOUDHV_DEVICE_ID) {
- Status = InstallCloudHvTables (AcpiTable);
- } else {
- Status = InstallQemuFwCfgTables (AcpiTable);
- }
-
- return Status;
+ // TODO(b/236184260): Add conditional back once we can reliably identify
+ // crosvm.
+ return InstallCloudHvTables(AcpiTable);
}
diff --git a/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c b/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c
index ff59600d3e..93858eb3b4 100644
--- a/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c
+++ b/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c
@@ -51,7 +51,31 @@ InstallCloudHvTables (
}
pvh_start_info = (struct hvm_start_info *)(UINTN)PVHResetVectorData[0];
- AcpiRsdpStructurePtr = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)(UINTN)pvh_start_info->rsdp_paddr;
+
+ // If the PVH struct wasn't there then fall back to finding the RDSP the way a
+ // normal OS would, by scanning for the string "RSD PTR" starting from 0x00E0000.
+ // https://wiki.osdev.org/RSDP
+ //
+ // TODO(b/221075887): teach crosvm to do the xen thing and remove this.
+ if (pvh_start_info->magic != XEN_HVM_START_MAGIC_VALUE) {
+ UINT64 *p = (UINT64 *)0x000E0000;
+ UINT64 magic = 0x2052545020445352; // 'RSD PTR ' but C doesn't have 64-bit character constants, womp womp.
+ int found = 0;
+
+ // Looking on a 16-byte boundary, hence the += 2.
+ for (; p < (UINT64 *)0x000FFFFF; p += 2) {
+ if (*p == magic) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ return EFI_NOT_FOUND;
+ }
+ AcpiRsdpStructurePtr = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)p;
+ } else {
+ AcpiRsdpStructurePtr = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)pvh_start_info->rsdp_paddr;
+ }
// If XSDT table is found, just install its tables.
// Otherwise, try to find and install the RSDT tables.
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index 8a111444f8..9e6e4b1628 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -127,7 +127,7 @@
[LibraryClasses]
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf
+ TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/BaseResetSystemLib.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
@@ -243,7 +243,6 @@
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
[LibraryClasses.common.SEC]
- TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf
!ifdef $(DEBUG_ON_SERIAL_PORT)
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
!else
@@ -332,7 +331,6 @@
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
@@ -353,7 +351,6 @@
[LibraryClasses.common.UEFI_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
@@ -369,7 +366,6 @@
[LibraryClasses.common.DXE_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -401,7 +397,6 @@
[LibraryClasses.common.UEFI_APPLICATION]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -415,7 +410,6 @@
[LibraryClasses.common.DXE_SMM_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
@@ -438,7 +432,6 @@
[LibraryClasses.common.SMM_CORE]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf
MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf
@@ -630,6 +623,7 @@
# Set ConfidentialComputing defaults
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
[PcdsDynamicHii]
!include OvmfPkg/OvmfTpmPcdsHii.dsc.inc
@@ -718,7 +712,7 @@
OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
<LibraryClasses>
- PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+ PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf
}
@@ -728,7 +722,6 @@
}
MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
MdeModulePkg/Universal/Metronome/Metronome.inf
- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {
<LibraryClasses>
@@ -780,7 +773,6 @@
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf
MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
- OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf
MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
OvmfPkg/SataControllerDxe/SataControllerDxe.inf
diff --git a/OvmfPkg/CloudHv/CloudHvX64.fdf b/OvmfPkg/CloudHv/CloudHvX64.fdf
index a41a553693..7e4c2f6c26 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.fdf
+++ b/OvmfPkg/CloudHv/CloudHvX64.fdf
@@ -223,7 +223,6 @@ INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
INF MdeModulePkg/Universal/Metronome/Metronome.inf
-INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
INF OvmfPkg/Virtio10Dxe/Virtio10.inf
@@ -284,7 +283,6 @@ INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResour
INF FatPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
-INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf
!if $(TOOL_CHAIN_TAG) != "XCODE5"
INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 51016a5548..2804dd83d6 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -426,9 +426,9 @@ PlatformBootManagerBeforeConsole (
// rely on the serial I/O port to be connected as a console. It reuses the
// definition from Xen as it is very generic.
//
- PlatformInitializeConsole (
- (XenDetected () || PcdGet16 (PcdOvmfHostBridgePciDevId) == CLOUDHV_DEVICE_ID) ? gXenPlatformConsole : gPlatformConsole
- );
+ // TODO(b/236184260): Add conditional back once we can reliably identify
+ // crosvm.
+ PlatformInitializeConsole(gXenPlatformConsole);
//
// Process TPM PPI request; this may require keyboard input
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 1448f925b7..c4e73ed4ec 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -140,7 +140,7 @@
[LibraryClasses]
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf
+ TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/BaseResetSystemLib.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
@@ -261,7 +261,6 @@
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLib.inf
[LibraryClasses.common.SEC]
- TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf
!ifdef $(DEBUG_ON_SERIAL_PORT)
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
@@ -351,7 +350,6 @@
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
@@ -373,7 +371,6 @@
[LibraryClasses.common.UEFI_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
@@ -389,7 +386,6 @@
[LibraryClasses.common.DXE_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -421,7 +417,6 @@
[LibraryClasses.common.UEFI_APPLICATION]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -435,7 +430,6 @@
[LibraryClasses.common.DXE_SMM_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
@@ -458,7 +452,6 @@
[LibraryClasses.common.SMM_CORE]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf
MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf
@@ -683,6 +676,9 @@
# Set ConfidentialComputing defaults
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0
+ # Disable bus enumeration
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
+
!if $(CSM_ENABLE) == FALSE
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000
!endif
@@ -825,7 +821,7 @@
OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
<LibraryClasses>
- PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+ PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf
}
@@ -835,7 +831,6 @@
}
MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
MdeModulePkg/Universal/Metronome/Metronome.inf
- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {
<LibraryClasses>
@@ -895,7 +890,6 @@
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf
MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
- OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf
MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
OvmfPkg/SataControllerDxe/SataControllerDxe.inf
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 438806fba8..26b7d11da0 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -257,7 +257,6 @@ INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
INF MdeModulePkg/Universal/Metronome/Metronome.inf
-INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
INF OvmfPkg/Virtio10Dxe/Virtio10.inf
@@ -322,7 +321,6 @@ INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResour
INF FatPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
-INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf
!if $(TOOL_CHAIN_TAG) != "XCODE5"
INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
diff --git a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c b/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
index e55d135504..b5bb81bf76 100644
--- a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
+++ b/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
@@ -28,24 +28,12 @@ SmbiosTablePublishEntry (
{
EFI_STATUS Status;
UINT8 *SmbiosTables;
- UINT16 HostBridgeDevId;
+ // TODO(b/236184260): Add conditional back once we can reliably identify crosvm.
Status = EFI_NOT_FOUND;
- //
- // Add SMBIOS data if found
- //
- HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);
- if (HostBridgeDevId == CLOUDHV_DEVICE_ID) {
- SmbiosTables = GetCloudHvSmbiosTables ();
- if (SmbiosTables != NULL) {
- Status = InstallAllStructures (SmbiosTables);
- }
- } else {
- SmbiosTables = GetQemuSmbiosTables ();
- if (SmbiosTables != NULL) {
- Status = InstallAllStructures (SmbiosTables);
- FreePool (SmbiosTables);
- }
+ SmbiosTables = GetCloudHvSmbiosTables ();
+ if (SmbiosTables != NULL) {
+ Status = InstallAllStructures (SmbiosTables);
}
return Status;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [edk2-devel] Running OVMF on crosvm
2022-06-16 23:29 Running OVMF on crosvm Mike Gerow
@ 2022-06-16 23:45 ` Andrew Fish
2022-06-17 0:06 ` Pedro Falcato
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Fish @ 2022-06-16 23:45 UTC (permalink / raw)
To: devel, gerow
[-- Attachment #1: Type: text/plain, Size: 2580 bytes --]
Mike,
FYI you are not subscribed to the mailing list so all your posts require a humans approval, so that is the delay in them showing up..
> On Jun 16, 2022, at 4:29 PM, Mike Gerow via groups.io <gerow=google.com@groups.io> wrote:
>
> Hi Folks,
>
> For the last few months I've been using OVMF with crosvm <https://chromium.googlesource.com/chromiumos/platform/crosvm/+/HEAD/README.md#:~:text=crosvm%20is%20a%20virtual%20machine,on%20the%20Chrome%20OS%20platform.> to give it the ability to boot a UEFI OS image in a UEFI environment, and it's been working fantastically! Eventually I'd like to get secure boot working, but I haven't fully begun exploring that yet. I just wanted to post here to figure out how I might go about making crosvm properly supported within OVMF.
>
> As you might guess, OVMF didn't boot out of the box and I had to do quite a few hacks to get it to work. All the changes are attached as a diff, but I'll list the main points out here:
>
> * Switch TimerLib from the ACPI-based ones like OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf to MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf since crosvm doesn't provide these methods
> * Hack out the RTC dependency completely, since for reasons I haven't yet figured out crosvm hangs OVMF tries to access it
> * Disable bus enumeration since crosvm doesn't support moving PCI BARs around, which causes it to hang
> * Remove VirtioFsDxe dependency as crosvm seems to choke on certain things it's doing too
I hit something like this in another context. I root caused it to the VirtioFsDxe being coded to a recent version of the VirtIo Spec (it is a newer EFI driver) and my VM was on an older version. So some things did not work properly.
Thanks,
Andrew Fish
> * Manually searching for ACPI tables instead of using PVH
>
> And one major theme of some of the other changes: removing conditionals that checked if we're cloud-hypervisor and just doing things the cloud-hypervisor way (which happens to work under crosvm, for reasons that are readily apparent given the nature of cloud-hypervisor and crosvm).
>
> Clearly this isn't upstreamable at this point, but I'd like eventually go that direction. I think a lot of these are just bugs in crosvm that'll need to be fixed, but for the cloud-hypervisor conditionals case I'd need to teach OVMF to detect when we're running under crosvm and act appropriately.
>
> In either case, I appreciate your attention and any feedback you might have on what I'm trying to do here.
>
> <ovmf-crosvm.diff>
[-- Attachment #2: Type: text/html, Size: 3559 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] Running OVMF on crosvm
2022-06-16 23:29 Running OVMF on crosvm Mike Gerow
2022-06-16 23:45 ` [edk2-devel] " Andrew Fish
@ 2022-06-17 0:06 ` Pedro Falcato
2022-06-17 1:55 ` Mike Gerow
1 sibling, 1 reply; 4+ messages in thread
From: Pedro Falcato @ 2022-06-17 0:06 UTC (permalink / raw)
To: edk2-devel-groups-io, gerow
[-- Attachment #1: Type: text/plain, Size: 2343 bytes --]
Hi Mike,
What's the point of upstreaming firmware for crosvm? Isn't crosvm supposed
to be a "thin" hypervisor that runs the kernel directly?
Thanks,
Pedro
On Fri, Jun 17, 2022 at 12:40 AM Mike Gerow via groups.io <gerow=
google.com@groups.io> wrote:
> Hi Folks,
>
> For the last few months I've been using OVMF with crosvm
> <https://chromium.googlesource.com/chromiumos/platform/crosvm/+/HEAD/README.md#:~:text=crosvm%20is%20a%20virtual%20machine,on%20the%20Chrome%20OS%20platform.>
> to give it the ability to boot a UEFI OS image in a UEFI environment, and
> it's been working fantastically! Eventually I'd like to get secure boot
> working, but I haven't fully begun exploring that yet. I just wanted to
> post here to figure out how I might go about making crosvm properly
> supported within OVMF.
>
> As you might guess, OVMF didn't boot out of the box and I had to do quite
> a few hacks to get it to work. All the changes are attached as a diff, but
> I'll list the main points out here:
>
> * Switch TimerLib from the ACPI-based ones
> like OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf
> to MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf since
> crosvm doesn't provide these methods
> * Hack out the RTC dependency completely, since for reasons I haven't yet
> figured out crosvm hangs OVMF tries to access it
> * Disable bus enumeration since crosvm doesn't support moving PCI BARs
> around, which causes it to hang
> * Remove VirtioFsDxe dependency as crosvm seems to choke on certain things
> it's doing too
> * Manually searching for ACPI tables instead of using PVH
>
> And one major theme of some of the other changes: removing conditionals
> that checked if we're cloud-hypervisor and just doing things the
> cloud-hypervisor way (which happens to work under crosvm, for reasons that
> are readily apparent given the nature of cloud-hypervisor and crosvm).
>
> Clearly this isn't upstreamable at this point, but I'd like eventually go
> that direction. I think a lot of these are just bugs in crosvm that'll need
> to be fixed, but for the cloud-hypervisor conditionals case I'd need to
> teach OVMF to detect when we're running under crosvm and act appropriately.
>
> In either case, I appreciate your attention and any feedback you might
> have on what I'm trying to do here.
>
>
>
--
Pedro Falcato
[-- Attachment #2: Type: text/html, Size: 2944 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] Running OVMF on crosvm
2022-06-17 0:06 ` Pedro Falcato
@ 2022-06-17 1:55 ` Mike Gerow
0 siblings, 0 replies; 4+ messages in thread
From: Mike Gerow @ 2022-06-17 1:55 UTC (permalink / raw)
To: Pedro Falcato; +Cc: edk2-devel-groups-io
[-- Attachment #1: Type: text/plain, Size: 675 bytes --]
On Thu, Jun 16, 2022, 17:06 Pedro Falcato <pedro.falcato@gmail.com> wrote:
> Hi Mike,
>
> What's the point of upstreaming firmware for crosvm? Isn't crosvm supposed
> to be a "thin" hypervisor that runs the kernel directly?
>
Yes, the initial goal was for crosvm to be a thin hypervisor, just running
the kernel directly, but it's expanded in capabilities (and complexity)
over the years.
I'm working to expand on ChromeOS's current Crostini system to let it run
more generic VMs, so part of that means being able to boot from a normal
UEFI disk image and locking that down from the inside using secure boot so
we can run things other than the official Crostini offering.
[-- Attachment #2: Type: text/html, Size: 1201 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-06-17 1:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-16 23:29 Running OVMF on crosvm Mike Gerow
2022-06-16 23:45 ` [edk2-devel] " Andrew Fish
2022-06-17 0:06 ` Pedro Falcato
2022-06-17 1:55 ` Mike Gerow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox