1 /* 2 * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp> 3 * VA Linux Systems Japan K.K. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 #ifndef XC_CORE_H 21 #define XC_CORE_H 22 23 #include "xen/version.h" 24 #include "xg_private.h" 25 #include "xen/libelf/elfstructs.h" 26 27 /* section names */ 28 #define XEN_DUMPCORE_SEC_NOTE ".note.Xen" 29 #define XEN_DUMPCORE_SEC_PRSTATUS ".xen_prstatus" 30 #define XEN_DUMPCORE_SEC_SHARED_INFO ".xen_shared_info" 31 #define XEN_DUMPCORE_SEC_P2M ".xen_p2m" 32 #define XEN_DUMPCORE_SEC_PFN ".xen_pfn" 33 #define XEN_DUMPCORE_SEC_PAGES ".xen_pages" 34 35 /* elf note name */ 36 #define XEN_DUMPCORE_ELFNOTE_NAME "Xen" 37 /* note numbers are defined in xen/elfnote.h */ 38 39 struct elfnote { 40 uint32_t namesz; /* Elf_Note note; */ 41 uint32_t descsz; 42 uint32_t type; 43 char name[4]; /* sizeof("Xen") = 4 44 * Fotunately this is 64bit aligned so that 45 * we can use same structore for both 32/64bit 46 */ 47 }; 48 49 struct xen_dumpcore_elfnote_none_desc { 50 /* nothing */ 51 }; 52 53 struct xen_dumpcore_elfnote_header_desc { 54 uint64_t xch_magic; 55 uint64_t xch_nr_vcpus; 56 uint64_t xch_nr_pages; 57 uint64_t xch_page_size; 58 }; 59 60 struct xen_dumpcore_elfnote_xen_version_desc { 61 uint64_t major_version; 62 uint64_t minor_version; 63 xen_extraversion_t extra_version; 64 xen_compile_info_t compile_info; 65 xen_capabilities_info_t capabilities; 66 xen_changeset_info_t changeset; 67 xen_platform_parameters_t platform_parameters; 68 uint64_t pagesize; 69 }; 70 71 #define XEN_DUMPCORE_FORMAT_VERSION(major, minor) \ 72 ((major) << 32) | ((minor) & 0xffffffff) 73 #define XEN_DUMPCORE_FORMAT_MAJOR(version) ((major) >> 32) 74 #define XEN_DUMPCORE_FORMAT_MINOR(version) ((minor) & 0xffffffff) 75 76 #define XEN_DUMPCORE_FORMAT_MAJOR_CURRENT ((uint64_t)0) 77 #define XEN_DUMPCORE_FORMAT_MINOR_CURRENT ((uint64_t)1) 78 #define XEN_DUMPCORE_FORMAT_VERSION_CURRENT \ 79 XEN_DUMPCORE_FORMAT_VERSION(XEN_DUMPCORE_FORMAT_MAJOR_CURRENT, \ 80 XEN_DUMPCORE_FORMAT_MINOR_CURRENT) 81 82 struct xen_dumpcore_elfnote_format_version_desc { 83 uint64_t version; 84 }; 85 86 87 struct xen_dumpcore_elfnote_none { 88 struct elfnote elfnote; 89 struct xen_dumpcore_elfnote_none_desc none; 90 }; 91 92 struct xen_dumpcore_elfnote_header { 93 struct elfnote elfnote; 94 struct xen_dumpcore_elfnote_header_desc header; 95 }; 96 97 struct xen_dumpcore_elfnote_xen_version { 98 struct elfnote elfnote; 99 struct xen_dumpcore_elfnote_xen_version_desc xen_version; 100 }; 101 102 struct xen_dumpcore_elfnote_format_version { 103 struct elfnote elfnote; 104 struct xen_dumpcore_elfnote_format_version_desc format_version; 105 }; 106 107 #define XC_CORE_INVALID_PFN (~(uint64_t)0) 108 #define XC_CORE_INVALID_GMFN (~(uint64_t)0) 109 struct xen_dumpcore_p2m { 110 uint64_t pfn; 111 uint64_t gmfn; 112 }; 113 114 115 struct xc_core_strtab; 116 struct xc_core_section_headers; 117 118 Elf64_Shdr* 119 xc_core_shdr_get(xc_interface *xch, 120 struct xc_core_section_headers *sheaders); 121 int 122 xc_core_shdr_set(xc_interface *xch, 123 Elf64_Shdr *shdr, 124 struct xc_core_strtab *strtab, 125 const char *name, uint32_t type, 126 uint64_t offset, uint64_t size, 127 uint64_t addralign, uint64_t entsize); 128 129 struct xc_core_memory_map { 130 uint64_t addr; 131 uint64_t size; 132 }; 133 typedef struct xc_core_memory_map xc_core_memory_map_t; 134 struct xc_core_arch_context; 135 int xc_core_arch_memory_map_get(xc_interface *xch, 136 struct xc_core_arch_context *arch_ctxt, 137 xc_domaininfo_t *info, shared_info_any_t *live_shinfo, 138 xc_core_memory_map_t **mapp, 139 unsigned int *nr_entries); 140 int xc_core_arch_map_p2m(xc_interface *xch, struct domain_info_context *dinfo, 141 xc_domaininfo_t *info, shared_info_any_t *live_shinfo, 142 xen_pfn_t **live_p2m); 143 144 int xc_core_arch_map_p2m_writable(xc_interface *xch, struct domain_info_context *dinfo, 145 xc_domaininfo_t *info, 146 shared_info_any_t *live_shinfo, 147 xen_pfn_t **live_p2m); 148 149 int xc_core_arch_get_scratch_gpfn(xc_interface *xch, uint32_t domid, 150 xen_pfn_t *gpfn); 151 152 153 #if defined (__i386__) || defined (__x86_64__) 154 # include "xg_core_x86.h" 155 #elif defined (__arm__) || defined(__aarch64__) 156 # include "xg_core_arm.h" 157 #else 158 # error "unsupported architecture" 159 #endif 160 161 #ifndef ELF_CORE_EFLAGS 162 # define ELF_CORE_EFLAGS 0 163 #endif 164 165 #endif /* XC_CORE_H */ 166 167 /* 168 * Local variables: 169 * mode: C 170 * c-file-style: "BSD" 171 * c-basic-offset: 4 172 * tab-width: 4 173 * indent-tabs-mode: nil 174 * End: 175 */ 176