All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v8 00/16] Xen ARM DomU ACPI support
@ 2016-09-29  1:18 Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 01/16] tools/libxl: Add an unified configuration option for ACPI Shannon Zhao
                   ` (16 more replies)
  0 siblings, 17 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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_v8

Changes since v7:
* use xen_mk_ullong
* replace LIBXL_MAXMEM_CONSTANT everywhere
* do not use return value as output parameter

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.c                |  45 +++-
 tools/libxl/libxl_arch.h           |   9 +
 tools/libxl/libxl_arm.c            | 104 ++++++++--
 tools/libxl/libxl_arm.h            |  48 +++++
 tools/libxl/libxl_arm_acpi.c       | 408 +++++++++++++++++++++++++++++++++++++
 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            |  11 +-
 tools/libxl/libxl_internal.h       |  11 +
 tools/libxl/libxl_types.idl        |   4 +
 tools/libxl/libxl_x86.c            |  15 ++
 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 +
 25 files changed, 767 insertions(+), 34 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.10.0.windows.1


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

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

* [PATCH v8 01/16] tools/libxl: Add an unified configuration option for ACPI
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 02/16] libxl/arm: prepare for constructing ACPI tables Shannon Zhao
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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 d8108e3..21b58bc 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1249,6 +1249,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 b35f7b6..fff0554 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 0190baa..84493df 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -573,6 +573,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 cb43c00..1e93b1b 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.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] 23+ messages in thread

* [PATCH v8 02/16] libxl/arm: prepare for constructing ACPI tables
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 01/16] tools/libxl: Add an unified configuration option for ACPI Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 03/16] libxl/arm: Generate static ACPI DSDT table Shannon Zhao
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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>
---
 tools/libxl/Makefile            |  7 +++++
 tools/libxl/libxl_arm.c         | 24 +++++++++++++++-
 tools/libxl/libxl_arm.h         | 32 +++++++++++++++++++++
 tools/libxl/libxl_arm_acpi.c    | 61 +++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_arm_no_acpi.c | 33 ++++++++++++++++++++++
 xen/include/public/arch-arm.h   |  4 +++
 6 files changed, 160 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 3c63bf9..d8cd5f9 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -90,6 +90,13 @@ acpi:
 
 LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o
 LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
+ifeq ($(CONFIG_ARM_64),y)
+LIBXL_OBJS-y += libxl_arm_acpi.o
+libxl_arm_acpi.o: libxl_arm_acpi.c
+	$(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c
+else
+LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_no_acpi.o
+endif
 
 ifeq ($(CONFIG_NetBSD),y)
 LIBXL_OBJS-y += libxl_netbsd.o
diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 8ec5cd5..ec76c32 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, 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..fcce405
--- /dev/null
+++ b/tools/libxl/libxl_arm.h
@@ -0,0 +1,32 @@
+/*
+ * 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,
+                        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..5bf9396
--- /dev/null
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -0,0 +1,61 @@
+/*
+ * 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,
+                        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..88ebbb6
--- /dev/null
+++ b/tools/libxl/libxl_arm_no_acpi.c
@@ -0,0 +1,33 @@
+/*
+ * 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,
+                        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 17ce3a0..498d03d 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     xen_mk_ullong(0x03020000) /* vCPU0..127 */
 #define GUEST_GICV3_GICR0_SIZE     xen_mk_ullong(0x01000000)
 
+/* 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.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] 23+ messages in thread

* [PATCH v8 03/16] libxl/arm: Generate static ACPI DSDT table
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 01/16] tools/libxl: Add an unified configuration option for ACPI Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 02/16] libxl/arm: prepare for constructing ACPI tables Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-30 11:09   ` Wei Liu
  2016-09-29  1:18 ` [PATCH v8 04/16] libxl/arm: Estimate the size of ACPI tables Shannon Zhao
                   ` (13 subsequent siblings)
  16 siblings, 1 reply; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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 5724ace..794c615 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 65a540e..2502d53 100644
--- a/tools/libacpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -19,6 +19,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)
 
 # Suffix for temporary files.
@@ -38,7 +39,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: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh $(MK_DSDT)
@@ -65,6 +66,11 @@ $(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT)
 	cat dsdt_acpi_info.asl >> $@
 	$(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $@
 
+$(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 d8cd5f9..c4e4117 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -91,7 +91,10 @@ acpi:
 LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o
 LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
 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 5bf9396..06dff5f 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,
                         struct xc_dom_image *dom)
 {
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index c3bf419..7e43691 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -554,6 +554,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 498d03d..bd974fb 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.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] 23+ messages in thread

* [PATCH v8 04/16] libxl/arm: Estimate the size of ACPI tables
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (2 preceding siblings ...)
  2016-09-29  1:18 ` [PATCH v8 03/16] libxl/arm: Generate static ACPI DSDT table Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  9:59   ` Wei Liu
  2016-09-29  1:18 ` [PATCH v8 05/16] libxl/arm: Construct ACPI RSDP table Shannon Zhao
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 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 | 95 ++++++++++++++++++++++++++++++++++++++++++++
 xen/include/acpi/actbl1.h    |  2 +
 2 files changed, 97 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 06dff5f..bc9ab84 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -34,11 +34,104 @@ 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,
+                                     size_t *size)
+{
+    int rc = 0;
+
+    switch (info->arch_arm.gic_version) {
+    case LIBXL_GIC_VERSION_V2:
+        *size = sizeof(struct acpi_table_madt) +
+                ACPI_MADT_GICC_SIZE_v5 * info->max_vcpus +
+                sizeof(struct acpi_madt_generic_distributor);
+        break;
+    case LIBXL_GIC_VERSION_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__allocate_acpi_tables(libxl__gc *gc,
+                                       libxl_domain_build_info *info,
+                                       struct xc_dom_image *dom,
+                                       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, &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,
                         struct xc_dom_image *dom)
 {
     const libxl_version_info *vers;
     int rc = 0;
+    struct acpitable acpitables[MAX_TABLE_NUMS];
 
     vers = libxl_get_version_info(CTX);
     if (vers == NULL) {
@@ -53,6 +146,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__allocate_acpi_tables(gc, info, dom, 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] 23+ messages in thread

* [PATCH v8 05/16] libxl/arm: Construct ACPI RSDP table
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (3 preceding siblings ...)
  2016-09-29  1:18 ` [PATCH v8 04/16] libxl/arm: Estimate the size of ACPI tables Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 06/16] libxl/arm: Construct ACPI XSDT table Shannon Zhao
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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>
---
 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 bc9ab84..0512630 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,
                         struct xc_dom_image *dom)
 {
@@ -147,6 +182,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__allocate_acpi_tables(gc, info, dom, acpitables);
+    if (rc)
+        goto out;
+
+    make_acpi_rsdp(gc, dom, acpitables);
 
 out:
     return rc;
-- 
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] 23+ messages in thread

* [PATCH v8 06/16] libxl/arm: Construct ACPI XSDT table
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (4 preceding siblings ...)
  2016-09-29  1:18 ` [PATCH v8 05/16] libxl/arm: Construct ACPI RSDP table Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 07/16] libxl/arm: Construct ACPI GTDT table Shannon Zhao
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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_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 0512630..ab68bf8 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,
                         struct xc_dom_image *dom)
 {
@@ -186,6 +215,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.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] 23+ messages in thread

* [PATCH v8 07/16] libxl/arm: Construct ACPI GTDT table
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (5 preceding siblings ...)
  2016-09-29  1:18 ` [PATCH v8 06/16] libxl/arm: Construct ACPI XSDT table Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 08/16] libxl/arm: Factor MPIDR computing codes out as a helper Shannon Zhao
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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>
---
 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 ab68bf8..b2136fd 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,
                         struct xc_dom_image *dom)
 {
@@ -216,6 +253,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.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] 23+ messages in thread

* [PATCH v8 08/16] libxl/arm: Factor MPIDR computing codes out as a helper
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (6 preceding siblings ...)
  2016-09-29  1:18 ` [PATCH v8 07/16] libxl/arm: Construct ACPI GTDT table Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 09/16] libxl/arm: Construct ACPI MADT table Shannon Zhao
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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>
---
 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 ec76c32..a21dc56 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 fcce405..7097def 100644
--- a/tools/libxl/libxl_arm.h
+++ b/tools/libxl/libxl_arm.h
@@ -23,6 +23,17 @@ _hidden
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         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.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] 23+ messages in thread

* [PATCH v8 09/16] libxl/arm: Construct ACPI MADT table
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (7 preceding siblings ...)
  2016-09-29  1:18 ` [PATCH v8 08/16] libxl/arm: Factor MPIDR computing codes out as a helper Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 10/16] libxl/arm: Construct ACPI FADT table Shannon Zhao
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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>
---
 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 b2136fd..f593dab 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,
+                          libxl_domain_build_info *info,
+                          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 (info->arch_arm.gic_version) {
+    case LIBXL_GIC_VERSION_V2:
+        table += sizeof(struct acpi_table_madt);
+        make_acpi_madt_gicc(table, info->max_vcpus, GUEST_GICC_BASE);
+
+        table += ACPI_MADT_GICC_SIZE_v5 * info->max_vcpus;
+        make_acpi_madt_gicd(table, GUEST_GICD_BASE, ACPI_MADT_GIC_VERSION_V2);
+        break;
+    case LIBXL_GIC_VERSION_V3:
+        table += sizeof(struct acpi_table_madt);
+        make_acpi_madt_gicc(table, info->max_vcpus, 0);
+
+        table += ACPI_MADT_GICC_SIZE_v5 * info->max_vcpus;
+        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,
                         struct xc_dom_image *dom)
 {
@@ -254,6 +337,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, acpitables);
 
 out:
     return rc;
-- 
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] 23+ messages in thread

* [PATCH v8 10/16] libxl/arm: Construct ACPI FADT table
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (8 preceding siblings ...)
  2016-09-29  1:18 ` [PATCH v8 09/16] libxl/arm: Construct ACPI MADT table Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 11/16] libxl/arm: Construct ACPI DSDT table Shannon Zhao
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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_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 f593dab..6530f45 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,
                         struct xc_dom_image *dom)
 {
@@ -338,6 +357,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, acpitables);
+    if (rc)
+        goto out;
+
+    make_acpi_fadt(gc, dom, acpitables);
 
 out:
     return rc;
-- 
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] 23+ messages in thread

* [PATCH v8 11/16] libxl/arm: Construct ACPI DSDT table
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (9 preceding siblings ...)
  2016-09-29  1:18 ` [PATCH v8 10/16] libxl/arm: Construct ACPI FADT table Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function Shannon Zhao
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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>
---
 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 6530f45..6c713ac 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,
                         struct xc_dom_image *dom)
 {
@@ -361,6 +370,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.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] 23+ messages in thread

* [PATCH v8 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (10 preceding siblings ...)
  2016-09-29  1:18 ` [PATCH v8 11/16] libxl/arm: Construct ACPI DSDT table Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  1:18 ` [PATCH v8 13/16] libxl/arm: Add ACPI module Shannon Zhao
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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>
---
 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 a21dc56..19d3067 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.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] 23+ messages in thread

* [PATCH v8 13/16] libxl/arm: Add ACPI module
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (11 preceding siblings ...)
  2016-09-29  1:18 ` [PATCH v8 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function Shannon Zhao
@ 2016-09-29  1:18 ` Shannon Zhao
  2016-09-29  1:19 ` [PATCH v8 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI Shannon Zhao
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:18 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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>
---
 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 19d3067..376307e 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.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] 23+ messages in thread

* [PATCH v8 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (12 preceding siblings ...)
  2016-09-29  1:18 ` [PATCH v8 13/16] libxl/arm: Add ACPI module Shannon Zhao
@ 2016-09-29  1:19 ` Shannon Zhao
  2016-09-29  7:13   ` Jan Beulich
  2016-09-29  1:19 ` [PATCH v8 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ Shannon Zhao
                   ` (2 subsequent siblings)
  16 siblings, 1 reply; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:19 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 f1c5526..ce97359 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2064,9 +2064,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..3f54a49 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 xen_mk_ullong(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.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] 23+ messages in thread

* [PATCH v8 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (13 preceding siblings ...)
  2016-09-29  1:19 ` [PATCH v8 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI Shannon Zhao
@ 2016-09-29  1:19 ` Shannon Zhao
  2016-09-29  1:19 ` [PATCH v8 16/16] libxl/arm: Add the size of ACPI tables to maxmem Shannon Zhao
  2016-09-30 11:10 ` [PATCH v8 00/16] Xen ARM DomU ACPI support Wei Liu
  16 siblings, 0 replies; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:19 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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 376307e..5f5ff03 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.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] 23+ messages in thread

* [PATCH v8 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (14 preceding siblings ...)
  2016-09-29  1:19 ` [PATCH v8 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ Shannon Zhao
@ 2016-09-29  1:19 ` Shannon Zhao
  2016-09-29  9:59   ` Wei Liu
  2016-09-30 11:10 ` [PATCH v8 00/16] Xen ARM DomU ACPI support Wei Liu
  16 siblings, 1 reply; 23+ messages in thread
From: Shannon Zhao @ 2016-09-29  1:19 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, ian.jackson, julien.grall, Shannon Zhao,
	zhaoshenglong, boris.ostrovsky

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.c             | 45 ++++++++++++++++++++++++++++++++---------
 tools/libxl/libxl_arch.h        |  5 +++++
 tools/libxl/libxl_arm.c         | 20 ++++++++++++++++++
 tools/libxl/libxl_arm.h         |  5 +++++
 tools/libxl/libxl_arm_acpi.c    | 23 +++++++++++++++++++++
 tools/libxl/libxl_arm_no_acpi.c |  7 +++++++
 tools/libxl/libxl_dom.c         | 11 ++++++++--
 tools/libxl/libxl_internal.h    |  2 ++
 tools/libxl/libxl_x86.c         |  9 +++++++++
 9 files changed, 116 insertions(+), 11 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 997d94c..a46b827 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -17,6 +17,7 @@
 #include "libxl_osdeps.h"
 
 #include "libxl_internal.h"
+#include "libxl_arch.h"
 
 #define PAGE_TO_MEMKB(pages) ((pages) * 4)
 #define BACKEND_STRING_SIZE 5
@@ -4022,10 +4023,11 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
 {
     GC_INIT(ctx);
     char *mem, *endptr;
-    uint64_t memorykb;
+    uint64_t memorykb, size;
     char *dompath = libxl__xs_get_dompath(gc, domid);
     int rc = 1;
     libxl__domain_userdata_lock *lock = NULL;
+    libxl_domain_config d_config;
 
     CTX_LOCK;
 
@@ -4051,11 +4053,24 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
              "memory_static_max must be greater than or or equal to memory_dynamic_max");
         goto out;
     }
-    rc = xc_domain_setmaxmem(ctx->xch, domid, max_memkb + LIBXL_MAXMEM_CONSTANT);
+
+    rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config);
+    if (rc < 0) {
+        LOGE(ERROR, "unable to retrieve domain configuration");
+        goto out;
+    }
+
+    rc = libxl__arch_extra_memory(gc, &d_config.b_info, &size);
+    if (rc < 0) {
+        LOGE(ERROR, "Couldn't get arch extra constant memory size");
+        goto out;
+    }
+
+    rc = xc_domain_setmaxmem(ctx->xch, domid, max_memkb + size);
     if (rc != 0) {
         LOGE(ERROR,
              "xc_domain_setmaxmem domid=%d memkb=%"PRIu64" failed ""rc=%d\n",
-             domid, max_memkb + LIBXL_MAXMEM_CONSTANT, rc);
+             domid, max_memkb + size, rc);
         goto out;
     }
 
@@ -4149,7 +4164,7 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid,
 {
     GC_INIT(ctx);
     int rc, r, lrc, abort_transaction = 0;
-    uint64_t memorykb;
+    uint64_t memorykb, size;
     uint64_t videoram = 0;
     uint64_t current_target_memkb = 0, new_target_memkb = 0;
     uint64_t current_max_memkb = 0;
@@ -4160,6 +4175,7 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid,
     char *uuid;
     xs_transaction_t t;
     libxl__domain_userdata_lock *lock;
+    libxl_domain_config d_config;
 
     CTX_LOCK;
 
@@ -4169,6 +4185,18 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid,
         goto out_no_transaction;
     }
 
+    rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config);
+    if (rc < 0) {
+        LOGE(ERROR, "unable to retrieve domain configuration");
+        goto out_no_transaction;
+    }
+
+    rc = libxl__arch_extra_memory(gc, &d_config.b_info, &size);
+    if (rc < 0) {
+        LOGE(ERROR, "Couldn't get arch extra constant memory size");
+        goto out_no_transaction;
+    }
+
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
 
@@ -4246,13 +4274,12 @@ retry_transaction:
 
     if (enforce) {
         memorykb = new_target_memkb + videoram;
-        r = xc_domain_setmaxmem(ctx->xch, domid, memorykb +
-                LIBXL_MAXMEM_CONSTANT);
+        r = xc_domain_setmaxmem(ctx->xch, domid, memorykb + size);
         if (r != 0) {
             LOGE(ERROR,
                  "xc_domain_setmaxmem domid=%u memkb=%"PRIu64" failed ""rc=%d\n",
                  domid,
-                 memorykb + LIBXL_MAXMEM_CONSTANT,
+                 memorykb + size,
                  r);
             abort_transaction = 1;
             rc = ERROR_FAIL;
@@ -4261,12 +4288,12 @@ retry_transaction:
     }
 
     r = xc_domain_set_pod_target(ctx->xch, domid,
-            (new_target_memkb + LIBXL_MAXMEM_CONSTANT) / 4, NULL, NULL, NULL);
+            (new_target_memkb + size) / 4, NULL, NULL, NULL);
     if (r != 0) {
         LOGE(ERROR,
              "xc_domain_set_pod_target domid=%d, memkb=%"PRIu64" failed rc=%d\n",
              domid,
-             new_target_memkb / 4,
+             (new_target_memkb + size) / 4,
              r);
         abort_transaction = 1;
         rc = ERROR_FAIL;
diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
index fff0554..5e1fc60 100644
--- a/tools/libxl/libxl_arch.h
+++ b/tools/libxl/libxl_arch.h
@@ -66,6 +66,11 @@ _hidden
 void libxl__arch_domain_build_info_acpi_setdefault(
                                         libxl_domain_build_info *b_info);
 
+_hidden
+int libxl__arch_extra_memory(libxl__gc *gc,
+                             const libxl_domain_build_info *info,
+                             uint64_t *out);
+
 #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 5f5ff03..d842d88 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -106,6 +106,26 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
     return 0;
 }
 
+int libxl__arch_extra_memory(libxl__gc *gc,
+                             const libxl_domain_build_info *info,
+                             uint64_t *out)
+{
+    int rc = 0;
+    uint64_t size = 0;
+
+    if (libxl_defbool_val(info->acpi)) {
+        rc = libxl__get_acpi_size(gc, info, &size);
+        if (rc < 0) {
+            rc = ERROR_FAIL;
+            goto out;
+        }
+    }
+
+    *out = LIBXL_MAXMEM_CONSTANT + DIV_ROUNDUP(size, 1024);
+out:
+    return rc;
+}
+
 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 7097def..8aef210 100644
--- a/tools/libxl/libxl_arm.h
+++ b/tools/libxl/libxl_arm.h
@@ -23,6 +23,11 @@ _hidden
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         struct xc_dom_image *dom);
 
+_hidden
+int libxl__get_acpi_size(libxl__gc *gc,
+                         const libxl_domain_build_info *info,
+                         uint64_t *out);
+
 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 6c713ac..db113db 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -94,6 +94,29 @@ static int libxl__estimate_madt_size(libxl__gc *gc,
     return rc;
 }
 
+int libxl__get_acpi_size(libxl__gc *gc,
+                         const libxl_domain_build_info *info,
+                         uint64_t *out)
+{
+    uint64_t size;
+    int rc = 0;
+
+
+    rc = libxl__estimate_madt_size(gc, info, &size);
+    if (rc < 0)
+        goto out;
+
+    *out = 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 rc;
+}
+
 static int libxl__allocate_acpi_tables(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 88ebbb6..5dde0cd 100644
--- a/tools/libxl/libxl_arm_no_acpi.c
+++ b/tools/libxl/libxl_arm_no_acpi.c
@@ -24,6 +24,13 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     return ERROR_FAIL;
 }
 
+int libxl__get_acpi_size(libxl__gc *gc,
+                         const libxl_domain_build_info *info,
+                         uint64_t *out)
+{
+    return ERROR_FAIL;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index 2924629..d519c8d 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -302,6 +302,7 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
     libxl_ctx *ctx = libxl__gc_owner(gc);
     char *xs_domid, *con_domid;
     int rc;
+    uint64_t size;
 
     if (xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus) != 0) {
         LOG(ERROR, "Couldn't set max vcpu count");
@@ -408,8 +409,14 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
         }
     }
 
-    if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
-        LIBXL_MAXMEM_CONSTANT) < 0) {
+
+    rc = libxl__arch_extra_memory(gc, info, &size);
+    if (rc < 0) {
+        LOGE(ERROR, "Couldn't get arch extra constant memory size");
+        return ERROR_FAIL;
+    }
+
+    if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + size) < 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 84493df..e1844c8 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -359,6 +359,15 @@ out:
     return ret;
 }
 
+int libxl__arch_extra_memory(libxl__gc *gc,
+                             const libxl_domain_build_info *info,
+                             uint64_t *out)
+{
+    *out = LIBXL_MAXMEM_CONSTANT;
+
+    return 0;
+}
+
 int libxl__arch_domain_init_hw_description(libxl__gc *gc,
                                            libxl_domain_build_info *info,
                                            libxl__domain_build_state *state,
-- 
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] 23+ messages in thread

* Re: [PATCH v8 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI
  2016-09-29  1:19 ` [PATCH v8 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI Shannon Zhao
@ 2016-09-29  7:13   ` Jan Beulich
  2016-09-29  9:49     ` Wei Liu
  0 siblings, 1 reply; 23+ messages in thread
From: Jan Beulich @ 2016-09-29  7:13 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, wei.liu2, Andrew Cooper, ian.jackson, xen-devel,
	julien.grall, zhaoshenglong, boris.ostrovsky

>>> On 29.09.16 at 03:19, <shannon.zhao@linaro.org> wrote:
> 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>

Acked-by: Jan Beulich <jbeulich@suse.com>

> ---

But you should have placed a note to the committer here that this
patch depends on the one introducing xen_mk_ullong() (as that
isn't part of your series).

Jan


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

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

* Re: [PATCH v8 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI
  2016-09-29  7:13   ` Jan Beulich
@ 2016-09-29  9:49     ` Wei Liu
  0 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2016-09-29  9:49 UTC (permalink / raw)
  To: Jan Beulich
  Cc: sstabellini, wei.liu2, Andrew Cooper, ian.jackson, xen-devel,
	julien.grall, Shannon Zhao, zhaoshenglong, boris.ostrovsky

On Thu, Sep 29, 2016 at 01:13:26AM -0600, Jan Beulich wrote:
> >>> On 29.09.16 at 03:19, <shannon.zhao@linaro.org> wrote:
> > 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>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>
> 
> > ---
> 
> But you should have placed a note to the committer here that this
> patch depends on the one introducing xen_mk_ullong() (as that
> isn't part of your series).
> 

Noted, thanks for the heads-up.

Wei.

> Jan
> 

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

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

* Re: [PATCH v8 04/16] libxl/arm: Estimate the size of ACPI tables
  2016-09-29  1:18 ` [PATCH v8 04/16] libxl/arm: Estimate the size of ACPI tables Shannon Zhao
@ 2016-09-29  9:59   ` Wei Liu
  0 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2016-09-29  9:59 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, wei.liu2, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, boris.ostrovsky

On Wed, Sep 28, 2016 at 06:18:50PM -0700, Shannon Zhao wrote:
> Estimate the size of ACPI tables and reserve a memory map space for ACPI
> tables.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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

Thanks for the quick turnaround.

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

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

* Re: [PATCH v8 16/16] libxl/arm: Add the size of ACPI tables to maxmem
  2016-09-29  1:19 ` [PATCH v8 16/16] libxl/arm: Add the size of ACPI tables to maxmem Shannon Zhao
@ 2016-09-29  9:59   ` Wei Liu
  0 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2016-09-29  9:59 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, wei.liu2, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, boris.ostrovsky

On Wed, Sep 28, 2016 at 06:19:02PM -0700, Shannon Zhao wrote:
> 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>

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] 23+ messages in thread

* Re: [PATCH v8 03/16] libxl/arm: Generate static ACPI DSDT table
  2016-09-29  1:18 ` [PATCH v8 03/16] libxl/arm: Generate static ACPI DSDT table Shannon Zhao
@ 2016-09-30 11:09   ` Wei Liu
  0 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2016-09-30 11:09 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, wei.liu2, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, boris.ostrovsky

On Wed, Sep 28, 2016 at 06:18:49PM -0700, Shannon Zhao wrote:
> 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 +-

Please add a note in the future to ask committers to run autogen.sh.

>  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 5724ace..794c615 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 65a540e..2502d53 100644
> --- a/tools/libacpi/Makefile
> +++ b/tools/libacpi/Makefile
> @@ -19,6 +19,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

This doesn't build on x86.

I wrote the following patch to fix that. Tested on both x86 and ARM.

From 63bd22a110730310deba5abf81e82ffb43182932 Mon Sep 17 00:00:00 2001
From: Wei Liu <wei.liu2@citrix.com>
Date: Fri, 30 Sep 2016 11:26:36 +0100
Subject: [PATCH] fixup! libxl/arm: Generate static ACPI DSDT table

---
 tools/libacpi/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
index 2502d53..db7a3a9 100644
--- a/tools/libacpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -18,8 +18,8 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
 
 C_SRC-$(GPL) = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
+C_SRC-$(CONFIG_ARM) = $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.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)
 
 # Suffix for temporary files.
-- 
2.1.4


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

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

* Re: [PATCH v8 00/16] Xen ARM DomU ACPI support
  2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
                   ` (15 preceding siblings ...)
  2016-09-29  1:19 ` [PATCH v8 16/16] libxl/arm: Add the size of ACPI tables to maxmem Shannon Zhao
@ 2016-09-30 11:10 ` Wei Liu
  16 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2016-09-30 11:10 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: sstabellini, wei.liu2, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, boris.ostrovsky

This series is now pushed. Thanks for all your work to make this happen.

Please keep an eye on related bug reports and patches.

Wei.

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

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

end of thread, other threads:[~2016-09-30 11:10 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-29  1:18 [PATCH v8 00/16] Xen ARM DomU ACPI support Shannon Zhao
2016-09-29  1:18 ` [PATCH v8 01/16] tools/libxl: Add an unified configuration option for ACPI Shannon Zhao
2016-09-29  1:18 ` [PATCH v8 02/16] libxl/arm: prepare for constructing ACPI tables Shannon Zhao
2016-09-29  1:18 ` [PATCH v8 03/16] libxl/arm: Generate static ACPI DSDT table Shannon Zhao
2016-09-30 11:09   ` Wei Liu
2016-09-29  1:18 ` [PATCH v8 04/16] libxl/arm: Estimate the size of ACPI tables Shannon Zhao
2016-09-29  9:59   ` Wei Liu
2016-09-29  1:18 ` [PATCH v8 05/16] libxl/arm: Construct ACPI RSDP table Shannon Zhao
2016-09-29  1:18 ` [PATCH v8 06/16] libxl/arm: Construct ACPI XSDT table Shannon Zhao
2016-09-29  1:18 ` [PATCH v8 07/16] libxl/arm: Construct ACPI GTDT table Shannon Zhao
2016-09-29  1:18 ` [PATCH v8 08/16] libxl/arm: Factor MPIDR computing codes out as a helper Shannon Zhao
2016-09-29  1:18 ` [PATCH v8 09/16] libxl/arm: Construct ACPI MADT table Shannon Zhao
2016-09-29  1:18 ` [PATCH v8 10/16] libxl/arm: Construct ACPI FADT table Shannon Zhao
2016-09-29  1:18 ` [PATCH v8 11/16] libxl/arm: Construct ACPI DSDT table Shannon Zhao
2016-09-29  1:18 ` [PATCH v8 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function Shannon Zhao
2016-09-29  1:18 ` [PATCH v8 13/16] libxl/arm: Add ACPI module Shannon Zhao
2016-09-29  1:19 ` [PATCH v8 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI Shannon Zhao
2016-09-29  7:13   ` Jan Beulich
2016-09-29  9:49     ` Wei Liu
2016-09-29  1:19 ` [PATCH v8 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ Shannon Zhao
2016-09-29  1:19 ` [PATCH v8 16/16] libxl/arm: Add the size of ACPI tables to maxmem Shannon Zhao
2016-09-29  9:59   ` Wei Liu
2016-09-30 11:10 ` [PATCH v8 00/16] Xen ARM DomU ACPI support Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.