diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2012-09-12 17:55:27 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2012-09-12 17:55:27 +0100 |
commit | e567964a54b854354492a90d4d2c1e9541e4901d (patch) | |
tree | 6bee1a782c03463d08fa0e75fca418ae9dbe135f /tools/libxc | |
parent | 2fcb3c6fc7ed6f5a5f96aed63b6b6d3a19a3fafc (diff) | |
download | xen-e567964a54b854354492a90d4d2c1e9541e4901d.tar.gz xen-e567964a54b854354492a90d4d2c1e9541e4901d.tar.bz2 xen-e567964a54b854354492a90d4d2c1e9541e4901d.zip |
tools: drop ia64 support
Removed support from libxc and mini-os.
This also took me under xen/include/public via various symlinks.
Dropped tools/debugger/xenitp entirely, it was described upon commit
as:
"Xenitp is a low-level debugger for ia64" and doesn't appear to be
linked into the build anywhere.
99 files changed, 14 insertions(+), 32361 deletions(-)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxc')
-rw-r--r-- | tools/libxc/Makefile | 2 | ||||
-rw-r--r-- | tools/libxc/ia64/Makefile | 50 | ||||
-rw-r--r-- | tools/libxc/ia64/ac_ia64_tools.h | 46 | ||||
-rw-r--r-- | tools/libxc/ia64/dom_fw_acpi.c | 45 | ||||
-rw-r--r-- | tools/libxc/ia64/sal.h | 85 | ||||
-rw-r--r-- | tools/libxc/ia64/xc_dom_ia64_util.c | 196 | ||||
-rw-r--r-- | tools/libxc/ia64/xc_dom_ia64_util.h | 46 | ||||
-rw-r--r-- | tools/libxc/ia64/xc_ia64.h | 58 | ||||
-rw-r--r-- | tools/libxc/ia64/xc_ia64_dom_fwloader.c | 142 | ||||
-rw-r--r-- | tools/libxc/ia64/xc_ia64_hvm_build.c | 1215 | ||||
-rw-r--r-- | tools/libxc/ia64/xc_ia64_linux_restore.c | 739 | ||||
-rw-r--r-- | tools/libxc/ia64/xc_ia64_linux_save.c | 801 | ||||
-rw-r--r-- | tools/libxc/ia64/xc_ia64_save_restore.h | 47 | ||||
-rw-r--r-- | tools/libxc/ia64/xc_ia64_stubs.c | 282 | ||||
-rw-r--r-- | tools/libxc/xc_core.c | 4 | ||||
-rw-r--r-- | tools/libxc/xc_core.h | 4 | ||||
-rw-r--r-- | tools/libxc/xc_core_ia64.c | 380 | ||||
-rw-r--r-- | tools/libxc/xc_core_ia64.h | 70 | ||||
-rw-r--r-- | tools/libxc/xc_dom_boot.c | 2 | ||||
-rw-r--r-- | tools/libxc/xc_dom_elfloader.c | 2 | ||||
-rw-r--r-- | tools/libxc/xc_dom_ia64.c | 334 | ||||
-rw-r--r-- | tools/libxc/xc_minios.c | 20 | ||||
-rw-r--r-- | tools/libxc/xenctrl.h | 19 |
23 files changed, 5 insertions, 4584 deletions
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index ca38cbd6e3..441ba4d940 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -7,7 +7,6 @@ MINOR = 0 CTRL_SRCS-y := CTRL_SRCS-y += xc_core.c CTRL_SRCS-$(CONFIG_X86) += xc_core_x86.c -CTRL_SRCS-$(CONFIG_IA64) += xc_core_ia64.c CTRL_SRCS-$(CONFIG_ARM) += xc_core_arm.c CTRL_SRCS-y += xc_cpupool.c CTRL_SRCS-y += xc_domain.c @@ -65,7 +64,6 @@ GUEST_SRCS-y += xc_dom_compat_linux.c GUEST_SRCS-$(CONFIG_X86) += xc_dom_x86.c GUEST_SRCS-$(CONFIG_X86) += xc_cpuid_x86.c GUEST_SRCS-$(CONFIG_X86) += xc_hvm_build_x86.c -GUEST_SRCS-$(CONFIG_IA64) += xc_dom_ia64.c GUEST_SRCS-$(CONFIG_ARM) += xc_dom_arm.c GUEST_SRCS-$(CONFIG_ARM) += xc_hvm_build_arm.c diff --git a/tools/libxc/ia64/Makefile b/tools/libxc/ia64/Makefile deleted file mode 100644 index 81f472a78d..0000000000 --- a/tools/libxc/ia64/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -ifneq ($(stubdom),y) -CTRL_SRCS-y += ia64/xc_ia64_stubs.c - -GUEST_SRCS-y += ia64/xc_ia64_hvm_build.c -GUEST_SRCS-y += ia64/xc_ia64_linux_save.c -GUEST_SRCS-y += ia64/xc_ia64_linux_restore.c - -GUEST_SRCS-y += ia64/xc_dom_ia64_util.c -GUEST_SRCS-y += ia64/dom_fw_acpi.c - -GUEST_SRCS-y += ia64/xc_ia64_dom_fwloader.c - -DOMFW_SRCS_BASE := dom_fw_common.c dom_fw_domu.c dom_fw_asm.S -endif -DOMFW_SRCS := $(addprefix ia64/, $(DOMFW_SRCS_BASE)) -$(DOMFW_SRCS): - ln -sf $(XEN_ROOT)/xen/arch/ia64/xen/$(@F) $@ - -GUEST_SRCS-y += $(patsubst %.S, %.c, $(DOMFW_SRCS)) - -CFLAGS += -Iia64 - -DOMFW_ASM_HDRS_BASE := bundle.h dom_fw.h dom_fw_common.h dom_fw_domu.h -DOMFW_ASM_HDRS := $(addprefix ia64/asm/, $(DOMFW_ASM_HDRS_BASE)) -$(DOMFW_ASM_HDRS): ia64/asm - ln -sf $(XEN_ROOT)/xen/include/asm-ia64/$(@F) $@ -build: $(DOMFW_ASM_HDR) - -.PHONY: mk-symlinks-acpi mk-symlinks-misc ia64-clean - -IA64_HDR_DIRS := ia64/asm ia64/xen ia64/acpi ia64/acpi/platform -$(IA64_HDR_DIRS): - mkdir -p $@ - -IA64_EMPTY_FILES := ia64/asm/acpi.h ia64/xen/list.h -$(IA64_EMPTY_FILES): $(IA64_HDR_DIRS) - echo "/* automatically created dummy empty header file. */" > $@ - -mk-symlinks-acpi: $(IA64_HDR_DIRS) $(IA64_EMPTY_FILES) $(DOMFW_ASM_HDRS) - ( cd ia64/acpi && ln -sf $(XEN_ROOT)/xen/include/acpi/*.h .) - ( cd ia64/acpi/platform && ln -sf $(XEN_ROOT)/xen/include/acpi/platform/*.h .) - ( cd ia64/xen && ln -sf $(XEN_ROOT)/xen/include/xen/acpi.h .) -mk-symlinks-misc: $(IA64_HDR_DIRS) - ( cd ia64/asm && ln -sf $(XEN_ROOT)/xen/include/asm-ia64/linux-xen/asm/kregs.h .) - ( cd ia64/asm && ln -sf $(XEN_ROOT)/xen/include/asm-ia64/linux/asm/fpswa.h .) -build: mk-symlinks-acpi mk-symlinks-misc - -clean: ia64-clean -ia64-clean: - rm -rf $(DOMFW_SRCS) $(DOMFW_ASM_HDRS) $(IA64_EMPTY_FILES) $(IA64_HDR_DIRS) diff --git a/tools/libxc/ia64/ac_ia64_tools.h b/tools/libxc/ia64/ac_ia64_tools.h deleted file mode 100644 index 658ab33505..0000000000 --- a/tools/libxc/ia64/ac_ia64_tools.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ac_ia64_tools.h - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef AC_IA64_TOOLS_H -#define AC_IA64_TOOLS_H - -#define ACPI_MACHINE_WIDTH 64 -#define COMPILER_DEPENDENT_UINT64 unsigned long long -#define COMPILER_DEPENDENT_INT64 long long -typedef unsigned long long u64; -typedef long long s64; -typedef unsigned u32; -typedef int s32; -typedef unsigned char u8; -typedef unsigned short u16; -#define __iomem -#define asmlinkage -#define CONFIG_ACPI_BOOT - -#endif /* AC_IA64_TOOLS_H */ - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/ia64/dom_fw_acpi.c b/tools/libxc/ia64/dom_fw_acpi.c deleted file mode 100644 index 5ac9b527a9..0000000000 --- a/tools/libxc/ia64/dom_fw_acpi.c +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * - * FUNCTION: acpi_tb_checksum - * - * PARAMETERS: Buffer - Pointer to memory region to be checked - * Length - Length of this memory region - * - * RETURN: Checksum (u8) - * - * DESCRIPTION: Calculates circular checksum of memory region. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - ******************************************************************************/ - -/* stolen from xen/drivers/acpi/tables/tbutils.c */ - -#include <inttypes.h> -#include "xc_dom_ia64_util.h" -#include <xen/acpi.h> -#include <acpi/actables.h> - -u8 acpi_tb_checksum(u8 * buffer, acpi_native_uint length) -{ - u8 sum = 0; - u8 *end = buffer + length; - - while (buffer < end) { - sum = (u8) (sum + *(buffer++)); - } - - return sum; -} diff --git a/tools/libxc/ia64/sal.h b/tools/libxc/ia64/sal.h deleted file mode 100644 index 6ed475e863..0000000000 --- a/tools/libxc/ia64/sal.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * definitions from - * xen/include/asm-ia64/linux/asm/sal.h - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XC_IA64_SAL_H -#define XC_IA64_SAL_H - -/* - * The SAL system table is followed by a variable number of variable - * length descriptors. The structure of these descriptors follows - * below. - * The defininition follows SAL specs from July 2000 - */ -struct ia64_sal_systab { - uint8_t signature[4]; /* should be "SST_" */ - uint32_t size; /* size of this table in bytes */ - uint8_t sal_rev_minor; - uint8_t sal_rev_major; - uint16_t entry_count; /* # of entries in variable portion */ - uint8_t checksum; - uint8_t reserved1[7]; - uint8_t sal_a_rev_minor; - uint8_t sal_a_rev_major; - uint8_t sal_b_rev_minor; - uint8_t sal_b_rev_major; - /* oem_id & product_id: terminating NUL is missing if string is exactly 32 bytes long. */ - uint8_t oem_id[32]; - uint8_t product_id[32]; /* ASCII product id */ - uint8_t reserved2[8]; -}; - -enum sal_systab_entry_type { - SAL_DESC_ENTRY_POINT = 0, - SAL_DESC_MEMORY = 1, - SAL_DESC_PLATFORM_FEATURE = 2, - SAL_DESC_TR = 3, - SAL_DESC_PTC = 4, - SAL_DESC_AP_WAKEUP = 5 -}; - -typedef struct ia64_sal_desc_entry_point { - uint8_t type; - uint8_t reserved1[7]; - uint64_t pal_proc; - uint64_t sal_proc; - uint64_t gp; - uint8_t reserved2[16]; -}ia64_sal_desc_entry_point_t; - -#define IA64_SAL_AP_EXTERNAL_INT 0 - -typedef struct ia64_sal_desc_ap_wakeup { - uint8_t type; - uint8_t mechanism; /* 0 == external interrupt */ - uint8_t reserved1[6]; - uint64_t vector; /* interrupt vector in range 0x10-0xff */ -} ia64_sal_desc_ap_wakeup_t ; - -//XXX should move xen_sal_data to arch-ia64.h? -/* These are data in domain memory for SAL emulator. */ -struct xen_sal_data { - /* OS boot rendez vous. */ - unsigned long boot_rdv_ip; - unsigned long boot_rdv_r1; - - /* There are these for EFI_SET_VIRTUAL_ADDRESS_MAP emulation. */ - int efi_virt_mode; /* phys : 0 , virt : 1 */ -}; - -#endif /* XC_IA64_SAL_H */ diff --git a/tools/libxc/ia64/xc_dom_ia64_util.c b/tools/libxc/ia64/xc_dom_ia64_util.c deleted file mode 100644 index bc83dbb841..0000000000 --- a/tools/libxc/ia64/xc_dom_ia64_util.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp> - * VA Linux Systems Japan K.K. - * - */ - -#include <assert.h> -#include "xg_private.h" -#include "xc_dom.h" -#include "asm/dom_fw.h" -#include "asm/dom_fw_common.h" -#include "ia64/xc_dom_ia64_util.h" - -uint32_t -xen_ia64_version(struct xc_dom_image *dom) -{ - return xc_version(dom->xch, XENVER_version, NULL); -} - -int -xen_ia64_fpswa_revision(struct xc_dom_image *dom, unsigned int *revision) -{ - int ret; - DECLARE_HYPERCALL; - DECLARE_HYPERCALL_BOUNCE(revision, sizeof(*revision), XC_HYPERCALL_BUFFER_BOUNCE_BOTH); - - if (xc_hypercall_bounce_pre(dom->xch, revision) ) - { - PERROR("Could not lock memory for xen fpswa hypercall"); - return -1; - } - - hypercall.op = __HYPERVISOR_ia64_dom0vp_op; - hypercall.arg[0] = IA64_DOM0VP_fpswa_revision; - hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(revision); - - ret = do_xen_hypercall(dom->xch, &hypercall); - - xc_hypercall_bounce_post(dom->xch, revision); - - return ret; -} - -int xen_ia64_is_running_on_sim(struct xc_dom_image *dom) -{ - /* - * This is only used by dom_fw_init() as - * "!xen_ia64_is_dom0() || xen_ia64_is_running_on_sim()". - * So this doesn't affect the result. - */ - return 0; -} - -int -xen_ia64_is_dom0(struct xc_dom_image *unused) -{ - /* libxc is for non-dom0 domain builder */ - return 0; -} - -void* -xen_ia64_dom_fw_map(struct xc_dom_image *dom, unsigned long mpaddr) -{ - unsigned long page_size = XC_DOM_PAGE_SIZE(dom); - void* ret; - - ret = xc_map_foreign_range(dom->xch, dom->guest_domid, - page_size, PROT_READ | PROT_WRITE, - mpaddr / page_size); - if (ret != NULL) - ret = (void*)((unsigned long)ret | (mpaddr & (page_size - 1))); - - return ret; -} - -void -xen_ia64_dom_fw_unmap(struct xc_dom_image *dom, void *vaddr) -{ - unsigned long page_size = XC_DOM_PAGE_SIZE(dom); - munmap((void*)((unsigned long)vaddr & ~(page_size - 1)), page_size); -} - -int -xen_ia64_is_vcpu_allocated(struct xc_dom_image *dom, uint32_t vcpu) -{ - // return d->vcpu[vcpu] != NULL; - - int rc; - xc_vcpuinfo_t info; - xc_interface *xch = dom->xch; - - rc = xc_vcpu_getinfo(xch, dom->guest_domid, - vcpu, &info); - if (rc == 0) - return 1; - - if (errno != ESRCH) - PERROR("Could not get vcpu info"); - return 0; -} - -int -xen_ia64_dom_fw_setup(struct xc_dom_image *d, uint64_t brkimm, - unsigned long bp_mpa, unsigned long maxmem) -{ - int rc = 0; - void *imva_hypercall_base = NULL; - struct fw_tables *fw_tables = NULL; - struct fake_acpi_tables *imva = NULL; - struct xen_ia64_boot_param *bp = NULL; - - BUILD_BUG_ON(sizeof(struct fw_tables) > - (FW_TABLES_END_PADDR_MIN - FW_TABLES_BASE_PADDR)); - - /* Create page for hypercalls. */ - imva_hypercall_base = xen_ia64_dom_fw_map(d, FW_HYPERCALL_BASE_PADDR); - if (imva_hypercall_base == NULL) { - rc = -errno; - goto out; - } - - /* Create page for FW tables. */ - fw_tables = (struct fw_tables*)xen_ia64_dom_fw_map(d, FW_TABLES_BASE_PADDR); - if (fw_tables == NULL) { - rc = -errno; - goto out; - } - memset(fw_tables, 0, FW_TABLES_END_PADDR_MIN - FW_TABLES_BASE_PADDR); - BUILD_BUG_ON(FW_END_PADDR_MIN != FW_TABLES_END_PADDR_MIN); - fw_tables->fw_tables_size = FW_TABLES_END_PADDR_MIN - FW_TABLES_BASE_PADDR; - fw_tables->fw_end_paddr = FW_END_PADDR_MIN; - fw_tables->fw_tables_end_paddr = FW_TABLES_END_PADDR_MIN; - fw_tables->num_mds = 0; - - /* Create page for acpi tables. */ - imva = (struct fake_acpi_tables *) - xen_ia64_dom_fw_map(d, FW_ACPI_BASE_PADDR); - if (imva == NULL) { - rc = -errno; - goto out; - } - dom_fw_fake_acpi(d, imva); - - /* Create page for boot_param. */ - bp = xen_ia64_dom_fw_map(d, bp_mpa); - if (bp == NULL) { - rc = -errno; - goto out; - } - rc = dom_fw_init(d, brkimm, bp, fw_tables, - (unsigned long)imva_hypercall_base, maxmem); - BUG_ON(fw_tables->fw_tables_size < sizeof(*fw_tables) + - sizeof(fw_tables->efi_memmap[0]) * fw_tables->num_mds); - - /* clear domain builder internal use member */ - fw_tables->fw_tables_size = 0; - fw_tables->fw_end_paddr = 0; - fw_tables->fw_tables_end_paddr = 0; - fw_tables->num_mds = 0; - - out: - if (imva_hypercall_base != NULL) - xen_ia64_dom_fw_unmap(d, imva_hypercall_base); - if (fw_tables != NULL) - xen_ia64_dom_fw_unmap(d, fw_tables); - if (imva != NULL) - xen_ia64_dom_fw_unmap(d, imva); - if (bp != NULL) - xen_ia64_dom_fw_unmap(d, bp); - - return rc; -} - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/ia64/xc_dom_ia64_util.h b/tools/libxc/ia64/xc_dom_ia64_util.h deleted file mode 100644 index 82082ad5a8..0000000000 --- a/tools/libxc/ia64/xc_dom_ia64_util.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XC_IA64_DOM_IA64_UTIL_H -#define XC_IA64_DOM_IA64_UTIL_H - -struct xc_dom_image; -uint32_t xen_ia64_version(struct xc_dom_image *dom); -void* xen_ia64_dom_fw_map(struct xc_dom_image *dom, unsigned long mpaddr); -void xen_ia64_dom_fw_unmap(struct xc_dom_image *dom, void *addr); -int xen_ia64_fpswa_revision(struct xc_dom_image *dom, unsigned int *revision); -int xen_ia64_is_vcpu_allocated(struct xc_dom_image *dom, uint32_t vcpu); -int xen_ia64_is_running_on_sim(struct xc_dom_image *dom); -int xen_ia64_is_dom0(struct xc_dom_image *dom); - -int -xen_ia64_dom_fw_setup(struct xc_dom_image *d, uint64_t brkimm, - unsigned long bp_mpa, unsigned long maxmem); -#define efi_systable_init_dom0(tables) assert(0) -#define complete_dom0_memmap(d, tables) ({assert(0);0;}) - -/* Defined in xc_dom_ia64.c */ -extern int start_info_ia64(struct xc_dom_image *dom); -extern int shared_info_ia64(struct xc_dom_image *dom, void *ptr); - -#define FW_MEM_BASE 0xff000000UL -#define FW_MEM_SIZE 0x01000000UL - -#ifdef __XEN_TOOLS__ -/* Necessary for including the acpi header chain when not in kernel context */ -typedef struct { } spinlock_t; -#endif -#endif /* XC_IA64_DOM_IA64_UTIL_H */ diff --git a/tools/libxc/ia64/xc_ia64.h b/tools/libxc/ia64/xc_ia64.h deleted file mode 100644 index faf3376af8..0000000000 --- a/tools/libxc/ia64/xc_ia64.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp> - * VA Linux Systems Japan K.K. - * - */ - -#ifndef _XC_IA64_H_ -#define _XC_IA64_H_ - -int xc_ia64_copy_memmap(xc_interface *xc_handle, uint32_t domid, - shared_info_t *live_shinfo, - xen_ia64_memmap_info_t **memmap_info_p, - unsigned long *memmap_info_num_pages_p); - -struct xen_ia64_p2m_table { - unsigned long size; - unsigned long *p2m; -}; - -void xc_ia64_p2m_init(struct xen_ia64_p2m_table *p2m_table); -int xc_ia64_p2m_map(struct xen_ia64_p2m_table *p2m_table, xc_interface *xc_handle, - uint32_t domid, struct xen_ia64_memmap_info *memmap_info, - unsigned long flag); -void xc_ia64_p2m_unmap(struct xen_ia64_p2m_table *p2m_table); -int xc_ia64_p2m_present(struct xen_ia64_p2m_table *p2m_table, - unsigned long gpfn); -int xc_ia64_p2m_allocated(struct xen_ia64_p2m_table *p2m_table, - unsigned long gpfn); - -unsigned long xc_ia64_p2m_mfn(struct xen_ia64_p2m_table *p2m_table, - unsigned long gpfn); - - -#endif /* _XC_IA64_H_ */ - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/ia64/xc_ia64_dom_fwloader.c b/tools/libxc/ia64/xc_ia64_dom_fwloader.c deleted file mode 100644 index cdf3333e9d..0000000000 --- a/tools/libxc/ia64/xc_ia64_dom_fwloader.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <inttypes.h> -#include <asm/kregs.h> - -#include <xen/xen.h> -#include <xen/foreign/ia64.h> -#include <xen/io/protocols.h> - -#include "xg_private.h" -#include "xc_dom.h" - -#include "ia64/xc_dom_ia64_util.h" - -static const char fw_magic[16] = {'X', 'e', 'n', '-', - 'i', 'a', '6', '4', - '-', 'f', 'w', 0, - 0, 0, 0, 0}; -#define FW_LOAD 0xff800000UL -#define FW_SIZE (8 * 1024 * 1024) - -static int xc_dom_probe_fw_kernel(struct xc_dom_image *dom) -{ - if (dom->kernel_size != FW_SIZE) - return -EINVAL; - if (memcmp (dom->kernel_blob, fw_magic, sizeof (fw_magic))) - return -EINVAL; - return 0; -} - -static int xc_dom_parse_fw_kernel(struct xc_dom_image *dom) -{ - dom->kernel_seg.vstart = FW_LOAD; - dom->kernel_seg.vend = FW_LOAD + FW_SIZE; - dom->parms.virt_base = FW_MEM_BASE; - dom->parms.virt_entry = FW_LOAD + sizeof (fw_magic); - dom->ramdisk_blob = NULL; /* No ramdisk yet. */ - dom->guest_type = "hvm-3.0-ia64-sioemu"; - return 0; -} - -static int xc_dom_load_fw_kernel(struct xc_dom_image *dom) -{ - char *dest; - unsigned long i; - - dest = xc_dom_vaddr_to_ptr(dom, dom->kernel_seg.vstart); - memcpy(dest, dom->kernel_blob, FW_SIZE); - - /* Synchronize cache. */ - for (i = 0; i < FW_SIZE; i += 32) - asm volatile ("fc.i %0" :: "r"(dest + i) : "memory"); - - return 0; -} - -/* ------------------------------------------------------------------------ */ - -static int alloc_magic_pages(struct xc_dom_image *dom) -{ - /* allocate special pages */ - /* Note: do not use 0 for console or xenstore otherwise clear_page won't - clear the page. */ - dom->start_info_pfn = 0; - dom->console_pfn = 1; - dom->xenstore_pfn = 2; - return 0; -} - -extern unsigned long xc_ia64_fpsr_default(void); - -static int vcpu_ia64(struct xc_dom_image *dom, void *ptr) -{ - vcpu_guest_context_ia64_t *ctxt = ptr; - - DOMPRINTF_CALLED(dom->xch); - - /* clear everything */ - memset(ctxt, 0, sizeof(*ctxt)); - - ctxt->flags = 0; - ctxt->regs.ip = dom->parms.virt_entry; -#ifdef __ia64__ /* FIXME */ - ctxt->regs.ar.fpsr = xc_ia64_fpsr_default(); -#endif - ctxt->regs.cr.isr = 1UL << 63; - ctxt->regs.psr = IA64_PSR_AC | IA64_PSR_BN; - ctxt->regs.cr.dcr = 0; - ctxt->regs.cr.pta = 15 << 2; - - return 0; -} - -static struct xc_dom_arch xc_dom_arch_ia64_fw = { - .guest_type = "hvm-3.0-ia64-sioemu", - .native_protocol = XEN_IO_PROTO_ABI_IA64, - .page_shift = PAGE_SHIFT_IA64, - .alloc_magic_pages = alloc_magic_pages, - .start_info = start_info_ia64, - .shared_info = shared_info_ia64, - .vcpu = vcpu_ia64, -}; - -/* ------------------------------------------------------------------------ */ - -static struct xc_dom_loader fw_loader = { - .name = "xen-ia64-fw", - .probe = xc_dom_probe_fw_kernel, - .parser = xc_dom_parse_fw_kernel, - .loader = xc_dom_load_fw_kernel, -}; - -static void __init register_fwloader(void) -{ - xc_dom_register_arch_hooks(&xc_dom_arch_ia64_fw); - xc_dom_register_loader(&fw_loader); -} - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/ia64/xc_ia64_hvm_build.c b/tools/libxc/ia64/xc_ia64_hvm_build.c deleted file mode 100644 index 3f9273fa0f..0000000000 --- a/tools/libxc/ia64/xc_ia64_hvm_build.c +++ /dev/null @@ -1,1215 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <asm/kregs.h> -#include "xg_private.h" -#include "xenguest.h" -#include "xc_private.h" -#include "xc_elf.h" -#include "xc_efi.h" -#include <stdlib.h> -#include <unistd.h> -#include <assert.h> -#include <zlib.h> -#include "xen/arch-ia64.h" -#include <xen/hvm/ioreq.h> -#include <xen/hvm/params.h> - -static int -xc_ia64_copy_to_domain_pages(xc_interface *xch, uint32_t domid, void* src_page, - unsigned long dst_pfn, int nr_pages) -{ - // N.B. gva should be page aligned - int i; - - for (i = 0; i < nr_pages; i++) { - if (xc_copy_to_domain_page(xch, domid, dst_pfn + i, - src_page + (i << PAGE_SHIFT))) - return -1; - } - - return 0; -} - -#define HOB_SIGNATURE 0x3436474953424f48 // "HOBSIG64" -#define GFW_HOB_START ((4UL<<30)-(14UL<<20)) // 4G - 14M -#define GFW_HOB_SIZE (1UL<<20) // 1M - -typedef struct { - unsigned long signature; - unsigned int type; - unsigned int length; -} HOB_GENERIC_HEADER; - -/* - * INFO HOB is the first data data in one HOB list - * it contains the control information of the HOB list - */ -typedef struct { - HOB_GENERIC_HEADER header; - unsigned long length; // current length of hob - unsigned long cur_pos; // current poisiton of hob - unsigned long buf_size; // size of hob buffer -} HOB_INFO; - -typedef struct{ - unsigned long start; - unsigned long size; -} hob_mem_t; - -typedef enum { - HOB_TYPE_INFO=0, - HOB_TYPE_TERMINAL, - HOB_TYPE_MEM, - HOB_TYPE_PAL_BUS_GET_FEATURES_DATA, - HOB_TYPE_PAL_CACHE_SUMMARY, - HOB_TYPE_PAL_MEM_ATTRIB, - HOB_TYPE_PAL_CACHE_INFO, - HOB_TYPE_PAL_CACHE_PROT_INFO, - HOB_TYPE_PAL_DEBUG_INFO, - HOB_TYPE_PAL_FIXED_ADDR, - HOB_TYPE_PAL_FREQ_BASE, - HOB_TYPE_PAL_FREQ_RATIOS, - HOB_TYPE_PAL_HALT_INFO, - HOB_TYPE_PAL_PERF_MON_INFO, - HOB_TYPE_PAL_PROC_GET_FEATURES, - HOB_TYPE_PAL_PTCE_INFO, - HOB_TYPE_PAL_REGISTER_INFO, - HOB_TYPE_PAL_RSE_INFO, - HOB_TYPE_PAL_TEST_INFO, - HOB_TYPE_PAL_VM_SUMMARY, - HOB_TYPE_PAL_VM_INFO, - HOB_TYPE_PAL_VM_PAGE_SIZE, - HOB_TYPE_NR_VCPU, - HOB_TYPE_NVRAM, - HOB_TYPE_MAX -} hob_type_t; - -static int hob_init(void *buffer ,unsigned long buf_size); -static int add_pal_hob(void* hob_buf); -static int add_mem_hob(void* hob_buf, unsigned long dom_mem_size); -static int add_vcpus_hob(void* hob_buf, unsigned long nr_vcpu); -static int add_nvram_hob(void* hob_buf, unsigned long nvram_addr); -static int build_hob(xc_interface *xch, - void* hob_buf, unsigned long hob_buf_size, - unsigned long dom_mem_size, unsigned long vcpus, - unsigned long nvram_addr); -static int load_hob(xc_interface *xch,uint32_t dom, void *hob_buf); - -static int -xc_ia64_build_hob(xc_interface *xch, uint32_t dom, - unsigned long memsize, unsigned long vcpus, - unsigned long nvram_addr) -{ - char *hob_buf; - - hob_buf = malloc(GFW_HOB_SIZE); - if (hob_buf == NULL) { - PERROR("Could not allocate hob"); - return -1; - } - - if (build_hob(xch, hob_buf, GFW_HOB_SIZE, memsize, vcpus, nvram_addr) < 0) { - free(hob_buf); - PERROR("Could not build hob"); - return -1; - } - - if (load_hob(xch, dom, hob_buf) < 0) { - free(hob_buf); - PERROR("Could not load hob"); - return -1; - } - free(hob_buf); - return 0; - -} - -static int -hob_init(void *buffer, unsigned long buf_size) -{ - HOB_INFO *phit; - HOB_GENERIC_HEADER *terminal; - - if (sizeof(HOB_INFO) + sizeof(HOB_GENERIC_HEADER) > buf_size) { - // buffer too small - return -1; - } - - phit = (HOB_INFO*)buffer; - phit->header.signature = HOB_SIGNATURE; - phit->header.type = HOB_TYPE_INFO; - phit->header.length = sizeof(HOB_INFO); - phit->length = sizeof(HOB_INFO) + sizeof(HOB_GENERIC_HEADER); - phit->cur_pos = 0; - phit->buf_size = buf_size; - - terminal = (HOB_GENERIC_HEADER*)(buffer + sizeof(HOB_INFO)); - terminal->signature = HOB_SIGNATURE; - terminal->type = HOB_TYPE_TERMINAL; - terminal->length = sizeof(HOB_GENERIC_HEADER); - - return 0; -} - -/* - * Add a new HOB to the HOB List. - * - * hob_start - start address of hob buffer - * type - type of the hob to be added - * data - data of the hob to be added - * data_size - size of the data - */ -static int -hob_add(void* hob_start, int type, void* data, int data_size) -{ - HOB_INFO *phit; - HOB_GENERIC_HEADER *newhob, *tail; - - phit = (HOB_INFO*)hob_start; - - if (phit->length + data_size > phit->buf_size) { - // no space for new hob - return -1; - } - - //append new HOB - newhob = (HOB_GENERIC_HEADER*)(hob_start + phit->length - - sizeof(HOB_GENERIC_HEADER)); - newhob->signature = HOB_SIGNATURE; - newhob->type = type; - newhob->length = data_size + sizeof(HOB_GENERIC_HEADER); - memcpy((void*)newhob + sizeof(HOB_GENERIC_HEADER), data, data_size); - - // append terminal HOB - tail = (HOB_GENERIC_HEADER*)(hob_start + phit->length + data_size); - tail->signature = HOB_SIGNATURE; - tail->type = HOB_TYPE_TERMINAL; - tail->length = sizeof(HOB_GENERIC_HEADER); - - // adjust HOB list length - phit->length += sizeof(HOB_GENERIC_HEADER) + data_size; - - return 0; -} - -static int -get_hob_size(xc_interface *xch, void* hob_buf) -{ - HOB_INFO *phit = (HOB_INFO*)hob_buf; - - if (phit->header.signature != HOB_SIGNATURE) { - PERROR("xc_get_hob_size:Incorrect signature"); - return -1; - } - return phit->length; -} - -static int -build_hob(xc_interface *xch, void* hob_buf, unsigned long hob_buf_size, - unsigned long dom_mem_size, unsigned long vcpus, - unsigned long nvram_addr) -{ - //Init HOB List - if (hob_init(hob_buf, hob_buf_size) < 0) { - PERROR("buffer too small"); - goto err_out; - } - - if (add_mem_hob(hob_buf,dom_mem_size) < 0) { - PERROR("Add memory hob failed, buffer too small"); - goto err_out; - } - - if (add_vcpus_hob(hob_buf, vcpus) < 0) { - PERROR("Add NR_VCPU hob failed, buffer too small"); - goto err_out; - } - - if (add_pal_hob( hob_buf ) < 0) { - PERROR("Add PAL hob failed, buffer too small"); - goto err_out; - } - - if (add_nvram_hob( hob_buf, nvram_addr ) < 0) { - PERROR("Add nvram hob failed, buffer too small"); - goto err_out; - } - - return 0; - -err_out: - return -1; -} - -static int -load_hob(xc_interface *xch, uint32_t dom, void *hob_buf) -{ - // hob_buf should be page aligned - int hob_size; - int nr_pages; - - hob_size = get_hob_size(xch, hob_buf); - if (hob_size < 0) { - PERROR("Invalid hob data"); - return -1; - } - - if (hob_size > GFW_HOB_SIZE) { - PERROR("No enough memory for hob data"); - return -1; - } - - nr_pages = (hob_size + PAGE_SIZE -1) >> PAGE_SHIFT; - - return xc_ia64_copy_to_domain_pages(xch, dom, hob_buf, - GFW_HOB_START >> PAGE_SHIFT, nr_pages); -} - -#define MIN(x, y) (((x) < (y)) ? (x) : (y)) -static int -add_mem_hob(void* hob_buf, unsigned long dom_mem_size) -{ - hob_mem_t memhob; - - // less than 3G accounting VGA RAM hole - memhob.start = 0; - if (dom_mem_size < VGA_IO_START) - memhob.size = dom_mem_size; - else - memhob.size = MIN(dom_mem_size + VGA_IO_SIZE, 0xC0000000); - - if (hob_add(hob_buf, HOB_TYPE_MEM, &memhob, sizeof(memhob)) < 0) - return -1; - - if (dom_mem_size > 0xC0000000) { - // 4G ~ 4G+remain - memhob.start = 0x100000000; //4G - memhob.size = dom_mem_size + VGA_IO_SIZE - 0xC0000000; - if (hob_add(hob_buf, HOB_TYPE_MEM, &memhob, sizeof(memhob)) < 0) - return -1; - } - return 0; -} - -static int -add_vcpus_hob(void* hob_buf, unsigned long vcpus) -{ - return hob_add(hob_buf, HOB_TYPE_NR_VCPU, &vcpus, sizeof(vcpus)); -} - -static int -add_nvram_hob(void *hob_buf, unsigned long nvram_addr) -{ - return hob_add(hob_buf, HOB_TYPE_NVRAM, &nvram_addr, sizeof(nvram_addr)); -} - -static const unsigned char config_pal_bus_get_features_data[24] = { - 0, 0, 0, 32, 0, 0, 240, 189, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_cache_summary[16] = { - 3, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_mem_attrib[8] = { - 241, 0, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_cache_info[152] = { - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 6, 4, 6, 7, 255, 1, 0, 1, 0, 64, 0, 0, 12, 12, - 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 7, 0, 1, - 0, 1, 0, 64, 0, 0, 12, 12, 49, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 8, 7, 7, 255, 7, 0, 11, 0, 0, 16, 0, - 12, 17, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 8, 7, - 7, 7, 5, 9, 11, 0, 0, 4, 0, 12, 15, 49, 0, 254, 255, - 255, 255, 255, 255, 255, 255, 2, 8, 7, 7, 7, 5, 9, - 11, 0, 0, 4, 0, 12, 15, 49, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 3, 12, 7, 7, 7, 14, 1, 3, 0, 0, 192, 0, 12, 20, 49, 0 -}; - -static const unsigned char config_pal_cache_prot_info[200] = { - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 45, 0, 16, 8, 0, 76, 12, 64, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8, 0, 16, 4, 0, 76, 44, 68, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, - 0, 16, 8, 0, 81, 44, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, - 112, 12, 0, 79, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 254, 255, 255, 255, 255, 255, 255, 255, - 32, 0, 112, 12, 0, 79, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 160, - 12, 0, 84, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0 -}; - -static const unsigned char config_pal_debug_info[16] = { - 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_fixed_addr[8] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_freq_base[8] = { - 109, 219, 182, 13, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_freq_ratios[24] = { - 11, 1, 0, 0, 77, 7, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 4, - 0, 0, 0, 7, 0, 0, 0 -}; - -static const unsigned char config_pal_halt_info[64] = { - 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_perf_mon_info[136] = { - 12, 47, 18, 8, 0, 0, 0, 0, 241, 255, 0, 0, 255, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 241, 255, 0, 0, 223, 0, 255, 255, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_proc_get_features[104] = { - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 64, 6, 64, 49, 0, 0, 0, 0, 64, 6, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, - 231, 0, 0, 0, 0, 0, 0, 0, 228, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, - 63, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_ptce_info[24] = { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_register_info[64] = { - 255, 0, 47, 127, 17, 17, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, - 255, 208, 128, 238, 238, 0, 0, 248, 255, 255, 255, 255, 255, 0, 0, 7, 3, - 251, 3, 0, 0, 0, 0, 255, 7, 3, 0, 0, 0, 0, 0, 248, 252, 4, - 252, 255, 255, 255, 255, 2, 248, 252, 255, 255, 255, 255, 255 -}; - -static const unsigned char config_pal_rse_info[16] = { - 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_test_info[48] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_vm_summary[16] = { - 101, 18, 15, 2, 7, 7, 4, 2, 59, 18, 0, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_vm_info[104] = { - 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 32, 32, 0, 0, 0, 0, 0, 0, 112, 85, 21, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 32, 32, 0, 0, 0, 0, 0, 0, 112, 85, - 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 128, 128, 0, - 4, 0, 0, 0, 0, 112, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 128, 128, 0, 4, 0, 0, 0, 0, 112, 85, 0, 0, 0, 0, 0 -}; - -static const unsigned char config_pal_vm_page_size[16] = { - 0, 112, 85, 21, 0, 0, 0, 0, 0, 112, 85, 21, 0, 0, 0, 0 -}; - -typedef struct{ - hob_type_t type; - void* data; - unsigned long size; -} hob_batch_t; - -static const hob_batch_t hob_batch[]={ - { HOB_TYPE_PAL_BUS_GET_FEATURES_DATA, - &config_pal_bus_get_features_data, - sizeof(config_pal_bus_get_features_data) - }, - { HOB_TYPE_PAL_CACHE_SUMMARY, - &config_pal_cache_summary, - sizeof(config_pal_cache_summary) - }, - { HOB_TYPE_PAL_MEM_ATTRIB, - &config_pal_mem_attrib, - sizeof(config_pal_mem_attrib) - }, - { HOB_TYPE_PAL_CACHE_INFO, - &config_pal_cache_info, - sizeof(config_pal_cache_info) - }, - { HOB_TYPE_PAL_CACHE_PROT_INFO, - &config_pal_cache_prot_info, - sizeof(config_pal_cache_prot_info) - }, - { HOB_TYPE_PAL_DEBUG_INFO, - &config_pal_debug_info, - sizeof(config_pal_debug_info) - }, - { HOB_TYPE_PAL_FIXED_ADDR, - &config_pal_fixed_addr, - sizeof(config_pal_fixed_addr) - }, - { HOB_TYPE_PAL_FREQ_BASE, - &config_pal_freq_base, - sizeof(config_pal_freq_base) - }, - { HOB_TYPE_PAL_FREQ_RATIOS, - &config_pal_freq_ratios, - sizeof(config_pal_freq_ratios) - }, - { HOB_TYPE_PAL_HALT_INFO, - &config_pal_halt_info, - sizeof(config_pal_halt_info) - }, - { HOB_TYPE_PAL_PERF_MON_INFO, - &config_pal_perf_mon_info, - sizeof(config_pal_perf_mon_info) - }, - { HOB_TYPE_PAL_PROC_GET_FEATURES, - &config_pal_proc_get_features, - sizeof(config_pal_proc_get_features) - }, - { HOB_TYPE_PAL_PTCE_INFO, - &config_pal_ptce_info, - sizeof(config_pal_ptce_info) - }, - { HOB_TYPE_PAL_REGISTER_INFO, - &config_pal_register_info, - sizeof(config_pal_register_info) - }, - { HOB_TYPE_PAL_RSE_INFO, - &config_pal_rse_info, - sizeof(config_pal_rse_info) - }, - { HOB_TYPE_PAL_TEST_INFO, - &config_pal_test_info, - sizeof(config_pal_test_info) - }, - { HOB_TYPE_PAL_VM_SUMMARY, - &config_pal_vm_summary, - sizeof(config_pal_vm_summary) - }, - { HOB_TYPE_PAL_VM_INFO, - &config_pal_vm_info, - sizeof(config_pal_vm_info) - }, - { HOB_TYPE_PAL_VM_PAGE_SIZE, - &config_pal_vm_page_size, - sizeof(config_pal_vm_page_size) - }, -}; - -static int -add_pal_hob(void* hob_buf) -{ - int i; - for (i = 0; i < sizeof(hob_batch)/sizeof(hob_batch_t); i++) { - if (hob_add(hob_buf, hob_batch[i].type, hob_batch[i].data, - hob_batch[i].size) < 0) - return -1; - } - return 0; -} - -// The most significant bit of nvram file descriptor: -// 1: valid; 0: invalid -#define VALIDATE_NVRAM_FD(x) ((1UL<<(sizeof(x)*8 - 1)) | x) -#define IS_VALID_NVRAM_FD(x) ((uint64_t)x >> (sizeof(x)*8 - 1)) -static uint64_t -nvram_init(xc_interface *xch, const char *nvram_path) -{ - uint64_t fd = 0; - fd = open(nvram_path, O_CREAT|O_RDWR, 0644); - - if ( fd < 0 ) - { - PERROR("Nvram open failed at %s. Guest will boot without" - " nvram support!\n", nvram_path); - return -1; - } - - return VALIDATE_NVRAM_FD(fd); -} - -static int -copy_from_nvram_to_GFW(xc_interface *xch, uint32_t dom, int nvram_fd) -{ - unsigned int nr_pages = NVRAM_SIZE >> PAGE_SHIFT; - struct stat file_stat; - char buf[NVRAM_SIZE] = {0}; - - if ( fstat(nvram_fd, &file_stat) < 0 ) - { - PERROR("Cannot get Nvram file info! Guest will boot without " - "nvram support!\n"); - return -1; - } - - if ( 0 == file_stat.st_size ) - { - DPRINTF("Nvram file create successful!\n"); - return 0; - } - - if ( read(nvram_fd, buf, NVRAM_SIZE) != NVRAM_SIZE ) - { - PERROR("Load nvram fail. guest will boot without" - " nvram support!\n"); - return -1; - } - - return xc_ia64_copy_to_domain_pages(xch, dom, buf, - NVRAM_START >> PAGE_SHIFT, nr_pages); -} - - -/* - *Check is the address where NVRAM data located valid - */ -static int is_valid_address(xc_interface *xch, void *addr) -{ - struct nvram_save_addr *p = (struct nvram_save_addr *)addr; - - if ( p->signature == NVRAM_VALID_SIG ) - return 1; - else { - PERROR("Invalid nvram signature. Nvram save failed!"); - return 0; - } -} - -/* - * GFW use 4k page. when doing foreign map, we should 16k align - * the address and map one more page to guarantee all 64k nvram data - * can be got. - */ -static int -copy_from_GFW_to_nvram(xc_interface *xch, uint32_t dom, int nvram_fd) -{ - xen_pfn_t *pfn_list = NULL; - char *tmp_ptr = NULL; - unsigned int nr_pages = 0; - uint64_t addr_from_GFW_4k_align = 0; - uint32_t offset = 0; - uint64_t nvram_base_addr = 0; - char buf[NVRAM_SIZE] = {0}; - int i; - - // map one more page - nr_pages = (NVRAM_SIZE + PAGE_SIZE) >> PAGE_SHIFT; - pfn_list = (xen_pfn_t *)malloc(sizeof(xen_pfn_t) * nr_pages); - if ( NULL == pfn_list ) - { - PERROR("Cannot allocate memory for nvram save!"); - close(nvram_fd); - return -1; - } - - /* - * GFW allocate memory dynamicly to save nvram data - * and save address of the dynamic memory at NVRAM_START. - * To save nvram data to file, we must get the dynamic - * memory address first. - */ - pfn_list[0] = NVRAM_START >> PAGE_SHIFT; - tmp_ptr = (char *)xc_map_foreign_range(xch, dom, PAGE_SIZE, - PROT_READ | PROT_WRITE, pfn_list[0]); - - if ( NULL == tmp_ptr ) - { - PERROR("Cannot get nvram data from GFW!"); - free(pfn_list); - close(nvram_fd); - return -1; - } - - /* Check is NVRAM data vaild */ - if ( !is_valid_address(xch, tmp_ptr) ) - { - free(pfn_list); - munmap(tmp_ptr, PAGE_SIZE); - close(nvram_fd); - return -1; - } - - addr_from_GFW_4k_align = ((struct nvram_save_addr *)tmp_ptr)->addr; - munmap(tmp_ptr, PAGE_SIZE); - - // align address to 16k - offset = addr_from_GFW_4k_align % ( 16 * MEM_K ); - addr_from_GFW_4k_align = addr_from_GFW_4k_align - offset; - for ( i=0; i<nr_pages; i++ ) - pfn_list[i] = (addr_from_GFW_4k_align >> PAGE_SHIFT) + i; - - tmp_ptr = (char *)xc_map_foreign_pages(xch, dom, - PROT_READ | PROT_WRITE, - pfn_list, nr_pages); - if ( NULL == tmp_ptr ) - { - PERROR("Cannot get nvram data from GFW!"); - free(pfn_list); - close(nvram_fd); - return -1; - } - - // calculate nvram data base addrees - nvram_base_addr = (uint64_t)(tmp_ptr + offset); - - memcpy(buf, (void *)nvram_base_addr, NVRAM_SIZE); - free(pfn_list); - munmap(tmp_ptr, NVRAM_SIZE + PAGE_SIZE); - - lseek(nvram_fd, 0, SEEK_SET); - if ( write(nvram_fd, buf, NVRAM_SIZE) != NVRAM_SIZE ) - { - PERROR("Save to nvram fail!"); - return -1; - } - - close(nvram_fd); - - DPRINTF("Nvram save successful!\n"); - - return 0; -} - -int xc_ia64_save_to_nvram(xc_interface *xch, uint32_t dom) -{ - xc_dominfo_t info; - uint64_t nvram_fd = 0; - - if ( xc_domain_getinfo(xch, dom, 1, &info) != 1 ) - { - PERROR("Could not get info for domain"); - return -1; - } - - if ( !info.hvm ) - return 0; - - xc_get_hvm_param(xch, dom, HVM_PARAM_NVRAM_FD, &nvram_fd); - - if ( !IS_VALID_NVRAM_FD(nvram_fd) ) - PERROR("Nvram not initialized. Nvram save failed!"); - else - copy_from_GFW_to_nvram(xch, dom, (int)nvram_fd); - - // although save to nvram maybe fail, we don't return any error number - // to Xend. This is quite logical because damage of NVRAM on native would - // not block OS's executive path. Return error number will cause an - // exception of Xend and block XenU when it destroy. - return 0; -} - -#define NVRAM_DIR "/var/lib/xen/nvram/" -#define NVRAM_FILE_PREFIX "nvram_" - -int xc_ia64_nvram_init(xc_interface *xch, char *dom_name, uint32_t dom) -{ - uint64_t nvram_fd; - char nvram_path[PATH_MAX] = NVRAM_DIR; - - if ( access(nvram_path, R_OK|W_OK|X_OK) == -1 ) { - if ( errno != ENOENT ) - { - PERROR("Error stat'ing NVRAM dir %s.", nvram_path); - return -1; - } - if ( mkdir(nvram_path, 0755) == -1 ) - { - PERROR("Unable to create NVRAM store directory %s.", nvram_path); - return -1; - } - } - - if ( access(nvram_path, R_OK|W_OK|X_OK) == -1 ) { - errno = EACCES; - PERROR("No RWX permission to NVRAM store directory %s.", nvram_path); - return -1; - } - - if ( strlen(nvram_path) + strlen(NVRAM_FILE_PREFIX) + - strlen(dom_name) + 1 > sizeof(nvram_path) ) - { - PERROR("Nvram file path is too long!"); - return -1; - } - strcat(nvram_path, NVRAM_FILE_PREFIX); - strcat(nvram_path, dom_name); - - nvram_fd = nvram_init(xch, nvram_path); - if ( nvram_fd == (uint64_t)(-1) ) - { - xc_set_hvm_param(xch, dom, HVM_PARAM_NVRAM_FD, 0); - return -1; - } - - xc_set_hvm_param(xch, dom, HVM_PARAM_NVRAM_FD, nvram_fd); - return 0; -} - -#define GFW_PAGES (GFW_SIZE >> PAGE_SHIFT) -#define VGA_START_PAGE (VGA_IO_START >> PAGE_SHIFT) -#define VGA_END_PAGE ((VGA_IO_START + VGA_IO_SIZE) >> PAGE_SHIFT) - -static void -xc_ia64_setup_md(efi_memory_desc_t *md, - unsigned long start, unsigned long end) -{ - md->type = EFI_CONVENTIONAL_MEMORY; - md->pad = 0; - md->phys_addr = start; - md->virt_addr = 0; - md->num_pages = (end - start) >> EFI_PAGE_SHIFT; - md->attribute = EFI_MEMORY_WB; -} - -static inline unsigned long -min(unsigned long lhs, unsigned long rhs) -{ - return (lhs < rhs)? lhs: rhs; -} - -static int -xc_ia64_setup_memmap_info(xc_interface *xch, uint32_t dom, - unsigned long dom_memsize, /* in bytes */ - unsigned long *pfns_special_pages, - unsigned long nr_special_pages, - unsigned long memmap_info_pfn, - unsigned long memmap_info_num_pages) -{ - xen_ia64_memmap_info_t* memmap_info; - efi_memory_desc_t *md; - uint64_t nr_mds; - - memmap_info = xc_map_foreign_range(xch, dom, - PAGE_SIZE * memmap_info_num_pages, - PROT_READ | PROT_WRITE, - memmap_info_pfn); - if (memmap_info == NULL) { - PERROR("Could not map memmmap_info page."); - return -1; - } - memset(memmap_info, 0, PAGE_SIZE * memmap_info_num_pages); - - /* - * [0, VGA_IO_START = 0xA0000) - * [VGA_IO_START + VGA_IO_SIZE = 0xC0000, MMIO_START = 3GB) - * [IO_PAGE_START (> 3GB), IO_PAGE_START + IO_PAGE_SIZE) - * [STORE_PAGE_START, STORE_PAGE_START + STORE_PAGE_SIZE) - * [BUFFER_IO_PAGE_START, BUFFER_IO_PAGE_START + BUFFER_IO_PAGE_SIZE) - * [BUFFER_PIO_PAGE_START, BUFFER_PIO_PAGE_START + BUFFER_PIO_PAGE_SIZE) - * [memmap_info_pfn << PAGE_SHIFT, - * (memmap_info_pfn << PAGE_SHIFT) + PAGE_SIZE) - * [GFW_START=4GB - GFW_SIZE, GFW_START + GFW_SIZE = 4GB) - * [4GB, ...) - */ - md = (efi_memory_desc_t*)&memmap_info->memdesc; - xc_ia64_setup_md(md, 0, min(VGA_IO_START, dom_memsize)); - md++; - - if (dom_memsize > VGA_IO_START) { - xc_ia64_setup_md(md, VGA_IO_START + VGA_IO_SIZE, - min(MMIO_START, dom_memsize + VGA_IO_SIZE)); - md++; - } - xc_ia64_setup_md(md, IO_PAGE_START, IO_PAGE_START + IO_PAGE_SIZE); - md++; - xc_ia64_setup_md(md, STORE_PAGE_START, STORE_PAGE_START + STORE_PAGE_SIZE); - md++; - xc_ia64_setup_md(md, BUFFER_IO_PAGE_START, - BUFFER_IO_PAGE_START + BUFFER_IO_PAGE_SIZE); - md++; - xc_ia64_setup_md(md, BUFFER_PIO_PAGE_START, - BUFFER_PIO_PAGE_START + BUFFER_PIO_PAGE_SIZE); - md++; - xc_ia64_setup_md(md, memmap_info_pfn << PAGE_SHIFT, - (memmap_info_pfn << PAGE_SHIFT) + - PAGE_SIZE * memmap_info_num_pages); - md++; - xc_ia64_setup_md(md, GFW_START, GFW_START + GFW_SIZE); - md++; - if (dom_memsize + VGA_IO_SIZE > MMIO_START) { - xc_ia64_setup_md(md, 4 * MEM_G, dom_memsize + VGA_IO_SIZE + (1 * MEM_G)); - md++; - } - nr_mds = md - (efi_memory_desc_t*)&memmap_info->memdesc; - - assert(nr_mds <= - (PAGE_SIZE * memmap_info_num_pages - - offsetof(typeof(*memmap_info), memdesc))/sizeof(*md)); - memmap_info->efi_memmap_size = nr_mds * sizeof(*md); - memmap_info->efi_memdesc_size = sizeof(*md); - memmap_info->efi_memdesc_version = EFI_MEMORY_DESCRIPTOR_VERSION; - - munmap(memmap_info, PAGE_SIZE * memmap_info_num_pages); - return 0; -} - -/* setup shared_info page */ -static int -xc_ia64_setup_shared_info(xc_interface *xch, uint32_t dom, - unsigned long shared_info_pfn, - unsigned long memmap_info_pfn, - unsigned long memmap_info_num_pages) -{ - shared_info_t *shared_info; - - shared_info = xc_map_foreign_range(xch, dom, PAGE_SIZE, - PROT_READ | PROT_WRITE, - shared_info_pfn); - if (shared_info == NULL) { - PERROR("Could not map shared_info"); - return -1; - } - memset(shared_info, 0, sizeof(*shared_info)); - shared_info->arch.memmap_info_num_pages = memmap_info_num_pages; - shared_info->arch.memmap_info_pfn = memmap_info_pfn; - munmap(shared_info, PAGE_SIZE); - return 0; -} - -/* - * In this function, we will allocate memory and build P2M/M2P table for VTI - * guest. Frist, a pfn list will be initialized discontiguous, normal memory - * begins with 0, GFW memory and other five pages at their place defined in - * xen/include/public/arch-ia64.h xc_domain_populate_physmap_exact() called - * five times, to set parameter 'extent_order' to different value, this is - * convenient to allocate discontiguous memory with different size. - */ -static int -setup_guest(xc_interface *xch, uint32_t dom, unsigned long memsize, - char *image, unsigned long image_size) -{ - xen_pfn_t *pfn_list; - unsigned long dom_memsize = memsize; - unsigned long nr_pages = memsize >> PAGE_SHIFT; - unsigned long vcpus; - unsigned long nr_special_pages; - unsigned long memmap_info_pfn; - unsigned long memmap_info_num_pages; - unsigned long nvram_start = NVRAM_START, nvram_fd = 0; - int rc; - unsigned long i; - unsigned long pfn; - const struct hvm_special_page { - int param; - xen_pfn_t pfn; - } special_pages[] = { - // pfn-sorted array - { HVM_PARAM_IOREQ_PFN, IO_PAGE_START >> PAGE_SHIFT}, - { HVM_PARAM_STORE_PFN, STORE_PAGE_START >> PAGE_SHIFT}, - { HVM_PARAM_BUFIOREQ_PFN, BUFFER_IO_PAGE_START >> PAGE_SHIFT}, - { HVM_PARAM_BUFPIOREQ_PFN, BUFFER_PIO_PAGE_START >> PAGE_SHIFT}, - }; - DECLARE_DOMCTL; - - - if ((image_size > 12 * MEM_M) || (image_size & (PAGE_SIZE - 1))) { - PERROR("Guest firmware size is incorrect [%ld]?", image_size); - return -1; - } - - pfn_list = malloc(nr_pages * sizeof(xen_pfn_t)); - if (pfn_list == NULL) { - PERROR("Could not allocate memory."); - return -1; - } - - // - // Populate - // [0, VGA_IO_START) (VGA_IO_SIZE hole) - // [VGA_IO_START + VGA_IO_SIZE, MMIO_START) (1GB hole) - // [4GB, end) - // - i = 0; - for (pfn = 0; - pfn < MIN((dom_memsize >> PAGE_SHIFT), VGA_START_PAGE); - pfn++) - pfn_list[i++] = pfn; - for (pfn = VGA_END_PAGE; - pfn < (MIN(dom_memsize + VGA_IO_SIZE, MMIO_START) >> PAGE_SHIFT); - pfn++) - pfn_list[i++] = pfn; - for (pfn = ((4 * MEM_G) >> PAGE_SHIFT); - pfn < ((dom_memsize + VGA_IO_SIZE + 1 * MEM_G) >> PAGE_SHIFT); - pfn++) - pfn_list[i++] = pfn; - - rc = xc_domain_populate_physmap_exact(xch, dom, nr_pages, 0, 0, - &pfn_list[0]); - if (rc != 0) { - PERROR("Could not allocate normal memory for Vti guest."); - goto error_out; - } - - // We allocate additional pfn for GFW and other five pages, so - // the pfn_list is not contiguous. Due to this we must support - // old interface xc_ia64_get_pfn_list(). - for (i = 0; i < GFW_PAGES; i++) - pfn_list[i] = (GFW_START >> PAGE_SHIFT) + i; - - rc = xc_domain_populate_physmap_exact(xch, dom, GFW_PAGES, - 0, 0, &pfn_list[0]); - if (rc != 0) { - PERROR("Could not allocate GFW memory for Vti guest."); - goto error_out; - } - - for (i = 0; i < sizeof(special_pages) / sizeof(special_pages[0]); i++) - pfn_list[i] = special_pages[i].pfn; - - nr_special_pages = i; - memmap_info_pfn = pfn_list[nr_special_pages - 1] + 1; - memmap_info_num_pages = 1; - pfn_list[nr_special_pages] = memmap_info_pfn; - nr_special_pages++; - - rc = xc_domain_populate_physmap_exact(xch, dom, nr_special_pages, - 0, 0, &pfn_list[0]); - if (rc != 0) { - PERROR("Could not allocate IO page or store page or buffer io page."); - goto error_out; - } - - domctl.u.arch_setup.flags = 0; - domctl.u.arch_setup.bp = 0; - domctl.u.arch_setup.maxmem = GFW_START + GFW_SIZE; - if (dom_memsize + VGA_IO_SIZE > MMIO_START) - domctl.u.arch_setup.maxmem = dom_memsize + VGA_IO_SIZE + 1 * MEM_G; - domctl.cmd = XEN_DOMCTL_arch_setup; - domctl.domain = (domid_t)dom; - if (xc_domctl(xch, &domctl)) - goto error_out; - - // Load guest firmware - if (xc_ia64_copy_to_domain_pages(xch, dom, image, - (GFW_START + GFW_SIZE - image_size) >> PAGE_SHIFT, - image_size >> PAGE_SHIFT)) { - PERROR("Could not load guest firmware into domain"); - goto error_out; - } - - domctl.cmd = XEN_DOMCTL_getdomaininfo; - domctl.domain = (domid_t)dom; - if (xc_domctl(xch, &domctl) < 0) { - PERROR("Could not get info on domain"); - goto error_out; - } - - if (xc_ia64_setup_memmap_info(xch, dom, dom_memsize, - pfn_list, nr_special_pages, - memmap_info_pfn, memmap_info_num_pages)) { - PERROR("Could not build memmap info"); - goto error_out; - } - if (xc_ia64_setup_shared_info(xch, dom, - domctl.u.getdomaininfo.shared_info_frame, - memmap_info_pfn, memmap_info_num_pages)) { - PERROR("Could not setup shared_info"); - goto error_out; - } - - xc_get_hvm_param(xch, dom, HVM_PARAM_NVRAM_FD, &nvram_fd); - if ( !IS_VALID_NVRAM_FD(nvram_fd) ) - nvram_start = 0; - else if ( copy_from_nvram_to_GFW(xch, dom, (int)nvram_fd ) == -1 ) { - nvram_start = 0; - close(nvram_fd); - } - - vcpus = domctl.u.getdomaininfo.max_vcpu_id + 1; - - // Hand-off state passed to guest firmware - if (xc_ia64_build_hob(xch, dom, dom_memsize, vcpus, nvram_start) < 0) { - PERROR("Could not build hob"); - goto error_out; - } - - // zero clear all special pages - for (i = 0; i < sizeof(special_pages) / sizeof(special_pages[0]); i++) { - xc_set_hvm_param(xch, dom, - special_pages[i].param, special_pages[i].pfn); - if (xc_clear_domain_page(xch, dom, special_pages[i].pfn)) - goto error_out; - } - - free(pfn_list); - return 0; - -error_out: - return -1; -} - -int -xc_hvm_build(xc_interface *xch, uint32_t domid, const struct xc_hvm_build_args *args) -{ - vcpu_guest_context_any_t st_ctxt_any; - vcpu_guest_context_t *ctxt = &st_ctxt_any.c; - char *image = NULL; - unsigned long image_size; - - image = xc_read_image(xch, args->image_file_name, &image_size); - if (image == NULL) { - PERROR("Could not read guest firmware image %s", image_name); - goto error_out; - } - - image_size = (image_size + PAGE_SIZE - 1) & PAGE_MASK; - - if (setup_guest(xch, domid, (unsigned long)args->mem_size, image, - image_size) < 0) { - ERROR("Error constructing guest OS"); - goto error_out; - } - - free(image); - - memset(&st_ctxt_any, 0, sizeof(st_ctxt_any)); - ctxt->regs.ip = 0x80000000ffffffb0UL; - ctxt->regs.ar.fpsr = xc_ia64_fpsr_default(); - ctxt->regs.cr.itir = 14 << 2; - ctxt->regs.psr = IA64_PSR_AC | IA64_PSR_BN; - ctxt->regs.cr.dcr = 0; - ctxt->regs.cr.pta = 15 << 2; - return xc_vcpu_setcontext(xch, domid, 0, &st_ctxt_any); - -error_out: - free(image); - return -1; -} - -/* xc_hvm_build_target_mem: - * Create a domain for a pre-ballooned virtualized Linux, using - * files/filenames. If target < memsize, domain is created with - * memsize pages marked populate-on-demand, and with a PoD cache size - * of target. If target == memsize, pages are populated normally. - * - * XXX:PoD isn't supported yet so setting target does nothing. - */ -int xc_hvm_build_target_mem(xc_interface *xch, - uint32_t domid, - int memsize, - int target, - const char *image_name) -{ - struct xc_hvm_build_args args; - - args.mem_size = (uint64_t)memsize << 20; - args.mem_target = (uint64_t)target << 20; - args.image_file_name = image_name; - - return xc_hvm_build(xch, domid, &args); -} - -/* - * From asm/pgtable.h - */ -#define _PAGE_P_BIT 0 -#define _PAGE_A_BIT 5 -#define _PAGE_D_BIT 6 - -#define _PAGE_P (1 << _PAGE_P_BIT) /* page present bit */ -#define _PAGE_A (1 << _PAGE_A_BIT) /* page accessed bit */ -#define _PAGE_D (1 << _PAGE_D_BIT) /* page dirty bit */ - -#define _PAGE_MA_WB (0x0 << 2) /* write back memory attribute */ -#define _PAGE_MA_UC (0x4 << 2) /* uncacheable memory attribute */ -#define _PAGE_AR_RW (2 << 9) /* read & write */ - -int -xc_ia64_set_os_type(xc_interface *xch, char *guest_os_type, uint32_t dom) -{ - DECLARE_DOMCTL; - - domctl.cmd = XEN_DOMCTL_set_opt_feature; - domctl.domain = (domid_t)dom; - - if (!guest_os_type || !strlen(guest_os_type) || - !strcmp("default", guest_os_type)) { - - /* Nothing */ - return 0; - - } else if (!strcmp("windows", guest_os_type)) { - DPRINTF("Enabling Windows guest OS optimizations\n"); - - /* Windows identity maps regions 4 & 5 */ - domctl.u.set_opt_feature.optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG4; - domctl.u.set_opt_feature.optf.on = XEN_IA64_OPTF_ON; - domctl.u.set_opt_feature.optf.pgprot = (_PAGE_P | _PAGE_A | _PAGE_D | - _PAGE_MA_WB | _PAGE_AR_RW); - domctl.u.set_opt_feature.optf.key = 0; - if (xc_domctl(xch, &domctl)) - PERROR("Failed to set region 4 identity mapping for Windows " - "guest OS type.\n"); - - domctl.u.set_opt_feature.optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG5; - domctl.u.set_opt_feature.optf.on = XEN_IA64_OPTF_ON; - domctl.u.set_opt_feature.optf.pgprot = (_PAGE_P | _PAGE_A | _PAGE_D | - _PAGE_MA_UC | _PAGE_AR_RW); - domctl.u.set_opt_feature.optf.key = 0; - if (xc_domctl(xch, &domctl)) - PERROR("Failed to set region 5 identity mapping for Windows " - "guest OS type.\n"); - return 0; - - } else if (!strcmp("linux", guest_os_type)) { - DPRINTF("Enabling Linux guest OS optimizations\n"); - - /* Linux identity maps regions 7 */ - domctl.u.set_opt_feature.optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG7; - domctl.u.set_opt_feature.optf.on = XEN_IA64_OPTF_ON; - domctl.u.set_opt_feature.optf.pgprot = (_PAGE_P | _PAGE_A | _PAGE_D | - _PAGE_MA_WB | _PAGE_AR_RW); - domctl.u.set_opt_feature.optf.key = 0; - if (xc_domctl(xch, &domctl)) - PERROR("Failed to set region 7 identity mapping for Linux " - "guest OS type.\n"); - return 0; - } - - DPRINTF("Unknown guest_os_type (%s), using defaults\n", guest_os_type); - - return 0; -} - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/ia64/xc_ia64_linux_restore.c b/tools/libxc/ia64/xc_ia64_linux_restore.c deleted file mode 100644 index d199cbfac4..0000000000 --- a/tools/libxc/ia64/xc_ia64_linux_restore.c +++ /dev/null @@ -1,739 +0,0 @@ -/****************************************************************************** - * xc_ia64_linux_restore.c - * - * Restore the state of a Linux session. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Copyright (c) 2003, K A Fraser. - * Rewritten for ia64 by Tristan Gingold <tristan.gingold@bull.net> - * - * Copyright (c) 2007 Isaku Yamahata <yamahata@valinux.co.jp> - * Use foreign p2m exposure. - * VTi domain support - */ - -#include <stdlib.h> -#include <unistd.h> - -#include "xg_private.h" -#include "xc_ia64_save_restore.h" -#include "xc_ia64.h" -#include "xc_efi.h" -#include "xen/hvm/params.h" - -#define PFN_TO_KB(_pfn) ((_pfn) << (PAGE_SHIFT - 10)) - -/* number of pfns this guest has (i.e. number of entries in the P2M) */ -static unsigned long p2m_size; - -/* number of 'in use' pfns in the guest (i.e. #P2M entries with a valid mfn) */ -static unsigned long nr_pfns; - -static int -populate_page_if_necessary(xc_interface *xch, uint32_t dom, unsigned long gmfn, - struct xen_ia64_p2m_table *p2m_table) -{ - if (xc_ia64_p2m_present(p2m_table, gmfn)) - return 0; - - return xc_domain_populate_physmap_exact(xch, dom, 1, 0, 0, &gmfn); -} - -static int -read_page(xc_interface *xch, int io_fd, uint32_t dom, unsigned long pfn) -{ - void *mem; - - mem = xc_map_foreign_range(xch, dom, PAGE_SIZE, - PROT_READ|PROT_WRITE, pfn); - if (mem == NULL) { - ERROR("cannot map page"); - return -1; - } - if (read_exact(io_fd, mem, PAGE_SIZE)) { - ERROR("Error when reading from state file (5)"); - munmap(mem, PAGE_SIZE); - return -1; - } - munmap(mem, PAGE_SIZE); - return 0; -} - -/* - * Get the list of PFNs that are not in the psuedo-phys map. - * Although we allocate pages on demand, balloon driver may - * decreased simaltenously. So we have to free the freed - * pages here. - */ -static int -xc_ia64_recv_unallocated_list(xc_interface *xch, int io_fd, uint32_t dom, - struct xen_ia64_p2m_table *p2m_table) -{ - int rc = -1; - unsigned int i; - unsigned int count; - unsigned long *pfntab = NULL; - unsigned int nr_frees; - - if (read_exact(io_fd, &count, sizeof(count))) { - ERROR("Error when reading pfn count"); - goto out; - } - - pfntab = malloc(sizeof(unsigned long) * count); - if (pfntab == NULL) { - ERROR("Out of memory"); - goto out; - } - - if (read_exact(io_fd, pfntab, sizeof(unsigned long)*count)) { - ERROR("Error when reading pfntab"); - goto out; - } - - nr_frees = 0; - for (i = 0; i < count; i++) { - if (xc_ia64_p2m_allocated(p2m_table, pfntab[i])) { - pfntab[nr_frees] = pfntab[i]; - nr_frees++; - } - } - if (nr_frees > 0) { - if (xc_domain_decrease_reservation_exact(xch, dom, nr_frees, - 0, pfntab) < 0) { - PERROR("Could not decrease reservation"); - goto out; - } else - DPRINTF("Decreased reservation by %d / %d pages\n", - nr_frees, count); - } - - rc = 0; - - out: - if (pfntab != NULL) - free(pfntab); - return rc; -} - -static int -xc_ia64_recv_vcpu_context(xc_interface *xch, int io_fd, uint32_t dom, - uint32_t vcpu, vcpu_guest_context_any_t *ctxt_any) -{ - vcpu_guest_context_t *ctxt = &ctxt_any->c; - if (read_exact(io_fd, ctxt, sizeof(*ctxt))) { - ERROR("Error when reading ctxt"); - return -1; - } - - fprintf(stderr, "ip=%016lx, b0=%016lx\n", ctxt->regs.ip, ctxt->regs.b[0]); - - /* Initialize and set registers. */ - ctxt->flags = VGCF_EXTRA_REGS | VGCF_SET_CR_IRR | VGCF_online | - VGCF_SET_AR_ITC; - if (xc_vcpu_setcontext(xch, dom, vcpu, ctxt_any) != 0) { - ERROR("Couldn't set vcpu context"); - return -1; - } - - /* Just a check. */ - ctxt->flags = 0; - if (xc_vcpu_getcontext(xch, dom, vcpu, ctxt_any)) { - ERROR("Could not get vcpu context"); - return -1; - } - - return 0; -} - -/* Read shared info. */ -static int -xc_ia64_recv_shared_info(xc_interface *xch, int io_fd, uint32_t dom, - unsigned long shared_info_frame, - unsigned long *start_info_pfn) -{ - unsigned int i; - - /* The new domain's shared-info frame. */ - shared_info_t *shared_info; - - /* Read shared info. */ - shared_info = xc_map_foreign_range(xch, dom, PAGE_SIZE, - PROT_READ|PROT_WRITE, - shared_info_frame); - if (shared_info == NULL) { - ERROR("cannot map page"); - return -1; - } - - if (read_exact(io_fd, shared_info, PAGE_SIZE)) { - ERROR("Error when reading shared_info page"); - munmap(shared_info, PAGE_SIZE); - return -1; - } - - /* clear any pending events and the selector */ - memset(&(shared_info->evtchn_pending[0]), 0, - sizeof (shared_info->evtchn_pending)); - for (i = 0; i < XEN_LEGACY_MAX_VCPUS; i++) - shared_info->vcpu_info[i].evtchn_pending_sel = 0; - - if (start_info_pfn != NULL) - *start_info_pfn = shared_info->arch.start_info_pfn; - - munmap (shared_info, PAGE_SIZE); - - return 0; -} - -static int -xc_ia64_recv_vcpumap(xc_interface *xch, - const xc_dominfo_t *info, int io_fd, uint64_t **vcpumapp) -{ - uint64_t max_virt_cpus; - unsigned long vcpumap_size; - uint64_t *vcpumap = NULL; - - *vcpumapp = NULL; - - if (read_exact(io_fd, &max_virt_cpus, sizeof(max_virt_cpus))) { - ERROR("error reading max_virt_cpus"); - return -1; - } - if (max_virt_cpus < info->max_vcpu_id) { - ERROR("too large max_virt_cpus %i < %i\n", - max_virt_cpus, info->max_vcpu_id); - return -1; - } - vcpumap_size = bitmap_size(max_virt_cpus); - rc = bitmap_alloc(&vcpumap, max_virt_cpus); - if (rc < 0) { - ERROR("memory alloc for vcpumap"); - return rc; - } - if (read_exact(io_fd, vcpumap, vcpumap_size)) { - ERROR("read vcpumap"); - free(vcpumap); - return -1; - } - - *vcpumapp = vcpumap; - return 0; -} - -static int -xc_ia64_pv_recv_vcpu_context(xc_interface *xch, int io_fd, int32_t dom, - uint32_t vcpu) -{ - int rc = -1; - - /* A copy of the CPU context of the guest. */ - vcpu_guest_context_any_t ctxt_any; - vcpu_guest_context_t *ctxt = &ctxt_any.c; - - if (xc_ia64_recv_vcpu_context(xch, io_fd, dom, vcpu, &ctxt_any)) - goto out; - - /* Then get privreg page. */ - if (read_page(xch, io_fd, dom, ctxt->privregs_pfn) < 0) { - ERROR("Could not read vcpu privregs"); - goto out; - } - - rc = 0; - - out: - return rc; -} - -static int -xc_ia64_pv_recv_shared_info(xc_interface *xch, int io_fd, int32_t dom, - unsigned long shared_info_frame, - struct xen_ia64_p2m_table *p2m_table, - unsigned int store_evtchn, - unsigned long *store_mfn, - unsigned int console_evtchn, - unsigned long *console_mfn) -{ - unsigned long gmfn; - - /* A temporary mapping of the guest's start_info page. */ - start_info_t *start_info; - - /* Read shared info. */ - if (xc_ia64_recv_shared_info(xch, io_fd, dom, - shared_info_frame, &gmfn)) - return -1; - - /* Uncanonicalise the suspend-record frame number and poke resume rec. */ - if (populate_page_if_necessary(xch, dom, gmfn, p2m_table)) { - ERROR("cannot populate page 0x%lx", gmfn); - return -1; - } - start_info = xc_map_foreign_range(xch, dom, PAGE_SIZE, - PROT_READ | PROT_WRITE, gmfn); - if (start_info == NULL) { - ERROR("cannot map start_info page"); - return -1; - } - start_info->nr_pages = p2m_size; - start_info->shared_info = shared_info_frame << PAGE_SHIFT; - start_info->flags = 0; - *store_mfn = start_info->store_mfn; - start_info->store_evtchn = store_evtchn; - *console_mfn = start_info->console.domU.mfn; - start_info->console.domU.evtchn = console_evtchn; - munmap(start_info, PAGE_SIZE); - - return 0; -} - -static int -xc_ia64_pv_recv_context_ver_one_or_two(xc_interface *xch, int io_fd, uint32_t dom, - unsigned long shared_info_frame, - struct xen_ia64_p2m_table *p2m_table, - unsigned int store_evtchn, - unsigned long *store_mfn, - unsigned int console_evtchn, - unsigned long *console_mfn) -{ - int rc; - - /* vcpu 0 context */ - rc = xc_ia64_pv_recv_vcpu_context(xch, io_fd, dom, 0); - if (rc) - return rc; - - - /* shared_info */ - rc = xc_ia64_pv_recv_shared_info(xch, io_fd, dom, shared_info_frame, - p2m_table, store_evtchn, store_mfn, - console_evtchn, console_mfn); - return rc; -} - -static int -xc_ia64_pv_recv_context_ver_three(xc_interface *xch, int io_fd, uint32_t dom, - unsigned long shared_info_frame, - struct xen_ia64_p2m_table *p2m_table, - unsigned int store_evtchn, - unsigned long *store_mfn, - unsigned int console_evtchn, - unsigned long *console_mfn) -{ - int rc = -1; - xc_dominfo_t info; - unsigned int i; - - /* vcpu map */ - uint64_t *vcpumap = NULL; - - if (xc_domain_getinfo(xch, dom, 1, &info) != 1) { - ERROR("Could not get domain info"); - return -1; - } - rc = xc_ia64_recv_vcpumap(xch, &info, io_fd, &vcpumap); - if (rc != 0) - goto out; - - /* vcpu context */ - for (i = 0; i <= info.max_vcpu_id; i++) { - if (!test_bit(i, vcpumap)) - continue; - - rc = xc_ia64_pv_recv_vcpu_context(xch, io_fd, dom, i); - if (rc != 0) - goto out; - } - - /* shared_info */ - rc = xc_ia64_pv_recv_shared_info(xch, io_fd, dom, shared_info_frame, - p2m_table, store_evtchn, store_mfn, - console_evtchn, console_mfn); - out: - if (vcpumap != NULL) - free(vcpumap); - return rc; -} - -static int -xc_ia64_pv_recv_context(unsigned long format_version, - xc_interface *xch, int io_fd, uint32_t dom, - unsigned long shared_info_frame, - struct xen_ia64_p2m_table *p2m_table, - unsigned int store_evtchn, - unsigned long *store_mfn, - unsigned int console_evtchn, - unsigned long *console_mfn) -{ - int rc; - switch (format_version) { - case XC_IA64_SR_FORMAT_VER_ONE: - case XC_IA64_SR_FORMAT_VER_TWO: - rc = xc_ia64_pv_recv_context_ver_one_or_two(xch, io_fd, dom, - shared_info_frame, - p2m_table, store_evtchn, - store_mfn, console_evtchn, - console_mfn); - break; - case XC_IA64_SR_FORMAT_VER_THREE: - rc = xc_ia64_pv_recv_context_ver_three(xch, io_fd, dom, - shared_info_frame, - p2m_table, store_evtchn, - store_mfn, console_evtchn, - console_mfn); - break; - default: - ERROR("Unsupported format version"); - rc = -1; - break; - } - return rc; -} - -static int -xc_ia64_hvm_recv_context(xc_interface *xch, int io_fd, uint32_t dom, - unsigned long shared_info_frame, - struct xen_ia64_p2m_table *p2m_table, - unsigned int store_evtchn, unsigned long *store_mfn, - unsigned int console_evtchn, - unsigned long *console_mfn) -{ - int rc = -1; - xc_dominfo_t info; - unsigned int i; - - /* cpumap */ - uint64_t *vcpumap = NULL; - - /* HVM: magic frames for ioreqs and xenstore comms */ - const int hvm_params[] = { - HVM_PARAM_STORE_PFN, - HVM_PARAM_IOREQ_PFN, - HVM_PARAM_BUFIOREQ_PFN, - HVM_PARAM_BUFPIOREQ_PFN, - }; - const int NR_PARAMS = sizeof(hvm_params) / sizeof(hvm_params[0]); - /* ioreq_pfn, bufioreq_pfn, store_pfn */ - uint64_t magic_pfns[NR_PARAMS]; - - /* HVM: a buffer for holding HVM contxt */ - uint64_t rec_size = 0; - uint8_t *hvm_buf = NULL; - - /* Read shared info. */ - if (xc_ia64_recv_shared_info(xch, io_fd, dom, shared_info_frame, - NULL)) - goto out; - - /* vcpu map */ - if (xc_domain_getinfo(xch, dom, 1, &info) != 1) { - ERROR("Could not get domain info"); - goto out; - } - if (xc_ia64_recv_vcpumap(xch, &info, io_fd, &vcpumap)) - goto out; - - /* vcpu context */ - for (i = 0; i <= info.max_vcpu_id; i++) { - /* A copy of the CPU context of the guest. */ - vcpu_guest_context_any_t ctxt_any; - - if (!test_bit(i, vcpumap)) - continue; - - if (xc_ia64_recv_vcpu_context(xch, io_fd, dom, i, &ctxt_any)) - goto out; - - /* system context of vcpu is recieved as hvm context. */ - } - - /* Set HVM-specific parameters */ - if (read_exact(io_fd, magic_pfns, sizeof(magic_pfns))) { - ERROR("error reading magic page addresses"); - goto out; - } - - /* These comms pages need to be zeroed at the start of day */ - for (i = 0; i < NR_PARAMS; i++) { - rc = xc_clear_domain_page(xch, dom, magic_pfns[i]); - if (rc != 0) { - ERROR("error zeroing magic pages: %i", rc); - goto out; - } - rc = xc_set_hvm_param(xch, dom, hvm_params[i], magic_pfns[i]); - if (rc != 0) { - ERROR("error setting HVM params: %i", rc); - goto out; - } - } - rc = xc_set_hvm_param(xch, dom, - HVM_PARAM_STORE_EVTCHN, store_evtchn); - if (rc != 0) { - ERROR("error setting HVM params: %i", rc); - goto out; - } - rc = -1; - *store_mfn = magic_pfns[0]; - - /* Read HVM context */ - if (read_exact(io_fd, &rec_size, sizeof(rec_size))) { - ERROR("error read hvm context size!\n"); - goto out; - } - - hvm_buf = malloc(rec_size); - if (hvm_buf == NULL) { - ERROR("memory alloc for hvm context buffer failed"); - errno = ENOMEM; - goto out; - } - - if (read_exact(io_fd, hvm_buf, rec_size)) { - ERROR("error loading the HVM context"); - goto out; - } - - rc = xc_domain_hvm_setcontext(xch, dom, hvm_buf, rec_size); - if (rc != 0) { - ERROR("error setting the HVM context"); - goto out; - } - - rc = 0; - -out: - if (vcpumap != NULL) - free(vcpumap); - if (hvm_buf != NULL) - free(hvm_buf); - return rc; -} - -/* - * hvm domain requires IO pages allocated when XEN_DOMCTL_arch_setup - */ -static int -xc_ia64_hvm_domain_setup(xc_interface *xch, uint32_t dom) -{ - int rc; - xen_pfn_t pfn_list[] = { - IO_PAGE_START >> PAGE_SHIFT, - BUFFER_IO_PAGE_START >> PAGE_SHIFT, - BUFFER_PIO_PAGE_START >> PAGE_SHIFT, - }; - unsigned long nr_pages = sizeof(pfn_list) / sizeof(pfn_list[0]); - - rc = xc_domain_populate_physmap_exact(xch, dom, nr_pages, - 0, 0, &pfn_list[0]); - if (rc != 0) - PERROR("Could not allocate IO page or buffer io page."); - return rc; -} - -int -xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, - unsigned int store_evtchn, unsigned long *store_mfn, - unsigned int console_evtchn, unsigned long *console_mfn, - unsigned int hvm, unsigned int pae, int superpages, - int no_incr_generationid, - unsigned long *vm_generationid_addr) -{ - DECLARE_DOMCTL; - int rc = 1; - unsigned long ver; - - /* The new domain's shared-info frame number. */ - unsigned long shared_info_frame; - - struct xen_ia64_p2m_table p2m_table; - xc_ia64_p2m_init(&p2m_table); - - /* For info only */ - nr_pfns = 0; - - if ( read_exact(io_fd, &p2m_size, sizeof(unsigned long)) ) - { - ERROR("read: p2m_size"); - goto out; - } - DPRINTF("xc_linux_restore start: p2m_size = %lx\n", p2m_size); - - if (read_exact(io_fd, &ver, sizeof(unsigned long))) { - ERROR("Error when reading version"); - goto out; - } - if (ver != XC_IA64_SR_FORMAT_VER_ONE && - ver != XC_IA64_SR_FORMAT_VER_TWO && - ver != XC_IA64_SR_FORMAT_VER_THREE) { - ERROR("version of save doesn't match"); - goto out; - } - - if (read_exact(io_fd, &domctl.u.arch_setup, sizeof(domctl.u.arch_setup))) { - ERROR("read: domain setup"); - goto out; - } - - if (hvm && xc_ia64_hvm_domain_setup(xch, dom) != 0) - goto out; - - /* Build firmware (will be overwritten). */ - domctl.domain = (domid_t)dom; - domctl.u.arch_setup.flags &= ~XEN_DOMAINSETUP_query; - domctl.u.arch_setup.bp = 0; /* indicate domain restore */ - - domctl.cmd = XEN_DOMCTL_arch_setup; - if (xc_domctl(xch, &domctl)) - goto out; - - /* Get the domain's shared-info frame. */ - domctl.cmd = XEN_DOMCTL_getdomaininfo; - domctl.domain = (domid_t)dom; - if (xc_domctl(xch, &domctl) < 0) { - ERROR("Could not get information on new domain"); - goto out; - } - shared_info_frame = domctl.u.getdomaininfo.shared_info_frame; - - if (ver == XC_IA64_SR_FORMAT_VER_THREE || - ver == XC_IA64_SR_FORMAT_VER_TWO) { - unsigned int memmap_info_num_pages; - unsigned long memmap_size; - xen_ia64_memmap_info_t *memmap_info; - - if (read_exact(io_fd, &memmap_info_num_pages, - sizeof(memmap_info_num_pages))) { - ERROR("read: memmap_info_num_pages"); - goto out; - } - memmap_size = memmap_info_num_pages * PAGE_SIZE; - memmap_info = malloc(memmap_size); - if (memmap_info == NULL) { - ERROR("Could not allocate memory for memmap_info"); - goto out; - } - if (read_exact(io_fd, memmap_info, memmap_size)) { - ERROR("read: memmap_info"); - goto out; - } - if (xc_ia64_p2m_map(&p2m_table, xch, - dom, memmap_info, IA64_DOM0VP_EFP_ALLOC_PTE)) { - ERROR("p2m mapping"); - goto out; - } - free(memmap_info); - } else if (ver == XC_IA64_SR_FORMAT_VER_ONE) { - xen_ia64_memmap_info_t *memmap_info; - efi_memory_desc_t *memdesc; - uint64_t buffer[(sizeof(*memmap_info) + sizeof(*memdesc) + - sizeof(uint64_t) - 1) / sizeof(uint64_t)]; - - memset(buffer, 0, sizeof(buffer)); - memmap_info = (xen_ia64_memmap_info_t *)buffer; - memdesc = (efi_memory_desc_t*)&memmap_info->memdesc[0]; - memmap_info->efi_memmap_size = sizeof(*memdesc); - memmap_info->efi_memdesc_size = sizeof(*memdesc); - memmap_info->efi_memdesc_version = EFI_MEMORY_DESCRIPTOR_VERSION; - - memdesc->type = EFI_MEMORY_DESCRIPTOR_VERSION; - memdesc->phys_addr = 0; - memdesc->virt_addr = 0; - memdesc->num_pages = nr_pfns << (PAGE_SHIFT - EFI_PAGE_SHIFT); - memdesc->attribute = EFI_MEMORY_WB; - - if (xc_ia64_p2m_map(&p2m_table, xch, - dom, memmap_info, IA64_DOM0VP_EFP_ALLOC_PTE)) { - ERROR("p2m mapping"); - goto out; - } - } else { - ERROR("unknown version"); - goto out; - } - - DPRINTF("Reloading memory pages: 0%%\n"); - - while (1) { - unsigned long gmfn; - if (read_exact(io_fd, &gmfn, sizeof(unsigned long))) { - ERROR("Error when reading batch size"); - goto out; - } - if (gmfn == INVALID_MFN) - break; - - if (populate_page_if_necessary(xch, dom, gmfn, &p2m_table) < 0) { - ERROR("can not populate page 0x%lx", gmfn); - goto out; - } - if (read_page(xch, io_fd, dom, gmfn) < 0) - goto out; - } - - DPRINTF("Received all pages\n"); - - if (xc_ia64_recv_unallocated_list(xch, io_fd, dom, &p2m_table)) - goto out; - - if (!hvm) - rc = xc_ia64_pv_recv_context(ver, - xch, io_fd, dom, shared_info_frame, - &p2m_table, store_evtchn, store_mfn, - console_evtchn, console_mfn); - else - rc = xc_ia64_hvm_recv_context(xch, io_fd, dom, shared_info_frame, - &p2m_table, store_evtchn, store_mfn, - console_evtchn, console_mfn); - if (rc) - goto out; - - /* - * Safety checking of saved context: - * 1. user_regs is fine, as Xen checks that on context switch. - * 2. fpu_ctxt is fine, as it can't hurt Xen. - * 3. trap_ctxt needs the code selectors checked. - * 4. ldt base must be page-aligned, no more than 8192 ents, ... - * 5. gdt already done, and further checking is done by Xen. - * 6. check that kernel_ss is safe. - * 7. pt_base is already done. - * 8. debugregs are checked by Xen. - * 9. callback code selectors need checking. - */ - DPRINTF("Domain ready to be built.\n"); - - rc = 0; - - out: - xc_ia64_p2m_unmap(&p2m_table); - - if ((rc != 0) && (dom != 0)) - xc_domain_destroy(xch, dom); - - DPRINTF("Restore exit with rc=%d\n", rc); - - return rc; -} - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/ia64/xc_ia64_linux_save.c b/tools/libxc/ia64/xc_ia64_linux_save.c deleted file mode 100644 index 3440da343a..0000000000 --- a/tools/libxc/ia64/xc_ia64_linux_save.c +++ /dev/null @@ -1,801 +0,0 @@ -/****************************************************************************** - * xc_ia64_linux_save.c - * - * Save the state of a running Linux session. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Copyright (c) 2003, K A Fraser. - * Rewritten for ia64 by Tristan Gingold <tristan.gingold@bull.net> - * - * Copyright (c) 2007 Isaku Yamahata <yamahata@valinux.co.jp> - * Use foreign p2m exposure. - * VTi domain support. - */ - -#include <inttypes.h> -#include <time.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/time.h> - -#include "xg_private.h" -#include "xc_bitops.h" -#include "xc_ia64.h" -#include "xc_ia64_save_restore.h" -#include "xc_efi.h" -#include "xen/hvm/params.h" - -/* -** Default values for important tuning parameters. Can override by passing -** non-zero replacement values to xc_linux_save(). -** -** XXX SMH: should consider if want to be able to override MAX_MBIT_RATE too. -** -*/ -#define DEF_MAX_ITERS (4 - 1) /* limit us to 4 times round loop */ -#define DEF_MAX_FACTOR 3 /* never send more than 3x nr_pfns */ - -/* -** During (live) save/migrate, we maintain a number of bitmaps to track -** which pages we have to send, and to skip. -*/ - -static int -suspend_and_state(int (*suspend)(void*), void* data, - xc_interface *xch, int io_fd, - int dom, xc_dominfo_t *info) -{ - if ( !(*suspend)(data) ) { - ERROR("Suspend request failed"); - return -1; - } - - if ( (xc_domain_getinfo(xch, dom, 1, info) != 1) || - !info->shutdown || (info->shutdown_reason != SHUTDOWN_suspend) ) { - ERROR("Could not get domain info"); - return -1; - } - - return 0; -} - -static inline int -md_is_not_ram(const efi_memory_desc_t *md) -{ - return ((md->type != EFI_CONVENTIONAL_MEMORY) || - (md->attribute != EFI_MEMORY_WB) || - (md->num_pages == 0)); -} - -/* - * Send through a list of all the PFNs that were not in map at the close. - * We send pages which was allocated. However balloon driver may - * decreased after sending page. So we have to check the freed - * page after pausing the domain. - */ -static int -xc_ia64_send_unallocated_list(xc_interface *xch, int io_fd, - struct xen_ia64_p2m_table *p2m_table, - xen_ia64_memmap_info_t *memmap_info, - void *memmap_desc_start, void *memmap_desc_end) -{ - void *p; - efi_memory_desc_t *md; - - unsigned long N; - unsigned long pfntab[1024]; - unsigned int j; - - j = 0; - for (p = memmap_desc_start; - p < memmap_desc_end; - p += memmap_info->efi_memdesc_size) { - md = p; - - if (md_is_not_ram(md)) - continue; - - for (N = md->phys_addr >> PAGE_SHIFT; - N < (md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) >> - PAGE_SHIFT; - N++) { - if (!xc_ia64_p2m_allocated(p2m_table, N)) - j++; - } - } - if (write_exact(io_fd, &j, sizeof(unsigned int))) { - ERROR("Error when writing to state file (6a)"); - return -1; - } - - j = 0; - for (p = memmap_desc_start; - p < memmap_desc_end; - p += memmap_info->efi_memdesc_size) { - md = p; - - if (md_is_not_ram(md)) - continue; - - for (N = md->phys_addr >> PAGE_SHIFT; - N < (md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) >> - PAGE_SHIFT; - N++) { - if (!xc_ia64_p2m_allocated(p2m_table, N)) - pfntab[j++] = N; - if (j == sizeof(pfntab)/sizeof(pfntab[0])) { - if (write_exact(io_fd, &pfntab, sizeof(pfntab[0]) * j)) { - ERROR("Error when writing to state file (6b)"); - return -1; - } - j = 0; - } - } - } - if (j > 0) { - if (write_exact(io_fd, &pfntab, sizeof(pfntab[0]) * j)) { - ERROR("Error when writing to state file (6c)"); - return -1; - } - } - - return 0; -} - -static int -xc_ia64_send_vcpu_context(xc_interface *xch, int io_fd, uint32_t dom, - uint32_t vcpu, vcpu_guest_context_any_t *ctxt_any) -{ - vcpu_guest_context_t *ctxt = &ctxt_any->c; - if (xc_vcpu_getcontext(xch, dom, vcpu, ctxt_any)) { - ERROR("Could not get vcpu context"); - return -1; - } - - if (write_exact(io_fd, ctxt, sizeof(*ctxt))) { - ERROR("Error when writing to state file (1)"); - return -1; - } - - fprintf(stderr, "ip=%016lx, b0=%016lx\n", ctxt->regs.ip, ctxt->regs.b[0]); - return 0; -} - -static int -xc_ia64_send_shared_info(xc_interface *xch, int io_fd, shared_info_t *live_shinfo) -{ - if (write_exact(io_fd, live_shinfo, PAGE_SIZE)) { - ERROR("Error when writing to state file (1)"); - return -1; - } - return 0; -} - -static int -xc_ia64_send_vcpumap(xc_interface *xch, int io_fd, uint32_t dom, - const xc_dominfo_t *info, uint64_t max_virt_cpus, - uint64_t **vcpumapp) -{ - int rc = -1; - unsigned int i; - unsigned long vcpumap_size; - uint64_t *vcpumap = NULL; - - vcpumap_size = bitmap_size(max_virt_cpus); - vcpumap = bitmap_alloc(max_virt_cpus); - if (!vcpumap) { - ERROR("memory alloc for vcpumap"); - goto out; - } - - for (i = 0; i <= info->max_vcpu_id; i++) { - xc_vcpuinfo_t vinfo; - if ((xc_vcpu_getinfo(xch, dom, i, &vinfo) == 0) && vinfo.online) - set_bit(i, vcpumap); - } - - if (write_exact(io_fd, &max_virt_cpus, sizeof(max_virt_cpus))) { - ERROR("write max_virt_cpus"); - goto out; - } - - if (write_exact(io_fd, vcpumap, vcpumap_size)) { - ERROR("write vcpumap"); - goto out; - } - - rc = 0; - - out: - if (rc != 0 && vcpumap != NULL) { - free(vcpumap); - vcpumap = NULL; - } - *vcpumapp = vcpumap; - return rc; -} - - -static int -xc_ia64_pv_send_context(xc_interface *xch, int io_fd, uint32_t dom, - const xc_dominfo_t *info, shared_info_t *live_shinfo) -{ - int rc = -1; - unsigned int i; - - /* vcpu map */ - uint64_t *vcpumap = NULL; - if (xc_ia64_send_vcpumap(xch, io_fd, dom, info, XEN_LEGACY_MAX_VCPUS, - &vcpumap)) - goto out; - - /* vcpu context */ - for (i = 0; i <= info->max_vcpu_id; i++) { - /* A copy of the CPU context of the guest. */ - vcpu_guest_context_any_t ctxt_any; - vcpu_guest_context_t *ctxt = &ctxt_any.c; - - char *mem; - - if (!test_bit(i, vcpumap)) - continue; - - if (xc_ia64_send_vcpu_context(xch, io_fd, dom, i, &ctxt_any)) - goto out; - - mem = xc_map_foreign_range(xch, dom, PAGE_SIZE, - PROT_READ|PROT_WRITE, ctxt->privregs_pfn); - if (mem == NULL) { - ERROR("cannot map privreg page"); - goto out; - } - if (write_exact(io_fd, mem, PAGE_SIZE)) { - ERROR("Error when writing privreg to state file (5)"); - munmap(mem, PAGE_SIZE); - goto out; - } - munmap(mem, PAGE_SIZE); - } - - rc = xc_ia64_send_shared_info(xch, io_fd, live_shinfo); - - out: - if (vcpumap != NULL) - free(vcpumap); - return rc; -} - -static int -xc_ia64_hvm_send_context(xc_interface *xch, int io_fd, uint32_t dom, - const xc_dominfo_t *info, shared_info_t *live_shinfo) -{ - int rc = -1; - unsigned int i; - - /* vcpu map */ - uint64_t *vcpumap = NULL; - - /* HVM: magic frames for ioreqs and xenstore comms */ - const int hvm_params[] = { - HVM_PARAM_STORE_PFN, - HVM_PARAM_IOREQ_PFN, - HVM_PARAM_BUFIOREQ_PFN, - HVM_PARAM_BUFPIOREQ_PFN, - }; - const int NR_PARAMS = sizeof(hvm_params) / sizeof(hvm_params[0]); - /* ioreq_pfn, bufioreq_pfn, store_pfn */ - uint64_t magic_pfns[NR_PARAMS]; - - /* HVM: a buffer for holding HVM contxt */ - uint64_t rec_size; - uint64_t hvm_buf_size = 0; - uint8_t *hvm_buf = NULL; - - if (xc_ia64_send_shared_info(xch, io_fd, live_shinfo)) - return -1; - - /* vcpu map */ - if (xc_ia64_send_vcpumap(xch, io_fd, dom, info, XEN_LEGACY_MAX_VCPUS, - &vcpumap)) - goto out; - - /* vcpu context */ - for (i = 0; i <= info->max_vcpu_id; i++) { - /* A copy of the CPU context of the guest. */ - vcpu_guest_context_any_t ctxt_any; - - if (!test_bit(i, vcpumap)) - continue; - - if (xc_ia64_send_vcpu_context(xch, io_fd, dom, i, &ctxt_any)) - goto out; - - /* system context of vcpu is sent as hvm context. */ - } - - /* Save magic-page locations. */ - memset(magic_pfns, 0, sizeof(magic_pfns)); - for (i = 0; i < NR_PARAMS; i++) { - if (xc_get_hvm_param(xch, dom, hvm_params[i], &magic_pfns[i])) { - PERROR("Error when xc_get_hvm_param"); - goto out; - } - } - - if (write_exact(io_fd, magic_pfns, sizeof(magic_pfns))) { - ERROR("Error when writing to state file (7)"); - goto out; - } - - /* Need another buffer for HVM context */ - hvm_buf_size = xc_domain_hvm_getcontext(xch, dom, 0, 0); - if (hvm_buf_size == -1) { - ERROR("Couldn't get HVM context size from Xen"); - goto out; - } - - hvm_buf = malloc(hvm_buf_size); - if (!hvm_buf) { - ERROR("Couldn't allocate memory"); - goto out; - } - - /* Get HVM context from Xen and save it too */ - rec_size = xc_domain_hvm_getcontext(xch, dom, hvm_buf, hvm_buf_size); - if (rec_size == -1) { - ERROR("HVM:Could not get hvm buffer"); - goto out; - } - - if (write_exact(io_fd, &rec_size, sizeof(rec_size))) { - ERROR("error write hvm buffer size"); - goto out; - } - - if (write_exact(io_fd, hvm_buf, rec_size)) { - ERROR("write HVM info failed!\n"); - goto out; - } - - rc = 0; -out: - if (hvm_buf != NULL) - free(hvm_buf); - if (vcpumap != NULL) - free(vcpumap); - return rc; -} - -int -xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters, - uint32_t max_factor, uint32_t flags, - struct save_callbacks* callbacks, int hvm, - unsigned long vm_generationid_addr) -{ - DECLARE_DOMCTL; - xc_dominfo_t info; - - int rc = 1; - - int debug = (flags & XCFLAGS_DEBUG); - int live = (flags & XCFLAGS_LIVE); - - /* The new domain's shared-info frame number. */ - unsigned long shared_info_frame; - - /* Live mapping of shared info structure */ - shared_info_t *live_shinfo = NULL; - - /* Iteration number. */ - int iter; - - /* Number of pages sent in the last iteration (live only). */ - unsigned int sent_last_iter; - - /* Number of pages sent (live only). */ - unsigned int total_sent = 0; - - /* total number of pages used by the current guest */ - unsigned long p2m_size; - - /* Size of the shadow bitmap (live only). */ - unsigned int bitmap_size = 0; - - /* True if last iteration. */ - int last_iter = 0; - - /* Bitmap of pages to be sent. */ - DECLARE_HYPERCALL_BUFFER(unsigned long, to_send); - /* Bitmap of pages not to be sent (because dirtied). */ - DECLARE_HYPERCALL_BUFFER(unsigned long, to_skip); - - char *mem; - - /* for foreign p2m exposure */ - unsigned long memmap_info_num_pages; - /* Unsigned int was used before. To keep file format compatibility. */ - unsigned int memmap_info_num_pages_to_send; - unsigned long memmap_size = 0; - xen_ia64_memmap_info_t *memmap_info = NULL; - void *memmap_desc_start; - void *memmap_desc_end; - void *p; - efi_memory_desc_t *md; - struct xen_ia64_p2m_table p2m_table; - - if ( hvm && !callbacks->switch_qemu_logdirty ) - { - ERROR("No switch_qemu_logdirty callback given."); - errno = EINVAL; - return 1; - } - - xc_ia64_p2m_init(&p2m_table); - - if (debug) - fprintf(stderr, "xc_linux_save (ia64): started dom=%d\n", dom); - - /* If no explicit control parameters given, use defaults */ - if (!max_iters) - max_iters = DEF_MAX_ITERS; - if (!max_factor) - max_factor = DEF_MAX_FACTOR; - - //initialize_mbit_rate(); - - if (xc_domain_getinfo(xch, dom, 1, &info) != 1) { - ERROR("Could not get domain info"); - return 1; - } - - shared_info_frame = info.shared_info_frame; - -#if 0 - /* cheesy sanity check */ - if ((info.max_memkb >> (PAGE_SHIFT - 10)) > max_mfn) { - ERROR("Invalid state record -- pfn count out of range: %lu", - (info.max_memkb >> (PAGE_SHIFT - 10))); - goto out; - } -#endif - - /* Map the shared info frame */ - live_shinfo = xc_map_foreign_range(xch, dom, PAGE_SIZE, - PROT_READ, shared_info_frame); - if (!live_shinfo) { - ERROR("Couldn't map live_shinfo"); - goto out; - } - - p2m_size = xc_domain_maximum_gpfn(xch, dom) + 1; - - /* This is expected by xm restore. */ - if (write_exact(io_fd, &p2m_size, sizeof(unsigned long))) { - ERROR("write: p2m_size"); - goto out; - } - - /* xc_linux_restore starts to read here. */ - /* Write a version number. This can avoid searching for a stupid bug - if the format change. - The version is hard-coded, don't forget to change the restore code - too! */ - { - unsigned long version = XC_IA64_SR_FORMAT_VER_CURRENT; - - if (write_exact(io_fd, &version, sizeof(unsigned long))) { - ERROR("write: version"); - goto out; - } - } - - domctl.cmd = XEN_DOMCTL_arch_setup; - domctl.domain = (domid_t)dom; - domctl.u.arch_setup.flags = XEN_DOMAINSETUP_query; - if (xc_domctl(xch, &domctl) < 0) { - ERROR("Could not get domain setup"); - goto out; - } - if (write_exact(io_fd, &domctl.u.arch_setup, - sizeof(domctl.u.arch_setup))) { - ERROR("write: domain setup"); - goto out; - } - - /* Domain is still running at this point */ - if (live) { - - if (xc_shadow_control(xch, dom, - XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY, - NULL, 0, NULL, 0, NULL ) < 0) { - ERROR("Couldn't enable shadow mode"); - goto out; - } - - last_iter = 0; - - bitmap_size = ((p2m_size + BITS_PER_LONG-1) & ~(BITS_PER_LONG-1)) / 8; - to_send = xc_hypercall_buffer_alloc(xch, to_send, bitmap_size); - to_skip = xc_hypercall_buffer_alloc(xch, to_skip, bitmap_size); - - if (!to_send || !to_skip) { - ERROR("Couldn't allocate bitmap array"); - goto out; - } - - /* Initially all the pages must be sent. */ - memset(to_send, 0xff, bitmap_size); - - /* Enable qemu-dm logging dirty pages to xen */ - if (hvm && callbacks->switch_qemu_logdirty(dom, 1, callbacks->data)) { - ERROR("Unable to enable qemu log-dirty mode"); - goto out; - } - } else { - - /* This is a non-live suspend. Issue the call back to get the - domain suspended */ - - last_iter = 1; - - if (suspend_and_state(callbacks->suspend, callbacks->data, xch, - io_fd, dom, &info)) { - ERROR("Domain appears not to have suspended"); - goto out; - } - - } - - /* copy before use in case someone updating them */ - if (xc_ia64_copy_memmap(xch, info.domid, live_shinfo, - &memmap_info, &memmap_info_num_pages) != 0) { - PERROR("Could not copy memmap"); - goto out; - } - memmap_size = memmap_info_num_pages << PAGE_SHIFT; - - if (xc_ia64_p2m_map(&p2m_table, xch, dom, memmap_info, 0) < 0) { - PERROR("xc_ia64_p2m_map"); - goto out; - } - memmap_info_num_pages_to_send = memmap_info_num_pages; - if (write_exact(io_fd, &memmap_info_num_pages_to_send, - sizeof(memmap_info_num_pages_to_send))) { - PERROR("write: arch.memmap_info_num_pages"); - goto out; - } - if (write_exact(io_fd, memmap_info, memmap_size)) { - PERROR("write: memmap_info"); - goto out; - } - - sent_last_iter = p2m_size; - - copypages: - for (iter = 1; ; iter++) { - unsigned int sent_this_iter, skip_this_iter; - unsigned long N; - - sent_this_iter = 0; - skip_this_iter = 0; - - /* Dirtied pages won't be saved. - slightly wasteful to peek the whole array evey time, - but this is fast enough for the moment. */ - if (!last_iter) { - if (xc_shadow_control(xch, dom, - XEN_DOMCTL_SHADOW_OP_PEEK, - HYPERCALL_BUFFER(to_skip), p2m_size, - NULL, 0, NULL) != p2m_size) { - ERROR("Error peeking shadow bitmap"); - goto out; - } - } - - /* Start writing out the saved-domain record. */ - memmap_desc_start = &memmap_info->memdesc; - memmap_desc_end = memmap_desc_start + memmap_info->efi_memmap_size; - for (p = memmap_desc_start; - p < memmap_desc_end; - p += memmap_info->efi_memdesc_size) { - md = p; - if (md_is_not_ram(md)) - continue; - - for (N = md->phys_addr >> PAGE_SHIFT; - N < (md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) >> - PAGE_SHIFT; - N++) { - - if (!xc_ia64_p2m_allocated(&p2m_table, N)) - continue; - - if (!last_iter) { - if (test_bit(N, to_skip) && test_bit(N, to_send)) - skip_this_iter++; - if (test_bit(N, to_skip) || !test_bit(N, to_send)) - continue; - } else if (live) { - if (!test_bit(N, to_send)) - continue; - } - - if (debug) - fprintf(stderr, "xc_linux_save: page %lx (%lu/%lu)\n", - xc_ia64_p2m_mfn(&p2m_table, N), - N, p2m_size); - - mem = xc_map_foreign_range(xch, dom, PAGE_SIZE, - PROT_READ|PROT_WRITE, N); - if (mem == NULL) { - /* The page may have move. - It will be remarked dirty. - FIXME: to be tracked. */ - fprintf(stderr, "cannot map mfn page %lx gpfn %lx: %s\n", - xc_ia64_p2m_mfn(&p2m_table, N), - N, xc_strerror(xch, errno)); - goto out; - } - - if (write_exact(io_fd, &N, sizeof(N))) { - ERROR("write: p2m_size"); - munmap(mem, PAGE_SIZE); - goto out; - } - - if (write(io_fd, mem, PAGE_SIZE) != PAGE_SIZE) { - ERROR("Error when writing to state file (5)"); - munmap(mem, PAGE_SIZE); - goto out; - } - munmap(mem, PAGE_SIZE); - sent_this_iter++; - total_sent++; - } - } - - if (last_iter) - break; - - DPRINTF(" %d: sent %d, skipped %d\n", - iter, sent_this_iter, skip_this_iter ); - - if (live) { - if ( /* ((sent_this_iter > sent_last_iter) && RATE_IS_MAX()) || */ - (iter >= max_iters) || (sent_this_iter+skip_this_iter < 50) || - (total_sent > p2m_size*max_factor)) { - DPRINTF("Start last iteration\n"); - last_iter = 1; - - if (suspend_and_state(callbacks->suspend, callbacks->data, - xch, io_fd, dom, &info)) { - ERROR("Domain appears not to have suspended"); - goto out; - } - } - - /* Pages to be sent are pages which were dirty. */ - if (xc_shadow_control(xch, dom, - XEN_DOMCTL_SHADOW_OP_CLEAN, - HYPERCALL_BUFFER(to_send), p2m_size, - NULL, 0, NULL ) != p2m_size) { - ERROR("Error flushing shadow PT"); - goto out; - } - - sent_last_iter = sent_this_iter; - - //print_stats(xch, dom, sent_this_iter, &stats, 1); - } - } - - fprintf(stderr, "All memory is saved\n"); - - /* terminate */ - { - unsigned long pfn = INVALID_MFN; - if (write_exact(io_fd, &pfn, sizeof(pfn))) { - ERROR("Error when writing to state file (6)"); - goto out; - } - } - - if (xc_ia64_send_unallocated_list(xch, io_fd, &p2m_table, - memmap_info, - memmap_desc_start, memmap_desc_end)) - goto out; - - if (!hvm) - rc = xc_ia64_pv_send_context(xch, io_fd, - dom, &info, live_shinfo); - else - rc = xc_ia64_hvm_send_context(xch, io_fd, - dom, &info, live_shinfo); - if (rc) - goto out; - - /* Success! */ - rc = 0; - - out: - if ( !rc && callbacks->postcopy ) - callbacks->postcopy(callbacks->data); - - /* Flush last write and discard cache for file. */ - discard_file_cache(xch, io_fd, 1 /* flush */); - - /* checkpoint_cb can spend arbitrarily long in between rounds */ - if (!rc && callbacks->checkpoint && - callbacks->checkpoint(callbacks->data) > 0) - { - /* reset stats timer */ - //print_stats(xch, dom, 0, &stats, 0); - - rc = 1; - /* last_iter = 1; */ - if ( suspend_and_state(callbacks->suspend, callbacks->data, xch, - io_fd, dom, &info) ) - { - ERROR("Domain appears not to have suspended"); - goto out; - } - DPRINTF("SUSPEND shinfo %08lx\n", info.shared_info_frame); - //print_stats(xch, dom, 0, &stats, 1); - - if ( xc_shadow_control(xch, dom, - XEN_DOMCTL_SHADOW_OP_CLEAN, HYPERCALL_BUFFER(to_send), - p2m_size, NULL, 0, NULL) != p2m_size ) - { - ERROR("Error flushing shadow PT"); - } - - goto copypages; - } - - if (live) { - if (xc_shadow_control(xch, dom, - XEN_DOMCTL_SHADOW_OP_OFF, - NULL, 0, NULL, 0, NULL ) < 0) { - DPRINTF("Warning - couldn't disable shadow mode"); - } - if ( hvm && - callbacks->switch_qemu_logdirty(dom, 0, callbacks->data) ) { - DPRINTF("Warning - couldn't disable qemu log-dirty mode"); - } - } - - xc_hypercall_buffer_free(xch, to_send); - xc_hypercall_buffer_free(xch, to_skip); - if (live_shinfo) - munmap(live_shinfo, PAGE_SIZE); - if (memmap_info) - free(memmap_info); - xc_ia64_p2m_unmap(&p2m_table); - - fprintf(stderr,"Save exit rc=%d\n",rc); - - return !!rc; -} - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/ia64/xc_ia64_save_restore.h b/tools/libxc/ia64/xc_ia64_save_restore.h deleted file mode 100644 index d392fc8c7c..0000000000 --- a/tools/libxc/ia64/xc_ia64_save_restore.h +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************** - * xc_ia64_save_restore.h - * - * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp> - * VA Linux Systems Japan K.K. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef XC_IA64_SAVE_RESTORE_H -#define XC_IA64_SR_H - - /* introduced changeset 10692:306d7857928c of xen-ia64-unstable.ht */ -#define XC_IA64_SR_FORMAT_VER_ONE 1UL - /* using foreign p2m exposure version */ -#define XC_IA64_SR_FORMAT_VER_TWO 2UL - /* only pv change: send vcpumap and all vcpu context */ -#define XC_IA64_SR_FORMAT_VER_THREE 3UL -#define XC_IA64_SR_FORMAT_VER_MAX 3UL - -#define XC_IA64_SR_FORMAT_VER_CURRENT XC_IA64_SR_FORMAT_VER_THREE - - -#endif /* XC_IA64_SAVE_RESTORE_H */ - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/ia64/xc_ia64_stubs.c b/tools/libxc/ia64/xc_ia64_stubs.c deleted file mode 100644 index 9691acb03e..0000000000 --- a/tools/libxc/ia64/xc_ia64_stubs.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "xg_private.h" -#include "xc_efi.h" -#include "xc_ia64.h" - -/* this is a very ugly way of getting FPSR_DEFAULT. struct ia64_fpreg is - * mysteriously declared in two places: /usr/include/asm/fpu.h and - * /usr/include/bits/sigcontext.h. The former also defines FPSR_DEFAULT, - * the latter doesn't but is included (indirectly) by xg_private.h */ -#define __ASSEMBLY__ -#include <asm/fpu.h> -#undef __IA64_UL -#define __IA64_UL(x) ((unsigned long)(x)) -#undef __ASSEMBLY__ - -unsigned long -xc_ia64_fpsr_default(void) -{ - return FPSR_DEFAULT; -} - - -/* It is possible to get memmap_info and memmap by - foreign domain page mapping. But it's racy. Use hypercall to avoid race. */ -static int -xc_ia64_get_memmap(xc_interface *xch, - uint32_t domid, char *buf, unsigned long bufsize) -{ - privcmd_hypercall_t hypercall; - DECLARE_HYPERCALL_BOUNCE(buf, bufsize, XC_HYPERCALL_BUFFER_BOUNCE_OUT); - int ret; - - if ( xc_hypercall_bounce_pre(xch, pfn_buf) ) - { - PERROR("xc_get_pfn_list: pfn_buf bounce failed"); - return -1; - } - - hypercall.op = __HYPERVISOR_ia64_dom0vp_op; - hypercall.arg[0] = IA64_DOM0VP_get_memmap; - hypercall.arg[1] = domid; - hypercall.arg[2] = HYPERCALL_BUFFER_AS_ARG(buf); - hypercall.arg[3] = bufsize; - hypercall.arg[4] = 0; - - ret = do_xen_hypercall(xch, &hypercall); - xc_hypercall_bounce_post(xc, buf); - return ret; -} - -int -xc_ia64_copy_memmap(xc_interface *xch, uint32_t domid, shared_info_t *live_shinfo, - xen_ia64_memmap_info_t **memmap_info_p, - unsigned long *memmap_info_num_pages_p) -{ - unsigned long gpfn_max_prev; - unsigned long gpfn_max_post; - - unsigned long num_pages; - unsigned long num_pages_post; - unsigned long memmap_size; - xen_ia64_memmap_info_t *memmap_info; - - int ret; - - gpfn_max_prev = xc_domain_maximum_gpfn(xch, domid); - if (gpfn_max_prev < 0) - return -1; - - again: - num_pages = live_shinfo->arch.memmap_info_num_pages; - if (num_pages == 0) { - ERROR("num_pages 0x%x", num_pages); - return -1; - } - - memmap_size = num_pages << PAGE_SHIFT; - memmap_info = malloc(memmap_size); - if (memmap_info == NULL) - return -1; - ret = xc_ia64_get_memmap(xch, - domid, (char*)memmap_info, memmap_size); - if (ret != 0) { - free(memmap_info); - return -1; - } - xen_rmb(); - num_pages_post = live_shinfo->arch.memmap_info_num_pages; - if (num_pages != num_pages_post) { - free(memmap_info); - num_pages = num_pages_post; - goto again; - } - - gpfn_max_post = xc_domain_maximum_gpfn(xch, domid); - if (gpfn_max_prev < 0) { - free(memmap_info); - return -1; - } - if (gpfn_max_post > gpfn_max_prev) { - free(memmap_info); - gpfn_max_prev = gpfn_max_post; - goto again; - } - - /* reject unknown memmap */ - if (memmap_info->efi_memdesc_size != sizeof(efi_memory_desc_t) || - (memmap_info->efi_memmap_size / memmap_info->efi_memdesc_size) == 0 || - memmap_info->efi_memmap_size > - (num_pages << PAGE_SHIFT) - sizeof(memmap_info) || - memmap_info->efi_memdesc_version != EFI_MEMORY_DESCRIPTOR_VERSION) { - PERROR("unknown memmap header. defaulting to compat mode."); - free(memmap_info); - return -1; - } - - *memmap_info_p = memmap_info; - if (memmap_info_num_pages_p != NULL) - *memmap_info_num_pages_p = num_pages; - - return 0; -} - -/* - * XXX from xen/include/asm-ia64/linux-xen/asm/pgtable.h - * Should PTRS_PER_PTE be exported by arch-ia64.h? - */ -#define PTRS_PER_PTE (1UL << (PAGE_SHIFT - 3)) - -static void* -xc_ia64_map_foreign_p2m(xc_interface *xch, uint32_t dom, - struct xen_ia64_memmap_info *memmap_info, - unsigned long flags, unsigned long *p2m_size_p) -{ - DECLARE_HYPERCALL_BOUNCE(memmap_info, sizeof(*memmap_info) + memmap_info->efi_memmap_size, XC_HYPERCALL_BOUNCE_BUFFER_IN); - unsigned long gpfn_max; - unsigned long p2m_size; - void *addr; - privcmd_hypercall_t hypercall; - int ret; - int saved_errno; - - gpfn_max = xc_domain_maximum_gpfn(xch, dom); - if (gpfn_max < 0) - return NULL; - p2m_size = - (((gpfn_max + 1) + PTRS_PER_PTE - 1) / PTRS_PER_PTE) << PAGE_SHIFT; - addr = mmap(NULL, p2m_size, PROT_READ, MAP_SHARED, xch->fd, 0); - if (addr == MAP_FAILED) - return NULL; - if (xc_hypercall_bounce_pre(xc, memmap_info)) { - saved_errno = errno; - munmap(addr, p2m_size); - errno = saved_errno; - return NULL; - } - - hypercall.op = __HYPERVISOR_ia64_dom0vp_op; - hypercall.arg[0] = IA64_DOM0VP_expose_foreign_p2m; - hypercall.arg[1] = (unsigned long)addr; - hypercall.arg[2] = dom; - hypercall.arg[3] = HYPERCALL_BUFFER_AS_ARG(memmap_info); - hypercall.arg[4] = flags; - - ret = do_xen_hypercall(xch, &hypercall); - saved_errno = errno; - xc_hypercall_bounce_post(xch, memmap_info); - if (ret < 0) { - munmap(addr, p2m_size); - errno = saved_errno; - return NULL; - } - - *p2m_size_p = p2m_size; - return addr; -} - -void -xc_ia64_p2m_init(struct xen_ia64_p2m_table *p2m_table) -{ - p2m_table->size = 0; - p2m_table->p2m = NULL; -} - -int -xc_ia64_p2m_map(struct xen_ia64_p2m_table *p2m_table, xc_interface *xch, - uint32_t domid, struct xen_ia64_memmap_info *memmap_info, - unsigned long flag) -{ - p2m_table->p2m = xc_ia64_map_foreign_p2m(xch, domid, memmap_info, - flag, &p2m_table->size); - if (p2m_table->p2m == NULL) { - PERROR("Could not map foreign p2m. falling back to old method"); - return -1; - } - return 0; -} - -void -xc_ia64_p2m_unmap(struct xen_ia64_p2m_table *p2m_table) -{ - if (p2m_table->p2m == NULL) - return; - munmap(p2m_table->p2m, p2m_table->size); - //p2m_table->p2m = NULL; - //p2m_table->size = 0; -} - -/* - * XXX from xen/include/asm-ia64/linux-xen/asm/pgtable.h - * Should those be exported by arch-ia64.h? - */ -#define _PAGE_P_BIT 0 -#define _PAGE_P (1UL << _PAGE_P_BIT) /* page present bit */ -#define _PAGE_PGC_ALLOCATED_BIT 59 /* _PGC_allocated */ -#define _PAGE_PGC_ALLOCATED (1UL << _PAGE_PGC_ALLOCATED_BIT) -#define _PAGE_IO_BIT 60 -#define _PAGE_IO (1UL << _PAGE_IO_BIT) - -#define IA64_MAX_PHYS_BITS 50 /* max. number of physical address bits (architected) */ -#define _PAGE_PPN_MASK (((1UL << IA64_MAX_PHYS_BITS) - 1) & ~0xfffUL) - -int -xc_ia64_p2m_present(struct xen_ia64_p2m_table *p2m_table, unsigned long gpfn) -{ - if (sizeof(p2m_table->p2m[0]) * gpfn < p2m_table->size) { - unsigned long pte = p2m_table->p2m[gpfn]; - return !!((pte & _PAGE_P) && !(pte & _PAGE_IO)); - } - return 0; -} - -int -xc_ia64_p2m_allocated(struct xen_ia64_p2m_table *p2m_table, unsigned long gpfn) -{ - if (sizeof(p2m_table->p2m[0]) * gpfn < p2m_table->size) { - unsigned long pte = p2m_table->p2m[gpfn]; - return !!((pte & _PAGE_P) && (pte & _PAGE_PGC_ALLOCATED) && - !(pte & _PAGE_IO)); - } - return 0; -} - -unsigned long -xc_ia64_p2m_mfn(struct xen_ia64_p2m_table *p2m_table, unsigned long gpfn) -{ - unsigned long pte; - - if (sizeof(p2m_table->p2m[0]) * gpfn >= p2m_table->size) - return INVALID_MFN; - pte = p2m_table->p2m[gpfn]; - if (pte & _PAGE_IO) - return INVALID_MFN; - if (!(pte & _PAGE_P)) - return INVALID_MFN; - return (pte & _PAGE_PPN_MASK) >> PAGE_SHIFT; -} - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/xc_core.c b/tools/libxc/xc_core.c index d711f1b727..802fcaeff4 100644 --- a/tools/libxc/xc_core.c +++ b/tools/libxc/xc_core.c @@ -31,7 +31,6 @@ * | .shstrtab | * | .note.Xen | * | .xen_prstatus | - * | .xen_ia64_mmapped_regs if ia64 | * | .xen_shared_info if present | * | .xen_pages | * | .xen_p2m or .xen_pfn | @@ -48,9 +47,6 @@ * |.xen_prstatus | * | vcpu_guest_context_t[nr_vcpus] | * +--------------------------------------------------------+ - * |.xen_ia64_mmapped_regs if ia64 pv | - * | mmapped_regs_t[nr_vcpus] | - * +--------------------------------------------------------+ * |.xen_shared_info if possible | * +--------------------------------------------------------+ * |.xen_pages | diff --git a/tools/libxc/xc_core.h b/tools/libxc/xc_core.h index 358a8c1956..3f301d9f20 100644 --- a/tools/libxc/xc_core.h +++ b/tools/libxc/xc_core.h @@ -33,8 +33,6 @@ #define XEN_DUMPCORE_SEC_PFN ".xen_pfn" #define XEN_DUMPCORE_SEC_PAGES ".xen_pages" -#define XEN_DUMPCORE_SEC_IA64_MAPPED_REGS ".xen_ia64_mapped_regs" - /* elf note name */ #define XEN_DUMPCORE_ELFNOTE_NAME "Xen" /* note numbers are defined in xen/elfnote.h */ @@ -153,8 +151,6 @@ int xc_core_arch_map_p2m_writable(xc_interface *xch, unsigned int guest_width, #if defined (__i386__) || defined (__x86_64__) # include "xc_core_x86.h" -#elif defined (__ia64__) -# include "xc_core_ia64.h" #elif defined (__arm__) # include "xc_core_arm.h" #else diff --git a/tools/libxc/xc_core_ia64.c b/tools/libxc/xc_core_ia64.c deleted file mode 100644 index 7411e3e22f..0000000000 --- a/tools/libxc/xc_core_ia64.c +++ /dev/null @@ -1,380 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp> - * VA Linux Systems Japan K.K. - * - */ - -#include "xg_private.h" -#include "xc_core.h" -#include "xc_efi.h" -#include "xc_dom.h" -#include <inttypes.h> - -int -xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt, - unsigned long pfn) -{ - if (arch_ctxt->p2m_table.p2m == NULL) - return 1; /* default to trying to map the page */ - - return xc_ia64_p2m_present(&arch_ctxt->p2m_table, pfn); -} - -static int -xc_memory_map_cmp(const void *lhs__, const void *rhs__) -{ - const struct xc_core_memory_map *lhs = - (const struct xc_core_memory_map *)lhs__; - const struct xc_core_memory_map *rhs = - (const struct xc_core_memory_map *)rhs__; - - if (lhs->addr < rhs->addr) - return -1; - if (lhs->addr > rhs->addr) - return 1; - - /* memory map overlap isn't allowed. complain */ -#ifdef DEBUG - fprintf(stderr, "duplicated addresses are detected " - "(0x%" PRIx64 ", 0x%" PRIx64 "), " - "(0x%" PRIx64 ", 0x%" PRIx64 ")\n", - lhs->addr, lhs->size, rhs->addr, rhs->size); -#endif - return 0; -} - -int -xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info) -{ - /* - * on ia64, both paravirtualize domain and hvm domain are - * auto_translated_physmap mode - */ - return 1; -} - -/* see setup_guest() @ xc_linux_build.c */ -static int -memory_map_get_old_domu(xc_interface *xch, xc_dominfo_t *info, - shared_info_any_t *live_shinfo, - xc_core_memory_map_t **mapp, unsigned int *nr_entries) -{ - xc_core_memory_map_t *map = NULL; - - map = malloc(sizeof(*map)); - if ( map == NULL ) - { - PERROR("Could not allocate memory"); - goto out; - } - - map->addr = 0; - map->size = info->max_memkb * 1024; - - *mapp = map; - *nr_entries = 1; - return 0; - -out: - if ( map != NULL ) - free(map); - return -1; -} - -/* see setup_guest() @ xc_ia64_hvm_build.c */ -static int -memory_map_get_old_hvm(xc_interface *xch, xc_dominfo_t *info, - shared_info_any_t *live_shinfo, - xc_core_memory_map_t **mapp, unsigned int *nr_entries) -{ - const xc_core_memory_map_t gfw_map[] = { - {IO_PAGE_START, IO_PAGE_SIZE}, - {STORE_PAGE_START, STORE_PAGE_SIZE}, - {BUFFER_IO_PAGE_START, BUFFER_IO_PAGE_SIZE}, - {BUFFER_PIO_PAGE_START, BUFFER_PIO_PAGE_SIZE}, - {GFW_START, GFW_SIZE}, - }; - const unsigned int nr_gfw_map = sizeof(gfw_map)/sizeof(gfw_map[0]); - xc_core_memory_map_t *map = NULL; - unsigned int i; - -#define VGA_IO_END (VGA_IO_START + VGA_IO_SIZE) - /* [0, VGA_IO_START) [VGA_IO_END, 3GB), [4GB, ...) + gfw_map */ - map = malloc((3 + nr_gfw_map) * sizeof(*map)); - if ( map == NULL ) - { - PERROR("Could not allocate memory"); - goto out; - } - - for ( i = 0; i < nr_gfw_map; i++ ) - map[i] = gfw_map[i]; - map[i].addr = 0; - map[i].size = info->max_memkb * 1024; - i++; - if ( map[i - 1].size < VGA_IO_END ) - { - map[i - 1].size = VGA_IO_START; - } - else - { - map[i].addr = VGA_IO_END; - map[i].size = map[i - 1].size - VGA_IO_END; - map[i - 1].size = VGA_IO_START; - i++; - if ( map[i - 1].addr + map[i - 1].size > MMIO_START ) - { - map[i].addr = MMIO_START + 1 * MEM_G; - map[i].size = map[i - 1].addr + map[i - 1].size - MMIO_START; - map[i - 1].size = MMIO_START - map[i - 1].addr; - i++; - } - } - *mapp = map; - *nr_entries = i; - qsort(map, *nr_entries, sizeof(map[0]), &xc_memory_map_cmp); - return 0; - -out: - if ( map != NULL ) - free(map); - return -1; -} - -static int -memory_map_get_old(xc_interface *xch, xc_dominfo_t *info, - shared_info_any_t *live_shinfo, - xc_core_memory_map_t **mapp, unsigned int *nr_entries) -{ - if ( info->hvm ) - return memory_map_get_old_hvm(xch, info, live_shinfo, - mapp, nr_entries); - if ( live_shinfo == NULL ) - return -1; - return memory_map_get_old_domu(xch, info, live_shinfo, - mapp, nr_entries); -} - -int -xc_core_arch_memory_map_get(xc_interface *xch, - struct xc_core_arch_context *arch_ctxt, - xc_dominfo_t *info, - shared_info_any_t *live_shinfo, - xc_core_memory_map_t **mapp, - unsigned int *nr_entries) -{ - int ret = -1; - - xen_ia64_memmap_info_t *memmap_info = NULL; - xc_core_memory_map_t *map; - char *start; - char *end; - char *p; - efi_memory_desc_t *md; - - if ( live_shinfo == NULL ) - { - ERROR("can't access shared info"); - goto old; - } - - /* copy before use in case someone updating them */ - if (xc_ia64_copy_memmap(xch, info->domid, &live_shinfo->s, - &memmap_info, NULL)) { - goto old; - } - - *nr_entries = memmap_info->efi_memmap_size / memmap_info->efi_memdesc_size; - map = malloc(*nr_entries * sizeof(*md)); - if ( map == NULL ) - { - PERROR("Could not allocate memory for memmap."); - free(memmap_info); - return -1; - } - *mapp = map; - - *nr_entries = 0; - start = (char*)&memmap_info->memdesc; - end = start + memmap_info->efi_memmap_size; - for ( p = start; p < end; p += memmap_info->efi_memdesc_size ) - { - md = (efi_memory_desc_t*)p; - if ( md->type != EFI_CONVENTIONAL_MEMORY || - md->attribute != EFI_MEMORY_WB || - md->num_pages == 0 ) - continue; - - map[*nr_entries].addr = md->phys_addr; - map[*nr_entries].size = md->num_pages << EFI_PAGE_SHIFT; - (*nr_entries)++; - } - ret = 0; - - xc_ia64_p2m_map(&arch_ctxt->p2m_table, xch, info->domid, - memmap_info, 0); - if ( memmap_info != NULL ) - free(memmap_info); - qsort(map, *nr_entries, sizeof(map[0]), &xc_memory_map_cmp); - return ret; - -old: - DPRINTF("Falling back old method.\n"); - return memory_map_get_old(xch, info, live_shinfo, mapp, nr_entries); -} - -int -xc_core_arch_map_p2m(xc_interface *xch, unsigned int guest_width, xc_dominfo_t *info, - shared_info_any_t *live_shinfo, xen_pfn_t **live_p2m, - unsigned long *pfnp) -{ - /* - * on ia64, both paravirtualize domain and hvm domain are - * auto_translated_physmap mode - */ - errno = ENOSYS; - return -1; -} - -void -xc_core_arch_context_init(struct xc_core_arch_context* arch_ctxt) -{ - arch_ctxt->mapped_regs_size = - (XMAPPEDREGS_SIZE < PAGE_SIZE) ? PAGE_SIZE: XMAPPEDREGS_SIZE; - arch_ctxt->nr_vcpus = 0; - arch_ctxt->mapped_regs = NULL; - - xc_ia64_p2m_init(&arch_ctxt->p2m_table); -} - -void -xc_core_arch_context_free(struct xc_core_arch_context* arch_ctxt) -{ - int i; - for ( i = 0; i < arch_ctxt->nr_vcpus; i++ ) - if ( arch_ctxt->mapped_regs[i] != NULL ) - munmap(arch_ctxt->mapped_regs[i], arch_ctxt->mapped_regs_size); - free(arch_ctxt->mapped_regs); - xc_ia64_p2m_unmap(&arch_ctxt->p2m_table); -} - -int -xc_core_arch_context_get(struct xc_core_arch_context* arch_ctxt, - vcpu_guest_context_any_t* ctxt_any, - xc_interface *xch, uint32_t domid) -{ - vcpu_guest_context_t *ctxt = &ctxt_any->c; - mapped_regs_t* mapped_regs; - - if ( ctxt->privregs_pfn == VGC_PRIVREGS_HVM ) - return 0; /* VTi domain case */ - - if ( ctxt->privregs_pfn == INVALID_P2M_ENTRY ) - { - PERROR("Could not get mmapped privregs gmfn"); - errno = ENOENT; - return -1; - } - if ( !(arch_ctxt->nr_vcpus & (arch_ctxt->nr_vcpus - 1)) ) { - unsigned int nr = arch_ctxt->nr_vcpus ? arch_ctxt->nr_vcpus << 1 : 1; - mapped_regs_t** new = realloc(arch_ctxt->mapped_regs, - nr * sizeof(*new)); - - if ( !new ) - { - PERROR("Could not alloc mapped regs pointer array"); - return -1; - } - memset(new + arch_ctxt->nr_vcpus, 0, - (nr - arch_ctxt->nr_vcpus) * sizeof(*new)); - arch_ctxt->mapped_regs = new; - } - - mapped_regs = xc_map_foreign_range(xch, domid, - arch_ctxt->mapped_regs_size, - PROT_READ, ctxt->privregs_pfn); - if ( mapped_regs == NULL ) - { - PERROR("Could not map mapped privregs"); - return -1; - } - arch_ctxt->mapped_regs[arch_ctxt->nr_vcpus] = mapped_regs; - arch_ctxt->nr_vcpus++; - return 0; -} - -int -xc_core_arch_context_get_shdr(xc_interface *xch, - struct xc_core_arch_context *arch_ctxt, - struct xc_core_section_headers *sheaders, - struct xc_core_strtab *strtab, - uint64_t *filesz, uint64_t offset) -{ - int sts = -1; - Elf64_Shdr *shdr; - - if ( arch_ctxt->nr_vcpus == 0 ) - { - /* VTi domain case */ - *filesz = 0; - return 0; - } - - /* mmapped priv regs */ - shdr = xc_core_shdr_get(xch, sheaders); - if ( shdr == NULL ) - { - PERROR("Could not get section header for .xen_ia64_mapped_regs"); - return sts; - } - *filesz = arch_ctxt->mapped_regs_size * arch_ctxt->nr_vcpus; - sts = xc_core_shdr_set(xch, shdr, strtab, - XEN_DUMPCORE_SEC_IA64_MAPPED_REGS, - SHT_PROGBITS, offset, *filesz, - __alignof__(*arch_ctxt->mapped_regs[0]), - arch_ctxt->mapped_regs_size); - return sts; -} - -int -xc_core_arch_context_dump(xc_interface *xch, - struct xc_core_arch_context* arch_ctxt, - void* args, dumpcore_rtn_t dump_rtn) -{ - int sts = 0; - int i; - - /* ia64 mapped_regs: .xen_ia64_mapped_regs */ - for ( i = 0; i < arch_ctxt->nr_vcpus; i++ ) - { - sts = dump_rtn(xch, args, (char*)arch_ctxt->mapped_regs[i], - arch_ctxt->mapped_regs_size); - if ( sts != 0 ) - break; - } - return sts; -} - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/xc_core_ia64.h b/tools/libxc/xc_core_ia64.h deleted file mode 100644 index 754523d883..0000000000 --- a/tools/libxc/xc_core_ia64.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp> - * VA Linux Systems Japan K.K. - * - */ - -#ifndef XC_CORE_IA64_H -#define XC_CORE_IA64_H - -#include "ia64/xc_ia64.h" - -#define ELF_ARCH_DATA ELFDATA2LSB -#define ELF_ARCH_MACHINE EM_IA_64 - -struct xc_core_arch_context { - size_t mapped_regs_size; - int nr_vcpus; - mapped_regs_t** mapped_regs; - - struct xen_ia64_p2m_table p2m_table; -}; - -void -xc_core_arch_context_init(struct xc_core_arch_context* arch_ctxt); -void -xc_core_arch_context_free(struct xc_core_arch_context* arch_ctxt); -int -xc_core_arch_context_get(struct xc_core_arch_context* arch_ctxt, - vcpu_guest_context_any_t* ctxt, - xc_interface *xch, uint32_t domid); -int -xc_core_arch_context_get_shdr(xc_interface *xch, - struct xc_core_arch_context* arch_ctxt, - struct xc_core_section_headers *sheaders, - struct xc_core_strtab *strtab, - uint64_t *filesz, uint64_t offset); -int -xc_core_arch_context_dump(xc_interface *xch, - struct xc_core_arch_context* arch_ctxt, - void* args, dumpcore_rtn_t dump_rtn); - -int -xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt, - unsigned long pfn); - -#endif /* XC_CORE_IA64_H */ - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c index a9a868c06e..f83aa12d91 100644 --- a/tools/libxc/xc_dom_boot.c +++ b/tools/libxc/xc_dom_boot.c @@ -213,7 +213,7 @@ int xc_dom_boot_image(struct xc_dom_image *dom) DOMPRINTF_CALLED(dom->xch); - /* misc ia64 stuff*/ + /* misc stuff*/ if ( (rc = arch_setup_bootearly(dom)) != 0 ) return rc; diff --git a/tools/libxc/xc_dom_elfloader.c b/tools/libxc/xc_dom_elfloader.c index 2e695599b1..0f656202fd 100644 --- a/tools/libxc/xc_dom_elfloader.c +++ b/tools/libxc/xc_dom_elfloader.c @@ -74,8 +74,6 @@ static char *xc_dom_guest_type(struct xc_dom_image *dom, } case EM_X86_64: return "xen-3.0-x86_64"; - case EM_IA_64: - return elf_msb(elf) ? "xen-3.0-ia64be" : "xen-3.0-ia64"; default: return "xen-3.0-unknown"; } diff --git a/tools/libxc/xc_dom_ia64.c b/tools/libxc/xc_dom_ia64.c deleted file mode 100644 index dcd1523936..0000000000 --- a/tools/libxc/xc_dom_ia64.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Xen domain builder -- ia64 bits. - * - * Most architecture-specific code for ia64 goes here. - * - fill architecture-specific structs. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * written 2006 by Gerd Hoffmann <kraxel@suse.de>. - * - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <inttypes.h> -#include <assert.h> -#include <asm/kregs.h> - -#include <xen/xen.h> -#include <xen/foreign/ia64.h> -#include <xen/io/protocols.h> - -#include "xg_private.h" -#include "xc_dom.h" -#include "xenctrl.h" - -#include <asm/dom_fw_common.h> -#include "ia64/xc_dom_ia64_util.h" - -/* ------------------------------------------------------------------------ */ - -static int alloc_magic_pages(struct xc_dom_image *dom) -{ - /* allocate special pages */ - dom->console_pfn = dom->total_pages -1; - dom->xenstore_pfn = dom->total_pages -2; - dom->start_info_pfn = dom->total_pages -3; - return 0; -} - -int start_info_ia64(struct xc_dom_image *dom) -{ - start_info_ia64_t *start_info = - xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1); - struct xen_ia64_boot_param_ia64 *bp = - (struct xen_ia64_boot_param_ia64 *)(start_info + 1); - - DOMPRINTF_CALLED(dom->xch); - - memset(start_info, 0, sizeof(*start_info)); - sprintf(start_info->magic, dom->guest_type); - start_info->flags = dom->flags; - start_info->nr_pages = dom->total_pages; - start_info->store_mfn = dom->xenstore_pfn; - start_info->store_evtchn = dom->xenstore_evtchn; - start_info->console.domU.mfn = dom->console_pfn; - start_info->console.domU.evtchn = dom->console_evtchn; - - /* - * domain_start and domain_size are abused for arch_setup hypercall - * so that we need to clear them here. - */ - XEN_IA64_MEMMAP_INFO_NUM_PAGES(bp) = 0; - XEN_IA64_MEMMAP_INFO_PFN(bp) = 0; - - if ( dom->ramdisk_blob ) - { - start_info->mod_start = dom->ramdisk_seg.vstart; - start_info->mod_len = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart; - bp->initrd_start = start_info->mod_start; - bp->initrd_size = start_info->mod_len; - } - bp->command_line = (dom->start_info_pfn << PAGE_SHIFT_IA64) - + offsetof(start_info_t, cmd_line); - if ( dom->cmdline ) - { - strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE); - start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0'; - } - return 0; -} - -int shared_info_ia64(struct xc_dom_image *dom, void *ptr) -{ - shared_info_ia64_t *shared_info = ptr; - int i; - - DOMPRINTF_CALLED(dom->xch); - - memset(shared_info, 0, sizeof(*shared_info)); - for (i = 0; i < XEN_LEGACY_MAX_VCPUS; i++) - shared_info->vcpu_info[i].evtchn_upcall_mask = 1; - shared_info->arch.start_info_pfn = dom->start_info_pfn; - shared_info->arch.memmap_info_num_pages = 1; //XXX - shared_info->arch.memmap_info_pfn = dom->start_info_pfn - 1; - return 0; -} - -extern unsigned long xc_ia64_fpsr_default(void); - -static int vcpu_ia64(struct xc_dom_image *dom, void *ptr) -{ - vcpu_guest_context_ia64_t *ctxt = ptr; - - DOMPRINTF_CALLED(dom->xch); - - /* clear everything */ - memset(ctxt, 0, sizeof(*ctxt)); - - ctxt->flags = 0; - /* PSR is set according to SAL 3.2.4: AC, IC and BN are set. */ - ctxt->regs.psr = IA64_PSR_AC | IA64_PSR_IC | IA64_PSR_BN; - ctxt->regs.ip = dom->parms.virt_entry; - ctxt->regs.cfm = 1UL << 63; -#ifdef __ia64__ /* FIXME */ - ctxt->regs.ar.fpsr = xc_ia64_fpsr_default(); -#endif - ctxt->regs.r[28] = (dom->start_info_pfn << PAGE_SHIFT_IA64) - + sizeof(start_info_ia64_t); - return 0; -} - -/* ------------------------------------------------------------------------ */ - -static struct xc_dom_arch xc_dom_arch = { - .guest_type = "xen-3.0-ia64", - .native_protocol = XEN_IO_PROTO_ABI_IA64, - .page_shift = PAGE_SHIFT_IA64, - .alloc_magic_pages = alloc_magic_pages, - .start_info = start_info_ia64, - .shared_info = shared_info_ia64, - .vcpu = vcpu_ia64, -}; - -static struct xc_dom_arch xc_dom_arch_ia64be = { - .guest_type = "xen-3.0-ia64be", - .native_protocol = XEN_IO_PROTO_ABI_IA64, - .page_shift = PAGE_SHIFT_IA64, - .alloc_magic_pages = alloc_magic_pages, - .start_info = start_info_ia64, - .shared_info = shared_info_ia64, - .vcpu = vcpu_ia64, -}; - -static void __init register_arch_hooks(void) -{ - xc_dom_register_arch_hooks(&xc_dom_arch); - xc_dom_register_arch_hooks(&xc_dom_arch_ia64be); -} - -#include "xc_efi.h" - -int arch_setup_meminit(struct xc_dom_image *dom) -{ - xen_pfn_t pfn; - int rc; - unsigned long start; - unsigned long nbr; - - /* setup initial p2m */ - if (dom->guest_type && strcmp(dom->guest_type, - "hvm-3.0-ia64-sioemu") == 0) { - start = FW_MEM_BASE >> PAGE_SHIFT_IA64; - nbr = FW_MEM_SIZE >> PAGE_SHIFT_IA64; - } else { - start = 0; - nbr = dom->total_pages; - } - - /* setup initial p2m */ - dom->p2m_host = xc_dom_malloc(dom, sizeof(xen_pfn_t) * nbr); - for ( pfn = 0; pfn < nbr; pfn++ ) - dom->p2m_host[pfn] = start + pfn; - - /* allocate guest memory */ - rc = xc_domain_populate_physmap_exact(dom->xch, dom->guest_domid, - nbr, 0, 0, - dom->p2m_host); - return rc; -} - -static int ia64_setup_memmap(struct xc_dom_image *dom) -{ - unsigned int page_size = XC_DOM_PAGE_SIZE(dom); - unsigned long memmap_info_num_pages; - unsigned long memmap_info_pfn; - xen_ia64_memmap_info_t* memmap_info; - unsigned int num_mds; - efi_memory_desc_t *md; - - char* start_info; - struct xen_ia64_boot_param* bp; - - /* setup memmap page */ - memmap_info_num_pages = 1; - memmap_info_pfn = dom->start_info_pfn - 1; - DOMPRINTF("%s: memmap: mfn 0x%" PRIpfn " pages 0x%lx", - __FUNCTION__, memmap_info_pfn, memmap_info_num_pages); - memmap_info = xc_map_foreign_range(dom->xch, dom->guest_domid, - page_size * memmap_info_num_pages, - PROT_READ | PROT_WRITE, - memmap_info_pfn); - if (NULL == memmap_info) - return -1; - /* [0, total_pages) */ - memmap_info->efi_memdesc_size = sizeof(md[0]); - memmap_info->efi_memdesc_version = EFI_MEMORY_DESCRIPTOR_VERSION; - num_mds = 0; - md = (efi_memory_desc_t*)&memmap_info->memdesc; - md[num_mds].type = EFI_CONVENTIONAL_MEMORY; - md[num_mds].pad = 0; - md[num_mds].phys_addr = 0; - md[num_mds].virt_addr = 0; - md[num_mds].num_pages = dom->total_pages << (PAGE_SHIFT - EFI_PAGE_SHIFT); - md[num_mds].attribute = EFI_MEMORY_WB; - num_mds++; - memmap_info->efi_memmap_size = num_mds * sizeof(md[0]); - munmap(memmap_info, page_size * memmap_info_num_pages); - assert(num_mds <= - (page_size * memmap_info_num_pages - - offsetof(typeof(*memmap_info), memdesc))/sizeof(*md)); - - /* - * kludge: we need to pass memmap_info page's pfn and other magic pages - * somehow. - * we use xen_ia64_boot_param::efi_memmap::{efi_memmap, efi_memmap_size} - * for this purpose - */ - start_info = xc_map_foreign_range(dom->xch, dom->guest_domid, - page_size, - PROT_READ | PROT_WRITE, - dom->start_info_pfn); - if (NULL == start_info) - return -1; - bp = (struct xen_ia64_boot_param*)(start_info + sizeof(start_info_t)); - memset(bp, 0, sizeof(*bp)); - XEN_IA64_MEMMAP_INFO_NUM_PAGES(bp) = memmap_info_num_pages; - XEN_IA64_MEMMAP_INFO_PFN(bp) = memmap_info_pfn; - munmap(start_info, page_size); - return 0; -} - -int arch_setup_bootearly(struct xc_dom_image *dom) -{ - DECLARE_DOMCTL; - int rc; - - DOMPRINTF("%s: setup firmware for %s", __FUNCTION__, dom->guest_type); - - if (dom->guest_type && strcmp(dom->guest_type, - "hvm-3.0-ia64-sioemu") == 0) { - memset(&domctl, 0, sizeof(domctl)); - domctl.u.arch_setup.flags = XEN_DOMAINSETUP_sioemu_guest; - domctl.u.arch_setup.bp = 0; - domctl.u.arch_setup.maxmem = 0; - domctl.cmd = XEN_DOMCTL_arch_setup; - domctl.domain = dom->guest_domid; - rc = xc_domctl(dom->xch, &domctl); - DOMPRINTF("%s: hvm-3.0-ia64-sioemu: %d", __FUNCTION__, rc); - return rc; - } - - rc = ia64_setup_memmap(dom); - if (rc) - return rc; - - memset(&domctl, 0, sizeof(domctl)); - domctl.cmd = XEN_DOMCTL_arch_setup; - domctl.domain = dom->guest_domid; - domctl.u.arch_setup.flags = XEN_DOMAINSETUP_query; - rc = do_domctl(dom->xch, &domctl); - if (rc) - return rc; - rc = xen_ia64_dom_fw_setup(dom, domctl.u.arch_setup.hypercall_imm, - (dom->start_info_pfn << PAGE_SHIFT) + - sizeof(start_info_t), - dom->total_pages << PAGE_SHIFT); - if (rc) - return rc; - - memset(&domctl, 0, sizeof(domctl)); - domctl.cmd = XEN_DOMCTL_arch_setup; - domctl.domain = dom->guest_domid; - domctl.u.arch_setup.flags = 0; - - domctl.u.arch_setup.bp = (dom->start_info_pfn << PAGE_SHIFT) - + sizeof(start_info_t); - domctl.u.arch_setup.maxmem = dom->total_pages << PAGE_SHIFT; - domctl.u.arch_setup.vhpt_size_log2 = dom->vhpt_size_log2; - rc = do_domctl(dom->xch, &domctl); - return rc; -} - -int arch_setup_bootlate(struct xc_dom_image *dom) -{ - unsigned int page_size = XC_DOM_PAGE_SIZE(dom); - shared_info_t *shared_info; - - /* setup shared_info page */ - DOMPRINTF("%s: shared_info: mfn 0x%" PRIpfn "", - __FUNCTION__, dom->shared_info_mfn); - shared_info = xc_map_foreign_range(dom->xch, dom->guest_domid, - page_size, - PROT_READ | PROT_WRITE, - dom->shared_info_mfn); - if ( shared_info == NULL ) - return -1; - dom->arch_hooks->shared_info(dom, shared_info); - munmap(shared_info, page_size); - return 0; -} - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c index eacd6f6dc3..ab86b7254d 100644 --- a/tools/libxc/xc_minios.c +++ b/tools/libxc/xc_minios.c @@ -109,14 +109,10 @@ static void *minios_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle const xen_pfn_t *arr, int *err, unsigned int num) { unsigned long pt_prot = 0; -#ifdef __ia64__ - /* TODO */ -#else if (prot & PROT_READ) pt_prot = L1_PROT_RO; if (prot & PROT_WRITE) pt_prot = L1_PROT; -#endif return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); } @@ -129,14 +125,11 @@ static void *minios_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handl int i; unsigned long addr; -#ifdef __ia64__ - /* TODO */ -#else if (prot & PROT_READ) pt_prot = L1_PROT_RO; if (prot & PROT_WRITE) pt_prot = L1_PROT; -#endif + addr = (unsigned long) map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); for (i = 0; i < num; i++) { if (err[i]) @@ -151,14 +144,12 @@ static void *minios_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle unsigned long mfn) { unsigned long pt_prot = 0; -#ifdef __ia64__ - /* TODO */ -#else + if (prot & PROT_READ) pt_prot = L1_PROT_RO; if (prot & PROT_WRITE) pt_prot = L1_PROT; -#endif + assert(!(size % getpagesize())); return map_frames_ex(&mfn, size / getpagesize(), 0, 1, 1, dom, NULL, pt_prot); } @@ -172,14 +163,11 @@ static void *minios_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handl int i, j, n; unsigned long pt_prot = 0; void *ret; -#ifdef __ia64__ - /* TODO */ -#else + if (prot & PROT_READ) pt_prot = L1_PROT_RO; if (prot & PROT_WRITE) pt_prot = L1_PROT; -#endif mfns = malloc((size / XC_PAGE_SIZE) * sizeof(*mfns)); diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index b7741ca543..3254537dce 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -55,11 +55,7 @@ #include <xen/arch-x86/xen-mca.h> #endif -#ifdef __ia64__ -#define XC_PAGE_SHIFT 14 -#else #define XC_PAGE_SHIFT 12 -#endif #define XC_PAGE_SIZE (1UL << XC_PAGE_SHIFT) #define XC_PAGE_MASK (~(XC_PAGE_SIZE-1)) @@ -79,10 +75,6 @@ #define xen_mb() asm volatile ( "mfence" : : : "memory") #define xen_rmb() xen_barrier() #define xen_wmb() xen_barrier() -#elif defined(__ia64__) -#define xen_mb() asm volatile ("mf" ::: "memory") -#define xen_rmb() asm volatile ("mf" ::: "memory") -#define xen_wmb() asm volatile ("mf" ::: "memory") #elif defined(__arm__) #define xen_mb() asm volatile ("dmb" : : : "memory") #define xen_rmb() asm volatile ("dmb" : : : "memory") @@ -1248,8 +1240,6 @@ unsigned long xc_translate_foreign_address(xc_interface *xch, uint32_t dom, int xc_get_pfn_list(xc_interface *xch, uint32_t domid, uint64_t *pfn_buf, unsigned long max_pfns); -unsigned long xc_ia64_fpsr_default(void); - int xc_copy_to_domain_page(xc_interface *xch, uint32_t domid, unsigned long dst_pfn, const char *src_page); @@ -1659,15 +1649,6 @@ void xc_clear_last_error(xc_interface *xch); int xc_set_hvm_param(xc_interface *handle, domid_t dom, int param, unsigned long value); int xc_get_hvm_param(xc_interface *handle, domid_t dom, int param, unsigned long *value); -/* IA64 specific, nvram save */ -int xc_ia64_save_to_nvram(xc_interface *xch, uint32_t dom); - -/* IA64 specific, nvram init */ -int xc_ia64_nvram_init(xc_interface *xch, char *dom_name, uint32_t dom); - -/* IA64 specific, set guest OS type optimizations */ -int xc_ia64_set_os_type(xc_interface *xch, char *guest_os_type, uint32_t dom); - /* HVM guest pass-through */ int xc_assign_device(xc_interface *xch, uint32_t domid, |