Skip to contentSkip to conversation

Specific platform to run OVMF in Xen PVH and HVM guests

PATCH Superseded Anthony PERARD 3 participants 81 messages Jul 29, 2019 – Aug 13, 2019

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#1 lore raw

PATCH v4 1/35 OvmfPkg/ResetSystemLib: Add missing dependency on PciLib

In reply to Anthony PERARD

Add missing dependency on PciLib
and remove extra includes of OvmfPlatforms.h.

---

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 7c44f99a5c..2f24dac87f 100644
@@ -30,4 +30,5 @@ [Packages]
 [LibraryClasses]
   DebugLib
   IoLib
+  PciLib
   TimerLib
OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c +1 -2
index 27460cd100..98dd80e33c 100644
@@ -11,11 +11,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 · 6 lines
Anthony PERARD

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

PATCH v4 9/35 OvmfPkg/OvmfXen: use a TimerLib instance that depends only on the CPU

In reply to Anthony PERARD

The ACPI Timer isn't present in a PVH guest, but local APIC works on both PVH and HVM.

Note that the use of SecPeiDxeTimerLibCpu might be an issue with a driver of type DXE_RUNTIME_DRIVER. I've attempted to find out which of the DXE_RUNTIME_DRIVER uses the TimerLib at runtime. I've done that by replacing the TimerLib evaluation in [LibraryClasses.common.DXE_RUNTIME_DRIVER] by a different one and checking every module that uses it (with the --report-file=report build option).

ResetSystemRuntimeDxe is calling the TimerLib API at runtime to do the operation "EfiResetCold", so this may never complete if the OS have disabled the Local APIC Timer.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- reworded the first sentence, use "not present" instead of "don't work".

v3:
- cleanup .dsc, leave only one TimerLib resolution
- Added a note in the commit message regarding the use of the local apic by runtime drivers

 OvmfPkg/OvmfXen.dsc | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
OvmfPkg/OvmfXen.dsc +1 -6
index 7619a89382..b40d39e003 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
@@ -202,7 +202,6 @@ [LibraryClasses.common]
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
 
 [LibraryClasses.common.SEC]
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
@@ -281,7 +280,6 @@ [LibraryClasses.common.DXE_CORE]
 
 [LibraryClasses.common.DXE_RUNTIME_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -298,7 +296,6 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER]
 
 [LibraryClasses.common.UEFI_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -313,7 +310,6 @@ [LibraryClasses.common.UEFI_DRIVER]
 
 [LibraryClasses.common.DXE_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
@@ -337,7 +333,6 @@ [LibraryClasses.common.DXE_DRIVER]
 
 [LibraryClasses.common.UEFI_APPLICATION]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
Signature · 6 lines
Anthony PERARD

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

v4 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-v4

Changes in v4:
- patch "OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it has run" was removed, and instead a different change is done in "OvmfPkg/XenPlatformPei: Rework memory detection"
- other changes detailed in the notes of each patch

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.

To build and boot:

To build, simply run OvmfPkg/build.sh -p OvmfPkg/OvmfXen.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-v4

Anthony PERARD (35):
OvmfPkg/ResetSystemLib: Add missing dependency on PciLib
OvmfPkg: Create platform OvmfXen
OvmfPkg: Introduce XenResetVector
OvmfPkg: Introduce XenPlatformPei
OvmfPkg/OvmfXen: 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 jumpstart from either hvmloader or PVH OvmfPkg/OvmfXen: 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 XenPlatformLib OvmfPkg/AcpiPlatformDxe: Use Xen PVH RSDP if it exist OvmfPkg/XenHypercallLib: Enable it in PEIM OvmfPkg/XenPlatformPei: Reinit XenHypercallLib OvmfPkg/XenPlatformPei: Introduce XenHvmloaderDetected OvmfPkg/XenPlatformPei: Setup HyperPages earlier OvmfPkg/XenPlatformPei: Introduce XenPvhDetected
OvmfPkg: Import XENMEM_memory_map hypercall to Xen/memory.h OvmfPkg/XenPlatformPei: no hvmloader: get the 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/XenPlatformLib: Cache result for XenDetected OvmfPkg/PlatformBootManagerLib: Use XenDetected from XenPlatformLib OvmfPkg/PlatformBootManagerLib: Handle the absence of PCI bus on Xen
PVH
OvmfPkg/OvmfXen: Override PcdFSBClock to Xen vLAPIC timer frequency OvmfPkg/OvmfXen: Introduce XenTimerDxe OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn
OvmfPkg: Introduce PcdXenGrantFrames
OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables
OvmfPkg: Move XenRealTimeClockLib from ArmVirtPkg OvmfPkg/OvmfXen: use RealTimeClockRuntimeDxe from EmbeddedPkg

 OvmfPkg/OvmfPkg.dec                           |  10 +
 ArmVirtPkg/ArmVirtXen.dsc                     |   2 +-
 OvmfPkg/OvmfPkgIa32.dsc                       |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                    |   1 +
 OvmfPkg/OvmfPkgX64.dsc                        |   1 +
 OvmfPkg/{OvmfPkgX64.dsc => OvmfXen.dsc}       | 238 +-------
 OvmfPkg/OvmfXen.fdf                           | 539 ++++++++++++++++++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf   |   3 +-
 .../PlatformBootManagerLib.inf                |   6 +-
 .../Library/ResetSystemLib/ResetSystemLib.inf |   1 +
 .../XenHypercallLib/XenHypercallLib.inf       |   4 +-
 .../Library/XenPlatformLib/XenPlatformLib.inf |  33 ++
 .../XenRealTimeClockLib.inf                   |   0
 OvmfPkg/XenBusDxe/XenBusDxe.inf               |   2 +
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf           |  35 ++
 OvmfPkg/XenPlatformPei/XenPlatformPei.inf     | 100 ++++
 OvmfPkg/XenResetVector/XenResetVector.inf     |  41 ++
 OvmfPkg/XenTimerDxe/XenTimerDxe.inf           |  42 ++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h        |   6 +-
 OvmfPkg/Include/Guid/XenInfo.h                |   8 +-
 .../Xen/arch-x86/hvm/start_info.h             | 143 +++++
 OvmfPkg/Include/IndustryStandard/Xen/memory.h |  23 +
 OvmfPkg/Include/Library/XenHypercallLib.h     |  12 +
 OvmfPkg/Include/Library/XenPlatformLib.h      |  53 ++
 .../PlatformBootManagerLib/BdsPlatform.h      |   1 +
 OvmfPkg/XenBusDxe/XenBusDxe.h                 |   1 +
 OvmfPkg/XenPlatformPei/Cmos.h                 |  52 ++
 OvmfPkg/XenPlatformPei/Platform.h             | 136 +++++
 OvmfPkg/XenPlatformPei/Xen.h                  |  39 ++
 OvmfPkg/XenTimerDxe/XenTimerDxe.h             | 177 ++++++
 OvmfPkg/AcpiPlatformDxe/Xen.c                 |  41 +-
 .../PlatformBootManagerLib/BdsPlatform.c      |  43 +-
 .../PlatformBootManagerLib/PlatformData.c     |  49 +-
 .../Library/ResetSystemLib/ResetSystemLib.c   |   3 +-
 .../Library/XenHypercallLib/X86XenHypercall.c |   8 +-
 .../Library/XenHypercallLib/XenHypercall.c    |  16 +
 .../Library/XenPlatformLib/XenPlatformLib.c   |  81 +++
 .../XenRealTimeClockLib/XenRealTimeClockLib.c |   0
 OvmfPkg/OvmfXenElfHeaderGenerator.c           | 140 +++++
 OvmfPkg/PlatformPei/Xen.c                     |   3 -
 OvmfPkg/XenBusDxe/GrantTable.c                |   3 +-
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c             |  53 ++
 OvmfPkg/XenPlatformPei/AmdSev.c               |  64 +++
 OvmfPkg/XenPlatformPei/ClearCache.c           | 112 ++++
 OvmfPkg/XenPlatformPei/Cmos.c                 |  60 ++
 OvmfPkg/XenPlatformPei/Fv.c                   |  76 +++
 OvmfPkg/XenPlatformPei/MemDetect.c            | 490 ++++++++++++++++
 OvmfPkg/XenPlatformPei/Platform.c             | 463 +++++++++++++++
 OvmfPkg/XenPlatformPei/Xen.c                  | 373 ++++++++++++
 OvmfPkg/XenTimerDxe/XenTimerDxe.c             | 355 ++++++++++++
 Maintainers.txt                               |  10 +-
 .../XenResetVector/Ia16/Real16ToFlat32.asm    | 137 +++++
 .../XenResetVector/Ia16/ResetVectorVtf0.asm   |  79 +++
 .../XenResetVector/Ia32/Flat32ToFlat64.asm    |  68 +++
 OvmfPkg/XenResetVector/Ia32/PageTables64.asm  | 149 +++++
 .../XenResetVector/Ia32/SearchForBfvBase.asm  |  87 +++
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm    |  84 +++
 OvmfPkg/XenResetVector/XenResetVector.nasmb   |  71 +++
 58 files changed, 4523 insertions(+), 305 deletions(-)
 copy OvmfPkg/{OvmfPkgX64.dsc => OvmfXen.dsc} (76%)
 create mode 100644 OvmfPkg/OvmfXen.fdf
 create mode 100644 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
 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
 create mode 100644 OvmfPkg/XenPlatformPei/Xen.h
 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/OvmfXenElfHeaderGenerator.c
 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 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 · 6 lines
Anthony PERARD

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

PATCH v4 5/35 OvmfPkg/OvmfXen: Creating an ELF header

This patch changes the flash device image of OvmfXen to make it look like it's an ELF. For this, we replace the empty embedded variable store by a binary array, which is a ELF file header.

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. The header also includes a Xen ELF note that is part of the PVH ABI.

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

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- fix top-level comment style
- Update Maintainers.txt

v3:
- added license to generate_elf_header.c
which is renamed to OvmfPkg/OvmfXenElfHeaderGenerator.c
- added an ELF NOTE into the header

 OvmfPkg/OvmfXen.fdf                 | 101 +++++++++++++++++++-
 OvmfPkg/OvmfXenElfHeaderGenerator.c | 140 ++++++++++++++++++++++++++++
 Maintainers.txt                     |   1 +
 3 files changed, 239 insertions(+), 3 deletions(-)
 create mode 100644 OvmfPkg/OvmfXenElfHeaderGenerator.c
OvmfPkg/OvmfXen.fdf +98 -3
index 2ceff7baa2..43c268f6cb 100644
@@ -15,8 +15,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)
@@ -25,7 +25,102 @@ [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
+DATA = {
+  #
+  # This hex array have been generated by OvmfPkg/OvmfXenElfHeaderGenerator.c
+  # and copied manually.
+  #
+  # 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
+  0x02, 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
+  0x00, 0x00, # e_shstrndx
+
+  # ELF Program segment headers
+  # - Load segment
+  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
+  # - ELFNOTE segment
+  0x04, 0x00, 0x00, 0x00, # p_type = PT_NOTE
+  0x74, 0x00, 0x00, 0x00, # p_offset = point to XEN_ELFNOTE_PHYS32_ENTRY below
+  0x74, 0x00, 0x10, 0x00,
+  0x74, 0x00, 0x10, 0x00,
+  0x14, 0x00, 0x00, 0x00,
+  0x14, 0x00, 0x00, 0x00,
+  0x04, 0x00, 0x00, 0x00, # p_flags = Segment is readable
+  0x00, 0x00, 0x00, 0x00,
+
+  # XEN_ELFNOTE_PHYS32_ENTRY
+  0x04, 0x00, 0x00, 0x00, # name size
+  0x04, 0x00, 0x00, 0x00, # desc size
+  0x12, 0x00, 0x00, 0x00, # type = XEN_ELFNOTE_PHYS32_ENTRY
+  0x58, 0x65, 0x6e, 0x00, # name = "Xen"
+  0xd0, 0xff, 0x2f, 0x00, # desc: PVH entry point
+  0x00
+}
+
+!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
OvmfPkg/OvmfXenElfHeaderGenerator.c new file +140 -0

140 lines not on this page · raw message

Maintainers.txt +1 -0
index 42ec8d54af..016523b401 100644
@@ -373,6 +373,7 @@ F: OvmfPkg/Library/XenConsoleSerialPortLib/
 F: OvmfPkg/Library/XenHypercallLib/
 F: OvmfPkg/Library/XenIoMmioLib/
 F: OvmfPkg/OvmfXen.*
+F: OvmfPkg/OvmfXenElfHeaderGenerator.c
 F: OvmfPkg/PlatformPei/MemDetect.c
 F: OvmfPkg/PlatformPei/Platform.*
 F: OvmfPkg/PlatformPei/Xen.*
Signature · 6 lines
Anthony PERARD

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

PATCH v4 6/35 OvmfPkg/XenResetVector: Add new entry point for Xen PVH

In reply to Anthony PERARD

Add a new entry point for Xen PVH that 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

Also, compare to the original file [1], the two `nop' of the "resetVector" entry point are removed. There were introduced by 8332983e2e33 ("UefiCpuPkg: Replace the un-necessary WBINVD instruction at the reset vector with two NOPs in VTF0.", 2011-08-04), but don't seems to be useful. This is the entry point used by HVM guest (hvmloader).

[1] UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- remove the two nop in the HVM entry point

v3:
- rebased, SPDX
- remove `cli' as via PVH the interrupts are guaranteed to be off
- rewrite some comments

 .../XenResetVector/Ia16/ResetVectorVtf0.asm   | 79 +++++++++++++++++++
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm    | 49 ++++++++++++
 OvmfPkg/XenResetVector/XenResetVector.nasmb   |  1 +
 3 files changed, 129 insertions(+)
 create mode 100644 OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm
OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm new file +79 -0
new file mode 100644
index 0000000000..56749bdbc9
@@ -0,0 +1,79 @@
+;------------------------------------------------------------------------------
+; @file
+; First code executed by processor after resetting.
+;
+; Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019, Citrix Systems, Inc.
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+;------------------------------------------------------------------------------
+
+BITS    16
+
+ALIGN   16
+
+;
+; Pad the image size to 4k when page tables are in VTF0
+;
+; If the VTF0 image has page tables built in, then we need to make
+; sure the end of VTF0 is 4k above where the page tables end.
+;
+; This is required so the page tables will be 4k aligned when VTF0 is
+; located just below 0x100000000 (4GB) in the firmware device.
+;
+%ifdef ALIGN_TOP_TO_4K_FOR_PAGING
+    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
+;
+; GenFv generates code aligned on a 4k boundary which will jump to this
+; location.  (0xffffffe0)  This allows the Local APIC Startup IPI to be
+; used to wake up the application processors.
+;
+    jmp     EarlyApInitReal16
+
+ALIGN   8
+
+    DD      0
+
+;
+; The VTF signature
+;
+; VTF-0 means that the VTF (Volume Top File) code does not require
+; any fixups.
+;
+vtfSignature:
+    DB      'V', 'T', 'F', 0
+
+ALIGN   16
+
+resetVector:
+;
+; Reset Vector
+;
+; This is where the processor will begin execution
+;
+    jmp     EarlyBspInitReal16
+
+ALIGN   16
+
+fourGigabytes:
+
OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm new file +49 -0

49 lines not on this page · raw message

OvmfPkg/XenResetVector/XenResetVector.nasmb +1 -0
index 89a4b08bc3..0dbc4f2c1d 100644
@@ -63,6 +63,7 @@
 %include "Ia16/Init16.asm"
 
 %include "Main.asm"
+%include "Ia32/XenPVHMain.asm"
 
 %include "Ia16/ResetVectorVtf0.asm"
 
Signature · 6 lines
Anthony PERARD

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

PATCH v4 8/35 OvmfPkg/XenResetVector: Allow 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 being 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 be run 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.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- rebased, SPDX
- fix commit message

 .../XenResetVector/Ia16/Real16ToFlat32.asm    |  3 +
 .../XenResetVector/Ia32/Flat32ToFlat64.asm    | 68 +++++++++++++++
 .../XenResetVector/Ia32/SearchForBfvBase.asm  | 87 +++++++++++++++++++
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm    | 43 +++++++--
 4 files changed, 194 insertions(+), 7 deletions(-)
 create mode 100644 OvmfPkg/XenResetVector/Ia32/Flat32ToFlat64.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm
OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm +3 -0
index 5c329bfaea..36ea74f7fe 100644
@@ -54,6 +54,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 new file +68 -0

68 lines not on this page · raw message

OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm new file +87 -0

87 lines not on this page · raw message

OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm +36 -7

67 lines not on this page · raw message

Signature · 6 lines
Anthony PERARD

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

PATCH v4 3/35 OvmfPkg: Introduce XenResetVector

In reply to Anthony PERARD

Introduce XenResetVector, a 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 (gEfiFirmwareVolumeTopFileGuid).

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- Update Maintainers.txt

v3:
- Added gEfiFirmwareVolumeTopFileGuid to the commit message.
- rebased: SPDX

 OvmfPkg/OvmfXen.dsc                           |   2 +-
 OvmfPkg/OvmfXen.fdf                           |   2 +-
 OvmfPkg/XenResetVector/XenResetVector.inf     |  38 +++++
 Maintainers.txt                               |   1 +
 .../XenResetVector/Ia16/Real16ToFlat32.asm    | 134 ++++++++++++++++
 OvmfPkg/XenResetVector/Ia32/PageTables64.asm  | 149 ++++++++++++++++++
 OvmfPkg/XenResetVector/XenResetVector.nasmb   |  68 ++++++++
 7 files changed, 392 insertions(+), 2 deletions(-)
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.inf
 create mode 100644 OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/PageTables64.asm
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.nasmb
OvmfPkg/OvmfXen.dsc +1 -1
index f224ac32b4..1a0e59f0cc 100644
@@ -495,7 +495,7 @@ [PcdsDynamicDefault]
 #
 ################################################################################
 [Components]
-  OvmfPkg/ResetVector/ResetVector.inf
+  OvmfPkg/XenResetVector/XenResetVector.inf
 
   #
   # SEC Phase modules
OvmfPkg/OvmfXen.fdf +1 -1
index f59647fd14..6fc8479aae 100644
@@ -118,7 +118,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 new file +38 -0
new file mode 100644
index 0000000000..097fc9b5b4
@@ -0,0 +1,38 @@
+## @file
+#  Reset Vector
+#
+#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2019, Citrix Systems, Inc.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = XenResetVector
+  FILE_GUID                      = 1BA0062E-C779-4582-8566-336AE8F78F09
+  MODULE_TYPE                    = SEC
+  VERSION_STRING                 = 1.1
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  XenResetVector.nasmb
+
+[Packages]
+  OvmfPkg/OvmfPkg.dec
+  MdePkg/MdePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+
+[BuildOptions]
+   *_*_IA32_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/
+   *_*_X64_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/
+
+[Pcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize
Maintainers.txt +1 -0
index 98f6d828eb..34bdb275b4 100644
@@ -380,6 +380,7 @@ F: OvmfPkg/SmbiosPlatformDxe/*Xen.c
 F: OvmfPkg/XenBusDxe/
 F: OvmfPkg/XenIoPciDxe/
 F: OvmfPkg/XenPvBlkDxe/
+F: OvmfPkg/XenResetVector/
 R: Anthony Perard <[email protected]>
 R: Julien Grall <[email protected]>
 
OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm new file +134 -0

134 lines not on this page · raw message

OvmfPkg/XenResetVector/Ia32/PageTables64.asm new file +149 -0

149 lines not on this page · raw message

OvmfPkg/XenResetVector/XenResetVector.nasmb new file +68 -0

68 lines not on this page · raw message

Signature · 6 lines
Anthony PERARD

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

PATCH v4 2/35 OvmfPkg: Create platform OvmfXen

In reply to Anthony PERARD

OvmfXen 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.
- reverted d272449d9e1e, "OvmfPkg: raise DXEFV size to 11 MB"

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- rebased
- Update Maintainers.txt

v3:
- rebased, SPDX + 8259/8254 changes

 OvmfPkg/OvmfXen.dsc | 729 ++++++++++++++++++++++++++++++++++++++++++++
 OvmfPkg/OvmfXen.fdf | 439 ++++++++++++++++++++++++++
 Maintainers.txt     |   1 +
 3 files changed, 1169 insertions(+)
 create mode 100644 OvmfPkg/OvmfXen.dsc
 create mode 100644 OvmfPkg/OvmfXen.fdf
OvmfPkg/OvmfXen.dsc new file +729 -0
new file mode 100644
index 0000000000..f224ac32b4
@@ -0,0 +1,729 @@
+## @file
+#  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
+#
+#  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.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+  PLATFORM_NAME                  = Ovmf
+  PLATFORM_GUID                  = e3aa4fbe-9459-482d-bd40-d3f3b5f89d6e
+  PLATFORM_VERSION               = 0.1
+  DSC_SPECIFICATION              = 0x00010005
+  OUTPUT_DIRECTORY               = Build/OvmfXen
+  SUPPORTED_ARCHITECTURES        = X64
+  BUILD_TARGETS                  = NOOPT|DEBUG|RELEASE
+  SKUID_IDENTIFIER               = DEFAULT
+  FLASH_DEFINITION               = OvmfPkg/OvmfXen.fdf
+
+  #
+  # Defines for default states.  These can be changed on the command line.
+  # -D FLAG=VALUE
+  #
+
+  #
+  # Network definition
+  #
+  DEFINE NETWORK_TLS_ENABLE             = FALSE
+  DEFINE NETWORK_IP6_ENABLE             = FALSE
+  DEFINE NETWORK_HTTP_BOOT_ENABLE       = FALSE
+  DEFINE NETWORK_ALLOW_HTTP_CONNECTIONS = TRUE
+
+!include NetworkPkg/NetworkDefines.dsc.inc
+
+  #
+  # Flash size selection. Setting FD_SIZE_IN_KB on the command line directly to
+  # one of the supported values, in place of any of the convenience macros, is
+  # permitted.
+  #
+!ifdef $(FD_SIZE_1MB)
+  DEFINE FD_SIZE_IN_KB           = 1024
+!else
+!ifdef $(FD_SIZE_2MB)
+  DEFINE FD_SIZE_IN_KB           = 2048
+!else
+!ifdef $(FD_SIZE_4MB)
+  DEFINE FD_SIZE_IN_KB           = 4096
+!else
+  DEFINE FD_SIZE_IN_KB           = 2048
+!endif
+!endif
+!endif
+
+[BuildOptions]
+  GCC:RELEASE_*_*_CC_FLAGS             = -DMDEPKG_NDEBUG
+  INTEL:RELEASE_*_*_CC_FLAGS           = /D MDEPKG_NDEBUG
+  MSFT:RELEASE_*_*_CC_FLAGS            = /D MDEPKG_NDEBUG
+!if $(TOOL_CHAIN_TAG) != "XCODE5"
+  GCC:*_*_*_CC_FLAGS                   = -mno-mmx -mno-sse
+!endif
+!ifdef $(SOURCE_DEBUG_ENABLE)
+  MSFT:*_*_X64_GENFW_FLAGS  = --keepexceptiontable
+  GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
+  INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
+!endif
+
+  #
+  # Disable deprecated APIs.
+  #
+  MSFT:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
+  INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
+  GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+
+[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+  XCODE:*_*_*_DLINK_FLAGS =
+
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
+# protection of DXE_SMM_DRIVER/SMM_CORE modules
+[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+  XCODE:*_*_*_DLINK_FLAGS =
+
+################################################################################
+#
+# SKU Identification section - list of all SKU IDs supported by this Platform.
+#
+################################################################################
+[SkuIds]
+  0|DEFAULT
+
+################################################################################
+#
+# Library Class section - list of all Library Classes needed by this Platform.
+#
+################################################################################
+[LibraryClasses]
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf
+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
+  SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
+  CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
+  PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
+  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+  CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
+  UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
+  UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
+  HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
+  SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+  UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+  BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
+  FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
+  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
+  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
+  DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
+  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
+  PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
+  PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
+  PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
+  PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
+  PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
+  PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
+  PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
+  IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
+  OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
+  SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
+  MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+  UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
+  UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+  UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
+  UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
+  DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
+  NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
+  FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
+  SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
+  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
+  SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
+  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.inf
+  LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
+  MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/BaseMemEncryptSevLib.inf
+  LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
+  CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
+  FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
+
+!ifdef $(SOURCE_DEBUG_ENABLE)
+  PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
+  DebugCommunicationLib|SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf
+!else
+  PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
+  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
+!endif
+
+  ResetSystemLib|OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
+  LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
+  DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+
+  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+!if $(NETWORK_TLS_ENABLE) == TRUE
+  OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
+!else
+  OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
+!endif
+
+  AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
+
+
+  #
+  # Network libraries
+  #
+!include NetworkPkg/NetworkLibs.dsc.inc
+
+!if $(NETWORK_TLS_ENABLE) == TRUE
+  TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf
+!endif
+
+  ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+  ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
+  S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
+  SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
+  OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
+  XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
+
+  Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
+  TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+
+[LibraryClasses.common]
+  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+
+[LibraryClasses.common.SEC]
+  TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf
+  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
+!endif
+  ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
+  ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
+!ifdef $(SOURCE_DEBUG_ENABLE)
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
+!endif
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+  PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
+  MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+  CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+
+[LibraryClasses.common.PEI_CORE]
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
+  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+  MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+  PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf
+  ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
+  OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
+  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
+  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+
+[LibraryClasses.common.PEIM]
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
+  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+  MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
+  ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
+  OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
+  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
+  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+  ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
+  ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
+!ifdef $(SOURCE_DEBUG_ENABLE)
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
+!endif
+  CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
+  MpInitLib|UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
+  QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf
+  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
+
+[LibraryClasses.common.DXE_CORE]
+  HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
+  DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
+  MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
+  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
+  ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
+!ifdef $(SOURCE_DEBUG_ENABLE)
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
+!endif
+  CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+
+[LibraryClasses.common.DXE_RUNTIME_DRIVER]
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
+  MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
+  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
+  PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
+  QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
+
+[LibraryClasses.common.UEFI_DRIVER]
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
+  MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
+  PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
+
+[LibraryClasses.common.DXE_DRIVER]
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
+  PlatformBootManagerLib|OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+  PlatformBmPrintScLib|OvmfPkg/Library/PlatformBmPrintScLib/PlatformBmPrintScLib.inf
+  QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
+  CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+  LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
+!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
+
+[LibraryClasses.common.UEFI_APPLICATION]
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+  TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.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.
+#
+################################################################################
+[PcdsFeatureFlag]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|TRUE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
+
+[PcdsFixedAtBuild]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
+  gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
+!if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
+!if $(NETWORK_TLS_ENABLE) == FALSE
+  # match PcdFlashNvStorageVariableSize purely for convenience
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0xe000
+!endif
+!endif
+!if $(FD_SIZE_IN_KB) == 4096
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x8400
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x8400
+!if $(NETWORK_TLS_ENABLE) == FALSE
+  # match PcdFlashNvStorageVariableSize purely for convenience
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x40000
+!endif
+!endif
+!if $(NETWORK_TLS_ENABLE) == TRUE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x80000
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize|0x40000
+!endif
+
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0
+
+  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07
+
+  # DEBUG_INIT      0x00000001  // Initialization
+  # DEBUG_WARN      0x00000002  // Warnings
+  # DEBUG_LOAD      0x00000004  // Load events
+  # DEBUG_FS        0x00000008  // EFI File system
+  # DEBUG_POOL      0x00000010  // Alloc & Free (pool)
+  # DEBUG_PAGE      0x00000020  // Alloc & Free (page)
+  # DEBUG_INFO      0x00000040  // Informational debug messages
+  # DEBUG_DISPATCH  0x00000080  // PEI/DXE/SMM Dispatchers
+  # DEBUG_VARIABLE  0x00000100  // Variable
+  # DEBUG_BM        0x00000400  // Boot Manager
+  # DEBUG_BLKIO     0x00001000  // BlkIo Driver
+  # DEBUG_NET       0x00004000  // SNP Driver
+  # DEBUG_UNDI      0x00010000  // UNDI Driver
+  # DEBUG_LOADFILE  0x00020000  // LoadFile
+  # DEBUG_EVENT     0x00080000  // Event messages
+  # DEBUG_GCD       0x00100000  // Global Coherency Database changes
+  # DEBUG_CACHE     0x00200000  // Memory range cachability changes
+  # DEBUG_VERBOSE   0x00400000  // Detailed debug messages that may
+  #                             // significantly impact boot performance
+  # DEBUG_ERROR     0x80000000  // Error
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
+
+!ifdef $(SOURCE_DEBUG_ENABLE)
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
+!else
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
+!endif
+
+  # This PCD is used to set the base address of the PCI express hierarchy. It
+  # is only consulted when OVMF runs on Q35. In that case it is programmed into
+  # the PCIEXBAR register.
+  #
+  # On Q35 machine types that QEMU intends to support in the long term, QEMU
+  # never lets the RAM below 4 GB exceed 2816 MB.
+  gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xB0000000
+
+!ifdef $(SOURCE_DEBUG_ENABLE)
+  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2
+!endif
+
+  #
+  # Network Pcds
+  #
+!include NetworkPkg/NetworkPcds.dsc.inc
+
+  # IRQs 5, 9, 10, 11 are level-triggered
+  gUefiOvmfPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel|0x0E20
+
+  # 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 }
+
+################################################################################
+#
+# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform
+#
+################################################################################
+
+[PcdsDynamicDefault]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600
+  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0
+  gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase|0x0
+  gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize|0x0
+  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base|0x0
+  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size|0x0
+  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base|0x0
+  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size|0x800000000
+
+  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|0
+
+  # Set video resolution for text setup.
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480
+
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0
+  gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE
+
+  # Noexec settings for DXE.
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
+
+  # UefiCpuPkg PCDs related to initial AP bringup and general AP management.
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000
+
+  # Set memory encryption mask
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0
+
+  gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00
+
+################################################################################
+#
+# Components Section - list of all EDK II Modules needed by this Platform.
+#
+################################################################################
+[Components]
+  OvmfPkg/ResetVector/ResetVector.inf
+
+  #
+  # SEC Phase modules
+  #
+  OvmfPkg/Sec/SecMain.inf {
+    <LibraryClasses>
+      NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
+  }
+
+  #
+  # PEI Phase modules
+  #
+  MdeModulePkg/Core/Pei/PeiMain.inf
+  MdeModulePkg/Universal/PCD/Pei/Pcd.inf  {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  }
+  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  }
+  MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  }
+  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+
+  OvmfPkg/PlatformPei/PlatformPei.inf
+  UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
+  UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+
+  #
+  # DXE Phase modules
+  #
+  MdeModulePkg/Core/Dxe/DxeMain.inf {
+    <LibraryClasses>
+      NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
+      DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  }
+
+  MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
+  MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf
+  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf  {
+   <LibraryClasses>
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  }
+
+  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
+
+  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
+
+  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
+  OvmfPkg/8259InterruptControllerDxe/8259.inf
+  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
+  UefiCpuPkg/CpuDxe/CpuDxe.inf
+  OvmfPkg/8254TimerDxe/8254Timer.inf
+  OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
+  OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
+  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
+    <LibraryClasses>
+      PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+      NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf
+  }
+  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+  }
+  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+  MdeModulePkg/Universal/Metronome/Metronome.inf
+  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
+  MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
+  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {
+    <LibraryClasses>
+!ifdef $(CSM_ENABLE)
+      NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf
+      NULL|OvmfPkg/Csm/LegacyBootManagerLib/LegacyBootManagerLib.inf
+!endif
+  }
+  MdeModulePkg/Logo/LogoDxe.inf
+  MdeModulePkg/Application/UiApp/UiApp.inf {
+    <LibraryClasses>
+      NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
+      NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
+      NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
+!ifdef $(CSM_ENABLE)
+      NULL|OvmfPkg/Csm/LegacyBootManagerLib/LegacyBootManagerLib.inf
+      NULL|OvmfPkg/Csm/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf
+!endif
+  }
+  OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
+  OvmfPkg/XenBusDxe/XenBusDxe.inf
+  OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
+  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
+  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
+  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
+  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+  }
+  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
+  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf {
+    <LibraryClasses>
+      DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  }
+  MdeModulePkg/Universal/PrintDxe/PrintDxe.inf
+  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
+  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
+  MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
+  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+  FatPkg/EnhancedFatDxe/Fat.inf
+  MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
+  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+  OvmfPkg/SataControllerDxe/SataControllerDxe.inf
+  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
+  MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
+  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
+
+  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
+  OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf
+
+  #
+  # ISA Support
+  #
+  OvmfPkg/SioBusDxe/SioBusDxe.inf
+  MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxe.inf
+  MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
+
+  #
+  # SMBIOS Support
+  #
+  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf {
+    <LibraryClasses>
+      NULL|OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf
+  }
+  OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+
+  #
+  # ACPI Support
+  #
+  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+  OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
+  OvmfPkg/AcpiTables/AcpiTables.inf
+  MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
+  MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
+  MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
+
+  #
+  # Network Support
+  #
+!include NetworkPkg/NetworkComponents.dsc.inc
+
+!if $(NETWORK_TLS_ENABLE) == TRUE
+  NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf {
+    <LibraryClasses>
+      NULL|OvmfPkg/Library/TlsAuthConfigLib/TlsAuthConfigLib.inf
+  }
+!endif
+
+  #
+  # Usb Support
+  #
+  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+  MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
+!ifdef $(CSM_ENABLE)
+  OvmfPkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+  }
+  OvmfPkg/Csm/LegacyBiosDxe/LegacyBiosDxe.inf
+  OvmfPkg/Csm/Csm16/Csm16.inf
+!endif
+
+!if $(TOOL_CHAIN_TAG) != "XCODE5"
+  ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf {
+    <PcdsFixedAtBuild>
+      gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+  }
+!endif
+  ShellPkg/Application/Shell/Shell.inf {
+    <LibraryClasses>
+      ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf
+      NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
+      NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
+      NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf
+      NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf
+      NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
+      NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf
+      NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
+!if $(NETWORK_IP6_ENABLE) == TRUE
+      NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf
+!endif
+      HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
+      PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+      BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf
+
+    <PcdsFixedAtBuild>
+      gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF
+      gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+      gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000
+  }
+
+  OvmfPkg/PlatformDxe/Platform.inf
+  OvmfPkg/AmdSevDxe/AmdSevDxe.inf
+  OvmfPkg/IoMmuDxe/IoMmuDxe.inf
+
+  #
+  # Variable driver stack (non-SMM)
+  #
+  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
+  OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
+    <LibraryClasses>
+      PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
+  }
+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+    <LibraryClasses>
+      NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
OvmfPkg/OvmfXen.fdf new file +439 -0

439 lines not on this page · raw message

Maintainers.txt +1 -0
index 0298010809..98f6d828eb 100644
@@ -372,6 +372,7 @@ F: OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
 F: OvmfPkg/Library/XenConsoleSerialPortLib/
 F: OvmfPkg/Library/XenHypercallLib/
 F: OvmfPkg/Library/XenIoMmioLib/
+F: OvmfPkg/OvmfXen.*
 F: OvmfPkg/PlatformPei/MemDetect.c
 F: OvmfPkg/PlatformPei/Platform.*
 F: OvmfPkg/PlatformPei/Xen.*
Signature · 6 lines
Anthony PERARD

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

PATCH v4 7/35 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

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- rename PcdXenStartOfDay* to PcdXenPvhStartOfDay*
- Use first available token value for those (0x17 and 0x28)

 OvmfPkg/OvmfPkg.dec                         | 3 +++
 OvmfPkg/OvmfXen.fdf                         | 4 ++++
 OvmfPkg/XenResetVector/XenResetVector.inf   | 3 +++
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm  | 6 ++++++
 OvmfPkg/XenResetVector/XenResetVector.nasmb | 2 ++
 5 files changed, 18 insertions(+)
OvmfPkg/OvmfPkg.dec +3 -0
index 9640360f62..c2a2ebfb95 100644
@@ -218,6 +218,9 @@ [PcdsFixedAtBuild]
   #  The value should be a multiple of 4KB.
   gUefiOvmfPkgTokenSpaceGuid.PcdHighPmmMemorySize|0x400000|UINT32|0x31
 
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr|0x0|UINT32|0x17
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize|0x0|UINT32|0x32
+
 [PcdsDynamic, PcdsDynamicEx]
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10
OvmfPkg/OvmfXen.fdf +4 -0
index 43c268f6cb..49997fee9b 100644
@@ -172,6 +172,10 @@ [FD.MEMFD]
 0x007000|0x001000
 gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
 
+0x008000|0x001000
+# Used by XenResetVector to communicate with XenPlatformPei
+gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr|gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize
+
 0x010000|0x010000
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
 
OvmfPkg/XenResetVector/XenResetVector.inf +3 -0
index 097fc9b5b4..46b133a834 100644
@@ -36,3 +36,6 @@ [BuildOptions]
 [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize
+
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize
OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm +6 -0
index 2a17fed52f..f42df3dba2 100644
@@ -22,6 +22,12 @@ xenPVHMain:
     ;
     xor     esp, esp
 
+    ;
+    ; Store "Start of day" struct pointer for later use
+    ;
+    mov     dword[PVH_SPACE (0)], ebx
+    mov     dword[PVH_SPACE (4)], 'XPVH'
+
     mov     ebx, ADDR_OF(gdtr)
     lgdt    [ebx]
 
OvmfPkg/XenResetVector/XenResetVector.nasmb +2 -0
index 0dbc4f2c1d..b2cb405d54 100644
@@ -34,6 +34,8 @@
 
 %include "CommonMacros.inc"
 
+%define PVH_SPACE(Offset) (FixedPcdGet32 (PcdXenPvhStartOfDayStructPtr) + (Offset))
+
 %include "PostCodes.inc"
 
 %ifdef DEBUG_PORT80
Signature · 6 lines
Anthony PERARD

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

PATCH v4 4/35 OvmfPkg: Introduce XenPlatformPei

In reply to Anthony PERARD

Introduce XenPlatformPei, 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.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- replace the other EFI_D_ by DEBUG_.
- Update Maintainers.txt
- fix one trailing whitespace

v3:
- fix coding style in new code
(use DEBUG_xxx, add ASSERT before CpuDeadLoop)
- rebased, SPDX

 OvmfPkg/OvmfXen.dsc                       |   2 +-
 OvmfPkg/OvmfXen.fdf                       |   2 +-
 OvmfPkg/XenPlatformPei/XenPlatformPei.inf |  96 +++++
 OvmfPkg/XenPlatformPei/Cmos.h             |  52 +++
 OvmfPkg/XenPlatformPei/Platform.h         | 108 ++++++
 OvmfPkg/XenPlatformPei/Xen.h              |  39 ++
 OvmfPkg/XenPlatformPei/AmdSev.c           |  64 ++++
 OvmfPkg/XenPlatformPei/ClearCache.c       | 112 ++++++
 OvmfPkg/XenPlatformPei/Cmos.c             |  60 +++
 OvmfPkg/XenPlatformPei/Fv.c               |  76 ++++
 OvmfPkg/XenPlatformPei/MemDetect.c        | 421 ++++++++++++++++++++
 OvmfPkg/XenPlatformPei/Platform.c         | 444 ++++++++++++++++++++++
 OvmfPkg/XenPlatformPei/Xen.c              | 219 +++++++++++
 Maintainers.txt                           |   1 +
 14 files changed, 1694 insertions(+), 2 deletions(-)
 create mode 100644 OvmfPkg/XenPlatformPei/XenPlatformPei.inf
 create mode 100644 OvmfPkg/XenPlatformPei/Cmos.h
 create mode 100644 OvmfPkg/XenPlatformPei/Platform.h
 create mode 100644 OvmfPkg/XenPlatformPei/Xen.h
 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
OvmfPkg/OvmfXen.dsc +1 -1
index 1a0e59f0cc..7619a89382 100644
@@ -523,7 +523,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/OvmfXen.fdf +1 -1
index 6fc8479aae..2ceff7baa2 100644
@@ -152,7 +152,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 new file +96 -0

96 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Cmos.h new file +52 -0

52 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Platform.h new file +108 -0

108 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Xen.h new file +39 -0
new file mode 100644
index 0000000000..2605481280
@@ -0,0 +1,39 @@
+/** @file
+  Ovmf info structure passed by Xen
+
+Copyright (c) 2013, Citrix Systems UK Ltd.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __XEN_H__
+#define __XEN_H__
+
+#include <PiPei.h>
+
+// Physical address of OVMF info
+#define OVMF_INFO_PHYSICAL_ADDRESS 0x00001000
+
+// This structure must match the definition on Xen side
+#pragma pack(1)
+typedef struct {
+  CHAR8 Signature[14]; // XenHVMOVMF\0
+  UINT8 Length;        // Length of this structure
+  UINT8 Checksum;      // Set such that the sum over bytes 0..length == 0
+  //
+  // Physical address of an array of TablesCount elements.
+  //
+  // Each element contains the physical address of a BIOS table.
+  //
+  EFI_PHYSICAL_ADDRESS Tables;
+  UINT32 TablesCount;
+  //
+  // Physical address of the E820 table, contains E820EntriesCount entries.
+  //
+  EFI_PHYSICAL_ADDRESS E820;
+  UINT32 E820EntriesCount;
+} EFI_XEN_OVMF_INFO;
+#pragma pack()
+
+#endif /* __XEN_H__ */
OvmfPkg/XenPlatformPei/AmdSev.c new file +64 -0

64 lines not on this page · raw message

OvmfPkg/XenPlatformPei/ClearCache.c new file +112 -0

112 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Cmos.c new file +60 -0

60 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Fv.c new file +76 -0

76 lines not on this page · raw message

OvmfPkg/XenPlatformPei/MemDetect.c new file +421 -0

421 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Platform.c new file +444 -0

444 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Xen.c new file +219 -0

219 lines not on this page · raw message

Maintainers.txt +1 -0
index 34bdb275b4..42ec8d54af 100644
@@ -379,6 +379,7 @@ F: OvmfPkg/PlatformPei/Xen.*
 F: OvmfPkg/SmbiosPlatformDxe/*Xen.c
 F: OvmfPkg/XenBusDxe/
 F: OvmfPkg/XenIoPciDxe/
+F: OvmfPkg/XenPlatformPei/
 F: OvmfPkg/XenPvBlkDxe/
 F: OvmfPkg/XenResetVector/
 R: Anthony Perard <[email protected]>
Signature · 6 lines
Anthony PERARD

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

PATCH v4 21/35 OvmfPkg: Import XENMEM_memory_map hypercall to Xen/memory.h

In reply to Anthony PERARD

The informations to make a XENMEM_memory_map hypercall is copied over from the public header of the Xen Project, with the type name modified to build on OVMF.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- expanded the "This" that was starting the commit message body.

 OvmfPkg/Include/IndustryStandard/Xen/memory.h | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
OvmfPkg/Include/IndustryStandard/Xen/memory.h +23 -0
index 81e981331a..4a33a26d4e 100644
@@ -65,6 +65,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 · 6 lines
Anthony PERARD

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

PATCH v4 24/35 OvmfPkg/XenPlatformPei: Reserve VGA memory region, to boot Linux

In reply to Anthony PERARD

Linux panic if the VGA 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

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- fix commit message

 OvmfPkg/XenPlatformPei/Xen.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
OvmfPkg/XenPlatformPei/Xen.c +16 -0
index 182e96cc5b..c3eabe7fa4 100644
@@ -292,6 +292,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);
+
   LocalApic = PcdGet32(PcdCpuLocalApicBaseAddress);
   AddIoMemoryBaseSizeHob (LocalApic, SIZE_1MB);
 
@@ -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 · 6 lines
Anthony PERARD

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

PATCH v4 18/35 OvmfPkg/XenPlatformPei: Introduce XenHvmloaderDetected

In reply to Anthony PERARD

This new XenHvmloaderDetected() return true if the hvmloader firmware has runned before OVMF.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- Added one sentence in the commit message.

 OvmfPkg/XenPlatformPei/Platform.h | 5 +++++
 OvmfPkg/XenPlatformPei/Xen.c      | 7 +++++++
 2 files changed, 12 insertions(+)
OvmfPkg/XenPlatformPei/Platform.h +5 -0
index 77427496c0..925df31f88 100644
@@ -89,6 +89,11 @@ XenDetect (
   VOID
   );
 
+BOOLEAN
+XenHvmloaderDetected (
+  VOID
+  );
+
 VOID
 AmdSevInitialize (
   VOID
OvmfPkg/XenPlatformPei/Xen.c +7 -0
index c67f4c9697..2105304c41 100644
@@ -199,6 +199,13 @@ XenDetect (
   return FALSE;
 }
 
+BOOLEAN
+XenHvmloaderDetected (
+  VOID
+  )
+{
+  return (mXenHvmloaderInfo != NULL);
+}
 
 VOID
 XenPublishRamRegions (
Signature · 6 lines
Anthony PERARD

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

PATCH v4 17/35 OvmfPkg/XenPlatformPei: Reinit XenHypercallLib

In reply to Anthony PERARD

The XenPlatformPei needs to make hypercalls, but the XenHypercallLib was initialised before the HyperPage was ready. Now that XenPlatformPei has initialised the HyperPage, reinitialise the XenHypercallLib.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- new patch split from XenHypercallLib: Enable it in PEIM.
- check for Lib initialisation failure.

 OvmfPkg/XenPlatformPei/XenPlatformPei.inf | 1 +
 OvmfPkg/XenPlatformPei/Xen.c              | 9 +++++++++
 2 files changed, 10 insertions(+)
OvmfPkg/XenPlatformPei/XenPlatformPei.inf +1 -0
index 4d00206d09..0ef77db92c 100644
@@ -59,6 +59,7 @@ [LibraryClasses]
   MtrrLib
   MemEncryptSevLib
   PcdLib
+  XenHypercallLib
 
 [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
OvmfPkg/XenPlatformPei/Xen.c +9 -0
index b366139a0a..c67f4c9697 100644
@@ -26,6 +26,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"
@@ -88,6 +89,7 @@ XenConnect (
   EFI_XEN_OVMF_INFO *Info;
   CHAR8 Sig[sizeof (Info->Signature) + 1];
   UINT32 *PVHResetVectorData;
+  RETURN_STATUS Status;
 
   AsmCpuid (XenLeaf + 2, &TransferPages, &TransferReg, NULL, NULL);
   mXenInfo.HyperPages = AllocatePages (TransferPages);
@@ -152,6 +154,13 @@ XenConnect (
     sizeof(mXenInfo)
     );
 
+  //
+  // Initialize the XenHypercall library, now that the XenInfo HOB is
+  // available
+  //
+  Status = XenHypercallLibInit ();
+  ASSERT_RETURN_ERROR (Status);
+
   return EFI_SUCCESS;
 }
 
Signature · 6 lines
Anthony PERARD

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

PATCH v4 23/35 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 work without CMOS by reading the e820 table.

Rework XenPublishRamRegions to also care for the reserved and ACPI entry in the e820 table. The region that was added by InitializeXen() isn't needed as that same entry is in the e820 table provided by hvmloader.

MTRR settings aren't modified anymore, on HVM it's already done by hvmloader, on PVH it is supposed to have sane default. MTRR will need to be done properly but keeping what's already been done by programmes that has runned before OVMF will do for now.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- some coding style
- Added AddReservedMemoryRangeHob, and using it.
- this patch now replace "OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it has run" from v3. hvmloader have added an entry in the e820 table, there is no
need for a special case.
- now, everything that is in the e820 table is added to OVMF's memory
map, no more skipping ACPI entries or hvmloader's reserved entries.
Instead, we look for the local APIC region and avoid it if it is
present in the e820.
- rework commit message

 OvmfPkg/XenPlatformPei/Platform.h  | 13 ++++++
 OvmfPkg/XenPlatformPei/MemDetect.c | 69 +++++++++++++++++++++++++++++
 OvmfPkg/XenPlatformPei/Platform.c  | 11 +++++
 OvmfPkg/XenPlatformPei/Xen.c       | 70 +++++++++++++++++++-----------
 4 files changed, 137 insertions(+), 26 deletions(-)
OvmfPkg/XenPlatformPei/Platform.h +13 -0
index db9a62572f..7661f4a8de 100644
@@ -44,6 +44,13 @@ AddReservedMemoryBaseSizeHob (
   BOOLEAN                     Cacheable
   );
 
+VOID
+AddReservedMemoryRangeHob (
+  EFI_PHYSICAL_ADDRESS        MemoryBase,
+  EFI_PHYSICAL_ADDRESS        MemoryLimit,
+  BOOLEAN                     Cacheable
+  );
+
 VOID
 AddressWidthInitialization (
   VOID
@@ -114,6 +121,12 @@ XenPublishRamRegions (
   VOID
   );
 
+EFI_STATUS
+XenGetE820Map (
+  EFI_E820_ENTRY64 **Entries,
+  UINT32 *Count
+  );
+
 extern EFI_BOOT_MODE mBootMode;
 
 extern UINT8 mPhysMemAddressWidth;
OvmfPkg/XenPlatformPei/MemDetect.c +69 -0

87 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Platform.c +11 -0
index 6aaafc3ee9..2f42ca6ccd 100644
@@ -102,6 +102,17 @@ AddReservedMemoryBaseSizeHob (
     );
 }
 
+VOID
+AddReservedMemoryRangeHob (
+  EFI_PHYSICAL_ADDRESS        MemoryBase,
+  EFI_PHYSICAL_ADDRESS        MemoryLimit,
+  BOOLEAN                     Cacheable
+  )
+{
+  AddReservedMemoryBaseSizeHob (MemoryBase,
+    (UINT64)(MemoryLimit - MemoryBase), Cacheable);
+}
+
 VOID
 AddIoMemoryRangeHob (
   EFI_PHYSICAL_ADDRESS        MemoryBase,
OvmfPkg/XenPlatformPei/Xen.c +44 -26

91 lines not on this page · raw message

Signature · 6 lines
Anthony PERARD

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

PATCH v4 31/35 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 implemented via SerialDxe.

That is 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.

Since we use VENDOR_UART_DEVICE_PATH, fix its description and coding style.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- instead of creating a new XEN_CONSOLE_DEVICE_PATH, use the existing VENDOR_UART_DEVICE_PATH. And explain why VENDOR_UART_DEVICE_PATH changed in the commit message.

v3:
- removed PciSioSerialDxe and IsaSerialDxe from OvmfXen, since they would not be used, maybe, to check.
- some coding style fix

- not changed: PciSioSerialDxe: even if we add SerialDxe, we still needs PciSioSerialDxe to have OVMF use the emulated serial port on HVM.

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/OvmfXen.dsc                           |  4 ++
 OvmfPkg/OvmfXen.fdf                           |  1 +
 .../PlatformBootManagerLib.inf                |  4 ++
 .../PlatformBootManagerLib/BdsPlatform.h      |  1 +
 .../PlatformBootManagerLib/BdsPlatform.c      |  3 +-
 .../PlatformBootManagerLib/PlatformData.c     | 49 +++++++++++++++++--
 6 files changed, 58 insertions(+), 4 deletions(-)
OvmfPkg/OvmfXen.dsc +4 -0
index 54ac910d8e..e719a168f8 100644
@@ -586,6 +586,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/OvmfXen.fdf +1 -0
index fa0830a324..5c1a925d6a 100644
@@ -312,6 +312,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 04d614cd49..f89cce1879 100644
@@ -61,6 +61,10 @@ [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
+  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 49a072b400..153e215101 100644
@@ -165,6 +165,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 +2 -1
index 1eba304f09..70df6b841a 100644
@@ -398,7 +398,8 @@ PlatformBootManagerBeforeConsole (
   //
   EfiBootManagerDispatchDeferredImages ();
 
-  PlatformInitializeConsole (gPlatformConsole);
+  PlatformInitializeConsole (
+    XenDetected() ? gXenPlatformConsole : gPlatformConsole);
   PcdStatus = PcdSet16S (PcdPlatformBootTimeOut,
                 GetFrontPageTimeoutFromQemu ());
   ASSERT_RETURN_ERROR (PcdStatus);
OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c +46 -3

76 lines not on this page · raw message

Signature · 6 lines
Anthony PERARD

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

PATCH v4 32/35 OvmfPkg: Introduce PcdXenGrantFrames

In reply to Anthony PERARD

Introduce PcdXenGrantFrames to replace a define in XenBusDxe and allow the same value to be used in a different module.

The reason for the number of page to be 4 doesn't exist anymore, so simply remove the comment.

---
 OvmfPkg/OvmfPkg.dec             | 3 +++
 OvmfPkg/XenBusDxe/XenBusDxe.inf | 2 ++
 OvmfPkg/XenBusDxe/XenBusDxe.h   | 1 +
 OvmfPkg/XenBusDxe/GrantTable.c  | 3 +--
 4 files changed, 7 insertions(+), 2 deletions(-)
OvmfPkg/OvmfPkg.dec +3 -0
index 04d5e29272..d5fee805ef 100644
@@ -225,6 +225,9 @@ [PcdsFixedAtBuild]
   gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr|0x0|UINT32|0x17
   gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize|0x0|UINT32|0x32
 
+  ## Number of page frames to use for storing grant table entries.
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenGrantFrames|4|UINT32|0x33
+
 [PcdsDynamic, PcdsDynamicEx]
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10
OvmfPkg/XenBusDxe/XenBusDxe.inf +2 -0
index 86e0fb8224..0b78cd0af4 100644
@@ -59,3 +59,5 @@ [Protocols]
   gXenBusProtocolGuid
   gXenIoProtocolGuid
 
+[FixedPcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenGrantFrames
OvmfPkg/XenBusDxe/XenBusDxe.h +1 -0
index 8510361bca..b1dcc3549c 100644
@@ -22,6 +22,7 @@
 #include <Library/UefiLib.h>
 #include <Library/DevicePathLib.h>
 #include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
 
 
 //
OvmfPkg/XenBusDxe/GrantTable.c +1 -2
index 6575e9b88c..1130404cd1 100644
@@ -22,8 +22,7 @@
 
 #define NR_RESERVED_ENTRIES 8
 
-/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
-#define NR_GRANT_FRAMES 4
+#define NR_GRANT_FRAMES (FixedPcdGet32 (PcdXenGrantFrames))
 #define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * EFI_PAGE_SIZE / sizeof(grant_entry_v1_t))
 
 STATIC grant_entry_v1_t *GrantTable = NULL;
Signature · 6 lines
Anthony PERARD

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

PATCH v4 34/35 OvmfPkg: Move XenRealTimeClockLib from ArmVirtPkg

In reply to Anthony PERARD

Move XenRealTimeClockLib from ArmVirtPkg to OvmfPkg so it can be used from the OvmfPkg by the following patch, "OvmfPkg/OvmfXen: use RealTimeClockRuntimeDxe from EmbeddedPkg"

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- Update Maintainers.txt

v3:
- fix the commit message body

 ArmVirtPkg/ArmVirtXen.dsc                                       | 2 +-
 .../Library/XenRealTimeClockLib/XenRealTimeClockLib.inf         | 0
 .../Library/XenRealTimeClockLib/XenRealTimeClockLib.c           | 0
 Maintainers.txt                                                 | 2 +-
 4 files changed, 2 insertions(+), 2 deletions(-)
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf (100%)
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.c (100%)
ArmVirtPkg/ArmVirtXen.dsc +1 -1
index 79304ee61d..1b42a9a813 100644
@@ -27,7 +27,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
Maintainers.txt +1 -1
index 79defd13bf..919baccc56 100644
@@ -114,7 +114,6 @@ R: Leif Lindholm <[email protected]>
 ArmVirtPkg: modules used on Xen
 F: ArmVirtPkg/ArmVirtXen.*
 F: ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/
-F: ArmVirtPkg/Library/XenRealTimeClockLib/
 F: ArmVirtPkg/Library/XenVirtMemInfoLib/
 F: ArmVirtPkg/PrePi/
 F: ArmVirtPkg/XenAcpiPlatformDxe/
@@ -374,6 +373,7 @@ F: OvmfPkg/Library/XenConsoleSerialPortLib/
 F: OvmfPkg/Library/XenHypercallLib/
 F: OvmfPkg/Library/XenIoMmioLib/
 F: OvmfPkg/Library/XenPlatformLib/
+F: OvmfPkg/Library/XenRealTimeClockLib/
 F: OvmfPkg/OvmfXen.*
 F: OvmfPkg/OvmfXenElfHeaderGenerator.c
 F: OvmfPkg/PlatformPei/MemDetect.c
Signature · 6 lines
Anthony PERARD

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

PATCH v4 11/35 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.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---
 OvmfPkg/XenPlatformPei/Xen.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
OvmfPkg/XenPlatformPei/Xen.c +9 -9
index 9962fe9fc7..5c7d7ddc1c 100644
@@ -53,18 +53,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 · 6 lines
Anthony PERARD

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

PATCH v4 15/35 OvmfPkg/AcpiPlatformDxe: Use Xen PVH RSDP if it exist

In reply to Anthony PERARD

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

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- fix coding style

v3:
- patch splited from the previous one
- Fix DEBUG format string, use %p for pointers. and use gEfiCallerBaseName to print module name

 OvmfPkg/AcpiPlatformDxe/Xen.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
OvmfPkg/AcpiPlatformDxe/Xen.c +17 -0
index 82794b933e..f80dfe1a57 100644
@@ -36,10 +36,27 @@ GetXenAcpiRsdp (
   EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER   *RsdpStructurePtr;
   UINT8                                          *XenAcpiPtr;
   UINT8                                          Sum;
+  EFI_XEN_INFO                                   *XenInfo;
 
   //
   // Detect the RSDP structure
   //
+
+  //
+  // First look for PVH one
+  //
+  XenInfo = XenGetInfoHOB ();
+  ASSERT (XenInfo != NULL);
+  if (XenInfo->RsdpPvh != NULL) {
+    DEBUG ((DEBUG_INFO, "%a: Use ACPI RSDP table at 0x%p\n",
+      gEfiCallerBaseName, XenInfo->RsdpPvh));
+    *RsdpPtr = XenInfo->RsdpPvh;
+    return EFI_SUCCESS;
+  }
+
+  //
+  // Otherwise, look for the HVM one
+  //
   for (XenAcpiPtr = (UINT8*)(UINTN) XEN_ACPI_PHYSICAL_ADDRESS;
        XenAcpiPtr < (UINT8*)(UINTN) XEN_BIOS_PHYSICAL_END;
        XenAcpiPtr += 0x10) {
Signature · 6 lines
Anthony PERARD

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

PATCH v4 25/35 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.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- Remove use of XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID, and simply don't set PcdOvmfHostBridgePciDevId.

v2:
- Use new XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID macro

 OvmfPkg/XenPlatformPei/Platform.c | 6 ++++++
 1 file changed, 6 insertions(+)
OvmfPkg/XenPlatformPei/Platform.c +6 -0
index 2f42ca6ccd..717fd0ab1a 100644
@@ -283,6 +283,12 @@ MiscInitialization (
       AcpiEnBit  = ICH9_ACPI_CNTL_ACPI_EN;
       break;
     default:
+      if (XenPvhDetected ()) {
+        //
+        // There is no PCI bus in this case
+        //
+        return;
+      }
       DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
         __FUNCTION__, mHostBridgeDevId));
       ASSERT (FALSE);
Signature · 6 lines
Anthony PERARD

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

PATCH v4 10/35 OvmfPkg/XenPlatformPei: Detect OVMF_INFO from hvmloader

In reply to Anthony PERARD

EFI_XEN_OVMF_INFO 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.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- fix coding style
- fix commit message

 OvmfPkg/Include/Guid/XenInfo.h |  4 ----
 OvmfPkg/PlatformPei/Xen.c      |  3 ---
 OvmfPkg/XenPlatformPei/Xen.c   | 25 +++++++++++++++++++++++--
 3 files changed, 23 insertions(+), 9 deletions(-)
OvmfPkg/Include/Guid/XenInfo.h +0 -4
index 25d76a7828..b052d618fd 100644
@@ -18,10 +18,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 89dc4143b2..3e15b32a73 100644
@@ -98,9 +98,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 +23 -2
index f4d0d1c73b..9962fe9fc7 100644
@@ -33,6 +33,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
 
@@ -78,6 +84,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);
@@ -97,8 +105,21 @@ 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 · 6 lines
Anthony PERARD

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

PATCH v4 19/35 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().

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---
 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 925df31f88..4a80057bdc 100644
@@ -79,6 +79,11 @@ InstallClearCacheCallback (
   VOID
   );
 
+EFI_STATUS
+XenConnect (
+  VOID
+  );
+
 EFI_STATUS
 InitializeXen (
   VOID
OvmfPkg/XenPlatformPei/Platform.c +2 -0
index 5809eadb0b..6aaafc3ee9 100644
@@ -416,6 +416,8 @@ InitializeXenPlatform (
     CpuDeadLoop ();
   }
 
+  XenConnect ();
+
   BootModeInitialization ();
   AddressWidthInitialization ();
 
OvmfPkg/XenPlatformPei/Xen.c +12 -11
index 2105304c41..29b42b746c 100644
@@ -72,14 +72,11 @@ XenGetE820Map (
 /**
   Connects to the Hypervisor.
 
-  @param  XenLeaf     CPUID index used to connect.
-
   @return EFI_STATUS
 
 **/
 EFI_STATUS
 XenConnect (
-  UINT32 XenLeaf
   )
 {
   UINT32 Index;
@@ -91,7 +88,13 @@ XenConnect (
   UINT32 *PVHResetVectorData;
   RETURN_STATUS Status;
 
-  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;
@@ -103,7 +106,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 ((DEBUG_ERROR, "Detected Xen version %d.%d\n",
           XenVersion >> 16, XenVersion & 0xFFFF));
   mXenInfo.VersionMajor = (UINT16)(XenVersion >> 16);
@@ -262,12 +269,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 · 6 lines
Anthony PERARD

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

PATCH v4 20/35 OvmfPkg/XenPlatformPei: Introduce XenPvhDetected

In reply to Anthony PERARD

XenPvhDetected() can be used to figure out if OVMF has started via the Xen PVH entry point.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---
 OvmfPkg/XenPlatformPei/Platform.h |  5 +++++
 OvmfPkg/XenPlatformPei/Xen.c      | 13 +++++++++++++
 2 files changed, 18 insertions(+)
OvmfPkg/XenPlatformPei/Platform.h +5 -0
index 4a80057bdc..db9a62572f 100644
@@ -99,6 +99,11 @@ XenHvmloaderDetected (
   VOID
   );
 
+BOOLEAN
+XenPvhDetected (
+  VOID
+  );
+
 VOID
 AmdSevInitialize (
   VOID
OvmfPkg/XenPlatformPei/Xen.c +13 -0
index 29b42b746c..71fe5de446 100644
@@ -214,6 +214,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 · 6 lines
Anthony PERARD

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

PATCH v4 28/35 OvmfPkg/PlatformBootManagerLib: Handle the absence of PCI bus on Xen PVH

In reply to Anthony PERARD

When running in a Xen PVH guest, there's nothing to do in PciAcpiInitialization() because there isn't any PCI bus. When the Host Bridge DID isn't recognised, simply continue. (The value of PcdOvmfHostBridgePciDevId would be 0 because it isn't set.)

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- Instead of checking for a false value, XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID, simply check if we are running xen when the HostBridge device ID isn't recognised.

 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 6 ++++++
 1 file changed, 6 insertions(+)
OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +6 -0
index d5d5d20fd8..1eba304f09 100644
@@ -1208,6 +1208,12 @@ PciAcpiInitialization (
       PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H
       break;
     default:
+      if (XenDetected ()) {
+        //
+        // There is no PCI bus in this case.
+        //
+        return;
+      }
       DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
         __FUNCTION__, mHostBridgeDevId));
       ASSERT (FALSE);
Signature · 6 lines
Anthony PERARD

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

PATCH v4 26/35 OvmfPkg/XenPlatformLib: Cache result for XenDetected

In reply to Anthony PERARD

We are going to replace XenDetected() implementation in PlatformBootManagerLib by the one in XenPlatformLib. PlatformBootManagerLib's implementation does cache the result of GetFirstGuidHob(), so we do something similar in XenPlatformLib.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- fix coding style

v3:
- new patch

 .../Library/XenPlatformLib/XenPlatformLib.c   | 20 +++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c +16 -4
index 974a0e73f1..8f20ae2d45 100644
@@ -25,14 +25,26 @@ XenGetInfoHOB (
   VOID
   )
 {
-  EFI_HOB_GUID_TYPE  *GuidHob;
+  EFI_HOB_GUID_TYPE   *GuidHob;
+  STATIC BOOLEAN      Cached = FALSE;
+  STATIC EFI_XEN_INFO *XenInfo;
+
+  //
+  // Return the cached result for the benefit of XenDetected that can be
+  // called many times.
+  //
+  if (Cached) {
+    return XenInfo;
+  }
 
   GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
   if (GuidHob == NULL) {
-    return NULL;
+    XenInfo = NULL;
+  } else {
+    XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
   }
-
-  return (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
+  Cached = TRUE;
+  return XenInfo;
 }
 
 /**
Signature · 6 lines
Anthony PERARD

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

PATCH v4 16/35 OvmfPkg/XenHypercallLib: Enable it in PEIM

In reply to Anthony PERARD

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

Change the return value of XenHypercallLibInit so failure can be detected when the call shouldn't fail, but still have the constructor always succeed.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- only modify XenHypercallLib, and to the modification of XenPlatformPei in a separated patch.
- Allow XenHypercallLibInit to be called outside the library instead of creating a new function, but also return failure on failure, and have a new constructor that never fail.

 .../Library/XenHypercallLib/XenHypercallLib.inf  |  4 ++--
 OvmfPkg/Include/Library/XenHypercallLib.h        | 12 ++++++++++++
 .../Library/XenHypercallLib/X86XenHypercall.c    |  8 +-------
 OvmfPkg/Library/XenHypercallLib/XenHypercall.c   | 16 ++++++++++++++++
 4 files changed, 31 insertions(+), 9 deletions(-)
OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf +2 -2
index 1208f0057a..21ce5b4434 100644
@@ -12,10 +12,10 @@ [Defines]
   FILE_GUID                      = B5EE9A32-CA5A-49A8-82E3-ADA4CCB77C7C
   MODULE_TYPE                    = BASE
   VERSION_STRING                 = 1.0
-  CONSTRUCTOR                    = XenHypercallLibInit
+  CONSTRUCTOR                    = XenHypercallLibConstruct
 
 [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/Include/Library/XenHypercallLib.h +12 -0
index c43822782b..c1491dd652 100644
@@ -10,6 +10,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.
+**/
+RETURN_STATUS
+EFIAPI
+XenHypercallLibInit (
+  VOID
+  );
+
 /**
   Check if the Xen Hypercall library is able to make calls to the Xen
   hypervisor.
OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c +1 -7
index 27083f924f..f779e46470 100644
@@ -59,13 +59,7 @@ XenHypercallLibInit (
 
   GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
   if (GuidHob == NULL) {
-    //
-    // We don't fail library construction, since that has catastrophic
-    // consequences for client modules (whereas those modules may easily be
-    // running on a non-Xen platform). Instead, XenHypercallIsAvailable() above
-    // will return FALSE.
-    //
-    return RETURN_SUCCESS;
+    return RETURN_NOT_FOUND;
   }
   XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
   HyperPage = XenInfo->HyperPages;
OvmfPkg/Library/XenHypercallLib/XenHypercall.c +16 -0
index a2c41a2a69..d4fa802743 100644
@@ -15,6 +15,22 @@
 #include <Library/DebugLib.h>
 #include <Library/XenHypercallLib.h>
 
+RETURN_STATUS
+EFIAPI
+XenHypercallLibConstruct (
+  VOID
+  )
+{
+  XenHypercallLibInit ();
+  //
+  // We don't fail library construction, since that has catastrophic
+  // consequences for client modules (whereas those modules may easily be
+  // running on a non-Xen platform). Instead, XenHypercallIsAvailable()
+  // will return FALSE.
+  //
+  return RETURN_SUCCESS;
+}
+
 UINT64
 EFIAPI
 XenHypercallHvmGetParam (
Signature · 6 lines
Anthony PERARD

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

PATCH v4 35/35 OvmfPkg/OvmfXen: 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 XenRealTimeClockLib which simply always return the same time. This will work on both Xen PVH and HVM guests.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- moved RealTimeClockLib|*/XenRealTimeClockLib.inf to the global [LibraryClasses]

 OvmfPkg/OvmfXen.dsc | 3 ++-
 OvmfPkg/OvmfXen.fdf | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
OvmfPkg/OvmfXen.dsc +2 -1
index 5e07b37279..5a31f75f05 100644
@@ -199,6 +199,7 @@ [LibraryClasses]
 
   Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
   TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+  RealTimeClockLib|OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf
 
 [LibraryClasses.common]
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
@@ -564,7 +565,7 @@ [Components]
   }
   MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
   MdeModulePkg/Universal/Metronome/Metronome.inf
-  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
+  EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
   MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
   MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {
     <LibraryClasses>
OvmfPkg/OvmfXen.fdf +1 -1
index 517a492f14..e6e9e184ef 100644
@@ -307,7 +307,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 · 6 lines
Anthony PERARD

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

PATCH v4 29/35 OvmfPkg/OvmfXen: Override PcdFSBClock to Xen vLAPIC timer frequency

In reply to Anthony PERARD

PcdFSBClock is used by SecPeiDxeTimerLibCpu, the TimerLib implementation. It will also be used by XenTimerDxe. Override PcdFSBClock to match Xen vLAPIC timer frequency.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- expand commit message body to be standalone

 OvmfPkg/OvmfXen.dsc | 3 +++
 1 file changed, 3 insertions(+)
OvmfPkg/OvmfXen.dsc +3 -0
index 22970eda5d..477d8c76a1 100644
@@ -439,6 +439,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 · 6 lines
Anthony PERARD

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

PATCH v4 33/35 OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables

In reply to Anthony PERARD

XenIoPvhDxe 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 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.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- Removed XenIoPvhDxeNotifyExitBoot() which was doing action that should not be done in an ExitBootServices notification. (InitializeXenIoPvhDxe() has been cleaned up following this.)
- Use new PcdXenGrantFrames.
- Some coding style fix
- Update Maintainers.txt

v3:
- downgrade type to DXE_DRIVER
- use SPDX
- rework InitializeXenIoPvhDxe, and handle errors properly.
- Free the reserved allocation in ExitBootServices even if the XenIo protocol could successfully been uninstalled.

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/OvmfXen.dsc                 |  2 ++
 OvmfPkg/OvmfXen.fdf                 |  1 +
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf | 35 +++++++++++++++++++
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c   | 53 +++++++++++++++++++++++++++++
 Maintainers.txt                     |  1 +
 5 files changed, 92 insertions(+)
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c
OvmfPkg/OvmfXen.dsc +2 -0
index e719a168f8..5e07b37279 100644
@@ -195,6 +195,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
   TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
@@ -583,6 +584,7 @@ [Components]
       NULL|OvmfPkg/Csm/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf
 !endif
   }
+  OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
   OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
   OvmfPkg/XenBusDxe/XenBusDxe.inf
   OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
OvmfPkg/OvmfXen.fdf +1 -0
index 5c1a925d6a..517a492f14 100644
@@ -309,6 +309,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 new file +35 -0
new file mode 100644
index 0000000000..5740df6e59
@@ -0,0 +1,35 @@
+## @file
+#  Driver for the XenIo protocol
+#
+#  Copyright (c) 2019, Citrix Systems, Inc.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION               = 0x00010005
+  BASE_NAME                 = XenIoPvhDxe
+  FILE_GUID                 = 7a567cc4-0e75-4d7a-a305-c3db109b53ad
+  MODULE_TYPE               = DXE_DRIVER
+  VERSION_STRING            = 1.0
+  ENTRY_POINT               = InitializeXenIoPvhDxe
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[Sources]
+  XenIoPvhDxe.c
+
+[LibraryClasses]
+  MemoryAllocationLib
+  UefiDriverEntryPoint
+  XenIoMmioLib
+  XenPlatformLib
+
+[FixedPcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenGrantFrames
+
+[Depex]
+  TRUE
OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c new file +53 -0

53 lines not on this page · raw message

Maintainers.txt +1 -0
index 78e9f889ab..79defd13bf 100644
@@ -382,6 +382,7 @@ F: OvmfPkg/PlatformPei/Xen.*
 F: OvmfPkg/SmbiosPlatformDxe/*Xen.c
 F: OvmfPkg/XenBusDxe/
 F: OvmfPkg/XenIoPciDxe/
+F: OvmfPkg/XenIoPvhDxe/
 F: OvmfPkg/XenPlatformPei/
 F: OvmfPkg/XenPvBlkDxe/
 F: OvmfPkg/XenResetVector/
Signature · 6 lines
Anthony PERARD

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

PATCH v4 12/35 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.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- use SPDX
- use SIGNATURE_32
- fix coding style

 OvmfPkg/XenPlatformPei/XenPlatformPei.inf     |   3 +
 OvmfPkg/Include/Guid/XenInfo.h                |   4 +
 .../Xen/arch-x86/hvm/start_info.h             | 143 ++++++++++++++++++
 OvmfPkg/XenPlatformPei/Xen.c                  |  25 +++
 4 files changed, 175 insertions(+)
 create mode 100644 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/hvm/start_info.h
OvmfPkg/XenPlatformPei/XenPlatformPei.inf +3 -0
index d1265c365a..4d00206d09 100644
@@ -84,6 +84,9 @@ [Pcd]
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy
   gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
 
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize
+
 [FixedPcd]
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
 
OvmfPkg/Include/Guid/XenInfo.h +4 -0
index b052d618fd..25743b3884 100644
@@ -25,6 +25,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 +143 -0

143 lines not on this page · raw message

OvmfPkg/XenPlatformPei/Xen.c +25 -0
index 5c7d7ddc1c..b366139a0a 100644
@@ -25,6 +25,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"
@@ -86,6 +87,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);
@@ -121,6 +123,29 @@ 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 (PcdXenPvhStartOfDayStructPtr);
+  //
+  // That magic value is written in XenResetVector/Ia32/XenPVHMain.asm
+  //
+  if (PVHResetVectorData[1] == SIGNATURE_32 ('X', 'P', 'V', 'H')) {
+    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 · 6 lines
Anthony PERARD

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

PATCH v4 22/35 OvmfPkg/XenPlatformPei: no hvmloader: get the E820 table via hypercall

In reply to Anthony PERARD

When the Xen PVH entry point has been used, hvmloader hasn't run and hasn't prepared an E820 table. 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.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v3:
- fix commit message
- add 'm' prefix to the global variables
and make them static

 OvmfPkg/XenPlatformPei/Xen.c | 46 +++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
OvmfPkg/XenPlatformPei/Xen.c +45 -1
index 71fe5de446..a21d657357 100644
@@ -27,6 +27,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"
@@ -40,6 +41,8 @@ EFI_XEN_INFO mXenInfo;
 // Only the E820 table is used by OVMF.
 //
 EFI_XEN_OVMF_INFO *mXenHvmloaderInfo;
+STATIC EFI_E820_ENTRY64 mE820Entries[128];
+STATIC UINT32 mE820EntriesCount;
 
 /**
   Returns E820 map provided by Xen
@@ -55,6 +58,12 @@ XenGetE820Map (
   UINT32 *Count
   )
 {
+  INTN ReturnCode;
+  xen_memory_map_t Parameters;
+  UINTN LoopIndex;
+  UINTN Index;
+  EFI_E820_ENTRY64 TmpEntry;
+
   //
   // Get E820 produced by hvmloader
   //
@@ -66,7 +75,42 @@ XenGetE820Map (
     return EFI_SUCCESS;
   }
 
-  return EFI_NOT_FOUND;
+  //
+  // Otherwise, get the E820 table from the Xen hypervisor
+  //
+
+  if (mE820EntriesCount > 0) {
+    *Entries = mE820Entries;
+    *Count = mE820EntriesCount;
+    return EFI_SUCCESS;
+  }
+
+  Parameters.nr_entries = 128;
+  set_xen_guest_handle (Parameters.buffer, mE820Entries);
+
+  // Returns a errno
+  ReturnCode = XenHypercallMemoryOp (XENMEM_memory_map, &Parameters);
+  ASSERT (ReturnCode == 0);
+
+  mE820EntriesCount = Parameters.nr_entries;
+
+  //
+  // Sort E820 entries
+  //
+  for (LoopIndex = 1; LoopIndex < mE820EntriesCount; LoopIndex++) {
+    for (Index = LoopIndex; Index < mE820EntriesCount; Index++) {
+      if (mE820Entries[Index - 1].BaseAddr > mE820Entries[Index].BaseAddr) {
+        TmpEntry = mE820Entries[Index];
+        mE820Entries[Index] = mE820Entries[Index - 1];
+        mE820Entries[Index - 1] = TmpEntry;
+      }
+    }
+  }
+
+  *Count = mE820EntriesCount;
+  *Entries = mE820Entries;
+
+  return EFI_SUCCESS;
 }
 
 /**
Signature · 6 lines
Anthony PERARD

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

PATCH v4 30/35 OvmfPkg/OvmfXen: Introduce XenTimerDxe

In reply to Anthony PERARD

"OvmfPkg/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 "OvmfPkg/8254TimerDxe" implementation.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- fix the commit message to reflect the fact that the original code as moved.
- Update Maintainers.txt

v3:
- rebased, SPDX, copyright

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/OvmfXen.dsc                 |   3 +-
 OvmfPkg/OvmfXen.fdf                 |   3 +-
 OvmfPkg/XenTimerDxe/XenTimerDxe.inf |  42 ++++
 OvmfPkg/XenTimerDxe/XenTimerDxe.h   | 177 ++++++++++++++
 OvmfPkg/XenTimerDxe/XenTimerDxe.c   | 355 ++++++++++++++++++++++++++++
 Maintainers.txt                     |   1 +
 6 files changed, 577 insertions(+), 4 deletions(-)
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.inf
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.h
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.c
OvmfPkg/OvmfXen.dsc +1 -2
index 477d8c76a1..54ac910d8e 100644
@@ -547,10 +547,9 @@ [Components]
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
 
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
-  OvmfPkg/8259InterruptControllerDxe/8259.inf
+  OvmfPkg/XenTimerDxe/XenTimerDxe.inf
   UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
   UefiCpuPkg/CpuDxe/CpuDxe.inf
-  OvmfPkg/8254TimerDxe/8254Timer.inf
   OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
   OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
   MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
OvmfPkg/OvmfXen.fdf +1 -2
index 49997fee9b..fa0830a324 100644
@@ -298,10 +298,9 @@ [FV.DXEFV]
 INF  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
 INF  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
 INF  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
-INF  OvmfPkg/8259InterruptControllerDxe/8259.inf
+INF  OvmfPkg/XenTimerDxe/XenTimerDxe.inf
 INF  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
 INF  UefiCpuPkg/CpuDxe/CpuDxe.inf
-INF  OvmfPkg/8254TimerDxe/8254Timer.inf
 INF  OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
 INF  OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
 INF  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
OvmfPkg/XenTimerDxe/XenTimerDxe.inf new file +42 -0

42 lines not on this page · raw message

OvmfPkg/XenTimerDxe/XenTimerDxe.h new file +177 -0

177 lines not on this page · raw message

OvmfPkg/XenTimerDxe/XenTimerDxe.c new file +355 -0

355 lines not on this page · raw message

Maintainers.txt +1 -0
index f51731a6b6..78e9f889ab 100644
@@ -385,6 +385,7 @@ F: OvmfPkg/XenIoPciDxe/
 F: OvmfPkg/XenPlatformPei/
 F: OvmfPkg/XenPvBlkDxe/
 F: OvmfPkg/XenResetVector/
+F: OvmfPkg/XenTimerDxe/
 R: Anthony Perard <[email protected]>
 R: Julien Grall <[email protected]>
 
Signature · 6 lines
Anthony PERARD

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

PATCH v4 14/35 OvmfPkg/AcpiPlatformDxe: Use XenPlatformLib

In reply to Anthony PERARD

This patch replace the XenDetected() function by the one in XenPlatformLib.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- removed gEfiXenInfoGuid from Guids list.

v3:
- new patch, splited from the next patch
(which was OvmfPkg/AcpiPlatformDxe: Use PVH RSDP if exist)

 OvmfPkg/OvmfPkgIa32.dsc                     |  1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                  |  1 +
 OvmfPkg/OvmfPkgX64.dsc                      |  1 +
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf |  3 +--
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h      |  6 +-----
 OvmfPkg/AcpiPlatformDxe/Xen.c               | 24 ---------------------
 6 files changed, 5 insertions(+), 31 deletions(-)
OvmfPkg/OvmfPkgIa32.dsc +1 -0
index 6ab7300186..66e944436a 100644
@@ -200,6 +200,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 f163aa2671..51c2bfb44f 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/OvmfPkgX64.dsc +1 -0
index fa98f16a3f..ba7a758844 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/AcpiPlatformDxe/AcpiPlatformDxe.inf +1 -2
index 24634eeae2..e486b8afa5 100644
@@ -44,13 +44,13 @@ [LibraryClasses]
   DebugLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
-  HobLib
   QemuFwCfgLib
   QemuFwCfgS3Lib
   MemoryAllocationLib
   BaseLib
   DxeServicesTableLib
   OrderedCollectionLib
+  XenPlatformLib
 
 [Protocols]
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED
@@ -58,7 +58,6 @@ [Protocols]
   gEfiPciIoProtocolGuid                         # PROTOCOL SOMETIMES_CONSUMED
 
 [Guids]
-  gEfiXenInfoGuid
   gRootBridgesConnectedEventGroupGuid
 
 [Pcd]
OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h +1 -5
index 3037afcf18..9597e028e4 100644
@@ -19,6 +19,7 @@
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/DebugLib.h>
 #include <Library/PcdLib.h>
+#include <Library/XenPlatformLib.h>
 
 #include <IndustryStandard/Acpi.h>
 
@@ -52,11 +53,6 @@ QemuInstallAcpiTable (
   OUT  UINTN                         *TableKey
   );
 
-BOOLEAN
-XenDetected (
-  VOID
-  );
-
 EFI_STATUS
 EFIAPI
 InstallXenTables (
OvmfPkg/AcpiPlatformDxe/Xen.c +0 -24
index e4e47bf0e8..82794b933e 100644
@@ -9,8 +9,6 @@
 **/ 
 
 #include "AcpiPlatform.h"
-#include <Library/HobLib.h>
-#include <Guid/XenInfo.h>
 #include <Library/BaseLib.h>
 
 #define XEN_ACPI_PHYSICAL_ADDRESS         0x000EA020
@@ -18,28 +16,6 @@
 
 EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *XenAcpiRsdpStructurePtr = NULL;
 
-/**
-  This function detects if OVMF is running on Xen.
-
-**/
-BOOLEAN
-XenDetected (
-  VOID
-  )
-{
-  EFI_HOB_GUID_TYPE         *GuidHob;
-
-  //
-  // See if a XenInfo HOB is available
-  //
-  GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
-  if (GuidHob == NULL) {
-    return FALSE;
-  }
-
-  return TRUE;
-}
-
 /**
   Get the address of Xen ACPI Root System Description Pointer (RSDP)
   structure.
Signature · 6 lines
Anthony PERARD

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

PATCH v4 27/35 OvmfPkg/PlatformBootManagerLib: Use XenDetected from XenPlatformLib

In reply to Anthony PERARD

Replace the XenDetected() implementation by the one from XenPlatformLib.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- removed gEfiXenInfoGuid from Guids list and the associated include of Guid/XenInfo.h

v3:
- new patch

 .../PlatformBootManagerLib.inf                |  2 +-
 .../PlatformBootManagerLib/BdsPlatform.c      | 34 +------------------
 2 files changed, 2 insertions(+), 34 deletions(-)
OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +1 -1
index 060a3ab4c5..04d614cd49 100644
@@ -54,6 +54,7 @@ [LibraryClasses]
   UefiLib
   PlatformBmPrintScLib
   Tcg2PhysicalPresenceLib
+  XenPlatformLib
 
 [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent
@@ -73,7 +74,6 @@ [Protocols]
   gEfiFirmwareVolume2ProtocolGuid               # PROTOCOL SOMETIMES_CONSUMED
 
 [Guids]
-  gEfiXenInfoGuid
   gEfiEndOfDxeEventGroupGuid
   gRootBridgesConnectedEventGroupGuid
   gUefiShellFileGuid
OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +1 -33
index 797731a41c..d5d5d20fd8 100644
@@ -7,11 +7,11 @@
 **/
 
 #include "BdsPlatform.h"
-#include <Guid/XenInfo.h>
 #include <Guid/RootBridgesConnectedEventGroup.h>
 #include <Protocol/FirmwareVolume2.h>
 #include <Library/PlatformBmPrintScLib.h>
 #include <Library/Tcg2PhysicalPresenceLib.h>
+#include <Library/XenPlatformLib.h>
 
 
 //
@@ -1225,38 +1225,6 @@ PciAcpiInitialization (
   IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0);
 }
 
-/**
-  This function detects if OVMF is running on Xen.
-
-**/
-STATIC
-BOOLEAN
-XenDetected (
-  VOID
-  )
-{
-  EFI_HOB_GUID_TYPE         *GuidHob;
-  STATIC INTN               FoundHob = -1;
-
-  if (FoundHob == 0) {
-    return FALSE;
-  } else if (FoundHob == 1) {
-    return TRUE;
-  }
-
-  //
-  // See if a XenInfo HOB is available
-  //
-  GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
-  if (GuidHob == NULL) {
-    FoundHob = 0;
-    return FALSE;
-  }
-
-  FoundHob = 1;
-  return TRUE;
-}
-
 EFI_STATUS
 EFIAPI
 ConnectRecursivelyIfPciMassStorage (
Signature · 6 lines
Anthony PERARD

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

PATCH v4 13/35 OvmfPkg/Library/XenPlatformLib: New library

In reply to Anthony PERARD

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

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- fix top-level comment style
- Update Maintainers.txt

v3:
- use SPDX
- add XenPlatformLib.h to [LibraryClasses] in OvmfPkg.dec
- fix typos

 OvmfPkg/OvmfPkg.dec                           |  4 ++
 OvmfPkg/OvmfXen.dsc                           |  1 +
 .../Library/XenPlatformLib/XenPlatformLib.inf | 33 +++++++++
 OvmfPkg/Include/Library/XenPlatformLib.h      | 53 ++++++++++++++
 .../Library/XenPlatformLib/XenPlatformLib.c   | 69 +++++++++++++++++++
 Maintainers.txt                               |  2 +
 6 files changed, 162 insertions(+)
 create mode 100644 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
 create mode 100644 OvmfPkg/Include/Library/XenPlatformLib.h
 create mode 100644 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c
OvmfPkg/OvmfPkg.dec +4 -0
index c2a2ebfb95..04d5e29272 100644
@@ -70,6 +70,10 @@ [LibraryClasses]
   #
   XenIoMmioLib|Include/Library/XenIoMmioLib.h
 
+  ##  @libraryclass  Get information about Xen
+  #
+  XenPlatformLib|Include/Library/XenPlatformLib.h
+
 [Guids]
   gUefiOvmfPkgTokenSpaceGuid          = {0x93bb96af, 0xb9f2, 0x4eb8, {0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}}
   gEfiXenInfoGuid                     = {0xd3b46f3b, 0xd441, 0x1244, {0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}}
OvmfPkg/OvmfXen.dsc +1 -0
index b40d39e003..22970eda5d 100644
@@ -194,6 +194,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
   TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf new file +33 -0
new file mode 100644
index 0000000000..32adb246d6
@@ -0,0 +1,33 @@
+## @file
+#  Get information about Xen
+#
+#  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.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = XenPlatformLib
+  FILE_GUID                      = DB54DBB7-8142-4EE5-9364-78C824B582EB
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = XenPlatformLib
+
+[Sources]
+  XenPlatformLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+  HobLib
+
+[Guids]
+  gEfiXenInfoGuid
OvmfPkg/Include/Library/XenPlatformLib.h new file +53 -0

53 lines not on this page · raw message

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

69 lines not on this page · raw message

Maintainers.txt +2 -0
index 016523b401..f51731a6b6 100644
@@ -365,6 +365,7 @@ F: OvmfPkg/Include/Guid/XenInfo.h
 F: OvmfPkg/Include/IndustryStandard/Xen/
 F: OvmfPkg/Include/Library/XenHypercallLib.h
 F: OvmfPkg/Include/Library/XenIoMmioLib.h
+F: OvmfPkg/Include/Library/XenPlatformLib.h
 F: OvmfPkg/Include/Protocol/XenBus.h
 F: OvmfPkg/Include/Protocol/XenIo.h
 F: OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
@@ -372,6 +373,7 @@ F: OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
 F: OvmfPkg/Library/XenConsoleSerialPortLib/
 F: OvmfPkg/Library/XenHypercallLib/
 F: OvmfPkg/Library/XenIoMmioLib/
+F: OvmfPkg/Library/XenPlatformLib/
 F: OvmfPkg/OvmfXen.*
 F: OvmfPkg/OvmfXenElfHeaderGenerator.c
 F: OvmfPkg/PlatformPei/MemDetect.c
Signature · 6 lines
Anthony PERARD

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

Re: [Xen-devel] [edk2-devel] [PATCH v4 02/35] OvmfPkg: Create platform OvmfXen

In reply to Anthony PERARD
Quoted 38 lines · Anthony PERARD

OvmfXen 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.
- reverted d272449d9e1e, "OvmfPkg: raise DXEFV size to 11 MB"

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- rebased
- Update Maintainers.txt

v3:
- rebased, SPDX + 8259/8254 changes

 OvmfPkg/OvmfXen.dsc | 729 ++++++++++++++++++++++++++++++++++++++++++++
 OvmfPkg/OvmfXen.fdf | 439 ++++++++++++++++++++++++++
 Maintainers.txt     |   1 +
 3 files changed, 1169 insertions(+)
 create mode 100644 OvmfPkg/OvmfXen.dsc
 create mode 100644 OvmfPkg/OvmfXen.fdf

[...]

Maintainers.txt F: OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c · line 378

Quoted 13 lines
Maintainers.txt +1 -0
index 0298010809..98f6d828eb 100644
@@ -372,6 +372,7 @@ F: OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
 F: OvmfPkg/Library/XenConsoleSerialPortLib/
 F: OvmfPkg/Library/XenHypercallLib/
 F: OvmfPkg/Library/XenIoMmioLib/
+F: OvmfPkg/OvmfXen.*
 F: OvmfPkg/PlatformPei/MemDetect.c
 F: OvmfPkg/PlatformPei/Platform.*
 F: OvmfPkg/PlatformPei/Xen.*

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

Reviewed-by on v4 3/35
#5 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 03/35] OvmfPkg: Introduce XenResetVector

In reply to Anthony PERARD
Quoted 38 lines · Anthony PERARD

Introduce XenResetVector, a 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 (gEfiFirmwareVolumeTopFileGuid).

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- Update Maintainers.txt

v3:
- Added gEfiFirmwareVolumeTopFileGuid to the commit message.
- rebased: SPDX

 OvmfPkg/OvmfXen.dsc                           |   2 +-
 OvmfPkg/OvmfXen.fdf                           |   2 +-
 OvmfPkg/XenResetVector/XenResetVector.inf     |  38 +++++
 Maintainers.txt                               |   1 +
 .../XenResetVector/Ia16/Real16ToFlat32.asm    | 134 ++++++++++++++++
 OvmfPkg/XenResetVector/Ia32/PageTables64.asm  | 149 ++++++++++++++++++
 OvmfPkg/XenResetVector/XenResetVector.nasmb   |  68 ++++++++
 7 files changed, 392 insertions(+), 2 deletions(-)
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.inf
 create mode 100644 OvmfPkg/XenResetVector/Ia16/Real16ToFlat32.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/PageTables64.asm
 create mode 100644 OvmfPkg/XenResetVector/XenResetVector.nasmb

[...]

Maintainers.txt F: OvmfPkg/SmbiosPlatformDxe/*Xen.c · line 386

Quoted 12 lines
Maintainers.txt +1 -0
index 98f6d828eb..34bdb275b4 100644
@@ -380,6 +380,7 @@ F: OvmfPkg/SmbiosPlatformDxe/*Xen.c
 F: OvmfPkg/XenBusDxe/
 F: OvmfPkg/XenIoPciDxe/
 F: OvmfPkg/XenPvBlkDxe/
+F: OvmfPkg/XenResetVector/
 R: Anthony Perard <[email protected]>
 R: Julien Grall <[email protected]>
 

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

Reviewed-by on v4 4/35
#7 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 04/35] OvmfPkg: Introduce XenPlatformPei

In reply to Anthony PERARD
Quoted 77 lines · Anthony PERARD

Introduce XenPlatformPei, 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.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- replace the other EFI_D_ by DEBUG_.
- Update Maintainers.txt
- fix one trailing whitespace

v3:
- fix coding style in new code
(use DEBUG_xxx, add ASSERT before CpuDeadLoop)
- rebased, SPDX

 OvmfPkg/OvmfXen.dsc                       |   2 +-
 OvmfPkg/OvmfXen.fdf                       |   2 +-
 OvmfPkg/XenPlatformPei/XenPlatformPei.inf |  96 +++++
 OvmfPkg/XenPlatformPei/Cmos.h             |  52 +++
 OvmfPkg/XenPlatformPei/Platform.h         | 108 ++++++
 OvmfPkg/XenPlatformPei/Xen.h              |  39 ++
 OvmfPkg/XenPlatformPei/AmdSev.c           |  64 ++++
 OvmfPkg/XenPlatformPei/ClearCache.c       | 112 ++++++
 OvmfPkg/XenPlatformPei/Cmos.c             |  60 +++
 OvmfPkg/XenPlatformPei/Fv.c               |  76 ++++
 OvmfPkg/XenPlatformPei/MemDetect.c        | 421 ++++++++++++++++++++
 OvmfPkg/XenPlatformPei/Platform.c         | 444 ++++++++++++++++++++++
 OvmfPkg/XenPlatformPei/Xen.c              | 219 +++++++++++
 Maintainers.txt                           |   1 +
 14 files changed, 1694 insertions(+), 2 deletions(-)
 create mode 100644 OvmfPkg/XenPlatformPei/XenPlatformPei.inf
 create mode 100644 OvmfPkg/XenPlatformPei/Cmos.h
 create mode 100644 OvmfPkg/XenPlatformPei/Platform.h
 create mode 100644 OvmfPkg/XenPlatformPei/Xen.h
 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

[...]

Maintainers.txt F: OvmfPkg/PlatformPei/Xen.* · line 385

Quoted 13 lines
Maintainers.txt +1 -0
index 34bdb275b4..42ec8d54af 100644
@@ -379,6 +379,7 @@ F: OvmfPkg/PlatformPei/Xen.*
 F: OvmfPkg/SmbiosPlatformDxe/*Xen.c
 F: OvmfPkg/XenBusDxe/
 F: OvmfPkg/XenIoPciDxe/
+F: OvmfPkg/XenPlatformPei/
 F: OvmfPkg/XenPvBlkDxe/
 F: OvmfPkg/XenResetVector/
 R: Anthony Perard <[email protected]>

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

Acked-by on v4 5/35
#9 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 05/35] OvmfPkg/OvmfXen: Creating an ELF header

In reply to Anthony PERARD
Quoted 32 lines · Anthony PERARD

This patch changes the flash device image of OvmfXen to make it look like it's an ELF. For this, we replace the empty embedded variable store by a binary array, which is a ELF file header.

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. The header also includes a Xen ELF note that is part of the PVH ABI.

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

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- fix top-level comment style
- Update Maintainers.txt

v3:
- added license to generate_elf_header.c
which is renamed to OvmfPkg/OvmfXenElfHeaderGenerator.c
- added an ELF NOTE into the header

 OvmfPkg/OvmfXen.fdf                 | 101 +++++++++++++++++++-
 OvmfPkg/OvmfXenElfHeaderGenerator.c | 140 ++++++++++++++++++++++++++++
 Maintainers.txt                     |   1 +
 3 files changed, 239 insertions(+), 3 deletions(-)
 create mode 100644 OvmfPkg/OvmfXenElfHeaderGenerator.c

[...]

Maintainers.txt F: OvmfPkg/Library/XenConsoleSerialPortLib/ · line 379

Quoted 13 lines
Maintainers.txt +1 -0
index 42ec8d54af..016523b401 100644
@@ -373,6 +373,7 @@ F: OvmfPkg/Library/XenConsoleSerialPortLib/
 F: OvmfPkg/Library/XenHypercallLib/
 F: OvmfPkg/Library/XenIoMmioLib/
 F: OvmfPkg/OvmfXen.*
+F: OvmfPkg/OvmfXenElfHeaderGenerator.c
 F: OvmfPkg/PlatformPei/MemDetect.c
 F: OvmfPkg/PlatformPei/Platform.*
 F: OvmfPkg/PlatformPei/Xen.*

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

Acked-by on v4 6/35
#11 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 06/35] OvmfPkg/XenResetVector: Add new entry point for Xen PVH

In reply to Anthony PERARD
Quoted 14 lines · Anthony PERARD

Add a new entry point for Xen PVH that 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

Also, compare to the original file [1], the two `nop' of the "resetVector" entry point are removed. There were introduced by 8332983e2e33 ("UefiCpuPkg: Replace the un-necessary WBINVD instruction at the reset vector with two NOPs in VTF0.", 2011-08-04), but don't seems to be useful. This is the entry point used by HVM guest (hvmloader).

[1] UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm

Quoted 8 lines

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- remove the two nop in the HVM entry point

Also, new paragraph in the commit message.

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

Acked-by on v4 9/35
#16 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 09/35] OvmfPkg/OvmfXen: use a TimerLib instance that depends only on the CPU

In reply to Anthony PERARD
Quoted 15 lines · Anthony PERARD

The ACPI Timer isn't present in a PVH guest, but local APIC works on both PVH and HVM.

Note that the use of SecPeiDxeTimerLibCpu might be an issue with a driver of type DXE_RUNTIME_DRIVER. I've attempted to find out which of the DXE_RUNTIME_DRIVER uses the TimerLib at runtime. I've done that by replacing the TimerLib evaluation in [LibraryClasses.common.DXE_RUNTIME_DRIVER] by a different one and checking every module that uses it (with the --report-file=report build option).

ResetSystemRuntimeDxe is calling the TimerLib API at runtime to do the operation "EfiResetCold", so this may never complete if the OS have disabled the Local APIC Timer.

Quoted 8 lines

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- reworded the first sentence, use "not present" instead of "don't work".

Plus two typo fixes.

Thanks
Laszlo

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

Reviewed-by on v4 13/35
#25 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 13/35] OvmfPkg/Library/XenPlatformLib: New library

In reply to Anthony PERARD
Quoted 29 lines · Anthony PERARD

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

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- fix top-level comment style
- Update Maintainers.txt

v3:
- use SPDX
- add XenPlatformLib.h to [LibraryClasses] in OvmfPkg.dec
- fix typos

 OvmfPkg/OvmfPkg.dec                           |  4 ++
 OvmfPkg/OvmfXen.dsc                           |  1 +
 .../Library/XenPlatformLib/XenPlatformLib.inf | 33 +++++++++
 OvmfPkg/Include/Library/XenPlatformLib.h      | 53 ++++++++++++++
 .../Library/XenPlatformLib/XenPlatformLib.c   | 69 +++++++++++++++++++
 Maintainers.txt                               |  2 +
 6 files changed, 162 insertions(+)
 create mode 100644 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
 create mode 100644 OvmfPkg/Include/Library/XenPlatformLib.h
 create mode 100644 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c

[...]

Quoted 14 lines
Maintainers.txt +1 -0
index 016523b401..f51731a6b6 100644
@@ -365,6 +365,7 @@ F: OvmfPkg/Include/Guid/XenInfo.h
 F: OvmfPkg/Include/IndustryStandard/Xen/
 F: OvmfPkg/Include/Library/XenHypercallLib.h
 F: OvmfPkg/Include/Library/XenIoMmioLib.h
+F: OvmfPkg/Include/Library/XenPlatformLib.h
 F: OvmfPkg/Include/Protocol/XenBus.h
 F: OvmfPkg/Include/Protocol/XenIo.h
 F: OvmfPkg/Library/PciHostBridgeLib/XenSupport.c

Maintainers.txt F: OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c · line 379

Quoted 7 lines
Maintainers.txt +1 -0
@@ -372,6 +373,7 @@ F: OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
 F: OvmfPkg/Library/XenConsoleSerialPortLib/
 F: OvmfPkg/Library/XenHypercallLib/
 F: OvmfPkg/Library/XenIoMmioLib/
+F: OvmfPkg/Library/XenPlatformLib/
 F: OvmfPkg/OvmfXen.*
 F: OvmfPkg/OvmfXenElfHeaderGenerator.c
 F: OvmfPkg/PlatformPei/MemDetect.c

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

#42 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 23/35] OvmfPkg/XenPlatformPei: Rework memory detection

In reply to Anthony PERARD
Quoted 9 lines · 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 work without CMOS by reading the e820 table.

Rework XenPublishRamRegions to also care for the reserved and ACPI entry in the e820 table. The region that was added by InitializeXen() isn't needed as that same entry is in the e820 table provided by hvmloader.

Quoted 4 lines

MTRR settings aren't modified anymore, on HVM it's already done by hvmloader, on PVH it is supposed to have sane default. MTRR will need to be done properly but keeping what's already been done by programmes that has runned before OVMF will do for now.

(1) s/programmes that has runned/programs that have run/

Quoted 202 lines

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- some coding style
- Added AddReservedMemoryRangeHob, and using it.
- this patch now replace "OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it has run" from v3. hvmloader have added an entry in the e820 table, there is no
need for a special case.
- now, everything that is in the e820 table is added to OVMF's memory
map, no more skipping ACPI entries or hvmloader's reserved entries.
Instead, we look for the local APIC region and avoid it if it is
present in the e820.
- rework commit message

 OvmfPkg/XenPlatformPei/Platform.h  | 13 ++++++
 OvmfPkg/XenPlatformPei/MemDetect.c | 69 +++++++++++++++++++++++++++++
 OvmfPkg/XenPlatformPei/Platform.c  | 11 +++++
 OvmfPkg/XenPlatformPei/Xen.c       | 70 +++++++++++++++++++-----------
 4 files changed, 137 insertions(+), 26 deletions(-)
OvmfPkg/XenPlatformPei/Platform.h +13 -0
index db9a62572f..7661f4a8de 100644
@@ -44,6 +44,13 @@ AddReservedMemoryBaseSizeHob (
   BOOLEAN                     Cacheable
   );
 
+VOID
+AddReservedMemoryRangeHob (
+  EFI_PHYSICAL_ADDRESS        MemoryBase,
+  EFI_PHYSICAL_ADDRESS        MemoryLimit,
+  BOOLEAN                     Cacheable
+  );
+
 VOID
 AddressWidthInitialization (
   VOID
@@ -114,6 +121,12 @@ XenPublishRamRegions (
   VOID
   );
 
+EFI_STATUS
+XenGetE820Map (
+  EFI_E820_ENTRY64 **Entries,
+  UINT32 *Count
+  );
+
 extern EFI_BOOT_MODE mBootMode;
 
 extern UINT8 mPhysMemAddressWidth;
OvmfPkg/XenPlatformPei/MemDetect.c +69 -0
index cf95f9c474..1f81eee407 100644
@@ -96,6 +96,45 @@ Q35TsegMbytesInitialization (
   mQ35TsegMbytes = ExtendedTsegMbytes;
 }
 
+STATIC
+UINT64
+GetHighestSystemMemoryAddress (
+  BOOLEAN       Below4gb
+  )
+{
+  EFI_E820_ENTRY64    *E820Map;
+  UINT32              E820EntriesCount;
+  EFI_E820_ENTRY64    *Entry;
+  EFI_STATUS          Status;
+  UINT32              Loop;
+  UINT64              HighestAddress;
+  UINT64              EntryEnd;
+
+  HighestAddress = 0;
+
+  Status = XenGetE820Map (&E820Map, &E820EntriesCount);
+  ASSERT_EFI_ERROR (Status);
+
+  for (Loop = 0; Loop < E820EntriesCount; Loop++) {
+    Entry = E820Map + Loop;
+    EntryEnd = Entry->BaseAddr + Entry->Length;
+
+    if (Entry->Type == EfiAcpiAddressRangeMemory &&
+        EntryEnd > HighestAddress) {
+
+      if (Below4gb && (EntryEnd <= BASE_4GB)) {
+        HighestAddress = EntryEnd;
+      } else if (!Below4gb && (EntryEnd >= BASE_4GB)) {
+        HighestAddress = EntryEnd;
+      }
+    }
+  }
+
+  //
+  // Round down the end address.
+  //
+  return HighestAddress & ~(UINT64)EFI_PAGE_MASK;
+}
 
 UINT32
 GetSystemMemorySizeBelow4gb (
@@ -105,6 +144,19 @@ GetSystemMemorySizeBelow4gb (
   UINT8 Cmos0x34;
   UINT8 Cmos0x35;
 
+  //
+  // In PVH case, there is no CMOS, we have to calculate the memory size
+  // from parsing the E820
+  //
+  if (XenPvhDetected ()) {
+    UINT64  HighestAddress;
+
+    HighestAddress = GetHighestSystemMemoryAddress (TRUE);
+    ASSERT (HighestAddress > 0 && HighestAddress <= BASE_4GB);
+
+    return HighestAddress;
+  }
+
   //
   // CMOS 0x34/0x35 specifies the system memory above 16 MB.
   // * CMOS(0x35) is the high byte
@@ -129,6 +181,23 @@ GetSystemMemorySizeAbove4gb (
   UINT32 Size;
   UINTN  CmosIndex;
 
+  //
+  // In PVH case, there is no CMOS, we have to calculate the memory size
+  // from parsing the E820
+  //
+  if (XenPvhDetected ()) {
+    UINT64  HighestAddress;
+
+    HighestAddress = GetHighestSystemMemoryAddress (FALSE);
+    ASSERT (HighestAddress == 0 || HighestAddress >= BASE_4GB);
+
+    if (HighestAddress >= BASE_4GB) {
+      HighestAddress -= BASE_4GB;
+    }
+
+    return HighestAddress;
+  }
+
   //
   // CMOS 0x5b-0x5d specifies the system memory above 4GB MB.
   // * CMOS(0x5d) is the most significant size byte
OvmfPkg/XenPlatformPei/Platform.c +11 -0
index 6aaafc3ee9..2f42ca6ccd 100644
@@ -102,6 +102,17 @@ AddReservedMemoryBaseSizeHob (
     );
 }
 
+VOID
+AddReservedMemoryRangeHob (
+  EFI_PHYSICAL_ADDRESS        MemoryBase,
+  EFI_PHYSICAL_ADDRESS        MemoryLimit,
+  BOOLEAN                     Cacheable
+  )
+{
+  AddReservedMemoryBaseSizeHob (MemoryBase,
+    (UINT64)(MemoryLimit - MemoryBase), Cacheable);
+}
+
 VOID
 AddIoMemoryRangeHob (
   EFI_PHYSICAL_ADDRESS        MemoryBase,
OvmfPkg/XenPlatformPei/Xen.c +6 -7
index a21d657357..182e96cc5b 100644
@@ -276,9 +276,12 @@ XenPublishRamRegions (
   VOID
   )
 {
-  EFI_E820_ENTRY64  *E820Map;
-  UINT32            E820EntriesCount;
-  EFI_STATUS        Status;
+  EFI_E820_ENTRY64      *E820Map;
+  UINT32                E820EntriesCount;
+  EFI_STATUS            Status;
+  EFI_E820_ENTRY64      *Entry;
+  UINTN                 Index;
+  EFI_PHYSICAL_ADDRESS  LocalApic;
 
   DEBUG ((DEBUG_INFO, "Using memory map provided by Xen\n"));
 
@@ -287,26 +290,47 @@ XenPublishRamRegions (
   //
   E820EntriesCount = 0;
   Status = XenGetE820Map (&E820Map, &E820EntriesCount);
-
   ASSERT_EFI_ERROR (Status);
 
-  if (E820EntriesCount > 0) {
-    EFI_E820_ENTRY64 *Entry;
-    UINT32 Loop;

OvmfPkg/XenPlatformPei/Xen.c XenPublishRamRegions ( · line 295

Quoted 10 lines
OvmfPkg/XenPlatformPei/Xen.c +1 -9
-
-    for (Loop = 0; Loop < E820EntriesCount; Loop++) {
-      Entry = E820Map + Loop;
-
-      //
-      // Only care about RAM
-      //
-      if (Entry->Type != EfiAcpiAddressRangeMemory) {
-        continue;
+  LocalApic = PcdGet32(PcdCpuLocalApicBaseAddress);

(2) missing space before "(" -- but, actually, please see below

Quoted 25 lines
OvmfPkg/XenPlatformPei/Xen.c +25 -0
+  AddIoMemoryBaseSizeHob (LocalApic, SIZE_1MB);
+
+  for (Index = 0; Index < E820EntriesCount; Index++) {
+    UINT64 Base;
+    UINT64 End;
+
+    Entry = &E820Map[Index];
+
+    //
+    // Round up the start address, and round down the end address.
+    //
+    Base = ALIGN_VALUE (Entry->BaseAddr, (UINT64)EFI_PAGE_SIZE);
+    End = (Entry->BaseAddr + Entry->Length) & ~(UINT64)EFI_PAGE_MASK;
+
+    switch (Entry->Type) {
+    case EfiAcpiAddressRangeMemory:
+      AddMemoryRangeHob (Base, End);
+      break;
+    case EfiAcpiAddressRangeACPI:
+      AddReservedMemoryRangeHob (Base, End, FALSE);
+      break;
+    case EfiAcpiAddressRangeReserved:
+      if (Base < LocalApic && LocalApic < End) {
+        //
+        // hvmloader marks a range that overlaps with the local APIC memory

OvmfPkg/XenPlatformPei/Xen.c XenPublishRamRegions ( · line 330

Quoted 10 lines
OvmfPkg/XenPlatformPei/Xen.c +9 -0
+        // mapped region as reserved, but CpuDxe wants it as mapped IO. We
+        // have already added it as mapped IO, so skip it here.
+        //
+        AddReservedMemoryRangeHob (Base, LocalApic, FALSE);
+        if (End > (LocalApic + SIZE_1MB)) {
+          AddReservedMemoryRangeHob (LocalApic + SIZE_1MB, End, FALSE);
+        }
+      } else {
+        AddReservedMemoryRangeHob (Base, End, FALSE);
       }

(3) Not sure how general you want to be here, but I don't think this is fully general. How about:

(3a) before the loop, drop "LocalApic", and add:

UINT64 LapicBase;
UINT64 LapicEnd;

  LapicBase = PcdGet32 (PcdCpuLocalApicBaseAddress);
  LapicEnd = LapicBase + SIZE_1MB;

(3b) inside the loop body, near the top of the block, add:

UINT64 ReservedBase;
UINT64 ReservedEnd;

(3c) under the EfiAcpiAddressRangeReserved case label:

  //
  // add LAPIC predecessor range, if any
  //
  ReservedBase = Base;
  ReservedEnd = MIN (End, LapicBase);
  if (ReservedBase < ReservedEnd) {
    AddReservedMemoryRangeHob (ReservedBase, ReservedEnd, FALSE);
  }

  //
  // add LAPIC successor range, if any
  //
  ReservedBase = MAX (Base, LapicEnd);
  ReservedEnd = End;
  if (ReservedBase < ReservedEnd) {
    AddReservedMemoryRangeHob (ReservedBase, ReservedEnd, FALSE);
  }

This will cover all possible constellations between the [LapicBase, LapicEnd) and [Base, End) intervals.

--*--

Regarding the approach itself, I'll defer to Roger.

Thanks
Laszlo

Quoted 14 lines
OvmfPkg/XenPlatformPei/Xen.c +3 -4
-
-      AddMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
-
-      MtrrSetMemoryAttribute (Entry->BaseAddr, Entry->Length, CacheWriteBack);
+      break;
+    default:
+      break;
     }
   }
 }
@@ -326,12 +350,6 @@ InitializeXen (
 {
   RETURN_STATUS PcdStatus;

OvmfPkg/XenPlatformPei/Xen.c InitializeXen ( · line 355

Quoted 10 lines
OvmfPkg/XenPlatformPei/Xen.c +0 -6
 
-  //
-  // Reserve away HVMLOADER reserved memory [0xFC000000,0xFD000000).
-  // This needs to match HVMLOADER RESERVED_MEMBASE/RESERVED_MEMSIZE.
-  //
-  AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000, FALSE);
-
   PcdStatus = PcdSetBoolS (PcdPciDisableBusEnumeration, TRUE);
   ASSERT_RETURN_ERROR (PcdStatus);
 

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

#43 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 23/35] OvmfPkg/XenPlatformPei: Rework memory detection

Quoted 305 lines · Laszlo Ersek
Quoted 9 lines · 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 work without CMOS by reading the e820 table.

Rework XenPublishRamRegions to also care for the reserved and ACPI entry in the e820 table. The region that was added by InitializeXen() isn't needed as that same entry is in the e820 table provided by hvmloader.

Quoted 4 lines

MTRR settings aren't modified anymore, on HVM it's already done by hvmloader, on PVH it is supposed to have sane default. MTRR will need to be done properly but keeping what's already been done by programmes that has runned before OVMF will do for now.

(1) s/programmes that has runned/programs that have run/

Quoted 202 lines

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- some coding style
- Added AddReservedMemoryRangeHob, and using it.
- this patch now replace "OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it has run" from v3. hvmloader have added an entry in the e820 table, there is no
need for a special case.
- now, everything that is in the e820 table is added to OVMF's memory
map, no more skipping ACPI entries or hvmloader's reserved entries.
Instead, we look for the local APIC region and avoid it if it is
present in the e820.
- rework commit message

 OvmfPkg/XenPlatformPei/Platform.h  | 13 ++++++
 OvmfPkg/XenPlatformPei/MemDetect.c | 69 +++++++++++++++++++++++++++++
 OvmfPkg/XenPlatformPei/Platform.c  | 11 +++++
 OvmfPkg/XenPlatformPei/Xen.c       | 70 +++++++++++++++++++-----------
 4 files changed, 137 insertions(+), 26 deletions(-)
OvmfPkg/XenPlatformPei/Platform.h +13 -0
index db9a62572f..7661f4a8de 100644
@@ -44,6 +44,13 @@ AddReservedMemoryBaseSizeHob (
   BOOLEAN                     Cacheable
   );
 
+VOID
+AddReservedMemoryRangeHob (
+  EFI_PHYSICAL_ADDRESS        MemoryBase,
+  EFI_PHYSICAL_ADDRESS        MemoryLimit,
+  BOOLEAN                     Cacheable
+  );
+
 VOID
 AddressWidthInitialization (
   VOID
@@ -114,6 +121,12 @@ XenPublishRamRegions (
   VOID
   );
 
+EFI_STATUS
+XenGetE820Map (
+  EFI_E820_ENTRY64 **Entries,
+  UINT32 *Count
+  );
+
 extern EFI_BOOT_MODE mBootMode;
 
 extern UINT8 mPhysMemAddressWidth;
OvmfPkg/XenPlatformPei/MemDetect.c +69 -0
index cf95f9c474..1f81eee407 100644
@@ -96,6 +96,45 @@ Q35TsegMbytesInitialization (
   mQ35TsegMbytes = ExtendedTsegMbytes;
 }
 
+STATIC
+UINT64
+GetHighestSystemMemoryAddress (
+  BOOLEAN       Below4gb
+  )
+{
+  EFI_E820_ENTRY64    *E820Map;
+  UINT32              E820EntriesCount;
+  EFI_E820_ENTRY64    *Entry;
+  EFI_STATUS          Status;
+  UINT32              Loop;
+  UINT64              HighestAddress;
+  UINT64              EntryEnd;
+
+  HighestAddress = 0;
+
+  Status = XenGetE820Map (&E820Map, &E820EntriesCount);
+  ASSERT_EFI_ERROR (Status);
+
+  for (Loop = 0; Loop < E820EntriesCount; Loop++) {
+    Entry = E820Map + Loop;
+    EntryEnd = Entry->BaseAddr + Entry->Length;
+
+    if (Entry->Type == EfiAcpiAddressRangeMemory &&
+        EntryEnd > HighestAddress) {
+
+      if (Below4gb && (EntryEnd <= BASE_4GB)) {
+        HighestAddress = EntryEnd;
+      } else if (!Below4gb && (EntryEnd >= BASE_4GB)) {
+        HighestAddress = EntryEnd;
+      }
+    }
+  }
+
+  //
+  // Round down the end address.
+  //
+  return HighestAddress & ~(UINT64)EFI_PAGE_MASK;
+}
 
 UINT32
 GetSystemMemorySizeBelow4gb (
@@ -105,6 +144,19 @@ GetSystemMemorySizeBelow4gb (
   UINT8 Cmos0x34;
   UINT8 Cmos0x35;
 
+  //
+  // In PVH case, there is no CMOS, we have to calculate the memory size
+  // from parsing the E820
+  //
+  if (XenPvhDetected ()) {
+    UINT64  HighestAddress;
+
+    HighestAddress = GetHighestSystemMemoryAddress (TRUE);
+    ASSERT (HighestAddress > 0 && HighestAddress <= BASE_4GB);
+
+    return HighestAddress;
+  }
+
   //
   // CMOS 0x34/0x35 specifies the system memory above 16 MB.
   // * CMOS(0x35) is the high byte
@@ -129,6 +181,23 @@ GetSystemMemorySizeAbove4gb (
   UINT32 Size;
   UINTN  CmosIndex;
 
+  //
+  // In PVH case, there is no CMOS, we have to calculate the memory size
+  // from parsing the E820
+  //
+  if (XenPvhDetected ()) {
+    UINT64  HighestAddress;
+
+    HighestAddress = GetHighestSystemMemoryAddress (FALSE);
+    ASSERT (HighestAddress == 0 || HighestAddress >= BASE_4GB);
+
+    if (HighestAddress >= BASE_4GB) {
+      HighestAddress -= BASE_4GB;
+    }
+
+    return HighestAddress;
+  }
+
   //
   // CMOS 0x5b-0x5d specifies the system memory above 4GB MB.
   // * CMOS(0x5d) is the most significant size byte
OvmfPkg/XenPlatformPei/Platform.c +11 -0
index 6aaafc3ee9..2f42ca6ccd 100644
@@ -102,6 +102,17 @@ AddReservedMemoryBaseSizeHob (
     );
 }
 
+VOID
+AddReservedMemoryRangeHob (
+  EFI_PHYSICAL_ADDRESS        MemoryBase,
+  EFI_PHYSICAL_ADDRESS        MemoryLimit,
+  BOOLEAN                     Cacheable
+  )
+{
+  AddReservedMemoryBaseSizeHob (MemoryBase,
+    (UINT64)(MemoryLimit - MemoryBase), Cacheable);
+}
+
 VOID
 AddIoMemoryRangeHob (
   EFI_PHYSICAL_ADDRESS        MemoryBase,
OvmfPkg/XenPlatformPei/Xen.c +6 -7
index a21d657357..182e96cc5b 100644
@@ -276,9 +276,12 @@ XenPublishRamRegions (
   VOID
   )
 {
-  EFI_E820_ENTRY64  *E820Map;
-  UINT32            E820EntriesCount;
-  EFI_STATUS        Status;
+  EFI_E820_ENTRY64      *E820Map;
+  UINT32                E820EntriesCount;
+  EFI_STATUS            Status;
+  EFI_E820_ENTRY64      *Entry;
+  UINTN                 Index;
+  EFI_PHYSICAL_ADDRESS  LocalApic;
 
   DEBUG ((DEBUG_INFO, "Using memory map provided by Xen\n"));
 
@@ -287,26 +290,47 @@ XenPublishRamRegions (
   //
   E820EntriesCount = 0;
   Status = XenGetE820Map (&E820Map, &E820EntriesCount);
-
   ASSERT_EFI_ERROR (Status);
 
-  if (E820EntriesCount > 0) {
-    EFI_E820_ENTRY64 *Entry;
-    UINT32 Loop;

OvmfPkg/XenPlatformPei/Xen.c XenPublishRamRegions ( · line 295

Quoted 10 lines
OvmfPkg/XenPlatformPei/Xen.c +1 -9
-
-    for (Loop = 0; Loop < E820EntriesCount; Loop++) {
-      Entry = E820Map + Loop;
-
-      //
-      // Only care about RAM
-      //
-      if (Entry->Type != EfiAcpiAddressRangeMemory) {
-        continue;
+  LocalApic = PcdGet32(PcdCpuLocalApicBaseAddress);

(2) missing space before "(" -- but, actually, please see below

Quoted 25 lines
OvmfPkg/XenPlatformPei/Xen.c +25 -0
+  AddIoMemoryBaseSizeHob (LocalApic, SIZE_1MB);
+
+  for (Index = 0; Index < E820EntriesCount; Index++) {
+    UINT64 Base;
+    UINT64 End;
+
+    Entry = &E820Map[Index];
+
+    //
+    // Round up the start address, and round down the end address.
+    //
+    Base = ALIGN_VALUE (Entry->BaseAddr, (UINT64)EFI_PAGE_SIZE);
+    End = (Entry->BaseAddr + Entry->Length) & ~(UINT64)EFI_PAGE_MASK;
+
+    switch (Entry->Type) {
+    case EfiAcpiAddressRangeMemory:
+      AddMemoryRangeHob (Base, End);
+      break;
+    case EfiAcpiAddressRangeACPI:
+      AddReservedMemoryRangeHob (Base, End, FALSE);
+      break;
+    case EfiAcpiAddressRangeReserved:
+      if (Base < LocalApic && LocalApic < End) {
+        //
+        // hvmloader marks a range that overlaps with the local APIC memory

OvmfPkg/XenPlatformPei/Xen.c XenPublishRamRegions ( · line 330

Quoted 10 lines
OvmfPkg/XenPlatformPei/Xen.c +9 -0
+        // mapped region as reserved, but CpuDxe wants it as mapped IO. We
+        // have already added it as mapped IO, so skip it here.
+        //
+        AddReservedMemoryRangeHob (Base, LocalApic, FALSE);
+        if (End > (LocalApic + SIZE_1MB)) {
+          AddReservedMemoryRangeHob (LocalApic + SIZE_1MB, End, FALSE);
+        }
+      } else {
+        AddReservedMemoryRangeHob (Base, End, FALSE);
       }

(3) Not sure how general you want to be here, but I don't think this is fully general. How about:

(3a) before the loop, drop "LocalApic", and add:

UINT64 LapicBase;
UINT64 LapicEnd;

  LapicBase = PcdGet32 (PcdCpuLocalApicBaseAddress);
  LapicEnd = LapicBase + SIZE_1MB;

(3b) inside the loop body, near the top of the block, add:

UINT64 ReservedBase;
UINT64 ReservedEnd;

(3c) under the EfiAcpiAddressRangeReserved case label:

  //
  // add LAPIC predecessor range, if any
  //
  ReservedBase = Base;
  ReservedEnd = MIN (End, LapicBase);
  if (ReservedBase < ReservedEnd) {
    AddReservedMemoryRangeHob (ReservedBase, ReservedEnd, FALSE);
  }

  //
  // add LAPIC successor range, if any
  //
  ReservedBase = MAX (Base, LapicEnd);
  ReservedEnd = End;
  if (ReservedBase < ReservedEnd) {
    AddReservedMemoryRangeHob (ReservedBase, ReservedEnd, FALSE);
  }
Quoted 6 lines

This will cover all possible constellations between the [LapicBase, LapicEnd) and [Base, End) intervals.

--*--

Regarding the approach itself, I'll defer to Roger.

If you and Roger both think that the present patch is good enough (because there is no issue in practice), I'm OK to ACK the patch -- I can fix the typos (1) and (2) when pushing.

(What I propose under (3) could be posted as an incremental improvement, if you agree with it. It could be ignored too, if you think the suggested generality is speculative and would never be exercised in practice.)

Thanks
Laszlo

Quoted 14 lines
Quoted 14 lines
OvmfPkg/XenPlatformPei/Xen.c +3 -4
-
-      AddMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
-
-      MtrrSetMemoryAttribute (Entry->BaseAddr, Entry->Length, CacheWriteBack);
+      break;
+    default:
+      break;
     }
   }
 }
@@ -326,12 +350,6 @@ InitializeXen (
 {
   RETURN_STATUS PcdStatus;
 
Quoted 11 lines

OvmfPkg/XenPlatformPei/Xen.c InitializeXen ( · line 355

Quoted 10 lines
OvmfPkg/XenPlatformPei/Xen.c +0 -6
-  //
-  // Reserve away HVMLOADER reserved memory [0xFC000000,0xFD000000).
-  // This needs to match HVMLOADER RESERVED_MEMBASE/RESERVED_MEMSIZE.
-  //
-  AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000, FALSE);
-
   PcdStatus = PcdSetBoolS (PcdPciDisableBusEnumeration, TRUE);
   ASSERT_RETURN_ERROR (PcdStatus);
 

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

Acked-by on v4 30/35
#61 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 30/35] OvmfPkg/OvmfXen: Introduce XenTimerDxe

In reply to Anthony PERARD
Quoted 43 lines · Anthony PERARD

"OvmfPkg/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 "OvmfPkg/8254TimerDxe" implementation.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- fix the commit message to reflect the fact that the original code as moved.
- Update Maintainers.txt

v3:
- rebased, SPDX, copyright

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/OvmfXen.dsc                 |   3 +-
 OvmfPkg/OvmfXen.fdf                 |   3 +-
 OvmfPkg/XenTimerDxe/XenTimerDxe.inf |  42 ++++
 OvmfPkg/XenTimerDxe/XenTimerDxe.h   | 177 ++++++++++++++
 OvmfPkg/XenTimerDxe/XenTimerDxe.c   | 355 ++++++++++++++++++++++++++++
 Maintainers.txt                     |   1 +
 6 files changed, 577 insertions(+), 4 deletions(-)
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.inf
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.h
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.c

[...]

Maintainers.txt F: OvmfPkg/XenIoPciDxe/ · line 391

Quoted 13 lines
Maintainers.txt +1 -0
index f51731a6b6..78e9f889ab 100644
@@ -385,6 +385,7 @@ F: OvmfPkg/XenIoPciDxe/
 F: OvmfPkg/XenPlatformPei/
 F: OvmfPkg/XenPvBlkDxe/
 F: OvmfPkg/XenResetVector/
+F: OvmfPkg/XenTimerDxe/
 R: Anthony Perard <[email protected]>
 R: Julien Grall <[email protected]>
 

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

#63 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 31/35] OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn

In reply to Anthony PERARD
Quoted 38 lines · 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 implemented via SerialDxe.

That is 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.

Since we use VENDOR_UART_DEVICE_PATH, fix its description and coding style.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- instead of creating a new XEN_CONSOLE_DEVICE_PATH, use the existing VENDOR_UART_DEVICE_PATH. And explain why VENDOR_UART_DEVICE_PATH changed in the commit message.

v3:
- removed PciSioSerialDxe and IsaSerialDxe from OvmfXen, since they would not be used, maybe, to check.
- some coding style fix

- not changed: PciSioSerialDxe: even if we add SerialDxe, we still needs PciSioSerialDxe to have OVMF use the emulated serial port on HVM.

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.

Quoted 7 lines
 OvmfPkg/OvmfXen.dsc                           |  4 ++
 OvmfPkg/OvmfXen.fdf                           |  1 +
 .../PlatformBootManagerLib.inf                |  4 ++
 .../PlatformBootManagerLib/BdsPlatform.h      |  1 +
 .../PlatformBootManagerLib/BdsPlatform.c      |  3 +-
 .../PlatformBootManagerLib/PlatformData.c     | 49 +++++++++++++++++--
 6 files changed, 58 insertions(+), 4 deletions(-)

Looks good, thanks.
Laszlo

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

#77 lore raw
In reply to Anthony PERARD
Quoted 8 lines · Anthony PERARD

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

Changes in v4:
- patch "OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it has run" was removed, and instead a different change is done in "OvmfPkg/XenPlatformPei: Rework memory detection"
- other changes detailed in the notes of each patch

I didn't understand why we'd still have 35 patches with one from v3 removed in v4 -- but I've found the new patch now: "OvmfPkg: Introduce PcdXenGrantFrames".

Hopefully a v5 will not be necessary, but as a "precaution", you could run "git notes edit" on patch v4 32/35 at once, in order to state "introduced in v4", or something similar.

Thanks,
Laszlo

Quoted 144 lines

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.

To build and boot:

To build, simply run OvmfPkg/build.sh -p OvmfPkg/OvmfXen.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-v4

Anthony PERARD (35):
OvmfPkg/ResetSystemLib: Add missing dependency on PciLib
OvmfPkg: Create platform OvmfXen
OvmfPkg: Introduce XenResetVector
OvmfPkg: Introduce XenPlatformPei
OvmfPkg/OvmfXen: 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 jumpstart from either hvmloader or PVH OvmfPkg/OvmfXen: 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 XenPlatformLib OvmfPkg/AcpiPlatformDxe: Use Xen PVH RSDP if it exist OvmfPkg/XenHypercallLib: Enable it in PEIM OvmfPkg/XenPlatformPei: Reinit XenHypercallLib OvmfPkg/XenPlatformPei: Introduce XenHvmloaderDetected OvmfPkg/XenPlatformPei: Setup HyperPages earlier OvmfPkg/XenPlatformPei: Introduce XenPvhDetected
OvmfPkg: Import XENMEM_memory_map hypercall to Xen/memory.h OvmfPkg/XenPlatformPei: no hvmloader: get the 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/XenPlatformLib: Cache result for XenDetected OvmfPkg/PlatformBootManagerLib: Use XenDetected from XenPlatformLib OvmfPkg/PlatformBootManagerLib: Handle the absence of PCI bus on Xen
PVH
OvmfPkg/OvmfXen: Override PcdFSBClock to Xen vLAPIC timer frequency OvmfPkg/OvmfXen: Introduce XenTimerDxe OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn
OvmfPkg: Introduce PcdXenGrantFrames
OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables
OvmfPkg: Move XenRealTimeClockLib from ArmVirtPkg OvmfPkg/OvmfXen: use RealTimeClockRuntimeDxe from EmbeddedPkg

 OvmfPkg/OvmfPkg.dec                           |  10 +
 ArmVirtPkg/ArmVirtXen.dsc                     |   2 +-
 OvmfPkg/OvmfPkgIa32.dsc                       |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                    |   1 +
 OvmfPkg/OvmfPkgX64.dsc                        |   1 +
 OvmfPkg/{OvmfPkgX64.dsc => OvmfXen.dsc}       | 238 +-------
 OvmfPkg/OvmfXen.fdf                           | 539 ++++++++++++++++++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf   |   3 +-
 .../PlatformBootManagerLib.inf                |   6 +-
 .../Library/ResetSystemLib/ResetSystemLib.inf |   1 +
 .../XenHypercallLib/XenHypercallLib.inf       |   4 +-
 .../Library/XenPlatformLib/XenPlatformLib.inf |  33 ++
 .../XenRealTimeClockLib.inf                   |   0
 OvmfPkg/XenBusDxe/XenBusDxe.inf               |   2 +
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf           |  35 ++
 OvmfPkg/XenPlatformPei/XenPlatformPei.inf     | 100 ++++
 OvmfPkg/XenResetVector/XenResetVector.inf     |  41 ++
 OvmfPkg/XenTimerDxe/XenTimerDxe.inf           |  42 ++
 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h        |   6 +-
 OvmfPkg/Include/Guid/XenInfo.h                |   8 +-
 .../Xen/arch-x86/hvm/start_info.h             | 143 +++++
 OvmfPkg/Include/IndustryStandard/Xen/memory.h |  23 +
 OvmfPkg/Include/Library/XenHypercallLib.h     |  12 +
 OvmfPkg/Include/Library/XenPlatformLib.h      |  53 ++
 .../PlatformBootManagerLib/BdsPlatform.h      |   1 +
 OvmfPkg/XenBusDxe/XenBusDxe.h                 |   1 +
 OvmfPkg/XenPlatformPei/Cmos.h                 |  52 ++
 OvmfPkg/XenPlatformPei/Platform.h             | 136 +++++
 OvmfPkg/XenPlatformPei/Xen.h                  |  39 ++
 OvmfPkg/XenTimerDxe/XenTimerDxe.h             | 177 ++++++
 OvmfPkg/AcpiPlatformDxe/Xen.c                 |  41 +-
 .../PlatformBootManagerLib/BdsPlatform.c      |  43 +-
 .../PlatformBootManagerLib/PlatformData.c     |  49 +-
 .../Library/ResetSystemLib/ResetSystemLib.c   |   3 +-
 .../Library/XenHypercallLib/X86XenHypercall.c |   8 +-
 .../Library/XenHypercallLib/XenHypercall.c    |  16 +
 .../Library/XenPlatformLib/XenPlatformLib.c   |  81 +++
 .../XenRealTimeClockLib/XenRealTimeClockLib.c |   0
 OvmfPkg/OvmfXenElfHeaderGenerator.c           | 140 +++++
 OvmfPkg/PlatformPei/Xen.c                     |   3 -
 OvmfPkg/XenBusDxe/GrantTable.c                |   3 +-
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c             |  53 ++
 OvmfPkg/XenPlatformPei/AmdSev.c               |  64 +++
 OvmfPkg/XenPlatformPei/ClearCache.c           | 112 ++++
 OvmfPkg/XenPlatformPei/Cmos.c                 |  60 ++
 OvmfPkg/XenPlatformPei/Fv.c                   |  76 +++
 OvmfPkg/XenPlatformPei/MemDetect.c            | 490 ++++++++++++++++
 OvmfPkg/XenPlatformPei/Platform.c             | 463 +++++++++++++++
 OvmfPkg/XenPlatformPei/Xen.c                  | 373 ++++++++++++
 OvmfPkg/XenTimerDxe/XenTimerDxe.c             | 355 ++++++++++++
 Maintainers.txt                               |  10 +-
 .../XenResetVector/Ia16/Real16ToFlat32.asm    | 137 +++++
 .../XenResetVector/Ia16/ResetVectorVtf0.asm   |  79 +++
 .../XenResetVector/Ia32/Flat32ToFlat64.asm    |  68 +++
 OvmfPkg/XenResetVector/Ia32/PageTables64.asm  | 149 +++++
 .../XenResetVector/Ia32/SearchForBfvBase.asm  |  87 +++
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm    |  84 +++
 OvmfPkg/XenResetVector/XenResetVector.nasmb   |  71 +++
 58 files changed, 4523 insertions(+), 305 deletions(-)
 copy OvmfPkg/{OvmfPkgX64.dsc => OvmfXen.dsc} (76%)
 create mode 100644 OvmfPkg/OvmfXen.fdf
 create mode 100644 OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
 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
 create mode 100644 OvmfPkg/XenPlatformPei/Xen.h
 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/OvmfXenElfHeaderGenerator.c
 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
Quoted 9 lines
 create mode 100644 OvmfPkg/XenTimerDxe/XenTimerDxe.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

Reviewed-by on v4 32/35
#66 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 32/35] OvmfPkg: Introduce PcdXenGrantFrames

In reply to Anthony PERARD
Quoted 43 lines · Anthony PERARD

Introduce PcdXenGrantFrames to replace a define in XenBusDxe and allow the same value to be used in a different module.

The reason for the number of page to be 4 doesn't exist anymore, so simply remove the comment.

---
 OvmfPkg/OvmfPkg.dec             | 3 +++
 OvmfPkg/XenBusDxe/XenBusDxe.inf | 2 ++
 OvmfPkg/XenBusDxe/XenBusDxe.h   | 1 +
 OvmfPkg/XenBusDxe/GrantTable.c  | 3 +--
 4 files changed, 7 insertions(+), 2 deletions(-)
OvmfPkg/OvmfPkg.dec +3 -0
index 04d5e29272..d5fee805ef 100644
@@ -225,6 +225,9 @@ [PcdsFixedAtBuild]
   gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr|0x0|UINT32|0x17
   gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize|0x0|UINT32|0x32
 
+  ## Number of page frames to use for storing grant table entries.
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenGrantFrames|4|UINT32|0x33
+
 [PcdsDynamic, PcdsDynamicEx]
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10
OvmfPkg/XenBusDxe/XenBusDxe.inf +2 -0
index 86e0fb8224..0b78cd0af4 100644
@@ -59,3 +59,5 @@ [Protocols]
   gXenBusProtocolGuid
   gXenIoProtocolGuid
 
+[FixedPcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenGrantFrames
OvmfPkg/XenBusDxe/XenBusDxe.h +0 -0
index 8510361bca..b1dcc3549c 100644

OvmfPkg/XenBusDxe/XenBusDxe.h line 28

Quoted 7 lines
OvmfPkg/XenBusDxe/XenBusDxe.h +1 -0
@@ -22,6 +22,7 @@
 #include <Library/UefiLib.h>
 #include <Library/DevicePathLib.h>
 #include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
 
 
 //

Good catch; in my v3 review at
<http://mid.mail-archive.com/[email protected]>
I didn't realize we'd be introducing the PcdLib dependency anew.

(1) However, in that case, we should list PcdLib in the [LibraryClasses] section of the INF file as well.

With (1) fixed:

There is no need to post v5 just because of this -- if a v5 is otherwise unnecessary, I can fix this up for you before pushing v4.

Thanks
Laszlo

Quoted 6 lines
OvmfPkg/XenBusDxe/GrantTable.c +0 -0
index 6575e9b88c..1130404cd1 100644

OvmfPkg/XenBusDxe/GrantTable.c line 28

Quoted 9 lines
OvmfPkg/XenBusDxe/GrantTable.c +1 -2
@@ -22,8 +22,7 @@
 
 #define NR_RESERVED_ENTRIES 8
 
-/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
-#define NR_GRANT_FRAMES 4
+#define NR_GRANT_FRAMES (FixedPcdGet32 (PcdXenGrantFrames))
 #define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * EFI_PAGE_SIZE / sizeof(grant_entry_v1_t))
 
 STATIC grant_entry_v1_t *GrantTable = NULL;

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

Reviewed-by on v4 33/35
#68 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 33/35] OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables

In reply to Anthony PERARD
Quoted 181 lines · Anthony PERARD

XenIoPvhDxe 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 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.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- Removed XenIoPvhDxeNotifyExitBoot() which was doing action that should not be done in an ExitBootServices notification. (InitializeXenIoPvhDxe() has been cleaned up following this.)
- Use new PcdXenGrantFrames.
- Some coding style fix
- Update Maintainers.txt

v3:
- downgrade type to DXE_DRIVER
- use SPDX
- rework InitializeXenIoPvhDxe, and handle errors properly.
- Free the reserved allocation in ExitBootServices even if the XenIo protocol could successfully been uninstalled.

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/OvmfXen.dsc                 |  2 ++
 OvmfPkg/OvmfXen.fdf                 |  1 +
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf | 35 +++++++++++++++++++
 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c   | 53 +++++++++++++++++++++++++++++
 Maintainers.txt                     |  1 +
 5 files changed, 92 insertions(+)
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
 create mode 100644 OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c
OvmfPkg/OvmfXen.dsc +2 -0
index e719a168f8..5e07b37279 100644
@@ -195,6 +195,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
   TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
@@ -583,6 +584,7 @@ [Components]
       NULL|OvmfPkg/Csm/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf
 !endif
   }
+  OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
   OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
   OvmfPkg/XenBusDxe/XenBusDxe.inf
   OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
OvmfPkg/OvmfXen.fdf +1 -0
index 5c1a925d6a..517a492f14 100644
@@ -309,6 +309,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 new file +35 -0
new file mode 100644
index 0000000000..5740df6e59
@@ -0,0 +1,35 @@
+## @file
+#  Driver for the XenIo protocol
+#
+#  Copyright (c) 2019, Citrix Systems, Inc.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION               = 0x00010005
+  BASE_NAME                 = XenIoPvhDxe
+  FILE_GUID                 = 7a567cc4-0e75-4d7a-a305-c3db109b53ad
+  MODULE_TYPE               = DXE_DRIVER
+  VERSION_STRING            = 1.0
+  ENTRY_POINT               = InitializeXenIoPvhDxe
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[Sources]
+  XenIoPvhDxe.c
+
+[LibraryClasses]
+  MemoryAllocationLib
+  UefiDriverEntryPoint
+  XenIoMmioLib
+  XenPlatformLib
+
+[FixedPcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenGrantFrames
+
+[Depex]
+  TRUE
OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c new file +53 -0
new file mode 100644
index 0000000000..e5699cdd80
@@ -0,0 +1,53 @@
+/** @file
+
+  Driver for the XenIo protocol
+
+  This driver simply allocate space for the grant tables.
+
+  Copyright (c) 2019, Citrix Systems, Inc.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#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
+  )
+{
+  VOID          *Allocation;
+  EFI_STATUS    Status;
+  EFI_HANDLE    XenIoHandle;
+
+  Allocation = NULL;
+  XenIoHandle = NULL;
+
+  if (!XenPvhDetected ()) {
+    return EFI_UNSUPPORTED;
+  }
+
+  Allocation = AllocateReservedPages (FixedPcdGet32 (PcdXenGrantFrames));
+  if (Allocation == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto Error;
+  }
+
+  Status = XenIoMmioInstall (&XenIoHandle, (UINTN) Allocation);
+  if (EFI_ERROR (Status)) {
+    goto Error;
+  }
+
+  return EFI_SUCCESS;
+
+Error:
+  if (Allocation != NULL) {
+    FreePages (Allocation, FixedPcdGet32 (PcdXenGrantFrames));
+  }
+  return Status;
+}
Maintainers.txt +0 -0
index 78e9f889ab..79defd13bf 100644

Maintainers.txt F: OvmfPkg/PlatformPei/Xen.* · line 388

Quoted 7 lines
Maintainers.txt +1 -0
@@ -382,6 +382,7 @@ F: OvmfPkg/PlatformPei/Xen.*
 F: OvmfPkg/SmbiosPlatformDxe/*Xen.c
 F: OvmfPkg/XenBusDxe/
 F: OvmfPkg/XenIoPciDxe/
+F: OvmfPkg/XenIoPvhDxe/
 F: OvmfPkg/XenPlatformPei/
 F: OvmfPkg/XenPvBlkDxe/
 F: OvmfPkg/XenResetVector/

(1) We should #include <Library/PcdLib.h> in the "XenIoPvhDxe.c" file, and list PcdLib in the [LibraryClasses] section of the "XenIoPvhDxe.inf" file.

With (1) fixed:

If v5 doesn't become necessary, I can update this patch for you before pushing the v4 series; if that's what you prefer.

Thanks
Laszlo

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

Reviewed-by on v4 34/35
#72 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 34/35] OvmfPkg: Move XenRealTimeClockLib from ArmVirtPkg

In reply to Anthony PERARD
Quoted 23 lines · Anthony PERARD

Move XenRealTimeClockLib from ArmVirtPkg to OvmfPkg so it can be used from the OvmfPkg by the following patch, "OvmfPkg/OvmfXen: use RealTimeClockRuntimeDxe from EmbeddedPkg"

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- Update Maintainers.txt

v3:
- fix the commit message body

 ArmVirtPkg/ArmVirtXen.dsc                                       | 2 +-
 .../Library/XenRealTimeClockLib/XenRealTimeClockLib.inf         | 0
 .../Library/XenRealTimeClockLib/XenRealTimeClockLib.c           | 0
 Maintainers.txt                                                 | 2 +-
 4 files changed, 2 insertions(+), 2 deletions(-)
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf (100%)
 rename {ArmVirtPkg => OvmfPkg}/Library/XenRealTimeClockLib/XenRealTimeClockLib.c (100%)

[...]

Quoted 14 lines
Maintainers.txt +0 -1
index 79defd13bf..919baccc56 100644
@@ -114,7 +114,6 @@ R: Leif Lindholm <[email protected]>
 ArmVirtPkg: modules used on Xen
 F: ArmVirtPkg/ArmVirtXen.*
 F: ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/
-F: ArmVirtPkg/Library/XenRealTimeClockLib/
 F: ArmVirtPkg/Library/XenVirtMemInfoLib/
 F: ArmVirtPkg/PrePi/
 F: ArmVirtPkg/XenAcpiPlatformDxe/

Maintainers.txt F: OvmfPkg/Library/XenConsoleSerialPortLib/ · line 379

Quoted 7 lines
Maintainers.txt +1 -0
@@ -374,6 +373,7 @@ F: OvmfPkg/Library/XenConsoleSerialPortLib/
 F: OvmfPkg/Library/XenHypercallLib/
 F: OvmfPkg/Library/XenIoMmioLib/
 F: OvmfPkg/Library/XenPlatformLib/
+F: OvmfPkg/Library/XenRealTimeClockLib/
 F: OvmfPkg/OvmfXen.*
 F: OvmfPkg/OvmfXenElfHeaderGenerator.c
 F: OvmfPkg/PlatformPei/MemDetect.c

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

#78 lore raw
In reply to Anthony PERARD

Hi Anthony,

Quoted 8 lines · Anthony PERARD

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

Changes in v4:
- patch "OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it has run" was removed, and instead a different change is done in "OvmfPkg/XenPlatformPei: Rework memory detection"
- other changes detailed in the notes of each patch

I've gone through the v4 series. If reviewers on the xen-devel list think v4 is okay to merge, I can do that (with the small fixups I offered here and there). I suggest that we wait a few days -- please ping me when you believe the review on xen-devel has concluded.

If you prefer to post v5, that works as well of course.

Thanks,
Laszlo

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

#12 lore raw

Re: [Xen-devel] [PATCH v4 06/35] OvmfPkg/XenResetVector: Add new entry point for Xen PVH

In reply to Anthony PERARD
Quoted 60 lines · Anthony PERARD

Add a new entry point for Xen PVH that 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

Also, compare to the original file [1], the two `nop' of the "resetVector" entry point are removed. There were introduced by 8332983e2e33 ("UefiCpuPkg: Replace the un-necessary WBINVD instruction at the reset vector with two NOPs in VTF0.", 2011-08-04), but don't seems to be useful. This is the entry point used by HVM guest (hvmloader).

[1] UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- remove the two nop in the HVM entry point

v3:
- rebased, SPDX
- remove `cli' as via PVH the interrupts are guaranteed to be off
- rewrite some comments

 .../XenResetVector/Ia16/ResetVectorVtf0.asm   | 79 +++++++++++++++++++
 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm    | 49 ++++++++++++
 OvmfPkg/XenResetVector/XenResetVector.nasmb   |  1 +
 3 files changed, 129 insertions(+)
 create mode 100644 OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm
 create mode 100644 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm
OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm new file +19 -0
new file mode 100644
index 0000000000..56749bdbc9
@@ -0,0 +1,79 @@
+;------------------------------------------------------------------------------
+; @file
+; First code executed by processor after resetting.
+;
+; Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019, Citrix Systems, Inc.
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+;------------------------------------------------------------------------------
+
+BITS    16
+
+ALIGN   16
+
+;
+; Pad the image size to 4k when page tables are in VTF0
+;
+; If the VTF0 image has page tables built in, then we need to make

OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm line 29

Quoted 10 lines
OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm new file +10 -0
+; sure the end of VTF0 is 4k above where the page tables end.
+;
+; This is required so the page tables will be 4k aligned when VTF0 is
+; located just below 0x100000000 (4GB) in the firmware device.
+;
+%ifdef ALIGN_TOP_TO_4K_FOR_PAGING
+    TIMES (0x1000 - ($ - EndOfPageTables) - (fourGigabytes - xenPVHEntryPoint)) DB 0
+%endif
+
+BITS    32

I think you likely want an ALIGN 32 here in case ALIGN_TOP_TO_4K_FOR_PAGING is not defined, so that xenPVHEntryPoint is aligned to a double word boundary?

(not that it's mandatory for this to work)

The rest LGTM.

Thanks, Roger.

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

#17 lore raw

Re: [Xen-devel] [PATCH v4 09/35] OvmfPkg/OvmfXen: use a TimerLib instance that depends only on the CPU

In reply to Anthony PERARD
Quoted 15 lines · Anthony PERARD

The ACPI Timer isn't present in a PVH guest, but local APIC works on both PVH and HVM.

Note that the use of SecPeiDxeTimerLibCpu might be an issue with a driver of type DXE_RUNTIME_DRIVER. I've attempted to find out which of the DXE_RUNTIME_DRIVER uses the TimerLib at runtime. I've done that by replacing the TimerLib evaluation in [LibraryClasses.common.DXE_RUNTIME_DRIVER] by a different one and checking every module that uses it (with the --report-file=report build option).

ResetSystemRuntimeDxe is calling the TimerLib API at runtime to do the operation "EfiResetCold", so this may never complete if the OS have disabled the Local APIC Timer.

Quoted 8 lines

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

---

Notes:
v4:
- reworded the first sentence, use "not present" instead of "don't work".

Thanks, I'm afraid I cannot comment on the change itself, but the comment message is accurate now :).

Roger.

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

#21 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 12/35] OvmfPkg/XenPlatformPei: Grab RSDP from PVH guest start of day struct

In reply to Anthony PERARD
Quoted 4 lines · 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.

You seem to change the types when importing start_info.h, is that absolutely necessary?

From my experience working with different projects when importing such headers it's better to keep them verbatim, this makes importing future versions from upstream easier.

I have a comment below, but it's more like a question.

Quoted 33 lines
OvmfPkg/XenPlatformPei/Xen.c +11 -0
index 5c7d7ddc1c..b366139a0a 100644
@@ -25,6 +25,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"
@@ -86,6 +87,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);
@@ -121,6 +123,29 @@ 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 (PcdXenPvhStartOfDayStructPtr);
+  //

OvmfPkg/XenPlatformPei/Xen.c XenConnect ( · line 144

Quoted 10 lines
OvmfPkg/XenPlatformPei/Xen.c +10 -0
+  // That magic value is written in XenResetVector/Ia32/XenPVHMain.asm
+  //
+  if (PVHResetVectorData[1] == SIGNATURE_32 ('X', 'P', 'V', 'H')) {
+    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;

I guess you can do this because OVMF has an identity map of virtual addresses to physical addresses?

I wonder the size of such identity map, and whether you need to check that the rsdp address is indeed inside of that region before converting it to a pointer. The same would apply to PcdXenPvhStartOfDayStructPtr, but that's likely safe because it's always < 4GB, which I assume OVMF always has identity mapped?

Thanks, Roger.

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

#33 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 20/35] OvmfPkg/XenPlatformPei: Introduce XenPvhDetected

In reply to Anthony PERARD
Quoted 6 lines · Anthony PERARD

XenPvhDetected() can be used to figure out if OVMF has started via the Xen PVH entry point.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689

Thanks, I've got a comment, but it can be fixed afterwards if required.

Quoted 28 lines
---
 OvmfPkg/XenPlatformPei/Platform.h |  5 +++++
 OvmfPkg/XenPlatformPei/Xen.c      | 13 +++++++++++++
 2 files changed, 18 insertions(+)
OvmfPkg/XenPlatformPei/Platform.h +5 -0
index 4a80057bdc..db9a62572f 100644
@@ -99,6 +99,11 @@ XenHvmloaderDetected (
   VOID
   );
 
+BOOLEAN
+XenPvhDetected (
+  VOID
+  );
+
 VOID
 AmdSevInitialize (
   VOID
OvmfPkg/XenPlatformPei/Xen.c +0 -0
index 29b42b746c..71fe5de446 100644
@@ -214,6 +214,19 @@ XenHvmloaderDetected (
   return (mXenHvmloaderInfo != NULL);
 }

OvmfPkg/XenPlatformPei/Xen.c XenHvmloaderDetected ( · line 225

Quoted 10 lines
OvmfPkg/XenPlatformPei/Xen.c +9 -0
 
+BOOLEAN
+XenPvhDetected (
+  VOID
+  )
+{
+  //
+  // This function should only be used after XenConnect
+  //
+  ASSERT (mXenInfo.VersionMajor != 0);

That's IMO dangerous. Using the version as an indication that XenConnect has run seems like a bad idea, since returning a major version of 0 is a valid number to return. Can't you check against something else that doesn't depends on hypervisor provided data? (ie:
like some allocations or such that happen in XenConnect)

A paranoid could provider could even return major == 0 and minor == 0 in order to attempt to hide the Xen version used, since guests are not supposed to infer anything from the Xen version, available hypervisor features are reported by other means.

Thanks, Roger.

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

#38 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 22/35] OvmfPkg/XenPlatformPei: no hvmloader: get the E820 table via hypercall

In reply to Anthony PERARD
Quoted 4 lines · Anthony PERARD

When the Xen PVH entry point has been used, hvmloader hasn't run and hasn't prepared an E820 table. 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.

I think we agreed that the above is not true, and that the memory map can be fetched as many times as desired using the hypercall interface.

Thanks, Roger.

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

#44 lore raw

Re: [Xen-devel] [PATCH v4 23/35] OvmfPkg/XenPlatformPei: Rework memory detection

In reply to Anthony PERARD
Quoted 4 lines · 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 work without CMOS by reading the e820 table.

Quoted 8 lines

Rework XenPublishRamRegions to also care for the reserved and ACPI entry in the e820 table. The region that was added by InitializeXen() isn't needed as that same entry is in the e820 table provided by hvmloader.

MTRR settings aren't modified anymore, on HVM it's already done by hvmloader, on PVH it is supposed to have sane default. MTRR will need to be done properly but keeping what's already been done by programmes

^ firmware

Quoted 1 line

that has runned before OVMF will do for now.

^ ran

Quoted 53 lines
OvmfPkg/XenPlatformPei/Xen.c +20 -16
index a21d657357..182e96cc5b 100644
@@ -276,9 +276,12 @@ XenPublishRamRegions (
   VOID
   )
 {
-  EFI_E820_ENTRY64  *E820Map;
-  UINT32            E820EntriesCount;
-  EFI_STATUS        Status;
+  EFI_E820_ENTRY64      *E820Map;
+  UINT32                E820EntriesCount;
+  EFI_STATUS            Status;
+  EFI_E820_ENTRY64      *Entry;
+  UINTN                 Index;
+  EFI_PHYSICAL_ADDRESS  LocalApic;
 
   DEBUG ((DEBUG_INFO, "Using memory map provided by Xen\n"));
 
@@ -287,26 +290,47 @@ XenPublishRamRegions (
   //
   E820EntriesCount = 0;
   Status = XenGetE820Map (&E820Map, &E820EntriesCount);
-
   ASSERT_EFI_ERROR (Status);
 
-  if (E820EntriesCount > 0) {
-    EFI_E820_ENTRY64 *Entry;
-    UINT32 Loop;
-
-    for (Loop = 0; Loop < E820EntriesCount; Loop++) {
-      Entry = E820Map + Loop;
-
-      //
-      // Only care about RAM
-      //
-      if (Entry->Type != EfiAcpiAddressRangeMemory) {
-        continue;
+  LocalApic = PcdGet32(PcdCpuLocalApicBaseAddress);
+  AddIoMemoryBaseSizeHob (LocalApic, SIZE_1MB);
+
+  for (Index = 0; Index < E820EntriesCount; Index++) {
+    UINT64 Base;
+    UINT64 End;
+
+    Entry = &E820Map[Index];
+
+    //
+    // Round up the start address, and round down the end address.
+    //
+    Base = ALIGN_VALUE (Entry->BaseAddr, (UINT64)EFI_PAGE_SIZE);
+    End = (Entry->BaseAddr + Entry->Length) & ~(UINT64)EFI_PAGE_MASK;

OvmfPkg/XenPlatformPei/Xen.c XenPublishRamRegions ( · line 318

Quoted 10 lines
OvmfPkg/XenPlatformPei/Xen.c +10 -0
+
+    switch (Entry->Type) {
+    case EfiAcpiAddressRangeMemory:
+      AddMemoryRangeHob (Base, End);
+      break;
+    case EfiAcpiAddressRangeACPI:
+      AddReservedMemoryRangeHob (Base, End, FALSE);
+      break;
+    case EfiAcpiAddressRangeReserved:
+      if (Base < LocalApic && LocalApic < End) {

Don't you also need to check for equality? In case such region starts at Base == LocalApic?

I guess it doesn't matter that much since this is to workaround a specific issue with hvmloader, but I would like to see this sorted out in hvmloader so that there's no clash anymore.

Thanks, Roger.

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

#51 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 28/35] OvmfPkg/PlatformBootManagerLib: Handle the absence of PCI bus on Xen PVH

In reply to Anthony PERARD
Quoted 4 lines · Anthony PERARD

When running in a Xen PVH guest, there's nothing to do in PciAcpiInitialization() because there isn't any PCI bus. When the Host Bridge DID isn't recognised, simply continue. (The value of PcdOvmfHostBridgePciDevId would be 0 because it isn't set.)

I guess we will need to figure out how to make OVMF happy when passthrough support is added to PVH. Having to fake a bridge is quite cumbersome, but I assume OVMF only pokes at some specific bridge registers which we might be able to emulate without much fuss.

Thanks, Roger.

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

#53 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 29/35] OvmfPkg/OvmfXen: Override PcdFSBClock to Xen vLAPIC timer frequency

In reply to Anthony PERARD
Quoted 3 lines · Anthony PERARD

PcdFSBClock is used by SecPeiDxeTimerLibCpu, the TimerLib implementation. It will also be used by XenTimerDxe. Override PcdFSBClock to match Xen vLAPIC timer frequency.

I'm kind of surprised that his is not automatically detected?

Is it a bug in Xen or just always hardcoded on OVMF?

Thanks, Roger.

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

#64 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 31/35] OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn

In reply to Anthony PERARD
Quoted 5 lines · 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 implemented via SerialDxe.

That is a simple console implementation that can works on both PVH

^ work

Quoted 1 line

guest and HVM guests, even if it rarely going to be use on HVM.

^ is ^ used

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

#69 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 33/35] OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables

In reply to Anthony PERARD
Quoted 7 lines · Anthony PERARD

XenIoPvhDxe 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 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.

Since I'm not familiar with OVMF code, where is the grant table physical memory coming from then, is it allocated from a hole in the memory map?

Thanks, Roger.

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

#74 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 35/35] OvmfPkg/OvmfXen: use RealTimeClockRuntimeDxe from EmbeddedPkg

In reply to Anthony PERARD
Quoted 5 lines · 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 XenRealTimeClockLib which simply always return the same time. This will work on both Xen PVH and HVM guests.

Not that this is not correct, but what's the point in requiring a clock if it can be faked by always returning the same value?

It seems like it's usage is not really required, and could indeed be dropped altogether?

Alternatively, there's the PV clock which is available to PVH guests and will return a proper time.

Thanks, Roger.

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

#22 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 12/35] OvmfPkg/XenPlatformPei: Grab RSDP from PVH guest start of day struct

In reply to Roger Pau Monné
Quoted 8 lines · Roger Pau Monné
Quoted 4 lines · 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.

You seem to change the types when importing start_info.h, is that absolutely necessary?

I guess one could try to map xen's types to EDKII's type with typedefs, but I'm not sur how well that would work. Importing the xen headers is documented so changing the types is fairly easy, see
https://github.com/tianocore/edk2/blob/master/OvmfPkg/Include/IndustryStandard/Xen/README

Also, changing the header further might have been something useful to do, we could have match EDKII's naming convention and source files would have looked a bit less weird.

Quoted 44 lines

From my experience working with different projects when importing such headers it's better to keep them verbatim, this makes importing future versions from upstream easier.

I have a comment below, but it's more like a question.

Quoted 38 lines
OvmfPkg/XenPlatformPei/Xen.c +16 -0
index 5c7d7ddc1c..b366139a0a 100644
@@ -25,6 +25,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"
@@ -86,6 +87,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);
@@ -121,6 +123,29 @@ 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 (PcdXenPvhStartOfDayStructPtr);
+  //
+  // That magic value is written in XenResetVector/Ia32/XenPVHMain.asm
+  //
+  if (PVHResetVectorData[1] == SIGNATURE_32 ('X', 'P', 'V', 'H')) {
+    struct hvm_start_info *HVMStartInfo;
+
Quoted 8 lines

OvmfPkg/XenPlatformPei/Xen.c XenConnect ( · line 144

Quoted 5 lines
OvmfPkg/XenPlatformPei/Xen.c +5 -0
+    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;

I guess you can do this because OVMF has an identity map of virtual addresses to physical addresses?

I think so, yes. I know that early code does created page table like that, but I don't know if later code rework those page table or not.

Quoted 5 lines

I wonder the size of such identity map, and whether you need to check that the rsdp address is indeed inside of that region before converting it to a pointer. The same would apply to PcdXenPvhStartOfDayStructPtr, but that's likely safe because it's always < 4GB, which I assume OVMF always has identity mapped?

PcdXenPvhStartOfDayStructPtr is safe because OVMF owns it. As for the rspd_paddr* and the HVMStartInfo*, I need to check. As you say, it's probably fine as long as it's <4GB.

I've looked at the comment here:
https://github.com/tianocore/edk2/blob/master/OvmfPkg/ResetVector/Ia32/PageTables64.asm#L94
This mean that the code executed in the patch (accessing the hvm start info struct) is executed while the id map is setup up to 4GB. So as long as the struct is below 4G, it's fine.

As for the RSDP, I think that pointer is accessed much later, when a different page table is setup, I think that would be that code:
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
But I'm not sure how much is setup. But I'm guessing that whatever is pointed by RSDP, it will be in the 1:1, because we tell the UEFI about it while parsing the e820.

Thanks,

Signature · 6 lines
Anthony PERARD

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

Re: [Xen-devel] [edk2-devel] [PATCH v4 20/35] OvmfPkg/XenPlatformPei: Introduce XenPvhDetected

In reply to Roger Pau Monné
Quoted 17 lines · Roger Pau Monné

OvmfPkg/XenPlatformPei/Xen.c XenHvmloaderDetected ( · line 225

Quoted 9 lines · Anthony PERARD
OvmfPkg/XenPlatformPei/Xen.c +9 -0
+BOOLEAN
+XenPvhDetected (
+  VOID
+  )
+{
+  //
+  // This function should only be used after XenConnect
+  //
+  ASSERT (mXenInfo.VersionMajor != 0);

That's IMO dangerous. Using the version as an indication that XenConnect has run seems like a bad idea, since returning a major version of 0 is a valid number to return. Can't you check against something else that doesn't depends on hypervisor provided data? (ie:
like some allocations or such that happen in XenConnect)

Quoted 4 lines

A paranoid could provider could even return major == 0 and minor == 0 in order to attempt to hide the Xen version used, since guests are not supposed to infer anything from the Xen version, available hypervisor features are reported by other means.

I'm sure a paranoid provider wouldn't use a debug build of OVMF :-). So that assert doesn't matter. There's nothing dangerous in a `nop'! :-D

But I could use mXenInfo.HyperPages instead.

Thanks,

Signature · 6 lines
Anthony PERARD

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

Re: [Xen-devel] [edk2-devel] [PATCH v4 12/35] OvmfPkg/XenPlatformPei: Grab RSDP from PVH guest start of day struct

In reply to Anthony PERARD
Quoted 10 lines · Anthony PERARD
Quoted 8 lines · Roger Pau Monné
Quoted 4 lines · 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.

You seem to change the types when importing start_info.h, is that absolutely necessary?

Quoted 8 lines

I guess one could try to map xen's types to EDKII's type with typedefs, but I'm not sur how well that would work. Importing the xen headers is documented so changing the types is fairly easy, see
https://github.com/tianocore/edk2/blob/master/OvmfPkg/Include/IndustryStandard/Xen/README

Also, changing the header further might have been something useful to do, we could have match EDKII's naming convention and source files would have looked a bit less weird.

Ack, didn't know there was a README for this procedure.

Quoted 66 lines
Quoted 44 lines

From my experience working with different projects when importing such headers it's better to keep them verbatim, this makes importing future versions from upstream easier.

I have a comment below, but it's more like a question.

Quoted 38 lines
OvmfPkg/XenPlatformPei/Xen.c +16 -0
index 5c7d7ddc1c..b366139a0a 100644
@@ -25,6 +25,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"
@@ -86,6 +87,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);
@@ -121,6 +123,29 @@ 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 (PcdXenPvhStartOfDayStructPtr);
+  //
+  // That magic value is written in XenResetVector/Ia32/XenPVHMain.asm
+  //
+  if (PVHResetVectorData[1] == SIGNATURE_32 ('X', 'P', 'V', 'H')) {
+    struct hvm_start_info *HVMStartInfo;
+
Quoted 8 lines

OvmfPkg/XenPlatformPei/Xen.c XenConnect ( · line 144

Quoted 5 lines
OvmfPkg/XenPlatformPei/Xen.c +5 -0
+    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;

I guess you can do this because OVMF has an identity map of virtual addresses to physical addresses?

I think so, yes. I know that early code does created page table like that, but I don't know if later code rework those page table or not.

Quoted 5 lines

I wonder the size of such identity map, and whether you need to check that the rsdp address is indeed inside of that region before converting it to a pointer. The same would apply to PcdXenPvhStartOfDayStructPtr, but that's likely safe because it's always < 4GB, which I assume OVMF always has identity mapped?

PcdXenPvhStartOfDayStructPtr is safe because OVMF owns it. As for the rspd_paddr* and the HVMStartInfo*, I need to check. As you say, it's probably fine as long as it's <4GB.

Quoted 5 lines

I've looked at the comment here:
https://github.com/tianocore/edk2/blob/master/OvmfPkg/ResetVector/Ia32/PageTables64.asm#L94
This mean that the code executed in the patch (accessing the hvm start info struct) is executed while the id map is setup up to 4GB. So as long as the struct is below 4G, it's fine.

Yes, the start_info struct is guaranteed to be below 4GB because the physical memory address of it is passed on a register when starting the kernel in 32bit protected mode, so the address cannot be greater than 4GB or it would be truncated.

Quoted 6 lines

As for the RSDP, I think that pointer is accessed much later, when a different page table is setup, I think that would be that code:
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
But I'm not sure how much is setup. But I'm guessing that whatever is pointed by RSDP, it will be in the 1:1, because we tell the UEFI about it while parsing the e820.

OK, as long as we know it's safe to access. Note it's quite likely the rsdp is also below 4GB anyway, but better be safe than sorry.

Thanks, Roger.

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

#39 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 22/35] OvmfPkg/XenPlatformPei: no hvmloader: get the E820 table via hypercall

In reply to Roger Pau Monné
Quoted 9 lines · Roger Pau Monné
Quoted 4 lines · Anthony PERARD

When the Xen PVH entry point has been used, hvmloader hasn't run and hasn't prepared an E820 table. 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.

I think we agreed that the above is not true, and that the memory map can be fetched as many times as desired using the hypercall interface.

Yes, I'll change the commit message. How about:

When the Xen PVH entry point has been used, hvmloader hasn't run and hasn't prepared an E820 table. The only way left to get an E820 table is to ask Xen via an hypercall. We keep the result cached to avoid making a second hypercall which would give the same result.

Thanks,

Signature · 6 lines
Anthony PERARD

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

Re: [Xen-devel] [edk2-devel] [PATCH v4 20/35] OvmfPkg/XenPlatformPei: Introduce XenPvhDetected

In reply to Anthony PERARD
Quoted 23 lines · Anthony PERARD
Quoted 17 lines · Roger Pau Monné

OvmfPkg/XenPlatformPei/Xen.c XenHvmloaderDetected ( · line 225

Quoted 9 lines · Anthony PERARD
OvmfPkg/XenPlatformPei/Xen.c +9 -0
+BOOLEAN
+XenPvhDetected (
+  VOID
+  )
+{
+  //
+  // This function should only be used after XenConnect
+  //
+  ASSERT (mXenInfo.VersionMajor != 0);

That's IMO dangerous. Using the version as an indication that XenConnect has run seems like a bad idea, since returning a major version of 0 is a valid number to return. Can't you check against something else that doesn't depends on hypervisor provided data? (ie:
like some allocations or such that happen in XenConnect)

Quoted 4 lines

A paranoid could provider could even return major == 0 and minor == 0 in order to attempt to hide the Xen version used, since guests are not supposed to infer anything from the Xen version, available hypervisor features are reported by other means.

Quoted 4 lines

I'm sure a paranoid provider wouldn't use a debug build of OVMF :-). So that assert doesn't matter. There's nothing dangerous in a `nop'! :-D

But I could use mXenInfo.HyperPages instead.

It's just a nit, and TBH it's quite unlikely for anyone to report a major version of 0, it's just that if you have something else to assert for initialization it might be safer.

Thanks, Roger.

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

#40 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 22/35] OvmfPkg/XenPlatformPei: no hvmloader: get the E820 table via hypercall

In reply to Anthony PERARD
Quoted 11 lines · Anthony PERARD
Quoted 9 lines · Roger Pau Monné
Quoted 4 lines · Anthony PERARD

When the Xen PVH entry point has been used, hvmloader hasn't run and hasn't prepared an E820 table. 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.

I think we agreed that the above is not true, and that the memory map can be fetched as many times as desired using the hypercall interface.

Quoted 6 lines

Yes, I'll change the commit message. How about:

When the Xen PVH entry point has been used, hvmloader hasn't run and hasn't prepared an E820 table. The only way left to get an E820 table is to ask Xen via an hypercall. We keep the result cached to avoid making a second hypercall which would give the same result.

LGTM, thanks.

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

#45 lore raw

Re: [Xen-devel] [PATCH v4 23/35] OvmfPkg/XenPlatformPei: Rework memory detection

In reply to Roger Pau Monné
Quoted 10 lines · Roger Pau Monné
Quoted 9 lines · 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 work without CMOS by reading the e820 table.

Rework XenPublishRamRegions to also care for the reserved and ACPI entry in the e820 table. The region that was added by InitializeXen() isn't needed as that same entry is in the e820 table provided by hvmloader.

Quoted 4 lines
Quoted 3 lines

MTRR settings aren't modified anymore, on HVM it's already done by hvmloader, on PVH it is supposed to have sane default. MTRR will need to be done properly but keeping what's already been done by programmes

^ firmware

I've used programmes instead of firmware because in case of PVH, OVMF is the first firmware to run, libxl (and what ever it called) is what causes an MTRR to be setup, no firmware are involved in that.

Quoted 16 lines
Quoted 5 lines
OvmfPkg/XenPlatformPei/Xen.c +5 -0
+    //
+    // Round up the start address, and round down the end address.
+    //
+    Base = ALIGN_VALUE (Entry->BaseAddr, (UINT64)EFI_PAGE_SIZE);
+    End = (Entry->BaseAddr + Entry->Length) & ~(UINT64)EFI_PAGE_MASK;

OvmfPkg/XenPlatformPei/Xen.c XenPublishRamRegions ( · line 318

Quoted 10 lines
OvmfPkg/XenPlatformPei/Xen.c +10 -0
+
+    switch (Entry->Type) {
+    case EfiAcpiAddressRangeMemory:
+      AddMemoryRangeHob (Base, End);
+      break;
+    case EfiAcpiAddressRangeACPI:
+      AddReservedMemoryRangeHob (Base, End, FALSE);
+      break;
+    case EfiAcpiAddressRangeReserved:
+      if (Base < LocalApic && LocalApic < End) {
Quoted 6 lines

Don't you also need to check for equality? In case such region starts at Base == LocalApic?

I guess it doesn't matter that much since this is to workaround a specific issue with hvmloader, but I would like to see this sorted out in hvmloader so that there's no clash anymore.

Indeed, it doesn't matter to much, so I've been lazy. But Laszlo have pointed that out as well, so there were going to be a patch to make the workaround better. But I feel like I'm going to need to repost the series, so I'm probably going to fix that as well.

Thanks,

Signature · 6 lines
Anthony PERARD

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

Re: [Xen-devel] [edk2-devel] [PATCH v4 29/35] OvmfPkg/OvmfXen: Override PcdFSBClock to Xen vLAPIC timer frequency

In reply to Roger Pau Monné
Quoted 8 lines · Roger Pau Monné
Quoted 3 lines · Anthony PERARD

PcdFSBClock is used by SecPeiDxeTimerLibCpu, the TimerLib implementation. It will also be used by XenTimerDxe. Override PcdFSBClock to match Xen vLAPIC timer frequency.

I'm kind of surprised that his is not automatically detected?

Is it a bug in Xen or just always hardcoded on OVMF?

It's hardcoded. Why would you need auto detection when you always run on the same machine ;-).

Signature · 6 lines
Anthony PERARD

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

Re: [Xen-devel] [edk2-devel] [PATCH v4 29/35] OvmfPkg/OvmfXen: Override PcdFSBClock to Xen vLAPIC timer frequency

Quoted 6 lines · Anthony PERARD
Quoted 5 lines · Roger Pau Monné
Quoted 3 lines · Anthony PERARD

PcdFSBClock is used by SecPeiDxeTimerLibCpu, the TimerLib implementation. It will also be used by XenTimerDxe. Override PcdFSBClock to match Xen vLAPIC timer frequency.

Quoted 6 lines
Quoted 3 lines

I'm kind of surprised that his is not automatically detected?

Is it a bug in Xen or just always hardcoded on OVMF?

It's hardcoded. Why would you need auto detection when you always run on the same machine ;-).

I don't think that's part of the HVM/PVH ABI in any way, and if you hardcode it in OVMF it would prevent Xen from changing the frequency in the future if such necessity arises. We should try to avoid painting ourselves into a corner when possible.

Doesn't OVMF have a way to get this from the hardware itself?

Thanks, Roger.

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

#56 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 29/35] OvmfPkg/OvmfXen: Override PcdFSBClock to Xen vLAPIC timer frequency

Quoted 14 lines · Roger Pau Monné
Quoted 6 lines · Anthony PERARD
Quoted 5 lines · Roger Pau Monné
Quoted 3 lines · Anthony PERARD

PcdFSBClock is used by SecPeiDxeTimerLibCpu, the TimerLib implementation. It will also be used by XenTimerDxe. Override PcdFSBClock to match Xen vLAPIC timer frequency.

Quoted 6 lines
Quoted 3 lines

I'm kind of surprised that his is not automatically detected?

Is it a bug in Xen or just always hardcoded on OVMF?

It's hardcoded. Why would you need auto detection when you always run on the same machine ;-).

Quoted 6 lines

I don't think that's part of the HVM/PVH ABI in any way, and if you hardcode it in OVMF it would prevent Xen from changing the frequency in the future if such necessity arises. We should try to avoid painting ourselves into a corner when possible.

Doesn't OVMF have a way to get this from the hardware itself?

So EDKII doesn't have that capability, FSBClock is a build time value and can't be changed at run time. But OVMF (on KVM or HVM) doesn't use that value at all, it uses the ACPI timer instead.

We could try to find a better way to get time in OvmfXen without hardcoding FSBClock, but maybe in a follow-up.

Thanks,

Signature · 6 lines
Anthony PERARD

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

Re: [Xen-devel] [edk2-devel] [PATCH v4 33/35] OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables

In reply to Roger Pau Monné
Quoted 4 lines · Roger Pau Monné
Quoted 3 lines · Anthony PERARD

XenIoPvhDxe use XenIoMmioLib to reserve some space to be use by the Grant Tables.

Quoted 8 lines
Quoted 4 lines

The call is only done if it is necessary, we simply detect if the guest is 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.

Since I'm not familiar with OVMF code, where is the grant table physical memory coming from then, is it allocated from a hole in the memory map?

On HVM, we use the first BAR of the Xen platform PCI device. Since there is no such thing on PVH, I simply allocate some memory for it, with AllocateReservedPages() which mean allocate some pages and tell the OS to not touch them.

We could deallocate these pages and give them back to the OS but that would need some refactoring.

Signature · 6 lines
Anthony PERARD

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

Re: [Xen-devel] [edk2-devel] [PATCH v4 35/35] OvmfPkg/OvmfXen: use RealTimeClockRuntimeDxe from EmbeddedPkg

In reply to Roger Pau Monné
Quoted 9 lines · Roger Pau Monné
Quoted 5 lines · 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 XenRealTimeClockLib which simply always return the same time. This will work on both Xen PVH and HVM guests.

Not that this is not correct, but what's the point in requiring a clock if it can be faked by always returning the same value?

It's not a clock that is required, it is a library that implements RealTimeClockLib. Something needs it, so it is provided, even if it is only to display the "current time".

Quoted 2 lines

It seems like it's usage is not really required, and could indeed be dropped altogether?

Way to much work to drop it. Also, I don't work to fork OVMF.

The ARM implementation of OVMF for Xen does the same thing and simply always return the same value.

Quoted 2 lines

Alternatively, there's the PV clock which is available to PVH guests and will return a proper time.

We might need to do that one day I guess, but right now it is just a nice to have.

Thanks,

Signature · 6 lines
Anthony PERARD

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

Re: [Xen-devel] [edk2-devel] [PATCH v4 29/35] OvmfPkg/OvmfXen: Override PcdFSBClock to Xen vLAPIC timer frequency

In reply to Anthony PERARD
Quoted 20 lines · Anthony PERARD
Quoted 19 lines · Roger Pau Monné
Quoted 6 lines · Anthony PERARD
Quoted 5 lines · Roger Pau Monné
Quoted 3 lines · Anthony PERARD

PcdFSBClock is used by SecPeiDxeTimerLibCpu, the TimerLib implementation. It will also be used by XenTimerDxe. Override PcdFSBClock to match Xen vLAPIC timer frequency.

Quoted 6 lines
Quoted 3 lines

I'm kind of surprised that his is not automatically detected?

Is it a bug in Xen or just always hardcoded on OVMF?

It's hardcoded. Why would you need auto detection when you always run on the same machine ;-).

I don't think that's part of the HVM/PVH ABI in any way, and if you hardcode it in OVMF it would prevent Xen from changing the frequency in the future if such necessity arises. We should try to avoid painting ourselves into a corner when possible.

Quoted 5 lines
Quoted 1 line

Doesn't OVMF have a way to get this from the hardware itself?

So EDKII doesn't have that capability, FSBClock is a build time value and can't be changed at run time. But OVMF (on KVM or HVM) doesn't use that value at all, it uses the ACPI timer instead.

But after your series both PVH and HVM will use the lapic timer instead of the ACPI timer, and thus rely on the value of FSBClock?

Quoted 2 lines

We could try to find a better way to get time in OvmfXen without hardcoding FSBClock, but maybe in a follow-up.

Yes please. As said above lapic frequency is not part of the ABI, so if we need to use it like that APIC_BUS_CYCLE_NS (currently in vlapic.h) would have to be moved to a public header.

Thanks, Roger.

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

#76 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 35/35] OvmfPkg/OvmfXen: use RealTimeClockRuntimeDxe from EmbeddedPkg

In reply to Anthony PERARD
Quoted 20 lines · Anthony PERARD
Quoted 9 lines · Roger Pau Monné
Quoted 5 lines · 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 XenRealTimeClockLib which simply always return the same time. This will work on both Xen PVH and HVM guests.

Not that this is not correct, but what's the point in requiring a clock if it can be faked by always returning the same value?

It's not a clock that is required, it is a library that implements RealTimeClockLib. Something needs it, so it is provided, even if it is only to display the "current time".

Quoted 2 lines

It seems like it's usage is not really required, and could indeed be dropped altogether?

Way to much work to drop it. Also, I don't work to fork OVMF.

Quoted 8 lines

The ARM implementation of OVMF for Xen does the same thing and simply always return the same value.

Quoted 2 lines

Alternatively, there's the PV clock which is available to PVH guests and will return a proper time.

We might need to do that one day I guess, but right now it is just a nice to have.

Ack, thanks for the explanation.

Roger.

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

#59 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 29/35] OvmfPkg/OvmfXen: Override PcdFSBClock to Xen vLAPIC timer frequency

In reply to Roger Pau Monné
Quoted 14 lines · Roger Pau Monné
Quoted 6 lines · Anthony PERARD
Quoted 5 lines · Roger Pau Monné
Quoted 3 lines · Anthony PERARD

PcdFSBClock is used by SecPeiDxeTimerLibCpu, the TimerLib implementation. It will also be used by XenTimerDxe. Override PcdFSBClock to match Xen vLAPIC timer frequency.

Quoted 6 lines
Quoted 3 lines

I'm kind of surprised that his is not automatically detected?

Is it a bug in Xen or just always hardcoded on OVMF?

It's hardcoded. Why would you need auto detection when you always run on the same machine ;-).

Quoted 6 lines

I don't think that's part of the HVM/PVH ABI in any way, and if you hardcode it in OVMF it would prevent Xen from changing the frequency in the future if such necessity arises. We should try to avoid painting ourselves into a corner when possible.

Doesn't OVMF have a way to get this from the hardware itself?

It might be possible to change the PCDs access method in the DSC file to "dynamic", and then set it dynamically in XenPlatformPei. That should work fine if only the DXE phase relies on the PCD. However, if PEIMs (other than XenPlatformPei) consume the PCD too, then the ordering (between set/get) might not be trivial to ensure. This kind of problem sometimes requries separate library instances for SEC/PEI/DXE.

Thanks
Laszlo

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

#58 lore raw

Re: [Xen-devel] [edk2-devel] [PATCH v4 29/35] OvmfPkg/OvmfXen: Override PcdFSBClock to Xen vLAPIC timer frequency

In reply to Roger Pau Monné
Quoted 7 lines · Roger Pau Monné
Quoted 3 lines · Anthony PERARD

So EDKII doesn't have that capability, FSBClock is a build time value and can't be changed at run time. But OVMF (on KVM or HVM) doesn't use that value at all, it uses the ACPI timer instead.

But after your series both PVH and HVM will use the lapic timer instead of the ACPI timer, and thus rely on the value of FSBClock?

Short answer, Yes.

Longuer answer, after the series is applied, there will be a new platform, "OvmfXen" which will be for both Xen PVH and Xen HVM, but the OVMF that we know (OvmfPkgX64 that xen.git builds) will still be capable of running on Xen HVM for a short while and will still use the ACPI timer.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#79 lore raw
In reply to Laszlo Ersek
Quoted 12 lines · Laszlo Ersek

Hi Anthony,

Quoted 8 lines · Anthony PERARD

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

Changes in v4:
- patch "OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it has run" was removed, and instead a different change is done in "OvmfPkg/XenPlatformPei: Rework memory detection"
- other changes detailed in the notes of each patch

Quoted 6 lines

I've gone through the v4 series. If reviewers on the xen-devel list think v4 is okay to merge, I can do that (with the small fixups I offered here and there). I suggest that we wait a few days -- please ping me when you believe the review on xen-devel has concluded.

If you prefer to post v5, that works as well of course.

There's a few more small fixup proposed by Roger, should I post a v5 for them? (and maybe only CC you and the lists.)

Otherwise, I've pushed the branch br.platform-xen-pvh-v4.1 to my repo [1] where I believe I've collected all the small fixups.
[1] https://xenbits.xen.org/git-http/people/aperard/ovmf.git br.platform-xen-pvh-v4.1

Thanks,

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#80 lore raw
Quoted 18 lines · Anthony PERARD
Quoted 17 lines · Laszlo Ersek

Hi Anthony,

Quoted 8 lines · Anthony PERARD

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

Changes in v4:
- patch "OvmfPkg/XenPlatformPei: Reserve hvmloader's memory only when it has run" was removed, and instead a different change is done in "OvmfPkg/XenPlatformPei: Rework memory detection"
- other changes detailed in the notes of each patch

I've gone through the v4 series. If reviewers on the xen-devel list think v4 is okay to merge, I can do that (with the small fixups I offered here and there). I suggest that we wait a few days -- please ping me when you believe the review on xen-devel has concluded.

Quoted 8 lines
Quoted 1 line

If you prefer to post v5, that works as well of course.

There's a few more small fixup proposed by Roger, should I post a v5 for them? (and maybe only CC you and the lists.)

Otherwise, I've pushed the branch br.platform-xen-pvh-v4.1 to my repo [1] where I believe I've collected all the small fixups.
[1] https://xenbits.xen.org/git-http/people/aperard/ovmf.git br.platform-xen-pvh-v4.1

Please post v5.

Thanks!
Laszlo

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