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