From nobody Fri May 17 20:35:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87225+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87225+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646227918; cv=none; d=zohomail.com; s=zohoarc; b=i6WqY8wnocMIHnIpZiw1l65MItpwx+H8XMTqP+yXmMA3HE6T6WeC2BSfl37XIRHkfPSJLIqSCJTpx/SkgZFRlfFg4obsw6pmfERri2Ydo7TBUmhwNfdd0FeUX+Buf1RzPMGGrjzSfFfAqX9kjQzX9AoAUwaiwwtTAalLNZd1KWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646227918; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=MRoKORBMcvzT4dUX1PFtu7gs3GARzsdS5f0QfjuhSX4=; b=VMUIw+2vB+Gs2S+UlK9Of4XfGLEN4L6qETIBtifVswo3HZk8u9+PwsGLWGyqElW0XvpqEfxs7W2KYzu2zgGQA4o2YpHocd5cIP8mXHVYH23wMOEopxThmQsEWBIBetf8HIXkGoAGlIYfxnQWtl9fQuA93LXO12i9KZoasNF8gh8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87225+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1646227918536389.60918057557717; Wed, 2 Mar 2022 05:31:58 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id q9QzYY1788612xH9unyv0U5M; Wed, 02 Mar 2022 05:31:58 -0800 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.7218.1646227914344900897 for ; Wed, 02 Mar 2022 05:31:57 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="240813671" X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="240813671" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:31:53 -0800 X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="535389198" X-Received: from spearce-mobl1.amr.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.27.130]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:31:52 -0800 From: "Boeuf, Sebastien" To: devel@edk2.groups.io Cc: jiewen.yao@intel.com, jordan.l.justen@intel.com, kraxel@redhat.com, sebastien.boeuf@intel.com Subject: [edk2-devel] [PATCH v6 1/8] OvmfPkg: Make the Xen ELF header generator more flexible Date: Wed, 2 Mar 2022 14:31:30 +0100 Message-Id: <57faf25b046346821a99adbcf9a6718b8ca31a47.1646227817.git.sebastien.boeuf@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sebastien.boeuf@intel.com X-Gm-Message-State: Ze97XhuGH16v5ChzahnYYFGVx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646227918; bh=CNu8NKCwKUfSXNtaQ0yjZUMDCehjVXpjB5ra6UOBGOQ=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=GPCdS239GL5HwwS4vXBEsA7DEz62TQNSbFkwEPA8ZCmIL68USXJnUr1nHC2RS8JcjUE e6TEVnHrUFO1zDnp04+uSz78U03Z3scJ9lnExX/upy4R9yNr5V/dALLfqN+tW1ZerT82B jiBUea1t0u0FlLBg1n7wETXUc/SZAMg5ZV0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646227919196100001 Content-Type: text/plain; charset="utf-8" From: Sebastien Boeuf Adding some flexibility to the program through optional parameters and global define, so that other targets can use the generator. * A global define is added so that we can choose at build time if we want to use 32-bit or 64-bit base structures. * A first optional parameter is added so the user can provide the expected blob size of the generated binary. * A second optional parameter is added so the user can specify an output file to which the generated output will be printed. The default behavior isn't modified. Acked-by: Gerd Hoffmann Signed-off-by: Sebastien Boeuf --- OvmfPkg/OvmfXenElfHeaderGenerator.c | 141 +++++++++++++++++++++------- 1 file changed, 109 insertions(+), 32 deletions(-) diff --git a/OvmfPkg/OvmfXenElfHeaderGenerator.c b/OvmfPkg/OvmfXenElfHeader= Generator.c index 489060cdad..672129b85d 100644 --- a/OvmfPkg/OvmfXenElfHeaderGenerator.c +++ b/OvmfPkg/OvmfXenElfHeaderGenerator.c @@ -10,19 +10,31 @@ **/ =20 #include "elf.h" -#include "stdio.h" +#include "fcntl.h" +#include "stdbool.h" #include "stddef.h" +#include "stdio.h" +#include "stdlib.h" =20 void print_hdr ( + FILE *file, void *s, - size_t size + size_t size, + bool end_delimiter ) { char *c =3D s; =20 - while (size--) { - printf ("0x%02hhx, ", *(c++)); + fprintf (file, " "); + while (size-- > 1) { + fprintf (file, "0x%02hhx, ", *(c++)); + } + + if (end_delimiter) { + fprintf (file, "0x%02hhx,", *c); + } else { + fprintf (file, "0x%02hhx", *c); } } =20 @@ -36,34 +48,79 @@ typedef struct { uint32_t desc; } xen_elfnote_phys32_entry; =20 +#define LICENSE_HDR "\ +## @file\r\n\ +# FDF include file that defines a PVH ELF header.\r\n\ +#\r\n\ +# Copyright (c) 2022, Intel Corporation. All rights reserved.\r\n\ +#\r\n\ +# SPDX-License-Identifier: BSD-2-Clause-Patent\r\n\ +#\r\n\ +##\r\n\ +\r\n\ +" + int main ( - void + int argc, + char *argv[] ) { /* FW_SIZE */ size_t ovmf_blob_size =3D 0x00200000; /* Load OVMF at 1MB when running as PVH guest */ uint32_t ovmf_base_address =3D 0x00100000; + uint32_t ovmfxen_pvh_entry_point; + size_t offset_into_file =3D 0; + char *endptr, *str; + long param; + FILE *file =3D stdout; + + /* Parse the size parameter */ + if (argc > 1) { + str =3D argv[1]; + param =3D strtol (str, &endptr, 10); + if (endptr !=3D str) { + ovmf_blob_size =3D (size_t)param; + } + } + + /* Parse the filepath parameter */ + if (argc > 2) { + file =3D fopen (argv[2], "w"); + fprintf (file, LICENSE_HDR); + } + /* Xen PVH entry point */ - uint32_t ovmfxen_pvh_entry_point =3D ovmf_base_address + ovmf_blob_size= - 0x30; - size_t offset_into_file =3D 0; + ovmfxen_pvh_entry_point =3D ovmf_base_address + ovmf_blob_size - 0x30; =20 /* ELF file header */ + #ifdef PVH64 + Elf64_Ehdr hdr =3D { + #else Elf32_Ehdr hdr =3D { - .e_ident =3D ELFMAG, - .e_type =3D ET_EXEC, - .e_machine =3D EM_386, - .e_version =3D EV_CURRENT, - .e_entry =3D ovmfxen_pvh_entry_point, - .e_flags =3D R_386_NONE, - .e_ehsize =3D sizeof (hdr), + #endif + .e_ident =3D ELFMAG, + .e_type =3D ET_EXEC, + .e_machine =3D EM_386, + .e_version =3D EV_CURRENT, + .e_entry =3D ovmfxen_pvh_entry_point, + .e_flags =3D R_386_NONE, + .e_ehsize =3D sizeof (hdr), + #ifdef PVH64 + .e_phentsize =3D sizeof (Elf64_Phdr), + #else .e_phentsize =3D sizeof (Elf32_Phdr), + #endif }; =20 offset_into_file +=3D sizeof (hdr); =20 - hdr.e_ident[EI_CLASS] =3D ELFCLASS32; + #ifdef PVH64 + hdr.e_ident[EI_CLASS] =3D ELFCLASS64; + #else + hdr.e_ident[EI_CLASS] =3D ELFCLASS32; + #endif hdr.e_ident[EI_DATA] =3D ELFDATA2LSB; hdr.e_ident[EI_VERSION] =3D EV_CURRENT; hdr.e_ident[EI_OSABI] =3D ELFOSABI_LINUX; @@ -71,14 +128,22 @@ main ( hdr.e_phoff =3D sizeof (hdr); =20 /* program header */ + #ifdef PVH64 + Elf64_Phdr phdr_load =3D { + #else Elf32_Phdr phdr_load =3D { + #endif .p_type =3D PT_LOAD, .p_offset =3D 0, /* load everything */ .p_paddr =3D ovmf_base_address, .p_filesz =3D ovmf_blob_size, .p_memsz =3D ovmf_blob_size, .p_flags =3D PF_X | PF_W | PF_R, + #ifdef PVH64 + .p_align =3D 4, + #else .p_align =3D 0, + #endif }; =20 phdr_load.p_vaddr =3D phdr_load.p_paddr; @@ -98,12 +163,20 @@ main ( sizeof (xen_elfnote_phys32_entry) - offsetof (xen_elfnote_phys32_entry, desc), }; - Elf32_Phdr phdr_note =3D { + #ifdef PVH64 + Elf64_Phdr phdr_note =3D { + #else + Elf32_Phdr phdr_note =3D { + #endif .p_type =3D PT_NOTE, .p_filesz =3D sizeof (xen_elf_note), .p_memsz =3D sizeof (xen_elf_note), .p_flags =3D PF_R, + #ifdef PVH64 + .p_align =3D 4, + #else .p_align =3D 0, + #endif }; =20 hdr.e_phnum +=3D 1; @@ -120,31 +193,35 @@ main ( size_t hdr_size =3D sizeof (hdr); size_t entry_off =3D offsetof (typeof(hdr), e_entry); =20 - printf ("# ELF file header\n"); - print_hdr (&hdr, entry_off); - printf ("\n"); - print_hdr (&hdr.e_entry, sizeof (hdr.e_entry)); - printf (" # hdr.e_entry\n"); - print_hdr (&hdr.e_entry + 1, hdr_size - entry_off - sizeof (hdr.e_entry)= ); + fprintf (file, "DATA =3D {\r\n"); =20 - printf ("\n\n# ELF Program segment headers\n"); - printf ("# - Load segment\n"); + fprintf (file, " # ELF file header\r\n"); + print_hdr (file, &hdr, entry_off, true); + fprintf (file, "\r\n"); + print_hdr (file, &hdr.e_entry, sizeof (hdr.e_entry), true); + fprintf (file, " # hdr.e_entry\r\n"); + print_hdr (file, &hdr.e_entry + 1, hdr_size - entry_off - sizeof (hdr.e_= entry), true); + + fprintf (file, "\r\n\r\n # ELF Program segment headers\r\n"); + fprintf (file, " # - Load segment\r\n"); for (i =3D 0; i < sizeof (phdr_load); i +=3D 4) { - print_hdr (((char *)&phdr_load) + i, 4); - printf ("\n"); + print_hdr (file, ((char *)&phdr_load) + i, 4, true); + fprintf (file, "\r\n"); } =20 - printf ("# - ELFNOTE segment\n"); + fprintf (file, " # - ELFNOTE segment\r\n"); for (i =3D 0; i < sizeof (phdr_note); i +=3D 4) { - print_hdr (((char *)&phdr_note) + i, 4); - printf ("\n"); + print_hdr (file, ((char *)&phdr_note) + i, 4, true); + fprintf (file, "\r\n"); } =20 - printf ("\n# XEN_ELFNOTE_PHYS32_ENTRY\n"); + fprintf (file, "\r\n # XEN_ELFNOTE_PHYS32_ENTRY\r\n"); for (i =3D 0; i < sizeof (xen_elf_note); i +=3D 4) { - print_hdr (((char *)&xen_elf_note) + i, 4); - printf ("\n"); + print_hdr (file, ((char *)&xen_elf_note) + i, 4, (sizeof (xen_elf_note= ) - i) > 4); + fprintf (file, "\r\n"); } =20 + fprintf (file, "}\r\n"); + return 0; } --=20 2.32.0 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris,=20 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87225): https://edk2.groups.io/g/devel/message/87225 Mute This Topic: https://groups.io/mt/89500821/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 20:35:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87228+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87228+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646227945; cv=none; d=zohomail.com; s=zohoarc; b=R5xYmDKIHdyFsz4TGMaBrt/OViUZPTNGbDSeEcnx4k9A00hd5Gbr53I5HOUqXgQbut9qhERvkavDQC8jde8eX/Hx9Ff/pu8a4Q/WY9aLDGbU8kG0fisfPjrWQvDiRJdkzggCBdm1FlCmhNCZWWeNDEANE2W6LU+vCbZNjmNgnj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646227945; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ZP3S+jYy4mD9g0NpvbNHepH4XVwxIgNBYoHx7sCm13o=; b=QiAf25ioshNKOuuqTiACcW27hbDbAxZS+ZUbml2O62eRL498w14JNcpY9jZZz4cE1tJF0CmiL4b5+T5UlMtOhw5np7pcPVQgjszA6JHDcLxb2l6Nj4X7KPwYDmGelbkLFvCKX4GqTb/Z0cU/Rm7CPExbPtoQvXd/kDEt8nW+1Go= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87228+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1646227945623931.7538273855058; Wed, 2 Mar 2022 05:32:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id DVTBYY1788612xZS7w1Not6E; Wed, 02 Mar 2022 05:32:25 -0800 X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web09.7182.1646227944999519812 for ; Wed, 02 Mar 2022 05:32:25 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="250974653" X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="250974653" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:03 -0800 X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="535389250" X-Received: from spearce-mobl1.amr.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.27.130]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:01 -0800 From: "Boeuf, Sebastien" To: devel@edk2.groups.io Cc: jiewen.yao@intel.com, jordan.l.justen@intel.com, kraxel@redhat.com, sebastien.boeuf@intel.com Subject: [edk2-devel] [PATCH v6 2/8] OvmfPkg: Xen: Use a new fdf include for the PVH ELF header Date: Wed, 2 Mar 2022 14:31:31 +0100 Message-Id: <706cda501c9864adcccf9e1da681fbefb16c4eac.1646227817.git.sebastien.boeuf@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sebastien.boeuf@intel.com X-Gm-Message-State: y5mVLgNQBL7JqkAllQnpnWDrx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646227945; bh=0yaLA32lpuRCX08kAKN6+aaMUI6Ycwy7CpzI/2n7si4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=rCwck+16mrsEu+0ffUAFnF/yqRW9Vlypr0KzCJVQ7JE+n9SHJ4CUNVmzVDHahv3HLC+ AoFQC8IFm2ZcVxAXsO3hD//7lc4dPcuTrfMywIo7ecBSeLZ7AuPbWaXz3unlnqgbyuJUx X8tKISrI0haXOqjPVhD/3D1RHUQ1ElZWi/k= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646227947582100001 Content-Type: text/plain; charset="utf-8" From: Sebastien Boeuf 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 Signed-off-by: Sebastien Boeuf --- OvmfPkg/OvmfXen.fdf | 57 ++------------------------------ OvmfPkg/XenElfHeader.fdf.inc | 64 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 55 deletions(-) create mode 100644 OvmfPkg/XenElfHeader.fdf.inc diff --git a/OvmfPkg/OvmfXen.fdf b/OvmfPkg/OvmfXen.fdf index a6acf3b835..2e67db5d32 100644 --- a/OvmfPkg/OvmfXen.fdf +++ b/OvmfPkg/OvmfXen.fdf @@ -31,61 +31,8 @@ NumBlocks =3D $(FW_BLOCKS) !if $(FD_SIZE_IN_KB) =3D=3D 4096 0x00000000|0x00040000 !endif -DATA =3D { - # - # This hex array have been generated by OvmfPkg/OvmfXenElfHeaderGenerato= r.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 =3D Executable file - 0x03, 0x00, # e_machine =3D 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 =3D 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 =3D Segment is executable | writable |= readable - 0x00, 0x00, 0x00, 0x00, # p_align - # - ELFNOTE segment - 0x04, 0x00, 0x00, 0x00, # p_type =3D PT_NOTE - 0x74, 0x00, 0x00, 0x00, # p_offset =3D 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 =3D 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 =3D XEN_ELFNOTE_PHYS32_ENTRY - 0x58, 0x65, 0x6e, 0x00, # name =3D "Xen" - 0xd0, 0xff, 0x2f, 0x00, # desc: PVH entry point - 0x00 -} + +!include XenElfHeader.fdf.inc =20 !if ($(FD_SIZE_IN_KB) =3D=3D 1024) || ($(FD_SIZE_IN_KB) =3D=3D 2048) 0x0000e000|0x00001000 diff --git a/OvmfPkg/XenElfHeader.fdf.inc b/OvmfPkg/XenElfHeader.fdf.inc new file mode 100644 index 0000000000..dbc1305d25 --- /dev/null +++ b/OvmfPkg/XenElfHeader.fdf.inc @@ -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 =3D { + # + # This hex array have been generated by OvmfPkg/OvmfXenElfHeaderGenerato= r.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 =3D Executable file + 0x03, 0x00, # e_machine =3D 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 =3D 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 =3D Segment is executable | writable |= readable + 0x00, 0x00, 0x00, 0x00, # p_align + # - ELFNOTE segment + 0x04, 0x00, 0x00, 0x00, # p_type =3D PT_NOTE + 0x74, 0x00, 0x00, 0x00, # p_offset =3D 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 =3D 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 =3D XEN_ELFNOTE_PHYS32_ENTRY + 0x58, 0x65, 0x6e, 0x00, # name =3D "Xen" + 0xd0, 0xff, 0x2f, 0x00, # desc: PVH entry point + 0x00 +} --=20 2.32.0 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris,=20 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87228): https://edk2.groups.io/g/devel/message/87228 Mute This Topic: https://groups.io/mt/89500834/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 20:35:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87226+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87226+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646227932; cv=none; d=zohomail.com; s=zohoarc; b=kaJY6BQVntj7+29xcZ5A/c7s/ylM58HInlcXhUNKwvIa58Y1x7rWBTl60lOVt00LINoHOGMMPIc2iIX1iLTp6vJXl8Pa+ymwZA1KMj/YW78xqGKT9fTgYYFqN2PCAKAH7rhgZR1Q2NkEXSr5TfKaR6NqgMDD5u1DZIrXLHm8EEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646227932; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=gmlRpTrF06n6MsplygIqTT31AIE/9nMBp9fKW1CPU1o=; b=OgYKDv2erCfPK9B5PnFrLDUbBKVtSXOjlczy+yfQ9j1wABBhiOMvAEMNtaQ7uwEtLtxgmqIHyUWf8GoFKPiS9/W+vTXLXj1PQ3zYkGkn0Sm/xcjfBzjdjpbIwjqNLHga3bJOsVpdlRDx6StD1+XfqoC42ve/KFiEedLeGmgN798= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87226+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16462279325218.241796035134143; Wed, 2 Mar 2022 05:32:12 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ut8eYY1788612xOIWf0aGy63; Wed, 02 Mar 2022 05:32:12 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web08.7084.1646227930932743649 for ; Wed, 02 Mar 2022 05:32:11 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="233365251" X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="233365251" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:10 -0800 X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="535389277" X-Received: from spearce-mobl1.amr.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.27.130]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:08 -0800 From: "Boeuf, Sebastien" To: devel@edk2.groups.io Cc: jiewen.yao@intel.com, jordan.l.justen@intel.com, kraxel@redhat.com, sebastien.boeuf@intel.com Subject: [edk2-devel] [PATCH v6 3/8] OvmfPkg: Xen: Generate fdf include file from ELF header generator Date: Wed, 2 Mar 2022 14:31:32 +0100 Message-Id: <5b6b7ace7554eafc75ce1113cc029b89744bec2a.1646227817.git.sebastien.boeuf@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sebastien.boeuf@intel.com X-Gm-Message-State: r0DP1P0i4WMfkrTrhJ799Vfux1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646227932; bh=PQ6DHKU0Yoj3kECcV90EkTti7+Th0dOiSs0IQu/qZw8=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Uy51aNY2Lxtb2vbQAUkUdoG03RDklumJ88xNkVAYae4+dfuE45khsaOxFNz+bQm+1nF 25FuEIdYZXAhnDINZTVIOFwfuVrOKFE/af6BN3992HFcX7DAkqypZD3AwQchKxOw9jMIB /8v6zWiCE4b5HSiPBptYnz3UkEIAs3AZKc8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646227933269100001 Content-Type: text/plain; charset="utf-8" From: Sebastien Boeuf Updating the fdf include file based on the run of the ELF header generator. The diff from this patch is the result of: $ gcc -o elf_gen OvmfPkg/OvmfXenElfHeaderGenerator.c $ ./elf_gen 2097152 OvmfPkg/XenElfHeader.fdf.inc Acked-by: Gerd Hoffmann Signed-off-by: Sebastien Boeuf --- OvmfPkg/XenElfHeader.fdf.inc | 60 ++++++++++++------------------------ 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/OvmfPkg/XenElfHeader.fdf.inc b/OvmfPkg/XenElfHeader.fdf.inc index dbc1305d25..c4f04ad28b 100644 --- a/OvmfPkg/XenElfHeader.fdf.inc +++ b/OvmfPkg/XenElfHeader.fdf.inc @@ -8,57 +8,35 @@ ## =20 DATA =3D { - # - # This hex array have been generated by OvmfPkg/OvmfXenElfHeaderGenerato= r.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 =3D Executable file - 0x03, 0x00, # e_machine =3D 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 + 0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, = 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xd0, 0xff, 0x2f, 0x00, # hdr.e_entry + 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, = 0x34, 0x00, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, =20 # ELF Program segment headers # - Load segment - 0x01, 0x00, 0x00, 0x00, # p_type =3D 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 =3D Segment is executable | writable |= readable - 0x00, 0x00, 0x00, 0x00, # p_align + 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x20, 0x00, + 0x00, 0x00, 0x20, 0x00, + 0x07, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, # - ELFNOTE segment - 0x04, 0x00, 0x00, 0x00, # p_type =3D PT_NOTE - 0x74, 0x00, 0x00, 0x00, # p_offset =3D point to XEN_ELFNOTE_PHYS32_ENTRY= below + 0x04, 0x00, 0x00, 0x00, + 0x74, 0x00, 0x00, 0x00, 0x74, 0x00, 0x10, 0x00, 0x74, 0x00, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, # p_flags =3D Segment is readable + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, =20 # XEN_ELFNOTE_PHYS32_ENTRY - 0x04, 0x00, 0x00, 0x00, # name size - 0x04, 0x00, 0x00, 0x00, # desc size - 0x12, 0x00, 0x00, 0x00, # type =3D XEN_ELFNOTE_PHYS32_ENTRY - 0x58, 0x65, 0x6e, 0x00, # name =3D "Xen" - 0xd0, 0xff, 0x2f, 0x00, # desc: PVH entry point - 0x00 + 0x04, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, + 0x58, 0x65, 0x6e, 0x00, + 0xd0, 0xff, 0x2f, 0x00 } --=20 2.32.0 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris,=20 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87226): https://edk2.groups.io/g/devel/message/87226 Mute This Topic: https://groups.io/mt/89500826/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 20:35:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87227+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87227+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646227938; cv=none; d=zohomail.com; s=zohoarc; b=Aue51xqxF3C52nuq0ezg8RaFq7/BkBBTtnOS9o3hpCMw5ESn13bL7Y8vJhMkAebUYE3mO8txbPP3X0MGFc5B5XqodEajpERsg0g+zDCe1x5wV8EUeAObYHISmKbQrakWTH7PGBidSmxJYHR9ABkV+cpBHLS1I5ZJd+GU7oArjqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646227938; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=97pDWLReIkpPchj9Yel9KdPfuWac0uFJp0eYu56ANe4=; b=l2INSwwTWkLnMC8VpNPNuJhRoIcI4YqVUkYDHemQvyAstYWVth36UKqOK9+WLrSzbrQt0PWv/bR4IX/JCLXQ1K2BUP6dnskqMCdyYaMo+cQwDrrpF1+pl/Q2UxYcZ7k56wOVQXLoNAsgAoBWdiPYRcGuSwvdlXZa0Rkcsp0ZeqI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87227+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1646227938131157.06869153172136; Wed, 2 Mar 2022 05:32:18 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id tDrmYY1788612xOKNumBuWrP; Wed, 02 Mar 2022 05:32:17 -0800 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web09.7180.1646227937113677854 for ; Wed, 02 Mar 2022 05:32:17 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="240813747" X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="240813747" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:16 -0800 X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="535389310" X-Received: from spearce-mobl1.amr.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.27.130]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:15 -0800 From: "Boeuf, Sebastien" To: devel@edk2.groups.io Cc: jiewen.yao@intel.com, jordan.l.justen@intel.com, kraxel@redhat.com, sebastien.boeuf@intel.com Subject: [edk2-devel] [PATCH v6 4/8] OvmfPkg: CloudHv: Remove VARS and CODE sections Date: Wed, 2 Mar 2022 14:31:33 +0100 Message-Id: <5b0c8ea4a9252b3902168b191ff037bd425c8740.1646227817.git.sebastien.boeuf@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sebastien.boeuf@intel.com X-Gm-Message-State: PDod9K0eSEctfhKM6BNOFyn8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646227937; bh=rbn+3PtKue1WQ9DuNdiV62rC2ibkD+yR6ejE79Puhqk=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=a6A31IzDeskmjDZaiaCZvlrokBvsoSPybkPWkJUkGVlpIrmtuyP3wUIT1sJSwt3OY7n eDeNK6G8tpnSZ3+I/csrBQ57YM24mIoHa6JK8B8vvn26aY4BGXS0xSj/XEKOj35aSBzE6 pCHyP9nhoN1YYP7Y6qu4LjLXSfYxkOxFnqc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646227939327100001 Content-Type: text/plain; charset="utf-8" From: Sebastien Boeuf CloudHv doesn't need any VARS store, and it doesn't need the CODE section to be generated separately either. The only thing needed is to generate a firmware binary that can be used by Cloud Hypervisor. Signed-off-by: Sebastien Boeuf Acked-by: Gerd Hoffmann --- OvmfPkg/CloudHv/CloudHvX64.fdf | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/OvmfPkg/CloudHv/CloudHvX64.fdf b/OvmfPkg/CloudHv/CloudHvX64.fdf index ce3302c6d6..0974e76ac8 100644 --- a/OvmfPkg/CloudHv/CloudHvX64.fdf +++ b/OvmfPkg/CloudHv/CloudHvX64.fdf @@ -24,38 +24,10 @@ ErasePolarity =3D 1 BlockSize =3D $(BLOCK_SIZE) NumBlocks =3D $(FW_BLOCKS) =20 -!include OvmfPkg/VarStore.fdf.inc - -$(VARS_SIZE)|$(FVMAIN_SIZE) -FV =3D FVMAIN_COMPACT - -$(SECFV_OFFSET)|$(SECFV_SIZE) -FV =3D SECFV - -# -# Build the variable store and the firmware code as separate flash device -# images. -# -[FD.CLOUDHV_VARS] -BaseAddress =3D $(FW_BASE_ADDRESS) -Size =3D $(VARS_SIZE) -ErasePolarity =3D 1 -BlockSize =3D $(BLOCK_SIZE) -NumBlocks =3D $(VARS_BLOCKS) - -!include OvmfPkg/VarStore.fdf.inc - -[FD.CLOUDHV_CODE] -BaseAddress =3D $(CODE_BASE_ADDRESS) -Size =3D $(CODE_SIZE) -ErasePolarity =3D 1 -BlockSize =3D $(BLOCK_SIZE) -NumBlocks =3D $(CODE_BLOCKS) - 0x00000000|$(FVMAIN_SIZE) FV =3D FVMAIN_COMPACT =20 -$(FVMAIN_SIZE)|$(SECFV_SIZE) +$(SECFV_OFFSET)|$(SECFV_SIZE) FV =3D SECFV =20 ##########################################################################= ###### --=20 2.32.0 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris,=20 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87227): https://edk2.groups.io/g/devel/message/87227 Mute This Topic: https://groups.io/mt/89500829/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 20:35:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87229+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87229+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646227953; cv=none; d=zohomail.com; s=zohoarc; b=acRadXxl4Mqr8lRXiwRn7BzHlGyRPPaAcWopHhIZllQ5D9+4wNhQy6ouAZvJUYaylaOUqIbrBAcC7DKwyZ1XBjTlBs5yTxFign7mIroM7HHMn5FWoBCd/i/3X7550dQzz7lSOMXtumjkoOGEKpi0bzmsofW1j29/ZVfuEB+LYwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646227953; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=+wwFEIu7ShI/bZHX4ZJsuU5qJ6bg553Tlyeczb84Bng=; b=gsSL8wGBZzVrBov09kr3RRsZILq7x36q6Nw2TkkzIIFcDWV1vPqFErP5xzA7nciLV69iwN37PfZMJbb6L+wHvVZ4AVN00P5tnzSd5K+Go0TuQDEHosw8jHgKK8vghkPk2tCZtWj5KX1Fly2SNDq3YVRQ3rcGNEIxpV8zSpyUwM0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87229+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16462279539800.08960796932285575; Wed, 2 Mar 2022 05:32:33 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id phGyYY1788612x22GyIOlpUG; Wed, 02 Mar 2022 05:32:33 -0800 X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web12.7226.1646227952775237843 for ; Wed, 02 Mar 2022 05:32:32 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="250974756" X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="250974756" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:25 -0800 X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="535389387" X-Received: from spearce-mobl1.amr.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.27.130]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:24 -0800 From: "Boeuf, Sebastien" To: devel@edk2.groups.io Cc: jiewen.yao@intel.com, jordan.l.justen@intel.com, kraxel@redhat.com, sebastien.boeuf@intel.com Subject: [edk2-devel] [PATCH v6 5/8] OvmfPkg: Generate CloudHv as a PVH ELF binary Date: Wed, 2 Mar 2022 14:31:34 +0100 Message-Id: <1f82cc46921762b209436aff32d6b098e4a3ea27.1646227817.git.sebastien.boeuf@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sebastien.boeuf@intel.com X-Gm-Message-State: YDTm3MGDmU7Ml98dVbBOWPZYx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646227953; bh=S95sao1GUeucuJ2rJ9exSqRvpEU6nAOUj3JW82WZ/3U=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=sp29iO+9LBHa7SQFXirNzwWTBs8LRaYxsvnY1BXSmjriHIXoz1h4tWJQhubKa61KExU AXxjZYyPXMTTwwkcjl4Keik9NBW3p/zNDh7COOXY+LkGb6S0B2MBllXhNPJvCb+vt4oSY KgrO9ch47smkoFMXwx0WzFxqvuSkli5iSbM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646227955615100001 Content-Type: text/plain; charset="utf-8" From: Sebastien Boeuf 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 Acked-by: Gerd Hoffmann --- OvmfPkg/CloudHv/CloudHvElfHeader.fdf.inc | 54 ++++++++++++++++++++++++ OvmfPkg/CloudHv/CloudHvX64.dsc | 2 +- OvmfPkg/CloudHv/CloudHvX64.fdf | 15 +++++-- 3 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 OvmfPkg/CloudHv/CloudHvElfHeader.fdf.inc diff --git a/OvmfPkg/CloudHv/CloudHvElfHeader.fdf.inc b/OvmfPkg/CloudHv/Clo= udHvElfHeader.fdf.inc new file mode 100644 index 0000000000..8377e30bdc --- /dev/null +++ b/OvmfPkg/CloudHv/CloudHvElfHeader.fdf.inc @@ -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 =3D { + # 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, 0x0= 2, 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 +} diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc index 3172100310..b4d855d80f 100644 --- a/OvmfPkg/CloudHv/CloudHvX64.dsc +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc @@ -631,7 +631,7 @@ # ##########################################################################= ###### [Components] - OvmfPkg/ResetVector/ResetVector.inf + OvmfPkg/XenResetVector/XenResetVector.inf =20 # # SEC Phase modules diff --git a/OvmfPkg/CloudHv/CloudHvX64.fdf b/OvmfPkg/CloudHv/CloudHvX64.fdf index 0974e76ac8..282bcf8634 100644 --- a/OvmfPkg/CloudHv/CloudHvX64.fdf +++ b/OvmfPkg/CloudHv/CloudHvX64.fdf @@ -14,8 +14,8 @@ !include OvmfPkg/OvmfPkgDefines.fdf.inc =20 # -# Build the variable store and the firmware code as one unified flash devi= ce -# image. +# This will allow the flash device image to be recognize as an ELF, with f= irst +# an ELF headers, then the firmware code. # [FD.CLOUDHV] BaseAddress =3D $(FW_BASE_ADDRESS) @@ -24,7 +24,14 @@ ErasePolarity =3D 1 BlockSize =3D $(BLOCK_SIZE) NumBlocks =3D $(FW_BLOCKS) =20 -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 =3D FVMAIN_COMPACT =20 $(SECFV_OFFSET)|$(SECFV_SIZE) @@ -114,7 +121,7 @@ READ_LOCK_STATUS =3D TRUE # INF OvmfPkg/Sec/SecMain.inf =20 -INF RuleOverride=3DRESET_VECTOR OvmfPkg/ResetVector/ResetVector.inf +INF RuleOverride=3DRESET_VECTOR OvmfPkg/XenResetVector/XenResetVector.inf =20 ##########################################################################= ###### [FV.PEIFV] --=20 2.32.0 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris,=20 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87229): https://edk2.groups.io/g/devel/message/87229 Mute This Topic: https://groups.io/mt/89500837/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 20:35:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87230+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87230+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646227956; cv=none; d=zohomail.com; s=zohoarc; b=HHhYLHJaNwiTJ/MMJDecL40N9obYTCsj/TibGXnA+3WA3H4zXSxdwxB/cjvznJUnUz6msI5xrP2meLrMhjAW37PlNDVU4Jja59QW0GwSjuVGZNsvCz2ubSN+vwEn2ZCFcxqWiu/siX0vSNRA/Ep1z1FsoV276y7m2+uFhigIqy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646227956; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=4nUkkw3I2Ylna9Dz+kHoSlMDaE4Ks63GfLTCbx6AULo=; b=IrSPkhmZzHTxc3qX88UHFK1IZFRhQIgfGnok56P4aXq6DyRk8A4kOoe6XZnL2xR3ptk+nCGWYK2fXEwbJNt9kWArn+bPhmFvYSc9tYghfnAjSpHdsD0sEGFGcG36M0LctpMO/xBfuEvaIVhGKIMeGnOLh3a4h8izZ8FHOttSydQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87230+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1646227956099240.35526665231555; Wed, 2 Mar 2022 05:32:36 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id FUR9YY1788612xsKBJJBCOo1; Wed, 02 Mar 2022 05:32:35 -0800 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web08.7087.1646227955006789591 for ; Wed, 02 Mar 2022 05:32:35 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="314118084" X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="314118084" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:34 -0800 X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="535389488" X-Received: from spearce-mobl1.amr.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.27.130]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:32 -0800 From: "Boeuf, Sebastien" To: devel@edk2.groups.io Cc: jiewen.yao@intel.com, jordan.l.justen@intel.com, kraxel@redhat.com, sebastien.boeuf@intel.com Subject: [edk2-devel] [PATCH v6 6/8] OvmfPkg: CloudHv: Retrieve RSDP address from PVH Date: Wed, 2 Mar 2022 14:31:35 +0100 Message-Id: <6c69a0ccf88c3ca9ab73cba362784c2f50aedf33.1646227817.git.sebastien.boeuf@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sebastien.boeuf@intel.com X-Gm-Message-State: gMkMyHOEyYjBpvQt1ItMEMr4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646227955; bh=0zBPnsVML0RpZpplxIoWqmbd1LUaHKGxeuQVqDHqUYk=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Qsk3/DBPkpVcQpKhHXij5C/N4Aew0OKE1BnBQJ0jqH1HdiqM8ViJZq4OJTkSwAmRxe5 7yY8wpumPp4OmZwo8QAnTWqJIXqENq3McDRwTwoYllsRPpiWCcC1gD2Q+3F5jNFlju/vZ eiWwPgxHdF9ad936Ezpy3MBu+go22DIfDKc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646227957602100005 Content-Type: text/plain; charset="utf-8" From: Sebastien Boeuf Instead of hardcoding the address of the RSDP in the firmware, let's rely on the PVH structure hvm_start_info to retrieve this information. Acked-by: Gerd Hoffmann Signed-off-by: Sebastien Boeuf --- OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf | 2 ++ OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c | 39 ++++++++++++++------- OvmfPkg/CloudHv/CloudHvX64.fdf | 3 ++ OvmfPkg/Include/IndustryStandard/CloudHv.h | 5 --- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/AcpiPlat= formDxe/AcpiPlatformDxe.inf index b36b8413e0..f22bd7cb6d 100644 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf @@ -56,6 +56,8 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId + gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr + gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize =20 [Depex] gEfiAcpiTableProtocolGuid diff --git a/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c b/OvmfPkg/AcpiPlatformDx= e/CloudHvAcpi.c index 44a6bb70fe..ff59600d3e 100644 --- a/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c +++ b/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c @@ -7,9 +7,11 @@ =20 **/ =20 -#include // CLOUDHV_RSDP_ADDRESS -#include // CpuDeadLoop() -#include // DEBUG() +#include // CLOUDHV_RSDP_= ADDRESS +#include // hvm_start_info +#include // CpuDeadLoop() +#include // DEBUG() +#include // PcdGet32() =20 #include "AcpiPlatform.h" =20 @@ -23,20 +25,33 @@ InstallCloudHvTables ( EFI_STATUS Status; UINTN TableHandle; =20 - EFI_ACPI_DESCRIPTION_HEADER *Xsdt; - VOID *CurrentTableEntry; - UINTN CurrentTablePointer; - EFI_ACPI_DESCRIPTION_HEADER *CurrentTable; - UINTN Index; - UINTN NumberOfTableEntries; - EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt2Table; - EFI_ACPI_DESCRIPTION_HEADER *DsdtTable; + EFI_ACPI_DESCRIPTION_HEADER *Xsdt; + VOID *CurrentTableEntry; + UINTN CurrentTablePointer; + EFI_ACPI_DESCRIPTION_HEADER *CurrentTable; + UINTN Index; + UINTN NumberOfTableEntries; + EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt2Table; + EFI_ACPI_DESCRIPTION_HEADER *DsdtTable; + EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *AcpiRsdpStructurePtr; + UINT32 *PVHResetVectorData; + struct hvm_start_info *pvh_start_info; =20 Fadt2Table =3D NULL; DsdtTable =3D NULL; TableHandle =3D 0; NumberOfTableEntries =3D 0; - EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *AcpiRsdpStructurePtr =3D = (VOID *)CLOUDHV_RSDP_ADDRESS; + AcpiRsdpStructurePtr =3D NULL; + PVHResetVectorData =3D NULL; + pvh_start_info =3D NULL; + + PVHResetVectorData =3D (VOID *)(UINTN)PcdGet32 (PcdXenPvhStartOfDayStruc= tPtr); + if (PVHResetVectorData =3D=3D 0) { + return EFI_NOT_FOUND; + } + + pvh_start_info =3D (struct hvm_start_info *)(UINTN)PVHResetVectorD= ata[0]; + AcpiRsdpStructurePtr =3D (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *= )(UINTN)pvh_start_info->rsdp_paddr; =20 // If XSDT table is found, just install its tables. // Otherwise, try to find and install the RSDT tables. diff --git a/OvmfPkg/CloudHv/CloudHvX64.fdf b/OvmfPkg/CloudHv/CloudHvX64.fdf index 282bcf8634..d80e13ae90 100644 --- a/OvmfPkg/CloudHv/CloudHvX64.fdf +++ b/OvmfPkg/CloudHv/CloudHvX64.fdf @@ -73,6 +73,9 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase|gUefiOvm= fPkgTokenSpaceGuid.PcdO 0x00E000|0x001000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase|gUefiOvmfPkgTokenSpaceGuid.Pcd= OvmfCpuidSize =20 +0x00F000|0x001000 +gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr|gUefiOvmfPkgTokenS= paceGuid.PcdXenPvhStartOfDayStructPtrSize + 0x010000|0x010000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpace= Guid.PcdOvmfSecPeiTempRamSize =20 diff --git a/OvmfPkg/Include/IndustryStandard/CloudHv.h b/OvmfPkg/Include/I= ndustryStandard/CloudHv.h index 86404cc97e..d31ecc9eec 100644 --- a/OvmfPkg/Include/IndustryStandard/CloudHv.h +++ b/OvmfPkg/Include/IndustryStandard/CloudHv.h @@ -38,9 +38,4 @@ // #define CLOUDHV_SMBIOS_ADDRESS 0xf0000 =20 -// -// RSDP address -// -#define CLOUDHV_RSDP_ADDRESS 0xa0000 - #endif // __CLOUDHV_H__ --=20 2.32.0 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris,=20 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87230): https://edk2.groups.io/g/devel/message/87230 Mute This Topic: https://groups.io/mt/89500840/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 20:35:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87231+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87231+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646227974; cv=none; d=zohomail.com; s=zohoarc; b=MzPZ/qrHBTMI4roIoi+VATJ/u83G1donamZ3Cr3nNIJXBoW+LvQ12skmuztOZKbFQgPnXrD7pril0cBuBeUlFv4GFRZFsixGM/kpk65wz4WVuASPEhNl4/FCjpKJaLkNE/CGOfb8+xQVCKXFbW8ssLTt3r9ZfTBFwIKypW0RsnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646227974; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Pfgpk39DKAwAFinJKQ3wWsFHZpgrHZSqBN5C2Nzesqg=; b=Zpe4TNOOyBnur24ruo0PAifSC+0YI5Hw63eZASvYSRUneKKeLKVM7mn6I57lU9BdNlnaBxGBbYcLhCJYThI9zYlO7KAk/odbv3AL8dBrjaUWaTlglu35p8QTNmDDHsojqCC//IgP+D1FgtSl5lK7ZnLtKTRKwB7+ryCZ3jBuarU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87231+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1646227974323227.70219298305756; Wed, 2 Mar 2022 05:32:54 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 3AazYY1788612xNTytRBHkiI; Wed, 02 Mar 2022 05:32:53 -0800 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web09.7188.1646227973092336980 for ; Wed, 02 Mar 2022 05:32:53 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="253130664" X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="253130664" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:43 -0800 X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="535389541" X-Received: from spearce-mobl1.amr.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.27.130]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:41 -0800 From: "Boeuf, Sebastien" To: devel@edk2.groups.io Cc: jiewen.yao@intel.com, jordan.l.justen@intel.com, kraxel@redhat.com, sebastien.boeuf@intel.com Subject: [edk2-devel] [PATCH v6 7/8] OvmfPkg: CloudHv: Rely on PVH memmap instead of CMOS Date: Wed, 2 Mar 2022 14:31:36 +0100 Message-Id: <72270dff2f01a8cb955d6c8eb0bdd1fb9f156ffe.1646227817.git.sebastien.boeuf@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sebastien.boeuf@intel.com X-Gm-Message-State: POpwtCbcsDLafbc2P5l0wgBgx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646227973; bh=UinxDenaH+ogIErTVxN1OhmcyYrPvhuX1d+XjZS26gM=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=AbgKufKDc2erjKAOjcGA8cz2g2sGFucOb00aSQNtPD3c3/6/4/FVKekuJI3xJPo2oRt ZHR5dVCqnyXiObckVqmgxzeaPhmKPv3lKbgIaksIL+WGOl+MsG5stodyApb29kljfzdO4 PzOCGY0gH8InlElymtjzIaC7A9miKLyPXZQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646227975835100002 Content-Type: text/plain; charset="utf-8" From: Sebastien Boeuf Instead of using the CMOS, the CloudHv platform relies on the list of memmap entries provided through the PVH boot protocol to determine the last RAM address below 4G. Acked-by: Gerd Hoffmann Signed-off-by: Sebastien Boeuf --- OvmfPkg/PlatformPei/MemDetect.c | 73 +++++++++++++++++++++++++++++ OvmfPkg/PlatformPei/PlatformPei.inf | 2 + 2 files changed, 75 insertions(+) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 1bcb5a08bc..8ecc8257f9 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -17,6 +17,7 @@ Module Name: #include #include #include +#include #include #include =20 @@ -315,6 +316,73 @@ ScanOrAdd64BitE820Ram ( return EFI_SUCCESS; } =20 +/** + Returns PVH memmap + + @param Entries Pointer to PVH memmap + @param Count Number of entries + + @return EFI_STATUS +**/ +EFI_STATUS +GetPvhMemmapEntries ( + struct hvm_memmap_table_entry **Entries, + UINT32 *Count + ) +{ + UINT32 *PVHResetVectorData; + struct hvm_start_info *pvh_start_info; + + PVHResetVectorData =3D (VOID *)(UINTN)PcdGet32 (PcdXenPvhStartOfDayStruc= tPtr); + if (PVHResetVectorData =3D=3D 0) { + return EFI_NOT_FOUND; + } + + pvh_start_info =3D (struct hvm_start_info *)(UINTN)PVHResetVectorData[0]; + + *Entries =3D (struct hvm_memmap_table_entry *)(UINTN)pvh_start_info->mem= map_paddr; + *Count =3D pvh_start_info->memmap_entries; + + return EFI_SUCCESS; +} + +STATIC +UINT64 +GetHighestSystemMemoryAddressFromPvhMemmap ( + BOOLEAN Below4gb + ) +{ + struct hvm_memmap_table_entry *Memmap; + UINT32 MemmapEntriesCount; + struct hvm_memmap_table_entry *Entry; + EFI_STATUS Status; + UINT32 Loop; + UINT64 HighestAddress; + UINT64 EntryEnd; + + HighestAddress =3D 0; + + Status =3D GetPvhMemmapEntries (&Memmap, &MemmapEntriesCount); + ASSERT_EFI_ERROR (Status); + + for (Loop =3D 0; Loop < MemmapEntriesCount; Loop++) { + Entry =3D Memmap + Loop; + EntryEnd =3D Entry->addr + Entry->size; + + if ((Entry->type =3D=3D XEN_HVM_MEMMAP_TYPE_RAM) && + (EntryEnd > HighestAddress)) + { + if (Below4gb && (EntryEnd <=3D BASE_4GB)) { + HighestAddress =3D EntryEnd; + } else if (!Below4gb && (EntryEnd >=3D BASE_4GB)) { + HighestAddress =3D EntryEnd; + } + } + } + + return HighestAddress; +} + UINT32 GetSystemMemorySizeBelow4gb ( VOID @@ -325,6 +393,11 @@ GetSystemMemorySizeBelow4gb ( UINT8 Cmos0x34; UINT8 Cmos0x35; =20 + if (mHostBridgeDevId =3D=3D CLOUDHV_DEVICE_ID) { + // Get the information from PVH memmap + return (UINT32)GetHighestSystemMemoryAddressFromPvhMemmap (TRUE); + } + Status =3D ScanOrAdd64BitE820Ram (FALSE, &LowerMemorySize, NULL); if ((Status =3D=3D EFI_SUCCESS) && (LowerMemorySize > 0)) { return (UINT32)LowerMemorySize; diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index 8ef404168c..212aa7b047 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -91,6 +91,8 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase + gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr + gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize --=20 2.32.0 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris,=20 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87231): https://edk2.groups.io/g/devel/message/87231 Mute This Topic: https://groups.io/mt/89500845/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 20:35:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87232+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87232+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646227975; cv=none; d=zohomail.com; s=zohoarc; b=md3MNO1JviDUEIVM2ytYyfBkSRsHYBxvV6ACxscxwlhidu3NUUW7xYevzA7xvMzEnh64PHOd+4hLLe2+KU5HvQ06WnrfV4eVRR+5bCKgwPEkU31IvfgevmWvGikIS84WmX6/vZI9eHcPC9aVi4kePs/Uyu3FMzJczXAfzUlxKtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646227975; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=hsXEBWxWuTgSfoGD4M6Psn0TI7KKbSwCyIh+oIajA+Q=; b=G9gIFlGeoSAnyMb8b2dgphOJQshZAG9ji8UI76ezY6/wW2fekfzlqvW49ETyGVdJdjs2S+5SC1QW2eVSZ1f8t1tn+CLHaHJfM8G+LqYFITLYO3zkdt/GhFJUkIho+cwv0u/tbUAHUdG9Hdyd/prD2MsjCivby9kkV977fNf+MlU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87232+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1646227975676356.3585727117529; Wed, 2 Mar 2022 05:32:55 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Xso1YY1788612xzW3LuLy7C3; Wed, 02 Mar 2022 05:32:55 -0800 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web09.7189.1646227974640882148 for ; Wed, 02 Mar 2022 05:32:54 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="253325447" X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="253325447" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:53 -0800 X-IronPort-AV: E=Sophos;i="5.90,149,1643702400"; d="scan'208";a="535389598" X-Received: from spearce-mobl1.amr.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.27.130]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 05:32:52 -0800 From: "Boeuf, Sebastien" To: devel@edk2.groups.io Cc: jiewen.yao@intel.com, jordan.l.justen@intel.com, kraxel@redhat.com, sebastien.boeuf@intel.com Subject: [edk2-devel] [PATCH v6 8/8] OvmfPkg: CloudHv: Add README Date: Wed, 2 Mar 2022 14:31:37 +0100 Message-Id: <9d6446b2eac74d6c5332990929650052454d90a2.1646227817.git.sebastien.boeuf@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sebastien.boeuf@intel.com X-Gm-Message-State: 89dfVVrmZFeVz2IEVHgpF0DKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646227975; bh=TdX40tS6Opjvce6vxDSO7b4FuJqTudfJiwR9ZgHSuRI=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=LJd6JxHom5jlf9kVFatpO4LYTiTXZm7Mj+N2V4O7vEgB9q+WEP8bTzPHcEuDQz5wbyz vEa5HKLdoV8aFw+2Db6sits05L3CFUoBGoDFOO9KKAq3ilbK7DJWCPyGne1/P+FVgmUFp N7x8kDkgwWaIPFLHJ6ZB9WOy9U3VgDC9+aI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646227977803100006 Content-Type: text/plain; charset="utf-8" From: Sebastien Boeuf Add some documentation to the CloudHv target in order to clarify how to use it and what to expect from it. Signed-off-by: Sebastien Boeuf Acked-by: Gerd Hoffmann --- OvmfPkg/CloudHv/README | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 OvmfPkg/CloudHv/README diff --git a/OvmfPkg/CloudHv/README b/OvmfPkg/CloudHv/README new file mode 100644 index 0000000000..63e28860e0 --- /dev/null +++ b/OvmfPkg/CloudHv/README @@ -0,0 +1,67 @@ + +CloudHv is a port of OVMF for the Cloud Hypervisor project. + +The Cloud Hypervisor project +---------------------------- + +Cloud Hypervisor is a Virtual Machine Monitor that runs on top of KVM. The +project focuses on exclusively running modern, cloud workloads, on top of a +limited set of hardware architectures and platforms. Cloud workloads refer= s to +those that are usually run by customers inside a cloud provider. This means +modern operating systems with most I/O handled by paravirtualised devices +(i.e. virtio), no requirement for legacy devices, and 64-bit CPUs. + +https://github.com/cloud-hypervisor/cloud-hypervisor + +Design +------ + +Based on Cloud Hypervisor's motto to reduce the emulation as much as possi= ble, +the project logically decided to support the PVH boot specification as the= only +way of booting virtual machines. That includes both direct kernel boot and= OVMF +firmware which must be generated as PVH ELF binaries. +PVH allows information like location of ACPI tables and location of guest = RAM +ranges to be shared without the need of an extra emulated device like a CM= OS. + +Features +-------- + +* Serial console +* EFI shell +* virtio-pci + +Build +----- + +The way to build the CloudHv target is as follows: + +OvmfPkg/build.sh -p OvmfPkg/CloudHv/CloudHvX64.dsc -a X64 -b DEBUG + +Usage +----- + +Assuming Cloud Hypervisor is already built, one can start a virtual machin= e as +follows: + +./cloud-hypervisor \ + --cpus boot=3D1 \ + --memory size=3D1G \ + --kernel Build/CloudHvX64/DEBUG_GCC5/FV/CLOUDHV.fd \ + --disk path=3D/path/to/disk.raw + +Releases +-------- + +In edk2-stable202202, CloudHv is generated as data-only binary. +Starting with edk2-stable202205, CloudHv is generated as a PVH ELF binary = to +reduce the amount of emulation needed from Cloud Hypervisor. +For TDX, things are handled differently and PVH is not used, which is why = the +firmware is always generated as a data-only binary. + ++-------------------+----------------+ +| | CloudHv | ++-------------------+----------------+ +| edk2-stable202202 | Data binary | ++-------------------+----------------+ +| edk2-stable202205 | PVH ELF binary | ++-------------------+----------------+ --=20 2.32.0 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris,=20 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87232): https://edk2.groups.io/g/devel/message/87232 Mute This Topic: https://groups.io/mt/89500846/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-