ARM: Start working on tools
cover ARM: Start working on tools
Now that we have an ARM build environment[0] I've made a very basic start on getting the Xen tools for the ARMv7 w/ virt extensions port to compile. A short series follows. Nothing too earth shatteringly exciting...
Currently compiles a fair bit of interesting stuff (libxc, xenstore, xenconsole) and gets as far as mid way through libxl before it fails due to CPUID stuff. Solving that needs some more infrastructure work in libxl to be able to have per-arch members in IDL structs. But I thought I might as well share what I have now. Note that I've not run any of it.
Obviously the final patch is not to be applied!
Ian.
[0] https://plus.google.com/106815887686504011057/posts/Kgdakxs5cFt
Quoted 4 lines · Ian Campbell
Now that we have an ARM build environment[0] I've made a very basic start on getting the Xen tools for the ARMv7 w/ virt extensions port to compile. A short series follows. Nothing too earth shatteringly exciting...
I made a typo in the xen-devel address on first posting of the series so I'm resending. Apologies for the noise.
PATCH 1/5 arm: add stub hvm/save.h
In reply to Ian Campbell--- xen/include/public/arch-arm/hvm/save.h | 39 ++++++++++++++++++++++++++++++++ xen/include/public/hvm/save.h | 2 + 2 files changed, 41 insertions(+), 0 deletions(-) create mode 100644 xen/include/public/arch-arm/hvm/save.h
xen/include/public/arch-arm/hvm/save.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Structure definitions for HVM state that is held by Xen and must +* be saved along with the domain's memory and device-model state. +* +* Copyright (c) 2012 Citrix Systems Ltd. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __XEN_PUBLIC_HVM_SAVE_ARM_H__ +#define __XEN_PUBLIC_HVM_SAVE_ARM_H__ + +#endif + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/public/hvm/save.h +2 -0
@@ -104,6 +104,8 @@ DECLARE_HVM_SAVE_TYPE(END, 0, struct hvm_save_end);#include "../arch-x86/hvm/save.h" #elif defined(__ia64__)#include "../arch-ia64/hvm/save.h" +#elif defined(__arm__) +#include "../arch-arm/hvm/save.h" #else #error "unsupported architecture"#endif
Signature · 1 line
1.7.8.3
PATCH 2/5 arm: allow libxc to build (untested)
--- Config.mk | 2 +- tools/libxc/Makefile | 1 + tools/libxc/xc_core.h | 2 + tools/libxc/xc_core_arm.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ tools/libxc/xc_core_arm.h | 61 +++++++++++++++++++++++++++++++++++++++ tools/libxc/xenctrl.h | 4 ++ 6 files changed, 139 insertions(+), 1 deletions(-) create mode 100644 tools/libxc/xc_core_arm.c create mode 100644 tools/libxc/xc_core_arm.h
Config.mk +1 -1
@@ -13,7 +13,7 @@ realpath = $(wildcard $(foreach file,$(1),$(shell cd -P $(dir $(file)) && echo " debug ?= y XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ \ - -e s/i86pc/x86_32/ -e s/amd64/x86_64/) + -e s/i86pc/x86_32/ -e s/amd64/x86_64/ -e s/arm.*/arm/) XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH) XEN_OS ?= $(shell uname -s)
tools/libxc/Makefile +1 -0
@@ -6,6 +6,7 @@ MINOR = 0 CTRL_SRCS-y := CTRL_SRCS-y += xc_core.c +CTRL_SRCS-$(CONFIG_ARM) += xc_core_arm.c CTRL_SRCS-$(CONFIG_X86) += xc_core_x86.c CTRL_SRCS-$(CONFIG_IA64) += xc_core_ia64.c CTRL_SRCS-y += xc_cpupool.c
tools/libxc/xc_core.h +2 -0
@@ -155,6 +155,8 @@ int xc_core_arch_map_p2m_writable(xc_interface *xch, unsigned int guest_width,# include "xc_core_x86.h" #elif defined (__ia64__)# include "xc_core_ia64.h" +#elif defined (__arm__) +# include "xc_core_arm.h" #else # error "unsupported architecture"#endif
tools/libxc/xc_core_arm.c new file +70 -0
70 lines not on this page · raw message
tools/libxc/xc_core_arm.h new file +61 -0
61 lines not on this page · raw message
tools/libxc/xenctrl.h +4 -0
@@ -81,6 +81,10 @@#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 ("dsb" : : : "memory") +#define xen_rmb () asm volatile ("dsb" : : : "memory") +#define xen_wmb () asm volatile ("dsb" : : : "memory")#else #error "Define barriers"#endif
Signature · 1 line
1.7.8.3
Re: [PATCH 2/5] arm: allow libxc to build (untested)
Quoted 168 lines · Ian Campbell
Signed-off-by Ian Campbell <[email protected]>--- Config.mk | 2 +- tools/libxc/Makefile | 1 + tools/libxc/xc_core.h | 2 + tools/libxc/xc_core_arm.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ tools/libxc/xc_core_arm.h | 61 +++++++++++++++++++++++++++++++++++++++ tools/libxc/xenctrl.h | 4 ++ 6 files changed, 139 insertions(+), 1 deletions(-) create mode 100644 tools/libxc/xc_core_arm.c create mode 100644 tools/libxc/xc_core_arm.hConfig.mk +1
-1@@ -13,7 +13,7 @@ realpath = $(wildcard $(foreach file,$(1),$(shell cd -P $(dir $(file)) && echo " debug ?= y XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ \ - -e s/i86pc/x86_32/ -e s/amd64/x86_64/) + -e s/i86pc/x86_32/ -e s/amd64/x86_64/ -e s/arm.*/arm/) XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH) XEN_OS ?= $(shell uname -s)tools/libxc/Makefile +1
-0@@ -6,6 +6,7 @@ MINOR = 0 CTRL_SRCS-y := CTRL_SRCS-y += xc_core.c +CTRL_SRCS-$(CONFIG_ARM) += xc_core_arm.c CTRL_SRCS-$(CONFIG_X86) += xc_core_x86.c CTRL_SRCS-$(CONFIG_IA64) += xc_core_ia64.c CTRL_SRCS-y += xc_cpupool.ctools/libxc/xc_core.h +2
-0@@ -155,6 +155,8 @@ int xc_core_arch_map_p2m_writable(xc_interface *xch, unsigned int guest_width,# include "xc_core_x86.h" #elif defined (__ia64__)# include "xc_core_ia64.h" +#elif defined (__arm__) +# include "xc_core_arm.h" #else # error "unsupported architecture"#endif tools/libxc/xc_core_arm.c new file +70
-0@@ -0,0 +1,70 @@ +/* +* 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) 2012 Citrix Systems Ltd. +*/ + +#include "xg_private.h" +#include "xc_core.h" + +int +xc_core_arch_gpfn_may_present (struct xc_core_arch_context *arch_ctxt, +unsigned long pfn) +{ +/* default to trying to map the page */ +/* TODO consult p2m */ +return 1 ; +} + +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) +{ +/* TODO return the memory map! */ +ERROR ("%s is not implemented yet\n" , __func__); + errno =ENOSYS ; +return -1 ; +} + +int +xc_core_arch_auto_translated_physmap (const xc_dominfo_t *info) +{ +/* All domains are auto_translated_physmap mode. */ +return 1 ; +} + +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) +{ +/* All domains are auto_translated_physmap mode. */ + errno =ENOSYS ; +return -1 ; +} + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/ tools/libxc/xc_core_arm.h new file +36
-0@@ -0,0 +1,61 @@ +/* +* 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_ARM_H +#define XC_CORE_ARM_H + +#define ELF_ARCH_DATA ELFDATA2LSB +#define ELF_ARCH_MACHINE EM_ARM + +struct xc_core_arch_context { +/* nothing */ +}; + +#define xc_core_arch_context_init (arch_ctxt) do {} while (0) +#define xc_core_arch_context_free (arch_ctxt) do {} while (0) +#define xc_core_arch_context_get (arch_ctxt, ctxt, xch, domid) \ + (0) +#define xc_core_arch_context_dump (xch, arch_ctxt, args, dump_rtn) (0) +
tools/libxc/xc_core_arm.h line 46
Quoted 10 lines
tools/libxc/xc_core_arm.h new file +10
-0+int +xc_core_arch_gpfn_may_present (struct xc_core_arch_context *arch_ctxt, +unsigned long pfn); +static inline 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) +{
/* TODO */ ?
Quoted 20 lines
tools/libxc/xc_core_arm.h new file +15
-0+ *filesz =0 ; + return 0; +} + +#endif /* XC_CORE_ARM_H */ + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/ tools/libxc/xenctrl.h +0
-0
tools/libxc/xenctrl.h line 90
Quoted 10 lines
tools/libxc/xenctrl.h +4
-0@@ -81,6 +81,10 @@#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 ("dsb" : : : "memory") +#define xen_rmb () asm volatile ("dsb" : : : "memory") +#define xen_wmb () asm volatile ("dsb" : : : "memory")#else #error "Define barriers"#endif
I think the memory barriers are correct
PATCH 3/5 libxl: do not allocate e820 for non x86 guests.
In reply to Ian Campbell--- tools/libxl/libxl_create.c | 3 ++- tools/libxl/libxl_pci.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletions(-)
tools/libxl/libxl_create.c +2 -1
@@ -640,7 +640,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, goto error_out; } } - +#if defined(__i386__) || defined(__x86_64__)if (d_config->c_info.type ==LIBXL_DOMAIN_TYPE_PV && d_config->b_info.u.pv.e820_host) {int rc;
@@ -650,6 +650,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,"Failed while collecting E820 with: %d (errno:%d)\n" , rc, errno); } +#endif if ( cb && (d_config->c_info.type ==LIBXL_DOMAIN_TYPE_HVM || (d_config->c_info.type ==LIBXL_DOMAIN_TYPE_PV && d_config->b_info.u.pv.bootloader ))) {
tools/libxl/libxl_pci.c +2 -0
@@ -1163,6 +1163,7 @@ int libxl__device_pci_destroy_all(libxl__gc *gc, uint32_t domid)return 0 ; } +#if defined(__i386__) || defined(__x86_64__)static const char *e820_names (int type) {switch (type) {
@@ -1404,6 +1405,7 @@ int libxl__e820_alloc(libxl__gc *gc, uint32_t domid, libxl_domain_config *d_conf }return 0 ; } +#endif /* * Local variables:
Signature · 1 line
1.7.8.3
PATCH 4/5 blktap2/libvhd: Build shared objects using -fPIC.
In reply to Ian Campbell--- tools/blktap2/vhd/lib/Makefile | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
tools/blktap2/vhd/lib/Makefile +9 -4
@@ -45,27 +45,32 @@ LIB-SRCS += atomicio.c LIB-OBJS = $(patsubst %.c,%.o,$(LIB-SRCS)) LIB-OBJS += $(LVM-UTIL-OBJ) +LIB-PICOBJS = $(patsubst %.o,%.opic,$(LIB-OBJS)) + LIBVHD = libvhd.a libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) all: build -build: $(LIBVHD-BUILD) +build: libvhd.a libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) libvhd.a: $(LIB-OBJS) + $(AR) rc $@ $^ + +libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR): $(LIB-PICOBJS) $(CC) -Wl,$(SONAME_LDFLAG),$(LIBVHD-SONAME) $(SHLIB_LDFLAGS) \ $(LDFLAGS) -o libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $^ $(LIBS) ln -sf libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) libvhd.so.$(LIBVHD-MAJOR) ln -sf libvhd.so.$(LIBVHD-MAJOR) libvhd.so - $(AR) rc $@ $^ install: all $(INSTALL_DIR) -p $(DESTDIR)$(INST-DIR) - $(INSTALL_PROG) $(LIBVHD) $(DESTDIR)$(INST-DIR) + $(INSTALL_PROG) libvhd.a $(DESTDIR)$(INST-DIR) + $(INSTALL_PROG) libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $(DESTDIR)$(INST-DIR) ln -sf libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $(DESTDIR)$(INST-DIR)/libvhd.so.$(LIBVHD-MAJOR) ln -sf libvhd.so.$(LIBVHD-MAJOR) $(DESTDIR)$(INST-DIR)/libvhd.so clean: - rm -rf *.a *.so* *.o *~ $(DEPS) $(LIBVHD) + rm -rf *.a *.so* *.o *.opic *~ $(DEPS) $(LIBVHD) .PHONY: all build clean install libvhd
Signature · 1 line
1.7.8.3
PATCH 5/5 DO-NOT-APPLY: Hackily remove bits which don't (yet) build on ARM.
In reply to Ian CampbellFor the most part these tools need domU support to be more fully baked before they can be ported.
In a few cases (e.g. blktap 1) I don't think it makes sense to provide them for a new platform.
In some cases the lack of portability is just gratuitous (libfsimage/xfs -- I'm looking at you).
--- tools/Makefile | 6 +++--- tools/libfsimage/Makefile | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-)
tools/Makefile +3 -3
@@ -14,7 +14,7 @@ SUBDIRS-y += xenstore SUBDIRS-y += misc SUBDIRS-y += examples SUBDIRS-y += hotplug -SUBDIRS-y += xentrace +#SUBDIRS-y += xentrace SUBDIRS-$(CONFIG_XCUTILS) += xcutils SUBDIRS-$(CONFIG_X86) += firmware SUBDIRS-y += console
@@ -23,8 +23,8 @@ SUBDIRS-$(VTPM_TOOLS) += vtpm_manager SUBDIRS-$(VTPM_TOOLS) += vtpm SUBDIRS-y += xenstat SUBDIRS-$(CONFIG_Linux) += $(SUBDIRS-libaio) -SUBDIRS-$(CONFIG_Linux) += memshr -SUBDIRS-$(CONFIG_Linux) += blktap +#SUBDIRS-$(CONFIG_Linux) += memshr +#SUBDIRS-$(CONFIG_Linux) += blktap SUBDIRS-$(CONFIG_Linux) += blktap2 SUBDIRS-$(CONFIG_NetBSD) += $(SUBDIRS-libaio) SUBDIRS-$(CONFIG_NetBSD) += blktap2
tools/libfsimage/Makefile +2 -1
@@ -1,7 +1,8 @@ XEN_ROOT = $(CURDIR)/../.. include $(XEN_ROOT)/tools/Rules.mk -SUBDIRS-y = common ufs reiserfs iso9660 fat zfs xfs +SUBDIRS-y = common ufs reiserfs iso9660 fat zfs +SUBDIRS-$(CONFIG_X86) += xfs SUBDIRS-y += $(shell env CC="$(CC)" ./check-libext2fs) .PHONY: all clean install
Signature · 1 line
1.7.8.3