arm: compile tools
v7 cover arm: compile tools
Hi all,
this patch series allows tools/ to compile on ARM, mostly providing an empty implementation for all the arch specific functions that are needed.
All the patches of this series have been previously acked.
Changes in v7:
- rebase on "x86_64: Record entry vector for double faults.";
- split the last patch in three patches to make it easier to read and find all the code motions (I kept the acked-by on all the patches because there are no changes except the split).
Changes in v6:
- rebase on 33659563f589 (this is a mercurial id).
Changes in v5:
- libxc: return -1 and set errno on error;
- add few missing emacs runes in new files.
Changes in v4:
- rebased on 55a36564fb4f85722c67f16fe508f3ecbd204549;
- minor compile fixes.
Changes in v3:
- move libxl_cpuid_policy_list_gen_json to libxl_(no)cpuid.c;
- rename xc_hvm_build.c to xc_hvm_build_x86.c;
- remove xc_nohvm, introduce xc_hvm_build_arm.c instead;
- remove "libxl: do not allocate e820 for non x86 guests.";
- introduce libxl__arch_domain_create.
Changes in v2:
- rebased on a22587ae517170a7755d3a88611ae0e2d5bb555e;
- dropped "arm: arch_dump_shared_mem_info as a no-op" that is already in xen-unstable;
- define xen_callback_t as uint64_t;
- define guest_word_t as uint64_t.
Stefano Stabellini (8):
arm: compile libxenguest
arm: compile memshr
arm: compile xentrace
arm: compile libxl
libxl: Introduce libxl__arch_domain_create
libxl: Introduce libxl__arch_domain_create (x86 version)
libxl: move e820_names, e820_sanitize, libxl__e820_alloc to libxl_x86.c
libxl: make libxl__e820_alloc a static function
tools/libxc/Makefile | 12 +- tools/libxc/xc_dom_arm.c | 50 +++++ tools/libxc/xc_hvm_build.c | 472 ---------------------------------------- tools/libxc/xc_hvm_build_arm.c | 49 ++++ tools/libxc/xc_hvm_build_x86.c | 472 ++++++++++++++++++++++++++++++++++++++++ tools/libxc/xc_nomigrate.c | 54 +++++ tools/libxl/Makefile | 5 +- tools/libxl/libxl_arch.h | 22 ++ tools/libxl/libxl_cpuid.c | 60 +++++ tools/libxl/libxl_create.c | 12 +- tools/libxl/libxl_internal.h | 2 - tools/libxl/libxl_json.c | 60 ----- tools/libxl/libxl_noarch.c | 8 + tools/libxl/libxl_nocpuid.c | 8 +- tools/libxl/libxl_pci.c | 242 -------------------- tools/libxl/libxl_x86.c | 262 ++++++++++++++++++++++ tools/memshr/bidir-hash.c | 31 +++ tools/xentrace/xenctx.c | 12 + 18 files changed, 1041 insertions(+), 792 deletions(-)
Cheers,
Stefano
PATCH v7 1/8 arm: compile libxenguest
Introduce an empty implementation of the arch specific ARM functions in xc_dom_arm.c.
Provide empty implementations of xc_domain_save and xc_domain_restore when CONFIG_MIGRATE is not set.
Move xc_hvm_build.c to xc_hvm_build_x86.c because the implementation is x86 specific, introduce xc_hvm_build_arm.c with empty stubs.
Changes in v3:
- rename xc_hvm_build.c to xc_hvm_build_x86.c;
- remove xc_nohvm, introduce xc_hvm_build_arm.c instead;
--- tools/libxc/Makefile | 12 +- tools/libxc/xc_dom_arm.c | 50 +++++ tools/libxc/xc_hvm_build.c | 472 ---------------------------------------- tools/libxc/xc_hvm_build_arm.c | 49 ++++ tools/libxc/xc_hvm_build_x86.c | 472 ++++++++++++++++++++++++++++++++++++++++ tools/libxc/xc_nomigrate.c | 54 +++++ 6 files changed, 634 insertions(+), 475 deletions(-) create mode 100644 tools/libxc/xc_dom_arm.c delete mode 100644 tools/libxc/xc_hvm_build.c create mode 100644 tools/libxc/xc_hvm_build_arm.c create mode 100644 tools/libxc/xc_hvm_build_x86.c create mode 100644 tools/libxc/xc_nomigrate.c
tools/libxc/Makefile +9 -3
@@ -42,9 +42,12 @@ CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c GUEST_SRCS-y := GUEST_SRCS-y += xg_private.c xc_suspend.c -GUEST_SRCS-$(CONFIG_MIGRATE) += xc_domain_restore.c xc_domain_save.c -GUEST_SRCS-$(CONFIG_MIGRATE) += xc_offline_page.c xc_compression.c -GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c +ifeq ($(CONFIG_MIGRATE),y) +GUEST_SRCS-y += xc_domain_restore.c xc_domain_save.c +GUEST_SRCS-y += xc_offline_page.c xc_compression.c +else +GUEST_SRCS-y += xc_nomigrate.c +endif vpath %.c ../../xen/common/libelf CFLAGS += -I../../xen/common/libelf
@@ -61,7 +64,10 @@ 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 OSDEP_SRCS-y += xenctrl_osdep_ENOSYS.c
tools/libxc/xc_dom_arm.c new file +50 -0
50 lines not on this page · raw message
tools/libxc/xc_hvm_build.c deleted +0 -472
472 lines not on this page · raw message
tools/libxc/xc_hvm_build_arm.c new file +49 -0
49 lines not on this page · raw message
tools/libxc/xc_hvm_build_x86.c new file +472 -0
472 lines not on this page · raw message
tools/libxc/xc_nomigrate.c new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v7 2/8 arm: compile memshr
In reply to Stefano Stabellini--- tools/memshr/bidir-hash.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-)
tools/memshr/bidir-hash.c +31 -0
@@ -109,6 +109,37 @@ static void hash_resize(struct __hash *h); } while (0) static inline void atomic_inc(uint32_t *v) { ia64_fetchadd4_rel(v, 1); }static inline void atomic_dec (uint32_t *v) {ia64_fetchadd4_rel (v,-1 ); } +#elif defined(__arm__) +static inline void atomic_inc (uint32_t *v) +{ +unsigned long tmp; +int result; + + __asm__ __volatile__("@ atomic_add\n" +"1: ldrex %0, [%3]\n" +" add %0, %0, #1\n" +" strex %1, %0, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (result),"=&r" (tmp),"+Qo" (*v) + :"r" (v) + :"cc" ); +} +static inline void atomic_dec (uint32_t *v) +{ +unsigned long tmp; +int result; + + __asm__ __volatile__("@ atomic_sub\n" +"1: ldrex %0, [%3]\n" +" sub %0, %0, #1\n" +" strex %1, %0, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (result),"=&r" (tmp),"+Qo" (*v) + :"r" (v) + :"cc" ); +}#else /* __x86__ */ static inline void atomic_inc (uint32_t *v) {
Signature · 1 line
1.7.2.5
PATCH v7 3/8 arm: compile xentrace
In reply to Stefano Stabellini--- tools/xentrace/xenctx.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
tools/xentrace/xenctx.c +12 -0
@@ -60,6 +60,12 @@ int disp_ar_regs;int disp_br_regs;int disp_bank_regs;int disp_tlb; + +#elif defined(__arm__) +#define NO_TRANSLATION +typedef uint64_t guest_word_t ; +#define FMT_32B_WORD "%08llx" +#define FMT_64B_WORD "%016llx"#endif struct symbol {
@@ -678,6 +684,12 @@ void print_ctx(vcpu_guest_context_any_t *ctx) print_tr(i, &tr->dtrs[i]); } } +#elif defined(__arm__) +static void print_ctx (vcpu_guest_context_any_t *ctx) +{ +/* XXX: properly implement this */ +print_symbol (0 ); +}#endif #ifndef NO_TRANSLATION
Signature · 1 line
1.7.2.5
PATCH v7 4/8 arm: compile libxl
In reply to Stefano Stabellinilibxl_cpuid_destroy has been renamed to libxl_cpuid_dispose; also cpuid functions are only available on x86, so ifdef the new cpuid related function in libxl_json.c.
Changes in v3:
- move libxl_cpuid_policy_list_gen_json to libxl_(no)cpuid.c.
--- tools/libxl/Makefile | 1 + tools/libxl/libxl_cpuid.c | 60 +++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_json.c | 60 ------------------------------------------- tools/libxl/libxl_nocpuid.c | 8 +++++- 4 files changed, 68 insertions(+), 61 deletions(-)
tools/libxl/Makefile +1 -0
@@ -36,6 +36,7 @@ LIBXL_OBJS-y += libxl_noblktap2.o endif LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o +LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o ifeq ($(CONFIG_NetBSD),y) LIBXL_OBJS-y += libxl_netbsd.o
tools/libxl/libxl_cpuid.c +60 -0
66 lines not on this page · raw message
tools/libxl/libxl_json.c +0 -60
66 lines not on this page · raw message
tools/libxl/libxl_nocpuid.c +7 -1
@@ -14,7 +14,7 @@#include "libxl_internal.h" -void libxl_cpuid_destroy (libxl_cpuid_policy_list *p_cpuid_list) +void libxl_cpuid_dispose (libxl_cpuid_policy_list *p_cpuid_list) { }
@@ -38,6 +38,12 @@ void libxl_cpuid_set(libxl_ctx *ctx, uint32_t domid, { } +yajl_gen_status libxl_cpuid_policy_list_gen_json (yajl_gen hand, +libxl_cpuid_policy_list *pcpuid) +{ +return 0 ; +} +/* * Local variables: * mode: C
Signature · 1 line
1.7.2.5
Re: [PATCH v7 4/8] arm: compile libxl
Quoted 3 lines · Stefano Stabellini
libxl_cpuid_destroyhas been renamed tolibxl_cpuid_dispose; also cpuid functions are only available on x86, so ifdef the new cpuid related function inlibxl_json.c.
This was out of date. I replaced with:
libxl_cpuid_destroy has been renamed to libxl_cpuid_dispose; also cpuid functions are only available on x86, so move them to libxl_cpuid.c.
Quoted 197 lines
Changes in v3:
- move
libxl_cpuid_policy_list_gen_jsonto libxl_(no)cpuid.c.Signed-off-by Stefano Stabellini <[email protected]>Acked-by Ian Campbell <[email protected]>Acked-by Ian Jackson <[email protected]>--- tools/libxl/Makefile | 1 + tools/libxl/libxl_cpuid.c | 60 +++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_json.c | 60 ------------------------------------------- tools/libxl/libxl_nocpuid.c | 8 +++++- 4 files changed, 68 insertions(+), 61 deletions(-)tools/libxl/Makefile +1
-0@@ -36,6 +36,7 @@ LIBXL_OBJS-y += libxl_noblktap2.o endif LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o +LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o ifeq ($(CONFIG_NetBSD),y) LIBXL_OBJS-y += libxl_netbsd.otools/libxl/libxl_cpuid.c +60
-0@@ -333,6 +333,66 @@ void libxl_cpuid_set(libxl_ctx *ctx, uint32_t domid, (const char**)(cpuid[i].policy), cpuid_res); } +yajl_gen_status libxl_cpuid_policy_list_gen_json (yajl_gen hand, +libxl_cpuid_policy_list *pcpuid) +{ +libxl_cpuid_policy_list cpuid = *pcpuid; +yajl_gen_status s; +const char *input_names[2 ] = {"leaf" ,"subleaf" }; +const char *policy_names[4 ] = {"eax" ,"ebx" ,"ecx" ,"edx" }; +int i, j; + +/* +* Aiming for: +* [ +* { 'leaf': 'val-eax', +* 'subleaf': 'val-ecx', +* 'eax': 'filter', +* 'ebx': 'filter', +* 'ecx': 'filter', +* 'edx': 'filter' }, +* { 'leaf': 'val-eax', ..., 'eax': 'filter', ... }, +* ... etc ... +* ] +*/ + + s =yajl_gen_array_open (hand); +if (s != yajl_gen_status_ok) goto out; + +if (cpuid ==NULL ) goto empty; + +for (i =0 ; cpuid[i].input[0 ] !=XEN_CPUID_INPUT_UNUSED ; i++) { + s =yajl_gen_map_open (hand); +if (s != yajl_gen_status_ok) goto out; + +for (j =0 ; j <2 ; j++) { +if (cpuid[i].input[j] !=XEN_CPUID_INPUT_UNUSED ) { + s =libxl__yajl_gen_asciiz (hand, input_names[j]); +if (s != yajl_gen_status_ok) goto out; + s =yajl_gen_integer (hand, cpuid[i].input[j]); +if (s != yajl_gen_status_ok) goto out; + } + } + +for (j =0 ; j <4 ; j++) { +if (cpuid[i].policy[j] !=NULL ) { + s =libxl__yajl_gen_asciiz (hand, policy_names[j]); +if (s != yajl_gen_status_ok) goto out; + s =yajl_gen_string (hand, + (const unsigned char *)cpuid[i].policy[j],32 ); +if (s != yajl_gen_status_ok) goto out; + } + } + s =yajl_gen_map_close (hand); +if (s != yajl_gen_status_ok) goto out; + } + +empty: + s =yajl_gen_array_close (hand); +out: +return s; +} +/* * Local variables: * mode: C tools/libxl/libxl_json.c +0
-60@@ -146,66 +146,6 @@ out:return s; } -yajl_gen_status libxl_cpuid_policy_list_gen_json (yajl_gen hand, -libxl_cpuid_policy_list *pcpuid) -{ -libxl_cpuid_policy_list cpuid = *pcpuid; -yajl_gen_status s; -const char *input_names[2 ] = {"leaf" ,"subleaf" }; -const char *policy_names[4 ] = {"eax" ,"ebx" ,"ecx" ,"edx" }; -int i, j; - -/* -* Aiming for: -* [ -* { 'leaf': 'val-eax', -* 'subleaf': 'val-ecx', -* 'eax': 'filter', -* 'ebx': 'filter', -* 'ecx': 'filter', -* 'edx': 'filter' }, -* { 'leaf': 'val-eax', ..., 'eax': 'filter', ... }, -* ... etc ... -* ] -*/ - - s =yajl_gen_array_open (hand); -if (s != yajl_gen_status_ok) goto out; - -if (cpuid ==NULL ) goto empty; - -for (i =0 ; cpuid[i].input[0 ] !=XEN_CPUID_INPUT_UNUSED ; i++) { - s =yajl_gen_map_open (hand); -if (s != yajl_gen_status_ok) goto out; - -for (j =0 ; j <2 ; j++) { -if (cpuid[i].input[j] !=XEN_CPUID_INPUT_UNUSED ) { - s =libxl__yajl_gen_asciiz (hand, input_names[j]); -if (s != yajl_gen_status_ok) goto out; - s =yajl_gen_integer (hand, cpuid[i].input[j]); -if (s != yajl_gen_status_ok) goto out; - } - } - -for (j =0 ; j <4 ; j++) { -if (cpuid[i].policy[j] !=NULL ) { - s =libxl__yajl_gen_asciiz (hand, policy_names[j]); -if (s != yajl_gen_status_ok) goto out; - s =yajl_gen_string (hand, - (const unsigned char *)cpuid[i].policy[j],32 ); -if (s != yajl_gen_status_ok) goto out; - } - } - s =yajl_gen_map_close (hand); -if (s != yajl_gen_status_ok) goto out; - } - -empty: - s =yajl_gen_array_close (hand); -out: -return s; -} -yajl_gen_status libxl_string_list_gen_json (yajl_gen hand,libxl_string_list *pl) {libxl_string_list l = *pl;tools/libxl/libxl_nocpuid.c +7
-1@@ -14,7 +14,7 @@#include "libxl_internal.h" -void libxl_cpuid_destroy (libxl_cpuid_policy_list *p_cpuid_list) +void libxl_cpuid_dispose (libxl_cpuid_policy_list *p_cpuid_list) { }@@ -38,6 +38,12 @@ void libxl_cpuid_set(libxl_ctx *ctx, uint32_t domid, { } +yajl_gen_status libxl_cpuid_policy_list_gen_json (yajl_gen hand, +libxl_cpuid_policy_list *pcpuid) +{ +return 0 ; +} +/* * Local variables: * mode: C
PATCH v7 5/8 libxl: Introduce libxl__arch_domain_create
In reply to Stefano StabelliniIntroduce an arch specific internal domain creation function. The X86 version of libxl__arch_domain_create is going to be introduced in the next few patches, to make it easier to spot all the code motions.
--- tools/libxl/Makefile | 6 +++--- tools/libxl/libxl_arch.h | 22 ++++++++++++++++++++++ tools/libxl/libxl_noarch.c | 8 ++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tools/libxl/libxl_arch.h create mode 100644 tools/libxl/libxl_noarch.c
tools/libxl/Makefile +3 -3
@@ -34,9 +34,9 @@ LIBXL_OBJS-y += libxl_blktap2.o else LIBXL_OBJS-y += libxl_noblktap2.o endif -LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o -LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o -LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o +LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_noarch.o +LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o libxl_noarch.o +LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_noarch.o ifeq ($(CONFIG_NetBSD),y) LIBXL_OBJS-y += libxl_netbsd.o
tools/libxl/libxl_arch.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (C) 2012 Citrix Ltd. +* +* This program 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 only. with the special +* exception on linking described in file LICENSE. +* +* This program 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. +*/ + +#ifndef LIBXL_ARCH_H +#define LIBXL_ARCH_H + +/* arch specific internal domain creation function */ +int libxl__arch_domain_create (libxl__gc *gc,libxl_domain_config *d_config, +uint32_t domid); + +#endif
tools/libxl/libxl_noarch.c new file +8 -0
@@ -0,0 +1,8 @@ +#include "libxl_internal.h" +#include "libxl_arch.h" + +int libxl__arch_domain_create (libxl__gc *gc,libxl_domain_config *d_config, +uint32_t domid) +{ +return 0 ; +}
Signature · 1 line
1.7.2.5
PATCH v7 6/8 libxl: Introduce libxl__arch_domain_create (x86 version)
In reply to Stefano Stabellini--- tools/libxl/Makefile | 2 +- tools/libxl/libxl_create.c | 12 ++---------- tools/libxl/libxl_x86.c | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 tools/libxl/libxl_x86.c
tools/libxl/Makefile +1 -1
@@ -34,7 +34,7 @@ LIBXL_OBJS-y += libxl_blktap2.o else LIBXL_OBJS-y += libxl_noblktap2.o endif -LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_noarch.o +LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o libxl_noarch.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_noarch.o
tools/libxl/libxl_create.c +2 -10
@@ -18,6 +18,7 @@#include "libxl_osdeps.h" /* must come before any other headers */ #include "libxl_internal.h" +#include "libxl_arch.h" #include <xc_dom.h> #include <xenguest.h>
@@ -820,16 +821,7 @@ static void domcreate_devmodel_started(libxl__egc *egc, } } -if (d_config->c_info.type ==LIBXL_DOMAIN_TYPE_PV && -libxl_defbool_val (d_config->b_info.u.pv.e820_host)) { - ret =libxl__e820_alloc (gc, domid, d_config); -if (ret) { -LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR , -"Failed while collecting E820 with: %d (errno:%d)\n" , - ret, errno); - goto error_out; - } - } +libxl__arch_domain_create (gc, d_config, domid);domcreate_console_available (egc, dcs);domcreate_complete (egc, dcs,0 );
tools/libxl/libxl_x86.c new file +19 -0
@@ -0,0 +1,19 @@ +#include "libxl_internal.h" +#include "libxl_arch.h" + +int libxl__arch_domain_create (libxl__gc *gc,libxl_domain_config *d_config, +uint32_t domid) +{ +int ret =0 ; +if (d_config->c_info.type ==LIBXL_DOMAIN_TYPE_PV && +libxl_defbool_val (d_config->b_info.u.pv.e820_host)) { + ret =libxl__e820_alloc (gc, domid, d_config); +if (ret) { +LIBXL__LOG_ERRNO (gc->owner,LIBXL__LOG_ERROR , +"Failed while collecting E820 with: %d (errno:%d)\n" , + ret, errno); + } + } + +return ret; +}
Signature · 1 line
1.7.2.5
Re: [PATCH v7 6/8] libxl: Introduce libxl__arch_domain_create (x86 version)
Quoted 1 line · Stefano Stabellini
+ LIBXL__LOG_ERRNO(gc->owner,
LIBXL__LOG_ERROR,
BTW you can use "CTX" instead of gc->owner.
Since this is code motion it's not really relevant but in general switching LIBXL__LOG* into LOG* when you are touching a line anyway is nice.
Quoted 7 lines
tools/libxl/libxl_x86.c new file +7
-0+"Failed while collecting E820 with: %d (errno:%d)\n" , + ret, errno); + } + } + +return ret; +}
PATCH v7 7/8 libxl: move e820_names, e820_sanitize, libxl__e820_alloc to libxl_x86.c
In reply to Stefano Stabellini--- tools/libxl/libxl_pci.c | 242 ----------------------------------------------- tools/libxl/libxl_x86.c | 242 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+), 242 deletions(-)
tools/libxl/libxl_pci.c +0 -242
@@ -1412,248 +1412,6 @@ int libxl__device_pci_destroy_all(libxl__gc *gc, uint32_t domid)return 0 ; } -static const char *e820_names (int type) -{ -switch (type) { -case E820_RAM :return "RAM" ; -case E820_RESERVED :return "Reserved" ; -case E820_ACPI :return "ACPI" ; -case E820_NVS :return "ACPI NVS" ; -case E820_UNUSABLE :return "Unusable" ; -default :break ; - } -return "Unknown" ; -} - -static int e820_sanitize (libxl_ctx *ctx,struct e820entry src[], -uint32_t *nr_entries, -unsigned long map_limitkb, -unsigned long balloon_kb) -{ -uint64_t delta_kb =0 , start =0 , start_kb =0 , last =0 , ram_end; -uint32_t i, idx =0 , nr; -struct e820entry e820[E820MAX ]; - -if (!src || !map_limitkb || !nr_entries) -return ERROR_INVAL ; - - nr = *nr_entries; -if (!nr) -return ERROR_INVAL ; - -if (nr >E820MAX ) -return ERROR_NOMEM ; - -/* Weed out anything under 1MB */ -for (i =0 ; i < nr; i++) { -if (src[i].addr >0x100000 ) -continue ; - - src[i].type =0 ; - src[i].size =0 ; - src[i].addr =-1ULL ; - } - -/* Find the lowest and highest entry in E820, skipping over -* undesired entries. */ - start =-1ULL ; - last =0 ; -for (i =0 ; i < nr; i++) { -if ((src[i].type ==E820_RAM ) || - (src[i].type ==E820_UNUSABLE ) || - (src[i].type ==0 )) -continue ; - - start = src[i].addr < start ? src[i].addr : start; - last = src[i].addr + src[i].size > last ? - src[i].addr + src[i].size > last : last; - } -if (start >1024 ) - start_kb = start >>10 ; - -/* Add the memory RAM region for the guest */ - e820[idx].addr =0 ; - e820[idx].size = (uint64_t )map_limitkb <<10 ; - e820[idx].type =E820_RAM ; - -/* .. and trim if neccessary */ -if (start_kb && map_limitkb > start_kb) { - delta_kb = map_limitkb - start_kb; -if (delta_kb) - e820[idx].size -= (uint64_t )(delta_kb <<10 ); - } -/* Note: We don't touch balloon_kb here. Will add it at the end. */ - ram_end = e820[idx].addr + e820[idx].size; - idx ++; - -LIBXL__LOG (ctx,LIBXL__LOG_DEBUG ,"Memory: %" PRIu64"kB End of RAM: " \ -"0x%" PRIx64" (PFN) Delta: %" PRIu64"kB, PCI start: %" PRIu64"kB " \ -"(0x%" PRIx64" PFN), Balloon %" PRIu64"kB\n" , (uint64_t )map_limitkb, - ram_end >>12 , delta_kb, start_kb ,start >>12 , - (uint64_t )balloon_kb); - - -/* This whole code below is to guard against if the Intel IGD is passed into -* the guest. If we don't pass in IGD, this whole code can be ignored. -* -* The reason for this code is that Intel boxes fill their E820 with -* E820_RAM amongst E820_RESERVED and we can't just ditch those E820_RAM. -* That is b/c any "gaps" in the E820 is considered PCI I/O space by -* Linux and it would be utilized by the Intel IGD as I/O space while -* in reality it was an RAM region. -* -* What this means is that we have to walk the E820 and for any region -* that is RAM and below 4GB and above ram_end, needs to change its type -* to E820_UNUSED. We also need to move some of the E820_RAM regions if -* the overlap with ram_end. */ -for (i =0 ; i < nr; i++) { -uint64_t end = src[i].addr + src[i].size; - -/* We don't care about E820_UNUSABLE, but we need to -* change the type to zero b/c the loop after this -* sticks E820_UNUSABLE on the guest's E820 but ignores -* the ones with type zero. */ -if ((src[i].type ==E820_UNUSABLE ) || -/* Any region that is within the "RAM region" can -* be safely ditched. */ - (end < ram_end)) { - src[i].type =0 ; -continue ; - } - -/* Look only at RAM regions. */ -if (src[i].type !=E820_RAM ) -continue ; - -/* We only care about RAM regions below 4GB. */ -if (src[i].addr >= (1ULL <<32 )) -continue ; - -/* E820_RAM overlaps with our RAM region. Move it */ -if (src[i].addr < ram_end) { -uint64_t delta; - - src[i].type =E820_UNUSABLE ; - delta = ram_end - src[i].addr; -/* The end < ram_end should weed this out */ -if (src[i].size - delta <0 ) - src[i].type =0 ; -else { - src[i].size -= delta; - src[i].addr = ram_end; - } -if (src[i].addr + src[i].size != end) { -/* We messed up somewhere */ - src[i].type =0 ; -LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"Computed E820 wrongly. Continuing on." ); - } - } -/* Lastly, convert the RAM to UNSUABLE. Look in the Linux kernel -at git commit 2f14ddc3a7146ea4cd5a3d1ecd993f85f2e4f948 -"xen/setup: Inhibit resource API from using System RAM E820 -gaps as PCI mem gaps" for full explanation. */ -if (end > ram_end) - src[i].type =E820_UNUSABLE ; - } - -/* Check if there is a region between ram_end and start. */ -if (start > ram_end) { -int add_unusable =1 ; -for (i =0 ; i < nr && add_unusable; i++) { -if (src[i].type !=E820_UNUSABLE ) -continue ; -if (ram_end != src[i].addr) -continue ; -if (start != src[i].addr + src[i].size) { -/* there is one, adjust it */ - src[i].size = start - src[i].addr; - } - add_unusable =0 ; - } -/* .. and if not present, add it in. This is to guard against -the Linux guest assuming that the gap between the end of -RAM region and the start of the E820_[ACPI,NVS,RESERVED] -is PCI I/O space. Which it certainly is _not_. */ -if (add_unusable) { - e820[idx].type =E820_UNUSABLE ; - e820[idx].addr = ram_end; - e820[idx].size = start - ram_end; - idx++; - } - } -/* Almost done: copy them over, ignoring the undesireable ones */ -for (i =0 ; i < nr; i++) { -if ((src[i].type ==E820_RAM ) || - (src[i].type ==0 )) -continue ; - - e820[idx].type = src[i].type; - e820[idx].addr = src[i].addr; - e820[idx].size = src[i].size; - idx++; - } -/* At this point we have the mapped RAM + E820 entries from src. */ -if (balloon_kb) { -/* and if we truncated the RAM region, then add it to the end. */ - e820[idx].type =E820_RAM ; - e820[idx].addr = (uint64_t )(1ULL <<32 ) > last ? - (uint64_t )(1ULL <<32 ) : last; -/* also add the balloon memory to the end. */ - e820[idx].size = (uint64_t )(delta_kb <<10 ) + - (uint64_t )(balloon_kb <<10 ); - idx++; - - } - nr = idx; - -for (i =0 ; i < nr; i++) { -LIBXL__LOG (ctx,LIBXL__LOG_DEBUG ,":\t[%" PRIx64" -> %" PRIx64"] %s" , - e820[i].addr >>12 , (e820[i].addr + e820[i].size) >>12 , -e820_names (e820[i].type)); - } - -/* Done: copy the sanitized version. */ - *nr_entries = nr; -memcpy (src, e820, nr *sizeof (struct e820entry )); -return 0 ; -} - -int libxl__e820_alloc (libxl__gc *gc,uint32_t domid,libxl_domain_config *d_config) -{ -libxl_ctx *ctx =libxl__gc_owner (gc); -int rc; -uint32_t nr; -struct e820entry map[E820MAX ]; -libxl_domain_build_info *b_info; - -if (d_config ==NULL || d_config->c_info.type ==LIBXL_DOMAIN_TYPE_HVM ) -return ERROR_INVAL ; - - b_info = &d_config->b_info; -if (!libxl_defbool_val (b_info->u.pv.e820_host)) -return ERROR_INVAL ; - - rc =xc_get_machine_memory_map (ctx->xch, map,E820MAX ); -if (rc <0 ) { - errno = rc; -return ERROR_FAIL ; - } - nr = rc; - rc =e820_sanitize (ctx, map, &nr, b_info->target_memkb, - (b_info->max_memkb - b_info->target_memkb) + - b_info->u.pv.slack_memkb); -if (rc) -return ERROR_FAIL ; - - rc =xc_domain_set_memory_map (ctx->xch, domid, map, nr); - -if (rc <0 ) { - errno = rc; -return ERROR_FAIL ; - } -return 0 ; -} -/* * Local variables: * mode: C
tools/libxl/libxl_x86.c +242 -0
248 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v7 8/8 libxl: make libxl__e820_alloc a static function
In reply to Stefano Stabellini--- tools/libxl/libxl_internal.h | 2 -- tools/libxl/libxl_x86.c | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-)
tools/libxl/libxl_internal.h +0 -2
@@ -1276,8 +1276,6 @@ _hidden int libxl__error_set(libxl__gc *gc, int code); _hidden int libxl__file_reference_map(libxl_file_reference *f); _hidden int libxl__file_reference_unmap(libxl_file_reference *f); -_hidden int libxl__e820_alloc(libxl__gc *gc, uint32_t domid, libxl_domain_config *d_config); -/* parse the string @s as a sequence of 6 colon separated bytes in to @mac */ _hidden int libxl__parse_mac(const char *s, libxl_mac mac);/* compare mac address @a and @b. 0 if the same, -ve if a<b and +ve if a>b */
tools/libxl/libxl_x86.c +2 -1
@@ -207,7 +207,8 @@ static int e820_sanitize(libxl_ctx *ctx, struct e820entry src[],return 0 ; } -int libxl__e820_alloc (libxl__gc *gc,uint32_t domid,libxl_domain_config *d_config) +static int libxl__e820_alloc (libxl__gc *gc,uint32_t domid, +libxl_domain_config *d_config) {libxl_ctx *ctx =libxl__gc_owner (gc);int rc;
Signature · 1 line
1.7.2.5
Quoted 5 lines · Stefano Stabellini
Hi all,
this patch series allowstools/to compile on ARM, mostly providing an empty implementation for all the arch specific functions that are needed.All the patches of this series have been previously acked.
I am proposing this series for 4.2, not only because it has been acked since the beginning of March
(http://marc.info/?l=xen-devel&m=133070513015066) and it doesn't contain any functional changes since then, but also because the X86 changes are limited to code motion and related Makefile.
In particular:
- patch #1
the big x86 change is just a rename of xc_hvm_build.c to xc_hvm_build_x86.c;
- patch #4
moves libxl_cpuid_policy_list_gen_json from libxl_json.c to libxl_cpuid.c;
- patch #6
moves 10 lines from libxl_create.c to libxl_x86.c;
- patch #7
move e820_names, e820_sanitize, libxl__e820_alloc from libxl_pci.c to libxl_x86.c.
Quoted 92 lines
Changes in v7:
- rebase on "
x86_64: Record entry vector for double faults.";- split the last patch in three patches to make it easier to read and find all the code motions (I kept the acked-by on all the patches because there are no changes except the split).
Changes in v6:
- rebase on
33659563f589(this is a mercurial id).Changes in v5:
- libxc: return -1 and set errno on error;
- add few missing emacs runes in new files.
Changes in v4:
- rebased on
55a36564fb4f85722c67f16fe508f3ecbd204549;- minor compile fixes.
Changes in v3:
- move
libxl_cpuid_policy_list_gen_jsonto libxl_(no)cpuid.c;- rename
xc_hvm_build.ctoxc_hvm_build_x86.c;- remove
xc_nohvm, introducexc_hvm_build_arm.cinstead;- remove "libxl: do not allocate e820 for non x86 guests.";
- introduce
libxl__arch_domain_create.Changes in v2:
- rebased on
a22587ae517170a7755d3a88611ae0e2d5bb555e;- dropped "arm:
arch_dump_shared_mem_infoas a no-op" that is already in xen-unstable;- define
xen_callback_tasuint64_t;- define
guest_word_tasuint64_t.Stefano Stabellini (8):
arm: compile libxenguest
arm: compile memshr
arm: compile xentrace
arm: compile libxl
libxl: Introducelibxl__arch_domain_create
libxl: Introducelibxl__arch_domain_create(x86 version)
libxl: movee820_names,e820_sanitize,libxl__e820_alloctolibxl_x86.c
libxl: makelibxl__e820_alloca static functiontools/libxc/Makefile | 12 +- tools/libxc/xc_dom_arm.c | 50 +++++ tools/libxc/xc_hvm_build.c | 472 ---------------------------------------- tools/libxc/xc_hvm_build_arm.c | 49 ++++ tools/libxc/xc_hvm_build_x86.c | 472 ++++++++++++++++++++++++++++++++++++++++ tools/libxc/xc_nomigrate.c | 54 +++++ tools/libxl/Makefile | 5 +- tools/libxl/libxl_arch.h | 22 ++ tools/libxl/libxl_cpuid.c | 60 +++++ tools/libxl/libxl_create.c | 12 +- tools/libxl/libxl_internal.h | 2 - tools/libxl/libxl_json.c | 60 ----- tools/libxl/libxl_noarch.c | 8 + tools/libxl/libxl_nocpuid.c | 8 +- tools/libxl/libxl_pci.c | 242 -------------------- tools/libxl/libxl_x86.c | 262 ++++++++++++++++++++++ tools/memshr/bidir-hash.c | 31 +++ tools/xentrace/xenctx.c | 12 + 18 files changed, 1041 insertions(+), 792 deletions(-)Cheers,
Stefano
Quoted 22 lines · Stefano Stabellini
Quoted 5 lines · Stefano Stabellini
Hi all,
this patch series allowstools/to compile on ARM, mostly providing an empty implementation for all the arch specific functions that are needed.All the patches of this series have been previously acked.
I am proposing this series for 4.2, not only because it has been acked since the beginning of March
(http://marc.info/?l=xen-devel&m=133070513015066) and it doesn't contain any functional changes since then, but also because the X86 changes are limited to code motion and relatedMakefile.In particular:
- patch #1
the big x86 change is just a rename ofxc_hvm_build.ctoxc_hvm_build_x86.c;- patch #4
moveslibxl_cpuid_policy_list_gen_jsonfromlibxl_json.ctolibxl_cpuid.c;
Quoted 6 lines
- patch #6
moves 10 lines fromlibxl_create.ctolibxl_x86.c;- patch #7
movee820_names,e820_sanitize,libxl__e820_allocfromlibxl_pci.ctolibxl_x86.c.
and the remainder is all #if __arm__ or similar.
I think on that basis we can take this for 4.2.
Ian.
Ian Campbell writes ("Re: [PATCH v7 0/8] arm: compile tools"):
Quoted 26 lines · Stefano Stabellini
Quoted 25 lines · Stefano Stabellini
Quoted 5 lines
Hi all,
this patch series allowstools/to compile on ARM, mostly providing an empty implementation for all the arch specific functions that are needed.All the patches of this series have been previously acked.
I am proposing this series for 4.2, not only because it has been acked since the beginning of March
(http://marc.info/?l=xen-devel&m=133070513015066) and it doesn't contain any functional changes since then, but also because the X86 changes are limited to code motion and relatedMakefile.In particular:
- patch #1
the big x86 change is just a rename ofxc_hvm_build.ctoxc_hvm_build_x86.c;- patch #4
moveslibxl_cpuid_policy_list_gen_jsonfromlibxl_json.ctolibxl_cpuid.c;- patch #6
moves 10 lines fromlibxl_create.ctolibxl_x86.c;
Quoted 7 lines
Quoted 3 lines
- patch #7
movee820_names,e820_sanitize,libxl__e820_allocfromlibxl_pci.ctolibxl_x86.c.and the remainder is all #if
__arm__or similar.I think on that basis we can take this for 4.2.
Yes, I agree. Ian C, please go ahead and commit this when you're ready to do so.
Ian.
Quoted 18 lines · Stefano Stabellini
Quoted 5 lines · Stefano Stabellini
Hi all,
this patch series allowstools/to compile on ARM, mostly providing an empty implementation for all the arch specific functions that are needed.All the patches of this series have been previously acked.
I am proposing this series for 4.2, not only because it has been acked since the beginning of March
(http://marc.info/?l=xen-devel&m=133070513015066) and it doesn't contain any functional changes since then, but also because the X86 changes are limited to code motion and relatedMakefile.In particular:
- patch #1
the big x86 change is just a rename ofxc_hvm_build.ctoxc_hvm_build_x86.c;
Quoted 6 lines
- patch #4
moveslibxl_cpuid_policy_list_gen_jsonfromlibxl_json.ctolibxl_cpuid.c;- patch #6
moves 10 lines fromlibxl_create.ctolibxl_x86.c;
... and s/ctx/gc->owner (which is fine, AFAICT, but useful to mention).
Quoted 3 lines
- patch #7
movee820_names,e820_sanitize,libxl__e820_allocfromlibxl_pci.ctolibxl_x86.c.
I checked all these and they are indeed code motion (other than the nit above).
I build tested x86 and arm and have pushed.
Thanks!
Quoted 98 lines
Quoted 98 lines
Changes in v7:
- rebase on "
x86_64: Record entry vector for double faults.";- split the last patch in three patches to make it easier to read and find all the code motions (I kept the acked-by on all the patches because there are no changes except the split).
Changes in v6:
- rebase on
33659563f589(this is a mercurial id).Changes in v5:
- libxc: return -1 and set errno on error;
- add few missing emacs runes in new files.
Changes in v4:
- rebased on
55a36564fb4f85722c67f16fe508f3ecbd204549;- minor compile fixes.
Changes in v3:
- move
libxl_cpuid_policy_list_gen_jsonto libxl_(no)cpuid.c;- rename
xc_hvm_build.ctoxc_hvm_build_x86.c;- remove
xc_nohvm, introducexc_hvm_build_arm.cinstead;- remove "libxl: do not allocate e820 for non x86 guests.";
- introduce
libxl__arch_domain_create.Changes in v2:
- rebased on
a22587ae517170a7755d3a88611ae0e2d5bb555e;- dropped "arm:
arch_dump_shared_mem_infoas a no-op" that is already in xen-unstable;- define
xen_callback_tasuint64_t;- define
guest_word_tasuint64_t.Stefano Stabellini (8):
arm: compile libxenguest
arm: compile memshr
arm: compile xentrace
arm: compile libxl
libxl: Introducelibxl__arch_domain_create
libxl: Introducelibxl__arch_domain_create(x86 version)
libxl: movee820_names,e820_sanitize,libxl__e820_alloctolibxl_x86.c
libxl: makelibxl__e820_alloca static functiontools/libxc/Makefile | 12 +- tools/libxc/xc_dom_arm.c | 50 +++++ tools/libxc/xc_hvm_build.c | 472 ---------------------------------------- tools/libxc/xc_hvm_build_arm.c | 49 ++++ tools/libxc/xc_hvm_build_x86.c | 472 ++++++++++++++++++++++++++++++++++++++++ tools/libxc/xc_nomigrate.c | 54 +++++ tools/libxl/Makefile | 5 +- tools/libxl/libxl_arch.h | 22 ++ tools/libxl/libxl_cpuid.c | 60 +++++ tools/libxl/libxl_create.c | 12 +- tools/libxl/libxl_internal.h | 2 - tools/libxl/libxl_json.c | 60 ----- tools/libxl/libxl_noarch.c | 8 + tools/libxl/libxl_nocpuid.c | 8 +- tools/libxl/libxl_pci.c | 242 -------------------- tools/libxl/libxl_x86.c | 262 ++++++++++++++++++++++ tools/memshr/bidir-hash.c | 31 +++ tools/xentrace/xenctx.c | 12 + 18 files changed, 1041 insertions(+), 792 deletions(-)Cheers,
Stefano