Re: [Xen-devel] [PATCH v5 02/16] libxl/arm: prepare for constructing ACPI tables
Hi Shannon, On 02/09/16 03:55, Shannon Zhao wrote: From: Shannon ZhaoIt only constructs the ACPI tables for 64-bit ARM DomU when user enables acpi because 32-bit DomU doesn't support ACPI. And the generation codes are only built for 64-bit toolstack. Signed-off-by: Shannon Zhao Acked-by: Julien Grall Regards, --- tools/libxl/Makefile| 7 + tools/libxl/libxl_arm.c | 24 +++- tools/libxl/libxl_arm.h | 33 ++ tools/libxl/libxl_arm_acpi.c| 62 + tools/libxl/libxl_arm_no_acpi.c | 34 ++ xen/include/public/arch-arm.h | 4 +++ 6 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 tools/libxl/libxl_arm.h create mode 100644 tools/libxl/libxl_arm_acpi.c create mode 100644 tools/libxl/libxl_arm_no_acpi.c diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index a148374..afd93de 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -90,6 +90,13 @@ acpi: LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o +ifeq ($(CONFIG_ARM_64),y) +LIBXL_OBJS-y += libxl_arm_acpi.o +libxl_arm_acpi.o: libxl_arm_acpi.c + $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c +else +LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_no_acpi.o +endif ifeq ($(CONFIG_NetBSD),y) LIBXL_OBJS-y += libxl_netbsd.o diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index 8ec5cd5..333c9a1 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -1,6 +1,7 @@ #include "libxl_internal.h" #include "libxl_arch.h" #include "libxl_libfdt_compat.h" +#include "libxl_arm.h" #include #include @@ -885,8 +886,29 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc, libxl__domain_build_state *state, struct xc_dom_image *dom) { +int rc; + assert(info->type == LIBXL_DOMAIN_TYPE_PV); -return libxl__prepare_dtb(gc, info, state, dom); +rc = libxl__prepare_dtb(gc, info, state, dom); +if (rc) goto out; + +if (!libxl_defbool_val(info->acpi)) { +LOG(DEBUG, "Generating ACPI tables is disabled by user."); +rc = 0; +goto out; +} + +if (strcmp(dom->guest_type, "xen-3.0-aarch64")) { +/* ACPI is only supported for 64-bit guest currently. */ +LOG(ERROR, "Can not enable libxl option 'acpi' for %s", dom->guest_type); +rc = ERROR_FAIL; +goto out; +} + +rc = libxl__prepare_acpi(gc, info, state, dom); + +out: +return rc; } static void finalise_one_memory_node(libxl__gc *gc, void *fdt, diff --git a/tools/libxl/libxl_arm.h b/tools/libxl/libxl_arm.h new file mode 100644 index 000..1c01177 --- /dev/null +++ b/tools/libxl/libxl_arm.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2016 Linaro Ltd. + * + * Author: Shannon Zhao + * + * 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. + */ + +#include "libxl_internal.h" +#include "libxl_arch.h" + +#include + +_hidden +int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, +libxl__domain_build_state *state, +struct xc_dom_image *dom); + +/* + * Local variables: + * mode: C + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c new file mode 100644 index 000..810aed8 --- /dev/null +++ b/tools/libxl/libxl_arm_acpi.c @@ -0,0 +1,62 @@ +/* + * ARM DomU ACPI generation + * + * Copyright (C) 2016 Linaro Ltd. + * + * Author: Shannon Zhao + * + * 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. + */ + +#include "libxl_arm.h" + +#include + +/* Below typedefs are useful for the headers under acpi/ */ +typedef
Re: [Xen-devel] [PATCH v5 02/16] libxl/arm: prepare for constructing ACPI tables
On Fri, Sep 02, 2016 at 10:55:25AM +0800, Shannon Zhao wrote: > From: Shannon Zhao> > It only constructs the ACPI tables for 64-bit ARM DomU when user enables > acpi because 32-bit DomU doesn't support ACPI. And the generation codes > are only built for 64-bit toolstack. > > Signed-off-by: Shannon Zhao The code looks reasonable to me. Subject to an ack from ARM maintainers: Acked-by: Wei Liu ___ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel
[Xen-devel] [PATCH v5 02/16] libxl/arm: prepare for constructing ACPI tables
From: Shannon ZhaoIt only constructs the ACPI tables for 64-bit ARM DomU when user enables acpi because 32-bit DomU doesn't support ACPI. And the generation codes are only built for 64-bit toolstack. Signed-off-by: Shannon Zhao --- tools/libxl/Makefile| 7 + tools/libxl/libxl_arm.c | 24 +++- tools/libxl/libxl_arm.h | 33 ++ tools/libxl/libxl_arm_acpi.c| 62 + tools/libxl/libxl_arm_no_acpi.c | 34 ++ xen/include/public/arch-arm.h | 4 +++ 6 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 tools/libxl/libxl_arm.h create mode 100644 tools/libxl/libxl_arm_acpi.c create mode 100644 tools/libxl/libxl_arm_no_acpi.c diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index a148374..afd93de 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -90,6 +90,13 @@ acpi: LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o +ifeq ($(CONFIG_ARM_64),y) +LIBXL_OBJS-y += libxl_arm_acpi.o +libxl_arm_acpi.o: libxl_arm_acpi.c + $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c +else +LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_no_acpi.o +endif ifeq ($(CONFIG_NetBSD),y) LIBXL_OBJS-y += libxl_netbsd.o diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index 8ec5cd5..333c9a1 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -1,6 +1,7 @@ #include "libxl_internal.h" #include "libxl_arch.h" #include "libxl_libfdt_compat.h" +#include "libxl_arm.h" #include #include @@ -885,8 +886,29 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc, libxl__domain_build_state *state, struct xc_dom_image *dom) { +int rc; + assert(info->type == LIBXL_DOMAIN_TYPE_PV); -return libxl__prepare_dtb(gc, info, state, dom); +rc = libxl__prepare_dtb(gc, info, state, dom); +if (rc) goto out; + +if (!libxl_defbool_val(info->acpi)) { +LOG(DEBUG, "Generating ACPI tables is disabled by user."); +rc = 0; +goto out; +} + +if (strcmp(dom->guest_type, "xen-3.0-aarch64")) { +/* ACPI is only supported for 64-bit guest currently. */ +LOG(ERROR, "Can not enable libxl option 'acpi' for %s", dom->guest_type); +rc = ERROR_FAIL; +goto out; +} + +rc = libxl__prepare_acpi(gc, info, state, dom); + +out: +return rc; } static void finalise_one_memory_node(libxl__gc *gc, void *fdt, diff --git a/tools/libxl/libxl_arm.h b/tools/libxl/libxl_arm.h new file mode 100644 index 000..1c01177 --- /dev/null +++ b/tools/libxl/libxl_arm.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2016 Linaro Ltd. + * + * Author: Shannon Zhao + * + * 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. + */ + +#include "libxl_internal.h" +#include "libxl_arch.h" + +#include + +_hidden +int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, +libxl__domain_build_state *state, +struct xc_dom_image *dom); + +/* + * Local variables: + * mode: C + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c new file mode 100644 index 000..810aed8 --- /dev/null +++ b/tools/libxl/libxl_arm_acpi.c @@ -0,0 +1,62 @@ +/* + * ARM DomU ACPI generation + * + * Copyright (C) 2016 Linaro Ltd. + * + * Author: Shannon Zhao + * + * 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. + */ + +#include "libxl_arm.h" + +#include + +/* Below typedefs are useful for the headers under acpi/ */ +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +#include +#include + +int