Skip to contentSkip to conversation

Specific platform to run OVMF in Xen PVH and HVM guests

PATCH Superseded Anthony PERARD 3 participants 36 messages Apr 8, 2019 – Apr 9, 2019

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Specific platform to run OVMF in Xen PVH and HVM guests

Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/ovmf.git br.platform-xen-pvh-v2

Hi,

I've started to create a Xen specific platform, in OvmfPkg/XenOvmf.dsc with the goal to make it work on both Xen HVM and Xen PVH.

The first few patches only create the platform and duplicate some code from OvmfPkg and the later patches makes OVMF boot in a Xen PVH guest and can boot a Linux guest.

After this patch series, I'd like to wait a bit before removing Xen support from the OvmfPkg*.dsc, to allow time to switch to the new Xen only platform, maybe 1 year.

Question:

Should we start moving these to a different *Pkg? Like it's done for ArmPkg and ArmVirtPkg? Maybe XenPkg.

To build and boot:

To build, simply run OvmfPkg/build.sh -p OvmfPkg/XenOvmf.dsc Then use OVMF.fd as a kernel of a pvh guest config file (with xl/libxl).

Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/ovmf.git br.platform-xen-pvh-v2

Anthony PERARD (31):
OvmfPkg/ResetSystemLib: Add missing dependency on PciLib
OvmfPkg: Create platform XenOvmf
OvmfPkg: Introduce XenResetVector
OvmfPkg: Introduce XenPlatformPei
OvmfPkg/XenOvmf: Creating an ELF header OvmfPkg/XenResetVector: Add new entry point for Xen PVH OvmfPkg/XenResetVector: Saving start of day pointer for PVH guests OvmfPkg/XenResetVector: Allow to jumpstart from either hvmloader or
PVH
OvmfPkg/XenOvmf: use a TimerLib instance that depends only on the CPU OvmfPkg/XenPlatformPei: Detect OVMF_INFO from hvmloader OvmfPkg/XenPlatformPei: Use mXenHvmloaderInfo to get E820 OvmfPkg/XenPlatformPei: Grab RSDP from PVH guest start of day struct OvmfPkg/Library/XenPlatformLib: New library OvmfPkg/AcpiPlatformDxe: Use PVH RSDP if exist OvmfPkg/XenHypercallLib: Enable it in PEIM OvmfPkg/XenPlatformPei: Introduce XenHvmloaderDetected OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it as
runned
OvmfPkg/XenPlatformPei: Setup HyperPages earlier OvmfPkg/XenPlatformPei: Introduce XenPvhDetected
OvmfPkg: Import XENMEM_memory_map hypercall to Xen/memory.h OvmfPkg/XenPlatformPei: Get E820 table via hypercall ... OvmfPkg/XenPlatformPei: Rework memory detection OvmfPkg/XenPlatformPei: Reserve VGA memory region, to boot Linux OvmfPkg/XenPlatformPei: Ignore missing PCI Host Bridge on Xen PVH OvmfPkg/PlatformBootManagerLib: Handle the absence of PCI bus on Xen
PVH
OvmfPkg/XenOvmf: Override PcdFSBClock to Xen vLAPIC timer frequency OvmfPkg/XenOvmf: Introduce XenTimerDxe OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn
OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables
OvmfPkg: Move XenRealTimeClockLib from ArmVirtPkg OvmfPkg/XenOvmf: use RealTimeClockRuntimeDxe from EmbeddedPkg

 OvmfPkg/OvmfPkg.dec                                                                                                 |   4 +
 ArmVirtPkg/ArmVirtXen.dsc                                                                                           |   2 +-
 OvmfPkg/OvmfPkgIa32.dsc                                                                                             |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                                                                                          |   1 +
 OvmfPkg/OvmfPkgX64.dsc                                                                                              |   1 +
 OvmfPkg/{OvmfPkgX64.dsc => XenOvmf.dsc}                                                                             | 236 ++------
 OvmfPkg/XenOvmf.fdf                                                                                                 | 561 ++++++++++++++++++++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf                                                                         |   2 +-
 OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf                                                   |   4 +
 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf                                                                   |   1 +
 OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf                                                                 |   2 +-
 ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf => OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf |  30 +-
 {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf                                         |   0
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf                                                                                 |  35 ++
 OvmfPkg/XenPlatformPei/XenPlatformPei.inf                                                                           | 107 ++++
 OvmfPkg/XenResetVector/XenResetVector.inf                                                                           |  46 ++
 OvmfPkg/XenTimerDxe/XenTimerDxe.inf                                                                                 |  49 ++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h                                                                              |   6 +-
 OvmfPkg/Include/Guid/XenInfo.h                                                                                      |   8 +-
 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/hvm/start_info.h                                                      | 159 ++++++
 OvmfPkg/Include/IndustryStandard/Xen/memory.h                                                                       |  23 +
 OvmfPkg/Include/Library/XenHypercallLib.h                                                                           |  12 +
 OvmfPkg/Include/Library/XenPlatformLib.h                                                                            |  59 ++
 OvmfPkg/Include/OvmfPlatforms.h                                                                                     |   6 +
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h                                                                |   1 +
 OvmfPkg/XenPlatformPei/Cmos.h                                                                                       |  58 ++
 OvmfPkg/XenPlatformPei/Platform.h                                                                                   | 135 +++++
 OvmfPkg/{PlatformPei => XenPlatformPei}/Xen.h                                                                       |   0
 OvmfPkg/XenTimerDxe/XenTimerDxe.h                                                                                   | 183 +++++++
 OvmfPkg/AcpiPlatformDxe/Xen.c                                                                                       |  41 +-
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                                                                |  15 +-
 OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c                                                               |  59 ++
 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c                                                                     |   3 +-
 OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c                                                                   |  11 +
 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c                                                                     |  75 +++
 {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.c                                           |   0
 OvmfPkg/PlatformPei/Xen.c                                                                                           |   3 -
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c                                                                                   |  38 ++
 OvmfPkg/XenPlatformPei/AmdSev.c                                                                                     |  70 +++
 OvmfPkg/XenPlatformPei/ClearCache.c                                                                                 | 118 ++++
 OvmfPkg/XenPlatformPei/Cmos.c                                                                                       |  66 +++
 OvmfPkg/XenPlatformPei/Fv.c                                                                                         |  82 +++
 OvmfPkg/XenPlatformPei/MemDetect.c                                                                                  | 498 +++++++++++++++++
 OvmfPkg/XenPlatformPei/Platform.c                                                                                   | 458 ++++++++++++++++
 OvmfPkg/XenPlatformPei/Xen.c                                                                                        | 381 +++++++++++++
 OvmfPkg/XenTimerDxe/XenTimerDxe.c                                                                                   | 361 +++++++++++++
 generate_elf_header.c                                                                                               |  78 +++
 OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm                                                                      | 144 +++++
 OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm                                                                     |  87 +++
 OvmfPkg/XenResetVector/Ia32/Flat32ToFlat64.asm                                                                      |  66 +++
 OvmfPkg/XenResetVector/Ia32/PageTables64.asm                                                                        | 156 ++++++
 OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm                                                                    |  93 ++++
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm                                                                          |  75 +++
 OvmfPkg/XenResetVector/XenResetVector.nasmb                                                                         |  78 +++
 54 files changed, 4526 insertions(+), 262 deletions(-)
 copy OvmfPkg/{OvmfPkgX64.dsc => XenOvmf.dsc} (78%)
 create mode 100644 OvmfPkg/XenOvmf.fdf
 copy ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf => OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf (50%)
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf (100%)
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
 create mode 100644 OvmfPkg/XenPlatformPei/XenPlatformPei.inf
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.inf
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.inf
 create mode 100644 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/hvm/start_info.h
 create mode 100644 OvmfPkg/Include/Library/XenPlatformLib.h
 create mode 100644 OvmfPkg/XenPlatformPei/Cmos.h
 create mode 100644 OvmfPkg/XenPlatformPei/Platform.h
 copy OvmfPkg/{PlatformPei => XenPlatformPei}/Xen.h (100%)
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.h
 create mode 100644 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.c (100%)
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c
 create mode 100644 OvmfPkg/XenPlatformPei/AmdSev.c
 create mode 100644 OvmfPkg/XenPlatformPei/ClearCache.c
 create mode 100644 OvmfPkg/XenPlatformPei/Cmos.c
 create mode 100644 OvmfPkg/XenPlatformPei/Fv.c
 create mode 100644 OvmfPkg/XenPlatformPei/MemDetect.c
 create mode 100644 OvmfPkg/XenPlatformPei/Platform.c
 create mode 100644 OvmfPkg/XenPlatformPei/Xen.c
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.c
 create mode 100644 generate_elf_header.c
 create mode 100644 OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/Flat32ToFlat64.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/PageTables64.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.nasmb
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH v2 1/31 OvmfPkg/ResetSystemLib: Add missing dependency on PciLib

and remove extra includes of OvmfPlatforms.h.

Contributed-under: TianoCore Contribution Agreement 1.1

---

Notes:
v2:
- also add PciLib.h include to the .c
- and remove extra include of OvmfPlatforms.h

 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf | 1 +
 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c   | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)
OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf +1 -0
index 39ca805730..ebd722e66b 100644
@@ -36,4 +36,5 @@ [Packages]
 [LibraryClasses]
   DebugLib
   IoLib
+  PciLib
   TimerLib
OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c +1 -2
index cc75d046a8..9348502836 100644
@@ -17,11 +17,10 @@
 #include <Library/BaseLib.h>
 #include <Library/DebugLib.h>
 #include <Library/IoLib.h>
+#include <Library/PciLib.h>
 #include <Library/TimerLib.h>
 #include <OvmfPlatforms.h>
 
-#include <OvmfPlatforms.h>
-
 VOID
 AcpiPmControl (
   UINTN SuspendType
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw

PATCH v2 2/31 OvmfPkg: Create platform XenOvmf

In reply to Anthony PERARD

This is a copy of OvmfX64, removing VirtIO and some SMM.

This new platform will be changed to make it works on two types of Xen
guest: HVM and PVH.

Compare to OvmfX64, this patch:

- changed: PLATFORM_GUID, OUTPUT_DIRECTORY, FLASH_DEFINITION
- removed: VirtioLib class resolution
- removed: all UEFI_DRIVER modules for virtio devices
- removed: DXE_SMM_DRIVER and SMM_CORE lib class resolutions
- removed: DXE_SMM_DRIVER and SMM_CORE FDF rules
- removed: Everything related to SMM_REQUIRE==true
- removed: Everything related to SECURE_BOOT_ENABLE==true
- removed: Everything related to TPM2_ENABLE==true
- changed: PcdPciDisableBusEnumeration dynamic default flipped to TRUE
- changed: default FD_SIZE_IN_KB to 2M.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/{OvmfPkgX64.dsc => XenOvmf.dsc}     | 202 +-------------------
 OvmfPkg/{OvmfPkgIa32X64.fdf => XenOvmf.fdf} |  72 +------
 2 files changed, 12 insertions(+), 262 deletions(-)
OvmfPkg/XenOvmf.dsc renamed from OvmfPkg/OvmfPkgX64.dsc +8 -194
similarity index 79%
copy from OvmfPkg/OvmfPkgX64.dsc
copy to OvmfPkg/XenOvmf.dsc
index 2943e9e8af..bfe9190735 100644
@@ -3,6 +3,7 @@
 #
 #  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+#  Copyright (c) 2019, Citrix Systems, Inc.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -21,26 +22,22 @@
 ################################################################################
 [Defines]
   PLATFORM_NAME                  = Ovmf
-  PLATFORM_GUID                  = 5a9e7754-d81b-49ea-85ad-69eaa7b1539b
+  PLATFORM_GUID                  = e3aa4fbe-9459-482d-bd40-d3f3b5f89d6e
   PLATFORM_VERSION               = 0.1
   DSC_SPECIFICATION              = 0x00010005
-  OUTPUT_DIRECTORY               = Build/OvmfX64
+  OUTPUT_DIRECTORY               = Build/XenOvmf
   SUPPORTED_ARCHITECTURES        = X64
   BUILD_TARGETS                  = NOOPT|DEBUG|RELEASE
   SKUID_IDENTIFIER               = DEFAULT
-  FLASH_DEFINITION               = OvmfPkg/OvmfPkgX64.fdf
+  FLASH_DEFINITION               = OvmfPkg/XenOvmf.fdf
 
   #
   # Defines for default states.  These can be changed on the command line.
   # -D FLAG=VALUE
   #
-  DEFINE SECURE_BOOT_ENABLE      = FALSE
   DEFINE NETWORK_IP6_ENABLE      = FALSE
   DEFINE HTTP_BOOT_ENABLE        = FALSE
-  DEFINE SMM_REQUIRE             = FALSE
   DEFINE TLS_ENABLE              = FALSE
-  DEFINE TPM2_ENABLE             = FALSE
-  DEFINE TPM2_CONFIG_ENABLE      = FALSE
   DEFINE USE_LEGACY_ISA_STACK    = FALSE
 
   #
@@ -57,7 +54,7 @@ [Defines]
 !ifdef $(FD_SIZE_4MB)
   DEFINE FD_SIZE_IN_KB           = 4096
 !else
-  DEFINE FD_SIZE_IN_KB           = 4096
+  DEFINE FD_SIZE_IN_KB           = 2048
 !endif
 !endif
 !endif
@@ -157,12 +154,9 @@ [LibraryClasses]
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
   SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.inf
-  VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
   LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/BaseMemEncryptSevLib.inf
-!if $(SMM_REQUIRE) == FALSE
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
-!endif
   CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
   FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
 
@@ -185,14 +179,8 @@ [LibraryClasses]
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
 !endif
 
-!if $(SECURE_BOOT_ENABLE) == TRUE
-  PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
-  TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
-  AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
-!else
   TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
-!endif
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 
   TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf
@@ -211,13 +199,7 @@ [LibraryClasses]
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
   XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
 
-!if $(TPM2_ENABLE) == TRUE
-  Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
-  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
-  Tcg2PpVendorLib|SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
-!else
   Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
-!endif
 
 [LibraryClasses.common]
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
@@ -283,11 +265,6 @@ [LibraryClasses.common.PEIM]
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
 
-!if $(TPM2_ENABLE) == TRUE
-  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
-  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
-!endif
-
 [LibraryClasses.common.DXE_CORE]
   HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
@@ -357,20 +334,13 @@ [LibraryClasses.common.DXE_DRIVER]
   PlatformBmPrintScLib|OvmfPkg/Library/PlatformBmPrintScLib/PlatformBmPrintScLib.inf
   QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
   CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
-!if $(SMM_REQUIRE) == TRUE
-  LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf
-!else
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
-!endif
 !ifdef $(SOURCE_DEBUG_ENABLE)
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
-!if $(TPM2_ENABLE) == TRUE
-  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf
-!endif
 
 [LibraryClasses.common.UEFI_APPLICATION]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@@ -385,43 +355,6 @@ [LibraryClasses.common.UEFI_APPLICATION]
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
 
-[LibraryClasses.common.DXE_SMM_DRIVER]
-  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
-  MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
-  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
-  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
-  SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
-  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
-  SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
-!ifdef $(DEBUG_ON_SERIAL_PORT)
-  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
-!else
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
-!endif
-  CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
-!ifdef $(SOURCE_DEBUG_ENABLE)
-  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf
-!endif
-  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
-  PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
-
-[LibraryClasses.common.SMM_CORE]
-  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
-  SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf
-  MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf
-  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
-  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
-  SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
-  SmmServicesTableLib|MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.inf
-!ifdef $(DEBUG_ON_SERIAL_PORT)
-  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
-!else
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
-!endif
-  PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
-
 ################################################################################
 #
 # Pcd Section - list of all EDK II PCD Entries defined by this Platform.
@@ -436,10 +369,6 @@ [PcdsFeatureFlag]
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
-!if $(SMM_REQUIRE) == TRUE
-  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE
-!endif
 
 [PcdsFixedAtBuild]
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
@@ -516,10 +445,6 @@ [PcdsFixedAtBuild]
 
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }
 
-!if $(SMM_REQUIRE) == TRUE
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x4000
-!endif
-
   # IRQs 5, 9, 10, 11 are level-triggered
   gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel|0x0E20
 
@@ -533,14 +458,11 @@ [PcdsFixedAtBuild]
 ################################################################################
 
 [PcdsDynamicDefault]
-  # only set when
-  #   ($(SMM_REQUIRE) == FALSE)
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
-
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE
@@ -573,18 +495,8 @@ [PcdsDynamicDefault]
   # Set memory encryption mask
   gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0
 
-!if $(SMM_REQUIRE) == TRUE
-  gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|100000
-!endif
-
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00
 
-!if $(TPM2_ENABLE) == TRUE
-  gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-!endif
-
 ################################################################################
 #
 # Components Section - list of all EDK II Modules needed by this Platform.
@@ -620,32 +532,9 @@ [Components]
   MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
 
   OvmfPkg/PlatformPei/PlatformPei.inf
-  UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf {
-    <LibraryClasses>
-!if $(SMM_REQUIRE) == TRUE
-      LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf
-!endif
-  }
-!if $(SMM_REQUIRE) == TRUE
-  OvmfPkg/SmmAccess/SmmAccessPei.inf
-!endif
+  UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
   UefiCpuPkg/CpuMpPei/CpuMpPei.inf
 
-!if $(TPM2_ENABLE) == TRUE
-  OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
-  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf {
-    <LibraryClasses>
-      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
-      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
-      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
-      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
-      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
-  }
-!if $(TPM2_CONFIG_ENABLE) == TRUE
-  SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
-!endif
-!endif
-
   #
   # DXE Phase modules
   #
@@ -664,15 +553,7 @@ [Components]
 
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
 
-  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
-    <LibraryClasses>
-!if $(SECURE_BOOT_ENABLE) == TRUE
-      NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
-!endif
-!if $(TPM2_ENABLE) == TRUE
-      NULL|SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
-!endif
-  }
+  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
 
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
   PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf
@@ -712,11 +593,6 @@ [Components]
       NULL|IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf
 !endif
   }
-  OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
-  OvmfPkg/Virtio10Dxe/Virtio10.inf
-  OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
-  OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
-  OvmfPkg/VirtioRngDxe/VirtioRng.inf
   OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
   OvmfPkg/XenBusDxe/XenBusDxe.inf
   OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
@@ -755,7 +631,6 @@ [Components]
 
   OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
   OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf
-  OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
 
   #
   # ISA Support
@@ -824,7 +699,6 @@ [Components]
       NULL|OvmfPkg/Library/TlsAuthConfigLib/TlsAuthConfigLib.inf
   }
 !endif
-  OvmfPkg/VirtioNetDxe/VirtioNet.inf
 
   #
   # Usb Support
@@ -874,56 +748,10 @@ [Components]
       gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000
   }
 
-!if $(SECURE_BOOT_ENABLE) == TRUE
-  SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
-!endif
-
   OvmfPkg/PlatformDxe/Platform.inf
   OvmfPkg/AmdSevDxe/AmdSevDxe.inf
   OvmfPkg/IoMmuDxe/IoMmuDxe.inf
 
-!if $(SMM_REQUIRE) == TRUE
-  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
-  OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
-  UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
-
-  #
-  # SMM Initial Program Load (a DXE_RUNTIME_DRIVER)
-  #
-  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
-
-  #
-  # SMM_CORE
-  #
-  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
-
-  #
-  # Privileged drivers (DXE_SMM_DRIVER modules)
-  #
-  UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
-  MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf {
-    <LibraryClasses>
-      LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
-  }
-  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
-    <LibraryClasses>
-      SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
-      SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
-  }
-
-  #
-  # Variable driver stack (SMM)
-  #
-  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
-  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
-    <LibraryClasses>
-      NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
-  }
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
-
-!else
-
   #
   # Variable driver stack (non-SMM)
   #
@@ -937,17 +765,3 @@ [Components]
     <LibraryClasses>
       NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
   }
-!endif
-
-!if $(TPM2_ENABLE) == TRUE
-  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf {
-    <LibraryClasses>
-      Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf
-      NULL|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
-      HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
-      NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
-      NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
-      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
-      NULL|SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.inf
-  }
-!endif
OvmfPkg/XenOvmf.fdf renamed from OvmfPkg/OvmfPkgIa32X64.fdf +4 -68

141 lines not on this page · raw message

Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#3 lore raw

PATCH v2 3/31 OvmfPkg: Introduce XenResetVector

In reply to Anthony PERARD

Copy of OvmfPkg/ResetVector, with one changes:
- SEC_DEFAULT_CR0: enable cache (bit 30 or CD set to 0)

Xen copies the OVMF code to RAM, there is no need to disable cache.

This new module will later be modified to add a new entry point, more detail in a following commit "OvmfPkg/XenResetVector: Add new entry point for Xen PVH"

Value FILE_GUID of XenResetVector have not changed compare to ResetVector because it is a special value.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenOvmf.dsc                                                             | 2 +-
 OvmfPkg/XenOvmf.fdf                                                             | 2 +-
 OvmfPkg/{ResetVector/ResetVector.inf => XenResetVector/XenResetVector.inf}      | 5 +++--
 {UefiCpuPkg/ResetVector/Vtf0 => OvmfPkg/XenResetVector}/Ia16/Real16ToFlat32.asm | 4 +++-
 OvmfPkg/{ResetVector => XenResetVector}/Ia32/PageTables64.asm                   | 2 ++
 OvmfPkg/{ResetVector/ResetVector.nasmb => XenResetVector/XenResetVector.nasmb}  | 2 ++
 6 files changed, 12 insertions(+), 5 deletions(-)
OvmfPkg/XenOvmf.dsc +1 -1
index bfe9190735..6161133fa8 100644
@@ -503,7 +503,7 @@ [PcdsDynamicDefault]
 #
 ################################################################################
 [Components]
-  OvmfPkg/ResetVector/ResetVector.inf
+  OvmfPkg/XenResetVector/XenResetVector.inf
 
   #
   # SEC Phase modules
OvmfPkg/XenOvmf.fdf +1 -1
index 612ffb2e01..292cf4b492 100644
@@ -124,7 +124,7 @@ [FV.SECFV]
 #
 INF  OvmfPkg/Sec/SecMain.inf
 
-INF  RuleOverride=RESET_VECTOR OvmfPkg/ResetVector/ResetVector.inf
+INF  RuleOverride=RESET_VECTOR OvmfPkg/XenResetVector/XenResetVector.inf
 
 ################################################################################
 [FV.PEIFV]
OvmfPkg/XenResetVector/XenResetVector.inf renamed from OvmfPkg/ResetVector/ResetVector.inf +3 -2
similarity index 88%
copy from OvmfPkg/ResetVector/ResetVector.inf
copy to OvmfPkg/XenResetVector/XenResetVector.inf
index d1e5d4d9bd..5c05f02285 100644
@@ -2,6 +2,7 @@
 #  Reset Vector
 #
 #  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2019, Citrix Systems, Inc.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -14,7 +15,7 @@
 
 [Defines]
   INF_VERSION                    = 0x00010005
-  BASE_NAME                      = ResetVector
+  BASE_NAME                      = XenResetVector
   FILE_GUID                      = 1BA0062E-C779-4582-8566-336AE8F78F09
   MODULE_TYPE                    = SEC
   VERSION_STRING                 = 1.1
@@ -26,7 +27,7 @@ [Defines]
 #
 
 [Sources]
-  ResetVector.nasmb
+  XenResetVector.nasmb
 
 [Packages]
   OvmfPkg/OvmfPkg.dec
OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm renamed from UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm +3 -1
similarity index 94%
copy from UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
copy to OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm
index bc68c8dd74..e22e92c8a6 100644
@@ -3,6 +3,8 @@
 ; Transition from 16 bit real mode into 32 bit flat protected mode
 ;
 ; Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019, Citrix Systems, Inc.
+;
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD License
 ; which accompanies this distribution.  The full text of the license may be found at
@@ -13,7 +15,7 @@
 ;
 ;------------------------------------------------------------------------------
 
-%define SEC_DEFAULT_CR0  0x40000023
+%define SEC_DEFAULT_CR0  0x00000023
 %define SEC_DEFAULT_CR4  0x640
 
 BITS    16
OvmfPkg/XenResetVector/Ia32/PageTables64.asm renamed from OvmfPkg/ResetVector/Ia32/PageTables64.asm +2 -0
similarity index 95%
copy from OvmfPkg/ResetVector/Ia32/PageTables64.asm
copy to OvmfPkg/XenResetVector/Ia32/PageTables64.asm
index db1590aedd..ded466031b 100644
@@ -3,6 +3,8 @@
 ; Sets the CR3 register for 64-bit paging
 ;
 ; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019, Citrix Systems, Inc.
+;
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD License
 ; which accompanies this distribution.  The full text of the license may be found at
OvmfPkg/XenResetVector/XenResetVector.nasmb renamed from OvmfPkg/ResetVector/ResetVector.nasmb +2 -0
similarity index 94%
copy from OvmfPkg/ResetVector/ResetVector.nasmb
copy to OvmfPkg/XenResetVector/XenResetVector.nasmb
index 29cbad3677..49f2bab001 100644
@@ -3,6 +3,8 @@
 ; This file includes all other code files to assemble the reset vector code
 ;
 ; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019, Citrix Systems, Inc.
+;
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD License
 ; which accompanies this distribution.  The full text of the license may be found at
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#4 lore raw

PATCH v2 4/31 OvmfPkg: Introduce XenPlatformPei

In reply to Anthony PERARD

A copy of OvmfPkg/PlatformPei without some of QEMU specific initialization, Xen does not support QemuFwCfg.

This new module will be adjusted to accommodate Xen PVH.

fw_cfg dependents that have been removed, which are dynamically skipped when running PlatformPei on Xen:
- GetFirstNonAddress(): controlling the 64-bit PCI MMIO aperture via the (experimental) "opt/ovmf/X-PciMmio64Mb" file
- GetFirstNonAddress(): honoring the hotplug DIMM area ("etc/reserved-memory-end") in the placement of the 64-bit PCI MMIO aperture
- NoexecDxeInitialization() is removed, so PcdPropertiesTableEnable and PcdSetNxForStack are left constant FALSE (not set dynamically from fw_cfg "opt/ovmf/PcdXxxx")
- MaxCpuCountInitialization(), PublishPeiMemory(): the max CPU count is not taken from the QemuFwCfgItemSmpCpuCount fw_cfg key; PcdCpuMaxLogicalProcessorNumber is used intact and PcdCpuApInitTimeOutInMicroSeconds is never changed or used.
- InitializeXenPlatform(), S3Verification(): S3 is assumed disabled (not consulting "etc/system-states" via QemuFwCfgS3Enabled()).
- InstallFeatureControlCallback(): the feature control MSR is not set from "etc/msr_feature_control"
(also removed FeatureControl.c as there is nothing been executed)

Also removed:
- SMRAM/TSEG-related low mem size adjusting (PcdSmmSmramRequire is assumed FALSE) in PublishPeiMemory(),
- QemuInitializeRam() entirely,

Xen related changes:
- Have removed the module variable mXen, as it should be always true.
- Have the platform PEI initialization fails if Xen has not been detected.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenOvmf.dsc                                                        |   2 +-
 OvmfPkg/XenOvmf.fdf                                                        |   2 +-
 OvmfPkg/{PlatformPei/PlatformPei.inf => XenPlatformPei/XenPlatformPei.inf} |  28 +-
 OvmfPkg/{PlatformPei => XenPlatformPei}/Cmos.h                             |   2 +
 OvmfPkg/{PlatformPei => XenPlatformPei}/Platform.h                         |  13 +-
 OvmfPkg/{PlatformPei => XenPlatformPei}/Xen.h                              |   0
 OvmfPkg/{PlatformPei => XenPlatformPei}/AmdSev.c                           |  30 +-
 OvmfPkg/{PlatformPei => XenPlatformPei}/ClearCache.c                       |   1 +
 OvmfPkg/{PlatformPei => XenPlatformPei}/Cmos.c                             |   2 +
 OvmfPkg/{PlatformPei => XenPlatformPei}/Fv.c                               |  26 +-
 OvmfPkg/XenPlatformPei/MemDetect.c                                         | 427 ++++++++++++++++++++
 OvmfPkg/{PlatformPei => XenPlatformPei}/Platform.c                         | 246 +----------
 OvmfPkg/{PlatformPei => XenPlatformPei}/Xen.c                              |   8 +-
 13 files changed, 453 insertions(+), 334 deletions(-)
OvmfPkg/XenOvmf.dsc +1 -1
index 6161133fa8..7b8a1fdf6b 100644
@@ -531,7 +531,7 @@ [Components]
   }
   MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
 
-  OvmfPkg/PlatformPei/PlatformPei.inf
+  OvmfPkg/XenPlatformPei/XenPlatformPei.inf
   UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
   UefiCpuPkg/CpuMpPei/CpuMpPei.inf
 
OvmfPkg/XenOvmf.fdf +1 -1
index 292cf4b492..295e30ca3f 100644
@@ -158,7 +158,7 @@ [FV.PEIFV]
 INF  MdeModulePkg/Universal/PCD/Pei/Pcd.inf
 INF  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf
 INF  MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf
-INF  OvmfPkg/PlatformPei/PlatformPei.inf
+INF  OvmfPkg/XenPlatformPei/XenPlatformPei.inf
 INF  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
 INF  UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
 INF  UefiCpuPkg/CpuMpPei/CpuMpPei.inf
OvmfPkg/XenPlatformPei/XenPlatformPei.inf renamed from OvmfPkg/PlatformPei/PlatformPei.inf +4 -24
similarity index 69%
copy from OvmfPkg/PlatformPei/PlatformPei.inf
copy to OvmfPkg/XenPlatformPei/XenPlatformPei.inf
index 5c8dd0fe6d..c8d25c115f 100644
@@ -3,6 +3,7 @@
 #
 #  This module provides platform specific function to detect boot mode.
 #  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2019, Citrix Systems, Inc.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -16,11 +17,11 @@
 
 [Defines]
   INF_VERSION                    = 0x00010005
-  BASE_NAME                      = PlatformPei
-  FILE_GUID                      = 222c386d-5abc-4fb4-b124-fbb82488acf4
+  BASE_NAME                      = XenPlatformPei
+  FILE_GUID                      = f112a6ee-993a-4f0b-8295-e52029d9b4ba
   MODULE_TYPE                    = PEIM
   VERSION_STRING                 = 1.0
-  ENTRY_POINT                    = InitializePlatform
+  ENTRY_POINT                    = InitializeXenPlatform
 
 #
 # The following information is for reference only and not required by the build tools.
@@ -33,7 +34,6 @@ [Sources]
   ClearCache.c
   Cmos.c
   Cmos.h
-  FeatureControl.c
   Fv.c
   MemDetect.c
   Platform.c
@@ -62,10 +62,7 @@ [LibraryClasses]
   PciLib
   ResourcePublicationLib
   PeiServicesLib
-  PeiServicesTablePointerLib
   PeimEntryPoint
-  QemuFwCfgLib
-  QemuFwCfgS3Lib
   MtrrLib
   MemEncryptSevLib
   PcdLib
@@ -75,13 +72,8 @@ [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
-  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase
-  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
-  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase
-  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize
-  gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
   gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase
   gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize
@@ -89,31 +81,19 @@ [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size
   gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base
   gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size
-  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd
   gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes
-  gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
   gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable
-  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
   gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy
   gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize
 
 [FixedPcd]
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
 
-[FeaturePcd]
-  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
-
 [Ppis]
   gEfiPeiMasterBootModePpiGuid
   gEfiPeiMpServicesPpiGuid
OvmfPkg/XenPlatformPei/Cmos.h renamed from OvmfPkg/PlatformPei/Cmos.h +2 -0
similarity index 92%
copy from OvmfPkg/PlatformPei/Cmos.h
copy to OvmfPkg/XenPlatformPei/Cmos.h
index 949f884c2c..defe677122 100644
@@ -2,6 +2,8 @@
   PC/AT CMOS access routines
 
   Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2019, Citrix Systems, Inc.
+
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
OvmfPkg/XenPlatformPei/Platform.h renamed from OvmfPkg/PlatformPei/Platform.h +2 -11
similarity index 88%
copy from OvmfPkg/PlatformPei/Platform.h
copy to OvmfPkg/XenPlatformPei/Platform.h
index b12a5c1f5f..6ccd5eb66c 100644
@@ -2,6 +2,8 @@
   Platform PEI module include file.
 
   Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2019, Citrix Systems, Inc.
+
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
@@ -78,11 +80,6 @@ PeiFvInitialization (
   VOID
   );
 
-VOID
-InstallFeatureControlCallback (
-  VOID
-  );
-
 VOID
 InstallClearCacheCallback (
   VOID
@@ -103,8 +100,6 @@ AmdSevInitialize (
   VOID
   );
 
-extern BOOLEAN mXen;
-
 VOID
 XenPublishRamRegions (
   VOID
@@ -112,12 +107,8 @@ XenPublishRamRegions (
 
 extern EFI_BOOT_MODE mBootMode;
 
-extern BOOLEAN mS3Supported;
-
 extern UINT8 mPhysMemAddressWidth;
 
-extern UINT32 mMaxCpuCount;
-
 extern UINT16 mHostBridgeDevId;
 
 #endif // _PLATFORM_PEI_H_INCLUDED_
OvmfPkg/XenPlatformPei/Xen.h renamed from OvmfPkg/PlatformPei/Xen.h +0 -0
similarity index 100%
copy from OvmfPkg/PlatformPei/Xen.h
copy to OvmfPkg/XenPlatformPei/Xen.h
OvmfPkg/XenPlatformPei/AmdSev.c renamed from OvmfPkg/PlatformPei/AmdSev.c +1 -29
similarity index 61%
copy from OvmfPkg/PlatformPei/AmdSev.c
copy to OvmfPkg/XenPlatformPei/AmdSev.c
index 2e14eaf8c3..1a1f46291f 100644
@@ -2,6 +2,7 @@
   Initialize Secure Encrypted Virtualization (SEV) support
 
   Copyright (c) 2017, Advanced Micro Devices. All rights reserved.<BR>
+  Copyright (c) 2019, Citrix Systems, Inc.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD
@@ -16,7 +17,6 @@
 // The package level header files this module uses
 //
 #include <Library/DebugLib.h>
-#include <Library/HobLib.h>
 #include <Library/MemEncryptSevLib.h>
 #include <Library/PcdLib.h>
 #include <PiPei.h>
@@ -67,32 +67,4 @@ AmdSevInitialize (
   //
   PcdStatus = PcdSet32S (PcdOptionRomImageVerificationPolicy, 0x4);
   ASSERT_RETURN_ERROR (PcdStatus);
-
-  //
-  // When SMM is required, cover the pages containing the initial SMRAM Save
-  // State Map with a memory allocation HOB:
-  //
-  // There's going to be a time interval between our decrypting those pages for
-  // SMBASE relocation and re-encrypting the same pages after SMBASE
-  // relocation. We shall ensure that the DXE phase stay away from those pages
-  // until after re-encryption, in order to prevent an information leak to the
-  // hypervisor.
-  //
-  if (FeaturePcdGet (PcdSmmSmramRequire) && (mBootMode != BOOT_ON_S3_RESUME)) {
-    RETURN_STATUS LocateMapStatus;
-    UINTN         MapPagesBase;
-    UINTN         MapPagesCount;
-
-    LocateMapStatus = MemEncryptSevLocateInitialSmramSaveStateMapPages (
-                        &MapPagesBase,
-                        &MapPagesCount
-                        );
-    ASSERT_RETURN_ERROR (LocateMapStatus);
-
-    BuildMemoryAllocationHob (
-      MapPagesBase,                      // BaseAddress
-      EFI_PAGES_TO_SIZE (MapPagesCount), // Length
-      EfiBootServicesData                // MemoryType
-      );
-  }
 }
OvmfPkg/XenPlatformPei/ClearCache.c renamed from OvmfPkg/PlatformPei/ClearCache.c +1 -0
similarity index 95%
copy from OvmfPkg/PlatformPei/ClearCache.c
copy to OvmfPkg/XenPlatformPei/ClearCache.c
index 7d15fd925c..78e22124e3 100644
@@ -6,6 +6,7 @@
   sake.
 
   Copyright (C) 2018, Red Hat, Inc.
+  Copyright (c) 2019, Citrix Systems, Inc.
 
   This program and the accompanying materials are licensed and made available
   under the terms and conditions of the BSD License which accompanies this
OvmfPkg/XenPlatformPei/Cmos.c renamed from OvmfPkg/PlatformPei/Cmos.c +2 -0
similarity index 92%
copy from OvmfPkg/PlatformPei/Cmos.c
copy to OvmfPkg/XenPlatformPei/Cmos.c
index 48ed2cb8f4..174ec773ec 100644
@@ -2,6 +2,8 @@
   PC/AT CMOS access routines
 
   Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2019, Citrix Systems, Inc.
+
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
OvmfPkg/XenPlatformPei/Fv.c renamed from OvmfPkg/PlatformPei/Fv.c +4 -22
similarity index 72%
copy from OvmfPkg/PlatformPei/Fv.c
copy to OvmfPkg/XenPlatformPei/Fv.c
index 248c585085..388e8768bf 100644
@@ -2,6 +2,8 @@
   Build FV related hobs for platform.
 
   Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2019, Citrix Systems, Inc.
+
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
@@ -32,8 +34,6 @@ PeiFvInitialization (
   VOID
   )
 {
-  BOOLEAN SecureS3Needed;
-
   DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n"));
 
   //
@@ -44,7 +44,7 @@ PeiFvInitialization (
   BuildMemoryAllocationHob (
     PcdGet32 (PcdOvmfPeiMemFvBase),
     PcdGet32 (PcdOvmfPeiMemFvSize),
-    mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
+    EfiBootServicesData
     );
 
   //
@@ -52,8 +52,6 @@ PeiFvInitialization (
   //
   BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));
 
-  SecureS3Needed = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire);
-
   //
   // Create a memory allocation HOB for the DXE FV.
   //
@@ -65,25 +63,9 @@ PeiFvInitialization (
   BuildMemoryAllocationHob (
     PcdGet32 (PcdOvmfDxeMemFvBase),
     PcdGet32 (PcdOvmfDxeMemFvSize),
-    SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData
+    EfiBootServicesData
     );
 
-  //
-  // Additionally, said decompression will use temporary memory above the end
-  // of DXEFV, so let's keep away the OS from there too.
-  //
-  if (SecureS3Needed) {
-    UINT32 DxeMemFvEnd;
-
-    DxeMemFvEnd = PcdGet32 (PcdOvmfDxeMemFvBase) +
-                  PcdGet32 (PcdOvmfDxeMemFvSize);
-    BuildMemoryAllocationHob (
-      DxeMemFvEnd,
-      PcdGet32 (PcdOvmfDecompressionScratchEnd) - DxeMemFvEnd,
-      EfiACPIMemoryNVS
-      );
-  }
-
   //
   // Let PEI know about the DXE FV so it can find the DXE Core
   //
OvmfPkg/XenPlatformPei/MemDetect.c new file +427 -0

427 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Platform.c renamed from OvmfPkg/PlatformPei/Platform.c +7 -239

319 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Xen.c renamed from OvmfPkg/PlatformPei/Xen.c +1 -7
similarity index 94%
copy from OvmfPkg/PlatformPei/Xen.c
copy to OvmfPkg/XenPlatformPei/Xen.c
index ab38f97a67..7c82e5b69b 100644
@@ -3,6 +3,7 @@
 
   Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2011, Andrei Warkentin <[email protected]>
+  Copyright (c) 2019, Citrix Systems, Inc.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -34,8 +35,6 @@
 #include "Platform.h"
 #include "Xen.h"
 
-BOOLEAN mXen = FALSE;
-
 STATIC UINT32 mXenLeaf = 0;
 
 EFI_XEN_INFO mXenInfo;
@@ -143,7 +142,6 @@ XenDetect (
               (UINT32 *) &Signature[8]);
 
     if (!AsciiStrCmp ((CHAR8 *) Signature, "XenVMMXenVMM")) {
-      mXen = TRUE;
       return TRUE;
     }
   }
@@ -162,10 +160,6 @@ XenPublishRamRegions (
   UINT32            E820EntriesCount;
   EFI_STATUS        Status;
 
-  if (!mXen) {
-    return;
-  }
-
   DEBUG ((EFI_D_INFO, "Using memory map provided by Xen\n"));
 
   //
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#5 lore raw

PATCH v2 5/31 OvmfPkg/XenOvmf: Creating an ELF header

In reply to Anthony PERARD

This header replace the embedded variable store.

The ELF header explain to a loader to load the binary at the address 1MB, then jump to the PVH entry point which will be created in a later patch.

That patch include generate_elf_header.c which can be use to regenerate the ELF header, but this will be a manual step.

Contributed-under: TianoCore Contribution Agreement 1.1

---

Notes:
This "ELF header" might not be the best way, but with it the Xen toolstack can load OVMF like any other PVH-compatible kernel without modification. Is there a better way?

The generate_elf_header.c file was used to generate the series of hex number. It isn't at a right place but I'm not sure where to put this C file. Maybe in the commit message or maybe it could be forgotten since I've added all the comments in the .fdf file.

 OvmfPkg/XenOvmf.fdf   | 82 +++++++++++++++++++-
 generate_elf_header.c | 78 +++++++++++++++++++
 2 files changed, 157 insertions(+), 3 deletions(-)
OvmfPkg/XenOvmf.fdf +79 -3
index 295e30ca3f..20ebacd673 100644
@@ -21,8 +21,8 @@ [Defines]
 !include OvmfPkg.fdf.inc
 
 #
-# Build the variable store and the firmware code as one unified flash device
-# image.
+# This will allow the flash device image to be recognize as an ELF, with first
+# an ELF headers, then the firmware code.
 #
 [FD.OVMF]
 BaseAddress   = $(FW_BASE_ADDRESS)
@@ -31,7 +31,83 @@ [FD.OVMF]
 BlockSize     = $(BLOCK_SIZE)
 NumBlocks     = $(FW_BLOCKS)
 
-!include VarStore.fdf.inc
+!if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
+0x00000000|0x0000e000
+!endif
+!if $(FD_SIZE_IN_KB) == 4096
+0x00000000|0x00040000
+!endif
+#was NV_VARIABLE_STORE
+DATA = {
+  # ELF file header
+  0x7f, 0x45, 0x4c, 0x46, # e_ident[0..3]: Magic number
+  0x01, # File class: 32-bit objects
+  0x01, # Data encoding: 2's complement, little endian
+  0x01, # File version
+  0x03, # OS ABI identification: Object uses GNU ELF extensions
+  0x00, # ABI version
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  # e_ident[EI_PAD...]
+
+  0x02, 0x00, # e_type = Executable file
+  0x03, 0x00, # e_machine = Intel 80386
+  0x01, 0x00, 0x00, 0x00, # e_version
+  0xd0, 0xff, 0x2f, 0x00, # e_entry: Entry point virtual address
+  0x34, 0x00, 0x00, 0x00, # e_phoff: Program header table file offset
+  0x00, 0x00, 0x00, 0x00, # e_shoff: Section header table file offset
+  0x00, 0x00, 0x00, 0x00, # e_flags: Processor-specific flags
+  0x34, 0x00, #    e_ehsize: ELF header size
+  0x20, 0x00, # e_phentsize: Program header table entry size
+  0x01, 0x00, #     e_phnum: Program header table entry count
+  0x00, 0x00, # e_shentsize: Section header table entry size
+  0x00, 0x00, #     e_shnum: Section header table entry count
+  0xff, 0xff, # e_shstrndx
+
+  # ELF Program segment header
+  0x01, 0x00, 0x00, 0x00, # p_type = Loadable program segment
+  0x00, 0x00, 0x00, 0x00, # p_offset
+  0x00, 0x00, 0x10, 0x00, # p_vaddr: Segment virtual address
+  0x00, 0x00, 0x10, 0x00, # p_paddr: Segment physical address
+  0x00, 0x00, 0x20, 0x00, # p_filesz: Segment size in file
+  0x00, 0x00, 0x20, 0x00, # p_memsz: Segment size in memory
+  0x07, 0x00, 0x00, 0x00, # p_flags = Segment is executable | writable | readable
+  0x00, 0x00, 0x00, 0x00  # p_align
+
+}
+
+!if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
+0x0000e000|0x00001000
+!endif
+!if $(FD_SIZE_IN_KB) == 4096
+0x00040000|0x00001000
+!endif
+#NV_EVENT_LOG
+
+!if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
+0x0000f000|0x00001000
+!endif
+!if $(FD_SIZE_IN_KB) == 4096
+0x00041000|0x00001000
+!endif
+#NV_FTW_WORKING
+DATA = {
+  # EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature = gEdkiiWorkingBlockSignatureGuid         =
+  #  { 0x9e58292b, 0x7c68, 0x497d, { 0xa0, 0xce, 0x65,  0x0, 0xfd, 0x9f, 0x1b, 0x95 }}
+  0x2b, 0x29, 0x58, 0x9e, 0x68, 0x7c, 0x7d, 0x49,
+  0xa0, 0xce, 0x65,  0x0, 0xfd, 0x9f, 0x1b, 0x95,
+  # Crc:UINT32            #WorkingBlockValid:1, WorkingBlockInvalid:1, Reserved
+  0x2c, 0xaf, 0x2c, 0x64, 0xFE, 0xFF, 0xFF, 0xFF,
+  # WriteQueueSize: UINT64
+  0xE0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+}
+
+!if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
+0x00010000|0x00010000
+!endif
+!if $(FD_SIZE_IN_KB) == 4096
+0x00042000|0x00042000
+!endif
+#NV_FTW_SPARE
+
 
 $(VARS_SIZE)|$(FVMAIN_SIZE)
 FV = FVMAIN_COMPACT
generate_elf_header.c new file +78 -0

78 lines not on this page · raw message

Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#6 lore raw

PATCH v2 6/31 OvmfPkg/XenResetVector: Add new entry point for Xen PVH

In reply to Anthony PERARD

This one enter directly in 32bits

Information on the expected state of the machine when this entry point is used can be found at:
https://xenbits.xenproject.org/docs/unstable/misc/pvh.html

Contributed-under: TianoCore Contribution Agreement 1.1

---
 {UefiCpuPkg/ResetVector/Vtf0 => OvmfPkg/XenResetVector}/Ia16/ResetVectorVtf0.asm | 18 +++++++-
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm                                       | 47 ++++++++++++++++++++
 OvmfPkg/XenResetVector/XenResetVector.nasmb                                      |  1 +
 3 files changed, 65 insertions(+), 1 deletion(-)
OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm renamed from UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm +17 -1
similarity index 76%
copy from UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm
copy to OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm
index 142d9f3212..46eec66859 100644
@@ -3,6 +3,8 @@
 ; First code executed by processor after resetting.
 ;
 ; Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019, Citrix Systems, Inc.
+;
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD License
 ; which accompanies this distribution.  The full text of the license may be found at
@@ -27,9 +29,23 @@ ALIGN   16
 ; located just below 0x100000000 (4GB) in the firmware device.
 ;
 %ifdef ALIGN_TOP_TO_4K_FOR_PAGING
-    TIMES (0x1000 - ($ - EndOfPageTables) - 0x20) DB 0
+    TIMES (0x1000 - ($ - EndOfPageTables) - (fourGigabytes - xenPVHEntryPoint)) DB 0
 %endif
 
+BITS    32
+xenPVHEntryPoint:
+;
+; Entry point to use when running as a Xen PVH guest. (0xffffffd0)
+;
+; Description of the expected state of the machine when this entry point is
+; used can be found at:
+; https://xenbits.xenproject.org/docs/unstable/misc/pvh.html
+;
+    jmp     xenPVHMain
+
+BITS    16
+ALIGN   16
+
 applicationProcessorEntryPoint:
 ;
 ; Application Processors entry point
OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm new file +47 -0

47 lines not on this page · raw message

OvmfPkg/XenResetVector/XenResetVector.nasmb +1 -0
index 49f2bab001..d5a791c139 100644
@@ -70,6 +70,7 @@
 %include "Ia16/Init16.asm"
 
 %include "Main.asm"
+%include "Ia32/XenPVHMain.asm"
 
 %include "Ia16/ResetVectorVtf0.asm"
 
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#7 lore raw

PATCH v2 7/31 OvmfPkg/XenResetVector: Saving start of day pointer for PVH guests

In reply to Anthony PERARD

As described in the Xen PVH documentation [1], "ebx: contains the physical memory address where the loader has placed the boot start info structure". To have this pointer saved to be able to use it later in the PEI phase, we allocate some space in the MEMFD for it. We use 'XPVH' as a signature (for "Xen PVH").

[1] https://xenbits.xenproject.org/docs/unstable/misc/pvh.html

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/OvmfPkg.dec                         | 4 ++++
 OvmfPkg/XenOvmf.fdf                         | 4 ++++
 OvmfPkg/XenResetVector/XenResetVector.inf   | 3 +++
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm  | 4 ++++
 OvmfPkg/XenResetVector/XenResetVector.nasmb | 2 ++
 5 files changed, 17 insertions(+)
OvmfPkg/OvmfPkg.dec +4 -0
index e50c6179a2..1cbbc49a6b 100644
@@ -127,6 +127,10 @@ [PcdsFixedAtBuild]
   gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize|0x0|UINT32|0x1a
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd|0x0|UINT32|0x1f
 
+  # Used by XenOvmf
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenStartOfDayStructPtr|0x0|UINT32|0x30
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenStartOfDayStructPtrSize|0x0|UINT32|0x31
+
 [PcdsDynamic, PcdsDynamicEx]
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10
OvmfPkg/XenOvmf.fdf +4 -0
index 20ebacd673..f9e58befd6 100644
@@ -159,6 +159,10 @@ [FD.MEMFD]
 0x007000|0x001000
 gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
 
+0x008000|0x001000
+# Used by XenResetVector to communicate with XenPlatformPei
+gUefiOvmfPkgTokenSpaceGuid.PcdXenStartOfDayStructPtr|gUefiOvmfPkgTokenSpaceGuid.PcdXenStartOfDayStructPtrSize
+
 0x010000|0x010000
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
 
OvmfPkg/XenResetVector/XenResetVector.inf +3 -0
index 5c05f02285..ec98c17876 100644
@@ -41,3 +41,6 @@ [BuildOptions]
 [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize
+
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenStartOfDayStructPtr
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenStartOfDayStructPtrSize
OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm +4 -0
index c4802bf4d1..4e55b0ac1f 100644
@@ -22,6 +22,10 @@ xenPVHMain:
     ; ESP -  Initial value of the EAX register (BIST: Built-in Self Test)
     mov     esp, eax
 
+    ;; Store "Start of day" struct pointer for later use
+    mov     dword[PVH_SPACE (0)], ebx
+    mov     dword[PVH_SPACE (4)], 'XPVH'
+
     cli
 
     mov     ebx, ADDR_OF(gdtr)
OvmfPkg/XenResetVector/XenResetVector.nasmb +2 -0
index d5a791c139..50cb81fcd1 100644
@@ -41,6 +41,8 @@
 
 %include "CommonMacros.inc"
 
+%define PVH_SPACE(Offset) (FixedPcdGet32 (PcdXenStartOfDayStructPtr) + (Offset))
+
 %include "PostCodes.inc"
 
 %ifdef DEBUG_PORT80
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#8 lore raw

PATCH v2 8/31 OvmfPkg/XenResetVector: Allow to jumpstart from either hvmloader or PVH

In reply to Anthony PERARD

This patch allows the ResetVector to be run indenpendently from build time addresses.

The goal of the patch is to avoid having to create RAM just below 4G when creating a Xen PVH guest while been compatible with the way hvmloader currently load OVMF, just below 4G.

Only the new PVH entry point will do the calculation.

The ResetVector will figure out its current running address by creating a temporary stack, make a call and calculate the difference between the build time address and the address at run time.

This patch copies and make the necessary modification to some other asm files:
- copy of UefiCpuPkg/.../Flat32ToFlat64.asm:
Allow Transition32FlatTo64Flat to been runnned from anywhere in memory
_ copy of UefiCpuPkg/../SearchForBfvBase.asm:
Add a extra parameter to indicate where to start the search for the boot firmware volume.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm                                    |  3 ++
 {UefiCpuPkg/ResetVector/Vtf0 => OvmfPkg/XenResetVector}/Ia32/Flat32ToFlat64.asm   | 25 ++++++++++++++--
 {UefiCpuPkg/ResetVector/Vtf0 => OvmfPkg/XenResetVector}/Ia32/SearchForBfvBase.asm | 19 +++++++++----
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm                                        | 30 ++++++++++++++++++--
 4 files changed, 66 insertions(+), 11 deletions(-)
OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm +3 -0
index e22e92c8a6..eebced6ced 100644
@@ -61,6 +61,9 @@ jumpTo32BitAndLandHere:
     mov     gs, ax
     mov     ss, ax
 
+    ; parameter for Flat32SearchForBfvBase
+    xor     eax, eax ; Start searching from top of 4GB for BfvBase
+
     OneTimeCallRet TransitionFromReal16To32BitFlat
 
 ALIGN   2
OvmfPkg/XenResetVector/Ia32/Flat32ToFlat64.asm renamed from UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm +23 -2
similarity index 69%
copy from UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm
copy to OvmfPkg/XenResetVector/Ia32/Flat32ToFlat64.asm
index 5b6b375330..ca03ea43e0 100644
@@ -3,6 +3,8 @@
 ; Transition from 32 bit flat protected mode into 64 bit flat protected mode
 ;
 ; Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019, Citrix Systems, Inc.
+;
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD License
 ; which accompanies this distribution.  The full text of the license may be found at
@@ -16,7 +18,7 @@
 BITS    32
 
 ;
-; Modified:  EAX
+; Modified:  EAX, EBX, ECX, EDX, ESP
 ;
 Transition32FlatTo64Flat:
 
@@ -35,10 +37,29 @@ Transition32FlatTo64Flat:
     bts     eax, 31                     ; set PG
     mov     cr0, eax                    ; enable paging
 
-    jmp     LINEAR_CODE64_SEL:ADDR_OF(jumpTo64BitAndLandHere)
+    ; backup ESP
+    mov     ebx, esp
+
+    ;; recalculate delta
+    mov     esp, PVH_SPACE(16)
+    call    .delta
+.delta:
+    pop     edx
+    sub     edx, ADDR_OF(.delta)
+
+    ; push return addr and seg to the stack, then return far
+    push    dword LINEAR_CODE64_SEL
+    mov     eax, ADDR_OF(jumpTo64BitAndLandHere)
+    add     eax, edx ; add delta
+    push    eax
+    retf
+
 BITS    64
 jumpTo64BitAndLandHere:
 
+    ; restore ESP
+    mov     esp, ebx
+
     debugShowPostCode POSTCODE_64BIT_MODE
 
     OneTimeCallRet Transition32FlatTo64Flat
OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm renamed from UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm +13 -6
similarity index 83%
copy from UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm
copy to OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm
index d0c2d8c39c..0519e05601 100644
@@ -3,6 +3,8 @@
 ; Search for the Boot Firmware Volume (BFV) base address
 ;
 ; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019, Citrix Systems, Inc.
+;
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD License
 ; which accompanies this distribution.  The full text of the license may be found at
@@ -23,22 +25,26 @@
 BITS    32
 
 ;
-; Modified:  EAX, EBX
+; Modified:  EAX, EBX, ECX
 ; Preserved: EDI, ESP
 ;
+; @param[in]   EAX  Start search from here
 ; @param[out]  EBP  Address of Boot Firmware Volume (BFV)
 ;
 Flat32SearchForBfvBase:
 
-    xor     eax, eax
+    mov     ecx, eax
 searchingForBfvHeaderLoop:
     ;
-    ; We check for a firmware volume at every 4KB address in the top 16MB
-    ; just below 4GB.  (Addresses at 0xffHHH000 where H is any hex digit.)
+    ; We check for a firmware volume at every 4KB address in the 16MB
+    ; just below where we started, ECX.
     ;
     sub     eax, 0x1000
-    cmp     eax, 0xff000000
-    jb      searchedForBfvHeaderButNotFound
+    mov     ebx, ecx
+    sub     ebx, eax
+    cmp     ebx, 0x01000000
+    ; if ECX-EAX > 16MB; jump notfound
+    ja      searchedForBfvHeaderButNotFound
 
     ;
     ; Check FFS GUID
@@ -59,6 +65,7 @@ searchingForBfvHeaderLoop:
     jne     searchingForBfvHeaderLoop
     mov     ebx, eax
     add     ebx, dword [eax + 0x20]
+    cmp     ebx, ecx
     jnz     searchingForBfvHeaderLoop
 
     jmp     searchedForBfvHeaderAndItWasFound
OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm +27 -3
index 4e55b0ac1f..612b2e9c44 100644
@@ -19,22 +19,39 @@ BITS    32
 xenPVHMain:
     mov     di, 'BP'
 
-    ; ESP -  Initial value of the EAX register (BIST: Built-in Self Test)
-    mov     esp, eax
+    ; EBP -  Initial value of the EAX register (BIST: Built-in Self Test)
+    mov     ebp, eax
 
     ;; Store "Start of day" struct pointer for later use
     mov     dword[PVH_SPACE (0)], ebx
     mov     dword[PVH_SPACE (4)], 'XPVH'
 
+    ;; calculate delta between build-addr and run position
+    mov     esp, PVH_SPACE(16)          ; create a temporary stack
+    call    .delta
+.delta:
+    pop     edx                         ; get addr of .delta
+    sub     edx, ADDR_OF(.delta)        ; calculate delta
+
     cli
 
+    ;; Find address of GDT and gdtr and fix the later
     mov     ebx, ADDR_OF(gdtr)
+    add     ebx, edx                    ; add delta gdtr
+    mov     eax, ADDR_OF(GDT_BASE)
+    add     eax, edx                    ; add delta to GDT_BASE
+    mov     dword[ebx + 2], eax         ; fix GDT_BASE addr in gdtr
     lgdt    [ebx]
 
     mov     eax, SEC_DEFAULT_CR0
     mov     cr0, eax
 
-    jmp     LINEAR_CODE_SEL:ADDR_OF(.jmpToNewCodeSeg)
+    ;; push return addr to the stack, then return far
+    push    dword LINEAR_CODE_SEL       ; segment to select
+    mov     eax, ADDR_OF(.jmpToNewCodeSeg) ; return addr
+    add     eax, edx                    ; add delta to return addr
+    push    eax
+    retf
 .jmpToNewCodeSeg:
 
     mov     eax, SEC_DEFAULT_CR4
@@ -47,5 +64,12 @@ xenPVHMain:
     mov     gs, ax
     mov     ss, ax
 
+    ; ESP -  Initial value of the EAX register (BIST: Built-in Self Test)
+    mov     esp, ebp
+
+    ; parameter for Flat32SearchForBfvBase
+    mov     eax, ADDR_OF(fourGigabytes)
+    add     eax, edx ; add delta
+
     ; return to the Main16
     OneTimeCallRet TransitionFromReal16To32BitFlat
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#9 lore raw

PATCH v2 9/31 OvmfPkg/XenOvmf: use a TimerLib instance that depends only on the CPU

In reply to Anthony PERARD

ACPI Timer does not work in a PVH guest, but local APIC works on both PVH and HVM.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenOvmf.dsc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
OvmfPkg/XenOvmf.dsc +6 -6
index 7b8a1fdf6b..cc51bac3be 100644
@@ -104,7 +104,7 @@ [SkuIds]
 ################################################################################
 [LibraryClasses]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf
+  TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
   BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
@@ -205,7 +205,7 @@ [LibraryClasses.common]
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
 
 [LibraryClasses.common.SEC]
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf
+  TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
@@ -284,7 +284,7 @@ [LibraryClasses.common.DXE_CORE]
 
 [LibraryClasses.common.DXE_RUNTIME_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -301,7 +301,7 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER]
 
 [LibraryClasses.common.UEFI_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -316,7 +316,7 @@ [LibraryClasses.common.UEFI_DRIVER]
 
 [LibraryClasses.common.DXE_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
@@ -344,7 +344,7 @@ [LibraryClasses.common.DXE_DRIVER]
 
 [LibraryClasses.common.UEFI_APPLICATION]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#10 lore raw

PATCH v2 10/31 OvmfPkg/XenPlatformPei: Detect OVMF_INFO from hvmloader

In reply to Anthony PERARD

This struct is only useful to retrieve the E820 table. The mXenHvmloaderInfo isn't used yet, but will be use in a further patch to retrieve the E820 table.

Also remove the unused pointer from the XenInfo HOB as that information is only useful in the XenPlatformPei.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/Include/Guid/XenInfo.h |  4 ----
 OvmfPkg/PlatformPei/Xen.c      |  3 ---
 OvmfPkg/XenPlatformPei/Xen.c   | 23 ++++++++++++++++++--
 3 files changed, 21 insertions(+), 9 deletions(-)
OvmfPkg/Include/Guid/XenInfo.h +0 -4
index d512b0b63f..5d4579f244 100644
@@ -24,10 +24,6 @@ typedef struct {
   ///
   VOID *HyperPages;
   ///
-  /// Location of the hvm_info page.
-  ///
-  VOID *HvmInfo;
-  ///
   /// Hypervisor major version.
   ///
   UINT16 VersionMajor;
OvmfPkg/PlatformPei/Xen.c +0 -3
index ab38f97a67..75181be2fd 100644
@@ -104,9 +104,6 @@ XenConnect (
   mXenInfo.VersionMajor = (UINT16)(XenVersion >> 16);
   mXenInfo.VersionMinor = (UINT16)(XenVersion & 0xFFFF);
 
-  /* TBD: Locate hvm_info and reserve it away. */
-  mXenInfo.HvmInfo = NULL;
-
   BuildGuidDataHob (
     &gEfiXenInfoGuid,
     &mXenInfo,
OvmfPkg/XenPlatformPei/Xen.c +21 -2
index 7c82e5b69b..a866641b67 100644
@@ -39,6 +39,12 @@ STATIC UINT32 mXenLeaf = 0;
 
 EFI_XEN_INFO mXenInfo;
 
+//
+// Location of the firmware info struct setup by hvmloader.
+// Only the E820 table is used by OVMF.
+//
+EFI_XEN_OVMF_INFO *mXenHvmloaderInfo;
+
 /**
   Returns E820 map provided by Xen
 
@@ -84,6 +90,8 @@ XenConnect (
   UINT32 TransferReg;
   UINT32 TransferPages;
   UINT32 XenVersion;
+  EFI_XEN_OVMF_INFO *Info;
+  CHAR8 Sig[sizeof (Info->Signature) + 1];
 
   AsmCpuid (XenLeaf + 2, &TransferPages, &TransferReg, NULL, NULL);
   mXenInfo.HyperPages = AllocatePages (TransferPages);
@@ -103,8 +111,19 @@ XenConnect (
   mXenInfo.VersionMajor = (UINT16)(XenVersion >> 16);
   mXenInfo.VersionMinor = (UINT16)(XenVersion & 0xFFFF);
 
-  /* TBD: Locate hvm_info and reserve it away. */
-  mXenInfo.HvmInfo = NULL;
+  //
+  // Check if there are information left by hvmloader
+  //
+
+  Info = (EFI_XEN_OVMF_INFO *)(UINTN) OVMF_INFO_PHYSICAL_ADDRESS;
+  // Copy the signature, and make it null-terminated.
+  AsciiStrnCpyS(Sig, sizeof (Sig),
+                (CHAR8 *) &Info->Signature, sizeof (Info->Signature));
+  if (AsciiStrCmp (Sig, "XenHVMOVMF") == 0) {
+    mXenHvmloaderInfo = Info;
+  } else {
+    mXenHvmloaderInfo = NULL;
+  }
 
   BuildGuidDataHob (
     &gEfiXenInfoGuid,
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#11 lore raw

PATCH v2 11/31 OvmfPkg/XenPlatformPei: Use mXenHvmloaderInfo to get E820

In reply to Anthony PERARD

Use the already checked pointer mXenHvmloaderInfo to retrieve the E820 table produced by hvmloader.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenPlatformPei/Xen.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
OvmfPkg/XenPlatformPei/Xen.c +9 -9
index a866641b67..df906b6be5 100644
@@ -59,18 +59,18 @@ XenGetE820Map (
   UINT32 *Count
   )
 {
-  EFI_XEN_OVMF_INFO *Info =
-    (EFI_XEN_OVMF_INFO *)(UINTN) OVMF_INFO_PHYSICAL_ADDRESS;
+  //
+  // Get E820 produced by hvmloader
+  //
+  if (mXenHvmloaderInfo != NULL) {
+    ASSERT (mXenHvmloaderInfo->E820 < MAX_ADDRESS);
+    *Entries = (EFI_E820_ENTRY64 *)(UINTN) mXenHvmloaderInfo->E820;
+    *Count = mXenHvmloaderInfo->E820EntriesCount;
 
-  if (AsciiStrCmp ((CHAR8 *) Info->Signature, "XenHVMOVMF")) {
-    return EFI_NOT_FOUND;
+    return EFI_SUCCESS;
   }
 
-  ASSERT (Info->E820 < MAX_ADDRESS);
-  *Entries = (EFI_E820_ENTRY64 *)(UINTN) Info->E820;
-  *Count = Info->E820EntriesCount;
-
-  return EFI_SUCCESS;
+  return EFI_NOT_FOUND;
 }
 
 /**
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#12 lore raw

PATCH v2 12/31 OvmfPkg/XenPlatformPei: Grab RSDP from PVH guest start of day struct

In reply to Anthony PERARD

Check if there's a start of the day struct provided to PVH guest, save the ACPI RSDP address for later.

This patch import import arch-x86/hvm/start_info.h from xen.git.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenPlatformPei/XenPlatformPei.inf                      |   3 +
 OvmfPkg/Include/Guid/XenInfo.h                                 |   4 +
 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/hvm/start_info.h | 159 ++++++++++++++++++++
 OvmfPkg/XenPlatformPei/Xen.c                                   |  26 ++++
 4 files changed, 192 insertions(+)
OvmfPkg/XenPlatformPei/XenPlatformPei.inf +3 -0
index c8d25c115f..1870e39208 100644
@@ -91,6 +91,9 @@ [Pcd]
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy
   gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
 
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenStartOfDayStructPtr
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenStartOfDayStructPtrSize
+
 [FixedPcd]
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
 
OvmfPkg/Include/Guid/XenInfo.h +4 -0
index 5d4579f244..d9c09080bb 100644
@@ -31,6 +31,10 @@ typedef struct {
   /// Hypervisor minor version.
   ///
   UINT16 VersionMinor;
+  ///
+  /// Pointer to the RSDP found in the hvm_start_info provided to a PVH guest
+  ///
+  VOID *RsdpPvh;
 } EFI_XEN_INFO;
 
 extern EFI_GUID gEfiXenInfoGuid;
OvmfPkg/Include/IndustryStandard/Xen/arch-x86/hvm/start_info.h new file +159 -0

159 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Xen.c +26 -0
index df906b6be5..fb01094ba9 100644
@@ -31,6 +31,7 @@
 #include <IndustryStandard/E820.h>
 #include <Library/ResourcePublicationLib.h>
 #include <Library/MtrrLib.h>
+#include <IndustryStandard/Xen/arch-x86/hvm/start_info.h>
 
 #include "Platform.h"
 #include "Xen.h"
@@ -92,6 +93,7 @@ XenConnect (
   UINT32 XenVersion;
   EFI_XEN_OVMF_INFO *Info;
   CHAR8 Sig[sizeof (Info->Signature) + 1];
+  UINT32 *PVHResetVectorData;
 
   AsmCpuid (XenLeaf + 2, &TransferPages, &TransferReg, NULL, NULL);
   mXenInfo.HyperPages = AllocatePages (TransferPages);
@@ -125,6 +127,30 @@ XenConnect (
     mXenHvmloaderInfo = NULL;
   }
 
+  mXenInfo.RsdpPvh = NULL;
+
+  //
+  // Locate and use information from the start of day structure if we have
+  // booted via the PVH entry point.
+  //
+
+  PVHResetVectorData = (VOID *)(UINTN) PcdGet32(PcdXenStartOfDayStructPtr);
+  //
+  // That magic value is "XPVH", and it is written in
+  // XenResetVector/Ia32/XenPVHMain.asm
+  //
+  if (PVHResetVectorData[1] == 0x48565058) {
+    struct hvm_start_info *HVMStartInfo;
+
+    HVMStartInfo = (VOID *)(UINTN) PVHResetVectorData[0];
+    if (HVMStartInfo->magic == XEN_HVM_START_MAGIC_VALUE) {
+      ASSERT (HVMStartInfo->rsdp_paddr != 0);
+      if (HVMStartInfo->rsdp_paddr != 0) {
+        mXenInfo.RsdpPvh = (VOID *)(UINTN)HVMStartInfo->rsdp_paddr;
+      }
+    }
+  }
+
   BuildGuidDataHob (
     &gEfiXenInfoGuid,
     &mXenInfo,
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#13 lore raw

PATCH v2 13/31 OvmfPkg/Library/XenPlatformLib: New library

In reply to Anthony PERARD

The purpose of XenPlatformPei is to regroup the few functions that are used in several places to detect if Xen is detected, and to get the XenInfo HOB.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenOvmf.dsc                                                                                       |  1 +
 MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf => OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf | 27 +++----
 OvmfPkg/Include/Library/XenPlatformLib.h                                                                  | 59 +++++++++++++++
 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c                                                           | 75 ++++++++++++++++++++
 4 files changed, 150 insertions(+), 12 deletions(-)
OvmfPkg/XenOvmf.dsc +1 -0
index cc51bac3be..9529b4834f 100644
@@ -198,6 +198,7 @@ [LibraryClasses]
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
   XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
+  XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
 
   Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
 
OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf renamed from MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf +15 -12
similarity index 56%
copy from MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
copy to OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
index 4fd4874595..ca078f7263 100644
@@ -1,7 +1,10 @@
 ## @file
-# Null implementation of the SMBUS Library.
+#  Get information about Xen
 #
-# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
+#  This library simply allow to find out if OVMF is running under Xen and
+#  allow to get more information when it is the case.
+#
+#  Copyright (c) 2019, Citrix Systems, Inc.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -10,26 +13,26 @@
 #  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
+#
 ##
 
 [Defines]
   INF_VERSION                    = 0x00010005
-  BASE_NAME                      = BaseSmbusLibNull
-  MODULE_UNI_FILE                = BaseSmbusLibNull.uni
-  FILE_GUID                      = E2ECA273-A1C0-407E-9A5C-F10C55142196
+  BASE_NAME                      = XenPlatformLib
+  FILE_GUID                      = DB54DBB7-8142-4EE5-9364-78C824B582EB
   MODULE_TYPE                    = BASE
   VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = SmbusLib
-
-#
-#  VALID_ARCHITECTURES           = IA32 X64 EBC
-#
+  LIBRARY_CLASS                  = XenPlatformLib
 
 [Sources]
-  BaseSmbusLibNull.c
+  XenPlatformLib.c
 
 [Packages]
   MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
-  DebugLib
+  HobLib
+
+[Guids]
+  gEfiXenInfoGuid
OvmfPkg/Include/Library/XenPlatformLib.h new file +59 -0

59 lines not on this page · raw message

OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c new file +75 -0

75 lines not on this page · raw message

Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#14 lore raw

PATCH v2 14/31 OvmfPkg/AcpiPlatformDxe: Use PVH RSDP if exist

In reply to Anthony PERARD

If the firmware have been started via the PVH entry point, a RSDP pointer would have been provided. Use it.

Also, use XenDetect() from the new XenPlatformLib.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/OvmfPkgIa32.dsc                     |  1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                  |  1 +
 OvmfPkg/OvmfPkgX64.dsc                      |  1 +
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf |  2 +-
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h      |  6 +--
 OvmfPkg/AcpiPlatformDxe/Xen.c               | 41 ++++++++------------
 6 files changed, 22 insertions(+), 30 deletions(-)
OvmfPkg/OvmfPkgIa32.dsc +1 -0
index f55ab5a3d2..cab9764cab 100644
@@ -205,6 +205,7 @@ [LibraryClasses]
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
   XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
+  XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
 
 !if $(TPM2_ENABLE) == TRUE
   Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
OvmfPkg/OvmfPkgIa32X64.dsc +1 -0
index 5c9bdf034e..a156358690 100644
@@ -210,6 +210,7 @@ [LibraryClasses]
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
   XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
+  XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
 
 !if $(TPM2_ENABLE) == TRUE
   Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
OvmfPkg/OvmfPkgX64.dsc +1 -0
index 2943e9e8af..9d8dc442b4 100644
@@ -210,6 +210,7 @@ [LibraryClasses]
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
   XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
+  XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
 
 !if $(TPM2_ENABLE) == TRUE
   Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf +1 -1
index 8440e7b343..ca54a3bd9e 100644
@@ -51,13 +51,13 @@ [LibraryClasses]
   DebugLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
-  HobLib
   QemuFwCfgLib
   QemuFwCfgS3Lib
   MemoryAllocationLib
   BaseLib
   DxeServicesTableLib
   OrderedCollectionLib
+  XenPlatformLib
 
 [Protocols]
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED
OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h +1 -5
index 83b981ee00..85f37128dd 100644
@@ -25,6 +25,7 @@
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/DebugLib.h>
 #include <Library/PcdLib.h>
+#include <Library/XenPlatformLib.h>
 
 #include <IndustryStandard/Acpi.h>
 
@@ -58,11 +59,6 @@ QemuInstallAcpiTable (
   OUT  UINTN                         *TableKey
   );
 
-BOOLEAN
-XenDetected (
-  VOID
-  );
-
 EFI_STATUS
 EFIAPI
 InstallXenTables (
OvmfPkg/AcpiPlatformDxe/Xen.c +17 -24

63 lines not on this page · raw message

Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#15 lore raw

PATCH v2 15/31 OvmfPkg/XenHypercallLib: Enable it in PEIM

In reply to Anthony PERARD

Allow to use Xen hypercalls earlier, during the PEIM stage, but XenHypercallLibReInit() must be called once the XenInfo HOB is created with the HyperPage setup.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf |  2 +-
 OvmfPkg/XenPlatformPei/XenPlatformPei.inf           |  1 +
 OvmfPkg/Include/Library/XenHypercallLib.h           | 12 ++++++++++++
 OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c   | 11 +++++++++++
 OvmfPkg/XenPlatformPei/Xen.c                        |  7 +++++++
 5 files changed, 32 insertions(+), 1 deletion(-)
OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf +1 -1
index d268e540fe..e0a1889171 100644
@@ -21,7 +21,7 @@ [Defines]
   CONSTRUCTOR                    = XenHypercallLibInit
 
 [Defines.IA32, Defines.X64]
-  LIBRARY_CLASS                  = XenHypercallLib|DXE_DRIVER UEFI_DRIVER
+  LIBRARY_CLASS                  = XenHypercallLib|PEIM DXE_DRIVER UEFI_DRIVER
 
 [Defines.ARM, Defines.AARCH64]
   LIBRARY_CLASS                  = XenHypercallLib
OvmfPkg/XenPlatformPei/XenPlatformPei.inf +1 -0
index 1870e39208..bc6065a709 100644
@@ -66,6 +66,7 @@ [LibraryClasses]
   MtrrLib
   MemEncryptSevLib
   PcdLib
+  XenHypercallLib
 
 [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
OvmfPkg/Include/Library/XenHypercallLib.h +12 -0
index 36e3344e2f..38e64ab108 100644
@@ -16,6 +16,18 @@
 #ifndef __XEN_HYPERCALL_LIB_H__
 #define __XEN_HYPERCALL_LIB_H__
 
+/**
+  To call when the gEfiXenInfoGuid HOB became available after the library init
+  function has already been executed.
+
+  This allow to make hypercall in the PEIM stage.
+**/
+VOID
+EFIAPI
+XenHypercallLibReInit (
+  VOID
+  );
+
 /**
   Check if the Xen Hypercall library is able to make calls to the Xen
   hypervisor.
OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c +11 -0
index 7cb7f46c9b..2ac7254759 100644
@@ -78,6 +78,17 @@ XenHypercallLibInit (
   return RETURN_SUCCESS;
 }
 
+VOID
+EFIAPI
+XenHypercallLibReInit (
+  VOID
+  )
+{
+  if (HyperPage == NULL) {
+    XenHypercallLibInit();
+  }
+}
+
 /**
   This function will put the two arguments in the right place (registers) and
   invoke the hypercall identified by HypercallID.
OvmfPkg/XenPlatformPei/Xen.c +7 -0
index fb01094ba9..9d9e9f8020 100644
@@ -32,6 +32,7 @@
 #include <Library/ResourcePublicationLib.h>
 #include <Library/MtrrLib.h>
 #include <IndustryStandard/Xen/arch-x86/hvm/start_info.h>
+#include <Library/XenHypercallLib.h>
 
 #include "Platform.h"
 #include "Xen.h"
@@ -157,6 +158,12 @@ XenConnect (
     sizeof(mXenInfo)
     );
 
+  //
+  // Initialize the XenHypercall library, now that the XenInfo HOB is
+  // available
+  //
+  XenHypercallLibReInit ();
+
   return EFI_SUCCESS;
 }
 
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#16 lore raw

PATCH v2 16/31 OvmfPkg/XenPlatformPei: Introduce XenHvmloaderDetected

In reply to Anthony PERARD

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenPlatformPei/Platform.h | 5 +++++
 OvmfPkg/XenPlatformPei/Xen.c      | 7 +++++++
 2 files changed, 12 insertions(+)
OvmfPkg/XenPlatformPei/Platform.h +5 -0
index 6ccd5eb66c..5565d47e34 100644
@@ -95,6 +95,11 @@ XenDetect (
   VOID
   );
 
+BOOLEAN
+XenHvmloaderDetected (
+  VOID
+  );
+
 VOID
 AmdSevInitialize (
   VOID
OvmfPkg/XenPlatformPei/Xen.c +7 -0
index 9d9e9f8020..89933ec3e9 100644
@@ -202,6 +202,13 @@ XenDetect (
   return FALSE;
 }
 
+BOOLEAN
+XenHvmloaderDetected (
+  VOID
+  )
+{
+  return (mXenHvmloaderInfo != NULL);
+}
 
 VOID
 XenPublishRamRegions (
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#17 lore raw

PATCH v2 17/31 OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it as runned

In reply to Anthony PERARD

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenPlatformPei/Xen.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
OvmfPkg/XenPlatformPei/Xen.c +3 -1
index 89933ec3e9..22c7a22c88 100644
@@ -275,7 +275,9 @@ InitializeXen (
   // Reserve away HVMLOADER reserved memory [0xFC000000,0xFD000000).
   // This needs to match HVMLOADER RESERVED_MEMBASE/RESERVED_MEMSIZE.
   //
-  AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000, FALSE);
+  if (XenHvmloaderDetected ()) {
+    AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000, FALSE);
+  }
 
   PcdStatus = PcdSetBoolS (PcdPciDisableBusEnumeration, TRUE);
   ASSERT_RETURN_ERROR (PcdStatus);
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#18 lore raw

PATCH v2 18/31 OvmfPkg/XenPlatformPei: Setup HyperPages earlier

In reply to Anthony PERARD

We are going to need to make an hypercall in order to retreive the E820 table from the hypervisor before been able to setup the memory.

Calling XenConnect earlier will allow to setup the XenHypercallLib earlier to allow to make hypercalls.

While here, add some comments in XenConnect().

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenPlatformPei/Platform.h |  5 +++++
 OvmfPkg/XenPlatformPei/Platform.c |  2 ++
 OvmfPkg/XenPlatformPei/Xen.c      | 23 ++++++++++----------
 3 files changed, 19 insertions(+), 11 deletions(-)
OvmfPkg/XenPlatformPei/Platform.h +5 -0
index 5565d47e34..a524c23a43 100644
@@ -85,6 +85,11 @@ InstallClearCacheCallback (
   VOID
   );
 
+EFI_STATUS
+XenConnect (
+  VOID
+  );
+
 EFI_STATUS
 InitializeXen (
   VOID
OvmfPkg/XenPlatformPei/Platform.c +2 -0
index 2d567a4760..5e6d553ad5 100644
@@ -421,6 +421,8 @@ InitializeXenPlatform (
     CpuDeadLoop ();
   }
 
+  XenConnect ();
+
   BootModeInitialization ();
   AddressWidthInitialization ();
 
OvmfPkg/XenPlatformPei/Xen.c +12 -11
index 22c7a22c88..b36eff524d 100644
@@ -78,14 +78,11 @@ XenGetE820Map (
 /**
   Connects to the Hypervisor.
  
-  @param  XenLeaf     CPUID index used to connect.
-
   @return EFI_STATUS
 
 **/
 EFI_STATUS
 XenConnect (
-  UINT32 XenLeaf
   )
 {
   UINT32 Index;
@@ -96,7 +93,13 @@ XenConnect (
   CHAR8 Sig[sizeof (Info->Signature) + 1];
   UINT32 *PVHResetVectorData;
 
-  AsmCpuid (XenLeaf + 2, &TransferPages, &TransferReg, NULL, NULL);
+  ASSERT (mXenLeaf != 0);
+
+  //
+  // Prepare HyperPages to be able to make hypercalls
+  //
+
+  AsmCpuid (mXenLeaf + 2, &TransferPages, &TransferReg, NULL, NULL);
   mXenInfo.HyperPages = AllocatePages (TransferPages);
   if (!mXenInfo.HyperPages) {
     return EFI_OUT_OF_RESOURCES;
@@ -108,7 +111,11 @@ XenConnect (
                    (Index << EFI_PAGE_SHIFT) + Index);
   }
 
-  AsmCpuid (XenLeaf + 1, &XenVersion, NULL, NULL, NULL);
+  //
+  // Find out the Xen version
+  //
+
+  AsmCpuid (mXenLeaf + 1, &XenVersion, NULL, NULL, NULL);
   DEBUG ((EFI_D_ERROR, "Detected Xen version %d.%d\n",
           XenVersion >> 16, XenVersion & 0xFFFF));
   mXenInfo.VersionMajor = (UINT16)(XenVersion >> 16);
@@ -265,12 +272,6 @@ InitializeXen (
 {
   RETURN_STATUS PcdStatus;
 
-  if (mXenLeaf == 0) {
-    return EFI_NOT_FOUND;
-  }
-
-  XenConnect (mXenLeaf);
-
   //
   // Reserve away HVMLOADER reserved memory [0xFC000000,0xFD000000).
   // This needs to match HVMLOADER RESERVED_MEMBASE/RESERVED_MEMSIZE.
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#19 lore raw

PATCH v2 19/31 OvmfPkg/XenPlatformPei: Introduce XenPvhDetected

In reply to Anthony PERARD

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenPlatformPei/Platform.h |  5 +++++
 OvmfPkg/XenPlatformPei/Xen.c      | 13 +++++++++++++
 2 files changed, 18 insertions(+)
OvmfPkg/XenPlatformPei/Platform.h +5 -0
index a524c23a43..c5a139f016 100644
@@ -105,6 +105,11 @@ XenHvmloaderDetected (
   VOID
   );
 
+BOOLEAN
+XenPvhDetected (
+  VOID
+  );
+
 VOID
 AmdSevInitialize (
   VOID
OvmfPkg/XenPlatformPei/Xen.c +13 -0
index b36eff524d..23ff3102b5 100644
@@ -217,6 +217,19 @@ XenHvmloaderDetected (
   return (mXenHvmloaderInfo != NULL);
 }
 
+BOOLEAN
+XenPvhDetected (
+  VOID
+  )
+{
+  //
+  // This function should only be used after XenConnect
+  //
+  ASSERT (mXenInfo.VersionMajor != 0);
+
+  return mXenHvmloaderInfo == NULL;
+}
+
 VOID
 XenPublishRamRegions (
   VOID
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#20 lore raw

PATCH v2 20/31 OvmfPkg: Import XENMEM_memory_map hypercall to Xen/memory.h

In reply to Anthony PERARD

This is copied over from the public header of the Xen Project, with the type name modified to build on OVMF.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/Include/IndustryStandard/Xen/memory.h | 23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
OvmfPkg/Include/IndustryStandard/Xen/memory.h +23 -0
index 020155962c..b00a87097d 100644
@@ -81,6 +81,29 @@ struct xen_remove_from_physmap {
 typedef struct xen_remove_from_physmap xen_remove_from_physmap_t;
 DEFINE_XEN_GUEST_HANDLE(xen_remove_from_physmap_t);
 
+/*
+ * Returns the pseudo-physical memory map as it was when the domain
+ * was started (specified by XENMEM_set_memory_map).
+ * arg == addr of xen_memory_map_t.
+ */
+#define XENMEM_memory_map           9
+struct xen_memory_map {
+    /*
+     * On call the number of entries which can be stored in buffer. On
+     * return the number of entries which have been stored in
+     * buffer.
+     */
+    UINT32 nr_entries;
+
+    /*
+     * Entries in the buffer are in the same format as returned by the
+     * BIOS INT 0x15 EAX=0xE820 call.
+     */
+    XEN_GUEST_HANDLE(void) buffer;
+};
+typedef struct xen_memory_map xen_memory_map_t;
+DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t);
+
 #endif /* __XEN_PUBLIC_MEMORY_H__ */
 
 /*
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#21 lore raw

PATCH v2 21/31 OvmfPkg/XenPlatformPei: Get E820 table via hypercall ...

In reply to Anthony PERARD

.. when hvmloader haven't runned before OVMF. The only way left to get an E820 table is to ask Xen via an hypercall, the call can only be made once so keep the result cached for later.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenPlatformPei/Xen.c | 46 +++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
OvmfPkg/XenPlatformPei/Xen.c +45 -1
index 23ff3102b5..f8cee671d8 100644
@@ -33,6 +33,7 @@
 #include <Library/MtrrLib.h>
 #include <IndustryStandard/Xen/arch-x86/hvm/start_info.h>
 #include <Library/XenHypercallLib.h>
+#include <IndustryStandard/Xen/memory.h>
 
 #include "Platform.h"
 #include "Xen.h"
@@ -46,6 +47,8 @@ EFI_XEN_INFO mXenInfo;
 // Only the E820 table is used by OVMF.
 //
 EFI_XEN_OVMF_INFO *mXenHvmloaderInfo;
+EFI_E820_ENTRY64 E820Entries[128];
+UINT32 E820EntriesCount;
 
 /**
   Returns E820 map provided by Xen
@@ -61,6 +64,12 @@ XenGetE820Map (
   UINT32 *Count
   )
 {
+  INTN ReturnCode;
+  xen_memory_map_t Parameters;
+  UINTN LoopIndex;
+  UINTN Index;
+  EFI_E820_ENTRY64 TmpEntry;
+
   //
   // Get E820 produced by hvmloader
   //
@@ -72,7 +81,42 @@ XenGetE820Map (
     return EFI_SUCCESS;
   }
 
-  return EFI_NOT_FOUND;
+  //
+  // Otherwise, get the E820 table from the Xen hypervisor
+  //
+
+  if (E820EntriesCount > 0) {
+    *Entries = E820Entries;
+    *Count = E820EntriesCount;
+    return EFI_SUCCESS;
+  }
+
+  Parameters.nr_entries = 128;
+  set_xen_guest_handle (Parameters.buffer, E820Entries);
+
+  // Returns a errno
+  ReturnCode = XenHypercallMemoryOp (XENMEM_memory_map, &Parameters);
+  ASSERT (ReturnCode == 0);
+
+  E820EntriesCount = Parameters.nr_entries;
+
+  //
+  // Sort E820 entries
+  //
+  for (LoopIndex = 1; LoopIndex < E820EntriesCount; LoopIndex++) {
+    for (Index = LoopIndex; Index < E820EntriesCount; Index++) {
+      if (E820Entries[Index - 1].BaseAddr > E820Entries[Index].BaseAddr) {
+        TmpEntry = E820Entries[Index];
+        E820Entries[Index] = E820Entries[Index - 1];
+        E820Entries[Index - 1] = TmpEntry;
+      }
+    }
+  }
+
+  *Count = E820EntriesCount;
+  *Entries = E820Entries;
+
+  return EFI_SUCCESS;
 }
 
 /**
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#22 lore raw

PATCH v2 22/31 OvmfPkg/XenPlatformPei: Rework memory detection

In reply to Anthony PERARD

When running as a Xen PVH guest, there is no CMOS to read the memory size from. Rework GetSystemMemorySize(Below|Above)4gb() so they can works without CMOS by reading the e820 table.

Rework XenPublishRamRegions for PVH, handle the Reserve type and explain about the ACPI type. MTRR settings aren't modified anymore, on HVM, it's already done by hvmloader, on PVH it is supposed to have sane default.

Contributed-under: TianoCore Contribution Agreement 1.1

---

Notes:
About MTRR, should we redo the setting in OVMF? Even if in both case of PVH and HVM, something would have setup the default type to write back and handle a few other ranges like PCI hole, hvmloader for HVM or and libxc I think for PVH.

(For PVH, it's in the spec as well
https://xenbits.xenproject.org/docs/unstable/misc/pvh.html#mtrr )

 OvmfPkg/XenPlatformPei/Platform.h  |  6 ++
 OvmfPkg/XenPlatformPei/MemDetect.c | 71 ++++++++++++++++++++
 OvmfPkg/XenPlatformPei/Xen.c       | 47 +++++++++----
 3 files changed, 111 insertions(+), 13 deletions(-)
OvmfPkg/XenPlatformPei/Platform.h +6 -0
index c5a139f016..d6d93eab2d 100644
@@ -120,6 +120,12 @@ XenPublishRamRegions (
   VOID
   );
 
+EFI_STATUS
+XenGetE820Map (
+  EFI_E820_ENTRY64 **Entries,
+  UINT32 *Count
+  );
+
 extern EFI_BOOT_MODE mBootMode;
 
 extern UINT8 mPhysMemAddressWidth;
OvmfPkg/XenPlatformPei/MemDetect.c +71 -0

89 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Xen.c +34 -13

66 lines not on this page · raw message

Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#23 lore raw

PATCH v2 23/31 OvmfPkg/XenPlatformPei: Reserve VGA memory region, to boot Linux

In reply to Anthony PERARD

Linux panic if this region isn't reserved.

When Linux is booted on EFI system, it expects the memory at 0xa0000 to _not_ be conventional memory. Otherwise a variable isn't initialised properly and Linux panic when a virtual console/terminal is asked to be created.

See for more detail:
https://lists.xenproject.org/archives/html/xen-devel/2019-03/msg02139.html

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenPlatformPei/Xen.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
OvmfPkg/XenPlatformPei/Xen.c +16 -0
index 7b503f2c4e..25f12c2f9c 100644
@@ -294,6 +294,12 @@ XenPublishRamRegions (
   Status = XenGetE820Map (&E820Map, &E820EntriesCount);
   ASSERT_EFI_ERROR (Status);
 
+  AddMemoryBaseSizeHob (0, 0xA0000);
+  //
+  // Video memory + Legacy BIOS region, to allow Linux to boot.
+  //
+  AddReservedMemoryBaseSizeHob (0xA0000, BASE_1MB - 0xA0000, TRUE);
+
   for (Index = 0; Index < E820EntriesCount; Index++) {
     UINT64 Base;
     UINT64 End;
@@ -307,6 +313,16 @@ XenPublishRamRegions (
     Base = ALIGN_VALUE (Entry->BaseAddr, (UINT64)EFI_PAGE_SIZE);
     End = (Entry->BaseAddr + Entry->Length) & ~(UINT64)EFI_PAGE_MASK;
 
+    //
+    // Ignore the first 1MB, this is handled before the loop.
+    //
+    if (Base < BASE_1MB) {
+      Base = BASE_1MB;
+    }
+    if (Base >= End) {
+      continue;
+    }
+
     switch (Entry->Type) {
     case EfiAcpiAddressRangeMemory:
       AddMemoryRangeHob (Base, End);
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#24 lore raw

PATCH v2 24/31 OvmfPkg/XenPlatformPei: Ignore missing PCI Host Bridge on Xen PVH

In reply to Anthony PERARD

When the device ID of the host bridge is unknown, check if we are running as a PVH guest as there is no PCI bus in that case.

Contributed-under: TianoCore Contribution Agreement 1.1

---

Notes:
v2:
- Use new XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID macro

 OvmfPkg/Include/OvmfPlatforms.h   | 6 ++++++
 OvmfPkg/XenPlatformPei/Platform.c | 7 +++++++
 2 files changed, 13 insertions(+)
OvmfPkg/Include/OvmfPlatforms.h +6 -0
index cc67f40a88..1ce71e18ec 100644
@@ -43,4 +43,10 @@
 //
 #define ACPI_TIMER_OFFSET 0x8
 
+//
+// When running OVMF on a Xen PVH guest there is no PCI,
+// so -1 is return for the Host Bridge Device ID.
+//
+#define XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID 0xFFFF
+
 #endif
OvmfPkg/XenPlatformPei/Platform.c +7 -0
index 5e6d553ad5..d91cd98bf4 100644
@@ -278,6 +278,13 @@ MiscInitialization (
       AcpiEnBit  = ICH9_ACPI_CNTL_ACPI_EN;
       break;
     default:
+      if (XenPvhDetected ()) {
+        //
+        // There is no PCI bus in this case
+        //
+        PcdSet16S (PcdOvmfHostBridgePciDevId, XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID);
+        return;
+      }
       DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
         __FUNCTION__, mHostBridgeDevId));
       ASSERT (FALSE);
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#25 lore raw

PATCH v2 25/31 OvmfPkg/PlatformBootManagerLib: Handle the absence of PCI bus on Xen PVH

In reply to Anthony PERARD

When running on PVH without PCI bus, the XenPlatformPei will set PcdOvmfHostBridgePciDevId to XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 5 +++++
 1 file changed, 5 insertions(+)
OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +5 -0
index 12303fb0f1..1a6d47732e 100644
@@ -1213,6 +1213,11 @@ PciAcpiInitialization (
       PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6a), 0x0b); // G
       PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H
       break;
+    case XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID:
+      //
+      // There are no PCI bus in this case.
+      //
+      return;
     default:
       DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
         __FUNCTION__, mHostBridgeDevId));
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#26 lore raw

PATCH v2 26/31 OvmfPkg/XenOvmf: Override PcdFSBClock to Xen vLAPIC timer frequency

In reply to Anthony PERARD

That value is used by SecPeiDxeTimerLibCpu, the TimerLib implementation. It will also be used by XenTimerDxe.

Contributed-under: TianoCore Contribution Agreement 1.1

---

Notes:
new patch in v2.

 OvmfPkg/XenOvmf.dsc | 3 +++
 1 file changed, 3 insertions(+)
OvmfPkg/XenOvmf.dsc +3 -0
index 9529b4834f..54601c697f 100644
@@ -452,6 +452,9 @@ [PcdsFixedAtBuild]
   # Point to the MdeModulePkg/Application/UiApp/UiApp.inf
   gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
 
+  ## Xen vlapic's frequence is 100 MHz
+  gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000
+
 ################################################################################
 #
 # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#27 lore raw

PATCH v2 27/31 OvmfPkg/XenOvmf: Introduce XenTimerDxe

In reply to Anthony PERARD

"PcAtChipsetPkg/8254TimerDxe" is replaced with a Xen-specific EFI_TIMER_ARCH_PROTOCOL implementation. Also remove 8259InterruptControllerDxe as it is not used anymore.

This Timer uses the local APIC timer as time source as it can work on both a Xen PVH guest and an HVM one.

Based on the "PcAtChipsetPkg/8254TimerDxe" implementation.

Contributed-under: TianoCore Contribution Agreement 1.1

---

Notes:
v2:
- Use InitializeApicTimer instead of WriteLocalApicReg
- rework comments (remove many that don't apply)
- remove unused includes, and libs
- have a macro to the timervector.
- cleanup, copyright
- rework calculation of TimerCount, value to be use by the APIC timer
- check for overflow of TimerPeriod, with the apic timer, the period can be up to about 42s on Xen (or even higher by changing the DivideValue).

 OvmfPkg/XenOvmf.dsc                                                              |   3 +-
 OvmfPkg/XenOvmf.fdf                                                              |   3 +-
 PcAtChipsetPkg/8254TimerDxe/8254Timer.inf => OvmfPkg/XenTimerDxe/XenTimerDxe.inf |  27 +++---
 PcAtChipsetPkg/8254TimerDxe/Timer.h => OvmfPkg/XenTimerDxe/XenTimerDxe.h         |  32 +++----
 PcAtChipsetPkg/8254TimerDxe/Timer.c => OvmfPkg/XenTimerDxe/XenTimerDxe.c         | 100 ++++++--------------
 5 files changed, 55 insertions(+), 110 deletions(-)
OvmfPkg/XenOvmf.dsc +1 -2
index 54601c697f..35af05715b 100644
@@ -560,10 +560,9 @@ [Components]
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
 
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
-  PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf
+  OvmfPkg/XenTimerDxe/XenTimerDxe.inf
   UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
   UefiCpuPkg/CpuDxe/CpuDxe.inf
-  PcAtChipsetPkg/8254TimerDxe/8254Timer.inf
   OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
   OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
   MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
OvmfPkg/XenOvmf.fdf +1 -2
index f9e58befd6..d614bdce1d 100644
@@ -284,10 +284,9 @@ [FV.DXEFV]
 INF  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
 INF  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
 INF  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
-INF  PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf
+INF  OvmfPkg/XenTimerDxe/XenTimerDxe.inf
 INF  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
 INF  UefiCpuPkg/CpuDxe/CpuDxe.inf
-INF  PcAtChipsetPkg/8254TimerDxe/8254Timer.inf
 INF  OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
 INF  OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
 INF  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
OvmfPkg/XenTimerDxe/XenTimerDxe.inf renamed from PcAtChipsetPkg/8254TimerDxe/8254Timer.inf +14 -13
similarity index 64%
copy from PcAtChipsetPkg/8254TimerDxe/8254Timer.inf
copy to OvmfPkg/XenTimerDxe/XenTimerDxe.inf
index 46cf01de39..5ad80b9368 100644
@@ -1,7 +1,9 @@
 ## @file
-# 8254 timer driver that provides Timer Arch protocol.
+# Local APIC timer driver that provides Timer Arch protocol.
+#
+# Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2019, Citrix Systems, Inc.
 #
-# Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
 # which accompanies this distribution.  The full text of the license may be found at
@@ -14,9 +16,8 @@
 
 [Defines]
   INF_VERSION                    = 0x00010005
-  BASE_NAME                      = Timer
-  MODULE_UNI_FILE                = Timer.uni
-  FILE_GUID                      = f2765dec-6b41-11d5-8e71-00902707b35e
+  BASE_NAME                      = XenTimerDxe
+  FILE_GUID                      = 52fe8196-f9de-4d07-b22f-51f77a0e7c41
   MODULE_TYPE                    = DXE_DRIVER
   VERSION_STRING                 = 1.0
 
@@ -25,24 +26,24 @@ [Defines]
 [Packages]
   MdePkg/MdePkg.dec
   IntelFrameworkPkg/IntelFrameworkPkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+  OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
   UefiBootServicesTableLib
   BaseLib
   DebugLib
   UefiDriverEntryPoint
-  IoLib
+  LocalApicLib
 
 [Sources]
-  Timer.h
-  Timer.c
+  XenTimerDxe.h
+  XenTimerDxe.c
 
 [Protocols]
   gEfiCpuArchProtocolGuid       ## CONSUMES
-  gEfiLegacy8259ProtocolGuid    ## CONSUMES
   gEfiTimerArchProtocolGuid     ## PRODUCES
-
+[Pcd]
+  gEfiMdePkgTokenSpaceGuid.PcdFSBClock  ## CONSUMES
 [Depex]
-  gEfiCpuArchProtocolGuid AND gEfiLegacy8259ProtocolGuid
-[UserExtensions.TianoCore."ExtraFiles"]
-  TimerExtra.uni
+  gEfiCpuArchProtocolGuid
OvmfPkg/XenTimerDxe/XenTimerDxe.h renamed from PcAtChipsetPkg/8254TimerDxe/Timer.h +12 -20
similarity index 89%
copy from PcAtChipsetPkg/8254TimerDxe/Timer.h
copy to OvmfPkg/XenTimerDxe/XenTimerDxe.h
index 9d70e3aa19..747259c162 100644
@@ -1,7 +1,9 @@
 /** @file
   Private data structures
 
-Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2019, Citrix Systems, Inc.
+
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -17,34 +19,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <PiDxe.h>
 
 #include <Protocol/Cpu.h>
-#include <Protocol/Legacy8259.h>
 #include <Protocol/Timer.h>
 
+#include <Register/LocalApic.h>
+
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/BaseLib.h>
 #include <Library/DebugLib.h>
-#include <Library/IoLib.h>
+#include <Library/LocalApicLib.h>
+#include <Library/PcdLib.h>
 
-//
-// The PCAT 8253/8254 has an input clock at 1.193182 MHz and Timer 0 is
-// initialized as a 16 bit free running counter that generates an interrupt(IRQ0)
-// each time the counter rolls over.
-//
-//   65536 counts
-// ---------------- * 1,000,000 uS/S = 54925.4 uS = 549254 * 100 ns
-//   1,193,182 Hz
-//
-
-//
-// The maximum tick duration for 8254 timer
-//
-#define MAX_TIMER_TICK_DURATION     549254
-//
 // The default timer tick duration is set to 10 ms = 100000 100 ns units
 //
 #define DEFAULT_TIMER_TICK_DURATION 100000
-#define TIMER_CONTROL_PORT          0x43
-#define TIMER0_COUNT_PORT           0x40
+
+//
+// The Timer Vector use for interrupt
+//
+#define LOCAL_APIC_TIMER_VECTOR 32
 
 //
 // Function Prototypes
OvmfPkg/XenTimerDxe/XenTimerDxe.c renamed from PcAtChipsetPkg/8254TimerDxe/Timer.c +27 -73

181 lines not on this page · raw message

Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#28 lore raw

PATCH v2 28/31 OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn

In reply to Anthony PERARD

On a Xen PVH guest, none of the existing serial or console interface works, so we add a new one, based on XenConsoleSerialPortLib, and implemeted via SerialDxe.

That a simple console implementation that can works on both PVH guest and HVM guests, even if it rarely going to be use on HVM.

Have PlatformBootManagerLib look for the new console, when running as a Xen guest.

Contributed-under: TianoCore Contribution Agreement 1.1

---

Notes:
v2:
- Use MdeModulePkg/Universal/SerialDxe instead of something new.
- Have PlatformInitializeConsole() look for it by using the known-in-advance device path for the xen console in the PLATFORM_CONSOLE_CONNECT_ENTRY.

 OvmfPkg/XenOvmf.dsc                                               |  4 ++
 OvmfPkg/XenOvmf.fdf                                               |  1 +
 OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  4 ++
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h              |  1 +
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c              | 10 +++-
 OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c             | 59 ++++++++++++++++++++
 6 files changed, 78 insertions(+), 1 deletion(-)
OvmfPkg/XenOvmf.dsc +4 -0
index 35af05715b..a26f611058 100644
@@ -599,6 +599,10 @@ [Components]
   OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
   OvmfPkg/XenBusDxe/XenBusDxe.inf
   OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
+  MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {
+    <LibraryClasses>
+      SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf
+  }
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
OvmfPkg/XenOvmf.fdf +1 -0
index d614bdce1d..e078c7b405 100644
@@ -298,6 +298,7 @@ [FV.DXEFV]
 INF  OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
 INF  OvmfPkg/XenBusDxe/XenBusDxe.inf
 INF  OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
+INF  MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
 
 INF  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 INF  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +4 -0
index c41aaeef3f..7dd0683cd2 100644
@@ -67,6 +67,10 @@ [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate         ## CONSUMES
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits         ## CONSUMES
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity           ## CONSUMES
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits         ## CONSUMES
 
 [Pcd.IA32, Pcd.X64]
   gEfiMdePkgTokenSpaceGuid.PcdFSBClock
OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h +1 -0
index 4948ca6518..2ab1a76f6a 100644
@@ -172,6 +172,7 @@ typedef struct {
 #define CONSOLE_IN  BIT1
 #define STD_ERROR   BIT2
 extern PLATFORM_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];
+extern PLATFORM_CONSOLE_CONNECT_ENTRY  gXenPlatformConsole[];
 
 //
 // Platform BDS Functions
OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +9 -1
index 1a6d47732e..f186060f34 100644
@@ -85,6 +85,13 @@ InstallDevicePathCallback (
   VOID
   );
 
+STATIC
+BOOLEAN
+XenDetected (
+  VOID
+  );
+
+
 VOID
 PlatformRegisterFvBootOption (
   EFI_GUID                         *FileGuid,
@@ -404,7 +411,8 @@ PlatformBootManagerBeforeConsole (
   //
   EfiBootManagerDispatchDeferredImages ();
 
-  PlatformInitializeConsole (gPlatformConsole);
+  PlatformInitializeConsole (
+    XenDetected() ? gXenPlatformConsole : gPlatformConsole);
   PcdStatus = PcdSet16S (PcdPlatformBootTimeOut,
                 GetFrontPageTimeoutFromQemu ());
   ASSERT_RETURN_ERROR (PcdStatus);
OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c +59 -0

83 lines not on this page · raw message

Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#29 lore raw

PATCH v2 29/31 OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables

In reply to Anthony PERARD

This "device" use XenIoMmioLib to reserve some space to be use by the Grant Tables.

The call is only done if it is necessary, we simply detect if the guest is probably PVH, as in this case there is currently no PCI bus, and no PCI Xen platform device which would start the XenIoPciDxe and allocate the space for the Grant Tables.

Contributed-under: TianoCore Contribution Agreement 1.1

---

Notes:
v2:
- do allocation in EntryPoint like the other user of XenIoMmioLib.
- allocate memory instead of hardcoded addr.
- cleanup, add copyright
- detect if we are running in PVH mode

 OvmfPkg/XenOvmf.dsc                                                  |  2 ++
 OvmfPkg/XenOvmf.fdf                                                  |  1 +
 OvmfPkg/{XenIoPciDxe/XenIoPciDxe.inf => XenIoPvhDxe/XenIoPvhDxe.inf} | 26 +++++---------
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c                                    | 38 ++++++++++++++++++++
 4 files changed, 49 insertions(+), 18 deletions(-)
OvmfPkg/XenOvmf.dsc +2 -0
index a26f611058..72d6ea8b29 100644
@@ -199,6 +199,7 @@ [LibraryClasses]
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
   XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
   XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
+  XenIoMmioLib|OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.inf
 
   Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
 
@@ -596,6 +597,7 @@ [Components]
       NULL|IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf
 !endif
   }
+  OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
   OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
   OvmfPkg/XenBusDxe/XenBusDxe.inf
   OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
OvmfPkg/XenOvmf.fdf +1 -0
index e078c7b405..9aa998f15f 100644
@@ -295,6 +295,7 @@ [FV.DXEFV]
 INF  MdeModulePkg/Universal/Metronome/Metronome.inf
 INF  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
 
+INF  OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
 INF  OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
 INF  OvmfPkg/XenBusDxe/XenBusDxe.inf
 INF  OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf renamed from OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf +8 -18
similarity index 56%
copy from OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
copy to OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
index b32075a381..985b6d54b7 100644
@@ -1,7 +1,7 @@
 ## @file
-#  Driver for the virtual Xen PCI device
+#  Driver for the XenIo protocol
 #
-#  Copyright (C) 2015, Linaro Ltd.
+#  Copyright (c) 2019, Citrix Systems, Inc.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -15,31 +15,21 @@
 
 [Defines]
   INF_VERSION               = 0x00010005
-  BASE_NAME                 = XenIoPciDxe
-  FILE_GUID                 = cf569f50-de44-4f54-b4d7-f4ae25cda599
+  BASE_NAME                 = XenIoPvhDxe
+  FILE_GUID                 = 7a567cc4-0e75-4d7a-a305-c3db109b53ad
   MODULE_TYPE               = UEFI_DRIVER
   VERSION_STRING            = 1.0
-  ENTRY_POINT               = XenIoPciDeviceEntryPoint
+  ENTRY_POINT               = InitializeXenIoPvhDxe
 
 [Packages]
   MdePkg/MdePkg.dec
   OvmfPkg/OvmfPkg.dec
 
 [Sources]
-  XenIoPciDxe.c
+  XenIoPvhDxe.c
 
 [LibraryClasses]
   UefiDriverEntryPoint
-  UefiBootServicesTableLib
   MemoryAllocationLib
-  BaseMemoryLib
-  BaseLib
-  UefiLib
-  DebugLib
-
-[Protocols]
-  gEfiDriverBindingProtocolGuid
-  gEfiPciIoProtocolGuid
-  gEfiComponentName2ProtocolGuid
-  gEfiComponentNameProtocolGuid
-  gXenIoProtocolGuid
+  XenIoMmioLib
+  XenPlatformLib
OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c new file +38 -0
new file mode 100644
index 0000000000..f2113b768c
@@ -0,0 +1,38 @@
+/** @file
+
+  Driver for the XenIo protocol
+
+  This driver simply allocate space for the grant tables.
+
+  Copyright (c) 2019, Citrix Systems, Inc.
+
+  This program and the accompanying materials are licensed and made available
+  under the terms and conditions of the BSD License which accompanies this
+  distribution. The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Library/MemoryAllocationLib.h>
+#include <Library/XenIoMmioLib.h>
+#include <Library/XenPlatformLib.h>
+
+EFI_STATUS
+EFIAPI
+InitializeXenIoPvhDxe (
+  IN EFI_HANDLE       ImageHandle,
+  IN EFI_SYSTEM_TABLE *SystemTable
+  )
+{
+  if (XenPvhDetected ()) {
+    EFI_HANDLE Handle;
+
+    Handle = NULL;
+    return XenIoMmioInstall (&Handle, (UINTN) AllocateReservedPages (4));
+  }
+
+  return EFI_SUCCESS;
+}
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#30 lore raw

PATCH v2 30/31 OvmfPkg: Move XenRealTimeClockLib from ArmVirtPkg

In reply to Anthony PERARD

So it can be used from the OvmfPkg by the following patch, "OvmfPkg/XenOvmf: use RealTimeClockRuntimeDxe from EmbeddedPkg"

Contributed-under: TianoCore Contribution Agreement 1.1

---
 ArmVirtPkg/ArmVirtXen.dsc                                                   | 2 +-
 {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf | 0
 {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.c   | 0
 3 files changed, 1 insertion(+), 1 deletion(-)
ArmVirtPkg/ArmVirtXen.dsc +1 -1
index a3688ae2cb..d5d8d79561 100644
@@ -33,7 +33,7 @@ [Defines]
 
 [LibraryClasses]
   SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf
-  RealTimeClockLib|ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf
+  RealTimeClockLib|OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf
   XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
 
   ArmGenericTimerCounterLib|ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf renamed from ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf +0 -0
similarity index 100%
rename from ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf
rename to OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf
OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c renamed from ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c +0 -0
similarity index 100%
rename from ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
rename to OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#31 lore raw

PATCH v2 31/31 OvmfPkg/XenOvmf: use RealTimeClockRuntimeDxe from EmbeddedPkg

In reply to Anthony PERARD

A Xen PVH guest doesn't have a RTC that OVMF would expect, so PcatRealTimeClockRuntimeDxe fails to initialize and prevent the firmware from finish to boot. To prevent that, we will use the XenRealTimeClockLib from ArmVirtPkg which simply always return the same time. This will work on both Xen PVH and HVM guests.

Contributed-under: TianoCore Contribution Agreement 1.1

---
 OvmfPkg/XenOvmf.dsc | 5 ++++-
 OvmfPkg/XenOvmf.fdf | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
OvmfPkg/XenOvmf.dsc +4 -1
index 72d6ea8b29..14ef9ea9f2 100644
@@ -577,7 +577,10 @@ [Components]
   }
   MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
   MdeModulePkg/Universal/Metronome/Metronome.inf
-  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
+  EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {
+    <LibraryClasses>
+      RealTimeClockLib|OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf
+  }
   MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
   MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {
     <LibraryClasses>
OvmfPkg/XenOvmf.fdf +1 -1
index 9aa998f15f..1b62da2ec5 100644
@@ -293,7 +293,7 @@ [FV.DXEFV]
 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  EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
 
 INF  OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
 INF  OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#32 lore raw
In reply to Anthony PERARD
Quoted 7 lines · Anthony PERARD

Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/ovmf.git br.platform-xen-pvh-v2

Hi,

I've started to create a Xen specific platform, in OvmfPkg/XenOvmf.dsc with the goal to make it work on both Xen HVM and Xen PVH.

The previous version of this feature dates back to Dec 2016 / Jan 2017; I haven't forgotten about it, and I'm happy that you are adding the feature as a separate platform DSC, as I requested.

Quoted 7 lines

The first few patches only create the platform and duplicate some code from OvmfPkg and the later patches makes OVMF boot in a Xen PVH guest and can boot a Linux guest.

After this patch series, I'd like to wait a bit before removing Xen support from the OvmfPkg*.dsc, to allow time to switch to the new Xen only platform, maybe 1 year.

I welcome this proposal very much. This will eliminate a significant amount of complexity in the current modules, allow for easier-to-understand maintenance assignments/responsibilities, and pave the way for features that are unique to either Xen or QEMU (in particular in the variable storage area, for which Xen has just received a dedicated userspace daemon IIRC, and for which -- on QEMU -- I had attempted to make pflash a conditional hard requirement, in the past, but failed due to OvmfPkg*.dsc targeting Xen too).

Quoted 4 lines

Question:

Should we start moving these to a different *Pkg? Like it's done for ArmPkg and ArmVirtPkg? Maybe XenPkg.

I'm pretty happy with the current package structure. ArmPkg is for both physical and virtual hardware. ArmVirtPkg is virt-only, and we already have separate platform DSCs/FDFs between Xen (ArmVirtXen) and QEMU/KVM (ArmVirtQemu[Kernel]). Xen- and QEMU/KVM-specific drivers and library instances peacefully coexist under ArmVirtPkg; the DSCs/FDFs include them as appropriate.

The same should map nicely to OvmfPkg. x86 stuff that targets both physical and virtual hardware belongs under PcAtChipsetPkg and UefiCpuPkg. Virt-only stuff should go under OvmfPkg; Xen-specific and QEMU/KVM-specific modules can coexist under OvmfPkg. It's sufficient if the platform DSCs cherry-pick them as appropriate.

And, if there are Xen-specific (but not arch-specific) PEIMs / drivers / libraries that work alike on ARM and x86, they should go under OvmfPkg, as ArmVirtPkg can (and already does) pull Xen-only modules from OvmfPkg. See for example, in ArmVirtXen.dsc:

SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf

OvmfPkg/XenBusDxe/XenBusDxe.inf
OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf

Quoted 3 lines

To build and boot:

To build, simply run OvmfPkg/build.sh -p OvmfPkg/XenOvmf.dsc

(1) To stick with the ArmVirt pattern, we should initially call this platform OvmfXen.

(2) And, once you remove the Xen bits from the current OvmfPkg*.dsc files, we should likely rename those to OvmfQemu*dsc.

I'll try to process this series in a timely manner. My main focus will be possible regressions on QEMU/KVM, and formalities (license blocks, signoffs, edk2 coding style, build issues that I might notice in review).

I can't provide testing feedback, but xen-devel subscribers (and any other Xen users too, obviously) are super welcome to test & report results!

(3) Please file a BZ at <https://bugzilla.tianocore.org/> about this feature, and assign it to yourself. The BZ should keep track of all versions of the patch series (from the mailing list archive).

(4) Ideally, the release notes for the edk2 stable release in which the feature will appear, should mention the feature (via linking the BZ):
<https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Planning#proposed-features>

(5) The BZ should be referenced in all the commit messages.

(6) The new edk2 development mailing list is at:

https://edk2.groups.io/g/devel

Please subscribe there, and resend this series to that address, i.e. <[email protected]>. I'm CC'ing the new address myself, for this initial response, but I'd prefer the rest of my comments to go only to the new list (without manually updating the CC list on every response).

Thanks!
Laszlo

Quoted 122 lines

Then use OVMF.fd as a kernel of a pvh guest config file (with xl/libxl).

Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/ovmf.git br.platform-xen-pvh-v2

Anthony PERARD (31):
OvmfPkg/ResetSystemLib: Add missing dependency on PciLib
OvmfPkg: Create platform XenOvmf
OvmfPkg: Introduce XenResetVector
OvmfPkg: Introduce XenPlatformPei
OvmfPkg/XenOvmf: Creating an ELF header OvmfPkg/XenResetVector: Add new entry point for Xen PVH OvmfPkg/XenResetVector: Saving start of day pointer for PVH guests OvmfPkg/XenResetVector: Allow to jumpstart from either hvmloader or
PVH
OvmfPkg/XenOvmf: use a TimerLib instance that depends only on the CPU OvmfPkg/XenPlatformPei: Detect OVMF_INFO from hvmloader OvmfPkg/XenPlatformPei: Use mXenHvmloaderInfo to get E820 OvmfPkg/XenPlatformPei: Grab RSDP from PVH guest start of day struct OvmfPkg/Library/XenPlatformLib: New library OvmfPkg/AcpiPlatformDxe: Use PVH RSDP if exist OvmfPkg/XenHypercallLib: Enable it in PEIM OvmfPkg/XenPlatformPei: Introduce XenHvmloaderDetected OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it as
runned
OvmfPkg/XenPlatformPei: Setup HyperPages earlier OvmfPkg/XenPlatformPei: Introduce XenPvhDetected
OvmfPkg: Import XENMEM_memory_map hypercall to Xen/memory.h OvmfPkg/XenPlatformPei: Get E820 table via hypercall ... OvmfPkg/XenPlatformPei: Rework memory detection OvmfPkg/XenPlatformPei: Reserve VGA memory region, to boot Linux OvmfPkg/XenPlatformPei: Ignore missing PCI Host Bridge on Xen PVH OvmfPkg/PlatformBootManagerLib: Handle the absence of PCI bus on Xen
PVH
OvmfPkg/XenOvmf: Override PcdFSBClock to Xen vLAPIC timer frequency OvmfPkg/XenOvmf: Introduce XenTimerDxe OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn
OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables
OvmfPkg: Move XenRealTimeClockLib from ArmVirtPkg OvmfPkg/XenOvmf: use RealTimeClockRuntimeDxe from EmbeddedPkg

 OvmfPkg/OvmfPkg.dec                                                                                                 |   4 +
 ArmVirtPkg/ArmVirtXen.dsc                                                                                           |   2 +-
 OvmfPkg/OvmfPkgIa32.dsc                                                                                             |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                                                                                          |   1 +
 OvmfPkg/OvmfPkgX64.dsc                                                                                              |   1 +
 OvmfPkg/{OvmfPkgX64.dsc => XenOvmf.dsc}                                                                             | 236 ++------
 OvmfPkg/XenOvmf.fdf                                                                                                 | 561 ++++++++++++++++++++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf                                                                         |   2 +-
 OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf                                                   |   4 +
 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf                                                                   |   1 +
 OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf                                                                 |   2 +-
 ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf => OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf |  30 +-
 {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf                                         |   0
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf                                                                                 |  35 ++
 OvmfPkg/XenPlatformPei/XenPlatformPei.inf                                                                           | 107 ++++
 OvmfPkg/XenResetVector/XenResetVector.inf                                                                           |  46 ++
 OvmfPkg/XenTimerDxe/XenTimerDxe.inf                                                                                 |  49 ++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h                                                                              |   6 +-
 OvmfPkg/Include/Guid/XenInfo.h                                                                                      |   8 +-
 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/hvm/start_info.h                                                      | 159 ++++++
 OvmfPkg/Include/IndustryStandard/Xen/memory.h                                                                       |  23 +
 OvmfPkg/Include/Library/XenHypercallLib.h                                                                           |  12 +
 OvmfPkg/Include/Library/XenPlatformLib.h                                                                            |  59 ++
 OvmfPkg/Include/OvmfPlatforms.h                                                                                     |   6 +
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h                                                                |   1 +
 OvmfPkg/XenPlatformPei/Cmos.h                                                                                       |  58 ++
 OvmfPkg/XenPlatformPei/Platform.h                                                                                   | 135 +++++
 OvmfPkg/{PlatformPei => XenPlatformPei}/Xen.h                                                                       |   0
 OvmfPkg/XenTimerDxe/XenTimerDxe.h                                                                                   | 183 +++++++
 OvmfPkg/AcpiPlatformDxe/Xen.c                                                                                       |  41 +-
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                                                                |  15 +-
 OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c                                                               |  59 ++
 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c                                                                     |   3 +-
 OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c                                                                   |  11 +
 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c                                                                     |  75 +++
 {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.c                                           |   0
 OvmfPkg/PlatformPei/Xen.c                                                                                           |   3 -
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c                                                                                   |  38 ++
 OvmfPkg/XenPlatformPei/AmdSev.c                                                                                     |  70 +++
 OvmfPkg/XenPlatformPei/ClearCache.c                                                                                 | 118 ++++
 OvmfPkg/XenPlatformPei/Cmos.c                                                                                       |  66 +++
 OvmfPkg/XenPlatformPei/Fv.c                                                                                         |  82 +++
 OvmfPkg/XenPlatformPei/MemDetect.c                                                                                  | 498 +++++++++++++++++
 OvmfPkg/XenPlatformPei/Platform.c                                                                                   | 458 ++++++++++++++++
 OvmfPkg/XenPlatformPei/Xen.c                                                                                        | 381 +++++++++++++
 OvmfPkg/XenTimerDxe/XenTimerDxe.c                                                                                   | 361 +++++++++++++
 generate_elf_header.c                                                                                               |  78 +++
 OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm                                                                      | 144 +++++
 OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm                                                                     |  87 +++
 OvmfPkg/XenResetVector/Ia32/Flat32ToFlat64.asm                                                                      |  66 +++
 OvmfPkg/XenResetVector/Ia32/PageTables64.asm                                                                        | 156 ++++++
 OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm                                                                    |  93 ++++
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm                                                                          |  75 +++
 OvmfPkg/XenResetVector/XenResetVector.nasmb                                                                         |  78 +++
 54 files changed, 4526 insertions(+), 262 deletions(-)
 copy OvmfPkg/{OvmfPkgX64.dsc => XenOvmf.dsc} (78%)
 create mode 100644 OvmfPkg/XenOvmf.fdf
 copy ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf => OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf (50%)
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf (100%)
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
 create mode 100644 OvmfPkg/XenPlatformPei/XenPlatformPei.inf
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.inf
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.inf
 create mode 100644 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/hvm/start_info.h
 create mode 100644 OvmfPkg/Include/Library/XenPlatformLib.h
 create mode 100644 OvmfPkg/XenPlatformPei/Cmos.h
 create mode 100644 OvmfPkg/XenPlatformPei/Platform.h
 copy OvmfPkg/{PlatformPei => XenPlatformPei}/Xen.h (100%)
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.h
 create mode 100644 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.c (100%)
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c
 create mode 100644 OvmfPkg/XenPlatformPei/AmdSev.c
 create mode 100644 OvmfPkg/XenPlatformPei/ClearCache.c
 create mode 100644 OvmfPkg/XenPlatformPei/Cmos.c
 create mode 100644 OvmfPkg/XenPlatformPei/Fv.c
 create mode 100644 OvmfPkg/XenPlatformPei/MemDetect.c
 create mode 100644 OvmfPkg/XenPlatformPei/Platform.c
 create mode 100644 OvmfPkg/XenPlatformPei/Xen.c
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.c
Quoted 9 lines
 create mode 100644 generate_elf_header.c
 create mode 100644 OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/Flat32ToFlat64.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/PageTables64.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.nasmb

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#33 lore raw
Quoted 88 lines · Laszlo Ersek
Quoted 7 lines · Anthony PERARD

Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/ovmf.git br.platform-xen-pvh-v2

Hi,

I've started to create a Xen specific platform, in OvmfPkg/XenOvmf.dsc with the goal to make it work on both Xen HVM and Xen PVH.

The previous version of this feature dates back to Dec 2016 / Jan 2017; I haven't forgotten about it, and I'm happy that you are adding the feature as a separate platform DSC, as I requested.

Quoted 7 lines

The first few patches only create the platform and duplicate some code from OvmfPkg and the later patches makes OVMF boot in a Xen PVH guest and can boot a Linux guest.

After this patch series, I'd like to wait a bit before removing Xen support from the OvmfPkg*.dsc, to allow time to switch to the new Xen only platform, maybe 1 year.

I welcome this proposal very much. This will eliminate a significant amount of complexity in the current modules, allow for easier-to-understand maintenance assignments/responsibilities, and pave the way for features that are unique to either Xen or QEMU (in particular in the variable storage area, for which Xen has just received a dedicated userspace daemon IIRC, and for which -- on QEMU -- I had attempted to make pflash a conditional hard requirement, in the past, but failed due to OvmfPkg*.dsc targeting Xen too).

Quoted 4 lines

Question:

Should we start moving these to a different *Pkg? Like it's done for ArmPkg and ArmVirtPkg? Maybe XenPkg.

I'm pretty happy with the current package structure. ArmPkg is for both physical and virtual hardware. ArmVirtPkg is virt-only, and we already have separate platform DSCs/FDFs between Xen (ArmVirtXen) and QEMU/KVM (ArmVirtQemu[Kernel]). Xen- and QEMU/KVM-specific drivers and library instances peacefully coexist under ArmVirtPkg; the DSCs/FDFs include them as appropriate.

The same should map nicely to OvmfPkg. x86 stuff that targets both physical and virtual hardware belongs under PcAtChipsetPkg and UefiCpuPkg. Virt-only stuff should go under OvmfPkg; Xen-specific and QEMU/KVM-specific modules can coexist under OvmfPkg. It's sufficient if the platform DSCs cherry-pick them as appropriate.

And, if there are Xen-specific (but not arch-specific) PEIMs / drivers / libraries that work alike on ARM and x86, they should go under OvmfPkg, as ArmVirtPkg can (and already does) pull Xen-only modules from OvmfPkg. See for example, in ArmVirtXen.dsc:

SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf

OvmfPkg/XenBusDxe/XenBusDxe.inf
OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf

Quoted 3 lines

To build and boot:

To build, simply run OvmfPkg/build.sh -p OvmfPkg/XenOvmf.dsc

(1) To stick with the ArmVirt pattern, we should initially call this platform OvmfXen.

(2) And, once you remove the Xen bits from the current OvmfPkg*.dsc files, we should likely rename those to OvmfQemu*dsc.

I'll try to process this series in a timely manner. My main focus will be possible regressions on QEMU/KVM, and formalities (license blocks, signoffs, edk2 coding style, build issues that I might notice in review).

I can't provide testing feedback, but xen-devel subscribers (and any other Xen users too, obviously) are super welcome to test & report results!

(3) Please file a BZ at <https://bugzilla.tianocore.org/> about this feature, and assign it to yourself. The BZ should keep track of all versions of the patch series (from the mailing list archive).

(4) Ideally, the release notes for the edk2 stable release in which the feature will appear, should mention the feature (via linking the BZ):
<https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Planning#proposed-features>

(5) The BZ should be referenced in all the commit messages.

Quoted 8 lines

(6) The new edk2 development mailing list is at:

https://edk2.groups.io/g/devel

Please subscribe there, and resend this series to that address, i.e. <[email protected]>. I'm CC'ing the new address myself, for this initial response, but I'd prefer the rest of my comments to go only to the new list (without manually updating the CC list on every response).

(7) I forgot to mention that, due to
<https://bugzilla.tianocore.org/show_bug.cgi?id=1373> being very close to being fixed / pushed, the the "Contributed-under" lines near your signoffs will no longer be necessary.

Thanks
Laszlo

Quoted 136 lines

Thanks!
Laszlo

Quoted 131 lines

Then use OVMF.fd as a kernel of a pvh guest config file (with xl/libxl).

Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/ovmf.git br.platform-xen-pvh-v2

Anthony PERARD (31):
OvmfPkg/ResetSystemLib: Add missing dependency on PciLib
OvmfPkg: Create platform XenOvmf
OvmfPkg: Introduce XenResetVector
OvmfPkg: Introduce XenPlatformPei
OvmfPkg/XenOvmf: Creating an ELF header OvmfPkg/XenResetVector: Add new entry point for Xen PVH OvmfPkg/XenResetVector: Saving start of day pointer for PVH guests OvmfPkg/XenResetVector: Allow to jumpstart from either hvmloader or
PVH
OvmfPkg/XenOvmf: use a TimerLib instance that depends only on the CPU OvmfPkg/XenPlatformPei: Detect OVMF_INFO from hvmloader OvmfPkg/XenPlatformPei: Use mXenHvmloaderInfo to get E820 OvmfPkg/XenPlatformPei: Grab RSDP from PVH guest start of day struct OvmfPkg/Library/XenPlatformLib: New library OvmfPkg/AcpiPlatformDxe: Use PVH RSDP if exist OvmfPkg/XenHypercallLib: Enable it in PEIM OvmfPkg/XenPlatformPei: Introduce XenHvmloaderDetected OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it as
runned
OvmfPkg/XenPlatformPei: Setup HyperPages earlier OvmfPkg/XenPlatformPei: Introduce XenPvhDetected
OvmfPkg: Import XENMEM_memory_map hypercall to Xen/memory.h OvmfPkg/XenPlatformPei: Get E820 table via hypercall ... OvmfPkg/XenPlatformPei: Rework memory detection OvmfPkg/XenPlatformPei: Reserve VGA memory region, to boot Linux OvmfPkg/XenPlatformPei: Ignore missing PCI Host Bridge on Xen PVH OvmfPkg/PlatformBootManagerLib: Handle the absence of PCI bus on Xen
PVH
OvmfPkg/XenOvmf: Override PcdFSBClock to Xen vLAPIC timer frequency OvmfPkg/XenOvmf: Introduce XenTimerDxe OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn
OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables
OvmfPkg: Move XenRealTimeClockLib from ArmVirtPkg OvmfPkg/XenOvmf: use RealTimeClockRuntimeDxe from EmbeddedPkg

 OvmfPkg/OvmfPkg.dec                                                                                                 |   4 +
 ArmVirtPkg/ArmVirtXen.dsc                                                                                           |   2 +-
 OvmfPkg/OvmfPkgIa32.dsc                                                                                             |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                                                                                          |   1 +
 OvmfPkg/OvmfPkgX64.dsc                                                                                              |   1 +
 OvmfPkg/{OvmfPkgX64.dsc => XenOvmf.dsc}                                                                             | 236 ++------
 OvmfPkg/XenOvmf.fdf                                                                                                 | 561 ++++++++++++++++++++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf                                                                         |   2 +-
 OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf                                                   |   4 +
 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf                                                                   |   1 +
 OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf                                                                 |   2 +-
 ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf => OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf |  30 +-
 {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf                                         |   0
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf                                                                                 |  35 ++
 OvmfPkg/XenPlatformPei/XenPlatformPei.inf                                                                           | 107 ++++
 OvmfPkg/XenResetVector/XenResetVector.inf                                                                           |  46 ++
 OvmfPkg/XenTimerDxe/XenTimerDxe.inf                                                                                 |  49 ++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h                                                                              |   6 +-
 OvmfPkg/Include/Guid/XenInfo.h                                                                                      |   8 +-
 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/hvm/start_info.h                                                      | 159 ++++++
 OvmfPkg/Include/IndustryStandard/Xen/memory.h                                                                       |  23 +
 OvmfPkg/Include/Library/XenHypercallLib.h                                                                           |  12 +
 OvmfPkg/Include/Library/XenPlatformLib.h                                                                            |  59 ++
 OvmfPkg/Include/OvmfPlatforms.h                                                                                     |   6 +
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h                                                                |   1 +
 OvmfPkg/XenPlatformPei/Cmos.h                                                                                       |  58 ++
 OvmfPkg/XenPlatformPei/Platform.h                                                                                   | 135 +++++
 OvmfPkg/{PlatformPei => XenPlatformPei}/Xen.h                                                                       |   0
 OvmfPkg/XenTimerDxe/XenTimerDxe.h                                                                                   | 183 +++++++
 OvmfPkg/AcpiPlatformDxe/Xen.c                                                                                       |  41 +-
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                                                                |  15 +-
 OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c                                                               |  59 ++
 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c                                                                     |   3 +-
 OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c                                                                   |  11 +
 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c                                                                     |  75 +++
 {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.c                                           |   0
 OvmfPkg/PlatformPei/Xen.c                                                                                           |   3 -
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c                                                                                   |  38 ++
 OvmfPkg/XenPlatformPei/AmdSev.c                                                                                     |  70 +++
 OvmfPkg/XenPlatformPei/ClearCache.c                                                                                 | 118 ++++
 OvmfPkg/XenPlatformPei/Cmos.c                                                                                       |  66 +++
 OvmfPkg/XenPlatformPei/Fv.c                                                                                         |  82 +++
 OvmfPkg/XenPlatformPei/MemDetect.c                                                                                  | 498 +++++++++++++++++
 OvmfPkg/XenPlatformPei/Platform.c                                                                                   | 458 ++++++++++++++++
 OvmfPkg/XenPlatformPei/Xen.c                                                                                        | 381 +++++++++++++
 OvmfPkg/XenTimerDxe/XenTimerDxe.c                                                                                   | 361 +++++++++++++
 generate_elf_header.c                                                                                               |  78 +++
 OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm                                                                      | 144 +++++
 OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm                                                                     |  87 +++
 OvmfPkg/XenResetVector/Ia32/Flat32ToFlat64.asm                                                                      |  66 +++
 OvmfPkg/XenResetVector/Ia32/PageTables64.asm                                                                        | 156 ++++++
 OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm                                                                    |  93 ++++
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm                                                                          |  75 +++
 OvmfPkg/XenResetVector/XenResetVector.nasmb                                                                         |  78 +++
 54 files changed, 4526 insertions(+), 262 deletions(-)
 copy OvmfPkg/{OvmfPkgX64.dsc => XenOvmf.dsc} (78%)
 create mode 100644 OvmfPkg/XenOvmf.fdf
 copy ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf => OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf (50%)
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf (100%)
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
 create mode 100644 OvmfPkg/XenPlatformPei/XenPlatformPei.inf
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.inf
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.inf
 create mode 100644 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/hvm/start_info.h
 create mode 100644 OvmfPkg/Include/Library/XenPlatformLib.h
 create mode 100644 OvmfPkg/XenPlatformPei/Cmos.h
 create mode 100644 OvmfPkg/XenPlatformPei/Platform.h
 copy OvmfPkg/{PlatformPei => XenPlatformPei}/Xen.h (100%)
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.h
 create mode 100644 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.c (100%)
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c
 create mode 100644 OvmfPkg/XenPlatformPei/AmdSev.c
 create mode 100644 OvmfPkg/XenPlatformPei/ClearCache.c
 create mode 100644 OvmfPkg/XenPlatformPei/Cmos.c
 create mode 100644 OvmfPkg/XenPlatformPei/Fv.c
 create mode 100644 OvmfPkg/XenPlatformPei/MemDetect.c
 create mode 100644 OvmfPkg/XenPlatformPei/Platform.c
 create mode 100644 OvmfPkg/XenPlatformPei/Xen.c
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.c
 create mode 100644 generate_elf_header.c
 create mode 100644 OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/Flat32ToFlat64.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/PageTables64.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.nasmb

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#34 lore raw
Quoted 62 lines · Laszlo Ersek
Quoted 61 lines · Laszlo Ersek
Quoted 7 lines · Anthony PERARD

Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/ovmf.git br.platform-xen-pvh-v2

Hi,

I've started to create a Xen specific platform, in OvmfPkg/XenOvmf.dsc with the goal to make it work on both Xen HVM and Xen PVH.

The previous version of this feature dates back to Dec 2016 / Jan 2017; I haven't forgotten about it, and I'm happy that you are adding the feature as a separate platform DSC, as I requested.

Quoted 7 lines

The first few patches only create the platform and duplicate some code from OvmfPkg and the later patches makes OVMF boot in a Xen PVH guest and can boot a Linux guest.

After this patch series, I'd like to wait a bit before removing Xen support from the OvmfPkg*.dsc, to allow time to switch to the new Xen only platform, maybe 1 year.

I welcome this proposal very much. This will eliminate a significant amount of complexity in the current modules, allow for easier-to-understand maintenance assignments/responsibilities, and pave the way for features that are unique to either Xen or QEMU (in particular in the variable storage area, for which Xen has just received a dedicated userspace daemon IIRC, and for which -- on QEMU -- I had attempted to make pflash a conditional hard requirement, in the past, but failed due to OvmfPkg*.dsc targeting Xen too).

Quoted 4 lines

Question:

Should we start moving these to a different *Pkg? Like it's done for ArmPkg and ArmVirtPkg? Maybe XenPkg.

I'm pretty happy with the current package structure. ArmPkg is for both physical and virtual hardware. ArmVirtPkg is virt-only, and we already have separate platform DSCs/FDFs between Xen (ArmVirtXen) and QEMU/KVM (ArmVirtQemu[Kernel]). Xen- and QEMU/KVM-specific drivers and library instances peacefully coexist under ArmVirtPkg; the DSCs/FDFs include them as appropriate.

The same should map nicely to OvmfPkg. x86 stuff that targets both physical and virtual hardware belongs under PcAtChipsetPkg and UefiCpuPkg. Virt-only stuff should go under OvmfPkg; Xen-specific and QEMU/KVM-specific modules can coexist under OvmfPkg. It's sufficient if the platform DSCs cherry-pick them as appropriate.

And, if there are Xen-specific (but not arch-specific) PEIMs / drivers / libraries that work alike on ARM and x86, they should go under OvmfPkg, as ArmVirtPkg can (and already does) pull Xen-only modules from OvmfPkg. See for example, in ArmVirtXen.dsc:

SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf

OvmfPkg/XenBusDxe/XenBusDxe.inf
OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf

Quoted 2 lines

To build and boot:

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

To build, simply run OvmfPkg/build.sh -p OvmfPkg/XenOvmf.dsc

(1) To stick with the ArmVirt pattern, we should initially call this platform OvmfXen.

(2) And, once you remove the Xen bits from the current OvmfPkg*.dsc files, we should likely rename those to OvmfQemu*dsc.

I'm happy to read this simplification suggestion :)

Quoted 174 lines
Quoted 19 lines

I'll try to process this series in a timely manner. My main focus will be possible regressions on QEMU/KVM, and formalities (license blocks, signoffs, edk2 coding style, build issues that I might notice in review).

I can't provide testing feedback, but xen-devel subscribers (and any other Xen users too, obviously) are super welcome to test & report results!

(3) Please file a BZ at <https://bugzilla.tianocore.org/> about this feature, and assign it to yourself. The BZ should keep track of all versions of the patch series (from the mailing list archive).

(4) Ideally, the release notes for the edk2 stable release in which the feature will appear, should mention the feature (via linking the BZ):
<https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Planning#proposed-features>

(5) The BZ should be referenced in all the commit messages.

Quoted 8 lines

(6) The new edk2 development mailing list is at:

https://edk2.groups.io/g/devel

Please subscribe there, and resend this series to that address, i.e. <[email protected]>. I'm CC'ing the new address myself, for this initial response, but I'd prefer the rest of my comments to go only to the new list (without manually updating the CC list on every response).

(7) I forgot to mention that, due to
<https://bugzilla.tianocore.org/show_bug.cgi?id=1373> being very close to being fixed / pushed, the the "Contributed-under" lines near your signoffs will no longer be necessary.

Thanks
Laszlo

Quoted 136 lines

Thanks!
Laszlo

Quoted 131 lines

Then use OVMF.fd as a kernel of a pvh guest config file (with xl/libxl).

Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/ovmf.git br.platform-xen-pvh-v2

Anthony PERARD (31):
OvmfPkg/ResetSystemLib: Add missing dependency on PciLib
OvmfPkg: Create platform XenOvmf
OvmfPkg: Introduce XenResetVector
OvmfPkg: Introduce XenPlatformPei
OvmfPkg/XenOvmf: Creating an ELF header OvmfPkg/XenResetVector: Add new entry point for Xen PVH OvmfPkg/XenResetVector: Saving start of day pointer for PVH guests OvmfPkg/XenResetVector: Allow to jumpstart from either hvmloader or
PVH
OvmfPkg/XenOvmf: use a TimerLib instance that depends only on the CPU OvmfPkg/XenPlatformPei: Detect OVMF_INFO from hvmloader OvmfPkg/XenPlatformPei: Use mXenHvmloaderInfo to get E820 OvmfPkg/XenPlatformPei: Grab RSDP from PVH guest start of day struct OvmfPkg/Library/XenPlatformLib: New library OvmfPkg/AcpiPlatformDxe: Use PVH RSDP if exist OvmfPkg/XenHypercallLib: Enable it in PEIM OvmfPkg/XenPlatformPei: Introduce XenHvmloaderDetected OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it as
runned
OvmfPkg/XenPlatformPei: Setup HyperPages earlier OvmfPkg/XenPlatformPei: Introduce XenPvhDetected
OvmfPkg: Import XENMEM_memory_map hypercall to Xen/memory.h OvmfPkg/XenPlatformPei: Get E820 table via hypercall ... OvmfPkg/XenPlatformPei: Rework memory detection OvmfPkg/XenPlatformPei: Reserve VGA memory region, to boot Linux OvmfPkg/XenPlatformPei: Ignore missing PCI Host Bridge on Xen PVH OvmfPkg/PlatformBootManagerLib: Handle the absence of PCI bus on Xen
PVH
OvmfPkg/XenOvmf: Override PcdFSBClock to Xen vLAPIC timer frequency OvmfPkg/XenOvmf: Introduce XenTimerDxe OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn
OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables
OvmfPkg: Move XenRealTimeClockLib from ArmVirtPkg OvmfPkg/XenOvmf: use RealTimeClockRuntimeDxe from EmbeddedPkg

 OvmfPkg/OvmfPkg.dec                                                                                                 |   4 +
 ArmVirtPkg/ArmVirtXen.dsc                                                                                           |   2 +-
 OvmfPkg/OvmfPkgIa32.dsc                                                                                             |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                                                                                          |   1 +
 OvmfPkg/OvmfPkgX64.dsc                                                                                              |   1 +
 OvmfPkg/{OvmfPkgX64.dsc => XenOvmf.dsc}                                                                             | 236 ++------
 OvmfPkg/XenOvmf.fdf                                                                                                 | 561 ++++++++++++++++++++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf                                                                         |   2 +-
 OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf                                                   |   4 +
 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf                                                                   |   1 +
 OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf                                                                 |   2 +-
 ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf => OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf |  30 +-
 {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf                                         |   0
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf                                                                                 |  35 ++
 OvmfPkg/XenPlatformPei/XenPlatformPei.inf                                                                           | 107 ++++
 OvmfPkg/XenResetVector/XenResetVector.inf                                                                           |  46 ++
 OvmfPkg/XenTimerDxe/XenTimerDxe.inf                                                                                 |  49 ++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h                                                                              |   6 +-
 OvmfPkg/Include/Guid/XenInfo.h                                                                                      |   8 +-
 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/hvm/start_info.h                                                      | 159 ++++++
 OvmfPkg/Include/IndustryStandard/Xen/memory.h                                                                       |  23 +
 OvmfPkg/Include/Library/XenHypercallLib.h                                                                           |  12 +
 OvmfPkg/Include/Library/XenPlatformLib.h                                                                            |  59 ++
 OvmfPkg/Include/OvmfPlatforms.h                                                                                     |   6 +
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h                                                                |   1 +
 OvmfPkg/XenPlatformPei/Cmos.h                                                                                       |  58 ++
 OvmfPkg/XenPlatformPei/Platform.h                                                                                   | 135 +++++
 OvmfPkg/{PlatformPei => XenPlatformPei}/Xen.h                                                                       |   0
 OvmfPkg/XenTimerDxe/XenTimerDxe.h                                                                                   | 183 +++++++
 OvmfPkg/AcpiPlatformDxe/Xen.c                                                                                       |  41 +-
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                                                                |  15 +-
 OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c                                                               |  59 ++
 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c                                                                     |   3 +-
 OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c                                                                   |  11 +
 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c                                                                     |  75 +++
 {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.c                                           |   0
 OvmfPkg/PlatformPei/Xen.c                                                                                           |   3 -
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c                                                                                   |  38 ++
 OvmfPkg/XenPlatformPei/AmdSev.c                                                                                     |  70 +++
 OvmfPkg/XenPlatformPei/ClearCache.c                                                                                 | 118 ++++
 OvmfPkg/XenPlatformPei/Cmos.c                                                                                       |  66 +++
 OvmfPkg/XenPlatformPei/Fv.c                                                                                         |  82 +++
 OvmfPkg/XenPlatformPei/MemDetect.c                                                                                  | 498 +++++++++++++++++
 OvmfPkg/XenPlatformPei/Platform.c                                                                                   | 458 ++++++++++++++++
 OvmfPkg/XenPlatformPei/Xen.c                                                                                        | 381 +++++++++++++
 OvmfPkg/XenTimerDxe/XenTimerDxe.c                                                                                   | 361 +++++++++++++
 generate_elf_header.c                                                                                               |  78 +++
 OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm                                                                      | 144 +++++
 OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm                                                                     |  87 +++
 OvmfPkg/XenResetVector/Ia32/Flat32ToFlat64.asm                                                                      |  66 +++
 OvmfPkg/XenResetVector/Ia32/PageTables64.asm                                                                        | 156 ++++++
 OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm                                                                    |  93 ++++
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm                                                                          |  75 +++
 OvmfPkg/XenResetVector/XenResetVector.nasmb                                                                         |  78 +++
 54 files changed, 4526 insertions(+), 262 deletions(-)
 copy OvmfPkg/{OvmfPkgX64.dsc => XenOvmf.dsc} (78%)
 create mode 100644 OvmfPkg/XenOvmf.fdf
 copy ArmVirtPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf => OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf (50%)
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf (100%)
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
 create mode 100644 OvmfPkg/XenPlatformPei/XenPlatformPei.inf
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.inf
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.inf
 create mode 100644 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/hvm/start_info.h
 create mode 100644 OvmfPkg/Include/Library/XenPlatformLib.h
 create mode 100644 OvmfPkg/XenPlatformPei/Cmos.h
 create mode 100644 OvmfPkg/XenPlatformPei/Platform.h
 copy OvmfPkg/{PlatformPei => XenPlatformPei}/Xen.h (100%)
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.h
 create mode 100644 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.c (100%)
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c
 create mode 100644 OvmfPkg/XenPlatformPei/AmdSev.c
 create mode 100644 OvmfPkg/XenPlatformPei/ClearCache.c
 create mode 100644 OvmfPkg/XenPlatformPei/Cmos.c
 create mode 100644 OvmfPkg/XenPlatformPei/Fv.c
 create mode 100644 OvmfPkg/XenPlatformPei/MemDetect.c
 create mode 100644 OvmfPkg/XenPlatformPei/Platform.c
 create mode 100644 OvmfPkg/XenPlatformPei/Xen.c
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.c
 create mode 100644 generate_elf_header.c
 create mode 100644 OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/Flat32ToFlat64.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/PageTables64.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.nasmb
Quoted 9 lines

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#38693): https://edk2.groups.io/g/devel/message/38693
Mute This Topic: https://groups.io/mt/30964532/1768864
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#35 lore raw
In reply to Laszlo Ersek
Quoted 13 lines · Laszlo Ersek
Quoted 4 lines · Anthony PERARD

Question:

Should we start moving these to a different *Pkg? Like it's done for ArmPkg and ArmVirtPkg? Maybe XenPkg.

I'm pretty happy with the current package structure. ArmPkg is for both physical and virtual hardware. ArmVirtPkg is virt-only, and we already have separate platform DSCs/FDFs between Xen (ArmVirtXen) and QEMU/KVM (ArmVirtQemu[Kernel]). Xen- and QEMU/KVM-specific drivers and library instances peacefully coexist under ArmVirtPkg; the DSCs/FDFs include them as appropriate.

Quoted 5 lines

The same should map nicely to OvmfPkg. x86 stuff that targets both physical and virtual hardware belongs under PcAtChipsetPkg and UefiCpuPkg. Virt-only stuff should go under OvmfPkg; Xen-specific and QEMU/KVM-specific modules can coexist under OvmfPkg. It's sufficient if the platform DSCs cherry-pick them as appropriate.

Thanks for the feedback, that sounds good.

Quoted 6 lines
Quoted 3 lines

To build and boot:

To build, simply run OvmfPkg/build.sh -p OvmfPkg/XenOvmf.dsc

(1) To stick with the ArmVirt pattern, we should initially call this platform OvmfXen.

I'll rename it in v3.

Quoted 3 lines

(3) Please file a BZ at <https://bugzilla.tianocore.org/> about this feature, and assign it to yourself. The BZ should keep track of all versions of the patch series (from the mailing list archive).

Done: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
I'll add the links for the patch series once there is one for v2.

Quoted 1 line

(5) The BZ should be referenced in all the commit messages.

I'll do that in v3.

Quoted 1 line

(6) The new edk2 development mailing list is at:

:-(

Quoted 6 lines

https://edk2.groups.io/g/devel

Please subscribe there, and resend this series to that address, i.e. <[email protected]>. I'm CC'ing the new address myself, for this initial response, but I'd prefer the rest of my comments to go only to the new list (without manually updating the CC list on every response).

I'm about to do that.

Thanks,

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel