--- /dev/null
+/*\r
+ * SPDX-License-Identifier: MIT\r
+ *\r
+ * Copyright (c) 2016, Citrix Systems, Inc.\r
+ */\r
+\r
+#ifndef __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__\r
+#define __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__\r
+\r
+/*\r
+ * Start of day structure passed to PVH guests and to HVM guests in %ebx.\r
+ *\r
+ * NOTE: nothing will be loaded at physical address 0, so a 0 value in any\r
+ * of the address fields should be treated as not present.\r
+ *\r
+ * 0 +----------------+\r
+ * | magic | Contains the magic value XEN_HVM_START_MAGIC_VALUE\r
+ * | | ("xEn3" with the 0x80 bit of the "E" set).\r
+ * 4 +----------------+\r
+ * | version | Version of this structure. Current version is 1. New\r
+ * | | versions are guaranteed to be backwards-compatible.\r
+ * 8 +----------------+\r
+ * | flags | SIF_xxx flags.\r
+ * 12 +----------------+\r
+ * | nr_modules | Number of modules passed to the kernel.\r
+ * 16 +----------------+\r
+ * | modlist_paddr | Physical address of an array of modules\r
+ * | | (layout of the structure below).\r
+ * 24 +----------------+\r
+ * | cmdline_paddr | Physical address of the command line,\r
+ * | | a zero-terminated ASCII string.\r
+ * 32 +----------------+\r
+ * | rsdp_paddr | Physical address of the RSDP ACPI data structure.\r
+ * 40 +----------------+\r
+ * | memmap_paddr | Physical address of the (optional) memory map. Only\r
+ * | | present in version 1 and newer of the structure.\r
+ * 48 +----------------+\r
+ * | memmap_entries | Number of entries in the memory map table. Zero\r
+ * | | if there is no memory map being provided. Only\r
+ * | | present in version 1 and newer of the structure.\r
+ * 52 +----------------+\r
+ * | reserved | Version 1 and newer only.\r
+ * 56 +----------------+\r
+ *\r
+ * The layout of each entry in the module structure is the following:\r
+ *\r
+ * 0 +----------------+\r
+ * | paddr | Physical address of the module.\r
+ * 8 +----------------+\r
+ * | size | Size of the module in bytes.\r
+ * 16 +----------------+\r
+ * | cmdline_paddr | Physical address of the command line,\r
+ * | | a zero-terminated ASCII string.\r
+ * 24 +----------------+\r
+ * | reserved |\r
+ * 32 +----------------+\r
+ *\r
+ * The layout of each entry in the memory map table is as follows:\r
+ *\r
+ * 0 +----------------+\r
+ * | addr | Base address\r
+ * 8 +----------------+\r
+ * | size | Size of mapping in bytes\r
+ * 16 +----------------+\r
+ * | type | Type of mapping as defined between the hypervisor\r
+ * | | and guest. See XEN_HVM_MEMMAP_TYPE_* values below.\r
+ * 20 +----------------|\r
+ * | reserved |\r
+ * 24 +----------------+\r
+ *\r
+ * The address and sizes are always a 64bit little endian unsigned integer.\r
+ *\r
+ * NB: Xen on x86 will always try to place all the data below the 4GiB\r
+ * boundary.\r
+ *\r
+ * Version numbers of the hvm_start_info structure have evolved like this:\r
+ *\r
+ * Version 0: Initial implementation.\r
+ *\r
+ * Version 1: Added the memmap_paddr/memmap_entries fields (plus 4 bytes of\r
+ * padding) to the end of the hvm_start_info struct. These new\r
+ * fields can be used to pass a memory map to the guest. The\r
+ * memory map is optional and so guests that understand version 1\r
+ * of the structure must check that memmap_entries is non-zero\r
+ * before trying to read the memory map.\r
+ */\r
+#define XEN_HVM_START_MAGIC_VALUE 0x336ec578\r
+\r
+/*\r
+ * The values used in the type field of the memory map table entries are\r
+ * defined below and match the Address Range Types as defined in the "System\r
+ * Address Map Interfaces" section of the ACPI Specification. Please refer to\r
+ * section 15 in version 6.2 of the ACPI spec: http://uefi.org/specifications\r
+ */\r
+#define XEN_HVM_MEMMAP_TYPE_RAM 1\r
+#define XEN_HVM_MEMMAP_TYPE_RESERVED 2\r
+#define XEN_HVM_MEMMAP_TYPE_ACPI 3\r
+#define XEN_HVM_MEMMAP_TYPE_NVS 4\r
+#define XEN_HVM_MEMMAP_TYPE_UNUSABLE 5\r
+#define XEN_HVM_MEMMAP_TYPE_DISABLED 6\r
+#define XEN_HVM_MEMMAP_TYPE_PMEM 7\r
+\r
+/*\r
+ * C representation of the x86/HVM start info layout.\r
+ *\r
+ * The canonical definition of this layout is above, this is just a way to\r
+ * represent the layout described there using C types.\r
+ */\r
+struct hvm_start_info {\r
+ UINT32 magic; /* Contains the magic value 0x336ec578 */\r
+ /* ("xEn3" with the 0x80 bit of the "E" set).*/\r
+ UINT32 version; /* Version of this structure. */\r
+ UINT32 flags; /* SIF_xxx flags. */\r
+ UINT32 nr_modules; /* Number of modules passed to the kernel. */\r
+ UINT64 modlist_paddr; /* Physical address of an array of */\r
+ /* hvm_modlist_entry. */\r
+ UINT64 cmdline_paddr; /* Physical address of the command line. */\r
+ UINT64 rsdp_paddr; /* Physical address of the RSDP ACPI data */\r
+ /* structure. */\r
+ /* All following fields only present in version 1 and newer */\r
+ UINT64 memmap_paddr; /* Physical address of an array of */\r
+ /* hvm_memmap_table_entry. */\r
+ UINT32 memmap_entries; /* Number of entries in the memmap table. */\r
+ /* Value will be zero if there is no memory */\r
+ /* map being provided. */\r
+ UINT32 reserved; /* Must be zero. */\r
+};\r
+\r
+struct hvm_modlist_entry {\r
+ UINT64 paddr; /* Physical address of the module. */\r
+ UINT64 size; /* Size of the module in bytes. */\r
+ UINT64 cmdline_paddr; /* Physical address of the command line. */\r
+ UINT64 reserved;\r
+};\r
+\r
+struct hvm_memmap_table_entry {\r
+ UINT64 addr; /* Base address of the memory region */\r
+ UINT64 size; /* Size of the memory region in bytes */\r
+ UINT32 type; /* Mapping type */\r
+ UINT32 reserved; /* Must be zero for Version 1. */\r
+};\r
+\r
+#endif /* __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ */\r
#include <IndustryStandard/E820.h>\r
#include <Library/ResourcePublicationLib.h>\r
#include <Library/MtrrLib.h>\r
+#include <IndustryStandard/Xen/arch-x86/hvm/start_info.h>\r
\r
#include "Platform.h"\r
#include "Xen.h"\r
UINT32 XenVersion;\r
EFI_XEN_OVMF_INFO *Info;\r
CHAR8 Sig[sizeof (Info->Signature) + 1];\r
+ UINT32 *PVHResetVectorData;\r
\r
AsmCpuid (XenLeaf + 2, &TransferPages, &TransferReg, NULL, NULL);\r
mXenInfo.HyperPages = AllocatePages (TransferPages);\r
mXenHvmloaderInfo = NULL;\r
}\r
\r
+ mXenInfo.RsdpPvh = NULL;\r
+\r
+ //\r
+ // Locate and use information from the start of day structure if we have\r
+ // booted via the PVH entry point.\r
+ //\r
+\r
+ PVHResetVectorData = (VOID *)(UINTN) PcdGet32 (PcdXenPvhStartOfDayStructPtr);\r
+ //\r
+ // That magic value is written in XenResetVector/Ia32/XenPVHMain.asm\r
+ //\r
+ if (PVHResetVectorData[1] == SIGNATURE_32 ('X', 'P', 'V', 'H')) {\r
+ struct hvm_start_info *HVMStartInfo;\r
+\r
+ HVMStartInfo = (VOID *)(UINTN) PVHResetVectorData[0];\r
+ if (HVMStartInfo->magic == XEN_HVM_START_MAGIC_VALUE) {\r
+ ASSERT (HVMStartInfo->rsdp_paddr != 0);\r
+ if (HVMStartInfo->rsdp_paddr != 0) {\r
+ mXenInfo.RsdpPvh = (VOID *)(UINTN)HVMStartInfo->rsdp_paddr;\r
+ }\r
+ }\r
+ }\r
+\r
BuildGuidDataHob (\r
&gEfiXenInfoGuid,\r
&mXenInfo,\r