]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Generate CloudHv as a PVH ELF binary
authorSebastien Boeuf <sebastien.boeuf@intel.com>
Wed, 2 Mar 2022 13:31:34 +0000 (21:31 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 4 Mar 2022 02:41:57 +0000 (02:41 +0000)
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>
OvmfPkg/CloudHv/CloudHvElfHeader.fdf.inc [new file with mode: 0644]
OvmfPkg/CloudHv/CloudHvX64.dsc
OvmfPkg/CloudHv/CloudHvX64.fdf

diff --git a/OvmfPkg/CloudHv/CloudHvElfHeader.fdf.inc b/OvmfPkg/CloudHv/CloudHvElfHeader.fdf.inc
new file mode 100644 (file)
index 0000000..8377e30
--- /dev/null
@@ -0,0 +1,54 @@
+## @file\r
+#  FDF include file that defines a PVH ELF header.\r
+#\r
+#  Copyright (c) 2022, Intel Corporation. All rights reserved.\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+DATA = {\r
+  # ELF file header\r
+  0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,\r
+  0xd0, 0xff, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, # hdr.e_entry\r
+  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,\r
+\r
+  # ELF Program segment headers\r
+  # - Load segment\r
+  0x01, 0x00, 0x00, 0x00,\r
+  0x07, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x10, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x10, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x40, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x40, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0x04, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  # - ELFNOTE segment\r
+  0x04, 0x00, 0x00, 0x00,\r
+  0x04, 0x00, 0x00, 0x00,\r
+  0xb0, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0xb0, 0x00, 0x10, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0xb0, 0x00, 0x10, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0x14, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0x14, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0x04, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x00, 0x00,\r
+\r
+  # XEN_ELFNOTE_PHYS32_ENTRY\r
+  0x04, 0x00, 0x00, 0x00,\r
+  0x04, 0x00, 0x00, 0x00,\r
+  0x12, 0x00, 0x00, 0x00,\r
+  0x58, 0x65, 0x6e, 0x00,\r
+  0xd0, 0xff, 0x4f, 0x00\r
+}\r
index 3172100310b130ef98ec40dfb15b6723d7a9d2b6..b4d855d80f56cc14e6b6e717db9950926f0a3e59 100644 (file)
 #\r
 ################################################################################\r
 [Components]\r
-  OvmfPkg/ResetVector/ResetVector.inf\r
+  OvmfPkg/XenResetVector/XenResetVector.inf\r
 \r
   #\r
   # SEC Phase modules\r
index 0974e76ac8d7b5f32331ca88be8dba87b18da87a..282bcf863491327781a058b2d1725dd5acf652d0 100644 (file)
@@ -14,8 +14,8 @@
 !include OvmfPkg/OvmfPkgDefines.fdf.inc\r
 \r
 #\r
-# Build the variable store and the firmware code as one unified flash device\r
-# image.\r
+# This will allow the flash device image to be recognize as an ELF, with first\r
+# an ELF headers, then the firmware code.\r
 #\r
 [FD.CLOUDHV]\r
 BaseAddress   = $(FW_BASE_ADDRESS)\r
@@ -24,7 +24,14 @@ ErasePolarity = 1
 BlockSize     = $(BLOCK_SIZE)\r
 NumBlocks     = $(FW_BLOCKS)\r
 \r
-0x00000000|$(FVMAIN_SIZE)\r
+#\r
+# Leaving 4kiB for the PVH ELF header. This is more than enough.\r
+#\r
+0x00000000|0x00001000\r
+\r
+!include CloudHvElfHeader.fdf.inc\r
+\r
+0x00001000|$(FVMAIN_SIZE)\r
 FV = FVMAIN_COMPACT\r
 \r
 $(SECFV_OFFSET)|$(SECFV_SIZE)\r
@@ -114,7 +121,7 @@ READ_LOCK_STATUS   = TRUE
 #\r
 INF  OvmfPkg/Sec/SecMain.inf\r
 \r
-INF  RuleOverride=RESET_VECTOR OvmfPkg/ResetVector/ResetVector.inf\r
+INF  RuleOverride=RESET_VECTOR OvmfPkg/XenResetVector/XenResetVector.inf\r
 \r
 ################################################################################\r
 [FV.PEIFV]\r