xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/17] Xen ARM DomU ACPI support
@ 2016-07-05  3:12 Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB Shannon Zhao
                   ` (17 more replies)
  0 siblings, 18 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Note: while there are still two points (user configuration name and
where to load the ACPI blob) which we don't reach an agreement and need
other maintainer's opinions, but I'd like to send the updated series out
since we could move forward and once we reach an agreement I can make
changes.

The design of this feature is described as below.
Firstly, the toolstack (libxl) generates the ACPI tables according the
number of vcpus and gic controller.

Then, it copies these ACPI tables to DomU non-RAM memory map space and
passes them to UEFI firmware through the "ARM multiboot" protocol.

At last, UEFI gets the ACPI tables through the "ARM multiboot" protocol
and installs these tables like the usual way and passes both ACPI and DT
information to the Xen DomU.

Currently libxl only generates RSDP, XSDT, GTDT, MADT, FADT, DSDT tables
since it's enough now.

This has been tested using guest kernel with the Dom0 ACPI support
patches which could be fetched from:
https://git.kernel.org/cgit/linux/kernel/git/mfleming/efi.git/log/?h=efi/arm-xen

The UEFI binary could be fetched from or built from edk2 master branch:
http://people.linaro.org/~shannon.zhao/DomU_ACPI/XEN_EFI.fd

This series can be fetched from:
https://git.linaro.org/people/shannon.zhao/xen.git  domu_acpi_v3

Changes since v2:
* return error for 32bit domain with acpi enabled
* include actypes.h to reuse the definitions
* rename libxl_arm_acpi.h to libxl_arm.h
* use ACPI_MADT_ENABLED
* rebased on top of Boris's ACPI branch to reuse mk_dsdt.c

Changes since v1:
* move ACPI tables generation codes to a new file
* use static asl file to generate DSDT table and include processor
  device objects
* assign a non-RAM map for ACPI blob
* use existing ACPI table definitions under xen/include/acpi/
* add a configuration for user to enable/disable ACPI generation
* calculate the ACPI table checksum

Shannon Zhao (17):
  libxl/arm: Factor out codes for generating DTB
  libxc: Add placeholders for ACPI tables blob and size
  libxl/arm: Add a configuration option for ARM DomU ACPI
  libxl/arm: prepare for constructing ACPI tables
  libxl/arm: Generate static ACPI DSDT table
  libxl/arm: Estimate the size of ACPI tables
  libxl/arm: Construct ACPI RSDP table
  libxl/arm: Construct ACPI XSDT table
  libxl/arm: Construct ACPI GTDT table
  libxl/arm: Factor MPIDR computing codes out as a helper
  libxl/arm: Construct ACPI MADT table
  libxl/arm: Construct ACPI FADT table
  libxl/arm: Construct ACPI DSDT table
  libxl/arm: Factor finalise_one_memory_node as a gerneric function
  libxl/arm: Add ACPI module
  libxc/xc_dom_core: Copy ACPI tables to guest space
  libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ

 docs/misc/arm/device-tree/acpi.txt |  24 +++
 tools/libacpi/Makefile             |  15 +-
 tools/libacpi/mk_dsdt.c            |  51 ++++--
 tools/libxc/include/xc_dom.h       |   2 +
 tools/libxc/xc_dom_core.c          |  51 ++++++
 tools/libxl/Makefile               |   7 +
 tools/libxl/libxl.h                |   5 +
 tools/libxl/libxl_arm.c            |  86 +++++++--
 tools/libxl/libxl_arm.h            |  44 +++++
 tools/libxl/libxl_arm_acpi.c       | 354 +++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_types.idl        |   1 +
 tools/libxl/xl_cmdimpl.c           |   4 +
 xen/include/public/arch-arm.h      |   7 +
 13 files changed, 620 insertions(+), 31 deletions(-)
 create mode 100644 docs/misc/arm/device-tree/acpi.txt
 create mode 100644 tools/libxl/libxl_arm.h
 create mode 100644 tools/libxl/libxl_arm_acpi.c

-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-07 15:41   ` Wei Liu
  2016-07-05  3:12 ` [PATCH v3 02/17] libxc: Add placeholders for ACPI tables blob and size Shannon Zhao
                   ` (16 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Factor out codes for generating DTB to prepare for adding ACPI tables
generation codes.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl_arm.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index ddd80aa..4a57dd7 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -747,10 +747,9 @@ static int copy_partial_fdt(libxl__gc *gc, void *fdt, void *pfdt)
 
 #define FDT_MAX_SIZE (1<<20)
 
-int libxl__arch_domain_init_hw_description(libxl__gc *gc,
-                                           libxl_domain_build_info *info,
-                                           libxl__domain_build_state *state,
-                                           struct xc_dom_image *dom)
+static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
+                       libxl__domain_build_state *state,
+                       struct xc_dom_image *dom)
 {
     void *fdt = NULL;
     void *pfdt = NULL;
@@ -764,8 +763,6 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc,
     /* convenience aliases */
     xc_domain_configuration_t *xc_config = &state->config;
 
-    assert(info->type == LIBXL_DOMAIN_TYPE_PV);
-
     vers = libxl_get_version_info(CTX);
     if (vers == NULL) return ERROR_FAIL;
 
@@ -883,6 +880,15 @@ out:
     return rc;
 }
 
+int libxl__arch_domain_init_hw_description(libxl__gc *gc,
+                                           libxl_domain_build_info *info,
+                                           libxl__domain_build_state *state,
+                                           struct xc_dom_image *dom)
+{
+    assert(info->type == LIBXL_DOMAIN_TYPE_PV);
+    return libxl__prepare_dtb(gc, info, state, dom);
+}
+
 static void finalise_one_memory_node(libxl__gc *gc, void *fdt,
                                      uint64_t base, uint64_t size)
 {
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 02/17] libxc: Add placeholders for ACPI tables blob and size
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-07 15:42   ` Wei Liu
  2016-07-05  3:12 ` [PATCH v3 03/17] libxl/arm: Add a configuration option for ARM DomU ACPI Shannon Zhao
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Add placeholders for ACPI tables blob and size here so that ACPI blob
can be accessed from libxl and libxc.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxc/include/xc_dom.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
index 6cb10c4..cbeb4fb 100644
--- a/tools/libxc/include/xc_dom.h
+++ b/tools/libxc/include/xc_dom.h
@@ -64,6 +64,8 @@ struct xc_dom_image {
     size_t ramdisk_size;
     void *devicetree_blob;
     size_t devicetree_size;
+    void *acpitable_blob;
+    size_t acpitable_size;
 
     size_t max_kernel_size;
     size_t max_ramdisk_size;
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 03/17] libxl/arm: Add a configuration option for ARM DomU ACPI
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 02/17] libxc: Add placeholders for ACPI tables blob and size Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-07 15:48   ` Wei Liu
  2016-07-05  3:12 ` [PATCH v3 04/17] libxl/arm: prepare for constructing ACPI tables Shannon Zhao
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Add a configuration option for ARM DomU so that user can deicde to use
ACPI or not. This option is defaultly false.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl.h         | 5 +++++
 tools/libxl/libxl_types.idl | 1 +
 tools/libxl/xl_cmdimpl.c    | 4 ++++
 3 files changed, 10 insertions(+)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 2c0f868..ccaf87b 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -234,6 +234,11 @@
 #define LIBXL_HAVE_BUILDINFO_ARM_GIC_VERSION 1
 
 /*
+ * libxl_domain_build_info has the arm.acpi field.
+ */
+#define LIBXL_HAVE_BUILDINFO_ARM_ACPI 1
+
+/*
  * LIBXL_HAVE_SOFT_RESET indicates that libxl supports performing
  * 'soft reset' for domains and there is 'soft_reset' shutdown reason
  * in enum libxl_shutdown_reason.
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index ef614be..426b868 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -560,6 +560,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
 
 
     ("arch_arm", Struct(None, [("gic_version", libxl_gic_version),
+                               ("acpi", libxl_defbool),
                               ])),
 
     ], dir=DIR_IN
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 6459eec..0634ffa 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -2506,6 +2506,10 @@ skip_usbdev:
         }
      }
 
+    if (xlu_cfg_get_defbool(config, "acpi", &b_info->arch_arm.acpi, 0)) {
+        libxl_defbool_set(&b_info->arch_arm.acpi, 0);
+    }
+
     xlu_cfg_destroy(config);
 }
 
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 04/17] libxl/arm: prepare for constructing ACPI tables
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (2 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 03/17] libxl/arm: Add a configuration option for ARM DomU ACPI Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-07 15:50   ` Wei Liu
  2016-07-05  3:12 ` [PATCH v3 05/17] libxl/arm: Generate static ACPI DSDT table Shannon Zhao
                   ` (13 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

It only constructs the ACPI tables for 64-bit ARM DomU when user enables
acpi because 32-bit DomU doesn't support ACPI.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/Makefile         |  4 ++++
 tools/libxl/libxl_arm.c      | 19 ++++++++++++++-
 tools/libxl/libxl_arm.h      | 33 ++++++++++++++++++++++++++
 tools/libxl/libxl_arm_acpi.c | 56 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 111 insertions(+), 1 deletion(-)
 create mode 100644 tools/libxl/libxl_arm.h
 create mode 100644 tools/libxl/libxl_arm_acpi.c

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 0cf9f6a..88ab4d2 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -91,6 +91,10 @@ 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
+LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_acpi.o
+
+libxl_arm_acpi.o: libxl_arm_acpi.c
+	$(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c
 
 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 4a57dd7..7c522e1 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 <xc_dom.h>
 #include <stdbool.h>
@@ -885,8 +886,24 @@ 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)
+        return rc;
+
+    if (!libxl_defbool_val(info->arch_arm.acpi)) {
+        LOG(DEBUG, "Generating ACPI tables is disabled by user.");
+        return 0;
+    }
+
+    if (strcmp(dom->guest_type, "xen-3.0-aarch64")) {
+        LOG(ERROR, "Can not enable xl option 'acpi' for %s", dom->guest_type);
+        return ERROR_FAIL;
+    }
+
+    return libxl__prepare_acpi(gc, info, state, dom);
 }
 
 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 0000000..1c01177
--- /dev/null
+++ b/tools/libxl/libxl_arm.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016      Linaro Ltd.
+ *
+ * Author: Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * 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 <xc_dom.h>
+
+_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 0000000..8c273f9
--- /dev/null
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -0,0 +1,56 @@
+/*
+ * ARM DomU ACPI generation
+ *
+ * Copyright (C) 2016      Linaro Ltd.
+ *
+ * Author: Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * 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 <stdint.h>
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+
+#include <acpi/acconfig.h>
+#include <acpi/actbl.h>
+
+int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
+                        libxl__domain_build_state *state,
+                        struct xc_dom_image *dom)
+{
+    const libxl_version_info *vers;
+
+    vers = libxl_get_version_info(CTX);
+    if (vers == NULL)
+        return ERROR_FAIL;
+
+    LOG(DEBUG, "constructing ACPI tables for Xen version %d.%d guest",
+        vers->xen_version_major, vers->xen_version_minor);
+
+    dom->acpitable_blob = NULL;
+    dom->acpitable_size = 0;
+
+    return 0;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 05/17] libxl/arm: Generate static ACPI DSDT table
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (3 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 04/17] libxl/arm: prepare for constructing ACPI tables Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-07 15:52   ` Wei Liu
  2016-07-05  3:12 ` [PATCH v3 06/17] libxl/arm: Estimate the size of ACPI tables Shannon Zhao
                   ` (12 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

It uses static DSDT table like the way x86 uses. Currently the DSDT
table only contains processor device objects and it generates the
maximal objects which so far is 128.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libacpi/Makefile        | 15 ++++++++++++-
 tools/libacpi/mk_dsdt.c       | 51 ++++++++++++++++++++++++++++++++-----------
 tools/libxl/Makefile          |  5 ++++-
 tools/libxl/libxl_arm_acpi.c  |  5 +++++
 xen/include/public/arch-arm.h |  3 +++
 5 files changed, 64 insertions(+), 15 deletions(-)

diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
index 4068d9a..0401810 100644
--- a/tools/libacpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -22,6 +22,7 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
 # Sources to be generated
 C_SRC = $(ACPI_BUILD_DIR)/dsdt_anycpu.c $(ACPI_BUILD_DIR)/dsdt_15cpu.c 
 C_SRC += $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.c $(ACPI_BUILD_DIR)/dsdt_pvh.c
+C_SRC += $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.c
 H_SRC = $(ACPI_BUILD_DIR)/ssdt_s3.h $(ACPI_BUILD_DIR)/ssdt_s4.h $(ACPI_BUILD_DIR)/ssdt_pm.h $(ACPI_BUILD_DIR)/ssdt_tpm.h
 
 vpath iasl $(PATH)
@@ -35,7 +36,7 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
 	cd $(CURDIR)
 
 $(MK_DSDT): mk_dsdt.c
-	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
+	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -o $@ mk_dsdt.c
 
 $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
@@ -69,6 +70,18 @@ $(ACPI_BUILD_DIR)/dsdt_pvh.c: iasl $(ACPI_BUILD_DIR)/dsdt_pvh.asl
 	rm -f $*.aml $*.hex
 	cd $(CURDIR)
 
+$(ACPI_BUILD_DIR)/dsdt_anycpu_arm.asl: $(MK_DSDT)
+	printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 3, \"XenARM\", \"Xen DSDT\", 1)\n{" > $@
+	$(MK_DSDT) --debug=$(debug) --arch arm >> $@
+
+$(ACPI_BUILD_DIR)/dsdt_anycpu_arm.c: iasl $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.asl
+	cd $(ACPI_BUILD_DIR)
+	iasl -vs -p $* -tc $(ACPI_BUILD_DIR)/$*.asl
+	sed -e 's/AmlCode/$*/g' $*.hex >$@
+	echo "int $*_len=sizeof($*);" >>$@
+	rm -f $*.aml $*.hex
+	cd $(CURDIR)
+
 iasl:
 	@echo
 	@echo "ACPI ASL compiler (iasl) is needed"
diff --git a/tools/libacpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c
index 1322510..1d3ed0f 100644
--- a/tools/libacpi/mk_dsdt.c
+++ b/tools/libacpi/mk_dsdt.c
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 #include <stdbool.h>
 #include <xen/hvm/hvm_info_table.h>
+#include <xen/arch-arm.h>
 
 static unsigned int indent_level;
 static bool debug = false;
@@ -87,6 +88,7 @@ static struct option options[] = {
     { "dm-version", 1, 0, 'q' },
     { "debug", 1, 0, 'd' },
     { "no-dm", 0, 0, 'n' },
+    { "arch", 1, 0, 'a' },
     { 0, 0, 0, 0 }
 };
 
@@ -94,7 +96,7 @@ int main(int argc, char **argv)
 {
     unsigned int slot, dev, intx, link, cpu, max_cpus = HVM_MAX_VCPUS;
     dm_version dm_version = QEMU_XEN_TRADITIONAL;
-    bool no_dm = 0;
+    bool no_dm = 0, arch_is_arm = false;
 
     for ( ; ; )
     {
@@ -133,6 +135,10 @@ int main(int argc, char **argv)
         case 'n':
             no_dm = 1;
             break;
+        case 'a':
+            if (strcmp(optarg, "arm") == 0)
+                arch_is_arm = true;
+            break;
         case 'd':
             if (*optarg == 'y')
                 debug = true;
@@ -142,6 +148,9 @@ int main(int argc, char **argv)
         }
     }
 
+    if (arch_is_arm)
+        max_cpus = GUEST_MAX_VCPUS;
+
     /**** DSDT DefinitionBlock start ****/
     /* (we append to existing DSDT definition block) */
     indent_level++;
@@ -149,19 +158,21 @@ int main(int argc, char **argv)
     /**** Processor start ****/
     push_block("Scope", "\\_SB");
 
-    /* MADT checksum */
-    stmt("OperationRegion", "MSUM, SystemMemory, \\_SB.MSUA, 1");
-    push_block("Field", "MSUM, ByteAcc, NoLock, Preserve");
-    indent(); printf("MSU, 8\n");
-    pop_block();
+    if (!arch_is_arm) {
+        /* MADT checksum */
+        stmt("OperationRegion", "MSUM, SystemMemory, \\_SB.MSUA, 1");
+        push_block("Field", "MSUM, ByteAcc, NoLock, Preserve");
+        indent(); printf("MSU, 8\n");
+        pop_block();
 
-    /* Processor object helpers. */
-    push_block("Method", "PMAT, 2");
-    push_block("If", "LLess(Arg0, NCPU)");
-    stmt("Return", "ToBuffer(Arg1)");
-    pop_block();
-    stmt("Return", "Buffer() {0, 8, 0xff, 0xff, 0, 0, 0, 0}");
-    pop_block();
+        /* Processor object helpers. */
+        push_block("Method", "PMAT, 2");
+        push_block("If", "LLess(Arg0, NCPU)");
+        stmt("Return", "ToBuffer(Arg1)");
+        pop_block();
+        stmt("Return", "Buffer() {0, 8, 0xff, 0xff, 0, 0, 0, 0}");
+        pop_block();
+    }
 
     /* Define processor objects and control methods. */
     for ( cpu = 0; cpu < max_cpus; cpu++)
@@ -170,6 +181,12 @@ int main(int argc, char **argv)
 
         stmt("Name", "_HID, \"ACPI0007\"");
 
+        if (arch_is_arm) {
+            stmt("Name", "_UID, %d", cpu);
+            pop_block();
+            continue;
+        }
+
         /* Name this processor's MADT LAPIC descriptor. */
         stmt("OperationRegion", 
              "MATR, SystemMemory, Add(\\_SB.MAPA, %d), 8", cpu*8);
@@ -208,6 +225,14 @@ int main(int argc, char **argv)
         pop_block();
     }
 
+    if (arch_is_arm) {
+        pop_block();
+        /**** Processor end ****/
+        pop_block();
+        /**** DSDT DefinitionBlock end ****/
+        return 0;
+    }
+
     /* Operation Region 'PRST': bitmask of online CPUs. */
     stmt("OperationRegion", "PRST, SystemIO, 0xaf00, 32");
     push_block("Field", "PRST, ByteAcc, NoLock, Preserve");
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 88ab4d2..a398c8e 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -91,7 +91,10 @@ 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
-LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_acpi.o
+LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_acpi.o dsdt_anycpu_arm.o
+
+dsdt_anycpu_arm.c:
+	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(shell pwd)
 
 libxl_arm_acpi.o: libxl_arm_acpi.c
 	$(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c
diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 8c273f9..d1c066d 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -28,6 +28,11 @@ typedef uint64_t u64;
 #include <acpi/acconfig.h>
 #include <acpi/actbl.h>
 
+_hidden
+extern const unsigned char dsdt_anycpu_arm[];
+_hidden
+extern const int dsdt_anycpu_arm_len;
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)
diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index 870bc3b..4a49254 100644
--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -431,6 +431,9 @@ typedef uint64_t xen_callback_t;
 #define GUEST_RAM_BANK_BASES   { GUEST_RAM0_BASE, GUEST_RAM1_BASE }
 #define GUEST_RAM_BANK_SIZES   { GUEST_RAM0_SIZE, GUEST_RAM1_SIZE }
 
+/* Current supported guest VCPUs */
+#define GUEST_MAX_VCPUS 128
+
 /* Interrupts */
 #define GUEST_TIMER_VIRT_PPI    27
 #define GUEST_TIMER_PHYS_S_PPI  29
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 06/17] libxl/arm: Estimate the size of ACPI tables
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (4 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 05/17] libxl/arm: Generate static ACPI DSDT table Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-07 16:07   ` Wei Liu
  2016-07-05  3:12 ` [PATCH v3 07/17] libxl/arm: Construct ACPI RSDP table Shannon Zhao
                   ` (11 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Estimate the size of ACPI tables and reserve a memory map space for ACPI
tables.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm_acpi.c  | 85 +++++++++++++++++++++++++++++++++++++++++++
 xen/include/public/arch-arm.h |  4 ++
 2 files changed, 89 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index d1c066d..7a59126 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -33,11 +33,92 @@ extern const unsigned char dsdt_anycpu_arm[];
 _hidden
 extern const int dsdt_anycpu_arm_len;
 
+enum {
+    RSDP,
+    XSDT,
+    GTDT,
+    MADT,
+    FADT,
+    DSDT,
+    NUMS,
+};
+
+struct acpitable {
+    uint64_t addr;
+    size_t size;
+};
+
+static int libxl__estimate_acpi_size(libxl__gc *gc,
+                                     libxl_domain_build_info *info,
+                                     struct xc_dom_image *dom,
+                                     xc_domain_configuration_t *xc_config,
+                                     struct acpitable acpitables[])
+{
+    uint64_t size;
+
+    acpitables[RSDP].addr = GUEST_ACPI_BASE;
+    acpitables[RSDP].size = sizeof(struct acpi_table_rsdp);
+    dom->acpitable_size += ROUNDUP(acpitables[RSDP].size, 3);
+
+    acpitables[XSDT].addr = GUEST_ACPI_BASE + dom->acpitable_size;
+    /*
+     * Currently only 3 tables(GTDT, FADT, MADT) are pointed by XSDT. Alloc
+     * entries for them.
+     */
+    acpitables[XSDT].size = sizeof(struct acpi_table_xsdt) +
+                            sizeof(uint64_t) * 2;
+    dom->acpitable_size += ROUNDUP(acpitables[XSDT].size, 3);
+
+    acpitables[GTDT].addr = GUEST_ACPI_BASE + dom->acpitable_size;
+    acpitables[GTDT].size = sizeof(struct acpi_table_gtdt);
+    dom->acpitable_size += ROUNDUP(acpitables[GTDT].size, 3);
+
+    acpitables[MADT].addr = GUEST_ACPI_BASE + dom->acpitable_size;
+
+    switch (xc_config->gic_version) {
+    case XEN_DOMCTL_CONFIG_GIC_V2:
+        size = sizeof(struct acpi_table_madt) +
+               sizeof(struct acpi_madt_generic_interrupt) * info->max_vcpus +
+               sizeof(struct acpi_madt_generic_distributor);
+        break;
+    case XEN_DOMCTL_CONFIG_GIC_V3:
+        size = sizeof(struct acpi_table_madt) +
+               sizeof(struct acpi_madt_generic_interrupt) * info->max_vcpus +
+               sizeof(struct acpi_madt_generic_distributor) +
+               sizeof(struct acpi_madt_generic_redistributor);
+        break;
+    default:
+        LOG(ERROR, "Unknown GIC version");
+        return ERROR_FAIL;
+    }
+
+    acpitables[MADT].size = size;
+    dom->acpitable_size += ROUNDUP(acpitables[MADT].size, 3);
+
+    acpitables[FADT].addr = GUEST_ACPI_BASE + dom->acpitable_size;
+    acpitables[FADT].size = sizeof(struct acpi_table_fadt);
+    dom->acpitable_size += ROUNDUP(acpitables[FADT].size, 3);
+
+    acpitables[DSDT].addr = GUEST_ACPI_BASE + dom->acpitable_size;
+    acpitables[DSDT].size = dsdt_anycpu_arm_len;
+    dom->acpitable_size += ROUNDUP(acpitables[DSDT].size, 3);
+
+    assert(dom->acpitable_size <= GUEST_ACPI_SIZE);
+    dom->acpitable_blob = libxl__zalloc(gc, dom->acpitable_size);
+
+    return 0;
+}
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)
 {
     const libxl_version_info *vers;
+    int rc;
+    struct acpitable acpitables[NUMS];
+
+    /* convenience aliases */
+    xc_domain_configuration_t *xc_config = &state->config;
 
     vers = libxl_get_version_info(CTX);
     if (vers == NULL)
@@ -49,6 +130,10 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     dom->acpitable_blob = NULL;
     dom->acpitable_size = 0;
 
+    rc = libxl__estimate_acpi_size(gc, info, dom, xc_config, acpitables);
+    if (rc)
+        return rc;
+
     return 0;
 }
 
diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index 4a49254..008a2a0 100644
--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -406,6 +406,10 @@ typedef uint64_t xen_callback_t;
 #define GUEST_GICV3_GICR0_BASE     0x03020000ULL    /* vCPU0 - vCPU127 */
 #define GUEST_GICV3_GICR0_SIZE     0x01000000ULL
 
+/* ACPI tables physical address */
+#define GUEST_ACPI_BASE 0x20000000ULL
+#define GUEST_ACPI_SIZE 0x00200000ULL
+
 /*
  * 16MB == 4096 pages reserved for guest to use as a region to map its
  * grant table in.
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 07/17] libxl/arm: Construct ACPI RSDP table
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (5 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 06/17] libxl/arm: Estimate the size of ACPI tables Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-07 22:43   ` Boris Ostrovsky
  2016-07-05  3:12 ` [PATCH v3 08/17] libxl/arm: Construct ACPI XSDT table Shannon Zhao
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Construct ACPI RSDP table and add a helper to calculate the ACPI table
checksum.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm_acpi.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 7a59126..9df1573 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -33,6 +33,9 @@ extern const unsigned char dsdt_anycpu_arm[];
 _hidden
 extern const int dsdt_anycpu_arm_len;
 
+#define ACPI_BUILD_APPNAME6 "XenARM"
+#define ACPI_BUILD_APPNAME4 "Xen "
+
 enum {
     RSDP,
     XSDT,
@@ -109,6 +112,36 @@ static int libxl__estimate_acpi_size(libxl__gc *gc,
     return 0;
 }
 
+static void calculate_checksum(void *table, uint32_t checksum_offset,
+                               uint32_t length)
+{
+    uint8_t *p, sum = 0;
+
+    p = table;
+    p[checksum_offset] = 0;
+
+    while ( length-- )
+        sum = sum + *p++;
+
+    p = table;
+    p[checksum_offset] = -sum;
+}
+
+static void make_acpi_rsdp(libxl__gc *gc, struct xc_dom_image *dom,
+                           struct acpitable acpitables[])
+{
+    uint64_t offset = acpitables[RSDP].addr - GUEST_ACPI_BASE;
+    struct acpi_table_rsdp *rsdp = dom->acpitable_blob + offset;
+
+    memcpy(rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
+    memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, sizeof(rsdp->oem_id));
+    rsdp->length = acpitables[RSDP].size;
+    rsdp->revision = 0x02;
+    rsdp->xsdt_physical_address = acpitables[XSDT].addr;
+    calculate_checksum(rsdp, offsetof(struct acpi_table_rsdp, checksum),
+                       acpitables[RSDP].size);
+}
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)
@@ -134,6 +167,8 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     if (rc)
         return rc;
 
+    make_acpi_rsdp(gc, dom, acpitables);
+
     return 0;
 }
 
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 08/17] libxl/arm: Construct ACPI XSDT table
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (6 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 07/17] libxl/arm: Construct ACPI RSDP table Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 09/17] libxl/arm: Construct ACPI GTDT table Shannon Zhao
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm_acpi.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 9df1573..1989050 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -142,6 +142,35 @@ static void make_acpi_rsdp(libxl__gc *gc, struct xc_dom_image *dom,
                        acpitables[RSDP].size);
 }
 
+static void make_acpi_header(struct acpi_table_header *h, const char *sig,
+                             int len, uint8_t rev)
+{
+    memcpy(h->signature, sig, 4);
+    h->length = len;
+    h->revision = rev;
+    memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6);
+    memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4);
+    memcpy(h->oem_table_id + 4, sig, 4);
+    h->oem_revision = 1;
+    memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4);
+    h->asl_compiler_revision = 1;
+    h->checksum = 0;
+}
+
+static void make_acpi_xsdt(libxl__gc *gc, struct xc_dom_image *dom,
+                           struct acpitable acpitables[])
+{
+    uint64_t offset = acpitables[XSDT].addr - GUEST_ACPI_BASE;
+    struct acpi_table_xsdt *xsdt = dom->acpitable_blob + offset;
+
+    xsdt->table_offset_entry[0] = acpitables[MADT].addr;
+    xsdt->table_offset_entry[1] = acpitables[GTDT].addr;
+    xsdt->table_offset_entry[2] = acpitables[FADT].addr;
+    make_acpi_header(&xsdt->header, "XSDT", acpitables[XSDT].size, 1);
+    calculate_checksum(xsdt, offsetof(struct acpi_table_header, checksum),
+                       acpitables[XSDT].size);
+}
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)
@@ -168,6 +197,7 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
         return rc;
 
     make_acpi_rsdp(gc, dom, acpitables);
+    make_acpi_xsdt(gc, dom, acpitables);
 
     return 0;
 }
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 09/17] libxl/arm: Construct ACPI GTDT table
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (7 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 08/17] libxl/arm: Construct ACPI XSDT table Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 10/17] libxl/arm: Factor MPIDR computing codes out as a helper Shannon Zhao
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Construct GTDT table with the interrupt information of timers.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm_acpi.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 1989050..c2599b7 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -24,10 +24,18 @@ typedef uint8_t u8;
 typedef uint16_t u16;
 typedef uint32_t u32;
 typedef uint64_t u64;
+typedef int64_t s64;
 
 #include <acpi/acconfig.h>
 #include <acpi/actbl.h>
 
+#include <asm-generic/bitsperlong.h>
+#define ACPI_MACHINE_WIDTH __BITS_PER_LONG
+#define COMPILER_DEPENDENT_INT64 int64_t
+#define COMPILER_DEPENDENT_UINT64 uint64_t
+
+#include <acpi/actypes.h>
+
 _hidden
 extern const unsigned char dsdt_anycpu_arm[];
 _hidden
@@ -171,6 +179,26 @@ static void make_acpi_xsdt(libxl__gc *gc, struct xc_dom_image *dom,
                        acpitables[XSDT].size);
 }
 
+static void make_acpi_gtdt(libxl__gc *gc, struct xc_dom_image *dom,
+                           struct acpitable acpitables[])
+{
+    uint64_t offset = acpitables[GTDT].addr - GUEST_ACPI_BASE;
+    struct acpi_table_gtdt *gtdt = dom->acpitable_blob + offset;
+
+    gtdt->non_secure_el1_interrupt = GUEST_TIMER_PHYS_NS_PPI;
+    gtdt->non_secure_el1_flags =
+                             (ACPI_LEVEL_SENSITIVE << ACPI_GTDT_INTERRUPT_MODE)
+                             |(ACPI_ACTIVE_LOW << ACPI_GTDT_INTERRUPT_POLARITY);
+    gtdt->virtual_timer_interrupt = GUEST_TIMER_VIRT_PPI;
+    gtdt->virtual_timer_flags =
+                             (ACPI_LEVEL_SENSITIVE << ACPI_GTDT_INTERRUPT_MODE)
+                             |(ACPI_ACTIVE_LOW << ACPI_GTDT_INTERRUPT_POLARITY);
+
+    make_acpi_header(&gtdt->header, "GTDT", acpitables[GTDT].size, 2);
+    calculate_checksum(gtdt, offsetof(struct acpi_table_header, checksum),
+                       acpitables[GTDT].size);
+}
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)
@@ -198,6 +226,7 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
 
     make_acpi_rsdp(gc, dom, acpitables);
     make_acpi_xsdt(gc, dom, acpitables);
+    make_acpi_gtdt(gc, dom, acpitables);
 
     return 0;
 }
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 10/17] libxl/arm: Factor MPIDR computing codes out as a helper
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (8 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 09/17] libxl/arm: Construct ACPI GTDT table Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 11/17] libxl/arm: Construct ACPI MADT table Shannon Zhao
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Factor MPIDR computing codes out as a helper, so it could be shared
between DT and ACPI.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm.c |  8 +-------
 tools/libxl/libxl_arm.h | 11 +++++++++++
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 7c522e1..94cb773 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -309,13 +309,7 @@ static int make_cpus_node(libxl__gc *gc, void *fdt, int nr_cpus,
     for (i = 0; i < nr_cpus; i++) {
         const char *name;
 
-        /*
-         * According to ARM CPUs bindings, the reg field should match
-         * the MPIDR's affinity bits. We will use AFF0 and AFF1 when
-         * constructing the reg value of the guest at the moment, for it
-         * is enough for the current max vcpu number.
-         */
-        mpidr_aff = (i & 0x0f) | (((i >> 4) & 0xff) << 8);
+        mpidr_aff = libxl__compute_mpdir(i);
         name = GCSPRINTF("cpu@%"PRIx64, mpidr_aff);
 
         res = fdt_begin_node(fdt, name);
diff --git a/tools/libxl/libxl_arm.h b/tools/libxl/libxl_arm.h
index 1c01177..a91ff93 100644
--- a/tools/libxl/libxl_arm.h
+++ b/tools/libxl/libxl_arm.h
@@ -24,6 +24,17 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom);
 
+static inline uint64_t libxl__compute_mpdir(unsigned int cpuid)
+{
+    /*
+     * According to ARM CPUs bindings, the reg field should match
+     * the MPIDR's affinity bits. We will use AFF0 and AFF1 when
+     * constructing the reg value of the guest at the moment, for it
+     * is enough for the current max vcpu number.
+     */
+    return (cpuid & 0x0f) | (((cpuid >> 4) & 0xff) << 8);
+}
+
 /*
  * Local variables:
  * mode: C
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 11/17] libxl/arm: Construct ACPI MADT table
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (9 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 10/17] libxl/arm: Factor MPIDR computing codes out as a helper Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-07 16:11   ` Wei Liu
  2016-07-05  3:12 ` [PATCH v3 12/17] libxl/arm: Construct ACPI FADT table Shannon Zhao
                   ` (6 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

According to the GIC version, construct the MADT table.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm_acpi.c | 83 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index c2599b7..96ce605 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -199,6 +199,86 @@ static void make_acpi_gtdt(libxl__gc *gc, struct xc_dom_image *dom,
                        acpitables[GTDT].size);
 }
 
+static void make_acpi_madt_gicc(void *table, int nr_cpus, uint64_t gicc_base)
+{
+    uint32_t i;
+    struct acpi_madt_generic_interrupt *gicc = table;
+
+    for (i = 0; i < nr_cpus; i++) {
+        gicc->header.type = ACPI_MADT_TYPE_GENERIC_INTERRUPT;
+        gicc->header.length = sizeof(*gicc);
+        gicc->base_address = gicc_base;
+        gicc->cpu_interface_number = i;
+        gicc->arm_mpidr = libxl__compute_mpdir(i);
+        gicc->uid = i;
+        gicc->flags = ACPI_MADT_ENABLED;
+        gicc++;
+    }
+}
+
+static void make_acpi_madt_gicd(void *table, uint64_t gicd_base,
+                                uint8_t gic_version)
+{
+    struct acpi_madt_generic_distributor *gicd = table;
+
+    gicd->header.type = ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR;
+    gicd->header.length = sizeof(*gicd);
+    gicd->base_address = gicd_base;
+    /* This version field has no meaning before ACPI 5.1 errata. */
+    gicd->version = gic_version;
+}
+
+static void make_acpi_madt_gicr(void *table, uint64_t gicr_base,
+                                uint64_t gicr_size)
+{
+    struct acpi_madt_generic_redistributor *gicr = table;
+
+    gicr->header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR;
+    gicr->header.length = sizeof(*gicr);
+    gicr->base_address = gicr_base;
+    gicr->length = gicr_size;
+}
+
+static int make_acpi_madt(libxl__gc *gc, struct xc_dom_image *dom, int nr_cpus,
+                          xc_domain_configuration_t *xc_config,
+                          struct acpitable acpitables[])
+{
+    uint64_t offset = acpitables[MADT].addr - GUEST_ACPI_BASE;
+    struct acpi_table_madt *madt = dom->acpitable_blob + offset;
+    void *table = dom->acpitable_blob + offset;
+
+    switch (xc_config->gic_version) {
+    case XEN_DOMCTL_CONFIG_GIC_V2:
+        table += sizeof(struct acpi_table_madt);
+        make_acpi_madt_gicc(table, nr_cpus, GUEST_GICC_BASE);
+
+        table += sizeof(struct acpi_madt_generic_interrupt) * nr_cpus;
+        make_acpi_madt_gicd(table, GUEST_GICD_BASE, ACPI_MADT_GIC_VERSION_V2);
+        break;
+    case XEN_DOMCTL_CONFIG_GIC_V3:
+        table += sizeof(struct acpi_table_madt);
+        make_acpi_madt_gicc(table, nr_cpus, 0);
+
+        table += sizeof(struct acpi_madt_generic_interrupt) * nr_cpus;
+        make_acpi_madt_gicd(table, GUEST_GICV3_GICD_BASE,
+                            ACPI_MADT_GIC_VERSION_V3);
+
+        table += sizeof(struct acpi_madt_generic_distributor);
+        make_acpi_madt_gicr(table, GUEST_GICV3_GICR0_BASE,
+                            GUEST_GICV3_GICR0_SIZE);
+        break;
+    default:
+        LOG(ERROR, "Unknown GIC version");
+        return ERROR_FAIL;
+    }
+
+    make_acpi_header(&madt->header, "APIC", acpitables[MADT].size, 3);
+    calculate_checksum(madt, offsetof(struct acpi_table_header, checksum),
+                       acpitables[MADT].size);
+
+    return 0;
+}
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)
@@ -227,6 +307,9 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     make_acpi_rsdp(gc, dom, acpitables);
     make_acpi_xsdt(gc, dom, acpitables);
     make_acpi_gtdt(gc, dom, acpitables);
+    rc = make_acpi_madt(gc, dom, info->max_vcpus, xc_config, acpitables);
+    if (rc)
+	return rc;
 
     return 0;
 }
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 12/17] libxl/arm: Construct ACPI FADT table
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (10 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 11/17] libxl/arm: Construct ACPI MADT table Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 13/17] libxl/arm: Construct ACPI DSDT table Shannon Zhao
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm_acpi.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 96ce605..6075391 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -279,6 +279,25 @@ static int make_acpi_madt(libxl__gc *gc, struct xc_dom_image *dom, int nr_cpus,
     return 0;
 }
 
+static void make_acpi_fadt(libxl__gc *gc, struct xc_dom_image *dom,
+                           struct acpitable acpitables[])
+{
+    uint64_t offset = acpitables[FADT].addr - GUEST_ACPI_BASE;
+    struct acpi_table_fadt *fadt = dom->acpitable_blob + offset;
+
+    /* Hardware Reduced = 1 and use PSCI 0.2+ and with HVC */
+    fadt->flags = ACPI_FADT_HW_REDUCED;
+    fadt->arm_boot_flags = (ACPI_FADT_PSCI_COMPLIANT) | ACPI_FADT_PSCI_USE_HVC;
+
+    /* ACPI v5.1 (fadt->revision.fadt->minor_revision) */
+    fadt->minor_revision = 0x1;
+    fadt->dsdt = acpitables[DSDT].addr;
+
+    make_acpi_header(&fadt->header, "FACP", acpitables[FADT].size, 5);
+    calculate_checksum(fadt, offsetof(struct acpi_table_header, checksum),
+                       acpitables[FADT].size);
+}
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)
@@ -311,6 +330,8 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     if (rc)
 	return rc;
 
+    make_acpi_fadt(gc, dom, acpitables);
+
     return 0;
 }
 
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 13/17] libxl/arm: Construct ACPI DSDT table
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (11 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 12/17] libxl/arm: Construct ACPI FADT table Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 14/17] libxl/arm: Factor finalise_one_memory_node as a gerneric function Shannon Zhao
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Copy the static DSDT table into ACPI blob.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm_acpi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 6075391..368db04 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -298,6 +298,15 @@ static void make_acpi_fadt(libxl__gc *gc, struct xc_dom_image *dom,
                        acpitables[FADT].size);
 }
 
+static void make_acpi_dsdt(libxl__gc *gc, struct xc_dom_image *dom,
+                           struct acpitable acpitables[])
+{
+    uint64_t offset = acpitables[DSDT].addr - GUEST_ACPI_BASE;
+    void *dsdt = dom->acpitable_blob + offset;
+
+    memcpy(dsdt, dsdt_anycpu_arm, dsdt_anycpu_arm_len);
+}
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)
@@ -331,6 +340,7 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
 	return rc;
 
     make_acpi_fadt(gc, dom, acpitables);
+    make_acpi_dsdt(gc, dom, acpitables);
 
     return 0;
 }
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 14/17] libxl/arm: Factor finalise_one_memory_node as a gerneric function
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (12 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 13/17] libxl/arm: Construct ACPI DSDT table Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 15/17] libxl/arm: Add ACPI module Shannon Zhao
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Rename finalise_one_memory_node to finalise_one_node and pass the node
name via function parameter.

This is useful for adding ACPI module which will be added by a later
patch.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 94cb773..6820fd4 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -900,11 +900,11 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc,
     return libxl__prepare_acpi(gc, info, state, dom);
 }
 
-static void finalise_one_memory_node(libxl__gc *gc, void *fdt,
-                                     uint64_t base, uint64_t size)
+static void finalise_one_node(libxl__gc *gc, void *fdt, const char *uname,
+                              uint64_t base, uint64_t size)
 {
     int node, res;
-    const char *name = GCSPRINTF("/memory@%"PRIx64, base);
+    const char *name = GCSPRINTF("%s@%"PRIx64, uname, base);
 
     node = fdt_path_offset(fdt, name);
     assert(node > 0);
@@ -967,7 +967,7 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
     for (i = 0; i < GUEST_RAM_BANKS; i++) {
         const uint64_t size = (uint64_t)dom->rambank_size[i] << XC_PAGE_SHIFT;
 
-        finalise_one_memory_node(gc, fdt, bankbase[i], size);
+        finalise_one_node(gc, fdt, "/memory", bankbase[i], size);
     }
 
     debug_dump_fdt(gc, fdt);
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 15/17] libxl/arm: Add ACPI module
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (13 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 14/17] libxl/arm: Factor finalise_one_memory_node as a gerneric function Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 16/17] libxc/xc_dom_core: Copy ACPI tables to guest space Shannon Zhao
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Add the ARM Multiboot module for ACPI, so UEFI or DomU can get the base
address of ACPI tables from it.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 docs/misc/arm/device-tree/acpi.txt | 24 ++++++++++++++++++++++++
 tools/libxl/libxl_arm.c            | 24 ++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
 create mode 100644 docs/misc/arm/device-tree/acpi.txt

diff --git a/docs/misc/arm/device-tree/acpi.txt b/docs/misc/arm/device-tree/acpi.txt
new file mode 100644
index 0000000..3e70157
--- /dev/null
+++ b/docs/misc/arm/device-tree/acpi.txt
@@ -0,0 +1,24 @@
+DomU ACPI module
+================================
+
+Xen toolstack passes the domU ACPI tables via a reference in the /chosen node of
+the device tree.
+
+Each node contains the following properties:
+
+- compatible
+
+	"xen,guest-acpi", "multiboot,module"
+
+- reg
+
+	Specifies the physical address and the length of the module.
+	RSDP table is always located at the beginning of this region.
+
+Examples
+========
+
+	module@0x20000000 {
+		compatible = "xen,guest-acpi", "multiboot,module";
+		reg = <0x20000000 0x1234>;
+	};
diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 6820fd4..bc38318 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -285,6 +285,25 @@ static int make_chosen_node(libxl__gc *gc, void *fdt, bool ramdisk,
         if (res) return res;
     }
 
+    if (libxl_defbool_val(info->arch_arm.acpi)) {
+        const uint64_t acpi_base = GUEST_ACPI_BASE;
+        const char *name = GCSPRINTF("module@%"PRIx64, acpi_base);
+
+        res = fdt_begin_node(fdt, name);
+        if (res) return res;
+
+        res = fdt_property_compat(gc, fdt, 2, "xen,guest-acpi",
+                                  "multiboot,module");
+        if (res) return res;
+
+        res = fdt_property_regs(gc, fdt, ROOT_ADDRESS_CELLS, ROOT_SIZE_CELLS,
+                                1, 0, 0);
+        if (res) return res;
+
+        res = fdt_end_node(fdt);
+        if (res) return res;
+    }
+
     res = fdt_end_node(fdt);
     if (res) return res;
 
@@ -970,6 +989,11 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
         finalise_one_node(gc, fdt, "/memory", bankbase[i], size);
     }
 
+    if (dom->acpitable_blob) {
+        finalise_one_node(gc, fdt, "/chosen/module", GUEST_ACPI_BASE,
+                          dom->acpitable_size);
+    }
+
     debug_dump_fdt(gc, fdt);
 
     return 0;
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 16/17] libxc/xc_dom_core: Copy ACPI tables to guest space
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (14 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 15/17] libxl/arm: Add ACPI module Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-05  3:12 ` [PATCH v3 17/17] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ Shannon Zhao
  2016-07-05 10:32 ` [PATCH v3 00/17] Xen ARM DomU ACPI support Julien Grall
  17 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

Copy all the ACPI tables to guest space so that UEFI or guest could
access them.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxc/xc_dom_core.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
index ebada89..2fafa59 100644
--- a/tools/libxc/xc_dom_core.c
+++ b/tools/libxc/xc_dom_core.c
@@ -1040,6 +1040,50 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
     return -1;
 }
 
+static int xc_dom_load_acpi(struct xc_dom_image *dom)
+{
+    int rc, i;
+    uint32_t pages_num = ROUNDUP(dom->acpitable_size, XC_PAGE_SHIFT) >>
+                         XC_PAGE_SHIFT;
+    const xen_pfn_t base = GUEST_ACPI_BASE >> XC_PAGE_SHIFT;
+    xen_pfn_t *p2m;
+    void *acpi_pages;
+
+    p2m = malloc(pages_num * sizeof(*p2m));
+    if ( !p2m )
+        return -1;
+
+    for (i = 0; i < pages_num; i++)
+        p2m[i] = base + i;
+
+    rc = xc_domain_populate_physmap_exact(dom->xch, dom->guest_domid,
+                                          pages_num, 0, 0, p2m);
+    if ( rc )
+    {
+        DOMPRINTF("%s: xc_domain_populate_physmap_exact failed with %d",
+                  __FUNCTION__, rc);
+        goto out;
+    }
+
+    acpi_pages = xc_map_foreign_range(dom->xch, dom->guest_domid,
+                                      PAGE_SIZE * pages_num,
+                                      PROT_READ | PROT_WRITE, base);
+    if ( !acpi_pages )
+    {
+        DOMPRINTF("%s Can't map acpi_pages", __FUNCTION__);
+        rc = -1;
+        goto out;
+    }
+
+    memcpy(acpi_pages, dom->acpitable_blob, dom->acpitable_size);
+
+out:
+    munmap(acpi_pages, pages_num * PAGE_SIZE);
+    free(p2m);
+
+    return rc;
+}
+
 int xc_dom_build_image(struct xc_dom_image *dom)
 {
     unsigned int page_size;
@@ -1097,6 +1141,13 @@ int xc_dom_build_image(struct xc_dom_image *dom)
         memcpy(devicetreemap, dom->devicetree_blob, dom->devicetree_size);
     }
 
+    /* load ACPI tables */
+    if ( dom->acpitable_blob && dom->acpitable_size > 0 )
+    {
+        if ( xc_dom_load_acpi(dom) != 0 )
+            goto err;
+    }
+
     /* allocate other pages */
     if ( !dom->arch_hooks->p2m_base_supported ||
          dom->parms.p2m_base >= dom->parms.virt_base ||
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v3 17/17] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (15 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 16/17] libxc/xc_dom_core: Copy ACPI tables to guest space Shannon Zhao
@ 2016-07-05  3:12 ` Shannon Zhao
  2016-07-07 16:15   ` Wei Liu
  2016-07-05 10:32 ` [PATCH v3 00/17] Xen ARM DomU ACPI support Julien Grall
  17 siblings, 1 reply; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05  3:12 UTC (permalink / raw)
  To: xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

From: Shannon Zhao <shannon.zhao@linaro.org>

The guest kernel will get the event channel interrupt information via
domain param HVM_PARAM_CALLBACK_IRQ. Initialize it here.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index bc38318..acacba0 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -900,8 +900,19 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc,
                                            struct xc_dom_image *dom)
 {
     int rc;
+    uint64_t val;
 
     assert(info->type == LIBXL_DOMAIN_TYPE_PV);
+
+    /* Set the value of domain param HVM_PARAM_CALLBACK_IRQ. */
+    val = (uint64_t)HVM_PARAM_CALLBACK_TYPE_PPI << 56;
+    val |= (2 << 8); /* Active-low level-sensitive  */
+    val |= GUEST_EVTCHN_PPI & 0xff;
+    rc = xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_CALLBACK_IRQ,
+                          val);
+    if (rc)
+        return rc;
+
     rc = libxl__prepare_dtb(gc, info, state, dom);
     if (rc)
         return rc;
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 00/17] Xen ARM DomU ACPI support
  2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
                   ` (16 preceding siblings ...)
  2016-07-05  3:12 ` [PATCH v3 17/17] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ Shannon Zhao
@ 2016-07-05 10:32 ` Julien Grall
  2016-07-05 14:09   ` Shannon Zhao
  17 siblings, 1 reply; 47+ messages in thread
From: Julien Grall @ 2016-07-05 10:32 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	shannon.zhao, boris.ostrovsky

Hi Shannon,

On 05/07/16 04:12, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> Note: while there are still two points (user configuration name and
> where to load the ACPI blob) which we don't reach an agreement and need
> other maintainer's opinions, but I'd like to send the updated series out
> since we could move forward and once we reach an agreement I can make
> changes.

It would have been nice to summarize the problems in the concerned 
patches to avoid having looking through all the patches in the previous 
version understanding what are the disagreements. Note that as the 
contributor of this series, I would expect you to drive the discussion 
(e.g gentle ping...).

You also did not address my concern related to require iasl even on 
platform when ACPI will not be used (such as arm32).

> This series can be fetched from:
> https://git.linaro.org/people/shannon.zhao/xen.git  domu_acpi_v3

It would have been nice to specify the dependencies and mention that
Boris's series has not yet been sent to the ML.

>
> Changes since v2:
> * return error for 32bit domain with acpi enabled
> * include actypes.h to reuse the definitions
> * rename libxl_arm_acpi.h to libxl_arm.h
> * use ACPI_MADT_ENABLED
> * rebased on top of Boris's ACPI branch to reuse mk_dsdt.c
>
> Changes since v1:
> * move ACPI tables generation codes to a new file
> * use static asl file to generate DSDT table and include processor
>    device objects
> * assign a non-RAM map for ACPI blob
> * use existing ACPI table definitions under xen/include/acpi/
> * add a configuration for user to enable/disable ACPI generation
> * calculate the ACPI table checksum
>
> Shannon Zhao (17):
>    libxl/arm: Factor out codes for generating DTB
>    libxc: Add placeholders for ACPI tables blob and size
>    libxl/arm: Add a configuration option for ARM DomU ACPI
>    libxl/arm: prepare for constructing ACPI tables
>    libxl/arm: Generate static ACPI DSDT table
>    libxl/arm: Estimate the size of ACPI tables
>    libxl/arm: Construct ACPI RSDP table
>    libxl/arm: Construct ACPI XSDT table
>    libxl/arm: Construct ACPI GTDT table
>    libxl/arm: Factor MPIDR computing codes out as a helper
>    libxl/arm: Construct ACPI MADT table
>    libxl/arm: Construct ACPI FADT table
>    libxl/arm: Construct ACPI DSDT table
>    libxl/arm: Factor finalise_one_memory_node as a gerneric function
>    libxl/arm: Add ACPI module
>    libxc/xc_dom_core: Copy ACPI tables to guest space
>    libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ
>
>   docs/misc/arm/device-tree/acpi.txt |  24 +++
>   tools/libacpi/Makefile             |  15 +-
>   tools/libacpi/mk_dsdt.c            |  51 ++++--
>   tools/libxc/include/xc_dom.h       |   2 +
>   tools/libxc/xc_dom_core.c          |  51 ++++++
>   tools/libxl/Makefile               |   7 +
>   tools/libxl/libxl.h                |   5 +
>   tools/libxl/libxl_arm.c            |  86 +++++++--
>   tools/libxl/libxl_arm.h            |  44 +++++
>   tools/libxl/libxl_arm_acpi.c       | 354 +++++++++++++++++++++++++++++++++++++
>   tools/libxl/libxl_types.idl        |   1 +
>   tools/libxl/xl_cmdimpl.c           |   4 +
>   xen/include/public/arch-arm.h      |   7 +
>   13 files changed, 620 insertions(+), 31 deletions(-)
>   create mode 100644 docs/misc/arm/device-tree/acpi.txt
>   create mode 100644 tools/libxl/libxl_arm.h
>   create mode 100644 tools/libxl/libxl_arm_acpi.c
>

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 00/17] Xen ARM DomU ACPI support
  2016-07-05 10:32 ` [PATCH v3 00/17] Xen ARM DomU ACPI support Julien Grall
@ 2016-07-05 14:09   ` Shannon Zhao
  0 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-05 14:09 UTC (permalink / raw)
  To: Julien Grall, Shannon Zhao, xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	boris.ostrovsky

On 2016年07月05日 18:32, Julien Grall wrote:
> On 05/07/16 04:12, Shannon Zhao wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Note: while there are still two points (user configuration name and
>> where to load the ACPI blob) which we don't reach an agreement and need
>> other maintainer's opinions, but I'd like to send the updated series out
>> since we could move forward and once we reach an agreement I can make
>> changes.
>
> It would have been nice to summarize the problems in the concerned
> patches to avoid having looking through all the patches in the
> previous version understanding what are the disagreements. Note that
> as the contributor of this series, I would expect you to drive the
> discussion (e.g gentle ping...).
>
Actually I notice Stefano and Wei are not active recently, so I thought
they are on holidays(or doing other things). So currently ping is
useless. Once they come back and if they don't reply I'll ping them.

> You also did not address my concern related to require iasl even on
> platform when ACPI will not be used (such as arm32). 
Oh, sorry, will address at next version.

Thanks,

-- 
Shannon


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB
  2016-07-05  3:12 ` [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB Shannon Zhao
@ 2016-07-07 15:41   ` Wei Liu
  2016-07-07 15:48     ` Boris Ostrovsky
  0 siblings, 1 reply; 47+ messages in thread
From: Wei Liu @ 2016-07-07 15:41 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	xen-devel, julien.grall, shannon.zhao, boris.ostrovsky

On Tue, Jul 05, 2016 at 11:12:31AM +0800, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Factor out codes for generating DTB to prepare for adding ACPI tables
> generation codes.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Acked-by: Wei Liu <wei.liu2@citrix.com>
> ---
>  tools/libxl/libxl_arm.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> index ddd80aa..4a57dd7 100644
> --- a/tools/libxl/libxl_arm.c
> +++ b/tools/libxl/libxl_arm.c
> @@ -747,10 +747,9 @@ static int copy_partial_fdt(libxl__gc *gc, void *fdt, void *pfdt)
>  
>  #define FDT_MAX_SIZE (1<<20)
>  
> -int libxl__arch_domain_init_hw_description(libxl__gc *gc,
> -                                           libxl_domain_build_info *info,
> -                                           libxl__domain_build_state *state,
> -                                           struct xc_dom_image *dom)
> +static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
> +                       libxl__domain_build_state *state,
> +                       struct xc_dom_image *dom)

I've queued this up for committing and will fix the indentation as I go
along.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 02/17] libxc: Add placeholders for ACPI tables blob and size
  2016-07-05  3:12 ` [PATCH v3 02/17] libxc: Add placeholders for ACPI tables blob and size Shannon Zhao
@ 2016-07-07 15:42   ` Wei Liu
  0 siblings, 0 replies; 47+ messages in thread
From: Wei Liu @ 2016-07-07 15:42 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	xen-devel, julien.grall, shannon.zhao, boris.ostrovsky

On Tue, Jul 05, 2016 at 11:12:32AM +0800, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add placeholders for ACPI tables blob and size here so that ACPI blob
> can be accessed from libxl and libxc.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Acked-by: Wei Liu <wei.liu2@citrix.com>

Though this patch is simple, it seems that these fields would only be
used later patches, so I will wait until all of them are sorted.

> ---
>  tools/libxc/include/xc_dom.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
> index 6cb10c4..cbeb4fb 100644
> --- a/tools/libxc/include/xc_dom.h
> +++ b/tools/libxc/include/xc_dom.h
> @@ -64,6 +64,8 @@ struct xc_dom_image {
>      size_t ramdisk_size;
>      void *devicetree_blob;
>      size_t devicetree_size;
> +    void *acpitable_blob;
> +    size_t acpitable_size;
>  
>      size_t max_kernel_size;
>      size_t max_ramdisk_size;
> -- 
> 2.0.4
> 
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 03/17] libxl/arm: Add a configuration option for ARM DomU ACPI
  2016-07-05  3:12 ` [PATCH v3 03/17] libxl/arm: Add a configuration option for ARM DomU ACPI Shannon Zhao
@ 2016-07-07 15:48   ` Wei Liu
  0 siblings, 0 replies; 47+ messages in thread
From: Wei Liu @ 2016-07-07 15:48 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	xen-devel, julien.grall, shannon.zhao, boris.ostrovsky

On Tue, Jul 05, 2016 at 11:12:33AM +0800, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a configuration option for ARM DomU so that user can deicde to use
> ACPI or not. This option is defaultly false.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  tools/libxl/libxl.h         | 5 +++++
>  tools/libxl/libxl_types.idl | 1 +
>  tools/libxl/xl_cmdimpl.c    | 4 ++++
>  3 files changed, 10 insertions(+)
> 
> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> index 2c0f868..ccaf87b 100644
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -234,6 +234,11 @@
>  #define LIBXL_HAVE_BUILDINFO_ARM_GIC_VERSION 1
>  
>  /*
> + * libxl_domain_build_info has the arm.acpi field.
> + */
> +#define LIBXL_HAVE_BUILDINFO_ARM_ACPI 1
> +
> +/*
>   * LIBXL_HAVE_SOFT_RESET indicates that libxl supports performing
>   * 'soft reset' for domains and there is 'soft_reset' shutdown reason
>   * in enum libxl_shutdown_reason.
> diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> index ef614be..426b868 100644
> --- a/tools/libxl/libxl_types.idl
> +++ b/tools/libxl/libxl_types.idl
> @@ -560,6 +560,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
>  
>  
>      ("arch_arm", Struct(None, [("gic_version", libxl_gic_version),
> +                               ("acpi", libxl_defbool),
>                                ])),
>  
>      ], dir=DIR_IN
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index 6459eec..0634ffa 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -2506,6 +2506,10 @@ skip_usbdev:
>          }
>       }
>  
> +    if (xlu_cfg_get_defbool(config, "acpi", &b_info->arch_arm.acpi, 0)) {
> +        libxl_defbool_set(&b_info->arch_arm.acpi, 0);
> +    }
> +

Setting .acpi to false should be done in libxl.

See libxl__domain_build_info_setdefault.

>      xlu_cfg_destroy(config);
>  }
>  
> -- 
> 2.0.4
> 
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB
  2016-07-07 15:41   ` Wei Liu
@ 2016-07-07 15:48     ` Boris Ostrovsky
  2016-07-07 16:06       ` Julien Grall
  2016-07-07 16:08       ` Wei Liu
  0 siblings, 2 replies; 47+ messages in thread
From: Boris Ostrovsky @ 2016-07-07 15:48 UTC (permalink / raw)
  To: Wei Liu, Shannon Zhao
  Cc: hangaohuai, sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao

On 07/07/2016 11:41 AM, Wei Liu wrote:
> On Tue, Jul 05, 2016 at 11:12:31AM +0800, Shannon Zhao wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Factor out codes for generating DTB to prepare for adding ACPI tables
>> generation codes.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> Acked-by: Wei Liu <wei.liu2@citrix.com>
>> ---
>>  tools/libxl/libxl_arm.c | 18 ++++++++++++------
>>  1 file changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
>> index ddd80aa..4a57dd7 100644
>> --- a/tools/libxl/libxl_arm.c
>> +++ b/tools/libxl/libxl_arm.c
>> @@ -747,10 +747,9 @@ static int copy_partial_fdt(libxl__gc *gc, void *fdt, void *pfdt)
>>  
>>  #define FDT_MAX_SIZE (1<<20)
>>  
>> -int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>> -                                           libxl_domain_build_info *info,
>> -                                           libxl__domain_build_state *state,
>> -                                           struct xc_dom_image *dom)
>> +static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
>> +                       libxl__domain_build_state *state,
>> +                       struct xc_dom_image *dom)
> I've queued this up for committing and will fix the indentation as I go
> along.


I don't think this can be ready for committing since it sits on top of
my not-yet-reviewed series (which is pretty much guaranteed to require a
new spin).


-boris




_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 04/17] libxl/arm: prepare for constructing ACPI tables
  2016-07-05  3:12 ` [PATCH v3 04/17] libxl/arm: prepare for constructing ACPI tables Shannon Zhao
@ 2016-07-07 15:50   ` Wei Liu
  2016-07-12  7:05     ` Shannon Zhao
  0 siblings, 1 reply; 47+ messages in thread
From: Wei Liu @ 2016-07-07 15:50 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	xen-devel, julien.grall, shannon.zhao, boris.ostrovsky

On Tue, Jul 05, 2016 at 11:12:34AM +0800, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> It only constructs the ACPI tables for 64-bit ARM DomU when user enables
> acpi because 32-bit DomU doesn't support ACPI.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  tools/libxl/Makefile         |  4 ++++
>  tools/libxl/libxl_arm.c      | 19 ++++++++++++++-
>  tools/libxl/libxl_arm.h      | 33 ++++++++++++++++++++++++++
>  tools/libxl/libxl_arm_acpi.c | 56 ++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 111 insertions(+), 1 deletion(-)
>  create mode 100644 tools/libxl/libxl_arm.h
>  create mode 100644 tools/libxl/libxl_arm_acpi.c
> 
> diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
> index 0cf9f6a..88ab4d2 100644
> --- a/tools/libxl/Makefile
> +++ b/tools/libxl/Makefile
> @@ -91,6 +91,10 @@ 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
> +LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_acpi.o
> +
> +libxl_arm_acpi.o: libxl_arm_acpi.c
> +	$(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c
>  
>  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 4a57dd7..7c522e1 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 <xc_dom.h>
>  #include <stdbool.h>
> @@ -885,8 +886,24 @@ 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)
> +        return rc;
> +
> +    if (!libxl_defbool_val(info->arch_arm.acpi)) {
> +        LOG(DEBUG, "Generating ACPI tables is disabled by user.");
> +        return 0;
> +    }
> +
> +    if (strcmp(dom->guest_type, "xen-3.0-aarch64")) {
> +        LOG(ERROR, "Can not enable xl option 'acpi' for %s", dom->guest_type);
> +        return ERROR_FAIL;
> +    }
> +
> +    return libxl__prepare_acpi(gc, info, state, dom);

Please use goto style error handling for consistency. See
tools/libxl/CODING_STYLE. Please fix all other instances as well.


>  }
>  
>  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 0000000..1c01177
> --- /dev/null
> +++ b/tools/libxl/libxl_arm.h
> @@ -0,0 +1,33 @@
> +/*
> + * Copyright (C) 2016      Linaro Ltd.
> + *
> + * Author: Shannon Zhao <shannon.zhao@linaro.org>
> + *
> + * 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 <xc_dom.h>
> +
> +_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 0000000..8c273f9
> --- /dev/null
> +++ b/tools/libxl/libxl_arm_acpi.c
> @@ -0,0 +1,56 @@
> +/*
> + * ARM DomU ACPI generation
> + *
> + * Copyright (C) 2016      Linaro Ltd.
> + *
> + * Author: Shannon Zhao <shannon.zhao@linaro.org>
> + *
> + * 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 <stdint.h>
> +
> +typedef uint8_t u8;
> +typedef uint16_t u16;
> +typedef uint32_t u32;
> +typedef uint64_t u64;
> +
> +#include <acpi/acconfig.h>
> +#include <acpi/actbl.h>
> +
> +int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
> +                        libxl__domain_build_state *state,
> +                        struct xc_dom_image *dom)
> +{
> +    const libxl_version_info *vers;
> +
> +    vers = libxl_get_version_info(CTX);
> +    if (vers == NULL)
> +        return ERROR_FAIL;
> +
> +    LOG(DEBUG, "constructing ACPI tables for Xen version %d.%d guest",
> +        vers->xen_version_major, vers->xen_version_minor);
> +
> +    dom->acpitable_blob = NULL;
> +    dom->acpitable_size = 0;
> +
> +    return 0;

Same here.

> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> -- 
> 2.0.4
> 
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 05/17] libxl/arm: Generate static ACPI DSDT table
  2016-07-05  3:12 ` [PATCH v3 05/17] libxl/arm: Generate static ACPI DSDT table Shannon Zhao
@ 2016-07-07 15:52   ` Wei Liu
  2016-07-12  3:50     ` Shannon Zhao
  0 siblings, 1 reply; 47+ messages in thread
From: Wei Liu @ 2016-07-07 15:52 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	xen-devel, julien.grall, shannon.zhao, boris.ostrovsky

On Tue, Jul 05, 2016 at 11:12:35AM +0800, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> It uses static DSDT table like the way x86 uses. Currently the DSDT
> table only contains processor device objects and it generates the
> maximal objects which so far is 128.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  tools/libacpi/Makefile        | 15 ++++++++++++-
>  tools/libacpi/mk_dsdt.c       | 51 ++++++++++++++++++++++++++++++++-----------
>  tools/libxl/Makefile          |  5 ++++-
>  tools/libxl/libxl_arm_acpi.c  |  5 +++++
>  xen/include/public/arch-arm.h |  3 +++
>  5 files changed, 64 insertions(+), 15 deletions(-)
> 
> diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
> index 4068d9a..0401810 100644
> --- a/tools/libacpi/Makefile
> +++ b/tools/libacpi/Makefile
> @@ -22,6 +22,7 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
>  # Sources to be generated
>  C_SRC = $(ACPI_BUILD_DIR)/dsdt_anycpu.c $(ACPI_BUILD_DIR)/dsdt_15cpu.c 
>  C_SRC += $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.c $(ACPI_BUILD_DIR)/dsdt_pvh.c
> +C_SRC += $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.c
>  H_SRC = $(ACPI_BUILD_DIR)/ssdt_s3.h $(ACPI_BUILD_DIR)/ssdt_s4.h $(ACPI_BUILD_DIR)/ssdt_pm.h $(ACPI_BUILD_DIR)/ssdt_tpm.h
>  
>  vpath iasl $(PATH)
> @@ -35,7 +36,7 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
>  	cd $(CURDIR)
>  
>  $(MK_DSDT): mk_dsdt.c
> -	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
> +	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -o $@ mk_dsdt.c

Why is this needed? Which unstable hypervisor interface you need in
order to build this?

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB
  2016-07-07 15:48     ` Boris Ostrovsky
@ 2016-07-07 16:06       ` Julien Grall
  2016-07-07 16:09         ` Wei Liu
  2016-07-07 16:12         ` Boris Ostrovsky
  2016-07-07 16:08       ` Wei Liu
  1 sibling, 2 replies; 47+ messages in thread
From: Julien Grall @ 2016-07-07 16:06 UTC (permalink / raw)
  To: Boris Ostrovsky, Wei Liu, Shannon Zhao
  Cc: hangaohuai, sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	shannon.zhao



On 07/07/16 16:48, Boris Ostrovsky wrote:
> On 07/07/2016 11:41 AM, Wei Liu wrote:
>> On Tue, Jul 05, 2016 at 11:12:31AM +0800, Shannon Zhao wrote:
>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>
>>> Factor out codes for generating DTB to prepare for adding ACPI tables
>>> generation codes.
>>>
>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>> Acked-by: Wei Liu <wei.liu2@citrix.com>
>>> ---
>>>   tools/libxl/libxl_arm.c | 18 ++++++++++++------
>>>   1 file changed, 12 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
>>> index ddd80aa..4a57dd7 100644
>>> --- a/tools/libxl/libxl_arm.c
>>> +++ b/tools/libxl/libxl_arm.c
>>> @@ -747,10 +747,9 @@ static int copy_partial_fdt(libxl__gc *gc, void *fdt, void *pfdt)
>>>
>>>   #define FDT_MAX_SIZE (1<<20)
>>>
>>> -int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>>> -                                           libxl_domain_build_info *info,
>>> -                                           libxl__domain_build_state *state,
>>> -                                           struct xc_dom_image *dom)
>>> +static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
>>> +                       libxl__domain_build_state *state,
>>> +                       struct xc_dom_image *dom)
>> I've queued this up for committing and will fix the indentation as I go
>> along.
>
>
> I don't think this can be ready for committing since it sits on top of
> my not-yet-reviewed series (which is pretty much guaranteed to require a
> new spin).

This is only used by the ARM code which you don't modify. So I don't see 
any issue to commit this patch.

Regards,


-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 06/17] libxl/arm: Estimate the size of ACPI tables
  2016-07-05  3:12 ` [PATCH v3 06/17] libxl/arm: Estimate the size of ACPI tables Shannon Zhao
@ 2016-07-07 16:07   ` Wei Liu
  2016-07-07 16:39     ` Julien Grall
  0 siblings, 1 reply; 47+ messages in thread
From: Wei Liu @ 2016-07-07 16:07 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	xen-devel, julien.grall, shannon.zhao, boris.ostrovsky

On Tue, Jul 05, 2016 at 11:12:36AM +0800, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Estimate the size of ACPI tables and reserve a memory map space for ACPI
> tables.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

I will leave this patch to Stefano and Julien.

> ---
>  tools/libxl/libxl_arm_acpi.c  | 85 +++++++++++++++++++++++++++++++++++++++++++
>  xen/include/public/arch-arm.h |  4 ++
>  2 files changed, 89 insertions(+)
> 
> diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
> index d1c066d..7a59126 100644
> --- a/tools/libxl/libxl_arm_acpi.c
> +++ b/tools/libxl/libxl_arm_acpi.c
> @@ -33,11 +33,92 @@ extern const unsigned char dsdt_anycpu_arm[];
>  _hidden
>  extern const int dsdt_anycpu_arm_len;
>  
> +enum {
> +    RSDP,
> +    XSDT,
> +    GTDT,
> +    MADT,
> +    FADT,
> +    DSDT,
> +    NUMS,
> +};
> +
> +struct acpitable {
> +    uint64_t addr;
> +    size_t size;
> +};
> +
> +static int libxl__estimate_acpi_size(libxl__gc *gc,
> +                                     libxl_domain_build_info *info,
> +                                     struct xc_dom_image *dom,
> +                                     xc_domain_configuration_t *xc_config,
> +                                     struct acpitable acpitables[])
> +{
> +    uint64_t size;
> +
> +    acpitables[RSDP].addr = GUEST_ACPI_BASE;
> +    acpitables[RSDP].size = sizeof(struct acpi_table_rsdp);
> +    dom->acpitable_size += ROUNDUP(acpitables[RSDP].size, 3);
> +
> +    acpitables[XSDT].addr = GUEST_ACPI_BASE + dom->acpitable_size;
> +    /*
> +     * Currently only 3 tables(GTDT, FADT, MADT) are pointed by XSDT. Alloc
> +     * entries for them.
> +     */
> +    acpitables[XSDT].size = sizeof(struct acpi_table_xsdt) +
> +                            sizeof(uint64_t) * 2;
> +    dom->acpitable_size += ROUNDUP(acpitables[XSDT].size, 3);
> +
> +    acpitables[GTDT].addr = GUEST_ACPI_BASE + dom->acpitable_size;
> +    acpitables[GTDT].size = sizeof(struct acpi_table_gtdt);
> +    dom->acpitable_size += ROUNDUP(acpitables[GTDT].size, 3);
> +
> +    acpitables[MADT].addr = GUEST_ACPI_BASE + dom->acpitable_size;
> +
> +    switch (xc_config->gic_version) {
> +    case XEN_DOMCTL_CONFIG_GIC_V2:
> +        size = sizeof(struct acpi_table_madt) +
> +               sizeof(struct acpi_madt_generic_interrupt) * info->max_vcpus +
> +               sizeof(struct acpi_madt_generic_distributor);
> +        break;
> +    case XEN_DOMCTL_CONFIG_GIC_V3:
> +        size = sizeof(struct acpi_table_madt) +
> +               sizeof(struct acpi_madt_generic_interrupt) * info->max_vcpus +
> +               sizeof(struct acpi_madt_generic_distributor) +
> +               sizeof(struct acpi_madt_generic_redistributor);
> +        break;
> +    default:
> +        LOG(ERROR, "Unknown GIC version");
> +        return ERROR_FAIL;
> +    }
> +
> +    acpitables[MADT].size = size;
> +    dom->acpitable_size += ROUNDUP(acpitables[MADT].size, 3);
> +
> +    acpitables[FADT].addr = GUEST_ACPI_BASE + dom->acpitable_size;
> +    acpitables[FADT].size = sizeof(struct acpi_table_fadt);
> +    dom->acpitable_size += ROUNDUP(acpitables[FADT].size, 3);
> +
> +    acpitables[DSDT].addr = GUEST_ACPI_BASE + dom->acpitable_size;
> +    acpitables[DSDT].size = dsdt_anycpu_arm_len;
> +    dom->acpitable_size += ROUNDUP(acpitables[DSDT].size, 3);
> +
> +    assert(dom->acpitable_size <= GUEST_ACPI_SIZE);
> +    dom->acpitable_blob = libxl__zalloc(gc, dom->acpitable_size);
> +

Goto style error handling.

> +    return 0;
> +}
> +
>  int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>                          libxl__domain_build_state *state,
>                          struct xc_dom_image *dom)
>  {
>      const libxl_version_info *vers;
> +    int rc;
> +    struct acpitable acpitables[NUMS];
> +
> +    /* convenience aliases */
> +    xc_domain_configuration_t *xc_config = &state->config;
>  

Julien seemed to have suggested this structure shouldn't be used. Did I
misremember?

>      vers = libxl_get_version_info(CTX);
>      if (vers == NULL)
> @@ -49,6 +130,10 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>      dom->acpitable_blob = NULL;
>      dom->acpitable_size = 0;
>  
> +    rc = libxl__estimate_acpi_size(gc, info, dom, xc_config, acpitables);
> +    if (rc)
> +        return rc;
> +
>      return 0;
>  }

Goto style error handling please.

>  
> diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
> index 4a49254..008a2a0 100644
> --- a/xen/include/public/arch-arm.h
> +++ b/xen/include/public/arch-arm.h
> @@ -406,6 +406,10 @@ typedef uint64_t xen_callback_t;
>  #define GUEST_GICV3_GICR0_BASE     0x03020000ULL    /* vCPU0 - vCPU127 */
>  #define GUEST_GICV3_GICR0_SIZE     0x01000000ULL
>  
> +/* ACPI tables physical address */
> +#define GUEST_ACPI_BASE 0x20000000ULL
> +#define GUEST_ACPI_SIZE 0x00200000ULL
> +
>  /*
>   * 16MB == 4096 pages reserved for guest to use as a region to map its
>   * grant table in.
> -- 
> 2.0.4
> 
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB
  2016-07-07 15:48     ` Boris Ostrovsky
  2016-07-07 16:06       ` Julien Grall
@ 2016-07-07 16:08       ` Wei Liu
  1 sibling, 0 replies; 47+ messages in thread
From: Wei Liu @ 2016-07-07 16:08 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: hangaohuai, sstabellini, Wei Liu, ian.jackson, peter.huangpeng,
	xen-devel, julien.grall, shannon.zhao, Shannon Zhao

On Thu, Jul 07, 2016 at 11:48:49AM -0400, Boris Ostrovsky wrote:
> On 07/07/2016 11:41 AM, Wei Liu wrote:
> > On Tue, Jul 05, 2016 at 11:12:31AM +0800, Shannon Zhao wrote:
> >> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >> Factor out codes for generating DTB to prepare for adding ACPI tables
> >> generation codes.
> >>
> >> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> Acked-by: Wei Liu <wei.liu2@citrix.com>
> >> ---
> >>  tools/libxl/libxl_arm.c | 18 ++++++++++++------
> >>  1 file changed, 12 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> >> index ddd80aa..4a57dd7 100644
> >> --- a/tools/libxl/libxl_arm.c
> >> +++ b/tools/libxl/libxl_arm.c
> >> @@ -747,10 +747,9 @@ static int copy_partial_fdt(libxl__gc *gc, void *fdt, void *pfdt)
> >>  
> >>  #define FDT_MAX_SIZE (1<<20)
> >>  
> >> -int libxl__arch_domain_init_hw_description(libxl__gc *gc,
> >> -                                           libxl_domain_build_info *info,
> >> -                                           libxl__domain_build_state *state,
> >> -                                           struct xc_dom_image *dom)
> >> +static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
> >> +                       libxl__domain_build_state *state,
> >> +                       struct xc_dom_image *dom)
> > I've queued this up for committing and will fix the indentation as I go
> > along.
> 
> 
> I don't think this can be ready for committing since it sits on top of
> my not-yet-reviewed series (which is pretty much guaranteed to require a
> new spin).
> 

I thought this patch posted long time ago. But things might have
changed. I will wait.

> 
> -boris
> 
> 
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB
  2016-07-07 16:06       ` Julien Grall
@ 2016-07-07 16:09         ` Wei Liu
  2016-07-07 16:12         ` Boris Ostrovsky
  1 sibling, 0 replies; 47+ messages in thread
From: Wei Liu @ 2016-07-07 16:09 UTC (permalink / raw)
  To: Julien Grall
  Cc: hangaohuai, sstabellini, Wei Liu, ian.jackson, peter.huangpeng,
	xen-devel, shannon.zhao, Shannon Zhao, Boris Ostrovsky

On Thu, Jul 07, 2016 at 05:06:11PM +0100, Julien Grall wrote:
> 
> 
> On 07/07/16 16:48, Boris Ostrovsky wrote:
> >On 07/07/2016 11:41 AM, Wei Liu wrote:
> >>On Tue, Jul 05, 2016 at 11:12:31AM +0800, Shannon Zhao wrote:
> >>>From: Shannon Zhao <shannon.zhao@linaro.org>
> >>>
> >>>Factor out codes for generating DTB to prepare for adding ACPI tables
> >>>generation codes.
> >>>
> >>>Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >>>Acked-by: Wei Liu <wei.liu2@citrix.com>
> >>>---
> >>>  tools/libxl/libxl_arm.c | 18 ++++++++++++------
> >>>  1 file changed, 12 insertions(+), 6 deletions(-)
> >>>
> >>>diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> >>>index ddd80aa..4a57dd7 100644
> >>>--- a/tools/libxl/libxl_arm.c
> >>>+++ b/tools/libxl/libxl_arm.c
> >>>@@ -747,10 +747,9 @@ static int copy_partial_fdt(libxl__gc *gc, void *fdt, void *pfdt)
> >>>
> >>>  #define FDT_MAX_SIZE (1<<20)
> >>>
> >>>-int libxl__arch_domain_init_hw_description(libxl__gc *gc,
> >>>-                                           libxl_domain_build_info *info,
> >>>-                                           libxl__domain_build_state *state,
> >>>-                                           struct xc_dom_image *dom)
> >>>+static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
> >>>+                       libxl__domain_build_state *state,
> >>>+                       struct xc_dom_image *dom)
> >>I've queued this up for committing and will fix the indentation as I go
> >>along.
> >
> >
> >I don't think this can be ready for committing since it sits on top of
> >my not-yet-reviewed series (which is pretty much guaranteed to require a
> >new spin).
> 
> This is only used by the ARM code which you don't modify. So I don't see any
> issue to commit this patch.

Ah, so I can go ahead after all.

> 
> Regards,
> 
> 
> -- 
> Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 11/17] libxl/arm: Construct ACPI MADT table
  2016-07-05  3:12 ` [PATCH v3 11/17] libxl/arm: Construct ACPI MADT table Shannon Zhao
@ 2016-07-07 16:11   ` Wei Liu
  2016-07-07 16:46     ` Julien Grall
  0 siblings, 1 reply; 47+ messages in thread
From: Wei Liu @ 2016-07-07 16:11 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	xen-devel, julien.grall, shannon.zhao, boris.ostrovsky

On Tue, Jul 05, 2016 at 11:12:41AM +0800, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> According to the GIC version, construct the MADT table.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  tools/libxl/libxl_arm_acpi.c | 83 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 83 insertions(+)
> 
> diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
> index c2599b7..96ce605 100644
> --- a/tools/libxl/libxl_arm_acpi.c
> +++ b/tools/libxl/libxl_arm_acpi.c
> @@ -199,6 +199,86 @@ static void make_acpi_gtdt(libxl__gc *gc, struct xc_dom_image *dom,
>                         acpitables[GTDT].size);
>  }
>  
> +static void make_acpi_madt_gicc(void *table, int nr_cpus, uint64_t gicc_base)
> +{
> +    uint32_t i;
> +    struct acpi_madt_generic_interrupt *gicc = table;
> +
> +    for (i = 0; i < nr_cpus; i++) {
> +        gicc->header.type = ACPI_MADT_TYPE_GENERIC_INTERRUPT;
> +        gicc->header.length = sizeof(*gicc);
> +        gicc->base_address = gicc_base;
> +        gicc->cpu_interface_number = i;
> +        gicc->arm_mpidr = libxl__compute_mpdir(i);
> +        gicc->uid = i;
> +        gicc->flags = ACPI_MADT_ENABLED;
> +        gicc++;
> +    }
> +}
> +
> +static void make_acpi_madt_gicd(void *table, uint64_t gicd_base,
> +                                uint8_t gic_version)
> +{
> +    struct acpi_madt_generic_distributor *gicd = table;
> +
> +    gicd->header.type = ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR;
> +    gicd->header.length = sizeof(*gicd);
> +    gicd->base_address = gicd_base;
> +    /* This version field has no meaning before ACPI 5.1 errata. */
> +    gicd->version = gic_version;
> +}
> +
> +static void make_acpi_madt_gicr(void *table, uint64_t gicr_base,
> +                                uint64_t gicr_size)
> +{
> +    struct acpi_madt_generic_redistributor *gicr = table;
> +
> +    gicr->header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR;
> +    gicr->header.length = sizeof(*gicr);
> +    gicr->base_address = gicr_base;
> +    gicr->length = gicr_size;
> +}
> +
> +static int make_acpi_madt(libxl__gc *gc, struct xc_dom_image *dom, int nr_cpus,
> +                          xc_domain_configuration_t *xc_config,
> +                          struct acpitable acpitables[])
> +{
> +    uint64_t offset = acpitables[MADT].addr - GUEST_ACPI_BASE;
> +    struct acpi_table_madt *madt = dom->acpitable_blob + offset;
> +    void *table = dom->acpitable_blob + offset;
> +
> +    switch (xc_config->gic_version) {
> +    case XEN_DOMCTL_CONFIG_GIC_V2:
> +        table += sizeof(struct acpi_table_madt);
> +        make_acpi_madt_gicc(table, nr_cpus, GUEST_GICC_BASE);
> +
> +        table += sizeof(struct acpi_madt_generic_interrupt) * nr_cpus;
> +        make_acpi_madt_gicd(table, GUEST_GICD_BASE, ACPI_MADT_GIC_VERSION_V2);
> +        break;
> +    case XEN_DOMCTL_CONFIG_GIC_V3:
> +        table += sizeof(struct acpi_table_madt);
> +        make_acpi_madt_gicc(table, nr_cpus, 0);
> +
> +        table += sizeof(struct acpi_madt_generic_interrupt) * nr_cpus;
> +        make_acpi_madt_gicd(table, GUEST_GICV3_GICD_BASE,
> +                            ACPI_MADT_GIC_VERSION_V3);
> +
> +        table += sizeof(struct acpi_madt_generic_distributor);
> +        make_acpi_madt_gicr(table, GUEST_GICV3_GICR0_BASE,
> +                            GUEST_GICV3_GICR0_SIZE);
> +        break;
> +    default:
> +        LOG(ERROR, "Unknown GIC version");
> +        return ERROR_FAIL;
> +    }
> +

Why is this code snippet referencing libxc structure? I would think all
relevant information is already available in libxl, right?

> +    make_acpi_header(&madt->header, "APIC", acpitables[MADT].size, 3);
> +    calculate_checksum(madt, offsetof(struct acpi_table_header, checksum),
> +                       acpitables[MADT].size);
> +
> +    return 0;
> +}
> +
>  int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>                          libxl__domain_build_state *state,
>                          struct xc_dom_image *dom)
> @@ -227,6 +307,9 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>      make_acpi_rsdp(gc, dom, acpitables);
>      make_acpi_xsdt(gc, dom, acpitables);
>      make_acpi_gtdt(gc, dom, acpitables);
> +    rc = make_acpi_madt(gc, dom, info->max_vcpus, xc_config, acpitables);
> +    if (rc)
> +	return rc;
>  
>      return 0;
>  }
> -- 
> 2.0.4
> 
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB
  2016-07-07 16:06       ` Julien Grall
  2016-07-07 16:09         ` Wei Liu
@ 2016-07-07 16:12         ` Boris Ostrovsky
  2016-07-07 16:15           ` Julien Grall
  2016-07-07 16:16           ` Wei Liu
  1 sibling, 2 replies; 47+ messages in thread
From: Boris Ostrovsky @ 2016-07-07 16:12 UTC (permalink / raw)
  To: Julien Grall, Wei Liu, Shannon Zhao
  Cc: hangaohuai, sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	shannon.zhao

On 07/07/2016 12:06 PM, Julien Grall wrote:
>
>
> On 07/07/16 16:48, Boris Ostrovsky wrote:
>> On 07/07/2016 11:41 AM, Wei Liu wrote:
>>> On Tue, Jul 05, 2016 at 11:12:31AM +0800, Shannon Zhao wrote:
>>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>
>>>> Factor out codes for generating DTB to prepare for adding ACPI tables
>>>> generation codes.
>>>>
>>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>>> Acked-by: Wei Liu <wei.liu2@citrix.com>
>>>> ---
>>>>   tools/libxl/libxl_arm.c | 18 ++++++++++++------
>>>>   1 file changed, 12 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
>>>> index ddd80aa..4a57dd7 100644
>>>> --- a/tools/libxl/libxl_arm.c
>>>> +++ b/tools/libxl/libxl_arm.c
>>>> @@ -747,10 +747,9 @@ static int copy_partial_fdt(libxl__gc *gc,
>>>> void *fdt, void *pfdt)
>>>>
>>>>   #define FDT_MAX_SIZE (1<<20)
>>>>
>>>> -int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>>>> -                                           libxl_domain_build_info
>>>> *info,
>>>> -                                          
>>>> libxl__domain_build_state *state,
>>>> -                                           struct xc_dom_image *dom)
>>>> +static int libxl__prepare_dtb(libxl__gc *gc,
>>>> libxl_domain_build_info *info,
>>>> +                       libxl__domain_build_state *state,
>>>> +                       struct xc_dom_image *dom)
>>> I've queued this up for committing and will fix the indentation as I go
>>> along.
>>
>>
>> I don't think this can be ready for committing since it sits on top of
>> my not-yet-reviewed series (which is pretty much guaranteed to require a
>> new spin).
>
> This is only used by the ARM code which you don't modify. So I don't
> see any issue to commit this patch.

I thought Wei was referring to the whole series being prepared for
committing. If he was talking only about this patch (and possibly
selected other patches) then yes, there is no dependency here. I know
that further patches in this series want to see tools/libacpi, for
example, and that is not ready.

-boris



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 17/17] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ
  2016-07-05  3:12 ` [PATCH v3 17/17] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ Shannon Zhao
@ 2016-07-07 16:15   ` Wei Liu
  2016-07-07 16:57     ` Julien Grall
  0 siblings, 1 reply; 47+ messages in thread
From: Wei Liu @ 2016-07-07 16:15 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	xen-devel, julien.grall, shannon.zhao, boris.ostrovsky

On Tue, Jul 05, 2016 at 11:12:47AM +0800, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> The guest kernel will get the event channel interrupt information via
> domain param HVM_PARAM_CALLBACK_IRQ. Initialize it here.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  tools/libxl/libxl_arm.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> index bc38318..acacba0 100644
> --- a/tools/libxl/libxl_arm.c
> +++ b/tools/libxl/libxl_arm.c
> @@ -900,8 +900,19 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>                                             struct xc_dom_image *dom)
>  {
>      int rc;
> +    uint64_t val;
>  
>      assert(info->type == LIBXL_DOMAIN_TYPE_PV);
> +
> +    /* Set the value of domain param HVM_PARAM_CALLBACK_IRQ. */
> +    val = (uint64_t)HVM_PARAM_CALLBACK_TYPE_PPI << 56;
> +    val |= (2 << 8); /* Active-low level-sensitive  */

Please avoid using magic numbers here -- 56, 2 and 8.

Another question to Julien and Stefano: is it normal for ARM guest to
use hvm callback vector?

Wei.

> +    val |= GUEST_EVTCHN_PPI & 0xff;
> +    rc = xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_CALLBACK_IRQ,
> +                          val);
> +    if (rc)
> +        return rc;
> +
>      rc = libxl__prepare_dtb(gc, info, state, dom);
>      if (rc)
>          return rc;
> -- 
> 2.0.4
> 
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB
  2016-07-07 16:12         ` Boris Ostrovsky
@ 2016-07-07 16:15           ` Julien Grall
  2016-07-07 16:16           ` Wei Liu
  1 sibling, 0 replies; 47+ messages in thread
From: Julien Grall @ 2016-07-07 16:15 UTC (permalink / raw)
  To: Boris Ostrovsky, Wei Liu, Shannon Zhao
  Cc: hangaohuai, sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	shannon.zhao



On 07/07/16 17:12, Boris Ostrovsky wrote:
> On 07/07/2016 12:06 PM, Julien Grall wrote:
>>
>>
>> On 07/07/16 16:48, Boris Ostrovsky wrote:
>>> On 07/07/2016 11:41 AM, Wei Liu wrote:
>>>> On Tue, Jul 05, 2016 at 11:12:31AM +0800, Shannon Zhao wrote:
>>>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>>
>>>>> Factor out codes for generating DTB to prepare for adding ACPI tables
>>>>> generation codes.
>>>>>
>>>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>>>> Acked-by: Wei Liu <wei.liu2@citrix.com>
>>>>> ---
>>>>>    tools/libxl/libxl_arm.c | 18 ++++++++++++------
>>>>>    1 file changed, 12 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
>>>>> index ddd80aa..4a57dd7 100644
>>>>> --- a/tools/libxl/libxl_arm.c
>>>>> +++ b/tools/libxl/libxl_arm.c
>>>>> @@ -747,10 +747,9 @@ static int copy_partial_fdt(libxl__gc *gc,
>>>>> void *fdt, void *pfdt)
>>>>>
>>>>>    #define FDT_MAX_SIZE (1<<20)
>>>>>
>>>>> -int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>>>>> -                                           libxl_domain_build_info
>>>>> *info,
>>>>> -
>>>>> libxl__domain_build_state *state,
>>>>> -                                           struct xc_dom_image *dom)
>>>>> +static int libxl__prepare_dtb(libxl__gc *gc,
>>>>> libxl_domain_build_info *info,
>>>>> +                       libxl__domain_build_state *state,
>>>>> +                       struct xc_dom_image *dom)
>>>> I've queued this up for committing and will fix the indentation as I go
>>>> along.
>>>
>>>
>>> I don't think this can be ready for committing since it sits on top of
>>> my not-yet-reviewed series (which is pretty much guaranteed to require a
>>> new spin).
>>
>> This is only used by the ARM code which you don't modify. So I don't
>> see any issue to commit this patch.
>
> I thought Wei was referring to the whole series being prepared for
> committing. If he was talking only about this patch (and possibly
> selected other patches) then yes, there is no dependency here. I know
> that further patches in this series want to see tools/libacpi, for
> example, and that is not ready.

I know about this. I don't think this series is ready to be fully 
committed due to some the disagreement such as where to handle the ACPI 
blob.

However, it would be nice to get trivial patch to slim down the size of 
the series.

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB
  2016-07-07 16:12         ` Boris Ostrovsky
  2016-07-07 16:15           ` Julien Grall
@ 2016-07-07 16:16           ` Wei Liu
  1 sibling, 0 replies; 47+ messages in thread
From: Wei Liu @ 2016-07-07 16:16 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: hangaohuai, sstabellini, Wei Liu, ian.jackson, peter.huangpeng,
	xen-devel, Julien Grall, shannon.zhao, Shannon Zhao

On Thu, Jul 07, 2016 at 12:12:48PM -0400, Boris Ostrovsky wrote:
> On 07/07/2016 12:06 PM, Julien Grall wrote:
> >
> >
> > On 07/07/16 16:48, Boris Ostrovsky wrote:
> >> On 07/07/2016 11:41 AM, Wei Liu wrote:
> >>> On Tue, Jul 05, 2016 at 11:12:31AM +0800, Shannon Zhao wrote:
> >>>> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>>>
> >>>> Factor out codes for generating DTB to prepare for adding ACPI tables
> >>>> generation codes.
> >>>>
> >>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >>>> Acked-by: Wei Liu <wei.liu2@citrix.com>
> >>>> ---
> >>>>   tools/libxl/libxl_arm.c | 18 ++++++++++++------
> >>>>   1 file changed, 12 insertions(+), 6 deletions(-)
> >>>>
> >>>> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> >>>> index ddd80aa..4a57dd7 100644
> >>>> --- a/tools/libxl/libxl_arm.c
> >>>> +++ b/tools/libxl/libxl_arm.c
> >>>> @@ -747,10 +747,9 @@ static int copy_partial_fdt(libxl__gc *gc,
> >>>> void *fdt, void *pfdt)
> >>>>
> >>>>   #define FDT_MAX_SIZE (1<<20)
> >>>>
> >>>> -int libxl__arch_domain_init_hw_description(libxl__gc *gc,
> >>>> -                                           libxl_domain_build_info
> >>>> *info,
> >>>> -                                          
> >>>> libxl__domain_build_state *state,
> >>>> -                                           struct xc_dom_image *dom)
> >>>> +static int libxl__prepare_dtb(libxl__gc *gc,
> >>>> libxl_domain_build_info *info,
> >>>> +                       libxl__domain_build_state *state,
> >>>> +                       struct xc_dom_image *dom)
> >>> I've queued this up for committing and will fix the indentation as I go
> >>> along.
> >>
> >>
> >> I don't think this can be ready for committing since it sits on top of
> >> my not-yet-reviewed series (which is pretty much guaranteed to require a
> >> new spin).
> >
> > This is only used by the ARM code which you don't modify. So I don't
> > see any issue to commit this patch.
> 
> I thought Wei was referring to the whole series being prepared for
> committing. If he was talking only about this patch (and possibly
> selected other patches) then yes, there is no dependency here. I know
> that further patches in this series want to see tools/libacpi, for
> example, and that is not ready.
> 

Oh yes, sure. This patch series is not yet ready to go in. :-)

I was only about to commit this first patch to reduce Shannon's patch
queue length.

> -boris
> 
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 06/17] libxl/arm: Estimate the size of ACPI tables
  2016-07-07 16:07   ` Wei Liu
@ 2016-07-07 16:39     ` Julien Grall
  2016-07-08 10:45       ` Wei Liu
  0 siblings, 1 reply; 47+ messages in thread
From: Julien Grall @ 2016-07-07 16:39 UTC (permalink / raw)
  To: Wei Liu, Shannon Zhao
  Cc: hangaohuai, sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	shannon.zhao, boris.ostrovsky

Hi Wei,

On 07/07/16 17:07, Wei Liu wrote:
> On Tue, Jul 05, 2016 at 11:12:36AM +0800, Shannon Zhao wrote:
>>   int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>>                           libxl__domain_build_state *state,
>>                           struct xc_dom_image *dom)
>>   {
>>       const libxl_version_info *vers;
>> +    int rc;
>> +    struct acpitable acpitables[NUMS];
>> +
>> +    /* convenience aliases */
>> +    xc_domain_configuration_t *xc_config = &state->config;
>>
>
> Julien seemed to have suggested this structure shouldn't be used. Did I
> misremember?

On the previous version, I said we should not extend this structure for 
parameter which is not used by the hypervisor (e.g the hypervisor does 
not need to know whether the guest will use ACPI).

However, this structure have to be used to get the version of the GIC 
that will be emulated for the guest. This is because the hypervisor 
might choose the version if the user did not specify one.

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 11/17] libxl/arm: Construct ACPI MADT table
  2016-07-07 16:11   ` Wei Liu
@ 2016-07-07 16:46     ` Julien Grall
  0 siblings, 0 replies; 47+ messages in thread
From: Julien Grall @ 2016-07-07 16:46 UTC (permalink / raw)
  To: Wei Liu, Shannon Zhao
  Cc: hangaohuai, sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	shannon.zhao, boris.ostrovsky

Hi Wei,

On 07/07/16 17:11, Wei Liu wrote:
> On Tue, Jul 05, 2016 at 11:12:41AM +0800, Shannon Zhao wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> According to the GIC version, construct the MADT table.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>   tools/libxl/libxl_arm_acpi.c | 83 ++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 83 insertions(+)
>>
>> diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
>> index c2599b7..96ce605 100644
>> --- a/tools/libxl/libxl_arm_acpi.c
>> +++ b/tools/libxl/libxl_arm_acpi.c
>> @@ -199,6 +199,86 @@ static void make_acpi_gtdt(libxl__gc *gc, struct xc_dom_image *dom,
>>                          acpitables[GTDT].size);
>>   }
>>
>> +static void make_acpi_madt_gicc(void *table, int nr_cpus, uint64_t gicc_base)
>> +{
>> +    uint32_t i;
>> +    struct acpi_madt_generic_interrupt *gicc = table;
>> +
>> +    for (i = 0; i < nr_cpus; i++) {
>> +        gicc->header.type = ACPI_MADT_TYPE_GENERIC_INTERRUPT;
>> +        gicc->header.length = sizeof(*gicc);
>> +        gicc->base_address = gicc_base;
>> +        gicc->cpu_interface_number = i;
>> +        gicc->arm_mpidr = libxl__compute_mpdir(i);
>> +        gicc->uid = i;
>> +        gicc->flags = ACPI_MADT_ENABLED;
>> +        gicc++;
>> +    }
>> +}
>> +
>> +static void make_acpi_madt_gicd(void *table, uint64_t gicd_base,
>> +                                uint8_t gic_version)
>> +{
>> +    struct acpi_madt_generic_distributor *gicd = table;
>> +
>> +    gicd->header.type = ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR;
>> +    gicd->header.length = sizeof(*gicd);
>> +    gicd->base_address = gicd_base;
>> +    /* This version field has no meaning before ACPI 5.1 errata. */
>> +    gicd->version = gic_version;
>> +}
>> +
>> +static void make_acpi_madt_gicr(void *table, uint64_t gicr_base,
>> +                                uint64_t gicr_size)
>> +{
>> +    struct acpi_madt_generic_redistributor *gicr = table;
>> +
>> +    gicr->header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR;
>> +    gicr->header.length = sizeof(*gicr);
>> +    gicr->base_address = gicr_base;
>> +    gicr->length = gicr_size;
>> +}
>> +
>> +static int make_acpi_madt(libxl__gc *gc, struct xc_dom_image *dom, int nr_cpus,
>> +                          xc_domain_configuration_t *xc_config,
>> +                          struct acpitable acpitables[])
>> +{
>> +    uint64_t offset = acpitables[MADT].addr - GUEST_ACPI_BASE;
>> +    struct acpi_table_madt *madt = dom->acpitable_blob + offset;
>> +    void *table = dom->acpitable_blob + offset;
>> +
>> +    switch (xc_config->gic_version) {
>> +    case XEN_DOMCTL_CONFIG_GIC_V2:
>> +        table += sizeof(struct acpi_table_madt);
>> +        make_acpi_madt_gicc(table, nr_cpus, GUEST_GICC_BASE);
>> +
>> +        table += sizeof(struct acpi_madt_generic_interrupt) * nr_cpus;
>> +        make_acpi_madt_gicd(table, GUEST_GICD_BASE, ACPI_MADT_GIC_VERSION_V2);
>> +        break;
>> +    case XEN_DOMCTL_CONFIG_GIC_V3:
>> +        table += sizeof(struct acpi_table_madt);
>> +        make_acpi_madt_gicc(table, nr_cpus, 0);
>> +
>> +        table += sizeof(struct acpi_madt_generic_interrupt) * nr_cpus;
>> +        make_acpi_madt_gicd(table, GUEST_GICV3_GICD_BASE,
>> +                            ACPI_MADT_GIC_VERSION_V3);
>> +
>> +        table += sizeof(struct acpi_madt_generic_distributor);
>> +        make_acpi_madt_gicr(table, GUEST_GICV3_GICR0_BASE,
>> +                            GUEST_GICV3_GICR0_SIZE);
>> +        break;
>> +    default:
>> +        LOG(ERROR, "Unknown GIC version");
>> +        return ERROR_FAIL;
>> +    }
>> +
>
> Why is this code snippet referencing libxc structure? I would think all
> relevant information is already available in libxl, right?

The hypervisor may choose the version of the GIC emulated if the user 
did not specified one. Those values are not replicated in libxl because 
this will be encoded in the hvm records during the migration (see the 
thread on the patch which introduced xc_config [1]).

FWIW, this is similar to what is done for the device tree case.

>
>> +    make_acpi_header(&madt->header, "APIC", acpitables[MADT].size, 3);
>> +    calculate_checksum(madt, offsetof(struct acpi_table_header, checksum),
>> +                       acpitables[MADT].size);
>> +
>> +    return 0;
>> +}
>> +
>>   int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>>                           libxl__domain_build_state *state,
>>                           struct xc_dom_image *dom)
>> @@ -227,6 +307,9 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>>       make_acpi_rsdp(gc, dom, acpitables);
>>       make_acpi_xsdt(gc, dom, acpitables);
>>       make_acpi_gtdt(gc, dom, acpitables);
>> +    rc = make_acpi_madt(gc, dom, info->max_vcpus, xc_config, acpitables);
>> +    if (rc)
>> +	return rc;
>>
>>       return 0;
>>   }
>> --
>> 2.0.4
>>
>>
>

[1] https://lists.xen.org/archives/html/xen-devel/2015-02/msg02538.html

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 17/17] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ
  2016-07-07 16:15   ` Wei Liu
@ 2016-07-07 16:57     ` Julien Grall
  2016-07-08  3:41       ` Shannon Zhao
  2016-07-08 10:47       ` Wei Liu
  0 siblings, 2 replies; 47+ messages in thread
From: Julien Grall @ 2016-07-07 16:57 UTC (permalink / raw)
  To: Wei Liu, Shannon Zhao
  Cc: hangaohuai, sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	shannon.zhao, boris.ostrovsky

Hi Wei,

On 07/07/16 17:15, Wei Liu wrote:
> On Tue, Jul 05, 2016 at 11:12:47AM +0800, Shannon Zhao wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> The guest kernel will get the event channel interrupt information via
>> domain param HVM_PARAM_CALLBACK_IRQ. Initialize it here.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>   tools/libxl/libxl_arm.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
>> index bc38318..acacba0 100644
>> --- a/tools/libxl/libxl_arm.c
>> +++ b/tools/libxl/libxl_arm.c
>> @@ -900,8 +900,19 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>>                                              struct xc_dom_image *dom)
>>   {
>>       int rc;
>> +    uint64_t val;
>>
>>       assert(info->type == LIBXL_DOMAIN_TYPE_PV);
>> +
>> +    /* Set the value of domain param HVM_PARAM_CALLBACK_IRQ. */
>> +    val = (uint64_t)HVM_PARAM_CALLBACK_TYPE_PPI << 56;
>> +    val |= (2 << 8); /* Active-low level-sensitive  */
>
> Please avoid using magic numbers here -- 56, 2 and 8.

The magic numbers are described in public/hvm/params.h however there is 
no defines associated to them.

The public header would need to be updated if we don't want the value 
hardcoded in libxl.

>
> Another question to Julien and Stefano: is it normal for ARM guest to
> use hvm callback vector?

Yes. The HVM callback vector is used by ACPI guest to find the PPI 
(per-cpu interrupt) which will be used to notify event.

This is how DOM0 is using ACPI on ARM (see [1]), I don't think we should 
differ here.

BTW, I have noticed that the design doc is only available on the ML.
Shannon, would it be possible to send a patch to add it in docs/misc/arm?

[2] https://lists.xen.org/archives/html/xen-devel/2015-11/msg00488.html

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 07/17] libxl/arm: Construct ACPI RSDP table
  2016-07-05  3:12 ` [PATCH v3 07/17] libxl/arm: Construct ACPI RSDP table Shannon Zhao
@ 2016-07-07 22:43   ` Boris Ostrovsky
  2016-07-08  3:31     ` Shannon Zhao
  0 siblings, 1 reply; 47+ messages in thread
From: Boris Ostrovsky @ 2016-07-07 22:43 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao

On 07/04/2016 11:12 PM, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> Construct ACPI RSDP table and add a helper to calculate the ACPI table
> checksum.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  tools/libxl/libxl_arm_acpi.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
>
> diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
> index 7a59126..9df1573 100644
> --- a/tools/libxl/libxl_arm_acpi.c
> +++ b/tools/libxl/libxl_arm_acpi.c
> @@ -33,6 +33,9 @@ extern const unsigned char dsdt_anycpu_arm[];
>  _hidden
>  extern const int dsdt_anycpu_arm_len;
>  
> +#define ACPI_BUILD_APPNAME6 "XenARM"
> +#define ACPI_BUILD_APPNAME4 "Xen "
> +
>  enum {
>      RSDP,
>      XSDT,
> @@ -109,6 +112,36 @@ static int libxl__estimate_acpi_size(libxl__gc *gc,
>      return 0;
>  }
>  
> +static void calculate_checksum(void *table, uint32_t checksum_offset,
> +                               uint32_t length)
> +{
> +    uint8_t *p, sum = 0;
> +
> +    p = table;
> +    p[checksum_offset] = 0;
> +
> +    while ( length-- )
> +        sum = sum + *p++;
> +
> +    p = table;
> +    p[checksum_offset] = -sum;
> +}
> +
> +static void make_acpi_rsdp(libxl__gc *gc, struct xc_dom_image *dom,
> +                           struct acpitable acpitables[])
> +{
> +    uint64_t offset = acpitables[RSDP].addr - GUEST_ACPI_BASE;
> +    struct acpi_table_rsdp *rsdp = dom->acpitable_blob + offset;
> +
> +    memcpy(rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
> +    memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, sizeof(rsdp->oem_id));
> +    rsdp->length = acpitables[RSDP].size;
> +    rsdp->revision = 0x02;
> +    rsdp->xsdt_physical_address = acpitables[XSDT].addr;
> +    calculate_checksum(rsdp, offsetof(struct acpi_table_rsdp, checksum),
> +                       acpitables[RSDP].size);

Should this be extended_checksum? checksum is for ACPI v1 (and thus for
smaller size structure, with only RSDT pointer).

-boris


> +}
> +
>  int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>                          libxl__domain_build_state *state,
>                          struct xc_dom_image *dom)
> @@ -134,6 +167,8 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>      if (rc)
>          return rc;
>  
> +    make_acpi_rsdp(gc, dom, acpitables);
> +
>      return 0;
>  }
>  




_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 07/17] libxl/arm: Construct ACPI RSDP table
  2016-07-07 22:43   ` Boris Ostrovsky
@ 2016-07-08  3:31     ` Shannon Zhao
  0 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-08  3:31 UTC (permalink / raw)
  To: Boris Ostrovsky, xen-devel
  Cc: hangaohuai, sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao



On 2016/7/8 6:43, Boris Ostrovsky wrote:
>> +    calculate_checksum(rsdp, offsetof(struct acpi_table_rsdp, checksum),
>> > +                       acpitables[RSDP].size);
> Should this be extended_checksum? checksum is for ACPI v1 (and thus for
> smaller size structure, with only RSDT pointer).
Ah, right. Will fix this.

Thanks,
-- 
Shannon


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 17/17] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ
  2016-07-07 16:57     ` Julien Grall
@ 2016-07-08  3:41       ` Shannon Zhao
  2016-07-08 10:47       ` Wei Liu
  1 sibling, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-08  3:41 UTC (permalink / raw)
  To: Julien Grall, Wei Liu
  Cc: hangaohuai, sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	shannon.zhao, boris.ostrovsky



On 2016/7/8 0:57, Julien Grall wrote:
> On 07/07/16 17:15, Wei Liu wrote:
>> On Tue, Jul 05, 2016 at 11:12:47AM +0800, Shannon Zhao wrote:
>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>
>>> The guest kernel will get the event channel interrupt information via
>>> domain param HVM_PARAM_CALLBACK_IRQ. Initialize it here.
>>>
>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>> ---
>>>   tools/libxl/libxl_arm.c | 11 +++++++++++
>>>   1 file changed, 11 insertions(+)
>>>
>>> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
>>> index bc38318..acacba0 100644
>>> --- a/tools/libxl/libxl_arm.c
>>> +++ b/tools/libxl/libxl_arm.c
>>> @@ -900,8 +900,19 @@ int
>>> libxl__arch_domain_init_hw_description(libxl__gc *gc,
>>>                                              struct xc_dom_image *dom)
>>>   {
>>>       int rc;
>>> +    uint64_t val;
>>>
>>>       assert(info->type == LIBXL_DOMAIN_TYPE_PV);
>>> +
>>> +    /* Set the value of domain param HVM_PARAM_CALLBACK_IRQ. */
>>> +    val = (uint64_t)HVM_PARAM_CALLBACK_TYPE_PPI << 56;
>>> +    val |= (2 << 8); /* Active-low level-sensitive  */
>>
>> Please avoid using magic numbers here -- 56, 2 and 8.
> 
> The magic numbers are described in public/hvm/params.h however there is
> no defines associated to them.
> 
> The public header would need to be updated if we don't want the value
> hardcoded in libxl.
> 
ok, so do we decide to update that?

>>
>> Another question to Julien and Stefano: is it normal for ARM guest to
>> use hvm callback vector?
> 
> Yes. The HVM callback vector is used by ACPI guest to find the PPI
> (per-cpu interrupt) which will be used to notify event.
> 
> This is how DOM0 is using ACPI on ARM (see [1]), I don't think we should
> differ here.
> 
> BTW, I have noticed that the design doc is only available on the ML.
> Shannon, would it be possible to send a patch to add it in docs/misc/arm?
> 
Ok, I'll send a patch later.

> [2] https://lists.xen.org/archives/html/xen-devel/2015-11/msg00488.html

-- 
Shannon


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 06/17] libxl/arm: Estimate the size of ACPI tables
  2016-07-07 16:39     ` Julien Grall
@ 2016-07-08 10:45       ` Wei Liu
  0 siblings, 0 replies; 47+ messages in thread
From: Wei Liu @ 2016-07-08 10:45 UTC (permalink / raw)
  To: Julien Grall
  Cc: hangaohuai, sstabellini, Wei Liu, ian.jackson, peter.huangpeng,
	xen-devel, shannon.zhao, Shannon Zhao, boris.ostrovsky

On Thu, Jul 07, 2016 at 05:39:38PM +0100, Julien Grall wrote:
> Hi Wei,
> 
> On 07/07/16 17:07, Wei Liu wrote:
> >On Tue, Jul 05, 2016 at 11:12:36AM +0800, Shannon Zhao wrote:
> >>  int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
> >>                          libxl__domain_build_state *state,
> >>                          struct xc_dom_image *dom)
> >>  {
> >>      const libxl_version_info *vers;
> >>+    int rc;
> >>+    struct acpitable acpitables[NUMS];
> >>+
> >>+    /* convenience aliases */
> >>+    xc_domain_configuration_t *xc_config = &state->config;
> >>
> >
> >Julien seemed to have suggested this structure shouldn't be used. Did I
> >misremember?
> 
> On the previous version, I said we should not extend this structure for
> parameter which is not used by the hypervisor (e.g the hypervisor does not
> need to know whether the guest will use ACPI).
> 
> However, this structure have to be used to get the version of the GIC that
> will be emulated for the guest. This is because the hypervisor might choose
> the version if the user did not specify one.
> 

OK. Makes sense.

Wei.

> Cheers,
> 
> -- 
> Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 17/17] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ
  2016-07-07 16:57     ` Julien Grall
  2016-07-08  3:41       ` Shannon Zhao
@ 2016-07-08 10:47       ` Wei Liu
  1 sibling, 0 replies; 47+ messages in thread
From: Wei Liu @ 2016-07-08 10:47 UTC (permalink / raw)
  To: Julien Grall
  Cc: hangaohuai, sstabellini, Wei Liu, ian.jackson, peter.huangpeng,
	xen-devel, shannon.zhao, Shannon Zhao, boris.ostrovsky

On Thu, Jul 07, 2016 at 05:57:09PM +0100, Julien Grall wrote:
> Hi Wei,
> 
> On 07/07/16 17:15, Wei Liu wrote:
> >On Tue, Jul 05, 2016 at 11:12:47AM +0800, Shannon Zhao wrote:
> >>From: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >>The guest kernel will get the event channel interrupt information via
> >>domain param HVM_PARAM_CALLBACK_IRQ. Initialize it here.
> >>
> >>Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >>---
> >>  tools/libxl/libxl_arm.c | 11 +++++++++++
> >>  1 file changed, 11 insertions(+)
> >>
> >>diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> >>index bc38318..acacba0 100644
> >>--- a/tools/libxl/libxl_arm.c
> >>+++ b/tools/libxl/libxl_arm.c
> >>@@ -900,8 +900,19 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc,
> >>                                             struct xc_dom_image *dom)
> >>  {
> >>      int rc;
> >>+    uint64_t val;
> >>
> >>      assert(info->type == LIBXL_DOMAIN_TYPE_PV);
> >>+
> >>+    /* Set the value of domain param HVM_PARAM_CALLBACK_IRQ. */
> >>+    val = (uint64_t)HVM_PARAM_CALLBACK_TYPE_PPI << 56;
> >>+    val |= (2 << 8); /* Active-low level-sensitive  */
> >
> >Please avoid using magic numbers here -- 56, 2 and 8.
> 
> The magic numbers are described in public/hvm/params.h however there is no
> defines associated to them.
> 
> The public header would need to be updated if we don't want the value
> hardcoded in libxl.
> 

Either update the public header or have some local #defines plus
appropriate comments on the what the actual source of those numbers is.

FWIW I certainly prefer the formal option.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 05/17] libxl/arm: Generate static ACPI DSDT table
  2016-07-07 15:52   ` Wei Liu
@ 2016-07-12  3:50     ` Shannon Zhao
  2016-07-12 11:38       ` Wei Liu
  0 siblings, 1 reply; 47+ messages in thread
From: Shannon Zhao @ 2016-07-12  3:50 UTC (permalink / raw)
  To: Wei Liu
  Cc: hangaohuai, sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky



On 2016/7/7 23:52, Wei Liu wrote:
> On Tue, Jul 05, 2016 at 11:12:35AM +0800, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > It uses static DSDT table like the way x86 uses. Currently the DSDT
>> > table only contains processor device objects and it generates the
>> > maximal objects which so far is 128.
>> > 
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> >  tools/libacpi/Makefile        | 15 ++++++++++++-
>> >  tools/libacpi/mk_dsdt.c       | 51 ++++++++++++++++++++++++++++++++-----------
>> >  tools/libxl/Makefile          |  5 ++++-
>> >  tools/libxl/libxl_arm_acpi.c  |  5 +++++
>> >  xen/include/public/arch-arm.h |  3 +++
>> >  5 files changed, 64 insertions(+), 15 deletions(-)
>> > 
>> > diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
>> > index 4068d9a..0401810 100644
>> > --- a/tools/libacpi/Makefile
>> > +++ b/tools/libacpi/Makefile
>> > @@ -22,6 +22,7 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
>> >  # Sources to be generated
>> >  C_SRC = $(ACPI_BUILD_DIR)/dsdt_anycpu.c $(ACPI_BUILD_DIR)/dsdt_15cpu.c 
>> >  C_SRC += $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.c $(ACPI_BUILD_DIR)/dsdt_pvh.c
>> > +C_SRC += $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.c
>> >  H_SRC = $(ACPI_BUILD_DIR)/ssdt_s3.h $(ACPI_BUILD_DIR)/ssdt_s4.h $(ACPI_BUILD_DIR)/ssdt_pm.h $(ACPI_BUILD_DIR)/ssdt_tpm.h
>> >  
>> >  vpath iasl $(PATH)
>> > @@ -35,7 +36,7 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
>> >  	cd $(CURDIR)
>> >  
>> >  $(MK_DSDT): mk_dsdt.c
>> > -	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
>> > +	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -o $@ mk_dsdt.c
> Why is this needed? Which unstable hypervisor interface you need in
> order to build this?
It needs GUEST_MAX_VCPUS in mk_dsdt.c while the GUEST_MAX_VCPUS is
defined under #if defined(__XEN__) || defined(__XEN_TOOLS__) in
xen/include/public/arch-arm.h

Thanks,
-- 
Shannon


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 04/17] libxl/arm: prepare for constructing ACPI tables
  2016-07-07 15:50   ` Wei Liu
@ 2016-07-12  7:05     ` Shannon Zhao
  0 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-12  7:05 UTC (permalink / raw)
  To: Wei Liu
  Cc: hangaohuai, sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky



On 2016/7/7 23:50, Wei Liu wrote:
> On Tue, Jul 05, 2016 at 11:12:34AM +0800, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > It only constructs the ACPI tables for 64-bit ARM DomU when user enables
>> > acpi because 32-bit DomU doesn't support ACPI.
>> > 
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> >  tools/libxl/Makefile         |  4 ++++
>> >  tools/libxl/libxl_arm.c      | 19 ++++++++++++++-
>> >  tools/libxl/libxl_arm.h      | 33 ++++++++++++++++++++++++++
>> >  tools/libxl/libxl_arm_acpi.c | 56 ++++++++++++++++++++++++++++++++++++++++++++
>> >  4 files changed, 111 insertions(+), 1 deletion(-)
>> >  create mode 100644 tools/libxl/libxl_arm.h
>> >  create mode 100644 tools/libxl/libxl_arm_acpi.c
>> > 
>> > diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
>> > index 0cf9f6a..88ab4d2 100644
>> > --- a/tools/libxl/Makefile
>> > +++ b/tools/libxl/Makefile
>> > @@ -91,6 +91,10 @@ 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
>> > +LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_acpi.o
>> > +
>> > +libxl_arm_acpi.o: libxl_arm_acpi.c
>> > +	$(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c
>> >  
>> >  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 4a57dd7..7c522e1 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 <xc_dom.h>
>> >  #include <stdbool.h>
>> > @@ -885,8 +886,24 @@ 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)
>> > +        return rc;
>> > +
>> > +    if (!libxl_defbool_val(info->arch_arm.acpi)) {
>> > +        LOG(DEBUG, "Generating ACPI tables is disabled by user.");
>> > +        return 0;
>> > +    }
>> > +
>> > +    if (strcmp(dom->guest_type, "xen-3.0-aarch64")) {
>> > +        LOG(ERROR, "Can not enable xl option 'acpi' for %s", dom->guest_type);
>> > +        return ERROR_FAIL;
>> > +    }
>> > +
>> > +    return libxl__prepare_acpi(gc, info, state, dom);
> Please use goto style error handling for consistency. See
> tools/libxl/CODING_STYLE. Please fix all other instances as well.
> 
Ok, will fix these. Thanks.

-- 
Shannon


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 05/17] libxl/arm: Generate static ACPI DSDT table
  2016-07-12  3:50     ` Shannon Zhao
@ 2016-07-12 11:38       ` Wei Liu
  2016-07-12 14:49         ` Shannon Zhao
  0 siblings, 1 reply; 47+ messages in thread
From: Wei Liu @ 2016-07-12 11:38 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, sstabellini, Wei Liu, ian.jackson, peter.huangpeng,
	xen-devel, julien.grall, shannon.zhao, boris.ostrovsky

On Tue, Jul 12, 2016 at 11:50:32AM +0800, Shannon Zhao wrote:
> 
> 
> On 2016/7/7 23:52, Wei Liu wrote:
> > On Tue, Jul 05, 2016 at 11:12:35AM +0800, Shannon Zhao wrote:
> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >> > 
> >> > It uses static DSDT table like the way x86 uses. Currently the DSDT
> >> > table only contains processor device objects and it generates the
> >> > maximal objects which so far is 128.
> >> > 
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> > ---
> >> >  tools/libacpi/Makefile        | 15 ++++++++++++-
> >> >  tools/libacpi/mk_dsdt.c       | 51 ++++++++++++++++++++++++++++++++-----------
> >> >  tools/libxl/Makefile          |  5 ++++-
> >> >  tools/libxl/libxl_arm_acpi.c  |  5 +++++
> >> >  xen/include/public/arch-arm.h |  3 +++
> >> >  5 files changed, 64 insertions(+), 15 deletions(-)
> >> > 
> >> > diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
> >> > index 4068d9a..0401810 100644
> >> > --- a/tools/libacpi/Makefile
> >> > +++ b/tools/libacpi/Makefile
> >> > @@ -22,6 +22,7 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
> >> >  # Sources to be generated
> >> >  C_SRC = $(ACPI_BUILD_DIR)/dsdt_anycpu.c $(ACPI_BUILD_DIR)/dsdt_15cpu.c 
> >> >  C_SRC += $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.c $(ACPI_BUILD_DIR)/dsdt_pvh.c
> >> > +C_SRC += $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.c
> >> >  H_SRC = $(ACPI_BUILD_DIR)/ssdt_s3.h $(ACPI_BUILD_DIR)/ssdt_s4.h $(ACPI_BUILD_DIR)/ssdt_pm.h $(ACPI_BUILD_DIR)/ssdt_tpm.h
> >> >  
> >> >  vpath iasl $(PATH)
> >> > @@ -35,7 +36,7 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
> >> >  	cd $(CURDIR)
> >> >  
> >> >  $(MK_DSDT): mk_dsdt.c
> >> > -	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
> >> > +	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -o $@ mk_dsdt.c
> > Why is this needed? Which unstable hypervisor interface you need in
> > order to build this?
> It needs GUEST_MAX_VCPUS in mk_dsdt.c while the GUEST_MAX_VCPUS is
> defined under #if defined(__XEN__) || defined(__XEN_TOOLS__) in
> xen/include/public/arch-arm.h
> 

OK. Let me elaborate a bit on this.

The two macros basically imply everything enclosed in them is subject to
change. I guess I can live with this because this is not a public facing
interface for library users.

Can you ack or nack my assessment?

Wei.

> Thanks,
> -- 
> Shannon
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v3 05/17] libxl/arm: Generate static ACPI DSDT table
  2016-07-12 11:38       ` Wei Liu
@ 2016-07-12 14:49         ` Shannon Zhao
  0 siblings, 0 replies; 47+ messages in thread
From: Shannon Zhao @ 2016-07-12 14:49 UTC (permalink / raw)
  To: Wei Liu, Shannon Zhao
  Cc: hangaohuai, sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, boris.ostrovsky

On 2016年07月12日 19:38, Wei Liu wrote:
> On Tue, Jul 12, 2016 at 11:50:32AM +0800, Shannon Zhao wrote:
>> > 
>> > 
>> > On 2016/7/7 23:52, Wei Liu wrote:
>>> > > On Tue, Jul 05, 2016 at 11:12:35AM +0800, Shannon Zhao wrote:
>>>>> > >> > From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>> > >> > 
>>>>> > >> > It uses static DSDT table like the way x86 uses. Currently the DSDT
>>>>> > >> > table only contains processor device objects and it generates the
>>>>> > >> > maximal objects which so far is 128.
>>>>> > >> > 
>>>>> > >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>>>> > >> > ---
>>>>> > >> >  tools/libacpi/Makefile        | 15 ++++++++++++-
>>>>> > >> >  tools/libacpi/mk_dsdt.c       | 51 ++++++++++++++++++++++++++++++++-----------
>>>>> > >> >  tools/libxl/Makefile          |  5 ++++-
>>>>> > >> >  tools/libxl/libxl_arm_acpi.c  |  5 +++++
>>>>> > >> >  xen/include/public/arch-arm.h |  3 +++
>>>>> > >> >  5 files changed, 64 insertions(+), 15 deletions(-)
>>>>> > >> > 
>>>>> > >> > diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
>>>>> > >> > index 4068d9a..0401810 100644
>>>>> > >> > --- a/tools/libacpi/Makefile
>>>>> > >> > +++ b/tools/libacpi/Makefile
>>>>> > >> > @@ -22,6 +22,7 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
>>>>> > >> >  # Sources to be generated
>>>>> > >> >  C_SRC = $(ACPI_BUILD_DIR)/dsdt_anycpu.c $(ACPI_BUILD_DIR)/dsdt_15cpu.c 
>>>>> > >> >  C_SRC += $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.c $(ACPI_BUILD_DIR)/dsdt_pvh.c
>>>>> > >> > +C_SRC += $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.c
>>>>> > >> >  H_SRC = $(ACPI_BUILD_DIR)/ssdt_s3.h $(ACPI_BUILD_DIR)/ssdt_s4.h $(ACPI_BUILD_DIR)/ssdt_pm.h $(ACPI_BUILD_DIR)/ssdt_tpm.h
>>>>> > >> >  
>>>>> > >> >  vpath iasl $(PATH)
>>>>> > >> > @@ -35,7 +36,7 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
>>>>> > >> >  	cd $(CURDIR)
>>>>> > >> >  
>>>>> > >> >  $(MK_DSDT): mk_dsdt.c
>>>>> > >> > -	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
>>>>> > >> > +	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -o $@ mk_dsdt.c
>>> > > Why is this needed? Which unstable hypervisor interface you need in
>>> > > order to build this?
>> > It needs GUEST_MAX_VCPUS in mk_dsdt.c while the GUEST_MAX_VCPUS is
>> > defined under #if defined(__XEN__) || defined(__XEN_TOOLS__) in
>> > xen/include/public/arch-arm.h
>> > 
> OK. Let me elaborate a bit on this.
> 
> The two macros basically imply everything enclosed in them is subject to
> change. I guess I can live with this because this is not a public facing
> interface for library users.
> 
> Can you ack or nack my assessment?
Yeah, the mk_dsdt is just a middle result of compilation which is used
to generate DSDT table.

Thanks,
-- 
Shannon

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2016-07-12 14:49 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05  3:12 [PATCH v3 00/17] Xen ARM DomU ACPI support Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 01/17] libxl/arm: Factor out codes for generating DTB Shannon Zhao
2016-07-07 15:41   ` Wei Liu
2016-07-07 15:48     ` Boris Ostrovsky
2016-07-07 16:06       ` Julien Grall
2016-07-07 16:09         ` Wei Liu
2016-07-07 16:12         ` Boris Ostrovsky
2016-07-07 16:15           ` Julien Grall
2016-07-07 16:16           ` Wei Liu
2016-07-07 16:08       ` Wei Liu
2016-07-05  3:12 ` [PATCH v3 02/17] libxc: Add placeholders for ACPI tables blob and size Shannon Zhao
2016-07-07 15:42   ` Wei Liu
2016-07-05  3:12 ` [PATCH v3 03/17] libxl/arm: Add a configuration option for ARM DomU ACPI Shannon Zhao
2016-07-07 15:48   ` Wei Liu
2016-07-05  3:12 ` [PATCH v3 04/17] libxl/arm: prepare for constructing ACPI tables Shannon Zhao
2016-07-07 15:50   ` Wei Liu
2016-07-12  7:05     ` Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 05/17] libxl/arm: Generate static ACPI DSDT table Shannon Zhao
2016-07-07 15:52   ` Wei Liu
2016-07-12  3:50     ` Shannon Zhao
2016-07-12 11:38       ` Wei Liu
2016-07-12 14:49         ` Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 06/17] libxl/arm: Estimate the size of ACPI tables Shannon Zhao
2016-07-07 16:07   ` Wei Liu
2016-07-07 16:39     ` Julien Grall
2016-07-08 10:45       ` Wei Liu
2016-07-05  3:12 ` [PATCH v3 07/17] libxl/arm: Construct ACPI RSDP table Shannon Zhao
2016-07-07 22:43   ` Boris Ostrovsky
2016-07-08  3:31     ` Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 08/17] libxl/arm: Construct ACPI XSDT table Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 09/17] libxl/arm: Construct ACPI GTDT table Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 10/17] libxl/arm: Factor MPIDR computing codes out as a helper Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 11/17] libxl/arm: Construct ACPI MADT table Shannon Zhao
2016-07-07 16:11   ` Wei Liu
2016-07-07 16:46     ` Julien Grall
2016-07-05  3:12 ` [PATCH v3 12/17] libxl/arm: Construct ACPI FADT table Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 13/17] libxl/arm: Construct ACPI DSDT table Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 14/17] libxl/arm: Factor finalise_one_memory_node as a gerneric function Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 15/17] libxl/arm: Add ACPI module Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 16/17] libxc/xc_dom_core: Copy ACPI tables to guest space Shannon Zhao
2016-07-05  3:12 ` [PATCH v3 17/17] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ Shannon Zhao
2016-07-07 16:15   ` Wei Liu
2016-07-07 16:57     ` Julien Grall
2016-07-08  3:41       ` Shannon Zhao
2016-07-08 10:47       ` Wei Liu
2016-07-05 10:32 ` [PATCH v3 00/17] Xen ARM DomU ACPI support Julien Grall
2016-07-05 14:09   ` Shannon Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).