OvmfPkg: Generate CloudHv as a PVH ELF binary

Following the model from the Xen target, CloudHv is generated as a PVH
ELF binary to take advantage of the PVH specification, which requires
less emulation from the VMM.

The fdf include file CloudHvElfHeader.fdf.inc has been generated from
the following commands:

$ gcc -D PVH64 -o elf_gen OvmfPkg/OvmfXenElfHeaderGenerator.c
$ ./elf_gen 4194304 OvmfPkg/CloudHv/CloudHvElfHeader.fdf.inc

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Sebastien Boeuf 2022-03-02 21:31:34 +08:00 committed by mergify[bot]
parent 9ac8c85d50
commit e1c7f9b4e5
3 changed files with 66 additions and 5 deletions

View File

@ -0,0 +1,54 @@
## @file
# FDF include file that defines a PVH ELF header.
#
# Copyright (c) 2022, Intel Corporation. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
DATA = {
# ELF file header
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
0xd0, 0xff, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, # hdr.e_entry
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x38, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
# ELF Program segment headers
# - Load segment
0x01, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x00,
0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
# - ELFNOTE segment
0x04, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00,
0xb0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0xb0, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0x00,
0xb0, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
# XEN_ELFNOTE_PHYS32_ENTRY
0x04, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00,
0x12, 0x00, 0x00, 0x00,
0x58, 0x65, 0x6e, 0x00,
0xd0, 0xff, 0x4f, 0x00
}

View File

@ -631,7 +631,7 @@
#
################################################################################
[Components]
OvmfPkg/ResetVector/ResetVector.inf
OvmfPkg/XenResetVector/XenResetVector.inf
#
# SEC Phase modules

View File

@ -14,8 +14,8 @@
!include OvmfPkg/OvmfPkgDefines.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.CLOUDHV]
BaseAddress = $(FW_BASE_ADDRESS)
@ -24,7 +24,14 @@ ErasePolarity = 1
BlockSize = $(BLOCK_SIZE)
NumBlocks = $(FW_BLOCKS)
0x00000000|$(FVMAIN_SIZE)
#
# Leaving 4kiB for the PVH ELF header. This is more than enough.
#
0x00000000|0x00001000
!include CloudHvElfHeader.fdf.inc
0x00001000|$(FVMAIN_SIZE)
FV = FVMAIN_COMPACT
$(SECFV_OFFSET)|$(SECFV_SIZE)
@ -114,7 +121,7 @@ READ_LOCK_STATUS = TRUE
#
INF OvmfPkg/Sec/SecMain.inf
INF RuleOverride=RESET_VECTOR OvmfPkg/ResetVector/ResetVector.inf
INF RuleOverride=RESET_VECTOR OvmfPkg/XenResetVector/XenResetVector.inf
################################################################################
[FV.PEIFV]