1 /*
2  * SPDX-License-Identifier: MIT
3  *
4  * Copyright (c) 2016, Citrix Systems, Inc.
5  */
6 
7 #ifndef __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__
8 #define __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__
9 
10 /*
11  * Start of day structure passed to PVH guests and to HVM guests in %ebx.
12  *
13  * NOTE: nothing will be loaded at physical address 0, so a 0 value in any
14  * of the address fields should be treated as not present.
15  *
16  *  0 +----------------+
17  *    | magic          | Contains the magic value XEN_HVM_START_MAGIC_VALUE
18  *    |                | ("xEn3" with the 0x80 bit of the "E" set).
19  *  4 +----------------+
20  *    | version        | Version of this structure. Current version is 1. New
21  *    |                | versions are guaranteed to be backwards-compatible.
22  *  8 +----------------+
23  *    | flags          | SIF_xxx flags.
24  * 12 +----------------+
25  *    | nr_modules     | Number of modules passed to the kernel.
26  * 16 +----------------+
27  *    | modlist_paddr  | Physical address of an array of modules
28  *    |                | (layout of the structure below).
29  * 24 +----------------+
30  *    | cmdline_paddr  | Physical address of the command line,
31  *    |                | a zero-terminated ASCII string.
32  * 32 +----------------+
33  *    | rsdp_paddr     | Physical address of the RSDP ACPI data structure.
34  * 40 +----------------+
35  *    | memmap_paddr   | Physical address of the (optional) memory map. Only
36  *    |                | present in version 1 and newer of the structure.
37  * 48 +----------------+
38  *    | memmap_entries | Number of entries in the memory map table. Zero
39  *    |                | if there is no memory map being provided. Only
40  *    |                | present in version 1 and newer of the structure.
41  * 52 +----------------+
42  *    | reserved       | Version 1 and newer only.
43  * 56 +----------------+
44  *
45  * The layout of each entry in the module structure is the following:
46  *
47  *  0 +----------------+
48  *    | paddr          | Physical address of the module.
49  *  8 +----------------+
50  *    | size           | Size of the module in bytes.
51  * 16 +----------------+
52  *    | cmdline_paddr  | Physical address of the command line,
53  *    |                | a zero-terminated ASCII string.
54  * 24 +----------------+
55  *    | reserved       |
56  * 32 +----------------+
57  *
58  * The layout of each entry in the memory map table is as follows:
59  *
60  *  0 +----------------+
61  *    | addr           | Base address
62  *  8 +----------------+
63  *    | size           | Size of mapping in bytes
64  * 16 +----------------+
65  *    | type           | Type of mapping as defined between the hypervisor
66  *    |                | and guest. See XEN_HVM_MEMMAP_TYPE_* values below.
67  * 20 +----------------|
68  *    | reserved       |
69  * 24 +----------------+
70  *
71  * The address and sizes are always a 64bit little endian unsigned integer.
72  *
73  * NB: Xen on x86 will always try to place all the data below the 4GiB
74  * boundary.
75  *
76  * Version numbers of the hvm_start_info structure have evolved like this:
77  *
78  * Version 0:  Initial implementation.
79  *
80  * Version 1:  Added the memmap_paddr/memmap_entries fields (plus 4 bytes of
81  *             padding) to the end of the hvm_start_info struct. These new
82  *             fields can be used to pass a memory map to the guest. The
83  *             memory map is optional and so guests that understand version 1
84  *             of the structure must check that memmap_entries is non-zero
85  *             before trying to read the memory map.
86  */
87 #define XEN_HVM_START_MAGIC_VALUE 0x336ec578
88 
89 /*
90  * The values used in the type field of the memory map table entries are
91  * defined below and match the Address Range Types as defined in the "System
92  * Address Map Interfaces" section of the ACPI Specification. Please refer to
93  * section 15 in version 6.2 of the ACPI spec: http://uefi.org/specifications
94  */
95 #define XEN_HVM_MEMMAP_TYPE_RAM       1
96 #define XEN_HVM_MEMMAP_TYPE_RESERVED  2
97 #define XEN_HVM_MEMMAP_TYPE_ACPI      3
98 #define XEN_HVM_MEMMAP_TYPE_NVS       4
99 #define XEN_HVM_MEMMAP_TYPE_UNUSABLE  5
100 #define XEN_HVM_MEMMAP_TYPE_DISABLED  6
101 #define XEN_HVM_MEMMAP_TYPE_PMEM      7
102 
103 /*
104  * C representation of the x86/HVM start info layout.
105  *
106  * The canonical definition of this layout is above, this is just a way to
107  * represent the layout described there using C types.
108  */
109 struct hvm_start_info {
110     UINT32 magic;             /* Contains the magic value 0x336ec578       */
111                               /* ("xEn3" with the 0x80 bit of the "E" set).*/
112     UINT32 version;           /* Version of this structure.                */
113     UINT32 flags;             /* SIF_xxx flags.                            */
114     UINT32 nr_modules;        /* Number of modules passed to the kernel.   */
115     UINT64 modlist_paddr;     /* Physical address of an array of           */
116                               /* hvm_modlist_entry.                        */
117     UINT64 cmdline_paddr;     /* Physical address of the command line.     */
118     UINT64 rsdp_paddr;        /* Physical address of the RSDP ACPI data    */
119                               /* structure.                                */
120     /* All following fields only present in version 1 and newer */
121     UINT64 memmap_paddr;      /* Physical address of an array of           */
122                               /* hvm_memmap_table_entry.                   */
123     UINT32 memmap_entries;    /* Number of entries in the memmap table.    */
124                               /* Value will be zero if there is no memory  */
125                               /* map being provided.                       */
126     UINT32 reserved;          /* Must be zero.                             */
127 };
128 
129 struct hvm_modlist_entry {
130     UINT64 paddr;             /* Physical address of the module.           */
131     UINT64 size;              /* Size of the module in bytes.              */
132     UINT64 cmdline_paddr;     /* Physical address of the command line.     */
133     UINT64 reserved;
134 };
135 
136 struct hvm_memmap_table_entry {
137     UINT64 addr;              /* Base address of the memory region         */
138     UINT64 size;              /* Size of the memory region in bytes        */
139     UINT32 type;              /* Mapping type                              */
140     UINT32 reserved;          /* Must be zero for Version 1.               */
141 };
142 
143 #endif /* __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ */
144