xref: /freebsd/sys/contrib/xen/arch-x86/hvm/start_info.h (revision 3a9fd8242b35884921dfc4e886f284a75870a536)
1*3a9fd824SRoger Pau Monné /*
2*3a9fd824SRoger Pau Monné  * Permission is hereby granted, free of charge, to any person obtaining a copy
3*3a9fd824SRoger Pau Monné  * of this software and associated documentation files (the "Software"), to
4*3a9fd824SRoger Pau Monné  * deal in the Software without restriction, including without limitation the
5*3a9fd824SRoger Pau Monné  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6*3a9fd824SRoger Pau Monné  * sell copies of the Software, and to permit persons to whom the Software is
7*3a9fd824SRoger Pau Monné  * furnished to do so, subject to the following conditions:
8*3a9fd824SRoger Pau Monné  *
9*3a9fd824SRoger Pau Monné  * The above copyright notice and this permission notice shall be included in
10*3a9fd824SRoger Pau Monné  * all copies or substantial portions of the Software.
11*3a9fd824SRoger Pau Monné  *
12*3a9fd824SRoger Pau Monné  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13*3a9fd824SRoger Pau Monné  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14*3a9fd824SRoger Pau Monné  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15*3a9fd824SRoger Pau Monné  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16*3a9fd824SRoger Pau Monné  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17*3a9fd824SRoger Pau Monné  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18*3a9fd824SRoger Pau Monné  * DEALINGS IN THE SOFTWARE.
19*3a9fd824SRoger Pau Monné  *
20*3a9fd824SRoger Pau Monné  * Copyright (c) 2016, Citrix Systems, Inc.
21*3a9fd824SRoger Pau Monné  */
22*3a9fd824SRoger Pau Monné 
23*3a9fd824SRoger Pau Monné #ifndef __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__
24*3a9fd824SRoger Pau Monné #define __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__
25*3a9fd824SRoger Pau Monné 
26*3a9fd824SRoger Pau Monné /*
27*3a9fd824SRoger Pau Monné  * Start of day structure passed to PVH guests and to HVM guests in %ebx.
28*3a9fd824SRoger Pau Monné  *
29*3a9fd824SRoger Pau Monné  * NOTE: nothing will be loaded at physical address 0, so a 0 value in any
30*3a9fd824SRoger Pau Monné  * of the address fields should be treated as not present.
31*3a9fd824SRoger Pau Monné  *
32*3a9fd824SRoger Pau Monné  *  0 +----------------+
33*3a9fd824SRoger Pau Monné  *    | magic          | Contains the magic value XEN_HVM_START_MAGIC_VALUE
34*3a9fd824SRoger Pau Monné  *    |                | ("xEn3" with the 0x80 bit of the "E" set).
35*3a9fd824SRoger Pau Monné  *  4 +----------------+
36*3a9fd824SRoger Pau Monné  *    | version        | Version of this structure. Current version is 1. New
37*3a9fd824SRoger Pau Monné  *    |                | versions are guaranteed to be backwards-compatible.
38*3a9fd824SRoger Pau Monné  *  8 +----------------+
39*3a9fd824SRoger Pau Monné  *    | flags          | SIF_xxx flags.
40*3a9fd824SRoger Pau Monné  * 12 +----------------+
41*3a9fd824SRoger Pau Monné  *    | nr_modules     | Number of modules passed to the kernel.
42*3a9fd824SRoger Pau Monné  * 16 +----------------+
43*3a9fd824SRoger Pau Monné  *    | modlist_paddr  | Physical address of an array of modules
44*3a9fd824SRoger Pau Monné  *    |                | (layout of the structure below).
45*3a9fd824SRoger Pau Monné  * 24 +----------------+
46*3a9fd824SRoger Pau Monné  *    | cmdline_paddr  | Physical address of the command line,
47*3a9fd824SRoger Pau Monné  *    |                | a zero-terminated ASCII string.
48*3a9fd824SRoger Pau Monné  * 32 +----------------+
49*3a9fd824SRoger Pau Monné  *    | rsdp_paddr     | Physical address of the RSDP ACPI data structure.
50*3a9fd824SRoger Pau Monné  * 40 +----------------+
51*3a9fd824SRoger Pau Monné  *    | memmap_paddr   | Physical address of the (optional) memory map. Only
52*3a9fd824SRoger Pau Monné  *    |                | present in version 1 and newer of the structure.
53*3a9fd824SRoger Pau Monné  * 48 +----------------+
54*3a9fd824SRoger Pau Monné  *    | memmap_entries | Number of entries in the memory map table. Zero
55*3a9fd824SRoger Pau Monné  *    |                | if there is no memory map being provided. Only
56*3a9fd824SRoger Pau Monné  *    |                | present in version 1 and newer of the structure.
57*3a9fd824SRoger Pau Monné  * 52 +----------------+
58*3a9fd824SRoger Pau Monné  *    | reserved       | Version 1 and newer only.
59*3a9fd824SRoger Pau Monné  * 56 +----------------+
60*3a9fd824SRoger Pau Monné  *
61*3a9fd824SRoger Pau Monné  * The layout of each entry in the module structure is the following:
62*3a9fd824SRoger Pau Monné  *
63*3a9fd824SRoger Pau Monné  *  0 +----------------+
64*3a9fd824SRoger Pau Monné  *    | paddr          | Physical address of the module.
65*3a9fd824SRoger Pau Monné  *  8 +----------------+
66*3a9fd824SRoger Pau Monné  *    | size           | Size of the module in bytes.
67*3a9fd824SRoger Pau Monné  * 16 +----------------+
68*3a9fd824SRoger Pau Monné  *    | cmdline_paddr  | Physical address of the command line,
69*3a9fd824SRoger Pau Monné  *    |                | a zero-terminated ASCII string.
70*3a9fd824SRoger Pau Monné  * 24 +----------------+
71*3a9fd824SRoger Pau Monné  *    | reserved       |
72*3a9fd824SRoger Pau Monné  * 32 +----------------+
73*3a9fd824SRoger Pau Monné  *
74*3a9fd824SRoger Pau Monné  * The layout of each entry in the memory map table is as follows:
75*3a9fd824SRoger Pau Monné  *
76*3a9fd824SRoger Pau Monné  *  0 +----------------+
77*3a9fd824SRoger Pau Monné  *    | addr           | Base address
78*3a9fd824SRoger Pau Monné  *  8 +----------------+
79*3a9fd824SRoger Pau Monné  *    | size           | Size of mapping in bytes
80*3a9fd824SRoger Pau Monné  * 16 +----------------+
81*3a9fd824SRoger Pau Monné  *    | type           | Type of mapping as defined between the hypervisor
82*3a9fd824SRoger Pau Monné  *    |                | and guest. See XEN_HVM_MEMMAP_TYPE_* values below.
83*3a9fd824SRoger Pau Monné  * 20 +----------------|
84*3a9fd824SRoger Pau Monné  *    | reserved       |
85*3a9fd824SRoger Pau Monné  * 24 +----------------+
86*3a9fd824SRoger Pau Monné  *
87*3a9fd824SRoger Pau Monné  * The address and sizes are always a 64bit little endian unsigned integer.
88*3a9fd824SRoger Pau Monné  *
89*3a9fd824SRoger Pau Monné  * NB: Xen on x86 will always try to place all the data below the 4GiB
90*3a9fd824SRoger Pau Monné  * boundary.
91*3a9fd824SRoger Pau Monné  *
92*3a9fd824SRoger Pau Monné  * Version numbers of the hvm_start_info structure have evolved like this:
93*3a9fd824SRoger Pau Monné  *
94*3a9fd824SRoger Pau Monné  * Version 0:  Initial implementation.
95*3a9fd824SRoger Pau Monné  *
96*3a9fd824SRoger Pau Monné  * Version 1:  Added the memmap_paddr/memmap_entries fields (plus 4 bytes of
97*3a9fd824SRoger Pau Monné  *             padding) to the end of the hvm_start_info struct. These new
98*3a9fd824SRoger Pau Monné  *             fields can be used to pass a memory map to the guest. The
99*3a9fd824SRoger Pau Monné  *             memory map is optional and so guests that understand version 1
100*3a9fd824SRoger Pau Monné  *             of the structure must check that memmap_entries is non-zero
101*3a9fd824SRoger Pau Monné  *             before trying to read the memory map.
102*3a9fd824SRoger Pau Monné  */
103*3a9fd824SRoger Pau Monné #define XEN_HVM_START_MAGIC_VALUE 0x336ec578
104*3a9fd824SRoger Pau Monné 
105*3a9fd824SRoger Pau Monné /*
106*3a9fd824SRoger Pau Monné  * The values used in the type field of the memory map table entries are
107*3a9fd824SRoger Pau Monné  * defined below and match the Address Range Types as defined in the "System
108*3a9fd824SRoger Pau Monné  * Address Map Interfaces" section of the ACPI Specification. Please refer to
109*3a9fd824SRoger Pau Monné  * section 15 in version 6.2 of the ACPI spec: http://uefi.org/specifications
110*3a9fd824SRoger Pau Monné  */
111*3a9fd824SRoger Pau Monné #define XEN_HVM_MEMMAP_TYPE_RAM       1
112*3a9fd824SRoger Pau Monné #define XEN_HVM_MEMMAP_TYPE_RESERVED  2
113*3a9fd824SRoger Pau Monné #define XEN_HVM_MEMMAP_TYPE_ACPI      3
114*3a9fd824SRoger Pau Monné #define XEN_HVM_MEMMAP_TYPE_NVS       4
115*3a9fd824SRoger Pau Monné #define XEN_HVM_MEMMAP_TYPE_UNUSABLE  5
116*3a9fd824SRoger Pau Monné #define XEN_HVM_MEMMAP_TYPE_DISABLED  6
117*3a9fd824SRoger Pau Monné #define XEN_HVM_MEMMAP_TYPE_PMEM      7
118*3a9fd824SRoger Pau Monné 
119*3a9fd824SRoger Pau Monné /*
120*3a9fd824SRoger Pau Monné  * C representation of the x86/HVM start info layout.
121*3a9fd824SRoger Pau Monné  *
122*3a9fd824SRoger Pau Monné  * The canonical definition of this layout is above, this is just a way to
123*3a9fd824SRoger Pau Monné  * represent the layout described there using C types.
124*3a9fd824SRoger Pau Monné  */
125*3a9fd824SRoger Pau Monné struct hvm_start_info {
126*3a9fd824SRoger Pau Monné     uint32_t magic;             /* Contains the magic value 0x336ec578       */
127*3a9fd824SRoger Pau Monné                                 /* ("xEn3" with the 0x80 bit of the "E" set).*/
128*3a9fd824SRoger Pau Monné     uint32_t version;           /* Version of this structure.                */
129*3a9fd824SRoger Pau Monné     uint32_t flags;             /* SIF_xxx flags.                            */
130*3a9fd824SRoger Pau Monné     uint32_t nr_modules;        /* Number of modules passed to the kernel.   */
131*3a9fd824SRoger Pau Monné     uint64_t modlist_paddr;     /* Physical address of an array of           */
132*3a9fd824SRoger Pau Monné                                 /* hvm_modlist_entry.                        */
133*3a9fd824SRoger Pau Monné     uint64_t cmdline_paddr;     /* Physical address of the command line.     */
134*3a9fd824SRoger Pau Monné     uint64_t rsdp_paddr;        /* Physical address of the RSDP ACPI data    */
135*3a9fd824SRoger Pau Monné                                 /* structure.                                */
136*3a9fd824SRoger Pau Monné     /* All following fields only present in version 1 and newer */
137*3a9fd824SRoger Pau Monné     uint64_t memmap_paddr;      /* Physical address of an array of           */
138*3a9fd824SRoger Pau Monné                                 /* hvm_memmap_table_entry.                   */
139*3a9fd824SRoger Pau Monné     uint32_t memmap_entries;    /* Number of entries in the memmap table.    */
140*3a9fd824SRoger Pau Monné                                 /* Value will be zero if there is no memory  */
141*3a9fd824SRoger Pau Monné                                 /* map being provided.                       */
142*3a9fd824SRoger Pau Monné     uint32_t reserved;          /* Must be zero.                             */
143*3a9fd824SRoger Pau Monné };
144*3a9fd824SRoger Pau Monné 
145*3a9fd824SRoger Pau Monné struct hvm_modlist_entry {
146*3a9fd824SRoger Pau Monné     uint64_t paddr;             /* Physical address of the module.           */
147*3a9fd824SRoger Pau Monné     uint64_t size;              /* Size of the module in bytes.              */
148*3a9fd824SRoger Pau Monné     uint64_t cmdline_paddr;     /* Physical address of the command line.     */
149*3a9fd824SRoger Pau Monné     uint64_t reserved;
150*3a9fd824SRoger Pau Monné };
151*3a9fd824SRoger Pau Monné 
152*3a9fd824SRoger Pau Monné struct hvm_memmap_table_entry {
153*3a9fd824SRoger Pau Monné     uint64_t addr;              /* Base address of the memory region         */
154*3a9fd824SRoger Pau Monné     uint64_t size;              /* Size of the memory region in bytes        */
155*3a9fd824SRoger Pau Monné     uint32_t type;              /* Mapping type                              */
156*3a9fd824SRoger Pau Monné     uint32_t reserved;          /* Must be zero for Version 1.               */
157*3a9fd824SRoger Pau Monné };
158*3a9fd824SRoger Pau Monné 
159*3a9fd824SRoger Pau Monné #endif /* __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ */
160