xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 00/16] Xen ARM DomU ACPI support
@ 2016-09-22 12:52 z00226004
  2016-09-22 12:52 ` [PATCH v6 01/16] tools/libxl: Add an unified configuration option for ACPI z00226004
                   ` (17 more replies)
  0 siblings, 18 replies; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

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

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 linux master or:
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_v6

Changes since v5:
* Set the MADT GICC size correctly
* Add libxl__arch_memory_constant to get acpi table size and add it at
  common code
* other samll changes

Changes since v4:
* make changes in tools/configure.ac instead of tools/configure
* add libxl_arm_no_acpi.c for no acpi build
* add a function to get the acpi table size and use it to set maxmem
* drop HVM_PARAM_CALLBACK_TYPE_PPI_MASK and update hvm_set_callback_via
* add libxl__arch_domain_build_info_acpi_setdefault to set b_info->acpi
  default value separately
* update ACPI_OEM_ID
* set gtdt->counter_block_addresss and gtdt->counter_read_block_address
* add a BUILD_BUG_ON to check if GUEST_MAX_VCPUS >= MAX_VIRT_CPUS

Changes since v3:
* use goto style error handle
* unify configuration option for ACPI
* use extended_checksum instead of checksum in RSDP table
* only require iasl on arm64
* count acpi tables size for maxmem

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 (16):
  tools/libxl: Add an unified configuration option for 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
  public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI
  libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ
  libxl/arm: Add the size of ACPI tables to maxmem

 docs/man/xl.cfg.pod.5.in           |   1 +
 docs/misc/arm/device-tree/acpi.txt |  24 +++
 tools/configure.ac                 |   2 +-
 tools/libacpi/Makefile             |   8 +-
 tools/libacpi/mk_dsdt.c            |  27 ++-
 tools/libxl/Makefile               |  10 +
 tools/libxl/libxl_arch.h           |   8 +
 tools/libxl/libxl_arm.c            | 100 +++++++--
 tools/libxl/libxl_arm.h            |  48 +++++
 tools/libxl/libxl_arm_acpi.c       | 409 +++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_arm_no_acpi.c    |  40 ++++
 tools/libxl/libxl_create.c         |   4 +-
 tools/libxl/libxl_dm.c             |   4 +-
 tools/libxl/libxl_dom.c            |   9 +-
 tools/libxl/libxl_internal.h       |  11 +
 tools/libxl/libxl_types.idl        |   4 +
 tools/libxl/libxl_x86.c            |  12 ++
 tools/libxl/xl_cmdimpl.c           |   2 +-
 xen/arch/arm/domain.c              |   1 +
 xen/arch/arm/domain_build.c        |   9 +-
 xen/arch/x86/hvm/irq.c             |   2 +-
 xen/include/acpi/actbl1.h          |   2 +
 xen/include/public/arch-arm.h      |   7 +
 xen/include/public/hvm/params.h    |   3 +
 24 files changed, 723 insertions(+), 24 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
 create mode 100644 tools/libxl/libxl_arm_no_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] 56+ messages in thread

* [PATCH v6 01/16] tools/libxl: Add an unified configuration option for ACPI
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 12:52 ` [PATCH v6 02/16] libxl/arm: prepare for constructing ACPI tables z00226004
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

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

Since the existing configuration option "u.hvm.acpi" is x86 specific and
we want to reuse it on ARM as well, add a unified option "acpi" for
x86 and ARM, and for ARM it's disabled by default.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 docs/man/xl.cfg.pod.5.in     | 1 +
 tools/libxl/libxl_arch.h     | 4 ++++
 tools/libxl/libxl_arm.c      | 6 ++++++
 tools/libxl/libxl_create.c   | 4 +++-
 tools/libxl/libxl_dm.c       | 4 ++--
 tools/libxl/libxl_internal.h | 6 ++++++
 tools/libxl/libxl_types.idl  | 4 ++++
 tools/libxl/libxl_x86.c      | 6 ++++++
 tools/libxl/xl_cmdimpl.c     | 2 +-
 9 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index 77a1be3..db71fca 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1239,6 +1239,7 @@ the virtual firmware to the guest Operating System. ACPI is required
 by most modern guest Operating Systems. This option is enabled by
 default and usually you should omit it. However it may be necessary to
 disable ACPI for compatibility with some guest Operating Systems.
+This option is true for x86 while it's false for ARM by default.
 
 =item B<acpi_s3=BOOLEAN>
 
diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
index 7a70b01..8cb9ba7 100644
--- a/tools/libxl/libxl_arch.h
+++ b/tools/libxl/libxl_arch.h
@@ -62,6 +62,10 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
                                         uint32_t domid,
                                         struct xc_dom_image *dom);
 
+_hidden
+void libxl__arch_domain_build_info_acpi_setdefault(
+                                        libxl_domain_build_info *b_info);
+
 #if defined(__i386__) || defined(__x86_64__)
 
 #define LAPIC_BASE_ADDRESS  0xfee00000
diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index bd3d611..8ec5cd5 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -985,6 +985,12 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
     return 0;
 }
 
+void libxl__arch_domain_build_info_acpi_setdefault(
+                                        libxl_domain_build_info *b_info)
+{
+    libxl_defbool_setdefault(&b_info->acpi, false);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 07b2b4b..d986cd2 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -215,6 +215,8 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
     if (!b_info->event_channels)
         b_info->event_channels = 1023;
 
+    libxl__arch_domain_build_info_acpi_setdefault(b_info);
+
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         if (b_info->shadow_memkb == LIBXL_MEMKB_DEFAULT)
@@ -454,7 +456,7 @@ int libxl__domain_build(libxl__gc *gc,
         localents = libxl__calloc(gc, 9, sizeof(char *));
         i = 0;
         localents[i++] = "platform/acpi";
-        localents[i++] = libxl_defbool_val(info->u.hvm.acpi) ? "1" : "0";
+        localents[i++] = libxl__acpi_defbool_val(info) ? "1" : "0";
         localents[i++] = "platform/acpi_s3";
         localents[i++] = libxl_defbool_val(info->u.hvm.acpi_s3) ? "1" : "0";
         localents[i++] = "platform/acpi_s4";
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index e3bf28f..ad366a8 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -583,7 +583,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
         if (b_info->u.hvm.soundhw) {
             flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL);
         }
-        if (libxl_defbool_val(b_info->u.hvm.acpi)) {
+        if (libxl__acpi_defbool_val(b_info)) {
             flexarray_append(dm_args, "-acpi");
         }
         if (b_info->max_vcpus > 1) {
@@ -1204,7 +1204,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
         if (b_info->u.hvm.soundhw) {
             flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL);
         }
-        if (!libxl_defbool_val(b_info->u.hvm.acpi)) {
+        if (!libxl__acpi_defbool_val(b_info)) {
             flexarray_append(dm_args, "-no-acpi");
         }
         if (b_info->max_vcpus > 1) {
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index a8fb23e..f1ba473 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -4292,6 +4292,12 @@ _hidden int libxl__read_sysfs_file_contents(libxl__gc *gc,
 #define LIBXL_QEMU_USER_PREFIX "xen-qemuuser"
 #define LIBXL_QEMU_USER_BASE   LIBXL_QEMU_USER_PREFIX"-domid"
 #define LIBXL_QEMU_USER_SHARED LIBXL_QEMU_USER_PREFIX"-shared"
+
+static inline bool libxl__acpi_defbool_val(const libxl_domain_build_info *b_info)
+{
+    return libxl_defbool_val(b_info->acpi) &&
+           libxl_defbool_val(b_info->u.hvm.acpi);
+}
 #endif
 
 /*
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 98bfc3a..a02446f 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -494,11 +494,15 @@ libxl_domain_build_info = Struct("domain_build_info",[
     # Note that the partial device tree should avoid to use the phandle
     # 65000 which is reserved by the toolstack.
     ("device_tree",      string),
+    ("acpi",             libxl_defbool),
     ("u", KeyedUnion(None, libxl_domain_type, "type",
                 [("hvm", Struct(None, [("firmware",         string),
                                        ("bios",             libxl_bios_type),
                                        ("pae",              libxl_defbool),
                                        ("apic",             libxl_defbool),
+                                       # The following acpi field is deprecated.
+                                       # Please use the unified acpi field above
+                                       # which works for both x86 and ARM.
                                        ("acpi",             libxl_defbool),
                                        ("acpi_s3",          libxl_defbool),
                                        ("acpi_s4",          libxl_defbool),
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index d10b04b..f69f3c2 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -571,6 +571,12 @@ out:
     return rc;
 }
 
+void libxl__arch_domain_build_info_acpi_setdefault(
+                                        libxl_domain_build_info *b_info)
+{
+    libxl_defbool_setdefault(&b_info->acpi, true);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 62237d0..6a01801 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -1550,6 +1550,7 @@ static void parse_config_data(const char *config_source,
     b_info->cmdline = parse_cmdline(config);
 
     xlu_cfg_get_defbool(config, "driver_domain", &c_info->driver_domain, 0);
+    xlu_cfg_get_defbool(config, "acpi", &b_info->acpi, 0);
 
     switch(b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
@@ -1579,7 +1580,6 @@ static void parse_config_data(const char *config_source,
 
         xlu_cfg_get_defbool(config, "pae", &b_info->u.hvm.pae, 0);
         xlu_cfg_get_defbool(config, "apic", &b_info->u.hvm.apic, 0);
-        xlu_cfg_get_defbool(config, "acpi", &b_info->u.hvm.acpi, 0);
         xlu_cfg_get_defbool(config, "acpi_s3", &b_info->u.hvm.acpi_s3, 0);
         xlu_cfg_get_defbool(config, "acpi_s4", &b_info->u.hvm.acpi_s4, 0);
         xlu_cfg_get_defbool(config, "nx", &b_info->u.hvm.nx, 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] 56+ messages in thread

* [PATCH v6 02/16] libxl/arm: prepare for constructing ACPI tables
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
  2016-09-22 12:52 ` [PATCH v6 01/16] tools/libxl: Add an unified configuration option for ACPI z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:13   ` Wei Liu
  2016-09-22 12:52 ` [PATCH v6 03/16] libxl/arm: Generate static ACPI DSDT table z00226004
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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. And the generation codes
are only built for 64-bit toolstack.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 tools/libxl/Makefile            |  7 +++++
 tools/libxl/libxl_arm.c         | 24 +++++++++++++++-
 tools/libxl/libxl_arm.h         | 33 ++++++++++++++++++++++
 tools/libxl/libxl_arm_acpi.c    | 62 +++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_arm_no_acpi.c | 34 ++++++++++++++++++++++
 xen/include/public/arch-arm.h   |  4 +++
 6 files changed, 163 insertions(+), 1 deletion(-)
 create mode 100644 tools/libxl/libxl_arm.h
 create mode 100644 tools/libxl/libxl_arm_acpi.c
 create mode 100644 tools/libxl/libxl_arm_no_acpi.c

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 336358c..94ab743 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -91,6 +91,13 @@ acpi:
 
 LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o
 LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
+ifeq ($(CONFIG_ARM_64),y)
+LIBXL_OBJS-y += libxl_arm_acpi.o
+libxl_arm_acpi.o: libxl_arm_acpi.c
+	$(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c
+else
+LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_no_acpi.o
+endif
 
 ifeq ($(CONFIG_NetBSD),y)
 LIBXL_OBJS-y += libxl_netbsd.o
diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 8ec5cd5..333c9a1 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -1,6 +1,7 @@
 #include "libxl_internal.h"
 #include "libxl_arch.h"
 #include "libxl_libfdt_compat.h"
+#include "libxl_arm.h"
 
 #include <xc_dom.h>
 #include <stdbool.h>
@@ -885,8 +886,29 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc,
                                            libxl__domain_build_state *state,
                                            struct xc_dom_image *dom)
 {
+    int rc;
+
     assert(info->type == LIBXL_DOMAIN_TYPE_PV);
-    return libxl__prepare_dtb(gc, info, state, dom);
+    rc = libxl__prepare_dtb(gc, info, state, dom);
+    if (rc) goto out;
+
+    if (!libxl_defbool_val(info->acpi)) {
+        LOG(DEBUG, "Generating ACPI tables is disabled by user.");
+        rc = 0;
+        goto out;
+    }
+
+    if (strcmp(dom->guest_type, "xen-3.0-aarch64")) {
+        /* ACPI is only supported for 64-bit guest currently. */
+        LOG(ERROR, "Can not enable libxl option 'acpi' for %s", dom->guest_type);
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    rc = libxl__prepare_acpi(gc, info, state, dom);
+
+out:
+    return rc;
 }
 
 static void finalise_one_memory_node(libxl__gc *gc, void *fdt,
diff --git a/tools/libxl/libxl_arm.h b/tools/libxl/libxl_arm.h
new file mode 100644
index 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..810aed8
--- /dev/null
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -0,0 +1,62 @@
+/*
+ * ARM DomU ACPI generation
+ *
+ * Copyright (C) 2016      Linaro Ltd.
+ *
+ * Author: Shannon Zhao <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>
+
+/* Below typedefs are useful for the headers under acpi/ */
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+
+#include <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;
+    int rc = 0;
+
+    vers = libxl_get_version_info(CTX);
+    if (vers == NULL) {
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    LOG(DEBUG, "constructing ACPI tables for Xen version %d.%d guest",
+        vers->xen_version_major, vers->xen_version_minor);
+
+    dom->acpi_modules[0].data = NULL;
+    dom->acpi_modules[0].length = 0;
+    dom->acpi_modules[0].guest_addr_out = GUEST_ACPI_BASE;
+
+out:
+    return rc;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/tools/libxl/libxl_arm_no_acpi.c b/tools/libxl/libxl_arm_no_acpi.c
new file mode 100644
index 0000000..e7f7411
--- /dev/null
+++ b/tools/libxl/libxl_arm_no_acpi.c
@@ -0,0 +1,34 @@
+/*
+ * 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"
+
+int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
+                        libxl__domain_build_state *state,
+                        struct xc_dom_image *dom)
+{
+    return ERROR_FAIL;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index 870bc3b..4b4c959 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 0x02000000ULL
+
 /*
  * 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] 56+ messages in thread

* [PATCH v6 03/16] libxl/arm: Generate static ACPI DSDT table
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
  2016-09-22 12:52 ` [PATCH v6 01/16] tools/libxl: Add an unified configuration option for ACPI z00226004
  2016-09-22 12:52 ` [PATCH v6 02/16] libxl/arm: prepare for constructing ACPI tables z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 12:52 ` [PATCH v6 04/16] libxl/arm: Estimate the size of ACPI tables z00226004
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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.

While the GUEST_MAX_VCPUS is defined under __XEN__ or __XEN_TOOLS__, it
needs to add -D__XEN_TOOLS__ to compile mk_dsdt.c.

Also only check iasl for aarch64 in configure since ACPI on ARM32 is not
supported.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/configure.ac            |  2 +-
 tools/libacpi/Makefile        |  8 +++++++-
 tools/libacpi/mk_dsdt.c       | 27 ++++++++++++++++++++++++++-
 tools/libxl/Makefile          |  5 ++++-
 tools/libxl/libxl_arm_acpi.c  |  5 +++++
 xen/arch/arm/domain.c         |  1 +
 xen/include/public/arch-arm.h |  3 +++
 7 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/tools/configure.ac b/tools/configure.ac
index f010d72..dba7c7a 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -340,7 +340,7 @@ dnl "host" here means the platform on which the hypervisor and tools is
 dnl going to run, not the platform on which we are building (known as
 dnl "build" in gnu speak).
 case "$host_cpu" in
-i[[3456]]86|x86_64)
+i[[3456]]86|x86_64|aarch64)
     AX_PATH_PROG_OR_FAIL([IASL], [iasl])
     ;;
 esac
diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
index 68351c7..ee3f071 100644
--- a/tools/libacpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -24,6 +24,7 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
 
 C_SRC-$(GPL) 	= dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
 C_SRC		= $(addprefix $(ACPI_BUILD_DIR)/, dsdt_pvh.c $(C_SRC-y))
+C_SRC		+= $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.c
 H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
 
 vpath iasl $(PATH)
@@ -35,7 +36,7 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
 	rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex)
 
 $(MK_DSDT): mk_dsdt.c
-	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
+	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -o $@ mk_dsdt.c
 
 ifeq ($(GPL),y)
 $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: gpl/dsdt.asl $(MK_DSDT)
@@ -58,6 +59,11 @@ $(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT)
 	$(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $@.$(TMP_SUFFIX)
 	mv -f $@.$(TMP_SUFFIX) $@
 
+$(ACPI_BUILD_DIR)/dsdt_anycpu_arm.asl: $(MK_DSDT)
+	printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 3, \"Xen\", \"ARM\", 1)\n{" > $@.$(TMP_SUFFIX)
+	$(MK_DSDT) --debug=$(debug) >> $@.$(TMP_SUFFIX)
+	mv -f $@.$(TMP_SUFFIX) $@
+
 $(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl
 	iasl -vs -p $(ACPI_BUILD_DIR)/$*.$(TMP_SUFFIX) -tc $(ACPI_BUILD_DIR)/$*.asl
 	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@.$(TMP_SUFFIX)
diff --git a/tools/libacpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c
index 8130cbd..4ae68bc 100644
--- a/tools/libacpi/mk_dsdt.c
+++ b/tools/libacpi/mk_dsdt.c
@@ -17,7 +17,11 @@
 #include <getopt.h>
 #include <stdlib.h>
 #include <stdbool.h>
+#if defined(__i386__) || defined(__x86_64__)
 #include <xen/hvm/hvm_info_table.h>
+#elif defined(__aarch64__)
+#include <xen/arch-arm.h>
+#endif
 
 static unsigned int indent_level;
 static bool debug = false;
@@ -104,9 +108,15 @@ static struct option options[] = {
 
 int main(int argc, char **argv)
 {
-    unsigned int slot, cpu, max_cpus = HVM_MAX_VCPUS;
+    unsigned int slot, cpu, max_cpus;
     dm_version dm_version = QEMU_XEN_TRADITIONAL;
 
+#if defined(__i386__) || defined(__x86_64__)
+    max_cpus = HVM_MAX_VCPUS;
+#elif defined(__aarch64__)
+    max_cpus = GUEST_MAX_VCPUS;
+#endif
+
     for ( ; ; )
     {
         int opt = getopt_long(argc, argv, "", options, NULL);
@@ -159,6 +169,7 @@ int main(int argc, char **argv)
     /**** Processor start ****/
     push_block("Scope", "\\_SB");
 
+#if defined(__i386__) || defined(__x86_64__)
     /* MADT checksum */
     stmt("OperationRegion", "MSUM, SystemMemory, \\_SB.MSUA, 1");
     push_block("Field", "MSUM, ByteAcc, NoLock, Preserve");
@@ -172,6 +183,7 @@ int main(int argc, char **argv)
     pop_block();
     stmt("Return", "Buffer() {0, 8, 0xff, 0xff, 0, 0, 0, 0}");
     pop_block();
+#endif
 
     /* Define processor objects and control methods. */
     for ( cpu = 0; cpu < max_cpus; cpu++)
@@ -180,6 +192,11 @@ int main(int argc, char **argv)
 
         stmt("Name", "_HID, \"ACPI0007\"");
 
+        stmt("Name", "_UID, %d", cpu);
+#if defined(__aarch64__)
+        pop_block();
+        continue;
+#endif
         /* Name this processor's MADT LAPIC descriptor. */
         stmt("OperationRegion", 
              "MATR, SystemMemory, Add(\\_SB.MAPA, %d), 8", cpu*8);
@@ -218,6 +235,14 @@ int main(int argc, char **argv)
         pop_block();
     }
 
+#if defined(__aarch64__)
+    pop_block();
+    /**** Processor end ****/
+    pop_block();
+    /**** DSDT DefinitionBlock end ****/
+    return 0;
+#endif
+
     /* 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 94ab743..95f6a33 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -92,7 +92,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
 ifeq ($(CONFIG_ARM_64),y)
-LIBXL_OBJS-y += libxl_arm_acpi.o
+LIBXL_OBJS-y += libxl_arm_acpi.o dsdt_anycpu_arm.o
+dsdt_anycpu_arm.c:
+	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR)
+
 libxl_arm_acpi.o: libxl_arm_acpi.c
 	$(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c
 else
diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 810aed8..0851411 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -29,6 +29,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/arch/arm/domain.c b/xen/arch/arm/domain.c
index 20bb2ba..e237f61 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -548,6 +548,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
 {
     int rc, count = 0;
 
+    BUILD_BUG_ON(GUEST_MAX_VCPUS < MAX_VIRT_CPUS);
     d->arch.relmem = RELMEM_not_started;
 
     /* Idle domains do not need this setup */
diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index 4b4c959..1bef2ee 100644
--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -435,6 +435,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] 56+ messages in thread

* [PATCH v6 04/16] libxl/arm: Estimate the size of ACPI tables
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (2 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 03/16] libxl/arm: Generate static ACPI DSDT table z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:21   ` Wei Liu
  2016-09-27 15:20   ` [PATCH v7 " Shannon Zhao
  2016-09-22 12:52 ` [PATCH v6 05/16] libxl/arm: Construct ACPI RSDP table z00226004
                   ` (13 subsequent siblings)
  17 siblings, 2 replies; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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 | 98 ++++++++++++++++++++++++++++++++++++++++++++
 xen/include/acpi/actbl1.h    |  2 +
 2 files changed, 100 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 0851411..1dbd7e5 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -34,12 +34,108 @@ 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_madt_size(libxl__gc *gc,
+                                     libxl_domain_build_info *info,
+                                     xc_domain_configuration_t *xc_config)
+{
+    int rc;
+
+    switch (xc_config->gic_version) {
+    case XEN_DOMCTL_CONFIG_GIC_V2:
+        rc = sizeof(struct acpi_table_madt) +
+             ACPI_MADT_GICC_SIZE_v5 * info->max_vcpus +
+             sizeof(struct acpi_madt_generic_distributor);
+        break;
+    case XEN_DOMCTL_CONFIG_GIC_V3:
+        rc = sizeof(struct acpi_table_madt) +
+             ACPI_MADT_GICC_SIZE_v5 * info->max_vcpus +
+             sizeof(struct acpi_madt_generic_distributor) +
+             sizeof(struct acpi_madt_generic_redistributor);
+        break;
+    default:
+        LOG(ERROR, "Unknown GIC version");
+        rc = ERROR_FAIL;
+        break;
+    }
+
+    return rc;
+}
+
+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[])
+{
+    int rc;
+
+    acpitables[RSDP].addr = GUEST_ACPI_BASE;
+    acpitables[RSDP].size = sizeof(struct acpi_table_rsdp);
+    dom->acpi_modules[0].length += ROUNDUP(acpitables[RSDP].size, 3);
+
+    acpitables[XSDT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length;
+    /*
+     * 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->acpi_modules[0].length += ROUNDUP(acpitables[XSDT].size, 3);
+
+    acpitables[GTDT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length;
+    acpitables[GTDT].size = sizeof(struct acpi_table_gtdt);
+    dom->acpi_modules[0].length += ROUNDUP(acpitables[GTDT].size, 3);
+
+    acpitables[MADT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length;
+
+    rc = libxl__estimate_madt_size(gc, info, xc_config);
+    if (rc < 0)
+        goto out;
+
+    acpitables[MADT].size = rc;
+    dom->acpi_modules[0].length += ROUNDUP(acpitables[MADT].size, 3);
+
+    acpitables[FADT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length;
+    acpitables[FADT].size = sizeof(struct acpi_table_fadt);
+    dom->acpi_modules[0].length += ROUNDUP(acpitables[FADT].size, 3);
+
+    acpitables[DSDT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length;
+    acpitables[DSDT].size = dsdt_anycpu_arm_len;
+    dom->acpi_modules[0].length += ROUNDUP(acpitables[DSDT].size, 3);
+
+    assert(dom->acpi_modules[0].length <= GUEST_ACPI_SIZE);
+    dom->acpi_modules[0].data = libxl__zalloc(gc, dom->acpi_modules[0].length);
+
+    rc = 0;
+out:
+    return rc;
+}
+
 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 = 0;
+    struct acpitable acpitables[NUMS];
+
+    /* convenience aliases */
+    xc_domain_configuration_t *xc_config = &state->config;
 
     vers = libxl_get_version_info(CTX);
     if (vers == NULL) {
@@ -54,6 +150,8 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     dom->acpi_modules[0].length = 0;
     dom->acpi_modules[0].guest_addr_out = GUEST_ACPI_BASE;
 
+    rc = libxl__estimate_acpi_size(gc, info, dom, xc_config, acpitables);
+
 out:
     return rc;
 }
diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
index ed5cd2d..e199136 100644
--- a/xen/include/acpi/actbl1.h
+++ b/xen/include/acpi/actbl1.h
@@ -786,6 +786,8 @@ struct acpi_madt_generic_interrupt {
 	u8 reserved2[3];
 };
 
+#define ACPI_MADT_GICC_SIZE_v5          76
+
 /* Masks for Flags field above */
 
 /* ACPI_MADT_ENABLED                    (1)      Processor is usable if set */
-- 
2.0.4



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

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

* [PATCH v6 05/16] libxl/arm: Construct ACPI RSDP table
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (3 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 04/16] libxl/arm: Estimate the size of ACPI tables z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:14   ` Wei Liu
  2016-09-22 12:52 ` [PATCH v6 06/16] libxl/arm: Construct ACPI XSDT table z00226004
                   ` (12 subsequent siblings)
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 tools/libxl/libxl_arm_acpi.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 1dbd7e5..421128a 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -34,6 +34,10 @@ extern const unsigned char dsdt_anycpu_arm[];
 _hidden
 extern const int dsdt_anycpu_arm_len;
 
+#define ACPI_OEM_ID "Xen"
+#define ACPI_OEM_TABLE_ID "ARM"
+#define ACPI_ASL_COMPILER_ID "XL"
+
 enum {
     RSDP,
     XSDT,
@@ -126,6 +130,37 @@ out:
     return rc;
 }
 
+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 = (void *)dom->acpi_modules[0].data + offset;
+
+    memcpy(rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
+    memcpy(rsdp->oem_id, ACPI_OEM_ID, 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, extended_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)
@@ -151,6 +186,10 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     dom->acpi_modules[0].guest_addr_out = GUEST_ACPI_BASE;
 
     rc = libxl__estimate_acpi_size(gc, info, dom, xc_config, acpitables);
+    if (rc)
+        goto out;
+
+    make_acpi_rsdp(gc, dom, acpitables);
 
 out:
     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] 56+ messages in thread

* [PATCH v6 06/16] libxl/arm: Construct ACPI XSDT table
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (4 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 05/16] libxl/arm: Construct ACPI RSDP table z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:14   ` Wei Liu
  2016-09-22 12:52 ` [PATCH v6 07/16] libxl/arm: Construct ACPI GTDT table z00226004
                   ` (11 subsequent siblings)
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 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 421128a..eb62096 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -161,6 +161,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,
+                             size_t len, uint8_t rev)
+{
+    memcpy(h->signature, sig, 4);
+    h->length = len;
+    h->revision = rev;
+    memcpy(h->oem_id, ACPI_OEM_ID, sizeof(h->oem_id));
+    memcpy(h->oem_table_id, ACPI_OEM_TABLE_ID, sizeof(h->oem_table_id));
+    h->oem_revision = 0;
+    memcpy(h->asl_compiler_id, ACPI_ASL_COMPILER_ID,
+           sizeof(h->asl_compiler_id));
+    h->asl_compiler_revision = 0;
+    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 = (void *)dom->acpi_modules[0].data + 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)
@@ -190,6 +219,7 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
         goto out;
 
     make_acpi_rsdp(gc, dom, acpitables);
+    make_acpi_xsdt(gc, dom, acpitables);
 
 out:
     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] 56+ messages in thread

* [PATCH v6 07/16] libxl/arm: Construct ACPI GTDT table
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (5 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 06/16] libxl/arm: Construct ACPI XSDT table z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:14   ` Wei Liu
  2016-09-22 12:52 ` [PATCH v6 08/16] libxl/arm: Factor MPIDR computing codes out as a helper z00226004
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 tools/libxl/libxl_arm_acpi.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index eb62096..2488c0f 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -25,10 +25,24 @@ 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>
 
+#ifndef BITS_PER_LONG
+#ifdef _LP64
+#define BITS_PER_LONG 64
+#else
+#define BITS_PER_LONG 32
+#endif
+#endif
+#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
@@ -190,6 +204,29 @@ 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 = (void *)dom->acpi_modules[0].data + 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);
+
+    gtdt->counter_block_addresss = ~((uint64_t)0);
+    gtdt->counter_read_block_address = ~((uint64_t)0);
+
+    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)
@@ -220,6 +257,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);
 
 out:
     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] 56+ messages in thread

* [PATCH v6 08/16] libxl/arm: Factor MPIDR computing codes out as a helper
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (6 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 07/16] libxl/arm: Construct ACPI GTDT table z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:14   ` Wei Liu
  2016-09-22 12:52 ` [PATCH v6 09/16] libxl/arm: Construct ACPI MADT table z00226004
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 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 333c9a1..2a4577c 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] 56+ messages in thread

* [PATCH v6 09/16] libxl/arm: Construct ACPI MADT table
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (7 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 08/16] libxl/arm: Factor MPIDR computing codes out as a helper z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:14   ` Wei Liu
  2016-09-22 12:52 ` [PATCH v6 10/16] libxl/arm: Construct ACPI FADT table z00226004
                   ` (8 subsequent siblings)
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 tools/libxl/libxl_arm_acpi.c | 84 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 2488c0f..8716a81 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -227,6 +227,89 @@ 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)
+{
+    int 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 = ACPI_MADT_GICC_SIZE_v5;
+        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 = table + ACPI_MADT_GICC_SIZE_v5;
+    }
+}
+
+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;
+    void *table = dom->acpi_modules[0].data + offset;
+    struct acpi_table_madt *madt = table;
+    int rc = 0;
+
+    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 += ACPI_MADT_GICC_SIZE_v5 * 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 += ACPI_MADT_GICC_SIZE_v5 * 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");
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    make_acpi_header(&madt->header, "APIC", acpitables[MADT].size, 3);
+    calculate_checksum(madt, offsetof(struct acpi_table_header, checksum),
+                       acpitables[MADT].size);
+
+out:
+    return rc;
+}
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)
@@ -258,6 +341,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);
+    rc = make_acpi_madt(gc, dom, info->max_vcpus, xc_config, acpitables);
 
 out:
     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] 56+ messages in thread

* [PATCH v6 10/16] libxl/arm: Construct ACPI FADT table
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (8 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 09/16] libxl/arm: Construct ACPI MADT table z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:14   ` Wei Liu
  2016-09-22 12:52 ` [PATCH v6 11/16] libxl/arm: Construct ACPI DSDT table z00226004
                   ` (7 subsequent siblings)
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 tools/libxl/libxl_arm_acpi.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 8716a81..9f26d0f 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -310,6 +310,25 @@ out:
     return rc;
 }
 
+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 = (void *)dom->acpi_modules[0].data + 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)
@@ -342,6 +361,10 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     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)
+        goto out;
+
+    make_acpi_fadt(gc, dom, acpitables);
 
 out:
     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] 56+ messages in thread

* [PATCH v6 11/16] libxl/arm: Construct ACPI DSDT table
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (9 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 10/16] libxl/arm: Construct ACPI FADT table z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:15   ` Wei Liu
  2016-09-22 12:52 ` [PATCH v6 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function z00226004
                   ` (6 subsequent siblings)
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 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 9f26d0f..9c4005f 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -329,6 +329,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->acpi_modules[0].data + 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)
@@ -365,6 +374,7 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
         goto out;
 
     make_acpi_fadt(gc, dom, acpitables);
+    make_acpi_dsdt(gc, dom, acpitables);
 
 out:
     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] 56+ messages in thread

* [PATCH v6 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (10 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 11/16] libxl/arm: Construct ACPI DSDT table z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:15   ` Wei Liu
  2016-09-22 12:52 ` [PATCH v6 13/16] libxl/arm: Add ACPI module z00226004
                   ` (5 subsequent siblings)
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 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 2a4577c..f7f2c60 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -905,11 +905,11 @@ out:
     return rc;
 }
 
-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);
@@ -972,7 +972,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] 56+ messages in thread

* [PATCH v6 13/16] libxl/arm: Add ACPI module
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (11 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:15   ` Wei Liu
  2016-09-22 12:52 ` [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI z00226004
                   ` (4 subsequent siblings)
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 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 f7f2c60..6f0bc70 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->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;
 
@@ -975,6 +994,11 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
         finalise_one_node(gc, fdt, "/memory", bankbase[i], size);
     }
 
+    if (dom->acpi_modules[0].data) {
+        finalise_one_node(gc, fdt, "/chosen/module", GUEST_ACPI_BASE,
+                          dom->acpi_modules[0].length);
+    }
+
     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] 56+ messages in thread

* [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (12 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 13/16] libxl/arm: Add ACPI module z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:44   ` Julien Grall
                     ` (2 more replies)
  2016-09-22 12:52 ` [PATCH v6 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ z00226004
                   ` (3 subsequent siblings)
  17 siblings, 3 replies; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, Andrew Cooper, ian.jackson,
	peter.huangpeng, julien.grall, shannon.zhao, Jan Beulich,
	boris.ostrovsky

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

Add macros for HVM_PARAM_CALLBACK_TYPE_PPI operation values and update
them in evtchn_fixup().

Also use HVM_PARAM_CALLBACK_IRQ_TYPE_MASK in hvm_set_callback_via().

Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/domain_build.c     | 9 ++++++---
 xen/arch/x86/hvm/irq.c          | 2 +-
 xen/include/public/hvm/params.h | 3 +++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 35ab08d..0cf7dc3 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2016,9 +2016,12 @@ static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
            d->arch.evtchn_irq);
 
     /* Set the value of domain param HVM_PARAM_CALLBACK_IRQ */
-    val = (u64)HVM_PARAM_CALLBACK_TYPE_PPI << 56;
-    val |= (2 << 8); /* Active-low level-sensitive  */
-    val |= d->arch.evtchn_irq & 0xff;
+    val = MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI,
+                    HVM_PARAM_CALLBACK_IRQ_TYPE_MASK);
+    /* Active-low level-sensitive  */
+    val |= MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_LOW_LEVEL,
+                     HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_MASK);
+    val |= d->arch.evtchn_irq;
     d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = val;
 
     /*
diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c
index 5323d7c..e597114 100644
--- a/xen/arch/x86/hvm/irq.c
+++ b/xen/arch/x86/hvm/irq.c
@@ -325,7 +325,7 @@ void hvm_set_callback_via(struct domain *d, uint64_t via)
     unsigned int gsi=0, pdev=0, pintx=0;
     uint8_t via_type;
 
-    via_type = (uint8_t)(via >> 56) + 1;
+    via_type = (uint8_t)MASK_EXTR(via, HVM_PARAM_CALLBACK_IRQ_TYPE_MASK) + 1;
     if ( ((via_type == HVMIRQ_callback_gsi) && (via == 0)) ||
          (via_type > HVMIRQ_callback_vector) )
         via_type = HVMIRQ_callback_none;
diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
index f7338a3..5c50e2e 100644
--- a/xen/include/public/hvm/params.h
+++ b/xen/include/public/hvm/params.h
@@ -30,6 +30,7 @@
  */
 
 #define HVM_PARAM_CALLBACK_IRQ 0
+#define HVM_PARAM_CALLBACK_IRQ_TYPE_MASK 0xFF00000000000000
 /*
  * How should CPU0 event-channel notifications be delivered?
  *
@@ -66,6 +67,8 @@
  * This is only used by ARM/ARM64 and masking/eoi the interrupt associated to
  * the notification is handled by the interrupt controller.
  */
+#define HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_MASK      0xFF00
+#define HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_LOW_LEVEL 2
 #endif
 
 /*
-- 
2.0.4



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

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

* [PATCH v6 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (13 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:16   ` Wei Liu
  2016-09-22 12:52 ` [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem z00226004
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: 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>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 tools/libxl/libxl_arm.c      | 14 ++++++++++++++
 tools/libxl/libxl_internal.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 6f0bc70..913f401 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -900,8 +900,22 @@ 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 = MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI,
+                    HVM_PARAM_CALLBACK_IRQ_TYPE_MASK);
+    /* Active-low level-sensitive  */
+    val |= MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_LOW_LEVEL,
+                     HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_MASK);
+    val |= GUEST_EVTCHN_PPI;
+    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) goto out;
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index f1ba473..cb6d9e0 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -128,6 +128,9 @@
 #define ROUNDUP(_val, _order)                                           \
     (((unsigned long)(_val)+(1UL<<(_order))-1) & ~((1UL<<(_order))-1))
 
+#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m)))
+#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m))
+
 #define min(X, Y) ({                             \
             const typeof (X) _x = (X);           \
             const typeof (Y) _y = (Y);           \
-- 
2.0.4



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

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

* [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (14 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ z00226004
@ 2016-09-22 12:52 ` z00226004
  2016-09-22 14:10   ` Wei Liu
  2016-09-22 13:27 ` [PATCH v6 00/16] Xen ARM DomU ACPI support Julien Grall
  2016-09-22 14:27 ` Julien Grall
  17 siblings, 1 reply; 56+ messages in thread
From: z00226004 @ 2016-09-22 12:52 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	julien.grall, shannon.zhao, boris.ostrovsky

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

Here it adds the ACPI tables size to set the target maxmem to avoid
providing less available memory for guest.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arch.h        |  4 ++++
 tools/libxl/libxl_arm.c         | 16 ++++++++++++++++
 tools/libxl/libxl_arm.h         |  4 ++++
 tools/libxl/libxl_arm_acpi.c    | 20 ++++++++++++++++++++
 tools/libxl/libxl_arm_no_acpi.c |  6 ++++++
 tools/libxl/libxl_dom.c         |  9 ++++++++-
 tools/libxl/libxl_internal.h    |  2 ++
 tools/libxl/libxl_x86.c         |  6 ++++++
 8 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
index 8cb9ba7..a066bbd 100644
--- a/tools/libxl/libxl_arch.h
+++ b/tools/libxl/libxl_arch.h
@@ -66,6 +66,10 @@ _hidden
 void libxl__arch_domain_build_info_acpi_setdefault(
                                         libxl_domain_build_info *b_info);
 
+_hidden
+int libxl__arch_memory_constant(libxl__gc *gc, libxl_domain_build_info *info,
+                                libxl__domain_build_state *state);
+
 #if defined(__i386__) || defined(__x86_64__)
 
 #define LAPIC_BASE_ADDRESS  0xfee00000
diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 913f401..932e674 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -106,6 +106,22 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
     return 0;
 }
 
+int libxl__arch_memory_constant(libxl__gc *gc, libxl_domain_build_info *info,
+                                libxl__domain_build_state *state)
+{
+    int size;
+
+    if (libxl_defbool_val(info->acpi)) {
+        size = libxl__get_acpi_size(gc, info, state);
+        if (size < 0)
+            return ERROR_FAIL;
+
+        return DIV_ROUNDUP(size, 1024);
+    }
+
+    return 0;
+}
+
 static struct arch_info {
     const char *guest_type;
     const char *timer_compat;
diff --git a/tools/libxl/libxl_arm.h b/tools/libxl/libxl_arm.h
index a91ff93..37b1f15 100644
--- a/tools/libxl/libxl_arm.h
+++ b/tools/libxl/libxl_arm.h
@@ -24,6 +24,10 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom);
 
+_hidden
+int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
+                         libxl__domain_build_state *state);
+
 static inline uint64_t libxl__compute_mpdir(unsigned int cpuid)
 {
     /*
diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 9c4005f..0d4092d 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -94,6 +94,26 @@ static int libxl__estimate_madt_size(libxl__gc *gc,
     return rc;
 }
 
+int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
+                         libxl__domain_build_state *state)
+{
+    int size;
+
+    size = libxl__estimate_madt_size(gc, info, &state->config);
+    if (size < 0)
+        goto out;
+
+    size = ROUNDUP(size, 3) +
+           ROUNDUP(sizeof(struct acpi_table_rsdp), 3) +
+           ROUNDUP(sizeof(struct acpi_table_xsdt), 3) +
+           ROUNDUP(sizeof(struct acpi_table_gtdt), 3) +
+           ROUNDUP(sizeof(struct acpi_table_fadt), 3) +
+           ROUNDUP(sizeof(dsdt_anycpu_arm_len), 3);
+
+out:
+    return size;
+}
+
 static int libxl__estimate_acpi_size(libxl__gc *gc,
                                      libxl_domain_build_info *info,
                                      struct xc_dom_image *dom,
diff --git a/tools/libxl/libxl_arm_no_acpi.c b/tools/libxl/libxl_arm_no_acpi.c
index e7f7411..5eeb825 100644
--- a/tools/libxl/libxl_arm_no_acpi.c
+++ b/tools/libxl/libxl_arm_no_acpi.c
@@ -25,6 +25,12 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     return ERROR_FAIL;
 }
 
+int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
+                         libxl__domain_build_state *state)
+{
+    return ERROR_FAIL;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index 2924629..118beab 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
         }
     }
 
+
+    rc = libxl__arch_memory_constant(gc, info, state);
+    if (rc < 0) {
+        LOGE(ERROR, "Couldn't get arch constant memory size");
+        return ERROR_FAIL;
+    }
+
     if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
-        LIBXL_MAXMEM_CONSTANT) < 0) {
+        LIBXL_MAXMEM_CONSTANT + rc) < 0) {
         LOGE(ERROR, "Couldn't set max memory");
         return ERROR_FAIL;
     }
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index cb6d9e0..8366fee 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -128,6 +128,8 @@
 #define ROUNDUP(_val, _order)                                           \
     (((unsigned long)(_val)+(1UL<<(_order))-1) & ~((1UL<<(_order))-1))
 
+#define DIV_ROUNDUP(n, d) (((n) + (d) - 1) / (d))
+
 #define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m)))
 #define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m))
 
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index f69f3c2..0a86040 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -358,6 +358,12 @@ out:
     return ret;
 }
 
+int libxl__arch_memory_constant(libxl__gc *gc, libxl_domain_build_info *info,
+                                libxl__domain_build_state *state)
+{
+    return 0;
+}
+
 int libxl__arch_domain_init_hw_description(libxl__gc *gc,
                                            libxl_domain_build_info *info,
                                            libxl__domain_build_state *state,
-- 
2.0.4



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

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

* Re: [PATCH v6 00/16] Xen ARM DomU ACPI support
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (15 preceding siblings ...)
  2016-09-22 12:52 ` [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem z00226004
@ 2016-09-22 13:27 ` Julien Grall
  2016-09-22 13:32   ` Shannon Zhao
  2016-09-22 14:27 ` Julien Grall
  17 siblings, 1 reply; 56+ messages in thread
From: Julien Grall @ 2016-09-22 13:27 UTC (permalink / raw)
  To: z00226004, xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	shannon.zhao, boris.ostrovsky

Hi Shannon,

I am not sure why, but your name on this patch series become: z00226004.
You may want to give a look to your mail sender.

Cheers,

-- 
Julien Grall

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

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

* Re: [PATCH v6 00/16] Xen ARM DomU ACPI support
  2016-09-22 13:27 ` [PATCH v6 00/16] Xen ARM DomU ACPI support Julien Grall
@ 2016-09-22 13:32   ` Shannon Zhao
  2016-09-22 13:37     ` Julien Grall
  0 siblings, 1 reply; 56+ messages in thread
From: Shannon Zhao @ 2016-09-22 13:32 UTC (permalink / raw)
  To: Julien Grall, xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	shannon.zhao, boris.ostrovsky



On 2016/9/22 21:27, Julien Grall wrote:
> Hi Shannon,
> 
> I am not sure why, but your name on this patch series become: z00226004.
> You may want to give a look to your mail sender.
> 
Oops, I just modified the user.name before and forgot to change back. I
will resend soon.

Thanks,
-- 
Shannon


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

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

* Re: [PATCH v6 00/16] Xen ARM DomU ACPI support
  2016-09-22 13:32   ` Shannon Zhao
@ 2016-09-22 13:37     ` Julien Grall
  2016-09-22 13:38       ` Shannon Zhao
  0 siblings, 1 reply; 56+ messages in thread
From: Julien Grall @ 2016-09-22 13:37 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	shannon.zhao, boris.ostrovsky



On 22/09/16 14:32, Shannon Zhao wrote:
>
>
> On 2016/9/22 21:27, Julien Grall wrote:
>> Hi Shannon,
>>
>> I am not sure why, but your name on this patch series become: z00226004.
>> You may want to give a look to your mail sender.
>>
> Oops, I just modified the user.name before and forgot to change back. I
> will resend soon.

No need to resend just for that. The "From:" field is correct so we 
could apply your series if everything is ok. :)

Cheers,

-- 
Julien Grall

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

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

* Re: [PATCH v6 00/16] Xen ARM DomU ACPI support
  2016-09-22 13:37     ` Julien Grall
@ 2016-09-22 13:38       ` Shannon Zhao
  0 siblings, 0 replies; 56+ messages in thread
From: Shannon Zhao @ 2016-09-22 13:38 UTC (permalink / raw)
  To: Julien Grall, xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	shannon.zhao, boris.ostrovsky



On 2016/9/22 21:37, Julien Grall wrote:
> 
> 
> On 22/09/16 14:32, Shannon Zhao wrote:
>>
>>
>> On 2016/9/22 21:27, Julien Grall wrote:
>>> Hi Shannon,
>>>
>>> I am not sure why, but your name on this patch series become: z00226004.
>>> You may want to give a look to your mail sender.
>>>
>> Oops, I just modified the user.name before and forgot to change back. I
>> will resend soon.
> 
> No need to resend just for that. The "From:" field is correct so we
> could apply your series if everything is ok. :)
> 
Ok, I just realized this. Thanks :)

-- 
Shannon


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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-22 12:52 ` [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem z00226004
@ 2016-09-22 14:10   ` Wei Liu
  2016-09-22 14:32     ` Wei Liu
  2016-09-26 21:54     ` Shannon Zhao
  0 siblings, 2 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:10 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:33PM +0800, z00226004 wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Here it adds the ACPI tables size to set the target maxmem to avoid
> providing less available memory for guest.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  tools/libxl/libxl_arch.h        |  4 ++++
>  tools/libxl/libxl_arm.c         | 16 ++++++++++++++++
>  tools/libxl/libxl_arm.h         |  4 ++++
>  tools/libxl/libxl_arm_acpi.c    | 20 ++++++++++++++++++++
>  tools/libxl/libxl_arm_no_acpi.c |  6 ++++++
>  tools/libxl/libxl_dom.c         |  9 ++++++++-
>  tools/libxl/libxl_internal.h    |  2 ++
>  tools/libxl/libxl_x86.c         |  6 ++++++
>  8 files changed, 66 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
> index 8cb9ba7..a066bbd 100644
> --- a/tools/libxl/libxl_arch.h
> +++ b/tools/libxl/libxl_arch.h
> @@ -66,6 +66,10 @@ _hidden
>  void libxl__arch_domain_build_info_acpi_setdefault(
>                                          libxl_domain_build_info *b_info);
>  
> +_hidden
> +int libxl__arch_memory_constant(libxl__gc *gc, libxl_domain_build_info *info,
> +                                libxl__domain_build_state *state);

I think the prototype should change a bit.

_hidden
int libxl__arch_extra_memory(libxl__gc, *gc,
                             const libxl_domain_build_info *info,
                             const libxl__domain_build_state *state,
                             uint64_t *out);

The important bit is to not overload the return value to carry the
output value.

> +
>  #if defined(__i386__) || defined(__x86_64__)
>  
>  #define LAPIC_BASE_ADDRESS  0xfee00000
> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> index 913f401..932e674 100644
> --- a/tools/libxl/libxl_arm.c
> +++ b/tools/libxl/libxl_arm.c
> @@ -106,6 +106,22 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
>      return 0;
>  }
>  
> +int libxl__arch_memory_constant(libxl__gc *gc, libxl_domain_build_info *info,
> +                                libxl__domain_build_state *state)
> +{
> +    int size;
> +
> +    if (libxl_defbool_val(info->acpi)) {
> +        size = libxl__get_acpi_size(gc, info, state);
> +        if (size < 0)
> +            return ERROR_FAIL;
> +
> +        return DIV_ROUNDUP(size, 1024);
> +    }
> +
> +    return 0;
> +}
> +
>  static struct arch_info {
>      const char *guest_type;
>      const char *timer_compat;
> diff --git a/tools/libxl/libxl_arm.h b/tools/libxl/libxl_arm.h
> index a91ff93..37b1f15 100644
> --- a/tools/libxl/libxl_arm.h
> +++ b/tools/libxl/libxl_arm.h
> @@ -24,6 +24,10 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>                          libxl__domain_build_state *state,
>                          struct xc_dom_image *dom);
>  
> +_hidden
> +int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
> +                         libxl__domain_build_state *state);
> +

Same here, don't overload the return value for output.

>  static inline uint64_t libxl__compute_mpdir(unsigned int cpuid)
>  {
>      /*
> diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
> index 9c4005f..0d4092d 100644
> --- a/tools/libxl/libxl_arm_acpi.c
> +++ b/tools/libxl/libxl_arm_acpi.c
> @@ -94,6 +94,26 @@ static int libxl__estimate_madt_size(libxl__gc *gc,
>      return rc;
>  }
>  
> +int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
> +                         libxl__domain_build_state *state)
> +{
> +    int size;
> +
> +    size = libxl__estimate_madt_size(gc, info, &state->config);
> +    if (size < 0)
> +        goto out;
> +
> +    size = ROUNDUP(size, 3) +
> +           ROUNDUP(sizeof(struct acpi_table_rsdp), 3) +
> +           ROUNDUP(sizeof(struct acpi_table_xsdt), 3) +
> +           ROUNDUP(sizeof(struct acpi_table_gtdt), 3) +
> +           ROUNDUP(sizeof(struct acpi_table_fadt), 3) +
> +           ROUNDUP(sizeof(dsdt_anycpu_arm_len), 3);
> +
> +out:
> +    return size;
> +}
> +
>  static int libxl__estimate_acpi_size(libxl__gc *gc,
>                                       libxl_domain_build_info *info,
>                                       struct xc_dom_image *dom,
> diff --git a/tools/libxl/libxl_arm_no_acpi.c b/tools/libxl/libxl_arm_no_acpi.c
> index e7f7411..5eeb825 100644
> --- a/tools/libxl/libxl_arm_no_acpi.c
> +++ b/tools/libxl/libxl_arm_no_acpi.c
> @@ -25,6 +25,12 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>      return ERROR_FAIL;
>  }
>  
> +int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
> +                         libxl__domain_build_state *state)
> +{
> +    return ERROR_FAIL;
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> index 2924629..118beab 100644
> --- a/tools/libxl/libxl_dom.c
> +++ b/tools/libxl/libxl_dom.c
> @@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
>          }
>      }
>  
> +
> +    rc = libxl__arch_memory_constant(gc, info, state);
> +    if (rc < 0) {
> +        LOGE(ERROR, "Couldn't get arch constant memory size");
> +        return ERROR_FAIL;
> +    }
> +
>      if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
> -        LIBXL_MAXMEM_CONSTANT) < 0) {
> +        LIBXL_MAXMEM_CONSTANT + rc) < 0) {

I think this LIBXL_MAXMEM_CONSTANT should be pushed to your helper
function, too.

So that, we can have all LIBXL_MAXMEM_CONSTANT removed in libxl
functions (see libxl.c and libxl_dom.c)


>          LOGE(ERROR, "Couldn't set max memory");
>          return ERROR_FAIL;
>      }
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index cb6d9e0..8366fee 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -128,6 +128,8 @@
>  #define ROUNDUP(_val, _order)                                           \
>      (((unsigned long)(_val)+(1UL<<(_order))-1) & ~((1UL<<(_order))-1))
>  
> +#define DIV_ROUNDUP(n, d) (((n) + (d) - 1) / (d))
> +
>  #define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m)))
>  #define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m))
>  
> diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
> index f69f3c2..0a86040 100644
> --- a/tools/libxl/libxl_x86.c
> +++ b/tools/libxl/libxl_x86.c
> @@ -358,6 +358,12 @@ out:
>      return ret;
>  }
>  
> +int libxl__arch_memory_constant(libxl__gc *gc, libxl_domain_build_info *info,
> +                                libxl__domain_build_state *state)
> +{
> +    return 0;
> +}
> +
>  int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>                                             libxl_domain_build_info *info,
>                                             libxl__domain_build_state *state,
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v6 02/16] libxl/arm: prepare for constructing ACPI tables
  2016-09-22 12:52 ` [PATCH v6 02/16] libxl/arm: prepare for constructing ACPI tables z00226004
@ 2016-09-22 14:13   ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:13 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:19PM +0800, z00226004 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. And the generation codes
> are only built for 64-bit toolstack.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Acked-by: Julien Grall <julien.grall@arm.com>

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

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

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

* Re: [PATCH v6 05/16] libxl/arm: Construct ACPI RSDP table
  2016-09-22 12:52 ` [PATCH v6 05/16] libxl/arm: Construct ACPI RSDP table z00226004
@ 2016-09-22 14:14   ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:14 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:22PM +0800, z00226004 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>
> Acked-by: Julien Grall <julien.grall@arm.com>

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

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

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

* Re: [PATCH v6 06/16] libxl/arm: Construct ACPI XSDT table
  2016-09-22 12:52 ` [PATCH v6 06/16] libxl/arm: Construct ACPI XSDT table z00226004
@ 2016-09-22 14:14   ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:14 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:23PM +0800, z00226004 wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Acked-by: Julien Grall <julien.grall@arm.com>

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

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

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

* Re: [PATCH v6 07/16] libxl/arm: Construct ACPI GTDT table
  2016-09-22 12:52 ` [PATCH v6 07/16] libxl/arm: Construct ACPI GTDT table z00226004
@ 2016-09-22 14:14   ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:14 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:24PM +0800, z00226004 wrote:
> 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>
> Acked-by: Julien Grall <julien.grall@arm.com>

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

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

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

* Re: [PATCH v6 08/16] libxl/arm: Factor MPIDR computing codes out as a helper
  2016-09-22 12:52 ` [PATCH v6 08/16] libxl/arm: Factor MPIDR computing codes out as a helper z00226004
@ 2016-09-22 14:14   ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:14 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:25PM +0800, z00226004 wrote:
> 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>
> Acked-by: Julien Grall <julien.grall@arm.com>

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

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

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

* Re: [PATCH v6 09/16] libxl/arm: Construct ACPI MADT table
  2016-09-22 12:52 ` [PATCH v6 09/16] libxl/arm: Construct ACPI MADT table z00226004
@ 2016-09-22 14:14   ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:14 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:26PM +0800, z00226004 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>
> Acked-by: Julien Grall <julien.grall@arm.com>

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

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

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

* Re: [PATCH v6 10/16] libxl/arm: Construct ACPI FADT table
  2016-09-22 12:52 ` [PATCH v6 10/16] libxl/arm: Construct ACPI FADT table z00226004
@ 2016-09-22 14:14   ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:14 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:27PM +0800, z00226004 wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Acked-by: Julien Grall <julien.grall@arm.com>

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

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

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

* Re: [PATCH v6 11/16] libxl/arm: Construct ACPI DSDT table
  2016-09-22 12:52 ` [PATCH v6 11/16] libxl/arm: Construct ACPI DSDT table z00226004
@ 2016-09-22 14:15   ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:15 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:28PM +0800, z00226004 wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Copy the static DSDT table into ACPI blob.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Acked-by: Julien Grall <julien.grall@arm.com>

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

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

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

* Re: [PATCH v6 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function
  2016-09-22 12:52 ` [PATCH v6 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function z00226004
@ 2016-09-22 14:15   ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:15 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:29PM +0800, z00226004 wrote:
> 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>
> Acked-by: Julien Grall <julien.grall@arm.com>

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

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

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

* Re: [PATCH v6 13/16] libxl/arm: Add ACPI module
  2016-09-22 12:52 ` [PATCH v6 13/16] libxl/arm: Add ACPI module z00226004
@ 2016-09-22 14:15   ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:15 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:30PM +0800, z00226004 wrote:
> 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>
> Acked-by: Julien Grall <julien.grall@arm.com>

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

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

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

* Re: [PATCH v6 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ
  2016-09-22 12:52 ` [PATCH v6 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ z00226004
@ 2016-09-22 14:16   ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:16 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:32PM +0800, z00226004 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>
> Acked-by: Julien Grall <julien.grall@arm.com>

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

> ---
>  tools/libxl/libxl_arm.c      | 14 ++++++++++++++
>  tools/libxl/libxl_internal.h |  3 +++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> index 6f0bc70..913f401 100644
> --- a/tools/libxl/libxl_arm.c
> +++ b/tools/libxl/libxl_arm.c
> @@ -900,8 +900,22 @@ 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 = MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI,
> +                    HVM_PARAM_CALLBACK_IRQ_TYPE_MASK);
> +    /* Active-low level-sensitive  */
> +    val |= MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_LOW_LEVEL,
> +                     HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_MASK);
> +    val |= GUEST_EVTCHN_PPI;
> +    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) goto out;
>  
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index f1ba473..cb6d9e0 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -128,6 +128,9 @@
>  #define ROUNDUP(_val, _order)                                           \
>      (((unsigned long)(_val)+(1UL<<(_order))-1) & ~((1UL<<(_order))-1))
>  
> +#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m)))
> +#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m))
> +

Though I would have moved this to libxl_arm.c because the only user is
there, or at least give them less cryptic names.

>  #define min(X, Y) ({                             \
>              const typeof (X) _x = (X);           \
>              const typeof (Y) _y = (Y);           \
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v6 04/16] libxl/arm: Estimate the size of ACPI tables
  2016-09-22 12:52 ` [PATCH v6 04/16] libxl/arm: Estimate the size of ACPI tables z00226004
@ 2016-09-22 14:21   ` Wei Liu
  2016-09-27 15:20   ` [PATCH v7 " Shannon Zhao
  1 sibling, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:21 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 08:52:21PM +0800, z00226004 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>
> ---
>  tools/libxl/libxl_arm_acpi.c | 98 ++++++++++++++++++++++++++++++++++++++++++++
>  xen/include/acpi/actbl1.h    |  2 +
>  2 files changed, 100 insertions(+)
> 
> diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
> index 0851411..1dbd7e5 100644
> --- a/tools/libxl/libxl_arm_acpi.c
> +++ b/tools/libxl/libxl_arm_acpi.c
> @@ -34,12 +34,108 @@ extern const unsigned char dsdt_anycpu_arm[];
>  _hidden
>  extern const int dsdt_anycpu_arm_len;
>  
> +enum {
> +    RSDP,
> +    XSDT,
> +    GTDT,
> +    MADT,
> +    FADT,
> +    DSDT,
> +    NUMS,

NUMS is not a very good name. Maybe MAX_TABLE_NUMS or something?

Unfortunately I'm bad at naming things...

> +};
> +
> +struct acpitable {
> +    uint64_t addr;
> +    size_t size;
> +};
> +
> +static int libxl__estimate_madt_size(libxl__gc *gc,
> +                                     libxl_domain_build_info *info,
> +                                     xc_domain_configuration_t *xc_config)

Please try not to overload the return value for output. Use a dedicated
output parameter. And maybe constify things that you don't intend to
change in the function.

The rest looks reasonable to me.

Wei.

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

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

* Re: [PATCH v6 00/16] Xen ARM DomU ACPI support
  2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
                   ` (16 preceding siblings ...)
  2016-09-22 13:27 ` [PATCH v6 00/16] Xen ARM DomU ACPI support Julien Grall
@ 2016-09-22 14:27 ` Julien Grall
  17 siblings, 0 replies; 56+ messages in thread
From: Julien Grall @ 2016-09-22 14:27 UTC (permalink / raw)
  To: z00226004, xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng,
	shannon.zhao, boris.ostrovsky

Hi Shannon,

On 22/09/16 13:52, z00226004 wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> 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 linux master or:
> 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_v6

I have tested this series with the latest kernel and UEFI and everything 
works for me:

Tested-by: Julien Grall <julien.grall@arm.com>

Cheers,

-- 
Julien Grall

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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-22 14:10   ` Wei Liu
@ 2016-09-22 14:32     ` Wei Liu
  2016-09-26  7:08       ` Shannon Zhao
  2016-09-26 21:54     ` Shannon Zhao
  1 sibling, 1 reply; 56+ messages in thread
From: Wei Liu @ 2016-09-22 14:32 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, shannon.zhao, boris.ostrovsky

On Thu, Sep 22, 2016 at 03:10:46PM +0100, Wei Liu wrote:
> On Thu, Sep 22, 2016 at 08:52:33PM +0800, z00226004 wrote:
> > From: Shannon Zhao <shannon.zhao@linaro.org>
> > 
> > Here it adds the ACPI tables size to set the target maxmem to avoid
> > providing less available memory for guest.
> > 
> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > ---
> >  tools/libxl/libxl_arch.h        |  4 ++++
> >  tools/libxl/libxl_arm.c         | 16 ++++++++++++++++
> >  tools/libxl/libxl_arm.h         |  4 ++++
> >  tools/libxl/libxl_arm_acpi.c    | 20 ++++++++++++++++++++
> >  tools/libxl/libxl_arm_no_acpi.c |  6 ++++++
> >  tools/libxl/libxl_dom.c         |  9 ++++++++-
> >  tools/libxl/libxl_internal.h    |  2 ++
> >  tools/libxl/libxl_x86.c         |  6 ++++++
> >  8 files changed, 66 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
> > index 8cb9ba7..a066bbd 100644
> > --- a/tools/libxl/libxl_arch.h
> > +++ b/tools/libxl/libxl_arch.h
> > @@ -66,6 +66,10 @@ _hidden
> >  void libxl__arch_domain_build_info_acpi_setdefault(
> >                                          libxl_domain_build_info *b_info);
> >  
> > +_hidden
> > +int libxl__arch_memory_constant(libxl__gc *gc, libxl_domain_build_info *info,
> > +                                libxl__domain_build_state *state);
> 
> I think the prototype should change a bit.
> 
> _hidden
> int libxl__arch_extra_memory(libxl__gc, *gc,
>                              const libxl_domain_build_info *info,
>                              const libxl__domain_build_state *state,
>                              uint64_t *out);
> 
> The important bit is to not overload the return value to carry the
> output value.
> 
> > +
> >  #if defined(__i386__) || defined(__x86_64__)
> >  
> >  #define LAPIC_BASE_ADDRESS  0xfee00000
> > diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> > index 913f401..932e674 100644
> > --- a/tools/libxl/libxl_arm.c
> > +++ b/tools/libxl/libxl_arm.c
> > @@ -106,6 +106,22 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
> >      return 0;
> >  }
> >  
> > +int libxl__arch_memory_constant(libxl__gc *gc, libxl_domain_build_info *info,
> > +                                libxl__domain_build_state *state)
> > +{
> > +    int size;
> > +
> > +    if (libxl_defbool_val(info->acpi)) {
> > +        size = libxl__get_acpi_size(gc, info, state);
> > +        if (size < 0)
> > +            return ERROR_FAIL;
> > +
> > +        return DIV_ROUNDUP(size, 1024);
> > +    }
> > +
> > +    return 0;
> > +}
> > +
> >  static struct arch_info {
> >      const char *guest_type;
> >      const char *timer_compat;
> > diff --git a/tools/libxl/libxl_arm.h b/tools/libxl/libxl_arm.h
> > index a91ff93..37b1f15 100644
> > --- a/tools/libxl/libxl_arm.h
> > +++ b/tools/libxl/libxl_arm.h
> > @@ -24,6 +24,10 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
> >                          libxl__domain_build_state *state,
> >                          struct xc_dom_image *dom);
> >  
> > +_hidden
> > +int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
> > +                         libxl__domain_build_state *state);
> > +
> 
> Same here, don't overload the return value for output.
> 
> >  static inline uint64_t libxl__compute_mpdir(unsigned int cpuid)
> >  {
> >      /*
> > diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
> > index 9c4005f..0d4092d 100644
> > --- a/tools/libxl/libxl_arm_acpi.c
> > +++ b/tools/libxl/libxl_arm_acpi.c
> > @@ -94,6 +94,26 @@ static int libxl__estimate_madt_size(libxl__gc *gc,
> >      return rc;
> >  }
> >  
> > +int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
> > +                         libxl__domain_build_state *state)
> > +{
> > +    int size;
> > +
> > +    size = libxl__estimate_madt_size(gc, info, &state->config);
> > +    if (size < 0)
> > +        goto out;
> > +
> > +    size = ROUNDUP(size, 3) +
> > +           ROUNDUP(sizeof(struct acpi_table_rsdp), 3) +
> > +           ROUNDUP(sizeof(struct acpi_table_xsdt), 3) +
> > +           ROUNDUP(sizeof(struct acpi_table_gtdt), 3) +
> > +           ROUNDUP(sizeof(struct acpi_table_fadt), 3) +
> > +           ROUNDUP(sizeof(dsdt_anycpu_arm_len), 3);
> > +
> > +out:
> > +    return size;
> > +}
> > +
> >  static int libxl__estimate_acpi_size(libxl__gc *gc,
> >                                       libxl_domain_build_info *info,
> >                                       struct xc_dom_image *dom,
> > diff --git a/tools/libxl/libxl_arm_no_acpi.c b/tools/libxl/libxl_arm_no_acpi.c
> > index e7f7411..5eeb825 100644
> > --- a/tools/libxl/libxl_arm_no_acpi.c
> > +++ b/tools/libxl/libxl_arm_no_acpi.c
> > @@ -25,6 +25,12 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
> >      return ERROR_FAIL;
> >  }
> >  
> > +int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
> > +                         libxl__domain_build_state *state)
> > +{
> > +    return ERROR_FAIL;
> > +}
> > +
> >  /*
> >   * Local variables:
> >   * mode: C
> > diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> > index 2924629..118beab 100644
> > --- a/tools/libxl/libxl_dom.c
> > +++ b/tools/libxl/libxl_dom.c
> > @@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
> >          }
> >      }
> >  
> > +
> > +    rc = libxl__arch_memory_constant(gc, info, state);
> > +    if (rc < 0) {
> > +        LOGE(ERROR, "Couldn't get arch constant memory size");
> > +        return ERROR_FAIL;
> > +    }
> > +
> >      if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
> > -        LIBXL_MAXMEM_CONSTANT) < 0) {
> > +        LIBXL_MAXMEM_CONSTANT + rc) < 0) {
> 
> I think this LIBXL_MAXMEM_CONSTANT should be pushed to your helper
> function, too.
> 
> So that, we can have all LIBXL_MAXMEM_CONSTANT removed in libxl
> functions (see libxl.c and libxl_dom.c)
> 

FAOD:

I think all the issues I found so far in this patch and other patch(es)
are mostly cosmetic. I would be happy to accept incremental patches on
top of this series to make those changes.

No need to resend just yet unless there is something substantial that
you need to change.

Wei.

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

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

* Re: [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI
  2016-09-22 12:52 ` [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI z00226004
@ 2016-09-22 14:44   ` Julien Grall
  2016-09-22 15:00   ` Jan Beulich
  2016-09-27 15:27   ` [PATCH v7 " Shannon Zhao
  2 siblings, 0 replies; 56+ messages in thread
From: Julien Grall @ 2016-09-22 14:44 UTC (permalink / raw)
  To: z00226004, xen-devel
  Cc: sstabellini, wei.liu2, Andrew Cooper, ian.jackson,
	peter.huangpeng, shannon.zhao, Jan Beulich, boris.ostrovsky

Hi Shannon,

On 22/09/16 13:52, z00226004 wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> Add macros for HVM_PARAM_CALLBACK_TYPE_PPI operation values and update
> them in evtchn_fixup().
>
> Also use HVM_PARAM_CALLBACK_IRQ_TYPE_MASK in hvm_set_callback_via().
>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Providing Jan's comments have been addressed (I will let Jan confirm):

Acked-by: Julien Grall <julien.grall@arm.com>

Regards,

-- 
Julien Grall

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

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

* Re: [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI
  2016-09-22 12:52 ` [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI z00226004
  2016-09-22 14:44   ` Julien Grall
@ 2016-09-22 15:00   ` Jan Beulich
  2016-09-26 19:45     ` Shannon Zhao
  2016-09-27 15:27   ` [PATCH v7 " Shannon Zhao
  2 siblings, 1 reply; 56+ messages in thread
From: Jan Beulich @ 2016-09-22 15:00 UTC (permalink / raw)
  To: z00226004
  Cc: sstabellini, wei.liu2, Andrew Cooper, ian.jackson,
	peter.huangpeng, xen-devel, julien.grall, shannon.zhao,
	boris.ostrovsky

>>> On 22.09.16 at 14:52, <zhaoshenglong@huawei.com> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add macros for HVM_PARAM_CALLBACK_TYPE_PPI operation values and update
> them in evtchn_fixup().
> 
> Also use HVM_PARAM_CALLBACK_IRQ_TYPE_MASK in hvm_set_callback_via().
> 
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c     | 9 ++++++---
>  xen/arch/x86/hvm/irq.c          | 2 +-
>  xen/include/public/hvm/params.h | 3 +++
>  3 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 35ab08d..0cf7dc3 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -2016,9 +2016,12 @@ static void evtchn_fixup(struct domain *d, struct 
> kernel_info *kinfo)
>             d->arch.evtchn_irq);
>  
>      /* Set the value of domain param HVM_PARAM_CALLBACK_IRQ */
> -    val = (u64)HVM_PARAM_CALLBACK_TYPE_PPI << 56;
> -    val |= (2 << 8); /* Active-low level-sensitive  */
> -    val |= d->arch.evtchn_irq & 0xff;
> +    val = MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI,
> +                    HVM_PARAM_CALLBACK_IRQ_TYPE_MASK);
> +    /* Active-low level-sensitive  */
> +    val |= MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_LOW_LEVEL,
> +                     HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_MASK);
> +    val |= d->arch.evtchn_irq;
>      d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = val;
>  
>      /*
> diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c
> index 5323d7c..e597114 100644
> --- a/xen/arch/x86/hvm/irq.c
> +++ b/xen/arch/x86/hvm/irq.c
> @@ -325,7 +325,7 @@ void hvm_set_callback_via(struct domain *d, uint64_t via)
>      unsigned int gsi=0, pdev=0, pintx=0;
>      uint8_t via_type;
>  
> -    via_type = (uint8_t)(via >> 56) + 1;
> +    via_type = (uint8_t)MASK_EXTR(via, HVM_PARAM_CALLBACK_IRQ_TYPE_MASK) + 
> 1;
>      if ( ((via_type == HVMIRQ_callback_gsi) && (via == 0)) ||
>           (via_type > HVMIRQ_callback_vector) )
>          via_type = HVMIRQ_callback_none;
> diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
> index f7338a3..5c50e2e 100644
> --- a/xen/include/public/hvm/params.h
> +++ b/xen/include/public/hvm/params.h
> @@ -30,6 +30,7 @@
>   */
>  
>  #define HVM_PARAM_CALLBACK_IRQ 0
> +#define HVM_PARAM_CALLBACK_IRQ_TYPE_MASK 0xFF00000000000000

I'd be surprised if this goes through on all compiler versions: This
is a constant which needs at least a UL suffix (and if intended to
be usable on 32-bit even a ULL one, which would then get us into
complications with there not being supposed to be any non-C89
constructs in the public headers).

Jan


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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-22 14:32     ` Wei Liu
@ 2016-09-26  7:08       ` Shannon Zhao
  2016-09-26  9:05         ` Wei Liu
  0 siblings, 1 reply; 56+ messages in thread
From: Shannon Zhao @ 2016-09-26  7:08 UTC (permalink / raw)
  To: Wei Liu, z00226004
  Cc: sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, boris.ostrovsky



On 2016/9/22 22:32, Wei Liu wrote:
> FAOD:
>
> I think all the issues I found so far in this patch and other patch(es)
> are mostly cosmetic. I would be happy to accept incremental patches on
> top of this series to make those changes.
>
Ok, thanks for your review.

> No need to resend just yet unless there is something substantial that
> you need to change.
So far do I need to resend this series for comments?

Thanks,
-- 
Shannon

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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-26  7:08       ` Shannon Zhao
@ 2016-09-26  9:05         ` Wei Liu
  2016-09-26 18:30           ` Shannon Zhao
  0 siblings, 1 reply; 56+ messages in thread
From: Wei Liu @ 2016-09-26  9:05 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, Wei Liu, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, z00226004, boris.ostrovsky

On Mon, Sep 26, 2016 at 03:08:43PM +0800, Shannon Zhao wrote:
> 
> 
> On 2016/9/22 22:32, Wei Liu wrote:
> >FAOD:
> >
> >I think all the issues I found so far in this patch and other patch(es)
> >are mostly cosmetic. I would be happy to accept incremental patches on
> >top of this series to make those changes.
> >
> Ok, thanks for your review.
> 
> >No need to resend just yet unless there is something substantial that
> >you need to change.
> So far do I need to resend this series for comments?

No, you don't have to resend this series at the moment. Please address
Jan's comment on patch 14 first.

Wei.

> 
> Thanks,
> -- 
> Shannon

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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-26  9:05         ` Wei Liu
@ 2016-09-26 18:30           ` Shannon Zhao
  2016-09-27  9:30             ` Wei Liu
  0 siblings, 1 reply; 56+ messages in thread
From: Shannon Zhao @ 2016-09-26 18:30 UTC (permalink / raw)
  To: Wei Liu
  Cc: sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, z00226004, boris.ostrovsky



On 2016/9/26 2:05, Wei Liu wrote:
> On Mon, Sep 26, 2016 at 03:08:43PM +0800, Shannon Zhao wrote:
>> >
>> >
>> > On 2016/9/22 22:32, Wei Liu wrote:
>>> > >FAOD:
>>> > >
>>> > >I think all the issues I found so far in this patch and other patch(es)
>>> > >are mostly cosmetic. I would be happy to accept incremental patches on
>>> > >top of this series to make those changes.
>>> > >
>> > Ok, thanks for your review.
>> >
>>> > >No need to resend just yet unless there is something substantial that
>>> > >you need to change.
>> > So far do I need to resend this series for comments?
> No, you don't have to resend this series at the moment. Please address
> Jan's comment on patch 14 first.
Ok, I see. Do I need to resend the patch or add new one on top of that?

Thanks,
-- 
Shannon

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

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

* Re: [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI
  2016-09-22 15:00   ` Jan Beulich
@ 2016-09-26 19:45     ` Shannon Zhao
  2016-09-27  8:01       ` Jan Beulich
  0 siblings, 1 reply; 56+ messages in thread
From: Shannon Zhao @ 2016-09-26 19:45 UTC (permalink / raw)
  To: Jan Beulich, z00226004
  Cc: sstabellini, wei.liu2, Andrew Cooper, ian.jackson,
	peter.huangpeng, xen-devel, julien.grall, boris.ostrovsky



On 2016/9/22 8:00, Jan Beulich wrote:
>>>> On 22.09.16 at 14:52, <zhaoshenglong@huawei.com> wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Add macros for HVM_PARAM_CALLBACK_TYPE_PPI operation values and update
>> them in evtchn_fixup().
>>
>> Also use HVM_PARAM_CALLBACK_IRQ_TYPE_MASK in hvm_set_callback_via().
>>
>> Cc: Jan Beulich <jbeulich@suse.com>
>> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/domain_build.c     | 9 ++++++---
>>  xen/arch/x86/hvm/irq.c          | 2 +-
>>  xen/include/public/hvm/params.h | 3 +++
>>  3 files changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> index 35ab08d..0cf7dc3 100644
>> --- a/xen/arch/arm/domain_build.c
>> +++ b/xen/arch/arm/domain_build.c
>> @@ -2016,9 +2016,12 @@ static void evtchn_fixup(struct domain *d, struct
>> kernel_info *kinfo)
>>             d->arch.evtchn_irq);
>>
>>      /* Set the value of domain param HVM_PARAM_CALLBACK_IRQ */
>> -    val = (u64)HVM_PARAM_CALLBACK_TYPE_PPI << 56;
>> -    val |= (2 << 8); /* Active-low level-sensitive  */
>> -    val |= d->arch.evtchn_irq & 0xff;
>> +    val = MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI,
>> +                    HVM_PARAM_CALLBACK_IRQ_TYPE_MASK);
>> +    /* Active-low level-sensitive  */
>> +    val |= MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_LOW_LEVEL,
>> +                     HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_MASK);
>> +    val |= d->arch.evtchn_irq;
>>      d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = val;
>>
>>      /*
>> diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c
>> index 5323d7c..e597114 100644
>> --- a/xen/arch/x86/hvm/irq.c
>> +++ b/xen/arch/x86/hvm/irq.c
>> @@ -325,7 +325,7 @@ void hvm_set_callback_via(struct domain *d, uint64_t via)
>>      unsigned int gsi=0, pdev=0, pintx=0;
>>      uint8_t via_type;
>>
>> -    via_type = (uint8_t)(via >> 56) + 1;
>> +    via_type = (uint8_t)MASK_EXTR(via, HVM_PARAM_CALLBACK_IRQ_TYPE_MASK) +
>> 1;
>>      if ( ((via_type == HVMIRQ_callback_gsi) && (via == 0)) ||
>>           (via_type > HVMIRQ_callback_vector) )
>>          via_type = HVMIRQ_callback_none;
>> diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
>> index f7338a3..5c50e2e 100644
>> --- a/xen/include/public/hvm/params.h
>> +++ b/xen/include/public/hvm/params.h
>> @@ -30,6 +30,7 @@
>>   */
>>
>>  #define HVM_PARAM_CALLBACK_IRQ 0
>> +#define HVM_PARAM_CALLBACK_IRQ_TYPE_MASK 0xFF00000000000000
>
> I'd be surprised if this goes through on all compiler versions: This
> is a constant which needs at least a UL suffix (and if intended to
> be usable on 32-bit even a ULL one, which would then get us into
> complications with there not being supposed to be any non-C89
> constructs in the public headers).
>
Hi Jan,

Do I need to resend this patch or add new one to fix this on top of this 
one?

Thanks,
--
Shannon

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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-22 14:10   ` Wei Liu
  2016-09-22 14:32     ` Wei Liu
@ 2016-09-26 21:54     ` Shannon Zhao
  2016-09-27  9:41       ` Wei Liu
  1 sibling, 1 reply; 56+ messages in thread
From: Shannon Zhao @ 2016-09-26 21:54 UTC (permalink / raw)
  To: Wei Liu, z00226004
  Cc: sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, boris.ostrovsky



On 2016/9/22 7:10, Wei Liu wrote:
>> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
>> > index 2924629..118beab 100644
>> > --- a/tools/libxl/libxl_dom.c
>> > +++ b/tools/libxl/libxl_dom.c
>> > @@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
>> >          }
>> >      }
>> >
>> > +
>> > +    rc = libxl__arch_memory_constant(gc, info, state);
>> > +    if (rc < 0) {
>> > +        LOGE(ERROR, "Couldn't get arch constant memory size");
>> > +        return ERROR_FAIL;
>> > +    }
>> > +
>> >      if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
>> > -        LIBXL_MAXMEM_CONSTANT) < 0) {
>> > +        LIBXL_MAXMEM_CONSTANT + rc) < 0) {
> I think this LIBXL_MAXMEM_CONSTANT should be pushed to your helper
> function, too.
>
> So that, we can have all LIBXL_MAXMEM_CONSTANT removed in libxl
> functions (see libxl.c and libxl_dom.c)
>
If we push LIBXL_MAXMEM_CONSTANT to the libxl_arch_memory_constant and 
remove it from libxl.c, do we need to call libxl_arch_memory_constant 
there in libxl_set_memory_target()?

Thanks,
-- 
Shannon

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

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

* Re: [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI
  2016-09-26 19:45     ` Shannon Zhao
@ 2016-09-27  8:01       ` Jan Beulich
  0 siblings, 0 replies; 56+ messages in thread
From: Jan Beulich @ 2016-09-27  8:01 UTC (permalink / raw)
  To: z00226004, Shannon Zhao
  Cc: sstabellini, wei.liu2, Andrew Cooper, ian.jackson,
	peter.huangpeng, xen-devel, julien.grall, boris.ostrovsky

>>> On 26.09.16 at 21:45, <shannon.zhao@linaro.org> wrote:
> On 2016/9/22 8:00, Jan Beulich wrote:
>>>>> On 22.09.16 at 14:52, <zhaoshenglong@huawei.com> wrote:
>>> --- a/xen/include/public/hvm/params.h
>>> +++ b/xen/include/public/hvm/params.h
>>> @@ -30,6 +30,7 @@
>>>   */
>>>
>>>  #define HVM_PARAM_CALLBACK_IRQ 0
>>> +#define HVM_PARAM_CALLBACK_IRQ_TYPE_MASK 0xFF00000000000000
>>
>> I'd be surprised if this goes through on all compiler versions: This
>> is a constant which needs at least a UL suffix (and if intended to
>> be usable on 32-bit even a ULL one, which would then get us into
>> complications with there not being supposed to be any non-C89
>> constructs in the public headers).
> 
> Do I need to resend this patch or add new one to fix this on top of this 
> one?

Well, the patch should not go in without this addressed, so yes,
I think you will need to send a v7.

Jan


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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-26 18:30           ` Shannon Zhao
@ 2016-09-27  9:30             ` Wei Liu
  0 siblings, 0 replies; 56+ messages in thread
From: Wei Liu @ 2016-09-27  9:30 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, Wei Liu, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, z00226004, boris.ostrovsky

On Mon, Sep 26, 2016 at 11:30:53AM -0700, Shannon Zhao wrote:
> 
> 
> On 2016/9/26 2:05, Wei Liu wrote:
> >On Mon, Sep 26, 2016 at 03:08:43PM +0800, Shannon Zhao wrote:
> >>>
> >>>
> >>> On 2016/9/22 22:32, Wei Liu wrote:
> >>>> >FAOD:
> >>>> >
> >>>> >I think all the issues I found so far in this patch and other patch(es)
> >>>> >are mostly cosmetic. I would be happy to accept incremental patches on
> >>>> >top of this series to make those changes.
> >>>> >
> >>> Ok, thanks for your review.
> >>>
> >>>> >No need to resend just yet unless there is something substantial that
> >>>> >you need to change.
> >>> So far do I need to resend this series for comments?
> >No, you don't have to resend this series at the moment. Please address
> >Jan's comment on patch 14 first.
> Ok, I see. Do I need to resend the patch or add new one on top of that?
> 

What Jan said in his reply.

Please resend that patch to address his comment.

Sorry I didn't make that clear from the beginning.

Wei.

> Thanks,
> -- 
> Shannon

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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-26 21:54     ` Shannon Zhao
@ 2016-09-27  9:41       ` Wei Liu
  2016-09-27 16:01         ` Shannon Zhao
  0 siblings, 1 reply; 56+ messages in thread
From: Wei Liu @ 2016-09-27  9:41 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, Wei Liu, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, z00226004, boris.ostrovsky

On Mon, Sep 26, 2016 at 02:54:55PM -0700, Shannon Zhao wrote:
> 
> 
> On 2016/9/22 7:10, Wei Liu wrote:
> >>diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> >>> index 2924629..118beab 100644
> >>> --- a/tools/libxl/libxl_dom.c
> >>> +++ b/tools/libxl/libxl_dom.c
> >>> @@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
> >>>          }
> >>>      }
> >>>
> >>> +
> >>> +    rc = libxl__arch_memory_constant(gc, info, state);
> >>> +    if (rc < 0) {
> >>> +        LOGE(ERROR, "Couldn't get arch constant memory size");
> >>> +        return ERROR_FAIL;
> >>> +    }
> >>> +
> >>>      if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
> >>> -        LIBXL_MAXMEM_CONSTANT) < 0) {
> >>> +        LIBXL_MAXMEM_CONSTANT + rc) < 0) {
> >I think this LIBXL_MAXMEM_CONSTANT should be pushed to your helper
> >function, too.
> >
> >So that, we can have all LIBXL_MAXMEM_CONSTANT removed in libxl
> >functions (see libxl.c and libxl_dom.c)
> >
> If we push LIBXL_MAXMEM_CONSTANT to the libxl_arch_memory_constant and
> remove it from libxl.c, do we need to call libxl_arch_memory_constant there
> in libxl_set_memory_target()?
> 

Yes, we need to call that function everywhere to get consistent results.
That's the reason I asked you to consolidate it to a function.

Wei.

> Thanks,
> -- 
> Shannon

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

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

* [PATCH v7 04/16] libxl/arm: Estimate the size of ACPI tables
  2016-09-22 12:52 ` [PATCH v6 04/16] libxl/arm: Estimate the size of ACPI tables z00226004
  2016-09-22 14:21   ` Wei Liu
@ 2016-09-27 15:20   ` Shannon Zhao
  1 sibling, 0 replies; 56+ messages in thread
From: Shannon Zhao @ 2016-09-27 15:20 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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 | 100 +++++++++++++++++++++++++++++++++++++++++++
 xen/include/acpi/actbl1.h    |   2 +
 2 files changed, 102 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 0851411..33a25ff 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -34,12 +34,110 @@ extern const unsigned char dsdt_anycpu_arm[];
 _hidden
 extern const int dsdt_anycpu_arm_len;
 
+enum {
+    RSDP,
+    XSDT,
+    GTDT,
+    MADT,
+    FADT,
+    DSDT,
+    MAX_TABLE_NUMS,
+};
+
+struct acpitable {
+    uint64_t addr;
+    size_t size;
+};
+
+static int libxl__estimate_madt_size(libxl__gc *gc,
+                                     const libxl_domain_build_info *info,
+                                     const xc_domain_configuration_t *xc_config,
+                                     size_t *size)
+{
+    int rc = 0;
+
+    switch (xc_config->gic_version) {
+    case XEN_DOMCTL_CONFIG_GIC_V2:
+        *size = sizeof(struct acpi_table_madt) +
+                ACPI_MADT_GICC_SIZE_v5 * info->max_vcpus +
+                sizeof(struct acpi_madt_generic_distributor);
+        break;
+    case XEN_DOMCTL_CONFIG_GIC_V3:
+        *size = sizeof(struct acpi_table_madt) +
+                ACPI_MADT_GICC_SIZE_v5 * info->max_vcpus +
+                sizeof(struct acpi_madt_generic_distributor) +
+                sizeof(struct acpi_madt_generic_redistributor);
+        break;
+    default:
+        LOG(ERROR, "Unknown GIC version");
+        rc = ERROR_FAIL;
+        break;
+    }
+
+    return rc;
+}
+
+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[])
+{
+    int rc;
+    size_t size;
+
+    acpitables[RSDP].addr = GUEST_ACPI_BASE;
+    acpitables[RSDP].size = sizeof(struct acpi_table_rsdp);
+    dom->acpi_modules[0].length += ROUNDUP(acpitables[RSDP].size, 3);
+
+    acpitables[XSDT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length;
+    /*
+     * 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->acpi_modules[0].length += ROUNDUP(acpitables[XSDT].size, 3);
+
+    acpitables[GTDT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length;
+    acpitables[GTDT].size = sizeof(struct acpi_table_gtdt);
+    dom->acpi_modules[0].length += ROUNDUP(acpitables[GTDT].size, 3);
+
+    acpitables[MADT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length;
+
+    rc = libxl__estimate_madt_size(gc, info, xc_config, &size);
+    if (rc < 0)
+        goto out;
+
+    acpitables[MADT].size = size;
+    dom->acpi_modules[0].length += ROUNDUP(acpitables[MADT].size, 3);
+
+    acpitables[FADT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length;
+    acpitables[FADT].size = sizeof(struct acpi_table_fadt);
+    dom->acpi_modules[0].length += ROUNDUP(acpitables[FADT].size, 3);
+
+    acpitables[DSDT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length;
+    acpitables[DSDT].size = dsdt_anycpu_arm_len;
+    dom->acpi_modules[0].length += ROUNDUP(acpitables[DSDT].size, 3);
+
+    assert(dom->acpi_modules[0].length <= GUEST_ACPI_SIZE);
+    dom->acpi_modules[0].data = libxl__zalloc(gc, dom->acpi_modules[0].length);
+
+    rc = 0;
+out:
+    return rc;
+}
+
 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 = 0;
+    struct acpitable acpitables[MAX_TABLE_NUMS];
+
+    /* convenience aliases */
+    xc_domain_configuration_t *xc_config = &state->config;
 
     vers = libxl_get_version_info(CTX);
     if (vers == NULL) {
@@ -54,6 +152,8 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     dom->acpi_modules[0].length = 0;
     dom->acpi_modules[0].guest_addr_out = GUEST_ACPI_BASE;
 
+    rc = libxl__estimate_acpi_size(gc, info, dom, xc_config, acpitables);
+
 out:
     return rc;
 }
diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
index ed5cd2d..e199136 100644
--- a/xen/include/acpi/actbl1.h
+++ b/xen/include/acpi/actbl1.h
@@ -786,6 +786,8 @@ struct acpi_madt_generic_interrupt {
 	u8 reserved2[3];
 };
 
+#define ACPI_MADT_GICC_SIZE_v5          76
+
 /* Masks for Flags field above */
 
 /* ACPI_MADT_ENABLED                    (1)      Processor is usable if set */
-- 
2.10.0.windows.1


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

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

* [PATCH v7 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI
  2016-09-22 12:52 ` [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI z00226004
  2016-09-22 14:44   ` Julien Grall
  2016-09-22 15:00   ` Jan Beulich
@ 2016-09-27 15:27   ` Shannon Zhao
  2016-09-28 10:55     ` Jan Beulich
  2 siblings, 1 reply; 56+ messages in thread
From: Shannon Zhao @ 2016-09-27 15:27 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, Andrew Cooper, ian.jackson, julien.grall,
	Shannon Zhao, Jan Beulich, zhaoshenglong, boris.ostrovsky

Add macros for HVM_PARAM_CALLBACK_TYPE_PPI operation values and update
them in evtchn_fixup().

Also use HVM_PARAM_CALLBACK_IRQ_TYPE_MASK in hvm_set_callback_via().

Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/domain_build.c     | 9 ++++++---
 xen/arch/x86/hvm/irq.c          | 2 +-
 xen/include/public/hvm/params.h | 3 +++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 35ab08d..0cf7dc3 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2016,9 +2016,12 @@ static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
            d->arch.evtchn_irq);
 
     /* Set the value of domain param HVM_PARAM_CALLBACK_IRQ */
-    val = (u64)HVM_PARAM_CALLBACK_TYPE_PPI << 56;
-    val |= (2 << 8); /* Active-low level-sensitive  */
-    val |= d->arch.evtchn_irq & 0xff;
+    val = MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI,
+                    HVM_PARAM_CALLBACK_IRQ_TYPE_MASK);
+    /* Active-low level-sensitive  */
+    val |= MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_LOW_LEVEL,
+                     HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_MASK);
+    val |= d->arch.evtchn_irq;
     d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = val;
 
     /*
diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c
index 5323d7c..e597114 100644
--- a/xen/arch/x86/hvm/irq.c
+++ b/xen/arch/x86/hvm/irq.c
@@ -325,7 +325,7 @@ void hvm_set_callback_via(struct domain *d, uint64_t via)
     unsigned int gsi=0, pdev=0, pintx=0;
     uint8_t via_type;
 
-    via_type = (uint8_t)(via >> 56) + 1;
+    via_type = (uint8_t)MASK_EXTR(via, HVM_PARAM_CALLBACK_IRQ_TYPE_MASK) + 1;
     if ( ((via_type == HVMIRQ_callback_gsi) && (via == 0)) ||
          (via_type > HVMIRQ_callback_vector) )
         via_type = HVMIRQ_callback_none;
diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
index f7338a3..8b126e2 100644
--- a/xen/include/public/hvm/params.h
+++ b/xen/include/public/hvm/params.h
@@ -30,6 +30,7 @@
  */
 
 #define HVM_PARAM_CALLBACK_IRQ 0
+#define HVM_PARAM_CALLBACK_IRQ_TYPE_MASK 0xFF00000000000000ULL
 /*
  * How should CPU0 event-channel notifications be delivered?
  *
@@ -66,6 +67,8 @@
  * This is only used by ARM/ARM64 and masking/eoi the interrupt associated to
  * the notification is handled by the interrupt controller.
  */
+#define HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_MASK      0xFF00
+#define HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_LOW_LEVEL 2
 #endif
 
 /*
-- 
2.10.0.windows.1


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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-27  9:41       ` Wei Liu
@ 2016-09-27 16:01         ` Shannon Zhao
  2016-09-27 16:35           ` Wei Liu
  0 siblings, 1 reply; 56+ messages in thread
From: Shannon Zhao @ 2016-09-27 16:01 UTC (permalink / raw)
  To: Wei Liu
  Cc: sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, z00226004, boris.ostrovsky



On 2016/9/27 2:41, Wei Liu wrote:
> On Mon, Sep 26, 2016 at 02:54:55PM -0700, Shannon Zhao wrote:
>>
>>
>> On 2016/9/22 7:10, Wei Liu wrote:
>>>> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
>>>>> index 2924629..118beab 100644
>>>>> --- a/tools/libxl/libxl_dom.c
>>>>> +++ b/tools/libxl/libxl_dom.c
>>>>> @@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
>>>>>          }
>>>>>      }
>>>>>
>>>>> +
>>>>> +    rc = libxl__arch_memory_constant(gc, info, state);
>>>>> +    if (rc < 0) {
>>>>> +        LOGE(ERROR, "Couldn't get arch constant memory size");
>>>>> +        return ERROR_FAIL;
>>>>> +    }
>>>>> +
>>>>>      if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
>>>>> -        LIBXL_MAXMEM_CONSTANT) < 0) {
>>>>> +        LIBXL_MAXMEM_CONSTANT + rc) < 0) {
>>> I think this LIBXL_MAXMEM_CONSTANT should be pushed to your helper
>>> function, too.
>>>
>>> So that, we can have all LIBXL_MAXMEM_CONSTANT removed in libxl
>>> functions (see libxl.c and libxl_dom.c)
>>>
>> If we push LIBXL_MAXMEM_CONSTANT to the libxl_arch_memory_constant and
>> remove it from libxl.c, do we need to call libxl_arch_memory_constant there
>> in libxl_set_memory_target()?
>>
>
> Yes, we need to call that function everywhere to get consistent results.
> That's the reason I asked you to consolidate it to a function.
>
Well it's a little awkward I think, since in libxl_domain_setmaxmem() 
and libxl_set_memory_target() it seems it can't get the parameters info 
and state for libxl__arch_memory_constant().
I'm not sure how to solve it. Wei, any suggestion?

Thanks,
-- 
Shannon

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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-27 16:01         ` Shannon Zhao
@ 2016-09-27 16:35           ` Wei Liu
  2016-09-27 18:43             ` Shannon Zhao
  0 siblings, 1 reply; 56+ messages in thread
From: Wei Liu @ 2016-09-27 16:35 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, Wei Liu, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, z00226004, boris.ostrovsky

On Tue, Sep 27, 2016 at 09:01:00AM -0700, Shannon Zhao wrote:
> 
> 
> On 2016/9/27 2:41, Wei Liu wrote:
> >On Mon, Sep 26, 2016 at 02:54:55PM -0700, Shannon Zhao wrote:
> >>
> >>
> >>On 2016/9/22 7:10, Wei Liu wrote:
> >>>>diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> >>>>>index 2924629..118beab 100644
> >>>>>--- a/tools/libxl/libxl_dom.c
> >>>>>+++ b/tools/libxl/libxl_dom.c
> >>>>>@@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
> >>>>>         }
> >>>>>     }
> >>>>>
> >>>>>+
> >>>>>+    rc = libxl__arch_memory_constant(gc, info, state);
> >>>>>+    if (rc < 0) {
> >>>>>+        LOGE(ERROR, "Couldn't get arch constant memory size");
> >>>>>+        return ERROR_FAIL;
> >>>>>+    }
> >>>>>+
> >>>>>     if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
> >>>>>-        LIBXL_MAXMEM_CONSTANT) < 0) {
> >>>>>+        LIBXL_MAXMEM_CONSTANT + rc) < 0) {
> >>>I think this LIBXL_MAXMEM_CONSTANT should be pushed to your helper
> >>>function, too.
> >>>
> >>>So that, we can have all LIBXL_MAXMEM_CONSTANT removed in libxl
> >>>functions (see libxl.c and libxl_dom.c)
> >>>
> >>If we push LIBXL_MAXMEM_CONSTANT to the libxl_arch_memory_constant and
> >>remove it from libxl.c, do we need to call libxl_arch_memory_constant there
> >>in libxl_set_memory_target()?
> >>
> >
> >Yes, we need to call that function everywhere to get consistent results.
> >That's the reason I asked you to consolidate it to a function.
> >
> Well it's a little awkward I think, since in libxl_domain_setmaxmem() and
> libxl_set_memory_target() it seems it can't get the parameters info and
> state for libxl__arch_memory_constant().
> I'm not sure how to solve it. Wei, any suggestion?
> 

Hmm...

The first question is can state be derived from build_info ? From my
quick skim of the code the answer is likely yes.

Then, you can call libxl_retrieve_domain_configuration to get
domain_config, then domain_config->build_info, so that you can derive
state from it.

Feel free to ask more questions.

Without such arrangement, ballooning is going to be broken for ARM
guests.


Wei.

> Thanks,
> -- 
> Shannon

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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-27 16:35           ` Wei Liu
@ 2016-09-27 18:43             ` Shannon Zhao
  2016-09-28 10:00               ` Wei Liu
  0 siblings, 1 reply; 56+ messages in thread
From: Shannon Zhao @ 2016-09-27 18:43 UTC (permalink / raw)
  To: Wei Liu
  Cc: sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, z00226004, boris.ostrovsky



On 2016/9/27 9:35, Wei Liu wrote:
> On Tue, Sep 27, 2016 at 09:01:00AM -0700, Shannon Zhao wrote:
>>
>>
>> On 2016/9/27 2:41, Wei Liu wrote:
>>> On Mon, Sep 26, 2016 at 02:54:55PM -0700, Shannon Zhao wrote:
>>>>
>>>>
>>>> On 2016/9/22 7:10, Wei Liu wrote:
>>>>>> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
>>>>>>> index 2924629..118beab 100644
>>>>>>> --- a/tools/libxl/libxl_dom.c
>>>>>>> +++ b/tools/libxl/libxl_dom.c
>>>>>>> @@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
>>>>>>>         }
>>>>>>>     }
>>>>>>>
>>>>>>> +
>>>>>>> +    rc = libxl__arch_memory_constant(gc, info, state);
>>>>>>> +    if (rc < 0) {
>>>>>>> +        LOGE(ERROR, "Couldn't get arch constant memory size");
>>>>>>> +        return ERROR_FAIL;
>>>>>>> +    }
>>>>>>> +
>>>>>>>     if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
>>>>>>> -        LIBXL_MAXMEM_CONSTANT) < 0) {
>>>>>>> +        LIBXL_MAXMEM_CONSTANT + rc) < 0) {
>>>>> I think this LIBXL_MAXMEM_CONSTANT should be pushed to your helper
>>>>> function, too.
>>>>>
>>>>> So that, we can have all LIBXL_MAXMEM_CONSTANT removed in libxl
>>>>> functions (see libxl.c and libxl_dom.c)
>>>>>
>>>> If we push LIBXL_MAXMEM_CONSTANT to the libxl_arch_memory_constant and
>>>> remove it from libxl.c, do we need to call libxl_arch_memory_constant there
>>>> in libxl_set_memory_target()?
>>>>
>>>
>>> Yes, we need to call that function everywhere to get consistent results.
>>> That's the reason I asked you to consolidate it to a function.
>>>
>> Well it's a little awkward I think, since in libxl_domain_setmaxmem() and
>> libxl_set_memory_target() it seems it can't get the parameters info and
>> state for libxl__arch_memory_constant().
>> I'm not sure how to solve it. Wei, any suggestion?
>>
>
> Hmm...
>
> The first question is can state be derived from build_info ? From my
> quick skim of the code the answer is likely yes.
>
I'm not familiar with the relationship between these structures and not 
sure how to do this. Please give me some suggestion.

> Then, you can call libxl_retrieve_domain_configuration to get
> domain_config, then domain_config->build_info, so that you can derive
> state from it.
>
> Feel free to ask more questions.
>
> Without such arrangement, ballooning is going to be broken for ARM
> guests.
>
I see.

Thanks,
-- 
Shannon

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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-27 18:43             ` Shannon Zhao
@ 2016-09-28 10:00               ` Wei Liu
  2016-09-28 13:11                 ` Shannon Zhao
  0 siblings, 1 reply; 56+ messages in thread
From: Wei Liu @ 2016-09-28 10:00 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, Wei Liu, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, z00226004, boris.ostrovsky

On Tue, Sep 27, 2016 at 11:43:38AM -0700, Shannon Zhao wrote:
> 
> 
> On 2016/9/27 9:35, Wei Liu wrote:
> >On Tue, Sep 27, 2016 at 09:01:00AM -0700, Shannon Zhao wrote:
> >>
> >>
> >>On 2016/9/27 2:41, Wei Liu wrote:
> >>>On Mon, Sep 26, 2016 at 02:54:55PM -0700, Shannon Zhao wrote:
> >>>>
> >>>>
> >>>>On 2016/9/22 7:10, Wei Liu wrote:
> >>>>>>diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> >>>>>>>index 2924629..118beab 100644
> >>>>>>>--- a/tools/libxl/libxl_dom.c
> >>>>>>>+++ b/tools/libxl/libxl_dom.c
> >>>>>>>@@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
> >>>>>>>        }
> >>>>>>>    }
> >>>>>>>
> >>>>>>>+
> >>>>>>>+    rc = libxl__arch_memory_constant(gc, info, state);
> >>>>>>>+    if (rc < 0) {
> >>>>>>>+        LOGE(ERROR, "Couldn't get arch constant memory size");
> >>>>>>>+        return ERROR_FAIL;
> >>>>>>>+    }
> >>>>>>>+
> >>>>>>>    if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
> >>>>>>>-        LIBXL_MAXMEM_CONSTANT) < 0) {
> >>>>>>>+        LIBXL_MAXMEM_CONSTANT + rc) < 0) {
> >>>>>I think this LIBXL_MAXMEM_CONSTANT should be pushed to your helper
> >>>>>function, too.
> >>>>>
> >>>>>So that, we can have all LIBXL_MAXMEM_CONSTANT removed in libxl
> >>>>>functions (see libxl.c and libxl_dom.c)
> >>>>>
> >>>>If we push LIBXL_MAXMEM_CONSTANT to the libxl_arch_memory_constant and
> >>>>remove it from libxl.c, do we need to call libxl_arch_memory_constant there
> >>>>in libxl_set_memory_target()?
> >>>>
> >>>
> >>>Yes, we need to call that function everywhere to get consistent results.
> >>>That's the reason I asked you to consolidate it to a function.
> >>>
> >>Well it's a little awkward I think, since in libxl_domain_setmaxmem() and
> >>libxl_set_memory_target() it seems it can't get the parameters info and
> >>state for libxl__arch_memory_constant().
> >>I'm not sure how to solve it. Wei, any suggestion?
> >>
> >
> >Hmm...
> >
> >The first question is can state be derived from build_info ? From my
> >quick skim of the code the answer is likely yes.
> >
> I'm not familiar with the relationship between these structures and not sure
> how to do this. Please give me some suggestion.
> 

Oh, I was just reading the code in your patch series and existing code
in libxl_arm.c.  Here is my analysis of the code, please point out any
inaccuracy.

In your patch that estimates the size of ACPI table(s), xc_config is
needed. In particular, you need to know the gic version -- in fact
that's the only thing you need to know as far as I can tell.

In libxl_arm.c, the gic version is finally saved to  d_config, which
means you should be able to later extract that from d_config.

But, as I understand it, you can't use  d_config only while *building*
the domain, because the gic version might be determined only after the
domain is constructed (_NATIVE case). If you want to do so, you need to
move some code around, which might or might not be feasible -- I haven't
checked.

So based on my analysis, it would make sense to have such function:

   libxl__arch_extra_memory(gc, d_config)

This is the function that is used in libxl_set_memory_target and
friends.

Obviously x86 would only need to return a constant in that function.

Then, in arm implementation:

   libxl__get_acpi_size(gc, info, gic_version /* not build_state anymore */)

   /* also fix up libxl__estimate_madt_size */


   /* this is the function called when constructing the domain etc, only
    * in libxl_arm.c */
   static acpi_extra_memory(gc, build_info, gic_version)
   {
        libxl__get_acpi_size...
   }

   libxl__arch_extra_memory(gc, d_config)
   {
        gic_version = d_config->..gic_version;

        acpi_extra_memory...
   }

Does this make sense?

One thing I don't quite understand is that in patch 4
libxl__estimate_acpi_size seems to do allocations as well. You might
want to rename that libxl__allocate_acpi_tables or something.

Wei.

> >Then, you can call libxl_retrieve_domain_configuration to get
> >domain_config, then domain_config->build_info, so that you can derive
> >state from it.
> >
> >Feel free to ask more questions.
> >
> >Without such arrangement, ballooning is going to be broken for ARM
> >guests.
> >
> I see.
> 
> Thanks,
> -- 
> Shannon

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

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

* Re: [PATCH v7 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI
  2016-09-27 15:27   ` [PATCH v7 " Shannon Zhao
@ 2016-09-28 10:55     ` Jan Beulich
  0 siblings, 0 replies; 56+ messages in thread
From: Jan Beulich @ 2016-09-28 10:55 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, wei.liu2, Andrew Cooper, ian.jackson, xen-devel,
	julien.grall, zhaoshenglong, boris.ostrovsky

>>> On 27.09.16 at 17:27, <shannon.zhao@linaro.org> wrote:
> --- a/xen/include/public/hvm/params.h
> +++ b/xen/include/public/hvm/params.h
> @@ -30,6 +30,7 @@
>   */
>  
>  #define HVM_PARAM_CALLBACK_IRQ 0
> +#define HVM_PARAM_CALLBACK_IRQ_TYPE_MASK 0xFF00000000000000ULL

Well, I have to admit that I'm somewhat disappointed: I had
specifically pointed out that the ULL suffix is not C89 conforming,
and that dealing with this may need a little more thought. On the
plus side, the mere presence of that #define won't cause C89
compilers to error out. But to help actually using such a value, I
think we'd better introduce xen_mk_ullong() (next to the two
already existing variants) and use it here and in all other places
wrongly using that C99 construct. That way customization by
such consumers could be limited to exactly one place. If you
wish I can put together the necessary cleanup patch, and you
could then re-base yours on top.

Jan


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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-28 10:00               ` Wei Liu
@ 2016-09-28 13:11                 ` Shannon Zhao
  2016-09-28 13:17                   ` Wei Liu
  0 siblings, 1 reply; 56+ messages in thread
From: Shannon Zhao @ 2016-09-28 13:11 UTC (permalink / raw)
  To: Wei Liu
  Cc: sstabellini, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, z00226004, boris.ostrovsky



On 2016/9/28 3:00, Wei Liu wrote:
> On Tue, Sep 27, 2016 at 11:43:38AM -0700, Shannon Zhao wrote:
>>
>>
>> On 2016/9/27 9:35, Wei Liu wrote:
>>> On Tue, Sep 27, 2016 at 09:01:00AM -0700, Shannon Zhao wrote:
>>>>
>>>>
>>>> On 2016/9/27 2:41, Wei Liu wrote:
>>>>> On Mon, Sep 26, 2016 at 02:54:55PM -0700, Shannon Zhao wrote:
>>>>>>
>>>>>>
>>>>>> On 2016/9/22 7:10, Wei Liu wrote:
>>>>>>>> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
>>>>>>>>> index 2924629..118beab 100644
>>>>>>>>> --- a/tools/libxl/libxl_dom.c
>>>>>>>>> +++ b/tools/libxl/libxl_dom.c
>>>>>>>>> @@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
>>>>>>>>>        }
>>>>>>>>>    }
>>>>>>>>>
>>>>>>>>> +
>>>>>>>>> +    rc = libxl__arch_memory_constant(gc, info, state);
>>>>>>>>> +    if (rc < 0) {
>>>>>>>>> +        LOGE(ERROR, "Couldn't get arch constant memory size");
>>>>>>>>> +        return ERROR_FAIL;
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>>    if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
>>>>>>>>> -        LIBXL_MAXMEM_CONSTANT) < 0) {
>>>>>>>>> +        LIBXL_MAXMEM_CONSTANT + rc) < 0) {
>>>>>>> I think this LIBXL_MAXMEM_CONSTANT should be pushed to your helper
>>>>>>> function, too.
>>>>>>>
>>>>>>> So that, we can have all LIBXL_MAXMEM_CONSTANT removed in libxl
>>>>>>> functions (see libxl.c and libxl_dom.c)
>>>>>>>
>>>>>> If we push LIBXL_MAXMEM_CONSTANT to the libxl_arch_memory_constant and
>>>>>> remove it from libxl.c, do we need to call libxl_arch_memory_constant there
>>>>>> in libxl_set_memory_target()?
>>>>>>
>>>>>
>>>>> Yes, we need to call that function everywhere to get consistent results.
>>>>> That's the reason I asked you to consolidate it to a function.
>>>>>
>>>> Well it's a little awkward I think, since in libxl_domain_setmaxmem() and
>>>> libxl_set_memory_target() it seems it can't get the parameters info and
>>>> state for libxl__arch_memory_constant().
>>>> I'm not sure how to solve it. Wei, any suggestion?
>>>>
>>>
>>> Hmm...
>>>
>>> The first question is can state be derived from build_info ? From my
>>> quick skim of the code the answer is likely yes.
>>>
>> I'm not familiar with the relationship between these structures and not sure
>> how to do this. Please give me some suggestion.
>>
>
> Oh, I was just reading the code in your patch series and existing code
> in libxl_arm.c.  Here is my analysis of the code, please point out any
> inaccuracy.
>
> In your patch that estimates the size of ACPI table(s), xc_config is
> needed. In particular, you need to know the gic version -- in fact
> that's the only thing you need to know as far as I can tell.
>
> In libxl_arm.c, the gic version is finally saved to  d_config, which
> means you should be able to later extract that from d_config.
>
> But, as I understand it, you can't use  d_config only while *building*
> the domain, because the gic version might be determined only after the
> domain is constructed (_NATIVE case). If you want to do so, you need to
> move some code around, which might or might not be feasible -- I haven't
> checked.
>
> So based on my analysis, it would make sense to have such function:
>
>    libxl__arch_extra_memory(gc, d_config)
>
> This is the function that is used in libxl_set_memory_target and
> friends.
>
> Obviously x86 would only need to return a constant in that function.
>
> Then, in arm implementation:
>
>    libxl__get_acpi_size(gc, info, gic_version /* not build_state anymore */)
>
>    /* also fix up libxl__estimate_madt_size */
>
>
>    /* this is the function called when constructing the domain etc, only
>     * in libxl_arm.c */
>    static acpi_extra_memory(gc, build_info, gic_version)
>    {
>         libxl__get_acpi_size...
>    }
>
>    libxl__arch_extra_memory(gc, d_config)
>    {
>         gic_version = d_config->..gic_version;
>
If user doesn't specify gic_version in xl config, the 
d_config->b_info.arch_arm.gic_version will be LIBXL_GIC_VERSION_DEFAULT, 
so we can't know the exact gic_version which will be constructed later.

Since the gic_version is now only used to determine if it should include 
acpi_madt_generic_redistributor size, can we add a function 
libxl__get_acpi_max_size which doesn't care about the gic_version and 
just returns the max acpi size. And this max size is just for setting 
the target maxmem and not for allocating the acpi tables.

What do you think about this?

Thanks,
-- 
Shannon

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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-28 13:11                 ` Shannon Zhao
@ 2016-09-28 13:17                   ` Wei Liu
  2016-09-28 17:52                     ` Julien Grall
  0 siblings, 1 reply; 56+ messages in thread
From: Wei Liu @ 2016-09-28 13:17 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, Wei Liu, ian.jackson, peter.huangpeng, xen-devel,
	julien.grall, z00226004, boris.ostrovsky

On Wed, Sep 28, 2016 at 06:11:53AM -0700, Shannon Zhao wrote:
> 
> 
> On 2016/9/28 3:00, Wei Liu wrote:
> >On Tue, Sep 27, 2016 at 11:43:38AM -0700, Shannon Zhao wrote:
> >>
> >>
> >>On 2016/9/27 9:35, Wei Liu wrote:
> >>>On Tue, Sep 27, 2016 at 09:01:00AM -0700, Shannon Zhao wrote:
> >>>>
> >>>>
> >>>>On 2016/9/27 2:41, Wei Liu wrote:
> >>>>>On Mon, Sep 26, 2016 at 02:54:55PM -0700, Shannon Zhao wrote:
> >>>>>>
> >>>>>>
> >>>>>>On 2016/9/22 7:10, Wei Liu wrote:
> >>>>>>>>diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> >>>>>>>>>index 2924629..118beab 100644
> >>>>>>>>>--- a/tools/libxl/libxl_dom.c
> >>>>>>>>>+++ b/tools/libxl/libxl_dom.c
> >>>>>>>>>@@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
> >>>>>>>>>       }
> >>>>>>>>>   }
> >>>>>>>>>
> >>>>>>>>>+
> >>>>>>>>>+    rc = libxl__arch_memory_constant(gc, info, state);
> >>>>>>>>>+    if (rc < 0) {
> >>>>>>>>>+        LOGE(ERROR, "Couldn't get arch constant memory size");
> >>>>>>>>>+        return ERROR_FAIL;
> >>>>>>>>>+    }
> >>>>>>>>>+
> >>>>>>>>>   if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
> >>>>>>>>>-        LIBXL_MAXMEM_CONSTANT) < 0) {
> >>>>>>>>>+        LIBXL_MAXMEM_CONSTANT + rc) < 0) {
> >>>>>>>I think this LIBXL_MAXMEM_CONSTANT should be pushed to your helper
> >>>>>>>function, too.
> >>>>>>>
> >>>>>>>So that, we can have all LIBXL_MAXMEM_CONSTANT removed in libxl
> >>>>>>>functions (see libxl.c and libxl_dom.c)
> >>>>>>>
> >>>>>>If we push LIBXL_MAXMEM_CONSTANT to the libxl_arch_memory_constant and
> >>>>>>remove it from libxl.c, do we need to call libxl_arch_memory_constant there
> >>>>>>in libxl_set_memory_target()?
> >>>>>>
> >>>>>
> >>>>>Yes, we need to call that function everywhere to get consistent results.
> >>>>>That's the reason I asked you to consolidate it to a function.
> >>>>>
> >>>>Well it's a little awkward I think, since in libxl_domain_setmaxmem() and
> >>>>libxl_set_memory_target() it seems it can't get the parameters info and
> >>>>state for libxl__arch_memory_constant().
> >>>>I'm not sure how to solve it. Wei, any suggestion?
> >>>>
> >>>
> >>>Hmm...
> >>>
> >>>The first question is can state be derived from build_info ? From my
> >>>quick skim of the code the answer is likely yes.
> >>>
> >>I'm not familiar with the relationship between these structures and not sure
> >>how to do this. Please give me some suggestion.
> >>
> >
> >Oh, I was just reading the code in your patch series and existing code
> >in libxl_arm.c.  Here is my analysis of the code, please point out any
> >inaccuracy.
> >
> >In your patch that estimates the size of ACPI table(s), xc_config is
> >needed. In particular, you need to know the gic version -- in fact
> >that's the only thing you need to know as far as I can tell.
> >
> >In libxl_arm.c, the gic version is finally saved to  d_config, which
> >means you should be able to later extract that from d_config.
> >
> >But, as I understand it, you can't use  d_config only while *building*
> >the domain, because the gic version might be determined only after the
> >domain is constructed (_NATIVE case). If you want to do so, you need to
> >move some code around, which might or might not be feasible -- I haven't
> >checked.
> >
> >So based on my analysis, it would make sense to have such function:
> >
> >   libxl__arch_extra_memory(gc, d_config)
> >
> >This is the function that is used in libxl_set_memory_target and
> >friends.
> >
> >Obviously x86 would only need to return a constant in that function.
> >
> >Then, in arm implementation:
> >
> >   libxl__get_acpi_size(gc, info, gic_version /* not build_state anymore */)
> >
> >   /* also fix up libxl__estimate_madt_size */
> >
> >
> >   /* this is the function called when constructing the domain etc, only
> >    * in libxl_arm.c */
> >   static acpi_extra_memory(gc, build_info, gic_version)
> >   {
> >        libxl__get_acpi_size...
> >   }
> >
> >   libxl__arch_extra_memory(gc, d_config)
> >   {
> >        gic_version = d_config->..gic_version;
> >
> If user doesn't specify gic_version in xl config, the
> d_config->b_info.arch_arm.gic_version will be LIBXL_GIC_VERSION_DEFAULT, so
> we can't know the exact gic_version which will be constructed later.
> 

First, can you confirm if it really can't be retrieved?

libxl__arch_domain_save_config updates that field after the domain is
constructed, so you might have a determined gic version to hand.

> Since the gic_version is now only used to determine if it should include
> acpi_madt_generic_redistributor size, can we add a function
> libxl__get_acpi_max_size which doesn't care about the gic_version and just
> returns the max acpi size.

Fine by me. But ...

> And this max size is just for setting the target
> maxmem and not for allocating the acpi tables.
> 

please use that everywhere -- including table allocation.

Wei.

> What do you think about this?
> 


> Thanks,
> -- 
> Shannon

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

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

* Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-28 13:17                   ` Wei Liu
@ 2016-09-28 17:52                     ` Julien Grall
  0 siblings, 0 replies; 56+ messages in thread
From: Julien Grall @ 2016-09-28 17:52 UTC (permalink / raw)
  To: Wei Liu, Shannon Zhao
  Cc: sstabellini, ian.jackson, peter.huangpeng, xen-devel, z00226004,
	boris.ostrovsky

Hi,

On 28/09/2016 06:17, Wei Liu wrote:
> On Wed, Sep 28, 2016 at 06:11:53AM -0700, Shannon Zhao wrote:
>>>   libxl__get_acpi_size(gc, info, gic_version /* not build_state anymore */)
>>>
>>>   /* also fix up libxl__estimate_madt_size */
>>>
>>>
>>>   /* this is the function called when constructing the domain etc, only
>>>    * in libxl_arm.c */
>>>   static acpi_extra_memory(gc, build_info, gic_version)
>>>   {
>>>        libxl__get_acpi_size...
>>>   }
>>>
>>>   libxl__arch_extra_memory(gc, d_config)
>>>   {
>>>        gic_version = d_config->..gic_version;
>>>
>> If user doesn't specify gic_version in xl config, the
>> d_config->b_info.arch_arm.gic_version will be LIBXL_GIC_VERSION_DEFAULT, so
>> we can't know the exact gic_version which will be constructed later.
>>
>
> First, can you confirm if it really can't be retrieved?
>
> libxl__arch_domain_save_config updates that field after the domain is
> constructed, so you might have a determined gic version to hand.

The target memory of the domain is created after the domain has been 
created. So we should have the correct GIC version is hand.

Regards,

-- 
Julien Grall

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

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

end of thread, other threads:[~2016-09-28 17:52 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
2016-09-22 12:52 ` [PATCH v6 01/16] tools/libxl: Add an unified configuration option for ACPI z00226004
2016-09-22 12:52 ` [PATCH v6 02/16] libxl/arm: prepare for constructing ACPI tables z00226004
2016-09-22 14:13   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 03/16] libxl/arm: Generate static ACPI DSDT table z00226004
2016-09-22 12:52 ` [PATCH v6 04/16] libxl/arm: Estimate the size of ACPI tables z00226004
2016-09-22 14:21   ` Wei Liu
2016-09-27 15:20   ` [PATCH v7 " Shannon Zhao
2016-09-22 12:52 ` [PATCH v6 05/16] libxl/arm: Construct ACPI RSDP table z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 06/16] libxl/arm: Construct ACPI XSDT table z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 07/16] libxl/arm: Construct ACPI GTDT table z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 08/16] libxl/arm: Factor MPIDR computing codes out as a helper z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 09/16] libxl/arm: Construct ACPI MADT table z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 10/16] libxl/arm: Construct ACPI FADT table z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 11/16] libxl/arm: Construct ACPI DSDT table z00226004
2016-09-22 14:15   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function z00226004
2016-09-22 14:15   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 13/16] libxl/arm: Add ACPI module z00226004
2016-09-22 14:15   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI z00226004
2016-09-22 14:44   ` Julien Grall
2016-09-22 15:00   ` Jan Beulich
2016-09-26 19:45     ` Shannon Zhao
2016-09-27  8:01       ` Jan Beulich
2016-09-27 15:27   ` [PATCH v7 " Shannon Zhao
2016-09-28 10:55     ` Jan Beulich
2016-09-22 12:52 ` [PATCH v6 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ z00226004
2016-09-22 14:16   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem z00226004
2016-09-22 14:10   ` Wei Liu
2016-09-22 14:32     ` Wei Liu
2016-09-26  7:08       ` Shannon Zhao
2016-09-26  9:05         ` Wei Liu
2016-09-26 18:30           ` Shannon Zhao
2016-09-27  9:30             ` Wei Liu
2016-09-26 21:54     ` Shannon Zhao
2016-09-27  9:41       ` Wei Liu
2016-09-27 16:01         ` Shannon Zhao
2016-09-27 16:35           ` Wei Liu
2016-09-27 18:43             ` Shannon Zhao
2016-09-28 10:00               ` Wei Liu
2016-09-28 13:11                 ` Shannon Zhao
2016-09-28 13:17                   ` Wei Liu
2016-09-28 17:52                     ` Julien Grall
2016-09-22 13:27 ` [PATCH v6 00/16] Xen ARM DomU ACPI support Julien Grall
2016-09-22 13:32   ` Shannon Zhao
2016-09-22 13:37     ` Julien Grall
2016-09-22 13:38       ` Shannon Zhao
2016-09-22 14:27 ` Julien Grall

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).