public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sami Mujawar" <sami.mujawar@arm.com>
To: Jianyong Wu <Jianyong.Wu@arm.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	"lersek@redhat.com" <lersek@redhat.com>,
	"ardb+tianocore@kernel.org" <ardb+tianocore@kernel.org>
Cc: "hao.a.wu@intel.com" <hao.a.wu@intel.com>,
	Justin He <Justin.He@arm.com>, Leif Lindholm <leif@nuviainc.com>,
	nd <nd@arm.com>
Subject: Re: [PATCH v2 4/5] ArmVirtPkg: Introduce Cloud Hypervisor to edk2 family
Date: Sat, 29 May 2021 08:43:52 +0100	[thread overview]
Message-ID: <31935dd3-3028-b236-56e8-e05813d9a205@arm.com> (raw)
In-Reply-To: <AM9PR08MB7055566199870B7FA0FDAA09F4239@AM9PR08MB7055.eurprd08.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 43491 bytes --]

Hi Jianyon,

Please find my response inline marked [SAMI].

Regards,

Sami Mujawar

On 27/05/2021 07:19 AM, Jianyong Wu wrote:
> Hi Sami,
>
>> -----Original Message-----
>> From: Sami Mujawar <Sami.Mujawar@arm.com>
>> Sent: Wednesday, May 19, 2021 4:27 AM
>> To: Jianyong Wu <Jianyong.Wu@arm.com>; devel@edk2.groups.io;
>> lersek@redhat.com; ardb+tianocore@kernel.org
>> Cc: hao.a.wu@intel.com; Justin He <Justin.He@arm.com>; Leif Lindholm
>> <leif@nuviainc.com>; nd <nd@arm.com>
>> Subject: Re: [PATCH v2 4/5] ArmVirtPkg: Introduce Cloud Hypervisor to edk2
>> family
>>
>> Hi Jianyon,
>>
>> Thank you for this patch.
>>
>> Please find my response inline marked [SAMI].
>>
>> Regards,
>>
>> Sami Mujawar
>>
>>
>> On 17/05/2021 07:50 AM, Jianyong Wu wrote:
>>> Cloud Hypervisor is kvm based VMM and is implemented in rust. Just
>>> like other VMMs it need UEFI support to let ACPI work. That's why
>>> Cloud Hypervisor is introduced here.
>>>
>>> Cc: Laszlo Ersek <lersek@redhat.com>
>>> Cc: Leif Lindholm <leif@nuviainc.com>
>>> Cc:
>>> Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
>>> ---
>>>    ArmVirtPkg/ArmVirtCloudHv.dsc           | 455
>> ++++++++++++++++++++++++
>>>    ArmVirtPkg/ArmVirtCloudHv.fdf           | 292 +++++++++++++++
>>>    ArmVirtPkg/ArmVirtCloudHvFvMain.fdf.inc | 169 +++++++++
>>>    3 files changed, 916 insertions(+)
>>>    create mode 100644 ArmVirtPkg/ArmVirtCloudHv.dsc
>>>    create mode 100644 ArmVirtPkg/ArmVirtCloudHv.fdf
>>>    create mode 100644 ArmVirtPkg/ArmVirtCloudHvFvMain.fdf.inc
>>>
>>> diff --git a/ArmVirtPkg/ArmVirtCloudHv.dsc
>>> b/ArmVirtPkg/ArmVirtCloudHv.dsc new file mode 100644 index
>>> 000000000000..bf1f8c5a75ae
>>> --- /dev/null
>>> +++ b/ArmVirtPkg/ArmVirtCloudHv.dsc
>>> @@ -0,0 +1,455 @@
>>> +#
>>> +#  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
>>> +#  Copyright (c) 2014, Linaro Limited. All rights reserved.
>>> +#  Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
>>> +#
>>> +#  SPDX-License-Identifier: BSD-2-Clause-Patent # #
>>> +
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +#
>>> +# Defines Section - statements that will be processed to create a Makefile.
>>> +#
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +[Defines]
>>> +  PLATFORM_NAME                  = ArmVirtCloudHv
>>> +  PLATFORM_GUID                  = DFFED32B-DFFE-D32B-DFFE-D32BDFFED32B
>>> +  PLATFORM_VERSION               = 0.1
>>> +  DSC_SPECIFICATION              = 0x00010005
>>> +  OUTPUT_DIRECTORY               = Build/ArmVirtCloudHv-$(ARCH)
>>> +  SUPPORTED_ARCHITECTURES        = AARCH64|ARM
>>> +  BUILD_TARGETS                  = DEBUG|RELEASE|NOOPT
>>> +  SKUID_IDENTIFIER               = DEFAULT
>>> +  FLASH_DEFINITION               = ArmVirtPkg/ArmVirtCloudHv.fdf
>>> +
>>> +  #
>>> +  # Defines for default states.  These can be changed on the command line.
>>> +  # -D FLAG=VALUE
>>> +  #
>>> +  DEFINE TTY_TERMINAL            = FALSE
>>> +  DEFINE SECURE_BOOT_ENABLE      = FALSE
>>> +  DEFINE TPM2_ENABLE             = FALSE
>>> +  DEFINE TPM2_CONFIG_ENABLE      = FALSE
>>> +
>>> +!include ArmVirtPkg/ArmVirt.dsc.inc
>>> +
>>> +[LibraryClasses.common]
>>> +  ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
>>> +  ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
>>> +
>>> +  # Virtio Support
>>> +  VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
>>> +
>>> +
>> VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDe
>>> + viceLib.inf
>>> + QemuFwCfgLib|ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
>>> +
>>> +
>> QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3Li
>> bNull
>>> + .inf
>>> +
>> QemuFwCfgSimpleParserLib|OvmfPkg/Library/QemuFwCfgSimpleParserLib/
>> Qe
>>> + muFwCfgSimpleParserLib.inf
>>> +
>> QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/Generic
>> Qemu
>>> + LoadImageLib.inf
>> [SAMI] Does Cloud Hypervisor support Qemu-FwCfg? If not, then are the
>> above 4 libraries needed?
> Hi Sami, I think CloudHv doesn't dependent on qemu-fwcfg, so I have tried to remove the dependencies. But I find it difficult to do that.
> Some implicit codes depend on qemu-cfg that I can't do workaround. E.g.
>   
> In OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c
> "
>   Status = QemuFwCfgFindFile ("etc/extra-pci-roots", &FwCfgItem, &FwCfgSize);
>    if (EFI_ERROR (Status) || FwCfgSize != sizeof ExtraRootBridges) {
>      ExtraRootBridges = 0;
>    } else {
>      QemuFwCfgSelectItem (FwCfgItem);
>      QemuFwCfgReadBytes (FwCfgSize, &ExtraRootBridges);
> "
> I don't know how to do with it. So, I keep it here.
> Maybe I need your help if these dependencies should be removed.
[SAMI] I am working on a patch series that adds ACPI and PCI support for 
Kvmtool firmware. So, I may just have the patch you need. The patch is 
an instance of PciHostBridgeUtilityLib without the FwCfg and I think it 
should work for Choud Hypervisor too.
If you can try the attached patch and let me know if it works; I will 
reword the patch so that it is common for both Kvmtool and Cloud 
Hypervisor and post it to the mailing list.
Please let me know if you face any issues.
[/SAMI]
>>> +
>>> +
>>> +
>> ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatform
>>> + LibNull.inf
>>> +
>>> +  TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
>>> +
>>> +
>> CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.
>>> + inf  BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
>>> +
>>> +
>> PlatformBootManagerLib|ArmVirtPkg/Library/PlatformBootManagerLib/Pla
>>> + tformBootManagerLib.inf
>> [SAMI] The above instance of PlatformBootManagerLibhas a dependency on
>> Qemu-FwCfg, right?
>>> +
>>> +
>> PlatformBmPrintScLib|OvmfPkg/Library/PlatformBmPrintScLib/PlatformBm
>>> + PrintScLib.inf
>>> +
>> CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Custo
>>> + mizedDisplayLib.inf
>>> +
>> FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBuffer
>>> + BltLib.inf
>>> +
>> QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrder
>> Lib.i
>>> + nf
>> [SAMI] Qemu-FwCfg dependency?
> Sure
>
>>> +
>>> + FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib
>>> + .inf
>>> + PciPcdProducerLib|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdP
>>> + roducerLib.inf
>>> +
>> PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibP
>>> + ci.inf
>>> + PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBr
>>> + idgeLib.inf
>>> + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciH
>>> + ostBridgeUtilityLib.inf
>>> +
>>> +!if $(TPM2_ENABLE) == TRUE
>>> +
>>>
>> +Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2Command
>> Lib.inf
>>> +
>>>
>> +Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/
>> D
>>> +xeTcg2PhysicalPresenceLib.inf
>> [SAMI] Is this supported by Cloud Hypervisor?
> No, should be removed.
>
>>> +
>>>
>> +TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeT
>> pmMeas
>>> +urementLib.inf
>>> +!else
>>> +
>>>
>> +TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/T
>> pmMeasu
>>> +rementLibNull.inf
>>> +!endif
>>> +
>>> +!include MdePkg/MdeLibs.dsc.inc
>>> +
>>> +[LibraryClasses.common.PEIM]
>>> +
>>>
>> +ArmVirtMemInfoLib|ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHv
>> Vir
>>> +tMemInfoPeiLib.inf
>>> +
>>> +!if $(TPM2_ENABLE) == TRUE
>>> +  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
>>> +
>>>
>> +ResetSystemLib|MdeModulePkg/Library/PeiResetSystemLib/PeiResetSyst
>> emL
>>> +ib.inf
>>> +
>>>
>> +Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibD
>> Tpm
>>> +.inf
>>> +!endif
>>> +
>>> +[LibraryClasses.common.DXE_DRIVER]
>>> +
>>>
>> +ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/D
>> xeRe
>>> +portStatusCodeLib.inf
>>> +
>>> +!if $(TPM2_ENABLE) == TRUE
>>> +
>>>
>> +Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg
>> 2
>>> +.inf
>>> +!endif
>>> +
>>> +[LibraryClasses.common.UEFI_DRIVER]
>>> +  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
>>> +
>>> +[BuildOptions]
>>> +!include NetworkPkg/NetworkBuildOptions.dsc.inc
>>> +
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +#
>>> +# Pcd Section - list of all EDK II PCD Entries defined by this
>>> +Platform #
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +
>>> +[PcdsFeatureFlag.common]
>>> +  gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE
>>> +
>> gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|TRUE
>>> +
>>> +  ## If TRUE, Graphics Output Protocol will be installed on virtual handle
>> created by ConsplitterDxe.
>>> +  #  It could be set FALSE to save size.
>>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
>>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
>>> +
>>> +
>> gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE
>>> +
>>> +  gArmVirtTokenSpaceGuid.PcdTpm2SupportEnabled|$(TPM2_ENABLE)
>>> +
>>> +[PcdsFixedAtBuild.common]
>>> +!if $(ARCH) == AARCH64
>>> +  gArmTokenSpaceGuid.PcdVFPEnabled|1
>>> +!endif
>>> +
>>> +  gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase|0x4007c000
>>> +
>> gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
>>> +  gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000
>>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
>>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
>>> +
>>> +  # Rsdp base address in Cloud Hypervisor
>>> +
>> gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiRsdpBaseAddress|0x40200000
>>> +
>>> +
>>>
>> +gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x40
>> 0000
>>> +0
>>> +
>>>
>> +gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x400
>> 00
>>> +!if $(NETWORK_TLS_ENABLE) == TRUE
>>> +  #
>>> +  # The cumulative and individual VOLATILE variable size limits
>>> +should be set
>>> +  # high enough for accommodating several and/or large CA certificates.
>>> +  #
>>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x80000
>>> +
>> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize|0x40000
>>> +!endif
>>> +
>>> +  # Size of the region used by UEFI in permanent memory (Reserved
>>> + 64MB)
>>> +
>> gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x040000
>> 00
>>> +
>>> +  #
>>> +  # ARM PrimeCell
>>> +  #
>>> +
>>> +  ## PL011 - Serial Terminal
>>> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|38400
>>> +
>>> +  ## Default Terminal Type
>>> +  ## 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM !if
>>> +$(TTY_TERMINAL) == TRUE
>>> +  gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4
>>> +  # Set terminal type to TtyTerm, the value encoded is
>>> +EFI_TTY_TERM_GUID
>>> +  gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d,
>> 0x91,
>>> +0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51,
>>> +0xef, 0x94} !else
>>> +  gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|1
>>> +!endif
>>> +
>>> +  # System Memory Base -- fixed at 0x4000_0000
>>> +  gArmTokenSpaceGuid.PcdSystemMemoryBase|0x40000000
>>> +
>>> +  # initial location of the device tree blob passed by Cloud
>>> + Hypervisor -- base of DRAM
>>> +  gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x40000000
>>> +
>>> +
>>> +
>>> +
>> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationC
>> hange
>>> + |FALSE
>> gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{
>>> + 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a,
>>> + 0xb6, 0xf4, 0x66, 0x23, 0x31 }
>>> +
>>> +  #
>>> +  # The maximum physical I/O addressability of the processor, set
>>> + with  # BuildCpuHob().
>>> +  #
>>> +  gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16
>>> +
>>> +  #
>>> +  # Enable the non-executable DXE stack. (This gets set up by DxeIpl)
>>> + #  gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
>>> +
>>> +!if $(SECURE_BOOT_ENABLE) == TRUE
>>> +  # override the default values from SecurityPkg to ensure images
>>> +from all sources are verified in secure boot
>>> +
>>>
>> +gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x
>> 0
>>> +4
>>> +
>>>
>> +gEfiSecurityPkgTokenSpaceGuid.PcdFixedMediaImageVerificationPolicy|0x
>>> +04
>>> +
>>>
>> +gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPoli
>> c
>>> +y|0x04
>>> +!endif
>>> +
>>> +  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|3
>>> +  gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x20000
>>> +
>>> +[PcdsFixedAtBuild.AARCH64]
>>> +  # Clearing BIT0 in this PCD prevents installing a 32-bit SMBIOS
>>> +entry point,
>>> +  # if the entry point version is >= 3.0. AARCH64 OSes cannot assume
>>> +the
>>> +  # presence of the 32-bit entry point anyway (because many AARCH64
>>> +systems
>>> +  # don't have 32-bit addressable physical RAM), and the additional
>>> +allocations
>>> +  # below 4 GB needlessly fragment the memory map. So expose the
>>> +64-bit entry
>>> +  # point only, for entry point versions >= 3.0.
>>> +
>> gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosEntryPointProvideMethod|0
>> x2
>>> +
>>> +[PcdsDynamicDefault.common]
>>> +  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3
>>> +
>>> +  ## If TRUE, OvmfPkg/AcpiPlatformDxe will not wait for PCI  #
>>> + enumeration to complete before installing ACPI tables.
>>> +
>> gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
>>> +
>>> +  # System Memory Size -- 1 MB initially, actual size will be fetched
>>> + from DT
>>> +  gArmTokenSpaceGuid.PcdSystemMemorySize|0x00100000
>>> +
>>> +
>> gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
>>> +
>>> +  gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0
>>> +  gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x0
>>> +  gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x0
>>> +  gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum|0x0
>>> +
>>> +  #
>>> +  # ARM General Interrupt Controller
>>> +  #
>>> +  gArmTokenSpaceGuid.PcdGicDistributorBase|0x0
>>> +  gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x0
>>> +  gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x0
>>> +
>>> +  ## PL031 RealTimeClock
>>> +  gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0
>>> +
>>> +  # set PcdPciExpressBaseAddress to MAX_UINT64, which signifies that
>>> + this  # PCD and PcdPciDisableBusEnumeration above have not been
>>> + assigned yet
>>> +
>> gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xFFFFFFFFFFFFFF
>> FF
>>> +
>>> +  gArmTokenSpaceGuid.PcdPciIoTranslation|0
>>> +#  gArmTokenSpaceGuid.PcdPciIoTranslation|0x50000000
>> [SAMI] Remove commented code.
> Yeah
>
>>> +
>>> +  #
>>> +  # TPM2 support
>>> +  #
>>> +  gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress|0x0
>>> +!if $(TPM2_ENABLE) == TRUE
>>> +  gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x00, 0x00, 0x00,
>>> +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>>> +0x00, 0x00}
>>> +  gEfiSecurityPkgTokenSpaceGuid.PcdTpm2HashMask|0
>>> +!endif
>>> +
>>> +[PcdsDynamicHii]
>>> +
>>>
>> +gArmVirtTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gArmVirtVaria
>> ble
>>> +Guid|0x0|FALSE|NV,BS
>>> +
>>> +!if $(TPM2_CONFIG_ENABLE) == TRUE
>>> +
>>>
>> +gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer|L"TC
>>> +G2_VERSION"|gTcg2ConfigFormSetGuid|0x0|"1.3"|NV,BS
>>> +
>>>
>> +gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev|L"TCG2_VERSION"
>> |gTc
>>> +g2ConfigFormSetGuid|0x8|3|NV,BS
>>> +!endif
>>> +
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +#
>>> +# Components Section - list of all EDK II Modules needed by this
>>> +Platform #
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +[Components.common]
>>> +  #
>>> +  # PEI Phase modules
>>> +  #
>>> +  ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf
>>> +  MdeModulePkg/Core/Pei/PeiMain.inf
>>> +  MdeModulePkg/Universal/PCD/Pei/Pcd.inf {
>>> +    <LibraryClasses>
>>> +      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
>>> +  }
>>> +  ArmPlatformPkg/PlatformPei/PlatformPeim.inf
>>> +  ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf
>>> +  ArmPkg/Drivers/CpuPei/CpuPei.inf
>>> +
>>> +  MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
>>> +
>>> +!if $(TPM2_ENABLE) == TRUE
>>> +  MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf {
>>> +    <LibraryClasses>
>>> +
>>>
>> +ResetSystemLib|ArmVirtPkg/Library/ArmVirtPsciResetSystemPeiLib/ArmVi
>> r
>>> +tPsciResetSystemPeiLib.inf
>>> +  }
>>> +  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
>>> +  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf {
>>> +    <LibraryClasses>
>>> +
>> HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoR
>> outerPei.inf
>>> +
>> NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
>>> +
>> NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.in
>> f
>>> +
>> NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.in
>> f
>>> +
>> NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.in
>> f
>>> +
>>> +NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
>>> +  }
>>> +!endif
>>> +
>>> +  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf {
>>> +    <LibraryClasses>
>>> +
>>> +
>> NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDec
>> ompre
>>> + ssLib.inf
>>> +  }
>>> +
>>> +  #
>>> +  # DXE
>>> +  #
>>> +  MdeModulePkg/Core/Dxe/DxeMain.inf {
>>> +    <LibraryClasses>
>>> +
>> NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32G
>> uidedSectionExtractLib.inf
>>> +
>>> + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
>>> +  }
>>> +  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
>>> +    <LibraryClasses>
>>> +      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
>>> +  }
>>> +
>>> +  #
>>> +  # Architectural Protocols
>>> +  #
>>> +  ArmPkg/Drivers/CpuDxe/CpuDxe.inf
>>> +  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
>>> +
>> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
>>> +    <LibraryClasses>
>>> +      NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
>>> +      # don't use unaligned CopyMem () on the UEFI varstore NOR flash
>> region
>>> +
>> BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
>>> +  }
>>> +!if $(SECURE_BOOT_ENABLE) == TRUE
>>> +  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
>>> +    <LibraryClasses>
>>> +
>>> +NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerification
>>> +Lib.inf
>>> +!if $(TPM2_ENABLE) == TRUE
>>> +
>>>
>> +NULL|SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBo
>> otLib.
>>> +inf
>>> +!endif
>>> +  }
>>> +
>>>
>> +SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConf
>> i
>>> +gDxe.inf
>>> +  OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.inf
>>> +!else
>>> +  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
>>> +!endif
>>> +  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
>>> +
>>>
>> +MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.i
>> n
>>> +f
>>> +
>>>
>> +MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCou
>> nterRun
>>> +timeDxe.inf
>>> +
>>>
>> +MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntime
>> Dxe.in
>>> +f
>>> +
>> EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {
>>> +    <LibraryClasses>
>>> +
>>>
>> +NULL|ArmVirtPkg/Library/ArmVirtPL031FdtClientLib/ArmVirtPL031FdtClien
>>> +tLib.inf
>>> +  }
>>> +  EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
>>> +
>>> +
>> MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
>>> +  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
>>> +
>>> +
>> MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
>> xe
>>> + .inf  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
>>> +  MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
>>> +
>>> +  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
>>> +
>>> +  ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
>>> +  ArmPkg/Drivers/TimerDxe/TimerDxe.inf {
>>> +    <LibraryClasses>
>>> +
>>> + NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClie
>>> + ntLib.inf
>>> +  }
>>> +  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
>>> +
>>> +  #
>>> +  # Status Code Routing
>>> +  #
>>> +
>>> +
>> MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportSt
>> atu
>>> + sCodeRouterRuntimeDxe.inf
>>> +
>>> +  #
>>> +  # Platform Driver
>>> +  #
>>> +  ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf
>>> +  ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf
>>> +  ArmVirtPkg/HighMemDxe/HighMemDxe.inf
>>> +  OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
>>> +  OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
>>> +  OvmfPkg/VirtioNetDxe/VirtioNet.inf
>>> +  OvmfPkg/VirtioRngDxe/VirtioRng.inf
>>> +
>>> +  #
>>> +  # FAT filesystem + GPT/MBR partitioning + UDF filesystem +
>>> + virtio-fs  #  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
>>> +  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
>>> +
>>> +
>> MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.i
>>> + nf
>>> +  FatPkg/EnhancedFatDxe/Fat.inf
>>> +  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
>>> +  OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf
>>> +
>>> +  #
>>> +  # Bds
>>> +  #
>>> +  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf {
>>> +    <LibraryClasses>
>>> +
>> DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
>>> +      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
>>> +  }
>>> +  MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
>>> +  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
>>> +
>>> +
>> MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManager
>> Dxe
>>> + .inf  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
>>> +  MdeModulePkg/Logo/LogoDxe.inf
>>> +  MdeModulePkg/Application/UiApp/UiApp.inf {
>>> +    <LibraryClasses>
>>> +
>> NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
>>> +
>> NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
>>> +
>>> +
>> NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMainte
>> nanc
>>> + eManagerUiLib.inf
>>> +  }
>>> +  OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
>> [SAMI] Qemu-FwCfg dependency?
> Yeah
>
>>> +
>>> +  #
>>> +  # SCSI Bus and Disk Driver
>>> +  #
>>> +  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
>>> +  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
>>> +
>>> +  #
>>> +  # PCI support
>>> +  #
>>> +  ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf {
>>> +    <LibraryClasses>
>>> +
>>> + NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.in
>>> + f
>>> +  }
>>> +  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
>>> +  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {
>>> +    <LibraryClasses>
>>> +
>>> + NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.in
>>> + f
>>> +  }
>>> +  OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
>>> +  OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
>>> +  OvmfPkg/Virtio10Dxe/Virtio10.inf
>>> +
>>> +  #
>>> +  # TPM2 support
>>> +  #
>>> +!if $(TPM2_ENABLE) == TRUE
>>> +  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf {
>>> +    <LibraryClasses>
>>> +
>> HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoR
>> outerDxe.inf
>>> +
>> Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibR
>> outerDxe.inf
>>> +
>> NULL|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
>>> +
>> NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
>>> +
>> NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.in
>> f
>>> +
>> NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.in
>> f
>>> +
>> NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.in
>> f
>>> +
>>> +NULL|SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.inf
>>> +  }
>>> +!if $(TPM2_CONFIG_ENABLE) == TRUE
>>> +  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
>>> +!endif
>>> +!endif
>>> +
>>> +  #
>>> +  # ACPI Support
>>> +  #
>>> +  ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.inf
>>> +[Components.AARCH64]
>>> +
>>>
>> +MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGrap
>> hics
>>> +ResourceTableDxe.inf
>>> +  ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpiPlatformDxe.inf {
>>> +    <LibraryClasses>
>>> +
>>>
>> +NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf
>>> +  }
>>> diff --git a/ArmVirtPkg/ArmVirtCloudHv.fdf
>>> b/ArmVirtPkg/ArmVirtCloudHv.fdf new file mode 100644 index
>>> 000000000000..3619a09ba8c5
>>> --- /dev/null
>>> +++ b/ArmVirtPkg/ArmVirtCloudHv.fdf
>>> @@ -0,0 +1,292 @@
>>> +#
>>> +#  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
>>> +#  Copyright (c) 2014, Linaro Limited. All rights reserved.
>>> +#  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
>>> +#
>>> +#  SPDX-License-Identifier: BSD-2-Clause-Patent #
>>> +
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +#
>>> +# FD Section
>>> +# The [FD] Section is made up of the definition statements and a #
>>> +description of what goes into  the Flash Device Image.  Each FD
>>> +section # defines one flash "device" image.  A flash device image may
>>> +be one of # the following: Removable media bootable image (like a
>>> +boot floppy # image,) an Option ROM image (that would be "flashed"
>>> +into an add-in # card,) a System "Flash"  image (that would be burned
>>> +into a system's # flash) or an Update ("Capsule") image that will be
>>> +used to update and # existing system flash.
>>> +#
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +
>>> +[Defines]
>>> +!if $(FD_SIZE_IN_MB) == 2
>>> +  DEFINE FVMAIN_COMPACT_SIZE  = 0x1ff000 !endif !if $(FD_SIZE_IN_MB)
>>> +== 3
>>> +  DEFINE FVMAIN_COMPACT_SIZE  = 0x2ff000 !endif
>>> +
>>> +[FD.CLOUDHV_EFI]
>>> +BaseAddress   = 0x00000000|gArmTokenSpaceGuid.PcdFdBaseAddress  #
>> cloud-hypervisor assigns 0 - 0x8000000 for a BootROM
>>> +Size          = $(FD_SIZE)|gArmTokenSpaceGuid.PcdFdSize         # The size in
>> bytes of the FLASH Device
>>> +ErasePolarity = 1
>>> +
>>> +# This one is tricky, it must be: BlockSize * NumBlocks = Size
>>> +BlockSize     = 0x00001000
>>> +NumBlocks     = $(FD_NUM_BLOCKS)
>>> +
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +#
>>> +# Following are lists of FD Region layout which correspond to the
>>> +locations of different # images within the flash device.
>>> +#
>>> +# Regions must be defined in ascending order and may not overlap.
>>> +#
>>> +# A Layout Region start with a eight digit hex offset (leading "0x"
>>> +required) followed by # the pipe "|" character, followed by the size
>>> +of the region, also in hex with the leading # "0x" characters. Like:
>>> +# Offset|Size
>>> +# PcdOffsetCName|PcdSizeCName
>>> +# RegionType <FV, DATA, or FILE>
>>> +#
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +
>>> +#
>>> +# UEFI has trouble dealing with FVs that reside at physical address 0x0.
>>> +# So instead, put a hardcoded 'jump to 0x1000' at offset 0x0, and put
>>> +the # real FV at offset 0x1000 #
>>> +0x00000000|0x00001000
>>> +DATA = {
>>> +!if $(ARCH) == AARCH64
>>> +  0x00, 0x04, 0x00, 0x14   # 'b 0x1000' in AArch64 ASM
>>> +!else
>>> +  0xfe, 0x03, 0x00, 0xea   # 'b 0x1000' in AArch32 ASM
>>> +!endif
>>> +}
>>> +
>>> +0x00001000|$(FVMAIN_COMPACT_SIZE)
>>>
>> +gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
>>> +FV = FVMAIN_COMPACT
>>> +
>>> +!include VarStore.fdf.inc
>>> +
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +#
>>> +# FV Section
>>> +#
>>> +# [FV] section is used to define what components or modules are
>>> +placed within a flash # device file.  This section also defines order
>>> +the components and modules are positioned # within the image.  The
>>> +[FV] section consists of define statements, set statements and # module
>> statements.
>>> +#
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +
>>> +#!include ArmVirtCloudHvFvMain.fdf.inc
>>> +
>>> +
>>> +
>>> +[FV.FvMain]
>>> +FvNameGuid         = 2A88A00E-E267-C8BF-0E80-AE1BD504ED90
>>> +BlockSize          = 0x40
>>> +NumBlocks          = 0         # This FV gets compressed so make it just big
>> enough
>>> +FvAlignment        = 16        # FV alignment and FV attributes setting.
>>> +ERASE_POLARITY     = 1
>>> +MEMORY_MAPPED      = TRUE
>>> +STICKY_WRITE       = TRUE
>>> +LOCK_CAP           = TRUE
>>> +LOCK_STATUS        = TRUE
>>> +WRITE_DISABLED_CAP = TRUE
>>> +WRITE_ENABLED_CAP  = TRUE
>>> +WRITE_STATUS       = TRUE
>>> +WRITE_LOCK_CAP     = TRUE
>>> +WRITE_LOCK_STATUS  = TRUE
>>> +READ_DISABLED_CAP  = TRUE
>>> +READ_ENABLED_CAP   = TRUE
>>> +READ_STATUS        = TRUE
>>> +READ_LOCK_CAP      = TRUE
>>> +READ_LOCK_STATUS   = TRUE
>>> +
>>> +  INF MdeModulePkg/Core/Dxe/DxeMain.inf  INF
>>> + MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
>>> +  INF ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf
>>> +  INF ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf
>>> +  INF ArmVirtPkg/HighMemDxe/HighMemDxe.inf
>>> +
>>> +  #
>>> +  # PI DXE Drivers producing Architectural Protocols (EFI Services)
>>> +  #
>>> +  INF ArmPkg/Drivers/CpuDxe/CpuDxe.inf
>>> +  INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
>>> +  INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
>>> +  INF
>> MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
>>> +  INF
>>>
>> +MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.i
>> n
>>> +f
>>> +  INF
>>>
>> +MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
>>> +!if $(SECURE_BOOT_ENABLE) == TRUE
>>> +  INF
>>>
>> +SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConf
>> i
>>> +gDxe.inf
>>> +!endif
>>> +  INF
>>>
>> +MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCou
>> nterRun
>>> +timeDxe.inf
>>> +  INF
>>>
>> +MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntime
>> Dxe.in
>>> +f
>>> +  INF
>> EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
>>> +  INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
>>> +  INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
>>> +
>>> +  #
>>> +  # Multiple Console IO support
>>> +  #
>>> +  INF
>>> +
>> MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
>>> +  INF
>>> + MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
>>> +  INF
>>> +
>> MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
>> xe
>>> + .inf  INF
>> MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
>>> +  INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
>>> +
>>> +  INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
>>> +  INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
>>> +  INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
>>> +
>>> +  #
>>> +  # FAT filesystem + GPT/MBR partitioning + UDF filesystem +
>>> + virtio-fs  #  INF
>>> + MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
>>> +  INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
>>> +  INF FatPkg/EnhancedFatDxe/Fat.inf
>>> +  INF
>>> +
>> MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.i
>>> + nf  INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
>>> +  INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf
>>> +
>>> +  #
>>> +  # Status Code Routing
>>> +  #
>>> +  INF
>>> +
>> MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportSt
>> atu
>>> + sCodeRouterRuntimeDxe.inf
>>> +
>>> +  #
>>> +  # Platform Driver
>>> +  #
>>> +  INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
>>> +  INF OvmfPkg/VirtioNetDxe/VirtioNet.inf
>>> +  INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
>>> +  INF OvmfPkg/VirtioRngDxe/VirtioRng.inf
>>> +
>>> +  #
>>> +  # UEFI application (Shell Embedded Boot Loader)  #  INF
>>> + ShellPkg/Application/Shell/Shell.inf
>>> +  INF
>>> +
>> ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.
>> inf
>>> +  INF
>>> +
>> ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand
>> .inf
>>> +  INF
>>> +
>> OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellComma
>> n
>>> + d.inf
>>> +
>>> +  #
>>> +  # Bds
>>> +  #
>>> +  INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
>>> +  INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
>>> +  INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
>>> +  INF
>>> +
>> MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManager
>> Dxe
>>> + .inf  INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
>>> +  INF MdeModulePkg/Application/UiApp/UiApp.inf
>>> +  INF OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
>> [SAMI] Qemu-FwCfg dependency? Also check at other places in the fdf and
>> fdf.inc file.
> Yeah, it's a tough work for me.
>
>>> +
>>> +  #
>>> +  # SCSI Bus and Disk Driver
>>> +  #
>>> +  INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
>>> +  INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
>>> +
>>> +  #
>>> +  # ACPI Support
>>> +  #
>>> +  INF
>> ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.inf
>>> +!if $(ARCH) == AARCH64
>>> +  INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
>>> +  INF
>>>
>> +MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGrap
>> hics
>>> +ResourceTableDxe.inf
>>> +  INF ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpiPlatformDxe.inf
>>> +
>>> +  #
>>> +  # EBC support
>>> +  #
>>> +  INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
>>> +!endif
>>> +
>>> +  #
>>> +  # PCI support
>>> +  #
>>> +  INF ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf
>>> +  INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
>>> +  INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
>>> +  INF OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
>>> +  INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
>>> +  INF OvmfPkg/Virtio10Dxe/Virtio10.inf
>>> +
>>> +  #
>>> +  # TPM2 support
>>> +  #
>>> +!if $(TPM2_ENABLE) == TRUE
>>> +  INF SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
>>> +!if $(TPM2_CONFIG_ENABLE) == TRUE
>>> +  INF SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
>>> +!endif
>>> +!endif
>>> +
>>> +  #
>>> +  # TianoCore logo (splash screen)
>>> +  #
>>> +  INF MdeModulePkg/Logo/LogoDxe.inf
>>> +
>>> +  #
>>> +  # Ramdisk support
>>> +  #
>>> +  INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
>>> +
>>> +
>>> +
>>> +
>>> +
>>> +
>>> +
>>> +
>>> +
>>> +
>>> +
>>> +
>> [SAMI] Remove empty lines.
> Oh, it's my bad.
>
> Thanks
> Jianyong
>
>>> +[FV.FVMAIN_COMPACT]
>>> +FvAlignment        = 16
>>> +ERASE_POLARITY     = 1
>>> +MEMORY_MAPPED      = TRUE
>>> +STICKY_WRITE       = TRUE
>>> +LOCK_CAP           = TRUE
>>> +LOCK_STATUS        = TRUE
>>> +WRITE_DISABLED_CAP = TRUE
>>> +WRITE_ENABLED_CAP  = TRUE
>>> +WRITE_STATUS       = TRUE
>>> +WRITE_LOCK_CAP     = TRUE
>>> +WRITE_LOCK_STATUS  = TRUE
>>> +READ_DISABLED_CAP  = TRUE
>>> +READ_ENABLED_CAP   = TRUE
>>> +READ_STATUS        = TRUE
>>> +READ_LOCK_CAP      = TRUE
>>> +READ_LOCK_STATUS   = TRUE
>>> +
>>> +  INF ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf
>>> +  INF MdeModulePkg/Core/Pei/PeiMain.inf  INF
>>> + ArmPlatformPkg/PlatformPei/PlatformPeim.inf
>>> +  INF ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf
>>> +  INF ArmPkg/Drivers/CpuPei/CpuPei.inf  INF
>>> + MdeModulePkg/Universal/PCD/Pei/Pcd.inf
>>> +  INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
>>> +  INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
>>> +
>>> +!if $(TPM2_ENABLE) == TRUE
>>> +  INF MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>>> +  INF OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
>>> +  INF SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
>>> +!endif
>>> +
>>> +  FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
>>> +    SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF
>> PROCESSING_REQUIRED = TRUE {
>>> +      SECTION FV_IMAGE = FVMAIN
>>> +    }
>>> +  }
>>> +
>>> +!include ArmVirtRules.fdf.inc
>>> diff --git a/ArmVirtPkg/ArmVirtCloudHvFvMain.fdf.inc
>>> b/ArmVirtPkg/ArmVirtCloudHvFvMain.fdf.inc
>>> new file mode 100644
>>> index 000000000000..51041e889ef4
>>> --- /dev/null
>>> +++ b/ArmVirtPkg/ArmVirtCloudHvFvMain.fdf.inc
>>> @@ -0,0 +1,169 @@
>>> +#
>>> +#  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
>>> +#  Copyright (c) 2014-2016, Linaro Limited. All rights reserved.
>>> +#  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
>>> +#
>>> +#  SPDX-License-Identifier: BSD-2-Clause-Patent #
>>> +
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +#
>>> +# FV Section
>>> +#
>>> +# [FV] section is used to define what components or modules are
>>> +placed within a flash # device file.  This section also defines order
>>> +the components and modules are positioned # within the image.  The
>>> +[FV] section consists of define statements, set statements and # module
>> statements.
>>> +#
>>>
>> +#########################################################
>> ############
>>> +###########
>>> +
>>> +[FV.FvMain]
>>> +FvNameGuid         = 2A88A00E-E267-C8BF-0E80-AE1BD504ED90
>>> +BlockSize          = 0x40
>>> +NumBlocks          = 0         # This FV gets compressed so make it just big
>> enough
>>> +FvAlignment        = 16        # FV alignment and FV attributes setting.
>>> +ERASE_POLARITY     = 1
>>> +MEMORY_MAPPED      = TRUE
>>> +STICKY_WRITE       = TRUE
>>> +LOCK_CAP           = TRUE
>>> +LOCK_STATUS        = TRUE
>>> +WRITE_DISABLED_CAP = TRUE
>>> +WRITE_ENABLED_CAP  = TRUE
>>> +WRITE_STATUS       = TRUE
>>> +WRITE_LOCK_CAP     = TRUE
>>> +WRITE_LOCK_STATUS  = TRUE
>>> +READ_DISABLED_CAP  = TRUE
>>> +READ_ENABLED_CAP   = TRUE
>>> +READ_STATUS        = TRUE
>>> +READ_LOCK_CAP      = TRUE
>>> +READ_LOCK_STATUS   = TRUE
>>> +
>>> +  INF MdeModulePkg/Core/Dxe/DxeMain.inf  INF
>>> + MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
>>> +  INF ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf
>>> +  INF ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf
>>> +  INF ArmVirtPkg/HighMemDxe/HighMemDxe.inf
>>> +
>>> +  #
>>> +  # PI DXE Drivers producing Architectural Protocols (EFI Services)
>>> +  #
>>> +  INF ArmPkg/Drivers/CpuDxe/CpuDxe.inf
>>> +  INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
>>> +  INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
>>> +  INF
>> MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
>>> +  INF
>>>
>> +MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.i
>> n
>>> +f
>>> +  INF
>>>
>> +MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
>>> +!if $(SECURE_BOOT_ENABLE) == TRUE
>>> +  INF
>>>
>> +SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConf
>> i
>>> +gDxe.inf
>>> +!endif
>>> +  INF
>>>
>> +MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCou
>> nterRun
>>> +timeDxe.inf
>>> +  INF
>>>
>> +MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntime
>> Dxe.in
>>> +f
>>> +  INF
>> EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
>>> +  INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
>>> +  INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
>>> +
>>> +  #
>>> +  # Multiple Console IO support
>>> +  #
>>> +  INF
>>> +
>> MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
>>> +  INF
>>> + MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
>>> +  INF
>>> +
>> MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
>> xe
>>> + .inf  INF
>> MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
>>> +  INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
>>> +
>>> +  INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
>>> +  INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
>>> +  INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
>>> +
>>> +  #
>>> +  # FAT filesystem + GPT/MBR partitioning + UDF filesystem +
>>> + virtio-fs  #  INF
>>> + MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
>>> +  INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
>>> +  INF FatPkg/EnhancedFatDxe/Fat.inf
>>> +  INF
>>> +
>> MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.i
>>> + nf  INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
>>> +  INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf
>>> +
>>> +  #
>>> +  # Status Code Routing
>>> +  #
>>> +  INF
>>> +
>> MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportSt
>> atu
>>> + sCodeRouterRuntimeDxe.inf
>>> +
>>> +  #
>>> +  # Platform Driver
>>> +  #
>>> +  INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
>>> +  INF OvmfPkg/VirtioNetDxe/VirtioNet.inf
>>> +  INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
>>> +  INF OvmfPkg/VirtioRngDxe/VirtioRng.inf
>>> +
>>> +  #
>>> +  # UEFI application (Shell Embedded Boot Loader)  #  INF
>>> + ShellPkg/Application/Shell/Shell.inf
>>> +  INF
>>> +
>> ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.
>> inf
>>> +  INF
>>> +
>> ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand
>> .inf
>>> +  INF
>>> +
>> OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellComma
>> n
>>> + d.inf
>>> +
>>> +  #
>>> +  # Bds
>>> +  #
>>> +  INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
>>> +  INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
>>> +  INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
>>> +  INF
>>> +
>> MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManager
>> Dxe
>>> + .inf  INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
>>> +  INF MdeModulePkg/Application/UiApp/UiApp.inf
>>> +  INF OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
>>> +
>>> +  #
>>> +  # SCSI Bus and Disk Driver
>>> +  #
>>> +  INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
>>> +  INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
>>> +
>>> +  #
>>> +  # ACPI Support
>>> +  #
>>> +  INF
>> ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.inf
>>> +!if $(ARCH) == AARCH64
>>> +  INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
>>> +  INF
>>>
>> +MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGrap
>> hics
>>> +ResourceTableDxe.inf
>>> +  INF ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpiPlatformDxe.inf
>>> +
>>> +  #
>>> +  # EBC support
>>> +  #
>>> +  INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
>>> +!endif
>>> +
>>> +  #
>>> +  # PCI support
>>> +  #
>>> +  INF ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf
>>> +  INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
>>> +  INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
>>> +  INF OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
>>> +  INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
>>> +  INF OvmfPkg/Virtio10Dxe/Virtio10.inf
>>> +
>>> +  #
>>> +  # TPM2 support
>>> +  #
>>> +!if $(TPM2_ENABLE) == TRUE
>>> +  INF SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
>>> +!if $(TPM2_CONFIG_ENABLE) == TRUE
>>> +  INF SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
>>> +!endif
>>> +!endif
>>> +
>>> +  #
>>> +  # TianoCore logo (splash screen)
>>> +  #
>>> +  INF MdeModulePkg/Logo/LogoDxe.inf
>>> +
>>> +  #
>>> +  # Ramdisk support
>>> +  #
>>> +  INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf


[-- Attachment #2: 0001-ArmVirtPkg-Add-PCI-host-bridge-utility-lib-for-Kvmto.patch --]
[-- Type: text/plain, Size: 10091 bytes --]

From cc33217ae783ba88ab64672774d90a998cd5cea4 Mon Sep 17 00:00:00 2001
From: Sami Mujawar <sami.mujawar@arm.com>
Date: Tue, 20 Apr 2021 13:59:06 +0100
Subject: [PATCH 1/1] ArmVirtPkg: Add PCI host bridge utility lib for Kvmtool

The PCI host bridge utility lib is used to retrieve information
about the Root Bridges in a platform.
Therefore, add an instance of PciHostBridgeUtilityLib as this is
required to enable PCI support for Kvmtool firmware.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
 .../KvmtoolPciHostBridgeUtilityLib.c               | 220 +++++++++++++++++++++
 .../KvmtoolPciHostBridgeUtilityLib.inf             |  39 ++++
 2 files changed, 259 insertions(+)
 create mode 100644 ArmVirtPkg/Library/KvmtoolPciHostBridgeUtilityLib/KvmtoolPciHostBridgeUtilityLib.c
 create mode 100644 ArmVirtPkg/Library/KvmtoolPciHostBridgeUtilityLib/KvmtoolPciHostBridgeUtilityLib.inf

diff --git a/ArmVirtPkg/Library/KvmtoolPciHostBridgeUtilityLib/KvmtoolPciHostBridgeUtilityLib.c b/ArmVirtPkg/Library/KvmtoolPciHostBridgeUtilityLib/KvmtoolPciHostBridgeUtilityLib.c
new file mode 100644
index 000000000000..ee3af07340fc
--- /dev/null
+++ b/ArmVirtPkg/Library/KvmtoolPciHostBridgeUtilityLib/KvmtoolPciHostBridgeUtilityLib.c
@@ -0,0 +1,220 @@
+/** @file
+  PCI Host Bridge utility functions for Kvmtool.
+
+  Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <IndustryStandard/Acpi10.h>
+#include <IndustryStandard/Pci.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PciHostBridgeLib.h>
+#include <Library/PciHostBridgeUtilityLib.h>
+#include <Library/PciLib.h>
+
+#pragma pack(1)
+
+/** A structure describing the ACPI and EFI device path for
+    the PCI Root Bridge device.
+**/
+typedef struct {
+  ACPI_HID_DEVICE_PATH     AcpiDevicePath;
+  EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;
+
+#pragma pack ()
+
+/** An array of strings describing the ACPI address space type.
+**/
+GLOBAL_REMOVE_IF_UNREFERENCED
+STATIC CONST CHAR16 *mPciHostBridgeAcpiAddressSpaceTypeStr[] = {
+  L"Mem",
+  L"I/O",
+  L"Bus"
+};
+
+STATIC CONST EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath = {
+  {
+    // ACPI device path.
+    {
+      ACPI_DEVICE_PATH,
+      ACPI_DP,
+      {
+        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)),
+        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
+      }
+    },
+    EISA_PNP_ID (0x0A03), // HID
+    0                     // UID
+  },
+
+  // End device path.
+  {
+    END_DEVICE_PATH_TYPE,
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,
+    {
+      END_DEVICE_PATH_LENGTH,
+      0
+    }
+  }
+};
+
+STATIC PCI_ROOT_BRIDGE mRootBridge;
+
+/**
+  Utility function to return all the root bridge instances in an array.
+
+  @param [out] Count                  The number of root bridge instances.
+  @param [in]  Attributes             Initial attributes.
+  @param [in]  AllocAttributes        Allocation attributes.
+  @param [in]  DmaAbove4G             DMA above 4GB memory.
+  @param [in]  NoExtendedConfigSpace  No Extended Config Space.
+  @param [in]  BusMin                 Minimum Bus number, inclusive.
+  @param [in]  BusMax                 Maximum Bus number, inclusive.
+  @param [in]  Io                     IO aperture.
+  @param [in]  Mem                    MMIO aperture.
+  @param [in]  MemAbove4G             MMIO aperture above 4G.
+  @param [in]  PMem                   Prefetchable MMIO aperture.
+  @param [in]  PMemAbove4G            Prefetchable MMIO aperture above 4G.
+
+  @return                            All the root bridge instances in an array.
+**/
+PCI_ROOT_BRIDGE *
+EFIAPI
+PciHostBridgeUtilityGetRootBridges (
+  OUT UINTN                    *Count,
+  IN  UINT64                   Attributes,
+  IN  UINT64                   AllocationAttributes,
+  IN  BOOLEAN                  DmaAbove4G,
+  IN  BOOLEAN                  NoExtendedConfigSpace,
+  IN  UINTN                    BusMin,
+  IN  UINTN                    BusMax,
+  IN  PCI_ROOT_BRIDGE_APERTURE *Io,
+  IN  PCI_ROOT_BRIDGE_APERTURE *Mem,
+  IN  PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,
+  IN  PCI_ROOT_BRIDGE_APERTURE *PMem,
+  IN  PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G
+  )
+{
+  if ((Count == NULL)       ||
+      (Io == NULL)          ||
+      (Mem == NULL)         ||
+      (MemAbove4G == NULL)  ||
+      (PMem == NULL)        ||
+      (PMemAbove4G == NULL)) {
+    return NULL;
+  }
+
+  *Count = 1;
+
+  mRootBridge.Segment               = 0;
+  mRootBridge.Supports              = Attributes;
+  mRootBridge.Attributes            = Attributes;
+
+  mRootBridge.DmaAbove4G            = DmaAbove4G;
+  mRootBridge.NoExtendedConfigSpace = NoExtendedConfigSpace;
+  mRootBridge.ResourceAssigned      = FALSE;
+
+  mRootBridge.AllocationAttributes  = AllocationAttributes;
+
+  mRootBridge.Bus.Base              = BusMin;
+  mRootBridge.Bus.Limit             = BusMax;
+  mRootBridge.Io.Base               = Io->Base;
+  mRootBridge.Io.Limit              = Io->Limit;
+  mRootBridge.Mem.Base              = Mem->Base;
+  mRootBridge.Mem.Limit             = Mem->Limit;
+  mRootBridge.MemAbove4G.Base       = MemAbove4G->Base;
+  mRootBridge.MemAbove4G.Limit      = MemAbove4G->Limit;
+  mRootBridge.PMem.Base             = PMem->Base;
+  mRootBridge.PMem.Limit            = PMem->Limit;
+  mRootBridge.PMemAbove4G.Base      = PMemAbove4G->Base;
+  mRootBridge.PMemAbove4G.Limit     = PMemAbove4G->Limit;
+
+  mRootBridge.DevicePath =
+    (EFI_DEVICE_PATH_PROTOCOL*)&mEfiPciRootBridgeDevicePath;
+
+  return &mRootBridge;
+}
+
+/**
+  Utility function to free root bridge instances array from
+  PciHostBridgeUtilityGetRootBridges().
+
+  @param[in] Bridges  The root bridge instances array.
+  @param[in] Count    The count of the array.
+**/
+VOID
+EFIAPI
+PciHostBridgeUtilityFreeRootBridges (
+  IN PCI_ROOT_BRIDGE *Bridges,
+  IN UINTN           Count
+  )
+{
+  // Nothing to do here.
+}
+
+/**
+  Utility function to inform the platform that the resource conflict happens.
+
+  @param[in] Configuration  Pointer to PCI I/O and PCI memory resource
+                            descriptors. The Configuration contains the
+                            resources for all the root bridges. The resource
+                            for each root bridge is terminated with END
+                            descriptor and an additional END is appended
+                            indicating the end of the entire resources. The
+                            resource descriptor field values follow the
+                            description in
+                            EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
+                            .SubmitResources().
+**/
+VOID
+EFIAPI
+PciHostBridgeUtilityResourceConflict (
+  IN VOID  *Configuration
+  )
+{
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
+  UINTN                             RootBridgeIndex;
+  DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n"));
+
+  RootBridgeIndex = 0;
+  Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR*)Configuration;
+  while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
+    DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
+    for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
+      ASSERT (Descriptor->ResType <
+              ARRAY_SIZE (mPciHostBridgeAcpiAddressSpaceTypeStr)
+              );
+      DEBUG ((
+        DEBUG_ERROR,
+        " %s: Length/Alignment = 0x%lx / 0x%lx\n",
+        mPciHostBridgeAcpiAddressSpaceTypeStr[Descriptor->ResType],
+        Descriptor->AddrLen,
+        Descriptor->AddrRangeMax
+        ));
+      if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
+        DEBUG ((
+          DEBUG_ERROR,
+          "     Granularity/SpecificFlag = %ld / %02x%s\n",
+          Descriptor->AddrSpaceGranularity,
+          Descriptor->SpecificFlag,
+          ((Descriptor->SpecificFlag &
+            EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
+            ) != 0) ? L" (Prefetchable)" : L""
+          ));
+      }
+    }
+    //
+    // Skip the END descriptor for root bridge
+    //
+    ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);
+    Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR*)(
+                   (EFI_ACPI_END_TAG_DESCRIPTOR*)Descriptor + 1
+                   );
+  }
+}
diff --git a/ArmVirtPkg/Library/KvmtoolPciHostBridgeUtilityLib/KvmtoolPciHostBridgeUtilityLib.inf b/ArmVirtPkg/Library/KvmtoolPciHostBridgeUtilityLib/KvmtoolPciHostBridgeUtilityLib.inf
new file mode 100644
index 000000000000..0e03fd6af8f0
--- /dev/null
+++ b/ArmVirtPkg/Library/KvmtoolPciHostBridgeUtilityLib/KvmtoolPciHostBridgeUtilityLib.inf
@@ -0,0 +1,39 @@
+## @file
+#  PciHostBridgeLib utility functions for Kvmtool.
+#
+#  Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = KvmtoolPciHostBridgeUtilityLib
+  FILE_GUID                      = 22A8844E-2AE7-4BF1-91FA-6EFDE3FE540C
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = PciHostBridgeUtilityLib
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+#  VALID_ARCHITECTURES           = AARCH64 ARM
+#
+
+[Sources]
+  KvmtoolPciHostBridgeUtilityLib.c
+
+[Packages]
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+  BaseMemoryLib
+  DebugLib
+  DevicePathLib
+  MemoryAllocationLib
+  PciLib
-- 
SAMI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}


  reply	other threads:[~2021-05-29  7:44 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  6:50 [PATCH v2 0/5] Enable Cloud Hypervisor support in edk2 Jianyong Wu
2021-05-17  6:50 ` [PATCH v2 1/5] ArmVirtPkg: Library: Memory initialization for Cloud Hypervisor Jianyong Wu
2021-05-18 20:20   ` Sami Mujawar
2021-05-27  2:18     ` Jianyong Wu
2021-05-19  6:07   ` [edk2-devel] " Laszlo Ersek
2021-05-19  6:11     ` Laszlo Ersek
2021-05-27  6:39       ` Jianyong Wu
2021-05-17  6:50 ` [PATCH v2 2/5] MdeMoudlePkg: introduce new PCD for Acpi/rsdp Jianyong Wu
2021-05-18 20:25   ` Sami Mujawar
2021-05-27  2:31     ` Jianyong Wu
2021-05-19  6:17   ` [edk2-devel] " Laszlo Ersek
2021-05-27  2:42     ` Jianyong Wu
2021-05-17  6:50 ` [PATCH v2 3/5] ArmVirtPkg: enable ACPI for cloud hypervisor Jianyong Wu
2021-05-18 20:26   ` Sami Mujawar
2021-05-27  2:57     ` Jianyong Wu
2021-05-19  6:25   ` [edk2-devel] " Laszlo Ersek
2021-05-27  3:18     ` Jianyong Wu
2021-05-17  6:50 ` [PATCH v2 4/5] ArmVirtPkg: Introduce Cloud Hypervisor to edk2 family Jianyong Wu
2021-05-18 20:26   ` Sami Mujawar
2021-05-27  6:19     ` Jianyong Wu
2021-05-29  7:43       ` Sami Mujawar [this message]
2021-06-01  7:51         ` Jianyong Wu
2021-05-19  6:36   ` [edk2-devel] " Laszlo Ersek
2021-05-27  6:23     ` Jianyong Wu
2021-05-17  6:50 ` [PATCH v2 5/5] Maintainers: update Maintainers file as new files/folders created Jianyong Wu
2021-05-18 20:26   ` Sami Mujawar
2021-05-19  6:55     ` Laszlo Ersek
2021-05-27  6:28       ` Jianyong Wu
2021-05-19  6:39   ` [edk2-devel] " Laszlo Ersek
2021-05-18 17:46 ` [edk2-devel] [PATCH v2 0/5] Enable Cloud Hypervisor support in edk2 Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31935dd3-3028-b236-56e8-e05813d9a205@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox