OvmfPkg: Xen: Use a new fdf include for the PVH ELF header

Instead of having the PVH ELF header part of the fdf file directly, we
move it to a dedicated include file. This is the first step in
automating the generation of the header.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Sebastien Boeuf 2022-03-02 21:31:31 +08:00 committed by mergify[bot]
parent b909b4ad09
commit 0a707eb258
2 changed files with 65 additions and 54 deletions

View File

@ -31,61 +31,8 @@ NumBlocks = $(FW_BLOCKS)
!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
}
!include XenElfHeader.fdf.inc
!if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
0x0000e000|0x00001000

View File

@ -0,0 +1,64 @@
## @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 = {
#
# 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
}